biosig-2.3.3/0000775000175000017500000000000014105434245013161 5ustar schloeglschloeglbiosig-2.3.3/tools/0000775000175000017500000000000014105434233014316 5ustar schloeglschloeglbiosig-2.3.3/tools/template.vmrk0000775000175000017500000000104714105434233017037 0ustar schloeglschloeglBrain Vision Data Exchange Marker File, Version 1.0 [Common Infos] Codepage=UTF-8 DataFile=template.dat [Marker Infos] ; Each entry: Mk=,,, ; , ; Fields are delimited by commas, some fields might be omitted (empty). ; Commas in type or description text are coded as "\1". Mk1=New Segment,,1,1,0,20100210192602835395 Mk2=Stimulus,S 1,4297,1,0 Mk3=Stimulus,S 6,4561,1,0 Mk4=Stimulus,S 2,6827,1,0 biosig-2.3.3/tools/template.vhdr0000775000175000017500000000134614105434233017025 0ustar schloeglschloeglBrain Vision Data Exchange Header File Version 1.0 ; Data created by generate_vhdr.sh [Common Infos] Codepage=UTF-8 DataFile=template.dat # MarkerFile=template.vmrk DataFormat=BINARY ; Data orientation: MULTIPLEXED=ch1,pt1, ch2,pt1 ... DataOrientation=MULTIPLEXED NumberOfChannels=6 ; Sampling interval in microseconds SamplingInterval=200 [Binary Infos] BinaryFormat=INT_16 [Channel Infos] ; Each entry: Ch=,, ; ,, Future extensions.. ; Fields are delimited by commas, some fields might be omitted (empty). ; Commas in channel names are coded as "\1". CH1=0,,0.39,uV CH2=1,,0.39,uV CH3=2,,0.39,uV CH4=3,,0.39,uV CH5=4,,0.39,uV CH6=5,,0.39,uV biosig-2.3.3/tools/biosig_vhdr_generator.sh0000775000175000017500000000377114105434233021232 0ustar schloeglschloegl#!/bin/bash # # Generate vhdr header files from a template *.vhdr file # This is a simple way make flat binary files readable by Biosig # tools (including SigViewer, Stimfit, etc). # Add known sampling interval, number of channels, and data type in # template file; optionally, you can also define channel labels, # scaling factors and physical units, and then apply this to a large # set of flat binary files with same setting. # The template.vhdr (and template.vmrk) are self-explaining. # # Usage: # biosig_vhdr_generator.sh template.vhdr *.dat # # *.dat file names are expanded and corresponding # *.vhdr files are generated based on template.vhdr. # # # Copyright (C) 2020 Alois Schloegl # This file is part of BioSig http://biosig.sourceforge.io/ # # BioSig 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 3 # of the License, 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, see . # TEMPLATE=$1 shift FILELIST=$* for F in $FILELIST; do OUTFILE="${F%.*}.vhdr" if [ -f "${OUTFILE}" ]; then echo "File ${OUTFILE} exists already - delete it first before you can regenerate ${OUTFILE} " else # sed s/DataFile=.*$/DataFile=${F}/g $TEMPLATE > ${F%.*}.vhdr sed -e 's/DataFile=.*$/DataFile='${F}'/g' -e 's/MarkerFile=.*/MarkerFile='${F%.*}'.vmrk/g' $TEMPLATE > ${OUTFILE} fi # this would generate also Marker file from an template - but this is hardly useful # sed 's/DataFile=.*$/DataFile='${F}'/' ${TEMPLATE%.*}.vmrk >${F%.*}.vmrk done biosig-2.3.3/Makefile.in0000664000175000017500000001142314105434233015224 0ustar schloeglschloegl####### Main Makefile for building the various biosig tools #################### ### ### Copyright (C) 2010-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ################################################################################ exec_prefix ?= $(prefix) first :: lib tools java: lib $(MAKE) -C biosig4c++/java lib: $(MAKE) -C biosig4c++ lib tools: lib $(MAKE) -C biosig4c++ tools mma mathematica: lib $(MAKE) -C biosig4c++/mma mex4m matlab: lib $(MAKE) -C biosig4c++/mex mex4m R: lib $(MAKE) -C biosig4c++/R install :: $(MAKE) -C biosig4c++ install install -d $(DESTDIR)@prefix@/share/biosig/matlab cp -r biosig4matlab/* $(DESTDIR)@prefix@/share/biosig/matlab/ -rm -rf $(DESTDIR)@prefix@/share/biosig/matlab/maybe-missing uninstall :: $(MAKE) -C biosig4c++ uninstall -rm -rf $(DESTDIR)@prefix@/share/biosig clean :: $(MAKE) -C biosig4c++/mma clean $(MAKE) -C biosig4c++ clean -rm mexbiosig*.src.tar.gz -rm biosig4octave*.src.tar.gz distclean : clean # also configure.ac for list of files -rm config.log -rm config.status rm Makefile biosig4c++/Makefile biosig4c++/*/Makefile \ biosig4c++/python/setup.py \ biosig4c++/R/DESCRIPTION ifneq (:,@JAVA@) ifneq (:,@JAVAC@) first :: lib -$(MAKE) -C biosig4c++/java endif clean :: -$(MAKE) -C biosig4c++/java clean test :: -$(MAKE) -C biosig4c++/java test endif ifneq (:,@MATHEMATICA@) first :: lib $(MAKE) -C biosig4c++/mma install :: -$(MAKE) -C biosig4c++/mma install uninstall :: -$(MAKE) -C biosig4c++/mma uninstall endif ifneq (:,@MATLAB@) MATLAB_MEX := $(shell dirname @MATLAB@)/mex first :: $(MAKE) -C biosig4c++/mex mex4m install :: $(MAKE) -C biosig4c++/mex install uninstall :: $(MAKE) -C biosig4c++/mex uninstall endif # source package mexbiosig and biosig4octave first :: biosig4octave mexbiosig :: $(MAKE) -C biosig4c++ mexbiosig ln -sf biosig4c++/mex/mexbiosig-@PACKAGE_VERSION@.src.tar.gz biosig4octave :: $(MAKE) -C biosig4c++ biosig4octave ln -sf biosig4c++/mex/biosig4octave-@PACKAGE_VERSION@.src.tar.gz ifneq (:,@OCTAVE@) ifneq (:,@MKOCTFILE@) BIOSIG_MEX_DIR = $(DESTDIR)$(shell octave-config -p LOCALOCTFILEDIR)/biosig BIOSIG_DIR = $(DESTDIR)$(shell octave-config -p LOCALFCNFILEDIR)/biosig first :: MKOCTFILE="@MKOCTFILE@" $(MAKE) -C biosig4c++/mex mex4o install :: # mexbiosig #-@OCTAVE@ --no-gui --eval "pkg install -global biosig4c++/mex/mexbiosig-@PACKAGE_VERSION@.src.tar.gz" # *.mex install -d $(BIOSIG_MEX_DIR) install biosig4c++/mex/*.mex $(BIOSIG_MEX_DIR) # biosig for octave and matlab install -d $(BIOSIG_DIR) cp -r biosig4matlab/* $(BIOSIG_DIR) -rm -rf $(BIOSIG_DIR)/maybe-missing uninstall :: # mexbiosig #-@OCTAVE@ --no-gui --eval "pkg uninstall -global mexbiosig" # *.mex -rm -rf $(BIOSIG_MEX_DIR) # biosig for octave and matlab -rm -rf $(BIOSIG_DIR) endif endif ifneq (:,@PHP@) first :: -$(MAKE) -C biosig4c++/php install :: -$(MAKE) -C biosig4c++/php install clean :: -$(MAKE) -C biosig4c++/php clean endif ifneq (:,@PYTHON3@) first :: python python :: -PYTHON=@PYTHON3@ $(MAKE) -C biosig4c++/python sdist -$(foreach py, $(shell pyversions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python build; ) -$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python build; ) install :: -PYTHON=@PYTHON3@ $(MAKE) -C biosig4c++/python install -$(foreach py, $(shell pyversions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python install; ) -$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python install; ) uninstall :: -@PYTHON3@ -m pip uninstall -y Biosig -$(foreach py, $(shell pyversions -i), $(py) -m pip uninstall -y Biosig;) -$(foreach py, $(shell py3versions -i), $(py) -m pip uninstall -y Biosig;) clean :: $(MAKE) -C biosig4c++/python clean endif ifneq (:,@R@) first :: -$(MAKE) -C biosig4c++/R build install :: -$(MAKE) -C biosig4c++/R install clean :: -$(MAKE) -C biosig4c++/R clean endif all: first #win32 win64 #sigviewer #win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer #---- automatic remaking ---------------------------------------------------# # https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Automatic-Remaking.html#Automatic-Remaking #---------------------------------------------------------------------------# $(srcdir)/configure: configure.ac aclocal.m4 autoconf # autoheader might not change config.h.in, so touch a stamp file. $(srcdir)/config.h.in: stamp-h.in $(srcdir)/stamp-h.in: configure.ac aclocal.m4 autoheader echo timestamp > '$(srcdir)/stamp-h.in' config.h: stamp-h stamp-h: config.h.in config.status ./config.status Makefile: Makefile.in config.status ./config.status config.status: configure ./config.status --recheck biosig-2.3.3/config.log0000664000175000017500000024622614105434245015145 0ustar schloeglschloeglThis file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by biosig configure 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ ./configure ## --------- ## ## Platform. ## ## --------- ## hostname = platon uname -m = x86_64 uname -r = 5.10.0-8-amd64 uname -s = Linux uname -v = #1 SMP Debian 5.10.46-4 (2021-08-03) /usr/bin/uname -p = unknown /bin/uname -X = unknown /bin/arch = unknown /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = unknown /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown PATH: /usr/local/bin PATH: /usr/bin PATH: /bin PATH: /usr/local/games PATH: /usr/games ## ----------- ## ## Core tests. ## ## ----------- ## configure:2421: checking for gcc configure:2437: found /usr/bin/gcc configure:2448: result: gcc configure:2677: checking for C compiler version configure:2686: gcc --version >&5 gcc (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:2697: $? = 0 configure:2686: gcc -v >&5 Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6) configure:2697: $? = 0 configure:2686: gcc -V >&5 gcc: error: unrecognized command line option '-V' gcc: fatal error: no input files compilation terminated. configure:2697: $? = 1 configure:2686: gcc -qversion >&5 gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? gcc: fatal error: no input files compilation terminated. configure:2697: $? = 1 configure:2717: checking whether the C compiler works configure:2739: gcc conftest.c >&5 configure:2743: $? = 0 configure:2791: result: yes configure:2794: checking for C compiler default output file name configure:2796: result: a.out configure:2802: checking for suffix of executables configure:2809: gcc -o conftest conftest.c >&5 configure:2813: $? = 0 configure:2835: result: configure:2857: checking whether we are cross compiling configure:2865: gcc -o conftest conftest.c >&5 configure:2869: $? = 0 configure:2876: ./conftest configure:2880: $? = 0 configure:2868: result: no configure:2873: checking for suffix of object files configure:2895: gcc -c conftest.c >&5 configure:2899: $? = 0 configure:2920: result: o configure:2924: checking whether we are using the GNU C compiler configure:2943: gcc -c conftest.c >&5 configure:2943: $? = 0 configure:2952: result: yes configure:2961: checking whether gcc accepts -g configure:2981: gcc -c -g conftest.c >&5 configure:2981: $? = 0 configure:3022: result: yes configure:3039: checking for gcc option to accept ISO C89 configure:3102: gcc -c -g -O2 conftest.c >&5 configure:3102: $? = 0 configure:3115: result: none needed configure:3141: checking how to run the C preprocessor configure:3172: gcc -E conftest.c configure:3172: $? = 0 configure:3186: gcc -E conftest.c conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory #include ^~~~~~~~~~~~~~~~~~ compilation terminated. configure:3186: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | /* end confdefs.h. */ | #include configure:3211: result: gcc -E configure:3231: gcc -E conftest.c configure:3231: $? = 0 configure:3245: gcc -E conftest.c conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory #include ^~~~~~~~~~~~~~~~~~ compilation terminated. configure:3245: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | /* end confdefs.h. */ | #include configure:3274: checking for grep that handles long lines and -e configure:3332: result: /bin/grep configure:3337: checking for egrep configure:3399: result: /bin/grep -E configure:3404: checking for ANSI C header files configure:3424: gcc -c -g -O2 conftest.c >&5 configure:3424: $? = 0 configure:3497: gcc -o conftest -g -O2 conftest.c >&5 configure:3497: $? = 0 configure:3497: ./conftest configure:3497: $? = 0 configure:3508: result: yes configure:3521: checking for sys/types.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for sys/stat.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for stdlib.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for string.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for memory.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for strings.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for inttypes.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for stdint.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3521: checking for unistd.h configure:3521: gcc -c -g -O2 conftest.c >&5 configure:3521: $? = 0 configure:3521: result: yes configure:3534: checking minix/config.h usability configure:3534: gcc -c -g -O2 conftest.c >&5 conftest.c:52:10: fatal error: minix/config.h: No such file or directory #include ^~~~~~~~~~~~~~~~ compilation terminated. configure:3534: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | #include configure:3534: result: no configure:3534: checking minix/config.h presence configure:3534: gcc -E conftest.c conftest.c:19:10: fatal error: minix/config.h: No such file or directory #include ^~~~~~~~~~~~~~~~ compilation terminated. configure:3534: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | /* end confdefs.h. */ | #include configure:3534: result: no configure:3534: checking for minix/config.h configure:3534: result: no configure:3555: checking whether it is safe to define __EXTENSIONS__ configure:3573: gcc -c -g -O2 conftest.c >&5 configure:3573: $? = 0 configure:3580: result: yes configure:3654: checking for g++ configure:3670: found /usr/bin/g++ configure:3681: result: g++ configure:3708: checking for C++ compiler version configure:3717: g++ --version >&5 g++ (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:3728: $? = 0 configure:3717: g++ -v >&5 Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6) configure:3728: $? = 0 configure:3717: g++ -V >&5 g++: error: unrecognized command line option '-V' g++: fatal error: no input files compilation terminated. configure:3728: $? = 1 configure:3717: g++ -qversion >&5 g++: error: unrecognized command line option '-qversion'; did you mean '--version'? g++: fatal error: no input files compilation terminated. configure:3728: $? = 1 configure:3732: checking whether we are using the GNU C++ compiler configure:3751: g++ -c conftest.cpp >&5 configure:3751: $? = 0 configure:3760: result: yes configure:3769: checking whether g++ accepts -g configure:3789: g++ -c -g conftest.cpp >&5 configure:3789: $? = 0 configure:3830: result: yes configure:3857: checking for gawk configure:3873: found /usr/bin/gawk configure:3884: result: gawk configure:3943: checking for gcc configure:3970: result: gcc configure:4199: checking for C compiler version configure:4208: gcc --version >&5 gcc (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:4219: $? = 0 configure:4208: gcc -v >&5 Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6) configure:4219: $? = 0 configure:4208: gcc -V >&5 gcc: error: unrecognized command line option '-V' gcc: fatal error: no input files compilation terminated. configure:4219: $? = 1 configure:4208: gcc -qversion >&5 gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? gcc: fatal error: no input files compilation terminated. configure:4219: $? = 1 configure:4223: checking whether we are using the GNU C compiler configure:4251: result: yes configure:4260: checking whether gcc accepts -g configure:4321: result: yes configure:4338: checking for gcc option to accept ISO C89 configure:4414: result: none needed configure:4477: checking for a BSD-compatible install configure:4545: result: /usr/bin/install -c configure:4556: checking whether ln -s works configure:4560: result: yes configure:4567: checking whether make sets $(MAKE) configure:4589: result: yes configure:4600: checking for snd_pcm_open in -lasound configure:4625: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:4625: $? = 0 configure:4634: result: yes configure:4645: checking for base64_encode_block in -lb64 configure:4670: gcc -o conftest -g -O2 conftest.c -lb64 -lasound >&5 configure:4670: $? = 0 configure:4679: result: yes configure:4686: checking for cholmod_start in -lcholmod configure:4711: gcc -o conftest -g -O2 conftest.c -lcholmod -lasound >&5 configure:4711: $? = 0 configure:4720: result: yes configure:4727: checking for dcmEnableOtherLongVRGeneration in -ldcmdata configure:4752: gcc -o conftest -g -O2 conftest.c -ldcmdata -lasound >&5 configure:4752: $? = 0 configure:4761: result: yes configure:4770: checking for gzopen in -lz configure:4795: gcc -o conftest -g -O2 conftest.c -lz -lasound >&5 configure:4795: $? = 0 configure:4804: result: yes configure:4825: checking for iconv_open in -liconv configure:4850: gcc -o conftest -g -O2 conftest.c -liconv -lasound >&5 /usr/bin/ld: cannot find -liconv collect2: error: ld returned 1 exit status configure:4850: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | /* end confdefs.h. */ | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char iconv_open (); | int | main () | { | return iconv_open (); | ; | return 0; | } configure:4859: result: no configure:4870: checking iconv.h usability configure:4870: gcc -c -g -O2 conftest.c >&5 configure:4870: $? = 0 configure:4870: result: yes configure:4870: checking iconv.h presence configure:4870: gcc -E conftest.c configure:4870: $? = 0 configure:4870: result: yes configure:4870: checking for iconv.h configure:4870: result: yes configure:4879: checking for main in -ltinyxml configure:4898: gcc -o conftest -g -O2 conftest.c -ltinyxml -lasound >&5 configure:4898: $? = 0 configure:4908: result: yes configure:4922: checking for java configure:4940: found /usr/bin/java configure:4953: result: /usr/bin/java configure:4963: checking for javac configure:4981: found /usr/bin/javac configure:4994: result: /usr/bin/javac configure:5005: checking for mathematica configure:5036: result: : configure:5046: checking for mprep configure:5077: result: : configure:5090: checking for matlab configure:5118: result: : configure:5128: checking for mkoctfile configure:5146: found /usr/bin/mkoctfile configure:5159: result: /usr/bin/mkoctfile configure:5169: checking for octave configure:5187: found /usr/bin/octave configure:5200: result: /usr/bin/octave configure:5211: checking for php configure:5242: result: : configure:5252: checking for pear configure:5283: result: : configure:5293: checking for pecl configure:5324: result: : configure:5335: checking for python configure:5353: found /usr/bin/python configure:5366: result: /usr/bin/python configure:5376: checking for python2 configure:5394: found /usr/bin/python2 configure:5407: result: /usr/bin/python2 configure:5417: checking for python3 configure:5435: found /usr/bin/python3 configure:5448: result: /usr/bin/python3 configure:5459: checking for R configure:5477: found /usr/bin/R configure:5490: result: /usr/bin/R configure:5500: checking for main in -llibmex configure:5519: gcc -o conftest -g -O2 conftest.c -llibmex -lasound >&5 /usr/bin/ld: cannot find -llibmex collect2: error: ld returned 1 exit status configure:5519: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | /* end confdefs.h. */ | | | int | main () | { | return main (); | ; | return 0; | } configure:5528: result: no configure:5540: checking for main in -llibmx configure:5559: gcc -o conftest -g -O2 conftest.c -llibmx -lasound >&5 /usr/bin/ld: cannot find -llibmx collect2: error: ld returned 1 exit status configure:5559: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | /* end confdefs.h. */ | | | int | main () | { | return main (); | ; | return 0; | } configure:5568: result: no configure:5580: checking for round in -lm configure:5605: gcc -o conftest -g -O2 conftest.c -lm -lasound >&5 conftest.c:32:6: warning: conflicting types for built-in function 'round' [-Wbuiltin-declaration-mismatch] char round (); ^~~~~ configure:5605: $? = 0 configure:5614: result: yes configure:5623: checking for MLPutRealArray in -lmathlink configure:5648: gcc -o conftest -g -O2 conftest.c -lmathlink -lasound >&5 /usr/bin/ld: cannot find -lmathlink collect2: error: ld returned 1 exit status configure:5648: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | /* end confdefs.h. */ | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char MLPutRealArray (); | int | main () | { | return MLPutRealArray (); | ; | return 0; | } configure:5657: result: no configure:5664: checking for uuid_generate in -luuid configure:5689: gcc -o conftest -g -O2 conftest.c -luuid -lasound >&5 configure:5689: $? = 0 configure:5698: result: yes configure:5711: checking for size_t configure:5711: gcc -c -g -O2 conftest.c >&5 configure:5711: $? = 0 configure:5711: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:61:21: error: expected expression before ')' token if (sizeof ((size_t))) ^ configure:5711: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((size_t))) | return 0; | ; | return 0; | } configure:5711: result: yes configure:5724: checking for working alloca.h configure:5741: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:5741: $? = 0 configure:5749: result: yes configure:5757: checking for alloca configure:5794: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:5794: $? = 0 configure:5802: result: yes configure:5911: checking arpa/inet.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking arpa/inet.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for arpa/inet.h configure:5911: result: yes configure:5911: checking fcntl.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking fcntl.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for fcntl.h configure:5911: result: yes configure:5911: checking float.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking float.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for float.h configure:5911: result: yes configure:5911: checking for inttypes.h configure:5911: result: yes configure:5911: checking limits.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking limits.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for limits.h configure:5911: result: yes configure:5911: checking locale.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking locale.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for locale.h configure:5911: result: yes configure:5911: checking malloc.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking malloc.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for malloc.h configure:5911: result: yes configure:5911: checking netdb.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking netdb.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for netdb.h configure:5911: result: yes configure:5911: checking netinet/in.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking netinet/in.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for netinet/in.h configure:5911: result: yes configure:5911: checking stddef.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking stddef.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for stddef.h configure:5911: result: yes configure:5911: checking for stdint.h configure:5911: result: yes configure:5911: checking for stdlib.h configure:5911: result: yes configure:5911: checking for string.h configure:5911: result: yes configure:5911: checking for strings.h configure:5911: result: yes configure:5911: checking sys/param.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking sys/param.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for sys/param.h configure:5911: result: yes configure:5911: checking sys/socket.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking sys/socket.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for sys/socket.h configure:5911: result: yes configure:5911: checking sys/time.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking sys/time.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for sys/time.h configure:5911: result: yes configure:5911: checking syslog.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking syslog.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for syslog.h configure:5911: result: yes configure:5911: checking termios.h usability configure:5911: gcc -c -g -O2 conftest.c >&5 configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking termios.h presence configure:5911: gcc -E conftest.c configure:5911: $? = 0 configure:5911: result: yes configure:5911: checking for termios.h configure:5911: result: yes configure:5911: checking for unistd.h configure:5911: result: yes configure:5923: checking for stdbool.h that conforms to C99 configure:5990: gcc -c -g -O2 conftest.c >&5 configure:5990: $? = 0 configure:5997: result: yes configure:5999: checking for _Bool configure:5999: gcc -c -g -O2 conftest.c >&5 configure:5999: $? = 0 configure:5999: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:83:20: error: expected expression before ')' token if (sizeof ((_Bool))) ^ configure:5999: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((_Bool))) | return 0; | ; | return 0; | } configure:5999: result: yes configure:6010: checking for inline configure:6026: gcc -c -g -O2 conftest.c >&5 configure:6026: $? = 0 configure:6034: result: inline configure:6052: checking for int16_t configure:6052: gcc -c -g -O2 conftest.c >&5 configure:6052: $? = 0 configure:6052: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:85:12: error: size of array 'test_array' is negative static int test_array [1 - 2 * !((int16_t) (((((int16_t) 1 << N) << N) - 1) * 2 + 1) ^~~~~~~~~~ configure:6052: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | enum { N = 16 / 2 - 1 }; | int | main () | { | static int test_array [1 - 2 * !((int16_t) (((((int16_t) 1 << N) << N) - 1) * 2 + 1) | < (int16_t) (((((int16_t) 1 << N) << N) - 1) * 2 + 2))]; | test_array [0] = 0; | return test_array [0]; | | ; | return 0; | } configure:6052: result: yes configure:6063: checking for int32_t configure:6063: gcc -c -g -O2 conftest.c >&5 configure:6063: $? = 0 configure:6063: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:86:53: warning: integer overflow in expression of type 'int' results in '-2147483648' [-Woverflow] < (int32_t) (((((int32_t) 1 << N) << N) - 1) * 2 + 2))]; ^ conftest.c:85:12: error: storage size of 'test_array' isn't constant static int test_array [1 - 2 * !((int32_t) (((((int32_t) 1 << N) << N) - 1) * 2 + 1) ^~~~~~~~~~ configure:6063: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | enum { N = 32 / 2 - 1 }; | int | main () | { | static int test_array [1 - 2 * !((int32_t) (((((int32_t) 1 << N) << N) - 1) * 2 + 1) | < (int32_t) (((((int32_t) 1 << N) << N) - 1) * 2 + 2))]; | test_array [0] = 0; | return test_array [0]; | | ; | return 0; | } configure:6063: result: yes configure:6074: checking for int64_t configure:6074: gcc -c -g -O2 conftest.c >&5 configure:6074: $? = 0 configure:6074: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:86:53: warning: integer overflow in expression of type 'long int' results in '-9223372036854775808' [-Woverflow] < (int64_t) (((((int64_t) 1 << N) << N) - 1) * 2 + 2))]; ^ conftest.c:85:12: error: storage size of 'test_array' isn't constant static int test_array [1 - 2 * !((int64_t) (((((int64_t) 1 << N) << N) - 1) * 2 + 1) ^~~~~~~~~~ configure:6074: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | enum { N = 64 / 2 - 1 }; | int | main () | { | static int test_array [1 - 2 * !((int64_t) (((((int64_t) 1 << N) << N) - 1) * 2 + 1) | < (int64_t) (((((int64_t) 1 << N) << N) - 1) * 2 + 2))]; | test_array [0] = 0; | return test_array [0]; | | ; | return 0; | } configure:6074: result: yes configure:6085: checking for int8_t configure:6085: gcc -c -g -O2 conftest.c >&5 configure:6085: $? = 0 configure:6085: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:85:12: error: size of array 'test_array' is negative static int test_array [1 - 2 * !((int8_t) (((((int8_t) 1 << N) << N) - 1) * 2 + 1) ^~~~~~~~~~ configure:6085: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | enum { N = 8 / 2 - 1 }; | int | main () | { | static int test_array [1 - 2 * !((int8_t) (((((int8_t) 1 << N) << N) - 1) * 2 + 1) | < (int8_t) (((((int8_t) 1 << N) << N) - 1) * 2 + 2))]; | test_array [0] = 0; | return test_array [0]; | | ; | return 0; | } configure:6085: result: yes configure:6096: checking for mode_t configure:6096: gcc -c -g -O2 conftest.c >&5 configure:6096: $? = 0 configure:6096: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:84:21: error: expected expression before ')' token if (sizeof ((mode_t))) ^ configure:6096: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((mode_t))) | return 0; | ; | return 0; | } configure:6096: result: yes configure:6107: checking for pid_t configure:6107: gcc -c -g -O2 conftest.c >&5 configure:6107: $? = 0 configure:6107: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:84:20: error: expected expression before ')' token if (sizeof ((pid_t))) ^ configure:6107: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((pid_t))) | return 0; | ; | return 0; | } configure:6107: result: yes configure:6118: checking for size_t configure:6118: result: yes configure:6129: checking for ssize_t configure:6129: gcc -c -g -O2 conftest.c >&5 configure:6129: $? = 0 configure:6129: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:84:22: error: expected expression before ')' token if (sizeof ((ssize_t))) ^ configure:6129: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((ssize_t))) | return 0; | ; | return 0; | } configure:6129: result: yes configure:6140: checking for uint16_t configure:6140: gcc -c -g -O2 conftest.c >&5 configure:6140: $? = 0 configure:6140: result: yes configure:6152: checking for uint32_t configure:6152: gcc -c -g -O2 conftest.c >&5 configure:6152: $? = 0 configure:6152: result: yes configure:6166: checking for uint64_t configure:6166: gcc -c -g -O2 conftest.c >&5 configure:6166: $? = 0 configure:6166: result: yes configure:6180: checking for uint8_t configure:6180: gcc -c -g -O2 conftest.c >&5 configure:6180: $? = 0 configure:6180: result: yes configure:6194: checking for ptrdiff_t configure:6194: gcc -c -g -O2 conftest.c >&5 configure:6194: $? = 0 configure:6194: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:84:24: error: expected expression before ')' token if (sizeof ((ptrdiff_t))) ^ configure:6194: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | int | main () | { | if (sizeof ((ptrdiff_t))) | return 0; | ; | return 0; | } configure:6194: result: yes configure:6206: checking for error_at_line configure:6222: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6222: $? = 0 configure:6230: result: yes configure:6243: checking vfork.h usability configure:6243: gcc -c -g -O2 conftest.c >&5 conftest.c:82:10: fatal error: vfork.h: No such file or directory #include ^~~~~~~~~ compilation terminated. configure:6243: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | #define HAVE_PTRDIFF_T 1 | /* end confdefs.h. */ | #include | #ifdef HAVE_SYS_TYPES_H | # include | #endif | #ifdef HAVE_SYS_STAT_H | # include | #endif | #ifdef STDC_HEADERS | # include | # include | #else | # ifdef HAVE_STDLIB_H | # include | # endif | #endif | #ifdef HAVE_STRING_H | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H | # include | # endif | # include | #endif | #ifdef HAVE_STRINGS_H | # include | #endif | #ifdef HAVE_INTTYPES_H | # include | #endif | #ifdef HAVE_STDINT_H | # include | #endif | #ifdef HAVE_UNISTD_H | # include | #endif | #include configure:6243: result: no configure:6243: checking vfork.h presence configure:6243: gcc -E conftest.c conftest.c:49:10: fatal error: vfork.h: No such file or directory #include ^~~~~~~~~ compilation terminated. configure:6243: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | #define HAVE_PTRDIFF_T 1 | /* end confdefs.h. */ | #include configure:6243: result: no configure:6243: checking for vfork.h configure:6243: result: no configure:6256: checking for fork configure:6256: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:72:6: warning: conflicting types for built-in function 'fork' [-Wbuiltin-declaration-mismatch] char fork (); ^~~~ configure:6256: $? = 0 configure:6256: result: yes configure:6256: checking for vfork configure:6256: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6256: $? = 0 configure:6256: result: yes configure:6266: checking for working fork configure:6288: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6288: $? = 0 configure:6288: ./conftest configure:6288: $? = 0 configure:6298: result: yes configure:6319: checking for working vfork configure:6429: result: yes configure:6456: checking for stdlib.h configure:6456: result: yes configure:6466: checking for GNU libc compatible malloc configure:6490: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6490: $? = 0 configure:6490: ./conftest configure:6490: $? = 0 configure:6500: result: yes configure:6521: checking whether time.h and sys/time.h may both be included configure:6541: gcc -c -g -O2 conftest.c >&5 configure:6541: $? = 0 configure:6548: result: yes configure:6562: checking for sys/time.h configure:6562: result: yes configure:6562: checking for unistd.h configure:6562: result: yes configure:6583: checking for alarm configure:6583: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6583: $? = 0 configure:6583: result: yes configure:6596: checking for working mktime configure:6798: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6798: $? = 0 configure:6798: ./conftest configure:6798: $? = 0 configure:6808: result: yes configure:6821: checking for stdlib.h configure:6821: result: yes configure:6831: checking for GNU libc compatible realloc configure:6855: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6855: $? = 0 configure:6855: ./conftest configure:6855: $? = 0 configure:6865: result: yes configure:6890: checking build system type configure:6904: result: x86_64-pc-linux-gnu configure:6924: checking host system type configure:6937: result: x86_64-pc-linux-gnu configure:6957: checking for working strnlen configure:6995: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:6995: $? = 0 configure:6995: ./conftest configure:6995: $? = 0 configure:7005: result: yes configure:7014: checking for working strtod configure:7055: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7055: $? = 0 configure:7055: ./conftest configure:7055: $? = 0 configure:7065: result: yes configure:7130: checking for alarm configure:7130: result: yes configure:7130: checking for atexit configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for bzero configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:86:6: warning: conflicting types for built-in function 'bzero' [-Wbuiltin-declaration-mismatch] char bzero (); ^~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for dup2 configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for floor configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:88:6: warning: conflicting types for built-in function 'floor' [-Wbuiltin-declaration-mismatch] char floor (); ^~~~~ /usr/bin/ld: /tmp/cc9hWBGY.o: undefined reference to symbol 'floor@@GLIBC_2.2.5' /usr/bin/ld: //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status configure:7130: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | #define HAVE_PTRDIFF_T 1 | #define HAVE_FORK 1 | #define HAVE_VFORK 1 | #define HAVE_WORKING_VFORK 1 | #define HAVE_WORKING_FORK 1 | #define HAVE_STDLIB_H 1 | #define HAVE_MALLOC 1 | #define TIME_WITH_SYS_TIME 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE_ALARM 1 | #define HAVE_STDLIB_H 1 | #define HAVE_REALLOC 1 | #define HAVE_ALARM 1 | #define HAVE_ATEXIT 1 | #define HAVE_BZERO 1 | #define HAVE_DUP2 1 | /* end confdefs.h. */ | /* Define floor to an innocuous variant, in case declares floor. | For example, HP-UX 11i declares gettimeofday. */ | #define floor innocuous_floor | | /* System header to define __stub macros and hopefully few prototypes, | which can conflict with char floor (); below. | Prefer to if __STDC__ is defined, since | exists even on freestanding compilers. */ | | #ifdef __STDC__ | # include | #else | # include | #endif | | #undef floor | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char floor (); | /* The GNU C library defines this for functions which it implements | to always fail with ENOSYS. Some functions are actually named | something starting with __ and the normal name is an alias. */ | #if defined __stub_floor || defined __stub___floor | choke me | #endif | | int | main () | { | return floor (); | ; | return 0; | } configure:7130: result: no configure:7130: checking for getcwd configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for getdelim configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for gethostbyname configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for gethostname configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for gettimeofday configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for localtime_r configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for memchr configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:94:6: warning: conflicting types for built-in function 'memchr' [-Wbuiltin-declaration-mismatch] char memchr (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for memmove configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:95:6: warning: conflicting types for built-in function 'memmove' [-Wbuiltin-declaration-mismatch] char memmove (); ^~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for memset configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:96:6: warning: conflicting types for built-in function 'memset' [-Wbuiltin-declaration-mismatch] char memset (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for mkdir configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for modf configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:98:6: warning: conflicting types for built-in function 'modf' [-Wbuiltin-declaration-mismatch] char modf (); ^~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for pow configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:99:6: warning: conflicting types for built-in function 'pow' [-Wbuiltin-declaration-mismatch] char pow (); ^~~ /usr/bin/ld: /tmp/ccacDbjJ.o: undefined reference to symbol 'pow@@GLIBC_2.2.5' /usr/bin/ld: //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status configure:7130: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "biosig" | #define PACKAGE_TARNAME "biosig" | #define PACKAGE_VERSION "2.3.3" | #define PACKAGE_STRING "biosig 2.3.3" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_MEMORY_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_UNISTD_H 1 | #define __EXTENSIONS__ 1 | #define _ALL_SOURCE 1 | #define _GNU_SOURCE 1 | #define _POSIX_PTHREAD_SEMANTICS 1 | #define _TANDEM_SOURCE 1 | #define HAVE_LIBASOUND 1 | #define HAVE_ALLOCA_H 1 | #define HAVE_ALLOCA 1 | #define HAVE_ARPA_INET_H 1 | #define HAVE_FCNTL_H 1 | #define HAVE_FLOAT_H 1 | #define HAVE_INTTYPES_H 1 | #define HAVE_LIMITS_H 1 | #define HAVE_LOCALE_H 1 | #define HAVE_MALLOC_H 1 | #define HAVE_NETDB_H 1 | #define HAVE_NETINET_IN_H 1 | #define HAVE_STDDEF_H 1 | #define HAVE_STDINT_H 1 | #define HAVE_STDLIB_H 1 | #define HAVE_STRING_H 1 | #define HAVE_STRINGS_H 1 | #define HAVE_SYS_PARAM_H 1 | #define HAVE_SYS_SOCKET_H 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_SYSLOG_H 1 | #define HAVE_TERMIOS_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE__BOOL 1 | #define HAVE_PTRDIFF_T 1 | #define HAVE_FORK 1 | #define HAVE_VFORK 1 | #define HAVE_WORKING_VFORK 1 | #define HAVE_WORKING_FORK 1 | #define HAVE_STDLIB_H 1 | #define HAVE_MALLOC 1 | #define TIME_WITH_SYS_TIME 1 | #define HAVE_SYS_TIME_H 1 | #define HAVE_UNISTD_H 1 | #define HAVE_ALARM 1 | #define HAVE_STDLIB_H 1 | #define HAVE_REALLOC 1 | #define HAVE_ALARM 1 | #define HAVE_ATEXIT 1 | #define HAVE_BZERO 1 | #define HAVE_DUP2 1 | #define HAVE_GETCWD 1 | #define HAVE_GETDELIM 1 | #define HAVE_GETHOSTBYNAME 1 | #define HAVE_GETHOSTNAME 1 | #define HAVE_GETTIMEOFDAY 1 | #define HAVE_LOCALTIME_R 1 | #define HAVE_MEMCHR 1 | #define HAVE_MEMMOVE 1 | #define HAVE_MEMSET 1 | #define HAVE_MKDIR 1 | #define HAVE_MODF 1 | /* end confdefs.h. */ | /* Define pow to an innocuous variant, in case declares pow. | For example, HP-UX 11i declares gettimeofday. */ | #define pow innocuous_pow | | /* System header to define __stub macros and hopefully few prototypes, | which can conflict with char pow (); below. | Prefer to if __STDC__ is defined, since | exists even on freestanding compilers. */ | | #ifdef __STDC__ | # include | #else | # include | #endif | | #undef pow | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char pow (); | /* The GNU C library defines this for functions which it implements | to always fail with ENOSYS. Some functions are actually named | something starting with __ and the normal name is an alias. */ | #if defined __stub_pow || defined __stub___pow | choke me | #endif | | int | main () | { | return pow (); | ; | return 0; | } configure:7130: result: no configure:7130: checking for putenv configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for rmdir configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for select configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for setenv configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for setlocale configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for socket configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strcasecmp configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:105:6: warning: conflicting types for built-in function 'strcasecmp' [-Wbuiltin-declaration-mismatch] char strcasecmp (); ^~~~~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strchr configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:106:6: warning: conflicting types for built-in function 'strchr' [-Wbuiltin-declaration-mismatch] char strchr (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strcspn configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:107:6: warning: conflicting types for built-in function 'strcspn' [-Wbuiltin-declaration-mismatch] char strcspn (); ^~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strdup configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:108:6: warning: conflicting types for built-in function 'strdup' [-Wbuiltin-declaration-mismatch] char strdup (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strerror configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strncasecmp configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:110:6: warning: conflicting types for built-in function 'strncasecmp' [-Wbuiltin-declaration-mismatch] char strncasecmp (); ^~~~~~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strndup configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:111:6: warning: conflicting types for built-in function 'strndup' [-Wbuiltin-declaration-mismatch] char strndup (); ^~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strpbrk configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:112:6: warning: conflicting types for built-in function 'strpbrk' [-Wbuiltin-declaration-mismatch] char strpbrk (); ^~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strrchr configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:113:6: warning: conflicting types for built-in function 'strrchr' [-Wbuiltin-declaration-mismatch] char strrchr (); ^~~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strspn configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:114:6: warning: conflicting types for built-in function 'strspn' [-Wbuiltin-declaration-mismatch] char strspn (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strstr configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 conftest.c:115:6: warning: conflicting types for built-in function 'strstr' [-Wbuiltin-declaration-mismatch] char strstr (); ^~~~~~ configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strtol configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strtoul configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for strtoumax configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7130: checking for tzset configure:7130: gcc -o conftest -g -O2 conftest.c -lasound >&5 configure:7130: $? = 0 configure:7130: result: yes configure:7249: creating ./config.status ## ---------------------- ## ## Running config.status. ## ## ---------------------- ## This file was extended by biosig config.status 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = CONFIG_HEADERS = CONFIG_LINKS = CONFIG_COMMANDS = $ ./config.status on platon config.status:933: creating Makefile config.status:933: creating biosig4c++/Makefile config.status:1036: WARNING: 'biosig4c++/Makefile.in' seems to ignore the --datarootdir setting config.status:933: creating biosig4c++/examples/Makefile config.status:933: creating biosig4c++/igor/Makefile config.status:933: creating biosig4c++/java/Makefile config.status:933: creating biosig4c++/magic/Makefile config.status:933: creating biosig4c++/mex/Makefile config.status:1036: WARNING: 'biosig4c++/mex/Makefile.in' seems to ignore the --datarootdir setting config.status:933: creating biosig4c++/mma/Makefile config.status:933: creating biosig4c++/perl/Makefile config.status:933: creating biosig4c++/php/Makefile config.status:933: creating biosig4c++/python/Makefile config.status:933: creating biosig4c++/python/setup.py config.status:933: creating biosig4c++/python/README.md config.status:933: creating biosig4c++/R/Makefile config.status:933: creating biosig4c++/R/DESCRIPTION config.status:933: creating biosig4c++/ruby/Makefile config.status:933: creating biosig4c++/t240/Makefile config.status:933: creating biosig4c++/t241/Makefile config.status:933: creating biosig4c++/tcl/Makefile config.status:933: creating config.h ## ---------------- ## ## Cache variables. ## ## ---------------- ## ac_cv_build=x86_64-pc-linux-gnu ac_cv_c_compiler_gnu=yes ac_cv_c_inline=inline ac_cv_c_int16_t=yes ac_cv_c_int32_t=yes ac_cv_c_int64_t=yes ac_cv_c_int8_t=yes ac_cv_c_uint16_t=yes ac_cv_c_uint32_t=yes ac_cv_c_uint64_t=yes ac_cv_c_uint8_t=yes ac_cv_cxx_compiler_gnu=yes ac_cv_env_CCC_set= ac_cv_env_CCC_value= ac_cv_env_CC_set= ac_cv_env_CC_value= ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set= ac_cv_env_CPPFLAGS_value= ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_CXXFLAGS_set= ac_cv_env_CXXFLAGS_value= ac_cv_env_CXX_set= ac_cv_env_CXX_value= ac_cv_env_LDFLAGS_set= ac_cv_env_LDFLAGS_value= ac_cv_env_LIBS_set= ac_cv_env_LIBS_value= ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set= ac_cv_env_host_alias_value= ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_func_alarm=yes ac_cv_func_alloca_works=yes ac_cv_func_atexit=yes ac_cv_func_bzero=yes ac_cv_func_dup2=yes ac_cv_func_floor=no ac_cv_func_fork=yes ac_cv_func_fork_works=yes ac_cv_func_getcwd=yes ac_cv_func_getdelim=yes ac_cv_func_gethostbyname=yes ac_cv_func_gethostname=yes ac_cv_func_gettimeofday=yes ac_cv_func_localtime_r=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_memchr=yes ac_cv_func_memmove=yes ac_cv_func_memset=yes ac_cv_func_mkdir=yes ac_cv_func_modf=yes ac_cv_func_pow=no ac_cv_func_putenv=yes ac_cv_func_realloc_0_nonnull=yes ac_cv_func_rmdir=yes ac_cv_func_select=yes ac_cv_func_setenv=yes ac_cv_func_setlocale=yes ac_cv_func_socket=yes ac_cv_func_strcasecmp=yes ac_cv_func_strchr=yes ac_cv_func_strcspn=yes ac_cv_func_strdup=yes ac_cv_func_strerror=yes ac_cv_func_strncasecmp=yes ac_cv_func_strndup=yes ac_cv_func_strnlen_working=yes ac_cv_func_strpbrk=yes ac_cv_func_strrchr=yes ac_cv_func_strspn=yes ac_cv_func_strstr=yes ac_cv_func_strtod=yes ac_cv_func_strtol=yes ac_cv_func_strtoul=yes ac_cv_func_strtoumax=yes ac_cv_func_tzset=yes ac_cv_func_vfork=yes ac_cv_func_vfork_works=yes ac_cv_func_working_mktime=yes ac_cv_header_arpa_inet_h=yes ac_cv_header_fcntl_h=yes ac_cv_header_float_h=yes ac_cv_header_iconv_h=yes ac_cv_header_inttypes_h=yes ac_cv_header_limits_h=yes ac_cv_header_locale_h=yes ac_cv_header_malloc_h=yes ac_cv_header_memory_h=yes ac_cv_header_minix_config_h=no ac_cv_header_netdb_h=yes ac_cv_header_netinet_in_h=yes ac_cv_header_stdbool_h=yes ac_cv_header_stdc=yes ac_cv_header_stddef_h=yes ac_cv_header_stdint_h=yes ac_cv_header_stdlib_h=yes ac_cv_header_string_h=yes ac_cv_header_strings_h=yes ac_cv_header_sys_param_h=yes ac_cv_header_sys_socket_h=yes ac_cv_header_sys_stat_h=yes ac_cv_header_sys_time_h=yes ac_cv_header_sys_types_h=yes ac_cv_header_syslog_h=yes ac_cv_header_termios_h=yes ac_cv_header_time=yes ac_cv_header_unistd_h=yes ac_cv_header_vfork_h=no ac_cv_host=x86_64-pc-linux-gnu ac_cv_lib_asound_snd_pcm_open=yes ac_cv_lib_b64_base64_encode_block=yes ac_cv_lib_cholmod_cholmod_start=yes ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration=yes ac_cv_lib_error_at_line=yes ac_cv_lib_iconv_iconv_open=no ac_cv_lib_libmex_main=no ac_cv_lib_libmx_main=no ac_cv_lib_m_round=yes ac_cv_lib_mathlink_MLPutRealArray=no ac_cv_lib_tinyxml____main=yes ac_cv_lib_uuid_uuid_generate=yes ac_cv_lib_z_gzopen=yes ac_cv_objext=o ac_cv_path_EGREP='/bin/grep -E' ac_cv_path_GREP=/bin/grep ac_cv_path_JAVA=/usr/bin/java ac_cv_path_JAVAC=/usr/bin/javac ac_cv_path_MATHEMATICA=: ac_cv_path_MATHEMATICA_MPREP=: ac_cv_path_MKOCTFILE=/usr/bin/mkoctfile ac_cv_path_OCTAVE=/usr/bin/octave ac_cv_path_PEAR=: ac_cv_path_PECL=: ac_cv_path_PHP=: ac_cv_path_PYTHON2=/usr/bin/python2 ac_cv_path_PYTHON3=/usr/bin/python3 ac_cv_path_PYTHON=/usr/bin/python ac_cv_path_R=/usr/bin/R ac_cv_path_install='/usr/bin/install -c' ac_cv_prog_AWK=gawk ac_cv_prog_CPP='gcc -E' ac_cv_prog_MATLAB=: ac_cv_prog_ac_ct_CC=gcc ac_cv_prog_ac_ct_CXX=g++ ac_cv_prog_cc_c89= ac_cv_prog_cc_g=yes ac_cv_prog_cxx_g=yes ac_cv_prog_make_make_set=yes ac_cv_safe_to_define___extensions__=yes ac_cv_type__Bool=yes ac_cv_type_mode_t=yes ac_cv_type_pid_t=yes ac_cv_type_ptrdiff_t=yes ac_cv_type_size_t=yes ac_cv_type_ssize_t=yes ac_cv_working_alloca_h=yes ## ----------------- ## ## Output variables. ## ## ----------------- ## ALLOCA='' AWK='gawk' CC='gcc' CFLAGS='-g -O2' CPP='gcc -E' CPPFLAGS='' CXX='g++' CXXFLAGS='-g -O2' DEFS='-DHAVE_CONFIG_H' ECHO_C='' ECHO_N='-n' ECHO_T='' EGREP='/bin/grep -E' EXEEXT='' GREP='/bin/grep' HAVE_LIBB64='1' HAVE_LIBCHOLMOD='1' HAVE_LIBDCMTK='1' HAVE_LIBM='1' HAVE_LIBTINYXML='1' HAVE_LIBZ='1' HAVE_MATHEMATICA='' HAVE_UUID='1' INSTALL_DATA='${INSTALL} -m 644' INSTALL_PROGRAM='${INSTALL}' INSTALL_SCRIPT='${INSTALL}' JAVA='/usr/bin/java' JAVAC='/usr/bin/javac' LDFLAGS='' LIBOBJS='' LIBS='-lasound ' LN_S='ln -s' LTLIBOBJS='' MATHEMATICA=':' MATHEMATICA_MPREP=':' MATLAB=':' MKOCTFILE='/usr/bin/mkoctfile' OBJEXT='o' OCTAVE='/usr/bin/octave' PACKAGE_BUGREPORT='' PACKAGE_NAME='biosig' PACKAGE_STRING='biosig 2.3.3' PACKAGE_TARNAME='biosig' PACKAGE_URL='' PACKAGE_VERSION='2.3.3' PATH_SEPARATOR=':' PEAR=':' PECL=':' PHP=':' POW_LIB='' PYTHON2='/usr/bin/python2' PYTHON3='/usr/bin/python3' PYTHON='/usr/bin/python' R='/usr/bin/R' SET_MAKE='' SHELL='/bin/bash' ac_ct_CC='gcc' ac_ct_CXX='g++' bindir='${exec_prefix}/bin' build='x86_64-pc-linux-gnu' build_alias='' build_cpu='x86_64' build_os='linux-gnu' build_vendor='pc' datadir='${datarootdir}' datarootdir='${prefix}/share' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' dvidir='${docdir}' exec_prefix='${prefix}' host='x86_64-pc-linux-gnu' host_alias='' host_cpu='x86_64' host_os='linux-gnu' host_vendor='pc' htmldir='${docdir}' includedir='${prefix}/include' infodir='${datarootdir}/info' libdir='${exec_prefix}/lib' libexecdir='${exec_prefix}/libexec' localedir='${datarootdir}/locale' localstatedir='${prefix}/var' mandir='${datarootdir}/man' oldincludedir='/usr/include' pdfdir='${docdir}' prefix='/usr/local' program_transform_name='s,x,x,' psdir='${docdir}' runstatedir='${localstatedir}/run' sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com' sysconfdir='${prefix}/etc' target_alias='' ## ----------- ## ## confdefs.h. ## ## ----------- ## /* confdefs.h */ #define PACKAGE_NAME "biosig" #define PACKAGE_TARNAME "biosig" #define PACKAGE_VERSION "2.3.3" #define PACKAGE_STRING "biosig 2.3.3" #define PACKAGE_BUGREPORT "" #define PACKAGE_URL "" #define STDC_HEADERS 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_STAT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRING_H 1 #define HAVE_MEMORY_H 1 #define HAVE_STRINGS_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_STDINT_H 1 #define HAVE_UNISTD_H 1 #define __EXTENSIONS__ 1 #define _ALL_SOURCE 1 #define _GNU_SOURCE 1 #define _POSIX_PTHREAD_SEMANTICS 1 #define _TANDEM_SOURCE 1 #define HAVE_LIBASOUND 1 #define HAVE_ALLOCA_H 1 #define HAVE_ALLOCA 1 #define HAVE_ARPA_INET_H 1 #define HAVE_FCNTL_H 1 #define HAVE_FLOAT_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_LIMITS_H 1 #define HAVE_LOCALE_H 1 #define HAVE_MALLOC_H 1 #define HAVE_NETDB_H 1 #define HAVE_NETINET_IN_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRING_H 1 #define HAVE_STRINGS_H 1 #define HAVE_SYS_PARAM_H 1 #define HAVE_SYS_SOCKET_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_SYSLOG_H 1 #define HAVE_TERMIOS_H 1 #define HAVE_UNISTD_H 1 #define HAVE__BOOL 1 #define HAVE_PTRDIFF_T 1 #define HAVE_FORK 1 #define HAVE_VFORK 1 #define HAVE_WORKING_VFORK 1 #define HAVE_WORKING_FORK 1 #define HAVE_STDLIB_H 1 #define HAVE_MALLOC 1 #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_TIME_H 1 #define HAVE_UNISTD_H 1 #define HAVE_ALARM 1 #define HAVE_STDLIB_H 1 #define HAVE_REALLOC 1 #define HAVE_ALARM 1 #define HAVE_ATEXIT 1 #define HAVE_BZERO 1 #define HAVE_DUP2 1 #define HAVE_GETCWD 1 #define HAVE_GETDELIM 1 #define HAVE_GETHOSTBYNAME 1 #define HAVE_GETHOSTNAME 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_LOCALTIME_R 1 #define HAVE_MEMCHR 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMSET 1 #define HAVE_MKDIR 1 #define HAVE_MODF 1 #define HAVE_PUTENV 1 #define HAVE_RMDIR 1 #define HAVE_SELECT 1 #define HAVE_SETENV 1 #define HAVE_SETLOCALE 1 #define HAVE_SOCKET 1 #define HAVE_STRCASECMP 1 #define HAVE_STRCHR 1 #define HAVE_STRCSPN 1 #define HAVE_STRDUP 1 #define HAVE_STRERROR 1 #define HAVE_STRNCASECMP 1 #define HAVE_STRNDUP 1 #define HAVE_STRPBRK 1 #define HAVE_STRRCHR 1 #define HAVE_STRSPN 1 #define HAVE_STRSTR 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOUMAX 1 #define HAVE_TZSET 1 configure: exit 0 biosig-2.3.3/install-sh0000775000175000017500000003546314105434233015175 0ustar schloeglschloegl#!/bin/sh # install - install a program, script, or datafile scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) # $RANDOM is not portable (e.g. dash); use it when possible to # lower collision chance tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 # As "mkdir -p" follows symlinks and we work in /tmp possibly; so # create the $tmpdir first (and fail if unsuccessful) to make sure # that nobody tries to guess the $tmpdir name. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: biosig-2.3.3/config.status0000775000175000017500000007657114105434244015715 0ustar schloeglschloegl#! /bin/bash # Generated by configure. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=${CONFIG_SHELL-/bin/bash} export SHELL ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by biosig $as_me 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " # Files that config.status was made for. config_files=" Makefile biosig4c++/Makefile biosig4c++/examples/Makefile biosig4c++/igor/Makefile biosig4c++/java/Makefile biosig4c++/magic/Makefile biosig4c++/mex/Makefile biosig4c++/mma/Makefile biosig4c++/perl/Makefile biosig4c++/php/Makefile biosig4c++/python/Makefile biosig4c++/python/setup.py biosig4c++/python/README.md biosig4c++/R/Makefile biosig4c++/R/DESCRIPTION biosig4c++/ruby/Makefile biosig4c++/t240/Makefile biosig4c++/t241/Makefile biosig4c++/tcl/Makefile" config_headers=" config.h" ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." ac_cs_config="" ac_cs_version="\ biosig config.status 2.3.3 configured by ./configure, generated by GNU Autoconf 2.69, with options \"$ac_cs_config\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='/home/schloegl/tmp/biosig-code' srcdir='.' INSTALL='/usr/bin/install -c' AWK='gawk' test -n "$AWK" || AWK=awk # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi if $ac_cs_recheck; then set X /bin/bash './configure' $ac_configure_extra_args --no-create --no-recursion shift $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' export CONFIG_SHELL exec "$@" fi exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "biosig4c++/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/Makefile" ;; "biosig4c++/examples/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/examples/Makefile" ;; "biosig4c++/igor/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/igor/Makefile" ;; "biosig4c++/java/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/java/Makefile" ;; "biosig4c++/magic/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/magic/Makefile" ;; "biosig4c++/mex/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/mex/Makefile" ;; "biosig4c++/mma/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/mma/Makefile" ;; "biosig4c++/perl/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/perl/Makefile" ;; "biosig4c++/php/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/php/Makefile" ;; "biosig4c++/python/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/Makefile" ;; "biosig4c++/python/setup.py") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/setup.py" ;; "biosig4c++/python/README.md") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/README.md" ;; "biosig4c++/R/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/R/Makefile" ;; "biosig4c++/R/DESCRIPTION") CONFIG_FILES="$CONFIG_FILES biosig4c++/R/DESCRIPTION" ;; "biosig4c++/ruby/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/ruby/Makefile" ;; "biosig4c++/t240/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/t240/Makefile" ;; "biosig4c++/t241/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/t241/Makefile" ;; "biosig4c++/tcl/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/tcl/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && S["LTLIBOBJS"]="" S["POW_LIB"]="" S["host_os"]="linux-gnu" S["host_vendor"]="pc" S["host_cpu"]="x86_64" S["host"]="x86_64-pc-linux-gnu" S["build_os"]="linux-gnu" S["build_vendor"]="pc" S["build_cpu"]="x86_64" S["build"]="x86_64-pc-linux-gnu" S["LIBOBJS"]="" S["ALLOCA"]="" S["HAVE_UUID"]="1" S["HAVE_MATHEMATICA"]="" S["HAVE_LIBM"]="1" S["R"]="/usr/bin/R" S["PYTHON3"]="/usr/bin/python3" S["PYTHON2"]="/usr/bin/python2" S["PYTHON"]="/usr/bin/python" S["PECL"]=":" S["PEAR"]=":" S["PHP"]=":" S["OCTAVE"]="/usr/bin/octave" S["MKOCTFILE"]="/usr/bin/mkoctfile" S["MATLAB"]=":" S["MATHEMATICA_MPREP"]=":" S["MATHEMATICA"]=":" S["JAVAC"]="/usr/bin/javac" S["JAVA"]="/usr/bin/java" S["HAVE_LIBTINYXML"]="1" S["HAVE_LIBZ"]="1" S["HAVE_LIBDCMTK"]="1" S["HAVE_LIBCHOLMOD"]="1" S["HAVE_LIBB64"]="1" S["SET_MAKE"]="" S["LN_S"]="ln -s" S["INSTALL_DATA"]="${INSTALL} -m 644" S["INSTALL_SCRIPT"]="${INSTALL}" S["INSTALL_PROGRAM"]="${INSTALL}" S["AWK"]="gawk" S["ac_ct_CXX"]="g++" S["CXXFLAGS"]="-g -O2" S["CXX"]="g++" S["EGREP"]="/bin/grep -E" S["GREP"]="/bin/grep" S["CPP"]="gcc -E" S["OBJEXT"]="o" S["EXEEXT"]="" S["ac_ct_CC"]="gcc" S["CPPFLAGS"]="" S["LDFLAGS"]="" S["CFLAGS"]="-g -O2" S["CC"]="gcc" S["target_alias"]="" S["host_alias"]="" S["build_alias"]="" S["LIBS"]="-lasound " S["ECHO_T"]="" S["ECHO_N"]="-n" S["ECHO_C"]="" S["DEFS"]="-DHAVE_CONFIG_H" S["mandir"]="${datarootdir}/man" S["localedir"]="${datarootdir}/locale" S["libdir"]="${exec_prefix}/lib" S["psdir"]="${docdir}" S["pdfdir"]="${docdir}" S["dvidir"]="${docdir}" S["htmldir"]="${docdir}" S["infodir"]="${datarootdir}/info" S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}" S["oldincludedir"]="/usr/include" S["includedir"]="${prefix}/include" S["runstatedir"]="${localstatedir}/run" S["localstatedir"]="${prefix}/var" S["sharedstatedir"]="${prefix}/com" S["sysconfdir"]="${prefix}/etc" S["datadir"]="${datarootdir}" S["datarootdir"]="${prefix}/share" S["libexecdir"]="${exec_prefix}/libexec" S["sbindir"]="${exec_prefix}/sbin" S["bindir"]="${exec_prefix}/bin" S["program_transform_name"]="s,x,x," S["prefix"]="/usr/local" S["exec_prefix"]="${prefix}" S["PACKAGE_URL"]="" S["PACKAGE_BUGREPORT"]="" S["PACKAGE_STRING"]="biosig 2.3.3" S["PACKAGE_VERSION"]="2.3.3" S["PACKAGE_TARNAME"]="biosig" S["PACKAGE_NAME"]="biosig" S["PATH_SEPARATOR"]=":" S["SHELL"]="/bin/bash" _ACAWK cat >>"$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { D["PACKAGE_NAME"]=" \"biosig\"" D["PACKAGE_TARNAME"]=" \"biosig\"" D["PACKAGE_VERSION"]=" \"2.3.3\"" D["PACKAGE_STRING"]=" \"biosig 2.3.3\"" D["PACKAGE_BUGREPORT"]=" \"\"" D["PACKAGE_URL"]=" \"\"" D["STDC_HEADERS"]=" 1" D["HAVE_SYS_TYPES_H"]=" 1" D["HAVE_SYS_STAT_H"]=" 1" D["HAVE_STDLIB_H"]=" 1" D["HAVE_STRING_H"]=" 1" D["HAVE_MEMORY_H"]=" 1" D["HAVE_STRINGS_H"]=" 1" D["HAVE_INTTYPES_H"]=" 1" D["HAVE_STDINT_H"]=" 1" D["HAVE_UNISTD_H"]=" 1" D["__EXTENSIONS__"]=" 1" D["_ALL_SOURCE"]=" 1" D["_GNU_SOURCE"]=" 1" D["_POSIX_PTHREAD_SEMANTICS"]=" 1" D["_TANDEM_SOURCE"]=" 1" D["HAVE_LIBASOUND"]=" 1" D["HAVE_ALLOCA_H"]=" 1" D["HAVE_ALLOCA"]=" 1" D["HAVE_ARPA_INET_H"]=" 1" D["HAVE_FCNTL_H"]=" 1" D["HAVE_FLOAT_H"]=" 1" D["HAVE_INTTYPES_H"]=" 1" D["HAVE_LIMITS_H"]=" 1" D["HAVE_LOCALE_H"]=" 1" D["HAVE_MALLOC_H"]=" 1" D["HAVE_NETDB_H"]=" 1" D["HAVE_NETINET_IN_H"]=" 1" D["HAVE_STDDEF_H"]=" 1" D["HAVE_STDINT_H"]=" 1" D["HAVE_STDLIB_H"]=" 1" D["HAVE_STRING_H"]=" 1" D["HAVE_STRINGS_H"]=" 1" D["HAVE_SYS_PARAM_H"]=" 1" D["HAVE_SYS_SOCKET_H"]=" 1" D["HAVE_SYS_TIME_H"]=" 1" D["HAVE_SYSLOG_H"]=" 1" D["HAVE_TERMIOS_H"]=" 1" D["HAVE_UNISTD_H"]=" 1" D["HAVE__BOOL"]=" 1" D["HAVE_PTRDIFF_T"]=" 1" D["HAVE_FORK"]=" 1" D["HAVE_VFORK"]=" 1" D["HAVE_WORKING_VFORK"]=" 1" D["HAVE_WORKING_FORK"]=" 1" D["HAVE_STDLIB_H"]=" 1" D["HAVE_MALLOC"]=" 1" D["TIME_WITH_SYS_TIME"]=" 1" D["HAVE_SYS_TIME_H"]=" 1" D["HAVE_UNISTD_H"]=" 1" D["HAVE_ALARM"]=" 1" D["HAVE_STDLIB_H"]=" 1" D["HAVE_REALLOC"]=" 1" D["HAVE_ALARM"]=" 1" D["HAVE_ATEXIT"]=" 1" D["HAVE_BZERO"]=" 1" D["HAVE_DUP2"]=" 1" D["HAVE_GETCWD"]=" 1" D["HAVE_GETDELIM"]=" 1" D["HAVE_GETHOSTBYNAME"]=" 1" D["HAVE_GETHOSTNAME"]=" 1" D["HAVE_GETTIMEOFDAY"]=" 1" D["HAVE_LOCALTIME_R"]=" 1" D["HAVE_MEMCHR"]=" 1" D["HAVE_MEMMOVE"]=" 1" D["HAVE_MEMSET"]=" 1" D["HAVE_MKDIR"]=" 1" D["HAVE_MODF"]=" 1" D["HAVE_PUTENV"]=" 1" D["HAVE_RMDIR"]=" 1" D["HAVE_SELECT"]=" 1" D["HAVE_SETENV"]=" 1" D["HAVE_SETLOCALE"]=" 1" D["HAVE_SOCKET"]=" 1" D["HAVE_STRCASECMP"]=" 1" D["HAVE_STRCHR"]=" 1" D["HAVE_STRCSPN"]=" 1" D["HAVE_STRDUP"]=" 1" D["HAVE_STRERROR"]=" 1" D["HAVE_STRNCASECMP"]=" 1" D["HAVE_STRNDUP"]=" 1" D["HAVE_STRPBRK"]=" 1" D["HAVE_STRRCHR"]=" 1" D["HAVE_STRSPN"]=" 1" D["HAVE_STRSTR"]=" 1" D["HAVE_STRTOL"]=" 1" D["HAVE_STRTOUL"]=" 1" D["HAVE_STRTOUMAX"]=" 1" D["HAVE_TZSET"]=" 1" for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { line = $ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} ac_datarootdir_hack=' s&@datadir@&${datarootdir}&g s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g s&@infodir@&${datarootdir}/info&g s&@localedir@&${datarootdir}/locale&g s&@mandir@&${datarootdir}/man&g s&\${datarootdir}&${prefix}/share&g' ;; esac ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// } :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 biosig-2.3.3/configure0000775000175000017500000071776214105434235015113 0ustar schloeglschloegl#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for biosig 2.3.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # # Copyright (C) 2019-2021 Alois Schlögl ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='biosig' PACKAGE_TARNAME='biosig' PACKAGE_VERSION='2.3.3' PACKAGE_STRING='biosig 2.3.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="biosig4c++/biosig.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_list= ac_func_list= ac_subst_vars='LTLIBOBJS POW_LIB host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBOBJS ALLOCA HAVE_UUID HAVE_MATHEMATICA HAVE_LIBM R PYTHON3 PYTHON2 PYTHON PECL PEAR PHP OCTAVE MKOCTFILE MATLAB MATHEMATICA_MPREP MATHEMATICA JAVAC JAVA HAVE_LIBTINYXML HAVE_LIBZ HAVE_LIBDCMTK HAVE_LIBCHOLMOD HAVE_LIBB64 SET_MAKE LN_S INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM AWK ac_ct_CXX CXXFLAGS CXX EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures biosig 2.3.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/biosig] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of biosig 2.3.3:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF biosig configure 2.3.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Copyright (C) 2019-2021 Alois Schlögl _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_find_intX_t LINENO BITS VAR # ----------------------------------- # Finds a signed integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_intX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 $as_echo_n "checking for int$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in int$2_t 'int' 'long int' \ 'long long int' 'short int' 'signed char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else case $ac_type in #( int$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_intX_t # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by biosig $as_me 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi as_fn_append ac_header_list " sys/time.h" as_fn_append ac_header_list " unistd.h" as_fn_append ac_func_list " alarm" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snd_pcm_open in -lasound" >&5 $as_echo_n "checking for snd_pcm_open in -lasound... " >&6; } if ${ac_cv_lib_asound_snd_pcm_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lasound $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char snd_pcm_open (); int main () { return snd_pcm_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_asound_snd_pcm_open=yes else ac_cv_lib_asound_snd_pcm_open=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asound_snd_pcm_open" >&5 $as_echo "$ac_cv_lib_asound_snd_pcm_open" >&6; } if test "x$ac_cv_lib_asound_snd_pcm_open" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBASOUND 1 _ACEOF LIBS="-lasound $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for base64_encode_block in -lb64" >&5 $as_echo_n "checking for base64_encode_block in -lb64... " >&6; } if ${ac_cv_lib_b64_base64_encode_block+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lb64 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char base64_encode_block (); int main () { return base64_encode_block (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_b64_base64_encode_block=yes else ac_cv_lib_b64_base64_encode_block=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_b64_base64_encode_block" >&5 $as_echo "$ac_cv_lib_b64_base64_encode_block" >&6; } if test "x$ac_cv_lib_b64_base64_encode_block" = xyes; then : HAVE_LIBB64="1" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cholmod_start in -lcholmod" >&5 $as_echo_n "checking for cholmod_start in -lcholmod... " >&6; } if ${ac_cv_lib_cholmod_cholmod_start+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcholmod $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char cholmod_start (); int main () { return cholmod_start (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_cholmod_cholmod_start=yes else ac_cv_lib_cholmod_cholmod_start=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cholmod_cholmod_start" >&5 $as_echo "$ac_cv_lib_cholmod_cholmod_start" >&6; } if test "x$ac_cv_lib_cholmod_cholmod_start" = xyes; then : HAVE_LIBCHOLMOD="1" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dcmEnableOtherLongVRGeneration in -ldcmdata" >&5 $as_echo_n "checking for dcmEnableOtherLongVRGeneration in -ldcmdata... " >&6; } if ${ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldcmdata $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dcmEnableOtherLongVRGeneration (); int main () { return dcmEnableOtherLongVRGeneration (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration=yes else ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration" >&5 $as_echo "$ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration" >&6; } if test "x$ac_cv_lib_dcmdata_dcmEnableOtherLongVRGeneration" = xyes; then : HAVE_LIBDCMTK="1" fi # AC_CHECK_LIB([hdf5], [H5open], AC_SUBST(HAVE_LIBHDF5, "1") ) # AC_CHECK_LIB([matio], [Mat_Open], AC_SUBST(HAVE_LIBMATIO, "1") ) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 $as_echo_n "checking for gzopen in -lz... " >&6; } if ${ac_cv_lib_z_gzopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gzopen (); int main () { return gzopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_z_gzopen=yes else ac_cv_lib_z_gzopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzopen" >&5 $as_echo "$ac_cv_lib_z_gzopen" >&6; } if test "x$ac_cv_lib_z_gzopen" = xyes; then : HAVE_LIBZ="1" fi # FIXME: Replace `main' with a function in `-lgdcmCommon': #AC_CHECK_LIB([gdcmCommon], [main]) # FIXME: Replace `main' with a function in `-lgdcmDICT': #AC_CHECK_LIB([gdcmDICT], [main]) # FIXME: Replace `main' with a function in `-lgdcmDSED': #AC_CHECK_LIB([gdcmDSED], [main]) # FIXME: Replace `main' with a function in `-lgdcmIOD': #AC_CHECK_LIB([gdcmIOD], [main]) # FIXME: Replace `main' with a function in `-lgdcmMEXD': #AC_CHECK_LIB([gdcmMEXD], [main]) # FIXME: Replace `main' with a function in `-lgdcmMSFF': #AC_CHECK_LIB([gdcmMSFF], [main]) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5 $as_echo_n "checking for iconv_open in -liconv... " >&6; } if ${ac_cv_lib_iconv_iconv_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-liconv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char iconv_open (); int main () { return iconv_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_iconv_iconv_open=yes else ac_cv_lib_iconv_iconv_open=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv_open" >&5 $as_echo "$ac_cv_lib_iconv_iconv_open" >&6; } if test "x$ac_cv_lib_iconv_iconv_open" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBICONV 1 _ACEOF LIBS="-liconv $LIBS" fi ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" if test "x$ac_cv_header_iconv_h" = xyes; then : else as_fn_error $? "can not find iconv.h" "$LINENO" 5 fi as_ac_Lib=`$as_echo "ac_cv_lib_tinyxml ''_main" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ltinyxml " >&5 $as_echo_n "checking for main in -ltinyxml ... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltinyxml $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : HAVE_LIBTINYXML="1" TEST_LIBS="$TEST_LIBS -ltinyxml" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libtinyxml is not installed." >&5 $as_echo "$as_me: WARNING: libtinyxml is not installed." >&2;} fi # AC_CHECK_LIB([tinyxml2], [main], AC_SUBST(HAVE_LIBTINYXML2, "1") [TEST_LIBS="$TEST_LIBS -ltinyxml2"], AC_MSG_WARN([libtinyxml2 is not installed.])) # Extract the first word of "java", so it can be a program name with args. set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_JAVA+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVA in [\\/]* | ?:[\\/]*) ac_cv_path_JAVA="$JAVA" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_JAVA" && ac_cv_path_JAVA=":" ;; esac fi JAVA=$ac_cv_path_JAVA if test -n "$JAVA"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA" >&5 $as_echo "$JAVA" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "javac", so it can be a program name with args. set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_JAVAC+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVAC in [\\/]* | ?:[\\/]*) ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_JAVAC" && ac_cv_path_JAVAC=":" ;; esac fi JAVAC=$ac_cv_path_JAVAC if test -n "$JAVAC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAC" >&5 $as_echo "$JAVAC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # # Extract the first word of "mathematica", so it can be a program name with args. set dummy mathematica; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MATHEMATICA+:} false; then : $as_echo_n "(cached) " >&6 else case $MATHEMATICA in [\\/]* | ?:[\\/]*) ac_cv_path_MATHEMATICA="$MATHEMATICA" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MATHEMATICA="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MATHEMATICA" && ac_cv_path_MATHEMATICA=":" ;; esac fi MATHEMATICA=$ac_cv_path_MATHEMATICA if test -n "$MATHEMATICA"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MATHEMATICA" >&5 $as_echo "$MATHEMATICA" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "mprep", so it can be a program name with args. set dummy mprep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MATHEMATICA_MPREP+:} false; then : $as_echo_n "(cached) " >&6 else case $MATHEMATICA_MPREP in [\\/]* | ?:[\\/]*) ac_cv_path_MATHEMATICA_MPREP="$MATHEMATICA_MPREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MATHEMATICA_MPREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MATHEMATICA_MPREP" && ac_cv_path_MATHEMATICA_MPREP=":" ;; esac fi MATHEMATICA_MPREP=$ac_cv_path_MATHEMATICA_MPREP if test -n "$MATHEMATICA_MPREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MATHEMATICA_MPREP" >&5 $as_echo "$MATHEMATICA_MPREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # MATLAB needs to contain full path, because it also used to find mex and mexext # readlink -f does not work on MacOSX, use "matlab -n" to extract the path # AC_CHECK_PROG([MATLAB], [matlab], [$(readlink -f $(which matlab))], [:]) # Extract the first word of "matlab", so it can be a program name with args. set dummy matlab; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MATLAB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MATLAB"; then ac_cv_prog_MATLAB="$MATLAB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MATLAB="$(matlab -n|awk '/^-> r MATLAB = / {printf("%s/bin/matlab",$5)}')" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_MATLAB" && ac_cv_prog_MATLAB=":" fi fi MATLAB=$ac_cv_prog_MATLAB if test -n "$MATLAB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MATLAB" >&5 $as_echo "$MATLAB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "mkoctfile", so it can be a program name with args. set dummy mkoctfile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MKOCTFILE+:} false; then : $as_echo_n "(cached) " >&6 else case $MKOCTFILE in [\\/]* | ?:[\\/]*) ac_cv_path_MKOCTFILE="$MKOCTFILE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MKOCTFILE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MKOCTFILE" && ac_cv_path_MKOCTFILE=":" ;; esac fi MKOCTFILE=$ac_cv_path_MKOCTFILE if test -n "$MKOCTFILE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5 $as_echo "$MKOCTFILE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "octave", so it can be a program name with args. set dummy octave; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_OCTAVE+:} false; then : $as_echo_n "(cached) " >&6 else case $OCTAVE in [\\/]* | ?:[\\/]*) ac_cv_path_OCTAVE="$OCTAVE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_OCTAVE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_OCTAVE" && ac_cv_path_OCTAVE=":" ;; esac fi OCTAVE=$ac_cv_path_OCTAVE if test -n "$OCTAVE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE" >&5 $as_echo "$OCTAVE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # PHP # Extract the first word of "php", so it can be a program name with args. set dummy php; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PHP+:} false; then : $as_echo_n "(cached) " >&6 else case $PHP in [\\/]* | ?:[\\/]*) ac_cv_path_PHP="$PHP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PHP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PHP" && ac_cv_path_PHP=":" ;; esac fi PHP=$ac_cv_path_PHP if test -n "$PHP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PHP" >&5 $as_echo "$PHP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "pear", so it can be a program name with args. set dummy pear; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PEAR+:} false; then : $as_echo_n "(cached) " >&6 else case $PEAR in [\\/]* | ?:[\\/]*) ac_cv_path_PEAR="$PEAR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PEAR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PEAR" && ac_cv_path_PEAR=":" ;; esac fi PEAR=$ac_cv_path_PEAR if test -n "$PEAR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PEAR" >&5 $as_echo "$PEAR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "pecl", so it can be a program name with args. set dummy pecl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PECL+:} false; then : $as_echo_n "(cached) " >&6 else case $PECL in [\\/]* | ?:[\\/]*) ac_cv_path_PECL="$PECL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PECL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PECL" && ac_cv_path_PECL=":" ;; esac fi PECL=$ac_cv_path_PECL if test -n "$PECL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PECL" >&5 $as_echo "$PECL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # PYTHON # Extract the first word of "python", so it can be a program name with args. set dummy python; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else case $PYTHON in [\\/]* | ?:[\\/]*) ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PYTHON" && ac_cv_path_PYTHON=":" ;; esac fi PYTHON=$ac_cv_path_PYTHON if test -n "$PYTHON"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 $as_echo "$PYTHON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "python2", so it can be a program name with args. set dummy python2; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON2+:} false; then : $as_echo_n "(cached) " >&6 else case $PYTHON2 in [\\/]* | ?:[\\/]*) ac_cv_path_PYTHON2="$PYTHON2" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON2="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PYTHON2" && ac_cv_path_PYTHON2=":" ;; esac fi PYTHON2=$ac_cv_path_PYTHON2 if test -n "$PYTHON2"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON2" >&5 $as_echo "$PYTHON2" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "python3", so it can be a program name with args. set dummy python3; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON3+:} false; then : $as_echo_n "(cached) " >&6 else case $PYTHON3 in [\\/]* | ?:[\\/]*) ac_cv_path_PYTHON3="$PYTHON3" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON3="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PYTHON3" && ac_cv_path_PYTHON3=":" ;; esac fi PYTHON3=$ac_cv_path_PYTHON3 if test -n "$PYTHON3"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON3" >&5 $as_echo "$PYTHON3" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # R # Extract the first word of "R", so it can be a program name with args. set dummy R; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_R+:} false; then : $as_echo_n "(cached) " >&6 else case $R in [\\/]* | ?:[\\/]*) ac_cv_path_R="$R" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_R="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_R" && ac_cv_path_R=":" ;; esac fi R=$ac_cv_path_R if test -n "$R"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $R" >&5 $as_echo "$R" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # FIXME: Replace `main' with a function in `-llibmex': { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llibmex" >&5 $as_echo_n "checking for main in -llibmex... " >&6; } if ${ac_cv_lib_libmex_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llibmex $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_libmex_main=yes else ac_cv_lib_libmex_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_libmex_main" >&5 $as_echo "$ac_cv_lib_libmex_main" >&6; } if test "x$ac_cv_lib_libmex_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBLIBMEX 1 _ACEOF LIBS="-llibmex $LIBS" fi # FIXME: Replace `main' with a function in `-llibmx': { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llibmx" >&5 $as_echo_n "checking for main in -llibmx... " >&6; } if ${ac_cv_lib_libmx_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llibmx $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_libmx_main=yes else ac_cv_lib_libmx_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_libmx_main" >&5 $as_echo "$ac_cv_lib_libmx_main" >&6; } if test "x$ac_cv_lib_libmx_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBLIBMX 1 _ACEOF LIBS="-llibmx $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for round in -lm" >&5 $as_echo_n "checking for round in -lm... " >&6; } if ${ac_cv_lib_m_round+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char round (); int main () { return round (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_round=yes else ac_cv_lib_m_round=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_round" >&5 $as_echo "$ac_cv_lib_m_round" >&6; } if test "x$ac_cv_lib_m_round" = xyes; then : HAVE_LIBM="1" fi # Wolfram/Mathematica Mathlink interface { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MLPutRealArray in -lmathlink" >&5 $as_echo_n "checking for MLPutRealArray in -lmathlink... " >&6; } if ${ac_cv_lib_mathlink_MLPutRealArray+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmathlink $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char MLPutRealArray (); int main () { return MLPutRealArray (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_mathlink_MLPutRealArray=yes else ac_cv_lib_mathlink_MLPutRealArray=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mathlink_MLPutRealArray" >&5 $as_echo "$ac_cv_lib_mathlink_MLPutRealArray" >&6; } if test "x$ac_cv_lib_mathlink_MLPutRealArray" = xyes; then : HAVE_MATHEMATICA="1" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 $as_echo_n "checking for uuid_generate in -luuid... " >&6; } if ${ac_cv_lib_uuid_uuid_generate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-luuid $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char uuid_generate (); int main () { return uuid_generate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_uuid_uuid_generate=yes else ac_cv_lib_uuid_uuid_generate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 $as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : HAVE_UUID="1" fi #AC_CHECK_LIB([pthread], [pthread_mutex_lock]) # FIXME: Replace `main' with a function in `-lssp': #AC_CHECK_LIB([ssp], [main]) # Checks for header files. ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } int main (int argc, char **argv) { return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi for ac_header in arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" case $ac_cv_c_int16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int16_t $ac_cv_c_int16_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" case $ac_cv_c_int32_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int32_t $ac_cv_c_int32_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" case $ac_cv_c_int64_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int64_t $ac_cv_c_int64_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" case $ac_cv_c_int8_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int8_t $ac_cv_c_int8_t _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define uint16_t $ac_cv_c_uint16_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( *) $as_echo "#define _UINT64_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint64_t $ac_cv_c_uint64_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) $as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint8_t $ac_cv_c_uint8_t _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" if test "x$ac_cv_type_ptrdiff_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTRDIFF_T 1 _ACEOF fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if ${ac_cv_lib_error_at_line+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi for ac_header in vfork.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" if test "x$ac_cv_header_vfork_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF fi done for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } if ${ac_cv_func_fork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_fork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fork_works=yes else ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 $as_echo "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } if ${ac_cv_func_vfork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_vfork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_vfork_works=yes else ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 $as_echo "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then $as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h else $as_echo "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in $ac_func_list do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 $as_echo_n "checking for working mktime... " >&6; } if ${ac_cv_func_working_mktime+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_working_mktime=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Test program from Paul Eggert and Tony Leneis. */ #ifdef TIME_WITH_SYS_TIME # include # include #else # ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif #include #include #ifdef HAVE_UNISTD_H # include #endif #ifndef HAVE_ALARM # define alarm(X) /* empty */ #endif /* Work around redefinition to rpl_putenv by other config tests. */ #undef putenv static time_t time_t_max; static time_t time_t_min; /* Values we'll use to set the TZ environment variable. */ static const char *tz_strings[] = { (const char *) 0, "TZ=GMT0", "TZ=JST-9", "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" }; #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) /* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */ static int spring_forward_gap () { /* glibc (up to about 1998-10-07) failed this test. */ struct tm tm; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); tm.tm_year = 98; tm.tm_mon = 3; tm.tm_mday = 5; tm.tm_hour = 2; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm) != (time_t) -1; } static int mktime_test1 (time_t now) { struct tm *lt; return ! (lt = localtime (&now)) || mktime (lt) == now; } static int mktime_test (time_t now) { return (mktime_test1 (now) && mktime_test1 ((time_t) (time_t_max - now)) && mktime_test1 ((time_t) (time_t_min + now))); } static int irix_6_4_bug () { /* Based on code from Ariel Faigon. */ struct tm tm; tm.tm_year = 96; tm.tm_mon = 3; tm.tm_mday = 0; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; mktime (&tm); return tm.tm_mon == 2 && tm.tm_mday == 31; } static int bigtime_test (int j) { struct tm tm; time_t now; tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; now = mktime (&tm); if (now != (time_t) -1) { struct tm *lt = localtime (&now); if (! (lt && lt->tm_year == tm.tm_year && lt->tm_mon == tm.tm_mon && lt->tm_mday == tm.tm_mday && lt->tm_hour == tm.tm_hour && lt->tm_min == tm.tm_min && lt->tm_sec == tm.tm_sec && lt->tm_yday == tm.tm_yday && lt->tm_wday == tm.tm_wday && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) return 0; } return 1; } static int year_2050_test () { /* The correct answer for 2050-02-01 00:00:00 in Pacific time, ignoring leap seconds. */ unsigned long int answer = 2527315200UL; struct tm tm; time_t t; tm.tm_year = 2050 - 1900; tm.tm_mon = 2 - 1; tm.tm_mday = 1; tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_isdst = -1; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); t = mktime (&tm); /* Check that the result is either a failure, or close enough to the correct answer that we can assume the discrepancy is due to leap seconds. */ return (t == (time_t) -1 || (0 < t && answer - 120 <= t && t <= answer + 120)); } int main () { time_t t, delta; int i, j; /* This test makes some buggy mktime implementations loop. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ alarm (60); for (;;) { t = (time_t_max << 1) + 1; if (t <= time_t_max) break; time_t_max = t; } time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { if (tz_strings[i]) putenv ((char*) tz_strings[i]); for (t = 0; t <= time_t_max - delta; t += delta) if (! mktime_test (t)) return 1; if (! (mktime_test ((time_t) 1) && mktime_test ((time_t) (60 * 60)) && mktime_test ((time_t) (60 * 60 * 24)))) return 1; for (j = 1; ; j <<= 1) if (! bigtime_test (j)) return 1; else if (INT_MAX / 2 < j) break; if (! bigtime_test (INT_MAX)) return 1; } return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_working_mktime=yes else ac_cv_func_working_mktime=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 $as_echo "$ac_cv_func_working_mktime" >&6; } if test $ac_cv_func_working_mktime = no; then case " $LIBOBJS " in *" mktime.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS mktime.$ac_objext" ;; esac fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 $as_echo_n "checking for GNU libc compatible realloc... " >&6; } if ${ac_cv_func_realloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_realloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_realloc_0_nonnull=yes else ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 $as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then : $as_echo "#define HAVE_REALLOC 1" >>confdefs.h else $as_echo "#define HAVE_REALLOC 0" >>confdefs.h case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac $as_echo "#define realloc rpl_realloc" >>confdefs.h fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strnlen" >&5 $as_echo_n "checking for working strnlen... " >&6; } if ${ac_cv_func_strnlen_working+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : # Guess no on AIX systems, yes otherwise. case "$host_os" in aix*) ac_cv_func_strnlen_working=no;; *) ac_cv_func_strnlen_working=yes;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { #define S "foobar" #define S_LEN (sizeof S - 1) /* At least one implementation is buggy: that of AIX 4.3 would give strnlen (S, 1) == 3. */ int i; for (i = 0; i < S_LEN + 1; ++i) { int expected = i <= S_LEN ? i : S_LEN; if (strnlen (S, i) != expected) return 1; } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_strnlen_working=yes else ac_cv_func_strnlen_working=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strnlen_working" >&5 $as_echo "$ac_cv_func_strnlen_working" >&6; } test $ac_cv_func_strnlen_working = no && case " $LIBOBJS " in *" strnlen.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 $as_echo_n "checking for working strtod... " >&6; } if ${ac_cv_func_strtod+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_strtod=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifndef strtod double strtod (); #endif int main() { { /* Some versions of Linux strtod mis-parse strings with leading '+'. */ char *string = " +69"; char *term; double value; value = strtod (string, &term); if (value != 69 || term != (string + 4)) return 1; } { /* Under Solaris 2.4, strtod returns the wrong value for the terminating character under some conditions. */ char *string = "NaN"; char *term; strtod (string, &term); if (term != string && *(term - 1) == 0) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_strtod=yes else ac_cv_func_strtod=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 $as_echo "$ac_cv_func_strtod" >&6; } if test $ac_cv_func_strtod = no; then case " $LIBOBJS " in *" strtod.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtod.$ac_objext" ;; esac ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" if test "x$ac_cv_func_pow" = xyes; then : fi if test $ac_cv_func_pow = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 $as_echo_n "checking for pow in -lm... " >&6; } if ${ac_cv_lib_m_pow+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pow (); int main () { return pow (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_pow=yes else ac_cv_lib_m_pow=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 $as_echo "$ac_cv_lib_m_pow" >&6; } if test "x$ac_cv_lib_m_pow" = xyes; then : POW_LIB=-lm else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 $as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} fi fi fi for ac_func in alarm atexit bzero dup2 floor getcwd getdelim gethostbyname gethostname gettimeofday localtime_r memchr memmove memset mkdir modf pow putenv rmdir select setenv setlocale socket strcasecmp strchr strcspn strdup strerror strncasecmp strndup strpbrk strrchr strspn strstr strtol strtoul strtoumax tzset do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files Makefile biosig4c++/Makefile biosig4c++/examples/Makefile biosig4c++/igor/Makefile biosig4c++/java/Makefile biosig4c++/magic/Makefile biosig4c++/mex/Makefile biosig4c++/mma/Makefile biosig4c++/perl/Makefile biosig4c++/php/Makefile biosig4c++/python/Makefile biosig4c++/python/setup.py biosig4c++/python/README.md biosig4c++/R/Makefile biosig4c++/R/DESCRIPTION biosig4c++/ruby/Makefile biosig4c++/t240/Makefile biosig4c++/t241/Makefile biosig4c++/tcl/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by biosig $as_me 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ biosig config.status 2.3.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "biosig4c++/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/Makefile" ;; "biosig4c++/examples/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/examples/Makefile" ;; "biosig4c++/igor/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/igor/Makefile" ;; "biosig4c++/java/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/java/Makefile" ;; "biosig4c++/magic/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/magic/Makefile" ;; "biosig4c++/mex/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/mex/Makefile" ;; "biosig4c++/mma/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/mma/Makefile" ;; "biosig4c++/perl/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/perl/Makefile" ;; "biosig4c++/php/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/php/Makefile" ;; "biosig4c++/python/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/Makefile" ;; "biosig4c++/python/setup.py") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/setup.py" ;; "biosig4c++/python/README.md") CONFIG_FILES="$CONFIG_FILES biosig4c++/python/README.md" ;; "biosig4c++/R/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/R/Makefile" ;; "biosig4c++/R/DESCRIPTION") CONFIG_FILES="$CONFIG_FILES biosig4c++/R/DESCRIPTION" ;; "biosig4c++/ruby/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/ruby/Makefile" ;; "biosig4c++/t240/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/t240/Makefile" ;; "biosig4c++/t241/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/t241/Makefile" ;; "biosig4c++/tcl/Makefile") CONFIG_FILES="$CONFIG_FILES biosig4c++/tcl/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi biosig-2.3.3/INSTALL0000664000175000017500000003661414105434233014221 0ustar schloeglschloeglInstallation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this 'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure'). It can also use an optional file (typically called 'config.cache' and enabled with '--cache-file=config.cache' or simply '-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how 'configure' could check whether to do them, and mail diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at some point 'config.cache' contains results you don't want to keep, you may remove or edit it. The file 'configure.ac' (or 'configure.in') is used to create 'configure' by a program called 'autoconf'. You need 'configure.ac' if you want to change it or regenerate 'configure' using a newer version of 'autoconf'. The simplest way to compile this package is: 1. 'cd' to the directory containing the package's source code and type './configure' to configure the package for your system. Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type 'make' to compile the package. 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the 'make install' phase executed with root privileges. 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing 'make clean'. To also remove the files that 'configure' created (so you can compile the package for a different kind of computer), type 'make distclean'. There is also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. You can give 'configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run the 'configure' script. 'configure' automatically checks for the source code in the directory that 'configure' is in and in '..'. This is known as a "VPATH" build. With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple '-arch' options to the compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the 'lipo' tool if you have problems. Installation Names ================== By default, 'make install' installs the package's commands under '/usr/local/bin', include files under '/usr/local/include', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like '--bindir=DIR' to specify different values for particular kinds of files. Run 'configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of '${prefix}', so that specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the 'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of '${prefix}'. Any directories that were specified during 'configure', but not in terms of '${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the 'DESTDIR' variable. For example, 'make install DESTDIR=/alternate/directory' will prepend '/alternate/directory' before all installation names. The approach of 'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of '${prefix}' at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving 'configure' the option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. Some packages pay attention to '--enable-FEATURE' options to 'configure', where FEATURE indicates an optional part of the package. They may also pay attention to '--with-PACKAGE' options, where PACKAGE is something like 'gnu-as' or 'x' (for the X Window System). The 'README' should mention any '--enable-' and '--with-' options that the package recognizes. For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, you can use the 'configure' options '--x-includes=DIR' and '--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be overridden with 'make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX 'make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its '' header file. The option '-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in '/usr/bin'. So, if you need '/usr/ucb' in your 'PATH', put it _after_ '/usr/bin'. On Haiku, software installed for all users goes in '/boot/common', not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the '--build=TYPE' option. TYPE can either be a short name for the system type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file 'config.sub' for the possible values of each field. If 'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with '--host=TYPE'. Sharing Defaults ================ If you want to set default values for 'configure' scripts to share, you can create a site shell script called 'config.site' that gives default values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' looks for 'PREFIX/share/config.site' if it exists, then 'PREFIX/etc/config.site' if it exists. Or, you can set the 'CONFIG_SITE' environment variable to the location of the site script. A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 'configure' Invocation ====================== 'configure' recognizes the following options to control how it operates. '--help' '-h' Print a summary of all of the options to 'configure', and exit. '--help=short' '--help=recursive' Print a summary of the options unique to this package's 'configure', and exit. The 'short' variant lists options used only in the top level, while the 'recursive' variant lists options also present in any nested packages. '--version' '-V' Print the version of Autoconf used to generate the 'configure' script, and exit. '--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. '--config-cache' '-C' Alias for '--cache-file=config.cache'. '--quiet' '--silent' '-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). '--srcdir=DIR' Look for the package's source code in directory DIR. Usually 'configure' can determine that directory automatically. '--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. '--no-create' '-n' Run the configure checks, but stop before creating any output files. 'configure' also accepts some other, not widely useful, options. Run 'configure --help' for more details. biosig-2.3.3/README0000664000175000017500000001774414105434233014053 0ustar schloeglschloeglIntroduction: ============= The aim of this repository is providing a software library for biomedical signal processing. Biosig consists of the following parts: (1) "Biosig for Octave and Matlab" and (2) "Biosig for C/C++" provides libbiosig, and several command line tools (3) binding of libbiosig to the following programming languages: Python, Mathematica, Matlab/Octave, Java, and R. == Installation == The build and installation is quite flexible, and will adapt to your configuration. If numpy/libpython-dev is available, the biosig language binding for python will be installed. The same is try for Octave, Matlab, Mathematica, R, and Java. --- Recommended packages at compile time --- apt-get install \ gawk \ libb64-dev tinyxml-dev libdcmtk-dev \ liboctave-dev octave \ python-numpy python3-numpy \ python-setuptools python3-setuptools \ libpython-dev libpython3-dev \ R texlive-fonts-extra \ default-jdk --- Recommended packages at runtime --- apt-get install \ libb64 tinyxml libdcmtk14 \ python-numpy python3-numpy \ R default-jre \ octave octave-tsa octave-nan octave-signal octave-statistics Installing Biosig from source is as simple as ./configure make sudo make install This should install libbiosig and als biosig command line tools like save2gdf biosig_fhir physicalunits Depending on your software configuration, also language bindings to Matlab, Octave, Python, Java, R, Mathematica might be installed. If you have python/numpy/libpython-dev installed, also biosig for python will be installed. If you have Octave/liboctave-dev installed, also mexbiosig will be installed in octave. However there are some known (and probably also unknown) limitations. Known limitations are - Java language binding does not compile on MacOSX - Cross compilation for Windows does not work (except for Matlab and Mathematica language bindings) BioSig4C++ provides several tools: (1) = LIBRARIES = (1a) "libbiosig" provides a library for accessing different dataformats. The supported data formats are listed here: http://pub.ist.ac.at/~schloegl/biosig/TESTED (1b) "libgdf" is a lightweight version of libbiosig, supporting only the GDF format. it requires only GCC not G++ for linking, has potentially much less security loopholes (XML) and bugs, and a much smaller memory footprint, which might be especially useful for embedded devices. It's interface is the same than for libbiosig, namely biosig.h (1c) "libphysicalunits" provides conversion tools for physical units from ascii text to 16bit integers according to ISO/IEEE 11073-10101:2004 Table A.6.3: Vital signs units of measurements text strings are cached for performance reasons, and can be used in a multi-threaded application. * Installation of official source release (for users): download source release and run see above * Installation from git repository (for developers, usually untested): Requirement: gawk ** Checkout code for the first time: git clone https://git.code.sf.net/p/biosig/code biosig-code cd biosig-code autoconf # needed only the first time after checkout ./configure make sudo make install ** next time just update latest changes git pull autoreconf -fi # usually this can be omitted ./configure # usually this can be omitted make make install For doing some advanced (special) configurations, you can modify these flags in Makefile.in (2) = converter and tools = contains several tools for data conversion, save2gdf: is a converter between different file formats, including but not limited to SCP-ECG(EN1064), HL7aECG (FDA-XML), GDF, EDF, BDF, CWFB and others save2gdf can be also used to upload or retrieve data from a bscs server, and to display the header information in ascii and in JSON format. biosig2fhir: is a tool than converts biosig data into a hl7/fhir binary template, the header information is encoded in JSON format, the data is converted into a base64-encoded GDF (OeNorm K2202:2015) formatted file. physicalunits: is a tool to show the encoding of physical units according to ISO/IEEE 11073 These can can be build with: make tools (3) language bindings and foreign function interfaces: (3a) "mexSLOAD" is a MEX-interface for Octave and Matlab and is linked statically to libbiosig. It can be build with make mex4o # octave make mex4m # matlab for details see mex/README. (3b) "python" is an interface to python and dynamically linked to libbiosig. Requirement: python, python-dev, python-numpy for Debian/Ubuntu: sudo apt-get install python python-dev python-numpy python-setuptools sudo apt-get install python3 python3-dev python3-numpy python3-setuptools It can be build with any of the following commands: make python make -C biosig4c++/python build make -C biosig4c++/python release For installation, you can than do either cd biosig4c++/python && python setup.py install cd biosig4c++/python && python3 setup.py install or python -m pip install python/dist/Biosig-2.1.1.tar.gz python3 -m pip install python/dist/Biosig-2.1.1.tar.gz Use of the interface is shown in ./python/demo2.py (3c) mathematica is linked dynamically to libbiosig and can be build with: make mma see also biosig4c++/mma/README, and biosig4c++/mma/biosig, biosig4c++/mma/hdrinfo.nb, biosig4c++/mma/mySLOAD.nb for more details. (3z) other language interfaces Basic interfaces for R and Java are also available. For other languages (including PHP, Perl and TCL) are considered, but these still need to be implemented and tested. (5) Biosig tools for Matlab and Octave The easiest approach is to change into the directory cd biosig4matlab and run "install" from within Matlab or Octave. This will set the path to the subdirectories. (6) Precompiled binaries for Win32 and Win64 biosig4c++/win##/save2gdf.exe binary converter biosig4c++/win##/libbiosig.{lib,dll} static and dynamic library (requires zlib and libws2_32) biosig4c++/mma/biosig.exe Mathematica binding through Mathlink interface biosig4c++/mex/mexSLOAD.mexw32 Mex-file for Win32/Matlab The internal data structure resemble the header structure similar to https://sourceforge.net/p/biosig/code/ci/master/tree/biosig4matlab/doc/header.txt and is defined in https://sourceforge.net/p/biosig/code/ci/master/tree/biosig4c++/biosig-dev.h (see HDRTYPE and CHANNEL_TYPE) Encoding of Event/Markers/Annotations is available here: http://pub.ist.ac.at/~schloegl/matlab/eeg/EventCodes.html The latest list of supported data formats is available here: http://pub.ist.ac.at/~schloegl/biosig/TESTED File(s): ------------- README this file biosig.h definition of external biosig interface biosig-dev.h definition of internal functions biosig.c SOPEN, SREAD, SWRITE, SEOF, SCLOSE functions save2gdf.c converter between various file formats. physicalunit.c en-/decodes physical units according to ISO/DIS 11073-10101:2003 mexSLOAD.cpp is a MEX-File for loading data in Octave and Matab. t210/* reading SCP,FAMOS file format t220/* writing SCP file format t230/* support of HL7aECG file format t240/* Support for CNSystems' File Exchange Format (CNS-FEF), note this is different to CENTS14271 in t241/ t241/*.asn1 ASN.1 specification of ISO11073-xxxxx and CENTS-14271 (FEF), test0/* scripts and functions for testing Makefile script for compiling and testing under GNU/Linux Makefile.win32 script for compiling and testing on win32 using mingw mex/* Octave/Matlab binding through MEX-interface mma/* MathLink interface to mathematica win32/* library and executables for Windows python/*.py show example and demo src/*.c applications: flowmon reads data from serial port, ttl2trig reads data from audio card More information is available at http://biosig.sf.net/ If you have any questions you can also contact the mailinglist https://lists.sourceforge.net/lists/listinfo/biosig-general Copyright (C) 2005-2020 Alois Schloegl This function is part of the BioSig repository at http://biosig.sf.net/ biosig-2.3.3/Makefile0000664000175000017500000001145514105434244014626 0ustar schloeglschloegl####### Main Makefile for building the various biosig tools #################### ### ### Copyright (C) 2010-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ################################################################################ exec_prefix ?= $(prefix) first :: lib tools java: lib $(MAKE) -C biosig4c++/java lib: $(MAKE) -C biosig4c++ lib tools: lib $(MAKE) -C biosig4c++ tools mma mathematica: lib $(MAKE) -C biosig4c++/mma mex4m matlab: lib $(MAKE) -C biosig4c++/mex mex4m R: lib $(MAKE) -C biosig4c++/R install :: $(MAKE) -C biosig4c++ install install -d $(DESTDIR)/usr/local/share/biosig/matlab cp -r biosig4matlab/* $(DESTDIR)/usr/local/share/biosig/matlab/ -rm -rf $(DESTDIR)/usr/local/share/biosig/matlab/maybe-missing uninstall :: $(MAKE) -C biosig4c++ uninstall -rm -rf $(DESTDIR)/usr/local/share/biosig clean :: $(MAKE) -C biosig4c++/mma clean $(MAKE) -C biosig4c++ clean -rm mexbiosig*.src.tar.gz -rm biosig4octave*.src.tar.gz distclean : clean # also configure.ac for list of files -rm config.log -rm config.status rm Makefile biosig4c++/Makefile biosig4c++/*/Makefile \ biosig4c++/python/setup.py \ biosig4c++/R/DESCRIPTION ifneq (:,/usr/bin/java) ifneq (:,/usr/bin/javac) first :: lib -$(MAKE) -C biosig4c++/java endif clean :: -$(MAKE) -C biosig4c++/java clean test :: -$(MAKE) -C biosig4c++/java test endif ifneq (:,:) first :: lib $(MAKE) -C biosig4c++/mma install :: -$(MAKE) -C biosig4c++/mma install uninstall :: -$(MAKE) -C biosig4c++/mma uninstall endif ifneq (:,:) MATLAB_MEX := $(shell dirname :)/mex first :: $(MAKE) -C biosig4c++/mex mex4m install :: $(MAKE) -C biosig4c++/mex install uninstall :: $(MAKE) -C biosig4c++/mex uninstall endif # source package mexbiosig and biosig4octave first :: biosig4octave mexbiosig :: $(MAKE) -C biosig4c++ mexbiosig ln -sf biosig4c++/mex/mexbiosig-2.3.3.src.tar.gz biosig4octave :: $(MAKE) -C biosig4c++ biosig4octave ln -sf biosig4c++/mex/biosig4octave-2.3.3.src.tar.gz ifneq (:,/usr/bin/octave) ifneq (:,/usr/bin/mkoctfile) BIOSIG_MEX_DIR = $(DESTDIR)$(shell octave-config -p LOCALOCTFILEDIR)/biosig BIOSIG_DIR = $(DESTDIR)$(shell octave-config -p LOCALFCNFILEDIR)/biosig first :: MKOCTFILE="/usr/bin/mkoctfile" $(MAKE) -C biosig4c++/mex mex4o install :: # mexbiosig #-/usr/bin/octave --no-gui --eval "pkg install -global biosig4c++/mex/mexbiosig-2.3.3.src.tar.gz" # *.mex install -d $(BIOSIG_MEX_DIR) install biosig4c++/mex/*.mex $(BIOSIG_MEX_DIR) # biosig for octave and matlab install -d $(BIOSIG_DIR) cp -r biosig4matlab/* $(BIOSIG_DIR) -rm -rf $(BIOSIG_DIR)/maybe-missing uninstall :: # mexbiosig #-/usr/bin/octave --no-gui --eval "pkg uninstall -global mexbiosig" # *.mex -rm -rf $(BIOSIG_MEX_DIR) # biosig for octave and matlab -rm -rf $(BIOSIG_DIR) endif endif ifneq (:,:) first :: -$(MAKE) -C biosig4c++/php install :: -$(MAKE) -C biosig4c++/php install clean :: -$(MAKE) -C biosig4c++/php clean endif ifneq (:,/usr/bin/python3) first :: python python :: -PYTHON=/usr/bin/python3 $(MAKE) -C biosig4c++/python sdist -$(foreach py, $(shell pyversions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python build; ) -$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python build; ) install :: -PYTHON=/usr/bin/python3 $(MAKE) -C biosig4c++/python install -$(foreach py, $(shell pyversions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python install; ) -$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python install; ) uninstall :: -/usr/bin/python3 -m pip uninstall -y Biosig -$(foreach py, $(shell pyversions -i), $(py) -m pip uninstall -y Biosig;) -$(foreach py, $(shell py3versions -i), $(py) -m pip uninstall -y Biosig;) clean :: $(MAKE) -C biosig4c++/python clean endif ifneq (:,/usr/bin/R) first :: -$(MAKE) -C biosig4c++/R build install :: -$(MAKE) -C biosig4c++/R install clean :: -$(MAKE) -C biosig4c++/R clean endif all: first #win32 win64 #sigviewer #win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer #---- automatic remaking ---------------------------------------------------# # https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Automatic-Remaking.html#Automatic-Remaking #---------------------------------------------------------------------------# $(srcdir)/configure: configure.ac aclocal.m4 autoconf # autoheader might not change config.h.in, so touch a stamp file. $(srcdir)/config.h.in: stamp-h.in $(srcdir)/stamp-h.in: configure.ac aclocal.m4 autoheader echo timestamp > '$(srcdir)/stamp-h.in' config.h: stamp-h stamp-h: config.h.in config.status ./config.status Makefile: Makefile.in config.status ./config.status config.status: configure ./config.status --recheck biosig-2.3.3/config.h0000664000175000017500000002601014105434245014576 0ustar schloeglschloegl/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ /* #undef CRAY_STACKSEG_END */ /* Define to 1 if using `alloca.c'. */ /* #undef C_ALLOCA */ /* Define to 1 if you have the `alarm' function. */ #define HAVE_ALARM 1 /* Define to 1 if you have `alloca', as a function or macro. */ #define HAVE_ALLOCA 1 /* Define to 1 if you have and it should be used (not on Ultrix). */ #define HAVE_ALLOCA_H 1 /* Define to 1 if you have the header file. */ #define HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `atexit' function. */ #define HAVE_ATEXIT 1 /* Define to 1 if you have the `bzero' function. */ #define HAVE_BZERO 1 /* Define to 1 if you have the `dup2' function. */ #define HAVE_DUP2 1 /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_FLOAT_H 1 /* Define to 1 if you have the `floor' function. */ /* #undef HAVE_FLOOR */ /* Define to 1 if you have the `fork' function. */ #define HAVE_FORK 1 /* Define to 1 if you have the `getcwd' function. */ #define HAVE_GETCWD 1 /* Define to 1 if you have the `getdelim' function. */ #define HAVE_GETDELIM 1 /* Define to 1 if you have the `gethostbyname' function. */ #define HAVE_GETHOSTBYNAME 1 /* Define to 1 if you have the `gethostname' function. */ #define HAVE_GETHOSTNAME 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the `asound' library (-lasound). */ #define HAVE_LIBASOUND 1 /* Define to 1 if you have the `iconv' library (-liconv). */ /* #undef HAVE_LIBICONV */ /* Define to 1 if you have the `libmex' library (-llibmex). */ /* #undef HAVE_LIBLIBMEX */ /* Define to 1 if you have the `libmx' library (-llibmx). */ /* #undef HAVE_LIBLIBMX */ /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LOCALE_H 1 /* Define to 1 if you have the `localtime_r' function. */ #define HAVE_LOCALTIME_R 1 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #define HAVE_MALLOC 1 /* Define to 1 if you have the header file. */ #define HAVE_MALLOC_H 1 /* Define to 1 if you have the `memchr' function. */ #define HAVE_MEMCHR 1 /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `mkdir' function. */ #define HAVE_MKDIR 1 /* Define to 1 if you have the `modf' function. */ #define HAVE_MODF 1 /* Define to 1 if you have the header file. */ #define HAVE_NETDB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NETINET_IN_H 1 /* Define to 1 if you have the `pow' function. */ /* #undef HAVE_POW */ /* Define to 1 if the system has the type `ptrdiff_t'. */ #define HAVE_PTRDIFF_T 1 /* Define to 1 if you have the `putenv' function. */ #define HAVE_PUTENV 1 /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #define HAVE_REALLOC 1 /* Define to 1 if you have the `rmdir' function. */ #define HAVE_RMDIR 1 /* Define to 1 if you have the `select' function. */ #define HAVE_SELECT 1 /* Define to 1 if you have the `setenv' function. */ #define HAVE_SETENV 1 /* Define to 1 if you have the `setlocale' function. */ #define HAVE_SETLOCALE 1 /* Define to 1 if you have the `socket' function. */ #define HAVE_SOCKET 1 /* Define to 1 if you have the header file. */ #define HAVE_STDDEF_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `strcasecmp' function. */ #define HAVE_STRCASECMP 1 /* Define to 1 if you have the `strchr' function. */ #define HAVE_STRCHR 1 /* Define to 1 if you have the `strcspn' function. */ #define HAVE_STRCSPN 1 /* Define to 1 if you have the `strdup' function. */ #define HAVE_STRDUP 1 /* Define to 1 if you have the `strerror' function. */ #define HAVE_STRERROR 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strncasecmp' function. */ #define HAVE_STRNCASECMP 1 /* Define to 1 if you have the `strndup' function. */ #define HAVE_STRNDUP 1 /* Define to 1 if you have the `strpbrk' function. */ #define HAVE_STRPBRK 1 /* Define to 1 if you have the `strrchr' function. */ #define HAVE_STRRCHR 1 /* Define to 1 if you have the `strspn' function. */ #define HAVE_STRSPN 1 /* Define to 1 if you have the `strstr' function. */ #define HAVE_STRSTR 1 /* Define to 1 if you have the `strtol' function. */ #define HAVE_STRTOL 1 /* Define to 1 if you have the `strtoul' function. */ #define HAVE_STRTOUL 1 /* Define to 1 if you have the `strtoumax' function. */ #define HAVE_STRTOUMAX 1 /* Define to 1 if you have the header file. */ #define HAVE_SYSLOG_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_TERMIOS_H 1 /* Define to 1 if you have the `tzset' function. */ #define HAVE_TZSET 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the `vfork' function. */ #define HAVE_VFORK 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_VFORK_H */ /* Define to 1 if `fork' works. */ #define HAVE_WORKING_FORK 1 /* Define to 1 if `vfork' works. */ #define HAVE_WORKING_VFORK 1 /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "biosig" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "biosig 2.3.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "biosig" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "2.3.3" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ /* #undef STACK_DIRECTION */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # define __EXTENSIONS__ 1 #endif /* Define to 1 if on MINIX. */ /* #undef _MINIX */ /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef _POSIX_SOURCE */ /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ /* #undef _UINT32_T */ /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ /* #undef _UINT64_T */ /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ /* #undef _UINT8_T */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus /* #undef inline */ #endif /* Define to the type of a signed integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ /* #undef int16_t */ /* Define to the type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ /* #undef int32_t */ /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ /* #undef int64_t */ /* Define to the type of a signed integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ /* #undef int8_t */ /* Define to rpl_malloc if the replacement function should be used. */ /* #undef malloc */ /* Define to `int' if does not define. */ /* #undef mode_t */ /* Define to `int' if does not define. */ /* #undef pid_t */ /* Define to rpl_realloc if the replacement function should be used. */ /* #undef realloc */ /* Define to `unsigned int' if does not define. */ /* #undef size_t */ /* Define to `int' if does not define. */ /* #undef ssize_t */ /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ /* #undef uint16_t */ /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ /* #undef uint32_t */ /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ /* #undef uint64_t */ /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ /* #undef uint8_t */ /* Define as `fork' if `vfork' does not work. */ /* #undef vfork */ biosig-2.3.3/config.h.in0000664000175000017500000002476714105434236015224 0ustar schloeglschloegl/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if you have the `bzero' function. */ #undef HAVE_BZERO /* Define to 1 if you have the `dup2' function. */ #undef HAVE_DUP2 /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FLOAT_H /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the `getdelim' function. */ #undef HAVE_GETDELIM /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `asound' library (-lasound). */ #undef HAVE_LIBASOUND /* Define to 1 if you have the `iconv' library (-liconv). */ #undef HAVE_LIBICONV /* Define to 1 if you have the `libmex' library (-llibmex). */ #undef HAVE_LIBLIBMEX /* Define to 1 if you have the `libmx' library (-llibmx). */ #undef HAVE_LIBLIBMX /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the `memchr' function. */ #undef HAVE_MEMCHR /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the `modf' function. */ #undef HAVE_MODF /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW /* Define to 1 if the system has the type `ptrdiff_t'. */ #undef HAVE_PTRDIFF_T /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strcspn' function. */ #undef HAVE_STRCSPN /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strpbrk' function. */ #undef HAVE_STRPBRK /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strspn' function. */ #undef HAVE_STRSPN /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define to 1 if you have the `strtoumax' function. */ #undef HAVE_STRTOUMAX /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the `tzset' function. */ #undef HAVE_TZSET /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to the type of a signed integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef int16_t /* Define to the type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef int32_t /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef int64_t /* Define to the type of a signed integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef int8_t /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `int' if does not define. */ #undef mode_t /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t /* Define as `fork' if `vfork' does not work. */ #undef vfork biosig-2.3.3/biosig4c++/0000775000175000017500000000000014105434245015012 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/pdp2gdf.c0000664000175000017500000001227414105434233016507 0ustar schloeglschloegl/* $Id: pdp2gdf.c,v 1.1 2009-03-23 22:01:51 schloegl Exp $ Copyright (C) 2009 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include #include "biosig-network.h" #ifdef __cplusplus extern "C" { #endif int savelink(const char* filename); #ifdef __cplusplus } #endif #ifdef WITH_PDP void sopen_pdp_read(HDRTYPE *hdr); #endif int main (int argc, char *argv[]) { int k,s,status; register int sd; struct stat info; int state; char *filename = NULL; char *hostname = "129.27.3.99"; //"localhost" char *dest = NULL; int VERBOSE = 1; int numopt = 0; for (k=1; k\n"); fprintf(stdout," is the source file (an unencrypted pdp-file)\n"); fprintf(stdout," The converted data is stored in .gdf\n"); fprintf(stdout," A link file is also stored in /tmp/.bscs[.n]\n"); fprintf(stdout," The data can be also loaded from the server into Matlab/Octave with [data,HDR]=mexSLOAD('/tmp/.bscs[.n]');\n"); fprintf(stdout," or with [data,HDR]=mexSLOAD('bscs:///ID');\n"); fprintf(stdout,"\n Supported OPTIONS are:\n"); fprintf(stdout," -v, --version\n\tprints version information\n"); fprintf(stdout," -h, --help \n\tprints this information\n"); fprintf(stdout,"\n\n"); return(0); } else if (!strncmp(argv[k],"-VERBOSE",2)) { VERBOSE = argv[k][strlen(argv[k])-1]-48; #ifndef VERBOSE_LEVEL // then VERBOSE_LEVEL is not a constant but a variable VERBOSE_LEVEL = VERBOSE; #endif } else if (numopt==0) { filename = argv[k]; numopt++; } else if (numopt==1) { hostname = argv[k]; numopt++; } else if (numopt==2) { dest = argv[k]; numopt++; } else fprintf(stdout,"arg%i: <%s>\n",k,argv[k]); if (filename==NULL) { fprintf(stdout,"PDP2GDF send PDP data to a server and retrieves the corresponding data in GDF.\n For more details see pdp2gdf -h\n"); return(0); } #define VERBOSE_LEVEL 8 sd = bscs_connect(hostname); if(sd<0) { perror("cannot connect to server"); exit(1); } SERVER_STATE = STATE_INIT; uint64_t ID = 0; ID = 0; s = bscs_open(sd, &ID); if (s) fprintf(stderr,"bscs open failed %x %lx\n",s,ID); savelink(filename); // store if (VERBOSE_LEVEL>7) fprintf(stdout,"bscs opened \n"); // s = bscs_nop(sd); s = bscs_put_file(sd, filename); if (s) fprintf(stderr,"put file failed %x\n",s); if (VERBOSE_LEVEL>7) fprintf(stdout,"put file %lx done \n",ID); char *fn = (char*) malloc(strlen(hostname)+25); #ifdef _WIN32 sprintf(fn,"bscs://%s/%08lx%08lx",hostname,*((uint32_t*)&ID+1),*((uint32_t*)&ID)); #else sprintf(fn,"bscs://%s/%016lx",hostname,ID); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"get file %s \n",fn); if (!dest) { dest = (char*)malloc(strlen(filename)+5); strcpy(dest,filename); strcat(dest,".gdf"); bscs_get_file(sd,ID,dest); free(dest); } else bscs_get_file(sd,ID,dest); /* fprintf(stdout,"Data is available from %s\n",fn); HDRTYPE *hdr = sopen(fn,"r",NULL); if ((status=serror())) { destructHDR(hdr); fprintf(stderr,"Could not load file from server (%s)\n",fn); exit(status); } sread(NULL,0,hdr->NRec,hdr); sclose(hdr); fn = (char*) realloc(fn,strlen(filename)+5); strcpy(fn,filename); strcat(fn,".gdf"); hdr->TYPE = GDF; hdr->VERSION = 2.11; hdr->FileName = fn; hdr = sopen(fn, "wb", hdr); if ((status=serror())) { destructHDR(hdr); exit(status); } swrite(hdr->data.block, hdr->NRec, hdr); sclose(hdr); destructHDR(hdr); */ s = bscs_close(sd); if (VERBOSE_LEVEL>7) fprintf(stdout,"bscs close \n"); bscs_disconnect(sd); } biosig-2.3.3/biosig4c++/units.i0000664000175000017500000002106514105434245016332 0ustar schloeglschloegl#if 0 ### This file is autogenerated - Do not modify it !!! ### ### Vital Signs Units of Measurement # prEN ISO 11073-10101 (Nov 2003) # ISO/IEEE 11073-10101:2004 # Health Informatics - Point-of-care medical device communications - Part 10101: Nomenclature # p.62-75. Table A.6.3: Vital signs units of measurements # # CEN/TC251/PT40 2001 # File Exchange Format for Vital Signs - Annex A # # Copyright (C) 2005,2006,2008,2012,2016 Alois Schloegl # This file is part of the biosig project http://biosig.sf.net/ # # In some cases, there are more than one text representation for a certain code. #endif { 0, "?" }, { 512, "-" }, { 544, "%" }, { 544, "percent" }, { 576, "ppht" }, { 608, "ppm" }, { 640, "ppmd" }, { 672, "ppb" }, { 704, "ppt" }, { 736, "degree" }, { 768, "rad" }, { 800, "g g-1" }, { 832, "g kg-1" }, { 864, "mol mol-1" }, { 896, "l l-1" }, { 928, "m m-3" }, { 960, "m cm-3" }, { 6240, "vol %" }, { 992, "pH" }, { 1024, "drop" }, { 1056, "rbc" }, { 1088, "beat" }, { 1120, "breath" }, { 1152, "cell" }, { 1184, "cough" }, { 1216, "sigh" }, { 1248, "%PCV" }, { 1280, "m" }, { 1312, "yd" }, { 1344, "ft" }, { 1376, "in" }, { 1408, "lm-2" }, { 1440, "m-1" }, { 1472, "m2" }, { 1504, "in2" }, { 1536, "m-2" }, { 1568, "m3" }, { 1600, "l" }, { 1632, "l breath-1" }, { 6112, "l beat-1" }, { 1664, "m-3" }, { 1696, "l-1" }, { 1728, "g" }, { 1760, "lb" }, { 1792, "oz" }, { 1824, "g-1" }, { 1856, "g m" }, { 1888, "g m m-2" }, { 1920, "kg m2" }, { 1952, "kg m-2" }, { 1984, "g m-3" }, { 2016, "g cm-3" }, { 2048, "g l-1" }, { 2080, "g cl-3" }, { 2112, "g dl-3" }, { 2144, "g ml-3" }, { 2176, "s" }, { 2208, "min" }, { 2240, "h" }, { 2272, "d" }, { 2304, "weeks" }, { 2336, "mth" }, { 2368, "y" }, { 2400, "TOD" }, { 2432, "DATE" }, { 2464, "s-1" }, { 2496, "Hz" }, { 2528, "min-1" }, { 2560, "h-1" }, { 2592, "d-1" }, { 2624, "week-1" }, { 2656, "mth-1" }, { 2688, "y-1" }, { 2720, "bpm" }, { 2752, "puls min-1" }, { 2784, "resp min-1" }, { 2816, "m s-1" }, { 2848, "l min-1 m-2" }, { 2848, "l/(min*m²)" }, { 2880, "m2 s-1" }, { 2912, "m3 s-1" }, { 2944, "m3 min-1" }, { 2976, "m3 h-1" }, { 3008, "m3 d-1" }, { 3040, "l s-1" }, { 3072, "l min-1" }, { 3072, "l/min" }, { 3104, "l h-1" }, { 3136, "l d-1" }, { 3168, "l kg-1" }, { 3200, "m3 kg-1" }, { 3232, "m Pa-1s-1" }, { 3264, "l min-1 mmHG-1" }, { 3296, "g s-1" }, { 3328, "g m-1" }, { 3360, "g h-1" }, { 3392, "g d-1" }, { 3424, "g kg-1 s-1" }, { 3456, "g kg-1 m-1" }, { 3488, "g kg-1 h-1" }, { 3520, "g kg-1 d-1" }, { 3552, "g l-1 s-1" }, { 3584, "g l-1 m-1" }, { 3616, "g l-1 h-1" }, { 3648, "g l-1 d-1" }, { 3680, "g m-1 s-1" }, { 3712, "gm s-1" }, { 3744, "Ns" }, { 3776, "N" }, { 3808, "dyn" }, { 3840, "Pa" }, { 3872, "mmHg" }, { 3904, "cm H2O" }, { 3936, "bar" }, { 3968, "J" }, { 4000, "eV" }, { 4032, "W" }, { 4064, "Pa s m-3" }, { 4096, "Pa s l-1" }, { 5888, "l (cmH2O)-1" }, { 6272, "l (mmHg)-1" }, { 6304, "l Pa-1" }, { 6144, "cmH2O l-1" }, { 6336, "mmHg l-1" }, { 6368, "Pa l-1" }, { 4160, "A" }, { 4192, "C" }, { 6080, "Ah" }, { 4224, "A m-1" }, { 4256, "V" }, { 4288, "Ohm" }, { 4320, "Wm" }, { 4352, "F" }, { 4384, "K" }, { 6048, "°C" }, { 4416, "°F" }, { 4448, "K W-1" }, { 4480, "cd" }, { 4512, "osmole" }, { 4544, "mol" }, { 4576, "eq" }, { 4608, "osmol l-1" }, { 4640, "mol cm-3" }, { 4672, "mol m-3" }, { 4704, "mol l-1" }, { 4736, "mol ml-1" }, { 4768, "eq cm-3" }, { 4800, "eq m-3" }, { 4832, "eq l-1" }, { 4864, "eq ml-1" }, { 4896, "osmol kg-1" }, { 4928, "mol kg-1" }, { 4960, "mol s-1" }, { 4992, "mol min-1" }, { 5024, "mol h-1" }, { 5056, "mol d-1" }, { 5088, "eq s-1" }, { 5120, "eq min-1" }, { 5152, "eq h-1" }, { 5184, "eq d-1" }, { 5216, "mol kg-1 s-1" }, { 5248, "mol kg-1 min-1" }, { 5280, "mol kg-1 h-1" }, { 5312, "mol kg-1 d-1" }, { 5344, "eq kg-1 s-1" }, { 5376, "eq kg-1 min-1" }, { 5408, "eq kg-1 h-1" }, { 5440, "eq kg-1 d-1" }, { 5472, "i.u." }, { 5504, "i.u. cm-3" }, { 5536, "i.u. m-3" }, { 5568, "i.u. l-1" }, { 5600, "i.u. ml-1" }, { 5632, "i.u. s-1" }, { 5664, "i.u. min-1" }, { 5696, "i.u. h-1" }, { 5728, "i.u. d-1" }, { 5760, "i.u. kg-1 s-1" }, { 5792, "i.u. kg-1 min-1" }, { 5824, "i.u. kg-1 h-1" }, { 5856, "i.u. kg-1 d-1" }, { 5920, "cmH2O l-1s-1" }, { 5952, "l2s-1" }, { 5984, "cmH2O %-1" }, { 6016, "dyne s m-2 cm-5" }, { 6176, "mmHg %-1" }, { 6208, "Pa %-1" }, { 6432, "B" }, { 6624, "m s-2" }, { 6624, "m/s²" }, { 6656, "rad s2-2" }, { 6688, "ft min-1" }, { 6720, "in min-1" }, { 7776, "" }, { 7808, "dB(V)" }, { 7840, "dB(10V)" }, { 7872, "dB(W)" }, { 7744, "g m-2" }, { 8032, "cm2" }, { 8064, "s-2" }, { 8096, "rpm" }, { 8128, "drops min-1" }, { 6784, "g lb-1 min-1" }, { 6752, "g lb-1 h-1" }, { 6848, "g m-2 min-1" }, { 6816, "g m-2 h-1" }, { 7168, "g m-2 d-1" }, { 8160, "l cmH2O-1 kg-1" }, { 8192, "Wb m-2" }, { 8192, "T" }, { 8224, "Vs" }, { 8256, "V s-1" }, { 8256, "V/s" }, { 8288, "S" }, { 7552, "mol m-2" }, { 7584, "eq kg-1" }, { 7616, "eq m-2" }, { 7424, "mol m-2 s-1" }, { 7456, "mol m-2 min-1" }, { 7488, "mol m-2 h-1" }, { 7520, "mol m-2 d-1" }, { 7040, "eq lb-2 min-1" }, { 7008, "eq lb-2 h-1" }, { 7104, "eq m-2 min-1" }, { 7072, "eq m-2 h-1" }, { 7136, "eq m-2 d-1" }, { 7680, "i.u. kg-1" }, { 7712, "i.u. m-2" }, { 6912, "i.u. lb-1 min-1" }, { 10400, "i.u. lb-1 h-1" }, { 6880, "i.u. lb-1 d-1" }, { 7648, "i.u. m-2 s-1" }, { 6976, "i.u. m-2 min-1" }, { 6944, "i.u. m-2 h-1" }, { 7200, "i.u. m-2 d-1" }, { 8320, "dyne s m2 cm-5" }, { 8352, "cal" }, { 8384, "nutr cal" }, { 8416, "cal d-1" }, { 7264, "L kg-1 min-1" }, { 7232, "L kg-1 h-1" }, { 7296, "L kg-1 d-1" }, { 7328, "L m-2 min-1" }, { 7360, "L m-2 h-1" }, { 7392, "L m-2 d-1" }, { 8448, "J/breath" }, { 8480, "J/L" }, { 10528, "J/mL" }, { 10496, "J/day" }, { 8480, "J/L" }, { 8512, "dyn s cm-5" }, { 8512, "dyne s cm-5" }, { 8544, "PRU" }, { 8576, "WU" }, { 8608, "b" }, { 8640, "B" }, { 8672, "drops/L" }, { 8704, "breaths/min/L" }, { 8736, "breaths^2/min/L" }, { 8768, "L/min/kg" }, { 8800, "sat-sec" }, { 8832, "m/V" }, { 8864, "gf m" }, { 8896, "gf m L-1" }, { 8928, "gf m m-2" }, { 8960, "cal kg-1" }, { 8992, "cal kg-1 d-1" }, { 9024, "cal mL-1" }, { 9056, "arb.u" }, { 9088, "arb.u cm-3" }, { 9120, "arb.u m-3" }, { 9152, "arb.u l-1" }, { 9184, "arb.u ml-1" }, { 9216, "arb.u s-1" }, { 9248, "arb.u min-1" }, { 9280, "arb.u h-1" }, { 9312, "arb.u d-1" }, { 9344, "arb.u kg-1" }, { 9376, "arb.u m-2" }, { 9408, "arb.u kg-1 s-1" }, { 9440, "arb.u kg-1 min-1" }, { 9472, "arb.u kg-1 h-1" }, { 9504, "arb.u kg-1 d-1" }, { 9536, "arb.u lb-1 min-1" }, { 10432, "arb.u lb-1 h-1" }, { 9568, "arb.u lb-1 d-1" }, { 9600, "arb.u m-2 s-1" }, { 9632, "arb.u m-2 min-1" }, { 9664, "arb.u m-2 h-1" }, { 9696, "arb.u m-2 d-1" }, { 9728, "USP.u" }, { 9760, "USP.u cm-3" }, { 9792, "USP.u m-3" }, { 9824, "USP.u l-1" }, { 9856, "USP.u ml-1" }, { 9888, "USP.u s-1" }, { 9920, "USP.u min-1" }, { 9952, "USP.u h-1" }, { 9984, "USP.u d-1" }, { 10016, "USP.u kg-1" }, { 10048, "USP.u m-2" }, { 10080, "USP.u kg-1 s-1" }, { 10112, "USP.u kg-1 min-1" }, { 10144, "USP.u kg-1 h-1" }, { 10176, "USP.u kg-1 d-1" }, { 10208, "USP.u lb-1 min-1" }, { 10464, "USP.u lb-1 h-1" }, { 10240, "USP.u lb-1 d-1" }, { 10272, "USP.u m-2 s-1" }, { 10304, "USP.u m-2 min-1" }, { 10336, "USP.u m-2 h-1" }, { 10368, "USP.u m-2 d-1" }, { 10560, "vol % L-1" }, { 10592, "Pa L-1" }, { 10624, "Pa mL-1" }, { 10656, "bar L-1" }, { 10688, "bar L-1 10-1" }, { 10720, "bar mL-1" }, { 10752, "bar s L-1" }, { 10784, "bar s L-1 10-1" }, { 10816, "L hPa-1" }, { 10848, "L bar-1" }, { 10880, "L mbar-1" }, { 10912, "J/L/s" }, { 10944, "mmHg min-1" }, { 10976, "mmHg s-1" }, { 11008, "bar s-1" }, { 11040, "cmH2O min-1" }, { 11072, "% per 1/2 h" }, { 11104, "L beat-1 m-2" }, { 11136, "V cm-1" }, { 11168, "W cm-2 mm-1" }, { 11200, "cmH2O uV-1" }, { 65088, "mph" }, { 65120, "Nm" }, { 65152, "V/s" }, { 65184, "m/m" }, { 65216, "km/h" }, { 65248, "g s-2" }, { 65280, "g s-3" }, { 65312, "mHg s-1" }, { 65344, "mol l-1 mm" }, { 65376, "r.p.m" }, { 65408, "B" }, { 65440, "dyne s m2 cm-5" }, { 65440, "dyne*s*m²/cm^5" }, { 65472, "l m-2" }, { 65472, "l/m²" }, { 65504, "T" }, biosig-2.3.3/biosig4c++/t230/0000775000175000017500000000000014105434233015477 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/t230/sopen_hl7aecg.cpp0000664000175000017500000015421414105434233020730 0ustar schloeglschloegl/* Copyright (C) 2006,2007,2009,2011,2012,2018 Alois Schloegl Copyright (C) 2007 Elias Apostolopoulos Copyright (C) 2011 Stoyan Mihaylov Copyright (C) 2018 Stefan Soueiha This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ #include // system includes #include // for strtod(3) #include #include "../biosig.h" #if defined(WITH_LIBTINYXML) # define TIXML_USE_STL # include #elif defined(WITH_LIBTINYXML2) # include #else # include "../XMLParser/tinyxml.h" #endif #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * convert time in string format into gdf-time format Currently, the following formats are supported YYYYMMDDhhmmss.uuuuuu YYYYMMDDhhmmss YYYYMMDD in case of error, zero is returned * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ EXTERN_C gdf_time str_time2gdf_time(const char *t1) { struct tm t0; gdf_time T; double fracsec = 0.0; double f; int len; #define MAXLEN 22 char t[MAXLEN+1]; if (t1==NULL) return(0); len = strlen(t1); if (len>MAXLEN) return(0); if (len<8) return(0); strncpy(t,t1,MAXLEN); t[len] = 0; if (VERBOSE_LEVEL>8) fprintf(stdout,"str_time2gdf_time: [%i]<%s>\n",len,t1); char *p = strrchr(t,'.'); if (p==NULL) { // no comma p = t+len; } else { for (p++, f=0.1; p[0]; p++, f=f/10) { if (p[0]<'0' || p[0]>'9') return(0); fracsec += (p[0]-'0')*f; } p = strrchr(t,'.'); } if (VERBOSE_LEVEL>8) fprintf(stdout,"str_time2gdf_time: [%i]<%s>\n",len,t1); if (len>=14) { // decode hhmmss p[0] = '\0'; p-=2; t0.tm_sec = atoi(p); p[0] = '\0'; p-=2; t0.tm_min = atoi(p); p[0] = '\0'; p-=2; t0.tm_hour = atoi(p); p[0] = '\0'; } else { t0.tm_sec = 0; t0.tm_min = 0; t0.tm_hour = 0; } p -= 2; t0.tm_mday = atoi(p); p[0] = '\0'; p-=2; t0.tm_mon = atoi(p)-1; p[0] = '\0'; p-=4; t0.tm_year = atoi(t)-1900; t0.tm_isdst = -1; T = tm_time2gdf_time(&t0); if (fracsec>0) T += ldexp(fracsec/86400,32); if (VERBOSE_LEVEL>8) fprintf(stdout,"str_time2gdf_time: [%i]<%s>\n",len,t1); return(T); } EXTERN_C int sopen_HL7aECG_read(HDRTYPE* hdr) { /* this function is a stub or placeholder and need to be defined in order to be useful. It will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ char tmp[80]; if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7r: [410]\n"); #if defined(TINYXML_INCLUDED) TiXmlDocument doc(hdr->FileName); #elif 0 // defined(TINYXML2_INCLUDED) // this is not ready yet tinyxml2::XMLDocument doc(hdr->FileName); #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "HL7aECG not supported because of missing libtinyxml - recompile with libtinyxml"); return -1; #endif if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7r: [411]\n"); if ( doc.LoadFile() ) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7r: [412]\n"); #if defined(TINYXML_INCLUDED) TiXmlHandle hDoc(&doc); TiXmlHandle geECG = hDoc.FirstChild("CardiologyXML"); TiXmlHandle IHE = hDoc.FirstChild("IHEDocumentList"); TiXmlHandle aECG = hDoc.FirstChild("AnnotatedECG"); TiXmlHandle SierraECG = hDoc.FirstChild("restingECG"); TiXmlHandle SierraECG2 = hDoc.FirstChild("restingecgdata"); #elif defined(TINYXML2_INCLUDED) TINYXML2_LIB XMLNode hDoc(doc); TINYXML2_LIB XMLNode geECG = hDoc.FirstChild("CardiologyXML"); TINYXML2_LIB XMLNode IHE = hDoc.FirstChild("IHEDocumentList"); TINYXML2_LIB XMLNode aECG = hDoc.FirstChild("AnnotatedECG"); TINYXML2_LIB XMLNode SierraECG = hDoc.FirstChild("restingECG"); TINYXML2_LIB XMLNode SierraECG2 = hDoc.FirstChild("restingecgdata"); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [412]\n"); if (SierraECG.Element()) { fprintf(stdout,"Great! Philips Sierra ECG is recognized\n"); } else if (SierraECG2.Element()) { const char *t; const char *e; float notch = 0, lowpass=0, highpass=0; //uint16_t gdftyp = 16; struct tm t0; fprintf(stdout,"Great! Philips Sierra ECG 2 is recognized\n"); TiXmlHandle H = SierraECG2.FirstChild("dataacquisition"); if (H.Element()) { e = SierraECG2.FirstChild("dataacquisition").Element()->Attribute("date"); t0.tm_year = (int)strtod(e,(char**)&e) - 1900; t0.tm_mon = (int)strtod(e+1,(char**)&e) - 1 ; t0.tm_mday = (int)strtod(e+1,(char**)&e); e = SierraECG2.FirstChild("dataacquisition").Element()->Attribute("time"); t0.tm_hour = (int)strtod(e+1,(char**)&e); t0.tm_min = (int)strtod(e+1,(char**)&e); t0.tm_sec = (int)strtod(e+1,(char**)&e); hdr->T0 = tm_time2gdf_time(&t0); } H = SierraECG2.FirstChild("dataacquisition").FirstChild("signalcharacteristics").FirstChild("acsetting"); if (H.Element()) notch = atof(H.Element()->GetText()); H = SierraECG2.FirstChild("reportinfo").FirstChild("reportbandwidth").FirstChild("lowpassfiltersetting"); if (H.Element()) lowpass = atof(H.Element()->GetText()); H = SierraECG2.FirstChild("reportinfo").FirstChild("reportbandwidth").FirstChild("highpassfiltersetting"); if (H.Element()) highpass = atof(H.Element()->GetText()); H = SierraECG2.FirstChild("dataacquisition").FirstChild("acquirer").FirstChild("institutionname"); if (H.Element()) hdr->ID.Hospital = strdup(H.Element()->GetText()); H = SierraECG2.FirstChild("dataacquisition").FirstChild("signalcharacteristics").FirstChild("samplingrate"); if (H.Element()) hdr->SampleRate = atof(H.Element()->GetText()); H = SierraECG2.FirstChild("dataacquisition").FirstChild("signalcharacteristics").FirstChild("signalresolution"); double Cal = 1.0; if (H.Element()) Cal = atof(H.Element()->GetText()); H = SierraECG2.FirstChild("dataacquisition").FirstChild("signalcharacteristics").FirstChild("numberchannelsvalid"); if (H.Element()) hdr->NS = atoi(H.Element()->GetText()); H = SierraECG2.FirstChild("dataacquisition").FirstChild("signalcharacteristics").FirstChild("numberchannelsallocated"); if (H.Element()) { if (hdr->NS != atoi(H.Element()->GetText()) ) fprintf(stdout,"SierraECG: number of channels is ambiguous\n"); } H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("patientid"); if (H.Element()) memcpy(hdr->Patient.Id, H.Element()->GetText(), MAX_LENGTH_PID); hdr->Patient.Name[0] = 0; size_t NameLength = 0; H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("name").FirstChild("lastname"); if (H.Element()) { strncpy(hdr->Patient.Name, H.Element()->GetText(), MAX_LENGTH_NAME); hdr->Patient.Name[MAX_LENGTH_NAME]=0; NameLength = strlen(hdr->Patient.Name); } H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("name").FirstChild("firstname"); if (H.Element()) { const char *str = H.Element()->GetText(); size_t l2 = strlen(str); if (NameLength+l2+1 < MAX_LENGTH_NAME) { hdr->Patient.Name[NameLength]= 0x1f; // unit separator ascii(31) strncpy(hdr->Patient.Name+NameLength+1, str, l2+1); NameLength += l2+1; } } H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("name").FirstChild("middlename"); if (H.Element()) { const char *str = H.Element()->GetText(); size_t l2 = strlen(str); if (NameLength+l2+1 < MAX_LENGTH_NAME) { hdr->Patient.Name[NameLength]= ' '; strncpy(hdr->Patient.Name+NameLength+1, str, l2+1); NameLength += l2+1; } } H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("age").FirstChild("years"); // if (H.Element()) hdr->Patient.Age != atoi(H.Element()->GetText()) H = SierraECG2.FirstChild("patient").FirstChild("generalpatientdata").FirstChild("sex"); if (H.Element()) { t = H.Element()->GetText(); hdr->Patient.Sex = (t[0]=='M') + (t[0]=='m') + 2 * ( (t[0]=='F') + (t[0]=='f') ); } H = SierraECG2.FirstChild("waveforms").FirstChild("parsedwaveforms"); if (H.Element()) { hdr->SPR = atof(H.Element()->Attribute("durationperchannel"))*hdr->SampleRate/1000; } hdr->NRec = 1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (uint16_t k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->GDFTYP = 16; sprintf(hc->Label,"#%i",k); hc->Transducer[0] = 0; hc->Cal = Cal; hc->Off = 0.0; hc->OnOff = 1; hc->DigMin = -ldexp(1,15); hc->DigMax = +ldexp(1,15)-1; hc->PhysMin = hc->DigMin * Cal; hc->PhysMax = hc->DigMax * Cal; hc->PhysDimCode = PhysDimCode("nV"); //strcpy(hc->PhysDim,"nV"); hc->bi = k*hdr->SPR*4; hc->bi8 = 0; hc->LeadIdCode = 0; hc->SPR = hdr->SPR; hc->LowPass = lowpass; hc->HighPass = highpass; hc->Notch = notch; hc->TOffset = 0; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; } hdr->AS.bpb = sizeof(float)*hdr->NS; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, hdr->AS.bpb*hdr->NRec*hdr->SPR); hdr->AS.first = 0; hdr->AS.length= hdr->NRec; if (H.Element()) { const char *e = H.Element()->GetText(); size_t k = 0; while (e != NULL && k < hdr->SPR * (size_t)hdr->NRec * hdr->NS) { ((float*)hdr->AS.rawdata)[k++] = (float)strtod(e,(char**)&e); } } } else if (geECG.Element()) { hdr->ID.Manufacturer.Name = "GE"; TiXmlHandle H = geECG.FirstChild("ClinicalInfo").FirstChild("ObservationDateTime"); if (H.Element()) { struct tm t0; t0.tm_hour = atoi(H.FirstChild("Hour").Element()->GetText()); t0.tm_min = atoi(H.FirstChild("Minute").Element()->GetText()); t0.tm_sec = atoi(H.FirstChild("Second").Element()->GetText()); t0.tm_mday = atoi(H.FirstChild("Day").Element()->GetText()); t0.tm_mon = atoi(H.FirstChild("Month").Element()->GetText())-1; t0.tm_year = atoi(H.FirstChild("Year").Element()->GetText())-1900; hdr->T0 = tm_time2gdf_time(&t0); } H = geECG.FirstChild("Device-Type"); if (H.Element()) { strncpy(hdr->ID.Manufacturer._field, H.Element()->GetText(),MAX_LENGTH_PID); hdr->ID.Manufacturer.Model = hdr->ID.Manufacturer._field; } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [413]\n"); H = geECG.FirstChild("PatientInfo"); if (H.Element()) { strncpy(hdr->Patient.Id, H.FirstChild("PID").Element()->GetText(),MAX_LENGTH_PID); const char *tmp = H.FirstChild("PID").Element()->GetText(); hdr->Patient.Sex = (toupper(tmp[0])=='M') + 2*(toupper(tmp[0])=='F'); if (!hdr->FLAG.ANONYMOUS) { const char *str1 = H.FirstChild("Name").FirstChild("FamilyName").Element()->GetText(); const char *str2 = H.FirstChild("Name").FirstChild("GivenName").Element()->GetText(); size_t l1 = str1 ? strlen(str1) : 0; size_t l2 = str2 ? strlen(str2) : 0; if (0 < l1 && l1 <= MAX_LENGTH_PID) strncpy(hdr->Patient.Name, str1, l1+1); if (l1+l2+1 < MAX_LENGTH_PID) { hdr->Patient.Name[l1] = 0x1f; strncpy(hdr->Patient.Name+l1+1, str2, l2+1); } } } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [413]\n"); double Cal=0.0, LP=NAN, HP=NAN, Notch=0.0; hdr->NRec= 0; hdr->SPR = 1; hdr->NS = 1; H = geECG.FirstChild("FilterSetting"); if (H.Element()) { LP = atof(H.FirstChild("LowPass").Element()->GetText()); HP = atof(H.FirstChild("HighPass").Element()->GetText()); if (!strcasecmp("yes",H.FirstChild("Filter50Hz").Element()->GetText())) Notch = 50; else if (!strcasecmp("yes",H.FirstChild("Filter60Hz").Element()->GetText())) Notch = 60; } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [413]\n"); H = geECG.FirstChild("StripData"); TiXmlElement *C = NULL; if (H.Element()) { C = H.FirstChild("NumberOfLeads").Element(); if (C != NULL) hdr->NS = atoi(C->GetText()); C = H.FirstChild("ChannelSampleCountTotal").Element(); if (C != NULL) hdr->NRec = atoi(C->GetText()); hdr->SampleRate = atof(H.FirstChild("SampleRate").Element()->GetText()); Cal = atof(H.FirstChild("Resolution").Element()->GetText()); } uint16_t gdftyp = 3; hdr->AS.bpb = 0; int k=0, NCHAN = hdr->NS; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); C = H.FirstChild("WaveformData").Element(); while (C != NULL) { if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [413] %i\n",k); if (k>=NCHAN) { NCHAN = max(12,(NCHAN+1)*2); hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, NCHAN*sizeof(CHANNEL_TYPE)); } CHANNEL_TYPE *hc = hdr->CHANNEL + k; // default values hc->GDFTYP = gdftyp; hc->PhysDimCode = 4275; //PhysDimCode("uV"); hc->DigMin = (double)(int16_t)0x8000; hc->DigMax = (double)(int16_t)0x7fff; strncpy(hc->Label, C->Attribute("lead"), MAX_LENGTH_LABEL); hc->Transducer[0] = 0; hc->LeadIdCode = 0; size_t j; for (j=0; strcasecmp(hc->Label, LEAD_ID_TABLE[j]) && LEAD_ID_TABLE[j][0]; j++) {}; if (LEAD_ID_TABLE[j][0]) hc->LeadIdCode = j; hc->LowPass = LP; hc->HighPass = HP; hc->Notch = Notch; hc->Impedance = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; // defined hc->Cal = Cal; hc->Off = 0.0; hc->SPR = 1; hc->OnOff = 1; C = C->NextSiblingElement(); k++; } hdr->NS = k; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [417] %i\n",hdr->NS); C = H.FirstChild("WaveformData").Element(); size_t szRawData = 0; size_t SPR = 0; for (k=0; kNS; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [415] %i\n",k); CHANNEL_TYPE *hc = hdr->CHANNEL + k; /* read data samples */ hc->DigMax = -1.0/0.0; hc->DigMin = 1.0/0.0; // int16_t* data = (int16_t*)(hdr->AS.rawdata)+SPR; hc->bi = hdr->AS.bpb; char *s = (char*)C->GetText(); const char *delim = ","; size_t spr = 0; while (s && *s) { s += strspn(s, delim); //skip kommas if (SPR+spr+1 >= szRawData) { szRawData = max(5000,2*szRawData); hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata, szRawData * sizeof(int16_t)); } double d = strtod(s,&s); ((int16_t*)hdr->AS.rawdata)[SPR+spr++] = d; /* get Min/Max */ if (d > hc->DigMax) hc->DigMax = d; if (d < hc->DigMin) hc->DigMin = d; } SPR += spr; hc->SPR = spr; hdr->SPR = lcm(hdr->SPR,spr); hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; C = C->NextSiblingElement(); } hdr->AS.bpb += hdr->SPR * 2; hdr->NRec = 1; hdr->AS.first = 0; hdr->AS.length = hdr->NRec; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [497] %i\n",hdr->NS); } else if (IHE.Element()) { fprintf(stderr,"XML IHE: support for IHE XML is experimental - some important features are not implemented yet \n"); TiXmlHandle activityTime = IHE.FirstChild("activityTime"); TiXmlHandle recordTarget = IHE.FirstChild("recordTarget"); TiXmlHandle author = IHE.FirstChild("author"); /* an IHE file can contain several segments (i.e. components) need to implement TARGET_SEGMENT feature */ TiXmlHandle component = IHE.FirstChild("component"); if (VERBOSE_LEVEL>8) fprintf(stdout,"IHE: [413] \n"); if (author.FirstChild("assignedAuthor").Element()) { // TiXmlHandle noteText = author.FirstChild("noteText").Element(); TiXmlHandle assignedAuthor = author.FirstChild("assignedAuthor").Element(); if (assignedAuthor.FirstChild("assignedDevice").Element()) { TiXmlHandle assignedDevice = assignedAuthor.FirstChild("assignedDevice").Element(); hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; if (assignedDevice.Element()) { strncpy(hdr->ID.Manufacturer._field, assignedDevice.FirstChild("manufacturerModelName").Element()->GetText(), MAX_LENGTH_MANUF); int len = strlen(hdr->ID.Manufacturer._field)+1; hdr->ID.Manufacturer.Model = hdr->ID.Manufacturer._field+len; strncpy(hdr->ID.Manufacturer._field+len, assignedDevice.FirstChild("code").Element()->Attribute("code"),MAX_LENGTH_MANUF-len); len += strlen(hdr->ID.Manufacturer.Model)+1; } } } if (recordTarget.FirstChild("patient").Element()) { TiXmlHandle patient = recordTarget.FirstChild("patient").Element(); TiXmlHandle id = patient.FirstChild("id").Element(); TiXmlHandle patientPatient = patient.FirstChild("patientPatient").Element(); TiXmlHandle providerOrganization = patient.FirstChild("providerOrganization").Element(); if (VERBOSE_LEVEL>8) fprintf(stdout,"IHE: [414] %p %p %p\n",id.Element(),patientPatient.Element(),providerOrganization.Element()); if (id.Element()) { char *strtmp = strdup(id.Element()->Attribute("root")); size_t len = strlen(strtmp); if (len <= MAX_LENGTH_RID) { strcpy(hdr->ID.Recording, strtmp); // Flawfinder: ignore if (strtmp) free(strtmp); strtmp = strdup(id.Element()->Attribute("extension")); size_t l1 = strlen(strtmp); if (len+1+l1 < MAX_LENGTH_RID) { len += 1 + l1; hdr->ID.Recording[len] = ' '; strncpy(hdr->ID.Recording+len+1,strtmp,l1+1); } else fprintf(stdout,"Warning HL7aECG(read): length of Recording ID exceeds maximum length %i>%i\n",(int)(len+1+l1),MAX_LENGTH_PID); } else fprintf(stdout,"Warning HL7aECG(read): length of Recording ID exceeds maximum length %i>%i\n",(int)len,MAX_LENGTH_PID); if (strtmp) free(strtmp); if (VERBOSE_LEVEL>7) fprintf(stdout,"IHE (read): length of Recording ID %i,%i\n",(int)len,MAX_LENGTH_PID); } if (VERBOSE_LEVEL>7) fprintf(stdout,"IHE: [414] RID= %s\n",hdr->ID.Recording); if (providerOrganization.Element()) { hdr->ID.Hospital = strdup(providerOrganization.FirstChild("name").Element()->GetText()); } if (VERBOSE_LEVEL>7) fprintf(stdout,"IHE: [414] hospital %s\n",hdr->ID.Hospital); if (patientPatient.Element()) { if (!hdr->FLAG.ANONYMOUS) { TiXmlHandle Name = patientPatient.FirstChild("name").Element(); if (Name.Element()) { char *str1 = strdup(Name.FirstChild("family").Element()->GetText()); char *str2 = strdup(Name.FirstChild("given").Element()->GetText()); size_t l1 = str1 ? strlen(str1) : 0; size_t l2 = str2 ? strlen(str2) : 0; if (l1 <= MAX_LENGTH_NAME) strcpy(hdr->Patient.Name, str1); // Flawfinder: ignore if (l1+l2+2 <= MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name, str1); // Flawfinder: ignore hdr->Patient.Name[l1] = 0x1f; strcpy(hdr->Patient.Name+l1+1, str2); // Flawfinder: ignore } } } TiXmlHandle Gender = patientPatient.FirstChild("administrativeGenderCode").Element(); TiXmlHandle Birth = patientPatient.FirstChild("birthTime").Element(); if (Gender.Element()) { const char *gender = Gender.Element()->Attribute("code"); hdr->Patient.Sex = (tolower(gender[0])=='m') + (tolower(gender[0])=='f'); } if (Birth.Element()) { hdr->Patient.Birthday = str_time2gdf_time(Birth.Element()->Attribute("value")); } } } if (VERBOSE_LEVEL>8) fprintf(stdout,"IHE: [415] \n"); } else if(aECG.Element()){ if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [412]\n"); size_t len = strlen(aECG.FirstChild("id").Element()->Attribute("root")); if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [413]\n"); strncpy(hdr->ID.Recording,aECG.FirstChild("id").Element()->Attribute("root"),MAX_LENGTH_RID); if (len>MAX_LENGTH_RID) fprintf(stdout,"Warning HL7aECG(read): length of Recording ID exceeds maximum length %i>%i\n",(int)len,MAX_LENGTH_PID); if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [414]\n"); TiXmlHandle effectiveTime = aECG.FirstChild("effectiveTime"); char *T0 = NULL; if(effectiveTime.FirstChild("low").Element()) T0 = (char *)effectiveTime.FirstChild("low").Element()->Attribute("value"); else if(effectiveTime.FirstChild("center").Element()) T0 = (char *)effectiveTime.FirstChild("center").Element()->Attribute("value"); if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [413 2] <%s>\n", T0); if (T0 != NULL) hdr->T0 = str_time2gdf_time(T0); if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [413 4]\n"); TiXmlHandle demographic = aECG.FirstChild("componentOf").FirstChild("timepointEvent").FirstChild("componentOf").FirstChild("subjectAssignment").FirstChild("subject").FirstChild("trialSubject"); TiXmlElement *id = demographic.FirstChild("id").Element(); if(id) { const char* tmpstr = id->Attribute("extension"); size_t len = strlen(tmpstr); if (len>MAX_LENGTH_PID) fprintf(stdout,"Warning HL7aECG(read): length of Patient Id exceeds maximum length %i>%i\n",(int)len,MAX_LENGTH_PID); strncpy(hdr->Patient.Id,tmpstr,MAX_LENGTH_PID); } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [413]\n"); if (!hdr->FLAG.ANONYMOUS) { demographic = demographic.FirstChild("subjectDemographicPerson"); TiXmlElement *Name1 = demographic.FirstChild("name").Element(); if (Name1 != NULL) { const char *name = Name1->GetText(); if (name != NULL) { size_t len = strlen(name); if (len>MAX_LENGTH_NAME) fprintf(stdout,"Warning HL7aECG(read): length of Patient Name exceeds maximum length %i>%i\n",(int)len,MAX_LENGTH_PID); strncpy(hdr->Patient.Name, name, MAX_LENGTH_NAME); } else { fprintf(stderr,"Warning: composite subject name is not supported.\n"); if (VERBOSE_LEVEL>7) { fprintf(stdout,"hl7r: [413++]<%s>\n",name); for (int k=1;k<40;k++) fprintf(stderr,"%c.",((char*)Name1)[k]); } //hdr->Patient.Name[0] = 0; /* ### FIXME: support of composite patient name. const char *Name11 = Name1->Attribute("family"); fprintf(stdout,"Patient Family Name %p\n", Name11); char *Name2 = Name.FirstChild("given")->GetText(); if ((Name1!=NULL) || (Name2!=NULL)) { strncpy(hdr->Patient.Name, Name1, MAX_LENGTH_NAME); } */ } } else { hdr->Patient.Name[0] = 0; fprintf(stderr,"Warning: Patient Name not available could not be read.\n"); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [414]\n"); /* non-standard fields height and weight */ TiXmlElement *weight = demographic.FirstChild("weight").Element(); if (weight) { uint16_t code = PhysDimCode(weight->Attribute("unit")); if ((code & 0xFFE0) != 1728) fprintf(stderr,"Warning: incorrect weight unit (%s)\n",weight->Attribute("unit")); else // convert to kilogram hdr->Patient.Weight = (uint8_t)(atof(weight->Attribute("value"))*PhysDimScale(code)*1e-3); } TiXmlElement *height = demographic.FirstChild("height").Element(); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [415]\n"); if (height) { uint16_t code = PhysDimCode(height->Attribute("unit")); if ((code & 0xFFE0) != 1280) fprintf(stderr,"Warning: incorrect height unit (%s) %i \n",height->Attribute("unit"),code); else // convert to centimeter hdr->Patient.Height = (uint8_t)(atof(height->Attribute("value"))*PhysDimScale(code)*1e+2); } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [416]\n"); TiXmlElement *birthday = demographic.FirstChild("birthTime").Element(); if(birthday){ T0 = (char *)birthday->Attribute("value"); if (T0==NULL) T0=(char *)birthday->GetText(); // workaround for reading two different formats hdr->Patient.Birthday = str_time2gdf_time(T0); } if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [417]\n"); if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [418]\n"); TiXmlElement *sex = demographic.FirstChild("administrativeGenderCode").Element(); if(sex){ if (sex->Attribute("code")==NULL) hdr->Patient.Sex = 0; else if(!strcmp(sex->Attribute("code"),"F")) hdr->Patient.Sex = 2; else if(!strcmp(sex->Attribute("code"),"M")) hdr->Patient.Sex = 1; else hdr->Patient.Sex = 0; } else { hdr->Patient.Sex = 0; } if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [419]\n"); int LowPass=0, HighPass=0, Notch=0; TiXmlHandle channels = aECG.FirstChild("component").FirstChild("series").FirstChild("component").FirstChild("sequenceSet"); TiXmlHandle variables = aECG.FirstChild("component").FirstChild("series"); for(TiXmlElement *tmpvar = variables.FirstChild("controlVariable").Element(); tmpvar; tmpvar = tmpvar->NextSiblingElement("controlVariable")){ if(!strcmp(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("code")->Attribute("code"), "MDC_ATTR_FILTER_NOTCH")) Notch = atoi(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("component")->FirstChildElement("controlVariable")->FirstChildElement("value")->Attribute("value")); else if(!strcmp(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("code")->Attribute("code"), "MDC_ATTR_FILTER_LOW_PASS")) LowPass = atoi(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("component")->FirstChildElement("controlVariable")->FirstChildElement("value")->Attribute("value")); else if(!strcmp(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("code")->Attribute("code"), "MDC_ATTR_FILTER_HIGH_PASS")) HighPass = atoi(tmpvar->FirstChildElement("controlVariable")->FirstChildElement("component")->FirstChildElement("controlVariable")->FirstChildElement("value")->Attribute("value")); } if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7r: [421]\n"); hdr->NRec = 1; // hdr->SPR = 1; // hdr->AS.rawdata = (uint8_t *)malloc(hdr->SPR); // int32_t *data; hdr->SampleRate = 1.0/atof(channels.FirstChild("component").FirstChild("sequence").FirstChild("value").FirstChild("increment").Element()->Attribute("value")); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [517] %f\n",hdr->SampleRate); /*************** Annotations **********************/ TiXmlHandle AnnotationSet = aECG.FirstChild("component").FirstChild("series").FirstChild("subjectOf").FirstChild("annotationSet"); TiXmlHandle Annotation = AnnotationSet.Child("component", 1).FirstChild("annotation").FirstChild("component").FirstChild("annotation"); size_t N_Event = 0, N=0; for(int i = 1; AnnotationSet.Child("component", i).FirstChild("annotation").Element(); ++i) { for(int j = 0; j<3; ++j) { Annotation = AnnotationSet.Child("component", i).FirstChild("annotation").Child("component",j).FirstChild("annotation"); if (Annotation.FirstChild("value").Element() == NULL) break; const char *code = Annotation.FirstChild("value").Element()->Attribute("code"); if (code==NULL) break; uint16_t EventTyp1 = 0, EventTyp2 = 0; if (!strcmp(code,"MDC_ECG_WAVC_PWAVE")) { EventTyp1 = 0x0502; // start P-Wave EventTyp2 = 0x8502; // end P-Wave } else if (!strcmp(code,"MDC_ECG_WAVC_QRSWAVE")) { EventTyp1 = 0x0503; // start QRS EventTyp2 = 0x8505; // end QRS } else if (!strcmp(code,"MDC_ECG_WAVC_TWAVE")) { EventTyp1 = 0x0506; // start T-Wave EventTyp2 = 0x8506; // end T-Wave } if ((N+3) > N_Event) { N_Event = max(16,2*(N+2)); hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,N_Event*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,N_Event*sizeof(*hdr->EVENT.POS)); } TiXmlHandle Boundary = Annotation.FirstChild("support").FirstChild("supportingROI").FirstChild("component").FirstChild("boundary").FirstChild("value"); int64_t pos1=0, pos2=0; if (Boundary.FirstChild("low").Element()) { const char *tmpstr = (Boundary.FirstChild("low").Element()->Attribute("value")); pos1 = (ldexp((str_time2gdf_time(tmpstr)-hdr->T0)*86400*hdr->SampleRate,-32)); hdr->EVENT.TYP[N] = EventTyp1; hdr->EVENT.POS[N] = pos1; N++; } if (Boundary.FirstChild("high").Element()) { const char *tmpstr = (Boundary.FirstChild("high").Element()->Attribute("value")); pos2 = (ldexp((str_time2gdf_time(tmpstr)-hdr->T0)*86400*hdr->SampleRate,-32)); hdr->EVENT.TYP[N] = EventTyp2; hdr->EVENT.POS[N] = pos2; N++; } } } hdr->EVENT.N = N; TiXmlHandle channel = channels.Child("component", 1).FirstChild("sequence"); for (hdr->NS = 0; channel.Element(); ++(hdr->NS), channel = channels.Child("component", hdr->NS+1).FirstChild("sequence")) {}; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); channel = channels.Child("component", 1).FirstChild("sequence"); hdr->AS.bpb = 0; size_t szRawData = 0; size_t SPR = 0; hdr->SPR = 1; for(int i = 0; channel.Element(); ++i, channel = channels.Child("component", i+1).FirstChild("sequence")){ const char *code = channel.FirstChild("code").Element()->Attribute("code"); CHANNEL_TYPE *hc = hdr->CHANNEL+i; hc->LeadIdCode = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] %i\n",i); strncpy(hc->Label, code, min(40, MAX_LENGTH_LABEL)); hc->Label[MAX_LENGTH_LABEL] = '\0'; hc->Transducer[0] = '\0'; hc->GDFTYP = 16; // float32 hc->DigMax = -1.0/0.0; hc->DigMin = 1.0/0.0; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] %i\n",i); char *s = (char*) channel.FirstChild("value").FirstChild("digits").Element()->GetText(); size_t spr = 0; //char *ps = s ? s+strlen(s) : NULL; //end of s if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] %i %p <%s>\n",i,s,s); while (s && *s) { if (SPR+spr+1 >= szRawData) { szRawData = max(5000, 2*szRawData); hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata, szRawData * sizeof(float)); } double d = strtod(s,&s); ((float*)(hdr->AS.rawdata))[SPR + spr++] = d; /* get Min/Max */ if(d > hc->DigMax) hc->DigMax = d; if(d < hc->DigMin) hc->DigMin = d; } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] %i %i\n",i,(int)spr); hc->bi = hdr->AS.bpb; SPR += spr; hc->SPR = spr; if (spr>0) hdr->SPR = lcm(hdr->SPR,spr); hc->OnOff = 1; hc->LeadIdCode = 0; hdr->AS.bpb += hc->SPR * sizeof(float); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420+] %i\n",i); /* scaling factors */ const char *tmpchar; tmpchar = channel.FirstChild("value").FirstChild("scale").Element()->Attribute("value"); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] <%s>\n",tmpchar); hc->Cal = atof(tmpchar); tmpchar = channel.FirstChild("value").FirstChild("origin").Element()->Attribute("value"); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] <%s>\n",tmpchar); hc->Off = atof(tmpchar); hc->DigMax += 1; hc->DigMin -= 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] Cal: %f Off: %f\n",hc->Cal,hc->Off); hc->PhysMax = hc->DigMax*hc->Cal + hc->Off; hc->PhysMin = hc->DigMin*hc->Cal + hc->Off; /* Physical units */ strncpy(tmp, channel.FirstChild("value").FirstChild("origin").Element()->Attribute("unit"),20); hc->PhysDimCode = PhysDimCode(tmp); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7r: [420] %i\n",i); hc->LowPass = LowPass; hc->HighPass = HighPass; hc->Notch = Notch; // hc->XYZ[0] = l_endian_f32( *(float*) (Header2+ 4*k + 224*hdr->NS) ); // hc->XYZ[1] = l_endian_f32( *(float*) (Header2+ 4*k + 228*hdr->NS) ); // hc->XYZ[2] = l_endian_f32( *(float*) (Header2+ 4*k + 232*hdr->NS) ); // //memcpy(&hdr->CHANNEL[k].XYZ,Header2 + 4*k + 224*hdr->NS,12); // hc->Impedance= ldexp(1.0, (uint8_t)Header2[k + 236*hdr->NS]/8); // hc->Impedance = INF; // for(int k1=0; k1<3; hdr->CHANNEL[index].XYZ[k1++] = 0.0); } hdr->FLAG.OVERFLOWDETECTION = 0; if (VERBOSE_LEVEL>7) { fprintf(stdout,"hl7r: [430] %i\n",hdr->AS.B4C_ERRNUM); hdr2ascii(hdr,stdout,3); fprintf(stdout,"hl7r: [431] %i\n",hdr->AS.B4C_ERRNUM); } } else { fprintf(stderr, "%s : failed to parse (2)\n", hdr->FileName); } } else fprintf(stderr, "%s : failed to parse (1)\n", hdr->FileName); return(0); }; EXTERN_C void sopen_HL7aECG_write(HDRTYPE* hdr) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7w: [610] <%s>\n",hdr->FileName); size_t k; for (k=0; kNS; k++) { hdr->CHANNEL[k].GDFTYP = 16; //float32 hdr->CHANNEL[k].SPR *= hdr->NRec; } hdr->SPR *= hdr->NRec; hdr->NRec = 1; hdr->FILE.OPEN=2; return; }; EXTERN_C int sclose_HL7aECG_write(HDRTYPE* hdr){ /* this function is a stub or placeholder and need to be defined in order to be useful. It will be called by the function SOPEN in "biosig.c" Input: HDR structure Output: char* HDR.AS.Header // contains the content which will be written to the file in SOPEN */ if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7c: [910] <%s>\n",hdr->FileName); struct tm *t0; char tmp[80]; #if defined(TINYXML_INCLUDED) TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); doc.LinkEndChild(decl); #elif 0 // defined(TINYXML2_INCLUDED) // this is not ready yet #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "HL7aECG not supported because of missing libtinyxml - recompile with libtinyxml"); return -1; #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"910 %i\n",1); TiXmlElement *root = new TiXmlElement("AnnotatedECG"); root->SetAttribute("xmlns", "urn:hl7-org:v3"); root->SetAttribute("xmlns:voc", "urn:hl7-org:v3/voc"); root->SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); root->SetAttribute("xsi:schemaLocation", "urn:hl7-org:v3/HL7/aECG/2003-12/schema/PORT_MT020001.xsd"); root->SetAttribute("classCode", "OBS"); root->SetAttribute("moodCode", "EVN"); root->SetAttribute("type", "Observation"); doc.LinkEndChild(root); TiXmlElement *rootid = new TiXmlElement("id"); rootid->SetAttribute("root", hdr->ID.Recording); root->LinkEndChild(rootid); TiXmlElement *rootCode = new TiXmlElement("code"); rootCode->SetAttribute("code", "93000"); rootCode->SetAttribute("codeSystem", "2.16.840.1.113883.6.12"); rootCode->SetAttribute("codeSystemName", "CPT-4"); root->LinkEndChild(rootCode); if (VERBOSE_LEVEL>7) fprintf(stdout,"910 %i\n",2); char timelow[24], timehigh[24]; gdf_time t1,t2; t1 = hdr->T0;// + ldexp(timezone/(3600.0*24),32); if (VERBOSE_LEVEL>7) fprintf(stdout,"gdftime: hdr->T0: %ld\n", t1); t0 = gdf_time2tm_time(t1); sprintf(timelow, "%4d%2d%2d%2d%2d%2d", t0->tm_year+1900, t0->tm_mon+1, t0->tm_mday, t0->tm_hour, t0->tm_min, t0->tm_sec); t1 = hdr->T0 + ldexp((hdr->SPR/hdr->SampleRate)/(3600.0*24),32); t0 = gdf_time2tm_time(t1); sprintf(timehigh, "%4d%2d%2d%2d%2d%2d", t0->tm_year+1900, t0->tm_mon+1, t0->tm_mday, t0->tm_hour, t0->tm_min, t0->tm_sec); for(int i=0; i<18; ++i) { if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 920 %i\n",i); if(timelow[i] == ' ') timelow[i] = '0'; if(timehigh[i] == ' ') timehigh[i] = '0'; } if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 930\n"); TiXmlElement *effectiveTime = new TiXmlElement("effectiveTime"); TiXmlElement *effectiveTimeLow = new TiXmlElement("low"); effectiveTimeLow->SetAttribute("value", timelow); effectiveTime->LinkEndChild(effectiveTimeLow); TiXmlElement *effectiveTimeHigh = new TiXmlElement("high"); effectiveTimeHigh->SetAttribute("value", timehigh); effectiveTime->LinkEndChild(effectiveTimeHigh); root->LinkEndChild(effectiveTime); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 931\n"); TiXmlElement *rootComponentOf = new TiXmlElement("componentOf"); rootComponentOf->SetAttribute("typeCode", "COMP"); rootComponentOf->SetAttribute("contextConductionInd", "true"); root->LinkEndChild(rootComponentOf); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 932\n"); TiXmlElement *timePointEvent = new TiXmlElement("timepointEvent"); timePointEvent->SetAttribute("classCode", "CTTEVENT"); timePointEvent->SetAttribute("moodCode", "EVN"); rootComponentOf->LinkEndChild(timePointEvent); TiXmlElement *timePointComponentOf = new TiXmlElement("componentOf"); timePointComponentOf->SetAttribute("typeCode", "COMP"); timePointComponentOf->SetAttribute("contextConductionInd", "true"); timePointEvent->LinkEndChild(timePointComponentOf); TiXmlElement *subjectAssignment = new TiXmlElement("subjectAssignment"); subjectAssignment->SetAttribute("classCode", "CLNTRL"); subjectAssignment->SetAttribute("moodCode", "EVN"); timePointComponentOf->LinkEndChild(subjectAssignment); TiXmlElement *subject = new TiXmlElement("subject"); subject->SetAttribute("typeCode", "SBJ"); subject->SetAttribute("contextControlCode", "OP"); subjectAssignment->LinkEndChild(subject); TiXmlElement *trialSubject = new TiXmlElement("trialSubject"); trialSubject->SetAttribute("classCode", "RESBJ"); subject->LinkEndChild(trialSubject); if (strlen(hdr->Patient.Id)>0) { TiXmlElement *trialSubjectId = new TiXmlElement("id"); trialSubjectId->SetAttribute("extension", hdr->Patient.Id); trialSubject->LinkEndChild(trialSubjectId); } TiXmlElement *trialSubjectDemographicPerson = new TiXmlElement("subjectDemographicPerson"); trialSubjectDemographicPerson->SetAttribute("classCode", "PSN"); trialSubjectDemographicPerson->SetAttribute("determinerCode", "INSTANCE"); trialSubject->LinkEndChild(trialSubjectDemographicPerson); if (VERBOSE_LEVEL>7) fprintf(stdout,"933\n"); if (strlen(hdr->Patient.Name)>0) if (!hdr->FLAG.ANONYMOUS) { TiXmlElement *subjectDemographicPersonName = new TiXmlElement("name"); char tmpstr[MAX_LENGTH_NAME+1]; strcpy(tmpstr, hdr->Patient.Name); char *LastName=strtok(tmpstr, "\x1f"); char *FirstName=strtok(NULL, "\x1f"); /* LastName */ TiXmlElement *subjectDemographicPersonLastName = new TiXmlElement("family"); TiXmlText *lastnameText = new TiXmlText(LastName); subjectDemographicPersonLastName->LinkEndChild(lastnameText); subjectDemographicPersonName->LinkEndChild(subjectDemographicPersonLastName); /* FirstName */ TiXmlElement *subjectDemographicPersonFirstName = new TiXmlElement("given"); TiXmlText *firstnameText = new TiXmlText(FirstName); subjectDemographicPersonFirstName->LinkEndChild(firstnameText); subjectDemographicPersonName->LinkEndChild(subjectDemographicPersonFirstName); trialSubjectDemographicPerson->LinkEndChild(subjectDemographicPersonName); } TiXmlElement *subjectDemographicPersonGender = new TiXmlElement("administrativeGenderCode"); if(hdr->Patient.Sex == 1){ subjectDemographicPersonGender->SetAttribute("code", "M"); subjectDemographicPersonGender->SetAttribute("displayName", "Male"); } else if(hdr->Patient.Sex == 2){ subjectDemographicPersonGender->SetAttribute("code", "F"); subjectDemographicPersonGender->SetAttribute("displayName", "Female"); } else{ subjectDemographicPersonGender->SetAttribute("code", "UN"); subjectDemographicPersonGender->SetAttribute("displayName", "Undefined"); } subjectDemographicPersonGender->SetAttribute("codeSystem", "2.16.840.1.113883.5.1"); subjectDemographicPersonGender->SetAttribute("codeSystemName", "AdministrativeGender"); trialSubjectDemographicPerson->LinkEndChild(subjectDemographicPersonGender); if (hdr->Patient.Birthday>0) { t0 = gdf_time2tm_time(hdr->Patient.Birthday); // TODO: fixme if "t0->tm_sec" sprintf(tmp, "%04d%02d%02d%02d%02d%02d", t0->tm_year+1900, t0->tm_mon+1, t0->tm_mday, t0->tm_hour, t0->tm_min, t0->tm_sec); TiXmlElement *subjectDemographicPersonBirthtime = new TiXmlElement("birthTime"); subjectDemographicPersonBirthtime->SetAttribute("value", tmp); trialSubjectDemographicPerson->LinkEndChild(subjectDemographicPersonBirthtime); } /* write non-standard fields height and weight */ if (hdr->Patient.Weight) { sprintf(tmp,"%i",hdr->Patient.Weight); TiXmlElement *subjectDemographicPersonWeight = new TiXmlElement("weight"); subjectDemographicPersonWeight->SetAttribute("value", tmp); subjectDemographicPersonWeight->SetAttribute("unit", "kg"); trialSubjectDemographicPerson->LinkEndChild(subjectDemographicPersonWeight); } if (hdr->Patient.Height) { sprintf(tmp,"%i",hdr->Patient.Height); TiXmlElement *subjectDemographicPersonHeight = new TiXmlElement("height"); subjectDemographicPersonHeight->SetAttribute("value", tmp); subjectDemographicPersonHeight->SetAttribute("unit", "cm"); trialSubjectDemographicPerson->LinkEndChild(subjectDemographicPersonHeight); } if (VERBOSE_LEVEL>7) fprintf(stdout,"937\n"); TiXmlElement *subjectAssignmentComponentOf = new TiXmlElement("componentOf"); subjectAssignmentComponentOf->SetAttribute("typeCode", "COMP"); subjectAssignmentComponentOf->SetAttribute("contextConductionInd", "true"); subjectAssignment->LinkEndChild(subjectAssignmentComponentOf); TiXmlElement *clinicalTrial = new TiXmlElement("clinicalTrial"); clinicalTrial->SetAttribute("classCode", "CLNTRL"); clinicalTrial->SetAttribute("moodCode", "EVN"); subjectAssignmentComponentOf->LinkEndChild(clinicalTrial); TiXmlElement *clinicalTrialId = new TiXmlElement("id"); clinicalTrialId->SetAttribute("root", "GRATZ"); clinicalTrialId->SetAttribute("extension", "CLINICAL_TRIAL"); clinicalTrial->LinkEndChild(clinicalTrialId); /* location/trialSite/location/name */ /* hdr->ID.Hospital is malloc'ed only if exist */ TiXmlText *t_location = new TiXmlText(hdr->ID.Hospital ? hdr->ID.Hospital : ""); TiXmlElement *s_location_1 = new TiXmlElement("location"); TiXmlElement *s_location_2 = new TiXmlElement("trialSite"); TiXmlElement *s_location_3 = new TiXmlElement("location"); TiXmlElement *s_location_name = new TiXmlElement("name"); s_location_name->LinkEndChild(t_location); s_location_3->LinkEndChild(s_location_name); s_location_2->LinkEndChild(s_location_3); s_location_1->LinkEndChild(s_location_2); clinicalTrial->LinkEndChild(s_location_1); TiXmlElement *rootComponent = new TiXmlElement("component"); rootComponent->SetAttribute("typeCode", "COMP"); rootComponent->SetAttribute("contextConductionInd", "true"); root->LinkEndChild(rootComponent); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 939\n"); TiXmlElement *series = new TiXmlElement("series"); series->SetAttribute("classCode", "OBSSER"); series->SetAttribute("moodCode", "EVN"); rootComponent->LinkEndChild(series); TiXmlElement *seriesCode = new TiXmlElement("code"); seriesCode->SetAttribute("code", "RHYTHM"); seriesCode->SetAttribute("seriesCode", "2.16.840.1.113883.5.4"); series->LinkEndChild(seriesCode); TiXmlElement *seriesEffectiveTime = new TiXmlElement("effectiveTime"); TiXmlElement *seriesEffectiveTimeLow = new TiXmlElement("low"); seriesEffectiveTimeLow->SetAttribute("value", timelow); seriesEffectiveTime->LinkEndChild(seriesEffectiveTimeLow); TiXmlElement *seriesEffectiveTimeHigh = new TiXmlElement("high"); seriesEffectiveTimeHigh->SetAttribute("value", timehigh); seriesEffectiveTime->LinkEndChild(seriesEffectiveTimeHigh); series->LinkEndChild(seriesEffectiveTime); /* Manufacturer device modelname manu name */ TiXmlText *t_modelname = new TiXmlText(hdr->ID.Manufacturer.Model ? hdr->ID.Manufacturer.Model : ""); TiXmlText *t_manuname = new TiXmlText(hdr->ID.Manufacturer.Name ? hdr->ID.Manufacturer.Name : ""); TiXmlElement *s_author = new TiXmlElement("author"); TiXmlElement *s_seriesauthor = new TiXmlElement("seriesAuthor"); TiXmlElement *s_manudev = new TiXmlElement("manufacturedSeriesDevice"); TiXmlElement *s_manumodel = new TiXmlElement("manufacturerModelName"); s_manumodel->LinkEndChild(t_modelname); s_manudev->LinkEndChild(s_manumodel); s_seriesauthor->LinkEndChild(s_manudev); TiXmlElement *s_manuorg = new TiXmlElement("manufacturerOrganization"); TiXmlElement *s_manuorgname = new TiXmlElement("name"); s_manuorgname->LinkEndChild(t_manuname); s_manuorg->LinkEndChild(s_manuorgname); s_seriesauthor->LinkEndChild(s_manuorg); s_author->LinkEndChild(s_seriesauthor); series->LinkEndChild(s_author); for(int i=3; i; --i){ if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 950 %i\n",i); TiXmlElement *seriesControlVariable = new TiXmlElement("controlVariable"); seriesControlVariable->SetAttribute("typeCode", "CTRLV"); series->LinkEndChild(seriesControlVariable); TiXmlElement *CTRLControlVariable = new TiXmlElement("controlVariable"); CTRLControlVariable->SetAttribute("classCode", "OBS"); seriesControlVariable->LinkEndChild(CTRLControlVariable); TiXmlElement *controlVariableCode = new TiXmlElement("code"); CTRLControlVariable->LinkEndChild(controlVariableCode); TiXmlElement *controlVariableComponent = new TiXmlElement("component"); controlVariableComponent->SetAttribute("typeCode", "COMP"); CTRLControlVariable->LinkEndChild(controlVariableComponent); TiXmlElement *componentControlVariable = new TiXmlElement("controlVariable"); componentControlVariable->SetAttribute("classCode", "OBS"); controlVariableComponent->LinkEndChild(componentControlVariable); TiXmlElement *componentControlVariableCode = new TiXmlElement("code"); componentControlVariable->LinkEndChild(componentControlVariableCode); TiXmlElement *componentControlVariableValue = new TiXmlElement("value"); componentControlVariableValue->SetAttribute("xsi:type", "PQ"); componentControlVariable->LinkEndChild(componentControlVariableValue); switch(i){ case 3: controlVariableCode->SetAttribute("code", "MDC_ATTR_FILTER_NOTCH"); componentControlVariableCode->SetAttribute("code", "MDC_ATTR_NOTCH_FREQ"); componentControlVariableValue->SetDoubleAttribute("value", hdr->CHANNEL[0].Notch); break; case 2: controlVariableCode->SetAttribute("code", "MDC_ATTR_FILTER_LOW_PASS"); componentControlVariableCode->SetAttribute("code", "MDC_ATTR_FILTER_CUTOFF_FREQ"); componentControlVariableValue->SetDoubleAttribute("value", hdr->CHANNEL[0].LowPass); break; case 1: controlVariableCode->SetAttribute("code", "MDC_ATTR_FILTER_HIGH_PASS"); componentControlVariableCode->SetAttribute("code", "MDC_ATTR_FILTER_CUTOFF_FREQ"); componentControlVariableValue->SetDoubleAttribute("value", hdr->CHANNEL[0].HighPass); break; } controlVariableCode->SetAttribute("codeSystem", "2.16.840.1.113883.6.24"); controlVariableCode->SetAttribute("codeSystemName", "MDC"); componentControlVariableCode->SetAttribute("codeSystem", "2.16.840.1.113883.6.24"); componentControlVariableCode->SetAttribute("codeSystemName", "MDC"); componentControlVariableValue->SetAttribute("unit", "Hz"); switch(i){ case 3: controlVariableCode->SetAttribute("displayName", "Notch Filter"); componentControlVariableCode->SetAttribute("displayName", "Notch Frequency"); break; case 2: controlVariableCode->SetAttribute("displayName", "Low Pass Filter"); componentControlVariableCode->SetAttribute("displayName", "Cutoff Frequency"); break; case 1: controlVariableCode->SetAttribute("displayName", "High Pass Filter"); componentControlVariableCode->SetAttribute("displayName", "Cutoff Frequency"); break; } } TiXmlElement *seriesComponent = new TiXmlElement("component"); seriesComponent->SetAttribute("typeCode", "COMP"); seriesComponent->SetAttribute("contextConductionInd", "true"); series->LinkEndChild(seriesComponent); TiXmlElement *sequenceSet = new TiXmlElement("sequenceSet"); sequenceSet->SetAttribute("classCode", "OBSCOR"); sequenceSet->SetAttribute("moodCode", "EVN"); seriesComponent->LinkEndChild(sequenceSet); TiXmlElement *sequenceSetComponent = new TiXmlElement("component"); sequenceSetComponent->SetAttribute("typeCode", "COMP"); sequenceSetComponent->SetAttribute("contextConductionInd", "true"); sequenceSet->LinkEndChild(sequenceSetComponent); TiXmlElement *sequence = new TiXmlElement("sequence"); sequence->SetAttribute("classCode", "OBS"); sequence->SetAttribute("moodCode", "EVN"); sequenceSetComponent->LinkEndChild(sequence); TiXmlElement *sequenceCode = new TiXmlElement("code"); sequenceCode->SetAttribute("code", "TIME_ABSOLUTE"); sequenceCode->SetAttribute("codeSystem", "2.16.840.1.113883.6.24"); sequence->LinkEndChild(sequenceCode); TiXmlElement *sequenceValue = new TiXmlElement("value"); sequenceValue->SetAttribute("xsi:type", "GLIST_TS"); sequence->LinkEndChild(sequenceValue); TiXmlElement *valueHead = new TiXmlElement("head"); valueHead->SetAttribute("value", timelow); valueHead->SetAttribute("unit", "s"); // TODO: value is date/time of the day - unit=[s] does not make sense sequenceValue->LinkEndChild(valueHead); TiXmlElement *valueIncrement = new TiXmlElement("increment"); valueIncrement->SetDoubleAttribute("value", 1/hdr->SampleRate); valueIncrement->SetAttribute("unit", "s"); sequenceValue->LinkEndChild(valueIncrement); TiXmlText *digitsText; float*Dat; char *S; char *pS; #ifdef NO_BI size_t bi = 0; #endif for(int i=0; iNS; ++i) if (hdr->CHANNEL[i].OnOff) { if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 960 %i\n",i); sequenceSetComponent = new TiXmlElement("component"); sequenceSetComponent->SetAttribute("typeCode", "COMP"); sequenceSetComponent->SetAttribute("contextConductionInd", "true"); sequenceSet->LinkEndChild(sequenceSetComponent); sequence = new TiXmlElement("sequence"); sequence->SetAttribute("classCode", "OBS"); sequence->SetAttribute("moodCode", "EVN"); sequenceSetComponent->LinkEndChild(sequence); sequenceCode = new TiXmlElement("code"); if (hdr->CHANNEL[i].LeadIdCode) { strcpy(tmp,"MDC_ECG_LEAD_"); // Flawfinder: ignore strcat(tmp,LEAD_ID_TABLE[hdr->CHANNEL[i].LeadIdCode]); // Flawfinder: ignore } else strcpy(tmp,hdr->CHANNEL[i].Label); // Flawfinder: ignore sequenceCode->SetAttribute("code", tmp); sequenceCode->SetAttribute("codeSystem", "2.16.840.1.113883.6.24"); sequenceCode->SetAttribute("codeSystemName", "MDC"); sequence->LinkEndChild(sequenceCode); sequenceValue = new TiXmlElement("value"); sequenceValue->SetAttribute("xsi:type", "SLIST_PQ"); sequence->LinkEndChild(sequenceValue); valueHead = new TiXmlElement("origin"); valueHead->SetDoubleAttribute("value", hdr->CHANNEL[i].Off); // valueHead->SetDoubleAttribute("value", 0); valueHead->SetAttribute("unit", PhysDim3(hdr->CHANNEL[i].PhysDimCode)); sequenceValue->LinkEndChild(valueHead); valueIncrement = new TiXmlElement("scale"); valueIncrement->SetDoubleAttribute("value", hdr->CHANNEL[i].Cal); //valueIncrement->SetDoubleAttribute("value", 1); valueIncrement->SetAttribute("unit", PhysDim3(hdr->CHANNEL[i].PhysDimCode)); sequenceValue->LinkEndChild(valueIncrement); TiXmlElement *valueDigits = new TiXmlElement("digits"); sequenceValue->LinkEndChild(valueDigits); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c [967] %i %f\n",i,*(float*)(hdr->AS.rawdata + hdr->CHANNEL[i].bi)); #ifndef NO_BI Dat=(float*)(hdr->AS.rawdata + hdr->CHANNEL[i].bi); #else Dat=(float*)(hdr->AS.rawdata + bi); #endif //size_t sz = GDFTYP_BITS[hdr->CHANNEL[i].GDFTYP]>>3; S=new char[32*hdr->CHANNEL[i].SPR]; S[0]=0; pS=S; for (unsigned int j=0; jCHANNEL[i].SPR; ++j) { if (VERBOSE_LEVEL>8) fprintf(stdout,"hl7c 969: %i %i %f \n",i, j, Dat [j]); pS+=sprintf(pS,"%g ",Dat[j]); } #ifdef NO_BI bi += hdr->CHANNEL[i].SPR*sz; if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 970 %i %i \n%s \n",i, bi, S); #else if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 970 %i %i \n%s \n",i, hdr->CHANNEL[i].bi, S); #endif digitsText = new TiXmlText(S); valueDigits->LinkEndChild(digitsText); delete []S; } #if defined(WITH_LIBTINYXML) if (hdr->FILE.COMPRESSION) fprintf(stderr,"WARNING: saving of compressed HL7aECG file not supported - compression flag is ignored\n"); int status = doc.SaveFile(hdr->FileName); #else int status = doc.SaveFile(hdr->FileName, (char)hdr->FILE.COMPRESSION); #endif // doc.SaveFile(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 989 (%i)\n",status); return(0); }; biosig-2.3.3/biosig4c++/biosig.c0000664000175000017500000170065214105434233016442 0ustar schloeglschloegl/* Copyright (C) 2005-2020 Alois Schloegl Copyright (C) 2011 Stoyan Mihaylov This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ /* Library function for reading and writing of varios biosignal data formats. It provides also one reference implementation for reading and writing of the GDF data format [1]. Features: - reading and writing of EDF, BDF, GDF1, GDF2, CWFB, HL7aECG, SCP files - reading of ACQ, AINF, BKR, BrainVision, CNT, DEMG, EGI, ETG4000, MFER files The full list of supported formats is shown at http://pub.ist.ac.at/~schloegl/biosig/TESTED implemented functions: - SOPEN, SREAD, SWRITE, SCLOSE, SEOF, SSEEK, STELL, SREWIND References: [1] GDF - A general data format for biomedical signals. available online http://arxiv.org/abs/cs.DB/0608052 */ /* TODO: ensure that hdr->CHANNEL[.].TOffset gets initialized after every alloc() */ #define _GNU_SOURCE #include #include #include #include #include #include // define macro isnan() #include #include #ifdef _WIN32 // Can't include sys/stat.h or sopen is declared twice. #include struct stat { _dev_t st_dev; _ino_t st_ino; unsigned short st_mode; short st_nlink; short st_uid; short st_gid; _dev_t st_rdev; _off_t st_size; time_t st_atime; time_t st_mtime; time_t st_ctime; }; int __cdecl stat(const char *_Filename,struct stat *_Stat); #else #include #endif #ifdef WITH_CURL # include #endif int VERBOSE_LEVEL __attribute__ ((visibility ("default") )) = 0; // this variable is always available, but only used without NDEBUG #include "biosig.h" #include "biosig-network.h" #ifdef _WIN32 #include #include #define FILESEP '\\' #else #include #include /* sockaddr_in and sockaddr_in6 definitions. */ #include #include #define FILESEP '/' #endif #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) char* getlogin (void); char* xgethostname (void); /*----------------------------------------------------------------------- error handling should use error variables local to each HDR otherwise, sopen() etc. is not re-entrant. Therefore, use of variables B4C_ERRNUM and B4C_ERRMSG is deprecated; Use instead serror2(hdr), hdr->AS.B4C_ERRNUM, hdr->AS.B4C_ERRMSG. ----------------------------------------------------------------------- */ // do not expose deprecated interface in libgdf #ifndef ONLYGDF ATT_DEPREC int B4C_ERRNUM = 0; ATT_DEPREC const char *B4C_ERRMSG; #endif #ifdef HAVE_CHOLMOD cholmod_common CHOLMOD_COMMON_VAR; void CSstop() { cholmod_finish(&CHOLMOD_COMMON_VAR); } void CSstart () { cholmod_start (&CHOLMOD_COMMON_VAR) ; /* start CHOLMOD */ atexit (&CSstop) ; } #endif #ifndef ONLYGDF #ifdef __cplusplus extern "C" { #endif int sopen_SCP_read (HDRTYPE* hdr); int sopen_SCP_write (HDRTYPE* hdr); int sopen_HL7aECG_read (HDRTYPE* hdr); void sopen_HL7aECG_write(HDRTYPE* hdr); void sopen_abf_read (HDRTYPE* hdr); void sopen_abf2_read (HDRTYPE* hdr); void sopen_axg_read (HDRTYPE* hdr); void sopen_alpha_read (HDRTYPE* hdr); void sopen_cadwell_read(HDRTYPE* hdr); void sopen_cfs_read (HDRTYPE* hdr); void sopen_FAMOS_read (HDRTYPE* hdr); void sopen_fiff_read (HDRTYPE* hdr); int sclose_HL7aECG_write(HDRTYPE* hdr); void sopen_ibw_read (HDRTYPE* hdr); void sopen_itx_read (HDRTYPE* hdr); void sopen_smr_read (HDRTYPE* hdr); #ifdef WITH_INTAN void sopen_rhd2000_read (HDRTYPE* hdr); void sopen_rhs2000_read (HDRTYPE* hdr); void sopen_intan_clp_read (HDRTYPE* hdr); #endif #ifdef WITH_TDMS void sopen_tdms_read (HDRTYPE* hdr); #endif int sopen_trc_read (HDRTYPE* hdr); int sopen_unipro_read (HDRTYPE* hdr); #ifdef WITH_FEF int sopen_fef_read(HDRTYPE* hdr); int sclose_fef_read(HDRTYPE* hdr); #endif void sopen_heka(HDRTYPE* hdr,FILE *fid); #ifdef HAVE_HDF int sopen_hdf5(HDRTYPE *hdr); #endif #ifdef HAVE_MATIO int sopen_matlab(HDRTYPE *hdr); #endif #if defined(WITH_DICOM) || defined(WITH_DCMTK) int sopen_dicom_read(HDRTYPE* hdr); #endif void sopen_atf_read(HDRTYPE* hdr); void sread_atf(HDRTYPE* hdr); #ifdef __cplusplus } #endif #endif //ONLYGDF const uint16_t GDFTYP_BITS[] __attribute__ ((visibility ("default") )) = { 8, 8, 8,16,16,32,32,64,64,32,64, 0, 0, 0, 0, 0, /* 0 */ 32,64,128,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 32 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 48 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 64 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128: EEG1100 coder, */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,10, 0,12, 0, 0, 0,16, /* 256 - 271*/ 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0,32, /* 255+24 = bit24, 3 byte */ 0, 0, 0, 0, 0, 0, 0,40, 0, 0, 0, 0, 0, 0, 0,48, 0, 0, 0, 0, 0, 0, 0,56, 0, 0, 0, 0, 0, 0, 0,64, 0, 0, 0, 0, 0, 0, 0,72, 0, 0, 0, 0, 0, 0, 0,80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 384 - 399*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,10, 0,12, 0, 0, 0,16, /* 512 - 527*/ 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0,32, 0, 0, 0, 0, 0, 0, 0,40, 0, 0, 0, 0, 0, 0, 0,48, 0, 0, 0, 0, 0, 0, 0,56, 0, 0, 0, 0, 0, 0, 0,64, 0, 0, 0, 0, 0, 0, 0,72, 0, 0, 0, 0, 0, 0, 0,80 }; const char *gdftyp_string[] = { "char","int8","uint8","int16","uint16","int32","uint32","int64","uint64", "","","","","","","","float32","float64","float128" }; const char *LEAD_ID_TABLE[] = { "unspecified", "I","II","V1","V2","V3","V4","V5","V6", "V7","V2R","V3R","V4R","V5R","V6R","V7R","X", "Y","Z","CC5","CM5","LA","RA","LL","fI", "fE","fC","fA","fM","fF","fH","dI", "dII","dV1","dV2","dV3","dV4","dV5", "dV6","dV7","dV2R","dV3R","dV4R","dV5R", "dV6R","dV7R","dX","dY","dZ","dCC5","dCM5", "dLA","dRA","dLL","dfI","dfE","dfC","dfA", "dfM","dfF","dfH","III","aVR","aVL","aVF", "aVRneg","V8","V9","V8R","V9R","D","A","J", "Defib","Extern","A1","A2","A3","A4","dV8", "dV9","dV8R","dV9R","dD","dA","dJ","Chest", "V","VR","VL","VF","MCL","MCL1","MCL2","MCL3", "MCL4","MCL5","MCL6","CC","CC1","CC2","CC3", "CC4","CC6","CC7","CM","CM1","CM2","CM3","CM4", "CM6","dIII","daVR","daVL","daVF","daVRneg","dChest", "dV","dVR","dVL","dVF","CM7","CH5","CS5","CB5","CR5", "ML","AB1","AB2","AB3","AB4","ES","AS","AI","S", "dDefib","dExtern","dA1","dA2","dA3","dA4","dMCL1", "dMCL2","dMCL3","dMCL4","dMCL5","dMCL6","RL","CV5RL", "CV6LL","CV6LU","V10","dMCL","dCC","dCC1","dCC2", "dCC3","dCC4","dCC6","dCC7","dCM","dCM1","dCM2", "dCM3","dCM4","dCM6","dCM7","dCH5","dCS5","dCB5", "dCR5","dML","dAB1","dAB2","dAB3","dAB4","dES", "dAS","dAI","dS","dRL","dCV5RL","dCV6LL","dCV6LU","dV10" /* EEG Leads - non consecutive index ,"NZ","FPZ","AFZ","FZ","FCZ","CZ","CPZ","PZ", "POZ","OZ","IZ","FP1","FP2","F1","F2","F3","F4", "F5","F6","F7","F8","F9","F10","FC1","FC2","FC3", "FC4","FC5","FC6","FT7","FT8","FT9","FT10","C1", "C2","C3","C4","C5","C6","CP1","CP2","CP3","CP4", "CP5","CP6","P1","P2","P3","P4","P5","P6","P9", "P10","O1","O2","AF3","AF4","AF7","AF8","PO3", "PO4","PO7","PO8","T3","T7","T4","T8","T5","P7", "T6","P8","T9","T10","TP7","TP8","TP9","TP10", "A1","A2","T1","T2","PG1","PG2","SP1","SP2", "E0","EL1","EL2","EL3","EL4","EL5","EL6","EL7", "ER1","ER2","ER3","ER4","ER5","ER6","ER7","ELL", "ERL","ELA","ELB","ERA","ERB" */ , "\0\0" }; // stop marker #ifndef ONLYGDF /* This information was obtained from here: http://www.physionet.org/physiotools/wfdb/lib/ecgcodes.h */ const char *MIT_EVENT_DESC[] = { "normal beat", "left bundle branch block beat", "right bundle branch block beat", "aberrated atrial premature beat", "premature ventricular contraction", "fusion of ventricular and normal beat", "nodal (junctional) premature beat", "atrial premature contraction", "premature or ectopic supraventricular beat", "ventricular escape beat", "nodal (junctional) escape beat", "paced beat", "unclassifiable beat", "signal quality change", "condition 15", "isolated QRS-like artifact", "condition 17", "ST change", "T-wave change", "systole", "diastole", "comment annotation", "measurement annotation", "P-wave peak", "left or right bundle branch block", "non-conducted pacer spike", "T-wave peak", "rhythm change", "U-wave peak", "learning", "ventricular flutter wave", "start of ventricular flutter/fibrillation", "end of ventricular flutter/fibrillation", "atrial escape beat", "supraventricular escape beat", "link to external data (aux contains URL)", "non-conducted P-wave (blocked APB)", "fusion of paced and normal beat", "PQ junction (beginning of QRS)", "J point (end of QRS)", "R-on-T premature ventricular contraction", "condition 42", "condition 43", "condition 44", "condition 45", "condition 46", "condition 47", "condition 48", "not-QRS (not a getann/putann code)", // code = 0 is mapped to 49(ACMAX) ""}; #endif //ONLYGDF /* --------------------------------------------------- * * Predefined Event Code Table * * --------------------------------------------------- */ #if (BIOSIG_VERSION < 10500) ATT_DEPREC static uint8_t GLOBAL_EVENTCODES_ISLOADED = 0; ATT_DEPREC struct global_t { uint16_t LenCodeDesc; uint16_t *CodeIndex; const char **CodeDesc; char *EventCodesTextBuffer; } Global; // deprecated since Oct 2012, v1.4.0 #endif // event table desription const struct etd_t ETD [] = { #include "eventcodes.i" {0, 0, ""} }; // event groups const struct event_groups_t EventCodeGroups [] = { #include "eventcodegroups.i" {0xffff, "end-of-table" }, }; /****************************************************************************/ /** **/ /** INTERNAL FUNCTIONS **/ /** **/ /****************************************************************************/ // greatest common divisor uint32_t gcd(uint32_t A, uint32_t B) { uint32_t t; if (A0) { t = B; B = A%B; A = t; } return(A); }; // least common multiple - used for obtaining the common HDR.SPR uint32_t lcm(uint32_t A, uint32_t B) { // return(A*(B/gcd(A,B)) with overflow detection uint64_t A64 = A; A64 *= B/gcd(A,B); if (A64 > 0x00000000ffffffffllu) { fprintf(stderr,"Error: HDR.SPR=LCM(%u,%u) overflows and does not fit into uint32.\n",(unsigned)A,(unsigned)B); } return((uint32_t)A64); }; #ifndef ONLYGDF void* mfer_swap8b(uint8_t *buf, int8_t len, char FLAG_SWAP) { if (VERBOSE_LEVEL==9) fprintf(stdout,"swap=%i %i %i \nlen=%i %2x%2x%2x%2x%2x%2x%2x%2x\n", (int)FLAG_SWAP, __BYTE_ORDER, __LITTLE_ENDIAN, (int)len, (unsigned)buf[0],(unsigned)buf[1],(unsigned)buf[2],(unsigned)buf[3], (unsigned)buf[4],(unsigned)buf[5],(unsigned)buf[6],(unsigned)buf[7] ); #ifndef S_SPLINT_S #if __BYTE_ORDER == __BIG_ENDIAN if (FLAG_SWAP) { unsigned k; for (k=len; k < sizeof(uint64_t); buf[k++]=0); *(uint64_t*)buf = bswap_64(*(uint64_t*)buf); } else { *(uint64_t*)buf >>= (sizeof(uint64_t)-len)*8; } #elif __BYTE_ORDER == __LITTLE_ENDIAN if (FLAG_SWAP) { *(uint64_t*)buf = bswap_64(*(uint64_t*)buf) >> (sizeof(uint64_t)-len)*8; } else { unsigned k; for (k=len; k < sizeof(uint64_t); buf[k++]=0) {}; } #endif #endif if (VERBOSE_LEVEL==9) fprintf(stdout,"%2x%2x%2x%2x%2x%2x%2x%2x %i %f\n", buf[0],buf[1],buf[2],buf[3],buf[4],buf[5], buf[6],buf[7],(int)*(uint64_t*)buf,*(double*)buf ); return(buf); } /* -------------------------------- * float to ascii[8] conversion * -------------------------------- */ int ftoa8(char* buf, double num) { // used for converting scaling factors Dig/Phys/Min/Max into EDF header // Important note: buf may need more than len+1 bytes. make sure there is enough memory allocated. double f1,f2; if (num==ceil(num)) sprintf(buf,"%d",(int)num); else sprintf(buf,"%f",num); f1 = atof(buf); buf[8] = 0; // truncate f2 = atof(buf); return (fabs(f1-f2) > (fabs(f1)+fabs(f2)) * 1e-6); } int is_nihonkohden_signature(char *str) { return (!( strncmp(str, "EEG-1200A V01.00", 16) && strncmp(str, "EEG-1100A V01.00", 16) && strncmp(str, "EEG-1100B V01.00", 16) && strncmp(str, "EEG-1100C V01.00", 16) && strncmp(str, "QI-403A V01.00", 16) && strncmp(str, "QI-403A V02.00", 16) && strncmp(str, "EEG-2100 V01.00", 16) && strncmp(str, "EEG-2100 V02.00", 16) && strncmp(str, "DAE-2100D V01.30", 16) && strncmp(str, "DAE-2100D V02.00", 16) )); } #endif //ONLYGDF #if (BIOSIG_VERSION < 10700) int strncmpi(const char* str1, const char* str2, size_t n) { fprintf(stderr,"Warning from libbiosig: use of function strncmpi() is deprecated - use instead strncasecmp()\n"); return strncasecmp(str1,str2,n); } int strcmpi(const char* str1, const char* str2) { fprintf(stderr,"Warning from libbiosig: use of function strcmpi() is deprecated - use instead strcasecmp()\n"); return strcasecmp(str1,str2); } #endif /* Converts name of month int numeric value. */ int month_string2int(const char *s) { const char ListOfMonth[12][4] = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}; int k; for (k = 0; k < 12; k++) if (!strncasecmp(s, ListOfMonth[k], 3)) return k; return -1; } /* compare uint32_t */ int u32cmp(const void *a,const void *b) { return((int)(*(uint32_t*)a - *(uint32_t*)b)); } /* Interface for mixed use of ZLIB and STDIO If ZLIB is not available, STDIO is used. If ZLIB is availabe, HDR.FILE.COMPRESSION tells whether STDIO or ZLIB is used. */ HDRTYPE* ifopen(HDRTYPE* hdr, const char* mode) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) { hdr->FILE.gzFID = gzopen(hdr->FileName, mode); hdr->FILE.OPEN = (hdr->FILE.gzFID != NULL); } else #endif { hdr->FILE.FID = fopen(hdr->FileName, mode); hdr->FILE.OPEN = (hdr->FILE.FID != NULL); } return(hdr); } int ifclose(HDRTYPE* hdr) { hdr->FILE.OPEN = 0; #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzclose(hdr->FILE.gzFID)); else #endif return(fclose(hdr->FILE.FID)); } int ifflush(HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzflush(hdr->FILE.gzFID,Z_FINISH)); else #endif return(fflush(hdr->FILE.FID)); } size_t ifread(void* ptr, size_t size, size_t nmemb, HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION>0) return(gzread(hdr->FILE.gzFID, ptr, size * nmemb)/size); else #endif return(fread(ptr, size, nmemb, hdr->FILE.FID)); } size_t ifwrite(void* ptr, size_t size, size_t nmemb, HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzwrite(hdr->FILE.gzFID, ptr, size*nmemb)/size); else #endif return(fwrite(ptr, size, nmemb, hdr->FILE.FID)); } int ifprintf(HDRTYPE* hdr, const char *format, va_list arg) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzprintf(hdr->FILE.gzFID, format, arg)); else #endif return(fprintf(hdr->FILE.FID, format, arg)); } int ifputc(int c, HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzputc(hdr->FILE.gzFID, c)); else #endif return(fputc(c,hdr->FILE.FID)); } int ifgetc(HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzgetc(hdr->FILE.gzFID)); else #endif return(fgetc(hdr->FILE.FID)); } char* ifgets(char *str, int n, HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzgets(hdr->FILE.gzFID, str, n)); else #endif return(fgets(str,n,hdr->FILE.FID)); } int ifseek(HDRTYPE* hdr, ssize_t offset, int whence) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) { if (whence==SEEK_END) fprintf(stdout,"Warning SEEK_END is not supported but used in gzseek/ifseek.\nThis can cause undefined behaviour.\n"); return(gzseek(hdr->FILE.gzFID,offset,whence)); } else #endif #if defined(__MINGW64__) return(_fseeki64(hdr->FILE.FID,offset,whence)); #else return(fseek(hdr->FILE.FID,offset,whence)); #endif } ssize_t iftell(HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gztell(hdr->FILE.gzFID)); else #endif return(ftell(hdr->FILE.FID)); } int ifsetpos(HDRTYPE* hdr, size_t *pos) { #if __gnu_linux__ // gnu linux on sparc needs this fpos_t p; p.__pos = *pos; #elif __sparc__ || __APPLE__ || __MINGW32__ || ANDROID || __NetBSD__ || __CYGWIN__ fpos_t p = *pos; #else fpos_t p; p.__pos = *pos; #endif #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) { gzseek(hdr->FILE.gzFID,*pos,SEEK_SET); size_t pos1 = *pos; *pos = gztell(hdr->FILE.gzFID); return(*pos - pos1); } else #endif { int c= fsetpos(hdr->FILE.FID,&p); #if __gnu_linux__ // gnu linux on sparc needs this *pos = p.__pos; #elif __sparc__ || __APPLE__ || __MINGW32__ || ANDROID || __NetBSD__ || __CYGWIN__ *pos = p; #else *pos = p.__pos; #endif return(c); } } int ifgetpos(HDRTYPE* hdr, size_t *pos) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) { z_off_t p = gztell(hdr->FILE.gzFID); if (p<0) return(-1); else { *pos = p; return(0); } } else #endif { fpos_t p; int c = fgetpos(hdr->FILE.FID, &p); #if __gnu_linux__ // gnu linux on sparc needs this *pos = p.__pos; // ugly hack but working #elif __sparc__ || __APPLE__ || __MINGW32__ || ANDROID || __NetBSD__ || __CYGWIN__ *pos = p; #else *pos = p.__pos; // ugly hack but working #endif return(c); } } int ifeof(HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) return(gzeof(hdr->FILE.gzFID)); else #endif return(feof(hdr->FILE.FID)); } int iferror(HDRTYPE* hdr) { #ifdef ZLIB_H if (hdr->FILE.COMPRESSION) { int errnum; const char *tmp = gzerror(hdr->FILE.gzFID,&errnum); fprintf(stderr,"GZERROR: %i %s \n",errnum, tmp); return(errnum); } else #endif return(ferror(hdr->FILE.FID)); } /*------------------------------------------------------------------------ sort event table according to EVENT.POS ------------------------------------------------------------------------*/ struct event { uint32_t POS; uint32_t DUR; uint16_t TYP; uint16_t CHN; #if (BIOSIG_VERSION >= 10500) gdf_time TimeStamp; #endif }; int compare_eventpos(const void *e1, const void *e2) { return(((struct event*)(e1))->POS - ((struct event*)(e2))->POS); } void sort_eventtable(HDRTYPE *hdr) { size_t k; struct event *entry = (struct event*) calloc(hdr->EVENT.N, sizeof(struct event)); if ((hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL)) for (k=0; k < hdr->EVENT.N; k++) { entry[k].TYP = hdr->EVENT.TYP[k]; entry[k].POS = hdr->EVENT.POS[k]; entry[k].CHN = hdr->EVENT.CHN[k]; entry[k].DUR = hdr->EVENT.DUR[k]; } else for (k=0; k < hdr->EVENT.N; k++) { entry[k].TYP = hdr->EVENT.TYP[k]; entry[k].POS = hdr->EVENT.POS[k]; } #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp != NULL) for (k=0; k < hdr->EVENT.N; k++) { entry[k].TimeStamp = hdr->EVENT.TimeStamp[k]; } #endif qsort(entry, hdr->EVENT.N, sizeof(struct event), &compare_eventpos); if ((hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL)) for (k=0; k < hdr->EVENT.N; k++) { hdr->EVENT.TYP[k] = entry[k].TYP; hdr->EVENT.POS[k] = entry[k].POS; hdr->EVENT.CHN[k] = entry[k].CHN; hdr->EVENT.DUR[k] = entry[k].DUR; } else for (k=0; k < hdr->EVENT.N; k++) { hdr->EVENT.TYP[k] = entry[k].TYP; hdr->EVENT.POS[k] = entry[k].POS; } #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp != NULL) for (k=0; k < hdr->EVENT.N; k++) { hdr->EVENT.TimeStamp[k] = entry[k].TimeStamp; } #endif free(entry); } /*------------------------------------------------------------------------ re-allocates memory for Eventtable. hdr->EVENT.N contains actual number of events EventN determines the size of the allocated memory return value: in case of success, EVENT_N is returned in case of failure SIZE_MAX is returned; ------------------------------------------------------------------------*/ size_t reallocEventTable(HDRTYPE *hdr, size_t EventN) { size_t n; hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, EventN * sizeof(*hdr->EVENT.POS)); hdr->EVENT.DUR = (uint32_t*)realloc(hdr->EVENT.DUR, EventN * sizeof(*hdr->EVENT.DUR)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, EventN * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.CHN = (uint16_t*)realloc(hdr->EVENT.CHN, EventN * sizeof(*hdr->EVENT.CHN)); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*)realloc(hdr->EVENT.TimeStamp, EventN * sizeof(gdf_time)); #endif if (hdr->EVENT.POS==NULL) return SIZE_MAX; if (hdr->EVENT.TYP==NULL) return SIZE_MAX; if (hdr->EVENT.CHN==NULL) return SIZE_MAX; if (hdr->EVENT.DUR==NULL) return SIZE_MAX; if (hdr->EVENT.TimeStamp==NULL) return SIZE_MAX; for (n = hdr->EVENT.N; n< EventN; n++) { hdr->EVENT.TYP[n] = 0; hdr->EVENT.CHN[n] = 0; hdr->EVENT.DUR[n] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[n] = 0; #endif } return EventN; } /*------------------------------------------------------------------------ converts event table from {TYP,POS} to [TYP,POS,CHN,DUR} format ------------------------------------------------------------------------*/ void convert2to4_eventtable(HDRTYPE *hdr) { size_t k1,k2,N=hdr->EVENT.N; sort_eventtable(hdr); if (hdr->EVENT.DUR == NULL) hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) calloc(N,sizeof(*hdr->EVENT.DUR)); if (hdr->EVENT.CHN == NULL) hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) calloc(N,sizeof(*hdr->EVENT.CHN)); for (k1=0; k1EVENT.TYP) typ = hdr->EVENT.TYP[k1]; if ((typ < 0x8000) && (typ>0) && !hdr->EVENT.DUR[k1]) for (k2 = k1+1; k2EVENT.TYP[k2]) { hdr->EVENT.DUR[k1] = hdr->EVENT.POS[k2] - hdr->EVENT.POS[k1]; hdr->EVENT.TYP[k2] = 0; break; } } } for (k1=0,k2=0; k1EVENT.TYP[k2]=hdr->EVENT.TYP[k1]; hdr->EVENT.POS[k2]=hdr->EVENT.POS[k1]; hdr->EVENT.DUR[k2]=hdr->EVENT.DUR[k1]; hdr->EVENT.CHN[k2]=hdr->EVENT.CHN[k1]; #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp != NULL) hdr->EVENT.TimeStamp[k2] = hdr->EVENT.TimeStamp[k1]; #endif } if (hdr->EVENT.TYP[k1]) k2++; } hdr->EVENT.N = k2; } /*------------------------------------------------------------------------ converts event table from [TYP,POS,CHN,DUR} to {TYP,POS} format ------------------------------------------------------------------------*/ void convert4to2_eventtable(HDRTYPE *hdr) { size_t k1,k2,N = hdr->EVENT.N; if ((hdr->EVENT.DUR == NULL) || (hdr->EVENT.CHN == NULL)) return; for (k1=0; k1EVENT.CHN[k1]) return; hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,2*N*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,2*N*sizeof(*hdr->EVENT.POS)); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*) realloc(hdr->EVENT.TimeStamp,2*N*sizeof(gdf_time)); #endif for (k1=0,k2=N; k1EVENT.DUR[k1]) { hdr->EVENT.TYP[k2] = hdr->EVENT.TYP[k1] | 0x8000; hdr->EVENT.POS[k2] = hdr->EVENT.POS[k1] + hdr->EVENT.DUR[k1]; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[k2] = hdr->EVENT.TimeStamp[k1] + lround(ldexp(hdr->EVENT.DUR[k1]/(hdr->EVENT.SampleRate*24*3600),32)); #endif k2++; } hdr->EVENT.N = k2; free(hdr->EVENT.CHN); hdr->EVENT.CHN=NULL; free(hdr->EVENT.DUR); hdr->EVENT.DUR=NULL; sort_eventtable(hdr); } /*------------------------------------------------------------------------ write GDF event table utility function for SCLOSE and SFLUSH_GDF_EVENT_TABLE TODO: writing of TimeStamps ------------------------------------------------------------------------*/ void write_gdf_eventtable(HDRTYPE *hdr) { uint32_t k32u; uint8_t buf[88]; char flag; fprintf(stdout,"write_gdf_eventtable is obsolete - use hdrEVT2rawEVT instead;\n"); ifseek(hdr, hdr->HeadLen + hdr->AS.bpb*hdr->NRec, SEEK_SET); if (VERBOSE_LEVEL>7) fprintf(stdout,"WriteEventTable: %p %p %p %p\t",hdr->EVENT.TYP,hdr->EVENT.POS,hdr->EVENT.DUR,hdr->EVENT.CHN); flag = (hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL); if (flag) // any DUR or CHN is larger than 0 for (k32u=0, flag=0; (k32uEVENT.N) && !flag; k32u++) flag |= hdr->EVENT.CHN[k32u] || hdr->EVENT.DUR[k32u]; if (VERBOSE_LEVEL>7) fprintf(stdout,"flag=%d.\n",flag); buf[0] = (flag ? 3 : 1); if (hdr->VERSION < 1.94) { k32u = lround(hdr->EVENT.SampleRate); buf[1] = k32u & 0x000000FF; buf[2] = (k32u>>8 ) & 0x000000FF; buf[3] = (k32u>>16) & 0x000000FF; leu32a(hdr->EVENT.N, buf+4); } else { k32u = hdr->EVENT.N; buf[1] = k32u & 0x000000FF; buf[2] = (k32u>>8 ) & 0x000000FF; buf[3] = (k32u>>16) & 0x000000FF; lef32a(hdr->EVENT.SampleRate, buf+4); }; for (k32u=0; k32uEVENT.N; k32u++) { hdr->EVENT.POS[k32u] = htole32(hdr->EVENT.POS[k32u]); hdr->EVENT.TYP[k32u] = htole16(hdr->EVENT.TYP[k32u]); } ifwrite(buf, 8, 1, hdr); ifwrite(hdr->EVENT.POS, sizeof(*hdr->EVENT.POS), hdr->EVENT.N, hdr); ifwrite(hdr->EVENT.TYP, sizeof(*hdr->EVENT.TYP), hdr->EVENT.N, hdr); if (flag) { for (k32u=0; k32uEVENT.N; k32u++) { hdr->EVENT.DUR[k32u] = le32toh(hdr->EVENT.DUR[k32u]); hdr->EVENT.CHN[k32u] = le16toh(hdr->EVENT.CHN[k32u]); } ifwrite(hdr->EVENT.CHN, sizeof(*hdr->EVENT.CHN), hdr->EVENT.N,hdr); ifwrite(hdr->EVENT.DUR, sizeof(*hdr->EVENT.DUR), hdr->EVENT.N,hdr); } } #if (BIOSIG_VERSION < 10500) /* Stubs for deprecated functions */ ATT_DEPREC void FreeGlobalEventCodeTable() {} // deprecated since Oct 2012, v1.4.0 ATT_DEPREC void LoadGlobalEventCodeTable() {} // deprecated since Oct 2012, v1.4.0 #endif /*------------------------------------------------------------------------ adds free text annotation to event table the EVENT.TYP is identified from the table EVENT.CodeDesc if annotations is not listed in CodeDesc, it is added to CodeDesc The table is limited to 256 entries, because the table EventCodes allows only codes 0-255 as user specific entry. ------------------------------------------------------------------------*/ void FreeTextEvent(HDRTYPE* hdr,size_t N_EVENT, const char* annotation) { /* free text annotations encoded as user specific events (codes 1-255) */ /* !!! annotation is not copied, but it is assumed that annotation string is also available after return usually, the string is available in hdr->AS.Header; still this can disappear (free, or rellocated) before the Event table is destroyed. !!! */ size_t k; int flag; // static int LengthCodeDesc = 0; if (hdr->EVENT.CodeDesc == NULL) { hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,257*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0] = ""; // typ==0, is always empty hdr->EVENT.LenCodeDesc = 1; } if (annotation == NULL) { hdr->EVENT.TYP[N_EVENT] = 0; return; } // First, compare text with any predefined event description for (k=0; ETD[k].typ != 0; k++) { if (!strcmp(ETD[k].desc, annotation)) { // annotation is already a predefined event hdr->EVENT.TYP[N_EVENT] = ETD[k].typ; return; } } // Second, compare text with user-defined event description flag=1; for (k=0; (k < hdr->EVENT.LenCodeDesc) && flag; k++) { if (!strncmp(hdr->EVENT.CodeDesc[k], annotation, strlen(annotation))) { hdr->EVENT.TYP[N_EVENT] = k; flag = 0; } } // Third, add event description if needed if (flag && (hdr->EVENT.LenCodeDesc < 256)) { hdr->EVENT.TYP[N_EVENT] = hdr->EVENT.LenCodeDesc; hdr->EVENT.CodeDesc[hdr->EVENT.LenCodeDesc] = annotation; hdr->EVENT.LenCodeDesc++; } if (hdr->EVENT.LenCodeDesc > 255) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Maximum number of user-defined events (256) exceeded"); } } /*------------------------------------------------------------------------ returns clear text description of n-th event -------------------------------------------------------------- */ const char* GetEventDescription(HDRTYPE *hdr, size_t N) { if (hdr==NULL || N >= hdr->EVENT.N) return NULL; uint16_t TYP = hdr->EVENT.TYP[N]; if (TYP < hdr->EVENT.LenCodeDesc) // user-specified events, TYP < 256 return hdr->EVENT.CodeDesc[TYP]; if (TYP < 256) // not defined by user return NULL; // end of event: encoded by 0x8000+TYP if ((hdr->EVENT.TYP[N] & 0x8000) && (hdr->TYPE==GDF)) return (NULL); if ((hdr->EVENT.TYP[N] == 0x7fff) && (hdr->TYPE==GDF)) return "[neds]"; // event definition according to GDF's eventcodes.txt table uint16_t k; for (k=0; ETD[k].typ != 0; k++) if (ETD[k].typ==TYP) return ETD[k].desc; fprintf(stderr,"Warning: invalid event type 0x%04x\n",TYP); return (NULL); } /*------------------------------------------------------------------------ DUR2VAL converts sparse sample values in the event table from the DUR format (uint32, machine endian) to the sample value. Endianity of the platform is considered. ------------------------------------------------------------------------*/ double dur2val(uint32_t DUR, uint16_t gdftyp) { if (gdftyp==5) return (double)(int32_t)DUR; if (gdftyp==6) return (double)(uint32_t)DUR; if (gdftyp==16) { float fDur; memcpy(&fDur,&DUR,4); return (double)fDur; } union { uint32_t t32; uint16_t t16[2]; uint8_t t8[4]; } u; /* make sure u32 is always little endian like in the GDF file and only then extract the sample value */ u.t32 = htole32(DUR); if (gdftyp==1) return (double)(int8_t)(u.t8[0]); if (gdftyp==2) return (double)(uint8_t)(u.t8[0]); if (gdftyp==3) return (double)(int16_t)le16toh(u.t16[0]); if (gdftyp==4) return (double)(uint16_t)le16toh(u.t16[0]); return NAN; } /*------------------------------------------------------------------------ getTimeChannelNumber searches all channels, whether one channel contains the time axis Return value: the number of the first channel containing the time axis is returned. if no time channel is found, 0 is returned; Note: a 1-based indexing is used, the corresponding time channel is used the header of the time channel is in hdr->CHANNEL[getTimeChannelNumber(hdr)-1] ------------------------------------------------------------------------*/ int getTimeChannelNumber(HDRTYPE* hdr) { typeof(hdr->NS) k; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff==2) return (k+1); return 0; } /*------------------------------------------------------------------------ biosig_set_hdr_ipaddr set the field HDR.IPaddr based on the IP address of hostname Return value: 0: hdr->IPaddr is set otherwise hdr->IPaddr is not set ------------------------------------------------------------------------*/ int biosig_set_hdr_ipaddr(HDRTYPE *hdr, const char *hostname) { struct addrinfo hints; struct addrinfo *result, *rp; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = 0; hints.ai_flags = 0; hints.ai_protocol = 0; /* Any protocol */ int s = getaddrinfo(hostname, NULL, &hints, &result); if (s != 0) return -1; // IPaddr can not be set for (rp = result; rp != NULL; rp = rp->ai_next) { if ( rp->ai_family == AF_INET6) memcpy(hdr->IPaddr, &(((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr), 16); else if ( rp->ai_family == AF_INET) { memcpy(hdr->IPaddr, &(((struct sockaddr_in *)rp->ai_addr)->sin_addr.s_addr), 4); memset(hdr->IPaddr+4, 0, 12); } break; // set first found address } freeaddrinfo(result); return 0; } /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ uint32_t get_biosig_version () { return ((BIOSIG_VERSION_MAJOR<<16) + (BIOSIG_VERSION_MINOR<<8) + BIOSIG_PATCHLEVEL); } /****************************************************************************/ /** INIT HDR **/ /****************************************************************************/ #define Header1 ((char*)hdr->AS.Header) HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT) { /* HDR is initialized, memory is allocated for NS channels and N_EVENT number of events. The purpose is to define all parameters at an initial step. No parameters must remain undefined. */ HDRTYPE* hdr = (HDRTYPE*)malloc(sizeof(HDRTYPE)); union { uint32_t testword; uint8_t testbyte[sizeof(uint32_t)]; } EndianTest; int k,k1; uint8_t LittleEndian; size_t BitsPerBlock; EndianTest.testword = 0x4a3b2c1d; LittleEndian = (EndianTest.testbyte[0]==0x1d && EndianTest.testbyte[1]==0x2c && EndianTest.testbyte[2]==0x3b && EndianTest.testbyte[3]==0x4a ); assert ( ( LittleEndian && __BYTE_ORDER == __LITTLE_ENDIAN) || (!LittleEndian && __BYTE_ORDER == __BIG_ENDIAN ) ); hdr->FileName = NULL; hdr->FILE.OPEN = 0; hdr->FILE.FID = 0; hdr->FILE.POS = 0; hdr->FILE.Des = 0; hdr->FILE.COMPRESSION = 0; hdr->FILE.size = 0; #ifdef ZLIB_H hdr->FILE.gzFID = 0; #endif hdr->AS.B4C_ERRNUM = B4C_NO_ERROR; hdr->AS.B4C_ERRMSG = NULL; hdr->AS.Header = NULL; hdr->AS.rawEventData = NULL; hdr->AS.auxBUF = NULL; hdr->AS.bpb = 0; hdr->TYPE = noFile; hdr->VERSION = 2.0; hdr->AS.rawdata = NULL; //(uint8_t*) malloc(0); hdr->AS.flag_collapsed_rawdata = 0; // is rawdata not collapsed hdr->AS.first = 0; hdr->AS.length = 0; // no data loaded memset(hdr->AS.SegSel,0,sizeof(hdr->AS.SegSel)); hdr->Calib = NULL; hdr->rerefCHANNEL = NULL; hdr->NRec = 0; hdr->SPR = 0; hdr->NS = NS; hdr->SampleRate = 4321.5; hdr->Patient.Id[0]=0; strcpy(hdr->ID.Recording,"00000000"); hdr->data.size[0] = 0; // rows hdr->data.size[1] = 0; // columns hdr->data.block = NULL; hdr->T0 = t_time2gdf_time(time(NULL)-timezone); // localtime hdr->tzmin = -timezone/60; // convert from seconds west of UTC to minutes east; { uint8_t Equipment[8] = "b4c_1.5 "; Equipment[4] = BIOSIG_VERSION_MAJOR+'0'; Equipment[6] = BIOSIG_VERSION_MINOR+'0'; memcpy(&(hdr->ID.Equipment), &Equipment, 8); } hdr->ID.Manufacturer._field[0] = 0; hdr->ID.Manufacturer.Name = NULL; hdr->ID.Manufacturer.Model = NULL; hdr->ID.Manufacturer.Version = NULL; hdr->ID.Manufacturer.SerialNumber = NULL; hdr->ID.Technician = NULL; hdr->ID.Hospital = NULL; memset(hdr->IPaddr, 0, 16); { // some local variables are used only in this block #ifdef _WIN32 #if 1 // getlogin() a flawfinder level [4] issue, recommended to use getpwuid(geteuid()) but not available on Windows hdr->ID.Technician = strdup(getlogin()); #else // this compiles but stops with "Program error" on wine char str[1001]; GetUserName(str,1000); if (VERBOSE_LEVEL>7) fprintf(stdout,"Name:%s\n",str); hdr->ID.Technician = strdup(str); #endif #else char *username = NULL; struct passwd *p = getpwuid(geteuid()); if (p != NULL) username = p->pw_name; if (username) hdr->ID.Technician = strdup(username); #endif } #ifndef WITHOUT_NETWORK #ifdef _WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(1,1), &wsadata); #endif { // set default IP address to local IP address char *localhostname; localhostname = xgethostname(); if (localhostname) { biosig_set_hdr_ipaddr(hdr, localhostname); free (localhostname); } } #ifdef _WIN32 WSACleanup(); #endif #endif // not WITHOUT_NETWORK hdr->Patient.Name[0] = 0; //hdr->Patient.Id[0] = 0; hdr->Patient.Birthday = (gdf_time)0; // Unknown; hdr->Patient.Medication = 0; // 0:Unknown, 1: NO, 2: YES hdr->Patient.DrugAbuse = 0; // 0:Unknown, 1: NO, 2: YES hdr->Patient.AlcoholAbuse=0; // 0:Unknown, 1: NO, 2: YES hdr->Patient.Smoking = 0; // 0:Unknown, 1: NO, 2: YES hdr->Patient.Sex = 0; // 0:Unknown, 1: Male, 2: Female hdr->Patient.Handedness = 0; // 0:Unknown, 1: Right, 2: Left, 3: Equal hdr->Patient.Impairment.Visual = 0; // 0:Unknown, 1: NO, 2: YES, 3: Corrected hdr->Patient.Impairment.Heart = 0; // 0:Unknown, 1: NO, 2: YES, 3: Pacemaker hdr->Patient.Weight = 0; // 0:Unknown hdr->Patient.Height = 0; // 0:Unknown for (k1=0; k1<3; k1++) { hdr->Patient.Headsize[k1] = 0; // Unknown; hdr->ELEC.REF[k1] = 0.0; hdr->ELEC.GND[k1] = 0.0; } hdr->LOC[0] = 0x00292929; hdr->LOC[1] = 48*3600000+(1<<31); // latitude hdr->LOC[2] = 15*3600000+(1<<31); // longitude hdr->LOC[3] = 35000; //altitude in centimeter above sea level hdr->FLAG.UCAL = 0; // un-calibration OFF (auto-scaling ON) hdr->FLAG.OVERFLOWDETECTION = 1; // overflow detection ON hdr->FLAG.ANONYMOUS = 1; // <>0: no personal names are processed hdr->FLAG.TARGETSEGMENT = 1; // read 1st segment hdr->FLAG.ROW_BASED_CHANNELS=0; // define variable header hdr->CHANNEL = (CHANNEL_TYPE*)calloc(hdr->NS, sizeof(CHANNEL_TYPE)); BitsPerBlock = 0; for (k=0;kNS;k++) { size_t nbits; CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Label[0] = 0; hc->LeadIdCode= 0; strcpy(hc->Transducer, "EEG: Ag-AgCl electrodes"); hc->PhysDimCode = 19+4256; // uV hc->PhysMax = +100; hc->PhysMin = -100; hc->DigMax = +2047; hc->DigMin = -2048; hc->Cal = NAN; hc->Off = 0.0; hc->TOffset = 0.0; hc->GDFTYP = 3; // int16 hc->SPR = 1; // one sample per block hc->bi = 2*k; hc->bi8 = BitsPerBlock; nbits = GDFTYP_BITS[hc->GDFTYP]*hc->SPR; BitsPerBlock += nbits; hc->OnOff = 1; hc->HighPass = 0.16; hc->LowPass = 70.0; hc->Notch = 50; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; } // define EVENT structure hdr->EVENT.N = N_EVENT; hdr->EVENT.SampleRate = 0; hdr->EVENT.CodeDesc = NULL; hdr->EVENT.LenCodeDesc = 0; if (hdr->EVENT.N) { hdr->EVENT.POS = (uint32_t*) calloc(hdr->EVENT.N, sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*) calloc(hdr->EVENT.N, sizeof(*hdr->EVENT.TYP)); hdr->EVENT.DUR = (uint32_t*) calloc(hdr->EVENT.N, sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*) calloc(hdr->EVENT.N, sizeof(*hdr->EVENT.CHN)); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*) calloc(hdr->EVENT.N, sizeof(gdf_time)); #endif } else { hdr->EVENT.POS = NULL; hdr->EVENT.TYP = NULL; hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = NULL; #endif } // initialize specialized fields hdr->aECG = NULL; hdr->AS.bci2000 = NULL; #if (BIOSIG_VERSION >= 10500) hdr->SCP.Section7 = NULL; hdr->SCP.Section8 = NULL; hdr->SCP.Section9 = NULL; hdr->SCP.Section10 = NULL; hdr->SCP.Section11 = NULL; hdr->SCP.Section7Length = 0; hdr->SCP.Section8Length = 0; hdr->SCP.Section9Length = 0; hdr->SCP.Section10Length = 0; hdr->SCP.Section11Length = 0; #endif return(hdr); } /* just for debugging void debug_showptr(HDRTYPE* hdr) { fprintf(stdout,"=========================\n"); fprintf(stdout,"&AS.Header=%p\n",hdr->AS.Header); fprintf(stdout,"&AS.auxBUF=%p\n",hdr->AS.auxBUF); fprintf(stdout,"&aECG=%p\n",hdr->aECG); fprintf(stdout,"&AS.bci2000=%p\n",hdr->AS.bci2000); fprintf(stdout,"&AS.rawEventData=%p\n",hdr->AS.rawEventData); fprintf(stdout,"&AS.rawData=%p\n",hdr->AS.rawdata); fprintf(stdout,"&data.block=%p\n",hdr->data.block); fprintf(stdout,"&CHANNEL=%p\n",hdr->CHANNEL); fprintf(stdout,"&EVENT.POS=%p\n",hdr->EVENT.POS); fprintf(stdout,"&EVENT.TYP=%p\n",hdr->EVENT.TYP); fprintf(stdout,"&EVENT.DUR=%p\n",hdr->EVENT.DUR); fprintf(stdout,"&EVENT.CHN=%p\n",hdr->EVENT.CHN); fprintf(stdout,"&EVENT.CodeDesc=%p\n",hdr->EVENT.CodeDesc); fprintf(stdout,"&FileName=%p %s\n",&hdr->FileName,hdr->FileName); fprintf(stdout,"&Hospital=%p\n",hdr->ID.Hospital); } */ void destructHDR(HDRTYPE* hdr) { if (hdr==NULL) return; sclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR(%s): free HDR.aECG\n",hdr->FileName); #if (BIOSIG_VERSION < 10500) if (hdr->aECG != NULL) { if (((struct aecg*)hdr->aECG)->Section8.NumberOfStatements>0) free(((struct aecg*)hdr->aECG)->Section8.Statements); if (((struct aecg*)hdr->aECG)->Section11.NumberOfStatements>0) free(((struct aecg*)hdr->aECG)->Section11.Statements); free(hdr->aECG); } #endif if (hdr->ID.Technician != NULL) free(hdr->ID.Technician); if (hdr->ID.Hospital != NULL) free(hdr->ID.Hospital); if (hdr->AS.bci2000 != NULL) free(hdr->AS.bci2000); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.AS.rawdata @%p\n",hdr->AS.rawdata); // in case of SCPv3, rawdata can be loaded into Header if ( (hdr->AS.rawdata < hdr->AS.Header) || (hdr->AS.rawdata > (hdr->AS.Header+hdr->HeadLen)) ) if (hdr->AS.rawdata != NULL) free(hdr->AS.rawdata); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.data.block @%p\n",hdr->data.block); if (hdr->data.block != NULL) free(hdr->data.block); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.CHANNEL[] @%p %p\n",hdr->CHANNEL,hdr->rerefCHANNEL); if (hdr->CHANNEL != NULL) free(hdr->CHANNEL); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.AS.Header\n"); if (hdr->AS.rawEventData != NULL) free(hdr->AS.rawEventData); if (hdr->AS.Header != NULL) free(hdr->AS.Header); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free Event Table %p %p %p %p \n",hdr->EVENT.TYP,hdr->EVENT.POS,hdr->EVENT.DUR,hdr->EVENT.CHN); if (hdr->EVENT.POS != NULL) free(hdr->EVENT.POS); if (hdr->EVENT.TYP != NULL) free(hdr->EVENT.TYP); if (hdr->EVENT.DUR != NULL) free(hdr->EVENT.DUR); if (hdr->EVENT.CHN != NULL) free(hdr->EVENT.CHN); #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp) free(hdr->EVENT.TimeStamp); #endif if (hdr->EVENT.CodeDesc != NULL) free(hdr->EVENT.CodeDesc); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.AS.auxBUF\n"); if (hdr->AS.auxBUF != NULL) free(hdr->AS.auxBUF); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR.rerefCHANNEL\n"); #ifdef CHOLMOD_H //if (hdr->Calib) cholmod_print_sparse(hdr->Calib,"destructHDR hdr->Calib",&CHOLMOD_COMMON_VAR); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free hdr->Calib\n"); if (hdr->Calib) cholmod_free_sparse(&hdr->Calib, &CHOLMOD_COMMON_VAR); if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free hdr->rerefCHANNEL %p\n",hdr->rerefCHANNEL); if (hdr->rerefCHANNEL) free(hdr->rerefCHANNEL); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"destructHDR: free HDR\n"); if (hdr->FileName != NULL) free(hdr->FileName); if (hdr != NULL) free(hdr); return; } /****************************************************************************/ /** INITIALIZE FIELDS OF A SINGLE CHANNEL TO DEFAULT VALUES **/ /****************************************************************************/ void init_channel(struct CHANNEL_STRUCT *hc) { hc->PhysMin = -1e9; hc->PhysMax = +1e9; hc->DigMin = ldexp(-1,15); hc->DigMax = ldexp(1,15)-1; hc->Cal = 1.0; hc->Off = 0.0; hc->Label[0] = '\0'; hc->OnOff = 1; hc->LeadIdCode = 0; hc->Transducer[0] = '\0'; hc->PhysDimCode = 0; #ifdef MAX_LENGTH_PHYSDIM hc->PhysDim[0] = '?'; #endif hc->TOffset = 0.0; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; hc->Impedance = NAN; hc->bufptr = NULL; hc->SPR = 1; hc->bi = 0; hc->bi8 = 0; hc->GDFTYP = 3; // int16 } /* http://www.ietf.org/rfc/rfc1952.txt */ const char *MAGIC_NUMBER_GZIP = "\x1f\x8B\x08"; /****************************************************************************/ /** GETFILETYPE **/ /****************************************************************************/ HDRTYPE* getfiletype(HDRTYPE* hdr) /* input: hdr->AS.Header1 contains first block of hdr->HeadLen bytes hdr->TYPE must be unknown, otherwise no FileFormat evaluation is performed output: hdr->TYPE file format hdr->VERSION is defined for some selected formats e.g. ACQ, EDF, BDF, GDF */ { // ToDo: use LEN to detect buffer overflow hdr->TYPE = unknown; if (VERBOSE_LEVEL>7) fprintf(stdout,"[%s line %i]! %i\n", __func__,__LINE__, hdr->HeadLen); #ifndef ONLYGDF const uint8_t MAGIC_NUMBER_FEF1[] = {67,69,78,13,10,0x1a,4,0x84}; const uint8_t MAGIC_NUMBER_FEF2[] = {67,69,78,0x13,0x10,0x1a,4,0x84}; const uint8_t MAGIC_NUMBER_Z[] = {31,157,144}; // const uint8_t MAGIC_NUMBER_ZIP[] = {80,75,3,4}; const uint8_t MAGIC_NUMBER_TIFF_l32[] = {73,73,42,0}; const uint8_t MAGIC_NUMBER_TIFF_b32[] = {77,77,0,42}; const uint8_t MAGIC_NUMBER_TIFF_l64[] = {73,73,43,0,8,0,0,0}; const uint8_t MAGIC_NUMBER_TIFF_b64[] = {77,77,0,43,0,8,0,0}; const uint8_t MAGIC_NUMBER_DICOM[] = {8,0,5,0,10,0,0,0,73,83,79,95,73,82,32,49,48,48}; const uint8_t MAGIC_NUMBER_UNIPRO[] = {40,0,4,1,44,1,102,2,146,3,44,0,190,3}; const uint8_t MAGIC_NUMBER_SYNERGY[] = {83,121,110,101,114,103,121,0,48,49,50,46,48,48,51,46,48,48,48,46,48,48,48,0,28,0,0,0,2,0,0,0}; const char* MAGIC_NUMBER_BRAINVISION = "Brain Vision Data Exchange Header File"; const char* MAGIC_NUMBER_BRAINVISION1 = "Brain Vision V-Amp Data Header File Version"; const char* MAGIC_NUMBER_BRAINVISIONMARKER = "Brain Vision Data Exchange Marker File, Version"; /******** read 1st (fixed) header *******/ uint32_t U32 = leu32p(hdr->AS.Header+2); uint32_t MAGIC_EN1064_Section0Length = leu32p(hdr->AS.Header+10); if ((U32>=30) & (U32<=45)) { hdr->VERSION = (float)U32; U32 = leu32p(hdr->AS.Header+6); if ((hdr->VERSION <34.0) && (U32 == 150)) hdr->TYPE = ACQ; else if ((hdr->VERSION <35.0) && (U32 == 164)) hdr->TYPE = ACQ; else if ((hdr->VERSION <36.0) && (U32 == 326)) hdr->TYPE = ACQ; else if ((hdr->VERSION <37.0) && (U32 == 886)) hdr->TYPE = ACQ; else if ((hdr->VERSION <38.0) && (U32 ==1894)) hdr->TYPE = ACQ; else if ((hdr->VERSION <41.0) && (U32 ==1896)) hdr->TYPE = ACQ; else if ((hdr->VERSION <43.0) && (U32 ==1944)) hdr->TYPE = ACQ; //else if ((hdr->VERSION <45.0) && (U32 ==2976)) hdr->TYPE = ACQ; else if ((hdr->VERSION <45.0) && (U32 >=2220)) hdr->TYPE = ACQ; else if ((hdr->VERSION>=45.0) && (U32 ==(12944+160))) hdr->TYPE = ACQ; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s ACQ %f %i\n", __FILE__, __LINE__, __func__, hdr->VERSION, U32); if (hdr->TYPE == ACQ) { hdr->HeadLen = U32; // length of fixed header hdr->FILE.LittleEndian = 1; return(hdr); } } U32 = beu32p(hdr->AS.Header+2); if ((U32==83)) { hdr->VERSION = (float)U32; U32 = beu32p(hdr->AS.Header+6); if ((hdr->VERSION == 83) & (U32 == 1564)) hdr->TYPE = ACQ; if (hdr->TYPE == ACQ) { hdr->HeadLen = U32; // length of fixed header hdr->FILE.LittleEndian = 0; return(hdr); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s (..): %u %u %u\n", __FILE__,__LINE__,__func__,beu32p(hdr->AS.Header+2),beu32p(hdr->AS.Header+6),beu32p(hdr->AS.Header+10)); #endif //ONLYGDF if (VERBOSE_LEVEL>7) fprintf(stdout,"(%s line %i: %x %x! <%8s>\n",__func__,__LINE__, leu16p(hdr->AS.Header),leu16p(hdr->AS.Header+154),hdr->AS.Header); if (hdr->TYPE != unknown) return(hdr); #ifndef ONLYGDF else if (!memcmp(hdr->AS.Header, "ABF ", 4)) { // else if (!memcmp(Header1,"ABF \x66\x66\xE6\x3F",4)) { // ABF v1.8 hdr->TYPE = ABF; hdr->VERSION = lef32p(hdr->AS.Header+4); } else if (!memcmp(hdr->AS.Header, "ABF2\x00\x00", 6) && ( hdr->AS.Header[6] < 10 ) && ( hdr->AS.Header[7] < 10 ) ) { hdr->TYPE = ABF2; hdr->VERSION = hdr->AS.Header[7] + ( hdr->AS.Header[6] / 10.0 ); } else if (!memcmp(Header1+20,"ACR-NEMA",8)) hdr->TYPE = ACR_NEMA; else if (strstr(Header1,"ALPHA-TRACE-MEDICAL")) hdr->TYPE = alpha; else if (!memcmp(Header1,"ATES MEDICA SOFT. EEG for Windows",33)) hdr->TYPE = ATES; else if (!memcmp(Header1,"ATF\x09",4)) hdr->TYPE = ATF; else if (!memcmp(Header1,"AxGr",4)) { hdr->TYPE = AXG; hdr->VERSION = bei16p(hdr->AS.Header+4); } else if (!memcmp(Header1,"axgx",4)) { hdr->TYPE = AXG; hdr->VERSION = bei32p(hdr->AS.Header+4); } else if (!memcmp(Header1,"ADU1",4) || !memcmp(Header1,"ADU2",4) ) hdr->TYPE = Axona; else if (!memcmp(Header1,"HeaderLen=",10)) { hdr->TYPE = BCI2000; hdr->VERSION = 1.0; } else if (!memcmp(Header1,"BCI2000V",8)) { hdr->TYPE = BCI2000; hdr->VERSION = 1.1; } else if (!memcmp(Header1+1,"BIOSEMI",7) && (hdr->AS.Header[0]==0xff) && (hdr->HeadLen > 255)) { hdr->TYPE = BDF; hdr->VERSION = -1; } else if (!memcmp(Header1,"#BIOSIG ASCII",13)) hdr->TYPE = ASCII; else if (!memcmp(Header1,"#BIOSIG BINARY",14)) hdr->TYPE = BIN; else if ((leu16p(hdr->AS.Header)==207) && (leu16p(hdr->AS.Header+154)==0)) hdr->TYPE = BKR; else if (!memcmp(Header1+34,"BLSC",4)) hdr->TYPE = BLSC; else if (!memcmp(Header1,"bscs://",7)) hdr->TYPE = BSCS; else if (((beu16p(hdr->AS.Header)==0x0311) && (beu32p(hdr->AS.Header+4)==0x0809B002) && (leu16p(hdr->AS.Header+2) > 240) && (leu16p(hdr->AS.Header+2) < 250)) // v2.40 - v2.50 || !memcmp(hdr->AS.Header+307, "E\x00\x00\x00\x00\x00\x00\x00DAT", 11) ) hdr->TYPE = BLSC; else if (!memcmp(Header1,"FileFormat = BNI-1-BALTIMORE",28)) hdr->TYPE = BNI; else if (!memcmp(Header1,MAGIC_NUMBER_BRAINVISION,strlen(MAGIC_NUMBER_BRAINVISION)) || ((leu32p(hdr->AS.Header)==0x42bfbbef) && !memcmp(Header1+3, MAGIC_NUMBER_BRAINVISION,38))) hdr->TYPE = BrainVision; else if (!memcmp(Header1,MAGIC_NUMBER_BRAINVISION1,strlen(MAGIC_NUMBER_BRAINVISION1))) hdr->TYPE = BrainVisionVAmp; else if (!memcmp(Header1,MAGIC_NUMBER_BRAINVISIONMARKER,strlen(MAGIC_NUMBER_BRAINVISIONMARKER))) hdr->TYPE = BrainVisionMarker; else if (!memcmp(Header1,"BZh91",5)) hdr->TYPE = BZ2; else if (!memcmp(Header1,"CDF",3)) hdr->TYPE = CDF; else if (!memcmp(Header1,"CEDFILE",7)) hdr->TYPE = CFS; else if (!memcmp(Header1+2,"(C) CED 87",10)) hdr->TYPE = SMR; // CED's SMR/SON format else if (!memcmp(Header1,"CFWB\1\0\0\0",8)) hdr->TYPE = CFWB; else if (!memcmp(Header1,"Version 3.0",11)) hdr->TYPE = CNT; else if (!memcmp(Header1,"MEG4",4)) hdr->TYPE = CTF; else if (!memcmp(Header1,"CTF_MRI_FORMAT VER 2.2",22)) hdr->TYPE = CTF; else if (!memcmp(Header1,"PATH OF DATASET:",16)) hdr->TYPE = CTF; else if (!memcmp(Header1,"DEMG",4)) hdr->TYPE = DEMG; else if (!memcmp(Header1+128,"DICM\x02\x00\x00\x00",8)) hdr->TYPE = DICOM; else if (!memcmp(Header1, MAGIC_NUMBER_DICOM,sizeof(MAGIC_NUMBER_DICOM))) hdr->TYPE = DICOM; else if (!memcmp(Header1+12, MAGIC_NUMBER_DICOM,sizeof(MAGIC_NUMBER_DICOM))) hdr->TYPE = DICOM; else if (!memcmp(Header1+12, MAGIC_NUMBER_DICOM,8)) hdr->TYPE = DICOM; else if (!memcmp(Header1, "SctHdr\0\0Directory\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\xff\xff\xff\xff\xff\xff\xff\0\0\0\0\0\0\0\0", 48) && (leu32p((hdr->AS.Header+0x3C))==0x68) ) { hdr->TYPE = EAS; } else if (!memcmp(Header1,"Easy3File",10)) { hdr->TYPE = EZ3; } else if (!memcmp(Header1,"EBS\x94\x0a\x13\x1a\x0d",8)) hdr->TYPE = EBS; else if (!memcmp(Header1,"0 ",8) && (hdr->HeadLen > 255)) { hdr->TYPE = EDF; hdr->VERSION = 0; } /* Nihon Kohden */ else if (is_nihonkohden_signature((char*)Header1) && is_nihonkohden_signature((char*)(Header1+0x81))) { hdr->TYPE = EEG1100; hdr->VERSION = strtod((char*)Header1+11,NULL); } else if (!memcmp(Header1, "RIFF",4) && !memcmp(Header1+8, "CNT ",4)) hdr->TYPE = EEProbe; else if (!memcmp(Header1, "EEP V2.0",8)) hdr->TYPE = EEProbe; else if (!memcmp(Header1, "\x26\x00\x10\x00",4)) // AVR hdr->TYPE = EEProbe; else if (( bei32p(hdr->AS.Header) == 0x01020304) && ((beu16p(hdr->AS.Header+4) == 0xffff) || (beu16p(hdr->AS.Header+4) == 3)) ) { hdr->TYPE = EGIS; hdr->FILE.LittleEndian = 0; } else if (( lei32p(hdr->AS.Header) == 0x01020304) && ((leu16p(hdr->AS.Header+4) == 0xffff) || (leu16p(hdr->AS.Header+4) == 3)) ) { hdr->TYPE = EGIS; hdr->FILE.LittleEndian = 1; } else if ((beu32p(hdr->AS.Header) > 1) && (beu32p(hdr->AS.Header) < 8) && !hdr->AS.Header[6] && !hdr->AS.Header[8] && !hdr->AS.Header[10] && !hdr->AS.Header[12] && !hdr->AS.Header[14] && !hdr->AS.Header[26] ) { /* sanity check: the high byte of month, day, hour, min, sec and bits must be zero */ hdr->TYPE = EGI; hdr->VERSION = hdr->AS.Header[3]; } else if (*(uint32_t*)(Header1) == htobe32(0x7f454c46)) hdr->TYPE = ELF; else if ( (hdr->HeadLen > 64) && !memcmp(Header1+0x30,"GALNT EEG DATA",14)) hdr->TYPE = EBNEURO; else if ( (hdr->HeadLen > 14) && !memcmp(Header1,"Embla data file",15)) hdr->TYPE = EMBLA; else if ( (hdr->HeadLen > 4) && ( !memcmp(Header1,"PBJ",3) || !memcmp(Header1,"BPC",3) ) ) hdr->TYPE = EMSA; else if (strstr(Header1,"Subject") && strstr(Header1,"Target.OnsetTime") && strstr(Header1,"Target.RTTime") && strstr(Header1,"Target.RESP")) hdr->TYPE = ePrime; else if (!memcmp(Header1,"[Header]",8)) hdr->TYPE = ET_MEG; else if ( (hdr->HeadLen > 19) && !memcmp(Header1,"Header\r\nFile Version'",20)) hdr->TYPE = ETG4000; else if (!memcmp(Header1,"|CF,",4)) hdr->TYPE = FAMOS; else if (!memcmp(Header1,MAGIC_NUMBER_FEF1,sizeof(MAGIC_NUMBER_FEF1)) || !memcmp(Header1,MAGIC_NUMBER_FEF2,sizeof(MAGIC_NUMBER_FEF1))) { hdr->TYPE = FEF; char tmp[9];tmp[8] = 0; memcpy(tmp,hdr->AS.Header+8,8); hdr->VERSION = (float)atol(tmp); } else if (!memcmp(hdr->AS.Header, "\0\0\0\x64\0\0\0\x1f\0\0\0\x14\0\0\0\0\0\1",4) && !memcmp(hdr->AS.Header+36,"\0\0\0\x65\0\0\0\3\0\0\0\4\0\0",14) && !memcmp(hdr->AS.Header+56,"\0\0\0\x6a\0\0\0\3\0\0\0\4\0\0\0\0\xff\xff\xff\xff\0\0",22) ) hdr->TYPE = FIFF; else if (!memcmp(Header1,"fLaC",4)) hdr->TYPE = FLAC; #endif //ONLYGDF else if (!memcmp(Header1,"GDF",3) && (hdr->HeadLen > 255)) { hdr->TYPE = GDF; char tmp[6]; tmp[5] = 0; memcpy(tmp,hdr->AS.Header+3, 5); hdr->VERSION = strtod(tmp,NULL); } #ifndef ONLYGDF else if (!memcmp(Header1,"GIF87a",6)) hdr->TYPE = GIF; else if (!memcmp(Header1,"GIF89a",6)) hdr->TYPE = GIF; else if ( (hdr->HeadLen > 21) && !memcmp(Header1,"GALILEO EEG TRACE FILE",22)) hdr->TYPE = GTF; else if (!memcmp(Header1,MAGIC_NUMBER_GZIP,strlen(MAGIC_NUMBER_GZIP))) { hdr->TYPE = GZIP; // hdr->FILE.COMPRESSION = 1; } else if (!memcmp(Header1,"\x89HDF\x0d\x0a\x1a\x0a",8)) hdr->TYPE = HDF; else if (!memcmp(Header1,"DATA\0\0\0\0",8)) { hdr->TYPE = HEKA; hdr->VERSION = 0; } else if (!memcmp(Header1,"DAT1\0\0\0\0",8)) { hdr->TYPE = HEKA; hdr->VERSION = 1; } else if (!memcmp(Header1,"DAT2\0\0\0\0",8)) { hdr->TYPE = HEKA; hdr->VERSION = 2; } else if (!memcmp(Header1,"IGOR",4)) hdr->TYPE = ITX; else if (*(int16_t*)Header1==0x0001 || *(int16_t*)Header1==0x0002 || *(int16_t*)Header1==0x0003 || *(int16_t*)Header1==0x0005 ) { /* no swapping */ hdr->TYPE = IBW; hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->VERSION = *(int16_t*)Header1; } else if (*(int16_t*)Header1==0x0100 || *(int16_t*)Header1==0x0200 || *(int16_t*)Header1==0x0300 || *(int16_t*)Header1==0x0500 ) { /* data need to be swapped */ hdr->TYPE = IBW; hdr->FILE.LittleEndian = (__BYTE_ORDER == __BIG_ENDIAN); hdr->VERSION = bswap_16(*(int16_t*)Header1); } else if (!memcmp(Header1,"ANN 1.0",8)) hdr->TYPE = ISHNE; else if (!memcmp(Header1,"ISHNE1.0",8)) hdr->TYPE = ISHNE; else if (!memcmp(Header1,"@ MFER ",8)) hdr->TYPE = MFER; else if (!memcmp(Header1,"@ MFR ",6)) hdr->TYPE = MFER; else if (!memcmp(Header1,"MATLAB 5.0 MAT-file, ",7) && !memcmp(Header1+10," MAT-file, ",11) ) { hdr->TYPE = Matlab; hdr->VERSION = (Header1[7]-'0') + (Header1[9]-'0')/10.0; } else if (!memcmp(Header1,"%%MatrixMarket",14)) hdr->TYPE = MM; /* else if (!memcmp(Header1,"MThd\000\000\000\001\000",9)) hdr->TYPE = MIDI; */ else if (!memcmp(Header1,"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF\x09\x00\x06",0x21)) hdr->TYPE = MSI; else if (!strcmp(Header1,"(*This is a Mathematica binary dump file. It can be loaded with Get.*)")) hdr->TYPE = MX; else if ( (hdr->HeadLen>346) && (Header1[344]=='n') && (Header1[347]=='\0') && \ ((Header1[345]=='i') || (Header1[345]=='+') ) && \ (Header1[346]>'0') && (Header1[346]<='9') ) { hdr->TYPE = NIFTI; hdr->VERSION = Header1[346]-'0'; } else if ( (hdr->HeadLen > 344) && (!memcmp(Header1+344,"ni1",4) || !memcmp(Header1+344,"n+1",4) ) ) hdr->TYPE = NIFTI; else if (!memcmp(Header1,"NEURALEV",8) || !memcmp(Header1,"N.EV.",6) ) hdr->TYPE = NEV; else if (!memcmp(Header1,"NEX1",3)) hdr->TYPE = NEX1; else if ( (hdr->HeadLen > 31) && !memcmp(Header1,"Logging Start\x0aLogger SW Version: ",31)) hdr->TYPE = NeuroLoggerHEX; else if (!memcmp(Header1,"Neuron",6)) hdr->TYPE = NEURON; else if (!memcmp(Header1,"\x93NUMPY",6)) { hdr->TYPE = NUMPY; } else if (!memcmp(Header1,"[FileInfo]",10)) hdr->TYPE = Persyst; else if (!memcmp(Header1,"SXDF",4)) hdr->TYPE = OpenXDF; else if (!memcmp(Header1,"PLEX",4)) { hdr->TYPE = PLEXON; hdr->VERSION=1.0; } else if (!memcmp(Header1+10,"PLEXON",6)) { hdr->TYPE = PLEXON; hdr->VERSION=2.0; } else if (!memcmp(Header1,"\x02\x27\x91\xC6",4)) { hdr->TYPE = RHD2000; // Intan RHD2000 format hdr->FILE.LittleEndian = 1; } else if (!memcmp(Header1,"\xAC\x27\x91\xD6",4)) { hdr->TYPE = RHS2000; // Intan RHS2000 format hdr->FILE.LittleEndian = 1; } else if (!memcmp(Header1,"\x81\xa4\xb1\xf3",4) & (leu16p(Header1+8) < 2)) { hdr->TYPE = IntanCLP; // Intan CLP format, we'll use same read for now hdr->FILE.LittleEndian = 1; } else if (!memcmp(Header1,"\x55\xAA\x00\xb0",2)) { hdr->TYPE = RDF; // UCSD ERPSS aquisition system hdr->FILE.LittleEndian = 1; } else if (!memcmp(Header1,"\xAA\x55\xb0\x00",2)) { hdr->TYPE = RDF; // UCSD ERPSS aquisition system hdr->FILE.LittleEndian = 0; } else if (!memcmp(Header1,"RIFF",4)) { hdr->TYPE = RIFF; if (!memcmp(Header1+8,"WAVE",4)) hdr->TYPE = WAV; if (!memcmp(Header1+8,"AIF",3)) hdr->TYPE = AIFF; if (!memcmp(Header1+8,"AVI ",4)) hdr->TYPE = AVI; } // general SCP else if ( (hdr->HeadLen>32) && ( MAGIC_EN1064_Section0Length > 120) && ( MAGIC_EN1064_Section0Length < 16+10*1024) && ((MAGIC_EN1064_Section0Length%10)== 6) && (*(uint16_t*)(hdr->AS.Header+ 8) == 0x0000) && (leu32p(hdr->AS.Header+10) == leu32p(hdr->AS.Header+24)) && ( (!memcmp(hdr->AS.Header+16,"SCPECG\0\0",8)) || (*(uint64_t*)(hdr->AS.Header+16) == 0) ) && (leu32p(hdr->AS.Header+28) == (uint32_t)0x00000007) && (leu16p(hdr->AS.Header+32) == (uint16_t)0x0001) ) { hdr->TYPE = SCP_ECG; } /* // special SCP files - header is strange, files can be decoded else if ( (leu32p(hdr->AS.Header+10) == 136) && (*(uint16_t*)(hdr->AS.Header+ 8) == 0x0000) && ( (!memcmp(hdr->AS.Header+14,"\x0A\x01\x25\x01\x99\x01\xE7\x49\0\0",10)) || (!memcmp(hdr->AS.Header+14,"\x0A\x00\x90\x80\0\0\x78\x80\0\0",10)) || (!memcmp(hdr->AS.Header+14,"\x0A\xCD\xCD\xCD\xCD\xCD\xCD\xCD\0\0",10)) ) && (leu32p(hdr->AS.Header+24) == 136) && (leu32p(hdr->AS.Header+28) == 0x0007) && (leu16p(hdr->AS.Header+32) == 0x0001) ) { hdr->TYPE = SCP_ECG; hdr->VERSION = -2; } else if ( (leu32p(hdr->AS.Header+10) == 136) && (*(uint16_t*)(hdr->AS.Header+ 8) == 0x0000) && (*(uint8_t*) (hdr->AS.Header+14) == 0x0A) && (*(uint8_t*) (hdr->AS.Header+15) == 0x0B) && (*(uint32_t*)(hdr->AS.Header+16) == 0) && (*(uint32_t*)(hdr->AS.Header+20) == 0) && (*(uint32_t*)(hdr->AS.Header+24) == 0) && (*(uint32_t*)(hdr->AS.Header+28) == 0) && (leu16p(hdr->AS.Header+32) == 0x0001) ) { hdr->TYPE = SCP_ECG; hdr->VERSION = -3; } */ /* // special SCP files - header is strange, files cannot be decoded else if ( (leu32p(hdr->AS.Header+10) == 136) && (*(uint16_t*)(hdr->AS.Header+ 8) == 0x0000) && (leu16p(hdr->AS.Header+14) == 0x0b0b) && (!memcmp(hdr->AS.Header+16,"x06SCPECG",7)) ) { hdr->TYPE = SCP_ECG; hdr->VERSION = -1; } else if ( (leu32p(hdr->AS.Header+10) == 136) && (*(uint16_t*)(hdr->AS.Header+ 8) == 0x0000) && (leu16p(hdr->AS.Header+14) == 0x0d0d) && (!memcmp(hdr->AS.Header+16,"SCPEGC\0\0",8)) && (leu32p(hdr->AS.Header+24) == 136) && (leu32p(hdr->AS.Header+28) == 0x0007) && (leu16p(hdr->AS.Header+32) == 0x0001) ) { hdr->TYPE = SCP_ECG; hdr->VERSION = -4; } */ else if ((hdr->HeadLen > 78) && !memcmp(Header1,"HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000",78)) hdr->TYPE = SASXPT; // SAS Transport file format (XPORT) else if (!memcmp(Header1,"$FL2@(#) SPSS DATA FILE",8)) { hdr->TYPE = SPSS; // SPSS file format switch (*(uint32_t*)(Header1+64)) { case 0x00000002: case 0x00000003: hdr->FILE.LittleEndian = 1; break; case 0x02000000: case 0x03000000: hdr->FILE.LittleEndian = 0; break; } } else if ((Header1[0]==0x71 || Header1[0]==0x72) && (Header1[1]==1 || Header1[1]==2) && Header1[2]==1 && Header1[3]==0 ) hdr->TYPE = STATA; else if (!memcmp(Header1,"IAvSFo",6)) hdr->TYPE = SIGIF; else if (!memcmp(Header1,"position,duration,channel,type,name\n",35)) hdr->TYPE = SigViewerEventsCSV; else if ((hdr->HeadLen>23) && !memcmp(Header1,"SQLite format 3\000",16) && Header1[21]==64 && Header1[22]==32 && Header1[23]==32 ) hdr->TYPE = SQLite; else if ((hdr->HeadLen>23) && !memcmp(Header1,"\"Snap-Master Data File\"",24)) hdr->TYPE = SMA; else if (!memcmp(Header1,".snd",5)) hdr->TYPE = SND; else if (!memcmp(Header1,".snd",5)) hdr->TYPE = SND; else if (!memcmp(Header1,"TDSm",4)) hdr->TYPE = TDMS; // http://www.ni.com/white-paper/5696/en else if ((hdr->HeadLen>30) && !memcmp(Header1,"POLY SAMPLE FILEversion ",24) && !memcmp(Header1+28, "\x0d\x0a\x1a",3)) hdr->TYPE = TMS32; else if ((hdr->HeadLen>35) && !memcmp(Header1,"FileId=TMSi PortiLab sample log file\x0a\x0dVersion=",35)) hdr->TYPE = TMSiLOG; else if (!memcmp(Header1,MAGIC_NUMBER_TIFF_l32,4)) hdr->TYPE = TIFF; else if (!memcmp(Header1,MAGIC_NUMBER_TIFF_b32,4)) hdr->TYPE = TIFF; else if (!memcmp(Header1,MAGIC_NUMBER_TIFF_l64,8)) hdr->TYPE = TIFF; else if (!memcmp(Header1,MAGIC_NUMBER_TIFF_b64,8)) hdr->TYPE = TIFF; else if (!memcmp(Header1,"#VRML",5)) hdr->TYPE = VRML; else if ((hdr->HeadLen > 17) && !memcmp(hdr->AS.Header+4,MAGIC_NUMBER_UNIPRO,14)) hdr->TYPE = UNIPRO; else if (!memcmp(Header1,MAGIC_NUMBER_SYNERGY,sizeof(MAGIC_NUMBER_SYNERGY)) && !strncmp(Header1+63,"CRawDataElement",15) && !strncmp(Header1+85,"CRawDataBuffer",14) ) { hdr->TYPE = SYNERGY; } else if ((hdr->HeadLen > 23) && !memcmp(Header1,"# vtk DataFile Version ",23)) { hdr->TYPE = VTK; char tmp[4]; tmp[3]=0; memcpy(tmp,(char*)Header1+23,3); hdr->VERSION = strtod(tmp,NULL); } else if (!strncmp(Header1,"Serial number",13)) hdr->TYPE = ASCII_IBI; else if (!memcmp(Header1,"VER=9\r\nCTIME=",13)) hdr->TYPE = WCP; else if (!memcmp(Header1,"\xAF\xFE\xDA\xDA",4) || !memcmp(Header1,"\xDA\xDA\xFE\xAF",4) || !memcmp(Header1,"\x55\x55\xFE\xAF",4) ) hdr->TYPE = WG1; // Walter Graphtek else if (!memcmp(Header1,MAGIC_NUMBER_Z,3)) hdr->TYPE = Z; else if (!strncmp(Header1,"PK\003\004",4)) hdr->TYPE = ZIP; else if (!strncmp(Header1,"PK\005\006",4)) hdr->TYPE = ZIP; else if (!strncmp(Header1,"!\n",8)) hdr->TYPE = MSVCLIB; /* else if (!strncmp(Header1,"XDF",3)) hdr->TYPE = XDF; */ else if (!strncmp(Header1,"ZIP2",4)) hdr->TYPE = ZIP2; else if ((hdr->HeadLen>13) && !memcmp(Header1,"TYPE = HL7aECG; else if ( (leu32p(hdr->AS.Header) & 0x00FFFFFFL) == 0x00BFBBEFL && !memcmp(Header1+3,"TYPE = HL7aECG; // UTF8 else if (leu16p(hdr->AS.Header)==0xFFFE) { hdr->TYPE = XML; // UTF16 BigEndian hdr->FILE.LittleEndian = 0; } else if (leu16p(hdr->AS.Header)==0xFEFF) { hdr->TYPE = XML; // UTF16 LittleEndian hdr->FILE.LittleEndian = 1; } else if ((hdr->HeadLen>40) && !memcmp(hdr->AS.Header,"V3.0 ",16) && !memcmp(hdr->AS.Header+32,"[PatInfo]",9)) { hdr->TYPE = Sigma; hdr->VERSION = 3.0; } else if ((hdr->HeadLen > 175) && (hdr->AS.Header[175] < 5)) { hdr->TYPE = TRC; // Micromed *.TRC format hdr->FILE.LittleEndian = 1; } else if (!memcmp(hdr->AS.Header,"\x4c\x00\x00\x00\x01\x14\x02\x00\x00\x00\x00\x00\xC0\x00\x00\x00\x00\x00\x46",20)) { hdr->TYPE = MS_LNK; // Microsoft *.LNK format hdr->FILE.LittleEndian = 1; } else if ((hdr->HeadLen > 175) && (hdr->AS.Header[175] < 5)) { hdr->TYPE = TRC; // Micromed *.TRC format hdr->FILE.LittleEndian = 1; } else { // if the first 4 bytes represent the file length struct stat FileBuf; if (stat(hdr->FileName,&FileBuf)==0 && (leu32p(hdr->AS.Header+2)==FileBuf.st_size) && (leu16p(hdr->AS.Header)==0) ) { // Cardioview 3000 generates such SCP files hdr->TYPE = SCP_ECG; hdr->FILE.LittleEndian = 1; fprintf(stderr,"Warning SOPEN (SCP): this kind of an SCP file predates the official SCP (EN1064) standard and is not fully implemented.\n" ); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): %i %s %s \n",__FILE__,__LINE__,hdr->TYPE,GetFileTypeString(hdr->TYPE),hdr->FileName); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): 0x%x 0x%x \n",__FILE__,__LINE__,leu32p(hdr->AS.Header),(int)FileBuf.st_size); } #endif //ONLYGDF if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): %i %s %s \n",__FILE__,__LINE__,hdr->TYPE,GetFileTypeString(hdr->TYPE),hdr->FileName); return(hdr); } const struct FileFormatStringTable_t FileFormatStringTable[] = { { unknown, "unknown" }, { alpha, "alpha" }, { ABF, "ABF" }, { ABF2, "ABF2" }, { ACQ, "ACQ" }, { ACR_NEMA, "ACR_NEMA" }, { AINF, "AINF" }, { AIFC, "AIFC" }, { AIFF, "AIFF" }, { ARC, "ARC(Cadwell)" }, { ARFF, "ARFF" }, { ASCII, "ASCII" }, { ATES, "ATES" }, { ATF, "ATF" }, { AU, "AU" }, { AXG, "AXG" }, { Axona, "Axona" }, { BCI2000, "BCI2000" }, { BDF, "BDF" }, { BESA, "BESA" }, { BIN, "BINARY" }, { BKR, "BKR" }, { BLSC, "BLSC" }, { BMP, "BMP" }, { BNI, "BNI-1-Baltimore/Nicolet" }, { BrainVision, "BrainVision" }, { BrainVisionVAmp, "BrainVision" }, { BrainVisionMarker, "BrainVision" }, { BZ2, "BZ2" }, { CDF, "CDF" }, { CFS, "CFS" }, { CFWB, "CFWB" }, { CNT, "CNT" }, { CTF, "CTF" }, { DEMG, "DEMG" }, { DICOM, "DICOM" }, { EAS, "EAS(Cadwell)" }, { EBNEURO, "EBNEURO"}, { EBS, "EBS" }, { EDF, "EDF" }, { EEG1100, "EEG1100" }, { EEProbe, "EEProbe" }, { EGI, "EGI" }, { EGIS, "EGIS" }, { ELF, "ELF" }, { EMBLA, "EMBLA" }, { EMSA, "EMSA" }, { ePrime, "ePrime" }, { ET_MEG, "ET-MEG" }, { ETG4000, "ETG4000" }, { EVENT, "EVENT" }, { EXIF, "EXIF" }, { EZ3, "EZ3(Cadwell)" }, { FAMOS, "FAMOS" }, { FEF, "FEF" }, { FIFF, "FIFF" }, { FITS, "FITS" }, { FLAC, "FLAC" }, { GDF, "GDF" }, { GIF, "GIF" }, { GTF, "GTF" }, { GZIP, "GZIP" }, { HDF, "HDF" }, { HEKA, "HEKA" }, { HL7aECG, "HL7aECG" }, { IBW, "IBW" }, { ITX, "ITX" }, { ISHNE, "ISHNE" }, { JPEG, "JPEG" }, { JSON, "JSON" }, { Matlab, "MAT" }, { MFER, "MFER" }, { MIDI, "MIDI" }, { MIT, "MIT" }, { MM, "MatrixMarket" }, { MSI, "MSI" }, { MS_LNK, ".LNK" }, { MSVCLIB, "MS VC++ Library" }, { MX, "Mathematica serialized package format" }, { native, "native" }, { NeuroLoggerHEX, "NeuroLoggerHEX"}, { NetCDF, "NetCDF" }, { NEV, "NEV" }, { NEX1, "NEX" }, { NIFTI, "NIFTI" }, { NEURON, "NEURON" }, { NUMPY, "NUMPY" }, { Persyst, "Persyst" }, { OGG, "OGG" }, { PDP, "PDP" }, { PLEXON, "PLEXON" }, { RDF, "RDF" }, { IntanCLP, "IntanCLP" }, { RHD2000, "RHD2000" }, { RHS2000, "RHS2000" }, { RIFF, "RIFF" }, { SASXPT, "SAS_XPORT" }, { SCP_ECG, "SCP" }, { SIGIF, "SIGIF" }, { Sigma, "Sigma" }, { SigViewerEventsCSV, "SigViewer's CSV event table"}, { SMA, "SMA" }, { SMR, "SON/SMR" }, { SND, "SND" }, { SPSS, "SPSS" }, { SQLite, "SQLite" }, { STATA, "STATA" }, { SVG, "SVG" }, { SYNERGY, "SYNERGY"}, { TDMS, "TDMS (NI)" }, { TIFF, "TIFF" }, { TMS32, "TMS32" }, { TMSiLOG, "TMSiLOG" }, { TRC, "TRC" }, { UNIPRO, "UNIPRO" }, { VRML, "VRML" }, { VTK, "VTK" }, { WAV, "WAV" }, { WCP, "WCP" }, { WG1, "Walter Graphtek" }, { WMF, "WMF" }, { XDF, "XDF" }, { XML, "XML" }, { ZIP, "ZIP" }, { ZIP2, "ZIP2" }, { Z, "Z" }, { noFile, NULL } } ; /* ------------------------------------------ * returns string of file type * ------------------------------------------- */ const char* GetFileTypeString(enum FileFormat FMT) { uint16_t k; for (k=0; ; k++) { if (FMT==FileFormatStringTable[k].fmt) return (FileFormatStringTable[k].FileTypeString); if (noFile==FileFormatStringTable[k].fmt) // stopping criteria: last element in FileFormatStringTable return (NULL); } } /* ------------------------------------------ * returns file type from type string * ------------------------------------------- */ enum FileFormat GetFileTypeFromString(const char *FileTypeString) { uint16_t k; for (k=0; ; k++) { if (FileFormatStringTable[k].FileTypeString == NULL) // stopping criteria: last element in FileFormatStringTable return (noFile); if (!strcmp(FileFormatStringTable[k].FileTypeString, FileTypeString)) return (FileFormatStringTable[k].fmt); } } /****************************************************************************/ /** struct2gdfbin **/ /****************************************************************************/ void struct2gdfbin(HDRTYPE *hdr) { size_t k; char tmp[81]; uint32_t Dur[2]; // NS number of channels selected for writing typeof(hdr->NS) NS = 0; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (hc->OnOff) NS++; hc->Cal = (hc->PhysMax-hc->PhysMin)/(hc->DigMax-hc->DigMin); hc->Off = hc->PhysMin-hc->Cal*hc->DigMin; } hdr->HeadLen = (NS+1)*256; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %p\n", __func__, __LINE__, hdr->HeadLen, hdr->EVENT.LenCodeDesc, hdr->EVENT.CodeDesc); /****** * The size of Header 3 is computed by going through all TLV triples, * and compute HeadLen to allocate sufficient amount of memory * Header 3 is filled later in a 2nd scan below ******/ /* writing header 3, in Tag-Length-Value from */ uint32_t TagNLen[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint8_t tag=1; if (hdr->EVENT.LenCodeDesc > 1) { // first entry is always empty - no need to save tag1 for (k=0; kEVENT.LenCodeDesc; k++) TagNLen[tag] += strlen(hdr->EVENT.CodeDesc[k])+1; TagNLen[tag] += 1; // acounts for terminating \0 hdr->HeadLen += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 2; if (hdr->AS.bci2000 != NULL) { TagNLen[tag] = strlen(hdr->AS.bci2000)+1; hdr->HeadLen += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 3; if ((hdr->ID.Manufacturer.Name != NULL) || (hdr->ID.Manufacturer.Model != NULL) || (hdr->ID.Manufacturer.Version != NULL) || (hdr->ID.Manufacturer.SerialNumber != NULL)) { if (hdr->ID.Manufacturer.Name == NULL) hdr->ID.Manufacturer.Name=""; if (hdr->ID.Manufacturer.Model == NULL) hdr->ID.Manufacturer.Model=""; if (hdr->ID.Manufacturer.Version == NULL) hdr->ID.Manufacturer.Version=""; if (hdr->ID.Manufacturer.SerialNumber == NULL) hdr->ID.Manufacturer.SerialNumber=""; TagNLen[tag] = strlen(hdr->ID.Manufacturer.Name)+strlen(hdr->ID.Manufacturer.Model)+strlen(hdr->ID.Manufacturer.Version)+strlen(hdr->ID.Manufacturer.SerialNumber)+4; hdr->HeadLen += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 4; /* OBSOLETE char FLAG_SENSOR_ORIENTATION = 0; for (k=0; kNS; k++) { FLAG_SENSOR_ORIENTATION |= hdr->CHANNEL[k].Orientation[0] != (float)0.0; FLAG_SENSOR_ORIENTATION |= hdr->CHANNEL[k].Orientation[1] != (float)0.0; FLAG_SENSOR_ORIENTATION |= hdr->CHANNEL[k].Orientation[2] != (float)0.0; FLAG_SENSOR_ORIENTATION |= hdr->CHANNEL[k].Area != (float)0.0; } if (FLAG_SENSOR_ORIENTATION) TagNLen[tag] = hdr->NS*sizeof(float)*4; hdr->HeadLen += 4+TagNLen[tag]; */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 5; for (k=0; k<16; k++) { if (hdr->IPaddr[k]) { if (k<4) TagNLen[tag] = 4; else TagNLen[tag] = 16; } hdr->HeadLen += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 6; TagNLen[tag] = hdr->ID.Technician==NULL ? 0 : strlen(hdr->ID.Technician); if (TagNLen[tag]) { TagNLen[tag]++; hdr->HeadLen += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 7; if (hdr->ID.Hospital!=NULL) { TagNLen[tag] = strlen(hdr->ID.Hospital); if (TagNLen[tag]) { TagNLen[tag]++; hdr->HeadLen += 4+TagNLen[tag]; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); #if (BIOSIG_VERSION >= 10500) tag = 9; if (hdr->SCP.Section7 != NULL) { TagNLen[tag] = hdr->SCP.Section7Length; // leu32p(hdr->SCP.Section7+4); if (TagNLen[tag]) { hdr->HeadLen += 4+TagNLen[tag]; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 10; if (hdr->SCP.Section8 != NULL) { TagNLen[tag] = hdr->SCP.Section8Length; // leu32p(hdr->SCP.Section8+4); if (TagNLen[tag]) { hdr->HeadLen += 4+TagNLen[tag]; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 11; if (hdr->SCP.Section9 != NULL) { TagNLen[tag] = hdr->SCP.Section9Length; // leu32p(hdr->SCP.Section9+4); if (TagNLen[tag]) { hdr->HeadLen += 4+TagNLen[tag]; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 12; if (hdr->SCP.Section10 != NULL) { TagNLen[tag] = hdr->SCP.Section10Length; // leu32p(hdr->SCP.Section10+4); if (TagNLen[tag]) { hdr->HeadLen += 4+TagNLen[tag]; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); tag = 13; if (hdr->SCP.Section11 != NULL) { TagNLen[tag] = hdr->SCP.Section11Length; // leu32p(hdr->SCP.Section11+4); if (TagNLen[tag]) { hdr->HeadLen += 4+TagNLen[tag]; } } #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); /* end */ if (hdr->TYPE==GDF) { if (0.0 < hdr->VERSION && hdr->VERSION < 1.9) { hdr->VERSION = 1.25; } else if (hdr->VERSION < 3.0) { // this is currently still the default version #if (BIOSIG_VERSION >= 10500) hdr->VERSION = 2.51; #else hdr->VERSION = 2.22; #endif } else { hdr->VERSION = 3.0; } // in case of GDF v2, make HeadLen a multiple of 256. if ((hdr->VERSION > 2.0) && (hdr->HeadLen & 0x00ff)) hdr->HeadLen = (hdr->HeadLen & 0xff00) + 256; } else if (hdr->TYPE==GDF1) { fprintf(stderr,"libbiosig@sopen(hdr,\"w\") with hdr->TYPE=GDF1 is deprecated. Use hdr->TYPE=GDF and hdr->VERSION=1.25 instead\n"); hdr->VERSION = 1.25; hdr->TYPE = GDF; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, 1, hdr->HeadLen, TagNLen[1]); if (hdr->SCP.Section7 || hdr->SCP.Section8 || hdr->SCP.Section9 || hdr->SCP.Section10 || hdr->SCP.Section11) { // use auxillary pointer in order to keep SCP sections in memory if (hdr->aECG) free(hdr->aECG); hdr->aECG = hdr->AS.Header; hdr->AS.Header = (uint8_t*) realloc(NULL, hdr->HeadLen); } else { hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, hdr->HeadLen); } if (hdr->AS.Header == NULL) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Memory allocation failed"); return; } memset(Header1, 0, 256*(1+hdr->NS)); sprintf((char*)hdr->AS.Header,"GDF %4.2f",hdr->VERSION); uint8_t* Header2 = hdr->AS.Header+256; uint16_t maxlen = 66; if (hdr->VERSION < 1.90) maxlen = 80; size_t l1 = (hdr->Patient.Id==NULL) ? 0 : strlen(hdr->Patient.Id); size_t l2 = (hdr->Patient.Name==NULL) ? 0 : strlen(hdr->Patient.Name); if (0 < l1 && l1 < maxlen) { for (k=0; hdr->Patient.Id[k]; k++) if (isspace(hdr->Patient.Id[k])) hdr->Patient.Id[k] = '_'; strncpy(Header1+8, hdr->Patient.Id, l1+1); } else { strncpy(Header1+8, "X X",4); l1 = 1; } if (!hdr->FLAG.ANONYMOUS && (0 < l2) && (l1+l2+1 < maxlen) ) { Header1[8+l1] = ' '; strcpy(Header1+8+1+l1, hdr->Patient.Name); /* Flawfinder: ignore *** length is already checked with l1+l2+1 */ } else if (l1+3 < maxlen) strcpy(Header1+8+l1, " X"); if (hdr->VERSION>1.90) { Header1[84] = (hdr->Patient.Smoking%4) + ((hdr->Patient.AlcoholAbuse%4)<<2) + ((hdr->Patient.DrugAbuse%4)<<4) + ((hdr->Patient.Medication%4)<<6); Header1[85] = hdr->Patient.Weight; Header1[86] = hdr->Patient.Height; Header1[87] = (hdr->Patient.Sex%4) + ((hdr->Patient.Handedness%4)<<2) + ((hdr->Patient.Impairment.Visual%4)<<4) + ((hdr->Patient.Impairment.Heart%4)<<6); } size_t len = strlen(hdr->ID.Recording); memcpy(Header1+88, hdr->ID.Recording, min(len,80)); Header1[88 + min(len,80)] = 0; if (hdr->VERSION>1.90) { memcpy(Header1+152, &hdr->LOC, 16); #if __BYTE_ORDER == __BIG_ENDIAN *(uint32_t*) (Header1+152) = htole32( *(uint32_t*) (Header1+152) ); *(uint32_t*) (Header1+156) = htole32( *(uint32_t*) (Header1+156) ); *(uint32_t*) (Header1+160) = htole32( *(uint32_t*) (Header1+160) ); *(uint32_t*) (Header1+164) = htole32( *(uint32_t*) (Header1+164) ); #endif } if (hdr->VERSION<1.90) { struct tm *t = gdf_time2tm_time(hdr->T0); sprintf(tmp,"%04i%02i%02i%02i%02i%02i00",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); memcpy(hdr->AS.Header+168,tmp,max(strlen(tmp),16)); leu32a(hdr->HeadLen, hdr->AS.Header+184); memcpy(Header1+192, &hdr->ID.Equipment, 8); // FIXME: 200: LabId, 208 TechId, 216, Serial No // } else { //memcpy(Header1+168, &hdr->T0, 8); leu64a(hdr->T0, hdr->AS.Header+168); //memcpy(Header1+176, &hdr->Patient.Birthday, 8); leu64a(hdr->Patient.Birthday, hdr->AS.Header+176); // *(uint16_t*)(Header1+184) = (hdr->HeadLen>>8)+(hdr->HeadLen%256>0); leu32a(hdr->HeadLen>>8, hdr->AS.Header+184); memcpy(hdr->AS.Header+192, &hdr->ID.Equipment, 8); memcpy(hdr->AS.Header+200, &hdr->IPaddr, 6); memcpy(hdr->AS.Header+206, &hdr->Patient.Headsize, 6); lef32a(hdr->ELEC.REF[0], hdr->AS.Header+212); lef32a(hdr->ELEC.REF[1], hdr->AS.Header+216); lef32a(hdr->ELEC.REF[2], hdr->AS.Header+220); lef32a(hdr->ELEC.GND[0], hdr->AS.Header+224); lef32a(hdr->ELEC.GND[1], hdr->AS.Header+228); lef32a(hdr->ELEC.GND[2], hdr->AS.Header+232); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %x\n", __func__, __LINE__, hdr->HeadLen,leu32p(hdr->AS.Header+184)); leu64a(hdr->NRec, hdr->AS.Header+236); /* FIXME: this part should make the records as small as possible size_t DIV = 1, div; for (k=0; kNS; k++) { div = hdr->SPR/hdr->CHANNEL[k].SPR; if (div>DIV) DIV=div; } for (k=0; kNS; k++) { hdr->CHANNEL[k].SPR = (hdr->CHANNEL[k].SPR*DIV)/hdr->SPR; } hdr->NRec *= hdr->SPR/DIV; hdr->SPR = DIV; */ double fDur = hdr->SPR/hdr->SampleRate; if (hdr->NS==0 && 0.0 < hdr->EVENT.SampleRate && hdr->EVENT.SampleRate < INFINITY) fDur = 1.0 / hdr->EVENT.SampleRate; if (hdr->VERSION < 2.21) { /* Duration is expressed as an fraction of integers */ double dtmp1, dtmp2; dtmp2 = modf(fDur, &dtmp1); // approximate real with rational number if (fabs(dtmp2) < DBL_EPSILON) { Dur[0] = lround(fDur); Dur[1] = 1; } else { Dur[1] = lround(1.0 / dtmp2 ); Dur[0] = lround(1.0 + dtmp1 * Dur[1]); } leu32a(Dur[0], hdr->AS.Header+244); leu32a(Dur[1], hdr->AS.Header+248); } else lef64a(fDur, hdr->AS.Header+244); leu16a(NS, hdr->AS.Header + 252); if (hdr->VERSION > 2.4) { lei16a(hdr->tzmin, hdr->AS.Header+254); } /* define HDR.Header2 this requires checking the arguments in the fields of the struct HDR.CHANNEL and filling in the bytes in HDR.Header2. */ typeof(k) k2=0; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) { const char *tmpstr; CHANNEL_TYPE *hc = hdr->CHANNEL+k; if ( (0 < hc->LeadIdCode) && (hc->LeadIdCode * sizeof(&LEAD_ID_TABLE[0]) < sizeof(LEAD_ID_TABLE) ) ) tmpstr = LEAD_ID_TABLE[hc->LeadIdCode]; else tmpstr = hc->Label; len = strlen(tmpstr)+1; memcpy(Header2+16*k2,tmpstr,min(len,16)); Header2[16*k2+min(len,16)] = 0; len = strlen(hdr->CHANNEL[k].Transducer); memcpy(Header2+80*k2 + 16*NS, hdr->CHANNEL[k].Transducer, min(len,80)); Header2[80*k2 + min(len,80) + 16*NS] = 0; tmpstr = PhysDim3(hdr->CHANNEL[k].PhysDimCode); len = strlen(tmpstr)+1; if (hdr->VERSION < 1.9) memcpy(Header2+ 8*k2 + 96*NS, tmpstr, min(8,len)); else { memcpy(Header2+ 6*k2 + 96*NS, tmpstr, min(6,len)); leu16a(hdr->CHANNEL[k].PhysDimCode, Header2+ 2*k2 + 102*NS); }; lef64a(hdr->CHANNEL[k].PhysMin, Header2 + 8*k2 + 104*NS); lef64a(hdr->CHANNEL[k].PhysMax, Header2 + 8*k2 + 112*NS); if (hdr->VERSION < 1.9) { lei64a((int64_t)hdr->CHANNEL[k].DigMin, Header2 + 8*k2 + 120*NS); lei64a((int64_t)hdr->CHANNEL[k].DigMax, Header2 + 8*k2 + 128*NS); // FIXME // memcpy(Header2 + 80*k + 136*hdr->NS,hdr->CHANNEL[k].PreFilt,max(80,strlen(hdr->CHANNEL[k].PreFilt))); } else { lef64a(hdr->CHANNEL[k].DigMin, Header2 + 8*k2 + 120*NS); lef64a(hdr->CHANNEL[k].DigMax, Header2 + 8*k2 + 128*NS); if (hdr->VERSION >= 2.22) lef32a(hdr->CHANNEL[k].TOffset, Header2 + 4*k2 + 200*NS); // GDF222 lef32a(hdr->CHANNEL[k].LowPass, Header2 + 4*k2 + 204*NS); lef32a(hdr->CHANNEL[k].HighPass, Header2 + 4*k2 + 208*NS); lef32a(hdr->CHANNEL[k].Notch, Header2 + 4*k2 + 212*NS); lef32a(hdr->CHANNEL[k].XYZ[0], Header2 + 4*k2 + 224*NS); lef32a(hdr->CHANNEL[k].XYZ[1], Header2 + 4*k2 + 228*NS); lef32a(hdr->CHANNEL[k].XYZ[2], Header2 + 4*k2 + 232*NS); if (hdr->VERSION < (float)2.19) Header2[k2+236*NS] = (uint8_t)ceil(log10(min(39e8,hdr->CHANNEL[k].Impedance))/log10(2.0)*8.0-0.5); else switch (hdr->CHANNEL[k].PhysDimCode & 0xFFE0) { // context-specific header 2 area case 4256: lef32a((float)hdr->CHANNEL[k].Impedance, Header2+236*NS+20*k2); break; case 4288: lef32a((float)hdr->CHANNEL[k].fZ, Header2+236*NS+20*k2); break; // default: // reserved area } } leu32a(hdr->CHANNEL[k].SPR, Header2 + 4*k2 + 216*NS); leu32a(hdr->CHANNEL[k].GDFTYP, Header2 + 4*k2 + 220*NS); k2++; } if (errno==34) errno = 0; // reset numerical overflow error if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d) %d %s\n", __func__, __LINE__, errno, strerror(errno)); /***** * This is the 2nd scan of Header3 - memory is allocated, now H3 is filled in with content *****/ Header2 = hdr->AS.Header+(NS+1)*256; tag = 1; if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=1 & Length of Tag 1 size_t pos = 4; for (k=0; kEVENT.LenCodeDesc; k++) { strcpy((char*)(Header2+pos),hdr->EVENT.CodeDesc[k]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ pos += strlen(hdr->EVENT.CodeDesc[k])+1; } Header2[pos]=0; // terminating NULL Header2 += pos+1; } tag = 2; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=2 & Length of Tag 2 strcpy((char*)(Header2+4),hdr->AS.bci2000); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ Header2 += 4+TagNLen[tag]; } tag = 3; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=3 & Length of Tag 3 if (VERBOSE_LEVEL>8) fprintf(stdout,"SOPEN(GDF)w: tag=%i,len=%i\n",tag,TagNLen[tag]); memset(Header2+4,0,TagNLen[tag]); size_t len = 0; strcpy((char*)(Header2+4), hdr->ID.Manufacturer.Name); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ if (hdr->ID.Manufacturer.Name != NULL) len += strlen(hdr->ID.Manufacturer.Name); strcpy((char*)(Header2+5+len), hdr->ID.Manufacturer.Model); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ if (hdr->ID.Manufacturer.Model != NULL) len += strlen(hdr->ID.Manufacturer.Model); strcpy((char*)(Header2+6+len), hdr->ID.Manufacturer.Version); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ if (hdr->ID.Manufacturer.Version != NULL) len += strlen(hdr->ID.Manufacturer.Version); strcpy((char*)(Header2+7+len), hdr->ID.Manufacturer.SerialNumber); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ if (hdr->ID.Manufacturer.SerialNumber != NULL) len += strlen(hdr->ID.Manufacturer.SerialNumber); Header2 += 4+TagNLen[tag]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); /* tag = 4; if (TagNLen[tag]>0) { *(uint32_t*)(Header2) = htole32(tag + (TagNLen[tag]<<8)); // Tag=4 & Length of Tag 4 Header2 += 4; for (k=0; kNS; k++) { *(uint32_t*)(Header2 + 4*k) = le32toh(*(uint32_t*)(hdr->CHANNEL[k].Orientation+0)); *(uint32_t*)(Header2 + 4*k + 4*hdr->NS) = le32toh(*(uint32_t*)(hdr->CHANNEL[k].Orientation+1)); *(uint32_t*)(Header2 + 4*k + 8*hdr->NS) = le32toh(*(uint32_t*)(hdr->CHANNEL[k].Orientation+2)); *(uint32_t*)(Header2 + 4*k +12*hdr->NS) = le32toh(*(uint32_t*)(&(hdr->CHANNEL[k].Area)); } Header2 += 4*sizeof(float)*hdr->NS; } */ tag = 5; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=5 & Length of Tag 5 memcpy(Header2+4,hdr->IPaddr,TagNLen[tag]); Header2 += 4+TagNLen[tag]; } tag = 6; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=6 & Length of Tag 6 strcpy((char*)(Header2+4),hdr->ID.Technician); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ Header2 += 4+TagNLen[tag]; } tag = 7; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=7 & Length of Tag 7 strcpy((char*)(Header2+4),hdr->ID.Hospital); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ Header2 += 4+TagNLen[tag]; } #if (BIOSIG_VERSION >= 10500) tag = 9; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=9 & Length of Tag 9 memcpy((char*)(Header2+4),hdr->SCP.Section7, TagNLen[tag]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ hdr->SCP.Section7 = Header2+4; Header2 += 4+TagNLen[tag]; } tag = 10; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=10 & Length of Tag 10 memcpy((char*)(Header2+4),hdr->SCP.Section8, TagNLen[tag]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ hdr->SCP.Section8 = Header2+4; Header2 += 4+TagNLen[tag]; } tag = 11; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=11 & Length of Tag 11 memcpy((char*)(Header2+4),hdr->SCP.Section9, TagNLen[tag]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ hdr->SCP.Section9 = Header2+4; Header2 += 4+TagNLen[tag]; } tag = 12; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=12 & Length of Tag 12 memcpy((char*)(Header2+4),hdr->SCP.Section10, TagNLen[tag]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ hdr->SCP.Section10 = Header2+4; Header2 += 4+TagNLen[tag]; } tag = 13; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i %i\n", __func__, __LINE__, tag, hdr->HeadLen, TagNLen[tag]); if (TagNLen[tag]>0) { leu32a(tag + (TagNLen[tag]<<8), Header2); // Tag=13 & Length of Tag 13 memcpy((char*)(Header2+4),hdr->SCP.Section11, TagNLen[tag]); /* Flawfinder: ignore *** memory is allocated after 1st H3 scan above */ hdr->SCP.Section11 = Header2+4; Header2 += 4+TagNLen[tag]; } #endif while (Header2 < (hdr->AS.Header + hdr->HeadLen) ) { *Header2 = 0; Header2++; } if (hdr->aECG) { free(hdr->aECG); hdr->aECG=NULL; } if (VERBOSE_LEVEL>8) fprintf(stdout,"GDFw [339] %p %p\n", Header1,Header2); } /**************************************************************************** gdfbin2struct converts flat file into hdr structure ****************************************************************************/ int gdfbin2struct(HDRTYPE *hdr) { unsigned int k; char tmp[81]; double Dur; // char* ptr_str; struct tm tm_time; // time_t tt; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %p\n",__func__,__LINE__,hdr->AS.Header); if (!memcmp("GDF",(char*)(hdr->AS.Header+3),3)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Only GDF is supported"); return (hdr->AS.B4C_ERRNUM); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i \n",__func__,__LINE__, (int)hdr->NS); strncpy(tmp,(char*)(hdr->AS.Header+3),5); tmp[5]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i Ver=<%s>\n",__func__,__LINE__, (int)hdr->NS,tmp); hdr->VERSION = atof(tmp); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i Ver=<%s>\n",__func__,__LINE__, (int)hdr->NS,tmp); hdr->NRec = lei64p(hdr->AS.Header+236); hdr->NS = leu16p(hdr->AS.Header+252); hdr->tzmin = (hdr->VERSION > 2.4) ? lei16p(hdr->AS.Header+254) : 0; if (hdr->VERSION < 2.21) Dur = (double)leu32p(hdr->AS.Header+244)/(double)leu32p(hdr->AS.Header+248); else Dur = lef64p(hdr->AS.Header+244); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i Ver=%g\n",__func__,__LINE__, hdr->NS, hdr->VERSION); if (hdr->VERSION > 1.90) { hdr->HeadLen = leu16p(hdr->AS.Header+184)<<8; int len = min(66,MAX_LENGTH_PID); strncpy(hdr->Patient.Id,(const char*)hdr->AS.Header+8,len); hdr->Patient.Id[len]=0; len = min(64,MAX_LENGTH_RID); strncpy(hdr->ID.Recording,(const char*)hdr->AS.Header+88,len); hdr->ID.Recording[len]=0; strtok(hdr->Patient.Id," "); char *tmpptr = strtok(NULL," "); if ((!hdr->FLAG.ANONYMOUS) && (tmpptr != NULL)) { // strncpy(hdr->Patient.Name,tmpptr,Header1+8-tmpptr); strncpy(hdr->Patient.Name,tmpptr,MAX_LENGTH_NAME); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__func__,__LINE__, GetFileTypeString(hdr->TYPE), hdr->VERSION); hdr->Patient.Smoking = Header1[84]%4; hdr->Patient.AlcoholAbuse = (Header1[84]>>2)%4; hdr->Patient.DrugAbuse = (Header1[84]>>4)%4; hdr->Patient.Medication = (Header1[84]>>6)%4; hdr->Patient.Weight = Header1[85]; hdr->Patient.Height = Header1[86]; hdr->Patient.Sex = Header1[87]%4; hdr->Patient.Handedness = (Header1[87]>>2)%4; hdr->Patient.Impairment.Visual = (Header1[87]>>4)%4; hdr->Patient.Impairment.Heart = (Header1[87]>>6)%4; #if __BYTE_ORDER == __BIG_ENDIAN *(uint32_t*)(hdr->AS.Header+156) = bswap_32(*(uint32_t*)(hdr->AS.Header+156)); *(uint32_t*)(hdr->AS.Header+160) = bswap_32(*(uint32_t*)(hdr->AS.Header+160)); *(uint32_t*)(hdr->AS.Header+164) = bswap_32(*(uint32_t*)(hdr->AS.Header+164)); #endif if (hdr->AS.Header[156]) { hdr->LOC[0] = 0x00292929; memcpy(&hdr->LOC[1], hdr->AS.Header+156, 12); } else { #if __BYTE_ORDER == __BIG_ENDIAN *(uint32_t*) (hdr->AS.Header+152) = bswap_32(*(uint32_t*)(hdr->AS.Header+152)); #endif memcpy(&hdr->LOC, hdr->AS.Header+152, 16); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__func__,__LINE__, GetFileTypeString(hdr->TYPE), hdr->VERSION); hdr->T0 = lei64p(hdr->AS.Header+168); hdr->Patient.Birthday = lei64p(hdr->AS.Header+176); // memcpy(&hdr->T0, Header1+168,8); // memcpy(&hdr->Patient.Birthday, Header1+176, 8); hdr->ID.Equipment = lei64p(hdr->AS.Header+192); if (hdr->VERSION < (float)2.10) memcpy(hdr->IPaddr, Header1+200,4); hdr->Patient.Headsize[0]= leu16p(hdr->AS.Header+206); hdr->Patient.Headsize[1]= leu16p(hdr->AS.Header+208); hdr->Patient.Headsize[2]= leu16p(hdr->AS.Header+210); //memcpy(&hdr->ELEC.REF, Header1+212,12); //memcpy(&hdr->ELEC.GND, Header1+224,12); hdr->ELEC.REF[0] = lef32p(hdr->AS.Header+212); hdr->ELEC.REF[1] = lef32p(hdr->AS.Header+216); hdr->ELEC.REF[2] = lef32p(hdr->AS.Header+220); hdr->ELEC.GND[0] = lef32p(hdr->AS.Header+224); hdr->ELEC.GND[1] = lef32p(hdr->AS.Header+228); hdr->ELEC.GND[2] = lef32p(hdr->AS.Header+232); if (hdr->VERSION > 100000.0) { fprintf(stdout,"%e \nb4c %c %i %c. %c%c%c%c%c%c%c\n",hdr->VERSION,169,2007,65,83,99,104,108,246,103,108); FILE *fid = fopen("/tmp/b4c_tmp","wb"); if (fid != NULL) { fprintf(fid,"\nb4c %f \n%c %i %c.%c%c%c%c%c%c%c\n",hdr->VERSION,169,2007,65,83,99,104,108,246,103,108); fclose(fid); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__func__,__LINE__, GetFileTypeString(hdr->TYPE), hdr->VERSION); } else if (hdr->VERSION > 0.0) { strncpy(hdr->Patient.Id,Header1+8,min(80,MAX_LENGTH_PID)); hdr->Patient.Id[min(80,MAX_LENGTH_PID)] = 0; strncpy(hdr->ID.Recording,(const char*)Header1+88,min(80,MAX_LENGTH_RID)); hdr->ID.Recording[min(80,MAX_LENGTH_RID)] = 0; strtok(hdr->Patient.Id," "); char *tmpptr = strtok(NULL," "); if ((!hdr->FLAG.ANONYMOUS) && (tmpptr != NULL)) { // strncpy(hdr->Patient.Name,tmpptr,Header1+8-tmpptr); strncpy(hdr->Patient.Name,tmpptr,MAX_LENGTH_NAME); } memset(tmp,0,5); strncpy(tmp,Header1+168+12,2); tm_time.tm_sec = atoi(tmp); strncpy(tmp,Header1+168+10,2); tm_time.tm_min = atoi(tmp); strncpy(tmp,Header1+168+ 8,2); tm_time.tm_hour = atoi(tmp); strncpy(tmp,Header1+168+ 6,2); tm_time.tm_mday = atoi(tmp); strncpy(tmp,Header1+168+ 4,2); tm_time.tm_mon = atoi(tmp)-1; strncpy(tmp,Header1+168 ,4); tm_time.tm_year = atoi(tmp)-1900; tm_time.tm_isdst= -1; hdr->T0 = tm_time2gdf_time(&tm_time); hdr->HeadLen = leu64p(hdr->AS.Header+184); } else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(GDF); invalid version number."); return (hdr->AS.B4C_ERRNUM); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i Ver=%4.2f\n",__func__,__LINE__, hdr->NS, hdr->VERSION); if (hdr->HeadLen < (256u * (hdr->NS + 1u))) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "(GDF) Length of Header is too small"); return (hdr->AS.B4C_ERRNUM); } hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); uint8_t *Header2 = hdr->AS.Header+256; hdr->AS.bpb=0; size_t bpb8 = 0; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i/%i\n",__func__,__LINE__, k, hdr->NS); hc->LeadIdCode = 0; size_t len = min(16, MAX_LENGTH_LABEL); strncpy(hc->Label,(char*)Header2 + 16*k, len); hc->Label[len] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"#%2i: <%s> %i %i\n",k,hc->Label,(int)len,(int)strlen(hc->Label)); len = min(MAX_LENGTH_TRANSDUCER, 80); memcpy(hc->Transducer, (char*)Header2 + 16*hdr->NS + 80*k, len); hc->Transducer[len] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[GDF 212] #=%i/%i %s\n",k,hdr->NS,hc->Label); hc->PhysMin = lef64p(Header2+ 8*k + 104*hdr->NS); hc->PhysMax = lef64p(Header2+ 8*k + 112*hdr->NS); hc->SPR = leu32p(Header2+ 4*k + 216*hdr->NS); hc->GDFTYP = leu16p(Header2+ 4*k + 220*hdr->NS); hc->OnOff = 1; hc->bi = bpb8>>3; hc->bi8 = bpb8; size_t nbits = (GDFTYP_BITS[hc->GDFTYP]*(size_t)hc->SPR); bpb8 += nbits; if (hdr->VERSION < 1.90) { char p[9]; strncpy(p, (char*)Header2 + 8*k + 96*hdr->NS,8); p[8] = 0; // remove trailing blanks int k1; for (k1=7; (k1>0) && isspace(p[k1]); p[k1--] = 0) {}; hc->PhysDimCode = PhysDimCode(p); hc->DigMin = (double) lei64p(Header2 + 8*k + 120*hdr->NS); hc->DigMax = (double) lei64p(Header2 + 8*k + 128*hdr->NS); char *PreFilt = (char*)(Header2+ 68*k + 136*hdr->NS); hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->TOffset = NAN; float lf,hf; if (sscanf(PreFilt,"%f - %f Hz",&lf,&hf)==2) { hc->LowPass = hf; hc->HighPass = lf; } } else { hc->PhysDimCode = leu16p(Header2+ 2*k + 102*hdr->NS); hc->DigMin = lef64p(Header2+ 8*k + 120*hdr->NS); hc->DigMax = lef64p(Header2+ 8*k + 128*hdr->NS); hc->LowPass = lef32p(Header2+ 4*k + 204*hdr->NS); hc->HighPass = lef32p(Header2+ 4*k + 208*hdr->NS); hc->Notch = lef32p(Header2+ 4*k + 212*hdr->NS); hc->XYZ[0] = lef32p(Header2+ 4*k + 224*hdr->NS); hc->XYZ[1] = lef32p(Header2+ 4*k + 228*hdr->NS); hc->XYZ[2] = lef32p(Header2+ 4*k + 232*hdr->NS); // memcpy(&hc->XYZ,Header2 + 4*k + 224*hdr->NS,12); hc->Impedance= ldexp(1.0, (uint8_t)Header2[k + 236*hdr->NS]/8); if (hdr->VERSION < 2.22) hc->TOffset = NAN; else hc->TOffset = lef32p(Header2 + 4 * k + 200 * hdr->NS); if (hdr->VERSION < (float)2.19) hc->Impedance = ldexp(1.0, (uint8_t)Header2[k + 236*hdr->NS]/8); else switch(hdr->CHANNEL[k].PhysDimCode & 0xFFE0) { // context-specific header 2 area case 4256: hc->Impedance = *(float*)(Header2+236*hdr->NS+20*k); break; case 4288: hc->fZ = *(float*)(Header2+236*hdr->NS+20*k); break; // default: // reserved area } } hc->Cal = (hc->PhysMax-hc->PhysMin)/(hc->DigMax-hc->DigMin); hc->Off = hc->PhysMin-hc->Cal*hc->DigMin; } hdr->AS.bpb = bpb8>>3; if (bpb8 & 0x07) { // each block must use whole number of bytes hdr->AS.bpb++; hdr->AS.bpb8 = hdr->AS.bpb<<3; } if (VERBOSE_LEVEL>8) fprintf(stdout,"[213] FMT=%s Ver=%4.2f\n",GetFileTypeString(hdr->TYPE),hdr->VERSION); for (k=0, hdr->SPR=1; kNS;k++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"[GDF 214] #=%i\n",k); if (hdr->CHANNEL[k].SPR) hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[k].SPR); if (GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP]==0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "GDF: Invalid or unsupported GDFTYP"); return(hdr->AS.B4C_ERRNUM); } } hdr->SampleRate = ((double)(hdr->SPR))/Dur; if (VERBOSE_LEVEL>8) fprintf(stdout,"[219] FMT=%s Ver=%4.2f\n",GetFileTypeString(hdr->TYPE),hdr->VERSION); /* read GDF Header 3 - experimental */ if ((hdr->HeadLen > 256u*(hdr->NS+1u)) && (hdr->VERSION>=(float)2.10)) { uint8_t *Header2 = hdr->AS.Header + 256*(hdr->NS+1); uint8_t tag = 0xff; size_t pos=0,len=0; tag = (uint8_t)Header2[0]; if (VERBOSE_LEVEL>8) fprintf(stdout,"[220] GDFr3: %i %i Tag=%i\n",hdr->HeadLen,hdr->NS,tag); while ((pos < (hdr->HeadLen-256*(hdr->NS+1)-4)) && (tag>0)) { len = leu32p(Header2+pos)>>8; if (VERBOSE_LEVEL>8) fprintf(stdout,"GDFr3: Tag=%i Len=%i pos=%i\n",tag,(int)len,(int)pos); if (0) {} else if (tag==1) { // user-specific events i.e. free text annotations if (VERBOSE_LEVEL>6) fprintf(stdout,"user-specific events defined\n"); hdr->AS.auxBUF = (uint8_t*) realloc(hdr->AS.auxBUF,len); memcpy(hdr->AS.auxBUF, Header2+pos+4, len); hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,257*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0] = ""; // typ==0, is always empty hdr->EVENT.LenCodeDesc = 1; k = 1; while (hdr->AS.auxBUF[k]) { hdr->EVENT.CodeDesc[hdr->EVENT.LenCodeDesc++] = (char*)(hdr->AS.auxBUF+k); k += strlen((char*)(hdr->AS.auxBUF+k))+1; } } else if (tag==2) { /* BCI 2000 information */ hdr->AS.bci2000 = (char*) realloc(hdr->AS.bci2000,len+1); memcpy(hdr->AS.bci2000,Header2+pos+4,len); hdr->AS.bci2000[len]=0; } else if (tag==3) { /* manufacture information */ if (len > MAX_LENGTH_MANUF) { fprintf(stderr,"Warning: length of Manufacturer information (%i) exceeds length of %i bytes\n", (int)len, MAX_LENGTH_MANUF); len = MAX_LENGTH_MANUF; } memcpy(hdr->ID.Manufacturer._field,Header2+pos+4,len); hdr->ID.Manufacturer._field[MAX_LENGTH_MANUF]=0; hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; hdr->ID.Manufacturer.Model= hdr->ID.Manufacturer.Name+strlen(hdr->ID.Manufacturer.Name)+1; hdr->ID.Manufacturer.Version = hdr->ID.Manufacturer.Model+strlen(hdr->ID.Manufacturer.Model)+1; hdr->ID.Manufacturer.SerialNumber = hdr->ID.Manufacturer.Version+strlen(hdr->ID.Manufacturer.Version)+1; } else if (0) { // (tag==4) { /* sensor orientation */ /* // OBSOLETE for (k=0; kNS; k++) { hdr->CHANNEL[k].Orientation[0] = lef32p(Header2+pos+4+4*k); hdr->CHANNEL[k].Orientation[1] = lef32p(Header2+pos+4+4*k+hdr->NS*4); hdr->CHANNEL[k].Orientation[2] = lef32p(Header2+pos+4+4*k+hdr->NS*8); // if (len >= 12*hdr->NS) hdr->CHANNEL[k].Area = lef32p(Header2+pos+4+4*k+hdr->NS*12); if (VERBOSE_LEVEL>8) fprintf(stdout,"GDF tag=4 #%i pos=%i/%i: %f\n",k,pos,len,hdr->CHANNEL[k].Area); } */ } else if (tag==5) { /* IP address */ memcpy(hdr->IPaddr,Header2+pos+4,len); } else if (tag==6) { /* Technician */ hdr->ID.Technician = (char*)realloc(hdr->ID.Technician,len+1); memcpy(hdr->ID.Technician,Header2+pos+4, len); hdr->ID.Technician[len]=0; } else if (tag==7) { // recording institution // hdr->ID.Hospital = strndup((char*)(Header2+pos+4),len); hdr->ID.Hospital = malloc(len+1); if (hdr->ID.Hospital) { hdr->ID.Hospital[len] = 0; strncpy(hdr->ID.Hospital,(char*)Header2+pos+4,len); } } #if (BIOSIG_VERSION >= 10500) else if (tag==9) { hdr->SCP.Section7 = Header2+pos+4; hdr->SCP.Section7Length = len; } else if (tag==10) { hdr->SCP.Section8 = Header2+pos+4; hdr->SCP.Section8Length = len; } else if (tag==11) { hdr->SCP.Section9 = Header2+pos+4; hdr->SCP.Section9Length = len; } else if (tag==12) { hdr->SCP.Section10 = Header2+pos+4; hdr->SCP.Section10Length = len; } else if (tag==13) { hdr->SCP.Section11 = Header2+pos+4; hdr->SCP.Section11Length = len; } #endif /* further tags may include - Manufacturer: SCP, MFER, GDF1 - Orientation of MEG channels - Study ID - BCI: session, run */ pos+= 4+len; tag = (uint8_t)Header2[pos]; if (VERBOSE_LEVEL>8) fprintf(stdout,"GDFr3: next Tag=%i pos=%i\n",tag,(int)pos); } } // if (VERBOSE_LEVEL>8) fprintf(stdout,"[GDF 217] #=%li\n",iftell(hdr)); return(hdr->AS.B4C_ERRNUM); } /********************************************************************************* hdrEVT2rawEVT(HDRTYPE *hdr) converts structure HDR.EVENT into raw event data (hdr->AS.rawEventData) TODO: support of EVENT.TimeStamp *********************************************************************************/ size_t hdrEVT2rawEVT(HDRTYPE *hdr) { size_t k32u; char flag = (hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL) ? 3 : 1; if (flag==3) // any DUR or CHN is larger than 0 for (k32u=0, flag=1; k32u < hdr->EVENT.N; k32u++) if (hdr->EVENT.CHN[k32u] || hdr->EVENT.DUR[k32u]) { flag = 3; break; } #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp != NULL) { flag = flag | 0x04; } #endif int sze; sze = (flag & 2) ? 12 : 6; sze += (flag & 4) ? 8 : 0; size_t len = 8+hdr->EVENT.N*sze; hdr->AS.rawEventData = (uint8_t*) realloc(hdr->AS.rawEventData,len); uint8_t *buf = hdr->AS.rawEventData; buf[0] = flag; if (hdr->VERSION < 1.94) { k32u = lround(hdr->EVENT.SampleRate); buf[1] = k32u & 0x000000FF; buf[2] = (k32u>>8 ) & 0x000000FF; buf[3] = (k32u>>16) & 0x000000FF; leu32a(hdr->EVENT.N, buf+4); } else { k32u = hdr->EVENT.N; buf[1] = k32u & 0x000000FF; buf[2] = (k32u>>8 ) & 0x000000FF; buf[3] = (k32u>>16) & 0x000000FF; lef32a(hdr->EVENT.SampleRate, buf+4); }; uint8_t *buf1=hdr->AS.rawEventData+8; uint8_t *buf2=hdr->AS.rawEventData+8+hdr->EVENT.N*4; for (k32u=0; k32uEVENT.N; k32u++) { *(uint32_t*)(buf1+k32u*4) = htole32(hdr->EVENT.POS[k32u]+1); // convert from 0-based (biosig4c++) to 1-based (GDF) indexing *(uint16_t*)(buf2+k32u*2) = htole16(hdr->EVENT.TYP[k32u]); } if (flag & 2) { buf1 = hdr->AS.rawEventData+8+hdr->EVENT.N*6; buf2 = hdr->AS.rawEventData+8+hdr->EVENT.N*8; for (k32u=0; k32uEVENT.N; k32u++) { *(uint16_t*)(buf1+k32u*2) = htole16(hdr->EVENT.CHN[k32u]); *(uint32_t*)(buf2+k32u*4) = htole32(hdr->EVENT.DUR[k32u]); } } #if (BIOSIG_VERSION >= 10500) if (flag & 4) { buf1 = hdr->AS.rawEventData+8+hdr->EVENT.N*(sze-8); for (k32u=0; k32uEVENT.N; k32u++) { *(uint64_t*)(buf1+k32u*8) = htole64(hdr->EVENT.TimeStamp[k32u]); } } #endif return(len); } /********************************************************************************* rawEVT2hdrEVT(HDRTYPE *hdr) converts raw event data (hdr->AS.rawEventData) into structure HDR.EVENT TODO: support of EVENT.TimeStamp *********************************************************************************/ void rawEVT2hdrEVT(HDRTYPE *hdr, size_t length_rawEventData) { // TODO: avoid additional copying size_t k; uint8_t *buf = hdr->AS.rawEventData; if ((buf==NULL) || (length_rawEventData < 8)) { hdr->EVENT.N = 0; return; } if (hdr->VERSION < 1.94) { if (buf[1] | buf[2] | buf[3]) hdr->EVENT.SampleRate = buf[1] + (buf[2] + buf[3]*256.0)*256.0; else { fprintf(stdout,"Warning GDF v1: SampleRate in Eventtable is not set in %s !!!\n",hdr->FileName); hdr->EVENT.SampleRate = hdr->SampleRate; } hdr->EVENT.N = leu32p(buf + 4); } else { hdr->EVENT.N = buf[1] + (buf[2] + buf[3]*256)*256; hdr->EVENT.SampleRate = lef32p(buf + 4); } char flag = buf[0]; int sze = (flag & 2) ? 12 : 6; if (flag & 4) sze+=8; if (sze*hdr->EVENT.N+8 < length_rawEventData) { hdr->EVENT.N = 0; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error GDF: event table is corrupted"); return; } if (hdr->NS==0 && !isfinite(hdr->SampleRate)) hdr->SampleRate = hdr->EVENT.SampleRate; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP) ); uint8_t *buf1 = hdr->AS.rawEventData+8; uint8_t *buf2 = hdr->AS.rawEventData+8+4*hdr->EVENT.N; for (k=0; k < hdr->EVENT.N; k++) { // POS & TYP hdr->EVENT.POS[k] = leu32p(buf1 + k*4)-1; // convert from 1-based (GDF) to 0-based (biosig4c++) indexing hdr->EVENT.TYP[k] = leu16p(buf2 + k*2); } if (flag & 2) { // DUR & CHN hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR,hdr->EVENT.N*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN,hdr->EVENT.N*sizeof(*hdr->EVENT.CHN)); buf1 = hdr->AS.rawEventData+8+6*hdr->EVENT.N; buf2 = hdr->AS.rawEventData+8+8*hdr->EVENT.N; for (k=0; k < hdr->EVENT.N; k++) { hdr->EVENT.CHN[k] = leu16p(buf1 + k*2); hdr->EVENT.DUR[k] = leu32p(buf2 + k*4); } } else { hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; } #if (BIOSIG_VERSION >= 10500) if (flag & 4) { // TimeStamp hdr->EVENT.TimeStamp = (gdf_time*) realloc(hdr->EVENT.TimeStamp, hdr->EVENT.N*sizeof(*hdr->EVENT.TimeStamp)); buf1 = hdr->AS.rawEventData+8+hdr->EVENT.N*(sze-8); for (k=0; k < hdr->EVENT.N; k++) { hdr->EVENT.TimeStamp[k] = leu64p(buf1 + k*8); } } else { hdr->EVENT.TimeStamp = NULL; } #endif } int NumberOfChannels(HDRTYPE *hdr) { unsigned int k,NS; for (k=0, NS=0; kNS; k++) if (hdr->CHANNEL[k].OnOff==1) NS++; #ifdef CHOLMOD_H if (hdr->Calib == NULL) return (NS); if (NS == hdr->Calib->nrow) return (hdr->Calib->ncol); #endif return(hdr->NS); } int RerefCHANNEL(HDRTYPE *hdr, void *arg2, char Mode) { #ifndef CHOLMOD_H if (!arg2 || !Mode) return(0); // do nothing biosigERROR(hdr, B4C_REREF_FAILED, "Error RerefCHANNEL: cholmod library is missing"); return(1); #else if (arg2==NULL) Mode = 0; // do nothing cholmod_sparse *ReRef=NULL; uint16_t flag,NS; size_t i,j,k; long r; char flagLabelIsSet = 0; switch (Mode) { case 1: { HDRTYPE *RR = sopen((const char*)arg2,"r",NULL); ReRef = RR->Calib; if (RR->rerefCHANNEL != NULL) { flagLabelIsSet = 1; if (hdr->rerefCHANNEL) free(hdr->rerefCHANNEL); hdr->rerefCHANNEL = RR->rerefCHANNEL; RR->rerefCHANNEL = NULL; } RR->Calib = NULL; // do not destroy ReRef destructHDR(RR); RR = NULL; break; } case 2: ReRef = (cholmod_sparse*) arg2; CSstart(); break; } if ((ReRef==NULL) || !Mode) { // reset rereferencing if (hdr->Calib != NULL) cholmod_free_sparse(&hdr->Calib, &CHOLMOD_COMMON_VAR); hdr->Calib = ReRef; if (hdr->rerefCHANNEL) free(hdr->rerefCHANNEL); hdr->rerefCHANNEL = NULL; return(0); } cholmod_sparse *A = ReRef; // check dimensions for (k=0, NS=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) NS++; if (NS - A->nrow) { biosigERROR(hdr, B4C_REREF_FAILED, "Error REREF_CHAN: size of data does not fit ReRef-matrix"); return(1); } // allocate memory if (hdr->Calib != NULL) cholmod_free_sparse(&hdr->Calib, &CHOLMOD_COMMON_VAR); if (VERBOSE_LEVEL>8) { CHOLMOD_COMMON_VAR.print = 5; cholmod_print_sparse(ReRef,"HDR.Calib", &CHOLMOD_COMMON_VAR); } hdr->Calib = ReRef; if (hdr->rerefCHANNEL==NULL) hdr->rerefCHANNEL = (CHANNEL_TYPE*) realloc(hdr->rerefCHANNEL, A->ncol*sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *NEWCHANNEL = hdr->rerefCHANNEL; hdr->FLAG.ROW_BASED_CHANNELS = 1; // check each component for (i=0; incol; i++) // i .. column index { flag = 0; int mix = -1, oix = -1, pix = -1; double m = 0.0; double v; for (j = *((unsigned*)(A->p)+i); j < *((unsigned*)(A->p)+i+1); j++) { v = *(((double*)A->x)+j); r = *(((int*)A->i)+j); // r .. row index if (v>m) { m = v; mix = r; } if (v==1.0) { if (oix<0) oix = r; else fprintf(stderr,"Warning: ambiguous channel information (in new #%i,%i more than one scaling factor of 1.0 is used.) \n",(int)i,(int)j); } if (v) { if (pix == -1) { //memcpy(NEWCHANNEL+i, hdr->CHANNEL+r, sizeof(CHANNEL_TYPE)); NEWCHANNEL[i].PhysDimCode = hdr->CHANNEL[r].PhysDimCode; NEWCHANNEL[i].LowPass = hdr->CHANNEL[r].LowPass; NEWCHANNEL[i].HighPass = hdr->CHANNEL[r].HighPass; NEWCHANNEL[i].Notch = hdr->CHANNEL[r].Notch; NEWCHANNEL[i].SPR = hdr->CHANNEL[r].SPR; NEWCHANNEL[i].GDFTYP = hdr->CHANNEL[r].GDFTYP; NEWCHANNEL[i].Impedance = fabs(v)*hdr->CHANNEL[r].Impedance; NEWCHANNEL[i].OnOff = 1; NEWCHANNEL[i].LeadIdCode = 0; if (!flagLabelIsSet) memcpy(NEWCHANNEL[i].Label, hdr->CHANNEL[r].Label, MAX_LENGTH_LABEL); pix = 0; } else { if (NEWCHANNEL[i].PhysDimCode != hdr->CHANNEL[r].PhysDimCode) NEWCHANNEL[i].PhysDimCode = 0; if (NEWCHANNEL[i].LowPass != hdr->CHANNEL[r].LowPass) NEWCHANNEL[i].LowPass = NAN; if (NEWCHANNEL[i].HighPass != hdr->CHANNEL[r].HighPass) NEWCHANNEL[i].HighPass = NAN; if (NEWCHANNEL[i].Notch != hdr->CHANNEL[r].Notch) NEWCHANNEL[i].Notch = NAN; if (NEWCHANNEL[i].SPR != hdr->CHANNEL[r].SPR) NEWCHANNEL[i].SPR = lcm(NEWCHANNEL[i].SPR, hdr->CHANNEL[r].SPR); if (NEWCHANNEL[i].GDFTYP != hdr->CHANNEL[r].GDFTYP) NEWCHANNEL[i].GDFTYP = max(NEWCHANNEL[i].GDFTYP, hdr->CHANNEL[r].GDFTYP); NEWCHANNEL[i].Impedance += fabs(v)*NEWCHANNEL[r].Impedance; NEWCHANNEL[i].GDFTYP = 16; } } if (r >= hdr->NS) { flag = 1; fprintf(stderr,"Error: index (%i) in channel (%i) exceeds number of channels (%i)\n",(int)r,(int)i,hdr->NS); } } // heuristic to determine hdr->CHANNEL[k].Label; if (oix>-1) r=oix; // use the info from channel with a scaling of 1.0 ; else if (mix>-1) r=mix; // use the info from channel with the largest scale; else r = -1; if (flagLabelIsSet) ; else if (!flag && (rNS) && (r>=0)) { // if successful memcpy(NEWCHANNEL[i].Label, hdr->CHANNEL[r].Label, MAX_LENGTH_LABEL); } else { sprintf(NEWCHANNEL[i].Label,"component #%i",(int)i); } } return(0); #endif } /**************************************************************************** * READ_HEADER_1 * * ****************************************************************************/ int read_header(HDRTYPE *hdr) { /* input: hdr must be an open file able to read from hdr->TYPE must be unknown, otherwise no FileFormat evaluation is performed hdr->FILE.size output: defines whole header structure and event table return value: 0 no error -1 error reading header 1 -2 error reading header 2 -3 error reading event table */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %f\n",__func__,__LINE__, (int)hdr->FILE.size, (int)hdr->HeadLen, hdr->VERSION); size_t count = hdr->HeadLen; if (hdr->HeadLen<=512) { ifseek(hdr, count, SEEK_SET); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 513); count += ifread(hdr->AS.Header+hdr->HeadLen, 1, 512-count, hdr); getfiletype(hdr); } char tmp[6]; strncpy(tmp,(char*)hdr->AS.Header+3,5); tmp[5]=0; hdr->VERSION = atof(tmp); // currently, only GDF is supported if ( (hdr->TYPE != GDF) || (hdr->VERSION < 0.01) ) return ( -1 ); if (hdr->VERSION > 1.90) hdr->HeadLen = leu16p(hdr->AS.Header+184)<<8; else hdr->HeadLen = leu64p(hdr->AS.Header+184); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %f\n", __func__, __LINE__,(int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); if (count < hdr->HeadLen) { ifseek(hdr, count, SEEK_SET); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %f\n",__func__, __LINE__, (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); if (count < hdr->HeadLen) { if (VERBOSE_LEVEL>7) fprintf(stdout,"ambiguous GDF header size: %i %i\n",(int)count,hdr->HeadLen); biosigERROR(hdr, B4C_INCOMPLETE_FILE, "reading GDF header failed"); return(-2); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %f\n",__func__, __LINE__, (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); if ( gdfbin2struct(hdr) ) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %f\n",__func__, __LINE__, (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); return(-2); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %f\n",__func__, __LINE__, (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); hdr->EVENT.N = 0; hdr->EVENT.POS = NULL; hdr->EVENT.TYP = NULL; hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = NULL; #endif if (hdr->NRec < 0) { hdr->NRec = (hdr->FILE.size - hdr->HeadLen)/hdr->AS.bpb; if (hdr->AS.rawEventData!=NULL) { free(hdr->AS.rawEventData); hdr->AS.rawEventData=NULL; } } else if (hdr->FILE.size > hdr->HeadLen + hdr->AS.bpb*(size_t)hdr->NRec + 8) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"GDF EVENT: %i,%i %i,%i,%i\n",(int)hdr->FILE.size, (int)(hdr->HeadLen + hdr->AS.bpb*hdr->NRec + 8), hdr->HeadLen, hdr->AS.bpb, (int)hdr->NRec); ifseek(hdr, hdr->HeadLen + hdr->AS.bpb*hdr->NRec, SEEK_SET); // READ EVENTTABLE hdr->AS.rawEventData = (uint8_t*)realloc(hdr->AS.rawEventData,8); size_t c = ifread(hdr->AS.rawEventData, sizeof(uint8_t), 8, hdr); uint8_t *buf = hdr->AS.rawEventData; if (c<8) { hdr->EVENT.N = 0; } else if (hdr->VERSION < 1.94) { hdr->EVENT.N = leu32p(buf + 4); } else { hdr->EVENT.N = buf[1] + (buf[2] + buf[3]*256)*256; } if (VERBOSE_LEVEL > 7) fprintf(stdout,"EVENT.N = %i,%i\n",hdr->EVENT.N,(int)c); char flag = buf[0]; int sze = (flag & 2) ? 12 : 6; if (flag & 4) sze+=8; hdr->AS.rawEventData = (uint8_t*)realloc(hdr->AS.rawEventData,8+hdr->EVENT.N*sze); c = ifread(hdr->AS.rawEventData+8, sze, hdr->EVENT.N, hdr); ifseek(hdr, hdr->HeadLen, SEEK_SET); if (c < hdr->EVENT.N) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "reading GDF eventtable failed"); return(-3); } rawEVT2hdrEVT(hdr, 8+hdr->EVENT.N*sze); } else hdr->EVENT.N = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[228] FMT=%s Ver=%4.2f\n",GetFileTypeString(hdr->TYPE),hdr->VERSION); return (0); } /****************************************************************************/ /** SOPEN **/ /****************************************************************************/ HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): sopen(%s,%s)\n",__func__,__LINE__, FileName, MODE); return sopen_extended(FileName, MODE, hdr, NULL); } HDRTYPE* sopen_extended(const char* FileName, const char* MODE, HDRTYPE* hdr, biosig_options_type *biosig_options) { /* MODE="r" reads file and returns HDR MODE="w" writes HDR into file */ // unsigned int k2; // uint32_t k32u; size_t count; #ifndef ONLYGDF // double Dur; char* ptr_str; struct tm tm_time; // time_t tt; const char GENDER[] = "XMFX"; const uint16_t CFWB_GDFTYP[] = {17,16,3}; const float CNT_SETTINGS_NOTCH[] = {0.0, 50.0, 60.0}; const float CNT_SETTINGS_LOWPASS[] = {30, 40, 50, 70, 100, 200, 500, 1000, 1500, 2000, 2500, 3000}; const float CNT_SETTINGS_HIGHPASS[] = {NAN, 0, .05, .1, .15, .3, 1, 5, 10, 30, 100, 150, 300}; uint16_t BCI2000_StatusVectorLength=0; // specific for BCI2000 format #endif //ONLYGDF biosig_options_type default_options; default_options.free_text_event_limiter="\0"; if (biosig_options==NULL) biosig_options = &default_options; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(%s,%s) (line %d): --delimiter=<%s> %p\n",__func__, FileName, MODE, __LINE__, biosig_options->free_text_event_limiter, biosig_options); if (FileName == NULL) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "no filename specified"); return (hdr); } if (hdr==NULL) hdr = constructHDR(0,0); // initializes fields that may stay undefined during SOPEN if (FileName != NULL) { if (hdr->FileName) free(hdr->FileName); hdr->FileName = strdup(FileName); } if (VERBOSE_LEVEL>6) fprintf(stdout,"SOPEN( %s, %s) open=%i\n",FileName, MODE, hdr->FILE.OPEN); setlocale(LC_NUMERIC,"C"); // hdr->FLAG.SWAP = (__BYTE_ORDER == __BIG_ENDIAN); // default: most data formats are little endian hdr->FILE.LittleEndian = 1; if (!strncmp(MODE,"a",1)) { /***** SOPEN APPEND *****/ HDRTYPE *hdr2 = NULL; struct stat FileBuf; if (stat(FileName, &FileBuf)==0) hdr->FILE.size = FileBuf.st_size; else hdr->FILE.size = 0; if (hdr->FILE.size==0) { if (hdr->FILE.OPEN) ifclose(hdr); return( sopen(FileName, "w", hdr) ); } else if (hdr->FILE.size < 256) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(APPEND); file format not supported."); return (hdr); } else { // read header of existing file hdr2 = sopen(FileName, "r", hdr2); sclose(hdr2); }; if (hdr2->TYPE != GDF) { // currently only GDF is tested and supported biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(APPEND); file format not supported."); destructHDR(hdr2); return (hdr); } // test for additional restrictions if ( hdr2->EVENT.N > 0 && hdr2->FILE.COMPRESSION ) { // gzopen does not support "rb+" (simultaneous read/write) but can only append at the end of file biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(GDF APPEND); cannot append to compressed GDF file containing event table."); destructHDR(hdr2); return (hdr); } // use header of existing file, sopen does hdr=hdr2, and open files for writing. destructHDR(hdr); if (hdr2->FILE.COMPRESSION) hdr = ifopen(hdr2, "ab"); else { hdr = ifopen(hdr2, "rb+"); ifseek(hdr, hdr->HeadLen + hdr->NRec*hdr->AS.bpb, SEEK_SET); } if (!hdr->FILE.OPEN) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Error SOPEN(APPEND); Cannot open file."); return(hdr); } hdr->FILE.OPEN = 2; } else if (!strncmp(MODE,"r",1)) { /***** SOPEN READ *****/ #ifndef WITHOUT_NETWORK if (!memcmp(hdr->FileName,"bscs://",7)) { uint64_t ID; char *hostname = (char*)hdr->FileName+7; char *t = strrchr(hostname,'/'); if (t==NULL) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "SOPEN-NETWORK: file identifier not specifed"); return(hdr); } *t=0; cat64(t+1, &ID); int sd,s; sd = bscs_connect(hostname); if (sd<0) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "could not connect to server"); return(hdr); } hdr->FILE.Des = sd; s = bscs_open(sd, &ID); if (VERBOSE_LEVEL>7) fprintf(stdout,"%i = bscs_open\n",s); s = bscs_requ_hdr(sd,hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%i = bscs_requ_hdr\n",s); s = bscs_requ_evt(sd,hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%i = bscs_requ_evt\n",s); hdr->FILE.OPEN = 1; return(hdr); } #endif // modern cpu's have cache lines of 4096 bytes, so for performance reasons we use this size as well. const size_t PAGESIZE=4096; /* reading some formats may imply that at least 512 bytes are read, if you want to use a smaller page size, double check whether your format(s) are correctly handled. */ assert(PAGESIZE >= 512); hdr->AS.Header = (uint8_t*)malloc(PAGESIZE+1); size_t k; #ifndef ONLYGDF size_t name=0,ext=0; for (k=0; hdr->FileName[k]; k++) { if (hdr->FileName[k]==FILESEP) name = k+1; if (hdr->FileName[k]=='.') ext = k+1; } const char *FileExt = hdr->FileName+ext; const char *FileName = hdr->FileName+name; #endif //ONLYGDF #ifdef __CURL_CURL_H if (! strncmp(hdr->FileName,"file://", 7) || ! strncmp(hdr->FileName,"ftp://", 6) || ! strncmp(hdr->FileName,"http://", 7) || ! strncmp(hdr->FileName,"https://", 8) ) { CURL *curl; char errbuffer[CURL_ERROR_SIZE]; if ((curl = curl_easy_init()) != NULL) { FILE *tmpfid = tmpfile(); curl_easy_setopt(curl, CURLOPT_URL, hdr->FileName); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuffer); if (VERBOSE_LEVEL > 6) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_WRITEDATA, tmpfid); if (curl_easy_perform(curl) != CURLE_OK) { fprintf(stderr,"CURL ERROR: %s\n",errbuffer); biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Error SOPEN(READ); file download failed."); fclose(tmpfid); return(hdr); } /* associate temporary file with input stream channeling everything through zlib ensures that *.gz files are automatically decompressed According to http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.12.html#tmpfile, the tmpfile will be removed when stream is closed */ fseek(tmpfid,0,SEEK_SET); hdr->FILE.gzFID = gzdopen(fileno(tmpfid), "r"); hdr->FILE.COMPRESSION = 1; curl_easy_cleanup(curl); /* */ count = ifread(hdr->AS.Header, 1, PAGESIZE, hdr); hdr->AS.Header[count]=0; } } else #endif { if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN 101: <%s>\n",hdr->FileName); #ifndef ONLYGDF /* AINF */ if (!strcmp(FileExt, "ainf")) { if (VERBOSE_LEVEL>8) fprintf(stdout,"getfiletype ainf1 %s %i\n",hdr->FileName,(int)ext); char* AINF_RAW_FILENAME = (char*)calloc(strlen(hdr->FileName)+5,sizeof(char)); strncpy(AINF_RAW_FILENAME, hdr->FileName,ext); strcpy(AINF_RAW_FILENAME+ext, "raw"); FILE* fid1=fopen(AINF_RAW_FILENAME,"rb"); if (fid1) { fclose(fid1); hdr->TYPE = AINF; } free(AINF_RAW_FILENAME); } else if (!strcmp(FileExt, "raw")) { char* AINF_RAW_FILENAME = (char*)calloc(strlen(hdr->FileName)+5,sizeof(char)); strncpy(AINF_RAW_FILENAME, hdr->FileName,ext); strcpy(AINF_RAW_FILENAME+ext, "ainf"); FILE* fid1=fopen(AINF_RAW_FILENAME,"r"); if (fid1) { fclose(fid1); hdr->TYPE = AINF; } free(AINF_RAW_FILENAME); } #endif //ONLYGDF hdr->FILE.COMPRESSION = 0; hdr = ifopen(hdr,"rb"); if (!hdr->FILE.OPEN) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Error SOPEN(READ); Cannot open file."); return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN 101:\n"); count = ifread(hdr->AS.Header, 1, PAGESIZE, hdr); if (count<25) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): %s(...) count = %d\n",__FILE__,__LINE__,__func__,count); biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Error SOPEN(READ); file is empty (or too short)"); ifclose(hdr); return(hdr); } hdr->AS.Header[count]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) count=%i\n", __func__, __LINE__,(int)count); if (!memcmp(Header1,MAGIC_NUMBER_GZIP,strlen(MAGIC_NUMBER_GZIP))) { #ifdef ZLIB_H if (VERBOSE_LEVEL>7) fprintf(stdout,"[221] %i\n",(int)count); ifseek(hdr, 0, SEEK_SET); hdr->FILE.gzFID = gzdopen(fileno(hdr->FILE.FID),"r"); hdr->FILE.COMPRESSION = (uint8_t)1; hdr->FILE.FID = NULL; count = ifread(hdr->AS.Header, 1, PAGESIZE, hdr); hdr->AS.Header[count]=0; #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(READ); *.gz file not supported because not linked with zlib."); #endif } } if (VERBOSE_LEVEL>7) fprintf(stdout,"[222] %i\n",(int)count); hdr->HeadLen = count; getfiletype(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); #ifndef ONLYGDF if (hdr->TYPE != unknown) ; else if (!memcmp(Header1,FileName,strspn(FileName,".")) && (!strcmp(FileExt,"HEA") || !strcmp(FileExt,"hea") )) hdr->TYPE = MIT; else if (count < 512) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(READ): file is too short\n"); return(hdr); } #endif //ONLYGDF if (hdr->TYPE == unknown) { biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "ERROR BIOSIG4C++ SOPEN(read): Dataformat not known.\n"); ifclose(hdr); return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); count = iftell(hdr); hdr->AS.first = 0; hdr->AS.length = 0; hdr->AS.bpb = -1; // errorneous value: ensures that hdr->AS.bpb will be defined #ifndef WITHOUT_NETWORK if (!memcmp(hdr->AS.Header,"bscs://",7)) { hdr->AS.Header[count]=0; uint64_t ID; char *hostname = Header1+7; Header1[6]=0; char *t = strrchr(hostname,'/'); if (t==NULL) { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "SOPEN-NETWORK: file identifier not specifed"); return(hdr); } t[0]=0; cat64(t+1, &ID); int sd,s; sd = bscs_connect(hostname); if (sd<0) { fprintf(stderr,"could not connect to %s\n",hostname); biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "could not connect to server"); return(hdr); } hdr->FILE.Des = sd; s = bscs_open(sd, &ID); s = bscs_requ_hdr(sd,hdr); s = bscs_requ_evt(sd,hdr); hdr->FILE.OPEN = 1; return(hdr); } else #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); if (hdr->TYPE == GDF) { struct stat FileBuf; if (stat(hdr->FileName,&FileBuf)==0) hdr->FILE.size = FileBuf.st_size; if ( read_header(hdr) ) { return (hdr); } } #ifndef ONLYGDF else if ((hdr->TYPE == EDF) || (hdr->TYPE == BDF)) { if (count < 256) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "reading BDF/EDF fixed header failed"); return(hdr); } typeof(hdr->NS) StatusChannel = 0; int annotStartBi=-1; int annotEndBi=-1; int annotNumBytesPerBlock=0; int last = min(MAX_LENGTH_PID, 80); strncpy(hdr->Patient.Id, Header1+8, last); while ((0 <= last) && (isspace(hdr->Patient.Id[--last]))); hdr->Patient.Id[last+1]=0; last = min(MAX_LENGTH_RID, 80); memcpy(hdr->ID.Recording, Header1+88, last); while ((0 <= last) && (isspace(hdr->ID.Recording[--last]))); hdr->ID.Recording[last+1]=0; if (VERBOSE_LEVEL>8) fprintf(stdout,"[EDF 211] #=%li\nT0=<%16s>",iftell(hdr),Header1+168); // TODO: sanity check of T0 char tmp[81]; memset(tmp,0,9); strncpy(tmp,Header1+168+14,2); tm_time.tm_sec = atoi(tmp); strncpy(tmp,Header1+168+11,2); tm_time.tm_min = atoi(tmp); strncpy(tmp,Header1+168+8,2); tm_time.tm_hour = atoi(tmp); strncpy(tmp,Header1+168,2); tm_time.tm_mday = atoi(tmp); strncpy(tmp,Header1+168+3,2); tm_time.tm_mon = atoi(tmp)-1; strncpy(tmp,Header1+168+6,2); tm_time.tm_year = atoi(tmp); tm_time.tm_year+= (tm_time.tm_year < 70 ? 100 : 0); hdr->EVENT.N = 0; memset(tmp,0,9); hdr->NS = atoi(memcpy(tmp,Header1+252,4)); hdr->HeadLen = atoi(memcpy(tmp,Header1+184,8)); if (hdr->HeadLen < ((hdr->NS+1u)*256)) { biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "EDF/BDF corrupted: HDR.NS and HDR.HeadLen do not fit"); if (VERBOSE_LEVEL > 7) fprintf(stdout,"HeadLen=%i,%i\n",hdr->HeadLen ,(hdr->NS+1)<<8); }; hdr->NRec = atoi(strncpy(tmp,Header1+236,8)); //Dur = atof(strncpy(tmp,Header1+244,8)); if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211b] #=%li\nT0=%s\n",iftell(hdr),asctime(&tm_time)); if (!strncmp(Header1+192,"EDF+",4)) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211c+] <%s>\n",hdr->Patient.Id); strtok(hdr->Patient.Id," "); ptr_str = strtok(NULL," "); if (ptr_str!=NULL) { // define Id, Sex, Birthday, Name if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211c+] <%p>\n",ptr_str); hdr->Patient.Sex = (ptr_str[0]=='f')*2 + (ptr_str[0]=='F')*2 + (ptr_str[0]=='M') + (ptr_str[0]=='m'); ptr_str = strtok(NULL," "); // startdate char *tmpptr = strtok(NULL," "); if ((!hdr->FLAG.ANONYMOUS) && (tmpptr != NULL)) { strncpy(hdr->Patient.Name,tmpptr,MAX_LENGTH_NAME); hdr->Patient.Name[MAX_LENGTH_NAME]=0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211c] #=%li\n",iftell(hdr)); if (strlen(ptr_str)==11) { struct tm t1; char *strMDay=strtok(ptr_str,"-"); char *strMonth=strtok(NULL,"-"); char *strYear=strtok(NULL,"-"); for (k=0; strMonth[k]>0; ++k) strMonth[k]= toupper(strMonth[k]); // convert to uppper case t1.tm_mday = atoi(strMDay); t1.tm_mon = month_string2int(strMonth); t1.tm_year = atoi(strYear) - 1900; t1.tm_sec = 0; t1.tm_min = 0; t1.tm_hour = 12; t1.tm_isdst= -1; hdr->Patient.Birthday = tm_time2gdf_time(&t1); }} if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211d] <%s>\n",hdr->ID.Recording); if (!strncmp(Header1+88,"Startdate ",10)) { size_t pos = strcspn(Header1+88+10," ")+10; strncpy(hdr->ID.Recording, Header1+88+pos+1, 80-pos); hdr->ID.Recording[80-pos-1] = 0; if (strtok(hdr->ID.Recording," ")!=NULL) { char *tech = strtok(NULL," "); if (hdr->ID.Technician) free(hdr->ID.Technician); hdr->ID.Technician = (tech != NULL) ? strdup(tech) : NULL; hdr->ID.Manufacturer.Name = strtok(NULL," "); } Header1[167]=0; strtok(Header1+88," "); ptr_str = strtok(NULL," "); // check EDF+ Startdate against T0 if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211e-] <%s>\n",ptr_str); /* TODO: fix "Startdate X ..." */ if (strcmp(ptr_str,"X")) { int d,m,y; d = atoi(strtok(ptr_str,"-")); if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211e] <%s>\n",ptr_str); ptr_str = strtok(NULL,"-"); if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211f] <%s>\n",ptr_str); strcpy(tmp,ptr_str); for (k=0; k7) fprintf(stdout,"[EDF 211g] <%s>\n",tmp); y = atoi(strtok(NULL,"-")) - 1900; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211h] <%i>\n",tm_time.tm_year); if ((tm_time.tm_mday == d) && (tm_time.tm_mon == m)) { tm_time.tm_year = y; tm_time.tm_isdst= -1; } else { fprintf(stderr,"Error SOPEN(EDF+): recording dates do not match %i/%i <> %i/%i\n",d,m,tm_time.tm_mday,tm_time.tm_mon); } } } if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211z] #=%li\n",iftell(hdr)); } hdr->T0 = tm_time2gdf_time(&tm_time); // note: sub-second information will be extracted from first annotation if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 212] #=%li\n",iftell(hdr)); if (hdr->NS==0) return(hdr); hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->AS.Header = (uint8_t*) realloc(Header1,hdr->HeadLen); char *Header2 = (char*)hdr->AS.Header+256; if (hdr->HeadLen > count) count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); if (count < hdr->HeadLen) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "reading BDF/EDF variable header failed"); return(hdr); } /* identify buggy NeuroLoggerEDF export with bytes 236-257 EDF requires that the fields are left-justified, thus the first byte should be different than a space Therefore, the probability of a false positive detection is highly unlikely. */ char FLAG_BUGGY_NEUROLOGGER_EDF = !strncmp(Header1+236," 1 0 8 ",21) && Header1[0x180]==' ' && Header1[0x7c0]==' ' && Header1[0x400]==' ' && Header1[0x440]==' ' && Header1[0x480]==' ' && Header1[0x4c0]==' ' && Header1[0x500]==' '; if (FLAG_BUGGY_NEUROLOGGER_EDF) for (k=236; k<9*256; k++) Header1[k-1]=Header1[k]; char p[9]; hdr->AS.bpb = 0; size_t BitsPerBlock = 0; for (k=0, hdr->SPR = 1; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 213] #%i/%i\n",(int)k,hdr->NS); hc->LeadIdCode = 0; last = min(MAX_LENGTH_LABEL, 16); strncpy(hc->Label, Header2 + 16*k, last); while ((0 <= last) && (isspace(hc->Label[--last]))) ; hc->Label[last+1]=0; last = min(80,MAX_LENGTH_TRANSDUCER); strncpy(hc->Transducer, Header2+80*k+16*hdr->NS, last); while ((0 <= last) && (isspace(hc->Transducer[--last]))); hc->Transducer[last+1]=0; // PhysDim -> PhysDimCode last = 8; memcpy(p,Header2 + 8*k + 96*hdr->NS, last); while ((0 <= last) && (isspace(p[--last]))); p[last+1]=0; hc->PhysDimCode = PhysDimCode(p); tmp[8] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 215a] #%i/%i\n",(int)k,hdr->NS); hc->PhysMin = atof(strncpy(tmp,Header2 + 8*k + 104*hdr->NS,8)); hc->PhysMax = atof(strncpy(tmp,Header2 + 8*k + 112*hdr->NS,8)); hc->DigMin = atof(strncpy(tmp,Header2 + 8*k + 120*hdr->NS,8)); hc->DigMax = atof(strncpy(tmp,Header2 + 8*k + 128*hdr->NS,8)); if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 215b] #%i/%i\n",(int)k,hdr->NS); hc->Cal = (hc->PhysMax - hc->PhysMin) / (hc->DigMax-hc->DigMin); hc->Off = hc->PhysMin - hc->Cal*hc->DigMin; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 215c] #%i: NS=%i NRec=%i \n",(int)k,hdr->NS,(int)hdr->NRec); hc->LeadIdCode = 0; hc->SPR = atol(strncpy(tmp, Header2 + 8*k + 216*hdr->NS, 8)); hc->GDFTYP = ((hdr->TYPE != BDF) ? 3 : 255+24); hc->OnOff = 1; hc->bi = hdr->AS.bpb; hc->bi8 = BitsPerBlock; size_t nbits = GDFTYP_BITS[hc->GDFTYP]*(size_t)hc->SPR; BitsPerBlock += nbits; uint32_t nbytes = nbits>>3; hdr->AS.bpb += nbytes; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 216] #%i/%i/%i/%i/%i/%i\n",(int)k,hdr->NS,nbytes,hdr->AS.bpb,hc->SPR,hdr->SPR); hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->TOffset = NAN; hc->Impedance = NAN; // decode filter information into hdr->Filter.{Lowpass, Highpass, Notch} uint8_t kk; char PreFilt[81]; strncpy(PreFilt, Header2+ 80*k + 136*hdr->NS, 80); for (kk=0; kk<80; kk++) PreFilt[kk] = toupper(PreFilt[kk]); PreFilt[80] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"#%i# <%s>\n",(int)k,PreFilt); char *s1; s1 = strstr(PreFilt,"HP:"); if (s1) hc->HighPass = strtod(s1+3, &s1); s1 = strstr(PreFilt,"LP:"); if (s1) hc->LowPass = strtod(s1+3, &s1); s1 = strstr(PreFilt,"NOTCH:"); if (s1) hc->Notch = strtod(s1+6, &s1); if (VERBOSE_LEVEL>7) fprintf(stdout,"#%i# HP: %fHz LP:%fHz NOTCH=%f\n",(int)k,hc->HighPass,hc->LowPass,hc->Notch); if ((hdr->TYPE==EDF) && !strcmp(hc->Label,"EDF Annotations")) { hc->OnOff = 0; if (annotStartBi < 0) annotStartBi = hc->bi; annotEndBi = hdr->AS.bpb; annotNumBytesPerBlock += nbytes; } else if ((hdr->TYPE==BDF) && !strcmp(hc->Label,"BDF Annotations")) { hc->OnOff = 0; if (annotStartBi < 0) annotStartBi = hc->bi; annotEndBi = hdr->AS.bpb; annotNumBytesPerBlock += nbytes; } if ((hdr->TYPE==BDF) && !strcmp(hc->Label,"Status")) { hc->OnOff = 0; StatusChannel = k+1; } if (hc->OnOff) { // common sampling rate is based only on date channels but not annotation channels hdr->SPR = lcm(hdr->SPR, hc->SPR); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 219] #%i/%i/%i\n",(int)k,hdr->NS,hdr->SPR); } hdr->FLAG.OVERFLOWDETECTION = 0; // EDF does not support automated overflow and saturation detection double Dur = atof(strncpy(tmp,Header1+244,8)); if (Dur==0.0 && FLAG_BUGGY_NEUROLOGGER_EDF) Dur = hdr->SPR/496.0; hdr->SampleRate = hdr->SPR/Dur; if (VERBOSE_LEVEL>8) fprintf(stdout,"[EDF 220] #=%i SPR=%i Dur=%g\n",(int)iftell(hdr),(int)hdr->SPR, Dur); if (hdr->NRec <= 0) { struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->NRec = (FileBuf.st_size - hdr->HeadLen)/hdr->AS.bpb; } if (annotStartBi + annotNumBytesPerBlock - annotEndBi) fprintf(stdout, "WARNING: this file has multiple non-contigous blocks of EDF+/BDF+ annotations channels - annotation channels are not decoded"); else { /* read Annotation and Status channel and extract event information */ size_t bpb = annotNumBytesPerBlock; size_t len = bpb * hdr->NRec; uint8_t *Marker = (uint8_t*)malloc(len + 1); size_t skip = hdr->AS.bpb - bpb; ifseek(hdr, hdr->HeadLen + annotStartBi, SEEK_SET); nrec_t k3; for (k3=0; k3NRec; k3++) { ifread(Marker+k3*bpb, 1, bpb, hdr); ifseek(hdr, skip, SEEK_CUR); } Marker[hdr->NRec*bpb] = 20; // terminating marker size_t N_EVENT = 0; hdr->EVENT.SampleRate = hdr->SampleRate; /* convert EDF+/BDF+ annotation channel into event table */ char flag_subsec_isset = 0; for (k3 = 0; k3 < hdr->NRec; k3++) { double timeKeeping = 0; char *line = (char*)(Marker + k3 * bpb); char flag = !strncmp(Header1+193,"DF+D",4); // no time keeping for EDF+C while (line < (char*)(Marker + (k3+1) * bpb)) { // loop through all annotations within a segment if (VERBOSE_LEVEL>7) fprintf(stdout,"EDF+ line<%s>\n",line); char *next = strchr(line,0); // next points to end of annotation char *s1 = strtok(line,"\x14"); char *s2 = strtok(NULL,"\x14"); char *s3 = strtok(NULL,"\x14"); char *tstr = strtok(s1,"\x14\x15"); char *durstr = strtok(NULL,"\x14\x15"); if (tstr==NULL) { // TODO: check whether this is needed based on the EDF+ specs or whether it is an incorrect fprintf(stderr,"Warning EDF+ events: tstr not defined\n"); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): EDF+ line<%s>\n",__FILE__,__LINE__,line); break; } double t = atof(tstr); /* set sub-second start time: see also https://github.com/mne-tools/mne-python/pull/7875 https://www.edfplus.info/specs/edfplus.html#tal */ if ( !flag_subsec_isset && (s2==NULL) && (tstr[0]=='+' || tstr[0]=='-' ) ) { // first t contains subsecond information of starttime if (VERBOSE_LEVEL>7) fprintf(stdout,"T0=%20f + %f s\n",ldexp(hdr->T0,-32)*24*3600,t); hdr->T0 += ldexp(t / (24 * 3600.0), +32); if (VERBOSE_LEVEL>7) fprintf(stdout,"T0=%20f\n", ldexp(hdr->T0,-32) * 24 * 3600); } flag_subsec_isset = 1; if (flag>0 || s2!=NULL) { if (N_EVENT <= hdr->EVENT.N+1) { N_EVENT = reallocEventTable(hdr, max(6,hdr->EVENT.N*2)); if (N_EVENT == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } /* This is a workaround to read BDF data with large number of free text events containing meta information Free text is limited to the first occurence of limiter character, default is "\0" which does not remove anything */ s2 = strtok(s2, biosig_options->free_text_event_limiter); switch (flag) { case 0: // EDF+C FreeTextEvent(hdr, hdr->EVENT.N, s2); // set hdr->EVENT.TYP hdr->EVENT.POS[hdr->EVENT.N] = round(t * hdr->EVENT.SampleRate); break; case 1: // EDF+D: marker for beginning of segment hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; hdr->EVENT.POS[hdr->EVENT.N] = k3 * hdr->SPR; timeKeeping = t; flag = 2; break; default: // EDF+D: real annotation FreeTextEvent(hdr, hdr->EVENT.N, s2); // set hdr->EVENT.TYP hdr->EVENT.POS[hdr->EVENT.N] = k3 * hdr->SPR + round((t-timeKeeping) * hdr->EVENT.SampleRate); break; } #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = hdr->T0 + ldexp(t/(24*3600),32); #endif hdr->EVENT.DUR[hdr->EVENT.N] = durstr ? (atof(durstr)*hdr->EVENT.SampleRate) : 0; hdr->EVENT.CHN[hdr->EVENT.N] = 0; hdr->EVENT.N++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"EDF+ event\n\ts1:\t<%s>\n\ts2:\t<%s>\n\ts3:\t<%s>\n\tsdelay:\t<%s>\n\tdur:\t<%s>\n\t\n",s1,s2,s3,tstr,durstr); for (line=next; *line==0; line++) {}; // skip \0's and set line to start of next annotation } } hdr->AS.auxBUF = Marker; // contains EVENT.CodeDesc strings } /* End reading if Annotation channel */ if (StatusChannel) { /* read Status channel and extract event information */ CHANNEL_TYPE *hc = hdr->CHANNEL+StatusChannel-1; size_t sz = GDFTYP_BITS[hc->GDFTYP]>>3; size_t len = hc->SPR * hdr->NRec * sz; uint8_t *Marker = (uint8_t*)malloc(len + 1); size_t skip = hdr->AS.bpb - hc->SPR * sz; ifseek(hdr, hdr->HeadLen + hc->bi, SEEK_SET); nrec_t k3; for (k3=0; k3NRec; k3++) { ifread(Marker+k3*hc->SPR * sz, 1, hc->SPR * sz, hdr); ifseek(hdr, skip, SEEK_CUR); } size_t N_EVENT = 0; hdr->EVENT.SampleRate = hdr->SampleRate; /* convert BDF status channel into event table*/ uint32_t d1, d0; for (d0=0, k=0; k < len/3; d0 = d1, k++) { d1 = ((uint32_t)Marker[3*k+2]<<16) + ((uint32_t)Marker[3*k+1]<<8) + (uint32_t)Marker[3*k]; /* count raising edges */ if (d1 & 0x010000) d1 = 0; else d1 &= 0x00ffff; if (d0 < d1) ++N_EVENT; /* raising and falling edges if ((d1 & 0x010000) != (d0 & 0x010000)) ++N_EVENT; if ((d1 & 0x00ffff) != (d0 & 0x00ffff)) ++N_EVENT; */ } hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, (hdr->EVENT.N + N_EVENT) * sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, (hdr->EVENT.N + N_EVENT) * sizeof(*hdr->EVENT.TYP)); if (hdr->EVENT.POS==NULL || hdr->EVENT.TYP==NULL) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); } for (d0=0, k=0; k < len/3; d0=d1, k++) { d1 = ((uint32_t)Marker[3*k+2]<<16) + ((uint32_t)Marker[3*k+1]<<8) + (uint32_t)Marker[3*k]; /* raising edges */ if (d1 & 0x010000) d1 = 0; else d1 &= 0x00ffff; if (d0 < d1) { hdr->EVENT.POS[hdr->EVENT.N] = k; // 0-based indexing hdr->EVENT.TYP[hdr->EVENT.N] = d1; ++hdr->EVENT.N; } /* raising and falling edges if ((d1 & 0x010000) != (d0 & 0x010000)) { hdr->EVENT.POS[hdr->EVENT.N] = k; // 0-based indexing hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; ++hdr->EVENT.N; } if ((d1 & 0x00ffff) != (d0 & 0x00ffff)) { hdr->EVENT.POS[hdr->EVENT.N] = k; // 0-based indexing uint16_t d2 = d1 & 0x00ffff; if (!d2) d2 = (uint16_t)(d0 & 0x00ffff) | 0x8000; hdr->EVENT.TYP[hdr->EVENT.N] = d2; ++hdr->EVENT.N; if (d2==0x7ffe) fprintf(stdout,"Warning: BDF file %s uses ambiguous code 0x7ffe; For details see file eventcodes.txt. \n",hdr->FileName); } */ } free(Marker); } /* End reading BDF Status channel */ ifseek(hdr, hdr->HeadLen, SEEK_SET); } else if (hdr->TYPE==ABF) { hdr->HeadLen = count; sopen_abf_read(hdr); } else if (hdr->TYPE==ABF2) { hdr->HeadLen = count; sopen_abf2_read(hdr); } else if (hdr->TYPE==ATF) { // READ ATF hdr->HeadLen = count; hdr->VERSION = atof((char*)(hdr->AS.Header+4)); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); if (hdr->FILE.COMPRESSION) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "compressed ATF file format not supported"); return hdr; } sopen_atf_read(hdr); } else if (hdr->TYPE==ACQ) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: try loading ACQ header \n", __FILE__, __LINE__, __func__); if ( !hdr->FILE.LittleEndian ) { hdr->NS = bei16p(hdr->AS.Header + 10); hdr->HeadLen += hdr->NS*1714; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s (..): v%g noChan=%u HeadLen=%u\n", \ __FILE__, __LINE__, __func__, hdr->VERSION, hdr->NS, hdr->HeadLen); biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "BigEndian ACQ file format is currently not supported"); return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s \n", __FILE__, __LINE__, __func__); /* defined in http://biopac.com/AppNotes/app156FileFormat/FileFormat.htm */ hdr->NS = lei16p(hdr->AS.Header+10); hdr->SampleRate = 1000.0/lef64p(hdr->AS.Header+16); hdr->NRec = 1; hdr->SPR = 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s \n", __FILE__, __LINE__, __func__); // add "per channel data section" if (hdr->VERSION<38.0) // Version 3.0+ hdr->HeadLen += hdr->NS*122; else if (hdr->VERSION<39.0) // Version 3.7.0+ hdr->HeadLen += hdr->NS*252; else if (hdr->VERSION<42.0) // Version 3.7.3+ hdr->HeadLen += hdr->NS*254; else if (hdr->VERSION<43.0) // Version 3.7.3+ hdr->HeadLen += hdr->NS*256; else // Version 3.8.2+ hdr->HeadLen += hdr->NS*262; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s \n", __FILE__, __LINE__, __func__); hdr->HeadLen += 4; // read header up to nLenght and nID of foreign data section hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, hdr->HeadLen); if (hdr->HeadLen > count) count += ifread(Header1+count, 1, hdr->HeadLen-count, hdr); uint32_t POS = hdr->HeadLen; // read "foreign data section" and "per channel data types section" hdr->HeadLen += leu16p(hdr->AS.Header + hdr->HeadLen-4) - 4; // read "foreign data section" and "per channel data types section" hdr->HeadLen += 4*hdr->NS; hdr->AS.Header = (uint8_t*)realloc(Header1, hdr->HeadLen+8); if (hdr->HeadLen > POS) count += ifread(Header1+POS, 1, hdr->HeadLen-POS, hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s %i/%i %i/%i %i/%i %i/%i %i/%i \n", \ __FILE__, __LINE__, __func__, \ leu16p(hdr->AS.Header+hdr->HeadLen-20), leu16p(hdr->AS.Header+hdr->HeadLen-18), \ leu16p(hdr->AS.Header+hdr->HeadLen-16), leu16p(hdr->AS.Header+hdr->HeadLen-14), \ leu16p(hdr->AS.Header+hdr->HeadLen-12), leu16p(hdr->AS.Header+hdr->HeadLen-10), \ leu16p(hdr->AS.Header+hdr->HeadLen-8), leu16p(hdr->AS.Header+hdr->HeadLen-6), \ leu16p(hdr->AS.Header+hdr->HeadLen-4), leu16p(hdr->AS.Header+hdr->HeadLen-2) \ ); // define channel specific header information hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); uint32_t* ACQ_NoSamples = (uint32_t*) calloc(hdr->NS, sizeof(uint32_t)); //uint16_t CHAN; POS = leu32p(hdr->AS.Header+6); size_t minBufLenXVarDiv = -1; // maximum integer value for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; uint8_t* Header2 = hdr->AS.Header+POS; hc->LeadIdCode = 0; hc->Transducer[0] = '\0'; //CHAN = leu16p(Header2+4); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: #%i %i %i %i %i\n", \ __FILE__, __LINE__, __func__, (int)k, (int)leu32p(Header2), (int)leu16p(Header2+4), (int)leu32p(Header2+88), (int)leu16p(Header2+250)); int len=min(MAX_LENGTH_LABEL,40); strncpy(hc->Label,(char*)Header2+6,len); hc->Label[len]=0; char tmp[21]; strncpy(tmp,(char*)Header2+68,20); tmp[20]=0; /* ACQ uses none-standard way of encoding physical units Convert to ISO/IEEE 11073-10101 */ if (!strcmp(tmp,"Volts")) hc->PhysDimCode = 4256; else if (!strcmp(tmp,"Seconds")) hc->PhysDimCode = 2176; else if (!strcmp(tmp,"deg C")) hc->PhysDimCode = 6048; else if (!strcmp(tmp,"microsiemen")) hc->PhysDimCode = 8307; else hc->PhysDimCode = PhysDimCode(tmp); hc->Off = lef64p(Header2+52); hc->Cal = lef64p(Header2+60); hc->OnOff = 1; hc->SPR = 1; if (hdr->VERSION >= 38.0) { hc->SPR = leu16p(Header2+250); // used here as Divider if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: %i:%i\n", __FILE__, __LINE__, __func__, (int)hdr->SPR, (int)hc->SPR); if (hc->SPR > 1) hdr->SPR = lcm(hdr->SPR, hc->SPR); else hc->SPR = 1; } ACQ_NoSamples[k] = leu32p(Header2+88); size_t tmp64 = leu32p(Header2+88) * hc->SPR; if (minBufLenXVarDiv > tmp64) minBufLenXVarDiv = tmp64; POS += leu32p((uint8_t*)Header2); } hdr->NRec = minBufLenXVarDiv; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i\n", __FILE__, __LINE__, __func__, POS); /// foreign data section - skip POS += leu16p(hdr->AS.Header+POS); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); if (POS+2 > count) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, POS+2); count += ifread(Header1+count, 1, POS+2-count, hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i\n", __FILE__, __LINE__, __func__, POS); size_t DataLen=0; for (k=0, hdr->AS.bpb=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if ((hdr->VERSION>=38.0) && (hc->SPR > 1)) hc->SPR = hdr->SPR/hc->SPR; // convert DIVIDER into SPR uint16_t u16 = leu16p(hdr->AS.Header+POS+2); switch (u16) { case 1: hc->GDFTYP = 17; // double DataLen += ACQ_NoSamples[k]<<3; hc->DigMax = 1e9; hc->DigMin = -1e9; break; case 2: hc->GDFTYP = 3; // int DataLen += ACQ_NoSamples[k]<<1; hc->DigMax = 32767; hc->DigMin = -32678; break; default: if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: #%i type=%i \n", __FILE__, __LINE__, __func__, (int)k, (int)u16); biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "SOPEN(ACQ-READ): invalid channel type."); }; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->bi = hdr->AS.bpb; hdr->AS.bpb += (GDFTYP_BITS[hc->GDFTYP]*hc->SPR)>>3; POS +=4; } free(ACQ_NoSamples); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); /// Markers header section - skip POS += leu16p(hdr->AS.Header+POS); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); if (POS+2 > count) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, POS+2); count += ifread(Header1+count, 1, POS+2-count, hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); /// Markers header section - skip POS += leu16p(hdr->AS.Header+POS); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); if (POS+2 > count) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i,%i\n", __FILE__, __LINE__, __func__, (int)POS, (int)count); hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, POS+2); count += ifread(Header1+count, 1, POS+2-count, hdr); } // hdr->HeadLen = count + 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s: POS=%i HeadLen=%i\n", __FILE__, __LINE__, __func__, POS, (int)hdr->HeadLen); /* ### FIXME ### reading Marker section POS = hdr->HeadLen; #ifdef ZLIB_H gzseek(hdr->FILE.FID, hdr->HeadLen+DataLen, SEEK_SET); // start of markers header section count = gzread(hdr->FILE.FID, Header1+POS, 8); #else fseek(hdr->FILE.FID, hdr->HeadLen+DataLen, SEEK_SET); // start of markers header section count = fread(Header1+POS, 1, 8, hdr->FILE.FID); #endif size_t LengthMarkerItemSection = (leu32p(Header1+POS)); hdr->EVENT.N = (leu32p(Header1+POS+4)); Header1 = (char*)realloc(Header1,hdr->HeadLen+8+LengthMarkerItemSection); POS += 8; #ifdef ZLIB_H count = gzread(hdr->FILE.FID, Header1+POS, LengthMarkerItemSection); #else count = fread(Header1+POS, 1, LengthMarkerItemSection, hdr->FILE.FID); #endif hdr->EVENT.TYP = (uint16_t*)calloc(hdr->EVENT.N,2); hdr->EVENT.POS = (uint32_t*)calloc(hdr->EVENT.N,4); for (k=0; kEVENT.N; k++) { fprintf(stdout,"ACQ EVENT: %i POS: %i\n",k,POS); hdr->EVENT.POS[k] = leu32p(Header1+POS); POS += 12 + leu16p(Header1+POS+10); } */ ifseek(hdr, hdr->HeadLen, SEEK_SET); } else if (hdr->TYPE==AINF) { ifclose(hdr); char *filename = hdr->FileName; // keep input file name char* tmpfile = (char*)calloc(strlen(hdr->FileName)+5,1); strcpy(tmpfile, hdr->FileName); // Flawfinder: ignore char* ext = strrchr(tmpfile,'.')+1; /* open and read header file */ strcpy(ext,"ainf"); hdr->FileName = tmpfile; hdr = ifopen(hdr,"rb"); count = 0; while (!ifeof(hdr)) { size_t bufsiz = max(2*count, PAGESIZE); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); char *t1= NULL; char *t = strtok((char*)hdr->AS.Header,"\xA\xD"); while ((t) && !strncmp(t,"#",1)) { char* p; if ((p = strstr(t,"sfreq ="))) t1 = p; t = strtok(NULL,"\xA\xD"); } hdr->SampleRate = atof(strtok(t1+7," ")); hdr->SPR = 1; hdr->NS = 0; hdr->AS.bpb = 4; while (t) { int chno1=-1, chno2=-1; double f1,f2; char *label = NULL; #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L sscanf(t,"%d %as %d %lf %lf",&chno1,&label,&chno2,&f1,&f2); #else sscanf(t,"%d %ms %d %lf %lf",&chno1,&label,&chno2,&f1,&f2); #endif k = hdr->NS++; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *hc = hdr->CHANNEL+k; snprintf(hc->Label, MAX_LENGTH_LABEL+1, "%s %03i",label, chno2); hc->Transducer[0] = 0; hc->LeadIdCode = 0; hc->SPR = 1; hc->Cal = f1*f2; hc->Off = 0.0; hc->OnOff = 1; hc->GDFTYP = 3; hc->DigMax = 32767; hc->DigMin = -32678; hc->PhysMax= hc->DigMax * hc->Cal + hc->Off; hc->PhysMin= hc->DigMin * hc->Cal + hc->Off; hc->bi = hdr->AS.bpb; hdr->AS.bpb += 2; if (strcmp(label,"MEG")==0) hc->PhysDimCode = 1446; // "T/m" else hc->PhysDimCode = 4256; // "V" if (label) free(label); t = strtok(NULL,"\x0a\x0d"); } /* open data file */ strcpy(ext,"raw"); struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr = ifopen(hdr,"rb"); hdr->NRec = FileBuf.st_size/hdr->AS.bpb; hdr->HeadLen = 0; // hdr->FLAG.SWAP = (__BYTE_ORDER == __LITTLE_ENDIAN); // AINF is big endian hdr->FILE.LittleEndian = 0; /* restore input file name, and free temporary file name */ hdr->FileName = filename; free(tmpfile); } else if (hdr->TYPE==alpha) { ifclose(hdr); // close already opened file (typically its .../alpha.alp) sopen_alpha_read(hdr); } else if (hdr->TYPE==AXG) { sopen_axg_read(hdr); } else if (hdr->TYPE==Axona) { fprintf(stdout, "Axona: alpha version. \n"); hdr->AS.bpb = 12 + 20 + 2 * 192 + 16; hdr->NS = 4 + 64; hdr->SPR = 3; hdr->SampleRate = 24e3; struct stat FileBuf; if (stat(hdr->FileName, &FileBuf)==0) hdr->FILE.size = FileBuf.st_size; hdr->NRec = hdr->FILE.size / hdr->AS.bpb; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *hc; for (k = 0; k < hdr->NS; k++) { hc = hdr->CHANNEL + k; // hc->PhysDimCode = 4256; // "V" hc->PhysDimCode = 0; hc->Transducer[0] = 0; hc->LeadIdCode = 0; hc->SPR = hdr->SPR; hc->Cal = 1.0; hc->Off = 0.0; hc->OnOff = 1; hc->LeadIdCode = 0; hc->Notch = NAN; hc->LowPass = NAN; hc->HighPass = NAN; } for (k = 0; k+4 < hdr->NS; k++) { hc = hdr->CHANNEL + k + 4; sprintf(hc->Label, "#%02i", (int)k+1); hc->PhysDimCode = 4256; // "V" hc->PhysDimCode = 4274; // "mV" hc->PhysDimCode = 4275; // "uV" hc->GDFTYP = 3; hc->DigMax = 32767; hc->DigMin = -32678; hc->bi = 32 + 2*k; } hc = hdr->CHANNEL; strcpy(hc->Label, "PacketNumber"); hc->SPR = 1; hc->GDFTYP = 6; // uint32 hc->DigMin = 0.0; hc->DigMax = ldexp(1.0, 32) - 1.0; hc->bi = 4; hc = hdr->CHANNEL + 1; strcpy(hc->Label, "Digital I/O"); hc->SPR = 1; hc->GDFTYP = 6; // uint32 hc->DigMin = 0.0; hc->DigMax = ldexp(1.0, 32) - 1.0; hc->bi = 8; hc = hdr->CHANNEL + 2; strcpy(hc->Label, "FunKey"); hc->SPR = 1; hc->GDFTYP = 2; // uint8 hc->DigMin = 0.0; hc->DigMax = 255.0; hc->bi = 416; hc = hdr->CHANNEL + 3; strcpy(hc->Label, "Key Code"); hc->SPR = 1; hc->GDFTYP = 2; // uint8 hc->DigMin = 0.0; hc->DigMax = 255.0; hc->bi = 417; for (k = 0; k < hdr->NS; k++) { hc = hdr->CHANNEL + k; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; } hdr->HeadLen = 0; ifseek(hdr, 0, SEEK_SET); HDRTYPE H1; H1.FILE.COMPRESSION = 1; // try always with zlib, libz reverts to no compression anyway. H1.FileName = malloc(strlen(hdr->FileName)+5); strcpy(H1.FileName, hdr->FileName); // Flawfinder: ignore char *e = strrchr(H1.FileName,'.'); if (e==NULL) e = H1.FileName+strlen(H1.FileName); strcpy(e,".set"); ifopen(&H1, "r"); unsigned MaxLineLen = 1000; char *line = malloc(MaxLineLen); double PhysMax = NAN; //char* ifgets(char *str, int n, HDRTYPE* hdr) { while (!ifeof(&H1)) { ifgets(line, MaxLineLen, &H1); if (MaxLineLen <= strlen(line)) { fprintf(stderr,"Warning (Axona): line ## in file <%s> exceeds maximum length\n",H1.FileName); } char *tag = strtok(line," \t\n\r"); char *val = strtok(NULL,"\n\r"); if (tag==NULL || val==NULL) ; else if (!strcmp(tag,"trial date")) ; else if (!strcmp(tag,"trial time")) ; else if (!strcmp(tag,"experimenter")) hdr->ID.Technician = strdup(val); else if (!strcmp(tag,"sw_version")) ; else if (!strcmp(tag,"ADC_fullscale_mv")) { char *e; PhysMax = strtod(val, &e); if (e==NULL) continue; // ignore value because its invalid } else if (!strncmp(tag,"gain_ch_",4)) { char *e; size_t ch = strtol(tag+8, &e, 10); if (e==NULL || ch >= hdr->NS) continue; // ignore value because its invalid double Cal = strtod(val, &e); if (e==NULL) continue; // ignore value because its invalid hdr->CHANNEL[ch].Cal = 1.0/Cal; hdr->CHANNEL[ch].Off = 0.0; hdr->CHANNEL[ch].PhysMax = +PhysMax; hdr->CHANNEL[ch].PhysMin = -PhysMax; hdr->CHANNEL[ch].DigMax = +PhysMax/Cal; hdr->CHANNEL[ch].DigMin = -PhysMax/Cal; } else if (!strcmp(tag,"rawRate")) { char *e; double fs = strtod(val, &e); if (e==NULL) continue; // ignore value because its invalid hdr->SampleRate = fs; } else if (!strcmp(tag,"")) { ; } } free(line); ifclose(&H1); free(H1.FileName); } else if ((hdr->TYPE==ASCII) || (hdr->TYPE==BIN)) { while (!ifeof(hdr)) { size_t bufsiz = 65536; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count+bufsiz+1); count += ifread(hdr->AS.Header+count,1,bufsiz,hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); hdr->NS = 0; hdr->NRec = 1; hdr->SPR = 1; hdr->AS.bpb = 0; double Fs = 1.0; size_t N = 0; char status = 0; char *val = NULL; const char sep[] = " =\x09"; double duration = 0; size_t lengthRawData = 0; uint8_t FLAG_NUMBER_OF_FIELDS_READ; // used to trigger consolidation of channel info CHANNEL_TYPE *cp = NULL; char *datfile = NULL; uint16_t gdftyp = 0; char *line = strtok((char*)hdr->AS.Header,"\x0a\x0d"); while (line!=NULL) { if (VERBOSE_LEVEL>7) fprintf(stdout,"ASCII read line [%i]: <%s>\n",status,line); if (!strncmp(line,"[Header 1]",10)) status = 1; else if (!strncmp(line,"[Header 2]",10)) { status = 2; hdr->NS = 0; FLAG_NUMBER_OF_FIELDS_READ=0; } else if (!strncmp(line,"[EVENT TABLE]",13)) { status = 3; hdr->EVENT.SampleRate = hdr->SampleRate; N = 0; } val = strchr(line,'='); if ((val != NULL) && (status<3)) { val += strspn(val,sep); size_t c; c = strspn(val,"#"); if (c) val[c] = 0; // remove comments c = strcspn(line,sep); if (c) line[c] = 0; // deblank FLAG_NUMBER_OF_FIELDS_READ++; } if (VERBOSE_LEVEL>8) fprintf(stdout,"BIN <%s>=<%s> \n",line,val); if (status==1) { if (!strcmp(line,"Duration")) duration = atof(val); //else if (!strncmp(line,"NumberOfChannels")) else if (!strcmp(line,"Patient.Id")) strncpy(hdr->Patient.Id,val,MAX_LENGTH_PID); else if (!strcmp(line,"Patient.Birthday")) { struct tm t; sscanf(val,"%04i-%02i-%02i %02i:%02i:%02i",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec); t.tm_year -=1900; t.tm_mon--; t.tm_isdst = -1; hdr->Patient.Birthday = tm_time2gdf_time(&t); } else if (!strcmp(line,"Patient.Weight")) hdr->Patient.Weight = atoi(val); else if (!strcmp(line,"Patient.Height")) hdr->Patient.Height = atoi(val); else if (!strcmp(line,"Patient.Gender")) hdr->Patient.Sex = atoi(val); else if (!strcmp(line,"Patient.Handedness")) hdr->Patient.Handedness = atoi(val); else if (!strcmp(line,"Patient.Smoking")) hdr->Patient.Smoking = atoi(val); else if (!strcmp(line,"Patient.AlcoholAbuse")) hdr->Patient.AlcoholAbuse = atoi(val); else if (!strcmp(line,"Patient.DrugAbuse")) hdr->Patient.DrugAbuse = atoi(val); else if (!strcmp(line,"Patient.Medication")) hdr->Patient.Medication = atoi(val); else if (!strcmp(line,"Recording.ID")) strncpy(hdr->ID.Recording,val,MAX_LENGTH_RID); else if (!strcmp(line,"Recording.Time")) { struct tm t; sscanf(val,"%04i-%02i-%02i %02i:%02i:%02i",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec); t.tm_year -= 1900; t.tm_mon--; t.tm_isdst = -1; hdr->T0 = tm_time2gdf_time(&t); } else if (!strcmp(line,"Timezone")) { int m; if (sscanf(val,"%i min", &m) > 0) hdr->tzmin = m; } else if (!strcmp(line,"Recording.IPaddress")) { #ifndef WITHOUT_NETWORK #ifdef _WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(1,1), &wsadata); #endif biosig_set_hdr_ipaddr(hdr, val); #ifdef _WIN32 WSACleanup(); #endif #endif // not WITHOUT_NETWORK } else if (!strcmp(line,"Recording.Technician")) { if (hdr->ID.Technician) free(hdr->ID.Technician); hdr->ID.Technician = strdup(val); } else if (!strcmp(line,"Manufacturer.Name")) hdr->ID.Manufacturer.Name = val; else if (!strcmp(line,"Manufacturer.Model")) hdr->ID.Manufacturer.Model = val; else if (!strcmp(line,"Manufacturer.Version")) hdr->ID.Manufacturer.Version = val; else if (!strcmp(line,"Manufacturer.SerialNumber")) hdr->ID.Manufacturer.SerialNumber = val; } else if (status==2) { if (!strcmp(line,"Filename")) { // add next channel ++hdr->NS; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); cp = hdr->CHANNEL+hdr->NS-1; cp->Transducer[0] = 0; cp->bi = hdr->AS.bpb; cp->PhysDimCode = 0; cp->HighPass = NAN; cp->LowPass = NAN; cp->Notch = NAN; cp->Impedance= NAN; cp->fZ = NAN; cp->LeadIdCode = 0; datfile = val; FLAG_NUMBER_OF_FIELDS_READ = 1; } else if (!strcmp(line,"Label")) strncpy(cp->Label,val,MAX_LENGTH_LABEL); else if (!strcmp(line,"GDFTYP")) { if (!strcmp(val,"int8")) gdftyp = 1; else if (!strcmp(val,"uint8")) gdftyp = 2; else if (!strcmp(val,"int16")) gdftyp = 3; else if (!strcmp(val,"uint16")) gdftyp = 4; else if (!strcmp(val,"int32")) gdftyp = 5; else if (!strcmp(val,"uint32")) gdftyp = 6; else if (!strcmp(val,"int64")) gdftyp = 7; else if (!strcmp(val,"uint64")) gdftyp = 8; else if (!strcmp(val,"float32")) gdftyp = 16; else if (!strcmp(val,"float64")) gdftyp = 17; else if (!strcmp(val,"float128")) gdftyp = 18; else if (!strcmp(val,"ascii")) gdftyp = 0xfffe; else gdftyp = atoi(val); } else if (!strcmp(line,"PhysicalUnits")) cp->PhysDimCode = PhysDimCode(val); else if (!strcmp(line,"PhysDimCode")) { // If PhysicalUnits and PhysDimCode conflict, PhysicalUnits gets the preference if (!cp->PhysDimCode) cp->PhysDimCode = atoi(val); } else if (!strcmp(line,"Transducer")) strncpy(cp->Transducer,val,MAX_LENGTH_TRANSDUCER); else if (!strcmp(line,"SamplingRate")) Fs = atof(val); else if (!strcmp(line,"NumberOfSamples")) { cp->SPR = atol(val); if (cp->SPR>0) hdr->SPR = lcm(hdr->SPR,cp->SPR); if ((gdftyp>0) && (gdftyp<256)) { cp->GDFTYP = gdftyp; FILE *fid = fopen(datfile,"rb"); if (fid != NULL) { size_t bufsiz = (size_t)cp->SPR*GDFTYP_BITS[cp->GDFTYP]>>3; hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata,lengthRawData+bufsiz+1); count = fread(hdr->AS.rawdata+lengthRawData,1,bufsiz+1,fid); if (count != bufsiz) fprintf(stderr,"Warning SOPEN(BIN) #%i: mismatch between sample number and file size (%i,%i)\n",hdr->NS-1,(int)count,(int)bufsiz); lengthRawData += bufsiz; fclose(fid); } else if (cp->SPR > 0) { cp->SPR = 0; fprintf(stderr,"Warning SOPEN(BIN) #%i: data file (%s) not found\n",hdr->NS,datfile); } } else if (gdftyp==0xfffe) { cp->GDFTYP = 17; // double struct stat FileBuf; stat(datfile, &FileBuf); FILE *fid = fopen(datfile,"rb"); if (fid != NULL) { char *buf = (char*)malloc(FileBuf.st_size+1); count = fread(buf, 1, FileBuf.st_size, fid); fclose(fid); buf[count] = 0; size_t sz = GDFTYP_BITS[cp->GDFTYP]>>3; const size_t bufsiz = cp->SPR * sz; hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata, lengthRawData+bufsiz); char *bufbak = buf; // backup copy char **endptr = &bufbak; for (k = 0; k < cp->SPR; k++) { double d = strtod(*endptr,endptr); *(double*)(hdr->AS.rawdata+lengthRawData+sz*k) = d; } lengthRawData += bufsiz; free(buf); } else if (cp->SPR > 0) { cp->SPR = 0; fprintf(stderr,"Warning SOPEN(BIN) #%i: data file (%s) not found\n",hdr->NS,datfile); } } else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "ASCII/BIN: data type unsupported"); } hdr->AS.bpb = lengthRawData; } else if (!strcmp(line,"HighPassFilter")) cp->HighPass = atof(val); else if (!strcmp(line,"LowPassFilter")) cp->LowPass = atof(val); else if (!strcmp(line,"NotchFilter")) cp->Notch = atof(val); else if (!strcmp(line,"DigMax")) cp->DigMax = atof(val); else if (!strcmp(line,"DigMin")) cp->DigMin = atof(val); else if (!strcmp(line,"PhysMax")) cp->PhysMax = atof(val); else if (!strcmp(line,"PhysMin")) cp->PhysMin = atof(val); else if (!strcmp(line,"Impedance")) cp->Impedance = atof(val); else if (!strcmp(line,"freqZ")) cp->fZ = atof(val); else if (!strncmp(line,"Position",8)) { sscanf(val,"%f \t%f \t%f",cp->XYZ,cp->XYZ+1,cp->XYZ+2); // consolidate previous channel if ((((size_t)cp->SPR*GDFTYP_BITS[cp->GDFTYP] >> 3) != (hdr->AS.bpb-cp->bi)) && (hdr->TYPE==BIN)) { fprintf(stdout,"Warning SOPEN(BIN): problems with channel %i - filesize %i does not fit header info %"PRIiPTR"\n",(int)k+1, hdr->AS.bpb-hdr->CHANNEL[k].bi, (GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP]*(size_t)hdr->CHANNEL[k].SPR) >> 3); } hdr->SampleRate = hdr->SPR/duration; cp->LeadIdCode = 0; cp->OnOff = 1; cp->Cal = (cp->PhysMax - cp->PhysMin) / (cp->DigMax - cp->DigMin); cp->Off = cp->PhysMin - cp->Cal*cp->DigMin; } } else if (status==3) { if (!strncmp(line,"0x",2)) { if (hdr->EVENT.N+1 >= N) { N = max(PAGESIZE, 2*N); if (N != reallocEventTable(hdr, N)) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } val = line+2; int i; sscanf(val,"%04x",&i); if (i>0xffff) fprintf(stdout,"Warning: Type %i of event %i does not fit in 16bit\n",i,hdr->EVENT.N); else hdr->EVENT.TYP[hdr->EVENT.N] = (typeof(hdr->EVENT.TYP[0]))i; double d; val = strchr(val,'\t')+1; sscanf(val,"%lf",&d); hdr->EVENT.POS[hdr->EVENT.N] = (typeof(*hdr->EVENT.POS))round(d*hdr->EVENT.SampleRate); // 0-based indexing #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif val = strchr(val,'\t')+1; if (val[0]!='\t') { sscanf(val,"%lf",&d); hdr->EVENT.DUR[hdr->EVENT.N] = (typeof(*hdr->EVENT.POS))round(d*hdr->EVENT.SampleRate); } else hdr->EVENT.DUR[hdr->EVENT.N] = 0; val = strchr(val,'\t')+1; if (val[0]!='\t') { sscanf(val,"%d",&i); if (i>0xffff) fprintf(stdout,"Warning: channel number %i of event %i does not fit in 16bit\n",i,hdr->EVENT.N); else hdr->EVENT.CHN[hdr->EVENT.N] = i; } else hdr->EVENT.CHN[hdr->EVENT.N] = 0; val = strchr(val,'\t')+1; if ((hdr->EVENT.TYP[hdr->EVENT.N]==0x7fff) && (hdr->EVENT.CHN[hdr->EVENT.N]>0) && (!hdr->CHANNEL[hdr->EVENT.CHN[hdr->EVENT.N]-1].SPR)) { sscanf(val,"%d",&hdr->EVENT.DUR[hdr->EVENT.N]); } ++hdr->EVENT.N; } } line = strtok(NULL,"\x0a\x0d"); } hdr->AS.length = hdr->NRec; } else if (hdr->TYPE==BCI2000) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) FMT=%s Ver=%4.2f\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); char *ptr, *t1; /* decode header length */ hdr->HeadLen = 0; ptr = strstr((char*)hdr->AS.Header,"HeaderLen="); if (ptr==NULL) biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "not a BCI2000 format"); else { /* read whole header */ hdr->HeadLen = (typeof(hdr->HeadLen)) strtod(ptr+10,&ptr); if (count <= hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, hdr->HeadLen+1); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } else ifseek(hdr,hdr->HeadLen,SEEK_SET); } hdr->AS.Header[hdr->HeadLen]=0; hdr->AS.bci2000 = (char*)realloc(hdr->AS.bci2000, hdr->HeadLen+1); memcpy(hdr->AS.bci2000, hdr->AS.Header, hdr->HeadLen+1); /* decode number of channels */ t1 = strtok((char*)hdr->AS.Header,"\x0a\x0d"); ptr = strstr(t1,"SourceCh="); if (ptr==NULL) biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "not a BCI2000 format"); else hdr->NS = (typeof(hdr->NS)) strtod(ptr+9,&ptr); /* decode length of state vector */ ptr = strstr(t1,"StatevectorLen="); if (ptr==NULL) biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "not a BCI2000 format"); else BCI2000_StatusVectorLength = (size_t) strtod(ptr+15,&ptr); /* decode data format */ ptr = strstr(ptr,"DataFormat="); uint16_t gdftyp=3; if (ptr == NULL) gdftyp = 3; else if (!strncmp(ptr+12,"int16",3)) gdftyp = 3; else if (!strncmp(ptr+12,"int32",5)) gdftyp = 5; else if (!strncmp(ptr+12,"float32",5)) gdftyp = 16; else if (!strncmp(ptr+12,"int24",5)) gdftyp = 255+24; else if (!strncmp(ptr+12,"uint16",3)) gdftyp = 4; else if (!strncmp(ptr+12,"uint32",5)) gdftyp = 6; else if (!strncmp(ptr+12,"uint24",5)) gdftyp = 511+24; else if (!strncmp(ptr+12,"float64",6)) gdftyp = 17; else biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "SOPEN(BCI2000): invalid file format"); if (hdr->AS.B4C_ERRNUM) { return(hdr); } if (hdr->FLAG.OVERFLOWDETECTION) { fprintf(stderr,"WARNING: Automated overflowdetection not supported in BCI2000 file %s\n",hdr->FileName); hdr->FLAG.OVERFLOWDETECTION = 0; } hdr->SPR = 1; double gain=0.0, offset=0.0, digmin=0.0, digmax=0.0; size_t tc_len=0,tc_pos=0, rs_len=0,rs_pos=0, fb_len=0,fb_pos=0; char TargetOrientation=0; hdr->AS.bpb = 0; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Transducer[0] = 0; sprintf(hc->Label,"#%03i",(int)k+1); hc->Cal = gain; hc->Off = offset; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; hc->OnOff = 1; hc->SPR = 1; hc->GDFTYP = gdftyp; hc->bi = hdr->AS.bpb; hdr->AS.bpb += (GDFTYP_BITS[hc->GDFTYP] * (size_t)hc->SPR)>>3; } if (hdr->TYPE==BCI2000) hdr->AS.bpb += BCI2000_StatusVectorLength; int status = 0; ptr = strtok(NULL,"\x0a\x0d"); while (ptr != NULL) { if (VERBOSE_LEVEL>8) fprintf(stdout,"[203] %i: %s !\n",status,ptr); if (!strncmp(ptr,"[ State Vector Definition ]",26)) status = 1; else if (!strncmp(ptr,"[ Parameter Definition ]",24)) status = 2; else if (!strncmp(ptr,"[ ",2)) status = 3; else if (status==1) { int i[4]; char *item = NULL; #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L sscanf(ptr,"%as %i %i %i %i",&item,i,i+1,i+2,i+3); #else sscanf(ptr,"%ms %i %i %i %i",&item,i,i+1,i+2,i+3); #endif if (!strcmp(item,"TargetCode")) { tc_pos = i[2]*8 + i[3]; tc_len = i[0]; } else if (!strcmp(item,"ResultCode")) { rs_pos = i[2]*8 + i[3]; rs_len = i[0]; } else if (!strcmp(item,"Feedback")) { fb_pos = i[2]*8 + i[3]; fb_len = i[0]; } if (item) free(item); } else if (status==2) { t1 = strstr(ptr,"ChannelNames="); if (t1 != NULL) { unsigned NS = (unsigned)strtod(t1+13,&ptr); for (k=0; kMAX_LENGTH_LABEL) k1=MAX_LENGTH_LABEL; strncpy(hdr->CHANNEL[k].Label,ptr-k1,k1); hdr->CHANNEL[k].Label[k1]=0; // terminating 0 } } t1 = strstr(ptr,"SamplingRate="); if (t1 != NULL) hdr->SampleRate = strtod(t1+14,&ptr); t1 = strstr(ptr,"SourceChGain="); if (t1 != NULL) { unsigned NS = (unsigned) strtod(t1+13,&ptr); for (k=0; kCHANNEL[k].Cal = strtod(ptr,&ptr); for (; kNS; k++) hdr->CHANNEL[k].Cal = hdr->CHANNEL[k-1].Cal; } t1 = strstr(ptr,"SourceChOffset="); if (t1 != NULL) { unsigned NS = (unsigned) strtod(t1+15,&ptr); for (k=0; kCHANNEL[k].Off = strtod(ptr,&ptr); for (; kNS; k++) hdr->CHANNEL[k].Off = hdr->CHANNEL[k-1].Off; } t1 = strstr(ptr,"SourceMin="); if (t1 != NULL) digmin = strtod(t1+10,&ptr); t1 = strstr(ptr,"SourceMax="); if (t1 != NULL) digmax = strtod(t1+10,&ptr); t1 = strstr(ptr,"StorageTime="); if (t1 != NULL) { char *t2 = strstr(t1,"%20"); while (t2!=NULL) { memset(t2,' ',3); t2 = strstr(t1,"%20"); } char tmp[20]; int c=sscanf(t1+12,"%03s %03s %2u %2u:%2u:%2u %4u",tmp+10,tmp,&tm_time.tm_mday,&tm_time.tm_hour,&tm_time.tm_min,&tm_time.tm_sec,&tm_time.tm_year); if (c==7) { tm_time.tm_isdst = -1; tm_time.tm_year -= 1900; tm_time.tm_mon = month_string2int(tmp); hdr->T0 = tm_time2gdf_time(&tm_time); } } t1 = strstr(ptr,"TargetOrientation="); if (t1 != NULL) TargetOrientation = (char) strtod(t1+18, &ptr); // else if (status==3); } ptr = strtok(NULL,"\x0a\x0d"); } for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->DigMax = digmax; hc->DigMin = digmin; hc->PhysMax= hc->DigMax * hc->Cal + hc->Off; hc->PhysMin= hc->DigMin * hc->Cal + hc->Off; } hdr->AS.bpb = (hdr->NS * (GDFTYP_BITS[gdftyp]>>3) + BCI2000_StatusVectorLength); /* decode state vector into event table */ hdr->EVENT.SampleRate = hdr->SampleRate; size_t skip = hdr->NS * (GDFTYP_BITS[gdftyp]>>3); size_t N = 0; count = 0; uint8_t *StatusVector = (uint8_t*) malloc(BCI2000_StatusVectorLength*2); uint32_t b0=0,b1=0,b2=0,b3,b4=0,b5; while (!ifeof(hdr)) { ifseek(hdr, skip, SEEK_CUR); ifread(StatusVector + BCI2000_StatusVectorLength*(count & 1), 1, BCI2000_StatusVectorLength, hdr); if (memcmp(StatusVector, StatusVector+BCI2000_StatusVectorLength, BCI2000_StatusVectorLength)) { if (N+4 >= hdr->EVENT.N) { hdr->EVENT.N += 1024; if (SIZE_MAX == reallocEventTable(hdr, hdr->EVENT.N)) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[N] = 0; #endif /* event codes according to http://www.bci2000.org/wiki/index.php/User_Reference:GDFFileWriter http://biosig.cvs.sourceforge.net/biosig/biosig/doc/eventcodes.txt?view=markup */ /* decode ResultCode */ b3 = *(uint32_t*)(StatusVector + BCI2000_StatusVectorLength*(count & 1) + (rs_pos>>3)); b3 = (b3 >> (rs_pos & 7)) & ((1<b2) hdr->EVENT.TYP[N] = ( b3==b1 ? 0x0381 : 0x0382); else hdr->EVENT.TYP[N] = ( b2==b0 ? 0x8381 : 0x8382); hdr->EVENT.POS[N] = count; // 0-based indexing N++; b2 = b3; } /* decode TargetCode */ b1 = *(uint32_t*)(StatusVector + BCI2000_StatusVectorLength*(count & 1) + (tc_pos>>3)); b1 = (b1 >> (tc_pos & 7)) & ((1<EVENT.TYP[N] = 0x030c; break; case 2: hdr->EVENT.TYP[N] = 0x0306; break; case -1: hdr->EVENT.TYP[N] = 0x830c; break; case -2: hdr->EVENT.TYP[N] = 0x8306; break; default: if (b1>b0) hdr->EVENT.TYP[N] = 0x0300 + b1 - b0; else hdr->EVENT.TYP[N] = 0x8300 + b0 - b1; } } else { if (b1>b0) hdr->EVENT.TYP[N] = 0x0300 + b1 - b0; else hdr->EVENT.TYP[N] = 0x8300 + b0 - b1; } hdr->EVENT.POS[N] = count; // 0-based indexing N++; b0 = b1; } /* decode Feedback */ b5 = *(uint32_t*)(StatusVector + BCI2000_StatusVectorLength*(count & 1) + (fb_pos>>3)); b5 = (b5 >> (fb_pos & 7)) & ((1< b4) hdr->EVENT.TYP[N] = 0x030d; else if (b5 < b4) hdr->EVENT.TYP[N] = 0x830d; if (b5 != b4) { hdr->EVENT.POS[N] = count; // 0-based indexing N++; b4 = b5; } } count++; } hdr->EVENT.N = N; free(StatusVector); hdr->NRec = (iftell(hdr) - hdr->HeadLen) / hdr->AS.bpb; ifseek(hdr, hdr->HeadLen, SEEK_SET); if (VERBOSE_LEVEL>8) fprintf(stdout,"[209] header finished!\n"); } else if (hdr->TYPE==BKR) { if (VERBOSE_LEVEL>8) fprintf(stdout,"libbiosig/sopen (BKR)\n"); hdr->HeadLen = 1024; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, hdr->HeadLen); if (hdr->HeadLen > count) count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); hdr->NS = leu16p(hdr->AS.Header+2); hdr->NRec = leu32p(hdr->AS.Header+6); hdr->SPR = leu32p(hdr->AS.Header+10); hdr->NRec *= hdr->SPR; hdr->SPR = 1; hdr->T0 = 0; // Unknown; hdr->SampleRate = leu16p(hdr->AS.Header+4); /* extract more header information */ hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; sprintf(hc->Label,"# %02i",(int)k); hc->Transducer[0] = '\0'; hc->GDFTYP = 3; hc->SPR = 1; // *(int32_t*)(Header1+56); hc->LowPass = lef32p(hdr->AS.Header+22); hc->HighPass = lef32p(hdr->AS.Header+26); hc->Notch = -1.0; // unknown hc->PhysMax = (double)leu16p(hdr->AS.Header+14); hc->DigMax = (double)leu16p(hdr->AS.Header+16); hc->PhysMin = -hc->PhysMax; hc->DigMin = -hc->DigMax; hc->Cal = hc->PhysMax/hc->DigMax; hc->Off = 0.0; hc->OnOff = 1; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; hc->bi = k*2; } hdr->AS.bpb = hdr->NS*2; hdr->FLAG.OVERFLOWDETECTION = 0; // BKR does not support automated overflow and saturation detection } else if (hdr->TYPE==BLSC) { hdr->HeadLen = hdr->AS.Header[1]<<7; if (countHeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } hdr->VERSION = leu16p(hdr->AS.Header+2)/100.0; hdr->SampleRate = 128; hdr->SPR = 1; hdr->NS = hdr->AS.Header[346]; const uint32_t GAIN[] = { 0,50000,75000,100000,150000,200000,250000,300000, //0-7 0,5000,7500,10000,15000,20000,25000,30000, //8-15 0,500,750,1000,1500,2000,2500,3000, //16-23 10,50,75,100,150,200,250,300 //24-31 }; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Label[0] = 0; hc->Transducer[0] = '\0'; hc->GDFTYP = 2; hc->SPR = hdr->SPR; // *(int32_t*)(Header1+56); hc->LowPass = -1.0; hc->HighPass = -1.0; hc->Notch = -1.0; // unknown hc->DigMax = 255; hc->DigMin = 0; #define SENS leu16p(hdr->AS.Header+467) #define CALUV leu16p(hdr->AS.Header+469) #define CV hdr->AS.Header[425+k] #define DC hdr->AS.Header[446+k] #define gain GAIN[hdr->AS.Header[602+k]] if (VERBOSE_LEVEL>8) fprintf(stdout,"#%i sens=%i caluv=%i cv=%i dc=%i Gain=%i\n",(int)k,SENS,CALUV,CV,DC,gain); double cal, off; if (hdr->AS.Header[5]==0) { // external amplifier cal = 0.2*CALUV*SENS/CV; off = -DC*cal; } else { // internal amplifier cal = 4e6/(CV*gain); off = -(128+(DC-128)*gain/3e5)*cal; } #undef SENS #undef CALUV #undef CV #undef DC #undef gain hc->Cal = cal; hc->Off = off; hc->PhysMax = hc->DigMax * cal + off; hc->PhysMin = hc->DigMin * cal + off; hc->OnOff = 1; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; hc->bi = k*hc->SPR*(GDFTYP_BITS[2]>>3); } hdr->AS.bpb = hdr->NS*hdr->SPR*(GDFTYP_BITS[2]>>3); struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->NRec = FileBuf.st_size/hdr->NS; ifseek(hdr, hdr->HeadLen, SEEK_SET); } else if (hdr->TYPE==BNI) { // BNI-1-Baltimore/Nicolet char *line = strtok((char*)hdr->AS.Header,"\x0a\x0d"); fprintf(stderr,"Warning SOPEN: BNI not implemented - experimental code!\n"); double cal=0,age; char *Label=NULL; struct tm t; while (line != NULL) { size_t c1 = strcspn(line," ="); size_t c2 = strspn(line+c1," ="); char *val = line+c1+c2; if (!strncmp(line,"PatientId",9)) strncpy(hdr->Patient.Id,val,MAX_LENGTH_PID); else if (!strncasecmp(line,"Sex",3)) hdr->Patient.Sex = 1*(toupper(val[0])=='M')+2*(toupper(val[0])=='F'); else if (!strncasecmp(line,"medication",11)) hdr->Patient.Medication = val==NULL ? 1 : 2; else if (!strncasecmp(line,"diagnosis",10)) { } else if (!strncasecmp(line,"MontageRaw",9)) Label = val; else if (!strncasecmp(line,"Age",3)) age = atol(val); else if (!strncasecmp(line,"Date",c1)) sscanf(val,"%02i/%02i/%02i",&t.tm_mon,&t.tm_mday,&t.tm_year); else if (!strncasecmp(line,"Time",c1)) sscanf(val,"%02i:%02i:%02i",&t.tm_hour,&t.tm_min,&t.tm_sec); else if (!strncasecmp(line,"Rate",c1)) hdr->SampleRate = atol(val); else if (!strncasecmp(line,"NchanFile",9)) hdr->NS = atol(val); else if (!strncasecmp(line,"UvPerBit",c1)) cal = atof(val); else if (!strncasecmp(line,"[Events]",c1)) { // not implemented yet } else fprintf(stdout,"SOPEN(BNI): unknown field %s=%s\n",line,val); line = strtok(NULL,"\x0a\x0d"); } hdr->T0 = tm_time2gdf_time(&t); hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (!k) strncpy(hc->Label, strtok(Label,","),MAX_LENGTH_LABEL); else strncpy(hc->Label, strtok(NULL,","),MAX_LENGTH_LABEL); hc->Transducer[0] = '\0'; hc->GDFTYP = 0xffff; // unknown - triggers error status hc->SPR = 1; // hc->LowPass = -1.0; hc->HighPass = -1.0; hc->Notch = -1.0; // unknown hc->DigMax = 32767; hc->DigMin = -32768; hc->Cal = cal; hc->Off = 0.0; hc->PhysMax = hc->DigMax * cal; hc->PhysMin = hc->DigMin * cal; hc->OnOff = 1; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; //hc->bi = k*GDFTYP_BITS[hc->GDFTYP]>>3; } } else if (hdr->TYPE==BrainVisionMarker) { while (!ifeof(hdr)) { size_t bufsiz = max(count*2, PAGESIZE); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,bufsiz+1); count += ifread(hdr->AS.Header+count,1,bufsiz-count,hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); if (VERBOSE_LEVEL>8) fprintf(stdout,"SOPEN(BV): marker file read.\n"); int seq = 0; /* decode marker file */ char *t,*t1=" "; t = Header1; t += strcspn(Header1,"\x0A\x0D"); t += strspn(t,"\x0A\x0D"); //char *t1 = strtok(Header1,"\x0A\x0D"); // skip first line size_t N_EVENT=0; hdr->EVENT.N=0; do { t1 = t; t += strcspn(t,"\x0A\x0D"); t += strspn(t,"\x0A\x0D"); t[-1]=0; if (VERBOSE_LEVEL>8) fprintf(stdout,"%i <%s>\n",seq,t1); if (!strncmp(t1,";",1)) ; else if (!strncmp(t1,"[Common Infos]",14)) seq = 1; else if (!strncmp(t1,"[Marker Infos]",14)) seq = 2; else if (seq==1) ; else if ((seq==2) && !strncmp(t1,"Mk",2)) { int p1 = strcspn(t1,"="); int p2 = p1 + 1 + strcspn(t1+p1+1,","); int p3 = p2 + 1 + strcspn(t1+p2+1,","); int p4 = p3 + 1 + strcspn(t1+p3+1,","); int p5 = p4 + 1 + strcspn(t1+p4+1,","); int p6 = p5 + 1 + strcspn(t1+p5+1,","); if (VERBOSE_LEVEL>8) fprintf(stdout," %i %i %i %i %i %i \n",p1,p2,p3,p4,p5,p6); t1[p1]=0; t1[p2]=0; t1[p3]=0; t1[p4]=0; t1[p5]=0; if (hdr->EVENT.N <= N_EVENT) { hdr->EVENT.N += 256; if (reallocEventTable(hdr, hdr->EVENT.N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } hdr->EVENT.TYP[N_EVENT] = atol(t1+p2+2); hdr->EVENT.POS[N_EVENT] = atol(t1+p3+1)-1; // 0-based indexing hdr->EVENT.DUR[N_EVENT] = atol(t1+p4+1); hdr->EVENT.CHN[N_EVENT] = atol(t1+p5+1); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[N_EVENT] = 0; #endif if (!strncmp(t1+p1+1,"New Segment",11)) { hdr->EVENT.TYP[N_EVENT] = 0x7ffe; char* t2 = t1+p6+1; t2[14]=0; tm_time.tm_sec = atoi(t2+12); t2[12]=0; tm_time.tm_min = atoi(t2+10); t2[10]=0; tm_time.tm_hour = atoi(t2+8); t2[8] =0; tm_time.tm_mday = atoi(t2+6); t2[6] =0; tm_time.tm_mon = atoi(t2+4)-1; t2[4] =0; tm_time.tm_year = atoi(t2)-1900; hdr->T0 = tm_time2gdf_time(&tm_time); } else { if (VERBOSE_LEVEL>8) fprintf(stdout,"#%02i <%s>\n",(int)N_EVENT,t1+p2+1); FreeTextEvent(hdr,N_EVENT,t1+p2+1); } ++N_EVENT; } } while (strlen(t1)>0); // free(vmrk); hdr->AS.auxBUF = hdr->AS.Header; hdr->AS.Header = NULL; hdr->EVENT.N = N_EVENT; hdr->TYPE = EVENT; } else if ((hdr->TYPE==BrainVision) || (hdr->TYPE==BrainVisionVAmp)) { /* open and read header file */ // ifclose(hdr); char *filename = hdr->FileName; // keep input file name char* tmpfile = (char*)calloc(strlen(hdr->FileName)+5,1); strcpy(tmpfile, hdr->FileName); // Flawfinder: ignore hdr->FileName = tmpfile; char* ext = strrchr((char*)hdr->FileName,'.')+1; while (!ifeof(hdr)) { size_t bufsiz = max(2*count, PAGESIZE); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN(BV): header file read.\n"); int seq = 0; /* decode header information */ hdr->FLAG.OVERFLOWDETECTION = 0; seq = 0; uint16_t gdftyp=3; char FLAG_ASCII = 0; hdr->FILE.LittleEndian = 1; // default little endian double physmax=1e6,physmin=-1e6,digmax=1e6,digmin=-1e6,cal=1.0,off=0.0; enum o_t{VEC,MUL} orientation = MUL; char DECIMALSYMBOL='.'; int SKIPLINES=0, SKIPCOLUMNS=0; size_t npts=0; char *t; size_t pos; // skip first line with const char EOL[] = "\r\n"; pos = strcspn(Header1,EOL); pos += strspn(Header1+pos,EOL); while (pos < hdr->HeadLen) { t = Header1+pos; // start of line pos += strcspn(t,EOL); Header1[pos] = 0; // line terminator pos += strspn(Header1+pos+1,EOL)+1; // skip if (VERBOSE_LEVEL>7) fprintf(stdout,"[212]: %i pos=%i <%s>, ERR=%i\n",seq,(int)pos,t,hdr->AS.B4C_ERRNUM); if (!strncmp(t,";",1)) // comments ; else if (!strncmp(t,"[Common Infos]",14)) seq = 1; else if (!strncmp(t,"[Binary Infos]",14)) seq = 2; else if (!strncmp(t,"[ASCII Infos]",13)) { seq = 2; FLAG_ASCII = 1; gdftyp = 17; // biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SOPEN(BrainVision): ASCII-format not supported (yet)."); } else if (!strncmp(t,"[Channel Infos]",14)) { seq = 3; /* open data file */ if (FLAG_ASCII) hdr = ifopen(hdr,"rt"); else hdr = ifopen(hdr,"rb"); hdr->AS.bpb = (hdr->NS*GDFTYP_BITS[gdftyp])>>3; if (hdr->TYPE==BrainVisionVAmp) hdr->AS.bpb += 4; if (!npts) { struct stat FileBuf; stat(hdr->FileName,&FileBuf); npts = FileBuf.st_size/hdr->AS.bpb; } /* restore input file name, and free temporary file name */ hdr->FileName = filename; free(tmpfile); if (orientation == VEC) { hdr->SPR = npts; hdr->NRec= 1; hdr->AS.bpb*= hdr->SPR; } else { hdr->SPR = 1; hdr->NRec= npts; } hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Label[0] = 0; hc->Transducer[0] = '\0'; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; // *(int32_t*)(Header1+56); hc->LowPass = -1.0; hc->HighPass = -1.0; hc->Notch = -1.0; // unknown hc->PhysMax = physmax; hc->DigMax = digmax; hc->PhysMin = physmin; hc->DigMin = digmin; hc->Impedance = NAN; hc->Cal = cal; hc->Off = off; hc->OnOff = 1; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; size_t bi8 = k*(size_t)hdr->SPR*GDFTYP_BITS[gdftyp]; hc->bi8 = bi8; hc->bi = bi8>>3; } if (VERBOSE_LEVEL>7) fprintf(stdout,"BVA210 seq=%i,pos=%i,%i <%s> bpb=%i\n",seq,(int)pos,hdr->HeadLen,t,hdr->AS.bpb); } //else if (!strncmp(t,"[Common Infos]",14)) // seq = 4; else if (!strncmp(t,"[Coordinates]",13)) seq = 5; else if (!strncmp(t,"[Comment]",9)) seq = 6; else if (!strncmp(t,"[",1)) seq = 9; else if (seq==1) { if (!strncmp(t,"DataFile=",9)) strcpy(ext, strrchr(t,'.') + 1); else if (!strncmp(t,"MarkerFile=",11)) { char* mrkfile = (char*)calloc(strlen(hdr->FileName)+strlen(t),1); if (strrchr(hdr->FileName,FILESEP)) { strcpy(mrkfile, hdr->FileName); // Flawfinder: ignore strcpy(strrchr(mrkfile,FILESEP)+1, t+11); // Flawfinder: ignore } else strcpy(mrkfile,t+11); // Flawfinder: ignore if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN marker file <%s>.\n",mrkfile); HDRTYPE *hdr2 = sopen(mrkfile,"r",NULL); hdr->T0 = hdr2->T0; memcpy(&hdr->EVENT,&hdr2->EVENT,sizeof(hdr2->EVENT)); hdr->AS.auxBUF = hdr2->AS.auxBUF; // contains the free text annotation // do not de-allocate event table when hdr2 is deconstructed memset(&hdr2->EVENT,0,sizeof(hdr2->EVENT)); hdr2->AS.auxBUF = NULL; sclose(hdr2); destructHDR(hdr2); free(mrkfile); biosigERROR(hdr, B4C_NO_ERROR, NULL); // reset error status - missing or incorrect marker file is not critical } else if (!strncmp(t,"DataFormat=BINARY",11)) ; else if (!strncmp(t,"DataFormat=ASCII",16)) { FLAG_ASCII = 1; gdftyp = 17; // biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SOPEN(BrainVision): ASCII-format not supported (yet)."); } else if (!strncmp(t,"DataOrientation=VECTORIZED",25)) orientation = VEC; else if (!strncmp(t,"DataOrientation=MULTIPLEXED",26)) orientation = MUL; else if (!strncmp(t,"DataType=TIMEDOMAIN",19)) ; else if (!strncmp(t,"DataType=",9)) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SOPEN(BrainVision): DataType is not TIMEDOMAIN"); } else if (!strncmp(t,"NumberOfChannels=",17)) { hdr->NS = atoi(t+17); } else if (!strncmp(t,"DataPoints=",11)) { npts = atol(t+11); } else if (!strncmp(t,"SamplingInterval=",17)) { hdr->SampleRate = 1e6/atof(t+17); hdr->EVENT.SampleRate = hdr->SampleRate; } } else if (seq==2) { if (!strncmp(t,"BinaryFormat=IEEE_FLOAT_32",26)) { gdftyp = 16; digmax = physmax/cal; digmin = physmin/cal; } else if (!strncmp(t,"BinaryFormat=INT_16",19)) { gdftyp = 3; digmax = 32767; digmin = -32768; hdr->FLAG.OVERFLOWDETECTION = 1; } else if (!strncmp(t,"BinaryFormat=UINT_16",20)) { gdftyp = 4; digmax = 65535; digmin = 0; hdr->FLAG.OVERFLOWDETECTION = 1; } else if (!strncmp(t,"BinaryFormat",12)) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SOPEN(BrainVision): BinaryFormat="); } else if (!strncmp(t,"UseBigEndianOrder=NO",20)) { // hdr->FLAG.SWAP = (__BYTE_ORDER == __BIG_ENDIAN); hdr->FILE.LittleEndian = 1; } else if (!strncmp(t,"UseBigEndianOrder=YES",21)) { // hdr->FLAG.SWAP = (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->FILE.LittleEndian = 0; } else if (!strncmp(t,"DecimalSymbol=",14)) { DECIMALSYMBOL = t[14]; } else if (!strncmp(t,"SkipLines=",10)) { SKIPLINES = atoi(t+10); } else if (!strncmp(t,"SkipColumns=",12)) { SKIPCOLUMNS = atoi(t+12); } else if (0) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SOPEN(BrainVision): BinaryFormat="); return(hdr); } } else if (seq==3) { if (VERBOSE_LEVEL==9) fprintf(stdout,"BVA: seq=%i,line=<%s>,ERR=%i\n",seq,t,hdr->AS.B4C_ERRNUM ); if (!strncmp(t,"Ch",2)) { char* ptr; if (VERBOSE_LEVEL==9) fprintf(stdout,"%s\n",t); int n = strtoul(t+2, &ptr, 10)-1; if ((n < 0) || (n >= hdr->NS)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(BrainVision): invalid channel number"); ifclose(hdr); return(hdr); } size_t len = min(strcspn(ptr+1,","),MAX_LENGTH_LABEL); strncpy(hdr->CHANNEL[n].Label,ptr+1,len); hdr->CHANNEL[n].Label[len]=0; ptr += len+2; ptr += strcspn(ptr,",")+1; if (strlen(ptr)>0) { double tmp = atof(ptr); if (tmp) hdr->CHANNEL[n].Cal = tmp; hdr->CHANNEL[n].PhysMax = hdr->CHANNEL[n].DigMax * hdr->CHANNEL[n].Cal ; hdr->CHANNEL[n].PhysMin = hdr->CHANNEL[n].DigMin * hdr->CHANNEL[n].Cal ; } if (VERBOSE_LEVEL==9) fprintf(stdout,"Ch%02i=%s,,%s(%f)\n",n,hdr->CHANNEL[n].Label,ptr,hdr->CHANNEL[n].Cal ); } } else if (seq==4) { } else if (seq==5) { } else if (seq==6) { } // t = strtok(NULL,"\x0a\x0d"); // extract next line } hdr->HeadLen = 0; if (FLAG_ASCII) { count = 0; size_t bufsiz = hdr->NS*hdr->SPR*hdr->NRec*16; while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count+bufsiz+1); count += ifread(hdr->AS.Header+count,1,bufsiz,hdr); } ifclose(hdr); hdr->AS.Header[count]=0; // terminating null character size_t pos=0; if (DECIMALSYMBOL != '.') do { if (hdr->AS.Header[pos]==DECIMALSYMBOL) hdr->AS.Header[pos] = '.'; } while (hdr->AS.Header[++pos]); pos = 0; while (SKIPLINES>0) { while (!iscntrl(hdr->AS.Header[pos])) pos++; // skip line while ( iscntrl(hdr->AS.Header[pos])) pos++; // skip line feed and carriage return SKIPLINES--; } hdr->AS.rawdata = (uint8_t*)malloc(hdr->NS*npts*sizeof(double)); char* POS=(char*)(hdr->AS.Header+pos); for (k=0; k < hdr->NS*npts; k++) { if (((orientation==MUL) && !(k%hdr->NS)) || ((orientation==VEC) && !(k%npts))) { double d; int sc = SKIPCOLUMNS; while (sc--) d=strtod(POS,&POS); // skip value, return value is ignored } *(double*)(hdr->AS.rawdata+k*sizeof(double)) = strtod(POS,&POS); } hdr->TYPE = native; hdr->AS.length = hdr->NRec; } } else if (hdr->TYPE==CFS) { hdr->HeadLen = count; sopen_cfs_read(hdr); } else if (hdr->TYPE==SMR) { hdr->HeadLen = count; sopen_smr_read(hdr); } else if (hdr->TYPE==CFWB) { hdr->SampleRate = 1.0/lef64p(hdr->AS.Header+8); hdr->SPR = 1; tm_time.tm_year = lei32p(hdr->AS.Header+16) - 1900; tm_time.tm_mon = lei32p(hdr->AS.Header+20) - 1; tm_time.tm_mday = lei32p(hdr->AS.Header+24); tm_time.tm_hour = lei32p(hdr->AS.Header+28); tm_time.tm_min = lei32p(hdr->AS.Header+32); tm_time.tm_sec = (int)lef64p(hdr->AS.Header+36); tm_time.tm_isdst = -1; hdr->T0 = tm_time2gdf_time(&tm_time); // = *(double*)(Header1+44); // pre-trigger time hdr->NS = leu32p(hdr->AS.Header+52); hdr->NRec = leu32p(hdr->AS.Header+56); #define CFWB_FLAG_TIME_CHANNEL (*(int32_t*)(Header1+60)) // TimeChannel // = *(int32_t*)(Header1+64); // DataFormat hdr->HeadLen = 68 + hdr->NS*96; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); if (count<=hdr->HeadLen) count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); else ifseek(hdr, hdr->HeadLen, SEEK_SET); uint16_t gdftyp = leu32p(hdr->AS.Header+64); hdr->AS.bpb = (CFWB_FLAG_TIME_CHANNEL ? GDFTYP_BITS[CFWB_GDFTYP[gdftyp-1]]>>3 : 0); hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; uint8_t* Header2 = hdr->AS.Header+68+k*96; hc->Transducer[0] = '\0'; hc->GDFTYP = CFWB_GDFTYP[gdftyp-1]; hc->SPR = 1; // *(int32_t*)(Header1+56); strncpy(hc->Label, (char*)Header2, min(32,MAX_LENGTH_LABEL)); char p[17]; memcpy(p, (char*)Header2+32, 16); p[16] = 0; hc->PhysDimCode = PhysDimCode(p); hc->LeadIdCode = 0; hc->Cal = lef64p(Header2+64); hc->Off = lef64p(Header2+72); hc->PhysMax = lef64p(Header2+80); hc->PhysMin = lef64p(Header2+88); hc->DigMax = (hc->PhysMax - hc->Off) / hc->Cal; hc->DigMin = (hc->PhysMin - hc->Off) / hc->Cal; hc->OnOff = 1; hc->bi = hdr->AS.bpb; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } hdr->FLAG.OVERFLOWDETECTION = 0; // CFWB does not support automated overflow and saturation detection } else if (hdr->TYPE==CNT) { if (VERBOSE_LEVEL>7) fprintf(stdout, "%s: Neuroscan format (count=%d)\n",__func__, (int)count); // TODO: fix handling of AVG and EEG files if (count < 900) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 900); count += ifread(hdr->AS.Header+count, 1, 900-count, hdr); } hdr->VERSION = atof((char*)hdr->AS.Header + 8); int8_t FLAG_CNT32 = 0; uint16_t gdftyp = 0; uint8_t minor_revision = hdr->AS.Header[804]; size_t eventtablepos = leu32p(hdr->AS.Header+886); uint32_t nextfilepos = leu32p(hdr->AS.Header+12); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s: Neuroscan format: minor revision %i eventtablepos: %i nextfilepos: %i\n", __func__, minor_revision, (unsigned)eventtablepos, nextfilepos); /* make base of filename */ size_t i=0, j=0; while (hdr->FileName[i] != '\0') { if ((hdr->FileName[i]=='/') || (hdr->FileName[i]=='\\')) { j=i+1; } i++; } /* skip the extension '.cnt' of filename base and copy to Patient.Id */ strncpy(hdr->Patient.Id, hdr->FileName+j, min(MAX_LENGTH_PID,strlen(hdr->FileName)-j-4)); hdr->Patient.Id[MAX_LENGTH_PID] = 0; ptr_str = (char*)hdr->AS.Header+136; hdr->Patient.Sex = (ptr_str[0]=='f')*2 + (ptr_str[0]=='F')*2 + (ptr_str[0]=='M') + (ptr_str[0]=='m'); ptr_str = (char*)hdr->AS.Header+137; hdr->Patient.Handedness = (ptr_str[0]=='r')*2 + (ptr_str[0]=='R')*2 + (ptr_str[0]=='L') + (ptr_str[0]=='l'); ptr_str = (char*)hdr->AS.Header+225; char tmp[6]; tmp[2] = '\0'; // make sure tmp is 0-terminated tm_time.tm_sec = atoi(memcpy(tmp,ptr_str+16,2)); tm_time.tm_min = atoi(memcpy(tmp,ptr_str+13,2)); tm_time.tm_hour = atoi(memcpy(tmp,ptr_str+10,2)); tm_time.tm_mday = atoi(memcpy(tmp,ptr_str,2)); tm_time.tm_mon = atoi(memcpy(tmp,ptr_str+3,2))-1; tm_time.tm_year = atoi(memcpy(tmp,ptr_str+6,2)); if (tm_time.tm_year<=80) tm_time.tm_year += 100; hdr->T0 = tm_time2gdf_time(&tm_time); hdr->NS = leu16p(hdr->AS.Header+370); hdr->HeadLen = 900+hdr->NS*75; hdr->SampleRate = leu16p(hdr->AS.Header+376); hdr->AS.bpb = hdr->NS*2; if (hdr->AS.Header[20]==1) { // Neuroscan EEG hdr->NRec = leu16p(hdr->AS.Header+362); hdr->SPR = leu16p(hdr->AS.Header+368); hdr->AS.bpb = 2*hdr->NS*hdr->SPR+1+2+2+4+2+2; size_t bpb4 = 4*hdr->NS*hdr->SPR+1+2+2+4+2+2; struct stat FileBuf; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): Neuroscan format: minor rev=%i bpb2:%i bpb4:%i\n", __func__,__LINE__, minor_revision, (unsigned)hdr->AS.bpb, (unsigned)bpb4); switch (minor_revision) { case 9: // TODO: FIXME fprintf(stderr,"Warning biosig/%s (line %d) (CNT/EEG): minor revision %i is experimental\n", __func__,__LINE__, minor_revision); gdftyp = 3; hdr->FILE.LittleEndian = 0; stat(hdr->FileName,&FileBuf); if (hdr->NRec <= 0) { hdr->NRec = (min(FileBuf.st_size, nextfilepos) - hdr->HeadLen)/hdr->AS.bpb; } break; case 12: gdftyp = 3; eventtablepos = hdr->HeadLen + hdr->NRec*hdr->AS.bpb; break; default: if (minor_revision != 16) fprintf(stderr,"Warning biosig/%s (line %d) sopen (CNT/EEG): minor revision %i not tested\n", __func__,__LINE__, minor_revision); if (VERBOSE_LEVEL>7) fprintf(stdout,"biosig/%s (line %d) (CNT/EEG): %i %i %i %i %i %i \n", __func__,__LINE__, (int)hdr->NRec, hdr->SPR, hdr->NS, (int)eventtablepos, (int)(hdr->AS.bpb * hdr->NRec + hdr->HeadLen), (int)(bpb4 * hdr->NRec + hdr->HeadLen)); if ((size_t)(hdr->AS.bpb * hdr->NRec + hdr->HeadLen) == eventtablepos) gdftyp = 3; else if ((bpb4 * hdr->NRec + hdr->HeadLen) == eventtablepos) { hdr->AS.bpb = bpb4; gdftyp = 5; } else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CNT/EEG: type of format not supported"); return(hdr); } } } else { // Neuroscan CNT hdr->SPR = 1; eventtablepos = leu32p(hdr->AS.Header+886); if (nextfilepos > 0) { ifseek (hdr,nextfilepos+52,SEEK_SET); FLAG_CNT32 = (ifgetc(hdr)==1); ifseek (hdr,count,SEEK_SET); } gdftyp = FLAG_CNT32 ? 5 : 3; hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]/8; hdr->NRec = (eventtablepos - hdr->HeadLen) / hdr->AS.bpb; if (VERBOSE_LEVEL > 7) fprintf(stdout,"biosig/%s (line %d) (CNT): %i %i %i %i %i \n", __func__,__LINE__, (int)hdr->NRec, hdr->SPR, hdr->NS, (int)eventtablepos, (int)(hdr->AS.bpb * hdr->NRec + hdr->HeadLen) ); } if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*) realloc(Header1, hdr->HeadLen); count += ifread(Header1+count, 1, hdr->HeadLen-count, hdr); } hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); size_t bi = 0; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; uint8_t* Header2 = hdr->AS.Header+900+k*75; hc->Transducer[0] = '\0'; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; // *(int32_t*)(Header1+56); const size_t len = min(10, MAX_LENGTH_LABEL); if (VERBOSE_LEVEL > 7) fprintf(stdout,"biosig/%s (line %d): #%d label <%s>\n", __func__,__LINE__,(int)k, (char*) Header2 ); strncpy(hc->Label, (char*)Header2, len); hc->Label[len] = 0; hc->LeadIdCode = 0; hc->PhysDimCode = 4256+19; // uV hc->Cal = lef32p(Header2+59); hc->Cal *= lef32p(Header2+71)/204.8; hc->Off = lef32p(Header2+47) * hc->Cal; hc->HighPass = CNT_SETTINGS_HIGHPASS[(uint8_t)Header2[64]]; hc->LowPass = CNT_SETTINGS_LOWPASS[(uint8_t)Header2[65]]; hc->Notch = CNT_SETTINGS_NOTCH[(uint8_t)Header1[682]]; hc->OnOff = 1; if (FLAG_CNT32) { hc->DigMax = (double)(0x007fffff); hc->DigMin = -(double)(int32_t)(0xff800000); } else { hc->DigMax = (double)32767; hc->DigMin = -(double)32768; } hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->bi = bi; bi += (size_t)hdr->SPR * (GDFTYP_BITS[hc->GDFTYP]>>3); } if ((eventtablepos < nextfilepos) && !ifseek(hdr, eventtablepos, SEEK_SET)) { /* read event table */ hdr->EVENT.SampleRate = hdr->SampleRate; ifread(tmp, 9, 1, hdr); int8_t TeegType = tmp[0]; uint32_t TeegSize = leu32p(tmp+1); // uint32_t TeegOffset = leu32p(tmp+5); // not used int fieldsize; switch (TeegType) { case 2: case 3: fieldsize = 19; break; default: fieldsize = 8; } uint8_t* buf = (uint8_t*)malloc(TeegSize); count = ifread(buf, 1, TeegSize, hdr); hdr->EVENT.N = count/fieldsize; if (reallocEventTable(hdr, hdr->EVENT.N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; hdr->EVENT.DUR=NULL; hdr->EVENT.CHN=NULL; for (k = 0; k < hdr->EVENT.N; k++) { hdr->EVENT.TYP[k] = leu16p(buf+k*fieldsize); // stimulus type uint8_t tmp8 = buf[k*fieldsize+3]; if (tmp8>0) { if (hdr->EVENT.TYP[k]>0) fprintf(stdout,"Warning %s (line %d) event %i: both, stimulus and response, codes (%i/%i) are non-zero. response code is ignored.\n",__func__,__LINE__, (int)k+1,hdr->EVENT.TYP[k],tmp8); else hdr->EVENT.TYP[k] |= tmp8 | 0x80; // response type } hdr->EVENT.POS[k] = leu32p(buf+4+k*fieldsize); // 0-based indexing if (TeegType != 3) hdr->EVENT.POS[k] = (hdr->EVENT.POS[k] - hdr->HeadLen) / hdr->AS.bpb; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[k] = 0; #endif } free(buf); } ifseek(hdr, hdr->HeadLen, SEEK_SET); hdr->FLAG.OVERFLOWDETECTION = 0; // automated overflow and saturation detection not supported } else if (hdr->TYPE==CTF) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s: CTF[101]: %s\n", __func__, hdr->FileName); char *f0 = hdr->FileName; char *f1 = (char*)malloc(strlen(f0)+6); strcpy(f1, f0); // Flawfinder: ignore strcpy(strrchr(f1,'.')+1,"res4"); // Flawfinder: ignore if (VERBOSE_LEVEL>8) fprintf(stdout,"CTF[102]: %s\n\t%s\n",f0,f1); if (strcmp(strrchr(hdr->FileName,'.'),".res4")) { if (VERBOSE_LEVEL>8) fprintf(stdout,"CTF[103]:\n"); ifclose(hdr); hdr->FileName = f1; hdr = ifopen(hdr,"rb"); count = 0; } hdr->HeadLen = 1844; if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } if (VERBOSE_LEVEL>8) fprintf(stdout,"CTF[104]: %i %s\n\t%s\n",(int)count,f0,f1); struct tm t; sscanf((char*)(hdr->AS.Header+778),"%d:%d:%d",&t.tm_hour,&t.tm_min,&t.tm_sec); sscanf((char*)(hdr->AS.Header+778+255),"%d/%d/%d",&t.tm_mday,&t.tm_mon,&t.tm_year); --t.tm_mon; hdr->T0 = tm_time2gdf_time(&t); hdr->SPR = bei32p(hdr->AS.Header+1288); hdr->NS = bei16p(hdr->AS.Header+1292); hdr->SampleRate = bef64p(hdr->AS.Header+1296); // double Dur = bef64p(hdr->AS.Header+1304); hdr->NRec = bei16p(hdr->AS.Header+1312); strncpy(hdr->Patient.Id,(char*)(hdr->AS.Header+1712),min(MAX_LENGTH_PID,32)); int32_t CTF_RunSize = bei32p(hdr->AS.Header+1836); //int32_t CTF_RunSize2 = bei32p(hdr->AS.Header+1844); hdr->HeadLen=1844+CTF_RunSize+2; if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } int16_t CTF_NumberOfFilters = bei16p(hdr->AS.Header+1844+CTF_RunSize); hdr->HeadLen = 1844+CTF_RunSize+2+CTF_NumberOfFilters*26+hdr->NS*(32+48+1280); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } ifclose(hdr); size_t pos = 1846+CTF_RunSize+CTF_NumberOfFilters*26; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->AS.bpb = 0; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; strncpy(hc->Label,(const char*)(hdr->AS.Header+pos+k*32),min(32,MAX_LENGTH_LABEL)); hc->Label[min(MAX_LENGTH_LABEL,32)]=0; if (VERBOSE_LEVEL>8) fprintf(stdout,"CTF[107]: #%i\t%x\t%s\n",(int)k,(int)(pos+k*32),hc->Label); int16_t index = bei16p(hdr->AS.Header+pos+hdr->NS*32+k*(48+1280)); // index hc->Cal = 1.0/bef64p(hdr->AS.Header+pos+hdr->NS*32+k*(48+1280)+16); switch (index) { case 0: case 1: case 9: hc->Cal /= bef64p(hdr->AS.Header+pos+hdr->NS*32+k*(48+1280)+8); } hc->GDFTYP = 5; hc->SPR = hdr->SPR; hc->LeadIdCode = 0; hc->Off = 0.0; hc->OnOff = 1; hc->PhysDimCode = 0; hc->Transducer[0] = 0; hc->DigMax = ldexp( 1.0,31); hc->DigMin = ldexp(-1.0,31); hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->bi = hdr->AS.bpb; hdr->AS.bpb += hdr->SPR*(GDFTYP_BITS[hc->GDFTYP]>>3); } if (VERBOSE_LEVEL>8) fprintf(stdout,"CTF[109] %s: \n",hdr->FileName); /********** read marker file **********/ char *f2 = (char*)malloc(strlen(f0)+16); strcpy(f2, f0); // Flawfinder: ignore strcpy(strrchr(f2,FILESEP)+1,"MarkerFile.mrk"); // Flawfinder: ignore hdr->EVENT.SampleRate = hdr->SampleRate; hdr->EVENT.N = 0; hdr->FileName = f2; hdr = ifopen(hdr,"rb"); if (hdr->FILE.OPEN) { count = 0; char *vmrk=NULL; while (!ifeof(hdr)) { size_t bufsiz = max(2*count, PAGESIZE); vmrk = (char*)realloc(vmrk, bufsiz+1); count += ifread(vmrk+count, 1, bufsiz-count, hdr); } vmrk[count] = 0; // add terminating \0 character ifclose(hdr); char *t1, *t2; float u1,u2; t1 = strstr(vmrk,"TRIAL NUMBER"); t2 = strtok(t1,"\x0a\x0d"); size_t N = 0; t2 = strtok(NULL,"\x0a\x0d"); while (t2 != NULL) { sscanf(t2,"%f %f",&u1,&u2); if (N+1 >= hdr->EVENT.N) { hdr->EVENT.N += 256; if (reallocEventTable(hdr, hdr->EVENT.N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } hdr->EVENT.TYP[N] = 1; hdr->EVENT.POS[N] = (uint32_t)(u1*hdr->SPR+u2*hdr->SampleRate); hdr->EVENT.DUR[N] = 0; hdr->EVENT.CHN[N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[N] = 0; #endif N++; t2 = strtok(NULL,"\x0a\x0d"); } hdr->EVENT.N = N; free(vmrk); } free(f2); /********** end reading event/marker file **********/ strcpy(strrchr(f1,'.')+1,"meg4"); hdr->FileName = f1; hdr = ifopen(hdr,"rb"); hdr->HeadLen = 8; hdr->HeadLen = ifread(hdr->AS.Header,1,8,hdr); // hdr->FLAG.SWAP= (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->FILE.LittleEndian = 0; hdr->FileName = f0; free(f1); } else if (hdr->TYPE==DEMG) { hdr->VERSION = leu16p(hdr->AS.Header+4); hdr->NS = leu16p(hdr->AS.Header+6); hdr->SPR = 1; hdr->SampleRate = leu32p(hdr->AS.Header+8); hdr->NRec = leu32p(hdr->AS.Header+12); uint16_t gdftyp = 16; uint8_t bits = hdr->AS.Header[16]; double PhysMin = (double)(int8_t)hdr->AS.Header[17]; double PhysMax = (double)(int8_t)hdr->AS.Header[18]; double Cal = 1.0; double Off = 0.0; if (hdr->VERSION==1) { gdftyp = 16; // float32 Cal = 1.0; Off = 0.0; } else if (hdr->VERSION==2) { gdftyp = 4; // uint16 Cal = (PhysMax-PhysMin)/((1<CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->AS.bpb = 0; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->GDFTYP = gdftyp; hc->SPR = 1; hc->Cal = Cal; hc->Off = Off; hc->OnOff = 1; hc->Transducer[0] = '\0'; hc->LowPass = 450; hc->HighPass = 20; hc->PhysMax = PhysMax; hc->PhysMin = PhysMin; hc->DigMax = DigMax; hc->DigMin = DigMin; hc->LeadIdCode = 0; hc->bi = hdr->AS.bpb; hdr->AS.bpb += GDFTYP_BITS[gdftyp]>>3; } hdr->FLAG.OVERFLOWDETECTION = 0; // automated overflow and saturation detection not supported hdr->HeadLen = 19; ifseek(hdr, 19, SEEK_SET); } else if ((hdr->TYPE==EAS) || (hdr->TYPE==EZ3) || (hdr->TYPE==ARC)) { while (!ifeof(hdr)) { size_t bufsiz = max(2*count, PAGESIZE); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); sopen_cadwell_read(hdr); } else if (hdr->TYPE==EBS) { fprintf(stderr,"Warning SOPEN(EBS): support for EBS format is experimental\n"); /** Fixed Header (32 bytes) **/ uint32_t EncodingID = beu32p(hdr->AS.Header+8); hdr->NS = beu32p(hdr->AS.Header+12); hdr->SPR = beu64p(hdr->AS.Header+16); uint64_t datalen = beu64p(hdr->AS.Header+24); enum encoding { TIB_16 = 0x00000000, CIB_16 = 0x00000001, TIL_16 = 0x00000002, CIL_16 = 0x00000003, TI_16D = 0x00000010, CI_16D = 0x00000011 }; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); size_t pos = 32; uint32_t tag, len; /** Variable Header **/ tag = beu32p(hdr->AS.Header+pos); while (tag) { len = beu32p(hdr->AS.Header+pos+4)<<2; pos += 8; if (count < pos+len+8) { hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header,count*2); count += ifread(hdr->AS.Header+count, 1, count, hdr); } if (VERBOSE_LEVEL>8) fprintf(stdout,"%6i %6i tag=%08x len=%5i: |%c%c%c%c| %s\n", (int)pos, (int)count,tag, len, Header1[0x015f], Header1[0x0160], Header1[0x0161], Header1[0x0162], hdr->AS.Header+pos); /* Appendix A */ switch (tag) { case 0x00000002: break; case 0x00000004: strncpy(hdr->Patient.Name,Header1+pos,MAX_LENGTH_NAME); break; case 0x00000006: strncpy(hdr->Patient.Id,Header1+pos,MAX_LENGTH_PID); break; case 0x00000008: { struct tm t; t.tm_mday = (Header1[pos+6]-'0')*10 + (Header1[pos+7]-'0'); Header1[pos+6] = 0; t.tm_mon = atoi(Header1+pos+4) + 1; Header1[pos+4] = 0; t.tm_year = atoi(Header1+pos) - 1900; t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; hdr->Patient.Birthday = tm_time2gdf_time(&t); break; } case 0x0000000a: hdr->Patient.Sex = bei32p(hdr->AS.Header+pos); break; case 0x00000010: hdr->SampleRate = atof(Header1+pos); break; case 0x00000012: // strndup(hdr->ID.Hospital,Header1+pos,len); hdr->ID.Hospital = malloc(len+1); if (hdr->ID.Hospital) { hdr->ID.Hospital[len] = 0; strncpy(hdr->ID.Hospital,Header1+pos,len); } break; case 0x00000003: // units { int k; char* ptr = Header1+pos; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->Cal = strtod(ptr, &ptr); hc->PhysDimCode = PhysDimCode(ptr); } } break; case 0x00000005: { int k; char* ptr = Header1+pos; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; int c = 0; while (beu32p(ptr)) { if (VERBOSE_LEVEL>8) fprintf(stdout,"0x05: [%i %i] |%c%c%c%c%c%c%c%c|\n",k,c,ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5],ptr[6],ptr[7]); if ((*ptr) && (c<=MAX_LENGTH_LABEL)) { hc->Label[c++] = *ptr; } ptr++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"0x05: %08x\n",beu32p(ptr)); hc->Label[c] = 0; ptr += 4; while (bei32p(ptr)) ptr++; ptr += 4; } } break; case 0x0000000b: // recording time if (Header1[pos+8]=='T') { struct tm t; t.tm_sec = atoi(Header1+pos+13); Header1[pos+13] = 0; t.tm_min = atoi(Header1+pos+11); Header1[pos+11] = 0; t.tm_hour = atoi(Header1+pos+9); Header1[pos+8] = 0; t.tm_mday = atoi(Header1+pos+6); Header1[pos+6] = 0; t.tm_mon = atoi(Header1+pos+4) + 1; Header1[pos+4] = 0; t.tm_year = atoi(Header1+pos) - 1900; hdr->T0 = tm_time2gdf_time(&t); if (VERBOSE_LEVEL>8) fprintf(stdout,"<%s>, T0 = %s\n",Header1+pos,asctime(&t)); } if (VERBOSE_LEVEL>8) fprintf(stdout,"<%s>\n",Header1+pos); break; case 0x0000000f: // filter { int k; char* ptr = Header1+pos; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; switch (beu32p(ptr)) { case 1: // lowpass hc->LowPass = strtod(ptr+4, &ptr); break; case 2: // high pass hc->HighPass = strtod(ptr+4, &ptr); break; default: fprintf(stderr,"Warning SOPEN (EBS): unknown filter\n"); } while (bei32p(ptr) != -1) ptr++; ptr += 4; } } break; } pos += len; tag = beu32p(hdr->AS.Header+pos); } hdr->HeadLen = pos; ifseek(hdr,pos,SEEK_SET); hdr->AS.first = 0; hdr->AS.length = 0; if ((bei64p(hdr->AS.Header+24)==-1) && (bei64p(hdr->AS.Header+24)==-1)) { /* if data length is not present */ struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->FILE.size = FileBuf.st_size; datalen = (hdr->FILE.size - hdr->HeadLen); } else datalen <<= 2; /** Encoded Signal Data (4*d bytes) **/ size_t spr = datalen/(2*hdr->NS); switch (EncodingID) { case TIB_16: hdr->SPR = 1; hdr->NRec = spr; hdr->FILE.LittleEndian = 0; break; case CIB_16: hdr->SPR = spr; hdr->NRec = 1; hdr->FILE.LittleEndian = 0; break; case TIL_16: hdr->SPR = 1; hdr->NRec = spr; hdr->FILE.LittleEndian = 1; break; case CIL_16: hdr->SPR = spr; hdr->NRec = 1; hdr->FILE.LittleEndian = 1; break; case TI_16D: case CI_16D: default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "EBS: unsupported Encoding"); return(hdr); } typeof(hdr->NS) k; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->GDFTYP = 3; // int16 hc->SPR = hdr->SPR; // int16 hc->bi = k*2; hc->Off = 0.0; hc->OnOff = 1; hc->DigMax = (double)32767; hc->DigMin = (double)-32768; hc->PhysMax = hc->DigMax*hc->Cal; hc->PhysMin = hc->DigMin*hc->Cal; hc->Transducer[0] = 0; hc->LeadIdCode = 0; hc->Notch = NAN; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; } hdr->AS.bpb = hdr->SPR*hdr->NS*2; /** Optional Second Variable Header **/ } else if (hdr->TYPE==EEG1100) { // the information of this format is derived from nk2edf-0.43beta-src of Teunis van Beelen if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [207]: \n"); char *fn = (char*)malloc((strlen(hdr->FileName)+5)*sizeof(char)); strcpy(fn, hdr->FileName); // Flawfinder: ignore char *LOG=NULL; /* read .pnt */ if (strrchr(fn,FILESEP)) strncpy(strrchr(fn,FILESEP)+1, (char*)(hdr->AS.Header + 32), 4); else strncpy(fn, (char*)(hdr->AS.Header + 32), 4); FILE *fid = fopen(fn,"rb"); if (fid != NULL) { count = 0; while (!feof(fid)) { size_t r = max(count*2, PAGESIZE); LOG = (char*) realloc(LOG,r+1); count += fread(LOG+count,1,r-count,fid); } fclose(fid); LOG[count] = 0; // Name: @0x062e if (!hdr->FLAG.ANONYMOUS) { strncpy(hdr->Patient.Name, LOG+0x62e, MAX_LENGTH_PID); hdr->Patient.Name[MAX_LENGTH_NAME] = 0; } // Id: @0x0604 strncpy(hdr->Patient.Id, LOG+0x604, MAX_LENGTH_PID); hdr->Patient.Id[MAX_LENGTH_PID] = 0; // Gender: @0x064a hdr->Patient.Sex = (toupper(LOG[0x064a])=='M') + 2*(toupper(LOG[0x064a])=='F') + 2*(toupper(LOG[0x064a])=='W'); // Birthday: @0x0660 sscanf((char*)(LOG+0x0660),"%04u/%02u/%02u",&tm_time.tm_year,&tm_time.tm_mon,&tm_time.tm_mday); tm_time.tm_hour = 12; tm_time.tm_min = 0; tm_time.tm_sec = 0; tm_time.tm_year -= 1900; tm_time.tm_mon--; tm_time.tm_isdst = -1; hdr->Patient.Birthday = tm_time2gdf_time(&tm_time); } if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [222]: \n"); size_t n1,n2,k2,pos1,pos2; n1 = hdr->AS.Header[145]; if ((n1*20+0x92) > count) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,n1*20+0x92+1); count += ifread(hdr->AS.Header+count, 1, n1*20+0x92-count,hdr); } // Start date: @0x0040 sscanf((char*)(hdr->AS.Header+0x40),"%04u%02u%02u%02u%02u%02u",&tm_time.tm_year,&tm_time.tm_mon,&tm_time.tm_mday,&tm_time.tm_hour,&tm_time.tm_min,&tm_time.tm_sec); tm_time.tm_year -= 1900; tm_time.tm_mon--; // Jan=0, Feb=1, ... tm_time.tm_isdst = -1; //hdr->T0 = tm_time2gdf_time(&tm_time); int TARGET_SEGMENT = hdr->FLAG.TARGETSEGMENT; int numSegments = 0; size_t Total_NRec = 0; uint8_t *h2 = (uint8_t*)malloc(22); uint8_t *h3 = (uint8_t*)malloc(40); for (k=0; k7) fprintf(stdout,"EEG1100 [232] %i: \n",(int)k); pos1 = leu32p(hdr->AS.Header+146+k*20); ifseek(hdr, pos1, SEEK_SET); ifread(h2, 1, 22, hdr); n2 = h2[17]; if (n2>1) { h2 = (uint8_t*)realloc(h2,2+n2*20); ifread(h2+22, 1, 2+n2*20-22, hdr); } if (reallocEventTable(hdr, hdr->EVENT.N+n2) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; for (k2=0; k2\n",pos3,(char*)h3+1); if (!strncmp((char*)h3+1,"TIME",4)) { sscanf((char*)(h3+5),"%02u%02u%02u",&tm_time.tm_hour,&tm_time.tm_min,&tm_time.tm_sec); } typeof(hdr->NS) NS = h3[38]; typeof(hdr->SampleRate) SampleRate = leu16p(h3+26) & 0x3fff; nrec_t NRec = (nrec_t)(leu32p(h3+28) * SampleRate * 0.1); size_t HeadLen = pos2 + 39 + 10*NS; hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; hdr->EVENT.POS[hdr->EVENT.N] = Total_NRec; hdr->EVENT.DUR[hdr->EVENT.N] = NRec; hdr->EVENT.CHN[hdr->EVENT.N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif Total_NRec += NRec; hdr->EVENT.N++; numSegments++; --TARGET_SEGMENT; // decrease target segment counter if (TARGET_SEGMENT != 0) { continue; } hdr->T0 = tm_time2gdf_time(&tm_time); hdr->NS = NS; hdr->SampleRate = SampleRate; hdr->EVENT.SampleRate = SampleRate; hdr->NRec = NRec; hdr->HeadLen = HeadLen; hdr->SPR = 1; int16_t gdftyp = 128; // Nihon-Kohden int16 format hdr->AS.bpb = ((hdr->NS*GDFTYP_BITS[gdftyp])>>3)+2; // fprintf(stdout,"NK k=%i <%s> k2=%i <%s>\n",k,h2+1,k2,h3+1); // fprintf(stdout,"[%i %i]:pos=%u (%x) length=%Li(%Lx).\n",k,k2,pos2,pos2,hdr->NRec*(hdr->NS+1)*2,hdr->NRec*(hdr->NS+1)*2); h3 = (uint8_t*)realloc(h3,32 + hdr->NS*10); pos3 += ifread(h3+pos3, 1, 32+hdr->NS*10 - pos3, hdr); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); int k3; for (k3=0; k3NS; k3++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k3; uint8_t u8 = h3[39+k3*10]; switch (u8) { case 0: strcpy(hc->Label,"Fp1"); break; case 1: strcpy(hc->Label,"Fp2"); break; case 2: strcpy(hc->Label,"F3"); break; case 3: strcpy(hc->Label,"F4"); break; case 4: strcpy(hc->Label,"C3"); break; case 5: strcpy(hc->Label,"C4"); break; case 6: strcpy(hc->Label,"P3"); break; case 7: strcpy(hc->Label,"P4"); break; case 8: strcpy(hc->Label,"O1"); break; case 9: strcpy(hc->Label,"O2"); break; case 10: strcpy(hc->Label,"F7"); break; case 11: strcpy(hc->Label,"F8"); break; case 12: strcpy(hc->Label,"T3"); break; case 13: strcpy(hc->Label,"T4"); break; case 14: strcpy(hc->Label,"T5"); break; case 15: strcpy(hc->Label,"T6"); break; case 16: strcpy(hc->Label,"Fz"); break; case 17: strcpy(hc->Label,"Cz"); break; case 18: strcpy(hc->Label,"Pz"); break; case 19: strcpy(hc->Label,"E"); break; case 20: strcpy(hc->Label,"PG1"); break; case 21: strcpy(hc->Label,"PG2"); break; case 22: strcpy(hc->Label,"A1"); break; case 23: strcpy(hc->Label,"A2"); break; case 24: strcpy(hc->Label,"T1"); break; case 25: strcpy(hc->Label,"T2"); break; case 74: strcpy(hc->Label,"BN1"); break; case 75: strcpy(hc->Label,"BN2"); break; case 76: strcpy(hc->Label,"Mark1"); break; case 77: strcpy(hc->Label,"Mark2"); break; case 100: strcpy(hc->Label,"X12/BP1"); break; case 101: strcpy(hc->Label,"X13/BP2"); break; case 102: strcpy(hc->Label,"X14/BP3"); break; case 103: strcpy(hc->Label,"X15/BP4"); break; case 254: strcpy(hc->Label,"-"); break; case 255: strcpy(hc->Label,"Z"); break; default: if ((25Label,"X%u",u8-25); else if ((36Label,"-"); else if ((41Label,"DC%02u",u8-41); else if ((77Label,"-"); else if ((103Label,"X%u",u8-88); } if ((41PhysDimCode = 4274; // mV hc->PhysMin = -12002.9; hc->PhysMax = 12002.56; } else { hc->PhysDimCode = 4275; // uV hc->PhysMin = -3200.0; hc->PhysMax = 3200.0*((1<<15)-1)/(1<<15); } hc->GDFTYP = 128; // Nihon-Kohden int16 format hc->DigMax = 32767.0; hc->DigMin = -32768.0; hc->Cal = (hc->PhysMax - hc->PhysMin) / (hc->DigMax - hc->DigMin); hc->Off = hc->PhysMin - hc->Cal * hc->DigMin; hc->SPR = 1; hc->LeadIdCode = 0; hc->OnOff = 1; hc->Transducer[0] = 0; hc->bi = (k3*GDFTYP_BITS[gdftyp])>>3; // hc->LowPass = 0.1; // hc->HighPass = 100; // hdr->CHANNEL[k3].Notch = 0; } } } free(h2); free(h3); ifseek(hdr, hdr->HeadLen, SEEK_SET); if ((numSegments>1) && (hdr->FLAG.TARGETSEGMENT==1)) fprintf(stdout,"File %s has more than one (%i) segment; use TARGET_SEGMENT argument to select other segments.\n",hdr->FileName,numSegments); if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [242]: <%s>\n",fn); /* read .log */ char *c = strrchr(fn,'.'); if (c != NULL) { strcpy(c+1,"log"); FILE *fid = fopen(fn,"rb"); if (fid == NULL) { strcpy(c+1,"LOG"); fid = fopen(fn,"rb"); } if (fid != NULL) { count = 0; while (!feof(fid)) { size_t c = max(2*count, 11520); LOG = (char*) realloc(LOG, c+1); count += fread(LOG+count, 1, c-count, fid); } fclose(fid); LOG[count]=0; for (k=0; k<(unsigned)LOG[145]; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [252]: %i,%i<%s>\n",(int)k,(int)count,fn); //uint32_t lba = leu32p(LOG+146+k*20); uint32_t lba = atoi(LOG+146+k*20); if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [253]: <%d> %d 0x%x\n",(int)k,lba,lba); //break; // FIXME: there is at least one EEG1100C file that breaks this uint32_t N = LOG[lba+18]; if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [254]: <%d> %d %d\n",(int)k,(int)lba,N); if (reallocEventTable(hdr, hdr->EVENT.N+N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; size_t k1; for (k1=0; k17) fprintf(stdout,"EEG1100 [257]: [%d,%d] N=%d,%d\n",(int)k,(int)k1,N,hdr->EVENT.N); if (VERBOSE_LEVEL>8) fprintf(stdout,"EEG1100 [258]: [%d,%d] N=%d, <%s>\n",(int)k,(int)k1,hdr->EVENT.N,(char*)(LOG+lba+20+k1*45)); // FreeTextEvent(hdr,hdr->EVENT.N,(char*)(LOG+lba+20+k1*45)); if (VERBOSE_LEVEL>7) { fprintf(stdout," <%s>\n <%s>\n",(char*)(LOG+lba+9+k1*45),(char*)(LOG+lba+29+k1*45)); int kk; for (kk=0; kk<45; kk++) putchar(LOG[lba+9+k1*45+kk]); putchar('\n'); } char *desc = (char*)(LOG+lba+9+k1*45); if (desc[0] == 0) continue; /* char secstr[7]; memcpy(secstr, LOG+lba+29+k1*45, 6); secstr[6] = 0; */ if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [259]: <%s> <%s>",desc,(char*)LOG+lba+29+k1*45); /* int c = sscanf((char*)(LOG+lba+46+k1*45),"(%02u%02u%02u%02u%02u%02u)",&tm_time.tm_year,&tm_time.tm_mon,&tm_time.tm_mday,&tm_time.tm_hour,&tm_time.tm_min,&tm_time.tm_sec); if (c<6) continue; tm_time.tm_year += tm_time.tm_year<20 ? 100:0; tm_time.tm_mon--; // Jan=0, Feb=1, ... gdf_time t0 = tm_time2gdf_time(&tm_time); char tmpstr[80]; strftime(tmpstr,80,"%Y-%m-%d %H:%M:%S", &tm_time); if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [261]: %s\n",tmpstr); */ if (1) //(t0 >= hdr->T0) { hdr->EVENT.TYP[hdr->EVENT.N] = 1; //hdr->EVENT.POS[hdr->EVENT.N] = (uint32_t)(ldexp(t0 - hdr->T0,-32)*86400*hdr->SampleRate); // 0-based indexing //hdr->EVENT.POS[hdr->EVENT.N] = (uint32_t)(atoi(strtok((char*)(LOG+lba+29+k1*45),"("))*hdr->SampleRate); hdr->EVENT.POS[hdr->EVENT.N] = (uint32_t)(atoi(strtok((char*)(LOG+lba+29+k1*45),"("))*hdr->SampleRate); hdr->EVENT.DUR[hdr->EVENT.N] = 0; hdr->EVENT.CHN[hdr->EVENT.N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif FreeTextEvent(hdr,hdr->EVENT.N,desc); hdr->EVENT.N++; } } } } } hdr->AS.auxBUF = (uint8_t*)LOG; free(fn); if (VERBOSE_LEVEL>7) fprintf(stdout,"EEG1100 [292]: \n"); } else if (hdr->TYPE==EEProbe) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "EEProbe currently not supported"); } else if (hdr->TYPE==EGI) { fprintf(stdout,"Reading EGI is under construction\n"); uint16_t NEC = 0; // specific for EGI format uint16_t gdftyp = 3; // BigEndian hdr->FILE.LittleEndian = 0; hdr->VERSION = beu32p(hdr->AS.Header); if (hdr->VERSION==2 || hdr->VERSION==3) gdftyp = 3; // int32 else if (hdr->VERSION==4 || hdr->VERSION==5) gdftyp = 16; // float else if (hdr->VERSION==6 || hdr->VERSION==7) gdftyp = 17; // double tm_time.tm_year = beu16p(hdr->AS.Header+4) - 1900; tm_time.tm_mon = beu16p(hdr->AS.Header+6) - 1; tm_time.tm_mday = beu16p(hdr->AS.Header+8); tm_time.tm_hour = beu16p(hdr->AS.Header+10); tm_time.tm_min = beu16p(hdr->AS.Header+12); tm_time.tm_sec = beu16p(hdr->AS.Header+14); // tm_time.tm_sec = beu32p(Header1+16)/1000; // not supported by tm_time hdr->T0 = tm_time2gdf_time(&tm_time); hdr->SampleRate = beu16p(hdr->AS.Header+20); hdr->NS = beu16p(hdr->AS.Header+22); // uint16_t Gain = beu16p(Header1+24); // not used uint16_t Bits = beu16p(hdr->AS.Header+26); uint16_t PhysMax= beu16p(hdr->AS.Header+28); size_t POS; if (hdr->AS.Header[3] & 0x01) { // Version 3,5,7 POS = 32; for (k=0; k < beu16p(hdr->AS.Header+30); k++) { char tmp[256]; int len = hdr->AS.Header[POS]; strncpy(tmp,Header1+POS,len); tmp[len]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"EGI categorie %i: <%s>\n",(int)k,tmp); POS += *(hdr->AS.Header+POS); // skip EGI categories if (POS > count-8) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,2*count); count += ifread(hdr->AS.Header,1,count,hdr); } } hdr->NRec= beu16p(hdr->AS.Header+POS); hdr->SPR = beu32p(hdr->AS.Header+POS+2); NEC = beu16p(hdr->AS.Header+POS+6); // EGI.N POS += 8; } else { // Version 2,4,6 hdr->NRec = beu32p(hdr->AS.Header+30); NEC = beu16p(hdr->AS.Header+34); // EGI.N hdr->SPR = 1; /* see also end-of-sopen hdr->AS.spb = hdr->SPR+NEC; hdr->AS.bpb = (hdr->NS + NEC)*GDFTYP_BITS[hdr->CHANNEL[0].GDFTYP]>>3; */ POS = 36; } /* read event code description */ hdr->AS.auxBUF = (uint8_t*) realloc(hdr->AS.auxBUF,5*NEC); hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,257*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0] = ""; // typ==0, is always empty hdr->EVENT.LenCodeDesc = NEC+1; for (k=0; k < NEC; k++) { memcpy(hdr->AS.auxBUF+5*k,Header1+POS,4); hdr->AS.auxBUF[5*k+4]=0; hdr->EVENT.CodeDesc[k+1] = (char*)hdr->AS.auxBUF+5*k; POS += 4; } hdr->HeadLen = POS; ifseek(hdr,hdr->HeadLen,SEEK_SET); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->GDFTYP = gdftyp; hc->PhysDimCode = 4275; // "uV" hc->LeadIdCode = 0; hc->Transducer[0] = 0; sprintf(hc->Label,"# %03i",(int)k); hc->Cal = PhysMax/ldexp(1,Bits); hc->Off = 0; hc->SPR = hdr->SPR; hc->bi = k*hdr->SPR*(GDFTYP_BITS[gdftyp]>>3); if (VERBOSE_LEVEL>8) fprintf(stdout,"SOPEN(EGI): #%i %i %i\n",(int)k,Bits, PhysMax); if (Bits && PhysMax) { hc->PhysMax = PhysMax; hc->PhysMin = -PhysMax; hc->DigMax = ldexp(1,Bits); hc->DigMin = ldexp(-1,Bits); } else { /* hc->PhysMax = PhysMax; hc->PhysMin = -PhysMax; hc->DigMax = ldexp(1,Bits); hc->DigMin = ldexp(-1,Bits); */ hc->Cal = 1.0; hc->OnOff = 1; } } hdr->AS.bpb = (hdr->NS*hdr->SPR + NEC) * (GDFTYP_BITS[gdftyp]>>3); if (hdr->AS.Header[3] & 0x01) // triggered hdr->AS.bpb += 6; size_t N = 0; if (NEC > 0) { /* read event information */ size_t sz = GDFTYP_BITS[gdftyp]>>3; uint8_t *buf = (uint8_t*)calloc(NEC, sz); uint8_t *buf8 = (uint8_t*)calloc(NEC*2, 1); size_t *ix = (size_t*)calloc(NEC, sizeof(size_t)); size_t skip = hdr->AS.bpb - NEC * sz; ifseek(hdr, hdr->HeadLen + skip, SEEK_SET); typeof(NEC) k1; nrec_t k; for (k=0; (k < hdr->NRec*hdr->SPR) && !ifeof(hdr); k++) { ifread(buf, sz, NEC, hdr); ifseek(hdr, skip, SEEK_CUR); int off0, off1; if (k & 0x01) { off0 = 0; off1=NEC; } else { off0 = NEC; off1=0; } memset(buf8+off1,0,NEC); // reset for (k1=0; k1 < NEC * sz; k1++) if (buf[k1]) buf8[ off1 + k1/sz ] = 1; for (k1=0; k1 < NEC ; k1++) { if (buf8[off1 + k1] && !buf8[off0 + k1]) { /* rising edge */ ix[k1] = k; } else if (!buf8[off1 + k1] && buf8[off0 + k1]) { /* falling edge */ if (N <= (hdr->EVENT.N + NEC*2)) { N += (hdr->EVENT.N+NEC)*2; // allocate memory for this and the terminating line. if (reallocEventTable(hdr, N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } hdr->EVENT.TYP[hdr->EVENT.N] = k1+1; hdr->EVENT.POS[hdr->EVENT.N] = ix[k1]; // 0-based indexing hdr->EVENT.CHN[hdr->EVENT.N] = 0; hdr->EVENT.DUR[hdr->EVENT.N] = k-ix[k1]; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif hdr->EVENT.N++; ix[k1] = 0; } } } for (k1 = 0; k1 < NEC; k1++) if (ix[k1]) { /* end of data */ hdr->EVENT.TYP[hdr->EVENT.N] = k1+1; hdr->EVENT.POS[hdr->EVENT.N] = ix[k1]; // 0-based indexing hdr->EVENT.CHN[hdr->EVENT.N] = 0; hdr->EVENT.DUR[hdr->EVENT.N] = k-ix[k1]; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif hdr->EVENT.N++; ix[k1] = 0; } hdr->EVENT.SampleRate = hdr->SampleRate; free(buf); free(buf8); free(ix); } ifseek(hdr,hdr->HeadLen,SEEK_SET); /* TODO: check EGI format */ } #ifdef WITH_EGIS else if (hdr->TYPE==EGIS) { fprintf(stdout,"Reading EGIS is under construction\n"); #if __BYTE_ORDER == __BIG_ENDIAN char FLAG_SWAP = hdr->FILE.LittleEndian; #elif __BYTE_ORDER == __LITTLE_ENDIAN char FLAG_SWAP = hdr->FILE.LittleEndian; #endif hdr->VERSION = *(int16_t*) mfer_swap8b(hdr->AS.Header+4, sizeof(int16_t), char FLAG_SWAP); hdr->HeadLen = *(uint16_t*) mfer_swap8b(hdr->AS.Header+6, sizeof(uint16_t), char FLAG_SWAP); //hdr->HeadLen = *(uint32_t*) mfer_swap8b(hdr->AS.Header+8, sizeof(uint32_t), char FLAG_SWAP); /* read file */ hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen+1); if (hdr->HeadLen > count) count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); hdr->AS.Header[count]=0; } #endif #ifdef WITH_EMBLA else if (hdr->TYPE==EMBLA) { while (!ifeof(hdr)) { size_t bufsiz = max(2*count, PAGESIZE); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); count = 48; int chan; uint32_t cal; float chan32; uint16_t pdc=0; while (count+8 < hdr->HeadLen) { uint32_t tag = leu32p(hdr->AS.Header+count); uint32_t len = leu32p(hdr->AS.Header+count+4); count+=8; /* uint32_t taglen[2]; uint32_t *tag = &taglen[0]; uint32_t *len = &taglen[1]; size_t c = ifread(taglen, 4, 2, hdr); if (ifeof(hdr)) break; */ if (VERBOSE_LEVEL > 7) { int ssz = min(80,len); char S[81]; strncpy(S, hdr->AS.Header+count, ssz); S[ssz]=0; fprintf(stdout,"tag %8d [%d]: <%s>\n",tag,len, S); } switch (tag) { case 32: hdr->SPR = len/2; // hdr->AS.rawdata = realloc(hdr->AS.rawdata,len); break; case 133: chan = leu16p(hdr->AS.Header+count); fprintf(stdout,"\tchan=%d\n",chan); break; case 134: // Sampling Rate hdr->SampleRate=leu32p(hdr->AS.Header+count)/1000.0; fprintf(stdout,"\tFs=%g #134\n",hdr->SampleRate); break; case 135: // cal=leu32p(hdr->AS.Header+count)/1000.0; hc->Cal = (cal==1 ? 1.0 : cal*1e-9); break; case 136: // session count fprintf(stdout,"\t%d (session count)\n",leu32p(hdr->AS.Header+count)); break; case 137: // Sampling Rate hdr->SampleRate=lef64p(hdr->AS.Header+count); fprintf(stdout,"\tFs=%g #137\n",hdr->SampleRate); break; case 141: chan32 = lef32p(hdr->AS.Header+count); fprintf(stdout,"\tchan32=%g\n",chan32); break; case 144: // Label strncpy(hc->Label, hdr->AS.Header+count, MAX_LENGTH_LABEL); hc->Label[min(MAX_LENGTH_LABEL,len)]=0; break; case 153: // Label pdc=PhysDimCode(hdr->AS.Header+count); fprintf(stdout,"\tpdc=0x%x\t<%s>\n",pdc,PhysDim3(pdc)); break; case 208: // Patient Name if (!hdr->FLAG.ANONYMOUS) strncpy(hdr->Patient.Name, hdr->AS.Header+count, MAX_LENGTH_NAME); hdr->Patient.Name[min(MAX_LENGTH_NAME,len)]=0; break; case 209: // Patient Name strncpy(hdr->Patient.Id, hdr->AS.Header+count, MAX_LENGTH_PID); hdr->Patient.Id[min(MAX_LENGTH_PID,len)]=0; break; default: ; } count+=len; } hdr->NS = 1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->OnOff = 1; hc->GDFTYP = 3; hc->SPR = hdr->SPR; hc->Cal = 0.1; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = NAN; hc->HighPass = NAN; hc->PhysMax = 3276.7; hc->PhysMin = -3276.8; hc->DigMax = 32767; hc->DigMin = -32768; hc->LeadIdCode = 0; hc->PhysDimCode = 4275; //uV hc->bi = k*hdr->SPR*2; char *label = (char*)(hdr->AS.Header+1034+k*512); const size_t len = min(16,MAX_LENGTH_LABEL); if ( (hdr->AS.Header[1025+k*512]=='E') && strlen(label)<13) { strcpy(hc->Label, "EEG "); strcat(hc->Label, label); // Flawfinder: ignore } else { strncpy(hc->Label, label, len); hc->Label[len]=0; } } } #endif // EMBLA else if (hdr->TYPE==EMSA) { hdr->NS = (uint8_t)hdr->AS.Header[3]; hdr->HeadLen = 1024 + hdr->NS*512; if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, hdr->HeadLen); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } if (count < hdr->HeadLen) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "EMSA file corrupted"); } hdr->HeadLen = count; sprintf(hdr->Patient.Id,"%05i",leu32p(hdr->AS.Header+4)); unsigned seq_nr = hdr->AS.Header[8]; uint16_t fs = leu16p(hdr->AS.Header+9); if (fs % 10) hdr->SPR = fs; else hdr->SPR = fs/10; hdr->AS.bpb = 2*hdr->NS*hdr->SPR; hdr->NRec = (hdr->FILE.size - hdr->HeadLen) / hdr->AS.bpb; hdr->SampleRate = fs; { struct tm t; char tmp[9]; // Birthday strncpy(tmp, (char*)(hdr->AS.Header+169), 8); for (k=0; k<8; k++) if (tmp[k]<'0' || tmp[k]>'9') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; tmp[8] = 0; t.tm_mday = atoi(tmp+6); tmp[6] = 0; t.tm_mon = atoi(tmp+4)-1; tmp[4] = 0; t.tm_year = atoi(tmp+4)-1900; t.tm_hour = 12; t.tm_min = 0; t.tm_sec = 0; hdr->Patient.Birthday = tm_time2gdf_time(&t); // startdate strncpy(tmp, (char*)hdr->AS.Header+205, 8); for (k=0; k<8; k++) if (tmp[k]<'0' || tmp[k]>'9') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; tmp[8] = 0; t.tm_mday = atoi(tmp+6); tmp[6] = 0; t.tm_mon = atoi(tmp+4)-1; tmp[4] = 0; t.tm_year = atoi(tmp+4)-1900; // starttime strncpy(tmp, (char*)hdr->AS.Header+214, 8); for (k=0; k<8; k++) { if ((k==2 || k==5) && tmp[k] != ':') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; else if (tmp[k]<'0' || tmp[k]>'9') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; } tmp[8] = 0; t.tm_sec = atoi(tmp+6); tmp[5] = 0; t.tm_min = atoi(tmp+3); tmp[2] = 0; t.tm_hour= atoi(tmp); hdr->T0 = tm_time2gdf_time(&t); if (hdr->AS.B4C_ERRNUM) biosigERROR(hdr, B4C_FORMAT_UNKNOWN, "Reading EMSA file failed - invalid data / time format"); } size_t len = min(MAX_LENGTH_NAME,30); strncpy(hdr->Patient.Name, (char*)hdr->AS.Header+11, len); hdr->Patient.Name[len]=0; // equipment len = min(MAX_LENGTH_MANUF,40); strncpy(hdr->ID.Manufacturer._field, (char*)hdr->AS.Header+309, len); hdr->ID.Manufacturer._field[len]=0; char c = toupper(hdr->AS.Header[203]); hdr->Patient.Sex = (c=='M') + (c=='F')*2; c = hdr->AS.Header[204]; hdr->Patient.Handedness = (c=='D') + (c=='E')*2; //D->1: right-handed, E->2: left-handed, 0 unknown hdr->Patient.Weight = atoi((char*)(hdr->AS.Header+351)); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->OnOff = 1; hc->GDFTYP = 3; hc->SPR = hdr->SPR; hc->Cal = 0.1; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = NAN; hc->HighPass = NAN; hc->PhysMax = 3276.7; hc->PhysMin = -3276.8; hc->DigMax = 32767; hc->DigMin = -32768; hc->LeadIdCode = 0; hc->PhysDimCode = 4275; //uV hc->bi = k*hdr->SPR*2; char *label = (char*)(hdr->AS.Header+1034+k*512); len = min(16,MAX_LENGTH_LABEL); if ( (hdr->AS.Header[1025+k*512]=='E') && strlen(label)<13) { strcpy(hc->Label, "EEG "); strcat(hc->Label, label); // Flawfinder: ignore } else { strncpy(hc->Label, label, len); hc->Label[len]=0; } } /* read event file */ char* tmpfile = (char*)calloc(strlen(hdr->FileName)+4, 1); strcpy(tmpfile, hdr->FileName); char* ext = strrchr(tmpfile,'.'); if (ext != NULL) strcpy(ext+1,"LBK"); // Flawfinder: ignore else strcat(tmpfile,".LBK"); // Flawfinder: ignore FILE *fid = fopen(tmpfile,"rb"); if (fid==NULL) { if (ext != NULL) strcpy(ext+1,"lbk"); else strcat(tmpfile,".lbk"); } if (fid != NULL) { size_t N_EVENTS = 0; const int sz = 69; char buf[sz+1]; hdr->EVENT.SampleRate = hdr->SampleRate; while (!feof(fid)) { if (fread(buf,sz,1,fid) <= 0) break; // starttime char *tmp = buf; for (k=0; k<8; k++) { if ((k==2 || k==5) && tmp[k] != ':') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; else if (tmp[k]<'0' || tmp[k]>'9') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; } tmp[2] = 0; tmp[5] = 0; tmp[8] = 0; size_t tstart = atoi(tmp)*3600 + atoi(tmp+3)*60 + atoi(tmp+6); fread(buf,sz,1,fid); // endtime tmp = buf+9; for (k=0; k<8; k++) { if ((k==2 || k==5) && tmp[k] != ':') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; else if (tmp[k]<'0' || tmp[k]>'9') biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); // error ; } tmp[2] = 0; tmp[5] = 0; tmp[8] = 0; size_t tend = atoi(tmp)*3600 + atoi(tmp+3)*60 + atoi(tmp+6); if (tend18 && isspace(buf[k])) k--; buf[k+1]=0; if (hdr->EVENT.N+2 >= N_EVENTS) { // memory allocation if needed N_EVENTS = max(128, N_EVENTS*2); if (reallocEventTable(hdr, N_EVENTS) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } FreeTextEvent(hdr,hdr->EVENT.N,(char*)buf); hdr->EVENT.POS[hdr->EVENT.N] = tstart*hdr->EVENT.SampleRate; hdr->EVENT.DUR[hdr->EVENT.N] = (tend-tstart)*hdr->EVENT.SampleRate; hdr->EVENT.CHN[hdr->EVENT.N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif hdr->EVENT.N++; } } free(tmpfile); } else if (hdr->TYPE==ePrime) { /* read file */ while (!ifeof(hdr)) { size_t bufsiz = max(2*count,1<<16); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); struct Target { size_t OnsetTime; size_t RTTime; size_t RT; size_t TrigTarget; uint8_t RESP; char *Stimulus; } Target; Target.RESP = 0xff; Target.Stimulus = NULL; Target.OnsetTime = 0; Target.RTTime = 0; Target.RT = 0; Target.TrigTarget = 0; int colSubject = -1, colSampleRate = -1, colDate = -1, colTime = -1, colOnsetTime = -1; int colResponseTime = -1, colRTTime = -1, colStimulus = -1, colTrigTarget = -1, colRESP = -1; size_t N_EVENTS = 0; struct tm t; char nextRow = 0; int col=0, row=0, len; char *f = (char*)hdr->AS.Header; while (*f != 0) { len = strcspn(f,"\t\n\r"); col++; if (f[len]==9) { nextRow = 0; } else if ( f[len]==10 || f[len]==13 || f[len]==0 ) { nextRow = 1; if (row>0) { if (hdr->EVENT.N+2 >= N_EVENTS) { // memory allocation if needed N_EVENTS = max(128, N_EVENTS*2); if (reallocEventTable(hdr, N_EVENTS) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } // add trigger event if (Target.Stimulus != NULL || Target.TrigTarget > 0) { if (Target.Stimulus) FreeTextEvent(hdr, hdr->EVENT.N, Target.Stimulus); else hdr->EVENT.TYP[hdr->EVENT.N] = Target.TrigTarget; hdr->EVENT.POS[hdr->EVENT.N] = Target.OnsetTime; hdr->EVENT.DUR[hdr->EVENT.N] = Target.RT; hdr->EVENT.CHN[hdr->EVENT.N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif hdr->EVENT.N++; } if (Target.RESP < 0x0f) { // add response event hdr->EVENT.TYP[hdr->EVENT.N] = Target.RESP + 0x0140; // eventcodes.txt: response codes are in the range between 0x0140 to 0x014f hdr->EVENT.POS[hdr->EVENT.N] = Target.OnsetTime + Target.RT; hdr->EVENT.CHN[hdr->EVENT.N] = 0; hdr->EVENT.DUR[hdr->EVENT.N] = 0; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif hdr->EVENT.N++; }; } if (VERBOSE_LEVEL>7) fprintf(stdout,"=======%i: %i\t%s\t%i\t%i\t%i\t%i\n", hdr->EVENT.N-1, (int)Target.TrigTarget, Target.Stimulus, (int)Target.OnsetTime, (int)Target.RT, (int)Target.RTTime, Target.RESP); Target.RESP = 0xff; Target.Stimulus = NULL; Target.OnsetTime = 0; Target.RTTime = 0; Target.RT = 0; Target.TrigTarget = 0; } f[len] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"r%i\tc%i\t%s\t%i\t%i\t%i\t%i\t%i\t%i\t%i\t%i\n",(int)row,(int)col,f,colSubject, colSampleRate, colDate, colTime, colOnsetTime, colResponseTime, colStimulus, colRTTime); if (row==0) { // decode header line if (!strcmp(f,"Subject")) { colSubject = col; } else if (!strcmp(f,"Display.RefreshRate")) { colSampleRate = col; } else if (!strcmp(f,"SessionDate")) { colDate = col; } else if (!strcmp(f,"SessionTime")) { colTime = col; } else if (strstr(f,"Target.OnsetTime")) { colOnsetTime = col; } else if (strstr(f,"Target.RTTime")) { colRTTime = col; } else if (strstr(f,"Target.RT")) { colResponseTime = col; } else if (!strcmp(f,"Stimulus")) { colStimulus = col; } else if (!strcmp(f,"TrigTarget")) { colTrigTarget = col; } else if (strstr(f,"Target.RESP")) { colRESP = col; } } else { // decode line of body if (row==1) { t.tm_isdst = 0; char *eptr; if (col==colTime) { t.tm_hour = strtol(f, &eptr, 10); t.tm_min = strtol(eptr+1, &eptr, 10); t.tm_sec = strtol(eptr+1, &eptr, 10); } else if (col==colDate) { t.tm_mon = strtol(f, &eptr, 10)-1; t.tm_mday = strtol(eptr+1, &eptr, 10); t.tm_year = strtol(eptr+1, &eptr, 10)-1900; } else if (col==colSubject) { strncpy(hdr->Patient.Id, f, MAX_LENGTH_PID); } else if (col==colSampleRate) { hdr->EVENT.SampleRate = atof(f); } } if (col==colOnsetTime) { Target.OnsetTime = atol(f); } else if (col==colResponseTime) { Target.RT = atoi(f); } else if (col==colRTTime) { Target.RTTime = atol(f); } else if (col==colStimulus) { Target.Stimulus = f; } else if (col==colTrigTarget) { Target.TrigTarget = atoi(f); } else if ((col==colRESP) && strlen(f)) { Target.RESP = atoi(f); } } f += len+1; if (nextRow) { f += strspn(f,"\n\r"); row += nextRow; col = 0; } }; hdr->T0 = tm_time2gdf_time(&t); } else if (hdr->TYPE==SigViewerEventsCSV) { while (!ifeof(hdr)) { size_t bufsiz = max(2*count,1<<16); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); // position,duration,channel,type,name size_t N_EVENT=0,N=0; char *nextLine=NULL; char *line = strtok_r(hdr->AS.Header, "\n\r", &nextLine); // skip first line while (line != NULL) { line = strtok_r(NULL, "\n\r" ,&nextLine); if (line==NULL) break; char *nextToken=NULL; char *tok1 = strtok_r(line, ",", &nextToken); char *tok2 = strtok_r(NULL, ",", &nextToken); char *tok3 = strtok_r(NULL, ",", &nextToken); char *tok4 = strtok_r(NULL, ",", &nextToken); char *tok5 = strtok_r(NULL, ",", &nextToken); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): <%s> <%s> <%s> <%s> <%s>\n",__FILE__,__LINE__, tok1,tok2,tok3,tok4,tok5); if (!tok1 || !tok2 || !tok3 || !tok4) continue; if (N_EVENT <= N) { N_EVENT = reallocEventTable(hdr, max(256,N_EVENT*2)); if (N_EVENT == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } hdr->EVENT.POS[N] = (uint32_t)atol(tok1); hdr->EVENT.DUR[N] = (uint32_t)atol(tok2); int CHN = atoi(tok3); hdr->EVENT.CHN[N] = (CHN < 0) ? 0 : CHN+1; if (hdr->NS < CHN) hdr->NS = CHN+1; uint16_t TYP = (uint16_t)atoi(tok4); hdr->EVENT.TYP[N] = TYP; // read free text event description if ((0 < TYP) && (TYP < 255)) { if (hdr->EVENT.LenCodeDesc==0) { // allocate memory hdr->EVENT.LenCodeDesc = 257; hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,257*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0] = ""; // typ==0, is always empty for (k=0; k<=256; k++) hdr->EVENT.CodeDesc[k] = NULL; } if (hdr->EVENT.CodeDesc[TYP]==NULL) hdr->EVENT.CodeDesc[TYP] = tok5; } if (TYP>0) N++; // skip events with TYP==0 } hdr->AS.auxBUF=hdr->AS.Header; hdr->AS.Header=NULL; hdr->EVENT.SampleRate = NAN; hdr->EVENT.N = N; hdr->TYPE = EVENT; hdr->NS = 0; } else if (hdr->TYPE==ET_MEG) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "FLT/ET-MEG format not supported"); } else if (hdr->TYPE==ETG4000) { /* read file */ while (!ifeof(hdr)) { size_t bufsiz = max(2*count,1<<16); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; ifclose(hdr); if (VERBOSE_LEVEL==9) fprintf(stdout,"Size of File %s is %i\n",hdr->FileName,(int)count); /* decode header section */ char dlm[2]; dlm[0] = (char)hdr->AS.Header[20]; dlm[1] = 0; hdr->VERSION = -1; char FLAG_StimType_STIM = 0; char *t = strtok((char*)hdr->AS.Header,"\xA\xD"); char *ag=NULL, *dg=NULL, *label; double lpf=-1.0,hpf=-1.0,age=0.0; while (strncmp(t,"Probe",5)) { if (VERBOSE_LEVEL==9) fprintf(stderr,"-> %s\n",t); if (!strncmp(t,"File Version",12)) hdr->VERSION = atof(strpbrk(t,dlm)+1); else if (!strncmp(t,"Name",4)) strncpy(hdr->Patient.Id,strpbrk(t,dlm)+1,MAX_LENGTH_PID); else if (!strncmp(t,"Sex",3)) hdr->Patient.Sex = ((toupper(*strpbrk(t,dlm)+1)=='F')<<1) + (toupper(*strpbrk(t,dlm)+1)=='M'); else if (!strncmp(t,"Age",3)) { char *tmp1 = strpbrk(t,dlm)+1; size_t c = strcspn(tmp1,"0123456789"); char buf[20]; age = atof(strncpy(buf,tmp1,19)); if (tmp1[c]=='y') age *= 365.25; else if (tmp1[c]=='m') age *= 30; } else if (!strncmp(t,"Date",4)) { sscanf(strpbrk(t,dlm)+1,"%d/%d/%d %d:%d",&(tm_time.tm_year),&(tm_time.tm_mon),&(tm_time.tm_mday),&(tm_time.tm_hour),&(tm_time.tm_min)); tm_time.tm_sec = 0; tm_time.tm_year -= 1900; tm_time.tm_mon -= 1; hdr->T0 = tm_time2gdf_time(&tm_time); } else if (!strncmp(t,"HPF[Hz]",7)) hpf = atof(strpbrk(t,dlm)+1); else if (!strncmp(t,"LPF[Hz]",7)) lpf = atof(strpbrk(t,dlm)+1); else if (!strncmp(t,"Analog Gain",11)) ag = strpbrk(t,dlm); else if (!strncmp(t,"Digital Gain",12)) dg = strpbrk(t,dlm)+1; else if (!strncmp(t,"Sampling Period[s]",18)) hdr->SampleRate = 1.0/atof(strpbrk(t,dlm)+1); else if (!strncmp(t,"StimType",8)) FLAG_StimType_STIM = !strncmp(t+9,"STIM",4); t = strtok(NULL,"\xA\xD"); } if (VERBOSE_LEVEL==9) fprintf(stderr,"\nNS=%i\n-> %s\n",hdr->NS,t); hdr->Patient.Birthday = hdr->T0 - (uint64_t)ldexp(age,32); hdr->NS = 0; while (ag != NULL) { ++hdr->NS; ag = strpbrk(ag+1,dlm); } hdr->NS >>= 1; if (VERBOSE_LEVEL==9) fprintf(stderr,"\n-V=%i NS=%i\n-> %s\n",VERBOSE_LEVEL,hdr->NS,t); label = strpbrk(t,dlm) + 1; //uint16_t gdftyp = 16; // use float32 as internal buffer uint16_t gdftyp = 17; // use float64 as internal buffer double DigMax = 1.0, DigMin = -1.0; hdr->FLAG.OVERFLOWDETECTION = 0; // automated overflow and saturation detection not supported hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->OnOff = 1; hc->GDFTYP = gdftyp; hc->SPR = 1; hc->Cal = 1.0; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = lpf; hc->HighPass = hpf; hc->PhysMax = DigMax; hc->PhysMin = DigMin; hc->DigMax = DigMax; hc->DigMin = DigMin; hc->LeadIdCode = 0; hc->PhysDimCode = 65362; //mmol l-1 mm hc->bi = k*GDFTYP_BITS[gdftyp]>>3; size_t c = strcspn(label,dlm); size_t c1 = min(c,MAX_LENGTH_LABEL); strncpy(hc->Label, label, c1); hc->Label[c1]= 0; label += c+1; if (VERBOSE_LEVEL>8) fprintf(stderr,"-> Label #%02i: len(%i) %s\n",(int)k,(int)c1,hc->Label); } hdr->SPR = 1; hdr->NRec = 0; hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]>>3; /* decode data section */ // hdr->FLAG.SWAP = 0; hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); uint32_t pos; int Mark=0,hh,mm,ss,ds,BodyMovement,RemovalMark,PreScan; size_t NEV = 16; hdr->EVENT.N = 0; hdr->EVENT.SampleRate = hdr->SampleRate; hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; pos = atol(strtok(NULL,dlm)); while (pos) { hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata, (((size_t)hdr->NRec+1) * hdr->NS * GDFTYP_BITS[gdftyp])>>3); for (k=0; k < hdr->NS; k++) { if (gdftyp==16) *(float*)(hdr->AS.rawdata + (((size_t)hdr->NRec*hdr->NS+k)*(GDFTYP_BITS[gdftyp]>>3))) = (float)atof(strtok(NULL,dlm)); else if (gdftyp==17) *(double*)(hdr->AS.rawdata + (((size_t)hdr->NRec*hdr->NS+k)*(GDFTYP_BITS[gdftyp]>>3))) = atof(strtok(NULL,dlm)); } ++hdr->NRec; Mark = atoi(strtok(NULL,dlm)); if (Mark) { if (hdr->EVENT.N+1 >= NEV) { NEV<<=1; // double allocated memory hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, NEV*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, NEV*sizeof(*hdr->EVENT.TYP) ); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*)realloc(hdr->EVENT.TimeStamp, NEV*sizeof(gdf_time)); #endif } hdr->EVENT.POS[hdr->EVENT.N] = pos; // 0-based indexing hdr->EVENT.TYP[hdr->EVENT.N] = Mark; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = 0; #endif if (FLAG_StimType_STIM && !(hdr->EVENT.N & 0x01)) hdr->EVENT.TYP[hdr->EVENT.N] = Mark | 0x8000; ++hdr->EVENT.N; } sscanf(strtok(NULL,dlm),"%d:%d:%d.%d",&hh,&mm,&ss,&ds); BodyMovement = atoi(strtok(NULL,dlm)); RemovalMark = atoi(strtok(NULL,dlm)); PreScan = atoi(strtok(NULL,"\xA\xD")); if (VERBOSE_LEVEL>8) fprintf(stdout,"%d: %d %02d:%02d:%02d.%02d %d %d %d\n",pos,Mark,hh,mm,ss,ds,BodyMovement,RemovalMark,PreScan); pos = atol(strtok(NULL,dlm)); }; if (FLAG_StimType_STIM && (hdr->EVENT.N & 0x01)) { /* if needed, add End-Of-Event marker */ ++hdr->EVENT.N; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP) ); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*)realloc(hdr->EVENT.TimeStamp, hdr->EVENT.N*sizeof(gdf_time)); hdr->EVENT.TimeStamp[hdr->EVENT.N-1] = 0; #endif hdr->EVENT.POS[hdr->EVENT.N-1] = pos; // 0-based indexing hdr->EVENT.TYP[hdr->EVENT.N-1] = Mark | 0x8000; } hdr->AS.length = hdr->NRec; } #ifdef WITH_FAMOS else if (hdr->TYPE==FAMOS) { hdr->HeadLen=count; sopen_FAMOS_read(hdr); } #endif else if (hdr->TYPE==FEF) { #ifdef WITH_FEF size_t bufsiz = 1l<<24; while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count+bufsiz+1); count += ifread(hdr->AS.Header+count,1,bufsiz,hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; char tmp[9]; tmp[8] = 0; memcpy(tmp, hdr->AS.Header+8, 8); hdr->VERSION = atol(tmp)/100.0; memcpy(tmp, hdr->AS.Header+24, 8); hdr->FILE.LittleEndian = !atol(tmp); ifseek(hdr,32,SEEK_SET); if (VERBOSE_LEVEL>7) fprintf(stdout,"ASN1 [401] %i\n",(int)count); sopen_fef_read(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"ASN1 [491]\n"); #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "VITAL/FEF Format not supported"); return(hdr); #endif } else if (hdr->TYPE==FIFF) { hdr->HeadLen = count; sopen_fiff_read(hdr); } else if (hdr->TYPE==HDF) { #ifdef WITH_HDF if (sopen_hdf5(hdr) != 0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error reading HDF file"); } #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format HDF not supported"); ifclose(hdr); #endif return(hdr); } else if (hdr->TYPE==HEKA) { // HEKA PatchMaster file format hdr->HeadLen = count; FILE *itx = fopen((char*)hdr->aECG, "w"); hdr->aECG = NULL; // reset auxillary pointer sopen_heka(hdr, itx); if (itx) fclose(itx); } else if (hdr->TYPE==IBW) { struct stat FileBuf; stat(hdr->FileName, &FileBuf); hdr->FILE.size = FileBuf.st_size; sopen_ibw_read(hdr); } else if (hdr->TYPE==ITX) { sopen_itx_read(hdr); } else if (hdr->TYPE==ISHNE) { char flagANN = !strncmp((char*)hdr->AS.Header,"ANN",3); fprintf(stderr,"Warning SOPEN(ISHNE): support for ISHNE format is experimental\n"); // unknown, generic, X,Y,Z, I-VF, V1-V6, ES, AS, AI uint16_t Table1[] = {0,0,16,17,18,1,2,87,88,89,90,3,4,5,6,7,8,131,132,133}; size_t len; struct tm t; hdr->HeadLen = lei32p(hdr->AS.Header+22); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } hdr->HeadLen = count; if (VERBOSE_LEVEL>6) { fprintf(stdout,"SOPEN(ISNHE): @%p %i\n",hdr->AS.Header,hdr->HeadLen); fprintf(stdout,"SOPEN(ISNHE): @%p %x %x %x %x %x %x\n",hdr->AS.Header,hdr->AS.Header[132],hdr->AS.Header[133],hdr->AS.Header[134],hdr->AS.Header[135],hdr->AS.Header[136],hdr->AS.Header[137]); for (k=0;k<522;k++) { fprintf(stdout,"%02x ",hdr->AS.Header[k]); if (k%32==0) fputc('\n',stdout); } } //int offsetVarHdr = lei32p(hdr->AS.Header+18); hdr->VERSION = (float)lei16p(hdr->AS.Header+26); if (!hdr->FLAG.ANONYMOUS) { len = min(40, MAX_LENGTH_NAME); char *s; s = (char*)(hdr->AS.Header+68); // lastname size_t slen = strlen(s); int len1 = min(40, slen); strncpy(hdr->Patient.Name, s, len1); hdr->Patient.Name[len1] = 0x1f; // unit separator ascii(31) s = (char*)(hdr->AS.Header+28); // firstname int len2 = min(strlen(s), MAX_LENGTH_NAME-len-1); strncpy(hdr->Patient.Name+len1+1, s, len2); hdr->Patient.Name[len1+len2+1] = 0; } len = min(20, MAX_LENGTH_PID); strncpy(hdr->Patient.Id, (char*)(hdr->AS.Header+108), len); hdr->Patient.Id[len] = 0; hdr->Patient.Sex = lei16p(hdr->AS.Header+128); // Race = lei16p(hdr->AS.Header+128); t.tm_mday = lei16p(hdr->AS.Header + 132); t.tm_mon = lei16p(hdr->AS.Header + 134) - 1; t.tm_year = lei16p(hdr->AS.Header + 136) - 1900; t.tm_hour = 12; t.tm_min = 0; t.tm_sec = 0; t.tm_isdst = 0; if (VERBOSE_LEVEL>6) { fprintf(stdout,"SOPEN(ISNHE): Birthday: %04i-%02i-%02i %02i:%02i:%02i\n",t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec); fprintf(stdout,"SOPEN(ISNHE): @%p %x %x %x %x %x %x\n",hdr->AS.Header,hdr->AS.Header[132],hdr->AS.Header[133],hdr->AS.Header[134],hdr->AS.Header[135],hdr->AS.Header[136],hdr->AS.Header[137]); } if (t.tm_mday>0 && t.tm_mon>=0 && t.tm_year>=0) hdr->Patient.Birthday = tm_time2gdf_time(&t); t.tm_mday = leu16p(hdr->AS.Header + 138); t.tm_mon = leu16p(hdr->AS.Header + 140)-1; t.tm_year = leu16p(hdr->AS.Header + 142)-1900; t.tm_hour = leu16p(hdr->AS.Header + 150); t.tm_min = leu16p(hdr->AS.Header + 152); t.tm_sec = leu16p(hdr->AS.Header + 154); hdr->T0 = tm_time2gdf_time(&t); hdr->NS = lei16p(hdr->AS.Header + 156); hdr->AS.bpb= hdr->NS * 2; hdr->SPR = 1; hdr->SampleRate = lei16p(hdr->AS.Header + 272); hdr->Patient.Impairment.Heart = lei16p(hdr->AS.Header+230) ? 3 : 0; // Pacemaker { struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->FILE.size = FileBuf.st_size; } if (flagANN) { hdr->NRec=0; hdr->EVENT.N = (hdr->FILE.size - hdr->HeadLen)/4; hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, hdr->EVENT.N * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, hdr->EVENT.N * sizeof(*hdr->EVENT.POS)); /* define user specified events according to ECG Annotation format of http://thew-project.org/THEWFileFormat.htm */ hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,10*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0]=""; hdr->EVENT.CodeDesc[1]="Normal beat"; hdr->EVENT.CodeDesc[2]="Premature ventricular contraction"; hdr->EVENT.CodeDesc[3]="Supraventricular premature or ectopic beat"; hdr->EVENT.CodeDesc[4]="Calibration Pulse"; hdr->EVENT.CodeDesc[5]="Bundle branch block beat"; hdr->EVENT.CodeDesc[6]="Pace"; hdr->EVENT.CodeDesc[7]="Artfact"; hdr->EVENT.CodeDesc[8]="Unknown"; hdr->EVENT.CodeDesc[9]="NULL"; hdr->EVENT.LenCodeDesc = 9; uint8_t evt[4]; ifseek(hdr, lei32p(hdr->AS.Header+22), SEEK_SET); size_t N = 0, pos=0; while (!ifeof(hdr)) { if (!ifread(evt, 1, 4, hdr)) break; uint16_t typ = 8; switch ((char)(evt[0])) { case 'N': typ = 1; break; case 'V': typ = 2; break; case 'S': typ = 3; break; case 'C': typ = 4; break; case 'B': typ = 5; break; case 'P': typ = 6; break; case 'X': typ = 7; break; case '!': typ = 0x7ffe; break; case 'U': typ = 8; break; default: continue; } pos += leu16p(evt+2); hdr->EVENT.POS[N] = pos; hdr->EVENT.TYP[N] = typ; N++; } hdr->EVENT.N = N; } else { hdr->EVENT.N = 0; hdr->NRec = min(leu32p(hdr->AS.Header+14), (hdr->FILE.size - hdr->HeadLen)/hdr->AS.bpb ); } hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->OnOff = 1; if (hdr->VERSION == 1) { hc->GDFTYP = 3; //int16 - 2th complement hc->DigMax = (double)(int16_t)(0x7fff); hc->DigMin = (double)(int16_t)(0x8000); } else { hc->GDFTYP = 4; //uint16 hc->DigMax = (double)(uint16_t)(0xffff); hc->DigMin = (double)(uint16_t)(0x0000); } hc->SPR = 1; hc->Cal = lei16p(hdr->AS.Header + 206 + 2*k); hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = NAN; hc->HighPass = NAN; hc->PhysMax = hc->Cal * hc->DigMax; hc->PhysMin = hc->Cal * hc->DigMin; hc->LeadIdCode = Table1[lei16p(hdr->AS.Header + 158 + 2*k)]; hc->PhysDimCode = 4276; // nV hc->bi = k*2; strcpy(hc->Label, LEAD_ID_TABLE[hc->LeadIdCode]); } ifseek(hdr, lei32p(hdr->AS.Header+22), SEEK_SET); hdr->FILE.POS = 0; } else if (hdr->TYPE==Matlab) { #ifdef HAVE_MATIO if (sopen_matlab(hdr) != 0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error reading MATLAB file"); } #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format MAT not supported"); ifclose(hdr); #endif return(hdr); } else if (hdr->TYPE==MFER) { /* // ISO/TS 11073-92001:2007(E), Table 5, p.9 physicalunits({'V','mmHg','Pa','cm H2O', 'mmHg s-1','dyn','N','%','°C','min-1','s-1','Ohm','A','rpm','W','dB','kg','J','dyne s m-2 cm-5','l','l s-1','l min-1','cd'}) */ const uint16_t MFER_PhysDimCodeTable[30] = { 4256, 3872, 3840, 3904,65330, // Volt, mmHg, Pa, mmH2O, mmHg/s 3808, 3776, 544, 6048, 2528, // dyne, N, %, °C, 1/min 4264, 4288, 4160,65376, 4032, // 1/s, Ohm, A, rpm, W 6448, 1731, 3968, 6016, 1600, // dB, kg, J, dyne s m-2 cm-5, l 3040, 3072, 4480, 0, 0, // l/s, l/min, cd 0, 0, 0, 0, 0, // }; hdr->FLAG.OVERFLOWDETECTION = 0; // MFER does not support automated overflow and saturation detection uint8_t buf[128]; void* ptrbuf = buf; uint8_t gdftyp = 3; // default: int16 uint8_t UnitCode=0; double Cal = 1.0, Off = 0.0; char SWAP = ( __BYTE_ORDER == __LITTLE_ENDIAN); // default of MFER is BigEndian hdr->FILE.LittleEndian = 0; hdr->SampleRate = 1000; // default sampling rate is 1000 Hz hdr->NS = 1; // default number of channels is 1 /* TAG */ uint8_t tag = hdr->AS.Header[0]; ifseek(hdr,1,SEEK_SET); int curPos = 1; size_t N_EVENT=0; // number of events, memory is allocated for in the event table. while (!ifeof(hdr)) { uint32_t len, val32=0; int32_t chan=-1; uint8_t tmplen; if (tag==255) break; else if (tag==63) { /* CONTEXT */ curPos += ifread(buf,1,1,hdr); chan = buf[0] & 0x7f; while (buf[0] & 0x80) { curPos += ifread(buf,1,1,hdr); chan = (chan<<7) + (buf[0] & 0x7f); } } /* LENGTH */ curPos += ifread(&tmplen,1,1,hdr); char FlagInfiniteLength = 0; if ((tag==63) && (tmplen==0x80)) { FlagInfiniteLength = -1; //Infinite Length len = 0; } else if (tmplen & 0x80) { tmplen &= 0x7f; curPos += ifread(&buf,1,tmplen,hdr); len = 0; k = 0; while (k7) fprintf(stdout,"MFER: tag=%3i chan=%2i len=%i %3i curPos=%i %li\n",tag,chan,tmplen,len,curPos,iftell(hdr)); /* VALUE */ if (tag==0) { if (len!=1) fprintf(stderr,"Warning MFER tag0 incorrect length %i!=1\n",len); curPos += ifread(buf,1,len,hdr); } else if (tag==1) { // Endianity if (len!=1) fprintf(stderr,"Warning MFER tag1 incorrect length %i!=1\n",len); ifseek(hdr,len-1,SEEK_CUR); curPos += ifread(buf,1,1,hdr); hdr->FILE.LittleEndian = buf[0]; #if (__BYTE_ORDER == __BIG_ENDIAN) SWAP = hdr->FILE.LittleEndian; #elif (__BYTE_ORDER == __LITTLE_ENDIAN) SWAP = !hdr->FILE.LittleEndian; #endif } else if (tag==2) { // Version uint8_t v[3]; if (len!=3) fprintf(stderr,"Warning MFER tag2 incorrect length %i!=3\n",len); curPos += ifread(&v,1,3,hdr); hdr->VERSION = v[0] + (v[1]<10 ? v[1]/10.0 : (v[1]<100 ? v[1]/100.0 : v[1]/1000.0)); } else if (tag==3) { // character code char v[17]; if (len>16) fprintf(stderr,"Warning MFER tag2 incorrect length %i>16\n",len); curPos += ifread(&v,1,len,hdr); v[len] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: character code <%s>\n",v); } else if (tag==4) { // SPR if (len>4) fprintf(stderr,"Warning MFER tag4 incorrect length %i>4\n",len); curPos += ifread(buf,1,len,hdr); hdr->SPR = *(int64_t*) mfer_swap8b(buf, len, SWAP); if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i \n",tag,len,(int)hdr->SPR); } else if (tag==5) //0x05: number of channels { uint16_t oldNS=hdr->NS; if (len>4) fprintf(stderr,"Warning MFER tag5 incorrect length %i>4\n",len); curPos += ifread(buf,1,len,hdr); hdr->NS = *(int64_t*) mfer_swap8b(buf, len, SWAP); if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i \n",tag,len,(int)hdr->NS); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); for (k=oldNS; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->SPR = 0; hc->PhysDimCode = 4275; // uV : default value in Table 5, ISO/FDIS 22077-1(E)ISO/WD 22077-1 hc->Cal = 1.0; hc->Off = 0.0; hc->OnOff = 1; hc->LeadIdCode = 0; hc->GDFTYP = 3; hc->Transducer[0] = 0; } } else if (tag==6) // 0x06 "number of sequences" { // NRec if (len>4) fprintf(stderr,"Warning MFER tag6 incorrect length %i>4\n",len); curPos += ifread(buf,1,len,hdr); hdr->NRec = *(int64_t*) mfer_swap8b(buf, len, SWAP); if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i \n",tag,len,(int)hdr->NRec); } else if (tag==8) { if (len>2) fprintf(stderr,"Warning MFER tag8 incorrect length %i>2\n",len); curPos += ifread(buf,1,len,hdr); /* // NOT USED // Type of Waveform union { uint8_t TypeOfWaveForm8[2]; uint16_t TypeOfWaveForm; } t; if (len==1) t.TypeOfWaveForm = buf[0]; else { t.TypeOfWaveForm8[0] = buf[0]; t.TypeOfWaveForm8[1] = buf[1]; if (SWAP) t.TypeOfWaveForm = bswap_16(t.TypeOfWaveForm); } */ } else if (tag==10) { // GDFTYP if (len!=1) fprintf(stderr,"warning MFER tag10 incorrect length %i!=1\n",len); curPos += ifread(&gdftyp,1,1,hdr); if (gdftyp==0) gdftyp=3; // int16 else if (gdftyp==1) gdftyp=4; // uint16 else if (gdftyp==2) gdftyp=5; // int32 else if (gdftyp==3) gdftyp=2; // uint8 else if (gdftyp==4) gdftyp=4; // bit16 else if (gdftyp==5) gdftyp=1; // int8 else if (gdftyp==6) gdftyp=6; // uint32 else if (gdftyp==7) gdftyp=16; // float32 else if (gdftyp==8) gdftyp=17; // float64 else if (gdftyp==9) //gdftyp=2; // 8 bit AHA compression fprintf(stdout,"Warning: MFER compressed format not supported\n"); else gdftyp=3; } else if (tag==11) //0x0B { // Fs if (len>6) fprintf(stderr,"Warning MFER tag11 incorrect length %i>6\n",len); double fval; curPos += ifread(buf,1,len,hdr); fval = *(int64_t*) mfer_swap8b(buf+2, len-2, SWAP); hdr->SampleRate = fval*pow(10.0, (int8_t)buf[1]); if (buf[0]==1) // s hdr->SampleRate = 1.0/hdr->SampleRate; if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i %i %g \n",tag,len,buf[0], buf[1], hdr->SampleRate); } else if (tag==12) //0x0C { // sampling resolution if (len>6) fprintf(stderr,"Warning MFER tag12 incorrect length %i>6\n",len); val32 = 0; int8_t v8; curPos += ifread(&UnitCode,1,1,hdr); curPos += ifread(&v8,1,1,hdr); curPos += ifread(buf,1,len-2,hdr); Cal = *(int64_t*) mfer_swap8b(buf, len-2, SWAP); Cal *= pow(10.0,v8); if (!MFER_PhysDimCodeTable[UnitCode]) fprintf(stderr,"Warning MFER: unsupported physical unit (code=%i)\n", UnitCode); } else if (tag==13) { if (len>8) fprintf(stderr,"Warning MFER tag13 incorrect length %i>8\n",len); curPos += ifread(&buf,1,len,hdr); if (gdftyp == 1) Off = ( int8_t)buf[0]; else if (gdftyp == 2) Off = (uint8_t)buf[0]; else if (SWAP) { if (gdftyp == 3) Off = ( int16_t)bswap_16(*( int16_t*)ptrbuf); else if (gdftyp == 4) Off = (uint16_t)bswap_16(*(uint16_t*)ptrbuf); else if (gdftyp == 5) Off = ( int32_t)bswap_32(*( int32_t*)ptrbuf); else if (gdftyp == 6) Off = (uint32_t)bswap_32(*(uint32_t*)ptrbuf); else if (gdftyp == 7) Off = ( int64_t)bswap_64(*( int64_t*)ptrbuf); else if (gdftyp == 8) Off = (uint64_t)bswap_64(*(uint64_t*)ptrbuf); else if (gdftyp ==16) { *(uint32_t*)ptrbuf = bswap_32(*(uint32_t*)ptrbuf); Off = *(float*)ptrbuf; } else if (gdftyp ==17) { *(uint64_t*)ptrbuf = bswap_64(*(uint64_t*)ptrbuf); Off = *(double*)ptrbuf; } } else { if (gdftyp == 3) Off = *( int16_t*)ptrbuf; else if (gdftyp == 4) Off = *(uint16_t*)ptrbuf; else if (gdftyp == 5) Off = *( int32_t*)ptrbuf; else if (gdftyp == 6) Off = *(uint32_t*)ptrbuf; else if (gdftyp == 7) Off = *( int64_t*)ptrbuf; else if (gdftyp == 8) Off = *(uint64_t*)ptrbuf; else if (gdftyp ==16) Off = *(float*)ptrbuf; else if (gdftyp ==17) Off = *(double*)ptrbuf; } } else if (tag==22) { // MWF_NTE (16h): Comment char buf[257]; ifread(buf,1,min(256,len),hdr); buf[min(256,len)]=0; if (VERBOSE_LEVEL > 7) fprintf(stdout,"MFER comment (tag=22): %s\n",buf); size_t POS=0, CHN=0; const char *Desc = NULL; char *ptrP1 = strstr(buf,""); if (ptrP2) { *ptrP2=0; ptrP2++; POS = atol(ptrP1); Desc = ptrP2; } } char *ptrP3 = strstr(buf,""); if (ptrP2) { *ptrP2=0; ptrP2++; CHN = strtol(ptrP3, &ptrP3, 10); } } if (POS>0 && Desc) { size_t N = hdr->EVENT.N; if (N_EVENT <= N) { N_EVENT = reallocEventTable(hdr, N_EVENT); if (N_EVENT == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } hdr->EVENT.POS[N] = POS; hdr->EVENT.CHN[N] = CHN; FreeTextEvent(hdr, N, Desc); // sets hdr->EVENT.TYP[n] hdr->EVENT.N = N+1; } curPos += len; } else if (tag==23) { // manufacturer information: "Manufacturer^model^version number^serial number" ifread(hdr->ID.Manufacturer._field,1,min(MAX_LENGTH_MANUF,len),hdr); if (len>MAX_LENGTH_MANUF) { fprintf(stderr,"Warning MFER tag23 incorrect length %i>128\n",len); ifseek(hdr,len-MAX_LENGTH_MANUF,SEEK_CUR); } curPos += len; for (k=0; isprint(hdr->ID.Manufacturer._field[k]) && (kID.Manufacturer._field[k] = 0; hdr->ID.Manufacturer.Name = strtok(hdr->ID.Manufacturer._field,"^"); hdr->ID.Manufacturer.Model = strtok(NULL,"^"); hdr->ID.Manufacturer.Version = strtok(NULL,"^"); hdr->ID.Manufacturer.SerialNumber = strtok(NULL,"^"); if (hdr->ID.Manufacturer.Name == NULL) hdr->ID.Manufacturer.Name="\0"; if (hdr->ID.Manufacturer.Model == NULL) hdr->ID.Manufacturer.Model="\0"; if (hdr->ID.Manufacturer.Version == NULL) hdr->ID.Manufacturer.Version="\0"; if (hdr->ID.Manufacturer.SerialNumber == NULL) hdr->ID.Manufacturer.SerialNumber="\0"; } else if (tag==30) //0x1e: waveform data { // data block hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,len); hdr->HeadLen = curPos; curPos += ifread(hdr->AS.rawdata,1,len,hdr); hdr->AS.first = 0; hdr->AS.length= hdr->NRec; } else if (tag==63) { uint8_t tag2=255, len2=255; count = 0; while ((count4) fprintf(stderr,"Warning MFER tag63-4 incorrect length %i>4\n",len2); int64_t SPR = *(int64_t*) mfer_swap8b(buf, len2, SWAP); hdr->SPR = (chan==0) ? SPR : lcm(SPR, hdr->SPR); hdr->CHANNEL[chan].SPR = SPR; if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i %i %i %i %i %i %i\n",tag,len, chan, tag2,len2, buf[0], buf[1], (int)hdr->SPR, (int)hdr->CHANNEL[chan].SPR); } else if (tag2==9) { //leadname if (len2==2) hdr->CHANNEL[chan].LeadIdCode = 0; else if (len2==1) hdr->CHANNEL[chan].LeadIdCode = buf[0]; else if (len2<=32) strncpy(hdr->CHANNEL[chan].Label,(char*)buf,len2); else fprintf(stderr,"Warning MFER tag63-9 incorrect length %i>32\n",len2); } else if (tag2==10) { // GDFTYP if (len2!=1) fprintf(stderr,"warning MFER tag63-10 incorrect length %i!=1\n",len2); if (buf[0]==0) gdftyp=3; // int16 else if (buf[0]==1) gdftyp=4; // uint16 else if (buf[0]==2) gdftyp=5; // int32 else if (buf[0]==3) gdftyp=2; // uint8 else if (buf[0]==4) gdftyp=4; // bit16 else if (buf[0]==5) gdftyp=1; // int8 else if (buf[0]==6) gdftyp=6; // uint32 else if (buf[0]==7) gdftyp=16; // float32 else if (buf[0]==8) gdftyp=17; // float64 else if (buf[0]==9) //gdftyp=2; // 8 bit AHA compression fprintf(stdout,"Warning: MFER compressed format not supported\n"); else gdftyp=3; hdr->CHANNEL[chan].GDFTYP = gdftyp; if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i %i %i %i %i\n",tag, len, chan, tag2, len2, buf[0], gdftyp); } else if (tag2==11) { // sampling rate if (len2>6) fprintf(stderr,"Warning MFER tag63-11 incorrect length %i>6\n",len2); double fval; fval = *(int64_t*) mfer_swap8b(buf+2, len2-2, SWAP); fval *= pow(10.0, (int8_t)(buf[1])); if (buf[0]==1) // s fval = 1.0/fval; hdr->CHANNEL[chan].SPR = lround(hdr->SPR * fval / hdr->SampleRate); if (VERBOSE_LEVEL>7) fprintf(stdout,"MFER: TLV %i %i %i %i %i %i %i %g %i %g\n",tag,len, chan, tag2,len2, buf[0], buf[1], fval, (int)hdr->SPR, hdr->SampleRate); } else if (tag2==12) { // MWF_SEN (0Ch): Sampling resolution CHANNEL_TYPE *hc = hdr->CHANNEL+chan; hc->PhysDimCode = 4275; // uV : default value in Table 5, ISO/FDIS 22077-1(E)ISO/WD 22077-1 hc->Cal = *(int64_t*) mfer_swap8b(buf+2, len2-2, SWAP); hc->Cal *= pow(10.0, (int8_t)(buf[1])); hc->PhysDimCode = MFER_PhysDimCodeTable[buf[0]]; } else if (tag2==13) { // Offset gdftyp = hdr->CHANNEL[chan].GDFTYP; if (gdftyp == 1) Off = ( int8_t)buf[0]; else if (gdftyp == 2) Off = (uint8_t)buf[0]; else if (SWAP) { if (gdftyp == 3) Off = ( int16_t)bswap_16(*( int16_t*)buf); else if (gdftyp == 4) Off = (uint16_t)bswap_16(*(uint16_t*)buf); else if (gdftyp == 5) Off = ( int32_t)bswap_32(*( int32_t*)buf); else if (gdftyp == 6) Off = (uint32_t)bswap_32(*(uint32_t*)buf); else if (gdftyp == 7) Off = ( int64_t)bswap_64(*( int64_t*)buf); else if (gdftyp == 8) Off = (uint64_t)bswap_64(*(uint64_t*)buf); else if (gdftyp ==16) { *(uint32_t*)ptrbuf = bswap_32(*(uint32_t*)buf); Off = *(float*)ptrbuf; } else if (gdftyp ==17) { uint64_t u64 = bswap_64(*(uint64_t*)ptrbuf); Off = *(double*)&u64; } } else { if (gdftyp == 3) Off = *( int16_t*)buf; else if (gdftyp == 4) Off = *(uint16_t*)buf; else if (gdftyp == 5) Off = *( int32_t*)buf; else if (gdftyp == 6) Off = *(uint32_t*)buf; else if (gdftyp == 7) Off = *( int64_t*)buf; else if (gdftyp == 8) Off = *(uint64_t*)buf; else if (gdftyp ==16) Off = *(float*)buf; else if (gdftyp ==17) Off = *(double*)buf; } hdr->CHANNEL[chan].Off = Off; /* TODO convert to Phys/Dig/Min/Max */ } else if (tag2==18) { // null value // FIXME: needed for overflow detection if (len2>6) fprintf(stderr,"Warning MFER tag63-12 incorrect length %i>6\n", len2); if (!MFER_PhysDimCodeTable[UnitCode]) fprintf(stderr,"Warning MFER: unsupported physical unit (code=%i)\n", UnitCode); hdr->CHANNEL[chan].PhysDimCode = MFER_PhysDimCodeTable[UnitCode]; double cal = *(int64_t*) mfer_swap8b(buf+2, len2-2, SWAP); hdr->CHANNEL[chan].Cal = cal * pow(10.0,(int8_t)buf[1]); } else { if (VERBOSE_LEVEL==9) fprintf(stdout,"tag=63-%i (len=%i) not supported\n",tag2,len2); } } } else if (tag==64) //0x40 { // preamble char tmp[256]; curPos += ifread(tmp,1,len,hdr); if (VERBOSE_LEVEL>7) { fprintf(stdout,"Preamble: pos=%i|",curPos); for (k=0; k2) { size_t N = hdr->EVENT.N; #ifdef CURRENTLY_NOT_AVAILABLE // FIXME: biosig_set_number_of_events is currently part of biosig2 interface if (N_EVENT <= N) { N_EVENT = biosig_set_number_of_events(hdr, max(16, N*2)); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"MFER-event: N=%i\n",hdr->EVENT.N); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[N] = 0; #endif hdr->EVENT.CHN[N] = 0; hdr->EVENT.DUR[N] = 0; if (SWAP) { hdr->EVENT.TYP[N] = bswap_16(*(uint16_t*)ptrbuf); hdr->EVENT.POS[N] = bswap_32(*(uint32_t*)(buf+2)); // 0-based indexing if (len>6) hdr->EVENT.DUR[N] = bswap_32(*(uint32_t*)(buf+6)); } else { hdr->EVENT.TYP[N] = *(uint16_t*)ptrbuf; hdr->EVENT.POS[N] = *(uint32_t*)(buf+2); // 0-based indexing if (len>6) hdr->EVENT.DUR[N] = *(uint32_t*)(buf+6); } hdr->EVENT.N = N+1; #endif //CURRENTLY_NOT_AVAILABLE } } else if (tag==66) //0x42: NIPB, SpO2(value) { } else if (tag==67) //0x43: Sample skew { int skew=0; curPos += ifread(&skew, 1, len,hdr); if (VERBOSE_LEVEL>2) fprintf(stdout,"MFER: sample skew %i ns\n",skew); } else if (tag==70) //0x46: digital signature { if (VERBOSE_LEVEL>2) fprintf(stdout,"MFER: digital signature \n"); } else if (tag==103) //0x67 Group definition { if (VERBOSE_LEVEL>2) fprintf(stdout,"MFER: Group definition\n"); } else if (tag==129) //0x81 { if (!hdr->FLAG.ANONYMOUS) curPos += ifread(hdr->Patient.Name,1,len,hdr); else { ifseek(hdr,len,SEEK_CUR); curPos += len; } } else if (tag==130) //0x82 { // Patient Id if (len>64) fprintf(stderr,"Warning MFER tag131 incorrect length %i>64\n",len); if (len>MAX_LENGTH_PID) { ifread(hdr->Patient.Id,1,MAX_LENGTH_PID,hdr); ifseek(hdr,MAX_LENGTH_PID-len,SEEK_CUR); curPos += len; } else curPos += ifread(hdr->Patient.Id,1,len,hdr); } else if (tag==131) //0x83 { // Patient Age if (len!=7) fprintf(stderr,"Warning MFER tag131 incorrect length %i!=7\n",len); curPos += ifread(buf,1,len,hdr); uint16_t t16; memcpy(&t16, buf+3, 2); if (SWAP) t16 = bswap_16(t16); tm_time.tm_year = t16 - 1900; tm_time.tm_mon = buf[5]-1; tm_time.tm_mday = buf[6]; tm_time.tm_hour = 12; tm_time.tm_min = 0; tm_time.tm_sec = 0; hdr->Patient.Birthday = tm_time2gdf_time(&tm_time); //hdr->Patient.Age = buf[0] + cswap_u16(*(uint16_t*)(buf+1))/365.25; } else if (tag==132) //0x84 { // Patient Sex if (len!=1) fprintf(stderr,"Warning MFER tag132 incorrect length %i!=1\n",len); curPos += ifread(&hdr->Patient.Sex,1,len,hdr); } else if (tag==133) //0x85 { curPos += ifread(buf,1,len,hdr); uint16_t t16, u16; memcpy(&t16, buf+3, 2); if (SWAP) t16 = bswap_16(t16); tm_time.tm_year = t16 - 1900; tm_time.tm_mon = buf[2] - 1; tm_time.tm_mday = buf[3]; tm_time.tm_hour = buf[4]; tm_time.tm_min = buf[5]; tm_time.tm_sec = buf[6]; hdr->T0 = tm_time2gdf_time(&tm_time); // add milli- and micro-seconds memcpy(&t16, buf+7, 2); memcpy(&u16, buf+9, 2); if (SWAP) hdr->T0 += (uint64_t) ( bswap_16(t16) * 1e+3 + bswap_16(u16) * ldexp(1.0,32) / (24*3600e6) ); else hdr->T0 += (uint64_t) ( t16 * 1e+3 + u16 * ldexp(1.0,32) / (24*3600e6) ); } else if (tag==135) //0x67 Object identifier { if (VERBOSE_LEVEL>2) fprintf(stdout,"MFER: object identifier\n"); } else { curPos += len; ifseek(hdr,len,SEEK_CUR); if (VERBOSE_LEVEL>7) fprintf(stdout,"tag=%i (len=%i) not supported\n",tag,len); } if (curPos != iftell(hdr)) fprintf(stdout,"positions differ %i %li \n",curPos,iftell(hdr)); /* TAG */ int sz=ifread(&tag,1,1,hdr); curPos += sz; } hdr->FLAG.OVERFLOWDETECTION = 0; // overflow detection OFF - not supported hdr->AS.bpb = 0; for (k=0; kNS; k++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"sopen(MFER): #%i\n",(int)k); CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Transducer[0] = 0; if (!hc->PhysDimCode) hc->PhysDimCode = MFER_PhysDimCodeTable[UnitCode]; if (hc->Cal==1.0) hc->Cal = Cal; hc->Off = Off * hc->Cal; if (!hc->SPR) hc->SPR = hdr->SPR; if (hc->GDFTYP<16) if (hc->GDFTYP & 0x01) { hc->DigMax = ldexp( 1.0,GDFTYP_BITS[gdftyp]-1) - 1.0; hc->DigMin = ldexp(-1.0,GDFTYP_BITS[gdftyp]-1); } else { hc->DigMax = ldexp( 1.0,GDFTYP_BITS[gdftyp]); hc->DigMin = 0.0; } else { hc->DigMax = INFINITY; hc->DigMin = -INFINITY; } hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->OnOff = 1; hc->bi = hdr->AS.bpb; hdr->AS.bpb += hdr->SPR*(GDFTYP_BITS[gdftyp]>>3); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[MFER] -V=%i NE=%i\n",VERBOSE_LEVEL,hdr->EVENT.N); } else if (hdr->TYPE==MIT) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %i \n",__FILE__,__LINE__,__func__,VERBOSE_LEVEL); size_t bufsiz = 1024; while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count+bufsiz); count += ifread(hdr->AS.Header+count, 1, bufsiz, hdr); } ifclose(hdr); /* MIT: decode header information */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %s \n",__FILE__,__LINE__,__func__, (char*)hdr->AS.Header); hdr->SampleRate = 250.0; hdr->NRec = 0; hdr->SPR = 1; size_t NumberOfSegments = 1; char *ptr = (char*)hdr->AS.Header; char *line; do line = strtok((char*)hdr->AS.Header,"\x0d\x0a"); while ((line != NULL) && (line[0]=='#')); ptr = strpbrk(line,"\x09\x0a\x0d\x20"); // skip 1st field ptr[0] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %s \n",__FILE__,__LINE__,__func__, ptr); if (strchr(line,'/') != NULL) { NumberOfSegments = atol(strchr(line,'/')+1); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank: multi-segment records are not supported"); } hdr->NS = (typeof(hdr->NS))strtod(ptr+1,&ptr); // number of channels if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): NS=%i %p\n",__FILE__,__LINE__,__func__, hdr->NS, ptr); if ((ptr != NULL) && strlen(ptr)) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...) MIT : 123: <%s>\n",__FILE__,__LINE__,__func__, ptr); hdr->SampleRate = strtod(ptr,&ptr); if (ptr[0]=='/') { double CounterFrequency = strtod(ptr+1,&ptr); if (fabs(CounterFrequency-hdr->SampleRate) > 1e-5) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT format: Sampling rate and counter frequency differ - this is currently not supported!"); } } if (ptr[0]=='(') { double BaseCounterValue = strtod(ptr+1,&ptr); if (BaseCounterValue) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT format: BaseCounterValue is not zero - this is currently not supported !"); } ptr++; // skip ")" } } if ((ptr != NULL) && strlen(ptr)) { hdr->NRec = (nrec_t)strtod(ptr,&ptr); } if ((ptr != NULL) && strlen(ptr)) { struct tm t; sscanf(ptr," %u:%u:%u %u/%u/%u",&t.tm_hour,&t.tm_min,&t.tm_sec,&t.tm_mday,&t.tm_mon,&t.tm_year); t.tm_mon--; t.tm_year -= 1900; t.tm_isdst = -1; hdr->T0 = tm_time2gdf_time(&t); } if (VERBOSE_LEVEL>8) hdr2ascii(hdr,stdout,2); // channel header not parsed yet int fmt=0,FMT=0; size_t MUL=1; char **DatFiles = (char**)calloc(hdr->NS, sizeof(char*)); size_t *ByteOffset = (size_t*)calloc(hdr->NS, sizeof(size_t)); size_t nDatFiles = 0; uint16_t gdftyp,NUM=1,DEN=1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->AS.bpb8 = 0; hdr->AS.bpb = 0; for (k=0; k < hdr->NS; k++) { double skew=0; //double byteoffset=0; double ADCgain=200; double baseline=0; double ADCresolution=12; double ADCzero=0; double InitialValue=0; double BlockSize=0; CHANNEL_TYPE* hc = hdr->CHANNEL+k; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); do line = strtok(NULL,"\x0d\x0a"); while (line[0]=='#'); // read next line if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %i/%i <%s>\n",__FILE__,__LINE__,__func__, (int)k, hdr->NS, line); for (ptr=line; !isspace(ptr[0]); ptr++) {}; // skip 1st field ptr[0]=0; if (k==0) DatFiles[nDatFiles++]=line; else if (strcmp(DatFiles[nDatFiles-1],line)) DatFiles[nDatFiles++]=line; fmt = (typeof(fmt))strtod(ptr+1,&ptr); if (k==0) FMT = fmt; else if (FMT != fmt) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank: different formats within a single data set is not supported"); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); size_t DIV=1; if (ptr[0]=='x') { DIV = (size_t)strtod(ptr+1, &ptr); hdr->CHANNEL[k].SPR *= DIV; MUL = lcm(MUL, DIV); } hdr->CHANNEL[k].SPR = DIV; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); if (ptr[0]==':') skew = strtod(ptr+1,&ptr); if (ptr[0]=='+') ByteOffset[k] = (size_t)strtod(ptr+1,&ptr); if (ptr != NULL) ADCgain = strtod(ptr+1,&ptr); if (ADCgain==0) ADCgain=200; // DEFGAIN: https://www.physionet.org/physiotools/wag/header-5.htm if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); if (ptr[0] == '(') { baseline = strtod(ptr+1,&ptr); ptr++; } hc->PhysDimCode = 4274; // mV if (ptr[0] == '/') { char *PhysUnits = ++ptr; while (!isspace(ptr[0])) ++ptr; ptr[0] = 0; hc->PhysDimCode = PhysDimCode(PhysUnits); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); if (ptr != NULL) ADCresolution = strtod(ptr+1,&ptr); if (ptr != NULL) ADCzero = strtod(ptr+1,&ptr); if (ptr != NULL) InitialValue = strtod(ptr+1,&ptr); else InitialValue = ADCzero; double checksum; if (ptr != NULL) checksum = strtod(ptr+1,&ptr); if (ptr != NULL) BlockSize = strtod(ptr+1,&ptr); while (isspace(ptr[0])) ++ptr; strncpy(hdr->CHANNEL[k].Label,ptr,MAX_LENGTH_LABEL); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); hc->Cal = 1/ADCgain; hc->Off = -ADCzero*hc->Cal; hc->OnOff = 1; hc->Transducer[0] = '\0'; hc->LowPass = -1; hc->HighPass = -1; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); // hdr->FLAG.SWAP = (__BYTE_ORDER == __BIG_ENDIAN); hdr->FILE.LittleEndian = 1; switch (fmt) { case 8: gdftyp = 1; hc->DigMax = 127.0; hc->DigMin = -128.0; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank format 8(diff) not supported"); break; case 80: gdftyp = 2; // uint8; hc->Off= -128*hc->Cal; hc->DigMax = 255.0; hc->DigMin = 0.0; break; case 16: if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); gdftyp = 3; NUM = 2; DEN = 1; hc->DigMax = ldexp( 1.0,15)-1.0; hc->DigMin = ldexp(-1.0,15); break; case 24: gdftyp = 255+24; NUM = 3; DEN = 1; hc->DigMax = ldexp( 1.0,23)-1.0; hc->DigMin = ldexp(-1.0,23); break; case 32: gdftyp = 5; NUM = 4; DEN = 1; hc->DigMax = ldexp( 1.0,31)-1.0; hc->DigMin = ldexp(-1.0,31); break; case 61: gdftyp = 3; // hdr->FLAG.SWAP = !(__BYTE_ORDER == __BIG_ENDIAN); hdr->FILE.LittleEndian = 0; NUM = 2; DEN = 1; hc->DigMax = ldexp( 1.0,15)-1.0; hc->DigMin = ldexp(-1.0,15); break; case 160: gdftyp = 4; // uint16; hc->Off= ldexp(-1.0,15)*hc->Cal; NUM = 2; DEN = 1; hc->DigMax = ldexp(1.0,16)-1.0; hc->DigMin = 0.0; break; case 212: gdftyp = 255+12; NUM = 3; DEN = 2; hc->DigMax = ldexp( 1.0,11)-1.0; hc->DigMin = ldexp(-1.0,11); break; case 310: case 311: gdftyp = 255+10; NUM = 4; DEN = 3; hc->DigMax = ldexp( 1.0,9)-1.0; hc->DigMin = ldexp(-1.0,9); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank format 310/311 not supported"); break; default: gdftyp = 0xffff; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank: unknown format"); } hc->GDFTYP = gdftyp; hc->LeadIdCode = 0; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->bi8 = hdr->AS.bpb8; hdr->AS.bpb8 += (hdr->SPR*NUM<<3)/DEN; hc->bi = hdr->AS.bpb; hdr->AS.bpb += hdr->AS.bpb8>>3; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); } hdr->SampleRate *= MUL; hdr->SPR *= MUL; if (VERBOSE_LEVEL > 7) hdr2ascii(hdr,stdout,4); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): %s(...)\n",__FILE__,__LINE__,__func__); /* read age, sex etc. */ line = strtok(NULL,"\x0d\x0a"); if (line != NULL) { char *t1; double age=0.0; for (k=0; k:"); if (t1 != NULL) age = strtod(t1+5,&ptr); if (age>0.0) hdr->Patient.Birthday = hdr->T0 - (uint64_t)ldexp(age*365.25,32); t1 = strstr(line,"SEX:"); if (t1 != NULL) t1 += 4; else { t1 = strstr(line,"SEX>:"); if (t1 != NULL) t1 += 5; } if (t1 != NULL) { while (isspace(t1[0])) t1++; hdr->Patient.Sex = (t1[0]=='M') + 2* (t1[0]=='F'); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %i (%i) %s FMT=%i + %i\n",__FILE__,__LINE__,__func__, (int)k+1,(int)nDatFiles,DatFiles[0],fmt,(int)ByteOffset[0]); /* MIT: read ATR annotation file */ char *f0 = hdr->FileName; char *f1 = (char*) malloc(strlen(hdr->FileName)+5); strcpy(f1,hdr->FileName); // Flawfinder: ignore strcpy(strrchr(f1,'.')+1,"atr"); // Flawfinder: ignore hdr->FileName = f1; hdr = ifopen(hdr,"r"); if (!hdr->FILE.OPEN) { // if no *.atr file, try *.qrs strcpy(strrchr(f1,'.')+1,"qrs"); // Flawfinder: ignore hdr = ifopen(hdr,"r"); } if (!hdr->FILE.OPEN) { // *.ecg strcpy(strrchr(f1,'.')+1,"ecg"); // Flawfinder: ignore hdr = ifopen(hdr,"r"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): <%s> %i %i\n",__FILE__,__LINE__,__func__, hdr->FileName,hdr->FILE.OPEN,(int)bufsiz); if (hdr->FILE.OPEN) { uint16_t *Marker=NULL; count = 0; while (!ifeof(hdr)) { if (bufsiz<1024) bufsiz = 1024; bufsiz *= 2; void *tmp = realloc(Marker, 2 * bufsiz ); Marker = (uint16_t*) tmp; count += ifread (Marker+count, 2, bufsiz-count, hdr); } ifclose(hdr); Marker[count]=0; /* define user specified events according to http://www.physionet.org/physiotools/wfdb/lib/ecgcodes.h */ hdr->EVENT.CodeDesc = (typeof(hdr->EVENT.CodeDesc)) realloc(hdr->EVENT.CodeDesc,257*sizeof(*hdr->EVENT.CodeDesc)); hdr->EVENT.CodeDesc[0] = ""; for (k=0; strlen(MIT_EVENT_DESC[k])>0; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...) [MIT 182]: %i\n",__FILE__,__LINE__,__func__, (int)k); hdr->EVENT.CodeDesc[k+1] = (char*)MIT_EVENT_DESC[k]; // hack to satisfy MinGW (gcc version 4.2.1-sjlj) if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...) [MIT 182]: %i %s %s\n",__FILE__,__LINE__,__func__, (int)k,MIT_EVENT_DESC[k],hdr->EVENT.CodeDesc[k]); } hdr->EVENT.LenCodeDesc = k+1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...)[MIT 183] %s %i\n",__FILE__,__LINE__,__func__, f1,(int)count); /* decode ATR annotation information */ size_t N = count; hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,N*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,N*sizeof(*hdr->EVENT.POS)); hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) realloc(hdr->EVENT.CHN,N*sizeof(*hdr->EVENT.CHN)); hdr->EVENT.N = 0; hdr->EVENT.SampleRate = hdr->SampleRate; uint16_t chn = 0; size_t pos = 0; char flag_chn = 0; for (k=0; (k> 10; uint16_t len = a16 & 0x03ff; if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i) %s(...)[MIT 183] k=%i/%i N=%i A=%i l=%i\n", __FILE__,__LINE__,__func__, (int)k, (int)N, (int)hdr->EVENT.N, a16>>10, len); switch (A) { case 59: // SKIP pos += (((uint32_t)leu16p(Marker+k+1))<<16) + leu16p(Marker+k+2); k += 2; break; case 60: // NUM case 61: // SUB break; case 62: // CHN chn = len; flag_chn = flag_chn || chn; break; case 63: // AUX k += (len+1)/2; break; default: pos += len; // code = 0 is mapped to 49(ACMAX), see MIT_EVENT_DESC and http://www.physionet.org/physiotools/wfdb/lib/ecgcodes.h hdr->EVENT.TYP[hdr->EVENT.N] = (A==0 ? 49 : A); hdr->EVENT.POS[hdr->EVENT.N] = pos-1; // convert to 0-based indexing hdr->EVENT.CHN[hdr->EVENT.N] = chn; ++hdr->EVENT.N; } } if (flag_chn) hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR,N*sizeof(*hdr->EVENT.DUR)); else { free(hdr->EVENT.CHN); hdr->EVENT.CHN = NULL; } free(Marker); } free(f1); hdr->FileName = f0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...)[MIT 185] \n",__FILE__,__LINE__,__func__); /* MIT: open data file */ if (nDatFiles == 1) { //uint8_t *Marker=NULL; count = 0; char *f0 = hdr->FileName; char *f1 = (char*) malloc(strlen(hdr->FileName)+strlen(DatFiles[0])+2); strcpy(f1,hdr->FileName); hdr->FileName = f1; char *ptr = strrchr(f1,FILESEP); if (ptr != NULL) strcpy(ptr+1,DatFiles[0]); else strcpy(f1,DatFiles[0]); hdr->HeadLen = ByteOffset[0]; hdr = ifopen(hdr,"rb"); ifseek(hdr, hdr->HeadLen, SEEK_SET); count = 0; bufsiz = 1024; while (!ifeof(hdr)) { bufsiz *= 2; void *tmpptr = realloc(hdr->AS.rawdata, bufsiz + 1 ); hdr->AS.rawdata = (uint8_t*) tmpptr; count += ifread (hdr->AS.rawdata+count, 1, bufsiz-count, hdr); } ifclose(hdr); free(f1); hdr->FileName = f0; if (!hdr->NRec) { hdr->NRec = count/(hdr->AS.bpb); } } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %s(...)[MIT 198] #%i: (%i) %s FMT=%i\n",__FILE__,__LINE__,__func__,(int)k+1,(int)nDatFiles,DatFiles[0],fmt); free(DatFiles); free(ByteOffset); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %s(...)[MIT 199] #%i: (%i) %s FMT=%i\n",__FILE__,__LINE__,__func__,(int)k+1,(int)nDatFiles,DatFiles[0],fmt); if (nDatFiles != 1) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "MIT/HEA/PhysioBank: multiply data files within a single data set is not supported"); return(hdr); } hdr->AS.length = hdr->NRec; } /* END OF MIT FORMAT */ #ifdef CHOLMOD_H else if ((hdr->TYPE==MM) && (!hdr->FILE.COMPRESSION)) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 001] %i,%i\n",hdr->HeadLen,hdr->FILE.COMPRESSION); while (!ifeof(hdr)) { count = max(5000, hdr->HeadLen*2); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, count); hdr->HeadLen += ifread(hdr->AS.Header + hdr->HeadLen, 1, count - hdr->HeadLen - 1, hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 003] %i,%i\n",hdr->HeadLen,hdr->FILE.COMPRESSION); char *line = strtok((char*)hdr->AS.Header, "\x0a\x0d"); char status = 0; unsigned long ns = 0; while (line != NULL) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 013] <%s>\n",line); if ((line[0]=='%') && (line[1]=='%') && isspace(line[2])) { if (!strncmp(line+3,"LABELS",6)) status = 1; else if (!strncmp(line+3,"ENDLABEL",8)) { status = 0; break; } if (status) { int k = 3; while (isspace(line[k])) k++; unsigned long ch = strtoul(line+k, &line, 10); while (isspace(line[0])) line++; if (ch >= ns) { hdr->rerefCHANNEL = (CHANNEL_TYPE*)realloc(hdr->rerefCHANNEL, ch*sizeof(CHANNEL_TYPE)); while (ns < ch) { hdr->rerefCHANNEL[ns].Label[0] = 0; hdr->rerefCHANNEL[ns].Transducer[0] = 0; ns++; } } strncpy(hdr->rerefCHANNEL[ch-1].Label, line, MAX_LENGTH_LABEL); hdr->rerefCHANNEL[ch-1].OnOff = 1; hdr->rerefCHANNEL[ch-1].Label[MAX_LENGTH_LABEL] = 0; hdr->rerefCHANNEL[ch-1].LeadIdCode = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 027] %i <%s>\n",(int)ch,line); } } line = strtok(NULL,"\x0a\x0d"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 033]\n"); ifseek(hdr,0,SEEK_SET); CSstart(); // init cholmod library CHOLMOD_COMMON_VAR.print = 5; hdr->Calib = cholmod_read_sparse (hdr->FILE.FID, &CHOLMOD_COMMON_VAR); /* read in a matrix */ if (VERBOSE_LEVEL>7) cholmod_print_sparse (hdr->Calib, "Calib", &CHOLMOD_COMMON_VAR); /* print the matrix */ ifclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[MM 999]\n"); return(hdr); } /* END OF MatrixMarket */ #endif else if (hdr->TYPE==NEURON) { hdr->HeadLen = count; if (VERBOSE_LEVEL>7) fprintf(stdout,"NEURON: start\n"); size_t count; while (!ifeof(hdr)) { count = max(1<<20, hdr->HeadLen*2); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, count); hdr->HeadLen += ifread(hdr->AS.Header + hdr->HeadLen, 1, count - hdr->HeadLen - 1, hdr); } hdr->AS.Header[hdr->HeadLen] = 0; hdr->NS = 1; hdr->SPR = 1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->CHANNEL[0].GDFTYP = 17; hdr->CHANNEL[0].Cal = 1.0; hdr->CHANNEL[0].Off = 0.0; hdr->CHANNEL[0].PhysMin = -1e9; hdr->CHANNEL[0].PhysMax = +1e9; hdr->CHANNEL[0].DigMin = -1e9; hdr->CHANNEL[0].DigMax = +1e9; hdr->AS.bpb = sizeof(double); hdr->CHANNEL[0].bi = 0; hdr->CHANNEL[0].bi8 = 0; hdr->CHANNEL[0].LeadIdCode = 0; hdr->CHANNEL[0].SPR = hdr->SPR; hdr->CHANNEL[0].LowPass = NAN; hdr->CHANNEL[0].HighPass = NAN; hdr->CHANNEL[0].Notch = NAN; hdr->CHANNEL[0].Transducer[0] = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"NEURON 202: \n"); char *t = strtok( (char*)hdr->AS.Header, "\x0A\x0D"); char status = 0; size_t spr = 0; while (t != NULL) { if (VERBOSE_LEVEL>8) fprintf(stdout,"NEURON 301: <%s>\n", t); if (status==0) { if (!strncmp(t,"Header:", 7)) status = 1; } else if (status==1) { if (VERBOSE_LEVEL>7) fprintf(stdout,"NEURON 311: <%s>\n",t); char *val = t+strlen(t); while (isspace(*(--val))) {}; val[1]=0; // remove trailing blanks val = strchr(t,':'); // find right value val[0] = 0; while (isspace(*(++val))) {}; if (!strncmp(t,"Data", 7)) { status=2; spr = 0; } else if (!strcmp(t,"SampleInt")) hdr->SampleRate = 1.0 / atof(val); else if (!strcmp(t,"Points")) { hdr->NRec = atoi(val); hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, sizeof(double) * hdr->NRec); } else if (!strcmp(t,"XUnit")) { uint16_t xunits = PhysDimCode(val); double scale = PhysDimScale(xunits); if ((xunits & 0xffe0)==2176) hdr->SampleRate /= scale; else fprintf(stdout, "Error NEURON: invalid XUnits <%s>\n", val); } else if (!strcmp(t,"YUnit")) { if (VERBOSE_LEVEL>7) fprintf(stdout,"NEURON 321: Yunits:<%s>\n",val); hdr->CHANNEL[0].PhysDimCode = PhysDimCode(val); } else if (!strcmp(t,"Method")) { strncpy(hdr->CHANNEL[0].Label, val, MAX_LENGTH_LABEL); } } else if (status==2) { if (strpbrk(t,"0123456789")) { // ignore non-numeric (e.g. emtpy) lines *(double*)(hdr->AS.rawdata + spr*sizeof(double)) = atof(t); spr++; } if (hdr->NRec >= 0) if (spr >= (size_t)hdr->NRec) { void *ptr = realloc(hdr->AS.rawdata, 2 * min(spr, (size_t)hdr->NRec) * sizeof(double)); if (ptr==NULL) break; hdr->AS.rawdata = (uint8_t*)ptr; } } t = strtok(NULL, "\x0A\x0D"); } free(hdr->AS.Header); hdr->AS.Header = NULL; hdr->AS.first = 0; hdr->AS.length = spr; } else if (hdr->TYPE == NeuroLoggerHEX) { hdr->NS = 8; // uint16_t gdftyp = 2; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "NeuroLogger HEX format not supported, yet"); return(hdr); } #if defined(WITH_NEV) else if (hdr->TYPE==NEV) { fprintf(stdout,"Support for NEV format is under construction - most likely its not useful yet.\n"); if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (NEV)\n"); hdr->VERSION = beu16p(hdr->AS.Header+8)>>8; switch (beu16p(hdr->AS.Header+8)) { case 0x0100: // readnev1 case 0x0101: // readnev1_1 case 0x0200: // readnev2 //biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, NULL); break; default: biosigERROR(hdr, B4C_FORMAT_UNKNOWN, NULL); } const int H1Len = 28+16+32+256+4; /* read Basic Header */ // uint16_t fileFormat = beu16p(hdr->AS.Header+10); uint32_t HeadLen = leu32p(hdr->AS.Header+12); if (HeadLen < H1Len) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, NULL); return(hdr); } hdr->AS.bpb = leu32p(hdr->AS.Header+16); uint32_t TimeStepFrequency = leu32p(hdr->AS.Header+20); // samples = TimeStepFrequency / 10; // Freq in 0.1 seconds hdr->SampleRate = leu32p(hdr->AS.Header+24); if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (NEV) [210] %d %d \n", (int)count, (int)HeadLen); if (countAS.Header = (uint8_t*)realloc(hdr->AS.Header,HeadLen); count += ifread(hdr->AS.Header+count, 1, HeadLen-count, hdr); } uint32_t extHdrN = leu32p(hdr->AS.Header+H1Len-4); if (count < H1Len + 32*extHdrN) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,HeadLen); count += ifread(hdr->AS.Header+count, 1, HeadLen-count, hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (NEV) [220] %d %d %d \n", extHdrN, (int)count, (int)HeadLen); struct tm t; t.tm_year = leu32p(hdr->AS.Header+28); t.tm_mon = leu32p(hdr->AS.Header+30); //t.tm_wday = beu32p(hdr->AS.Header+32); t.tm_mday = leu32p(hdr->AS.Header+34); t.tm_hour = leu32p(hdr->AS.Header+36); t.tm_min = leu32p(hdr->AS.Header+38); t.tm_sec = leu32p(hdr->AS.Header+40); //milliseconds = beu32p(hdr->AS.Header+42); hdr->T0 = tm_time2gdf_time(&t); double time_interval = 1e3 * (hdr->AS.bpb-8) / TimeStepFrequency; if (VERBOSE_LEVEL>7) hdr2ascii(hdr,stdout,2); //******** read Extended Header ********* const char *nameOfElectrode, *extraComment, *continuedComment, *mapfile; const char *H2 = (char*)hdr->AS.Header + H1Len; hdr->NS = 0; for (k = 0; k < extHdrN; k++) { const char *identifier = H2 + k*32; if (VERBOSE_LEVEL>8) { char tmp[9];tmp[8]=0; char tmp24[25]; tmp24[24]=0; memcpy(tmp,identifier,8); memcpy(tmp24,identifier+8,24); fprintf(stdout,"SOPEN (NEV) [225] %d %d <%s> <%s>\n",(int)k,hdr->NS,tmp,tmp24); } if (!memcmp (identifier, "NEUEVWAV",8)) hdr->NS++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (NEV) [230]\n"); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); uint16_t NS = 0; for (k = 0; k < extHdrN; k++) { const char *identifier = H2 + k*32; if (!memcmp (identifier, "ARRAYNME",8)) { nameOfElectrode = identifier + 8; } else if (!memcmp (identifier, "ECOMMENT",8)) { extraComment = identifier + 8; } else if (!memcmp (identifier, "CCOMMENT",8)) { continuedComment = identifier + 8; } else if (!memcmp (identifier, "MAPFILE",8)) { mapfile = identifier + 8; } else if (!memcmp (identifier, "NEUEVWAV",8)) { //neuralEventWaveform = identifier + 8; CHANNEL_TYPE *hc = hdr->CHANNEL+(NS++); sprintf(hc->Label,"#%d",leu16p(identifier + 8)); // electrodeId hc->Transducer[0] = 0; // (uint8_t)(identifier + 8 + 2); // module // (uint8_t)(identifier + 8 + 3); // channel hc->OnOff = 1; hc->Cal = leu16p(identifier+ 8 + 4); // scaling factor // beu16p(identifier + 8 + 6); // energyTreshold hc->Off = 0; hc->DigMax = lei16p(identifier + 8 + 8); // high threshold hc->DigMin = lei16p(identifier + 8 + 10); // low threshold // (uint8_t)(identifier + 8 + 11); // sortedUnitsInChannel hc->GDFTYP = 2 * identifier[8 + 12]; // bytesPerWaveformSample hc->PhysMax = hc->DigMax*hc->Cal; hc->PhysMin = hc->DigMin*hc->Cal; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->PhysDimCode = 0; hc->TOffset = 0; hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; hc->Impedance = NAN; hc->SPR = 0; hc->bi = hdr->AS.bpb; hc->bi8 = hdr->AS.bpb*8; hc->bufptr = NULL; } else if (!memcmp (identifier, "NSASEXEV",8)) { char *nsas = identifier + 8; } else { /* // IGNORE biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "NEV: unknown extended header"); */ } } return(hdr); } #endif else if (hdr->TYPE==NEX1) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__func__,__LINE__); if (count < 284) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,284); count += ifread(hdr->AS.Header + count, 1, 284 - count, hdr); } uint8_t v = hdr->AS.Header[3]-'0'; const int H1LEN = (v==1) ? (4 + 4 + 256 + 8 + 4*4 + 256) : (4 + 4 + 256 + 8 + 8 + 4 + 8 + 64); const int H2LEN = (v==1) ? (4 + 4 + 64 + 6*4 + 4*8 + 12 + 16 + 52) : (4 + 4 + 64 + 2*8 + 2*4 + 8 + 32 + 4*8 + 4*4 + 60); uint32_t k = leu32p(hdr->AS.Header + 280); if (count < H1LEN + k * H2LEN) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, H1LEN + k * H2LEN); count += ifread(hdr->AS.Header + count, 1, H1LEN + k * H2LEN - count, hdr); } hdr->HeadLen = count; hdr->VERSION = leu32p(hdr->AS.Header + 4) / 100.0; hdr->SampleRate = lef64p(hdr->AS.Header + 264); hdr->SPR = 1; hdr->EVENT.SampleRate = lef64p(hdr->AS.Header + 264); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__func__,__LINE__); if (k > 0xffff) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "NEX format has more than 65535 channels"); return (hdr); } while (!ifeof(hdr)) { void *tmpptr = realloc(hdr->AS.Header, count*2); if (tmpptr) hdr->AS.Header = (uint8_t*)tmpptr; else { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Not enough memory to read NEX file"); return(hdr); } count += ifread(hdr->AS.Header + count, 1, count, hdr); } hdr->NS = k; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__func__,__LINE__); for (k=0; k < hdr->NS; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): VarHdr # %i\n",__func__,__LINE__, k); CHANNEL_TYPE *hc = hdr->CHANNEL+k; uint32_t type = leu32p(hdr->AS.Header + H1LEN + k*H2LEN); hc->OnOff = (type==5); strncpy(hc->Label, hdr->AS.Header + H1LEN + k*H2LEN + 8, min(64,MAX_LENGTH_LABEL)); hc->Label[min(64, MAX_LENGTH_LABEL)] = 0; hc->Transducer[0] = 0; size_t n; if (v==5) { hc->GDFTYP = (leu32p(hdr->AS.Header + H1LEN + k*H2LEN + 92)==1) ? 16 : 3; hc->PhysDimCode = PhysDimCode(hdr->AS.Header + H1LEN + k*H2LEN + 5*8 + 64); n = leu64p(hdr->AS.Header + 80 + H1LEN + k*H2LEN); hc->Cal = lef64p(hdr->AS.Header + 64+8*5+32 + H1LEN + k*H2LEN); hc->Off = lef64p(hdr->AS.Header + 64+8*5+40 + H1LEN + k*H2LEN); hc->SPR = leu64p(hdr->AS.Header + 64+8*5+48 + H1LEN + k*H2LEN); hc->bufptr = hdr->AS.Header + leu64p(hdr->AS.Header + 64+8 + H1LEN + k*H2LEN); } else { hc->GDFTYP = 3; hc->PhysDimCode = PhysDimCode("mV"); n = leu32p(hdr->AS.Header + 76 + H1LEN + k*H2LEN); hc->Cal = lef64p(hdr->AS.Header + 64+8*4+3*8 + H1LEN + k*H2LEN); hc->Off = lef64p(hdr->AS.Header + 64+8*4+3*8+20 + H1LEN + k*H2LEN); hc->SPR = leu32p(hdr->AS.Header + 64+8*4+4*8 + H1LEN + k*H2LEN); hc->bufptr = hdr->AS.Header+leu32p(hdr->AS.Header + 64+8 + H1LEN + k*H2LEN); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): VarHdr # %i %i %i %i \n",__func__,__LINE__, k,v,type,(int)n); switch (type) { case 2: //case 6: case 0: case 1: hdr->EVENT.N += n; } //if (hc->OnOff) hdr->SPR = lcm(hdr->SPR, hc->SPR); } if (hdr->EVENT.N > 0) { size_t N=hdr->EVENT.N; hdr->EVENT.N=0; reallocEventTable(hdr,N); N = 0; for (k=0; k < hdr->NS; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): VarHdr # %i\n",__func__,__LINE__, k); CHANNEL_TYPE *hc = hdr->CHANNEL+k; uint32_t type = leu32p(hdr->AS.Header + H1LEN + k*H2LEN); size_t n,l; uint16_t gdftyp = 5; if (v==5) { n = leu64p(hdr->AS.Header + 80 + H1LEN + k*H2LEN); if (leu32p(hdr->AS.Header + 88 + H1LEN + k*H2LEN)) gdftyp=7; } else n = leu32p(hdr->AS.Header + 76 + H1LEN + k*H2LEN); switch (type) { case 2: if (gdftyp==5) { for (l=0; lEVENT.DUR[N+l] = leu32p(hc->bufptr+4*(l+n)); } else { for (l=0; lEVENT.DUR[N+l] = leu64p(hc->bufptr+8*(l+n)); } case 0: case 1: //case 6: if (gdftyp==5) { for (l=0; lEVENT.POS[N+l] = leu32p(hc->bufptr+4*l); } else { for (l=0; lEVENT.POS[N+l] = leu64p(hc->bufptr+8*l); } for (l=0; lEVENT.TYP[N+l] = type; hdr->EVENT.CHN[N+l] = k; //hdr->EVENT.TimeStamp[N+l] = 0; } } N+=n; } hdr->EVENT.N=N; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__func__,__LINE__); hdr2ascii(hdr,stdout,4); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Support for NEX format is not ready yet"); return(hdr); } else if (hdr->TYPE==NIFTI) { if (count<352) count += ifread(hdr->AS.Header+count, 1, 352-count, hdr); // nifti_1_header *NIFTI_HDR = (nifti_1_header*)hdr-AS.Header; char SWAP = *(int16_t*)(Header1+40) > 7; #if (__BYTE_ORDER == __BIG_ENDIAN) hdr->FILE.LittleEndian = SWAP; #elif (__BYTE_ORDER == __LITTLE_ENDIAN) hdr->FILE.LittleEndian = !SWAP; #endif if (!SWAP) { hdr->HeadLen = (size_t)*(float*)(Header1+80); } else { union {uint32_t u32; float f32;} u; u.u32 = bswap_32(*(uint32_t*)(Header1+108)); hdr->HeadLen = (size_t)u.f32; } if (Header1[345]=='i') { ifclose(hdr); char *f0 = hdr->FileName; char *f1 = (char*)malloc(strlen(hdr->FileName)+4); strcpy(f1,hdr->FileName); strcpy(strrchr(f1,'.') + 1, "img"); // Flawfinder: ignore hdr->FileName = f1; hdr = ifopen(hdr,"r"); hdr->FileName = f0; } else ifseek(hdr,hdr->HeadLen,SEEK_SET); #ifdef _NIFTI_HEADER_ nifti_1_header *NIFTI_HDR = (nifti_1_header*)hdr->AS.Header; #endif ifclose(hdr); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NIFTI not supported"); return(hdr); } else if (hdr->TYPE==NUMPY) { /* There is no way to extract sampling rate and scaling factors from numpy files. For this reason, numpy is not going to be a supported data format. */ fprintf(stderr,"Warning SOPEN (NUMPY): sampling rate, scaling, physical units etc. are not supported, and are most likely incorrect."); hdr->VERSION = hdr->AS.Header[6]+hdr->AS.Header[7]/100; hdr->HeadLen = leu16p(hdr->AS.Header+8); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, hdr->HeadLen+1); count += ifread(hdr->AS.Header + count, 1, hdr->HeadLen - count, hdr); } hdr->AS.Header[count]=0; hdr->NS=1; hdr->SPR=0; hdr->NRec=1; uint16_t gdftyp = 0; const char *h=(char*)hdr->AS.Header+10; int flag_order = (strstr(h,"'fortran_order': False")==NULL) + (strstr(h,"'fortran_order': True")==NULL)*2; switch (flag_order) { case 1: break; case 2: break; default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "format NUMPY: fortran_order not specified or invalid"); } char *descr = strstr(h,"'descr':"); if (descr==NULL) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NUMPY: descr not defined"); else { descr += 8; descr += strspn(descr," \t'"); descr[strcspn(descr," \t'")]=0; if (descr[0]=='<') hdr->FILE.LittleEndian = 1; else if (descr[0]=='>') hdr->FILE.LittleEndian = 0; else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NUMPY: field 'descr': endianity undefined"); if (!strcmp(descr+1,"f8")) gdftyp = 17; else if (!strcmp(descr+1,"f4")) gdftyp = 16; else if (!strcmp(descr+1,"u8")) gdftyp = 8; else if (!strcmp(descr+1,"i8")) gdftyp = 7; else if (!strcmp(descr+1,"u4")) gdftyp = 6; else if (!strcmp(descr+1,"i4")) gdftyp = 5; else if (!strcmp(descr+1,"u2")) gdftyp = 4; else if (!strcmp(descr+1,"i2")) gdftyp = 3; else if (!strcmp(descr+1,"u1")) gdftyp = 2; else if (!strcmp(descr+1,"i1")) gdftyp = 1; else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NUMPY: field 'descr': not supported"); } char *shapestr = strstr(h,"'shape':"); if (shapestr==NULL) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NUMPY: shape not defined"); else { int n = 0; char *tmpstr = strchr(shapestr,'(') + 1; while (tmpstr && *tmpstr) { *strchr(tmpstr,')') = 0; // terminating \0 char *next = strchr(tmpstr,','); if (next) { *next=0; long dim = atol(tmpstr); switch (n) { case 0: hdr->SPR =dim; break; case 1: hdr->NS =dim; break; //case 2: hdr->NRec=dim; break; default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "format NUMPY: shape not supported"); } n++; tmpstr = next+1; } } } hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]>>3; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); typeof (hdr->NS) k; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Transducer[0] = 0; hc->Label[0] = 0; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; hc->Cal = 1.0; hc->Off = 0.0; } if (VERBOSE_LEVEL > 6) fprintf(stdout,"NUMPY:\n%s",(char*)hdr->AS.Header+10); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format NUMPY not supported"); return(hdr); } else if (hdr->TYPE==Persyst) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d) (Persyst) [225]\n", __func__,__LINE__); size_t c=1; while (~ifeof(hdr) && c) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d) (Persyst) [25] %d\n",__func__,__LINE__,(int)count); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count*2+1); c = ifread(hdr->AS.Header + count, 1, count, hdr); count += c; } hdr->AS.Header[count] = 0; ifclose(hdr); hdr->SPR = 1; int32_t gdftyp = 3; double Cal = 1.0; int status = 0; char *remHDR=(char*)hdr->AS.Header; const char *FirstName=NULL, *MiddleName=NULL, *SurName=NULL; char *datfile = NULL; struct tm RecTime; size_t NEvent = 0; hdr->FLAG.OVERFLOWDETECTION = 0; // overflow detection is not supported for this format double DigMax = ldexp(1,-15); double DigMin = -ldexp(1,-15)-1; char *line; char flag_interleaved = 1; while (1) { if (*remHDR == '\0') break; // line = strsep(&remHDR,"\n\r"); line = remHDR; remHDR = strpbrk(remHDR,"\n\r\0"); *remHDR++ = 0; remHDR += strspn(remHDR,"\n\r"); if (!strncmp(line,"[FileInfo]",10)) status = 1; else if (!strncmp(line,"[ChannelMap]",12)) { status = 2; hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]>>3; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); uint16_t ch; for (ch=0; ch < hdr->NS; ch++) { CHANNEL_TYPE *hc = hdr->CHANNEL+ch; hc->PhysMax = DigMax*Cal; hc->PhysMin = DigMin*Cal; hc->DigMax = DigMax; hc->DigMin = DigMin; hc->Cal = Cal; hc->Off = 0.0; hc->OnOff = 1; hc->Label[0] = 0; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->PhysDimCode = 0; //TODO hc->GDFTYP = gdftyp; hc->TOffset = NAN; hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; hc->Impedance = NAN; hc->SPR = hdr->SPR; hc->bi8 = ch*GDFTYP_BITS[gdftyp]; hc->bi = hc->bi8>>3; hc->bufptr = NULL; } } else if (!strncmp(line,"[Sheets]",8)) status = 3; else if (!strncmp(line,"[Comments]",10)) status = 4; else if (!strncmp(line,"[Patient]",9)) status = 5; else if (!strncmp(line,"[SampleTimes]",13)) status = 6; else { switch (status) { case 1: { char *tag = line; char *val = strchr(line,'='); *val= 0; // replace "=" with terminating \0 val++; // next character is the start of the value parameters if (!strcmp(tag,"File")) { datfile = strrchr(val,'/'); if (!datfile) datfile = strrchr(val,'\\')+1; if (!datfile) datfile = val; } else if (!strcmp(line,"FileType")) flag_interleaved = !strcmp(val,"Interleaved"); else if (!strcmp(line,"SamplingRate")) hdr->SampleRate = atof(val); else if (!strcmp(line,"Calibration")) Cal = atof(val); else if (!strcmp(line,"WaveformCount")) hdr->NS = atol(val); else if (!strcmp(line,"DataType")) { switch (atol(val)) { case 0: gdftyp = 3; // int 16 hdr->FILE.LittleEndian = 1; hdr->AS.bpb *= 2; DigMin = -ldexp(1.0,-15)-1; DigMax = ldexp(1.0,-15); break; case 4: gdftyp = 3; // int16 hdr->FILE.LittleEndian = 0; hdr->AS.bpb *= 2; DigMin = -ldexp(1.0,-15)-1; DigMax = ldexp(1.0,-15); break; case 6: gdftyp = 1; // int8 DigMin = -ldexp(1.0,-7)-1; DigMax = ldexp(1.0,-7); break; default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Persyst: unsupported data type"); } } break; } case 2: { char *tag = line; char *val = strchr(line,'='); *val = 0; // replace "=" with terminating \0 val++; // next character is the start of the value parameters int channo = atol(val)-1; if (0 <= channo && channo < hdr->NS) { strncpy(hdr->CHANNEL[channo].Label, tag, MAX_LENGTH_LABEL); } break; } case 3: { break; } case 4: { if (NEvent < hdr->EVENT.N+2) { NEvent += max(128,NEvent); if (reallocEventTable(hdr, NEvent) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return (hdr); }; } char *tmp2,*tmp1 = line; tmp2 = strchr(tmp1,','); *tmp2 = 0; hdr->EVENT.POS[hdr->EVENT.N] = atof(tmp1)*hdr->SampleRate; tmp1 = strchr(tmp2+1,','); *tmp1 = 0; hdr->EVENT.DUR[hdr->EVENT.N] = atof(tmp1)*hdr->SampleRate; tmp2 = strchr(tmp1+1,','); *tmp2 = 0; // ignore next field tmp1 = strchr(tmp2+1,','); *tmp1 = 0; // ignore next field char *Desc = tmp1+1; FreeTextEvent(hdr,hdr->EVENT.N,Desc); hdr->EVENT.N++; break; } case 5: { char *val = strchr(line,'='); *val= 0; // replace "=" with terminating \0 val++; // next character is the start of the value parameters if (!strcmp(line,"First")) FirstName=val; else if (!strcmp(line,"MI")) MiddleName=val; else if (!strcmp(line,"Last")) SurName=val; else if (!strcmp(line,"Hand")) hdr->Patient.Handedness = (toupper(val[0])=='R') + 2*(toupper(val[0])=='L') ; else if (!strcmp(line,"Sex")) hdr->Patient.Sex = (toupper(val[0])=='M') + 2*(toupper(val[0])=='F') ; else if (!strcmp(line,"BirthDate")) { struct tm t; t.tm_year = atol(val+6); if (t.tm_year < 80) t.tm_year+=100; val[5]=0; t.tm_mday = atol(val+3); val[2]=0; t.tm_mon = atol(val); t.tm_hour = 12; t.tm_min = 0; t.tm_sec = 0; hdr->Patient.Birthday = tm_time2gdf_time(&t); } else if (!strcmp(line,"TestDate")) { RecTime.tm_year = atol(val+6); if (RecTime.tm_year < 80) RecTime.tm_year+=100; val[5]=0; RecTime.tm_mday = atol(val+3); val[2]=0; RecTime.tm_mon = atol(val); } else if (!strcmp(line,"TestTime")) { RecTime.tm_sec = atol(val+6); val[5]=0; RecTime.tm_min = atol(val+3); val[2]=0; RecTime.tm_hour = atol(val); } else if (!strcmp(line,"ID")) { strncpy(hdr->Patient.Id,val,MAX_LENGTH_PID); hdr->Patient.Id[MAX_LENGTH_PID] = 0; } /* Omitted, because it is not important, identification through ID, and T0; quality is determined by Technician else if (!strcmp(line,"Physician")) Physician=val; */ else if (!strcmp(line,"Technician")) hdr->ID.Technician = strdup(val); else if (!strcmp(line,"Medications")) hdr->Patient.Medication = (val!=NULL) && strlen(val)>0; break; } case 6: { break; } case 7: { break; } } } } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [260] %d<%s>\n",status,line); hdr->T0 = tm_time2gdf_time(&RecTime); if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [270] %d<%s>\n",status,line); if (!hdr->FLAG.ANONYMOUS) { size_t len = 0, len0=0; if (SurName!=NULL) len += strlen(SurName); if (len < MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name, SurName); hdr->Patient.Name[len]=0x1f; len0 = ++len; } if (FirstName!=NULL) len += strlen(FirstName); if (len < MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name+len0, FirstName); hdr->Patient.Name[len]=' '; len0 = ++len; } if (MiddleName!=NULL) len += strlen(MiddleName); if (len < MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name+len0, MiddleName); hdr->Patient.Name[len0]=' '; } hdr->Patient.Name[len]=0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [280] %d<%s>\n",status,datfile); size_t len = strlen(hdr->FileName); char *FileName = hdr->FileName; hdr->FileName = (char*) malloc(len+strlen(datfile)+2); if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [283] %d<%s> %d/%d\n",(int)len,datfile,(int)hdr->SPR,(int)hdr->NRec); if (strspn(FileName,"/\\")) { strcpy(hdr->FileName, FileName); char *tmpstr = strrchr(hdr->FileName,'/')+1; if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [285] %d<%s>\n",(int)len,tmpstr); if (tmpstr==NULL) tmpstr = strrchr(hdr->FileName,'\\')+1; if (tmpstr!=NULL) strcpy(tmpstr,datfile); else { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Format Persyst: cannot open dat file."); } } else { strcpy(hdr->FileName, datfile); } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [290] %d<%s>\n",status, hdr->FileName); struct stat FileBuf; if (stat(hdr->FileName, &FileBuf)==0) { hdr->FILE.size = FileBuf.st_size; hdr->NRec = FileBuf.st_size*8/(hdr->NS*GDFTYP_BITS[gdftyp]); if (!flag_interleaved) { hdr->SPR = hdr->NRec; hdr->NRec = 1; uint16_t ch; for (ch=0; ch < hdr->NS; ch++) { CHANNEL_TYPE *hc = hdr->CHANNEL+ch; hc->SPR = hdr->SPR; size_t bi8 = ch * (size_t)hdr->SPR * GDFTYP_BITS[gdftyp]; hc->bi8 = bi8; hc->bi = bi8>>3; } hdr->AS.bpb = FileBuf.st_size; } } else { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "Format Persyst: cannot open dat file."); } ifopen(hdr,"r"); hdr->HeadLen = 0; // datfile has no header free(hdr->FileName); hdr->FileName = FileName; if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN (Persyst) [298] %d %d %d\n",(int)FileBuf.st_size,(int)hdr->AS.bpb,(int)(FileBuf.st_size/hdr->AS.bpb)); } else if (hdr->TYPE==PLEXON) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format PLEXON not supported"); return(hdr); } else if (hdr->TYPE==RDF) { // UCSD ERPSS aquisition system #define RH_F_CONV 0x0001 /* converted from other format */ #define RH_F_RCOMP 0x0002 /* raw file is compressed */ #define RH_F_DCMAP 0x4000 /* channel mapping used during dig. */ #define RH_CHANS 256 /* maximum # channels */ #define RH_DESC 64 /* max # chars in description */ #define RH_CHDESC 8 /* max # chars in channel descriptor */ #define RH_SFILL 4 /* short filler */ #define RH_LFILL 6 /* long filler */ #define RH_ALOG 828 /* max # chars in ASCII log */ struct rawhdr { uint16_t rh_byteswab; /* ERPSS byte swab indicator */ uint16_t rh_magic; /* file magic number */ uint16_t rh_flags; /* flags */ uint16_t rh_nchans; /* # channels */ uint16_t rh_calsize; /* (if norm, |cal|) */ uint16_t rh_res; /* (if norm, in pts/unit) */ uint16_t rh_pmod; /* # times processed */ uint16_t rh_dvers; /* dig. program version */ uint16_t rh_l2recsize; /* log 2 record size */ uint16_t rh_recsize; /* record size in pts */ uint16_t rh_errdetect; /* error detection in effect */ uint16_t rh_chksum; /* error detection chksum */ uint16_t rh_tcomp; /* log 2 time comp/exp */ uint16_t rh_narbins; /* (# art. rej. count slots) */ uint16_t rh_sfill[RH_SFILL]; /* short filler (to 16 slots) */ uint16_t rh_nrmcs[RH_CHANS]; /* (cal sizes used for norm.) */ uint32_t rh_time; /* creation time, secs since 1970 */ uint32_t rh_speriod; /* digitization sampling period */ uint32_t rh_lfill[RH_LFILL]; /* long filler (to 8 slots) */ char rh_chdesc[RH_CHANS][RH_CHDESC]; /* chan descriptions */ char rh_chmap[RH_CHANS]; /* input chan mapping array */ char rh_subdesc[RH_DESC]; /* subject description */ char rh_expdesc[RH_DESC]; /* experimenter description */ char rh_ename[RH_DESC]; /* experiment name */ char rh_hname[RH_DESC]; /* host machine name */ char rh_filedesc[RH_DESC]; /* file description */ char rh_arbdescs[RH_DESC]; /* (art. rej. descriptions) */ char rh_alog[RH_ALOG]; /* ASCII log */ }; if (count < sizeof(struct rawhdr)) { hdr->HeadLen = sizeof(struct rawhdr); hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header,hdr->HeadLen+1); count += ifread(Header1+count, 1, hdr->HeadLen-count, hdr); hdr->AS.Header[hdr->HeadLen]=0; } hdr->NS = *(uint16_t*)(hdr->AS.Header+2); time_t T0 = (time_t)*(uint32_t*)(hdr->AS.Header+32); // seconds since 1970 hdr->T0 = t_time2gdf_time(T0); hdr->SampleRate = 1e6 / (*(uint32_t*)(hdr->AS.Header+36)); strncpy(hdr->Patient.Id, (const char*)hdr->AS.Header+32+24+256*9, min(64,MAX_LENGTH_PID)); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->OnOff = 1; strncpy(hc->Label,(char*)(hdr->AS.Header+32+24+8*k),8); hc->Transducer[0] = 0; hc->LeadIdCode = 0; } biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format RDF (UCSD ERPSS) not supported"); } #ifdef WITH_INTAN else if (hdr->TYPE==IntanCLP) { sopen_intan_clp_read(hdr); } else if (hdr->TYPE==RHD2000) { sopen_rhd2000_read(hdr); } else if (hdr->TYPE==RHS2000) { sopen_rhs2000_read(hdr); } #endif else if (hdr->TYPE==SCP_ECG) { hdr->HeadLen = leu32p(hdr->AS.Header+2); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } uint16_t crc = CRCEvaluate(hdr->AS.Header+2,hdr->HeadLen-2); if ( leu16p(hdr->AS.Header) != crc) { biosigERROR(hdr, B4C_CRC_ERROR, "Warning SOPEN(SCP-READ): Bad CRC!"); } hdr->Version = hdr->AS.Header[14]/10.0; sopen_SCP_read(hdr); serror2(hdr); // report and reset error, but continue // hdr->FLAG.SWAP = 0; // no swapping hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); // no swapping hdr->AS.length = hdr->NRec; } else if (hdr->TYPE==Sigma) { /********* Sigma PLpro ************/ hdr->HeadLen = leu32p(hdr->AS.Header+16); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header,hdr->HeadLen+1); count += ifread(Header1+count, 1, hdr->HeadLen-count, hdr); } hdr->AS.Header[count]=0; struct tm t; char *tag, *val; size_t pos = leu32p(hdr->AS.Header+28); uint8_t len; typeof(hdr->NS) k; for (k=0; k<5; k++) { #define line ((char*)(hdr->AS.Header+pos)) len = strcspn(line,"\x0a\x0d"); line[len] = 0; tag = line; val = strchr(line,'='); if (val!=NULL) { val[0] = 0; val++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%i: %s=%s\n",k,tag,val); if (0) {} //else if (!strcmp(tag,"Name")) {} //else if (!strcmp(tag,"Vorname")) {} else if (!strcmp(tag,"GebDat")) { sscanf(val,"%02u.%02u.%04u",&t.tm_mday,&t.tm_mon,&t.tm_year); t.tm_year -=1900; t.tm_mon--; t.tm_hour = 12; t.tm_min = 0; t.tm_sec = 0; t.tm_isdst = -1; hdr->T0 = tm_time2gdf_time(&t); } else if (!strcmp(tag,"ID")) strncpy(hdr->Patient.Id,val,MAX_LENGTH_PID); pos += len+1; while ((line[0]==10) || (line[0]==13)) pos++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"333 SIGMA pos=%i, 0x%x\n", (int)pos, (int)pos); hdr->NS = leu16p(hdr->AS.Header+pos); hdr->SampleRate = 128; hdr->SPR = 1; hdr->NRec = -1; // unknown struct stat stbuf; if(!stat(hdr->FileName, &stbuf)) { if (!hdr->FILE.COMPRESSION) hdr->NRec = (stbuf.st_size-hdr->HeadLen)/(2*hdr->NS); else fprintf(stdout,"Compressed Sigma file (%s) is currently not supported. Uncompress file and try again.", hdr->FileName); } if (VERBOSE_LEVEL>7) fprintf(stdout,"333 SIGMA NS=%i/0x%x, Fs=%f, SPR=%i, NRec=%i\n",hdr->NS,hdr->NS, hdr->SampleRate,hdr->SPR,(int)hdr->NRec); // define variable header pos = 148; hdr->FLAG.UCAL = 1; hdr->FLAG.OVERFLOWDETECTION = 0; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); uint16_t p[] = {4,19,19,19,19+2,19,19,19,19+8,9,11}; // difference of positions of string elements within variable header for (k=1; k < sizeof(p)/sizeof(p[0]); k++) p[k] += p[k-1]; // relative position double *fs = (double*) malloc(hdr->NS * sizeof(double)); double minFs = INFINITY; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; pos = 148 + k*203; // ch = lei16p(hdr->AS.Header+pos); double val; hc->GDFTYP = 3; hc->OnOff = 1; hc->SPR = 1; hc->DigMax = (int16_t)0x7fff; hc->DigMin = (int16_t)0x8000; hc->PhysMax = hc->DigMax; hc->PhysMin = hc->DigMin; // hc->Cal = 1.0; hc->Off = 0.0; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = *(int16_t*)(hdr->AS.Header+pos+2) ? 1.0 : 0.0; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->Label[0] = 0; unsigned k1; for (k1 = sizeof(p)/sizeof(p[0]); k1>0; ) { k1--; len = hdr->AS.Header[pos+p[k1]]; hdr->AS.Header[pos+p[k1]+len+1] = 0; val = atof((char*)(hdr->AS.Header+pos+p[k1]+1)); switch (k1) { case 0: // Abtastrate fs[k] = val; if (hdr->SampleRate < fs[k]) hdr->SampleRate=fs[k]; if (minFs > fs[k]) minFs=fs[k]; break; case 1: // obere Grenzfrequenz hc->LowPass = val; break; case 2: // untere Grenzfrequenz hc->HighPass = val; break; case 6: // Electrodenimpedanz hc->Impedance = val; break; case 7: // Sensitivitaet Verstaerker hc->Cal = val; break; case 8: // Elektrodenbezeichnung strcpy(hc->Label, (char*)(hdr->AS.Header+pos+p[k1]+1)); break; case 10: // Masseinheit hc->PhysDimCode = PhysDimCode((char*)(hdr->AS.Header+pos+p[k1]+1)); break; case 11: // strcpy(hc->Transducer, (char*)(hdr->AS.Header+pos+p[k1]+1)); break; case 3: // gerfac ? case 4: // Kalibriergroesse case 5: // Kanaldimension case 9: // Bezeichnung der Referenzelektrode {}; } } hc->Off = lei16p(hdr->AS.Header+pos+ 80) * hc->Cal; hc->XYZ[0] = lei32p(hdr->AS.Header+pos+158); hc->XYZ[1] = lei32p(hdr->AS.Header+pos+162); hc->XYZ[2] = lei32p(hdr->AS.Header+pos+166); } #undef line hdr->SPR = (typeof(hdr->SPR))round(hdr->SampleRate/minFs); for (k=0,hdr->AS.bpb=0; kNS; k++) { hdr->CHANNEL[k].SPR = (typeof(hdr->SPR))round(fs[k]/minFs); hdr->CHANNEL[k].bi = hdr->AS.bpb; hdr->AS.bpb += hdr->CHANNEL[k].SPR*2; } free(fs); } /******* end of Sigma PLpro ********/ /* else if (hdr->TYPE==SMA) { char *delim = "=\x0a\x0d\x22"; } */ else if (hdr->TYPE==SND) { /* read file */ // hdr->FLAG.SWAP = (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->FILE.LittleEndian = 0; hdr->HeadLen = beu32p(hdr->AS.Header+4); size_t datlen = beu32p(hdr->AS.Header+8); uint32_t filetype = beu32p(hdr->AS.Header+12); hdr->SampleRate = (double)beu32p(hdr->AS.Header+16); hdr->NS = beu32p(hdr->AS.Header+20); if (countHeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count,1,hdr->HeadLen-count,hdr); } else { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); ifseek(hdr,hdr->HeadLen,SEEK_SET); } const uint16_t SND_GDFTYP[] = {0,2,1,3,255+24,5,16,17,0,0,0,2,4,511+25,6}; uint16_t gdftyp = SND_GDFTYP[filetype]; hdr->AS.bpb = hdr->NS * GDFTYP_BITS[gdftyp]>>3; double Cal = 1; if ((filetype>1) && (filetype<6)) Cal = ldexp(1,-GDFTYP_BITS[gdftyp]); hdr->NRec = datlen/hdr->AS.bpb; hdr->SPR = 1; hdr->FLAG.OVERFLOWDETECTION = 0; // automated overflow and saturation detection not supported hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); double digmax = ldexp(1,GDFTYP_BITS[gdftyp]); for (k=0,hdr->AS.bpb=0; k < hdr->NS; k++) { CHANNEL_TYPE* hc = hdr->CHANNEL+k; hc->OnOff = 1; hc->GDFTYP = gdftyp; hc->SPR = 1; hc->Cal = Cal; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = -1; hc->HighPass = -1; hc->PhysMax = 1.0; hc->PhysMin = -1.0; hc->DigMax = digmax; hc->DigMin = -digmax; hc->LeadIdCode = 0; hc->PhysDimCode = 0; hc->Label[0] = 0; hc->bi = hdr->AS.bpb; hdr->AS.bpb += GDFTYP_BITS[gdftyp]>>3; } } #if defined(WITH_TDMS) else if (hdr->TYPE==TDMS) { sopen_tdms_read(hdr); } #endif else if (hdr->TYPE==TMS32) { hdr->VERSION = leu16p(hdr->AS.Header+31); hdr->SampleRate = leu16p(hdr->AS.Header+114); size_t NS = leu16p(hdr->AS.Header+119); hdr->HeadLen = 217 + NS*136; if (hdr->HeadLen > count) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } else ifseek(hdr,hdr->HeadLen,SEEK_SET); // size_t filesize = lei32p(hdr->AS.Header+121); tm_time.tm_year = lei16p(hdr->AS.Header+129)-1900; tm_time.tm_mon = lei16p(hdr->AS.Header+131)-1; tm_time.tm_mday = lei16p(hdr->AS.Header+133); tm_time.tm_hour = lei16p(hdr->AS.Header+137); tm_time.tm_min = lei16p(hdr->AS.Header+139); tm_time.tm_sec = lei16p(hdr->AS.Header+141); tm_time.tm_isdst= -1; hdr->T0 = tm_time2gdf_time(&tm_time); hdr->NRec = lei32p(hdr->AS.Header+143); hdr->SPR = leu16p(hdr->AS.Header+147); //hdr->AS.bpb = leu16p(hdr->AS.Header+149)+86; hdr->AS.bpb = 86; hdr->FLAG.OVERFLOWDETECTION = 0; hdr->CHANNEL = (CHANNEL_TYPE*)calloc(NS, sizeof(CHANNEL_TYPE)); size_t aux = 0; for (k=0; k < NS; k += 1) { CHANNEL_TYPE* hc = hdr->CHANNEL+aux; uint8_t StringLength = hdr->AS.Header[217+k*136]; char *SignalName = (char*)(hdr->AS.Header+218+k*136); if (!strncmp(SignalName, "(Lo) ", 5)) { strncpy(hc->Label,SignalName+5,StringLength-5); hc->GDFTYP = 16; aux += 1; hc->Label[StringLength-5] = 0; hc->bi = hdr->AS.bpb; } else if (!strncmp(SignalName, "(Hi) ", 5)) { } else { strncpy(hc->Label, SignalName, StringLength); hc->GDFTYP = 3; aux += 1; hc->Label[StringLength] = 0; hc->bi = hdr->AS.bpb; } StringLength = hdr->AS.Header[45+217+k*136]; char tmp[256]; strncpy(tmp, (char*)(hdr->AS.Header+46+217+k*136), StringLength); tmp[StringLength] = 0; hc->PhysDimCode = PhysDimCode(tmp); hc->PhysMin = lef32p(hdr->AS.Header+56+217+k*136); hc->PhysMax = lef32p(hdr->AS.Header+60+217+k*136); hc->DigMin = lef32p(hdr->AS.Header+64+217+k*136); hc->DigMax = lef32p(hdr->AS.Header+68+217+k*136); hc->Cal = (hc->PhysMax-hc->PhysMin)/(hc->DigMax-hc->DigMin); hc->Off = hc->PhysMin - hc->Cal * hc->DigMin; hc->OnOff = 1; hc->SPR = hdr->SPR; hc->Transducer[0] = '\0'; hc->LowPass = -1; hc->HighPass = -1; hc->LeadIdCode = 0; //hdr->AS.bpb += 2 * hc->SPR; hdr->AS.bpb += hc->SPR * (GDFTYP_BITS[hc->GDFTYP]>>3); if (VERBOSE_LEVEL>7) fprintf(stdout,"k=%i\tLabel=%s [%s]\tNS=%i\tpos=%i\n",(int)k,SignalName,tmp,(int)NS,(int)iftell(hdr)); } hdr->NS = aux; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); } else if (hdr->TYPE==TMSiLOG) { /* read header docu says HeadLen = 141+275*NS, but our example has 135+277*NS; */ while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count*2+1); count += ifread(hdr->AS.Header + count, 1, count, hdr); } ifclose(hdr); hdr->AS.Header[count] = 0; hdr->NS = 0; hdr->SPR = 1; hdr->NRec = 1; double duration = 0.0; uint16_t gdftyp = 0; char *line = strstr(Header1,"Signals="); if (line) { char tmp[5]; strncpy(tmp,line+8,5); hdr->NS = atoi(tmp); } if (!hdr->NS) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: multiple data files not supported"); } hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); char *filename = NULL; line = strtok(Header1,"\x0d\x0a"); while (line) { char *val = strchr(line,'='); val[0] = 0; val++; if (!strcmp(line,"FileId")) {} else if (!strcmp(line,"Version")) hdr->VERSION = atoi(val); else if (!strcmp(line,"DateTime")) { struct tm t; sscanf(val,"%04d/%02d/%02d-%02d:%02d:%02d",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec); t.tm_year -= 1900; t.tm_mon--; t.tm_isdst =-1; } else if (!strcmp(line,"Format")) { if (!strcmp(val,"Float32")) gdftyp = 16; else if (!strcmp(val,"Int32 ")) gdftyp = 5; else if (!strcmp(val,"Int16 ")) gdftyp = 3; else if (!strcmp(val,"Ascii ")) gdftyp = 0xfffe; else gdftyp = 0xffff; } else if (!strcmp(line,"Length")) { duration = atof(val); } else if (!strcmp(line,"Signals")) { hdr->NS = atoi(val); } else if (!strncmp(line,"Signal",6)) { char tmp[5]; strncpy(tmp,line+6,4); size_t ch = atoi(tmp)-1; char *field = line+11; if (!strcmp(field,"Name")) strncpy(hdr->CHANNEL[ch].Label,val,MAX_LENGTH_LABEL); else if (!strcmp(field,"UnitName")) hdr->CHANNEL[ch].PhysDimCode=PhysDimCode(val); else if (!strcmp(field,"Resolution")) hdr->CHANNEL[ch].Cal=atof(val); else if (!strcmp(field,"StoreRate")) { hdr->NRec = (nrec_t)atof(val)*duration; hdr->CHANNEL[ch].SPR = 1; // hdr->CHANNEL[ch].SPR=atof(val)*duration; //hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[ch].SPR); } else if (!strcmp(field,"File")) { if (!filename) filename = val; else if (strcmp(val, filename)) { fprintf(stdout,"<%s><%s>",val,filename); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: multiple data files not supported"); } } else if (!strcmp(field,"Index")) {} else fprintf(stdout,"TMSi Signal%04i.%s = <%s>\n",(int)ch,field,val); } else fprintf(stdout,"TMSi %s = <%s>\n",line,val); line = strtok(NULL,"\x0d\x0a"); } hdr->SampleRate = hdr->SPR*hdr->NRec/duration; hdr->NRec *= hdr->SPR; hdr->SPR = 1; char *fullfilename = (char*)malloc(strlen(hdr->FileName)+strlen(filename)+1); if (!filename) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: data file not specified"); } else if (strrchr(hdr->FileName,FILESEP)) { strcpy(fullfilename,hdr->FileName); strcpy(strrchr(fullfilename,FILESEP)+1,filename); } else { strcpy(fullfilename,filename); } filename = NULL; // filename had a pointer to hdr->AS.Header; could be released here if (gdftyp < 1000) { FILE *fid = fopen(fullfilename,"rb"); if (!fid) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: data file not found"); } else { int16_t h[3]; size_t c = fread(h, 2, 3, fid); if (h[2]==16) h[2] = 3; else if (h[2]==32) h[2] = 5; else if (h[2]==288) h[2] = 16; else h[2] = 0xffff; // this triggers the error trap if ( (c<2) || (h[0] != hdr->NS) || (((double)h[1]) != hdr->SampleRate) || (h[2] != gdftyp) ) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: Binary file corrupted"); } else { size_t sz = (size_t)hdr->NS*hdr->SPR*hdr->NRec*(GDFTYP_BITS[gdftyp]>>3); hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,sz); c = fread(hdr->AS.rawdata, hdr->NRec, hdr->SPR*hdr->NS*GDFTYP_BITS[gdftyp]>>3, fid); if (c < sz) hdr->NRec = c; } fclose(fid); } } else if (gdftyp==0xfffe) { // double Fs; gdftyp = 17; // ascii is converted to double FILE *fid = fopen(fullfilename,"rt"); if (!fid) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: data file not found"); } else { size_t sz = (hdr->NS+1)*24; char *line = (char*) malloc(sz); // read and ignore (i.e. skip) 3 lines int c = 3; while (c>0) { if (fgetc(fid)=='\n') { c--; int ch = fgetc(fid); // skip '\r' if (ch=='\r') ungetc(ch,fid); } } // TODO: sanity checks if (0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "TMSiLOG: Binary file corrupted"); } else { // hdr->FLAG.SWAP = 0; // no swaping required typeof(hdr->NS) k2; size_t k; hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); size_t sz = (size_t)hdr->NS * hdr->SPR * hdr->NRec * GDFTYP_BITS[gdftyp]>>3; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,sz); for (k=0; k < (size_t)hdr->SPR*hdr->NRec; k++) if (fgets(line,sz,fid)) { char *next; strtoul(line, &next, 10); // skip index entry for (k2=0;k2NS;k2++) *(double*)(hdr->AS.rawdata+(k*hdr->NS+k2)*sizeof(double)) = strtod(next,&next); } else { for (k2=0;k2NS;k2++) *(double*)(hdr->AS.rawdata+(k*hdr->NS+k2)*sizeof(double)) = NAN; } } free(line); fclose(fid); } } free(fullfilename); hdr->AS.length = hdr->NRec; if (VERBOSE_LEVEL>8) fprintf(stdout,"TMSi [149] \n"); hdr->AS.bpb = 0; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (VERBOSE_LEVEL>8) fprintf(stdout,"TMSi [151] %i\n",(int)k); hc->GDFTYP = gdftyp; if (gdftyp==3) { hc->DigMax = (double)(int16_t)0x7fff; hc->DigMin = (double)(int16_t)0x8000; } else if (gdftyp==5) { hc->DigMax = (double)(int32_t)0x7fffffff; hc->DigMin = (double)(int32_t)0x80000000; } else { hc->DigMax = 1.0; hc->DigMin = 0.0; hdr->FLAG.OVERFLOWDETECTION = 0; // no overflow detection } hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->SPR = 1; // one sample per block hc->OnOff = 1; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; hc->bi = hdr->AS.bpb; hdr->AS.bpb += GDFTYP_BITS[gdftyp]>>3; } } else if (hdr->TYPE==AIFF) { // hdr->FLAG.SWAP = (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->FILE.LittleEndian = 0; uint8_t *tag; uint32_t tagsize; //uint16_t gdftyp; size_t pos; tagsize = beu32p(hdr->AS.Header+4); tagsize += tagsize & 0x0001; pos = 12; tag = hdr->AS.Header+pos; while (1) { tagsize = beu32p(hdr->AS.Header+pos+4); tagsize += tagsize & 0x0001; if (!strncmp((char*)tag,"COMM",4)) { } else if (!strncmp((char*)tag,"DATA",4)) { } pos += tagsize; tag = hdr->AS.Header+pos; } /// TODO, FIXME } #if defined(WITH_WAV) || defined(WITH_AVI) || defined(WITH_RIFF) else if ((hdr->TYPE==WAV)||(hdr->TYPE==AVI)||(hdr->TYPE==RIFF)) { // hdr->FLAG.SWAP = (__BYTE_ORDER == __BIG_ENDIAN); hdr->FILE.LittleEndian = 1; uint8_t *tag; uint32_t tagsize; uint16_t gdftyp; uint16_t format=0, bits = 0; double Cal=1.0, Off=0.0; size_t pos; tagsize = leu32p(hdr->AS.Header+4); tagsize += tagsize & 0x0001; pos = 12; tag = hdr->AS.Header+pos; while (1) { tagsize = leu32p(hdr->AS.Header+pos+4); tagsize += tagsize & 0x0001; if (!strncmp((char*)tag,"fmt ",4)) { format = leu16p(hdr->AS.Header+pos+4); hdr->NS = leu16p(hdr->AS.Header+pos+4+2); hdr->SampleRate = (double)leu32p(hdr->AS.Header+pos+4+4); if (format==1) { bits = leu16p(hdr->AS.Header+pos+4+14); Cal = ldexp(1,-8*(bits/8 + ((bits%8) > 0))); if (bits <= 8) { gdftyp = 2; Off = 0.5; } else if (bits <= 16) gdftyp = 3; else if (bits <= 24) gdftyp = 255+24; else if (bits <= 32) gdftyp = 5; } else fprintf(stdout,"Warning (WAV): format not supported.\n"); } else if (!strncmp((char*)tag,"data",4)) { if (format==1) { hdr->AS.bpb = hdr->NS * ((bits/8) + ((bits%8)>0)); hdr->SPR = tagsize/hdr->AS.bpb; } } pos += tagsize; tag = hdr->AS.Header+pos; /// TODO, FIXME } } #endif else if (hdr->TYPE==ASCII_IBI) { hdr->NS = 0; hdr->NRec = 0; hdr->SPR = 1; hdr->AS.bpb = 0; ifseek(hdr,0,SEEK_SET); char line[81]; ifgets(line,80,hdr); size_t N = 0; hdr->EVENT.N = 0; while (!ifeof(hdr) && strlen(line)) { if (isdigit(line[0])) { struct tm t; int ms,rri; char *desc = NULL; #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L sscanf(line,"%02u-%02u-%02u %02u:%02u:%02u %03u %as %u", &t.tm_mday, &t.tm_mon, &t.tm_year, &t.tm_hour, &t.tm_min, &t.tm_sec, &ms, &desc, &rri); #else sscanf(line,"%02u-%02u-%02u %02u:%02u:%02u %03u %ms %u", &t.tm_mday, &t.tm_mon, &t.tm_year, &t.tm_hour, &t.tm_min, &t.tm_sec, &ms, &desc, &rri); #endif if (t.tm_year < 1970) t.tm_year += 100; t.tm_mon--; t.tm_isdst = -1; if (N+1 >= hdr->EVENT.N) { hdr->EVENT.N += max(4096,hdr->EVENT.N); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP) ); } if (N==0) { hdr->T0 = (gdf_time)(tm_time2gdf_time(&t) + ldexp((ms-rri)/(24*3600*1e3),32)); hdr->EVENT.POS[0] = 0; hdr->EVENT.TYP[0] = 0x0501; hdr->EVENT.POS[1] = rri; hdr->EVENT.TYP[1] = 0x0501; N = 1; } else { hdr->EVENT.POS[N] = hdr->EVENT.POS[N-1] + rri; } if (!strcmp(desc,"IBI")) hdr->EVENT.TYP[N] = 0x0501; else FreeTextEvent(hdr,N,desc); ++N; if (desc) free(desc); } else { strtok(line,":"); char *v = strtok(NULL,":"); if (!strncmp(line,"File version",12)) hdr->VERSION = atof(v); else if (!hdr->FLAG.ANONYMOUS && !strncmp(line,"File version",12)) strncpy(hdr->Patient.Id,v,MAX_LENGTH_PID); } ifgets(line,80,hdr); } ifclose(hdr); hdr->EVENT.N = N; hdr->SampleRate = 1000.0; hdr->EVENT.SampleRate = 1000.0; hdr->TYPE = EVENT; hdr->data.block = NULL; hdr->data.size[0] = 0; hdr->data.size[1] = 0; } #if defined(WITH_DICOM) || defined(WITH_GDCM) || defined(WITH_DCMTK) else if (hdr->TYPE==DICOM) { fprintf(stderr,"DICOM support is very (!!!) experimental!\n"); hdr->HeadLen = count; sopen_dicom_read(hdr); return(hdr); } #endif else if (hdr->TYPE==HL7aECG || hdr->TYPE==XML) { sopen_HL7aECG_read(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[181] #%i\n",hdr->NS); if (hdr->AS.B4C_ERRNUM) return(hdr); // hdr->FLAG.SWAP = 0; hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); // no swapping hdr->AS.length = hdr->NRec; } #ifdef WITH_MICROMED else if (hdr->TYPE==TRC) { sopen_TRC_read(hdr); } #endif else if (hdr->TYPE==UNIPRO) { sopen_unipro_read(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[181] #%i\n",hdr->NS); if (hdr->AS.B4C_ERRNUM) return(hdr); // hdr->FLAG.SWAP = 0; } else if (hdr->TYPE==WCP) { fprintf(stderr,"%s (line %i) %s: WARNING WCP support is experimental!\n", __FILE__,__LINE__,__func__); const int WCP_HEADER_LENGTH=2048; if (hdr->HeadLen < WCP_HEADER_LENGTH) { hdr->AS.Header = realloc(hdr->AS.Header, WCP_HEADER_LENGTH); hdr->HeadLen += ifread(hdr->AS.Header+hdr->HeadLen, 1, WCP_HEADER_LENGTH - hdr->HeadLen, hdr); } int ADCMAX=0; char *tok = strtok(hdr->AS.Header,"\r\n"); while (tok != NULL) { char *sep = strchr(tok,'='); *sep = 0; char *val = sep+1; char *key = tok; if (!strcmp(key,"VER")) hdr->VERSION=atof(val); else if (!strcmp(key,"RTIME")) { struct tm T; #if !defined(_WIN32) strptime(val,"%d/%m/%Y %T",&T); #else char *p=val+strlen(val); do p--; while (isdigit(*p) && (p>val)); T.tm_sec = atoi(p+1); *p=0; do p--; while (isdigit(*p) && (p>val)); T.tm_min = atoi(p+1); *p=0; do p--; while (isdigit(*p) && (p>val)); T.tm_hour = atoi(p+1); *p=0; do p--; while (isdigit(*p) && (p>val)); T.tm_year = atoi(p+1); *p=0; do p--; while (isdigit(*p) && (p>val)); T.tm_mon = atoi(p+1); *p=0; do p--; while (isdigit(*p) && (p>val)); T.tm_mday = atoi(p+1); #endif hdr->T0 = tm_time2gdf_time(&T); } else if (!strcmp(key,"NC")) { hdr->NS=atoi(val); hdr->CHANNEL = realloc(hdr->CHANNEL, sizeof(CHANNEL_TYPE)*hdr->NS); } else if (!strcmp(key,"DT")) hdr->SampleRate=1.0/atof(val); else if (!strcmp(key,"ADCMAX")) ADCMAX=atoi(val); else if (!strcmp(key,"NR")) hdr->NRec=atoi(val); else if (key[0]=='Y') { int chan = atoi(key+2); CHANNEL_TYPE *hc = hdr->CHANNEL+chan; switch (key[1]) { case 'U': // YU hc->PhysDimCode = PhysDimCode(val); break; case 'N': // YN strncpy(hc->Label, val, MAX_LENGTH_LABEL+1); break; case 'G': // YG hc->Cal = atof(val); break; } } else { fprintf(stdout,"%s-WCP: %s=%s ignored\n",__func__,key,val); } tok = strtok(NULL,"\r\n"); } uint16_t gdftyp=3; if (ADCMAX==32767) gdftyp = 3; struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->SPR = 1; typeof (hdr->NS) k; size_t bpb8=0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Transducer[0] = 0; hc->GDFTYP = gdftyp; hc->OnOff = 1; hc->bi = bpb8>>3; hc->Off = 0.0; hc->DigMax = ADCMAX; hc->DigMin = -ADCMAX; hc->PhysMax = ADCMAX*hc->Cal; hc->PhysMin = -ADCMAX*hc->Cal; hc->SPR = 1; hc->TOffset = 0.0; hc->LowPass = 0.0; hc->HighPass= 0.0; hc->Notch = 0.0; hc->Impedance = NAN; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; hc->bufptr = NULL; bpb8 += GDFTYP_BITS[gdftyp]; } hdr->AS.bpb = bpb8>>3; hdr->NRec = (FileBuf.st_size - WCP_HEADER_LENGTH)/hdr->AS.bpb; } else if (hdr->TYPE==WG1) { uint32_t VER = leu32p(hdr->AS.Header); if (VER==0xAFFE5555) { // FIXME: this version is currently not implemented if (count < 5120) { hdr->AS.Header = realloc(hdr->AS.Header, 5120); count += ifread(hdr->AS.Header,5120-count,1,hdr); } hdr->HeadLen = count; hdr->NS = leu16p(hdr->AS.Header+0x40); hdr->NRec = leu16p(hdr->AS.Header+0x110); // total number of blocks /* uint16_t gdftyp = 1; uint16_t startblock = leu16p(hdr->AS.Header+0x112); // FIXME: */ biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "ERROR BIOSIG SOPEN(READ): WG1 0x5555FEAF format is not supported yet"); } else { hdr->SampleRate = 1e6 / leu32p(Header1+16); hdr->NS = leu16p(Header1+22); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "ERROR BIOSIG SOPEN(READ): WG1 data format is not supported yet"); } return(hdr); } #endif //ONLYGDF else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "ERROR BIOSIG SOPEN(READ): data format is not supported"); ifclose(hdr); return(hdr); } hdr->FILE.POS = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[189] #%i\n",hdr->NS); for (k=0; kNS; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[190] #%i: LeadIdCode=%i\n",(int)k,hdr->CHANNEL[k].LeadIdCode); // set HDR.PhysDim - this part will become obsolete /* k1 = hdr->CHANNEL[k].PhysDimCode; if (k1>0) hdr->CHANNEL[k].PhysDim = PhysDim3(k1); */ // set HDR.PhysDimCode if (hdr->CHANNEL[k].LeadIdCode == 0) { int k1; if (!strncmp(hdr->CHANNEL[k].Label, "MDC_ECG_LEAD_", 13)) { // MDC_ECG_LEAD_* - ignore case // for (k1=0; strcasecmp(hdr->CHANNEL[k].Label+13,LEAD_ID_TABLE[k1]) && LEAD_ID_TABLE[k1][0]; k1++) {}; if (LEAD_ID_TABLE[k1][0]) hdr->CHANNEL[k].LeadIdCode = k1; } else { for (k1=0; strcmp(hdr->CHANNEL[k].Label, LEAD_ID_TABLE[k1]) && LEAD_ID_TABLE[k1][0]; k1++) {}; if (LEAD_ID_TABLE[k1][0]) hdr->CHANNEL[k].LeadIdCode = k1; } } // based on ISO/DIS 11073-91064, EN 1064:2005+A1:2007 (E) if (200 <= hdr->CHANNEL[k].LeadIdCode) strcpy(hdr->CHANNEL[k].Label,"(Manufacturere specific)"); else if (185 <= hdr->CHANNEL[k].LeadIdCode) strcpy(hdr->CHANNEL[k].Label,"(reserved for future expansion)"); else if (hdr->CHANNEL[k].LeadIdCode) strcpy(hdr->CHANNEL[k].Label,LEAD_ID_TABLE[hdr->CHANNEL[k].LeadIdCode]); // Flawfinder: ignore } if (!hdr->EVENT.SampleRate) hdr->EVENT.SampleRate = hdr->SampleRate; /* convert2to4_eventtable(hdr); convert into canonical form if needed */ } else if (!strncmp(MODE,"w",1)) /* --- WRITE --- */ { hdr->FILE.COMPRESSION = hdr->FILE.COMPRESSION || strchr(MODE,'z'); if ( (hdr->Patient.Id==NULL) || !strlen(hdr->Patient.Id)) strcpy(hdr->Patient.Id,"00000000"); #ifndef WITHOUT_NETWORK if (!memcmp(hdr->FileName,"bscs://",7)) { // network: write to server const char *hostname = hdr->FileName+7; char *tmp= (char*)strchr(hostname,'/'); if (tmp != NULL) tmp[0]=0; // ignore terminating slash uint64_t ID=0; int sd, s; sd = bscs_connect(hostname); if (sd<0) { fprintf(stdout,"could not connect to <%s> (err %i)\n",hostname, sd); biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "could not connect to server"); return(hdr); } hdr->FILE.Des = sd; s = bscs_open(sd, &ID); s = bscs_send_hdr(sd,hdr); hdr->FILE.OPEN = 2; fprintf(stdout,"write file to bscs://%s/%016"PRIx64"\n",hostname,ID); return(hdr); } #endif // NS number of channels selected for writing typeof(hdr->NS) NS = 0; { typeof(hdr->NS) k; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) NS++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"sopen-W ns=%i (%s)\n",NS,GetFileTypeString(hdr->TYPE)); #ifndef ONLYGDF if ((hdr->TYPE==ASCII) || (hdr->TYPE==BIN)) { size_t k; FILE *fid = fopen(hdr->FileName,"w"); hdr->FILE.LittleEndian = 1; fprintf(fid,"#BIOSIG %s\n", (hdr->TYPE==ASCII ? "ASCII" : "BINARY")); fprintf(fid,"# comments start with #\n\n"); fprintf(fid,"Filename\t= %s\t # (this file)\n",hdr->FileName); fprintf(fid,"\n[Header 1]\n"); // fprintf(fid,"\n[Header 1]\nNumberOfChannels\t= %i\n",hdr->NS); //fprintf(fid,"NRec\t= %i\n",hdr->NRec); fprintf(fid,"Duration \t= %f\t# in seconds\n",hdr->SPR*hdr->NRec/hdr->SampleRate); char tmp[40]; snprintf_gdfdatetime(tmp, sizeof(tmp), hdr->T0); fprintf(fid,"Recording.Time \t= %s\t# YYYY-MM-DD hh:mm:ss.uuuuuu\n",tmp); fprintf(fid,"Timezone \t= +%i min\n",hdr->tzmin); fprintf(fid,"Patient.Id \t= %s\n",hdr->Patient.Id); snprintf_gdfdate(tmp, sizeof(tmp), hdr->Patient.Birthday); fprintf(fid,"Patient.Birthday \t= %s\t# YYYY-MM-DD\n",tmp); fprintf(fid,"Patient.Weight \t= %i\t# in [kg]\n",hdr->Patient.Weight); fprintf(fid,"Patient.Height \t= %i\t# in [cm]\n",hdr->Patient.Height); fprintf(fid,"Patient.Gender \t= %i\t# 0:Unknown, 1: Male, 2: Female, 9: Unspecified\n",hdr->Patient.Sex); fprintf(fid,"Patient.Handedness\t= %i\t# 0:Unknown, 1: Right, 2: Left, 3: Equal\n",hdr->Patient.Handedness); fprintf(fid,"Patient.Smoking \t= %i\t# 0:Unknown, 1: NO, 2: YES\n",hdr->Patient.Sex); fprintf(fid,"Patient.AlcoholAbuse\t= %i\t# 0:Unknown, 1: NO, 2: YES\n",hdr->Patient.AlcoholAbuse); fprintf(fid,"Patient.DrugAbuse \t= %i\t# 0:Unknown, 1: NO, 2: YES \n",hdr->Patient.DrugAbuse); fprintf(fid,"Patient.Medication\t= %i\t# 0:Unknown, 1: NO, 2: YES \n",hdr->Patient.Medication); fprintf(fid,"Recording.ID \t= %s\n",hdr->ID.Recording); uint8_t IPv6=0; for (k=4; k<16; k++) IPv6 |= hdr->IPaddr[k]; if (IPv6) fprintf(fid,"Recording.IPaddress \t= %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",hdr->IPaddr[0],hdr->IPaddr[1],hdr->IPaddr[2],hdr->IPaddr[3],hdr->IPaddr[4],hdr->IPaddr[5],hdr->IPaddr[6],hdr->IPaddr[7],hdr->IPaddr[8],hdr->IPaddr[9],hdr->IPaddr[10],hdr->IPaddr[11],hdr->IPaddr[12],hdr->IPaddr[13],hdr->IPaddr[14],hdr->IPaddr[15]); else fprintf(fid,"Recording.IPaddress \t= %u.%u.%u.%u\n",hdr->IPaddr[0],hdr->IPaddr[1],hdr->IPaddr[2],hdr->IPaddr[3]); fprintf(fid,"Recording.Technician\t= %s\n",hdr->ID.Technician); fprintf(fid,"Manufacturer.Name \t= %s\n",hdr->ID.Manufacturer.Name); fprintf(fid,"Manufacturer.Model\t= %s\n",hdr->ID.Manufacturer.Model); fprintf(fid,"Manufacturer.Version\t= %s\n",hdr->ID.Manufacturer.Version); fprintf(fid,"Manufacturer.SerialNumber\t= %s\n",hdr->ID.Manufacturer.SerialNumber); fprintf(fid,"\n[Header 2]\n"); k = strlen(hdr->FileName); char* fn = (char*)calloc(k + 10,1); strcpy(fn, hdr->FileName); char *e = strrchr(fn,'.'); if (e==NULL) { fn[k] = '.'; e = fn+k; } e[1] = (hdr->TYPE == ASCII ? 'a' : 's'); e+=2; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) { if (hdr->FILE.COMPRESSION) sprintf(e,"%02i_gz",(int)k+1); else sprintf(e,"%02i",(int)k+1); fprintf(fid,"Filename \t= %s\n",fn); fprintf(fid,"Label \t= %s\n",hdr->CHANNEL[k].Label); if (hdr->TYPE==ASCII) fprintf(fid,"GDFTYP \t= ascii\n"); else if (hdr->TYPE==BIN) { const char *gdftyp; switch (hdr->CHANNEL[k].GDFTYP) { case 1: gdftyp="int8"; break; case 2: gdftyp="uint8"; break; case 3: gdftyp="int16"; break; case 4: gdftyp="uint16"; break; case 5: gdftyp="int32"; break; case 6: gdftyp="uint32"; break; case 7: gdftyp="int64"; break; case 8: gdftyp="uint64"; break; case 16: gdftyp="float32"; break; case 17: gdftyp="float64"; break; case 18: gdftyp="float128"; break; case 255+24: gdftyp="bit24"; break; case 511+24: gdftyp="ubit24"; break; case 255+12: gdftyp="bit12"; break; case 511+12: gdftyp="ubit12"; break; default: gdftyp = "unknown"; } fprintf(fid,"GDFTYP \t= %s\n",gdftyp); } fprintf(fid,"Transducer\t= %s\n",hdr->CHANNEL[k].Transducer); fprintf(fid,"PhysicalUnits\t= %s\n",PhysDim3(hdr->CHANNEL[k].PhysDimCode)); fprintf(fid,"PhysDimCode\t= %i\n",hdr->CHANNEL[k].PhysDimCode); fprintf(fid,"DigMax \t= %f\n",hdr->CHANNEL[k].DigMax); fprintf(fid,"DigMin \t= %f\n",hdr->CHANNEL[k].DigMin); fprintf(fid,"PhysMax \t= %g\n",hdr->CHANNEL[k].PhysMax); fprintf(fid,"PhysMin \t= %g\n",hdr->CHANNEL[k].PhysMin); fprintf(fid,"SamplingRate\t= %f\n",hdr->CHANNEL[k].SPR*hdr->SampleRate/hdr->SPR); fprintf(fid,"NumberOfSamples\t= %i\t# 0 indicates a channel with sparse samples\n",(int)(hdr->CHANNEL[k].SPR*hdr->NRec)); fprintf(fid,"HighPassFilter\t= %f\n",hdr->CHANNEL[k].HighPass); fprintf(fid,"LowPassFilter\t= %f\n",hdr->CHANNEL[k].LowPass); fprintf(fid,"NotchFilter\t= %f\n",hdr->CHANNEL[k].Notch); switch (hdr->CHANNEL[k].PhysDimCode & 0xffe0) { case 4256: // Voltage data fprintf(fid,"Impedance\t= %f\n",hdr->CHANNEL[k].Impedance); break; case 4288: // Impedance data fprintf(fid,"freqZ\t= %f\n",hdr->CHANNEL[k].fZ); break; } fprintf(fid,"PositionXYZ\t= %f\t%f\t%f\n",hdr->CHANNEL[k].XYZ[0],hdr->CHANNEL[k].XYZ[1],hdr->CHANNEL[k].XYZ[2]); // fprintf(fid,"OrientationXYZ\t= %f\t%f\t%f\n",hdr->CHANNEL[k].Orientation[0],hdr->CHANNEL[k].Orientation[1],hdr->CHANNEL[k].Orientation[2]); // fprintf(fid,"Area \t= %f\n",hdr->CHANNEL[k].Area); fprintf(fid,"\n"); hdr->CHANNEL[k].SPR *= hdr->NRec; } hdr->SPR *= hdr->NRec; hdr->NRec = 1; fprintf(fid,"[EVENT TABLE]\n"); fprintf(fid,"TYP\tPOS [s]\tDUR [s]\tCHN\tVAL/Desc"); for (k=0; kEVENT.N; k++) { fprintf(fid,"\n0x%04x\t%f\t",hdr->EVENT.TYP[k],hdr->EVENT.POS[k]/hdr->EVENT.SampleRate); // EVENT.POS uses 0-based indexing if (hdr->EVENT.DUR != NULL) { typeof(*hdr->EVENT.DUR) DUR; DUR = (hdr->EVENT.TYP[k]==0x7fff) ? 0 : hdr->EVENT.DUR[k]; fprintf(fid,"%f\t%d\t", DUR/hdr->EVENT.SampleRate, hdr->EVENT.CHN[k]); } else fprintf(fid,"\t\t"); if (hdr->EVENT.TYP[k] == 0x7fff) { typeof(hdr->NS) chan = hdr->EVENT.CHN[k] - 1; double val = dur2val(hdr->EVENT.DUR[k], hdr->CHANNEL[chan].GDFTYP); val *= hdr->CHANNEL[chan].Cal; val += hdr->CHANNEL[chan].Off; fprintf(fid,"%g\t# sparse sample ", val); // value of sparse samples } else { const char *str = GetEventDescription(hdr,k); if (str) fprintf(fid,"%s",str); } } fclose(fid); free(fn); hdr->FILE.POS = 0; } else if (hdr->TYPE==ATF) { // Write ATF hdr->HeadLen = 0; hdr->FILE.POS = 0; hdr->FILE.FID = fopen(hdr->FileName, "w"); typeof(hdr->NS) k, NS = 1; for (k = 0; k < hdr->NS; k++) { NS += (hdr->CHANNEL[k].OnOff > 0); } hdr->HeadLen += fprintf(hdr->FILE.FID, "ATF\t1.0\n%"PRIu64"u\t%u", max(0,hdr->NRec * hdr->SPR), NS + 1); char *sep = "\n"; if (getTimeChannelNumber(hdr) == 0) { hdr->HeadLen += fprintf(hdr->FILE.FID, "%s\"Time (s)\"",sep); sep = "\t"; } for (k = 0; k < hdr->NS; k++) { if (hdr->CHANNEL[k].OnOff) { hdr->HeadLen += fprintf(hdr->FILE.FID, "%s\"%s (%s)\"", sep, hdr->CHANNEL[k].Label, PhysDim3(hdr->CHANNEL[k].PhysDimCode)); sep = "\t"; } } } else if (hdr->TYPE==BrainVision) { if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [210]\n"); char* tmpfile = (char*)calloc(strlen(hdr->FileName)+6,1); strcpy(tmpfile,hdr->FileName); // Flawfinder: ignore char* ext = strrchr(tmpfile,'.'); if (ext != NULL) strcpy(ext+1,"vhdr"); // Flawfinder: ignore else strcat(tmpfile,".vhdr"); // Flawfinder: ignore if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [211]\n"); hdr->HeadLen = 0; FILE *fid = fopen(tmpfile,"wb"); fprintf(fid,"Brain Vision Data Exchange Header File Version 1.0\r\n"); fprintf(fid,"; Data created by BioSig4C++\r\n\r\n"); fprintf(fid,"[Common Infos]\r\n"); fprintf(fid,"DataFile=%s\r\n",hdr->FileName); fprintf(fid,"MarkerFile=%s\r\n",strcpy(strrchr(tmpfile,'.')+1,"vhdr")); fprintf(fid,"DataFormat=BINARY\r\n"); fprintf(fid,"; Data orientation: MULTIPLEXED=ch1,pt1, ch2,pt1 ...\r\n"); fprintf(fid,"DataOrientation=MULTIPLEXED\r\n"); hdr->NRec *= hdr->SPR; hdr->SPR = 1; fprintf(fid,"NumberOfChannels=%i\r\n",hdr->NS); fprintf(fid,"; Sampling interval in microseconds\r\n"); fprintf(fid,"SamplingInterval=%f\r\n\r\n",1e6/hdr->SampleRate); if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [212]\n"); fprintf(fid,"[Binary Infos]\r\nBinaryFormat="); uint16_t gdftyp = 0; typeof(hdr->NS) k; for (k=0; kNS; k++) if (gdftyp < hdr->CHANNEL[k].GDFTYP) gdftyp = hdr->CHANNEL[k].GDFTYP; if (gdftyp<4) { gdftyp = 3; fprintf(fid,"INT_16"); } else { gdftyp = 16; fprintf(fid,"IEEE_FLOAT_32"); } if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [214] gdftyp=%i NS=%i\n",gdftyp,hdr->NS); hdr->AS.bpb = (size_t)hdr->NS * hdr->SPR * GDFTYP_BITS[gdftyp] >> 3; fprintf(fid,"\r\n\r\n[Channel Infos]\r\n"); fprintf(fid,"; Each entry: Ch=,,\r\n"); fprintf(fid,"; ,,,NS; k++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [220] %i\n",k); hdr->CHANNEL[k].SPR = hdr->SPR; hdr->CHANNEL[k].GDFTYP = gdftyp; char Label[MAX_LENGTH_LABEL+1]; strcpy(Label,hdr->CHANNEL[k].Label); // Flawfinder: ignore size_t k1; for (k1=0; Label[k1]; k1++) if (Label[k1]==',') Label[k1]=1; fprintf(fid,"Ch%d=%s,,1,%s\r\n",k+1,Label,PhysDim3(hdr->CHANNEL[k].PhysDimCode)); } fprintf(fid,"\r\n\r\n[Coordinates]\r\n"); // fprintf(fid,"; Each entry: Ch=,,\n\r"); fprintf(fid,"; Each entry: Ch=,,\r\n"); for (k=0; kNS; k++) fprintf(fid,"Ch%i=%f,%f,%f\r\n",k+1,hdr->CHANNEL[k].XYZ[0],hdr->CHANNEL[k].XYZ[1],hdr->CHANNEL[k].XYZ[2]); if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [222]\n"); fprintf(fid,"\r\n\r\n[Comment]\r\n\r\n"); fprintf(fid,"A m p l i f i e r S e t u p\r\n"); fprintf(fid,"============================\r\n"); fprintf(fid,"Number of channels: %i\r\n",hdr->NS); fprintf(fid,"Sampling Rate [Hz]: %f\r\n",hdr->SampleRate); fprintf(fid,"Sampling Interval [µS]: %f\r\n",1e6/hdr->SampleRate); fprintf(fid,"Channels\r\n--------\r\n"); fprintf(fid,"# Name Phys. Chn. Resolution [µV] Low Cutoff [s] High Cutoff [Hz] Notch [Hz]\n\r"); for (k=0; kNS; k++) { fprintf(fid,"\r\n%6i %13s %17i %18f",k+1,hdr->CHANNEL[k].Label,k+1,hdr->CHANNEL[k].Cal); if (hdr->CHANNEL[k].HighPass>0) fprintf(fid," %15f",1/(2*3.141592653589793238462643383279502884197169399375*hdr->CHANNEL[k].HighPass)); else fprintf(fid,"\t-"); if (hdr->CHANNEL[k].LowPass>0) fprintf(fid," %15f",hdr->CHANNEL[k].LowPass); else fprintf(fid,"\t-"); if (hdr->CHANNEL[k].Notch>0) fprintf(fid," %f",hdr->CHANNEL[k].Notch); else fprintf(fid,"\t-"); } fprintf(fid,"\r\n\r\nImpedance [kOhm] :\r\n\r\n"); for (k=0; kNS; k++) if (isnan(hdr->CHANNEL[k].Impedance)) fprintf(fid,"%s:\t\t-\r\n",hdr->CHANNEL[k].Label); else fprintf(fid,"%s:\t\t%f\r\n",hdr->CHANNEL[k].Label,hdr->CHANNEL[k].Impedance); fclose(fid); strcpy(strrchr(tmpfile,'.')+1,"vmrk"); fid = fopen(tmpfile,"wb"); fprintf(fid,"Brain Vision Data Exchange Marker File, Version 1.0\r\n"); fprintf(fid,"; Data created by BioSig4C++\r\n\r\n"); fprintf(fid,"[Common Infos]\r\n"); fprintf(fid,"DataFile=%s\r\n\r\n",hdr->FileName); fprintf(fid,"[Marker Infos]\r\n\r\n"); fprintf(fid,"; Each entry: Mk=,,,\r\n"); fprintf(fid,"; , \r\n"); fprintf(fid,"; Fields are delimited by commas, some fields might be omitted (empty).\r\n"); fprintf(fid,"; Commas in type or description text are coded as \"\\1\".\r\n"); struct tm *T0 = gdf_time2tm_time(hdr->T0); uint32_t us = (hdr->T0*24*3600 - floor(hdr->T0*24*3600))*1e6; fprintf(fid,"Mk1=New Segment,,1,1,0,%04u%02u%02u%02u%02u%02u%06u",T0->tm_year+1900,T0->tm_mon+1,T0->tm_mday,T0->tm_hour,T0->tm_min,T0->tm_sec,us); // 20081002150147124211 if ((hdr->EVENT.DUR==NULL) && (hdr->EVENT.CHN==NULL)) for (k=0; kEVENT.N; k++) { fprintf(fid,"\r\nMk%i=,0x%04x,%u,1,0",k+2,hdr->EVENT.TYP[k],hdr->EVENT.POS[k]+1); // convert to 1-based indexing } else for (k=0; kEVENT.N; k++) { fprintf(fid,"\r\nMk%i=,0x%04x,%u,%u,%u",k+2,hdr->EVENT.TYP[k],hdr->EVENT.POS[k]+1,hdr->EVENT.DUR[k],hdr->EVENT.CHN[k]); // convert EVENT.POS to 1-based indexing } fclose(fid); free(tmpfile); if (VERBOSE_LEVEL>8) fprintf(stdout,"BVA-write: [290] %s %s\n",tmpfile,hdr->FileName); } else if (hdr->TYPE==CFWB) { hdr->HeadLen = 68 + NS*96; hdr->AS.Header = (uint8_t*)malloc(hdr->HeadLen); uint8_t* Header2 = hdr->AS.Header+68; memset(hdr->AS.Header,0,hdr->HeadLen); memcpy(hdr->AS.Header,"CFWB\1\0\0\0",8); lef64a(1/hdr->SampleRate, hdr->AS.Header+8); lef64a(0.0, hdr->AS.Header+44); // pretrigger time leu32a(NS, hdr->AS.Header+52); hdr->NRec *= hdr->SPR; hdr->SPR = 1; leu32a(hdr->NRec, hdr->AS.Header+56); // number of samples lei32a(0, hdr->AS.Header+60); // 1: time channel int32_t gdftyp = 3; // 1:double, 2:float, 3: int16; see CFWB_GDFTYP too. typeof(hdr->NS) k,k2; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) { /* if int16 is not sufficient, use float or double */ if (hdr->CHANNEL[k].GDFTYP>16) gdftyp = min(gdftyp,1); // double else if (hdr->CHANNEL[k].GDFTYP>3) gdftyp = min(gdftyp,2); // float } lei32a(gdftyp, hdr->AS.Header+64); // 1: double, 2: float, 3:short for (k=0,k2=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) { hdr->CHANNEL[k].SPR = 1; hdr->CHANNEL[k].GDFTYP = CFWB_GDFTYP[gdftyp-1]; const char *tmpstr; if (hdr->CHANNEL[k].LeadIdCode) tmpstr = LEAD_ID_TABLE[hdr->CHANNEL[k].LeadIdCode]; else tmpstr = hdr->CHANNEL[k].Label; size_t len = strlen(tmpstr); memcpy(Header2+96*k2, tmpstr, min(len,32)); tmpstr = PhysDim3(hdr->CHANNEL[k].PhysDimCode); if (tmpstr != NULL) { len = strlen(tmpstr)+1; memcpy(Header2+96*k2+32, tmpstr, min(len,32)); } lef64a(hdr->CHANNEL[k].Cal, Header2+96*k2+64); lef64a(hdr->CHANNEL[k].Off, Header2+96*k2+72); lef64a(hdr->CHANNEL[k].PhysMax, Header2+96*k2+80); lef64a(hdr->CHANNEL[k].PhysMin, Header2+96*k2+88); k2++; } } else #endif //ONLYGDF if ((hdr->TYPE==GDF) || (hdr->TYPE==GDF1)) { /* use of GDF1 is deprecated, instead hdr->TYPE=GDF and hdr->VERSION=1.25 should be used. a test and a warning is about this is implemented within struct2gdfbin */ struct2gdfbin(hdr); size_t bpb8 = 0; typeof(hdr->NS) k; for (k=0, hdr->AS.bpb=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->bi8 = bpb8; hc->bi = bpb8>>3; if (hc->OnOff) bpb8 += (GDFTYP_BITS[hc->GDFTYP] * hc->SPR); } hdr->AS.bpb8 = bpb8; hdr->AS.bpb = bpb8>>3; if (bpb8 & 0x07) { // each block must use whole number of bytes hdr->AS.bpb++; hdr->AS.bpb8 = hdr->AS.bpb<<3; } if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw h3\n"); } #ifndef ONLYGDF else if ((hdr->TYPE==EDF) || (hdr->TYPE==BDF)) { hdr->HeadLen = (NS+1)*256; hdr->AS.Header = (uint8_t*)malloc(hdr->HeadLen); char* Header2 = (char*)hdr->AS.Header+256; memset(Header1,' ',hdr->HeadLen); if (hdr->TYPE==BDF) { Header1[0] = 255; memcpy(Header1+1,"BIOSEMI",7); } else { Header1[0] = '0'; } char tmp[81]; if (hdr->Patient.Birthday>1) strfgdftime(tmp,81,"%02d-%b-%04Y",hdr->Patient.Birthday); else strcpy(tmp,"X"); if (strlen(hdr->Patient.Id) > 0) { size_t k; for (k=0; hdr->Patient.Id[k]; k++) if (isspace(hdr->Patient.Id[k])) hdr->Patient.Id[k] = '_'; } char cmd[256]; if (!hdr->FLAG.ANONYMOUS) snprintf(cmd,MAX_LENGTH_PID+1,"%s %c %s %s",hdr->Patient.Id,GENDER[hdr->Patient.Sex],tmp,hdr->Patient.Name); else snprintf(cmd,MAX_LENGTH_PID+1,"%s %c %s X",hdr->Patient.Id,GENDER[hdr->Patient.Sex],tmp); memcpy(Header1+8, cmd, strlen(cmd)); if (hdr->T0 > 1) strfgdftime(tmp,81,"%d-%b-%Y", hdr->T0); else strcpy(tmp,"X"); char *tmpstr = hdr->ID.Technician; if (!tmpstr || !strlen(tmp)) tmpstr = "X"; size_t len = snprintf(cmd,sizeof(cmd),"Startdate %s X %s ", tmp, tmpstr); memcpy(Header1+88, cmd, len); memcpy(Header1+88+len, &hdr->ID.Equipment, 8); strfgdftime(tmp,81,"%d.%m.%y%H.%M.%S",hdr->T0); memcpy(Header1+168, tmp, 16); len = sprintf(tmp,"%i",hdr->HeadLen); if (len>8) fprintf(stderr,"Warning: HeaderLength is (%s) too long (%i>8).\n",tmp,(int)len); memcpy(Header1+184, tmp, len); memcpy(Header1+192, "EDF+C ", 5); len = sprintf(tmp,"%u",(int)hdr->NRec); if (len>8) fprintf(stderr,"Warning: NRec is (%s) too long (%i>8).\n",tmp,(int)len); memcpy(Header1+236, tmp, len); len = sprintf(tmp,"%f",hdr->SPR/hdr->SampleRate); if (len>8) fprintf(stderr,"Warning: Duration is (%s) too long (%i>8).\n",tmp,(int)len); memcpy(Header1+244, tmp, len); len = sprintf(tmp,"%i",NS); if (len>4) fprintf(stderr,"Warning: NS is (%s) too long (%i>4).\n",tmp,(int)len); memcpy(Header1+252, tmp, len); typeof(hdr->NS) k,k2; for (k=0,k2=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) { const char *tmpstr; if (hdr->CHANNEL[k].LeadIdCode) tmpstr = LEAD_ID_TABLE[hdr->CHANNEL[k].LeadIdCode]; else tmpstr = hdr->CHANNEL[k].Label; len = strlen(tmpstr); if (len>16) //fprintf(stderr,"Warning: Label (%s) of channel %i is to long.\n",hdr->CHANNEL[k].Label,k); fprintf(stderr,"Warning: Label of channel %i,%i is too long (%i>16).\n",k,k2, (int)len); memcpy(Header2+16*k2,tmpstr,min(len,16)); len = strlen(hdr->CHANNEL[k].Transducer); if (len>80) fprintf(stderr,"Warning: Transducer of channel %i,%i is too long (%i>80).\n",k,k2, (int)len); memcpy(Header2+80*k2 + 16*NS,hdr->CHANNEL[k].Transducer,min(len,80)); tmpstr = PhysDim3(hdr->CHANNEL[k].PhysDimCode); if (tmpstr) { len = strlen(tmpstr); if (len>8) fprintf(stderr,"Warning: Physical Dimension (%s) of channel %i is too long (%i>8).\n",tmpstr,k,(int)len); memcpy(Header2 + 8*k2 + 96*NS, tmpstr, min(len,8)); } if (ftoa8(tmp,hdr->CHANNEL[k].PhysMin)) fprintf(stderr,"Warning: PhysMin (%f)(%s) of channel %i does not fit into 8 bytes of EDF header.\n",hdr->CHANNEL[k].PhysMin,tmp,k); memcpy(Header2 + 8*k2 + 104*NS, tmp, strlen(tmp)); if (ftoa8(tmp,hdr->CHANNEL[k].PhysMax)) fprintf(stderr,"Warning: PhysMax (%f)(%s) of channel %i does not fit into 8 bytes of EDF header.\n",hdr->CHANNEL[k].PhysMax,tmp,k); memcpy(Header2 + 8*k2 + 112*NS, tmp, strlen(tmp)); if (ftoa8(tmp,hdr->CHANNEL[k].DigMin)) fprintf(stderr,"Warning: DigMin (%f)(%s) of channel %i does not fit into 8 bytes of EDF header.\n",hdr->CHANNEL[k].DigMin,tmp,k); memcpy(Header2 + 8*k2 + 120*NS, tmp, strlen(tmp)); if (ftoa8(tmp,hdr->CHANNEL[k].DigMax)) fprintf(stderr,"Warning: DigMax (%f)(%s) of channel %i does not fit into 8 bytes of EDF header.\n",hdr->CHANNEL[k].DigMax,tmp,k); memcpy(Header2 + 8*k2 + 128*NS, tmp, strlen(tmp)); if (hdr->CHANNEL[k].Notch>0) len = sprintf(tmp,"HP:%fHz LP:%fHz Notch:%fHz",hdr->CHANNEL[k].HighPass,hdr->CHANNEL[k].LowPass,hdr->CHANNEL[k].Notch); else len = sprintf(tmp,"HP:%fHz LP:%fHz",hdr->CHANNEL[k].HighPass,hdr->CHANNEL[k].LowPass); memcpy(Header2+ 80*k2 + 136*NS,tmp,min(80,len)); len = sprintf(tmp,"%i",hdr->CHANNEL[k].SPR); if (len>8) fprintf(stderr,"Warning: SPR (%s) of channel %i is to long (%i)>8.\n",tmp,k,(int)len); memcpy(Header2+ 8*k2 + 216*NS,tmp,min(8,len)); hdr->CHANNEL[k].GDFTYP = ( (hdr->TYPE != BDF) ? 3 : 255+24); k2++; } } else if (hdr->TYPE==HL7aECG) { sopen_HL7aECG_write(hdr); // hdr->FLAG.SWAP = 0; hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); // no byte-swapping } else if (hdr->TYPE==MFER) { uint8_t tag; size_t len, curPos=0; hdr->HeadLen = 32+128+3*6+3 +80000; hdr->AS.Header = (uint8_t*)malloc(hdr->HeadLen); memset(Header1, ' ', hdr->HeadLen); hdr->FILE.LittleEndian = 0; fprintf(stderr,"Warning SOPEN(MFER): write support for MFER format under construction\n"); /* FIXME & TODO: known issues: Label Sampling Rate HeadLen Encoding of data block */ // tag 64: preamble // Header1[curPos] = 64; // len =32; curPos = 34; strncpy(Header1,"@ MFER ",curPos); // Header1[curPos+1] = len; // curPos = len+2; if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 711]:\n"); // tag 23: Manufacturer tag = 23; Header1[curPos] = tag; { char *str = Header1+curPos+2; strncpy(str, hdr->ID.Manufacturer.Name, MAX_LENGTH_MANUF); size_t l2,l1 = strlen(str); l2 = (hdr->ID.Manufacturer.Model==NULL) ? MAX_LENGTH_MANUF*2 : strlen(hdr->ID.Manufacturer.Model); str[l1++]='^'; if (l1+l2 <= MAX_LENGTH_MANUF) { memcpy(str+l1, hdr->ID.Manufacturer.Model, l2); l1 += l2; } l2 = (hdr->ID.Manufacturer.Version==NULL) ? MAX_LENGTH_MANUF*2 : strlen(hdr->ID.Manufacturer.Version); str[l1++]='^'; if (l1+l2 <= MAX_LENGTH_MANUF) { memcpy(str+l1, hdr->ID.Manufacturer.Version, l2); l1 += l2; } l2 = (hdr->ID.Manufacturer.SerialNumber==NULL) ? MAX_LENGTH_MANUF*2 : strlen(hdr->ID.Manufacturer.SerialNumber); str[l1++]='^'; if (l1+l2 <= MAX_LENGTH_MANUF) { memcpy(str+l1, hdr->ID.Manufacturer.SerialNumber, l2); l1 += l2; } len = min(l1, MAX_LENGTH_MANUF); str[len]=0; } Header1[curPos] = tag; if (len<128) { hdr->AS.Header[curPos+1] = len; curPos += len+2; } else fprintf(stderr,"Warning MFER(W) Tag23 (manufacturer) too long len=%i>128\n",(int)len); if (VERBOSE_LEVEL>8) fprintf(stdout,"Write MFER: tag=%i,len%i,curPos=%i\n",tag,(int)len,(int)curPos); // tag 1: Endianity // use default BigEndianity if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-4]:\n"); // tag 4: SPR tag = 4; len = sizeof(uint32_t); Header1[curPos++] = tag; Header1[curPos++] = len; beu32a(hdr->SPR, hdr->AS.Header+curPos); curPos += len; if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-5]:\n"); // tag 5: NS tag = 5; len = sizeof(uint16_t); Header1[curPos++] = tag; Header1[curPos++] = len; beu16a(hdr->NS, hdr->AS.Header+curPos); curPos += len; if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-6]:\n"); // tag 6: NRec tag = 6; len = sizeof(uint32_t); Header1[curPos++] = tag; Header1[curPos++] = len; beu32a(hdr->NRec, hdr->AS.Header+curPos); curPos += len; if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-8]:\n"); // tag 8: Waveform: unidentified tag = 8; len = sizeof(uint8_t); Header1[curPos++] = tag; Header1[curPos++] = len; *(Header1+curPos) = 0; // unidentified curPos += len; if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-129]:\n"); // tag 129: Patient Name if (!hdr->FLAG.ANONYMOUS) { tag = 129; len = strlen(hdr->Patient.Name); Header1[curPos++] = tag; Header1[curPos++] = len; strcpy(Header1+curPos,hdr->Patient.Name); curPos += len; } // tag 130: Patient Id tag = 130; len = strlen(hdr->Patient.Id); Header1[curPos++] = tag; Header1[curPos++] = len; strcpy(Header1+curPos,hdr->Patient.Id); curPos += len; // tag 131: Patient Age if (hdr->Patient.Birthday>0) { tag = 131; len = 7; struct tm *t = gdf_time2tm_time(hdr->Patient.Birthday); hdr->AS.Header[curPos++] = tag; hdr->AS.Header[curPos++] = len; hdr->AS.Header[curPos] = (uint8_t)((hdr->T0 - hdr->Patient.Birthday)/365.25); double tmpf64 = (hdr->T0 - hdr->Patient.Birthday); tmpf64 -= 365.25*floor(tmpf64/365.25); beu16a((uint16_t)tmpf64, Header1+curPos+1); beu16a(t->tm_year+1900, Header1+curPos+3); hdr->AS.Header[curPos+5] = (t->tm_mon+1); hdr->AS.Header[curPos+6] = (t->tm_mday); curPos += len; } if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-132]:\n"); // tag 132: Patient Sex tag = 132; Header1[curPos] = tag; Header1[curPos+1] = 1; Header1[curPos+2] = hdr->Patient.Sex; curPos += 3; // tag 133: Recording time tag = 133; len = 11; { struct tm *t = gdf_time2tm_time(hdr->T0); hdr->AS.Header[curPos++] = tag; hdr->AS.Header[curPos++] = len; beu16a(t->tm_year+1900, hdr->AS.Header+curPos); hdr->AS.Header[curPos+2] = (uint8_t)(t->tm_mon+1); hdr->AS.Header[curPos+3] = (uint8_t)(t->tm_mday); hdr->AS.Header[curPos+4] = (uint8_t)(t->tm_hour); hdr->AS.Header[curPos+5] = (uint8_t)(t->tm_min); hdr->AS.Header[curPos+6] = (uint8_t)(t->tm_sec); memset(hdr->AS.Header+curPos+7, 0, 4); curPos += len; } // tag 9: LeadId // tag 10: gdftyp // tag 11: SampleRate // tag 12: Cal // tag 13: Off hdr->HeadLen = curPos; // tag 63: channel-specific settings if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-63]:\n"); tag = 63; size_t ch; for (ch=0; chNS; ch++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"[MFER 720-63 #%i/%i %i]:\n",(int)ch,hdr->NS,hdr->CHANNEL[ch].LeadIdCode); // FIXME: this is broken len = 0; Header1[curPos++] = tag; if (ch<128) Header1[curPos++] = ch; else { Header1[curPos++] = (ch >> 7) | 0x80; Header1[curPos++] = (ch && 0x7f); } // tag1 9: LeadId size_t ix = curPos; size_t len1 = 0; Header1[ix++] = 9; if (hdr->CHANNEL[ch].LeadIdCode>0) { hdr->AS.Header[ix++] = 2; leu16a(hdr->CHANNEL[ch].LeadIdCode, hdr->AS.Header+ix); len1 = 2; } else { len1 = strlen(hdr->CHANNEL[ch].Label); Header1[ix++] = len1; strcpy(Header1+ix, hdr->CHANNEL[ch].Label); } // tag1 10: gdftyp // tag1 11: SampleRate // tag1 12: Cal // tag1 13: Off len += len1+ix-curPos; hdr->AS.Header[curPos] = len; curPos += len+curPos; } // tag 30: data } else if (hdr->TYPE==SCP_ECG) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i) %s -> SOPEN_SCP_WRITE v%f\n",__FILE__,__LINE__,__func__,hdr->VERSION); sopen_SCP_write(hdr); if (hdr->AS.B4C_ERRNUM) return(hdr); } #ifdef WITH_TMSiLOG else if (hdr->TYPE==TMSiLOG) { // ###FIXME: writing of TMSi-LOG file is experimental and not completed FILE *fid = fopen(hdr->FileName,"wb"); fprintf(fid,"FileId=TMSi PortiLab sample log file\n\rVersion=0001\n\r",NULL); struct tm *t = gdf_time2tm_time(hdr->T0); fprintf(fid,"DateTime=%04d/02d/02d-02d:02d:02d\n\r",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); fprintf(fid,"Format=Float32\n\rLength=%f\n\rSignals=%04i\n\r",hdr->NRec*hdr->SPR/hdr->SampleRate,hdr->NS); const char* fn = strrchr(hdr->FileName,FILESEP); if (!fn) fn=hdr->FileName; size_t len = strcspn(fn,"."); char* fn2 = (char*)malloc(len+1); strncpy(fn2,fn,len); fn2[len]=0; for (k=0; kNS; k++) { fprintf(fid,"Signal%04d.Name=%s\n\r",k+1,hdr->CHANNEL[k].Label); fprintf(fid,"Signal%04d.UnitName=%s\n\r",k+1,PhysDim3(hdr->CHANNEL[k].PhysDimCode)); fprintf(fid,"Signal%04d.Resolution=%f\n\r",k+1,hdr->CHANNEL[k].Cal); fprintf(fid,"Signal%04d.StoreRate=%f\n\r",k+1,hdr->SampleRate); fprintf(fid,"Signal%04d.File=%s.asc\n\r",k+1,fn2); fprintf(fid,"Signal%04d.Index=%04d\n\r",k+1,k+1); } fprintf(fid,"\n\r\n\r"); fclose(fid); // ###FIXME: this belongs into SWRITE // write data file fn2 = (char*) realloc(fn2, strlen(hdr->FileName)+5); strcpy(fn2,hdr->FileName); // Flawfinder: ignore strcpy(strrchr(fn2,'.'),".asc"); // Flawfinder: ignore // hdr->FileName = fn2; fid = fopen(fn2,"wb"); fprintf(fid,"%d\tHz\n\r\n\rN",hdr->SampleRate); for (k=0; kNS; k++) { fprintf(fid,"\t%s(%s)", hdr->CHANNEL[k].Label, PhysDim3(hdr->CHANNEL[k].PhysDimCode)); } for (k1=0; k1SPR*hdr->NRec; k1++) { fprintf(fid,"\n%i",k1); for (k=0; kNS; k++) { // TODO: Row/Column ordering fprintf(fid,"\t%f",hdr->data.block[]); } } fclose(fid); free(fn2); } #endif // WITH_TMSiLOG #endif //ONLYGDF else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Writing of format not supported"); return(NULL); } if ((hdr->TYPE != ASCII) && (hdr->TYPE != ATF) && (hdr->TYPE != BIN) && (hdr->TYPE != HL7aECG) && (hdr->TYPE != TMSiLOG)){ hdr = ifopen(hdr,"wb"); if (!hdr->FILE.COMPRESSION && (hdr->FILE.FID == NULL) ) { biosigERROR(hdr, B4C_CANNOT_WRITE_FILE, "Unable to open file for writing"); return(NULL); } #ifdef ZLIB_H else if (hdr->FILE.COMPRESSION && (hdr->FILE.gzFID == NULL) ){ biosigERROR(hdr, B4C_CANNOT_WRITE_FILE, "Unable to open file for writing"); return(NULL); } #endif if(hdr->TYPE != SCP_ECG){ ifwrite(Header1, sizeof(char), hdr->HeadLen, hdr); } hdr->FILE.OPEN = 2; hdr->FILE.POS = 0; } size_t bpb8 = 0; #ifndef ONLYGDF if (hdr->TYPE==AINF) { hdr->AS.bpb = 4; bpb8 = 32; } else #endif //ONLYGDF hdr->AS.bpb = 0; typeof(hdr->NS) k; for (k=0, hdr->SPR = 1; k < hdr->NS; k++) { hdr->CHANNEL[k].bi = bpb8>>3; hdr->CHANNEL[k].bi8 = bpb8; if (hdr->CHANNEL[k].OnOff) { bpb8 += (GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP] * hdr->CHANNEL[k].SPR); if (hdr->CHANNEL[k].SPR > 0) // ignore sparse channels hdr->SPR = lcm(hdr->SPR, hdr->CHANNEL[k].SPR); } } hdr->AS.bpb8 = bpb8; hdr->AS.bpb = bpb8>>3; if ((hdr->TYPE==GDF) && (bpb8 & 0x07)) { // each block must use whole number of bytes hdr->AS.bpb++; hdr->AS.bpb8 = hdr->AS.bpb<<3; } } // end of branch "write" #ifndef ANDROID if (VERBOSE_LEVEL > 7) { //There is a way to send messages in Android to log, but I dont know it yet. Stoyan //There is problem with some files printing deubg info. //And debug in NDK is bad idea in Android if (hdr->FILE.POS != 0) fprintf(stdout,"Debugging Information: (Format=%d) %s FILE.POS=%d is not zero.\n",hdr->TYPE,hdr->FileName,(int)hdr->FILE.POS); typeof(hdr->NS) k; for (k=0; kNS; k++) if (GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP] % 8) { if (hdr->TYPE==alpha) ; // 12bit alpha is well tested else if ((__BYTE_ORDER == __LITTLE_ENDIAN) && !hdr->FILE.LittleEndian) fprintf(stdout,"GDFTYP=%i [12bit LE/BE] not well tested\n",hdr->CHANNEL[k].GDFTYP); else if ((__BYTE_ORDER == __LITTLE_ENDIAN) && hdr->FILE.LittleEndian) fprintf(stdout,"GDFTYP=%i [12bit LE/LE] not well tested\n",hdr->CHANNEL[k].GDFTYP); else if ((__BYTE_ORDER == __BIG_ENDIAN) && hdr->FILE.LittleEndian) fprintf(stdout,"GDFTYP=%i [12bit BE/LE] not well tested\n",hdr->CHANNEL[k].GDFTYP); else if ((__BYTE_ORDER == __BIG_ENDIAN) && !hdr->FILE.LittleEndian) fprintf(stdout,"GDFTYP=%i [12bit BE/BE] not well tested\n",hdr->CHANNEL[k].GDFTYP); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"sopen{return} %i %s\n", hdr->AS.B4C_ERRNUM,GetFileTypeString(hdr->TYPE) ); #endif return(hdr); } // end of SOPEN /**************************************************************************** bpb8_collapsed_rawdata computes the bytes per block when rawdata is collapsed ****************************************************************************/ size_t bpb8_collapsed_rawdata(HDRTYPE *hdr) { size_t bpb8=0; CHANNEL_TYPE *CHptr; typeof(hdr->NS) k; for (k=0; kNS; k++) { CHptr = hdr->CHANNEL+k; if (CHptr->OnOff) bpb8 += (size_t)CHptr->SPR*GDFTYP_BITS[CHptr->GDFTYP]; } return(bpb8); } /* *************************************************************************** collapse raw data this function is used to remove obsolete channels (e.g. status and annotation channels because the information as been already converted into the event table) that are not needed in GDF. if buf==NULL, hdr->AS.rawdata will be collapsed ****************************************************************************/ void collapse_rawdata(HDRTYPE *hdr, void *buf, size_t count) { CHANNEL_TYPE *CHptr; size_t bpb, k4; size_t bi1=0, bi2=0, SZ; int num3Segments=0,k1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): started\n",__func__,__LINE__); bpb = bpb8_collapsed_rawdata(hdr); if (bpb == hdr->AS.bpb<<3) return; // no collapsing needed if ((bpb & 7) || (hdr->AS.bpb8 & 7)) { biosigERROR(hdr, B4C_RAWDATA_COLLAPSING_FAILED, "collapse_rawdata: does not support bitfields"); } bpb >>= 3; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): bpb=%i/%i\n",__func__,__LINE__,(int)bpb,hdr->AS.bpb); if (buf == NULL) { buf = hdr->AS.rawdata; count = hdr->AS.length; } // prepare idxlist for copying segments within a single block (i.e. record) size_t *idxList= alloca(3*hdr->NS*sizeof(size_t)); CHptr = hdr->CHANNEL; while (1) { SZ = 0; while (!CHptr->OnOff && (CHptr < hdr->CHANNEL+hdr->NS) ) { SZ += (size_t)CHptr->SPR * GDFTYP_BITS[CHptr->GDFTYP]; if (SZ & 7) biosigERROR(hdr, B4C_RAWDATA_COLLAPSING_FAILED, "collapse_rawdata: does not support bitfields"); CHptr++; } bi1 += SZ; SZ = 0; while (CHptr->OnOff && (CHptr < hdr->CHANNEL+hdr->NS)) { SZ += (size_t)CHptr->SPR * GDFTYP_BITS[CHptr->GDFTYP]; if (SZ & 7) biosigERROR(hdr, B4C_RAWDATA_COLLAPSING_FAILED, "collapse_rawdata: does not support bitfields"); CHptr++; } if (SZ > 0) { SZ >>= 3; idxList[num3Segments] = bi2; // offset of destination idxList[num3Segments+1] = bi1; // offset of source idxList[num3Segments+2] = SZ; // size num3Segments += 3; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): #%i src:%i dest:%i size:%i\n",__func__,__LINE__,num3Segments/3,(int)bi1,(int)bi2,(int)SZ); } if (CHptr >= hdr->CHANNEL+hdr->NS) break; bi1 += SZ; bi2 += SZ; } for (k4 = 0; k4 < count; k4++) { void *src = buf + k4*hdr->AS.bpb; void *dest = buf + k4*bpb; for (k1=0; k1 < num3Segments; k1+=3) if ((dest + idxList[k1]) != (src + idxList[k1+1])) memcpy(dest + idxList[k1], src + idxList[k1+1], idxList[k1+2]); } if (buf == hdr->AS.rawdata) { hdr->AS.flag_collapsed_rawdata = 1; // rawdata is now "collapsed" } } /****************************************************************************/ /** SREAD_RAW : segment-based **/ /****************************************************************************/ size_t sread_raw(size_t start, size_t length, HDRTYPE* hdr, char flag, void *buf, size_t bufsize) { /* * Reads LENGTH blocks with HDR.AS.bpb BYTES each * (and HDR.SPR samples). * Rawdata is available in hdr->AS.rawdata. * * start <0: read from current position * >=0: start reading from position start * length : try to read length blocks * * flag!=0 : unused channels (those channels k where HDR.CHANNEL[k].OnOff==0) * are collapsed * * for reading whole data section, bufsize must be length*hdr->AS.bpb (also if flag is set) */ if (buf != NULL) { if (length > (bufsize / hdr->AS.bpb)) { fprintf(stderr, "Warning %s (line %i): bufsize is not large enough for converting %i blocks.\n", \ __func__, __LINE__, (int)length); length = bufsize / hdr->AS.bpb; } if ( (hdr->AS.first <= start) && ((start+length) <= (hdr->AS.first+hdr->AS.length)) ) { /**** copy from rawData if available: - better performance - required for some data formats (e.g. CFS, when hdr->AS.rawdata is populated in SOPEN) ****/ if (!hdr->AS.flag_collapsed_rawdata) { memcpy(buf, hdr->AS.rawdata + (start - hdr->AS.first) * hdr->AS.bpb, bufsize); if (flag) collapse_rawdata(hdr, buf, length); return (length); } else if (flag) { size_t bpb = bpb8_collapsed_rawdata(hdr)>>3; memcpy(buf, hdr->AS.rawdata + (start - hdr->AS.first) * bpb, bufsize); return (bufsize / bpb); } // else if (hdr->AS.flag_collapsed_rawdata && !flag) is handled below } } if (hdr->AS.flag_collapsed_rawdata && !flag) hdr->AS.length = 0; // force reloading of data size_t count, nelem; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): start=%d length=%d nrec=%d POS=%d bpb=%i\n",__func__,__LINE__, \ (int)start,(int)length,(int)hdr->NRec, (int)hdr->FILE.POS, hdr->AS.bpb); if ((nrec_t)start > hdr->NRec) return(0); else if ((ssize_t)start < 0) start = hdr->FILE.POS; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %d %d %d %d\n",__func__,__LINE__, (int)start, (int)length, (int)hdr->NRec, (int)hdr->FILE.POS); // limit reading to end of data block if (hdr->NRec<0) nelem = length; else if (start >= (size_t)hdr->NRec) nelem = 0; else nelem = min(length, hdr->NRec - start); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i %i %i %p\n",__func__,__LINE__, \ (int)start, (int)length, (int)nelem, (int)hdr->NRec, (int)hdr->FILE.POS, hdr->AS.rawdata); if ( (buf == NULL) && (start >= hdr->AS.first) && ( (start + nelem) <= (hdr->AS.first + hdr->AS.length) ) ) { // Caching, no file-IO, data is already loaded into hdr->AS.rawdata hdr->FILE.POS = start; count = nelem; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): \n",__func__,__LINE__); } #ifndef WITHOUT_NETWORK else if (hdr->FILE.Des > 0) { // network connection int s = bscs_requ_dat(hdr->FILE.Des, start, length,hdr); count = hdr->AS.length; if (VERBOSE_LEVEL>7) fprintf(stdout,"sread-raw from network: 222 count=%i\n",(int)count); } #endif else { assert(hdr->TYPE != CFS); // CFS data has been already cached in SOPEN assert(hdr->TYPE != SMR); // CFS data has been already cached in SOPEN if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): \n",__func__,__LINE__); // read required data block(s) if (ifseek(hdr, start*hdr->AS.bpb + hdr->HeadLen, SEEK_SET)<0) { if (VERBOSE_LEVEL>7) fprintf(stdout,"--%i %i %i %i \n",(int)(start*hdr->AS.bpb + hdr->HeadLen), (int)start, (int)hdr->AS.bpb, (int)hdr->HeadLen); return(0); } else hdr->FILE.POS = start; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): bpb=%i\n",__func__,__LINE__,(int)hdr->AS.bpb); // allocate AS.rawdata void* tmpptr = buf; if (buf == NULL) { tmpptr = realloc(hdr->AS.rawdata, hdr->AS.bpb*nelem); if ((tmpptr!=NULL) || (hdr->AS.bpb*nelem==0)) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i %i \n",__func__,__LINE__,(int)hdr->AS.bpb,(int)nelem); hdr->AS.rawdata = (uint8_t*) tmpptr; } else { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "memory allocation failed"); return(0); } } if (VERBOSE_LEVEL>8) fprintf(stdout,"#sread(%i %li)\n",(int)(hdr->HeadLen + hdr->FILE.POS*hdr->AS.bpb), iftell(hdr)); // read data count = ifread(tmpptr, hdr->AS.bpb, nelem, hdr); if (buf != NULL) { hdr->AS.flag_collapsed_rawdata = 0; // is rawdata not collapsed hdr->AS.first = start; hdr->AS.length= count; } if (count < nelem) { fprintf(stderr,"warning: less than the number of requested blocks read (%i/%i) from file %s - something went wrong\n",(int)count,(int)nelem,hdr->FileName); if (VERBOSE_LEVEL>7) fprintf(stderr,"warning: only %i instead of %i blocks read - something went wrong (bpb=%i,pos=%li)\n",(int)count,(int)nelem,hdr->AS.bpb,iftell(hdr)); } } // (uncollapsed) data is now in buffer hdr->AS.rawdata if (flag) { collapse_rawdata(hdr, NULL, 0); } return(count); } /**************************************************************************** caching: load data of whole file into buffer this will speed up data access, especially in interactive mode ****************************************************************************/ int cachingWholeFile(HDRTYPE* hdr) { sread_raw(0,hdr->NRec,hdr, 0, NULL, 0); return((hdr->AS.first != 0) || (hdr->AS.length != (size_t)hdr->NRec)); } /****************************************************************************/ /** SREAD : segment-based **/ /****************************************************************************/ size_t sread(biosig_data_type* data, size_t start, size_t length, HDRTYPE* hdr) { /* * Reads LENGTH blocks with HDR.AS.bpb BYTES each * (and HDR.SPR samples). * Rawdata is available in hdr->AS.rawdata. * Output data is available in hdr->data.block. * If the request can be completed, hdr->data.block contains * LENGTH*HDR.SPR samples and HDR.NS channels. * The size of the output data is availabe in hdr->data.size. * * hdr->FLAG.LittleEndian controls swapping * * hdr->CHANNEL[k].OnOff controls whether channel k is loaded or not * * data is a pointer to a memory array to write the data. * if data is NULL, memory is allocated and the pointer is returned * in hdr->data.block. * * channel selection is controlled by hdr->CHANNEL[k].OnOff * * start <0: read from current position * >=0: start reading from position start * length : try to read length blocks * * * ToDo: * - sample-based loading * */ size_t count,k1,k2,k4,k5=0,NS;//bi,bi8; size_t toffset; // time offset for rawdata biosig_data_type *data1=NULL; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s( %p, %i, %i, %s ) MODE=%i bpb=%i\n",__func__,data, (int)start, (int)length, hdr->FileName, hdr->FILE.OPEN, (int)hdr->AS.bpb); if ((ssize_t)start < 0) start=hdr->FILE.POS; if (start >= (size_t)hdr->NRec) return(0); switch (hdr->TYPE) { case AXG: case ABF2: case ATF: case SMR: // data is already cached count = hdr->NRec; break; default: count = sread_raw(start, length, hdr, 0, NULL, 0); } if (hdr->AS.B4C_ERRNUM) return(0); toffset = start - hdr->AS.first; // set position of file handle size_t POS = hdr->FILE.POS; hdr->FILE.POS += count; // count number of selected channels for (k1=0,NS=0; k1NS; ++k1) if (hdr->CHANNEL[k1].OnOff) ++NS; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): count=%i pos=[%i,%i,%i,%i], size of data = %ix%ix%ix%i = %i\n", __func__, __LINE__, \ (int)count,(int)start,(int)length,(int)POS,(int)hdr->FILE.POS,(int)hdr->SPR, (int)count, \ (int)NS, (int)sizeof(biosig_data_type), (int)(hdr->SPR * count * NS * sizeof(biosig_data_type))); #ifndef ANDROID //Stoyan: Arm has some problem with log2 - or I dont know how to fix it - it exists but do not work. if (log2(hdr->SPR) + log2(count) + log2(NS) + log2(sizeof(biosig_data_type)) + 1 >= sizeof(size_t)*8) { // used to check the 2GByte limit on 32bit systems biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Size of required data buffer too large (exceeds size_t addressable space)"); return(0); } #endif // transfer RAW into BIOSIG data format if ((data==NULL) || hdr->Calib) { // local data memory required size_t sz = hdr->SPR * count * NS * sizeof(biosig_data_type); void *tmpptr = realloc(hdr->data.block, sz); if (tmpptr!=NULL || !sz) data1 = (biosig_data_type*) tmpptr; else { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "memory allocation failed - not enough memory"); return(0); } hdr->data.block = data1; } else data1 = data; char ALPHA12BIT = (hdr->TYPE==alpha) && (hdr->NS>0) && (hdr->CHANNEL[0].GDFTYP==(255+12)); char MIT12BIT = (hdr->TYPE==MIT ) && (hdr->NS>0) && (hdr->CHANNEL[0].GDFTYP==(255+12)); #if (__BYTE_ORDER == __BIG_ENDIAN) char SWAP = hdr->FILE.LittleEndian; #elif (__BYTE_ORDER == __LITTLE_ENDIAN) char SWAP = !hdr->FILE.LittleEndian; #endif int stride = 1; #ifndef ONLYGDF if (hdr->TYPE==Axona) stride = 64; else if (hdr->TYPE==TMS32) stride = hdr->NS; #endif //ONLYGDF if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): alpha12bit=%i SWAP=%i spr=%i %p\n",__func__,__LINE__, ALPHA12BIT, SWAP, hdr->SPR, hdr->AS.rawdata); for (k1=0,k2=0; k1NS; k1++) { CHANNEL_TYPE *CHptr = hdr->CHANNEL+k1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i#%i: alpha12bit=%i SWAP=%i spr=%i %p | bi=%i bpb=%i \n",__func__,__LINE__, (int)k1, (int)k2, ALPHA12BIT, SWAP, hdr->SPR, hdr->AS.rawdata,(int)CHptr->bi,(int)hdr->AS.bpb ); if (CHptr->OnOff) { /* read selected channels only */ if (CHptr->SPR > 0) { size_t DIV = hdr->SPR/CHptr->SPR; uint16_t GDFTYP = CHptr->GDFTYP; size_t SZ = GDFTYP_BITS[GDFTYP]; int32_t int32_value = 0; uint8_t bitoff = 0; union {int16_t i16; uint16_t u16; uint32_t i32; float f32; uint64_t i64; double f64;} u; // TODO: MIT data types for (k4 = 0; k4 < count; k4++) { uint8_t *ptr1; #ifndef ONLYGDF if (hdr->TYPE == FEF) { ptr1 = CHptr->bufptr; } else #endif //ONLYGDF ptr1 = hdr->AS.rawdata + (k4+toffset)*hdr->AS.bpb + CHptr->bi; for (k5 = 0; k5 < CHptr->SPR; k5++) { biosig_data_type sample_value; uint8_t *ptr = ptr1 + (stride * k5 * SZ >> 3); if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): k_i = [%d %d %d %d ] 0x%08x[%g] @%p => ",__func__,__LINE__,(int)k1,(int)k2,(int)k4,(int)k5,(int)leu32p(ptr),lef64p(ptr),ptr); switch (GDFTYP) { case 1: sample_value = (biosig_data_type)(*(int8_t*)ptr); break; case 2: sample_value = (biosig_data_type)(*(uint8_t*)ptr); break; case 3: if (SWAP) { sample_value = (biosig_data_type)(int16_t)bswap_16(*(int16_t*)ptr); } else { sample_value = (biosig_data_type)(*(int16_t*)ptr); } break; case 4: if (SWAP) { sample_value = (biosig_data_type)(uint16_t)bswap_16(*(uint16_t*)ptr); } else { sample_value = (biosig_data_type)(*(uint16_t*)ptr); } break; case 5: if (SWAP) { sample_value = (biosig_data_type)(int32_t)bswap_32(*(int32_t*)ptr); } else { sample_value = (biosig_data_type)(*(int32_t*)ptr); } break; case 6: if (SWAP) { sample_value = (biosig_data_type)(uint32_t)bswap_32(*(uint32_t*)ptr); } else { sample_value = (biosig_data_type)(*(uint32_t*)ptr); } break; case 7: if (SWAP) { sample_value = (biosig_data_type)(int64_t)bswap_64(*(int64_t*)ptr); } else { sample_value = (biosig_data_type)(*(int64_t*)ptr); } break; case 8: if (SWAP) { sample_value = (biosig_data_type)(uint64_t)bswap_64(*(uint64_t*)ptr); } else { sample_value = (biosig_data_type)(*(uint64_t*)ptr); } break; case 16: if (SWAP) { u.i32 = bswap_32(*(uint32_t*)(ptr)); sample_value = (biosig_data_type)(u.f32); } else { sample_value = (biosig_data_type)(*(float*)(ptr)); } break; case 17: if (SWAP) { u.i64 = bswap_64(*(uint64_t*)(ptr)); sample_value = (biosig_data_type)(u.f64); } else { sample_value = (biosig_data_type)(*(double*)(ptr)); } break; case 128: // Nihon-Kohden little-endian int16 format u.u16 = leu16p(ptr) + 0x8000; sample_value = (biosig_data_type) (u.i16); break; case 255+12: if (ALPHA12BIT) { // get source address size_t off = (k4+toffset)*hdr->NS*SZ + hdr->CHANNEL[k1].bi8 + k5*SZ; ptr = hdr->AS.rawdata + (off>>3); if (off & 0x07) u.i16 = ptr[1] + ((ptr[0] & 0x0f)<<8); else u.i16 = (ptr[0]<<4) + (ptr[1] >> 4); if (u.i16 & 0x0800) u.i16 -= 0x1000; sample_value = (biosig_data_type)u.i16; } else if (MIT12BIT) { size_t off = (k4+toffset)*hdr->NS*SZ + hdr->CHANNEL[k1].bi8 + k5*SZ; ptr = hdr->AS.rawdata + (off>>3); //bitoff = k5*SZ & 0x07; if (off & 0x07) u.i16 = (((uint16_t)ptr[0] & 0xf0) << 4) + ptr[1]; else //u.i16 = ((uint16_t)ptr[0]<<4) + (ptr[1] & 0x0f); u.i16 = leu16p(ptr) & 0x0fff; if (u.i16 & 0x0800) u.i16 -= 0x1000; sample_value = (biosig_data_type)u.i16; } else if (hdr->FILE.LittleEndian) { bitoff = k5*SZ & 0x07; #if __BYTE_ORDER == __BIG_ENDIAN u.i16 = (leu16p(ptr) >> (4-bitoff)) & 0x0FFF; #elif __BYTE_ORDER == __LITTLE_ENDIAN u.i16 = (leu16p(ptr) >> bitoff) & 0x0FFF; #endif if (u.i16 & 0x0800) u.i16 -= 0x1000; sample_value = (biosig_data_type)u.i16; } else { bitoff = k5*SZ & 0x07; #if __BYTE_ORDER == __BIG_ENDIAN u.i16 = (beu16p(ptr) >> (4-bitoff)) & 0x0FFF; #elif __BYTE_ORDER == __LITTLE_ENDIAN u.i16 = (beu16p(ptr) >> bitoff) & 0x0FFF; #endif if (u.i16 & 0x0800) u.i16 -= 0x1000; sample_value = (biosig_data_type)u.i16; } break; case 511+12: bitoff = k5*SZ & 0x07; if (hdr->FILE.LittleEndian) { #if __BYTE_ORDER == __BIG_ENDIAN sample_value = (biosig_data_type)((leu16p(ptr) >> (4-bitoff)) & 0x0FFF); #elif __BYTE_ORDER == __LITTLE_ENDIAN sample_value = (biosig_data_type)((leu16p(ptr) >> bitoff) & 0x0FFF); #endif } else { #if __BYTE_ORDER == __BIG_ENDIAN sample_value = (biosig_data_type)((beu16p(ptr) >> (4-bitoff)) & 0x0FFF); #elif __BYTE_ORDER == __LITTLE_ENDIAN sample_value = (biosig_data_type)((beu16p(ptr) >> (4-bitoff)) & 0x0FFF); #endif } case 255+24: if (hdr->FILE.LittleEndian) { int32_value = (*(uint8_t*)(ptr)) + (*(uint8_t*)(ptr+1)<<8) + (*(int8_t*)(ptr+2)*(1<<16)); sample_value = (biosig_data_type)int32_value; } else { int32_value = (*(uint8_t*)(ptr+2)) + (*(uint8_t*)(ptr+1)<<8) + (*(int8_t*)(ptr)*(1<<16)); sample_value = (biosig_data_type)int32_value; } break; case 511+24: if (hdr->FILE.LittleEndian) { int32_value = (*(uint8_t*)(ptr)) + (*(uint8_t*)(ptr+1)<<8) + (*(uint8_t*)(ptr+2)<<16); sample_value = (biosig_data_type)int32_value; } else { int32_value = (*(uint8_t*)(ptr+2)) + (*(uint8_t*)(ptr+1)<<8) + (*(uint8_t*)(ptr)<<16); sample_value = (biosig_data_type)int32_value; } break; default: if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) GDFTYP=%i %i %i \n", __FILE__, __LINE__, GDFTYP, (int)k1, (int)k2); biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SREAD: datatype not supported"); return(-1); } // end switch // overflow and saturation detection if ((hdr->FLAG.OVERFLOWDETECTION) && ((sample_value <= CHptr->DigMin) || (sample_value >= CHptr->DigMax))) sample_value = NAN; // missing value if (!hdr->FLAG.UCAL) // scaling sample_value = sample_value * CHptr->Cal + CHptr->Off; if (VERBOSE_LEVEL>8) fprintf(stdout,"%g\n",sample_value); // resampling 1->DIV samples if (hdr->FLAG.ROW_BASED_CHANNELS) { size_t k3; for (k3=0; k3 < DIV; k3++) data1[k2 + (k4*hdr->SPR + k5*DIV + k3)*NS] = sample_value; // row-based channels } else { size_t k3; for (k3=0; k3 < DIV; k3++) data1[k2*count*hdr->SPR + k4*hdr->SPR + k5*DIV + k3] = sample_value; // column-based channels } } // end for (k5 .... } // end for (k4 .... } k2++; }} if (hdr->FLAG.ROW_BASED_CHANNELS) { hdr->data.size[0] = k2; // rows hdr->data.size[1] = hdr->SPR*count; // columns } else { hdr->data.size[0] = hdr->SPR*count; // rows hdr->data.size[1] = k2; // columns } /* read sparse samples */ if (((hdr->TYPE==GDF) && (hdr->VERSION > 1.9)) || (hdr->TYPE==PDP)) { for (k1=0,k2=0; k1NS; k1++) { CHANNEL_TYPE *CHptr = hdr->CHANNEL+k1; // Initialize sparse channels with NANs if (CHptr->OnOff) { /* read selected channels only */ if (CHptr->SPR==0) { // sparsely sampled channels are stored in event table if (hdr->FLAG.ROW_BASED_CHANNELS) { for (k5 = 0; k5 < hdr->SPR*count; k5++) data1[k2 + k5*NS] = CHptr->DigMin; // row-based channels } else { for (k5 = 0; k5 < hdr->SPR*count; k5++) data1[k2*count*hdr->SPR + k5] = CHptr->DigMin; // column-based channels } } k2++; } } double c = hdr->SPR / hdr->SampleRate * hdr->EVENT.SampleRate; size_t *ChanList = (size_t*)calloc(hdr->NS+1,sizeof(size_t)); // Note: ChanList and EVENT.CHN start with index=1 (not 0) size_t ch = 0; for (k1=0; k1NS; k1++) // list of selected channels ChanList[k1+1]= (hdr->CHANNEL[k1].OnOff ? ++ch : 0); for (k1=0; k1EVENT.N; k1++) if (hdr->EVENT.TYP[k1] == 0x7fff) // select non-equidistant sampled value if (ChanList[hdr->EVENT.CHN[k1]] > 0) // if channel is selected if ((hdr->EVENT.POS[k1] >= POS*c) && (hdr->EVENT.POS[k1] < hdr->FILE.POS*c)) { biosig_data_type sample_value; uint8_t *ptr = (uint8_t*)(hdr->EVENT.DUR + k1); k2 = ChanList[hdr->EVENT.CHN[k1]]-1; CHANNEL_TYPE *CHptr = hdr->CHANNEL+k2; size_t DIV = (uint32_t)ceil(hdr->SampleRate/hdr->EVENT.SampleRate); uint16_t GDFTYP = CHptr->GDFTYP; // size_t SZ = GDFTYP_BITS[GDFTYP]>>3; // obsolete int32_t int32_value = 0; if (0); else if (GDFTYP==3) sample_value = (biosig_data_type)lei16p(ptr); else if (GDFTYP==4) sample_value = (biosig_data_type)leu16p(ptr); else if (GDFTYP==16) sample_value = (biosig_data_type)lef32p(ptr); /* else if (GDFTYP==17) sample_value = (biosig_data_type)lef64p(ptr); */ else if (GDFTYP==0) sample_value = (biosig_data_type)(*(char*)ptr); else if (GDFTYP==1) sample_value = (biosig_data_type)(*(int8_t*)ptr); else if (GDFTYP==2) sample_value = (biosig_data_type)(*(uint8_t*)ptr); else if (GDFTYP==5) sample_value = (biosig_data_type)lei32p(ptr); else if (GDFTYP==6) sample_value = (biosig_data_type)leu32p(ptr); /* else if (GDFTYP==7) sample_value = (biosig_data_type)(*(int64_t*)ptr); else if (GDFTYP==8) sample_value = (biosig_data_type)(*(uint64_t*)ptr); */ else if (GDFTYP==255+24) { // assume LITTLE_ENDIAN format int32_value = (*(uint8_t*)(ptr)) + (*(uint8_t*)(ptr+1)<<8) + (*(int8_t*)(ptr+2)*(1<<16)); sample_value = (biosig_data_type)int32_value; } else if (GDFTYP==511+24) { // assume LITTLE_ENDIAN format int32_value = (*(uint8_t*)(ptr)) + (*(uint8_t*)(ptr+1)<<8) + (*(uint8_t*)(ptr+2)<<16); sample_value = (biosig_data_type)int32_value; } else { if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) GDFTYP=%i %i %i \n", __FILE__, __LINE__, GDFTYP,(int)k1,(int)k2); biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "Error SREAD: datatype not supported"); return(0); } // overflow and saturation detection if ((hdr->FLAG.OVERFLOWDETECTION) && ((sample_value<=CHptr->DigMin) || (sample_value>=CHptr->DigMax))) sample_value = NAN; // missing value if (!hdr->FLAG.UCAL) // scaling sample_value = sample_value * CHptr->Cal + CHptr->Off; // resampling 1->DIV samples k5 = (hdr->EVENT.POS[k1]/c - POS)*hdr->SPR; if (hdr->FLAG.ROW_BASED_CHANNELS) { size_t k3; for (k3=0; k3 < DIV; k3++) data1[k2 + (k5 + k3)*NS] = sample_value; } else { size_t k3; for (k3=0; k3 < DIV; k3++) data1[k2 * count * hdr->SPR + k5 + k3] = sample_value; } if (VERBOSE_LEVEL>7) fprintf(stdout,"E%02i: s(%d,%d)= %d %e %e %e\n",(int)k1,(int)k2,hdr->EVENT.CHN[k1],leu32p(ptr),sample_value,(*(double*)(ptr)),(*(float*)(ptr))); } free(ChanList); } else if (hdr->TYPE==TMS32) { // post-processing TMS32 files: last block can contain undefined samples size_t spr = lei32p(hdr->AS.Header+121); if (hdr->FILE.POS*hdr->SPR > spr) for (k2=0; k2SPR; k5 < hdr->SPR*count; k5++) { if (hdr->FLAG.ROW_BASED_CHANNELS) data1[k2 + k5*NS] = NAN; // row-based channels else data1[k2*count*hdr->SPR + k5] = NAN; // column-based channels } } #ifdef CHOLMOD_H if (hdr->Calib) { if (!hdr->FLAG.ROW_BASED_CHANNELS) fprintf(stderr,"Error SREAD: Re-Referencing on column-based data not supported."); else { cholmod_dense X,Y; X.nrow = hdr->data.size[0]; X.ncol = hdr->data.size[1]; X.d = hdr->data.size[0]; X.nzmax= hdr->data.size[1]*hdr->data.size[0]; X.x = data1; X.xtype = CHOLMOD_REAL; X.dtype = CHOLMOD_DOUBLE; Y.nrow = hdr->Calib->ncol; Y.ncol = hdr->data.size[1]; Y.d = Y.nrow; Y.nzmax= Y.nrow * Y.ncol; if (data) Y.x = data; else Y.x = malloc(Y.nzmax*sizeof(double)); Y.xtype = CHOLMOD_REAL; Y.dtype = CHOLMOD_DOUBLE; double alpha[]={1,0},beta[]={0,0}; cholmod_sdmult(hdr->Calib,1,alpha,beta,&X,&Y,&CHOLMOD_COMMON_VAR); if (VERBOSE_LEVEL>8) fprintf(stdout,"%f -> %f\n",*(double*)X.x,*(double*)Y.x); free(X.x); if (data==NULL) hdr->data.block = (biosig_data_type*)Y.x; else hdr->data.block = NULL; hdr->data.size[0] = Y.nrow; } } #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"sread - end \n"); //VERBOSE_LEVEL = V; return(count); } // end of SREAD #ifdef __GSL_MATRIX_DOUBLE_H__ /****************************************************************************/ /** GSL_SREAD : GSL-version of sread **/ /****************************************************************************/ size_t gsl_sread(gsl_matrix* m, size_t start, size_t length, HDRTYPE* hdr) { /* same as sread but return data is of type gsl_matrix */ // TODO: testing size_t count = sread(NULL, start, length, hdr); size_t n = hdr->data.size[0]*hdr->data.size[1]; if (m->owner && m->block) gsl_block_free(m->block); m->block = gsl_block_alloc(n); m->block->data = hdr->data.block; m->size1 = hdr->data.size[1]; m->tda = hdr->data.size[0]; m->size2 = hdr->data.size[0]; m->data = m->block->data; m->owner = 1; hdr->data.block = NULL; return(count); } #endif /****************************************************************************/ /** SWRITE **/ /****************************************************************************/ size_t swrite(const biosig_data_type *data, size_t nelem, HDRTYPE* hdr) { /* * writes NELEM blocks with HDR.AS.bpb BYTES each, */ uint8_t *ptr; size_t count=0,k1,k2,k4,k5,DIV,SZ=0; int GDFTYP; CHANNEL_TYPE* CHptr; biosig_data_type sample_value, iCal, iOff; union { int8_t i8; uint8_t u8; int16_t i16; uint16_t u16; int32_t i32; uint32_t u32; int64_t i64; uint64_t u64; } val; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s( %p, %i, %s ) MODE=%i\n",__func__, data, (int)nelem, hdr->FileName, hdr->FILE.OPEN); // write data #define MAX_INT8 ((int8_t)0x7f) #define MIN_INT8 ((int8_t)0x80) #define MAX_UINT8 ((uint8_t)0xff) #define MIN_UINT8 ((uint8_t)0) #define MAX_INT16 ((int16_t)0x7fff) #define MIN_INT16 ((int16_t)0x8000) #define MAX_UINT16 ((uint16_t)0xffff) #define MIN_UINT16 ((uint16_t)0) #define MAX_INT24 ((int32_t)0x007fffff) #define MIN_INT24 ((int32_t)0xff800000) #define MAX_UINT24 ((uint32_t)0x00ffffff) #define MIN_UINT24 ((uint32_t)0) #define MAX_INT32 ((int32_t)0x7fffffff) #define MIN_INT32 ((int32_t)0x80000000) #define MAX_UINT32 ((uint32_t)0xffffffff) #define MIN_UINT32 ((uint32_t)0) #define MAX_INT64 ((((uint64_t)1)<<63)-1) #define MIN_INT64 ((int64_t)((uint64_t)1)<<63) #define MAX_UINT64 ((uint64_t)0xffffffffffffffffl) #define MIN_UINT64 ((uint64_t)0) size_t bpb8 = bpb8_collapsed_rawdata(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): <%s> sz=%i\n",__func__,__LINE__,hdr->FileName,(int)(hdr->NRec*bpb8>>3)); if (hdr->TYPE==ATF) { if (VERBOSE_LEVEL>7) fprintf(stdout,"ATF swrite\n"); nrec_t nr = hdr->data.size[(int)hdr->FLAG.ROW_BASED_CHANNELS]; // if collapsed data, use k2, otherwise use k1 assert(nr == hdr->NRec * hdr->SPR); typeof(hdr->NS) k,k2; nrec_t c = 0; unsigned timeChan = getTimeChannelNumber(hdr); // char tabflag = 0; if ( timeChan == 0) { hdr->HeadLen += fprintf(hdr->FILE.FID, "\"Time (s)\""); // tabflag = 1; } if (hdr->data.size[1-hdr->FLAG.ROW_BASED_CHANNELS] < hdr->NS) { // if collapsed data, use k2, otherwise use k1 for (c = 0; c < nr; c++) { char *sep = "\n"; if (timeChan == 0) fprintf(hdr->FILE.FID,"%s%.16g",sep,(++hdr->FILE.POS)/hdr->SampleRate); for (k = 0, k2=0; k < hdr->NS; k++) { if (hdr->CHANNEL[k].OnOff) { size_t idx; if (hdr->FLAG.ROW_BASED_CHANNELS) idx = k2 + c * hdr->data.size[0]; else idx = k2 * hdr->data.size[0] + c; fprintf(hdr->FILE.FID,"%s%.16g",sep,data[idx]); sep = "\t"; k2++; } } } } else { // if not collapsed data, use k1 for (c = 0; c < nr; c++) { char *sep = "\n"; if (timeChan == 0) fprintf(hdr->FILE.FID,"%s%.16g",sep,(++hdr->FILE.POS)/hdr->SampleRate); for (k = 0; k < hdr->NS; k++) { if (hdr->CHANNEL[k].OnOff) { size_t idx; if (hdr->FLAG.ROW_BASED_CHANNELS) idx = k + c * hdr->data.size[0]; else idx = k * hdr->data.size[0] + c; fprintf(hdr->FILE.FID,"%s%.16g", sep, data[idx]); sep = "\t"; } } } } return nr; // end write ATF } if ((hdr->NRec*bpb8>0) && (hdr->TYPE != SCP_ECG)) { // memory allocation for SCP is done in SOPEN_SCP_WRITE Section 6 ptr = (typeof(ptr))realloc(hdr->AS.rawdata, (hdr->NRec*bpb8>>3)+1); if (ptr==NULL) { biosigERROR(hdr, B4C_INSUFFICIENT_MEMORY, "SWRITE: memory allocation failed."); return(0); } else hdr->AS.rawdata = (uint8_t*)ptr; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i\n",__func__,__LINE__,(int)hdr->NRec,hdr->NS); size_t bi8 = 0; for (k1=0,k2=0; k1NS; k1++) { CHptr = hdr->CHANNEL+k1; if (CHptr->OnOff != 0) { if (CHptr->SPR) { DIV = hdr->SPR/CHptr->SPR; GDFTYP = CHptr->GDFTYP; SZ = GDFTYP_BITS[GDFTYP]; iCal = 1/CHptr->Cal; //iOff = CHptr->DigMin - CHptr->PhysMin*iCal; iOff = -CHptr->Off*iCal; size_t col = (hdr->data.size[1-hdr->FLAG.ROW_BASED_CHANNELS]NS) ? k2 : k1; // if collapsed data, use k2, otherwise use k1 if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): #%i gdftyp=%i %i %i %i %f %f %f %f %i\n", __func__,__LINE__,(int)k1,GDFTYP,(int)bi8,(int)SZ,(int)CHptr->SPR,CHptr->Cal,CHptr->Off,iCal,iOff,(int)bpb8); for (k4 = 0; k4 < (size_t)hdr->NRec; k4++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): #%i: [%i %i] %i %i %i %i %i\n", __func__,__LINE__,(int)k1,(int)hdr->data.size[0],(int)hdr->data.size[1],(int)k4,(int)0,(int)hdr->SPR,(int)DIV,(int)nelem); for (k5 = 0; k5 < CHptr->SPR; k5++) { if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): #%i: [%i %i] %i %i %i %i %i\n", __func__,__LINE__,(int)k1,(int)hdr->data.size[0],(int)hdr->data.size[1],(int)k4,(int)k5,(int)hdr->SPR,(int)DIV,(int)nelem); size_t k3=0; if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): [%i %i %i %i %i] %i %i %i %i %i %i\n", __func__,__LINE__,(int)k1,(int)k2,(int)k3,(int)k4,(int)k5,(int)col, (int)hdr->data.size[0],(int)hdr->data.size[1],(int)hdr->SPR,(int)nelem,(int)hdr->NRec); if (hdr->FLAG.ROW_BASED_CHANNELS) { for (k3=0, sample_value=0.0; k3 < DIV; k3++) sample_value += data[col + (k4*hdr->SPR + k5*DIV + k3)*hdr->data.size[0]]; } else { for (k3=0, sample_value=0.0; k3 < DIV; k3++) sample_value += data[col*nelem*hdr->SPR + k4*hdr->SPR + k5*DIV + k3]; } if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): %f/%i\n",__func__,__LINE__,sample_value,(int)DIV); sample_value /= DIV; if (!hdr->FLAG.UCAL) // scaling sample_value = sample_value * iCal + iOff; // get target address //ptr = hdr->AS.rawdata + k4*hdr->AS.bpb + hdr->CHANNEL[k1].bi + k5*SZ; //ptr = hdr->AS.rawdata + (k4*bpb8 + bi8 + k5*SZ)>>3; //size_t off = k4*hdr->AS.bpb8 + hdr->CHANNEL[k1].bi8 + (k5*SZ); size_t off = k4*bpb8 + bi8 + (k5*SZ); ptr = hdr->AS.rawdata + (off>>3); if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): %i %i %i %f %p %p\n", __func__,__LINE__,(int)k4,(int)k5,(int)(off>>3),sample_value, hdr->AS.Header, ptr); // mapping of raw data type to (biosig_data_type) switch (GDFTYP) { case 3: if (sample_value > MAX_INT16) val.i16 = MAX_INT16; else if (sample_value > MIN_INT16) val.i16 = (int16_t) sample_value; else val.i16 = MIN_INT16; lei16a(val.i16, ptr); break; case 4: if (sample_value > MAX_UINT16) val.u16 = MAX_UINT16; else if (sample_value > MIN_UINT16) val.u16 = (uint16_t) sample_value; else val.u16 = MIN_UINT16; leu16a(val.u16, ptr); break; case 16: lef32a((float)sample_value, ptr); break; case 17: lef64a((double)sample_value, ptr); break; case 0: if (sample_value > MAX_INT8) val.i8 = MAX_INT8; else if (sample_value > MIN_INT8) val.i8 = (int8_t) sample_value; else val.i8 = MIN_INT8; *(int8_t*)ptr = val.i8; break; case 1: if (sample_value > MAX_INT8) val.i8 = MAX_INT8; else if (sample_value > MIN_INT8) val.i8 = (int8_t) sample_value; else val.i8 = MIN_INT8; *(int8_t*)ptr = val.i8; break; case 2: if (sample_value > MAX_UINT8) val.u8 = MAX_UINT8; else if (sample_value > MIN_UINT8) val.u8 = (uint8_t) sample_value; else val.u8 = MIN_UINT8; *(uint8_t*)ptr = val.u8; break; case 5: if (sample_value > ldexp(1.0,31)-1) val.i32 = MAX_INT32; else if (sample_value > ldexp(-1.0,31)) val.i32 = (int32_t) sample_value; else val.i32 = MIN_INT32; lei32a(val.i32, ptr); break; case 6: if (sample_value > ldexp(1.0,32)-1.0) val.u32 = MAX_UINT32; else if (sample_value > 0.0) val.u32 = (uint32_t) sample_value; else val.u32 = MIN_UINT32; leu32a(val.u32, ptr); break; case 7: if (sample_value > ldexp(1.0,63)-1.0) val.i64 = MAX_INT64; else if (sample_value > -ldexp(1.0,63)) val.i64 = (int64_t) sample_value; else val.i64 = MIN_INT64; lei64a(val.i64, ptr); break; case 8: if (sample_value > ldexp(1.0,64)-1.0) val.u64 = (uint64_t)(-1); else if (sample_value > 0.0) val.u64 = (uint64_t) sample_value; else val.u64 = 0; leu64a(val.u64, ptr); break; case 255+24: if (sample_value > MAX_INT24) val.i32 = MAX_INT24; else if (sample_value > MIN_INT24) val.i32 = (int32_t) sample_value; else val.i32 = MIN_INT24; *(uint8_t*)ptr = (uint8_t)(val.i32 & 0x000000ff); *((uint8_t*)ptr+1) = (uint8_t)((val.i32>>8) & 0x000000ff); *((uint8_t*)ptr+2) = (uint8_t)((val.i32>>16) & 0x000000ff); break; case 511+24: if (sample_value > MAX_UINT24) val.i32 = MAX_UINT24; else if (sample_value > MIN_UINT24) val.i32 = (int32_t) sample_value; else val.i32 = MIN_UINT24; *(uint8_t*)ptr = val.i32 & 0x000000ff; *((uint8_t*)ptr+1) = (uint8_t)((val.i32>>8) & 0x000000ff); *((uint8_t*)ptr+2) = (uint8_t)((val.i32>>16) & 0x000000ff); break; case 255+12: case 511+12: { if (GDFTYP == 255+12) { if (sample_value > ((1<<11)-1)) val.i16 = (1<<11)-1; else if (sample_value > -(1<<11)) val.i16 = (int16_t) sample_value; else val.i16 = -(1<<11); } else if (GDFTYP == 511+12) { if (sample_value > ((1<<12)-1)) val.u16 = (1<<12)-1; else if (sample_value > 0) val.u16 = (int16_t) sample_value; else val.u16 = 0; } if (hdr->FILE.LittleEndian) { uint16_t acc = leu16p(ptr); if (off) leu16a( (acc & 0x000F) | (val.u16<<4), ptr); else leu16a( (acc & 0xF000) | (val.u16 & 0x0FFF), ptr); } else { uint16_t acc = beu16p(ptr); if (!off) beu16a( (acc & 0x000F) | (val.u16<<4), ptr); else beu16a( (acc & 0xF000) | (val.u16 & 0x0FFF), ptr); } break; } default: biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "SWRITE: datatype not supported"); return(0); } } // end for k5 } // end for k4 } // end if SPR k2++; bi8 += SZ*CHptr->SPR; if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite 314 %i\n",(int)k2); } // end if OnOff } // end for k1 if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite 315 <%s>\n", hdr->FileName ); #ifndef WITHOUT_NETWORK if (hdr->FILE.Des>0) { if (VERBOSE_LEVEL>7) fprintf(stdout,"bscs_send_dat sz=%i\n",(int)(hdr->NRec*bpb8>>3)); int s = bscs_send_dat(hdr->FILE.Des,hdr->AS.rawdata,hdr->NRec*bpb8>>3); if (VERBOSE_LEVEL>7) fprintf(stdout,"bscs_send_dat succeeded %i\n",s); } else #endif #ifndef ONLYGDF if ((hdr->TYPE == ASCII) || (hdr->TYPE == BIN)) { HDRTYPE H1; H1.CHANNEL = NULL; H1.FILE.COMPRESSION = hdr->FILE.COMPRESSION; if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite ASCII/BIN\n"); k1 = strlen(hdr->FileName); char* fn = (char*)calloc(k1 + 10,1); strcpy(fn, hdr->FileName); char *e = strrchr(fn,'.'); if (e==NULL) { fn[k1] = '.'; e = fn+k1; } e[1] = (hdr->TYPE == ASCII ? 'a' : 's'); e+=2; for (k1=0; k1NS; k1++) if (hdr->CHANNEL[k1].OnOff) { //if (hdr->CHANNEL[k1].OnOff && hdr->CHANNEL[k1].SPR) { /* Off channels and sparse channels (SPR) are not exported; sparse samples are available throught the header file containing the event table. */ CHptr = hdr->CHANNEL+k1; if (hdr->FILE.COMPRESSION) sprintf(e,"%02i_gz",(int)k1+1); else sprintf(e,"%02i",(int)k1+1); if (VERBOSE_LEVEL>7) fprintf(stdout,"#%i: %s\n",(int)k1,fn); H1.FileName = fn; ifopen(&H1,"wb"); if (hdr->TYPE == ASCII) { typeof(hdr->SPR) SPR; if (CHptr->SPR>0) { DIV = hdr->SPR/CHptr->SPR; SPR = CHptr->SPR; } else { DIV = 1; SPR = hdr->SPR; } size_t k2; for (k2=0; k2 < SPR*(size_t)hdr->NRec; k2++) { biosig_data_type i = 0.0; size_t k3; // TODO: row channels if (hdr->FLAG.ROW_BASED_CHANNELS) for (k3=0; k3data.block[k1+(k2*DIV+k3)*hdr->data.size[0]]; else // assumes column channels for (k3=0; k3data.block[hdr->SPR*hdr->NRec*k1+k2*DIV+k3]; /* if (hdr->FLAG.ROW_BASED_CHANNELS) { for (k3=0, sample_value=0.0; k3 < DIV; k3++) sample_value += data[col + (k4*hdr->SPR + k5*DIV + k3)*hdr->data.size[0]]; } else { for (k3=0, sample_value=0.0; k3 < DIV; k3++) sample_value += data[col*nelem*hdr->SPR + k4*hdr->SPR + k5*DIV + k3]; } */ #ifdef ZLIB_H if (H1.FILE.COMPRESSION) gzprintf(H1.FILE.gzFID,"%g\n",i/DIV); else #endif fprintf(H1.FILE.FID,"%g\n",i/DIV); } } else if (hdr->TYPE == BIN) { size_t nbytes = ((size_t)hdr->CHANNEL[k1].SPR * GDFTYP_BITS[hdr->CHANNEL[k1].GDFTYP])>>3; ifwrite(hdr->AS.rawdata+hdr->CHANNEL[k1].bi, nbytes, hdr->NRec, &H1); } ifclose(&H1); } count = hdr->NRec; free(fn); } else #endif //ONLYGDF if ((hdr->TYPE != SCP_ECG) && (hdr->TYPE != HL7aECG)) { // for SCP: writing to file is done in SCLOSE if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite 317 <%s>\n", hdr->FileName ); count = ifwrite((uint8_t*)(hdr->AS.rawdata), hdr->AS.bpb, hdr->NRec, hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite 319 <%i>\n", (int)count); } else { // SCP_ECG, HL7aECG #ifdef ONLYGDF assert(0); #endif //ONLYGDF count = 1; } // set position of file handle hdr->FILE.POS += count; return(count); } // end of SWRITE /****************************************************************************/ /** SEOF **/ /****************************************************************************/ int seof(HDRTYPE* hdr) { return (hdr->FILE.POS >= (size_t)hdr->NRec); } /****************************************************************************/ /** SREWIND **/ /****************************************************************************/ void srewind(HDRTYPE* hdr) { sseek(hdr,0,SEEK_SET); return; } /****************************************************************************/ /** SSEEK **/ /****************************************************************************/ int sseek(HDRTYPE* hdr, ssize_t offset, int whence) { int64_t pos=0; if (whence < 0) pos = offset * hdr->AS.bpb; else if (whence == 0) pos = (hdr->FILE.POS + offset) * hdr->AS.bpb; else if (whence > 0) pos = (hdr->NRec + offset) * hdr->AS.bpb; if ((pos < 0) | (pos > hdr->NRec * hdr->AS.bpb)) return(-1); else if (ifseek(hdr, pos + hdr->HeadLen, SEEK_SET)) return(-1); hdr->FILE.POS = pos / (hdr->AS.bpb); return(0); } // end of SSEEK /****************************************************************************/ /** STELL **/ /****************************************************************************/ ssize_t stell(HDRTYPE* hdr) { ssize_t pos = iftell(hdr); if (pos<0) return(-1); else if ((size_t)pos != (hdr->FILE.POS * hdr->AS.bpb + hdr->HeadLen)) return(-1); else return(hdr->FILE.POS); } // end of STELL /****************************************************************************/ /** SCLOSE **/ /****************************************************************************/ int sclose(HDRTYPE* hdr) { ssize_t pos, len; if (VERBOSE_LEVEL>6) fprintf(stdout,"SCLOSE( %s ) MODE=%i\n",hdr->FileName, hdr->FILE.OPEN); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose\n",__FILE__,__LINE__); if (hdr==NULL) return(0); size_t k; for (k=0; kNS; k++) { // replace Nihon-Kohden code with standard code if (hdr->CHANNEL[k].GDFTYP==128) hdr->CHANNEL[k].GDFTYP=3; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose OPEN=%i %s\n",__FILE__,__LINE__,hdr->FILE.OPEN,GetFileTypeString(hdr->TYPE)); #if defined(WITH_FEF) && !defined(ONLYGDF) if (hdr->TYPE == FEF) sclose_fef_read(hdr); #endif #ifndef WITHOUT_NETWORK if (hdr->FILE.Des>0) { // network connection if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose\n",__FILE__,__LINE__); if (hdr->FILE.OPEN > 1) bscs_send_evt(hdr->FILE.Des,hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose\n",__FILE__,__LINE__); int s = bscs_close(hdr->FILE.Des); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose\n",__FILE__,__LINE__); if (s & ERR_MASK) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): bscs_close failed (err %i %08x)\n",__FILE__,__LINE__,s,s); biosigERROR(hdr, B4C_SCLOSE_FAILED, "bscs_close failed"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): sclose\n",__FILE__,__LINE__); hdr->FILE.Des = 0; hdr->FILE.OPEN = 0; bscs_disconnect(hdr->FILE.Des); } else #endif if ((hdr->FILE.OPEN>1) && ((hdr->TYPE==GDF) || (hdr->TYPE==EDF) || (hdr->TYPE==BDF))) { if (VERBOSE_LEVEL>7) fprintf(stdout,"sclose(121) nrec= %i\n",(int)hdr->NRec); // WRITE HDR.NRec pos = (iftell(hdr)-hdr->HeadLen); if (hdr->NRec<0) { union { char tmp[88]; int64_t i64; } t; if (pos>0) hdr->NRec = pos/hdr->AS.bpb; else hdr->NRec = 0; if (hdr->TYPE==GDF) { t.i64 = htole64(hdr->NRec); len = sizeof(hdr->NRec); } else { len = sprintf(t.tmp,"%d",(int)hdr->NRec); if (len>8) fprintf(stderr,"Warning: NRec is (%s) to long.\n",t.tmp); } /* ### FIXME : gzseek supports only forward seek */ if (hdr->FILE.COMPRESSION>0) fprintf(stderr,"Warning: writing NRec in gz-file requires gzseek which may not be supported.\n"); ifseek(hdr,236,SEEK_SET); ifwrite(t.tmp,len,1,hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout, "888: File Type=%s ,N#of Events %i,bpb=%i\n",GetFileTypeString(hdr->TYPE),hdr->EVENT.N,hdr->AS.bpb); if ((hdr->TYPE==GDF) && (hdr->EVENT.N>0)) { size_t len = hdrEVT2rawEVT(hdr); ifseek(hdr, hdr->HeadLen + hdr->AS.bpb*hdr->NRec, SEEK_SET); ifwrite(hdr->AS.rawEventData, len, 1, hdr); // write_gdf_eventtable(hdr); } } #ifndef ONLYGDF else if ((hdr->FILE.OPEN>1) && (hdr->TYPE==ATF)) { fprintf(hdr->FILE.FID, "\n"); } else if ((hdr->FILE.OPEN>1) && (hdr->TYPE==SCP_ECG)) { uint16_t crc; uint8_t* ptr; // pointer to memory mapping of the file layout hdr->AS.rawdata = NULL; struct aecg* aECG = (struct aecg*)hdr->aECG; if (aECG->Section5.Length>0) { // compute CRC for Section 5 uint16_t crc = CRCEvaluate(hdr->AS.Header + aECG->Section5.StartPtr+2,aECG->Section5.Length-2); // compute CRC leu16a(crc, hdr->AS.Header + aECG->Section5.StartPtr); } if (aECG->Section6.Length>0) { // compute CRC for Section 6 uint16_t crc = CRCEvaluate(hdr->AS.Header + aECG->Section6.StartPtr+2,aECG->Section6.Length-2); // compute CRC leu16a(crc, hdr->AS.Header + aECG->Section6.StartPtr); } if ((aECG->Section12.Length>0) && (hdr->VERSION >2.5)){ // compute CRC for Section 12 uint16_t crc = CRCEvaluate(hdr->AS.Header + aECG->Section12.StartPtr+2,aECG->Section12.Length-2); // compute CRC leu16a(crc, hdr->AS.Header + aECG->Section12.StartPtr); } // compute crc and len and write to preamble ptr = hdr->AS.Header; leu32a(hdr->HeadLen, ptr+2); crc = CRCEvaluate(ptr+2,hdr->HeadLen-2); leu16a(crc, ptr); ifwrite(hdr->AS.Header, sizeof(char), hdr->HeadLen, hdr); } else if ((hdr->FILE.OPEN>1) && (hdr->TYPE==HL7aECG)) { sclose_HL7aECG_write(hdr); hdr->FILE.OPEN = 0; } #endif //ONLYGDF if (hdr->FILE.OPEN > 0) { int status = ifclose(hdr); if (status) iferror(hdr); hdr->FILE.OPEN = 0; } return(0); } /****************************************************************************/ /** Error Handling **/ /****************************************************************************/ void biosigERROR(HDRTYPE *hdr, enum B4C_ERROR errnum, const char *errmsg) { /* sets the local and the (deprecated) global error variables B4C_ERRNUM and B4C_ERRMSG the global error variables are kept for backwards compatibility. */ #if (BIOSIG_VERSION < 10500) #ifndef ONLYGDF B4C_ERRNUM = errnum; B4C_ERRMSG = errmsg; #endif //ONLYGDF #endif hdr->AS.B4C_ERRNUM = errnum; hdr->AS.B4C_ERRMSG = errmsg; } #if (BIOSIG_VERSION < 10500) #ifndef ONLYGDF // do not expose deprecated interface in libgdf int serror() { int status = B4C_ERRNUM; fprintf(stderr,"Warning: use of function SERROR() is deprecated - use SERROR2() instead"); if (status) { fprintf(stderr,"ERROR %i: %s\n",B4C_ERRNUM,B4C_ERRMSG); B4C_ERRNUM = B4C_NO_ERROR; } return(status); } #endif //ONLYGDF #endif int serror2(HDRTYPE *hdr) { int status = hdr->AS.B4C_ERRNUM; if (status) { fprintf(stderr,"ERROR %i: %s\n",hdr->AS.B4C_ERRNUM,hdr->AS.B4C_ERRMSG); hdr->AS.B4C_ERRNUM = B4C_NO_ERROR; hdr->AS.B4C_ERRMSG = NULL; } return(status); } char *biosig_get_errormsg(HDRTYPE *hdr) { if (hdr==NULL) return NULL; if (hdr->AS.B4C_ERRNUM==0) return NULL; return strdup(hdr->AS.B4C_ERRMSG); }; int biosig_check_error(HDRTYPE *hdr) { if (hdr==NULL) return B4C_NO_ERROR; return hdr->AS.B4C_ERRNUM; }; /****************************************************************************/ /* Write / Update Event Table in GDF file */ /* */ /* returns 0 in case of success */ /* returns -1 in case of failure */ /****************************************************************************/ int sflush_gdf_event_table(HDRTYPE* hdr) { if ((hdr->TYPE!=GDF) || hdr->FILE.COMPRESSION) return(-1); ssize_t filepos = iftell(hdr); ifclose(hdr); hdr = ifopen(hdr,"rb+"); if (!hdr->FILE.OPEN) { /* file cannot be opened in write mode */ hdr = ifopen(hdr,"rb"); return(-1); } size_t len = hdrEVT2rawEVT(hdr); ifseek(hdr, hdr->HeadLen + hdr->AS.bpb*hdr->NRec, SEEK_SET); ifwrite(hdr->AS.rawEventData, len, 1, hdr); // write_gdf_eventtable(hdr); ifseek(hdr,filepos,SEEK_SET); return(0); } void fprintf_json_double(FILE *fid, const char* Name, double val) { fprintf(fid,"\t\t\"%s\"\t: %g", Name, val); } /****************************************************************************/ /** HDR2ASCII **/ /** displaying header information **/ /****************************************************************************/ int asprintf_hdr2json(char **str, HDRTYPE *hdr) { size_t k; char tmp[41]; char flag_comma = 0; size_t sz = 25*50 + hdr->NS * 16 * 50 + hdr->EVENT.N * 6 * 50; // rough estimate of memory needed size_t c = 0; *str = (char*) realloc(*str, sz); #define STR ((*str)+c) if (VERBOSE_LEVEL>7) fprintf(stdout, "asprintf_hdr2json: sz=%i\n", (int)sz); size_t NumberOfSweeps = (hdr->SPR*hdr->NRec > 0); size_t NumberOfUserSpecifiedEvents = 0; for (k = 0; k < hdr->EVENT.N; k++) { if (hdr->EVENT.TYP[k] < 255) NumberOfUserSpecifiedEvents++; else if (hdr->EVENT.TYP[k]==0x7ffe) NumberOfSweeps++; } c += sprintf(STR, "\n{\n"); c += sprintf(STR, "\t\"TYPE\"\t: \"%s\",\n",GetFileTypeString(hdr->TYPE)); c += sprintf(STR, "\t\"VERSION\"\t: %4.2f,\n",hdr->VERSION); c += sprintf(STR, "\t\"Filename\"\t: \"%s\",\n",hdr->FileName); c += sprintf(STR, "\t\"NumberOfChannels\"\t: %i,\n",(int)hdr->NS); c += sprintf(STR, "\t\"NumberOfRecords\"\t: %i,\n",(int)hdr->NRec); c += sprintf(STR, "\t\"SamplesPerRecords\"\t: %i,\n",(int)hdr->SPR); c += sprintf(STR, "\t\"NumberOfSamples\"\t: %i,\n",(int)(hdr->NRec*hdr->SPR)); if ((0.0 <= hdr->SampleRate) && (hdr->SampleRate < INFINITY)) c += sprintf(STR, "\t\"Samplingrate\"\t: %f,\n",hdr->SampleRate); snprintf_gdfdatetime(tmp, 40, hdr->T0); c += sprintf(STR, "\t\"StartOfRecording\"\t: \"%s\",\n",tmp); c += sprintf(STR, "\t\"TimezoneMinutesEastOfUTC\"\t: %i,\n", hdr->tzmin); c += sprintf(STR, "\t\"NumberOfSweeps\"\t: %d,\n",(unsigned)NumberOfSweeps); c += sprintf(STR, "\t\"NumberOfGroupsOrUserSpecifiedEvents\"\t: %d,\n", (unsigned)NumberOfUserSpecifiedEvents); c += sprintf(STR, "\t\"Patient\"\t: {\n"); if (strlen(hdr->Patient.Name)) { c += sprintf(STR, "\t\t\"Name\"\t: \"%s\",\n", hdr->Patient.Name); char Name[MAX_LENGTH_NAME+1]; strcpy(Name, hdr->Patient.Name); char *lastname = strtok(Name,"\x1f"); char *firstname = strtok(NULL,"\x1f"); char *secondlastname = strtok(NULL,"\x1f"); c += sprintf(STR, "\t\t\"Lastname\"\t: \"%s\",\n", lastname); c += sprintf(STR, "\t\t\"Firstname\"\t: \"%s\",\n", firstname); c += sprintf(STR, "\t\t\"Second_Lastname\"\t: \"%s\",\n", secondlastname); } if (hdr->Patient.Id) c += sprintf(STR, "\t\t\"Id\"\t: \"%s\",\n", hdr->Patient.Id); if (hdr->Patient.Weight) c += sprintf(STR, "\t\t\"Weight\"\t: \"%i kg\",\n", hdr->Patient.Weight); if (hdr->Patient.Height) c += sprintf(STR, "\t\t\"Height\"\t: \"%i cm\",\n", hdr->Patient.Height); if (hdr->Patient.Birthday>0) c += sprintf(STR, "\t\t\"Age\"\t: %i,\n", (int)((hdr->T0 - hdr->Patient.Birthday)/ldexp(365.25,32)) ); c += sprintf(STR, "\t\t\"Gender\"\t: \"%s\"\n", hdr->Patient.Sex==1 ? "Male" : "Female"); // no comma at the end because its the last element c += sprintf(STR, "\t},\n"); // end-of-Patient if (hdr->ID.Manufacturer.Name || hdr->ID.Manufacturer.Model || hdr->ID.Manufacturer.Version || hdr->ID.Manufacturer.SerialNumber) { c += sprintf(STR,"\t\"Manufacturer\"\t: {\n"); flag_comma = 0; if (hdr->ID.Manufacturer.Name) { c += sprintf(STR,"\t\t\"Name\"\t: \"%s\"", hdr->ID.Manufacturer.Name); flag_comma = 1; } if (hdr->ID.Manufacturer.Model) { if (flag_comma) c += sprintf(STR,",\n"); c += sprintf(STR,"\t\t\"Model\"\t: \"%s\"", hdr->ID.Manufacturer.Model); flag_comma = 1; } if (hdr->ID.Manufacturer.Version) { if (flag_comma) c += sprintf(STR,",\n"); c += sprintf(STR,"\t\t\"Version\"\t: \"%s\"", hdr->ID.Manufacturer.Version); flag_comma = 1; } if (hdr->ID.Manufacturer.SerialNumber) { if (flag_comma) c += sprintf(STR,",\n"); c += sprintf(STR,"\t\t\"SerialNumber\"\t: \"%s\"", hdr->ID.Manufacturer.SerialNumber); } c += sprintf(STR,"\n\t},\n"); // end-of-Manufacturer } c += sprintf(STR,"\t\"CHANNEL\"\t: ["); if (VERBOSE_LEVEL>7) fprintf(stdout, "asprintf_hdr2json: count=%i\n", (int)c); for (k = 0; k < hdr->NS; k++) { if (sz < c + 1000) { // double allocated memory sz *= 2; *str = (char*) realloc(*str, sz); } CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (k>0) c += sprintf(STR,","); c += sprintf(STR,"\n\t\t{\n"); c += sprintf(STR,"\t\t\"ChannelNumber\"\t: %i,\n", (int)k+1); c += sprintf(STR,"\t\t\"Label\"\t: \"%s\",\n", hc->Label); double fs = hdr->SampleRate * hc->SPR/hdr->SPR; if ((0.0 <= fs) && (fs < INFINITY)) c += sprintf(STR, "\t\t\"Samplingrate\"\t: %f,\n", fs); if ( hc->Transducer && strlen(hc->Transducer) ) c += sprintf(STR,"\t\t\"Transducer\"\t: \"%s\",\n", hc->Transducer); if (!isnan(hc->PhysMax)) c += sprintf(STR,"\t\t\"PhysicalMaximum\"\t: %g,\n", hc->PhysMax); if (!isnan(hc->PhysMin)) c += sprintf(STR,"\t\t\"PhysicalMinimum\"\t: %g,\n", hc->PhysMin); if (!isnan(hc->DigMax)) c += sprintf(STR,"\t\t\"DigitalMaximum\"\t: %f,\n", hc->DigMax); if (!isnan(hc->DigMin)) c += sprintf(STR,"\t\t\"DigitalMinimum\"\t: %f,\n", hc->DigMin); if (!isnan(hc->Cal)) c += sprintf(STR,"\t\t\"scaling\"\t: %g,\n", hc->Cal); if (!isnan(hc->Off)) c += sprintf(STR,"\t\t\"offset\"\t: %g,\n", hc->Off); if (!isnan(hc->TOffset)) c += sprintf(STR,"\t\t\"TimeDelay\"\t: %g", hc->TOffset); uint8_t flag = (0 < hc->LowPass && hc->LowPassHighPass && hc->HighPassNotch && hc->NotchLowPass, flag & 0x06 ? ',' : ' '); if (flag & 0x02) c += sprintf(STR, "\t\t\t\"Highpass\"\t: %g%c\n", hc->HighPass, flag & 0x04 ? ',' : ' ' ); if (flag & 0x04) c += sprintf(STR, "\t\t\t\"Notch\"\t: %g\n", hc->Notch); c += sprintf(STR, "\n\t\t},\n"); } switch (hc->PhysDimCode & 0xffe0) { case 4256: // Volt if (!isnan(hc->Impedance)) c += sprintf(STR, "\t\t\"Impedance\"\t: %g,\n", hc->Impedance); break; case 4288: // Ohm if (!isnan(hc->fZ)) c += sprintf(STR, "\t\t\"fZ\"\t: %g,\n", hc->fZ); break; } c += sprintf(STR,"\t\t\"PhysicalUnit\"\t: \"%s\"", PhysDim3(hc->PhysDimCode)); c += sprintf(STR, "\n\t\t}"); // end-of-CHANNEL } c += sprintf(STR, "\n\t]"); // end-of-CHANNELS if (VERBOSE_LEVEL>7) fprintf(stdout, "asprintf_hdr2json: count=%i\n", (int)c); if (hdr->EVENT.N>0) { c += sprintf(STR, ",\n\t\"EVENT\"\t: ["); flag_comma = 0; for (k = 0; k < hdr->EVENT.N; k++) { if ( hdr->EVENT.TYP[k] == 0 ) continue; if (sz < c + 1000) { // double allocated memory sz *= 2; *str = (char*) realloc(*str, sz); } if ( flag_comma ) c += sprintf(STR,","); c += sprintf(STR, "\n\t\t{\n"); c += sprintf(STR, "\t\t\"TYP\"\t: \"0x%04x\",\n", hdr->EVENT.TYP[k]); c += sprintf(STR, "\t\t\"POS\"\t: %f", hdr->EVENT.POS[k]/hdr->EVENT.SampleRate); if (hdr->EVENT.CHN && hdr->EVENT.DUR) { if (hdr->EVENT.CHN[k]) c += sprintf(STR, ",\n\t\t\"CHN\"\t: %d", hdr->EVENT.CHN[k]); if (hdr->EVENT.TYP[k] != 0x7fff) c += sprintf(STR, ",\n\t\t\"DUR\"\t: %f", hdr->EVENT.DUR[k]/hdr->EVENT.SampleRate); } if (hdr->EVENT.TimeStamp != NULL && hdr->EVENT.TimeStamp[k] != 0) { char buf[255]; snprintf_gdfdatetime(buf, sizeof(buf), hdr->EVENT.TimeStamp[k]); c += sprintf(STR,",\n\t\t\"TimeStamp\"\t: \"%s\"", buf); } if (hdr->EVENT.TYP[k] == 0x7fff) { // c += sprintf(STR, ",\n\t\t\"Description\"\t: \"[sparse sample]\""); typeof(hdr->NS) chan = hdr->EVENT.CHN[k] - 1; double val = dur2val(hdr->EVENT.DUR[k], hdr->CHANNEL[chan].GDFTYP); val *= hdr->CHANNEL[chan].Cal; val += hdr->CHANNEL[chan].Off; if (isfinite(val)) c += sprintf(STR, ",\n\t\t\"Value\"\t: %g", val); // no comma at the end because its the last element } else { const char *tmpstr = GetEventDescription(hdr,k); if (tmpstr != NULL) c += sprintf(STR, ",\n\t\t\"Description\"\t: \"%s\"", tmpstr); // no comma at the end because its the last element } c += sprintf(STR, "\n\t\t}"); flag_comma = 1; } c += sprintf(STR, "\n\t]"); // end-of-EVENT } c += sprintf(STR, "\n}\n"); if (VERBOSE_LEVEL>7) fprintf(stdout, "asprintf_hdr2json: count=%i\n", (int)c); return (0); #undef STR } /****************************************************************************/ /** HDR2ASCII **/ /** displaying header information **/ /****************************************************************************/ #if (BIOSIG_VERSION < 10500) // for backwards compatibility ATT_DEPREC int hdr2json( HDRTYPE *hdr, FILE *fid) { return fprintf_hdr2json(fid, hdr); } // deprecated since Oct 2012, v1.4.0 #endif int fprintf_hdr2json(FILE *fid, HDRTYPE* hdr) { size_t k; char tmp[41]; char flag_comma = 0; size_t NumberOfSweeps = (hdr->SPR*hdr->NRec > 0); size_t NumberOfUserSpecifiedEvents = 0; for (k = 0; k < hdr->EVENT.N; k++) { if (hdr->EVENT.TYP[k] < 255) NumberOfUserSpecifiedEvents++; else if (hdr->EVENT.TYP[k]==0x7ffe) NumberOfSweeps++; } fprintf(fid,"{\n"); fprintf(fid,"\t\"TYPE\"\t: \"%s\",\n",GetFileTypeString(hdr->TYPE)); fprintf(fid,"\t\"VERSION\"\t: %4.2f,\n",hdr->VERSION); fprintf(fid,"\t\"Filename\"\t: \"%s\",\n",hdr->FileName); fprintf(fid,"\t\"NumberOfChannels\"\t: %i,\n",(int)hdr->NS); fprintf(fid,"\t\"NumberOfRecords\"\t: %i,\n",(int)hdr->NRec); fprintf(fid,"\t\"SamplesPerRecords\"\t: %i,\n",(int)hdr->SPR); fprintf(fid,"\t\"NumberOfSamples\"\t: %i,\n",(int)(hdr->NRec*hdr->SPR)); if ((0.0 <= hdr->SampleRate) && (hdr->SampleRate < INFINITY)) fprintf(fid,"\t\"Samplingrate\"\t: %f,\n", hdr->SampleRate); snprintf_gdfdatetime(tmp, 40, hdr->T0); fprintf(fid,"\t\"StartOfRecording\"\t: \"%s\",\n",tmp); fprintf(fid,"\t\"TimezoneMinutesEastOfUTC\"\t: %i,\n", hdr->tzmin); fprintf(fid,"\t\"NumberOfSweeps\"\t: %d,\n",(unsigned)NumberOfSweeps); fprintf(fid,"\t\"NumberOfGroupsOrUserSpecifiedEvents\"\t: %d,\n",(unsigned)NumberOfUserSpecifiedEvents); fprintf(fid,"\t\"Patient\"\t: {\n"); if (strlen(hdr->Patient.Name)) { fprintf(fid, "\t\t\"Name\"\t: \"%s\",\n", hdr->Patient.Name); char Name[MAX_LENGTH_NAME+1]; strcpy(Name, hdr->Patient.Name); char *lastname = strtok(Name,"\x1f"); char *firstname = strtok(NULL,"\x1f"); char *secondlastname = strtok(NULL,"\x1f"); fprintf(fid, "\t\t\"Lastname\"\t: \"%s\",\n", lastname); fprintf(fid, "\t\t\"Firstname\"\t: \"%s\",\n", firstname); fprintf(fid, "\t\t\"Second_Lastname\"\t: \"%s\",\n", secondlastname); } if (hdr->Patient.Id) fprintf(fid,"\t\t\"Id\"\t: \"%s\",\n", hdr->Patient.Id); if (hdr->Patient.Weight) fprintf(fid,"\t\t\"Weight\"\t: \"%i kg\",\n", hdr->Patient.Weight); if (hdr->Patient.Height) fprintf(fid,"\t\t\"Height\"\t: \"%i cm\",\n", hdr->Patient.Height); if (hdr->Patient.Birthday>0) fprintf(fid,"\t\t\"Age\"\t: %i,\n", (int)((hdr->T0 - hdr->Patient.Birthday)/ldexp(365.25,32)) ); fprintf(fid,"\t\t\"Gender\"\t: \"%s\"\n", hdr->Patient.Sex==1 ? "Male" : "Female"); // no comma at the end because its the last element fprintf(fid,"\t},\n"); // end-of-Patient if (hdr->ID.Manufacturer.Name || hdr->ID.Manufacturer.Model || hdr->ID.Manufacturer.Version || hdr->ID.Manufacturer.SerialNumber) { fprintf(fid,"\t\"Manufacturer\"\t: {\n"); flag_comma = 0; if (hdr->ID.Manufacturer.Name) { fprintf(fid,"\t\t\"Name\"\t: \"%s\"", hdr->ID.Manufacturer.Name); flag_comma = 1; } if (hdr->ID.Manufacturer.Model) { if (flag_comma) fprintf(fid,",\n"); fprintf(fid,"\t\t\"Model\"\t: \"%s\"", hdr->ID.Manufacturer.Model); flag_comma = 1; } if (hdr->ID.Manufacturer.Version) { if (flag_comma) fprintf(fid,",\n"); fprintf(fid,"\t\t\"Version\"\t: \"%s\"", hdr->ID.Manufacturer.Version); flag_comma = 1; } if (hdr->ID.Manufacturer.SerialNumber) { if (flag_comma) fprintf(fid,",\n"); fprintf(fid,"\t\t\"SerialNumber\"\t: \"%s\"", hdr->ID.Manufacturer.SerialNumber); // no comma at the end because its the last element } fprintf(fid,"\n\t},\n"); // end-of-Manufacturer } fprintf(fid,"\t\"CHANNEL\"\t: ["); for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (k>0) fprintf(fid,","); fprintf(fid,"\n\t\t{\n"); fprintf(fid,"\t\t\"ChannelNumber\"\t: %i,\n", (int)k+1); fprintf(fid,"\t\t\"Label\"\t: \"%s\",\n", hc->Label); double fs = hdr->SampleRate * hc->SPR/hdr->SPR; if ((0.0 <= fs) && (fs < INFINITY)) fprintf(fid,"\t\t\"Samplingrate\"\t: %f,\n", fs); if ( hc->Transducer && strlen(hc->Transducer) ) fprintf(fid,"\t\t\"Transducer\"\t: \"%s\",\n", hc->Transducer); if (!isnan(hc->PhysMax)) fprintf(fid,"\t\t\"PhysicalMaximum\"\t: %g,\n", hc->PhysMax); if (!isnan(hc->PhysMin)) fprintf(fid,"\t\t\"PhysicalMinimum\"\t: %g,\n", hc->PhysMin); if (!isnan(hc->DigMax)) fprintf(fid,"\t\t\"DigitalMaximum\"\t: %f,\n", hc->DigMax); if (!isnan(hc->DigMin)) fprintf(fid,"\t\t\"DigitalMinimum\"\t: %f,\n", hc->DigMin); if (!isnan(hc->Cal)) fprintf(fid,"\t\t\"scaling\"\t: %g,\n", hc->Cal); if (!isnan(hc->Off)) fprintf(fid,"\t\t\"offset\"\t: %g,\n", hc->Off); if (!isnan(hc->TOffset)) fprintf(fid,"\t\t\"TimeDelay\"\t: %g,\n", hc->TOffset); uint8_t flag = (0 < hc->LowPass && hc->LowPassHighPass && hc->HighPassNotch && hc->NotchLowPass, flag & 0x06 ? ',' : ' '); if (flag & 0x02) fprintf(fid,"\t\t\t\"Highpass\"\t: %g%c\n",hc->HighPass, flag & 0x04 ? ',' : ' ' ); if (flag & 0x04) fprintf(fid,"\t\t\t\"Notch\"\t: %g\n",hc->Notch); fprintf(fid,"\n\t\t},\n"); } switch (hc->PhysDimCode & 0xffe0) { case 4256: // Volt if (!isnan(hc->Impedance)) fprintf(fid,"\t\t\"Impedance\"\t: %g,\n", hc->Impedance); break; case 4288: // Ohm if (!isnan(hc->fZ)) fprintf(fid,"\t\t\"fZ\"\t: %g,\n", hc->fZ); break; } fprintf(fid,"\t\t\"PhysicalUnit\"\t: \"%s\"", PhysDim3(hc->PhysDimCode)); // no comma at the end because its the last element fprintf(fid,"\n\t\t}"); // end-of-CHANNEL } fprintf(fid,"\n\t]"); // end-of-CHANNELS if (hdr->EVENT.N>0) { flag_comma = 0; fprintf(fid,",\n\t\"EVENT\"\t: ["); for (k = 0; k < hdr->EVENT.N; k++) { if ( hdr->EVENT.TYP[k] == 0 ) continue; if ( flag_comma ) fprintf(fid,","); fprintf(fid,"\n\t\t{\n"); fprintf(fid,"\t\t\"TYP\"\t: \"0x%04x\",\n", hdr->EVENT.TYP[k]); fprintf(fid,"\t\t\"POS\"\t: %f", hdr->EVENT.POS[k]/hdr->EVENT.SampleRate); if (hdr->EVENT.CHN && hdr->EVENT.DUR) { if (hdr->EVENT.CHN[k]) fprintf(fid,",\n\t\t\"CHN\"\t: %d", hdr->EVENT.CHN[k]); if (hdr->EVENT.TYP[k] != 0x7fff) fprintf(fid,",\n\t\t\"DUR\"\t: %f", hdr->EVENT.DUR[k]/hdr->EVENT.SampleRate); } if (hdr->EVENT.TimeStamp != NULL && hdr->EVENT.TimeStamp[k] != 0) { char buf[255]; snprintf_gdfdatetime(buf,sizeof(buf), hdr->EVENT.TimeStamp[k]); fprintf(fid,",\n\t\t\"TimeStamp\"\t: \"%s\"", buf); } if ((hdr->EVENT.TYP[k] == 0x7fff) && (hdr->TYPE==GDF)) { //fprintf(fid,"\t\t\"Description\"\t: [neds]\n"); // no comma at the end because its the last element //fprintf(fid,",\n\t\t\"Description\"\t: \"[sparse sample]\""); typeof(hdr->NS) chan = hdr->EVENT.CHN[k] - 1; double val = dur2val(hdr->EVENT.DUR[k], hdr->CHANNEL[chan].GDFTYP); val *= hdr->CHANNEL[chan].Cal; val += hdr->CHANNEL[chan].Off; if (isfinite(val)) fprintf(fid,",\n\t\t\"Value\"\t: %g", val); // no comma at the end because its the last element } else { const char *str = GetEventDescription(hdr,k); if (str != NULL) fprintf(fid,",\n\t\t\"Description\"\t: \"%s\"",str); // no comma at the end because its the last element } fprintf(fid,"\n\t\t}"); flag_comma = 1; } fprintf(fid,"\n\t]"); // end-of-EVENT } fprintf(fid,"\n}\n"); return (0); } /****************************************************************************/ /** HDR2ASCII **/ /** displaying header information **/ /****************************************************************************/ int hdr2ascii(HDRTYPE* hdr, FILE *fid, int VERBOSE) { CHANNEL_TYPE* cp; struct tm *T0; float age; if (VERBOSE==7) { char tmp[60]; snprintf_gdfdatetime(tmp, sizeof(tmp), hdr->T0); fprintf(fid,"\tStartOfRecording: %s\nbci2000: %p\n",tmp,hdr->AS.bci2000); return(0); } if (VERBOSE==-1) { return(fprintf_hdr2json(fid, hdr)); } if (VERBOSE>0) { /* demographic information */ fprintf(fid,"\n===========================================\n[FIXED HEADER]\n"); // fprintf(fid,"\nPID:\t|%s|\nPatient:\n",hdr->AS.PID); fprintf(fid, "Recording:\n\tID : %s\n",hdr->ID.Recording); fprintf(fid, "\tInstitution : %s\n",hdr->ID.Hospital); fprintf(fid, "\tTechnician : %s\t# default: localuser\n",hdr->ID.Technician); char tmp[60]; strncpy(tmp,(char*)&hdr->ID.Equipment,8); tmp[8] = 0; fprintf(fid, "\tEquipment : %s\n",tmp); if (VERBOSE_LEVEL>8) fprintf(fid, "\t %#.16"PRIx64"\n",(uint64_t)hdr->ID.Equipment); uint8_t k,IPv6=0; for (k=4; k<16; k++) IPv6 |= hdr->IPaddr[k]; if (IPv6) fprintf(fid, "\tIPv6 address : %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",hdr->IPaddr[0],hdr->IPaddr[1],hdr->IPaddr[2],hdr->IPaddr[3],hdr->IPaddr[4],hdr->IPaddr[5],hdr->IPaddr[6],hdr->IPaddr[7],hdr->IPaddr[8],hdr->IPaddr[9],hdr->IPaddr[10],hdr->IPaddr[11],hdr->IPaddr[12],hdr->IPaddr[13],hdr->IPaddr[14],hdr->IPaddr[15]); else fprintf(fid, "\tIPv4 address : %u.%u.%u.%u",hdr->IPaddr[0],hdr->IPaddr[1],hdr->IPaddr[2],hdr->IPaddr[3]); fprintf(fid,"\t # default:local host\nManufacturer:\n\tName : %s\n",hdr->ID.Manufacturer.Name); fprintf(fid, "\tModel : %s\n",hdr->ID.Manufacturer.Model); fprintf(fid, "\tVersion : %s\n",hdr->ID.Manufacturer.Version); fprintf(fid, "\tSerialNumber : %s\n",hdr->ID.Manufacturer.SerialNumber); fprintf(fid, "Patient:\n\tID : %s\n",hdr->Patient.Id); if (strlen(hdr->Patient.Name)) { fprintf(fid, "\tName : %s\n",hdr->Patient.Name); char Name[MAX_LENGTH_NAME+1]; strcpy(Name, hdr->Patient.Name); char *lastname = strtok(Name,"\x1f"); char *firstname = strtok(NULL,"\x1f"); char *secondlastname = strtok(NULL,"\x1f"); fprintf(fid,"\t\tLastname : %s\n",lastname); fprintf(fid,"\t\tFirstname : %s\n",firstname); fprintf(fid,"\t\tSecondLastName : %s\n",secondlastname); } if (hdr->Patient.Birthday>0) age = (hdr->T0 - hdr->Patient.Birthday)/ldexp(365.25,32); else age = NAN; if (hdr->Patient.Height) fprintf(fid,"\tHeight : %i cm\n",hdr->Patient.Height); if (hdr->Patient.Height) fprintf(stdout,"\tWeight : %i kg\n",hdr->Patient.Weight); const char *Gender[] = {"unknown","male","female","unknown"}; const char *EyeImpairment[] = {"unknown","no","yes","corrected"}; const char *HeartImpairment[] = {"unknown","no","yes","pacemaker"}; fprintf(fid,"\tGender : %s\n",Gender[hdr->Patient.Sex]); fprintf(fid,"\tEye Impairment : %s\n",EyeImpairment[hdr->Patient.Impairment.Visual]); fprintf(fid,"\tHeart Impairment: %s\n",HeartImpairment[hdr->Patient.Impairment.Heart]); if (hdr->Patient.Birthday) { snprintf_gdfdatetime(tmp, sizeof(tmp), hdr->T0); fprintf(fid,"\tAge : %4.1f years\n\tBirthday : (%.6f) %s ",age,ldexp(hdr->Patient.Birthday,-32),tmp); } else fprintf(fid,"\tAge : ----\n\tBirthday : unknown\n"); snprintf_gdfdatetime(tmp, sizeof(tmp), hdr->T0); fprintf(fid,"\tStartOfRecording: (%.6f) %s",ldexp(hdr->T0,-32),tmp); fprintf(fid,"\tTimezone : %+i min\n\n", hdr->tzmin); if (hdr->AS.bci2000 != NULL) { if (VERBOSE < 4) { size_t c = min(39,strcspn(hdr->AS.bci2000,"\xa\xd")); strncpy(tmp, hdr->AS.bci2000, c); tmp[c]=0; fprintf(fid,"BCI2000 [%i]\t\t: <%s...>\n",(int)strlen(hdr->AS.bci2000),tmp); } else { fprintf(fid,"BCI2000 [%i]:\n%s\n",(int)strlen(hdr->AS.bci2000),hdr->AS.bci2000); } } fprintf(fid,"bpb=%i\n",hdr->AS.bpb); fprintf(fid,"row-based=%i\n",hdr->FLAG.ROW_BASED_CHANNELS); fprintf(fid,"uncalib =%i\n",hdr->FLAG.UCAL); fprintf(fid,"OFdetect =%i\n",hdr->FLAG.OVERFLOWDETECTION); } if (VERBOSE>1) { /* display header information */ fprintf(fid,"FileName:\t%s\nType :\t%s\nVersion :\t%4.2f\nHeadLen :\t%i\n",hdr->FileName,GetFileTypeString(hdr->TYPE),hdr->VERSION,hdr->HeadLen); // fprintf(fid,"NoChannels:\t%i\nSPR:\t\t%i\nNRec:\t\t%Li\nDuration[s]:\t%u/%u\nFs:\t\t%f\n",hdr->NS,hdr->SPR,hdr->NRec,hdr->Dur[0],hdr->Dur[1],hdr->SampleRate); fprintf(fid,"NoChannels:\t%i\nSPR:\t\t%i\nNRec:\t\t%li\nFs:\t\t%f\n",hdr->NS,hdr->SPR,(long)hdr->NRec,hdr->SampleRate); fprintf(fid,"Events/Annotations:\t%i\nEvents/SampleRate:\t%f\n",hdr->EVENT.N,hdr->EVENT.SampleRate); } if (VERBOSE>2) { /* channel settings */ fprintf(fid,"\n[CHANNEL HEADER] %p",hdr->CHANNEL); fprintf(fid,"\nNo LeadId Label\tFs[Hz]\tSPR\tGDFTYP\tCal\tOff\tPhysDim\tPhysMax \tPhysMin \tDigMax \tDigMin \tHighPass\tLowPass \tNotch \tdelay [s]\tX\tY\tZ"); size_t k; #ifdef CHOLMOD_H typeof(hdr->NS) NS = hdr->NS; if (hdr->Calib) NS += hdr->Calib->ncol; for (k=0; kNS) cp = hdr->CHANNEL+k; else cp = hdr->rerefCHANNEL + k - hdr->NS; #else for (k=0; kNS; k++) { cp = hdr->CHANNEL+k; #endif const char *tmpstr = cp->Label; if (tmpstr==NULL || strlen(tmpstr)==0) tmpstr = LEAD_ID_TABLE[cp->LeadIdCode]; fprintf(fid,"\n#%02i: %3i %i %-17s\t%5f %5i", (int)k+1, cp->LeadIdCode, cp->bi8, tmpstr, cp->SPR*hdr->SampleRate/hdr->SPR, cp->SPR); if (cp->GDFTYP<20) fprintf(fid," %s ",gdftyp_string[cp->GDFTYP]); else if (cp->GDFTYP>511) fprintf(fid, " bit%i ", cp->GDFTYP-511); else if (cp->GDFTYP>255) fprintf(fid, " bit%i ", cp->GDFTYP-255); tmpstr = PhysDim3(cp->PhysDimCode); if (tmpstr==NULL) tmpstr="\0"; fprintf(fid,"%e %e %s\t%g\t%g\t%5f\t%5f\t%5f\t%5f\t%5f\t%5g\t%5f\t%5f\t%5f", cp->Cal, cp->Off, tmpstr, cp->PhysMax, cp->PhysMin, cp->DigMax, cp->DigMin,cp->HighPass,cp->LowPass,cp->Notch,cp->TOffset, cp->XYZ[0],cp->XYZ[1],cp->XYZ[2]); //fprintf(fid,"\t %3i", cp->SPR); } } if (VERBOSE>3) { /* channel settings */ fprintf(fid,"\n\n[EVENT TABLE %i] N=%i Fs=%f", (hdr->EVENT.TimeStamp!=NULL) + (hdr->EVENT.TYP!=NULL) + (hdr->EVENT.POS!=NULL) + (hdr->EVENT.CHN!=NULL) + (hdr->EVENT.DUR!=NULL), hdr->EVENT.N,hdr->EVENT.SampleRate); fprintf(fid,"\nNo\tTYP\tPOS\tCHN\tDUR/VAL\tDesc"); size_t k; for (k=0; kEVENT.N; k++) { fprintf(fid,"\n%5i\t0x%04x\t%d",(int)(k+1),hdr->EVENT.TYP[k],hdr->EVENT.POS[k]); if (hdr->EVENT.TimeStamp != NULL && hdr->EVENT.TimeStamp[k] != 0) { char buf[255]; snprintf_gdfdatetime(buf,sizeof(buf), hdr->EVENT.TimeStamp[k]); fprintf(fid,"\t%s",buf); } if (hdr->EVENT.TYP[k] == 0x7fff) fprintf(fid,"\t%d",hdr->EVENT.CHN[k]); else if (hdr->EVENT.DUR != NULL) fprintf(fid,"\t%d\t%5d",hdr->EVENT.CHN[k],hdr->EVENT.DUR[k]); if ((hdr->EVENT.TYP[k] == 0x7fff) && (hdr->TYPE==GDF)) { typeof(hdr->NS) chan = hdr->EVENT.CHN[k]-1; double val = dur2val(hdr->EVENT.DUR[k], hdr->CHANNEL[chan].GDFTYP); val *= hdr->CHANNEL[chan].Cal; val += hdr->CHANNEL[chan].Off; fprintf(fid, "\t%g %s\t## sparse sample", val, PhysDim3(hdr->CHANNEL[chan].PhysDimCode)); // no comma at the end because its the last element } else { const char *str = GetEventDescription(hdr,k); if (str) fprintf(fid,"\t\t%s",str); } } } if (VERBOSE>4) { const char* StatusString[] = {"Original (not overread)", "Confirmed", "Overread (not confirmed)", "unknown"}; #if (BIOSIG_VERSION >= 10500) if (hdr->SCP.Section7) { fprintf(stdout,"\n\n=== SCP Section 7: Global measurements ===\n"); fprintf(stdout,"\n\n (report of this section is not implemented yet \n"); } if (hdr->SCP.Section8) { struct tm t; t.tm_year = leu16p(hdr->SCP.Section8+1)-1900; t.tm_mon = hdr->SCP.Section8[3]-1; t.tm_mday = hdr->SCP.Section8[4]; t.tm_hour = hdr->SCP.Section8[5]; t.tm_min = hdr->SCP.Section8[6]; t.tm_sec = hdr->SCP.Section8[7]; uint8_t NumberOfStatements = hdr->SCP.Section8[8]; fprintf(stdout,"\n\n=== SCP Section 8: Storage of full text interpretive statements ===\n"); fprintf(stdout,"Report %04i-%02i-%02i %02ih%02im%02is (Status=%s) %i statements\n",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec,StatusString[min(hdr->SCP.Section8[0],3)], NumberOfStatements); uint32_t curSectPos = 9; uint8_t k; for (k=0; k < NumberOfStatements;k++) { if (curSectPos+3 > hdr->SCP.Section8Length) break; fprintf(stdout, "%s\n", (char*)(hdr->SCP.Section8+curSectPos+3)); curSectPos += 3+leu16p(hdr->SCP.Section8+curSectPos+1); } } if (hdr->SCP.Section9) { struct tm t; t.tm_year = leu16p(hdr->SCP.Section9+1)-1900; t.tm_mon = hdr->SCP.Section9[3]-1; t.tm_mday = hdr->SCP.Section9[4]; t.tm_hour = hdr->SCP.Section9[5]; t.tm_min = hdr->SCP.Section9[6]; t.tm_sec = hdr->SCP.Section9[7]; uint8_t NumberOfStatements = hdr->SCP.Section9[8]; fprintf(stdout,"\n\n=== SCP Section 9: Storing manufacturer specific interpretive statements and data related to the overreading trail ===\n"); fprintf(stdout,"Report %04i-%02i-%02i %02ih%02im%02is (Status=%s) %i statements\n",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec,StatusString[min(hdr->SCP.Section8[0],3)], NumberOfStatements); uint32_t curSectPos = 9; uint8_t k; for (k=0; k < NumberOfStatements;k++) { if (curSectPos+3 > hdr->SCP.Section9Length) break; fprintf(stdout, "%s\n", (char*)(hdr->SCP.Section9+curSectPos+3)); curSectPos += 3+leu16p(hdr->SCP.Section9+curSectPos+1); } } if (hdr->SCP.Section10) { fprintf(stdout,"\n\n=== SCP Section 10: Lead measurement block ===\n"); fprintf(stdout,"\n\n (report of this section is not implemented yet \n"); } if (hdr->SCP.Section11) { struct tm t; t.tm_year = leu16p(hdr->SCP.Section11+1)-1900; t.tm_mon = hdr->SCP.Section11[3]-1; t.tm_mday = hdr->SCP.Section11[4]; t.tm_hour = hdr->SCP.Section11[5]; t.tm_min = hdr->SCP.Section11[6]; t.tm_sec = hdr->SCP.Section11[7]; uint8_t NumberOfStatements = hdr->SCP.Section11[8]; fprintf(stdout,"\n\n=== SCP Section 11: Storage of the universal ECG interpretive statement codes ===\n"); fprintf(stdout,"Report %04i-%02i-%02i %02ih%02im%02is (Status=%s) %i statements\n",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec,StatusString[min(hdr->SCP.Section8[0],3)], NumberOfStatements); uint32_t curSectPos = 9; uint8_t k; for (k=0; k < NumberOfStatements;k++) { if (curSectPos+3 > hdr->SCP.Section11Length) break; fprintf(stdout, "%s\n", (char*)(hdr->SCP.Section11+curSectPos+3)); curSectPos += 3+leu16p(hdr->SCP.Section11+curSectPos+1); } } #else if (hdr->aECG && (hdr->TYPE==SCP_ECG)) { struct aecg* aECG = (struct aecg*)hdr->aECG; fprintf(stdout,"\nInstitution Number: %i\n",aECG->Section1.Tag14.INST_NUMBER); fprintf(stdout,"DepartmentNumber : %i\n",aECG->Section1.Tag14.DEPT_NUMBER); fprintf(stdout,"Device Id : %i\n",aECG->Section1.Tag14.DEVICE_ID); fprintf(stdout,"Device Type : %i\n",aECG->Section1.Tag14.DeviceType); fprintf(stdout,"Manufacture code : %i\n",aECG->Section1.Tag14.MANUF_CODE); fprintf(stdout,"MOD_DESC : %s\n",aECG->Section1.Tag14.MOD_DESC); fprintf(stdout,"Version : %i\n",aECG->Section1.Tag14.VERSION); fprintf(stdout,"ProtCompLevel : %i\n",aECG->Section1.Tag14.PROT_COMP_LEVEL); fprintf(stdout,"LangSuppCode : %i\n",aECG->Section1.Tag14.LANG_SUPP_CODE); fprintf(stdout,"ECG_CAP_DEV : %i\n",aECG->Section1.Tag14.ECG_CAP_DEV); fprintf(stdout,"Mains Frequency : %i\n",aECG->Section1.Tag14.MAINS_FREQ); /* fprintf(stdout,"ANAL_PROG_REV_NUM : %s\n",aECG->Section1.Tag14.ANAL_PROG_REV_NUM); fprintf(stdout,"SERIAL_NUMBER_ACQ_DEV: %s\n",aECG->Section1.Tag14.SERIAL_NUMBER_ACQ_DEV); fprintf(stdout,"ACQ_DEV_SYS_SW_ID : %i\n",aECG->Section1.Tag14.ACQ_DEV_SYS_SW_ID); fprintf(stdout,"ACQ_DEV_SCP_SW : %i\n",aECG->Section1.Tag14.ACQ_DEV_SCP_SW); */ fprintf(stdout,"ACQ_DEV_MANUF : %s\n",aECG->Section1.Tag14.ACQ_DEV_MANUF); fprintf(stdout,"Compression HUFFMAN : %i\n",aECG->FLAG.HUFFMAN); fprintf(stdout,"Compression REF-BEAT: %i\n",aECG->FLAG.REF_BEAT); fprintf(stdout,"Compression BIMODAL : %i\n",aECG->FLAG.BIMODAL); fprintf(stdout,"Compression DIFF : %i\n",aECG->FLAG.DIFF); if ((aECG->systolicBloodPressure > 0.0) || (aECG->diastolicBloodPressure > 0.0)) fprintf(stdout,"Blood pressure (systolic/diastolic) : %3.0f/%3.0f mmHg\n",aECG->systolicBloodPressure,aECG->diastolicBloodPressure); uint8_t k; if (aECG->Section8.NumberOfStatements>0) { fprintf(stdout,"\n\nReport %04i-%02i-%02i %02ih%02im%02is (Status=%s)\n",aECG->Section8.t.tm_year+1900,aECG->Section8.t.tm_mon+1,aECG->Section8.t.tm_mday,aECG->Section8.t.tm_hour,aECG->Section8.t.tm_min,aECG->Section8.t.tm_sec,StatusString[min(aECG->Section8.Confirmed,3)]); for (k=0; kSection8.NumberOfStatements;k++) { fprintf(stdout,"%s\n",aECG->Section8.Statements[k]); } } if ( aECG->Section11.NumberOfStatements > 0 ) { fprintf(stdout,"\n\nReport %04i-%02i-%02i %02ih%02im%02is (Status=%s)\n",aECG->Section11.t.tm_year+1900,aECG->Section11.t.tm_mon+1,aECG->Section11.t.tm_mday,aECG->Section11.t.tm_hour,aECG->Section11.t.tm_min,aECG->Section11.t.tm_sec,StatusString[min(aECG->Section11.Confirmed,3)]); for (k=0; kSection11.NumberOfStatements;k++) { fprintf(stdout,"%s\n",aECG->Section11.Statements[k]); } } fprintf(stdout,"\n\nSection9:\n%s\n\n",aECG->Section9.StartPtr); } #endif // BIOSIGVERSION < 10500 } fprintf(fid,"\n\n"); return(0); } /* end of HDR2ASCII */ /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ biosig-2.3.3/biosig4c++/extern0000777000175000017500000000000014105434233021656 2../biosig4matlab/docustar schloeglschloeglbiosig-2.3.3/biosig4c++/Makefile.in0000664000175000017500000013703614105434233017066 0ustar schloeglschloegl######## Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at https://biosig.sourceforge.io/ ### ############################################################## ##### Target: GNU/Linux # ## make && make install build and install libbiosig, but no other tools. # libbiosig is a prerequisite for building all the other tools below. # ## make save2gdf - makes converter ## make biosig_fhir - makes converter for fhir-binary template ## make install_save2gdf - installs converter ## make install_mma installs biosig's sload for Mathematica in $PREFIX/share/biosig/mathematica ## make install_mex installs mexbiosig for Matlab in $PREFIX/share/biosig/mex # ## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) ## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) ## make mexw32 - makes mexSLOAD.mexw32, mexSOPEN.mexw32 (requires that mingw32, gnumex libraries from Matlab/Win32) ## make mexw64 - makes mexSLOAD.mexw64, mexSOPEN.mexw64 (requires that mce-w32, gnumex libraries from Matlab/Win64) ## make mex - mex4o, mex4m, mexw32, mexw64 combined ## make biosig4java - makes Java interface (experimental) ## make biosig4php - makes PHP interface (experimental) ## make biosig4perl - makes perl interface (experimental) ## make biosig4ruby - makes ruby interface (experimental) ## make biosig4tcl - makes tcl/tk interface (experimental) ## ## make win32 and make win64 are obsolete. save2gdf.exe, and libbiosig.{a,dll} for windows can now be built ## with the mingw-cross-compiler environment (mxe.cc). ## git clone https://github.com/schloegl/mxe.git ## make biosig ## should do what you want. Please note, that win32mma does now also rely that libbiosig is built with MXE. ## Make sure that CROSS or CROSS64 is properly defined when running `make` ## ## ??? ## make sigviewer - makes sigviewer ##### Target: Win32 ## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw32 mex/mexSLOAD.mexw32 - requires MinGW32 and GNUMEX libraries from Matlab/Win32 ## make win32/sigviewer.exe - requires sources of SigViewer, and MinGW32 (mex: make suitesparse zlib qt ) ##### Target: Win64 ## make win64 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw64 mex/mexSLOAD.mexw64 - requires MCE-W64 and GNUMEX libraries from Matlab/Win64 ## make win64/sigviewer.exe - requires sources of SigViewer and MCE-W64, make suitesparse zlib qt ##### Target: MacOSX w/ homebrew ## make install_homebrew installs libbiosig and save2gdf # requires: brew tap homebrew/dupes # brew install libiconv ############################### # whether dynamic or static linking is used, can be controlled with # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically # LIBEXT = a #LIBEXT = so ############################### ### User-specified options: its likely you want to change this # settings for cross compiler: tested with MXE and mce-w64 with make suitesparse zlib qt ; CROSS = $(HOME)/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static ## local MXE ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = $(HOME)/src/mxe.master/usr/bin/i686-w64-mingw32.static endif ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = $(shell pwd)/../mxe/usr/bin/i686-w64-mingw32.static endif ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static endif CROSS64 = $(HOME)/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = $(HOME)/src/mxe.master/usr/bin/x86_64-w64-mingw32.static endif ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = $(HOME)/src/mxe.master/usr/bin/x86_64-w64-mingw32.static endif # settings for mex files MEX_OPTION = -largeArrayDims # turn on for 64 bit Matlab, otherwise empty # directory for sources of sigviewer PathToSigViewer = ../sigviewer PathToSigViewerWIN32 = ../sigviewer4win32 PathToSigViewerWIN64 = ../sigviewer4win64 CFLAGS += -pipe -fPIC -fno-builtin-memcmp -O2 -Wno-unused-result CFLAGS += -Wno-deprecated CFLAGS += -fvisibility=hidden prefix = @prefix@ exec_prefix ?= @prefix@ libdir = @libdir@ includedir = @includedir@ bindir = @bindir@ mandir = @mandir@ CFLAGS += -I$(includedir) CXXFLAGS += $(CFLAGS) ## TARGET dependencies ifeq (,$(TARGET)) CC ?= gcc CXX ?= g++ AR := ar rcs PKGCONF := pkg-config SHAREDLIB = -shared DLEXT = so else ifeq (intel,$(TARGET)) CC := icc CXX := icc LD := xild AR := xiar crs else PREFIX := $(subst /bin/,/,$(dir $(shell which $(TARGET)-gcc))) CC := $(TARGET)-gcc CXX := $(TARGET)-g++ LD := $(TARGET)-ld AR := $(TARGET)-ar rcs PKGCONF := $(TARGET)-pkg-config ifneq (,$(findstring mingw,$(TARGET))) ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o LDLIBS += -lssp LDLIBS += -liconv -lstdc++ -lws2_32 PKG_CONFIG_LIBS += -liconv -lws2_32 BINEXT = .exe DLEXT = dll endif endif SONAMEVERSION ?= 3 ### TODO: DLEXT does not work correctly on MXE/MINGW DLDIR = $(libdir) ifneq (,$(findstring Darwin, $(shell uname))) ## Homebrew: ## brew install gawk ## brew install gnu-tar ## brew install homebrew/dupes/libiconv ## brew install homebrew/science/suite-sparse ## LD = $(CXX) -shared CFLAGS += -I$(prefix)/include CFLAGS += -mmacosx-version-min=10.13 LDLIBS += -liconv -lstdc++ SHAREDLIB = -dylib -arch x86_64 #-macosx_version_min 10.13 LDFLAGS += -L$(prefix)/lib/ DLEXT = dylib FULLDLEXT = .dylib SONAME_PREFIX = -install_name # the last space character is crucial else ifneq (,$(findstring CYGWIN, $(shell uname))) ### TODO: check if this path is useful at all ### DLEXT = dll LD = $(CXX) LDLIBS += -liconv -lstdc++ FULLDLEXT = ${SONAMEVERSION}.dll SONAME_PREFIX = -Wl,-soname= else ifneq (,$(findstring MINGW, $(shell uname))) ### TODO: check if this path is useful at all ### ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o ## exclude conflicting definition of sopen from mingw's io.h CC = gcc CXX = g++ CFLAGS += -pipe -fPIC -D_REENTRANT -D=BUILD_DLL LD = $(CXX) FULLDLEXT = ${SONAMEVERSION}.dll SONAME_PREFIX = -Wl,-soname= LDLIBS += -lstdc++ LDLIBS += -liconv -lws2_32 LDFLAGS += -Wl,-subsystem,windows LDFLAGS += -L$(prefix)/lib/ DLDIR = $(bindir) else LD = $(CXX) ifneq (,$(findstring mingw,$(TARGET))) FULLDLEXT = ${SONAMEVERSION}.dll DLDIR = $(bindir) else FULLDLEXT = .so.${SONAMEVERSION} endif SONAME_PREFIX = -Wl,-soname= endif DEFINES_ALL = #-D=NDEBUG DEFINES += $(DEFINES_ALL) #DEFINES += -D=WITH_SON #DEFINES += -D=WITHOUT_SCP_DECODE #DEFINES += -D=WITH_TIMESTAMPEVENT #DEFINES += -D=WITH_TIMESTAMPCHANNEL ### Mingw,MXE, etc. must avoid name space conflict concerning SOPEN ### #DEFINES += -D=NO_OLDNAMES #DEFINES += -D=WITH_CURL DEFINES += -D=__4HAERTEL__ DEFINES += -D=WITH_FAMOS DEFINES += -D=WITH_FIFF DEFINES += -D=WITHOUT_NETWORK DEFINES += -D=WITH_SCP3 DEFINES += -D=WITH_FEF #DEFINES += -D=WITH_PDP ### DICOM: DCMTK or GDCM, or internal # WITH_DCMTK is already configured by autoconf # WITH_GDCM is experimental # WITH_DICOM (internal implementation) is experimental #DEFINES += -D=WITH_GDCM #DEFINES += -D=WITH_GSL #DEFINES += -D=WITH_EEPROBE DEFINES += -D=WITH_INTAN #DEFINES += -D=WITH_TDMS DEFINES += -D=WITH_ATF #DEFINES += -D=WITH_AVI #DEFINES += -D=WITH_RIFF #DEFINES += -D=WITH_WAV #DEFINES += -D=WITH_NEV DEFINES += -D=MAKE_EDFLIB ifeq (1,@HAVE_LIBZ@) LDLIBS += -lz endif ifeq (1,@HAVE_LIBPTHREAD@) LDLIBS += -lpthread endif ifeq (1,@HAVE_LIBCHOLMOD@) LDLIBS += -lcholmod ifeq (Darwin,$(shell uname)) ## homebrew requires this in addition to cholmod LDLIBS += -lsuitesparseconfig endif endif ifeq (1,@HAVE_LIBDCMTK@) DEFINES += -D=WITH_DCMTK LDLIBS += -ldcmdata -loflog -lofstd SOURCES += t210/sopen_dcmtk_read.cpp OBJECTS += sopen_dcmtk_read.o MinGWOBJECTS += win32/sopen_dcmtk_read.obj endif ifeq (1,@HAVE_LIBHDF5@) LDLIBS += -lhdf5 endif ifeq (1,@HAVE_LIBMATIO@) LDLIBS += -lmatio endif ifeq (1,@HAVE_LIBM@) LDLIBS += -lm endif ifeq (1,@HAVE_LIBTINYXML@) DEFINES += -D=WITH_LIBTINYXML LDLIBS += -ltinyxml endif ifeq (1,@HAVE_LIBTINYXML2@) DEFINES += -D=WITH_LIBTINYXML2 LDLIBS += -ltinyxml2 endif ifneq (,$(findstring WITH_GDCM, $(DEFINES))) INCPATH += -I$(wildcard /usr/include/gdcm-2*/) LDLIBS += -lgdcmCommon -lgdcmDSED -lgdcmMEXD -lgdcmMSFF -lgdcmDICT -lgdcmIOD endif ifneq (,$(findstring WITH_CURL, $(DEFINES))) LDLIBS += -lcurl endif ifneq (,$(findstring stack-protector, $(CFLAGS))) ifneq (,$(findstring CYGWIN, $(shell uname))) LDLIBS += -lssp endif ifneq (,$(findstring MINGW, $(shell uname))) LDLIBS += -lssp endif endif DELETE = rm -f COPY = cp -f DATA_DIR = data/ DATA_DIR_CFS = $(HOME)/L/data/test/cfs/ TEMP_DIR = test/ SED = sed TAR = tar VERBOSE := -V0 ########################################################## ## set Matlab and Octave variables ifeq (undefined,$(origin MATLABDIR)) ifeq (Darwin,$(shell uname)) MATLABDIR := $(shell find /Applications/MATLAB* -name bin -type d -depth 1 2>/dev/null | head -1) else MATLABDIR ?= $(shell find /usr/local/MATLAB* -maxdepth 2 -name bin -type d 2>/dev/null | head -1) endif endif ifeq (,$(MATLABDIR)) #$(warning MATLABDIR is not defined) else MEX = $(MATLABDIR)/mex MEX_EXT := $(shell $(MATLABDIR)/mexext) endif ########################################################## ########################################################## ## set variables for MinGW Crosscompiler: compile on linux binaries for windows ## PathToMinGW = $(dir $(CROSS))..$(nondir $(CROSS)) PathToMinGW64 = $(dir $(CROSS64))..$(nondir $(CROSS64)) MinGWCC = $(CROSS)-gcc MinGWCXX = $(CROSS)-g++ MinGWDEF = $(DEFINES) MinGWCFLAGS = -pipe -fPIC -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -Iwin32 -I$(PathToMinGW)/include/ MinGWLIBS = win32/libbiosig.a -L$(PathToMinGW)/lib/ $(LDLIBS) # static MinGWLINK = $(MinGWCXX) MinGW64CC = $(CROSS64)-gcc MinGW64CXX = $(CROSS64)-g++ MinGW64CFLAGS = -pipe -fPIC -O2 -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -Iwin64 -I$(PathToMinGW64)/include/ MinGW64LIBS = win64/libbiosig.a -L$(PathToMinGW64)/lib/ $(LDLIBS) # static MinGW64LINK = $(MinGW64CXX) ########################################################## # Versioning MAJOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MAJOR' biosig-dev.h)) MINOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MINOR' biosig-dev.h)) STEPPING := $(word 3, $(shell grep '\#define BIOSIG_PATCHLEVEL' biosig-dev.h)) BIOSIG_VERSION := @PACKAGE_VERSION@ TODAY := $(shell date +%Y%m%d) ####### Output directory OBJ = ./obj ####### Files SOURCES += biosig.c \ biosig2.c \ t210/sopen_cfs_read.c \ t210/sopen_heka_read.c \ t210/sopen_igor.c \ t210/sopen_rhd2000_read.c \ t210/sopen_scp_read.c \ t210/sopen_tdms_read.c \ t210/sopen_famos_read.c \ t210/sopen_abf_read.c \ t210/sopen_alpha_read.c \ t210/sopen_axg_read.c \ t210/sopen_cadwell_read.c \ t210/scp-decode.cpp \ t220/sopen_scp_write.c \ t220/crc4scp.c \ t230/sopen_hl7aecg.cpp \ t240/sopen_fef_read.c \ test0/sandbox.c \ xgethostname.c \ gdftime.c \ mdc_ecg_codes.c \ physicalunits.c \ save2gdf.c \ biosig2gdf.c \ biosig_client.c \ biosig_server.c ifneq (1,@HAVE_LIBTINYXML@) ## build with internal TinyXML when libtinyxml is not available SOURCES += XMLParser/tinyxml.cpp \ XMLParser/tinyxmlparser.cpp \ XMLParser/tinyxmlerror.cpp \ XMLParser/tinystr.cpp endif OBJECTS += \ biosig.o \ biosig2.o \ crc4scp.o \ sopen_cfs_read.o \ sopen_heka_read.o \ sopen_igor.o \ sopen_scp_read.o \ sopen_abf_read.o \ sopen_alpha_read.o \ sopen_axg_read.o \ sopen_cadwell_read.o \ sopen_scp_write.o \ sopen_hl7aecg.o \ gdftime.o \ mdc_ecg_codes.o \ physicalunits.o \ sandbox.o \ xgethostname.o MinGWOBJECTS = \ win32/biosig.obj \ win32/biosig2.obj \ win32/crc4scp.obj \ win32/getlogin.obj \ win32/sopen_cfs_read.obj \ win32/sopen_heka_read.obj \ win32/sopen_igor.obj \ win32/sopen_scp_read.obj \ win32/sopen_abf_read.obj \ win32/sopen_alpha_read.obj \ win32/sopen_axg_read.obj \ win32/sopen_cadwell_read.obj \ win32/sopen_scp_write.obj \ win32/sopen_hl7aecg.obj \ win32/gdftime.obj \ win32/physicalunits.obj \ win32/sandbox.obj \ win32/xgethostname.obj ifneq (,$(findstring WITH_FAMOS, $(DEFINES))) OBJECTS += sopen_famos_read.o endif ifneq (,$(findstring WITH_FAMOS, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_famos_read.obj endif ifneq (,$(findstring WITH_FEF, $(DEFINES))) -include t240/modules.mk SOURCES += $(patsubst %.c,t240/%.c,${ASN_MODULE_SOURCES}) OBJECTS += $(patsubst %.c,%.o,${ASN_MODULE_SOURCES}) OBJECTS += sopen_fef_read.o endif ifneq (,$(findstring WITH_FEF, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_fef_read.obj endif ifneq (,$(findstring WITH_INTAN, $(DEFINES))) OBJECTS += sopen_rhd2000_read.o endif ifneq (,$(findstring WITH_INTAN, $(MinGWDEF))) MinGWOBJECTS += sopen_rhd2000_read.obj endif ifneq (,$(findstring WITH_TDMS, $(DEFINES))) OBJECTS += sopen_tdms_read.o endif ifneq (,$(findstring WITH_TDMS, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_tdms_read.obj endif ifeq (,$(findstring WITHOUT_NETWORK, $(DEFINES))) OBJECTS += biosig-network.o endif ifeq (,$(findstring WITHOUT_NETWORK, $(MinGWDEF))) MinGWOBJECTS += win32/biosig-network.obj endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(DEFINES))) OBJECTS += scp-decode.o endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(MinGWDEF))) MinGWOBJECTS += win32/scp-decode.obj endif ifeq (,$(findstring WITH_LIBTINYXML, $(DEFINES))) ## build with TinyXML when libtinyxml is not available OBJECTS += tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o MinGWOBJECTS += win32/tinyxml.obj win32/tinyxmlparser.obj win32/tinyxmlerror.obj win32/tinystr.obj endif MinGW64OBJECTS = $(patsubst win32/%.obj, win64/%.obj, $(MinGWOBJECTS)) TARGET = save2gdf libbiosig.a LIB_OBJECTS = libbiosig.a libgdf.a libphysicalunits.a libbiosig.pc ifeq (,$(findstring mingw,$(TARGET))) LIB_OBJECTS += libbiosig.$(DLEXT) libgdf.$(DLEXT) libphysicalunits.$(DLEXT) endif BIN_OBJECTS = save2gdf${BINEXT} physicalunits${BINEXT} biosig_fhir${BINEXT} biosig2gdf${BINEXT} first: $(IO_H_FILE2) lib tools tools: $(BIN_OBJECTS) all: first #win32 win64 #sigviewer #win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer libbiosig lib: $(LIB_OBJECTS) ############################################################# # Compilation: Implicit, default rules ############################################################# CHKSUM_LIBB64 = 20106f0ba95cfd9c35a13c71206643e3fb3e46512df3e2efb2fdbf87116314b2 libb64-1.2.1.zip: curl -SLO https://downloads.sourceforge.net/project/libb64/libb64/libb64/libb64-1.2.1.zip test $(shell sha256sum libb64-1.2.1.zip | cut -d " " -f 1) = $(CHKSUM_LIBB64) || rm libb64-1.2.1.zip libb64-1.2.1/src/cencode.c: libb64-1.2.1.zip test $(shell sha256sum libb64-1.2.1.zip | cut -d " " -f 1) = $(CHKSUM_LIBB64) && unzip -o libb64-1.2.1.zip -d . touch $@ vpath %.c ./:./t210:./t220:./t240:./test0:./src:./mma vpath %.cpp ./:./t210:./t230:./XMLParser .SUFFIXES: .o .c .cpp .cc .cxx .C %.o: t240/%.c biosig-dev.h gdftime.h physicalunits.h $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" %.c: %.h biosig-dev.h gdftime.h physicalunits.h %.cpp: %.h biosig-dev.h gdftime.h physicalunits.h %.o: %.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o : win32/%.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: %.cpp biosig.h biosig-dev.h $(CXX) -c $(DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(INCPATH) -o "$@" "$<" sandbox.o: test0/sandbox.c biosig.h $(CXX) -c $(DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t240/%.c biosig-dev.h $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -I t240 -o "$@" "$<" win32/%.obj: %.c $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" win32/%.obj: %.cpp $(MinGWCXX) -c $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" win32/%.obj: win32/%.c $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -I win32 -o "$@" "$<" win64/%.obj: t240/%.c biosig-dev.h $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -I t240 -o "$@" "$<" win64/%.obj: %.c $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" win64/%.obj: %.cpp $(MinGW64CXX) -c $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" win64/%.obj: win32/%.c $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -I win32 -o "$@" "$<" ############################################################# # eventcodes and units: conversion from ascii to C code ############################################################# biosig.c: eventcodes.i eventcodegroups.i 11073-10102-AnnexB.i biosig.h biosig-dev.h physicalunits.c: units.i physicalunits.h eventcodes.i eventcodegroups.i : ../biosig4matlab/doc/eventcodes.txt gawk -f eventcodes.awk "$<" units.i : ../biosig4matlab/doc/units.csv awk -f units.awk "$<" > "$@" 11073-10102-AnnexB.i : ../biosig4matlab/doc//11073-10102-AnnexB.txt awk -f annotatedECG.awk "$<" > "$@" ############################################################# # Compilation: exceptions, explicit rules ############################################################# gdf.o: biosig.c biosig-dev.h eventcodes.i units.i 11073-10102-AnnexB.i $(CC) -c -D=ONLYGDF -D=WITHOUT_NETWORK $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" #getlogin_r.o: win32/getlogin_r.c # $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" ########### WIN32 ################## win32/gdf.obj: biosig.c biosig-dev.h $(MinGWCC) -c -D=ONLYGDF $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" $(PathToSigViewerWIN32): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win32 $(PathToSigViewerWIN32)/src/src.pro: $(PathToSigViewerWIN32) svn up -r 557 ../sigviewer4win32 win32/sigviewer.exe: win32/libbiosig.a win32/libbiosig.dll #-$(COPY) ../biosig/doc/eventcodes.txt $(PathToSigViewerWIN32)/src/ -$(DELETE) $(PathToSigViewerWIN32)/extern/include/*.h -$(COPY) biosig.h biosig2.h biosig-dev.h physicalunits.h $(PathToSigViewerWIN32)/extern/include -$(DELETE) $(PathToSigViewerWIN32)/extern/lib/lib* -$(COPY) win32/libbiosig.a $(PathToSigViewerWIN32)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 -lcholmod -lz -lcurl \2|' $(PathToSigViewerWIN32)/src/src.pro echo 0.5.2-v${BIOSIG_VERSION} > $(PathToSigViewerWIN32)/src/version.txt -(cd $(PathToSigViewerWIN32)/src; $(CROSS)-qmake; $(MAKE)) #-(cd $(PathToSigViewerWIN32); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; $(CROSS)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN32)/bin/release/sigviewer.exe win32/sigviewer.exe ########### WIN64 ################## win64/gdf.obj: biosig.c biosig-dev.h $(MinGW64CC) -c -D=ONLYGDF $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" $(PathToSigViewerWIN64): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win64 $(PathToSigViewerWIN64)/src/src.pro: $(PathToSigViewerWIN64) svn up -r 557 ../sigviewer4win64 win64/sigviewer.exe: win64/libbiosig.a win64/libbiosig.dll #-$(COPY) ../biosig/doc/eventcodes.txt $(PathToSigViewerWIN64)/src/ -$(DELETE) $(PathToSigViewerWIN64)/extern/include/*.h -$(COPY) biosig.h biosig2.h biosig-dev.h physicalunits.h $(PathToSigViewerWIN64)/extern/include -$(DELETE) $(PathToSigViewerWIN64)/extern/lib/lib* -$(COPY) win64/libbiosig.a $(PathToSigViewerWIN64)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 -lcholmod -lz -lcurl\2|' $(PathToSigViewerWIN64)/src/src.pro echo 0.5.2-v${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} > $(PathToSigViewerWIN64)/src/version.txt -(cd $(PathToSigViewerWIN64)/src; $(CROSS64)-qmake; $(MAKE)) #-(cd $(PathToSigViewerWIN64); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; $(CROSS64)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN64)/bin/release/sigviewer.exe win64/sigviewer.exe ############################################################# # other language bindings (on Linux) ############################################################# java: libbiosig $(MAKE) -C java perl: libbiosig $(MAKE) -C perl php: libbiosig $(MAKE) -C php ruby/biosig_wrap.c: ruby/biosig.i (cd ruby && swig -ruby biosig.i) ruby/Makefile: ruby/extconf.rb ruby -C ruby extconf.rb biosig4ruby ruby: libbiosig ruby/Makefile ruby/biosig_wrap.c $(MAKE) -C ruby tcl: libbiosig tcl/biosig.i $(MAKE) -C tcl ############################################################# # WIN32 - BUILD ############################################################# # libraries are built in MXE ## save2gdf, pdp2gdf win32/%.exe: %.c $(MinGWCXX) $(DEFINES) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32/physicalunits.exe: pu.c $(MinGWCXX) $(DEFINES) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32: mexw32 win32mma ############################################################# # WIN64 - BUILD ############################################################# # Libraries are build in MXE ## save2gdf, pdp2gdf, pu win64/%.exe: %.c $(MinGW64CXX) $(DEFINES) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64/physicalunits.exe: pu.c $(MinGW64CXX) $(DEFINES) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64: mexw64 ############################################################# # GNU/Linux - Shared Libaries ############################################################# ifeq (,$(findstring Darwin, $(shell uname))) # not on MacOSX %.${DLEXT}:%${FULLDLEXT} ln -sf "$<" "$@" endif libbiosig${FULLDLEXT}:$(OBJECTS) $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libgdf${FULLDLEXT}: gdf.o gdftime.o physicalunits.o getlogin.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libgdftime${FULLDLEXT}:gdftime.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libphysicalunits${FULLDLEXT}:physicalunits.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" ############################################################# # Static Libaries ############################################################# libphysicalunits.a: physicalunits.o -$(DELETE) "$@" $(AR) "$@" "$<" libphysicalunits.dll: physicalunits.o $(LD) $(LDFLAGS) -o libphysicalunits.dll -s -shared -fPIC "$<" $(LDLIBS) -Wl,-subsystem,windows,--output-def,libphysicalunits.def,--out-implib,libphysicalunits.dll.a #libgdftime.a: gdftime.o # -$(DELETE) "$@" # $(AR) "$@" "$<" #libgdftime.def: gdftime.o # $(CC) $(LDFLAGS) -o libgdftime.dll -s -shared -fPIC "$@" -Wl,--subsystem,windows,--output-def,libgdftime.def,--out-implib,libgdftime.dll.a libgdf.a: gdf.o getlogin.o gdftime.o physicalunits.o -$(DELETE) "$@" $(AR) "$@" gdf.o gdftime.o physicalunits.o libgdf.dll: gdf.o getlogin.o gdftime.o physicalunits.o $(LD) $(LDFLAGS) -s -shared -fPIC -o libgdf.dll gdf.o getlogin.o gdftime.o physicalunits.o $(LDLIBS) -Wl,-subsystem,windows,--output-def,libgdf.def,--out-implib,libgdf.dll.a libbiosig.a: $(OBJECTS) libbiosig.pc -$(DELETE) libbiosig.a $(AR) libbiosig.a $(OBJECTS) libbiosig.dll: $(OBJECTS) libbiosig.pc $(LD) $(LDFLAGS) -o libbiosig.dll -s -shared -fPIC $(OBJECTS) $(LDLIBS) -Wl,-subsystem,windows,--output-def,libbiosig.def,--out-implib,libbiosig.dll.a libbiosig.pc : mkdir -p pkgconfig echo "# Defines libbiosig.pc" > "$@" echo "prefix=$(prefix)" >>"$@" echo "exec_prefix=$(prefix)" >>"$@" echo "libdir=$(libdir)" >>"$@" echo "includedir=$(includedir)" >>"$@" echo >>"$@" echo "Name: libbiosig" >>"$@" echo "Description: Biosig library" >>"$@" echo "Version: ${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING}" >>"$@" echo "URL: http://biosig.sf.net" >>"$@" # echo "Requires: " >> "$@" echo "Requires.private: " >> "$@" echo "Cflags: $(DEFINES) " >> "$@" echo "Libs: -lbiosig $(PKG_CONFIG_LIBS)" >> "$@" echo "Libs.private: $(LDLIBS)" >> "$@" ## save2gdf, pdp2gdf %${BINEXT}: %.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) "$<" -L. -lbiosig -lstdc++ $(LDLIBS) -o "$@" physicalunits${BINEXT} : pu.c physicalunits.o $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o "$@" ifeq (1,@HAVE_LIBB64@) biosig_fhir${BINEXT}: biosig_fhir.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) "$<" -L. -lbiosig -lstdc++ -lb64 $(LDLIBS) -o "$@" else biosig_fhir${BINEXT}: biosig_fhir.c libb64-1.2.1/src/cencode.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Ilibb64-1.2.1/include/ "$<" libb64-1.2.1/src/cencode.c -L. -lbiosig -lstdc++ $(LDLIBS) -o "$@" endif bscs: biosig_client${BINEXT} biosig_server${BINEXT} sandbox.o biosig.o biosig_client${BINEXT}: biosig_client.c libbiosig.$(LIBEXT) biosig-network.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) biosig_client.c biosig-network.o libbiosig.$(LIBEXT) $(LDLIBS) -o "$@" biosig_server${BINEXT}: biosig_server.c libbiosig.$(LIBEXT) biosig-network.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) biosig_server.c biosig-network.o libbiosig.$(LIBEXT) $(LDLIBS) -o "$@" ############################################################# # MathLink interface to Mathematica ############################################################# mmaall: mma/sload.tm mma/sload.c $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS) -liconv" all mma : mma/biosig.exe mma/biosig.exe: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) mma win32mma: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS=$(CROSS) LDLIBS="$(LDLIBS) -liconv" win32mma win64mma: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS64=$(CROSS64) LDLIBS="$(LDLIBS) -liconv" win64mma ############################################################# # MEX-files for Octave and Matlab ############################################################# mex4o mex4m oct mex: MKOCTFILE="@MKOCTFILE@" $(MAKE) -C mex $@ mexw32 mexw64: CROSS=$(CROSS) CROSS64=$(CROSS64) $(MAKE) -C mex $@ mexbiosig: mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz biosig4octave: mex/biosig4octave-$(BIOSIG_VERSION).src.tar.gz mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz: mex/*.cpp $(eval $@_TMP := $(shell mktemp -d /tmp/biosig.XXXXXX)/mexbiosig-$(BIOSIG_VERSION)) echo "$($@_TMP) generated"; $(shell mkdir -p $($@_TMP)/doc/) $(shell mkdir -p $($@_TMP)/inst/) $(shell mkdir -p $($@_TMP)/src/) cp mex/README $($@_TMP)/doc/ $(SED) -e 's#^Version.*$$#Version: $(BIOSIG_VERSION)#g' -e 's#^Date.*$$#Date: '$(shell date +%Y-%m-%d)'#g' mex/DESCRIPTION > $($@_TMP)/DESCRIPTION cp ../COPYING $($@_TMP)/ cp mex/*.cpp mex/Makefile $($@_TMP)/src/ ### TODO #touch $($@_TMP)/src/mex{SOPEN,SLOAD,SSAVE}.m $(TAR) -czf "$@" $($@_TMP) -rm -rf $(shell dirname $($@_TMP) ) (cd mex && ln -sf mexbiosig-$(BIOSIG_VERSION).src.tar.gz mexbiosig.src.tar.gz) echo "### In order to publish release, run ### " echo "# cp "$@" ~/L/public_html/biosig/prereleases/" mex/biosig4octave-$(BIOSIG_VERSION).src.tar.gz: mex/*.cpp $(eval $@_TMP := $(shell mktemp -d /tmp/biosig.XXXXXX)/biosig4octave-$(BIOSIG_VERSION)) echo "$($@_TMP) generated"; $(shell mkdir -p $($@_TMP)/doc/) $(shell mkdir -p $($@_TMP)/inst/) $(shell mkdir -p $($@_TMP)/src/) cp mex/README $($@_TMP)/doc/ $(SED) -e 's#^Name.*$$#Name: biosig#g' -e '/^Title/ s#mexBiosig#Biosig#g' -e 's#^Version.*$$#Version: $(BIOSIG_VERSION)#g' -e 's#^Date.*$$#Date: '$(shell date +%Y-%m-%d)'#g' mex/DESCRIPTION > $($@_TMP)/DESCRIPTION cp ../COPYING ../CITATION $($@_TMP)/ cp mex/*.cpp mex/Makefile $($@_TMP)/src/ cp -r ../biosig4matlab/* $($@_TMP)/inst/ rm $($@_TMP)/inst/t300_FeatureExtraction/hurst.m # is part of Octave Signal package -rm -r $($@_TMP)/inst/maybe-missing ### TODO #touch $($@_TMP)/src/mex{SOPEN,SLOAD,SSAVE}.m $(TAR) -czf "$@" $($@_TMP) -rm -rf $(shell dirname $($@_TMP) ) (cd mex && ln -sf biosig4octave-$(BIOSIG_VERSION).src.tar.gz biosig4octave.src.tar.gz) echo "### In order to publish release, run ### " echo "# cp "$@" ~/L/public_html/biosig/prereleases/" ############################################################# # R/sload ############################################################# R: R/sload.$(DLEXT) R/sload.$(DLEXT): R/sload.c libbiosig.$(DLEXT) $(MAKE) -C R ############################################################# # SigViewer ############################################################# sigviewer: $(PathToSigViewer)/bin/sigviewer $(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer-$(TODAY) ln -sf sigviewer-$(TODAY) bin/sigviewer $(PathToSigViewer): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer $(PathToSigViewer)/src/src.pro: $(PathToSigViewer) svn up -r 557 ../sigviewer $(PathToSigViewer)/bin/sigviewer: libbiosig.$(LIBEXT) biosig-dev.h biosig.h -$(DELETE) $(PathToSigViewer)/extern/include/* -$(COPY) biosig-dev.h biosig.h biosig2.h physicalunits.h $(PathToSigViewer)/extern/include -$(DELETE) $(PathToSigViewer)/extern/lib/lib* -$(COPY) libbiosig.a $(PathToSigViewer)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 $(LDLIBS) \2|' $(PathToSigViewer)/src/src.pro echo 0.5.2-v${BIOSIG_VERSION} > $(PathToSigViewer)/src/version.txt (cd $(PathToSigViewer)/src; qmake; $(MAKE);) #-(cd $(PathToSigViewer); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; qmake; $(MAKE);) -$(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer docs: docs/save2gdf.txt docs/mexSLOAD.txt asciidoc -d manpage docs/save2gdf.txt asciidoc -d manpage docs/mexSLOAD.txt # for backward compatibility save2scp: save2gdf save2aecg: save2gdf ############################################################# # APPLICATIONS: TTL2TRIG, FLOWMON ############################################################# ### TTL2TRIG ttltrig: bin/ttltrig bin/ttl2trig : src/ttl2trig.c gdf.o gdftime.o physicalunits.o mkdir -p ./bin $(CC) -D=WITH_BIOSIG $(DEFINE) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -Wall -Wextra -lasound $(LDLIBS) -o "$@" ### FLOWMON flowmon.o: src/flowmon2.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) -o "$@" "$<" flowmon: bin/flowmon bin/flowmon: flowmon.o gdf.o gdftime.o physicalunits.o mkdir -p ./bin $(CC) $(LDFLAGS) $^ $(LDLIBS) -o "$@" ############################################################# # INSTALL and DE-INSTALL ############################################################# .PHONY: clean install install-strip install_libbiosig remove install_sigviewer asc bin testscp testhl7 testbin test test6 zip clean: -$(DELETE) *~ -$(DELETE) *.a -$(DELETE) *.def -$(DELETE) *.dll -$(DELETE) *.dll.a -$(DELETE) *.i -$(DELETE) *.o -$(DELETE) *.so *.dylib -$(DELETE) *.so.* -$(DELETE) *.oct -$(DELETE) libbiosig.pc -$(DELETE) $(TEMP_DIR)t1.* -$(DELETE) win32/*.exe win32/*.o* win32/*.lib win32/*.a -$(DELETE) win64/*.exe win64/*.o* win64/*.lib win64/*.a -$(DELETE) t240/*.o* -$(DELETE) t240/libcnsfef.a -$(DELETE) libbiosig.* libbiosig${SONAMEVERSION}.* -$(DELETE) pdp2gdf save2gdf physicalunits biosig_fhir biosig2gdf -$(DELETE) mma/biosig.exe mma/*/biosig.exe -$(MAKE) -C java clean -$(MAKE) -C mex clean -$(DELETE) mex/mexbiosig*.src.tar.gz -$(DELETE) mex/biosig4octave*.src.tar.gz -$(MAKE) -C mma clean -$(MAKE) -C php clean -$(MAKE) -C perl clean -$(MAKE) -C R clean -$(MAKE) -C ruby clean -$(MAKE) -C tcl clean install_sigviewer: sigviewer install $(PathToSigViewer)/bin/release/sigviewer $(DESTDIR)$(bindir) install_ttl2trig: bin/ttl2trig install bin/ttl2trig $(DESTDIR)$(bindir) install_headers: biosig-dev.h biosig.h biosig2.h gdftime.h physicalunits.h install -d $(DESTDIR)$(includedir) install $? $(DESTDIR)$(includedir) install_libbiosig: install_libbiosig.$(DLEXT) install_libbiosig.a install_libbiosig.a: libbiosig.a libphysicalunits.a libbiosig.pc install -d $(DESTDIR)$(libdir)/pkgconfig/ install libbiosig.a $(DESTDIR)$(libdir) install libphysicalunits.a $(DESTDIR)$(libdir) install libbiosig.pc $(DESTDIR)$(libdir)/pkgconfig/ install_libbiosig.$(DLEXT): libbiosig.$(DLEXT) install -d $(DESTDIR)$(DLDIR)/pkgconfig/ install libbiosig.$(DLEXT) $(DESTDIR)$(DLDIR)/libbiosig$(FULLDLEXT) ifneq (Darwin,$(shell uname)) cd $(DESTDIR)$(DLDIR) && ln -sf libbiosig$(FULLDLEXT) libbiosig.$(DLEXT) endif -ldconfig install: install_libbiosig.$(DLEXT) install_libbiosig.a install_headers install_tools install-strip: install -strip -x $(DESTDIR)$(libdir)/libbiosig.a -strip -x $(DESTDIR)$(libdir)/libphysicalunits.a -strip -x $(DESTDIR)$(libdir)/libbiosig$(FULLDLEXT) install_tools: tools doc/save2gdf.1 install -d $(DESTDIR)$(bindir) install ${BIN_OBJECTS} $(DESTDIR)$(bindir) install heka2itx $(DESTDIR)$(bindir) install rec2bin $(DESTDIR)$(bindir) install bin2rec $(DESTDIR)$(bindir) install save2aecg $(DESTDIR)$(bindir) install save2scp $(DESTDIR)$(bindir) mkdir -p $(DESTDIR)$(mandir)/man1 install doc/*.1 $(DESTDIR)$(mandir)/man1 #install libbiosig.man $(mandir) #$(MAKE) install_sigviewer #$(MAKE) install_octave uninstall_tools: ${RM} $(addprefix $(DESTDIR)$(bindir)/,$(BIN_OBJECTS)) ${RM} $(DESTDIR)$(bindir)/{heka2itx,bin2rec,rec2bin,save2aecg,save2scp} ${RM} $(addprefix $(DESTDIR)$(mandir)/man1/,$(addsuffix .1,$(BIN_OBJECTS))) ${RM} $(DESTDIR)$(mandir)/man1/{heka2itx,bin2rec,rec2bin,save2aecg,save2scp}.1 ### Install mexbiosig for Octave install_mexbiosig install_octave: mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz @OCTAVE@ --no-gui --eval "pkg install $<" uninstall_mexbiosig: -@OCTAVE@ --no-gui --eval "pkg uninstall mexbiosig" ### Install mexbiosig for Matlab and Octave install_mex: $(MAKE) -C mex install uninstall_mex: $(MAKE) -C mex uninstall uninstall remove: uninstall_mexbiosig uninstall_tools -$(DELETE) $(DESTDIR)$(bindir)/ttl2trig #-$(DELETE) $(DESTDIR)$(bindir)/rec2bin #-$(DELETE) $(DESTDIR)$(bindir)/bin2rec -$(DELETE) $(DESTDIR)$(bindir)/sigviewer -$(DELETE) $(DESTDIR)$(bindir)/eventcodes.txt -$(DELETE) $(DESTDIR)$(includedir)/biosig.h -$(DELETE) $(DESTDIR)$(includedir)/biosig-dev.h -$(DELETE) $(DESTDIR)$(includedir)/biosig2.h -$(DELETE) $(DESTDIR)$(includedir)/gdftime.h -$(DELETE) $(DESTDIR)$(includedir)/physicalunits.h -$(DELETE) $(DESTDIR)$(libdir)/libbiosig.* -$(DELETE) $(DESTDIR)$(libdir)/libbiosig${SONAMEVERSION}.* -$(DELETE) $(DESTDIR)$(libdir)/libphysicalunits.* -$(DELETE) $(DESTDIR)$(libdir)/pkgconfig/libbiosig.pc -ldconfig ############################################################# # Testing ############################################################# testtms: $(DATA_DIR)t1.scp # ./save2gdf -V8 ~/data/test/tms32/small_test.float32.log ./save2gdf -f=TMSi $(DATA_DIR)t1.scp $(TEMP_DIR)t2.log cat $(TEMP_DIR)t2.log fetchdata: $(TEMP_DIR)Osas2002plusQRS.edf $(DATA_DIR)Newtest17-2048.bdf $(TEMP_DIR)SC4001EC-Hypnogram.edf $(TEMP_DIR)scp/redred/PFE103.scp: # scp example data sets #wget -q -P$(DATA_DIR) http://www.openecg.net/ECGsamples.zip #wget -q -P$(DATA_DIR) http://www.openecg.net/ECGsamplesc.zip unzip -u $(DATA_DIR)ECGsamples.zip "scp*.zip" -d $(TEMP_DIR) unzip -u $(DATA_DIR)ECGsamplesc.zip "scp*.zip" -d $(TEMP_DIR) mkdir -p $(TEMP_DIR)scp/high mkdir -p $(TEMP_DIR)scp/highc mkdir -p $(TEMP_DIR)scp/redred mkdir -p $(TEMP_DIR)scp/redredc unzip -u $(TEMP_DIR)scp_high.zip -d $(TEMP_DIR)scp/high unzip -u $(TEMP_DIR)scp_highc.zip -d $(TEMP_DIR)scp/highc unzip -u $(TEMP_DIR)scp_redred.zip -d $(TEMP_DIR)scp/redred unzip -u $(TEMP_DIR)scp_redredc.zip -d $(TEMP_DIR)scp/redredc rm -rf $(TEMP_DIR)ECGsamples*.zip rm -rf $(TEMP_DIR)scp*.zip $(DATA_DIR)t1.scp: $(TEMP_DIR)scp/redred/PFE103.scp $(COPY) "$<" "$@" touch "$@" #"$(DATA_DIR)aECG Release 1 Schema and Example.zip": $(DATA_DIR)2003-12\ Schema/example/Example\ aECG.xml: # HL7aECG example data set wget -q -P$(DATA_DIR) https://www.hl7.org/documentcenter/public/wg/rcrim/annecg/aECG%20Release%201%20Schema%20and%20Example.zip unzip -u $(DATA_DIR)"aECG Release 1 Schema and Example.zip" -d $(DATA_DIR) $(TEMP_DIR)t1.hl7: $(DATA_DIR)2003-12\ Schema/example/Example\ aECG.xml $(COPY) "$<" "$@" #rm -rf "$(TEMP_DIR)aECG Release 1 Schema and Example.zip" #rm -rf "$(TEMP_DIR)2003-12 Schema" $(TEMP_DIR)Osas2002plusQRS.edf: # EDF+ example data set wget -q -P$(TEMP_DIR) http://www.edfplus.info/downloads/files/osas.zip unzip -u "$(TEMP_DIR)osas.zip" -d $(TEMP_DIR) $(TEMP_DIR)SC4001EC-Hypnogram.edf: wget -q -P$(TEMP_DIR) https://www.physionet.org/files/sleep-edfx/1.0.0/sleep-cassette/SC4001EC-Hypnogram.edf $(DATA_DIR)t1.edf: $(TEMP_DIR)Osas2002plusQRS.edf $(COPY) "$<" "$@" touch "$@" asc: save2gdf ./save2gdf -f=ASCII t0.xxx $(TEMP_DIR)t1.asc bin: save2gdf ./save2gdf -f=BIN t0.xxx $(TEMP_DIR)t1.bin testjson: save2gdf $(DATA_DIR)t1.edf ./save2gdf -JSON t0.xxx |tee $(TEMP_DIR)t1.xxx.json ./save2gdf -JSON $(TEMP_DIR)t1.edf |tee $(TEMP_DIR)t1.edf.json testbin: save2gdf $(DATA_DIR)t1.edf ./save2gdf -f=BIN $(DATA_DIR)t1.edf $(TEMP_DIR)t1.hdr ./save2gdf -f=BIN $(TEMP_DIR)t1.hdr $(TEMP_DIR)t2.hdr ./save2gdf -f=GDF $(TEMP_DIR)t2.hdr $(TEMP_DIR)t2.gdf testedf: save2gdf $(TEMP_DIR)Osas2002plusQRS.edf $(TEMP_DIR)SC4001EC-Hypnogram.edf ./save2gdf -f=GDF $(TEMP_DIR)Osas2002plusQRS.edf $(TEMP_DIR)Osas2002plusQRS.gdf ./save2gdf -JSON $(TEMP_DIR)Osas2002plusQRS.edf | json_pp ./save2gdf -JSON $(TEMP_DIR)SC4001EC-Hypnogram.edf | json_pp testscp: $(DATA_DIR)t1.scp save2gdf # test converting SCP data ./save2gdf -f=HL7 "$<" $(TEMP_DIR)t1.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.hl7 $(TEMP_DIR)t1.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.hl7.gdf.scp $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7.scp ./save2gdf -f=GDF "$<" $(TEMP_DIR)t1.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf $(TEMP_DIR)t1.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.hl7.scp $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf.scp testscp2: $(DATA_DIR)t1.scp find test/scp -iname '*.scp' -exec ./save2gdf -V0 {} /dev/null \; testscp3: $(DATA_DIR)t1.scp find test/scp -iname '*.scp' -exec ./save2gdf -f=SCP3 -V0 {} {}.scp3 \; testhl7: $(TEMP_DIR)t1.hl7 save2gdf # test converting HL7aECG data ./save2gdf -f=GDF "$<" $(TEMP_DIR)t1.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf $(TEMP_DIR)t1.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf.scp.hl7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf.hl7 ./save2gdf -f=SCP "$<" $(TEMP_DIR)t1.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp $(TEMP_DIR)t1.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp.gdf.hl7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp.hl7 test: $(DATA_DIR)t1.scp save2scp save2aecg save2gdf # biosig4python # includes test for on-the-fly compression and decompression ./save2gdf -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.gdf ./save2gdf -f=SCP -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.scp ./save2gdf -f=HL7 -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.hl7 ./save2gdf $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.gdf ./save2gdf $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.gdf ./save2gdf $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.scp ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.scp ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.hl7 ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.hl7 ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.hl7 # python test0/test.py ./biosig2gdf $(DATA_DIR)t1.scp | md5sum zip: $(DATA_DIR)t1.scp save2gdf # test for on-the-fly compression and decompression # on-the-fly compression of output file ./save2gdf -z -f=GDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.gdf ./save2gdf -z -f=GDF1 $(DATA_DIR)t1.scp $(TEMP_DIR)t1.gd1 ./save2gdf -z -f=EDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.edf ./save2gdf -z -f=BDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.bdf ./save2gdf -z -f=SCP $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp ./save2gdf -z -f=CFWB $(DATA_DIR)t1.scp $(TEMP_DIR)t1.cfw ./save2gdf -z -f=MFER $(DATA_DIR)t1.scp $(TEMP_DIR)t1.mwf ./save2gdf -z -f=HL7 $(DATA_DIR)t1.scp $(TEMP_DIR)t1.hl7 gzip -c $(DATA_DIR)t1.scp >$(TEMP_DIR)t1.scp.gz # on-the-fly decompression of input file ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.hl7 ./save2gdf -f=MFER $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.mwf ./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.cfw test6: $(DATA_DIR)t1.scp save2gdf $(COPY) $(DATA_DIR)t1.scp $(TEMP_DIR)t0.xxx #test7: $(DATA_DIR)t1.edf save2gdf #$(COPY) $(DATA_DIR)t1.edf $(TEMP_DIR)t0.xxx ./save2gdf -z -f=GDF1 $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.gd1 ./save2gdf -z -f=GDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.gdf ./save2gdf -z -f=EDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.edf ./save2gdf -z -f=BDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.bdf ./save2gdf -z -f=SCP $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.hl7 # -z not supported for HL7 gzip -f $(TEMP_DIR)t1.hl7 ./save2gdf -z -f=CFWB $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.cfw ./save2gdf -z -f=MFER $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.mwf ./save2gdf -f=BVA $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.bva ./save2gdf -f=GDF1 $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.hl7 ./save2gdf -f=GDF1 $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.hl7 $(DATA_DIR)Newtest17-2048.bdf : $(DATA_DIR)BDFtestfiles.zip unzip -u "$<" -d $(DATA_DIR) testbdf : $(DATA_DIR)Newtest17-2048.bdf ./save2gdf -V4 "$<" | awk '/(NoChannels|NRec|Fs|Events\/Annotations):/ { print $$2 } ' testpybdf : $(DATA_DIR)Newtest17-2048.bdf $(PYTHON) python/demo2.py $(PYTHON) python/demo2.py $(DATA_DIR)*-256.bdf $(PYTHON) python/example.py $(DATA_DIR)*-256.bdf 256 $(PYTHON) python/example.py $(DATA_DIR)*-2048.bdf 2048 $(DATA_DIR)BDFtestfiles.zip : wget -P$(DATA_DIR) http://www.biosemi.com/download/BDFtestfiles.zip .PHONY: stat stat: @echo 'TODO/FIXME: '; @grep -ri '\bTODO\b' *.c *.h *.i t210/*.c t210/*.h |grep -v '\.svn' |wc -l; @grep -ri '\bFIXME\b' *.c *.h *.i t210/*.c t210/*.h |grep -v '\.svn' |wc -l; test_physicalunits : units.i physicalunits.c physicalunits.h gcc -D=TEST_PHYSDIMTABLE_PERFORMANCE -D=WITH_PTHREAD physicalunits.c -o test_physicalunits ./test_physicalunits @echo '--- end of test_physicalunits ---' testcfs : $(DATA_DIR_CFS) save2gdf -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/Actions.CFS -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/example.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/Leak.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/NAME_0AA.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/SCANexam.CFS -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/TEST.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/TRIAL0AA.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)100118s1AB.dat -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)100121s1AF.dat -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.000.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.001.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.002.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.LAST.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)/1617K2AA.DAT biosig-2.3.3/biosig4c++/eventcodegroups.i0000664000175000017500000000276214105434245020407 0ustar schloeglschloegl#if 0 ### This file is autogenerated - Do not modify it !!! ### ### Table of event codes. # This table is also part of the specification of # GDF v2.x http://arxiv.org/abs/cs.DB/0608052 and # GDF v1.x http://pub.ist.ac.at/~schloegl/matlab/eeg/gdf4/TR_GDF.pdf # and part of the BioSig project http://biosig.sf.net/ # Copyright (C) 2004-2015 Alois Schloegl # # BioSig 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 3 of the License, or (at your option) any later version. #endif { 0x0100, "EEG artifacts" }, { 0x0110, "EEG patterns" }, { 0x0120, "Stimulus for Evoked potentials" }, { 0x0130, "Stimulus for Steady State Evoked potentials" }, { 0x0140, "Response code" }, { 0x0200, "Neural activity, patch clamp" }, { 0x0200, "Neural spikes, and spike trains" }, { 0x0210, "miniature post-synaptic events" }, { 0x0300, "BCI: Trigger, cues, classlabels" }, { 0x0400, "Respiratory Events" }, { 0x0410, "Sleep stages according to Rechtschaffen&Kales and AASM'07" }, { 0x0420, "Sleep" }, { 0x0430, "Eye movements" }, { 0x0440, "muscle activity (for checking on EEG artifacts)" }, { 0x0500, "ECG events" }, { 0x0580, "ergometric events " }, { 0x1000, "neural spikes " }, { 0x2000, "reserved for ECG events (see HL7 10102 Annotated ECG)" }, { 0x0000, "user specific events" }, { 0x4000, "up to 4096 different stimuli" }, { 0x7f00, "special codes" }, biosig-2.3.3/biosig4c++/ruby/0000775000175000017500000000000014105434245015773 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/ruby/Makefile.in0000664000175000017500000000106314105434233020035 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2017 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Ruby interface is available here # http://www.swig.org/Doc1.3/Ruby.html all: $(error support for biosig on ruby is not ready yet) swig -c++ -ruby biosig.i ruby extconf.rb $(MAKE) clean: -rm *.cxx -rm *.o -rm *.pm -rm *.so biosig-2.3.3/biosig4c++/ruby/extconf.rb0000664000175000017500000000041114105434233017757 0ustar schloeglschloegl# Loads mkmf which is used to make makefiles for Ruby extensions require 'mkmf' # Give it a name extension_name = 'biosig' # The destination dir_config(extension_name, "..", ".." ) $LDFLAGS='-lbiosig -lz -lcholmod' # Do the work create_makefile(extension_name) biosig-2.3.3/biosig4c++/ruby/Makefile0000664000175000017500000000106314105434245017433 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2017 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Ruby interface is available here # http://www.swig.org/Doc1.3/Ruby.html all: $(error support for biosig on ruby is not ready yet) swig -c++ -ruby biosig.i ruby extconf.rb $(MAKE) clean: -rm *.cxx -rm *.o -rm *.pm -rm *.so biosig-2.3.3/biosig4c++/ruby/install.sh0000664000175000017500000000030614105434233017771 0ustar schloeglschloegl#!/bin/sh # $Id$ # Copyright (C) 2012 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ swig -ruby biosig.i ruby extconf.rb make biosig-2.3.3/biosig4c++/ruby/test.rb0000775000175000017500000000040714105434233017300 0ustar schloeglschloegl#!/usr/bin/ruby -- # $Id$ # Copyright (C) 2012 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ require 'biosig' print Biosig.display_header('/home/as/data/test/BDF/sample_bdf_plus_file.bdf') biosig-2.3.3/biosig4c++/ruby/biosig.i0000664000175000017500000002547514105434233017433 0ustar schloeglschloegl/* % % $Id$ % Copyright (C) 2008,2009,2012 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ // swig.i %module biosig %{ #include "../biosig.h" %} %include typedef int64_t gdf_time; /* gdf time is represented in 64 bits */ typedef int64_t nrec_t; /* type for number of records */ /* list of file formats */ enum FileFormat { noFile, unknown, ABF, ACQ, ACR_NEMA, AIFC, AIFF, AINF, alpha, ARFF, ASCII_IBI, ASCII, AU, ASF, ATES, ATF, AVI, Axona, BCI2000, BDF, BESA, BIN, BKR, BLSC, BMP, BNI, BSCS, BrainVision, BrainVisionVAmp, BrainVisionMarker, BZ2, CDF, CFS, CFWB, CNT, CTF, DICOM, DEMG, EBS, EDF, EEG1100, EEProbe, EEProbe2, EEProbeAvr, EGI, EGIS, ELF, EMBLA, EMSA, ePrime, ET_MEG, ETG4000, EVENT, EXIF, FAMOS, FEF, FITS, FLAC, GDF, GDF1, GIF, GTF, GZIP, HDF, HL7aECG, HEKA, ISHNE, ITX, JPEG, JSON, Lexicor, Matlab, MFER, MIDI, MIT, MM, MSI, MSVCLIB, MS_LNK, native, NeuroLoggerHEX, NetCDF, NEURON, NEV, NEX1, NIFTI, OGG, OpenXDF, PBMA, PBMN, PDF, PDP, Persyst, PGMA, PGMB, PLEXON, PNG, PNM, POLY5, PPMA, PPMB, PS, RDF, RIFF, SASXPT, SCP_ECG, SIGIF, Sigma, SMA, SND, SQLite, SPSS, STATA, SVG, SXI, SYNERGY, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK, WAV, WG1, WinEEG, WMF, XML, XPM, Z, ZIP, ZIP2 }; typedef struct CHANNEL_STRUCT { double PhysMin; /* physical minimum */ double PhysMax; /* physical maximum */ double DigMin; /* digital minimum */ double DigMax; /* digital maximum */ double Cal; /* gain factor */ double Off; /* bias */ char OnOff; char Label[MAX_LENGTH_LABEL+1]; /* Label of channel */ uint16_t LeadIdCode; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1]; /* transducer e.g. EEG: Ag-AgCl electrodes */ // char PhysDim[MAX_LENGTH_PHYSDIM+1] ; /* physical dimension */ /*PhysDim is now obsolete - use function PhysDim3(PhysDimCode) instead */ uint16_t PhysDimCode; /* code for physical dimension */ /* char* PreFilt; // pre-filtering */ float TOffset; /* time delay of sampling */ float LowPass; /* lowpass filter */ float HighPass; /* high pass */ float Notch; /* notch filter */ float XYZ[3]; /* sensor position */ // float Orientation[3]; // sensor direction // float Area; // area of sensor (e.g. for MEG) union { /* context specific channel information */ float Impedance; /* Electrode Impedance in Ohm, defined only if PhysDim = _Volt */ float fZ; /* ICG probe frequency, defined only if PhysDim = _Ohm */ }; uint16_t GDFTYP; /* data type */ uint32_t SPR; /* samples per record (block) */ } CHANNEL_TYPE; /* This structure defines the general (fixed) header */ typedef struct { float VERSION; /* GDF version number */ char* FileName; enum FileFormat TYPE; /* type of file format */ struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint8_t IPaddr[16]; /* IP address of recording device (if applicable) */ double SampleRate; /* Sampling rate */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ gdf_time T0; /* starttime of recording */ uint32_t HeadLen; /* length of header in bytes */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ uint16_t NS; /* number of channels */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ #endif CHANNEL_TYPE *rerefCHANNEL; /* Patient specific information */ struct { gdf_time Birthday; /* Birthday of Patient */ // Age; /* the age is HDR.T0 - HDR.Patient.Birthday, even if T0 and Birthday are not known */ uint16_t Headsize[3]; /* circumference, nasion-inion, left-right mastoid in millimeter; */ char Name[MAX_LENGTH_NAME+1]; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ // char* Name; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ char Id[MAX_LENGTH_PID+1]; /* patient identification, identification code as used in hospital */ uint8_t Weight; /* weight in kilograms [kg] 0:unkown, 255: overflow */ uint8_t Height; /* height in centimeter [cm] 0:unkown, 255: overflow */ // BMI; /* the body-mass index = weight[kg]/height[m]^2 */ /* Patient classification */ int Sex; /* 0:Unknown, 1: Male, 2: Female */ int Handedness; /* 0:Unknown, 1: Right, 2: Left, 3: Equal */ int Smoking; /* 0:Unknown, 1: NO, 2: YES */ int AlcoholAbuse; /* 0:Unknown, 1: NO, 2: YES */ int DrugAbuse; /* 0:Unknown, 1: NO, 2: YES */ int Medication; /* 0:Unknown, 1: NO, 2: YES */ struct { int Visual; /* 0:Unknown, 1: NO, 2: YES, 3: Corrected */ int Heart; /* 0:Unknown, 1: NO, 2: YES, 3: Pacemaker */ } Impairment; } Patient; struct { char Recording[MAX_LENGTH_RID+1]; /* HL7, EDF, GDF, BDF replaces HDR.AS.RID */ char* Technician; char* Hospital; uint64_t Equipment; /* identifies this software */ struct { /* see SCP: section1, tag14, MFER: tag23: "Manufacturer^model^version number^serial number" GDF: tag3: "Manufacturer\0model\0version\0number\0serial number\0" */ // char _field[MAX_LENGTH_MANUF+1]; /* buffer */ char* Name; char* Model; char* Version; char* SerialNumber; } Manufacturer; } ID; /* position of electrodes; see also HDR.CHANNEL[k].XYZ */ struct { float REF[3]; /* XYZ position of reference electrode */ float GND[3]; /* XYZ position of ground electrode */ } ELEC; /* EVENTTABLE */ struct { double SampleRate; /* for converting POS and DUR into seconds */ uint16_t *TYP; /* defined at ../biosig4matlab/doc/eventcodes.txt */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ #if (BIOSIG_VERSION >= 10500) gdf_time *TimeStamp ATT_ALI; /* store time stamps */ #endif char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ uint32_t N; /* number of events */ uint16_t LenCodeDesc; /* length of CodeDesc Table */ } EVENT; struct { /* flags */ char OVERFLOWDETECTION; /* overflow & saturation detection 0: OFF, !=0 ON */ char UCAL; /* UnCalibration 0: scaling !=0: NO scaling - raw data return */ char ANONYMOUS; /* 1: anonymous mode, no personal names are processed */ char ROW_BASED_CHANNELS; /* 0: column-based data [default]; 1: row-based data */ char TARGETSEGMENT; /* in multi-segment files (like Nihon-Khoden, EEG1100), it is used to select a segment */ } FLAG; CHANNEL_TYPE *CHANNEL; struct { /* File specific data */ #ifdef ZLIB_H gzFile gzFID; #endif #ifdef _BZLIB_H // BZFILE* bzFID; #endif FILE* FID; /* file handle */ size_t POS; /* current reading/writing position [in blocks] */ // int Des; /* file descriptor */ uint8_t OPEN; /* 0: closed, 1:read, 2: write */ uint8_t LittleEndian; uint8_t COMPRESSION; /* 0: no compression 9: best compression */ // int DES; /* descriptor for streams */ } FILE; /* internal variables (not public) */ struct { const char* B4C_ERRMSG; /* error message */ // char PID[MAX_LENGTH_PID+1]; /* use HDR.Patient.Id instead */ // char* RID; /* recording identification */ // uint32_t spb; /* total samples per block */ // uint32_t bpb; /* total bytes per block */ // uint32_t bpb8; /* total bits per block */ uint8_t* Header; // uint8_t* rawEventData; // uint8_t* rawdata; /* raw data block */ // char flag_collapsed_rawdata; /*0 if rawdata contain obsolete channels, too. */ // nrec_t first; /* first block loaded in buffer - this is equivalent to hdr->FILE.POS */ // nrec_t length; /* number of block(s) loaded in buffer */ uint8_t* auxBUF; /* auxillary buffer - used for storing EVENT.CodeDesc, MIT FMT infor */ char* bci2000; // uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ enum B4C_ERROR B4C_ERRNUM; /* error code */ // char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ } AS; void *aECG; } HDRTYPE; HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); void destructHDR(HDRTYPE* hdr); HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr); int sclose(HDRTYPE* hdr); size_t sread(biosig_data_type* data, size_t start, size_t length, HDRTYPE* hdr); size_t swrite(const biosig_data_type *data, size_t nelem, HDRTYPE* hdr); int seof(HDRTYPE* hdr); void srewind(HDRTYPE* hdr); int sseek(HDRTYPE* hdr, long int offset, int whence); long int stell(HDRTYPE* hdr); int serror2(HDRTYPE* hdr); int hdr2ascii(HDRTYPE* hdr, FILE *fid, int verbosity); int RerefCHANNEL(HDRTYPE *hdr, void *ReRef, char rrtype); const char* GetFileTypeString(enum FileFormat FMT); uint16_t PhysDimCode(char* PhysDim0); char* PhysDim3(uint16_t PhysDimCode); int fprintf_hdr2json(FILE *stream, HDRTYPE* hdr); int asprintf_hdr2json(char **str, HDRTYPE* hdr); int printf_hdr2json(HDRTYPE* hdr); %{ int printf_hdr2json(HDRTYPE* hdr) { return ( fprintf_hdr2json(stdout, hdr) ); }; %} char *display_header(const char *filename); %{ int display_header(const char *filename) { HDRTYPE *hdr = sopen(filename,"r",NULL); if (serror()) return NULL; char *str = NULL; asprintf_hdr2json(&str, hdr); destructHDR(hdr); return str; }; %} /* HDRTYPE* sopen(char *filename); %{ HDRTYPE* sopen(char *filename) { HDRTYPE *hdr = constructHDR(0,0); hdr = sopen(filename, "r", hdr); return hdr; } %} int sclose(HDRTYPE *hdr); %{ int sclose(HDRTYPE *hdr) { sclose(hdr); destructHDR(hdr); return 0; } %} void serror(); %{ void _serror() { fprintf(stderr,"Use of SERROR is deprecated - use serror2(HDR) instead"); serror(); } %} void hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} */ biosig-2.3.3/biosig4c++/units.awk0000775000175000017500000000230214105434233016655 0ustar schloeglschloegl#!/usr/bin/awk -f # # Converts units.csv into units.i # # Copyright (C) 2011-2019 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ # # BioSig 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 3 # of the License, 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, see . BEGIN { FS = ","; print "#if 0\n### This file is autogenerated - Do not modify it !!! ###\n"; } { if (NR < 14) { printf("%s\n", $0); } else if (NR == 14) { printf("#endif\n"); } } /^[^#,]/ { split( $0, a, "\""); sub(/\[.*\]/, "",a[2]); sub(/ *$/, "",a[2]); printf("\t{ %i, \"%s\" }, \n",$1, a[2]); } biosig-2.3.3/biosig4c++/physicalunits.h0000664000175000017500000000447014105434233020064 0ustar schloeglschloegl/* Copyright (C) 2005-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ /**************************************************************************** ** ** ** Conversion functions for encoded physical units according to ** ** ISO/IEEE 11073-10101:2004 Vital Signs Units of Measurement ** ** ** ****************************************************************************/ #ifndef __PHYSICALUNITS_H__ #define __PHYSICALUNITS_H__ #if defined(_MSC_VER) && (_MSC_VER < 1600) typedef unsigned __int64 uint16_t; #else #include #endif #pragma GCC visibility push(default) #ifdef __cplusplus extern "C" { #endif uint16_t PhysDimCode(const char* PhysDim); /* Encodes Physical Dimension as 16bit integer according to ISO/IEEE 11073-10101:2004 Vital Signs Units of Measurement Leading and trailing whitespace are skipped. --------------------------------------------------------------- */ const char* PhysDim3(uint16_t PhysDimCode); /* converts PhysDimCode into a readable Physical Dimension --------------------------------------------------------------- */ double PhysDimScale(uint16_t PhysDimCode); /* returns scaling factor of physical dimension e.g. 0.001 for milli, 1000 for kilo etc. for undefined codes, not-a-number (NAN) is returned --------------------------------------------------------------- */ #pragma GCC visibility pop #ifdef __cplusplus } #endif #endif /* __PHYSICALUNITS_H__ */ biosig-2.3.3/biosig4c++/NEWS0000664000175000017500000001654014105434233015514 0ustar schloeglschloegl2018 Build system is now using autogen.sh, autoconf, and automake, 2017 JSON(HL7/FHIR) support added Interface to Python3/Python2 added 2016 R binding added Nov 2015 homebrew support added brew tap schloegl/biosig brew install biosig mexbiosig Mar 2013 GDF v2.5 released: support for timezone, time stamps, and SCP sections 7-11 added GDF got a step closer to provide a backwards compatible way to upgrade Oct 2013 libgdf - a small lightwight library, with the same API than libbiosig Aug 2012 utility functions of detection miniature epsp and ipsp events added the tools get_local_maxima_above_threshold.m and signal_deconvolution.m are available from biosig4octmat/t300 Jul 2012 packages for libbiosig, biosig4c++-tools, mexSLOAD and biosig4python will become available for Debian/Wheezy Jun 2012 Support of FEF data format implemented May 2012 Support on NetBSD tested May 2012 NIRS tools of Günter Bauernfeind added. Apr 2012 Stimfit can be used with biosig Dec 2011 Support for Itanium and SPARC/Solaris platform fixed Support for Philips Sierra ECG added Oct 2011 Support for ARM platform improved Aug 2011 Support detecting spikes, actionpotentials and bursts added Jul 2011 SigViewer patch to fix several issues Apr 2011 Several new fileformats, including HEKA/Patchmaster v2, CFS and Igor text format (ITX), have been included. Jan 2011 MathLink interface to Mathematica Nov 2010 switch from mingw to mingw-cross-env for win32 Oct 2009 Support spatial filters in biosig4c++ (libbiosig). Mar 2009 Several new file formats supported including alpha-trace (B.E.S.T), GE-ECG Improvements in: BVA, CNT, EDF+, GDF, FAMOS, MFER, SCP, DICOM, HL7aECG Feb 2009 Introduction of biosig client-server (BSCS) architecture. The first prototyp can be used as a central archive for biomedical signal data. Nov 2008 mexSLOAD.mexw32 - Mex-file for WIN32/matlab available. About 30 file formats are supported in libbiosig used by mexSLOAD, sigviewer, save2gdf About 50 file formats are supported in biosig for octave and matlab Aug 2008 save2gdf.exe - a file converter for WIN32 is available Jul 2008 GDF v2.1 defined, BCI2000 implements GDFv2.1 May 2008 SigViewer 0.2 supports approx. 15 different data formats. Apr 2008 MEX-Interface speeds up data access Mar 2008 BioSig4C++ supports now reading of ca 15 data formats including: ACQ, AINF, BDF, BKR, BrainVision, CFWB, CNT, DEMG, EDF, EGI, ETG4000, GDF v1, GDF v2, HL7aECG/FDA-XML, MFER, SCP-ECG. Sep 2007 BioSig4C++ supports reading of MFER data Aug 2007 BioSig4C++ supports the bidirectional conversion between the following six 6 data formats: SCP, HL7aECG, GDF, BDF, EDF, CFWB Jul 2007 CSP classifier included in BioSig4OctMat Jun 2007 SCP-ECG - HL7aECG converter is available through BioSig4C++ Oct 2006 Sparse-LDA and libSVM classifier included. Aug 2006 GDF2.0 is finalized. Jul 2006 removing line interference supported. Jun 2006 LDA/GSVD classifier added. LDA/GSVD is able to address the small sample size problem. Hence, it is very suitable for high dimensional data. May 2006 BioSig improves ranking: it's now within top 1000 projects on SourceForge and is the top rank project in the field (keyword search on "EEG ECG Biosignal") Mar 2006 BioSig for Python started Mar 2006 The stats-activity at SourceForge shows 99.1 % for BioSig. Thus, BioSig belongs to the top 1% projects. BioSig is the top project in the field of EEG and biomedical signal processing. Jan 2006 Converter between SCP and aECG started Dec 2005 BioSig for Java started Nov 2005 Benchmark test based on BioSig developed Oct 2005 BioSig's homepage got a new layout - thanks to Clemens Brunner Sep 2005 Several subprojects are started: - Biosig4c++ is a C/C++ library for accessing GDF and other dataformats is started. - SigViewer is a Viewing and Scoring software programmed in C/C++ and Qt - BioProFeed is a real-time acquisition analysis system based on RTAI - rtsBCI is a realtime BCI system based on Matlab/Simulink - biosig4octmat is the known Biosig-toolbox for Octave and Matlab Aug 2005 The next version (2.0) of the GDF data format 2.0 is under development. GDF2.0 will contain many new features while having still a simple file structure like EDF and GDF 1.x. Jul 2005 BioProFeed: realtime data aquisition tool based on RTAI - thanks to Andreas Glatz Jun 2005 new version of rtsBCI available - thanks to Reinhold Scherer Apr 2005 BIOSIG supports more dataformats (of biomedical signals) than any other software package. Currently, over 30 different biosignal formats and several image and sound formats are supported. Mar 2005 BIOSIG has been tested with whole Physiobank. Mar 2005 TLOAD loads and triggers data, rejects visually identified artifacts. All processing steps are included in TLOAD. Feb 2005 multiclass LDA included Dec 2004 BCI competition 2005 has been announced. Support for these datasets is included in BIOSIG. Nov 2004 SVIEWER, a powerful viewing and scoring program is included. Now, it is really an important milestone which justifies the new version number 1.00. Thanks to Franz Einspieler, a student of the University of Technology Graz, Austria. Nov 2004 Support of several IMAGE-, MESH- and MATRIX- formats added 8 file formats can be written 39 file formats can be read, ca. 100 formats are identified Sep 2004 Interface to EEGLAB improved BIOSIG and EEGLAB work together Aug 15th, 2004 Online HELP uploaded HELP is now available online at http://biosig.sf.net/help/ and http://pub.ist.ac.at/~schloegl/matlab/help/ Jul 7th, 2004 BIOSIG 0.65 released minor changes May 24th, 2004 New Release: BIOSIG 0.60 More dataformats, new features, improved performance. see release notes for more details May 05th, 2004 New Release: Dataformat 1.40 see release notes for more details Apr 16, 2004 EEG data of the Graz BCI experiments are saved in GDF format using the BIOSIG toolbox: The Event Codes as proposed in http://dpmi.tu-graz.ac.at/~schloegl/matlab/eeg/EventCodes.html are implemented in the GDF format. This allows to save EEG data and Events in a single file. The advantage of this solution is based on some modifications of the originally, simple EDF format. April 16th, 2004 Thanks to Robert Oostenveld's effort, support for 3 more data formats is included. BrainVision, FIF and EEProbe are supported now. April 4th, 2004 BIOSIG reaches new record number of monthly downloads. In March 497 downloads are counted. The last record number was in Oct 2003 with 367 downloads. April 1st, 2004 Alois Schloegl is 3rd winner of the OpenECG programming contest. CONGRATULATION. He received the prize for implemented an Converter for the SCP-ECG data format for Octave. The converver is part of the BIOSIG. March, 2004 Robert Oostenveld will include support for the following formats: CTF, NeuroMag, BrainVision, EEProbe March 8th, 2004 New releases from the BIOSIG project. === earlier news omitted === biosig-2.3.3/biosig4c++/gdftime.c0000664000175000017500000002374214105434233016602 0ustar schloeglschloegl/* Copyright (C) 2005-2013,2020 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ /* Library function for conversion of gdf_time into other datetime formats. gdf_time is used in [1] and in Octave and Matlab. Also Python seems to use this format but with an offset of 366 days. References: [1] GDF - A general data format for biomedical signals. available online http://arxiv.org/abs/cs.DB/0608052 */ #define _GNU_SOURCE #include "gdftime.h" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Conversion of time formats between Unix and GDF format. The default time format in BIOSIG uses a 64-bit fixed point format with reference date 01-Jan-0000 00h00m00s (value=0). One unit indicates the 2^(-32) part of 1 day (ca 20 us). Accordingly, the higher 32 bits count the number of days, the lower 32 bits describe the fraction of a day. 01-Jan-1970 is the day 719529. time_t t0; t0 = time(NULL); T0 = (double)t0/86400.0; // convert seconds in days since 1970-Jan-01 floor(T0) + 719529; // number of days since 01-Jan-0000 floor(ldexp(T0-floor(T0),32)); // fraction x/2^32; one day is 2^32 The following macros define the conversions between the unix time and the GDF format. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define fix(m) (m<0 ? ceil(m) : floor(m)) gdf_time tm_time2gdf_time(struct tm *t){ /* based on Octave's datevec.m it referes Peter Baum's algorithm at http://vsg.cape.com/~pbaum/date/date0.htm but the link is not working anymore as of 2008-12-03. Other links to Peter Baum's algorithm are http://www.rexswain.com/b2mmddyy.rex http://www.dpwr.net/forums/index.php?s=ecfa72e38be61327403126e23aeea7e5&showtopic=4309 */ if (t == NULL) return(0); int Y,M,s; // h,m, double D; gdf_time o; const int monthstart[] = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; D = (double)t->tm_mday; M = t->tm_mon+1; Y = t->tm_year+1900; // Set start of year to March by moving Jan. and Feb. to previous year. // Correct for months > 12 by moving to subsequent years. Y += fix ((M-14.0)/12); // Lookup number of days since start of the current year. D += monthstart[t->tm_mon % 12] + 60; // Add number of days to the start of the current year. Correct // for leap year every 4 years except centuries not divisible by 400. D += 365*Y + floor (Y/4.0) - floor (Y/100.0) + floor (Y/400.0); // Add fraction representing current second of the day. s = t->tm_hour*3600 + t->tm_min*60 + t->tm_sec; // s -= timezone; o = (((uint64_t)D) << 32) + (((uint64_t)s) << 32)/86400; return(o); } struct tm *gdf_time2tm_time(gdf_time t) { // this is not re-entrant, use gdf_time2tm_time_r instead /* based Octave's datevec.m it referes Peter Baum's algorithm at http://vsg.cape.com/~pbaum/date/date0.htm but the link is not working anymore as of 2008-12-03. Other links to Peter Baum's algorithm are http://www.rexswain.com/b2mmddyy.rex http://www.dpwr.net/forums/index.php?s=ecfa72e38be61327403126e23aeea7e5&showtopic=4309 */ static struct tm tt; // allocate memory for t3; gdf_time2tm_time_r(t,&tt); return(&tt); } struct gdf_time_tm_t { int YEAR; int MONTH; int MDAY; int HOUR; int MINUTE; double SECOND; }; int split_gdf_time(gdftime_t t, struct gdf_time_tm_t *gte) { /* based Octave's datevec.m it referes Peter Baum's algorithm at http://vsg.cape.com/~pbaum/date/date0.htm but the link is not working anymore as of 2008-12-03. Other links to Peter Baum's algorithm are http://www.rexswain.com/b2mmddyy.rex http://www.dpwr.net/forums/index.php?s=ecfa72e38be61327403126e23aeea7e5&showtopic=4309 */ int32_t rd = (int32_t)floor(ldexp((double)t,-32)); // days since 0001-01-01 double s = ldexp((t & 0x00000000ffffffff)*86400,-32); // seconds of the day // int32_t sec = round (s); // s += timezone; /* derived from datenum.m from Octave 3.0.0 */ // Move day 0 from midnight -0001-12-31 to midnight 0000-3-1 double z = floor (rd) - 60; // Calculate number of centuries; K1 = 0.25 is to avoid rounding problems. double a = floor ((z - 0.25) / 36524.25); // Days within century; K2 = 0.25 is to avoid rounding problems. double b = z - 0.25 + a - floor (a / 4); // Calculate the year (year starts on March 1). int y = (int)floor (b / 365.25); // Calculate day in year. double c = fix (b - floor (365.25 * y)) + 1; // Calculate month in year. double m = fix ((5 * c + 456) / 153); double d = c - fix ((153 * m - 457) / 5); // Move to Jan 1 as start of year. if (m>12) {y++; m-=12;} gte->YEAR = y; gte->MONTH = (int)m; gte->MDAY = (int)d; int h = (int) s / 3600; s = s - (3600 * h); m = s / 60; // !! reuse of m: is now minutes instead of month gte->HOUR = h; gte->MINUTE = (int) m; gte->SECOND = s - (60 * gte->MINUTE); //t3->tm_gmtoff = 3600; return(0); } int gdf_time2tm_time_r(gdftime_t t, struct tm *t3) { struct gdf_time_tm_t gte; split_gdf_time(t, >e); t3->tm_year = gte.YEAR-1900; t3->tm_mon = gte.MONTH-1; t3->tm_mday = gte.MDAY; t3->tm_hour = gte.HOUR; t3->tm_min = gte.MINUTE; t3->tm_sec = (int)gte.SECOND; } #if 0 gdftime_t string2gdftime(const char* str) { struct tm t; strptime(str,"%d %b %Y",&t); t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; return tm_time2gdf_time(&t); } gdftime_t string2gdfdate(const char* str) { struct tm t; strptime(str,"%d %b %Y",&t); t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; return tm_time2gdf_time(&t); } gdftime_t string2gdfdatetime(const char* str) { struct tm t; return tm_time2gdf_time(getdate(str)); } #endif size_t snprintf_gdftime(char *out, size_t outbytesleft, gdftime_t T) { struct gdf_time_tm_t gte; size_t len; split_gdf_time(T, >e); len = snprintf(out, outbytesleft, "%02d:%02d:", gte.HOUR, gte.MINUTE); outbytesleft -= len; out += len; double intSec; double fracSec=modf(gte.SECOND, &intSec); if (fracSec == 0.0) len = snprintf(out, outbytesleft, "%02d", (int)gte.SECOND); else len = snprintf(out, outbytesleft, "%09.6f", gte.SECOND); outbytesleft -= len; out += len; return len; } size_t snprintf_gdfdate(char *out, size_t outbytesleft, gdftime_t T) { struct gdf_time_tm_t gte; size_t len; split_gdf_time(T, >e); len = snprintf(out, outbytesleft, "%04d-%02d-%02d", gte.YEAR, gte.MONTH, gte.MDAY); outbytesleft -= len; out += len; return len; } size_t snprintf_gdfdatetime(char *out, size_t outbytesleft, gdftime_t T) { struct gdf_time_tm_t gte; size_t len; split_gdf_time(T, >e); len = snprintf(out, outbytesleft, "%04d-%02d-%02d %02d:%02d:", gte.YEAR, gte.MONTH, gte.MDAY, gte.HOUR, gte.MINUTE); outbytesleft -= len; out += len; double intSec; double fracSec=modf(gte.SECOND, &intSec); if (fracSec == 0.0) len = snprintf(out, outbytesleft, "%02d", (int)gte.SECOND); else len = snprintf(out, outbytesleft, "%09.6f", gte.SECOND); outbytesleft -= len; out += len; return len; } size_t strfgdftime(char *out, size_t outbytesleft, const char *FMT, gdftime_t T) { struct gdf_time_tm_t gte; struct tm tm; size_t len; int cin=0; int cout=0; char FMT2[4]="%%\0\0"; split_gdf_time(T, >e); gdf_time2tm_time_r(T, &tm); while ( cout < outbytesleft && cin 7) fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, line); if (VERBOSE_LEVEL > 7) { char tmp[30]; strftime(tmp,30,"%F %T",&t); fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, tmp); } } else if (!strncmp(line,"Date",p)) { strptime(line+p+1,"%d %b %Y",&t); t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; if (VERBOSE_LEVEL > 7) { char tmp[30]; strftime(tmp,30,"%F %T",&t); fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, tmp); } } else if (!strncmp(line,"Time Stamp",p)) { hdr->SampleRate *= hdr->SPR*hdr->NRec/strtod(line+p+1,NULL); } line = strtok(NULL, "\n\r\0"); */ /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ biosig-2.3.3/biosig4c++/biosig_client.c0000664000175000017500000002047014105434233017770 0ustar schloeglschloegl/* Copyright (C) 2009,2015,2016 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include "biosig-network.h" #include #include #ifndef _WIN32 # include #endif #include #include #include #include int main (int argc, char *argv[]) { int s=0; register int sd; struct stat info; int state; sd = bscs_connect(argv[1]); if(sd<0) { perror("cannot connect "); exit(1); } fprintf(stdout,"client 122 %i %s <%s>\n",errno,strerror(errno),getenv("HOME")); char path2keys[1024]; char *str; #ifdef _WIN32 str = strncpy(path2keys,getenv("HOME"),1023); #elif 0 // TODO: getpwuid can cause a memory leak in glibc2.15 and earlier struct passwd *p = getpwuid(geteuid()); str = strncpy(path2keys,p->pw_dir,1023); //path2keys = strdup(p->pw_dir); if (VERBOSE_LEVEL>7) fprintf(stdout,"Name:%s\nPw:%s\nuid/gui: %i/%i\nreal name: %s\n$HOME:%s\nSHELL:%s\n",p->pw_name,p->pw_passwd,p->pw_uid,p->pw_gid,p->pw_gecos,p->pw_dir,p->pw_shell); #endif str += strlen(path2keys); str[0] = FILESEP; str = (char*)memcpy(str+1,".biosig",7)+7; str[0] = FILESEP; str[1] = 0; size_t path2keysLength = strlen(path2keys); stat(path2keys, &info); if (!(S_ISDIR(info.st_mode))) mkdir(path2keys,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); // read/write/search permissions for owner and group, and with read/search permissions for others. SERVER_STATE = STATE_INIT; HDRTYPE *hdr=constructHDR(0,0); uint64_t ID = 0; // bscs_send_msg(sd,"Hello Server"); fprintf(stdout,"client 125 %i %s\n",errno,strerror(errno)); char clbuf[1000]; char *cmd; while (1) { fprintf(stdout,"prompt$:"); cmd = fgets(clbuf,1000,stdin); if (!strncasecmp(clbuf,"exit",4) || !strncasecmp(clbuf,"bye",3)) { fprintf(stdout,"\n%p>\n",cmd); bscs_close(sd); close(sd); break; } // fprintf(stdout,"cmd=<%s> %i\n",cmd,strncasecmp(cmd,"close",5)); if (cmd[0]=='!') system(cmd+1); else if (!strncasecmp(cmd,"ow+c",4)) { ID = 0; s=bscs_open(sd, &ID); fprintf(stdout,"ow ID=%016"PRIx64" s=%i %08x\n",ID,s,s); s=bscs_close(sd); fprintf(stdout,"c ID=%016"PRIx64" s=%i %08x\n",ID,s,s); } else if (!strncasecmp(cmd,"or+c",4)) { ID = htole64(0x233ab6dfc96f664fLL); s=bscs_open(sd, &ID); fprintf(stdout,"or ID=%016"PRIx64" s=%i %08x\n",ID,s,s); // hdr->TYPE = unknown; // getfiletype(hdr); bscs_requ_hdr(sd,hdr); bscs_requ_dat(sd,0,hdr->NRec,hdr); // bscs_requ_evt(sd,hdr); s=bscs_close(sd); fprintf(stdout,"c ID=%016"PRIx64" s=%i %08x\n",ID,s,s); } else if (!strncasecmp(cmd,"openr",5)) { ID = htole64(0x233ab6dfc96f664fLL); ID = htole64(0x233ab6dfc96f664fLL); fprintf(stdout,"or ID=%016"PRIx64" s=%i %08x\n",ID,s,s); s=bscs_open(sd, &ID); } else if (!strncasecmp(cmd,"openw",5)) { char *fn = cmd+5; char *ix; while (isspace(fn[0])) fn++; ix = fn; while (!isspace(ix[0])) ix++; ix[0]=0; hdr = sopen(fn,"r",hdr); ID = 0; s=bscs_open(sd, &ID); fprintf(stdout,"openw: ID=%016"PRIx64" s=%i %08x\n",ID,s,s); } else if (!strncasecmp(cmd,"sendhdr",7)) { s= bscs_send_hdr(sd, hdr); } else if (!strncasecmp(cmd,"senddat",7)) { s= bscs_send_dat(sd, hdr->AS.rawdata, hdr->AS.bpb*hdr->AS.length); fprintf(stdout,"sent dat %i\n",s); } else if (!strncasecmp(cmd,"sendevt",7)) { if (hdr->TYPE != GDF) hdrEVT2rawEVT(hdr); if (hdr->EVENT.N>0) s= bscs_send_evt(sd, hdr); } else if (!strncasecmp(cmd,"hdr",3)) { bscs_requ_hdr(sd,hdr); } else if (!strncasecmp(cmd,"show1",5)) { hdr2ascii(hdr,stdout,1); } else if (!strncasecmp(cmd,"show2",5)) { hdr2ascii(hdr,stdout,2); } else if (!strncasecmp(cmd,"show3",5)) { hdr2ascii(hdr,stdout,3); } else if (!strncasecmp(cmd,"show4",5)) { hdr2ascii(hdr,stdout,4); } else if (!strncasecmp(cmd,"dat",3)) { bscs_requ_dat(sd,0,hdr->NRec,hdr); } else if (!strncasecmp(cmd,"evt",3)) { bscs_requ_evt(sd,hdr); } else if (!strncasecmp(cmd,"ow",2)) { ID = 0; s=bscs_open(sd, &ID); fprintf(stdout,"ow ID=%016"PRIx64" s=%i %08x\n",ID,s,s); } else if (!strncasecmp(cmd,"close",5)) { s=bscs_close(sd); fprintf(stdout,"oc ID=%016"PRIx64" s=%i %08x\n",ID,s,s); } else if (!strncasecmp(cmd,"requ ",5)) { char *fn = cmd+5; char *ix; while (isspace(fn[0])) fn++; ix = fn; while (!isspace(ix[0])) ix++; ix[0]=0; cat64(fn,&ID); bscs_open(sd, &ID); fprintf(stdout,"11 %i\n",hdr->EVENT.N); bscs_requ_hdr(sd,hdr); hdr->TYPE = unknown; fprintf(stdout,"12 %i\n",hdr->EVENT.N); getfiletype(hdr); fprintf(stdout,"13 %s %i\n",GetFileTypeString(hdr->TYPE),hdr->EVENT.N); bscs_requ_hdr(sd,hdr); fprintf(stdout,"14a %i %i %i\n",0,(int)hdr->NRec,hdr->EVENT.N); bscs_requ_dat(sd,0,hdr->NRec,hdr); fprintf(stdout,"14b %i\n",hdr->EVENT.N); // bscs_requ_evt(sd,hdr); fprintf(stdout,"14c %i\n",hdr->EVENT.N); if (hdr->TYPE == GDF) { fprintf(stdout,"15\n"); ;//hdr2ascii(hdr,stdout,3); fprintf(stdout,"16 %i\n",hdr->EVENT.N); } bscs_close(sd); } else if (!strncasecmp(cmd,"send ",5)) { char *fn = cmd+5; char *ix; while (isspace(fn[0])) fn++; ix = fn; while (!isspace(ix[0])) ix++; ix[0]=0; hdr = sopen(fn,"r",NULL); // if (hdr->TYPE!=GDF) { if (serror2(hdr)) { stat(fn, &info); FILE *fid = fopen(fn,"r"); if (fid==NULL) fprintf(stdout,"file %s not found\n",fn); else { uint8_t *buf = (uint8_t*) malloc(info.st_size); ssize_t count = fread(buf, 1, info.st_size, fid); fclose(fid); ID = 0; if ((state = bscs_open(sd,&ID))) // write-open fprintf(stdout,"BSCS_OPEN failed: state=%08x\n",state); else { /* write key file */ char *tmp = strrchr(fn,FILESEP); if (tmp==NULL) tmp = fn; strcpy(path2keys+path2keysLength,tmp); fid = fopen(path2keys,"w"); // TODO: prevent overwritting fprintf(fid,"key4biosig: host=%s ID=%016"PRIx64" ",argv[1],ID); fclose(fid); fprintf(stdout,"open_w ID=%016"PRIx64"\n",ID); hdr->HeadLen = count; bscs_send_dat(sd, buf, count); bscs_close(sd); } free(buf); } } else { sread_raw(0,hdr->NRec,hdr,1,NULL,0); // collapse rawdata (remove obsolete channels) size_t bpb = bpb8_collapsed_rawdata(hdr)>>3; if (serror2(hdr)) { sclose(hdr); exit(-1); } ID = 0; bscs_open(sd,&ID); // write-open /* write key file */ char *tmp = strrchr(fn,FILESEP); if (tmp==NULL) tmp = fn; strcpy(path2keys+path2keysLength,tmp); FILE *fid = fopen(path2keys,"w"); // TODO: prevent overwritting if (fid==NULL) fprintf(stdout,"error: %i %s\n",errno, strerror(errno)); fprintf(fid,"bscs://%s/%016"PRIx64"",argv[1],ID); fclose(fid); fprintf(stdout,"open_w ID=%016"PRIx64" len=%"PRIiPTR"\n",ID,hdr->AS.length); s= bscs_send_hdr(sd, hdr); fprintf(stdout,"sent hdr %i %i\n",s,hdr->AS.bpb); s = bscs_send_dat(sd, hdr->AS.rawdata, hdr->AS.length*bpb); fprintf(stdout,"sent dat %i %"PRIiPTR"\n",s,bpb); if (hdr->TYPE != GDF) hdrEVT2rawEVT(hdr); if (hdr->EVENT.N>0) s= bscs_send_evt(sd, hdr); fprintf(stdout,"sent evt %i\n",s); s = bscs_close(sd); fprintf(stdout,"closed %08x\n",s); sclose(hdr); } } } /* * We can simply use close() to terminate the * connection, since we're done . */ // bscs_disconnect(sd); return(0); } biosig-2.3.3/biosig4c++/gdftime.h0000664000175000017500000001143114105434233016577 0ustar schloeglschloegl/* % Copyright (C) 2005-2013,2020 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++/libbiosig) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ #ifndef __GDFTIME_H__ #define __GDFTIME_H__ #if defined(_MSC_VER) && (_MSC_VER < 1600) typedef __int64 int64_t; #else #include #endif #include #include #include #include #ifdef __cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C #endif /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Conversion of time formats between Unix and GDF format. The default time format in BIOSIG uses a 64-bit fixed point format with reference date 01-Jan-0000 00h00m00s (value=0). One unit indicates the 2^(-32) part of 1 day (ca 20 us). Accordingly, the higher 32 bits count the number of days, the lower 32 bits describe the fraction of a day. 01-Jan-1970 is the day 719529. time_t t0; t0 = time(NULL); T0 = (double)t0/86400.0; // convert seconds in days since 1970-Jan-01 floor(T0) + 719529; // number of days since 01-Jan-0000 floor(ldexp(T0-floor(T0),32)); // fraction x/2^32; one day is 2^32 The following macros define the conversions between the unix time and the GDF format. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ typedef int64_t gdf_time, gdftime_t; /* gdf time is represented in 64 bits */ #define t_time2gdf_time(t) ((gdf_time)floor(ldexp(((double)(t))/86400.0 + 719529.0, 32))) #define gdf_time2t_time(t) ((ldexp(((double)(t)),-32) - 719529.0)*86400.0) #define ntp_time2gdf_time(t) ((gdf_time)ldexp(ldexp(((double)(t)),-32)/86400 + 719529.0 - 70,32)) #define gdf_time2ntp_time(t) ((int64_t)ldexp((ldexp(((double)(t)),-32) - 719529.0 + 70) * 86400,32)) #pragma GCC visibility push(default) #ifdef __cplusplus EXTERN_C { #endif /* * converts struct tm into gdf_time format */ gdftime_t tm_time2gdf_time(struct tm *t); /* * gdf_time2tm_time converts gdf-time into struct tm format, this is deprecated because time resolution (sub-seconds) are lost */ struct tm *gdf_time2tm_time(gdftime_t t); /* * re-entrant version of gdf_time2tm_time, memory for t must be allocated this is deprecated because time resolution (sub-seconds) are lost */ int gdf_time2tm_time_r(gdftime_t t, struct tm *tm); /* converts date and time to strings using this format %Y-%m-%d %H:%M:%S with microsecond resolution, if needed. %04d-%02d-%02d %02d:%02d:%02d %04d-%02d-%02d %02d:%02d:%09.6f strfgdftime resembles strftime(...), except for format %s and %S which will also present 6 digits the fraction of the second */ size_t snprintf_gdftime(char *out, size_t outbytesleft, gdftime_t T); size_t snprintf_gdfdate(char *out, size_t outbytesleft, gdftime_t T); size_t snprintf_gdfdatetime(char *out, size_t outbytesleft, gdftime_t T); size_t strfgdftime(char *out, size_t outbytesleft, const char *FMT, gdftime_t T); /* gdftime_t string2gdftime(const char*) gdftime_t string2gdfdate(const char*) gdftime_t string2gdfdatetime(const char*) gdftime_t time2gdftime(int,int,float) gdftime_t date2gdftime(int,int,int) gdftime_t datetime2gdftime(int,int,int,int,int,float) void gdftime2datetime(&int,&int,&int,&int,&int,&float) void gdftime2time(&int,&int,&float) void gdftime2date(&int,&int,&int) */ #ifdef __cplusplus } #endif #pragma GCC visibility pop /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #endif /* __BIOSIG_EXT_H__ */ biosig-2.3.3/biosig4c++/java/0000775000175000017500000000000014105434244015732 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/java/Makefile.in0000664000175000017500000000167514105434233020006 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2018-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ### JNI ### # https://stackoverflow.com/questions/5963266/call-c-function-from-java JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which @JAVAC@ )))/..) CLASS_PATH ?= $(JAVA_HOME)/bin libBiosig.so: Biosig.h Biosig.c $(CXX) -shared -fPIC \ -I.. \ -I$(JAVA_HOME)/include \ -I$(JAVA_HOME)/include/$(shell uname -s | tr '[:upper:]' '[:lower:]') \ Biosig.c -L.. -lbiosig -o libBiosig.so Biosig.h: Biosig.class @JAVAC@ -h . Biosig.java Biosig.class: Biosig.java @JAVAC@ Biosig.java test: libBiosig.so LD_LIBRARY_PATH=.. @JAVA@ -Djava.library.path=. Biosig "../data/Newtest17-256.bdf" clean: -rm *.h -rm *.o -rm *.cxx -rm *.so biosig-2.3.3/biosig4c++/java/Biosig.c0000664000175000017500000000351414105434233017313 0ustar schloeglschloegl/* Copyright (C) 2018,2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include "Biosig.h" /* Header for class Biosig */ #ifndef _Included_biosig #define _Included_biosig #ifdef __cplusplus extern "C" { #endif /* * Class: Biosig * Method: hdr2ascii * Signature: ()V */ JNIEXPORT jstring JNICALL Java_Biosig_hdr2ascii (JNIEnv *env, jobject, jstring filename) { HDR_STRUCT *hdr = sopen((const char*)env->GetStringUTFChars(filename, 0),"r", NULL); char *json=NULL; asprintf_hdr2json(&json,hdr); sclose(hdr); destructHDR(hdr); printf("hdr2ascii: Hello World! \n%s\n", json); return env->NewStringUTF(json); } /* * Class: Biosig * Method: isTTY * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_Biosig_isTTY (JNIEnv *env, jclass) { printf("isTTY: Hello World!\n"); } /* * Class: Biosig * Method: getTTYName * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_Biosig_getTTYName (JNIEnv *env, jclass) { printf("getTTYName: Hello World!\n"); } #ifdef __cplusplus } #endif #endif biosig-2.3.3/biosig4c++/java/Biosig.java0000664000175000017500000000261014105434233020006 0ustar schloeglschloegl/* Copyright (C) 2018,2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html */ //package Biosig; public class Biosig { static { System.loadLibrary("Biosig"); } private native void version(); private native String hdr2ascii(String filename); private native void hdr2json(String filename); private native void sopen(String filename); private native void sread(String filename); private native void sclose(String filename); public static void main(String[] args) { System.out.println(new Biosig().hdr2ascii(args[0])); } } biosig-2.3.3/biosig4c++/java/Makefile0000664000175000017500000000173114105434244017374 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2018-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ### JNI ### # https://stackoverflow.com/questions/5963266/call-c-function-from-java JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which /usr/bin/javac )))/..) CLASS_PATH ?= $(JAVA_HOME)/bin libBiosig.so: Biosig.h Biosig.c $(CXX) -shared -fPIC \ -I.. \ -I$(JAVA_HOME)/include \ -I$(JAVA_HOME)/include/$(shell uname -s | tr '[:upper:]' '[:lower:]') \ Biosig.c -L.. -lbiosig -o libBiosig.so Biosig.h: Biosig.class /usr/bin/javac -h . Biosig.java Biosig.class: Biosig.java /usr/bin/javac Biosig.java test: libBiosig.so LD_LIBRARY_PATH=.. /usr/bin/java -Djava.library.path=. Biosig "../data/Newtest17-256.bdf" clean: -rm *.h -rm *.o -rm *.cxx -rm *.so biosig-2.3.3/biosig4c++/biosig.h0000664000175000017500000007102514105434233016441 0ustar schloeglschloegl/* Copyright (C) 2012-2018 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #ifndef __LIBBIOSIG2_H__ #define __LIBBIOSIG2_H__ #include "biosig-dev.h" #define BIOSIG_FLAG_COMPRESSION 0x0001 #define BIOSIG_FLAG_UCAL 0x0002 #define BIOSIG_FLAG_OVERFLOWDETECTION 0x0004 #define BIOSIG_FLAG_ROW_BASED_CHANNELS 0x0008 #pragma GCC visibility push(default) #ifdef __cplusplus extern "C" { #endif /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS : Level 1 **/ /** **/ /****************************************************************************/ uint32_t get_biosig_version (); /* returns the version number in hex-decimal representation get_biosig_version() & 0x00ff0000 : major version number get_biosig_version() & 0x0000ff00 : minor version number get_biosig_version() & 0x000000ff : patch level --------------------------------------------------------------- */ HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); /* allocates memory initializes header HDR of type HDRTYPE with NS channels an N_EVENT event elements --------------------------------------------------------------- */ void destructHDR(HDRTYPE* hdr); /* destroys the header *hdr and frees allocated memory --------------------------------------------------------------- */ HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr); /* FileName: name of file Mode: "r" is reading mode, requires FileName Mode: "w" is writing mode, hdr contains the header information If the number of records is not known, set hdr->NRec=-1 and sclose will fill in the correct number. Mode: "a" is append mode, if file exists, header and eventtable is read, position pointer is set to end of data in order to add more data. If file is successfully opened, the header structure of the existing file is used, and any different specification in hdr is discarded. If file is not compressed, it can be used for read and write, for compressed files, only appending at the end of file is possible. Currently, append mode is supported only for the GDF format. hdr should be generated with constructHDR, and the necessary fields must be defined. In read-mode, hdr can be NULL; however, hdr->FLAG... can be used to turn off spurious warnings. In write-mode, the whole header information must be defined. In append mode, it is recommended to provide whole header information, which must be equivalent to the header info of an existing file. After calling sopen, the file header is read or written, and the position pointer points to the beginning of the data section in append mode, the position pointer points to the end of the data section. --------------------------------------------------------------- */ int sclose(HDRTYPE* hdr); /* closes the file corresponding to hdr file handles are closed, the position pointer becomes meaningless Note: hdr is not destroyed; use destructHDR() to free the memory of hdr if hdr was opened in writing mode, the event table is added to the file and if hdr->NRec=-1, the number of records is obtained from the position pointer and written into the header, --------------------------------------------------------------- */ size_t sread(biosig_data_type* DATA, size_t START, size_t LEN, HDRTYPE* hdr); /* LEN data segments are read from file associated with hdr, starting from segment START. The data is copied into DATA; if DATA == NULL, a sufficient amount of memory is allocated, and the pointer to the data is available in hdr->data.block. In total, LEN*hdr->SPR*NS samples are read and stored in data type of biosig_data_type (currently double). NS is the number of channels with non-zero hdr->CHANNEL[].OnOff. The number of successfully read data blocks is returned. A pointer to the data block is also available from hdr->data.block, the number of columns and rows is available from hdr->data.size[0] and hdr->data.size[1] respectively. Channels k with (hdr->CHANNEL[k].SPR==0) are interpreted as sparsely sampled channels [for details see specification ofGDF v2 or larger]. The sample values are also returned in DATA the corresponding sampling time, the values in between the sparse sampling times are set to DigMin. (Applying the flags UCAL and OVERFLOWDETECTION will convert this into PhysMin and NaN, resp. see below). The following flags will influence the result. hdr->FLAG.UCAL = 0 scales the data to its physical values hdr->FLAG.UCAL = 1 does not apply the scaling factors hdr->FLAG.OVERFLOWDETECTION = 0 does not apply overflow detection hdr->FLAG.OVERFLOWDETECTION = 1: replaces all values that exceed the dynamic range (defined by Phys/Dig/Min/Max) hdr->FLAG.ROW_BASED_CHANNELS = 0 each channel is in one column hdr->FLAG.ROW_BASED_CHANNELS = 1 each channel is in one row --------------------------------------------------------------- */ #ifdef __GSL_MATRIX_DOUBLE_H__ size_t gsl_sread(gsl_matrix* DATA, size_t START, size_t LEN, HDRTYPE* hdr); /* same as sread but return data is of type gsl_matrix --------------------------------------------------------------- */ #endif size_t swrite(const biosig_data_type *DATA, size_t NELEM, HDRTYPE* hdr); /* DATA contains the next NELEM data segment(s) for writing. * hdr contains the definition of the header information and was generated by sopen * the number of successfully written segments is returned; --------------------------------------------------------------- */ int seof(HDRTYPE* hdr); /* returns 1 if end of file is reached. --------------------------------------------------------------- */ void srewind(HDRTYPE* hdr); /* postions file pointer to the beginning * * Currently, this function is meaning less because sread requires always the start value --------------------------------------------------------------- */ int sseek(HDRTYPE* hdr, ssize_t offset, int whence); /* positions file pointer * * Currently, this function is meaning less because sread requires always the start value --------------------------------------------------------------- */ ssize_t stell(HDRTYPE* hdr); /* returns position of file point in segments --------------------------------------------------------------- */ #ifndef ONLYGDF ATT_DEPREC int serror(); /* handles errors; it reports whether an error has occured. * if yes, an error message is displayed, and the error status is reset. * the return value is 0 if no error has occured, otherwise the error code * is returned. * IMPORTANT NOTE: * serror() uses the global error variables B4C_ERRNUM and B4C_ERRMSG, * which is not re-entrant, because two opened files share the same * error variables. --------------------------------------------------------------- */ #endif //ONLYGDF int serror2(HDRTYPE* hdr); /* handles errors; it reports whether an error has occured. * if yes, an error message is displayed, and the error status is reset. * the return value is 0 if no error has occured, otherwise the error code * is returned. --------------------------------------------------------------- */ int biosig_check_error(HDRTYPE *hdr); /* returns error status but does not handle/reset it. * it can be used for checking whether some error status has been set --------------------------------------------------------------- */ char* biosig_get_errormsg(HDRTYPE *hdr); /* returns error message but does not reset it. * memory for the error message is allocated and need to be freed * by the calling application --------------------------------------------------------------- */ int sflush_gdf_event_table(HDRTYPE* hdr); /* writes the event table of file hdr. hdr must define a file in GDF format * and can be opened as read or write. * In case of success, the return value is 0. --------------------------------------------------------------- */ int cachingWholeFile(HDRTYPE* hdr); /* caching: load data of whole file into buffer * this will speed up data access, especially in interactive mode --------------------------------------------------------------- */ int RerefCHANNEL(HDRTYPE *hdr, void *ReRef, char rrtype); /* rerefCHAN defines rereferencing of channels, hdr->Calib defines the rereferencing matrix hdr->rerefCHANNEL is defined. hdr->rerefCHANNEL[.].Label is by some heuristics from hdr->CHANNEL either the maximum scaling factor if ReRef is NULL, rereferencing is turned off (hdr->Calib and hdr->rerefCHANNEL are reset to NULL). if rrtype==1, Reref is a filename pointing to a MatrixMarket file if rrtype==2, Reref must be a pointer to a cholmod sparse matrix (cholmod_sparse*) In case of an error (mismatch of dimensions), a non-zero is returned, and serror() is set. rr is a pointer to a rereferencing matrix rrtype determines the type of pointer rrtype=0: no rereferencing, RR is ignored (NULL) 1: pointer to MarketMatrix file (char*) 2: pointer to a sparse cholmod matrix (cholmod_sparse*) ------------------------------------------------------------------------*/ /* ============================================================= utility functions for handling of event table ============================================================= */ void sort_eventtable(HDRTYPE *hdr); /* sort event table with respect to hdr->EVENT.POS --------------------------------------------------------------*/ size_t reallocEventTable(HDRTYPE *hdr, size_t EventN); /*------------------------------------------------------------------------ re-allocates memory for Eventtable. hdr->EVENT.N contains actual number of events EventN determines the size of the allocated memory return value: in case of success, EVENT_N is returned in case of failure SIZE_MAX is returned; ------------------------------------------------------------------------*/ void convert2to4_eventtable(HDRTYPE *hdr); /* converts event table from {TYP,POS} to [TYP,POS,CHN,DUR} format -------------------------------------------------------------- */ void convert4to2_eventtable(HDRTYPE *hdr); /* converts event table from [TYP,POS,CHN,DUR} to {TYP,POS} format all CHN[k] must be 0 -------------------------------------------------------------- */ const char* GetEventDescription(HDRTYPE *hdr, size_t n); /* returns clear text description of n-th event, considers also user-defined events. -------------------------------------------------------------- */ void FreeTextEvent(HDRTYPE* hdr, size_t N, const char* annotation); /* adds free text annotation to event table for the N-th event. the EVENT.TYP[N] is identified from the table EVENT.CodeDesc if annotations is not listed in CodeDesc, it is added to CodeDesc The table is limited to 256 entries, because the table EventCodes allows only codes 0-255 as user specific entry. If the description table contains more than 255 entries, an error is set. ------------------------------------------------------------------------*/ /* ============================================================= utility functions for handling of physical dimensons ============================================================= */ #ifndef __PHYSICALUNITS_H__ uint16_t PhysDimCode(const char* PhysDim); /* Encodes Physical Dimension as 16bit integer according to ISO/IEEE 11073-10101:2004 Vital Signs Units of Measurement --------------------------------------------------------------- */ char* PhysDim(uint16_t PhysDimCode, char *PhysDimText); /* DEPRECATED: USE INSTEAD PhysDim3(uint16_t PhysDimCode) It's included just for backwards compatibility converts HDR.CHANNEL[k].PhysDimCode into a readable Physical Dimension the memory for PhysDim must be preallocated, its maximum length is defined by (MAX_LENGTH_PHYSDIM+1) --------------------------------------------------------------- */ const char* PhysDim3(uint16_t PhysDimCode); /* converts PhysDimCode into a readable Physical Dimension --------------------------------------------------------------- */ double PhysDimScale(uint16_t PhysDimCode); /* returns scaling factor of physical dimension e.g. 0.001 for milli, 1000 for kilo etc. --------------------------------------------------------------- */ #endif int biosig_set_hdr_ipaddr(HDRTYPE *hdr, const char *hostname); /* set the field HDR.IPaddr based on the IP address of hostname Return value: 0: hdr->IPaddr is set otherwise hdr->IPaddr is not set ---------------------------------------------------------------*/ /* ============================================================= printing of header information ============================================================= */ int hdr2ascii(HDRTYPE* hdr, FILE *fid, int VERBOSITY); /* writes the header information is ascii format the stream defined by fid * Typically fid is stdout. VERBOSITY defines how detailed the information is. * VERBOSITY=0 or 1 report just some basic information, * VERBOSITY=2 reports als the channel information * VERBOSITY=3 provides in addition the event table. * VERBOSITY=8 for debugging * VERBOSITY=9 for debugging * VERBOSITY=-1 header and event table is shown in JSON format --------------------------------------------------------------- */ ATT_DEPREC int hdr2json (HDRTYPE *hdr, FILE *fid); int fprintf_hdr2json(FILE *stream, HDRTYPE* hdr); /* prints header in json format into stream; hdr2json is the old form and deprecated, use fprintf_hdr2json instead --------------------------------------------------------------- */ int asprintf_hdr2json(char **str, HDRTYPE* hdr); /* prints header in json format into *str; memory for str is automatically allocated and must be freed after usage. --------------------------------------------------------------- */ HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); /* allocates memory initializes header HDR of type HDRTYPE with NS channels an N_EVENT event elements --------------------------------------------------------------- */ void destructHDR(HDRTYPE* hdr); /* destroys the header *hdr and frees allocated memory --------------------------------------------------------------- */ /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS : Level 2 **/ /** **/ /****************************************************************************/ /* ============================================================= setter and getter functions for accessing fields of HDRTYPE these functions are currently experimential and are likely to change ============================================================= */ /* get, set and check function of filetype */ enum FileFormat biosig_get_filetype(HDRTYPE *hdr); int biosig_set_filetype(HDRTYPE *hdr, enum FileFormat format); #define biosig_check_filetype(a,b) (biosig_get_filetype(a)==b) ATT_DEPREC int biosig_set_flags(HDRTYPE *hdr, char compression, char ucal, char overflowdetection); int biosig_get_flag(HDRTYPE *hdr, unsigned flags); int biosig_set_flag(HDRTYPE *hdr, unsigned flags); int biosig_reset_flag(HDRTYPE *hdr, unsigned flags); int biosig_set_targetsegment(HDRTYPE *hdr, unsigned targetsegment); int biosig_get_targetsegment(HDRTYPE *hdr); const char* biosig_get_filename(HDRTYPE *hdr); float biosig_get_version(HDRTYPE *hdr); int biosig_set_segment_selection(HDRTYPE *hdr, int k, uint32_t argSweepSel); uint32_t* biosig_get_segment_selection(HDRTYPE *hdr); // returns error message in memory allocated with strdup int biosig_check_error(HDRTYPE *hdr); char *biosig_get_errormsg(HDRTYPE *hdr); long biosig_get_number_of_channels(HDRTYPE *hdr); size_t biosig_get_number_of_samples(HDRTYPE *hdr); ATT_DEPREC size_t biosig_get_number_of_samples_per_record(HDRTYPE *hdr); size_t biosig_get_number_of_records(HDRTYPE *hdr); size_t biosig_get_number_of_segments(HDRTYPE *hdr); int biosig_set_number_of_channels(HDRTYPE *hdr, int ns); int biosig_set_number_of_samples(HDRTYPE *hdr, ssize_t nrec, ssize_t spr); #define biosig_set_number_of_samples_per_record(h,n) biosig_set_number_of_samples(h,-1,n) #define biosig_set_number_of_records(h,n) biosig_set_number_of_samples(h,n,-1) // ATT_DEPREC int biosig_set_number_of_segments(HDRTYPE *hdr, ); int biosig_get_datablock(HDRTYPE *hdr, biosig_data_type **data, size_t *rows, size_t *columns); biosig_data_type* biosig_get_data(HDRTYPE *hdr, char flag); double biosig_get_samplerate(HDRTYPE *hdr); int biosig_set_samplerate(HDRTYPE *hdr, double fs); size_t biosig_get_number_of_events(HDRTYPE *hdr); size_t biosig_set_number_of_events(HDRTYPE *hdr, size_t N); // get n-th event, variables pointing to NULL are ignored int biosig_get_nth_event(HDRTYPE *hdr, size_t n, uint16_t *typ, uint32_t *pos, uint16_t *chn, uint32_t *dur, gdf_time *timestamp, const char **desc); /* set n-th event, variables pointing to NULL are ignored typ or Desc can be used to determine the type of the event. if both, typ and Desc, are not NULL, the result is undefined */ int biosig_set_nth_event(HDRTYPE *hdr, size_t n, uint16_t* typ, uint32_t *pos, uint16_t *chn, uint32_t *dur, gdf_time *timestamp, char *Desc); double biosig_get_eventtable_samplerate(HDRTYPE *hdr); int biosig_set_eventtable_samplerate(HDRTYPE *hdr, double fs); int biosig_change_eventtable_samplerate(HDRTYPE *hdr, double fs); int biosig_get_startdatetime(HDRTYPE *hdr, struct tm *T); int biosig_set_startdatetime(HDRTYPE *hdr, struct tm T); gdf_time biosig_get_startdatetime_gdf(HDRTYPE *hdr); int biosig_set_startdatetime_gdf(HDRTYPE *hdr, gdf_time T); int biosig_get_birthdate(HDRTYPE *hdr, struct tm *T); int biosig_set_birthdate(HDRTYPE *hdr, struct tm T); const char* biosig_get_patient_name(HDRTYPE *hdr); const char* biosig_get_patient_id(HDRTYPE *hdr); const char* biosig_get_recording_id(HDRTYPE *hdr); const char* biosig_get_technician(HDRTYPE *hdr); const char* biosig_get_manufacturer_name(HDRTYPE *hdr); const char* biosig_get_manufacturer_model(HDRTYPE *hdr); const char* biosig_get_manufacturer_version(HDRTYPE *hdr); const char* biosig_get_manufacturer_serial_number(HDRTYPE *hdr); const char* biosig_get_application_specific_information(HDRTYPE *hdr); int biosig_set_patient_name(HDRTYPE *hdr, const char* rid); int biosig_set_patient_name_structured(HDRTYPE *hdr, const char* LastName, const char* FirstName, const char* SecondLastName); int biosig_set_patient_id(HDRTYPE *hdr, const char* rid); int biosig_set_recording_id(HDRTYPE *hdr, const char* rid); int biosig_set_technician(HDRTYPE *hdr, const char* rid); int biosig_set_manufacturer_name(HDRTYPE *hdr, const char* rid); int biosig_set_manufacturer_model(HDRTYPE *hdr, const char* rid); int biosig_set_manufacturer_version(HDRTYPE *hdr, const char* rid); int biosig_set_manufacturer_serial_number(HDRTYPE *hdr, const char* rid); int biosig_set_application_specific_information(HDRTYPE *hdr, const char* appinfo); double biosig_get_channel_samplerate(HDRTYPE *hdr, int chan); int biosig_set_channel_samplerate_and_samples_per_record(HDRTYPE *hdr, int chan, ssize_t spr, double fs); /* ============================================================= setter and getter functions for accessing fields of CHANNEL_TYPE these functions are currently experimential and are likely to change ============================================================= */ // returns M-th channel, M is zero-based CHANNEL_TYPE* biosig_get_channel(HDRTYPE *hdr, int M); const char* biosig_channel_get_label(CHANNEL_TYPE *chan); int biosig_channel_set_label(CHANNEL_TYPE *chan, const char* label); uint16_t biosig_channel_get_physdimcode(CHANNEL_TYPE *chan); const char* biosig_channel_get_physdim(CHANNEL_TYPE *chan); #define biosig_channel_get_unit(h) biosig_channel_get_physdim(h) int biosig_channel_set_physdimcode(CHANNEL_TYPE *chan, uint16_t physdimcode); #define biosig_channel_set_physdim(a,b) biosig_channel_set_physdimcode(a, PhysDimCode(b)) #define biosig_channel_set_unit(a,b) biosig_channel_set_physdimcode(a, PhysDimCode(b)) // this will affect result of next SREAD when flag.ucal==0 int biosig_channel_change_scale_to_physdimcode(CHANNEL_TYPE *chan, uint16_t physdimcode); #define biosig_channel_change_scale_to_unitcode(a,b) biosig_channel_set_scale_to_physdimcode(a, b) #define biosig_channel_change_scale_to_physdim(a,b) biosig_channel_set_scale_to_physdimcode(a, PhysDimCode(b)) #define biosig_channel_change_scale_to_unit(a,b) biosig_channel_set_scale_to_physdimcode(a, PhysDimCode(b)) int biosig_channel_get_scaling(CHANNEL_TYPE *chan, double *PhysMax, double *PhysMin, double *DigMax, double *DigMin); int biosig_channel_set_scaling(CHANNEL_TYPE *chan, double PhysMax, double PhysMin, double DigMax, double DigMin); double biosig_channel_get_cal(CHANNEL_TYPE *chan); double biosig_channel_get_off(CHANNEL_TYPE *chan); ATT_DEPREC int biosig_channel_set_cal(CHANNEL_TYPE *chan, double cal); ATT_DEPREC int biosig_channel_set_off(CHANNEL_TYPE *chan, double off); int biosig_channel_get_filter(CHANNEL_TYPE *chan, double *LowPass, double *HighPass, double *Notch); int biosig_channel_set_filter(CHANNEL_TYPE *chan, double LowPass, double HighPass, double Notch); double biosig_channel_get_timing_offset(CHANNEL_TYPE *hc); int biosig_channel_set_timing_offset(CHANNEL_TYPE *hc, double off); double biosig_channel_get_impedance(CHANNEL_TYPE *hc); int biosig_channel_set_impedance(CHANNEL_TYPE *hc, double val); /* double biosig_channel_get_samplerate(CHANNEL_TYPE *hc); int biosig_channel_set_samplerate_and_samples_per_record(CHANNEL_TYPE *hc, size_t spr, double val); */ size_t biosig_channel_get_samples_per_record(CHANNEL_TYPE *hc); int biosig_channel_set_samples_per_record(CHANNEL_TYPE *hc, size_t spr); uint16_t biosig_channel_get_datatype(CHANNEL_TYPE *hc); int biosig_channel_set_datatype(CHANNEL_TYPE *hc, uint16_t gdftyp); #define biosig_channel_set_datatype_to_int8(h) biosig_channel_set_datatype(h,1) #define biosig_channel_set_datatype_to_uint8(h) biosig_channel_set_datatype(h,2) #define biosig_channel_set_datatype_to_int16(h) biosig_channel_set_datatype(h,3) #define biosig_channel_set_datatype_to_uint16(h) biosig_channel_set_datatype(h,4) #define biosig_channel_set_datatype_to_int32(h) biosig_channel_set_datatype(h,5) #define biosig_channel_set_datatype_to_uint32(h) biosig_channel_set_datatype(h,6) #define biosig_channel_set_datatype_to_int64(h) biosig_channel_set_datatype(h,7) #define biosig_channel_set_datatype_to_uint64(h) biosig_channel_set_datatype(h,8) #define biosig_channel_set_datatype_to_float(h) biosig_channel_set_datatype(h,16) #define biosig_channel_set_datatype_to_single(h) biosig_channel_set_datatype(h,16) #define biosig_channel_set_datatype_to_double(h) biosig_channel_set_datatype(h,17) const char *biosig_channel_get_transducer(CHANNEL_TYPE *hc); int biosig_channel_set_transducer(CHANNEL_TYPE *hc, const char *transducer); #pragma GCC visibility pop typedef HDRTYPE *biosig_handle_t ; #if defined(MAKE_EDFLIB) // definitions according to edflib v1.09 #define edflib_version() (109) #define EDFLIB_MAX_ANNOTATION_LEN 512 #define EDFLIB_FILETYPE_EDF 0 #define EDFLIB_FILETYPE_EDFPLUS 1 #define EDFLIB_FILETYPE_BDF 2 #define EDFLIB_FILETYPE_BDFPLUS 3 #define EDFLIB_MALLOC_ERROR -1 #define EDFLIB_NO_SUCH_FILE_OR_DIRECTORY -2 #define EDFLIB_FILE_CONTAINS_FORMAT_ERRORS -3 #define EDFLIB_MAXFILES_REACHED -4 #define EDFLIB_FILE_READ_ERROR -5 #define EDFLIB_FILE_ALREADY_OPENED -6 #define EDFLIB_FILETYPE_ERROR -7 #define EDFLIB_FILE_WRITE_ERROR -8 #define EDFLIB_NUMBER_OF_SIGNALS_INVALID -9 #define EDFLIB_FILE_IS_DISCONTINUOUS -10 #define EDFLIB_INVALID_READ_ANNOTS_VALUE -11 /* values for annotations */ #define EDFLIB_DO_NOT_READ_ANNOTATIONS 0 #define EDFLIB_READ_ANNOTATIONS 1 #define EDFLIB_READ_ALL_ANNOTATIONS 2 /* the following defines are possible errors returned by edfopen_file_writeonly() */ #define EDFLIB_NO_SIGNALS -20 #define EDFLIB_TOO_MANY_SIGNALS -21 #define EDFLIB_NO_SAMPLES_IN_RECORD -22 #define EDFLIB_DIGMIN_IS_DIGMAX -23 #define EDFLIB_DIGMAX_LOWER_THAN_DIGMIN -24 #define EDFLIB_PHYSMIN_IS_PHYSMAX -25 #define EDFLIB_TIME_DIMENSION (10000000LL) #define EDFLIB_MAXSIGNALS 256 #define EDFLIB_MAX_ANNOTATION_LEN 512 #define EDFSEEK_SET 0 #define EDFSEEK_CUR 1 #define EDFSEEK_END 2 struct edf_annotation_struct { /* this structure is used for annotations */ size_t onset; /* onset time of the event, expressed in units of 100 nanoSeconds and relative to the starttime in the header */ size_t duration; /* duration time, this is a null-terminated ASCII text-string */ char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1]; /* description of the event in UTF-8, this is a null terminated string */ }; int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals); #define edfopen_file_readonly(a,c) biosig_open_file_readonly(a,c) #define edfclose_file(handle) biosig_close_file(handle) int edfread_physical_samples(int handle, int edfsignal, int n, double *buf); int edfread_digital_samples(int handle, int edfsignal, int n, int *buf); long long edfseek(int handle, int biosig_signal, long long offset, int whence); long long edftell(int handle, int biosig_signal); int edfrewind(int handle, int edfsignal); //#define edf_get_annotation(a,b,c) biosig_get_annotation(a,b,c) int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot); //#define edfopen_file_writeonly(a,b,c) biosig_open_file_writeonly(a,b,c) int biosig_open_file_writeonly(const char *path, enum FileFormat filetype, int number_of_signals); #define edf_set_samplefrequency(a,b,c) biosig_set_samplefrequency(a,b,c) #define edf_set_physical_maximum(a,b,c) biosig_set_physical_maximum(a,b,c) #define edf_set_physical_minimum(a,b,c) biosig_set_physical_minimum(a,b,c) #define edf_set_digital_maximum(a,b,c) biosig_set_digital_maximum(a,b,(double)(c)) #define edf_set_digital_minimum(a,b,c) biosig_set_digital_minimum(a,b,(double)(c)) #define edf_set_label(a,b,c) biosig_set_label(a,b,c) #define edf_set_prefilter(a,b,c) biosig_set_prefilter(a,b,c) #define edf_set_transducer(a,b,c) biosig_set_transducer(a,b,c) #define edf_set_physical_dimension(a,b,c) biosig_set_physical_dimension(a,b,c) int edf_set_startdatetime(int handle, int startdate_year, int startdate_month, int startdate_day, int starttime_hour, int starttime_minute, int starttime_second); #define edf_set_patientname(a,b) biosig_set_patientname(a,b) #define edf_set_patientcode(a,b) biosig_set_patientcode(a,b) //#define edf_set_gender(a,b) biosig_set_gender(a,b) int edf_set_gender(int handle, int gender); int edf_set_birthdate(int handle, int birthdate_year, int birthdate_month, int birthdate_day); #define edf_set_patient_additional(a,b) biosig_set_patient_additional(a,b) #define edf_set_admincode(a,b) biosig_set_admincode(a,b) #define edf_set_technician(a,b) biosig_set_technician(a,b) #define edf_set_equipment(a,b) biosig_set_equipment(a,b) int edf_set_recording_additional(int handle, const char *recording_additional); int edfwrite_physical_samples(int handle, double *buf); int edf_blockwrite_physical_samples(int handle, double *buf); int edfwrite_digital_samples(int handle, int *buf); int edf_blockwrite_digital_samples(int handle, int *buf); #define edfwrite_annotation_utf8(a,b,c,d) biosig_write_annotation_utf8(a,b,c,d) #define edfwrite_annotation_latin1(a,b,c,d) biosig_write_annotation_latin1(a,b,c,d) #define edf_set_datarecord_duration(a,b) biosig_set_datarecord_duration(a,b) #endif #ifdef __cplusplus } /* extern "C" */ #endif #endif biosig-2.3.3/biosig4c++/VERSION0000664000175000017500000000013114105434245016055 0ustar schloeglschloegl# BioSig http://biosig.sf.net/ # Version: biosig4c++/libbiosig 2.3.3 # Date: 2021-08-13 biosig-2.3.3/biosig4c++/Makefile.win320000664000175000017500000006601114105434233017414 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id$ ### Copyright (C) 2006,2007,2008,2009 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ## make save2gdf - makes converter ## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) ## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) ## make mex - mex4o and mex4m combined ## make libbiosig - makes libbiosig ## make biosig4python - makes python interface (requires Python) ## make biosig4java - makes Java interface (experimental) ## make biosig4php - makes PHP interface (experimental) ## make biosig4perl - makes perl interface (experimental) ## make biosig4ruby - makes ruby interface (experimental) ## make biosig4tcl - makes tcl/tk interface (experimental) ## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make sigviewer - makes sigviewer ############################### # whether dynamic or static linking is used, can be controlled with # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically # LIBEXT = a #LIBEXT = so ############################### ### User-specified options: its likely you want to change this MEX_OPTION = -largeArrayDims # turn on for 64 bit Matlab, otherwise empty PathToSigViewer = ../../src/sigviewer PathToSigViewerWIN32 = ../../src/sigviewer4win32 PathToMinGW = $(HOME)/R:/src/mingw-cross-env PathToMinGW64 = $(HOME)/R:/src/mce-w64 ## default options CC = gcc CXX = g++ #DEFINES = -D=WITHOUT_SCP_DECODE DEFINES = -D=HARDCODED_EVENTTABLE -D=__4HAERTEL__ -D=WITH_FAMOS #-D=WITH_FEF #D=WITH_CHOLMOD -D=WITH_ZLIB -D=WITH_PDP -D=WITH_DICOM #-D=WITH_GDCM #-D=WITH_GSL #-D=WITH_EEPROBE #-D=SOFTCODED_PHYSDIMTABLE # if you have zlib #DEFINES += -D=CNT32 CFLAGS = -pipe -fPIC -Wall -O2 -Wextra $(DEFINES) # -I cntopenlib/include/ CXXFLAGS = -pipe -fPIC -Wall -O2 -Wextra $(DEFINES) # -I cntopenlib/include/ AR = ar crs INCPATH = -I /usr/local/include/gdcm-2.0/ # ../gdcm-2.0.10/Source/DataStructureAndEncodingDefinition \ # ../gdcm-2.0.10/Source/InformationObjectDefinition \ # ../gdcm-2.0.10/Source/MediaStorageAndFileFormat \ # ../gdcm-2.0.10/Source/DataDictionary \ # ../gdcm-2.0.10/Source/Common LINK = $(CXX) LFLAGS_dynamic = -L/usr/local/lib/ -L. LIBS_dynamic = -lbiosig LFLAGS_static = -L/usr/local/lib/ LIBS_static = libbiosig.a ifeq ($(LIBEXT),so) LFLAGS = $(LFLAGS_dynamic) LIBS = $(LIBS_dynamic) else LFLAGS = $(LFLAGS_static) LIBS = $(LIBS_static) endif LDLIBS = -static-libgcc -static-libstdc++ -lws2_32 #-lgdcmDSED # static LIBS += $(LDLIBS) DELETE = rm COPY = cp -f TEMP_DIR = /tmp/ ########################################################## ## set Matlab and Octave variables ifneq ($(shell which matlab), ) MATLABDIR := $(dir $(shell readlink -f $(shell which matlab) ) ) MEX = $(MATLABDIR)mex MEX_EXT := $(shell $(MATLABDIR)mexext) endif octVER = # default OCT = mkoctfile$(octVER) ########################################################## ########################################################## ## set variables for Python SWIG = swig PYTHONVER = $(shell python -c "import sys; print sys.version[:3]") ########################################################## ########################################################## ## set variables for MinGW Crosscompiler: compile on linux binaries for windows ## CROSS = i586-mingw32msvc- CROSS = $(PathToMinGW)/usr/bin/i686-pc-mingw32- CROSS64 = $(PathToMinGW64)/usr/bin/x86_64-w64-mingw32- MinGWCC = $(CROSS)gcc MinGWCXX = $(CROSS)g++ MinGWDEF = -D=HARDCODED_EVENTTABLE -D=__4HAERTEL__ -D=WITH_FAMOS -D=WITH_CHOLMOD #-D=WITH_ZLIB #-D=WITH_FEF #-D=WITH_DICOM #-D=WITH_GDCM #-D=WITH_GSL #-D=WITH_EEPROBE #-D=SOFTCODED_PHYSDIMTABLE MinGWCFLAGS = -pipe -fPIC -O2 -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -I$(PathToMinGW)/usr/i686-pc-mingw32/include/ MinGWLIBS = win32/libbiosig.a -L$(PathToMinGW)/usr/i686-pc-mingw32/lib/ -lz -lws2_32 $(LDLIBS) # static MinGWLINK = $(MinGWCXX) ########################################################## # Versioning MAJOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MAJOR' biosig.h)) MINOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MINOR' biosig.h)) STEPPING := $(word 3, $(shell grep '\#define BIOSIG_VERSION_STEPPING' biosig.h)) TODAY := $(shell date +%Y%m%d) ####### Output directory OBJ = ./obj BIN = $(DESTDIR)/usr/bin LIB = $(DESTDIR)/usr/lib ####### Files SOURCES = biosig.c \ XMLParser/tinyxml.cpp \ XMLParser/tinyxmlparser.cpp \ XMLParser/tinyxmlerror.cpp \ XMLParser/tinystr.cpp \ t210/sopen_scp_read.c \ t210/sopen_famos_read.c \ t210/sopen_alpha_read.c \ t210/scp-decode.cpp \ t220/sopen_scp_write.c \ t220/crc4scp.c \ t230/sopen_hl7aecg.c \ t240/sopen_fef_read.c \ test0/sandbox.c \ physicalunits.c \ biosig-network.c \ save2gdf.c \ biosig_client.c \ biosig_server.c OBJECTS = \ crc4scp.o \ biosig.o \ getlogin_r.o \ tinyxml.o \ tinyxmlparser.o \ tinyxmlerror.o \ tinystr.o \ sopen_scp_read.o \ sopen_alpha_read.o \ sopen_scp_write.o \ sopen_hl7aecg.o \ biosig-network.o \ sandbox.o \ MinGWOBJECTS = \ win32/crc4scp.obj \ win32/biosig.obj \ win32/getlogin_r.obj \ win32/tinyxml.obj \ win32/tinyxmlparser.obj \ win32/tinyxmlerror.obj \ win32/tinystr.obj \ win32/sopen_scp_read.obj \ win32/sopen_alpha_read.obj \ win32/sopen_scp_write.obj \ win32/sopen_hl7aecg.obj \ win32/biosig-network.obj \ win32/sandbox.obj \ ifneq (,$(findstring WITH_FAMOS, $(DEFINES))) OBJECTS += sopen_famos_read.o endif ifneq (,$(findstring WITH_FAMOS, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_famos_read.obj endif ifneq (,$(findstring WITH_FEF, $(DEFINES))) OBJECTS += sopen_fef_read.o endif ifneq (,$(findstring WITH_FEF, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_fef_read.obj endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(DEFINES))) OBJECTS += scp-decode.o endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(MinGWDEF))) MinGWOBJECTS += win32/scp-decode.obj endif TARGET = save2gdf save2aecg save2scp libbiosig.a mex4o libbiosig.so first: $(TARGET) all: $(TARGET) mex4o biosig4python win32 biosig_client biosig_server mma java tcl perl php ruby #sigviewer lib: libbiosig.a libbiosig.so win32/libbiosig.dll libbiosig.lib ############################################################# # Compilation: Implicit, default rules ############################################################# .SUFFIXES: .o .c .cpp .cc .cxx .C .cpp.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" .cc.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" .cxx.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" .C.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" .c.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" %.o: %.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: t210/%.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: t220/%.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: t230/%.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: t240/%.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" %.o: test0/%.c biosig.h biosig-dev.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: XMLParser/%.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: %.c biosig-dev.h biosig.h $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t210/%.c biosig-dev.h biosig.h $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t220/%.c biosig-dev.h biosig.h $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t230/%.c biosig-dev.h biosig.h $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t240/%.c biosig-dev.h biosig.h $(MinGWCC) -c $(MinGWCFLAGS) -I t240 $(INCPATH) -o "$@" "$<" win32/%.obj: XMLParser/%.cpp $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" ############################################################# # event table: conversion from ascii to C code ############################################################# biosig.c: eventcodes.i eventcodes.i : ../biosig/doc/eventcodes.txt cat ../biosig/doc/eventcodes.txt | awk "-F\t" '/^[^#]/ {print "\t"$$1", \""$$2,"\","}' > eventcodes.i ############################################################# # Compilation: exceptions, explicit rules ############################################################# sandbox.o: test0/sandbox.c biosig.h $(CXX) -c $(CFLAGS) $(INCPATH) -o sandbox.o test0/sandbox.c sopen_fef_read.o: t240/sopen_fef_read.c biosig-dev.h biosig.h # cd t240 # #asn1c -fcompound-names -pdu=SessionArchiveSection -S /home/schloegl/cvs/asn1c/skeletons fef.asn1 # asn1c -fcompound-names -pdu=SessionArchiveSection fef.asn1 # #asn1c -fcompound-names iso11073-10471.asn1 # #asn1c -fcompound-names iso11073-20601.asn1 # cd .. # $(MAKE) -C t240 -f Makefile.am.sample $(CC) -c $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" sopen_hl7aecg.o: t230/sopen_hl7aecg.c biosig-dev.h biosig.h XMLParser/tinyxml.h XMLParser/tinystr.h $(CXX) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" sopen_scp_read.o: t210/sopen_scp_read.c biosig-dev.h biosig.h biosig.h t210/structures.h $(CXX) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" scp-decode.o: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" getlogin_r.o: win32/getlogin_r.c $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" #strtod.o: gnulib/strtod.c # $(CC) -c $(CFLAGS) $(INCPATH) -o strtod.o gnulib/strtod.c win32/sandbox.obj: test0/sandbox.c biosig.h $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/sopen_scp_read.obj: t210/sopen_scp_read.c biosig-dev.h biosig.h t210/structures.h $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/sopen_alpha_read.obj: t210/sopen_alpha_read.c biosig-dev.h $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/scp-decode.obj: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" #win32/sopen_fef_read.obj: t240/sopen_fef_read.c biosig-dev.h biosig.h # $(MinGWCC) -c $(MinGWCFLAGS) -I t240 $(INCPATH) -o win32/sopen_fef_read.obj t240/sopen_fef_read.c win32/sopen_hl7aecg.obj: t230/sopen_hl7aecg.c biosig-dev.h biosig.h XMLParser/tinyxml.h XMLParser/tinystr.h $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/getlogin_r.obj: win32/getlogin_r.c $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/sigviewer.exe: win32/libbiosig.a win32/libbiosig.dll -$(DELETE) $(PathToSigViewerWIN32)/extern/include/*.h -$(COPY) biosig.h $(PathToSigViewerWIN32)/extern/include -$(DELETE) $(PathToSigViewerWIN32)/extern/lib/lib* -$(COPY) win32/libbiosig.a $(PathToSigViewerWIN32)/extern/lib -(cd $(PathToSigViewerWIN32)/src; $(CROSS)qmake; make) -$(COPY) $(PathToSigViewerWIN32)/bin/sigviewer.exe win32/ ############################################################# # other language bindings (on Linux) ############################################################# biosig4python : python/_biosig.so python/biosig.py python/biosig.py python/swig_wrap.cxx: python/swig.i $(SWIG) -c++ -python -I/usr/include -I/usr/share/pyshared/numpy/core/include/numpy -o python/swig_wrap.cxx python/swig.i python/_biosig.so : python/swig_wrap.cxx libbiosig.$(LIBEXT) $(CXX) -c $(CXXFLAGS) python/swig_wrap.cxx -o python/swig_wrap.o -I/usr/include/python$(PYTHONVER) -I/usr/share/pyshared/numpy/core/include/numpy $(CXX) -shared python/swig_wrap.o $(LFLAGS) $(LIBS) -o python/_biosig.so java: libbiosig.$(LIBEXT) java/biosig.i $(MAKE) -C java perl: libbiosig.$(LIBEXT) perl/biosig.i $(MAKE) -C perl php: libbiosig.$(LIBEXT) php/biosig.i $(MAKE) -C php python: libbiosig.$(LIBEXT) python/swig.i $(MAKE) -C python ruby: libbiosig.$(LIBEXT) ruby/biosig.i $(MAKE) -C ruby tcl: libbiosig.$(LIBEXT) tcl/biosig.i $(MAKE) -C tcl ############################################################# # WIN32 - BUILD ############################################################# win32/libbiosig.lib: win32/libbiosig.a $(COPY) win32/libbiosig.a win32/libbiosig.lib win32/libbiosig.a: $(MinGWOBJECTS) win32/libcnsfef.a biosig.h biosig-dev.h -$(DELETE) win32/libbiosig.a $(CROSS)$(AR) win32/libbiosig.a $(MinGWOBJECTS) t240/*.obj win32/libcnsfef.a: make CROSS=$(CROSS) -C t240 ../win32/libcnsfef.a win32/libbiosig.dll: $(MinGWOBJECTS) biosig.h biosig-dev.h $(MinGWLINK) -shared -fPIC $(MinGWOBJECTS) $(MinGWLIBS) -o win32/libbiosig.dll -Wl,--output-def,win32/libbiosig.def,--out-implib,win32/libbiosig.dll.a -$(COPY) win32/libbiosig.dll $(PathToSigViewerWIN32)/extern/lib/ win32/save2gdf.exe: save2gdf.c win32/libbiosig.a $(MinGWLINK) $(MinGWCFLAGS) save2gdf.c $(MinGWLIBS) -o win32/save2gdf.exe win32/pdp2gdf.exe: pdp2gdf.c win32/libbiosig.a $(MinGWLINK) $(MinGWCFLAGS) pdp2gdf.c $(MinGWLIBS) -o win32/pdp2gdf.exe win32 exe: win32/save2gdf.exe win32/libbiosig.dll mma #win32/sigviewer.exe ############################################################# # GNU/Linux - BUILD ############################################################# t240/libcnsfef.a: # $(MAKE) -C t240 regen # $(MAKE) -C t240 libcnsfef.a # generate t240/*.o files libbiosig.a: $(OBJECTS) biosig.h biosig-dev.h #t240/libcnsfef.a -$(DELETE) libbiosig.a $(AR) libbiosig.a $(OBJECTS) #t240/*.o libbiosig.so: $(OBJECTS) t240/libcnsfef.a biosig.h biosig-dev.h $(CXX) -shared -fPIC -Wl,-soname,libbiosig.so.${MAJOR_VERSION} $(LDLIBS) \ -o libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(OBJECTS) t240/*.o ln -sf libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} libbiosig.so.${MAJOR_VERSION} ln -sf libbiosig.so.${MAJOR_VERSION} libbiosig.so save2gdf: save2gdf.o libbiosig.$(LIBEXT) Makefile $(LINK) $(CXXFLAGS) save2gdf.o $(LFLAGS) $(LIBS) -o save2gdf pdp2gdf: pdp2gdf.o libbiosig.$(LIBEXT) $(LINK) $(CXXFLAGS) pdp2gdf.o $(LFLAGS) $(LIBS) -o pdp2gdf physicalunits: physicalunits.o libbiosig.$(LIBEXT) $(LINK) $(CXXFLAGS) physicalunits.o $(LFLAGS) $(LIBS) -o physicalunits bscs: biosig_client biosig_server sandbox.o biosig.o biosig_client: biosig_client.c libbiosig.$(LIBEXT) biosig-network.o Makefile $(LINK) $(CXXFLAGS) biosig_client.c biosig-network.o $(LFLAGS) $(LIBS) -o biosig_client biosig_server: biosig_server.c libbiosig.$(LIBEXT) biosig-network.o Makefile $(LINK) $(CXXFLAGS) biosig_server.c biosig-network.o $(LFLAGS) $(LIBS) -o biosig_server ############################################################# # MathLink interface to Mathematica ############################################################# mma: libbiosig.a $(MAKE) -C mma -f Makefile.win32 mex mex4m mex4o mexw32 oct: $(MAKE) -C mex $@ ############################################################# # MEX-files for Octave and Matlab ############################################################# mex: $(MAKE) -C mex mex -k mex mex4m mex4o mexw32 oct: $(MAKE) -C mex $@ %.mex %.mex.$(MEX_EXT) %.mexw32: $(MAKE) -C mex $@ ############################################################# # SigViewer ############################################################# sigviewer: $(PathToSigViewer)/bin/sigviewer $(COPY) $(PathToSigViewer)/bin/release/sigviewer ~/bin/sigviewer-$(TODAY) mv $(PathToSigViewer)/bin/release/sigviewer $(PathToSigViewer)/bin/sigviewer-$(TODAY) ln -sf ~/bin/sigviewer-$(TODAY) ~/bin/sigviewer $(PathToSigViewer)/bin/sigviewer: libbiosig.$(LIBEXT) biosig.h $(COPY) -lf biosig.h $(PathToSigViewer)/extern/include/ $(COPY) -lf libbiosig.$(LIBEXT) $(PathToSigViewer)/extern/lib/ # touch $(PathToSigViewer)/tmp/basic_header.o (cd $(PathToSigViewer)/src; qmake;make;) docs: docs/save2gdf.txt docs/mexSLOAD.txt asciidoc -d manpage docs/save2gdf.txt asciidoc -d manpage docs/mexSLOAD.txt # for backward compatibility save2scp: save2gdf save2aecg: save2gdf ############################################################# # INSTALL and DE-INSTALL ############################################################# clean: -$(DELETE) *~ -$(DELETE) *.a -$(DELETE) eventcodes.i -$(DELETE) *.o -$(DELETE) *.so -$(DELETE) *.so.* -$(DELETE) *.mex* -$(DELETE) *.oct -$(DELETE) python/biosig.py* _biosig.so -$(DELETE) python/swig_wrap.* -$(DELETE) win32/*.a -$(DELETE) win32/*.lib -$(DELETE) win32/*.o -$(DELETE) win32/*.obj -$(DELETE) win32/*.exe -$(DELETE) t240/*.o -$(DELETE) t240/libcnsfef.a -$(DELETE) t240/libbiosig.* -$(DELETE) t240/*.obj -$(DELETE) pdp2gdf -$(MAKE) -C java clean -$(MAKE) -C matlab clean -$(MAKE) -C mma clean -$(MAKE) -C php clean -$(MAKE) -C perl clean -$(MAKE) -C ruby clean -$(MAKE) -C tcl clean install_sigviewer: sigviewer install $(PathToSigViewer)/bin/sigviewer $(BIN) install ../biosig/doc/eventcodes.txt $(BIN) install_octave: mexSLOAD.mex mkdir -p $(DESTDIR)/usr/local/share/octave/site-m/ install mex/mexSLOAD.mex $(DESTDIR)/usr/local/share/octave/site-m/ install mex/mexSOPEN.mex $(DESTDIR)/usr/local/share/octave/site-m/ install: save2gdf libbiosig.a libbiosig.so doc/save2gdf.1 install -d $(BIN) install save2gdf $(BIN) install save2aecg $(BIN) install save2scp $(BIN) #install rec2bin $(BIN) #install bin2rec $(BIN) install -d $(LIB) $(DESTDIR)/usr/include install biosig.h $(DESTDIR)/usr/include install libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(LIB) ln -sf libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(LIB)/libbiosig.so.${MAJOR_VERSION} ln -sf libbiosig.so.${MAJOR_VERSION} $(LIB)/libbiosig.so install libbiosig.a $(LIB) mkdir -p $(DESTDIR)/usr/share/man/man1 install doc/*.1 $(DESTDIR)/usr/share/man/man1 #install libbiosig.man $(DESTDIR)/usr/share/ #make install_sigviewer #make install_octave remove: rm $(BIN)/save2gdf rm $(BIN)/save2scp rm $(BIN)/save2aecg #rm $(BIN)/rec2bin #rm $(BIN)/bin2rec rm $(BIN)/sigviewer rm $(BIN)/eventcodes.txt rm $(DESTDIR)/usr/include/biosig.h rm $(LIB)/libbiosig.* rm $(DESTDIR)/usr/share/man/man1/save2gdf.1 rm $(DESTDIR)/usr/share/man/man1/mexSLOAD.1 rm $(DESTDIR)/usr/share/man/man1/sigviewer.1 #rm $(DESTDIR)/usr/share/man/man1/rec2bin.1 #rm $(DESTDIR)/usr/share/man/man1/bin2rec.1 ############################################################# # Testing ############################################################# # ./save2gdf -V8 ~/data/test/tms32/small_test.float32.log ./save2gdf -f=TMSi t0.scp t2.log cat t2.log $(TEMP_DIR)t1.scp: # scp example data sets wget -q -P$(TEMP_DIR) http://www.openecg.net/ECGsamples.zip wget -q -P$(TEMP_DIR) http://www.openecg.net/ECGsamplesc.zip unzip -u $(TEMP_DIR)ECGsamples.zip "scp*.zip" -d $(TEMP_DIR) unzip -u $(TEMP_DIR)ECGsamplesc.zip "scp*.zip" -d $(TEMP_DIR) mkdir -p $(TEMP_DIR)scp/high mkdir -p $(TEMP_DIR)scp/highc mkdir -p $(TEMP_DIR)scp/redred mkdir -p $(TEMP_DIR)scp/redredc unzip -u $(TEMP_DIR)scp_high.zip -d $(TEMP_DIR)scp/high unzip -u $(TEMP_DIR)scp_highc.zip -d $(TEMP_DIR)scp/highc unzip -u $(TEMP_DIR)scp_redred.zip -d $(TEMP_DIR)scp/redred unzip -u $(TEMP_DIR)scp_redredc.zip -d $(TEMP_DIR)scp/redredc rm -rf $(TEMP_DIR)ECGsamples*.zip rm -rf $(TEMP_DIR)scp*.zip $(COPY) $(TEMP_DIR)scp/redred/PFE103.scp $(TEMP_DIR)t1.scp touch $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.hl7: # HL7aECG example data set wget -q -P$(TEMP_DIR) http://hl7.org/library/committees/rcrim/annecg/aECG%20Release%201%20Schema%20and%20Example%2Ezip unzip -u "$(TEMP_DIR)aECG Release 1 Schema and Example.zip" -d $(TEMP_DIR) $(COPY) "$(TEMP_DIR)2003-12 Schema/example/Example aECG.xml" $(TEMP_DIR)t1.hl7 rm -rf "$(TEMP_DIR)aECG Release 1 Schema and Example.zip" rm -rf "$(TEMP_DIR)2003-12 Schema" touch $(TEMP_DIR)t1.hl7 $(TEMP_DIR)t1.edf: # EDF+ example data set wget -q -P$(TEMP_DIR) http://www.edfplus.info/downloads/files/osas.zip unzip -u "$(TEMP_DIR)osas.zip" -d $(TEMP_DIR) cp "$(TEMP_DIR)Osas2002plusQRS.edf" $(TEMP_DIR)t1.edf touch $(TEMP_DIR)t1.edf asc: save2gdf ./save2gdf -f=ASCII t0.xxx t1.asc bin: save2gdf ./save2gdf -f=BIN t0.xxx t1.bin testbin: save2gdf $(TEMP_DIR)t1.edf ./save2gdf -f=BIN $(TEMP_DIR)t1.edf $(TEMP_DIR)t1.hdr ./save2gdf -f=BIN $(TEMP_DIR)t1.hdr $(TEMP_DIR)t2.hdr ./save2gdf -f=GDF $(TEMP_DIR)t2.hdr $(TEMP_DIR)t2.gdf testscp: save2gdf $(TEMP_DIR)t1.scp # test converting SCP data ./save2gdf -f=HL7 $(TEMP_DIR)/t1.scp $(TEMP_DIR)/t1.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)/t1.scp.hl7 $(TEMP_DIR)/t1.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)/t1.scp.hl7.gdf $(TEMP_DIR)/t1.scp.hl7.gdf.scp ./save2gdf -f=GDF $(TEMP_DIR)/t1.scp.hl7.gdf.scp $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf $(TEMP_DIR)t1.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.hl7.scp $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf.scp testhl7: save2gdf $(TEMP_DIR)t1.hl7 # test converting HL7aECG data ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7 $(TEMP_DIR)t1.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf $(TEMP_DIR)t1.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf.scp.hl7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7 $(TEMP_DIR)t1.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp $(TEMP_DIR)t1.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp.gdf.hl7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp.hl7 test: $(TEMP_DIR)t1.scp save2scp save2aecg save2gdf # biosig4python # includes test for on-the-fly compression and decompression ./save2gdf -z $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.scp.gdf ./save2scp -z $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.scp.scp ./save2aecg -z $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.scp.hl7 ./save2gdf $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.gdf ./save2gdf $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.gdf ./save2gdf $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.gdf ./save2scp $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.scp ./save2scp $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.scp ./save2scp $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.scp ./save2aecg $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.hl7 ./save2aecg $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.hl7 ./save2aecg $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.hl7 # python test0/test.py zip: $(TEMP_DIR)t1.scp save2gdf # test for on-the-fly compression and decompression # on-the-fly compression of output file ./save2gdf -z -f=GDF $(TEMP_DIR)t1.scp t1.gdf ./save2gdf -z -f=GDF1 $(TEMP_DIR)t1.scp t1.gd1 ./save2gdf -z -f=EDF $(TEMP_DIR)t1.scp t1.edf ./save2gdf -z -f=BDF $(TEMP_DIR)t1.scp t1.bdf ./save2gdf -z -f=SCP $(TEMP_DIR)t1.scp t1.scp ./save2gdf -z -f=CFWB $(TEMP_DIR)t1.scp t1.cfw ./save2gdf -z -f=MFER $(TEMP_DIR)t1.scp t1.mwf ./save2gdf -z -f=HL7 $(TEMP_DIR)t1.scp t1.hl7 gzip -c $(TEMP_DIR)t1.scp >$(TEMP_DIR)t1.scp.gz # on-the-fly decompression of input file ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz t1.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz t1.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz t1.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz t1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz t1.hl7 ./save2gdf -f=MFER $(TEMP_DIR)t1.scp.gz t1.mwf ./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz t1.cfw test6: $(TEMP_DIR)t1.scp save2gdf $(COPY) $(TEMP_DIR)t1.scp t0.xxx #test7: $(TEMP_DIR)t1.edf save2gdf #$(COPY) $(TEMP_DIR)t1.edf t0.xxx ./save2gdf -z -f=GDF1 t0.xxx t1.gd1 ./save2gdf -z -f=GDF t0.xxx t1.gdf ./save2gdf -z -f=EDF t0.xxx t1.edf ./save2gdf -z -f=BDF t0.xxx t1.bdf ./save2gdf -z -f=SCP t0.xxx t1.scp ./save2gdf -f=HL7 t0.xxx t1.hl7 # -z not supported for HL7 gzip t1.hl7 ./save2gdf -z -f=CFWB t0.xxx t1.cfw ./save2gdf -z -f=MFER t0.xxx t1.mwf ./save2gdf -z -f=BVA t0.xxx t1.bva ./save2gdf -f=GDF1 t1.gd1.gz t2.gd1.gd1 ./save2gdf -f=GDF t1.gd1.gz t2.gd1.gdf ./save2gdf -f=EDF t1.gd1.gz t2.gd1.edf ./save2gdf -f=BDF t1.gd1.gz t2.gd1.bdf ./save2gdf -f=SCP t1.gd1.gz t2.gd1.scp ./save2gdf -f=HL7 t1.gd1.gz t2.gd1.hl7 ./save2gdf -f=CFWB t1.gd1.gz t2.gd1.cfw ./save2gdf -f=GDF1 t1.gdf.gz t2.gdf.gd1 ./save2gdf -f=GDF t1.gdf.gz t2.gdf.gdf ./save2gdf -f=EDF t1.gdf.gz t2.gdf.edf ./save2gdf -f=BDF t1.gdf.gz t2.gdf.bdf ./save2gdf -f=SCP t1.gdf.gz t2.gdf.scp ./save2gdf -f=HL7 t1.gdf.gz t2.gdf.hl7 ./save2gdf -f=CFWB t1.gdf.gz t2.gdf.cfw ./save2gdf -f=GDF1 t1.edf.gz t2.edf.gd1 ./save2gdf -f=GDF t1.edf.gz t2.edf.gdf ./save2gdf -f=EDF t1.edf.gz t2.edf.edf ./save2gdf -f=BDF t1.edf.gz t2.edf.bdf ./save2gdf -f=SCP t1.edf.gz t2.edf.scp ./save2gdf -f=HL7 t1.edf.gz t2.edf.hl7 ./save2gdf -f=CFWB t1.edf.gz t2.edf.cfw ./save2gdf -f=GDF1 t1.bdf.gz t2.bdf.gd1 ./save2gdf -f=GDF t1.bdf.gz t2.bdf.gdf ./save2gdf -f=EDF t1.bdf.gz t2.bdf.edf ./save2gdf -f=BDF t1.bdf.gz t2.bdf.bdf ./save2gdf -f=SCP t1.bdf.gz t2.bdf.scp ./save2gdf -f=HL7 t1.bdf.gz t2.bdf.hl7 ./save2gdf -f=CFWB t1.bdf.gz t2.bdf.cfw ./save2gdf -f=GDF1 t1.scp.gz t2.scp.gd1 ./save2gdf -f=GDF t1.scp.gz t2.scp.gdf ./save2gdf -f=EDF t1.scp.gz t2.scp.edf ./save2gdf -f=BDF t1.scp.gz t2.scp.bdf # ./save2gdf -f=SCP t1.scp.gz t2.scp.scp ./save2gdf -f=HL7 t1.scp.gz t2.scp.hl7 ./save2gdf -f=CFWB t1.scp.gz t2.scp.cfw ./save2gdf -f=GDF1 t1.hl7.gz t2.hl7.gd1 ./save2gdf -f=GDF t1.hl7.gz t2.hl7.gdf ./save2gdf -f=EDF t1.hl7.gz t2.hl7.edf ./save2gdf -f=BDF t1.hl7.gz t2.hl7.bdf ./save2gdf -f=SCP t1.hl7.gz t2.hl7.scp ./save2gdf -f=HL7 t1.hl7.gz t2.hl7.hl7 ./save2gdf -f=CFWB t1.hl7.gz t2.hl7.cfw ./save2gdf -f=GDF1 t1.cfw.gz t2.cfw.gd1 ./save2gdf -f=GDF t1.cfw.gz t2.cfw.gdf ./save2gdf -f=EDF t1.cfw.gz t2.cfw.edf ./save2gdf -f=BDF t1.cfw.gz t2.cfw.bdf ./save2gdf -f=SCP t1.cfw.gz t2.cfw.scp ./save2gdf -f=HL7 t1.cfw.gz t2.cfw.hl7 ./save2gdf -f=GDF1 t1.mwf.gz t2.mwf.gd1 ./save2gdf -f=GDF t1.mwf.gz t2.mwf.gdf ./save2gdf -f=EDF t1.mwf.gz t2.mwf.edf ./save2gdf -f=BDF t1.mwf.gz t2.mwf.bdf ./save2gdf -f=SCP t1.mwf.gz t2.mwf.scp ./save2gdf -f=HL7 t1.mwf.gz t2.mwf.hl7 testpybdf : $(TEMP_DIR)BDFtestfiles.zip unzip -u $(TEMP_DIR)BDFtestfiles.zip -d $(TEMP_DIR) && \ python python/demo.py $(TEMP_DIR)*-256.bdf python python/example.py $(TEMP_DIR)*-256.bdf 256 && \ python python/example.py $(TEMP_DIR)*-2048.bdf 2048 $(TEMP_DIR)BDFtestfiles.zip : wget -P$(TEMP_DIR) http://www.biosemi.com/download/BDFtestfiles.zip biosig-2.3.3/biosig4c++/win32/0000775000175000017500000000000014105434233015751 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/win32/rec2bin.bat0000775000175000017500000000106114105434233017766 0ustar schloeglschloegl: Converts data into ascii-Header and each channel into a separate binary data file : : Copyright (C) 2008,2020 Alois Schloegl : This file is part of the BioSig at https://biosig.sourceforge.io echo off echo REC2BIN is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo REC2BIN converts different biosignal data formats into the BIN format echo usage: rec2bin source dest echo usage: rec2bin -f=FMT source dest echo FMT can be BDF,BIN,CFWB,EDF,GDF,HL7aECG,SCP_ECG save2gdf.exe -f=BIN %1 %2 %3 %4 %5 %6 %7 biosig-2.3.3/biosig4c++/win32/getdelim.c0000664000175000017500000000732614105434233017717 0ustar schloeglschloegl/* getdelim.c --- Implementation of replacement getdelim function. Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2013 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, see . */ /* Ported from glibc by Simon Josefsson. */ /* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */ #if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) #define _GL_ARG_NONNULL(params) #include #include #include #include #include #if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L #include #endif #ifndef SSIZE_MAX # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif #if USE_UNLOCKED_IO # include "unlocked-io.h" # define getc_maybe_unlocked(fp) getc(fp) #elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED # undef flockfile # undef funlockfile # define flockfile(x) ((void) 0) # define funlockfile(x) ((void) 0) # define getc_maybe_unlocked(fp) getc(fp) #else # define getc_maybe_unlocked(fp) getc_unlocked(fp) #endif /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and NUL-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *N characters of space. It is realloc'ed as necessary. Returns the number of characters read (not including the null terminator), or -1 on error or EOF. */ ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) { ssize_t result; size_t cur_len = 0; if (lineptr == NULL || n == NULL || fp == NULL) { errno = EINVAL; return -1; } flockfile (fp); if (*lineptr == NULL || *n == 0) { char *new_lineptr; *n = 120; new_lineptr = (char *) realloc (*lineptr, *n); if (new_lineptr == NULL) { result = -1; goto unlock_return; } *lineptr = new_lineptr; } for (;;) { int i; i = getc_maybe_unlocked (fp); if (i == EOF) { result = -1; break; } /* Make enough space for len+1 (for final NUL) bytes. */ if (cur_len + 1 >= *n) { size_t needed_max = SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; size_t needed = 2 * *n + 1; /* Be generous. */ char *new_lineptr; if (needed_max < needed) needed = needed_max; if (cur_len + 1 >= needed) { result = -1; //errno = EOVERFLOW; goto unlock_return; } new_lineptr = (char *) realloc (*lineptr, needed); if (new_lineptr == NULL) { result = -1; goto unlock_return; } *lineptr = new_lineptr; *n = needed; } (*lineptr)[cur_len] = i; cur_len++; if (i == delimiter) break; } (*lineptr)[cur_len] = '\0'; result = cur_len ? cur_len : result; unlock_return: funlockfile (fp); /* doesn't set errno */ return result; } #endif biosig-2.3.3/biosig4c++/win32/README0000664000175000017500000000236014105434233016632 0ustar schloeglschloeglIntroduction: --------------- This directory contains the pre-compiled biosig tools for Windows platforms, Directory structure, and Files: ------------------------------- README this file bin/ binary exectutables and batch files (converters and utilities) include/ include files lib/ libbiosig and related libraries matlab/ mex files for matlab mathematica/ biosig mathlink interface [ python/ biosig module for python - not yet usable on windows ] share/ common, platform-independent files share/man manual, man pages, documentation share/matlab Biosig for Octave and Matlab share/mathematica mathematica notebook, demos how to use biosig mathlink interface share/python demos how to use biosig in python Installation: ------------- Copy the files from the current directory into some directory and setup the path manually. More information is available at http://biosig.sf.net/ If you have any questions you can also contact the mailinglist https://lists.sourceforge.net/lists/listinfo/biosig-general Copyright (C) 2008,2009,2010,2012,2020 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig-2.3.3/biosig4c++/win32/heka2itx.bat0000775000175000017500000000117114105434233020163 0ustar schloeglschloegl: Conversion of HEKA/Patchmaster data into ITX (Igor Text) format : : Copyright (C) 2008, 2011,2020 Alois Schloegl : This file is part of the BioSig http://biosig.sourceforge.io/ echo off echo HEKA2ITX is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo HEKA2ITX converts HEKA files into ITX (IgorProText) files echo usage: heka2itx source dest echo usage: heka2itx -SWEEP=ne,ng,ns source dest echo selects sweep ns from group ng from experiment ne. echo use 0 as wildcard selecting all sweeps fullfilling the criteria save2gdf.exe -f=ITX %1 %2 %3 %4 %5 %6 %7 biosig-2.3.3/biosig4c++/win32/getlogin.c0000664000175000017500000000227514105434233017733 0ustar schloeglschloegl/* Provide a working getlogin for systems which lack it. Copyright (C) 2010-2012 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 3 of the License, 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, see . */ /* Written by Bruno Haible, 2010. */ /* Specification. */ #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #endif char * getlogin (void) { #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ static char login_name[1024]; DWORD sz = sizeof (login_name); if (GetUserName (login_name, &sz)) return login_name; #endif return NULL; } biosig-2.3.3/biosig4c++/win32/save2aecg.bat0000775000175000017500000000106514105434233020306 0ustar schloeglschloegl: Converts short-term ECG data into XML-based HL7v3 Annotated ECG format : : Copyright (C) 2008,2020 Alois Schloegl : This file is part of the BioSig at http://biosig.sourceforge.io/ echo off echo REC2BIN is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo SAVE2AECG converts short-term ECG data into XML-based HL7v3 Annotated ECG format echo usage: save2aecg source dest echo usage: save2aecg -f=FMT source dest echo FMT can be BDF,BIN,CFWB,EDF,GDF,HL7aECG,SCP_ECG save2gdf.exe -f=HL7 %1 %2 %3 %4 %5 %6 %7 biosig-2.3.3/biosig4c++/win32/getline.c0000664000175000017500000000214614105434233017547 0ustar schloeglschloegl/* getline.c --- Implementation of replacement getline function. Copyright (C) 2005-2007, 2009-2013 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, see . */ /* Written by Simon Josefsson. */ #if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) #include #if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L #include #endif ssize_t getline (char **lineptr, size_t *n, FILE *stream) { return getdelim (lineptr, n, '\n', stream); } #endif biosig-2.3.3/biosig4c++/win32/bin2rec.bat0000775000175000017500000000105614105434233017772 0ustar schloeglschloegl: Conversion of ASCII-Header and binary channels into REC(GDF,EDF) data format : : Copyright (C) 2008,2020 Alois Schloegl : This file is part of the BioSig at http://biosig.sourceforge.io/ echo off echo REC2BIN is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo BIN2REC converts BIN data into other biosignal data formats (default GDF) echo usage: bin2rec source dest echo usage: bin2rec -f=FMT source dest echo FMT can be BDF,BIN,CFWB,EDF,GDF,HL7aECG,SCP_ECG save2gdf.exe -f=GDF %1 %2 %3 %4 %5 %6 %7 biosig-2.3.3/biosig4c++/win32/save2scp.bat0000775000175000017500000000103114105434233020165 0ustar schloeglschloegl: Converts short-term ECG data into EN1094 SCP-ECG format : : Copyright (C) 2008,2020 Alois Schloegl : This file is part of the BioSig at http://biosig.sourceforge.io/ echo off echo SAVE2SCP is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo SAVE2SCO converts short-term ECG data into EN1094 SCP-ECG format echo usage: save2scp source dest echo usage: save2scp -f=FMT source dest echo FMT can be BDF,BIN,CFWB,EDF,GDF,HL7aECG,SCP_ECG save2gdf.exe -f=SCP_ECG %1 %2 %3 %4 %5 %6 %7 biosig-2.3.3/biosig4c++/macports/0000775000175000017500000000000014105434233016637 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/macports/science/0000775000175000017500000000000014105434233020250 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/macports/science/libbiosig/0000775000175000017500000000000014105434233022213 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/macports/science/libbiosig/Portfile.in0000664000175000017500000000345114105434233024332 0ustar schloeglschloegl# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 # $Id$ PortSystem 1.0 PortGroup cmake 1.0 name libbiosig version BSVERSION categories science platforms darwin license GPL-3 maintainers gmx.de:christsc description I/O library for biomedical data long_description BioSig is a library for accessing files in several \ biomedical data formats (including EDF, BDF, GDF, \ BrainVision, BCI2000, CFWB, HL7aECG, SCP_ECG (EN1064), \ MFER, ACQ, CNT(Neuroscan), DEMG, EGI, EEG1100, FAMOS, \ SigmaPLpro, TMS32) homepage http://biosig.sourceforge.net/index.html master_sites sourceforge:biosig master_sites.mirror_subdir \ /BioSig%20for%20C_C++/src distname biosig4c++-${version}.src worksrcdir biosig4c++-${version} checksums rmd160 RMD160 \ sha256 SHA256 depends_build-append \ port:gawk depends_lib port:SuiteSparse \ port:zlib \ port:libiconv cmake.out_of_source yes configure.args-append \ -DUSE_SUITESPARSE=ON \ -DUSE_ZLIB=ON \ -DZLIB_INCLUDE_DIR=${prefix}/include \ -DZLIB_LIBRARY=${prefix}/lib/libz.dylib \ -DICONV_LIBRARY=${prefix}/lib/libiconv.dylib \ -DCHOLMOD_LIBRARY=${prefix}/lib/libcholmod.dylib configure.cflags-append \ -DMACPORTS configure.cxxflags-append \ -DMACPORTS livecheck.regex biosig4c\\+\\+-(\[0-9a-z.\]+)\\.src${extract.suffix} biosig-2.3.3/biosig4c++/macports/science/libbiosig/Portfile0000664000175000017500000000360114105434233023722 0ustar schloeglschloegl# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 # $Id$ PortSystem 1.0 PortGroup cmake 1.0 name libbiosig version 1.8.4 categories science platforms darwin license GPL-3 maintainers gmx.de:christsc description I/O library for biomedical data long_description BioSig is a library for accessing files in several \ biomedical data formats (including EDF, BDF, GDF, \ BrainVision, BCI2000, CFWB, HL7aECG, SCP_ECG (EN1064), \ MFER, ACQ, CNT(Neuroscan), DEMG, EGI, EEG1100, FAMOS, \ SigmaPLpro, TMS32) homepage http://biosig.sourceforge.net/index.html master_sites sourceforge:biosig master_sites.mirror_subdir \ /BioSig%20for%20C_C++/src distname biosig4c++-${version}.src worksrcdir biosig4c++-${version} checksums rmd160 0f242f403f5ea02f76d353b132d86633ec4a5dcb \ sha256 76145dabbf0dd5904e6645ed739284982064f68399e46e472e26c3fbd4c85348 depends_build-append \ port:gawk depends_lib port:SuiteSparse \ port:zlib \ port:libiconv cmake.out_of_source yes configure.args-append \ -DUSE_SUITESPARSE=ON \ -DUSE_ZLIB=ON \ -DZLIB_INCLUDE_DIR=${prefix}/include \ -DZLIB_LIBRARY=${prefix}/lib/libz.dylib \ -DICONV_LIBRARY=${prefix}/lib/libiconv.dylib \ -DCHOLMOD_LIBRARY=${prefix}/lib/libcholmod.dylib configure.cflags-append \ -DMACPORTS configure.cxxflags-append \ -DMACPORTS livecheck.regex biosig4c\\+\\+-(\[0-9a-z.\]+)\\.src${extract.suffix} biosig-2.3.3/biosig4c++/macports/insert_checksums.sh0000775000175000017500000000142714105434233022553 0ustar schloeglschloegl#! /bin/bash BSVERSION="1.8.4" MPDIR=`pwd` wget http://downloads.sourceforge.net/project/biosig/BioSig%20for%20C_C%2B%2B/src/biosig4c%2B%2B-${BSVERSION}.src.tar.gz RMD160=`openssl rmd160 -r biosig4c++-${BSVERSION}.src.tar.gz | awk '{print $1;}'` SHA256=`openssl sha256 -r biosig4c++-${BSVERSION}.src.tar.gz | awk '{print $1;}'` echo "rmd160:" ${RMD160} echo "sha256:" ${SHA256} GSED=`which gsed` if [ "${GSED}" = "" ] then GSED=`which sed` fi ${GSED} 's/RMD160/'${RMD160}'/g' ${MPDIR}/science/libbiosig/Portfile.in > ${MPDIR}/science/libbiosig/Portfile ${GSED} -i 's/SHA256/'${SHA256}'/g' ${MPDIR}/science/libbiosig/Portfile ${GSED} -i 's/BSVERSION/'${BSVERSION}'/g' ${MPDIR}/science/libbiosig/Portfile sudo portindex sudo port uninstall libbiosig sudo port clean --all libbiosig biosig-2.3.3/biosig4c++/macports/mk_diff.sh0000775000175000017500000000054114105434233020575 0ustar schloeglschloegl#! /bin/sh CURDIR=`pwd` cd ~/macports/dports git pull origin master cd $CURDIR TARGET="science/libbiosig" mkdir -p tmp/a mkdir -p tmp/b cp ~/macports/dports/$TARGET/Portfile ./tmp/a/ gsed -i '2s/.*/# $Id$/' ./tmp/a/Portfile cp $TARGET/Portfile ./tmp/b/ cd tmp PORT=`echo $TARGET | cut -d'/' -f 2` diff -ur a b > ../Portfile-$PORT.diff cd .. rm -r tmp biosig-2.3.3/biosig4c++/save2gdf.c0000664000175000017500000006326414105434233016667 0ustar schloeglschloegl/* Copyright (C) 2000,2005,2007-2020 Alois Schloegl Copyright (C) 2007 Elias Apostolopoulos This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ // T1T2 is an experimental flag for testing segment selection #define T1T2 #include #include #include #include #include #include #include #include "biosig-dev.h" #include "biosig.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #ifdef __cplusplus extern "C" { #endif int savelink(const char* filename); #ifdef __cplusplus } #endif #ifdef WITH_PDP void sopen_pdp_read(HDRTYPE *hdr); #endif int main(int argc, char **argv){ HDRTYPE *hdr; size_t count, k1, ne=0; char *source, *dest, *tmpstr; biosig_options_type biosig_options; biosig_options.free_text_event_limiter = ""; // default is no delimiter enum FileFormat SOURCE_TYPE; // type of file format struct { enum FileFormat TYPE; float VERSION; } TARGET; TARGET.TYPE=GDF; TARGET.VERSION=-1.0; int COMPRESSION_LEVEL=0; int status; uint16_t k; uint16_t chansel = 0; int TARGETSEGMENT=1; // select segment in multi-segment file format EEG1100 (Nihon Kohden) int VERBOSE = 0; char FLAG_ANON = 1; char FLAG_CSV = 0; char FLAG_JSON = 0; char FLAG_DYGRAPH = 0; char *argsweep = NULL; double t1=0.0, t2=1.0/0.0; #ifdef CHOLMOD_H char *rrFile = NULL; int refarg = 0; #endif for (k=1; k/ID e.g. bscs://129.27.3.99/9aebcc5b4eef1024 \n"); fprintf(stdout," DEST is the destination file \n"); fprintf(stdout," DEST can be also network server bscs://\n"); fprintf(stdout," The corresponding ID number is reported and a bscs-link file is stored in /tmp/.bscs\n"); fprintf(stdout,"\n Supported OPTIONS are:\n"); fprintf(stdout," -v, --version\n\tprints version information\n"); fprintf(stdout," -h, --help \n\tprints this information\n"); #ifdef T1T2 fprintf(stdout," [t0,dt]\n\tstart time and duration in seconds (do not use any spaces). \n"); fprintf(stdout,"\tTHIS FEATURE IS CURRENTLY EXPERIMENTAL !!!\n"); #endif #ifdef CHOLMOD_H fprintf(stdout," -r, --ref=MM \n\trereference data with matrix file MM. \n\tMM must be a 'MatrixMarket matrix coordinate real general' file.\n"); #endif fprintf(stdout," -f=FMT \n\tconverts data into format FMT\n"); fprintf(stdout,"\tFMT must represent a valid target file format\n"); #if defined(WITH_SCP3) fprintf(stdout,"\tCurrently are supported: HL7aECG, SCP_ECG (EN1064:2005), SCP2, SCP3, GDF, EDF, BDF, CFWB, BIN, ASCII, ATF, BVA (BrainVision)\n\tas well as HEKA v2 -> ITX\n"); #else fprintf(stdout,"\tCurrently are supported: HL7aECG, SCP_ECG (EN1064:2005), GDF, EDF, BDF, CFWB, BIN, ASCII, ATF, BVA (BrainVision)\n\tas well as HEKA v2 -> ITX\n"); #endif fprintf(stdout, " -a, --anon=yes (default)\n" "\tanonymized data processing - personalize data (name, and birthday) is not processed but ignored.\n" "\tThe patient can be still identified with the unique patient identifier (and an external database).\n" "\tThis is for many cases sufficient (e.g. for research etc.). This mode can be turn off with\n" " -n, --anon=no\n" "\tThis will process personal information like name and birthday. One might want to use this mode\n" "\twhen converting personalized patient data and no unique patient identifier is available.\n" "\tIt's recommended to pseudonize the data, or to use the patient identifier instead of patient name and birthday.\n" ); fprintf(stdout," -CSV \n\texports data into CSV file\n"); fprintf(stdout," --free-text-event-limiter=\";\"\n\tfree text of events limited to first occurrence of \";\" (only EDF+/BDF+ format)\n"); fprintf(stdout," -DYGRAPH, -f=DYGRAPH \n\tproduces JSON output for presentation with dygraphs\n"); fprintf(stdout," -JSON \n\tshows header and events in JSON format\n"); fprintf(stdout," -z=#, -z#\n\t# indicates the compression level (#=0 no compression; #=9 best compression, default #=1)\n"); fprintf(stdout," -s=#\tselect target segment # (in the multisegment file format EEG1100)\n"); fprintf(stdout," -SWEEP=ne,ng,ns\n\tsweep selection of HEKA/PM files\n\tne,ng, and ns select the number of experiment, the number of group, and the sweep number, resp.\n"); fprintf(stdout," -VERBOSE=#, verbosity level #\n\t0=silent [default], 9=debugging\n"); fprintf(stdout," --chan=CHAN\n\tselect channel CHAN (0: all channels, 1: first channel, etc.)\n"); fprintf(stdout,"\n\n"); return(0); } else if (!strncmp(argv[k],"-z",2)) { #ifdef ZLIB_H COMPRESSION_LEVEL = 1; // default char *s = argv[k] + 2; if (s[0] == '=') s++; // skip "=" if (strlen(s)>0) COMPRESSION_LEVEL = atoi(s); if (COMPRESSION_LEVEL<0 || COMPRESSION_LEVEL>9) fprintf(stderr,"Error %s: Invalid Compression Level %s\n",argv[0],argv[k]); #else fprintf(stderr,"Warning: option -z (compression) not supported. zlib not linked.\n"); #endif } else if (!strncmp(argv[k],"-VERBOSE",2)) { VERBOSE = argv[k][strlen(argv[k])-1]-48; #ifndef NDEBUG // then VERBOSE_LEVEL is not a constant but a variable VERBOSE_LEVEL = VERBOSE; #endif } else if (!strncasecmp(argv[k],"-SWEEP=",7)) { argsweep = argv[k]+6; } else if (!strcasecmp(argv[k],"-a") || !strcasecmp(argv[k],"--anon") ) FLAG_ANON = 1; else if (!strcasecmp(argv[k],"-n") || !strcasecmp(argv[k],"--anon=no") ) FLAG_ANON = 0; else if (!strcasecmp(argv[k],"-CSV")) FLAG_CSV = 1; else if (!strcasecmp(argv[k],"-JSON")) FLAG_JSON = 1; else if (!strcasecmp(argv[k],"-DYGRAPH")) FLAG_DYGRAPH = 1; else if (!strncmp(argv[k],"--free-text-event-limiter=",26)) biosig_options.free_text_event_limiter = strstr(argv[k],"=") + 1; else if (!strncmp(argv[k],"-f=",3)) { if (0) {} else if (!strncmp(argv[k],"-f=ASCII",8)) TARGET.TYPE=ASCII; else if (!strcmp(argv[k],"-f=ATF")) TARGET.TYPE=ATF; else if (!strcmp(argv[k],"-f=BDF")) TARGET.TYPE=BDF; else if (!strncmp(argv[k],"-f=BIN",6)) TARGET.TYPE=BIN; else if (!strncmp(argv[k],"-f=BVA",6)) TARGET.TYPE=BrainVision; else if (!strncmp(argv[k],"-f=CFWB",7)) TARGET.TYPE=CFWB; else if (!strcmp(argv[k],"-f=EDF")) TARGET.TYPE=EDF; else if (!strcmp(argv[k],"-f=GDF")) TARGET.TYPE=GDF; else if (!strcmp(argv[k],"-f=GDF1")) { TARGET.TYPE=GDF; TARGET.VERSION=1.0; } else if (!strcmp(argv[k],"-f=GDF2")) { TARGET.TYPE=GDF; TARGET.VERSION=2.0; } #if (BIOSIG_VERSION >= 10700) else if (!strcmp(argv[k],"-f=GDF3") && (get_biosig_version() > 0x010703) ) { TARGET.TYPE=GDF; TARGET.VERSION=3.0; } #endif else if (!strncmp(argv[k],"-f=HL7",6)) TARGET.TYPE=HL7aECG; else if (!strncmp(argv[k],"-f=CSV",6)) { FLAG_CSV = 1; } else if (!strncmp(argv[k],"-f=DYGRAPH",10)) { FLAG_DYGRAPH = 1; } else if (!strncmp(argv[k],"-f=MFER",7)) TARGET.TYPE=MFER; #if defined(WITH_SCP3) else if (!strncmp(argv[k],"-f=SCP3",7) && (get_biosig_version() > 0x010806) ) { TARGET.TYPE=SCP_ECG; TARGET.VERSION=3.0; fprintf(stderr,"WARNING %s: Specification of SCPv3 is not finalized, " "\n\tand is subject to change without further notice. " "\n\tSCP3 may be used only for experimental work" "\n\tYou are warned !!!\n",__FILE__); } #endif else if (!strncmp(argv[k],"-f=SCP",6)) { TARGET.TYPE=SCP_ECG; TARGET.VERSION=2.0; } // else if (!strncmp(argv[k],"-f=TMSi",7)) // TARGET.TYPE=TMSiLOG; else if (!strncmp(argv[k],"-f=ITX",6)) TARGET.TYPE=ITX; else { fprintf(stderr,"format %s not supported.\n",argv[k]); return(-1); } } #ifdef CHOLMOD_H else if ( !strncmp(argv[k],"-r=",3) || !strncmp(argv[k],"--ref=",6) ) { // re-referencing matrix refarg = k; } #endif else if (!strncmp(argv[k],"-s=",3)) { TARGETSEGMENT = atoi(argv[k]+3); } else if (argv[k][0]=='[' && argv[k][strlen(argv[k])-1]==']' && (tmpstr=strchr(argv[k],',')) ) { t1 = strtod(argv[k]+1,NULL); t2 = strtod(tmpstr+1,NULL); if (VERBOSE_LEVEL>7) fprintf(stdout,"[%f,%f]\n",t1,t2); } else { break; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): save2gdf: arg%i = <%s>\n",__FILE__,__LINE__, k, argv[k]); } source = NULL; dest = NULL; switch (argc - k) { case 0: fprintf(stderr,"save2gdf: missing file argument\n"); fprintf(stdout,"usage: save2gdf [options] SOURCE DEST\n"); fprintf(stdout," for more details see also save2gdf --help \n"); exit(-1); case 2: dest = argv[k+1]; case 1: source = argv[k]; } if (VERBOSE_LEVEL<0) VERBOSE=1; // default if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SAVE2GDF %s %s started \n",__FILE__,__LINE__, source, dest); fprintf(stderr,"%s %s %s\n", argv[0], source, dest); tzset(); hdr = constructHDR(0,0); // hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = ((TARGET.TYPE==BIN) || (TARGET.TYPE==SCP_ECG)); hdr->FLAG.TARGETSEGMENT = TARGETSEGMENT; hdr->FLAG.ANONYMOUS = FLAG_ANON; if (argsweep) { k = 0; do { if (VERBOSE_LEVEL>7) fprintf(stdout,"SWEEP [109] %i: %s\t",k,argsweep); hdr->AS.SegSel[k++] = strtod(argsweep+1, &argsweep); if (VERBOSE_LEVEL>7) fprintf(stdout,",%i\n",hdr->AS.SegSel[k-1]); } while (argsweep[0]==',' && (k < 5) ); } // HEKA2ITX hack if (TARGET.TYPE==ITX) { // hack: HEKA->ITX conversion will be done in SOPEN hdr->aECG = dest; } hdr = sopen_extended(source, "r", hdr, &biosig_options); #ifdef WITH_PDP if (hdr->AS.B4C_ERRNUM) { biosigERROR(hdr, 0, NULL); // reset error sopen_pdp_read(hdr); } #endif // HEKA2ITX hack if (TARGET.TYPE==ITX) { if (hdr->TYPE==HEKA) { // hack: HEKA->ITX conversion is already done in SOPEN dest = NULL; } else { fprintf(stdout,"error: only HEKA->ITX is supported - source file is not HEKA file"); biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "error: only HEKA->ITX is supported - source file is not HEKA file"); } } #ifdef CHOLMOD_H if (refarg > 0) { rrFile = strchr(argv[refarg], '=') + 1; if (RerefCHANNEL(hdr, rrFile, 1)) fprintf(stdout,"error: reading re-ref matrix %s \n",rrFile); } #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SOPEN-R finished (error %i)\n",__FILE__,__LINE__, hdr->AS.B4C_ERRNUM); if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } t1 *= hdr->SampleRate / hdr->SPR; t2 *= hdr->SampleRate / hdr->SPR; if (isnan(t1)) t1 = 0.0; if (t2+t1 > hdr->NRec) t2 = hdr->NRec - t1; if ( ( t1 - floor (t1) ) || ( t2 - floor(t2) ) ) { fprintf(stderr,"ERROR SAVE2GDF: cutting from parts of blocks not supported; t1 (%f) and t2 (%f) must be a multiple of block duration %f\n", t1,t2,hdr->SPR / hdr->SampleRate); biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "blocks must not be split"); } if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) SOPEN-R finished\n",__FILE__,__LINE__); sort_eventtable(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) event table sorted\n",__FILE__,__LINE__); if (FLAG_JSON) { fprintf_hdr2json(stdout, hdr); } else { hdr2ascii(hdr, stdout, VERBOSE); } // all channels are converted - channel selection currently not supported for (k=0; kNS; k++) { if ( (hdr->CHANNEL[k].OnOff > 0) && hdr->CHANNEL[k].SPR ) { if ((hdr->SPR/hdr->CHANNEL[k].SPR)*hdr->CHANNEL[k].SPR != hdr->SPR) fprintf(stdout,"Warning: channel %i might be decimated!\n",k+1); }; // hdr->CHANNEL[k].OnOff = 1; // convert all channels } #ifdef CHOLMOD_H int flagREREF = hdr->Calib != NULL && hdr->rerefCHANNEL != NULL; #else int flagREREF = 0; #endif hdr->FLAG.OVERFLOWDETECTION = 0; hdr->FLAG.UCAL = hdr->FLAG.UCAL && !flagREREF; hdr->FLAG.ROW_BASED_CHANNELS = flagREREF; #ifdef CHOLMOD_H if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %p %p Flag.ReRef=%i\n",__FILE__,__LINE__,hdr->Calib, hdr->rerefCHANNEL,flagREREF); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SREAD [%f,%f].\n",__FILE__,__LINE__,t1,t2); if (hdr->NRec <= 0) { // in case number of samples is not known count = sread(NULL, t1, (size_t)-1, hdr); t2 = count; } else { if (t2+t1 > hdr->NRec) t2 = hdr->NRec - t1; if ((dest != NULL) || FLAG_CSV || FLAG_DYGRAPH ) count = sread(NULL, t1, t2, hdr); } biosig_data_type* data = hdr->data.block; if ((VERBOSE_LEVEL>8) && (hdr->data.size[0]*hdr->data.size[1]>500)) fprintf(stdout,"%s (line %i): UCAL=%i %e %e %e \n",__FILE__,__LINE__,hdr->FLAG.UCAL,data[100],data[110],data[500+hdr->SPR]); if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); }; if (VERBOSE_LEVEL>7) fprintf(stdout,"\n%s (line %i): SREAD on %s successful [%i,%i].\n",__FILE__,__LINE__,hdr->FileName,(int)hdr->data.size[0],(int)hdr->data.size[1]); // fprintf(stdout,"\n %f,%f.\n",hdr->FileName,hdr->data.block[3*hdr->SPR],hdr->data.block[4*hdr->SPR]); if (VERBOSE_LEVEL>7) fprintf(stdout,"\n%s (line %i): File %s =%i/%i\n",__FILE__,__LINE__,hdr->FileName,hdr->FILE.OPEN,hdr->FILE.Des); if ((dest==NULL) && !FLAG_CSV && !FLAG_DYGRAPH) { if (ne) /* used for testig SFLUSH_GDF_EVENT_TABLE */ { if (hdr->EVENT.N > ne) hdr->EVENT.N -= ne; else hdr->EVENT.N = 0; // fprintf(stdout,"Status-SFLUSH %i\n",sflush_gdf_event_table(hdr)); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): going for SCLOSE\n",__FILE__,__LINE__); sclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SCLOSE(HDR) finished\n",__FILE__,__LINE__); status=serror2(hdr); destructHDR(hdr); exit(status); } if (hdr->FILE.OPEN) { sclose(hdr); free(hdr->AS.Header); hdr->AS.Header = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): file closed\n",__FILE__,__LINE__); } if (VERBOSE_LEVEL>7 ) fprintf(stdout,"\n%s (line %i): File %s closed sd=%i/%i\n",__FILE__,__LINE__,hdr->FileName,hdr->FILE.OPEN,hdr->FILE.Des); SOURCE_TYPE = hdr->TYPE; if (FLAG_DYGRAPH) TARGET.TYPE=SOURCE_TYPE; hdr->TYPE = TARGET.TYPE; if (TARGET.VERSION>=0) hdr->VERSION = TARGET.VERSION; hdr->FILE.COMPRESSION = COMPRESSION_LEVEL; /******************************************* make block size as small as possible *******************************************/ if (1) { uint32_t asGCD=hdr->SPR; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff && hdr->CHANNEL[k].SPR) asGCD = gcd(asGCD, hdr->CHANNEL[k].SPR); if (TARGET.TYPE==EDF) { double d = asGCD / hdr->SampleRate; if (d==ceil(d)) asGCD = d; // make block duration 1 second } hdr->SPR /= asGCD; hdr->NRec *= asGCD; for (k=0; kNS; k++) hdr->CHANNEL[k].SPR /= asGCD; #ifdef CHOLMOD_H if (hdr->Calib) for (k=0; kCalib->ncol; k++) hdr->rerefCHANNEL[k].SPR /= asGCD; #endif } /********************************* re-referencing *********************************/ #ifdef CHOLMOD_H if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %p %p\n",__FILE__,__LINE__,hdr->CHANNEL,hdr->rerefCHANNEL); if (hdr->Calib && hdr->rerefCHANNEL) { if (VERBOSE_LEVEL>6) hdr2ascii(hdr,stdout,3); hdr->NS = hdr->Calib->ncol; free(hdr->CHANNEL); hdr->CHANNEL = hdr->rerefCHANNEL; hdr->rerefCHANNEL = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"[200-]\n"); RerefCHANNEL(hdr, NULL, 0); // clear HDR.Calib und HDR.rerefCHANNEL if (VERBOSE_LEVEL>7) fprintf(stdout,"[200+]\n"); hdr->Calib = NULL; if (VERBOSE_LEVEL>6) hdr2ascii(hdr,stdout,3); } #endif /********************************* Write data *********************************/ //************ identify Max/Min ********** if (VERBOSE_LEVEL>7) fprintf(stdout,"[201]\n"); double PhysMaxValue0 = -INFINITY; //hdr->data.block[0]; double PhysMinValue0 = +INFINITY; //hdr->data.block[0]; biosig_data_type val = NAN; char FLAG_CONVERSION_TESTED = 1; size_t N; #ifdef T1T2 N = hdr->FLAG.ROW_BASED_CHANNELS ? hdr->data.size[1] : hdr->data.size[0]; hdr->NRec = N/hdr->SPR; #else N = hdr->NRec*hdr->SPR; #endif typeof(hdr->NS) k2=0; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff && hdr->CHANNEL[k].SPR) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): #%i %i %i N=%i [%i,%i]\n",__FILE__,__LINE__,(int)k,(int)k2,(int)hdr->FLAG.ROW_BASED_CHANNELS,(int)N,(int)hdr->data.size[0],(int)(hdr->data.size[1])); double MaxValue; double MinValue; double MaxValueF; double MinValueF; double MaxValueD; double MinValueD; if (hdr->FLAG.ROW_BASED_CHANNELS) { MaxValue = hdr->data.block[k2]; MinValue = hdr->data.block[k2]; for (k1=1; k1data.block[k2 + k1*hdr->data.size[0]]; if (MaxValue < val) MaxValue = val; if (MinValue > val) MinValue = val; } } else { MaxValue = hdr->data.block[k2*N]; MinValue = hdr->data.block[k2*N]; for (k1=1; k1data.block[k2*N + k1]; if (MaxValue < val) MaxValue = val; if (MinValue > val) MinValue = val; } } if (!hdr->FLAG.UCAL) { MaxValueF = MaxValue; MinValueF = MinValue; MaxValueD = (MaxValue - hdr->CHANNEL[k].Off) / hdr->CHANNEL[k].Cal; MinValueD = (MinValue - hdr->CHANNEL[k].Off) / hdr->CHANNEL[k].Cal; } else { MaxValueF = MaxValue * hdr->CHANNEL[k].Cal + hdr->CHANNEL[k].Off; MinValueF = MinValue * hdr->CHANNEL[k].Cal + hdr->CHANNEL[k].Off; MaxValueD = MaxValue; MinValueD = MinValue; } if (PhysMaxValue0 < MaxValueF) PhysMaxValue0 = MaxValueF; if (PhysMinValue0 > MinValueF) PhysMinValue0 = MinValueF; if ((SOURCE_TYPE==alpha) && (hdr->CHANNEL[k].GDFTYP==(255+12)) && (TARGET.TYPE==GDF)) // 12 bit into 16 bit ; //hdr->CHANNEL[k].GDFTYP = 3; else if ((SOURCE_TYPE==ETG4000) && (TARGET.TYPE==GDF)) { hdr->CHANNEL[k].GDFTYP = 16; hdr->CHANNEL[k].PhysMax = MaxValueF; hdr->CHANNEL[k].PhysMin = MinValueF; hdr->CHANNEL[k].DigMax = MaxValueD; hdr->CHANNEL[k].DigMin = MinValueD; } /* TODO: check whether this is really needed - was probably just a workaround for another bug else if ((SOURCE_TYPE==GDF) && (TARGET.TYPE==GDF)) ; else if (SOURCE_TYPE==HEKA) ; else if (SOURCE_TYPE==ABF) ; */ else if (TARGET.TYPE==SCP_ECG && !hdr->FLAG.UCAL) { double scale = PhysDimScale(hdr->CHANNEL[k].PhysDimCode) *1e9; if (hdr->FLAG.ROW_BASED_CHANNELS) { for (k1=0; k1data.block[k2 + k1*hdr->data.size[0]] *= scale; } else { for (k1=0; k1data.block[k2*N + k1] *= scale; } hdr->CHANNEL[k].GDFTYP = 3; hdr->CHANNEL[k].PhysDimCode = 4276; // nV hdr->CHANNEL[k].DigMax = ldexp(1.0,15)-1.0; hdr->CHANNEL[k].DigMin = -hdr->CHANNEL[k].DigMax; double PhysMax = max(fabs(PhysMaxValue0),fabs(PhysMinValue0)) * scale; hdr->CHANNEL[k].PhysMax = PhysMax; hdr->CHANNEL[k].PhysMin = -PhysMax; } else if (TARGET.TYPE==EDF) { hdr->CHANNEL[k].GDFTYP = 3; hdr->CHANNEL[k].DigMax = ldexp(1.0,15)-1.0; hdr->CHANNEL[k].DigMin = -hdr->CHANNEL[k].DigMax; hdr->CHANNEL[k].PhysMax = MaxValueF; hdr->CHANNEL[k].PhysMin = MinValueF; hdr->CHANNEL[k].Cal = (hdr->CHANNEL[k].PhysMax - hdr->CHANNEL[k].PhysMin) / (hdr->CHANNEL[k].DigMax - hdr->CHANNEL[k].DigMin); hdr->CHANNEL[k].Off = hdr->CHANNEL[k].PhysMin - hdr->CHANNEL[k].DigMin * hdr->CHANNEL[k].Cal; } else if ((SOURCE_TYPE==EDF) && (TARGET.TYPE==GDF)) { // do nothing } else if ((hdr->CHANNEL[k].GDFTYP<10 ) && (TARGET.TYPE==GDF || TARGET.TYPE==CFWB)) { /* heuristic to determine optimal data type */ if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): #%i %i %f %f %f %f %f %f\n",__FILE__,__LINE__,k+1,(int)hdr->FLAG.UCAL,MinValue,MaxValue,MinValueF,MaxValueF,MinValueD,MaxValueD); if ((MaxValueD <= 127) && (MinValueD >= -128)) hdr->CHANNEL[k].GDFTYP = 1; else if ((MaxValueD <= 255.0) && (MinValueD >= 0.0)) hdr->CHANNEL[k].GDFTYP = 2; else if ((MaxValueD <= ldexp(1.0,15)-1.0) && (MinValueD >= ldexp(-1.0,15))) hdr->CHANNEL[k].GDFTYP = 3; else if ((MaxValueD <= ldexp(1.0,16)-1.0) && (MinValueD >= 0.0)) hdr->CHANNEL[k].GDFTYP = 4; else if ((MaxValueD <= ldexp(1.0,31)-1.0) && (MinValueD >= ldexp(-1.0,31))) hdr->CHANNEL[k].GDFTYP = 5; else if ((MaxValueD <= ldexp(1.0,32)-1.0) && (MinValueD >= 0.0)) hdr->CHANNEL[k].GDFTYP = 6; } else { FLAG_CONVERSION_TESTED = 0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"#%3d %d [%g %g][%g %g]\n",k,hdr->CHANNEL[k].GDFTYP,MinValue,MaxValue,PhysMinValue0,PhysMaxValue0); k2++; } if (!FLAG_CONVERSION_TESTED) fprintf(stderr,"Warning SAVE2GDF: conversion from %s to %s not tested\n",GetFileTypeString(SOURCE_TYPE),GetFileTypeString(TARGET.TYPE)); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): UCAL=%i\n",__FILE__,__LINE__, hdr->FLAG.UCAL); hdr->FLAG.ANONYMOUS = FLAG_ANON; /* keep header data from previous file, in might contain optional data (GDF Header3, EventDescription, hdr->SCP.SectionX, etc. ) and might still be referenced and needed. */ void *tmpmem = hdr->AS.Header; hdr->AS.Header = NULL; if (FLAG_CSV) { const char SEP=','; FILE *fid = stdout; if (dest != NULL) fid = fopen(dest,"wt+"); ssize_t k1; size_t k2; char flag = 0; for (k2 = 0; k2 < hdr->NS; k2++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k2; if (hc->OnOff) { if (flag) fprintf(fid,"%c",SEP); flag = 1; fprintf(fid,"\"%s [%s]\"", hc->Label, PhysDim3(hc->PhysDimCode) ); } } for (k1 = 0; k1 < hdr->SPR*hdr->NRec; k1++) { flag = 0; for (k2 = 0; k2 < hdr->NS; k2++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k2; if (hc->OnOff) { fprintf(fid,"%c", flag ? SEP : '\n'); flag = 1; size_t p = hdr->FLAG.ROW_BASED_CHANNELS ? hdr->data.size[0] * k1 + k2 : hdr->data.size[0] * k2 + k1 ; fprintf(fid,"%g", data[p]); } } } fprintf(fid,"\n"); if (dest != NULL) fclose(fid); } else if (FLAG_DYGRAPH) { FILE *fid = stdout; if (dest != NULL) fid = fopen(dest,"wb+"); fprintf(fid,"{\n\"Header\": "); fprintf_hdr2json(fid, hdr); fprintf(fid,",\n\"Data\": [ "); ssize_t k1; size_t k2; for (k1=0; k1 < hdr->SPR * hdr->NRec; k1++) { if (k1>0) fprintf(fid,",\n\t"); fprintf(fid,"["); for (k2=0; k2NS; k2++) { if (k2>0) fprintf(fid,", "); size_t p = hdr->FLAG.ROW_BASED_CHANNELS ? hdr->data.size[0] * k1 + k2 : hdr->data.size[0] * k2 + k1 ; fprintf(fid,"%g",data[p]); } fprintf(fid,"]"); } fprintf(fid," ],\n\"labels\": [ "); for (k2=0; k2NS; k2++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k2; if (k2>0) fprintf(fid,", "); fprintf(fid,"\"%s [%s]\"",hc->Label,PhysDim3(hc->PhysDimCode)); } fprintf(fid,"]\n}\n"); if (dest != NULL) fclose(fid); } else { /* write file */ size_t destlen = strlen(dest); char *tmp = (char*)malloc(destlen+4); strcpy(tmp,dest); if (hdr->FILE.COMPRESSION) // add .gz extension to filename strcpy(tmp+destlen,".gz"); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) z=%i sd=%i\n",__FILE__,__LINE__,hdr->FILE.COMPRESSION,hdr->FILE.Des); sopen(tmp, "wb", hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"returned from sopen-wb\n"); free(tmp); if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } #ifndef WITHOUT_NETWORK if (hdr->FILE.Des>0) savelink(source); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"\n%s (line %i): File %s opened. %i %i %i Des=%i\n",__FILE__,__LINE__,hdr->FileName,hdr->AS.bpb,hdr->NS,(int)(hdr->NRec),hdr->FILE.Des); swrite(data, hdr->NRec, hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SWRITE finishes (errno=%i)\n",__FILE__,__LINE__,(int)hdr->AS.B4C_ERRNUM); if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SWRITE finishes %i\n",__FILE__,__LINE__,(int)status); sclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SCLOSE finished\n",__FILE__,__LINE__); } status = serror2(hdr); destructHDR(hdr); if (tmpmem != NULL) free(tmpmem); exit(status); } biosig-2.3.3/biosig4c++/biosig-network.c0000664000175000017500000005573414105434233020134 0ustar schloeglschloegl/* Copyright (C) 2009,2015,2016 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include "biosig-network.h" #ifdef _WIN32 #define TC (char*) // WINSOCK's send and recv require (char*)buf #if 0 /* these functions have a different name under windows, MinGW für windows requires these */ int creat(const char *path, mode_t mode) { // return(OpenFile(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); return(OpenFile(path, , OF_WRITE|OF_CREAT )); } ssize_t write(int fildes, const void *buf, size_t nbyte) { ssize_t sz; WriteFile(fildes, buf, nbyte, &sz, NULL) return(sz); } int close(int fildes) { return(CloseFile(fildes)); { } // the following ones are not used /* int open(const char *path, int oflag) { return(OpenFile(path, oflag)); } int open(const char *path, int oflag, mode_t mode ) { return(OpenFile(path, oflag, mode)); } ssize_t read(int fildes, const void *buf, size_t nbyte) { return(ReadFile(fildes, buf, nbyte)); } */ #endif #else #define TC #endif uint64_t B4C_ID=0; // ID of currently open file const char *B4C_HOSTNAME = NULL; uint32_t SERVER_STATE; // state of server, useful for preliminary error checking /* converts 64bit integer into hex string */ int c64ta(uint64_t ID, char *txt) { const char hex[] = "0123456789abcdef"; int k=(BSCS_ID_BITLEN>>2)-1; for (; k>=0; k--) { txt[k] = hex[ID & 0x0f]; ID>>=4; } txt[BSCS_ID_BITLEN>>2] = 0; if (VERBOSE_LEVEL>8) fprintf(stdout,"c64ta: ID=%016"PRIx64" TXT=%s\n",ID,txt); return 0; } /* converts hex string into 64bit integer */ int cat64(char* txt, uint64_t *id) { uint64_t ID = 0; int k = 0; for (; txt[k] && (k<(BSCS_ID_BITLEN>>2));k++) { ID<<=4; if (isdigit(txt[k])) ID += txt[k]-'0'; else if (isxdigit(txt[k])) ID += toupper(txt[k])-'A'+10; else { *id = -1; return(-1); } } *id = ID; if (VERBOSE_LEVEL>8) fprintf(stdout,"cat64: ID=%016"PRIx64" TXT=%s\n",ID,txt); return(0); } // get sockaddr, IPv4 or IPv6: void *get_in_addr(struct sockaddr *sa) { if (sa->sa_family == AF_INET) { return &(((struct sockaddr_in*)sa)->sin_addr); } #ifndef _WIN32 return &(((struct sockaddr_in6*)sa)->sin6_addr); #else return(NULL); #endif } /**************************************************************************************** OPEN CONNECTION TO SERVER ****************************************************************************************/ int bscs_connect(const char* hostname) { int sd; struct sockaddr_in localAddr; if (hostname==NULL) hostname = "129.27.3.99"; B4C_HOSTNAME = hostname; #ifdef _WIN32 WSADATA wsadata; if (WSAStartup(MAKEWORD(1,1), &wsadata) == SOCKET_ERROR) { fprintf(stderr,"Error creating socket."); return(BSCS_CANNOT_CONNECT); } #endif int status; #if 1 // IPv4 and IPv6 struct addrinfo hints; struct addrinfo *result, *p; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = SOCK_STREAM; // TCP stream sockets hints.ai_flags = 0; hints.ai_protocol = 0; /* Any protocol */ status = getaddrinfo(hostname, NULL, &hints, &result); if (status != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status)); return(BSCS_UNKNOWN_HOST); } // loop through all the results and connect to the first we can #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif for(p = result; p != NULL; p = p->ai_next) { char hostname1[NI_MAXHOST] = ""; int error = getnameinfo(p->ai_addr, p->ai_addrlen, hostname1, NI_MAXHOST, NULL, 0, 0); if (*hostname1) printf("hostname: %s\n", hostname1); if ((sd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("client: socket"); continue; } if (connect(sd, p->ai_addr, p->ai_addrlen) != -1) break; close(sd); } if (p == NULL) { fprintf(stderr, "client: failed to connect\n"); #ifdef _WIN32 WSACleanup(); #endif return(BSCS_CANNOT_CONNECT); } char s[INET6_ADDRSTRLEN]; #if !defined(_WIN32) // FIXME: does not compile with MXE for TARGET "i686-w64-mingw32.static" inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s, sizeof(s)); #else strcpy(s," [Icannot get server name - NET_NTOP() not available]"); #endif printf("client: connecting to %s\n", s); freeaddrinfo(result); // all done with this structure #else // IPv4 only struct hostent *h; struct sockaddr_in sain; h = gethostbyname(hostname); if(h==NULL) return(BSCS_UNKNOWN_HOST); sain.sin_family = h->h_addrtype; memcpy((char *) &sain.sin_addr.s_addr, h->h_addr_list[0],h->h_length); sain.sin_port = htons(SERVER_PORT); /* create socket */ sd = socket(AF_INET, SOCK_STREAM, 0); if(sd<0) return(BSCS_CANNOT_OPEN_SOCKET); /* bind any port number */ localAddr.sin_family = AF_INET; localAddr.sin_addr.s_addr = htonl(INADDR_ANY); localAddr.sin_port = htons(0); /* connect to server */ int rc = connect(sd, (struct sockaddr *) &sain, sizeof(sain)); if(rc<0) return(BSCS_CANNOT_CONNECT); #endif /* identification */ mesg_t msg; recv(sd,TC&msg,8,0); int len = be32toh(msg.LEN); if ((msg.STATE & (VER_MASK|CMD_MASK)) != (BSCS_VERSION_01 | BSCS_SEND_MSG)) // currently only V0.1 is supported { close(sd); return(BSCS_SERVER_NOT_SUPPORTED); } char *greeting = (char*)malloc(len+1); recv(sd,greeting,len,0); greeting[len]=0; //fprintf(stdout,"%s",greeting); free(greeting); return(sd); } /**************************************************************************************** CLOSE CONNECTION TO SERVER ****************************************************************************************/ int bscs_disconnect(int sd) { close(sd); #ifdef _WIN32 WSACleanup(); #endif } int send_packet(int sd, uint32_t state, uint32_t len, void* load) { mesg_t msg; msg.STATE = state; msg.LEN = htobe32(len); send(sd, TC &msg, 8, 0); if (len>0) send(sd, TC load, len, 0); } /* stores a bscs link file on client side for the currently open network file is stored in the directory "/tmp/" */ int savelink(const char* filename) { if ((SERVER_STATE & STATE_MASK)==STATE_INIT) return(-1); char *logpath = "/tmp/"; // perhaps some other directory const char *ext = ".bscs"; const char *fn = strrchr(filename,FILESEP); if (fn==NULL) fn = filename; else fn++; size_t l1 = strlen(logpath); size_t l2 = strlen(fn); size_t l3 = strlen(ext); size_t l4 = 10; char *logfile = (char*)malloc(l1+l2+l3+l4+1); memcpy(logfile, logpath, l1); memcpy(logfile+l1, fn, l2); strcpy(logfile+l1+l2, ext); int k=0; size_t sl = strlen(logfile); FILE *fid; // check whether file already exists while ((fid=fopen(logfile,"r")) != NULL) { fclose(fid); snprintf(logfile+sl, l4, ".%i", k); k++; } errno = 0; // fopen caused errno=2; reset errno fprintf(stdout,"savelink %s\n",logfile); fid = fopen(logfile,"w"); fprintf(fid,"bscs://%s/%016"PRIx64"\n",B4C_HOSTNAME,B4C_ID); fclose(fid); free(logfile); } /**************************************************************************************** OPEN FILE with ID ****************************************************************************************/ int bscs_open(int sd, uint64_t* ID) { if (SERVER_STATE != STATE_INIT) return(BSCS_ERROR); size_t LEN; mesg_t msg; if (*ID==0) { msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_W | STATE_INIT | BSCS_NO_ERROR; LEN = 0; } else { msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_R | STATE_INIT | BSCS_NO_ERROR; *(uint64_t*)&msg.LOAD = leu64p(ID); LEN = BSCS_ID_BITLEN>>3; } if (VERBOSE_LEVEL>8) fprintf(stdout,"open: %16"PRIx64" %016"PRIx64"\n",*ID,*(uint64_t*)&(msg.LOAD)); msg.LEN = htobe32(LEN); int s = send(sd, TC &msg, LEN+8, 0); // wait for reply ssize_t count = 0; count = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"BSCS_OPEN %i:%"PRIiPTR": ID=%16"PRIx64" LEN=%"PRIx32" STATE=0x%08"PRIx32"\n",s,count,*ID,msg.LEN,be32toh(msg.STATE)); if ((*ID==0) && (LEN==8) && (msg.STATE==(BSCS_VERSION_01 | BSCS_OPEN_W | BSCS_REPLY | STATE_OPEN_WRITE_HDR | BSCS_NO_ERROR)) ) { // write access: get new ID count += recv(sd, TC ID, LEN, 0); *ID = htole64(*ID); B4C_ID = *ID; return(0); } if ((*ID != 0) && (LEN==0) && (msg.STATE==(BSCS_VERSION_01 | BSCS_OPEN_R | BSCS_REPLY | STATE_OPEN_READ | BSCS_NO_ERROR)) ) { ; // read access return(0); } uint8_t buf[8]; count = 0; while (LEN > (size_t)count) { count += recv(sd, TC &buf, min(8,LEN-count), 0); // invalid packet or error opening file } if (VERBOSE_LEVEL>7) fprintf(stdout,"ERR: state= %08"PRIx32" %08"PRIx32" len=%"PRIiPTR"\n",htobe32(msg.STATE),BSCS_VERSION_01 | BSCS_OPEN_R | BSCS_REPLY | STATE_OPEN_READ | BSCS_NO_ERROR,LEN); return(msg.STATE); } /**************************************************************************************** CLOSE FILE ****************************************************************************************/ int bscs_close(int sd) { int s; size_t LEN; mesg_t msg; msg.STATE = BSCS_VERSION_01 | BSCS_CLOSE | BSCS_NO_ERROR | SERVER_STATE; if (VERBOSE_LEVEL>8) fprintf(stdout,"close1: %08"PRIx32" \n",msg.STATE); msg.LEN = htobe32(0); if (VERBOSE_LEVEL>8) fprintf(stdout,"close2: %08"PRIx32" %"PRIiPTR" %"PRIi32"\n",msg.STATE,sizeof(msg),msg.LEN); s = send(sd, TC &msg, 8, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"close3: %08"PRIx32" %i\n",msg.STATE,s); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"s=%i state= %08"PRIx32" len=%"PRIiPTR" %i %08"PRIx32"\n",s,msg.STATE & ~STATE_MASK,LEN,s,(BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY)); if ((LEN==0) && ((msg.STATE & ~STATE_MASK)==(BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY | BSCS_NO_ERROR)) ) // close without error return(0); if ((LEN==0) && ((msg.STATE & ~STATE_MASK & ~ERR_MASK)==(BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY)) ) // close with error return(msg.STATE & ERR_MASK); // invalid packet or error opening file if (VERBOSE_LEVEL>8) fprintf(stdout,"ERR: state= %08"PRIx32" len=%"PRIiPTR"\n",msg.STATE,LEN); return(msg.STATE); } /**************************************************************************************** SEND HEADER ****************************************************************************************/ int bscs_send_hdr(int sd, HDRTYPE *hdr) { /* hdr->AS.Header must contain GDF header information hdr->HeadLen must contain header length -------------------------------------------------------------- */ // ToDo: convert HDR into AS.Header if (SERVER_STATE != STATE_OPEN_WRITE_HDR) return(BSCS_ERROR); mesg_t msg; hdr->TYPE = GDF; hdr->FLAG.ANONYMOUS = 1; // do not store name struct2gdfbin(hdr); msg.STATE = BSCS_VERSION_01 | BSCS_SEND_HDR | STATE_OPEN_WRITE_HDR | BSCS_NO_ERROR; msg.LEN = htobe32(hdr->HeadLen); int s = send(sd, TC &msg, 8, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR %i %i\n",hdr->HeadLen,s); s = send(sd, TC hdr->AS.Header, hdr->HeadLen, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR %i %i\n",hdr->HeadLen,s); // wait for reply ssize_t count = recv(sd, TC &msg, 8, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR %i %i %"PRIiPTR" %08"PRIx32"\n",hdr->HeadLen,s,count,msg.STATE); size_t LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if ((LEN==0) && (msg.STATE==(BSCS_VERSION_01 | BSCS_SEND_HDR | BSCS_REPLY | STATE_OPEN_WRITE | BSCS_NO_ERROR)) ) // close without error return(0); if ((LEN==0) && ((msg.STATE & ~ERR_MASK)==(BSCS_VERSION_01 | BSCS_SEND_HDR | BSCS_REPLY | STATE_OPEN_WRITE_HDR)) ) // could not write header return((msg.STATE & ~ERR_MASK) | BSCS_ERROR_COULD_NOT_WRITE_HDR); // invalid packet or error opening file return(msg.STATE); } /**************************************************************************************** SEND DATA ****************************************************************************************/ int bscs_send_dat(int sd, void* buf, size_t len ) { if (SERVER_STATE != STATE_OPEN_WRITE) return(BSCS_ERROR); size_t LEN; mesg_t msg; msg.STATE = BSCS_VERSION_01 | BSCS_SEND_DAT | STATE_OPEN_WRITE | BSCS_NO_ERROR; msg.LEN = htobe32(len); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND DAT %"PRIiPTR" %08"PRIx32"\n",len,msg.STATE); ssize_t s; s = send(sd, TC &msg, 8, 0); s = send(sd, TC buf, len, 0); if (errno) fprintf(stdout,"SND DAT ERR=%i %s\n",errno,strerror(errno)); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND DAT %"PRIiPTR" %08"PRIx32" %"PRIiPTR" \n",len,msg.STATE,s); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"SND DAT RPLY %"PRIiPTR" %08"PRIx32" \n",s,msg.STATE); if ((LEN==0) && (msg.STATE==(BSCS_VERSION_01 | BSCS_SEND_DAT | BSCS_REPLY | STATE_OPEN_WRITE | BSCS_NO_ERROR)) ) // end without error return(0); if (LEN>0) return (BSCS_VERSION_01 | BSCS_SEND_DAT | BSCS_REPLY | STATE_OPEN_WRITE | BSCS_INCORRECT_REPLY_PACKET_LENGTH); if ((msg.STATE & ~ERR_MASK)==(BSCS_VERSION_01 | BSCS_SEND_DAT | BSCS_REPLY | STATE_OPEN_WRITE)) // could not write header return ((msg.STATE & ~ERR_MASK) | BSCS_ERROR_COULD_NOT_WRITE_DAT); // invalid packet or error opening file return(msg.STATE); } /**************************************************************************************** SEND EVENTS ****************************************************************************************/ int bscs_send_evt(int sd, HDRTYPE *hdr) { if (SERVER_STATE != STATE_OPEN_WRITE) return(BSCS_ERROR); int sze; char flag; size_t LEN; mesg_t msg; if ((hdr->EVENT.DUR!=NULL) && (hdr->EVENT.CHN!=NULL)) { sze = 12; flag = 3; } else { sze = 6; flag = 1; } size_t len = hdrEVT2rawEVT(hdr); if (VERBOSE_LEVEL>8) fprintf(stdout,"write evt: len=%"PRIiPTR"\n",len); msg.STATE = BSCS_VERSION_01 | BSCS_SEND_EVT | STATE_OPEN_WRITE | BSCS_NO_ERROR; msg.LEN = htobe32(len); int s1 = send(sd, TC &msg, 8, 0); int s2 = send(sd, TC hdr->AS.rawEventData, len, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"write evt2: %08"PRIx32" len=%"PRIiPTR"\n",msg.STATE,len); // wait for reply ssize_t count = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"write evt2: %08"PRIx32" len=%"PRIiPTR" count=%"PRIiPTR"\n",msg.STATE,LEN,count); if ((LEN==0) && (msg.STATE==(BSCS_VERSION_01 | BSCS_SEND_EVT | BSCS_REPLY | STATE_OPEN_WRITE | BSCS_NO_ERROR)) ) // close without error return(0); if (LEN>0) return (BSCS_VERSION_01 | BSCS_SEND_EVT | BSCS_REPLY | STATE_OPEN_WRITE | BSCS_INCORRECT_REPLY_PACKET_LENGTH); if (msg.STATE & ERR_MASK) // could not write evt return (BSCS_ERROR_COULD_NOT_WRITE_EVT); // invalid packet or error opening file return(msg.STATE); } /**************************************************************************************** REQUEST HEADER ****************************************************************************************/ int bscs_requ_hdr(int sd, HDRTYPE *hdr) { mesg_t msg; int count; if (SERVER_STATE != STATE_OPEN_READ) return(BSCS_ERROR); msg.STATE = BSCS_VERSION_01 | BSCS_REQU_HDR | BSCS_NO_ERROR | (SERVER_STATE & STATE_MASK); msg.LEN = 0; count = send(sd, TC &msg, 8, 0); count = recv(sd, TC &msg, 8, 0); hdr->HeadLen = be32toh(msg.LEN); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); hdr->TYPE = GDF; count = 0; while (hdr->HeadLen > (size_t)count) { count += recv(sd, TC hdr->AS.Header+count, hdr->HeadLen-count, 0); } if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ HDR: %i %s\n",count,GetFileTypeString(hdr->TYPE)); hdr->FLAG.ANONYMOUS = 1; // do not store name gdfbin2struct(hdr); return(count-hdr->HeadLen); } /**************************************************************************************** REQUEST DATA ****************************************************************************************/ ssize_t bscs_requ_dat(int sd, size_t start, size_t length, HDRTYPE *hdr) { /* bufsiz should be equal to hdr->AS.bpb*length */ mesg_t msg; size_t LEN; if (SERVER_STATE != STATE_OPEN_READ) return(BSCS_ERROR); msg.STATE = BSCS_VERSION_01 | BSCS_REQU_DAT | BSCS_NO_ERROR | (SERVER_STATE & STATE_MASK); msg.LEN = htobe32(8); leu32a(length,msg.LOAD+0); leu32a(start, msg.LOAD+4); int s = send(sd, TC &msg, 16, 0); ssize_t count = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata,LEN); count = 0; while (LEN > (size_t)count) { count += recv(sd, TC hdr->AS.rawdata+count, LEN-count, 0); } hdr->AS.first = start; if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ DAT: %"PRIiPTR" %i\n",count,hdr->AS.bpb); hdr->AS.length= (hdr->AS.bpb ? (size_t)count/hdr->AS.bpb : length); if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ DAT: %"PRIiPTR" %"PRIiPTR"\n",hdr->AS.first,hdr->AS.length); return(0); } /**************************************************************************************** REQUEST EVENT TABLE ****************************************************************************************/ int bscs_requ_evt(int sd, HDRTYPE *hdr) { mesg_t msg; size_t LEN; if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ EVT %08x %08x\n",SERVER_STATE, STATE_OPEN_READ); if (SERVER_STATE != STATE_OPEN_READ) return(BSCS_ERROR); msg.STATE = BSCS_VERSION_01 | BSCS_REQU_EVT | BSCS_NO_ERROR | (SERVER_STATE & STATE_MASK); msg.LEN = htobe32(0); int s = send(sd, TC &msg, 8, 0); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ EVT: %i %"PRIiPTR" \n",s,LEN); if (LEN>0) { hdr->AS.rawEventData = (uint8_t*)realloc(hdr->AS.rawEventData,LEN); int count = 0; while (LEN > (size_t)count) { count += recv(sd, TC hdr->AS.rawEventData+count, LEN-count, 0); } rawEVT2hdrEVT(hdr, count); // TODO: replace this function because it is inefficient } if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ EVT: %i %"PRIiPTR" \n",s,LEN); #if 0 uint8_t *buf = hdr->AS.rawEventData; if (hdr->VERSION < 1.94) { if (buf[1] | buf[2] | buf[3]) hdr->EVENT.SampleRate = buf[1] + (buf[2] + buf[3]*256.0)*256.0; else { fprintf(stdout,"Warning GDF v1: SampleRate in Eventtable is not set in %s !!!\n",hdr->FileName); hdr->EVENT.SampleRate = hdr->SampleRate; } hdr->EVENT.N = leu32p(buf + 4); } else { hdr->EVENT.N = buf[1] + (buf[2] + buf[3]*256)*256; hdr->EVENT.SampleRate = lef32p(buf + 4); } int sze = (buf[0]>1) ? 12 : 6; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP) ); #endif return(0); } /**************************************************************************************** PUT FILE ****************************************************************************************/ int bscs_put_file(int sd, char *filename) { size_t LEN; mesg_t msg; if (SERVER_STATE != STATE_OPEN_WRITE_HDR) return(BSCS_ERROR); struct stat FileBuf; stat(filename,&FileBuf); LEN = FileBuf.st_size; if (VERBOSE_LEVEL>8) fprintf(stdout,"PUT FILE(1) %s\n",filename); // int sdi = open(filename,O_RDONLY); // if (sdi<=0) return(BSCS_ERROR); FILE *fid = fopen(filename,"r"); if (fid==NULL) return(BSCS_ERROR); msg.STATE = BSCS_VERSION_01 | BSCS_PUT_FILE | STATE_OPEN_WRITE_HDR | BSCS_NO_ERROR; msg.LEN = htobe32(LEN); int s1 = send(sd, TC &msg, 8, 0); //if (VERBOSE_LEVEL>8) fprintf(stdout,"PUT FILE(2) %i %i\n",LEN,sdi); const unsigned BUFLEN = 1024; char buf[BUFLEN]; size_t count = 0; while (count7) fprintf(stdout,"%"PRIiPTR" LEN=%"PRIiPTR" %08x %08x %08x %08x\n",count,LEN,msg.STATE, BSCS_PUT_FILE | BSCS_REPLY , STATE_INIT, (BSCS_VERSION_01 | BSCS_PUT_FILE | BSCS_REPLY | STATE_INIT | BSCS_NO_ERROR)); if ((LEN==0) && (msg.STATE==(BSCS_VERSION_01 | BSCS_PUT_FILE | BSCS_REPLY | STATE_INIT | BSCS_NO_ERROR)) ) // close without error return(0); if (LEN>0) return (BSCS_VERSION_01 | BSCS_PUT_FILE | BSCS_REPLY | STATE_INIT | BSCS_ERROR); // invalid packet or error opening file return(msg.STATE); } /**************************************************************************************** GET FILE ****************************************************************************************/ int bscs_get_file(int sd, uint64_t ID, char *filename) { size_t LEN; mesg_t msg; #if _WIN32 mode_t mode = S_IRUSR | S_IWUSR; #else mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; #endif int sdo = creat(filename, mode); if (VERBOSE_LEVEL>7) fprintf(stdout,"get file (1) %i\n",sdo); msg.STATE = BSCS_VERSION_01 | BSCS_GET_FILE | STATE_INIT | BSCS_NO_ERROR; leu64a(ID, &msg.LOAD); LEN = BSCS_ID_BITLEN>>3; msg.LEN = htobe32(LEN); int s = send(sd, TC &msg, LEN+8, 0); if (VERBOSE_LEVEL>7) fprintf(stdout,"get file (1)\n"); // wait for reply ssize_t count = recv(sd, TC &msg, 8, 0); LEN = be32toh(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>7) fprintf(stdout,"get file (3) %"PRIiPTR"\n",LEN); const unsigned BUFLEN = 1024; char buf[BUFLEN]; count = 0; size_t len = 0; while ((size_t)count < LEN) { size_t len = recv(sd, buf, min(LEN - count,BUFLEN), 0); count+=write(sdo,buf,len); } if (VERBOSE_LEVEL>7) fprintf(stdout,"get file (1) %"PRIiPTR"\n",count); close(sdo); if (LEN-count) return(msg.STATE); else // close without error return(0); } /**************************************************************************************** NO OPERATION ****************************************************************************************/ int bscs_nop(int sd) { size_t LEN; mesg_t msg; msg.STATE = BSCS_NOP | SERVER_STATE; msg.LEN = htobe32(0); int s = send(sd, TC &msg, 8, 0); } biosig-2.3.3/biosig4c++/CMakeLists.txt0000664000175000017500000001043514105434233017552 0ustar schloeglschloeglcmake_minimum_required (VERSION 2.6) project (libbiosig) option (USE_ZLIB "Add support for compressed files." OFF) option (USE_SUITESPARSE "Add support for automatic re-referencing." OFF) # Version number set (libbiosig_VERSION_MAJOR 1) set (libbiosig_VERSION_MINOR 8) set (libbiosig_VERSION_PATCH 4) find_program (GAWK NAMES gawk) add_custom_target (eventcodes COMMAND ${GAWK} -f eventcodes.awk extern/eventcodes.txt WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS eventcodes.awk extern/eventcodes.txt ) add_custom_target (units COMMAND ${GAWK} -f units.awk extern/units.csv > "units.i" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS units.awk extern/units.csv ) add_custom_target (annexb COMMAND ${GAWK} -f annotatedECG.awk extern/11073-10102-AnnexB.txt > "11073-10102-AnnexB.i" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS annotatedECG.awk extern/11073-10102-AnnexB.txt ) set (headers t210/abfheadr.h XMLParser/tinyxml.h XMLParser/tinystr.h biosig.h gdftime.h physicalunits.h ) set (sources t210/sopen_abf_read.c t210/sopen_alpha_read.c t210/sopen_axg_read.c t210/sopen_cfs_read.c t210/sopen_heka_read.c t210/sopen_igor.c t210/sopen_scp_read.c t210/scp-decode.cpp t220/crc4scp.c t220/sopen_scp_write.c t230/sopen_hl7aecg.cpp test0/sandbox.c XMLParser/tinystr.cpp XMLParser/tinyxml.cpp XMLParser/tinyxmlerror.cpp XMLParser/tinyxmlparser.cpp biosig.c gdftime.c mdc_ecg_codes.c physicalunits.c ) if (WIN32) list (APPEND sources win32/getdelim.c win32/getline.c win32/getlogin.c ) endif () if (APPLE) list (APPEND sources win32/getdelim.c win32/getline.c ) endif () # Cannot have same name for static and shared library, # so we'll correct that later on add_library (biosigstatic STATIC ${headers} ${sources} ) set_target_properties(biosigstatic PROPERTIES OUTPUT_NAME biosig) add_library (biosig2static STATIC ${headers} biosig2.h biosig-dev.h ${sources} biosig2.c ) set_target_properties(biosig2static PROPERTIES OUTPUT_NAME biosig2) add_library (biosigshared SHARED ${headers} ${sources} ) set_target_properties(biosigshared PROPERTIES OUTPUT_NAME biosig) if (APPLE) set_target_properties(biosigshared PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" ) endif () add_library (biosig2shared SHARED ${headers} biosig2.h biosig-dev.h ${sources} biosig2.c ) set_target_properties(biosig2shared PROPERTIES OUTPUT_NAME biosig2) if (APPLE) set_target_properties(biosigshared PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" ) endif () add_dependencies (biosigstatic eventcodes units annexb) add_dependencies (biosigshared eventcodes units annexb) add_dependencies (biosig2static eventcodes units annexb) add_dependencies (biosig2shared eventcodes units annexb) FIND_LIBRARY( ICONV_LIBRARY NAMES iconv ) MARK_AS_ADVANCED( ICONV_LIBRARY ) target_link_libraries( biosigstatic ${ICONV_LIBRARY} ) target_link_libraries( biosigshared ${ICONV_LIBRARY} ) target_link_libraries( biosig2static ${ICONV_LIBRARY} ) target_link_libraries( biosig2shared ${ICONV_LIBRARY} ) if (USE_ZLIB) add_definitions (-D=WITH_ZLIB) find_package( ZLIB REQUIRED ) if ( ZLIB_FOUND ) include_directories( ${ZLIB_INCLUDE_DIRS} ) target_link_libraries( biosigstatic ${ZLIB_LIBRARIES} ) target_link_libraries( biosigshared ${ZLIB_LIBRARIES} ) target_link_libraries( biosig2static ${ZLIB_LIBRARIES} ) target_link_libraries( biosig2shared ${ZLIB_LIBRARIES} ) endif( ZLIB_FOUND ) endif () if (USE_SUITESPARSE) add_definitions (-D=WITH_CHOLMOD) FIND_LIBRARY( CHOLMOD_LIBRARY NAMES cholmod ) MARK_AS_ADVANCED( CHOLMOD_LIBRARY ) target_link_libraries( biosigstatic ${CHOLMOD_LIBRARY} ) target_link_libraries( biosigshared ${CHOLMOD_LIBRARY} ) target_link_libraries( biosig2static ${CHOLMOD_LIBRARY} ) target_link_libraries( biosig2shared ${CHOLMOD_LIBRARY} ) endif () add_definitions (-D=WITHOUT_NETWORK) install (TARGETS biosigstatic DESTINATION lib) install (TARGETS biosigshared DESTINATION lib) install (TARGETS biosig2static DESTINATION lib) install (TARGETS biosig2shared DESTINATION lib) install (FILES biosig.h DESTINATION include) install (FILES biosig2.h DESTINATION include) install (FILES biosig-dev.h DESTINATION include) install (FILES gdftime.h DESTINATION include) biosig-2.3.3/biosig4c++/igor/0000775000175000017500000000000014105434244015751 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/igor/Makefile.in0000664000175000017500000000735514105434233020026 0ustar schloeglschloegl# Makefile for XOP interface to Igor # This is experimental for testing the use of MinGW for XOP's # # Copyright 2010 A. Schloegl # configure your cross-compiler and path to IGOR XOP toolkit CROSS = i586-mingw32msvc- CROSS = $(HOME)/src/mingw-cross-env/usr/bin/i686-pc-mingw32- # define path to XOP toolkit #IGORDIR = $(HOME)/.wine/drive_c/Program\ Files/WaveMetrics/XOP\ Toolkit\ 6/IgorXOPs6 IGORDIR = $(HOME)/.wine/drive_c/Program\ Files/WaveMetrics/XOP\ Toolkit\ 5/IgorXOPs5 ##### start of Makefile: XOP1 = $(IGORDIR)/XOP1/XOP1.c GBDIR = $(IGORDIR)/GBLoadWave INCDIR = -I$(IGORDIR)/XOPSupport/ INCDIR += -I$(IGORDIR)/XOP1/ INCDIR += -I$(IGORDIR)/GBLoadWave/ INCDIR += -I. LIBS += $(IGORDIR)/XOPSupport/VC6/XOPSupport.lib LIBS += ../win32/libbiosig.a ../win32/zlib/lib/libz.a -lws2_32 LIBS += -lversion -lmsvcrt -lcomdlg32 CC = g++ DEFINES = -D=WINIGOR -D=_WINDOWS_ all:XOP1.xop XOPas.xop GBLoadWave.xop GBLoadWaveres.o: $(GBDIR)/GBLoadWave.rc $(CROSS)windres $(DEFINES) $(INCDIR) $(GBDIR)/GBLoadWave.rc -o GBLoadWaveres.o GBLoadWave.o: $(GBDIR)/GBLoadWave.c $(CROSS)$(CC) -shared -c -o GBLoadWave.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWave.c GBLoadWaveDialog.o: $(GBDIR)/GBLoadWaveDialog.c $(CROSS)$(CC) -shared -c -o GBLoadWaveDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveDialog.c GBLoadWaveOperation.o: $(GBDIR)/GBLoadWaveOperation.c $(CROSS)$(CC) -shared -c -o GBLoadWaveOperation.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveOperation.c GBScalingDialog.o: $(GBDIR)/GBScalingDialog.c $(CROSS)$(CC) -shared -c -o GBScalingDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBScalingDialog.c GBLoadWaveDialog.o: $(GBDIR)/GBLoadWaveDialog.c $(CROSS)$(CC) -shared -c -o GBLoadWaveDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveDialog.c GBLoadWave.xop: GBLoadWave.o GBLoadWaveres.o GBLoadWaveOperation.o GBLoadWaveDialog.o GBScalingDialog.o XOPDialogsWin.o libIgor.a XOPSupport.o XOPFiles.o $(CROSS)$(CC) -shared -o GBLoadWave.xop GBLoadWave.o GBLoadWaveOperation.o GBLoadWaveDialog.o GBScalingDialog.o XOPDialogsWin.o GBLoadWaveres.o XOPSupport.o XOPFiles.o $(LIBS) libIgor.a xopSLOAD.o:xopSLOAD.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) xopSLOAD.c -o xopSLOAD.o -c #xopSLOAD.xop:libIgor.a XOPSupport.o # $(CROSS)$(CC) -shared -o xopSLOAD.xop $(DEFINES) $(INCDIR) xopSLOAD.c XOPSupport.o $(LIBS) libIgor.a xopSLOAD.xop: xopSLOAD.o libIgor.a XOPSupport.o $(CROSS)$(CC) -shared -o xopSLOAD.xop xopSLOAD.o XOPSupport.o $(LIBS) libIgor.a libIgor.a: $(IGORDIR)/XOPSupport/IGOR.lib $(CROSS)reimp -c --as $(CROSS)as --dlltool $(CROSS)dlltool $(IGORDIR)/XOPSupport/IGOR.lib XOPDialogsWin.o:$(IGORDIR)/XOPSupport/XOPDialogsWin.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPDialogsWin.c -o XOPDialogsWin.o -c XOPSupport.o:$(IGORDIR)/XOPSupport/XOPSupport.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPSupport.c -o XOPSupport.o -c XOPFiles.o:$(IGORDIR)/XOPSupport/XOPFiles.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPFiles.c -o XOPFiles.o -c ## compiling XOP1: this should work XOP1res.o:$(IGORDIR)/XOP1/XOP1.rc $(CROSS)windres $(DEFINES) $(INCDIR) $(IGORDIR)/XOP1/XOP1.rc -o XOP1res.o XOP1.xop: XOPSupport.o libIgor.a XOP1res.o $(CROSS)$(CC) -shared -o XOP1.xop $(DEFINES) $(INCDIR) $(XOP1) XOP1res.o XOPSupport.o $(LIBS) libIgor.a ## testing a modified XOP1 XOPasres.o:XOPas.rc $(CROSS)windres $(DEFINES) $(INCDIR) XOPas.rc -o XOPasres.o XOPas.o:XOPas.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) XOPas.c -o XOPas.o -c XOPas.xop:XOPas.o XOPSupport.o libIgor.a XOPasres.o $(CROSS)$(CC) -shared -o XOPas.xop XOPas.o XOPasres.o XOPSupport.o $(LIBS) libIgor.a clean: rm *.o *.xop *.exe biosig-2.3.3/biosig4c++/igor/IgorBin.h0000664000175000017500000002221114105434233017447 0ustar schloeglschloegl/* Copyright (C) 2013 Alois Schloegl Copyright (C) 1999 Wavematrix, Inc. Lake Oswego OR, USA This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ // IgorBin.h -- structures and #defines for dealing with Igor binary data. #include #ifdef __cplusplus extern "C" { #endif // All structures written to disk are 2-byte-aligned. #if __GNUC__ #pragma pack(push,2) /* igor uses a 32bit memory model, all pointers are 32 bit. in order to keep the structs containing poiners aligned, all pointers need to be remapped to uint32_t. */ #define ptr_t uint32_t #define Handle uint32_t #elif GENERATINGPOWERPC #pragma options align=mac68k #endif // From IgorMath.h #define NT_CMPLX 1 // Complex numbers. #define NT_FP32 2 // 32 bit fp numbers. #define NT_FP64 4 // 64 bit fp numbers. #define NT_I8 8 // 8 bit signed integer. Requires Igor Pro 2.0 or later. #define NT_I16 0x10 // 16 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_I32 0x20 // 32 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_UNSIGNED 0x40 // Makes above signed integers unsigned. Requires Igor Pro 3.0 or later. // From wave.h #define MAXDIMS 4 // From binary.h typedef struct BinHeader1 { int16_t version; // Version number for backwards compatibility. int32_t wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. int16_t checksum; // Checksum over this header and the wave header. } BinHeader1; typedef struct BinHeader2 { int16_t version; // Version number for backwards compatibility. int32_t wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. int32_t noteSize; // The size of the note text. int32_t pictSize; // Reserved. Write zero. Ignore on read. int16_t checksum; // Checksum over this header and the wave header. } BinHeader2; typedef struct BinHeader3 { int16_t version; // Version number for backwards compatibility. int32_t wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. int32_t noteSize; // The size of the note text. int32_t formulaSize; // The size of the dependency formula, if any. int32_t pictSize; // Reserved. Write zero. Ignore on read. int16_t checksum; // Checksum over this header and the wave header. } BinHeader3; typedef struct BinHeader5 { int16_t version; // Version number for backwards compatibility. int16_t checksum; // Checksum over this header and the wave header. int32_t wfmSize; // The size of the WaveHeader5 data structure plus the wave data. int32_t formulaSize; // The size of the dependency formula, if any. int32_t noteSize; // The size of the note text. int32_t dataEUnitsSize; // The size of optional extended data units. int32_t dimEUnitsSize[MAXDIMS]; // The size of optional extended dimension units. int32_t dimLabelsSize[MAXDIMS]; // The size of optional dimension labels. int32_t sIndicesSize; // The size of string indicies if this is a text wave. int32_t optionsSize1; // Reserved. Write zero. Ignore on read. int32_t optionsSize2; // Reserved. Write zero. Ignore on read. } BinHeader5; // From wave.h #define MAX_WAVE_NAME2 18 // Maximum length of wave name in version 1 and 2 files. Does not include the trailing null. #define MAX_WAVE_NAME5 31 // Maximum length of wave name in version 5 files. Does not include the trailing null. #define MAX_UNIT_CHARS 3 // Header to an array of waveform data. struct WaveHeader2 { int16_t type; // See types (e.g. NT_FP64) above. Zero for text waves. // struct WaveHeader2 **next; // Used in memory only. Write zero. Ignore on read. ptr_t next; char bname[MAX_WAVE_NAME2+2]; // Name of wave plus trailing null. int16_t whVersion; // Write 0. Ignore on read. int16_t srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char xUnits[MAX_UNIT_CHARS+1]; // Natural x-axis units go here - null if none. int32_t npnts; // Number of data points in wave. int16_t aModified; // Used in memory only. Write zero. Ignore on read. double hsA,hsB; // X value for point p = hsA*p + hsB int16_t wModified; // Used in memory only. Write zero. Ignore on read. int16_t swModified; // Used in memory only. Write zero. Ignore on read. int16_t fsValid; // True if full scale values have meaning. double topFullScale,botFullScale; // The min full scale value for wave. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. //void **formula; // Used in memory only. Write zero. Ignore on read. ptr_t formula; int32_t depID; // Used in memory only. Write zero. Ignore on read. uint32_t creationDate; // DateTime of creation. Not used in version 1 files. char wUnused[2]; // Reserved. Write zero. Ignore on read. uint32_t modDate; // DateTime of last modification. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. float wData[4]; // The start of the array of waveform data. }; typedef struct WaveHeader2 WaveHeader2; typedef WaveHeader2 *WavePtr2; typedef WavePtr2 *waveHandle2; struct WaveHeader5 { //struct WaveHeader5 **next; // link to next wave in linked list. ptr_t next; uint32_t creationDate; // DateTime of creation. uint32_t modDate; // DateTime of last modification. int32_t npnts; // Total number of points (multiply dimensions up to first zero). int16_t type; // See types (e.g. NT_FP64) above. Zero for text waves. int16_t dLock; // Reserved. Write zero. Ignore on read. char whpad1[6]; // Reserved. Write zero. Ignore on read. int16_t whVersion; // Write 1. Ignore on read. char bname[MAX_WAVE_NAME5+1]; // Name of wave plus trailing null. int32_t whpad2; // Reserved. Write zero. Ignore on read. //struct DataFolder **dFolder; // Used in memory only. Write zero. Ignore on read. ptr_t dFolder; // Dimensioning info. [0] == rows, [1] == cols etc int32_t nDim[MAXDIMS]; // Number of of items in a dimension -- 0 means no data. double sfA[MAXDIMS]; // Index value for element e of dimension d = sfA[d]*e + sfB[d]. double sfB[MAXDIMS]; // SI units char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char dimUnits[MAXDIMS][MAX_UNIT_CHARS+1]; // Natural dimension units go here - null if none. int16_t fsValid; // TRUE if full scale values have meaning. int16_t whpad3; // Reserved. Write zero. Ignore on read. double topFullScale,botFullScale; // The max and max full scale value for wave. Handle dataEUnits; // Used in memory only. Write zero. Ignore on read. Handle dimEUnits[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle dimLabels[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. int32_t whUnused[16]; // Reserved. Write zero. Ignore on read. // The following stuff is considered private to Igor. int16_t aModified; // Used in memory only. Write zero. Ignore on read. int16_t wModified; // Used in memory only. Write zero. Ignore on read. int16_t swModified; // Used in memory only. Write zero. Ignore on read. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. //void **formula; // Used in memory only. Write zero. Ignore on read. ptr_t formula; int32_t depID; // Used in memory only. Write zero. Ignore on read. int16_t whpad4; // Reserved. Write zero. Ignore on read. int16_t srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. //int32_t **sIndices; // Used in memory only. Write zero. Ignore on read. ptr_t sIndices; float wData[1]; // The start of the array of data. Must be 64 bit aligned. }; typedef struct WaveHeader5 WaveHeader5; typedef WaveHeader5 *WavePtr5; typedef WavePtr5 *WaveHandle5; #if __GNUC__ #pragma pack(pop) #undef ptr_t #undef Handle #elif GENERATINGPOWERPC #pragma options align=reset #endif // All structures written to disk are 2-byte-aligned. #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/igor/xopSLOAD.c0000664000175000017500000001011314105434233017500 0ustar schloeglschloegl// // UFPE_BioSig.c // Biosig interface in IGOR // #include "../biosig.h" #include "XOPStandardHeaders.h" // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h static HDRTYPE *hdr = NULL; int xopSLOAD( void * ); // ...Handle FName; Handle sRes; }* p) /* int UFPE_BioSigOpen( void * ); // ...Handle FName; Handle sRes; }* p) int UFPE_BioSigClose( void * ); // double hnd; Handle sRes; }* p) int UFPE_BioSigRead( void * ); // double hnd; Handle sRes; }* p) */ ///////////////////////////////////////////////////////////////////////////////////////// // SAME ORDER HERE IN '(*sFunc[])' AND IN UF_UtilsWinCustom.RC /* int (*)sFunc(void)[] = // Der Name der Direct Call method // Funktion or Message method Used that often { { UFPE_BioSigOpen }, { UFPE_BioSigClose }, // { UFPE_BioSigRead }, { NULL } // Endemarkierung }; */ //////////////////////////////////////////////////////////////////////// typedef struct { char *FileName; waveHndl data; double res; HDRTYPE* hdr;} inSLOAD_t; typedef struct { char *FileName; double res; } inSOpen_t; typedef struct { double res; } inSClose_t; int sload( inSLOAD_t* p) // IGOR wrapper for Biosig.SLoad() { // read header hdr = sopen( p->FileName, "r", hdr ); p->res = serror2(hdr); if (p->res) return(0); // read data biosig_data_type* data = NULL; sread(data, 0, -1, hdr); p->res = serror2(hdr); if (p->res) return(0); // close file sclose(hdr); p->res = serror2(hdr); return(0); } int UFPE_BioSigOpen( inSOpen_t* p) // IGOR wrapper for Biosig.SOpen() { int hState; hdr = sopen( p->FileName, "r", hdr ); p->res = (double)hdr->AS.B4C_ERRNUM; // if ( hdr->AS.B4C_ERRNUM ) { char buf[500]; sprintf( buf, "\t\tUFPE_BioSigOpen...receives '%s' : %s, returns code=%d \r", p->FileName, hdr->AS.B4C_ERRMSG, hdr->AS.B4C_ERRNUM ); XOPNotice( buf ); hdr->AS.B4C_ERRNUM = B4C_NO_ERROR; } p->res = 0; return 0; // Returning 0 prevents IGOR from doing anything with the error (no error box, no debugger) } int UFPE_BioSigClose( inSClose_t *p) { short code = sclose( hdr ); p->res = serror2(hdr); // ..we return the error code to the calling function. After having done all that... return 0; // ..we don't want IGOR to do anything with the error (no error box, no debugger) } /* int UFPE_BioSigRead( struct { double ErrMode; waveHndl wDataADS; double Bytes; double StartOffset; double DataSection; double hnd; double res; }* p) // IGOR wrappper for CFS ReadData() // Difference to CFS: as IGOR doesn't know pointers the CFS buffer is passed as a wave { short hnd = (short)p->hnd; WORD DataSection = (WORD)p->DataSection; long StartOffset = (long)p->StartOffset; WORD Bytes = (WORD)p->Bytes; short code; void *Raw; // DebugPrintWaveProperties( "UFPE_CfsReadData ", p->wDataADS ); // 050128 if ( p->wDataADS == NIL ) // check if wave handle is valid { SetNaN64( &p->res ); // return NaN if wave is not valid return( NON_EXISTENT_WAVE ); } if ( WaveType(p->wDataADS) != NT_I16 ) // check wave's numeric type { SetNaN64( &p->res ); // return NaN if wave is not 2Byte int return( IS_NOT_2BYTE_INT_WAVE ); } Raw = WaveData( p->wDataADS ); // char pointer to IGOR wave data code = ReadData( hnd, DataSection, StartOffset, Bytes, Raw ); if ( code < 0 ) PrintFileError( (int)p->ErrMode ); p->res = (double)code; // We handle the errors here, but we also return the error code to the calling function return 0; // ..we don't want IGOR to do anything with the error (no error box, no debugger) } // END OF BIOSIG INTERFACE ///////////////////////////////////////////////////////////////////////////////////////// */ biosig-2.3.3/biosig4c++/igor/tn003/0000775000175000017500000000000014105434233016613 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/igor/tn003/IgorBin.h0000664000175000017500000001776114105434233020331 0ustar schloeglschloegl// IgorBin.h -- structures and #defines for dealing with Igor binary data. #ifdef __cplusplus extern "C" { #endif // All structures written to disk are 2-byte-aligned. #if GENERATINGPOWERPC #pragma options align=mac68k #endif #ifdef WIN32 #pragma pack(2) #endif #ifdef WIN32 typedef void** Handle; #endif // From IgorMath.h #define NT_CMPLX 1 // Complex numbers. #define NT_FP32 2 // 32 bit fp numbers. #define NT_FP64 4 // 64 bit fp numbers. #define NT_I8 8 // 8 bit signed integer. Requires Igor Pro 2.0 or later. #define NT_I16 0x10 // 16 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_I32 0x20 // 32 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_UNSIGNED 0x40 // Makes above signed integers unsigned. Requires Igor Pro 3.0 or later. // From wave.h #define MAXDIMS 4 // From binary.h typedef struct BinHeader1 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. short checksum; // Checksum over this header and the wave header. } BinHeader1; typedef struct BinHeader2 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. long noteSize; // The size of the note text. long pictSize; // Reserved. Write zero. Ignore on read. short checksum; // Checksum over this header and the wave header. } BinHeader2; typedef struct BinHeader3 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. long noteSize; // The size of the note text. long formulaSize; // The size of the dependency formula, if any. long pictSize; // Reserved. Write zero. Ignore on read. short checksum; // Checksum over this header and the wave header. } BinHeader3; typedef struct BinHeader5 { short version; // Version number for backwards compatibility. short checksum; // Checksum over this header and the wave header. long wfmSize; // The size of the WaveHeader5 data structure plus the wave data. long formulaSize; // The size of the dependency formula, if any. long noteSize; // The size of the note text. long dataEUnitsSize; // The size of optional extended data units. long dimEUnitsSize[MAXDIMS]; // The size of optional extended dimension units. long dimLabelsSize[MAXDIMS]; // The size of optional dimension labels. long sIndicesSize; // The size of string indicies if this is a text wave. long optionsSize1; // Reserved. Write zero. Ignore on read. long optionsSize2; // Reserved. Write zero. Ignore on read. } BinHeader5; // From wave.h #define MAX_WAVE_NAME2 18 // Maximum length of wave name in version 1 and 2 files. Does not include the trailing null. #define MAX_WAVE_NAME5 31 // Maximum length of wave name in version 5 files. Does not include the trailing null. #define MAX_UNIT_CHARS 3 // Header to an array of waveform data. struct WaveHeader2 { short type; // See types (e.g. NT_FP64) above. Zero for text waves. struct WaveHeader2 **next; // Used in memory only. Write zero. Ignore on read. char bname[MAX_WAVE_NAME2+2]; // Name of wave plus trailing null. short whVersion; // Write 0. Ignore on read. short srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char xUnits[MAX_UNIT_CHARS+1]; // Natural x-axis units go here - null if none. long npnts; // Number of data points in wave. short aModified; // Used in memory only. Write zero. Ignore on read. double hsA,hsB; // X value for point p = hsA*p + hsB short wModified; // Used in memory only. Write zero. Ignore on read. short swModified; // Used in memory only. Write zero. Ignore on read. short fsValid; // True if full scale values have meaning. double topFullScale,botFullScale; // The min full scale value for wave. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. void **formula; // Used in memory only. Write zero. Ignore on read. long depID; // Used in memory only. Write zero. Ignore on read. unsigned long creationDate; // DateTime of creation. Not used in version 1 files. char wUnused[2]; // Reserved. Write zero. Ignore on read. unsigned long modDate; // DateTime of last modification. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. float wData[4]; // The start of the array of waveform data. }; typedef struct WaveHeader2 WaveHeader2; typedef WaveHeader2 *WavePtr2; typedef WavePtr2 *waveHandle2; struct WaveHeader5 { struct WaveHeader5 **next; // link to next wave in linked list. unsigned long creationDate; // DateTime of creation. unsigned long modDate; // DateTime of last modification. long npnts; // Total number of points (multiply dimensions up to first zero). short type; // See types (e.g. NT_FP64) above. Zero for text waves. short dLock; // Reserved. Write zero. Ignore on read. char whpad1[6]; // Reserved. Write zero. Ignore on read. short whVersion; // Write 1. Ignore on read. char bname[MAX_WAVE_NAME5+1]; // Name of wave plus trailing null. long whpad2; // Reserved. Write zero. Ignore on read. struct DataFolder **dFolder; // Used in memory only. Write zero. Ignore on read. // Dimensioning info. [0] == rows, [1] == cols etc long nDim[MAXDIMS]; // Number of of items in a dimension -- 0 means no data. double sfA[MAXDIMS]; // Index value for element e of dimension d = sfA[d]*e + sfB[d]. double sfB[MAXDIMS]; // SI units char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char dimUnits[MAXDIMS][MAX_UNIT_CHARS+1]; // Natural dimension units go here - null if none. short fsValid; // TRUE if full scale values have meaning. short whpad3; // Reserved. Write zero. Ignore on read. double topFullScale,botFullScale; // The max and max full scale value for wave. Handle dataEUnits; // Used in memory only. Write zero. Ignore on read. Handle dimEUnits[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle dimLabels[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. long whUnused[16]; // Reserved. Write zero. Ignore on read. // The following stuff is considered private to Igor. short aModified; // Used in memory only. Write zero. Ignore on read. short wModified; // Used in memory only. Write zero. Ignore on read. short swModified; // Used in memory only. Write zero. Ignore on read. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. void **formula; // Used in memory only. Write zero. Ignore on read. long depID; // Used in memory only. Write zero. Ignore on read. short whpad4; // Reserved. Write zero. Ignore on read. short srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. long **sIndices; // Used in memory only. Write zero. Ignore on read. float wData[1]; // The start of the array of data. Must be 64 bit aligned. }; typedef struct WaveHeader5 WaveHeader5; typedef WaveHeader5 *WavePtr5; typedef WavePtr5 *WaveHandle5; #if GENERATINGPOWERPC #pragma options align=reset #endif #ifdef WIN32 #pragma pack() #endif // All structures written to disk are 2-byte-aligned. #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/igor/tn003/WriteWave.c0000664000175000017500000001261314105434233020677 0ustar schloeglschloegl// This file contains an example of writing a wave file. #include #include #include #include #include #include "IgorBin.h" #include "CrossPlatformFileIO.h" /* Checksum(data,oldcksum,numbytes) Returns shortwise simpleminded checksum over the data. ASSUMES data starts on an even boundary. */ static int Checksum(short *data, int oldcksum, int numbytes) { numbytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. while(numbytes-- > 0) oldcksum += *data++; return oldcksum&0xffff; } /* NumBytesPerPoint(int type) Given a numeric wave type, returns the number of data bytes per point. */ static int NumBytesPerPoint(int type) { int numBytesPerPoint; // Consider the number type, not including the complex bit or the unsigned bit. switch(type & ~(NT_CMPLX | NT_UNSIGNED)) { case NT_I8: numBytesPerPoint = 1; // char break; case NT_I16: numBytesPerPoint = 2; // short break; case NT_I32: numBytesPerPoint = 4; // long break; case NT_FP32: numBytesPerPoint = 4; // float break; case NT_FP64: numBytesPerPoint = 8; // double break; default: return 0; break; } if (type & NT_CMPLX) numBytesPerPoint *= 2; // Complex wave - twice as many points. return numBytesPerPoint; } /* WriteVersion2NumericWave(fr, whp, data, waveNote, noteSize) Writes an Igor version 2 binary wave with the properties specified in whp, the data specified by data, and the wave note specified by waveNote and noteSize. Returns 0 or an error code. */ static int WriteVersion2NumericWave(CP_FILE_REF fr, WaveHeader2* whp, const void* data, const char* waveNote, long noteSize) { unsigned long numBytesToWrite; unsigned long numBytesWritten; unsigned long waveDataSize; int numBytesPerPoint; short cksum; BinHeader2 bh; char padding[16]; int err; numBytesPerPoint = NumBytesPerPoint(whp->type); if (numBytesPerPoint <= 0) { printf("Invalid wave type (0x%x).\n", whp->type); return -1; } waveDataSize = whp->npnts * numBytesPerPoint; // Prepare the BinHeader structure. memset(&bh,0,sizeof(struct BinHeader2)); bh.version = 2; bh.wfmSize = offsetof(WaveHeader2, wData) + waveDataSize + 16; // Includes 16 bytes padding. bh.noteSize = noteSize; /* The checksum is over the BinHeader2 structure and the WaveHeader2 structure. The wData field of the WaveHeader2 structure is assumed to contain the same data as the first 16 bytes of the actual wave data. This is necessary to get the correct checksum. */ cksum = Checksum((short *)&bh, 0, sizeof(struct BinHeader2)); cksum = Checksum((short *)whp, cksum, sizeof(struct WaveHeader2)); bh.checksum = -cksum; do { // Write the BinHeader. numBytesToWrite = sizeof(struct BinHeader2); if (err = CPWriteFile(fr, numBytesToWrite, &bh, &numBytesWritten)) break; // Write the WaveHeader, up to but not including the wData field. numBytesToWrite = offsetof(WaveHeader2, wData); if (err = CPWriteFile(fr, numBytesToWrite, whp, &numBytesWritten)) break; // Write the wave data. numBytesToWrite = waveDataSize; if (err = CPWriteFile(fr, numBytesToWrite, data, &numBytesWritten)) break; // Write the 16 byte padding. memset(padding, 0, 16); // Write padding at the end of the wave data. numBytesToWrite = 16; if (err = CPWriteFile(fr, numBytesToWrite, padding, &numBytesWritten)) break; // Now write optional data, in the correct order. // Write the wave note. numBytesToWrite = noteSize; if (numBytesToWrite > 0) { if (err = CPWriteFile(fr, numBytesToWrite, waveNote, &numBytesWritten)) break; } } while(0); return err; } #define WAVEPOINTS 100 int DoWriteTest(const char* filePath); int DoWriteTest(const char* filePath) { WaveHeader2 wh; unsigned long now; float data[WAVEPOINTS]; char waveNote[256]; CP_FILE_REF fr; long p; int err; #ifdef WIN32 now = 0; // It would be possible to write a Windows equivalent for the Macintosh GetDateTime function but it is not easy. #else GetDateTime(&now); #endif memset(&wh, 0, sizeof(wh)); wh.type = NT_FP32; // Single precision floating point. strcpy(wh.bname, "TestWave"); strcpy(wh.dataUnits, "v"); strcpy(wh.xUnits, "s"); wh.npnts = WAVEPOINTS; wh.hsA = 1e-6; // 1 usec per point. wh.hsB = 0.0e0; // Starting from zero. wh.modDate = now; // Fill in data. for (p = 0; p < WAVEPOINTS; p++) data[p] = (float)p; // Copy the first 16 bytes of data to the wData field of the WaveHeader2 structure. // This is necessary for the checksum done by WriteVersion2NumericWave. memcpy(wh.wData, data, 16); // Add a wave note. strcpy(waveNote, "This is a test, this is only a test."); do { // Create a file. if (err = CPCreateFile(filePath, 1, 'IGR0', 'IGBW')) { printf("Error %d creating the file.\n", err); break; } // Open the file. if (err = CPOpenFile(filePath, 1, &fr)) { printf("Error %d opening the file.\n", err); break; } // Write the data. if (err = WriteVersion2NumericWave(fr, &wh, data, waveNote, strlen(waveNote))) printf("Error %d writing the file.\n", err); CPCloseFile(fr); } while(0); if (err == 0) printf("Successfully wrote the file %s.\n", filePath); return err; } biosig-2.3.3/biosig4c++/igor/tn003/ReadWave.c0000664000175000017500000003421014105434233020455 0ustar schloeglschloegl// This file contains an example of reading a wave file. #include #include #include #include #include #include "CrossPlatformFileIO.h" #include "IgorBin.h" static void ReorderBytes(void *p, int bytesPerPoint, long numValues) // Reverses byte order. { unsigned char ch, *p1, *p2, *pEnd; pEnd = (unsigned char *)p + numValues*bytesPerPoint; while (p < (void *)pEnd) { p1 = p; p2 = (unsigned char *)p + bytesPerPoint-1; while (p1 < p2) { ch = *p1; *p1++ = *p2; *p2-- = ch; } p = (unsigned char *)p + bytesPerPoint; } } static void ReorderShort(void* sp) { ReorderBytes(sp, 2, 1); } static void ReorderLong(void* lp) { ReorderBytes(lp, 4, 1); } static void ReorderDouble(void* dp) { ReorderBytes(dp, 8, 1); } static void ReorderBinHeader1(BinHeader1* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderShort(&p->checksum); } static void ReorderBinHeader2(BinHeader2* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } static void ReorderBinHeader3(BinHeader3* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); ReorderLong(&p->formulaSize); ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } static void ReorderBinHeader5(BinHeader5* p) { ReorderShort(&p->version); ReorderShort(&p->checksum); ReorderLong(&p->wfmSize); ReorderLong(&p->formulaSize); ReorderLong(&p->noteSize); ReorderLong(&p->dataEUnitsSize); ReorderBytes(&p->dimEUnitsSize, 4, 4); ReorderBytes(&p->dimLabelsSize, 4, 4); ReorderLong(&p->sIndicesSize); ReorderLong(&p->optionsSize1); ReorderLong(&p->optionsSize2); } static void ReorderWaveHeader2(WaveHeader2* p) { ReorderShort(&p->type); ReorderLong(&p->next); // char bname does not need to be reordered. ReorderShort(&p->whVersion); ReorderShort(&p->srcFldr); ReorderLong(&p->fileName); // char dataUnits does not need to be reordered. // char xUnits does not need to be reordered. ReorderLong(&p->npnts); ReorderShort(&p->aModified); ReorderDouble(&p->hsA); ReorderDouble(&p->hsB); ReorderShort(&p->wModified); ReorderShort(&p->swModified); ReorderShort(&p->fsValid); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. ReorderLong(&p->formula); ReorderLong(&p->depID); ReorderLong(&p->creationDate); // char wUnused does not need to be reordered. ReorderLong(&p->modDate); ReorderLong(&p->waveNoteH); // The wData field marks the start of the wave data which will be reordered separately. } static void ReorderWaveHeader5(WaveHeader5* p) { ReorderLong(&p->next); ReorderLong(&p->creationDate); ReorderLong(&p->modDate); ReorderLong(&p->npnts); ReorderShort(&p->type); ReorderShort(&p->dLock); // char whpad1 does not need to be reordered. ReorderShort(&p->whVersion); // char bname does not need to be reordered. ReorderLong(&p->whpad2); ReorderLong(&p->dFolder); ReorderBytes(&p->nDim, 4, 4); ReorderBytes(&p->sfA, 8, 4); ReorderBytes(&p->sfB, 8, 4); // char dataUnits does not need to be reordered. // char dimUnits does not need to be reordered. ReorderShort(&p->fsValid); ReorderShort(&p->whpad3); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); ReorderLong(&p->dataEUnits); ReorderBytes(&p->dimEUnits, 4, 4); ReorderBytes(&p->dimLabels, 4, 4); ReorderLong(&p->waveNoteH); ReorderBytes(&p->whUnused, 4, 16); ReorderShort(&p->aModified); ReorderShort(&p->wModified); ReorderShort(&p->swModified); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. ReorderLong(&p->formula); ReorderLong(&p->depID); ReorderShort(&p->whpad4); ReorderShort(&p->srcFldr); ReorderLong(&p->fileName); ReorderLong(&p->sIndices); // The wData field marks the start of the wave data which will be reordered separately. } static int Checksum(short *data, int needToReorderBytes, int oldcksum, int numbytes) { unsigned short s; numbytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. while(numbytes-- > 0) { s = *data++; if (needToReorderBytes) ReorderShort(&s); oldcksum += s; } return oldcksum&0xffff; } /* NumBytesPerPoint(int type) Given a numeric wave type, returns the number of data bytes per point. */ static int NumBytesPerPoint(int type) { int numBytesPerPoint; // Consider the number type, not including the complex bit or the unsigned bit. switch(type & ~(NT_CMPLX | NT_UNSIGNED)) { case NT_I8: numBytesPerPoint = 1; // char break; case NT_I16: numBytesPerPoint = 2; // short break; case NT_I32: numBytesPerPoint = 4; // long break; case NT_FP32: numBytesPerPoint = 4; // float break; case NT_FP64: numBytesPerPoint = 8; // double break; default: return 0; break; } if (type & NT_CMPLX) numBytesPerPoint *= 2; // Complex wave - twice as many points. return numBytesPerPoint; } /* LoadNumericWaveData(fr, type, npnts, waveDataSize, needToReorderBytes, pp) fr is a file reference. type is the Igor number type. npnts is the total number of elements in all dimensions. waveDataSize is the number of data bytes stored in the file. needToReorderBytes if the byte ordering of the file is not the byte ordering of the current platform. pp is a pointer to a pointer. If an error occurs, LoadWaveData returns a non-zero error code and sets *pp to NULL. If no error occurs, LoadWaveData returns 0 and sets *pp to a pointer allocated via malloc. This pointer must be freed by the calling routine. */ static int LoadNumericWaveData(CP_FILE_REF fr, int type, long npnts, unsigned long waveDataSize, int needToReorderBytes, void**pp) { int numBytesPerPoint; unsigned long numBytesToRead, numBytesToAllocate; unsigned long numBytesRead; void* p; int err; *pp = NULL; // Assume that we can not allocate memory. numBytesPerPoint = NumBytesPerPoint(type); if (numBytesPerPoint <= 0) { printf("Invalid wave type (0x%x).\n", type); return -1; } numBytesToRead = npnts * numBytesPerPoint; numBytesToAllocate = numBytesToRead; if (numBytesToAllocate == 0) numBytesToAllocate = 8; // This is just because malloc refuses to allocate a zero byte block. p = malloc(numBytesToAllocate); // Allocate memory to store the wave data. if (p == NULL) { printf("Unable to allocate %ld bytes to store data.\n", numBytesToAllocate); return -1; } if (numBytesToRead > 0) { if (waveDataSize < numBytesToRead) { /* If here, this should be a wave governed by a dependency formula for which no wave data was written to the file. Since we can't execute the dependency formula we have no way to recreate the wave's data. Therefore, we return 0 for all points in the wave. */ memset(p, 0, numBytesToRead); } else { if (err = CPReadFile(fr, numBytesToRead, p, &numBytesRead)) { free(p); printf("Error %d occurred while reading the wave data.\n", err); return err; } if (needToReorderBytes) { if (type != 0) // Text wave data does not need to be reordered. ReorderBytes(p, numBytesPerPoint, numBytesToRead/numBytesPerPoint); } } } *pp = p; // Return the pointer to the calling routine. return 0; } /* ReadWave(fr, typePtr, npntsPtr, waveDataPtrPtr) Reads the wave file and prints some information about it. Returns to the calling routine the wave's type, number of points, and the wave data. The calling routine must free *waveDataPtrPtr if it is not null. Returns 0 or an error code. This routine is written such that it could be used to read waves from an Igor packed experiment file as well as from a standalone Igor binary wave file. In order to achieve this, we must not assume that the wave is at the start of the file. We do assume that, on entry to this routine, the file position is at the start of the wave. */ static int ReadWave(CP_FILE_REF fr, int* typePtr, long* npntsPtr, void** waveDataPtrPtr) { unsigned long startFilePos; short version; short check; int binHeaderSize, waveHeaderSize, checkSumSize; unsigned long waveDataSize; unsigned long numBytesRead; int needToReorderBytes; char buffer[512]; unsigned long modDate; long wfmSize; long npnts; int type; char name[64]; int err; *waveDataPtrPtr = NULL; *typePtr = 0; *npntsPtr = 0; if (err = CPGetFilePosition(fr, &startFilePos)) return err; // Read the file version field. if (err = CPReadFile(fr, 2, &version, &numBytesRead)) { printf("Error %d occurred while reading the file version.\n", err); return err; } /* Reorder version field bytes if necessary. If the low order byte of the version field of the BinHeader structure is zero then the file is from a platform that uses different byte-ordering and therefore all data will need to be reordered. */ needToReorderBytes = (version & 0xFF) == 0; if (needToReorderBytes) ReorderShort(&version); // Check the version. switch(version) { case 1: printf("This is a version 1 file.\n"); binHeaderSize = sizeof(BinHeader1); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 2: printf("This is a version 2 file.\n"); binHeaderSize = sizeof(BinHeader2); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 3: printf("This is a version 3 file.\n"); binHeaderSize = sizeof(BinHeader3); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 5: printf("This is a version 5 file.\n"); binHeaderSize = sizeof(BinHeader5); waveHeaderSize = sizeof(WaveHeader5); checkSumSize = binHeaderSize + waveHeaderSize - 4; // Version 5 checksum does not include the wData field. break; default: printf("This does not appear to be a valid Igor binary wave file. The version field = %d.\n", version); return -1; break; } // Load the BinHeader and the WaveHeader into memory. CPSetFilePosition(fr, startFilePos, -1); if (err = CPReadFile(fr, binHeaderSize+waveHeaderSize, buffer, &numBytesRead)) { printf("Error %d occurred while reading the file headers.\n", err); return err; } // Check the checksum. check = Checksum((short*)buffer, needToReorderBytes, 0, checkSumSize); if (check != 0) { printf("Error in checksum - should be 0, is %d.\n", check); printf("This does not appear to be a valid Igor binary wave file.\n"); return -1; } // Do byte reordering if the file is from another platform. if (needToReorderBytes) { switch(version) { case 1: ReorderBinHeader1((BinHeader1*)buffer); break; case 2: ReorderBinHeader2((BinHeader2*)buffer); break; case 3: ReorderBinHeader3((BinHeader3*)buffer); break; case 5: ReorderBinHeader5((BinHeader5*)buffer); break; } switch(version) { case 1: // Version 1 and 2 files use WaveHeader2. case 2: case 3: ReorderWaveHeader2((WaveHeader2*)(buffer+binHeaderSize)); break; case 5: ReorderWaveHeader5((WaveHeader5*)(buffer+binHeaderSize)); break; } } // Read some of the BinHeader fields. switch(version) { case 1: { BinHeader1* b1; b1 = (BinHeader1*)buffer; wfmSize = b1->wfmSize; } break; case 2: { BinHeader2* b2; b2 = (BinHeader2*)buffer; wfmSize = b2->wfmSize; } break; case 3: { BinHeader3* b3; b3 = (BinHeader3*)buffer; wfmSize = b3->wfmSize; } break; case 5: { BinHeader5* b5; b5 = (BinHeader5*)buffer; wfmSize = b5->wfmSize; } break; } // Read some of the WaveHeader fields. switch(version) { case 1: case 2: case 3: { WaveHeader2* w2; w2 = (WaveHeader2*)(buffer+binHeaderSize); modDate = w2->modDate; npnts = w2->npnts; type = w2->type; strcpy(name, w2->bname); } break; case 5: { WaveHeader5* w5; w5 = (WaveHeader5*)(buffer+binHeaderSize); modDate = w5->modDate; npnts = w5->npnts; type = w5->type; strcpy(name, w5->bname); } break; } printf("Wave name=%s, npnts=%ld, type=0x%x, wfmSize=%ld.\n", name, npnts, type, wfmSize); // Return information to the calling routine. *typePtr = type; *npntsPtr = npnts; // Determine the number of bytes of wave data in the file. switch(version) { case 1: case 2: case 3: waveDataSize = wfmSize - offsetof(WaveHeader2, wData) - 16; break; case 5: waveDataSize = wfmSize - offsetof(WaveHeader5, wData); break; } // Position the file pointer to the start of the wData field. switch(version) { case 1: case 2: case 3: CPSetFilePosition(fr, startFilePos+binHeaderSize+waveHeaderSize-16, -1); // 16 = size of wData field in WaveHeader2 structure. break; case 5: CPSetFilePosition(fr, startFilePos+binHeaderSize+waveHeaderSize-4, -1); // 4 = size of wData field in WaveHeader2 structure. break; } if (type == 0) { // For simplicity, we don't load text wave data in this example program. printf("This is a text wave.\n"); return 0; } // Load the data and allocates memory to store it. if (err = LoadNumericWaveData(fr, type, npnts, waveDataSize, needToReorderBytes, waveDataPtrPtr)) return err; return 0; } int DoReadTest(const char* filePath); int DoReadTest(const char* filePath) { CP_FILE_REF fr; int type; long npnts; void* waveDataPtr; int err; if (err = CPOpenFile(filePath, 0, &fr)) { printf("Error %d occurred while opening the file.\n", err); return err; } err = ReadWave(fr, &type, &npnts, &waveDataPtr); // Here you would do something with the data. CPCloseFile(fr); if (waveDataPtr != NULL) free(waveDataPtr); printf("End of read test.\n"); return err; } biosig-2.3.3/biosig4c++/igor/tn003/COPYING0000664000175000017500000000041614105434233017647 0ustar schloeglschloeglThese files were downloaded from ftp://ftp.wavemetrics.net/IgorPro/Technical_Notes/TN003.zip When inquiring about the license, Howard Rodstein wrote on 2013-02-11: "You can use the files you mentioned for any purpose without restriction." biosig-2.3.3/biosig4c++/igor/tn003/CrossPlatformFileIO.c0000664000175000017500000002510714105434233022612 0ustar schloeglschloegl// This file contains utilities for cross-platform file I/O. #include #include #include #include #include #ifdef WIN32 #include #endif // The Windows headers create the WIN32 symbol if we are compiling for Windows. // Here, we create an analogous MACINTOSH symbol if we are compiling for Macintosh. #if (defined(GENERATINGPOWERPC) || defined(GENERATING68K)) #define MACINTOSH 1 #endif #include "CrossPlatformFileIO.h" /* CPCreateFile(fullFilePath, overwrite, macCreator, macFileType) Creates a file with the location and name specified by fullFilePath. fullFilePath must be a native path. If overwrite is true and a file by that name already exists, it first deletes the conflicting file. If overwrite is false and a file by that name exists, it returns an error. macFileType is ignored on Windows. On Macintosh, it is used to set the new file's type. For example, use 'TEXT' for a text file. macCreator is ignored on Windows. On Macintosh, it is used to set the new file's creator code. For example, use 'IGR0' (last character is zero) for an file. Returns 0 if OK or an error code. */ int CPCreateFile(const char* fullFilePath, int overwrite, long macCreator, long macFileType) { int err; if (overwrite) // Delete file if it exists and if overwrite is specified. CPDeleteFile(fullFilePath); // Ignore error. #ifdef MACINTOSH if (err = create(fullFilePath, 0, macCreator, macFileType)) return err; return 0; #endif #ifdef WIN32 { HANDLE fileH; long accessMode, shareMode; err = 0; accessMode = GENERIC_READ | GENERIC_WRITE; shareMode = 0; fileH = CreateFile(fullFilePath, accessMode, shareMode, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (fileH == INVALID_HANDLE_VALUE) err = GetLastError(); else CloseHandle(fileH); return err; } #endif } /* CPDeleteFile(fullFilePath) Deletes the file specified by fullFilePath. fullFilePath must be a native path. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPDeleteFile(const char* fullFilePath) { #ifdef MACINTOSH int err; if (err = fsdelete(fullFilePath, 0)) return err; return 0; #endif #ifdef WIN32 { int err; err = 0; if (DeleteFile(fullFilePath) == 0) err = GetLastError(); return err; } #endif } /* CPOpenFile(fullFilePath, readOrWrite, fileRefPtr) If readOrWrite is zero, opens an existing file for reading and returns a file reference via fileRefPtr. If readOrWrite is non-zero, opens an existing file for writing or creates a new file if none exists and returns a file reference via fileRefPtr. fullFilePath must be a native path. Returns 0 if OK or an error code. */ int CPOpenFile(const char* fullFilePath, int readOrWrite, CP_FILE_REF* fileRefPtr) { *fileRefPtr = fopen(fullFilePath, readOrWrite ? "wb" : "rb"); if (*fileRefPtr == NULL) return CP_FILE_OPEN_ERROR; return 0; } /* CPCloseFile(fileRef) Closes the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPCloseFile(CP_FILE_REF fileRef) { if (fclose(fileRef)) return CP_FILE_CLOSE_ERROR; return 0; } /* CPReadFile(fileRef, count, buffer, numBytesReadPtr) Reads count bytes from the referenced file into the buffer. If numBytesReadPtr is not NULL, stores the number of bytes read in *numBytesReadPtr. Returns 0 if OK or an error code. If bytes remain to be read in the file and you ask to read more bytes than remain, the remaining bytes are returned and the function result is zero. If no bytes remain to be read in the file and you ask to read bytes, no bytes are returned and the function result is CP_FILE_EOF_ERROR. CPReadFile is appropriate when you are reading data of variable size, in which case you do not want to consider it an error if the end of file is reached before reading all of the bytes that you requested. If you are reading a record of fixed size, use use CPReadFile2 instead of CPReadFile. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPReadFile(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr) { unsigned long numBytesRead; if (count == 0) { if (numBytesReadPtr != NULL) *numBytesReadPtr = 0; return 0; } clearerr(fileRef); numBytesRead = fread(buffer, 1, count, fileRef); if (numBytesReadPtr != NULL) *numBytesReadPtr = numBytesRead; if (ferror(fileRef)) return CP_FILE_READ_ERROR; if (numBytesRead==0 && CPAtEndOfFile(fileRef)) return CP_FILE_EOF_ERROR; // We were at the end of file when asked to read some bytes. return 0; } /* CPReadFile2(fileRef, count, buffer, numBytesReadPtr) Reads count bytes from the referenced file into the buffer. If numBytesReadPtr is not NULL, stores the number of bytes read in *numBytesReadPtr. Returns 0 if OK or an error code. If bytes remain to be read in the file and you ask to read more bytes than remain, the remaining bytes are returned and the function result is CP_FILE_EOF_ERROR. CPReadFile2 is appropriate when you are reading a record of fixed size, in which case you want to consider it an error if the end of file is reached before reading all of the bytes in the record. If you are reading a record of variable size then you should use CPReadFile instead of CPReadFile2. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPReadFile2(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr) { unsigned long numBytesRead; if (count == 0) { if (numBytesReadPtr != NULL) *numBytesReadPtr = 0; return 0; } clearerr(fileRef); numBytesRead = fread(buffer, 1, count, fileRef); if (numBytesReadPtr != NULL) *numBytesReadPtr = numBytesRead; if (ferror(fileRef)) return CP_FILE_READ_ERROR; if (numBytesRead < count) { // We did not read all of the bytes requested. if (CPAtEndOfFile(fileRef)) return CP_FILE_EOF_ERROR; // We hit the end of file. return CP_FILE_READ_ERROR; // Some other occurred but ferror did not reflect it. } return 0; } /* CPWriteFile(fileRef, count, buffer, numBytesWrittenPtr) Writes count bytes from the buffer to the referenced file. If numBytesWrittenPtr is not NULL, stores the number of bytes written in *numBytesWrittenPtr. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPWriteFile(CP_FILE_REF fileRef, unsigned long count, const void* buffer, unsigned long* numBytesWrittenPtr) { unsigned long numBytesWritten; if (count == 0) { if (numBytesWrittenPtr != NULL) *numBytesWrittenPtr = 0; return 0; } numBytesWritten = fwrite(buffer, 1, count, fileRef); if (numBytesWrittenPtr != NULL) *numBytesWrittenPtr = numBytesWritten; if (numBytesWritten != count) return CP_FILE_WRITE_ERROR; return 0; } /* CPGetFilePosition(fileRef, filePosPtr) Returns via filePosPtr the current file position of the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPGetFilePosition(CP_FILE_REF fileRef, unsigned long* filePosPtr) { long pos; pos = ftell(fileRef); if (pos == -1L) return CP_FILE_POS_ERROR; *filePosPtr = pos; return 0; } /* CPSetFilePosition(fileRef, filePos, mode) Sets the current file position in the referenced file. If mode is -1, then filePos is relative to the start of the file. If mode is 0, then filePos is relative to the current file position. If mode is 1, then filePos is relative to the end of the file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPSetFilePosition(CP_FILE_REF fileRef, long filePos, int mode) { int seekMode; switch(mode) { case -1: seekMode = SEEK_SET; break; case 0: seekMode = SEEK_CUR; break; case 1: seekMode = SEEK_END; break; default: return CP_FILE_POS_ERROR; } if (fseek(fileRef, filePos, seekMode) != 0) return CP_FILE_POS_ERROR; return 0; } /* CPAtEndOfFile(fileRef) Returns 1 if the current file position is at the end of file, 0 if not. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPAtEndOfFile(CP_FILE_REF fileRef) { if (feof(fileRef)) // Hit end of file? return 1; return 0; } /* CPNumberOfBytesInFile(fileRef, numBytesPtr) Returns via numBytesPtr the total number of bytes in the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPNumberOfBytesInFile(CP_FILE_REF fileRef, unsigned long* numBytesPtr) { long originalPos; originalPos = ftell(fileRef); if (fseek(fileRef, 0, SEEK_END) != 0) return CP_FILE_POS_ERROR; *numBytesPtr = ftell(fileRef); if (*numBytesPtr == -1L) return CP_FILE_POS_ERROR; if (fseek(fileRef, originalPos, SEEK_SET) != 0) return CP_FILE_POS_ERROR; return 0; } biosig-2.3.3/biosig4c++/igor/tn003/TestWave.c0000664000175000017500000000513314105434233020523 0ustar schloeglschloegl #include #include #include #include #include extern int DoReadTest(const char* filePath); extern int DoWriteTest(const char* filePath); static int GetNextCommand(char* filePath) { char input[1024]; int command; int i; *filePath = 0; while(1) { printf("Command: "); if (fgets(input, sizeof(input)-1, stdin) != NULL) { char* p = strchr(input, '\n'); // Find new line character. if (p != NULL) *p = 0; // Remove new line character. for(i=0; i<5; i++) input[i] = toupper(input[i]); // Convert command to upper case. if (strncmp(input, "READ ", 5) == 0) { command = 1; strcpy(filePath, input+5); break; } if (strncmp(input, "WRITE ", 6) == 0) { command = 2; strcpy(filePath, input+6); break; } if (strncmp(input, "QUIT", 4) == 0) { command = 3; break; } } printf("\n\n"); } return command; } int main(void) { int command; char filePath[1024]; char fullPathSample[32]; char partialPathSample[32]; int err; #ifdef WIN32 strcpy(fullPathSample, "C:\\FolderA\\MyWave.ibw"); strcpy(partialPathSample, "..\\SamplesWin\\version2.ibw"); #else strcpy(fullPathSample, "hd:FolderA:MyWave.ibw"); strcpy(partialPathSample, "::SamplesMac:version2.ibw"); #endif printf("This program illustrates reading and writing Igor binary wave files.\n\n"); printf("To read a file, enter the following: Read \n\n"); printf("To write a file, enter the following: Write \n\n"); printf(" can be either a full path (%s)\n", fullPathSample); printf("or a partial path relative to the folder containing this program (%s)\n", partialPathSample); printf("\n"); printf("Here are some sample commands:\n"); #ifdef WIN32 printf(" Read ..\\SamplesMac\\version2.ibw\n"); printf(" Read ..\\SamplesWin\\version5.ibw\n"); printf(" Write TestWave.ibw\n"); #else printf(" Read ::SamplesMac:version2.ibw\n"); printf(" Read ::SamplesWin:version5.ibw\n"); printf(" Write TestWave.ibw\n"); #endif #ifdef WIN32 printf("To quit the program, type Quit\n"); #else printf("To quit the program, choose Quit from the file menu.\n"); #endif while(1) { printf("\n"); command = GetNextCommand(filePath); if (command == 1) err = DoReadTest(filePath); if (command == 2) err = DoWriteTest(filePath); if (command == 3) { #ifndef WIN32 printf("Now you must choose Quit from the File menu to quit.\n"); #endif break; } } return 0; } biosig-2.3.3/biosig4c++/igor/tn003/CrossPlatformFileIO.h0000664000175000017500000000207414105434233022615 0ustar schloeglschloegl#define CP_FILE_OPEN_ERROR 10000 #define CP_FILE_CLOSE_ERROR 10001 #define CP_FILE_EOF_ERROR 10002 #define CP_FILE_READ_ERROR 10003 #define CP_FILE_WRITE_ERROR 10004 #define CP_FILE_POS_ERROR 10005 #define CP_FILE_REF FILE* int CPCreateFile(const char* fullFilePath, int overwrite, long macCreator, long macFileType); int CPDeleteFile(const char* fullFilePath); int CPOpenFile(const char* fullFilePath, int readOrWrite, CP_FILE_REF* fileRefPtr); int CPCloseFile(CP_FILE_REF fileRef); int CPReadFile(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr); int CPReadFile2(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr); int CPWriteFile(CP_FILE_REF fileRef, unsigned long count, const void* buffer, unsigned long* numBytesWrittenPtr); int CPGetFilePosition(CP_FILE_REF fileRef, unsigned long* filePosPtr); int CPSetFilePosition(CP_FILE_REF fileRef, long filePos, int mode); int CPAtEndOfFile(CP_FILE_REF fileRef); int CPNumberOfBytesInFile(CP_FILE_REF fileRef, unsigned long* numBytesPtr); biosig-2.3.3/biosig4c++/igor/README0000664000175000017500000000231114105434233016624 0ustar schloeglschloegl# Biosig's XOP interface to IGOR # Copyright 2010 Alois Schloegl This is currently in an experimental state. An open issue is, that biosig4c++/libbiosig compiles with GNU C++ compiler, but the supported platforms for Igor XOP's are only Mac and MS-Windows (MS VisualC++) Therefore, there are three options, (A) mixing MinGW and MSVC++, (B) moving everthing to MinGW, and (C) moving everything to MSVC++. Every option has currently one or more open issues: (A) mingw/libbiosig + MSVC++/xop - alignment of struct variables (B) MinGW/libbiosig + MinGW/xop - test of compiling XOP1 works fine. - need reimp utils form mingw/utils/reimp, on linux apply patchMinGW_utils_reimp.diff - requires MinGW dlltool and assembler - converts IGOR.lib into libIgor.a - conversion of XOPSupport.lib fails, however it is not needed, linking with XOPSupport.lib works fine. (C) MSVC++/libbiosig + MSVC++/xop (MSVC++-based libbiosig) - alignment - GNU specific extensions Open Issues: XOP1 causes application error seen on Wine and WinXP patchXOP1.diff ?? void main -> int main ? MinGW - most likely reason http://wiki.osdev.org/MinGW myXOP, XOPas do not work biosig-2.3.3/biosig4c++/igor/Makefile0000664000175000017500000000735514105434244017423 0ustar schloeglschloegl# Makefile for XOP interface to Igor # This is experimental for testing the use of MinGW for XOP's # # Copyright 2010 A. Schloegl # configure your cross-compiler and path to IGOR XOP toolkit CROSS = i586-mingw32msvc- CROSS = $(HOME)/src/mingw-cross-env/usr/bin/i686-pc-mingw32- # define path to XOP toolkit #IGORDIR = $(HOME)/.wine/drive_c/Program\ Files/WaveMetrics/XOP\ Toolkit\ 6/IgorXOPs6 IGORDIR = $(HOME)/.wine/drive_c/Program\ Files/WaveMetrics/XOP\ Toolkit\ 5/IgorXOPs5 ##### start of Makefile: XOP1 = $(IGORDIR)/XOP1/XOP1.c GBDIR = $(IGORDIR)/GBLoadWave INCDIR = -I$(IGORDIR)/XOPSupport/ INCDIR += -I$(IGORDIR)/XOP1/ INCDIR += -I$(IGORDIR)/GBLoadWave/ INCDIR += -I. LIBS += $(IGORDIR)/XOPSupport/VC6/XOPSupport.lib LIBS += ../win32/libbiosig.a ../win32/zlib/lib/libz.a -lws2_32 LIBS += -lversion -lmsvcrt -lcomdlg32 CC = g++ DEFINES = -D=WINIGOR -D=_WINDOWS_ all:XOP1.xop XOPas.xop GBLoadWave.xop GBLoadWaveres.o: $(GBDIR)/GBLoadWave.rc $(CROSS)windres $(DEFINES) $(INCDIR) $(GBDIR)/GBLoadWave.rc -o GBLoadWaveres.o GBLoadWave.o: $(GBDIR)/GBLoadWave.c $(CROSS)$(CC) -shared -c -o GBLoadWave.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWave.c GBLoadWaveDialog.o: $(GBDIR)/GBLoadWaveDialog.c $(CROSS)$(CC) -shared -c -o GBLoadWaveDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveDialog.c GBLoadWaveOperation.o: $(GBDIR)/GBLoadWaveOperation.c $(CROSS)$(CC) -shared -c -o GBLoadWaveOperation.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveOperation.c GBScalingDialog.o: $(GBDIR)/GBScalingDialog.c $(CROSS)$(CC) -shared -c -o GBScalingDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBScalingDialog.c GBLoadWaveDialog.o: $(GBDIR)/GBLoadWaveDialog.c $(CROSS)$(CC) -shared -c -o GBLoadWaveDialog.o $(DEFINES) $(INCDIR) -I./$(GBDIR)/ $(GBDIR)/GBLoadWaveDialog.c GBLoadWave.xop: GBLoadWave.o GBLoadWaveres.o GBLoadWaveOperation.o GBLoadWaveDialog.o GBScalingDialog.o XOPDialogsWin.o libIgor.a XOPSupport.o XOPFiles.o $(CROSS)$(CC) -shared -o GBLoadWave.xop GBLoadWave.o GBLoadWaveOperation.o GBLoadWaveDialog.o GBScalingDialog.o XOPDialogsWin.o GBLoadWaveres.o XOPSupport.o XOPFiles.o $(LIBS) libIgor.a xopSLOAD.o:xopSLOAD.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) xopSLOAD.c -o xopSLOAD.o -c #xopSLOAD.xop:libIgor.a XOPSupport.o # $(CROSS)$(CC) -shared -o xopSLOAD.xop $(DEFINES) $(INCDIR) xopSLOAD.c XOPSupport.o $(LIBS) libIgor.a xopSLOAD.xop: xopSLOAD.o libIgor.a XOPSupport.o $(CROSS)$(CC) -shared -o xopSLOAD.xop xopSLOAD.o XOPSupport.o $(LIBS) libIgor.a libIgor.a: $(IGORDIR)/XOPSupport/IGOR.lib $(CROSS)reimp -c --as $(CROSS)as --dlltool $(CROSS)dlltool $(IGORDIR)/XOPSupport/IGOR.lib XOPDialogsWin.o:$(IGORDIR)/XOPSupport/XOPDialogsWin.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPDialogsWin.c -o XOPDialogsWin.o -c XOPSupport.o:$(IGORDIR)/XOPSupport/XOPSupport.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPSupport.c -o XOPSupport.o -c XOPFiles.o:$(IGORDIR)/XOPSupport/XOPFiles.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) $(IGORDIR)/XOPSupport/XOPFiles.c -o XOPFiles.o -c ## compiling XOP1: this should work XOP1res.o:$(IGORDIR)/XOP1/XOP1.rc $(CROSS)windres $(DEFINES) $(INCDIR) $(IGORDIR)/XOP1/XOP1.rc -o XOP1res.o XOP1.xop: XOPSupport.o libIgor.a XOP1res.o $(CROSS)$(CC) -shared -o XOP1.xop $(DEFINES) $(INCDIR) $(XOP1) XOP1res.o XOPSupport.o $(LIBS) libIgor.a ## testing a modified XOP1 XOPasres.o:XOPas.rc $(CROSS)windres $(DEFINES) $(INCDIR) XOPas.rc -o XOPasres.o XOPas.o:XOPas.c $(CROSS)$(CC) $(DEFINES) $(INCDIR) XOPas.c -o XOPas.o -c XOPas.xop:XOPas.o XOPSupport.o libIgor.a XOPasres.o $(CROSS)$(CC) -shared -o XOPas.xop XOPas.o XOPasres.o XOPSupport.o $(LIBS) libIgor.a clean: rm *.o *.xop *.exe biosig-2.3.3/biosig4c++/igor/patchMinGW_utils_reimp.diff0000664000175000017500000000134714105434233023223 0ustar schloeglschloegl? reimp/reimp Index: reimp/reimp.h =================================================================== RCS file: /cvsroot/mingw/utils/reimp/reimp.h,v retrieving revision 1.1 diff -r1.1 reimp.h 0a1 > #include 6c7 < #define uint32 unsigned long --- > #define uint32 uint32_t 10c11 < #define uint16 unsigned short --- > #define uint16 uint16_t 90c91 < int spawnvp (int, char *, char **); --- > int spawnvp (int, char *, const char * const*); Index: reimp/util.c =================================================================== RCS file: /cvsroot/mingw/utils/reimp/util.c,v retrieving revision 1.2 diff -r1.2 util.c 82c82 < spawnvp (int mode, char *path, char **argv) --- > spawnvp (int mode, char *path, const char * const *argv) biosig-2.3.3/biosig4c++/igor/patchIgorXOPs.diff0000664000175000017500000003237314105434233021303 0ustar schloeglschloegldiff -rc IgorXOPs5.bak/XOP1/XOP1.c IgorXOPs5/XOP1/XOP1.c *** IgorXOPs5.bak/XOP1/XOP1.c Mon Mar 22 14:26:10 2004 --- IgorXOPs5/XOP1/XOP1.c Mon Oct 18 14:02:39 2010 *************** *** 128,134 **** cmdTemplate = "XOP1 wave"; runtimeNumVarList = ""; runtimeStrVarList = ""; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(XOP1RuntimeParams), ExecuteXOP1, 0); } static int --- 128,134 ---- cmdTemplate = "XOP1 wave"; runtimeNumVarList = ""; runtimeStrVarList = ""; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(XOP1RuntimeParams), (void*)(ExecuteXOP1), 0); } static int *************** *** 169,176 **** main does any necessary initialization and then sets the XOPEntry field of the ioRecHandle to the address to be called for future messages. */ ! HOST_IMPORT void ! main(IORecHandle ioRecHandle) { int result; --- 169,175 ---- main does any necessary initialization and then sets the XOPEntry field of the ioRecHandle to the address to be called for future messages. */ ! HOST_IMPORT int main(IORecHandle ioRecHandle) { int result; diff -rc IgorXOPs5.bak/XOP1/XOP1.h IgorXOPs5/XOP1/XOP1.h *** IgorXOPs5.bak/XOP1/XOP1.h Mon Mar 22 14:26:10 2004 --- IgorXOPs5/XOP1/XOP1.h Mon Oct 18 13:59:03 2010 *************** *** 5,8 **** /* no equates needed */ /* Prototypes */ ! HOST_IMPORT void main(IORecHandle ioRecHandle); --- 5,8 ---- /* no equates needed */ /* Prototypes */ ! HOST_IMPORT int main(IORecHandle ioRecHandle); diff -rc IgorXOPs5.bak/XOPSupport/XOPStandardHeaders.h IgorXOPs5/XOPSupport/XOPStandardHeaders.h *** IgorXOPs5.bak/XOPSupport/XOPStandardHeaders.h Fri Sep 1 10:36:28 2006 --- IgorXOPs5/XOPSupport/XOPStandardHeaders.h Mon Oct 18 14:03:25 2010 *************** *** 36,42 **** // We use the WIN32 symbol to detect that we are compiling for Windows because _WINDOWS_ is not defined until we include Windows.h. #ifdef WIN32 // Compiling for Windows [ ! #include // This creates the _WINDOWS_ symbol. #ifdef SetPort // SetPort is defined in WinSpool.h #undef SetPort // But we use SetPort in the Macintosh sense. --- 36,42 ---- // We use the WIN32 symbol to detect that we are compiling for Windows because _WINDOWS_ is not defined until we include Windows.h. #ifdef WIN32 // Compiling for Windows [ ! #include // This creates the _WINDOWS_ symbol. #ifdef SetPort // SetPort is defined in WinSpool.h #undef SetPort // But we use SetPort in the Macintosh sense. diff -rc IgorXOPs5.bak/XOPSupport/XOPSupport.c IgorXOPs5/XOPSupport/XOPSupport.c *** IgorXOPs5.bak/XOPSupport/XOPSupport.c Fri Jul 13 13:30:50 2007 --- IgorXOPs5/XOPSupport/XOPSupport.c Mon Oct 18 14:34:36 2010 *************** *** 370,376 **** versionInfoSize = GetFileVersionInfoSize(igorName, &dwHandle); if (versionInfoSize <= 0) return 0; ! versionBuffer = NewPtr(versionInfoSize); if (versionBuffer == NULL) return 0; if (GetFileVersionInfo(igorName, 0L, versionInfoSize, versionBuffer) == 0) { --- 370,376 ---- versionInfoSize = GetFileVersionInfoSize(igorName, &dwHandle); if (versionInfoSize <= 0) return 0; ! versionBuffer = (char*)NewPtr(versionInfoSize); if (versionBuffer == NULL) return 0; if (GetFileVersionInfo(igorName, 0L, versionInfoSize, versionBuffer) == 0) { diff -rc IgorXOPs5.bak/GBLoadWave/GBLoadWave.c IgorXOPs5/GBLoadWave/GBLoadWave.c *** IgorXOPs5.bak/GBLoadWave/GBLoadWave.c Mon Mar 22 14:25:16 2004 --- IgorXOPs5/GBLoadWave/GBLoadWave.c Thu Oct 28 10:13:30 2010 *************** *** 379,385 **** bytesInWave = arrayPoints * bytesInPoint; totalBytes = numArrays * bytesInWave; ! buffer = NewPtr(totalBytes); if (buffer == NIL) return NOMEM; --- 379,385 ---- bytesInWave = arrayPoints * bytesInPoint; totalBytes = numArrays * bytesInWave; ! buffer = (char*)NewPtr(totalBytes); if (buffer == NIL) return NOMEM; *************** *** 495,501 **** */ buffer = NIL; if (lsp->inputBytesPerPoint > lsp->outputBytesPerPoint) { // Can't read directly into wave? ! buffer = NewPtr(numPoints*lsp->inputBytesPerPoint); // Get temporary buffer. if (buffer == NIL) return NOMEM; } --- 495,501 ---- */ buffer = NIL; if (lsp->inputBytesPerPoint > lsp->outputBytesPerPoint) { // Can't read directly into wave? ! buffer = (char*)NewPtr(numPoints*lsp->inputBytesPerPoint); // Get temporary buffer. if (buffer == NIL) return NOMEM; } *************** *** 504,510 **** ciPtr = caPtr + column; GetWaveStuff(ciPtr->waveHandle, &ciPtr->hState, &dataType, &ciPtr->dataPtr); if (buffer==NIL) // Reading directly into wave. ! readDataPtr = ciPtr->dataPtr; else // Reading into buffer. readDataPtr = buffer; count = lsp->inputBytesPerPoint*numPoints; --- 504,510 ---- ciPtr = caPtr + column; GetWaveStuff(ciPtr->waveHandle, &ciPtr->hState, &dataType, &ciPtr->dataPtr); if (buffer==NIL) // Reading directly into wave. ! readDataPtr = (char*)ciPtr->dataPtr; else // Reading into buffer. readDataPtr = buffer; count = lsp->inputBytesPerPoint*numPoints; *************** *** 840,846 **** main does any necessary initialization and then sets the XOPEntry field of the XOPRecHandle to the address to be called for future messages. */ ! HOST_IMPORT void main(IORecHandle ioRecHandle) { int result; --- 840,846 ---- main does any necessary initialization and then sets the XOPEntry field of the XOPRecHandle to the address to be called for future messages. */ ! HOST_IMPORT int main(IORecHandle ioRecHandle) { int result; *************** *** 850,861 **** if (igorVersion < 500) { SetXOPResult(OLD_IGOR); // OLD_IGOR is defined in GBLoadWave.h and there are corresponding error strings in GBLoadWave.r and GBLoadWaveWinCustom.rc. ! return; } if (result = RegisterOperations()) { SetXOPResult(result); ! return; } SetXOPResult(0L); --- 850,861 ---- if (igorVersion < 500) { SetXOPResult(OLD_IGOR); // OLD_IGOR is defined in GBLoadWave.h and there are corresponding error strings in GBLoadWave.r and GBLoadWaveWinCustom.rc. ! return (0); } if (result = RegisterOperations()) { SetXOPResult(result); ! return (0); } SetXOPResult(0L); diff -rc IgorXOPs5.bak/GBLoadWave/GBLoadWave.h IgorXOPs5/GBLoadWave/GBLoadWave.h *** IgorXOPs5.bak/GBLoadWave/GBLoadWave.h Mon Mar 22 14:25:16 2004 --- IgorXOPs5/GBLoadWave/GBLoadWave.h Thu Oct 28 10:12:19 2010 *************** *** 111,117 **** /* Prototypes */ // In GBLoadWave.c ! HOST_IMPORT void main(IORecHandle ioRecHandle); int LoadWave(LoadSettings* lsp, const char* baseName, const char* symbolicPathName, const char* fileParam, int runningInUserFunction); // In GBLoadWaveOperation.c --- 111,117 ---- /* Prototypes */ // In GBLoadWave.c ! HOST_IMPORT int main(IORecHandle ioRecHandle); int LoadWave(LoadSettings* lsp, const char* baseName, const char* symbolicPathName, const char* fileParam, int runningInUserFunction); // In GBLoadWaveOperation.c diff -rc IgorXOPs5.bak/GBLoadWave/GBLoadWaveDialog.c IgorXOPs5/GBLoadWave/GBLoadWaveDialog.c *** IgorXOPs5.bak/GBLoadWave/GBLoadWaveDialog.c Mon Mar 22 14:25:16 2004 --- IgorXOPs5/GBLoadWave/GBLoadWaveDialog.c Thu Oct 28 11:34:13 2010 *************** *** 322,328 **** } static int ! DataTypeItemNumberToDataTypeCode(dataTypeItemNumber) { int result; --- 322,328 ---- } static int ! DataTypeItemNumberToDataTypeCode(int dataTypeItemNumber) { int result; diff -rc IgorXOPs5.bak/GBLoadWave/GBLoadWaveOperation.c IgorXOPs5/GBLoadWave/GBLoadWaveOperation.c *** IgorXOPs5.bak/GBLoadWave/GBLoadWaveOperation.c Mon Mar 22 14:25:16 2004 --- IgorXOPs5/GBLoadWave/GBLoadWaveOperation.c Thu Oct 28 10:47:16 2010 *************** *** 348,352 **** cmdTemplate = "GBLoadWave /A[=name:ABaseName] /B[=number:lowByteFirst] /D[=number:doublePrecision] /F=number:dataFormat /I[={string:macFilterStr,string:winFilterStr}] /J=number:floatFormat /L=number:dataLengthInBits /N[=name:NBaseName] /O[=number:overwrite] /P=name:pathName /Q[=number:quiet] /S=number:skipBytes /T={number:fileDataType,number:waveDataType} /U=number:pointsPerArray /V[=number:interleaved] /W=number:numberOfArraysInFile /Y={number:offset,number:multiplier} [string:fileParamStr]"; runtimeNumVarList = "V_flag;"; runtimeStrVarList = "S_fileName;S_path;S_waveNames;"; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(GBLoadWaveRuntimeParams), ExecuteGBLoadWave, 0); } --- 348,352 ---- cmdTemplate = "GBLoadWave /A[=name:ABaseName] /B[=number:lowByteFirst] /D[=number:doublePrecision] /F=number:dataFormat /I[={string:macFilterStr,string:winFilterStr}] /J=number:floatFormat /L=number:dataLengthInBits /N[=name:NBaseName] /O[=number:overwrite] /P=name:pathName /Q[=number:quiet] /S=number:skipBytes /T={number:fileDataType,number:waveDataType} /U=number:pointsPerArray /V[=number:interleaved] /W=number:numberOfArraysInFile /Y={number:offset,number:multiplier} [string:fileParamStr]"; runtimeNumVarList = "V_flag;"; runtimeStrVarList = "S_fileName;S_path;S_waveNames;"; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(GBLoadWaveRuntimeParams), (void*)(ExecuteGBLoadWave), 0); } diff -rc IgorXOPs5.bak/XOP1/XOP1.c IgorXOPs5/XOP1/XOP1.c *** IgorXOPs5.bak/XOP1/XOP1.c Mon Mar 22 14:26:10 2004 --- IgorXOPs5/XOP1/XOP1.c Wed Oct 27 14:08:58 2010 *************** *** 128,134 **** cmdTemplate = "XOP1 wave"; runtimeNumVarList = ""; runtimeStrVarList = ""; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(XOP1RuntimeParams), ExecuteXOP1, 0); } static int --- 128,134 ---- cmdTemplate = "XOP1 wave"; runtimeNumVarList = ""; runtimeStrVarList = ""; ! return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(XOP1RuntimeParams), (void*)(ExecuteXOP1), 0); } static int *************** *** 169,176 **** main does any necessary initialization and then sets the XOPEntry field of the ioRecHandle to the address to be called for future messages. */ ! HOST_IMPORT void ! main(IORecHandle ioRecHandle) { int result; --- 169,175 ---- main does any necessary initialization and then sets the XOPEntry field of the ioRecHandle to the address to be called for future messages. */ ! HOST_IMPORT int main(IORecHandle ioRecHandle) { int result; *************** *** 180,186 **** if (result = RegisterOperations()) { SetXOPResult(result); ! return; } SetXOPResult(0); --- 179,185 ---- if (result = RegisterOperations()) { SetXOPResult(result); ! return (0); } SetXOPResult(0); diff -rc IgorXOPs5.bak/XOP1/XOP1.h IgorXOPs5/XOP1/XOP1.h *** IgorXOPs5.bak/XOP1/XOP1.h Mon Mar 22 14:26:10 2004 --- IgorXOPs5/XOP1/XOP1.h Mon Oct 18 13:59:03 2010 *************** *** 5,8 **** /* no equates needed */ /* Prototypes */ ! HOST_IMPORT void main(IORecHandle ioRecHandle); --- 5,8 ---- /* no equates needed */ /* Prototypes */ ! HOST_IMPORT int main(IORecHandle ioRecHandle); diff -rc IgorXOPs5.bak/XOPSupport/XOPStandardHeaders.h IgorXOPs5/XOPSupport/XOPStandardHeaders.h *** IgorXOPs5.bak/XOPSupport/XOPStandardHeaders.h Fri Sep 1 10:36:28 2006 --- IgorXOPs5/XOPSupport/XOPStandardHeaders.h Mon Oct 18 14:03:25 2010 *************** *** 36,42 **** // We use the WIN32 symbol to detect that we are compiling for Windows because _WINDOWS_ is not defined until we include Windows.h. #ifdef WIN32 // Compiling for Windows [ ! #include // This creates the _WINDOWS_ symbol. #ifdef SetPort // SetPort is defined in WinSpool.h #undef SetPort // But we use SetPort in the Macintosh sense. --- 36,42 ---- // We use the WIN32 symbol to detect that we are compiling for Windows because _WINDOWS_ is not defined until we include Windows.h. #ifdef WIN32 // Compiling for Windows [ ! #include // This creates the _WINDOWS_ symbol. #ifdef SetPort // SetPort is defined in WinSpool.h #undef SetPort // But we use SetPort in the Macintosh sense. diff -rc IgorXOPs5.bak/XOPSupport/XOPSupport.c IgorXOPs5/XOPSupport/XOPSupport.c *** IgorXOPs5.bak/XOPSupport/XOPSupport.c Fri Jul 13 13:30:50 2007 --- IgorXOPs5/XOPSupport/XOPSupport.c Mon Oct 18 14:34:36 2010 *************** *** 370,376 **** versionInfoSize = GetFileVersionInfoSize(igorName, &dwHandle); if (versionInfoSize <= 0) return 0; ! versionBuffer = NewPtr(versionInfoSize); if (versionBuffer == NULL) return 0; if (GetFileVersionInfo(igorName, 0L, versionInfoSize, versionBuffer) == 0) { --- 370,376 ---- versionInfoSize = GetFileVersionInfoSize(igorName, &dwHandle); if (versionInfoSize <= 0) return 0; ! versionBuffer = (char*)NewPtr(versionInfoSize); if (versionBuffer == NULL) return 0; if (GetFileVersionInfo(igorName, 0L, versionInfoSize, versionBuffer) == 0) { Only in IgorXOPs5/XOPSupport: XOPSupport.c.rej biosig-2.3.3/biosig4c++/igor/ptn003/0000775000175000017500000000000014105434233016773 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/igor/ptn003/ReadPackedFile.c0000664000175000017500000004077414105434233021736 0ustar schloeglschloegl/* The code in this file writes a sample Igor Pro packed experiment file. See Igor Pro Tech Note PTN#003 for details. */ #include #include #include #include // For offsetof macro. #include "PackedFile.h" #include "Variables.h" #include "IgorBin.h" #include "CrossPlatformFileIO.h" #include "IgorSupport.h" #include "PackedFileDemo.h" // Constants #define NOMEM 1 // Error code for out of memory. #define DEMO_WAVE_LENGTH 10 // Number of points in the demo wave. static void PrintResult(const char* message, int error) { char buffer[256]; if (error) sprintf(buffer, "Error %d: %s", error, message); else strcpy(buffer, message); printf("%s\n", buffer); } static void ReorderBytes(void *p, int bytesPerPoint, long numValues) // Reverses byte order. { unsigned char ch, *p1, *p2, *pEnd; pEnd = (unsigned char *)p + numValues*bytesPerPoint; while (p < (void *)pEnd) { p1 = p; p2 = (unsigned char *)p + bytesPerPoint-1; while (p1 < p2) { ch = *p1; *p1++ = *p2; *p2-- = ch; } p = (unsigned char *)p + bytesPerPoint; } } static void ReorderShort(void* sp) { ReorderBytes(sp, 2, 1); } static void ReorderLong(void* lp) { ReorderBytes(lp, 4, 1); } static void ReorderDouble(void* dp) { ReorderBytes(dp, 8, 1); } static void ReorderPackedFileRecordHeader(PackedFileRecordHeader* php) { ReorderShort(&php->recordType); ReorderShort(&php->version); ReorderLong(&php->numDataBytes); } static void ReorderVarHeader2(VarHeader2* vhp) { ReorderBytes(vhp, 2, 6); // 6 shorts } static void ReorderUserNumVarRec(UserNumVarRec* nvp) { // The name field does not need to be reordered. ReorderShort(&nvp->type); ReorderShort(&nvp->num.numType); ReorderDouble(&nvp->num.realPart); ReorderDouble(&nvp->num.imagPart); } static void ReorderUserDependentVarRec(UserDependentVarRec* dvp) { // The name field does not need to be reordered. ReorderShort(&dvp->type); ReorderShort(&dvp->num.numType); ReorderDouble(&dvp->num.realPart); ReorderDouble(&dvp->num.imagPart); ReorderShort(&dvp->formulaLen); // The formula field does not need to be reordered. } static void DisplayTextLines(const char* text, unsigned long textLength) { const char* p1; const char* p; long bytesInLine, bytesToDisplay, count; char line[512]; int i; p1 = text; for(i=0; i <= 3; i++) { if (i == 3) { printf(" Skipping the rest of the text.\n"); break; } p = strchr(p1, 13); // Look for next CR. if (p == NULL) { bytesInLine = text + textLength - p1; bytesToDisplay = bytesInLine; } else { bytesInLine = p+1 - p1; bytesToDisplay = bytesInLine - 1; // Exclude CR. } count = bytesToDisplay; if (count > sizeof(line)-1) count = sizeof(line)-1; strncpy(line, p1, count); line[count] = 0; printf(" Line %d: %s\n", i, line); p1 += bytesInLine; if (p1 < text + textLength) { if (*p1 == 10) p1 += 1; // Skip linefeed following carriage return. } if (p1 >= text + textLength) break; // All done. } } static int ReadPackedHeader(CP_FILE_REF fr, int needToReorderBytes, PackedFileRecordHeader* php) { unsigned long numBytesToRead, numBytesRead; int err; numBytesToRead = sizeof(PackedFileRecordHeader); if (err = CPReadFile(fr, numBytesToRead, php, &numBytesRead)) return err; if (needToReorderBytes) ReorderPackedFileRecordHeader(php); return 0; } static int ReadVariablesRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { VarHeader2 vh; short version; unsigned long numBytesToRead, numBytesRead; int i; int err; memset(&vh, 0, sizeof(vh)); // First determine if we have a version 1 or version 2 VarHeader structure. numBytesToRead = 2; if (err = CPReadFile(fr, numBytesToRead, &version, &numBytesRead)) { PrintResult("ReadVariablesRecord error", err); return err; } if (needToReorderBytes) ReorderShort(&version); CPSetFilePosition(fr, -2, 0); // Back up to the starting point. switch(version) { case 1: numBytesToRead = sizeof(VarHeader1); err = CPReadFile(fr, numBytesToRead, &vh, &numBytesRead); break; case 2: numBytesToRead = sizeof(VarHeader2); err = CPReadFile(fr, numBytesToRead, &vh, &numBytesRead); break; default: printf("Unknown VarHeader version: %d\n", version); err = -1; break; } if (err != 0) { PrintResult("Error reading VarHeader record", err); return err; } if (needToReorderBytes) ReorderVarHeader2(&vh); printf("--Variables record--\n"); printf(" System: %d, numeric: %d, string: %d, dependent numeric: %d, dependent string: %d\n", vh.numSysVars, vh.numUserVars, vh.numUserStrs, vh.numDependentVars, vh.numDependentStrs); // Read system variables. for(i = 0; i < vh.numSysVars; i++) { float f; numBytesToRead = sizeof(float); if (err = CPReadFile(fr, numBytesToRead, &f, &numBytesRead)) { PrintResult("Error reading system variable", err); return err; } if (needToReorderBytes) ReorderLong(&f); } // Read user numeric variables. for(i = 0; i < vh.numUserVars; i++) { UserNumVarRec nv; numBytesToRead = sizeof(nv); if (err = CPReadFile(fr, numBytesToRead, &nv, &numBytesRead)) { PrintResult("Error reading user numeric variable", err); return err; } if (needToReorderBytes) ReorderUserNumVarRec(&nv); if (i <= 3) { if (i == 3) { printf(" Skipping remaining numeric variables.\n"); } else { if (nv.num.numType & NT_CMPLX) printf(" Numeric variable %s, value=(%g,%g)\n", nv.name, nv.num.realPart, nv.num.imagPart); else printf(" Numeric variable %s, value=%g\n", nv.name, nv.num.realPart); } } } // Read user string variables. for(i = 0; i < vh.numUserStrs; i++) { UserStrVarRec1 sv1; UserStrVarRec2 sv2; char buffer[32]; char ellipsis[16]; unsigned long pos; if (version == 1) { numBytesToRead = offsetof(UserStrVarRec1, data); err = CPReadFile(fr, numBytesToRead, &sv1, &numBytesRead); if (err == 0) { if (needToReorderBytes) ReorderShort(&sv1.strLen); // Copy sv1 record to sv2. Only sv2 is used below. strcpy(sv2.name, sv1.name); sv2.strLen = sv1.strLen; } } else { numBytesToRead = offsetof(UserStrVarRec2, data); err = CPReadFile(fr, numBytesToRead, &sv2, &numBytesRead); if (err == 0) { if (needToReorderBytes) ReorderLong(&sv2.strLen); } } if (err != 0) { PrintResult("Error reading user string variable header", err); return err; } CPGetFilePosition(fr, &pos); numBytesToRead = sv2.strLen; if (numBytesToRead > sizeof(buffer)-1) numBytesToRead = sizeof(buffer)-1; if (err = CPReadFile(fr, numBytesToRead, buffer, &numBytesRead)) { PrintResult("Error reading user string variable", err); return err; } buffer[numBytesRead] = 0; if (numBytesRead < (unsigned long)sv2.strLen) // Read only part of the string? strcpy(ellipsis, "..."); // This is used below in printout. else *ellipsis = 0; CPSetFilePosition(fr, pos + sv2.strLen, -1); // Move to the end of the string. if (i <= 3) { if (i == 3) printf(" Skipping remaining string variables.\n"); else printf(" String variable %s, value=\"%s%s\"\n", sv2.name, buffer, ellipsis); } } // Read user dependent numeric variables. for(i = 0; i < vh.numDependentVars; i++) { UserDependentVarRec dv; numBytesToRead = sizeof(dv); if (err = CPReadFile(fr, numBytesToRead, &dv, &numBytesRead)) { PrintResult("Error reading user dependent numeric variable", err); return err; } if (needToReorderBytes) ReorderUserDependentVarRec(&dv); if (i <= 3) { if (i == 3) { printf(" Skipping remaining numeric dependent variables.\n"); } else { if (dv.num.numType & NT_CMPLX) printf(" Numeric dependent variable %s, value=(%g,%g)\n", dv.name, dv.num.realPart, dv.num.imagPart); else printf(" Numeric dependent variable %s, value=%g\n", dv.name, dv.num.realPart); } } } // Read user dependent string variables. for(i = 0; i < vh.numDependentStrs; i++) { UserDependentVarRec dv; numBytesToRead = sizeof(dv); if (err = CPReadFile(fr, numBytesToRead, &dv, &numBytesRead)) { PrintResult("Error reading user dependent string variable", err); return err; } if (needToReorderBytes) ReorderUserDependentVarRec(&dv); if (i <= 3) { if (i == 3) { printf(" Skipping remaining string dependent variables.\n"); } else { printf(" String dependent variable %s\n", dv.name); } } } return 0; } static int ReadHistoryRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { char* text; unsigned long numBytesToRead, numBytesRead; int err; printf("--History record--\n"); if (numDataBytes > 0) { text = malloc(numDataBytes); if (text == NULL) { printf("ReadHistoryRecord unable to allocate %ld bytes\n", numDataBytes); return -1; } numBytesToRead = numDataBytes; if (err = CPReadFile(fr, numBytesToRead, text, &numBytesRead)) { PrintResult("Error reading history", err); free(text); return err; } DisplayTextLines(text, numDataBytes); free(text); } return 0; } static int ReadWaveRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { int type; long npnts; void* waveDataPtr; int err; printf("--Wave record--\n"); err = ReadWave(fr, &type, &npnts, &waveDataPtr); // If no error occurred, the main wave data is now available via waveDataPtr. if (waveDataPtr != NULL) free(waveDataPtr); if (err) { PrintResult("Error reading wave", err); return err; } return 0; } static int ReadRecreationRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { char* text; unsigned long numBytesToRead, numBytesRead; int err; printf("--Recreation macros record--\n"); if (numDataBytes > 0) { text = malloc(numDataBytes); if (text == NULL) { printf("ReadRecreationRecord unable to allocate %ld bytes\n", numDataBytes); return -1; } numBytesToRead = numDataBytes; if (err = CPReadFile(fr, numBytesToRead, text, &numBytesRead)) { PrintResult("Error reading recreation procedures", err); free(text); return err; } DisplayTextLines(text, numDataBytes); free(text); } return 0; } static int ReadProcedureRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { char* text; unsigned long numBytesToRead, numBytesRead; int err; printf("--Procedures record--\n"); if (numDataBytes > 0) { text = malloc(numDataBytes); if (text == NULL) { printf("ReadProcedureRecord unable to allocate %ld bytes\n", numDataBytes); return -1; } numBytesToRead = numDataBytes; if (err = CPReadFile(fr, numBytesToRead, text, &numBytesRead)) { PrintResult("Error reading procedures", err); free(text); return err; } DisplayTextLines(text, numDataBytes); free(text); } return 0; } static int ReadGetHistoryRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { printf("--Get history record--\n"); return 0; } static int ReadPackedFileRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { printf("--Packed file record--\n"); printf(" This type of record is used to store packed notebooks and procedure windows.\n"); printf(" The format of the record is quite complex and is not documented in PTN003.\n"); return 0; } static int ReadDataFolderStartRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { unsigned long numBytesToRead, numBytesRead; char name[32]; int err; printf("--Data folder start record--\n"); numBytesToRead = 32; if (err = CPReadFile(fr, numBytesToRead, name, &numBytesRead)) { PrintResult("Error reading data folder name", err); return err; } printf(" Entering data folder \'%s\'.\n", name); return 0; } static int ReadDataFolderEndRecord(CP_FILE_REF fr, long numDataBytes, int needToReorderBytes) { printf("--Data folder end record--\n"); return 0; } static int ReadPackedRecords(CP_FILE_REF fr) { unsigned long numberOfBytesInFile; unsigned long recordStartPos; unsigned long numBytesToRead, numBytesRead; PackedFileRecordHeader ph; unsigned short stemp; int needToReorderBytes; int err; /* First we must determine if the file uses the wrong byte ordering, in which case we will need to do reordering. We do this by reading the recordType field of the first record. All record types have 0 in the high byte, except for a possibly set SUPERCEDED_MASK. */ numBytesToRead = 2; if (err = CPReadFile(fr, numBytesToRead, &stemp, &numBytesRead)) { PrintResult("Read file error", err); return err; } needToReorderBytes = 0; stemp &= PACKEDRECTYPE_MASK; // Clear SUPERCEDED_MASK bit. if ((stemp & 0xFF00) != 0) // High byte is non-zero. needToReorderBytes = 1; // The file uses the wrong byte ordering. CPSetFilePosition(fr, -2, 0); // Back up to the starting point. if (needToReorderBytes) { #ifdef WIN32 printf("This file uses big-endian byte ordering.\n"); #else printf("This file uses little-endian byte ordering.\n"); #endif } // Now read the records. CPNumberOfBytesInFile(fr, &numberOfBytesInFile); while(1) { CPGetFilePosition(fr, &recordStartPos); if (recordStartPos >= numberOfBytesInFile) break; // No more data in the file. if (err = ReadPackedHeader(fr, needToReorderBytes, &ph)) { PrintResult("ReadPackedHeader error", err); return err; } switch(ph.recordType) { case kVariablesRecord: // 1: Contains system numeric variables (e.g., K0) and user numeric and string variables. if (err = ReadVariablesRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kHistoryRecord: // 2: Contains the experiment's history as plain text. if (err = ReadHistoryRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kWaveRecord: // 3: Contains the data for a wave if (err = ReadWaveRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kRecreationRecord: // 4: Contains the experiment's recreation procedures as plain text. if (err = ReadRecreationRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kProcedureRecord: // 5: Contains the experiment's main procedure window text as plain text. if (err = ReadProcedureRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kGetHistoryRecord: // 6: Not a real record but rather a message to go back and read the history text. if (err = ReadGetHistoryRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kPackedFileRecord: // 7: Contains the data for a procedure file or notebook in a packed form. if (err = ReadPackedFileRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kDataFolderStartRecord: // 8: Marks the start of a new data folder. if (err = ReadDataFolderStartRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; case kDataFolderEndRecord: // 10: Marks the end of a data folder. if (err = ReadDataFolderEndRecord(fr, ph.numDataBytes, needToReorderBytes)) return err; break; default: // Here if we have an unknown record type or a superceded record. break; } // Skip to next record. CPSetFilePosition(fr, recordStartPos + sizeof(ph) + ph.numDataBytes, -1); } return 0; } int ReadPackedFile(const char* packedFilePath) { CP_FILE_REF fr; // Ref number for the file we are writing to. unsigned long numberOfBytesInFile; char temp[256]; int err; if (err = CPOpenFile(packedFilePath, 0, &fr)) { PrintResult("Open file error", err); return err; } CPNumberOfBytesInFile(fr, &numberOfBytesInFile); printf("The file consists of %ld bytes.\n", numberOfBytesInFile); // Read the records. if (err = ReadPackedRecords(fr)) return err; if (err = CPCloseFile(fr)) { PrintResult("Close file error", err); return err; } sprintf(temp, "\"%s\" read successfully.", packedFilePath); PrintResult(temp, 0); return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/IgorBin.h0000664000175000017500000001776114105434233020511 0ustar schloeglschloegl// IgorBin.h -- structures and #defines for dealing with Igor binary data. #ifdef __cplusplus extern "C" { #endif // All structures written to disk are 2-byte-aligned. #if GENERATINGPOWERPC #pragma options align=mac68k #endif #ifdef WIN32 #pragma pack(2) #endif #ifdef WIN32 typedef void** Handle; #endif // From IgorMath.h #define NT_CMPLX 1 // Complex numbers. #define NT_FP32 2 // 32 bit fp numbers. #define NT_FP64 4 // 64 bit fp numbers. #define NT_I8 8 // 8 bit signed integer. Requires Igor Pro 2.0 or later. #define NT_I16 0x10 // 16 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_I32 0x20 // 32 bit integer numbers. Requires Igor Pro 2.0 or later. #define NT_UNSIGNED 0x40 // Makes above signed integers unsigned. Requires Igor Pro 3.0 or later. // From wave.h #define MAXDIMS 4 // From binary.h typedef struct BinHeader1 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. short checksum; // Checksum over this header and the wave header. } BinHeader1; typedef struct BinHeader2 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. long noteSize; // The size of the note text. long pictSize; // Reserved. Write zero. Ignore on read. short checksum; // Checksum over this header and the wave header. } BinHeader2; typedef struct BinHeader3 { short version; // Version number for backwards compatibility. long wfmSize; // The size of the WaveHeader2 data structure plus the wave data plus 16 bytes of padding. long noteSize; // The size of the note text. long formulaSize; // The size of the dependency formula, if any. long pictSize; // Reserved. Write zero. Ignore on read. short checksum; // Checksum over this header and the wave header. } BinHeader3; typedef struct BinHeader5 { short version; // Version number for backwards compatibility. short checksum; // Checksum over this header and the wave header. long wfmSize; // The size of the WaveHeader5 data structure plus the wave data. long formulaSize; // The size of the dependency formula, if any. long noteSize; // The size of the note text. long dataEUnitsSize; // The size of optional extended data units. long dimEUnitsSize[MAXDIMS]; // The size of optional extended dimension units. long dimLabelsSize[MAXDIMS]; // The size of optional dimension labels. long sIndicesSize; // The size of string indicies if this is a text wave. long optionsSize1; // Reserved. Write zero. Ignore on read. long optionsSize2; // Reserved. Write zero. Ignore on read. } BinHeader5; // From wave.h #define MAX_WAVE_NAME2 18 // Maximum length of wave name in version 1 and 2 files. Does not include the trailing null. #define MAX_WAVE_NAME5 31 // Maximum length of wave name in version 5 files. Does not include the trailing null. #define MAX_UNIT_CHARS 3 // Header to an array of waveform data. struct WaveHeader2 { short type; // See types (e.g. NT_FP64) above. Zero for text waves. struct WaveHeader2 **next; // Used in memory only. Write zero. Ignore on read. char bname[MAX_WAVE_NAME2+2]; // Name of wave plus trailing null. short whVersion; // Write 0. Ignore on read. short srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char xUnits[MAX_UNIT_CHARS+1]; // Natural x-axis units go here - null if none. long npnts; // Number of data points in wave. short aModified; // Used in memory only. Write zero. Ignore on read. double hsA,hsB; // X value for point p = hsA*p + hsB short wModified; // Used in memory only. Write zero. Ignore on read. short swModified; // Used in memory only. Write zero. Ignore on read. short fsValid; // True if full scale values have meaning. double topFullScale,botFullScale; // The min full scale value for wave. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. void **formula; // Used in memory only. Write zero. Ignore on read. long depID; // Used in memory only. Write zero. Ignore on read. unsigned long creationDate; // DateTime of creation. Not used in version 1 files. char wUnused[2]; // Reserved. Write zero. Ignore on read. unsigned long modDate; // DateTime of last modification. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. float wData[4]; // The start of the array of waveform data. }; typedef struct WaveHeader2 WaveHeader2; typedef WaveHeader2 *WavePtr2; typedef WavePtr2 *waveHandle2; struct WaveHeader5 { struct WaveHeader5 **next; // link to next wave in linked list. unsigned long creationDate; // DateTime of creation. unsigned long modDate; // DateTime of last modification. long npnts; // Total number of points (multiply dimensions up to first zero). short type; // See types (e.g. NT_FP64) above. Zero for text waves. short dLock; // Reserved. Write zero. Ignore on read. char whpad1[6]; // Reserved. Write zero. Ignore on read. short whVersion; // Write 1. Ignore on read. char bname[MAX_WAVE_NAME5+1]; // Name of wave plus trailing null. long whpad2; // Reserved. Write zero. Ignore on read. struct DataFolder **dFolder; // Used in memory only. Write zero. Ignore on read. // Dimensioning info. [0] == rows, [1] == cols etc long nDim[MAXDIMS]; // Number of of items in a dimension -- 0 means no data. double sfA[MAXDIMS]; // Index value for element e of dimension d = sfA[d]*e + sfB[d]. double sfB[MAXDIMS]; // SI units char dataUnits[MAX_UNIT_CHARS+1]; // Natural data units go here - null if none. char dimUnits[MAXDIMS][MAX_UNIT_CHARS+1]; // Natural dimension units go here - null if none. short fsValid; // TRUE if full scale values have meaning. short whpad3; // Reserved. Write zero. Ignore on read. double topFullScale,botFullScale; // The max and max full scale value for wave. Handle dataEUnits; // Used in memory only. Write zero. Ignore on read. Handle dimEUnits[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle dimLabels[MAXDIMS]; // Used in memory only. Write zero. Ignore on read. Handle waveNoteH; // Used in memory only. Write zero. Ignore on read. long whUnused[16]; // Reserved. Write zero. Ignore on read. // The following stuff is considered private to Igor. short aModified; // Used in memory only. Write zero. Ignore on read. short wModified; // Used in memory only. Write zero. Ignore on read. short swModified; // Used in memory only. Write zero. Ignore on read. char useBits; // Used in memory only. Write zero. Ignore on read. char kindBits; // Reserved. Write zero. Ignore on read. void **formula; // Used in memory only. Write zero. Ignore on read. long depID; // Used in memory only. Write zero. Ignore on read. short whpad4; // Reserved. Write zero. Ignore on read. short srcFldr; // Used in memory only. Write zero. Ignore on read. Handle fileName; // Used in memory only. Write zero. Ignore on read. long **sIndices; // Used in memory only. Write zero. Ignore on read. float wData[1]; // The start of the array of data. Must be 64 bit aligned. }; typedef struct WaveHeader5 WaveHeader5; typedef WaveHeader5 *WavePtr5; typedef WavePtr5 *WaveHandle5; #if GENERATINGPOWERPC #pragma options align=reset #endif #ifdef WIN32 #pragma pack() #endif // All structures written to disk are 2-byte-aligned. #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/igor/ptn003/WritePackedFile.c0000664000175000017500000001461314105434233022146 0ustar schloeglschloegl/* The code in this file writes a sample Igor Pro packed experiment file. See Igor Pro Tech Note PTN#003 for details. */ #include #include #include #include // For offsetof macro. #include "PackedFile.h" #include "Variables.h" #include "IgorBin.h" #include "CrossPlatformFileIO.h" #include "IgorSupport.h" #include "PackedFileDemo.h" // Constants #define NOMEM 1 // Error code for out of memory. #define DEMO_WAVE_LENGTH 10 // Number of points in the demo wave. static void PrintResult(const char* message, int error) { char buffer[256]; if (error) sprintf(buffer, "Error %d: %s", error, message); else strcpy(buffer, message); printf("%s\n", buffer); } static int WriteDemoVariablesRecord(CP_FILE_REF fr) { unsigned long recordStartPos; char temp[256]; int err; if (err = CPGetFilePosition(fr, &recordStartPos)) // Remember where record starts in the file. return err; // Write the generic packed file record header. numDataBytes field will be updated later. if (err = WriteRecordHeader(fr, kVariablesRecord, 0, 0)) return err; // Write the specific header for variables data. if (err = WriteVariablesHeader(fr, 0, 1, 1, 0, 0)) // There will be one numeric and one string variable. return err; // Write the numeric variable. if (err = WriteNumericVar(fr, "userNumVar", 0, 1234.0, 0.0)) return err; // Write the string variable. strcpy(temp, "This is a string variable."); if (err = WriteStringVar(fr, "userStrVar", temp, strlen(temp))) return err; // Update the numDataBytes field to record the actual length of the data. if (err = SetRecordHeaderNumDataBytesField(fr, recordStartPos)) return err; return 0; } static void SetDemoWaveDataContents(float* fp, long numPoints) { float val; val = 0.0; while(numPoints > 0) { *fp++ = val; val += 1.0; numPoints -= 1; } } static int WriteDemoWave1DNumericWaveRecord(CP_FILE_REF fr) { WaveHeader2 wh; float* data; unsigned long recordStartPos; unsigned long creationDate; long waveMainDataSize, noteSize; char note[256]; int err; if (err = CPGetFilePosition(fr, &recordStartPos)) // Remember where record starts in the file. return err; // Write the generic packed file record header. numDataBytes field will be updated later. if (err = WriteRecordHeader(fr, kWaveRecord, 0, 0)) return err; // It is OK to pass 0 for creationDate if you don't care about it. #ifdef WIN32 creationDate = 0; // GetDateTime can be simulated on Windows but it is fairly complicated. #else GetDateTime(&creationDate); // Seconds since midnight, January 1, 1904. #endif // Create the demo data. waveMainDataSize = DEMO_WAVE_LENGTH * sizeof(float); // Size of just the numeric data. data = malloc(waveMainDataSize); if (data == NULL) return NOMEM; SetDemoWaveDataContents(data, DEMO_WAVE_LENGTH); // This sets structure to be valid for a 1D numeric wave. InitWaveHeader2(&wh, "wave0", creationDate, DEMO_WAVE_LENGTH, NT_FP32); // Set X scaling. x = hsA*p + hsB. wh.hsA = 0.2; wh.hsB = 0.0; /* For the checksum calculated by WriteVersion2NumericWave, the wData field of the WaveHeader2 structure must contain the same data as the first 16 bytes of the main wave data. The wData field was cleared by InitWaveHeader2. */ { int tmp = 16; if (waveMainDataSize < tmp) tmp = waveMainDataSize; memcpy(&wh.wData, data, tmp); } // We need to know the size of the wave note. strcpy(note, "This is wave0."); noteSize = strlen(note); // Write the wave. err = WriteVersion2NumericWave(fr, &wh, data, note, strlen(note)); free(data); if (err) return err; // Update the numDataBytes field to record the actual length of the data. if (err = SetRecordHeaderNumDataBytesField(fr, recordStartPos)) return err; return 0; } static int WriteDemoRecreationProcedures(CP_FILE_REF fr) { char text[1024]; // Generate text to call the Table0() macro defined below. strcpy(text, "Table0()"CR_STR); strcat(text, CR_STR); // Generate text for a table recreation macro to display wave0. strcat(text, "Window Table0() : Table"CR_STR); strcat(text, "\tPauseUpdate; Silent 1 | building window..."CR_STR); strcat(text, "\tEdit wave0"CR_STR); strcat(text, "End"CR_STR); return WritePlainTextRecord(fr, kRecreationRecord, text, strlen(text)); } static int WriteDemoProcedureWindowProcedures(CP_FILE_REF fr) { char text[1024]; // Generate procedure window text. strcpy(text, "Macro Demo()"CR_STR); strcat(text, "\tDoAlert 0, \"Greetings!\""CR_STR); strcat(text, "End"CR_STR); return WritePlainTextRecord(fr, kProcedureRecord, text, strlen(text)); } static int WriteDemoHistory(CP_FILE_REF fr) { char text[1024]; int err; // Generate history text. strcpy(text, "// This experiment was created using Igor Pro Tech Note PTN003"CR_STR); strcat(text, "// This tech note shows how to write a packed Igor Pro 3.0 file from your own program."CR_STR); if (err = WritePlainTextRecord(fr, kHistoryRecord, text, strlen(text))) return err; return WriteRecordHeader(fr, kGetHistoryRecord, 0, 0); } static int WriteDemoPackedFile(CP_FILE_REF fr) { int err; if (err = WriteDemoVariablesRecord(fr)) return err; if (err = WriteDemoWave1DNumericWaveRecord(fr)) return err; if (err = WriteDemoRecreationProcedures(fr)) return err; if (err = WriteDemoProcedureWindowProcedures(fr)) return err; if (err = WriteDemoHistory(fr)) return err; return 0; } int WritePackedFile(const char* packedFilePath) { CP_FILE_REF fr; // Ref number for the file we are writing to. char temp[256]; int err; // Delete test file if it already exists and create a new file. if (err = CPCreateFile(packedFilePath, 1, IGOR_CREATOR_CODE, IGOR_PACKED_FILE_TYPE)) { PrintResult("Create file error", err); return err; } if (err = CPOpenFile(packedFilePath, 1, &fr)) { PrintResult("Open file error", err); return err; } // Write all of the records to the file. if (err = WriteDemoPackedFile(fr)) { PrintResult("WritePackedFile error", err); return err; } if (err = CPCloseFile(fr)) { PrintResult("Close file error", err); return err; } sprintf(temp, "\"%s\" written successfully.", packedFilePath); PrintResult(temp, 0); return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/PackedFileDemo.h0000664000175000017500000000064714105434233021747 0ustar schloeglschloeglint ReadPackedFile(const char* packedFilePath); int WritePackedFile(const char* packedFilePath); int WriteVersion2NumericWave(CP_FILE_REF fr, WaveHeader2* whp, const void* data, const char* waveNote, long noteSize); int WriteVersion5NumericWave(CP_FILE_REF fr, WaveHeader5* whp, const void* data, const char* waveNote, long noteSize); int ReadWave(CP_FILE_REF fr, int* typePtr, long* npntsPtr, void** waveDataPtrPtr); biosig-2.3.3/biosig4c++/igor/ptn003/IgorSupport.c0000664000175000017500000002677114105434233021451 0ustar schloeglschloegl/* This file provides support for Igor-related things, such as writing variable and wave records, for the Packed File demo program. See main.c for examples showing how these routines are called. See Igor Pro Tech Note PTN#003 for details. */ #include #include #include // For offsetof macro. #include "PackedFile.h" #include "Variables.h" #include "IgorBin.h" #include "CrossPlatformFileIO.h" #include "IgorSupport.h" // Support for writing packed file records. int WriteRecordHeader(CP_FILE_REF fr, int recordType, int recordVersion, long recordBytes) { PackedFileRecordHeader h; unsigned long numBytesToWrite, numBytesWritten; int err; h.recordType = recordType; h.version = recordVersion; h.numDataBytes = recordBytes; numBytesToWrite = sizeof(PackedFileRecordHeader); err = CPWriteFile(fr, numBytesToWrite, &h, &numBytesWritten); return err; } /* SetRecordHeaderNumDataBytesField(...) This is used to set the numDataBytes field of the PackedFileRecordHeader structure on disk, after the data section of a record has been written. This must be called after writing the data section so that the current file mark is just after the last data byte written. */ int SetRecordHeaderNumDataBytesField(CP_FILE_REF fr, long recordStartPos) { unsigned long currentFilePos; long numDataBytes; unsigned long numBytesToWrite, numBytesWritten; long filePos; int err; if (err = CPGetFilePosition(fr, ¤tFilePos)) return err; numDataBytes = currentFilePos - recordStartPos - sizeof(PackedFileRecordHeader); filePos = recordStartPos + offsetof(PackedFileRecordHeader, numDataBytes); if (err = CPSetFilePosition(fr, filePos, -1)) return err; numBytesToWrite = sizeof(numDataBytes); if (err = CPWriteFile(fr, numBytesToWrite, &numDataBytes, &numBytesWritten)) return err; if (err = CPSetFilePosition(fr, currentFilePos, -1)) return err; return 0; } // Support for writing variables. int WriteNumericVar(CP_FILE_REF fr, const char* name, int isComplex, double realPart, double imagPart) { UserNumVarRec nv; unsigned long numBytesToWrite, numBytesWritten; int err; strcpy(nv.name, name); nv.type = 1; // Signifies numeric variable. if (isComplex) nv.num.numType = NT_FP64 | NT_CMPLX; // Double-precision, complex. else nv.num.numType = NT_FP64; // Double-precision, real. nv.num.realPart = realPart; nv.num.imagPart = imagPart; nv.num.reserved = 0; numBytesToWrite = sizeof(UserNumVarRec); err = CPWriteFile(fr, numBytesToWrite, &nv, &numBytesWritten); return err; } int WriteStringVar(CP_FILE_REF fr, const char* name, const char* contents, long numBytes) { UserStrVarRec2 sv; unsigned long numBytesToWrite, numBytesWritten; int err; strcpy(sv.name, name); sv.strLen = numBytes; numBytesToWrite = offsetof(UserStrVarRec2, data); if (err = CPWriteFile(fr, numBytesToWrite, &sv, &numBytesWritten)) // Write up to but not including the data field. return err; numBytesToWrite = numBytes; err = CPWriteFile(fr, numBytesToWrite, contents, &numBytesWritten); // Write the string data. return err; } int WriteVariablesHeader(CP_FILE_REF fr, int numSysVars, int numUserVars, int numUserStrs, int numDependentVars, int numDependentStrs) { VarHeader2 vh; unsigned long numBytesToWrite, numBytesWritten; int err; // Write the specific header for variables data. vh.version = 2; // Version 2 variables header. vh.numSysVars = numSysVars; vh.numUserVars = numUserVars; vh.numUserStrs = numUserStrs; vh.numDependentVars = numDependentVars; vh.numDependentStrs = numDependentStrs; numBytesToWrite = sizeof(vh); err = CPWriteFile(fr, numBytesToWrite, &vh, &numBytesWritten); return err; return 0; } // Support for writing waves. static long Checksum( short *data, long oldcksum, long numBytes) { numBytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. while(numBytes-- > 0) oldcksum += *data++; return oldcksum&0xffff; } /* WriteWaveBinHeader2(...) This writes a version 2 BinHeader to disk. The wave BinHeader contains a checksum over the BinHeader itself plus the following wave WaveHeader2 structure. The wData field of the WaveHeader2 structure is included in the checksum. Therefore, the wData field must contain the same data as the first 16 bytes of the actual wave data. The wfmSize parameter is the size of the WaveHeader2 structure up to but not including the wData field plus the size of the wave's main data bytes plus 16 bytes of padding. Main data bytes means the numeric data for numeric waves. The noteSize parameters can be 0. */ int WriteWaveBinHeader2( CP_FILE_REF fr, WavePtr2 wp, // Pointer to wave structure for wave to be written long wfmSize, // Size of wave structure plus wave data proper plus 16 bytes of padding long noteSize) { BinHeader2 bh; long checksum; unsigned long numBytesToWrite, numBytesWritten; int err; memset(&bh, 0, sizeof(BinHeader2)); bh.version = 2; // This is a version 2 wave record. bh.wfmSize = wfmSize; bh.noteSize = noteSize; // Do checksum over wave structure and then add checksum over wave header. checksum = Checksum((short *)wp, 0, sizeof(WaveHeader2)); // Includes wData field which must contain the same data as the first 16 bytes of the main wave data. checksum = -Checksum((short *)&bh, checksum, sizeof(struct BinHeader2)); bh.checksum = (short)checksum; numBytesToWrite = sizeof(BinHeader2); err = CPWriteFile(fr, numBytesToWrite, &bh, &numBytesWritten); return err; } /* InitWaveHeader2(...) Initializes the wave structure pointed to by wp to valid values for a 1D numeric wave. Since this sets all fields to safe values, you should call this first for all waves and then change the structure as needed for multi-dimensional or text waves. See PTN003 for details. If you don't care about setting the creation and modification dates, pass 0 for creationDate. numPoints is the number of data points in all dimensions of the wave. */ void InitWaveHeader2( WavePtr2 wp, // Pointer to wave structure to be inited. const char* name, // C string. Up to 31 characters. unsigned long creationDate, // Number of seconds since midnight January 1, 1904. long numPoints, // Number of points in the wave. int type) // Valid Igor number type. See IgorBin.h. { memset(wp, 0, sizeof(WaveHeader2)); wp->creationDate = creationDate; wp->modDate = creationDate; wp->npnts = numPoints; wp->type = type; wp->whVersion = 0; strcpy(wp->bname, name); wp->hsA = 1.0; wp->hsB = 0.0; } /* WriteWaveBinHeader5(...) This writes a version 5 BinHeader to disk. Because the wave BinHeader contains a checksum over the header itself plus the following wave WaveHeader5 structure, this routine requires a pointer to the WaveHeader5 structure to be written. The structure must contain the values to be written so that the checksum will be correct. The wfmSize parameter is the size of the WaveHeader5 structure up to but not including the wData field plus the size of the wave's main data bytes. Main data bytes means the numeric data for numeric waves or the text data for text waves but does not include any optional data or the string indices. All of the size parameters, except for wfmSize, can be 0. For text waves, the sIndicesSize must be as described in TN003 (not PTN003). */ int WriteWaveBinHeader5( CP_FILE_REF fr, WavePtr5 wp, // Pointer to wave structure for wave to be written long wfmSize, // size of wave structure plus wave data proper long formulaSize, long noteSize, long dataEUnitsSize, long dimEUnitsSize[], // Array of 4 longs or NULL if no extended dimension units long dimLabelsSize[], // Array of 4 longs or NULL if no dimension labels long sIndicesSize) // Size of string indices if this is a text wave { BinHeader5 bh; long checksum; unsigned long numBytesToWrite, numBytesWritten; int err; memset(&bh, 0, sizeof(BinHeader5)); bh.version = 5; // This is a version 5 wave record. bh.wfmSize = wfmSize; bh.formulaSize = formulaSize; bh.noteSize = noteSize; bh.dataEUnitsSize = dataEUnitsSize; if (dimEUnitsSize != NULL) memcpy(bh.dimEUnitsSize, dimEUnitsSize, MAXDIMS*sizeof(long)); if (dimLabelsSize != NULL) memcpy(bh.dimLabelsSize, dimLabelsSize, MAXDIMS*sizeof(long)); bh.sIndicesSize = sIndicesSize; // Do checksum over wave structure and then add checksum over wave header. checksum = Checksum((short *)wp, 0, offsetof(WaveHeader5, wData)); checksum = -Checksum((short *)&bh, checksum, sizeof(struct BinHeader5)); bh.checksum = (short)checksum; numBytesToWrite = sizeof(BinHeader5); err = CPWriteFile(fr, numBytesToWrite, &bh, &numBytesWritten); return err; } /* InitWaveHeader5(...) Initializes the wave structure pointed to by wp to valid values for a 1D numeric wave. Since this sets all fields to safe values, you should call this first for all waves and then change the structure as needed for multi-dimensional or text waves. See PTN003 for details. If you don't care about setting the creation and modification dates, pass 0 for creationDate. numPoints is the number of data points in all dimensions of the wave. */ void InitWaveHeader5( WavePtr5 wp, // Pointer to wave structure to be inited. const char* name, // C string. Up to 31 characters. unsigned long creationDate, // Number of seconds since midnight January 1, 1904. long numPoints, // Number of points in the wave. int type) // Valid Igor number type. See IgorBin.h. { int i; memset(wp, 0, sizeof(WaveHeader5)); wp->creationDate = creationDate; wp->modDate = creationDate; wp->npnts = numPoints; wp->type = type; wp->whVersion = 1; strcpy(wp->bname, name); wp->nDim[0] = numPoints; // This assumes a 1D wave. for(i = 0; i < MAXDIMS; i++) { wp->sfA[i] = 1.0; // Dimension scaling delta value. wp->sfB[i] = 0.0; // Dimension scaling offset value. } } // Support for data folders. int WriteDataFolderStartRecord(CP_FILE_REF fr, const char* name) { char temp[32]; unsigned long numBytesToWrite, numBytesWritten; int err; if (err = WriteRecordHeader(fr, kDataFolderStartRecord, 0, 32)) return err; memset(temp, 0, sizeof(temp)); strncpy(temp, name, 31); numBytesToWrite = 32; err = CPWriteFile(fr, numBytesToWrite, temp, &numBytesWritten); return err; } int WriteDataFolderEndRecord(CP_FILE_REF fr) { return WriteRecordHeader(fr, kDataFolderEndRecord, 0, 0); } // Support for plain text records (kRecreationRecord, kHistoryRecord, kProcedureRecord). int WritePlainTextRecord(CP_FILE_REF fr, int recordType, const char* text, long numBytes) { unsigned long recordStartPos; unsigned long numBytesToWrite, numBytesWritten; int err; if (err = CPGetFilePosition(fr, &recordStartPos)) // Remember where record starts in the file. return err; // Write the generic packed file record header. numDataBytes field will be updated later. if (err = WriteRecordHeader(fr, recordType, 0, 0)) return err; // Write the text. numBytesToWrite = numBytes; if (err = CPWriteFile(fr, numBytesToWrite, text, &numBytesWritten)) return err; // Update the numDataBytes field to record the actual length of the data. if (err = SetRecordHeaderNumDataBytesField(fr, recordStartPos)) return err; return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/PackedFileDemo.c0000664000175000017500000000555214105434233021742 0ustar schloeglschloegl/* This is the main file for the Packed File Demo program which writes an Igor Pro 3.x packed experiment file. See Igor Pro Tech Note PTN#003 for details. */ #include #include #include #include #include // For offsetof macro. #include "PackedFile.h" #include "Variables.h" #include "IgorBin.h" #include "CrossPlatformFileIO.h" #include "IgorSupport.h" #include "PackedFileDemo.h" static int GetNextCommand(char* filePath) { char input[1024]; int command; int i; *filePath = 0; while(1) { printf("Command: "); if (fgets(input, sizeof(input)-1, stdin) != NULL) { char* p = strchr(input, '\n'); // Find new line character. if (p != NULL) *p = 0; // Remove new line character. for(i=0; i<5; i++) input[i] = toupper(input[i]); // Convert command to upper case. if (strncmp(input, "READ ", 5) == 0) { command = 1; strcpy(filePath, input+5); break; } if (strncmp(input, "WRITE ", 6) == 0) { command = 2; strcpy(filePath, input+6); break; } if (strncmp(input, "QUIT", 4) == 0) { command = 3; break; } } printf("\n\n"); } return command; } int main(void) { int command; char filePath[1024]; char fullPathSample[32]; char partialPathSample[32]; int err; #ifdef WIN32 strcpy(fullPathSample, "C:\\FolderA\\Test Packed File.pxp"); strcpy(partialPathSample, ".\\Test Packed File.pxp"); #else strcpy(fullPathSample, "hd:FolderA:Test Packed File"); strcpy(partialPathSample, ":SamplesMac:Test Packed File"); #endif printf("This program illustrates reading and writing Igor packed experiment files.\n\n"); printf("To read a file, enter the following: Read \n\n"); printf("To write a file, enter the following: Write \n\n"); printf(" can be either a full path (%s)\n", fullPathSample); printf("or a partial path relative to the folder containing this program (%s)\n", partialPathSample); printf("\n"); printf("Here are some sample commands:\n"); #ifdef WIN32 printf(" Read Test Packed File.pxp\n"); printf(" Read .\\Test Packed File.pxp\n"); printf(" Write Test Packed File.pxp\n"); #else printf(" Read Test Packed File\n"); printf(" Read :Test Packed File\n"); printf(" Write Test Packed File\n"); #endif #ifdef WIN32 printf("To quit the program, type Quit\n"); #else printf("To quit the program, choose Quit from the file menu.\n"); #endif while(1) { printf("\n"); command = GetNextCommand(filePath); if (command == 1) err = ReadPackedFile(filePath); if (command == 2) err = WritePackedFile(filePath); if (command == 3) { #ifndef WIN32 printf("Now you must choose Quit from the File menu to quit.\n"); #endif break; } } return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/WriteWave.c0000664000175000017500000001336614105434233021065 0ustar schloeglschloegl// This file contains utilities for writing a wave file. #include #include #include #include #include #include "CrossPlatformFileIO.h" #include "IgorBin.h" #include "PackedFileDemo.h" /* Checksum(data,oldcksum,numbytes) Returns shortwise simpleminded checksum over the data. ASSUMES data starts on an even boundary. */ static int Checksum(short *data, int oldcksum, int numbytes) { numbytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. while(numbytes-- > 0) oldcksum += *data++; return oldcksum&0xffff; } /* NumBytesPerPoint(int type) Given a numeric wave type, returns the number of data bytes per point. */ static int NumBytesPerPoint(int type) { int numBytesPerPoint; // Consider the number type, not including the complex bit or the unsigned bit. switch(type & ~(NT_CMPLX | NT_UNSIGNED)) { case NT_I8: numBytesPerPoint = 1; // char break; case NT_I16: numBytesPerPoint = 2; // short break; case NT_I32: numBytesPerPoint = 4; // long break; case NT_FP32: numBytesPerPoint = 4; // float break; case NT_FP64: numBytesPerPoint = 8; // double break; default: return 0; break; } if (type & NT_CMPLX) numBytesPerPoint *= 2; // Complex wave - twice as many points. return numBytesPerPoint; } /* WriteVersion2NumericWave(fr, whp, data, waveNote, noteSize) Writes an Igor version 2 binary wave with the properties specified in whp, the data specified by data, and the wave note specified by waveNote and noteSize. Returns 0 or an error code. */ int WriteVersion2NumericWave(CP_FILE_REF fr, WaveHeader2* whp, const void* data, const char* waveNote, long noteSize) { unsigned long numBytesToWrite; unsigned long numBytesWritten; unsigned long waveDataSize; int numBytesPerPoint; short cksum; BinHeader2 bh; char padding[16]; int err; numBytesPerPoint = NumBytesPerPoint(whp->type); if (numBytesPerPoint <= 0) { printf("Invalid wave type (0x%x).\n", whp->type); return -1; } waveDataSize = whp->npnts * numBytesPerPoint; // Prepare the BinHeader structure. memset(&bh,0,sizeof(struct BinHeader2)); bh.version = 2; bh.wfmSize = offsetof(WaveHeader2, wData) + waveDataSize + 16; // Includes 16 bytes padding. bh.noteSize = noteSize; /* The checksum is over the BinHeader2 structure and the WaveHeader2 structure. The wData field of the WaveHeader2 structure is assumed to contain the same data as the first 16 bytes of the actual wave data. This is necessary to get the correct checksum. */ cksum = Checksum((short *)&bh, 0, sizeof(struct BinHeader2)); cksum = Checksum((short *)whp, cksum, sizeof(struct WaveHeader2)); bh.checksum = -cksum; do { // Write the BinHeader. numBytesToWrite = sizeof(struct BinHeader2); if (err = CPWriteFile(fr, numBytesToWrite, &bh, &numBytesWritten)) break; // Write the WaveHeader, up to but not including the wData field. numBytesToWrite = offsetof(WaveHeader2, wData); if (err = CPWriteFile(fr, numBytesToWrite, whp, &numBytesWritten)) break; // Write the wave data. numBytesToWrite = waveDataSize; if (err = CPWriteFile(fr, numBytesToWrite, data, &numBytesWritten)) break; // Write the 16 byte padding. memset(padding, 0, 16); // Write padding at the end of the wave data. numBytesToWrite = 16; if (err = CPWriteFile(fr, numBytesToWrite, padding, &numBytesWritten)) break; // Now write optional data, in the correct order. // Write the wave note. numBytesToWrite = noteSize; if (numBytesToWrite > 0) { if (err = CPWriteFile(fr, numBytesToWrite, waveNote, &numBytesWritten)) break; } } while(0); return err; } /* WriteVersion5NumericWave(fr, whp, data, waveNote, noteSize) Writes an Igor version 5 binary wave with the properties specified in whp, the data specified by data, and the wave note specified by waveNote and noteSize. Returns 0 or an error code. */ int WriteVersion5NumericWave(CP_FILE_REF fr, WaveHeader5* whp, const void* data, const char* waveNote, long noteSize) { unsigned long numBytesToWrite; unsigned long numBytesWritten; unsigned long waveDataSize; int numBytesPerPoint; short cksum; BinHeader5 bh; int err; numBytesPerPoint = NumBytesPerPoint(whp->type); if (numBytesPerPoint <= 0) { printf("Invalid wave type (0x%x).\n", whp->type); return -1; } waveDataSize = whp->npnts * numBytesPerPoint; // Prepare the BinHeader structure. memset(&bh,0,sizeof(struct BinHeader5)); bh.version = 5; bh.wfmSize = offsetof(WaveHeader5, wData) + waveDataSize; bh.noteSize = noteSize; /* The checksum is over the BinHeader5 structure and the WaveHeader5 structure, excluding the wData field. */ cksum = Checksum((short *)&bh, 0, sizeof(BinHeader5)); cksum = Checksum((short *)whp, cksum, offsetof(WaveHeader5, wData)); bh.checksum = -cksum; do { // Write the BinHeader. numBytesToWrite = sizeof(struct BinHeader5); if (err = CPWriteFile(fr, numBytesToWrite, &bh, &numBytesWritten)) break; // Write the WaveHeader, up to but not including the wData field. numBytesToWrite = offsetof(WaveHeader5, wData); if (err = CPWriteFile(fr, numBytesToWrite, whp, &numBytesWritten)) break; // Write the wave data. numBytesToWrite = waveDataSize; if (err = CPWriteFile(fr, numBytesToWrite, data, &numBytesWritten)) break; // Now write optional data, in the correct order. // Write the wave note. numBytesToWrite = noteSize; if (numBytesToWrite > 0) { if (err = CPWriteFile(fr, numBytesToWrite, waveNote, &numBytesWritten)) break; } } while(0); return err; } biosig-2.3.3/biosig4c++/igor/ptn003/ReadWave.c0000664000175000017500000003207514105434233020644 0ustar schloeglschloegl// This file contains an example of reading a wave file. #include #include #include #include #include #include "CrossPlatformFileIO.h" #include "IgorBin.h" #include "PackedFileDemo.h" static void ReorderBytes(void *p, int bytesPerPoint, long numValues) // Reverses byte order. { unsigned char ch, *p1, *p2, *pEnd; pEnd = (unsigned char *)p + numValues*bytesPerPoint; while (p < (void *)pEnd) { p1 = p; p2 = (unsigned char *)p + bytesPerPoint-1; while (p1 < p2) { ch = *p1; *p1++ = *p2; *p2-- = ch; } p = (unsigned char *)p + bytesPerPoint; } } static void ReorderShort(void* sp) { ReorderBytes(sp, 2, 1); } static void ReorderLong(void* lp) { ReorderBytes(lp, 4, 1); } static void ReorderDouble(void* dp) { ReorderBytes(dp, 8, 1); } static void ReorderBinHeader1(BinHeader1* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderShort(&p->checksum); } static void ReorderBinHeader2(BinHeader2* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } static void ReorderBinHeader3(BinHeader3* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); ReorderLong(&p->formulaSize); ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } static void ReorderBinHeader5(BinHeader5* p) { ReorderShort(&p->version); ReorderShort(&p->checksum); ReorderLong(&p->wfmSize); ReorderLong(&p->formulaSize); ReorderLong(&p->noteSize); ReorderLong(&p->dataEUnitsSize); ReorderBytes(&p->dimEUnitsSize, 4, 4); ReorderBytes(&p->dimLabelsSize, 4, 4); ReorderLong(&p->sIndicesSize); ReorderLong(&p->optionsSize1); ReorderLong(&p->optionsSize2); } static void ReorderWaveHeader2(WaveHeader2* p) { ReorderShort(&p->type); ReorderLong(&p->next); // char bname does not need to be reordered. ReorderShort(&p->whVersion); ReorderShort(&p->srcFldr); ReorderLong(&p->fileName); // char dataUnits does not need to be reordered. // char xUnits does not need to be reordered. ReorderLong(&p->npnts); ReorderShort(&p->aModified); ReorderDouble(&p->hsA); ReorderDouble(&p->hsB); ReorderShort(&p->wModified); ReorderShort(&p->swModified); ReorderShort(&p->fsValid); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. ReorderLong(&p->formula); ReorderLong(&p->depID); ReorderLong(&p->creationDate); // char wUnused does not need to be reordered. ReorderLong(&p->modDate); ReorderLong(&p->waveNoteH); // The wData field marks the start of the wave data which will be reordered separately. } static void ReorderWaveHeader5(WaveHeader5* p) { ReorderLong(&p->next); ReorderLong(&p->creationDate); ReorderLong(&p->modDate); ReorderLong(&p->npnts); ReorderShort(&p->type); ReorderShort(&p->dLock); // char whpad1 does not need to be reordered. ReorderShort(&p->whVersion); // char bname does not need to be reordered. ReorderLong(&p->whpad2); ReorderLong(&p->dFolder); ReorderBytes(&p->nDim, 4, 4); ReorderBytes(&p->sfA, 8, 4); ReorderBytes(&p->sfB, 8, 4); // char dataUnits does not need to be reordered. // char dimUnits does not need to be reordered. ReorderShort(&p->fsValid); ReorderShort(&p->whpad3); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); ReorderLong(&p->dataEUnits); ReorderBytes(&p->dimEUnits, 4, 4); ReorderBytes(&p->dimLabels, 4, 4); ReorderLong(&p->waveNoteH); ReorderBytes(&p->whUnused, 4, 16); ReorderShort(&p->aModified); ReorderShort(&p->wModified); ReorderShort(&p->swModified); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. ReorderLong(&p->formula); ReorderLong(&p->depID); ReorderShort(&p->whpad4); ReorderShort(&p->srcFldr); ReorderLong(&p->fileName); ReorderLong(&p->sIndices); // The wData field marks the start of the wave data which will be reordered separately. } static int Checksum(short *data, int needToReorderBytes, int oldcksum, int numbytes) { unsigned short s; numbytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. while(numbytes-- > 0) { s = *data++; if (needToReorderBytes) ReorderShort(&s); oldcksum += s; } return oldcksum&0xffff; } /* NumBytesPerPoint(int type) Given a numeric wave type, returns the number of data bytes per point. */ static int NumBytesPerPoint(int type) { int numBytesPerPoint; // Consider the number type, not including the complex bit or the unsigned bit. switch(type & ~(NT_CMPLX | NT_UNSIGNED)) { case NT_I8: numBytesPerPoint = 1; // char break; case NT_I16: numBytesPerPoint = 2; // short break; case NT_I32: numBytesPerPoint = 4; // long break; case NT_FP32: numBytesPerPoint = 4; // float break; case NT_FP64: numBytesPerPoint = 8; // double break; default: return 0; break; } if (type & NT_CMPLX) numBytesPerPoint *= 2; // Complex wave - twice as many points. return numBytesPerPoint; } /* LoadNumericWaveData(fr, type, npnts, waveDataSize, needToReorderBytes, pp) fr is a file reference. type is the Igor number type. npnts is the total number of elements in all dimensions. waveDataSize is the number of data bytes stored in the file. needToReorderBytes if the byte ordering of the file is not the byte ordering of the current platform. pp is a pointer to a pointer. If an error occurs, LoadNumericWaveData returns a non-zero error code and sets *pp to NULL. If no error occurs, LoadNumericWaveData returns 0 and sets *pp to a pointer allocated via malloc. This pointer must be freed by the calling routine. For simplicity, this example does not handle text waves. */ static int LoadNumericWaveData(CP_FILE_REF fr, int type, long npnts, unsigned long waveDataSize, int needToReorderBytes, void**pp) { int numBytesPerPoint; unsigned long numBytesToRead, numBytesToAllocate; unsigned long numBytesRead; void* p; int err; *pp = NULL; // Assume that we can not allocate memory. numBytesPerPoint = NumBytesPerPoint(type); if (numBytesPerPoint <= 0) { printf("Invalid wave type (0x%x).\n", type); return -1; } numBytesToRead = npnts * numBytesPerPoint; if (type & NT_CMPLX) numBytesToRead *= 2; // Complex wave - twice as many points. numBytesToAllocate = numBytesToRead; if (numBytesToAllocate == 0) numBytesToAllocate = 8; // This is just because malloc refuses to allocate a zero byte block. p = malloc(numBytesToAllocate); // Allocate memory to store the wave data. if (p == NULL) { printf("Unable to allocate %ld bytes to store data.\n", numBytesToAllocate); return -1; } if (numBytesToRead > 0) { if (waveDataSize < numBytesToRead) { /* If here, this should be a wave governed by a dependency formula for which no wave data was written to the file. Since we can't execute the dependency formula we have no way to recreate the wave's data. Therefore, we return 0 for all points in the wave. */ memset(p, 0, numBytesToRead); } else { if (err = CPReadFile(fr, numBytesToRead, p, &numBytesRead)) { free(p); printf("Error %d occurred while reading the wave data.\n", err); return err; } if (needToReorderBytes) { if (type != 0) // Text wave data does not need to be reordered. ReorderBytes(p, numBytesPerPoint, numBytesToRead/numBytesPerPoint); } } } *pp = p; // Return the pointer to the calling routine. return 0; } /* ReadWave(fr, typePtr, npntsPtr, waveDataPtrPtr) Reads the wave file and prints some information about it. Returns to the calling routine the wave's type, number of points, and the wave data. The calling routine must free *waveDataPtrPtr if it is not null. Returns 0 or an error code. */ int ReadWave(CP_FILE_REF fr, int* typePtr, long* npntsPtr, void** waveDataPtrPtr) { unsigned long startFilePos; short version; short check; int binHeaderSize, waveHeaderSize, checkSumSize; unsigned long waveDataSize; unsigned long numBytesRead; int needToReorderBytes; char buffer[512]; WaveHeader2* w2; WaveHeader5* w5; unsigned long modDate; long npnts; int type; char name[64]; int err; *waveDataPtrPtr = NULL; *typePtr = 0; *npntsPtr = 0; if (err = CPGetFilePosition(fr, &startFilePos)) return err; // Read the wave version field. if (err = CPReadFile(fr, 2, &version, &numBytesRead)) { printf("Error %d occurred while reading the wave version.\n", err); return err; } /* Reorder version field bytes if necessary. If the low order byte of the version field of the BinHeader structure is zero then the file is from a platform that uses different byte-ordering and therefore all data will need to be reordered. */ needToReorderBytes = (version & 0xFF) == 0; if (needToReorderBytes) ReorderShort(&version); // Check the version. switch(version) { case 1: printf(" This is a version 1 wave.\n"); binHeaderSize = sizeof(BinHeader1); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 2: printf(" This is a version 2 wave.\n"); binHeaderSize = sizeof(BinHeader2); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 3: printf(" This is a version 3 wave.\n"); binHeaderSize = sizeof(BinHeader3); waveHeaderSize = sizeof(WaveHeader2); checkSumSize = binHeaderSize + waveHeaderSize; break; case 5: printf(" This is a version 5 wave.\n"); binHeaderSize = sizeof(BinHeader5); waveHeaderSize = sizeof(WaveHeader5); checkSumSize = binHeaderSize + waveHeaderSize - 4; // Version 5 checksum does not include the wData field. break; default: printf(" This does not appear to be a valid Igor binary wave. The version field = %d.\n", version); return -1; break; } // Load the BinHeader and the WaveHeader into memory. CPSetFilePosition(fr, startFilePos, -1); if (err = CPReadFile(fr, binHeaderSize+waveHeaderSize, buffer, &numBytesRead)) { printf("Error %d occurred while reading the wave headers.\n", err); return err; } // Check the checksum. check = Checksum((short*)buffer, needToReorderBytes, 0, checkSumSize); if (check != 0) { printf("Error in checksum - should be 0, is %d.\n", check); printf("This does not appear to be a valid Igor binary wave.\n"); return -1; } // Do byte reordering if the file is from another platform. if (needToReorderBytes) { switch(version) { case 1: ReorderBinHeader1((BinHeader1*)buffer); break; case 2: ReorderBinHeader2((BinHeader2*)buffer); break; case 3: ReorderBinHeader3((BinHeader3*)buffer); break; case 5: ReorderBinHeader5((BinHeader5*)buffer); break; } switch(version) { case 1: // Version 1 and 2 files use WaveHeader2. case 2: case 3: ReorderWaveHeader2((WaveHeader2*)(buffer+binHeaderSize)); break; case 5: ReorderWaveHeader5((WaveHeader5*)(buffer+binHeaderSize)); break; } } // Read some of the WaveHeader fields. switch(version) { case 1: case 2: case 3: w2 = (WaveHeader2*)(buffer+binHeaderSize); modDate = w2->modDate; npnts = w2->npnts; type = w2->type; strcpy(name, w2->bname); break; case 5: w5 = (WaveHeader5*)(buffer+binHeaderSize); modDate = w5->modDate; npnts = w5->npnts; type = w5->type; strcpy(name, w5->bname); break; } printf(" Wave name=%s, npnts=%d, type=0x%x.\n", name, npnts, type); // Return information to the calling routine. *typePtr = type; *npntsPtr = npnts; // Determine the number of bytes of wave data in the file. switch(version) { case 1: waveDataSize = ((BinHeader1*)buffer)->wfmSize - sizeof(WaveHeader2); break; case 2: waveDataSize = ((BinHeader2*)buffer)->wfmSize - sizeof(WaveHeader2); break; case 3: waveDataSize = ((BinHeader3*)buffer)->wfmSize - sizeof(WaveHeader2); break; case 5: waveDataSize = ((BinHeader5*)buffer)->wfmSize - (sizeof(WaveHeader5) - 4); break; } // Position the file pointer to the start of the wData field. switch(version) { case 1: case 2: case 3: CPSetFilePosition(fr, startFilePos+binHeaderSize+waveHeaderSize-16, -1); // 16 = size of wData field in WaveHeader2 structure. break; case 5: CPSetFilePosition(fr, startFilePos+binHeaderSize+waveHeaderSize-4, -1); // 4 = size of wData field in WaveHeader2 structure. break; } if (type == 0) { // For simplicity, we don't load text wave data in this example program. printf(" This is a text wave.\n"); return 0; } // Load the data and allocates memory to store it. if (err = LoadNumericWaveData(fr, type, npnts, waveDataSize, needToReorderBytes, waveDataPtrPtr)) return err; return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/IgorSupport.h0000664000175000017500000000233414105434233021443 0ustar schloeglschloegl// Prototypes for IgorSupport.c. int WriteRecordHeader(CP_FILE_REF fr, int recordType, int recordVersion, long recordBytes); int SetRecordHeaderNumDataBytesField(CP_FILE_REF fr, long recordStartPos); int WriteNumericVar(CP_FILE_REF fr, const char* name, int isComplex, double realPart, double imagPart); int WriteStringVar(CP_FILE_REF fr, const char* name, const char* contents, long numBytes); int WriteVariablesHeader(CP_FILE_REF fr, int numSysVars, int numUserVars, int numUserStrs, int numDependentVars, int numDependentStrs); int WriteWaveBinHeader2(CP_FILE_REF fr, WavePtr2 wp, long waveDataSize, long noteSize); void InitWaveHeader2(WavePtr2 wp, const char* name, unsigned long creationDate, long numPoints, int type); int WriteWaveBinHeader5(CP_FILE_REF fr, WavePtr5 wp, long waveDataSize, long formulaSize, long noteSize, long extDataUnitsSize, long extDimUnitsSize[], long dimLabelsSize[], long sIndiciesSize); void InitWaveHeader5(WavePtr5 wp, const char* name, unsigned long creationDate, long numPoints, int type); int WriteDataFolderStartRecord(CP_FILE_REF fr, const char* name); int WriteDataFolderEndRecord(CP_FILE_REF fr); int WritePlainTextRecord(CP_FILE_REF fr, int recordType, const char* text, long numBytes); biosig-2.3.3/biosig4c++/igor/ptn003/PackedFile.h0000664000175000017500000000571114105434233021137 0ustar schloeglschloegl/* Data structure and equates relating to Igor Pro packed files. See Igor Pro Technical Note PTN003 for details. */ #ifdef __cplusplus extern "C" { #endif /* All structures written to disk are 2 byte-aligned */ #if GENERATINGPOWERPC #pragma options align=mac68k #endif #ifdef _WINDOWS_ #pragma pack(2) #endif #define CR_STR "\015" // CR is the line terminator used by Igor. #define IGOR_CREATOR_CODE 'IGR0' // Mac file creator code (zero at the end). #define IGOR_PACKED_FILE_TYPE 'IGsU' // Mac file type code for packed experiment file. #define IGOR_PACKED_STATIONERY_TYPE 'IGsS' // Mac file type code for packed experiment stationery file. /* *** Packed File Structures *** */ /* The Igor Pro packed file consists of a series of records. Each record starts with a record header followed by the record data. The record header identifies the type and size of the record data. New types may be added in the future. When reading a packed file, you should skip over records whose types you do not know. */ enum PackedFileRecordType { kUnusedRecord = 0, kVariablesRecord, // 1: Contains system numeric variables (e.g., K0) and user numeric and string variables. kHistoryRecord, // 2: Contains the experiment's history as plain text. kWaveRecord, // 3: Contains the data for a wave kRecreationRecord, // 4: Contains the experiment's recreation procedures as plain text. kProcedureRecord, // 5: Contains the experiment's main procedure window text as plain text. kUnused2Record, kGetHistoryRecord, // 6: Not a real record but rather, a message to go back and read the history text. kPackedFileRecord, // 7: Contains the data for a procedure file or notebook in a packed form. kDataFolderStartRecord, // 8: Marks the start of a new data folder. kDataFolderEndRecord // 10: Marks the end of a data folder. /* Igor writes other kinds of records in a packed experiment file, for storing things like pictures, page setup records, and miscellaneous settings. The format for these records is quite complex and is not described in PTN003. If you are writing a program to read packed files, you must skip any record with a record type that is not listed above. */ }; typedef struct PackedFileRecordHeader { unsigned short recordType; /* Record type plus superceded flag. */ short version; /* Version information depends on the type of record. */ long numDataBytes; /* Number of data bytes in the record following this record header. */ } PackedFileRecordHeader, *PackedFileRecordHeaderPtr; #define PACKEDRECTYPE_MASK 0x7FFF /* Record type = (recordType & PACKEDREC_TYPE_MASK) */ #define SUPERCEDED_MASK 0x8000 /* Bit is set if the record is superceded by a later record in the packed file. */ #if GENERATINGPOWERPC #pragma options align=reset #endif #ifdef _WINDOWS_ #pragma pack() #endif /* All structures written to disk are 2 byte-aligned */ #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/igor/ptn003/COPYING0000664000175000017500000000041714105434233020030 0ustar schloeglschloeglThese files were downloaded from ftp://ftp.wavemetrics.net/IgorPro/Technical_Notes/PTN003.zip When inquiring about the license, Howard Rodstein wrote on 2013-02-11: "You can use the files you mentioned for any purpose without restriction." biosig-2.3.3/biosig4c++/igor/ptn003/CrossPlatformFileIO.c0000664000175000017500000002510714105434233022772 0ustar schloeglschloegl// This file contains utilities for cross-platform file I/O. #include #include #include #include #include #ifdef WIN32 #include #endif // The Windows headers create the WIN32 symbol if we are compiling for Windows. // Here, we create an analogous MACINTOSH symbol if we are compiling for Macintosh. #if (defined(GENERATINGPOWERPC) || defined(GENERATING68K)) #define MACINTOSH 1 #endif #include "CrossPlatformFileIO.h" /* CPCreateFile(fullFilePath, overwrite, macCreator, macFileType) Creates a file with the location and name specified by fullFilePath. fullFilePath must be a native path. If overwrite is true and a file by that name already exists, it first deletes the conflicting file. If overwrite is false and a file by that name exists, it returns an error. macFileType is ignored on Windows. On Macintosh, it is used to set the new file's type. For example, use 'TEXT' for a text file. macCreator is ignored on Windows. On Macintosh, it is used to set the new file's creator code. For example, use 'IGR0' (last character is zero) for an file. Returns 0 if OK or an error code. */ int CPCreateFile(const char* fullFilePath, int overwrite, long macCreator, long macFileType) { int err; if (overwrite) // Delete file if it exists and if overwrite is specified. CPDeleteFile(fullFilePath); // Ignore error. #ifdef MACINTOSH if (err = create(fullFilePath, 0, macCreator, macFileType)) return err; return 0; #endif #ifdef WIN32 { HANDLE fileH; long accessMode, shareMode; err = 0; accessMode = GENERIC_READ | GENERIC_WRITE; shareMode = 0; fileH = CreateFile(fullFilePath, accessMode, shareMode, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (fileH == INVALID_HANDLE_VALUE) err = GetLastError(); else CloseHandle(fileH); return err; } #endif } /* CPDeleteFile(fullFilePath) Deletes the file specified by fullFilePath. fullFilePath must be a native path. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPDeleteFile(const char* fullFilePath) { #ifdef MACINTOSH int err; if (err = fsdelete(fullFilePath, 0)) return err; return 0; #endif #ifdef WIN32 { int err; err = 0; if (DeleteFile(fullFilePath) == 0) err = GetLastError(); return err; } #endif } /* CPOpenFile(fullFilePath, readOrWrite, fileRefPtr) If readOrWrite is zero, opens an existing file for reading and returns a file reference via fileRefPtr. If readOrWrite is non-zero, opens an existing file for writing or creates a new file if none exists and returns a file reference via fileRefPtr. fullFilePath must be a native path. Returns 0 if OK or an error code. */ int CPOpenFile(const char* fullFilePath, int readOrWrite, CP_FILE_REF* fileRefPtr) { *fileRefPtr = fopen(fullFilePath, readOrWrite ? "wb" : "rb"); if (*fileRefPtr == NULL) return CP_FILE_OPEN_ERROR; return 0; } /* CPCloseFile(fileRef) Closes the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPCloseFile(CP_FILE_REF fileRef) { if (fclose(fileRef)) return CP_FILE_CLOSE_ERROR; return 0; } /* CPReadFile(fileRef, count, buffer, numBytesReadPtr) Reads count bytes from the referenced file into the buffer. If numBytesReadPtr is not NULL, stores the number of bytes read in *numBytesReadPtr. Returns 0 if OK or an error code. If bytes remain to be read in the file and you ask to read more bytes than remain, the remaining bytes are returned and the function result is zero. If no bytes remain to be read in the file and you ask to read bytes, no bytes are returned and the function result is CP_FILE_EOF_ERROR. CPReadFile is appropriate when you are reading data of variable size, in which case you do not want to consider it an error if the end of file is reached before reading all of the bytes that you requested. If you are reading a record of fixed size, use use CPReadFile2 instead of CPReadFile. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPReadFile(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr) { unsigned long numBytesRead; if (count == 0) { if (numBytesReadPtr != NULL) *numBytesReadPtr = 0; return 0; } clearerr(fileRef); numBytesRead = fread(buffer, 1, count, fileRef); if (numBytesReadPtr != NULL) *numBytesReadPtr = numBytesRead; if (ferror(fileRef)) return CP_FILE_READ_ERROR; if (numBytesRead==0 && CPAtEndOfFile(fileRef)) return CP_FILE_EOF_ERROR; // We were at the end of file when asked to read some bytes. return 0; } /* CPReadFile2(fileRef, count, buffer, numBytesReadPtr) Reads count bytes from the referenced file into the buffer. If numBytesReadPtr is not NULL, stores the number of bytes read in *numBytesReadPtr. Returns 0 if OK or an error code. If bytes remain to be read in the file and you ask to read more bytes than remain, the remaining bytes are returned and the function result is CP_FILE_EOF_ERROR. CPReadFile2 is appropriate when you are reading a record of fixed size, in which case you want to consider it an error if the end of file is reached before reading all of the bytes in the record. If you are reading a record of variable size then you should use CPReadFile instead of CPReadFile2. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPReadFile2(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr) { unsigned long numBytesRead; if (count == 0) { if (numBytesReadPtr != NULL) *numBytesReadPtr = 0; return 0; } clearerr(fileRef); numBytesRead = fread(buffer, 1, count, fileRef); if (numBytesReadPtr != NULL) *numBytesReadPtr = numBytesRead; if (ferror(fileRef)) return CP_FILE_READ_ERROR; if (numBytesRead < count) { // We did not read all of the bytes requested. if (CPAtEndOfFile(fileRef)) return CP_FILE_EOF_ERROR; // We hit the end of file. return CP_FILE_READ_ERROR; // Some other occurred but ferror did not reflect it. } return 0; } /* CPWriteFile(fileRef, count, buffer, numBytesWrittenPtr) Writes count bytes from the buffer to the referenced file. If numBytesWrittenPtr is not NULL, stores the number of bytes written in *numBytesWrittenPtr. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPWriteFile(CP_FILE_REF fileRef, unsigned long count, const void* buffer, unsigned long* numBytesWrittenPtr) { unsigned long numBytesWritten; if (count == 0) { if (numBytesWrittenPtr != NULL) *numBytesWrittenPtr = 0; return 0; } numBytesWritten = fwrite(buffer, 1, count, fileRef); if (numBytesWrittenPtr != NULL) *numBytesWrittenPtr = numBytesWritten; if (numBytesWritten != count) return CP_FILE_WRITE_ERROR; return 0; } /* CPGetFilePosition(fileRef, filePosPtr) Returns via filePosPtr the current file position of the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPGetFilePosition(CP_FILE_REF fileRef, unsigned long* filePosPtr) { long pos; pos = ftell(fileRef); if (pos == -1L) return CP_FILE_POS_ERROR; *filePosPtr = pos; return 0; } /* CPSetFilePosition(fileRef, filePos, mode) Sets the current file position in the referenced file. If mode is -1, then filePos is relative to the start of the file. If mode is 0, then filePos is relative to the current file position. If mode is 1, then filePos is relative to the end of the file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPSetFilePosition(CP_FILE_REF fileRef, long filePos, int mode) { int seekMode; switch(mode) { case -1: seekMode = SEEK_SET; break; case 0: seekMode = SEEK_CUR; break; case 1: seekMode = SEEK_END; break; default: return CP_FILE_POS_ERROR; } if (fseek(fileRef, filePos, seekMode) != 0) return CP_FILE_POS_ERROR; return 0; } /* CPAtEndOfFile(fileRef) Returns 1 if the current file position is at the end of file, 0 if not. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPAtEndOfFile(CP_FILE_REF fileRef) { if (feof(fileRef)) // Hit end of file? return 1; return 0; } /* CPNumberOfBytesInFile(fileRef, numBytesPtr) Returns via numBytesPtr the total number of bytes in the referenced file. Returns 0 if OK or an error code. Added for Igor Pro 3.13 but works with any version. However, some error codes returned require Igor Pro 3.13 or later, so you will get bogus error messages if you return these error codes to earlier versions of Igor. */ int CPNumberOfBytesInFile(CP_FILE_REF fileRef, unsigned long* numBytesPtr) { long originalPos; originalPos = ftell(fileRef); if (fseek(fileRef, 0, SEEK_END) != 0) return CP_FILE_POS_ERROR; *numBytesPtr = ftell(fileRef); if (*numBytesPtr == -1L) return CP_FILE_POS_ERROR; if (fseek(fileRef, originalPos, SEEK_SET) != 0) return CP_FILE_POS_ERROR; return 0; } biosig-2.3.3/biosig4c++/igor/ptn003/Variables.h0000664000175000017500000001052614105434233021060 0ustar schloeglschloegl/* Structures and equates used for version 1 and 2 Igor Pro variable records. See Igor Pro Technical Note PTN003 for details. */ #ifdef __cplusplus extern "C" { #endif // All structures written to disk are 2-byte-aligned. #if GENERATINGPOWERPC #pragma options align=mac68k #endif #ifdef WIN32 #pragma pack(2) #endif /* VarHeader1 This is the header written at the start of the version 1 variables record, before the actual variable data. The entire variables record on disk consists of: PackedFileRecordHeader of type kVariablesRecord numSysVars system variables written as floats in order (K0, K1 . . . K19). numUserVars user numeric variables, each written as a UserNumVarRec record. numUserStrs user string variables, each consisting of a UserStrVarRec record. */ typedef struct VarHeader1 { short version; // Version number is 1 for this header. short numSysVars; // Number of system variables (K0, K1 . . .). short numUserVars; // Number of user numeric variables -- may be zero./ short numUserStrs; // Number of user string variables -- may be zero. } VarHeader1; /* UserStrVarRec1 This header precedes each user string variable in a version 2 variables record. */ typedef struct UserStrVarRec1 { char name[31+1]; // Name of the string variable. short strLen; // The real size of the following array. char data[1]; } UserStrVarRec1; /* VarHeader2 This is the header written at the start of the version 2 variables record, before the actual variable data. The entire variables record on disk consists of: PackedFileRecordHeader of type kVariablesRecord numSysVars system variables written as floats in order (K0, K1 . . . K19). numUserVars user numeric variables, each written as a UserNumVarRec record. numUserStrs user string variables, each consisting of a UserStrVarRec record. numDependentVars user dependent numeric variables, each consisting of a UserDependentVarRec record. numDependentStrs user dependent string variables, each consisting of a UserDependentVarRec record. */ typedef struct VarHeader2 { short version; // Version number is 2 for this header. short numSysVars; // Number of system variables (K0, K1 . . .). short numUserVars; // Number of user numeric variables -- may be zero. short numUserStrs; // Number of user string variables -- may be zero. short numDependentVars; // Number of dependent numeric variables -- may be zero. short numDependentStrs; // Number of dependent string variables -- may be zero. } VarHeader2; /* UserStrVarRec2 This header precedes each user string variable in a version 2 variables record. */ typedef struct UserStrVarRec2 { char name[31+1]; // Name of the string variable. long strLen; // Number of bytes in the string. char data[1]; // Start of string data. This is not a C string - no null terminator. } UserStrVarRec2; struct VarNumRec { short numType; // Type from IgorMath.h. double realPart; // The real part of the number. double imagPart; // The imag part if the number is complex. long reserved; // Reserved - set to zero. }; typedef struct VarNumRec VarNumRec; /* UserNumVarRec This header precedes each user numeric variable. */ typedef struct UserNumVarRec { char name[31+1]; // Name of the variable as a C string including null terminator. short type; // Must be 1, signifying numeric. VarNumRec num; // Type and value of the variable if it is numeric. } UserNumVarRec; /* UserDependentVarRec This header precedes each user dependent numeric or string variable. A dependent variable is one controlled by a dependency formula, such as: numVar0 := 2*numVar1 */ typedef struct UserDependentVarRec { char name[31+1]; // Name of the variable. short type; // 0 = string, 1 = numeric. VarNumRec num; // Type and value of the variable if it is numeric. Not used for string. short formulaLen; // The length of the dependency formula. char formula[1]; // Start of the dependency formula. A C string including null terminator. } UserDependentVarRec; #if GENERATINGPOWERPC #pragma options align=reset #endif #ifdef WIN32 #pragma pack() #endif // All structures written to disk are 2-byte-aligned. #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/igor/ptn003/CrossPlatformFileIO.h0000664000175000017500000000207414105434233022775 0ustar schloeglschloegl#define CP_FILE_OPEN_ERROR 10000 #define CP_FILE_CLOSE_ERROR 10001 #define CP_FILE_EOF_ERROR 10002 #define CP_FILE_READ_ERROR 10003 #define CP_FILE_WRITE_ERROR 10004 #define CP_FILE_POS_ERROR 10005 #define CP_FILE_REF FILE* int CPCreateFile(const char* fullFilePath, int overwrite, long macCreator, long macFileType); int CPDeleteFile(const char* fullFilePath); int CPOpenFile(const char* fullFilePath, int readOrWrite, CP_FILE_REF* fileRefPtr); int CPCloseFile(CP_FILE_REF fileRef); int CPReadFile(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr); int CPReadFile2(CP_FILE_REF fileRef, unsigned long count, void* buffer, unsigned long* numBytesReadPtr); int CPWriteFile(CP_FILE_REF fileRef, unsigned long count, const void* buffer, unsigned long* numBytesWrittenPtr); int CPGetFilePosition(CP_FILE_REF fileRef, unsigned long* filePosPtr); int CPSetFilePosition(CP_FILE_REF fileRef, long filePos, int mode); int CPAtEndOfFile(CP_FILE_REF fileRef); int CPNumberOfBytesInFile(CP_FILE_REF fileRef, unsigned long* numBytesPtr); biosig-2.3.3/biosig4c++/python/0000775000175000017500000000000014105434245016333 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/python/Makefile.in0000664000175000017500000000216414105434233020400 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2021 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## PYTHON ?= python3 PYVER := $(shell $(PYTHON) -c "import sys; print(sys.version[:3])") release target : sdist build wheel: bdist_wheel dist/Biosig-@PACKAGE_VERSION@.tar.gz : sdist sdist build install bdist_wheel :: $(PYTHON) setup.py $@ test: ## get ../data/Newtest17-256.bdf $(MAKE) -C .. fetchdata ## need to run from different directory, because (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) -c 'import biosig; print(biosig.header("data/Newtest17-256.bdf"))') (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) -c 'import biosig; print(biosig.data("data/Newtest17-256.bdf"))') (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) < python/demo2.py) clean: -rm -rf build/* -rm -rf dist/* -rm *.so check: release twine check dist/* biosig-2.3.3/biosig4c++/python/demo2.py0000664000175000017500000000422414105434233017712 0ustar schloeglschloegl####### Demo for Python interface to BioSig" ##################### ### ### Copyright (C) 2009,2016 Alois Schloegl ### This file is part of the "BioSig for Python" repository ### at http://biosig.sf.net/ ### ############################################################## # download and extract # http://www.biosemi.com/download/BDFtestfiles.zip # into /tmp/ # then run this demo # # on linux you can run instead # make test import sys import biosig import numpy as np import matplotlib.pyplot as plt import json def printf(format, *args): sys.stdout.write(format % args) ## read header FILENAME="/home/schloegl/data/test/cfs/BaseDemo/Leak.cfs" FILENAME="/home/schloegl/data/test/cfs/20190417_A0AA.dat" FILENAME="/home/schloegl/data/test/cfs/minis.dat" FILENAME="data/Newtest17-256.bdf" HDR=biosig.header(FILENAME) #print HDR ## extracting header fields H=json.loads(HDR) print(H["Filename"]) print(H["TYPE"]) print(H["Samplingrate"]) Fs=H["Samplingrate"] NS=len(H["CHANNEL"]) # number of channels T0=H["StartOfRecording"] print(Fs,NS,T0) ### read and display data ### A=biosig.data(FILENAME) NS=np.size(A,1) # number of channels fig = plt.figure() ax = fig.add_subplot(111) h = plt.plot(np.arange(np.size(A,0))/H["Samplingrate"],A[:,0]); ax.set_xlabel('time [s]') plt.show() for chan in list(range(NS)): name=H["CHANNEL"][chan]["Label"] # name of channel unit=H["CHANNEL"][chan]["PhysicalUnit"] # units of channel printf("#%d:\t%s\t[%s]\n", chan, name, unit) ### get all sweeps, breaks-in-recording selpos=[0] if hasattr(H,"EVENT"): for k in list(range(len(H["EVENT"]))): if (H["EVENT"][k]["TYP"] == '0x7ffe'): selpos.append(round(H["EVENT"][k]["POS"]*H["Samplingrate"])) selpos.append(np.size(A,0)) ### data from channel m and sweep c can be obtained by: m=0 # channel c=0 # segment, trace, sweep number d = A[selpos[c]:selpos[c+1]-1,m] ### display data fig = plt.figure() k=0 for m in list(range(NS)): for c in list(range(len(selpos)-1)): k = k+1 ax = fig.add_subplot(NS,len(selpos)-1,k) d = A[selpos[c]:selpos[c+1]-1,m] h = plt.plot(np.arange(np.size(d,0))/H["Samplingrate"],d) plt.show() biosig-2.3.3/biosig4c++/python/README.md.in0000664000175000017500000000210214105434233020207 0ustar schloeglschloegl# Biosig Package Biosig contains tools for processing of biomedical signals like EEG, ECG/EKG, EMG, EOG, polysomnograms (PSG). Currently, it contains import filters of about 50 different file formats including EDF, GDF, BDF, HL7aECG, SCP (EN1064). More information is available at [Biosig project homepage](https://biosig.sourceforge.io) # Installation: ## GNU/Linux, Unix, pip install https://pub.ist.ac.at/~schloegl/biosig/prereleases/Biosig-@PACKAGE_VERSION@.tar.gz ## MacOSX/Homebrew brew install biosig pip install numpy pip install https://pub.ist.ac.at/~schloegl/biosig/prereleases/Biosig-@PACKAGE_VERSION@.tar.gz ## MS-Windows the biosig extension module is not supported on MS Windoes. Instead, it is recommended to use loadgdf.py together with biosig2gdf.exe for loading biosig data. # Usage of the biosig extension module import biosig import json # read header/metainformation HDR=json.loads(biosig.header(FILENAME)) # read data DATA=biosig.data(FILENAME) # Usage of loadgdf (biosig2gdf.exe is strongly recommended) loadgdf(filename) biosig-2.3.3/biosig4c++/python/README0000664000175000017500000000344214105434233017213 0ustar schloeglschloeglAbout Biosig's Python interfaces. ====================================== Biosig is toolbox for processing biomedical signals like ECG, EEG etc. It can read about 50 different data formats including EDF, CFS, Heka, BDF, BrainVision, and many more. The heavy lifting is done in "libbbiosig" the biosig library implemented in C/C++. The Python module of Biosig provides an interface between libbiosig and Python. Currently, two functions are provided, one for reading the data samples, and one for extracting the meta information, like event table, scaling factors, sampling rates, etc. Installation: -------------------------------------------------- Prerequisite: libbiosig (for your platform) make release pip install dist/Biosig-1.9.tar.gz Usage: -------------------------------------------------- - start python and run import biosig import json HDR=biosig.header("filename.gdf") HDR=json.JSONDecoder(HDR) print(HDR) Data=biosig.data("filename.gdf") History: ------------------------------------------------- In the past there were several attempts of providing Python support. A first attempt using pure python should to be very slow and a lot of implementation effort, only some early version of GDF has been supported. Later, Swig was used for providing a python binding. This was reasonable flexible, and the libbiosig implementation could be mostly used. Disadvantages were the effort to maintin swig.i interface file, which is currently most likely broken. Known issues are string support, lack of Python3 support. Also this attempt is considered deprecated. The third attempt is using "module extensions". Currently, two functions, one for reading the header information (in JSON format) and one for reading the data samples is provided. biosig-2.3.3/biosig4c++/python/Makefile0000664000175000017500000000215014105434244017770 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2021 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## PYTHON ?= python3 PYVER := $(shell $(PYTHON) -c "import sys; print(sys.version[:3])") release target : sdist build wheel: bdist_wheel dist/Biosig-2.3.3.tar.gz : sdist sdist build install bdist_wheel :: $(PYTHON) setup.py $@ test: ## get ../data/Newtest17-256.bdf $(MAKE) -C .. fetchdata ## need to run from different directory, because (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) -c 'import biosig; print(biosig.header("data/Newtest17-256.bdf"))') (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) -c 'import biosig; print(biosig.data("data/Newtest17-256.bdf"))') (cd .. && PYTHONPATH=/usr/local/lib/python$(PYVER)/dist-packages/ $(PYTHON) < python/demo2.py) clean: -rm -rf build/* -rm -rf dist/* -rm *.so check: release twine check dist/* biosig-2.3.3/biosig4c++/python/LICENSE0000664000175000017500000010451314105434233017341 0ustar schloeglschloegl GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 of the License, 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . biosig-2.3.3/biosig4c++/python/setup.py0000664000175000017500000000475214105434244020054 0ustar schloeglschloegl# encoding: utf-8 # # Copyright (C) 2016-2020 Alois Schlögl # # This file is part of the BioSig repository # at https://biosig.sourceforge.io/ # # BioSig 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 3 # of the License, 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, see . # # You need to edit setup.py.in (setup.py is autogenerated) # # TODO: # windows, how to add libbiosig.dll.a and alike # https://github.com/lebigot/uncertainties/blob/master/setup.py try: from setuptools import setup, Extension except ImportError: from distutils.core import setup from distutils.extension import Extension import os import numpy.distutils.misc_util module_biosig = Extension('biosig', define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '9')], include_dirs = ['./..', numpy.distutils.misc_util.get_numpy_include_dirs()[0]], libraries = ['biosig'], library_dirs = ['./..','../lib'], sources = ['biosigmodule.c']) def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup (name = 'Biosig', version = '2.3.3', description = 'BioSig - tools for biomedical signal processing', author = 'Alois Schlögl', author_email = 'alois.schloegl@gmail.com', license = 'GPLv3+', url = 'https://biosig.sourceforge.io', #long_description='Import filters of biomedical signal formats', long_description=read('README.md'), long_description_content_type="text/markdown", include_package_data = True, keywords = 'EEG ECG EKG EMG EOG Polysomnography ECoG biomedical signals SCP EDF GDF HEKA CFS ABF', install_requires=['numpy','setuptools>=6.0'], classifiers=[ 'Programming Language :: Python', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Operating System :: OS Independent' ], ext_modules = [module_biosig]) biosig-2.3.3/biosig4c++/python/example.py0000664000175000017500000000205614105434233020340 0ustar schloeglschloeglimport biosig import numpy as S def testsin(sig, sr, freq): quartper = int(sr / freq * .25) x = S.sqrt(sig[:-quartper] ** 2 + sig[quartper:] ** 2) ampl = x.mean() err = x.std() if err > ampl/3: return 0 return ampl import sys if len(sys.argv) < 3: print("usage:\n%s filename.bdf freq" % sys.argv[0]) sys.exit(1) fname = sys.argv[1] sr = int(sys.argv[2]) print("\nexample.py\nchecking file %s" % fname) sig=biosig.data(fname) HDR=biosig.header(fname) freq = 3 print("Looking for sinusoidal signals at %f Hz" % freq) sig = sig - S.mean(sig, axis=1)[:, S.newaxis] a1 = testsin(sig[0], sr, freq) print("channel A1, peak to peak amplitude of sin at %f Hz: %f" % (freq, 2*a1)) a2 = testsin(sig[1], sr, freq) print("channel A2, peak to peak amplitude of sin at %f Hz: %f" % (freq, 2*a2)) a3 = testsin(sig[0] + 2*sig[1], sr, freq) print("channel A1 + 2*A2, peak to peak amplitude of sin at %f Hz: %f" % (freq, 2*a3)) a4 = testsin(sig[2], sr, freq) print("status channel, peak to peak amplitude of sin at %f Hz: %f" % (freq, 2*a4)) biosig-2.3.3/biosig4c++/python/biosigmodule.h0000664000175000017500000000251714105434233021170 0ustar schloeglschloegl#ifndef Py_BIOSIGMODULE_H #define Py_BIOSIGMODULE_H #ifdef __cplusplus extern "C" { #endif /* Header file for BIOSIGMODULE */ /* C API functions */ #define PyBiosig_Header_NUM 0 #define PyBiosig_Header_RETURN int #define PyBiosig_Header_PROTO (const char *filename, char **jsonstr) #define PyBiosig_Data_NUM 1 #define PyBiosig_Data_RETURN int #define PyBiosig_Data_PROTO (const char *filename, PyArrayObject **data) /* Total number of C API pointers */ #define PyBiosig_API_pointers 2 #ifdef BIOSIG_MODULE /* This section is used when compiling BIOSIGMODULE.c */ static PyBiosig_Header_RETURN PyBiosig_Header PyBiosig_Header_PROTO; static PyBiosig_Data_RETURN PyBiosig_Data PyBiosig_Data_PROTO; #else /* This section is used in modules that use BIOSIGMODULE's API */ static void **PyBiosig_API; #define PyBiosig_Header (*(PyBiosig_Header_RETURN (*)PyBiosig_Header_PROTO) PyBiosig_API[PyBiosig_Header_NUM]) #define PyBiosig_Data (*(PyBiosig_Data_RETURN (*)PyBiosig_Data_PROTO) PyBiosig_API[PyBiosig_Data_NUM]) /* Return -1 on error, 0 on success. * PyCapsule_Import will set an exception if there's an error. */ static int import_biosig(void) { PyBiosig_API = (void **)PyCapsule_Import("biosig._C_API", 0); return (PyBiosig_API != NULL) ? 0 : -1; } #endif #ifdef __cplusplus } #endif #endif /* !defined(Py_BIOSIGMODULE_H) */ biosig-2.3.3/biosig4c++/python/setup.py.in0000664000175000017500000000476614105434233020464 0ustar schloeglschloegl# encoding: utf-8 # # Copyright (C) 2016-2020 Alois Schlögl # # This file is part of the BioSig repository # at https://biosig.sourceforge.io/ # # BioSig 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 3 # of the License, 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, see . # # You need to edit setup.py.in (setup.py is autogenerated) # # TODO: # windows, how to add libbiosig.dll.a and alike # https://github.com/lebigot/uncertainties/blob/master/setup.py try: from setuptools import setup, Extension except ImportError: from distutils.core import setup from distutils.extension import Extension import os import numpy.distutils.misc_util module_biosig = Extension('biosig', define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '9')], include_dirs = ['./..', numpy.distutils.misc_util.get_numpy_include_dirs()[0]], libraries = ['biosig'], library_dirs = ['./..','../lib'], sources = ['biosigmodule.c']) def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup (name = 'Biosig', version = '@PACKAGE_VERSION@', description = 'BioSig - tools for biomedical signal processing', author = 'Alois Schlögl', author_email = 'alois.schloegl@gmail.com', license = 'GPLv3+', url = 'https://biosig.sourceforge.io', #long_description='Import filters of biomedical signal formats', long_description=read('README.md'), long_description_content_type="text/markdown", include_package_data = True, keywords = 'EEG ECG EKG EMG EOG Polysomnography ECoG biomedical signals SCP EDF GDF HEKA CFS ABF', install_requires=['numpy','setuptools>=6.0'], classifiers=[ 'Programming Language :: Python', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Operating System :: OS Independent' ], ext_modules = [module_biosig]) biosig-2.3.3/biosig4c++/python/biosigmodule.c0000664000175000017500000001264514105434233021166 0ustar schloeglschloegl#include #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include #if 1 //defined(_MSC_VER) // Visual Studio Compiler can not read biosig.h/biosig-dev.h // #define BIOSIG_FLAG_COMPRESSION 0x0001 #define BIOSIG_FLAG_UCAL 0x0002 #define BIOSIG_FLAG_OVERFLOWDETECTION 0x0004 #define BIOSIG_FLAG_ROW_BASED_CHANNELS 0x0008 typedef double biosig_data_type; typedef void HDRTYPE; HDRTYPE* sopen_extended(const char* FileName, const char* MODE, HDRTYPE* hdr, void* ptr); size_t sread(biosig_data_type* DATA, size_t START, size_t LEN, HDRTYPE* hdr); int serror2(HDRTYPE* hdr); int asprintf_hdr2json(char **str, HDRTYPE* hdr); void destructHDR(HDRTYPE* hdr); long biosig_get_number_of_channels(HDRTYPE *hdr); size_t biosig_get_number_of_samples(HDRTYPE *hdr); size_t biosig_get_number_of_records(HDRTYPE *hdr); size_t biosig_get_number_of_segments(HDRTYPE *hdr); int biosig_get_flag(HDRTYPE *hdr, unsigned flags); int biosig_set_flag(HDRTYPE *hdr, unsigned flags); int biosig_reset_flag(HDRTYPE *hdr, unsigned flags); #else #include #endif #define BIOSIG_MODULE #include "biosigmodule.h" #if PY_MAJOR_VERSION >= 3 #define MOD_ERROR_VAL NULL #define MOD_SUCCESS_VAL(val) val #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) #define MOD_DEF(ob, name, doc, methods) \ static struct PyModuleDef moduledef = { \ PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ ob = PyModule_Create(&moduledef); #else #define MOD_ERROR_VAL #define MOD_SUCCESS_VAL(val) #define MOD_INIT(name) void init##name(void) #define MOD_DEF(ob, name, doc, methods) \ ob = Py_InitModule3(name, methods, doc); #endif static PyObject *BiosigError; static int PyBiosig_Header(const char *filename, char **jsonstr) { HDRTYPE *hdr = NULL; hdr = sopen_extended(filename, "r", hdr, NULL); if (serror2(hdr)) { PyErr_SetString(BiosigError, "could not open file"); destructHDR(hdr); return -1; } // convert to json-string char *str = NULL; asprintf_hdr2json(&str, hdr); destructHDR(hdr); *jsonstr = strdup(str); return 0; } static PyObject *biosig_json_header(PyObject *self, PyObject *args) { const char *filename = NULL; char *str = NULL; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; if (PyBiosig_Header(filename, &str)) return NULL; return Py_BuildValue("s", str); } static int PyBiosig_Data(const char *filename, PyArrayObject **D) { HDRTYPE *hdr = sopen_extended(filename, "r", NULL, NULL); if (serror2(hdr)) { PyErr_SetString(BiosigError, "could not open file"); destructHDR(hdr); return -1; } const int nd=2; npy_intp dims[2]; dims[0] = (int)biosig_get_number_of_samples(hdr); dims[1] = (int)biosig_get_number_of_channels(hdr); int type_num; switch (sizeof(biosig_data_type)) { case 4: type_num=NPY_FLOAT32; break; case 8: type_num=NPY_FLOAT64; break; #if NPY_BITSOF_LONGDOUBLE >= 128 case 16: type_num=NPY_FLOAT128; break; #endif } *D = (PyArrayObject*) PyArray_SimpleNew(nd, dims, type_num); biosig_set_flag(hdr, BIOSIG_FLAG_ROW_BASED_CHANNELS); size_t count = sread( PyArray_DATA(*D), 0, biosig_get_number_of_records(hdr), hdr); destructHDR(hdr); return 0; } static PyObject *biosig_data(PyObject *self, PyObject *args) { const char *filename = NULL; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; PyArrayObject* Data; if (PyBiosig_Data(filename, &Data)) return NULL; return Data; } static PyMethodDef BiosigMethods[] = { {"header", biosig_json_header, METH_VARARGS, "load biosig header and export as JSON string."}, {"data", biosig_data, METH_VARARGS, "load biosig data."}, /* {"base64", biosig_json_header, METH_VARARGS, "load biosig header and export as JSON ."}, {"fhir_json_binary_template", biosig_json_header, METH_VARARGS, "load biosig header and export as JSON ."}, {"fhir_xml_binary_template", biosig_json_header, METH_VARARGS, "load biosig header and export as JSON ."}, */ {NULL, NULL, 0, NULL} /* Sentinel */ }; const char module___doc__[] = "Biosig - a tool for loading biomedical signal data.\n" " Biosig can read about 50 different fileformats of EEG, ECG, etc.\n" " The data samples can be read into a single matrix\n" " using the function\n" " data = biosig.data(filename)\n" " The header- and meta information including events can be\n" " read into a JSON structure with the function\n" " header = biosig.header(filename)\n"; #if 0 // PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "biosig", /* m_name */ module___doc__, /* m_doc */ -1, /* m_size */ BiosigMethods, /* m_methods */ NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL, /* m_free */ }; #endif MOD_INIT(biosig) { import_array(); PyObject *m; MOD_DEF(m, "biosig", module___doc__, BiosigMethods); if (m == NULL) return MOD_ERROR_VAL; BiosigError = PyErr_NewException("biosig.error", NULL, NULL); Py_INCREF(BiosigError); PyModule_AddObject(m, "error", BiosigError); /* additional initialization can happen here */ return MOD_SUCCESS_VAL(m); } biosig-2.3.3/biosig4c++/python/MANIFEST.in0000664000175000017500000000005114105434233020062 0ustar schloeglschloeglinclude README.md include biosigmodule.h biosig-2.3.3/biosig4c++/python/README.md0000664000175000017500000000205214105434244017610 0ustar schloeglschloegl# Biosig Package Biosig contains tools for processing of biomedical signals like EEG, ECG/EKG, EMG, EOG, polysomnograms (PSG). Currently, it contains import filters of about 50 different file formats including EDF, GDF, BDF, HL7aECG, SCP (EN1064). More information is available at [Biosig project homepage](https://biosig.sourceforge.io) # Installation: ## GNU/Linux, Unix, pip install https://pub.ist.ac.at/~schloegl/biosig/prereleases/Biosig-2.3.3.tar.gz ## MacOSX/Homebrew brew install biosig pip install numpy pip install https://pub.ist.ac.at/~schloegl/biosig/prereleases/Biosig-2.3.3.tar.gz ## MS-Windows the biosig extension module is not supported on MS Windoes. Instead, it is recommended to use loadgdf.py together with biosig2gdf.exe for loading biosig data. # Usage of the biosig extension module import biosig import json # read header/metainformation HDR=json.loads(biosig.header(FILENAME)) # read data DATA=biosig.data(FILENAME) # Usage of loadgdf (biosig2gdf.exe is strongly recommended) loadgdf(filename) biosig-2.3.3/biosig4c++/mex/0000775000175000017500000000000014105434244015602 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/mex/Makefile.in0000664000175000017500000001743214105434233017654 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ##### Target: GNU/Linux # ## make && make install build and install libbiosig, but no other tools. # libbiosig is a prerequisite for building all the other tools below. # ## make save2gdf - makes converter ## make install_save2gdf - installs converter # ## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) ## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) ## make mexw32 - makes mexSLOAD.mexw32, mexSOPEN.mexw32 (requires that mingw32, gnumex libraries from Matlab/Win32) ## make mexw64 - makes mexSLOAD.mexw64, mexSOPEN.mexw64 (requires that mce-w32, gnumex libraries from Matlab/Win64) ## make mex - mex4o, mex4m, mexw32, mexw64 combined ## make biosig4python - makes python interface (requires Python) ## make biosig4java - makes Java interface (experimental) ## make biosig4php - makes PHP interface (experimental) ## make biosig4perl - makes perl interface (experimental) ## make biosig4ruby - makes ruby interface (experimental) ## make biosig4tcl - makes tcl/tk interface (experimental) ## ## make win32 and make win64 are obsolete. save2gdf.exe, and libbiosig.{a,dll} for windows can now be built ## with the mingw-cross-compiler environment (mxe.cc). ## git clone https://github.com/schloegl/mxe.git ## make biosig ## should do what you want. Please note, that win32mma does now also rely that libbiosig is built with MXE. ## Make sure that CROSS or CROSS64 is properly defined when running `make` ## ## ??? ## make sigviewer - makes sigviewer ##### Target: Win32 ## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw32 mex/mexSLOAD.mexw32 - requires MinGW32 and GNUMEX libraries from Matlab/Win32 ## make win32/sigviewer.exe - requires sources of SigViewer, and MinGW32 (mex: make suitesparse zlib qt ) ##### Target: Win64 ## make win64 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw64 mex/mexSLOAD.mexw64 - requires MCE-W64 and GNUMEX libraries from Matlab/Win64 ## make win64/sigviewer.exe - requires sources of SigViewer and MCE-W64, make suitesparse zlib qt ##### Target: MacOSX w/ homebrew ## make install_homebrew installs libbiosig and save2gdf # requires: brew tap homebrew/dupes # brew install libiconv ############################### # whether dynamic or static linking is used, can be controlled with # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically # LIBEXT = a #LIBEXT = so ############################### ## TARGET dependencies ifeq (,$(TARGET)) CC ?= gcc CXX ?= g++ AR := ar rcs PKGCONF := pkg-config ifneq (Darwin,$(shell uname)) LFLAGS += -Wl,-z,relro,-z,now endif else ifeq (intel,$(TARGET)) CC := /opt/intel/bin/icc CXX := /opt/intel/bin/icc LD := /opt/intel/bin/xild AR := /opt/intel/bin/xiar crs else prefix := $(dir $(shell which $(TARGET)-gcc)) CC := $(TARGET)-gcc CXX := $(TARGET)-g++ LD := $(TARGET)-ld AR := $(TARGET)-ar rcs PKGCONF := $(TARGET)-pkg-config ifeq (mingw, $(findstring mingw, $(TARGET))) ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o ## exclude conflicting definition of sopen from mingw's io.h CFLAGS += -I. IO_H_FILE2 = io.h CFLAGS += -I$(prefix)/include LIBS += -lssp LDLIBS += -liconv -lws2_32 endif endif ifeq (Darwin,$(shell uname)) ## Homebrew: ## brew tap homebrew/dupes ## brew install libiconv ## LD = ld CFLAGS += -I/usr/local/opt/libiconv/include LDLIBS += -L/usr/local/opt/libiconv/lib/ -liconv -lstdc++ LDFLAGS += -dylib -arch x86_64 -macosx_version_min 10.9 DLEXT = dylib FULLDLEXT = ${BIOSIG_VERSION}.dylib SONAME_PREFIX = -install_name # the last space character is crucial SONAME_POSTFIX = .${MAJOR_VERSION}.${MINOR_VERSION}.$(DLEXT) else LD = $(CXX) LDFLAGS += -shared DLEXT = so FULLDLEXT = so.${BIOSIG_VERSION} SONAME_PREFIX = -Wl,-soname= SONAME_POSTFIX = .$(DLEXT).${MAJOR_VERSION}.${MINOR_VERSION} endif exec_prefix ?= @prefix@ DEFINES_ALL = #-D=NDEBUG LIBS += $(LDLIBS) DELETE = rm -f COPY = cp -f DATA_DIR = data/ DATA_DIR_CFS = $(HOME)/L/data/test/CFS/ TEMP_DIR = test/ VERBOSE := -V0 ########################################################## ## set Matlab and Octave variables MATLABDIR ?= $(shell dirname @MATLAB@) ifeq (.,$(MATLABDIR)) #$(warning MATLABDIR is not defined) else MEX = $(MATLABDIR)/mex MEX_EXT := $(shell $(MATLABDIR)/mexext) endif ########################################################## first: mex4o ### Install mexbiosig for Matlab and Octave install: mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab install *.mex* $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab @echo " mexBiosig for Matlab is installed in $(exec_prefix)/libexec/biosig/matlab"; @echo " Usage: Start Matlab and addpath "; @echo " addpath('$(exec_prefix)/libexec/biosig/matlab')"; @echo " mexSLOAD"; uninstall: # from older source installations -${RM} $(DESTDIR)@datadir@/biosig/mex/* -cd $(DESTDIR)@datadir@ && rmdir -p biosig # from later than 2.0.6 installations -${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab/{mexSLOAD,mexSOPEN,mexSSAVE,physicalunits}.mex* -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/matlab ############################################################# # Compilation: Implicit, default rules ############################################################# ############################################################# # MEX-files for Octave and Matlab ############################################################# # include directory for Win32-Matlab include W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ -I../win32 W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ -I../win64 # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ GNUMEX = $(HOME)/bin/win32/gnumex GNUMEX64 = $(HOME)/bin/win64/gnumex mexSOPEN.cpp : mexSLOAD.cpp echo "#define mexSOPEN" > mexSOPEN.cpp cat mexSLOAD.cpp >> mexSOPEN.cpp MEX_OBJECTS = mexSLOAD.cpp mexSOPEN.cpp mexSSAVE.cpp physicalunits.cpp mex4o: $(patsubst %.cpp, %.mex, $(MEX_OBJECTS)) oct: $(patsubst %.cpp, %.oct, $(MEX_OBJECTS)) mexw32: $(patsubst %.cpp, %.mexw32, $(MEX_OBJECTS)) mexw64: $(patsubst %.cpp, %.mexw64, $(MEX_OBJECTS)) ifdef MEX_EXT mex: mex4o mex4m mexw32 mexw64 mex4m: $(patsubst %.cpp, %.$(MEX_EXT), $(MEX_OBJECTS)) %.$(MEX_EXT): %.cpp $(MEX) $(MEX_OPTION) $(DEFINES) -I.. "$<" -L.. -lbiosig -output "$@" else mex: mex4o mexw32 mexw64 endif ifneq (:,@OCTAVE@) %.mex: %.cpp $(MKOCTFILE) $(DEFINES) -I.. -v -g --mex "$<" -L.. -lbiosig -o "$@" %.oct: %.cpp $(MKOCTFILE) $(DEFINES) -I.. "$<" -L.. -lbiosig -o "$@" endif %.mexw32: %.cpp ## $(CROSS)-g++ is used instead of $(CXX), so it can be called from biosig as well as mxe. $(CROSS)-g++ -shared $(GNUMEX)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ -I$(prefix)/include \ -I$(W32MAT_INC) -O2 -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex $(shell $(CROSS)-pkg-config --libs libbiosig) %.mexw64: %.cpp $(CROSS64)-g++ -shared $(GNUMEX64)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ -I$(prefix)/include \ -I$(W64MAT_INC) -O2 -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex $(shell $(CROSS64)-pkg-config --libs libbiosig) clean: -$(DELETE) *.o *.obj *.o64 core octave-core *.oct *.mex* mexSOPEN.cpp biosig-2.3.3/biosig4c++/mex/README0000664000175000017500000000532514105434233016465 0ustar schloeglschloeglThis provides a language binding of libbiosig to Matlab and Octave. Basically, mex-files for loading biosig data are provided. - mexSLOAD.mex* loads the whole file (header and data). - mexSOPEN.mex* reads only the header information. - mexSSAVE.mex* saves data into various biosig format the list of supported formats is shown here: http://pub.ist.ac.at/~schloegl/biosig/TESTED COMPILATION: == Octave on Linux ======================= On Linux platforms the compilation is straight forward. A prerequisite is libbiosig (with its dependencies). make libbiosig && sudo make install Generate and install mexbiosig-package make mexbiosig sudo make install_mexbiosig == Octave on MacOSX ======================= You need to have homebrew (for details see http://brew.sh) # 1) Install XCode from App Store xcode-select --install # 2) install homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # 3) Install prerequisites and recommendations for Octave brew install caskroom/cask/brew-cask brew cask install xquartz brew cask install mactex brew install curl # 4) install Octave brew tap homebrew/science export PATH="$PATH:/usr/texbin" brew install octave --with-docs and install biosig brew tap schloegl/biosig brew install mexbiosig == Octave on Window (MXE-Octave) ======================= # 1) Download and install Octave 4.0.0 https://ftp.gnu.org/gnu/octave/windows/ # 2) Get biosig sources either with git git clone git://git.code.sf.net/p/biosig/code biosig-code or source package from http://biosig.sourceforge.net/download.html libbiosig-X.Y.Z.src.tar.gz (requires version 1.7.3 or later) # 3) Start Octave and change directory to .../biosig4c++/ # 4) Make and install libbiosig system('make && make install') # 5) Generate mexbiosig pkg system('make mexbiosig') # 6) Install mexbiosig-package pkg install mex/mexbiosig-1.7.3.tar.gz == Matlab on Linux, MacOSX ======================= Prerequisites: sudo apt-get install zlib1g-dev libsuitesparse-dev Edit Makefile and set the correct path to Matlab: The mex files for Matlab are generated with MATLABDIR=/usr/local/MATLAB/R2014b make mex4m == Matlab v7.11 for Win32 ================ Compilation was successful using the mingw-cross-env on linux to generate Win32/mex files. GnuMex/Mingw must be installed together with Matlab on windows. The gnumex libraries must be copied to the linux machine having MinGW-Cross-env installed. Adapt the Makefile and run make mexw32 mexw64 Copyright (C) 2011,2015 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig-2.3.3/biosig4c++/mex/Makefile0000664000175000017500000001745014105434244017251 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ##### Target: GNU/Linux # ## make && make install build and install libbiosig, but no other tools. # libbiosig is a prerequisite for building all the other tools below. # ## make save2gdf - makes converter ## make install_save2gdf - installs converter # ## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) ## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) ## make mexw32 - makes mexSLOAD.mexw32, mexSOPEN.mexw32 (requires that mingw32, gnumex libraries from Matlab/Win32) ## make mexw64 - makes mexSLOAD.mexw64, mexSOPEN.mexw64 (requires that mce-w32, gnumex libraries from Matlab/Win64) ## make mex - mex4o, mex4m, mexw32, mexw64 combined ## make biosig4python - makes python interface (requires Python) ## make biosig4java - makes Java interface (experimental) ## make biosig4php - makes PHP interface (experimental) ## make biosig4perl - makes perl interface (experimental) ## make biosig4ruby - makes ruby interface (experimental) ## make biosig4tcl - makes tcl/tk interface (experimental) ## ## make win32 and make win64 are obsolete. save2gdf.exe, and libbiosig.{a,dll} for windows can now be built ## with the mingw-cross-compiler environment (mxe.cc). ## git clone https://github.com/schloegl/mxe.git ## make biosig ## should do what you want. Please note, that win32mma does now also rely that libbiosig is built with MXE. ## Make sure that CROSS or CROSS64 is properly defined when running `make` ## ## ??? ## make sigviewer - makes sigviewer ##### Target: Win32 ## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw32 mex/mexSLOAD.mexw32 - requires MinGW32 and GNUMEX libraries from Matlab/Win32 ## make win32/sigviewer.exe - requires sources of SigViewer, and MinGW32 (mex: make suitesparse zlib qt ) ##### Target: Win64 ## make win64 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw64 mex/mexSLOAD.mexw64 - requires MCE-W64 and GNUMEX libraries from Matlab/Win64 ## make win64/sigviewer.exe - requires sources of SigViewer and MCE-W64, make suitesparse zlib qt ##### Target: MacOSX w/ homebrew ## make install_homebrew installs libbiosig and save2gdf # requires: brew tap homebrew/dupes # brew install libiconv ############################### # whether dynamic or static linking is used, can be controlled with # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically # LIBEXT = a #LIBEXT = so ############################### ## TARGET dependencies ifeq (,$(TARGET)) CC ?= gcc CXX ?= g++ AR := ar rcs PKGCONF := pkg-config ifneq (Darwin,$(shell uname)) LFLAGS += -Wl,-z,relro,-z,now endif else ifeq (intel,$(TARGET)) CC := /opt/intel/bin/icc CXX := /opt/intel/bin/icc LD := /opt/intel/bin/xild AR := /opt/intel/bin/xiar crs else prefix := $(dir $(shell which $(TARGET)-gcc)) CC := $(TARGET)-gcc CXX := $(TARGET)-g++ LD := $(TARGET)-ld AR := $(TARGET)-ar rcs PKGCONF := $(TARGET)-pkg-config ifeq (mingw, $(findstring mingw, $(TARGET))) ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o ## exclude conflicting definition of sopen from mingw's io.h CFLAGS += -I. IO_H_FILE2 = io.h CFLAGS += -I$(prefix)/include LIBS += -lssp LDLIBS += -liconv -lws2_32 endif endif ifeq (Darwin,$(shell uname)) ## Homebrew: ## brew tap homebrew/dupes ## brew install libiconv ## LD = ld CFLAGS += -I/usr/local/opt/libiconv/include LDLIBS += -L/usr/local/opt/libiconv/lib/ -liconv -lstdc++ LDFLAGS += -dylib -arch x86_64 -macosx_version_min 10.9 DLEXT = dylib FULLDLEXT = ${BIOSIG_VERSION}.dylib SONAME_PREFIX = -install_name # the last space character is crucial SONAME_POSTFIX = .${MAJOR_VERSION}.${MINOR_VERSION}.$(DLEXT) else LD = $(CXX) LDFLAGS += -shared DLEXT = so FULLDLEXT = so.${BIOSIG_VERSION} SONAME_PREFIX = -Wl,-soname= SONAME_POSTFIX = .$(DLEXT).${MAJOR_VERSION}.${MINOR_VERSION} endif exec_prefix ?= /usr/local DEFINES_ALL = #-D=NDEBUG LIBS += $(LDLIBS) DELETE = rm -f COPY = cp -f DATA_DIR = data/ DATA_DIR_CFS = $(HOME)/L/data/test/CFS/ TEMP_DIR = test/ VERBOSE := -V0 ########################################################## ## set Matlab and Octave variables MATLABDIR ?= $(shell dirname :) ifeq (.,$(MATLABDIR)) #$(warning MATLABDIR is not defined) else MEX = $(MATLABDIR)/mex MEX_EXT := $(shell $(MATLABDIR)/mexext) endif ########################################################## first: mex4o ### Install mexbiosig for Matlab and Octave install: mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab install *.mex* $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab @echo " mexBiosig for Matlab is installed in $(exec_prefix)/libexec/biosig/matlab"; @echo " Usage: Start Matlab and addpath "; @echo " addpath('$(exec_prefix)/libexec/biosig/matlab')"; @echo " mexSLOAD"; uninstall: # from older source installations -${RM} $(DESTDIR)${prefix}/share/biosig/mex/* -cd $(DESTDIR)${prefix}/share && rmdir -p biosig # from later than 2.0.6 installations -${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab/{mexSLOAD,mexSOPEN,mexSSAVE,physicalunits}.mex* -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/matlab ############################################################# # Compilation: Implicit, default rules ############################################################# ############################################################# # MEX-files for Octave and Matlab ############################################################# # include directory for Win32-Matlab include W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ -I../win32 W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ -I../win64 # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ GNUMEX = $(HOME)/bin/win32/gnumex GNUMEX64 = $(HOME)/bin/win64/gnumex mexSOPEN.cpp : mexSLOAD.cpp echo "#define mexSOPEN" > mexSOPEN.cpp cat mexSLOAD.cpp >> mexSOPEN.cpp MEX_OBJECTS = mexSLOAD.cpp mexSOPEN.cpp mexSSAVE.cpp physicalunits.cpp mex4o: $(patsubst %.cpp, %.mex, $(MEX_OBJECTS)) oct: $(patsubst %.cpp, %.oct, $(MEX_OBJECTS)) mexw32: $(patsubst %.cpp, %.mexw32, $(MEX_OBJECTS)) mexw64: $(patsubst %.cpp, %.mexw64, $(MEX_OBJECTS)) ifdef MEX_EXT mex: mex4o mex4m mexw32 mexw64 mex4m: $(patsubst %.cpp, %.$(MEX_EXT), $(MEX_OBJECTS)) %.$(MEX_EXT): %.cpp $(MEX) $(MEX_OPTION) $(DEFINES) -I.. "$<" -L.. -lbiosig -output "$@" else mex: mex4o mexw32 mexw64 endif ifneq (:,/usr/bin/octave) %.mex: %.cpp $(MKOCTFILE) $(DEFINES) -I.. -v -g --mex "$<" -L.. -lbiosig -o "$@" %.oct: %.cpp $(MKOCTFILE) $(DEFINES) -I.. "$<" -L.. -lbiosig -o "$@" endif %.mexw32: %.cpp ## $(CROSS)-g++ is used instead of $(CXX), so it can be called from biosig as well as mxe. $(CROSS)-g++ -shared $(GNUMEX)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ -I$(prefix)/include \ -I$(W32MAT_INC) -O2 -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex $(shell $(CROSS)-pkg-config --libs libbiosig) %.mexw64: %.cpp $(CROSS64)-g++ -shared $(GNUMEX64)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ -I$(prefix)/include \ -I$(W64MAT_INC) -O2 -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex $(shell $(CROSS64)-pkg-config --libs libbiosig) clean: -$(DELETE) *.o *.obj *.o64 core octave-core *.oct *.mex* mexSOPEN.cpp biosig-2.3.3/biosig4c++/mex/mexSLOAD.cpp0000664000175000017500000007500214105434233017664 0ustar schloeglschloegl/* Copyright (C) 2007-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ #include "mex.h" #include #include #include #include #ifdef HAVE_CHOLMOD # if !defined(__APPLE__) # include # else # include # endif #endif #include #include #ifdef NDEBUG #define VERBOSE_LEVEL 0 // turn off debugging information, but its only used without NDEBUG #else extern int VERBOSE_LEVEL; // used for debugging #endif #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; #endif #endif #ifndef TRUE #define TRUE (1) #endif #ifdef CHOLMOD_H //#include "cholmod/matlab/cholmod_matlab.h" /* The function sputil_get_sparse and its license was downloaded on Oct 16, 2009 from http://www.cise.ufl.edu/research/sparse/cholmod/CHOLMOD/MATLAB/cholmod_matlab.c http://www.cise.ufl.edu/research/sparse/cholmod/CHOLMOD/MATLAB/License.txt */ /* CHOLMOD/MATLAB Module. Copyright (C) 2005-2006, Timothy A. Davis CHOLMOD is also available under other licenses; contact authors for details. MATLAB(tm) is a Registered Trademark of The MathWorks, Inc. http://www.cise.ufl.edu/research/sparse Note that this license is for the CHOLMOD/MATLAB module only. All CHOLMOD modules are licensed separately. -------------------------------------------------------------------------------- This Module 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 of the License, or (at your option) any later version. This Module 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 Module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* ========================================================================== */ /* === sputil_get_sparse ==================================================== */ /* ========================================================================== */ /* Create a shallow CHOLMOD copy of a MATLAB sparse matrix. No memory is * allocated. The resulting matrix A must not be modified. */ cholmod_sparse *sputil_get_sparse ( const mxArray *Amatlab, /* MATLAB version of the matrix */ cholmod_sparse *A, /* CHOLMOD version of the matrix */ double *dummy, /* a pointer to a valid scalar double */ mwSize stype /* -1: lower, 0: unsymmetric, 1: upper */ ) { mwSize *Ap ; A->nrow = mxGetM (Amatlab) ; A->ncol = mxGetN (Amatlab) ; A->p = (mwSize *) mxGetJc (Amatlab) ; A->i = (mwSize *) mxGetIr (Amatlab) ; Ap = (mwSize*)A->p ; A->nzmax = Ap [A->ncol] ; A->packed = TRUE ; A->sorted = TRUE ; A->nz = NULL ; A->itype = CHOLMOD_LONG ; /* was CHOLMOD_INT in v1.6 and earlier */ A->dtype = CHOLMOD_DOUBLE ; A->stype = stype ; #ifndef MATLAB6p1_OR_EARLIER if (mxIsLogical (Amatlab)) { A->x = NULL ; A->z = NULL ; A->xtype = CHOLMOD_PATTERN ; } else if (mxIsEmpty (Amatlab)) { /* this is not dereferenced, but the existence (non-NULL) of these * pointers is checked in CHOLMOD */ A->x = dummy ; A->z = dummy ; A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } else if (mxIsDouble (Amatlab)) { A->x = mxGetPr (Amatlab) ; A->z = mxGetPi (Amatlab) ; A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } else { /* only logical and complex/real double matrices supported */ //sputil_error (ERROR_INVALID_TYPE, 0) ; // modified by AS, Oct 2009 } #else if (mxIsEmpty (Amatlab)) { /* this is not dereferenced, but the existence (non-NULL) of these * pointers is checked in CHOLMOD */ A->x = dummy ; A->z = dummy ; A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } else { /* in MATLAB 6.1, the matrix is sparse, so it must be double */ A->x = mxGetPr (Amatlab) ; A->z = mxGetPi (Amatlab) ; A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } #endif return (A) ; } /* ========================================================================== */ /* === end of sputil_get_sparse ============================================= */ /* ========================================================================== */ #endif #ifdef WITH_PDP void sopen_pdp_read(HDRTYPE *hdr); #endif //#define VERBOSE_LEVEL 9 //extern int VERBOSE_LEVEL; //#define DEBUG void mexFunction( int nlhs, /* number of expected outputs */ mxArray *plhs[], /* array of pointers to output arguments */ int nrhs, /* number of inputs */ const mxArray *prhs[] /* array of pointers to input arguments */ ) { size_t k,k1; const mxArray *arg; mxArray *HDR; HDRTYPE *hdr; CHANNEL_TYPE* cp; size_t count; time_t T0; char *FileName=NULL; int status; int CHAN = 0; int TARGETSEGMENT = 1; double *ChanList=NULL; int NS = -1; char FlagOverflowDetection = 1, FlagUCAL = 0; int argSweepSel = -1; #if (BIOSIG_VERSION >= 10905) biosig_options_type biosig_options; biosig_options.free_text_event_limiter="\0"; // default value #endif #ifdef CHOLMOD_H cholmod_sparse RR,*rr=NULL; double dummy; #endif // ToDO: output single data // mxClassId FlagMXclass=mxDOUBLE_CLASS; if (nrhs<1) { #ifdef mexSOPEN mexPrintf(" Usage of mexSOPEN:\n"); mexPrintf("\tHDR = mexSOPEN(f)\n"); mexPrintf(" Input:\n\tf\tfilename\n"); mexPrintf("\t... = mexSLOAD(f,'--free-text-event-limiter',';')\n"); #if (BIOSIG_VERSION >= 10905) mexPrintf("\t'--free-text-event-limiter',';' : free text limited by first \";\", remainder is ignored." "\n\t\tThis can help to reduce the number of distinct free text events.\n\n"); #endif mexPrintf(" Output:\n\tHDR\theader structure\n\n"); #else mexPrintf(" Usage of mexSLOAD:\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f)\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan)\n\t\tchan must be sorted in ascending order\n"); #ifdef CHOLMOD_H mexPrintf("\t[s,HDR]=mexSLOAD(f,ReRef)\n\t\treref is a (sparse) matrix for rerefencing\n"); #endif mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'...')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'OVERFLOWDETECTION:ON')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'OVERFLOWDETECTION:OFF')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'UCAL:ON')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'UCAL:OFF')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'OUTPUT:SINGLE')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'TARGETSEGMENT:')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'SWEEP',[NE, NG, NS])\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'--free-text-event-limiter',';')\n"); mexPrintf(" Input:\n\tf\tfilename\n"); mexPrintf("\tchan\tlist of selected channels; 0=all channels [default]\n"); mexPrintf("\tUCAL\tON: do not calibrate data; default=OFF\n"); // mexPrintf("\tOUTPUT\tSINGLE: single precision; default='double'\n"); mexPrintf("\tOVERFLOWDETECTION\tdefault = ON\n\t\tON: values outside dynamic range are not-a-number (NaN)\n"); mexPrintf("\tTARGETSEGMENT:\n\t\tselect segment in multisegment files (like Nihon-Khoden), default=1\n\t\tIt has no effect for other data formats.\n"); mexPrintf("\t[NE, NG, NS] are the number of the experiment, the series and the sweep, resp. for sweep selection in HEKA/PatchMaster files. (0 indicates all)\n"); mexPrintf("\t\t examples: [1,2,3] the 3rd sweep from the 2nd series of experiment 1; [1,3,0] selects all sweeps from experiment=1, series=3. \n\n"); #if (BIOSIG_VERSION >= 10905) mexPrintf("\t'--free-text-event-limiter',';' : free text limited by first \";\", remainder is ignored." "\n\t\tThis can help to reduce the number of distinct free text events.\n\n"); #endif mexPrintf(" Output:\n\ts\tsignal data, each column is one channel\n"); mexPrintf("\tHDR\theader structure\n\n"); #endif return; } /* improve checks for input arguments */ /* process input arguments */ for (k = 0; k < nrhs; k++) { arg = prhs[k]; if (mxIsEmpty(arg) && (k>0)) { #ifdef DEBUG mexPrintf("arg[%i] Empty\n",k); #endif } else if ((k==0) && mxIsCell(arg) && mxGetNumberOfElements(arg)==1 && mxGetCell(arg,0) && mxIsChar(mxGetCell(arg,0))) { FileName = mxArrayToString(mxGetCell(arg,0)); #ifdef DEBUG mexPrintf("arg[%i] IsCell\n",k); #endif } else if ((k==0) && mxIsStruct(arg)) { FileName = mxArrayToString(mxGetField(prhs[k],0,"FileName")); #ifdef DEBUG mexPrintf("arg[%i] IsStruct\n",k); #endif } else if ((k==1) && mxIsSparse(arg)) { #ifdef CHOLMOD_H rr = sputil_get_sparse(arg,&RR,&dummy,0); #else mexErrMsgTxt("This version of mexSLOAD does not support re-referencing matrix - recompile with -DWITH_CHOLMOD -lcholmod \n"); #endif } else if ((k==1) && mxIsNumeric(arg)) { #ifdef DEBUG mexPrintf("arg[%i] IsNumeric\n",k); #endif ChanList = (double*)mxGetData(prhs[k]); NS = mxGetNumberOfElements(prhs[k]); } else if (mxIsChar(arg)) { #ifdef DEBUG mexPrintf("arg[%i]=%s \n",k,mxArrayToString(prhs[k])); #endif if (k==0) FileName = mxArrayToString(prhs[k]); else if (!strcmp(mxArrayToString(prhs[k]), "CNT32")) ; // obsolete - supported for backwards compatibility else if (!strcmp(mxArrayToString(prhs[k]), "OVERFLOWDETECTION:ON")) FlagOverflowDetection = 1; else if (!strcmp(mxArrayToString(prhs[k]), "OVERFLOWDETECTION:OFF")) FlagOverflowDetection = 0; else if (!strcmp(mxArrayToString(prhs[k]), "UCAL:ON")) FlagUCAL = 1; else if (!strcmp(mxArrayToString(prhs[k]), "UCAL:OFF")) FlagUCAL = 0; // else if (!strcmp(mxArrayToString(prhs[k]),"OUTPUT:SINGLE")) // FlagMXclass = mxSINGLE_CLASS; else if (!strncmp(mxArrayToString(prhs[k]),"TARGETSEGMENT:",14)) TARGETSEGMENT = atoi(mxArrayToString(prhs[k])+14); else if (!strcasecmp(mxArrayToString(prhs[k]), "SWEEP") && (prhs[k+1] != NULL) && mxIsNumeric(prhs[k+1])) argSweepSel = ++k; #if (BIOSIG_VERSION >= 10905) else if (!strcasecmp(mxArrayToString(prhs[k]), "--free-text-event-limiter") && (prhs[k+1] != NULL) && mxIsChar(prhs[k+1])) biosig_options.free_text_event_limiter = mxArrayToString(prhs[++k]); #endif } else { #ifndef mexSOPEN mexPrintf("mexSLOAD: argument #%i is invalid.",k+1); mexErrMsgTxt("mexSLOAD fails because of unknown parameter\n"); #else mexPrintf("mexSOPEN: argument #%i is invalid.",k+1); mexErrMsgTxt("mexSOPEN fails because of unknown parameter\n"); #endif } } if (VERBOSE_LEVEL>7) mexPrintf("110: input arguments checked\n"); hdr = constructHDR(0,0); #ifdef __LIBBIOSIG2_H__ unsigned flags = (!!FlagOverflowDetection)*BIOSIG_FLAG_OVERFLOWDETECTION + (!!FlagUCAL)*BIOSIG_FLAG_UCAL; #ifdef CHOLMOD_H flags += (rr!=NULL)*BIOSIG_FLAG_ROW_BASED_CHANNELS; #else biosig_reset_flag(hdr, BIOSIG_FLAG_ROW_BASED_CHANNELS); #endif biosig_set_flag(hdr, flags); biosig_set_targetsegment(hdr, TARGETSEGMENT); // sweep selection for Heka format if (argSweepSel>0) { double *SZ = (double*) mxGetData(prhs[argSweepSel]); k = 0; while (k < mxGetNumberOfElements(prhs[argSweepSel]) && k < 5) { biosig_set_segment_selection(hdr, k+1, (uint32_t)SZ[k]); k++; } } #else //__LIBBIOSIG2_H__ hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = FlagUCAL; #ifdef CHOLMOD_H hdr->FLAG.ROW_BASED_CHANNELS = (rr!=NULL); #else hdr->FLAG.ROW_BASED_CHANNELS = 0; #endif hdr->FLAG.TARGETSEGMENT = TARGETSEGMENT; // sweep selection for Heka format if (argSweepSel>0) { double *SZ = (double*) mxGetData(prhs[argSweepSel]); k = 0; while (k < mxGetNumberOfElements(prhs[argSweepSel]) && k < 5) { hdr->AS.SegSel[k] = (uint32_t)SZ[k]; k++; } } #endif // __LIBBIOSIG2_H__ : TODO: below, nothing is converted to level-2 interface, yet if (VERBOSE_LEVEL>7) mexPrintf("120: going to sopen\n"); #if (BIOSIG_VERSION >= 10905) hdr = sopen_extended(FileName, "r", hdr, &biosig_options); #else hdr = sopen(FileName, "r", hdr); #endif /* #ifdef WITH_PDP if (hdr->AS.B4C_ERRNUM) { hdr->AS.B4C_ERRNUM = 0; sopen_pdp_read(hdr); } #endif */ if (VERBOSE_LEVEL>7) mexPrintf("121: sopen done\n"); if ((status=serror2(hdr))) { const char* fields[]={"TYPE","VERSION","FileName","FLAG","ErrNum","ErrMsg"}; HDR = mxCreateStructMatrix(1, 1, 6, fields); #ifdef __LIBBIOSIG2_H__ mxSetField(HDR,0,"FileName",mxCreateString(biosig_get_filename(hdr))); const char *FileTypeString = GetFileTypeString(biosig_get_filetype(hdr)); mxSetField(HDR,0,"VERSION",mxCreateDoubleScalar(biosig_get_version(hdr))); #else mxSetField(HDR,0,"FileName",mxCreateString(hdr->FileName)); const char *FileTypeString = GetFileTypeString(hdr->TYPE); mxSetField(HDR,0,"VERSION",mxCreateDoubleScalar(hdr->VERSION)); #endif mxArray *errnum = mxCreateNumericMatrix(1,1,mxUINT8_CLASS,mxREAL); *(uint8_t*)mxGetData(errnum) = (uint8_t)status; mxSetField(HDR,0,"ErrNum",errnum); #ifdef HAVE_OCTAVE // handle bug in octave: mxCreateString(NULL) causes segmentation fault // Octave 3.2.3 causes a seg-fault in mxCreateString(NULL) if (FileTypeString) FileTypeString="\0"; #endif mxSetField(HDR,0,"TYPE",mxCreateString(FileTypeString)); char *msg = (char*)malloc(72+23+strlen(FileName)); // 72: max length of constant text, 23: max length of GetFileTypeString() if (msg == NULL) mxSetField(HDR,0,"ErrMsg",mxCreateString("Error mexSLOAD: Cannot open file\n")); else { if (status==B4C_CANNOT_OPEN_FILE) sprintf(msg,"Error mexSLOAD: file %s not found.\n",FileName); /* Flawfinder: ignore *** sufficient memory is allocated above */ else if (status==B4C_FORMAT_UNKNOWN) sprintf(msg,"Error mexSLOAD: Cannot open file %s - format %s not known.\n",FileName,FileTypeString); /* Flawfinder: ignore *** sufficient memory is allocated above */ else if (status==B4C_FORMAT_UNSUPPORTED) sprintf(msg,"Error mexSLOAD: Cannot open file %s - format %s not supported [%s].\n", FileName, FileTypeString, hdr->AS.B4C_ERRMSG); /* Flawfinder: ignore *** sufficient memory is allocated above */ else sprintf(msg,"Error %i mexSLOAD: Cannot open file %s - format %s not supported [%s].\n", status, FileName, FileTypeString, hdr->AS.B4C_ERRMSG); /* Flawfinder: ignore *** sufficient memory is allocated above */ mxSetField(HDR,0,"ErrMsg",mxCreateString(msg)); free(msg); } if (VERBOSE_LEVEL>7) mexPrintf("737: abort mexSLOAD - sopen failed\n"); destructHDR(hdr); if (VERBOSE_LEVEL>7) mexPrintf("757: abort mexSLOAD - sopen failed\n"); #ifdef mexSOPEN plhs[0] = HDR; #else plhs[0] = mxCreateDoubleMatrix(0,0, mxREAL); plhs[1] = HDR; #endif if (VERBOSE_LEVEL>7) mexPrintf("777: abort mexSLOAD - sopen failed\n"); return; } #ifdef CHOLMOD_H RerefCHANNEL(hdr,rr,2); #endif if (!hdr->FLAG.OVERFLOWDETECTION && FlagOverflowDetection) mexPrintf("Warning %s: Overflowdetection not supported in file %s\n", __FILE__, hdr->FileName); if (hdr->FLAG.UCAL != FlagUCAL) mexPrintf("Warning %s: Flag UCAL is %i instead of %i (%s)\n", __FILE__, hdr->FLAG.UCAL, FlagUCAL, hdr->FileName); if (VERBOSE_LEVEL>7) fprintf(stderr,"[112] SOPEN-R finished NS=%i %i\n",hdr->NS,NS); // convert2to4_eventtable(hdr); #ifdef CHOLMOD_H if (hdr->Calib != NULL) { NS = hdr->Calib->ncol; } else #endif if ((NS<0) || ((NS==1) && (ChanList[0] == 0.0))) { // all channels for (k=0, NS=0; kNS; ++k) { if (hdr->CHANNEL[k].OnOff) NS++; } } else { for (k=0; kNS; ++k) hdr->CHANNEL[k].OnOff = 0; // reset for (k=0; k hdr->NS)) mexPrintf("Invalid channel number CHAN(%i) = %i!\n",k+1,ch); else hdr->CHANNEL[ch-1].OnOff = 1; // set } } if (VERBOSE_LEVEL>7) fprintf(stderr,"[113] NS=%i %i\n",hdr->NS,NS); #ifndef mexSOPEN if (hdr->FLAG.ROW_BASED_CHANNELS) plhs[0] = mxCreateDoubleMatrix(NS, hdr->NRec*hdr->SPR, mxREAL); else plhs[0] = mxCreateDoubleMatrix(hdr->NRec*hdr->SPR, NS, mxREAL); count = sread(mxGetPr(plhs[0]), 0, hdr->NRec, hdr); hdr->NRec = count; #endif sclose(hdr); #ifdef CHOLMOD_H if (hdr->Calib && hdr->rerefCHANNEL) { hdr->NS = hdr->Calib->ncol; free(hdr->CHANNEL); hdr->CHANNEL = hdr->rerefCHANNEL; hdr->rerefCHANNEL = NULL; hdr->Calib = NULL; } #endif if ((status=serror2(hdr))) return; if (VERBOSE_LEVEL>7) fprintf(stderr,"\n[129] SREAD/SCLOSE on %s successful [%i,%i] [%i,%i] %i.\n",hdr->FileName,(int)hdr->data.size[0],(int)hdr->data.size[1],(int)hdr->NRec,(int)count,(int)NS); // hdr2ascii(hdr,stderr,4); #ifndef mexSOPEN if (nlhs>1) { #endif char* mexFileName = (char*)mxMalloc(strlen(hdr->FileName)+1); mxArray *tmp, *tmp2, *Patient, *Manufacturer, *ID, *EVENT, *Filter, *Flag, *FileType; uint16_t numfields; const char *fnames[] = {"TYPE","VERSION","FileName","T0","tzmin","Patient",\ "HeadLen","NS","SPR","NRec","SampleRate", "FLAG", \ "EVENT","Label","LeadIdCode","PhysDimCode","PhysDim","Filter",\ "PhysMax","PhysMin","DigMax","DigMin","Transducer","Cal","Off","GDFTYP","TOffset",\ "ELEC","Impedance","fZ","AS","Dur","REC","Manufacturer",NULL}; for (numfields=0; fnames[numfields++] != NULL; ); HDR = mxCreateStructMatrix(1, 1, --numfields, fnames); mxSetField(HDR,0,"TYPE",mxCreateString(GetFileTypeString(hdr->TYPE))); mxSetField(HDR,0,"HeadLen",mxCreateDoubleScalar(hdr->HeadLen)); mxSetField(HDR,0,"VERSION",mxCreateDoubleScalar(hdr->VERSION)); mxSetField(HDR,0,"NS",mxCreateDoubleScalar(NS)); mxSetField(HDR,0,"SPR",mxCreateDoubleScalar(hdr->SPR)); mxSetField(HDR,0,"NRec",mxCreateDoubleScalar(hdr->NRec)); mxSetField(HDR,0,"SampleRate",mxCreateDoubleScalar(hdr->SampleRate)); mxSetField(HDR,0,"Dur",mxCreateDoubleScalar(hdr->SPR/hdr->SampleRate)); mxSetField(HDR,0,"FileName",mxCreateString(hdr->FileName)); mxSetField(HDR,0,"T0",mxCreateDoubleScalar(ldexp(hdr->T0,-32))); mxSetField(HDR,0,"tzmin",mxCreateDoubleScalar(hdr->tzmin)); /* Channel information */ #ifdef CHOLMOD_H /* if (hdr->Calib == NULL) { // is refering to &RR, do not destroy mxArray *Calib = mxCreateDoubleMatrix(hdr->Calib->nrow, hdr->Calib->ncol, mxREAL); } */ #endif mxArray *LeadIdCode = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *PhysDimCode = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *GDFTYP = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *PhysMax = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *PhysMin = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *DigMax = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *DigMin = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Cal = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Off = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Toffset = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *ELEC_POS = mxCreateDoubleMatrix(NS,3, mxREAL); /* mxArray *ELEC_Orient = mxCreateDoubleMatrix(NS,3, mxREAL); mxArray *ELEC_Area = mxCreateDoubleMatrix(NS,1, mxREAL); */ mxArray *LowPass = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *HighPass = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Notch = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Impedance = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *fZ = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *SPR = mxCreateDoubleMatrix(1,NS, mxREAL); mxArray *Label = mxCreateCellMatrix(NS,1); mxArray *Transducer = mxCreateCellMatrix(NS,1); mxArray *PhysDim1 = mxCreateCellMatrix(NS,1); for (k=0,k1=0; k1CHANNEL[k].OnOff) { *(mxGetPr(LeadIdCode)+k1) = (double)hdr->CHANNEL[k].LeadIdCode; *(mxGetPr(PhysDimCode)+k1) = (double)hdr->CHANNEL[k].PhysDimCode; *(mxGetPr(GDFTYP)+k1) = (double)hdr->CHANNEL[k].GDFTYP; *(mxGetPr(PhysMax)+k1) = (double)hdr->CHANNEL[k].PhysMax; *(mxGetPr(PhysMin)+k1) = (double)hdr->CHANNEL[k].PhysMin; *(mxGetPr(DigMax)+k1) = (double)hdr->CHANNEL[k].DigMax; *(mxGetPr(DigMin)+k1) = (double)hdr->CHANNEL[k].DigMin; *(mxGetPr(Toffset)+k1) = (double)hdr->CHANNEL[k].TOffset; *(mxGetPr(Cal)+k1) = (double)hdr->CHANNEL[k].Cal; *(mxGetPr(Off)+k1) = (double)hdr->CHANNEL[k].Off; *(mxGetPr(SPR)+k1) = (double)hdr->CHANNEL[k].SPR; *(mxGetPr(LowPass)+k1) = (double)hdr->CHANNEL[k].LowPass; *(mxGetPr(HighPass)+k1) = (double)hdr->CHANNEL[k].HighPass; *(mxGetPr(Notch)+k1) = (double)hdr->CHANNEL[k].Notch; *(mxGetPr(Impedance)+k1) = (double)hdr->CHANNEL[k].Impedance; *(mxGetPr(fZ)+k1) = (double)hdr->CHANNEL[k].fZ; *(mxGetPr(ELEC_POS)+k1) = (double)hdr->CHANNEL[k].XYZ[0]; *(mxGetPr(ELEC_POS)+k1+NS) = (double)hdr->CHANNEL[k].XYZ[1]; *(mxGetPr(ELEC_POS)+k1+NS*2) = (double)hdr->CHANNEL[k].XYZ[2]; /* *(mxGetPr(ELEC_Orient)+k1) = (double)hdr->CHANNEL[k].Orientation[0]; *(mxGetPr(ELEC_Orient)+k1+NS) = (double)hdr->CHANNEL[k].Orientation[1]; *(mxGetPr(ELEC_Orient)+k1+NS*2) = (double)hdr->CHANNEL[k].Orientation[2]; *(mxGetPr(ELEC_Area)+k1) = (double)hdr->CHANNEL[k].Area; */ mxSetCell(Label,k1,mxCreateString(hdr->CHANNEL[k].Label ? hdr->CHANNEL[k].Label : "")); mxSetCell(Transducer,k1,mxCreateString(hdr->CHANNEL[k].Transducer ? hdr->CHANNEL[k].Transducer : "")); mxSetCell(PhysDim1,k1,mxCreateString(PhysDim3(hdr->CHANNEL[k].PhysDimCode))); k1++; } mxSetField(HDR,0,"LeadIdCode",LeadIdCode); mxSetField(HDR,0,"PhysDimCode",PhysDimCode); mxSetField(HDR,0,"GDFTYP",GDFTYP); mxSetField(HDR,0,"PhysMax",PhysMax); mxSetField(HDR,0,"PhysMin",PhysMin); mxSetField(HDR,0,"DigMax",DigMax); mxSetField(HDR,0,"DigMin",DigMin); mxSetField(HDR,0,"TOffset",Toffset); mxSetField(HDR,0,"Cal",Cal); mxSetField(HDR,0,"Off",Off); mxSetField(HDR,0,"Impedance",Impedance); mxSetField(HDR,0,"fZ",fZ); mxSetField(HDR,0,"Off",Off); mxSetField(HDR,0,"PhysDim",PhysDim1); mxSetField(HDR,0,"Transducer",Transducer); mxSetField(HDR,0,"Label",Label); const char* field[] = {"XYZ",NULL}; for (numfields=0; field[numfields++] != 0; ); tmp = mxCreateStructMatrix(1, 1, --numfields, field); mxSetField(tmp,0,"XYZ",ELEC_POS); /* mxSetField(tmp,0,"Orientation",ELEC_Orient); mxSetField(tmp,0,"Area",ELEC_Area); */ mxSetField(HDR,0,"ELEC",tmp); const char* field2[] = {"SPR",NULL}; for (numfields=0; field2[numfields++] != 0; ); tmp2 = mxCreateStructMatrix(1, 1, --numfields, field2); mxSetField(tmp2,0,"SPR",SPR); if (hdr->AS.bci2000!=NULL) { mxAddField(tmp2, "BCI2000"); mxSetField(tmp2,0,"BCI2000",mxCreateString(hdr->AS.bci2000)); } if (hdr->TYPE==Sigma) { mxAddField(tmp2, "H1"); mxSetField(tmp2,0,"H1",mxCreateString((char*)hdr->AS.Header)); } mxSetField(HDR,0,"AS",tmp2); /* FLAG */ const char* field3[] = {"UCAL","OVERFLOWDETECTION","ROW_BASED_CHANNELS",NULL}; for (numfields=0; field3[numfields++] != 0; ); Flag = mxCreateStructMatrix(1, 1, --numfields, field3); #ifdef MX_API_VER //#if 1 // Matlab, Octave 3.6.1 mxSetField(Flag,0,"UCAL",mxCreateLogicalScalar(hdr->FLAG.UCAL)); mxSetField(Flag,0,"OVERFLOWDETECTION",mxCreateLogicalScalar(hdr->FLAG.OVERFLOWDETECTION)); mxSetField(Flag,0,"ROW_BASED_CHANNELS",mxCreateLogicalScalar(hdr->FLAG.ROW_BASED_CHANNELS)); #else // mxCreateLogicalScalar are not included in Octave 3.0 mxSetField(Flag,0,"UCAL",mxCreateDoubleScalar(hdr->FLAG.UCAL)); mxSetField(Flag,0,"OVERFLOWDETECTION",mxCreateDoubleScalar(hdr->FLAG.OVERFLOWDETECTION)); mxSetField(Flag,0,"ROW_BASED_CHANNELS",mxCreateDoubleScalar(hdr->FLAG.ROW_BASED_CHANNELS)); #endif mxSetField(HDR,0,"FLAG",Flag); /* Filter */ const char *filter_fields[] = {"HighPass","LowPass","Notch",NULL}; for (numfields=0; filter_fields[numfields++] != 0; ); Filter = mxCreateStructMatrix(1, 1, --numfields, filter_fields); mxSetField(Filter,0,"LowPass",LowPass); mxSetField(Filter,0,"HighPass",HighPass); mxSetField(Filter,0,"Notch",Notch); mxSetField(HDR,0,"Filter",Filter); /* annotation, marker, event table */ const char *event_fields[] = {"SampleRate","TYP","POS","DUR","CHN","Desc",NULL}; if (hdr->EVENT.DUR == NULL) EVENT = mxCreateStructMatrix(1, 1, 3, event_fields); else { EVENT = mxCreateStructMatrix(1, 1, 5, event_fields); mxArray *DUR = mxCreateDoubleMatrix(hdr->EVENT.N,1, mxREAL); mxArray *CHN = mxCreateDoubleMatrix(hdr->EVENT.N,1, mxREAL); for (k=0; kEVENT.N; ++k) { *(mxGetPr(DUR)+k) = (double)hdr->EVENT.DUR[k]; *(mxGetPr(CHN)+k) = (double)hdr->EVENT.CHN[k]; // channels use a 1-based index, 0 indicates all channels } mxSetField(EVENT,0,"DUR",DUR); mxSetField(EVENT,0,"CHN",CHN); } if (hdr->EVENT.CodeDesc != NULL) { mxAddField(EVENT, "CodeDesc"); mxArray *CodeDesc = mxCreateCellMatrix(hdr->EVENT.LenCodeDesc-1,1); for (k=1; k < hdr->EVENT.LenCodeDesc; ++k) { mxSetCell(CodeDesc,k-1,mxCreateString(hdr->EVENT.CodeDesc[k])); } mxSetField(EVENT,0,"CodeDesc",CodeDesc); } mxArray *TYP = mxCreateDoubleMatrix(hdr->EVENT.N,1, mxREAL); mxArray *POS = mxCreateDoubleMatrix(hdr->EVENT.N,1, mxREAL); for (k=0; kEVENT.N; ++k) { *(mxGetPr(TYP)+k) = (double)hdr->EVENT.TYP[k]; *(mxGetPr(POS)+k) = (double)hdr->EVENT.POS[k]+1; // conversion from 0-based to 1-based indexing } mxSetField(EVENT,0,"TYP",TYP); mxSetField(EVENT,0,"POS",POS); #if (BIOSIG_VERSION >= 10500) if (hdr->EVENT.TimeStamp) { mxArray *TimeStamp = mxCreateDoubleMatrix(hdr->EVENT.N,1, mxREAL); for (k=0; kEVENT.N; ++k) { *(mxGetPr(TimeStamp)+k) = ldexp(hdr->EVENT.TimeStamp[k],-32); } mxAddField(EVENT, "TimeStamp"); mxSetField(EVENT,0,"TimeStamp",TimeStamp); } #endif mxSetField(EVENT,0,"SampleRate",mxCreateDoubleScalar(hdr->EVENT.SampleRate)); mxSetField(HDR,0,"EVENT",EVENT); /* Record identification */ const char *ID_fields[] = {"Recording","Technician","Hospital","Equipment","IPaddr",NULL}; for (numfields=0; ID_fields[numfields++] != 0; ); ID = mxCreateStructMatrix(1, 1, --numfields, ID_fields); mxSetField(ID,0,"Recording",mxCreateString(hdr->ID.Recording)); mxSetField(ID,0,"Technician",mxCreateString(hdr->ID.Technician)); mxSetField(ID,0,"Hospital",mxCreateString(hdr->ID.Hospital)); mxSetField(ID,0,"Equipment",mxCreateString((char*)&hdr->ID.Equipment)); int len = 4; uint8_t IPv6=0; for (k=4; k<16; k++) IPv6 |= hdr->IPaddr[k]; if (IPv6) len=16; mxArray *IPaddr = mxCreateNumericMatrix(1,len,mxUINT8_CLASS,mxREAL); memcpy(mxGetData(IPaddr),hdr->IPaddr,len); mxSetField(ID,0,"IPaddr",IPaddr); mxSetField(HDR,0,"REC",ID); /* Patient Information */ const char *patient_fields[] = {"Sex","Handedness","Id","Name","Weight","Height","Birthday",NULL}; for (numfields=0; patient_fields[numfields++] != 0; ); Patient = mxCreateStructMatrix(1, 1, --numfields, patient_fields); const char *strarray; #ifdef __LIBBIOSIG2_H__ strarray = biosig_get_patient_name(hdr); mxSetField(Patient,0,"Name",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = biosig_get_patient_id(hdr); mxSetField(Patient,0,"Id",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); #else strarray = hdr->Patient.Name; mxSetField(Patient,0,"Name",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = hdr->Patient.Id; mxSetField(Patient,0,"Id",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); #endif mxSetField(Patient,0,"Handedness",mxCreateDoubleScalar(hdr->Patient.Handedness)); mxSetField(Patient,0,"Sex",mxCreateDoubleScalar(hdr->Patient.Sex)); mxSetField(Patient,0,"Weight",mxCreateDoubleScalar((double)hdr->Patient.Weight)); mxSetField(Patient,0,"Height",mxCreateDoubleScalar((double)hdr->Patient.Height)); mxSetField(Patient,0,"Birthday",mxCreateDoubleScalar(ldexp(hdr->Patient.Birthday,-32))); double d; if (hdr->Patient.Weight==0) d = NAN; // not-a-number else if (hdr->Patient.Weight==255) d = INFINITY; // Overflow else d = (double)hdr->Patient.Weight; mxSetField(Patient,0,"Weight",mxCreateDoubleScalar(d)); if (hdr->Patient.Height==0) d = NAN; // not-a-number else if (hdr->Patient.Height==255) d = INFINITY; // Overflow else d = (double)hdr->Patient.Height; mxSetField(Patient,0,"Height",mxCreateDoubleScalar(d)); /* Manufacturer Information */ const char *manufacturer_fields[] = {"Name","Model","Version","SerialNumber",NULL}; for (numfields=0; manufacturer_fields[numfields++] != 0; ); Manufacturer = mxCreateStructMatrix(1, 1, --numfields, manufacturer_fields); #ifdef __LIBBIOSIG2_H__ strarray = biosig_get_manufacturer_name(hdr); mxSetField(Manufacturer,0,"Name",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = biosig_get_manufacturer_model(hdr); mxSetField(Manufacturer,0,"Model",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = biosig_get_manufacturer_version(hdr); mxSetField(Manufacturer,0,"Version",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = biosig_get_manufacturer_serial_number(hdr); mxSetField(Manufacturer,0,"SerialNumber",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); #else strarray = hdr->ID.Manufacturer.Name; mxSetField(Manufacturer,0,"Name",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = hdr->ID.Manufacturer.Model; mxSetField(Manufacturer,0,"Model",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = hdr->ID.Manufacturer.Version; mxSetField(Manufacturer,0,"Version",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); strarray = hdr->ID.Manufacturer.SerialNumber; mxSetField(Manufacturer,0,"SerialNumber",mxCreateCharMatrixFromStrings(strarray!=NULL, &strarray)); #endif mxSetField(HDR,0,"Manufacturer",Manufacturer); if (VERBOSE_LEVEL>7) fprintf(stdout,"[148] going for SCLOSE\n"); mxSetField(HDR,0,"Patient",Patient); #ifndef mexSOPEN plhs[1] = HDR; } #else plhs[0] = HDR; #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"[151] going for SCLOSE\n"); #ifdef CHOLMOD_H hdr->Calib = NULL; // is refering to &RR, do not destroy #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"[156] SCLOSE finished\n"); destructHDR(hdr); hdr = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"[157] SCLOSE finished\n"); }; biosig-2.3.3/biosig4c++/mex/mexSSAVE.cpp0000664000175000017500000003714014105434233017704 0ustar schloeglschloegl/* Copyright (C) 2011,2013,2015 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ #include "mex.h" #include #include #include #include #include #include #include #ifdef NDEBUG #define VERBOSE_LEVEL 0 // turn off debugging information, but its only used without NDEBUG #else extern int VERBOSE_LEVEL; // used for debugging #endif #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; #endif #endif double getDouble(const mxArray *pm, size_t idx) { size_t n = mxGetNumberOfElements(pm); if (n == 0) return(NAN); if (n <= idx) idx = n-1; switch (mxGetClassID(pm)) { case mxCHAR_CLASS: case mxLOGICAL_CLASS: case mxINT8_CLASS: return(*((int8_t*)mxGetData(pm) + idx)); case mxUINT8_CLASS: return(*((uint8_t*)mxGetData(pm) + idx)); case mxDOUBLE_CLASS: return(*((double*)mxGetData(pm) + idx)); case mxSINGLE_CLASS: return(*((float*)mxGetData(pm) + idx)); case mxINT16_CLASS: return(*((int16_t*)mxGetData(pm) + idx)); case mxUINT16_CLASS: return(*((uint16_t*)mxGetData(pm) + idx)); case mxINT32_CLASS: return(*((int32_t*)mxGetData(pm) + idx)); case mxUINT32_CLASS: return(*((uint32_t*)mxGetData(pm) + idx)); case mxINT64_CLASS: return(*((int64_t*)mxGetData(pm) + idx)); case mxUINT64_CLASS: return(*((uint64_t*)mxGetData(pm) + idx)); /* case mxFUNCTION_CLASS: case mxUNKNOWN_CLASS: case mxCELL_CLASS: case mxSTRUCT_CLASS: */ default: return(NAN); } return(NAN); } void mexFunction( int nlhs, /* number of expected outputs */ mxArray *plhs[], /* array of pointers to output arguments */ int nrhs, /* number of inputs */ const mxArray *prhs[] /* array of pointers to input arguments */ ) { int k; const mxArray *arg; HDRTYPE *hdr; size_t count; time_t T0; char *FileName; char tmpstr[128]; int status; int CHAN = 0; double *ChanList=NULL; int NS = -1; char FlagOverflowDetection = 1, FlagUCAL = 0; void *data = NULL; mxArray *p = NULL, *p1 = NULL, *p2 = NULL; #ifdef CHOLMOD_H cholmod_sparse RR,*rr=NULL; double dummy; #endif // ToDO: output single data // mxClassId FlagMXclass=mxDOUBLE_CLASS; if (nrhs<1) { mexPrintf(" Usage of mexSSAVE:\n"); mexPrintf("\tstatus=mexSSAVE(HDR,data)\n"); mexPrintf(" Input:\n\tHDR\tHeader structure \n"); mexPrintf("\tdata\tdata matrix, one channel per column\n"); mexPrintf("\tHDR\theader structure\n\n"); mexPrintf("\tstatus 0: file saves successfully\n\n"); mexPrintf("\tstatus <>0: file could not saved\n\n"); return; } /* improve checks for input arguments */ /* process input arguments */ if (mxIsNumeric(prhs[1]) && mxIsStruct( prhs[0])) { data = (void*) mxGetData(prhs[1]); // get number of channels size_t NS = mxGetN (prhs[1]); // get number of events size_t NEvt=0; if ( (p = mxGetField(prhs[0], 0, "EVENT") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "POS") ) != NULL ) { NEvt = mxGetNumberOfElements(p1); } if ( (p1 = mxGetField(p, 0, "TYP") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); if (n>NEvt) NEvt = n; } } // allocate memory for header structure hdr = constructHDR (NS, NEvt); data = (biosig_data_type*) mxGetData (prhs[1]); hdr->NRec = mxGetM (prhs[1]); hdr->SPR = 1; } else { mexErrMsgTxt("mexSSAVE(HDR,data) failed because HDR and data, are not a struct and numeric, resp.\n"); return; } for (k = 2; k < nrhs; k++) { arg = prhs[k]; if (mxIsChar(arg)) { #ifdef DEBUG mexPrintf("arg[%i]=%s \n",k,mxArrayToString(prhs[k])); #endif if (!strcmp(mxArrayToString(prhs[k]), "OVERFLOWDETECTION:ON")) FlagOverflowDetection = 1; else if (!strcmp(mxArrayToString(prhs[k]), "OVERFLOWDETECTION:OFF")) FlagOverflowDetection = 0; else if (!strcmp(mxArrayToString(prhs[k]), "UCAL:ON")) FlagUCAL = 1; else if (!strcmp(mxArrayToString(prhs[k]), "UCAL:OFF")) FlagUCAL = 0; } else { #ifndef mexSOPEN mexPrintf("mexSSAVE: argument #%i is invalid.",k+1); mexErrMsgTxt("mexSSAVE failes because of unknown parameter\n"); #else mexPrintf("mexSOPEN: argument #%i is invalid.",k+1); mexErrMsgTxt("mexSOPEN fails because of unknown parameter\n"); #endif } } /***** SET INPUT ARGUMENTS *****/ hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = FlagUCAL; #ifdef CHOLMOD_H hdr->FLAG.ROW_BASED_CHANNELS = (rr!=NULL); #else hdr->FLAG.ROW_BASED_CHANNELS = 0; #endif /***** CHECK INPUT HDR STUCTURE CONVERT TO libbiosig hdr *****/ if (VERBOSE_LEVEL>7) mexPrintf("110: input arguments checked\n"); if ( (p = mxGetField(prhs[0], 0, "TYPE") ) != NULL ) { mxGetString(p,tmpstr,sizeof(tmpstr)); hdr->TYPE = GetFileTypeFromString(tmpstr); } if ( (p = mxGetField(prhs[0], 0, "VERSION") ) != NULL ) { mxGetString(p, tmpstr, sizeof(tmpstr)); hdr->VERSION = atof(tmpstr); } if ( (p = mxGetField(prhs[0], 0, "T0") ) != NULL ) hdr->T0 = (gdf_time)getDouble(p, 0); if ( (p = mxGetField(prhs[0], 0, "tzmin") ) != NULL ) hdr->tzmin = (int16_t)getDouble(p, 0); else hdr->tzmin = -timezone/60; if ( (p = mxGetField(prhs[0], 0, "FileName") ) != NULL ) FileName = mxArrayToString(p); if ( (p = mxGetField(prhs[0], 0, "SampleRate") ) != NULL ) hdr->SampleRate = getDouble(p, 0); if ( (p = mxGetField(prhs[0], 0, "NS") ) != NULL ) hdr->NS = getDouble(p, 0); #ifdef DEBUG mexPrintf("mexSSAVE [400] TYPE=<%s><%s> VERSION=%f\n",tmpstr,GetFileTypeString(hdr->TYPE),hdr->VERSION); #endif p1 = mxGetField(prhs[0], 0, "SPR"); p2 = mxGetField(prhs[0], 0, "NRec"); if ( p1 && p2) { hdr->SPR = (size_t)getDouble(p1, 0); hdr->NRec = (size_t)getDouble(p2, 0); } else if (!p1 && p2) { hdr->SPR = hdr->NRec; hdr->NRec = (size_t)getDouble(p2, 0); hdr->SPR /= hdr->NRec; } else if ( p1 && !p2) { hdr->SPR = (size_t)getDouble(p1, 0); hdr->NRec /= hdr->SPR; } else if (!p1 && !p2) { ; /* use default values SPR=1, NREC = size(data,1) */ } if (hdr->NRec * hdr->SPR != mxGetM (prhs[1]) ) mexPrintf("mexSSAVE: warning HDR.NRec * HDR.SPR (%i*%i = %i) does not match number of rows (%i) in data.", hdr->NRec, hdr->SPR, hdr->NRec*hdr->SPR, mxGetM(prhs[1]) ); if ( (p = mxGetField(prhs[0], 0, "Label") ) != NULL ) { if ( mxIsCell(p) ) { for (k = 0; k < hdr->NS; k++) mxGetString(mxGetCell(p,k), hdr->CHANNEL[k].Label, MAX_LENGTH_LABEL+1); } } if ( (p = mxGetField(prhs[0], 0, "Transducer") ) != NULL ) { if ( mxIsCell(p) ) { for (k = 0; k < hdr->NS; k++) mxGetString(mxGetCell(p,k), hdr->CHANNEL[k].Transducer, MAX_LENGTH_LABEL+1); } } if ( (p = mxGetField(prhs[0], 0, "LowPass") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].LowPass = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "HighPass") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].HighPass = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "Notch") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].Notch = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "PhysMax") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].PhysMax = (double)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "PhysMin") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].PhysMin = (double)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "DigMax") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].DigMax = (double)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "DigMin") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].DigMin = (double)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "PhysDimCode") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].PhysDimCode = (uint16_t)getDouble(p,k); } else if ( (p = mxGetField(prhs[0], 0, "PhysDim") ) != NULL ) { if ( mxIsCell(p) ) { for (k = 0; k < hdr->NS; k++) mxGetString(mxGetCell(p,k), tmpstr, sizeof(tmpstr)); hdr->CHANNEL[k].PhysDimCode = PhysDimCode(tmpstr); } } if ( (p = mxGetField(prhs[0], 0, "GDFTYP") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].GDFTYP = (uint16_t)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "TOffset") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].TOffset = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "Impedance") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].Impedance = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "fZ") ) != NULL ) { for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].fZ = (float)getDouble(p,k); } if ( (p = mxGetField(prhs[0], 0, "AS") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "SPR") ) != NULL ) { // define channel-based samplingRate, HDR.SampleRate*HDR.AS.SPR(channel)/HDR.SPR; for (k = 0; k < hdr->NS; k++) hdr->CHANNEL[k].SPR = (double)getDouble(p1,k); } } if ( (p = mxGetField(prhs[0], 0, "Patient") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "Id") ) != NULL ) if (mxIsChar(p1)) mxGetString(p1, hdr->Patient.Id, MAX_LENGTH_PID+1); if ( (p1 = mxGetField(p, 0, "Name") ) != NULL ) if (mxIsChar(p1)) mxGetString(p1, hdr->Patient.Name, MAX_LENGTH_PID+1); if ( (p1 = mxGetField(p, 0, "Sex") ) != NULL ) { if (mxIsChar(p1)) { char sex = toupper(*mxGetChars(p1)); hdr->Patient.Sex = (sex=='M') + 2*(sex=='F'); } else hdr->Patient.Sex = (int8_t)getDouble(p1,0); } if ( (p1 = mxGetField(p, 0, "Handedness") ) != NULL ) hdr->Patient.Handedness = (int8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "Smoking") ) != NULL ) hdr->Patient.Smoking = (int8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "AlcoholAbuse") ) != NULL ) hdr->Patient.AlcoholAbuse = (int8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "DrugAbuse") ) != NULL ) hdr->Patient.DrugAbuse = (int8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "Medication") ) != NULL ) hdr->Patient.Medication = (int8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "Impairment") ) != NULL ) { if ( (p2 = mxGetField(p1, 0, "Visual") ) != NULL ) hdr->Patient.Impairment.Visual = (int8_t)getDouble(p2,0); if ( (p2 = mxGetField(p1, 0, "Heart") ) != NULL ) hdr->Patient.Impairment.Heart = (int8_t)getDouble(p2,0); } if ( (p1 = mxGetField(p, 0, "Weight") ) != NULL ) hdr->Patient.Weight = (uint8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "Height") ) != NULL ) hdr->Patient.Height = (uint8_t)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "Birthday") ) != NULL ) hdr->Patient.Birthday = (gdf_time)getDouble(p1,0); } if ( (p = mxGetField(prhs[0], 0, "ID") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "Recording") ) != NULL ) if (mxIsChar(p1)) mxGetString(p1, hdr->ID.Recording, MAX_LENGTH_RID+1); if ( (p1 = mxGetField(p, 0, "Technician") ) != NULL ) if (mxIsChar(p1)) { char* str = mxArrayToString(p1); hdr->ID.Technician = strdup(str); } if ( (p1 = mxGetField(p, 0, "Hospital") ) != NULL && mxIsChar(p1) ) { size_t len = mxGetN(p1)*mxGetN(p1); hdr->ID.Hospital = (char*)realloc(hdr->ID.Hospital, len+1); mxGetString(p1, hdr->ID.Hospital, len); } if ( (p1 = mxGetField(p, 0, "Equipment") ) != NULL ) memcpy(&hdr->ID.Equipment,mxGetData(p1), 8); if ( (p1 = mxGetField(p, 0, "Manufacturer") ) != NULL ) { uint8_t pos = 0; if ( ( (p2 = mxGetField(p1, 0, "Name") ) != NULL ) && mxIsChar(p2)) { //hdr->ID.Manufacturer.Name=mxGetChars(p2); mxGetString(p1, hdr->ID.Manufacturer._field,MAX_LENGTH_MANUF); pos = strlen(hdr->ID.Manufacturer._field)+1; } else { hdr->ID.Manufacturer._field[pos++] = 0; } if ( ( (p2 = mxGetField(p1, 0, "Model") ) != NULL ) && mxIsChar(p2)) { //hdr->ID.Manufacturer.Model=mxGetChars(p2); mxGetString(p1, hdr->ID.Manufacturer._field + pos, MAX_LENGTH_MANUF); pos += strlen(hdr->ID.Manufacturer._field + pos)+1; } else { hdr->ID.Manufacturer._field[pos++] = 0; } if ( ( (p2 = mxGetField(p1, 0, "Version") ) != NULL ) && mxIsChar(p2)) { //hdr->ID.Manufacturer.Version=mxGetChars(p2); mxGetString(p1, hdr->ID.Manufacturer._field + pos, MAX_LENGTH_MANUF); pos += strlen(hdr->ID.Manufacturer._field+pos)+1; } else { hdr->ID.Manufacturer._field[pos++] = 0; } if ( ( (p2 = mxGetField(p1, 0, "SerialNumber") ) != NULL ) && mxIsChar(p2)) { //hdr->ID.Manufacturer.SerialNumber=mxGetChars(p2); mxGetString(p1, hdr->ID.Manufacturer._field + pos, MAX_LENGTH_MANUF); pos += strlen(hdr->ID.Manufacturer._field+pos)+1; } else { hdr->ID.Manufacturer._field[pos++] = 0; } } } if ( (p = mxGetField(prhs[0], 0, "FLAG") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "OVERFLOWDETECTION") ) != NULL ) hdr->FLAG.OVERFLOWDETECTION = (char)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "UCAL") ) != NULL ) hdr->FLAG.UCAL = (char)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "ANONYMOUS") ) != NULL ) hdr->FLAG.ANONYMOUS = (char)getDouble(p1,0); if ( (p1 = mxGetField(p, 0, "ROW_BASED_CHANNELS") ) != NULL ) hdr->FLAG.ROW_BASED_CHANNELS = (char)getDouble(p1,0); } if ( (p = mxGetField(prhs[0], 0, "EVENT") ) != NULL ) { if ( (p1 = mxGetField(p, 0, "SampleRate") ) != NULL ) { hdr->EVENT.SampleRate = (double)getDouble(p1,0); } if ( (p1 = mxGetField(p, 0, "POS") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); for (k = 0; k < n; k++) hdr->EVENT.POS[k] = (uint32_t)getDouble(p1,k); } if ( (p1 = mxGetField(p, 0, "TYP") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); for (k = 0; k < n; k++) hdr->EVENT.TYP[k] = (uint16_t)getDouble(p1,k); } if ( (p1 = mxGetField(p, 0, "DUR") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); for (k = 0; k < n; k++) hdr->EVENT.DUR[k] = (uint32_t)getDouble(p1,k); } if ( (p1 = mxGetField(p, 0, "CHN") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); for (k = 0; k < n; k++) hdr->EVENT.CHN[k] = (uint16_t)getDouble(p1,k); } if ( (p1 = mxGetField(p, 0, "CodeDesc") ) != NULL ) { size_t n = mxGetNumberOfElements(p1); hdr->EVENT.LenCodeDesc = n+1; // get total size for storing all CodeDesc strings size_t memsiz = 1; for (k = 0; k < n; k++) { mxArray *p2 = mxGetCell(p1,k); memsiz += mxGetN(p2)+1; } /* allocate memory for hdr->.AS.auxBUF contains the \0-terminated CodeDesc strings, hdr->EVENT.CodeDesc contains the pointer to the strings */ hdr->EVENT.CodeDesc = (const char**) realloc(hdr->EVENT.CodeDesc, hdr->EVENT.LenCodeDesc*sizeof(char*)); hdr->AS.auxBUF = (uint8_t*)realloc(hdr->AS.auxBUF, memsiz*sizeof(char)); // first element is always the empty string. hdr->AS.auxBUF[0] = 0; hdr->EVENT.CodeDesc[0] = (char*)hdr->AS.auxBUF; size_t pos = 1; for (k = 0; k < n; k++) { mxArray *p2 = mxGetCell(p1,k); size_t buflen = mxGetN(p2)+1; //*mxGetM(p2) mxGetString(p2, (char*)hdr->AS.auxBUF+pos, buflen); hdr->EVENT.CodeDesc[k+1] = (char*)hdr->AS.auxBUF+pos; pos += buflen; } } } hdr = sopen(FileName, "w", hdr); if (serror2(hdr)) mexErrMsgTxt("mexSSAVE: sopen failed \n"); swrite((biosig_data_type*)data, hdr->NRec, hdr); if (serror2(hdr)) mexErrMsgTxt("mexSSAVE: swrite failed \n"); destructHDR(hdr); if (serror2(hdr)) mexErrMsgTxt("mexSSAVE: sclose failed \n"); }; biosig-2.3.3/biosig4c++/mex/DESCRIPTION0000664000175000017500000000120014105434233017277 0ustar schloeglschloeglName: mexbiosig Version: 2.3.1 Date: 2021-07-19 Author: Alois Schloegl Maintainer: Alois Schlögl Title: The mexBiosig toolbox Description: The Biosig package provides a number of tools for biomedical signal processing, including importing of about 50 different data formations. Depends: octave (> 3.2.0) Recommends: general, signal, statistics, nan, tsa SystemRequirements: octave (> 3.2.0), libbiosig1 | libbiosig2 | libbiosig3 BuildRequires: libbiosig-dev (> 1.3.0) License: GPLv3+ Url: http://pub.ist.ac.at/~schloegl/matlab/biosig Autoload: yes Categories: EEG ECG EMG EOG biomedical signals dataformat biosig-2.3.3/biosig4c++/mex/physicalunits.cpp0000664000175000017500000001725714105434233021217 0ustar schloeglschloegl/* Copyright (C) 2011,2013,2015,2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ #include "mex.h" #include #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; #endif #endif // read numeric value and convert to uint16_t uint16_t getUINT16(const mxArray *pm, size_t idx) { size_t n = mxGetNumberOfElements(pm); if (n == 0) return(0); if (n <= idx) idx = 0; switch (mxGetClassID(pm)) { /* case mxCHAR_CLASS: case mxLOGICAL_CLASS: case mxINT8_CLASS: return(*((int8_t*)mxGetData(pm) + idx)); case mxUINT8_CLASS: return(*((uint8_t*)mxGetData(pm) + idx)); */ case mxDOUBLE_CLASS: return(*((double*)mxGetData(pm) + idx)); case mxSINGLE_CLASS: return(*((float*)mxGetData(pm) + idx)); case mxINT16_CLASS: return(*((int16_t*)mxGetData(pm) + idx)); case mxUINT16_CLASS: return(*((uint16_t*)mxGetData(pm) + idx)); case mxINT32_CLASS: return(*((int32_t*)mxGetData(pm) + idx)); case mxUINT32_CLASS: return(*((uint32_t*)mxGetData(pm) + idx)); case mxINT64_CLASS: return(*((int64_t*)mxGetData(pm) + idx)); case mxUINT64_CLASS: return(*((uint64_t*)mxGetData(pm) + idx)); /* case mxFUNCTION_CLASS: case mxUNKNOWN_CLASS: case mxCELL_CLASS: case mxSTRUCT_CLASS: */ default: return(0); } return(0); } void mexFunction( int nlhs, /* number of expected outputs */ mxArray *plhs[], /* array of pointers to output arguments */ int nrhs, /* number of inputs */ const mxArray *prhs[] /* array of pointers to input arguments */ ) { const char HELPTEXT[] = "PHYSICALUNITS converts PhysDim inte PhysDimCode and vice versa\n" " according to Annex A of FEF Vital Signs Format [1] \n" "\n" " HDR = physicalunits(HDR); \n" " adds HDR.PhysDim or HDR.PhysDimCode, if needed \n" "\n" " PhysDim = physicalunits(PhysDimCode);\n" " converts Code of PhysicalUnits into descriptive physical units\n" "\n" " PhysDimCode = physicalunits(PhysDim);\n" " converts descriptive units into Code for physical units.\n" "\n" " [..., scale] = physicalunits(...);\n" " scale contains the scaling factor of the decimal prefix\n" "\n" " Reference(s):\n" " ISO/IEEE 11073-10101:2004\n" " Health Informatics - Point-of-care medical device communications - Part 10101: Nomenclature\n" " p.62-75. Table A.6.3: Vital signs units of measurements\n"; if (nrhs<1) { mexPrintf( HELPTEXT); return; } const mxArray *mxPhysDim_Input = NULL; const mxArray *mxPhysDimCode_Input = NULL; mxArray *mxPhysDim_Output = NULL; mxArray *mxPhysDimCode_Output = NULL; mxArray *mxScale = NULL; mwSize nDims = 0; mwSize Numel = 1; const mwSize *SZ = NULL; mwSize k; /************************************************************* Input *************************************************************/ mxClassID Type = mxGetClassID(prhs[0]); /* process input arguments */ switch (Type) { case mxSTRUCT_CLASS: { mxPhysDim_Input = mxGetField(prhs[0], 0, "PhysDim"); mxPhysDimCode_Input = mxGetField(prhs[0], 0, "PhysDimCode"); break; } case mxINT16_CLASS: case mxINT32_CLASS: case mxINT64_CLASS: case mxUINT16_CLASS: case mxUINT32_CLASS: case mxUINT64_CLASS: case mxSINGLE_CLASS: case mxDOUBLE_CLASS: { mxPhysDimCode_Input = prhs[0]; break; } //case mxCHAR_CLASS: case mxCELL_CLASS: { mxPhysDim_Input = prhs[0]; break; } default: { mexPrintf("input arguments not supported\n"); return; } } // Get dimensions of input argument and set dimensions of output if (mxPhysDimCode_Input && !mxPhysDim_Input) { nDims = mxGetNumberOfDimensions(mxPhysDimCode_Input); SZ = mxGetDimensions(mxPhysDimCode_Input); Numel = mxGetNumberOfElements(mxPhysDimCode_Input); } else if (mxPhysDim_Input && !mxPhysDimCode_Input ) { nDims = mxGetNumberOfDimensions(mxPhysDim_Input); SZ = mxGetDimensions(mxPhysDim_Input); Numel = mxGetNumberOfElements(mxPhysDim_Input); } else if (!mxPhysDim_Input && !mxPhysDimCode_Input) { mexPrintf("Warning %s(..): Neither PhysDim nor PhysDimCode defined\n",__FILE__); plhs[0] = mxDuplicateArray(prhs[0]); return; } else if (!mxIsCell(mxPhysDim_Input) ) { mexErrMsgIdAndTxt(__FILE__":PhysDim_not_a_cell_array", "ERROR: PhysDim must be a cell array, but is not.\n"); return; } else { Numel = mxGetNumberOfElements(mxPhysDimCode_Input); if (Numel != mxGetNumberOfElements(mxPhysDim_Input)) { mexErrMsgIdAndTxt(__FILE__":Size_of_PhysDim_PhysDimCode_do_not_match", "ERROR: number of elements in PhysDim and PhysDimCode do not match.\n"); return; } int errorFlag=0; for (k=0; k < Numel; k++) { uint16_t PDC1 = getUINT16(mxPhysDimCode_Input, k); const int STRLEN=63; char tmpstring[STRLEN+1]; mxArray *tmpArr = mxGetCell(mxPhysDim_Input, k); mxGetString(tmpArr, tmpstring, STRLEN); uint16_t PDC2 = PhysDimCode(tmpstring); if (PDC1 != PDC2) { mexPrintf("ERROR %s(...): element %d doe not match %d~=%d, <%s>~=<%s>\n",__FILE__, k, PDC1,PDC2,PhysDim3(PDC1),tmpstring); errorFlag=1; } } if (errorFlag) { mexErrMsgIdAndTxt(__FILE__":some_elements_in_PhysDim_PhysDimCode_do_not_match", "ERROR: some elements in PhysDim and PhysDimCode do not match.\n"); return; } return; } // allocate 2nd output argument if ((nlhs > 1) && (nrhs > 0)) { mxScale = mxCreateNumericArray(nDims, SZ, mxDOUBLE_CLASS, mxREAL); plhs[1] = mxScale; } /************************************************************* Conversion *************************************************************/ if ( mxPhysDimCode_Input && !mxPhysDim_Input ) { mxPhysDim_Output = mxCreateCellArray(nDims, SZ); // Conversion: PhysDimCode -> PhysDim for (k=0; k < Numel; k++) { uint16_t PDC = getUINT16(mxPhysDimCode_Input, k); mxSetCell(mxPhysDim_Output, k, mxCreateString( PhysDim3( PDC ))); if (mxScale != NULL) *((double*)mxGetData(mxScale)+k) = PhysDimScale(PDC); } } else if ( mxPhysDim_Input && !mxPhysDimCode_Input && mxIsCell(mxPhysDim_Input) ) { mxPhysDimCode_Output = mxCreateNumericArray(nDims, SZ, mxUINT16_CLASS, mxREAL); // Conversion: PhysDim -> PhysDimCode for (k=0; k < Numel; k++) { const int STRLEN=63; char tmpstring[STRLEN+1]; mxArray *tmpArr = mxGetCell(mxPhysDim_Input, k); mxGetString(tmpArr, tmpstring, STRLEN); uint16_t PDC = PhysDimCode(tmpstring); *(((uint16_t*)mxGetData(mxPhysDimCode_Output))+k) = PDC; if (mxScale != NULL) *((double*)mxGetData(mxScale)+k) = PhysDimScale(PDC); } } else { mexPrintf("ERROR %s line %d\n",__FILE__,__LINE__); return; } /************************************************************* Output *************************************************************/ if ( mxIsStruct(prhs[0]) ) { plhs[0] = mxDuplicateArray(prhs[0]); if (mxPhysDimCode_Output) { int n = mxAddField( plhs[0], "PhysDimCode"); mxSetFieldByNumber( plhs[0], 0, n, mxDuplicateArray(mxPhysDimCode_Output) ); } if (mxPhysDim_Output) { int n = mxAddField( plhs[0], "PhysDim"); mxSetFieldByNumber( plhs[0], 0, n, mxDuplicateArray(mxPhysDim_Output) ); } } else if (mxPhysDim_Input && !mxPhysDimCode_Input) { plhs[0] = mxPhysDimCode_Output; } else if (mxPhysDimCode_Input && !mxPhysDim_Input) { plhs[0] = mxPhysDim_Output; } else { mexPrintf("ERROR %s line %d\n",__FILE__,__LINE__); return; } } biosig-2.3.3/biosig4c++/perl/0000775000175000017500000000000014105434244015753 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/perl/Makefile.in0000664000175000017500000000123514105434233020017 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Perl interface is available here # http://www.swig.org/Doc1.3/Perl5.html#Perl5 all: swig -c++ -perl biosig.i g++ -fPIC -c biosig_wrap.cxx -I/usr/lib/perl/5.10.1/CORE -Dbool=char g++ -shared ../libbiosig.so biosig_wrap.o -o biosig.so clean: -rm *.cxx -rm *.o -rm *.pm -rm *.so biosig-2.3.3/biosig4c++/perl/Makefile0000664000175000017500000000123514105434244017414 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Perl interface is available here # http://www.swig.org/Doc1.3/Perl5.html#Perl5 all: swig -c++ -perl biosig.i g++ -fPIC -c biosig_wrap.cxx -I/usr/lib/perl/5.10.1/CORE -Dbool=char g++ -shared ../libbiosig.so biosig_wrap.o -o biosig.so clean: -rm *.cxx -rm *.o -rm *.pm -rm *.so biosig-2.3.3/biosig4c++/perl/demo.pl0000775000175000017500000000437214105434233017243 0ustar schloeglschloegl#!/usr/bin/perl # # Demonstrates how the Header information of biosig data can be read through # JSON header export # # References: # [1] https://www.hl7.org/fhir/references.html # [2] ÖNorm K2204:2015, GDF - A general data format for biomedical signals # # Copyright (C) 2016 Alois Schloegl # This file is part of the BioSig repository at http://biosig.sf.net/ # # 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 3 # of the License, 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, see . use strict; use warnings; use JSON::XS; use Data::Dumper; my $EXT=''; if ("$^O" eq "MSWin32") { $EXT='.exe'; } # biosig_fhir_base64: # encodes a biosig file as a base64-encoded GDF [2] v3.0 stream sub biosig_fhir_base64 { my $cmd = "biosig_fhir$EXT -base64 '$_[0]' 2>/dev/null"; my $jsonhdr = `$cmd`; return $jsonhdr; } # biosig_fhir: makes a fhir_json_binary template sub biosig_fhir_json { my $cmd = "biosig_fhir$EXT -json '$_[0]' 2>/dev/null"; my $jsonhdr = `$cmd`; return $jsonhdr; } # biosig_fhir_xml: makes a fhir_xml_binary template sub biosig_fhir_xml { my $h = "biosig_fhir$EXT -xml $_[0] 2>/dev/null"; my $jsonhdr = `$h`; return $jsonhdr; } # get header (meta) information sub biosig_json_header { my $h = "save2gdf$EXT -JSON $_[0] 2>/dev/null"; my $jsonhdr = `$h`; return $jsonhdr; } # get header (meta) information in hash array sub biosig_header { return decode_json( biosig_json_header("$_[0]") ); } my $filename='data/Newtest17-256.bdf'; ### Hash array of header information through JSON interface my $HDR = biosig_header($filename); print Dumper($HDR); ## generate JSON_BINARY_TEMPLATE my $FHIR_JSON_BINARY_TEMPLATE = biosig_fhir_json($filename); print $FHIR_JSON_BINARY_TEMPLATE; biosig-2.3.3/biosig4c++/perl/biosig.i0000664000175000017500000002457314105434233017412 0ustar schloeglschloegl/* % % $Id: swig.i,v 1.25 2009-01-19 15:36:14 schloegl Exp $ % Copyright (C) 2008,2009 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ // swig.i %module biosig %{ #include "../biosig.h" %} %include typedef int64_t gdf_time; /* gdf time is represented in 64 bits */ typedef int64_t nrec_t; /* type for number of records */ /* list of file formats */ enum FileFormat { noFile, unknown, ABF, ACQ, ACR_NEMA, AIFC, AIFF, AINF, alpha, ARFF, ASCII_IBI, ASCII, AU, ASF, ATES, ATF, AVI, Axona, BCI2000, BDF, BESA, BIN, BKR, BLSC, BMP, BNI, BSCS, BrainVision, BrainVisionVAmp, BrainVisionMarker, BZ2, CDF, CFS, CFWB, CNT, CTF, DICOM, DEMG, EBS, EDF, EEG1100, EEProbe, EEProbe2, EEProbeAvr, EGI, EGIS, ELF, EMBLA, EMSA, ePrime, ET_MEG, ETG4000, EVENT, EXIF, FAMOS, FEF, FITS, FLAC, GDF, GDF1, GIF, GTF, GZIP, HDF, HL7aECG, HEKA, ISHNE, ITX, JPEG, JSON, Lexicor, Matlab, MFER, MIDI, MIT, MM, MSI, MSVCLIB, MS_LNK, native, NeuroLoggerHEX, NetCDF, NEURON, NEV, NEX1, NIFTI, OGG, OpenXDF, PBMA, PBMN, PDF, PDP, Persyst, PGMA, PGMB, PLEXON, PNG, PNM, POLY5, PPMA, PPMB, PS, RDF, RIFF, SASXPT, SCP_ECG, SIGIF, Sigma, SMA, SND, SQLite, SPSS, STATA, SVG, SXI, SYNERGY, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK, WAV, WG1, WinEEG, WMF, XML, XPM, Z, ZIP, ZIP2 }; typedef struct CHANNEL_STRUCT { double PhysMin; /* physical minimum */ double PhysMax; /* physical maximum */ double DigMin; /* digital minimum */ double DigMax; /* digital maximum */ double Cal; /* gain factor */ double Off; /* bias */ char OnOff; char Label[MAX_LENGTH_LABEL+1]; /* Label of channel */ uint16_t LeadIdCode; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1]; /* transducer e.g. EEG: Ag-AgCl electrodes */ // char PhysDim[MAX_LENGTH_PHYSDIM+1] ; /* physical dimension */ /*PhysDim is now obsolete - use function PhysDim3(PhysDimCode) instead */ uint16_t PhysDimCode; /* code for physical dimension */ /* char* PreFilt; // pre-filtering */ float TOffset; /* time delay of sampling */ float LowPass; /* lowpass filter */ float HighPass; /* high pass */ float Notch; /* notch filter */ float XYZ[3]; /* sensor position */ // float Orientation[3]; // sensor direction // float Area; // area of sensor (e.g. for MEG) union { /* context specific channel information */ float Impedance; /* Electrode Impedance in Ohm, defined only if PhysDim = _Volt */ float fZ; /* ICG probe frequency, defined only if PhysDim = _Ohm */ }; uint16_t GDFTYP; /* data type */ uint32_t SPR; /* samples per record (block) */ } CHANNEL_TYPE; /* This structure defines the general (fixed) header */ typedef struct { float VERSION; /* GDF version number */ char* FileName; enum FileFormat TYPE; /* type of file format */ struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint8_t IPaddr[16]; /* IP address of recording device (if applicable) */ double SampleRate; /* Sampling rate */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ gdf_time T0; /* starttime of recording */ uint32_t HeadLen; /* length of header in bytes */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ uint16_t NS; /* number of channels */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ #endif CHANNEL_TYPE *rerefCHANNEL; /* Patient specific information */ struct { gdf_time Birthday; /* Birthday of Patient */ // Age; /* the age is HDR.T0 - HDR.Patient.Birthday, even if T0 and Birthday are not known */ uint16_t Headsize[3]; /* circumference, nasion-inion, left-right mastoid in millimeter; */ char Name[MAX_LENGTH_NAME+1]; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ // char* Name; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ char Id[MAX_LENGTH_PID+1]; /* patient identification, identification code as used in hospital */ uint8_t Weight; /* weight in kilograms [kg] 0:unkown, 255: overflow */ uint8_t Height; /* height in centimeter [cm] 0:unkown, 255: overflow */ // BMI; /* the body-mass index = weight[kg]/height[m]^2 */ /* Patient classification */ int Sex; /* 0:Unknown, 1: Male, 2: Female */ int Handedness; /* 0:Unknown, 1: Right, 2: Left, 3: Equal */ int Smoking; /* 0:Unknown, 1: NO, 2: YES */ int AlcoholAbuse; /* 0:Unknown, 1: NO, 2: YES */ int DrugAbuse; /* 0:Unknown, 1: NO, 2: YES */ int Medication; /* 0:Unknown, 1: NO, 2: YES */ struct { int Visual; /* 0:Unknown, 1: NO, 2: YES, 3: Corrected */ int Heart; /* 0:Unknown, 1: NO, 2: YES, 3: Pacemaker */ } Impairment; } Patient; struct { char Recording[MAX_LENGTH_RID+1]; /* HL7, EDF, GDF, BDF replaces HDR.AS.RID */ char* Technician; char* Hospital; uint64_t Equipment; /* identifies this software */ struct { /* see SCP: section1, tag14, MFER: tag23: "Manufacturer^model^version number^serial number" GDF: tag3: "Manufacturer\0model\0version\0number\0serial number\0" */ // char _field[MAX_LENGTH_MANUF+1]; /* buffer */ char* Name; char* Model; char* Version; char* SerialNumber; } Manufacturer; } ID; /* position of electrodes; see also HDR.CHANNEL[k].XYZ */ struct { float REF[3]; /* XYZ position of reference electrode */ float GND[3]; /* XYZ position of ground electrode */ } ELEC; /* EVENTTABLE */ struct { double SampleRate; /* for converting POS and DUR into seconds */ uint16_t *TYP; /* defined at ../biosig4matlab/doc/eventcodes.txt */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ #if (BIOSIG_VERSION >= 10500) gdf_time *TimeStamp ATT_ALI; /* store time stamps */ #endif char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ uint32_t N; /* number of events */ uint16_t LenCodeDesc; /* length of CodeDesc Table */ } EVENT; struct { /* flags */ char OVERFLOWDETECTION; /* overflow & saturation detection 0: OFF, !=0 ON */ char UCAL; /* UnCalibration 0: scaling !=0: NO scaling - raw data return */ char ANONYMOUS; /* 1: anonymous mode, no personal names are processed */ char ROW_BASED_CHANNELS; /* 0: column-based data [default]; 1: row-based data */ char TARGETSEGMENT; /* in multi-segment files (like Nihon-Khoden, EEG1100), it is used to select a segment */ } FLAG; CHANNEL_TYPE *CHANNEL; struct { /* File specific data */ #ifdef ZLIB_H gzFile gzFID; #endif #ifdef _BZLIB_H // BZFILE* bzFID; #endif FILE* FID; /* file handle */ size_t POS; /* current reading/writing position [in blocks] */ // int Des; /* file descriptor */ uint8_t OPEN; /* 0: closed, 1:read, 2: write */ uint8_t LittleEndian; uint8_t COMPRESSION; /* 0: no compression 9: best compression */ // int DES; /* descriptor for streams */ } FILE; /* internal variables (not public) */ struct { const char* B4C_ERRMSG; /* error message */ // char PID[MAX_LENGTH_PID+1]; /* use HDR.Patient.Id instead */ // char* RID; /* recording identification */ // uint32_t spb; /* total samples per block */ // uint32_t bpb; /* total bytes per block */ // uint32_t bpb8; /* total bits per block */ uint8_t* Header; // uint8_t* rawEventData; // uint8_t* rawdata; /* raw data block */ // char flag_collapsed_rawdata; /*0 if rawdata contain obsolete channels, too. */ // nrec_t first; /* first block loaded in buffer - this is equivalent to hdr->FILE.POS */ // nrec_t length; /* number of block(s) loaded in buffer */ uint8_t* auxBUF; /* auxillary buffer - used for storing EVENT.CodeDesc, MIT FMT infor */ char* bci2000; // uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ enum B4C_ERROR B4C_ERRNUM; /* error code */ // char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ } AS; void *aECG; } HDRTYPE; HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); void destructHDR(HDRTYPE* hdr); HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr); int sclose(HDRTYPE* hdr); size_t sread(biosig_data_type* data, size_t start, size_t length, HDRTYPE* hdr); size_t swrite(const biosig_data_type *data, size_t nelem, HDRTYPE* hdr); int seof(HDRTYPE* hdr); void srewind(HDRTYPE* hdr); int sseek(HDRTYPE* hdr, long int offset, int whence); long int stell(HDRTYPE* hdr); int serror2(HDRTYPE* hdr); int hdr2ascii(HDRTYPE* hdr, FILE *fid, int verbosity); int RerefCHANNEL(HDRTYPE *hdr, void *ReRef, char rrtype); const char* GetFileTypeString(enum FileFormat FMT); uint16_t PhysDimCode(char* PhysDim0); char* PhysDim3(uint16_t PhysDimCode); /* HDRTYPE* sopen(char *filename); %{ HDRTYPE* sopen(char *filename) { HDRTYPE *hdr = constructHDR(0,0); hdr = sopen(filename, "r", hdr); return hdr; } %} int sclose(HDRTYPE *hdr); %{ int sclose(HDRTYPE *hdr) { sclose(hdr); destructHDR(hdr); return 0; } %} */ void serror(); %{ void _serror() { fprintf(stderr,"Use of SERROR is deprecated - use serror2(HDR) instead"); serror(); } %} void hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig-2.3.3/biosig4c++/t220/0000775000175000017500000000000014105434233015476 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/t220/crc4scp.c0000664000175000017500000000667414105434233017220 0ustar schloeglschloegl/* --------------------------------------------------------------------------- Copyright (C) 2005-2006 Franco Chiarugi Developed at the Foundation for Research and Technology - Hellas, Heraklion, Crete Copyright (C) 2009 Alois Schloegl 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ --------------------------------------------------------------------------- */ #if defined(_MSC_VER) && (_MSC_VER < 1600) typedef unsigned __int64 uint64_t; typedef __int64 int64_t; typedef unsigned __int32 uint32_t; typedef __int32 int32_t; typedef unsigned __int16 uint16_t; typedef __int16 int16_t; typedef unsigned __int8 uint8_t; typedef __int8 int8_t; #else #include #endif #ifdef __cplusplus extern "C" { #endif /******************************************************************** * CRCEvaluate * * * * Parameters: datablock is the buffer on which to evaluate the CRC. * * datalength is the length of the whole buffer * * * * Description: Evaluate the SCP-ECG CRC on a data block * * (all file or a section) * * * ********************************************************************/ uint16_t CRCEvaluate(uint8_t* datablock, uint32_t datalength) { uint32_t i; uint16_t crc_tot; uint8_t crchi, crclo; uint8_t a, b; uint8_t tmp1, tmp2; crchi = 0xFF; crclo = 0xFF; for (i = 0; i < datalength; i++) { a = datablock[i]; a ^= crchi; crchi = a; a >>= 4; a &= 0x0F; a ^= crchi; crchi = crclo; crclo = a; tmp1 = ((a & 0x0F) << 4) & 0xF0; tmp2 = ((a & 0xF0) >> 4) & 0x0F; a = tmp1 | tmp2; b = a; tmp1 = ((a & 0x7F) << 1) & 0xFE; tmp2 = ((a & 0x80) >> 7) & 0x01; a = tmp1 | tmp2; a &= 0x1F; crchi ^= a; a = b & 0xF0; crchi ^= a; tmp1 = ((b & 0x7F) << 1) & 0xFE; tmp2 = ((b & 0x80) >> 7) & 0x01; b = tmp1 | tmp2; b &= 0xE0; crclo ^= b; } crc_tot = ((0x00FF & (uint16_t) crchi) << 8) & 0xFF00; crc_tot |= (0x00FF & (uint16_t) crclo); return (crc_tot); } /******************************************************************** * CRCCheck * * * * Parameters: datablock is the buffer on which to verify the CRC. * * It starts with the two CRC-CCITT bytes. * * datalength is the length of the whole buffer * * (including the two CRC bytes) * * * * Description: Check the SCP-ECG CRC on a data block * * (all file or a section) * * * ********************************************************************/ int16_t CRCCheck(uint8_t* datablock, uint32_t datalength) { uint16_t crc; crc = 0; if (datalength <= 2) return (-1); // Evaluate CRC crc = CRCEvaluate((uint8_t*) (datablock + 2), (uint32_t) (datalength - 2)); if (((uint8_t) ((crc & 0xFF00) >> 8) != (uint8_t) datablock[1]) || ((uint8_t) (crc & 0x00FF) != (uint8_t) datablock[0])) return (0); else return (1); } #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/t220/sopen_scp_write.c0000664000175000017500000006721114105434233021054 0ustar schloeglschloegl/* Copyright (C) 2005-2018 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ #include #include #include #include #include "../biosig-dev.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #ifdef __cplusplus extern "C" { #endif int sopen_SCP_write(HDRTYPE* hdr) { /* This function is an auxillary function and is only called by the function SOPEN in "biosig.c" Input: HDRTYPE *hdr // defines the HDR structure according to "biosig.h" hdr->VERSION specifies the target version */ uint8_t* ptr; // pointer to memory mapping of the file layout uint8_t* PtrCurSect; // point to current section int curSect; uint32_t len; uint16_t crc; uint32_t i; uint32_t sectionStart; struct tm* T0_tm; double AVM, avm; uint16_t avm16; struct aecg* aECG; assert(hdr != NULL); assert(hdr->TYPE == SCP_ECG); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) : V%f\n",__FILE__,__LINE__,hdr->VERSION); if ((fabs(hdr->VERSION - 1.3)<0.01) && (fabs(hdr->VERSION-2.0)<0.01) && (fabs(hdr->VERSION-3.0)<0.01)) fprintf(stderr,"Warning SOPEN (SCP-WRITE): Version %f not supported\n",hdr->VERSION); uint8_t versionSection = (hdr->VERSION < 3.0) ? 20 : 29; // (uint8_t)round(hdr->VERSION*10); // implemented version number uint8_t versionProtocol = versionSection; if (hdr->aECG==NULL) { fprintf(stderr,"Warning SOPEN_SCP_WRITE: No aECG info defined\n"); hdr->aECG = malloc(sizeof(struct aecg)); aECG = (struct aecg*)hdr->aECG; aECG->diastolicBloodPressure=0.0; aECG->systolicBloodPressure=0.0; aECG->MedicationDrugs="/0"; aECG->ReferringPhysician="/0"; aECG->LatestConfirmingPhysician="/0"; aECG->Diagnosis="/0"; aECG->EmergencyLevel=0; #if (BIOSIG_VERSION < 10500) aECG->Section8.NumberOfStatements = 0; aECG->Section8.Statements = NULL; aECG->Section11.NumberOfStatements = 0; aECG->Section11.Statements = NULL; #endif } else aECG = (struct aecg*)hdr->aECG; //fprintf(stdout,"SCP-Write: IIb %s\n",hdr->aECG->ReferringPhysician); /* predefined values */ aECG->Section1.Tag14.INST_NUMBER = 0; // tag 14, byte 1-2 aECG->Section1.Tag14.DEPT_NUMBER = 0; // tag 14, byte 3-4 aECG->Section1.Tag14.DEVICE_ID = 0; // tag 14, byte 5-6 aECG->Section1.Tag14.DeviceType = 0; // tag 14, byte 7: 0: Cart, 1: System (or Host) aECG->Section1.Tag14.MANUF_CODE = 255; // tag 14, byte 8 (MANUF_CODE has to be 255) aECG->Section1.Tag14.MOD_DESC = "Cart1"; // tag 14, byte 9 (MOD_DESC has to be "Cart1") aECG->Section1.Tag14.VERSION = versionSection; // tag 14, byte 15 (VERSION * 10) aECG->Section1.Tag14.PROT_COMP_LEVEL = 0xA0; // tag 14, byte 16 (PROT_COMP_LEVEL has to be 0xA0 => level II) // tag 14, byte 17 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code, 0x37: UTF-8) aECG->Section1.Tag14.LANG_SUPP_CODE = (versionSection < 25) ? 0x00 : 0x37; aECG->Section1.Tag14.ECG_CAP_DEV = 0xD0; // tag 14, byte 18 (ECG_CAP_DEV has to be 0xD0 => Acquire, (No Analysis), Print and Store) aECG->Section1.Tag14.MAINS_FREQ = 0; // tag 14, byte 19 (MAINS_FREQ has to be 0: unspecified, 1: 50 Hz, 2: 60Hz) aECG->Section1.Tag14.ANAL_PROG_REV_NUM = ""; aECG->Section1.Tag14.SERIAL_NUMBER_ACQ_DEV = ""; aECG->Section1.Tag14.ACQ_DEV_SYS_SW_ID = ""; aECG->Section1.Tag14.ACQ_DEV_SCP_SW = "OpenECG XML-SCP 1.00"; // tag 14, byte 38 (SCP_IMPL_SW has to be "OpenECG XML-SCP 1.00") aECG->Section1.Tag14.ACQ_DEV_MANUF = "Manufacturer"; // tag 14, byte 38 (ACQ_DEV_MANUF has to be "Manufacturer") aECG->Section5.Length = 0; aECG->Section6.Length = 0; /* */ aECG->FLAG.HUFFMAN = 0; aECG->FLAG.REF_BEAT= 0; aECG->FLAG.DIFF = 0; aECG->FLAG.BIMODAL = 0; /* check channels: disable channels that do not have a known ECG LeadId disable channels with physical units other than Voltage. The number of channels for conversion is stored in NS. */ typeof(hdr->NS) NS = 0, k; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE *CH=hdr->CHANNEL+k; if ( CH->LeadIdCode > 255) CH->OnOff = 0; if ( (CH->PhysDimCode & 0xffe0) != PhysDimCode("V")) CH->OnOff = 0; if (CH->OnOff != 1) continue; NS++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) : v%f VERSION=%i\n",__FILE__,__LINE__, hdr->VERSION, versionSection); ptr = (uint8_t*)hdr->AS.Header; int NSections = (versionSection < 25) ? 12 : 19; // initialize section 0 sectionStart = 6+16+NSections*10; ptr = (uint8_t*)realloc(ptr,sectionStart); memset(ptr,0,sectionStart); uint32_t curSectLen; // current section length for (curSect=NSections-1; curSect>=0; curSect--) { curSectLen = 0; // current section length //ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); // if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) : Section %i/%i %i %p\n",__FILE__,__LINE__,curSect,NSections,sectionStart,ptr); if (curSect==0) // SECTION 0 { hdr->HeadLen = sectionStart; // length of all other blocks together ptr = (uint8_t*)realloc(ptr,hdr->HeadLen); // total file length curSectLen = 16; // current section length sectionStart = 6; curSectLen += NSections*10; } else if (curSect==1) // SECTION 1 { ptr = (uint8_t*)realloc(ptr,sectionStart+10000); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length char *nextPartOfPatientName=hdr->Patient.Name; if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 0 \n"); // Tag 0 (max len = 64) if (!hdr->FLAG.ANONYMOUS && (nextPartOfPatientName != NULL) && strlen(nextPartOfPatientName)) { *(ptr+sectionStart+curSectLen) = 0; // tag len = strcspn(nextPartOfPatientName, "\x1f"); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,nextPartOfPatientName,len); // field nextPartOfPatientName += len+1; curSectLen += len+3; } if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 1 \n"); // Tag 1 (max len = 64) Firstname if (!hdr->FLAG.ANONYMOUS && (nextPartOfPatientName != NULL) && strlen(nextPartOfPatientName)) { *(ptr+sectionStart+curSectLen) = 1; // tag len = strcspn(nextPartOfPatientName, "\x1f"); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,nextPartOfPatientName,len); // field nextPartOfPatientName += len+1; curSectLen += len+3; } // Tag 2 (max len = 64) Patient ID if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 2 \n"); // if (hdr->Patient.Id != NULL) { if (strlen(hdr->Patient.Id)>0) { *(ptr+sectionStart+curSectLen) = 2; // tag len = strlen(hdr->Patient.Id) + 1; leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,hdr->Patient.Id,len); // field curSectLen += len+3; } // Tag 3 (max len = 64) Second Last Name if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 3 \n"); if (!hdr->FLAG.ANONYMOUS && (nextPartOfPatientName != NULL) && strlen(nextPartOfPatientName)) { *(ptr+sectionStart+curSectLen) = 3; // tag len = strcspn(nextPartOfPatientName, "\x1f"); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,nextPartOfPatientName,len); // field nextPartOfPatientName += len+1; curSectLen += len+3; } // Tag 5 (len = 4) if ((hdr->Patient.Birthday) > 0) { T0_tm = gdf_time2tm_time(hdr->Patient.Birthday); *(ptr+sectionStart+curSectLen) = 5; // tag leu16a(4, ptr+sectionStart+curSectLen+1); // length leu16a(T0_tm->tm_year+1900, ptr+sectionStart+curSectLen+3);// year *(ptr+sectionStart+curSectLen+5) = (uint8_t)(T0_tm->tm_mon + 1); // month *(ptr+sectionStart+curSectLen+6) = (uint8_t)(T0_tm->tm_mday); // day curSectLen += 7; } // Tag 6 (len = 3) Height if (hdr->Patient.Height>0.0) { *(ptr+sectionStart+curSectLen) = 6; // tag leu16a(3, ptr+sectionStart+curSectLen+1); // length leu16a(hdr->Patient.Height, ptr+sectionStart+curSectLen+3); // value *(ptr+sectionStart+curSectLen+5) = 1; // cm curSectLen += 6; } // Tag 7 (len = 3) Weight if (hdr->Patient.Weight>0.0) { *(ptr+sectionStart+curSectLen) = 7; // tag leu16a(3, ptr+sectionStart+curSectLen+1); // length leu16a(hdr->Patient.Weight, ptr+sectionStart+curSectLen+3); // value *(ptr+sectionStart+curSectLen+5) = 1; // kg curSectLen += 6; } // Tag 8 (len = 1) if (hdr->Patient.Sex != 0) { *(ptr+sectionStart+curSectLen) = 8; // tag leu16a(1, ptr+sectionStart+curSectLen+1); // length *(ptr+sectionStart+curSectLen+3) = hdr->Patient.Sex; // value curSectLen += 4; } // Tag 11 (len = 2) if (aECG->systolicBloodPressure>0.0) { *(ptr+sectionStart+curSectLen) = 11; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length leu16a((uint16_t)aECG->systolicBloodPressure, ptr+sectionStart+curSectLen+3); // value curSectLen += 5; }; // Tag 12 (len = 2) if (aECG->diastolicBloodPressure>0.0) { *(ptr+sectionStart+curSectLen) = 12; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length leu16a((uint16_t)aECG->diastolicBloodPressure, ptr+sectionStart+curSectLen+3); // value curSectLen += 5; }; // Tag 13 (max len = 80) aECG->Diagnosis=""; len = strlen(aECG->Diagnosis); if (len>0) { *(ptr+sectionStart+curSectLen) = 13; // tag len = min(64,len+1); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)(ptr+sectionStart+curSectLen+3),aECG->Diagnosis,len); curSectLen += 3+len; }; // Tag 14 (max len = 2 + 2 + 2 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 16 + 1 + 25 + 25 + 25 + 25 + 25) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 14 \n"); // Total = 161 (max value) *(ptr+sectionStart+curSectLen) = 14; // tag //len = 41; // minimum length // leu16a(len, ptr+sectionStart+curSectLen+1); // length memset(ptr+sectionStart+curSectLen+3,0,41); // dummy value curSectLen += 3; leu16a(aECG->Section1.Tag14.INST_NUMBER, ptr+sectionStart+curSectLen); leu16a(aECG->Section1.Tag14.DEPT_NUMBER, ptr+sectionStart+curSectLen+2); leu16a(aECG->Section1.Tag14.DEVICE_ID, ptr+sectionStart+curSectLen+4); *(ptr+sectionStart+curSectLen+ 6) = aECG->Section1.Tag14.DeviceType; *(ptr+sectionStart+curSectLen+ 7) = aECG->Section1.Tag14.MANUF_CODE; // tag 14, byte 7 (MANUF_CODE has to be 255) strncpy((char*)(ptr+sectionStart+curSectLen+8), aECG->Section1.Tag14.MOD_DESC, 6); // tag 14, byte 7 (MOD_DESC has to be "Cart1") *(ptr+sectionStart+curSectLen+14) = versionSection; // tag 14, byte 14 (VERSION has to be 20) *(ptr+sectionStart+curSectLen+14) = aECG->Section1.Tag14.VERSION; *(ptr+sectionStart+curSectLen+15) = aECG->Section1.Tag14.PROT_COMP_LEVEL; // tag 14, byte 15 (PROT_COMP_LEVEL has to be 0xA0 => level II) *(ptr+sectionStart+curSectLen+16) = aECG->Section1.Tag14.LANG_SUPP_CODE; // tag 14, byte 16 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code) *(ptr+sectionStart+curSectLen+17) = aECG->Section1.Tag14.ECG_CAP_DEV; // tag 14, byte 17 (ECG_CAP_DEV has to be 0xD0 => Acquire, (No Analysis), Print and Store) *(ptr+sectionStart+curSectLen+18) = aECG->Section1.Tag14.MAINS_FREQ; // tag 14, byte 18 (MAINS_FREQ has to be 0: unspecified, 1: 50 Hz, 2: 60Hz) *(ptr+sectionStart+curSectLen+35) = strlen(aECG->Section1.Tag14.ANAL_PROG_REV_NUM)+1; // tag 14, byte 34 => length of ANAL_PROG_REV_NUM + 1 = 1 uint16_t len1 = 36; char* tmp; tmp = aECG->Section1.Tag14.ANAL_PROG_REV_NUM; len = min(25, strlen(tmp) + 1); strncpy((char*)(ptr+sectionStart+curSectLen+len1), tmp, len); len1 += len; tmp = aECG->Section1.Tag14.SERIAL_NUMBER_ACQ_DEV; len = min(25, strlen(tmp) + 1); strncpy((char*)(ptr+sectionStart+curSectLen+len1), tmp, len); len1 += len; tmp = aECG->Section1.Tag14.ACQ_DEV_SYS_SW_ID; len = min(25, strlen(tmp) + 1); strncpy((char*)(ptr+sectionStart+curSectLen+len1), tmp, len); len1 += len; tmp = aECG->Section1.Tag14.ACQ_DEV_SCP_SW; len = min(25, strlen(tmp) + 1); strncpy((char*)(ptr+sectionStart+curSectLen+len1), tmp, len); len1 += len; tmp = aECG->Section1.Tag14.ACQ_DEV_MANUF; len = min(25, strlen(tmp) + 1); strncpy((char*)(ptr+sectionStart+curSectLen+len1), tmp, len); len1 += len; leu16a(len1, ptr+sectionStart+curSectLen+1-3); // length curSectLen += len1; // Tag 16 (max len = 80) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 16 \n"); len = hdr->ID.Hospital ? strlen(hdr->ID.Hospital) : 0; if (len > 0) { *(ptr+sectionStart+curSectLen) = 16; // tag len = min(64,len+1); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)(ptr+sectionStart+curSectLen+3),hdr->ID.Hospital,len); curSectLen += 3+len; } // Tag 20 (max len = 64 ) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 20 \n"); len = aECG->ReferringPhysician ? strlen(aECG->ReferringPhysician) : 0; if (len > 0) { *(ptr+sectionStart+curSectLen) = 20; // tag len = min(64,len+1); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)(ptr+sectionStart+curSectLen+3),aECG->ReferringPhysician,len); curSectLen += 3+len; }; // Tag 21 (max len = 64 ) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 21 \n"); len = aECG->MedicationDrugs ? strlen(aECG->MedicationDrugs) : 0; if (len>0) { *(ptr+sectionStart+curSectLen) = 21; // tag len = min(64,len+1); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)(ptr+sectionStart+curSectLen+3),aECG->MedicationDrugs,len); curSectLen += 3+len; }; // Tag 22 (max len = 40 ) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 22 \n"); len = hdr->ID.Technician ? strlen(hdr->ID.Technician) : 0; if (len > 0) { *(ptr+sectionStart+curSectLen) = 22; // tag len = min(64,len+1); leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)(ptr+sectionStart+curSectLen+3),hdr->ID.Technician,len); curSectLen += 3+len; } // Tag 24 ( len = 1 ) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 24 \n"); *(ptr+sectionStart+curSectLen) = 24; // tag leu16a(1, ptr+sectionStart+curSectLen+1); // length *(ptr+sectionStart+curSectLen+3) = aECG->EmergencyLevel; curSectLen += 4; // Tag 25 (len = 4) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 25 \n"); gdf_time T1 = hdr->T0; #ifndef __APPLE__ T1 += (int32_t)ldexp(timezone/86400.0,32); #endif T0_tm = gdf_time2tm_time(T1); *(ptr+sectionStart+curSectLen) = 25; // tag leu16a(4, ptr+sectionStart+curSectLen+1); // length leu16a(T0_tm->tm_year+1900, ptr+sectionStart+curSectLen+3);// year *(ptr+sectionStart+curSectLen+5) = (uint8_t)(T0_tm->tm_mon + 1);// month *(ptr+sectionStart+curSectLen+6) = (uint8_t)T0_tm->tm_mday; // day curSectLen += 7; // Tag 26 (len = 3) *(ptr+sectionStart+curSectLen) = 26; // tag leu16a(3, ptr+sectionStart+curSectLen+1); // length *(ptr+sectionStart+curSectLen+3) = (uint8_t)T0_tm->tm_hour; // hour *(ptr+sectionStart+curSectLen+4) = (uint8_t)T0_tm->tm_min; // minute *(ptr+sectionStart+curSectLen+5) = (uint8_t)T0_tm->tm_sec; // second curSectLen += 6; if (NS>0) { CHANNEL_TYPE *CH = hdr->CHANNEL; while (CH->OnOff != 1) CH++; // Tag 27 (len = 3) highpass filter *(ptr+sectionStart+curSectLen) = 27; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length leu16a((uint16_t)CH->HighPass, ptr+sectionStart+curSectLen+3); // hour curSectLen += 5; // Tag 28 (len = 3) lowpass filter *(ptr+sectionStart+curSectLen) = 28; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length leu16a((uint16_t)CH->LowPass, ptr+sectionStart+curSectLen+3); // hour curSectLen += 5; // Tag 29 (len = 1) filter bitmap uint8_t bitmap = 0; if (fabs(CH->LowPass-60.0)<0.01) bitmap = 1; else if (fabs(CH->LowPass-50.0)<0.01) bitmap = 2; else bitmap = 0; *(ptr+sectionStart+curSectLen) = 29; // tag leu16a(1, ptr+sectionStart+curSectLen+1); // length *(ptr+sectionStart+curSectLen+3) = bitmap; curSectLen += 4; } // Tag 32 (len = 5) if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 32 \n"); *(ptr+sectionStart+curSectLen) = 32; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length if (hdr->Patient.Impairment.Heart==1) { *(ptr+sectionStart+curSectLen+3) = 0; *(ptr+sectionStart+curSectLen+4) = 1; // Apparently healthy curSectLen += 5; } else if (hdr->Patient.Impairment.Heart==3) { *(ptr+sectionStart+curSectLen+3) = 0; *(ptr+sectionStart+curSectLen+4) = 42; // Implanted cardiac pacemaker curSectLen += 5; } // Tag 34 (len = 5) *(ptr+sectionStart+curSectLen) = 34; // tag leu16a(5, ptr+sectionStart+curSectLen+1); // length lei16a(hdr->tzmin, ptr+sectionStart+curSectLen+3); lei16a(0, ptr+sectionStart+curSectLen+5); curSectLen += 8; // Tag 255 (len = 0) *(ptr+sectionStart+curSectLen) = 255; // tag leu16a(0, ptr+sectionStart+curSectLen+1); // length curSectLen += 3; // Evaluate the size and correct it if odd if (curSectLen & 1) { *(ptr+sectionStart+curSectLen++) = 0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"End-of-Section %i %p\n",curSect,ptr); } else if (curSect==2) // SECTION 2 { } else if (curSect==3) // SECTION 3 { ptr = (uint8_t*)realloc(ptr,sectionStart+16+2+9*NS+1); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length // Number of leads enclosed *(ptr+sectionStart+curSectLen++) = NS; // ### Situations with reference beat subtraction are not supported // Situations with not all the leads simultaneously recorded are not supported // Situations number of leads simultaneouly recorded != total number of leads are not supported // We assume all the leads are recorded simultaneously *(ptr+sectionStart+curSectLen++) = (NS<<3) | 0x04; for (i = 0; i < hdr->NS; i++) { CHANNEL_TYPE *CH=hdr->CHANNEL+i; if (CH->OnOff != 1) continue; leu32a(1L, ptr+sectionStart+curSectLen); leu32a(hdr->data.size[0], ptr+sectionStart+curSectLen+4); *(ptr+sectionStart+curSectLen+8) = (uint8_t)CH->LeadIdCode; curSectLen += 9; } // Evaluate the size and correct it if odd if ((curSectLen % 2) != 0) { *(ptr+sectionStart+curSectLen++) = 0; } memset(ptr+sectionStart+10,0,6); // reserved } else if (curSect==4) // SECTION 4 { } else if (curSect==5) // SECTION 5 { curSectLen = 0; // current section length aECG->Section5.StartPtr = sectionStart; aECG->Section5.Length = curSectLen; } else if (curSect==6) // SECTION 6 { if (versionSection < 25) // SECTION 6 { uint16_t GDFTYP = 3; size_t SZ = GDFTYP_BITS[GDFTYP]>>3; typeof(hdr->NS) i=0; for (i = 0; i < hdr->NS; i++) { CHANNEL_TYPE *hc=hdr->CHANNEL+i; if (hc->OnOff != 1) continue; hc->GDFTYP = GDFTYP; } ptr = (uint8_t*)realloc(ptr,sectionStart+16+6+2*NS+SZ*(hdr->data.size[0]*hdr->data.size[1])); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length // Create all the fields char flagfirst = 1; for (i = 0; i < hdr->NS; i++) { CHANNEL_TYPE *CH=hdr->CHANNEL+i; if (CH->OnOff != 1) continue; // check for physical dimension and adjust scaling factor to "nV" avm = CH->Cal * 1e9 * PhysDimScale(CH->PhysDimCode); if (flagfirst) { // Amplitude Value Multiplier (AVM) AVM = avm; flagfirst=0; continue; } // check whether all channels have the same scaling factor if (fabs((AVM - avm)/AVM) > 1e-14) fprintf(stderr,"Warning SOPEN (SCP-WRITE): scaling factors differ between channel #1 and #%i. Scaling factor of 1st channel is used.\n",i+1); }; avm16 = lrint(AVM); leu16a(avm16, ptr+sectionStart+curSectLen); avm = leu16p(ptr+sectionStart+curSectLen); curSectLen += 2; if (fabs((AVM - avm)/AVM)>1e-14) fprintf(stderr,"Warning SOPEN (SCP-WRITE): Scaling factor has been truncated (%f instead %f).\n",avm,AVM); // Sample interval AVM = 1e6/hdr->SampleRate; avm16 = lrint(AVM); leu16a(avm16, ptr+sectionStart+curSectLen); avm = leu16p(ptr+sectionStart+curSectLen); curSectLen += 2; if (fabs((AVM - avm)/AVM)>1e-14) fprintf(stderr,"Warning SOPEN (SCP-WRITE): Sampling interval has been truncated (%f instead %f us).\n",avm,AVM); // Diff used *(ptr+sectionStart+curSectLen++) = 0; // Bimodal/Non-bimodal *(ptr+sectionStart+curSectLen++) = 0; /* DATA COMPRESSION currently, no compression method is supported. In case of data compression, the data compression can happen here. */ // Fill the length block for (i = 0; i < NS; i++) { leu16a((uint16_t)hdr->data.size[0]*2, ptr+sectionStart+curSectLen); avm = leu16p(ptr+sectionStart+curSectLen); AVM = hdr->data.size[0]*2; if (fabs((AVM - avm)/AVM)>1e-14) fprintf(stderr,"Warning SOPEN (SCP-WRITE): Block length truncated (%f instead %f us).\n",avm,AVM); curSectLen += 2; } /* data in channel multiplexed order */ for (i = 0; i < hdr->NS; i++) { hdr->CHANNEL[i].SPR *= hdr->NRec; }; hdr->NRec = 1; // Prepare filling the data block with the ECG samples by SWRITE curSectLen += SZ * (hdr->data.size[hdr->FLAG.ROW_BASED_CHANNELS] * NS); // Evaluate the size and correct it if odd if ((curSectLen % 2) != 0) { fprintf(stderr,"Warning Section 6 has an odd length\n"); *(ptr+sectionStart+curSectLen++) = 0; } memset(ptr+sectionStart+10,0,6); // reserved aECG->Section6.StartPtr = sectionStart; aECG->Section6.Length = curSectLen; } } else if (curSect==7) // SECTION 7 { if (hdr->SCP.Section7 != NULL) { curSectLen = hdr->SCP.Section7Length+16; // current section length ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); PtrCurSect = ptr+sectionStart; memcpy(PtrCurSect+16,hdr->SCP.Section7,hdr->SCP.Section7Length); } } else if (curSect==8) // SECTION 8 { if (hdr->SCP.Section8 != NULL) { curSectLen = hdr->SCP.Section8Length+16; // current section length ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); PtrCurSect = ptr+sectionStart; memcpy(PtrCurSect,hdr->SCP.Section8,hdr->SCP.Section8Length); } } else if (curSect==9) // SECTION 9 { if (hdr->SCP.Section9 != NULL) { curSectLen = hdr->SCP.Section9Length+16; // current section length ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); PtrCurSect = ptr+sectionStart; memcpy(PtrCurSect,hdr->SCP.Section9,hdr->SCP.Section9Length); } } else if (curSect==10) // SECTION 10 { if (hdr->SCP.Section10 != NULL) { curSectLen = hdr->SCP.Section10Length+16; // current section length ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); PtrCurSect = ptr+sectionStart; memcpy(PtrCurSect+16,hdr->SCP.Section10,hdr->SCP.Section10Length); } } else if (curSect==11) // SECTION 11 { if (hdr->SCP.Section11 != NULL) { curSectLen = hdr->SCP.Section11Length+16; // current section length ptr = (uint8_t*)realloc(ptr,sectionStart+curSectLen); PtrCurSect = ptr+sectionStart; memcpy(PtrCurSect+16,hdr->SCP.Section11,hdr->SCP.Section11Length); } } else if (curSect==12) // SECTION 12 { if (versionSection > 25 ) // SECTION 12, SCP version 3 { uint16_t gdftyp= 0; uint8_t bps = 0; //double PhysMax = -1.0/0.0; uint16_t PhysDimBaseCode = 4256; // Volt for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (hc->OnOff == 1) { if (bps < GDFTYP_BITS[gdftyp]) { bps = GDFTYP_BITS[hc->GDFTYP]; gdftyp = hc->GDFTYP; } } } if (NS>255) { NS=255; fprintf(stderr,"Warning SOPEN (SCP-WRITE): Number of channels exceeds 255, limited to 255.\n"); } bps = GDFTYP_BITS[gdftyp]>>3; double DigMax = ldexp(1.0, GDFTYP_BITS[gdftyp]-1)-1; int ns=0; for (k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (hc->OnOff > 0) { if (ns > 255) { hc->OnOff = 0; continue; } ns++; double scale = PhysDimScale(hc->PhysDimCode); hc->GDFTYP = gdftyp; hc->PhysMax = max(fabs(hc->PhysMax),fabs(-hc->PhysMin))*scale*1e9; hc->PhysMin = -hc->PhysMax; hc->Off = 0.0; hc->Cal = ceil(hc->PhysMax / hc->DigMax); // AVM must be integer //hc->DigMax = hc->PhysMax / hc->Cal; hc->DigMin = -hc->DigMax; hc->PhysDimCode = 4276; // nV } } curSectLen = 16 + 70 + NS * (4 + hdr->SPR*hdr->NRec * bps); // current section length without 16 bytes curSectLen+= (curSectLen & 1); ptr = (uint8_t*)realloc(ptr, sectionStart + curSectLen); memset(ptr + sectionStart, 0, 16+70); PtrCurSect = ptr + sectionStart + 16; leu32a((uint32_t)hdr->SampleRate, PtrCurSect); PtrCurSect[4] = (uint8_t)NS; leu32a((uint32_t)(hdr->NRec*hdr->SPR), PtrCurSect + 5); PtrCurSect[9] = (uint8_t)bps; // Recording Date and Time gdf_time T1 = hdr->T0; #ifndef __APPLE__ T1 += (int32_t)ldexp(timezone/86400.0,32); #endif T0_tm = gdf_time2tm_time(T1); leu16a(T0_tm->tm_year+1900, PtrCurSect+10); // year PtrCurSect[12] = (uint8_t)(T0_tm->tm_mon + 1); // month PtrCurSect[13] = (uint8_t)T0_tm->tm_mday; // day PtrCurSect[14] = (uint8_t)T0_tm->tm_hour; // hour PtrCurSect[15] = (uint8_t)T0_tm->tm_min; // minute PtrCurSect[16] = (uint8_t)T0_tm->tm_sec; // second // all other fields are set to zero. filter settings are defined in Section 1, Tags 27-29 /* Leads Definistion block */ PtrCurSect += 70; for (k=0,ns=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; if (hc->OnOff > 0) { PtrCurSect[ns*4] = hc->LeadIdCode; leu16a(hc->Cal, PtrCurSect+1+ns*4); // AVM per lead PtrCurSect[3+ns*4] = 0; ns++; } } /* ECG signals data block */ PtrCurSect += 4*NS; } aECG->Section12.StartPtr = sectionStart; aECG->Section12.Length = curSectLen; } else { } // write to pointer field in Section 0 leu16a(curSect, ptr+curSect*10+6+16); // leu32a(curSectLen, ptr+curSect*10+6+16+2); // length // Section start - must be odd. See EN1064:2005(E) Section 5.2.1 // write to Section ID Header if (curSectLen>0) { // Section 0: startpos in pointer field leu32a(sectionStart+1, ptr+curSect*10+6+16+6); // Section ID header (16 bytes) leu16a(curSect, ptr+sectionStart+2); // Section ID leu32a(curSectLen, ptr+sectionStart+4); // section length->section header ptr[sectionStart+8] = versionSection; // Section Version Number ptr[sectionStart+9] = versionProtocol; // Protocol Version Number if (curSect==0) { memcpy(ptr+16,"SCPECG",6); // defined as in ISO/DIS 11073-91064 Section 5.3.2 } else { memset(ptr+sectionStart+10,0,6); // reserved according to ISO/DIS 11073-91064 Section 5.2.7 } crc = CRCEvaluate(ptr+sectionStart+2,curSectLen-2); // compute CRC leu16a(crc, ptr+sectionStart); } sectionStart += curSectLen; // offset for next section } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN_SCP_WRITE 300\n"); // Prepare filling the data block with the ECG samples by SWRITE if (versionSection < 25) hdr->AS.rawdata = ptr+aECG->Section6.StartPtr+16+6+2*NS; else hdr->AS.rawdata = ptr+aECG->Section12.StartPtr+16+70+4*NS; hdr->AS.Header = ptr; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i,%i %i,%i \n",__func__,__LINE__,(int)aECG->Section6.StartPtr,(int)aECG->Section6.Length,(int)aECG->Section12.StartPtr,(int)aECG->Section12.Length); return(0); } #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/annotatedECG.awk0000664000175000017500000000241314105434233020007 0ustar schloeglschloegl #!/usr/bin/awk -f # # Converts 11073-10102-AnnexB into 11073-10101-AnnexB.i # # Copyright (C) 2013,2014 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ # # BioSig 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 3 # of the License, 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, see . BEGIN { FS = "\t"; print "#if 0\n### This file is autogenerated - Do not modify it !!! ###\n#"; flag = 1; } { if (/^#/) { print $0; } else if (NF==4) { if (flag) { print "#endif\n"; flag = 0; } # hexadecimal or decimal - both are fine printf("\t{ %5i, %9i, \"%s\" }, \n",$2, $3, $4); # printf("\t{ 0x%x, 0x%x, \"%s\" }, \n", $2, $3, $4); } } biosig-2.3.3/biosig4c++/xgethostname.c0000664000175000017500000000577114105434233017673 0ustar schloeglschloegl/* Copyright (c) 2001 Neal H Walfield . Copyright (c) 2012 Alois Schloegl This file is placed into the public domain. Its distribution is unlimited. THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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. */ /* NAME xgethostname - get the host name. SYNOPSIS char *xgethostname (void); DESCRIPTION The xhostname function is intended to replace gethostname(2), a function used to access the host name. The old interface is inflexable given that it assumes the existance of the MAXHOSTNAMELEN macro, which neither POSIX nor the proposed Single Unix Specification version 3 guarantee to be defined. RETURN VALUE On success, a malloced, null terminated (possibly truncated) string containing the host name is returned. On failure, NULL is returned and errno is set. */ #include /* For MAXHOSTNAMELEN */ #include #include #include #ifdef _WIN32 #include #endif char * xgethostname (void) { int size = 0; int addnull = 0; char *buf; int err; #ifdef MAXHOSTNAMELEN size = MAXHOSTNAMELEN; addnull = 1; #else /* MAXHOSTNAMELEN */ #ifdef _SC_HOST_NAME_MAX size = sysconf (_SC_HOST_NAME_MAX); addnull = 1; #endif /* _SC_HOST_NAME_MAX */ if (size <= 0) size = 256; #endif /* MAXHOSTNAMELEN */ buf = malloc (size + addnull); if (! buf) { errno = ENOMEM; return NULL; } #ifdef _WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(1,1), &wsadata); #endif err = gethostname (buf, size); while (err == -1 && errno == ENAMETOOLONG) { free (buf); size *= 2; buf = malloc (size + addnull); if (! buf) { #ifdef _WIN32 WSACleanup(); #endif errno = ENOMEM; return NULL; } err = gethostname (buf, size); } #ifdef _WIN32 WSACleanup(); #endif if (err) { if (buf) free (buf); errno = err; return NULL; } if (addnull) buf[size] = '\0'; return buf; } #ifdef WANT_TO_TEST_XGETHOSTNAME #include #include int main (int argc, char *argv[]) { char *hostname; hostname = xgethostname (); if (! hostname) { perror ("xgethostname"); return 1; } printf ("%s\n", hostname); free (hostname); return 0; } #endif /* WANT_TO_TEST_XGETHOSTNAME */ biosig-2.3.3/biosig4c++/pu.c0000664000175000017500000000620214105434233015577 0ustar schloeglschloegl/* Copyright (C) 2015 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ #include #include #include #include #include "physicalunits.h" const char help[] = "\nphysicalunits is a program to convert physical units from string\n" "\trepresentation into numerical constants, according to\n" "\tISO/IEEE 11073-10101:2004 Vital Signs Units of Measurement\n\n" "Usage:\n\tphysicalunits units\n\tphysicalunits code (decimal or hexadecimal)\n\n" "The output returns the ,,,,\n\n" "Examples:\n physicalunits mV\n" "\tuV 4275 0x10b3 1e-06 V\n\n" " physicalunits 4275\n" "\tuV 4275 0x10b3 1e-06 V\n\n" " physicalunits mV nA 4180 kg dag degree \"kg l-1\" rpm\n" "\tmV 4274 0x10b2 0.001 V\n" "\tnA 4180 0x1054 1e-09 A\n" "\tnA 4180 0x1054 1e-09 A\n" "\tkg 1731 0x6c3 1000 g\n" "\tdag 1729 0x6c1 10 g\n" "\tdegree 736 0x2e0 1 degree\n" "\tkg l-1 2015 0x0803 1000 g l-1\n" "\trpm 6816 0x1aa0 1 rpm\n"; int main(int argc, char **argv) { uint16_t pdc; const char *in; double scale; const char *out1; const char *out2; char *E; if (argc<2) fprintf(stdout,"%s", help); for (int k=1; k This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ #include #include #include #include #include #include #include #include #include "biosig.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #ifdef __cplusplus extern "C" { #endif int savelink(const char* filename); #ifdef __cplusplus } #endif #ifdef WITH_PDP void sopen_pdp_read(HDRTYPE *hdr); #endif extern const uint16_t GDFTYP_BITS[]; int compare_uint16 (const void* a, const void* b) { return ( (int)*(uint16_t*)a - (int)*(uint16_t*)b ); } int main(int argc, char **argv) { HDRTYPE *hdr; size_t count, k1, ne=0; char *source, *dest, *tmpstr; biosig_options_type biosig_options; biosig_options.free_text_event_limiter = ""; // default is no delimiter enum FileFormat SOURCE_TYPE; // type of file format struct { enum FileFormat TYPE; float VERSION; } TARGET; TARGET.TYPE=GDF; TARGET.VERSION=-1.0; FILE* fid=stdout; int COMPRESSION_LEVEL=0; int status; uint16_t k; uint16_t chansel = 0; int TARGETSEGMENT=1; // select segment in multi-segment file format EEG1100 (Nihon Kohden) int VERBOSE = 0; char FLAG_ANON = 1; char FLAG_CSV = 0; char FLAG_JSON = 0; char FLAG_DYGRAPH = 0; char *argsweep = NULL; double t1=0.0, t2=1.0/0.0; uint16_t *CHANLIST = NULL; uint16_t LenChanList = 0; // number of entries in CHANLIST #ifdef CHOLMOD_H char *rrFile = NULL; int refarg = 0; #endif source = NULL; dest = NULL; for (k=1; k/ID e.g. bscs://129.27.3.99/9aebcc5b4eef1024 \n"); fprintf(stderr," DEST is the destination file \n"); fprintf(stderr,"\n Supported OPTIONS are:\n"); fprintf(stderr," -v, --version\n\tprints version information\n"); fprintf(stderr," -h, --help \n\tprints this information\n"); #ifdef CHOLMOD_H fprintf(stderr," -r, --ref=MM \n\trereference data with matrix file MM. \n\tMM must be a 'MatrixMarket matrix coordinate real general' file.\n"); #endif fprintf(stderr, " -a, --anon=yes (default)\n" "\tanonymized data processing - personalize data (name, and birthday) is not processed but ignored.\n" "\tThe patient can be still identified with the unique patient identifier (and an external database).\n" "\tThis is for many cases sufficient (e.g. for research etc.). This mode can be turn off with\n" " -n, --anon=no\n" "\tThis will process personal information like name and birthday. One might want to use this mode\n" "\twhen converting personalized patient data and no unique patient identifier is available.\n" "\tIt's recommended to pseudonize the data, or to use the patient identifier instead of patient name and birthday.\n" ); fprintf(stderr, " -c (default: 0)\n" "\tThis flag is in preparation and not working yet.\n" "\t is a comma-separated list of channel numbers.\n" "\tIf contains any number smaller than 1 or larger than the number \n" "\t of available channels, all channels are loaded.\n" ); fprintf(stderr," --free-text-event-limiter=\";\"\n\tfree text of events limited to first occurrence of \";\" (only EDF+/BDF+ format)\n"); fprintf(stderr," -s=#\tselect target segment # (in the multisegment file format EEG1100)\n"); fprintf(stderr," -SWEEP=ne,ng,ns\n\tsweep selection of HEKA/PM files\n\tne,ng, and ns select the number of experiment, the number of group, and the sweep number, resp.\n"); fprintf(stderr," -VERBOSE=#, verbosity level #\n\t0=silent [default], 9=debugging\n"); fprintf(stderr," --chan=CHAN\n\tselect channel CHAN (0: all channels, 1: first channel, etc.)\n"); fprintf(stderr,"\n\n"); return(0); } else if (!strncmp(argv[k],"-VERBOSE",2)) { VERBOSE = argv[k][strlen(argv[k])-1]-48; #ifndef NDEBUG // then VERBOSE_LEVEL is not a constant but a variable VERBOSE_LEVEL = VERBOSE; #endif } else if (!strncasecmp(argv[k],"-SWEEP=",7)) argsweep = argv[k]+6; else if (!strcasecmp(argv[k],"-a") || !strcasecmp(argv[k],"--anon") ) FLAG_ANON = 1; else if (!strcasecmp(argv[k],"-n") || !strcasecmp(argv[k],"--anon=no") ) FLAG_ANON = 0; else if (!strcasecmp(argv[k],"-c") ) { char *CS = strdup(argv[++k]); char *CS0 = CS; CHANLIST = realloc(CHANLIST,sizeof(uint16_t)*strlen(CS)); LenChanList = 0; while (isdigit(*CS)) { CHANLIST[LenChanList++] = strtol(CS,&CS,10); if (*CS==0) break; if (*CS != ',') { LenChanList = 0; break; } CS++; } CHANLIST[LenChanList]=0xffff; free(CS0); qsort(CHANLIST, LenChanList, sizeof(uint16_t), compare_uint16); } else if (!strncmp(argv[k],"--free-text-event-limiter=",26)) biosig_options.free_text_event_limiter = strstr(argv[k],"=") + 1; #ifdef CHOLMOD_H else if ( !strncmp(argv[k],"-r=",3) || !strncmp(argv[k],"--ref=",6) ) { // re-referencing matrix refarg = k; } #endif else if (!strncmp(argv[k],"-s=",3)) { TARGETSEGMENT = atoi(argv[k]+3); } else if (argv[k][0]=='[' && argv[k][strlen(argv[k])-1]==']' && (tmpstr=strchr(argv[k],',')) ) { t1 = strtod(argv[k]+1,NULL); t2 = strtod(tmpstr+1,NULL); if (VERBOSE_LEVEL>7) fprintf(stderr,"[%f,%f]\n",t1,t2); } else { break; } if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i): biosig2gdf: arg%i = <%s>\n",__FILE__,__LINE__, k, argv[k]); } // end of for (k=1; k7) fprintf(stderr,"%s (line %i): BIOSIG2GDF %s started \n",__FILE__,__LINE__, source); tzset(); hdr = constructHDR(0,0); // hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = 1; hdr->FLAG.TARGETSEGMENT = TARGETSEGMENT; hdr->FLAG.ANONYMOUS = FLAG_ANON; if (argsweep) { k = 0; do { hdr->AS.SegSel[k++] = strtod(argsweep+1, &argsweep); } while (argsweep[0]==',' && (k < 5) ); } hdr = sopen_extended(source, "r", hdr, &biosig_options); #ifdef WITH_PDP if (hdr->AS.B4C_ERRNUM) { biosigERROR(hdr, 0, NULL); // reset error sopen_pdp_read(hdr); } #endif // HEKA2ITX hack if (TARGET.TYPE==ITX) { if (hdr->TYPE==HEKA) { // hack: HEKA->ITX conversion is already done in SOPEN dest = NULL; } else { fprintf(stderr,"error: only HEKA->ITX is supported - source file is not HEKA file"); biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "error: only HEKA->ITX is supported - source file is not HEKA file"); } } if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } t1 *= hdr->SampleRate / hdr->SPR; t2 *= hdr->SampleRate / hdr->SPR; if (isnan(t1)) t1 = 0.0; if (t2+t1 > hdr->NRec) t2 = hdr->NRec - t1; if ( ( t1 - floor (t1) ) || ( t2 - floor(t2) ) ) { fprintf(stderr,"ERROR BIOSIG2GDF: cutting from parts of blocks not supported; t1 (%f) and t2 (%f) must be a multiple of block duration %f\n", t1,t2,hdr->SPR / hdr->SampleRate); biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "blocks must not be split"); } if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } sort_eventtable(hdr); /******************************************* Channel selection *******************************************/ uint16_t NS2=0; // number of channels (w/o hidden channels) for (k=0; k < hdr->NS; k++) { NS2 += (hdr->CHANNEL[k].OnOff > 0); } for (k = 0; k < LenChanList; k++) { // check whether all arguments specify a valid channel number if ((CHANLIST[k] < 1) || (NS2 < CHANLIST[k])) { LenChanList = 0; // in case of an invalid channel, all channels are selected break; } } if (LenChanList > 0) { fprintf(stderr, "argument -c is currently not supported, the argument is ignored "); LenChanList=0; } if (LenChanList > 0) { // all entries in argument -c specify valid channels int chan=0; int k1 = 0; for (k=0; kNS; k++) if (hdr->CHANNEL[k].OnOff > 0) { chan++; // count while (CHANLIST[k1] < chan) k1++; // skip double entries in CHANLIST if (CHANLIST[k1]==chan) { hdr->CHANNEL[k].OnOff = 1; k1++; fprintf(stderr,"-- %d %d %d \n",k,k1,chan); } else if (CHANLIST[k1] > chan) hdr->CHANNEL[k].OnOff = 0; } } for (k=0; kNS; k++) { if ( (hdr->CHANNEL[k].OnOff > 0) && hdr->CHANNEL[k].SPR ) { if ((hdr->SPR/hdr->CHANNEL[k].SPR)*hdr->CHANNEL[k].SPR != hdr->SPR) fprintf(stderr,"Warning: channel %i might be decimated!\n",k+1); }; } if (CHANLIST) {free(CHANLIST); CHANLIST=NULL;} hdr->FLAG.OVERFLOWDETECTION = 0; hdr->FLAG.UCAL = 1; hdr->FLAG.ROW_BASED_CHANNELS = 1; if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i): SREAD [%f,%f].\n",__FILE__,__LINE__,t1,t2); if (hdr->NRec <= 0) { // in case number of samples is not known count = sread(NULL, t1, (size_t)-1, hdr); t2 = count; } else { if (t2+t1 > hdr->NRec) t2 = hdr->NRec - t1; count = sread(NULL, t1, t2, hdr); } biosig_data_type* data = hdr->data.block; if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); }; if (hdr->FILE.OPEN) { sclose(hdr); free(hdr->AS.Header); hdr->AS.Header = NULL; if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i): file closed\n",__FILE__,__LINE__); } SOURCE_TYPE = hdr->TYPE; hdr->TYPE = GDF; hdr->VERSION = 3.0; hdr->FILE.COMPRESSION = COMPRESSION_LEVEL; /******************************************* convert to unique sampling rate and unique data type *******************************************/ uint16_t gdftyp=0; if (1) { uint16_t nbits=0; int flag_fnbits=0; int flag_snbits=0; int flag_unbits=0; int flag_signed=0; for (k=0; k < hdr->NS; k++) { if (hdr->CHANNEL[k].OnOff && hdr->CHANNEL[k].SPR) { hdr->CHANNEL[k].SPR = hdr->SPR; uint16_t gt = hdr->CHANNEL[k].GDFTYP; if ((15flag_unbits) { nbits=flag_snbits; flag_signed=1;} else if (flag_snbits64) gdftyp=8-flag_signed; else if (nbits>32) gdftyp=8-flag_signed; else if (nbits>16) gdftyp=6-flag_signed; else if (nbits>8) gdftyp=4-flag_signed; else gdftyp=2-flag_signed; hdr->SPR = 1; hdr->NRec = hdr->data.size[1]; typeof(hdr->NS) NS=0; for (k=0; kNS; k++) { if (hdr->CHANNEL[k].OnOff) { NS++; hdr->CHANNEL[k].GDFTYP = gdftyp; hdr->CHANNEL[k].SPR = hdr->SPR; } } hdr->AS.bpb = NS*GDFTYP_BITS[gdftyp]; } /********************************* Write data *********************************/ hdr->FLAG.ANONYMOUS = FLAG_ANON; /* keep header data from previous file, in might contain optional data (GDF Header3, EventDescription, hdr->SCP.SectionX, etc. ) and might still be referenced and needed. */ void *tmpmem = hdr->AS.Header; hdr->AS.Header = NULL; size_t filesize=0; // open_gdfwrite(hdr,stdout); // encode header hdr->TYPE=GDF; hdr->VERSION=3.0; struct2gdfbin(hdr); // write header into buffer filesize += fwrite (hdr->AS.Header, 1, hdr->HeadLen, fid); count = 0; char BLK[0x10000]; unsigned spb = (0x10000 / hdr->AS.bpb) * hdr->AS.bpb / GDFTYP_BITS[gdftyp]; while (count < hdr->data.size[0]*hdr->data.size[1]) { if (count+spb > hdr->data.size[0]*hdr->data.size[1]) spb = hdr->data.size[0] * hdr->data.size[1] - count; switch (gdftyp) { case 1: { int8_t *data = (void*)&BLK; for (int k=0; k < spb; k++) data[k]=(int8_t)hdr->data.block[k+count]; break; } case 2: { uint8_t *data = (void*)&BLK; for (int k=0; k < spb; k++) data[k]=(int8_t)hdr->data.block[k+count]; break; } case 3: { int16_t *data = (void*)&BLK; for (int k=0; k < spb; k++) lei16a((int16_t)hdr->data.block[k+count], data+k); break; } case 4: { uint16_t *data = (void*)&BLK; for (int k=0; k < spb; k++) leu16a((uint16_t)hdr->data.block[k+count], data+k); break; } case 5: { int32_t *data = (void*)&BLK; for (int k=0; k < spb; k++) lei32a((int32_t)hdr->data.block[k+count], data+k); break; } case 6: { uint32_t *data = (void*)&BLK; for (int k=0; k < spb; k++) leu32a((uint32_t)hdr->data.block[k+count], data+k); break; } case 7: { int64_t *data = (void*)&BLK; for (int k=0; k < spb; k++) lei64a((int64_t)hdr->data.block[k+count], data+k); break; } case 8: { uint64_t *data = (void*)&BLK; for (int k=0; k < spb; k++) leu64a((uint64_t)hdr->data.block[k+count], data+k); break; } case 16: { float *data = (void*)&BLK; for (int k=0; k < spb; k++) lef32a((float)hdr->data.block[k+count], data+k); break; } case 17: { double *data = (void*)&BLK; for (int k=0; k < spb; k++) lef64a((double)hdr->data.block[k+count], data+k); break; } default: { } } count += fwrite(BLK, GDFTYP_BITS[gdftyp]/8, spb, fid); } filesize += count*GDFTYP_BITS[gdftyp]/8; // write event table into buffer size_t len3 = hdrEVT2rawEVT(hdr); filesize += fwrite(hdr->AS.rawEventData, 1, len3, fid); if (fid != stdout) fclose(fid); status = serror2(hdr); destructHDR(hdr); exit(status); } biosig-2.3.3/biosig4c++/INSTALL0000664000175000017500000002203714105434233016044 0ustar schloeglschloegl INSTALLATION ============ Quick start for Debian/Linux installing libbiosig: # Compile-Time Requirements apt-get install libb64-dev optional: apt-get install libsuitesparse-dev zlib1g-dev libtinyxml-dev libdcmtk-dev # Runtime requirements apt-get install libb64 zlib1g optional: apt-get install libsuitesparse libtinyxml libdcmtk8 # Installation (for users): download source release and run VER=2.0.2 wget https://sourceforge.net/projects/biosig/files/BioSig\ for\ C_C\+\+/src/biosig4c\+\+-$VER.src.tar.gz tar xvf biosig4c++-$VER.src.tar.gz cd biosig4c++-$VER ./configure && make && sudo make install # Installation for developers: ## latest development version git clone https://git.code.sf.net/p/biosig/code biosig-code cd biosig-code autoreconf -fi # only needed if autoconf files have been changed ./configure # only needed if configuration has changed make && sudo make install ## or if git pull make distclean autoreconf -fi # only needed if autoconf files have been changed ./configure # only needed if configuration has changed make && sudo make install # compiling of mexbiosig for Matlab and Octave MATLABDIR=/usr/local/MATLAB/R20##x/bin make mex4m make mex4o # generating an octave package make mexbiosig start octave and run pkg install mex/mexbiosig-X.Y.Z.src.tar.gz If libbiosig is available on your OS, you can also start octave and run pkg install https://pub.ist.ac.at/~schloegl/biosig/prereleases/mexbiosig-1.9.2.src.tar.gz # Compiling for python make python # Compiling save2gdf and biosig_fhir make tools sudo make install_tools # Monitoring of flow sensor ./flowmon2 -d `ls /dev/ttyUSB*` ### The information below might be outdated - it's not removed yet because it might still contain some useful hints ### General remarks: ---------------- Prerequisites: -------------- P0) gnu c compiler (gcc, g++, gnu make, gawk). It will work on unix like systems (Linux, BSD, etc) mingw, cygwin. and NO, MSVC is not suitable for compiling libbiosig !!! P1) for building libbiosig, save2gdf, mma (mathematica) and mex (matlab) sudo apt-get install subversion libz-dev libsuitesparse-dev libcurl-dev gawk g++ gcc svn co https://biosig.svn.sourceforge.net/svnroot/biosig/trunk/biosig4c++ For ttl2trig, also the package libasound-dev is required. P2) for building SigViewer sudo apt-get install qt4-dev-tools libqt4-dev libqt4-qt3support svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk sigviewer P3) Cross-compilation on Linux for Win32/Win64-target: aptitude install -R autoconf automake bash bison bzip2 \ cmake flex g++ intltool make sed \ libtool openssl libssl-dev \ libxml-parser-perl patch perl \ pkg-config scons unzip wget \ xz-utils yasm mercurial git clone https://github.com/schloegl/mxe.git cd mxe make biosig stimfit Platform specific information ----------------------------- # Linux You need GNU gcc, g++ (ver>4.0), make, zlib (if you do not have zlib, do not define WITH_ZLIB), libsuitesparse (if you do not have libsuitesparse, do not define WITH_CHOLMOD). Running make compiles the converter. make # makes the file format converter make save2gdf # makes the file format converter make win32 # makes the file format converter for Win32 make win64 # makes the file format converter for Win64 make physicalunits # makes the en/decoder for physical units make lib # makes library make mex4o # makes mexSLOAD for Octave (requires Octave-headers2.9 or higher) make mex4m # makes mexSLOAD for Matlab (path_to_mex need to be defined in Makefile) make biosig4python # compiles the BioSig interface for Python (requires SWIG and Python) make all # all of the above make sigviewer # recompiles SigViewer (requires qmake and Qt, the sources of sigviewer must be in ../sigviewer) make testscp make testhl7 make test # tests HL7<->SCP, SCP<->GDF, GDF<->HL7 converters make test6 # tests bidirectional conversion between 6 differerent data formats # Mac OS X (tested under 10.7 Lion) 1. First, get Xcode from the App Store. You need to create an Apple Developer Account (which is free) to install the command line tools (see next step). 2. In Xcode, go to Preferences - Downloads - Components - Install Command Line Tools. 3. Install MacPorts from http://www.macports.org/. 4. In a terminal, type "sudo port install gawk". 5. In a terminal, type "sudo port install SuiteSparse". Optional (if you want a good IDE, this is recommended): 6. Install Eclipse from http://www.eclipse.org/. 7. Install CDT (in Eclipse, go to Help - Install New Software...). Activate the CDT repository by clicking on "Available Software Sites" and activate "CDT Juno". After clicking OK, select "-- All Available Sites --" and install "CDT Main Features". 8. In Eclipse, go to Preferences - C/C++ - Build - Environment - Add... Enter PATH in the Name text box and /opt/local/bin:/opt/local/sbin in the Value text box. 9. To load the project, go to File - New - Makefile Project with Existing Code. Fill in the name of the project (for example, biosig4c++) and enter the root folder containing the source code of biosig4c++. 10. In the Project Explorer, you can now right-click on the project and choose Clean or Build to start compiling the project. # MinGW Crosscompiler on Debian/Ubuntu for Windows - aptitude install mingw32 mingw32-binutils mingw32-runtime # mxe/mce-w64 on GNU/Linux for Windows Prerequisites P3) and/or P4) (see above) - modify Makefile and set variable CROSS for Win32 (and CROSS64 for Win64) to the proper value e.g. CROSS = $(HOME)/src/mxe/usr/bin/i686-pc-mingw32 CROSS64 = $(HOME)/src/mce-w64/usr/bin/x86_64-w64-mingw32 - run the command make win32/save2gdf.exe # converter between data formats make win32/libbiosig.dll # dynamic library make win32/libbiosig.a # static library make win32mma # Win32/Mathematica interface make mexw32 # Win32/Matlab mex interface make win32 # all of the above make win64/save2gdf.exe # converter between data formats 64bit Windows make mexw64 # Win64/Matlab mex interface # Windows + MinGW Prerequisites P5) (see above) Support for FEF, ZLIB, CHOLMOD is turned off, because of lack of support in MinGW. In general, Makefile.win32 should be used. - Run the make command make -f Makefile.win32 libbiosig.a make -f Makefile.win32 save2gdf.exe make -f Makefile.win32 sigviewer make -C mma -f Makefile.win32 sload.exe # mathematica interface You can also start compilation of sigviewer. First, you need to have the sigviewer sources in ..\sigviewer and Then, you need to run once qmake in ..\sigviewer\src\ make -f Makefile.win32 sigviewer # Matlab/Win32 using MinGW on Windows do the steps in "Windows+MinGW" install and configure gnumex (from http://gnumex.sf.net) make libbiosig.a start matlab >> gnumex % configure mingw for mex >> mex mexSLOAD.cpp libbiosig \mingw\lib\libws2_32.a # Mathematica/Win32 using MinGW on Windows Adapt user-specified variables (directory names) in Makefile.win32 and mma/Makefile.win32 cd biosig4c++/mma make -f Makefile.win32 sload.exe # Windows + Cygwin Currently, only the file converter save2gdf is supported. - install Cygwin - within Cygwin install gcc4 g++4, zlib, suitesparse/cholmod and make - run the make command make save2gdf # MSVC - Microsoft Visual C++ MSVC is currently not supported. You are on your own. # Other platforms (Windows+MSVC, MacOSX, Solaris, etc. ) some tests on other Unix-like systems have been successful. Installation: ------------- run as root make make install # installs save2gdf, save2scp, save2aecg, make install_octave # installs mexSLOAD.mex in /usr/local/share/octave/site-m/ make install_sigviewer # installs sigviewer Execution: ---------- # if test.gdf exists, some header information is displayed save2gdf test.gdf # help and usage information save2gdf -h # converts a data file into a GDF format (destination save2gdf PFE103.scp t5.gdf # converts a data file into a SCP format (destination save2scp t5.gdf t5.scp save2gdf -f=SCP t5.gdf t5.scp # converts a data file into a HL7aECG format (destination save2aecg t5.gdf t5.hl7 save2gdf -f=HL7aECG t5.gdf t5.hl7 # load matlab into octave or matlab start octave or matlab addpath path_to_mexSLOAD.mex [data,HDR] = mexSLOAD(filename); % loads data and header information Development & Testing: ---------------------- There are several testing functions included. The following commands test the converter and should finish without errors. make test make testhl7 make testscp make test6 The Octave/Matlab script test0/test01.m tests whether the various data formats give the same results or whether some conversion error has been included. Copyright (C) 2005-2013, Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig-2.3.3/biosig4c++/README0000664000175000017500000001664114105434233015677 0ustar schloeglschloeglIntroduction: ============= The aim of this repository is providing a C/C++ software library for biomedical signal processing. BioSig4C++ provides several tools: (1) = LIBRARIES = (1a) "libbiosig" provides a library for accessing different dataformats. The supported data formats are listed here: http://pub.ist.ac.at/~schloegl/biosig/TESTED A disadvantages is the direct access to internal data structure, which makes it difficult to maintain ABI combatibility. External applications should use libbiosig2 instead. (1b) "libgdf" is a lightweight version of libbiosig, supporting only the GDF format. it requires only GCC not G++ for linking, has potentially much less security loopholes (XML) and bugs, and a much smaller memory footprint, which might be especially useful for embedded devices. It's interface is the same than for libbiosig, namely biosig.h (1c) "libbiosig" is a level 2 interface for managing multiple files, It's interface is defined in biosig.h. It can be used to link libbiosig compiled with GCC to software compiled with MSVisualC++. ABI compatibility is easier to maintain because access to internal data structures can be applied only through functions calls and not through pointers. (1d) "libphysicalunits" provides conversion tools for physical units from ascii text to 16bit integers according to ISO/IEEE 11073-10101:2004 Table A.6.3: Vital signs units of measurements text strings are cached for performance reasons, and can be used in a multi-threaded application. Static and dynamic libraries are build. The Application Programming Interface (API) is reasonable stable, changes are managed through marking the modified "deprecated". The appliction binary interface (ABI) depends also on external tools and libraries, especially access to interal data structures like structs can break ABI compatibility, even when the API is stable. Recompiling the application is on solution, but not always feasible. In order to avoid that need, it is strongly recommended to use only the level 2 interface, which provides access to the internal header data through functions. If only level 2 interface functions are used, it is reasonable save to dynamically link libbiosig2. * Installation of official source release (for users): download source release and run VER=1.9.5 wget https://sourceforge.net/projects/biosig/files/BioSig\ for\ C_C\+\+/src/biosig4c\+\+-$VER.src.tar.gz tar xvf biosig4c++-$VER.src.tar.gz cd biosig4c++-$VER ./configure && make && sudo make install * Installation from git repository (for developers, usually untested): ** Checkout code for the first time: git clone https://git.code.sf.net/p/biosig/code biosig-code cd biosig-code/biosig4c++ autoconf # needed only the first time after checkout ./configure make sudo make install ** next time just update latest changes git pull autoreconf -fim # usually this can be omitted ./configure # usually this can be omitted make make install For doing some advanced (special) configurations, you can modify these flags in Makefile.in (2) = converter and tools = contains several tools for data conversion, save2gdf: is a converter between different file formats, including but not limited to SCP-ECG(EN1064), HL7aECG (FDA-XML), GDF, EDF, BDF, CWFB and others save2gdf can be also used to upload or retrieve data from a bscs server, and to display the header information in ascii and in JSON format. biosig2fhir: is a tool than converts biosig data into a hl7/fhir binary template, the header information is encoded in JSON format, the data is converted into a base64-encoded GDF (OeNorm K2202:2015) formatted file. physicalunits: is a tool to show the encoding of physical units according to ISO/IEEE 11073 These can can be build with: make tools (3) language bindings and foreign function interfaces: (3a) "mexSLOAD" is a MEX-interface for Octave and Matlab and is linked statically to libbiosig. It can be build with make mex4o # octave make mex4m # matlab for details see mex/README. (3b) "python" is an interface to python and dynamically linked to libbiosig. Requirement: python, python-dev, python-numpy for Debian/Ubuntu: sudo apt-get install python python-dev python-numpy python-wheels sudo apt-get install python3 python3-dev python3-numpy python3-wheels It can be build with any of the following commands: make python make -C python build make -C python release For installation, you can than do either cd python && python setup.py install cd python && python3 setup.py install or python -m pip install python/dist/Biosig-1.9.2.tar.gz python3 -m pip install python/dist/Biosig-1.9.2.tar.gz Use of the interface is shown in ./python/demo2.py (3c) mathematica is linked dynamically to libbiosig and can be build with: make mma see also mma/README, and mma/biosig, mma/hdrinfo.nb, mma/mySLOAD.nb for more details. (3z) other language interfaces Interfaces to other languages (including Java, PHP, Perl and TCL) are considered, but these still need to be implemented and tested. (5) = SigViewer = Requirement: qmake, Qt5 an important patch to overcome several limitations (event handling beyond 16.7 Mio samples) is applied. (6) Precompiled binaries for Win32 and Win64 win##/save2gdf.exe binary converter win##/libbiosig.{lib,dll} static and dynamic library (requires zlib and libws2_32) mma/sload.exe Mathematica binding through Mathlink interface mex/mexSLOAD.mexw32 Mex-file for Win32/Matlab The internal data structure resemble the header structure similar to http://biosig.svn.sourceforge.net/viewvc/biosig/trunk/biosig/doc/header.txt and is defined in http://biosig.svn.sourceforge.net/viewvc/biosig/trunk/biosig4c%2B%2B/biosig.h (see HDRTYPE and CHANNEL_TYPE) Encoding of Event/Markers/Annotations is available here: http://pub.ist.ac.at/~schloegl/matlab/eeg/EventCodes.html The latest list of supported data formats is available here: http://pub.ist.ac.at/~schloegl/biosig/TESTED File(s): ------------- README this file biosig.h definition of external biosig interface biosig-dev.h definition of internal functions biosig.c SOPEN, SREAD, SWRITE, SEOF, SCLOSE functions save2gdf.c converter between various file formats. physicalunit.c en-/decodes physical units according to ISO/DIS 11073-10101:2003 mexSLOAD.cpp is a MEX-File for loading data in Octave and Matab. t210/* reading SCP, FAMOS file format t220/* writing SCP file format t230/* support of HL7aECG file format t240/* Support for CNSystems' File Exchange Format (CNS-FEF), note this is different to CENTS14271 in t241/ t241/*.asn1 ASN.1 specification of ISO11073-xxxxx and CENTS-14271 (FEF), test0/* scripts and functions for testing Makefile script for compiling and testing under GNU/Linux Makefile.win32 script for compiling and testing on win32 using mingw mex/* Octave/Matlab binding through MEX-interface mma/* MathLink interface to mathematica win32/* library and executables for Windows python/*.py show example and demo src/*.c applications: flowmon reads data from serial port, ttl2trig reads data from audio card More information is available at http://biosig.sf.net/ If you have any questions you can also contact the mailinglist https://lists.sourceforge.net/lists/listinfo/biosig-general Copyright (C) 2005-2020 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig-2.3.3/biosig4c++/Makefile0000664000175000017500000013676114105434244016467 0ustar schloeglschloegl######## Makefile for "BioSig for C/C++" ##################### ### ### Copyright (C) 2006-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at https://biosig.sourceforge.io/ ### ############################################################## ##### Target: GNU/Linux # ## make && make install build and install libbiosig, but no other tools. # libbiosig is a prerequisite for building all the other tools below. # ## make save2gdf - makes converter ## make biosig_fhir - makes converter for fhir-binary template ## make install_save2gdf - installs converter ## make install_mma installs biosig's sload for Mathematica in $PREFIX/share/biosig/mathematica ## make install_mex installs mexbiosig for Matlab in $PREFIX/share/biosig/mex # ## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) ## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) ## make mexw32 - makes mexSLOAD.mexw32, mexSOPEN.mexw32 (requires that mingw32, gnumex libraries from Matlab/Win32) ## make mexw64 - makes mexSLOAD.mexw64, mexSOPEN.mexw64 (requires that mce-w32, gnumex libraries from Matlab/Win64) ## make mex - mex4o, mex4m, mexw32, mexw64 combined ## make biosig4java - makes Java interface (experimental) ## make biosig4php - makes PHP interface (experimental) ## make biosig4perl - makes perl interface (experimental) ## make biosig4ruby - makes ruby interface (experimental) ## make biosig4tcl - makes tcl/tk interface (experimental) ## ## make win32 and make win64 are obsolete. save2gdf.exe, and libbiosig.{a,dll} for windows can now be built ## with the mingw-cross-compiler environment (mxe.cc). ## git clone https://github.com/schloegl/mxe.git ## make biosig ## should do what you want. Please note, that win32mma does now also rely that libbiosig is built with MXE. ## Make sure that CROSS or CROSS64 is properly defined when running `make` ## ## ??? ## make sigviewer - makes sigviewer ##### Target: Win32 ## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw32 mex/mexSLOAD.mexw32 - requires MinGW32 and GNUMEX libraries from Matlab/Win32 ## make win32/sigviewer.exe - requires sources of SigViewer, and MinGW32 (mex: make suitesparse zlib qt ) ##### Target: Win64 ## make win64 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW ## make mexw64 mex/mexSLOAD.mexw64 - requires MCE-W64 and GNUMEX libraries from Matlab/Win64 ## make win64/sigviewer.exe - requires sources of SigViewer and MCE-W64, make suitesparse zlib qt ##### Target: MacOSX w/ homebrew ## make install_homebrew installs libbiosig and save2gdf # requires: brew tap homebrew/dupes # brew install libiconv ############################### # whether dynamic or static linking is used, can be controlled with # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically # LIBEXT = a #LIBEXT = so ############################### ### User-specified options: its likely you want to change this # settings for cross compiler: tested with MXE and mce-w64 with make suitesparse zlib qt ; CROSS = $(HOME)/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static ## local MXE ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = $(HOME)/src/mxe.master/usr/bin/i686-w64-mingw32.static endif ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = $(shell pwd)/../mxe/usr/bin/i686-w64-mingw32.static endif ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static endif CROSS64 = $(HOME)/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = $(HOME)/src/mxe.master/usr/bin/x86_64-w64-mingw32.static endif ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = $(HOME)/src/mxe.master/usr/bin/x86_64-w64-mingw32.static endif # settings for mex files MEX_OPTION = -largeArrayDims # turn on for 64 bit Matlab, otherwise empty # directory for sources of sigviewer PathToSigViewer = ../sigviewer PathToSigViewerWIN32 = ../sigviewer4win32 PathToSigViewerWIN64 = ../sigviewer4win64 CFLAGS += -pipe -fPIC -fno-builtin-memcmp -O2 -Wno-unused-result CFLAGS += -Wno-deprecated CFLAGS += -fvisibility=hidden prefix = /usr/local exec_prefix ?= /usr/local libdir = ${exec_prefix}/lib includedir = ${prefix}/include bindir = ${exec_prefix}/bin mandir = ${prefix}/share/man CFLAGS += -I$(includedir) CXXFLAGS += $(CFLAGS) ## TARGET dependencies ifeq (,$(TARGET)) CC ?= gcc CXX ?= g++ AR := ar rcs PKGCONF := pkg-config SHAREDLIB = -shared DLEXT = so else ifeq (intel,$(TARGET)) CC := icc CXX := icc LD := xild AR := xiar crs else PREFIX := $(subst /bin/,/,$(dir $(shell which $(TARGET)-gcc))) CC := $(TARGET)-gcc CXX := $(TARGET)-g++ LD := $(TARGET)-ld AR := $(TARGET)-ar rcs PKGCONF := $(TARGET)-pkg-config ifneq (,$(findstring mingw,$(TARGET))) ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o LDLIBS += -lssp LDLIBS += -liconv -lstdc++ -lws2_32 PKG_CONFIG_LIBS += -liconv -lws2_32 BINEXT = .exe DLEXT = dll endif endif SONAMEVERSION ?= 3 ### TODO: DLEXT does not work correctly on MXE/MINGW DLDIR = $(libdir) ifneq (,$(findstring Darwin, $(shell uname))) ## Homebrew: ## brew install gawk ## brew install gnu-tar ## brew install homebrew/dupes/libiconv ## brew install homebrew/science/suite-sparse ## LD = $(CXX) -shared CFLAGS += -I$(prefix)/include CFLAGS += -mmacosx-version-min=10.13 LDLIBS += -liconv -lstdc++ SHAREDLIB = -dylib -arch x86_64 #-macosx_version_min 10.13 LDFLAGS += -L$(prefix)/lib/ DLEXT = dylib FULLDLEXT = .dylib SONAME_PREFIX = -install_name # the last space character is crucial else ifneq (,$(findstring CYGWIN, $(shell uname))) ### TODO: check if this path is useful at all ### DLEXT = dll LD = $(CXX) LDLIBS += -liconv -lstdc++ FULLDLEXT = ${SONAMEVERSION}.dll SONAME_PREFIX = -Wl,-soname= else ifneq (,$(findstring MINGW, $(shell uname))) ### TODO: check if this path is useful at all ### ## add gnulib's getlogin SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c OBJECTS += getlogin.o getline.o getdelim.o ## exclude conflicting definition of sopen from mingw's io.h CC = gcc CXX = g++ CFLAGS += -pipe -fPIC -D_REENTRANT -D=BUILD_DLL LD = $(CXX) FULLDLEXT = ${SONAMEVERSION}.dll SONAME_PREFIX = -Wl,-soname= LDLIBS += -lstdc++ LDLIBS += -liconv -lws2_32 LDFLAGS += -Wl,-subsystem,windows LDFLAGS += -L$(prefix)/lib/ DLDIR = $(bindir) else LD = $(CXX) ifneq (,$(findstring mingw,$(TARGET))) FULLDLEXT = ${SONAMEVERSION}.dll DLDIR = $(bindir) else FULLDLEXT = .so.${SONAMEVERSION} endif SONAME_PREFIX = -Wl,-soname= endif DEFINES_ALL = #-D=NDEBUG DEFINES += $(DEFINES_ALL) #DEFINES += -D=WITH_SON #DEFINES += -D=WITHOUT_SCP_DECODE #DEFINES += -D=WITH_TIMESTAMPEVENT #DEFINES += -D=WITH_TIMESTAMPCHANNEL ### Mingw,MXE, etc. must avoid name space conflict concerning SOPEN ### #DEFINES += -D=NO_OLDNAMES #DEFINES += -D=WITH_CURL DEFINES += -D=__4HAERTEL__ DEFINES += -D=WITH_FAMOS DEFINES += -D=WITH_FIFF DEFINES += -D=WITHOUT_NETWORK DEFINES += -D=WITH_SCP3 DEFINES += -D=WITH_FEF #DEFINES += -D=WITH_PDP ### DICOM: DCMTK or GDCM, or internal # WITH_DCMTK is already configured by autoconf # WITH_GDCM is experimental # WITH_DICOM (internal implementation) is experimental #DEFINES += -D=WITH_GDCM #DEFINES += -D=WITH_GSL #DEFINES += -D=WITH_EEPROBE DEFINES += -D=WITH_INTAN #DEFINES += -D=WITH_TDMS DEFINES += -D=WITH_ATF #DEFINES += -D=WITH_AVI #DEFINES += -D=WITH_RIFF #DEFINES += -D=WITH_WAV #DEFINES += -D=WITH_NEV DEFINES += -D=MAKE_EDFLIB ifeq (1,1) LDLIBS += -lz endif ifeq (1,@HAVE_LIBPTHREAD@) LDLIBS += -lpthread endif ifeq (1,1) LDLIBS += -lcholmod ifeq (Darwin,$(shell uname)) ## homebrew requires this in addition to cholmod LDLIBS += -lsuitesparseconfig endif endif ifeq (1,1) DEFINES += -D=WITH_DCMTK LDLIBS += -ldcmdata -loflog -lofstd SOURCES += t210/sopen_dcmtk_read.cpp OBJECTS += sopen_dcmtk_read.o MinGWOBJECTS += win32/sopen_dcmtk_read.obj endif ifeq (1,@HAVE_LIBHDF5@) LDLIBS += -lhdf5 endif ifeq (1,@HAVE_LIBMATIO@) LDLIBS += -lmatio endif ifeq (1,1) LDLIBS += -lm endif ifeq (1,1) DEFINES += -D=WITH_LIBTINYXML LDLIBS += -ltinyxml endif ifeq (1,@HAVE_LIBTINYXML2@) DEFINES += -D=WITH_LIBTINYXML2 LDLIBS += -ltinyxml2 endif ifneq (,$(findstring WITH_GDCM, $(DEFINES))) INCPATH += -I$(wildcard /usr/include/gdcm-2*/) LDLIBS += -lgdcmCommon -lgdcmDSED -lgdcmMEXD -lgdcmMSFF -lgdcmDICT -lgdcmIOD endif ifneq (,$(findstring WITH_CURL, $(DEFINES))) LDLIBS += -lcurl endif ifneq (,$(findstring stack-protector, $(CFLAGS))) ifneq (,$(findstring CYGWIN, $(shell uname))) LDLIBS += -lssp endif ifneq (,$(findstring MINGW, $(shell uname))) LDLIBS += -lssp endif endif DELETE = rm -f COPY = cp -f DATA_DIR = data/ DATA_DIR_CFS = $(HOME)/L/data/test/cfs/ TEMP_DIR = test/ SED = sed TAR = tar VERBOSE := -V0 ########################################################## ## set Matlab and Octave variables ifeq (undefined,$(origin MATLABDIR)) ifeq (Darwin,$(shell uname)) MATLABDIR := $(shell find /Applications/MATLAB* -name bin -type d -depth 1 2>/dev/null | head -1) else MATLABDIR ?= $(shell find /usr/local/MATLAB* -maxdepth 2 -name bin -type d 2>/dev/null | head -1) endif endif ifeq (,$(MATLABDIR)) #$(warning MATLABDIR is not defined) else MEX = $(MATLABDIR)/mex MEX_EXT := $(shell $(MATLABDIR)/mexext) endif ########################################################## ########################################################## ## set variables for MinGW Crosscompiler: compile on linux binaries for windows ## PathToMinGW = $(dir $(CROSS))..$(nondir $(CROSS)) PathToMinGW64 = $(dir $(CROSS64))..$(nondir $(CROSS64)) MinGWCC = $(CROSS)-gcc MinGWCXX = $(CROSS)-g++ MinGWDEF = $(DEFINES) MinGWCFLAGS = -pipe -fPIC -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -Iwin32 -I$(PathToMinGW)/include/ MinGWLIBS = win32/libbiosig.a -L$(PathToMinGW)/lib/ $(LDLIBS) # static MinGWLINK = $(MinGWCXX) MinGW64CC = $(CROSS64)-gcc MinGW64CXX = $(CROSS64)-g++ MinGW64CFLAGS = -pipe -fPIC -O2 -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -Iwin64 -I$(PathToMinGW64)/include/ MinGW64LIBS = win64/libbiosig.a -L$(PathToMinGW64)/lib/ $(LDLIBS) # static MinGW64LINK = $(MinGW64CXX) ########################################################## # Versioning MAJOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MAJOR' biosig-dev.h)) MINOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MINOR' biosig-dev.h)) STEPPING := $(word 3, $(shell grep '\#define BIOSIG_PATCHLEVEL' biosig-dev.h)) BIOSIG_VERSION := 2.3.3 TODAY := $(shell date +%Y%m%d) ####### Output directory OBJ = ./obj ####### Files SOURCES += biosig.c \ biosig2.c \ t210/sopen_cfs_read.c \ t210/sopen_heka_read.c \ t210/sopen_igor.c \ t210/sopen_rhd2000_read.c \ t210/sopen_scp_read.c \ t210/sopen_tdms_read.c \ t210/sopen_famos_read.c \ t210/sopen_abf_read.c \ t210/sopen_alpha_read.c \ t210/sopen_axg_read.c \ t210/sopen_cadwell_read.c \ t210/scp-decode.cpp \ t220/sopen_scp_write.c \ t220/crc4scp.c \ t230/sopen_hl7aecg.cpp \ t240/sopen_fef_read.c \ test0/sandbox.c \ xgethostname.c \ gdftime.c \ mdc_ecg_codes.c \ physicalunits.c \ save2gdf.c \ biosig2gdf.c \ biosig_client.c \ biosig_server.c ifneq (1,1) ## build with internal TinyXML when libtinyxml is not available SOURCES += XMLParser/tinyxml.cpp \ XMLParser/tinyxmlparser.cpp \ XMLParser/tinyxmlerror.cpp \ XMLParser/tinystr.cpp endif OBJECTS += \ biosig.o \ biosig2.o \ crc4scp.o \ sopen_cfs_read.o \ sopen_heka_read.o \ sopen_igor.o \ sopen_scp_read.o \ sopen_abf_read.o \ sopen_alpha_read.o \ sopen_axg_read.o \ sopen_cadwell_read.o \ sopen_scp_write.o \ sopen_hl7aecg.o \ gdftime.o \ mdc_ecg_codes.o \ physicalunits.o \ sandbox.o \ xgethostname.o MinGWOBJECTS = \ win32/biosig.obj \ win32/biosig2.obj \ win32/crc4scp.obj \ win32/getlogin.obj \ win32/sopen_cfs_read.obj \ win32/sopen_heka_read.obj \ win32/sopen_igor.obj \ win32/sopen_scp_read.obj \ win32/sopen_abf_read.obj \ win32/sopen_alpha_read.obj \ win32/sopen_axg_read.obj \ win32/sopen_cadwell_read.obj \ win32/sopen_scp_write.obj \ win32/sopen_hl7aecg.obj \ win32/gdftime.obj \ win32/physicalunits.obj \ win32/sandbox.obj \ win32/xgethostname.obj ifneq (,$(findstring WITH_FAMOS, $(DEFINES))) OBJECTS += sopen_famos_read.o endif ifneq (,$(findstring WITH_FAMOS, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_famos_read.obj endif ifneq (,$(findstring WITH_FEF, $(DEFINES))) -include t240/modules.mk SOURCES += $(patsubst %.c,t240/%.c,${ASN_MODULE_SOURCES}) OBJECTS += $(patsubst %.c,%.o,${ASN_MODULE_SOURCES}) OBJECTS += sopen_fef_read.o endif ifneq (,$(findstring WITH_FEF, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_fef_read.obj endif ifneq (,$(findstring WITH_INTAN, $(DEFINES))) OBJECTS += sopen_rhd2000_read.o endif ifneq (,$(findstring WITH_INTAN, $(MinGWDEF))) MinGWOBJECTS += sopen_rhd2000_read.obj endif ifneq (,$(findstring WITH_TDMS, $(DEFINES))) OBJECTS += sopen_tdms_read.o endif ifneq (,$(findstring WITH_TDMS, $(MinGWDEF))) MinGWOBJECTS += win32/sopen_tdms_read.obj endif ifeq (,$(findstring WITHOUT_NETWORK, $(DEFINES))) OBJECTS += biosig-network.o endif ifeq (,$(findstring WITHOUT_NETWORK, $(MinGWDEF))) MinGWOBJECTS += win32/biosig-network.obj endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(DEFINES))) OBJECTS += scp-decode.o endif ifeq (,$(findstring WITHOUT_SCP_DECODE, $(MinGWDEF))) MinGWOBJECTS += win32/scp-decode.obj endif ifeq (,$(findstring WITH_LIBTINYXML, $(DEFINES))) ## build with TinyXML when libtinyxml is not available OBJECTS += tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o MinGWOBJECTS += win32/tinyxml.obj win32/tinyxmlparser.obj win32/tinyxmlerror.obj win32/tinystr.obj endif MinGW64OBJECTS = $(patsubst win32/%.obj, win64/%.obj, $(MinGWOBJECTS)) TARGET = save2gdf libbiosig.a LIB_OBJECTS = libbiosig.a libgdf.a libphysicalunits.a libbiosig.pc ifeq (,$(findstring mingw,$(TARGET))) LIB_OBJECTS += libbiosig.$(DLEXT) libgdf.$(DLEXT) libphysicalunits.$(DLEXT) endif BIN_OBJECTS = save2gdf${BINEXT} physicalunits${BINEXT} biosig_fhir${BINEXT} biosig2gdf${BINEXT} first: $(IO_H_FILE2) lib tools tools: $(BIN_OBJECTS) all: first #win32 win64 #sigviewer #win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer libbiosig lib: $(LIB_OBJECTS) ############################################################# # Compilation: Implicit, default rules ############################################################# CHKSUM_LIBB64 = 20106f0ba95cfd9c35a13c71206643e3fb3e46512df3e2efb2fdbf87116314b2 libb64-1.2.1.zip: curl -SLO https://downloads.sourceforge.net/project/libb64/libb64/libb64/libb64-1.2.1.zip test $(shell sha256sum libb64-1.2.1.zip | cut -d " " -f 1) = $(CHKSUM_LIBB64) || rm libb64-1.2.1.zip libb64-1.2.1/src/cencode.c: libb64-1.2.1.zip test $(shell sha256sum libb64-1.2.1.zip | cut -d " " -f 1) = $(CHKSUM_LIBB64) && unzip -o libb64-1.2.1.zip -d . touch $@ vpath %.c ./:./t210:./t220:./t240:./test0:./src:./mma vpath %.cpp ./:./t210:./t230:./XMLParser .SUFFIXES: .o .c .cpp .cc .cxx .C %.o: t240/%.c biosig-dev.h gdftime.h physicalunits.h $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" %.c: %.h biosig-dev.h gdftime.h physicalunits.h %.cpp: %.h biosig-dev.h gdftime.h physicalunits.h %.o: %.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o : win32/%.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: %.cpp biosig.h biosig-dev.h $(CXX) -c $(DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(INCPATH) -o "$@" "$<" sandbox.o: test0/sandbox.c biosig.h $(CXX) -c $(DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: t240/%.c biosig-dev.h $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -I t240 -o "$@" "$<" win32/%.obj: %.c $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" win32/%.obj: %.cpp $(MinGWCXX) -c $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" win32/%.obj: win32/%.c $(MinGWCC) -c $(DEFINES) $(MinGWCFLAGS) -I win32 -o "$@" "$<" win64/%.obj: t240/%.c biosig-dev.h $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -I t240 -o "$@" "$<" win64/%.obj: %.c $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" win64/%.obj: %.cpp $(MinGW64CXX) -c $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" win64/%.obj: win32/%.c $(MinGW64CC) -c $(DEFINES) $(MinGW64CFLAGS) -I win32 -o "$@" "$<" ############################################################# # eventcodes and units: conversion from ascii to C code ############################################################# biosig.c: eventcodes.i eventcodegroups.i 11073-10102-AnnexB.i biosig.h biosig-dev.h physicalunits.c: units.i physicalunits.h eventcodes.i eventcodegroups.i : ../biosig4matlab/doc/eventcodes.txt gawk -f eventcodes.awk "$<" units.i : ../biosig4matlab/doc/units.csv awk -f units.awk "$<" > "$@" 11073-10102-AnnexB.i : ../biosig4matlab/doc//11073-10102-AnnexB.txt awk -f annotatedECG.awk "$<" > "$@" ############################################################# # Compilation: exceptions, explicit rules ############################################################# gdf.o: biosig.c biosig-dev.h eventcodes.i units.i 11073-10102-AnnexB.i $(CC) -c -D=ONLYGDF -D=WITHOUT_NETWORK $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" #getlogin_r.o: win32/getlogin_r.c # $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(INCPATH) -o "$@" "$<" ########### WIN32 ################## win32/gdf.obj: biosig.c biosig-dev.h $(MinGWCC) -c -D=ONLYGDF $(DEFINES) $(MinGWCFLAGS) -o "$@" "$<" $(PathToSigViewerWIN32): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win32 $(PathToSigViewerWIN32)/src/src.pro: $(PathToSigViewerWIN32) svn up -r 557 ../sigviewer4win32 win32/sigviewer.exe: win32/libbiosig.a win32/libbiosig.dll #-$(COPY) ../biosig/doc/eventcodes.txt $(PathToSigViewerWIN32)/src/ -$(DELETE) $(PathToSigViewerWIN32)/extern/include/*.h -$(COPY) biosig.h biosig2.h biosig-dev.h physicalunits.h $(PathToSigViewerWIN32)/extern/include -$(DELETE) $(PathToSigViewerWIN32)/extern/lib/lib* -$(COPY) win32/libbiosig.a $(PathToSigViewerWIN32)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 -lcholmod -lz -lcurl \2|' $(PathToSigViewerWIN32)/src/src.pro echo 0.5.2-v${BIOSIG_VERSION} > $(PathToSigViewerWIN32)/src/version.txt -(cd $(PathToSigViewerWIN32)/src; $(CROSS)-qmake; $(MAKE)) #-(cd $(PathToSigViewerWIN32); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; $(CROSS)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN32)/bin/release/sigviewer.exe win32/sigviewer.exe ########### WIN64 ################## win64/gdf.obj: biosig.c biosig-dev.h $(MinGW64CC) -c -D=ONLYGDF $(DEFINES) $(MinGW64CFLAGS) -o "$@" "$<" $(PathToSigViewerWIN64): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win64 $(PathToSigViewerWIN64)/src/src.pro: $(PathToSigViewerWIN64) svn up -r 557 ../sigviewer4win64 win64/sigviewer.exe: win64/libbiosig.a win64/libbiosig.dll #-$(COPY) ../biosig/doc/eventcodes.txt $(PathToSigViewerWIN64)/src/ -$(DELETE) $(PathToSigViewerWIN64)/extern/include/*.h -$(COPY) biosig.h biosig2.h biosig-dev.h physicalunits.h $(PathToSigViewerWIN64)/extern/include -$(DELETE) $(PathToSigViewerWIN64)/extern/lib/lib* -$(COPY) win64/libbiosig.a $(PathToSigViewerWIN64)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 -lcholmod -lz -lcurl\2|' $(PathToSigViewerWIN64)/src/src.pro echo 0.5.2-v${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} > $(PathToSigViewerWIN64)/src/version.txt -(cd $(PathToSigViewerWIN64)/src; $(CROSS64)-qmake; $(MAKE)) #-(cd $(PathToSigViewerWIN64); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; $(CROSS64)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN64)/bin/release/sigviewer.exe win64/sigviewer.exe ############################################################# # other language bindings (on Linux) ############################################################# java: libbiosig $(MAKE) -C java perl: libbiosig $(MAKE) -C perl php: libbiosig $(MAKE) -C php ruby/biosig_wrap.c: ruby/biosig.i (cd ruby && swig -ruby biosig.i) ruby/Makefile: ruby/extconf.rb ruby -C ruby extconf.rb biosig4ruby ruby: libbiosig ruby/Makefile ruby/biosig_wrap.c $(MAKE) -C ruby tcl: libbiosig tcl/biosig.i $(MAKE) -C tcl ############################################################# # WIN32 - BUILD ############################################################# # libraries are built in MXE ## save2gdf, pdp2gdf win32/%.exe: %.c $(MinGWCXX) $(DEFINES) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32/physicalunits.exe: pu.c $(MinGWCXX) $(DEFINES) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32: mexw32 win32mma ############################################################# # WIN64 - BUILD ############################################################# # Libraries are build in MXE ## save2gdf, pdp2gdf, pu win64/%.exe: %.c $(MinGW64CXX) $(DEFINES) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64/physicalunits.exe: pu.c $(MinGW64CXX) $(DEFINES) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64: mexw64 ############################################################# # GNU/Linux - Shared Libaries ############################################################# ifeq (,$(findstring Darwin, $(shell uname))) # not on MacOSX %.${DLEXT}:%${FULLDLEXT} ln -sf "$<" "$@" endif libbiosig${FULLDLEXT}:$(OBJECTS) $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libgdf${FULLDLEXT}: gdf.o gdftime.o physicalunits.o getlogin.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libgdftime${FULLDLEXT}:gdftime.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" libphysicalunits${FULLDLEXT}:physicalunits.o $(LD) $(LDFLAGS) ${SONAME_PREFIX}"$@" $^ $(SHAREDLIB) $(LDLIBS) -o "$@" ############################################################# # Static Libaries ############################################################# libphysicalunits.a: physicalunits.o -$(DELETE) "$@" $(AR) "$@" "$<" libphysicalunits.dll: physicalunits.o $(LD) $(LDFLAGS) -o libphysicalunits.dll -s -shared -fPIC "$<" $(LDLIBS) -Wl,-subsystem,windows,--output-def,libphysicalunits.def,--out-implib,libphysicalunits.dll.a #libgdftime.a: gdftime.o # -$(DELETE) "$@" # $(AR) "$@" "$<" #libgdftime.def: gdftime.o # $(CC) $(LDFLAGS) -o libgdftime.dll -s -shared -fPIC "$@" -Wl,--subsystem,windows,--output-def,libgdftime.def,--out-implib,libgdftime.dll.a libgdf.a: gdf.o getlogin.o gdftime.o physicalunits.o -$(DELETE) "$@" $(AR) "$@" gdf.o gdftime.o physicalunits.o libgdf.dll: gdf.o getlogin.o gdftime.o physicalunits.o $(LD) $(LDFLAGS) -s -shared -fPIC -o libgdf.dll gdf.o getlogin.o gdftime.o physicalunits.o $(LDLIBS) -Wl,-subsystem,windows,--output-def,libgdf.def,--out-implib,libgdf.dll.a libbiosig.a: $(OBJECTS) libbiosig.pc -$(DELETE) libbiosig.a $(AR) libbiosig.a $(OBJECTS) libbiosig.dll: $(OBJECTS) libbiosig.pc $(LD) $(LDFLAGS) -o libbiosig.dll -s -shared -fPIC $(OBJECTS) $(LDLIBS) -Wl,-subsystem,windows,--output-def,libbiosig.def,--out-implib,libbiosig.dll.a libbiosig.pc : mkdir -p pkgconfig echo "# Defines libbiosig.pc" > "$@" echo "prefix=$(prefix)" >>"$@" echo "exec_prefix=$(prefix)" >>"$@" echo "libdir=$(libdir)" >>"$@" echo "includedir=$(includedir)" >>"$@" echo >>"$@" echo "Name: libbiosig" >>"$@" echo "Description: Biosig library" >>"$@" echo "Version: ${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING}" >>"$@" echo "URL: http://biosig.sf.net" >>"$@" # echo "Requires: " >> "$@" echo "Requires.private: " >> "$@" echo "Cflags: $(DEFINES) " >> "$@" echo "Libs: -lbiosig $(PKG_CONFIG_LIBS)" >> "$@" echo "Libs.private: $(LDLIBS)" >> "$@" ## save2gdf, pdp2gdf %${BINEXT}: %.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) "$<" -L. -lbiosig -lstdc++ $(LDLIBS) -o "$@" physicalunits${BINEXT} : pu.c physicalunits.o $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o "$@" ifeq (1,1) biosig_fhir${BINEXT}: biosig_fhir.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) "$<" -L. -lbiosig -lstdc++ -lb64 $(LDLIBS) -o "$@" else biosig_fhir${BINEXT}: biosig_fhir.c libb64-1.2.1/src/cencode.c libbiosig.$(DLEXT) $(CC) $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Ilibb64-1.2.1/include/ "$<" libb64-1.2.1/src/cencode.c -L. -lbiosig -lstdc++ $(LDLIBS) -o "$@" endif bscs: biosig_client${BINEXT} biosig_server${BINEXT} sandbox.o biosig.o biosig_client${BINEXT}: biosig_client.c libbiosig.$(LIBEXT) biosig-network.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) biosig_client.c biosig-network.o libbiosig.$(LIBEXT) $(LDLIBS) -o "$@" biosig_server${BINEXT}: biosig_server.c libbiosig.$(LIBEXT) biosig-network.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) biosig_server.c biosig-network.o libbiosig.$(LIBEXT) $(LDLIBS) -o "$@" ############################################################# # MathLink interface to Mathematica ############################################################# mmaall: mma/sload.tm mma/sload.c $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS) -liconv" all mma : mma/biosig.exe mma/biosig.exe: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) mma win32mma: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS=$(CROSS) LDLIBS="$(LDLIBS) -liconv" win32mma win64mma: mma/biosig.tm mma/biosig.c $(MAKE) -C mma CROSS64=$(CROSS64) LDLIBS="$(LDLIBS) -liconv" win64mma ############################################################# # MEX-files for Octave and Matlab ############################################################# mex4o mex4m oct mex: MKOCTFILE="/usr/bin/mkoctfile" $(MAKE) -C mex $@ mexw32 mexw64: CROSS=$(CROSS) CROSS64=$(CROSS64) $(MAKE) -C mex $@ mexbiosig: mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz biosig4octave: mex/biosig4octave-$(BIOSIG_VERSION).src.tar.gz mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz: mex/*.cpp $(eval $@_TMP := $(shell mktemp -d /tmp/biosig.XXXXXX)/mexbiosig-$(BIOSIG_VERSION)) echo "$($@_TMP) generated"; $(shell mkdir -p $($@_TMP)/doc/) $(shell mkdir -p $($@_TMP)/inst/) $(shell mkdir -p $($@_TMP)/src/) cp mex/README $($@_TMP)/doc/ $(SED) -e 's#^Version.*$$#Version: $(BIOSIG_VERSION)#g' -e 's#^Date.*$$#Date: '$(shell date +%Y-%m-%d)'#g' mex/DESCRIPTION > $($@_TMP)/DESCRIPTION cp ../COPYING $($@_TMP)/ cp mex/*.cpp mex/Makefile $($@_TMP)/src/ ### TODO #touch $($@_TMP)/src/mex{SOPEN,SLOAD,SSAVE}.m $(TAR) -czf "$@" $($@_TMP) -rm -rf $(shell dirname $($@_TMP) ) (cd mex && ln -sf mexbiosig-$(BIOSIG_VERSION).src.tar.gz mexbiosig.src.tar.gz) echo "### In order to publish release, run ### " echo "# cp "$@" ~/L/public_html/biosig/prereleases/" mex/biosig4octave-$(BIOSIG_VERSION).src.tar.gz: mex/*.cpp $(eval $@_TMP := $(shell mktemp -d /tmp/biosig.XXXXXX)/biosig4octave-$(BIOSIG_VERSION)) echo "$($@_TMP) generated"; $(shell mkdir -p $($@_TMP)/doc/) $(shell mkdir -p $($@_TMP)/inst/) $(shell mkdir -p $($@_TMP)/src/) cp mex/README $($@_TMP)/doc/ $(SED) -e 's#^Name.*$$#Name: biosig#g' -e '/^Title/ s#mexBiosig#Biosig#g' -e 's#^Version.*$$#Version: $(BIOSIG_VERSION)#g' -e 's#^Date.*$$#Date: '$(shell date +%Y-%m-%d)'#g' mex/DESCRIPTION > $($@_TMP)/DESCRIPTION cp ../COPYING ../CITATION $($@_TMP)/ cp mex/*.cpp mex/Makefile $($@_TMP)/src/ cp -r ../biosig4matlab/* $($@_TMP)/inst/ rm $($@_TMP)/inst/t300_FeatureExtraction/hurst.m # is part of Octave Signal package -rm -r $($@_TMP)/inst/maybe-missing ### TODO #touch $($@_TMP)/src/mex{SOPEN,SLOAD,SSAVE}.m $(TAR) -czf "$@" $($@_TMP) -rm -rf $(shell dirname $($@_TMP) ) (cd mex && ln -sf biosig4octave-$(BIOSIG_VERSION).src.tar.gz biosig4octave.src.tar.gz) echo "### In order to publish release, run ### " echo "# cp "$@" ~/L/public_html/biosig/prereleases/" ############################################################# # R/sload ############################################################# R: R/sload.$(DLEXT) R/sload.$(DLEXT): R/sload.c libbiosig.$(DLEXT) $(MAKE) -C R ############################################################# # SigViewer ############################################################# sigviewer: $(PathToSigViewer)/bin/sigviewer $(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer-$(TODAY) ln -sf sigviewer-$(TODAY) bin/sigviewer $(PathToSigViewer): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer $(PathToSigViewer)/src/src.pro: $(PathToSigViewer) svn up -r 557 ../sigviewer $(PathToSigViewer)/bin/sigviewer: libbiosig.$(LIBEXT) biosig-dev.h biosig.h -$(DELETE) $(PathToSigViewer)/extern/include/* -$(COPY) biosig-dev.h biosig.h biosig2.h physicalunits.h $(PathToSigViewer)/extern/include -$(DELETE) $(PathToSigViewer)/extern/lib/lib* -$(COPY) libbiosig.a $(PathToSigViewer)/extern/lib $(SED) -i 's|\([[:space:]]*-lbiosig\)\([ #\\]*\)$$|\1 $(LDLIBS) \2|' $(PathToSigViewer)/src/src.pro echo 0.5.2-v${BIOSIG_VERSION} > $(PathToSigViewer)/src/version.txt (cd $(PathToSigViewer)/src; qmake; $(MAKE);) #-(cd $(PathToSigViewer); svn revert -R .; svn up -r 557; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.2.diff; cd src; qmake; $(MAKE);) -$(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer docs: docs/save2gdf.txt docs/mexSLOAD.txt asciidoc -d manpage docs/save2gdf.txt asciidoc -d manpage docs/mexSLOAD.txt # for backward compatibility save2scp: save2gdf save2aecg: save2gdf ############################################################# # APPLICATIONS: TTL2TRIG, FLOWMON ############################################################# ### TTL2TRIG ttltrig: bin/ttltrig bin/ttl2trig : src/ttl2trig.c gdf.o gdftime.o physicalunits.o mkdir -p ./bin $(CC) -D=WITH_BIOSIG $(DEFINE) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -Wall -Wextra -lasound $(LDLIBS) -o "$@" ### FLOWMON flowmon.o: src/flowmon2.c $(CC) -c $(DEFINES) $(CPPFLAGS) $(CFLAGS) -o "$@" "$<" flowmon: bin/flowmon bin/flowmon: flowmon.o gdf.o gdftime.o physicalunits.o mkdir -p ./bin $(CC) $(LDFLAGS) $^ $(LDLIBS) -o "$@" ############################################################# # INSTALL and DE-INSTALL ############################################################# .PHONY: clean install install-strip install_libbiosig remove install_sigviewer asc bin testscp testhl7 testbin test test6 zip clean: -$(DELETE) *~ -$(DELETE) *.a -$(DELETE) *.def -$(DELETE) *.dll -$(DELETE) *.dll.a -$(DELETE) *.i -$(DELETE) *.o -$(DELETE) *.so *.dylib -$(DELETE) *.so.* -$(DELETE) *.oct -$(DELETE) libbiosig.pc -$(DELETE) $(TEMP_DIR)t1.* -$(DELETE) win32/*.exe win32/*.o* win32/*.lib win32/*.a -$(DELETE) win64/*.exe win64/*.o* win64/*.lib win64/*.a -$(DELETE) t240/*.o* -$(DELETE) t240/libcnsfef.a -$(DELETE) libbiosig.* libbiosig${SONAMEVERSION}.* -$(DELETE) pdp2gdf save2gdf physicalunits biosig_fhir biosig2gdf -$(DELETE) mma/biosig.exe mma/*/biosig.exe -$(MAKE) -C java clean -$(MAKE) -C mex clean -$(DELETE) mex/mexbiosig*.src.tar.gz -$(DELETE) mex/biosig4octave*.src.tar.gz -$(MAKE) -C mma clean -$(MAKE) -C php clean -$(MAKE) -C perl clean -$(MAKE) -C R clean -$(MAKE) -C ruby clean -$(MAKE) -C tcl clean install_sigviewer: sigviewer install $(PathToSigViewer)/bin/release/sigviewer $(DESTDIR)$(bindir) install_ttl2trig: bin/ttl2trig install bin/ttl2trig $(DESTDIR)$(bindir) install_headers: biosig-dev.h biosig.h biosig2.h gdftime.h physicalunits.h install -d $(DESTDIR)$(includedir) install $? $(DESTDIR)$(includedir) install_libbiosig: install_libbiosig.$(DLEXT) install_libbiosig.a install_libbiosig.a: libbiosig.a libphysicalunits.a libbiosig.pc install -d $(DESTDIR)$(libdir)/pkgconfig/ install libbiosig.a $(DESTDIR)$(libdir) install libphysicalunits.a $(DESTDIR)$(libdir) install libbiosig.pc $(DESTDIR)$(libdir)/pkgconfig/ install_libbiosig.$(DLEXT): libbiosig.$(DLEXT) install -d $(DESTDIR)$(DLDIR)/pkgconfig/ install libbiosig.$(DLEXT) $(DESTDIR)$(DLDIR)/libbiosig$(FULLDLEXT) ifneq (Darwin,$(shell uname)) cd $(DESTDIR)$(DLDIR) && ln -sf libbiosig$(FULLDLEXT) libbiosig.$(DLEXT) endif -ldconfig install: install_libbiosig.$(DLEXT) install_libbiosig.a install_headers install_tools install-strip: install -strip -x $(DESTDIR)$(libdir)/libbiosig.a -strip -x $(DESTDIR)$(libdir)/libphysicalunits.a -strip -x $(DESTDIR)$(libdir)/libbiosig$(FULLDLEXT) install_tools: tools doc/save2gdf.1 install -d $(DESTDIR)$(bindir) install ${BIN_OBJECTS} $(DESTDIR)$(bindir) install heka2itx $(DESTDIR)$(bindir) install rec2bin $(DESTDIR)$(bindir) install bin2rec $(DESTDIR)$(bindir) install save2aecg $(DESTDIR)$(bindir) install save2scp $(DESTDIR)$(bindir) mkdir -p $(DESTDIR)$(mandir)/man1 install doc/*.1 $(DESTDIR)$(mandir)/man1 #install libbiosig.man $(mandir) #$(MAKE) install_sigviewer #$(MAKE) install_octave uninstall_tools: ${RM} $(addprefix $(DESTDIR)$(bindir)/,$(BIN_OBJECTS)) ${RM} $(DESTDIR)$(bindir)/{heka2itx,bin2rec,rec2bin,save2aecg,save2scp} ${RM} $(addprefix $(DESTDIR)$(mandir)/man1/,$(addsuffix .1,$(BIN_OBJECTS))) ${RM} $(DESTDIR)$(mandir)/man1/{heka2itx,bin2rec,rec2bin,save2aecg,save2scp}.1 ### Install mexbiosig for Octave install_mexbiosig install_octave: mex/mexbiosig-$(BIOSIG_VERSION).src.tar.gz /usr/bin/octave --no-gui --eval "pkg install $<" uninstall_mexbiosig: -/usr/bin/octave --no-gui --eval "pkg uninstall mexbiosig" ### Install mexbiosig for Matlab and Octave install_mex: $(MAKE) -C mex install uninstall_mex: $(MAKE) -C mex uninstall uninstall remove: uninstall_mexbiosig uninstall_tools -$(DELETE) $(DESTDIR)$(bindir)/ttl2trig #-$(DELETE) $(DESTDIR)$(bindir)/rec2bin #-$(DELETE) $(DESTDIR)$(bindir)/bin2rec -$(DELETE) $(DESTDIR)$(bindir)/sigviewer -$(DELETE) $(DESTDIR)$(bindir)/eventcodes.txt -$(DELETE) $(DESTDIR)$(includedir)/biosig.h -$(DELETE) $(DESTDIR)$(includedir)/biosig-dev.h -$(DELETE) $(DESTDIR)$(includedir)/biosig2.h -$(DELETE) $(DESTDIR)$(includedir)/gdftime.h -$(DELETE) $(DESTDIR)$(includedir)/physicalunits.h -$(DELETE) $(DESTDIR)$(libdir)/libbiosig.* -$(DELETE) $(DESTDIR)$(libdir)/libbiosig${SONAMEVERSION}.* -$(DELETE) $(DESTDIR)$(libdir)/libphysicalunits.* -$(DELETE) $(DESTDIR)$(libdir)/pkgconfig/libbiosig.pc -ldconfig ############################################################# # Testing ############################################################# testtms: $(DATA_DIR)t1.scp # ./save2gdf -V8 ~/data/test/tms32/small_test.float32.log ./save2gdf -f=TMSi $(DATA_DIR)t1.scp $(TEMP_DIR)t2.log cat $(TEMP_DIR)t2.log fetchdata: $(TEMP_DIR)Osas2002plusQRS.edf $(DATA_DIR)Newtest17-2048.bdf $(TEMP_DIR)SC4001EC-Hypnogram.edf $(TEMP_DIR)scp/redred/PFE103.scp: # scp example data sets #wget -q -P$(DATA_DIR) http://www.openecg.net/ECGsamples.zip #wget -q -P$(DATA_DIR) http://www.openecg.net/ECGsamplesc.zip unzip -u $(DATA_DIR)ECGsamples.zip "scp*.zip" -d $(TEMP_DIR) unzip -u $(DATA_DIR)ECGsamplesc.zip "scp*.zip" -d $(TEMP_DIR) mkdir -p $(TEMP_DIR)scp/high mkdir -p $(TEMP_DIR)scp/highc mkdir -p $(TEMP_DIR)scp/redred mkdir -p $(TEMP_DIR)scp/redredc unzip -u $(TEMP_DIR)scp_high.zip -d $(TEMP_DIR)scp/high unzip -u $(TEMP_DIR)scp_highc.zip -d $(TEMP_DIR)scp/highc unzip -u $(TEMP_DIR)scp_redred.zip -d $(TEMP_DIR)scp/redred unzip -u $(TEMP_DIR)scp_redredc.zip -d $(TEMP_DIR)scp/redredc rm -rf $(TEMP_DIR)ECGsamples*.zip rm -rf $(TEMP_DIR)scp*.zip $(DATA_DIR)t1.scp: $(TEMP_DIR)scp/redred/PFE103.scp $(COPY) "$<" "$@" touch "$@" #"$(DATA_DIR)aECG Release 1 Schema and Example.zip": $(DATA_DIR)2003-12\ Schema/example/Example\ aECG.xml: # HL7aECG example data set wget -q -P$(DATA_DIR) https://www.hl7.org/documentcenter/public/wg/rcrim/annecg/aECG%20Release%201%20Schema%20and%20Example.zip unzip -u $(DATA_DIR)"aECG Release 1 Schema and Example.zip" -d $(DATA_DIR) $(TEMP_DIR)t1.hl7: $(DATA_DIR)2003-12\ Schema/example/Example\ aECG.xml $(COPY) "$<" "$@" #rm -rf "$(TEMP_DIR)aECG Release 1 Schema and Example.zip" #rm -rf "$(TEMP_DIR)2003-12 Schema" $(TEMP_DIR)Osas2002plusQRS.edf: # EDF+ example data set wget -q -P$(TEMP_DIR) http://www.edfplus.info/downloads/files/osas.zip unzip -u "$(TEMP_DIR)osas.zip" -d $(TEMP_DIR) $(TEMP_DIR)SC4001EC-Hypnogram.edf: wget -q -P$(TEMP_DIR) https://www.physionet.org/files/sleep-edfx/1.0.0/sleep-cassette/SC4001EC-Hypnogram.edf $(DATA_DIR)t1.edf: $(TEMP_DIR)Osas2002plusQRS.edf $(COPY) "$<" "$@" touch "$@" asc: save2gdf ./save2gdf -f=ASCII t0.xxx $(TEMP_DIR)t1.asc bin: save2gdf ./save2gdf -f=BIN t0.xxx $(TEMP_DIR)t1.bin testjson: save2gdf $(DATA_DIR)t1.edf ./save2gdf -JSON t0.xxx |tee $(TEMP_DIR)t1.xxx.json ./save2gdf -JSON $(TEMP_DIR)t1.edf |tee $(TEMP_DIR)t1.edf.json testbin: save2gdf $(DATA_DIR)t1.edf ./save2gdf -f=BIN $(DATA_DIR)t1.edf $(TEMP_DIR)t1.hdr ./save2gdf -f=BIN $(TEMP_DIR)t1.hdr $(TEMP_DIR)t2.hdr ./save2gdf -f=GDF $(TEMP_DIR)t2.hdr $(TEMP_DIR)t2.gdf testedf: save2gdf $(TEMP_DIR)Osas2002plusQRS.edf $(TEMP_DIR)SC4001EC-Hypnogram.edf ./save2gdf -f=GDF $(TEMP_DIR)Osas2002plusQRS.edf $(TEMP_DIR)Osas2002plusQRS.gdf ./save2gdf -JSON $(TEMP_DIR)Osas2002plusQRS.edf | json_pp ./save2gdf -JSON $(TEMP_DIR)SC4001EC-Hypnogram.edf | json_pp testscp: $(DATA_DIR)t1.scp save2gdf # test converting SCP data ./save2gdf -f=HL7 "$<" $(TEMP_DIR)t1.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.hl7 $(TEMP_DIR)t1.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.hl7.gdf.scp $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7.scp ./save2gdf -f=GDF "$<" $(TEMP_DIR)t1.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf $(TEMP_DIR)t1.scp.gdf.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.hl7.scp $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf.scp testscp2: $(DATA_DIR)t1.scp find test/scp -iname '*.scp' -exec ./save2gdf -V0 {} /dev/null \; testscp3: $(DATA_DIR)t1.scp find test/scp -iname '*.scp' -exec ./save2gdf -f=SCP3 -V0 {} {}.scp3 \; testhl7: $(TEMP_DIR)t1.hl7 save2gdf # test converting HL7aECG data ./save2gdf -f=GDF "$<" $(TEMP_DIR)t1.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf $(TEMP_DIR)t1.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7 ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf.scp.hl7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf.hl7 ./save2gdf -f=SCP "$<" $(TEMP_DIR)t1.hl7.scp ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp $(TEMP_DIR)t1.hl7.scp.gdf ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7 ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp.gdf.hl7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp.hl7 test: $(DATA_DIR)t1.scp save2scp save2aecg save2gdf # biosig4python # includes test for on-the-fly compression and decompression ./save2gdf -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.gdf ./save2gdf -f=SCP -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.scp ./save2gdf -f=HL7 -z $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp.hl7 ./save2gdf $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.gdf ./save2gdf $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.gdf ./save2gdf $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.gdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.scp ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.scp ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.hl7 ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.hl7 ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.hl7 # python test0/test.py ./biosig2gdf $(DATA_DIR)t1.scp | md5sum zip: $(DATA_DIR)t1.scp save2gdf # test for on-the-fly compression and decompression # on-the-fly compression of output file ./save2gdf -z -f=GDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.gdf ./save2gdf -z -f=GDF1 $(DATA_DIR)t1.scp $(TEMP_DIR)t1.gd1 ./save2gdf -z -f=EDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.edf ./save2gdf -z -f=BDF $(DATA_DIR)t1.scp $(TEMP_DIR)t1.bdf ./save2gdf -z -f=SCP $(DATA_DIR)t1.scp $(TEMP_DIR)t1.scp ./save2gdf -z -f=CFWB $(DATA_DIR)t1.scp $(TEMP_DIR)t1.cfw ./save2gdf -z -f=MFER $(DATA_DIR)t1.scp $(TEMP_DIR)t1.mwf ./save2gdf -z -f=HL7 $(DATA_DIR)t1.scp $(TEMP_DIR)t1.hl7 gzip -c $(DATA_DIR)t1.scp >$(TEMP_DIR)t1.scp.gz # on-the-fly decompression of input file ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.hl7 ./save2gdf -f=MFER $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.mwf ./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t1.cfw test6: $(DATA_DIR)t1.scp save2gdf $(COPY) $(DATA_DIR)t1.scp $(TEMP_DIR)t0.xxx #test7: $(DATA_DIR)t1.edf save2gdf #$(COPY) $(DATA_DIR)t1.edf $(TEMP_DIR)t0.xxx ./save2gdf -z -f=GDF1 $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.gd1 ./save2gdf -z -f=GDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.gdf ./save2gdf -z -f=EDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.edf ./save2gdf -z -f=BDF $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.bdf ./save2gdf -z -f=SCP $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.hl7 # -z not supported for HL7 gzip -f $(TEMP_DIR)t1.hl7 ./save2gdf -z -f=CFWB $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.cfw ./save2gdf -z -f=MFER $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.mwf ./save2gdf -f=BVA $(TEMP_DIR)t0.xxx $(TEMP_DIR)t1.bva ./save2gdf -f=GDF1 $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.gd1.gz $(TEMP_DIR)t2.gd1.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.gdf.gz $(TEMP_DIR)t2.gdf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.edf.gz $(TEMP_DIR)t2.edf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.bdf.gz $(TEMP_DIR)t2.bdf.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz $(TEMP_DIR)t2.scp.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.hl7 ./save2gdf -f=CFWB $(TEMP_DIR)t1.hl7.gz $(TEMP_DIR)t2.hl7.cfw ./save2gdf -f=GDF1 $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.cfw.gz $(TEMP_DIR)t2.cfw.hl7 ./save2gdf -f=GDF1 $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.gd1 ./save2gdf -f=GDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.gdf ./save2gdf -f=EDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.edf ./save2gdf -f=BDF $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.bdf ./save2gdf -f=SCP $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.scp ./save2gdf -f=HL7 $(TEMP_DIR)t1.mwf.gz $(TEMP_DIR)t2.mwf.hl7 $(DATA_DIR)Newtest17-2048.bdf : $(DATA_DIR)BDFtestfiles.zip unzip -u "$<" -d $(DATA_DIR) testbdf : $(DATA_DIR)Newtest17-2048.bdf ./save2gdf -V4 "$<" | awk '/(NoChannels|NRec|Fs|Events\/Annotations):/ { print $$2 } ' testpybdf : $(DATA_DIR)Newtest17-2048.bdf $(PYTHON) python/demo2.py $(PYTHON) python/demo2.py $(DATA_DIR)*-256.bdf $(PYTHON) python/example.py $(DATA_DIR)*-256.bdf 256 $(PYTHON) python/example.py $(DATA_DIR)*-2048.bdf 2048 $(DATA_DIR)BDFtestfiles.zip : wget -P$(DATA_DIR) http://www.biosemi.com/download/BDFtestfiles.zip .PHONY: stat stat: @echo 'TODO/FIXME: '; @grep -ri '\bTODO\b' *.c *.h *.i t210/*.c t210/*.h |grep -v '\.svn' |wc -l; @grep -ri '\bFIXME\b' *.c *.h *.i t210/*.c t210/*.h |grep -v '\.svn' |wc -l; test_physicalunits : units.i physicalunits.c physicalunits.h gcc -D=TEST_PHYSDIMTABLE_PERFORMANCE -D=WITH_PTHREAD physicalunits.c -o test_physicalunits ./test_physicalunits @echo '--- end of test_physicalunits ---' testcfs : $(DATA_DIR_CFS) save2gdf -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/Actions.CFS -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/example.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/Leak.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/NAME_0AA.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/SCANexam.CFS -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/TEST.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)BaseDemo/TRIAL0AA.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)100118s1AB.dat -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)100121s1AF.dat -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.000.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.001.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.002.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)Signal/1_23456.LAST.cfs -./save2gdf $(VERBOSE) $(DATA_DIR_CFS)/1617K2AA.DAT biosig-2.3.3/biosig4c++/test0/0000775000175000017500000000000014105434233016046 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/test0/test01.m0000664000175000017500000000360114105434233017344 0ustar schloeglschloegl%%% Octave script for testing BioSig4C++:SAVE2GDF % $Id: test01.m,v 1.3 2007-08-30 12:41:17 schloegl Exp $ % Copyright (c) 2007 by Alois Schloegl % This file is part of the biosig project http://biosig.sf.net/ % 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 % of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. pfad=pwd; cd .. [s,m]=unix('make'); %% compile save2gdf if (s>0), fprintf(1,'this script must be started from within .../biosig4c++/test0/ directory!\n'); end; [s,m]=unix('make testhl7'); %% run test for HL7 file [s,m]=unix('make testscp'); %% run test for SCP file fn = dir('/tmp/t1.*'); clear s HDR for k=1:length(fn), try [s{k},H]=sload(fullfile('/tmp',fn(k).name),0,'UCAL','ON','OVERFLOWDETECTION','OFF'); %[H]=sopen(fullfile('/tmp',fn(k).name),'r',0); %[H]=sopen(fn(k).name,'r',0); %H.FLAG.UCAL=1; %H.FLAG.OVERFLOWDETECTION=0; %[s{k},H]=sread(H); %H = sclose(H); HDR{k}=H; [t,scale]=physicalunits(H.PhysDimCode); s{k} = s{k}*diag(scale); r = rms(s{k}); r1 = std(s{k}); R(k,1:length(r1))=r1; fprintf(1,'%02i %s: [%s] %e %e %e %e\n',k,H.FileName,H.PhysDim{1},r(1:4)); catch ; end; end; for k=1:length(HDR) try fprintf(1,'%02i %-32s: [%s] %e %e %e %e\n',k, HDR{k}.FileName,HDR{k}.PhysDim{1},R(k,1:4)); catch end; end; cd(pfad); biosig-2.3.3/biosig4c++/test0/test_ttl2trig.sh0000775000175000017500000000027014105434233021216 0ustar schloeglschloegl#!/bin/bash # This file is for testing ttl2trig # Copyright 2011 Alois Schloegl, IST Austria ../bin/ttl2trig -c "date" -i hw:2,0 --chan=0 --Threshold=.25 biosig-2.3.3/biosig4c++/test0/test.py0000664000175000017500000000054514105434233017403 0ustar schloeglschloeglimport pylab import numpy import biosig HDR=biosig.sopen('/home/schloegl/data/test/gdf/sample.gdf','r',biosig.constructHDR(0,0)); #for i in range(HDR.NS): # HDR.CHANNEL[i].OnOff = 0 #HDR.CHANNEL[0].OnOff = 1 data = biosig.sread(0, HDR.NRec, HDR) biosig.sclose(HDR) #biosig.destructHDR(HDR) pylab.ion(); pylab.plot(numpy.transpose(data)) pylab.show(); biosig-2.3.3/biosig4c++/test0/gztest.c0000664000175000017500000000471714105434233017543 0ustar schloeglschloegl/* $Id: gztest.c,v 1.2 2007-08-31 13:18:15 schloegl Exp $ Copyright (C) 2007 Alois Schloegl This function is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../biosig.h" #include int main(int argc, char **argv){ HDRTYPE HDR, *hdr; CHANNEL_TYPE* cp; size_t count; uint16_t numopt = 0, k; time_t T0; char *source, *dest; enum FileFormat TARGET_TYPE=GDF; // type of file format int COMPRESSION_LEVEL=0; uint8_t mem[100000]; char tmp[100], p[10]; source=argv[1]; hdr = &HDR; hdr->TYPE = unknown; hdr->FILE.COMPRESSION = 0; hdr->FileName = source; hdr = FOPEN(hdr,"rb"); count = FREAD(mem,1,100000,hdr); hdr->AS.Header1 = mem; hdr = getfiletype(hdr); FCLOSE(hdr); fprintf(stdout,"1: %s %i %i %i %i %i %i %i %i \n",hdr->FileName, count,hdr->TYPE,unknown,GDF,GZIP,SCP_ECG,HL7aECG,BDF); hdr->FILE.COMPRESSION = 0; hdr->FileName = source; hdr = FOPEN(hdr,"rb"); count = FREAD(mem,1,100000,hdr); hdr->AS.Header1 = mem; hdr = getfiletype(hdr); FCLOSE(hdr); fprintf(stdout,"2: %s %i %i %i %i %i %i %i %i \n",hdr->FileName, count,hdr->TYPE,unknown,GDF,GZIP,SCP_ECG,HL7aECG,BDF); /* hdr->FILE.COMPRESSION = 0; hdr->FileName = "out0.fil"; hdr = FOPEN(hdr,"wb"); count = FWRITE(mem,1,count,hdr); FCLOSE(hdr); hdr->FILE.COMPRESSION = 0; hdr->FileName = "out00.fil"; hdr = FOPEN(hdr,"wb"); count = FWRITE(mem,1,count,hdr); FCLOSE(hdr); for (k=0;k<10;k++) { hdr->FILE.COMPRESSION = 1; strcpy(tmp,"out10.fil"); *(tmp+4)=k+48; strncpy(p,"wb",5); p[strlen(p)]=k+48; hdr->FileName = tmp; hdr = FOPEN(hdr,p); count = FWRITE(mem,1,count,hdr); FCLOSE(hdr); } */ } biosig-2.3.3/biosig4c++/test0/sandbox.c0000664000175000017500000005076314105434233017663 0ustar schloeglschloegl/* sandbox is used for development and under constraction work The functions here are either under construction or experimental. The functions will be either fixed, then they are moved to another place; or the functions are discarded. Do not rely on the interface in this function Copyright (C) 2008-2014 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include "../biosig.h" /************************************************************************* use DCMTK for reading DICOM files *************************************************************************/ #ifdef WITH_DCMTK #undef WITH_DICOM // disable internal DICOM implementation #undef WITH_GDCM // disable interface to GDCM #ifdef __cplusplus extern "C" { #endif int sopen_dcmtk_read(HDRTYPE* hdr); int sopen_dicom_read(HDRTYPE* hdr) { return sopen_dcmtk_read(hdr); } #ifdef __cplusplus } #endif #endif // DCMTK #ifdef HAVE_HDF #include #endif #ifdef HAVE_MATIO #include #endif /************************************************************************* use GDCM for reading DICOM files *************************************************************************/ #ifdef WITH_GDCM #undef WITH_DICOM #include "gdcmReader.h" //#include "gdcmImageReader.h" //#include "gdcmWriter.h" #include "gdcmDataSet.h" #include "gdcmAttribute.h" //#include "gdcmCommon.h" //#include "gdcmPreamble.h" #include "gdcmFile.h" #include "gdcmFileMetaInformation.h" #include "gdcmWaveform.h" /* This is the list from gdcmconv.cxx #include "gdcmReader.h" #include "gdcmFileDerivation.h" #include "gdcmAnonymizer.h" #include "gdcmVersion.h" #include "gdcmPixmapReader.h" #include "gdcmPixmapWriter.h" #include "gdcmWriter.h" #include "gdcmSystem.h" #include "gdcmFileMetaInformation.h" #include "gdcmDataSet.h" #include "gdcmIconImageGenerator.h" #include "gdcmAttribute.h" #include "gdcmSequenceOfItems.h" #include "gdcmUIDGenerator.h" #include "gdcmImage.h" #include "gdcmImageChangeTransferSyntax.h" #include "gdcmImageApplyLookupTable.h" #include "gdcmImageFragmentSplitter.h" #include "gdcmImageChangePlanarConfiguration.h" #include "gdcmImageChangePhotometricInterpretation.h" #include "gdcmFileExplicitFilter.h" #include "gdcmJPEG2000Codec.h" #include "gdcmJPEGCodec.h" #include "gdcmJPEGLSCodec.h" #include "gdcmSequenceOfFragments.h" */ int sopen_dicom_read(HDRTYPE* hdr) { fprintf(stdout,"%s ( line %d): GDCM is used to read dicom files.\n",__func__,__LINE__); gdcm::Reader reader; const gdcm::DataElement *de; reader.SetFileName( hdr->FileName ); if ( !reader.Read() ) { fprintf(stdout,"%s (line %i) \n",__FILE__,__LINE__); return 1; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); gdcm::File &file = reader.GetFile(); gdcm::FileMetaInformation &header = file.GetHeader(); if ( header.FindDataElement( gdcm::Tag(0x0002, 0x0013 ) ) ) const gdcm::DataElement &de = header.GetDataElement( gdcm::Tag(0x0002, 0x0013) ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); gdcm::DataSet &ds = file.GetDataSet(); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); if ( header.FindDataElement( gdcm::Tag(0x0002, 0x0010 ) ) ) de = &header.GetDataElement( gdcm::Tag(0x0002, 0x0010) ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0002,0x0010> len=%i\n",__FILE__,__LINE__,de->GetByteValue() ); if (0) { gdcm::Attribute<0x28,0x100> at; at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); if( at.GetValue() != 8 ) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0002,0x0010> GetValue\n",__FILE__,__LINE__ ); return 1; } at.SetValue( 32 ); ds.Replace( at.GetAsDataElement() ); } { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0008,0x002a>\n",__FILE__,__LINE__); gdcm::Attribute<0x0008,0x002a> at; ds.GetDataElement( at.GetTag() ); at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0008,0x002a>\n",__FILE__,__LINE__); // fprintf(stdout,"DCM: [0008,002a]: %i %p\n", at.GetNumberOfValues(), at.GetValue()); } { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0008,0x0023>\n",__FILE__,__LINE__); gdcm::Attribute<0x0008,0x0023> at; ds.GetDataElement( at.GetTag() ); at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x0008,0x0023>\n",__FILE__,__LINE__); } if (1) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x0005>\n",__FILE__,__LINE__); gdcm::Attribute<0x003a,0x0005> NumberOfWaveformChannels; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x0005> %i\n",__FILE__,__LINE__, NumberOfWaveformChannels.GetValue()); // ds.GetDataElement( NumberOfWaveformChannels.GetTag() ); // NumberOfWaveformChannels.SetFromDataElement( ds.GetDataElement( NumberOfWaveformChannels.GetTag() ) ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x0005> %i\n",__FILE__,__LINE__, NumberOfWaveformChannels.GetValue()); } { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x0010>\n",__FILE__,__LINE__); gdcm::Attribute<0x003a,0x0010> NumberOfWaveformSamples; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x0010> %i\n",__FILE__,__LINE__, NumberOfWaveformSamples.GetValue()); // fprintf(stdout,"DCM: [0008,0023]: %i %p\n",at.GetNumberOfValues(), at.GetValue()); } gdcm::Attribute<0x003a,0x001a> SamplingFrequency; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): attr <0x003a,0x001a> %f\n",__FILE__,__LINE__, SamplingFrequency.GetValue()); return 0; } #endif #ifdef __cplusplus extern "C" { #endif #ifdef WITH_HDF int sopen_hdf5(HDRTYPE* hdr) { /* file hdr->FileName is already opened and hdr->HeadLen bytes are read These are available from hdr->AS.Header. ToDo: populate hdr */ size_t count = hdr->HeadLen; fprintf(stdout,"Trying to read HDF data using \"%s\"\n",H5_VERS_INFO); ifclose(hdr); return(-1); } #endif #ifdef HAVE_MATIO int sopen_matlab(HDRTYPE* hdr) { /* file hdr->FileName is already opened and hdr->HeadLen bytes are read These are available from hdr->AS.Header. ToDo: populate hdr sanity checks memory leaks */ ifclose(hdr); //size_t count = hdr->HeadLen; fprintf(stdout, "Trying to read Matlab data using MATIO v%i.%i.%i\n", MATIO_MAJOR_VERSION, MATIO_MINOR_VERSION, MATIO_RELEASE_LEVEL); mat_t *matfile = Mat_Open(hdr->FileName, MAT_ACC_RDONLY); matvar_t *EEG=NULL, *pnts=NULL, *nbchan=NULL, *trials=NULL, *srate=NULL, *data=NULL, *chanlocs=NULL, *event=NULL; if (matfile != NULL) { EEG = Mat_VarRead(matfile, "EEG" ); if (EEG != NULL) { Mat_VarReadDataAll(matfile, EEG ); pnts = Mat_VarGetStructField(EEG, "pnts", BY_NAME, 0); nbchan = Mat_VarGetStructField(EEG, "nbchan", BY_NAME, 0); trials = Mat_VarGetStructField(EEG, "trials", BY_NAME, 0); srate = Mat_VarGetStructField(EEG, "srate", BY_NAME, 0); data = Mat_VarGetStructField(EEG, "data", BY_NAME, 0); chanlocs = Mat_VarGetStructField(EEG, "chanlocs", BY_NAME, 0); event = Mat_VarGetStructField(EEG, "event", BY_NAME, 0); hdr->NS = *(double*)(nbchan->data); hdr->SPR = *(double*)(pnts->data); hdr->NRec= *(double*)(trials->data); hdr->SampleRate = *(double*)(srate->data); /* TODO CB hdr->NRec = ; hdr->SPR = ; hdr->T0 = 0; // Unknown; uint16_t gdftyp = ; 16: float; 17: double */ hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); size_t k; for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; sprintf(hc->Label,"#%2d",k+1); hc->SPR = hdr->SPR; /* TODO CB hc->GDFTYP = gdftyp; hc->Transducer[0] = '\0'; hc->LowPass = ; hc->HighPass = ; hc->Notch = ; // unknown hc->PhysMax = ; hc->DigMax = ; hc->PhysMin = ; hc->DigMin = ; hc->Cal = 1.0; hc->Off = 0.0; hc->OnOff = 1; hc->PhysDimCode = 4275; // uV hc->LeadIdCode = 0; hc->bi = k*GDFTYP_BITS[gdftyp]>>3; // TODO AS */ } size_t sz = hdr->NS*hdr->SPR*hdr->NRec*GDFTYP_BITS[gdftyp]>>3; hdr->AS.rawdata = realloc(hdr->AS.rawdata, sz); /* TODO CB memcpy(hdr->AS.rawdata,...,sz); */ hdr->EVENT.N = 0; // TODO CB hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, hdr->EVENT.N*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, hdr->EVENT.N*sizeof(*hdr->EVENT.CHN)); for (k=0; kEVENT.N; k++) { /* TODO CB hdr->EVENT.TYP[k] = FreeTextEvent(hdr, k, annotation) hdr->EVENT.POS[k] = hdr->EVENT.CHN[k] = 0; hdr->EVENT.DUR[k] = 0; */ } hdr->AS.bpb = hdr->NS*2; hdr->FLAG.OVERFLOWDETECTION = 0; // BKR does not support automated overflow and saturation detection Mat_VarPrint(pnts, 1); Mat_VarPrint(nbchan, 1); Mat_VarPrint(trials, 1); Mat_VarPrint(srate, 1); //Mat_VarPrint(data, 1); //Mat_VarPrint(chanlocs, 1); //Mat_VarPrint(event, 1); Mat_VarFree(EEG); } Mat_Close(matfile); } return (0); } #endif int sopen_fiff_read(HDRTYPE* hdr) { /* TODO: implement FIFF support define all fields in hdr->.... currently only the first hdr->HeadLen bytes are stored in hdr->AS.Header, all other fields still need to be defined. */ size_t k; /* define basic header */ hdr->NS = 0; // hdr->.... fill in all /* define channel headers */ hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; } /* define event table */ hdr->EVENT.N = 0; //reallocEventTable(hdr, 0); /* report status header and return */ hdr2ascii(hdr,stdout,4); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "FIFF support not completed"); return 0; } int sopen_unipro_read(HDRTYPE* hdr) { hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); char *Header1 = (char*)hdr->AS.Header; struct tm t0; char tmp[5]; memset(tmp,0,5); strncpy(tmp,Header1+0x9c,2); t0.tm_mon = atoi(tmp)-1; strncpy(tmp,Header1+0x9e,2); t0.tm_mday = atoi(tmp); strncpy(tmp,Header1+0xa1,2); t0.tm_hour = atoi(tmp); strncpy(tmp,Header1+0xa3,2); t0.tm_min = atoi(tmp); strncpy(tmp,Header1+0xa5,2); t0.tm_sec = atoi(tmp); strncpy(tmp,Header1+0x98,4); t0.tm_year = atoi(tmp)-1900; hdr->T0 = tm_time2gdf_time(&t0); memset(tmp,0,5); strncpy(tmp,Header1+0x85,2); t0.tm_mday = atoi(tmp); strncpy(tmp,Header1+0x83,2); t0.tm_mon = atoi(tmp)-1; strncpy(tmp,Header1+0x7f,4); t0.tm_year = atoi(tmp)-1900; hdr->Patient.Birthday = tm_time2gdf_time(&t0); // filesize = leu32p(hdr->AS.Header + 0x24); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "UNIPRO not supported"); return(0); } /************************************************************************* use internal implementation for reading DICOM files *************************************************************************/ #ifdef WITH_DICOM int sopen_dicom_read(HDRTYPE* hdr) { fprintf(stdout,"home-made parser is used to read dicom files.\n"); char FLAG_implicite_VR = 0; int EndOfGroup2=-1; if (hdr->HeadLen<132) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 132); hdr->HeadLen += ifread(hdr->AS.Header+hdr->HeadLen, 1, 132-hdr->HeadLen, hdr); } size_t count = hdr->HeadLen; size_t pos = 128; while (!hdr->AS.Header[pos] && (pos<128)) pos++; if ((pos==128) && !memcmp(hdr->AS.Header+128,"DICM",4)) { // FLAG_implicite_VR = 0; pos = 132; } else pos = 0; size_t bufsiz = 16384; while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, count+bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz, hdr); bufsiz *= 2; } ifclose(hdr); hdr->AS.Header[count] = 0; uint16_t nextTag[2]; struct tm T0; char flag_t0=0; char flag_ignored; uint32_t Tag; uint32_t Len; nextTag[0] = *(uint16_t*)(hdr->AS.Header+pos); nextTag[1] = *(uint16_t*)(hdr->AS.Header+pos+2); while (pos < count) { if ((__BYTE_ORDER == __BIG_ENDIAN) ^ !hdr->FILE.LittleEndian) { // swapping required Tag = (((uint32_t)bswap_16(nextTag[0])) << 16) + bswap_16(nextTag[1]); pos += 4; if (FLAG_implicite_VR) { Len = bswap_32(*(uint32_t*)(hdr->AS.Header+pos)); pos += 4; } else { // explicite_VR if (pos+4 > count) break; if (memcmp(hdr->AS.Header+pos,"OB",2) && memcmp(hdr->AS.Header+pos,"OW",2) && memcmp(hdr->AS.Header+pos,"OF",2) && memcmp(hdr->AS.Header+pos,"SQ",2) && memcmp(hdr->AS.Header+pos,"UT",2) && memcmp(hdr->AS.Header+pos,"UN",2) ) { Len = bswap_16(*(uint16_t*)(hdr->AS.Header+pos+2)); pos += 4; } else { Len = bswap_32(*(uint32_t*)(hdr->AS.Header+pos+4)); pos += 8; } } } else { // no swapping Tag = (((uint32_t)nextTag[0]) << 16) + nextTag[1]; pos += 4; if (FLAG_implicite_VR) { Len = *(uint32_t*)(hdr->AS.Header+pos); pos += 4; } else { // explicite_VR if (pos+4 > count) break; if (memcmp(hdr->AS.Header+pos,"OB",2) && memcmp(hdr->AS.Header+pos,"OW",2) && memcmp(hdr->AS.Header+pos,"OF",2) && memcmp(hdr->AS.Header+pos,"SQ",2) && memcmp(hdr->AS.Header+pos,"UT",2) && memcmp(hdr->AS.Header+pos,"UN",2) ) { Len = *(uint16_t*)(hdr->AS.Header+pos+2); pos += 4; } else { Len = *(uint32_t*)(hdr->AS.Header+pos+4); pos += 8; } } } /* backup next tag, this allows setting of terminating 0 */ if (pos+Len < count) { nextTag[0] = *(uint16_t*)(hdr->AS.Header+pos+Len); nextTag[1] = *(uint16_t*)(hdr->AS.Header+pos+Len+2); hdr->AS.Header[pos+Len] = 0; } flag_ignored = 0; if (VERBOSE_LEVEL>8) fprintf(stdout," %6x: (%04x,%04x) %8d\t%s\n",pos,Tag>>16,Tag&0x0ffff,Len,(char*)hdr->AS.Header+pos); switch (Tag) { /* elements of group 0x0002 use always Explicite VR little Endian encoding */ case 0x00020000: { int c = 0; if (!memcmp(hdr->AS.Header+pos-4,"UL",2)) c = leu32p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-4,"SL",2)) c = lei32p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-4,"US",2)) c = leu16p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-4,"SS",2)) c = lei16p(hdr->AS.Header+pos); else { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %i<%i %i>\n",__FILE__,__LINE__,pos,hdr->AS.Header[pos-8],hdr->AS.Header[pos-7]); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "DICOM (0002,0000): unsupported"); } EndOfGroup2 = c + pos; break; } case 0x00020001: break; case 0x00020002: { hdr->NS = 1; char *t = (char*)hdr->AS.Header+pos; while (isspace(*t)) t++; // deblank char *ct[] = { "1.2.840.10008.5.1.4.1.1.9.1.1", "1.2.840.10008.5.1.4.1.1.9.1.2", "1.2.840.10008.5.1.4.1.1.9.1.3", "1.2.840.10008.5.1.4.1.1.9.2.1", "1.2.840.10008.5.1.4.1.1.9.3.1", "1.2.840.10008.5.1.4.1.1.9.4.1" }; if (!strcmp(t,*ct)) hdr->NS = 12; break; } case 0x00020003: break; case 0x00020010: { char *t = (char*)hdr->AS.Header+pos; while (isspace(*t)) t++; // deblank char *ct[] = { "1.2.840.10008.1.2", "1.2.840.10008.1.2.1", "1.2.840.10008.1.2.1.99", "1.2.840.10008.1.2.2" }; if (!strcmp(t,*ct)) FLAG_implicite_VR = 1; else if (!strcmp(t,*ct+1)) FLAG_implicite_VR = 0; else if (!strcmp(t,*ct+3)) FLAG_implicite_VR = 1; break; } case 0x00080020: // StudyDate case 0x00080023: // ContentDate { hdr->AS.Header[pos+8]=0; T0.tm_mday = atoi((char*)hdr->AS.Header+pos+6); hdr->AS.Header[pos+6]=0; T0.tm_mon = atoi((char*)hdr->AS.Header+pos+4)-1; hdr->AS.Header[pos+4]=0; T0.tm_year = atoi((char*)hdr->AS.Header+pos)-1900; flag_t0 |= 1; break; } case 0x0008002a: // AcquisitionDateTime { struct tm t0; hdr->AS.Header[pos+14]=0; t0.tm_sec = atoi((char*)hdr->AS.Header+pos+12); hdr->AS.Header[pos+12]=0; t0.tm_min = atoi((char*)hdr->AS.Header+pos+10); hdr->AS.Header[pos+10]=0; t0.tm_hour = atoi((char*)hdr->AS.Header+pos+8); hdr->AS.Header[pos+8]=0; t0.tm_mday = atoi((char*)hdr->AS.Header+pos+6); hdr->AS.Header[pos+6]=0; t0.tm_mon = atoi((char*)hdr->AS.Header+pos+4)-1; hdr->AS.Header[pos+4]=0; t0.tm_year = atoi((char*)hdr->AS.Header+pos)-1900; hdr->T0 = tm_time2gdf_time(&t0); break; } case 0x00080030: // StudyTime case 0x00080033: // ContentTime { hdr->AS.Header[pos+6]=0; T0.tm_sec = atoi((char*)hdr->AS.Header+pos+4); hdr->AS.Header[pos+4]=0; T0.tm_min = atoi((char*)hdr->AS.Header+pos+2); hdr->AS.Header[pos+2]=0; T0.tm_hour = atoi((char*)hdr->AS.Header+pos); flag_t0 |= 2; break; } case 0x00080070: // Manufacturer { strncpy(hdr->ID.Manufacturer._field,(char*)hdr->AS.Header+pos,MAX_LENGTH_MANUF); hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; break; } case 0x00081050: // Performing Physician { strncpy(hdr->ID.Technician,(char*)hdr->AS.Header+pos,MAX_LENGTH_TECHNICIAN); break; } case 0x00081090: // Manufacturer Model { const size_t nn = strlen(hdr->ID.Manufacturer.Name)+1; strncpy(hdr->ID.Manufacturer._field+nn,(char*)hdr->AS.Header+pos,MAX_LENGTH_MANUF-nn-1); hdr->ID.Manufacturer.Model = hdr->ID.Manufacturer._field+nn; break; } case 0x00100010: // Name if (!hdr->FLAG.ANONYMOUS) { strncpy(hdr->Patient.Name,(char*)hdr->AS.Header+pos,MAX_LENGTH_NAME); hdr->Patient.Name[MAX_LENGTH_NAME]=0; } break; case 0x00100020: // ID strncpy(hdr->Patient.Id,(char*)hdr->AS.Header+pos,MAX_LENGTH_PID); hdr->Patient.Id[MAX_LENGTH_PID]=0; break; case 0x00100030: // Birthday { struct tm t0; t0.tm_sec = 0; t0.tm_min = 0; t0.tm_hour = 12; hdr->AS.Header[pos+8]=0; t0.tm_mday = atoi((char*)hdr->AS.Header+pos+6); hdr->AS.Header[pos+6]=0; t0.tm_mon = atoi((char*)hdr->AS.Header+pos+4)-1; hdr->AS.Header[pos+4]=0; t0.tm_year = atoi((char*)hdr->AS.Header+pos)-1900; hdr->Patient.Birthday = tm_time2gdf_time(&t0); break; } case 0x00100040: hdr->Patient.Sex = (toupper(hdr->AS.Header[pos])=='M') + 2*(toupper(hdr->AS.Header[pos])=='F'); break; case 0x00101010: //Age break; case 0x00101020: hdr->Patient.Height = (uint8_t)(atof((char*)hdr->AS.Header+pos)*100.0); break; case 0x00101030: hdr->Patient.Weight = (uint8_t)atoi((char*)hdr->AS.Header+pos); break; default: flag_ignored = 1; if (VERBOSE_LEVEL<7) fprintf(stdout,"ignored %6x: (%04x,%04x) %8d\t%s\n",pos,Tag>>16,Tag&0x0ffff,Len,(char*)hdr->AS.Header+pos); } if (VERBOSE_LEVEL>6) { if (!FLAG_implicite_VR || (Tag < 0x00030000)) fprintf(stdout,"%s %6x: (%04x,%04x) %8d %c%c \t%s\n",(flag_ignored?"ignored":" "),pos,Tag>>16,Tag&0x0ffff,Len,hdr->AS.Header[pos-8],hdr->AS.Header[pos-7],(char*)hdr->AS.Header+pos); else fprintf(stdout,"%s %6x: (%04x,%04x) %8d\t%s\n",(flag_ignored?"ignored":" "),pos,Tag>>16,Tag&0x0ffff,Len,(char*)hdr->AS.Header+pos); } pos += Len + (Len & 0x01 ? 1 : 0); // even number of bytes } if (flag_t0 == 3) hdr->T0 = tm_time2gdf_time(&T0); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); return(0); } #endif #ifdef WITH_PDP #include "../NONFREE/sopen_pdp_read.c" #endif #ifdef WITH_TRC #include "../NONFREE/sopen_trc_read.c" #endif #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/test0/test_scp_decode.c0000664000175000017500000000435514105434233021350 0ustar schloeglschloegl/* $Id: test_scp_decode.c,v 1.2 2007-08-31 13:18:15 schloegl Exp $ Copyright (C) 2007 Eugenio Cervesato Modified by Alois Schloegl This function is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if defined(_MSC_VER) && (_MSC_VER < 1600) #define __LITTLE_ENDIAN=1 #define __BIG_ENDIAN=0 USEUNIT("t210/scp-decode.cpp"); #include "patient.h" #include #endif #include "../biosig.h" #include "../t210/structures.h" #include #include #include int scp_decode(HDRTYPE* hdr, pointer_section *info_sections, DATA_DECODE &info_decoding, DATA_RECORD &info_recording, DATA_INFO &info_textual, bool &add_filter); //#include "patient.h" int main(int argc, char* argv[]) { HDRTYPE *hdr ; pointer_section *section; DATA_DECODE decode; DATA_RECORD record; DATA_INFO textual; bool add_filter=true; FILE *in; hdr = (HDRTYPE *)malloc(sizeof(HDRTYPE)); if( (section = (pointer_section *)malloc(sizeof(pointer_section)*12)) ==NULL) { return 2; } hdr->FileName=argv[1]; hdr->FILE.OPEN=0; hdr->FILE.COMPRESSION=0; scp_decode(hdr, section, decode, record, textual, add_filter); for (int i=0;i DATA CONSINSTENT fprintf(stdout,"%i %i %i\n",i,k,x); } return(0); } biosig-2.3.3/biosig4c++/eventcodes.awk0000775000175000017500000000414214105434233017656 0ustar schloeglschloegl#!/usr/bin/gawk -f # # Converts eventcodes.txt into eventcodes.i and eventcodegroups.i # # $Id$ # Copyright (C) 2011 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ # # BioSig 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 3 # of the License, 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, see . BEGIN { FS = "\t"; nG = 0; nC = 0; INIT = "#if 0\n### This file is autogenerated - Do not modify it !!! ###\n\n"; printf(INIT,ARGV[0],ARGV[1]) > "eventcodes.i"; printf(INIT,ARGV[0],ARGV[1]) > "eventcodegroups.i"; } { if (NR < 12) { printf("%s\n", $0) >> "eventcodes.i"; printf("%s\n", $0) >> "eventcodegroups.i"; } else if (NR == 12) { printf("#endif\n") >> "eventcodes.i"; printf("#endif\n") >> "eventcodegroups.i"; } } # list of event groups /^### 0x/ { nG++; g = substr($1,7,4); gsub(/_/, "0", g); G[nG,1] = g; G[nG,2] = $2; } # list of event codes /^[^#]/ { if (255 < strtonum($1)) { # ignore user-specified events nC++; C[nC,1] = $1; C[nC,2] = g; C[nC,3] = $2; } } END { for (i=1; i<=nG; i++) { printf("\t{ 0x%s, \"%s\" },\n",G[i,1],G[i,2]) >> "eventcodegroups.i" } for (i=1; i<256; i++) { # add pre-defined user-specified events 0x0001-0x00ff printf("\t{ 0x%04x, 0x0000, \"condition %i\" },\n",i,i) >> "eventcodes.i" } for (i=1; i<=nC; i++) { printf("\t{ %s, 0x%s, \"%s\" },\n",C[i,1],C[i,2],C[i,3]) >> "eventcodes.i" } } biosig-2.3.3/biosig4c++/config.h.in0000664000175000017500000002476714105434233017052 0ustar schloeglschloegl/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if you have the `bzero' function. */ #undef HAVE_BZERO /* Define to 1 if you have the `dup2' function. */ #undef HAVE_DUP2 /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FLOAT_H /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the `getdelim' function. */ #undef HAVE_GETDELIM /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `asound' library (-lasound). */ #undef HAVE_LIBASOUND /* Define to 1 if you have the `iconv' library (-liconv). */ #undef HAVE_LIBICONV /* Define to 1 if you have the `libmex' library (-llibmex). */ #undef HAVE_LIBLIBMEX /* Define to 1 if you have the `libmx' library (-llibmx). */ #undef HAVE_LIBLIBMX /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the `memchr' function. */ #undef HAVE_MEMCHR /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the `modf' function. */ #undef HAVE_MODF /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW /* Define to 1 if the system has the type `ptrdiff_t'. */ #undef HAVE_PTRDIFF_T /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strcspn' function. */ #undef HAVE_STRCSPN /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strpbrk' function. */ #undef HAVE_STRPBRK /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strspn' function. */ #undef HAVE_STRSPN /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define to 1 if you have the `strtoumax' function. */ #undef HAVE_STRTOUMAX /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the `tzset' function. */ #undef HAVE_TZSET /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to the type of a signed integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef int16_t /* Define to the type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef int32_t /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef int64_t /* Define to the type of a signed integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef int8_t /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `int' if does not define. */ #undef mode_t /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t /* Define as `fork' if `vfork' does not work. */ #undef vfork biosig-2.3.3/biosig4c++/biosig-network.h0000664000175000017500000002302214105434233020122 0ustar schloeglschloegl/* Copyright (C) 2005,2006,2007,2008,2009,2016 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ #define IPv4 #ifndef __BIOSIG_NETWORK_H__ #define __BIOSIG_NETWORK_H__ #include "biosig-dev.h" #define SERVER_PORT 54321 #if defined(__MINGW32__) #include #include #ifndef socklen_t #define socklen_t int #endif /* mingw/include/errno.h */ #ifndef _INC_ERRNO #define EALREADY WSAEALREADY #define ECONNABORTED WSAECONNABORTED #define ECONNREFUSED WSAECONNREFUSED #define ECONNRESET WSAECONNRESET #define EHOSTDOWN WSAEHOSTDOWN #define EHOSTUNREACH WSAEHOSTUNREACH #define EINPROGRESS WSAEINPROGRESS #define EISCONN WSAEISCONN #define ENETDOWN WSAENETDOWN #define ENETRESET WSAENETRESET #define ENETUNREACH WSAENETUNREACH #define EWOULDBLOCK WSAEWOULDBLOCK #define EADDRINUSE WSAEADDRINUSE #define ENOTSUP ENOSYS #define ETIMEDOUT WSAETIMEDOUT #define ENOTSOCK WSAENOTSOCK #define ENOBUFS WSAENOBUFS #define EMSGSIZE WSAEMSGSIZE #define EADDRNOTAVAIL WSAEADDRNOTAVAIL #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #endif #if 0 //!__linux__ // needed by MinGW on Windows #define creat(a, c) OpenFile(a, O_WRONLY|O_CREAT|O_TRUNC, c) #define write(a,b,c) WriteFile(a,b,c,0,0) #define close(a) CloseFile(a) #endif #else #include #include #include #include #include #include #endif /* External API definitions */ /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ /* client server commands*/ #define BSCS_ID_BITLEN 64 #define BSCS_MAX_BUFSIZ_LOG2 14 #define BSCS_MAX_BUFSIZ (1< (b)) ? (a) : (b)) typedef struct { uint32_t STATE; uint32_t LEN; uint8_t LOAD[max(8,BSCS_ID_BITLEN>>3)] __attribute__ ((aligned (8))); // must fit at least ID length } mesg_t __attribute__ ((aligned (8))); extern uint32_t SERVER_STATE; /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ #ifdef __cplusplus extern "C" { #endif int c64ta(uint64_t ID, char* txt); // convert 64bit to ascii int cat64(char* txt, uint64_t *ID); // convert ascii to 64bit void *get_in_addr(struct sockaddr *sa); /* biosig client-server functions */ int bscs_connect(const char* hostname); /* opens a connection to the server on success, the socket file descriptor (a positive integer) is returned in case of failure, a negative integer is returned -------------------------------------------------------------- */ int bscs_disconnect(int sd); /* disconnects the socket file descriptor -------------------------------------------------------------- */ int send_packet(int sd, uint32_t state, uint32_t len, void* load); /* send a single packet including header and load -------------------------------------------------------------- */ int bscs_open(int sd, uint64_t *ID); // read-open /* ID = 0 : write access, new identifier is returned in ID ID > 0 : read access to the file with known ID -------------------------------------------------------------- */ int bscs_close(int sd); /* close current connection -------------------------------------------------------------- */ int bscs_send_hdr(int sd, HDRTYPE *hdr); /* hdr->AS.Header must contain GDF header information hdr->HeadLen must contain header length -------------------------------------------------------------- */ int bscs_send_dat(int sd, void* buf, size_t len ); /* buf must contain the data block as in hdr->AS.rawdata -------------------------------------------------------------- */ int bscs_send_evt(int sd, HDRTYPE *hdr); /* hdr->EVENT defines the event table -------------------------------------------------------------- */ int bscs_send_msg(int sd, char* msg); /* msg is string -------------------------------------------------------------- */ int bscs_error(int sd, int ERRNUM, char* ERRMSG); /* ERRNUM contains the error number ERRMSG is string -------------------------------------------------------------- */ int bscs_requ_hdr(int sd, HDRTYPE *hdr); /* request header information -------------------------------------------------------------- */ ssize_t bscs_requ_dat(int sd, size_t start, size_t nblocks, HDRTYPE *hdr); /* request data blocks bufsiz is maximum number of bytes, typically it must be nblocks*hdr->AS.bpb -------------------------------------------------------------- */ int bscs_requ_evt(int sd, HDRTYPE *hdr); /* request event information -------------------------------------------------------------- */ int bscs_put_file(int sd, char *filename); /* put raw data file on server -------------------------------------------------------------- */ int bscs_get_file(int sd, uint64_t ID, char *filename); /* put raw data file on server -------------------------------------------------------------- */ int bscs_nop(int sd); /* no operation -------------------------------------------------------------- */ #ifdef __cplusplus } #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #endif /* __BIOSIG_NETWORK_H__ */ biosig-2.3.3/biosig4c++/eventcodes.i0000664000175000017500000003772314105434245017337 0ustar schloeglschloegl#if 0 ### This file is autogenerated - Do not modify it !!! ### ### Table of event codes. # This table is also part of the specification of # GDF v2.x http://arxiv.org/abs/cs.DB/0608052 and # GDF v1.x http://pub.ist.ac.at/~schloegl/matlab/eeg/gdf4/TR_GDF.pdf # and part of the BioSig project http://biosig.sf.net/ # Copyright (C) 2004-2015 Alois Schloegl # # BioSig 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 3 of the License, or (at your option) any later version. #endif { 0x0001, 0x0000, "condition 1" }, { 0x0002, 0x0000, "condition 2" }, { 0x0003, 0x0000, "condition 3" }, { 0x0004, 0x0000, "condition 4" }, { 0x0005, 0x0000, "condition 5" }, { 0x0006, 0x0000, "condition 6" }, { 0x0007, 0x0000, "condition 7" }, { 0x0008, 0x0000, "condition 8" }, { 0x0009, 0x0000, "condition 9" }, { 0x000a, 0x0000, "condition 10" }, { 0x000b, 0x0000, "condition 11" }, { 0x000c, 0x0000, "condition 12" }, { 0x000d, 0x0000, "condition 13" }, { 0x000e, 0x0000, "condition 14" }, { 0x000f, 0x0000, "condition 15" }, { 0x0010, 0x0000, "condition 16" }, { 0x0011, 0x0000, "condition 17" }, { 0x0012, 0x0000, "condition 18" }, { 0x0013, 0x0000, "condition 19" }, { 0x0014, 0x0000, "condition 20" }, { 0x0015, 0x0000, "condition 21" }, { 0x0016, 0x0000, "condition 22" }, { 0x0017, 0x0000, "condition 23" }, { 0x0018, 0x0000, "condition 24" }, { 0x0019, 0x0000, "condition 25" }, { 0x001a, 0x0000, "condition 26" }, { 0x001b, 0x0000, "condition 27" }, { 0x001c, 0x0000, "condition 28" }, { 0x001d, 0x0000, "condition 29" }, { 0x001e, 0x0000, "condition 30" }, { 0x001f, 0x0000, "condition 31" }, { 0x0020, 0x0000, "condition 32" }, { 0x0021, 0x0000, "condition 33" }, { 0x0022, 0x0000, "condition 34" }, { 0x0023, 0x0000, "condition 35" }, { 0x0024, 0x0000, "condition 36" }, { 0x0025, 0x0000, "condition 37" }, { 0x0026, 0x0000, "condition 38" }, { 0x0027, 0x0000, "condition 39" }, { 0x0028, 0x0000, "condition 40" }, { 0x0029, 0x0000, "condition 41" }, { 0x002a, 0x0000, "condition 42" }, { 0x002b, 0x0000, "condition 43" }, { 0x002c, 0x0000, "condition 44" }, { 0x002d, 0x0000, "condition 45" }, { 0x002e, 0x0000, "condition 46" }, { 0x002f, 0x0000, "condition 47" }, { 0x0030, 0x0000, "condition 48" }, { 0x0031, 0x0000, "condition 49" }, { 0x0032, 0x0000, "condition 50" }, { 0x0033, 0x0000, "condition 51" }, { 0x0034, 0x0000, "condition 52" }, { 0x0035, 0x0000, "condition 53" }, { 0x0036, 0x0000, "condition 54" }, { 0x0037, 0x0000, "condition 55" }, { 0x0038, 0x0000, "condition 56" }, { 0x0039, 0x0000, "condition 57" }, { 0x003a, 0x0000, "condition 58" }, { 0x003b, 0x0000, "condition 59" }, { 0x003c, 0x0000, "condition 60" }, { 0x003d, 0x0000, "condition 61" }, { 0x003e, 0x0000, "condition 62" }, { 0x003f, 0x0000, "condition 63" }, { 0x0040, 0x0000, "condition 64" }, { 0x0041, 0x0000, "condition 65" }, { 0x0042, 0x0000, "condition 66" }, { 0x0043, 0x0000, "condition 67" }, { 0x0044, 0x0000, "condition 68" }, { 0x0045, 0x0000, "condition 69" }, { 0x0046, 0x0000, "condition 70" }, { 0x0047, 0x0000, "condition 71" }, { 0x0048, 0x0000, "condition 72" }, { 0x0049, 0x0000, "condition 73" }, { 0x004a, 0x0000, "condition 74" }, { 0x004b, 0x0000, "condition 75" }, { 0x004c, 0x0000, "condition 76" }, { 0x004d, 0x0000, "condition 77" }, { 0x004e, 0x0000, "condition 78" }, { 0x004f, 0x0000, "condition 79" }, { 0x0050, 0x0000, "condition 80" }, { 0x0051, 0x0000, "condition 81" }, { 0x0052, 0x0000, "condition 82" }, { 0x0053, 0x0000, "condition 83" }, { 0x0054, 0x0000, "condition 84" }, { 0x0055, 0x0000, "condition 85" }, { 0x0056, 0x0000, "condition 86" }, { 0x0057, 0x0000, "condition 87" }, { 0x0058, 0x0000, "condition 88" }, { 0x0059, 0x0000, "condition 89" }, { 0x005a, 0x0000, "condition 90" }, { 0x005b, 0x0000, "condition 91" }, { 0x005c, 0x0000, "condition 92" }, { 0x005d, 0x0000, "condition 93" }, { 0x005e, 0x0000, "condition 94" }, { 0x005f, 0x0000, "condition 95" }, { 0x0060, 0x0000, "condition 96" }, { 0x0061, 0x0000, "condition 97" }, { 0x0062, 0x0000, "condition 98" }, { 0x0063, 0x0000, "condition 99" }, { 0x0064, 0x0000, "condition 100" }, { 0x0065, 0x0000, "condition 101" }, { 0x0066, 0x0000, "condition 102" }, { 0x0067, 0x0000, "condition 103" }, { 0x0068, 0x0000, "condition 104" }, { 0x0069, 0x0000, "condition 105" }, { 0x006a, 0x0000, "condition 106" }, { 0x006b, 0x0000, "condition 107" }, { 0x006c, 0x0000, "condition 108" }, { 0x006d, 0x0000, "condition 109" }, { 0x006e, 0x0000, "condition 110" }, { 0x006f, 0x0000, "condition 111" }, { 0x0070, 0x0000, "condition 112" }, { 0x0071, 0x0000, "condition 113" }, { 0x0072, 0x0000, "condition 114" }, { 0x0073, 0x0000, "condition 115" }, { 0x0074, 0x0000, "condition 116" }, { 0x0075, 0x0000, "condition 117" }, { 0x0076, 0x0000, "condition 118" }, { 0x0077, 0x0000, "condition 119" }, { 0x0078, 0x0000, "condition 120" }, { 0x0079, 0x0000, "condition 121" }, { 0x007a, 0x0000, "condition 122" }, { 0x007b, 0x0000, "condition 123" }, { 0x007c, 0x0000, "condition 124" }, { 0x007d, 0x0000, "condition 125" }, { 0x007e, 0x0000, "condition 126" }, { 0x007f, 0x0000, "condition 127" }, { 0x0080, 0x0000, "condition 128" }, { 0x0081, 0x0000, "condition 129" }, { 0x0082, 0x0000, "condition 130" }, { 0x0083, 0x0000, "condition 131" }, { 0x0084, 0x0000, "condition 132" }, { 0x0085, 0x0000, "condition 133" }, { 0x0086, 0x0000, "condition 134" }, { 0x0087, 0x0000, "condition 135" }, { 0x0088, 0x0000, "condition 136" }, { 0x0089, 0x0000, "condition 137" }, { 0x008a, 0x0000, "condition 138" }, { 0x008b, 0x0000, "condition 139" }, { 0x008c, 0x0000, "condition 140" }, { 0x008d, 0x0000, "condition 141" }, { 0x008e, 0x0000, "condition 142" }, { 0x008f, 0x0000, "condition 143" }, { 0x0090, 0x0000, "condition 144" }, { 0x0091, 0x0000, "condition 145" }, { 0x0092, 0x0000, "condition 146" }, { 0x0093, 0x0000, "condition 147" }, { 0x0094, 0x0000, "condition 148" }, { 0x0095, 0x0000, "condition 149" }, { 0x0096, 0x0000, "condition 150" }, { 0x0097, 0x0000, "condition 151" }, { 0x0098, 0x0000, "condition 152" }, { 0x0099, 0x0000, "condition 153" }, { 0x009a, 0x0000, "condition 154" }, { 0x009b, 0x0000, "condition 155" }, { 0x009c, 0x0000, "condition 156" }, { 0x009d, 0x0000, "condition 157" }, { 0x009e, 0x0000, "condition 158" }, { 0x009f, 0x0000, "condition 159" }, { 0x00a0, 0x0000, "condition 160" }, { 0x00a1, 0x0000, "condition 161" }, { 0x00a2, 0x0000, "condition 162" }, { 0x00a3, 0x0000, "condition 163" }, { 0x00a4, 0x0000, "condition 164" }, { 0x00a5, 0x0000, "condition 165" }, { 0x00a6, 0x0000, "condition 166" }, { 0x00a7, 0x0000, "condition 167" }, { 0x00a8, 0x0000, "condition 168" }, { 0x00a9, 0x0000, "condition 169" }, { 0x00aa, 0x0000, "condition 170" }, { 0x00ab, 0x0000, "condition 171" }, { 0x00ac, 0x0000, "condition 172" }, { 0x00ad, 0x0000, "condition 173" }, { 0x00ae, 0x0000, "condition 174" }, { 0x00af, 0x0000, "condition 175" }, { 0x00b0, 0x0000, "condition 176" }, { 0x00b1, 0x0000, "condition 177" }, { 0x00b2, 0x0000, "condition 178" }, { 0x00b3, 0x0000, "condition 179" }, { 0x00b4, 0x0000, "condition 180" }, { 0x00b5, 0x0000, "condition 181" }, { 0x00b6, 0x0000, "condition 182" }, { 0x00b7, 0x0000, "condition 183" }, { 0x00b8, 0x0000, "condition 184" }, { 0x00b9, 0x0000, "condition 185" }, { 0x00ba, 0x0000, "condition 186" }, { 0x00bb, 0x0000, "condition 187" }, { 0x00bc, 0x0000, "condition 188" }, { 0x00bd, 0x0000, "condition 189" }, { 0x00be, 0x0000, "condition 190" }, { 0x00bf, 0x0000, "condition 191" }, { 0x00c0, 0x0000, "condition 192" }, { 0x00c1, 0x0000, "condition 193" }, { 0x00c2, 0x0000, "condition 194" }, { 0x00c3, 0x0000, "condition 195" }, { 0x00c4, 0x0000, "condition 196" }, { 0x00c5, 0x0000, "condition 197" }, { 0x00c6, 0x0000, "condition 198" }, { 0x00c7, 0x0000, "condition 199" }, { 0x00c8, 0x0000, "condition 200" }, { 0x00c9, 0x0000, "condition 201" }, { 0x00ca, 0x0000, "condition 202" }, { 0x00cb, 0x0000, "condition 203" }, { 0x00cc, 0x0000, "condition 204" }, { 0x00cd, 0x0000, "condition 205" }, { 0x00ce, 0x0000, "condition 206" }, { 0x00cf, 0x0000, "condition 207" }, { 0x00d0, 0x0000, "condition 208" }, { 0x00d1, 0x0000, "condition 209" }, { 0x00d2, 0x0000, "condition 210" }, { 0x00d3, 0x0000, "condition 211" }, { 0x00d4, 0x0000, "condition 212" }, { 0x00d5, 0x0000, "condition 213" }, { 0x00d6, 0x0000, "condition 214" }, { 0x00d7, 0x0000, "condition 215" }, { 0x00d8, 0x0000, "condition 216" }, { 0x00d9, 0x0000, "condition 217" }, { 0x00da, 0x0000, "condition 218" }, { 0x00db, 0x0000, "condition 219" }, { 0x00dc, 0x0000, "condition 220" }, { 0x00dd, 0x0000, "condition 221" }, { 0x00de, 0x0000, "condition 222" }, { 0x00df, 0x0000, "condition 223" }, { 0x00e0, 0x0000, "condition 224" }, { 0x00e1, 0x0000, "condition 225" }, { 0x00e2, 0x0000, "condition 226" }, { 0x00e3, 0x0000, "condition 227" }, { 0x00e4, 0x0000, "condition 228" }, { 0x00e5, 0x0000, "condition 229" }, { 0x00e6, 0x0000, "condition 230" }, { 0x00e7, 0x0000, "condition 231" }, { 0x00e8, 0x0000, "condition 232" }, { 0x00e9, 0x0000, "condition 233" }, { 0x00ea, 0x0000, "condition 234" }, { 0x00eb, 0x0000, "condition 235" }, { 0x00ec, 0x0000, "condition 236" }, { 0x00ed, 0x0000, "condition 237" }, { 0x00ee, 0x0000, "condition 238" }, { 0x00ef, 0x0000, "condition 239" }, { 0x00f0, 0x0000, "condition 240" }, { 0x00f1, 0x0000, "condition 241" }, { 0x00f2, 0x0000, "condition 242" }, { 0x00f3, 0x0000, "condition 243" }, { 0x00f4, 0x0000, "condition 244" }, { 0x00f5, 0x0000, "condition 245" }, { 0x00f6, 0x0000, "condition 246" }, { 0x00f7, 0x0000, "condition 247" }, { 0x00f8, 0x0000, "condition 248" }, { 0x00f9, 0x0000, "condition 249" }, { 0x00fa, 0x0000, "condition 250" }, { 0x00fb, 0x0000, "condition 251" }, { 0x00fc, 0x0000, "condition 252" }, { 0x00fd, 0x0000, "condition 253" }, { 0x00fe, 0x0000, "condition 254" }, { 0x00ff, 0x0000, "condition 255" }, { 0x0101, 0x0100, "artifact:EOG (blinks, fast, large amplitude)" }, { 0x0102, 0x0100, "artifact:ECG" }, { 0x0103, 0x0100, "artifact:EMG/Muscle" }, { 0x0104, 0x0100, "artifact:Movement" }, { 0x0105, 0x0100, "artifact:Failing Electrode" }, { 0x0106, 0x0100, "artifact:Sweat" }, { 0x0107, 0x0100, "artifact:50/60 Hz mains interference" }, { 0x0108, 0x0100, "artifact:breathing" }, { 0x0109, 0x0100, "artifact:pulse" }, { 0x010a, 0x0100, "artifact:EOG (slow, small amplitudes)" }, { 0x0111, 0x0110, "eeg:Sleep spindles" }, { 0x0112, 0x0110, "eeg:K-complexes" }, { 0x0113, 0x0110, "eeg:Saw-tooth waves" }, { 0x0114, 0x0110, "eeg:Idling EEG - eyes open" }, { 0x0115, 0x0110, "eeg:Idling EEG - eyes closed" }, { 0x0116, 0x0110, "eeg:spike" }, { 0x0117, 0x0110, "eeg:seizure" }, { 0x0121, 0x0120, "VEP: visual EP" }, { 0x0122, 0x0120, "AEP: auditory EP" }, { 0x0123, 0x0120, "SEP: somato-sensory EP" }, { 0x012F, 0x0120, "TMS: transcranial magnetic stimulation " }, { 0x0131, 0x0130, "SSVEP" }, { 0x0132, 0x0130, "SSAEP" }, { 0x0133, 0x0130, "SSSEP" }, { 0x0140, 0x0140, "response code 0, or no response or false" }, { 0x0141, 0x0140, "response code 1, or correct response" }, { 0x0142, 0x0140, "response code 2" }, { 0x0143, 0x0140, "response code 3" }, { 0x0144, 0x0140, "Go, or response code 4" }, { 0x0145, 0x0140, "NoGo, or response code 5" }, { 0x0201, 0x0200, "Spike, action potential (fiducial point)" }, { 0x0202, 0x0200, "Burst " }, { 0x0203, 0x0200, "maximum slope time" }, { 0x0204, 0x0200, "peak time of spike" }, { 0x0211, 0x0210, "EPSP - Excitatory Post-Synaptic Potentials" }, { 0x0212, 0x0210, "IPSP - Inhibitory Post-Synaptic Potentials" }, { 0x0213, 0x0210, "EPSC - Excitatory Post-Synaptic Currents" }, { 0x0214, 0x0210, "IPSC - Inhibitory Post-Synaptic Currents" }, { 0x0300, 0x0300, "Start of Trial, Trigger at t=0s" }, { 0x0301, 0x0300, "class1, Left hand" }, { 0x0302, 0x0300, "class2, Right hand" }, { 0x0303, 0x0300, "class3, Foot, towards Right - cue onset (BCI experiment)" }, { 0x0304, 0x0300, "class4, Tongue" }, { 0x0305, 0x0300, "class5" }, { 0x0306, 0x0300, "class6, towards Down" }, { 0x0307, 0x0300, "class7" }, { 0x0308, 0x0300, "class8" }, { 0x0309, 0x0300, "class9, towards Left " }, { 0x030A, 0x0300, "class10 " }, { 0x030B, 0x0300, "class11 " }, { 0x030C, 0x0300, "class12, towards Up " }, { 0x030D, 0x0300, "Feedback (continuous) - onset (BCI experiment)" }, { 0x030E, 0x0300, "Feedback (discrete) - onset (BCI experiment)" }, { 0x030F, 0x0300, "cue unknown/undefined (used for BCI competition) " }, { 0x0311, 0x0300, "Beep (accustic stimulus, BCI experiment)" }, { 0x0312, 0x0300, "Cross on screen (BCI experiment)" }, { 0x0313, 0x0300, "Flashing light" }, { 0x0381, 0x0300, "target hit, task successful, correct classification" }, { 0x0382, 0x0300, "target missed, task not reached, incorrect classification" }, { 0x03ff, 0x0300, "Rejection of whole trial" }, { 0x0401, 0x0400, "Obstructive apnea/Hypopnea event (OAHE)" }, { 0x0402, 0x0400, "RERA #(Respiratory Effort Related Arousal)" }, { 0x0403, 0x0400, "Central Apnea/Hypopnea Event (CAHE)" }, { 0x0404, 0x0400, "CS Breathing #(Cheyne-Stokes Breathing)" }, { 0x0405, 0x0400, "Hypoventilation " }, { 0x0406, 0x0400, "Apnea " }, { 0x0407, 0x0400, "Obstructive apnea" }, { 0x0408, 0x0400, "Central apnea " }, { 0x0409, 0x0400, "Mixed apnea " }, { 0x040A, 0x0400, "Hypopnea " }, { 0x040B, 0x0400, "Periodic Breathing " }, { 0x040C, 0x0400, "Limb movement " }, { 0x040D, 0x0400, "PLMS" }, { 0x040E, 0x0400, "(time of) maximum inspiration " }, { 0x040F, 0x0400, "Start of inspiration, (end of expiration) " }, { 0x0410, 0x0410, "Sleep stage Wake" }, { 0x0411, 0x0410, "Sleep stage 1" }, { 0x0412, 0x0410, "Sleep stage 2" }, { 0x0413, 0x0410, "Sleep stage 3" }, { 0x0414, 0x0410, "Sleep stage 4" }, { 0x0415, 0x0410, "Sleep stage REM" }, { 0x0416, 0x0410, "Sleep stage ?" }, { 0x0417, 0x0410, "Movement time" }, { 0x0418, 0x0410, "Bruxism" }, { 0x0419, 0x0410, "RBD #(Rapid eye movement sleep behaviour disorder)" }, { 0x041A, 0x0410, "RMD #(Sleep related rhythmic movement disorder)" }, { 0x041B, 0x0410, "Sleep stage N" }, { 0x041C, 0x0410, "Sleep stage N1" }, { 0x041D, 0x0410, "Sleep stage N2" }, { 0x041E, 0x0410, "Sleep stage N3" }, { 0x0420, 0x0420, "Lights on " }, { 0x0431, 0x0430, "eyes left" }, { 0x0432, 0x0430, "eyes right" }, { 0x0433, 0x0430, "eyes up" }, { 0x0434, 0x0430, "eyes down" }, { 0x0435, 0x0430, "horizontal eye movement" }, { 0x0436, 0x0430, "vertical eye movement" }, { 0x0437, 0x0430, "eye rotation (clockwise)" }, { 0x0438, 0x0430, "eye rotation (counterclockwise)" }, { 0x0439, 0x0430, "eye blinks" }, { 0x0441, 0x0440, "left hand movement" }, { 0x0442, 0x0440, "right hand movement" }, { 0x0443, 0x0440, "head movement" }, { 0x0444, 0x0440, "tongue movement" }, { 0x0445, 0x0440, "swallowing" }, { 0x0446, 0x0440, "biting, chewing, teeth griding " }, { 0x0447, 0x0440, "foot movement" }, { 0x0449, 0x0440, "arm movement" }, { 0x044a, 0x0440, "arm (right) movement" }, { 0x0501, 0x0500, "ecg:Fiducial point of QRS complex" }, { 0x0502, 0x0500, "ecg:P-wave-onset, MDC_ECG_TIME_START_P" }, { 0x0503, 0x0500, "ecg:Q-wave-onset, QRS-onset, MDC_ECG_TIME_START_QRS" }, { 0x0504, 0x0500, "ecg:R-point" }, { 0x0505, 0x0500, "ecg:S-wave-onset, S-wave-peak" }, { 0x0506, 0x0500, "ecg:T-wave-onset, MDC_ECG_TIME_START_T" }, { 0x0507, 0x0500, "ecg:U-wave-onset" }, { 0x0580, 0x0580, "start" }, { 0x0581, 0x0580, " 25 Watt" }, { 0x0582, 0x0580, " 50 Watt" }, { 0x0583, 0x0580, " 75 Watt" }, { 0x0584, 0x0580, "100 Watt" }, { 0x0585, 0x0580, "125 Watt" }, { 0x0586, 0x0580, "150 Watt" }, { 0x0587, 0x0580, "175 Watt" }, { 0x0588, 0x0580, "200 Watt" }, { 0x0589, 0x0580, "225 Watt" }, { 0x058a, 0x0580, "250 Watt" }, { 0x058b, 0x0580, "275 Watt" }, { 0x058c, 0x0580, "300 Watt" }, { 0x058d, 0x0580, "325 Watt" }, { 0x058e, 0x0580, "350 Watt" }, { 0x7ffe, 0x7f00, "start of a new segment (after a break)" }, { 0x7fff, 0x7f00, "non-equidistant sampling value" }, biosig-2.3.3/biosig4c++/THANKS0000664000175000017500000000033014105434233015716 0ustar schloeglschloeglThanks to the contributors: Thomas Brunner Makefile, testing Eugenio Cervesato reading of SCP-ECG format Franco Chiarugi writing of SCP-ECG format Elias Apostolopoulos read/write support of HL7aECG format biosig-2.3.3/biosig4c++/DESCRIPTION0000664000175000017500000000043714105434245016524 0ustar schloeglschloeglName: BioSig Version: 2.3.3 Date: 2021-08-13 Author: Alois Schloegl Maintainer: Alois Schloegl Title: BioSig Description: A software library for biomedical signal processing. Depends: octave (> 2.9.0), License: GPL version 3 or later Url: http://biosig.sf.net biosig-2.3.3/biosig4c++/t210/0000775000175000017500000000000014105434233015475 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/t210/sopen_igor.c0000664000175000017500000007245014105434233020015 0ustar schloeglschloegl/* Copyright (C) 2013,2014 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #define _GNU_SOURCE /* #include #include #include */ #include #include // define macro isnan() #include #include #include "../biosig-dev.h" #include "../igor/IgorBin.h" #define IGOROLD 1 // will be used for testing and migrating to new version #ifdef __cplusplus extern "C" { #endif #define ITX_MAXLINELENGTH 400 char *IgorChanLabel(char *inLabel, HDRTYPE *hdr, size_t *ngroup, size_t *nseries, size_t *nsweep, size_t *ns) { /* extract Channel Label of IGOR ITX data format */ *ns = 0; // static char Label[ITX_MAXLINELENGTH+1]; int k, s = 0, pos4=0, pos1=0; for (k = strlen(inLabel); inLabel[k] < ' '; k--); inLabel[k+1] = 0; while (inLabel[k] >= ' ') { while ( inLabel[k] >= '0' && inLabel[k] <= '9' ) k--; if (inLabel[k]=='_') { s++; if (s==1) pos4 = k; if (s==4) pos1 = k; k--; } if ( inLabel[k] < '0' || inLabel[k] > '9' ) break; } if (3 < s) { char nvar = 0; for (k = strlen(inLabel); 0 < k && nvar < 4; k--) { if (inLabel[k] == '_') { inLabel[k] = 0; char *v = inLabel+k+1; size_t n = atol(v); switch (nvar) { case 0: *ns = n; nvar++; break; case 1: *nsweep = n; nvar++; break; case 2: *nseries = n; nvar++; break; case 3: *ngroup = n; nvar++; break; } inLabel[k] = 0; } } for (k=1; inLabel[pos4+k-1]; k++) { inLabel[pos1+k] = inLabel[pos4+k]; } } if ((*ns)+1 > hdr->NS) { // another channel hdr->NS = (*ns)+1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); } return(inLabel); } /* compute igor checksum */ int ibwChecksum(int16_t *data, int flag_swap, int oldcksum, int numbytes) { numbytes >>= 1; // 2 bytes to a short -- ignore trailing odd byte. if (flag_swap) { while(numbytes-- > 0) oldcksum += bswap_16(*(data++)); } else { while(numbytes-- > 0) oldcksum += *(data++); } return oldcksum&0xffff; } /* void ReorderBytes(void *p, int bytesPerPoint, long numValues) // Reverses byte order. { unsigned char ch, *p1, *p2, *pEnd; pEnd = (unsigned char *)p + numValues*bytesPerPoint; while (p < (void *)pEnd) { p1 = p; p2 = (unsigned char *)p + bytesPerPoint-1; while (p1 < p2) { ch = *p1; *p1++ = *p2; *p2-- = ch; } p = (unsigned char *)p + bytesPerPoint; } } */ void ReorderShort(void* sp) { *(uint16_t*)sp = bswap_16(*(uint16_t*)sp); } void ReorderLong(void* lp) { *(uint32_t*)lp = bswap_32(*(uint32_t*)lp); } void ReorderDouble(void* dp) { *(uint64_t*)dp = bswap_64(*(uint64_t*)dp); } void ReorderBinHeader1(BinHeader1* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderShort(&p->checksum); } void ReorderBinHeader2(BinHeader2* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); // ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } void ReorderBinHeader3(BinHeader3* p) { ReorderShort(&p->version); ReorderLong(&p->wfmSize); ReorderLong(&p->noteSize); ReorderLong(&p->formulaSize); // ReorderLong(&p->pictSize); ReorderShort(&p->checksum); } void ReorderBinHeader5(BinHeader5* p) { ReorderShort(&p->version); ReorderShort(&p->checksum); ReorderLong(&p->wfmSize); ReorderLong(&p->formulaSize); ReorderLong(&p->noteSize); ReorderLong(&p->dataEUnitsSize); // ReorderBytes(&p->dimEUnitsSize, 4, 4); ReorderLong(&p->dimEUnitsSize[0]); ReorderLong(&p->dimEUnitsSize[1]); ReorderLong(&p->dimEUnitsSize[2]); ReorderLong(&p->dimEUnitsSize[3]); // ReorderBytes(&p->dimLabelsSize, 4, 4); ReorderLong(&p->dimLabelsSize[0]); ReorderLong(&p->dimLabelsSize[1]); ReorderLong(&p->dimLabelsSize[2]); ReorderLong(&p->dimLabelsSize[3]); ReorderLong(&p->sIndicesSize); // ReorderLong(&p->optionsSize1); // ReorderLong(&p->optionsSize2); } void ReorderWaveHeader2(WaveHeader2* p) { ReorderShort(&p->type); // ReorderLong(&p->next); // char bname does not need to be reordered. // ReorderShort(&p->whVersion); // ReorderShort(&p->srcFldr); // ReorderLong(&p->fileName); // char dataUnits does not need to be reordered. // char xUnits does not need to be reordered. ReorderLong(&p->npnts); // ReorderShort(&p->aModified); ReorderDouble(&p->hsA); ReorderDouble(&p->hsB); // ReorderShort(&p->wModified); // ReorderShort(&p->swModified); ReorderShort(&p->fsValid); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. // ReorderLong(&p->formula); // ReorderLong(&p->depID); ReorderLong(&p->creationDate); // char wUnused does not need to be reordered. ReorderLong(&p->modDate); // ReorderLong(&p->waveNoteH); // The wData field marks the start of the wave data which will be reordered separately. } void ReorderWaveHeader5(WaveHeader5* p) { // ReorderLong(&p->next); ReorderLong(&p->creationDate); ReorderLong(&p->modDate); ReorderLong(&p->npnts); ReorderShort(&p->type); // ReorderShort(&p->dLock); // char whpad1 does not need to be reordered. // ReorderShort(&p->whVersion); // char bname does not need to be reordered. // ReorderLong(&p->whpad2); // ReorderLong(&p->dFolder); // ReorderBytes(&p->nDim, 4, 4); ReorderLong(&p->nDim[0]); ReorderLong(&p->nDim[1]); ReorderLong(&p->nDim[2]); ReorderLong(&p->nDim[3]); // ReorderBytes(&p->sfA, 8, 4); ReorderDouble(&p->sfA[0]); ReorderDouble(&p->sfA[1]); ReorderDouble(&p->sfA[2]); ReorderDouble(&p->sfA[3]); // ReorderBytes(&p->sfB, 8, 4); ReorderDouble(&p->sfB[0]); ReorderDouble(&p->sfB[1]); ReorderDouble(&p->sfB[2]); ReorderDouble(&p->sfB[3]); // char dataUnits does not need to be reordered. // char dimUnits does not need to be reordered. ReorderShort(&p->fsValid); // ReorderShort(&p->whpad3); ReorderDouble(&p->topFullScale); ReorderDouble(&p->botFullScale); /* // according to IgorBin.h, the following stuff can be ignored for reading IBW files // ReorderLong(&p->dataEUnits); // ReorderBytes(&p->dimEUnits, 4, 4); ReorderLong(&p->dimEUnits[0]); ReorderLong(&p->dimEUnits[1]); ReorderLong(&p->dimEUnits[2]); ReorderLong(&p->dimEUnits[3]); // ReorderBytes(&p->dimLabels, 4, 4); ReorderLong(&p->dimLabels[0]); ReorderLong(&p->dimLabels[1]); ReorderLong(&p->dimLabels[2]); ReorderLong(&p->dimLabels[3]); ReorderLong(&p->waveNoteH); // ReorderBytes(&p->whUnused, 4, 16); ReorderShort(&p->aModified); ReorderShort(&p->wModified); ReorderShort(&p->swModified); // char useBits does not need to be reordered. // char kindBits does not need to be reordered. ReorderLong(&p->formula); ReorderLong(&p->depID); ReorderShort(&p->whpad4); ReorderShort(&p->srcFldr); ReorderLong(&p->fileName); ReorderLong(&p->sIndices); // The wData field marks the start of the wave data which will be reordered separately. */ } void sopen_ibw_read (HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ fprintf(stdout,"Warning: support for IBW is very experimental\n"); uint16_t version = *(uint16_t*)hdr->AS.Header; char flag_swap = (version & 0xFF) == 0; if (flag_swap) version = bswap_16(version); unsigned count=0; int binHeaderSize; int waveHeaderSize; switch (version) { case 1: binHeaderSize=sizeof(BinHeader1); waveHeaderSize=sizeof(WaveHeader2); break; case 2: binHeaderSize=sizeof(BinHeader2); waveHeaderSize=sizeof(WaveHeader2); break; case 3: binHeaderSize=sizeof(BinHeader3); waveHeaderSize=sizeof(WaveHeader2); break; case 5: binHeaderSize=sizeof(BinHeader5); waveHeaderSize=sizeof(WaveHeader5); break; default: if (VERBOSE_LEVEL>7) fprintf(stderr,"ver=%x \n",version); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Igor/IBW: unsupported version number"); return; } count = binHeaderSize+waveHeaderSize; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): IBW v%i %i %i %i\n",__FILE__,__LINE__,version, binHeaderSize,waveHeaderSize, (int)count); if (hdr->HeadLen < count) { hdr->AS.Header = realloc(hdr->AS.Header, count+1); hdr->HeadLen += ifread(hdr->AS.Header + hdr->HeadLen, 1, count-hdr->HeadLen, hdr); } // compute check sum if ((int)hdr->VERSION == 5) count -= 4; void *buffer = hdr->AS.Header; // Check the checksum. int crc; if ((ibwChecksum((int16_t*)buffer, flag_swap, 0, count))) { if (VERBOSE_LEVEL>7) fprintf(stderr,"ver=%x crc = %x %i %i \n",version, crc, binHeaderSize, waveHeaderSize); biosigERROR(hdr, B4C_CRC_ERROR, "Igor/IBW: checksum error"); return; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): sizeof BinHeaders %i %i %i %i\n",__FILE__,__LINE__, (int)sizeof(BinHeader1),(int)sizeof(BinHeader2),(int)sizeof(BinHeader3),(int)sizeof(BinHeader5)); // Do byte reordering if the file is from another platform. if (flag_swap) { version = bswap_16(version); switch(version) { case 1: ReorderBinHeader1((BinHeader1*)hdr->AS.Header); break; case 2: ReorderBinHeader2((BinHeader2*)hdr->AS.Header); break; case 3: ReorderBinHeader3((BinHeader3*)hdr->AS.Header); break; case 5: ReorderBinHeader5((BinHeader5*)hdr->AS.Header); break; } switch(version) { case 1: // Version 1 and 2 files use WaveHeader2. case 2: case 3: ReorderWaveHeader2((WaveHeader2*)(hdr->AS.Header+binHeaderSize)); break; case 5: ReorderWaveHeader5((WaveHeader5*)(hdr->AS.Header+binHeaderSize)); break; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): sizeof WaveHeaders %i %i %i v%i\n",__FILE__,__LINE__, (int)sizeof(WaveHeader2), (int)sizeof(WaveHeader5), (int)iftell(hdr),version); // Read some of the BinHeader fields. int16_t type = 0; // See types (e.g. NT_FP64) above. Zero for text waves. hdr->NS = 1; hdr->SampleRate = 1; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); // Read some of the WaveHeader fields. switch(version) { case 1: case 2: case 3: { WaveHeader2* w2; w2 = (WaveHeader2*)(buffer+binHeaderSize); type = w2->type; strncpy(hdr->CHANNEL[0].Label, w2->bname, MAX_LENGTH_LABEL); hdr->CHANNEL[0].PhysDimCode = PhysDimCode(w2->dataUnits); hdr->CHANNEL[0].SPR = hdr->SPR = 1; hdr->NRec = w2->npnts; #ifdef IGOROLD hdr->CHANNEL[0].Cal = w2->hsA; hdr->CHANNEL[0].Off = w2->hsB; /* hdr->CHANNEL[0].DigMax = (w2->topFullScale-w2->hsB) / w2->hsA; hdr->CHANNEL[0].DigMin = (w2->botFullScale-w2->hsB) / w2->hsA; */ #else hdr->SampleRate = 1.0 / w2->hsA; hdr->CHANNEL[0].PhysMax = w2->topFullScale; hdr->CHANNEL[0].PhysMin = w2->botFullScale; #endif hdr->FLAG.OVERFLOWDETECTION = !w2->fsValid; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): %f %f <%s> <%s>\n",__FILE__,__LINE__,w2->hsA,w2->hsB,w2->xUnits,w2->dataUnits); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): %f %f\n",__FILE__,__LINE__,w2->topFullScale,w2->botFullScale); hdr->HeadLen = binHeaderSize+waveHeaderSize-16; // 16 = size of wData field in WaveHeader2 structure. } break; case 5: { WaveHeader5* w5; w5 = (WaveHeader5*)(buffer+binHeaderSize); type = w5->type; int k; size_t nTraces=1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i): %i %i %i %i\n", __FILE__, __LINE__, w5->nDim[0], w5->nDim[1], w5->nDim[2], w5->nDim[3]); for (k=1; (w5->nDim[k]!=0) && (k<4); k++) { // count number of traces nTraces *= w5->nDim[k]; } if (nTraces > 1) { // set break marker between traces hdr->EVENT.N = nTraces-1; if (reallocEventTable(hdr, hdr->EVENT.N) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return; }; size_t n; for (n = 0; n < hdr->EVENT.N; n++) { hdr->EVENT.TYP[n] = 0x7ffe; hdr->EVENT.POS[n] = (n+1)*w5->nDim[0]; } } if (VERBOSE_LEVEL>7) { for (k=0; k<4; k++) fprintf(stdout,"%i\t%f\t%f\n",w5->nDim[k],w5->sfA[k],w5->sfB[k]); } strncpy(hdr->CHANNEL[0].Label, w5->bname, MAX_LENGTH_LABEL); hdr->CHANNEL[0].PhysDimCode = PhysDimCode(w5->dataUnits); hdr->CHANNEL[0].SPR = hdr->SPR = 1; hdr->NRec = w5->npnts; hdr->SampleRate /= w5->sfA[0]; #ifdef IGOROLD hdr->CHANNEL[0].Cal = 1.0; hdr->CHANNEL[0].Off = 0.0; #else hdr->CHANNEL[0].PhysMax = w5->topFullScale; hdr->CHANNEL[0].PhysMin = w5->botFullScale; #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %f %f\n",__FILE__,__LINE__,w5->topFullScale,w5->botFullScale); hdr->FLAG.OVERFLOWDETECTION = !w5->fsValid; hdr->HeadLen = binHeaderSize+waveHeaderSize-4; // 4 = size of wData field in WaveHeader5 structure. } break; } if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) Wave name=%s, npnts=%d, type=0x%x.\n", __FILE__, __LINE__, hdr->CHANNEL[0].Label, (int)hdr->NRec, type); uint16_t gdftyp; double digmin=NAN, digmax=NAN; // Consider the number type, not including the complex bit or the unsigned bit. switch(type & ~(NT_CMPLX | NT_UNSIGNED)) { case NT_I8: gdftyp = 1; hdr->AS.bpb = 1; // char break; if (type & NT_UNSIGNED) { gdftyp++; digmin = ldexp(-1,7); digmax = ldexp( 1,7)-1; } else { digmin = 0; digmax = ldexp( 1,8)-1; } break; case NT_I16: gdftyp = 3; hdr->AS.bpb = 2; // short if (type & NT_UNSIGNED) { gdftyp++; digmin = ldexp(-1,15); digmax = ldexp( 1,15)-1; } else { digmin = 0; digmax = ldexp( 1,16)-1; } break; case NT_I32: gdftyp = 5; hdr->AS.bpb = 4; // long if (type & NT_UNSIGNED) { gdftyp++; digmin = ldexp(-1,31); digmax = ldexp( 1,31)-1; } else { digmin = 0; digmax = ldexp( 1,32)-1; } break; case NT_FP32: gdftyp = 16; hdr->AS.bpb = 4; // float digmin = -__FLT_MAX__; digmax = __FLT_MAX__; break; case NT_FP64: gdftyp = 17; hdr->AS.bpb = 8; // double digmin = -__DBL_MAX__; digmax = __DBL_MAX__; break; case 0: // text waves biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Igor/IBW: text waves not supported"); return; default: if (VERBOSE_LEVEL>7) fprintf(stderr,"type=%x \n",version); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Igor/IBW: unsupported or unknown data type"); return; break; } if (type & NT_CMPLX) { hdr->AS.bpb *= 2; // Complex wave - twice as many points. hdr->NS *= 2; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); strcpy(hdr->CHANNEL[2].Label,"imag part"); hdr->CHANNEL[1].Cal = 1.0; hdr->CHANNEL[1].Off = 0.0; hdr->CHANNEL[1].SPR = hdr->SPR; } typeof (hdr->NS) k; size_t bpb=0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->GDFTYP = gdftyp; hc->OnOff = 1; hc->DigMin = digmin; hc->DigMax = digmax; #ifdef IGOROLD hc->PhysMax = digmax * hc->Cal + hc->Off; hc->PhysMin = digmin * hc->Cal + hc->Off; #else hc->Cal = (hc->PhysMax - hc->PhysMin) / (digmax - digmin); hc->Off = hc->PhysMin - hc->DigMin * hc->Cal; if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) %f %f %f %f.\n", __FILE__, __LINE__, hc->PhysMax, hc->PhysMin, digmax, digmin); #endif hc->LeadIdCode = 0; hc->bi = bpb; hc->Transducer[0] = 0; hc->TOffset = 0; hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->Impedance = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; bpb += GDFTYP_BITS[gdftyp]/8; } hdr->FILE.POS = 0; hdr->AS.first = 0; hdr->AS.length= 0; hdr->data.block = NULL; hdr->AS.rawdata = NULL; if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) %i %i %i 0x%x\n", __FILE__, __LINE__, (int)hdr->HeadLen, (int)hdr->FILE.size, (int)(hdr->AS.bpb*hdr->NRec), (int)(hdr->HeadLen+hdr->AS.bpb*hdr->NRec)); #ifndef IGOROLD size_t endpos = hdr->HeadLen + hdr->AS.bpb * hdr->NRec; if (endpos < hdr->FILE.size) { /* * If data were recorded with NeuroMatic/NClamp: http://www.neuromatic.thinkrandom.com/ * some additional information like SamplingRate, Scaling, etc. can be obtained from * a text block at the end of a file. */ size_t sz = hdr->FILE.size-endpos; char *tmpstr = malloc(sz+1); ifseek(hdr, endpos, SEEK_SET); ifread(tmpstr, 1, sz, hdr); tmpstr[sz]=0; char *ptr = tmpstr; // skip 0-bytes at the beginning of the block while ((ptr != (tmpstr+sz)) && (*ptr==0)) { ptr++; } if (ptr != tmpstr + sz) { // if block is not empty if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) [%i]<%s>\n", __FILE__, __LINE__, sz, ptr); // parse lines char *line = strtok(ptr,"\n\r\0"); CHANNEL_TYPE *hc = hdr->CHANNEL+0; struct tm t; while (line != NULL) { if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) <%s>\n", __FILE__, __LINE__, line); size_t p = strcspn(line,":"); // search for field delimiter if (!strncmp(line,"ADCname",p)) { strncpy(hc->Label,line+p+1,MAX_LENGTH_LABEL+1); hc->Label[MAX_LENGTH_LABEL]=0; } else if (!strncmp(line,"ADCunits",p)) { hc->PhysDimCode = PhysDimCode(line+p+1); if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) %s<%s>\n", __FILE__, __LINE__, line+p+1, PhysDim3(hc->PhysDimCode)); } else if (!strncmp(line,"ADCunitsX",p)) { if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) Fs=%f %s\n", __FILE__, __LINE__, hdr->SampleRate, line+p+1); if (!strcmp(line+p+1,"msec")) line[p+3]=0; hdr->SampleRate /= PhysDimScale(PhysDimCode(line+p+1)); if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) %f Hz\n", __FILE__, __LINE__, hdr->SampleRate); } else if (!strncmp(line,"ADCscale",p)) { hc->Cal = strtod(line+p+1,NULL); if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) Cal %f %s\n", __FILE__, __LINE__, hc->Cal, line+p+1); hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; hc->Label[MAX_LENGTH_LABEL]=0; } else if (!strncmp(line,"Time",p)) { ptr = line; // replace separator with : while (*ptr) { if (*ptr==',') *ptr=':'; ptr++; } strptime(line+p+1,"%H:%M:%S",&t); if (VERBOSE_LEVEL > 7) fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, line); if (VERBOSE_LEVEL > 7) { char tmp[30]; strftime(tmp,30,"%F %T",&t); fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, tmp); } } else if (!strncmp(line,"Date",p)) { strptime(line+p+1,"%d %b %Y",&t); t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; if (VERBOSE_LEVEL > 7) { char tmp[30]; strftime(tmp,30,"%F %T",&t); fprintf(stdout, "%s (line %i) %s\n", __FILE__, __LINE__, tmp); } } else if (!strncmp(line,"Time Stamp",p)) { //hdr->SampleRate *= hdr->SPR*hdr->NRec/strtod(line+p+1,NULL); } line = strtok(NULL, "\n\r\0"); } hdr->T0 = tm_time2gdf_time(&t); } if (tmpstr) free(tmpstr); } #endif // not defined IGOROLD } /* * utility functions for managing List of Sweep names */ struct sweepnames_t { size_t idx; char *name; struct sweepnames_t *next; }; size_t search_sweepnames(struct sweepnames_t* list, const char* name) { /* first element starts with 1 zero is returned in case of empty list */ struct sweepnames_t* next=list; for (next=list; next!=NULL; next=next->next) { if (!strcmp(next->name, name)) return next->idx; } return 0; } struct sweepnames_t* add_sweepnames(struct sweepnames_t* list, const char* name) { struct sweepnames_t* next = (struct sweepnames_t*)malloc(sizeof(struct sweepnames_t)); next->name = strdup(name); next->idx = list==NULL ? 1 : list->idx+1; next->next = list; return next; } size_t count_sweepnames(struct sweepnames_t* list) { size_t count = 0; for (; list!=NULL; list=list->next) count++; return count; } void clear_sweepnames(struct sweepnames_t* list) { if (list==NULL) return; if (list->name) free(list->name); clear_sweepnames(list->next); free(list->next); } void sopen_itx_read (HDRTYPE* hdr) { #define IGOR_MAXLENLINE 400 char line[IGOR_MAXLENLINE+1]; char flagData = 0; char flagSupported = 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) start reading %s,v%4.2f format (%i)\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION,ifeof(hdr)); typeof(hdr->SPR) SPR = 0, spr = 0; typeof(hdr->NS) ns = 0; int chanNo=0, sweepNo=0; hdr->SPR = 0; hdr->NRec= 0; struct sweepnames_t* sweepname_list=NULL; /* checks the structure of the file and extracts formating information */ ifseek(hdr,0,SEEK_SET); int c = ifgetc(hdr); // read first character while (!ifeof(hdr)) { if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i) start reading %s,v%4.2f format (%i)\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION,(int)iftell(hdr)); int i = 0; while ( (c != -1) && (c != 10) && (c != 13) && (i < IGOR_MAXLENLINE) ) { // terminate when any line break occurs line[i++] = c; c = ifgetc(hdr); }; line[i] = 0; while (isspace(c)) c = ifgetc(hdr); // keep first non-space character of next line in buffer if (VERBOSE_LEVEL>8) fprintf(stdout,"\t%s (line %i) <%s> (%i)\n",__FILE__,__LINE__,line,(int)iftell(hdr)); if (!strncmp(line,"BEGIN",5)) { flagData = 1; spr = 0; hdr->CHANNEL[ns].bi = SPR*sizeof(double); } else if (!strncmp(line,"END",3)) { flagData = 0; if ((SPR!=0) && (SPR != spr)) { flagSupported = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) ITX (not supported): %i, %i \n",__FILE__,__LINE__, SPR, spr); } else SPR = spr; if (ns==0) hdr->SPR += SPR; } else if (!strncmp(line,"X SetScale/P x",14)) { /* This line seems to have inconsistant formating, some times an comma is following the first 14 bytes, some times no comma is found. here are some examples X SetScale/P x, 0.000000000E+00, 5.000000000E-05,"s", AP101222bp_1_63_1_2 X SetScale/P x 0,5e-05,"s", f0ch1w1_1_0to0_Co_TCh; SetScale y 0,1e-09,"A", f0ch1w1_1_0to0_Co_TCh */ double TOffset = atof(strtok(line+15,",")); if (isnan(hdr->CHANNEL[ns].TOffset)) hdr->CHANNEL[ns].TOffset = TOffset; else if (fabs(hdr->CHANNEL[ns].TOffset - TOffset) > 1e-12) fprintf(stderr,"Warning TOffsets in channel #%i do not match (%f,%f)", ns, hdr->CHANNEL[ns].TOffset, TOffset); double dur = atof(strtok(NULL,",")); char *p = strchr(line,'"'); if (p != NULL) { p++; char *p2 = strchr(p,'"'); if (p2 != NULL) *p2=0; dur *= PhysDimScale(PhysDimCode(p)); } double div = spr / (hdr->SampleRate * dur); if (ns==0) { hdr->SampleRate = 1.0 / dur; } else if (hdr->SampleRate == 1.0 / dur) ; else if (div == floor(div)) { hdr->SampleRate *= div; } } else if (!strncmp(line,"X SetScale y,",13)) { char *p = strchr(line,'"'); if (p!=NULL) { p++; char *p2 = strchr(p,'"'); if (p2!=NULL) *p2=0; if (hdr->CHANNEL[ns].PhysDimCode == 0) hdr->CHANNEL[ns].PhysDimCode = PhysDimCode(p); else if (hdr->CHANNEL[ns].PhysDimCode != PhysDimCode(p)) { flagSupported = 0; // physical units do not match if (VERBOSE_LEVEL>7) fprintf(stdout,"[%s:%i] ITX (not supported): %i, %i,<%s> \n",__FILE__,__LINE__, hdr->CHANNEL[ns].PhysDimCode,PhysDimCode(p),p); } } } else if (!strncmp(line,"WAVES",5)) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): <%s>#%i: %i/%i\n",__FILE__,__LINE__,line,(int)ns,(int)spr,(int)hdr->SPR); char *p; p = strrchr(line,'_'); ns = 0; sweepNo = 0; if (p != NULL) { chanNo = strtol(p+1, NULL, 10); if (chanNo > 0) ns = chanNo - 1; // if decoding fails, assume there is only a single channel p[0] = 0; if (search_sweepnames(sweepname_list, line) == 0) { // when sweep not found, add to list sweepname_list = add_sweepnames(sweepname_list, line); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) ITX (supported %i): %i, %i, %i, %i, %i\n",__FILE__,__LINE__, flagSupported, (int)ns, (int)spr, (int)hdr->SPR, chanNo, sweepNo); if (ns >= hdr->NS) { hdr->NS = ns+1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): <%s>#%i: %i/%i\n",__FILE__,__LINE__,line,(int)ns,(int)spr,(int)hdr->SPR); CHANNEL_TYPE* hc = hdr->CHANNEL + ns; strncpy(hc->Label, line+6, MAX_LENGTH_LABEL); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): <%s>#%i: %i/%i\n",__FILE__,__LINE__,line,(int)ns,(int)spr,(int)hdr->SPR); hc->OnOff = 1; hc->GDFTYP = 17; hc->DigMax = (double)(int16_t)(0x7fff); hc->DigMin = (double)(int16_t)(0x8000); hc->LeadIdCode = 0; hc->Cal = 1.0; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = NAN; hc->HighPass = NAN; hc->TOffset = NAN; hc->PhysMax = hc->Cal * hc->DigMax; hc->PhysMin = hc->Cal * hc->DigMin; hc->PhysDimCode = 0; // decode channel number and sweep number if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): <%s>#%i: %i/%i\n",__FILE__,__LINE__,line,(int)ns,(int)spr,(int)hdr->SPR); } else if (flagData) spr++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): scanning %s,v%4.2f format (supported: %i)\n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION,flagSupported); if (!flagSupported) { clear_sweepnames(sweepname_list); biosigERROR(hdr, hdr->AS.B4C_ERRNUM, "This ITX format is not supported. Possible reasons: not generated by Heka-Patchmaster, corrupted, physical units do not match between sweeps, or do not fulfil some other requirements"); return; } hdr->NRec = count_sweepnames(sweepname_list); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): [%i,%i,%i] = %i, %i\n",__FILE__,__LINE__,(int)hdr->NS,(int)hdr->SPR,(int)hdr->NRec,(int)hdr->NRec*hdr->SPR*hdr->NS, (int)hdr->AS.bpb); hdr->EVENT.N = hdr->NRec - 1; hdr->EVENT.SampleRate = hdr->SampleRate; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N * sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N * sizeof(*hdr->EVENT.TYP)); #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp = (gdf_time*)realloc(hdr->EVENT.TimeStamp, hdr->EVENT.N*sizeof(gdf_time)); #endif hdr->NRec = hdr->SPR; hdr->SPR = 1; hdr->AS.first = 0; hdr->AS.length = hdr->NRec; hdr->AS.bpb = sizeof(double)*hdr->NS; for (ns=0; ns < hdr->NS; ns++) { hdr->CHANNEL[ns].SPR = hdr->SPR; hdr->CHANNEL[ns].bi = sizeof(double)*ns; } double *data = (double*)realloc(hdr->AS.rawdata,hdr->NRec*hdr->SPR*hdr->NS*sizeof(double)); hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); // no swapping hdr->AS.rawdata = (uint8_t*) data; /* reads and converts data into biosig structure */ spr = 0;SPR = 0; ifseek(hdr, 0, SEEK_SET); c = ifgetc(hdr); // read first character while (!ifeof(hdr)) { int i = 0; while ( (c != -1) && (c != 10) && (c != 13) && (i < IGOR_MAXLENLINE) ) { // terminate when any line break occurs line[i++] = c; c = ifgetc(hdr); }; line[i] = 0; while (isspace(c)) c = ifgetc(hdr); // keep first non-space character of next line in buffer if (!strncmp(line,"BEGIN",5)) { flagData = 1; spr = 0; } else if (!strncmp(line,"END",3)) { flagData = 0; if (chanNo+1 == hdr->NS) SPR += spr; } else if (!strncmp(line,"X SetScale y,",13)) { //ns++; } else if (!strncmp(line,"WAVES",5)) { // decode channel number and sweep number chanNo = 0; sweepNo= 0; char *p; p = strrchr(line,'_'); if (p != NULL) { chanNo = strtol(p+1,NULL,10); if (chanNo > 0) chanNo--; // if decoding fails, assume there is only a single channel. p[0] = 0; sweepNo = search_sweepnames(sweepname_list, line); if (sweepNo > 0) sweepNo--; // if decoding fails, assume there is only a single sweep } spr = 0; if (sweepNo > 0 && chanNo==0) { hdr->EVENT.POS[sweepNo-1] = SPR; hdr->EVENT.TYP[sweepNo-1] = 0x7ffe; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[sweepNo-1] = 0; #endif } } else if (flagData) { double val = atof(line); data[hdr->NS*(SPR + spr) + chanNo] = val; spr++; } } clear_sweepnames(sweepname_list); hdr->EVENT.N = sweepNo; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): reading %s,v%4.2f format finished \n",__FILE__,__LINE__,GetFileTypeString(hdr->TYPE),hdr->VERSION); hdr->SPR = 1; hdr->NRec *= hdr->SPR; hdr->AS.first = 0; hdr->AS.length = hdr->NRec; hdr->AS.bpb = sizeof(double)*hdr->NS; #undef IGOR_MAXLENLINE } #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/t210/sopen_cfs_read.c0000664000175000017500000013150614105434233020621 0ustar schloeglschloegl/* Copyright (C) 2010-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sourceforge.io/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include "../biosig.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) uint16_t cfs_data_type(uint8_t dataType) { switch (dataType) { case 0: //int8 return 1; case 1: //uint8 return 3; case 2: //int16 return 3; case 3: // uint16 return 4; case 4: // int32 return 5; case 5: //float return 16; case 6: // double return 17; case 7: // char return 0; default: return 0xffff; } } /* trim_trailing_space: trims trailing whitespaces from pascal string (pstr), and the string becomes always 0-terminated. This may mean that the last string character might be deleted, if all bytes are filled with non-zero values. no memory allocation or reallication is performed, maxLength+1 is the size of the memory allocation for pstr (pstr[0] to pstr[maxLength]). maxLength specify the string length w/o count or terminating zero byte. pascal string: first byte contains lengths, followed by characters, not null-terminated */ char *trim_trailing_space(uint8_t *pstr, unsigned maxLength) { unsigned len = min(pstr[0], maxLength); while (isspace(pstr[len]) && (len>0)) { len--; } if (len==maxLength) fprintf(stdout,"Warning %s: last and %i-th character of string <%c%c%c%c...> has been deleted\n",__func__,len,pstr[1],pstr[2],pstr[3],pstr[4]); len = min(len+1,maxLength); pstr[len]=0; pstr[0]=len; return (pstr+1); } const char *Signal6_StateTable[]={ "","State 1","State 2","State 3","State 4","State 5","State 6","State 7","State 8","State 9", "State 10","State 11","State 12","State 13","State 14","State 15","State 16","State 17","State 18","State 19", "State 20","State 21","State 22","State 23","State 24","State 25","State 26","State 27","State 28","State 29", "State 30","State 31","State 32","State 33","State 34","State 35","State 36","State 37","State 38","State 39", "State 40","State 41","State 42","State 43","State 44","State 45","State 46","State 47","State 48","State 49", "State 50","State 51","State 52","State 53","State 54","State 55","State 56","State 57","State 58","State 59", "State 60","State 61","State 62","State 63","State 64","State 65","State 66","State 67","State 68","State 69", "State 70" }; EXTERN_C void sopen_cfs_read(HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s:%i sopen_cfs_read started - %i bytes already loaded\n",__FILE__,__LINE__,hdr->HeadLen); #define H1LEN (8+14+4+8+8+2+2+2+2+2+4+2+2+74+4+40) size_t count = hdr->HeadLen; char flag_FPulse = 0; // indicates whether data was recorded using FPulse #define CFS_NEW // this flag allows to switch back to old version while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header,count*2+1); count += ifread(hdr->AS.Header+count,1,count,hdr); } hdr->AS.Header[count] = 0; hdr->FLAG.OVERFLOWDETECTION = 0; /* Implementation is based on the following reference: CFS - The CED Filing System October 2006 */ /* General Header */ // uint32_t filesize = leu32p(hdr->AS.Header+22); // unused hdr->FILE.size = leu32p(hdr->AS.Header+0x16); // file size hdr->NS = leu16p(hdr->AS.Header+0x2a); // 6 number of channels uint16_t n = leu16p(hdr->AS.Header+0x2c); // 7 number of file variables uint16_t d = leu16p(hdr->AS.Header+0x2e); // 8 number of data section variables uint16_t FileHeaderSize = leu16p(hdr->AS.Header+0x30); // 9 byte size of file header uint16_t DataHeaderSize = leu16p(hdr->AS.Header+0x32); // 10 byte size of data section header uint32_t LastDataSectionHeaderOffset = leu32p(hdr->AS.Header+0x34); // 11 last data section header offset uint16_t NumberOfDataSections = leu16p(hdr->AS.Header+0x38); // 12 last data section header offset // decode start time and date { struct tm t; char strtmp[9]; memcpy(strtmp, hdr->AS.Header+0x1a, 8); strtmp[8] = 0; // terminating null character if (VERBOSE_LEVEL>7) fprintf(stdout,"%s:%i sopen_cfs_read started [%s]\n",__FILE__,__LINE__,strtmp); t.tm_hour = atoi(strtok(strtmp,":/")); t.tm_min = atoi(strtok(NULL,":/")); t.tm_sec = atoi(strtok(NULL,":/")); memcpy(strtmp, hdr->AS.Header+0x22, 8); t.tm_mday = atoi(strtok(strtmp,"-:/")); t.tm_mon = atoi(strtok(NULL,"-:/"))-1; t.tm_year = atoi(strtok(NULL,"-:/")); if (t.tm_year<39) t.tm_year+=100; hdr->T0 = tm_time2gdf_time(&t); } if (NumberOfDataSections) { hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, (hdr->EVENT.N + 2*NumberOfDataSections - 1) * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, (hdr->EVENT.N + 2*NumberOfDataSections - 1) * sizeof(*hdr->EVENT.POS)); hdr->EVENT.TimeStamp = (typeof(hdr->EVENT.TimeStamp)) realloc(hdr->EVENT.TimeStamp, (hdr->EVENT.N + 2*NumberOfDataSections - 1) * sizeof(*hdr->EVENT.TimeStamp)); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) CFS - %d,%d,%d,0x%x,0x%x,0x%x,%d,0x%x\n",__FILE__,__LINE__,hdr->NS,n,d,FileHeaderSize,DataHeaderSize,LastDataSectionHeaderOffset,NumberOfDataSections,leu32p(hdr->AS.Header+0x86)); /* channel information */ hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); #define H2LEN (22+10+10+1+1+2+2) char* H2 = (char*)(hdr->AS.Header + H1LEN); double xPhysDimScale[100]; // CFS is limited to 99 channels typeof(hdr->NS) NS = hdr->NS; uint8_t k; uint32_t bpb=0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; /* 1 offset because CFS uses pascal type strings (first byte contains string length) in addition, the strings are \0 terminated. */ hc->OnOff = 1; hc->LeadIdCode = 0; hc->bi8 = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i) Channel #%i/%i: %i<%s>/%i<%s>\n",__FILE__,__LINE__,k+1, hdr->NS, H2[22 + k*H2LEN], H2 + 23 + k*H2LEN, H2[32 + k*H2LEN], H2 + 33 + k*H2LEN); strncpy(hc->Label, trim_trailing_space(H2 + k*H2LEN, 20), 21); // Channel name hc->PhysDimCode = PhysDimCode (trim_trailing_space(H2 + 22 + k*H2LEN,9)); // Y axis units xPhysDimScale[k] = PhysDimScale(PhysDimCode(trim_trailing_space(H2 + 32 + k*H2LEN,9))); // X axis units uint8_t dataType = H2[42 + k*H2LEN]; uint8_t dataKind = H2[43 + k*H2LEN]; //uint16_t byteSpace = leu16p(H2+44 + k*H2LEN); // stride //uint16_t next = leu16p(H2+46 + k*H2LEN); hc->GDFTYP = cfs_data_type(dataType); if (hc->GDFTYP > 580) // sizeof GDFTYP_BITS[] biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "CFS: unknown/unsupported data type !"); if (H2[43 + k * H2LEN] == 1) { // Matrix data does not return an extra channel, but contains Markers and goes into the event table. hc->OnOff = 0; NS--; } hc->bi = bpb; bpb += GDFTYP_BITS[hc->GDFTYP]>>3; // per single sample hc->Transducer[0] = '\0'; hc->Impedance = NAN; hc->TOffset = NAN; hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->XYZ[0] = NAN; hc->XYZ[1] = NAN; hc->XYZ[2] = NAN; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(line %i) Channel #%i: [%s](%i/%i) <%s>/<%s> ByteSpace%i,Next#%i\n", __FILE__, __LINE__, k+1, H2 + 1 + k*H2LEN, dataType, dataKind, H2 + 23 + k*H2LEN, H2 + 33 + k*H2LEN, leu16p(H2+44+k*H2LEN), leu16p(H2+46+k*H2LEN)); } hdr->AS.bpb = bpb; size_t datapos = H1LEN + H2LEN*hdr->NS; /* file variable information : will be extracted as application specific information // n*36 bytes */ if (VERBOSE_LEVEL>7) fprintf(stdout,"\n******* file variable information (n=%i) *********\n", n); hdr->AS.bci2000= realloc(hdr->AS.bci2000, 3); hdr->AS.bci2000[0]='\0'; for (k = 0; k < n; k++) { int i=-1; double f=NAN; size_t pos = datapos + k*36; char *desc = (char*)(hdr->AS.Header+pos+1); uint16_t typ = leu16p(hdr->AS.Header+pos+22); char *unit = (char*)(hdr->AS.Header+pos+25); uint16_t off = leu16p(hdr->AS.Header+pos+34); // if (flag_FPulse && !strcmp(desc, "Spare")) continue; /* H1LEN General Header H2LEN*NS Channel Information a 48 byte n*36 File Variable information a 36 byte d*36 DS Variable information */ size_t p3 = H1LEN + H2LEN*hdr->NS + (n+d+2)*36 + off; /***** file variable k *****/ switch (typ) { case 0: case 1: i = hdr->AS.Header[p3]; break; case 2: i = lei16p(hdr->AS.Header+p3); break; case 3: i = leu16p(hdr->AS.Header+p3); break; case 4: i = lei32p(hdr->AS.Header+p3); break; case 5: f = lef32p(hdr->AS.Header+p3); break; case 6: f = lef64p(hdr->AS.Header+p3); break; } if (VERBOSE_LEVEL>8) { fprintf(stdout,"#%2i [%i:%i] <%s>",k,typ,off,desc); if (typ<1) ; else if (typ<5) fprintf(stdout,"[%d]",i); else if (typ<7) fprintf(stdout,"[%g]",f); else if (typ==7) fprintf(stdout,"[%s]",hdr->AS.Header+p3+1); fprintf(stdout,"[%s]\n",unit); } else if (VERBOSE_LEVEL>7) { if (typ==7) fprintf(stdout,"#%2i [%i:] <%s> <%s> <%s>\n",k,typ,desc, hdr->AS.Header+p3+1,unit); } if ((typ==7) && !strncmp(desc,"Script",6)) { char *scriptline=(char*)hdr->AS.Header+p3+1; if (!strncmp(desc,"ScriptBlock",11)) { // only the script block is extracted assert(hdr->AS.Header[p3]==strlen(scriptline)); assert(hdr->AS.Header[p3+1+hdr->AS.Header[p3]]==0); // replace '\r' with '\n' in scriptline while (*scriptline) { switch (*scriptline) { case '\r': *scriptline='\n'; } scriptline++; } scriptline=(char*)hdr->AS.Header+p3+1; hdr->AS.bci2000=realloc(hdr->AS.bci2000, strlen(hdr->AS.bci2000) + strlen(scriptline) + 1); strcat(hdr->AS.bci2000, scriptline); // Flawfinder: ignore } else if (!strncmp(desc,"Scriptline",10)) { hdr->AS.bci2000=realloc(hdr->AS.bci2000, strlen(hdr->AS.bci2000) + strlen(scriptline) + 3); strcat(hdr->AS.bci2000, scriptline); // Flawfinder: ignore strcat(hdr->AS.bci2000, "\n"); // Flawfinder: ignore } } if (k==0) { // File variable zero flag_FPulse = !strcmp(unit,"FPulse"); if (typ==2) hdr->VERSION = i/100.0; else fprintf(stderr,"Warning (%s line %i): File variable zeros is not of type INT2\n",__func__,__LINE__); char *e = (char*)&(hdr->ID.Equipment); memcpy(e,unit,8); lei16a(i,e+6); } } hdr->ID.Manufacturer.Name = "CED - Cambridge Electronic Devices"; hdr->ID.Manufacturer.Model = NULL; hdr->ID.Manufacturer.Version = NULL; hdr->ID.Manufacturer.SerialNumber = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"\n******* Data Section variable information (n=%i,%i)*********\n", d,NumberOfDataSections); datapos = LastDataSectionHeaderOffset; //H1LEN + H2LEN*hdr->NS + n*36; // reverse order of data sections uint32_t *DATAPOS = (uint32_t*)malloc(sizeof(uint32_t)*NumberOfDataSections); uint16_t m; for (m = NumberOfDataSections; 0 < m; ) { DATAPOS[--m] = datapos; datapos = leu32p(hdr->AS.Header + datapos); if (VERBOSE_LEVEL>7) fprintf(stdout, "%s:%i sopen_cfs_read started: section %"PRIi16" pos %"PRIuPTR" 0x%"PRIxPTR"\n",__FILE__,__LINE__,m,datapos,datapos); } if (hdr->AS.SegSel[0] > NumberOfDataSections) { fprintf(stderr,"Warning loading CFS file: selected sweep number is larger than number of sweeps [%d,%d] - no data is loaded\n",hdr->AS.SegSel[0], NumberOfDataSections); NumberOfDataSections = 0; } else if (0 < hdr->AS.SegSel[0]) { // hack: if sweep is selected, use same method than for data with a single sweep DATAPOS[0] = DATAPOS[hdr->AS.SegSel[0]-1]; NumberOfDataSections = 1; } // void *VarChanInfoPos = hdr->AS.Header + datapos + 30; // unused char flag_ChanInfoChanged = 0; hdr->NRec = NumberOfDataSections; int Signal6_CodeDescLen = 0; size_t SPR = 0, SZ = 0; for (m = 0; m < NumberOfDataSections; m++) { int32_t tmp_event_typ=0; double tmp_event_pos=0; datapos = DATAPOS[m]; for (k = 0; k < d; k++) { /***** DS variable k information *****/ int i=-1; double f=NAN; size_t pos = H1LEN + H2LEN*hdr->NS + (n+k+1)*36; char *desc = (char*)(hdr->AS.Header+pos+1); uint16_t typ = leu16p(hdr->AS.Header+pos+22); char *unit = (char*)(hdr->AS.Header+pos+25); uint16_t off = leu16p(hdr->AS.Header+pos+34); if (flag_FPulse && !strcmp(desc, "Spare")) continue; /***** data section variable k *****/ size_t p3 = DATAPOS[m] + 30 + 24 * hdr->NS + off; switch (typ) { case 0: case 1: i = hdr->AS.Header[p3]; break; case 2: i = lei16p(hdr->AS.Header+p3); break; case 3: i = leu16p(hdr->AS.Header+p3); break; case 4: i = lei32p(hdr->AS.Header+p3); break; case 5: f = lef32p(hdr->AS.Header+p3); break; case 6: f = lef64p(hdr->AS.Header+p3); break; } if ((k==1) && (typ==4) && !strcmp(desc,"State")) { tmp_event_typ = i; if ((Signal6_CodeDescLen < i) && (i < 256)) Signal6_CodeDescLen = i; } else if ((k==3) && (typ==6) && !strcmp(desc,"Start") && !strcmp(unit,"s")) tmp_event_pos = f; if (VERBOSE_LEVEL>7) { fprintf(stdout,"#%2i [%i:%i] <%s>",k,typ,off,desc); if (typ<1) ; else if (typ<5) fprintf(stdout,"[%d]",i); else if (typ<7) fprintf(stdout,"[%g]",f); else if (typ==7) fprintf(stdout,"[%s]",hdr->AS.Header+p3+1); fprintf(stdout,"[%s]\n",unit); } } typeof (hdr->T0) TS = tmp_event_pos ? (hdr->T0 + ldexp(tmp_event_pos/(24.0*3600.0),32)) : 0; if (m>0) { hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; hdr->EVENT.POS[hdr->EVENT.N] = SPR; hdr->EVENT.TimeStamp[hdr->EVENT.N] = TS; hdr->EVENT.N++; } if (tmp_event_typ > 0) { hdr->EVENT.TYP[hdr->EVENT.N] = tmp_event_typ; hdr->EVENT.POS[hdr->EVENT.N] = SPR; hdr->EVENT.TimeStamp[hdr->EVENT.N] = TS; hdr->EVENT.N++; } if (!leu32p(hdr->AS.Header+datapos+8)) continue; // empty segment if (VERBOSE_LEVEL>7) fprintf(stdout,"\n******* DATA SECTION --%03i-- %i *********\n",m,flag_ChanInfoChanged); if (VERBOSE_LEVEL>7) fprintf(stdout,"\n[DS#%3i] 0x%x 0x%x [0x%x 0x%x szChanData=%i] 0x02%x\n", m, FileHeaderSize, \ (int)datapos, leu32p(hdr->AS.Header+datapos), leu32p(hdr->AS.Header+datapos+4), \ leu32p(hdr->AS.Header+datapos+8), leu16p(hdr->AS.Header+datapos+12)); uint32_t sz = 0; uint32_t bpb = 0, spr = 0; hdr->AS.first = 0; hdr->AS.length = 0; char flag_firstchan = 1; uint32_t xspr0 = 0; for (k = 0; k < hdr->NS; k++) { uint8_t *pos = hdr->AS.Header + datapos + 30 + 24 * k; CHANNEL_TYPE *hc = hdr->CHANNEL + k; // uint32_t bi = leu32p(pos); // unused uint32_t xspr = leu32p(pos+4); float Cal = lef32p(pos+8); float Off = lef32p(pos+12); double XCal = lef32p(pos+16); double XOff = lef32p(pos+20);// unused if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i/%i %i/%i %f+%f change SPR:%i->%i, Cal:%f->%f, Off: %f->%f\n", \ __FILE__,__LINE__, (int)m, (int)NumberOfDataSections, (int)k,(int)hdr->NS, XCal, XOff, \ (int)hc->SPR,(int)xspr,hc->Cal,Cal,hc->Off,Off); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) [%i %i] %i %i %p %i\n", __FILE__, __LINE__, m, k, xspr0, xspr, pos, (int)(datapos + 30 + 24 * k)); if (xspr0 == 0) xspr0 = xspr; else if (xspr>0) xspr0 = lcm(xspr0,xspr); else if (xspr==0) if (VERBOSE_LEVEL>7) fprintf(stdout,"Warning : #%i of section %i contains %i samples \n", (int)k, (int)m, (int)xspr); if (m > 0) { if ( (hc->Cal != Cal) || (hc->Off != Off) ) switch (hc->GDFTYP) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 16: hc->GDFTYP = 16; // float, single precision break; case 7: case 8: case 17: hc->GDFTYP = 17; // double break; case 18: // quadruple default: ; } } else { hc->Cal = Cal; hc->Off = Off; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i #%i: SPR=%i=%i=%i x%f+-%f %i x%g %g %g\n", __func__,__LINE__,m,k,spr,(int)SPR,hc->SPR,hc->Cal,hc->Off,hc->bi,xPhysDimScale[k], XCal, XOff); double Fs = 1.0 / (xPhysDimScale[k] * XCal); if ( (hc->OnOff == 0) || (XCal == 0.0) ) { ; // do nothing: } else if (flag_firstchan) { hdr->SampleRate = Fs; flag_firstchan = 0; } else if (fabs(hdr->SampleRate - Fs) > 1e-3) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: different sampling rates are not supported\n"); } sz += hc->SPR * GDFTYP_BITS[hc->GDFTYP] >> 3; hc->bi = bpb; bpb += GDFTYP_BITS[hc->GDFTYP]>>3; // per single sample hdr->AS.length += hc->SPR; } SPR += xspr0; SZ += sz; hdr->AS.bpb = bpb; } if (Signal6_CodeDescLen > 0) { if (Signal6_CodeDescLen > 70) { // 19 is sizeof Signal6_StateTable fprintf(stderr, "Warning %s (line %i): Event code description exceed table (Signal6_CodeDescLen=%i)\n",__func__,__LINE__,Signal6_CodeDescLen); Signal6_CodeDescLen = 70; } hdr->EVENT.LenCodeDesc = Signal6_CodeDescLen+1; //70 is sizeof(Signal6_StateTable) hdr->EVENT.CodeDesc = realloc(hdr->EVENT.CodeDesc, sizeof(char*) * (Signal6_CodeDescLen+1)); for (int k=0; k <= Signal6_CodeDescLen; k++) { hdr->EVENT.CodeDesc[k] = Signal6_StateTable[k]; } } /* The previous and the next loop have been split, in order to avoid multiple reallocations. Multiple reallocations seem to be a major issue for performance problems of Windows (a 50 MB file with 480 sweeps took 50 s to load). However, the two loops might contain some redundant operations. */ hdr->AS.flag_collapsed_rawdata = 0; void *ptr = realloc(hdr->AS.rawdata, hdr->AS.bpb * SPR); if (!ptr) biosigERROR(hdr,B4C_MEMORY_ALLOCATION_FAILED, "CFS: memory allocation failed in line __LINE__"); hdr->AS.rawdata = (uint8_t*)ptr; SPR = 0, SZ = 0; for (m = 0; m < NumberOfDataSections; m++) { datapos = DATAPOS[m]; if (!leu32p(hdr->AS.Header+datapos+8)) continue; // empty segment uint32_t sz = 0; uint32_t bpb = 0, spr = 0; hdr->AS.first = 0; hdr->AS.length = 0; char flag_firstchan = 1; uint32_t xspr0 = 0; float Cal, Off; for (k = 0; k < hdr->NS; k++) { uint8_t *pos = hdr->AS.Header + datapos + 30 + 24 * k; CHANNEL_TYPE *hc = hdr->CHANNEL + k; //uint32_t bi = leu32p(pos); // unused uint32_t xspr = leu32p(pos+4); hc->SPR = leu32p(pos+4); hc->Cal = lef32p(pos+8); hc->Off = lef32p(pos+12); Cal = lef32p(pos+8); Off = lef32p(pos+12); double XCal = lef32p(pos+16); double XOff = lef32p(pos+20);// unused if (xspr0 == 0) xspr0 = xspr; else if (xspr>0) xspr0 = lcm(xspr0, xspr); else if (xspr==0) if (VERBOSE_LEVEL>7) fprintf(stdout,"Warning : #%i of section %i contains %i samples \n", (int)k, (int)m, (int)xspr); assert( (xspr==0) || ((xspr0 % xspr) == 0) ); double Fs = 1.0 / (xPhysDimScale[k] * XCal); if ( (hc->OnOff == 0) || (XCal == 0.0) ) { ; // do nothing: } else if (flag_firstchan) { hdr->SampleRate = Fs; flag_firstchan = 0; } else if (fabs(hdr->SampleRate - Fs) > 1e-3) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: different sampling rates are not supported\n"); } sz += xspr * GDFTYP_BITS[hc->GDFTYP] >> 3; hc->bi = bpb; bpb += GDFTYP_BITS[hc->GDFTYP]>>3; // per single sample hdr->AS.length += xspr; } if (xspr0 > 0) { /* hack: copy data into a single block (rawdata) this is used as a data cache, no I/O is needed in sread, at the cost that sopen is slower sread_raw does not attempt to reload the data */ hdr->AS.first = 0; uint8_t ns = 0; for (k = 0; k < hdr->NS; k++) { uint8_t *pos = hdr->AS.Header + datapos + 30 + 24 * k; CHANNEL_TYPE *hc = hdr->CHANNEL + k; uint32_t memoffset = leu32p(pos); uint8_t *srcaddr = hdr->AS.Header + leu32p(hdr->AS.Header+datapos + 4) ; //uint16_t byteSpace = leu16p(H2+44 + k*H2LEN); uint8_t dataType = H2[42 + k*H2LEN]; uint8_t dataKind = H2[43 + k*H2LEN]; // equidistant, Subsidiary or Matrix data uint16_t stride = leu16p(H2+44 + k*H2LEN); // byteSpace uint16_t next = leu16p(H2+46 + k*H2LEN); uint16_t gdftyp = cfs_data_type(dataType); if (gdftyp > 580) // sizeof GDFTYP_BITS[] biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "CFS: unknown/unsupported data type !"); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) #%i %i,%i %i %i %i %i: %i @%p %i\n", __func__, __LINE__, k, dataType, dataKind, hc->SPR, gdftyp,hc->GDFTYP, stride, memoffset, srcaddr, leu32p(hdr->AS.Header+datapos + 4) + leu32p(hdr->AS.Header + datapos + 30 + 24 * k)); if (hc->OnOff==0) continue; // Time and Marker channels are not supported, yet if ((hc->SPR > 0) && (xspr0 != hc->SPR)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: samples-per-record (SPR) changes between channels - this is not supported yet."); } size_t k2; if (gdftyp == hc->GDFTYP) { for (k2 = 0; k2 < xspr0; k2++) { uint8_t *ptr = srcaddr + memoffset + k2*stride; uint8_t *dest = hdr->AS.rawdata + hc->bi + (SPR + k2) * hdr->AS.bpb; double val=NAN; switch (gdftyp) { // reorder for performance reasons - more frequent gdftyp's come first case 3: //val = lei16p(ptr); case 4: //val = leu16p(ptr); memcpy(dest, ptr, 2); break; case 16: //val = lef32p(ptr); memcpy(dest, ptr, 4); break; case 7: //val = lei64p(ptr); case 8: //val = leu64p(ptr); case 17: //val = lef64p(ptr); memcpy(dest, ptr, 8); break; case 0: //val = *( char*) ptr; case 1: //val = *( int8_t*) ptr; case 2: //val = *(uint8_t*) ptr; *dest = *ptr; break; case 5: val = lei32p(ptr); case 6: //val = leu32p(ptr); memcpy(dest, ptr, 4); break; default: val = NAN; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: invalid data type"); } if (hc->OnOff) continue; if (!strncmp(hc->Label,"Marker",6) && hc->PhysDimCode==2176 && hc->GDFTYP==5 && next != 0) { // matrix data might contain time markers. // memory allocation for additional events - more efficient implementation would be nice hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, (hdr->EVENT.N + NumberOfDataSections) * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, (hdr->EVENT.N + NumberOfDataSections) * sizeof(*hdr->EVENT.POS)); /* char Desc[2]; Desc[0] = srcaddr[hdr->CHANNEL[next].bi + k2*stride]; Desc[1] = 0; this does currently not work because FreeTextEvent expects that the string constant is available as long as hdr, which is not the case here. */ // typically a single character within a 4 byte integer, this should be sufficient to ensure \0 termination char *Desc = (char*)srcaddr + hdr->CHANNEL[next].bi + k2 * stride; Desc[1] = 0; FreeTextEvent(hdr, hdr->EVENT.N, Desc); hdr->EVENT.POS[hdr->EVENT.N] = lround( (val * hc->Cal + hc->Off) * hdr->SampleRate) + SPR; hdr->EVENT.N++; } } } else { for (k2 = 0; k2 < xspr0; k2++) { uint8_t *ptr = srcaddr + memoffset + k2*stride; uint8_t *dest = hdr->AS.rawdata + hc->bi + (SPR + k2) * hdr->AS.bpb; double val; if (hc->GDFTYP==16) { // float switch (gdftyp) { // reorder for performance reasons - more frequent gdftyp's come first case 3: val = lei16p(ptr) * Cal + Off; break; case 4: val = leu16p(ptr) * Cal + Off; break; case 16: val = lef32p(ptr) * Cal + Off; break; case 7: val = lei64p(ptr) * Cal + Off; break; case 8: val = leu64p(ptr) * Cal + Off; break; case 17: val = lef64p(ptr) * Cal + Off; break; case 0: val = (*( char*) ptr) * Cal + Off; break; case 1: val = (*( int8_t*) ptr) * Cal + Off; break; case 2: val = (*(uint8_t*) ptr) * Cal + Off; break; case 5: val = lei32p(ptr) * Cal + Off; break; case 6: val = leu32p(ptr) * Cal + Off; break; default: val = NAN; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: invalid data type"); } lef32a(val, dest); // hdr->AS.rawdata uses the native endian format of the platform } else { // any conversion to anything but float is not supported yet. biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: data type changes between segments - this is not supported yet."); } // scaling has been already consider when converting to float, do not scale in sread anymore. hc->Cal = 1.0; hc->Off = 0.0; if (hc->OnOff) continue; if (!strncmp(hc->Label,"Marker",6) && hc->PhysDimCode==2176 && hc->GDFTYP==5 && next != 0) { // matrix data might contain time markers. // memory allocation for additional events - more efficient implementation would be nice hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, (hdr->EVENT.N + NumberOfDataSections) * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, (hdr->EVENT.N + NumberOfDataSections) * sizeof(*hdr->EVENT.POS)); /* char Desc[2]; Desc[0] = srcaddr[hdr->CHANNEL[next].bi + k2*stride]; Desc[1] = 0; this does currently not work because FreeTextEvent expects that the string constant is available as long as hdr, which is not the case here. */ // typically a single character within a 4 byte integer, this should be sufficient to ensure \0 termination char *Desc = (char*)srcaddr + hdr->CHANNEL[next].bi + k2 * stride; Desc[1] = 0; FreeTextEvent(hdr, hdr->EVENT.N, Desc); hdr->EVENT.POS[hdr->EVENT.N] = lround( (val * hc->Cal + hc->Off) * hdr->SampleRate) + SPR; hdr->EVENT.N++; } } } ns += hc->OnOff; } } SPR += xspr0; SZ += sz; datapos = leu32p(hdr->AS.Header + datapos); } free(DATAPOS); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SPR=%i=%i NRec=%i @%p\n",__FILE__,__LINE__,(int)SPR,hdr->SPR,(int)hdr->NRec, hdr->AS.rawdata); // set variables such that sread_raw does not attempt to reload the data hdr->AS.first = 0; hdr->EVENT.SampleRate = hdr->SampleRate; if (NumberOfDataSections < 1) { hdr->SPR = 0; } else { hdr->SPR = 1; hdr->NRec = SPR; hdr->AS.length = SPR; size_t bpb = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; assert(hc->bi==bpb); bpb += GDFTYP_BITS[hc->GDFTYP] >> 3; hc->SPR = hdr->SPR; } assert(hdr->AS.bpb==bpb); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SPR=%i=%i NRec=%i\n",__func__,__LINE__,(int)SPR,hdr->SPR,(int)hdr->NRec); datapos = FileHeaderSize; //+DataHeaderSize; if (flag_ChanInfoChanged) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "CED/CFS: varying channel information not supported"); } for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; switch (hc->GDFTYP) { case 0: case 1: hc->DigMax = 127; hc->DigMin = -128; break; case 2: hc->DigMax = 255; hc->DigMin = 0; break; case 3: hc->DigMax = (int16_t)0x7fff; hc->DigMin = (int16_t)0x8000; break; case 4: hc->DigMax = 0xffff; hc->DigMin = 0; break; case 16: case 17: hc->DigMax = 1e9; hc->DigMin = -1e9; break; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (%i): %f %f %f %f %f %f\n",__FILE__,__LINE__,hc->PhysMax, hc->DigMax, hc->Cal, hc->Off,hc->PhysMin, hc->DigMin ); hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (%i): %f %f %f %f %f %f\n",__FILE__,__LINE__,hc->PhysMax, hc->DigMax, hc->Cal, hc->Off,hc->PhysMin, hc->DigMin ); } #undef H1LEN } /***************************************************************************** SOPEN_SMR_READ for reading SON/SMR files son.h, sonintl.h are used just for understanding the file format. and are not needed for the core functionality. TODO: Currently waveform data is supported, events and marker information is ignored *****************************************************************************/ #if defined(WITH_SON) #include "sonintl.h" // defines __SONINTL__ #else #define ADCdataBlkSize 32000 #endif EXTERN_C void sopen_smr_read(HDRTYPE* hdr) { /*TODO: implemnt SON/SMR format */ fprintf(stdout,"SOPEN: Support for CED's SMR/SON format is under construction \n"); size_t count = hdr->HeadLen; if (count < 512) { hdr->HeadLen = 512; // make sure fixed header (first 512 bytes) are read hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen+1); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); hdr->AS.Header[count]=0; } // get Endianity, Version and Header size hdr->FILE.LittleEndian = (*(uint16_t*)(hdr->AS.Header+38) == 0); // 0x0000: little endian, 0x0101: big endian if (hdr->FILE.LittleEndian) { hdr->VERSION = leu16p(hdr->AS.Header); hdr->HeadLen = leu32p(hdr->AS.Header + 26 ); // first data } else { hdr->VERSION = beu16p(hdr->AS.Header); hdr->HeadLen = beu32p(hdr->AS.Header + 26); // first data // TODO: relax this restriction biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "SON/SMR: big-endian file not supported,yet"); } size_t HeadLen = hdr->HeadLen; size_t size_factor = 1; if (hdr->VERSION >= 9) { size_factor = 512; HeadLen *= size_factor; if (sizeof(size_t) <= 4) { // TODO: relax that restriction biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "SON/SMR: version 9 (bigfile) not supported,yet"); return; } } if (count < HeadLen) { // read channel header and extra data (i.e. everything up to firstData) hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,HeadLen+1); count += ifread(hdr->AS.Header+count, 1, HeadLen-count, hdr); hdr->AS.Header[count]=0; } #ifdef __SONINTL__ if (VERBOSE_LEVEL > 6) { TFileHead *tfh = (void*)(hdr->AS.Header); TChannel *tc = (void*)(hdr->AS.Header+512); // debugging information fprintf(stdout,"\tsizeof TFileHead %i\n\tsizeof TChannel %i\n\tsizeof TDataBlock %i\n", (int)sizeof(TFileHead),(int)sizeof(TChannel),(int)sizeof(TDataBlock)); fprintf(stdout,"%i NS=%i %i %i %i\n", (int)sizeof(*tfh),hdr->NS,(int)offsetof(TFileHead,channels),(int)sizeof(TChannel),(int)sizeof(TDataBlock)); fprintf(stdout,"systemID\t%i %i %i\n",(int)offsetof(TFileHead,systemID), (int)sizeof(tfh->systemID),lei16p(hdr->AS.Header+offsetof(TFileHead,systemID))); fprintf(stdout,"copyright\t%i %i\n",(int)offsetof(TFileHead,copyright),(int)sizeof(tfh->copyright)); fprintf(stdout,"creator \t%i %i <%8s>\n",(int)offsetof(TFileHead,creator), (int)sizeof(tfh->creator),hdr->AS.Header+offsetof(TFileHead,creator)); fprintf(stdout,"usPerTime\t%i %i %i\n",(int)offsetof(TFileHead,usPerTime), (int)sizeof(tfh->usPerTime),lei16p(hdr->AS.Header+offsetof(TFileHead,usPerTime))); fprintf(stdout,"timePerADC\t%i %i %i\n",(int)offsetof(TFileHead,timePerADC), (int)sizeof(tfh->timePerADC),lei16p(hdr->AS.Header+offsetof(TFileHead,timePerADC))); fprintf(stdout,"fileState\t%i %i %i\n",(int)offsetof(TFileHead,fileState), (int)sizeof(tfh->fileState),lei16p(hdr->AS.Header+offsetof(TFileHead,fileState))); fprintf(stdout,"firstData\t%i %i %i\n",(int)offsetof(TFileHead,firstData), (int)sizeof(tfh->firstData),lei32p(hdr->AS.Header+offsetof(TFileHead,firstData))); fprintf(stdout,"channels\t%i %i 0x%04x\n",(int)offsetof(TFileHead,channels), (int)sizeof(tfh->channels),lei16p(hdr->AS.Header+offsetof(TFileHead,channels))); fprintf(stdout,"chanSize\t%i %i 0x%04x\n",(int)offsetof(TFileHead,chanSize), (int)sizeof(tfh->chanSize),lei16p(hdr->AS.Header+offsetof(TFileHead,chanSize))); fprintf(stdout,"extraData\t%i %i %i\n",(int)offsetof(TFileHead,extraData), (int)sizeof(tfh->extraData),lei16p(hdr->AS.Header+offsetof(TFileHead,extraData))); fprintf(stdout,"bufferSz\t%i %i %i\n",(int)offsetof(TFileHead,bufferSz), (int)sizeof(tfh->bufferSz),lei16p(hdr->AS.Header+offsetof(TFileHead,bufferSz))); fprintf(stdout,"osFormat\t%i %i %i\n",(int)offsetof(TFileHead,osFormat), (int)sizeof(tfh->osFormat),lei16p(hdr->AS.Header+offsetof(TFileHead,osFormat))); fprintf(stdout,"maxFTime\t%i %i %i\n",(int)offsetof(TFileHead,maxFTime), (int)sizeof(tfh->maxFTime),lei32p(hdr->AS.Header+offsetof(TFileHead,maxFTime))); fprintf(stdout,"dTimeBase\t%i %i %g\n",(int)offsetof(TFileHead,dTimeBase), (int)sizeof(tfh->dTimeBase),lef64p(hdr->AS.Header+offsetof(TFileHead,dTimeBase))); fprintf(stdout,"timeDate\t%i %i\n",(int)offsetof(TFileHead,timeDate),(int)sizeof(tfh->timeDate)); fprintf(stdout,"cAlignFlag\t%i %i\n",(int)offsetof(TFileHead,cAlignFlag),(int)sizeof(tfh->cAlignFlag)); fprintf(stdout,"pad0 \t%i %i\n",(int)offsetof(TFileHead,pad0),(int)sizeof(tfh->pad0)); fprintf(stdout,"LUTable \t%i %i\n",(int)offsetof(TFileHead,LUTable),(int)sizeof(tfh->LUTable)); fprintf(stdout,"pad \t%i %i\n",(int)offsetof(TFileHead,pad),(int)sizeof(tfh->pad)); fprintf(stdout,"fileComment\t%i %i\n",(int)offsetof(TFileHead,fileComment),(int)sizeof(tfh->fileComment)); fprintf(stdout,"==CHANNEL==\n"); fprintf(stdout,"delSize \t%i %i\n",(int)offsetof(TChannel,delSize),(int)sizeof(tc->delSize)); fprintf(stdout,"nextDelBlock\t%i %i\n",(int)offsetof(TChannel,nextDelBlock),(int)sizeof(tc->nextDelBlock)); fprintf(stdout,"firstBlock\t%i %i\n",(int)offsetof(TChannel,firstBlock),(int)sizeof(tc->firstBlock)); fprintf(stdout,"lastBlock\t%i %i\n",(int)offsetof(TChannel,lastBlock),(int)sizeof(tc->lastBlock)); fprintf(stdout,"blocks \t%i %i\n",(int)offsetof(TChannel,blocks),(int)sizeof(tc->blocks)); fprintf(stdout,"nExtra \t%i %i\n",(int)offsetof(TChannel,nExtra),(int)sizeof(tc->nExtra)); fprintf(stdout,"preTrig \t%i %i\n",(int)offsetof(TChannel,preTrig),(int)sizeof(tc->preTrig)); fprintf(stdout,"blocksMSW\t%i %i\n",(int)offsetof(TChannel,blocksMSW),(int)sizeof(tc->blocksMSW)); fprintf(stdout,"phySz \t%i %i\n",(int)offsetof(TChannel,phySz),(int)sizeof(tc->phySz)); fprintf(stdout,"maxData \t%i %i\n",(int)offsetof(TChannel,maxData),(int)sizeof(tc->maxData)); fprintf(stdout,"comment \t%i %i\n",(int)offsetof(TChannel,comment),(int)sizeof(tc->comment)); fprintf(stdout,"maxChanTime \t%i %i\n",(int)offsetof(TChannel,maxChanTime),(int)sizeof(tc->maxChanTime)); fprintf(stdout,"lChanDvd\t%i %i\n",(int)offsetof(TChannel,lChanDvd),(int)sizeof(tc->lChanDvd)); fprintf(stdout,"phyChan \t%i %i\n",(int)offsetof(TChannel,phyChan),(int)sizeof(tc->phyChan)); fprintf(stdout,"title \t%i %i %s\n",(int)offsetof(TChannel,title),(int)sizeof(tc->title),((char*)&(tc->title))+1); fprintf(stdout,"idealRate\t%i %i\n",(int)offsetof(TChannel,idealRate),(int)sizeof(tc->idealRate)); fprintf(stdout,"kind \t%i %i\n",(int)offsetof(TChannel,kind),(int)sizeof(tc->kind)); fprintf(stdout,"delSizeMSB\t%i %i\n",(int)offsetof(TChannel,delSizeMSB),(int)sizeof(tc->delSizeMSB)); fprintf(stdout,"v.adc.scale\t%i %i\n",(int)offsetof(TChannel,v.adc.scale),(int)sizeof(tc->v.adc.scale)); fprintf(stdout,"v.adc.offset\t%i %i\n",(int)offsetof(TChannel,v.adc.offset),(int)sizeof(tc->v.adc.offset)); fprintf(stdout,"v.adc.units\t%i %i\n",(int)offsetof(TChannel,v.adc.units),(int)sizeof(tc->v.adc.units)); fprintf(stdout,"v.adc.divide\t%i %i\n",(int)offsetof(TChannel,v.adc.divide),(int)sizeof(tc->v.adc.divide)); fprintf(stdout,"v.event.initLow\t%i %i\n",(int)offsetof(TChannel,v.event.initLow),(int)sizeof(tc->v.event.initLow)); fprintf(stdout,"v.event.nextLow\t%i %i\n",(int)offsetof(TChannel,v.event.nextLow),(int)sizeof(tc->v.event.nextLow)); fprintf(stdout,"v.real.min\t%i %i\n",(int)offsetof(TChannel,v.real.min),(int)sizeof(tc->v.real.min)); fprintf(stdout,"v.real.max\t%i %i\n",(int)offsetof(TChannel,v.real.max),(int)sizeof(tc->v.real.max)); fprintf(stdout,"v.real.units\t%i %i\n",(int)offsetof(TChannel,v.real.units),(int)sizeof(tc->v.real.units)); assert(sizeof(TSONTimeDate)==8); assert(sizeof(TFileHead)==512); assert(sizeof(TChannel)==140); assert(sizeof(TDataBlock)==64020); } #endif uint16_t timePerADC; uint32_t maxFTime; double timebase,dTimeBase; memcpy(&hdr->ID.Equipment, hdr->AS.Header+12, 8); if (hdr->FILE.LittleEndian) { timebase = hdr->VERSION < 6 ? 1e-6 : lef64p(hdr->AS.Header + 44); hdr->SampleRate = 1.0 / (timebase * leu16p(hdr->AS.Header + 20) ); hdr->NS = leu16p(hdr->AS.Header + 30 ); timePerADC = lei16p(hdr->AS.Header + 22); maxFTime = leu32p(hdr->AS.Header + 40); dTimeBase = lef64p(hdr->AS.Header + 44); } else { timebase = hdr->VERSION < 6 ? 1e-6 : bef64p(hdr->AS.Header + 44); hdr->SampleRate = 1.0 / (timebase * beu16p(hdr->AS.Header + 20)); hdr->NS = beu16p(hdr->AS.Header + 30); timePerADC = bei16p(hdr->AS.Header + 22); maxFTime = beu32p(hdr->AS.Header + 40); dTimeBase = bef64p(hdr->AS.Header + 44); } hdr->SPR = 1; while (!ifeof(hdr)) { // read channel header and extra data hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen*2); hdr->HeadLen *= 2; count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } hdr->HeadLen = count; /********************************************* read channel header *********************************************/ hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); typeof(hdr->NS) k; size_t bpb = 0; for (k = 0; k < hdr->NS; k++) { uint32_t off = 512 + k*140; CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Cal = lef32p(hdr->AS.Header + off + 124); // v.adc.scale hc->Off = lef32p(hdr->AS.Header + off + 128); // v.adc.off hc->OnOff = 0; //*(int16_t*)(hdr->AS.Header + off + 106) != 0; hc->SPR = 0; hc->GDFTYP = 3; hc->LeadIdCode = 0; hc->Transducer[0] = '\0'; int stringLength = hdr->AS.Header[off+108]; assert(stringLength < MAX_LENGTH_LABEL); memcpy(hc->Label, hdr->AS.Header+off+108+1, stringLength); hc->Label[stringLength] = '\0'; { // extract Physical units (pascal string - first byte indicates the length, no 0-terminator) stringLength = hdr->AS.Header[off+132]; char PhysicalUnit[6]; assert( stringLength < sizeof(PhysicalUnit) ); memcpy(PhysicalUnit, hdr->AS.Header+off+132+1, stringLength); PhysicalUnit[stringLength] = '\0'; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): #%i <%s> <%s>\n",__FILE__,__LINE__, k+1, hc->Label, PhysicalUnit); if (!strcmp(PhysicalUnit,"Volt") || !strcmp(PhysicalUnit," Volt")) hc->PhysDimCode = 4256; else if (!strcmp(PhysicalUnit,"mVolt")) hc->PhysDimCode = 4274; else if (!strcmp(PhysicalUnit,"uVolt")) hc->PhysDimCode = 4275; else hc->PhysDimCode = PhysDimCode(PhysicalUnit); } uint32_t firstBlock = leu32p(hdr->AS.Header+off+6); uint32_t lastBlock = leu32p(hdr->AS.Header+off+10); hc->bi = bpb; hc->bi8= 0; uint8_t kind = hdr->AS.Header[off+122]; switch (kind) { case 0: // // ChanOff=0, /* the channel is OFF - */ hc->OnOff = 0; break; case 1: { // Adc, /* a 16-bit waveform channel */ hc->OnOff = 1; hc->GDFTYP = 3; hc->Cal = lef32p(hdr->AS.Header + off + 124) / 6553.6; hc->Off = lef32p(hdr->AS.Header + off + 128); hc->DigMax = (double)(int16_t)0x7fff; hc->DigMin = (double)(int16_t)0x8000; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; uint32_t blocks = leu16p(hdr->AS.Header+off+14); size_t bpbnew = bpb + blocks * ADCdataBlkSize * 2; hdr->AS.rawdata = realloc(hdr->AS.rawdata,bpbnew); uint32_t pos = firstBlock; while (1) { uint32_t items = leu16p(hdr->AS.Header+pos+18); memcpy(hdr->AS.rawdata+bpb, hdr->AS.Header+pos+20, items*2); bpb += items*2; hc->SPR += items; if (pos == lastBlock) break; pos = leu32p(hdr->AS.Header+pos+4); }; hdr->SPR = lcm(hdr->SPR, hc->SPR); break; } case 2: // EventFall, /* Event times (falling edges) */ hc->OnOff = 0; break; case 3: // EventRise, /* Event times (rising edges) */ hc->OnOff = 0; break; case 4: // EventBoth, /* Event times (both edges) */ hc->OnOff = 0; break; case 5: // Marker, /* Event time plus 4 8-bit codes */ hc->OnOff = 0; break; case 6: // AdcMark, /* Marker plus Adc waveform data */ hc->OnOff = 0; break; case 7: // RealMark, /* Marker plus float numbers */ hc->OnOff = 0; break; case 8: // TextMark, /* Marker plus text string */ hc->OnOff = 0; break; case 9: { // RealWave /* waveform of float numbers */ hc->OnOff = 1; hc->GDFTYP = 16; hc->LeadIdCode = 0; hc->Cal = lef32p(hdr->AS.Header + off + 124) / 6553.6; hc->Off = lef32p(hdr->AS.Header + off + 128); hc->DigMax = +1e9; hc->DigMin = -1e9; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; uint32_t blocks = leu16p(hdr->AS.Header+off+14); size_t bpbnew = bpb + blocks * ADCdataBlkSize * 4; hdr->AS.rawdata = realloc(hdr->AS.rawdata, bpbnew); uint32_t pos = firstBlock; while (1) { uint32_t items = leu16p(hdr->AS.Header+pos+18); memcpy(hdr->AS.rawdata+bpb, hdr->AS.Header+pos+20, items*4); bpb += items*4; hc->SPR += items; if (pos == lastBlock) break; pos = leu32p(hdr->AS.Header+pos+4); } hdr->SPR = lcm(hdr->SPR, hc->SPR); break; } default: // unknown hc->OnOff = 0; fprintf(stderr,"SMR/SON: channel %i ignored - unknown type %i\n",k,kind); } if (VERBOSE_LEVEL > 6) { char tmp[98-26+1]; fprintf(stdout,"[%i].delSize\t%i\n",k,lei16p(hdr->AS.Header+off)); fprintf(stdout,"[%i].nextDelBlock\t%i\n",k,leu32p(hdr->AS.Header+off+2)); fprintf(stdout,"[%i].firstBlock\t%i\n",k,leu32p(hdr->AS.Header+off+6)); fprintf(stdout,"[%i].lastBlock\t%i\n",k,leu32p(hdr->AS.Header+off+10)); fprintf(stdout,"[%i].blocks\t%i\n",k,leu16p(hdr->AS.Header+off+14)); fprintf(stdout,"[%i].nExtra\t%i\n",k,leu16p(hdr->AS.Header+off+16)); fprintf(stdout,"[%i].preTrig\t%i\n",k,lei16p(hdr->AS.Header+off+18)); fprintf(stdout,"[%i].blocksMSW\t%i\n",k,lei16p(hdr->AS.Header+off+20)); fprintf(stdout,"[%i].phySz\t%i\n",k,lei16p(hdr->AS.Header+off+22)); fprintf(stdout,"[%i].maxData\t%i\n",k,lei16p(hdr->AS.Header+off+24)); stringLength = hdr->AS.Header[off+26]; assert(stringLength < sizeof(tmp)); memcpy(tmp, hdr->AS.Header+off+26+1, 9); tmp[stringLength] = 0; fprintf(stdout,"[%i].comment\t<%s>\n",(int)k,tmp); fprintf(stdout,"[%i].maxChanTime\t%i\t%i\n",(int)k,lei32p(hdr->AS.Header+off+98),*(int32_t*)(hdr->AS.Header+off+98)); fprintf(stdout,"[%i].lChanDvd\t%i\n",(int)k,lei32p(hdr->AS.Header+off+102)); fprintf(stdout,"[%i].phyChan\t%i\n",(int)k,lei16p(hdr->AS.Header+off+106)); stringLength = hdr->AS.Header[off+108]; assert(stringLength < sizeof(tmp)); memcpy(tmp, hdr->AS.Header+off+108+1,9); tmp[stringLength] = 0; fprintf(stdout,"[%i].title\t<%s>\n",(int)k,tmp); fprintf(stdout,"[%i].idealRate\t%f\n",(int)k,lef32p(hdr->AS.Header+off+118)); fprintf(stdout,"[%i].kind\t%i\n",(int)k,*(hdr->AS.Header+off+122)); fprintf(stdout,"[%i].delSizeMSB\t%i\n",(int)k,*(hdr->AS.Header+off+123)); fprintf(stdout,"[%i].v.adc.scale\t%f\n",(int)k,lef32p(hdr->AS.Header+off+124)); fprintf(stdout,"[%i].v.adc.offset\t%f\n",(int)k,lef32p(hdr->AS.Header+off+128)); stringLength = hdr->AS.Header[off+132]; assert(stringLength < sizeof(tmp)); memcpy(tmp, hdr->AS.Header+off+132+1, 5); tmp[stringLength] = 0; fprintf(stdout,"[%i].v.adc.units\t%s\n", (int)k, tmp); fprintf(stdout,"[%i].v.adc.divide\t%i\n", (int)k, lei16p(hdr->AS.Header+off+138)); fprintf(stdout,"[%i].v.real.max\t%f\n", (int)k, lef32p(hdr->AS.Header+off+124)); fprintf(stdout,"[%i].v.real.min\t%f\n", (int)k, lef32p(hdr->AS.Header+off+128)); fprintf(stdout,"[%i].v.real.units\t%s\n", (int)k, hdr->AS.Header+off+132+1); fprintf(stdout,"[%i].v.event\t%0x\t%g\n", (int)k, leu32p(hdr->AS.Header+off+124), lef32p(hdr->AS.Header+off+124)); } } hdr->NRec = 1; hdr->AS.bpb = bpb; } biosig-2.3.3/biosig4c++/t210/sopen_rhd2000_read.c0000664000175000017500000005444614105434233021134 0ustar schloeglschloegl/* Copyright (C) 2019,2020 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ /* References: [1] RHD2000 Application Note: Data File Formats, Intan TECHNOLOGIES, LLC Downloaded 2020-01-14 from http://www.intantech.com/files/Intan_RHD2000_data_file_formats.pdf [2] RHS2000 Data File Formats - Intan Tech http://www.intantech.com/files/Intan_RHS2000_data_file_formats.pdf */ #include #include #include #include #include #include #if !defined(__APPLE__) && defined (_LIBICONV_H) #define iconv libiconv #define iconv_open libiconv_open #define iconv_close libiconv_close #endif #include "../gdftime.h" #include "../biosig-dev.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #ifdef __cplusplus extern "C" { #endif /* get_qstring has the following functions and side effects: *) check whether sufficient data of the header information has been read, reads more data if needed, *) advance position pointer pos to the end of the string; *) convert QString into UTF-8 String in outbuf */ void read_qstring(HDRTYPE* hdr, size_t *pos, char *outbuf, size_t outlen) { uint32_t len = leu32p(hdr->AS.Header + (*pos)); *pos += 4; if (len==(uint32_t)(-1)) return; // after each qstring at most 28 bytes are loaded before the next check for a qstring // This check is also needed when qstring is empty size_t SIZE = *pos+len+100; if (SIZE > hdr->HeadLen) { SIZE = max(SIZE, 2*hdr->HeadLen); // always double size of header void *ptr = realloc(hdr->AS.Header, SIZE); if (ptr==NULL) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Format Intan RH[DS]2000 - memory allocation failed"); return; } hdr->AS.Header = (uint8_t*)ptr; hdr->HeadLen += ifread(hdr->AS.Header+hdr->HeadLen, 1, SIZE-hdr->HeadLen, hdr); } if ((*pos + len ) > hdr->HeadLen) biosigERROR(hdr, B4C_INCOMPLETE_FILE, "Format Intan RHD2000 - incomplete file"); // convert qString into UTF-8 string if (outbuf != NULL) { iconv_t CD = iconv_open ("UTF-8", "UTF-16LE"); size_t inlen = len; char *inbuf = hdr->AS.Header+(*pos); size_t iconv_res = iconv (CD, &inbuf, &inlen, &outbuf, &outlen); *outbuf = '\0'; iconv_close (CD); } *pos += len; return; } int sopen_intan_clp_read(HDRTYPE* hdr) { uint16_t NumADCs=0, NumChips=0, NumChan=0; float minor = leu16p(hdr->AS.Header+6); minor *= (minor < 10) ? 0.1 : 0.01; hdr->VERSION = leu16p(hdr->AS.Header+4) + minor; uint16_t datatype=leu16p(hdr->AS.Header+8); switch (datatype) { case 1: NumADCs=leu16p(hdr->AS.Header+10); hdr->SampleRate = lef32p(hdr->AS.Header+24); case 0: break; default: // this should never ever occurs, because getfiletype checks this biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan CLP - datatype unknown"); return -1; } size_t HeadLen=leu16p(hdr->AS.Header+10+(datatype*2)); // read header if (HeadLen > hdr->HeadLen) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, HeadLen+1); hdr->HeadLen += ifread(hdr->AS.Header+HeadLen, 1, HeadLen - hdr->HeadLen, hdr); } hdr->AS.Header[hdr->HeadLen]=0; if (HeadLen > hdr->HeadLen) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan/CLP - file is too short"); return -1; } ifseek(hdr, HeadLen, SEEK_SET); // read recording date and time size_t pos=12+(datatype*2); { struct tm t0; t0.tm_year = leu16p(hdr->AS.Header+pos); t0.tm_mon = leu16p(hdr->AS.Header+pos+2); t0.tm_mday = leu16p(hdr->AS.Header+pos+4); t0.tm_hour = leu16p(hdr->AS.Header+pos+6); t0.tm_min = leu16p(hdr->AS.Header+pos+8); t0.tm_sec = leu16p(hdr->AS.Header+pos+10); hdr->T0 = tm_time2gdf_time(&t0); } switch (datatype) { case 0: // If this is the standard data file (including clamp and measured data), /* TODO: read chips read settings */ break; case 1: // If this is the aux data file (including Digital Ins/Outs and ADC data) default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan CLP - datatype unknown"); return -1; } switch (datatype) { case 0: { // read chips pos = 24; NumChips=leu16p(hdr->AS.Header+pos); NumChan=leu16p(hdr->AS.Header+pos+2); for (uint16_t k1 = 0; k1 < NumChips; k1++) { for (uint16_t k2 = 0; k2 < NumChan; k2++) { // read one header per chip //14*2+4+4+16+20+4 } // read } pos += ((14*2+4+4+16+20+4) * NumChan + 8) * NumChips; // read settings hdr->NS = 4; hdr->SPR = 1; hdr->NRec = -1; hdr->AS.bpb= 16; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); // see below // strcpy(hdr->CHANNEL[0].Label,"Time"); strcpy(hdr->CHANNEL[1].Label,"Clamp"); strcpy(hdr->CHANNEL[2].Label,"TotalClamp"); strcpy(hdr->CHANNEL[3].Label,"Measured"); for (int k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Transducer[0]='\0'; hc->OnOff=1; hc->GDFTYP=16; hc->DigMax=+1e9; hc->DigMin=-1e9; hc->Cal=1; hc->Off=0; } break; } case 1: { hdr->NS = NumADCs; hdr->SPR = 1; hdr->NRec = -1; hdr->AS.bpb= 4 + 2 + 2 + 2 * NumADCs; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); for (int k=0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; sprintf(hdr->CHANNEL[3].Label, "ADC%d", k-2); hc->Transducer[0]='\0'; hc->OnOff=1; hc->GDFTYP=4; hc->DigMax=65535.0; hc->DigMin=0; hc->Cal = (k < 3) ? 1.0 : 0.0003125; hc->Off = (k < 3) ? 0.0 : -10.24; } // see below // strcpy(hdr->CHANNEL[0].Label, "Time"); strcpy(hdr->CHANNEL[1].Label,"DigitalIn"); strcpy(hdr->CHANNEL[2].Label,"DigitalOut"); break; } default: ; } hdr->CHANNEL[0].OnOff=2; //uint32 hdr->CHANNEL[0].GDFTYP=6; //uint32 hdr->CHANNEL[0].DigMax=ldexp(1l,32)-1; //uint32 hdr->CHANNEL[0].DigMin=0.0; //uint32 hdr->CHANNEL[0].Cal=1.0/hdr->SampleRate; //uint32 hdr->CHANNEL[0].PhysDimCode = 2176; //uint32 strcpy(hdr->CHANNEL[0].Label, "Time"); hdr->AS.bpb = 0; for (int k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->LeadIdCode = 0; hc->PhysDimCode = 0; hc->TOffset = 0; hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; hc->Impedance = NAN; hc->fZ = NAN; hc->SPR = 1; memset(hc->XYZ, 0, 12); hc->bi = hdr->AS.bpb; hdr->AS.bpb += (GDFTYP_BITS[hc->GDFTYP]*(size_t)hc->SPR) >> 3; } biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan/CLP not supported"); return -1; } /* RHS2000 Data File Formats - Intan Tech http://www.intantech.com/files/Intan_RHS2000_data_file_formats.pdf */ int sopen_rhs2000_read(HDRTYPE* hdr) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %u); %s(...) [%u]\n",__FILE__,__LINE__,__func__,hdr->HeadLen); // 8 bytes float minor = leu16p(hdr->AS.Header+6); minor *= (minor < 10) ? 0.1 : 0.01; hdr->VERSION = leu16p(hdr->AS.Header+4) + minor; // +38 = 46 bytes hdr->NS = 1; hdr->SampleRate = lef32p(hdr->AS.Header+8); float HighPass = ( leu16p(hdr->AS.Header+12) ? lef32p(hdr->AS.Header+14) : 0.0 ); HighPass = max( HighPass, lef32p(hdr->AS.Header+18) ); float LowPass = lef32p(hdr->AS.Header+26); // +10 = 56 bytes const int ListNotch[] = {0,50,60}; uint16_t tmp = leu16p(hdr->AS.Header+46); if (tmp>2) tmp=0; float Notch = ListNotch[tmp]; float fZ_desired = lef32p(hdr->AS.Header+46); // desired impedance test frequency float fZ_actual = lef32p(hdr->AS.Header+50); // actual impedance test frequency // +4 = 60 bytes // +12 = 72 bytes float StimStepSize = lef32p(hdr->AS.Header+58); // Stim Step Size [A] float ChargeRecoveryCurrentLimit = lef32p(hdr->AS.Header+62); // [A] float ChargeRecoveryTargetVoltage = lef32p(hdr->AS.Header+66); // [V] size_t pos = 72; read_qstring(hdr, &pos, NULL, 0); // note1 read_qstring(hdr, &pos, NULL, 0); // note2 read_qstring(hdr, &pos, NULL, 0); // note3 uint16_t flag_DC_amplifier_data_saved = leu16p(hdr->AS.Header+pos) > 0; pos += 2; uint16_t BoardMode = leu16p(hdr->AS.Header+pos); pos += 2; char *ReferenceChannelName = NULL; read_qstring(hdr, &pos, ReferenceChannelName, 0); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %u); %s(...) %u %u\n", __FILE__, __LINE__, __func__, (unsigned)pos, hdr->HeadLen); uint16_t numberOfSignalGroups = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t NS = 0; hdr->SPR = 128; size_t bi = (0+4)*hdr->SPR; // read all signal groups for (int nsg=0; nsg < numberOfSignalGroups; nsg++) { char SignalGroupName[101], SignalGroupPrefix[101]; read_qstring(hdr, &pos, SignalGroupName, 100); read_qstring(hdr, &pos, SignalGroupPrefix, 100); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %u); %s(...) group=%u %u SGP<%s> SGP<%s>\n",__FILE__,__LINE__,__func__, nsg, (unsigned)pos, SignalGroupName,SignalGroupPrefix ); uint16_t flag_SignalGroupEnabled = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t NumberOfChannelsInSignalGroup = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t NumberOfAmplifierChannelsInSignalGroup = leu16p(hdr->AS.Header+pos); pos += 2; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %u); %s(...) group=%u %u+%u %d\n", __FILE__, __LINE__, __func__, nsg, NS, NumberOfChannelsInSignalGroup, (int)pos); if (flag_SignalGroupEnabled) { typeof(pos) tmppos = pos; int NumChans0 = 0; int NumChans1 = 0; // get number of enabled channels for (unsigned k = 0; k < NumberOfChannelsInSignalGroup; k++) { read_qstring(hdr, &tmppos, NULL, 0); read_qstring(hdr, &tmppos, NULL, 0); tmppos += 4; int16_t SignalType = lei16p(hdr->AS.Header+tmppos); tmppos += 2; int16_t ChannelEnabled = lei16p(hdr->AS.Header+tmppos); tmppos += 24; NumChans0 += (ChannelEnabled > 0); NumChans1 += (ChannelEnabled > 0) * (1 + (SignalType==0) * (flag_DC_amplifier_data_saved+1)); } hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, (1+NS+NumChans1) * sizeof(CHANNEL_TYPE)); for (unsigned k = 0; k < NumberOfChannelsInSignalGroup; k++) { char NativeChannelName[MAX_LENGTH_LABEL+1]; char CustomChannelName[MAX_LENGTH_LABEL+1]; read_qstring(hdr, &pos, NativeChannelName, MAX_LENGTH_LABEL); read_qstring(hdr, &pos, CustomChannelName, MAX_LENGTH_LABEL); pos += 4; int16_t SignalType = lei16p(hdr->AS.Header+pos); pos += 2; int16_t ChannelEnabled = leu16p(hdr->AS.Header+pos)>0; pos += 2; int16_t ChipChannel = lei16p(hdr->AS.Header+pos); pos += 2; int16_t CommandStream = lei16p(hdr->AS.Header+pos); pos += 2; int16_t BoardStream = lei16p(hdr->AS.Header+pos); pos += 2; int16_t SpikeScopeVoltageTriggerMode = lei16p(hdr->AS.Header+pos); pos += 2; int16_t SpikeScopeVoltageThreshold = lei16p(hdr->AS.Header+pos); pos += 2; int16_t SpikeScopeDigitalTriggerChannel = lei16p(hdr->AS.Header+pos); pos += 2; int16_t SpikeScopeDigitalTriggerEdgePolarity = lei16p(hdr->AS.Header+pos); pos += 2; float ElectrodeImpedanceMagnitude = lef32p(hdr->AS.Header+pos); pos += 4; float ElectrodeImpedancePhase = lef32p(hdr->AS.Header+pos); pos += 4; if (ChannelEnabled) { int nn = 1 + (SignalType==0) * (1 + flag_DC_amplifier_data_saved); char *ChannelName = NULL; NS++; // first channel is Time channel for (int k2=0; k2 < nn; k2++) { // k2>0 takes care of StimDatea and DCamp channels CHANNEL_TYPE *hc = hdr->CHANNEL + NS + NumChans0*k2; strcpy(hc->Label, NativeChannelName); strncat(hc->Label, ":", MAX_LENGTH_LABEL-strlen(hc->Label)); strncat(hc->Label, CustomChannelName, MAX_LENGTH_LABEL-strlen(hc->Label)); #ifdef MAX_LENGTH_PHYSDIM strcpy(hc->PhysDim,"?"); #endif hc->OnOff = 1; hc->GDFTYP = 4; // uint16 hc->bi = bi + hdr->SPR * NumChans0 * k2 * 2; hc->bi8 = bi << 3; hc->LeadIdCode = 0; hc->DigMin = 0.0; hc->DigMax = ldexp(1,16)-1; hc->PhysDimCode = 0; // [?] default hc->Cal = 1; // default hc->Off = 0; // default hc->SPR = hdr->SPR; // default switch (SignalType) { case 0: // RHS2000 amplifier channel if (k2==0) { ChannelName = hc->Label; hc->Cal = 0.195; hc->Off = -32768 * hc->Cal; hc->PhysDimCode = 4275; // [uV] } else if ((k2+1)==nn) { // Stimulation Data sprintf(hc->Label,"Stim %s",ChannelName); hc->PhysDimCode = 4160; // [A] hc->Cal = StimStepSize; hc->Off = 0; /* NOTE: reading StimData disabled - this is not supported yet. Issues are decoding and scaling of data (bit9-16) */ hc->OnOff = 0; } else { sprintf(hc->Label,"DC_AmpData %s",ChannelName); hc->Cal = 19.23; hc->Off = -512 * hc->Cal; hc->PhysDimCode = 4274; // [mV] } break; /* case 2: // supply voltage channel hc->SPR = 1; hc->Cal = 0.0000748; hc->Off = 0; hc->PhysDimCode = 4256; // [V] break */ case 3: // Analog input channel case 4: // Analog output channel hc->PhysDimCode = 4256; // [V] hc->Cal = 0.0003125; hc->Off = -32768 * hc->Cal; break; case 5: // Digital Input channel case 6: // Digital Output channel hc->PhysDimCode = 0; // [1] break; default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan RHS2000 - not conformant to specification"); } hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->bufptr = NULL; hc->TOffset = 0; hc->LowPass = LowPass; hc->HighPass = HighPass; hc->Notch = Notch; hc->XYZ[0] = NAN; hc->XYZ[1] = NAN; hc->XYZ[2] = NAN; if ( (hc->PhysDimCode & 0xffe0) == 4256) // [V] hc->Impedance = ElectrodeImpedanceMagnitude; } bi += hdr->SPR * 2; } // if (ChannelEnabled) } // take care of StimData Channels and AmpDC channels bi += (NumChans1 - NumChans0) * hdr->SPR * 2; NS += NumChans1 - NumChans0; } } { // channel 0 - time channel CHANNEL_TYPE *hc = hdr->CHANNEL+0; hc->OnOff = 2; strcpy(hc->Label, "time"); strcpy(hc->Transducer, ""); #ifdef MAX_LENGTH_PHYSDIM strcpy(hc->PhysDim,"s"); #endif hc->bi = 0; hc->bufptr = NULL; hc->OnOff = 2; // time channel hc->SPR = hdr->SPR; hc->GDFTYP = 6; // uint32 hc->bi = 0; hc->bi8 = hc->bi << 3; hc->LeadIdCode = 0; hc->DigMin = 0.0; hc->DigMax = ldexp(1,32)-1; hc->Off = 0.0; hc->Cal = 1.0/hdr->SampleRate; hc->PhysDimCode = 2176; // [s] hc->PhysMin = 0; hc->PhysMax = hc->DigMax*hc->Cal; hc->bufptr = NULL; hc->TOffset = 0; hc->LowPass = 0; hc->HighPass = INFINITY; hc->Notch = 0; hc->XYZ[0] = NAN; hc->XYZ[1] = NAN; hc->XYZ[2] = NAN; hc->Impedance = NAN; } hdr->HeadLen = pos; hdr->NRec = -1; hdr->NS = NS+1; hdr->AS.bpb = bi; ifseek(hdr, hdr->HeadLen, SEEK_SET); struct stat FileBuf; if (stat(hdr->FileName,&FileBuf)==0) hdr->FILE.size = FileBuf.st_size; hdr->NRec = (hdr->FILE.size - hdr->HeadLen) / hdr->AS.bpb; return 0; } /* RHD2000 Data File Formats - Intan Tech http://www.intantech.com/files/Intan_RHD2000_data_file_formats.pdf */ int sopen_rhd2000_read(HDRTYPE* hdr) { uint16_t major = leu16p(hdr->AS.Header+4); float minor = leu16p(hdr->AS.Header+6); minor *= (minor < 10) ? 0.1 : 0.01; hdr->VERSION = major + minor; hdr->NS = 1; hdr->SampleRate = lef32p(hdr->AS.Header+8); float HighPass = ( leu16p(hdr->AS.Header+12) ? lef32p(hdr->AS.Header+14) : 0.0 ); HighPass = max( HighPass, lef32p(hdr->AS.Header+18) ); float LowPass = lef32p(hdr->AS.Header+22); const int ListNotch[] = {0,50,60}; uint16_t tmp = leu16p(hdr->AS.Header+38); if (tmp>2) tmp=0; float Notch = ListNotch[tmp]; float fZ_desired = lef32p(hdr->AS.Header+40); // desired impedance test frequency float fZ_actual = lef32p(hdr->AS.Header+44); // actual impedance test frequency size_t pos = 48; char tmpstr[101]; read_qstring(hdr, &pos, tmpstr, 100); // note1 read_qstring(hdr, &pos, tmpstr, 100); // note2 read_qstring(hdr, &pos, tmpstr, 100); // note3 uint16_t numberTemperatureSensors = 0; if (hdr->Version >= 1.1) { numberTemperatureSensors = leu16p(hdr->AS.Header+pos); pos += 2; } int BoardMode = 0; if (hdr->Version >= 1.3) { BoardMode = leu16p(hdr->AS.Header+pos); pos += 2; } char referenceChannelName[101]; referenceChannelName[0]=0; if (hdr->Version >= 2.0) { read_qstring(hdr, &pos, referenceChannelName, 100); } uint16_t numberOfSignalGroups = leu16p(hdr->AS.Header+pos); pos += 2; hdr->NS = 1+numberTemperatureSensors; // time channel + temparature channels hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *hc = hdr->CHANNEL; strcpy(hc->Label,"Time"); hc->Transducer[0] = 0; hc->OnOff = 2; hc->bi = 0; hc->GDFTYP = 5; //int32_t hc->DigMin = -ldexp(1,31); hc->DigMax = ldexp(1,31) - 1; hdr->SPR = (major==1) ? 60 : 128; hc->SPR = hdr->SPR; size_t bi = (0+4)*hdr->SPR; for (uint16_t k = 0; kAS.Header+pos); pos += 2; uint16_t numberChannelsInGroup = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t numberAmplifierChannels = leu16p(hdr->AS.Header+pos); pos += 2; if (enabledGroup && (numberChannelsInGroup > 0) ) { hdr->CHANNEL = realloc(hdr->CHANNEL, ((size_t)hdr->NS + (size_t)numberChannelsInGroup) * sizeof(CHANNEL_TYPE)); int ns = 0; uint32_t chan; for (chan=0; chan < numberChannelsInGroup; chan++) { char NativeChannelName[MAX_LENGTH_LABEL+1]; char CustomChannelName[MAX_LENGTH_LABEL+1]; read_qstring(hdr, &pos, NativeChannelName, MAX_LENGTH_LABEL); read_qstring(hdr, &pos, CustomChannelName, MAX_LENGTH_LABEL); uint16_t nativeOrder = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t customOrder = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t signalType = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t channelEnabled = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t chipChannel = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t boardStream = leu16p(hdr->AS.Header+pos); pos += 2; // Spike Scope uint16_t triggerMode = leu16p(hdr->AS.Header+pos); pos += 2; int16_t voltageThreshold = leu16p(hdr->AS.Header+pos); // uV pos += 2; uint16_t triggerChannel = leu16p(hdr->AS.Header+pos); pos += 2; uint16_t edgePolarity = leu16p(hdr->AS.Header+pos); pos += 2; float ImpedanceMagnitude = lef32p(hdr->AS.Header+pos); // Ohm pos += 4; float ImpedancePhase = lef32p(hdr->AS.Header+pos); // degree pos += 4; if (!(chipChannel<32) || !(signalType<6)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format Intan RHD2000 - not conformant to specification"); return -1; } if (channelEnabled) { CHANNEL_TYPE *hc = hdr->CHANNEL + hdr->NS + ns; ns += channelEnabled > 0; // translate into biosig HDR channel structure hc->GDFTYP = 4; // uint16_t hc->PhysDimCode = 0; // [?] default hc->Cal = 1; // default hc->Off = 0; // default hc->SPR = hdr->SPR; // default strcpy(hc->Label, NativeChannelName); strncat(hc->Label, ":", MAX_LENGTH_LABEL - strlen(hc->Label)); strncat(hc->Label, CustomChannelName, MAX_LENGTH_LABEL - strlen(hc->Label)); hc->Transducer[0] = 0; #ifdef MAX_LENGTH_PHYSDIM strcpy(hc->PhysDim, "?"); #endif hc->OnOff = 1; hc->bi = bi; hc->bi8 = bi << 3; hc->LeadIdCode = 0; hc->DigMin = 0.0; hc->DigMax = ldexp(1,16)-1; switch (signalType) { case 0: // amplifier channel hc->Cal = 0.195; hc->Off = -32768*hc->Cal; hc->PhysDimCode = 4275; // [uV] break; case 1: // auxilary input channel hc->SPR = hc->SPR/4; hc->Cal = 0.0000374; hc->Off = -32768*hc->Cal; hc->PhysDimCode = 4256; // [V] break; case 2: // supply voltage channel hc->SPR = channelEnabled; hc->Cal = 0.0000748; hc->Off = 0; hc->PhysDimCode = 4256; // [V] break; case 0xffff: // Temperature Sensor channel hc->GDFTYP = 3; // int16 hc->SPR = 1; hc->Cal = 0.01; hc->Off = 0; hc->PhysDimCode = 6048; // [°C] break; case 3: // USB board ADC input channel hc->PhysDimCode = 4256; // [V] switch(BoardMode) { case 0: hc->Cal = 0.000050354; hc->Off = 0; break; case 1: hc->Cal = 0.00015259; hc->Off = -32768*hc->Cal; break; case 13: hc->Cal = 0.0003125; hc->Off = -32768*hc->Cal; break; } break; case 4: // USB board digital input channel ; case 5: // USB board digital output channel ; } bi += hc->SPR*2; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; if ( (hc->PhysDimCode & 0xffe0) == 4256) // [V] hc->Impedance = ImpedanceMagnitude; } // if (channelEnabled) } hdr->NS += ns; } } hdr->CHANNEL = realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); hdr->HeadLen = pos; hdr->NRec = -1; hdr->AS.bpb = bi; ifseek(hdr, hdr->HeadLen, SEEK_SET); struct stat FileBuf; if (stat(hdr->FileName,&FileBuf)==0) hdr->FILE.size = FileBuf.st_size; hdr->NRec = (hdr->FILE.size - hdr->HeadLen) / hdr->AS.bpb; return 0; } #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/t210/scp-decode.cpp0000664000175000017500000031101314105434233020206 0ustar schloeglschloegl/* $Id: scp-decode.cpp,v 1.24 2008-07-12 20:46:58 schloegl Exp $ Copyright (C) 2011,2014 Alois Schloegl Copyright (C) 2011 Stoyan Mihaylov This function is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ Modifications by Alois Schloegl Jul 2011: get rid of warnings for unitialized variables and signed/unsigned comparison Jun 2007: replaced ultoa with sprintf Aug 2007: On-The-Fly-Decompression using ZLIB Oct 2007: Consider SunOS/SPARC platform obsolete code sections marked, this reduced SegFault from 18 to 1. --------------------------------------------------------------------------- Copyright (C) 2006 Eugenio Cervesato. Developed at the Associazione per la Ricerca in Cardiologia - Pordenone - Italy, based on the work of Eugenio Cervesato & Giorgio De Odorico. The original Copyright and comments follow. 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 3 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- ______________________________________________________________________________ scp-decode.cpp This is the "decode" module of the program SCP-AV. It opens an SCP-ECG v1.0 to v2.0 test file and extracts all the informations. Release 2.3 - feb 2006 --------------------------------------------------------------------------- ************************************************************************** ************************* original Copyright ***************************** Copyright (C) 2003-2004 Eugenio Cervesato & Giorgio De Odorico. Developed at the Associazione per la Ricerca in Cardiologia - Pordenone - Italy. 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- */ //______________________________________________________________________________ /* scp-decode.cpp This is the "decode" module of the program SCP-AV. It opens an SCP-ECG v1.3 or v2.0 test file and extracts all the informations. Developed by ING. GIORGIO DE ODORICO (giorgio.deodorico@tiscali.it) Documentation of the standard comes mainly from: http://www.centc251.org/TCMeet/doclist/TCdoc02/N02-015-prEN1064.pdf Internationalization, test, bug fix by Eugenio Cervesato (eugenio.cervesato@aopn.fvg.it) Release 2.1 - february 2004 */ // ************************* end of the original Copyright ***************************** // contribution of Michael Breuss . see 'by MB' in the sources // contribution of Stelios Sfakianakis . see 'by SS' in the sources // contribution of Federico cantini . see 'by FeC' in the sources //void remark(char *string); // #define WITH_OBSOLETE_PARTS // by E.C. 13.10.2003 part nedded to compile with gcc (Linux). // To compile with Borland C++ add the conditional define: WIN32. // In porting, I nedded to adapt fseek() and write a custom ultoa() #define COMPAT //______________________________________________________________________________ //#include #include //strcat, strcpy #include #include using namespace std; /* error handling should use error variables local to each HDR otherwise, sopen() etc. is not re-entrant. Therefore, use of variables B4C_ERRNUM and B4C_ERRMSG is deprecated; Instead, use biosigERROR for setting error status, and serror2(hdr), hdr->AS.B4C_ERRNUM, hdr->AS.B4C_ERRMSG for error handling. */ __attribute__ ((deprecated)) extern int B4C_ERRNUM; __attribute__ ((deprecated)) extern const char *B4C_ERRMSG; //______________________________________________________________________________ // FILE POINTERS #include "../biosig-dev.h" #include "structures.h" #include "codes.h" // the following define is private of Eugenio Cervesato. Please other readers ignore it! #ifdef CPPBUILDER3 #include "CPPBUILDER3.h" // inside are definitions needed to run on C++Builder GUI as a standalone module and bypass ZLIB #endif // end of private define. HDRTYPE* in; //--------------------------------------------------------------------------- static uint32_t _COUNT_BYTE=1UL; // counter of bytes read static uint32_t _DIM_FILE; // file length in byte static const uint8_t _NUM_SECTION=12U; // sections over 11 are not considered //______________________________________________________________________________ // section 2 uint8_t Input_Bit(uint8_t*,uint16_t&,uint16_t,uint8_t&,bool&); int16_t Input_Bits(uint8_t*,uint16_t&,uint16_t,uint8_t&,uint8_t,bool&); void decompress(TREE_NODE*,int16_t*,uint8_t&,uint16_t&,int32_t*,uint16_t,uint16_t&,table_H*,uint16_t*,uint16_t&); void Tree_Destroy(TREE_NODE*); TREE_NODE *Tree_Create(TREE_NODE*,uint16_t,table_H*,uint16_t); void Huffman(int32_t*,uint16_t*,uint8_t*,uint16_t&,uint16_t,table_H*,uint16_t*); void InitHuffman(table_H*); //inizialize default Huffman table //______________________________________________________________________________ // sections 3, 4, 5 and 6 template void Differences(int32_t*,t1,uint8_t); void Multiply(int32_t*,uint32_t,uint16_t); void Interpolate(int32_t*,int32_t*,f_lead,lead*,f_Res,Protected_Area*,uint32_t); void ExecFilter(int32_t*,int32_t*,uint32_t&,uint16_t); void DoFilter(int32_t*,int32_t*,f_Res,f_lead,lead*,Protected_Area*,Subtraction_Zone*); void DoAdd(int32_t*,int32_t*,f_Res,int32_t*,f_BdR0,Subtraction_Zone*,f_lead,lead*); void Opt_Filter(int32_t*, int32_t*, f_Res, f_lead, lead*, Protected_Area*); //______________________________________________________________________________ // INTERNAL FUNCTIONS char* ReadString(char*,uint16_t); //read a string char *FindString(char*,uint16_t); // calculate the length of a string and write it down int16_t Look(alfabetic*,uint16_t,uint16_t,uint16_t); //look at a number in alfabetic and give the position of the array //______________________________________________________________________________ template void ReadByte(t1&); //read a byte from stream void Skip(uint16_t); //skip some bytes //______________________________________________________________________________ uint16_t ReadCRC(); //read first 6 bytes of the file bool Check_CRC(uint16_t,uint32_t,uint32_t); // CRC check //______________________________________________________________________________ uint32_t ID_section(uint32_t, int8_t &version); //read section ID header void sectionsOptional(pointer_section*,DATA_DECODE &,DATA_RECORD&,DATA_INFO&); //handles optional sections #ifdef WITH_OBSOLETE_PARTS void section_0(pointer_section*, int size_max); //read section 0 void Init_S1(DATA_INFO &inf); void section_1(pointer_section,DATA_INFO&); //read section 1 data void section_1_0(demographic&); //read tag 0 of section 1 void section_1_1(demographic&); //read tag 1 of section 1 void section_1_2(demographic&); // ... and so on ... void section_1_3(demographic&); void section_1_4(demographic&); void section_1_5(demographic&); void section_1_6(demographic&); void section_1_7(demographic&); void section_1_8(demographic&); void section_1_9(demographic&); void section_1_10(clinic&,uint16_t&); void section_1_11(demographic&); void section_1_12(demographic&); void section_1_13(clinic&,uint16_t&); void section_1_14(descriptive&); void section_1_15(descriptive&); void section_1_16(descriptive&); void section_1_17(descriptive&); void section_1_18(descriptive&); void section_1_19(descriptive&); void section_1_20(clinic&); void section_1_21(clinic&); void section_1_22(clinic&); void section_1_23(descriptive&); void section_1_24(descriptive&); void section_1_25(device&); void section_1_26(device&); void section_1_27(device&); void section_1_28(device&); void section_1_29(device&); void section_1_30(clinic&,uint16_t&); void section_1_31(device&); void section_1_32(clinic&,uint16_t&, int8_t version); void section_1_33(device&); void section_1_34(device&); void section_1_35(clinic&,uint16_t&); void section_1_(); //skip tags of the manufacturer of the section 1 void section_1_255(); //read tag 255 of section 1 void section_7(pointer_section,DATA_RECORD&, int8_t version); //read section 7 void section_8(pointer_section,DATA_INFO&); //read section 8 void section_10(pointer_section,DATA_RECORD&, int8_t version); //read section 10 void section_11(pointer_section,DATA_INFO&); //read section 11 #endif void section_2(pointer_section,DATA_DECODE&); //read section 2 void section_3(pointer_section,DATA_DECODE&, int8_t version); //read section 3 void section_4(pointer_section,DATA_DECODE&, int8_t version); //read section 4 bool section_5(pointer_section,DATA_DECODE&,bool); //read section 5 void section_6(pointer_section,DATA_DECODE&,bool); //read section 6 //______________________________________________________________________________ void Decode_Data(pointer_section*,DATA_DECODE&,bool&); //______________________________________________________________________________ #define STR_NULL StrNull() void *FreeWithCare(void*P){ //Stoyan - else I got problems with some scp files - prestandart or so if(P) free(P); return NULL; } void *mymalloc(size_t size) // by E.C. 07.11.2003 this is a workaround for a bug { // present somewhere in memory allocation. // char buff[30]; // this problem should be fixed next! // ultoa(size, buff, 10); // used for debug purposes, shows the size // remark(buff); // fprintf(stdout,"MYMEMALLOC: %i\n",size); // void *res=malloc(size*2); // this way each time a doubled memory is requested. And it works!! void *res=malloc(size); return res; } const int StrNullLen=strlen(" unspecified/unknown "); char * StrNull(){ //Stoyan this way we can release everything char*Ret=(char*)mymalloc(StrNullLen+4); strcpy(Ret," unspecified/unknown "); return Ret; } /* moved by MB must be declared before first call (otherwise compiler error) */ //--------------------------------BYTE & BIT------------------------------------ template void ReadByte(t1 &number) { //read the requested number of bytes and //convert in decimal, taking into account that the first byte is the LSB. //the sign of the number is kept uint8_t *num, dim=sizeof(t1); uint8_t mask=0xFF; if(dim!=0 && (num=(uint8_t*)mymalloc(dim))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } ifread(num,dim,1,in); // *num = *(uint8_t*)(in->AS.Header+_COUNT_BYTE); number=0; _COUNT_BYTE+=dim; while((dim--)>0) { number<<=8; number+=num[dim]&mask; } free(num); }//end ReadByte // MAIN EXTERN_C void sopen_SCP_clean(struct DATA_DECODE *decode, struct DATA_RECORD *record, struct DATA_INFO *textual) { FreeWithCare(decode->length_BdR0); FreeWithCare(decode->samples_BdR0); FreeWithCare(decode->length_Res); FreeWithCare(decode->samples_Res); FreeWithCare(decode->t_Huffman); FreeWithCare(decode->flag_Huffman); FreeWithCare(decode->data_lead); FreeWithCare(decode->data_protected); FreeWithCare(decode->data_subtraction); FreeWithCare(decode->Median); FreeWithCare(decode->Residual); FreeWithCare(decode->Reconstructed); FreeWithCare(record->data_spike); FreeWithCare(record->type_BdR); FreeWithCare(record->data_BdR); FreeWithCare(record->data_additional); FreeWithCare(record->lead_block); FreeWithCare(textual->text_dim); FreeWithCare(textual->data_statement); FreeWithCare(textual->text_statement); FreeWithCare(textual->ana.last_name); FreeWithCare(textual->ana.first_name); FreeWithCare(textual->ana.ID); FreeWithCare(textual->ana.second_last_name); FreeWithCare(textual->cli.text_drug); FreeWithCare(textual->cli.text_diagnose); FreeWithCare(textual->cli.referring_physician); FreeWithCare(textual->cli.latest_confirming_physician); FreeWithCare(textual->cli.technician_description); FreeWithCare(textual->cli.text_free_text); FreeWithCare(textual->cli.text_free_medical_hystory); FreeWithCare(textual->cli.medical_hystory); FreeWithCare(textual->cli.free_text); FreeWithCare(textual->cli.drug); FreeWithCare(textual->des.acquiring.model_description); FreeWithCare(textual->des.acquiring.analysing_program_revision_number); FreeWithCare(textual->des.acquiring.serial_number_device); FreeWithCare(textual->des.acquiring.device_system_software); FreeWithCare(textual->des.acquiring.device_SCP_implementation_software); FreeWithCare(textual->des.acquiring.manifacturer_trade_name); FreeWithCare(textual->des.analyzing.model_description); FreeWithCare(textual->des.analyzing.analysing_program_revision_number); FreeWithCare(textual->des.analyzing.serial_number_device); FreeWithCare(textual->des.analyzing.device_system_software); FreeWithCare(textual->des.analyzing.device_SCP_implementation_software); FreeWithCare(textual->des.analyzing.manifacturer_trade_name); FreeWithCare(textual->des.acquiring_institution); FreeWithCare(textual->des.analyzing_institution); FreeWithCare(textual->des.acquiring_department); FreeWithCare(textual->des.analyzing_department); FreeWithCare(textual->des.room); FreeWithCare(textual->dev.sequence_number); FreeWithCare((char*)textual->dev.TZ.description); } //There is serious problem if we try to transfer whole structures between c and c++. I am not sure were exactly it is, but using pointers - solve it. extern C is not enough. Stoyan EXTERN_C int scp_decode(HDRTYPE* hdr, pointer_section *section, struct DATA_DECODE *decode, struct DATA_RECORD *info_recording, struct DATA_INFO *info_textual, bool add_filter) { uint16_t CRC; uint32_t pos; if (hdr->FILE.OPEN) { ifseek(hdr,0,SEEK_SET); } else hdr = ifopen(hdr,"rb"); if (!hdr->FILE.OPEN) { fprintf(stdout,"Cannot open the file %s.\n",hdr->FileName); return FALSE; // by E.C. 15.10.2003 now return FALSE } in = hdr; _COUNT_BYTE=1UL; CRC=ReadCRC(); pos=_COUNT_BYTE; ReadByte(_DIM_FILE); // if (CRC != 0xFFFF) Check_CRC(CRC,pos,_DIM_FILE-2U); // by E.C. may 2004 CARDIOLINE 1.0 ifseek(in, 0L, SEEK_SET); //mandatory sections #ifdef WITH_OBSOLETE_PARTS section_0(section, _DIM_FILE); // by E.C. may 2004 check file size section_1(section[1],*info_textual); sectionsOptional(section,*decode,*info_recording,*info_textual); #else if (section[2].length>0) section_2(section[2],*decode); //HUFFMAN if (section[3].length>0) section_3(section[3],*decode,hdr->aECG->Section1.Tag14.VERSION); //lead if (section[4].length) section_4(section[4],*decode,hdr->aECG->Section1.Tag15.VERSION); // fiducial locations if (section[5].length) if (!section_5(section[5],*decode,section[2].length)) section[5].length=0 ; //type 0 median beat if (section[6].length) section_6(section[6],*decode,section[2].length); //rhythm compressed data #endif ifclose(in); Decode_Data(section,*decode,add_filter); return TRUE; // by E.C. 15.10.2003 now return TRUE } //______________________________________________________________________________ // COMPUTATIONAL FUNCTIONS #ifdef WITH_OBSOLETE_PARTS //------------------------------STRINGS---------------------------------------- char *ReadString(char *temp_string, uint16_t num) //read a string from the stream. //the first extracted byte is written for fist. //each byte read from the stream is first "transformed" in char. { if(temp_string) free(temp_string); if(!num) return NULL;//before alocating memory, which will be loosed in case of num=0 if((temp_string=(char*)mymalloc(sizeof(char)*(num+2)))==NULL) // by E.C. 26.02.2004 one more byte { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return NULL; } _COUNT_BYTE+=num; ifread(temp_string,sizeof(char),num,in); if (temp_string[num-1]!='\0') temp_string[num]='\0'; return temp_string; }//end ReadString int16_t Look(alfabetic *code_, uint16_t a, uint16_t b, uint16_t key_) // look num in code_.number and give the element position { uint16_t middle=(a+b)/2U; if(code_[middle].number==key_) return middle; if(a>=b) return -1; if(code_[middle].number0U) ifseek(in,num,1U); _COUNT_BYTE+=num; }//end Skip //______________________________________________________________________________ // INITIALIZATION FUNCTIONS void InitHuffman(table_H *riga) //build the default Huffman table { /* The table is contructed as stated in the protocol SCP-ECG; each structure in each line. Columns are: bit_prefix = number of bits in the prefix bit_code = number of bits in the code TMS = table mode base_value = base value (decoded) cp = prefix code (in bits) base_code = decimal value of reversed cp From the stream I take a bit at a time until I find a correspondent value in the Huffman table. If: nbp=nbc the decode value is vb nbp!=nbc if m=1 I take nbc-nbp bits next in the stream if m=0 change to table vb Remark: Huffman tables stored in the stream contain vb in 2 complemented bytes. The decimal value of cp is included. Furthermore, always the MSB comes first! In my Huffman tables I set cp as a decimal value. Infact, I read a group of bits from the stream and convert them by multipying by 2^pos (where pos is 0 for bit 0, 1 for bit 1 and so on). So I read bits as they are. DEFAULT HUFFMAN TABLE nbp nbc m vb cp10 cp 1, 1, 1, 0, 0, 0, 3, 3, 1, 1, 1, 4, 3, 3, 1, -1, 5, 5, 4, 4, 1, 2, 3, 12, 4, 4, 1, -2, 11, 13, 5, 5, 1, 3, 7, 28, 5, 5, 1, -3, 23, 29, 6, 6, 1, 4, 15, 60, 6, 6, 1, -4, 47, 61, 7, 7, 1, 5, 31, 124, 7, 7, 1, -5, 95, 125, 8, 8, 1, 6, 63, 252, 8, 8, 1, -6, 191, 253, 9, 9, 1, 7, 127, 508, 9, 9, 1, -7, 383, 509, 10, 10, 1, 8, 255, 1020, 10, 10, 1, -8, 767, 1021, 10, 18, 1, 0, 511, 1022, 10, 26, 1, 0, 1023, 1023, */ uint8_t i; i= 0U; riga[i].bit_prefix= 1U; riga[i].bit_code= 1U; riga[i].TMS=1U; riga[i].base_value= 0; riga[i].base_code= 0UL; i= 1U; riga[i].bit_prefix= 3U; riga[i].bit_code= 3U; riga[i].TMS=1U; riga[i].base_value= 1; riga[i].base_code= 1UL; i= 2U; riga[i].bit_prefix= 3U; riga[i].bit_code= 3U; riga[i].TMS=1U; riga[i].base_value=-1; riga[i].base_code= 5UL; i= 3U; riga[i].bit_prefix= 4U; riga[i].bit_code= 4U; riga[i].TMS=1U; riga[i].base_value= 2; riga[i].base_code= 3UL; i= 4U; riga[i].bit_prefix= 4U; riga[i].bit_code= 4U; riga[i].TMS=1U; riga[i].base_value=-2; riga[i].base_code= 11UL; i= 5U; riga[i].bit_prefix= 5U; riga[i].bit_code= 5U; riga[i].TMS=1U; riga[i].base_value= 3; riga[i].base_code= 7UL; i= 6U; riga[i].bit_prefix= 5U; riga[i].bit_code= 5U; riga[i].TMS=1U; riga[i].base_value=-3; riga[i].base_code= 23UL; i= 7U; riga[i].bit_prefix= 6U; riga[i].bit_code= 6U; riga[i].TMS=1U; riga[i].base_value= 4; riga[i].base_code= 15UL; i= 8U; riga[i].bit_prefix= 6U; riga[i].bit_code= 6U; riga[i].TMS=1U; riga[i].base_value=-4; riga[i].base_code= 47UL; i= 9U; riga[i].bit_prefix= 7U; riga[i].bit_code= 7U; riga[i].TMS=1U; riga[i].base_value= 5; riga[i].base_code= 31UL; i=10U; riga[i].bit_prefix= 7U; riga[i].bit_code= 7U; riga[i].TMS=1U; riga[i].base_value=-5; riga[i].base_code= 95UL; i=11U; riga[i].bit_prefix= 8U; riga[i].bit_code= 8U; riga[i].TMS=1U; riga[i].base_value= 6; riga[i].base_code= 63UL; i=12U; riga[i].bit_prefix= 8U; riga[i].bit_code= 8U; riga[i].TMS=1U; riga[i].base_value=-6; riga[i].base_code= 191UL; i=13U; riga[i].bit_prefix= 9U; riga[i].bit_code= 9U; riga[i].TMS=1U; riga[i].base_value= 7; riga[i].base_code= 127UL; i=14U; riga[i].bit_prefix= 9U; riga[i].bit_code= 9U; riga[i].TMS=1U; riga[i].base_value=-7; riga[i].base_code= 383UL; i=15U; riga[i].bit_prefix=10U; riga[i].bit_code=10U; riga[i].TMS=1U; riga[i].base_value= 8; riga[i].base_code= 255UL; i=16U; riga[i].bit_prefix=10U; riga[i].bit_code=10U; riga[i].TMS=1U; riga[i].base_value=-8; riga[i].base_code= 767UL; i=17U; riga[i].bit_prefix=10U; riga[i].bit_code=18U; riga[i].TMS=1U; riga[i].base_value= 0; riga[i].base_code= 511UL; i=18U; riga[i].bit_prefix=10U; riga[i].bit_code=26U; riga[i].TMS=1U; riga[i].base_value= 0; riga[i].base_code=1023UL; }//end InitHuffman //______________________________________________________________________________ // handle sections uint16_t ReadCRC() // read the CRC of the entire file or of a section and convert it to decimal. { uint16_t dim; ReadByte(dim); return dim; }//end ReadCRC bool Check_CRC(uint16_t CRC, uint32_t pos, uint32_t length) /* CRC check starting from pos for Length Remark: all computations are in byte. A = new byte B = temp byte CRCHI = MSB of the CRC (16 bits) CRCLO = LSB of the CRC START: for A=first_byte to last_byte in block do: A = A xor CRCHI CRCHI = A shift A right 4 times {fulfill with zeroes} A = A xor CRCHI {I J K L M N O P} CRCHI = CRCLO {swap CRCHI, CRCLO} CRCLO = A rotate A left 4 times {M N O P I J K L} B = A { temp save } rotate A left once { N O P I J K L M } A = A and $1F { 0 0 0 I J L L M } CRCHI = A xor CRCHI A = B and $F0 { M N O P 0 0 0 0 } CRCHI = A xor CRCHI { CRCHI complete } rotate B left once { N O P 0 0 0 0 M } B = B and $E0 { N O P 0 0 0 0 0 } CRCLO = B xor CRCLO { CRCLO complete } end Final check on the CRC is accomplished by adding or concatenating CRCHI and CRCLO at the end of the data stream. Calculating the checksum of the resulting data stream shall result in a zero CRC if the data was correctly received. */ { uint32_t i; uint8_t A, B; uint8_t CRCLO, CRCHI; CRCLO=0xFF; CRCHI=0xFF; ifseek(in,pos-1,0U); for(i=1;i<=length;i++) { A=ifgetc(in); A^=CRCHI; A^=(A>>4); CRCHI=CRCLO; CRCLO=A; A=(A<<4)|(A>>4U); B=A; A=(A<<1)|(A>>7U); A&=0x1F; CRCHI^=A; A=B&0xF0; CRCHI^=A; B=(B<<1)|(B>>7U); B&=0xE0; CRCLO^=B; }//end for CRCLO-=CRC%256UL; CRCHI-=CRC/256UL; if ((CRCLO==CRCHI) && (CRCLO==0)) return 1; else { fprintf(stderr,"Cannot read the file: BAD CRC.\n"); // exit(2); return 0; } }//end Check_CRC uint32_t ID_section(uint32_t pos, int8_t &version) //read section Header { uint32_t dim; uint16_t CRC; CRC=ReadCRC(); Skip(2U); ReadByte(dim); // if (CRC != 0xFFFF) Check_CRC(CRC,pos+2,dim-2); // by E.C. may 2004 CARDIOLINE 1.0 ifseek(in,pos+7L,0); ReadByte(version); // by E.C. may 2004 store the version number Skip(7U); return dim; }//end ID_section void sectionsOptional(pointer_section *section, DATA_DECODE &block1, DATA_RECORD &block2, DATA_INFO &block3) //handles optional sections { uint8_t i=0, bimodal; //initialization block1.t_Huffman=NULL; block1.flag_Huffman=NULL; block1.data_lead=NULL; block1.data_protected=NULL; block1.data_subtraction=NULL; block1.length_BdR0=NULL; block1.samples_BdR0=NULL; block1.Median=NULL; block1.length_Res=NULL; block1.samples_Res=NULL; block1.Residual=NULL; // block1.Reconstructed=NULL; block2.data_spike=NULL; block2.type_BdR=NULL; block2.data_BdR=NULL; block2.data_additional=NULL; block2.lead_block=NULL; block3.text_dim=NULL; block3.text_report=NULL; block3.data_statement=NULL; block3.text_statement=NULL; //variables inizialization block1.flag_lead.number=0; block1.flag_lead.subtraction=0; block1.flag_lead.all_simultaneously=0; block1.flag_lead.number_simultaneously=0; block1.flag_BdR0.length=0; block1.flag_BdR0.fcM=0; block1.flag_BdR0.AVM=0; block1.flag_BdR0.STM=0; block1.flag_BdR0.number_samples=0; block1.flag_BdR0.encoding=0; block1.flag_Res.AVM=0; block1.flag_Res.STM=0; block1.flag_Res.number=0; block1.flag_Res.number_samples=0; block1.flag_Res.encoding=0; block1.flag_Res.bimodal=0; block1.flag_Res.decimation_factor=0; block2.data_global.number=0; block2.data_global.number_QRS=0; block2.data_global.number_spike=0; block2.data_global.average_RR=0; block2.data_global.average_PP=0; block2.data_global.ventricular_rate=0; block2.data_global.atrial_rate=0; block2.data_global.QT_corrected=0; block2.data_global.formula_type=0; block2.data_global.number_tag=0; block2.header_lead.number_lead=0; block2.header_lead.number_lead_measurement=0; while(i<_NUM_SECTION) { if(section[i].ID) switch(section[i].ID) { case 2: if(section[i].length) section_2(section[i],block1); //HUFFMAN break; case 3: if(section[i].length) section_3(section[i],block1,block3.des.acquiring.protocol_revision_number); //lead break; case 4: if(section[i].length) { if((block3.des.acquiring.protocol_revision_number>10) && section[6].length) // by E.C. 27.02.2004 whole section to be included in {} ! { ifseek(in,section[6].index+22,0); ReadByte(bimodal); block1.flag_Res.bimodal=bimodal; } else block1.flag_Res.bimodal=0; section_4(section[i],block1,block3.des.analyzing.protocol_revision_number); // fiducial locations } break; case 5: if(section[i].length) if (!section_5(section[i],block1,section[2].length)) section[i].length=0 ; //type 0 median beat break; case 6: if(section[i].length) section_6(section[i],block1,section[2].length); //rhythm compressed data break; #ifdef WITH_OBSOLETE_PARTS /* case 7: if(section[i].length) section_7(section[i],block2,block3.des.acquiring.protocol_revision_number); //global measurements break; case 8: if(section[i].length) section_8(section[i],block3); //full text interpretative statements break; case 10:if(section[i].length) section_10(section[i],block2,block3.des.acquiring.protocol_revision_number); //lead measurement block break; case 11:if(section[i].length) //universal ECG interpretative statements // section_11(section[i],block3); break; */ #endif }//end switch ++i; }//end while }//end sectionsOptional //______________________________________________________________________________ // sections //______________________________________________________________________________ #ifdef WITH_OBSOLETE_PARTS //______________________________________________________________________________ // section 0 //______________________________________________________________________________ void section_0(pointer_section *info, int size_max) // section 0 //build info_sections with ID, offset and length of each section { uint32_t pos, dim, ini; uint16_t ind; uint8_t i; int8_t version; ifseek(in,6L,0); pos=ID_section(7L, version)+7L; //length + offset _COUNT_BYTE=7L+16L; for(i=0;i<_NUM_SECTION;i++) { info[i].ID=0; info[i].length=0L; info[i].index=0L; } while((_COUNT_BYTE+10)<=pos) { ReadByte(ind); if(ind>11U) Skip(8U); else { ReadByte(dim); if(dim) { ReadByte(ini); if (ini<(unsigned)size_max) { // by E.C. may 2004 check overflow of file info[ind].ID=ind; info[ind].length=dim; info[ind].index=ini; } }//end if dim else Skip(4U); }//end else }//end while }//end section_0 //______________________________________________________________________________ // section 1 //______________________________________________________________________________ void Init_S1(DATA_INFO &inf) { inf.ana.last_name=STR_NULL; inf.ana.first_name=STR_NULL; inf.ana.ID=STR_NULL; inf.ana.second_last_name=STR_NULL; inf.ana.age.value=0; inf.ana.age.unit=0; inf.ana.height.value=0; inf.ana.height.unit=0; inf.ana.weight.value=0; inf.ana.weight.unit=0; inf.ana.sex=0; inf.ana.race=0; inf.ana.systolic_pressure=0; inf.ana.diastolic_pressure=0; inf.cli.number_drug=0; inf.cli.text_drug=STR_NULL; inf.cli.number_diagnose=0; inf.cli.text_diagnose=STR_NULL; inf.cli.referring_physician=STR_NULL; inf.cli.latest_confirming_physician=STR_NULL; inf.cli.technician_description=STR_NULL; inf.cli.number_text=0; inf.cli.text_free_text=STR_NULL; inf.cli.number_hystory=0; inf.cli.number_free_hystory=0; inf.cli.text_free_medical_hystory=STR_NULL; inf.cli.free_text=NULL; inf.cli.medical_hystory=NULL; inf.cli.drug=NULL; inf.des.acquiring.institution_number=0; inf.des.acquiring.department_number=0; inf.des.acquiring.ID=0; inf.des.acquiring.type=2; inf.des.acquiring.manifacturer=0; inf.des.acquiring.model_description=STR_NULL; inf.des.acquiring.protocol_revision_number=0; inf.des.acquiring.category=255; inf.des.acquiring.language=255; inf.des.acquiring.capability[0]=1; inf.des.acquiring.capability[1]=2; inf.des.acquiring.capability[2]=3; inf.des.acquiring.capability[3]=4; inf.des.acquiring.AC=0; inf.des.acquiring.analysing_program_revision_number=STR_NULL; inf.des.acquiring.serial_number_device=STR_NULL; inf.des.acquiring.device_system_software=STR_NULL; inf.des.acquiring.device_SCP_implementation_software=STR_NULL; inf.des.acquiring.manifacturer_trade_name=STR_NULL; inf.des.analyzing.institution_number=0; inf.des.analyzing.department_number=0; inf.des.analyzing.ID=0; inf.des.analyzing.type=2; inf.des.analyzing.manifacturer=0; inf.des.analyzing.model_description=STR_NULL; inf.des.analyzing.protocol_revision_number=0; inf.des.analyzing.category=255; inf.des.analyzing.language=255; inf.des.analyzing.capability[0]=1; inf.des.analyzing.capability[1]=2; inf.des.analyzing.capability[2]=3; inf.des.analyzing.capability[3]=4; inf.des.analyzing.AC=0; inf.des.analyzing.analysing_program_revision_number=STR_NULL; inf.des.analyzing.serial_number_device=STR_NULL; inf.des.analyzing.device_system_software=STR_NULL; inf.des.analyzing.device_SCP_implementation_software=STR_NULL; inf.des.analyzing.manifacturer_trade_name=STR_NULL; inf.des.acquiring_institution=STR_NULL; inf.des.analyzing_institution=STR_NULL; inf.des.acquiring_department=STR_NULL; inf.des.analyzing_department=STR_NULL; inf.des.room=STR_NULL; inf.des.stat_code=0; inf.dev.baseline_filter=0; inf.dev.lowpass_filter=0; inf.dev.other_filter[0]=0; inf.dev.other_filter[1]=0; inf.dev.other_filter[2]=0; inf.dev.other_filter[3]=0; inf.dev.sequence_number=STR_NULL; inf.dev.electrode_configuration.value=0; inf.dev.electrode_configuration.unit=0; inf.dev.TZ.offset=0; inf.dev.TZ.index=0; inf.dev.TZ.description=STR_NULL; } void section_1(pointer_section info_sections, DATA_INFO &inf) // section 1 { uint8_t tag; uint32_t num=info_sections.length+_COUNT_BYTE; uint16_t dim=0U; int8_t version; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version); Init_S1(inf); do { ReadByte(tag); switch(tag) { case 0: section_1_0(inf.ana); break; case 1: section_1_1(inf.ana); break; case 2: section_1_2(inf.ana); break; case 3: section_1_3(inf.ana); break; case 4: section_1_4(inf.ana); break; case 5: section_1_5(inf.ana); break; case 6: section_1_6(inf.ana); break; case 7: section_1_7(inf.ana); break; case 8: section_1_8(inf.ana); break; case 9: section_1_9(inf.ana); break; case 10: if(!inf.cli.number_drug) { inf.cli.drug=NULL; inf.cli.text_drug=(char*)FreeWithCare(inf.cli.text_drug); dim=0; } section_1_10(inf.cli,dim); break; case 11: section_1_11(inf.ana); break; case 12: section_1_12(inf.ana); break; case 13: if(!inf.cli.number_diagnose) { inf.cli.diagnose=NULL; inf.cli.text_diagnose=(char*)FreeWithCare(inf.cli.text_diagnose); dim=0; } section_1_13(inf.cli,dim); break; case 14: section_1_14(inf.des); break; case 15: section_1_15(inf.des); break; case 16: section_1_16(inf.des); break; case 17: section_1_17(inf.des); break; case 18: section_1_18(inf.des); break; case 19: section_1_19(inf.des); break; case 20: section_1_20(inf.cli); break; case 21: section_1_21(inf.cli); break; case 22: section_1_22(inf.cli); break; case 23: section_1_23(inf.des); break; case 24: section_1_24(inf.des); break; case 25: section_1_25(inf.dev); break; case 26: section_1_26(inf.dev); break; case 27: section_1_27(inf.dev); break; case 28: section_1_28(inf.dev); break; case 29: section_1_29(inf.dev); break; case 30: if(!inf.cli.number_text) { inf.cli.text_free_text=(char*)FreeWithCare(inf.cli.text_free_text); dim=0; } section_1_30(inf.cli,dim); break; case 31: section_1_31(inf.dev); break; case 32: if(!inf.cli.number_hystory) { inf.cli.medical_hystory=NULL; dim=0; } section_1_32(inf.cli,dim,inf.des.acquiring.protocol_revision_number); break; case 33: section_1_33(inf.dev); break; case 34: section_1_34(inf.dev); break; case 35: if(!inf.cli.number_free_hystory) { inf.cli.free_medical_hystory=NULL; inf.cli.text_free_medical_hystory=(char*)FreeWithCare(inf.cli.text_free_medical_hystory); dim=0; } section_1_35(inf.cli,dim); break; case 255: section_1_255(); break; default: section_1_(); break; }//end switch }//end do while((tag!=255) && (_COUNT_BYTE0)) inf.des.analyzing.protocol_revision_number=version; // by E.C. may 2004 CARDIOLINE 1.0 }//end section_1 void section_1_0(demographic &ana) // section 1 tag 0 { uint16_t dim; ReadByte(dim); ana.last_name=ReadString(ana.last_name,dim); }//end section_1_0 void section_1_1(demographic &ana) // section 1 tag 1 { uint16_t dim; ReadByte(dim); ana.first_name=ReadString(ana.first_name,dim); }//end section_1_1 void section_1_2(demographic &ana) //section 1 tag 2 { uint16_t dim; ReadByte(dim); ana.ID=ReadString(ana.ID,dim); }//end section_1_2 void section_1_3(demographic &ana) // section 1 tag 3 { uint16_t dim; ReadByte(dim); ana.second_last_name=ReadString(ana.second_last_name,dim); }//end section_1_3 void section_1_4(demographic &ana) // section 1 tag 4 { uint16_t dim; ReadByte(dim); ReadByte(ana.age.value); ReadByte(ana.age.unit); if(ana.age.unit>5) ana.age.unit=0; }//end section_1_4 void section_1_5(demographic &ana) // section 1 tag 5 { uint16_t dim; uint8_t m, g; uint16_t a; ReadByte(dim); ReadByte(a); ReadByte(m); ReadByte(g); struct tm tmf; // by E.C. feb 2006 tmf.tm_year = a - 1900; tmf.tm_mon = m - 1; tmf.tm_mday = g; tmf.tm_hour = 0; tmf.tm_min = 0; tmf.tm_sec = 0; tmf.tm_isdst = 0; ana.date_birth2 = mktime(&tmf); // store date in native format }//end section_1_5 void section_1_6(demographic &ana) // section 1 tag 6 { uint16_t dim; ReadByte(dim); ReadByte(ana.height.value); ReadByte(ana.height.unit); if(ana.height.unit>3) ana.height.unit=0; }//end section_1_6 void section_1_7(demographic &ana) // section 1 tag 7 { uint16_t dim; ReadByte(dim); ReadByte(ana.weight.value); ReadByte(ana.weight.unit); if(ana.weight.unit>4) ana.weight.unit=0; }//end section_1_7 void section_1_8(demographic &ana) // section 1 tag 8 { uint16_t dim; ReadByte(dim); ReadByte(ana.sex); if(ana.sex>2) ana.sex=3; }//end section_1_8 void section_1_9(demographic &ana) // section 1 tag 9 { uint16_t dim; ReadByte(dim); ReadByte(ana.race); if(ana.race>3) ana.race=0; }//end section_1_9 void section_1_10(clinic &cli, uint16_t &dim) // section 1 tag 10 { uint16_t val; uint8_t code_; char *temp_string=NULL, *pos_char; int16_t pos; ReadByte(val); /* this tag may have more instances; each instance have a: table code (1 byte), class code (1 byte) drug code (1 byte), text description of the drug (at least 1 byte with NULL). */ if(val) { if((cli.drug=(info_drug*)realloc(cli.drug,sizeof(info_drug)*(cli.number_drug+1)))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } ReadByte(cli.drug[cli.number_drug].table); ReadByte(code_); if(!cli.drug[cli.number_drug].table) { pos=Look(class_drug,0,15,code_); if(pos<=0) cli.drug[cli.number_drug].classes=0; else cli.drug[cli.number_drug].classes=pos; } else cli.drug[cli.number_drug].classes=code_; ReadByte(cli.drug[cli.number_drug].drug_code ); if(!cli.drug[cli.number_drug].table) { code_=cli.drug[cli.number_drug].drug_code +256*cli.drug[cli.number_drug].classes; pos=Look(class_drug,16,88,code_); if(pos<0) pos=0; cli.drug[cli.number_drug].drug_code =pos; } cli.drug[cli.number_drug].length=val-3; //string length + NULL if(cli.drug[cli.number_drug].length) { temp_string=ReadString(temp_string,cli.drug[cli.number_drug].length); strcat(temp_string,STR_END); dim+=strlen(temp_string); if((cli.text_drug=(char*)realloc(cli.text_drug,sizeof(char)*(dim+1)))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } pos_char=cli.text_drug; pos_char+=dim-strlen(temp_string); strcpy(pos_char,temp_string); free(temp_string); } cli.number_drug++; } }//end section_1_10 void section_1_11(demographic &ana) // section 1 tag 11 { uint16_t dim; ReadByte(dim); if(dim) ReadByte(ana.systolic_pressure); else ana.systolic_pressure=0; }//end section_1_11 void section_1_12(demographic &ana) // section 1 tag 12 { uint16_t dim; ReadByte(dim); if(dim) ReadByte(ana.diastolic_pressure); else ana.diastolic_pressure=0; }//end section_1_12 void section_1_13(clinic &cli, uint16_t &dim) // section 1 tag 13 { uint16_t val; char *temp_string=NULL, *pos_char; ReadByte(val); if(val) { if((cli.diagnose=(numeric*)realloc(cli.diagnose,sizeof(numeric)*(cli.number_diagnose+1)))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } cli.diagnose[cli.number_diagnose].unit=cli.number_diagnose+1; cli.diagnose[cli.number_diagnose].value=val; temp_string=ReadString(temp_string,cli.diagnose[cli.number_diagnose].value); strcat(temp_string,STR_END); dim+=strlen(temp_string); if((cli.text_diagnose=(char*)realloc(cli.text_diagnose,dim+1))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } pos_char=cli.text_diagnose; pos_char+=dim-strlen(temp_string); strcpy(pos_char,temp_string); free(temp_string); cli.number_diagnose++; } }//end section_1_13 void section_1_14(descriptive &des) // section 1 tag 14 { uint16_t dim, dim_to_skip; uint8_t i, mask, code_; int16_t pos; //fpos_t filepos, filepos_iniz; long filepos, filepos_iniz; ReadByte(dim); filepos = iftell(in); //FGETPOS(in,&filepos); //FGETPOS(in,&filepos_iniz); // by E.C. may 2004 ESAOTE save to reposition at the end of this section filepos_iniz=filepos; dim_to_skip=dim; dim+=filepos COMPAT; ReadByte(des.acquiring.institution_number); ReadByte(des.acquiring.department_number); ReadByte(des.acquiring.ID); ReadByte(des.acquiring.type); if(des.acquiring.type>1) des.acquiring.type=2; ReadByte(des.acquiring.manifacturer); if(des.acquiring.manifacturer>20 && des.acquiring.manifacturer!=255) des.acquiring.manifacturer=0; des.acquiring.model_description=ReadString(des.acquiring.model_description,6); ReadByte(des.acquiring.protocol_revision_number); ReadByte(des.acquiring.category); pos=Look(compatibility,0,3,des.acquiring.category); if(pos<0) pos=4; des.acquiring.category=pos; ReadByte(code_); if(code_<128U) pos=0; else if((code_<192U) && (code_>=128U)) pos=1; else { pos=Look(language_code,2,15,code_); if(pos<0) pos=16; } des.acquiring.language=pos; ReadByte(code_); mask=0x10; for(i=0;i<4;i++) { if(code_&mask) des.acquiring.capability[i]=i+4; else des.acquiring.capability[i]=i; mask<<=1; } ReadByte(des.acquiring.AC); if(des.acquiring.AC>2) des.acquiring.AC=0; Skip(16); des.acquiring.analysing_program_revision_number=(char*)FreeWithCare(des.acquiring.analysing_program_revision_number); des.acquiring.serial_number_device=(char*)FreeWithCare(des.acquiring.serial_number_device); des.acquiring.device_system_software=(char*)FreeWithCare(des.acquiring.device_system_software); des.acquiring.device_SCP_implementation_software=(char*)FreeWithCare(des.acquiring.device_SCP_implementation_software); des.acquiring.manifacturer_trade_name=(char*)FreeWithCare(des.acquiring.manifacturer_trade_name); ReadByte(i); if(!i) des.acquiring.analysing_program_revision_number=(char*)FreeWithCare(des.acquiring.analysing_program_revision_number); else des.acquiring.analysing_program_revision_number=ReadString(des.acquiring.analysing_program_revision_number,i); filepos = iftell(in); //FGETPOS(in,&filepos); des.acquiring.serial_number_device=FindString(des.acquiring.serial_number_device,dim-filepos COMPAT); if ((des.acquiring.protocol_revision_number==10) || (des.acquiring.protocol_revision_number==11)) // by E.C. may 2004 CARDIOLINE 1.0 & ESAOTE 1.1 ifseek(in,filepos_iniz COMPAT +dim_to_skip,0); // reposition file pointer else { filepos = iftell(in); //FGETPOS(in,&filepos); des.acquiring.device_system_software=FindString(des.acquiring.device_system_software,dim-filepos COMPAT); filepos = iftell(in); //FGETPOS(in,&filepos); des.acquiring.device_SCP_implementation_software=FindString(des.acquiring.device_SCP_implementation_software,dim-filepos COMPAT); filepos = iftell(in); //FGETPOS(in,&filepos); des.acquiring.manifacturer_trade_name=FindString(des.acquiring.manifacturer_trade_name,dim-filepos COMPAT); } }//end section_1_14 void section_1_15(descriptive &des) // section 1 tag 15 { uint16_t dim; uint8_t i, mask, code_; int16_t pos; //fpos_t filepos; long filepos; ReadByte(dim); filepos = iftell(in); //FGETPOS(in,&filepos); dim+=filepos COMPAT; ReadByte(des.analyzing.institution_number); ReadByte(des.analyzing.department_number); ReadByte(des.analyzing.ID); ReadByte(des.analyzing.type); if(des.analyzing.type>1) des.analyzing.type=2; ReadByte(des.analyzing.manifacturer); if(des.analyzing.manifacturer>20 && des.analyzing.manifacturer!=255) des.analyzing.manifacturer=0; des.analyzing.model_description=ReadString(des.analyzing.model_description,6); ReadByte(des.analyzing.protocol_revision_number); ReadByte(des.analyzing.category); pos=Look(compatibility,0,3,des.analyzing.category); if(pos<0) pos=4; des.analyzing.category=pos; ReadByte(code_); if(code_<128U) pos=0; else if((code_<192U) && (code_>=128U)) pos=1; else { pos=Look(language_code,2,15,code_); if(pos<0) pos=16; } des.analyzing.language=pos; ReadByte(code_); mask=0x10; for(i=0;i<4;i++) { if(code_&mask) des.analyzing.capability[i]=i+4; else des.analyzing.capability[i]=i; mask<<=1; } ReadByte(des.analyzing.AC); if(des.analyzing.AC>2) des.analyzing.AC=0; Skip(16); des.analyzing.analysing_program_revision_number=(char*)FreeWithCare(des.analyzing.analysing_program_revision_number); des.analyzing.serial_number_device=(char*)FreeWithCare(des.analyzing.serial_number_device); des.analyzing.device_system_software=(char*)FreeWithCare(des.analyzing.device_system_software); des.analyzing.device_SCP_implementation_software=(char*)FreeWithCare(des.analyzing.device_SCP_implementation_software); des.analyzing.manifacturer_trade_name=(char*)FreeWithCare(des.analyzing.manifacturer_trade_name); ReadByte(i); if(!i) des.analyzing.analysing_program_revision_number=(char*)FreeWithCare(des.analyzing.analysing_program_revision_number); else des.analyzing.analysing_program_revision_number=ReadString(des.analyzing.analysing_program_revision_number,i); filepos = iftell(in); //FGETPOS(in,&filepos); des.analyzing.serial_number_device=FindString(des.analyzing.serial_number_device,dim-filepos COMPAT); filepos = iftell(in); //FGETPOS(in,&filepos); des.analyzing.device_system_software=FindString(des.analyzing.device_system_software,dim-filepos COMPAT); filepos = iftell(in); //FGETPOS(in,&filepos); des.analyzing.device_SCP_implementation_software=FindString(des.analyzing.device_SCP_implementation_software,dim-filepos COMPAT); filepos = iftell(in); //FGETPOS(in,&filepos); des.analyzing.manifacturer_trade_name=FindString(des.analyzing.manifacturer_trade_name,dim-filepos COMPAT); }//end section_1_15 void section_1_16(descriptive &des) // section 1 tag 16 { uint16_t dim; ReadByte(dim); des.acquiring_institution=ReadString(des.acquiring_institution,dim); }//end section_1_16 void section_1_17(descriptive &des) // section 1 tag 17 { uint16_t dim; ReadByte(dim); des.analyzing_institution=ReadString(des.analyzing_institution,dim); }//end section_1_17 void section_1_18(descriptive &des) // section 1 tag 18 { uint16_t dim; ReadByte(dim); des.acquiring_department=ReadString(des.acquiring_department,dim); }//end section_1_18 void section_1_19(descriptive &des) // section 1 tag 19 { uint16_t dim; ReadByte(dim); des.analyzing_department=ReadString(des.analyzing_department,dim); }//end section_1_19 void section_1_20(clinic &cli) // section 1 tag 20 { uint16_t dim; ReadByte(dim); cli.referring_physician=ReadString(cli.referring_physician,dim); }//end section_1_20 void section_1_21(clinic &cli) // section 1 tag 21 { uint16_t dim; ReadByte(dim); cli.latest_confirming_physician=ReadString(cli.latest_confirming_physician,dim); }//end section_1_21 void section_1_22(clinic &cli) // section 1 tag 22 { uint16_t dim; ReadByte(dim); cli.technician_description=ReadString(cli.technician_description,dim); }//end section_1_22 void section_1_23(descriptive &des) // section 1 tag 23 { uint16_t dim; ReadByte(dim); des.room=ReadString(des.room,dim); }//end section_1_23 void section_1_24(descriptive &des) // section 1 tag 24 { uint16_t dim; ReadByte(dim); ReadByte(des.stat_code); }//end section_1_24 void section_1_25(device &dev) // section 1 tag 25 { uint16_t dim; uint8_t m, g; uint16_t a; ReadByte(dim); ReadByte(a); ReadByte(m); ReadByte(g); struct tm tmf; // by E.C. feb 2006 tmf.tm_year = a - 1900; tmf.tm_mon = m - 1; tmf.tm_mday = g; tmf.tm_hour = 0; tmf.tm_min = 0; tmf.tm_sec = 0; tmf.tm_isdst = 0; dev.date_acquisition2 = mktime(&tmf); // store date in native format }//end section_1_25 void section_1_26(device &dev) // section 1 tag 26 { uint16_t dim; uint8_t h, m, s; ReadByte(dim); ReadByte(h); ReadByte(m); ReadByte(s); dev.time_acquisition2 = (time_t) (s + m*(60 + h*24)); // by E.C. feb 2006 time in seconds }//end section_1_26 void section_1_27(device &dev) // section 1 tag 27 { uint16_t dim; ReadByte(dim); ReadByte(dev.baseline_filter); }//end section_1_27 void section_1_28(device &dev) // section 1 tag 28 { uint16_t dim; ReadByte(dim); ReadByte(dev.lowpass_filter); }//end section_1_28 void section_1_29(device &dev) // section 1 tag 29 { uint16_t dim; uint8_t mask=0x1, val, i, max=4, ris=0; ReadByte(dim); ReadByte(val); for(i=0;i6) pos=0; dev.electrode_configuration.value=pos; ReadByte(pos); if(pos>6) pos=0; dev.electrode_configuration.unit=pos; }//end section_1_33 void section_1_34(device &dev) // section 1 tag 34 { uint16_t dim; ReadByte(dim); ReadByte(dev.TZ.offset); //complemented if negative ReadByte(dev.TZ.index); if(dim-4) dev.TZ.description = FindString((char*)dev.TZ.description,dim-4); else{ dev.TZ.description = (const char*)realloc((char*)dev.TZ.description,4); strcpy((char*)dev.TZ.description,"-"); } }//end section_1_34 void section_1_35(clinic &cli, uint16_t &dim) // section 1 tag 35 { uint16_t val; char *temp_string=NULL, *pos_char; ReadByte(val); if(val) { if((cli.free_medical_hystory=(numeric*)realloc(cli.free_medical_hystory,sizeof(numeric)*(cli.number_free_hystory+1)))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } cli.free_medical_hystory[cli.number_free_hystory].unit=cli.number_free_hystory+1; cli.free_medical_hystory[cli.number_free_hystory].value=val; temp_string=ReadString(temp_string,cli.free_medical_hystory[cli.number_free_hystory].value); strcat(temp_string,STR_END); dim+=strlen(temp_string); if((cli.text_free_medical_hystory=(char*)realloc(cli.text_free_medical_hystory,dim+1))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } pos_char=cli.text_free_medical_hystory; pos_char+=dim-strlen(temp_string); strcpy(pos_char,temp_string); free(temp_string); cli.number_free_hystory++; } }//end section_1_35 void section_1_() // section 1 tag 36..254 are manufacturer specifics and are not utilized { uint16_t dim; ReadByte(dim); Skip(dim); }//end section_1_ void section_1_255() // section 1 tag 255 { uint16_t dim; ReadByte(dim); }//end section_1_255 #endif //______________________________________________________________________________ // section 2 //______________________________________________________________________________ void section_2(pointer_section info_sections,DATA_DECODE &data) //build Huffman tables if included in the file; if none then use del default one //cannot read the dummy Huffman table { uint16_t nt, i, j, ns=0, pos, dim; //fpos_t filepos; long filepos; int8_t version; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version); dim=info_sections.length-16; ReadByte(nt); if(nt!=19999U) { if((data.flag_Huffman=(uint16_t*)mymalloc(sizeof(uint16_t)*(nt+1)))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } data.flag_Huffman[0]=nt; filepos = iftell(in); //FGETPOS(in,&filepos); for(i=1;i<=data.flag_Huffman[0];i++) { ReadByte(data.flag_Huffman[i]); ns+=data.flag_Huffman[i]; Skip(9*data.flag_Huffman[i]); } ifseek(in,filepos COMPAT,0); if((ns*9)>dim || !ns) { B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "SCP-DECODE: Cannot read data"; return; } if(ns!=0 && (data.t_Huffman=(table_H*)mymalloc(sizeof(table_H)*ns))==NULL) //array of 5 columns and ns rows { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } pos=0; for(j=0;j>3; if (version==11) // by E.C. may 2004 ESAOTE data.flag_lead.number_simultaneously=8; if(data.flag_lead.number!=0 && (data.data_lead=(lead*)mymalloc(sizeof(lead)*data.flag_lead.number))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } for(i=0;i85) data.data_lead[i].ID=0; } }//end section_3 //______________________________________________________________________________ // section 4 //______________________________________________________________________________ void section_4(pointer_section info_sections,DATA_DECODE &data,int8_t version) { uint16_t i; int8_t version_loc; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version_loc); ReadByte(data.flag_BdR0.length); ReadByte(data.flag_BdR0.fcM); ReadByte(data.flag_Res.number); if(data.flag_Res.bimodal || data.flag_lead.subtraction) // by E.C. may 2004 { if(data.flag_Res.number!=0 && (data.data_subtraction=(Subtraction_Zone*)mymalloc(sizeof(Subtraction_Zone)*data.flag_Res.number))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } for(i=0;i2) data.flag_BdR0.encoding=0; Skip(1); if(data.flag_lead.number!=0 && (data.length_BdR0=(uint16_t*)mymalloc(sizeof(uint16_t)*data.flag_lead.number))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return false; } dim=0; for(i=0;i>=1; dim*=sizeof(int32_t); if(dim!=0 && (data.Median=(int32_t*)mymalloc(dim))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return false; } dim/=sizeof(int32_t); for(t=0;t0x7FFF) data.Median[t]|=0xFFFF0000; } } return true; }//end section_5 //______________________________________________________________________________ // section 6 //______________________________________________________________________________ void section_6(pointer_section info_sections,DATA_DECODE &data, bool sez2) { uint16_t i; uint32_t t, dim; uint16_t value; int8_t version; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version); ReadByte(data.flag_Res.AVM); ReadByte(data.flag_Res.STM); ReadByte(data.flag_Res.encoding); if(data.flag_Res.encoding>2) data.flag_Res.encoding=0; Skip(1); if(data.flag_lead.number!=0 && (data.length_Res=(uint16_t*)mymalloc(sizeof(uint16_t)*data.flag_lead.number))==NULL) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SCP-DECODE: Not enough memory"; return; } dim=0; for(i=0;i>=1; dim*=sizeof(int32_t); if(dim!=0 && (data.Residual=(int32_t*)mymalloc(dim))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim/=sizeof(int32_t); for(t=0;t0x7FFF) data.Residual[t]|=0xFFFF0000; } } }//end section_6 #ifdef WITH_OBSOLETE_PARTS //______________________________________________________________________________ // section 7 //______________________________________________________________________________ void section_7(pointer_section info_sections ,DATA_RECORD &data, int8_t version) { uint16_t i, j, dim; uint8_t lung; //fpos_t filepos; long filepos; int8_t version_loc; uint32_t length_eval; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version_loc); ReadByte(data.data_global.number); //each value should be checked in _special! ReadByte(data.data_global.number_spike); if (version==11) ReadByte(data.data_global.number_spike); // by E.C. may 2004 x ESAOTE!! This is an implementation error, for sure! ReadByte(data.data_global.average_RR); ReadByte(data.data_global.average_PP); if(Look(_special,0,3,data.data_global.number)<0) { if(data.data_global.number!=0 && (data.data_BdR=(BdR_measurement*)mymalloc(sizeof(BdR_measurement)*data.data_global.number))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } for(i=0;i3) data.data_spike[i].type=0; ReadByte(data.data_spike[i].source); if(data.data_spike[i].source>2) data.data_spike[i].source=0; ReadByte(data.data_spike[i].index); ReadByte(data.data_spike[i].pulse_width); }//end for }//end if if (version<13) { // by E.C. may 2004 CARDIOLINE & ESAOTE missing!! if ((data.data_global.average_RR>0) && (data.data_global.average_RR<10000)) data.data_global.ventricular_rate=60000.0/data.data_global.average_RR+0.5; return; } // Insert by F.C. if (version>=13) { length_eval = 16 + 6 + data.data_global.number * 16 + data.data_global.number_spike * 4 + data.data_global.number_spike * 6; if (length_eval >= info_sections.length) return; } // End of F.C. insertion ReadByte(data.data_global.number_QRS); if (data.data_global.number_QRS==29999) return; // by E.C. 12/09/2007 if(Look(_special,0,3,data.data_global.number_QRS)<0) { filepos = iftell(in); //FGETPOS(in,&filepos); //necessary for ESAOTE and CARDIOLINE test files dim=info_sections.index+info_sections.length-filepos COMPAT+1; if(data.data_global.number_QRS>dim) { fprintf(stderr,"Error: Cannot extract these data!!!"); exit(2); //necessary for ESAOTE and CARDIOLINE test files } if(data.data_global.number_QRS!=0 && (data.type_BdR=(uint8_t*)mymalloc(sizeof(uint8_t)*data.data_global.number_QRS))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } for(i=0;i=13) { length_eval += (2 + data.data_global.number_QRS); if (length_eval >= info_sections.length) return; } // End of F.C. insertion ReadByte(data.data_global.ventricular_rate); ReadByte(data.data_global.atrial_rate); ReadByte(data.data_global.QT_corrected); ReadByte(data.data_global.formula_type); if(data.data_global.formula_type>2) data.data_global.formula_type=0; ReadByte(data.data_global.number_tag); if(data.data_global.number_tag) { data.data_global.number_tag-=2; data.data_global.number_tag/=7; // tag number //warnig: this calculation is relative to the structure of STANDARD v2.0! if(data.data_global.number_tag!=0 && (data.data_additional=(additional_measurement*)mymalloc(sizeof(additional_measurement)*data.data_global.number_tag))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } for(i=0;i3) data.data_additional[i].ID=4; ReadByte(lung); if(lung) { //warning:(255 is undefined) for(j=0;j<5;j++) ReadByte(data.data_additional[i].byte[j]); }//end if }//end for }//end if }//end section_7 //______________________________________________________________________________ // section 8 //______________________________________________________________________________ void section_8(pointer_section info_sections,DATA_INFO &data) { uint8_t m, g, h, s, i; uint16_t a, dim; char *c; //fpos_t filepos; long filepos; int8_t version; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version); ReadByte(data.flag_report.type); if(data.flag_report.type>2) data.flag_report.type=3; ReadByte(a); ReadByte(m); ReadByte(g); ReadByte(h); ReadByte(m); ReadByte(s); struct tm tmf; tmf.tm_year = a; tmf.tm_mon = m; tmf.tm_mday = g; tmf.tm_hour = h; tmf.tm_min = m; tmf.tm_sec = s; data.flag_report.date = (char*)mymalloc(18); strftime(data.flag_report.date,18,"%d %b %Y", &tmf); data.flag_report.time = (char*)mymalloc(18); strftime(data.flag_report.date,18,"%H:%M:%S", &tmf); ReadByte(data.flag_report.number); if(data.flag_report.number) { filepos = iftell(in); //FGETPOS(in,&filepos); if(data.flag_report.number!=0 && (data.text_dim=(numeric*)mymalloc(data.flag_report.number*sizeof(numeric)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim=0; for(i=0;i>1)-2; if(n1>31) // for now 33 are defined n1=31; //ignore next bytes data.header_lead.number_lead_measurement=n1; //max number of statements by the manufacturer (2 bytes each) if(data.header_lead.number_lead) // by E.C. 17.11.2003 deleted "!" in the if { if((data.lead_block=(lead_measurement_block*)mymalloc(data.header_lead.number_lead*sizeof(lead_measurement_block)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } for(i=0;i85) id=0; ReadByte(dim); n2=(dim>>1); if(n2>n1) skip=(n2-n1)<<1; // bytes to skip else skip=0; data.lead_block[i].ID=id; //warnig: values relative to _SPECIAL for(j=1;j<=data.header_lead.number_lead_measurement;j++) { switch(j) { case 1: ReadByte(data.lead_block[i].P_duration); break; case 2: ReadByte(data.lead_block[i].PR_interval); break; case 3: ReadByte(data.lead_block[i].QRS_duration); break; case 4: ReadByte(data.lead_block[i].QT_interval); break; case 5: ReadByte(data.lead_block[i].Q_duration); break; case 6: ReadByte(data.lead_block[i].R_duration); break; case 7: ReadByte(data.lead_block[i].S_duration); break; case 8: ReadByte(data.lead_block[i].R1_duration); break; case 9: ReadByte(data.lead_block[i].S1_duration); break; case 10: ReadByte(data.lead_block[i].Q_amplitude); break; case 11: ReadByte(data.lead_block[i].R_amplitude); break; case 12: ReadByte(data.lead_block[i].S_amplitude); break; case 13: ReadByte(data.lead_block[i].R1_amplitude); break; case 14: ReadByte(data.lead_block[i].S1_amplitude); break; case 15: ReadByte(data.lead_block[i].J_point_amplitude); break; case 16: ReadByte(data.lead_block[i].Pp_amplitude); break; case 17: ReadByte(data.lead_block[i].Pm_amplitude); break; case 18: ReadByte(data.lead_block[i].Tp_amplitude); break; case 19: ReadByte(data.lead_block[i].Tm_amplitude); break; case 20: ReadByte(data.lead_block[i].ST_slope); break; case 21: ReadByte(data.lead_block[i].P_morphology); if(data.lead_block[i].P_morphology) data.lead_block[i].P_morphology=0; break; case 22: ReadByte(data.lead_block[i].T_morphology); if(data.lead_block[i].T_morphology) data.lead_block[i].T_morphology=0; break; case 23: ReadByte(data.lead_block[i].iso_electric_segment_onset_QRS); break; case 24: ReadByte(data.lead_block[i].iso_electric_segment_offset_QRS); break; case 25: ReadByte(data.lead_block[i].intrinsicoid_deflection); break; case 26: ReadByte(val); mask=0x3; for(k=0;k<8;k++) { data.lead_block[i].quality_recording[k]=mask&val; // TODO: code has no effect mask<<2; } break; case 27: ReadByte(data.lead_block[i].ST_amplitude_Jplus20); break; case 28: ReadByte(data.lead_block[i].ST_amplitude_Jplus60); break; case 29: ReadByte(data.lead_block[i].ST_amplitude_Jplus80); break; case 30: ReadByte(data.lead_block[i].ST_amplitude_JplusRR16); break; case 31: ReadByte(data.lead_block[i].ST_amplitude_JplusRR8); break; }//end switch }//end for if(skip) Skip(skip); }//end if }//end for }//end if }//end section_10 //______________________________________________________________________________ // section 11 //______________________________________________________________________________ void section_11(pointer_section info_sections,DATA_INFO &data) /* expressions (ASCII) should be either: 1) diagnostic statement_probability_modifiers; 2) diagnostic statement_probability_modifier_conjunctive term_diagnostic statement_probability_modifier...; in the test files I found only 1 diagnostic statement per expression, ending with a NULL. */ { uint8_t m, g, h, s, i, j; uint16_t a, dim; char *temp_string=0, *punt, c; //fpos_t filepos; long filepos; int8_t version; _COUNT_BYTE=info_sections.index; ifseek(in,info_sections.index-1,0); ID_section(info_sections.index, version); ReadByte(data.flag_statement.type); if(data.flag_statement.type>2) data.flag_statement.type=3; ReadByte(a); ReadByte(m); ReadByte(g); ReadByte(h); ReadByte(m); ReadByte(s); struct tm tmf; tmf.tm_year = a; tmf.tm_mon = m; tmf.tm_mday = g; tmf.tm_hour = h; tmf.tm_min = m; tmf.tm_sec = s; data.flag_statement.date = (char*)mymalloc(18); strftime(data.flag_statement.date,18,"%d %b %Y", &tmf); data.flag_statement.time = (char*)mymalloc(18); strftime(data.flag_statement.time,18,"%H:%M:%S", &tmf); ReadByte(data.flag_statement.number); //number of expressions if(!data.flag_statement.number) { filepos = iftell(in); //FGETPOS(in,&filepos); if(data.flag_statement.number!=0 && (data.data_statement=(statement_coded*)mymalloc(data.flag_statement.number*sizeof(statement_coded)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim=0; for(i=0;i void Differences(int32_t *dati, t1 flag, uint8_t num) { uint8_t i; uint16_t j; for(i=0;inext_0); Tree_Destroy(radix->next_1); free(radix); } return; } TREE_NODE *Tree_Create(TREE_NODE *tree, uint16_t n_of_struct, table_H *table, uint16_t pos) //build a tree { uint8_t i,j; uint32_t mask; TREE_NODE *temp; //build the root if((tree=(TREE_NODE *)mymalloc(sizeof(TREE_NODE)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } tree->next_0=NULL; tree->next_1=NULL; tree->row=-1; //-1 means no row in the table for (j=0;jnext_1==NULL) { if((temp->next_1=(TREE_NODE *)mymalloc(sizeof(TREE_NODE)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } temp->next_1->next_0=NULL; temp->next_1->next_1=NULL; temp->next_1->row=-1; } temp=temp->next_1; }//end if else { if (temp->next_0==NULL) { if((temp->next_0=(TREE_NODE *)mymalloc(sizeof(TREE_NODE)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } temp->next_0->next_0=NULL; temp->next_0->next_1=NULL; temp->next_0->row=-1; } temp=temp->next_0; }//end else mask <<=1; }//end for i temp->row=j; //marks the j row in the table }//end for j return tree; }//end Tree_Create uint8_t Input_Bit(uint8_t *raw, uint16_t &pos, uint16_t max, uint8_t &mask, bool &err) { uint8_t value; if(pos==max) { err=1; return 0; } value=raw[pos]&mask; mask>>=1; if(!mask) { mask=0x80; ++pos; } return( value ? 1 : 0 ); }//end Input_Bit int16_t Input_Bits(uint8_t *raw, uint16_t &pos, uint16_t max, uint8_t &mask, uint8_t bit_count, bool &err) { uint16_t temp; int16_t value; if(pos==max) { err=1; return 0; } temp=1<<(bit_count-1); value=0; do { if(raw[pos]&mask) value |= temp; temp>>=1; mask>>=1; if(!mask) { mask=0x80; ++pos; if(pos==max) { mask=0; // by E.C. may 2004 break; } } } while(temp); if(temp) err=1; if (value & (1<<(bit_count-1))) // by E.C. may 2004 negative value. extend to the left value|=(-1<next_1; else temp=temp->next_0; if (temp==NULL) { fprintf(stderr,"Tree overflow"); err=1; break; } if (temp->row > -1) // row found in the table: exit for break; if(pos_in==maxIN) err=1; if(err) break; }//end for if(err) // check for error conditions and if exit while { break; // by E.C. may 2004 } if(table[temp->row+pos_tH].TMS!=1) // switch to another table { Tree_Destroy(tree); // destroy the tree and rebuild with the new table pos_tH=0; for(i=1;irow+pos_tH].base_value;i++) pos_tH+=flag[i]; // offset of the table tree=Tree_Create(tree,flag[table[temp->row+pos_tH].base_value],table,pos_tH); continue; }//end if table else { nbits=table[temp->row+pos_tH].bit_code-table[temp->row+pos_tH].bit_prefix; if (nbits) // bit of the code != bit of the prefix { if(pos_in==maxIN) { err=1; break; // by E.C. may 2004 } raw_out[pos_out]=Input_Bits(raw_in,pos_in,maxIN,mask,nbits,err); // take value from the stream if(err) // check for error conditions and if exit while { break; // by E.C. may 2004 } ++pos_out; }//end if nbits else // bit of the code = bit of the prefix { raw_out[pos_out]=table[temp->row+pos_tH].base_value; // take value from the table ++pos_out; } }//end else if table ++j; if (j==max_out) break; // by E.C. may 2004 } //end while pos_in=maxIN; // by E.C. 23.02.2004: align for safety max_out=j; // flows here anyhow! if (max_out>4900) { max_out=5000; // by E.C. may 2004 ESAOTE pos_out=(pos_out+100)/max_out*max_out; // align pointer } }//end decompress //data.data_BdR0 , data.length_BdR0 , data.samples_BdR0 , data.flag_BdR0.number_samples , data.flag_lead.number , data.t_Huffman , data.flag_Huffman //out_data , length , in_data , n_samples , n_lead , t_Huffman , flag_Huffman void Huffman(int32_t *out_data, uint16_t *length, uint8_t *in_data, uint16_t &n_samples, uint16_t n_lead, table_H *t_Huffman, uint16_t *flag_Huffman) { TREE_NODE *tree = NULL; uint16_t pos_in, pos_out, pos_tH; uint8_t i; pos_in=0; pos_out=0; pos_tH=0; tree=Tree_Create(tree,flag_Huffman[1],t_Huffman,pos_tH); for(i=0;i1) // by E.C. 19.02.2004 (i.e. to open pd3471) { //dim_R = number of bytes of decimated signal (4 bytes (int32_t) ) //data.flag_Res.number_samples = samples of the decimated signal //dim_R_ = number of bytes of the reconstructed signal (4 bytes (int32_t) ) //number_samples_ = samples of the reconstructed signal data.flag_Res.number_samples=number_samples_; //number of samples per lead number_samples_=dim_R/(sizeof(int32_t)*data.flag_lead.number); dim_R=dim_R_; dim_R_=(dim_R/sizeof(int32_t))*sizeof(float)*2; //dim_R_ = number of bytes of decimated signal (4 bytes (int32_t) ) //number_samples_ = samples of the decimated signal //dim_R = number of bytes of the reconstructed signal (4 bytes (int32_t) ) //data.flag_Res.number_samples = samples of the reconstructed signal if(dim_R_!=0 && (dati_Res_=(int32_t*)mymalloc(dim_R_))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } Interpolate(dati_Res_,data.Residual,data.flag_lead,data.data_lead,data.flag_Res,data.data_protected,number_samples_); DoFilter(data.Residual,dati_Res_,data.flag_Res,data.flag_lead,data.data_lead,data.data_protected,data.data_subtraction); free(dati_Res_); //dim_R modifies } } Multiply(data.Residual,data.flag_Res.number_samples*data.flag_lead.number,data.flag_Res.AVM); /* AS 2007-10-23: for some (unknown) reason, sometimes the memory allocation has the wrong size doing the memory allocation in sopen_scp_read does it correctly. Number of files with SegFaults is reduced by 3. if(dim_R!=0 && (data.Reconstructed=(int32_t*)mymalloc(dim_R))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } */ unsigned dim_RR=dim_R/sizeof(int32_t); // by E.C. 15.10.2003 This to correct a trivial error for(t=0;t1)){ // by E.C. 25.02.2004 // now that the signal is completely reconstructructed, and if decimation was performed // during the compression phase, do an extra low-pass filter outside protected zones ! // This shows lower RMS values of about 0.5 - 1.0 // If you don't like this extra filtering please uncheck the menu option and reopen for(t=0;tb : may be - the first sample is the first of the first protected zone (a=b+1=1) - empty no-protection zone (a=b+1) - the last sample is the last of the last protected zone (a=b+1) in these situations samples are copied as they are. */ { uint16_t a, b; //interpolation range float v; //interpolation value uint8_t j; //working variable uint16_t dim; //number of samples (to skip) into a protected zone uint16_t mINS, mCOPY; //number of samples to insert, copy int16_t num; //number of samples to interpolate uint32_t pos_in, pos_out; uint16_t nz; //index of protected zones, i.e. index of QRS uint8_t ne; //index of lead pos_in=0; pos_out=0; for(ne=0;ne0) { mINS=num/flag.decimation_factor; //number to interpolate mCOPY=num%flag.decimation_factor; //if, residual number to copy if(mINS) { //store first two samples equal to the first value in the list ... raw_out[pos_out++]=raw_in[pos_in]; raw_out[pos_out++]=raw_in[pos_in]; } // ... then proceed with interpolation dim=mINS; while((dim--)>1) { v=1.0*(raw_in[pos_in+1]-raw_in[pos_in])/flag.decimation_factor; // by E.C. 23.02.2004 (float v) // rounding improves RMS! for(j=0;j=(sample_Huff*(ne+1))) //check overflow break; if(mINS) { raw_out[pos_out++]=raw_in[pos_in]; raw_out[pos_out++]=raw_in[pos_in]; if(pos_in<(sample_Huff*(ne+1))) // by E.C. 19.02.2004 check overflow ++pos_in; } //not normal situation? insert mCOPY samples while((mCOPY--)>0) if(pos_in<(sample_Huff*(ne+1))) // by E.C. 19.02.2004 check overflow raw_out[pos_out++]=raw_in[pos_in++]; else raw_out[pos_out++]=0; }//end if num>0 if (nz0) raw_out[pos_out++]=raw_in[pos_in++]; } }//for nz pos_in=sample_Huff*(ne+1); // by E.C. 19.02.2004 align, never mind!! pos_out=(pos_out+100)/5000*5000; // by E.C. may 2004 for testing purposes only }//for ne }//end Interpolate void ExecFilter(int32_t *raw_in, int32_t *raw_out, uint32_t &pos, uint16_t dim) //filter from pos for dim samples { int32_t v; //value uint16_t i; if (dim>0) { //fist sample = unchanged raw_out[pos]=raw_in[pos]; pos++; if(dim>2) for(i=2;i=0) // as suggested by the standard for rounding v+=1; else v-=1; raw_out[pos++]=v/3; // by E.C. 24.02.2004 in this case, declaring v as float doesn't change results } } //last sample = unchanged if(dim>1) { raw_out[pos]=raw_in[pos]; pos++; } }//end ExecFilter void DoFilter(int32_t *raw_out, int32_t *raw_in, f_Res flag, f_lead flag_L, lead *marker_A, Protected_Area *marker_P, Subtraction_Zone *marker_S) //filter low-pass outside the proteced zones (marker_Z) for each lead (marker_A) // but taking into account transients at the boundaries of the subtraction zones (marker_S) //It's included rounding. { uint16_t a, b=0; //interval int16_t num; uint32_t pos; uint16_t nz; uint8_t ne; //index of lead pos=0; // by E.C. 19.02.2004 function redefined such as Interpolate() for(ne=0;ne0) { raw_out[pos]=raw_in[pos]; pos++; } } }//for nz } // for ne/ng }//end DoFilter void DoAdd(int32_t *raw_out, int32_t *raw_R, f_Res flag_R, int32_t *raw_B, f_BdR0 flag_B, Subtraction_Zone *marker_S, f_lead flag_L, lead *marker_A) //add BdR0 with the rhythm data for all leads { uint16_t pos_B; uint32_t pos_R, pos_out; uint16_t ns, a , b, num; uint8_t ne; //index of leads pos_R=0; // by E.C. 19.02.2004 add reference beat to rhythm for(ne=0;ne0) { raw_out[pos_out]+=raw_B[pos_B]; pos_out++; pos_B++; pos_R++; } }//end for/if }//end DoAdd void Opt_Filter(int32_t *raw_out, int32_t *raw_in, f_Res flag, f_lead flag_L, lead *marker_A, Protected_Area *marker_P) // by E.C. 25.02.2004 // do an extra low-pass filter outside protected zones (marker_P) // in the range of the signal (marker_A) for each lead // this is simpler than DoFilter() { uint16_t a, b=0; //interval for filtering int16_t num; uint32_t pos; uint16_t nz; uint8_t ne; //lead index pos=0; for(ne=0;ne0) { raw_out[pos]=raw_in[pos]; pos++; } } }//for nz } // for ne }//end Opt_Filter biosig-2.3.3/biosig4c++/t210/sopen_alpha_read.c0000664000175000017500000004040214105434233021125 0ustar schloeglschloegl/* $Id: sopen_alpha_read.c,v 1.2 2009-02-12 16:15:17 schloegl Exp $ Copyright (C) 2005,2006,2007,2008,2009 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include "../biosig.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) EXTERN_C void sopen_alpha_read(HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ size_t count; unsigned int k; const char *FileName = hdr->FileName; fprintf(stdout,"Warning: support for alpha format is just experimental.\n"); char* fn = (char*)malloc(strlen(hdr->FileName)+15); strcpy(fn,hdr->FileName); // Flawfinder: ignore const size_t bufsiz = 4096; char buf[bufsiz]; // alpha.alp cal_res digin digvidtc eog marker measure mkdef montage rawdata rawhead report.txt r_info sleep const char *f2 = "alpha.alp"; char *tmpstr = strrchr(fn,FILESEP); if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore FILE *fid = fopen(fn,"r"); count = fread(buf,1,bufsiz-1,fid); fclose(fid); buf[count]=0; // terminating 0 character char *t = strtok(buf,"\xA\xD"); while (t) { if (VERBOSE_LEVEL>7) fprintf(stdout,"0: %s \n",t); if (!strncmp(t,"Version = ",9)) hdr->VERSION = atof(t+9); else if (!strncmp(t,"Id = ",4)) { strncpy(hdr->ID.Manufacturer._field,t+5,MAX_LENGTH_MANUF); hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; } t = strtok(NULL,"\xA\xD"); } f2 = "rawhead"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore int Notch = 0; int Bits = 0; double DigMax=0, DigMin=0; uint16_t gdftyp = 0; int ns = 0; fid = fopen(fn,"r"); count = fread(buf,1,bufsiz-1,fid); fclose(fid); buf[count]=0; // terminating 0 character t = strtok(buf,"\xA\xD"); char STATUS = 1; uint32_t *ChanOrder=NULL; char **ChanType = NULL; while ((t!=NULL) && (STATUS<9)) { char *t1 = strchr(t,'='); if (VERBOSE_LEVEL>7) fprintf(stdout,"<%6.2f> %i- %s | %s\n",hdr->VERSION, STATUS,t,t1); if (t1) { t1[-1] = 0; t1++; if (STATUS == 1) { if (!strcmp(t,"Version")) hdr->VERSION = atof(t1); else if (!strcmp(t,"BitsPerValue")) { Bits = atoi(t1); switch (Bits) { case 12: gdftyp = 255+12; // hdr->FILE.LittleEndian = 0; DigMax = (1<<(Bits-1))-1; DigMin = -(1<<(Bits-1)); break; case 16: gdftyp = 3; DigMax = 32752.0; //!!! that's the maximum value found in alpha-trace files DigMin = -32736.0; //!!! that's the minimum value found in alpha-trace files break; case 32: gdftyp = 5; break; DigMax = (1<<(Bits-1))-1; DigMin = -(1<<(Bits-1)); } } else if (!strcmp(t,"ChanCount")) { hdr->NS = atoi(t1); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); ChanOrder = (uint32_t*)calloc(hdr->NS,sizeof(uint32_t)*2); ChanType = (char**)calloc(hdr->NS,sizeof(char*)); } else if (!strcmp(t,"SampleFreq")) hdr->SampleRate = atof(t1); else if (!strcmp(t,"SampleCount")) { hdr->NRec = atoi(t1); hdr->SPR = 1; } else if (!strcmp(t,"NotchFreq")) Notch = atof(t1); else if (!strcmp(t,"DispFlags") && (hdr->VERSION < 411.89)) STATUS = 2; else if (!strcmp(t,"Sec2Marker") && (hdr->VERSION > 411.89)) STATUS = 2; } else if (STATUS == 2) { if (ns>=hdr->NS) { ns = 0; STATUS = 3; } else { CHANNEL_TYPE *hc = hdr->CHANNEL+ns; hc->GDFTYP = gdftyp; hc->Notch = Notch; hc->LeadIdCode = 0; hc->SPR = hdr->SPR; //hc->bi8 = GDFTYP_BITS[gdftyp]*ns; hc->DigMax = DigMax; hc->DigMin = DigMin; hc->OnOff = 1; hc->Cal = 1.0; hc->Off = 0.0; hc->PhysMax = hc->DigMax; hc->PhysMin = hc->DigMin; hc->Transducer[0] = 0; strncpy(hc->Label, t, MAX_LENGTH_LABEL+1); char* t2= strchr(t1,','); t2[0] = 0; while (isspace((++t2)[0])); char* t3= strchr(t2,','); t3[0] = 0; while (isspace((++t3)[0])); char* t4= strchr(t3,','); t4[0] = 0; while (isspace((++t4)[0])); ChanOrder[ns*2] = atoi(t2); ChanOrder[ns*2+1] = ns; ChanType[ns] = t3; ns++; } } else if (STATUS == 3) { // decode information (filters, PhysDim, etc.) and assign to corresponding channels. char *pd = NULL; float tmp1, tmp2, HighPass, LowPass; #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L sscanf(t1, "%f, %f, %f, %f, %as", &HighPass,&LowPass, &tmp1,&tmp2, &pd); #else sscanf(t1, "%f, %f, %f, %f, %ms", &HighPass,&LowPass, &tmp1,&tmp2, &pd); #endif strrchr(pd,',')[0]=0; if (!strcmp(pd,"%%")) pd[1]=0; uint16_t pdc = PhysDimCode(pd); if (pd) free(pd); char flag = 0; for (k=0; k < hdr->NS; k++) { if ((ChanType[k]!=NULL) && !strcmp(t,ChanType[k])) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->PhysDimCode = pdc; //strcpy(hc->PhysDim,pd); hc->LowPass = LowPass; hc->HighPass = HighPass; ChanType[k] = NULL; } if (ChanType[k] != NULL) flag = 1; // not done yet } if (!flag) STATUS = 99; // done with channel definition } } t = strtok(NULL,"\xA\xD"); } hdr->AS.bpb8 = (GDFTYP_BITS[gdftyp]*hdr->NS); // hdr->AS.bpb = (GDFTYP_BITS[gdftyp]*hdr->NS)>>3; // do not rely on this, because some bits can get lost // sort channels qsort(ChanOrder,hdr->NS,2*sizeof(uint32_t),&u32cmp); for (k=0; kNS; k++) { hdr->CHANNEL[ChanOrder[2*k+1]].bi8 = GDFTYP_BITS[gdftyp]*k; hdr->CHANNEL[ChanOrder[2*k+1]].bi = (GDFTYP_BITS[gdftyp]*k)>>3; } free(ChanOrder); free(ChanType); f2 = "cal_res"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore fid = fopen(fn,"r"); if (fid!=NULL) { if (VERBOSE_LEVEL>7) fprintf(stdout,"cal_res: \n"); count = fread(buf,1,bufsiz-1,fid); fclose(fid); buf[count]=0; // terminating 0 character t = strtok(buf,"\xA\xD"); t = strtok(NULL,"\xA\xD"); // skip lines 1 and 2 /* char label[MAX_LENGTH_LABEL+1]; char flag[MAX_LENGTH_LABEL+1]; double cal,off; */ char *t0,*t1,*t2,*t3; unsigned n=0; // for (k=0; max(k,n)NS; k++) { t = strtok(NULL,"\xA\xD"); if (t==NULL) { fprintf(stderr,"Warning SOPEN(alpha): scaling coefficients not defined for all channels\n"); break; } // strncpy(hc->Label,t,min(strcspn(t," =,"),MAX_LENGTH_LABEL)); t0 = strchr(t,'=');t0[0]=0;t0++; int ix = strlen(t)-1; while ((ix>0) && isspace(t[ix])) t[ix--] = 0; // remove trailing spaces t1 = strchr(t0,',');t1[0]=0;t1++; t2 = strchr(t1,',');t2[0]=0;t2++; t3 = strchr(t2,',');t3[0]=0;t3++; n = atoi(t); // n==0 if label is provided, n>0 if channel number is provided /* does not work because ambiguous labels are used in rawhead and cal_res (e.g. T3 and T7) if (!n) for (n=0; nNS; n++) { if (!strcmp(hdr->CHANNEL[n].Label,t)) { n++; break; } } */ if (VERBOSE_LEVEL>7) fprintf(stdout,"cal_res: %i %i <%s> %s %s %s\n",k,n,t,t1,t2,t3); CHANNEL_TYPE *hc = hdr->CHANNEL + (n>0 ? n-1 : k); // channel can be denoted by label or number hc->Cal = atof(t1); hc->Off = 0; if (VERBOSE_LEVEL>7) fprintf(stdout," <%s> %s = ###, %f, %f\n", t1,hc->Label,hc->Cal,hc->Off); hc->PhysMax = (hc->DigMax - hc->Off) * hc->Cal; hc->PhysMin = (hc->DigMin - hc->Off) * hc->Cal; hc->XYZ[0]=0; hc->XYZ[1]=0; hc->XYZ[2]=0; } } f2 = "r_info"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore fid = fopen(fn,"r"); if (fid!=NULL) { if (VERBOSE_LEVEL>7) fprintf(stdout,"r_info: \n"); count = fread(buf,1,bufsiz-1,fid); fclose(fid); buf[count]=0; // terminating 0 character struct tm T; t = strtok(buf,"\xA\xD"); t = strtok(NULL,"\xA\xD"); // skip line 1 while (t!=NULL) { char *t1 = strchr(t,'='); t1[0] = 0; while (isspace((++t1)[0])); for (k=strlen(t); (k>0) && isspace(t[--k]); t[k]=0); for (k=strlen(t1); (k>0) && isspace(t1[--k]); t1[k]=0); if (VERBOSE_LEVEL>7) fprintf(stdout,"r_info: %s = %s\n",t,t1); if (0) {} else if (!strcmp(t,"RecId")) strncpy(hdr->ID.Recording,t1,MAX_LENGTH_RID); else if (!strcmp(t,"RecDate")) { sscanf(t1,"%02d.%02d.%04d",&T.tm_mday,&T.tm_mon,&T.tm_year); T.tm_year -=1900; T.tm_mon -=1; } else if (!strcmp(t,"RecTime")) sscanf(t1,"%02d.%02d.%02d",&T.tm_hour,&T.tm_min,&T.tm_sec); else if (!strcmp(t,"TechSal")) { if (hdr->ID.Technician) free(hdr->ID.Technician); hdr->ID.Technician = strdup(t1); } else if (!strcmp(t,"TechTitle") || !strcmp(t,"TechLast") || !strcmp(t,"TechFirst")) { size_t l0 = strlen(hdr->ID.Technician); size_t l1 = strlen(t1); hdr->ID.Technician = (char*)realloc(hdr->ID.Technician,l0+l1+2); hdr->ID.Technician[l0] = ' '; strcpy(hdr->ID.Technician+l0+1, t1); // Flawfinder: ignore } t = strtok(NULL,"\xA\xD"); } hdr->T0 = tm_time2gdf_time(&T); } f2 = "marker"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore fid = fopen(fn,"r"); if (fid != NULL) { size_t n,N; N=0; n=0; while (!feof(fid)) { hdr->AS.auxBUF = (uint8_t*) realloc(hdr->AS.auxBUF,N+bufsiz+1); N += fread(hdr->AS.auxBUF+N, 1, bufsiz, fid); } fclose(fid); hdr->AS.auxBUF[N] = 0; // terminating 0 character N = 0; t = (char*)hdr->AS.auxBUF+strcspn((char*)hdr->AS.auxBUF,"\xA\xD"); t = t+strspn(t,"\xA\xD"); // skip lines 1 and 2 while (t[0]) { char* t1 = t; size_t l1 = strcspn(t1,"="); size_t p2 = strspn(t1+l1,"= ")+l1; char* t2 = t+p2; size_t l2 = strcspn(t2," ,"); size_t p3 = strspn(t2+l2," ,")+l2; char* t3 = t2+p3; size_t l3 = strcspn(t3," ,"); size_t p4 = strspn(t3+l3," ,")+l3; char* t4 = t3+p4; size_t l4 = strcspn(t4,"\xA\xD"); size_t p5 = strspn(t4+l4,"\xA\xD")+l4; t1[l1] = 0; while (isspace(t1[--l1])) t1[l1]=0; t2[l2] = 0; t3[l3] = 0; t4[l4] = 0; t = t4 + p5; if (n+1 >= N) { const size_t sz = 100; hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,(N+sz)*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,(N+sz)*sizeof(*hdr->EVENT.POS)); N += sz; } hdr->EVENT.POS[n] = atol(t3); if (!strcmp(t1,"REC")) hdr->EVENT.TYP[n] = 0x7ffe; else if (!strcmp(t1,"MON")) hdr->EVENT.TYP[n] = 0; else if (!strcmp(t1,"TXT")) FreeTextEvent(hdr, n, t4); else FreeTextEvent(hdr, n, t1); if (!strcmp(t2,"off")) hdr->EVENT.TYP[n] |= 0x8000; //fprintf(stdout,"#%u, 0x%04x,%u | t1=<%s> = t2=<%s>, t3=<%s>, t4=<%s>\n",n,hdr->EVENT.TYP[n],hdr->EVENT.POS[n],t1,t2,t3,t4); n++; // t = strtok(NULL,"\xA\xD"); //fprintf(stdout," <%s>\n",t1); } hdr->EVENT.N = n; hdr->EVENT.SampleRate = hdr->SampleRate; // convert2to4_eventtable(hdr); } tmpstr = strrchr(fn,FILESEP); tmpstr[0] = 0; tmpstr = strrchr(fn,FILESEP); f2 = "s_info"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore fid = fopen(fn,"r"); if (fid!=NULL) { count = fread(buf,1,bufsiz-1,fid); fclose(fid); buf[count]=0; // terminating 0 character char *Lastname = NULL; char *Firstname = NULL; struct tm T; t = strtok(buf,"\xA\xD"); t = strtok(NULL,"\xA\xD"); // skip line 1 while (t!=NULL) { char *t1 = strchr(t,'='); t1[0] = 0; while (isspace((++t1)[0])); for (k=strlen(t); (k>0) && isspace(t[--k]); t[k]=0); for (k=strlen(t1); (k>0) && isspace(t1[--k]); t1[k]=0); if (VERBOSE_LEVEL>7) fprintf(stdout,"s_info: <%s> = <%s>\n",t,t1); if (0) {} else if (!strcmp(t,"SubjId")) strncpy(hdr->Patient.Id,t1,MAX_LENGTH_PID); else if (!strcmp(t,"Gender")) switch (t1[0]) { case 'm': case 'M': hdr->Patient.Sex = 1; break; case 'w': case 'W': case 'f': case 'F': hdr->Patient.Sex = 2; break; default: hdr->Patient.Sex = 0; break; } else if (!strcmp(t,"Handedness")) switch (t1[0]) { case 'r': case 'R': hdr->Patient.Handedness = 1; break; case 'l': case 'L': hdr->Patient.Handedness = 2; break; default: hdr->Patient.Handedness = 0; break; } else if (!strcmp(t,"Size")) hdr->Patient.Height = atof(t1); else if (!strcmp(t,"Weight")) hdr->Patient.Weight = atof(t1); else if (!strcmp(t,"FirstName")) { Firstname = t1; } else if (!strcmp(t,"LastName")) { Lastname = t1; } else if (!strcmp(t,"BirthDay")) { int c = sscanf(t1,"%02d.%02d.%04d",&T.tm_mday,&T.tm_mon,&T.tm_year); T.tm_year -=1900; T.tm_mon -=1; T.tm_hour =12; T.tm_min =0; T.tm_sec =0; if (c > 2) hdr->Patient.Birthday = tm_time2gdf_time(&T); } t = strtok(NULL,"\xA\xD"); } size_t l0 = strlen(Firstname); size_t l1 = strlen(Lastname); if (l0+l1+1 <= MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name, Firstname); // Flawfinder: ignore hdr->Patient.Name[l0] = ' '; strcpy(hdr->Patient.Name + l0 + 1, Lastname); // Flawfinder: ignore } else strncpy(hdr->Patient.Name, Lastname, MAX_LENGTH_NAME+1); // Flawfinder: ignore } strcpy(fn,hdr->FileName); // Flawfinder: ignore tmpstr = strrchr(fn,FILESEP); f2 = "rawdata"; if (tmpstr) strcpy(tmpstr+1,f2); // Flawfinder: ignore else strcpy(fn,f2); // Flawfinder: ignore if (VERBOSE_LEVEL>7) fprintf(stdout,"rawdata11: %s \n",f2); hdr->FileName = fn; ifopen(hdr,"r"); if (VERBOSE_LEVEL>7) fprintf(stdout,"rawdata22: %s open=%i\n",f2,hdr->FILE.OPEN); if (hdr->FILE.OPEN) { int16_t a[3]; ifread(a, 2, 3, hdr); hdr->VERSION = a[0]; hdr->HeadLen = 6; switch (a[2]) { case 12: gdftyp = 255+12; break; case 16: gdftyp = 3; break; case 32: gdftyp = 5; break; } for (k=a[1]; kNS; k++) hdr->CHANNEL[k].OnOff = 0; for (k=0; kNS; k++) { hdr->CHANNEL[k].GDFTYP = gdftyp; } hdr->AS.bpb = (GDFTYP_BITS[gdftyp]*a[1])>>3; hdr->FILE.POS = 0; size_t len = (GDFTYP_BITS[gdftyp]*a[1]*hdr->NRec*hdr->SPR)>>3; if ((GDFTYP_BITS[gdftyp]*a[1]) & 0x07) { /* hack: if SPR*NS*bits are not a multiple of bytes, hdr->AS.bpb would be non-integer causing some problems in SREAD reading the correct number of bytes. This hack makes sure that all data is loaded. */ len++; } hdr->AS.rawdata = (uint8_t*) realloc(hdr->AS.rawdata, len); size_t count = ifread(hdr->AS.rawdata,1,len,hdr); hdr->AS.first = 0; hdr->AS.length = (count<<3)/(GDFTYP_BITS[gdftyp]*a[1]); } if (VERBOSE_LEVEL>7) fprintf(stdout,"rawdata55: %s c=%i [%i, %i] sizeof(CHAN)=%i\n",fn,(int)count,(int)hdr->AS.first,(int)hdr->AS.length,(int)sizeof(hdr->CHANNEL[0])); free(fn); hdr->FileName = FileName; } biosig-2.3.3/biosig4c++/t210/sopen_famos_read.c0000664000175000017500000003455614105434233021162 0ustar schloeglschloegl/* $Id$ Copyright (C) 2008,2009,2012 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include "../biosig-dev.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) /* FIXME: The switch __4HAERTEL__ is for some specific FAMOS file not supported yet by the default code. currently, it is not clear (at least to me) how support for such a file should be incorporated it the standard solution. #define __4HAERTEL__ */ EXTERN_C void sopen_FAMOS_read(HDRTYPE* hdr) { #define Header1 ((char*)hdr->AS.Header) size_t count = hdr->HeadLen; char *t, *t2; const char EOL[] = "|;\xA\xD"; size_t pos, l1, len; pos = strspn(Header1, EOL); uint16_t gdftyp, CHAN=0; char OnOff=1; double Fs = NAN; uint32_t NoChanCurrentGroup = 0; // number of (undefined) channels of current group int level = 0; // to check consistency of file char flag_AbstandFile = 0; // interleaved format ??? used for experimental code fprintf(stdout,"SOPEN(FAMOS): support is experimental. Only time series with equidistant sampling and single sampling rate are supported.\n"); while (pos < count-20) { t = Header1+pos; // start of line l1 = strcspn(t+5, ","); t[l1+5] = 0; len = atol(t+5); pos += 6+l1; t2 = Header1+pos; // start of line if (count < max(pos,hdr->HeadLen)+256) { size_t bufsiz = 4095; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, count+bufsiz+1); count += ifread(hdr->AS.Header+count,1,bufsiz,hdr); } pos += len+1; if (VERBOSE_LEVEL>7) fprintf(stdout,"FAMOS %i <%s>: %i,%i OnOff=%i\n",(int)pos,t,(int)l1,(int)len,OnOff); if (!strncmp(t,"CF,2",4) && (level==0)) { level = 1; } else if (!strncmp(t,"CK,1",4) && (level==1)) { level = 2; } else if (!strncmp(t,"NO,1",4) && ((level==1) || (level==2))) { int p; // Ursprung p = strcspn(t2,","); t2[p] = 0; // NameLang t2 += p+1; p = strcspn(t2,","); t2[p] = 0; size_t len = min(MAX_LENGTH_MANUF,atol(t2)); // Name t2 += p+1; strncpy(hdr->ID.Manufacturer._field,t2,len); hdr->ID.Manufacturer._field[len]=0; hdr->ID.Manufacturer.Name =hdr->ID.Manufacturer._field; } else if (!strncmp(t,"CT,1",4) && (level>1)) { } else if (!strncmp(t,"Cb,1",4)) // Buffer Beschreibung { // AnzahlBufferInKey int p = strcspn(t2,","); t2[p] = 0; if (atoi(t2) != 1) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "FAMOS: more than one buffer not supported"); } // BytesInUserInfo t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // Buffer Referenz t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // IndexSamplesKey t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // OffsetBufferInSamplesKey t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; hdr->CHANNEL[CHAN].bi = atol(t2); // BufferLangBytes t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // OffsetFirstSampleInBuffer, t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // BufferFilledBytes, t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; size_t bpb = atol(t2); if (VERBOSE_LEVEL>7) fprintf(stdout,"146 famos: <%s>%d %d %d %d %d [%d] %d\n",t2,(int)bpb,CHAN,(int)bpb,hdr->NS,(int)(hdr->SPR*hdr->NRec),hdr->CHANNEL[CHAN].GDFTYP,GDFTYP_BITS[hdr->CHANNEL[CHAN].GDFTYP]); /* This command causes "Caught MathWorks::System::FatalException" on mexw32 when compiled mingw-cross-env /scratch/schloegl/src/mingw-cross-env/usr/bin/i686-pc-mingw32-gcc v4.6.1 with Optimization -O1 or -O2 Turning optimization off solves the problem */ hdr->CHANNEL[CHAN].SPR = 8*bpb/GDFTYP_BITS[hdr->CHANNEL[CHAN].GDFTYP]; if (VERBOSE_LEVEL) fprintf(stdout,"famos123: %i %i %i\n", OnOff, CHAN, hdr->CHANNEL[CHAN].SPR); if ((OnOff) && (CHAN==0)) hdr->SPR = hdr->CHANNEL[CHAN].SPR; if (hdr->SPR != hdr->CHANNEL[CHAN].SPR) { fprintf(stdout,"Warning SOPEN(FAMOS): multiple sampling (%i:%i) rates not supported. Channel %i ignored!\n", hdr->SPR, hdr->CHANNEL[CHAN].SPR, CHAN+1); OnOff = 0; } if (!OnOff) hdr->CHANNEL[CHAN].SPR = 0; hdr->AS.bpb = hdr->CHANNEL[CHAN].bi + bpb; // 0, t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // X0, t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // AddZeit, t2 += 1+p; p = strcspn(t2,","); t2[p] = 0; // UserInfo t2 += 1+p; p = strcspn(t2,EOL); } else if (!strncmp(t,"CB,1",4) && (level>1)) { // Gruppen Definition // Index der Gruppe int p = strcspn(t2,","); t2[p] = 0; if (atol(t2)>1) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "FAMOS: more than one group not supported"); } level = 2; } else if (!strncmp(t,"CI,1",4)) { } else if (!strncmp(t,"CG,1",4)) // Definition eines Datenfeldes { int p; // Anzahl Komponenten p = strcspn(t2,","); t2[p] = 0; NoChanCurrentGroup = atol(t2); // additional channels hdr->NS += NoChanCurrentGroup; // Feldtyp p = strcspn(t2,","); t2[p] = 0; OnOff = 1; if (atoi(t2) != 1) { // OnOff = 0; // biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: data is not real and aquidistant sampled"); } // Dimension p = strcspn(t2,","); t2[p] = 0; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); level = 3; } else if (!strncmp(t,"CD,",3) && (level>=3)) { int p; // dx p = strcspn(t2,","); t2[p] = 0; Fs = 1.0/atof(t2); // kalibriert t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // EinheitLang t2 += p+1; p = strcspn(t2,","); t2[p] = 0; //size_t len = max(atol(t2),MAX_LENGTH_PHYSDIM); // Einheit t2 += p+1; if (strncmp(t,"s",strlen(t))) { // turn off channel if unit of x-axis is not seconds [s] // OnOff = 0; } //PhysDimCode(t2); } else if (!strncmp(t,"NT,1",4) && (level>=3)) { struct tm tm_time; int p = strcspn(t2,","); t2[p] = 0; tm_time.tm_mday = atoi(t2); t2 += p+1; p = strcspn(t2,","); t2[p] = 0; tm_time.tm_mon = atoi(t2)-1; t2 += p+1; p = strcspn(t2,","); t2[p] = 0; tm_time.tm_year = atoi(t2)-1900; t2 += p+1; p = strcspn(t2,","); t2[p] = 0; tm_time.tm_hour = atoi(t2); t2 += p+1; p = strcspn(t2,","); t2[p] = 0; tm_time.tm_min = atoi(t2); p = strcspn(t2,EOL); // t2[p] = 0; char tmp[10]; strncpy(tmp,t2,p); tmp[p]=0; tm_time.tm_sec = atoi(tmp); hdr->T0 = tm_time2gdf_time(&tm_time); } else if (!strncmp(t,"CZ,1",4) && (level==3)) { } else if (!strncmp(t,"CC,1",4) && (level>=3)) { if (NoChanCurrentGroup<1) { biosigERROR(hdr, B4C_UNSPECIFIC_ERROR, "FAMOS: too many CC definitions in group"); } CHAN = hdr->NS - NoChanCurrentGroup--; if (CHAN==0) hdr->SampleRate = Fs; else if (OnOff && (fabs(hdr->SampleRate - Fs)>1e-9*Fs)) { fprintf(stdout,"ERR2: %i %f %f\n",CHAN,hdr->SampleRate, Fs); // biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: multiple sampling rates not supported"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"CC: %i#%i Fs=%f,%i\n",OnOff,CHAN,Fs,(int)len); /* int p = strcspn(t2,","); t2[p] = 0; Fs = 1.0/atof(t2); */ level = 4; } else if (!strncmp(t,"CP,1",4) && (level==4)) { int p; char s[21]; strncpy(s,t2,20);s[20]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"CHAN=%i tag=<%s>\n",CHAN,s); // Bufferreferenz p = strcspn(t2,","); t2[p] = 0; // Bytes t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // Zahlenformat t2 += p+1; p = strcspn(t2,","); t2[p] = 0; gdftyp = atoi(t2); if (VERBOSE_LEVEL>7) fprintf(stdout,"CHAN=%i tag=<%s> gdf=%i\n",CHAN,s,gdftyp); // SignBits t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // Mask t2 += p+1; p = strcspn(t2,","); t2[p] = 0; if (atoi(t2)) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: Mask != 0 not supported"); }; // Offset t2 += p+1; p = strcspn(t2,","); t2[p] = 0; if (atoi(t2)) { fprintf(stdout,"Offset:<%s>\n",t2); flag_AbstandFile = 1; #ifndef __4HAERTEL__ biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: Offset != 0 not supported"); #endif }; // DirekteFolgeAnzahl t2 += p+1; p = strcspn(t2,","); t2[p] = 0; if (atoi(t2) != 1) { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: DirekteFolgeAnzahl != 1 not supported"); }; // AbstandBytes t2 += p+1; p = strcspn(t2,EOL); t2[p] = 0; if (atoi(t2)) { fprintf(stdout,"Abstandbytes:<%s>\n",t2); flag_AbstandFile = 1; #ifndef __4HAERTEL__ biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: AbstandBytes != 0 not supported"); #endif }; double digmax=1e6,digmin=-1e6; switch (gdftyp) { case 1: gdftyp = 2; // uint8 digmax = 255; digmin = 0; break; case 2: gdftyp = 1; // int8 digmax = 127; digmin = -128; break; case 3: case 9: case 11: gdftyp = 4; // uint16 digmax = 65535; digmin = 0; break; case 4: gdftyp = 3; // int16 digmax = 32767; digmin = -32768; break; case 5: gdftyp = 6; // uint32 digmax = (uint32_t)0xffffffff; digmin = 0; break; case 6: gdftyp = 5; // int32 digmax = (int32_t)0x7fffffff; digmin = (int32_t)0x80000000; break; case 7: gdftyp = 16; // float32 break; case 8: gdftyp = 17; // float64 break; case 10: gdftyp = 0; break; case 13: gdftyp = 511+48; // float64 break; default: gdftyp = 0; biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "FAMOS: unknown datatype"); }; hdr->CHANNEL[CHAN].LeadIdCode = 0; hdr->CHANNEL[CHAN].OnOff = OnOff; hdr->CHANNEL[CHAN].GDFTYP = gdftyp; hdr->CHANNEL[CHAN].DigMax = digmax; hdr->CHANNEL[CHAN].DigMin = digmin; hdr->CHANNEL[CHAN].PhysMax = digmax; hdr->CHANNEL[CHAN].PhysMin = digmin; // initialize undefined values hdr->CHANNEL[CHAN].LowPass = -1.0; hdr->CHANNEL[CHAN].HighPass= -1.0; hdr->CHANNEL[CHAN].Notch = -1.0; hdr->CHANNEL[CHAN].Label[0] = 0; hdr->CHANNEL[CHAN].Transducer[0]=0; hdr->CHANNEL[CHAN].PhysDimCode = 0; hdr->CHANNEL[CHAN].SPR = 1; // one sample per block hdr->CHANNEL[CHAN].Impedance = INFINITY; hdr->CHANNEL[CHAN].XYZ[0] = 0.0; hdr->CHANNEL[CHAN].XYZ[1] = 0.0; hdr->CHANNEL[CHAN].XYZ[2] = 0.0; if (VERBOSE_LEVEL>7) fprintf(stdout,"#%i\t%i %i\n",CHAN,gdftyp, hdr->CHANNEL[CHAN].GDFTYP); } else if (!strncmp(t,"CR,1",4)) { int p; t2[len] = 0; // Transformieren p = strcspn(t2,","); t2[p] = 0; int flagTransform = atoi(t2); // Faktor t2 += p+1; p = strcspn(t2,","); t2[p] = 0; hdr->CHANNEL[CHAN].Cal = flagTransform ? atof(t2) : 1.0; // Offset t2 += p+1; p = strcspn(t2,","); t2[p] = 0; hdr->CHANNEL[CHAN].Off = flagTransform ? atof(t2) : 0.0; hdr->CHANNEL[CHAN].PhysMax = hdr->CHANNEL[CHAN].DigMax * hdr->CHANNEL[CHAN].Cal + hdr->CHANNEL[CHAN].Off; hdr->CHANNEL[CHAN].PhysMin = hdr->CHANNEL[CHAN].DigMin * hdr->CHANNEL[CHAN].Cal + hdr->CHANNEL[CHAN].Off; // Kalibriert t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // EinheitLang t2 += p+1; p = strcspn(t2,","); t2[p] = 0; //int len = min(atoi(t2),MAX_LENGTH_PHYSDIM); // Einheit t2 += p+1; hdr->CHANNEL[CHAN].PhysDimCode = PhysDimCode(t2); } else if (!strncmp(t,"ND,1",4) && (level==4)) { // Display properties } else if (!strncmp(t,"CN,1",4) && (level==4)) { int p; // Indexgruppe p = strcspn(t2,","); t2[p] = 0; // 0 t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // IndexBit t2 += p+1; p = strcspn(t2,","); t2[p] = 0; // NameLang t2 += p+1; p = strcspn(t2,","); t2[p] = 0; int len = atoi(t2); // Name t2 += p+1; len = min(len,MAX_LENGTH_LABEL); strncpy(hdr->CHANNEL[CHAN].Label, t2, len); hdr->CHANNEL[CHAN].Label[len] = 0; // KommLang t2 += len+1; p = strcspn(t2,","); t2[p] = 0; // Kommentar t2 += p+1; p = strcspn(t2,","); } else if (!strncmp(t,"CS,1",4)) { int p = strcspn(t2,","); t2[p] = 0; if (atol(t2)>1) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "FAMOS: more than one CS section not supported"); } hdr->HeadLen = pos-len+p; if (VERBOSE_LEVEL>8) fprintf(stdout,"FAMOS: CS section reached\n"); break; } pos += strcspn(Header1+pos,EOL); pos += strspn(Header1+pos,EOL); } ifseek(hdr,hdr->HeadLen,SEEK_SET); hdr->NRec = 1; #ifdef __4HAERTEL__ if (flag_AbstandFile==1) { size_t bpb = 0; uint16_t k; for (k=0; kNS; k++) { if (hdr->CHANNEL[k].SPR>=1) hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[k].SPR); hdr->CHANNEL[k].SPR = 1; hdr->CHANNEL[k].bi = bpb; bpb += GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP]>>3; } hdr->NRec *= hdr->SPR; hdr->SPR = 1; hdr->AS.bpb = bpb; // This part is necessary for broken files (if header information does not fit file size) struct stat FileBuf; stat(hdr->FileName,&FileBuf); nrec_t tmp = (FileBuf.st_size - hdr->HeadLen)/bpb; if (tmp < 0) hdr->NRec = -1; else if (tmp < hdr->NRec) hdr->NRec = tmp; } #endif }; // End of SOPEN_FAMOS_READ biosig-2.3.3/biosig4c++/t210/codes.h0000664000175000017500000003364514105434233016756 0ustar schloeglschloegl/* --------------------------------------------------------------------------- Copyright (C) 2003 Eugenio Cervesato & Giorgio De Odorico. Developed at the Associazione per la Ricerca in Cardiologia - Pordenone - Italy. 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- */ // codes.h consts included in the protocol #ifndef __CODES_H__ #define __CODES_H__ static const char STR_END[]={(char)-1,'\0'}; static char STR_NULL[]=" unspecified/unknown "; static alfabetic _special[]={ { 29999 , "measurements not computed" }, { 29998 , "measurements not found due to rejection of the lead" }, { 19999 , "measurements not found because wave not present" }, { 999 , "undefined" } }; static alfabetic _age[]={ { 0 , " unspecified/unknown " } , { 1 , " years " } , { 2 , " months " } , { 3 , " weeks " } , { 4 , " days " } , { 5 , " hours " } }; static alfabetic _height[]={ { 0 , " unspecified/unknown " } , { 1 , " cm " } , { 2 , " inch " } , { 3 , " mm " } }; static alfabetic _weight[]={ { 0 , " unspecified/unknown " } , { 1 , " Kg " } , { 2 , " g " } , { 3 , " lb " } , { 4 , " oz " } }; static alfabetic _sex[]={ { 0 , " ? " } , { 1 , " M " } , { 2 , " F " } , { 3 , " unspecified/unknown " } }; static alfabetic _race[]={ { 0 , " unspecified/unknown " } , { 1 , " caucasian " } , { 2 , " black " } , { 3 , " oriental " } }; static alfabetic class_drug[]={ { 0 , " unspecified/unknown " } , { 1 , " digitalis preparation " } , { 2 , " antiarrhythmic " } , { 3 , " diuretics " } , { 4 , " antihypertensive " } , { 5 , " antianginal " } , { 6 , " antithrombotic agents " } , { 7 , " beta blockers " } , { 8 , " psychotropic " } , { 9 , " calcium blockers " } , { 10 , " antihypotensive " } , { 11 , " anticholesterol " } , { 12 , " ACE-inhibitors " } , { 100 , " not taking drugs " } , { 101 , " drugs, but unknown type " } , { 102 , " other medication " }, { 256 , " unspecified/unknown " } , { 257 , " digoxin-lanoxin " } , { 258 , " digitoxin-digitalis " } , { 265 , " other " }, { 512 , " unspecified/unknown " } , { 513 , " dysopyramide " } , { 514 , " quinidine " } , { 515 , " procainamide " } , { 516 , " lidocaine " } , { 517 , " phenytoin " } , { 518 , " dilantin " } , { 519 , " amiodarone " } , { 520 , " tocainide " } , { 521 , " other " } , { 522 , " encainide " } , { 523 , " mexitil/mexilitine " } , { 524 , " flecainide " } , { 525 , " lorcainide " } , { 768 , " unspecified/unknown " } , { 769 , " thiazide " } , { 770 , " furosemide (lasix) " } , { 771 , " potassium cloride " } , { 777 , " other " } , { 1024 , " unspecified/unknown " } , { 1025 , " clonidine " } , { 1026 , " prasozin " } , { 1027 , " hydralazine " } , { 1033 , " other " }, { 1280 , " unspecified/unknown " } , { 1281 , " isosorbide " } , { 1282 , " calcium blockers " } , { 1283 , " diuretics " } , { 1284 , " nitrates " } , { 1289 , " other " }, { 1536 , " unspecified/unknown " } , { 1537 , " aspirin " } , { 1538 , " coumarin " } , { 1539 , " heparin " } , { 1540 , " warfarin " } , { 1541 , " streptokinase " } , { 1542 , " t-PA " } , { 1545 , " other " }, { 1792 , " unspecified/unknown " } , { 1793 , " propanolol " } , { 1794 , " corgard " } , { 1795 , " atenolol " } , { 1796 , " metoprolol " } , { 1797 , " pindolol " } , { 1798 , " acebutolol " } , { 1801 , " other " }, { 2048 , " unspecified/unknown " } , { 2049 , " tricyclic antidepressant " } , { 2050 , " phenothiazide " } , { 2051 , " barbiturate " } , { 2057 , " other " }, { 2304 , " unspecified/unknown " } , { 2305 , " nifedipine " } , { 2306 , " verapamil " } , { 2313 , " other " }, { 2560 , " unspecified/unknown " } , { 2561 , " asthmatic drug " } , { 2562 , " aminophyline " } , { 2563 , " isuprel " } , { 2569 , " other " }, { 2816 , " unspecified/unknown " } , { 2817 , " colestid " } , { 2818 , " lovastatin " } , { 2819 , " simvastatin " } , { 2820 , " fibrates " } , { 2825 , " other " }, { 3071 , " unspecified/unknown " } , { 3072 , " captopril " } , { 3081 , " other " } }; static alfabetic device_type[]={ { 0 , " Cart " }, { 1 , " host " }, { 2 , " unspecified/unknown "} }; static alfabetic legacy_device[]={ { 0 , " unspecified/unknown " } , { 1 , " Burdick " } , { 2 , " Cambridge " } , { 3 , " Comprumed " } , { 4 , " Datamed " } , { 5 , " Fukuda " } , { 6 , " Hewlett-Packard " } , { 7 , " Marquette Electronics " } , { 8 , " Moratara Instruments " } , { 9 , " Nihon Kohden " } , { 10 , " Okin " } , { 11 , " Quinton " } , { 12 , " Siemens " } , { 13 , " Spacelabs " } , { 14 , " Telemed " } , { 15 , " Hellige " } , { 16 , " ESA-OTE " } , { 17 , " Schiller " } , { 18 , " Picker-Schwarzer " } , { 19 , " Elettronica-Trentina " } , { 20 , " Zwonitz " } }; static alfabetic compatibility[]={ { 72 , " I " } , { 160 , " II " } , { 176 , " III " } , { 192 , " IV " }, { 255 , " unspecified/unknown " } }; static alfabetic language_code[]={ { 0 , " 8 bit ASCII only " } , { 1 , " ISO-8859-1 latin-1 " } , { 192 , " ISO-8859-2 latin-2 (central and estern european) " } , { 208 , " ISO-8859-4 latin-4 (Baltic) " } , { 200 , " ISO-8859-5 (Cyrillic) " } , { 216 , " ISO-8859-6 (Arabic) " } , { 196 , " ISO-8859-7 (Greek) " } , { 212 , " ISO-8859-8 (Hebrew) " } , { 204 , " ISO-8859-11 (Thai) " } , { 220 , " ISO-8859-15 latin-9 (latin-0) " } , { 224 , " Unicode (ISO-60646) " } , { 240 , " JIS X0201-1976 (Japanese) " } , { 232 , " JIS X0208-1977 (Japanese) " } , { 248 , " JIS X0212-1990 (Japanese) " } , { 228 , " GB 2312-80 (Chinese) " } , { 244 , " KS C5601-1987 (Korean) " } , { 255 , " unspecified/unknown " } }; static alfabetic capability_device[]={ { 1 , " No printing " } , { 2 , " No analysis " } , { 3 , " No storage " } , { 4 , " No acquisition " } , { 5 , " can print ECG reports " } , { 6 , " can interpret ECG " } , { 7 , " can store ECG records " } , { 8 , " can acquire ECG data " } }; static alfabetic frequency_AC[]={ { 0 , " unspecified/unknown " } , { 1 , " 50 Hz " } , { 2 , " 60 Hz " } }; static alfabetic filter_bitmap[]={ { 0 , " unspecified/unknown " }, { 1 , " 60 Hz notch filter " } , { 2 , " 50 Hz notch filter " } , { 3 , " artifact filter " } , { 4 , " baseline filter " } }; static alfabetic _hystory[]={ { 0 , " diagnoses or clinical problems " } , { 1 , " apparently healty " } , { 10 , " acute myocardial infarction " } , { 11 , " myocardial infarction " } , { 12 , " previous myocardial infarction " } , { 15 , " ischemic heart disease " } , { 18 , " peripheral vascular disease " } , { 20 , " cyanotic congenital heart disease " } , { 21 , " acyanotic congenital heart disease " } , { 22 , " valvular heart disease " } , { 25 , " hypertension " } , { 27 , " cerebrovascular accident " } , { 30 , " cardiomyopathy " } , { 35 , " pericardits " } , { 36 , " myocardits " } , { 40 , " post-operative cardiac surgery " } , { 42 , " implanted cardiac pacemaker " } , { 45 , " pulmonary embolism " } , { 50 , " respiratory disease " } , { 55 , " endocrine disease " } , { 60 , " neurological disease " } , { 65 , " alimentary disease " } , { 70 , " renal disease " } , { 80 , " pre-operative general surgery " } , { 81 , " post-operative general surgery " } , { 90 , " general medical " } , { 100 , " unspecified/unknown " } }; static alfabetic electrode_configuration_standard[]={ { 0 , " unspecified/unknown " } , { 1 , " 12-lead positions: RA, RL, LA, and LL at limb extremities. V1 to V6 at standard positions on the chest. Individually " } , { 2 , " RA, RL, LA, and LL are placed on the torso. V1 to V6 are placed at standard positions on the chest. Individually " } , { 3 , " RA, RL, LA, and LL are individually placed on the torso. V1 to V6 on the chest as part of a single electrode pad " } , { 4 , " RA, RL, LA, LL, and V1 to V6 (all electrodes) are on the chest in a single electrode pad " } , { 5 , " 12-lead ECG is derived from Frank XYZ leads " } , { 6 , " 12-lead ECG is derived from non-standard leads " } }; static alfabetic electrode_configuration_XYZ[]={ { 0 , " unspecified/unknown " } , { 1 , " Frank " } , { 2 , " McFee-Parungao " } , { 3 , " Cube " } , { 4 , " XYZ bipolar uncorrected " } , { 5 , " pseudo-orthogonal XYZ (as used in Holter) " } , { 6 , " XYZ derived from standard 12 leads " } }; static alfabetic lead_identification[]={ { 0 , " unspecified/unknown " } , { 1 , " I " } , { 2 , " II " } , { 3 , " V1 " } , { 4 , " V2 " } , { 5 , " V3 " } , { 6 , " V4 " } , { 7 , " V5 " } , { 8 , " V6 " } , { 9 , " V7 " } , { 10 , " V2R " } , { 11 , " V3R " } , { 12 , " V4R " } , { 13 , " V5R " } , { 14 , " V6R " } , { 15 , " V7R " } , { 16 , " X " } , { 17 , " Y " } , { 18 , " Z " } , { 19 , " CC5 " } , { 20 , " CM5 " } , { 21 , " left arm " } , { 22 , " right arm " } , { 23 , " left leg " } , { 24 , " I " } , { 25 , " R " } , { 26 , " C " } , { 27 , " A " } , { 28 , " M " } , { 29 , " F " } , { 30 , " H " } , { 31 , " I-cal " } , { 32 , " II-cal " } , { 33 , " V1-cal " } , { 34 , " V2-cal " } , { 35 , " V3-cal " } , { 36 , " V4-cal " } , { 37 , " V5-cal " } , { 38 , " V6-cal " } , { 39 , " V7-cal " } , { 40 , " V2R-cal " } , { 41 , " V3R-cal " } , { 42 , " V4R-cal " } , { 43 , " V5R-cal " } , { 44 , " V6R-cal " } , { 45 , " V7R-cal " } , { 46 , " X-cal " } , { 47 , " Y-cal " } , { 48 , " Z-cal " } , { 49 , " CC5-cal " } , { 50 , " CM5-cal " } , { 51 , " left arm-cal " } , { 52 , " right arm-cal " } , { 53 , " left leg-cal " } , { 54 , " I-cal " } , { 55 , " R-cal " } , { 56 , " C-cal " } , { 57 , " A-cal " } , { 58 , " M-cal " } , { 59 , " F-cal " } , { 60 , " H-cal " } , { 61 , " III " } , { 62 , " aVR " } , { 63 , " aVL " } , { 64 , " aVF " } , { 65 , " -aVR " } , { 66 , " V8 " } , { 67 , " V9 " } , { 68 , " V8R " } , { 69 , " V9R " } , { 70 , " D (Nehb-dorsal) " } , { 71 , " A (Nehb-anterior) " } , { 72 , " J (Nehb-inferior) " } , { 73 , " defibrillator anterior-lateral " } , { 74 , " external pacing anterior-posterior " } , { 75 , " A1 (auxiliary unipolar lead 1) " } , { 76 , " A2 (auxiliary unipolar lead 2) " } , { 77 , " A3 (auxiliary unipolar lead 3) " } , { 78 , " A4 (auxiliary unipolar lead 4) " } , { 79 , " V8-cal " } , { 80 , " V9-cal " } , { 81 , " V8R-cal " } , { 82 , " V9R-cal " } , { 83 , " D-cal (Nehb-dorsal) " } , { 84 , " A-cal (Nehb-anterior) " } , { 85 , " J-cal (Nehb-inferior) " } }; static alfabetic _encode[]={ { 0 , " real " } , { 1 , " first difference " } , { 2 , " second difference " } }; static alfabetic _compression[]={ { 0 , " bimodal compression not used " } , { 1 , " bimodal compression used " } }; static alfabetic spike_type[]={ { 0 , " unspecified/unknown " } , { 1 , " spike triggers neither P-wave nor QRS " } , { 2 , " spike triggers a QRS " } , { 3 , " spike triggers a P-wave " } }; static alfabetic source_pacemaker[]={ { 0 , " unspecified/unknown " } , { 1 , " internal " } , { 2 , " external " } }; static alfabetic triggered_spike[]={ { 0 , " spike does not trigger a QRS " } , { 1 , " spike triggers a QRS " } }; static alfabetic _formula_type[]={ { 0 , " unspecified/unknown " } , { 1 , " Bazett " } , { 2 , " Hodges " } }; static alfabetic ID_tag[]={ { 0 , " QTend all-lead dispersion " } , { 1 , " QTpeak all-lead dispersion " } , { 2 , " QTend precordial dispersion " } , { 3 , " QTpeak precordial dispersion " } , { 4 , " unspecified/unknown " } }; static alfabetic value_tag[]={ { 0 , " Dispersion = maximum QT interval ? minimum QT interval " } , { 1 , " Heart rate corrected Dispersion: Max?Min " } , { 2 , " Dispersion = standard deviation of the QT intervals " } , { 3 , " Heart rate corrected Dispersion: standard deviation " } , { 4 , " Heart rate correction formula. (See definition of byte 7 for valid values) " } }; static alfabetic type_confirm[]={ { 0 , " original report (not overread) " } , { 1 , " confirmed report " } , { 2 , " overread report, but not confirmed " } , { 3 , " unspecified/unknown " } }; static alfabetic morphology_description[]={ { 0 , " unspecified/unknown " } , { 1 , " positive " } , { 2 , " negative " } , { 3 , " positive/negative " } , { 4 , " negative/positive " } , { 5 , " positive/negative/positive " } , { 6 , " negative/positive/negative " } , { 7 , " notched M-shaped " } , { 8 , " notched W-shaped " } }; static alfabetic quality_code[]={ { 0 , " AC (mains) noise " } , { 1 , " overrange " } , { 2 , " wander " } , { 3 , " tremor or muscle artifact " } , { 4 , " spike or sudden jumps " } , { 5 , " electrode loose or off " } , { 6 , " pacemaker " } , { 7 , " interchanged lead " } }; static alfabetic noise_level[]={ { 0 , " none/no " } , { 1 , " moderate/yes " } , { 2 , " severe " } , { 3 , " unknown " } }; static alfabetic type_statement[]={ { 1 , " coded statement type " } , { 2 , " full text type " } , { 3 , " statement logic type " } }; #endif /*__CODES_H__*/ biosig-2.3.3/biosig4c++/t210/abfheadr.h0000775000175000017500000017032714105434233017417 0ustar schloeglschloegl//*********************************************************************************************** // // Copyright (c) 1993-2003 Axon Instruments. // All rights reserved. // Permission is granted to freely use, modify and copy the code in this file. // //*********************************************************************************************** // HEADER: ABFHEADR.H. // PURPOSE: Defines the ABFFileHeader structure, and provides prototypes for // functions implemented in ABFHEADR.CPP for reading and writing // ABFFileHeader's. // REVISIONS: // 1.1 - Version 1.1 was released in April 1992. // 1.2 - Added nDataFormat so that data can optionally be stored in floating point format. // - Added lClockChange to control the multiplexed ADC sample number after which the second sampling interval commences. // 1.3 - Change 4-byte sFileType string to long lFileSignature. // - #define ABF_NATIVESIGNATURE & ABF_REVERSESIGNATURE for byte order detection. // - Added support for Bells during before or after acquisitions // - Added parameters to describe hysteresis during event detected acquisitions: nLevelHysteresis and lTimeHysteresis. // - Dropped support for BASIC and Pascal. // - Added the ABF Scope Config section to store scope configuration information // 1.4 - Remove support for big-endian machines. // 1.5 - Change ABFSignal parameters from UUTop & UUBottom to // fDisplayGain & fDisplayOffset. // - Added and changed parameters in the 'File Structure', 'Display Parameters', // 'DAC Output File', 'Autopeak Measurements' and 'Unused space and end of header' sections of the ABF file header. // - Expanded the ABF API and error return codes // 1.6 - Expanded header to 5120 bytes and added extra parameters to support 2 waveform channels PRC // 1.65 - Telegraph support added. // 1.67 - Train epochs, multiple channel and multiple region stats // 1.68 - ABFScopeConfig expanded // 1.69 - Added user entered percentile levels for rise and decay stats // 1.70 - Added data reduction - AjD // 1.71 - Added epoch resistance // 1.72 - Added alternating outputs // 1.73 - Added post-processing lowpass filter settings. When filtering is done in Clampfit it is stored in the header. // 1.74 - Added channel_count_acquired // 1.75 - Added polarity for each channel // 1.76 - Added digital trigger out flag // 1.77 - Added major, minor and bugfix version numbers // 1.78 - Added separate entries for alternating DAC and digital outputs // 1.79 - Removed data reduction (now minidigi only) // 1.80 - Added stats mode for each region: mode is cursor region, epoch etc // 1.81 - Added multi input signal P / N leak subtraction // 1.82 - Cyclic Redundancy Code (CRC). // 1.83 - Added Modifier application name / version number // // Added 64bit support according to Jakub Nowacki's implementation in libaxon: // http://libaxon.sourceforge.net /* modified for use with biosig Copyright (C) 2013 Alois Schlögl, This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #ifndef INC_ABFHEADR_H #define INC_ABFHEADR_H #include #include //#include "AxAbffio32.h" #ifdef __cplusplus extern "C" { #endif // // Constants used in defining the ABF file header // #define ABF_ADCCOUNT 16 // number of ADC channels supported. #define ABF_DACCOUNT 4 // number of DAC channels supported. #define ABF_WAVEFORMCOUNT 2 // number of DAC channels which support waveforms. #define ABF_EPOCHCOUNT 10 // number of waveform epochs supported. #define ABF_BELLCOUNT 2 // Number of auditory signals supported. #define ABF_ADCUNITLEN 8 // length of ADC units strings #define ABF_ADCNAMELEN 10 // length of ADC channel name strings #define ABF_DACUNITLEN 8 // length of DAC units strings #define ABF_DACNAMELEN 10 // length of DAC channel name strings #define ABF_VARPARAMLISTLEN 80 // length of conditioning string #define ABF_USERLISTLEN 256 // length of the user list (V1.6) #define ABF_USERLISTCOUNT 4 // number of independent user lists (V1.6) #define ABF_OLDFILECOMMENTLEN 56 // length of file comment string (pre V1.6) #define ABF_FILECOMMENTLEN 128 // length of file comment string (V1.6) #define ABF_CREATORINFOLEN 16 // length of file creator info string #define ABF_OLDDACFILENAMELEN 12 // old length of the DACFile name string #define ABF_OLDDACFILEPATHLEN 60 // old length of the DACFile path string #define ABF_DACFILEPATHLEN 84 // length of full path for DACFile #define ABF_PATHLEN 256 // length of full path, used for DACFile and Protocol name. #define ABF_ARITHMETICOPLEN 2 // length of the Arithmetic operator field #define ABF_ARITHMETICUNITSLEN 8 // length of arithmetic units string #define ABF_TAGCOMMENTLEN 56 // length of tag comment string #define ABF_LONGDESCRIPTIONLEN 56 // length of long description entry #define ABF_NOTENAMELEN 10 // length of the name component of a note #define ABF_NOTEVALUELEN 8 // length of the value component of a note #define ABF_NOTEUNITSLEN 8 // length of the units component of a note #define ABF_BLOCKSIZE 512 // Size of block alignment in ABF files. #define ABF_MACRONAMELEN 64 // Size of a Clampfit macro name. #define ABF_CURRENTVERSION ABF_V183 // Current file format version number #define ABF_PREVIOUSVERSION 1.5F // Previous file format version number (for old header size) #define ABF_V16 1.6F // Version number when the header size changed. #define ABF_HEADERSIZE 6144 // Size of a Version 1.6 or later header #define ABF_OLDHEADERSIZE 2048 // Size of a Version 1.5 or earlier header #define ABF_NATIVESIGNATURE 0x20464241 // PC="ABF ", MAC=" FBA" #define ABF_REVERSESIGNATURE 0x41424620 // PC=" FBA", MAC="ABF " #define PCLAMP6_MAXSWEEPLENGTH 16384 // Maximum multiplexed sweep length supported by pCLAMP6 apps. #define PCLAMP7_MAXSWEEPLEN_PERCHAN 1032258 // Maximum per channel sweep length supported by pCLAMP7 apps. #define ABF_MAX_TRIAL_SAMPLES 0x7FFFFFFF // Maximum length of acquisition supported (samples) // INT_MAX is used instead of UINT_MAX because of the signed // values in the ABF header. #define ABF_MAX_SWEEPS_PER_AVERAGE 65500 // The maximum number of sweeps that can be combined into a // cumulative average (nAverageAlgorithm=ABF_INFINITEAVERAGE). #define ABF_STATS_REGIONS 8 // The number of independent statistics regions. #define ABF_BASELINE_REGIONS 1 // The number of independent baseline regions. #ifdef _MAC #define ABF_OLDPCLAMP ABF_REVERSESIGNATURE #else #define ABF_OLDPCLAMP ABF_NATIVESIGNATURE #endif // // Constant definitions for nFileType // #define ABF_ABFFILE 1 #define ABF_FETCHEX 2 #define ABF_CLAMPEX 3 // // Constant definitions for nDataFormat // #define ABF_INTEGERDATA 0 #define ABF_FLOATDATA 1 // // Constant definitions for nOperationMode // #define ABF_VARLENEVENTS 1 #define ABF_FIXLENEVENTS 2 // (ABF_FIXLENEVENTS == ABF_LOSSFREEOSC) #define ABF_LOSSFREEOSC 2 #define ABF_GAPFREEFILE 3 #define ABF_HIGHSPEEDOSC 4 #define ABF_WAVEFORMFILE 5 // // Constant definitions for nParamToVary // #define ABF_CONDITNUMPULSES 0 #define ABF_CONDITBASELINEDURATION 1 #define ABF_CONDITBASELINELEVEL 2 #define ABF_CONDITSTEPDURATION 3 #define ABF_CONDITSTEPLEVEL 4 #define ABF_CONDITPOSTTRAINDURATION 5 #define ABF_CONDITPOSTTRAINLEVEL 6 #define ABF_EPISODESTARTTOSTART 7 #define ABF_INACTIVEHOLDING 8 #define ABF_DIGITALHOLDING 9 #define ABF_PNNUMPULSES 10 #define ABF_PARALLELVALUE 11 #define ABF_EPOCHINITLEVEL (ABF_PARALLELVALUE + ABF_EPOCHCOUNT) #define ABF_EPOCHINITDURATION (ABF_EPOCHINITLEVEL + ABF_EPOCHCOUNT) #define ABF_EPOCHTRAINPERIOD (ABF_EPOCHINITDURATION + ABF_EPOCHCOUNT) #define ABF_EPOCHTRAINPULSEWIDTH (ABF_EPOCHTRAINPERIOD + ABF_EPOCHCOUNT) // Next value is (ABF_EPOCHINITDURATION + ABF_EPOCHCOUNT) // // Constants for nAveragingMode // #define ABF_NOAVERAGING 0 #define ABF_SAVEAVERAGEONLY 1 #define ABF_AVERAGESAVEALL 2 // // Constants for nAverageAlgorithm // #define ABF_INFINITEAVERAGE 0 #define ABF_SLIDINGAVERAGE 1 // // Constants for nEpochType // #define ABF_EPOCHDISABLED 0 // disabled epoch #define ABF_EPOCHSTEPPED 1 // stepped waveform #define ABF_EPOCHRAMPED 2 // ramp waveform #define ABF_EPOCH_TYPE_RECTANGLE 3 // rectangular pulse train #define ABF_EPOCH_TYPE_TRIANGLE 4 // triangular waveform #define ABF_EPOCH_TYPE_COSINE 5 // cosinusoidal waveform #define ABF_EPOCH_TYPE_RESISTANCE 6 // resistance waveform #define ABF_EPOCH_TYPE_BIPHASIC 7 // biphasic pulse train // // Constants for epoch resistance // #define ABF_MIN_EPOCH_RESISTANCE_DURATION 8 // // Constants for nWaveformSource // #define ABF_WAVEFORMDISABLED 0 // disabled waveform #define ABF_EPOCHTABLEWAVEFORM 1 #define ABF_DACFILEWAVEFORM 2 // // Constants for nInterEpisodeLevel & nDigitalInterEpisode // #define ABF_INTEREPI_USEHOLDING 0 #define ABF_INTEREPI_USELASTEPOCH 1 // // Constants for nExperimentType // #define ABF_VOLTAGECLAMP 0 #define ABF_CURRENTCLAMP 1 #define ABF_SIMPLEACQUISITION 2 // // Constants for nAutosampleEnable // #define ABF_AUTOSAMPLEDISABLED 0 #define ABF_AUTOSAMPLEAUTOMATIC 1 #define ABF_AUTOSAMPLEMANUAL 2 // // Constants for nAutosampleInstrument // #define ABF_INST_UNKNOWN 0 // Unknown instrument (manual or user defined telegraph table). #define ABF_INST_AXOPATCH1 1 // Axopatch-1 with CV-4-1/100 #define ABF_INST_AXOPATCH1_1 2 // Axopatch-1 with CV-4-0.1/100 #define ABF_INST_AXOPATCH1B 3 // Axopatch-1B(inv.) CV-4-1/100 #define ABF_INST_AXOPATCH1B_1 4 // Axopatch-1B(inv) CV-4-0.1/100 #define ABF_INST_AXOPATCH201 5 // Axopatch 200 with CV 201 #define ABF_INST_AXOPATCH202 6 // Axopatch 200 with CV 202 #define ABF_INST_GENECLAMP 7 // GeneClamp #define ABF_INST_DAGAN3900 8 // Dagan 3900 #define ABF_INST_DAGAN3900A 9 // Dagan 3900A #define ABF_INST_DAGANCA1_1 10 // Dagan CA-1 Im=0.1 #define ABF_INST_DAGANCA1 11 // Dagan CA-1 Im=1.0 #define ABF_INST_DAGANCA10 12 // Dagan CA-1 Im=10 #define ABF_INST_WARNER_OC725 13 // Warner OC-725 #define ABF_INST_WARNER_OC725C 14 // Warner OC-725 #define ABF_INST_AXOPATCH200B 15 // Axopatch 200B #define ABF_INST_DAGANPCONE0_1 16 // Dagan PC-ONE Im=0.1 #define ABF_INST_DAGANPCONE1 17 // Dagan PC-ONE Im=1.0 #define ABF_INST_DAGANPCONE10 18 // Dagan PC-ONE Im=10 #define ABF_INST_DAGANPCONE100 19 // Dagan PC-ONE Im=100 #define ABF_INST_WARNER_BC525C 20 // Warner BC-525C #define ABF_INST_WARNER_PC505 21 // Warner PC-505 #define ABF_INST_WARNER_PC501 22 // Warner PC-501 #define ABF_INST_DAGANCA1_05 23 // Dagan CA-1 Im=0.05 #define ABF_INST_MULTICLAMP700 24 // MultiClamp 700 #define ABF_INST_TURBO_TEC 25 // Turbo Tec #define ABF_INST_OPUSXPRESS6000 26 // OpusXpress 6000A // // Constants for nManualInfoStrategy // #define ABF_ENV_DONOTWRITE 0 #define ABF_ENV_WRITEEACHTRIAL 1 #define ABF_ENV_PROMPTEACHTRIAL 2 // // Constants for nTriggerSource // #define ABF_TRIGGERLINEINPUT -5 // Start on line trigger (DD1320 only) #define ABF_TRIGGERTAGINPUT -4 #define ABF_TRIGGERFIRSTCHANNEL -3 #define ABF_TRIGGEREXTERNAL -2 #define ABF_TRIGGERSPACEBAR -1 // >=0 = ADC channel to trigger off. // // Constants for nTrialTriggerSource // #define ABF_TRIALTRIGGER_SWSTARTONLY -6 // Start on software message, end when protocol ends. #define ABF_TRIALTRIGGER_SWSTARTSTOP -5 // Start and end on software messages. #define ABF_TRIALTRIGGER_LINEINPUT -4 // Start on line trigger (DD1320 only) #define ABF_TRIALTRIGGER_SPACEBAR -3 // Start on spacebar press. #define ABF_TRIALTRIGGER_EXTERNAL -2 // Start on external trigger high #define ABF_TRIALTRIGGER_NONE -1 // Start immediately (default). // >=0 = ADC channel to trigger off. // Not implemented as yet... // // Constants for nTriggerPolarity. // #define ABF_TRIGGER_RISINGEDGE 0 #define ABF_TRIGGER_FALLINGEDGE 1 // // Constants for nTriggerAction // #define ABF_TRIGGER_STARTEPISODE 0 #define ABF_TRIGGER_STARTRUN 1 #define ABF_TRIGGER_STARTTRIAL 2 // N.B. Discontinued in favor of nTrialTriggerSource // // Constants for nDrawingStrategy // #define ABF_DRAW_NONE 0 #define ABF_DRAW_REALTIME 1 #define ABF_DRAW_FULLSCREEN 2 #define ABF_DRAW_ENDOFRUN 3 // // Constants for nTiledDisplay // #define ABF_DISPLAY_SUPERIMPOSED 0 #define ABF_DISPLAY_TILED 1 // // Constants for nDataDisplayMode // #define ABF_DRAW_POINTS 0 #define ABF_DRAW_LINES 1 // // Constants for nArithmeticExpression // #define ABF_SIMPLE_EXPRESSION 0 #define ABF_RATIO_EXPRESSION 1 // // Constants for nLowpassFilterType & nHighpassFilterType // #define ABF_FILTER_NONE 0 #define ABF_FILTER_EXTERNAL 1 #define ABF_FILTER_SIMPLE_RC 2 #define ABF_FILTER_BESSEL 3 #define ABF_FILTER_BUTTERWORTH 4 // // Constants for nPNPosition // #define ABF_PN_BEFORE_EPISODE 0 #define ABF_PN_AFTER_EPISODE 1 // // Constants for nPNPolarity // #define ABF_PN_OPPOSITE_POLARITY -1 #define ABF_PN_SAME_POLARITY 1 // // Constants for nAutopeakPolarity // #define ABF_PEAK_NEGATIVE -1 #define ABF_PEAK_ABSOLUTE 0 #define ABF_PEAK_POSITIVE 1 // // Constants for nAutopeakSearchMode // #define ABF_PEAK_SEARCH_SPECIFIED -2 #define ABF_PEAK_SEARCH_ALL -1 // nAutopeakSearchMode 0..9 = epoch in waveform 0's epoch table // nAutopeakSearchMode 10..19 = epoch in waveform 1's epoch table // // Constants for nAutopeakBaseline // #define ABF_PEAK_BASELINE_SPECIFIED -3 #define ABF_PEAK_BASELINE_NONE -2 #define ABF_PEAK_BASELINE_FIRSTHOLDING -1 #define ABF_PEAK_BASELINE_LASTHOLDING -4 // // Constants for lAutopeakMeasurements // #define ABF_PEAK_MEASURE_PEAK 0x00000001 #define ABF_PEAK_MEASURE_PEAKTIME 0x00000002 #define ABF_PEAK_MEASURE_ANTIPEAK 0x00000004 #define ABF_PEAK_MEASURE_ANTIPEAKTIME 0x00000008 #define ABF_PEAK_MEASURE_MEAN 0x00000010 #define ABF_PEAK_MEASURE_STDDEV 0x00000020 #define ABF_PEAK_MEASURE_INTEGRAL 0x00000040 #define ABF_PEAK_MEASURE_MAXRISESLOPE 0x00000080 #define ABF_PEAK_MEASURE_MAXRISESLOPETIME 0x00000100 #define ABF_PEAK_MEASURE_MAXDECAYSLOPE 0x00000200 #define ABF_PEAK_MEASURE_MAXDECAYSLOPETIME 0x00000400 #define ABF_PEAK_MEASURE_RISETIME 0x00000800 #define ABF_PEAK_MEASURE_DECAYTIME 0x00001000 #define ABF_PEAK_MEASURE_HALFWIDTH 0x00002000 #define ABF_PEAK_MEASURE_BASELINE 0x00004000 #define ABF_PEAK_MEASURE_RISESLOPE 0x00008000 #define ABF_PEAK_MEASURE_DECAYSLOPE 0x00010000 #define ABF_PEAK_MEASURE_REGIONSLOPE 0x00020000 #define ABF_PEAK_MEASURE_ALL 0x0002FFFF // All of the above OR'd together. // // Constants for nStatsActiveChannels // #define ABF_PEAK_SEARCH_CHANNEL0 0x0001 #define ABF_PEAK_SEARCH_CHANNEL1 0x0002 #define ABF_PEAK_SEARCH_CHANNEL2 0x0004 #define ABF_PEAK_SEARCH_CHANNEL3 0x0008 #define ABF_PEAK_SEARCH_CHANNEL4 0x0010 #define ABF_PEAK_SEARCH_CHANNEL5 0x0020 #define ABF_PEAK_SEARCH_CHANNEL6 0x0040 #define ABF_PEAK_SEARCH_CHANNEL7 0x0080 #define ABF_PEAK_SEARCH_CHANNEL8 0x0100 #define ABF_PEAK_SEARCH_CHANNEL9 0x0200 #define ABF_PEAK_SEARCH_CHANNEL10 0x0400 #define ABF_PEAK_SEARCH_CHANNEL11 0x0800 #define ABF_PEAK_SEARCH_CHANNEL12 0x1000 #define ABF_PEAK_SEARCH_CHANNEL13 0x2000 #define ABF_PEAK_SEARCH_CHANNEL14 0x4000 #define ABF_PEAK_SEARCH_CHANNEL15 0x8000 #define ABF_PEAK_SEARCH_CHANNELSALL 0xFFFF // All of the above OR'd together. // Bit flag settings for nStatsSearchRegionFlags // #define ABF_PEAK_SEARCH_REGION0 0x01 #define ABF_PEAK_SEARCH_REGION1 0x02 #define ABF_PEAK_SEARCH_REGION2 0x04 #define ABF_PEAK_SEARCH_REGION3 0x08 #define ABF_PEAK_SEARCH_REGION4 0x10 #define ABF_PEAK_SEARCH_REGION5 0x20 #define ABF_PEAK_SEARCH_REGION6 0x40 #define ABF_PEAK_SEARCH_REGION7 0x80 #define ABF_PEAK_SEARCH_REGIONALL 0xFF // All of the above OR'd together. // // Constants for lStatisticsMeasurements // #define ABF_STATISTICS_ABOVETHRESHOLD 0x00000001 #define ABF_STATISTICS_EVENTFREQUENCY 0x00000002 #define ABF_STATISTICS_MEANOPENTIME 0x00000004 #define ABF_STATISTICS_MEANCLOSEDTIME 0x00000008 #define ABF_STATISTICS_ALL 0x0000000F // All the above OR'd together. // // Constants for nStatisticsSaveStrategy // #define ABF_STATISTICS_NOAUTOSAVE 0 #define ABF_STATISTICS_AUTOSAVE 1 #define ABF_STATISTICS_AUTOSAVE_AUTOCLEAR 2 // // Constants for nStatisticsDisplayStrategy // #define ABF_STATISTICS_DISPLAY 0 #define ABF_STATISTICS_NODISPLAY 1 // // Constants for nStatisticsClearStrategy // determines whether to clear statistics after saving. // #define ABF_STATISTICS_NOCLEAR 0 #define ABF_STATISTICS_CLEAR 1 // // Constants for nDACFileEpisodeNum // #define ABF_DACFILE_SKIPFIRSTSWEEP -1 #define ABF_DACFILE_USEALLSWEEPS 0 // >0 = The specific sweep number. // // Constants for nUndoPromptStrategy // #define ABF_UNDOPROMPT_ONABORT 0 #define ABF_UNDOPROMPT_ALWAYS 1 // // Constants for nAutoAnalyseEnable // #define ABF_AUTOANALYSE_DISABLED 0 #define ABF_AUTOANALYSE_DEFAULT 1 #define ABF_AUTOANALYSE_RUNMACRO 2 // // Constants for post nPostprocessLowpassFilterType // #define ABF_POSTPROCESS_FILTER_NONE 0 #define ABF_POSTPROCESS_FILTER_ADAPTIVE 1 #define ABF_POSTPROCESS_FILTER_BESSEL 2 #define ABF_POSTPROCESS_FILTER_BOXCAR 3 #define ABF_POSTPROCESS_FILTER_BUTTERWORTH 4 #define ABF_POSTPROCESS_FILTER_CHEBYSHEV 5 #define ABF_POSTPROCESS_FILTER_GAUSSIAN 6 #define ABF_POSTPROCESS_FILTER_RC 7 #define ABF_POSTPROCESS_FILTER_RC8 8 #define ABF_POSTPROCESS_FILTER_NOTCH 9 // // Miscellaneous constants // #define ABF_FILTERDISABLED 100000.0F // Large frequency to disable lowpass filters #define ABF_UNUSED_CHANNEL -1 // Unused ADC and DAC channels. // // The output sampling sequence identifier for a seperate digital out channel. // #define ABF_DIGITAL_OUT_CHANNEL -1 #define ABF_PADDING_OUT_CHANNEL -2 // // maximum values for various parameters (used by ABFH_CheckUserList). // #define ABF_CTPULSECOUNT_MAX 10000 #define ABF_CTBASELINEDURATION_MAX 100000.0F #define ABF_CTSTEPDURATION_MAX 100000.0F #define ABF_CTPOSTTRAINDURATION_MAX 100000.0F #define ABF_SWEEPSTARTTOSTARTTIME_MAX 100000.0F #define ABF_PNPULSECOUNT_MAX 8 #define ABF_DIGITALVALUE_MAX 0xFF #define ABF_EPOCHDIGITALVALUE_MAX 0x0F // // LTP Types - Reflects whether the header is used for LTP as baseline or induction. // #define ABF_LTP_TYPE_NONE 0 #define ABF_LTP_TYPE_BASELINE 1 #define ABF_LTP_TYPE_INDUCTION 2 // // LTP Usage of DAC - Reflects whether the analog output will be used presynaptically or postsynaptically. // #define ABF_LTP_DAC_USAGE_NONE 0 #define ABF_LTP_DAC_USAGE_PRESYNAPTIC 1 #define ABF_LTP_DAC_USAGE_POSTSYNAPTIC 2 // // Header Version Numbers // #define ABF_V166 1.66F #define ABF_V167 1.67F #define ABF_V168 1.68F #define ABF_V169 1.69F #define ABF_V170 1.70F #define ABF_V171 1.71F #define ABF_V172 1.72F #define ABF_V173 1.73F #define ABF_V174 1.74F #define ABF_V175 1.75F #define ABF_V176 1.76F #define ABF_V177 1.77F #define ABF_V178 1.78F #define ABF_V179 1.79F #define ABF_V180 1.80F #define ABF_V181 1.81F #define ABF_V182 1.82F #define ABF_V183 1.83F // // pack structure on byte boundaries // #ifndef RC_INVOKED #pragma pack(push, 1) #endif // // Definition of the ABF header structure. // struct ABFFileHeader // The total header length = 6144 bytes. { // GROUP #1 - File ID and size information. (40 bytes) ABFLONG lFileSignature; float fFileVersionNumber; short nOperationMode; ABFLONG lActualAcqLength; short nNumPointsIgnored; ABFLONG lActualEpisodes; ABFLONG lFileStartDate; // YYYYMMDD ABFLONG lFileStartTime; ABFLONG lStopwatchTime; float fHeaderVersionNumber; short nFileType; short nMSBinFormat; // GROUP #2 - File Structure (78 bytes) ABFLONG lDataSectionPtr; ABFLONG lTagSectionPtr; ABFLONG lNumTagEntries; ABFLONG lScopeConfigPtr; ABFLONG lNumScopes; ABFLONG _lDACFilePtr; ABFLONG _lDACFileNumEpisodes; char sUnused001[4]; ABFLONG lDeltaArrayPtr; ABFLONG lNumDeltas; ABFLONG lVoiceTagPtr; ABFLONG lVoiceTagEntries; ABFLONG lUnused002; ABFLONG lSynchArrayPtr; ABFLONG lSynchArraySize; short nDataFormat; short nSimultaneousScan; ABFLONG lStatisticsConfigPtr; ABFLONG lAnnotationSectionPtr; ABFLONG lNumAnnotations; char sUnused003[2]; // GROUP #3 - Trial hierarchy information (82 bytes) /** The number of input channels we acquired. Do not access directly - use CABFHeader::get_channel_count_acquired */ short channel_count_acquired; /** The number of input channels we recorded. Do not access directly - use CABFHeader::get_channel_count_recorded */ short nADCNumChannels; float fADCSampleInterval; /*{{ The documentation says these two sample intervals are the interval between multiplexed samples, but not all digitisers work like that. Instead, these are the per-channel sample rate divided by the number of channels. If the user chose 100uS and has two channels, this value will be 50uS. }}*/ float fADCSecondSampleInterval; /*{{ // The two sample intervals must be an integer multiple (or submultiple) of each other. if (fADCSampleInterval > fADCSecondSampleInterval) ASSERT(fmod(fADCSampleInterval, fADCSecondSampleInterval) == 0.0); if (fADCSecondSampleInterval, fADCSampleInterval) ASSERT(fmod(fADCSecondSampleInterval, fADCSampleInterval) == 0.0); }}*/ float fSynchTimeUnit; float fSecondsPerRun; /** * The total number of samples per episode, for the recorded channels only. * This does not include channels which are acquired but not recorded. * * This is the number of samples per episode per channel, times the number of recorded channels. * * If you want the samples per episode for one channel, you must divide this by get_channel_count_recorded(). */ ABFLONG lNumSamplesPerEpisode; ABFLONG lPreTriggerSamples; ABFLONG lEpisodesPerRun; ABFLONG lRunsPerTrial; ABFLONG lNumberOfTrials; short nAveragingMode; short nUndoRunCount; short nFirstEpisodeInRun; float fTriggerThreshold; short nTriggerSource; short nTriggerAction; short nTriggerPolarity; float fScopeOutputInterval; float fEpisodeStartToStart; float fRunStartToStart; float fTrialStartToStart; ABFLONG lAverageCount; ABFLONG lClockChange; short nAutoTriggerStrategy; // GROUP #4 - Display Parameters (44 bytes) short nDrawingStrategy; short nTiledDisplay; short nEraseStrategy; // N.B. Discontinued. Use scope config entry instead. short nDataDisplayMode; ABFLONG lDisplayAverageUpdate; short nChannelStatsStrategy; ABFLONG lCalculationPeriod; // N.B. Discontinued. Use fStatisticsPeriod. ABFLONG lSamplesPerTrace; ABFLONG lStartDisplayNum; ABFLONG lFinishDisplayNum; short nMultiColor; short nShowPNRawData; float fStatisticsPeriod; ABFLONG lStatisticsMeasurements; short nStatisticsSaveStrategy; // GROUP #5 - Hardware information (16 bytes) float fADCRange; float fDACRange; ABFLONG lADCResolution; ABFLONG lDACResolution; // GROUP #6 Environmental Information (118 bytes) short nExperimentType; short _nAutosampleEnable; short _nAutosampleADCNum; short _nAutosampleInstrument; float _fAutosampleAdditGain; float _fAutosampleFilter; float _fAutosampleMembraneCap; short nManualInfoStrategy; float fCellID1; float fCellID2; float fCellID3; char sCreatorInfo[ABF_CREATORINFOLEN]; char _sFileComment[ABF_OLDFILECOMMENTLEN]; short nFileStartMillisecs; // Milliseconds portion of lFileStartTime short nCommentsEnable; char sUnused003a[8]; // GROUP #7 - Multi-channel information (1044 bytes) short nADCPtoLChannelMap[ABF_ADCCOUNT]; short nADCSamplingSeq[ABF_ADCCOUNT]; char sADCChannelName[ABF_ADCCOUNT][ABF_ADCNAMELEN]; char sADCUnits[ABF_ADCCOUNT][ABF_ADCUNITLEN]; float fADCProgrammableGain[ABF_ADCCOUNT]; float fADCDisplayAmplification[ABF_ADCCOUNT]; float fADCDisplayOffset[ABF_ADCCOUNT]; float fInstrumentScaleFactor[ABF_ADCCOUNT]; float fInstrumentOffset[ABF_ADCCOUNT]; float fSignalGain[ABF_ADCCOUNT]; float fSignalOffset[ABF_ADCCOUNT]; float fSignalLowpassFilter[ABF_ADCCOUNT]; float fSignalHighpassFilter[ABF_ADCCOUNT]; char sDACChannelName[ABF_DACCOUNT][ABF_DACNAMELEN]; char sDACChannelUnits[ABF_DACCOUNT][ABF_DACUNITLEN]; float fDACScaleFactor[ABF_DACCOUNT]; float fDACHoldingLevel[ABF_DACCOUNT]; short nSignalType; char sUnused004[10]; // GROUP #8 - Synchronous timer outputs (14 bytes) short nOUTEnable; short nSampleNumberOUT1; short nSampleNumberOUT2; short nFirstEpisodeOUT; short nLastEpisodeOUT; short nPulseSamplesOUT1; short nPulseSamplesOUT2; // GROUP #9 - Epoch Waveform and Pulses (184 bytes) short nDigitalEnable; short _nWaveformSource; short nActiveDACChannel; short _nInterEpisodeLevel; short _nEpochType[ABF_EPOCHCOUNT]; float _fEpochInitLevel[ABF_EPOCHCOUNT]; float _fEpochLevelInc[ABF_EPOCHCOUNT]; short _nEpochInitDuration[ABF_EPOCHCOUNT]; short _nEpochDurationInc[ABF_EPOCHCOUNT]; short nDigitalHolding; short nDigitalInterEpisode; short nDigitalValue[ABF_EPOCHCOUNT]; char sUnavailable1608[4]; // was float fWaveformOffset; short nDigitalDACChannel; char sUnused005[6]; // GROUP #10 - DAC Output File (98 bytes) float _fDACFileScale; float _fDACFileOffset; char sUnused006[2]; short _nDACFileEpisodeNum; short _nDACFileADCNum; char _sDACFilePath[ABF_DACFILEPATHLEN]; // GROUP #11 - Presweep (conditioning) pulse train (44 bytes) short _nConditEnable; short _nConditChannel; ABFLONG _lConditNumPulses; float _fBaselineDuration; float _fBaselineLevel; float _fStepDuration; float _fStepLevel; float _fPostTrainPeriod; float _fPostTrainLevel; char sUnused007[12]; // GROUP #12 - Variable parameter user list ( 82 bytes) short _nParamToVary; char _sParamValueList[ABF_VARPARAMLISTLEN]; // GROUP #13 - Autopeak measurement (36 bytes) short _nAutopeakEnable; short _nAutopeakPolarity; short _nAutopeakADCNum; short _nAutopeakSearchMode; ABFLONG _lAutopeakStart; ABFLONG _lAutopeakEnd; short _nAutopeakSmoothing; short _nAutopeakBaseline; short _nAutopeakAverage; char sUnavailable1866[2]; // Was nAutopeakSaveStrategy, use nStatisticsSaveStrategy ABFLONG _lAutopeakBaselineStart; ABFLONG _lAutopeakBaselineEnd; ABFLONG _lAutopeakMeasurements; // GROUP #14 - Channel Arithmetic (52 bytes) short nArithmeticEnable; float fArithmeticUpperLimit; float fArithmeticLowerLimit; short nArithmeticADCNumA; short nArithmeticADCNumB; float fArithmeticK1; float fArithmeticK2; float fArithmeticK3; float fArithmeticK4; char sArithmeticOperator[ABF_ARITHMETICOPLEN]; char sArithmeticUnits[ABF_ARITHMETICUNITSLEN]; float fArithmeticK5; float fArithmeticK6; short nArithmeticExpression; char sUnused008[2]; // GROUP #15 - On-line subtraction (34 bytes) short _nPNEnable; short nPNPosition; short _nPNPolarity; short nPNNumPulses; short _nPNADCNum; float _fPNHoldingLevel; float fPNSettlingTime; float fPNInterpulse; char sUnused009[12]; // GROUP #16 - Miscellaneous variables (82 bytes) short _nListEnable; short nBellEnable[ABF_BELLCOUNT]; short nBellLocation[ABF_BELLCOUNT]; short nBellRepetitions[ABF_BELLCOUNT]; short nLevelHysteresis; ABFLONG lTimeHysteresis; short nAllowExternalTags; char nLowpassFilterType[ABF_ADCCOUNT]; char nHighpassFilterType[ABF_ADCCOUNT]; short nAverageAlgorithm; float fAverageWeighting; short nUndoPromptStrategy; short nTrialTriggerSource; short nStatisticsDisplayStrategy; short nExternalTagType; ABFLONG lHeaderSize; double dFileDuration; short nStatisticsClearStrategy; // Size of v1.5 header = 2048 // Extra parameters in v1.6 // EXTENDED GROUP #2 - File Structure (26 bytes) ABFLONG lDACFilePtr[ABF_WAVEFORMCOUNT]; ABFLONG lDACFileNumEpisodes[ABF_WAVEFORMCOUNT]; // EXTENDED GROUP #3 - Trial Hierarchy float fFirstRunDelay; char sUnused010[6]; // EXTENDED GROUP #7 - Multi-channel information (62 bytes) float fDACCalibrationFactor[ABF_DACCOUNT]; float fDACCalibrationOffset[ABF_DACCOUNT]; char sUnused011[30]; // GROUP #17 - Trains parameters (160 bytes) ABFLONG lEpochPulsePeriod[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; ABFLONG lEpochPulseWidth [ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; // EXTENDED GROUP #9 - Epoch Waveform and Pulses ( 412 bytes) short nWaveformEnable[ABF_WAVEFORMCOUNT]; short nWaveformSource[ABF_WAVEFORMCOUNT]; short nInterEpisodeLevel[ABF_WAVEFORMCOUNT]; short nEpochType[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; float fEpochInitLevel[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; float fEpochLevelInc[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; ABFLONG lEpochInitDuration[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; ABFLONG lEpochDurationInc[ABF_WAVEFORMCOUNT][ABF_EPOCHCOUNT]; short nDigitalTrainValue[ABF_EPOCHCOUNT]; // 2 * 10 = 20 bytes short nDigitalTrainActiveLogic; // 2 bytes char sUnused012[18]; // EXTENDED GROUP #10 - DAC Output File (552 bytes) float fDACFileScale[ABF_WAVEFORMCOUNT]; float fDACFileOffset[ABF_WAVEFORMCOUNT]; ABFLONG lDACFileEpisodeNum[ABF_WAVEFORMCOUNT]; short nDACFileADCNum[ABF_WAVEFORMCOUNT]; char sDACFilePath[ABF_WAVEFORMCOUNT][ABF_PATHLEN]; char sUnused013[12]; // EXTENDED GROUP #11 - Presweep (conditioning) pulse train (100 bytes) short nConditEnable[ABF_WAVEFORMCOUNT]; ABFLONG lConditNumPulses[ABF_WAVEFORMCOUNT]; float fBaselineDuration[ABF_WAVEFORMCOUNT]; float fBaselineLevel[ABF_WAVEFORMCOUNT]; float fStepDuration[ABF_WAVEFORMCOUNT]; float fStepLevel[ABF_WAVEFORMCOUNT]; float fPostTrainPeriod[ABF_WAVEFORMCOUNT]; float fPostTrainLevel[ABF_WAVEFORMCOUNT]; char sUnused014[40]; // EXTENDED GROUP #12 - Variable parameter user list (1096 bytes) short nULEnable[ABF_USERLISTCOUNT]; short nULParamToVary[ABF_USERLISTCOUNT]; char sULParamValueList[ABF_USERLISTCOUNT][ABF_USERLISTLEN]; short nULRepeat[ABF_USERLISTCOUNT]; char sUnused015[48]; // EXTENDED GROUP #15 - On-line subtraction (56 bytes) short nPNEnable[ABF_WAVEFORMCOUNT]; short nPNPolarity[ABF_WAVEFORMCOUNT]; short __nPNADCNum[ABF_WAVEFORMCOUNT]; float fPNHoldingLevel[ABF_WAVEFORMCOUNT]; short nPNNumADCChannels[ABF_WAVEFORMCOUNT]; char nPNADCSamplingSeq[ABF_WAVEFORMCOUNT][ABF_ADCCOUNT]; // EXTENDED GROUP #6 Environmental Information (898 bytes) short nTelegraphEnable[ABF_ADCCOUNT]; short nTelegraphInstrument[ABF_ADCCOUNT]; float fTelegraphAdditGain[ABF_ADCCOUNT]; float fTelegraphFilter[ABF_ADCCOUNT]; float fTelegraphMembraneCap[ABF_ADCCOUNT]; short nTelegraphMode[ABF_ADCCOUNT]; short nTelegraphDACScaleFactorEnable[ABF_DACCOUNT]; char sUnused016a[24]; short nAutoAnalyseEnable; char sAutoAnalysisMacroName[ABF_MACRONAMELEN]; char sProtocolPath[ABF_PATHLEN]; char sFileComment[ABF_FILECOMMENTLEN]; struct GUID FileGUID; float fInstrumentHoldingLevel[ABF_DACCOUNT]; uint32_t ulFileCRC; char sModifierInfo[ABF_CREATORINFOLEN]; char sUnused017[76]; // EXTENDED GROUP #13 - Statistics measurements (388 bytes) short nStatsEnable; unsigned short nStatsActiveChannels; // Active stats channel bit flag unsigned short nStatsSearchRegionFlags; // Active stats region bit flag short nStatsSelectedRegion; short _nStatsSearchMode; short nStatsSmoothing; short nStatsSmoothingEnable; short nStatsBaseline; ABFLONG lStatsBaselineStart; ABFLONG lStatsBaselineEnd; ABFLONG lStatsMeasurements[ABF_STATS_REGIONS]; // Measurement bit flag for each region ABFLONG lStatsStart[ABF_STATS_REGIONS]; ABFLONG lStatsEnd[ABF_STATS_REGIONS]; short nRiseBottomPercentile[ABF_STATS_REGIONS]; short nRiseTopPercentile[ABF_STATS_REGIONS]; short nDecayBottomPercentile[ABF_STATS_REGIONS]; short nDecayTopPercentile[ABF_STATS_REGIONS]; short nStatsChannelPolarity[ABF_ADCCOUNT]; short nStatsSearchMode[ABF_STATS_REGIONS]; // Stats mode per region: mode is cursor region, epoch etc char sUnused018[156]; // GROUP #18 - Application version data (16 bytes) short nCreatorMajorVersion; short nCreatorMinorVersion; short nCreatorBugfixVersion; short nCreatorBuildVersion; short nModifierMajorVersion; short nModifierMinorVersion; short nModifierBugfixVersion; short nModifierBuildVersion; // GROUP #19 - LTP protocol (14 bytes) short nLTPType; short nLTPUsageOfDAC[ABF_WAVEFORMCOUNT]; short nLTPPresynapticPulses[ABF_WAVEFORMCOUNT]; char sUnused020[4]; // GROUP #20 - Digidata 132x Trigger out flag. (8 bytes) short nDD132xTriggerOut; char sUnused021[6]; // GROUP #21 - Epoch resistance (40 bytes) char sEpochResistanceSignalName[ABF_WAVEFORMCOUNT][ABF_ADCNAMELEN]; short nEpochResistanceState[ABF_WAVEFORMCOUNT]; char sUnused022[16]; // GROUP #22 - Alternating episodic mode (58 bytes) short nAlternateDACOutputState; short nAlternateDigitalValue[ABF_EPOCHCOUNT]; short nAlternateDigitalTrainValue[ABF_EPOCHCOUNT]; short nAlternateDigitalOutputState; char sUnused023[14]; // GROUP #23 - Post-processing actions (210 bytes) float fPostProcessLowpassFilter[ABF_ADCCOUNT]; char nPostProcessLowpassFilterType[ABF_ADCCOUNT]; // 6014 header bytes allocated + 130 header bytes not allocated char sUnused2048[130]; }; // Size = 6144 // This structure is persisted, so the size MUST NOT CHANGE #if !defined(_WINDOWS) || defined(__MINGW32__) #define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1]) #endif C_ASSERT(sizeof(struct ABFFileHeader) == 6144); /* inline ABFFileHeader::ABFFileHeader() { // Set everything to 0. memset( this, 0, sizeof(ABFFileHeader) ); // Set critical parameters so we can determine the version. lFileSignature = ABF_NATIVESIGNATURE; fFileVersionNumber = ABF_CURRENTVERSION; fHeaderVersionNumber = ABF_CURRENTVERSION; lHeaderSize = ABF_HEADERSIZE; } */ /* // // Scope descriptor format. // #define ABF_FACESIZE 32 struct ABFLogFont { short nHeight; // Height of the font in pixels. // short lWidth; // use 0 // short lEscapement; // use 0 // short lOrientation; // use 0 short nWeight; // MSWindows font weight value. // char bItalic; // use 0 // char bUnderline; // use 0 // char bStrikeOut; // use 0 // char cCharSet; // use ANSI_CHARSET (0) // char cOutPrecision; // use OUT_TT_PRECIS // char cClipPrecision; // use CLIP_DEFAULT_PRECIS // char cQuality; // use PROOF_QUALITY char cPitchAndFamily; // MSWindows pitch and family mask. char Unused[3]; // Unused space to maintain 4-byte packing. char szFaceName[ABF_FACESIZE];// Face name of the font. }; // Size = 40 struct ABFSignal { char szName[ABF_ADCNAMELEN+2]; // ABF name length + '\0' + 1 for alignment. short nMxOffset; // Offset of the signal in the sampling sequence. DWORD rgbColor; // Pen color used to draw trace. char nPenWidth; // Pen width in pixels. char bDrawPoints; // TRUE = Draw disconnected points char bHidden; // TRUE = Hide the trace. char bFloatData; // TRUE = Floating point pseudo channel float fVertProportion; // Relative proportion of client area to use float fDisplayGain; // Display gain of trace in UserUnits float fDisplayOffset; // Display offset of trace in UserUnits // float fUUTop; // Top of window in UserUnits // float fUUBottom; // Bottom of window in UserUnits }; // Size = 34 /////////////////////////////////////////////////////////////////////////////////// //// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ////// /////////////////////////////////////////////////////////////////////////////////// // The Following #defines appear to be largely unused in opur code base // However there does exist a second set of #defines in AxScope32.h // that REALLY defines what these bits in the header do. // In particular it important to note that all 32 bits are in fact used internally /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // Bit flags used in dwFlags field of ABFScopeConfig. #define ABF_OVERLAPPED 0x00000001 #define ABF_DONTERASE 0x00000002 #define ABF_MONOCHROME 0x00000004 #define ABF_CLIPPING 0x00000008 #define ABF_HIDEHORZGRIDS 0x00000010 #define ABF_HIDEVERTGRIDS 0x00000020 #define ABF_FULLSCREEN 0x00000040 #define ABF_HIDEXAXIS 0x00000080 #define ABF_HIDEYAXIS 0x00000100 #define ABF_HIDEXSCROLL 0x00000200 #define ABF_HIDEYSCROLL 0x00000400 #define ABF_HIDESIGNALNAME 0x00000800 #define ABF_ENABLEZOOM 0x00001000 #define ABF_XSPINFROMCENTER 0x00002000 #define ABF_HIDEXSPINNER 0x00004000 #define ABF_LARGESPINNERS 0x00008000 #define ABF_PERSISTENCEMODE 0x00010000 #define ABF_CARDIACMODE 0x00020000 #define ABF_HIDETWIRLER 0x00040000 #define ABF_DISABLEUI 0x00080000 /////////////////////////////////////////////////////////////////////////////////// // #define ABF_INTERNALUSE 0xFFF00000 // Do not add extra bit flags ^^^ here they are used internally /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// //// DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER// /////////////////////////////////////////////////////////////////////////////////// // Values for the wScopeMode field in ABFScopeConfig. #define ABF_EPISODICMODE 0 #define ABF_CONTINUOUSMODE 1 //#define ABF_XYMODE 2 // Values for the nEraseStrategy field in ABFScopeConfig. #define ABF_ERASE_EACHSWEEP 0 #define ABF_ERASE_EACHRUN 1 #define ABF_ERASE_EACHTRIAL 2 #define ABF_ERASE_DONTERASE 3 // Indexes into the rgbColor field of ABFScopeConfig. #define ABF_BACKGROUNDCOLOR 0 #define ABF_GRIDCOLOR 1 #define ABF_THRESHOLDCOLOR 2 #define ABF_EVENTMARKERCOLOR 3 #define ABF_SEPARATORCOLOR 4 #define ABF_AVERAGECOLOR 5 #define ABF_OLDDATACOLOR 6 #define ABF_TEXTCOLOR 7 #define ABF_AXISCOLOR 8 #define ABF_ACTIVEAXISCOLOR 9 #define ABF_LASTCOLOR ABF_ACTIVEAXISCOLOR #define ABF_SCOPECOLORS (ABF_LASTCOLOR+1) // Extended colors for rgbColorEx field in ABFScopeConfig #define ABF_STATISTICS_REGION0 0 #define ABF_STATISTICS_REGION1 1 #define ABF_STATISTICS_REGION2 2 #define ABF_STATISTICS_REGION3 3 #define ABF_STATISTICS_REGION4 4 #define ABF_STATISTICS_REGION5 5 #define ABF_STATISTICS_REGION6 6 #define ABF_STATISTICS_REGION7 7 #define ABF_BASELINE_REGION 8 #define ABF_STOREDSWEEPCOLOR 9 #define ABF_LASTCOLOR_EX ABF_STOREDSWEEPCOLOR #define ABF_SCOPECOLORS_EX (ABF_LASTCOLOR+1) // Values for the nDockState field in ABFScopeConfig #define ABF_SCOPE_NOTDOCKED 0 #define ABF_SCOPE_DOCKED_TOP 1 #define ABF_SCOPE_DOCKED_LEFT 2 #define ABF_SCOPE_DOCKED_RIGHT 3 #define ABF_SCOPE_DOCKED_BOTTOM 4 struct ABFScopeConfig { // Section 1 scope configurations DWORD dwFlags; // Flags that are meaningful to the scope. DWORD rgbColor[ABF_SCOPECOLORS]; // Colors for the components of the scope. float fDisplayStart; // Start of the display area in ms. float fDisplayEnd; // End of the display area in ms. WORD wScopeMode; // Mode that the scope is in. char bMaximized; // TRUE = Scope parent is maximized. char bMinimized; // TRUE = Scope parent is minimized. short xLeft; // Coordinate of the left edge. short yTop; // Coordinate of the top edge. short xRight; // Coordinate of the right edge. short yBottom; // Coordinate of the bottom edge. ABFLogFont LogFont; // Description of current font. ABFSignal TraceList[ABF_ADCCOUNT]; // List of traces in current use. short nYAxisWidth; // Width of the YAxis region. short nTraceCount; // Number of traces described in TraceList. short nEraseStrategy; // Erase strategy. short nDockState; // Docked position. // Size 656 // * Do not insert any new members above this point! * // Section 2 scope configurations for file version 1.68. short nSizeofOldStructure; // Unused byte to determine the offset of the version 2 data. DWORD rgbColorEx[ ABF_SCOPECOLORS_EX ]; // New color settings for stored sweep and cursors. short nAutoZeroState; // Status of the autozero selection. DWORD dwCursorsVisibleState; // Flag for visible status of cursors. DWORD dwCursorsLockedState; // Flag for enabled status of cursors. char sUnasigned[61]; // Size 113 ABFScopeConfig(); }; // Size = 769 inline ABFScopeConfig::ABFScopeConfig() { // Set everything to 0. memset( this, 0, sizeof(ABFScopeConfig) ); // Set critical parameters so we can determine the version. nSizeofOldStructure = 656; } */ // // Definition of the ABF synch array structure // struct ABFSynch { ABFLONG lStart; // Start of the episode/event in fSynchTimeUnit units. ABFLONG lLength; // Length of the episode/event in multiplexed samples. }; // Size = 8 // // Constants for nTagType in the ABFTag structure. // #define ABF_TIMETAG 0 #define ABF_COMMENTTAG 1 #define ABF_EXTERNALTAG 2 #define ABF_VOICETAG 3 #define ABF_NEWFILETAG 4 #define ABF_ANNOTATIONTAG 5 // Same as a comment tag except that nAnnotationIndex holds // the index of the annotation that holds extra information. // // Definition of the ABF Tag structure // struct ABFTag { ABFLONG lTagTime; // Time at which the tag was entered in fSynchTimeUnit units. char sComment[ABF_TAGCOMMENTLEN]; // Optional tag comment. short nTagType; // Type of tag ABF_TIMETAG, ABF_COMMENTTAG, ABF_EXTERNALTAG, ABF_VOICETAG, ABF_NEWFILETAG or ABF_ANNOTATIONTAG union { short nVoiceTagNumber; // If nTagType=ABF_VOICETAG, this is the number of this voice tag. short nAnnotationIndex; // If nTagType=ABF_ANNOTATIONTAG, this is the index of the corresponding annotation. }; }; // Size = 64 // Comment inserted for externally acquired tags (expanded with spaces to ABF_TAGCOMMENTLEN). #define ABF_EXTERNALTAGCOMMENT "" #define ABF_VOICETAGCOMMENT "" // // Constants for nCompressionType in the ABFVoiceTagInfo structure. // #define ABF_COMPRESSION_NONE 0 #define ABF_COMPRESSION_PKWARE 1 //#define ABF_COMPRESSION_MPEG 2 // // Definition of the ABFVoiceTagInfo structure. // struct ABFVoiceTagInfo { ABFLONG lTagNumber; // The tag number that corresponds to this VoiceTag ABFLONG lFileOffset; // Offset to this tag within the VoiceTag block ABFLONG lUncompressedSize; // Size of the voice tag expanded. ABFLONG lCompressedSize; // Compressed size of the tag. short nCompressionType; // Compression method used. short nSampleSize; // Size of the samples acquired. ABFLONG lSamplesPerSecond; // Rate at which the sound was acquired. uint32_t dwCRC; // CRC used to check data integrity. uint16_t wChannels; // Number of channels in the tag (usually 1). uint16_t wUnused; // Unused space. }; // Size 32 // // Constants for lParameterID in the ABFDelta structure. // // NOTE: If any changes are made to this list, the code in ABF_UpdateHeader must // be updated to include the new items. #define ABF_DELTA_HOLDING0 0 #define ABF_DELTA_HOLDING1 1 #define ABF_DELTA_HOLDING2 2 #define ABF_DELTA_HOLDING3 3 #define ABF_DELTA_DIGITALOUTS 4 #define ABF_DELTA_THRESHOLD 5 #define ABF_DELTA_PRETRIGGER 6 // Because of lack of space, the Autosample Gain ID also contains the ADC number. #define ABF_DELTA_AUTOSAMPLE_GAIN 100 // +ADC channel. // Because of lack of space, the Signal Gain ID also contains the ADC number. #define ABF_DELTA_SIGNAL_GAIN 200 // +ADC channel. // // Definition of the ABF Delta structure. // struct ABFDelta { ABFLONG lDeltaTime; // Time at which the parameter was changed in fSynchTimeUnit units. ABFLONG lParameterID; // Identifier for the parameter changed union { ABFLONG lNewParamValue; // Depending on the value of lParameterID float fNewParamValue; // this entry may be either a float or a long. }; }; // Size = 12 #ifndef RC_INVOKED #pragma pack(pop) // return to default packing #endif /* // // The size of the buffers to be passed to ABFH_GetWaveformVertor // #define ABFH_MAXVECTORS 30 // // Function prototypes for functions in ABFHEADR.C // void WINAPI ABFH_Initialize( ABFFileHeader *pFH ); void WINAPI ABFH_InitializeScopeConfig(const ABFFileHeader *pFH, ABFScopeConfig *pCfg); BOOL WINAPI ABFH_CheckScopeConfig(ABFFileHeader *pFH, ABFScopeConfig *pCfg); void WINAPI ABFH_GetADCDisplayRange( const ABFFileHeader *pFH, int nChannel, float *pfUUTop, float *pfUUBottom); void WINAPI ABFH_GetADCtoUUFactors( const ABFFileHeader *pFH, int nChannel, float *pfADCToUUFactor, float *pfADCToUUShift ); void WINAPI ABFH_ClipADCUUValue(const ABFFileHeader *pFH, int nChannel, float *pfUUValue); void WINAPI ABFH_GetDACtoUUFactors( const ABFFileHeader *pFH, int nChannel, float *pfDACToUUFactor, float *pfDACToUUShift ); void WINAPI ABFH_ClipDACUUValue(const ABFFileHeader *pFH, int nChannel, float *pfUUValue); BOOL WINAPI ABFH_GetMathValue(const ABFFileHeader *pFH, float fA, float fB, float *pfRval); int WINAPI ABFH_GetMathChannelName(char *pszName, UINT uNameLen); BOOL WINAPI ABFH_ParamReader( FILEHANDLE hFile, ABFFileHeader *pFH, int *pnError ); BOOL WINAPI ABFH_ParamReaderEx( HANDLE hFile, ABFFileHeader *pFH, int *pnError ); BOOL WINAPI ABFH_ParamWriter( HANDLE hFile, ABFFileHeader *pFH, int *pnError ); BOOL WINAPI ABFH_GetErrorText( int nError, char *pszBuffer, UINT nBufferSize ); // ABFHWAVE.CPP // Constants for ABFH_GetEpochLimits #define ABFH_FIRSTHOLDING -1 #define ABFH_LASTHOLDING ABF_EPOCHCOUNT // Return the bounds of a given epoch in a given episode. Values returned are ZERO relative. BOOL WINAPI ABFH_GetEpochLimits(const ABFFileHeader *pFH, int nADCChannel, DWORD dwEpisode, int nEpoch, UINT *puEpochStart, UINT *puEpochEnd, int *pnError); BOOL WINAPI ABFH_GetEpochLimitsEx(const ABFFileHeader *pFH, int nADCChannel, UINT uDACChannel, DWORD dwEpisode, int nEpoch, UINT *puEpochStart, UINT *puEpochEnd, int *pnError); // Get the offset in the sampling sequence for the given physical channel. BOOL WINAPI ABFH_GetChannelOffset( const ABFFileHeader *pFH, int nChannel, UINT *puChannelOffset ); // This function forms the de-multiplexed DAC output waveform for the // particular channel in the pfBuffer, in DAC UserUnits. BOOL WINAPI ABFH_GetWaveform( const ABFFileHeader *pFH, int nADCChannel, DWORD dwEpisode, float *pfBuffer, int *pnError); BOOL WINAPI ABFH_GetWaveformEx( const ABFFileHeader *pFH, UINT uDACChannel, DWORD dwEpisode, float *pfBuffer, int *pnError); // This function forms the de-multiplexed Digital output waveform for the // particular channel in the pdwBuffer, as a bit mask. Digital OUT 0 is in bit 0. BOOL WINAPI ABFH_GetDigitalWaveform( const ABFFileHeader *pFH, int nChannel, DWORD dwEpisode, DWORD *pdwBuffer, int *pnError); // Returns vector pairs for displaying a waveform made up of epochs. BOOL WINAPI ABFH_GetWaveformVector(const ABFFileHeader *pFH, DWORD dwEpisode, UINT uStart, UINT uFinish, float *pfLevels, float *pfTimes, int *pnVectors, int *pnError); // Returns vector pairs for displaying the digital outs. BOOL WINAPI ABFH_GetDigitalWaveformVector(const ABFFileHeader *pFH, DWORD dwEpisode, UINT uStart, UINT uFinish, DWORD *pdwLevels, float *pfTimes, int *pnVectors, int *pnError); // Calculates the timebase array for the file. void WINAPI ABFH_GetTimebase(const ABFFileHeader *pFH, float fTimeOffset, float *pfBuffer, UINT uBufferSize); void WINAPI ABFH_GetTimebaseEx(const ABFFileHeader *pFH, double dTimeOffset, double *pdBuffer, UINT uBufferSize); // Constant for ABFH_GetHoldingDuration #define ABFH_HOLDINGFRACTION 64 // Get the duration of the first holding period. UINT WINAPI ABFH_GetHoldingDuration(const ABFFileHeader *pFH); // Checks whether the waveform varies from episode to episode. BOOL WINAPI ABFH_IsConstantWaveform(const ABFFileHeader *pFH); BOOL WINAPI ABFH_IsConstantWaveformEx(const ABFFileHeader *pFH, UINT uDACChannel); // Checks that the sample intervals in the header are valid. BOOL WINAPI ABFH_CheckSampleIntervals(const ABFFileHeader *pFH, float fClockResolution, int *pnError); // Gets the closest sample intervals higher and lower than the passed interval. void WINAPI ABFH_GetClosestSampleIntervals(float fSampleInterval, float fClockResolution, int nOperationMode, float fMinPeriod, float fMaxPeriod, float *pfHigher, float *pfLower); // Sets up the list for the spinner to drive the sampling interval through. UINT WINAPI ABFH_SetupSamplingList(UINT uNumChannels, float fMinPeriod, float fMaxPeriod, float *pfIntervalList, UINT uListEntries); // Get the full sweep length given the length available to epochs or vice-versa. int WINAPI ABFH_SweepLenFromUserLen(int nUserLength, int nNumChannels); int WINAPI ABFH_UserLenFromSweepLen(int nSweepLength, int nNumChannels); // Converts a display range to the equivalent gain and offset factors. void WINAPI ABFH_GainOffsetToDisplayRange( const ABFFileHeader *pFH, int nChannel, float fDisplayGain, float fDisplayOffset, float *pfUUTop, float *pfUUBottom); // Converts a display range to the equivalent gain and offset factors. void WINAPI ABFH_DisplayRangeToGainOffset( const ABFFileHeader *pFH, int nChannel, float fUUTop, float fUUBottom, float *pfDisplayGain, float *pfDisplayOffset); // Converts a time value to a synch time count or vice-versa. void WINAPI ABFH_SynchCountToMS(const ABFFileHeader *pFH, UINT uCount, double *pdTimeMS); UINT WINAPI ABFH_MSToSynchCount(const ABFFileHeader *pFH, double dTimeMS); // Gets the point at which the sampling interval changes if split clock. UINT WINAPI ABFH_GetClockChange(const ABFFileHeader *pFH); // Gets the duration of the Waveform Episode (in us), allowing for split clock etc. void WINAPI ABFH_GetEpisodeDuration(const ABFFileHeader *pFH, double *pdEpisodeDuration); // Gets the duration of a P/N sequence (in us), including settling times. void WINAPI ABFH_GetPNDuration(const ABFFileHeader *pFH, double *pdPNDuration); void WINAPI ABFH_GetPNDurationEx(const ABFFileHeader *pFH, UINT uDAC, double *pdPNDuration); // Gets the duration of a pre-sweep train in us. void WINAPI ABFH_GetTrainDuration(const ABFFileHeader *pFH, double *pdTrainDuration); void WINAPI ABFH_GetTrainDurationEx (const ABFFileHeader *pFH, UINT uDAC, double *pdTrainDuration); // Gets the duration of a whole meta-episode (in us). void WINAPI ABFH_GetMetaEpisodeDuration(const ABFFileHeader *pFH, double *pdMetaEpisodeDuration); // Gets the start to start period for the episode in us. void WINAPI ABFH_GetEpisodeStartToStart(const ABFFileHeader *pFH, double *pdEpisodeStartToStart); // Checks that the user list contains valid entries for the protocol. BOOL WINAPI ABFH_CheckUserList(const ABFFileHeader *pFH, int *pnError); BOOL WINAPI ABFH_CheckUserListEx(const ABFFileHeader *pFH, UINT uListNum, int *pnError); // Checks if the ABFFileHeader is a new (6k) or old (2k) header. //BOOL WINAPI ABFH_IsNewHeader(const ABFFileHeader *pFH); // Demotes a new ABF header to a 1.5 version ABF header. void WINAPI ABFH_DemoteHeader(ABFFileHeader *pOut, const ABFFileHeader *pIn ); // Promotes an old ABF header to a 1.8 version ABF header. void WINAPI ABFH_PromoteHeader(ABFFileHeader *pOut, const ABFFileHeader *pIn ); // Gets the first sample interval, expressed as a double. double WINAPI ABFH_GetFirstSampleInterval( const ABFFileHeader *pFH ); // Gets the second sample interval expressed as a double. double WINAPI ABFH_GetSecondSampleInterval( const ABFFileHeader *pFH ); // Counts the number of changing sweeps. UINT WINAPI ABFH_GetNumberOfChangingSweeps( const ABFFileHeader *pFH ); // // Checks whether the digital output varies from episode to episode. BOOL WINAPI ABFH_IsConstantDigitalOutput(const ABFFileHeader *pFH); BOOL WINAPI ABFH_IsConstantDigitalOutputEx(const ABFFileHeader *pFH, UINT uDACChannel); int WINAPI ABFH_GetEpochDuration(const ABFFileHeader *pFH, UINT uDACChannel, UINT uEpisode, int nEpoch); float WINAPI ABFH_GetEpochLevel(const ABFFileHeader *pFH, UINT uDACChannel, UINT uEpisode, int nEpoch); BOOL WINAPI ABFH_GetEpochLevelRange(const ABFFileHeader *pFH, UINT uDACChannel, int nEpoch, float *pfMin, float *pfMax); UINT WINAPI ABFH_GetMaxPNSubsweeps(const ABFFileHeader *pFH, UINT uDACChannel); */ // // Error return values that may be returned by the ABFH_xxx functions. // #define ABFH_FIRSTERRORNUMBER 2001 #define ABFH_EHEADERREAD 2001 #define ABFH_EHEADERWRITE 2002 #define ABFH_EINVALIDFILE 2003 #define ABFH_EUNKNOWNFILETYPE 2004 #define ABFH_CHANNELNOTSAMPLED 2005 #define ABFH_EPOCHNOTPRESENT 2006 #define ABFH_ENOWAVEFORM 2007 #define ABFH_EDACFILEWAVEFORM 2008 #define ABFH_ENOMEMORY 2009 #define ABFH_BADSAMPLEINTERVAL 2010 #define ABFH_BADSECONDSAMPLEINTERVAL 2011 #define ABFH_BADSAMPLEINTERVALS 2012 #define ABFH_ENOCONDITTRAINS 2013 #define ABFH_EMETADURATION 2014 #define ABFH_ECONDITNUMPULSES 2015 #define ABFH_ECONDITBASEDUR 2016 #define ABFH_ECONDITBASELEVEL 2017 #define ABFH_ECONDITPOSTTRAINDUR 2018 #define ABFH_ECONDITPOSTTRAINLEVEL 2019 #define ABFH_ESTART2START 2020 #define ABFH_EINACTIVEHOLDING 2021 #define ABFH_EINVALIDCHARS 2022 #define ABFH_ENODIG 2023 #define ABFH_EDIGHOLDLEVEL 2024 #define ABFH_ENOPNPULSES 2025 #define ABFH_EPNNUMPULSES 2026 #define ABFH_ENOEPOCH 2027 #define ABFH_EEPOCHLEN 2028 #define ABFH_EEPOCHINITLEVEL 2029 #define ABFH_EDIGLEVEL 2030 #define ABFH_ECONDITSTEPDUR 2031 #define ABFH_ECONDITSTEPLEVEL 2032 #define ABFH_EINVALIDBINARYCHARS 2033 #define ABFH_EBADWAVEFORM 2034 #ifdef __cplusplus } #endif #endif /* INC_ABFHEADR_H */ biosig-2.3.3/biosig4c++/t210/sopen_dcmtk_read.cpp0000664000175000017500000003004514105434233021504 0ustar schloeglschloegl/* sandbox is used for development and under constraction work The functions here are either under construction or experimental. The functions will be either fixed, then they are moved to another place; or the functions are discarded. Do not rely on the interface in this function Copyright (C) 2018-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at https://biosig.sourceforge.io BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include "../biosig.h" // these functions are stubs #ifdef WITH_DCMTK #undef WITH_DICOM #undef WITH_GDCM /* DCMTK read files https://support.dcmtk.org/redmine/projects/dcmtk/wiki/Howto_LoadMetaHeader */ #include "dcmtk/config/osconfig.h" #include "dcmtk/dcmdata/dctk.h" #include "dcmtk/dcmdata/dcistrmf.h" #define INCLUDE_CSTRING #define INCLUDE_CSTDLIB #define INCLUDE_CSTDIO #include "dcmtk/ofstd/ofstdinc.h" #include "dcmtk/dcmdata/cmdlnarg.h" #include "dcmtk/ofstd/ofconapp.h" #include "dcmtk/dcmdata/dcuid.h" /* for dcmtk version name */ #include "dcmtk/dcmdata/dcostrmz.h" /* for dcmZlibCompressionLevel */ #include "dcmtk/dcmdata/dcistrmz.h" /* for dcmZlibExpectRFC1950Encoding */ #include "dcmtk/dcmdata/dcfilefo.h" /* for convertToUTF8 */ #ifdef HAVE_ZLIB #include /* for zlibVersion() */ #endif #ifdef DCMTK_ENABLE_CHARSET_CONVERSION #include "dcmtk/ofstd/ofchrenc.h" /* for OFCharacterEncoding */ #endif EXTERN_C int sopen_dcmtk_read(HDRTYPE* hdr) { if (PACKAGE_VERSION_NUMBER < 361) fprintf(stderr,"WARNING: DCMTK is not 3.6.1 but %s - this is not tested .\n",PACKAGE_VERSION); if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): DCMTK %s is used to read dicom files.\n",__func__,__LINE__, PACKAGE_VERSION); OFCondition status; E_FileReadMode opt_readMode = ERM_autoDetect; E_TransferSyntax opt_ixfer = EXS_Unknown; E_TransferSyntax opt_oxfer = EXS_Unknown; E_GrpLenEncoding opt_oglenc = EGL_recalcGL; E_EncodingType opt_oenctype = EET_ExplicitLength; E_PaddingEncoding opt_opadenc = EPD_noChange; OFCmdUnsignedInt opt_filepad = 0; OFCmdUnsignedInt opt_itempad = 0; #ifdef WITH_ZLIB OFCmdUnsignedInt opt_compressionLevel = 0; #endif #ifdef DCMTK_ENABLE_CHARSET_CONVERSION const char *opt_convertToCharset = NULL; size_t opt_conversionFlags = 0; #endif DcmFileFormat dfile; if (dfile.loadFile(hdr->FileName, opt_ixfer, EGL_noChange, DCM_MaxReadLength, opt_readMode).bad()) { fprintf(stderr,"# %s (line %d): DCMTK failed to read dicom file %s.\n",__func__,__LINE__, hdr->FileName); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "DICOM support not completed"); return -1; } if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): loadFile successful.\n",__func__,__LINE__); OFString csetString; DcmDataset *dset = dfile.getDataset(); if (dset->findAndGetOFStringArray(DCM_SpecificCharacterSet, csetString).good()) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): findAndGetOFStringArray successful.\n",__func__,__LINE__); if (csetString.compare("ISO_IR 192") != 0 && csetString.compare("ISO_IR 6") != 0) { #ifdef DCMTK_ENABLE_CHARSET_CONVERSION /* convert all DICOM strings to UTF-8 */ if (VERBOSE_LEVEL>7) fprintf(stdout,"# %s (line %d): converting all element values that are affected by SpecificCharacterSet (0008,0005) to UTF-8.\n",__func__,__LINE__); status = dset->convertToUTF8(); if (status.bad()) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "converting file to UTF-8 failed"); #else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "DICOM read error (character set conversion not available)"); #endif } } if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): \n",__func__,__LINE__); /* // this fails for example file cond = dfile.convertToUTF8(); if (cond.bad()) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "converting file to UTF-8 failed"); if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): convertToUTF8 successful.\n",__func__,__LINE__); */ /***** extract header1 fields *****/ DcmTagKey key; const char *str; if (dset->findAndGetString(DCM_PatientName, str).good()) strncpy(hdr->Patient.Name, str, MAX_LENGTH_NAME+1); if (dset->findAndGetString(DCM_PatientID, str).good()) strncpy(hdr->Patient.Id, str, MAX_LENGTH_PID+1); if (dset->findAndGetString(DCM_PatientWeight, str).good()) hdr->Patient.Weight = atol(str); if (dset->findAndGetString(DCM_PatientBirthDate, str).good()) { if ( (str != NULL) && (strlen(str) == 8)) { char *datestr = strdup(str); struct tm t; t.tm_mday=atoi(datestr+6); datestr[6]=0; t.tm_mon=atoi(datestr+4)-1; datestr[4]=0; t.tm_year=atoi(datestr); free(datestr); hdr->T0 = tm_time2gdf_time(&t); } else { if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): invalid birthday string <%s>\n",__func__,__LINE__,str ? str : ""); } } if (dset->findAndGetString(DCM_PatientSex, str).good() && str!=NULL) { if (strlen(str)==0) hdr->Patient.Sex = 0; // unknown else if (str[0]=='m' || str[0]=='M') hdr->Patient.Sex = 1; // male else if (str[0]=='f' || str[0]=='F') hdr->Patient.Sex = 2; // female } if (dset->findAndGetString(DCM_AcquisitionDateTime, str).good() && str!=NULL) { if ( (str != NULL) && (strlen(str) == 8)) { char *datestr = strdup(str); struct tm t0; datestr[14]=0; t0.tm_sec = atoi((char*)datestr+12); datestr[12]=0; t0.tm_min = atoi((char*)datestr+10); datestr[10]=0; t0.tm_hour = atoi((char*)datestr+8); datestr[8]=0; t0.tm_mday = atoi((char*)datestr+6); datestr[6]=0; t0.tm_mon = atoi((char*)datestr+4)-1; datestr[4]=0; t0.tm_year = atoi((char*)datestr)-1900; hdr->T0 = tm_time2gdf_time(&t0); } else { if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): invalid birthday string <%s>\n",__func__,__LINE__,str ? str : ""); } } if (dset->findAndGetString(DCM_Manufacturer, str).good()) if (str) strncpy(hdr->ID.Manufacturer._field, str, MAX_LENGTH_MANUF+1); if (dset->findAndGetString(DCM_InstitutionName, str).good()) hdr->ID.Hospital = strdup(str); if (VERBOSE_LEVEL > 7) fprintf(stdout,"# %s (line %d): read H1 successful.\n",__func__,__LINE__); DcmSequenceOfItems *seq = NULL; if (dset->findAndGetSequence(DCM_WaveformSequence, seq).bad() || (seq==NULL)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "DICOM read error - no Waveform sequence found"); return -1; } Uint32 numGroups = seq->card(); if (numGroups == 0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "DICOM read error - no multiplex group founds"); return -1; } for (uint32_t i = 0; i < numGroups; i++) { DcmItem *item = seq->getItem(i); // Number Of Waveform Channels Uint16 numChannels; if (item->findAndGetUint16(DCM_NumberOfWaveformChannels, numChannels).good()) hdr->NS=numChannels; // Number of samples Uint32 numSamples; if (item->findAndGetUint32(DCM_NumberOfWaveformSamples, numSamples).good()) hdr->NRec=numSamples; // Sampling Frequency if (item->findAndGetString(DCM_SamplingFrequency, str).good()) hdr->SampleRate = strtod(str, NULL); // read the channels hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); DcmSequenceOfItems *channelSeq; item->findAndGetSequence(DCM_ChannelDefinitionSequence, channelSeq); assert(hdr->NS == channelSeq->card()); // should be identical to numChannels ! /***** extract header2 and header 3 fields *****/ // Read channel attributes size_t bi = 0; hdr->SPR = 1; for (uint32_t k=0; k < hdr->NS; k++) { DcmItem *channelItem = channelSeq->getItem(k); CHANNEL_TYPE* hc = hdr->CHANNEL + k; hc->OnOff = 1; hc->SPR = hdr->SPR; hc->Cal = 1.0; hc->Off = 0.0; hc->Transducer[0] = '\0'; hc->LowPass = 0.0/0.0; hc->HighPass = 0.0/0.0; hc->DigMax = ldexp( 1.0, 15) - 1.0; // 2^15-1 hc->DigMin = ldexp(-1.0, 15); // -2^15 hc->LeadIdCode = 0; hc->PhysDimCode = 0; // undefined hc->bi = bi; if (channelItem->findAndGetString(DCM_ChannelLabel, str).good()) strncpy(hc->Label, str, MAX_LENGTH_LABEL+1); if (channelItem->findAndGetString(DCM_ChannelSensitivity, str).good()) hc->Cal = strtod(str, NULL); if (channelItem->findAndGetString(DCM_ChannelBaseline, str).good()) hc->Off = strtod(str, NULL); if (channelItem->findAndGetString(DCM_FilterLowFrequency, str).good()) hc->HighPass = strtod(str, NULL); if (channelItem->findAndGetString(DCM_FilterHighFrequency, str).good()) hc->LowPass = strtod(str, NULL); if (channelItem->findAndGetString(DCM_NotchFilterFrequency, str).good()) hc->Notch = strtod(str, NULL); Uint16 gdftyp; if (channelItem->findAndGetUint16(DCM_WaveformBitsStored, gdftyp).good()) { switch (gdftyp) { case 32: hc->GDFTYP = 5; hc->DigMax = ldexp(1.0,31)-1.0; hc->DigMin = -ldexp(1.0,31); break; case 24: hc->GDFTYP = 3+256; hc->DigMax = ldexp(1.0,23)-1.0; hc->DigMin = -ldexp(1.0,23); break; case 8: hc->GDFTYP = 1; hc->DigMax = 127; hc->DigMin = -128; break; case 16: hc->GDFTYP = 3; default: hc->GDFTYP = 3; hc->DigMax = ldexp(1.0,15)-1.0; hc->DigMin = -ldexp(1.0,15); } hc->PhysMax = hc->DigMax*hc->Cal+hc->Off; hc->PhysMin = hc->DigMin*hc->Cal+hc->Off; bi += hc->SPR * GDFTYP_BITS[hc->GDFTYP] >> 3; hdr->AS.bpb = bi; } // LeadIdCode DcmSequenceOfItems *channelSourceSeq; if (channelItem->findAndGetSequence(DCM_ChannelSourceSequence, channelSourceSeq).good()) { DcmItem *channelSourceItem = channelSourceSeq->getItem(0); if ( (channelSourceItem != NULL) && channelSourceItem->findAndGetString(DCM_CodeValue, str).good()) hc->LeadIdCode = atol(strchr(str,':') + 1); } // Physical Units DcmSequenceOfItems *channelUnitsSeq; if (channelItem->findAndGetSequence(DCM_ChannelSensitivityUnitsSequence, channelUnitsSeq).good()) { DcmItem *channelUnitsItem = channelUnitsSeq->getItem(0); if ( (channelUnitsItem != NULL) && channelUnitsItem->findAndGetString(DCM_CodeValue, str).good()) hc->PhysDimCode = PhysDimCode(str); } } // waveform data const Uint8* waveformData8 = NULL; const Uint16* waveformData16 = NULL; unsigned long count = 0; if (item->findAndGetUint16Array(DCM_WaveformData, waveformData16, &count ).good()) { count *= sizeof(uint16_t); hdr->NRec = count/hdr->AS.bpb; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, count); memcpy(hdr->AS.rawdata, waveformData16, count); hdr->AS.length = count/hdr->AS.bpb; } else if (item->findAndGetUint8Array(DCM_WaveformData, waveformData8, &count ).good()) { hdr->NRec = count/hdr->AS.bpb; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, count); memcpy(hdr->AS.rawdata, waveformData8, count); hdr->AS.length = count/hdr->AS.bpb; } } /***** TODO: extract event information *****/ /* hdr->EVENT.SampleRate = hdr->EVENT.POS = hdr->EVENT.TYP = hdr->EVENT.CHN = hdr->EVENT.DUR = hdr->EVENT.CodeDesc = hdr->EVENT.LenCodeDesc = */ if (VERBOSE_LEVEL>7) fprintf(stdout,"# %s (line %d): DCMTK is used to read dicom files.\n",__func__,__LINE__); } #endif // DCMTK biosig-2.3.3/biosig4c++/t210/LICENSE0000664000175000017500000004313114105434233016504 0ustar schloeglschloegl GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. biosig-2.3.3/biosig4c++/t210/sopen_tdms_read.c0000664000175000017500000004474514105434233021025 0ustar schloeglschloegl/* Copyright (C) 2010-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . References: [1] TDMS File Format Internal Structure, Publish Date: Jun 23, 2014 NI-Tutorial-5696-en.pdf downloaded from ni.com [2] npTDMS package for python https://github.com/adamreeve/npTDMS.git */ #include #include #include #include #include #include "../biosig-dev.h" typedef struct { uint32_t TDMSCONST; uint32_t toc_mask; uint32_t version; uint64_t nextSegmentOffset; uint64_t rawDataOffset; uint32_t numObjects; size_t data_position; size_t size; } __attribute__((aligned(4),packed)) tdms_segment_t; #define LEAD_SIZE 28 #define kTocMetaData (1L<<1) #define kTocRawData (1L<<3) #define kTocDAQmxRawData (1L<<7) #define kTocInterleavedData (1L<<5) #define kTocBigEndian (1L<<6) #define kTocNewObjList (1L<<2) typedef enum { tdsTypeVoid, tdsTypeI8, tdsTypeI16, tdsTypeI32, tdsTypeI64, tdsTypeU8, tdsTypeU16, tdsTypeU32, tdsTypeU64, tdsTypeSingleFloat, tdsTypeDoubleFloat, tdsTypeExtendedFloat, tdsTypeSingleFloatWithUnit=0x19, tdsTypeDoubleFloatWithUnit, tdsTypeExtendedFloatWithUnit, tdsTypeString=0x20, tdsTypeBoolean=0x21, tdsTypeTimeStamp=0x44, tdsTypeFixedPoint=0x4F, tdsTypeComplexSingleFloat=0x08000c, tdsTypeComplexDoubleFloat=0x10000d, tdsTypeDAQmxRawData=0xFFFFFFFF } tdsDataType; /* defines single tdms object */ typedef struct { tdsDataType datatype; void *value; char *object_path; } tdms_object_t; // define object store typedef struct { size_t numObjects; tdms_object_t *list; } tdms_object_store_t; // find element in object store ssize_t find_element(tdms_object_store_t *objList, const char *key) { for (size_t k=0; k < objList->numObjects; k++) { if (!strcmp(objList->list[k].object_path, key)) return k; } return -1; } // add (or replace) element in object store void add_element(tdms_object_store_t *objList, tdms_object_t element) { ssize_t idx = find_element(objList, element.object_path); if (idx < 0) { objList->numObjects++; objList->list = realloc(objList->list, objList->numObjects * sizeof(tdms_object_t)); idx = objList->numObjects - 1; } memcpy(objList->list+idx, &element, sizeof(tdms_object_t)); } // read number of objects into object store void read_tdms_objects(tdms_object_store_t O, void *ptr, uint32_t numObj) { // this function is under construction return; tdms_object_t element; // skip first 4 bytes, theise contains number of objects uint32_t numberOfObjects = leu32p(ptr); ptr += 4; char *pstr = NULL; for (uint32_t k = 0; k < numObj; k++) { uint32_t plen = leu32p(ptr); pstr = realloc(pstr,plen+1); memcpy(pstr, ptr+4, plen); pstr[plen] = 0; if (VERBOSE_LEVEL > 8) fprintf(stdout,"%s (line %i): Object %d [%d]<%s>\n",__func__,__LINE__, k, plen, pstr); ptr += 4 + plen; uint32_t idx = leu32p(ptr); ptr += 4; uint32_t numberOfProperties = leu32p(ptr); ptr += 4; if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): Object %i/%i <%s> ((%d) has %i properties \n",__func__,__LINE__, k, numberOfObjects, pstr, idx, numberOfProperties); if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i/%i path='%s' rawDataIdx=0x%08x\n",__func__,__LINE__, k, numberOfObjects, pstr, idx); char *propName = NULL; char *propVal = NULL; for (uint32_t p = 0; p < numberOfProperties; p++) { // property name uint32_t plen = leu32p(ptr); propName = realloc(propName,plen+1); memcpy(propName, ptr+4, plen); propName[plen] = 0; ptr += 4+plen; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i/%i <%s>\n",__func__,__LINE__, k, p, numberOfProperties, propName); // property type uint32_t propType = leu32p(ptr); ptr += 4; // property value int32_t val_i32; switch (propType) { case tdsTypeVoid: case tdsTypeI8: case tdsTypeI16: case tdsTypeI32: { // int32 int32_t val = lei32p(ptr); ptr += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int32)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeI64: case tdsTypeU8: case tdsTypeU16: case tdsTypeU32: { // uint32 uint32_t val = leu32p(ptr); ptr += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int32)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeU64: case tdsTypeSingleFloat: case tdsTypeDoubleFloat: case tdsTypeExtendedFloat: case tdsTypeSingleFloatWithUnit: // =0x19, case tdsTypeDoubleFloatWithUnit: case tdsTypeExtendedFloatWithUnit: case tdsTypeString: // case 0x20: plen = leu32p(ptr); propVal = realloc(propVal,plen+1); memcpy(propVal,ptr+4,plen); propVal[plen]=0; ptr += 4+plen; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(string)=<%s>\n",__func__,__LINE__, k, p,propName, propVal); break; case tdsTypeBoolean: case tdsTypeTimeStamp: // = 0x44 ptr += 4+plen; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(string)=<%s>\n",__func__,__LINE__, k, p,propName, propVal); break; case tdsTypeFixedPoint: // 0x4F, case tdsTypeComplexSingleFloat: // =0x08000c, case tdsTypeComplexDoubleFloat: // =0x10000d, case tdsTypeDAQmxRawData: // =0xFFFFFFFF default: if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %d property %d <%s>type=0x%x not supported. Skip %d bytes\n",__func__,__LINE__, k, p,propName,propType, plen); } } switch (idx) { case 0xffffffff : // no raw data break; case 0x00001269 : // DAQmx Format Changing scaler break; case 0x00001369 : // DAQmx Digital Line scaler break; case 0x00000000 : // ; } } if (pstr) free(pstr); } EXTERN_C void sopen_tdms_read(HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ // read whole file into memory size_t count = hdr->HeadLen; while (!ifeof(hdr)) { size_t bufsiz = 2*count; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, bufsiz+1); count += ifread(hdr->AS.Header+count, 1, bufsiz-count, hdr); } hdr->AS.Header[count]=0; hdr->HeadLen = count; tdms_object_store_t ObjectStore; ObjectStore.numObjects=0; ObjectStore.list=NULL; /* Specification obtained from http://www.ni.com/white-paper/5696/en however, there are also TDMS data out there, that is based on an XML header and a separate binary file. This is somewhat confusing. */ fprintf(stderr,"%s (line %i): Format TDMS is very experimental\n",__func__,__LINE__); /***** Lead In *****/ int currentSegment = 0; int currentSegmentTableSize = 16; // top level comprised of a single object that holds file-specific information like author or title. tdms_segment_t *segTable = malloc(currentSegmentTableSize * sizeof(tdms_segment_t)); memcpy(segTable, hdr->AS.Header, LEAD_SIZE+4); hdr->FILE.LittleEndian = !(segTable[0].toc_mask & kTocBigEndian); if ( (__BYTE_ORDER == __LITTLE_ENDIAN) != !(segTable[0].toc_mask & kTocBigEndian) ) { segTable[0].version = bswap_32(segTable[0].version); segTable[0].nextSegmentOffset = bswap_64(segTable[0].nextSegmentOffset); segTable[0].rawDataOffset = bswap_64(segTable[0].rawDataOffset); segTable[0].numObjects = bswap_32(segTable[0].numObjects); } segTable[currentSegment].data_position = LEAD_SIZE + segTable[currentSegment].rawDataOffset; // data position segTable[currentSegment].size = (segTable[currentSegment].toc_mask & kTocRawData) ? (segTable[currentSegment].nextSegmentOffset - segTable[currentSegment].rawDataOffset) : 0; switch (segTable[0].version) { case 4712: hdr->Version = 1.0; break; case 4713: hdr->Version = 2.0; break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"This version of format TDMS is currently not supported"); } read_tdms_objects(ObjectStore, hdr->AS.Header+LEAD_SIZE ,segTable[0].numObjects); size_t pos = LEAD_SIZE + segTable[currentSegment].nextSegmentOffset; // read table of indices for all segments while (++currentSegment) { // manage memory allocation of index table if (currentSegment >= currentSegmentTableSize) { currentSegmentTableSize *= 2; segTable = realloc(segTable, currentSegmentTableSize * sizeof(tdms_segment_t)); } // read next segment memcpy(segTable + currentSegment, hdr->AS.Header + pos, LEAD_SIZE+4); // copy global, and 1 segment if ( (__BYTE_ORDER == __LITTLE_ENDIAN) != !(segTable[currentSegment].toc_mask & kTocBigEndian) ) { segTable[currentSegment].version = bswap_32(segTable[currentSegment].version); segTable[currentSegment].nextSegmentOffset = bswap_64(segTable[currentSegment].nextSegmentOffset); segTable[currentSegment].rawDataOffset = bswap_64(segTable[currentSegment].rawDataOffset); segTable[currentSegment].numObjects = bswap_32(segTable[currentSegment].numObjects); } segTable[currentSegment].data_position = pos + LEAD_SIZE + segTable[currentSegment].rawDataOffset; segTable[currentSegment].size = (segTable[currentSegment].toc_mask & kTocRawData) ? (segTable[currentSegment].nextSegmentOffset - segTable[currentSegment].rawDataOffset) : -1; read_tdms_objects(ObjectStore, hdr->AS.Header+pos+LEAD_SIZE, segTable[currentSegment].numObjects); if (segTable[currentSegment].nextSegmentOffset == (uint64_t)(-1LL)) break; if (segTable[currentSegment].nextSegmentOffset == 0) break; if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %d): %s\n\tLittleEndian=%d\n\tVersion=%d\n\t@beginSeg %ld\n\t@NextSegment %ld\n\t@rawDataOffset %ld\n",__func__,__LINE__, hdr->AS.Header,hdr->FILE.LittleEndian, segTable[currentSegment].version, pos, segTable[currentSegment].nextSegmentOffset, segTable[currentSegment].rawDataOffset); pos += LEAD_SIZE + segTable[currentSegment].nextSegmentOffset; } if (VERBOSE_LEVEL > 7) { // show index table segTable fprintf(stdout, "#seg\tTMDs\tmask\tver\tnumObj\tnextSegOff\trawDataOffset\tDataPosition\tsize\n"); char tmpstr[8]; tmpstr[4]=0; for (int k = 0; k < currentSegment; k++) { memcpy(tmpstr,&segTable[k].TDMSCONST,4); fprintf(stdout, "%d\t%04s\t0x%04x\t%d\t%d\t%9ld\t%9ld\t%9ld\t%ld\n", k, tmpstr, segTable[k].toc_mask, segTable[k].version, segTable[k].numObjects, segTable[k].nextSegmentOffset, segTable[k].rawDataOffset, segTable[k].data_position, segTable[k].size); } } uint64_t nextSegmentOffset = leu64p(hdr->AS.Header+12); uint64_t RawDataOffset = leu64p(hdr->AS.Header+20); pos = 28; /***** Meta data *****/ if (1) { //while (posAS.Header+pos); pos += 4; char *pstr=NULL; for (uint32_t k=0; k < numberOfObjects; k++) { uint32_t plen = leu32p(hdr->AS.Header+pos); if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): %i %i %i\n",__func__,__LINE__, (int)hdr->HeadLen, (int)pos,plen); pstr = realloc(pstr,plen+1); memcpy(pstr,hdr->AS.Header+pos+4,plen); pstr[plen]=0; pos += 4+plen; uint32_t idx = leu32p(hdr->AS.Header+pos); pos += 4; uint32_t numberOfProperties = leu32p(hdr->AS.Header+pos); pos += 4; if (VERBOSE_LEVEL>8) fprintf(stdout,"%s (line %i): Object %i/%i <%s> ((%d) has %i properties \n", __func__,__LINE__, k,numberOfObjects,pstr,idx,numberOfProperties); char *propName=NULL; char *propVal=NULL; for (uint32_t p=0; p < numberOfProperties; p++) { // property name uint32_t plen = leu32p(hdr->AS.Header+pos); propName = realloc(propName,plen+1); memcpy(propName,hdr->AS.Header+pos+4,plen); propName[plen]=0; pos += 4+plen; // property type uint32_t propType = leu32p(hdr->AS.Header+pos); pos += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i/%i %d<%s> 0x%08x\n",__func__,__LINE__, k, p, numberOfProperties, plen,propName, propType); // property value int32_t val_i32; switch (propType) { case tdsTypeVoid: if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(void)\n",__func__,__LINE__, k, p,propName); break; case tdsTypeI8: { int8_t val = (int8_t)hdr->AS.Header[pos]; pos += 1; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int8)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeI16: { int16_t val = lei16p(hdr->AS.Header+pos); pos += 2; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int16)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeI32: { // int32 int32_t val = lei32p(hdr->AS.Header+pos); pos += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int32)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeI64: { // int64 int64_t val = lei64p(hdr->AS.Header+pos); pos += 8; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int64)=%ld\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeU8: { uint8_t val = (uint8_t)hdr->AS.Header[pos]; pos += 1; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(uint8)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeU16: { uint16_t val = leu16p(hdr->AS.Header+pos); pos += 1; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(uint16)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeU32: { // case 0x07: // uint32 uint32_t val = leu32p(hdr->AS.Header+pos); pos += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(int32)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeU64: { // uint64 uint64_t val = leu64p(hdr->AS.Header+pos); pos += 8; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(uint64)=%ld\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeSingleFloat: { float val = lef32p(hdr->AS.Header+pos); pos += 4; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(float32)=%g\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeDoubleFloat: { // double double val = lef64p(hdr->AS.Header+pos); pos += 8; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(float64)=%ld\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeExtendedFloat:{ // double // double val = lef128p(hdr->AS.Header+pos); pos += 16; break; } case tdsTypeSingleFloatWithUnit: // =0x19, case tdsTypeDoubleFloatWithUnit: case tdsTypeExtendedFloatWithUnit: case tdsTypeString: // case 0x20: plen = leu32p(hdr->AS.Header+pos); propVal = realloc(propVal,plen+1); memcpy(propVal,hdr->AS.Header+pos+4,plen); propVal[plen]=0; pos += 4+plen; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(string)=<%s>\n",__func__,__LINE__, k, p,propName, propVal); break; case tdsTypeBoolean: { uint8_t val = (uint8_t)hdr->AS.Header[pos]; pos += 1; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(boolean)=%i\n",__func__,__LINE__, k, p,propName,val); break; } case tdsTypeTimeStamp: { //=0x44 // NI Timestamps according to http://www.ni.com/product-documentation/7900/en/ int64_t time_seconds = lei64p(hdr->AS.Header+pos); uint64_t time_fraction = leu64p(hdr->AS.Header+pos+8); gdftime_t T0 = ldexp((time_seconds+ldexp(time_fraction,-64))/(24.0*3600.0)+695422,32); pos += 16; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i timestamp %ld %.8g \n",__func__,__LINE__, k, time_seconds, ldexp(time_fraction,-64)); break; } case tdsTypeFixedPoint: // 0x4F, pos += 8; break; case 0x61: //plen = leu32p(hdr->AS.Header+pos); pos += 16; break; case tdsTypeComplexSingleFloat: { // =0x08000c, float val[2]; val[0] = lef32p(hdr->AS.Header+pos); val[1] = lef32p(hdr->AS.Header+pos); pos += 16; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(float64)=%g + i%h\n",__func__,__LINE__, k, p, propName, val[0], val[1]); break; } case tdsTypeComplexDoubleFloat: {// =0x10000d, double val[2]; val[0] = lef64p(hdr->AS.Header+pos); val[1] = lef64p(hdr->AS.Header+pos); pos += 16; if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i property %i <%s>(float64)=%g + i%h\n",__func__,__LINE__, k, p, propName, val[0], val[1]); break; } case tdsTypeDAQmxRawData: { // =0xFFFFFFFF if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %d property %d <%s>type=0x%x not supported. Skip %d bytes\n",__func__,__LINE__, k, p,propName,propType, plen); break; } default: if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %d property %d <%s>type=0x%x not supported. Skip %d bytes\n",__func__,__LINE__, k, p,propName,propType, plen); } } if (VERBOSE_LEVEL>6) fprintf(stdout,"%s (line %i): object %i/%i path='%s' rawDataIdx=0x%08x\n",__func__,__LINE__, k, numberOfObjects, pstr, idx); switch (idx) { case 0xffffffff : // no raw data break; case 0x00001269 : // DAQmx Format Changing scaler break; case 0x00001369 : // DAQmx Digital Line scaler break; case 0x00000000 : // ; } } } if (segTable) free(segTable); biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"Format TDMS is currently not supported"); } biosig-2.3.3/biosig4c++/t210/axon_structs.h0000664000175000017500000002656114105434233020414 0ustar schloeglschloegl// // This file is part of the Axon Library. // // Copyright (c) 2008-2009 Jakub Nowacki // // The Axon Binary Format is property of Molecular Devices. // All rights to the Axon Binary Format are reserved to Molecular Devices. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, 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 St, Fifth Floor, Boston, MA 02110-1301, USA // /* modified for use with biosig Copyright (C) 2013 Alois Schlögl, This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ /*! \file * \brief Header containing all structures of ABF */ #ifndef INC_PROTOCOLSTRUCTS_HPP #define INC_PROTOCOLSTRUCTS_HPP #pragma once #pragma pack(push, 1) //#define UINT unsigned int //#define LONGLONG long long #define bool int // GUID is normally defined in the Windows Platform SDK struct GUID { uint32_t Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; }; // All these structs are persisted to file -> their sizes must NOT be changed without careful // attention to versioning issues in order to maintain compatibility. typedef struct ABF_Section { unsigned int uBlockIndex; // ABF block number of the first entry unsigned int uBytes; // size in bytes of of each entry long long llNumEntries; // number of entries in this section } ABF_Section; #define ABF_FILESIGNATURE 0x32464241 // PC="ABF2", MAC="2FBA" struct ABF_FileInfo { unsigned int uFileSignature; unsigned int uFileVersionNumber; // After this point there is no need to be the same as the ABF 1 equivalent. unsigned int uFileInfoSize; unsigned int uActualEpisodes; unsigned int uFileStartDate; unsigned int uFileStartTimeMS; unsigned int uStopwatchTime; short nFileType; short nDataFormat; short nSimultaneousScan; short nCRCEnable; unsigned int uFileCRC; struct GUID FileGUID; unsigned int uCreatorVersion; unsigned int uCreatorNameIndex; unsigned int uModifierVersion; unsigned int uModifierNameIndex; unsigned int uProtocolPathIndex; // New sections in ABF 2 - protocol stuff ... ABF_Section ProtocolSection; // the protocol ABF_Section ADCSection; // one for each ADC channel ABF_Section DACSection; // one for each DAC channel ABF_Section EpochSection; // one for each epoch ABF_Section ADCPerDACSection; // one for each ADC for each DAC ABF_Section EpochPerDACSection; // one for each epoch for each DAC ABF_Section UserListSection; // one for each user list ABF_Section StatsRegionSection; // one for each stats region ABF_Section MathSection; ABF_Section StringsSection; // ABF 1 sections ... ABF_Section DataSection; // Data ABF_Section TagSection; // Tags ABF_Section ScopeSection; // Scope config ABF_Section DeltaSection; // Deltas ABF_Section VoiceTagSection; // Voice Tags ABF_Section SynchArraySection; // Synch Array ABF_Section AnnotationSection; // Annotations ABF_Section StatsSection; // Stats config char sUnused[148]; // size = 512 bytes }; struct ABF_ProtocolInfo { short nOperationMode; float fADCSequenceInterval; bool bEnableFileCompression; char sUnused1[3]; unsigned int uFileCompressionRatio; float fSynchTimeUnit; float fSecondsPerRun; ABFLONG lNumSamplesPerEpisode; ABFLONG lPreTriggerSamples; ABFLONG lEpisodesPerRun; ABFLONG lRunsPerTrial; ABFLONG lNumberOfTrials; short nAveragingMode; short nUndoRunCount; short nFirstEpisodeInRun; float fTriggerThreshold; short nTriggerSource; short nTriggerAction; short nTriggerPolarity; float fScopeOutputInterval; float fEpisodeStartToStart; float fRunStartToStart; ABFLONG lAverageCount; float fTrialStartToStart; short nAutoTriggerStrategy; float fFirstRunDelayS; short nChannelStatsStrategy; ABFLONG lSamplesPerTrace; ABFLONG lStartDisplayNum; ABFLONG lFinishDisplayNum; short nShowPNRawData; float fStatisticsPeriod; ABFLONG lStatisticsMeasurements; short nStatisticsSaveStrategy; float fADCRange; float fDACRange; ABFLONG lADCResolution; ABFLONG lDACResolution; short nExperimentType; short nManualInfoStrategy; short nCommentsEnable; ABFLONG lFileCommentIndex; short nAutoAnalyseEnable; short nSignalType; short nDigitalEnable; short nActiveDACChannel; short nDigitalHolding; short nDigitalInterEpisode; short nDigitalDACChannel; short nDigitalTrainActiveLogic; short nStatsEnable; short nStatisticsClearStrategy; short nLevelHysteresis; ABFLONG lTimeHysteresis; short nAllowExternalTags; short nAverageAlgorithm; float fAverageWeighting; short nUndoPromptStrategy; short nTrialTriggerSource; short nStatisticsDisplayStrategy; short nExternalTagType; short nScopeTriggerOut; short nLTPType; short nAlternateDACOutputState; short nAlternateDigitalOutputState; float fCellID[3]; short nDigitizerADCs; short nDigitizerDACs; short nDigitizerTotalDigitalOuts; short nDigitizerSynchDigitalOuts; short nDigitizerType; char sUnused[304]; // size = 512 bytes }; struct ABF_MathInfo { short nMathEnable; short nMathExpression; unsigned int uMathOperatorIndex; unsigned int uMathUnitsIndex; float fMathUpperLimit; float fMathLowerLimit; short nMathADCNum[2]; char sUnused[16]; float fMathK[6]; char sUnused2[64]; // size = 128 bytes }; struct ABF_ADCInfo { // The ADC this struct is describing. short nADCNum; short nTelegraphEnable; short nTelegraphInstrument; float fTelegraphAdditGain; float fTelegraphFilter; float fTelegraphMembraneCap; short nTelegraphMode; float fTelegraphAccessResistance; short nADCPtoLChannelMap; short nADCSamplingSeq; float fADCProgrammableGain; float fADCDisplayAmplification; float fADCDisplayOffset; float fInstrumentScaleFactor; float fInstrumentOffset; float fSignalGain; float fSignalOffset; float fSignalLowpassFilter; float fSignalHighpassFilter; char nLowpassFilterType; char nHighpassFilterType; float fPostProcessLowpassFilter; char nPostProcessLowpassFilterType; bool bEnabledDuringPN; short nStatsChannelPolarity; ABFLONG lADCChannelNameIndex; ABFLONG lADCUnitsIndex; char sUnused[46]; // size = 128 bytes }; struct ABF_DACInfo { // The DAC this struct is describing. short nDACNum; short nTelegraphDACScaleFactorEnable; float fInstrumentHoldingLevel; float fDACScaleFactor; float fDACHoldingLevel; float fDACCalibrationFactor; float fDACCalibrationOffset; ABFLONG lDACChannelNameIndex; ABFLONG lDACChannelUnitsIndex; ABFLONG lDACFilePtr; ABFLONG lDACFileNumEpisodes; short nWaveformEnable; short nWaveformSource; short nInterEpisodeLevel; float fDACFileScale; float fDACFileOffset; ABFLONG lDACFileEpisodeNum; short nDACFileADCNum; short nConditEnable; ABFLONG lConditNumPulses; float fBaselineDuration; float fBaselineLevel; float fStepDuration; float fStepLevel; float fPostTrainPeriod; float fPostTrainLevel; short nMembTestEnable; short nLeakSubtractType; short nPNPolarity; float fPNHoldingLevel; short nPNNumADCChannels; short nPNPosition; short nPNNumPulses; float fPNSettlingTime; float fPNInterpulse; short nLTPUsageOfDAC; short nLTPPresynapticPulses; ABFLONG lDACFilePathIndex; float fMembTestPreSettlingTimeMS; float fMembTestPostSettlingTimeMS; short nLeakSubtractADCIndex; char sUnused[124]; // size = 256 bytes }; struct ABF_EpochInfoPerDAC { // The Epoch / DAC this struct is describing. short nEpochNum; short nDACNum; // One full set of epochs (ABF_EPOCHCOUNT) for each DAC channel ... short nEpochType; float fEpochInitLevel; float fEpochLevelInc; ABFLONG lEpochInitDuration; ABFLONG lEpochDurationInc; ABFLONG lEpochPulsePeriod; ABFLONG lEpochPulseWidth; char sUnused[18]; // size = 48 bytes }; struct ABF_EpochInfo { // The Epoch this struct is describing. short nEpochNum; // Describes one epoch short nDigitalValue; short nDigitalTrainValue; short nAlternateDigitalValue; short nAlternateDigitalTrainValue; bool bEpochCompression; // Compress the data from this epoch using uFileCompressionRatio char sUnused[21]; // size = 32 bytes }; struct ABF_StatsRegionInfo { // The stats region this struct is describing. short nRegionNum; short nADCNum; short nStatsActiveChannels; short nStatsSearchRegionFlags; short nStatsSelectedRegion; short nStatsSmoothing; short nStatsSmoothingEnable; short nStatsBaseline; ABFLONG lStatsBaselineStart; ABFLONG lStatsBaselineEnd; // Describes one stats region ABFLONG lStatsMeasurements; ABFLONG lStatsStart; ABFLONG lStatsEnd; short nRiseBottomPercentile; short nRiseTopPercentile; short nDecayBottomPercentile; short nDecayTopPercentile; short nStatsSearchMode; short nStatsSearchDAC; short nStatsBaselineDAC; char sUnused[78]; // size = 128 bytes }; struct ABF_UserListInfo { // The user list this struct is describing. short nListNum; // Describes one user list short nULEnable; short nULParamToVary; short nULRepeat; ABFLONG lULParamValueListIndex; char sUnused[52]; // size = 64 bytes }; struct ABF_SynchArray { ABFLONG lStart; ABFLONG lLength; }; // Strings section structure not defined by Axon #pragma pack(pop) // return to default packing #endif // INC_PROTOCOLSTRUCTS_HPP biosig-2.3.3/biosig4c++/t210/sopen_cadwell_read.c0000664000175000017500000001221414105434233021453 0ustar schloeglschloegl/* Copyright (C) 2021 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include #include "../biosig.h" /****************************************************************************** read CADWELL file formats (EAS, EZ3, ARC) ******************************************************************************/ void sopen_cadwell_read(HDRTYPE* hdr) { if (VERBOSE_LEVEL > 8) fprintf(stdout,"%s (line %d) %s(hdr)\n", __FILE__, __LINE__, __func__); if (hdr->TYPE==EAS) { /* 12 bit ADC ? 200 Hz 77*800 samples EEGData section has a periodicity of 202*2 (404 bytes) 800samples*16channels*2byte=25600 = 0x6400) */ hdr->NS = 16; // so far all example files had 16 channels hdr->SPR = 1; hdr->NRec = 0; unsigned lengthHeader0 = leu32p(hdr->AS.Header + 0x30); unsigned lengthHeader1 = leu32p(hdr->AS.Header + 0x34); // this is varying amoung data sets - meaning unknown assert(lengthHeader0==0x0400); for (int k=0; k*0x20 < lengthHeader1; k++) { char *sectName = hdr->AS.Header + 0x6c + k*0x20; size_t sectPos= leu32p(hdr->AS.Header + 0x7c + k*0x20); size_t sectN1 = leu32p(hdr->AS.Header + 0x80 + k*0x20); size_t sectN2 = leu32p(hdr->AS.Header + 0x84 + k*0x20); size_t sectN3 = leu32p(hdr->AS.Header + 0x88 + k*0x20); if (!sectPos || memcmp("SctHdr\0\0", hdr->AS.Header+sectPos, 8) || memcmp(hdr->AS.Header+sectPos+8, sectName, 16)) { if (VERBOSE_LEVEL > 8) fprintf(stdout,"%s (line %d): break loop (0x%x %s)\n",__FILE__,__LINE__, sectPos, sectName); break; } uint64_t curSec, nextSec; int flag=1; do { curSec = leu64p(hdr->AS.Header + sectPos + 24); nextSec = leu64p(hdr->AS.Header + sectPos + 32); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): 0x%08x %s 0x%08lx 0x%08lx \n",__FILE__,__LINE__, sectPos, sectName, curSec, nextSec); if (flag && !strcmp(sectName,"EEGData")) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): 0x%08x %s 0x%08lx 0x%08lx \n",__FILE__,__LINE__, sectPos, sectName, curSec, nextSec); FILE *fid2=fopen("tmp.bin","w"); fwrite(hdr->AS.Header + curSec+120, 1, nextSec-curSec-120,fid2); fclose(fid2); FILE *fid=fopen("tmp.asc","w"); for (size_t k0=curSec+8*15; k0 < nextSec; k0+=2) { fprintf(fid,"%d\n",bei16p(hdr->AS.Header + curSec + k0+1)); } fclose(fid); flag = 0; } sectPos = nextSec; } while (nextSec != (size_t)-1L); } biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format EAS(Cadwell): unsupported "); } else if (hdr->TYPE==EZ3) { hdr->VERSION = strtod((char*)hdr->AS.Header+21, NULL); // 16 bit ADC ? // 250 Hz ? if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d)0x%8x\n",__FILE__,__LINE__,hdr->HeadLen); uint32_t posH1 = leu32p(hdr->AS.Header + 0x10); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d)0x%8x\n",__FILE__,__LINE__,posH1); uint32_t posH1b = leu32p(hdr->AS.Header + 0x20); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d)0x%8x\n",__FILE__,__LINE__,posH1b); uint32_t posH2 = leu32p(hdr->AS.Header + 0x38); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d)0x%8x\n",__FILE__,__LINE__,posH2); uint32_t posH2b = leu32p(hdr->AS.Header + posH1 + 0x38); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d) 0x%08x 0x%08x 0x%08x 0x%08x \n",__FILE__,__LINE__,posH1,posH1b,posH2,posH2b); assert(posH1==posH1b); assert(posH2==posH2b); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d)\n",__FILE__,__LINE__); // start date/time { char *tmp = hdr->AS.Header + 0x5c; struct tm t; t.tm_year = strtol(tmp,&tmp,10)-1900; t.tm_mon = strtol(tmp+1,&tmp,10)-1; t.tm_mday = strtol(tmp+1,&tmp,10); t.tm_hour = strtol(tmp+1,&tmp,10); t.tm_min = strtol(tmp+1,&tmp,10); t.tm_sec = strtol(tmp+1,&tmp,10); hdr->T0 = tm_time2gdf_time(&t); } uint32_t pos0=posH1+0x40; for (size_t k = posH1+0x40; k < posH2; k += 0x30) { char *tmp = hdr->AS.Header + k + 1; uint32_t pos = leu32p(hdr->AS.Header + k + 0x28); if (tmp[0]=='\0') break; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %d): Label=<%s> %10d(0x%08x) [sz=%d]\n",__FILE__,__LINE__, tmp, pos, pos, pos-pos0); pos0=pos; } biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format EZ3(Cadwell): unsupported "); } else if (hdr->TYPE==ARC) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Format ARC(Cadwell): unsupported "); } } biosig-2.3.3/biosig4c++/t210/sopen_scp_read.c0000664000175000017500000016644414105434233020644 0ustar schloeglschloegl/* Copyright (C) 2005-2018 Alois Schloegl Copyright (C) 2011 Stoyan Mihaylov This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ // #define WITHOUT_SCP_DECODE // use SCP-DECODE if needed, Bimodal, reference beat /* the experimental version needs a few more thinks: - Bimodal and RefBeat decoding do not work yet - validation and testing */ #include #include #include #include #include #if !defined(__APPLE__) && defined (_LIBICONV_H) #define iconv libiconv #define iconv_open libiconv_open #define iconv_close libiconv_close #endif #include "../biosig-dev.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #include "structures.h" static const uint8_t _NUM_SECTION = 20; //consider first 19 sections of SCP static bool add_filter = true; // additional filtering gives better shape, but use with care #ifdef __cplusplus extern "C" { #endif #ifndef WITHOUT_SCP_DECODE int scp_decode(HDRTYPE* hdr, struct pointer_section *section, struct DATA_DECODE*, struct DATA_RECORD*, struct DATA_INFO*, bool ); void sopen_SCP_clean(struct DATA_DECODE*, struct DATA_RECORD*, struct DATA_INFO*); #endif // Huffman Tables uint16_t NHT; /* number of Huffman tables */ typedef struct table_t { uint8_t PrefixLength; uint8_t CodeLength; uint8_t TableModeSwitch; int16_t BaseValue; uint32_t BaseCode; } table_t; typedef struct huffman_t { uint16_t NCT; /* number of Code structures in Table #1 */ table_t *Table; } huffman_t; huffman_t *Huffman; typedef struct htree_t { struct htree_t* child0; struct htree_t* child1; uint16_t idxTable; } htree_t; htree_t **HTrees; table_t DefaultTable[19] = { { 1, 1, 1, 0, 0 }, { 3, 3, 1, 1, 1 }, { 3, 3, 1,-1, 5 }, { 4, 4, 1, 2, 3 }, { 4, 4, 1,-2, 11}, { 5, 5, 1, 3, 7 }, { 5, 5, 1,-3, 23}, { 6, 6, 1, 4, 15}, { 6, 6, 1,-4, 47}, { 7, 7, 1, 5, 31}, { 7, 7, 1,-5, 95}, { 8, 8, 1, 6, 63}, { 8, 8, 1,-6, 191}, { 9, 9, 1, 7, 127}, { 9, 9, 1,-7, 383}, {10, 10, 1, 8, 255}, {10, 10, 1,-8, 767}, {18, 10, 1, 0, 511}, {26, 10, 1, 0, 1023} }; /* This structure defines the fields used for "Annotated ECG" */ typedef struct en1064_t { char* test; /* test field for annotated ECG */ float diastolicBloodPressure; float systolicBloodPressure; char* MedicationDrugs; char* ReferringPhysician; char* LatestConfirmingPhysician; char* Diagnosis; uint8_t EmergencyLevel; /* 0: routine 1-10: increased emergency level */ float HeartRate; float P_wave[2]; /* start and end */ float QRS_wave[2]; /* start and end */ float T_wave[2]; /* start and end */ float P_QRS_T_axes[3]; /***** SCP only fields *****/ struct { uint8_t HUFFMAN; uint8_t REF_BEAT; uint8_t DIFF;// OBSOLETE uint8_t BIMODAL;// OBSOLETE } FLAG; struct { //uint8_t tag14[41],tag15[41]; struct { uint16_t INST_NUMBER; /* tag 14, byte 1-2 */ uint16_t DEPT_NUMBER; /* tag 14, byte 3-4 */ uint16_t DEVICE_ID; /* tag 14, byte 5-6 */ uint8_t DeviceType; /* tag 14, byte 7: 0: Cart, 1: System (or Host) */ uint8_t MANUF_CODE; /* tag 14, byte 8 (MANUF_CODE has to be 255) */ char* MOD_DESC; /* tag 14, byte 9 (MOD_DESC has to be "Cart1") */ uint8_t VERSION; /* tag 14, byte 15 (VERSION has to be 20) */ uint8_t PROT_COMP_LEVEL; /* tag 14, byte 16 (PROT_COMP_LEVEL has to be 0xA0 => level II) */ uint8_t LANG_SUPP_CODE; /* tag 14, byte 17 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code) */ uint8_t ECG_CAP_DEV; /* tag 14, byte 18 (ECG_CAP_DEV has to be 0xD0 => Acquire, (No Analysis), Print and Store) */ uint8_t MAINS_FREQ; /* tag 14, byte 19 (MAINS_FREQ has to be 0: unspecified, 1: 50 Hz, 2: 60Hz) */ char reserved[22]; /* char[35-19] reserved; */ char* ANAL_PROG_REV_NUM; char* SERIAL_NUMBER_ACQ_DEV; char* ACQ_DEV_SYS_SW_ID; char* ACQ_DEV_SCP_SW; /* tag 14, byte 38 (SCP_IMPL_SW has to be "OpenECG XML-SCP 1.00") */ char* ACQ_DEV_MANUF; /* tag 14, byte 38 (ACQ_DEV_MANUF has to be "Manufacturer") */ } Tag14, Tag15; } Section1; struct { } Section2; struct { uint8_t NS, flags; struct { uint32_t start; uint32_t end; // uint8_t id; } *lead; } Section3; struct { uint16_t len_ms, fiducial_sample, N; uint32_t SPR; struct { uint16_t btyp; uint32_t SB; uint32_t fcM; uint32_t SE; uint32_t QB; uint32_t QE; } *beat; } Section4; struct { size_t StartPtr; size_t Length; uint16_t AVM, dT_us; uint8_t DIFF; //diff: see FLAG uint16_t *inlen; int32_t *datablock; } Section5; struct { size_t StartPtr; size_t Length; uint16_t AVM, dT_us; uint8_t DIFF, BIMODAL; //diff, bimodal: see FLAG int32_t *datablock; } Section6; } en1064_t; en1064_t en1064; /* new node in Huffman tree */ htree_t* newNode() { htree_t* T = (htree_t*) malloc(sizeof(htree_t)); T->child0 = NULL; T->child1 = NULL; T->idxTable = 0; return(T); } /* check Huffman tree */ int checkTree(htree_t *T) { int v,v1,v2,v3; v1 = (T->child0 == NULL) && (T->child0 == NULL) && (T->idxTable > 0); v2 = (T->idxTable == 0) && (T->child0 != NULL) && checkTree(T->child0); v3 = (T->idxTable == 0) && (T->child1 != NULL) && checkTree(T->child1); v = v1 || v2 || v3; #ifndef ANDROID if (!v) fprintf(stderr,"Warning: Invalid Node in Huffman Tree: %i %p %p\n",T->idxTable,T->child0,T->child1); #endif return(v); } /* convert Huffman Table into a Huffman tree */ htree_t* makeTree(huffman_t HT) { uint16_t k1,k2; htree_t* T = newNode(); htree_t* node; for (k1=0; k1>=1) { if (bc & 0x00000001) { if (node->child1==NULL) node->child1 = newNode(); node = node->child1; } else { if (node->child0==NULL) node->child0 = newNode(); node = node->child0; } } node->idxTable = k1+1; } return(T); } /* get rid of Huffman tree */ void freeTree(htree_t* T) { if (T->child0 != NULL) freeTree(T->child0); if (T->child1 != NULL) freeTree(T->child1); free(T); } int DecodeHuffman(htree_t *HTrees[], huffman_t *HuffmanTables, uint8_t* indata, size_t inlen, int32_t* outdata, size_t outlen) { uint16_t ActualTable = 0; htree_t *node; size_t k1, k2, i; uint32_t acc; int8_t dlen,k3,r; k1=0, k2=0; node = HTrees[ActualTable]; r = 0; i = 0; while ((k1 < inlen*8) && (k2 < outlen)) { r = k1 % 8; i = k1 / 8; if (!node->idxTable) { if (indata[i] & (1<<(7-r))) { if (node->child1 != NULL) node = node->child1; else { return(-1); } } else { if (node->child0 != NULL) node = node->child0; else { return(-1); } } ++k1; } r = k1 % 8; i = k1 / 8; if (node->idxTable) { // leaf of tree reached table_t TableEntry = HuffmanTables[ActualTable].Table[node->idxTable - 1]; dlen = TableEntry.PrefixLength - TableEntry.CodeLength; if (!TableEntry.TableModeSwitch) // switch Huffman Code ActualTable = TableEntry.BaseValue; else if (dlen) { // no compression acc = 0; //(uint32_t)(indata[i]%(1<> (k3*8 - r - dlen)) & ((1L << dlen) - 1L) ; if (outdata[k2] >= (1 << (dlen-1))) outdata[k2] -= 1 << dlen; k1 += dlen; ++k2; } else { // lookup Huffman Table outdata[k2++] = TableEntry.BaseValue; } // reset node to root node = HTrees[ActualTable]; } } return(0); }; void deallocEN1064(en1064_t en1064) { /* free allocated memory */ if (en1064.FLAG.HUFFMAN) { size_t k1=0; for (; k1aECG)).Section1.Tag14.LANG_SUPP_CODE; iconv_t cd; if ((LanguageSupportCode & 0x01) == 0) cd = iconv_open ("UTF-8", "ASCII"); else if ((LanguageSupportCode & 0x03) == 1) cd = iconv_open ("UTF-8", "ISO8859-1"); else if (LanguageSupportCode == 0x03) cd = iconv_open ("UTF-8", "ISO8859-2"); else if (LanguageSupportCode == 0x0b) cd = iconv_open ("UTF-8", "ISO8859-4"); else if (LanguageSupportCode == 0x13) cd = iconv_open ("UTF-8", "ISO8859-5"); else if (LanguageSupportCode == 0x1b) cd = iconv_open ("UTF-8", "ISO8859-6"); else if (LanguageSupportCode == 0x23) cd = iconv_open ("UTF-8", "ISO8859-7"); else if (LanguageSupportCode == 0x2b) cd = iconv_open ("UTF-8", "ISO8859-8"); else if (LanguageSupportCode == 0x33) cd = iconv_open ("UTF-8", "ISO8859-11"); else if (LanguageSupportCode == 0x3b) cd = iconv_open ("UTF-8", "ISO8859-15"); else if (LanguageSupportCode == 0x07) cd = iconv_open ("UTF-8", "ISO-10646"); else if (LanguageSupportCode == 0x0f) // JIS X 0201-1976 (Japanese) - does not match exactly cd = iconv_open ("UTF-8", "EUC-JISX0213"); else if (LanguageSupportCode == 0x17) // JIS X 0208-1997 (Japanese) - does not match exactly cd = iconv_open ("UTF-8", "EUC-JISX0213"); else if (LanguageSupportCode == 0x1f) // JIS X 0212-1990 (Japanese) - does not match exactly cd = iconv_open ("UTF-8", "EUC-JISX0213"); else if (LanguageSupportCode == 0x27) cd = iconv_open ("UTF-8", "GB2312"); else if (LanguageSupportCode == 0x37) cd = iconv_open ("UTF-8", "UTF-8"); else if (LanguageSupportCode == 0x2F) // KS C5601-1987 (Korean) - does not match exactly cd = iconv_open ("UTF-8", "EUC-KR"); else { biosigERROR(hdr, B4C_CHAR_ENCODING_UNSUPPORTED, "SCP character encoding not supported"); return -1; } errno = 0; // reset error status int errsv; if (input[inbytesleft-1]==0) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(%i) decode_scp_text: input=<%s>%i,%i\n", __FILE__, __LINE__, input,(int)inbytesleft,(int)outbytesleft); // input string is 0-terminated iconv(cd, &input, &inbytesleft, &output, &outbytesleft); errsv = errno; } else if (inbytesleft < 64) { /* In case the string is not 0-terminated, * the string is copied to make it 0-terminated */ char buf[64]; char *tmpstr=buf; memcpy(buf,input,inbytesleft); tmpstr[inbytesleft++]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(%i) decode_scp_text: input=<%s>%i,%i\n", __FILE__, __LINE__, input,(int)inbytesleft,(int)outbytesleft); iconv(cd, &tmpstr, &inbytesleft, &output, &outbytesleft); errsv = errno; } else { /* In case the string is not 0-terminated, * the string is copied to make it 0-terminated */ char *tmpstr=malloc(inbytesleft+1); char *bakstr=tmpstr; strncpy(tmpstr,(char*)input,inbytesleft); tmpstr[inbytesleft]=0; inbytesleft++; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(%i) decode_scp_text: input=<%s>%i,%i\n", __FILE__, __LINE__, tmpstr,(int)inbytesleft,(int)outbytesleft); iconv(cd, &tmpstr, &inbytesleft, &output, &outbytesleft); errsv = errno; free(bakstr); } if (errsv) biosigERROR(hdr, B4C_CHAR_ENCODING_UNSUPPORTED, "conversion of SCP text failed"); #ifdef DEBUG if (VERBOSE_LEVEL>7) fprintf(stdout,"%s(%i) decode_scp_text: [e%i ] output=<%s>%i,%i\n", __FILE__, __LINE__, errsv,start,inbytesleft,outbytesleft); #endif return (iconv_close(cd) || errsv); #else // if neither _ICONV_H nor _LIBCONV_H are defined if ((LanguageSupportCode & 0xFE) != 0) { biosigERROR(hdr, B4C_CHAR_ENCODING_UNSUPPORTED, "SCP character encoding not supported"); } else // ASCII encoding is UTF-8 compatible - no convesion needed strncpy(output, input, min(inbytesleft, outbytesleft+1)); return(LanguageSupportCode & 0xFE); #endif } int sopen_SCP_read(HDRTYPE* hdr) { /* this function is a stub or placeholder and need to be defined in order to be useful. It will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ uint8_t* ptr; // pointer to memory mapping of the file layout uint8_t* PtrCurSect; // point to current section uint8_t* Ptr2datablock=NULL; // pointer to data block int32_t* data=NULL; // point to rawdata uint16_t curSect=0; // current section uint32_t len; uint16_t crc; uint32_t i,k1,k2; size_t curSectPos; size_t sectionStart; int NSections = 12; uint8_t tag; float HighPass=0, LowPass=INFINITY, Notch=-1; // filter settings uint16_t Cal5=0, Cal6=0, Cal0=0; // scaling coefficients uint16_t dT_us = 1000; // sampling interval in microseconds /* Try direct conversion SCP->HDR to internal data structure + whole data is loaded once, then no further File I/O is needed. - currently Huffman and Bimodal compression is not supported. */ struct aecg* aECG; en1064.Section5.inlen = NULL; en1064.Section5.datablock = NULL; en1064.Section3.lead = NULL; en1064.Section4.beat = NULL; if (hdr->aECG == NULL) { hdr->aECG = malloc(sizeof(struct aecg)); aECG = (struct aecg*)hdr->aECG; aECG->diastolicBloodPressure=0.0; aECG->systolicBloodPressure=0.0; aECG->MedicationDrugs = NULL; aECG->ReferringPhysician= NULL; aECG->LatestConfirmingPhysician=NULL; aECG->Diagnosis=NULL; aECG->EmergencyLevel=0; } else aECG = (struct aecg*)hdr->aECG; aECG->Section1.Tag14.VERSION = 0; // acquiring.protocol_revision_number aECG->Section1.Tag15.VERSION = 0; // analyzing.protocol_revision_number aECG->Section1.Tag14.LANG_SUPP_CODE = 0; aECG->FLAG.HUFFMAN = 0; aECG->FLAG.DIFF = 0; aECG->FLAG.REF_BEAT = 0; aECG->FLAG.BIMODAL = 0; #if (BIOSIG_VERSION < 10500) aECG->Section8.NumberOfStatements = 0; aECG->Section8.Statements = NULL; aECG->Section11.NumberOfStatements = 0; aECG->Section11.Statements = NULL; #endif en1064.FLAG.HUFFMAN = 0; en1064.FLAG.DIFF = 0; en1064.FLAG.REF_BEAT = 0; en1064.FLAG.BIMODAL = 0; en1064.Section4.len_ms = 0; struct pointer_section section[_NUM_SECTION]; #ifndef WITHOUT_SCP_DECODE struct DATA_DECODE decode; struct DATA_RECORD record; struct DATA_INFO textual; bool AS_DECODE = 0; decode.length_BdR0 = NULL; decode.samples_BdR0= NULL; decode.length_Res = NULL; decode.samples_Res = NULL; decode.t_Huffman=NULL; decode.flag_Huffman=NULL; decode.data_lead=NULL; decode.data_protected=NULL; decode.data_subtraction=NULL; decode.length_BdR0=NULL; decode.samples_BdR0=NULL; decode.Median=NULL; decode.length_Res=NULL; decode.samples_Res=NULL; decode.Residual=NULL; decode.Reconstructed=NULL; //variables inizialization decode.flag_lead.number=0; decode.flag_lead.subtraction=0; decode.flag_lead.all_simultaneously=0; decode.flag_lead.number_simultaneously=0; decode.flag_BdR0.length=0; decode.flag_BdR0.fcM=0; decode.flag_BdR0.AVM=0; decode.flag_BdR0.STM=0; decode.flag_BdR0.number_samples=0; decode.flag_BdR0.encoding=0; decode.flag_Res.AVM=0; decode.flag_Res.STM=0; decode.flag_Res.number=0; decode.flag_Res.number_samples=0; decode.flag_Res.encoding=0; decode.flag_Res.bimodal=0; decode.flag_Res.decimation_factor=0; #endif ptr = hdr->AS.Header; hdr->NRec = 0; sectionStart = 6; PtrCurSect = ptr+sectionStart; /**** SECTION 0 ****/ len = leu32p(PtrCurSect+4); NSections = (len-16)/10; if (memcmp(ptr+16, "SCPECG\0\0", 8)) { fprintf(stderr,"Warning SOPEN (SCP): Bytes 11-16 of Section 0 do not contain SCPECG - this violates ISO/DIS 11073-91064 Section 5.3.2.\n" ); } section[0].ID = 0; section[0].length = len; section[0].index = 6+16; int K; for (K=1; K<_NUM_SECTION; K++) { section[K].ID = -1; section[K].length = 0; section[K].index = 0; } for (K = 1; K < NSections; K++) { // this is needed because fields are not always sorted curSect = leu32p(ptr+6+16+K*10); len = leu32p(ptr+6+16+K*10+2); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): #%d section %d/%d %d %d\n",__FILE__,__LINE__,K,curSect,NSections,leu32p(ptr+6+16+K*10+2),leu32p(ptr+6+16+K*10+6)-1); if (curSect < _NUM_SECTION) { if (section[curSect].ID >= 0) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "SCP Section must not be defined twice"); return -1; } section[curSect].ID = curSect; section[curSect].length = len; section[curSect].index = leu32p(ptr+6+16+K*10+6)-1; } else if (len > 0) fprintf(stderr,"Warning SOPEN (SCP) : vendor specific section %d is not supported\n",curSect); } if (section[1].length) { /**** identify language support code - scan through section 1 for tag 14, byte 17 ****/ K = 1; curSect = section[K].ID; len = section[K].length; sectionStart = section[K].index; PtrCurSect = ptr+sectionStart; crc = leu16p(PtrCurSect); /* uint16_t tmpcrc = CRCEvaluate((uint8_t*)(PtrCurSect+2),len-2); uint8_t versionSection = *(ptr+sectionStart+8); uint8_t versionProtocol = *(ptr+sectionStart+9); */ // future versions might not need to do this, because language encoding is fixed (i.e. known). uint32_t len1; curSectPos = 16; while (curSectPos<=len) { tag = *(PtrCurSect+curSectPos); len1 = leu16p(PtrCurSect+curSectPos+1); curSectPos += 3; if (curSectPos+len1 > len) break; if (tag==14) { aECG->Section1.Tag14.LANG_SUPP_CODE = *(PtrCurSect+curSectPos+16); // tag 14, byte 16 (LANG_SUPP_CODE has to be 0x00 => Ascii only, if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) Language Support Code is 0x%02x\n",__FILE__,__LINE__,aECG->Section1.Tag14.LANG_SUPP_CODE); break; } curSectPos += len1; } } for (K=1; K<_NUM_SECTION; K++) { curSect = section[K].ID; len = section[K].length; sectionStart = section[K].index; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SCP Section %i %i len=%i secStart=%i HeaderLength=%i\n",__FILE__,__LINE__,K,curSect,len,(int)sectionStart,hdr->HeadLen); if (len==0) continue; /***** empty section *****/ if (sectionStart + len > hdr->HeadLen) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "%s (line %i): SOPEN(SCP-READ): File incomplete - Section length + start of section is more then total length of header"); break; } PtrCurSect = ptr+sectionStart; crc = leu16p(PtrCurSect); uint16_t tmpcrc = CRCEvaluate((uint8_t*)(PtrCurSect+2),len-2); uint8_t versionSection = *(ptr+sectionStart+8); uint8_t versionProtocol = *(ptr+sectionStart+9); #ifndef ANDROID if ((crc != 0xffff) && (crc != tmpcrc)) fprintf(stderr,"Warning SOPEN(SCP-READ): faulty CRC in section %i: crc=%x, %x\n" ,curSect,crc,tmpcrc); if (curSect != leu16p(PtrCurSect+2)) fprintf(stderr,"Warning SOPEN(SCP-READ): Current Section No does not match field in sections (%i %i)\n",curSect,leu16p(PtrCurSect+2)); if (len != leu32p(PtrCurSect+4)) fprintf(stderr,"Warning SOPEN(SCP-READ): length field in pointer section (%i) does not match length field in sections (%i %i)\n",K,len,leu32p(PtrCurSect+4)); if ((versionSection != 13) && (versionSection != 20) && (versionSection != (uint8_t)(hdr->Version*10))) fprintf(stderr,"Warning SOPEN(SCP-READ): Version of section %i is not 13 or 20 but %i. This is not tested.\n", curSect, versionSection); if ((versionProtocol != 13) && (versionProtocol != 20) && (versionProtocol != (uint8_t)(hdr->Version*10))) fprintf(stderr,"Warning SOPEN(SCP-READ): Version of Protocol is not 13 or 20 but %i. This is not tested.\n", versionProtocol); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SCP Section %i %i len=%i secStart=%i version=%i %i \n",__FILE__,__LINE__, K, curSect, len, (int)sectionStart,(int)versionSection, (int)versionProtocol); curSectPos = 16; /**** SECTION 0: POINTERS TO DATA AREAS IN THE RECORD ****/ if (curSect==0) { } /**** SECTION 1: HEADER INFORMATION - PATIENT DATA/ECG ACQUISITION DATA ****/ else if (curSect==1) { struct tm t0,t1; t0.tm_year = 0; t0.tm_mon = 0; t0.tm_mday = 0; t0.tm_hour = 0; t0.tm_min = 0; t0.tm_sec = 0; t0.tm_isdst= -1; // daylight savings time - unknown hdr->T0 = 0; hdr->Patient.Birthday = 0; uint32_t len1; while ((curSectPos<=len) && (*(PtrCurSect+curSectPos) < 255)) { tag = *(PtrCurSect+curSectPos); len1 = leu16p(PtrCurSect+curSectPos+1); if (VERBOSE_LEVEL > 7) fprintf(stdout,"SCP(r): Section 1 Tag %i Len %i <%s>\n",tag,len1, (char*)PtrCurSect+curSectPos); curSectPos += 3; if (curSectPos+len1 > len) { #ifndef ANDROID fprintf(stdout,"Warning SCP(read): section 1 corrupted (exceeds file length)\n"); #endif break; } if (tag==0) { // convert to UTF8 if (!hdr->FLAG.ANONYMOUS) { // Last name or entire name if no first name is provided decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, MAX_LENGTH_NAME, hdr->Patient.Name, versionSection); } } else if (tag==1) { if (!hdr->FLAG.ANONYMOUS) { // First name size_t len = strlen(hdr->Patient.Name); if (len+3 < MAX_LENGTH_NAME) { // unit separator ascii(31), 0x1f is used for separating name componentes strcat(hdr->Patient.Name,"\x1f"); len+=1; decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, MAX_LENGTH_NAME-len+1, hdr->Patient.Name+len, versionSection); } } } else if (tag==2) { #ifndef ANDROID if (len1 > MAX_LENGTH_PID) { fprintf(stdout,"Warning SCP(read): length of Patient Id (section1 tag2) exceeds %i>%i\n",len1,MAX_LENGTH_PID); } #endif // convert to UTF8 decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, MAX_LENGTH_PID, hdr->Patient.Id, versionSection); hdr->Patient.Id[MAX_LENGTH_PID] = 0; if (!strcmp(hdr->Patient.Id,"UNKNOWN")) hdr->Patient.Id[0] = 0; } else if (tag==3) { if (!hdr->FLAG.ANONYMOUS) { // Second last name size_t len = strlen(hdr->Patient.Name); if (len+2 < MAX_LENGTH_NAME) { // unit separator ascii(31), 0x1f is used for separating name componentes strcat(hdr->Patient.Name,"\x1f"); len+=1; decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, MAX_LENGTH_NAME-len+1, hdr->Patient.Name+len, versionSection); } } } else if (tag==4) { } else if (tag==5) { t1.tm_year = leu16p(PtrCurSect+curSectPos)-1900; t1.tm_mon = *(PtrCurSect+curSectPos+2)-1; t1.tm_mday = *(PtrCurSect+curSectPos+3); t1.tm_hour = 12; t1.tm_min = 0; t1.tm_sec = 0; t1.tm_isdst= -1; // daylight saving time: unknown // t1.tm_gmtoff = 0; hdr->Patient.Birthday = tm_time2gdf_time(&t1); } else if (tag==6) { hdr->Patient.Height = leu16p(PtrCurSect+curSectPos); } else if (tag==7) { hdr->Patient.Weight = leu16p(PtrCurSect+curSectPos); } else if (tag==8) { hdr->Patient.Sex = *(PtrCurSect+curSectPos); if (hdr->Patient.Sex>2) hdr->Patient.Sex = 0; } else if (tag==9) { } else if (tag==10) { // TODO: convert to UTF8 } else if (tag==11) { aECG->systolicBloodPressure = leu16p(PtrCurSect+curSectPos); } else if (tag==12) { aECG->diastolicBloodPressure = leu16p(PtrCurSect+curSectPos); } else if (tag==13) { // TODO: convert to UTF8 aECG->Diagnosis = (char*)(PtrCurSect+curSectPos); } else if (tag==14) { /* Acquiring Device ID Number */ // TODO: convert to UTF8 #ifndef ANDROID if (len1>85) fprintf(stderr,"Warning SCP(r): length of tag14 %i>40\n",len1); #endif memcpy(hdr->ID.Manufacturer._field,(char*)PtrCurSect+curSectPos,min(len1,MAX_LENGTH_MANUF)); hdr->ID.Manufacturer._field[min(len1,MAX_LENGTH_MANUF)] = 0; hdr->ID.Manufacturer.Model = hdr->ID.Manufacturer._field+8; hdr->ID.Manufacturer.Version = hdr->ID.Manufacturer._field+36; int tmp = strlen(hdr->ID.Manufacturer.Version)+1; hdr->ID.Manufacturer.SerialNumber = hdr->ID.Manufacturer.Version+tmp; tmp += strlen(hdr->ID.Manufacturer.Version+tmp)+1; // skip SW ID tmp += strlen(hdr->ID.Manufacturer.Version+tmp)+1; // skip SW tmp += strlen(hdr->ID.Manufacturer.Version+tmp)+1; // skip SW hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer.Version+tmp; /* might become obsolete */ //memcpy(hdr->aECG->Section1.tag14,PtrCurSect+curSectPos,40); //hdr->VERSION = *(PtrCurSect+curSectPos+14)/10.0; // tag 14, byte 15 aECG->Section1.Tag14.INST_NUMBER = leu16p(PtrCurSect+curSectPos); aECG->Section1.Tag14.DEPT_NUMBER = leu16p(PtrCurSect+curSectPos+2); aECG->Section1.Tag14.DEVICE_ID = leu16p(PtrCurSect+curSectPos+4); aECG->Section1.Tag14.DeviceType = *(PtrCurSect+curSectPos+ 6); aECG->Section1.Tag14.MANUF_CODE = *(PtrCurSect+curSectPos+ 7); // tag 14, byte 7 (MANUF_CODE has to be 255) const char *MANUFACTURER[] = { "unknown","Burdick","Cambridge", "Compumed","Datamed","Fukuda","Hewlett-Packard", "Marquette Electronics","Mortara Instruments", "Nihon Kohden","Okin","Quinton","Siemens","Spacelabs", "Telemed","Hellige","ESA-OTE","Schiller", "Picker-Schwarzer","et medical devices", "Zwönitz",NULL}; if (!strlen(hdr->ID.Manufacturer.Name)) { if (aECG->Section1.Tag14.MANUF_CODE < 21) hdr->ID.Manufacturer.Name = MANUFACTURER[aECG->Section1.Tag14.MANUF_CODE]; else fprintf(stderr,"Warning SOPEN(SCP): unknown manufacturer code\n"); } aECG->Section1.Tag14.MOD_DESC = (char*)(PtrCurSect+curSectPos+8); aECG->Section1.Tag14.VERSION = *(PtrCurSect+curSectPos+14); aECG->Section1.Tag14.PROT_COMP_LEVEL = *(PtrCurSect+curSectPos+15); // tag 14, byte 15 (PROT_COMP_LEVEL has to be 0xA0 => level II) aECG->Section1.Tag14.LANG_SUPP_CODE = *(PtrCurSect+curSectPos+16); // tag 14, byte 16 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code) aECG->Section1.Tag14.ECG_CAP_DEV = *(PtrCurSect+curSectPos+17); // tag 14, byte 17 (ECG_CAP_DEV has to be 0xD0 => Acquire, (No Analysis), Print and Store) aECG->Section1.Tag14.MAINS_FREQ = *(PtrCurSect+curSectPos+18); // tag 14, byte 18 (MAINS_FREQ has to be 0: unspecified, 1: 50 Hz, 2: 60Hz) aECG->Section1.Tag14.ANAL_PROG_REV_NUM = (char*)(PtrCurSect+curSectPos+36); tmp = strlen((char*)(PtrCurSect+curSectPos+36)); aECG->Section1.Tag14.SERIAL_NUMBER_ACQ_DEV = (char*)(PtrCurSect+curSectPos+36+tmp+1); tmp += strlen((char*)(PtrCurSect+curSectPos+36+tmp+1)); aECG->Section1.Tag14.ACQ_DEV_SYS_SW_ID = (char*)(PtrCurSect+curSectPos+36+tmp+1); tmp += strlen((char*)(PtrCurSect+curSectPos+36+tmp+1)); aECG->Section1.Tag14.ACQ_DEV_SCP_SW = (char*)(PtrCurSect+curSectPos+36+tmp+1); // tag 14, byte 38 (SCP_IMPL_SW has to be "OpenECG XML-SCP 1.00") tmp += strlen((char*)(PtrCurSect+curSectPos+36+tmp+1)); aECG->Section1.Tag14.ACQ_DEV_MANUF = (char*)(PtrCurSect+curSectPos+36+tmp+1); // tag 14, byte 38 (ACQ_DEV_MANUF has to be "Manufacturer") if (aECG->Section1.Tag14.LANG_SUPP_CODE & 0xFE) { #if _ICONV_H fprintf(stdout, "Warning SCP-ECG: decoding of text strings not ready yet"); #else biosigERROR(hdr, B4C_CHAR_ENCODING_UNSUPPORTED, "SCP-SCP: Non-ASCII text string language - conversion not supported"); #endif } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): Version %i\n",__FILE__,__LINE__,aECG->Section1.Tag14.VERSION); } else if (tag==15) { /* Analyzing Device ID Number */ // TODO: convert to UTF8 //memcpy(hdr->aECG->Section1.tag15,PtrCurSect+curSectPos,40); aECG->Section1.Tag15.VERSION = *(PtrCurSect+curSectPos+14); } else if (tag==16) { /* Acquiring Institution Description */ size_t outlen = len1*2+1; hdr->ID.Hospital = malloc(outlen); if (hdr->ID.Hospital) { // convert to UTF8 decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, outlen, hdr->ID.Hospital, versionSection); hdr->ID.Hospital[outlen] = 0; } } else if (tag==17) { /* Analyzing Institution Description */ // TODO: convert to UTF8 } else if (tag==18) { /* Acquiring Institution Description */ // TODO: convert to UTF8 } else if (tag==19) { /* Analyzing Institution Description */ // TODO: convert to UTF8 } else if (tag==20) { // TODO: convert to UTF8 aECG->ReferringPhysician = (char*)(PtrCurSect+curSectPos); } else if (tag==21) { // TODO: convert to UTF8 aECG->MedicationDrugs = (char*)(PtrCurSect+curSectPos); } else if (tag==22) { size_t outlen = len1*2+1; hdr->ID.Technician = malloc(outlen); if (hdr->ID.Technician) { // convert to UTF8 decode_scp_text(hdr, len1, (char*)PtrCurSect+curSectPos, outlen, hdr->ID.Technician, versionSection); hdr->ID.Technician[outlen] = 0; } } else if (tag==23) { /* Room Description */ // TODO: convert to UTF8 } else if (tag==24) { aECG->EmergencyLevel = *(PtrCurSect+curSectPos); } else if (tag==25) { t0.tm_year = leu16p(PtrCurSect+curSectPos)-1900; t0.tm_mon = (*(PtrCurSect+curSectPos+2)) - 1; t0.tm_mday = *(PtrCurSect+curSectPos+3); } else if (tag==26) { t0.tm_hour = *(PtrCurSect+curSectPos); t0.tm_min = *(PtrCurSect+curSectPos+1); t0.tm_sec = *(PtrCurSect+curSectPos+2); } else if (tag==27) { HighPass = leu16p(PtrCurSect+curSectPos)/100.0; } else if (tag==28) { LowPass = leu16p(PtrCurSect+curSectPos); } else if (tag==29) { uint8_t bitmap = *(PtrCurSect+curSectPos); if (bitmap==0) Notch = NAN; // undefined else if ((bitmap & 0x03)==0) Notch = -1; // notch off else if (bitmap & 0x01) Notch = 60.0; // notch 60Hz else if (bitmap & 0x02) Notch = 50.0; // notch 50Hz } else if (tag==30) { /* Free Text Field */ // TODO: convert to UTF8 } else if (tag==31) { /* ECG Sequence Number */ // TODO: convert to UTF8 } else if (tag==32) { /* History Diagnostic Codes */ // TODO: convert to UTF8 if (PtrCurSect[curSectPos]==0) { unsigned k=1; for (; k < len1; k++) { if ((PtrCurSect[curSectPos+k] > 9) && (PtrCurSect[curSectPos+k] < 40)) hdr->Patient.Impairment.Heart = 2; else if (PtrCurSect[curSectPos+k]==1) hdr->Patient.Impairment.Heart = 1; else if (PtrCurSect[curSectPos+k]==42) { hdr->Patient.Impairment.Heart = 3; break; } } } } else if (tag==33) { /* Electrode Configuration Code */ // TODO: convert to UTF8 } else if (tag==34) { /* DateTimeZone */ // TODO: convert to UTF8 int16_t tzmin = lei16p(PtrCurSect+curSectPos); if (tzmin != 0x7fff) { if (abs(tzmin)<=780) hdr->tzmin = tzmin; else fprintf(stderr,"Warning SOPEN(SCP-READ): invalid time zone (Section 1, Tag34)\n"); } //fprintf(stdout,"SOPEN(SCP-READ): tzmin = %i %x \n",tzmin,tzmin); } else if (tag==35) { /* Free Text Medical History */ // TODO: convert to UTF8 } else { } curSectPos += len1; } hdr->T0 = tm_time2gdf_time(&t0); } /**** SECTION 2: HUFFMAN TABLES USED IN ENCODING OF ECG DATA (IF USED) ****/ else if (curSect==2) { aECG->FLAG.HUFFMAN = 1; en1064.FLAG.HUFFMAN = 1; NHT = leu16p(PtrCurSect+curSectPos); curSectPos += 2; if (VERBOSE_LEVEL > 7) fprintf(stdout,"SCP(r): Section 2 NHT=%d\n", NHT); if (NHT==19999) { en1064.FLAG.HUFFMAN = 1; Huffman = (huffman_t*)malloc(sizeof(huffman_t)); HTrees = (htree_t**)malloc(sizeof(htree_t*)); Huffman[0].NCT = 19; Huffman[0].Table = DefaultTable; HTrees [0] = makeTree(Huffman[0]); k2 = 0; #ifndef ANDROID if (VERBOSE_LEVEL==9) for (k1=0; k1NS = *(PtrCurSect+curSectPos); aECG->FLAG.REF_BEAT = (*(PtrCurSect+curSectPos+1) & 0x01); en1064.Section3.flags = *(PtrCurSect+curSectPos+1); if (aECG->FLAG.REF_BEAT && (aECG->Section1.Tag14.VERSION > 25)) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "REF-BEAT compression is invalid in SCP v3"); } if (aECG->FLAG.REF_BEAT && !section[4].length) { #ifndef ANDROID fprintf(stderr,"Warning (SCP): Reference Beat but no Section 4\n"); #endif aECG->FLAG.REF_BEAT = 0; } #ifndef ANDROID if (!(en1064.Section3.flags & 0x04) || ((en1064.Section3.flags>>3) != hdr->NS)) fprintf(stderr,"Warning (SCP): channels are not simultaneously recorded! %x %i\n",en1064.Section3.flags,hdr->NS); #endif curSectPos += 2; hdr->CHANNEL = (CHANNEL_TYPE *) realloc(hdr->CHANNEL,hdr->NS* sizeof(CHANNEL_TYPE)); en1064.Section3.lead = (typeof(en1064.Section3.lead))malloc(hdr->NS*sizeof(*en1064.Section3.lead)); uint32_t startindex0; startindex0 = leu32p(PtrCurSect+curSectPos); for (i = 0, hdr->SPR=1; i < hdr->NS; i++) { en1064.Section3.lead[i].start = leu32p(PtrCurSect+curSectPos); en1064.Section3.lead[i].end = leu32p(PtrCurSect+curSectPos+4); uint8_t LeadIdCode = *(PtrCurSect+curSectPos+8); if (LeadIdCode > 184) { // consider this as undefined LeadId LeadIdCode = 0; fprintf(stderr,"Warning (SCP): LeadId of channel %i is %i - which is unspecified\n",i+1, LeadIdCode); } hdr->CHANNEL[i].SPR = en1064.Section3.lead[i].end - en1064.Section3.lead[i].start + 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): SCP Section %i #%i SPR=%d/%d [%d..%d]\n",__FILE__,__LINE__,curSect, i, hdr->CHANNEL[i].SPR, hdr->SPR, en1064.Section3.lead[i].end, en1064.Section3.lead[i].start ); hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[i].SPR); hdr->CHANNEL[i].LeadIdCode = LeadIdCode; hdr->CHANNEL[i].Label[0]= 0; hdr->CHANNEL[i].Transducer[0]= 0; hdr->CHANNEL[i].LowPass = LowPass; hdr->CHANNEL[i].HighPass= HighPass; hdr->CHANNEL[i].Notch = Notch; curSectPos += 9; #ifndef ANDROID if (en1064.Section3.lead[i].start != startindex0) fprintf(stderr,"Warning SCP(read): starting sample %i of #%i differ to %x in #1\n",en1064.Section3.lead[i].start,*(PtrCurSect+curSectPos+8),startindex0); #endif } } /**** SECTION 4: QRS LOCATIONS (IF REFERENCE BEATS ARE ENCODED) ****/ else if (curSect==4) { if (aECG->Section1.Tag14.VERSION > 25) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Section 4 must not be used in SCP v3"); en1064.Section4.len_ms = leu16p(PtrCurSect+curSectPos); // ### TODO: SCPECGv3 ### en1064.Section4.fiducial_sample = leu16p(PtrCurSect+curSectPos+2); // ### TODO: SCPECGv3 ### en1064.Section4.N = leu16p(PtrCurSect+curSectPos+4); // ### TODO: SCPECGv3 ### en1064.Section4.SPR = hdr->SPR/4; en1064.Section4.beat = (typeof(en1064.Section4.beat))malloc(en1064.Section4.N*sizeof(*en1064.Section4.beat)); curSectPos += 6; for (i=0; i < en1064.Section4.N; i++) { en1064.Section4.beat[i].btyp = leu16p(PtrCurSect+curSectPos); en1064.Section4.beat[i].SB = leu32p(PtrCurSect+curSectPos+2); en1064.Section4.beat[i].fcM = leu32p(PtrCurSect+curSectPos+6); en1064.Section4.beat[i].SE = leu32p(PtrCurSect+curSectPos+10); curSectPos += 14; } for (i=0; i < en1064.Section4.N; i++) { en1064.Section4.beat[i].QB = leu32p(PtrCurSect+curSectPos); en1064.Section4.beat[i].QE = leu32p(PtrCurSect+curSectPos+4); curSectPos += 8; en1064.Section4.SPR += en1064.Section4.beat[i].QE-en1064.Section4.beat[i].QB-1; } if (en1064.Section4.len_ms==0) { aECG->FLAG.REF_BEAT = 0; } } /**** SECTION 5: ENCODED REFERENCE BEAT DATA IF REFERENCE BEATS ARE STORED ****/ else if (curSect==5) { Cal5 = leu16p(PtrCurSect+curSectPos); en1064.Section5.AVM = leu16p(PtrCurSect+curSectPos); en1064.Section5.dT_us = leu16p(PtrCurSect+curSectPos+2); en1064.Section5.DIFF = *(PtrCurSect+curSectPos+4); en1064.Section5.Length = (1000L * en1064.Section4.len_ms) / en1064.Section5.dT_us; // hdr->SPR; en1064.Section5.inlen = (typeof(en1064.Section5.inlen))malloc(hdr->NS*2); for (i=0; i < hdr->NS; i++) { en1064.Section5.inlen[i] = leu16p(PtrCurSect+curSectPos+6+2*i); // ### TODO: SCPECGv3 ### if (!section[4].length && (en1064.Section5.Length < en1064.Section5.inlen[i])) en1064.Section5.Length = en1064.Section5.inlen[i]; } if (!section[4].length && en1064.FLAG.HUFFMAN) { en1064.Section5.Length *= 5; // decompressed data might need more space #ifndef ANDROID fprintf(stderr,"Warning SCPOPEN: Section 4 not defined - size of Sec5 can be only guessed (%i allocated)\n",(int)en1064.Section5.Length); #endif } en1064.Section5.datablock = NULL; if (aECG->FLAG.REF_BEAT) { en1064.Section5.datablock = (int32_t*)malloc(4 * hdr->NS * en1064.Section5.Length); Ptr2datablock = (PtrCurSect+curSectPos+6+2*hdr->NS); for (i=0; i < hdr->NS; i++) { en1064.Section5.inlen[i] = leu16p(PtrCurSect+curSectPos+6+2*i); // ### TODO: SCPECGv3 ### if (en1064.FLAG.HUFFMAN) { if (DecodeHuffman(HTrees, Huffman, Ptr2datablock, en1064.Section5.inlen[i], en1064.Section5.datablock + en1064.Section5.Length*i, en1064.Section5.Length)) { biosigERROR(hdr, B4C_DECOMPRESSION_FAILED, "Empty node in Huffman table! Do not know what to do !"); } if (hdr->AS.B4C_ERRNUM) { deallocEN1064(en1064); return(-1); } } else { for (k1=0; k1NS; k1++) for (ix = k1*en1064.Section5.Length+1; ix < (k1+1)*en1064.Section5.Length; ix++) data[ix] += data[ix-1]; else if (en1064.Section5.DIFF==2) for (k1 = 0; k1 < hdr->NS; k1++) for (ix = k1*en1064.Section5.Length+2; ix < (k1+1)*en1064.Section5.Length; ix++) data[ix] += 2*data[ix-1] - data[ix-2]; } } /**** SECTION 6 ****/ else if ((curSect==6) && (section[12].length==0)) { // Read Section6 only if no Section 12 is available hdr->NRec = 1; uint8_t FLAG_HUFFMAN = 0; uint16_t gdftyp = 5; // int32: internal raw data type hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,4 * hdr->NS * hdr->SPR * hdr->NRec); data = (int32_t*)hdr->AS.rawdata; en1064.Section6.AVM = leu16p(PtrCurSect+curSectPos); en1064.Section6.dT_us = leu16p(PtrCurSect+curSectPos+2); hdr->SampleRate = 1e6/en1064.Section6.dT_us; en1064.Section6.DIFF = *(PtrCurSect+curSectPos+4); en1064.FLAG.DIFF = *(PtrCurSect+curSectPos+4); if (hdr->VERSION < 3.0) { en1064.Section6.BIMODAL = *(PtrCurSect+curSectPos+5); en1064.FLAG.BIMODAL = *(PtrCurSect+curSectPos+5); aECG->FLAG.BIMODAL = *(PtrCurSect+curSectPos+5); } else { en1064.Section6.BIMODAL = 0; en1064.FLAG.BIMODAL = 0; aECG->FLAG.BIMODAL = 0; FLAG_HUFFMAN = *(PtrCurSect+curSectPos+5); } Cal6 = leu16p(PtrCurSect+curSectPos); en1064.Section6.dT_us = leu16p(PtrCurSect+curSectPos+2); aECG->FLAG.DIFF = *(PtrCurSect+curSectPos+4); if (VERBOSE_LEVEL>7) fprintf(stdout, "%s (line %i) Compression(Diff=%i Huffman=%i RefBeat=%i Bimodal=%i)\n", __func__, __LINE__, aECG->FLAG.DIFF, aECG->FLAG.HUFFMAN, aECG->FLAG.REF_BEAT, aECG->FLAG.BIMODAL); if ((section[5].length>4) && en1064.Section5.dT_us) dT_us = en1064.Section5.dT_us; else dT_us = en1064.Section6.dT_us; hdr->SampleRate = 1e6/dT_us; typeof(hdr->SPR) SPR = ( en1064.FLAG.BIMODAL ? en1064.Section4.SPR : hdr->SPR); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i\n", __func__ ,__LINE__, dT_us, Cal5, Cal6); if ((Cal5==0) && (Cal6 >0)) Cal0 = Cal6; else if ((Cal5 >0) && (Cal6==0)) Cal0 = Cal5; else if ((Cal5 >0) && (Cal6 >0)) Cal0 = gcd(Cal5,Cal6); else biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "SCP with invalid AVM data !"); uint16_t cal5 = Cal5/Cal0; uint16_t cal6 = Cal6/Cal0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): %i %i %i\n",__func__,__LINE__,dT_us,Cal5,Cal6); Ptr2datablock = (PtrCurSect+curSectPos + 6 + hdr->NS*2); // pointer for huffman decoder len = 0; size_t ix; hdr->AS.bpb = hdr->NS * hdr->SPR*GDFTYP_BITS[gdftyp]>>3; for (i=0; i < hdr->NS; i++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"sec6-%i\n",i); CHANNEL_TYPE *hc = hdr->CHANNEL+i; hc->SPR = hdr->SPR; hc->PhysDimCode = 4275; // PhysDimCode("uV") physical unit "uV" hc->Cal = Cal0 * 1e-3; hc->Off = 0; hc->OnOff = 1; // 1: ON 0:OFF hc->GDFTYP = gdftyp; #ifndef NO_BI hc->bi = i*hdr->SPR*GDFTYP_BITS[gdftyp]>>3; #endif // ### TODO: these values should represent the true saturation values ### // hc->DigMax = ldexp(1.0,20)-1; hc->DigMin = ldexp(-1.0,20); hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; uint16_t inlen = leu16p(PtrCurSect+curSectPos+6+2*i); // ### TODO: SCPECGv3 ### if (en1064.FLAG.HUFFMAN) { if (DecodeHuffman(HTrees, Huffman, Ptr2datablock, inlen, data + i*hdr->SPR, hdr->SPR)) { biosigERROR(hdr, B4C_DECOMPRESSION_FAILED, "Empty node in Huffman table! Do not know what to do !"); } if (hdr->AS.B4C_ERRNUM) { deallocEN1064(en1064); return(-1); } } else { for (k1=0, ix = i*hdr->SPR; k1 < SPR; k1++) data[ix+k1] = lei16p(Ptr2datablock + 2*k1); } len += inlen; Ptr2datablock += inlen; if (aECG->FLAG.DIFF==1) { for (ix = i*hdr->SPR+1; ix < i*hdr->SPR + SPR; ix++) data[ix] += data[ix-1]; } else if (aECG->FLAG.DIFF==2) { for (ix = i*hdr->SPR+2; ix < i*hdr->SPR + SPR; ix++) data[ix] += 2*data[ix-1] - data[ix-2]; } #ifndef WITHOUT_SCP_DECODE if (aECG->FLAG.BIMODAL || aECG->FLAG.REF_BEAT) { // if (aECG->FLAG.BIMODAL) { // if (aECG->FLAG.REF_BEAT { /* this is experimental work Bimodal and RefBeat decompression are under development. "continue" ignores code below AS_DECODE=1 will call later SCP-DECODE instead */ AS_DECODE = 1; continue; } #endif if (aECG->FLAG.BIMODAL) { // ### FIXME ### ix = i*hdr->SPR; // memory offset k1 = en1064.Section4.SPR; // SPR of decimated data k2 = hdr->SPR; // SPR of sample data uint32_t k3 = en1064.Section4.N-1; // # of protected zones uint8_t k4 = 4; // decimation factor do { --k2; data[ix + k2] = data[ix + k1 - 1]; if (k2 > en1064.Section4.beat[k3].QE) { // outside protected zone if (--k4==0) {k4=4; --k1; }; } else { // inside protected zone --k1; if (k20)); } if (aECG->FLAG.REF_BEAT) { /* Add reference beats */ // ### FIXME ### for (k1 = 0; k1 < en1064.Section4.N; k1++) { if (en1064.Section4.beat[k1].btyp == 0) for (ix = 0; ix < en1064.Section5.Length; ix++) { uint32_t ix1 = en1064.Section4.beat[k1].SB - en1064.Section4.beat[k1].fcM + ix; uint32_t ix2 = i*hdr->SPR + ix1; if ((en1064.Section4.beat[k1].btyp==0) && (ix1 < hdr->SPR)) data[ix2] = data[ix2] * cal6 + en1064.Section5.datablock[i*en1064.Section5.Length+ix] * cal5; } } } } en1064.Section6.datablock = data; curSectPos += 6 + 2*hdr->NS + len; if (VERBOSE_LEVEL>8) fprintf(stdout,"end sec6\n"); } /**** SECTION 7 ****/ else if (curSect==7) { #if (BIOSIG_VERSION >= 10500) hdr->SCP.Section7Length = leu32p(PtrCurSect+4)-curSectPos; hdr->SCP.Section7 = PtrCurSect+curSectPos; #endif uint16_t N_QRS = *(uint8_t*)(PtrCurSect+curSectPos)-1; uint8_t N_PaceMaker = *(uint8_t*)(PtrCurSect+curSectPos+1); // uint16_t RRI = leu16p(PtrCurSect+curSectPos+2); // uint16_t PPI = leu16p(PtrCurSect+curSectPos+4); curSectPos += 6; //size_t curSectPos0 = curSectPos; // backup of pointer // skip data on QRS measurements /* // ### FIXME ### It seems that the P,QRS, and T wave events can not be reconstructed because they refer to the reference beat and not to the overall signal data. Maybe Section 4 information need to be used. However, EN1064 does not mention this. hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, (hdr->EVENT.N+5*N_QRS+N_PaceMaker)*sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, (hdr->EVENT.N+5*N_QRS+N_PaceMaker)*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.DUR = (uint32_t*)realloc(hdr->EVENT.DUR, (hdr->EVENT.N+5*N_QRS+N_PaceMaker)*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*)realloc(hdr->EVENT.CHN, (hdr->EVENT.N+5*N_QRS+N_PaceMaker)*sizeof(*hdr->EVENT.CHN)); for (i=0; i < 5*N_QRS; i++) { hdr->EVENT.DUR[hdr->EVENT.N+i] = 0; hdr->EVENT.CHN[hdr->EVENT.N+i] = 0; } for (i=0; i < 5*N_QRS; i+=5) { uint8_t typ = *(PtrCurSect+curSectPos+i); hdr->EVENT.TYP[hdr->EVENT.N] = 0x0502; hdr->EVENT.TYP[hdr->EVENT.N+1] = 0x8502; hdr->EVENT.TYP[hdr->EVENT.N+2] = 0x0503; hdr->EVENT.TYP[hdr->EVENT.N+3] = 0x8503; hdr->EVENT.TYP[hdr->EVENT.N+4] = 0x8506; hdr->EVENT.POS[hdr->EVENT.N] = leu16p(PtrCurSect+curSectPos0); hdr->EVENT.POS[hdr->EVENT.N+1] = leu16p(PtrCurSect+curSectPos0+2); hdr->EVENT.POS[hdr->EVENT.N+2] = leu16p(PtrCurSect+curSectPos0+4); hdr->EVENT.POS[hdr->EVENT.N+3] = leu16p(PtrCurSect+curSectPos0+6); hdr->EVENT.POS[hdr->EVENT.N+4] = leu16p(PtrCurSect+curSectPos0+8); hdr->EVENT.N+= 5; curSectPos0 += 16; } */ curSectPos += N_QRS*16; // pace maker information is stored in sparse sampling channel if (N_PaceMaker>0) { hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, (hdr->EVENT.N+N_PaceMaker)*sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, (hdr->EVENT.N+N_PaceMaker)*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.DUR = (uint32_t*)realloc(hdr->EVENT.DUR, (hdr->EVENT.N+N_PaceMaker)*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*)realloc(hdr->EVENT.CHN, (hdr->EVENT.N+N_PaceMaker)*sizeof(*hdr->EVENT.CHN)); /* add pacemaker channel */ hdr->CHANNEL = (CHANNEL_TYPE *) realloc(hdr->CHANNEL,(++hdr->NS)*sizeof(CHANNEL_TYPE)); i = hdr->NS; CHANNEL_TYPE *hc = hdr->CHANNEL+i; hc->SPR = 0; // sparse event channel hc->PhysDimCode = 4275; // PhysDimCode("uV") physical unit "uV" hc->Cal = 1; hc->Off = 0; hc->OnOff = 1; // 1: ON 0:OFF strcpy(hc->Transducer,"Pacemaker"); hc->GDFTYP = 3; // ### these values should represent the true saturation values ###// hc->DigMax = ldexp(1.0,15)-1; hc->DigMin = ldexp(-1.0,15); hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; } // skip pacemaker spike measurements for (i=0; i < N_PaceMaker; i++) { ++hdr->EVENT.N; hdr->EVENT.TYP[hdr->EVENT.N] = 0x7fff; hdr->EVENT.CHN[hdr->EVENT.N] = hdr->NS; hdr->EVENT.POS[hdr->EVENT.N] = (uint32_t)(leu16p(PtrCurSect+curSectPos)*hdr->SampleRate*1e-3); hdr->EVENT.DUR[hdr->EVENT.N] = leu16p(PtrCurSect+curSectPos+2); curSectPos += 4; } // skip pacemaker spike information section curSectPos += N_PaceMaker*6; // QRS type information N_QRS = leu16p(PtrCurSect+curSectPos); curSectPos += 2; } /**** SECTION 8 ****/ else if (curSect==8) { // TODO: convert to UTF8 #if (BIOSIG_VERSION >= 10500) hdr->SCP.Section8Length = leu32p(PtrCurSect+4)-curSectPos; hdr->SCP.Section8 = PtrCurSect+curSectPos; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %p %d %d %d\n", __func__, __LINE__, hdr->AS.Header, hdr->SCP.Section8Length, (int)curSectPos, (int)(hdr->SCP.Section8-hdr->AS.Header)); #else aECG->Section8.Confirmed = *(char*)(PtrCurSect+curSectPos); aECG->Section8.t.tm_year = leu16p(PtrCurSect+curSectPos+1)-1900; aECG->Section8.t.tm_mon = *(uint8_t*)(PtrCurSect+curSectPos+3)-1; aECG->Section8.t.tm_mday = *(uint8_t*)(PtrCurSect+curSectPos+4); aECG->Section8.t.tm_hour = *(uint8_t*)(PtrCurSect+curSectPos+5); aECG->Section8.t.tm_min = *(uint8_t*)(PtrCurSect+curSectPos+6); aECG->Section8.t.tm_sec = *(uint8_t*)(PtrCurSect+curSectPos+7); aECG->Section8.NumberOfStatements = *(uint8_t*)(PtrCurSect+curSectPos+8); aECG->Section8.Statements= (char**)malloc(aECG->Section8.NumberOfStatements*sizeof(char*)); curSectPos += 9; uint8_t k=0; for (; kSection8.NumberOfStatements;k++) { if (curSectPos+3 > len) break; aECG->Section8.Statements[k] = (char*)(PtrCurSect+curSectPos+3); curSectPos += 3+leu16p(PtrCurSect+curSectPos+1); } #endif } /**** SECTION 9 ****/ else if (curSect==9) { // TODO: convert to UTF8 #if (BIOSIG_VERSION >= 10500) // hdr->SCP.Section9Length = leu32p(PtrCurSect+4)-curSectPos; // hdr->SCP.Section9 = PtrCurSect+curSectPos; #else aECG->Section9.StartPtr = (char*)(PtrCurSect+curSectPos); aECG->Section9.Length = len; #endif } /**** SECTION 10 ****/ else if (curSect==10) { #if (BIOSIG_VERSION >= 10500) hdr->SCP.Section10Length = leu32p(PtrCurSect+4)-curSectPos; hdr->SCP.Section10 = PtrCurSect+curSectPos; #endif } /**** SECTION 11 ****/ else if (curSect==11) { // TODO: convert to UTF8 if(len= 10500) /* hdr->SCP.Section11 = realloc(hdr->SCP.Section11, len); memcpy(hdr->SCP.Section11, PtrCurSect+curSectPos, len); */ hdr->SCP.Section11Length = leu32p(PtrCurSect+4)-curSectPos; hdr->SCP.Section11 = PtrCurSect+curSectPos; #else aECG->Section11.Confirmed = *(char*)(PtrCurSect+curSectPos); aECG->Section11.t.tm_year = leu16p(PtrCurSect+curSectPos+1)-1900; aECG->Section11.t.tm_mon = *(uint8_t*)(PtrCurSect+curSectPos+3)-1; aECG->Section11.t.tm_mday = *(uint8_t*)(PtrCurSect+curSectPos+4); aECG->Section11.t.tm_hour = *(uint8_t*)(PtrCurSect+curSectPos+5); aECG->Section11.t.tm_min = *(uint8_t*)(PtrCurSect+curSectPos+6); aECG->Section11.t.tm_sec = *(uint8_t*)(PtrCurSect+curSectPos+7); aECG->Section11.NumberOfStatements = *(uint8_t*)(PtrCurSect+curSectPos+8); aECG->Section11.Statements= (char**)malloc(aECG->Section11.NumberOfStatements*sizeof(char*)); curSectPos += 9; uint8_t k=0; for (; kSection11.NumberOfStatements;k++) { if (curSectPos+4 > len) break; aECG->Section11.Statements[k] = (char*)(PtrCurSect+curSectPos+4); curSectPos += 3+leu16p(PtrCurSect+curSectPos+1); } #endif } #if defined(WITH_SCP3) /**** SECTION 12 ****/ else if ( (curSect==12) && (versionSection > 25) && (versionProtocol > 25) && (len > 70) ) { uint32_t sec12_LN = leu32p(PtrCurSect+curSectPos+62); uint32_t sec12_LMI= leu32p(PtrCurSect+curSectPos+66); uint32_t sec12_Len1 = 70+sec12_LN+sec12_LMI; uint8_t sec12_FRST = *(PtrCurSect+curSectPos+16); // TODO: get rid of this field, no benefit uint8_t sec12_FBMP = *(PtrCurSect+curSectPos+31); uint16_t gdftyp = 0; uint8_t bps = *(uint8_t*)(PtrCurSect+curSectPos+9); double DigMin = -1.0/0.0; double DigMax = +1.0/0.0; switch (bps) { case 1: gdftyp = 1; break; case 2: gdftyp = 2; break; case 3: gdftyp = 255+24; break; case 4: gdftyp = 5; break; default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "invalid number of bytes per samplein SCP3:Section12"); } DigMin = -ldexp(1.0,bps-1); DigMax = ldexp(1.0,bps-1)-1.0; // TODO: why is this needed, why is Section 1 not good enough ? struct tm t0; t0.tm_year = leu16p(PtrCurSect+curSectPos+10)-1900; t0.tm_mon = (*(PtrCurSect+curSectPos+12)) - 1; t0.tm_mday = *(PtrCurSect+curSectPos+13); t0.tm_hour = *(PtrCurSect+curSectPos+14); t0.tm_min = *(PtrCurSect+curSectPos+15); t0.tm_sec = *(PtrCurSect+curSectPos+16); hdr->T0 = tm_time2gdf_time(&t0); hdr->SampleRate = leu32p(PtrCurSect+curSectPos); hdr->NS = *(uint8_t*)(PtrCurSect+curSectPos+4); hdr->NRec = leu32p(PtrCurSect+curSectPos+5); hdr->SPR = 1; // multiplexed hdr->AS.bpb = bps*hdr->NS; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,4 * hdr->NS * hdr->SPR * hdr->NRec); data = (int32_t*)hdr->AS.rawdata; /* Leads Definition Block */ hdr->CHANNEL = (CHANNEL_TYPE *) realloc(hdr->CHANNEL,hdr->NS* sizeof(CHANNEL_TYPE)); for (i = 0; i < hdr->NS; i++) { CHANNEL_TYPE *hc = hdr->CHANNEL+i; uint8_t LeadIdCode = *(PtrCurSect+curSectPos+sec12_Len1+i*4); if (LeadIdCode > 184) { // consider this as undefined LeadId LeadIdCode = 0; fprintf(stderr,"Warning (SCP): LeadId of channel %i is %i - which is unspecified\n",i+1, LeadIdCode); } hc->bi = bps*i; hc->bi8 = (bps*i)<<3; hc->SPR = 1; hc->LeadIdCode = LeadIdCode; hc->Label[0] = 0; hc->Transducer[0] = 0; hc->OnOff = 1; hc->Impedance = 0.0/0.0; hc->GDFTYP = gdftyp; hc->DigMin = DigMin; hc->DigMax = DigMax; hc->Off = 0.0; hc->Cal = leu16p(PtrCurSect+curSectPos+sec12_Len1+i*4+1)*1e-3; hc->PhysDimCode = 4275; // PhysDimCode("uV") physical unit "uV" hc->PhysMin = DigMin*hc->Cal; hc->PhysMax = DigMax*hc->Cal; if (sec12_FRST) { hc->LowPass = leu16p(PtrCurSect+curSectPos+29); hc->HighPass = leu16p(PtrCurSect+curSectPos+27); hc->Notch = ((sec12_FBMP==0) ? 60 : ((sec12_FBMP==1) ? 50 : NAN)); } else { // From Section 1 tags 27-28 hc->LowPass = LowPass; hc->HighPass = HighPass; hc->Notch = Notch; } } /* size_t sz = GDFTYP_BITS[gdftyp] * hdr->NS * hdr->SPR * hdr->NRec / 8; hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, sz); memcpy(hdr->AS.rawdata, PtrCurSect+curSectPos+sec12_Len1+hdr->NS*4, sz); */ hdr->AS.rawdata = PtrCurSect+curSectPos+sec12_Len1+hdr->NS*4; hdr->AS.first = 0; hdr->AS.length = hdr->SPR*hdr->NRec; } /**** SECTION 13 ****/ else if (curSect==13) { } /**** SECTION 14 ****/ else if (curSect==14) { } /**** SECTION 15 ****/ else if (curSect==15) { } /**** SECTION 16 ****/ else if (curSect==16) { } /**** SECTION 17 ****/ else if (curSect==17) { } /**** SECTION 18 ****/ else if (curSect==18) { } #endif else { } } /* free allocated memory */ deallocEN1064(en1064); return 0; #ifndef WITHOUT_SCP_DECODE if (AS_DECODE==0) return(0); /* --------------------------------------------------------------------------- Copyright (C) 2006 Eugenio Cervesato. Developed at the Associazione per la Ricerca in Cardiologia - Pordenone - Italy, 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- */ /* Fall back method: + implements Huffman, reference beat and Bimodal compression. - uses piece-wise file access - defines intermediate data structure */ #ifndef ANDROID if (VERBOSE_LEVEL > 7) fprintf(stdout, "\nUse SCP_DECODE (Diff=%i Huffman=%i RefBeat=%i Bimodal=%i)\n", aECG->FLAG.DIFF, aECG->FLAG.HUFFMAN, aECG->FLAG.REF_BEAT, aECG->FLAG.BIMODAL); #endif textual.des.acquiring.protocol_revision_number = aECG->Section1.Tag14.VERSION; textual.des.analyzing.protocol_revision_number = aECG->Section1.Tag15.VERSION; decode.flag_Res.bimodal = (aECG->Section1.Tag14.VERSION > 10 ? aECG->FLAG.BIMODAL : 0); decode.Reconstructed = (int32_t*) hdr->AS.rawdata; // TODO: check error handling biosigERROR(hdr, 0, NULL); if (scp_decode(hdr, section, &decode, &record, &textual, add_filter)) { if (Cal0>1) for (i=0; i < hdr->NS * hdr->SPR * hdr->NRec; ++i) data[i] /= Cal0; } else { biosigERROR(hdr, B4C_CANNOT_OPEN_FILE, "SCP-DECODE can not read file"); return(0); } // end of fall back method decode.Reconstructed = NULL; sopen_SCP_clean(&decode, &record, &textual); return(1); #endif }; #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/t210/sopen_heka_read.c0000664000175000017500000010770214105434233020757 0ustar schloeglschloegl/* Copyright (C) 2008-2013,2018 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #ifdef _WIN32 // Can't include sys/stat.h or sopen is declared twice. #include struct stat { _dev_t st_dev; _ino_t st_ino; unsigned short st_mode; short st_nlink; short st_uid; short st_gid; _dev_t st_rdev; _off_t st_size; time_t st_atime; time_t st_mtime; time_t st_ctime; }; int __cdecl stat(const char *_Filename,struct stat *_Stat); #else #include #endif #include "../biosig.h" /* TODO: - need to separate sopen_heka() and sread_heka() - data swapping */ #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) /**************************************************************************** rational : computes the rational approximation of a floating point number such that n/d is an approximation for r with an relative error smaller than tol see Octave's rat.m ****************************************************************************/ void rational (double x, double tol, long *n, long *d) { if (x != x) { // i.e. isnan(x) *n = 0; *d = 0; return; } if (!finite(x)) { *n = x>0; // i.e. sign(x) *d = 0; return; } tol *= fabs(x); *n = lround(x); *d = 1; double frac = x - *n; long lastn = 1, lastd = 0; while (fabs((*d) * x - (*n) ) >= fabs((*d) * tol)) { double flip = 1.0/frac; long step = lround(flip); frac = flip - step; long nextn = *n, nextd = *d; *n = *n * step + lastn; *d = *d * step + lastd; lastn = nextn; lastd = nextd; } if (*d < 0) { *n = - *n; *d = - *d; } } /**************************************************************************** heka2gdftime converts heka time format into gdftime ****************************************************************************/ gdf_time heka2gdftime(double t) { t -= 1580970496; if (t<0) t += 4294967296; t += 9561652096; return (uint64_t)ldexp(t/(24.0*60*60) + 584755, 32); // +datenum(1601,1,1)); } /**************************************************************************** sopen_heka reads heka format if itx is not null, the file is converted into an ITX formated file and streamed to itx, too. ****************************************************************************/ void sopen_heka(HDRTYPE* hdr, FILE *itx) { size_t count = hdr->HeadLen; if (hdr->TYPE==HEKA && hdr->VERSION > 1) { int32_t Levels=0; uint16_t k; //int32_t *Sizes=NULL; int32_t Counts[5], counts[5]; //, Sizes[5]; memset(Counts,0,20); memset(counts,0,20); //memset(Sizes,0,20); uint32_t StartOfData=0,StartOfPulse=0; union { struct { int32_t Root; int32_t Group; int32_t Series; int32_t Sweep; int32_t Trace; } Rec; int32_t all[5]; } Sizes; // HEKA PatchMaster file format count = hdr->HeadLen; struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, FileBuf.st_size); if (count < 1024) count += ifread(hdr->AS.Header+count, 1, 1024-count, hdr); hdr->HeadLen = count; hdr->FILE.LittleEndian = *(uint8_t*)(hdr->AS.Header+52) > 0; char SWAP = ( hdr->FILE.LittleEndian && (__BYTE_ORDER == __BIG_ENDIAN)) \ || (!hdr->FILE.LittleEndian && (__BYTE_ORDER == __LITTLE_ENDIAN)); if (SWAP) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster format requires data swapping - this is not supported yet."); return; } SWAP = 0; // might be useful for compile time optimization /* get file size and read whole file */ count += ifread(hdr->AS.Header+count, 1, FileBuf.st_size - count, hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %i bytes read\n",__FILE__,__LINE__,__func__, (int)count); // double oTime; uint32_t nItems; if (hdr->FILE.LittleEndian) { // oTime = lef64p(hdr->AS.Header+40); // not used nItems = leu32p(hdr->AS.Header+48); } else { // oTime = bef64p(hdr->AS.Header+40); // not used nItems = beu32p(hdr->AS.Header+48); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): nItems=%i\n",__FILE__,__LINE__,__func__, nItems); if (hdr->VERSION == 1) { Sizes.Rec.Root = 544; Sizes.Rec.Group = 128; Sizes.Rec.Series = 1120; Sizes.Rec.Sweep = 160; Sizes.Rec.Trace = 296; } else if (hdr->VERSION == 2) for (k=0; k < min(12,nItems); k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): HEKA nItems=%i\n",__func__,__LINE__, k); uint32_t start = *(uint32_t*)(hdr->AS.Header+k*16+64); uint32_t length = *(uint32_t*)(hdr->AS.Header+k*16+64+4); if (SWAP) { start = bswap_32(start); length = bswap_32(length); } uint8_t *ext = hdr->AS.Header + k*16 + 64 + 8; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): HEKA #%i: <%s> [%i:+%i]\n",__func__,__LINE__,k,ext,start,length); if (!start) break; if ((start+8) > count) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "Heka/Patchmaster: file is corrupted - segment with pulse data is not available!"); return; } if (!memcmp(ext,".pul\0\0\0\0",8)) { // find pulse data ifseek(hdr, start, SEEK_SET); //magic = *(int32_t*)(hdr->AS.Header+start); Levels = *(int32_t*)(hdr->AS.Header+start+4); if (SWAP) Levels = bswap_32(Levels); if (Levels>5) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster format with more than 5 levels not supported"); return; } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i): HEKA #%i Levels=%i\n",__func__,__LINE__,k,Levels); memcpy(Sizes.all,hdr->AS.Header+start+8,sizeof(int32_t)*Levels); if (SWAP) { int l; for (l=0; l < Levels; l++) Sizes.all[l] = bswap_32(Sizes.all[l]); } if (VERBOSE_LEVEL>7) {int l; for (l=0; l < Levels; l++) fprintf(stdout,"%s (line %i): HEKA #%i %i\n",__func__,__LINE__,l, Sizes.all[l]); } StartOfPulse = start + 8 + 4 * Levels; } else if (!memcmp(ext,".dat\0\0\0\0",8)) { StartOfData = start; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): \n",__FILE__,__LINE__,__func__); // if (!Sizes) free(Sizes); Sizes=NULL; /* DONE: HEKA, check channel number and label pass 1: + get number of sweeps + get number of channels + check whether all traces of a single sweep have the same SPR, and Fs + check whether channelnumber (TrAdcChannel), scaling (DataScaler) and Label fit among all sweeps + extract the total number of samples + physical units + level 4 may have no children + count event descriptions Level2/SeLabel pass 2: + initialize data to NAN + skip sweeps if selected channel is not in it + Y scale, physical scale + Event.CodeDescription, Events, resampling */ uint32_t k1=0, k2=0, k3=0, k4=0; uint32_t K1=0, K2=0, K3=0, K4=0, K5=0; double t; size_t pos; // read K1 if (SWAP) { K1 = bswap_32(*(uint32_t*)(hdr->AS.Header + StartOfPulse + Sizes.Rec.Root)); hdr->VERSION = bswap_32(*(uint32_t*)(hdr->AS.Header + StartOfPulse)); union { double f64; uint64_t u64; } c; c.u64 = bswap_64(*(uint64_t*)(hdr->AS.Header + StartOfPulse + 520)); t = c.f64; } else { K1 = (*(uint32_t*)(hdr->AS.Header + StartOfPulse + Sizes.Rec.Root)); hdr->VERSION = (*(uint32_t*)(hdr->AS.Header + StartOfPulse)); t = (*(double*)(hdr->AS.Header + StartOfPulse + 520)); } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): \n",__FILE__,__LINE__,__func__); hdr->T0 = heka2gdftime(t); // this is when when heka was started, data is recorded later. hdr->SampleRate = 0.0; double *DT = NULL; // list of sampling intervals per channel hdr->SPR = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i) %s(...): %p\n",__FILE__,__LINE__,__func__,hdr->EVENT.CodeDesc); /******************************************************************************************************* HEKA: read structural information *******************************************************************************************************/ pos = StartOfPulse + Sizes.Rec.Root + 4; size_t EventN=0; for (k1=0; k17) fprintf(stdout,"HEKA L1 @%i=\t%i/%i \n",(int)(pos+StartOfData),k1,K1); pos += Sizes.Rec.Group+4; // read number of children K2 = (*(uint32_t*)(hdr->AS.Header+pos-4)); hdr->AS.auxBUF = (uint8_t*)realloc(hdr->AS.auxBUF,K2*33); // used to store name of series for (k2=0; k2AS.Header+pos+4); // max 32 bytes strncpy((char*)hdr->AS.auxBUF + 33*k2, (char*)hdr->AS.Header+pos+4, 32); hdr->AS.auxBUF[33*k2+32] = 0; SeLabel = (char*)hdr->AS.auxBUF + 33*k2; double tt = *(double*)(hdr->AS.Header+pos+136); // time of series. TODO: this time should be taken into account Delay.u64 = bswap_64(*(uint64_t*)(hdr->AS.Header+pos+472+176)); gdf_time t = heka2gdftime(tt); if (VERBOSE_LEVEL>7) { char tmp[60]; snprintf_gdfdate(tmp, sizeof(tmp), t); fprintf(stdout,"HEKA L2 @%i=%s %f\t%i/%i %i/%i t=%.17g %s\n",(int)(pos+StartOfData),SeLabel,Delay.f64,k1,K1,k2,K2,ldexp(t,-32),tmp); } pos += Sizes.Rec.Series + 4; // read number of children K3 = (*(uint32_t*)(hdr->AS.Header+pos-4)); if (EventN <= hdr->EVENT.N + K3 + 2) { EventN = max(max(16,EventN),hdr->EVENT.N+K3+2) * 2; if (reallocEventTable(hdr, EventN) == SIZE_MAX) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "Allocating memory for event table failed."); return; }; } if (!hdr->AS.SegSel[0] && !hdr->AS.SegSel[1] && !hdr->AS.SegSel[2]) { // in case of reading the whole file (no sweep selection), include marker for start of series FreeTextEvent(hdr, hdr->EVENT.N, SeLabel); hdr->EVENT.POS[hdr->EVENT.N] = hdr->SPR; // within reading the structure, hdr->SPR is used as a intermediate variable counting the number of samples #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = t; #endif hdr->EVENT.N++; } for (k3=0; k3NRec++; // increase number of sweeps size_t SPR = 0, spr = 0; gdf_time t = heka2gdftime(*(double*)(hdr->AS.Header+pos+48)); // time of sweep. TODO: this should be taken into account if (VERBOSE_LEVEL>7) { char tmp[60]; snprintf_gdfdate(tmp, sizeof(tmp), t); fprintf(stdout,"HEKA L3 @%i= %fHz\t%i/%i %i/%i %i/%i %s\n",(int)(pos+StartOfData),hdr->SampleRate,k1,K1,k2,K2,k3,K3,tmp); } char flagSweepSelected = (hdr->AS.SegSel[0]==0 || k1+1==hdr->AS.SegSel[0]) && (hdr->AS.SegSel[1]==0 || k2+1==hdr->AS.SegSel[1]) && (hdr->AS.SegSel[2]==0 || k3+1==hdr->AS.SegSel[2]); // hdr->SPR if (hdr->SPR==0) hdr->T0 = t; // start time of first recording determines the start time of the recording else if (flagSweepSelected && hdr->SPR > 0) { // marker for start of sweep hdr->EVENT.POS[hdr->EVENT.N] = hdr->SPR; // within reading the structure, hdr->SPR is used as a intermediate variable counting the number of samples hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; #if (BIOSIG_VERSION >= 10500) hdr->EVENT.TimeStamp[hdr->EVENT.N] = t; #endif hdr->EVENT.N++; } pos += Sizes.Rec.Sweep + 4; // read number of children K4 = (*(uint32_t*)(hdr->AS.Header+pos-4)); for (k4=0; k4AS.Header+pos+36)); uint32_t DataPos = (*(uint32_t*)(hdr->AS.Header+pos+40)); spr = (*(uint32_t*)(hdr->AS.Header+pos+44)); double DataScaler= (*(double*)(hdr->AS.Header+pos+72)); double Toffset = (*(double*)(hdr->AS.Header+pos+80)); // time offset of uint16_t pdc = PhysDimCode((char*)(hdr->AS.Header + pos + 96)); double dT = (*(double*)(hdr->AS.Header+pos+104)); //double XStart = (*(double*)(hdr->AS.Header+pos+112)); uint16_t XUnits = PhysDimCode((char*)(hdr->AS.Header+pos+120)); double YRange = (*(double*)(hdr->AS.Header+pos+128)); double YOffset = (*(double*)(hdr->AS.Header+pos+136)); double Bandwidth = (*(double*)(hdr->AS.Header+pos+144)); //double PipetteResistance = (*(double*)(hdr->AS.Header+pos+152)); double RsValue = (*(double*)(hdr->AS.Header+pos+192)); uint8_t ValidYRange = hdr->AS.Header[pos+220]; uint16_t AdcChan = (*(uint16_t*)(hdr->AS.Header+pos+222)); /* obsolete: range is defined by DigMin/DigMax * DataScaler + YOffset double PhysMin = (*(double*)(hdr->AS.Header+pos+224)); double PhysMax = (*(double*)(hdr->AS.Header+pos+232)); */ if (VERBOSE_LEVEL>7) fprintf(stdout, "%s (line %i): %i %i %i %i %i %g %g 0x%x xUnits=%i %g %g %g %g %i %i\n", __FILE__,__LINE__, k1, k2, k3, k4, ns, DataScaler, Toffset, pdc, XUnits, YRange, YOffset, Bandwidth, RsValue, ValidYRange, AdcChan); switch (hdr->AS.Header[pos+70]) { case 0: gdftyp = 3; //int16 /* It seems that the range is 1.024*(2^15-1)/2^15 nA or V and symetric around zero. i.e. YOffset is zero */ DigMax = ldexp(1.0,15) - 1.0; DigMin = -DigMax; break; case 1: gdftyp = 5; //int32 DigMax = ldexp(1.0, 31) - 1.0; DigMin = -DigMax; break; case 2: gdftyp = 16; //float32 DigMax = 1e9; DigMin = -1e9; break; case 3: gdftyp = 17; //float64 DigMax = 1e9; DigMin = -1e9; break; default: DigMax = NAN; DigMin = NAN; biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster: data type not supported"); }; if (SWAP) { AdcChan = bswap_16(AdcChan); ns = bswap_32(ns); DataPos = bswap_32(DataPos); spr = bswap_32(spr); // avoid breaking strict-aliasing rules union { double f64; uint64_t u64; } c; c.f64 = dT; c.u64 = bswap_64(c.u64); dT = c.f64; c.f64 = YRange; c.u64 = bswap_64(c.u64); YRange = c.f64; c.f64 = YOffset; c.u64 = bswap_64(c.u64); YOffset = c.f64; //c.f64 = PhysMax; c.u64 = bswap_64(c.u64); PhysMax = c.f64; //c.f64 = PhysMin; c.u64 = bswap_64(c.u64); PhysMin = c.f64; c.f64 = Toffset; c.u64 = bswap_64(c.u64); Toffset = c.f64; } if (YOffset != 0.0) fprintf(stderr,"!!! WARNING !!! HEKA: the offset is not zero - " "this case is not tested and might result in incorrect scaling of " "the data,\n!!! YOU ARE WARNED !!!\n"); // scale to standard units - no prefix double Cal = DataScaler * PhysDimScale(pdc); double Off = YOffset * PhysDimScale(pdc); pdc &= 0xffe0; float Fs = 1.0 / ( dT * PhysDimScale(XUnits) ) ; // float is used to avoid spurios accuracy, round to single precision accuracy if (flagSweepSelected) { if (hdr->SampleRate <= 0.0) hdr->SampleRate = Fs; if (fabs(hdr->SampleRate - Fs) > 1e-9*Fs) { long DIV1 = 1, DIV2 = 1; rational(hdr->SampleRate*dT*PhysDimScale(XUnits), 1e-6, &DIV2, &DIV1); if (DIV1 > 1) { if ( ((size_t)DIV1 * hdr->SPR) > 0xffffffffffffffff) { fprintf(stderr,"!!! WARNING sopen_heka(%s) !!! due to resampling, the data will have more then 2^31 samples !!!\n", hdr->FileName); biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"HEKA file has more than 2^32 samples - this is not supported yet"); } hdr->SPR *= DIV1; hdr->SampleRate *= DIV1; hdr->EVENT.SampleRate = hdr->SampleRate; size_t n = 0; while (n < hdr->EVENT.N) hdr->EVENT.POS[n++] *= DIV1; } if (DIV2 > 1) spr *= DIV2; } // samples per sweep if (k4==0) SPR = spr; else if (SPR != spr) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster: number of samples among channels within a single sweep do not match."); return; } } char *Label = (char*)hdr->AS.Header+pos+4; for (ns=0; ns < hdr->NS; ns++) { if (!strcmp(hdr->CHANNEL[ns].Label,Label)) break; } if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA L4 @%i= #%i,%i, %s %f %fHz\t%i/%i %i/%i %i/%i %i/%i \n",(int)(pos+StartOfData),ns,AdcChan,Label,hdr->SampleRate,Fs,k1,K1,k2,K2,k3,K3,k4,K4); CHANNEL_TYPE *hc; if (ns >= hdr->NS) { hdr->NS = ns + 1; #ifdef WITH_TIMESTAMPCHANNEL // allocate memory for an extra time stamp channel, which is define only after the end of the channel loop - see below hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, (hdr->NS + 1) * sizeof(CHANNEL_TYPE)); #else hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); #endif hc = hdr->CHANNEL + ns; strncpy(hc->Label, Label, max(32, MAX_LENGTH_LABEL)); hc->Label[max(32,MAX_LENGTH_LABEL)] = 0; hc->Transducer[0] = 0; hc->SPR = 1; hc->PhysDimCode = pdc; hc->OnOff = 1; hc->GDFTYP = gdftyp; hc->LeadIdCode = 0; hc->DigMin = DigMin; hc->DigMax = DigMax; // TODO: case of non-zero YOffset is not tested // hc->PhysMax = DigMax * Cal + Off; hc->PhysMin = DigMin * Cal + Off; hc->Cal = Cal; hc->Off = Off; hc->TOffset = Toffset; #ifndef NDEBUG double Cal2 = (hc->PhysMax - hc->PhysMin) / (hc->DigMax - hc->DigMin); double Off2 = hc->PhysMin - Cal2 * hc->DigMin; double Off3 = hc->PhysMax - Cal2 * hc->DigMax; assert(fabs(Cal-Cal2) < 1e-8 * Cal); assert(fabs(Off-Off2) < 1e-8 * Cal); assert(fabs(Off-Off3) < 1e-8 * Cal); #endif /* TODO: fix remaining channel header */ /* LowPass, HighPass, Notch, Impedance, */ hc->HighPass = NAN; hc->LowPass = (Bandwidth > 0) ? Bandwidth : NAN; hc->Notch = NAN; hc->Impedance = (RsValue > 0) ? RsValue : NAN; DT = (double*) realloc(DT, hdr->NS*sizeof(double)); DT[ns] = dT; } else { /* channel has been already defined in earlier sweep. check compatibility and adapt internal format when needed */ hc = hdr->CHANNEL + ns; double PhysMax = DigMax * Cal + Off; double PhysMin = DigMin * Cal + Off; // get max value to avoid false positive saturation detection when scaling changes if (hc->PhysMax < PhysMax) hc->PhysMax = PhysMax; if (hc->PhysMin > PhysMin) hc->PhysMin = PhysMin; if (hc->GDFTYP < gdftyp) { /* when data type changes, use the largest data type */ if (4 < hc->GDFTYP && hc->GDFTYP < 9 && gdftyp==16) /* (U)INT32, (U)INT64 + FLOAT32 -> DOUBLE */ hc->GDFTYP = 17; else hc->GDFTYP = gdftyp; } else if (hc->GDFTYP > gdftyp) { /* when data type changes, use the largest data type */ if (4 < gdftyp && gdftyp < 9 && hc->GDFTYP==16) /* (U)INT32, (U)INT64 + FLOAT32 -> DOUBLE */ hc->GDFTYP = 17; } if (fabs(hc->Cal - Cal) > 1e-9*Cal) { /* when scaling changes from sweep to sweep, use floating point numbers internally. */ if (hc->GDFTYP < 5) // int16 or smaller hc->GDFTYP = 16; else if (hc->GDFTYP < 9) // int32, int64 -> double hc->GDFTYP = 17; } if ((pdc & 0xFFE0) != (hc->PhysDimCode & 0xFFE0)) { fprintf(stdout, "ERROR: [%i,%i,%i,%i] Yunits in %s do not match %04x(%s) ! %04x(%s)\n",k1,k2,k3,k4, Label, pdc, PhysDim3(pdc), hc->PhysDimCode, PhysDim3(hc->PhysDimCode)); biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster: Yunits do not match"); } if ( ( VERBOSE_LEVEL > 7 ) && ( fabs( DT[ns] - dT) > 1e-9 * dT) ) { fprintf(stdout, "%s (line %i) different sampling rates [%i,%i,%i,%i]#%i,%f/%f \n",__FILE__,__LINE__,(int)k1,(int)k2,(int)k3,(int)k4,(int)ns, 1.0/DT[ns],1.0/dT); } } if (YOffset) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster: YOffset is not zero"); } if (hdr->AS.Header[pos+220] != 1) { fprintf(stderr,"WARNING Heka/Patchmaster: ValidYRange not set to 1 but %i in sweep [%i,%i,%i,%i]\n", hdr->AS.Header[pos+220],k1+1,k2+1,k3+1,k4+1); } if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA L6 @%i= #%i,%i, %s %f-%fHz\t%i/%i %i/%i %i/%i %i/%i \n",(int)(pos+StartOfData),ns,AdcChan,Label,hdr->SampleRate,Fs,k1,K1,k2,K2,k3,K3,k4,K4); pos += Sizes.Rec.Trace+4; // read number of children -- this should be 0 - ALWAYS; K5 = (*(uint32_t*)(hdr->AS.Header+pos-4)); if (K5) { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster: Level 4 has some children"); } } // end loop k4 // if sweep is selected, add number of samples to counter if (flagSweepSelected) { if ( hdr->SPR > 0xffffffffffffffffu-SPR) { biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"HEKA file has more than 2^32 samples - this is not supported yet"); } hdr->SPR += SPR; } } // end loop k3 } // end loop k2 } // end loop k1 #ifndef NO_BI if (DT) free(DT); #else size_t *BI = (size_t*) DT; // DT is not used anymore, use space for BI #endif DT = NULL; #ifdef WITH_TIMESTAMPCHANNEL { /* define time stamp channel, memory is already allocated above */ CHANNEL_TYPE *hc = hdr->CHANNEL + hdr->NS; hc->GDFTYP = 7; // corresponds to int64_t, gdf_time strcpy(hc->Label,"Timestamp"); hc->Transducer[0]=0; hc->PhysDimCode = 2272; // units: days [d] hc->LeadIdCode = 0; hc->SPR = 1; hc->Cal = ldexp(1.0, -32); hc->Off = 0.0; hc->OnOff = 1; hc->DigMax = ldexp( 1.0, 61); hc->DigMin = 0; hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; hc->TOffset = 0.0; hc->Impedance = NAN; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; hdr->NS++; } #endif hdr->NRec = 1; hdr->AS.bpb = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->Cal = (hc->PhysMax - hc->PhysMin) / (hc->DigMax - hc->DigMin); hc->Off = hc->PhysMin - hc->DigMin * hc->Cal; #ifndef NO_BI hc->bi = hdr->AS.bpb; #else BI[k] = hdr->AS.bpb; #endif hc->SPR = hdr->SPR; hdr->AS.bpb += hc->SPR * (GDFTYP_BITS[hc->GDFTYP]>>3); // multiplation must not exceed 32 bit limit } if (hdr->AS.B4C_ERRNUM) { #ifdef NO_BI if (BI) free(BI); #endif return; } hdr->ID.Manufacturer.Name = "HEKA/Patchmaster"; /****************************************************************************** SREAD_HEKA void sread_heka(HDRTYPE* hdr, FILE *itx, ... ) { ******************************************************************************/ if (VERBOSE_LEVEL > 7) fprintf(stdout,"HEKA: 400: %"PRIi64" %"PRIi32" %"PRIi64"\n",hdr->NRec, hdr->AS.bpb, hdr->NRec * (size_t)hdr->AS.bpb); size_t sz = hdr->NRec * (size_t)hdr->AS.bpb; if (sz/hdr->NRec < hdr->AS.bpb) { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "memory allocation failed - more than 2GB required but platform supports only 32 bit!"); return; } void* tmpptr = realloc(hdr->AS.rawdata, sz); if (tmpptr!=NULL) hdr->AS.rawdata = (uint8_t*) tmpptr; else { biosigERROR(hdr, B4C_MEMORY_ALLOCATION_FAILED, "memory allocation failed - not enough memory!"); return; } assert(hdr->NRec >= 0); memset(hdr->AS.rawdata, 0xff, hdr->NRec * (size_t)hdr->AS.bpb); // initialize with NAN's #ifdef NO_BI #define _BI (BI[k]) #else #define _BI (hc->bi) #endif /* initialize with NAN's */ for (k=0; kNS; k++) { size_t k1; CHANNEL_TYPE *hc = hdr->CHANNEL+k; switch (hc->GDFTYP) { case 3: for (k1=0; k1SPR; k1++) { *(uint16_t*)(hdr->AS.rawdata + _BI + k1 * 2) = 0x8000; } break; case 5: for (k1=0; k1SPR; k1++) *(uint32_t*)(hdr->AS.rawdata + _BI + k1 * 4) = 0x80000000; break; case 7: for (k1=0; k1SPR; k1++) *(int64_t*)(hdr->AS.rawdata + _BI + k1 * 4) = 0x8000000000000000LL; break; case 16: for (k1=0; k1SPR; k1++) *(float*)(hdr->AS.rawdata + _BI + k1 * 4) = NAN; break; case 17: for (k1=0; k1SPR; k1++) *(double*)(hdr->AS.rawdata + _BI + k1 * 8) = NAN; break; } } #undef _BI char *WAVENAME = NULL; if (itx) { fprintf(itx, "IGOR\r\nX Silent 1\r\n"); const char *fn = strrchr(hdr->FileName,'\\'); if (fn) fn++; else fn = strrchr(hdr->FileName,'/'); if (fn) fn++; else fn = hdr->FileName; size_t len = strspn(fn,"."); WAVENAME = (char*)malloc(strlen(hdr->FileName)+7); if (len) strncpy(WAVENAME, fn, len); else strcpy(WAVENAME, fn); // Flawfinder: ignore } if (VERBOSE_LEVEL>7) hdr2ascii(hdr,stdout,4); /******************************************************************************************************* HEKA: read data blocks *******************************************************************************************************/ uint32_t SPR = 0; pos = StartOfPulse + Sizes.Rec.Root + 4; for (k1=0; k17) fprintf(stdout,"HEKA+L1 @%i=\t%i/%i \n",(int)(pos+StartOfData),k1,K1); pos += Sizes.Rec.Group+4; // read number of children K2 = (*(uint32_t*)(hdr->AS.Header+pos-4)); for (k2=0; k2AS.Header+pos+4); // max 32 bytes Delay.u64 = bswap_64(*(uint64_t*)(hdr->AS.Header+pos+472+176)); if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA+L2 @%i=%s %f\t%i/%i %i/%i \n",(int)(pos+StartOfData),SeLabel,Delay.f64,k1,K1,k2,K2); /* move to reading of data */ pos += Sizes.Rec.Series+4; // read number of children K3 = (*(uint32_t*)(hdr->AS.Header+pos-4)); for (k3=0; k3NS-1]) #else #define _BI (hdr->CHANNEL[hdr->NS-1].bi) #endif gdf_time t = heka2gdftime(*(double*)(hdr->AS.Header+pos+48)); // time of sweep. TODO: this should be taken into account *(int64_t*)(hdr->AS.rawdata + _BI + SPR * 8) = t; #undef _BI #endif // WITH_TIMESTAMPCHANNEL // read sweep char flagSweepSelected = (hdr->AS.SegSel[0]==0 || k1+1==hdr->AS.SegSel[0]) && (hdr->AS.SegSel[1]==0 || k2+1==hdr->AS.SegSel[1]) && (hdr->AS.SegSel[2]==0 || k3+1==hdr->AS.SegSel[2]); if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA+L3 @%i=\t%i/%i %i/%i %i/%i sel=%i\n",(int)(pos+StartOfData),k1,K1,k2,K2,k3,K3,flagSweepSelected); pos += Sizes.Rec.Sweep + 4; // read number of children K4 = (*(uint32_t*)(hdr->AS.Header+pos-4)); size_t DIV=1; for (k4=0; k4AS.Header+pos+36)); uint32_t DataPos = (*(uint32_t*)(hdr->AS.Header+pos+40)); spr = (*(uint32_t*)(hdr->AS.Header+pos+44)); double DataScaler= (*(double*)(hdr->AS.Header+pos+72)); double Toffset = (*(double*)(hdr->AS.Header+pos+80)); // time offset of uint16_t pdc = PhysDimCode((char*)(hdr->AS.Header + pos + 96)); char *physdim = (char*)(hdr->AS.Header + pos + 96); double dT = (*(double*)(hdr->AS.Header+pos+104)); // double XStart = (*(double*)(hdr->AS.Header+pos+112)); // uint16_t XUnits = PhysDimCode((char*)(hdr->AS.Header+pos+120)); double YRange = (*(double*)(hdr->AS.Header+pos+128)); double YOffset = (*(double*)(hdr->AS.Header+pos+136)); // double Bandwidth = (*(double*)(hdr->AS.Header+pos+144)); uint16_t AdcChan = (*(uint16_t*)(hdr->AS.Header+pos+222)); /* double PhysMin = (*(double*)(hdr->AS.Header+pos+224)); double PhysMax = (*(double*)(hdr->AS.Header+pos+232)); */ switch (hdr->AS.Header[pos+70]) { case 0: gdftyp = 3; break; // int16 case 1: gdftyp = 5; break; // int32 case 2: gdftyp = 16; break; // float32 case 3: gdftyp = 17; break; // float64 default: biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster unknown data type is used"); }; if (SWAP) { AdcChan = bswap_16(AdcChan); ns = bswap_32(ns); DataPos = bswap_32(DataPos); spr = bswap_32(spr); // avoid breaking strict-aliasing rules union { double f64; uint64_t u64; } c; c.f64 = dT; c.u64 = bswap_64(c.u64); dT = c.f64; c.f64 = YRange; c.u64 = bswap_64(c.u64); YRange = c.f64; c.f64 = YOffset; c.u64 = bswap_64(c.u64); YOffset = c.f64; /* c.f64 = PhysMax; c.u64 = bswap_64(c.u64); PhysMax = c.f64; c.f64 = PhysMin; c.u64 = bswap_64(c.u64); PhysMin = c.f64; */ c.f64 = Toffset; c.u64 = bswap_64(c.u64); Toffset = c.f64; } double Fs = round(1.0 / dT); DIV = round(hdr->SampleRate / Fs); char *Label = (char*)(hdr->AS.Header+pos+4); for (ns=0; ns < hdr->NS; ns++) { if (!strcmp(hdr->CHANNEL[ns].Label, Label)) break; } CHANNEL_TYPE *hc = hdr->CHANNEL+ns; if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA+L4 @%i= #%i,%i,%i/%i %s\t%i/%i %i/%i %i/%i %i/%i DIV=%i,%i,%i\n",(int)(pos+StartOfData),ns,AdcChan,spr,SPR,Label,k1,K1,k2,K2,k3,K3,k4,K4,(int)DIV,gdftyp,hc->GDFTYP); if (itx) { uint32_t k5; double Cal = DataScaler; assert(hdr->CHANNEL[ns].Off==0.0); double Off = 0.0; fprintf(itx, "\r\nWAVES %s_%i_%i_%i_%i\r\nBEGIN\r\n", WAVENAME,k1+1,k2+1,k3+1,k4+1); switch (hc->GDFTYP) { case 3: for (k5 = 0; k5 < spr; ++k5) fprintf(itx,"% e\n", (double)*(int16_t*)(hdr->AS.Header + DataPos + k5 * 2) * Cal + Off); break; case 5: for (k5 = 0; k5 < spr; ++k5) fprintf(itx,"% e\n", (double)*(int32_t*)(hdr->AS.Header + DataPos + k5 * 4) * Cal + Off); break; case 16: for (k5 = 0; k5 < spr; ++k5) fprintf(itx,"% e\n", (double)*(float*)(hdr->AS.Header + DataPos + k5 * 4) * Cal + Off); break; case 17: for (k5 = 0; k5 < spr; ++k5) fprintf(itx,"% e\n", *(double*)(hdr->AS.Header + DataPos + k5 * 8) * Cal + Off); break; } fprintf(itx, "END\r\nX SetScale/P x, %g, %g, \"s\", %s_%i_%i_%i_%i\r\n", Toffset, dT, WAVENAME, k1+1,k2+1,k3+1,k4+1); fprintf(itx, "X SetScale y,0,0,\"%s\", %s_%i_%i_%i_%i\n", physdim, WAVENAME, k1+1,k2+1,k3+1,k4+1); } #ifdef NO_BI #define _BI (BI[ns]) #else #define _BI (hc->bi) #endif // no need to check byte order because File.Endian is set and endian conversion is done in sread if ((DIV==1) && (gdftyp == hc->GDFTYP)) { uint16_t sz = GDFTYP_BITS[hc->GDFTYP]>>3; memcpy(hdr->AS.rawdata + _BI + SPR * sz, hdr->AS.Header + DataPos, spr * sz); } else if (1) { double Cal = DataScaler * PhysDimScale(pdc) / hdr->CHANNEL[ns].Cal; assert(Cal==1.0 || hc->GDFTYP > 15); // when scaling changes, target data type is always float/double -> see above uint32_t k5,k6; switch (gdftyp) { case 3: switch (hc->GDFTYP) { case 3: for (k5 = 0; k5 < spr; ++k5) { int16_t ival = *(int16_t*)(hdr->AS.Header + DataPos + k5 * 2); for (k6 = 0; k6 < DIV; ++k6) *(int16_t*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 2) = ival; } break; case 5: for (k5 = 0; k5 < spr; ++k5) { int16_t ival = *(int16_t*)(hdr->AS.Header + DataPos + k5 * 2); for (k6 = 0; k6 < DIV; ++k6) *(int32_t*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 4) = (int32_t)ival; } break; case 16: for (k5 = 0; k5 < spr; ++k5) { int16_t ival = *(int16_t*)(hdr->AS.Header + DataPos + k5 * 2); for (k6 = 0; k6 < DIV; ++k6) *(float*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 4) = (float)ival * Cal; } break; case 17: for (k5 = 0; k5 < spr; ++k5) { int16_t ival = *(int16_t*)(hdr->AS.Header + DataPos + k5 * 2); for (k6 = 0; k6 < DIV; ++k6) *(double*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 8) = (double)ival * Cal; } break; } break; case 5: switch (hc->GDFTYP) { case 5: for (k5 = 0; k5 < spr; ++k5) { int32_t ival = *(int32_t*)(hdr->AS.Header + DataPos + k5 * 4); for (k6 = 0; k6 < DIV; ++k6) *(int32_t*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 4) = ival; } break; case 16: for (k5 = 0; k5 < spr; ++k5) { int32_t ival = *(int32_t*)(hdr->AS.Header + DataPos + k5 * 4); for (k6 = 0; k6 < DIV; ++k6) *(float*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 4) = (float)ival * Cal; } break; case 17: for (k5 = 0; k5 < spr; ++k5) { int32_t ival = *(int32_t*)(hdr->AS.Header + DataPos + k5 * 4); for (k6 = 0; k6 < DIV; ++k6) *(double*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 8) = (double)ival * Cal; } break; } break; case 16: switch (hc->GDFTYP) { case 16: for (k5 = 0; k5 < spr; ++k5) { float ival = *(float*)(hdr->AS.Header + DataPos + k5 * 4); for (k6 = 0; k6 < DIV; ++k6) *(float*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 4) = ival * Cal; } break; case 17: for (k5 = 0; k5 < spr; ++k5) { float ival = *(float*)(hdr->AS.Header + DataPos + k5 * 4); for (k6 = 0; k6 < DIV; ++k6) *(double*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 8) = (double)ival * Cal; } break; } break; case 17: switch (hc->GDFTYP) { case 17: for (k5 = 0; k5 < spr; ++k5) { double ival = *(double*)(hdr->AS.Header + DataPos + k5 * 8); for (k6 = 0; k6 < DIV; ++k6) *(double*)(hdr->AS.rawdata + _BI + (SPR + k5*DIV + k6) * 8) = ival * Cal; } break; } break; } } #undef _BI pos += Sizes.Rec.Trace+4; } if (flagSweepSelected) SPR += spr * DIV; } } } #ifdef NO_BI if (BI) free(BI); #endif hdr->AS.first = 0; hdr->AS.length = hdr->NRec; free(hdr->AS.Header); hdr->AS.Header = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"End of SOPEN_HEKA\n"); } else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Heka/Patchmaster format has unsupported version number"); } } #ifdef __cplusplus } #endif biosig-2.3.3/biosig4c++/t210/structures.h0000664000175000017500000002017314105434233020074 0ustar schloeglschloegl/* --------------------------------------------------------------------------- Copyright (C) 2014 Alois Schloegl Copyright (C) 2003 Eugenio Cervesato & Giorgio De Odorico. Developed at the Associazione per la Ricerca in Cardiologia - Pordenone - Italy. 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- */ // structures.h header file #ifndef __STRUCTURES_H__ #define __STRUCTURES_H__ #include /* // obsolete definition #define int_S int8_t #define int_M int16_t #define int_L int32_t #define U_int_S uint8_t #define U_int_M uint16_t #define U_int_L uint32_t #define dec_S float #define dec_M double #define dec_L long double */ #define str char #define bool char #define true 1 #define false 0 #define TRUE 1 #define FALSE 0 struct alfabetic { uint16_t number; const char *sentence; }; struct numeric { uint16_t value; uint8_t unit; }; struct section_header { uint16_t CRC; uint16_t ID; uint32_t length; uint8_t version; uint8_t protocol_version; char *word; }; struct file_header { uint16_t CRC; uint32_t length; }; struct pointer_section { uint32_t index; int16_t ID; uint32_t length; }; struct device_info { uint16_t institution_number; uint16_t department_number; uint16_t ID; uint8_t type; uint8_t manifacturer; char *model_description; uint8_t protocol_revision_number; uint8_t category; uint8_t language; uint8_t capability[4]; uint8_t AC; char *analysing_program_revision_number; char *serial_number_device; char *device_system_software; char *device_SCP_implementation_software; char *manifacturer_trade_name; }; struct info_drug { uint8_t table; uint8_t classes; uint8_t drug_code; uint16_t length; }; struct Time_Zone { int16_t offset; uint16_t index; const char *description; }; struct demographic { char *first_name; char *last_name; char *ID; char *second_last_name; struct numeric age; time_t date_birth2; // by E.C. feb 2006 struct numeric height; struct numeric weight; uint8_t sex; uint8_t race; uint16_t systolic_pressure; uint16_t diastolic_pressure; }; struct clinic { uint16_t number_drug; struct info_drug *drug; char *text_drug; uint16_t number_diagnose; struct numeric *diagnose; char *text_diagnose; char *referring_physician; char *latest_confirming_physician; char *technician_description; uint16_t number_text; struct numeric *free_text; char *text_free_text; uint16_t number_hystory; struct numeric *medical_hystory; uint16_t number_free_hystory; struct numeric *free_medical_hystory; char *text_free_medical_hystory; }; struct descriptive { struct device_info acquiring; struct device_info analyzing; char *acquiring_institution; char *analyzing_institution; char *acquiring_department; char *analyzing_department; char *room; uint8_t stat_code; }; struct device { time_t date_acquisition2; // by E.C. feb 2006 time_t time_acquisition2; // by E.C. feb 2006 uint16_t baseline_filter; uint16_t lowpass_filter; uint8_t other_filter[4]; char *sequence_number; struct numeric electrode_configuration; struct Time_Zone TZ; }; struct table_H { uint8_t bit_prefix; uint8_t bit_code; uint8_t TMS; int16_t base_value; uint32_t base_code; }; struct f_lead { uint8_t number; bool subtraction; bool all_simultaneously; uint8_t number_simultaneously; }; struct lead { uint8_t ID; uint32_t start; uint32_t end; }; struct Subtraction_Zone { uint16_t beat_type; uint32_t SB; uint32_t fc; uint32_t SE; }; struct Protected_Area { uint32_t QB; uint32_t QE; }; struct f_BdR0 { uint16_t length; uint16_t fcM; uint16_t AVM; uint16_t STM; uint16_t number_samples; uint8_t encoding; }; struct f_Res { uint16_t AVM; uint16_t STM; uint16_t number; uint16_t number_samples; uint8_t encoding; bool bimodal; uint8_t decimation_factor; }; struct spike { uint16_t time; int16_t amplitude; uint8_t type; uint8_t source; uint8_t index; uint16_t pulse_width; }; struct global_measurement { uint8_t number; uint16_t number_QRS; uint8_t number_spike; uint16_t average_RR; uint16_t average_PP; uint16_t ventricular_rate; uint16_t atrial_rate; uint16_t QT_corrected; uint8_t formula_type; uint16_t number_tag; }; struct additional_measurement { uint8_t ID; uint8_t byte[5]; }; struct BdR_measurement { uint16_t P_onset; uint16_t P_offset; uint16_t QRS_onset; uint16_t QRS_offset; uint16_t T_offset; int16_t P_axis; int16_t QRS_axis; int16_t T_axis; }; struct info { uint8_t type; char *date; char *time; uint8_t number; }; struct header_lead_measurement { uint16_t number_lead; uint16_t number_lead_measurement; }; struct lead_measurement_block { uint16_t ID; int16_t P_duration; int16_t PR_interval; int16_t QRS_duration; int16_t QT_interval; int16_t Q_duration; int16_t R_duration; int16_t S_duration; int16_t R1_duration; int16_t S1_duration; int16_t Q_amplitude; int16_t R_amplitude; int16_t S_amplitude; int16_t R1_amplitude; int16_t S1_amplitude; int16_t J_point_amplitude; int16_t Pp_amplitude; int16_t Pm_amplitude; int16_t Tp_amplitude; int16_t Tm_amplitude; int16_t ST_slope; int16_t P_morphology; int16_t T_morphology; int16_t iso_electric_segment_onset_QRS; int16_t iso_electric_segment_offset_QRS; int16_t intrinsicoid_deflection; uint16_t quality_recording[8]; int16_t ST_amplitude_Jplus20; int16_t ST_amplitude_Jplus60; int16_t ST_amplitude_Jplus80; int16_t ST_amplitude_JplusRR16; int16_t ST_amplitude_JplusRR8; }; struct statement_coded { uint8_t sequence_number; uint16_t length; uint8_t type; uint16_t number_field; }; //_____________________________________ //structs for sections: 2, 3, 4, 5, 6 //_____________________________________ struct DATA_DECODE { struct table_H *t_Huffman; uint16_t *flag_Huffman; struct lead *data_lead; struct f_lead flag_lead; struct Protected_Area *data_protected; struct Subtraction_Zone *data_subtraction; struct f_BdR0 flag_BdR0; uint16_t *length_BdR0; uint8_t *samples_BdR0; int32_t *Median; struct f_Res flag_Res; uint16_t *length_Res; uint8_t *samples_Res; int32_t *Residual; int32_t *Reconstructed; }; struct TREE_NODE //struttura di un nodo dell'albero { struct TREE_NODE *next_0; struct TREE_NODE *next_1; int16_t row; }; //_____________________________________ //structs for sections: 7, 10 //_____________________________________ struct DATA_RECORD { struct global_measurement data_global; struct spike *data_spike; uint8_t *type_BdR; struct BdR_measurement *data_BdR; struct additional_measurement *data_additional; struct header_lead_measurement header_lead; struct lead_measurement_block *lead_block; }; //_____________________________________ //structs for sections: 1, 8, 11 //_____________________________________ struct DATA_INFO { struct demographic ana; struct clinic cli; struct descriptive des; struct device dev; struct info flag_report; struct numeric *text_dim; char *text_report; struct info flag_statement; struct statement_coded *data_statement; char *text_statement; }; #endif /*__STRUCTURES_H__*/ //_____________________________________ biosig-2.3.3/biosig4c++/t210/sopen_abf_read.c0000664000175000017500000014047614105434233020604 0ustar schloeglschloegl/* Copyright (C) 2012-2019,2021 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include #include "../biosig.h" #define ABFLONG int32_t #include "axon_structs.h" // ABF2 #include "abfheadr.h" // ABF1 #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) /****************************************************************************** read ATF file ******************************************************************************/ EXTERN_C void sopen_atf_read(HDRTYPE* hdr) { ifseek(hdr, 0, SEEK_SET); size_t ll = 0; char *line = NULL; ssize_t nc; typeof (hdr->NS) k; // first line - skip: contains "ATF\t1.0" or alike nc = getline(&line, &ll, hdr->FILE.FID); // 2nd line: number of rows and colums nc = getline(&line, &ll, hdr->FILE.FID); char *str = line; long numHdrLines = strtoul(str,&str,10); // number of additional header lines (?) - not used hdr->SPR = 1; hdr->NRec = 1; long numTraces = strtoul(str,&str,10); hdr->NS = 0; // 3rd line: trace labels, while (strncmp(line, "\"Time (", 7)) { // skip all (numHdrLines?) header lines nc = getline(&line, &ll, hdr->FILE.FID); if (VERBOSE_LEVEL>7) fprintf(stdout,"ATF line <%s>\n",line); } /* obtain hdr->NS from the number of equal labels. This will distinguish between ATF files with single channel and multiple sections and and ATF files with single section and multiple channels */ char**Label = malloc(numTraces*sizeof(void*)); size_t *traceList = (size_t*) malloc((numTraces-1)*sizeof(size_t)); size_t *chanList = (size_t*) malloc((numTraces-1)*sizeof(size_t)); char *str0 = strtok(line, "\t"); char *str1 = str0; size_t lenLabel = strcspn(str0,"("); char *tmpptr = NULL; char *timeunit = strchr(str0,'('); *timeunit=0; timeunit++; tmpptr=strchr(timeunit,')'); *tmpptr=0; hdr->SampleRate = 1.0 / PhysDimScale(PhysDimCode(timeunit)); k = 0; long K2 = 1; long k2 = 0; for (k2 = 0; k2 < numTraces-1; k2++) { k++; str0 = strtok(NULL, "\t"); Label[k2] = str0; char *p1 = NULL; long ll=0; if (!strncmp(str0, "\"Section", 8)) { p1 = strchr(str0,'['); ll = strtol(p1+1, &tmpptr, 10); } else if (!strncmp(str0, "\"Trace #", 8)) { p1 = strchr(str0,'#'); ll = strtol(p1+1, &tmpptr, 10)-1; } else { biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, " (ATF) invalid/unsupported label name"); } if (ll<0) biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, " (ATF) invalid trace number"); traceList[k2] = ll; if (!strncmp(str1, str0, lenLabel)) { if (k > hdr->NS) { K2 = k - hdr->NS + 1; hdr->NS = k; } } else { k = 0; str1 = str0; lenLabel = strcspn(str0,"("); } chanList[k2] = k; // zero-based indexing } hdr->NS = K2; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); hdr->AS.bpb = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; //init_channel(hc); hc->GDFTYP = 17; // float64 hc->PhysMin = -1e9; hc->PhysMax = +1e9; hc->DigMin = -1e9; hc->DigMax = +1e9; hc->Cal = 1.0; hc->Off = 0.0; hc->OnOff = 1; hc->LeadIdCode = 0; hc->Transducer[0] = '\0'; hc->PhysDimCode = 0; #ifdef MAX_LENGTH_PHYSDIM hc->PhysDim[0] = '?'; #endif hc->TOffset = 0.0; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; hc->Impedance = NAN; hc->bufptr = NULL; hc->SPR = 1; hc->bi8 = k * GDFTYP_BITS[hc->GDFTYP]; hc->bi = hc->bi8 / 8; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]/8; // split string into label and unit "label (unit)"; char *str = Label[K2+k]; if (str != NULL) { char *unit = strchr(str+1, '('); *unit=0; unit++; strncpy(hc->Label, str+1, MAX_LENGTH_LABEL+1); // do not copy quotes // extract physical units enclosed in parenthesis "Label (units)" if (unit != NULL) { char *tmpstr = strchr(unit,')'); if (tmpstr != NULL) { *tmpstr = 0; hc->PhysDimCode = PhysDimCode(unit); #ifdef MAX_LENGTH_PHYSDIM strncpy(hc->PhysDim, unit, MAX_LENGTH_PHYSDIM+1); #endif } } } } hdr->HeadLen = iftell(hdr); /*********************************************************************** read data block into memory ***********************************************************************/ size_t ln = 0; size_t numLines=0; double t1; while (~ifeof(hdr)) { ssize_t nc = getline(&line, &ll, hdr->FILE.FID); if (nc < 0) break; if (numLines <= (ln+1) ) { numLines = max(1024, ln*2); hdr->AS.rawdata = realloc(hdr->AS.rawdata, numLines * (numTraces-1) * sizeof(double)); } char *str = NULL; double val = strtod(line, &str); if (ln==0) t1 = val; if (ln==1) hdr->SampleRate /= (val-t1); for (size_t nc = 0; nc < numTraces-1; nc++) { val = strtod(str, &str); *(double*)(hdr->AS.rawdata + sizeof(double) * (ln * (numTraces-1) + nc)) = val; } ln++; } free(line); ifclose(hdr); hdr->SPR = ln; hdr->NRec = (numTraces-1) / hdr->NS; /* set up event table */ if (hdr->NRec > 1) { reallocEventTable(hdr, hdr->NRec - 1); hdr->EVENT.N = hdr->NRec - 1; hdr->EVENT.SampleRate = hdr->SampleRate; for (size_t k=0; k < hdr->EVENT.N ; k++) { hdr->EVENT.TYP[k] = 0x7ffe; hdr->EVENT.POS[k] = (k+1)*hdr->SPR; } } /* reshape data */ double *data = malloc(hdr->NS * hdr->NRec * hdr->SPR * sizeof(double)); for (size_t nr = 0; nr < hdr->SPR; nr++) for (size_t nc = 0; nc < (numTraces-1); nc++) { double val = *(double*)(hdr->AS.rawdata + sizeof(double) * (nr * (numTraces-1) + nc)); size_t idx = traceList[nc] * hdr->SPR + chanList[nc]*hdr->SPR*hdr->NRec + nr; data[idx] = val; } free(hdr->AS.rawdata); hdr->AS.rawdata = data; hdr->NRec *= hdr->SPR; hdr->SPR = 1; free(Label); free(traceList); free(chanList); hdr->FILE.POS = 0; hdr->AS.first = 0; hdr->AS.length = hdr->NRec; } EXTERN_C void sopen_abf_read(HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ if (VERBOSE_LEVEL>7) fprintf(stdout,"sopen_abf_read 101\n"); if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i) %"PRIiPTR" %i %i %"PRIiPTR"\n",__FILE__,__LINE__, sizeof(struct ABFFileHeader),ABF_OLDHEADERSIZE, ABF_HEADERSIZE, offsetof(struct ABFFileHeader, lHeaderSize)); if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i) %i %"PRIiPTR" %i\n",__FILE__,__LINE__, ABF_BLOCKSIZE, offsetof(struct ABFFileHeader, lDataSectionPtr), ABF_BLOCKSIZE*lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDataSectionPtr)) ); size_t count = hdr->HeadLen; hdr->VERSION = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fFileVersionNumber)); hdr->HeadLen = ABF_BLOCKSIZE * lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDataSectionPtr)); if (count < hdr->HeadLen) { hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, hdr->HeadLen); count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); } if ( count < (hdr->VERSION < 1.6 ? ABF_OLDHEADERSIZE : ABF_HEADERSIZE) || count < hdr->HeadLen ) { biosigERROR(hdr, B4C_INCOMPLETE_FILE, "Reading ABF Header block failed"); return; } hdr->HeadLen = count; { struct tm t; uint32_t u = leu32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lFileStartDate)); t.tm_year = u / 10000 - 1900; t.tm_mon = (u % 10000)/100 - 1; t.tm_mday = (u % 100); u = leu32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lFileStartTime)); t.tm_hour = u / 3600; t.tm_min = (u % 3600)/60; t.tm_sec = (u % 60); //u = leu16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nFileStartMillisecs)); hdr->T0 = tm_time2gdf_time(&t); } uint16_t gdftyp = 3; switch (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDataFormat))) { case 0: gdftyp = 3; break; case 1: gdftyp = 16; break; } if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i)\n",__FILE__,__LINE__); size_t slen; slen = min(MAX_LENGTH_MANUF, sizeof(((struct ABFFileHeader*)(hdr->AS.Header))->sCreatorInfo)); slen = min(MAX_LENGTH_MANUF, ABF_CREATORINFOLEN); strncpy(hdr->ID.Manufacturer._field, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sCreatorInfo), slen); hdr->ID.Manufacturer._field[slen] = 0; hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; if (hdr->Version > 1.5) { slen = min(MAX_LENGTH_RID, sizeof(((struct ABFFileHeader*)(hdr->AS.Header))->sFileComment)); strncpy(hdr->ID.Recording,(char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sFileComment), slen); hdr->ID.Recording[slen] = 0; } if (VERBOSE_LEVEL>7) { fprintf(stdout,"sCreatorInfo:\t%s\n",hdr->AS.Header + offsetof(struct ABFFileHeader, sCreatorInfo)); fprintf(stdout,"_sFileComment:\t%s\n",hdr->AS.Header + offsetof(struct ABFFileHeader, _sFileComment)); if (hdr->Version > 1.5) fprintf(stdout,"sFileComment:\t%s\n",hdr->AS.Header + offsetof(struct ABFFileHeader, sFileComment)); fprintf(stdout,"\nlHeaderSize:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lHeaderSize))); fprintf(stdout,"lTagSectionPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lTagSectionPtr))); fprintf(stdout,"lNumTagEntries:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumTagEntries))); fprintf(stdout,"lVoiceTagPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lVoiceTagPtr))); fprintf(stdout,"lVoiceTagEntries:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lVoiceTagEntries))); fprintf(stdout,"lSynchArrayPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lSynchArrayPtr))); fprintf(stdout,"lSynchArraySize:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lSynchArraySize))); fprintf(stdout,"\nlDataSectionPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDataSectionPtr))); fprintf(stdout,"lScopeConfigPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lScopeConfigPtr))); fprintf(stdout,"lNumScopes:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumScopes))); fprintf(stdout,"_lDACFilePtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, _lDACFilePtr))); fprintf(stdout,"_lDACFileNumEpisodes:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, _lDACFileNumEpisodes))); fprintf(stdout,"lDeltaArrayPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDeltaArrayPtr))); fprintf(stdout,"lNumDeltas:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumDeltas))); fprintf(stdout,"nDataFormat:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDataFormat))); fprintf(stdout,"nSimultaneousScan:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nSimultaneousScan))); fprintf(stdout,"lStatisticsConfigPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lStatisticsConfigPtr))); fprintf(stdout,"lAnnotationSectionPtr:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lAnnotationSectionPtr))); fprintf(stdout,"lNumAnnotations:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumAnnotations))); fprintf(stdout,"\nlNumSamplesPerEpisode:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumSamplesPerEpisode))); fprintf(stdout,"lPreTriggerSamples:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lPreTriggerSamples))); fprintf(stdout,"lEpisodesPerRun:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lEpisodesPerRun))); fprintf(stdout,"lActualAcqLength:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lActualAcqLength))); fprintf(stdout,"lActualEpisodes:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lActualEpisodes))); fprintf(stdout,"lRunsPerTrial:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lRunsPerTrial))); fprintf(stdout,"lNumberOfTrials:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumberOfTrials))); fprintf(stdout,"fADCRange:\t%g\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCRange))); fprintf(stdout,"fDACRange:\t%g\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fDACRange))); fprintf(stdout,"lADCResolution:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lADCResolution))); fprintf(stdout,"lDACResolution:\t%i\n",lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDACResolution))); fprintf(stdout,"\nchannel_count_acquired:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, channel_count_acquired))); fprintf(stdout,"nADCNumChannels:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCNumChannels))); fprintf(stdout,"fADCSampleInterval:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCSampleInterval))); fprintf(stdout,"nDigitalDACChannel:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalDACChannel))); fprintf(stdout,"nOperationMode:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nOperationMode))); fprintf(stdout,"nDigitalEnable:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalEnable))); fprintf(stdout,"\nfFileVersionNumber:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fFileVersionNumber))); fprintf(stdout,"fHeaderVersionNumber:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fHeaderVersionNumber))); fprintf(stdout,"fADCSampleInterval:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCSampleInterval))); fprintf(stdout,"fADCSecondSampleInterval:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCSecondSampleInterval))); fprintf(stdout,"fSynchTimeUnit:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSynchTimeUnit))); fprintf(stdout,"fSecondsPerRun:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSecondsPerRun))); fprintf(stdout,"fTriggerThreshold:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTriggerThreshold))); fprintf(stdout,"\nfScopeOutputInterval:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fScopeOutputInterval))); fprintf(stdout,"fEpisodeStartToStart:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fEpisodeStartToStart))); fprintf(stdout,"fRunStartToStart:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fRunStartToStart))); fprintf(stdout,"fTrialStartToStart:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTrialStartToStart))); fprintf(stdout,"fStatisticsPeriod:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fStatisticsPeriod))); fprintf(stdout,"fADCRange:\t%g\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCRange))); fprintf(stdout,"fDACRange:\t%g\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTriggerThreshold))); fprintf(stdout,"fTriggerThreshold:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fDACRange))); fprintf(stdout,"dFileDuration:\t%g\n",lef64p(hdr->AS.Header + offsetof(struct ABFFileHeader, dFileDuration))); fprintf(stdout,"fTriggerThreshold:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTriggerThreshold))); fprintf(stdout,"nExperimentType:\t%f\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nExperimentType))); } if (VERBOSE_LEVEL>7) fprintf(stdout,"sopen_abf_read 201\n"); if (VERBOSE_LEVEL>7) fprintf(stderr,"%s (line %i)\n",__FILE__,__LINE__); hdr->NS = lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCNumChannels)); if (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalEnable))) hdr->NS += lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalDACChannel)); hdr->SampleRate = 1e6 / (hdr->NS * lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCSampleInterval))); hdr->NRec = lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lActualAcqLength)) / lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCNumChannels)); hdr->SPR = 1; hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]/8; hdr->CHANNEL = realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); uint32_t k1=0,k; // ABF is 32 bits only, no need for more for (k=0; k < ABF_ADCCOUNT + ABF_DACCOUNT; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k1; if ((k < ABF_ADCCOUNT) && (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCSamplingSeq) + 2 * k) >= 0)) { hc->OnOff = 1; hc->bufptr = NULL; hc->LeadIdCode = 0; int ll = min(ABF_ADCNAMELEN, MAX_LENGTH_LABEL); strncpy(hc->Label, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sADCChannelName) + k*ABF_ADCNAMELEN, ll); while (ll > 0 && isspace(hc->Label[--ll])); hc->Label[ll+1] = 0; char units[ABF_ADCUNITLEN+1]; { memcpy(units, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sADCUnits) + k*ABF_ADCUNITLEN, ABF_ADCUNITLEN); units[ABF_ADCUNITLEN] = 0; int p=ABF_ADCUNITLEN; while ( (0PhysDimCode = PhysDimCode(units); } hc->Transducer[0] = '\0'; hc->LowPass = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalLowpassFilter) + 4 * k); hc->HighPass = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalHighpassFilter) + 4 * k); hc->Notch = NAN; hc->TOffset = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; hc->bi = k1*GDFTYP_BITS[gdftyp]/8; hc->bi8 = k1*GDFTYP_BITS[gdftyp]; double PhysMax = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCRange)); double DigMax = (double)lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lADCResolution)); double fTotalScaleFactor = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentScaleFactor) + 4 * k) * lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCProgrammableGain) + 4 * k); hc->Off = -lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentOffset) + 4 * k); if (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nSignalType) + 2 * k) != 0) { hc->Off -= lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentOffset) + 4 * k); fTotalScaleFactor *= lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalGain) + 4 * k); } if (hdr->Version > 1.5 && lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nTelegraphEnable) + 2 * k) != 0) { fTotalScaleFactor *= lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTelegraphAdditGain) + 4 * k); } hc->Cal = PhysMax / (fTotalScaleFactor * DigMax); hc->DigMax = DigMax-1.0; hc->DigMin = -hc->DigMax; hc->PhysMax = hc->DigMax * hc->Cal; hc->PhysMin = hc->DigMin * hc->Cal; if (VERBOSE_LEVEL>7) { fprintf(stdout,"==== CHANNEL %i [%s] ====\n",k,units); fprintf(stdout,"nSignalType:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nSignalType) + 2 * k)); fprintf(stdout,"nADCPtoLChannelMap:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCPtoLChannelMap) + 2 * k)); fprintf(stdout,"nADCSamplingSeq:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCSamplingSeq) + 2 * k)); fprintf(stdout,"fADCProgrammableGain:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCProgrammableGain) + 4 * k)); fprintf(stdout,"fADCRange:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCRange) + 4 * k)); fprintf(stdout,"fADCDisplayAmplification:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCDisplayAmplification) + 4 * k)); fprintf(stdout,"fADCDisplayOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCDisplayOffset) + 4 * k)); fprintf(stdout,"fInstrumentScaleFactor:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentScaleFactor) + 4 * k)); fprintf(stdout,"fInstrumentOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentOffset) + 4 * k)); fprintf(stdout,"fSignalGain:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalGain) + 4 * k)); fprintf(stdout,"fSignalOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalOffset) + 4 * k)); fprintf(stdout,"fSignalLowpassFilter:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalLowpassFilter) + 4 * k)); fprintf(stdout,"fSignalHighpassFilter:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalHighpassFilter) + 4 * k)); if (hdr->Version > 1.5) fprintf(stdout,"fTelegraphAdditGain:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fTelegraphAdditGain) + 4 * k)); } k1++; } else if (k < ABF_ADCCOUNT) { // do not increase k1; if (VERBOSE_LEVEL>7) { fprintf(stdout,"==== CHANNEL %i ====\n",k); fprintf(stdout,"nADCPtoLChannelMap:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCPtoLChannelMap) + 2 * k)); fprintf(stdout,"nADCSamplingSeq:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCSamplingSeq) + 2 * k)); fprintf(stdout,"fADCProgrammableGain:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCProgrammableGain) + 4 * k)); fprintf(stdout,"fADCDisplayAmplification:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCDisplayAmplification) + 4 * k)); fprintf(stdout,"fADCDisplayOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCDisplayOffset) + 4 * k)); fprintf(stdout,"fInstrumentScaleFactor:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentScaleFactor) + 4 * k)); fprintf(stdout,"fInstrumentOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fInstrumentOffset) + 4 * k)); fprintf(stdout,"fSignalGain:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalGain) + 4 * k)); fprintf(stdout,"fSignalOffset:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalOffset) + 4 * k)); fprintf(stdout,"fSignalLowpassFilter:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalLowpassFilter) + 4 * k)); fprintf(stdout,"fSignalHighpassFilter:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalHighpassFilter) + 4 * k)); } } else if ( (k1 < ABF_ADCCOUNT+ABF_DACCOUNT) && (k < hdr->NS) ) { hc->OnOff = 1; hc->bufptr = NULL; hc->LeadIdCode = 0; strncpy(hc->Label, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sDACChannelName) + (k-ABF_ADCCOUNT)*ABF_DACNAMELEN, min(ABF_DACNAMELEN,MAX_LENGTH_LABEL)); hc->Label[ABF_DACNAMELEN] = 0; char units[ABF_DACUNITLEN+1]; { memcpy(units, hdr->AS.Header + offsetof(struct ABFFileHeader, sDACChannelUnits) + (k-ABF_ADCCOUNT)*ABF_DACUNITLEN, ABF_DACUNITLEN); units[ABF_DACUNITLEN] = 0; int p=ABF_ADCUNITLEN; while ( (0PhysDimCode = PhysDimCode(units); } hc->Transducer[0] = '\0'; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->TOffset = NAN; hc->XYZ[0] = 0; hc->XYZ[1] = 0; hc->XYZ[2] = 0; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; hc->bi = k1*GDFTYP_BITS[gdftyp]/8; hc->bi8 = k1*GDFTYP_BITS[gdftyp]; double PhysMax = lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fDACRange)); double DigMax = (double)lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDACResolution)); hc->Cal = PhysMax/DigMax; hc->Off = 0.0; hc->PhysMax = PhysMax * (DigMax-1.0) / DigMax; hc->PhysMin = -hc->PhysMax; hc->DigMax = DigMax-1; hc->DigMin = -hc->DigMax; if (VERBOSE_LEVEL>7) { fprintf(stdout,"==== CHANNEL %i [%s] ====\nfDACScaleFactor:\t%f\n",k,units, lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fDACScaleFactor) + 4 * (k-ABF_ADCCOUNT))); fprintf(stdout,"fDACHoldingLevel:\t%f\n",lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fDACHoldingLevel) + 4 * (k-ABF_ADCCOUNT))); } k1++; } } /* ===== EVENT TABLE ===== */ uint32_t n1,n2; n1 = lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lActualEpisodes)) - 1; n2 = lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumTagEntries)); hdr->EVENT.N = n1+n2; /* add breaks between sweeps */ size_t spr = lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lNumSamplesPerEpisode))/hdr->NS; hdr->EVENT.SampleRate = hdr->SampleRate; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N * sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N * sizeof(*hdr->EVENT.TYP)); for (k=0; k < n1; k++) { hdr->EVENT.TYP[k] = 0x7ffe; hdr->EVENT.POS[k] = (k+1)*spr; } /* add tags */ hdr->AS.auxBUF = realloc(hdr->AS.auxBUF, n2 * sizeof(struct ABFTag)); ifseek(hdr, lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lTagSectionPtr))*ABF_BLOCKSIZE, SEEK_SET); count = ifread(hdr->AS.auxBUF, sizeof(struct ABFTag), n2, hdr); if (count>255) { count = 255; fprintf(stderr,"Warning ABF: more than 255 tags cannot be read"); } hdr->EVENT.N = n1+count; for (k=0; k < count; k++) { uint8_t *abftag = hdr->AS.auxBUF + k * sizeof(struct ABFTag); hdr->EVENT.POS[k+n1] = leu32p(abftag)/hdr->NS; abftag[ABF_TAGCOMMENTLEN+4-1]=0; FreeTextEvent(hdr, k+n1, (char*)(abftag+4)); } // set HeadLen to begin of data block hdr->HeadLen = ABF_BLOCKSIZE * lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lDataSectionPtr)); ifseek(hdr, hdr->HeadLen, SEEK_SET); } // end of sopen_abf_read size_t readABF2block(uint8_t *block, HDRTYPE *hdr, struct ABF_Section *S) { S->uBlockIndex = leu32p(block + offsetof(struct ABF_Section, uBlockIndex)); if (S->uBlockIndex==0) return 0; S->uBytes = leu32p(block + offsetof(struct ABF_Section, uBytes)); if (S->uBytes==0) return 0; S->llNumEntries = leu64p(block + offsetof(struct ABF_Section, llNumEntries)); hdr->AS.auxBUF = realloc(hdr->AS.auxBUF, S->llNumEntries*S->uBytes); ifseek(hdr, S->uBlockIndex*(size_t)512, SEEK_SET); return ifread(hdr->AS.auxBUF, 1, S->llNumEntries*S->uBytes, hdr); } EXTERN_C void sopen_abf2_read(HDRTYPE* hdr) { /* this function will be called by the function SOPEN in "biosig.c" Input: char* Header // contains the file content Output: HDRTYPE *hdr // defines the HDR structure accoring to "biosig.h" */ if (VERBOSE_LEVEL>7) fprintf(stdout,"sopen_abf2_read 101\n"); if (hdr->HeadLen < 512) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 512); hdr->HeadLen += ifread(hdr->AS.Header+hdr->HeadLen, 1, 512-hdr->HeadLen, hdr); } { struct tm t; uint32_t u = leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileStartDate)); t.tm_year = u / 10000 - 1900; t.tm_mon = (u % 10000)/100 - 1; t.tm_mday = (u % 100); u = leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileStartTimeMS))/1000; t.tm_hour = u / 3600; t.tm_min = (u % 3600)/60; t.tm_sec = (u % 60); //u = leu16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nFileStartMillisecs)); hdr->T0 = tm_time2gdf_time(&t); } hdr->SPR = 1; uint16_t gdftyp = 3; if (VERBOSE_LEVEL>7) { fprintf(stdout,"\nuFileInfoSize:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileInfoSize))); fprintf(stdout,"uActualEpisodes:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uActualEpisodes))); fprintf(stdout,"uFileStartDate:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileStartDate))); fprintf(stdout,"uFileStartTimeMS:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileStartTimeMS))); fprintf(stdout,"uStopwatchTime:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uStopwatchTime))); fprintf(stdout,"nFileType:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABF_FileInfo, nFileType))); fprintf(stdout,"nDataFormat:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABF_FileInfo, nDataFormat))); fprintf(stdout,"nSimultaneousScan:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABF_FileInfo, nSimultaneousScan))); fprintf(stdout,"nCRCEnable:\t%i\n",lei16p(hdr->AS.Header + offsetof(struct ABF_FileInfo, nCRCEnable))); fprintf(stdout,"uFileCRC: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uFileCRC))); fprintf(stdout,"uCreatorVersion: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uCreatorVersion))); fprintf(stdout,"uCreatorNameIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uCreatorNameIndex))); fprintf(stdout,"uModifierVersion: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uModifierVersion))); fprintf(stdout,"uModifierNameIndex:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uModifierNameIndex))); fprintf(stdout,"uProtocolPathIndex:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, uProtocolPathIndex))); fprintf(stdout,"ProtocolSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ProtocolSection.uBlockIndex))); fprintf(stdout,"ProtocolSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ProtocolSection.uBytes))); fprintf(stdout,"ProtocolSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ProtocolSection.llNumEntries))); fprintf(stdout,"ADCSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCSection.uBlockIndex))); fprintf(stdout,"ADCSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCSection.uBytes))); fprintf(stdout,"ADCSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCSection.llNumEntries))); fprintf(stdout,"DACSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DACSection.uBlockIndex))); fprintf(stdout,"DACSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DACSection.uBytes))); fprintf(stdout,"DACSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DACSection.llNumEntries))); fprintf(stdout,"EpochSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochSection.uBlockIndex))); fprintf(stdout,"EpochSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochSection.uBytes))); fprintf(stdout,"EpochSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochSection.llNumEntries))); fprintf(stdout,"ADCPerDACSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCPerDACSection.uBlockIndex))); fprintf(stdout,"ADCPerDACSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCPerDACSection.uBytes))); fprintf(stdout,"ADCPerDACSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCPerDACSection.llNumEntries))); fprintf(stdout,"EpochPerDACSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochPerDACSection.uBlockIndex))); fprintf(stdout,"EpochPerDACSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochPerDACSection.uBytes))); fprintf(stdout,"EpochPerDACSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochPerDACSection.llNumEntries))); fprintf(stdout,"UserListSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, UserListSection.uBlockIndex))); fprintf(stdout,"UserListSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, UserListSection.uBytes))); fprintf(stdout,"UserListSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, UserListSection.llNumEntries))); fprintf(stdout,"StatsRegionSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsRegionSection.uBlockIndex))); fprintf(stdout,"StatsRegionSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsRegionSection.uBytes))); fprintf(stdout,"StatsRegionSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsRegionSection.llNumEntries))); fprintf(stdout,"MathSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, MathSection.uBlockIndex))); fprintf(stdout,"MathSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, MathSection.uBytes))); fprintf(stdout,"MathSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, MathSection.llNumEntries))); fprintf(stdout,"StringsSection.uBlockIndex:\t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StringsSection.uBlockIndex))); fprintf(stdout,"StringsSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StringsSection.uBytes))); fprintf(stdout,"StringsSection.llNumEntries:\t%i\n",(int)lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StringsSection.llNumEntries))); fprintf(stdout,"DataSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection.uBlockIndex))); fprintf(stdout,"DataSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection.uBytes))); fprintf(stdout,"DataSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection.llNumEntries))); fprintf(stdout,"TagSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, TagSection.uBlockIndex))); fprintf(stdout,"TagSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, TagSection.uBytes))); fprintf(stdout,"TagSection.llNumEntries: \t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, TagSection.llNumEntries))); fprintf(stdout,"ScopeSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ScopeSection.uBlockIndex))); fprintf(stdout,"ScopeSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ScopeSection.uBytes))); fprintf(stdout,"ScopeSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, ScopeSection.llNumEntries))); fprintf(stdout,"DeltaSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DeltaSection.uBlockIndex))); fprintf(stdout,"DeltaSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DeltaSection.uBytes))); fprintf(stdout,"DeltaSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DeltaSection.llNumEntries))); fprintf(stdout,"VoiceTagSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, VoiceTagSection.uBlockIndex))); fprintf(stdout,"VoiceTagSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, VoiceTagSection.uBytes))); fprintf(stdout,"VoiceTagSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, VoiceTagSection.llNumEntries))); fprintf(stdout,"SynchArraySection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, SynchArraySection.uBlockIndex))); fprintf(stdout,"SynchArraySection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, SynchArraySection.uBytes))); fprintf(stdout,"SynchArraySection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, SynchArraySection.llNumEntries))); fprintf(stdout,"AnnotationSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, AnnotationSection.uBlockIndex))); fprintf(stdout,"AnnotationSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, AnnotationSection.uBytes))); fprintf(stdout,"AnnotationSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, AnnotationSection.llNumEntries))); fprintf(stdout,"StatsSection.uBlockIndex: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsSection.uBlockIndex))); fprintf(stdout,"StatsSection.uBytes: \t%i\n",leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsSection.uBytes))); fprintf(stdout,"StatsSection.llNumEntries:\t%"PRIi64"\n",lei64p(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsSection.llNumEntries))); } switch(leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection.uBytes))) { case 2: gdftyp=3; break; case 4: gdftyp=16; break; } struct ABF_Section S; readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, ProtocolSection), hdr, &S); // TODO: checking why it requires big-endian here float fADCRange = bef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fADCRange)); float fDACRange = bef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fDACRange)); int32_t lADCResolution = lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lADCResolution)); int32_t lDACResolution = lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lDACResolution)); hdr->SampleRate = 1e6 / lef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fADCSequenceInterval)); int16_t nOperationMode = lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nOperationMode)); switch (nOperationMode) { case 3: // Gap free break; case 1: // Variable-Length Event-Driven case 2: // Fixed-Length Event-Driven case 4: // High-Speed Oscilloscope Mode case 5: // Episodic Stimulation Mode fprintf(stdout,"Warning ABF2 v%4.2f: nOperationMode=%d is very experimental - double check the data you get.\n", hdr->VERSION, nOperationMode); break; default: biosigERROR(hdr, B4C_DATATYPE_UNSUPPORTED, "ABF2 nOperationMode=%d unknown and unsupported"); break; } if (VERBOSE_LEVEL>7) { fprintf(stdout,"nOperationMode:\t%i\n", nOperationMode); fprintf(stdout,"fADCSequenceInterval:\t%g\n", lef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fADCSequenceInterval))); fprintf(stdout,"fSecondsPerRun:\t%g\n", lef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fSecondsPerRun))); fprintf(stdout,"fSecondsPerRun:\t%g\n", bef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fSecondsPerRun))); fprintf(stdout,"lNumSamplesPerEpisode:\t%i\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lNumSamplesPerEpisode))); fprintf(stdout,"lPreTriggerSamples:\t%i\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lPreTriggerSamples))); fprintf(stdout,"lEpisodesPerRun:\t%i\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lEpisodesPerRun))); fprintf(stdout,"lRunsPerTrial:\t%i\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lRunsPerTrial))); fprintf(stdout,"lNumberOfTrials:\t%i\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lNumberOfTrials))); fprintf(stdout,"nDigitalEnable:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitalEnable))); fprintf(stdout,"nActiveDACChannel:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nActiveDACChannel))); fprintf(stdout,"nDigitalHolding:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitalHolding))); fprintf(stdout,"nDigitalInterEpisode:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitalInterEpisode))); fprintf(stdout,"nDigitalDACChannel:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitalDACChannel))); fprintf(stdout,"nDigitizerADCs:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitizerADCs))); fprintf(stdout,"nDigitizerDACs:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitizerDACs))); fprintf(stdout,"nDigitizerTotalDigitalOuts:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitizerTotalDigitalOuts))); fprintf(stdout,"nDigitizerSynchDigitalOuts:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitizerSynchDigitalOuts))); fprintf(stdout,"nDigitizerType:\t%i\n", lei16p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, nDigitizerType))); fprintf(stdout,"fADCRange:\t(l)%g\n", lef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fADCRange))); fprintf(stdout,"fDACRange:\t(l)%g\n", lef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fDACRange))); fprintf(stdout,"fADCRange:\t(b)%g\n", bef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fADCRange))); fprintf(stdout,"fDACRange:\t(b)%g\n", bef32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, fDACRange))); fprintf(stdout,"lADCResolution:\t0x%08x\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lADCResolution))); fprintf(stdout,"lDACResolution:\t0x%08x\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lDACResolution))); fprintf(stdout,"lADCResolution:\t(l)%d\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lADCResolution))); fprintf(stdout,"lDACResolution:\t(l)%d\n", lei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lDACResolution))); fprintf(stdout,"lADCResolution:\t(b)%d\n", bei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lADCResolution))); fprintf(stdout,"lDACResolution:\t(b)%d\n", bei32p(hdr->AS.auxBUF + offsetof(struct ABF_ProtocolInfo, lDACResolution))); } readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCSection), hdr, &S); hdr->NS = S.llNumEntries; hdr->CHANNEL = realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); int k; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->bufptr = NULL; hc->LeadIdCode = 0; hc->OnOff = 1; hc->Transducer[0] = 0; hc->Label[0] = 0; hc->LowPass = lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalLowpassFilter)); hc->HighPass = lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalHighpassFilter)); hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; hc->bi = k*GDFTYP_BITS[gdftyp] / 8; strncpy(hc->Label, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sADCChannelName) + k*ABF_ADCNAMELEN, min(ABF_ADCNAMELEN,MAX_LENGTH_LABEL)); hc->Label[ABF_ADCNAMELEN] = 0; /* char units[ABF_ADCUNITLEN+1]; { memcpy(units, (char*)hdr->AS.Header + offsetof(struct ABFFileHeader, sADCUnits) + k*ABF_ADCUNITLEN, ABF_ADCUNITLEN); units[ABF_ADCUNITLEN] = 0; int p=ABF_ADCUNITLEN; while ( (0PhysDimCode = PhysDimCode(units); } */ double PhysMax = fADCRange; double DigMax = lADCResolution; // https://swharden.com/pyabf/abf2-file-format/#reading-multi-byte-integers-from-bytestrings // https://support.moleculardevices.com/s/article/Convert-data-file-from-another-program-to-an-ABF-file-so-that-it-can-be-read-by-pCLAMP // https://github.com/yamad/libabf/blob/master/src/AxAbfFio32/abfheader.cpp -> GetADCtoUUFactors { double iCal = lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fInstrumentScaleFactor)); iCal *= lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fADCProgrammableGain)); if (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nSignalType) + 2 * k) != 0) iCal *= lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fSignalGain) + 4 * k); if (!lei16p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, nTelegraphEnable))) iCal *= lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fTelegraphAdditGain)); if (hc->Cal == 0.0) hc->Cal = 1.0; hc->Cal = fADCRange / (iCal * lADCResolution); hc->Off = lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fInstrumentOffset)); } // hc->Off = lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fInstrumentOffset)); hc->DigMax = lADCResolution - 1.0; hc->DigMin = -hc->DigMax; hc->PhysMax = hc->DigMax * hc->Cal + hc->Off; hc->PhysMin = hc->DigMin * hc->Cal + hc->Off; if (VERBOSE_LEVEL>7) { fprintf(stdout,"nADCNum:\t%i\n", lei16p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, nADCNum))); fprintf(stdout,"nADCSamplingSeq:\t%i\n", lei16p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, nADCSamplingSeq))); fprintf(stdout,"nADCPtoLChannelMap:\t%i\n", lei16p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, nADCPtoLChannelMap))); fprintf(stdout,"fADCProgrammableGain:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fADCProgrammableGain))); fprintf(stdout,"fInstrumentScaleFactor:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fInstrumentScaleFactor))); fprintf(stdout,"fInstrumentOffset:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fInstrumentOffset))); fprintf(stdout,"fSignalGain:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalGain))); fprintf(stdout,"fSignalOffset:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalOffset))); fprintf(stdout,"fSignalLowpassFilter:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalLowpassFilter))); fprintf(stdout,"fSignalHighpassFilter:\t%g\n", lef32p(hdr->AS.auxBUF + S.uBytes*k + offsetof(struct ABF_ADCInfo, fSignalHighpassFilter))); } } readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, DACSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, ADCPerDACSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, EpochPerDACSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, UserListSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsRegionSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, MathSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, StringsSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection), hdr, &S); hdr->AS.rawdata = hdr->AS.auxBUF; hdr->AS.auxBUF = NULL; hdr->AS.first = 0; hdr->AS.length = S.llNumEntries; hdr->NRec = S.llNumEntries; hdr->AS.bpb = S.uBytes; readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, TagSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, ScopeSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, DeltaSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, VoiceTagSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, SynchArraySection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, AnnotationSection), hdr, &S); readABF2block(hdr->AS.Header + offsetof(struct ABF_FileInfo, StatsSection), hdr, &S); /* hdr->NS = lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCNumChannels)); if (lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalEnable))) hdr->NS += lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nDigitalDACChannel)); hdr->SampleRate = 1e6 / (hdr->NS * lef32p(hdr->AS.Header + offsetof(struct ABFFileHeader, fADCSampleInterval))); hdr->NRec = lei32p(hdr->AS.Header + offsetof(struct ABFFileHeader, lActualAcqLength)) / lei16p(hdr->AS.Header + offsetof(struct ABFFileHeader, nADCNumChannels)); hdr->SPR = 1; hdr->AS.bpb = hdr->NS*GDFTYP_BITS[gdftyp]/8; hdr->CHANNEL = realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); */ // beginning of data block hdr->HeadLen = leu32p(hdr->AS.Header + offsetof(struct ABF_FileInfo, DataSection.uBlockIndex)) * 512; } biosig-2.3.3/biosig4c++/t210/sopen_axg_read.c0000664000175000017500000004572114105434233020630 0ustar schloeglschloegl/* sopen_axg_read is a helper function to sopen, reading AXG data. Copyright (C) 2008-2014 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #define _GNU_SOURCE #include #include #include #include #include #include #if !defined(__APPLE__) && defined (_LIBICONV_H) #define iconv libiconv #define iconv_open libiconv_open #define iconv_close libiconv_close #endif #include "../biosig-dev.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) void sopen_axg_read(HDRTYPE* hdr) { hdr->FILE.LittleEndian = 0; // read whole file into RAM size_t count = hdr->HeadLen; while (!ifeof(hdr)) { const int minsize = 1024; hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 2*count+minsize); count += ifread(hdr->AS.Header+count, 1, count+minsize, hdr); } ifclose(hdr); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, hdr->NS ); int32_t nCol; switch ((int) hdr->VERSION) { case 1: case 2: nCol = bei16p(hdr->AS.Header+6); hdr->HeadLen = 8; break; case 3: case 4: case 5: case 6: nCol = bei32p(hdr->AS.Header+8); hdr->HeadLen = 12; break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - unsupported version number"); return; } /* hack: for now each trace (i.e. column) becomes a separate channel - later the traces of the channels will be reorganized */ CHANNEL_TYPE *TEMPCHANNEL = (CHANNEL_TYPE*)malloc(nCol*sizeof(CHANNEL_TYPE)); char **ValLabel = (char**)malloc(nCol*sizeof(char*)); uint32_t *keyLabel = (uint32_t*)malloc(nCol*sizeof(uint32_t)); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, hdr->NS ); /******* read all column/traces ******/ int32_t k; uint8_t *pos = hdr->AS.Header+hdr->HeadLen; hdr->SPR = beu32p(pos); switch ((int) hdr->VERSION) { case 1: for (k = 0; k < nCol; k++) { CHANNEL_TYPE *hc = TEMPCHANNEL+k; hc->GDFTYP = 16; //float hc->PhysDimCode = 0; hc->SPR = beu32p(pos); int strlen = pos[4]; // string in Pascal format if (strlen > 79) { biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - invalid title length "); return; } /* Organize channels */ uint32_t i; for (i = 0; i < hdr->NS; i++) { // check if channel with same title already exists if (!memcmp(ValLabel[hdr->NS], pos+4, strlen)) { keyLabel[k] = hdr->NS; break; } } if (i==hdr->NS) { // in case of new title, add another channel ValLabel[hdr->NS] = (char*)pos+4; keyLabel[k] = hdr->NS; hdr->NS++; } // start of data section hc->bufptr = pos+84; pos += 84 + hc->SPR * sizeof(float); } break; case 2: for (k = 0; k < nCol; k++) { CHANNEL_TYPE *hc = TEMPCHANNEL+k; hc->GDFTYP = 3; // int16 hc->PhysDimCode = 0; hc->SPR = beu32p(pos); if (k==0) { hc->Off = bef32p(pos+84); hc->Cal = bef32p(pos+88); hc->bufptr = NULL; hdr->SampleRate = 1.0 / hc->Cal; } else { hc->Cal = bef32p(pos+84); hc->Off = 0.0; hc->bufptr = pos + 88; } int strlen = pos[4]; // string in Pascal format if (strlen > 79) { biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - invalid title length "); return; } biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - version 2 not supported yet "); return; // start of data sectioB pos += (k==0 ? 92 : 88 + hc->SPR * sizeof(int16_t) ); } break; case 6: for (k=0; k < nCol; k++) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, k ); CHANNEL_TYPE *hc = TEMPCHANNEL+k; hc->SPR = beu32p(pos); uint32_t datatype = beu32p(pos+4); size_t titleLen = beu32p(pos+8); char *inbuf = (char*)pos + 12; hc->bufptr = pos + 12 + titleLen; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %i %i %i\n", __FILE__, __LINE__, (int)datatype, (int)titleLen, (int)hc->SPR); /* // The only types used for data file columns are... // ShortArrayType = 4 IntArrayType = 5 // FloatArrayType = 6 DoubleArrayType = 7 // SeriesArrayType = 9 ScaledShortArrayType = 10 */ hc->Cal = 1.0; hc->Off = 0.0; hc->GDFTYP = datatype; //TEMPCHANNEL.GDFTYP uses a different encoding than standard GDFTYP hc->OnOff = 1; switch (datatype) { case 4: // int16 hc->GDFTYP=3; break; case 5: // int32 hc->GDFTYP=5; break; case 6: // float32 hc->GDFTYP=16; break; case 7: // double hc->GDFTYP=17; break; case 9: hc->GDFTYP = 17; // series // double firstval = bef64p(hc->bufptr); double increment = bef64p(hc->bufptr+8); hc->bufptr = NULL; hc->OnOff = 0; if (!memcmp(inbuf,"\0T\0i\0m\0e\0 \0(\0s\0)\0",8)) { hdr->SampleRate = 1.0/increment; //hc->OnOff = 2; // time axis } else { biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "AXG: series data not being a Time axis is not supported. "); return; } break; case 10: // scaled short hc->Cal = bef64p(hc->bufptr); hc->Off = bef64p(hc->bufptr+8); break; default: hc->OnOff = 0; } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, k ); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): %i %i %i %i\n", __FILE__, __LINE__, (int)hc->SPR, (int)datatype, (int)titleLen, (int)(pos-hdr->AS.Header) ); /* Organize channels find number of channels and setup data structure that assignes each column to a channel ValLabel contains the different Labels - one for each channel keyLabel contains the channel number for the corresponding column */ uint32_t i; for (i = 0; i < hdr->NS; i++) { // check if channel with same title already exists uint32_t prevTitleLen = beu32p((uint8_t*)(ValLabel[i])-4); if ((titleLen == prevTitleLen) && !memcmp(ValLabel[i], pos+12, titleLen)) { keyLabel[k] = i; break; } } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, k ); if (i==hdr->NS) { // in case of new title, add another channel ValLabel[hdr->NS] = (char*)pos+12; // pointer to title of channel 'nLabel', length of title is stored in beu32p(pos+8) keyLabel[k] = hdr->NS; hdr->NS++; } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %i\n", __FILE__, __LINE__, hdr->CHANNEL, k ); // pointer to data sections hc->bufptr = pos + 12 + titleLen; // move pos to the starting position of the next column pos += 12 + titleLen; // position of next column switch (datatype) { case 4: pos += hc->SPR * sizeof(int16_t); break; case 5: //int32 case 6: //float pos += hc->SPR * 4; break; case 7: pos += hc->SPR * sizeof(double); break; case 9: pos += 2 * sizeof(double); break; case 10: pos += 2 * sizeof(double) + hc->SPR * sizeof(int16_t); break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"error reading AXG: unsupported data type"); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): %i %i %i %i\n", __FILE__, __LINE__, (int)hc->SPR, (int)datatype, (int)titleLen, (int)(pos-hdr->AS.Header) ); } break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG version is not supported"); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) %p %p %i %i\n", __FILE__, __LINE__, TEMPCHANNEL, hdr->CHANNEL, (int)hdr->NS , (int)sizeof(CHANNEL_TYPE)); /* convert columns/traces into channels */ hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); uint32_t ns; for (ns=0; ns < hdr->NS; ns++) { CHANNEL_TYPE *hc = hdr->CHANNEL + ns; hc->SPR = 0; hc->GDFTYP = 0; hc->OnOff = 1; } size_t EventN = 0; hdr->SPR = 0; if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i) NS=%i nCol=%i\n", __FILE__, __LINE__, hdr->NS, nCol ); int flag_traces_of_first_sweep_done=0; for (k=0; k < nCol; k++) { /* copy essential parameters ´(GDFTYP, OnOff, Cal, Off) from TEMPCHANNEL and keep track of the number of samples SPR for each channel */ // define GDFTYP, Cal, Off ns = keyLabel[k]; // channel number for current column CHANNEL_TYPE *hc = hdr->CHANNEL + ns; hc->SPR += TEMPCHANNEL[k].SPR; switch (TEMPCHANNEL[k].GDFTYP) { case 4: // int16 if (hc->GDFTYP < 3) hc->GDFTYP = 3; break; case 5: // int32 if (hc->GDFTYP < 5) hc->GDFTYP = 5; break; case 6: // float32 if (hc->GDFTYP < 16) hc->GDFTYP = 16; break; case 7: // double if (hc->GDFTYP < 17) hc->GDFTYP = 17; break; case 10: hc->GDFTYP = 3; // scaled short if (hc->GDFTYP < 16) hc->GDFTYP = 16; break; default: hc->OnOff = 0; } if (!flag_traces_of_first_sweep_done) { hc->Cal = TEMPCHANNEL[k].Cal; hc->Off = TEMPCHANNEL[k].Off; } else { if (hc->Cal != TEMPCHANNEL[k].Cal || hc->Off != TEMPCHANNEL[k].Off) { // in case input is scaled short, output shoud be float hc->GDFTYP = max(16, hc->GDFTYP); } } if (hdr->SPR < hc->SPR) hdr->SPR = hc->SPR; if (ns+1 == hdr->NS) { flag_traces_of_first_sweep_done = 1; // ... add segment break in event table. if ( hdr->EVENT.N + 1 >= EventN ) { EventN += max(EventN, 16); hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, EventN * sizeof(*hdr->EVENT.POS)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, EventN * sizeof(*hdr->EVENT.TYP)); } hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; hdr->EVENT.POS[hdr->EVENT.N] = hdr->SPR; hdr->EVENT.N++; } } hdr->EVENT.N--; // ignore last separator event hdr->NRec = hdr->SPR; hdr->SPR = 1; uint32_t bi8 = 0; for (ns=0; ns < hdr->NS; ns++) { CHANNEL_TYPE *hc = hdr->CHANNEL+ns; hc->bi8 = bi8; hc->bi = bi8/8; if (hc->OnOff != 1) hc->SPR = 0; else bi8 += GDFTYP_BITS[hc->GDFTYP]; } hdr->AS.bpb = bi8/8; for (ns=0; ns < hdr->NS; ns++) { CHANNEL_TYPE *hc = hdr->CHANNEL+ns; // define hdr->channel[.].Label, hdr->channel[.].PhysDim if (hdr->Version <= 2) { // PascalToCString(ValLabel[ns]); // shift by 1 byte and terminate 0 char int strlen = min(ValLabel[ns][0],MAX_LENGTH_LABEL); strncpy(hc->Label, (ValLabel[ns])+1, strlen); char *u1 = strrchr(ValLabel[ns],'('); char *u2 = strrchr(ValLabel[ns],')'); if (u1 != NULL && u2 != NULL && u1 < u2) { *u1 = 0; *u2 = 0; hc->PhysDimCode = PhysDimCode(u1+1); } } else if (hdr->Version <= 6) { char *inbuf = ValLabel[ns]; size_t inlen = beu32p((uint8_t*)(ValLabel[ns])-4); char *outbuf = hc->Label; size_t outlen = MAX_LENGTH_LABEL+1; #if defined(_ICONV_H) || defined (_LIBICONV_H) iconv_t ICONV = iconv_open("UTF-8","UCS-2BE"); size_t reticonv = iconv(ICONV, &inbuf, &inlen, &outbuf, &outlen); iconv_close(ICONV); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i): %i %i %i %"PRIiPTR"\n", __FILE__, __LINE__, (int)hc->SPR, (int)inlen, (int)(pos-hdr->AS.Header), reticonv ); if (reticonv == (size_t)(-1) ) { perror("AXG - conversion of title failed!!!"); biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - conversion of title failed"); return; } *outbuf=0; #else ++inbuf; int i = min(MAX_LENGTH_LABEL, titleLen/2); for (; i>0 ; i-- ) { *outbuf= *inbuf; inbuf += 2; outbuf++; } outbuf = 0; #endif char *u1 = strrchr(hc->Label,'('); char *u2 = strrchr(hc->Label,')'); if (u1 != NULL && u2 != NULL && u1 < u2) { *u1 = 0; *u2 = 0; hc->PhysDimCode = PhysDimCode(u1+1); } } // these might be reorganized below hc->DigMax = 1e9; hc->DigMin = -1e9; hc->PhysMax = hc->DigMax; hc->PhysMin = hc->DigMin; hc->LeadIdCode = 0; hc->Transducer[0] = 0; hc->Cal = 1.0; hc->Off = 0.0; hc->TOffset = 0; hc->HighPass = NAN; hc->LowPass = NAN; hc->Notch = NAN; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; } hdr->AS.rawdata = (uint8_t*)realloc( hdr->AS.rawdata, hdr->AS.bpb*hdr->SPR*hdr->NRec); for (ns=0; ns < hdr->NS; ns++) { CHANNEL_TYPE *hc = hdr->CHANNEL + ns; hc->SPR = 0; } for (k=0; k < nCol; k++) { ns = keyLabel[k]; CHANNEL_TYPE *hc = hdr->CHANNEL + ns; if (hc->OnOff != 1) continue; uint32_t i; switch (hc->GDFTYP) { case 3: assert(TEMPCHANNEL[k].GDFTYP==4); for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(int16_t*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bei16p(TEMPCHANNEL[k].bufptr + i*2); } break; case 5: switch (TEMPCHANNEL[k].GDFTYP) { case 4: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(int32_t*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bei16p(TEMPCHANNEL[k].bufptr + i*2); } break; case 5: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(int32_t*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bei32p(TEMPCHANNEL[k].bufptr + i*4); } break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - data conversion not supported "); return; } break; case 16: switch (TEMPCHANNEL[k].GDFTYP) { case 4: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(float*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = (float)bei16p(TEMPCHANNEL[k].bufptr + i*2); } break; case 5: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(float*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = (float)bei32p(TEMPCHANNEL[k].bufptr + i*4); } break; case 6: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(float*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bef32p(TEMPCHANNEL[k].bufptr + i*4); } break; case 10: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(float*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bei16p(TEMPCHANNEL[k].bufptr + i*2) * TEMPCHANNEL[k].Cal + TEMPCHANNEL[k].Off; } break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - data conversion not supported "); return; } break; case 17: switch (TEMPCHANNEL[k].GDFTYP) { case 4: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(double*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = (double)bei16p(TEMPCHANNEL[k].bufptr + i*2); } break; case 5: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(double*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = (double)bei32p(TEMPCHANNEL[k].bufptr + i*4); } break; case 6: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(double*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = (double)bef32p(TEMPCHANNEL[k].bufptr + i*4); } break; case 7: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(double*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bef64p(TEMPCHANNEL[k].bufptr + i*8); } break; case 10: for (i=0; i < TEMPCHANNEL[k].SPR; i++) { *(double*)(hdr->AS.rawdata + hc->bi + (hc->SPR + i) * hdr->AS.bpb) = bei16p(TEMPCHANNEL[k].bufptr + i*2) * TEMPCHANNEL[k].Cal + TEMPCHANNEL[k].Off; } break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - data conversion not supported "); return; } break; default: biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - unsupported target data type"); return; } hc->SPR += TEMPCHANNEL[k].SPR; } for (ns=0; ns < hdr->NS; ns++) { CHANNEL_TYPE *hc = hdr->CHANNEL + ns; hc->SPR = hdr->SPR; } // free intermediate data structure to reorganized column/trace to channels if(TEMPCHANNEL) free(TEMPCHANNEL); if(keyLabel) free(keyLabel); if(ValLabel) free(ValLabel); // data is stored on hdr->AS.rawdata in such a way that swapping must not be applied hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); hdr->AS.first = 0; hdr->AS.length = (size_t)hdr->NRec; // read Comments size_t szComments = beu32p(pos); char *inbuf = (char*)pos+4; char *Comments = malloc(szComments+1); char *outbuf = Comments; size_t outlen = szComments+1; size_t inlen = szComments; iconv_t ICONV = iconv_open("UTF-8","UCS-2BE"); size_t reticonv = iconv(ICONV, &inbuf, &inlen, &outbuf, &outlen); iconv_close(ICONV); if (reticonv == (size_t)(-1) ) { perror("AXG - conversion of comments failed!!!"); biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - conversion of comments failed"); return; } Comments[outlen]=0; if (VERBOSE_LEVEL >7) fprintf(stdout,"\n=== COMMENT === \n %s\n",Comments); pos += 4+szComments; // read Notes size_t szNotes = beu32p(pos); inbuf = (char*)pos+4; char *Notes = malloc(szNotes+1); outbuf = Notes; outlen = szNotes+1; inlen = szNotes; ICONV = iconv_open("UTF-8","UCS-2BE"); reticonv = iconv(ICONV, &inbuf, &inlen, &outbuf, &outlen); iconv_close(ICONV); if ( reticonv == (size_t)(-1) ) { biosigERROR(hdr,B4C_FORMAT_UNSUPPORTED,"AXG - conversion of Notes failed"); return; } Notes[outlen]=0; if (VERBOSE_LEVEL >7) fprintf(stdout,"=== NOTES === \n %s\n",Notes); pos += 4+szNotes; /****** parse Date and Time ********/ struct tm T; #ifdef __GLIBC__ strptime(strstr(Notes,"Created on ")+11, "%a %b %d %Y", &T); strptime(strstr(Notes,"acquisition at ")+15, "%T", &T); hdr->T0 = tm_time2gdf_time(&T); #else char DATE[30]; strncpy(DATE, strstr(Notes,"Created on ")+11, 30); DATE[29] = 0; strtok(DATE, "\n\r"); // cut at newline char *tmp = strtok(DATE, " "); // day of week - skip tmp = strtok(NULL, " "); // abreviated month name T.tm_mon = month_string2int(tmp); tmp = strtok(NULL, " "); // day of month T.tm_mday = atoi(tmp); tmp = strtok(NULL , " "); // year T.tm_year = atoi(tmp) - 1900; strncpy(DATE, strstr(Notes,"acquisition at ")+15, 9); DATE[9] = 0; tmp = strtok(DATE, " :"); T.tm_hour = atoi(tmp); tmp = strtok(NULL, " :"); T.tm_min = atoi(tmp); tmp = strtok(NULL, " :"); T.tm_sec = atoi(tmp); hdr->T0 = tm_time2gdf_time(&T); #endif hdr->AS.fpulse = Notes; free(Comments); if (VERBOSE_LEVEL > 7) fprintf(stdout,"%s (line %i)\n", __FILE__, __LINE__ ); } biosig-2.3.3/biosig4c++/README.cygwin0000664000175000017500000000051214105434233017164 0ustar schloeglschloeglBioSig/libbiosig can be install on cygwin, mostly without and specific issues. If bindings (mexSLOAD, mexSSAVE, etc) for Octave 3.6.4 should compiled, the file mex.h need to be patched with mex/cygwin-octave364.patch REQUIREMENTS g++ gcc gawk Compiling for Octave (make mex4o) requires also octave gnuplot patch biosig-2.3.3/biosig4c++/physicalunits.c0000664000175000017500000002201414105434233020051 0ustar schloeglschloegl/* Copyright (C) 2005-2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include "physicalunits.h" #ifdef HAVE_PTHREAD // This is optional, because so far there are no multi-threaded applications for libbiosig. #include #endif /* physical units are defined in prEN ISO 11073-10101 (Nov 2003) Health Informatics - Point-of-care medical device communications - Part 10101:Nomenclature (ISO/DIS 11073-10101:2003) Table A.6.1: Table of Decimal Factors CEN/TC251/PT40 2001 File Exchange Format for Vital Signs - Annex A Table A.4.1: Table of Decimal Factors const double scale[32] = */ const struct PhysDimIdx { const uint16_t idx; const char* PhysDimDesc; } _physdim[] = { #include "units.i" {0xffff, "end-of-table" }, } ; /* compare strings, accept bit7=1 */ int strcmp8(const char* str1, const char* str2) { unsigned int k=0; int r; r = str1[k] - str2[k]; while (r==0 && str1[k]!='\0' && str2[k]!='\0') { k++; r = str1[k] - str2[k]; } return(r); } const char* PhysDimFactor[] = { "","da","h","k","M","G","T","P", // 0..7 "E","Z","Y","#","#","#","#","#", // 8..15 "d","c","m","u","n","p","f","a", // 16..23 "z","y","#","#","#","#","#","#", // 24..31 "\xB5" //hack for "µ" = "u" // 32 }; #ifndef NAN # define NAN (0.0/0.0) /* used for encoding of missing values */ #endif double PhysDimScale(uint16_t PhysDimCode) { // converting PhysDimCode -> scaling factor const double scale[] = { 1e+0, 1e+1, 1e+2, 1e+3, 1e+6, 1e+9, 1e+12, 1e+15, // 0..7 1e+18,1e+21,1e+24,NAN, NAN, NAN, NAN, NAN, // 8..15 1e-1, 1e-2, 1e-3, 1e-6, 1e-9, 1e-12, 1e-15, 1e-18, // 16..23 1e-21,1e-24,NAN, NAN, NAN, NAN, NAN, NAN, // 24..31 1e-6 // hack for "µ" = "u" // 32 }; return (scale[PhysDimCode & 0x001f]); } // DEPRECATED: USE INSTEAD PhysDim3(uint16_t PhysDimCode) __attribute__ ((deprecated)) char* PhysDim(uint16_t PhysDimCode, char *PhysDim) { #define MAX_LENGTH_PHYSDIM 20 // DEPRECATED - DO NOT USE // converting PhysDimCode -> PhysDim uint16_t k=0; size_t l2 = strlen(PhysDimFactor[PhysDimCode & 0x001F]); memcpy(PhysDim,PhysDimFactor[PhysDimCode & 0x001F],l2); PhysDimCode &= ~0x001F; for (k=0; _physdim[k].idx<0xffff; k++) if (PhysDimCode == _physdim[k].idx) { strncpy(PhysDim+l2, _physdim[k].PhysDimDesc, MAX_LENGTH_PHYSDIM+1-l2); PhysDim[MAX_LENGTH_PHYSDIM]='\0'; break; } return(PhysDim); #undef MAX_LENGTH_PHYSDIM } char* PhysDim2(uint16_t PhysDimCode) { // converting PhysDimCode -> PhysDim uint16_t k = 0; uint16_t l2 = strlen(PhysDimFactor[PhysDimCode & 0x001F]); for (k = 0; _physdim[k].idx < 0xffff; k++) if ( (PhysDimCode & ~0x001F) == _physdim[k].idx) { char *PhysDim = (char*)malloc(l2 + 1 + strlen(_physdim[k].PhysDimDesc)); if (PhysDim==NULL) return (NULL); memcpy(PhysDim, PhysDimFactor[PhysDimCode & 0x001F], l2); strcpy(PhysDim+l2, _physdim[k].PhysDimDesc); return(PhysDim); } return(NULL); } uint16_t PhysDimCode(const char* PhysDim0) { // converting PhysDim -> PhysDimCode /* converts Physical dimension into 16 bit code */ uint16_t k1, k2; char s[80]; char *s1; if (PhysDim0==NULL) return(0); while (isspace(*PhysDim0)) PhysDim0++; // remove leading whitespace if (strlen(PhysDim0)==0) return(0); // greedy search - check all codes 0..65535 for (k1=0; k1<33; k1++) if (strncmp(PhysDimFactor[k1],PhysDim0,strlen(PhysDimFactor[k1]))==0 && (PhysDimScale(k1)>0.0)) { // exclude if beginning of PhysDim0 differs from PhysDimFactor and if NAN strncpy(s, PhysDimFactor[k1],3); s1 = s+strlen(s); for (k2=0; _physdim[k2].idx < 0xffff; k2++) { strncpy(s1, _physdim[k2].PhysDimDesc, 77); if (strcmp8(PhysDim0, s)==0) { if (k1==32) k1 = 19; // hack for "µ" = "u" return(_physdim[k2].idx+k1); } } } return(0); } /*------------------------------------------------------------------------ * Table of Physical Units * * This part can be better optimized with a more sophisticated hash table * PhysDimTable depends only on constants, defined in units.csv/units.i; however, the table is only initialized upon usage. * These functions are thread safe except for the call to PhysDim2 which updates the table (it does a malloc). Everything else is just read operation, and the content is defined only by PhysDimFactor and PhysDimIdx, which are constant. * The implementation does not seem straightforward, but it should be faster to store already computed strings in a table, rather then recomputing them, again and again. *------------------------------------------------------------------------*/ #define PHYS_DIM_TABLE_SIZE 0x10000 static char *PhysDimTable[PHYS_DIM_TABLE_SIZE]; static char FlagInit_PhysDimTable = 0; #ifdef _PTHREAD_H pthread_mutex_t mutexPhysDimTable = PTHREAD_MUTEX_INITIALIZER; #endif /***** Release allocated memory *****/ void ClearPhysDimTable() { #ifdef _PTHREAD_H pthread_mutex_lock(&mutexPhysDimTable); #endif unsigned k = 0; while (k < PHYS_DIM_TABLE_SIZE) { char *o = PhysDimTable[k++]; if (o != NULL) free(o); } FlagInit_PhysDimTable = 0; #ifdef _PTHREAD_H pthread_mutex_unlock(&mutexPhysDimTable); #endif } /***** PhysDim3 returns the text representation of the provided 16bit code *****/ const char* PhysDim3(uint16_t PhysDimCode) { #ifdef _PTHREAD_H pthread_mutex_lock(&mutexPhysDimTable); #endif if (!FlagInit_PhysDimTable) { memset(PhysDimTable, 0, PHYS_DIM_TABLE_SIZE * sizeof(char*)); atexit(&ClearPhysDimTable); FlagInit_PhysDimTable = 1; } char **o = PhysDimTable+PhysDimCode; if (*o==NULL) *o = PhysDim2(PhysDimCode); #ifdef _PTHREAD_H pthread_mutex_unlock(&mutexPhysDimTable); #endif return( (const char*) *o); } /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #ifdef TEST_PHYSDIMTABLE_PERFORMANCE /*********************************** this is just for testing and is not part of the library ***********************************/ #include #include int main() { int k; char *s = NULL; struct rusage t[6]; struct timeval r[3]; /* #define PhysDim3(k) (PhysDim3(4275)) #define PhysDim2(k) (PhysDim2(4275)) */ int c[6]; memset(c,0,sizeof(c)); getrusage(RUSAGE_SELF, &t[0]); // initialize PhysDimTable for (k=0; k<0x10000; k++) c[0] += (PhysDim3(k)!=NULL); getrusage(RUSAGE_SELF, &t[1]); // recall PhysDimTable - many entries are Null, triggering a call to PhysDim2 for (k=0; k<0x10000; k++) c[1] += (PhysDim3(k)!=NULL); getrusage(RUSAGE_SELF, &t[2]); // recall PhysDimTable with a fixed code for (k=0; k<0x10000; k++) c[2] += (PhysDim3(4275)!=NULL); getrusage(RUSAGE_SELF, &t[3]); // trivial implementation PhysDimTable for (k=0; k<0x10000; k++) { s = PhysDim2(k); if (s!=NULL) { free(s); c[3]++; } } getrusage(RUSAGE_SELF, &t[4]); // trivial implementation PhysDimTable for a fixed code for (k=0; k<0x10000; k++) { s = PhysDim2(4275); if (s!=NULL) { free(s); c[4]++; } } getrusage(RUSAGE_SELF, &t[5]); // trivial implementation PhysDimTable for (k=0; k<0x10000; k++) { if ( (k & ~0x001f)==65408) continue; // exclude user-defined code for Bel, because it was later added in the standard s = (char*)PhysDim3(k); int m = PhysDimCode(s); c[5] += (m==k); if ((m!=k) && (s!=NULL) && (s[0]!='#')) { fprintf(stdout,"%s\t%d\t%d\t%s\n",PhysDimFactor[k & 0x1f],k,m,s); } } for (k=0; k<6; k++) { //fprintf(stdout,"=== [%i]: %d.%06d\t%d.%06d\n",k, t[k].ru_utime.tv_sec,t[k].ru_utime.tv_usec,t[k].ru_stime.tv_sec,t[k].ru_stime.tv_usec); if (!k) continue; timersub(&(t[k].ru_utime), &(t[k-1].ru_utime), &r[0]); fprintf(stdout,"usr [%i]: %d.%06d\t",k, r[0].tv_sec,r[0].tv_usec); timersub(&(t[k].ru_stime), &(t[k-1].ru_stime) ,&r[1]); fprintf(stdout,"sys [%i]: %d.%06d\t",k, r[1].tv_sec,r[1].tv_usec); timeradd(&r[0],&r[1],&r[2]); fprintf(stdout,"tot [%i]: %d.%06d\t%i\n",k,r[2].tv_sec,r[2].tv_usec,c[k-1]); } return 0; } #endif biosig-2.3.3/biosig4c++/php/0000775000175000017500000000000014105434244015600 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/php/Makefile.in0000664000175000017500000000117214105434233017644 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-PHP interface is available here # http://www.swig.org/Doc1.3/Php.html#Php all: swig -c++ -php biosig.i gcc `php-config --includes` -fpic -c biosig_wrap.cpp gcc -shared biosig_wrap.o -o php_biosig.so clean: -rm *.h -rm *.o -rm *.cpp -rm *.so biosig-2.3.3/biosig4c++/php/demo.php0000775000175000017500000000507314105434233017243 0ustar schloeglschloegl#!/usr/bin/php This file is part of the BioSig repository at http://biosig.sf.net/ 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 3 of the License, 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, see . */ function ext() { if (preg_match("/windows/i",php_uname())) return ".exe"; return; } /* biosig_fhir_base64: encodes a biosig file as a base64-encoded GDFv3.0 stream */ function biosig_fhir_base64($filename) { $h = popen('biosig_fhir' . ext() . ' -base64 "' . $filename.'"', 'rb'); $jsonhdr = stream_get_contents($h); fclose($h); return $jsonhdr; } /* biosig_fhir: makes a fhir_json_binary template */ function biosig_fhir_json($filename) { $h = popen('biosig_fhir' . ext() . ' -json "' . $filename.'"', 'rb'); $jsonhdr = stream_get_contents($h); fclose($h); return $jsonhdr; } /* biosig_fhir_xml: makes a fhir_xml_binary template */ function biosig_fhir_xml($filename) { $h = popen('biosig_fhir' . ext() . ' -xml "' . $filename.'"', 'rb'); $jsonhdr = stream_get_contents($h); fclose($h); return $jsonhdr; } /* get header (meta) information */ function biosig_json_header($filename) { $h = popen('save2gdf' . ext() . ' -JSON "' . $filename.'"', 'rb'); $jsonhdr = stream_get_contents($h); fclose($h); return $jsonhdr; } /* get header (meta) information in php array */ function biosig_header($filename) { return json_decode( biosig_json_header($filename) ); } ## example file $filename="data/Newtest17-256.bdf"; ## extract header information through JSON export $HDR = biosig_header($filename); var_dump($HDR); ## extract fhir binary template $BIN = biosig_fhir_base64($filename); echo $BIN; print "\n\n"; ## extract fhir binary template $BIN = biosig_fhir_json($filename); echo $BIN; print "\n\n"; ?> biosig-2.3.3/biosig4c++/php/Makefile0000664000175000017500000000117214105434244017241 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-PHP interface is available here # http://www.swig.org/Doc1.3/Php.html#Php all: swig -c++ -php biosig.i gcc `php-config --includes` -fpic -c biosig_wrap.cpp gcc -shared biosig_wrap.o -o php_biosig.so clean: -rm *.h -rm *.o -rm *.cpp -rm *.so biosig-2.3.3/biosig4c++/php/biosig.i0000664000175000017500000002500014105434233017221 0ustar schloeglschloegl/* % % $Id$ % Copyright (C) 2008,2009 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ // swig.i %module biosig %{ #include "../biosig.h" %} %include typedef int64_t gdf_time; /* gdf time is represented in 64 bits */ typedef int64_t nrec_t; /* type for number of records */ /* list of file formats */ enum FileFormat { noFile, unknown, ABF, ACQ, ACR_NEMA, AIFC, AIFF, AINF, alpha, ARFF, ASCII_IBI, ASCII, AU, ASF, ATES, ATF, AVI, Axona, BCI2000, BDF, BESA, BIN, BKR, BLSC, BMP, BNI, BSCS, BrainVision, BrainVisionVAmp, BrainVisionMarker, BZ2, CDF, CFS, CFWB, CNT, CTF, DICOM, DEMG, EBS, EDF, EEG1100, EEProbe, EEProbe2, EEProbeAvr, EGI, EGIS, ELF, EMBLA, EMSA, ePrime, ET_MEG, ETG4000, EVENT, EXIF, FAMOS, FEF, FITS, FLAC, GDF, GDF1, GIF, GTF, GZIP, HDF, HL7aECG, HEKA, ISHNE, ITX, JPEG, JSON, Lexicor, Matlab, MFER, MIDI, MIT, MM, MSI, MSVCLIB, MS_LNK, native, NeuroLoggerHEX, NetCDF, NEURON, NEV, NEX1, NIFTI, OGG, OpenXDF, PBMA, PBMN, PDF, PDP, Persyst, PGMA, PGMB, PLEXON, PNG, PNM, POLY5, PPMA, PPMB, PS, RDF, RIFF, SASXPT, SCP_ECG, SIGIF, Sigma, SMA, SND, SQLite, SPSS, STATA, SVG, SXI, SYNERGY, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK, WAV, WG1, WinEEG, WMF, XML, XPM, Z, ZIP, ZIP2 }; typedef struct CHANNEL_STRUCT { double PhysMin; /* physical minimum */ double PhysMax; /* physical maximum */ double DigMin; /* digital minimum */ double DigMax; /* digital maximum */ double Cal; /* gain factor */ double Off; /* bias */ char OnOff; char Label[MAX_LENGTH_LABEL+1]; /* Label of channel */ uint16_t LeadIdCode; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1]; /* transducer e.g. EEG: Ag-AgCl electrodes */ // char PhysDim[MAX_LENGTH_PHYSDIM+1] ; /* physical dimension */ /*PhysDim is now obsolete - use function PhysDim3(PhysDimCode) instead */ uint16_t PhysDimCode; /* code for physical dimension */ /* char* PreFilt; // pre-filtering */ float TOffset; /* time delay of sampling */ float LowPass; /* lowpass filter */ float HighPass; /* high pass */ float Notch; /* notch filter */ float XYZ[3]; /* sensor position */ // float Orientation[3]; // sensor direction // float Area; // area of sensor (e.g. for MEG) union { /* context specific channel information */ float Impedance; /* Electrode Impedance in Ohm, defined only if PhysDim = _Volt */ float fZ; /* ICG probe frequency, defined only if PhysDim = _Ohm */ }; uint16_t GDFTYP; /* data type */ uint32_t SPR; /* samples per record (block) */ } CHANNEL_TYPE; /* This structure defines the general (fixed) header */ typedef struct { float VERSION; /* GDF version number */ char* FileName; enum FileFormat TYPE; /* type of file format */ struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint8_t IPaddr[16]; /* IP address of recording device (if applicable) */ double SampleRate; /* Sampling rate */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ gdf_time T0; /* starttime of recording */ uint32_t HeadLen; /* length of header in bytes */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ uint16_t NS; /* number of channels */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ #endif CHANNEL_TYPE *rerefCHANNEL; /* Patient specific information */ struct { gdf_time Birthday; /* Birthday of Patient */ // Age; /* the age is HDR.T0 - HDR.Patient.Birthday, even if T0 and Birthday are not known */ uint16_t Headsize[3]; /* circumference, nasion-inion, left-right mastoid in millimeter; */ char Name[MAX_LENGTH_NAME+1]; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ // char* Name; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ char Id[MAX_LENGTH_PID+1]; /* patient identification, identification code as used in hospital */ uint8_t Weight; /* weight in kilograms [kg] 0:unkown, 255: overflow */ uint8_t Height; /* height in centimeter [cm] 0:unkown, 255: overflow */ // BMI; /* the body-mass index = weight[kg]/height[m]^2 */ /* Patient classification */ int Sex; /* 0:Unknown, 1: Male, 2: Female */ int Handedness; /* 0:Unknown, 1: Right, 2: Left, 3: Equal */ int Smoking; /* 0:Unknown, 1: NO, 2: YES */ int AlcoholAbuse; /* 0:Unknown, 1: NO, 2: YES */ int DrugAbuse; /* 0:Unknown, 1: NO, 2: YES */ int Medication; /* 0:Unknown, 1: NO, 2: YES */ struct { int Visual; /* 0:Unknown, 1: NO, 2: YES, 3: Corrected */ int Heart; /* 0:Unknown, 1: NO, 2: YES, 3: Pacemaker */ } Impairment; } Patient; struct { char Recording[MAX_LENGTH_RID+1]; /* HL7, EDF, GDF, BDF replaces HDR.AS.RID */ char* Technician; char* Hospital; uint64_t Equipment; /* identifies this software */ struct { /* see SCP: section1, tag14, MFER: tag23: "Manufacturer^model^version number^serial number" GDF: tag3: "Manufacturer\0model\0version\0number\0serial number\0" */ // char _field[MAX_LENGTH_MANUF+1]; /* buffer */ char* Name; char* Model; char* Version; char* SerialNumber; } Manufacturer; } ID; /* position of electrodes; see also HDR.CHANNEL[k].XYZ */ struct { float REF[3]; /* XYZ position of reference electrode */ float GND[3]; /* XYZ position of ground electrode */ } ELEC; /* EVENTTABLE */ struct { double SampleRate; /* for converting POS and DUR into seconds */ uint16_t *TYP; /* defined at ../biosig4matlab/doc/eventcodes.txt */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ #if (BIOSIG_VERSION >= 10500) gdf_time *TimeStamp ATT_ALI; /* store time stamps */ #endif char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ uint32_t N; /* number of events */ uint16_t LenCodeDesc; /* length of CodeDesc Table */ } EVENT; struct { /* flags */ char OVERFLOWDETECTION; /* overflow & saturation detection 0: OFF, !=0 ON */ char UCAL; /* UnCalibration 0: scaling !=0: NO scaling - raw data return */ char ANONYMOUS; /* 1: anonymous mode, no personal names are processed */ char ROW_BASED_CHANNELS; /* 0: column-based data [default]; 1: row-based data */ char TARGETSEGMENT; /* in multi-segment files (like Nihon-Khoden, EEG1100), it is used to select a segment */ } FLAG; CHANNEL_TYPE *CHANNEL; struct { /* File specific data */ #ifdef ZLIB_H gzFile gzFID; #endif #ifdef _BZLIB_H // BZFILE* bzFID; #endif FILE* FID; /* file handle */ size_t POS; /* current reading/writing position [in blocks] */ // int Des; /* file descriptor */ uint8_t OPEN; /* 0: closed, 1:read, 2: write */ uint8_t LittleEndian; uint8_t COMPRESSION; /* 0: no compression 9: best compression */ // int DES; /* descriptor for streams */ } FILE; /* internal variables (not public) */ struct { const char* B4C_ERRMSG; /* error message */ // char PID[MAX_LENGTH_PID+1]; /* use HDR.Patient.Id instead */ // char* RID; /* recording identification */ // uint32_t spb; /* total samples per block */ // uint32_t bpb; /* total bytes per block */ // uint32_t bpb8; /* total bits per block */ uint8_t* Header; // uint8_t* rawEventData; // uint8_t* rawdata; /* raw data block */ // char flag_collapsed_rawdata; /*0 if rawdata contain obsolete channels, too. */ // nrec_t first; /* first block loaded in buffer - this is equivalent to hdr->FILE.POS */ // nrec_t length; /* number of block(s) loaded in buffer */ uint8_t* auxBUF; /* auxillary buffer - used for storing EVENT.CodeDesc, MIT FMT infor */ char* bci2000; // uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ enum B4C_ERROR B4C_ERRNUM; /* error code */ // char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ } AS; void *aECG; } HDRTYPE; HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); void destructHDR(HDRTYPE* hdr); HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr); int sclose(HDRTYPE* hdr); size_t sread(biosig_data_type* data, size_t start, size_t length, HDRTYPE* hdr); size_t swrite(const biosig_data_type *data, size_t nelem, HDRTYPE* hdr); int seof(HDRTYPE* hdr); void srewind(HDRTYPE* hdr); int sseek(HDRTYPE* hdr, long int offset, int whence); long int stell(HDRTYPE* hdr); int serror2(HDRTYPE* hdr); int hdr2ascii(HDRTYPE* hdr, FILE *fid, int verbosity); int RerefCHANNEL(HDRTYPE *hdr, void *ReRef, char rrtype); const char* GetFileTypeString(enum FileFormat FMT); uint16_t PhysDimCode(char* PhysDim0); char* PhysDim3(uint16_t PhysDimCode); /* HDRTYPE* sopen(char *filename); %{ HDRTYPE* sopen(char *filename) { HDRTYPE *hdr = constructHDR(0,0); hdr = sopen(filename, "r", hdr); return hdr; } %} int sclose(HDRTYPE *hdr); %{ int sclose(HDRTYPE *hdr) { sclose(hdr); destructHDR(hdr); return 0; } %} */ size_t sread(biosig_data_type* DATA, size_t start, size_t length, HDRTYPE* hdr); %{ size_t sread(biosig_data_type* DATA, size_t start, size_t length, HDRTYPE* hdr) { } %} void serror(); %{ void _serror() { fprintf(stderr,"Use of SERROR is deprecated - use serror2(HDR) instead"); serror(); } %} void hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig-2.3.3/biosig4c++/biosig2.c0000664000175000017500000013327614105434233016525 0ustar schloeglschloegl/* Copyright (C) 2012-2018 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include "biosig.h" /* ============================================================= setter and getter functions for accessing fields of HDRTYPE ============================================================= */ enum FileFormat biosig_get_filetype(HDRTYPE *hdr) { if (hdr==NULL) return noFile; return hdr->TYPE; } int biosig_set_filetype(HDRTYPE *hdr, enum FileFormat format) { if (hdr==NULL) return -1; hdr->TYPE=format; if (format==GDF) hdr->VERSION = 1.0/0.0; // use latest version return 0; } #if (BIOSIG_VERSION < 10700) ATT_DEPREC int biosig_set_flags(HDRTYPE *hdr, char compression, char ucal, char overflowdetection) { fprintf(stderr,"Warning libbiosig2: function biosig_set_flags() is deprecated, use biosig_(re)set_flag() instead\n"); if (hdr==NULL) return -1; hdr->FLAG.UCAL = ucal; hdr->FLAG.OVERFLOWDETECTION = overflowdetection; hdr->FILE.COMPRESSION = compression; return 0; } #endif int biosig_get_flag(HDRTYPE *hdr, unsigned flags) { if (hdr==NULL) return -1; return flags & ( \ (!!hdr->FLAG.OVERFLOWDETECTION) * (unsigned)BIOSIG_FLAG_OVERFLOWDETECTION \ + (!!hdr->FLAG.UCAL) * (unsigned)BIOSIG_FLAG_UCAL \ + (!!hdr->FILE.COMPRESSION) * (unsigned)BIOSIG_FLAG_COMPRESSION \ + (!!hdr->FLAG.UCAL) * (unsigned)BIOSIG_FLAG_UCAL \ + (!!hdr->FLAG.ROW_BASED_CHANNELS)* (unsigned)BIOSIG_FLAG_ROW_BASED_CHANNELS \ ) ; } int biosig_set_flag(HDRTYPE *hdr, unsigned flags) { if (hdr==NULL) return -1; hdr->FLAG.UCAL |= !!(flags & BIOSIG_FLAG_UCAL); hdr->FLAG.OVERFLOWDETECTION |= !!(flags & BIOSIG_FLAG_OVERFLOWDETECTION); hdr->FILE.COMPRESSION |= !!(flags & BIOSIG_FLAG_COMPRESSION); hdr->FLAG.ROW_BASED_CHANNELS |= !!(flags & BIOSIG_FLAG_ROW_BASED_CHANNELS); return 0; }; int biosig_reset_flag(HDRTYPE *hdr, unsigned flags) { if (hdr==NULL) return -1; hdr->FLAG.UCAL &= !(flags & BIOSIG_FLAG_UCAL); hdr->FLAG.OVERFLOWDETECTION &= !(flags & BIOSIG_FLAG_OVERFLOWDETECTION); hdr->FILE.COMPRESSION &= !(flags & BIOSIG_FLAG_COMPRESSION); hdr->FLAG.ROW_BASED_CHANNELS &= !(flags & BIOSIG_FLAG_ROW_BASED_CHANNELS); return 0; }; int biosig_get_targetsegment(HDRTYPE *hdr) { if (hdr==NULL) return -1; return hdr->FLAG.TARGETSEGMENT; }; const char* biosig_get_filename(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->FileName; }; float biosig_get_version(HDRTYPE *hdr) { if (hdr==NULL) return NAN; return hdr->VERSION; }; int biosig_set_targetsegment(HDRTYPE *hdr, unsigned targetsegment) { return biosig_set_segment_selection(hdr, 0, targetsegment); }; int biosig_set_segment_selection(HDRTYPE *hdr, int k, uint32_t argSweepSel) {; if (hdr==NULL) return -1; if (k>5 || k<0) return -3; if (k==0) { if (argSweepSel > 127) { fprintf(stderr,"Warning libbiosig2: biosig_set_targetsegment is larger than 127 (%i)\n", argSweepSel); return -2; } hdr->FLAG.TARGETSEGMENT = argSweepSel; } else hdr->AS.SegSel[k-1] = argSweepSel; return 0; } uint32_t* biosig_get_segment_selection(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return (uint32_t*)&(hdr->AS.SegSel); }; long biosig_get_number_of_channels(HDRTYPE *hdr) { if (hdr==NULL) return -1; long k,m; for (k=0,m=0; kNS; k++) if (hdr->CHANNEL[k].OnOff==1) { m++; } return m; } size_t biosig_get_number_of_records(HDRTYPE *hdr) { if (hdr==NULL) return -1; return hdr->NRec; } size_t biosig_get_number_of_samples(HDRTYPE *hdr) { if (hdr==NULL) return -1; return hdr->NRec*hdr->SPR; } size_t biosig_get_number_of_samples_per_record(HDRTYPE *hdr) { if (hdr==NULL) return -1; return hdr->SPR; } size_t biosig_get_number_of_segments(HDRTYPE *hdr) { if (hdr==NULL) return 0; if (hdr->SPR==0) return 0; size_t k, n; for (k=0, n=1; kEVENT.N; k++) if (hdr->EVENT.TYP[k]==0x7ffe) n++; return n; } int biosig_set_number_of_channels(HDRTYPE *hdr, int ns) { if (hdr==NULL) return -1; // define variable header void *ptr = realloc(hdr->CHANNEL, ns*sizeof(CHANNEL_TYPE)); if (ptr==NULL) return -1; hdr->CHANNEL = (CHANNEL_TYPE*)ptr; int k; for (k=hdr->NS; k < ns; k++) { // initialize new channels CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->Label[0] = 0; hc->LeadIdCode= 0; strcpy(hc->Transducer, "EEG: Ag-AgCl electrodes"); hc->PhysDimCode = 19+4256; // uV hc->PhysMax = +100; hc->PhysMin = -100; hc->DigMax = +2047; hc->DigMin = -2048; hc->Cal = NAN; hc->Off = 0.0; hc->TOffset = 0.0; hc->GDFTYP = 3; // int16 hc->SPR = 1; // one sample per block hc->bi = 2*k; hc->bi8 = 16*k; hc->OnOff = 1; hc->HighPass = 0.16; hc->LowPass = 70.0; hc->Notch = 50; hc->Impedance = INFINITY; hc->fZ = NAN; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; } hdr->NS = ns; return 0; } int biosig_set_number_of_samples(HDRTYPE *hdr, ssize_t nrec, ssize_t spr) { if (hdr==NULL) return -1; if (nrec >= 0) hdr->NRec = nrec; if (spr >= 0) hdr->SPR = spr; return 0; } //ATT_DEPREC int biosig_set_number_of_segments(HDRTYPE *hdr, ) int biosig_get_datablock(HDRTYPE *hdr, double **data, size_t *rows, size_t *columns ) { if (hdr==NULL) return -1; *data = hdr->data.block; *rows = hdr->data.size[0]; *columns = hdr->data.size[1]; return 0; } biosig_data_type* biosig_get_data(HDRTYPE *hdr, char flag ) { if (hdr==NULL) return NULL; hdr->FLAG.ROW_BASED_CHANNELS = flag; sread(NULL, 0, hdr->NRec, hdr); return hdr->data.block; } double biosig_get_samplerate(HDRTYPE *hdr) { if (hdr==NULL) return NAN; return hdr->SampleRate; } int biosig_set_samplerate(HDRTYPE *hdr, double fs) { if (hdr==NULL) return -1; hdr->SampleRate=fs; return 0; } size_t biosig_get_number_of_events(HDRTYPE *hdr) { if (hdr==NULL) return 0; return hdr->EVENT.N; } size_t biosig_set_number_of_events(HDRTYPE *hdr, size_t N) { if (hdr==NULL) return 0; size_t k; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, N * 4 ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, N * 2 ); for (k = hdr->EVENT.N; kEVENT.POS[k] = 0; hdr->EVENT.TYP[k] = 0; } k = ( (hdr->EVENT.DUR==NULL) || (hdr->EVENT.CHN==NULL) ) ? 0 : hdr->EVENT.N; hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, N * 4 ); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, N * 2 ); for (; kEVENT.CHN[k] = 0; hdr->EVENT.DUR[k] = 0; } k = (hdr->EVENT.TimeStamp==NULL) ? 0 : hdr->EVENT.N; hdr->EVENT.TimeStamp = (gdf_time*) realloc(hdr->EVENT.TimeStamp, N * 8 ); for (; kEVENT.TimeStamp[k] = 0; } hdr->EVENT.N = N; return hdr->EVENT.N; } int biosig_get_nth_event(HDRTYPE *hdr, size_t n, uint16_t *typ, uint32_t *pos, uint16_t *chn, uint32_t *dur, gdf_time *timestamp, const char **desc) { if (hdr==NULL) return -1; if (hdr->EVENT.N <= n) return -1; uint16_t TYP=hdr->EVENT.TYP[n]; if (typ != NULL) *typ = TYP; if (pos != NULL) *pos = hdr->EVENT.POS[n]; if (chn != NULL) *chn = (hdr->EVENT.CHN==NULL) ? 0 : hdr->EVENT.CHN[n]; if (dur != NULL) *dur = (hdr->EVENT.DUR==NULL) ? 0 : hdr->EVENT.DUR[n]; if (timestamp != NULL) *timestamp = (hdr->EVENT.TimeStamp==NULL) ? 0 : hdr->EVENT.TimeStamp[n]; if ( (desc != NULL) ) *desc = (TYP < hdr->EVENT.LenCodeDesc) ? hdr->EVENT.CodeDesc[TYP] : NULL; return 0; } int biosig_set_nth_event(HDRTYPE *hdr, size_t n, uint16_t* typ, uint32_t *pos, uint16_t *chn, uint32_t *dur, gdf_time *timestamp, char *Desc) { if (hdr==NULL) return -1; if (hdr->EVENT.N <= n) biosig_set_number_of_events(hdr, n+1); if (typ != NULL) hdr->EVENT.TYP[n] = *typ; else if (typ == NULL) FreeTextEvent(hdr, n, Desc); // sets hdr->EVENT.TYP[n] if (pos != NULL) hdr->EVENT.POS[n] = *pos; if (chn != NULL) hdr->EVENT.CHN[n] = *chn; if (dur != NULL) hdr->EVENT.DUR[n] = *dur; if (timestamp != NULL) hdr->EVENT.TimeStamp[n] = *timestamp; return 0; } double biosig_get_eventtable_samplerate(HDRTYPE *hdr) { if (hdr==NULL) return NAN; return hdr->EVENT.SampleRate; } int biosig_set_eventtable_samplerate(HDRTYPE *hdr, double fs) { if (hdr==NULL) return -1; hdr->EVENT.SampleRate=fs; return 0; } int biosig_change_eventtable_samplerate(HDRTYPE *hdr, double fs) { if (hdr==NULL) return -1; if (hdr->EVENT.SampleRate==fs) return 0; size_t k; double ratio = fs/hdr->EVENT.SampleRate; for (k = 0; k < hdr->EVENT.N; k++) { uint32_t POS = hdr->EVENT.POS[k]; hdr->EVENT.POS[k] = ratio*POS; if (hdr->EVENT.DUR != NULL) hdr->EVENT.DUR[k] = (POS + hdr->EVENT.DUR[k]) * ratio - hdr->EVENT.POS[k]; } hdr->EVENT.SampleRate=fs; return 0; } // deprecated because time resolution is lost, use gdftime and its tools instead. __attribute__ ((deprecated)) int biosig_get_startdatetime(HDRTYPE *hdr, struct tm *T) { if (hdr==NULL) return -1; gdf_time2tm_time_r(hdr->T0, T); return (ldexp(hdr->T0,-32)<100.0); } int biosig_set_startdatetime(HDRTYPE *hdr, struct tm T) { if (hdr==NULL) return -1; hdr->T0 = tm_time2gdf_time(&T); return (ldexp(hdr->T0,-32)<100.0); } gdf_time biosig_get_startdatetime_gdf(HDRTYPE *hdr) { if (hdr==NULL) return 0; return(hdr->T0); } int biosig_set_startdatetime_gdf(HDRTYPE *hdr, gdf_time T) { if (hdr==NULL) return -1; hdr->T0 = T; return (ldexp(hdr->T0,-32)<100.0); } // deprecated because time resolution is lost, use gdftime and its tools instead. __attribute__ ((deprecated)) int biosig_get_birthdate(HDRTYPE *hdr, struct tm *T) { if (hdr==NULL) return -1; gdf_time2tm_time_r(hdr->Patient.Birthday, T); return (ldexp(hdr->Patient.Birthday,-32)<100.0); } int biosig_set_birthdate(HDRTYPE *hdr, struct tm T) { if (hdr==NULL) return -1; hdr->Patient.Birthday = tm_time2gdf_time(&T); return (ldexp(hdr->Patient.Birthday,-32)<100.0); } const char* biosig_get_patient_name(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->Patient.Name; } const char* biosig_get_patient_lastname(HDRTYPE *hdr, size_t *LengthLastName) { if (hdr==NULL) return NULL; *LengthLastName = strcspn(hdr->Patient.Name, "\x1f"); return hdr->Patient.Name; } const char* biosig_get_patient_firstname(HDRTYPE *hdr, size_t *LengthFirstName) { if (hdr==NULL) return NULL; char *tmpstr = strchr(hdr->Patient.Name, 0x1f); if (tmpstr==NULL) { *LengthFirstName = 0; return NULL; } *LengthFirstName = strcspn(tmpstr, "\x1f"); return tmpstr; } const char* biosig_get_patient_secondlastname(HDRTYPE *hdr, size_t *LengthSecondLastName) { if (hdr==NULL) return NULL; char *tmpstr = strchr(hdr->Patient.Name, 0x1f); if (tmpstr != NULL) tmpstr = strchr(tmpstr, 0x1f); if (tmpstr==NULL) { *LengthSecondLastName = 0; return NULL; } *LengthSecondLastName = strcspn(tmpstr, "\x1f"); return tmpstr; } const char* biosig_get_patient_id(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->Patient.Id; } const char* biosig_get_recording_id(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Recording; } const char* biosig_get_technician(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Technician; } const char* biosig_get_manufacturer_name(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Manufacturer.Name; } const char* biosig_get_manufacturer_model(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Manufacturer.Model; } const char* biosig_get_manufacturer_version(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Manufacturer.Version; } const char* biosig_get_manufacturer_serial_number(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->ID.Manufacturer.SerialNumber; } const char* biosig_get_application_specific_information(HDRTYPE *hdr) { if (hdr==NULL) return NULL; return hdr->AS.bci2000; } int biosig_set_patient_name(HDRTYPE *hdr, const char* name) { if (hdr==NULL) return -1; strncpy(hdr->Patient.Name, name, MAX_LENGTH_NAME); hdr->Patient.Name[MAX_LENGTH_NAME]=0; } int biosig_set_patient_name_structured(HDRTYPE *hdr, const char* LastName, const char* FirstName, const char* SecondLastName) { if (hdr==NULL) return -1; size_t len1 = (LastName ? strlen(LastName) : 0 ); size_t len2 = (FirstName ? strlen(FirstName) : 0 ); size_t len3 = (SecondLastName ? strlen(SecondLastName) : 0 ); if (len1+len2+len3+2 > MAX_LENGTH_NAME) { fprintf(stderr,"Error in function %s(...): total length of name too large (%i > %i)\n",__func__, (int)(len1+len2+len3+2), MAX_LENGTH_NAME); return -1; } strcpy(hdr->Patient.Name, LastName); // Flawfinder: ignore if (FirstName != NULL) { hdr->Patient.Name[len1]=0x1f; strcpy(hdr->Patient.Name+len1+1, FirstName); // Flawfinder: ignore } if (SecondLastName != NULL) { hdr->Patient.Name[len1+len2+1]=0x1f; strcpy(hdr->Patient.Name+len1+len2+2, SecondLastName); // Flawfinder: ignore } return 0; } int biosig_set_patient_id(HDRTYPE *hdr, const char* id) { if (hdr==NULL) return -1; strncpy(hdr->Patient.Id, id, MAX_LENGTH_PID); hdr->Patient.Id[MAX_LENGTH_PID]=0; return 0; } int biosig_set_recording_id(HDRTYPE *hdr, const char* rid) { if (hdr==NULL) return -1; strncpy(hdr->ID.Recording, rid, MAX_LENGTH_RID); hdr->ID.Recording[MAX_LENGTH_RID]=0; return 0; } int biosig_set_technician(HDRTYPE *hdr, const char* technician) { if (hdr==NULL) return -1; hdr->ID.Technician = (char*)technician; return 0; } int biosig_set_manufacturer_name(HDRTYPE *hdr, const char* rid) { if (hdr==NULL) return -1; hdr->ID.Manufacturer.Name = (char*)rid; return 0; } int biosig_set_manufacturer_model(HDRTYPE *hdr, const char* rid) { if (hdr==NULL) return -1; hdr->ID.Manufacturer.Model = rid; return 0; } int biosig_set_manufacturer_version(HDRTYPE *hdr, const char* rid) { if (hdr==NULL) return -1; hdr->ID.Manufacturer.Version = rid; return 0; } int biosig_set_manufacturer_serial_number(HDRTYPE *hdr, const char* rid) { if (hdr==NULL) return -1; hdr->ID.Manufacturer.SerialNumber = rid; return 0; } int biosig_set_application_specific_information(HDRTYPE *hdr, const char* appinfo) { if (hdr==NULL) return -1; hdr->AS.bci2000 = strdup(appinfo); return 0; } // returns M-th channel, M is 0-based CHANNEL_TYPE* biosig_get_channel(HDRTYPE *hdr, int M) { if (hdr==NULL) return NULL; typeof(hdr->NS) k,m; for (k=0,m=0; kNS; k++) if (hdr->CHANNEL[k].OnOff==1) { if (M==m) return hdr->CHANNEL+k; m++; } return NULL; } int biosig_channel_change_scale_to_physdimcode(CHANNEL_TYPE *hc, uint16_t physdimcode) { if (hc==NULL) return -1; if (hc->PhysDimCode == physdimcode) return 0; // nothing to do if ( (hc->PhysDimCode & 0xffe0) != (physdimcode & 0xffe0) ) return -2; // units do not match double scale = PhysDimScale(hc->PhysDimCode); scale /= PhysDimScale(physdimcode); hc->PhysDimCode = physdimcode; hc->PhysMax *= scale; hc->PhysMin *= scale; hc->Cal *= scale; hc->Off *= scale; return(0); } const char* biosig_channel_get_label(CHANNEL_TYPE *hc) { if (hc==NULL) return NULL; return hc->Label; } uint16_t biosig_channel_get_physdimcode(CHANNEL_TYPE *hc) { if (hc==NULL) return 0; return hc->PhysDimCode; } const char* biosig_channel_get_physdim(CHANNEL_TYPE *hc) { if (hc==NULL) return NULL; return PhysDim3(hc->PhysDimCode); } int biosig_channel_set_label(CHANNEL_TYPE *hc, const char* label) { if (hc==NULL) return -1; strncpy(hc->Label, label, MAX_LENGTH_LABEL); hc->Label[MAX_LENGTH_LABEL]=0; return 0; } int biosig_channel_set_physdimcode(CHANNEL_TYPE *hc, uint16_t physdimcode) { if (hc==NULL) return -1; hc->PhysDimCode = physdimcode; return 0; } int biosig_channel_get_scaling(CHANNEL_TYPE *hc, double *PhysMax, double *PhysMin, double *DigMax, double *DigMin) { if (hc==NULL) return -1; if (PhysMax != NULL) *PhysMax = hc->PhysMax; if (PhysMin != NULL) *PhysMax = hc->PhysMin; if (DigMax != NULL) *DigMax = hc->DigMax; if (DigMin != NULL) *DigMin = hc->DigMin; return 0; } int biosig_channel_set_scaling(CHANNEL_TYPE *hc, double PhysMax, double PhysMin, double DigMax, double DigMin) { if (hc==NULL) return -1; hc->PhysMax = PhysMax; hc->PhysMin = PhysMin; hc->DigMax = DigMax; hc->DigMin = DigMin; hc->Cal = ( PhysMax - PhysMin) / ( DigMax - DigMin ); hc->Off = PhysMin - DigMin * hc->Cal; return 0; } double biosig_channel_get_cal(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; double cal = ( hc->PhysMax - hc->PhysMin) / ( hc->DigMax - hc->DigMin ); assert(cal==hc->Cal); return (cal); } double biosig_channel_get_off(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; double off = hc->PhysMin - hc->DigMin * hc->Cal; assert(off==hc->Off); return off; } int biosig_channel_set_cal(CHANNEL_TYPE *hc, double cal) { if (hc==NULL) return -1; hc->Cal = cal; return 0; } int biosig_channel_set_off(CHANNEL_TYPE *hc, double off) { if (hc==NULL) return -1; hc->Off = off; return 0; } int biosig_channel_get_filter(CHANNEL_TYPE *hc, double *LowPass, double *HighPass, double *Notch) { if (hc==NULL) return -1; if (LowPass != NULL) *LowPass = hc->LowPass; if (HighPass != NULL) *HighPass = hc->HighPass; if (Notch != NULL) *Notch = hc->Notch; return 0; } int biosig_channel_set_filter(CHANNEL_TYPE *hc, double LowPass, double HighPass, double Notch) { if (hc==NULL) return -1; hc->LowPass = LowPass; hc->HighPass = HighPass; hc->Notch = Notch; return 0; } double biosig_channel_get_timing_offset(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; return hc->TOffset; } int biosig_channel_set_timing_offset(CHANNEL_TYPE *hc, double off) { if (hc==NULL) return -1; hc->TOffset = off; return 0; } double biosig_channel_get_impedance(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; return ( (hc->PhysDimCode & 0x7ffe) == 4256 ) ? hc->Impedance : NAN; } int biosig_channel_set_impedance(CHANNEL_TYPE *hc, double val) { if (hc==NULL) return -1; if ( (hc->PhysDimCode & 0x7ffe) != 4256 ) return -1; hc->Impedance = val; return 0; } uint16_t biosig_channel_get_datatype(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; return hc->GDFTYP; } int biosig_channel_set_datatype(CHANNEL_TYPE *hc, uint16_t gdftyp) { if (hc==NULL) return -1; hc->GDFTYP = gdftyp; return 0; } double biosig_get_channel_samplerate(HDRTYPE *hdr, int chan) { CHANNEL_TYPE *hc = biosig_get_channel(hdr, chan); if (hc==NULL) return -1; if (hdr==NULL) return -1; return (hdr->SampleRate * hc->SPR / hdr->SPR); } size_t biosig_channel_get_samples_per_record(CHANNEL_TYPE *hc) { if (hc==NULL) return -1; return hc->SPR; } int biosig_channel_set_samples_per_record(CHANNEL_TYPE *hc, size_t spr) { if (hc==NULL) return -1; hc->SPR = spr; return 0; } int biosig_set_channel_samplerate_and_samples_per_record(HDRTYPE *hdr, int chan, ssize_t spr, double fs) { CHANNEL_TYPE *hc = biosig_get_channel(hdr,chan); if (hc==NULL) return -1; if ((spr <= 0) && (fs >= 0.0)) { hc->SPR = hdr->SPR * fs / hdr->SampleRate; return 0; } if ((spr >= 0) && (fs != fs)) { hc->SPR = spr; return 0; } assert (hdr->SampleRate * hc->SPR == fs * hdr->SPR); return (hdr->SampleRate * hc->SPR != fs * hdr->SPR); } const char *biosig_channel_get_transducer(CHANNEL_TYPE *hc) { if (hc==NULL) return(NULL); return (hc->Transducer); } int biosig_channel_set_transducer(CHANNEL_TYPE *hc, const char *transducer) { if (hc==NULL) return(-1); strncpy(hc->Transducer, transducer, MAX_LENGTH_TRANSDUCER+1); return (0); } /* DO NOT USE DO NOT USE DO NOT USE DO NOT USE the functions below are experimental and have not been used so far in any productions system They will be removed or significantly changed . DO NOT USE DO NOT USE DO NOT USE DO NOT USE */ #define hdrlistlen 64 struct hdrlist_t { HDRTYPE *hdr; // header information as defined in level 1 interface //const char *filename; // name of file, is always hdr->FileName uint16_t NS; // number of effective channels, only CHANNEL[].OnOff==1 are considered size_t *chanpos; // position of file handle for each channel } ; struct hdrlist_t hdrlist[hdrlistlen]; CHANNEL_TYPE *getChannelHeader(HDRTYPE *hdr, uint16_t channel) { // returns channel header - skip Off-channels CHANNEL_TYPE *hc = hdr->CHANNEL; typeof(hdr->NS) chan = 0; while (1) { if (hc->OnOff==1) { if (chan==channel) return hc; chan++; } hc++; } return NULL; } int biosig_lib_version(void) { return (BIOSIG_VERSION); } biosig_handle_t biosig2_open_file_readonly(const char *path, int read_annotations) { /* on success returns handle. */ HDRTYPE *hdr = sopen(path,"r",NULL); if (serror2(hdr)) { destructHDR(hdr); return(NULL); } if (read_annotations) sort_eventtable(hdr); return(hdr); } int biosig_open_file_readonly(const char *path, int read_annotations) { /* on success returns handle. */ int k = 0; while (k < hdrlistlen && hdrlist[k].hdr != NULL) k++; if (k >= hdrlistlen) return(-1); HDRTYPE *hdr = sopen(path,"r",NULL); hdrlist[k].hdr = hdr; //hdrlist[k].filename = hdr->FileName; hdrlist[k].NS = 0; hdrlist[k].chanpos = calloc(hdrlist[k].NS,sizeof(size_t)); if (read_annotations) sort_eventtable(hdrlist[k].hdr); return(k); } int biosig2_close_file(biosig_handle_t hdr) { destructHDR(hdr); return(0); } int biosig_close_file(int handle) { destructHDR(hdrlist[handle].hdr); hdrlist[handle].hdr = NULL; if (hdrlist[handle].chanpos) free(hdrlist[handle].chanpos); hdrlist[handle].NS = 0; //hdrlist[handle].filename = NULL; #if 0 int k; for (k=0; k= hdrlistlen || hdrlist[handle].hdr==NULL || hdrlist[handle].NS<=channel ) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; CHANNEL_TYPE *hc = getChannelHeader(hdr,channel); size_t stride = 1; // stride between consecutive samples of same channel, depends on data orientation hdr->FLAG.ROW_BASED_CHANNELS size_t div = hdr->SPR/hc->SPR; // stride if sample rate of channel is smaller than the overall sampling rate size_t POS = hdrlist[handle].chanpos[channel]*div; // size_t LEN = n*div; size_t startpos = POS/hdr->SPR; // round towards 0 size_t endpos = (POS+LEN)/hdr->SPR + ((POS+LEN)%hdr->SPR != 0); // round towards infinity if (hdr->AS.first > startpos || (endpos-startpos) > hdr->AS.length || hdr->FLAG.UCAL!=UCAL) { // read data when not in data buffer hdr->data.block hdr->FLAG.UCAL = UCAL; sread(NULL, startpos, endpos - startpos, hdr); } // when starting position is not aligned with start of data size_t offset = hdr->AS.first * hdr->SPR - POS; // find starting position and stride of data double *data = hdr->data.block; if (hdr->FLAG.ROW_BASED_CHANNELS) { stride = hdr->data.size[0]; data = hdr->data.block + channel + offset * stride; } else { data = hdr->data.block + offset + channel * hdr->data.size[0]; } size_t k; for (k = 0; k < n; k++) { buf[k] = data[k*div*stride]; // copy data into output buffer } hdrlist[handle].chanpos[channel] += n; // update position pointer of channel chan return (0); } /* int biosig_read_physical_samples(int handle, size_t biosig_signal, size_t n, double *buf) { return biosig_read_samples(handle, biosig_signal, n, buf, (unsigned char)(0)); } int biosig_read_digital_samples(int handle, size_t biosig_signal, size_t n, double *buf) { return biosig_read_samples(handle, biosig_signal, n, buf, (unsigned char)(1)); } */ size_t biosig_seek(int handle, long long offset, int whence) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; sseek(hdr, offset, whence); return (hdr->FILE.POS); } size_t biosig_tell(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); return(stell(hdrlist[handle].hdr)); } void biosig_rewind(int handle, int biosig_signal) { /* It is equivalent to: (void) biosig_seek(int handle, int biosig_signal, 0LL, biosig_SEEK_SET) */ if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return; srewind(hdrlist[handle].hdr); } biosig_handle_t biosig2_open_file_writeonly(const char *path, enum FileFormat filetype, int number_of_signals) { /* TODO: does not open file and write to file */ HDRTYPE *hdr = constructHDR(number_of_signals,0); hdr->FLAG.UCAL = 0; hdr->FLAG.OVERFLOWDETECTION = 0; hdr->FILE.COMPRESSION = 0; return(hdr); } int biosig_open_file_writeonly(const char *path, enum FileFormat filetype, int number_of_signals) { /* TODO: does not open file and write to file */ #if 1 int k = 0; while (k < hdrlistlen && hdrlist[k].hdr != NULL) k++; if (k>=hdrlistlen) return -1; HDRTYPE *hdr = constructHDR(number_of_signals,0); #else HDRTYPE *hdr = constructHDR(number_of_signals,0); if (hdr==NULL) return (-1); hdr->FileName = strdup(path); hdr->TYPE = filetype; int k = 0; while (k < hdrlistlen && hdrlist[k].hdr != NULL) k++; if (k>=hdrlistlen) { void *ptr = realloc(hdrlist, (k+1)*sizeof(*hdrlist)); if (ptr==NULL) return (-1); hdrlist = (struct hdrlist_t*) ptr; hdrlistlen = k+1; } #endif hdr->FLAG.UCAL = 0; hdr->FLAG.OVERFLOWDETECTION = 0; hdr->FILE.COMPRESSION = 0; hdrlist[k].hdr = hdr; return(0); } double biosig_get_global_samplefrequency(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); return (hdrlist[handle].hdr->SampleRate); } int biosig_set_global_samplefrequency(int handle, double samplefrequency) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); hdrlist[handle].hdr->SampleRate = samplefrequency; return 0; } double biosig_get_samplefrequency(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NAN); return (hdr->SampleRate*hdr->CHANNEL[biosig_signal].SPR/hdr->SPR); } int biosig_set_samplefrequency(int handle, int biosig_signal, double samplefrequency) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = 0; int ch; for (ch = 0; ch < hdr->NS; ch++) { if (hdr->CHANNEL[ch].OnOff==1) { if (ns==biosig_signal) break; ns++; } } if (ch >= hdr->NS) return(-1); // FIXME: resulting sampling rate might depend on calling order; what's the overall sampling rate ? if (samplefrequency != hdr->SampleRate) { double spr = samplefrequency * hdr->SPR / hdr->SampleRate; hdr->CHANNEL[biosig_signal].SPR = spr; if (spr != ceil(spr)) return (-2); return 0; } hdr->CHANNEL[ch].SPR = hdr->SPR; return 0; } double biosig_get_physical_maximum(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NAN); return (hdr->CHANNEL[biosig_signal].PhysMax); } int biosig_set_physical_maximum(int handle, int biosig_signal, double phys_max) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].PhysMax = phys_max; return (0); } double biosig_get_physical_minimum(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NAN); return (hdr->CHANNEL[biosig_signal].PhysMin); } int biosig_set_physical_minimum(int handle, int biosig_signal, double phys_min) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].PhysMin = phys_min; return (0); } double biosig_get_digital_maximum(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NAN); return (hdr->CHANNEL[biosig_signal].DigMax); } int biosig_set_digital_maximum(int handle, int biosig_signal, double dig_max) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].DigMax = dig_max; return (0); } double biosig_get_digital_minimum(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NAN); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NAN); return (hdr->CHANNEL[biosig_signal].DigMin); } int biosig_set_digital_minimum(int handle, int biosig_signal, double dig_min) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].DigMin = dig_min; return (0); } const char *biosig_get_label(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NULL); return (hdr->CHANNEL[biosig_signal].Label); } int biosig_set_label(int handle, int biosig_signal, const char *label) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); strncpy(hdr->CHANNEL[biosig_signal].Label, label, MAX_LENGTH_LABEL); return (0); } int biosig_set_prefilter(int handle, int biosig_signal, const char *prefilter) { // TODO: parse prefilter and call biosig_set_{highpass,lowpass,notch}filter return fprintf(stderr,"Warning: biosig_set_prefilter(...) is not implemented, use instead biosig_set_highpassfilter(),biosig_set_lowpassfilter(),biosig_set_notchfilter().\n"); } int biosig_set_highpassfilter(int handle, int biosig_signal, double frequency) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].HighPass = frequency; return 0; } int biosig_set_lowpassfilter(int handle, int biosig_signal, double frequency) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].LowPass = frequency; return 0; } int biosig_set_notchfilter(int handle, int biosig_signal, double frequency) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].Notch = frequency; return (0); } const char *biosig_get_transducer(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NULL); return (hdr->CHANNEL[biosig_signal].Transducer); } int biosig_set_transducer(int handle, int biosig_signal, const char *transducer) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); strncpy(hdr->CHANNEL[biosig_signal].Transducer, transducer, MAX_LENGTH_TRANSDUCER+1); return (0); } const char *biosig_physical_dimension(int handle, int biosig_signal) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(NULL); return (PhysDim3(hdr->CHANNEL[biosig_signal].PhysDimCode)); } int biosig_set_physical_dimension(int handle, int biosig_signal, const char *phys_dim) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; typeof(hdr->NS) ns = hdr->NS; if (biosig_signal >= ns) return(-1); hdr->CHANNEL[biosig_signal].PhysDimCode = PhysDimCode(phys_dim); return (0); } int edf_set_startdatetime(int handle, int startdate_year, int startdate_month, int startdate_day, int starttime_hour, int starttime_minute, int starttime_second) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; struct tm T; T.tm_year = startdate_year; T.tm_mon = startdate_month; T.tm_mday = startdate_day; T.tm_hour = starttime_hour; T.tm_min = starttime_minute; T.tm_sec = starttime_second; hdr->T0 = tm_time2gdf_time(&T); return (0); } const char *biosig_get_patientname(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); return(hdrlist[handle].hdr->Patient.Name); } int biosig_set_patientname(int handle, const char *patientname) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); strncpy(hdrlist[handle].hdr->Patient.Name, patientname, MAX_LENGTH_NAME+1); return (0); } const char *biosig_get_patientcode(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); return(hdrlist[handle].hdr->Patient.Id); } int biosig_set_patientcode(int handle, const char *patientcode) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); strncpy(hdrlist[handle].hdr->Patient.Id, patientcode, MAX_LENGTH_PID+1); return(0); } int biosig_get_gender(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(0); return(hdrlist[handle].hdr->Patient.Sex); } int biosig_set_gender(int handle, int gender) { if (gender<0 || gender>9) return (-1); if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); switch (gender) { case 1 : case 'm': case 'M': hdrlist[handle].hdr->Patient.Sex = 1; return(0); case 2 : case 'f': case 'F': hdrlist[handle].hdr->Patient.Sex = 2; return(0); default: return(0); } } int edf_set_birthdate(int handle, int birthdate_year, int birthdate_month, int birthdate_day) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; struct tm T; T.tm_year = birthdate_year; T.tm_mon = birthdate_month; T.tm_mday = birthdate_day; T.tm_hour = 12; T.tm_min = 0; T.tm_sec = 0; hdr->Patient.Birthday = tm_time2gdf_time(&T); return (0); } int biosig_set_patient_additional(int handle, const char *patient_additional) { fprintf(stderr,"Warning: biosig_set_patient_additional() not supported.\n"); return (-1); } int biosig_set_admincode(int handle, const char *admincode) { fprintf(stderr,"Warning: biosig_set_admincode() not supported.\n"); return (-1); } /* const char *biosig_get_technician(int handle) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(NULL); HDRTYPE *hdr = hdrlist[handle].hdr; return(hdr->ID.Technician); } int biosig_set_technician(int handle, const char *technician) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; hdr->ID.Technician = realloc(hdr->ID.Technician, strlen(technician)+1); strcpy(hdr->ID.Technician, technician); return(0); } */ // TODO: implement the following functions int biosig_set_equipment(int handle, const char *equipment) { return (-1); } int biosig_set_recording_additional(int handle, const char *recording_additional) { return (-1); } int biosig_write_physical_samples(int handle, double *buf) { return (-1); } int biosig_blockwrite_physical_samples(int handle, double *buf) { return (-1); } int biosig_write_digital_samples(int handle, int *buf) { return (-1); } int biosig_blockwrite_digital_samples(int handle, int *buf) { return (-1); } int biosig_write_annotation(int handle, size_t onset, size_t duration, const char *description) { /* onset and duration are in samples */ if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; size_t N = hdr->EVENT.N++; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*(hdr->EVENT.POS)) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*(hdr->EVENT.TYP)) ); hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, hdr->EVENT.N*sizeof(*(hdr->EVENT.DUR)) ); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, hdr->EVENT.N*sizeof(*(hdr->EVENT.CHN)) ); hdr->EVENT.POS[N] = onset; hdr->EVENT.DUR[N] = duration; hdr->EVENT.CHN[N] = 0; FreeTextEvent(hdr, N, description); return (hdr->AS.B4C_ERRNUM); } int biosig_write_annotation_utf8(int handle, size_t onset, size_t duration, const char *description) { fprintf(stdout,"biosig_write_annotation_latin1(): It's recommended to use biosig_write_annotation() instead.\n"); return ( biosig_write_annotation(handle, onset, duration, description) ); } int biosig_write_annotation_latin1(int handle, size_t onset, size_t duration, const char *description) { fprintf(stdout,"biosig_write_annotation_latin1(): It's recommended to use biosig_write_annotation() instead.\n"); return ( biosig_write_annotation(handle, onset, duration, description) ); } int biosig_set_datarecord_duration(int handle, double duration) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; double spr = hdr->SampleRate * duration; size_t rspr = round(spr); if (fabs(spr - rspr) > 1e-8*spr) { fprintf(stderr,"Warning biosig_set_datarecord_duration(): number of samples is not integer (%g) - rounded to integers (%i)\n",spr,(int)rspr); } hdr->SPR = (size_t)rspr; return 0; } /****************************************************************************************** biosig_unserialize_header: converts memory buffer into header structure HDR biosig_unserialize: converts memory buffer into header structure HDR, and if data != NULL, data samples will be read into a matrix, the starting address of this data matrix will be stored in *data point to *data input: mem : buffer len : length of buffer mem start: starting position to extract data length: number of samples for extracting data, flags: BIOSIG_FLAG_UCAL | BIOSIG_FLAG_OVERFLOWDETECTION | BIOSIG_FLAG_ROW_BASED_CHANNELS output: *data will contain start address to matrix data samples, of size hdr->NS * (hdr->SPR * hdr->NRec) or its transpose form depending on flags return value: header structure HDRTYPE* hdr. ******************************************************************************************/ HDRTYPE* biosig_unserialize(void *mem, size_t len, size_t start, size_t length, biosig_data_type **data, int flags) { fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); HDRTYPE *hdr = constructHDR(0,0); // decode header fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); hdr->AS.Header = mem; // in case of error, memory is deallocated through destructHDR(hdr); if (gdfbin2struct(hdr)) return(hdr); // in case of success, memory is managed by its own pointer *mem hdr->AS.Header = NULL; fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); // get data block biosig_set_flag(hdr, flags); if (data != NULL) { hdr->AS.rawdata = mem+hdr->HeadLen; size_t L = sread(*data, start, length, hdr); *data = hdr->data.block; hdr->data.block = NULL; } hdr->AS.rawdata = NULL; fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); // read eventtable hdr->AS.rawEventData = (hdr->NRec != -1) ? mem + hdr->HeadLen + hdr->NRec*hdr->AS.bpb : NULL; rawEVT2hdrEVT(hdr, len - hdr->HeadLen - hdr->NRec*hdr->AS.bpb); // in case of success, memory is managed by its own pointer *mem hdr->AS.rawEventData = NULL; fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); return(hdr); } /****************************************************************************************** biosig_serialize: converts header structure into memory buffer input: hdr: header structure, including event table. output: *mem will contain start address of buffer *len will contain length of buffer mem. ******************************************************************************************/ void* biosig_serialize(HDRTYPE *hdr, void **mem, size_t *len) { // encode header fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); hdr->TYPE=GDF; hdr->VERSION=3.0; struct2gdfbin(hdr); fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); // write event table size_t len3 = hdrEVT2rawEVT(hdr); fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); size_t len0 = hdr->HeadLen + hdr->NRec*hdr->AS.bpb + len3; char* M = (char*)realloc(*mem,len0); if (M == NULL) return(NULL); *mem = M; *len = len0; // write header into buffer memcpy(M, hdr->AS.Header, hdr->HeadLen); fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); // write data into buffer, and collapse unused channels size_t count = sread_raw(0, hdr->NRec, hdr, 1, M + hdr->HeadLen, hdr->NRec*hdr->AS.bpb); fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); // write event table into buffer memcpy(M + hdr->HeadLen + hdr->NRec*hdr->AS.bpb, hdr->AS.rawEventData, len3); fprintf(stdout,"%s (line %i) %s:\n",__FILE__,__LINE__,__func__); return(M); } #if defined(MAKE_EDFLIB) int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals) { enum FileFormat fmt=unknown; switch (filetype) { case EDFLIB_FILETYPE_EDF: case EDFLIB_FILETYPE_EDFPLUS: fmt = EDF; break; case EDFLIB_FILETYPE_BDF: case EDFLIB_FILETYPE_BDFPLUS: fmt = EDF; break; default: return(-1); } return(biosig_open_file_writeonly(path, fmt, number_of_signals)); } int edf_set_gender(int handle, int gender) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; hdr->Patient.Sex = (gender==1) + (gender==0)*2 ; } int edfread_physical_samples(int handle, int edfsignal, int n, double *buf) { fprintf(stderr,"error: edfread_physical_samples - use biosig_read_physical_samples instead.\n"); return(-1); } int edfread_digital_samples(int handle, int edfsignal, int n, int *buf) { fprintf(stderr,"error: edfread_digital_samples - use biosig_read_digital_samples instead.\n"); return(-1); } long long edfseek(int handle, int channel, long long offset, int whence) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL || hdrlist[handle].NS<=channel ) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; switch (whence) { case SEEK_SET: hdrlist[handle].chanpos[channel] = offset; // update position pointer of channel chan break; case SEEK_CUR: hdrlist[handle].chanpos[channel] += offset; // update position pointer of channel chan break; case SEEK_END: { CHANNEL_TYPE *hc = getChannelHeader(hdr,channel); hdrlist[handle].chanpos[channel] = hdr->NRec*hc->SPR + offset; // update position pointer of channel chan break; } } return (hdrlist[handle].chanpos[channel]); } long long edftell(int handle, int channel) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL || hdrlist[handle].NS<=channel ) return(-1); return ( hdrlist[handle].chanpos[channel] ); } int edfrewind(int handle, int channel) { /* It is equivalent to: (void) edf_seek(int handle, int biosig_signal, 0LL, SEEK_SET) */ if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL || hdrlist[handle].NS<=channel ) return(-1); hdrlist[handle].chanpos[channel] = 0; return(0); } int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot) { if (handle<0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; annot->onset = hdr->EVENT.POS[n]*1e4/hdr->EVENT.SampleRate; annot->duration = hdr->EVENT.DUR[n]*1e4/hdr->EVENT.SampleRate; strncpy(annot->annotation,GetEventDescription(hdr, n),sizeof(annot->annotation)); return(0); } int edfwrite_annotation(int handle, size_t onset, size_t duration, const char *description) { /* onset and duration are multiples of 100 microseconds */ if (handle < 0 || handle >= hdrlistlen || hdrlist[handle].hdr==NULL) return(-1); HDRTYPE *hdr = hdrlist[handle].hdr; return (biosig_write_annotation(handle, onset*1e-4*hdr->EVENT.SampleRate, duration*1e-4*hdr->EVENT.SampleRate, description)); } /* TODO: the following functions neeed to be implemented */ int edf_set_recording_additional(int handle, const char *recording_additional) { return fprintf(stderr,"this function is not implemented, yet.\n"); } int edfwrite_physical_samples(int handle, double *buf) { return fprintf(stderr,"this function is not implemented, yet.\n"); } int edf_blockwrite_physical_samples(int handle, double *buf) { return fprintf(stderr,"this function is not implemented, yet.\n"); } /* int edfwrite_digital_samples(int handle, int *buf) { return fprintf(stderr,"this function is not implemented, yet.\n"); } */ int edf_blockwrite_digital_samples(int handle, int *buf) { return fprintf(stderr,"this function is not implemented, yet.\n"); } #endif biosig-2.3.3/biosig4c++/biosig.pro0000664000175000017500000000060714105434233017010 0ustar schloeglschloeglTEMPLATE = lib TARGET = biosig QMAKE_CC = $(CXX) INCLUDEPATH += ./ \ ./t210 \ ./t220 \ ./t230 \ ./XMLParser LIBS += -lz CONFIG += warn_on \ staticlib \ release HEADERS += *.h \ t210\*.h \ XMLParser\*.h SOURCES += *.c \ t210\*.c \ t210\*.cpp \ t220\*.c \ t230\*.c \ test0\sandbox.c \ XMLParser\*.cpp biosig-2.3.3/biosig4c++/biosig2.h0000664000175000017500000000160414105434233016517 0ustar schloeglschloegl/* Copyright (C) 2017 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ // #error Instead of biosig2.h use #include #include "biosig.h" biosig-2.3.3/biosig4c++/save2aecg0000775000175000017500000000016714105434233016601 0ustar schloeglschloegl#!/bin/sh # SAVE2AECG converts short-term ECG format # into XML-based HL7v3 Annotated ECG format # save2gdf -f=HL7 $@ biosig-2.3.3/biosig4c++/doc/0000775000175000017500000000000014105434233015554 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/doc/rec2bin.10000664000175000017500000000150114105434233017157 0ustar schloeglschloegl.TH REC2BIN 1 .SH NAME rec2bin - converts biosignal data into a header file in ASCII format, and a binary file for every channel. .SH SYNOPSIS .B REC2BIN\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/save2gdf.10000664000175000017500000000212614105434233017340 0ustar schloeglschloegl.TH SAVE2GDF 1 .SH NAME save2gdf - converts different biomedical signal file formats. .SH SYNOPSIS .B save2gdf\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-f=FMT converts data into format FMT FMT must represent a valid target file format Currently are supported: HL7aECG, SCP_ECG (EN1064), GDF (v2), GDF1 (v1), EDF, BDF, CFWB, BIN, ASCII, BVA (BrainVision) \-z compress data using gzip \-z=#, compress data with level # #=0 no compression; #=9 best compression \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2019 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/save2scp.10000664000175000017500000000144114105434233017364 0ustar schloeglschloegl.TH SAVE2SCP 1 .SH NAME save2scp - converts short-term ECG data into the EN1094 SCP-ECG format. .SH SYNOPSIS .B SAVE2SCP\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/biosig_fhir.10000664000175000017500000000205614105434233020125 0ustar schloeglschloegl.TH BIOSIG_FHIR 1 .SH NAME biosig_fhir - provides fhir binary template for biosignal data .SH SYNOPSIS .B biosig_fhir\ [-json|-xml|-base64]\ .SH DESCRIPTION reads filename and converts it fhir-(json|xml)-binary-template or a media-type X-biosig/gdf (i.e. base64-encoded GDF stream). is the name of biomedical signal file Supported OPTIONS are: \-json prints metainformation (header, annotations, etc.) in JSON format to standard output \-xml prints metainformation (header, annotations, etc.) in XML-based format to standard output \-base64 encapsulates biosignal data in base64-encoded GDF format. Supported data formats .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2016-2019 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/biosig2gdf.10000664000175000017500000000231314105434233017654 0ustar schloeglschloegl.TH BIOSIG2GDF 1 .SH NAME biosig2gdf - converts different biomedical signal file formats into a simplified version of GDF, and can stream the result to stdout. This is useful for reading the data by an unnamed pipe into different programming environment, while a simplified parser can be used to decode the data. The conversion performs a conversion to GDFv3 format, where all channels have the same data type and the same sampling rate. .SH SYNOPSIS .B biosig2gdf\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-z compress data using gzip \-z=#, compress data with level # #=0 no compression; #=9 best compression .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/physicalunits.10000664000175000017500000000333514105434233020541 0ustar schloeglschloegl.TH pu 1 .SH NAME physicalunits - encodes and de-codes physical units a according to ISO/IEEE 11073-10101:2004 Tables A6.1 and A6.3 physicalunits was formerly also known under "pu". .SH SYNOPSIS physicalunits [units_or_codes] .SH DESCRIPTION The output returns the :, where represents the character ascii(9) .SH Examples: Encoding of "microVolts", using text representation, decimal encoding and hexadecimal encoding: physicalunits mV uV 4275 0x10b3 1e-06 V physicalunits 4275 uV 4275 0x10b3 1e-06 V physicalunits 0x10b3 uV 4275 0x10b3 1e-06 V Text representation containing spaces need to be quoted physicalunits "kg l-1" kg l-1 2051 0x0803 1000 g l-1 A list of units can be converted using multiple input arguments physicalunits mV nA 4180 kg dag degree rpm "mol mol-1" "kg l-1" mV 4274 0x10b2 0.001 V nA 4180 0x1054 1e-09 A nA 4180 0x1054 1e-09 A kg 1731 0x06c3 1000 g dag 1729 0x06c1 10 g degree 736 0x02e0 1 degree rpm 6816 0x1aa0 1 rpm mol mol-1 864 0x0360 1 mol mol-1 kg l-1 2051 0x0803 1000 g l-1 physicalunits `seq 0 65535` |grep -v nan |grep -v null shows s complete table of defined units .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2019 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/save2aecg.10000664000175000017500000000145014105434233017476 0ustar schloeglschloegl.TH SAVE2AECG 1 .SH NAME save2aecg - converts short-term ECG data into XML-based HL7v3 annotated ECG. .SH SYNOPSIS .B SAVE2AECG\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/mexSLOAD.10000664000175000017500000000205414105434233017213 0ustar schloeglschloegl.TH mexSLOAD 1 .SH NAME mexSLOAD - a mex-functions for loading biomedical signal data into Octave or Matlab. .SH DESCRIPTION [s,HDR]=sload(f) [s,HDR]=sload(f,chan) chan must be sorted in ascending order [s,HDR]=sload(f,chan,"OVERFLOWDETECTION:ON") [s,HDR]=sload(f,chan,"OVERFLOWDETECTION:OFF") [s,HDR]=sload(f,chan,"UCAL:ON") [s,HDR]=sload(f,chan,"UCAL:OFF") Input: f filename chan list of selected channels; 0=all channels [default] UCAL ON: do not calibrate data; default=OFF OVERFLOWDETECTION default = ON ON: values outside dynamic range are not-a-number (NaN) Output: s signal data, each column is one channel HDR header structure .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2019 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/sigviewer.10000664000175000017500000000206314105434233017643 0ustar schloeglschloegl.TH SigViewer 1 .SH NAME SigViewer - a viewing and scoring tools for biomedical signals. .SH SYNOPSIS .B sigviewer .SH DESCRIPTION SigViewer is a viewing and scoring software for biomedical signal data. A number of data formats (including EDF, BDF, GDF, BrainVision, BCI2000, CFWB, HL7aECG, SCP_ECG (EN1064), MFER, ACQ, CNT(Neuroscan), DEMG, EGI, EEG1100, FAMOS, SigmaPLpro, TMS32) are supported. The complete list of supported file formats is available at http://hci.tugraz.at/schloegl/biosig/TESTED . .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2007-2009 Thomas Brunner Copyright (C) 2008-2010,2018 Alois Schloegl Copyright (C) 2008-2020 Clemens Brunner Copyright (C) 2008-2011 Christoph Eibel Copyright (C) 2017 Yida Lin License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.net biosig-2.3.3/biosig4c++/doc/heka2itx.10000664000175000017500000000161014105434233017353 0ustar schloeglschloegl.TH HEKA2ITX 1 .SH NAME heka2itx - converts a Heka file into an ITX (IgorPro text) file. .SH SYNOPSIS .B heka2itx\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-SWEEP=ne,ng,ns [OPTIONAL] select sweep ns from group ng from experiment ne 0 indicates a wildcard. \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/doc/bin2rec.10000664000175000017500000000165214105434233017166 0ustar schloeglschloegl.TH BIN2REC 1 .SH NAME bin2rec - converts biosignal data produced with rec2bin, into a gdf file. rec2bin and bin2rec are complementary functions, which can be useful to dump data, edit date and revert it back into the original format. .SH SYNOPSIS .B REC2BIN\ [OPTIONS]\ SOURCE\ [DEST] .SH DESCRIPTION SOURCE is the source file DEST is the destination file Supported OPTIONS are: \-v, \-\-version prints version information \-h, \-\-help prints this information \-VERBOSE=#, verbosity level # 0=silent, 9=debugging .SH AUTHOR Alois Schloegl .SH REPORTING BUGS Report bugs to .SH COPYRIGHT Copyright (C) 2008-2020 Alois Schloegl License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH RESOURCES https://biosig.sourceforge.io biosig-2.3.3/biosig4c++/examples/0000775000175000017500000000000014105434244016627 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/examples/Makefile.in0000664000175000017500000000060514105434233020673 0ustar schloeglschloegl all: test %:%.c $(CC) -DHL1 $< -lbiosig -lm -o $@.HL1 $(CC) -DHL2 $< -lbiosig -lm -o $@.HL2 $(CC) -DLL1 $< -lbiosig -lm -o $@.LL1 $(CC) -DLL2 $< -lbiosig -lm -o $@.LL2 test: generate_gdf_file -./generate_gdf_file.HL1 hl1.gdf -./generate_gdf_file.HL2 hl2.gdf -./generate_gdf_file.LL1 ll1.gdf -./generate_gdf_file.LL2 ll2.gdf clean: rm *.gdf generate_gdf_file.[HL]L[12] biosig-2.3.3/biosig4c++/examples/Makefile0000664000175000017500000000060514105434244020270 0ustar schloeglschloegl all: test %:%.c $(CC) -DHL1 $< -lbiosig -lm -o $@.HL1 $(CC) -DHL2 $< -lbiosig -lm -o $@.HL2 $(CC) -DLL1 $< -lbiosig -lm -o $@.LL1 $(CC) -DLL2 $< -lbiosig -lm -o $@.LL2 test: generate_gdf_file -./generate_gdf_file.HL1 hl1.gdf -./generate_gdf_file.HL2 hl2.gdf -./generate_gdf_file.LL1 ll1.gdf -./generate_gdf_file.LL2 ll2.gdf clean: rm *.gdf generate_gdf_file.[HL]L[12] biosig-2.3.3/biosig4c++/examples/generate_gdf_file.c0000664000175000017500000002540314105434233022406 0ustar schloeglschloegl/* Example how to generate GDF files as C/C++ code. This is only a rough outline, for details, please check biosig.h. Copyright (C) 2016,2018 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include extern int VERBOSE_LEVEL; int main(int argc, char* argv[]) { VERBOSE_LEVEL = 8; int number_of_channels=4; int number_of_events=0; double sampling_rate = 5000; // Hz size_t total_number_of_samples=100000; size_t number_of_epochs=5; HDRTYPE *hdr=constructHDR(number_of_channels, number_of_events); /* alternatively, number of channels, and number of events can be set this way. HDRTYPE *hdr=constructHDR(0, 0); biosig_set_number_of_channels(hdr, number_of_channels); biosig_set_number_of_events(hdr, number_of_events); */ // set sampling rate biosig_set_samplerate(hdr, sampling_rate); /* the data layout can be controlled in this way. Here it is assumed, that all channels have the same sampling rate It's also possible, the define different sampling rates for different channels through hdr->CHANNEL[ch].SPR and biosig_channel_set_samples_per_record(hdr->CHANNEL[ch], spr); */ size_t nrec,spr; // multiplexed data spr=1; nrec=total_number_of_samples; // channel-based data spr=total_number_of_samples; nrec=1; // sweep-based data spr=total_number_of_samples/number_of_epochs; nrec=number_of_epochs; // any other combination is fine as long as assert( spr*nrec == total_number_of_samples); biosig_set_number_of_samples(hdr, nrec, spr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); /************************************************************* define channel properties *************************************************************/ double PhysMax=10; double PhysMin=0; double DigMax= 32767; double DigMin=-32768; double LowPass=sampling_rate/4; double HighPass=0.0; double Notch=50; // 0: notch off, NaN: unkown int chan; chan=0; CHANNEL_TYPE *CH = biosig_get_channel(hdr, chan); biosig_channel_set_label(CH, "Channel 1"); biosig_channel_set_unit(CH,"mV"); biosig_channel_set_scaling(CH, PhysMax, PhysMin, DigMax, DigMin); biosig_channel_set_datatype_to_int16(CH); biosig_channel_set_filter(CH, LowPass, HighPass, Notch); biosig_channel_set_transducer(CH, "EEG"); biosig_channel_set_timing_offset(CH, 0); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); // do the same for all other channels for (chan++; chan < number_of_channels; chan++) { CHANNEL_TYPE *CH = biosig_get_channel(hdr, chan); biosig_channel_set_label(CH, "Channel 2"); biosig_channel_set_unit(CH,"mV"); biosig_channel_set_scaling(CH, PhysMax, PhysMin, DigMax, DigMin); biosig_channel_set_datatype_to_int16(CH); biosig_channel_set_filter(CH, LowPass, HighPass, Notch); biosig_channel_set_timing_offset(CH, chan*1e-6); // e.g. 1us delay in ADC multiplexer, 0.0 when simultaneous sampling } CHANNEL_TYPE *ch1 = biosig_get_channel(hdr, 0); CHANNEL_TYPE *ch2 = biosig_get_channel(hdr, 1); CHANNEL_TYPE *ch3 = biosig_get_channel(hdr, 2); CHANNEL_TYPE *ch4 = biosig_get_channel(hdr, 3); biosig_channel_set_samples_per_record(ch2, spr/2); biosig_channel_set_samples_per_record(ch3, spr/4); biosig_channel_set_samples_per_record(ch4, spr/5); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); /************************************************************* demographic data *************************************************************/ time_t timer; timer=time(NULL); struct tm *StartTime = localtime(&timer); biosig_set_startdatetime(hdr, *StartTime); struct tm birthday; birthday.tm_year=2005-1900; birthday.tm_mon=1; birthday.tm_mday=1; biosig_set_birthdate(hdr, birthday); biosig_set_patient_name(hdr, "Anonymous", "A.", NULL); biosig_set_patient_id(hdr, "pseudonym_0123456789"); biosig_set_recording_id(hdr, "recording 0000"); // biosig_set_technician(hdr, "Ms.Expert"); // by login name is used biosig_set_manufacturer_name(hdr, "Vendor XYZ"); biosig_set_manufacturer_model(hdr, "SuperDuper"); biosig_set_manufacturer_version(hdr, "alpha"); biosig_set_manufacturer_serial_number(hdr, "000000"); biosig_set_application_specific_information(hdr, "anything"); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); /* set markers in event table, this can be called at any time file is closed with SCLOSE. */ #if 0 // add 3 markers indicating "start-of-new-segment" spr = 5000; biosig_set_nth_event(hdr, 0, 0x7ffe, spr, 0, 0, NULL, NULL); biosig_set_nth_event(hdr, 0, 0x7ffe, 2*spr, 0, 0, NULL, NULL); biosig_set_nth_event(hdr, 0, 0x7ffe, 3*spr, 0, 0, NULL, NULL); // add free text annoations, typ must be between 1 and 255 (0xff) biosig_set_nth_event(hdr, 0, 0x01, 7000, 0, 0, NULL, "Marker1"); biosig_set_nth_event(hdr, 0, 0, 0, 0, 5000, NULL, "Seg1chan1"); biosig_set_nth_event(hdr, 0, 0, 5000, 3, 5000, NULL, "Seg2chan4"); biosig_set_nth_event(hdr, 0, 0, 10000, 2, 5000, NULL, "Seg3chan3"); #endif /************************************************************* open file and write header *************************************************************/ const char *f="filename.gdf"; if (argc>1) f=argv[1]; hdr->TYPE=GDF; hdr->VERSION=3.0; hdr = sopen(f,"w",hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); /************************************************************* write data block: there are high level and low level approaches. high level approaches assume data samples are available in a huge matrix, and swrite will deal with the details, like endian conversion, downsampling of the data, etc. the low level approach, assumes that the user, knows how to generate the correct binary layout of the data samples, and will use fwrite(..,..,..,hdr->FILE.FID). This might cause ABI incompatibilities on Windows. Most likely, another API need to be provided by biosig. *************************************************************/ size_t i,j,k; /* highlevel approach: needs to define data matrix, and its properties BIOSIG_FLAG_UCAL : do not apply scaling factors to convert from physical to digital values if this flag is not set, the scaling factors are applied in SWRITE BIOSIG_FLAG_ROW_BASED_CHANNELS: consecutive samples are from neighboring channel if not defined, all samples of first channel, then all samples form next channel must be available in data. */ biosig_set_flag(hdr, BIOSIG_FLAG_UCAL | BIOSIG_FLAG_ROW_BASED_CHANNELS); /* lets generate all data 1,2,3,4 Hz sinusoid, for each channel, resp. */ biosig_data_type* data=(biosig_data_type*)malloc(number_of_channels * total_number_of_samples * sizeof(biosig_data_type)); for (k=0; k < number_of_channels * total_number_of_samples; k++) data[k] = 33000 * sin( 1.0*(k%number_of_channels +1 )*(k%total_number_of_samples)*2*M_PI/sampling_rate ); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); #if defined(HL1) // option 1: define all data size_t count = swrite(data, nrec, hdr); if (nrec != count) fprintf(stderr,"%s (line %i) error\n",__FILE__,__LINE__); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); #elif defined(HL2) // option 2: define data of a single block data = realloc(data, number_of_channels * spr * sizeof(biosig_data_type)); for (k=0; k7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); #elif 0 // this spr=total_number_of_samples/number_of_epochs; for (k=0; k < number_of_epochs; k++) { for (chan=0; chan < number_of_channels; chan++) { for (chan=0; chan < number_of_channels; chan++) { CHANNEL_TYPE *ch = biosig_get_channel(hdr, chan); for (j=0; j < spr; j++) { data[j + chan*spr + k*spr*number_of_channels] = 3; // option 1: write sample j channel chan of sweep k // fwrite(&sample[k][chan][j],sizeof(int16_t),1,hdr->FILE.FID); } // option 2: avoid inner loop // fwrite(&sample_block[k][chan],sizeof(int16_t),spr,hdr->FILE.FID); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); /* low level approaches using fwrite - chances are it will not work in Windows because of ABI incompatibilities */ #elif defined(LL1) /* option 1: all the data is prepared and written at once. */ uint16_t *sample_block=(uint16_t*)malloc(hdr->AS.bpb*nrec); for (k=0; k < hdr->AS.bpb * nrec / sizeof(uint16_t); k++) sample_block[k] = 33000 * sin( 1.0*(k%number_of_channels +1 )*(k%total_number_of_samples)*2*M_PI/sampling_rate ); fwrite(sample_block,hdr->AS.bpb,nrec,hdr->FILE.FID); free(sample_block); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); #elif defined(LL2) uint16_t *sample_block=(uint16_t*)malloc(hdr->AS.bpb); for (k=0; k < hdr->AS.bpb / sizeof(uint16_t); k++) sample_block[k] = 33000 * sin( 1.0*(k%number_of_channels +1 )*(k%total_number_of_samples)*2*M_PI/sampling_rate ); for (k=0; k < nrec; k++) { /* option 3: the size of a single block is hdr->AS.bpb, a single data block is define, and written at once. change content of sample_block within loop */ fwrite(sample_block,hdr->AS.bpb,1,hdr->FILE.FID); } free(sample_block); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); #endif /************************************************************* write event table and close file *************************************************************/ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); sclose(hdr); /* cleanup, free any allocated memory to avoid memory leaks */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); destructHDR(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %i)\n",__FILE__,__LINE__); if (data!=NULL) free(data); } biosig-2.3.3/biosig4c++/bin2rec0000775000175000017500000000045714105434233016267 0ustar schloeglschloegl#!/bin/sh # BIN2REC converts ASCII-Header and binary channels data into GDF data file # The input files must match the format produced by rec2bin. # # Copyright (C) 2008,2020 Alois Schloegl # This file is part of BioSig https://biosig.sourceforge.io/ save2gdf -f=GDF $@ biosig-2.3.3/biosig4c++/mdc_ecg_codes.c0000664000175000017500000000454314105434233017717 0ustar schloeglschloegl/* Copyright (C) 2014 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include "mdc_ecg_codes.h" /* physical units are defined in IEEE/ISO 11073-10102-Annex B */ const struct mdc_code_table { const uint16_t code10; const uint32_t cf_code10; const char* refid; } MDC_CODE_TABLE[] = { #include "11073-10102-AnnexB.i" {0xffff, 0xffffffff, "MDC_ECG_ERROR_CODE" } } ; /* Conversion between MDC Refid and CODE10 encoding Currently, a simple lookup table is used, Eventually, this can be made more efficient */ uint16_t encode_mdc_ecg_code10(const char *IDstr) { if ( !memcmp(IDstr,"MDC_ECG_", 8) ) return 0xffff; uint32_t k; for (k=0; MDC_CODE_TABLE[k].cf_code10 < 0xffffffff; k++) { if (! strcmp(IDstr+8, MDC_CODE_TABLE[k].refid+8) ) return MDC_CODE_TABLE[k].code10; } return 0xffff; } uint32_t encode_mdc_ecg_cfcode10(const char *IDstr) { if ( !memcmp(IDstr,"MDC_ECG_", 8) ) return 0xffffffff; size_t k; for (k=0; MDC_CODE_TABLE[k].cf_code10 < 0xffffffff; k++) { if ( !strcmp(IDstr+8, MDC_CODE_TABLE[k].refid+8) ) return MDC_CODE_TABLE[k].cf_code10; } return 0xffffffff; } const char* decode_mdc_ecg_code10(uint16_t code10) { uint32_t k; for (k=0; MDC_CODE_TABLE[k].cf_code10 < 0xffffffff; k++) { if ( code10 == MDC_CODE_TABLE[k].code10 ) return MDC_CODE_TABLE[k].refid; } return NULL; } const char* decode_mdc_ecg_cfcode10(uint32_t cf_code10) { uint32_t k; for (k=0; MDC_CODE_TABLE[k].cf_code10 < 0xffffffff; k++) { if ( cf_code10 == MDC_CODE_TABLE[k].cf_code10 ) return MDC_CODE_TABLE[k].refid; } return NULL; } biosig-2.3.3/biosig4c++/autogen.sh0000775000175000017500000013443214105434233017017 0ustar schloeglschloegl#!/bin/sh # a u t o g e n . s h # # Copyright (c) 2005-2009 United States Government as represented by # the U.S. Army Research Laboratory. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. 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. # # 3. The name of the author may not be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # ### # # Script for automatically preparing the sources for compilation by # performing the myriad of necessary steps. The script attempts to # detect proper version support, and outputs warnings about particular # systems that have autotool peculiarities. # # Basically, if everything is set up and installed correctly, the # script will validate that minimum versions of the GNU Build System # tools are installed, account for several common configuration # issues, and then simply run autoreconf for you. # # If autoreconf fails, which can happen for many valid configurations, # this script proceeds to run manual preparation steps effectively # providing a POSIX shell script (mostly complete) reimplementation of # autoreconf. # # The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER # environment variables and corresponding _OPTIONS variables (e.g. # AUTORECONF_OPTIONS) may be used to override the default automatic # detection behaviors. Similarly the _VERSION variables will override # the minimum required version numbers. # # Examples: # # To obtain help on usage: # ./autogen.sh --help # # To obtain verbose output: # ./autogen.sh --verbose # # To skip autoreconf and prepare manually: # AUTORECONF=false ./autogen.sh # # To verbosely try running with an older (unsupported) autoconf: # AUTOCONF_VERSION=2.50 ./autogen.sh --verbose # # Author: # Christopher Sean Morrison # # Patches: # Sebastian Pipping # ###################################################################### # set to minimum acceptable version of autoconf if [ "x$AUTOCONF_VERSION" = "x" ] ; then AUTOCONF_VERSION=2.52 fi # set to minimum acceptable version of automake if [ "x$AUTOMAKE_VERSION" = "x" ] ; then AUTOMAKE_VERSION=1.6.0 fi # set to minimum acceptable version of libtool if [ "x$LIBTOOL_VERSION" = "x" ] ; then LIBTOOL_VERSION=1.4.2 fi ################## # ident function # ################## ident ( ) { # extract copyright from header __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`" if [ "x$__copyright" = "x" ] ; then __copyright="`date +%Y`" fi # extract version from CVS Id string __id="$Id: autogen.sh 33925 2009-03-01 23:27:06Z brlcad $" __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`" if [ "x$__version" = "x" ] ; then __version="" fi echo "autogen.sh build preparation script by Christopher Sean Morrison" echo " + config.guess download patch by Sebastian Pipping (2008-12-03)" echo "revised 3-clause BSD-style license, copyright (c) $__copyright" echo "script version $__version, ISO/IEC 9945 POSIX shell script" } ################## # USAGE FUNCTION # ################## usage ( ) { echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [-d|--download] [--version]" echo " --help Help on $NAME_OF_AUTOGEN usage" echo " --verbose Verbose progress output" echo " --quiet Quiet suppressed progress output" echo " --download Download the latest config.guess from gnulib" echo " --version Only perform GNU Build System version checks" echo echo "Description: This script will validate that minimum versions of the" echo "GNU Build System tools are installed and then run autoreconf for you." echo "Should autoreconf fail, manual preparation steps will be run" echo "potentially accounting for several common preparation issues. The" echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER," echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS" echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the" echo "default automatic detection behavior." echo ident return 0 } ########################## # VERSION_ERROR FUNCTION # ########################## version_error ( ) { if [ "x$1" = "x" ] ; then echo "INTERNAL ERROR: version_error was not provided a version" exit 1 fi if [ "x$2" = "x" ] ; then echo "INTERNAL ERROR: version_error was not provided an application name" exit 1 fi $ECHO $ECHO "ERROR: To prepare the ${PROJECT} build system from scratch," $ECHO " at least version $1 of $2 must be installed." $ECHO $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will" $ECHO "run configure or make. Either the GNU Autotools will need to be installed" $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source" $ECHO "code on another system and then transferred to here. -- Cheers!" $ECHO } ########################## # VERSION_CHECK FUNCTION # ########################## version_check ( ) { if [ "x$1" = "x" ] ; then echo "INTERNAL ERROR: version_check was not provided a minimum version" exit 1 fi _min="$1" if [ "x$2" = "x" ] ; then echo "INTERNAL ERROR: version check was not provided a comparison version" exit 1 fi _cur="$2" # needed to handle versions like 1.10 and 1.4-p6 _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" _min_major="`echo $_min | cut -d. -f1`" _min_minor="`echo $_min | cut -d. -f2`" _min_patch="`echo $_min | cut -d. -f3`" _cur_major="`echo $_cur | cut -d. -f1`" _cur_minor="`echo $_cur | cut -d. -f2`" _cur_patch="`echo $_cur | cut -d. -f3`" if [ "x$_min_major" = "x" ] ; then _min_major=0 fi if [ "x$_min_minor" = "x" ] ; then _min_minor=0 fi if [ "x$_min_patch" = "x" ] ; then _min_patch=0 fi if [ "x$_cur_minor" = "x" ] ; then _cur_major=0 fi if [ "x$_cur_minor" = "x" ] ; then _cur_minor=0 fi if [ "x$_cur_patch" = "x" ] ; then _cur_patch=0 fi $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}" if [ $_min_major -lt $_cur_major ] ; then return 0 elif [ $_min_major -eq $_cur_major ] ; then if [ $_min_minor -lt $_cur_minor ] ; then return 0 elif [ $_min_minor -eq $_cur_minor ] ; then if [ $_min_patch -lt $_cur_patch ] ; then return 0 elif [ $_min_patch -eq $_cur_patch ] ; then return 0 fi fi fi return 1 } ###################################### # LOCATE_CONFIGURE_TEMPLATE FUNCTION # ###################################### locate_configure_template ( ) { _pwd="`pwd`" if test -f "./configure.ac" ; then echo "./configure.ac" elif test -f "./configure.in" ; then echo "./configure.in" elif test -f "$_pwd/configure.ac" ; then echo "$_pwd/configure.ac" elif test -f "$_pwd/configure.in" ; then echo "$_pwd/configure.in" elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then echo "$PATH_TO_AUTOGEN/configure.ac" elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then echo "$PATH_TO_AUTOGEN/configure.in" fi } ################## # argument check # ################## ARGS="$*" PATH_TO_AUTOGEN="`dirname $0`" NAME_OF_AUTOGEN="`basename $0`" AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN" LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4" if [ "x$HELP" = "x" ] ; then HELP=no fi if [ "x$QUIET" = "x" ] ; then QUIET=no fi if [ "x$VERBOSE" = "x" ] ; then VERBOSE=no fi if [ "x$VERSION_ONLY" = "x" ] ; then VERSION_ONLY=no fi if [ "x$DOWNLOAD" = "x" ] ; then DOWNLOAD=no fi if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then AUTORECONF_OPTIONS="-i -f" fi if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then AUTOCONF_OPTIONS="-f" fi if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then AUTOMAKE_OPTIONS="-a -c -f" fi ALT_AUTOMAKE_OPTIONS="-a -c" if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then LIBTOOLIZE_OPTIONS="--automake -c -f" fi ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force" if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then ACLOCAL_OPTIONS="" fi if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then AUTOHEADER_OPTIONS="" fi if [ "x$CONFIG_GUESS_URL" = "x" ] ; then CONFIG_GUESS_URL="http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/config.guess;hb=HEAD" fi for arg in $ARGS ; do case "x$arg" in x--help) HELP=yes ;; x-[hH]) HELP=yes ;; x--quiet) QUIET=yes ;; x-[qQ]) QUIET=yes ;; x--verbose) VERBOSE=yes ;; x-[dD]) DOWNLOAD=yes ;; x--download) DOWNLOAD=yes ;; x-[vV]) VERBOSE=yes ;; x--version) VERSION_ONLY=yes ;; *) echo "Unknown option: $arg" echo usage exit 1 ;; esac done ##################### # environment check # ##################### # sanity check before recursions potentially begin if [ ! -f "$AUTOGEN_SH" ] ; then echo "INTERNAL ERROR: $AUTOGEN_SH does not exist" if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH" fi exit 1 fi # force locale setting to C so things like date output as expected LC_ALL=C # commands that this script expects for __cmd in echo head tail pwd ; do echo "test" | $__cmd > /dev/null 2>&1 if [ $? != 0 ] ; then echo "INTERNAL ERROR: '${__cmd}' command is required" exit 2 fi done echo "test" | grep "test" > /dev/null 2>&1 if test ! x$? = x0 ; then echo "INTERNAL ERROR: grep command is required" exit 1 fi echo "test" | sed "s/test/test/" > /dev/null 2>&1 if test ! x$? = x0 ; then echo "INTERNAL ERROR: sed command is required" exit 1 fi # determine the behavior of echo case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac # determine the behavior of head case "x`echo 'head' | head -n 1 2>&1`" in *xhead*) HEAD_N="n " ;; *) HEAD_N="" ;; esac # determine the behavior of tail case "x`echo 'tail' | tail -n 1 2>&1`" in *xtail*) TAIL_N="n " ;; *) TAIL_N="" ;; esac VERBOSE_ECHO=: ECHO=: if [ "x$QUIET" = "xyes" ] ; then if [ "x$VERBOSE" = "xyes" ] ; then echo "Verbose output quelled by quiet option. Further output disabled." fi else ECHO=echo if [ "x$VERBOSE" = "xyes" ] ; then echo "Verbose output enabled" VERBOSE_ECHO=echo fi fi # allow a recursive run to disable further recursions if [ "x$RUN_RECURSIVE" = "x" ] ; then RUN_RECURSIVE=yes fi ################################################ # check for help arg and bypass version checks # ################################################ if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then HELP=yes fi if [ "x$HELP" = "xyes" ] ; then usage $ECHO "---" $ECHO "Help was requested. No preparation or configuration will be performed." exit 0 fi ####################### # set up signal traps # ####################### untrap_abnormal ( ) { for sig in 1 2 13 15; do trap - $sig done } # do this cleanup whenever we exit. trap ' # start from the root if test -d "$START_PATH" ; then cd "$START_PATH" fi # restore/delete backup files if test "x$PFC_INIT" = "x1" ; then recursive_restore fi ' 0 # trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15) for sig in 1 2 13 15; do trap ' $ECHO "" $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'" # start from the root if test -d "$START_PATH" ; then cd "$START_PATH" fi # clean up on abnormal exit $VERBOSE_ECHO "rm -rf autom4te.cache" rm -rf autom4te.cache if test -f "acinclude.m4.$$.backup" ; then $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4" chmod u+w acinclude.m4 cat acinclude.m4.$$.backup > acinclude.m4 $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup" rm -f acinclude.m4.$$.backup fi { (exit 1); exit 1; } ' $sig done ############################# # look for a configure file # ############################# if [ "x$CONFIGURE" = "x" ] ; then CONFIGURE="`locate_configure_template`" if [ ! "x$CONFIGURE" = "x" ] ; then $VERBOSE_ECHO "Found a configure template: $CONFIGURE" fi else $ECHO "Using CONFIGURE environment variable override: $CONFIGURE" fi if [ "x$CONFIGURE" = "x" ] ; then if [ "x$VERSION_ONLY" = "xyes" ] ; then CONFIGURE=/dev/null else $ECHO $ECHO "A configure.ac or configure.in file could not be located implying" $ECHO "that the GNU Build System is at least not used in this directory. In" $ECHO "any case, there is nothing to do here without one of those files." $ECHO $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" exit 1 fi fi #################### # get project name # #################### if [ "x$PROJECT" = "x" ] ; then PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" if [ "x$PROJECT" = "xAC_INIT" ] ; then # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" fi if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then PROJECT="project" fi if [ "x$PROJECT" = "x" ] ; then PROJECT="project" fi else $ECHO "Using PROJECT environment variable override: $PROJECT" fi $ECHO "Preparing the $PROJECT build system...please wait" $ECHO ######################## # check for autoreconf # ######################## HAVE_AUTORECONF=no if [ "x$AUTORECONF" = "x" ] ; then for AUTORECONF in autoreconf ; do $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version" $AUTORECONF --version > /dev/null 2>&1 if [ $? = 0 ] ; then HAVE_AUTORECONF=yes break fi done else HAVE_AUTORECONF=yes $ECHO "Using AUTORECONF environment variable override: $AUTORECONF" fi ########################## # autoconf version check # ########################## _acfound=no if [ "x$AUTOCONF" = "x" ] ; then for AUTOCONF in autoconf ; do $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version" $AUTOCONF --version > /dev/null 2>&1 if [ $? = 0 ] ; then _acfound=yes break fi done else _acfound=yes $ECHO "Using AUTOCONF environment variable override: $AUTOCONF" fi _report_error=no if [ ! "x$_acfound" = "xyes" ] ; then $ECHO "ERROR: Unable to locate GNU Autoconf." _report_error=yes else _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" if [ "x$_version" = "x" ] ; then _version="0.0.0" fi $ECHO "Found GNU Autoconf version $_version" version_check "$AUTOCONF_VERSION" "$_version" if [ $? -ne 0 ] ; then _report_error=yes fi fi if [ "x$_report_error" = "xyes" ] ; then version_error "$AUTOCONF_VERSION" "GNU Autoconf" exit 1 fi ########################## # automake version check # ########################## _amfound=no if [ "x$AUTOMAKE" = "x" ] ; then for AUTOMAKE in automake ; do $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version" $AUTOMAKE --version > /dev/null 2>&1 if [ $? = 0 ] ; then _amfound=yes break fi done else _amfound=yes $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE" fi _report_error=no if [ ! "x$_amfound" = "xyes" ] ; then $ECHO $ECHO "ERROR: Unable to locate GNU Automake." _report_error=yes else _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" if [ "x$_version" = "x" ] ; then _version="0.0.0" fi $ECHO "Found GNU Automake version $_version" version_check "$AUTOMAKE_VERSION" "$_version" if [ $? -ne 0 ] ; then _report_error=yes fi fi if [ "x$_report_error" = "xyes" ] ; then version_error "$AUTOMAKE_VERSION" "GNU Automake" exit 1 fi ######################## # check for libtoolize # ######################## HAVE_LIBTOOLIZE=yes HAVE_ALT_LIBTOOLIZE=no _ltfound=no if [ "x$LIBTOOLIZE" = "x" ] ; then LIBTOOLIZE=libtoolize $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version" $LIBTOOLIZE --version > /dev/null 2>&1 if [ ! $? = 0 ] ; then HAVE_LIBTOOLIZE=no $ECHO if [ "x$HAVE_AUTORECONF" = "xno" ] ; then $ECHO "Warning: libtoolize does not appear to be available." else $ECHO "Warning: libtoolize does not appear to be available. This means that" $ECHO "the automatic build preparation via autoreconf will probably not work." $ECHO "Preparing the build by running each step individually, however, should" $ECHO "work and will be done automatically for you if autoreconf fails." fi # look for some alternates for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version" _glibtoolize="`$tool --version > /dev/null 2>&1`" if [ $? = 0 ] ; then $VERBOSE_ECHO "Found $tool --version" _glti="`which $tool`" if [ "x$_glti" = "x" ] ; then $VERBOSE_ECHO "Cannot find $tool with which" continue; fi if test ! -f "$_glti" ; then $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file" continue; fi _gltidir="`dirname $_glti`" if [ "x$_gltidir" = "x" ] ; then $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti" continue; fi if test ! -d "$_gltidir" ; then $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory" continue; fi HAVE_ALT_LIBTOOLIZE=yes LIBTOOLIZE="$tool" $ECHO $ECHO "Fortunately, $tool was found which means that your system may simply" $ECHO "have a non-standard or incomplete GNU Autotools install. If you have" $ECHO "sufficient system access, it may be possible to quell this warning by" $ECHO "running:" $ECHO sudo -V > /dev/null 2>&1 if [ $? = 0 ] ; then $ECHO " sudo ln -s $_glti $_gltidir/libtoolize" $ECHO else $ECHO " ln -s $_glti $_gltidir/libtoolize" $ECHO $ECHO "Run that as root or with proper permissions to the $_gltidir directory" $ECHO fi _ltfound=yes break fi done else _ltfound=yes fi else _ltfound=yes $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE" fi ############################ # libtoolize version check # ############################ _report_error=no if [ ! "x$_ltfound" = "xyes" ] ; then $ECHO $ECHO "ERROR: Unable to locate GNU Libtool." _report_error=yes else _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" if [ "x$_version" = "x" ] ; then _version="0.0.0" fi $ECHO "Found GNU Libtool version $_version" version_check "$LIBTOOL_VERSION" "$_version" if [ $? -ne 0 ] ; then _report_error=yes fi fi if [ "x$_report_error" = "xyes" ] ; then version_error "$LIBTOOL_VERSION" "GNU Libtool" exit 1 fi ##################### # check for aclocal # ##################### if [ "x$ACLOCAL" = "x" ] ; then for ACLOCAL in aclocal ; do $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version" $ACLOCAL --version > /dev/null 2>&1 if [ $? = 0 ] ; then break fi done else $ECHO "Using ACLOCAL environment variable override: $ACLOCAL" fi ######################## # check for autoheader # ######################## if [ "x$AUTOHEADER" = "x" ] ; then for AUTOHEADER in autoheader ; do $VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version" $AUTOHEADER --version > /dev/null 2>&1 if [ $? = 0 ] ; then break fi done else $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER" fi ######################### # check if version only # ######################### $VERBOSE_ECHO "Checking whether to only output version information" if [ "x$VERSION_ONLY" = "xyes" ] ; then $ECHO ident $ECHO "---" $ECHO "Version requested. No preparation or configuration will be performed." exit 0 fi ################################# # PROTECT_FROM_CLOBBER FUNCTION # ################################# protect_from_clobber ( ) { PFC_INIT=1 # protect COPYING & INSTALL from overwrite by automake. the # automake force option will (inappropriately) ignore the existing # contents of a COPYING and/or INSTALL files (depending on the # version) instead of just forcing *missing* files like it does # for AUTHORS, NEWS, and README. this is broken but extremely # prevalent behavior, so we protect against it by keeping a backup # of the file that can later be restored. for file in COPYING INSTALL ; do if test -f ${file} ; then if test -f ${file}.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "Already backed up ${file} in `pwd`" else $VERBOSE_ECHO "Backing up ${file} in `pwd`" $VERBOSE_ECHO "cp -p ${file} ${file}.$$.protect_from_automake.backup" cp -p ${file} ${file}.$$.protect_from_automake.backup fi fi done } ############################## # RECURSIVE_PROTECT FUNCTION # ############################## recursive_protect ( ) { # for projects using recursive configure, run the build # preparation steps for the subdirectories. this function assumes # START_PATH was set to pwd before recursion begins so that # relative paths work. # git 'r done, protect COPYING and INSTALL from being clobbered protect_from_clobber if test -d autom4te.cache ; then $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" $VERBOSE_ECHO "rm -rf autom4te.cache" rm -rf autom4te.cache fi # find configure template _configure="`locate_configure_template`" if [ "x$_configure" = "x" ] ; then return fi # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure" # look for subdirs # $VERBOSE_ECHO "Looking for subdirs in `pwd`" _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" CHECK_DIRS="" for dir in $_det_config_subdirs ; do if test -d "`pwd`/$dir" ; then CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" fi done # process subdirs if [ ! "x$CHECK_DIRS" = "x" ] ; then $VERBOSE_ECHO "Recursively scanning the following directories:" $VERBOSE_ECHO " $CHECK_DIRS" for dir in $CHECK_DIRS ; do $VERBOSE_ECHO "Protecting files from automake in $dir" cd "$START_PATH" eval "cd $dir" # recursively git 'r done recursive_protect done fi } # end of recursive_protect ############################# # RESTORE_CLOBBERED FUNCION # ############################# restore_clobbered ( ) { # The automake (and autoreconf by extension) -f/--force-missing # option may overwrite COPYING and INSTALL even if they do exist. # Here we restore the files if necessary. spacer=no for file in COPYING INSTALL ; do if test -f ${file}.$$.protect_from_automake.backup ; then if test -f ${file} ; then # compare entire content, restore if needed if test "x`cat ${file}`" != "x`cat ${file}.$$.protect_from_automake.backup`" ; then if test "x$spacer" = "xno" ; then $VERBOSE_ECHO spacer=yes fi # restore the backup $VERBOSE_ECHO "Restoring ${file} from backup (automake -f likely clobbered it)" $VERBOSE_ECHO "rm -f ${file}" rm -f ${file} $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" mv ${file}.$$.protect_from_automake.backup ${file} fi # check contents elif test -f ${file}.$$.protect_from_automake.backup ; then $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" mv ${file}.$$.protect_from_automake.backup ${file} fi # -f ${file} # just in case $VERBOSE_ECHO "rm -f ${file}.$$.protect_from_automake.backup" rm -f ${file}.$$.protect_from_automake.backup fi # -f ${file}.$$.protect_from_automake.backup done CONFIGURE="`locate_configure_template`" if [ "x$CONFIGURE" = "x" ] ; then return fi _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" if test ! -d "$_aux_dir" ; then _aux_dir=. fi for file in config.guess config.sub ltmain.sh ; do if test -f "${_aux_dir}/${file}" ; then $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\"" rm -f "${_aux_dir}/${file}.backup" fi done } # end of restore_clobbered ############################## # RECURSIVE_RESTORE FUNCTION # ############################## recursive_restore ( ) { # restore COPYING and INSTALL from backup if they were clobbered # for each directory recursively. # git 'r undone restore_clobbered # find configure template _configure="`locate_configure_template`" if [ "x$_configure" = "x" ] ; then return fi # look for subdirs _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" CHECK_DIRS="" for dir in $_det_config_subdirs ; do if test -d "`pwd`/$dir" ; then CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" fi done # process subdirs if [ ! "x$CHECK_DIRS" = "x" ] ; then $VERBOSE_ECHO "Recursively scanning the following directories:" $VERBOSE_ECHO " $CHECK_DIRS" for dir in $CHECK_DIRS ; do $VERBOSE_ECHO "Checking files for automake damage in $dir" cd "$START_PATH" eval "cd $dir" # recursively git 'r undone recursive_restore done fi } # end of recursive_restore ####################### # INITIALIZE FUNCTION # ####################### initialize ( ) { # this routine performs a variety of directory-specific # initializations. some are sanity checks, some are preventive, # and some are necessary setup detection. # # this function sets: # CONFIGURE # SEARCH_DIRS # CONFIG_SUBDIRS ################################## # check for a configure template # ################################## CONFIGURE="`locate_configure_template`" if [ "x$CONFIGURE" = "x" ] ; then $ECHO $ECHO "A configure.ac or configure.in file could not be located implying" $ECHO "that the GNU Build System is at least not used in this directory. In" $ECHO "any case, there is nothing to do here without one of those files." $ECHO $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" exit 1 fi ##################### # detect an aux dir # ##################### _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" if test ! -d "$_aux_dir" ; then _aux_dir=. else $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir" fi ################################ # detect a recursive configure # ################################ CONFIG_SUBDIRS="" _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" for dir in $_det_config_subdirs ; do if test -d "`pwd`/$dir" ; then $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir" CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir" fi done ########################################################### # make sure certain required files exist for GNU projects # ########################################################### _marker_found="" _marker_found_message_intro='Detected non-GNU marker "' _marker_found_message_mid='" in ' for marker in foreign cygnus ; do _marker_found_message=${_marker_found_message_intro}${marker}${_marker_found_message_mid} _marker_found="`grep 'AM_INIT_AUTOMAKE.*'${marker} $CONFIGURE`" if [ ! "x$_marker_found" = "x" ] ; then $VERBOSE_ECHO "${_marker_found_message}`basename \"$CONFIGURE\"`" break fi if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then _marker_found="`grep 'AUTOMAKE_OPTIONS.*'${marker} Makefile.am`" if [ ! "x$_marker_found" = "x" ] ; then $VERBOSE_ECHO "${_marker_found_message}Makefile.am" break fi fi done if [ "x${_marker_found}" = "x" ] ; then _suggest_foreign=no for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do if [ ! -f $file ] ; then $VERBOSE_ECHO "Touching ${file} since it does not exist" _suggest_foreign=yes touch $file fi done if [ "x${_suggest_foreign}" = "xyes" ] ; then $ECHO $ECHO "Warning: Several files expected of projects that conform to the GNU" $ECHO "coding standards were not found. The files were automatically added" $ECHO "for you since you do not have a 'foreign' declaration specified." $ECHO $ECHO "Considered adding 'foreign' to AM_INIT_AUTOMAKE in `basename \"$CONFIGURE\"`" if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then $ECHO "or to AUTOMAKE_OPTIONS in your top-level Makefile.am file." fi $ECHO fi fi ################################################## # make sure certain generated files do not exist # ################################################## for file in config.guess config.sub ltmain.sh ; do if test -f "${_aux_dir}/${file}" ; then $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\"" mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup" fi done ############################ # search alternate m4 dirs # ############################ SEARCH_DIRS="" for dir in m4 ; do if [ -d $dir ] ; then $VERBOSE_ECHO "Found extra aclocal search directory: $dir" SEARCH_DIRS="$SEARCH_DIRS -I $dir" fi done ###################################### # remove any previous build products # ###################################### if test -d autom4te.cache ; then $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" $VERBOSE_ECHO "rm -rf autom4te.cache" rm -rf autom4te.cache fi # tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it # if test -f aclocal.m4 ; then # $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it" # $VERBOSE_ECHO "rm -f aclocal.m4" # rm -f aclocal.m4 # fi } # end of initialize() ############## # initialize # ############## # stash path START_PATH="`pwd`" # Before running autoreconf or manual steps, some prep detection work # is necessary or useful. Only needs to occur once per directory, but # does need to traverse the entire subconfigure hierarchy to protect # files from being clobbered even by autoreconf. recursive_protect # start from where we started cd "$START_PATH" # get ready to process initialize ######################################### # DOWNLOAD_GNULIB_CONFIG_GUESS FUNCTION # ######################################### # TODO - should make sure wget/curl exist and/or work before trying to # use them. download_gnulib_config_guess () { # abuse gitweb to download gnulib's latest config.guess via HTTP config_guess_temp="config.guess.$$.download" ret=1 for __cmd in wget curl fetch ; do $VERBOSE_ECHO "Checking for command ${__cmd}" ${__cmd} --version > /dev/null 2>&1 ret=$? if [ ! $ret = 0 ] ; then continue fi __cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'` $VERBOSE_ECHO "Found ${__cmd} ${__cmd_version}" opts="" case ${__cmd} in wget) opts="-O" ;; curl) opts="-o" ;; fetch) opts="-t 5 -f" ;; esac $VERBOSE_ECHO "Running $__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" eval "$__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1 if [ $? = 0 ] ; then mv -f "${config_guess_temp}" ${_aux_dir}/config.guess ret=0 break fi done if [ ! $ret = 0 ] ; then $ECHO "Warning: config.guess download failed from: $CONFIG_GUESS_URL" rm -f "${config_guess_temp}" fi } ############################## # LIBTOOLIZE_NEEDED FUNCTION # ############################## libtoolize_needed () { ret=1 # means no, don't need libtoolize for feature in AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT ; do $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" found="`grep \"^$feature.*\" $CONFIGURE`" if [ ! "x$found" = "x" ] ; then ret=0 # means yes, need to run libtoolize break fi done return ${ret} } ############################################ # prepare build via autoreconf or manually # ############################################ reconfigure_manually=no if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then $ECHO $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C" $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS" autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$autoreconf_output" if [ ! $ret = 0 ] ; then if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then $ECHO $ECHO "Warning: autoreconf failed but due to what is usually a common libtool" $ECHO "misconfiguration issue. This problem is encountered on systems that" $ECHO "have installed libtoolize under a different name without providing a" $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable." $ECHO $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE" export LIBTOOLIZE RUN_RECURSIVE=no export RUN_RECURSIVE untrap_abnormal $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" exit $? fi fi $ECHO "Warning: $AUTORECONF failed" if test -f ltmain.sh ; then $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should" fi $ECHO "Attempting to run the preparation steps individually" reconfigure_manually=yes else if [ "x$DOWNLOAD" = "xyes" ] ; then if libtoolize_needed ; then download_gnulib_config_guess fi fi fi else reconfigure_manually=yes fi ############################ # LIBTOOL_FAILURE FUNCTION # ############################ libtool_failure ( ) { # libtool is rather error-prone in comparison to the other # autotools and this routine attempts to compensate for some # common failures. the output after a libtoolize failure is # parsed for an error related to AC_PROG_LIBTOOL and if found, we # attempt to inject a project-provided libtool.m4 file. _autoconf_output="$1" if [ "x$RUN_RECURSIVE" = "xno" ] ; then # we already tried the libtool.m4, don't try again return 1 fi if test -f "$LIBTOOL_M4" ; then found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`" if test ! "x$found_libtool" = "x" ; then if test -f acinclude.m4 ; then rm -f acinclude.m4.$$.backup $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup" cat acinclude.m4 > acinclude.m4.$$.backup fi $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4" chmod u+w acinclude.m4 cat "$LIBTOOL_M4" >> acinclude.m4 # don't keep doing this RUN_RECURSIVE=no export RUN_RECURSIVE untrap_abnormal $ECHO $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4" $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" exit $? fi fi } ########################### # MANUAL_AUTOGEN FUNCTION # ########################### manual_autogen ( ) { ################################################## # Manual preparation steps taken are as follows: # # aclocal [-I m4] # # libtoolize --automake -c -f # # aclocal [-I m4] # # autoconf -f # # autoheader # # automake -a -c -f # ################################################## ########### # aclocal # ########### $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$aclocal_output" if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi ############## # libtoolize # ############## if libtoolize_needed ; then if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS" libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$libtoolize_output" if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi else if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS" libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$libtoolize_output" if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi fi fi ########### # aclocal # ########### # re-run again as instructed by libtoolize $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$aclocal_output" # libtoolize might put ltmain.sh in the wrong place if test -f ltmain.sh ; then if test ! -f "${_aux_dir}/ltmain.sh" ; then $ECHO $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory" $ECHO $ECHO "Fortunately, the problem can be worked around by simply copying the" $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you." $ECHO $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\"" cp -p ltmain.sh "${_aux_dir}/ltmain.sh" $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" fi fi # ltmain.sh if [ "x$DOWNLOAD" = "xyes" ] ; then download_gnulib_config_guess fi fi # libtoolize_needed ############ # autoconf # ############ $VERBOSE_ECHO $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS" autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`" ret=$? $VERBOSE_ECHO "$autoconf_output" if [ ! $ret = 0 ] ; then # retry without the -f and check for usage of macros that are too new ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE" ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE" ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T" macros_to_search="" ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`" ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`" if [ $ac_major -lt 2 ] ; then macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" else if [ $ac_minor -lt 54 ] ; then macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" elif [ $ac_minor -lt 55 ] ; then macros_to_search="$ac2_59_macros $ac2_55_macros" elif [ $ac_minor -lt 59 ] ; then macros_to_search="$ac2_59_macros" fi fi configure_ac_macros=__none__ for feature in $macros_to_search ; do $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" found="`grep \"^$feature.*\" $CONFIGURE`" if [ ! "x$found" = "x" ] ; then if [ "x$configure_ac_macros" = "x__none__" ] ; then configure_ac_macros="$feature" else configure_ac_macros="$feature $configure_ac_macros" fi fi done if [ ! "x$configure_ac_macros" = "x__none__" ] ; then $ECHO $ECHO "Warning: Unsupported macros were found in $CONFIGURE" $ECHO $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any" $ECHO "unsupported macros are used that exceed the minimum version" $ECHO "settings specified within this file. As such, the following macros" $ECHO "should be removed from configure.ac or the version numbers in this" $ECHO "file should be increased:" $ECHO $ECHO "$configure_ac_macros" $ECHO $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C" fi ################### # autoconf, retry # ################### $VERBOSE_ECHO $VERBOSE_ECHO "$AUTOCONF" autoconf_output="`$AUTOCONF 2>&1`" ret=$? $VERBOSE_ECHO "$autoconf_output" if [ ! $ret = 0 ] ; then # test if libtool is busted libtool_failure "$autoconf_output" # let the user know what went wrong cat < This file is part of the "BioSig for C/C++" repository (biosig4c++) at https://biosig.sourceforge.io 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 3 of the License, 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, see . */ #include #include "mathlink.h" #include #ifdef NDEBUG #define VERBOSE_LEVEL 0 // turn off debugging information, but its only used without NDEBUG #else extern int VERBOSE_LEVEL; // used for debugging, variable is always defined #endif void sload(const char *fn, int *SZ, long SZlen) { uint16_t numberChannels; size_t k=0; size_t numberSamples; double samplerate; double *t; char *str = NULL; long int sz[2]; biosig_data_type *data=NULL; #ifdef __LIBBIOSIG2_H__ size_t rowcol[2]; #endif HDRTYPE *hdr = constructHDR(0,0); if (VERBOSE_LEVEL > 5) fprintf(stdout,"=== start sload ===\n"); /* contains [experiment,series,sweep,trace] numbers for selecting data. */ while ((k < SZlen) && (k < 5)) { #ifdef __LIBBIOSIG2_H__ biosig_set_segment_selection(hdr, k+1, SZ[k]); #else hdr->AS.SegSel[k] = (uint32_t)SZ[k]; #endif k++; } // ********* open file and read header ************ hdr = sopen(fn, "r", hdr); if (serror2(hdr)) { destructHDR(hdr); MLEvaluate(stdlink,"Message[sload::failed]"); MLNextPacket(stdlink); MLNewPacket(stdlink); MLPutSymbol(stdlink,"$Failed"); return; } #ifdef __LIBBIOSIG2_H__ numberChannels = biosig_get_number_of_channels(hdr); numberSamples = biosig_get_number_of_samples(hdr); samplerate = biosig_get_samplerate(hdr); biosig_reset_flag(hdr, BIOSIG_FLAG_ROW_BASED_CHANNELS); #else numberChannels = hdr->NS; numberSamples = hdr->NRec * hdr->SPR; samplerate = hdr->SampleRate; hdr->FLAG.ROW_BASED_CHANNELS = 0; #endif if (VERBOSE_LEVEL > 5) fprintf(stdout,"open filename <%s>NoOfChans=%i\n", fn, numberChannels); // ********** read data ******************** sread(NULL, 0, numberSamples, hdr); if (serror2(hdr)) { destructHDR(hdr); MLEvaluate(stdlink,"Message[sload::failed]"); MLNextPacket(stdlink); MLNewPacket(stdlink); MLPutSymbol(stdlink,"$Failed"); return; } #ifdef __LIBBIOSIG2_H__ biosig_get_datablock(hdr, &data, &rowcol[0], &rowcol[1]); sz[0] = rowcol[1]; sz[1] = rowcol[0]; #else sz[0] = hdr->data.size[1]; sz[1] = hdr->data.size[0]; data = hdr->data.block; #endif MLPutFunction(stdlink, "List", 3); // write data matrix MLPutRealArray(stdlink, data, sz, NULL, 2); // generate and write time axis t = (double*)malloc(numberSamples * sizeof(double)); for (k=0; k < numberSamples;k++) { t[k] = (k+1)/samplerate; } MLPutRealList(stdlink, t, numberSamples); free(t); // generate and write header information in JSON format asprintf_hdr2json(&str, hdr); MLPutFunction(stdlink,"ImportString",2); MLPutUTF8String(stdlink,str,strlen(str)); MLPutString(stdlink,"JSON"); free(str); if (VERBOSE_LEVEL > 5) { for (k=0; k@%p sz=[%zd,%zd]\n", fn, data, sz[1],sz[0]); } // *********** close file ********************* destructHDR(hdr); return; } void uload(const char *fn, int *SZ, long SZlen) { uint16_t numberChannels; size_t k=0; size_t numberSamples; double samplerate; double *t; char *str = NULL; long int sz[2]; biosig_data_type *data=NULL; #ifdef __LIBBIOSIG2_H__ size_t rowcol[2]; #endif HDRTYPE *hdr = constructHDR(0,0); if (VERBOSE_LEVEL > 5) fprintf(stdout,"=== start uload ===\n"); /* contains [experiment,series,sweep,trace] numbers for selecting data. */ while ((k < SZlen) && (k < 5)) { #ifdef __LIBBIOSIG2_H__ biosig_set_segment_selection(hdr, k+1, SZ[k]); #else hdr->AS.SegSel[k] = (uint32_t)SZ[k]; #endif k++; } // ********* open file and read header ************ hdr = sopen(fn, "r", hdr); if (serror2(hdr)) { destructHDR(hdr); MLEvaluate(stdlink,"Message[uload::failed]"); MLNextPacket(stdlink); MLNewPacket(stdlink); MLPutSymbol(stdlink,"$Failed"); return; } // do NOT apply calibration/scaling factor biosig_set_flag(hdr, BIOSIG_FLAG_UCAL); #ifdef __LIBBIOSIG2_H__ numberChannels = biosig_get_number_of_channels(hdr); numberSamples = biosig_get_number_of_samples(hdr); samplerate = biosig_get_samplerate(hdr); biosig_reset_flag(hdr, BIOSIG_FLAG_ROW_BASED_CHANNELS); #else numberChannels = hdr->NS; numberSamples = hdr->NRec * hdr->SPR; samplerate = hdr->SampleRate; hdr->FLAG.ROW_BASED_CHANNELS = 0; #endif if (VERBOSE_LEVEL > 5) fprintf(stdout,"open filename <%s>NoOfChans=%i\n", fn, numberChannels); // ********** read data ******************** sread(NULL, 0, numberSamples, hdr); if (serror2(hdr)) { destructHDR(hdr); MLEvaluate(stdlink,"Message[uload::failed]"); MLNextPacket(stdlink); MLNewPacket(stdlink); MLPutSymbol(stdlink,"$Failed"); return; } #ifdef __LIBBIOSIG2_H__ biosig_get_datablock(hdr, &data, &rowcol[0], &rowcol[1]); sz[0] = rowcol[1]; sz[1] = rowcol[0]; #else sz[0] = hdr->data.size[1]; sz[1] = hdr->data.size[0]; data = hdr->data.block; #endif MLPutFunction(stdlink, "List", 3); // write data matrix MLPutRealArray(stdlink, data, sz, NULL, 2); // generate and write time axis t = (double*)malloc(numberSamples * sizeof(double)); for (k=0; k < numberSamples;k++) { t[k] = (k+1)/samplerate; } MLPutRealList(stdlink, t, numberSamples); free(t); // generate and write header information in JSON format asprintf_hdr2json(&str, hdr); MLPutFunction(stdlink,"ImportString",2); MLPutUTF8String(stdlink,str,strlen(str)); MLPutString(stdlink,"JSON"); free(str); if (VERBOSE_LEVEL > 5) { for (k=0; k@%p sz=[%zd,%zd]\n", fn, data, sz[1],sz[0]); } // *********** close file ********************* destructHDR(hdr); return; } int main(int argc, char *argv[]) { return MLMain(argc, argv); } biosig-2.3.3/biosig4c++/mma/Makefile.in0000664000175000017500000001416514105434233017635 0ustar schloeglschloegl####### Makefile to compile biosig.exe for loading data supported by libbiosig into Mathematica ### ### Copyright (C) 2010-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ########################################### # user-defined variables ########################################### CROSS ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static CROSS64 ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static exec_prefix ?= @prefix@ ########################################### ## set Mathematica variables MATHEMATICA_EXE = @MATHEMATICA@ MATHEMATICA_EXE ?= $(shell which mathematica) ifeq (,$(MATHEMATICA_EXE)) $(error "mathematica not found in $$PATH - cannot compile biosig for Mathematica") endif MLINKDIR ?= $(shell dirname $(shell dirname $(shell readlink -f $(MATHEMATICA_EXE) ) ) ) ifneq (,$(findstring Darwin,$(shell uname))) MLINKDIR := /Applications/Mathematica.app/Contents/ SYS = MacOSX-x86-64 LDFLAGS += -demangle -dynamic -arch x86_64 LDFLAGS += -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration else SYS = $(notdir $(shell ls -1d $(MLINKDIR)/SystemFiles/Links/MathLink/DeveloperKit/*)) ifneq (1,$(words ${SYS})) SYS = Linux-x86-64# Set this value with the result of evaluating $SystemID endif endif # automated detection of most recent MLINTERFACE, without starting mathematica # 10.0 supports 3 and 4, 9.0 and earlier supports only 3, MLIVER := $(shell ${CC} mliver.c -I${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions/ -E -o - | tail -1) # # Windows SYSwin = Windows# Set this value with the result of evaluating $SystemID MLLIBwin = ml32i4m# Set this to ML64i3 if using a 64-bit system SYSwin64 = Windows-x86-64# Set this value with the result of evaluating $SystemID MLLIBwin64 = ml64i4# Set this to ML64i3 if using a 64-bit system ########################################### CADDSDIR = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions INCDIR = -I${CADDSDIR} -I${MLINKDIR}/SystemFiles/IncludeFiles/C/ LIBDIR += -L${CADDSDIR} EXTRALIBS += -lm -ldl -luuid -lstdc++ # Set these with appropriate libs for your system. ifeq (Darwin,$(shell uname)) MLLIB = MLi${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system SED = gsed else MLLIB = ML$(shell getconf LONG_BIT)i${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system EXTRALIBS += -lrt SED = sed endif LD = ${CC} ifneq (${MLIVER},) CFLAGS += -DMLINTERFACE=${MLIVER} endif MPREP = ${CADDSDIR}/mprep TARGET = biosig # make Linux-x86-64 mma : $(patsubst %, ${SYS}/%.exe, $(TARGET)) # make Linux-x86-64, Windows, Windows-x86-64 all : $(patsubst %, ${SYS}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) .c.o: ${CC} ${CFLAGS} -I.. ${INCDIR} -c "$<" %tm.c: %.tm ${MPREP} "$<" -o "$@" ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" ${SYS}/%.exe: %.o %tm.o mkdir -p ${SYS} ${LD} ${LDFLAGS} $? ${LIBDIR} -l${MLLIB} ${EXTRALIBS} -L.. -lbiosig -o "$@" ln -sf "$@" ### Install Biosig for Mathematica install : biosig.exe mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica install biosig.exe $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/ @echo " Biosig for Mathematica is installed in $(exec_prefix)/libexec/biosig/mathematica/biosig.exe"; @echo " Usage: Start Mathematica and run"; @echo "\tlink=Install[\"$(exec_prefix)/libexec/biosig/mathematica/biosig.exe\"];"; @echo "\t?Sload\n\t?Uload\n"; uninstall: ${RM} $(DESTDIR)$(datadir)/biosig/mathematica/{sload,biosig}.exe -cd $(DESTDIR)$(datadir) && rmdir -p biosig/mathematica ${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/biosig.exe -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/mathematica ########################################### # Win32 - cross-compilation ########################################### CCw32 = $(CROSS)-gcc CADDSDIRwin = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin}/CompilerAdditions INCDIRwin = -I${CADDSDIRwin} LIBDIRwin = ${CADDSDIRwin} EXTRALIBSwin = -lgdi32 -lm -lstdc++ -lws2_32 $(LDLIBS) # Set these with appropriate libs for your system. MPREPwin = ${CADDSDIRwin}/mprep.exe %tm.win32.c : %.tm WINEPREFIX=${HOME}/.wine32.mma wine ${MPREPwin} "$<" -o "$@" ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" ${SYSwin}/%.obj : %.c ${CCw32} -o "$@" -c "$<" $(shell $(CROSS)-pkg-config --cflags libbiosig) ${INCDIRwin} win32mma : $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) #${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.obj # uses MPREP ${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.win32.obj # uses MPREPwin mkdir -p ${SYSwin} ${CCw32} $? -mwindows -static-libgcc -static-libstdc++ $(shell $(CROSS)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin} -l${MLLIBwin} ${EXTRALIBSwin} -o "$@" ########################################### # Win64 - cross-compilation ########################################### CCw64 = $(CROSS64)-gcc CADDSDIRwin64 = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin64}/CompilerAdditions INCDIRwin64 = -I${CADDSDIRwin64} LIBDIRwin64 = ${CADDSDIRwin64} #MPREPwin64 = ${CADDSDIRwin64}/mprep.exe #%tm.win64.c : %.tm # WINEPREFIX=${HOME}/.wine64.mma wine64 ${MPREPwin64} "$<" -o "$@" #${MPREP} "$<" -o "$@" # ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#' "$@" ${SYSwin64}/%.obj : %.c ${CCw64} -o "$@" -c "$<" $(shell $(CROSS64)-pkg-config --cflags libbiosig) ${INCDIRwin64} win64mma : $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) #${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.win64.obj # uses MPREPwin64 ${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.obj # uses MPREP mkdir -p ${SYSwin64} ${CCw64} $? -static-libgcc -static-libstdc++ $(shell $(CROSS64)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin64} -l${MLLIBwin64} ${EXTRALIBSwin} -o "$@" ########################################### clean: -$(RM) *.o* */*.o* -$(RM) *tm.c */*tm.c -$(RM) *.exe */*.exe biosig-2.3.3/biosig4c++/mma/Makefile.win320000664000175000017500000000240014105434233020156 0ustar schloeglschloegl# Makefile to compile sload.exe for loading data supported by libbiosig into Mathematica # Copyright (C) 2010, 2011 Alois Schloegl ########################################### # user-defined variables ########################################### MLINKDIR = C:/Program\ Files/Wolfram\ Research/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit SYS = Windows# Set this value with the result of evaluating $SystemID MLLIB = ml32i3m # Set this to ML64i3 if using a 64-bit system ########################################### CC = g++ RM = rm CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions/mldev32 INCDIR = ${CADDSDIR}/include LIBDIR = ${CADDSDIR}/lib EXTRALIBS = -mwindows -lm -lpthread -lstdc++ -L.. -lbiosig -lws2_32 # -lcholmod -lz #Set these with appropriate libs for your system. MPREP = ${CADDSDIR}/bin/mprep.exe all : sload.exe win win32 : $(MAKE) -f Makefile.win32 ../libbiosig.a: $(MAKE) -C .. -f Makefile.win32 libbiosig.a .c.o : ${CC} -c -I${INCDIR} $< sloadtm.c : sload.tm ${MPREP} $? -o $@ sload.exe : sload.o sloadtm.o ../libbiosig.a ${CC} sloadtm.o sload.o -static-libgcc -static-libstdc++ -L${LIBDIR} -l${MLLIB} ${EXTRALIBS} -o $@ clean: -$(RM) *.o -$(RM) *.obj -$(RM) *tm.c -$(RM) sload -$(RM) sload.exe biosig-2.3.3/biosig4c++/mma/mySLOAD.m0000664000175000017500000000257314105434233017156 0ustar schloeglschloegl(* Platform independent loading of biosignal data Copyright 2011,2012,2016 Alois Schloegl, IST Austria This file is part of the "BioSig for C/C++" repository BioSig 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 3 of the License,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, see . *) mySLOAD[filename_, sweeps_] := Module [{link, data}, (* mySLOAD: makes it platform independent *) link = Install[$SystemID<>"/biosig.exe"]; data = Sload[filename, sweeps]; Uninstall[link]; data (* return data *) ]; (* This demonstrates the usage of the above module mySLOAD On Windows platform the directory separators must be either a single forward slash "/" or double backward slashes "\\" *) filename = "AP100427b.dat"; data = mySLOAD[filename, {1, 0, 0}]; signal = data[[1]] (* sampled data *) t = data[[2]] (* sampling time points *) hdrinfo = data[[3]] (* header information *) biosig-2.3.3/biosig4c++/mma/biosig.tm0000664000175000017500000000502714105434233017403 0ustar schloeglschloegl :Begin: :Function: sload :Pattern: Sload[fn_String, i_List] :Arguments: {fn, i} :ArgumentTypes: {String, IntegerList} :ReturnType: Manual :End: :Evaluate: Sload::usage = "Sload[filename, {ne,ng,ns}] load data sweeps into mathematica workspace. ne, ng, and ns are the number of the experiment, the number of the series from this experiment and the number of the sweep from this series sweep, respectivly. 0 can be used as wildcard to select all sweeps.\nExamples: data = Sload(\"abc.dat\",{1,5,0}) selects all sweeps from 5th series of first experiment; {0,0,0} selects all sweeps from file \"abc.dat\".\n The output ist a list of three elements, data[[1]] contains the 2-dim array of data samples, data[[2]] contains the time axis in seconds, and data[[3]] contains the header information in serialized JSON string. It can be converted with ImportString[data[[3]], \"JSON\"]. \n \nNOTE: If sweeps were sampled with different sampling rates, all data is converted to the least common multiple of the various sampling rates. (e.g. loading a 20kHz and a 25kHz sweep simultaneously, both sweeps are converted to 100kHz). \n\nCompiled on __DATE__" :Evaluate: Sload::failed="Failed to load file" :Begin: :Function: uload :Pattern: Uload[fn_String, i_List] :Arguments: {fn, i} :ArgumentTypes: {String, IntegerList} :ReturnType: Manual :End: :Evaluate: Uload::usage = "Uload[filename, {ne,ng,ns}] load data sweeps into mathematica workspace. uload is very similar to sload except that it returns the raw digital values without scaling it's the \"un-calibrated\" load function.\n ne, ng, and ns are the number of the experiment, the number of the series from this experiment and the number of the sweep from this series sweep, respectivly. 0 can be used as wildcard to select all sweeps.\nExamples: data = Uload(\"abc.dat\",{1,5,0}) selects all sweeps from 5th series of first experiment; {0,0,0} selects all sweeps from file \"abc.dat\".\n The output ist a list of three elements, data[[1]] contains the 2-dim array of data samples, data[[2]] contains the time axis in seconds, and data[[3]] contains the header information in serialized JSON string. It can be converted with ImportString[data[[3]], \"JSON\"]. \n \nNOTE: If sweeps were sampled with different sampling rates, all data is converted to the least common multiple of the various sampling rates. (e.g. loading a 20kHz and a 25kHz sweep simultaneously, both sweeps are converted to 100kHz). \n\nCompiled on __DATE__" :Evaluate: Uload::failed="Failed to load file" biosig-2.3.3/biosig4c++/mma/mliver.c0000664000175000017500000000017314105434233017224 0ustar schloeglschloegl/* used to obtain latest version of MLINTERFACE without starting mathematica */ #include MLINTERFACE biosig-2.3.3/biosig4c++/mma/INSTALL0000664000175000017500000000332214105434233016612 0ustar schloeglschloegl == Compiling on Debian and derivatives =============== == 1. REQUIREMENTS == sudo apt-get install libsuitesparse-dev libz-dev == 2. DOWNLOAD == and extract biosig4c++ and change into directory cd biosig4c++/ or checkout the latest version from the git repository git clone git://git.code.sf.net/p/biosig/code biosig-code cd biosig-code/biosig4c++/ == 3. COMPILATION == ./configure && make && make install make mma If it fails (file mma/sload not available), you might need to edit mma/Makefile (line 18) MLINKDIR= set it to the directory of the developerkit of your mathematica installation. Try again make mma == 4. INSTALL == copy the files mma/$SystemID/sload.exe mma/*.nb into your working directory. == 5. USAGE == Start mathematica link=Install["sload.exe"] ?sload mySLOAD.nb demonstrates how to use sload in mathematica. === OTHER PLATFORMS === are currently not maintained. The information below might be outdated. = Cross-Compiling on Linux for Windows = Prerequisites: Cross-compiler (e.g. mxe) wine Mathlink developer files from Windows e.g. C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Links\MathLink\DeveloperKit\Windows* to the linux computer (copyied them into the corresponding Mathematica directory on linux) e.g. /usr/local/Wolfram/gridMathematicaServer/7.0/SystemFiles/Links/MathLink/DeveloperKit/ Adapt the user-defined variables in Makefile.win32 and run make sload.exe ===== TESTING ========================================= The installation can be tested by starting Mathematica, loading and running test.nb. Copyright (C) 2011,2013,2015,2019 Alois Schloegl [1] http://pub.ist.ac.at/~schloegl/biosig/TESTED biosig-2.3.3/biosig4c++/mma/hdrinfo.nb0000664000175000017500000002452214105434233017540 0ustar schloeglschloegl(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 10387, 212] NotebookOptionsPosition[ 10088, 197] NotebookOutlinePosition[ 10446, 213] CellTagsIndexPosition[ 10403, 210] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{"(*", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ "HDRINFO", " ", "displays", " ", "and", " ", "load", " ", "header", " ", "information", " ", "\[IndentingNewLine]", " ", "Copyright", " ", "2011"}], ",", RowBox[{"2012", " ", "Alois", " ", "Schloegl"}], ",", " ", RowBox[{ RowBox[{ "IST", " ", "Austria", "\[IndentingNewLine]", " ", "This", " ", "file", " ", "is", " ", "part", " ", "of", " ", "the", " ", "\"\\"", " ", "repository", "\n", "\[IndentingNewLine]", "BioSig", " ", "is", " ", "free", " ", "software"}], ";", " ", RowBox[{"you", " ", "can", " ", "redistribute", " ", "it", " ", RowBox[{"and", "/", "or"}], "\n", "modify", " ", "it", " ", "under", " ", "the", " ", "terms", " ", "of", " ", "the", " ", "GNU", " ", "General", " ", "Public", " ", "License", "\n", "as", " ", "published", " ", "by", " ", "the", " ", "Free", " ", "Software", " ", "Foundation"}], ";", RowBox[{ "either", " ", "version", " ", "3", "\n", "of", " ", "the", " ", "License"}]}], ",", RowBox[{"or", " ", RowBox[{"(", RowBox[{"at", " ", "your", " ", "option"}], ")"}], " ", "any", " ", "later", " ", RowBox[{ "version", ".", "\[IndentingNewLine]", "\[IndentingNewLine]", "This"}], " ", "program", " ", "is", " ", "distributed", " ", "in", " ", "the", " ", "hope", " ", "that", " ", "it", " ", "will", " ", "be", " ", "useful"}], ",", RowBox[{ RowBox[{"but", " ", "WITHOUT", " ", "ANY", " ", "WARRANTY"}], ";", RowBox[{ "without", " ", "even", " ", "the", " ", "implied", " ", "warranty", " ", "of", "\n", "MERCHANTABILITY", " ", "or", " ", "FITNESS", " ", "FOR", " ", "A", " ", "PARTICULAR", " ", RowBox[{"PURPOSE", ".", "See"}], " ", "the", "\n", "GNU", " ", "General", " ", "Public", " ", "License", " ", "for", " ", "more", " ", RowBox[{ "details", ".", "\[IndentingNewLine]", "\[IndentingNewLine]", "You"}], " ", "should", " ", "have", " ", "received", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "GNU", " ", "General", " ", "Public", " ", "License", "\n", "along", " ", "with", " ", "this", " ", RowBox[{"program", ".", "If"}], " ", "not"}]}], ",", RowBox[{ RowBox[{"see", "<", RowBox[{"http", ":"}]}], "//", RowBox[{ RowBox[{ RowBox[{ RowBox[{"www", ".", "gnu", ".", "org"}], "/", "licenses"}], "/"}], ">", "."}]}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"hdrinfo", "[", RowBox[{"filename_", ",", " ", "sweeps_"}], "]"}], ":=", " ", RowBox[{"Module", " ", "[", RowBox[{ RowBox[{"{", "file", "}"}], ",", " ", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"hdrinfo", ":", " ", RowBox[{ "imports", " ", "header", " ", "information", " ", "\[IndentingNewLine]", " ", "It", " ", "uses", " ", RowBox[{"save2gdf", ".", "exe"}], " ", "to", " ", "export", " ", "the", " ", "header", " ", "information", " ", "into", " ", "JSON", " ", "format", " ", "\[IndentingNewLine]", " ", "which", " ", "is", " ", "then", " ", "imported", " ", "into", " ", RowBox[{"Mathematica", ".", " ", "save2gdf", ".", "exe"}], " ", "must", " ", "be", " ", "available", " ", "within", " ", "the", " ", "PATH", " ", RowBox[{"directories", "."}]}]}], " ", "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"link", "=", RowBox[{"Install", "[", RowBox[{"Switch", "[", RowBox[{ "$SystemID", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\""}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"data", " ", "=", " ", RowBox[{"biosig", "[", "file", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Uninstall", "[", "link", "]"}], ";", "\[IndentingNewLine]", RowBox[{"data", "=", " ", RowBox[{"Import", "[", RowBox[{ RowBox[{"data", "[", RowBox[{"[", "3", "]"}], "]"}], ",", "\"\\""}], "]"}]}]}]}], " ", RowBox[{"(*", " ", RowBox[{"return", " ", "data"}], " ", "*)"}], "\[IndentingNewLine]", "]"}]}], ";"}]}]], "Input", CellChangeTimes->{{3.519966450456757*^9, 3.519966502320704*^9}, { 3.519966532912158*^9, 3.519966567258428*^9}, {3.519966618877387*^9, 3.51996673299822*^9}, {3.519967510684229*^9, 3.519967518075049*^9}, { 3.519967718475827*^9, 3.519967817238503*^9}, {3.5199678483044167`*^9, 3.519967876960375*^9}, {3.51996870364047*^9, 3.519968728788637*^9}, 3.519968924215603*^9, {3.519969005484152*^9, 3.519969026719164*^9}, 3.519970272703093*^9, {3.519970402459618*^9, 3.519970431884839*^9}, { 3.519970507406836*^9, 3.519970525000025*^9}, {3.5199705605132723`*^9, 3.519970601765779*^9}, {3.5199706767387466`*^9, 3.519970694115168*^9}, { 3.519970737788637*^9, 3.519970820710442*^9}, {3.5199713618225*^9, 3.519971396988562*^9}, {3.51997143077888*^9, 3.519971470172937*^9}, { 3.5199716198612328`*^9, 3.519971627056596*^9}, {3.519971726220508*^9, 3.519971847383973*^9}, {3.519971901738119*^9, 3.5199719262231913`*^9}, { 3.519971991327641*^9, 3.519972011494048*^9}, {3.519972063607362*^9, 3.519972078449243*^9}, {3.5199721084608583`*^9, 3.5199721166614122`*^9}, { 3.519972179906435*^9, 3.519972253024084*^9}, {3.519972293264285*^9, 3.519972332511961*^9}, {3.519972600537383*^9, 3.519972606896717*^9}, { 3.51997595094864*^9, 3.519975959335071*^9}, {3.519975990577208*^9, 3.519975992123939*^9}, {3.519976036783289*^9, 3.519976040847102*^9}, { 3.51997613119839*^9, 3.5199761479495497`*^9}, 3.519976183864498*^9, { 3.519976224100204*^9, 3.519976226220254*^9}, {3.519976464411666*^9, 3.519976513020597*^9}, {3.5199765611290503`*^9, 3.519976574326784*^9}, { 3.5199766138015957`*^9, 3.5199766308529673`*^9}, {3.519976763613339*^9, 3.519976799683815*^9}, {3.519979138025991*^9, 3.5199791968322573`*^9}, { 3.519979289763797*^9, 3.5199792908051453`*^9}, {3.519979377123864*^9, 3.519979383972021*^9}, {3.519979442771205*^9, 3.51997946614472*^9}, { 3.5199806627277665`*^9, 3.519980674071444*^9}, {3.520006832039811*^9, 3.520006858540068*^9}, {3.5200069516304865`*^9, 3.5200069738178444`*^9}, { 3.5200072973938985`*^9, 3.520007442783593*^9}, {3.5200452788136187`*^9, 3.520045350254847*^9}, {3.5287739788324213`*^9, 3.528773986388357*^9}, { 3.5496155605201683`*^9, 3.549615589801598*^9}, 3.5569436797058687`*^9, { 3.556944509143981*^9, 3.5569445101951313`*^9}, {3.55694458824214*^9, 3.55694460125224*^9}, {3.556945020734132*^9, 3.55694502131108*^9}, { 3.55694520498739*^9, 3.556945212286521*^9}, {3.559368442317684*^9, 3.559368443191078*^9}, {3.559368475815453*^9, 3.559368484478388*^9}, { 3.559368560115286*^9, 3.5593686001369467`*^9}, {3.559368643489875*^9, 3.559368655914523*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{"Example", " ", "use", " ", "of", " ", RowBox[{"hdrinfo", "[", "]"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"filename", " ", "=", " ", RowBox[{"Switch", "[", RowBox[{ "$SystemID", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\""}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"data", " ", "=", " ", RowBox[{"hdrinfo", "[", "filename", "]"}]}]}]}]], "Input", CellChangeTimes->{{3.519979391272304*^9, 3.519979391298527*^9}, { 3.5199794391621532`*^9, 3.519979443619672*^9}, {3.5199796130222473`*^9, 3.519979624542252*^9}, {3.519979795590229*^9, 3.5199798223556824`*^9}, { 3.520006868285538*^9, 3.520006886419143*^9}, {3.5200071094263515`*^9, 3.5200072102225814`*^9}, {3.5200072451598577`*^9, 3.5200072750190415`*^9}, {3.528787036180324*^9, 3.528787110864997*^9}, { 3.5382845652299757`*^9, 3.5382846614577017`*^9}, {3.549615465329794*^9, 3.5496154794021807`*^9}, {3.549615523967299*^9, 3.5496155245441732`*^9}, { 3.549615636162397*^9, 3.549615649314818*^9}, {3.5496157473455763`*^9, 3.549615753000841*^9}, {3.5569436371616697`*^9, 3.5569436568764563`*^9}, { 3.556943688684099*^9, 3.5569436894182796`*^9}, {3.556944494196495*^9, 3.556944497034631*^9}, {3.556944609666651*^9, 3.5569446134500923`*^9}, { 3.556945025002976*^9, 3.5569450257378893`*^9}, {3.556945080988645*^9, 3.55694517551702*^9}, 3.556945219655058*^9, {3.556945262915558*^9, 3.556945263348009*^9}, {3.559368498962637*^9, 3.559368503501721*^9}, { 3.559368613403432*^9, 3.559368615663232*^9}, {3.559368669249528*^9, 3.559368690131969*^9}}] }, WindowSize->{740, 867}, WindowMargins->{{112, Automatic}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"8.0 for Linux x86 (64-bit) (February 23, 2011)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 7485, 138, 707, "Input"], Cell[8045, 160, 2039, 35, 168, "Input"] } ] *) (* End of internal cache information *) biosig-2.3.3/biosig4c++/mma/README0000664000175000017500000000122614105434233016442 0ustar schloeglschloeglThis is Biosig's interface to Mathematica through the MathLink interface. The function sload.exe provides interface for Mathematica through MathLink to the biosig4c+/libbiosig library. The supported data formats according to the column C/C++ in [1]. sload and uload are both loading the data, sload scales the data, uload does not apply scaling, and returns unscaled integer numbers (there are exceptions) Usage: Start mathematica and type link=Install["sload.exe"] ?sload link=Install["uload.exe"] ?uload Compilation: see INSTALL file Copyright (C) 2011,2015,2019 Alois Schloegl [1] http://pub.ist.ac.at/~schloegl/biosig/TESTED biosig-2.3.3/biosig4c++/mma/Makefile0000664000175000017500000001415314105434244017227 0ustar schloeglschloegl####### Makefile to compile biosig.exe for loading data supported by libbiosig into Mathematica ### ### Copyright (C) 2010-2020 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ########################################### # user-defined variables ########################################### CROSS ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static CROSS64 ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static exec_prefix ?= /usr/local ########################################### ## set Mathematica variables MATHEMATICA_EXE = : MATHEMATICA_EXE ?= $(shell which mathematica) ifeq (,$(MATHEMATICA_EXE)) $(error "mathematica not found in $$PATH - cannot compile biosig for Mathematica") endif MLINKDIR ?= $(shell dirname $(shell dirname $(shell readlink -f $(MATHEMATICA_EXE) ) ) ) ifneq (,$(findstring Darwin,$(shell uname))) MLINKDIR := /Applications/Mathematica.app/Contents/ SYS = MacOSX-x86-64 LDFLAGS += -demangle -dynamic -arch x86_64 LDFLAGS += -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration else SYS = $(notdir $(shell ls -1d $(MLINKDIR)/SystemFiles/Links/MathLink/DeveloperKit/*)) ifneq (1,$(words ${SYS})) SYS = Linux-x86-64# Set this value with the result of evaluating $SystemID endif endif # automated detection of most recent MLINTERFACE, without starting mathematica # 10.0 supports 3 and 4, 9.0 and earlier supports only 3, MLIVER := $(shell ${CC} mliver.c -I${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions/ -E -o - | tail -1) # # Windows SYSwin = Windows# Set this value with the result of evaluating $SystemID MLLIBwin = ml32i4m# Set this to ML64i3 if using a 64-bit system SYSwin64 = Windows-x86-64# Set this value with the result of evaluating $SystemID MLLIBwin64 = ml64i4# Set this to ML64i3 if using a 64-bit system ########################################### CADDSDIR = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions INCDIR = -I${CADDSDIR} -I${MLINKDIR}/SystemFiles/IncludeFiles/C/ LIBDIR += -L${CADDSDIR} EXTRALIBS += -lm -ldl -luuid -lstdc++ # Set these with appropriate libs for your system. ifeq (Darwin,$(shell uname)) MLLIB = MLi${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system SED = gsed else MLLIB = ML$(shell getconf LONG_BIT)i${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system EXTRALIBS += -lrt SED = sed endif LD = ${CC} ifneq (${MLIVER},) CFLAGS += -DMLINTERFACE=${MLIVER} endif MPREP = ${CADDSDIR}/mprep TARGET = biosig # make Linux-x86-64 mma : $(patsubst %, ${SYS}/%.exe, $(TARGET)) # make Linux-x86-64, Windows, Windows-x86-64 all : $(patsubst %, ${SYS}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) .c.o: ${CC} ${CFLAGS} -I.. ${INCDIR} -c "$<" %tm.c: %.tm ${MPREP} "$<" -o "$@" ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" ${SYS}/%.exe: %.o %tm.o mkdir -p ${SYS} ${LD} ${LDFLAGS} $? ${LIBDIR} -l${MLLIB} ${EXTRALIBS} -L.. -lbiosig -o "$@" ln -sf "$@" ### Install Biosig for Mathematica install : biosig.exe mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica install biosig.exe $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/ @echo " Biosig for Mathematica is installed in $(exec_prefix)/libexec/biosig/mathematica/biosig.exe"; @echo " Usage: Start Mathematica and run"; @echo "\tlink=Install[\"$(exec_prefix)/libexec/biosig/mathematica/biosig.exe\"];"; @echo "\t?Sload\n\t?Uload\n"; uninstall: ${RM} $(DESTDIR)$(datadir)/biosig/mathematica/{sload,biosig}.exe -cd $(DESTDIR)$(datadir) && rmdir -p biosig/mathematica ${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/biosig.exe -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/mathematica ########################################### # Win32 - cross-compilation ########################################### CCw32 = $(CROSS)-gcc CADDSDIRwin = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin}/CompilerAdditions INCDIRwin = -I${CADDSDIRwin} LIBDIRwin = ${CADDSDIRwin} EXTRALIBSwin = -lgdi32 -lm -lstdc++ -lws2_32 $(LDLIBS) # Set these with appropriate libs for your system. MPREPwin = ${CADDSDIRwin}/mprep.exe %tm.win32.c : %.tm WINEPREFIX=${HOME}/.wine32.mma wine ${MPREPwin} "$<" -o "$@" ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" ${SYSwin}/%.obj : %.c ${CCw32} -o "$@" -c "$<" $(shell $(CROSS)-pkg-config --cflags libbiosig) ${INCDIRwin} win32mma : $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) #${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.obj # uses MPREP ${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.win32.obj # uses MPREPwin mkdir -p ${SYSwin} ${CCw32} $? -mwindows -static-libgcc -static-libstdc++ $(shell $(CROSS)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin} -l${MLLIBwin} ${EXTRALIBSwin} -o "$@" ########################################### # Win64 - cross-compilation ########################################### CCw64 = $(CROSS64)-gcc CADDSDIRwin64 = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin64}/CompilerAdditions INCDIRwin64 = -I${CADDSDIRwin64} LIBDIRwin64 = ${CADDSDIRwin64} #MPREPwin64 = ${CADDSDIRwin64}/mprep.exe #%tm.win64.c : %.tm # WINEPREFIX=${HOME}/.wine64.mma wine64 ${MPREPwin64} "$<" -o "$@" #${MPREP} "$<" -o "$@" # ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#' "$@" ${SYSwin64}/%.obj : %.c ${CCw64} -o "$@" -c "$<" $(shell $(CROSS64)-pkg-config --cflags libbiosig) ${INCDIRwin64} win64mma : $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) #${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.win64.obj # uses MPREPwin64 ${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.obj # uses MPREP mkdir -p ${SYSwin64} ${CCw64} $? -static-libgcc -static-libstdc++ $(shell $(CROSS64)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin64} -l${MLLIBwin64} ${EXTRALIBSwin} -o "$@" ########################################### clean: -$(RM) *.o* */*.o* -$(RM) *tm.c */*tm.c -$(RM) *.exe */*.exe biosig-2.3.3/biosig4c++/heka2itx0000775000175000017500000000011514105434233016451 0ustar schloeglschloegl#!/bin/sh #conversion from HEKA DAT2 to ITX format format save2gdf -f=ITX $@ biosig-2.3.3/biosig4c++/t241/0000775000175000017500000000000014105434245015504 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/t241/Makefile.in0000664000175000017500000002211314105434233017545 0ustar schloeglschloeglASN_MODULE_SOURCES= \ Address.c \ MetricMeasure.c \ UnitCode.c \ HealthCareProviderId.c \ INT-U64.c \ INT-I64.c \ INT-U32.c \ INT-I32.c \ INT-U16.c \ INT-I16.c \ INT-U8.c \ INT-I8.c \ BITS-32.c \ BITS-16.c \ BITS-8.c \ FEFString.c \ FEFFloat.c \ Fraction.c \ AbsoluteRange.c \ Handle.c \ HandleRef.c \ DeviceCode.c \ UnitsOfMeasurementCode.c \ MetricsCode.c \ BodySiteCode.c \ AlertCode.c \ ExtNomenclatureCode.c \ ParameterGroupCode.c \ PrivateCode.c \ Placeholder.c \ ManufacturerID.c \ AbsoluteTime.c \ RelativeTime.c \ HighResRelativeTime.c \ ObservationTime.c \ SimpleColour.c \ ExtNomenRef.c \ PersonNameGroup.c \ PersonName.c \ OID-Type.c \ SessionArchiveSection.c \ ArchiveProtection.c \ ManufacturerSpecificSection.c \ ManufacturerSpecificEncoded.c \ ManufacturerSpecificBinary.c \ HealthCareProviderSection.c \ HealthCareProfessionalSection.c \ Authorization.c \ PatientDemographicsSection.c \ PatMeasure.c \ PatientSex.c \ PatientType.c \ PatientRace.c \ SessionTestSection.c \ MedicalDeviceSystemSection.c \ SystemModel.c \ SystemSpecEntry.c \ ProdSpecEntryType.c \ ProdSpecEntry.c \ ApplicationArea.c \ PowerStatus.c \ LineFrequency.c \ MedicalDeviceComponents.c \ VirtualMedicalDeviceSection.c \ MsmtPrinciple.c \ ChannelDescriptionSection.c \ ChannelStatus.c \ MultimediaSection.c \ Comments.c \ ContentOrReference.c \ SessionPhaseSection.c \ DescriptiveDataSection.c \ MetricDescriptiveDataSection.c \ MetricStatus.c \ MetricCategory.c \ MetricCalEntry.c \ MetricCalType.c \ MetricCalState.c \ MeasurementStatus.c \ SampleArrayDescriptiveDataSection.c \ SaSpec.c \ StorageDataType.c \ SaFlags.c \ ScaleRangeSpec.c \ SaFilterEntry.c \ FilterType.c \ SaGridEntry.c \ SaCalData.c \ SaCalDataType.c \ SaSignalFrequency.c \ RealTimeSampleArrayDescriptiveDataSection.c \ TimeSampleArrayDescriptiveDataSection.c \ DistributionSampleArrayDescriptiveDataSection.c \ DsaRangeSpec.c \ NumericDescriptiveDataSection.c \ EnumerationDescriptiveDataSection.c \ MeasuredDataSection.c \ SampleArrayMeasuredDataSection.c \ SampleArrayMeasuredDataBlock.c \ RealTimeSampleArrayMeasuredDataSection.c \ TimeSampleArrayMeasuredDataSection.c \ MarkerEntryRelTim.c \ DistributionSampleArrayMeasuredDataSection.c \ NumericMeasuredDataSection.c \ ChoiceOfNuObsValue.c \ NuObsValue.c \ DispResolution.c \ EnumerationMeasuredDataSection.c \ ChoiceOfEnumObsValue.c \ EnumObsValue.c \ EnumVal.c \ EnumObject.c \ EnumRecordMetric.c \ EnumRecordOO.c \ ChoiceOfEnumTimeStamp.c \ AlertSection.c \ AlertCondition.c \ AlertControls.c \ AlertFlags.c \ AlertType.c \ LimitSpecEntry.c \ CurLimAlStat.c \ DynamicAttributeChangeSection.c \ SessionNotesSection.c ASN_MODULE_HEADERS= \ Address.h \ MetricMeasure.h \ UnitCode.h \ HealthCareProviderId.h \ INT-U64.h \ INT-I64.h \ INT-U32.h \ INT-I32.h \ INT-U16.h \ INT-I16.h \ INT-U8.h \ INT-I8.h \ BITS-32.h \ BITS-16.h \ BITS-8.h \ FEFString.h \ FEFFloat.h \ Fraction.h \ AbsoluteRange.h \ Handle.h \ HandleRef.h \ DeviceCode.h \ UnitsOfMeasurementCode.h \ MetricsCode.h \ BodySiteCode.h \ AlertCode.h \ ExtNomenclatureCode.h \ ParameterGroupCode.h \ PrivateCode.h \ Placeholder.h \ ManufacturerID.h \ AbsoluteTime.h \ RelativeTime.h \ HighResRelativeTime.h \ ObservationTime.h \ SimpleColour.h \ ExtNomenRef.h \ PersonNameGroup.h \ PersonName.h \ OID-Type.h \ SessionArchiveSection.h \ ArchiveProtection.h \ ManufacturerSpecificSection.h \ ManufacturerSpecificEncoded.h \ ManufacturerSpecificBinary.h \ HealthCareProviderSection.h \ HealthCareProfessionalSection.h \ Authorization.h \ PatientDemographicsSection.h \ PatMeasure.h \ PatientSex.h \ PatientType.h \ PatientRace.h \ SessionTestSection.h \ MedicalDeviceSystemSection.h \ SystemModel.h \ SystemSpecEntry.h \ ProdSpecEntryType.h \ ProdSpecEntry.h \ ApplicationArea.h \ PowerStatus.h \ LineFrequency.h \ MedicalDeviceComponents.h \ VirtualMedicalDeviceSection.h \ MsmtPrinciple.h \ ChannelDescriptionSection.h \ ChannelStatus.h \ MultimediaSection.h \ Comments.h \ ContentOrReference.h \ SessionPhaseSection.h \ DescriptiveDataSection.h \ MetricDescriptiveDataSection.h \ MetricStatus.h \ MetricCategory.h \ MetricCalEntry.h \ MetricCalType.h \ MetricCalState.h \ MeasurementStatus.h \ SampleArrayDescriptiveDataSection.h \ SaSpec.h \ StorageDataType.h \ SaFlags.h \ ScaleRangeSpec.h \ SaFilterEntry.h \ FilterType.h \ SaGridEntry.h \ SaCalData.h \ SaCalDataType.h \ SaSignalFrequency.h \ RealTimeSampleArrayDescriptiveDataSection.h \ TimeSampleArrayDescriptiveDataSection.h \ DistributionSampleArrayDescriptiveDataSection.h \ DsaRangeSpec.h \ NumericDescriptiveDataSection.h \ EnumerationDescriptiveDataSection.h \ MeasuredDataSection.h \ SampleArrayMeasuredDataSection.h \ SampleArrayMeasuredDataBlock.h \ RealTimeSampleArrayMeasuredDataSection.h \ TimeSampleArrayMeasuredDataSection.h \ MarkerEntryRelTim.h \ DistributionSampleArrayMeasuredDataSection.h \ NumericMeasuredDataSection.h \ ChoiceOfNuObsValue.h \ NuObsValue.h \ DispResolution.h \ EnumerationMeasuredDataSection.h \ ChoiceOfEnumObsValue.h \ EnumObsValue.h \ EnumVal.h \ EnumObject.h \ EnumRecordMetric.h \ EnumRecordOO.h \ ChoiceOfEnumTimeStamp.h \ AlertSection.h \ AlertCondition.h \ AlertControls.h \ AlertFlags.h \ AlertType.h \ LimitSpecEntry.h \ CurLimAlStat.h \ DynamicAttributeChangeSection.h \ SessionNotesSection.h ASN_MODULE_HEADERS+=ANY.h ASN_MODULE_SOURCES+=ANY.c ASN_MODULE_HEADERS+=UTF8String.h ASN_MODULE_HEADERS+=INTEGER.h ASN_MODULE_HEADERS+=NativeEnumerated.h ASN_MODULE_HEADERS+=GeneralizedTime.h ASN_MODULE_SOURCES+=GeneralizedTime.c ASN_MODULE_SOURCES+=INTEGER.c ASN_MODULE_SOURCES+=NativeEnumerated.c ASN_MODULE_HEADERS+=NativeInteger.h ASN_MODULE_SOURCES+=NativeInteger.c ASN_MODULE_HEADERS+=REAL.h ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.c ASN_MODULE_SOURCES+=REAL.c ASN_MODULE_SOURCES+=UTF8String.c ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c ASN_MODULE_HEADERS+=asn_SET_OF.h ASN_MODULE_SOURCES+=asn_SET_OF.c ASN_MODULE_HEADERS+=constr_CHOICE.h ASN_MODULE_SOURCES+=constr_CHOICE.c ASN_MODULE_HEADERS+=constr_SEQUENCE.h ASN_MODULE_SOURCES+=constr_SEQUENCE.c ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c ASN_MODULE_HEADERS+=constr_SET_OF.h ASN_MODULE_SOURCES+=constr_SET_OF.c ASN_MODULE_HEADERS+=asn_application.h ASN_MODULE_HEADERS+=asn_system.h ASN_MODULE_HEADERS+=asn_codecs.h ASN_MODULE_HEADERS+=asn_internal.h ASN_MODULE_HEADERS+=OCTET_STRING.h ASN_MODULE_SOURCES+=OCTET_STRING.c ASN_MODULE_HEADERS+=BIT_STRING.h ASN_MODULE_SOURCES+=BIT_STRING.c ASN_MODULE_SOURCES+=asn_codecs_prim.c ASN_MODULE_HEADERS+=asn_codecs_prim.h ASN_MODULE_HEADERS+=ber_tlv_length.h ASN_MODULE_SOURCES+=ber_tlv_length.c ASN_MODULE_HEADERS+=ber_tlv_tag.h ASN_MODULE_SOURCES+=ber_tlv_tag.c ASN_MODULE_HEADERS+=ber_decoder.h ASN_MODULE_SOURCES+=ber_decoder.c ASN_MODULE_HEADERS+=der_encoder.h ASN_MODULE_SOURCES+=der_encoder.c ASN_MODULE_HEADERS+=constr_TYPE.h ASN_MODULE_SOURCES+=constr_TYPE.c ASN_MODULE_HEADERS+=constraints.h ASN_MODULE_SOURCES+=constraints.c ASN_MODULE_HEADERS+=xer_support.h ASN_MODULE_SOURCES+=xer_support.c ASN_MODULE_HEADERS+=xer_decoder.h ASN_MODULE_SOURCES+=xer_decoder.c ASN_MODULE_HEADERS+=xer_encoder.h ASN_MODULE_SOURCES+=xer_encoder.c ASN_MODULE_HEADERS+=per_support.h ASN_MODULE_SOURCES+=per_support.c ASN_MODULE_HEADERS+=per_decoder.h ASN_MODULE_SOURCES+=per_decoder.c ASN_MODULE_HEADERS+=per_encoder.h ASN_MODULE_SOURCES+=per_encoder.c #ASN_CONVERTER_SOURCES+=converter-sample.c lib_LTLIBRARIES=libsomething.la libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS) # This file may be used as an input for make(3) # Remove the lines below to convert it into a pure .am file TARGET = libfef.a ../win32/libfef.a ../win32/libfef.dll CFLAGS += -pipe -fPIC -Wall -O2 -Wextra -I. OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o} WINOBJS=${ASN_MODULE_SOURCES:.c=.obj} ${ASN_CONVERTER_SOURCES:.c=.obj} AR = ar crs MinGWCC = i586-mingw32msvc-gcc all: $(TARGET) #$(TARGET): ${OBJS} # $(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS) libfef.a: $(OBJS) $(AR) libfef.a $(OBJS) ../win32/libfef.a: $(WINOBJS) i586-mingw32msvc-$(AR) ../win32/libfef.a $(WINOBJS) #../win32/libfef.a: $(WINOBJS) # i586-mingw32msvc-$(AR) ../win32/libfef.a $(WINOBJS) ../win32/libfef.dll: $(WINOBJS) $(MinGWCC) -shared -fPIC $(WINOBJS) -Wl,--output-def,../win32/libfef.def,--out-implib,../win32/libfef.dll .SUFFIXES: .SUFFIXES: .c .o %.obj: %.c $(MinGWCC) $(CFLAGS) -o $@ -c $< .c.o: $(CC) $(CFLAGS) -o $@ -c $< clean: rm -f $(ASN_MODULE_HEADERS) rm -f $(ASN_MODULE_SOURCES) rm -f $(TARGET) rm -f $(OBJS) rm -f $(WINOBJS) rm -f Makefile.am.sample libfef.a regen: regenerate-from-asn1-source regenerate-from-asn1-source: -asn1c -fcompound-names CENTS14271-2003.asn1 -asn1c -fcompound-names ISO11073-10404.asn1 -asn1c -fcompound-names ISO11073-10417.asn1 -asn1c -fcompound-names ISO11073-10471.asn1 -asn1c -fcompound-names ISO11073-20601.asn1 rm -f converter-sample.c Makefile.am.sample libfef.a biosig-2.3.3/biosig4c++/t241/ISO11073-20601.asn10000664000175000017500000021400014105434233017756 0ustar schloeglschloegl/* ASN.1 Specification of 11073-20601 Health informatics – Personal health device communication – Part 20601: Application profile – Optimized exchange protocol The info was manually extracted and adapted to be valid ASN1 syntax. $Id$ Copyright (C) 2009,2012 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ ModuleTest DEFINITIONS ::= BEGIN /* This annex provides ASN.1 definitions relevant for the personal health device protocol. Some are imported from other parts of the ISO/IEEE 11073 family of standards and others are created specifically for the personal health device domain. If there is interest in understanding which structures are imported and which are new, see J. This annex ensures that all data structures required to implement this Standard are readily available. The naming convention followed in this annex is to use hyphen (-) to separate words in attributes and to use mixed case when describing data types; however, constructs that were imported from other specifications follow the existing use of capitalization and hyphenation. Common data types This subclause defines a set of ASN.1 data types that are used in the object definitions. Integer and bit string data types For representing integer numbers, the object definitions use fixed-size data types only. The bit string data type represents a bit field where each single bit has a defined meaning (i.e., flag fields). The following integer data types and bit string data types are used: */ -- -- 8-bit unsigned integer -- INT-U8 ::= INTEGER (0..255) -- -- 8-bit signed integer -- INT-I8 ::= INTEGER (-128..127) -- -- 16-bit unsigned integer -- INT-U16 ::= INTEGER (0..65535) -- -- 16-bit signed integer -- INT-I16 ::= INTEGER (-32768..32767) -- -- 32-bit unsigned integer -- INT-U32 ::= INTEGER (0..4294967295) -- -- 32-bit signed integer -- INT-I32 ::= INTEGER (-2147483648..2147483647) -- -- Unless otherwise stated, all unused (reserved) bits in any of the BITS-* constructs shall be set to 0 by -- the sender and unless otherwise stated, shall be ignored by the receiver if they are set to 1. -- -- 8-bit bit string -- BITS-8 ::= BIT STRING (SIZE(8)) -- -- 16-bit bit string -- BITS-16 ::= BIT STRING (SIZE(16)) -- -- 32-bit bit string -- BITS-32 ::= BIT STRING (SIZE(32)) /* Note that in object definitions, integer and bit string data types with named constants or named bits use the above defined basic data types for simplicity. This approach provides an abbreviated notation, but it is illegal ASN.1 syntax. It can be easily transformed to the correct syntax. For example, the definition NamedConstant ::= INTEGER { const1(1), const2(2) } becomes correct ASN.1 syntax defined as: NamedConstant ::= INTEGER { const1(1), const2(2) } (0..65535) Identification data type All elements (e.g., classes, objects, and measurement types) that need unique identification are assigned an object identifier (OID). The set of valid OIDs for this Standard is defined in ISO/IEEE 11073-10101 K. The nomenclature consists of a set of partitions, where each partition covers a specific concept and has its own 16-bit codes. In other words, a specific code is identified by both its partition number and an OID within that partition or its use is context dependent. In the case of context-dependent codes, the specific partition the code utilized is called out within this Standard. The 16-bit identification data type is defined as follows: */ -- -- OID type as defined in nomenclature -- (do not confuse with ASN.1 OID) -- OID-Type ::= INT-U16 -- 16-bit integer type /* A private partition is available for codes and IDs that are yet to be standardized or for manufacturer-specific codes. */ -- -- Private OID -- PrivateOid ::= INT-U16 /* Handle data type The handle data type is used for efficient and locally unique identification of all managed object instances. (Locally unique means unique within one MDS context.) This data type is defined as follows: */ -- -- handle -- HANDLE ::= INT-U16 /* Instance number data type The instance number is used to distinguish class or object instances of the same type or object instances that are not directly manageable (used, e.g., as the identification attribute for PM-segment objects). */ -- -- Instance Number -- InstNumber ::= INT-U16 /* Type ID data type The type ID data type is used to identify the type of all elements (e.g., classes, objects, and measurement types). It is similar to the OID type (B2.2), but includes both the nomenclature partition and code to provide unique identification of an element. It shall be used when the context is not implicit. This data type is defined as follows: */ -- -- Type ID -- TYPE ::= SEQUENCE { partition NomPartition, code OID-Type } -- -- The following nomenclature partitions exist: -- NomPartition ::= INTEGER { nom-part-unspec(0), -- unspecified nom-part-obj(1), -- object-oriented partition nom-part-metric(2), -- metric [supervisory control and data acquisition -- (SCADA)] partition nom-part-alert(3), -- alerts/events partition nom-part-dim(4), -- dimensions partition nom-part-vattr(5), -- virtual attribute partition for operation objects nom-part-pgrp(6), -- parameter group ID partition nom-part-sites(7), -- measurement and body site locations nom-part-infrastruct(8), -- infrastructure elements partition nom-part-fef(9), -- file exchange format partition nom-part-ecg-extn(10), -- electrocardiogram extensions partition nom-part-idco-extn(11), -- implantable cardiac device observation extensions nom-part-phd-dm(128), -- disease management nom-part-phd-hf(129), -- health and fitness nom-part-phd-ai(130), -- aging independently nom-part-ret-code(255), -- return codes partition nom-part-ext-nom(256), -- IDs of other nomenclatures and dictionaries nom-part-priv(1024) -- private partition } (0..65535) /* Attribute value assertion (AVA) data type The AVA data type fully specifies the attribute of an object by its attribute ID and its value. As the structure of the value is attribute dependent, the type is specified by ANY DEFINED BY. This data type supports a number of services used to access object attributes (e.g., GET and SET). The attribute ID values are defined for each object type in the Attribute ID column of the object definition tables (i.e., , , , , , , , , , , and ). The structure used for the attribute-value is defined by the Attribute Type column of the same tables. The AVA data type is defined as follows: */ -- AVA-Type ::= SEQUENCE { attribute-id OID-Type, -- This shall come from the nom-part-obj partition attribute-value ANY DEFINED BY attribute-id } /* Attribute list data type Frequently, a list of attribute ID–attribute value pairs is needed. The attribute list data type is a special data type that is provided for this situation and is defined as follows: */ -- AttributeList ::= SEQUENCE OF AVA-Type /* Attribute ID list data type Frequently, a list of attribute IDs is used. The attribute ID list data type is a special type that is provided for convenience and is defined as follows: */ -- AttributeIdList ::= SEQUENCE OF OID-Type /* Floating point type (FLOAT-Type) data type The FLOAT-Type data type is defined to represent numeric values that are not integer in type. The FLOAT-Type is defined as a 32-bit value with 24-bit mantissa and 8-bit exponent. See F.7 for full definition of this data type. This data type is defined as follows: */ -- -- 32-bit float type; the integer type is a placeholder only -- FLOAT-Type ::= INT-U32 /* The 32 bits contain an 8-bit signed exponent to base 10, followed by a 24-bit signed integer (mantissa). Special values are assigned to express the following: NaN (not a number) [exponent 0, mantissa +(2**23 –1)  0x007FFFFF] NRes (not at this resolution) [exponent 0, mantissa –(2**23)  0x00800000] + INFINITY [exponent 0, mantissa +(2**23 –2)  0x007FFFFE] – INFINITY [exponent 0, mantissa –(2**23 –2)  0x00800002] Reserved for future use [exponent 0, mantissa –(2**23–1)  0x00800001] */ /*Short floating point type (SFLOAT-Type) data type The short floating point type SFLOAT-Type data type is defined to represent numeric values that are not integer in type and have limited resolution. The SFLOAT-Type is defined as a 16-bit value with 12-bit mantissa and 4-bit exponent. See Annex ‎F.7 for full definition of this data type. This data type is defined as follows: */ -- -- 16-bit float type; the integer type is a placeholder only -- SFLOAT-Type ::= INT-U16 /* The 16–bit value contains a 4-bit exponent to base 10, followed by a 12-bit mantissa. Each is in twos-complement form. Special values are assigned to express the following: NaN [exponent 0, mantissa +(2**11 –1)  0x07FF] NRes [exponent 0, mantissa –(2**11)  0x0800] + INFINITY [exponent 0, mantissa +(2**11 –2)  0x07FE] – INFINITY [exponent 0, mantissa –(2**11 –2)  0x0802] Reserved for future use [exponent 0, mantissa –(2**11 –1)  0x0801] */ /* Relative time data type The relative time data type is a time counter that is used to determine the relative time between events. This data type is used to position events relative to each other. It is defined as follows: */ -- -- Relative time has a resolution of 125 μs (LSB), which is sufficient for sampling -- rates up to 8 kHz and spans time periods up to 6.2 days. -- The value of 0xFFFFFFFF shall be used when an agent is required to send a relative time in an ASN.1 -- structure but does not support a relative time clock. -- RelativeTime ::= INT-U32 /* Note that the actual time resolution is defined by the agent. High-resolution relative time data type The high-resolution relative time data type is a high-resolution time counter that is used to determine the relative time between events. This data type is used to position events relative to each other. It is defined as follows: */ -- -- High-resolution time has a resolution of 1 μs and can represent time -- spans of over 584 000 years. Theoretically, this could be modeled as an INT-U64; -- however, due to limitations in the ASN.1 compilers, embedded devices support -- for 64-bit integers, and the MDER specifications, an OCTET STRING was -- used instead. -- HighResRelativeTime ::= OCTET STRING (SIZE(8)) /* Note that the agent defines the actual time resolution used. */ -- -- Absolute time adjust has a resolution of 1/100 of a second and can represent time -- adjustments of plus or minus 44 505 years. Theoretically, this could be modeled as an INT-I48; -- however, due to potential limitations in ASN.1 compilers, embedded devices support -- for 48-bit integers, and the MDER specifications, an OCTET STRING was -- used instead. -- AbsoluteTimeAdjust ::= OCTET STRING (SIZE(6)) /* Absolute time data type The absolute time data type specifies the time of day with a resolution of 1/100 of a second. The hour field shall be reported in 24-hr time notion (i.e., from 0 to 23). The values in the structure shall be encoded using binary coded decimal (i.e., 4-bit nibbles). For example, the year 1996 shall be represented by the hexadecimal value 0x19 in the century field and the hexadecimal value 0x96 in the year field. This format is easily converted to character- or integer-based representations. The absolute time data type is defined as follows: */ -- AbsoluteTime ::= SEQUENCE { century INT-U8, year INT-U8, month INT-U8, day INT-U8, hour INT-U8, minute INT-U8, second INT-U8, sec-fractions INT-U8 -- 1/100 of a second if available } /* Note that the agent defines the actual time resolution used (e.g., if the clock resolution is 1 s, then sec‑fractions is always zero). Agents should have a resolution of 1 s or better. Base time with offsetdata type The base time with offset data type specifies the time of day and includes a time offset field to specify the difference in minutes between the base time and the local time. Base time is encoded as the number seconds since midnight of 1st January 1900 specified as INT-U32 and the fraction of x/65 536 s as INT-U16. The time offset field is specified as INT-I16. The base offset time data type is defined as follows: */ -- BaseOffsetTime ::= SEQUENCE { bo-seconds INT-U32, bo-fraction INT-U16, bo-time-offset INT-I16 } /* Operational state data type The operational state data type defines if a certain object or other property is enabled or disabled. */ -- OperationalState ::= INTEGER { disabled(0), enabled(1), notAvailable(2) -- the value notAvailable is not used in this Standard } (0..65535) /* Attribute data types MDS attributes */ -- -- SystemModel contains manufacturer name and manufacturer specific model information. -- While model-number field name suggests a number, there is no requirement that the field -- contains numeric values. The format of the manufacturer name and model number strings -- are decided upon by the agent vendor, but shall be printable ASCII. -- SystemModel ::= SEQUENCE { manufacturer OCTET STRING, -- string size shall be even model-number OCTET STRING -- string size shall be even } -- -- ProductionSpec deals with serial numbers, part numbers, revisions, etc. -- Note that an agent may have multiple components; therefore, the prod-spec should be an -- ASCII printable string of the format “spec-type: vendor-specified-str†where spec-type is -- replaced by the string representation of spec-type. The format of the vendor-specified-str -- is determined by the vendor. -- ProductionSpec ::= SEQUENCE OF ProdSpecEntry ProdSpecEntry ::= SEQUENCE { spec-type INTEGER { unspecified(0), serial-number(1), part-number(2), hw-revision(3), sw-revision(4), fw-revision(5), protocol-revision(6), prod-spec-gmdn(7) -- see note on GMDN below } (0..65535), component-id PrivateOid, prod-spec OCTET STRING -- string size shall be even } -- Note: The Global Medical Device Nomenclature (GMDN) is based on ISO 15225 K -- and was developed under the auspices of CEN TC257 SC1.1 -- -- PowerStatus defines whether device is on battery or on mains. Upper bits define the charging -- state. -- PowerStatus ::= BITS-16 { onMains(0), onBattery(1), chargingFull(8), chargingTrickle(9), chargingOff(10) } -- -- All measures about the battery are values with their dimensions. See the description -- of Remaining-Battery-Time in for a description of legal units. -- BatMeasure ::= SEQUENCE { value FLOAT-Type, unit OID-Type -- from nom-part-dim partition } /* Metric attributes This group contains imported attribute definitions that apply to the numeric, enumeration, and the RT-SA objects. */ -- -- Status of the measurement -- The bit values 14 and 15 are used in other ISO/IEEE 11073 standards and shall not be used for a different -- purpose. -- MeasurementStatus ::= BITS-16 { invalid(0), questionable(1), not-available(2), calibration-ongoing(3), test-data(4), demo-data(5), validated-data(8), -- relevant, e.g., in an archive early-indication(9), -- early estimate of value msmt-ongoing(10) -- indicates a new measurement is just being taken -- (episodic) } Numeric attributes -- -- NuObsValue (Numeric Observed Value) always includes identification, state, and dimension. -- NuObsValue ::= SEQUENCE { metric-id OID-Type, -- This code comes from the partition identified in -- Metric::Type attribute of the numeric object. state MeasurementStatus, unit-code OID-Type, -- from nom-part-dim dimensions nomenclature -- partition value FLOAT-Type } -- -- Observed value for compound numerics -- NuObsValueCmp ::= SEQUENCE OF NuObsValue /* RT-SA attributes */ -- -- SaSpec describes the sample array. -- SaSpec ::= SEQUENCE { array-size INT-U16, -- number of samples per metric update period sample-type SampleType, flags SaFlags } -- -- SampleType describes one sample in the observed value array. -- SampleType ::= SEQUENCE { sample-size INT-U8, -- e.g., 8 for 8-bit samples, 16 for 16-bit samples, -- shall be divisible by 8 significant-bits INT-U8 -- defines significant bits in one sample { signed-samples(255)} -- if value is 255, the samples -- in Simple-Sa-Observed-Value and -- lower-scaled-value and upper-scaled-value in -- ScaleRangeSpec shall be interpreted as signed -- integers in twos-complement form. } -- -- SaFlags defines additional wave form properties. -- SaFlags ::= BITS-16 { smooth-curve(0), -- for optimum display, use a smoothing algorithm delayed-curve(1), -- curve is delayed (not real time) static-scale(2), -- ScaleRangeSpec does not change sa-ext-val-range(3) -- The nonsignificant bits in a sample are not 0, e.g., -- when they are used for annotations or markers. -- The receiver shall apply a bit mask to extract the -- significant bits from the sample. If the samples are -- signed, the sa-ext-val-range bit shall not be set -- (because, by definition, there cannot be -- nonsignificant bits in the field). } -- -- The scale and range definition attribute describes a mapping between scaled values -- and absolute values and defines the expected range of absolute values and scaled values. -- Dependent on the range of the scaled values, multiple attribute types exist. -- The mapping between sample values and converted absolute values is defined by -- the Scale-and-Range-Specification formula in . -- ScaleRangeSpec8 ::= SEQUENCE { lower-absolute-value FLOAT-Type, upper-absolute-value FLOAT-Type, lower-scaled-value INT-U8, -- n.b. interpret as INT-I8 upper-scaled-value INT-U8 -- if Sa-Specification attribute -- indicates signed samples } ScaleRangeSpec16 ::= SEQUENCE { lower-absolute-value FLOAT-Type, upper-absolute-value FLOAT-Type, lower-scaled-value INT-U16, -- n.b. interpret as INT-I16 upper-scaled-value INT-U16 -- if Sa-Specification attribute -- indicates signed samples } ScaleRangeSpec32 ::= SEQUENCE { lower-absolute-value FLOAT-Type, upper-absolute-value FLOAT-Type, lower-scaled-value INT-U32, -- n.b. interpret as INT-I32 upper-scaled-value INT-U32 -- if Sa-Specification attribute -- indicates signed samples } /* Enumeration attributes */ -- -- EnumObsValue describes the enumeration observed value. -- EnumObsValue ::= SEQUENCE { metric-id OID-Type, -- This code comes from the partition defined in the -- Metric-Id-Partition attribute, if valued. Otherwise, -- it comes from the same partition as the Type -- attribute. state MeasurementStatus, value EnumVal -- supports different value data types } -- EnumVal is used to denote different specific observation data types as follows -- (Note that the type of measurement is coded in the top-level structure EnumObsVal::metric-id): -- -- enum-obj-id: used to communicate a metric OID, e.g., as an annotation or -- other event defined in the Metric::Type partition -- enum-text-string: used to communicate a free text string (e.g., a status message) -- enum-bit-str: for coding bit string values; the bit string data type shall be -- defined separately, e.g., in the nomenclature or in a -- device-specific standard -- -- Other data types defined in ISO/IEEE 11073-10201:2004 K are not included here as they are not -- relevant for personal health devices. -- EnumVal ::= CHOICE { enum-obj-id [1] OID-Type, -- This code comes from the partition defined in the -- Enum-Observed-Value-Partition attribute, if -- valued. Otherwise, it comes from the same -- partition as the Type attribute. enum-text-string [2] OCTET STRING, -- printable ASCII text, size even enum-bit-str [16] BITS-32 -- bit string } /* Scanner attributes None Configurable scanner attributes */ -- -- ConfirmMode defines if confirmed event reports or unconfirmed event reports are used. -- ConfirmMode ::= INTEGER { unconfirmed(0), confirmed(1) } (0..65535) /* Episodic configurable scanner attributes None Periodic configurable scanner attributes None PM-store and PM-segment attributes */ -- -- StoSampleAlg describes how samples are derived and averaged. -- StoSampleAlg ::= INTEGER { st-alg-nos(0), -- not otherwise specified st-alg-moving-average(1), st-alg-recursive(2), st-alg-min-pick(3), st-alg-max-pick(4), st-alg-median(5), st-alg-trended(512), -- trend values are used st-alg-no-downsampling(1024), -- means no averaging, this is a real measured sample st-alg-manuf-specific-start(61440), -- start of the reserved manufacturer-specific range st-alg-manuf-specific-end(65535) -- end of the reserved manufacturer-specific range } (0..65535) /* ACTION-method-related data types */ -- -- SetTimeInvoke selects the date and time to be set. -- SetTimeInvoke ::= SEQUENCE { date-time AbsoluteTime, accuracy FLOAT-Type -- accounts for set time (e.g., 2 min error); -- value is defined in seconds. This parameter is -- inherited from ISO/IEEE 11073-10201:2004 -- K, but not used. Thus, it shall be zero (0). } -- -- SetBOTimeInvoke selects the date and time to be set in base offset time format. If both the seconds and fraction fields are set to 0x0, they are ignored in the action and only the offset is changed. -- SetBOTimeInvoke ::= SEQUENCE { date-time BaseOffsetTime } -- -- SegmSelection selects the PM-segments that are subject to the method. -- SegmSelection ::= CHOICE { all-segments [1] INT-U16, -- if this type is chosen to select all segments -- the actual contents of the field is “do not care†-- and shall be zero segm-id-list [2] SegmIdList, -- using this list requires that the manager already -- knows the Instance-Number attributes of the -- PM-segments, e.g., from a previous -- Get-Segment-Info method call. abs-time-range [3] AbsTimeRange, -- support of abs-time-range is optional, indicated in -- the PM-Store-Capab attribute bo-time-range [4] BOTimeRange -- support of bo-time-range is optional, indicated in -- the PM-Store-Capab attribute } -- -- SegmIdList selects PM-segments by ID. -- SegmIdList ::= SEQUENCE OF InstNumber -- -- AbsTimeRange allows selection of PM-segments by time period. -- AbsTimeRange ::= SEQUENCE { from-time AbsoluteTime, to-time AbsoluteTime } -- -- BOTimeRange allows selection of PM-segments by time period specified as base offset time. -- BOTimeRange ::= SEQUENCE { from-time BaseOffsetTime, to-time BaseOffsetTime } -- -- SegmentInfoList returns the object attributes (except the Fixed-Segment-Data) of all -- selected PM-segment object instances in response to the Get-Segment-Info PM-store method. -- This is required by the manager to retrieve the dynamic information about the segments. -- SegmentInfoList ::= SEQUENCE OF SegmentInfo SegmentInfo ::= SEQUENCE { seg-inst-no InstNumber, seg-info AttributeList } /* Message-related data types */ ObservationScan ::= SEQUENCE { obj-handle HANDLE, attributes AttributeList } Other -- -- TimeProtocolId indicates the time protocols that are supported/used by the device. -- TimeProtocolId ::= OID-Type -- from the nom-part-infrastruct nomenclature partition /* Personal health device protocol frame The following data type represents the top-level message frame of the personal health device protocol. The data Apdu (encapsulated by the PrstApdu) is interpreted according to this Standard as a result of the negotiation contained within the association procedure as described in . MDER encoding rules shall always apply to the structure in A.7. */ ApduType ::= CHOICE { aarq [57856] AarqApdu, -- Association Request [0xE200] aare [58112] AareApdu, -- Association Response [0xE300] rlrq [58368] RlrqApdu, -- Association Release Request -- [0xE400] rlre [58624] RlreApdu, -- Association Release Response -- [0xE500] abrt [58880] AbrtApdu, -- Association Abort [0xE600] prst [59136] PrstApdu -- Presentation APDU [0xE700] } /* Association protocol definitions MDER encoding rules shall always apply to the structures in A.8. */ AarqApdu ::= SEQUENCE { -- The assoc-version defines the version of the association procedure -- used by the agent. The agent shall set exactly one -- version bit. If the manager does not understand that version, it shall -- reject the association request with rejected-unsupported-assoc-version. assoc-version AssociationVersion, data-proto-list DataProtoList } DataProtoList ::= SEQUENCE OF DataProto -- If the data-proto-id is set to data-proto-id-20601, the data-proto-info shall -- be filled with a PhdAssociationInformation structure. -- If the data-proto-id is set to data-proto-id-external, the data-proto-info shall -- be filled with a ManufSpecAssociationInformation structure. -- If the data-proto-id is set to data-proto-id-empty, the data-proto-info shall -- be empty (only used when the AareApdu is a reject). DataProto ::= SEQUENCE { data-proto-id DataProtoId, data-proto-info ANY DEFINED BY data-proto-id } -- All other DataProtoId values are reserved and shall not be used. DataProtoId ::= INTEGER { data-proto-id-empty(0), -- shall be used in AareApdu only when result is -- a rejection data-proto-id-20601(20601), -- indicates exchange protocol follows this Standard data-proto-id-external(65535) -- indicates manufacturer specific -- data protocol UUID is part of -- the ManufSpecAssociationInformation } (0..65535) -- Association response AareApdu ::= SEQUENCE { result AssociateResult, selected-data-proto DataProto } -- Release request RlrqApdu ::= SEQUENCE { reason ReleaseRequestReason } -- Release response RlreApdu ::= SEQUENCE { reason ReleaseResponseReason } -- Abort AbrtApdu ::= SEQUENCE { reason Abort-reason } -- Reason for the Abort -- All unassigned " Abort-reason " values are reserved for future expansion and shall not be used. Abort-reason ::= INTEGER { undefined(0), buffer-overflow(1), response-timeout(2), configuration-timeout(3) -- Configuration message not received in timely -- fashion } (0..65535) -- See for a usage description. -- All unassigned " AssociateResult " values are reserved for future expansion and shall not be used. AssociateResult ::= INTEGER { accepted(0), rejected-permanent(1), rejected-transient(2), accepted-unknown-config(3), rejected-no-common-protocol(4), rejected-no-common-parameter(5), rejected-unknown(6), rejected-unauthorized(7), rejected-unsupported-assoc-version(8) } (0..65535) -- All unassigned " ReleaseRequestReason " values are reserved for future expansion and shall not be used. ReleaseRequestReason ::= INTEGER { normal(0), -- used when the agent or manager decides to -- release the association under normal conditions no-more-configurations(1), -- used by the agent when all possible configurations -- were attempted and the manager -- rejected them all. configuration-changed(2) -- used by the agent when its configuration changes -- requiring the agent to release the association. This -- may be followed by an Association Request with -- new configuration information. } (0..65535) -- All unassigned " ReleaseResponseReason " values are reserved for future expansion and -- shall not be used. ReleaseResponseReason ::= INTEGER { normal(0) } (0..65535) -- Association Request DataProto values are mapped to the PhdAssociationInformation. -- This information is used to announce and negotiate the protocol version, profile, etc. PhdAssociationInformation ::= SEQUENCE { -- The protocolVersion information is used to communicate acceptable versions. When -- the agent sends the protocolVersion, it shall set the bit(s) for each version -- that it supports. When the manager responds, it shall set a single bit -- to indicate the protocol version to be used by both. If there is not -- a common protocol version, the manager shall reject the association request -- and set the protocolVersion to all zeros. protocol-version ProtocolVersion, encoding-rules EncodingRules, nomenclature-version NomenclatureVersion, functional-units FunctionalUnits, system-type SystemType, system-id OCTET STRING, dev-config-id ConfigId, data-req-mode-capab DataReqModeCapab, option-list AttributeList } -- -- Manufacturer-specific association information for a proprietary data protocol -- ManufSpecAssociationInformation ::= SEQUENCE { data-proto-id-ext UuidIdent, data-proto-info-ext ANY DEFINED BY data-proto-id-ext } -- All unassigned " AssociationVersion " bit values are reserved for future expansion and -- shall be set to zero. AssociationVersion ::= BITS-32 { assoc-version1(0) -- This bit shall be set if version 1 of the association -- protocol is supported } -- All unassigned " ProtocolVersion " bit values are reserved for future expansion and shall be set to zero. ProtocolVersion ::= BITS-32 { protocol-version1(0), -- This bit shall be set if IEEE Std 11073-20601-2008 -- is supported protocol-version2(1), -- This bit shall be set if IEEE Std 11073-20601a -- is supported } -- --The agent and manager shall always support MDER. --The agent and manager may negotiate other encoding rules besides MDER. -- All unassigned " EncodingRules " bit values are reserved for future expansion and shall be set to zero. -- EncodingRules ::= BITS-16 { mder(0), -- This bit shall be set if MDER supported/selected xer(1), -- This bit shall be set if XER supported/selected per(2) -- This bit shall be set if PER supported/selected } -- All unassigned " NomenclatureVersion " bit values are reserved for future expansion and -- shall be set to zero. NomenclatureVersion ::= BITS-32 { -- values reference a specific nomenclature standard nom-version1(0) -- This bit shall be set if version 1 is supported } -- All unassigned " FunctionalUnits " bit values are reserved for future expansion and shall be set to zero. FunctionalUnits ::= BITS-32 { fun-units-unidirectional(0), -- Reserved for future use. fun-units-havetestcap(1), -- This bit indicates if the device can enter a -- test association fun-units-createtestassoc(2) -- This bit is used to indicate an intention to -- form a test association } -- All unassigned " SystemType " bit values are reserved for future expansion and shall be set to zero. SystemType ::= BITS-32 { sys-type-manager(0), sys-type-agent(8) } ConfigId ::= INTEGER { manager-config-response(0), standard-config-start(1), standard-config-end(16383), extended-config-start(16384), extended-config-end(32767), reserved-start(32768), reserved-end(65535) } (0..65535) /* Presentation protocol definitions MDER encoding rules shall always apply to the structures in A.9. */ -- -- The OCTET STRING contains the data APDU encoded according to the abstract and transfer syntaxes -- negotiated at association time. When the data-proto-id is negotiated to be data-proto-id-20601, the -- OCTET STRING shall be an encoded version of DataApdu. -- PrstApdu ::= OCTET STRING /* Data protocol definitions General The DataApdu and the related structures in A.10 shall use encoding rules as negotiated during the association procedure as described in . The agent and manager shall always support the MDER. The agent and manager may negotiate other encoding rules besides MDER. Data protocol frame */ -- -- Combined Remote Operation Primitive Type and Operation Type -- In the remote operation invoke messages (roiv-*), invoke-id is an opaque handle -- that allows the sender of the message to identify the associated response message (if any). -- The sender of roiv-* message shall select a value of invoke-id that enables it to differentiate this message -- from any other roiv-* messages that have not been retired. Messages are retired either by the -- reception of a response (rors-*, roer, or rorj) or by exceeding the confirmation timeout value. -- When a response message (rors-*, roer, or rorj) is returned, the invoke-id from the invocation -- message shall be copied into the invoke-id of the response. This allows the initiator to match -- responses to outstanding requests. Since the handle is opaque, the receiver can make no other -- assumptions about invoke-id. In particular, it can not assume that it will be unique over any sequence of -- numbers or period of time. -- DataApdu ::= SEQUENCE { invoke-id InvokeIDType, message CHOICE { roiv-cmip-event-report [256] EventReportArgumentSimple, -- [0x0100] roiv-cmip-confirmed-event-report [257] EventReportArgumentSimple, -- [0x0101] roiv-cmip-get [259] GetArgumentSimple, -- [0x0103] roiv-cmip-set [260] SetArgumentSimple, -- [0x0104] roiv-cmip-confirmed-set [261] SetArgumentSimple, -- [0x0105] roiv-cmip-action [262] ActionArgumentSimple, -- [0x0106] roiv-cmip-confirmed-action [263] ActionArgumentSimple, -- [0x0107] rors-cmip-confirmed-event-report [513] EventReportResultSimple, -- [0x0201] rors-cmip-get [515] GetResultSimple, -- [0x0203] rors-cmip-confirmed-set [517] SetResultSimple, -- [0x0205] rors-cmip-confirmed-action [519] ActionResultSimple, -- [0x0207] roer [768] ErrorResult, -- [0x0300] rorj [1024] RejectResult -- [0x0400] } } -- The sender should limit the number of messages outstanding simultaneously. -- In fact, the receiver might not be able to handle more than one message at a time. InvokeIDType ::= INT-U16 -- At any point, if a DataApdu invoked action (roiv-*) results in an error, the receiver sends -- back an ErrorResult. The invokeID is used to determine which invocation resulted in an -- error condition. The error-value shall be filled in with an error value from the RoerErrorValue list -- below. The parameter is filled in with further information if warranted by the error-value. The use of -- the parameter value is defined in the comments found in RoerErrorValue. ErrorResult ::= SEQUENCE { error-value RoerErrorValue, parameter ANY DEFINED BY error-value } -- All unassigned " RoerErrorValue " values are reserved for future expansion and shall not be used. -- Note that ISO/IEEE 11073-20101:2004 K defines a number of RoerErrorValue values that are not -- defined in this Standard. For consistency, numbering of the RoerErrorValue skips any value already -- defined in ISO/IEEE 11073-20101:2004. RoerErrorValue ::= INTEGER { -- no-such-object-instance is returned when referencing an illegal handle or when there -- is an attempt to access any object other than the MDS before the configuration -- is agreed, i.e., agent and manager are not in the operating state. no-such-object-instance(1), -- no-such-action is returned when the action command is illegal no-such-action(9), -- invalid-object-instance is returned when object exists but the command -- is illegal for that object type (e.g., Get on any object except MDS or PM-store) invalid-object-instance(17), -- protocol-violation is returned when there has been a protocol violation (e.g., APDU -- exceeds maximum size) protocol-violation(23), -- not-allowed-by-object is returned when an action is attempted on an object -- but the object did not allow the action -- The higher layer may report the reason for aborting the action as an OID-Type -- in the parameter field using a return code taken from the return code partition not-allowed-by-object(24), -- action-timed-out is returned when an action is aborted before completion or when to -- complete the action would exceed the currently defined timeout value. -- The higher layer may report the reason for aborting the action as an OID-Type -- in the parameter field using a return code taken from the return code partition action-timed-out(25), -- action-aborted is returned when an action has been aborted due to reasons in the -- higher layers (e.g., storage capacity exceeded). -- The higher layer may report the reason for aborting the action as an OID-Type -- in the parameter field using a return code taken from the return code partition action-aborted(26) } (0..65535) -- At any point, if a DataApdu invoked action (roiv-*) requires the receiver to reject an -- operation prior to attempting to execute it, the receiver shall send -- back a RejectResult. The invokeID is used to determine which invocation resulted in a -- rejection condition. The problem field shall be filled in with a value from the RorjProblem list -- below. RejectResult ::= SEQUENCE { problem RorjProblem } -- All unassigned " RorjProblem " values are reserved for future expansion and shall not be used. RorjProblem ::= INTEGER { -- unrecognized-apdu is returned if the DataApdu is unrecognized, unrecognized-apdu(0), -- badly-structured-apdu is returned when the receiver is unable to -- understand the DataApdu due to its structure (or lack thereof) -- (e.g., incorrect data lengths) badly-structured-apdu(2), -- unrecognized-operation is sent when the operation being requested -- is not understood by the receiver unrecognized-operation(101), -- resource-limitation is sent when the receiver cannot handle the -- message due to limited resources. resource-limitation(103), -- unexpected-error covers error conditions where there is not a -- more specific error code defined unexpected-error(303) } (0..65535) /* EVENT REPORT service */ -- For event reports defined in this Standard, obj-handle shall either be 0 to represent the MDS object -- or a handle representing a scanner or PM-store object. -- If the agent does not support RelativeTime (as indicated by the mds-time-capab-relative-time -- bit in MdsTimeCapState), it shall set the event-time to 0xFFFFFFFF. Managers shall -- ignore the event-time if the agent reports that it does not support RelativeTime. -- For the event-types defined in , , , and , the -- corresponding event-info structure shall be used. Accordingly, event-info will be one of -- ConfigReport, ScanReportInfoFixed, ScanReportInfoVar, ScanReportInfoMPFixed, -- ScanReportInfoMPVar, ScanReportInfoGrouped, ScanReportInfoMPGrouped, -- or SegmentDataEvent EventReportArgumentSimple ::= SEQUENCE { obj-handle HANDLE, event-time RelativeTime, event-type OID-Type, -- From the nom-part-obj partition -- Subpartition NOTI (MDC_NOTI_*) event-info ANY DEFINED BY event-type } -- For event reports defined in this Standard, obj-handle shall be either 0 to represent the MDS object -- or a handle representing a scanner or PM-store object. -- The event-type of the result shall be a copy of the event-type from the invocation. -- For the event-types defined in , , , and , the corresponding -- event-reply-info shall be used. Accordingly event-reply-info will be empty, ConfigReportRsp, -- or SegmentDataResult. EventReportResultSimple ::= SEQUENCE { obj-handle HANDLE, currentTime RelativeTime, event-type OID-Type, -- From the nom-part-obj partition -- Subpartition NOTI (MDC_NOTI_*) event-reply-info ANY DEFINED BY event-type } /* GET service */ -- For GET requests defined in this Standard, obj-handle shall either be 0 to represent the MDS object -- or a handle representing a PM-store object. -- The attribute-id-list shall be left empty to query for all attributes of the MDS or PM-store object. -- Alternatively, specific attributes of an object may be queried by listing the desired -- Attribute IDs found in or . GetArgumentSimple ::= SEQUENCE { obj-handle HANDLE, attribute-id-list AttributeIdList } -- For GET responses defined in this Standard, obj-handle shall match the one in the corresponding request. -- The attribute-list contains all the requested attributes using the variable format. -- If a requested attribute ID does not exist within the MDS object, it shall not -- be returned in the attribute-list. GetResultSimple ::= SEQUENCE { obj-handle HANDLE, attribute-list AttributeList } TypeVerList ::= SEQUENCE OF TypeVer -- Since the type shall come from ISO/IEEE 11073-10101 K, communication -- nom-part-infrastruct partition, subpartition DEVspec, a simple OID-Type is used rather -- than a TYPE. -- The individual IEEE 11073-104zz specializations define which specification is classified -- as version 1, 2, …, and so on; thus, version 3 may correspond to specification version 1.5. TypeVer ::= SEQUENCE { type OID-Type, version INT-U16 } /* SET service */ -- For SETs defined in this Standard, obj-handle shall be the value of a handle representing a scanner object. SetArgumentSimple ::= SEQUENCE { obj-handle HANDLE, modification-list ModificationList } ModificationList ::= SEQUENCE OF AttributeModEntry AttributeModEntry ::= SEQUENCE { modify-operator ModifyOperator, attribute AVA-Type } -- All unassigned " ModifyOperator " values are reserved for future expansion and shall not be used. ModifyOperator ::= INTEGER { replace(0), addValues(1), -- used for modifying the values contained in list-like data types removeValues(2), -- used for modifying the values contained in list-like data types setToDefault(3) } (0..65535) -- -- The obj-handle shall be set to the value received in the SetArgumentSimple. -- The attribute-list shall contain each attribute-id that was modified and return -- the new value of the attribute. Normally, this is the value from the Set -- command; however, it is possible that, due to rounding conditions or an -- error condition, the returned value could differ from the requested value. SetResultSimple ::= SEQUENCE { obj-handle HANDLE, attribute-list AttributeList } /* ACTION service */ -- For action requests defined in this Standard, obj-handle shall either be 0 to represent the MDS object or -- a handle representing a PM-store object. -- For the action-types defined in and , the corresponding action-info-args -- structures shall be used. Accordingly, action-info-args will be one of DataRequest, -- SetTimeInvoke, SetBOTimeInvoke, SegmSelection, or TrigSegmDataXferReq. ActionArgumentSimple ::= SEQUENCE { obj-handle HANDLE, action-type OID-Type, -- From the nom-part-obj partition -- Subpartition ACT (MDC_ACT_*) action-info-args ANY DEFINED BY action-type } -- For action responses defined in this Standard, obj-handle shall match the one in the -- corresponding request. -- The action-type shall be copied from the invocation message action-type. -- For the action-types defined in and , the resulting action-info-args -- shall be used. Accordingly, action-info-args will be empty, DataResponse, -- SegmentInfoList, or TrigSegmDataXferRsp. ActionResultSimple ::= SEQUENCE { obj-handle HANDLE, action-type OID-Type, -- From the nom-part-obj partition -- Subpartition ACT (MDC_ACT_*) action-info-args ANY DEFINED BY action-type } /* Data types for new object attributes and object services General data types */ AttrValMap ::= SEQUENCE OF AttrValMapEntry AttrValMapEntry ::= SEQUENCE { attribute-id OID-Type, -- This comes from the nom-part-obj partition attribute-len INT-U16 } MDS-related data types UuidIdent ::= OCTET STRING(SIZE(16)) -- time-sync-accuracy allows an agent to report how closely synchronized its clock is with -- respect to the clock sync master when time synchronization is used. MdsTimeInfo ::= SEQUENCE { mds-time-cap-state MdsTimeCapState, time-sync-protocol TimeProtocolId, -- this is a nomenclature code from -- nom-part-infrastruct partition time-sync-accuracy RelativeTime, -- 0xFFFFFFFF if unknown -- 0 if better than 1/8 ms time-resolution-abs-time INT-U16, -- if -- mds-time-capab-real-time-clock -- is set then this indicates the -- resolution of the agent’s -- absolute time clock. -- 0 if unknown; otherwise, -- the number of 1/100 s -- that elapse with each clock -- increment. For example, if an -- agent has a clock that clicks at -- 1 s intervals, this value -- would be 100. -- if mds-time-capab-bo-time -- is set then this indicates the -- resolution of the agent’s -- base time clock. -- 0 if unknown; otherwise, -- the number of 1/65536 s -- that elapse with each clock -- increment. The value of 0xFFFF -- is reserved to indicate an interval -- 1 s. time-resolution-rel-time INT-U16, -- Resolution of the agent’s -- relative time clock. 0 if -- unknown; otherwise, the number -- of 125 μs that elapse -- with each clock increment. For -- example, if an agent has a clock -- that clicks at 1 s intervals, -- this value would be 8000. time-resolution-high-res-time INT-U32 -- Resolution of the agent’s -- high-resolution time clock. -- 0 if unknown; otherwise, the -- number of microseconds -- that elapse with each clock -- increment. For example, if an -- agent has a clock that clicks -- at 1 s intervals, this value -- would be 1 000 000. } -- Only one of mds-time-capab-real-time-clock and mds-time-capab-bo-time shall be specified. -- Only one of mds-time-capab-sync-abs-time and mds-time-capab-sync-bo-time shall be specified. -- Only one of mds-time-state-abs-time-synced and mds-time-state-bo-time-synced shall be specified. -- All unassigned " MdsTimeCapState " bit values are reserved for future expansion and shall be set to zero. MdsTimeCapState ::= BITS-16 { mds-time-capab-real-time-clock(0), -- device supports an internal RTC -- following absolute time mds-time-capab-set-clock(1), -- device supports Set-Time Action -- or Set-Base-OffsetTime Action mds-time-capab-relative-time(2), -- device supports RelativeTime mds-time-capab-high-res-relative-time(3), -- device supports -- HighResRelativeTime mds-time-capab-sync-abs-time(4), -- device syncs AbsoluteTime mds-time-capab-sync-rel-time(5), -- device syncs RelativeTime mds-time-capab-sync-hi-res-relative-time(6), -- device syncs HiResRelativeTime mds-time-capab-bo-time(7), -- device supports BaseOffsetTime mds-time-state-abs-time-synced(8), -- AbsoluteTime is synced mds-time-state-rel-time-synced(9), -- RelativeTime is synced mds-time-state-hi-res-relative-time-synced(10), -- HiResRelativeTime is synced mds-time-mgr-set-time(11), -- manager shall set the time mds-time-capab-sync-bo-time(12), -- device syncs BaseOffsetTime mds-time-state-bo-time-synced(13), -- Base time is synced mds-time-state-bo-time-UTC-aligned(14) -- Base time is aligned to UTC } -- ************ -- A list of various regulatory and certification compliance items to which the agent claims adherence. -- ************ RegCertDataList ::= SEQUENCE OF RegCertData RegCertData ::= SEQUENCE { auth-body-and-struc-type AuthBodyAndStrucType, auth-body-data ANY DEFINED BY auth-body-and-struc-type } AuthBodyAndStrucType ::= SEQUENCE { auth-body AuthBody, auth-body-struc-type AuthBodyStrucType } -- All unassigned " AuthBody " values are reserved for future expansion and shall not be used. AuthBody ::= INTEGER { auth-body-empty(0), auth-body-ieee-11073(1), auth-body-continua(2), auth-body-experimental(254), auth-body-reserved(255) } (0..255) -- -- Some other possible/expected authoritative bodies -- auth-body-eu(), -- auth-body-ieee(), -- auth-body-iso(), -- auth-body-us-fda(), -- specific values will be assigned when a given authoritative body -- assigns its first AuthBodyStrucType for a specific -- auth-body-data. -- AuthBodyStrucType is controlled and assigned by the authoritative body AuthBodyStrucType ::= INT-U8 /* Metric-related data types */ -- -- SupplementalTypeList provides an extensible mechanism to list additional information about an object. -- This can hold information such as the location of the sensor or the responsiveness of the object. -- SupplementalTypeList ::= SEQUENCE OF TYPE -- -- The Metric Spec Small attribute is an abbreviated MetricSpec attribute as defined in ISO/IEEE -- 11073-10201:2004 K. It defines availability, periodicity, and category of the measurement. -- The setting of bits 0 to 5 is primarily informational and shall be set if the condition is true but -- a manager cannot assume that if they are set the behavior will be observed. -- All unassigned " MetricSpecSmall " bit values are reserved for future expansion and shall be set to zero. -- MetricSpecSmall ::= BITS-16 { mss-avail-intermittent(0), -- value is available only intermittently mss-avail-stored-data(1), -- Agent may store and send multiple historical -- values (e.g., a weighing scale stores up -- to 25 values) mss-upd-aperiodic(2), -- value is sent only aperiodically -- (e.g., when changed) mss-msmt-aperiodic(3), -- the measurement is aperiodic mss-msmt-phys-ev-id(4), -- the measurement is a physiological trigger only -- (e.g., to mark the detection of a heart beat) mss-msmt-btb-metric(5), -- the measurement is beat-to-beat or breath-to-breath mss-acc-manager-initiated (8), -- the object value can be accessed by manager- -- initiated measurement data transmission mss-acc-agent-initiated(9), -- the object value is updated using agent-initiated -- measurement data transmission -- NOTES regarding the usage of the following mss-cat-* bits -- For automatically acquired measurements, neither the mss-cat-setting nor the -- mss-cat-calculation bits are set. The metric represents a normal, regular measured -- value. This implies that, for automatically acquired measurements provided by an -- agent, none of the mss-cat-* bits are set (default). mss-cat-manual(12), -- if this bit is set, the metric is acquired manually -- (e.g., a person manually entered the value). -- If this bit is not set, the metric is acquired -- automatically (e.g., the device measures the value) mss-cat-setting(13), -- If this bit is set, the metric represents a device -- setting. This may be a manually or automatically -- set value, as reported by the mss-cat-manual bit. mss-cat-calculation(14) -- If this bit is set, the metric represents a calculated -- value. This may be a manually or automatically -- calculated value, as reported by the -- mss-cat-manual bit. Calculated values are -- derived from automatically acquired measurements -- and/or manually entered values. } -- This attribute is partly inherited from ISO/IEEE 11073-10201:2004 K, but enhanced by -- value ms-struct::ms-struct-compound-fix. For this release of the standard, ms-struct-compound -- and ms-struct-compound-fix shall only be used for Numeric objects. Additional structures would -- need to be introduced in RT-SA and Enumeration objects to allow the use of compound structures. -- If compound is used, the agent shall send no more than ms-comp-no observed values. -- MetricStructureSmall ::= SEQUENCE { ms-struct INTEGER { ms-struct-simple(0), ms-struct-compound(1), -- multiple observed values, -- same dynamic context ms-struct-reserved(2), -- for ISO/IEEE 11073-10201:2004 ms-struct-compound-fix(3) -- similar to compound(1) but the -- compound observed value array -- size shall not be dynamic -- during an association } (0..255), ms-comp-no INT-U8 -- maximum number of components/elements in -- compound observed value, 0 if ms-struct is set to -- ms-struct-simple } -- This attribute defines a list of MetricIds. -- MetricIdList ::= SEQUENCE OF OID-Type -- -- The EnumPrintableString is the data type to report Enumeration Observed Values in the form of -- ASCII printable strings. -- EnumPrintableString ::= OCTET STRING -- string size shall be even PersonId ::= INTEGER { unknown-person-id(65535) -- 0xFFFF } (0..65535) /* Scanner-related data types */ HandleAttrValMap ::= SEQUENCE OF HandleAttrValMapEntry HandleAttrValMapEntry ::= SEQUENCE { obj-handle HANDLE, attr-val-map AttrValMap } HANDLEList ::= SEQUENCE OF HANDLE /* MDS services */ -- The following definitions support the above definitions of EventReportArgumentSimple -- and ActionArgumentSimple. -- -- The Scan Report Info types are utilized as the result data types for the various -- MDS-Dynamic-Data-Update* family of events (see for more detail). -- -- The ScanReport* definitions are used when reporting information about object attribute value -- changes (Attribute Change Sets). There are two vectors: A) single person or multiple person and B) variable format, -- fixed format, or grouped format. Combinations of these vectors lead to the six top-level definitions: -- ScanReportInfoVar, ScanReportInfoFixed, ScanReportInfoGrouped, -- ScanReportInfoMPVar, ScanReportInfoMPFixed, and ScanReportInfoMPGrouped. -- The SEQUENCE OF ObservationScan or ObservationScanFixed may contain multiple instances -- of the same handle as long as there is a time stamp to distinguish between the instances. -- In all cases, scan-report-no shall be initialized to zero at association time and monotonically -- increasing by one until roll-over occurs. ------------------------------------------------------------------------------------------------------------------------ ScanReportInfoVar ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports obs-scan-var SEQUENCE OF ObservationScan } ------------------------------------------------------------------------------------------------------------------------ ScanReportInfoFixed ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports obs-scan-fixed SEQUENCE OF ObservationScanFixed } ObservationScanFixed ::= SEQUENCE { obj-handle HANDLE, -- unique identification of the object obs-val-data OCTET STRING -- observed value data defined by obj-handle } ------------------------------------------------------------------------------------------------------------------------ -- obs-scan-grouped is a SEQUENCE OF so episodic measurements can combine more than -- one report into a single scan report. Periodic reports should not need to place more than one -- report in a single ScanReport. ScanReportInfoGrouped ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports obs-scan-grouped SEQUENCE OF ObservationScanGrouped } ObservationScanGrouped ::= OCTET STRING -- The format is defined by HandleAttrValMap ------------------------------------------------------------------------------------------------------------------------ ScanReportInfoMPVar ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports scan-per-var SEQUENCE OF ScanReportPerVar } DataReqId ::= INTEGER { data-req-id-manager-initiated-min(0), -- 0x0000 data-req-id-manager-initiated-max(61439), -- 0xEFFF -- Values between data-req-id-manager-initiated-min and -- data-req-id-manager-initiated-max, inclusive, shall be used in -- manager-initiated measurement data transmission. -- data-req-id-agent-initiated(61440) -- 0xF000 -- data-req-id-agent-initiated shall be used in agent-initiated measurement -- data transmission. -- -- Values between 0xF001 and 0xFFFF, inclusive, are reserved. } (0..65535) -- -- The value used for person-id is vendor determined (e.g., if an agent has two buttons -- to distinguish between two people, the agent may use ID 1 and 2 or ID 35 and 97). -- The process of mapping this ID to a specific person is outside the scope of this -- Standard. -- ScanReportPerVar ::= SEQUENCE { person-id PersonId, obs-scan-var SEQUENCE OF ObservationScan } ------------------------------------------------------------------------------------------------------------------------ ScanReportInfoMPFixed ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports scan-per-fixed SEQUENCE OF ScanReportPerFixed } ScanReportPerFixed ::= SEQUENCE { person-id PersonId, obs-scan-fixed SEQUENCE OF ObservationScanFixed } ------------------------------------------------------------------------------------------------------------------------ ScanReportInfoMPGrouped ::= SEQUENCE { data-req-id DataReqId, scan-report-no INT-U16, -- counter for detection of missing scan reports scan-per-grouped SEQUENCE OF ScanReportPerGrouped } ScanReportPerGrouped ::= SEQUENCE { person-id PersonId, obs-scan-grouped ObservationScanGrouped } ------------------------------------------------------------------------------------------------------------------------ -- The ConfigReport definition is used when reporting an agent’s configuration to a manager (see -- ) ConfigReport ::= SEQUENCE { config-report-id ConfigId, config-obj-list ConfigObjectList } ConfigObjectList ::= SEQUENCE OF ConfigObject ConfigObject ::= SEQUENCE { obj-class OID-Type, -- From the nom-part-obj partition -- Subpartition MOC/BASE (MDC_MOC_VMD_*) obj-handle HANDLE, attributes AttributeList } ConfigReportRsp ::= SEQUENCE { config-report-id ConfigId, config-result ConfigResult } -- All unassigned " ConfigResult " values are reserved for future expansion and shall not be used. ConfigResult ::= INTEGER { accepted-config(0), unsupported-config(1), standard-config-unknown(2) } (0..65535) DataRequest ::= SEQUENCE { data-req-id DataReqId, -- Allows differentiation of -- responses for multiple data -- requests (if the -- device allows for multiple -- simultaneous data requests). -- Mirrored back in -- ScanReportInfo* data-req-id data-req-mode DataReqMode, -- Defines the mode by setting one -- or more bits. data-req-time RelativeTime, -- Tells how long the agent is -- allowed to transmit data. -- This is used only for -- data-req-mode-time-period. data-req-person-id INT-U16, -- 0xFFFF all persons available data-req-class OID-Type, -- From the nom-part-obj partition -- Subpartition MOC/BASE -- (MDC_MOC_VMD_*) data-req-obj-handle-list HANDLEList } -- All unassigned " DataReqMode " bit values are reserved for future expansion and shall be set to zero. DataReqMode ::= BITS-16 { data-req-start-stop(0), -- start data request: 1 | stop data request: 0 data-req-continuation(1), -- continuation of a timed data request. -- Set to 1 to extend the time allocated to a data -- transfer. If this is set to 1, all other bits shall -- be ignored, and the settings from the initial -- start command shall be used. -- exactly one of the following data-req-scope-* bits shall be set data-req-scope-all(4), data-req-scope-class(5), data-req-scope-handle(6), -- exactly one of the following data-req-mode-* bits shall be set data-req-mode-single-rsp(8), -- response is directly embedded in DataResponse data-req-mode-time-period(9), -- time limited data request with -- responses as event reports. The time period -- is specified in data-req-time in DataRequest. data-req-mode-time-no-limit(10), -- time unlimited data request with -- responses as event reports data-req-person-id(12) } DataReqModeCapab ::= SEQUENCE { data-req-mode-flags DataReqModeFlags, data-req-init-agent-count INT-U8, -- maximum number of parallel agent initiated -- data requests/ flows. Shall currently be -- set only to 0 or 1. data-req-init-manager-count INT-U8 -- maximum number of parallel manager -- initiated data requests } -- All unassigned " DataReqModeFlags " bit values are reserved for future expansion and -- shall be set to zero. DataReqModeFlags ::= BITS-16 { -- this field is used in the association to flag -- data request capabilities data-req-supp-stop(0), -- supports stopping a running data request data-req-supp-scope-all(4), -- supports requesting all objects data-req-supp-scope-class(5), -- supports requesting objects based on object class data-req-supp-scope-handle(6), -- supports requesting objects based on object handle data-req-supp-mode-single-rsp(8), -- supports single response data-req-supp-mode-time-period(9), -- supports time limited data request data-req-supp-mode-time-no-limit(10), -- supports time unlimited data request data-req-supp-person-id(11), data-req-supp-init-agent(15) -- agent uses agent-initiated data requests/flows } -- DataResponse is returned as a result of an MDS-Data-Request (see ). However, the event-type -- and event-info fields are filled in using the same parameters as found in MDS object events. See -- for the legal event-type values and the corresponding event-info -- structure; however, for this usage, ConfigReport shall not be used. Thus, event-info is -- one of ScanReportInfoFixed, ScanReportInfoVar, ScanReportInfoMPFixed, or ScanReportInfoMPVar. DataResponse ::= SEQUENCE { rel-time-stamp RelativeTime, -- set to 0xFFFFFFFF if RelativeTime not supported data-req-result DataReqResult, event-type OID-Type, -- event-type and event-info are only -- in case of data-req-mode-single-rsp, -- otherwise event-type shall be 0 and -- event-info.length = 0 -- From the nom-part-obj partition -- Subpartition NOTI (MDC_NOTI_*) event-info ANY DEFINED BY event-type } -- The values in DataReqResult are used in a DataResponse data-req-result field. This is returned -- in response to a DataRequest. The agent shall return data-req-result-no-error if the request -- was successful. Otherwise, one of the defined errors shall be returned. -- All unassigned " DataReqResult " values are reserved for future expansion and shall not be used. DataReqResult ::= INTEGER { data-req-result-no-error(0), data-req-result-unspecific-error(1), -- The following error codes are returned when the manager request contains -- a DataReqMode that is not supported by the agent. data-req-result-no-stop-support(2), data-req-result-no-scope-all-support(3), data-req-result-no-scope-class-support(4), data-req-result-no-scope-handle-support(5), data-req-result-no-mode-single-rsp-support(6), data-req-result-no-mode-time-period-support(7), data-req-result-no-mode-time-no-limit-support(8), data-req-result-no-person-id-support(9), -- The following error codes are returned when the manager request contains -- unknown values in the supporting fields (e.g., data-req-person-id). data-req-result-unknown-person-id(11), data-req-result-unknown-class(12), data-req-result-unknown-handle(13), -- The following note a condition where the manager set more than one of the -- scope or mode bits. data-req-result-unsupp-scope(14), -- unsupported scope bits set data-req-result-unsupp-mode(15), -- unsupported mode bits set data-req-result-init-manager-overflow(16), -- manager has tried to establish more than -- data-req-init-manager-count flows data-req-result-continuation-not-supported(17), -- manager has attempted to continue -- a data transfer that is not running in -- timed mode data-req-result-invalid-req-id(18) -- manager has attempted to continue -- a data transfer on a nonexistent -- data-req-id. } (0..65535) /* Scanner services See A.11.5 for MDS services type definitions that are reused for the scanner services, namely ScanReportInfoVar ScanReportInfoFixed ScanReportInfoGrouped ScanReportInfoMPVar ScanReportInfoMPFixed ScanReportInfoMPGrouped Numeric related data types */ -- A simple numeric observed value is represented just by the floating point value. -- SimpleNuObsValue ::= FLOAT-Type -- A list type of SimpleNuObsValue -- SimpleNuObsValueCmp ::= SEQUENCE OF SimpleNuObsValue -- In many cases, the basic numeric observed value can be expressed with a smaller floating point value. -- BasicNuObsValue ::= SFLOAT-Type -- A list type of BasicNuObsValue -- BasicNuObsValueCmp ::= SEQUENCE OF BasicNuObsValue /* PM-store and PM-segment related data types */ -- -- The PM-Store-Capab attribute defines specific static capabilities and properties of the PM-store object -- instance. The default value of this attribute is 0 (no bits set). -- All unassigned " PmStoreCapab " bit values are reserved for future expansion and shall be set to zero. -- PmStoreCapab ::=BITS-16 { pmsc-var-no-of-segm(0), -- indicates that the number of PM-segments -- contained in this PM-store is dynamic and may -- change pmsc-segm-id-list-select(3), -- PM-segments in the SegmSelection data type can -- be selected by defining a list of segment -- identifiers pmsc-epi-seg-entries(4), -- Some/ all PM-segments contain -- episodic/aperiodic entries and therefore have -- to contain explicit time stamp information pmsc-peri-seg-entries(5), -- Some/all PM-segments contain periodically -- sampled entries and therefore the PM-segment -- or PM-store shall support the -- Sample-Period attribute pmsc-abs-time-select(6), -- PM-segments in the SegmSelection data type can -- be selected by defining an abs-time-range range or -- bo-time-range depending upon which time -- mode the device supports pmsc-clear-segm-by-list-sup(7), -- clearing a list of segments is supported pmsc-clear-segm-by-time-sup(8), -- clearing segments by abs time range or -- bo time range is supported depending -- upon which time mode the device supports pmsc-clear-segm-remove(9), -- if this bit is set, the agent will completely remove -- the specified PM-segment instance as part of the -- Clear-Segment method. If this bit is not set, it will -- just remove all entries from the specified -- PM-segment. pmsc-clear-segm-all-sup(10), -- clearing all segments is supported pmsc-multi-person(12) -- The PM-store supports PM-segment for more -- than one person } -- -- All entries in the segment shall follow the format defined by this attribute. First, the optional header -- shall follow the description in segm-entry-header. This allows each entry in the segment to be preceded -- by an optional header (e.g., for time stamp information) that is applicable to all elements in an entry. -- Next, the elements shall follow the format and order described in segm-entry-elem-list. -- An element typically represents a measurement. For each element, the stored data is defined in the form -- of an attribute value map, in the same way as metric objects. -- PmSegmentEntryMap ::= SEQUENCE { segm-entry-header SegmEntryHeader, -- defines optional elements in front -- of each entry segm-entry-elem-list SegmEntryElemList } -- -- The following bit string defines optional data items that are in front of each segment entry. -- Multiple data items are definable. In this case, the data item with the lower bit number shall come -- in front of items with higher bit numbers. The header allows definition of data items that are common -- to all elements in the entry. If all bits are zero, the segment entry event report shall begin with data -- from the first element. -- All unassigned " SegmEntryHeader " bit values are reserved for future expansion and shall be set to zero. -- If any bits are set to one beyond the expected bits (e.g., a new bit was added in a later version), -- the data shall not be retrieved since the offset to the first data element cannot be calculated. -- SegmEntryHeader ::= BITS-16 { seg-elem-hdr-absolute-time(0), -- entry preceded by absolute time -- (data type AbsoluteTime) seg-elem-hdr-relative-time(1), -- entry preceded by relative time -- (data type RelativeTime) seg-elem-hdr-hires-relative-time(2), -- entry preceded by high resolution relative time -- (data type HighResRelativeTime) seg-elem-hdr-bo-time(3) -- entry preceded by base offset time -- (data type BaseOffsetTime) -- option (0) and option (3) are mutually exclusive } SegmEntryElemList ::= SEQUENCE OF SegmEntryElem -- -- SegmEntryElem shall reference a metric object instance in the agent configuration -- using its handle value. This referenced object shall exist in the agent -- configuration, and the metric-type and class-id shall be equal to the corresponding attributes of the -- referenced metric object. -- SegmEntryElem ::= SEQUENCE { class-id OID-Type, -- contains nomenclature code from OO nom-part-obj -- partition defining the object class (e.g., numeric) metric-type TYPE, --specific static TYPE of the stored element handle HANDLE, -- handle of referenced object attr-val-map AttrValMap -- attribute value map describing the stored data } -- -- Request to start the transfer of the specified segment -- TrigSegmDataXferReq ::= SEQUENCE { seg-inst-no InstNumber } TrigSegmDataXferRsp ::= SEQUENCE { seg-inst-no InstNumber, trig-segm-xfer-rsp TrigSegmXferRsp } -- All unassigned " TrigSegmXferRsp " values are reserved for future expansion and shall not be used. TrigSegmXferRsp ::= INTEGER { tsxr-successful(0), -- Agent will start transfer of segment tsxr-fail-no-such-segment(1), -- segment ID not found tsxr-fail-clear-in-process(2), -- the storage media is currently being cleared. No -- access is currently possible. tsxr-fail-segm-empty(3), -- the segment being requested is empty tsxr-fail-not-otherwise-specified(512) } (0..65535) -- -- the SegmentDataEvent -- -- Notes: -- - the agent shall transfer all segment entries in order, first entry first (first in first out). -- SegmentDataEvent ::= SEQUENCE { segm-data-event-descr SegmDataEventDescr, segm-data-event-entries OCTET STRING -- contains the specified segment -- entries in an opaque data structure. -- Only complete entries shall be -- included in this field. } SegmentDataResult ::= SEQUENCE { segm-data-event-descr SegmDataEventDescr } -- -- The Segment Data Event Descriptor defines which entries of the Segment Data are communicated in the -- Event message. -- SegmDataEventDescr ::= SEQUENCE { segm-instance InstNumber, -- instance number of segment being transferred segm-evt-entry-index INT-U32, -- array index of the first entry in this event segm-evt-entry-count INT-U32, -- count of entries in this event segm-evt-status SegmEvtStatus } -- All unassigned " SegmEvtStatus " bit values are reserved for future expansion and shall be set to zero. SegmEvtStatus ::= BITS-16 { sevtsta-first-entry(0), -- this event contains the first segment entry sevtsta-last-entry(1), -- this event contains the last segment entry (both first -- and last bits can be set if all entries fit in one event) sevtsta-agent-abort(4), -- transfer aborted by agent (manager shall reply -- with the same status) sevtsta-manager-confirm(8), -- set in reply if segment was received correctly (if -- not set in reply, agent shall stop the segment -- transfer and respond with an error (roer) code -- of protocol-violation). sevtsta-manager-abort(12) -- sent in reply by manager (agent shall stop sending -- messages) } SegmentStatistics ::= SEQUENCE OF SegmentStatisticEntry SegmentStatisticEntry ::= SEQUENCE { segm-stat-type SegmStatType, segm-stat-entry OCTET STRING -- this attribute contains one segment entry in the -- format defined by the PmSegmentEntryMap } -- All unassigned " SegmStatType " values are reserved for future expansion and shall not be used. -- Values from 0xF000 to 0xFFFF are reserved for manufacturer-specific extensions. SegmStatType ::= INTEGER { segm-stat-type-undefined (0), segm-stat-type-minimum(1), segm-stat-type-maximum(2), segm-stat-type-average(3) } (0..65535) END biosig-2.3.3/biosig4c++/t241/Makefile0000664000175000017500000002211314105434245017143 0ustar schloeglschloeglASN_MODULE_SOURCES= \ Address.c \ MetricMeasure.c \ UnitCode.c \ HealthCareProviderId.c \ INT-U64.c \ INT-I64.c \ INT-U32.c \ INT-I32.c \ INT-U16.c \ INT-I16.c \ INT-U8.c \ INT-I8.c \ BITS-32.c \ BITS-16.c \ BITS-8.c \ FEFString.c \ FEFFloat.c \ Fraction.c \ AbsoluteRange.c \ Handle.c \ HandleRef.c \ DeviceCode.c \ UnitsOfMeasurementCode.c \ MetricsCode.c \ BodySiteCode.c \ AlertCode.c \ ExtNomenclatureCode.c \ ParameterGroupCode.c \ PrivateCode.c \ Placeholder.c \ ManufacturerID.c \ AbsoluteTime.c \ RelativeTime.c \ HighResRelativeTime.c \ ObservationTime.c \ SimpleColour.c \ ExtNomenRef.c \ PersonNameGroup.c \ PersonName.c \ OID-Type.c \ SessionArchiveSection.c \ ArchiveProtection.c \ ManufacturerSpecificSection.c \ ManufacturerSpecificEncoded.c \ ManufacturerSpecificBinary.c \ HealthCareProviderSection.c \ HealthCareProfessionalSection.c \ Authorization.c \ PatientDemographicsSection.c \ PatMeasure.c \ PatientSex.c \ PatientType.c \ PatientRace.c \ SessionTestSection.c \ MedicalDeviceSystemSection.c \ SystemModel.c \ SystemSpecEntry.c \ ProdSpecEntryType.c \ ProdSpecEntry.c \ ApplicationArea.c \ PowerStatus.c \ LineFrequency.c \ MedicalDeviceComponents.c \ VirtualMedicalDeviceSection.c \ MsmtPrinciple.c \ ChannelDescriptionSection.c \ ChannelStatus.c \ MultimediaSection.c \ Comments.c \ ContentOrReference.c \ SessionPhaseSection.c \ DescriptiveDataSection.c \ MetricDescriptiveDataSection.c \ MetricStatus.c \ MetricCategory.c \ MetricCalEntry.c \ MetricCalType.c \ MetricCalState.c \ MeasurementStatus.c \ SampleArrayDescriptiveDataSection.c \ SaSpec.c \ StorageDataType.c \ SaFlags.c \ ScaleRangeSpec.c \ SaFilterEntry.c \ FilterType.c \ SaGridEntry.c \ SaCalData.c \ SaCalDataType.c \ SaSignalFrequency.c \ RealTimeSampleArrayDescriptiveDataSection.c \ TimeSampleArrayDescriptiveDataSection.c \ DistributionSampleArrayDescriptiveDataSection.c \ DsaRangeSpec.c \ NumericDescriptiveDataSection.c \ EnumerationDescriptiveDataSection.c \ MeasuredDataSection.c \ SampleArrayMeasuredDataSection.c \ SampleArrayMeasuredDataBlock.c \ RealTimeSampleArrayMeasuredDataSection.c \ TimeSampleArrayMeasuredDataSection.c \ MarkerEntryRelTim.c \ DistributionSampleArrayMeasuredDataSection.c \ NumericMeasuredDataSection.c \ ChoiceOfNuObsValue.c \ NuObsValue.c \ DispResolution.c \ EnumerationMeasuredDataSection.c \ ChoiceOfEnumObsValue.c \ EnumObsValue.c \ EnumVal.c \ EnumObject.c \ EnumRecordMetric.c \ EnumRecordOO.c \ ChoiceOfEnumTimeStamp.c \ AlertSection.c \ AlertCondition.c \ AlertControls.c \ AlertFlags.c \ AlertType.c \ LimitSpecEntry.c \ CurLimAlStat.c \ DynamicAttributeChangeSection.c \ SessionNotesSection.c ASN_MODULE_HEADERS= \ Address.h \ MetricMeasure.h \ UnitCode.h \ HealthCareProviderId.h \ INT-U64.h \ INT-I64.h \ INT-U32.h \ INT-I32.h \ INT-U16.h \ INT-I16.h \ INT-U8.h \ INT-I8.h \ BITS-32.h \ BITS-16.h \ BITS-8.h \ FEFString.h \ FEFFloat.h \ Fraction.h \ AbsoluteRange.h \ Handle.h \ HandleRef.h \ DeviceCode.h \ UnitsOfMeasurementCode.h \ MetricsCode.h \ BodySiteCode.h \ AlertCode.h \ ExtNomenclatureCode.h \ ParameterGroupCode.h \ PrivateCode.h \ Placeholder.h \ ManufacturerID.h \ AbsoluteTime.h \ RelativeTime.h \ HighResRelativeTime.h \ ObservationTime.h \ SimpleColour.h \ ExtNomenRef.h \ PersonNameGroup.h \ PersonName.h \ OID-Type.h \ SessionArchiveSection.h \ ArchiveProtection.h \ ManufacturerSpecificSection.h \ ManufacturerSpecificEncoded.h \ ManufacturerSpecificBinary.h \ HealthCareProviderSection.h \ HealthCareProfessionalSection.h \ Authorization.h \ PatientDemographicsSection.h \ PatMeasure.h \ PatientSex.h \ PatientType.h \ PatientRace.h \ SessionTestSection.h \ MedicalDeviceSystemSection.h \ SystemModel.h \ SystemSpecEntry.h \ ProdSpecEntryType.h \ ProdSpecEntry.h \ ApplicationArea.h \ PowerStatus.h \ LineFrequency.h \ MedicalDeviceComponents.h \ VirtualMedicalDeviceSection.h \ MsmtPrinciple.h \ ChannelDescriptionSection.h \ ChannelStatus.h \ MultimediaSection.h \ Comments.h \ ContentOrReference.h \ SessionPhaseSection.h \ DescriptiveDataSection.h \ MetricDescriptiveDataSection.h \ MetricStatus.h \ MetricCategory.h \ MetricCalEntry.h \ MetricCalType.h \ MetricCalState.h \ MeasurementStatus.h \ SampleArrayDescriptiveDataSection.h \ SaSpec.h \ StorageDataType.h \ SaFlags.h \ ScaleRangeSpec.h \ SaFilterEntry.h \ FilterType.h \ SaGridEntry.h \ SaCalData.h \ SaCalDataType.h \ SaSignalFrequency.h \ RealTimeSampleArrayDescriptiveDataSection.h \ TimeSampleArrayDescriptiveDataSection.h \ DistributionSampleArrayDescriptiveDataSection.h \ DsaRangeSpec.h \ NumericDescriptiveDataSection.h \ EnumerationDescriptiveDataSection.h \ MeasuredDataSection.h \ SampleArrayMeasuredDataSection.h \ SampleArrayMeasuredDataBlock.h \ RealTimeSampleArrayMeasuredDataSection.h \ TimeSampleArrayMeasuredDataSection.h \ MarkerEntryRelTim.h \ DistributionSampleArrayMeasuredDataSection.h \ NumericMeasuredDataSection.h \ ChoiceOfNuObsValue.h \ NuObsValue.h \ DispResolution.h \ EnumerationMeasuredDataSection.h \ ChoiceOfEnumObsValue.h \ EnumObsValue.h \ EnumVal.h \ EnumObject.h \ EnumRecordMetric.h \ EnumRecordOO.h \ ChoiceOfEnumTimeStamp.h \ AlertSection.h \ AlertCondition.h \ AlertControls.h \ AlertFlags.h \ AlertType.h \ LimitSpecEntry.h \ CurLimAlStat.h \ DynamicAttributeChangeSection.h \ SessionNotesSection.h ASN_MODULE_HEADERS+=ANY.h ASN_MODULE_SOURCES+=ANY.c ASN_MODULE_HEADERS+=UTF8String.h ASN_MODULE_HEADERS+=INTEGER.h ASN_MODULE_HEADERS+=NativeEnumerated.h ASN_MODULE_HEADERS+=GeneralizedTime.h ASN_MODULE_SOURCES+=GeneralizedTime.c ASN_MODULE_SOURCES+=INTEGER.c ASN_MODULE_SOURCES+=NativeEnumerated.c ASN_MODULE_HEADERS+=NativeInteger.h ASN_MODULE_SOURCES+=NativeInteger.c ASN_MODULE_HEADERS+=REAL.h ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.c ASN_MODULE_SOURCES+=REAL.c ASN_MODULE_SOURCES+=UTF8String.c ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c ASN_MODULE_HEADERS+=asn_SET_OF.h ASN_MODULE_SOURCES+=asn_SET_OF.c ASN_MODULE_HEADERS+=constr_CHOICE.h ASN_MODULE_SOURCES+=constr_CHOICE.c ASN_MODULE_HEADERS+=constr_SEQUENCE.h ASN_MODULE_SOURCES+=constr_SEQUENCE.c ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c ASN_MODULE_HEADERS+=constr_SET_OF.h ASN_MODULE_SOURCES+=constr_SET_OF.c ASN_MODULE_HEADERS+=asn_application.h ASN_MODULE_HEADERS+=asn_system.h ASN_MODULE_HEADERS+=asn_codecs.h ASN_MODULE_HEADERS+=asn_internal.h ASN_MODULE_HEADERS+=OCTET_STRING.h ASN_MODULE_SOURCES+=OCTET_STRING.c ASN_MODULE_HEADERS+=BIT_STRING.h ASN_MODULE_SOURCES+=BIT_STRING.c ASN_MODULE_SOURCES+=asn_codecs_prim.c ASN_MODULE_HEADERS+=asn_codecs_prim.h ASN_MODULE_HEADERS+=ber_tlv_length.h ASN_MODULE_SOURCES+=ber_tlv_length.c ASN_MODULE_HEADERS+=ber_tlv_tag.h ASN_MODULE_SOURCES+=ber_tlv_tag.c ASN_MODULE_HEADERS+=ber_decoder.h ASN_MODULE_SOURCES+=ber_decoder.c ASN_MODULE_HEADERS+=der_encoder.h ASN_MODULE_SOURCES+=der_encoder.c ASN_MODULE_HEADERS+=constr_TYPE.h ASN_MODULE_SOURCES+=constr_TYPE.c ASN_MODULE_HEADERS+=constraints.h ASN_MODULE_SOURCES+=constraints.c ASN_MODULE_HEADERS+=xer_support.h ASN_MODULE_SOURCES+=xer_support.c ASN_MODULE_HEADERS+=xer_decoder.h ASN_MODULE_SOURCES+=xer_decoder.c ASN_MODULE_HEADERS+=xer_encoder.h ASN_MODULE_SOURCES+=xer_encoder.c ASN_MODULE_HEADERS+=per_support.h ASN_MODULE_SOURCES+=per_support.c ASN_MODULE_HEADERS+=per_decoder.h ASN_MODULE_SOURCES+=per_decoder.c ASN_MODULE_HEADERS+=per_encoder.h ASN_MODULE_SOURCES+=per_encoder.c #ASN_CONVERTER_SOURCES+=converter-sample.c lib_LTLIBRARIES=libsomething.la libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS) # This file may be used as an input for make(3) # Remove the lines below to convert it into a pure .am file TARGET = libfef.a ../win32/libfef.a ../win32/libfef.dll CFLAGS += -pipe -fPIC -Wall -O2 -Wextra -I. OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o} WINOBJS=${ASN_MODULE_SOURCES:.c=.obj} ${ASN_CONVERTER_SOURCES:.c=.obj} AR = ar crs MinGWCC = i586-mingw32msvc-gcc all: $(TARGET) #$(TARGET): ${OBJS} # $(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS) libfef.a: $(OBJS) $(AR) libfef.a $(OBJS) ../win32/libfef.a: $(WINOBJS) i586-mingw32msvc-$(AR) ../win32/libfef.a $(WINOBJS) #../win32/libfef.a: $(WINOBJS) # i586-mingw32msvc-$(AR) ../win32/libfef.a $(WINOBJS) ../win32/libfef.dll: $(WINOBJS) $(MinGWCC) -shared -fPIC $(WINOBJS) -Wl,--output-def,../win32/libfef.def,--out-implib,../win32/libfef.dll .SUFFIXES: .SUFFIXES: .c .o %.obj: %.c $(MinGWCC) $(CFLAGS) -o $@ -c $< .c.o: $(CC) $(CFLAGS) -o $@ -c $< clean: rm -f $(ASN_MODULE_HEADERS) rm -f $(ASN_MODULE_SOURCES) rm -f $(TARGET) rm -f $(OBJS) rm -f $(WINOBJS) rm -f Makefile.am.sample libfef.a regen: regenerate-from-asn1-source regenerate-from-asn1-source: -asn1c -fcompound-names CENTS14271-2003.asn1 -asn1c -fcompound-names ISO11073-10404.asn1 -asn1c -fcompound-names ISO11073-10417.asn1 -asn1c -fcompound-names ISO11073-10471.asn1 -asn1c -fcompound-names ISO11073-20601.asn1 rm -f converter-sample.c Makefile.am.sample libfef.a biosig-2.3.3/biosig4c++/t241/ISO11073-10471.asn10000664000175000017500000001754714105434233020003 0ustar schloeglschloegl/* ASN.1 specification of IEEE Std 11073-10471-2008 Health Informatics—Personal health device communication Part 10471: Device specialization—Independent living activity hub The info was manually extracted. $Id$ Copyright (C) 2009 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ ModuleTest DEFINITIONS ::= BEGIN -- All unassigned "SensorHealthFlags" bit values are reserved for future expansion and -- shall be reset. -- Zero or more flags may be set. SensorHealthFlags ::= BIT STRING { -- this field is used in the activity data events -- to report sensor health auto-presence-received(16), -- For sensors that have “heartbeat†operational status: -- indicates that the “heartbeat†has been seen and is ok. -- This flag may not be set if auto-presence-failed is set. auto-presence-failed(17), -- For sensors that have “heartbeat†operational status: -- indicates that the “heartbeat†has not been seen as expected. -- This flag may not be set if auto-presence-received is set. low-battery(18), -- Indicates the sensor is in the low battery condition. -- This determination is unique to the sensor. fault(19), -- Indicates that the sensor is in a fault condition and needs attention. -- This determination is unique to the sensor. end-of-life(20) -- Indicates that the sensor has reached end of life. -- This indication is unique to the sensor. } (SIZE(32)) -- All unassigned "FallSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. FallSensorFlags::= BIT STRING { -- this field is used in the fall sensor activity data events fall-detected(0) -- indicates that a fall has been detected } (SIZE(32)) -- All unassigned "PersSensorFlags" bit values are reserved for future expansion and -- shall be reset . -- Only one flag can be set at a time. PersSensorFlags::= BIT STRING { -- this field is used in the PERS sensor activity data events pers-activated(0) -- indicates that a PERS event has been detected } (SIZE(32)) -- All unassigned "EnvironmentalSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. EnvironmentalSensorFlags::= BIT STRING {-- this field is used in the environmental sensor activity data events condition-detected(0) -- indicates that an environmental event has been detected }(SIZE(32)) -- All unassigned "MotionSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one motion flag can be set at a time. -- The tamper flag may be additionally set at any time. MotionSensorFlags::= BIT STRING { -- this field is used in the motion sensor activity data events motion-detected(0), -- indicates that a motion event has been detected motion-detected-delayed(1), -- indicates that a motion with delay event has been -- detected tamper-detected(2) -- indicates that a tamper event has been detected } (SIZE(32)) -- All unassigned "PropertyExitSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. PropertyExitSensorFlags::= BIT STRING {-- this field is used in the property exit sensor activity data events occupant-exit-property(0), -- indicates that an occupant exit event has been detected exit-door-left-open(1) -- indicates that an exit door left open event has been detected } (SIZE(32)) -- All unassigned "EnuresisSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. EnuresisSensorFlags::= BIT STRING {-- this field is used in the enuresis sensor activity data events enuresis-detected(0) -- indicates that an enuresis event has been detected } (SIZE(32)) -- All unassigned "ContactClosureSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. ContactClosureSensorFlags::= BIT STRING {-- this field is used in the door use sensor activity data events contact-opened(0), -- indicates that a door open event has been detected contact-closed(1) -- indicates that a door close event has been detected } (SIZE(32)) -- All unassigned "UsageSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. UsageSensorFlags::= BIT STRING {-- this field is used in the usage sensor (bed/chair) activity data events usage-started(0), -- indicates that a usage started event has been detected usage-ended(1), -- indicates that a usage ended event has been detected expected-use-start-violation(2), -- indicates that an expected use start violation event -- has been detected expected-use-stop-violation(3), -- indicates that an expected use stop violation event -- has been detected absence-violation(4) -- indicates that an absence violation event has been detected } (SIZE(32)) -- All unassigned "SwitchSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. SwitchSensorFlags::= BIT STRING { -- this field is used in the switch sensor activity data events switch-on(0), -- indicates that a switch on event has been detected switch-off(1) -- indicates that a switch off event has been detected } (SIZE(32)) -- All unassigned "MedDosageSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. MedDosageSensorFlags::= BIT STRING {-- this field is used in the dosage sensor activity data events dosage-taken(0), -- indicates the med dosage was taken dosage-missed(1) -- indicates the med dosage was not taken when expected } (SIZE(32)) -- All unassigned "TemperatureSensorFlags" bit values are reserved for future expansion and -- shall be reset. -- Only one flag can be set at a time. TemperatureSensorFlags::= BIT STRING {-- this field is used in the temperature sensor activity data events high-temperature-detected(0), -- indicates that a high temperature event has been detected low-temperature-detected(1), -- indicates that a low temperature event has been detected rate-of-change-too-fast(2) -- indicates that a rate of change too fast event -- has been detected } (SIZE(32)) --All unassigned “StatusFlags†bit values are reserved for future expansion and shall be reset. --One or more flags may be set. StatusFlags ::=BIT STRING { -- this field is used to report medication monitor exceptions not-dispensed-as-expected(0), --a medication dosage was not dispensed within the --regimen allowed timing dispensed-unexpectedly(1), --a medication was dispensed outside the regimen allowed --timing medication-unfit(2), --the medication monitor has determined that the medication --has become unfit tamper(3), --the medication monitor has detected tampering environmental-exceeded-high(4), --the medication monitor has determined that the --environment has exceeded the safe high levels environmental-exceeded-low(5), --the medication monitor has determined that the --environment has exceeded the safe low levels medication-expiration(6), --the medication monitor has determined that the --medication has expired non-compliant-amber(7), --the non-compliant percentage is in the amber range --(coaching may be required) non-compliant-red(8), --the non-compliant percentage is in the red range --(intervention needed) medication-course-complete(9), --all the medication for the current course has --been dispensed medication-taken-incorrectly(10), --the medication monitor has determined that --the medication is being taken incorrectly client-side-effects(11) --the medication monitor has determined that the client --is suffering side effects } (SIZE(32)) END biosig-2.3.3/biosig4c++/t241/CENTS14271-2003.asn10000664000175000017500000014465014105434233020134 0ustar schloeglschloegl/* ASN.1 specification of the File Exchange Format for Vital Signs The info was manually extracted from CEN/TC251/PT-40/4002N005 A number of bugs and typos were fixed. $Id$ Copyright (C) 2009 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ ModuleTest DEFINITIONS ::= BEGIN /* B.1.1 ASN.1 built-in types used INTEGER ISO/IEC 8824-1:1998 Ch. 18 REAL ISO/IEC 8824-1:1998 Ch. 20 BIT-STRING ISO/IEC 8824-1:1998 Ch. 21 OCTET-STRING ISO/IEC 8824-1:1998 Ch. 22 SEQUENCE ISO/IEC 8824-1:1998 Ch. 24 SEQUENCE-OF ISO/IEC 8824-1:1998 Ch. 25 CHOICE ISO/IEC 8824-1:1998 Ch. 28 Tagged types ISO/IEC 8824-1:1998 Ch. 30 UTF8String ISO/IEC 8824-1:1998 Ch. 36.13; ISO/IEC 10646-1 Generalized time ISO/IEC 8824-1:1998 Ch. 41; ISO 8601 Constrained types ISO/IEC 8824-1:1998 Ch. 44 */ INT-U64 ::= INTEGER -- (0 .. 18446744073709551615) /* make asn1c v0.9.22 happy */ INT-I64 ::= INTEGER -- (-9223372036854775808 .. 9223372036854775807) /* reduced to make asn1c v0.9.22 happy */ INT-U32 ::= INTEGER (0 .. 4294967295) INT-I32 ::= INTEGER (-2147483648 .. 2147483647) INT-U16 ::= INTEGER (0 .. 65535) INT-I16 ::= INTEGER (-32768 .. 32767) INT-U8 ::= INTEGER (0 .. 255) INT-I8 ::= INTEGER (-128 .. 127) BITS-32 ::= BIT STRING SIZE (32) BITS-16 ::= BIT STRING SIZE (16) BITS-8 ::= BIT STRING SIZE (8) FEFString ::= UTF8String FEFFloat ::= REAL Fraction ::= SEQUENCE { numerator [1] INT-I32, -- INT-32 is not defined denominator [2] INT-I32 } AbsoluteRange ::= SEQUENCE { lowervalue [1] FEFFloat, uppervalue [2] FEFFloat } Handle ::= [APPLICATION 2337] INT-U16 HandleRef ::= INT-U16 DeviceCode ::= INT-U16 -- block A: Device Nomenclature UnitsOfMeasurementCode ::= INT-U16 -- block B: Units of Measurement MetricsCode ::= INT-U16 -- block C: Metrics BodySiteCode ::= INT-U16 -- block D: Body Sites AlertCode ::= INT-U16 -- block E: Alert Codes ExtNomenclatureCode ::= INT-U16 -- block F: External Nomenclatures ParameterGroupCode ::= INT-U16 -- unassigned block: Parameter Groups PrivateCode ::= INT-U16 -- code specified by the user or manufacturer -- ENV 13734 uses the term “PrivateOID†here Placeholder ::= [APPLICATION 6499] OCTET STRING -- missing definitions HealthCareProviderId ::= FEFString Address ::= FEFString UnitCode ::= FEFString ManufacturerID ::= CHOICE { oid [1] OBJECT IDENTIFIER, -- ISO 8824 object identifier uuid [2] OCTET STRING SIZE (16) -- ISO 11578 universal unique identifier } AbsoluteTime ::= GeneralizedTime RelativeTime ::= INT-U32 HighResRelativeTime ::= INT-U64 ObservationTime ::= SEQUENCE { absolutetimestamp [APPLICATION 2448] AbsoluteTime, --OPTIONAL, relativetimestamp [APPLICATION 2449] RelativeTime, --OPTIONAL, hirestimerelativestamp [APPLICATION 2537] HighResRelativeTime --OPTIONAL } SimpleColour ::= INTEGER { colblack (0), -- RGB=000 colred (1), -- RGB=100 colgreen (2), -- RGB=010 colyellow (3), -- RGB=110 colblue (4), -- RGB=001 colmagenta (5), -- RGB=101 colcyan (6), -- RGB=011 colwhite (7) -- RGB=111 } (0..65535) ExtNomenRef ::= SEQUENCE { nomenclatureid ExtNomenclatureCode, nomenclaturecode ANY DEFINED BY nomenclatureid } MetricMeasure ::= SEQUENCE { metricmeasurevalue [1] FEFFloat, metricmeasuremnit [2] UnitsOfMeasurementCode } PersonNameGroup ::= SEQUENCE { familyname [1] FEFString, givenname [2] FEFString, middlename [3] FEFString, prefix [4] FEFString, suffix [5] FEFString, degree [6] FEFString } PersonName ::= SEQUENCE { ungroupedname [APPLICATION 6001] FEFString OPTIONAL, characternamegroup [APPLICATION 6002] PersonNameGroup OPTIONAL, ideographicnamegroup [APPLICATION 6003] PersonNameGroup OPTIONAL, phoneticnamegroup [APPLICATION 6004] PersonNameGroup OPTIONAL -- at least one of the groups must be present -- this will be the characternamegroup for European names } -- -- Object Identifier Type as defined in nomenclature -- (do not confuse with ASN.1 OBJECT IDENTIFIER) -- OID-Type ::= INT-U16 -- 16 bit integer type SessionArchiveSection ::= [APPLICATION 7001] SEQUENCE { handle Handle, -- unique (within a file) handle s-archive-id [APPLICATION 2507] FEFString, s-archive-name [APPLICATION 2513] FEFString, s-archive-comments [APPLICATION 2530] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL, manufacturerspecific [APPLICATION 7002] ManufacturerSpecificSection OPTIONAL, healthcareprovider [APPLICATION 7003] HealthCareProviderSection OPTIONAL, demographics [APPLICATION 7004] PatientDemographicsSection, sessions [APPLICATION 7015] SEQUENCE SIZE (1..MAX) OF SessionTestSection, /* SIZE (1..*), -- to make asn1c v0.9.22 happy */ notes [APPLICATION 7016] SEQUENCE OF SessionNotesSection DEFAULT {} } ArchiveProtection ::= SEQUENCE { protectiontype [1] PrivateCode, protectionkey [2] ANY DEFINED BY protection-type } ManufacturerSpecificSection ::= SEQUENCE { manufacturerid [APPLICATION 6005] ManufacturerID, -- encodedentries [APPLICATION 6006] SEQUENCE OF ManufacturerSpecificEncoded DEFAULT {}, binaryentries [APPLICATION 6007] SEQUENCE OF ManufacturerSpecificBinary DEFAULT {} } ManufacturerSpecificEncoded ::= SEQUENCE { code [1] PrivateCode, data [2] ANY DEFINED BY code } ManufacturerSpecificBinary ::= SEQUENCE { code [1] PrivateCode, data [2] OCTET STRING } HealthCareProviderSection ::= SEQUENCE { identification [APPLICATION 6008] HealthCareProviderId, -- name [APPLICATION 6009] FEFString, -- address [APPLICATION 6010] Address OPTIONAL, -- placeholder Placeholder OPTIONAL, healthcareprofessionals [APPLICATION 7008] SEQUENCE OF HealthCareProfessionalSection DEFAULT {} } HealthCareProfessionalSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle COMPONENTS OF PersonName, -- use common person name attributes identification [APPLICATION 6011] FEFString OPTIONAL, -- optional textual unique identification identificationcode [APPLICATION 6012] ExtNomenRef OPTIONAL, -- optional coded unique identification authorization-level [APPLICATION 2481] Authorization OPTIONAL, -- optional organisation specific code function [APPLICATION 6048] FEFString OPTIONAL, -- optional textual function specification functioncode [APPLICATION 6049] ExtNomenRef OPTIONAL, -- optional coded function specification placeholder Placeholder OPTIONAL } Authorization ::= SEQUENCE { authorization-type [1] PrivateCode, authorization-key [2] ANY DEFINED BY authorization-type } PatientDemographicsSection ::= SEQUENCE { handle Handle, -- unique (within file) handle patientid [APPLICATION 2394] FEFString OPTIONAL, COMPONENTS OF PersonName, -- use common person name attributes birthname [APPLICATION 2398] FEFString OPTIONAL, -- maiden name sex [APPLICATION 2401] PatientSex OPTIONAL, race [APPLICATION 2526] PatientRace OPTIONAL, patienttype [APPLICATION 2402] PatientType OPTIONAL, dateofbirth [APPLICATION 2392] AbsoluteTime OPTIONAL, patientgeninfo [APPLICATION 2393] FEFString OPTIONAL, -- textual Patient related Information patientage [APPLICATION 2520] PatMeasure OPTIONAL, -- for neonatal, e.g. in hours or in weeks gestationalage [APPLICATION 2521] PatMeasure OPTIONAL, -- for neonatal patientheight [APPLICATION 2524] PatMeasure OPTIONAL, patientweight [APPLICATION 2527] PatMeasure OPTIONAL, patientbirthlength [APPLICATION 2522] PatMeasure OPTIONAL, patientbirthweight [APPLICATION 2523] PatMeasure OPTIONAL, motherpatientid [APPLICATION 2504] FEFString OPTIONAL, mothername [APPLICATION 2525] PersonName OPTIONAL, -- for neonatal patientheadcircumference[APPLICATION 2490] PatMeasure OPTIONAL, patientbsa [APPLICATION 2390] PatMeasure OPTIONAL, -- Body Surface Area, can be calculated bedid [APPLICATION 2501] FEFString OPTIONAL, diagnosticinfo [APPLICATION 2496] FEFString OPTIONAL, diagnosticcodes [APPLICATION 2492] SEQUENCE OF ExtNomenRef DEFAULT {}, admittingphysician [APPLICATION 2515] HandleRef OPTIONAL, -- for ICU; references HealthCareProfessionalSection attendingphysician [APPLICATION 2516] HandleRef OPTIONAL, -- for ICU; references HealthCareProfessionalSection dateofprocedure [APPLICATION 2518] AbsoluteTime OPTIONAL, -- for OR proceduredescription [APPLICATION 2495] FEFString OPTIONAL, -- for OR procedurecodes [APPLICATION 2493] SEQUENCE OF ExtNomenRef DEFAULT {}, -- for OR - procedure codes are specified in a -- nomenclature scheme not defined in this standard anaesthetist [APPLICATION 2479] HandleRef OPTIONAL, -- for OR; references HealthCareProfessionalSection surgeon [APPLICATION 2532] HandleRef OPTIONAL -- for OR; references HealthCareProfessionalSection } PatMeasure ::= SEQUENCE { value [1] FEFFloat, m-unit [2] UnitsOfMeasurementCode -- code for units of measure } -- Patient Sex according to ISO 5218 PatientSex ::= INTEGER { sex-unknown (0), male (1), female (2), sex-unspecified (9) } (0..65535) PatientType ::= INTEGER { pt-unspecified (0), adult (1), pediatric (2), neonatal (3) } (0..65535) -- Patient Race according to SCP ECG PatientRace ::= INTEGER { race-unspecified (0), race-caucasian (1), race-black (2), race-oriental (3) } (0..65535) SessionTestSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle st-archive-id [APPLICATION 2506] FEFString, st-archive-name [APPLICATION 2512] FEFString, st-archive-comments [APPLICATION 2529] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL, medicaldevicesystem [APPLICATION 7005] MedicalDeviceSystemSection, multimedia [APPLICATION 7006] SEQUENCE OF MultimediaSection DEFAULT {}, phases [APPLICATION 7017] SEQUENCE SIZE (1..MAX) OF SessionPhaseSection /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ } MedicalDeviceSystemSection ::= SEQUENCE { handle Handle, -- unique (within file) handle systemtype [APPLICATION 2438] DeviceCode, -- e.g. ventilator, monitor as -- defined in nomenclature systemmodel [APPLICATION 2344] SystemModel, -- model describes manufacturer and -- model no systemid [APPLICATION 2436] FEFString, -- manufacturer specified system ID -- e.g. serial number compatibilityid [APPLICATION 2336] INT-U32 OPTIONAL, -- for manufacturer use nomenclatureversion [APPLICATION 2376] INT-U32, -- version of nomenclature used by -- the system requirednomenclatureversion [APPLICATION 6013] AbsoluteTime, -- required revision of nomenclature to -- interpret any information from -- this medical device system usednomenclatureversion [APPLICATION 6014] AbsoluteTime, -- revision of nomenclature to -- interpret all information from -- this medical device system systemspecification [APPLICATION 2437] SEQUENCE OF SystemSpecEntry DEFAULT {}, -- defines functional components productionspecification [APPLICATION 2349] SEQUENCE OF ProdSpecEntry DEFAULT {}, -- component revisions, serial -- numbers etc. bedlabel [APPLICATION 2334] FEFString OPTIONAL, -- printable string identifying -- system location softid [APPLICATION 2350] FEFString OPTIONAL, -- settable, e.g. hospital -- inventory number operatingmode [APPLICATION 2374] PrivateCode OPTIONAL, applicationarea [APPLICATION 2317] ApplicationArea OPTIONAL, powerstatus [APPLICATION 2389] PowerStatus OPTIONAL, -- onBatteryoronMains altitude [APPLICATION 2316] INT-I16 OPTIONAL, -- above or below sea level in metres linefrequency [APPLICATION 2357] LineFrequency OPTIONAL, -- frequency of mains placeholder Placeholder OPTIONAL, components MedicalDeviceComponents } SystemModel ::= SEQUENCE { manufacturer [1] FEFString, model-number [2] FEFString } SystemSpecEntry ::= SEQUENCE { component-capab-id [1] PrivateCode, component-spec [2] ANY DEFINED BY component-capab-id } ProdSpecEntryType ::= INTEGER { unspecified (0), serial-number (1), part-number (2), hw-revision (3), sw-revision (4), fw-revision (5), protocol-revision (6) } (0..65535) ProdSpecEntry ::= SEQUENCE { spec-type [1] ProdSpecEntryType, component-id [2] PrivateCode, prod-spec [3] FEFString } ApplicationArea ::= INTEGER { area-unspec (0), area-operating-room (1), area-intensive-care (2) } (0..65535) PowerStatus ::= BIT STRING { onMains (0), onBattery (1), chargingFull (8), chargingTrickle (9), chargingOff (10) } SIZE(16) LineFrequency ::= INTEGER { line-f-unspec (0), line-f-50hz (1), line-f-60hz (2) } (0..65535) MedicalDeviceComponents ::= CHOICE { medicaldevice [APPLICATION 7009] VirtualMedicalDeviceSection, -- Simple MDS medicaldevices [APPLICATION 7010] SEQUENCE SIZE (2..MAX) OF VirtualMedicalDeviceSection, /* SIZE (2..*), -- to make asn1c v0.9.22 happy */ -- Hydra MDS subsystems [APPLICATION 7011] SEQUENCE SIZE (1..MAX) OF MedicalDeviceSystemSection /* SIZE (1..*), -- to make asn1c v0.9.22 happy */ -- Composite Single Bed MDS } VirtualMedicalDeviceSection ::= SEQUENCE { handle Handle, -- unique (within file) handle devicetype [APPLICATION 2351] DeviceCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of devicetype vmdmodel [APPLICATION 2344] SystemModel OPTIONAL, -- manufacturer and model number productionspecification [APPLICATION 2349] SEQUENCE OF ProdSpecEntry DEFAULT {}, -- serial numbers and revisions, -- only present if VMD represents an -- independent subsystem compatibilityid [APPLICATION 2336] INT-U32 OPTIONAL, -- static for manufacturer use parametergroup [APPLICATION 2346] ParameterGroupCode OPTIONAL, -- e.g. cardiovascular position [APPLICATION 2348] INT-U16 OPTIONAL, -- e.g. slot number, 0xffff marks -- an invalid or unknown position measurementprinciple [APPLICATION 2560] MsmtPrinciple OPTIONAL -- describes the physical principle -- of the measurement } MsmtPrinciple ::= BIT STRING { msp-chemical (1), msp-electrical (2), msp-impedance (3), msp-nuclear (4), msp-optical (5), msp-thermal (6), msp-biological (7), msp-mechanical (8), msp-manual (15) } SIZE(16) ChannelDescriptionSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle metrictype [APPLICATION 2351] MetricsCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of metrictype channelid [APPLICATION 2318] MetricsCode OPTIONAL, -- contains dynamic identification (e.g. a specific -- blood pressure label) compared to the -- static identification is in metrictype channelstatus [APPLICATION 2320] MetricStatus DEFAULT {}, -- usually part of an dynamic attribute change section parametergroup [APPLICATION 2346] ParameterGroupCode OPTIONAL, -- e.g. cardiovascular physicalchannelnr [APPLICATION 2319] INT-U16 DEFAULT 65535, -- e.g. ADC channel, 65535 (0xffff) marks -- an invalid or unknown channel measurementprinciple [APPLICATION 2560] MsmtPrinciple OPTIONAL -- describes the physical principle -- of the measurement } ChannelStatus ::= BIT STRING { chn-off (0), chn-not-ready (1), chn-standby (2), chn-transduc-discon (8), chn-hw-discon (9) } SIZE(16) MultimediaSection ::= SEQUENCE { starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, mimetype [APPLICATION 6017] FEFString, comments [APPLICATION 6018] Comments OPTIONAL, originallocation [APPLICATION 6019] FEFString OPTIONAL, placeholder [APPLICATION 6499] Placeholder OPTIONAL, contentorreference [APPLICATION 6020] ContentOrReference } Comments ::= SEQUENCE { commenttext [1] FEFString, commentator [2] HandleRef -- references HealthCareProfessionalSection } ContentOrReference ::= CHOICE { content [1] OCTET STRING, reference [2] FEFString } SessionPhaseSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, placeholder Placeholder OPTIONAL, descriptivedata [APPLICATION 7018] DescriptiveDataSection, measureddata [APPLICATION 7019] SEQUENCE SIZE (1..MAX) OF MeasuredDataSection /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ -- size = 1 except for streaming mode profile } DescriptiveDataSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle placeholder Placeholder OPTIONAL, realtimesadescs [APPLICATION 7020] SEQUENCE OF RealTimeSampleArrayDescriptiveDataSection DEFAULT {}, timesadescs [APPLICATION 7021] SEQUENCE OF TimeSampleArrayDescriptiveDataSection DEFAULT {}, distributionsadescs [APPLICATION 7022] SEQUENCE OF RealTimeSampleArrayDescriptiveDataSection DEFAULT {}, numericdescs [APPLICATION 7023] SEQUENCE OF NumericDescriptiveDataSection DEFAULT {}, enumerationdescs [APPLICATION 7024] SEQUENCE OF EnumerationDescriptiveDataSection DEFAULT {} } MetricDescriptiveDataSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle devicehandle [APPLICATION 6034] HandleRef, -- references the Virtual Medical Device Section or -- Channel Description Section this metric -- originates from metrictype [APPLICATION 2351] MetricsCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of metrictype metriccategory [APPLICATION 2367] MetricCategory DEFAULT mcat-unspec, -- the other COMPONENTS-OF MetricSpecification -- are not applicable for storage metricstatus [APPLICATION 2368] MetricStatus DEFAULT {}, -- usually part of an dynamic attribute change section measurementstatus [APPLICATION 2375] MeasurementStatus DEFAULT {}, -- usually part of an dynamic attribute change section metricid [APPLICATION 2347] MetricsCode OPTIONAL, -- contains dynamic identification (e.g. a specific -- blood pressure label) compared to the -- static identification is in metrictype metricidext [APPLICATION 2502] ExtNomenRef OPTIONAL, -- dynamic identification of the metric in a -- different nomenclature or dictionary. Use of -- this attribute severely limits interoperability -- of applications. unitcode [APPLICATION 2454] UnitsOfMeasurementCode OPTIONAL, -- dimension, e.g. 'mV' unitlabelstring [APPLICATION 2457] FEFString OPTIONAL, -- textual representation of dimension vmosourcelist [APPLICATION 2467] SEQUENCE OF MetricsCode DEFAULT {}, -- indicates sources of this metric in -- the form of references to other metrics metricsourcelist [APPLICATION 2366] SEQUENCE OF HandleRef DEFAULT {}, -- indicates sources of this metric in -- the form of a list of metric IDs msmtsitelist [APPLICATION 2430] SEQUENCE OF BodySiteCode DEFAULT {}, -- Measurement Sites, specified in -- internal nomenclature msmtsitelistext [APPLICATION 2551] SEQUENCE OF ExtNomenRef DEFAULT {}, -- Measurement Sites, specified in -- external nomenclature bodysitelist [APPLICATION 2429] SEQUENCE OF BodySiteCode DEFAULT {}, -- Body Sites, specified in internal nomenclature bodysitelistext [APPLICATION 2550] SEQUENCE OF ExtNomenRef DEFAULT {}, -- Body Sites, specified in external nomenclature metriccalibration [APPLICATION 2362] SEQUENCE OF MetricCalEntry DEFAULT {}, -- list time and state of calibrations colour [APPLICATION 2321] SimpleColour OPTIONAL, -- colour for representation measuremode [APPLICATION 2373] PrivateCode OPTIONAL, -- manufacturer measurement specific info measureperiod [APPLICATION 2443] MetricMeasure OPTIONAL, -- measurement repetition time, not necessarily -- the same as update period averagingperiod [APPLICATION 2535] MetricMeasure OPTIONAL, -- Time period used to average values, e.g. for -- an average flow of last hour metric starttime [APPLICATION 2538] AbsoluteTime OPTIONAL, -- time when measurement activity was started -- (e.g. when infusion was started) stoptime [APPLICATION 2539] AbsoluteTime OPTIONAL, -- Time when measurement activity was stopped metricinfolabelstring [APPLICATION 2365] FEFString OPTIONAL, -- textual attribute, allows e.g. to specify -- electrode displacements or other specific -- information about the measurement substance [APPLICATION 2542] ExtNomenRef OPTIONAL, -- substance that Metric pertains to, expressed -- in nomenclature that is defined outside of -- this standard substancelabelstring [APPLICATION 2508] FEFString OPTIONAL -- textual attribute that identifies the substance } /* already earlier defined PatMeasure ::= SEQUENCE { value [1] FEFFloat, m-unit [2] UnitsOfMeasurementCode -- code for units of measure } */ MetricStatus ::= BIT STRING { metric-off (0), metric-not-ready (1), metric-standby (2), metric-transduc-discon (8), metric-hw-discon (9) } SIZE(16) MetricCategory ::= INTEGER { mcat-unspec (0), auto-measurement (1), manual-measurement (2), auto-setting (3), manual-setting (4), auto-calculation (5), manual-calculation (6) } (0..65535) MetricCalEntry ::= SEQUENCE { cal-type [1] MetricCalType, cal-state [2] MetricCalState, cal-time [3] AbsoluteTime } MetricCalType ::= INTEGER { cal-unspec (0), cal-offset (1), cal-gain (2), cal-two-point (3) } (0..65535) MetricCalState ::= INTEGER { not-calibrated (0), cal-required (1), calibrated (2) } (0..65535) MeasurementStatus ::= BIT STRING { invalid (0), questionable (1), not-available (2), calibration-ongoing (3), test-data (4), demo-data (5), validated-data (8), -- relevant e.g. in an archive early-indication (9), -- early estimate of value msmt-ongoing (10) -- indicates that a new msmt is just -- being taken (episodic) } SIZE(16) SampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS-OF super class saspecification [APPLICATION 2413] SaSpec, -- static description of sample array and sample types compression [APPLICATION 2322] PrivateCode OPTIONAL, -- defines potential compression algorithm scaleandrangespec [APPLICATION 2416] ScaleRangeSpec, -- defines mapping between samples and actual -- values as well as measurement range, saphysiologicalrange[APPLICATION 2411] AbsoluteRange OPTIONAL, -- for optimum display scaling the physiological -- meaningful range is specified visualgrid [APPLICATION 2331] SEQUENCE OF SaGridEntry DEFAULT {}, -- defines gridline positions on displays -- and recorders -- (Note: tag NOM_ATTR_GRID_VIS_I32 used) sacalibrationdata [APPLICATION 2405] SEQUENCE OF SaCalData DEFAULT {}, -- defines positions of calibration markers on -- display and recorders -- (Note: tag NOM_ATTR_SA_CALIB_I32 used) filterspecification [APPLICATION 2329] SEQUENCE OF SaFilterEntry DEFAULT {}, -- ... sasignalfrequency [APPLICATION 2408] SaSignalFrequency OPTIONAL, -- max. signal frequency sameasureresolution [APPLICATION 2409] FEFFloat OPTIONAL -- ... } SaSpec ::= SEQUENCE { storagesize [1] INT-U8, -- e.g. 8 for 8bit samples, 16 for 16bit samples, significantbits [2] INT-U8 OPTIONAL, -- defines significant bits in one sample -- when not identical to storagesize storagedatatype [3] StorageDataType, flags [4] SaFlags DEFAULT {}, arraysize [5] INT-U16 -- defines the number of samples per -- signal in a subblock of a SAMDB } StorageDataType ::= INTEGER { unsigned (0), signed (1), ieee754float (2) } (0..255) -- allowed combinations of storagedatatype and storagedatasize are: -- storagedatatype storagesize -- unsigned 8 -- unsigned 16 -- unsigned 32 -- signed 8 -- signed 16 -- signed 32 -- ieee754float 32 -- ieee754float 64 SaFlags ::= BIT STRING { smoothcurve (0), -- for optimum display, use a smoothing algorithm delayedcurve (1), -- curve is delayed (not real time) saextvalrange (3) -- The non-significant bits in a sample are -- not 0 (or sign extended in the signed case) } SIZE(16) -- The scale and range definition attribute describes a relation between -- scaled values and absolute values. -- Note: If a wave does not represent absolute values, the absolute value -- fields should be equal to the scaled value fields. -- lowerabsolutevalue shall be smaller than upperabsolutevalue -- lowervaluescaled is the scaled value representing the absolute value -- lowerabsolutevalue -- uppervaluescaled is the scaled value representing the absolute value -- upperabsolutevalue ScaleRangeSpec ::= SEQUENCE { lowerabsolutevalue [1] FEFFloat, upperabsolutevalue [2] FEFFloat, lowervaluescaled [3] FEFFloat, uppervaluescaled [4] FEFFloat } SaFilterEntry ::= SEQUENCE { filtertype [1] FilterType, frequency [2] FEFFloat, filterorder [3] INT-I16 -- e.g. -1: 6 dB/oct } FilterType ::= INTEGER { other (0), lowpass (1), highpass (2), notch (3) } (0..65535) -- The visual grid definition attribute defines grid lines at different levels -- of grid lines. SaGridEntry ::= SEQUENCE { absolute-value [1] FEFFloat, level [3] INT-I16 } -- The calibration data definition attribute defines calibration markers -- on a display or on a recording strip. SaCalData ::= SEQUENCE { lowerabsolutevalue [1] FEFFloat, upperabsolutevalue [2] FEFFloat, increment [5] FEFFloat, -- value for each step of the stair cal-type [6] SaCalDataType } SaCalDataType ::= INTEGER { bar (0), -- display a calibration bar stair (1) -- display a calibration stair } (0..65535) -- Specification of signal frequency SaSignalFrequency ::= SEQUENCE { lowedgefreq [1] FEFFloat, -- in Hz highedgefreq [2] FEFFloat -- in Hz } RealTimeSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS OF super class sampleperiod [APPLICATION 2445] Fraction, -- in seconds, expressed as fraction sweepspeed [APPLICATION 2431] MetricMeasure OPTIONAL -- e.g. mm/s } TimeSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS-OF super class sampleperiod [APPLICATION 2445] Fraction, -- in seconds, expressed as fraction sweepspeed [APPLICATION 2431] MetricMeasure OPTIONAL -- e.g. mm/s } DistributionSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS-OF super class distributionrangespec [APPLICATION 2403] DsaRangeSpec, -- maps array index to absolute value xunitcode [APPLICATION 2455] UnitsOfMeasurementCode OPTIONAL, -- applies to x-axis xunitlabelstring [APPLICATION 2458] FEFString OPTIONAL -- applies to x-axis } DsaRangeSpec ::= SEQUENCE { first-element-value [1] FEFFloat, last-element-value [2] FEFFloat } NumericDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS-OF super class numeasurerange [APPLICATION 2382] AbsoluteRange OPTIONAL, -- potential measurement range nuphysiologicalrange [APPLICATION 2383] AbsoluteRange OPTIONAL, -- physiological reasonable range (note that -- this is not an alarming range) numeasureresolution [APPLICATION 2381] FEFFloat OPTIONAL, -- resolution of measurement, minimum -- difference between two observed values displayresolution [APPLICATION 2327] DispResolution OPTIONAL, -- if different resolution is needed when -- value is displayed accuracy [APPLICATION 2378] FEFFloat OPTIONAL -- max. deviation of actual value from reported -- observed value (if it can be specified) } EnumerationDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS OF super class enummeasurerange [APPLICATION 2561] SEQUENCE OF MetricsCode DEFAULT {}, -- list of possible observed value object OIDs, -- optional if the OID type is present in the -- observed value, out of scope otherwise enummeasurerangebits [APPLICATION 2568] BITS-32 OPTIONAL -- list of possible observed value bits in the -- bit string data type, optional if the BITS-32 -- type is used in the observed value, out of -- scope otherwise } MeasuredDataSection ::= SEQUENCE { realtimesas [APPLICATION 7025] SEQUENCE OF RealTimeSampleArrayMeasuredDataSection DEFAULT {}, timesas [APPLICATION 7026] SEQUENCE OF TimeSampleArrayMeasuredDataSection DEFAULT {}, distributionsas [APPLICATION 7027] SEQUENCE OF RealTimeSampleArrayMeasuredDataSection DEFAULT {}, numerics [APPLICATION 7028] SEQUENCE OF NumericMeasuredDataSection DEFAULT {}, enumerations [APPLICATION 7029] SEQUENCE OF EnumerationMeasuredDataSection DEFAULT {}, alerts [APPLICATION 7007] SEQUENCE OF AlertSection DEFAULT {}, attributechanges [APPLICATION 7030] SEQUENCE OF DynamicAttributeChangeSection DEFAULT {} } SampleArrayMeasuredDataSection ::= SEQUENCE { numberofsubblocks [APPLICATION 6035] INT-U32, subblocklength [APPLICATION 6036] Fraction, -- in seconds subblocksize [APPLICATION 6037] INT-U32, -- in octets metriclist [APPLICATION 6038] SEQUENCE SIZE (1..MAX) OF HandleRef /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ -- references to SampleArrayDescriptiveDataSection } SampleArrayMeasuredDataBlock ::= [APPLICATION 6039] OCTET STRING RealTimeSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } TimeSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, -- include COMPONENTS OF super class tsamarkerlist [APPLICATION 2452] SEQUENCE OF MarkerEntryRelTim DEFAULT {}, -- marks positions in wave snippets data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } MarkerEntryRelTim ::= SEQUENCE { markerid [1] MetricsCode, marktime [2] RelativeTime } DistributionSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, -- include COMPONENTS OF super class data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } NumericMeasuredDataSection ::= SEQUENCE { metricref [APPLICATION 6050] HandleRef, -- reference to -- NumericDescriptiveDataSection nuobservedvalue ChoiceOfNuObsValue, -- simple or compound timestamp ObservationTime } ChoiceOfNuObsValue ::= CHOICE { nuobservedvalue [APPLICATION 2384] NuObsValue, -- e.g. measurement value, should also contain -- validity information to be useful! compoundnuobservedvalue [APPLICATION 2379] SEQUENCE SIZE (2..MAX) OF NuObsValue /* SIZE (2..*) -- to make asn1 v0.9.22 happy */ -- used when multiple values are represented -- in a single NU object (Structure is compound) } NuObsValue ::= SEQUENCE { metricid [1] MetricsCode OPTIONAL, state [2] MeasurementStatus DEFAULT {}, unitcode [3] UnitsOfMeasurementCode OPTIONAL, value [4] FEFFloat } -- value representation on a display (may be lower resolution) DispResolution ::= SEQUENCE { prepoint [1] INT-U8, -- digits before decimal point postpoint [2] INT-U8 -- digits after decimal point } -- ASN.1 source defining EnumerationMeasuredDataSection EnumerationMeasuredDataSection ::= SEQUENCE { metricref [APPLICATION 6050] HandleRef, -- reference to -- EnumerationDescriptiveDataSection enumobservedvalue ChoiceOfEnumObsValue, -- simple or compound enumadditionaldata [APPLICATION 2498] ANY DEFINED BY enumobservedvalue OPTIONAL, -- additional non normative event specific -- information can be provided (e.g. pacer -- parameters of pace pulse detect). Requires -- use of enum-obj-id in observed value! enumtimestamp ChoiceOfEnumTimeStamp -- one or more timestamps } EnumObsValue ::= SEQUENCE { metric-id [1] MetricsCode OPTIONAL, state [2] MeasurementStatus DEFAULT {}, value [3] EnumVal } ChoiceOfEnumObsValue ::= CHOICE { enumobservedvalue [APPLICATION 2462] EnumObsValue, compoundenumobservedvalue [APPLICATION 2463] SEQUENCE SIZE (1..MAX) OF EnumObsValue /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ } EnumVal ::= CHOICE { enum-obj-id [1] MetricsCode, -- id of the metric enum-text-string [2] FEFString, -- free text enum-external-code [8] ExtNomenRef, -- code defined in other coding system enum-bit-str [16] BITS-32, -- bit string enum-record [33] EnumRecordMetric, -- record type defined Metric ID enum-record-oo [34] EnumRecordOO -- record type defined OO ID } EnumRecordMetric ::= SEQUENCE { record-type-code MetricsCode, record-data ANY DEFINED BY record-type-code } EnumRecordOO ::= SEQUENCE { record-type-code OID-Type, -- from OO Partition record-data ANY DEFINED BY record-type-code } ChoiceOfEnumTimeStamp ::= CHOICE { timestamp ObservationTime, absolutetimestamparray [APPLICATION 6042] SEQUENCE OF AbsoluteTime, relativetimestamparray [APPLICATION 6043] SEQUENCE OF RelativeTime, hirestimestamparray [APPLICATION 6044] SEQUENCE OF HighResRelativeTime } AlertSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle alerttype [APPLICATION 2351] AlertCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of alerttype timestamp ObservationTime, -- time of change alertcondition [APPLICATION 2476] AlertCondition, limitspec [APPLICATION 2477] LimitSpecEntry OPTIONAL, -- specification of the supervised limit vmoreference [APPLICATION 6045] HandleRef OPTIONAL -- reference to MDSS, VMD or MDDS } AlertCondition ::= SEQUENCE { objreference [1] HandleRef, controls [2] AlertControls, alertflags [3] AlertFlags, -- supporting flags alertsource [4] MetricsCode, alertcode [5] AlertCode, alerttype [6] AlertType, -- defines type and severity of condition alertinfoid [7] PrivateCode OPTIONAL, -- specific info can be appended alertinfo [8] ANY DEFINED BY alertinfoid OPTIONAL } -- Alert Controls define flags to communicate status information -- relevant for alarm processor AlertControls ::= BIT STRING { acobjoff (0), -- the object supervised by the alert is off acchanoff (1), -- channel is off acallobjaloff (3), -- all alerts supervising the reference objects are off acalertoff (4) -- this alert supervisor process is off } SIZE(16) -- Alert Flags give additional support information how to process the condition, AlertFlags ::= BIT STRING { localaudible (1), -- indicates that the condition is audible -- at the local system remoteaudible (2), -- condition can be audible at remote (not suppressed) visuallatching (3), -- visible latching of the condition is allowed audiblelatching (4), -- audio latching of the condition is allowed derived (6), recordinhibit (8) -- do not start alarm recording } SIZE(16) -- Alert Type allows to distinguish severity of technical and -- physiological alarms AlertType ::= INTEGER { noalert (0), lowprital (1), -- low priority technical alarm medprital (2), -- medium priority technical alarm hiprital (4), -- high priority technical alarm lowpripal (256), -- awareness condition medpripal (512), -- prompt response required (abnormal condition) hipripal (1024) -- immediate response required (emergency condition) } (0..65535) -- Specification of the supervised limit range LimitSpecEntry ::= SEQUENCE { sectionhandle [1] HandleRef, alsourceid [2] MetricsCode, -- typically the metric ID of the measurement unitcode [3] UnitCode, -- from DIM partition limalstat [4] CurLimAlStat, limalval [5] AbsoluteRange } -- Current Limit Alert State - -- NOTE: The bits refer to the Limit Alarm only, not to the global alert -- state of the metric! CurLimAlStat ::= BIT STRING { limalertoff (0), -- if this bit is set, all alerts (both -- high and low) are off limlowoff (1), -- low limit violation detection is off limhighoff (2) -- high limit violation detection is off } SIZE(16) DynamicAttributeChangeSection ::= SEQUENCE { timestamp ObservationTime, -- time of change handle [APPLICATION 6041] HandleRef, -- reference to section whose attribute changed attribute [APPLICATION 6046] INT-U16, -- attribute code value [APPLICATION 6047] ANY DEFINED BY attribute OPTIONAL -- new value -- or removal of optional attribute if absent } -- ASN.1 source defining SessionNotesSection SessionNotesSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle sn-id [APPLICATION 2505] FEFString, sn-name [APPLICATION 2511] FEFString, sn-comments [APPLICATION 2528] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, findings [APPLICATION 2500] FEFString OPTIONAL, diagnosticscodes [APPLICATION 2492] SEQUENCE OF ExtNomenRef DEFAULT {}, diagnosisdescription [APPLICATION 2494] FEFString OPTIONAL, procedurecodes [APPLICATION 2493] SEQUENCE OF ExtNomenRef DEFAULT {}, proceduredescription [APPLICATION 2495] FEFString OPTIONAL, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL } END biosig-2.3.3/biosig4c++/t241/ISO11073-10417.asn10000664000175000017500000000167214105434233017773 0ustar schloeglschloegl/* ASN.1 specification of IEEE Std 11073-10417-2008 Health Informatics—Personal health device communication Part 10417: Device specialization—Glucose meter The info was manually extracted. $Id$ Copyright (C) 2009 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ ModuleTest DEFINITIONS ::= BEGIN GlucoseDevStat::= BIT STRING { device-battery-low(0), sensor-malfunction(1), sensor-sample-size-insufficient(2), sensor-strip-insertion(3), sensor-strip-type-incorrect(4), sensor-result-too-high(5), sensor-result-too-low(6), sensor-temp-too-high(7), sensor-temp-too-low(8), sensor-read-interrupt(9), device-gen-fault(10) } (SIZE(16)) END biosig-2.3.3/biosig4c++/t241/ISO11073-10404.asn10000664000175000017500000000360214105434233017762 0ustar schloeglschloegl/* ASN.1 specification of IEEE Std 11073-10404-2008 Health Informatics—Personal health device communication Part 10404: Device specialization—Pulse oximeter The info was manually extracted and modified for valid ASN.1 syntax. $Id$ Copyright (C) 2009 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ PulseOximeter DEFINITIONS ::= BEGIN -- -- Alert-Op-State attribute defines the current limit alert state -- NOTE: The bits refer to the limit alarm only, not to the global alert state of the metric -- CurLimAlStat ::= BIT STRING { lim-alert-off(0), -- if this bit is set, all alerts (both high and low) are off lim-low-off(1), -- low-limit violation detection is off lim-high-off(2) -- high-limit violation detection is off } (SIZE(16)) -- -- Current-Limits attribute -- CurLimAlVal ::= SEQUENCE { lower FLOAT-Type, upper FLOAT-Type } -- -- B.2 Alert-Op-Text-String attribute assigns individual labels to upper and lower alarm limit -- AlertOpTextString ::= SEQUENCE { lower-text OCTET STRING, upper-text OCTET STRING } PulseOxPulsChar ::= BIT STRING { pulse-qual-nominal(0), pulse-qual-marginal(1), pulse-qual-minimal(2), pulse-qual-unacceptable(3) } (SIZE(16)) PulseOxDevStat ::= BIT STRING { sensor-disconnected(0), sensor-malfunction(1), sensor-displaced(2), sensor-unsupported(3), sensor-off(4), sensor-interference(5), signal-searching(6), signal-pulse-questionable(7), signal-non-pulsatile(8), signal-erratic(9), signal-low-perfusion(10), signal-poor(11), signal-inadequate(12), signal-processing-irregularity(13), device-equipment-malfunction(14), device-extended-update(15) } (SIZE(16)) END biosig-2.3.3/biosig4c++/AUTHORS0000664000175000017500000000020014105434233016047 0ustar schloeglschloeglAlois Schloegl Christoph Eibel Christoph Schmidt-Hieber Clemens Brunner Jan Umer Stefan Soueiha Stoy Mihaylo Yaroslav Halchenko biosig-2.3.3/biosig4c++/R/0000775000175000017500000000000014105434245015213 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/R/Makefile.in0000664000175000017500000000042514105434233017256 0ustar schloeglschloegl BIOSIG4R_PKG = biosig_@PACKAGE_VERSION@.tar.gz build: $(BIOSIG4R_PKG) sload.so: sload.c R CMD SHLIB sload.c -I.. -L.. -lbiosig clean: rm *.o *.so *.gz $(BIOSIG4R_PKG) $(BIOSIG4R_PKG): R CMD build . R CMD check --as-cran $@ install: $(BIOSIG4R_PKG) R CMD INSTALL $< biosig-2.3.3/biosig4c++/R/sload.r0000664000175000017500000000323214105434233016475 0ustar schloeglschloegl# # Copyright (C) 2016,2019 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++/libbiosig) at http://biosig.sf.net/ # # 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 3 # of the License, 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, see . dyn.load("sload.so") #' Loads biomedical signal data #' #' @param filename name of biosig data file #' @param channel indicates which channel should be loaded, (default 0: indicaes all channels) #' @return matrix containing sample values sload <- function(filename, channel=0) { result <- .Call("sload", filename, channel=0) return(result) } #' @param filename name of biosig data file #' @return Header (or Meta-) information of data file in JSON format jsonHeader <- function(filename) { result <- .Call("jsonHeader", filename) return(result) } # Usage: # # read header information # library(rjson) # HDR = fromJSON(jsonHeader("../data/Newtest17-256.bdf")) # # # read data # data = sload("../data/Newtest17-256.bdf") # plot((1:nrow(data))/HDR$Samplingrate,data[,1],"l",xlab="time [s]",ylab=HDR$CHANNEL[[1]]$Label) biosig-2.3.3/biosig4c++/R/DESCRIPTION.in0000664000175000017500000000116414105434233017325 0ustar schloeglschloeglPackage: biosig Version: @PACKAGE_VERSION@ Date: 2020-08-22 Encoding: UTF-8 Title: Biomedical Signal Tools Authors@R: person("Alois", "Schlögl", role = c("aut", "cre"), email = "alois.schloegl@gmail.com", comment="https://orcid.org/0000-0002-5621-8100") Author: Alois Schlögl [aut, cre] Maintainer: Alois Schlögl Depends: R (>= 3.1.0) Suggests: Description: Import filter for about 50 different biomedical signals data formats. License: GPL (>= 3) URL: https://biosig.sourceforge.io, http://pub.ist.ac.at/~schloegl BugReports: https://sourceforge.net/projects/biosig/support biosig-2.3.3/biosig4c++/R/README0000664000175000017500000000274514105434233016100 0ustar schloeglschloegl = Introduction = This provides an interface of libbiosig to R. There are two ways to access biosig data. One approach is with loadgdf.r and biosig2gdf.exe, the other approach is by using a shared object library sload.so to libbiosig. = A) loadgdf and biosig2exe.gdf = loadgdf(filename) will use biosig2exe to load and convert the data into a GDF data stream, which is then parsed by loadgdf.r This approach is will work on all platforms for which biosig2exe is available. Especially, it will also work in MS Windows. = B) Installation and use of sload.so = This approach will work on all *nix operating systems (GNU/Linux, BSD, MacOSX, etc), but does not work on MS Windows. # 0) Requirements apt-get install r-base-dev # 1) Make sure libbiosig and libbiosig2 are installed make -C .. && sudo make -C .. install # 2) Compile R binding make # or R CMD SHLIB sload.c -lbiosig # 3) Use of sload in R dyn.load("sload.so") sload <- function(filename,channels=0) { result <- .Call("sload", filename, channels=0) return(result) } jsonHeader <- function(filename) { result <- .Call("jsonHeader", filename) return(result) } jsonHeader("filename.gdf") # read header information library(rjson) HDR = fromJSON(jsonHeader("../data/Newtest17-256.bdf")) # read data data = sload("../data/Newtest17-256.bdf") plot((1:nrow(data))/HDR$Samplingrate,data[,1],"l",xlab="time [s]",ylab=HDR$CHANNEL[[1]]$Label) biosig-2.3.3/biosig4c++/R/Makefile0000664000175000017500000000041114105434245016647 0ustar schloeglschloegl BIOSIG4R_PKG = biosig_2.3.3.tar.gz build: $(BIOSIG4R_PKG) sload.so: sload.c R CMD SHLIB sload.c -I.. -L.. -lbiosig clean: rm *.o *.so *.gz $(BIOSIG4R_PKG) $(BIOSIG4R_PKG): R CMD build . R CMD check --as-cran $@ install: $(BIOSIG4R_PKG) R CMD INSTALL $< biosig-2.3.3/biosig4c++/R/DESCRIPTION0000664000175000017500000000115014105434245016716 0ustar schloeglschloeglPackage: biosig Version: 2.3.3 Date: 2020-08-22 Encoding: UTF-8 Title: Biomedical Signal Tools Authors@R: person("Alois", "Schlögl", role = c("aut", "cre"), email = "alois.schloegl@gmail.com", comment="https://orcid.org/0000-0002-5621-8100") Author: Alois Schlögl [aut, cre] Maintainer: Alois Schlögl Depends: R (>= 3.1.0) Suggests: Description: Import filter for about 50 different biomedical signals data formats. License: GPL (>= 3) URL: https://biosig.sourceforge.io, http://pub.ist.ac.at/~schloegl BugReports: https://sourceforge.net/projects/biosig/support biosig-2.3.3/biosig4c++/R/loadgdf.r0000664000175000017500000002547514105434233017010 0ustar schloeglschloegl# # Copyright (C) 2020,2021 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++/libbiosig) at http://biosig.sf.net/ # # 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 3 # of the License, 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, see . # References # https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/connections # https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/seek # https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/readBin # https://arxiv.org/abs/cs/0608052 setClass( "HeaderType", slots = list( # H1 VersionID = "numeric", # HeadLen = "numeric", EventTablePos = "numeric", NS = "numeric", # number of signals (i.e. channels) NRec = "numeric", # number of records (i.e. blocks) Dur = "numeric", # duration of a record SampleRate = "numeric", # sampling rate = SPR/Dur SPR = "numeric", # samples per record BPB = "numeric", # bytes per block T0 = "numeric", # Startdate and time Birthday = "numeric", # Birthday, date and time tzmin = "numeric", # timezone information, number of minutes east of UTC # H2 Label = "character", # channel label Transducer = "character", # transducer PhysDimCode = "numeric", # physical encoding PhysMin = "numeric", # physical minimum PhysMax = "numeric", # physical maximum DigMin = "numeric", # digital minimum DigMax = "numeric", # digital maximum Toffset = "numeric", # time offset of each channel LowPass = "numeric", # lowpass filter HighPass = "numeric", # highpass filter Notch = "numeric", # notch filter spr = "numeric", # samples per record in each channel GDFTYP = "numeric", # H3 # EventTable # data data = "matrix" ) ); GDFTYPE_BITS=as.integer(c( 8, 8, 8,16,16,32,32,64,64,32,64, 0, 0, 0, 0, 0, 32,64,128,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,10, 0,12, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0,32, 0, 0, 0, 0, 0, 0, 0,40, 0, 0, 0, 0, 0, 0, 0,48, 0, 0, 0, 0, 0, 0, 0,56, 0, 0, 0, 0, 0, 0, 0,64, 0, 0, 0, 0, 0, 0, 0,72, 0, 0, 0, 0, 0, 0, 0,80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,10, 0,12, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0,32, 0, 0, 0, 0, 0, 0, 0,40, 0, 0, 0, 0, 0, 0, 0,48, 0, 0, 0, 0, 0, 0, 0,56, 0, 0, 0, 0, 0, 0, 0,64, 0, 0, 0, 0, 0, 0, 0,72, 0, 0, 0, 0, 0, 0, 0,80 )); "%gcd%" <- function(u, v) {ifelse(u %% v != 0, v %gcd% (u%%v), v)} "%lcm%" <- function(u, v) { abs(u*v)/(u %gcd% v)} skipbytes <- function(fid, nbytes) { readBin(fid, "int", size=1, n=nbytes) } #' Loads biomedical signal data in GDF format #' #' @param filename name of the gdf data file #' @param channel indicates which channel(s) should be loaded, (default 0: indicaes all channels) #' @return HeaderType data HDR #' HDR@data is a matrix containing sample values with HDR@NS columns (i.e. channels) #' and HDR@NRec*HDR@SPR rows (sampling time points) #' HDR@SampleRate is the sampling rate #' HDR@Label contain the channel labels #' #' Usage: #' source('loadgdf.r') #' HDR=loadgdf(filename) # loads a biosig file #' uses biosig2gdf to convert and load any (supported) format #' HDR@Label # shows channel names #' HDR=loadgdf(..., 1) # loads 1st channel #' HDR=loadgdf(..., 2) # loads 2nd channel #' HDR=loadgdf(..., c(1,2)) # loads 1st and 2nd channel #' HDR@data contain the data samples loadgdf <- function(filename, chan=0) { TMPFILE <- tempfile("gdf", fileext='.gdf') myDir <- getSrcDirectory(function(x) {x}) if (.Platform$OS.type=="windows") { converter = file.path(myDir, "biosig2gdf.exe") } else { converter = "biosig2gdf" } status<-system2(converter, args=paste(filename, TMPFILE, sep=" ")) if (status) { print(status) print(errmsg) } fid <- file(TMPFILE, "rb") if (!isOpen(fid)) { stop("Cannot open file or pipe") } HDR <- new("HeaderType") ### read H1 - fixed header ### HDR@VersionID <- readBin(fid, "int", size=1, n=8) if (!all(HDR@VersionID[1:4] == c(0x47,0x44,0x46,0x20))) stop("This is not a GDF file - convert first to GDF - e.g. with save2gdf command line tool") skipbytes(fid, nbytes=168-8) t <- readBin(fid, "int", size=4, n=2, endian="little") HDR@T0 <- t[2]+t[1]*(2^-32) t <- readBin(fid, "int", size=4, n=2, endian="little") HDR@Birthday <- t[2]+t[1]*(2^-32) HeadLen <- readBin(fid, "int", size=2, signed=FALSE, endian="little")*256 skipbytes(fid, nbytes=236-184-2) HDR@NRec <- readBin(fid, "int", size=8, endian="little") HDR@Dur <- readBin(fid, "double", n=1, size=8, endian="little") HDR@NS <- readBin(fid, "int", size=2, signed=FALSE, endian="little") HDR@tzmin<- readBin(fid, "int", size=2, endian="little") # timezone in minutes east of UTC HDR@SPR <- 1 if (any(chan==0)) chan <- c(1:HDR@NS) ### read H2 - variable header, channel information ### for (k in c(1:HDR@NS)) { HDR@Label[k] <- readChar(fid, nchars=16, useBytes=TRUE) } for (k in c(1:HDR@NS)) { HDR@Transducer[k] <- readChar(fid, nchars=80, useBytes=TRUE) } skipbytes(fid, nbytes=(102-96)*HDR@NS) HDR@PhysDimCode<- readBin(fid, "int", size=2, n=HDR@NS, endian="little") HDR@PhysMin <- readBin(fid, "double", size=8, n=HDR@NS, endian="little") HDR@PhysMax <- readBin(fid, "double", size=8, n=HDR@NS, endian="little") HDR@DigMin <- readBin(fid, "double", size=8, n=HDR@NS, endian="little") HDR@DigMax <- readBin(fid, "double", size=8, n=HDR@NS, endian="little") skipbytes(fid, nbytes=(200-102-34)*HDR@NS) HDR@Toffset <- readBin(fid, "double", size=4, n=HDR@NS, endian="little") HDR@LowPass <- readBin(fid, "double", size=4, n=HDR@NS, endian="little") HDR@HighPass<- readBin(fid, "double", size=4, n=HDR@NS, endian="little") HDR@Notch <- readBin(fid, "double", size=4, n=HDR@NS, endian="little") HDR@spr <- readBin(fid, "int", size=4, n=HDR@NS, endian="little") for (v in unique(HDR@spr[chan])) HDR@SPR <- (HDR@SPR %lcm% v) HDR@SampleRate <- HDR@SPR / HDR@Dur HDR@GDFTYP <- readBin(fid, "int", size=4, n=HDR@NS, endian="little") HDR@BPB <- sum(GDFTYPE_BITS[HDR@GDFTYP+1] * HDR@spr)/8 bi <- c(0, cumsum(ceiling(GDFTYPE_BITS[HDR@GDFTYP+1]/8) * HDR@spr)) spb <- c(0, cumsum(HDR@spr)) Cal <- (HDR@PhysMax - HDR@PhysMin) / (HDR@DigMax - HDR@DigMin) Off <- HDR@PhysMin - Cal * HDR@DigMin HDR@EventTablePos <- HeadLen + HDR@BPB * HDR@NRec ### optional skipbytes(fid, nbytes=HeadLen-256-(200+24)*HDR@NS) if (all(HDR@GDFTYP==0)) { data <- readBin(fid, "int", size=1, n=HDR@BPB*HDR@NRec, endian="little") } else if (all(HDR@GDFTYP==1)) { data <- readBin(fid, "int", size=1, n=HDR@BPB*HDR@NRec, endian="little") } else if (all(HDR@GDFTYP==2)) { data <- readBin(fid, "int", size=1, signed=FALSE, n=HDR@BPB*HDR@NRec, endian="little") } else if (all(HDR@GDFTYP==3)) { data <- readBin(fid, "int", size=2, n=HDR@BPB*HDR@NRec/2, endian="little") } else if (all(HDR@GDFTYP==4)) { data <- readBin(fid, "int", size=2, signed=FALSE, n=HDR@BPB*HDR@NRec/2, endian="little") } else if (all(HDR@GDFTYP==5)) { data <- readBin(fid, "int", size=4, n=HDR@BPB*HDR@NRec/4, endian="little") } else if (all(HDR@GDFTYP==6)) { data <- readBin(fid, "int", size=2, signed=FALSE, n=HDR@BPB*HDR@NRec, endian="little") L=1:(length(data)/2); data = data[L*2-1] + 65536L * data[L*2] } else if (all(HDR@GDFTYP==7)) { data <- readBin(fid, "int", size=4, n=HDR@BPB*HDR@NRec/4, endian="little") } else if (all(HDR@GDFTYP==8)) { data <- readBin(fid, "int", size=2, signed=FALSE, n=HDR@BPB*HDR@NRec/2, endian="little") L=1:(length(data)/4); data = data[L*4-3] + 65536L*(data[L*4-2] + 65536L*(data[L*4-1] + 65536L*data[L*4])) } else if (all(HDR@GDFTYP==16)) { data <- readBin(fid, "double", size=4, n = HDR@BPB*HDR@NRec/4, endian="little") } else if (all(HDR@GDFTYP==17)) { data <- readBin(fid, "double", size=8, n = HDR@BPB*HDR@NRec/8, endian="little") } else if (all(HDR@GDFTYP==18)) { data <- readBin(fid, "double", size=16, n = HDR@BPB*HDR@NRec/16, endian="little") } else if (all(HDR@GDFTYP==(255+24))) { data <- readBin(fid, "int", size=1, signed=FALSE, n = HDR@BPB*HDR@NRec, endian="little") L = 1:(length(data) %/% 3) data = data[L*3-2] + 256L*(data[L*3-1] + 256L*data[L*3]) data = data - c(data>=2^23)*2^24 } else if (all(HDR@GDFTYP==(511+24))) { data <- readBin(fid, "int", size=1, signed=FALSE, n = HDR@BPB*HDR@NRec, endian="little") L = 1:(length(data) %/% 3) data = data[L*3-2] + 256L*(data[L*3-1] + 256L*data[L*3]) } else { stop("channels have different data types - this is not supported yet.") } k = 0; if (all(HDR@spr[chan[1]]==HDR@spr[chan])) { SPR <- HDR@spr[chan[1]] d <- matrix(data, nrow=sum(HDR@spr), byrow=FALSE) data <- matrix(c(1:(HDR@NRec * SPR * length(chan))), ncol=length(chan)) k = 0 for (ch in chan) { k = k+1; data[,k] = matrix(d[spb[ch]+c(1:HDR@spr[ch]),], ncol=1, byrow=FALSE) * Cal[ch] + Off[ch] } } else { stop("this file is currently not supported (channels have different sampling rates)") } # H3 <- readBin(fid, "raw", n=NS, size=256); ## seek EventTablePos HDR@data <- data close(fid) file.remove(TMPFILE) return(HDR) } biosig-2.3.3/biosig4c++/R/sload.c0000664000175000017500000000452014105434233016457 0ustar schloeglschloegl/* Copyright (C) 2016,2019 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++/libbiosig) at http://biosig.sf.net/ 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 3 of the License, 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, see . References: https://cran.r-project.org/doc/manuals/R-exts.html */ #include #include #include #include SEXP sload(SEXP filename, SEXP channels) { // sanity check of input if(!isString(filename) || length(filename) != 1) error("filename is not a single string"); // Open file HDRTYPE *hdr = sopen(CHAR(asChar(filename)), "r", NULL); if (serror2(hdr)) return R_NilValue; long NS = biosig_get_number_of_channels(hdr); size_t SPR = biosig_get_number_of_samples(hdr); // allocate memory for results SEXP result = PROTECT(allocMatrix(REALSXP, SPR, NS)); // read data from file and write into result int status = sread(REAL(result), 0, SPR, hdr); if (serror2(hdr)) { destructHDR(hdr); Free(result); UNPROTECT(1); return R_NilValue; } // close file, and cleanup memory to avoid any leaks destructHDR(hdr); UNPROTECT(1); return result; } SEXP jsonHeader (SEXP filename) { // sanity check of input if(!isString(filename) || length(filename) != 1) error("filename is not a single string"); // Open file HDRTYPE *hdr = sopen(CHAR(asChar(filename)), "r", NULL); if (serror2(hdr)) return R_NilValue; // convert header to json-string SEXP result = R_NilValue; char *str = NULL; asprintf_hdr2json(&str, hdr); if (str != NULL) { result = PROTECT(allocVector(STRSXP, strlen(str)+1)); SET_STRING_ELT(result, 0, mkChar(str)); free(str); } // close file, and cleanup memory to avoid any leaks destructHDR(hdr); UNPROTECT(1); return result; } biosig-2.3.3/biosig4c++/mdc_ecg_codes.h0000664000175000017500000000341414105434233017720 0ustar schloeglschloegl/* % Copyright (C) 2014 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ /**************************************************************************** ** ** ** Conversion functions for encoded physical units according to ** ** ISO/IEEE 11073-10102 Annex B ** ** ** ****************************************************************************/ #ifndef __MDC_ECG_CODES_H__ #define __MDC_ECG_CODES_H__ #if defined(_MSC_VER) && (_MSC_VER < 1600) typedef unsigned __int16 uint16_t; #else #include #endif #ifdef __cplusplus extern "C" { #endif uint16_t encode_mdc_ecg_code10 (const char *IDstr); uint32_t encode_mdc_ecg_cfcode10 (const char *IDstr); const char* decode_mdc_ecg_code10 (uint16_t code10); const char* decode_mdc_ecg_cfcode10 (uint32_t cf_code10); #ifdef __cplusplus } #endif #endif /* __PHYSICALUNITS_H__ */ biosig-2.3.3/biosig4c++/rec2bin0000775000175000017500000000062014105434233016257 0ustar schloeglschloegl#!/bin/sh # REC2BIN converts data into ascii-Header and each channel into a separate binary data file # This can be useful for manually editing biosig files, and converting it back into GDF, EDF, etc. # # Copyright (C) 2008,2020 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ save2gdf -f=BIN $@ biosig-2.3.3/biosig4c++/11073-10102-AnnexB.i0000664000175000017500000014627214105434245017465 0ustar schloeglschloegl#if 0 ### This file is autogenerated - Do not modify it !!! ### # # Expanded terms with discriminators and numeric codes # obtained from IEEE Std 11073-10102-2012 # Health informatics—Point-of-care medical device communication # Part 10102: Nomenclature—Annotated ECG # # This table is also part of the specification of # the BioSig project http://biosig.sf.net/ # # BioSig 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 3 of the License, or (at your option) any later version. # # #PART CODE10 CF_CODE10 REFID #endif { 0, 0, "MDC_ECG_LEAD_CONFIG" }, { 1, 1, "MDC_ECG_LEAD_I" }, { 31, 31, "MDC_ECG_LEAD_dI" }, { 2, 2, "MDC_ECG_LEAD_II" }, { 32, 32, "MDC_ECG_LEAD_dII" }, { 3, 3, "MDC_ECG_LEAD_V1" }, { 33, 33, "MDC_ECG_LEAD_dV1" }, { 4, 4, "MDC_ECG_LEAD_V2" }, { 34, 34, "MDC_ECG_LEAD_dV2" }, { 5, 5, "MDC_ECG_LEAD_V3" }, { 35, 35, "MDC_ECG_LEAD_dV3" }, { 6, 6, "MDC_ECG_LEAD_V4" }, { 36, 36, "MDC_ECG_LEAD_dV4" }, { 7, 7, "MDC_ECG_LEAD_V5" }, { 37, 37, "MDC_ECG_LEAD_dV5" }, { 8, 8, "MDC_ECG_LEAD_V6" }, { 38, 38, "MDC_ECG_LEAD_dV6" }, { 9, 9, "MDC_ECG_LEAD_V7" }, { 39, 39, "MDC_ECG_LEAD_dV7" }, { 10, 10, "MDC_ECG_LEAD_V2R" }, { 40, 40, "MDC_ECG_LEAD_dV2R" }, { 11, 11, "MDC_ECG_LEAD_V3R" }, { 41, 41, "MDC_ECG_LEAD_dV3R" }, { 12, 12, "MDC_ECG_LEAD_V4R" }, { 42, 42, "MDC_ECG_LEAD_dV4R" }, { 13, 13, "MDC_ECG_LEAD_V5R" }, { 43, 43, "MDC_ECG_LEAD_dV5R" }, { 14, 14, "MDC_ECG_LEAD_V6R" }, { 44, 44, "MDC_ECG_LEAD_dV6R" }, { 15, 15, "MDC_ECG_LEAD_V7R" }, { 45, 45, "MDC_ECG_LEAD_dV7R" }, { 16, 16, "MDC_ECG_LEAD_X" }, { 46, 46, "MDC_ECG_LEAD_dX" }, { 17, 17, "MDC_ECG_LEAD_Y" }, { 47, 47, "MDC_ECG_LEAD_dY" }, { 18, 18, "MDC_ECG_LEAD_Z" }, { 48, 48, "MDC_ECG_LEAD_dZ" }, { 19, 19, "MDC_ECG_LEAD_CC5" }, { 49, 49, "MDC_ECG_LEAD_dCC5" }, { 20, 20, "MDC_ECG_LEAD_CM5" }, { 50, 50, "MDC_ECG_LEAD_dCM5" }, { 21, 21, "MDC_ECG_LEAD_LA" }, { 51, 51, "MDC_ECG_LEAD_dLA" }, { 22, 22, "MDC_ECG_LEAD_RA" }, { 52, 52, "MDC_ECG_LEAD_dRA" }, { 23, 23, "MDC_ECG_LEAD_LL" }, { 53, 53, "MDC_ECG_LEAD_dLL" }, { 24, 24, "MDC_ECG_LEAD_fI" }, { 54, 54, "MDC_ECG_LEAD_dfI" }, { 25, 25, "MDC_ECG_LEAD_fE" }, { 55, 55, "MDC_ECG_LEAD_dfE" }, { 26, 26, "MDC_ECG_LEAD_fC" }, { 56, 56, "MDC_ECG_LEAD_dfC" }, { 27, 27, "MDC_ECG_LEAD_fA" }, { 57, 57, "MDC_ECG_LEAD_dfA" }, { 28, 28, "MDC_ECG_LEAD_fM" }, { 58, 58, "MDC_ECG_LEAD_dfM" }, { 29, 29, "MDC_ECG_LEAD_fF" }, { 59, 59, "MDC_ECG_LEAD_dfF" }, { 30, 30, "MDC_ECG_LEAD_fH" }, { 60, 60, "MDC_ECG_LEAD_dfH" }, { 61, 61, "MDC_ECG_LEAD_III" }, { 111, 111, "MDC_ECG_LEAD_dIII" }, { 62, 62, "MDC_ECG_LEAD_AVR" }, { 112, 112, "MDC_ECG_LEAD_dAVR" }, { 63, 63, "MDC_ECG_LEAD_AVL" }, { 113, 113, "MDC_ECG_LEAD_dAVL" }, { 64, 64, "MDC_ECG_LEAD_AVF" }, { 114, 114, "MDC_ECG_LEAD_dAVF" }, { 65, 65, "MDC_ECG_LEAD_AVRneg" }, { 115, 115, "MDC_ECG_LEAD_dAVRneg" }, { 66, 66, "MDC_ECG_LEAD_V8" }, { 79, 79, "MDC_ECG_LEAD_dV8" }, { 67, 67, "MDC_ECG_LEAD_V9" }, { 80, 80, "MDC_ECG_LEAD_dV9" }, { 68, 68, "MDC_ECG_LEAD_V8R" }, { 81, 81, "MDC_ECG_LEAD_dV8R" }, { 69, 69, "MDC_ECG_LEAD_V9R" }, { 82, 82, "MDC_ECG_LEAD_dV9R" }, { 70, 70, "MDC_ECG_LEAD_D" }, { 83, 83, "MDC_ECG_LEAD_dD" }, { 71, 71, "MDC_ECG_LEAD_A" }, { 84, 84, "MDC_ECG_LEAD_dA" }, { 72, 72, "MDC_ECG_LEAD_J" }, { 85, 85, "MDC_ECG_LEAD_dJ" }, { 73, 73, "MDC_ECG_LEAD_DEFIB" }, { 135, 135, "MDC_ECG_LEAD_dDEFIB" }, { 74, 74, "MDC_ECG_LEAD_EXTERN" }, { 136, 136, "MDC_ECG_LEAD_dEXTERN" }, { 75, 75, "MDC_ECG_LEAD_A1" }, { 137, 137, "MDC_ECG_LEAD_dA1" }, { 76, 76, "MDC_ECG_LEAD_A2" }, { 138, 138, "MDC_ECG_LEAD_dA2" }, { 77, 77, "MDC_ECG_LEAD_A3" }, { 139, 139, "MDC_ECG_LEAD_dA3" }, { 78, 78, "MDC_ECG_LEAD_A4" }, { 140, 140, "MDC_ECG_LEAD_dA4" }, { 86, 86, "MDC_ECG_LEAD_C" }, { 116, 116, "MDC_ECG_LEAD_dC" }, { 87, 87, "MDC_ECG_LEAD_V" }, { 117, 117, "MDC_ECG_LEAD_dV" }, { 88, 88, "MDC_ECG_LEAD_VR" }, { 118, 118, "MDC_ECG_LEAD_dVR" }, { 89, 89, "MDC_ECG_LEAD_VL" }, { 119, 119, "MDC_ECG_LEAD_dVL" }, { 90, 90, "MDC_ECG_LEAD_VF" }, { 120, 120, "MDC_ECG_LEAD_dVF" }, { 91, 91, "MDC_ECG_LEAD_MCL" }, { 152, 152, "MDC_ECG_LEAD_dMCL" }, { 92, 92, "MDC_ECG_LEAD_MCL1" }, { 141, 141, "MDC_ECG_LEAD_dMCL1" }, { 93, 93, "MDC_ECG_LEAD_MCL2" }, { 142, 142, "MDC_ECG_LEAD_dMCL2" }, { 94, 94, "MDC_ECG_LEAD_MCL3" }, { 143, 143, "MDC_ECG_LEAD_dMCL3" }, { 95, 95, "MDC_ECG_LEAD_MCL4" }, { 144, 144, "MDC_ECG_LEAD_dMCL4" }, { 96, 96, "MDC_ECG_LEAD_MCL5" }, { 145, 145, "MDC_ECG_LEAD_dMCL5" }, { 97, 97, "MDC_ECG_LEAD_MCL6" }, { 146, 146, "MDC_ECG_LEAD_dMCL6" }, { 98, 98, "MDC_ECG_LEAD_CC" }, { 153, 153, "MDC_ECG_LEAD_dCC" }, { 99, 99, "MDC_ECG_LEAD_CC1" }, { 154, 154, "MDC_ECG_LEAD_dCC1" }, { 100, 100, "MDC_ECG_LEAD_CC2" }, { 155, 155, "MDC_ECG_LEAD_dCC2" }, { 101, 101, "MDC_ECG_LEAD_CC3" }, { 156, 156, "MDC_ECG_LEAD_dCC3" }, { 102, 102, "MDC_ECG_LEAD_CC4" }, { 157, 157, "MDC_ECG_LEAD_dCC4" }, { 103, 103, "MDC_ECG_LEAD_CC6" }, { 158, 158, "MDC_ECG_LEAD_dCC6" }, { 104, 104, "MDC_ECG_LEAD_CC7" }, { 159, 159, "MDC_ECG_LEAD_dCC7" }, { 105, 105, "MDC_ECG_LEAD_CM" }, { 160, 160, "MDC_ECG_LEAD_dCM" }, { 106, 106, "MDC_ECG_LEAD_CM1" }, { 161, 161, "MDC_ECG_LEAD_dCM1" }, { 107, 107, "MDC_ECG_LEAD_CM2" }, { 162, 162, "MDC_ECG_LEAD_dCM2" }, { 108, 108, "MDC_ECG_LEAD_CM3" }, { 163, 163, "MDC_ECG_LEAD_dCM3" }, { 109, 109, "MDC_ECG_LEAD_CM4" }, { 164, 164, "MDC_ECG_LEAD_dCM4" }, { 110, 110, "MDC_ECG_LEAD_CM6" }, { 165, 165, "MDC_ECG_LEAD_dCM6" }, { 121, 121, "MDC_ECG_LEAD_CM7" }, { 166, 166, "MDC_ECG_LEAD_dCM7" }, { 122, 122, "MDC_ECG_LEAD_CH5" }, { 167, 167, "MDC_ECG_LEAD_dCH5" }, { 123, 123, "MDC_ECG_LEAD_CS5" }, { 168, 168, "MDC_ECG_LEAD_dCS5" }, { 124, 124, "MDC_ECG_LEAD_CB5" }, { 169, 169, "MDC_ECG_LEAD_dCB5" }, { 125, 125, "MDC_ECG_LEAD_CR5" }, { 170, 170, "MDC_ECG_LEAD_dCR5" }, { 126, 126, "MDC_ECG_LEAD_ML" }, { 171, 171, "MDC_ECG_LEAD_dML" }, { 127, 127, "MDC_ECG_LEAD_AB1" }, { 172, 172, "MDC_ECG_LEAD_dAB1" }, { 128, 128, "MDC_ECG_LEAD_AB2" }, { 173, 173, "MDC_ECG_LEAD_dAB2" }, { 129, 129, "MDC_ECG_LEAD_AB3" }, { 174, 174, "MDC_ECG_LEAD_dAB3" }, { 130, 130, "MDC_ECG_LEAD_AB4" }, { 175, 175, "MDC_ECG_LEAD_dAB4" }, { 131, 131, "MDC_ECG_LEAD_ES" }, { 176, 176, "MDC_ECG_LEAD_dES" }, { 132, 132, "MDC_ECG_LEAD_AS" }, { 177, 177, "MDC_ECG_LEAD_dAS" }, { 133, 133, "MDC_ECG_LEAD_AI" }, { 178, 178, "MDC_ECG_LEAD_dAI" }, { 134, 134, "MDC_ECG_LEAD_S" }, { 179, 179, "MDC_ECG_LEAD_dS" }, { 147, 147, "MDC_ECG_LEAD_RL" }, { 180, 180, "MDC_ECG_LEAD_dRL" }, { 148, 148, "MDC_ECG_LEAD_CV5RL" }, { 181, 181, "MDC_ECG_LEAD_dCV5RL" }, { 149, 149, "MDC_ECG_LEAD_CV6LL" }, { 182, 182, "MDC_ECG_LEAD_dCV6LL" }, { 150, 150, "MDC_ECG_LEAD_CV6LU" }, { 183, 183, "MDC_ECG_LEAD_dCV6LU" }, { 151, 151, "MDC_ECG_LEAD_V10" }, { 184, 184, "MDC_ECG_LEAD_dV10" }, { 256, 655616, "MDC_ECG_WAVC_PWAVE" }, { 257, 655617, "MDC_ECG_WAVC_PWAVE_TIME_POINT" }, { 258, 655618, "MDC_ECG_WAVC_PWAVE_DURN" }, { 259, 655619, "MDC_ECG_WAVC_PWAVE_PEAK" }, { 260, 655620, "MDC_ECG_WAVC_PWAVE_ONSET" }, { 261, 655621, "MDC_ECG_WAVC_PWAVE_OFFSET" }, { 262, 655622, "MDC_ECG_WAVC_PWAVE_ONSET_IMPL" }, { 263, 655623, "MDC_ECG_WAVC_PWAVE_OFFSET_IMPL" }, { 264, 655624, "MDC_ECG_WAVC_PWAVE_AREA" }, { 265, 655625, "MDC_ECG_WAVC_PWAVE_INTEGRAL" }, { 272, 655632, "MDC_ECG_WAVC_PWAVE_NA" }, { 273, 655633, "MDC_ECG_WAVC_PWAVE_NA_TIME_POINT" }, { 274, 655634, "MDC_ECG_WAVC_PWAVE_NA_DURN" }, { 275, 655635, "MDC_ECG_WAVC_PWAVE_NA_PEAK" }, { 276, 655636, "MDC_ECG_WAVC_PWAVE_NA_ONSET" }, { 277, 655637, "MDC_ECG_WAVC_PWAVE_NA_OFFSET" }, { 278, 655638, "MDC_ECG_WAVC_PWAVE_NA_ONSET_IMPL" }, { 279, 655639, "MDC_ECG_WAVC_PWAVE_NA_OFFSET_IMPL" }, { 280, 655640, "MDC_ECG_WAVC_PWAVE_NA_AREA" }, { 281, 655641, "MDC_ECG_WAVC_PWAVE_NA_INTEGRAL" }, { 288, 655648, "MDC_ECG_WAVC_PWAVE_FB" }, { 289, 655649, "MDC_ECG_WAVC_PWAVE_FB_TIME_POINT" }, { 290, 655650, "MDC_ECG_WAVC_PWAVE_FB_DURN" }, { 291, 655651, "MDC_ECG_WAVC_PWAVE_FB_PEAK" }, { 292, 655652, "MDC_ECG_WAVC_PWAVE_FB_ONSET" }, { 293, 655653, "MDC_ECG_WAVC_PWAVE_FB_OFFSET" }, { 294, 655654, "MDC_ECG_WAVC_PWAVE_FB_ONSET_IMPL" }, { 295, 655655, "MDC_ECG_WAVC_PWAVE_FB_OFFSET_IMPL" }, { 296, 655656, "MDC_ECG_WAVC_PWAVE_FB_AREA" }, { 297, 655657, "MDC_ECG_WAVC_PWAVE_FB_INTEGRAL" }, { 304, 655664, "MDC_ECG_WAVC_PWAVE_PB" }, { 305, 655665, "MDC_ECG_WAVC_PWAVE_PB_TIME_POINT" }, { 306, 655666, "MDC_ECG_WAVC_PWAVE_PB_DURN" }, { 307, 655667, "MDC_ECG_WAVC_PWAVE_PB_PEAK" }, { 308, 655668, "MDC_ECG_WAVC_PWAVE_PB_ONSET" }, { 309, 655669, "MDC_ECG_WAVC_PWAVE_PB_OFFSET" }, { 310, 655670, "MDC_ECG_WAVC_PWAVE_PB_ONSET_IMPL" }, { 311, 655671, "MDC_ECG_WAVC_PWAVE_PB_OFFSET_IMPL" }, { 312, 655672, "MDC_ECG_WAVC_PWAVE_PB_AREA" }, { 313, 655673, "MDC_ECG_WAVC_PWAVE_PB_INTEGRAL" }, { 320, 655680, "MDC_ECG_WAVC_PPWAVE" }, { 384, 655744, "MDC_ECG_WAVC_PPPWAVE" }, { 448, 655808, "MDC_ECG_WAVC_QWAVE" }, { 512, 655872, "MDC_ECG_WAVC_QSWAVE" }, { 576, 655936, "MDC_ECG_WAVC_RWAVE" }, { 640, 656000, "MDC_ECG_WAVC_RRWAVE" }, { 704, 656064, "MDC_ECG_WAVC_RRRWAVE" }, { 768, 656128, "MDC_ECG_WAVC_NOTCH" }, { 832, 656192, "MDC_ECG_WAVC_SWAVE" }, { 896, 656256, "MDC_ECG_WAVC_SSWAVE" }, { 960, 656320, "MDC_ECG_WAVC_SSSWAVE" }, { 1024, 656384, "MDC_ECG_WAVC_TWAVE" }, { 1088, 656448, "MDC_ECG_WAVC_TTWAVE" }, { 1152, 656512, "MDC_ECG_WAVC_UWAVE" }, { 1216, 656576, "MDC_ECG_WAVC_DELTA" }, { 1280, 656640, "MDC_ECG_WAVC_IWAVE" }, { 1344, 656704, "MDC_ECG_WAVC_KWAVE" }, { 1408, 656768, "MDC_ECG_WAVC_JWAVE" }, { 1472, 656832, "MDC_ECG_WAVC_PQRSTWAVE" }, { 1536, 656896, "MDC_ECG_WAVC_QRSTWAVE" }, { 1600, 656960, "MDC_ECG_WAVC_QRSWAVE" }, { 1664, 657024, "MDC_ECG_WAVC_TUWAVE" }, { 1728, 657088, "MDC_ECG_WAVC_VFLWAVE" }, { 1792, 657152, "MDC_ECG_WAVC_AFLWAVE" }, { 1856, 657216, "MDC_ECG_WAVC_ISO" }, { 1920, 657280, "MDC_ECG_WAVC_PRSEG" }, { 1984, 657344, "MDC_ECG_WAVC_STSEG" }, { 2048, 657408, "MDC_ECG_WAVC_STJ" }, { 2112, 657472, "MDC_ECG_WAVC_STM" }, { 2176, 657536, "MDC_ECG_WAVC_ARFCT" }, { 2240, 657600, "MDC_ECG_WAVC_CALP" }, { 2304, 657664, "MDC_ECG_WAVC_STCH" }, { 2368, 657728, "MDC_ECG_WAVC_TCH" }, { 2432, 657792, "MDC_ECG_WAVC_VAT" }, { 4096, 659456, "MDC_ECG_WAVP_PACE" }, { 4097, 659457, "MDC_ECG_WAVP_PACE_TIME_POINT" }, { 4098, 659458, "MDC_ECG_WAVP_PACE_DURN" }, { 4099, 659459, "MDC_ECG_WAVP_PACE_PEAK" }, { 4100, 659460, "MDC_ECG_WAVP_PACE_ONSET" }, { 4101, 659461, "MDC_ECG_WAVP_PACE_OFFSET" }, { 4102, 659462, "MDC_ECG_WAVP_PACE_ONSET_IMPL" }, { 4103, 659463, "MDC_ECG_WAVP_PACE_OFFSET_IMPL" }, { 4104, 659464, "MDC_ECG_WAVP_PACE_AREA" }, { 4105, 659465, "MDC_ECG_WAVP_PACE_INTEGRAL" }, { 4112, 659472, "MDC_ECG_WAVP_PACE_NC" }, { 4113, 659473, "MDC_ECG_WAVP_PACE_NC_TIME_POINT" }, { 4114, 659474, "MDC_ECG_WAVP_PACE_NC_DURN" }, { 4115, 659475, "MDC_ECG_WAVP_PACE_NC_PEAK" }, { 4116, 659476, "MDC_ECG_WAVP_PACE_NC_ONSET" }, { 4117, 659477, "MDC_ECG_WAVP_PACE_NC_OFFSET" }, { 4118, 659478, "MDC_ECG_WAVP_PACE_NC_ONSET_IMPL" }, { 4119, 659479, "MDC_ECG_WAVP_PACE_NC_OFFSET_IMPL" }, { 4120, 659480, "MDC_ECG_WAVP_PACE_NC_AREA" }, { 4121, 659481, "MDC_ECG_WAVP_PACE_NC_INTEGRAL" }, { 4128, 659488, "MDC_ECG_WAVP_PACE_C" }, { 4129, 659489, "MDC_ECG_WAVP_PACE_C_TIME_POINT" }, { 4130, 659490, "MDC_ECG_WAVP_PACE_C_DURN" }, { 4131, 659491, "MDC_ECG_WAVP_PACE_C_PEAK" }, { 4132, 659492, "MDC_ECG_WAVP_PACE_C_ONSET" }, { 4133, 659493, "MDC_ECG_WAVP_PACE_C_OFFSET" }, { 4134, 659494, "MDC_ECG_WAVP_PACE_C_ONSET_IMPL" }, { 4135, 659495, "MDC_ECG_WAVP_PACE_C_OFFSET_IMPL" }, { 4136, 659496, "MDC_ECG_WAVP_PACE_C_AREA" }, { 4137, 659497, "MDC_ECG_WAVP_PACE_C_INTEGRAL" }, { 4144, 659504, "MDC_ECG_WAVP_PACE_FSN" }, { 4145, 659505, "MDC_ECG_WAVP_PACE_FSN_TIME_POINT" }, { 4146, 659506, "MDC_ECG_WAVP_PACE_FSN_DURN" }, { 4147, 659507, "MDC_ECG_WAVP_PACE_FSN_PEAK" }, { 4148, 659508, "MDC_ECG_WAVP_PACE_FSN_ONSET" }, { 4149, 659509, "MDC_ECG_WAVP_PACE_FSN_OFFSET" }, { 4150, 659510, "MDC_ECG_WAVP_PACE_FSN_ONSET_IMPL" }, { 4151, 659511, "MDC_ECG_WAVP_PACE_FSN_OFFSET_IMPL" }, { 4152, 659512, "MDC_ECG_WAVP_PACE_FSN_AREA" }, { 4153, 659513, "MDC_ECG_WAVP_PACE_FSN_INTEGRAL" }, { 4160, 659520, "MDC_ECG_WAVP_PACE_APPR" }, { 4161, 659521, "MDC_ECG_WAVP_PACE_APPR_TIME_POINT" }, { 4162, 659522, "MDC_ECG_WAVP_PACE_APPR_DURN" }, { 4163, 659523, "MDC_ECG_WAVP_PACE_APPR_PEAK" }, { 4164, 659524, "MDC_ECG_WAVP_PACE_APPR_ONSET" }, { 4165, 659525, "MDC_ECG_WAVP_PACE_APPR_OFFSET" }, { 4166, 659526, "MDC_ECG_WAVP_PACE_APPR_ONSET_IMPL" }, { 4167, 659527, "MDC_ECG_WAVP_PACE_APPR_OFFSET_IMPL" }, { 4168, 659528, "MDC_ECG_WAVP_PACE_APPR_AREA" }, { 4169, 659529, "MDC_ECG_WAVP_PACE_APPR_INTEGRAL" }, { 4176, 659536, "MDC_ECG_WAVP_PACE_APPR_NC" }, { 4177, 659537, "MDC_ECG_WAVP_PACE_APPR_NC_TIME_POINT" }, { 4178, 659538, "MDC_ECG_WAVP_PACE_APPR_NC_DURN" }, { 4179, 659539, "MDC_ECG_WAVP_PACE_APPR_NC_PEAK" }, { 4180, 659540, "MDC_ECG_WAVP_PACE_APPR_NC_ONSET" }, { 4181, 659541, "MDC_ECG_WAVP_PACE_APPR_NC_OFFSET" }, { 4182, 659542, "MDC_ECG_WAVP_PACE_APPR_NC_ONSET_IMPL" }, { 4183, 659543, "MDC_ECG_WAVP_PACE_APPR_NC_OFFSET_IMPL" }, { 4184, 659544, "MDC_ECG_WAVP_PACE_APPR_NC_AREA" }, { 4185, 659545, "MDC_ECG_WAVP_PACE_APPR_NC_INTEGRAL" }, { 4192, 659552, "MDC_ECG_WAVP_PACE_APPR_C" }, { 4193, 659553, "MDC_ECG_WAVP_PACE_APPR_C_TIME_POINT" }, { 4194, 659554, "MDC_ECG_WAVP_PACE_APPR_C_DURN" }, { 4195, 659555, "MDC_ECG_WAVP_PACE_APPR_C_PEAK" }, { 4196, 659556, "MDC_ECG_WAVP_PACE_APPR_C_ONSET" }, { 4197, 659557, "MDC_ECG_WAVP_PACE_APPR_C_OFFSET" }, { 4198, 659558, "MDC_ECG_WAVP_PACE_APPR_C_ONSET_IMPL" }, { 4199, 659559, "MDC_ECG_WAVP_PACE_APPR_C_OFFSET_IMPL" }, { 4200, 659560, "MDC_ECG_WAVP_PACE_APPR_C_AREA" }, { 4201, 659561, "MDC_ECG_WAVP_PACE_APPR_C_INTEGRAL" }, { 4208, 659568, "MDC_ECG_WAVP_PACE_APPR_FSN" }, { 4209, 659569, "MDC_ECG_WAVP_PACE_APPR_FSN_TIME_POINT" }, { 4210, 659570, "MDC_ECG_WAVP_PACE_APPR_FSN_DURN" }, { 4211, 659571, "MDC_ECG_WAVP_PACE_APPR_FSN_PEAK" }, { 4212, 659572, "MDC_ECG_WAVP_PACE_APPR_FSN_ONSET" }, { 4213, 659573, "MDC_ECG_WAVP_PACE_APPR_FSN_OFFSET" }, { 4214, 659574, "MDC_ECG_WAVP_PACE_APPR_FSN_ONSET_IMPL" }, { 4215, 659575, "MDC_ECG_WAVP_PACE_APPR_FSN_OFFSET_IMPL" }, { 4216, 659576, "MDC_ECG_WAVP_PACE_APPR_FSN_AREA" }, { 4217, 659577, "MDC_ECG_WAVP_PACE_APPR_FSN_INTEGRAL" }, { 4224, 659584, "MDC_ECG_WAVP_PACE_INAPPR" }, { 4225, 659585, "MDC_ECG_WAVP_PACE_INAPPR_TIME_POINT" }, { 4226, 659586, "MDC_ECG_WAVP_PACE_INAPPR_DURN" }, { 4227, 659587, "MDC_ECG_WAVP_PACE_INAPPR_PEAK" }, { 4228, 659588, "MDC_ECG_WAVP_PACE_INAPPR_ONSET" }, { 4229, 659589, "MDC_ECG_WAVP_PACE_INAPPR_OFFSET" }, { 4230, 659590, "MDC_ECG_WAVP_PACE_INAPPR_ONSET_IMPL" }, { 4231, 659591, "MDC_ECG_WAVP_PACE_INAPPR_OFFSET_IMPL" }, { 4232, 659592, "MDC_ECG_WAVP_PACE_INAPPR_AREA" }, { 4233, 659593, "MDC_ECG_WAVP_PACE_INAPPR_INTEGRAL" }, { 4240, 659600, "MDC_ECG_WAVP_PACE_INAPPR_NC" }, { 4241, 659601, "MDC_ECG_WAVP_PACE_INAPPR_NC_TIME_POINT" }, { 4242, 659602, "MDC_ECG_WAVP_PACE_INAPPR_NC_DURN" }, { 4243, 659603, "MDC_ECG_WAVP_PACE_INAPPR_NC_PEAK" }, { 4244, 659604, "MDC_ECG_WAVP_PACE_INAPPR_NC_ONSET" }, { 4245, 659605, "MDC_ECG_WAVP_PACE_INAPPR_NC_OFFSET" }, { 4246, 659606, "MDC_ECG_WAVP_PACE_INAPPR_NC_ONSET_IMPL" }, { 4247, 659607, "MDC_ECG_WAVP_PACE_INAPPR_NC_OFFSET_IMPL" }, { 4248, 659608, "MDC_ECG_WAVP_PACE_INAPPR_NC_AREA" }, { 4249, 659609, "MDC_ECG_WAVP_PACE_INAPPR_NC_INTEGRAL" }, { 4256, 659616, "MDC_ECG_WAVP_PACE_INAPPR_C" }, { 4257, 659617, "MDC_ECG_WAVP_PACE_INAPPR_C_TIME_POINT" }, { 4258, 659618, "MDC_ECG_WAVP_PACE_INAPPR_C_DURN" }, { 4259, 659619, "MDC_ECG_WAVP_PACE_INAPPR_C_PEAK" }, { 4260, 659620, "MDC_ECG_WAVP_PACE_INAPPR_C_ONSET" }, { 4261, 659621, "MDC_ECG_WAVP_PACE_INAPPR_C_OFFSET" }, { 4262, 659622, "MDC_ECG_WAVP_PACE_INAPPR_C_ONSET_IMPL" }, { 4263, 659623, "MDC_ECG_WAVP_PACE_INAPPR_C_OFFSET_IMPL" }, { 4264, 659624, "MDC_ECG_WAVP_PACE_INAPPR_C_AREA" }, { 4265, 659625, "MDC_ECG_WAVP_PACE_INAPPR_C_INTEGRAL" }, { 4272, 659632, "MDC_ECG_WAVP_PACE_INAPPR_FSN" }, { 4273, 659633, "MDC_ECG_WAVP_PACE_INAPPR_FSN_TIME_POINT" }, { 4274, 659634, "MDC_ECG_WAVP_PACE_INAPPR_FSN_DURN" }, { 4275, 659635, "MDC_ECG_WAVP_PACE_INAPPR_FSN_PEAK" }, { 4276, 659636, "MDC_ECG_WAVP_PACE_INAPPR_FSN_ONSET" }, { 4277, 659637, "MDC_ECG_WAVP_PACE_INAPPR_FSN_OFFSET" }, { 4278, 659638, "MDC_ECG_WAVP_PACE_INAPPR_FSN_ONSET_IMPL" }, { 4279, 659639, "MDC_ECG_WAVP_PACE_INAPPR_FSN_OFFSET_IMPL" }, { 4280, 659640, "MDC_ECG_WAVP_PACE_INAPPR_FSN_AREA" }, { 4281, 659641, "MDC_ECG_WAVP_PACE_INAPPR_FSN_INTEGRAL" }, { 4288, 659648, "MDC_ECG_WAVP_PACE_EXCP" }, { 4289, 659649, "MDC_ECG_WAVP_PACE_EXCP_TIME_POINT" }, { 4290, 659650, "MDC_ECG_WAVP_PACE_EXCP_DURN" }, { 4291, 659651, "MDC_ECG_WAVP_PACE_EXCP_PEAK" }, { 4292, 659652, "MDC_ECG_WAVP_PACE_EXCP_ONSET" }, { 4293, 659653, "MDC_ECG_WAVP_PACE_EXCP_OFFSET" }, { 4294, 659654, "MDC_ECG_WAVP_PACE_EXCP_ONSET_IMPL" }, { 4295, 659655, "MDC_ECG_WAVP_PACE_EXCP_OFFSET_IMPL" }, { 4296, 659656, "MDC_ECG_WAVP_PACE_EXCP_AREA" }, { 4297, 659657, "MDC_ECG_WAVP_PACE_EXCP_INTEGRAL" }, { 4304, 659664, "MDC_ECG_WAVP_PACE_EXCP_NC" }, { 4305, 659665, "MDC_ECG_WAVP_PACE_EXCP_NC_TIME_POINT" }, { 4306, 659666, "MDC_ECG_WAVP_PACE_EXCP_NC_DURN" }, { 4307, 659667, "MDC_ECG_WAVP_PACE_EXCP_NC_PEAK" }, { 4308, 659668, "MDC_ECG_WAVP_PACE_EXCP_NC_ONSET" }, { 4309, 659669, "MDC_ECG_WAVP_PACE_EXCP_NC_OFFSET" }, { 4310, 659670, "MDC_ECG_WAVP_PACE_EXCP_NC_ONSET_IMPL" }, { 4311, 659671, "MDC_ECG_WAVP_PACE_EXCP_NC_OFFSET_IMPL" }, { 4312, 659672, "MDC_ECG_WAVP_PACE_EXCP_NC_AREA" }, { 4313, 659673, "MDC_ECG_WAVP_PACE_EXCP_NC_INTEGRAL" }, { 4320, 659680, "MDC_ECG_WAVP_PACE_EXCP_C" }, { 4321, 659681, "MDC_ECG_WAVP_PACE_EXCP_C_TIME_POINT" }, { 4322, 659682, "MDC_ECG_WAVP_PACE_EXCP_C_DURN" }, { 4323, 659683, "MDC_ECG_WAVP_PACE_EXCP_C_PEAK" }, { 4324, 659684, "MDC_ECG_WAVP_PACE_EXCP_C_ONSET" }, { 4325, 659685, "MDC_ECG_WAVP_PACE_EXCP_C_OFFSET" }, { 4326, 659686, "MDC_ECG_WAVP_PACE_EXCP_C_ONSET_IMPL" }, { 4327, 659687, "MDC_ECG_WAVP_PACE_EXCP_C_OFFSET_IMPL" }, { 4328, 659688, "MDC_ECG_WAVP_PACE_EXCP_C_AREA" }, { 4329, 659689, "MDC_ECG_WAVP_PACE_EXCP_C_INTEGRAL" }, { 4336, 659696, "MDC_ECG_WAVP_PACE_EXCP_FSN" }, { 4337, 659697, "MDC_ECG_WAVP_PACE_EXCP_FSN_TIME_POINT" }, { 4338, 659698, "MDC_ECG_WAVP_PACE_EXCP_FSN_DURN" }, { 4339, 659699, "MDC_ECG_WAVP_PACE_EXCP_FSN_PEAK" }, { 4340, 659700, "MDC_ECG_WAVP_PACE_EXCP_FSN_ONSET" }, { 4341, 659701, "MDC_ECG_WAVP_PACE_EXCP_FSN_OFFSET" }, { 4342, 659702, "MDC_ECG_WAVP_PACE_EXCP_FSN_ONSET_IMPL" }, { 4343, 659703, "MDC_ECG_WAVP_PACE_EXCP_FSN_OFFSET_IMPL" }, { 4344, 659704, "MDC_ECG_WAVP_PACE_EXCP_FSN_AREA" }, { 4345, 659705, "MDC_ECG_WAVP_PACE_EXCP_FSN_INTEGRAL" }, { 4352, 659712, "MDC_ECG_WAVP_PACE_ATR" }, { 4608, 659968, "MDC_ECG_WAVP_PACE_ATR_R" }, { 4864, 660224, "MDC_ECG_WAVP_PACE_ATR_L" }, { 5120, 660480, "MDC_ECG_WAVP_PACE_V" }, { 5376, 660736, "MDC_ECG_WAVP_PACE_V_R" }, { 5632, 660992, "MDC_ECG_WAVP_PACE_V_L" }, { 5888, 661248, "MDC_ECG_WAVP_PACE_EXT" }, { 6144, 661504, "MDC_ECG_WAVP_ATPACE" }, { 6400, 661760, "MDC_ECG_WAVP_ATPACE_ATR" }, { 6656, 662016, "MDC_ECG_WAVP_ATPACE_V" }, { 6912, 662272, "MDC_ECG_WAVP_ATPACE_EXT" }, { 7168, 662528, "MDC_ECG_WAVP_CDVS" }, { 7424, 662784, "MDC_ECG_WAVP_CDVS_ATR" }, { 7680, 663040, "MDC_ECG_WAVP_CDVS_V" }, { 7936, 663296, "MDC_ECG_WAVP_CDVS_EXT" }, { 8192, 663552, "MDC_ECG_WAVP_DEFIB" }, { 8448, 663808, "MDC_ECG_WAVP_DEFIB_ATR" }, { 8704, 664064, "MDC_ECG_WAVP_DEFIB_V" }, { 8960, 664320, "MDC_ECG_WAVP_DEFIB_EXT" }, { 8192, 663552, "MDC_ECG_BEAT" }, { 8193, 663553, "MDC_ECG_BEAT_TIME_POINT" }, { 8194, 663554, "MDC_ECG_BEAT_DURN" }, { 8195, 663555, "MDC_ECG_BEAT_PEAK" }, { 8196, 663556, "MDC_ECG_BEAT_ONSET" }, { 8197, 663557, "MDC_ECG_BEAT_OFFSET" }, { 8198, 663558, "MDC_ECG_BEAT_ONSET_IMPL" }, { 8199, 663559, "MDC_ECG_BEAT_OFFSET_IMPL" }, { 8200, 663560, "MDC_ECG_BEAT_EVENT" }, { 8201, 663561, "MDC_ECG_BEAT_COUNT" }, { 8202, 663562, "MDC_ECG_BEAT_RATE" }, { 8203, 663563, "MDC_ECG_BEAT_RATE_MAX" }, { 8204, 663564, "MDC_ECG_BEAT_RATE_MIN" }, { 8205, 663565, "MDC_ECG_BEAT_RATE_MEAN" }, { 8206, 663566, "MDC_ECG_BEAT_TIME" }, { 8207, 663567, "MDC_ECG_BEAT_ANNOT" }, { 8208, 663568, "MDC_ECG_BEAT_NORMAL" }, { 8224, 663584, "MDC_ECG_BEAT_ABNORMAL" }, { 8240, 663600, "MDC_ECG_BEAT_DOMINANT" }, { 8256, 663616, "MDC_ECG_BEAT_SV_P_C" }, { 8272, 663632, "MDC_ECG_BEAT_ATR_P_C" }, { 8288, 663648, "MDC_ECG_BEAT_JUNC_P_C" }, { 8304, 663664, "MDC_ECG_BEAT_ATR_P_C_ABERR" }, { 8320, 663680, "MDC_ECG_BEAT_ATR_PWAVE_BLK" }, { 8336, 663696, "MDC_ECG_BEAT_V_P_C" }, { 8352, 663712, "MDC_ECG_BEAT_V_P_C_FUSION" }, { 8368, 663728, "MDC_ECG_BEAT_V_P_C_RonT" }, { 8384, 663744, "MDC_ECG_BEAT_SV_ESC" }, { 8400, 663760, "MDC_ECG_BEAT_ATR_ESC" }, { 8416, 663776, "MDC_ECG_BEAT_JUNC_ESC" }, { 8432, 663792, "MDC_ECG_BEAT_V_ESC" }, { 8448, 663808, "MDC_ECG_BEAT_BB_BLK" }, { 8464, 663824, "MDC_ECG_BEAT_LBB_BLK_COMP" }, { 8480, 663840, "MDC_ECG_BEAT_LBB_BLK_INCOMP" }, { 8496, 663856, "MDC_ECG_BEAT_RBB_BLK_COMP" }, { 8512, 663872, "MDC_ECG_BEAT_RBB_BLK_INCOMP" }, { 8528, 663888, "MDC_ECG_BEAT_BLK_ANT_L_HEMI" }, { 8544, 663904, "MDC_ECG_BEAT_BLK_POS_L_HEMI" }, { 8560, 663920, "MDC_ECG_BEAT_BLK_BIFAS" }, { 8576, 663936, "MDC_ECG_BEAT_BLK_TRFAS" }, { 8592, 663952, "MDC_ECG_BEAT_BLK_BILAT" }, { 8608, 663968, "MDC_ECG_BEAT_BLK_IVCD" }, { 8624, 663984, "MDC_ECG_BEAT_PREX" }, { 8640, 664000, "MDC_ECG_BEAT_WPW_UNK" }, { 8656, 664016, "MDC_ECG_BEAT_WPW_A" }, { 8672, 664032, "MDC_ECG_BEAT_WPW_B" }, { 8688, 664048, "MDC_ECG_BEAT_LGL" }, { 8704, 664064, "MDC_ECG_BEAT_PACED" }, { 8720, 664080, "MDC_ECG_BEAT_PACED_FUS" }, { 8736, 664096, "MDC_ECG_BEAT_UNKNOWN" }, { 8752, 664112, "MDC_ECG_BEAT_LEARN" }, { 9216, 664576, "MDC_ECG_RHY_SINUS_RHY" }, { 9217, 664577, "MDC_ECG_RHY_SINUS_RHY_TIME_POINT" }, { 9218, 664578, "MDC_ECG_RHY_SINUS_RHY_DURN" }, { 9219, 664579, "MDC_ECG_RHY_SINUS_RHY_PEAK" }, { 9220, 664580, "MDC_ECG_RHY_SINUS_RHY_ONSET" }, { 9221, 664581, "MDC_ECG_RHY_SINUS_RHY_OFFSET" }, { 9222, 664582, "MDC_ECG_RHY_SINUS_RHY_ONSET_IMPL" }, { 9223, 664583, "MDC_ECG_RHY_SINUS_RHY_OFFSET_IMPL" }, { 9224, 664584, "MDC_ECG_RHY_SINUS_RHY_EVENT" }, { 9225, 664585, "MDC_ECG_RHY_SINUS_RHY_COUNT" }, { 9226, 664586, "MDC_ECG_RHY_SINUS_RHY_RATE" }, { 9227, 664587, "MDC_ECG_RHY_SINUS_RHY_RATE_MAX" }, { 9228, 664588, "MDC_ECG_RHY_SINUS_RHY_RATE_MIN" }, { 9229, 664589, "MDC_ECG_RHY_SINUS_RHY_RATE_MEAN" }, { 9230, 664590, "MDC_ECG_RHY_SINUS_RHY_TIME" }, { 9231, 664591, "MDC_ECG_RHY_SINUS_RHY_ANNOT" }, { 9232, 664592, "MDC_ECG_RHY_SINUS_NORMAL_RHY" }, { 9248, 664608, "MDC_ECG_RHY_SINUS_BRADY" }, { 9264, 664624, "MDC_ECG_RHY_SINUS_TACHY" }, { 9280, 664640, "MDC_ECG_RHY_SINUS_ARRHY" }, { 9296, 664656, "MDC_ECG_RHY_RESP_ARRHY" }, { 9312, 664672, "MDC_ECG_RHY_NON_RESP_ARRHY" }, { 9328, 664688, "MDC_ECG_RHY_WANDP_ARRHY" }, { 9344, 664704, "MDC_ECG_RHY_WANDPAV_ARRHY" }, { 9360, 664720, "MDC_ECG_RHY_ATR_ECT_RHY" }, { 9376, 664736, "MDC_ECG_RHY_ATR_BIGEM" }, { 9392, 664752, "MDC_ECG_RHY_ATR_TACHY" }, { 9408, 664768, "MDC_ECG_RHY_ATR_TACHY_PAROX" }, { 9424, 664784, "MDC_ECG_RHY_ATR_TACHY_MF" }, { 9440, 664800, "MDC_ECG_RHY_ATR_TACHY_AUTO" }, { 9456, 664816, "MDC_ECG_RHY_ATR_FLUT" }, { 9472, 664832, "MDC_ECG_RHY_ATR_FIB" }, { 9488, 664848, "MDC_ECG_RHY_SV_ECT_RHY" }, { 9504, 664864, "MDC_ECG_RHY_SV_TACHY" }, { 9520, 664880, "MDC_ECG_RHY_SV_TACHY_PAROX" }, { 9536, 664896, "MDC_ECG_RHY_JUNC_RHY" }, { 9552, 664912, "MDC_ECG_RHY_JUNC_ESC_BEATS" }, { 9568, 664928, "MDC_ECG_RHY_JUNC_ACCEL" }, { 9584, 664944, "MDC_ECG_RHY_JUNC_TACHY" }, { 9600, 664960, "MDC_ECG_RHY_AV_TACHY_RECIP" }, { 9616, 664976, "MDC_ECG_RHY_AV_TACHY_REENTRANT" }, { 9632, 664992, "MDC_ECG_RHY_AV_HEART_BLK_DEG_1" }, { 9648, 665008, "MDC_ECG_RHY_AV_HEART_BLK_DEG_2" }, { 9664, 665024, "MDC_ECG_RHY_AV_HEART_BLK_DEG_2_I" }, { 9680, 665040, "MDC_ECG_RHY_AV_HEART_BLK_DEG_2_II" }, { 9696, 665056, "MDC_ECG_RHY_AV_HEART_BLK_DEG_3" }, { 9712, 665072, "MDC_ECG_RHY_AV_DISSOC" }, { 9728, 665088, "MDC_ECG_RHY_AV_DISSOC_INT" }, { 9744, 665104, "MDC_ECG_RHY_AV_DISSOC_ISO" }, { 9760, 665120, "MDC_ECG_RHY_AV_DISSOC_COMP" }, { 9776, 665136, "MDC_ECG_RHY_SA_HEART_BLK_DEG_1" }, { 9792, 665152, "MDC_ECG_RHY_SA_HEART_BLK_DEG_2_I" }, { 9808, 665168, "MDC_ECG_RHY_SA_HEART_BLK_DEG_2_II" }, { 9824, 665184, "MDC_ECG_RHY_SA_HEART_BLK_DEG_3" }, { 9840, 665200, "MDC_ECG_RHY_V_RHY" }, { 9856, 665216, "MDC_ECG_RHY_V_IDIO_RHY" }, { 9872, 665232, "MDC_ECG_RHY_V_PARA" }, { 9888, 665248, "MDC_ECG_RHY_V_AIVR" }, { 9904, 665264, "MDC_ECG_RHY_V_IDIO_TACHY" }, { 10464, 665824, "MDC_ECG_RHY_V_BRADY" }, { 9920, 665280, "MDC_ECG_RHY_V_BIGEM" }, { 9936, 665296, "MDC_ECG_RHY_V_TRIGEM" }, { 9952, 665312, "MDC_ECG_RHY_V_P_C_CPLT" }, { 9968, 665328, "MDC_ECG_RHY_V_P_C_RUN" }, { 9984, 665344, "MDC_ECG_RHY_V_TACHY" }, { 10000, 665360, "MDC_ECG_RHY_V_FLUT" }, { 10016, 665376, "MDC_ECG_RHY_V_FIB" }, { 10032, 665392, "MDC_ECG_RHY_V_TACHY_PAROX" }, { 10048, 665408, "MDC_ECG_RHY_V_TACHY_MONO" }, { 10064, 665424, "MDC_ECG_RHY_V_TACHY_POLY" }, { 10080, 665440, "MDC_ECG_RHY_V_TACHY_TDP" }, { 10096, 665456, "MDC_ECG_RHY_PREX" }, { 10112, 665472, "MDC_ECG_RHY_WPW_UNK" }, { 10128, 665488, "MDC_ECG_RHY_WPW_A" }, { 10144, 665504, "MDC_ECG_RHY_WPW_B" }, { 10160, 665520, "MDC_ECG_RHY_LGL" }, { 10176, 665536, "MDC_ECG_RHY_EPADM" }, { 10192, 665552, "MDC_ECG_RHY_EPAC" }, { 10208, 665568, "MDC_ECG_RHY_EPAFC" }, { 10224, 665584, "MDC_ECG_RHY_EPAFS" }, { 10240, 665600, "MDC_ECG_RHY_EPVDM" }, { 10256, 665616, "MDC_ECG_RHY_EPVC" }, { 10272, 665632, "MDC_ECG_RHY_EPVFC" }, { 10288, 665648, "MDC_ECG_RHY_EPVFS" }, { 10304, 665664, "MDC_ECG_RHY_EPAVT" }, { 10320, 665680, "MDC_ECG_RHY_MISSB" }, { 10336, 665696, "MDC_ECG_RHY_ASYSTOLE" }, { 10352, 665712, "MDC_ECG_RHY_IRREG" }, { 10368, 665728, "MDC_ECG_RHY_LHRV" }, { 10384, 665744, "MDC_ECG_RHY_STELVATION" }, { 10400, 665760, "MDC_ECG_RHY_STHILOST" }, { 10416, 665776, "MDC_ECG_RHY_TALT" }, { 10432, 665792, "MDC_ECG_RHY_BRADY" }, { 10448, 665808, "MDC_ECG_RHY_CALS" }, { 10480, 665840, "MDC_ECG_RHY_EPAX" }, { 10496, 665856, "MDC_ECG_RHY_EPAXLO" }, { 10512, 665872, "MDC_ECG_RHY_EPAXFO" }, { 10528, 665888, "MDC_ECG_RHY_EPVX" }, { 10544, 665904, "MDC_ECG_RHY_EPVXLO" }, { 10560, 665920, "MDC_ECG_RHY_EPVXFO" }, { 11200, 666560, "MDC_ECG_NOISE_CLEAN" }, { 11201, 666561, "MDC_ECG_NOISE_CLEAN_TIME_POINT" }, { 11202, 666562, "MDC_ECG_NOISE_CLEAN_DURN" }, { 11203, 666563, "MDC_ECG_NOISE_CLEAN_PEAK" }, { 11204, 666564, "MDC_ECG_NOISE_CLEAN_ONSET" }, { 11205, 666565, "MDC_ECG_NOISE_CLEAN_OFFSET" }, { 11206, 666566, "MDC_ECG_NOISE_CLEAN_ONSET_IMPL" }, { 11207, 666567, "MDC_ECG_NOISE_CLEAN_OFFSET_IMPL" }, { 11208, 666568, "MDC_ECG_NOISE_CLEAN_EVENT" }, { 11209, 666569, "MDC_ECG_NOISE_CLEAN_COUNT" }, { 11210, 666570, "MDC_ECG_NOISE_CLEAN_RATE" }, { 11211, 666571, "MDC_ECG_NOISE_CLEAN_RATE_MAX" }, { 11212, 666572, "MDC_ECG_NOISE_CLEAN_RATE_MIN" }, { 11213, 666573, "MDC_ECG_NOISE_CLEAN_RATE_MEAN" }, { 11214, 666574, "MDC_ECG_NOISE_CLEAN_TIME" }, { 11215, 666575, "MDC_ECG_NOISE_CLEAN_ANNOT" }, { 11216, 666576, "MDC_ECG_NOISE_MODERATE" }, { 11232, 666592, "MDC_ECG_NOISE_SEVERE" }, { 11248, 666608, "MDC_ECG_NOISE_NOSIGNAL" }, { 16248, 147320, "MDC_ECG_ANGLE_J20_AZIM" }, { 16249, 147321, "MDC_ECG_ANGLE_J20_AZIM_MAX" }, { 16250, 147322, "MDC_ECG_ANGLE_J20_AZIM_MIN" }, { 16251, 147323, "MDC_ECG_ANGLE_J20_AZIM_MEAN" }, { 16284, 147356, "MDC_ECG_ANGLE_J80_AZIM" }, { 16288, 147360, "MDC_ECG_ANGLE_J80_ELEV" }, { 16296, 147368, "MDC_ECG_ANGLE_Jxx_AZIM" }, { 16300, 147372, "MDC_ECG_ANGLE_Jxx_ELEV" }, { 16236, 147308, "MDC_ECG_ANGLE_J_AZIM" }, { 16240, 147312, "MDC_ECG_ANGLE_J_ELEV" }, { 16252, 147324, "MDC_ECG_ANGLE_J20_ELEV" }, { 16260, 147332, "MDC_ECG_ANGLE_J40_AZIM" }, { 16264, 147336, "MDC_ECG_ANGLE_J40_ELEV" }, { 16272, 147344, "MDC_ECG_ANGLE_J60_AZIM" }, { 16276, 147348, "MDC_ECG_ANGLE_J60_ELEV" }, { 16204, 147276, "MDC_ECG_ANGLE_P_AZIM" }, { 16216, 147288, "MDC_ECG_ANGLE_P_ELEV" }, { 16128, 147200, "MDC_ECG_ANGLE_P_FRONT" }, { 16208, 147280, "MDC_ECG_ANGLE_QRS_AZIM" }, { 16220, 147292, "MDC_ECG_ANGLE_QRS_ELEV" }, { 16132, 147204, "MDC_ECG_ANGLE_QRS_FRONT" }, { 16224, 147296, "MDC_ECG_ANGLE_T_ELEV" }, { 16212, 147284, "MDC_ECG_ANGLE_T_AZIM" }, { 16136, 147208, "MDC_ECG_ANGLE_T_FRONT" }, { 16184, 147256, "MDC_ECG_TIME_PD_P" }, { 16184, 147256, "MDC_ECG_TIME_PD_P_GL" }, { 16140, 147212, "MDC_ECG_TIME_PD_PP" }, { 16140, 147212, "MDC_ECG_TIME_PD_PP_GL" }, { 16144, 147216, "MDC_ECG_TIME_PD_PQ" }, { 15872, 146944, "MDC_ECG_TIME_PD_PR" }, { 16148, 147220, "MDC_ECG_TIME_PD_PQ_SEG" }, { 16156, 147228, "MDC_ECG_TIME_PD_QRS" }, { 16156, 147228, "MDC_ECG_TIME_PD_QRS_GL" }, { 16160, 147232, "MDC_ECG_TIME_PD_QT" }, { 16160, 147232, "MDC_ECG_TIME_PD_QT_GL" }, { 16164, 147236, "MDC_ECG_TIME_PD_QTc" }, { 15876, 146948, "MDC_ECG_TIME_PD_QTC" }, { 15880, 146952, "MDC_ECG_TIME_PD_QTC_BAZETT" }, { 15884, 146956, "MDC_ECG_TIME_PD_QTC_FRAMINGHAM" }, { 15888, 146960, "MDC_ECG_TIME_PD_QTC_HODGES" }, { 15892, 146964, "MDC_ECG_TIME_PD_QTC_FREDERICA" }, { 15896, 146968, "MDC_ECG_TIME_PD_QTC_USER" }, { 16000, 147072, "MDC_ECG_TIME_PD_RR_GL" }, { 16004, 147076, "MDC_ECG_TIME_PD_QTU" }, { 16008, 147080, "MDC_ECG_DISPERSION_QT" }, { 16012, 147084, "MDC_ECG_DISPERSION_QTC" }, { 16168, 147240, "MDC_ECG_TIME_PD_RR" }, { 16168, 147240, "MDC_ECG_TIME_PD_RR_GL" }, { 16304, 147376, "MDC_ECG_TIME_ST_Jxx" }, { 16232, 147304, "MDC_ECG_MAG_J_VECT" }, { 16244, 147316, "MDC_ECG_MAG_J20_VECT" }, { 16256, 147328, "MDC_ECG_MAG_J40_VECT" }, { 16268, 147340, "MDC_ECG_MAG_J60_VECT" }, { 16280, 147352, "MDC_ECG_MAG_J80_VECT" }, { 16292, 147364, "MDC_ECG_MAG_Jxx_VECT" }, { 16172, 147244, "MDC_ECG_MAG_P_FRONT" }, { 16192, 147264, "MDC_ECG_MAG_P_VECT" }, { 16308, 147380, "MDC_ECG_MAG_P_VECT_FRONT" }, { 16312, 147384, "MDC_ECG_MAG_P_VECT_HORIZ" }, { 16316, 147388, "MDC_ECG_MAG_P_VECT_SAGI" }, { 16176, 147248, "MDC_ECG_MAG_QRS_FRONT" }, { 16196, 147268, "MDC_ECG_MAG_QRS_VECT" }, { 16320, 147392, "MDC_ECG_MAG_QRS_VECT_FRONT" }, { 16324, 147396, "MDC_ECG_MAG_QRS_VECT_HORIZ" }, { 16328, 147400, "MDC_ECG_MAG_QRS_VECT_SAGI" }, { 16180, 147252, "MDC_ECG_MAG_T_FRONT" }, { 16200, 147272, "MDC_ECG_MAG_T_VECT" }, { 16332, 147404, "MDC_ECG_MAG_T_VECT_FRONT" }, { 16336, 147408, "MDC_ECG_MAG_T_VECT_HORIZ" }, { 16340, 147412, "MDC_ECG_MAG_T_VECT_SAGI" }, { 16770, 147842, "MDC_ECG_HEART_RATE" }, { 16016, 147088, "MDC_ECG_VENTRICULAR_RATE" }, { 16020, 147092, "MDC_ECG_ATRIAL_RATE" }, { 16024, 147096, "MDC_ECG_VPC_COUNT" }, { 16028, 147100, "MDC_ECG_SVPC_RATE" }, { 16032, 147104, "MDC_ECG_BEAT_COUNT" }, { 6656, 137728, "MDC_ECG_TIME_PD_P" }, { 6657, 137729, "MDC_ECG_TIME_PD_P_I" }, { 6687, 137759, "MDC_ECG_TIME_PD_P_dI" }, { 6658, 137730, "MDC_ECG_TIME_PD_P_II" }, { 6688, 137760, "MDC_ECG_TIME_PD_P_dII" }, { 6659, 137731, "MDC_ECG_TIME_PD_P_V1" }, { 6689, 137761, "MDC_ECG_TIME_PD_P_dV1" }, { 6660, 137732, "MDC_ECG_TIME_PD_P_V2" }, { 6690, 137762, "MDC_ECG_TIME_PD_P_dV2" }, { 6661, 137733, "MDC_ECG_TIME_PD_P_V3" }, { 6691, 137763, "MDC_ECG_TIME_PD_P_dV3" }, { 6662, 137734, "MDC_ECG_TIME_PD_P_V4" }, { 6692, 137764, "MDC_ECG_TIME_PD_P_dV4" }, { 6663, 137735, "MDC_ECG_TIME_PD_P_V5" }, { 6693, 137765, "MDC_ECG_TIME_PD_P_dV5" }, { 6664, 137736, "MDC_ECG_TIME_PD_P_V6" }, { 6694, 137766, "MDC_ECG_TIME_PD_P_dV6" }, { 6665, 137737, "MDC_ECG_TIME_PD_P_V7" }, { 6695, 137767, "MDC_ECG_TIME_PD_P_dV7" }, { 6666, 137738, "MDC_ECG_TIME_PD_P_V2R" }, { 6696, 137768, "MDC_ECG_TIME_PD_P_dV2R" }, { 6667, 137739, "MDC_ECG_TIME_PD_P_V3R" }, { 6697, 137769, "MDC_ECG_TIME_PD_P_dV3R" }, { 6668, 137740, "MDC_ECG_TIME_PD_P_V4R" }, { 6698, 137770, "MDC_ECG_TIME_PD_P_dV4R" }, { 6669, 137741, "MDC_ECG_TIME_PD_P_V5R" }, { 6699, 137771, "MDC_ECG_TIME_PD_P_dV5R" }, { 6670, 137742, "MDC_ECG_TIME_PD_P_V6R" }, { 6700, 137772, "MDC_ECG_TIME_PD_P_dV6R" }, { 6671, 137743, "MDC_ECG_TIME_PD_P_V7R" }, { 6701, 137773, "MDC_ECG_TIME_PD_P_dV7R" }, { 6672, 137744, "MDC_ECG_TIME_PD_P_X" }, { 6702, 137774, "MDC_ECG_TIME_PD_P_dX" }, { 6673, 137745, "MDC_ECG_TIME_PD_P_Y" }, { 6703, 137775, "MDC_ECG_TIME_PD_P_dY" }, { 6674, 137746, "MDC_ECG_TIME_PD_P_Z" }, { 6704, 137776, "MDC_ECG_TIME_PD_P_dZ" }, { 6675, 137747, "MDC_ECG_TIME_PD_P_CC5" }, { 6705, 137777, "MDC_ECG_TIME_PD_P_dCC5" }, { 6676, 137748, "MDC_ECG_TIME_PD_P_CM5" }, { 6706, 137778, "MDC_ECG_TIME_PD_P_dCM5" }, { 6677, 137749, "MDC_ECG_TIME_PD_P_LA" }, { 6707, 137779, "MDC_ECG_TIME_PD_P_dLA" }, { 6678, 137750, "MDC_ECG_TIME_PD_P_RA" }, { 6708, 137780, "MDC_ECG_TIME_PD_P_dRA" }, { 6679, 137751, "MDC_ECG_TIME_PD_P_LL" }, { 6709, 137781, "MDC_ECG_TIME_PD_P_dLL" }, { 6680, 137752, "MDC_ECG_TIME_PD_P_fI" }, { 6710, 137782, "MDC_ECG_TIME_PD_P_dfI" }, { 6681, 137753, "MDC_ECG_TIME_PD_P_fE" }, { 6711, 137783, "MDC_ECG_TIME_PD_P_dfE" }, { 6682, 137754, "MDC_ECG_TIME_PD_P_fC" }, { 6712, 137784, "MDC_ECG_TIME_PD_P_dfC" }, { 6683, 137755, "MDC_ECG_TIME_PD_P_fA" }, { 6713, 137785, "MDC_ECG_TIME_PD_P_dfA" }, { 6684, 137756, "MDC_ECG_TIME_PD_P_fM" }, { 6714, 137786, "MDC_ECG_TIME_PD_P_dfM" }, { 6685, 137757, "MDC_ECG_TIME_PD_P_fF" }, { 6715, 137787, "MDC_ECG_TIME_PD_P_dfF" }, { 6686, 137758, "MDC_ECG_TIME_PD_P_fH" }, { 6716, 137788, "MDC_ECG_TIME_PD_P_dfH" }, { 6717, 137789, "MDC_ECG_TIME_PD_P_III" }, { 6767, 137839, "MDC_ECG_TIME_PD_P_dIII" }, { 6718, 137790, "MDC_ECG_TIME_PD_P_AVR" }, { 6768, 137840, "MDC_ECG_TIME_PD_P_dAVR" }, { 6719, 137791, "MDC_ECG_TIME_PD_P_AVL" }, { 6769, 137841, "MDC_ECG_TIME_PD_P_dAVL" }, { 6720, 137792, "MDC_ECG_TIME_PD_P_AVF" }, { 6770, 137842, "MDC_ECG_TIME_PD_P_dAVF" }, { 6721, 137793, "MDC_ECG_TIME_PD_P_AVRneg" }, { 6771, 137843, "MDC_ECG_TIME_PD_P_dAVRneg" }, { 6722, 137794, "MDC_ECG_TIME_PD_P_V8" }, { 6735, 137807, "MDC_ECG_TIME_PD_P_dV8" }, { 6723, 137795, "MDC_ECG_TIME_PD_P_V9" }, { 6736, 137808, "MDC_ECG_TIME_PD_P_dV9" }, { 6724, 137796, "MDC_ECG_TIME_PD_P_V8R" }, { 6737, 137809, "MDC_ECG_TIME_PD_P_dV8R" }, { 6725, 137797, "MDC_ECG_TIME_PD_P_V9R" }, { 6738, 137810, "MDC_ECG_TIME_PD_P_dV9R" }, { 6726, 137798, "MDC_ECG_TIME_PD_P_D" }, { 6739, 137811, "MDC_ECG_TIME_PD_P_dD" }, { 6727, 137799, "MDC_ECG_TIME_PD_P_A" }, { 6740, 137812, "MDC_ECG_TIME_PD_P_dA" }, { 6728, 137800, "MDC_ECG_TIME_PD_P_J" }, { 6741, 137813, "MDC_ECG_TIME_PD_P_dJ" }, { 6729, 137801, "MDC_ECG_TIME_PD_P_DEFIB" }, { 6791, 137863, "MDC_ECG_TIME_PD_P_dDEFIB" }, { 6730, 137802, "MDC_ECG_TIME_PD_P_EXTERN" }, { 6792, 137864, "MDC_ECG_TIME_PD_P_dEXTERN" }, { 6731, 137803, "MDC_ECG_TIME_PD_P_A1" }, { 6793, 137865, "MDC_ECG_TIME_PD_P_dA1" }, { 6732, 137804, "MDC_ECG_TIME_PD_P_A2" }, { 6794, 137866, "MDC_ECG_TIME_PD_P_dA2" }, { 6733, 137805, "MDC_ECG_TIME_PD_P_A3" }, { 6795, 137867, "MDC_ECG_TIME_PD_P_dA3" }, { 6734, 137806, "MDC_ECG_TIME_PD_P_A4" }, { 6796, 137868, "MDC_ECG_TIME_PD_P_dA4" }, { 6742, 137814, "MDC_ECG_TIME_PD_P_C" }, { 6772, 137844, "MDC_ECG_TIME_PD_P_dC" }, { 6743, 137815, "MDC_ECG_TIME_PD_P_V" }, { 6773, 137845, "MDC_ECG_TIME_PD_P_dV" }, { 6744, 137816, "MDC_ECG_TIME_PD_P_VR" }, { 6774, 137846, "MDC_ECG_TIME_PD_P_dVR" }, { 6745, 137817, "MDC_ECG_TIME_PD_P_VL" }, { 6775, 137847, "MDC_ECG_TIME_PD_P_dVL" }, { 6746, 137818, "MDC_ECG_TIME_PD_P_VF" }, { 6776, 137848, "MDC_ECG_TIME_PD_P_dVF" }, { 6747, 137819, "MDC_ECG_TIME_PD_P_MCL" }, { 6808, 137880, "MDC_ECG_TIME_PD_P_dMCL" }, { 6748, 137820, "MDC_ECG_TIME_PD_P_MCL1" }, { 6797, 137869, "MDC_ECG_TIME_PD_P_dMCL1" }, { 6749, 137821, "MDC_ECG_TIME_PD_P_MCL2" }, { 6798, 137870, "MDC_ECG_TIME_PD_P_dMCL2" }, { 6750, 137822, "MDC_ECG_TIME_PD_P_MCL3" }, { 6799, 137871, "MDC_ECG_TIME_PD_P_dMCL3" }, { 6751, 137823, "MDC_ECG_TIME_PD_P_MCL4" }, { 6800, 137872, "MDC_ECG_TIME_PD_P_dMCL4" }, { 6752, 137824, "MDC_ECG_TIME_PD_P_MCL5" }, { 6801, 137873, "MDC_ECG_TIME_PD_P_dMCL5" }, { 6753, 137825, "MDC_ECG_TIME_PD_P_MCL6" }, { 6802, 137874, "MDC_ECG_TIME_PD_P_dMCL6" }, { 6754, 137826, "MDC_ECG_TIME_PD_P_CC" }, { 6809, 137881, "MDC_ECG_TIME_PD_P_dCC" }, { 6755, 137827, "MDC_ECG_TIME_PD_P_CC1" }, { 6810, 137882, "MDC_ECG_TIME_PD_P_dCC1" }, { 6756, 137828, "MDC_ECG_TIME_PD_P_CC2" }, { 6811, 137883, "MDC_ECG_TIME_PD_P_dCC2" }, { 6757, 137829, "MDC_ECG_TIME_PD_P_CC3" }, { 6812, 137884, "MDC_ECG_TIME_PD_P_dCC3" }, { 6758, 137830, "MDC_ECG_TIME_PD_P_CC4" }, { 6813, 137885, "MDC_ECG_TIME_PD_P_dCC4" }, { 6759, 137831, "MDC_ECG_TIME_PD_P_CC6" }, { 6814, 137886, "MDC_ECG_TIME_PD_P_dCC6" }, { 6760, 137832, "MDC_ECG_TIME_PD_P_CC7" }, { 6815, 137887, "MDC_ECG_TIME_PD_P_dCC7" }, { 6761, 137833, "MDC_ECG_TIME_PD_P_CM" }, { 6816, 137888, "MDC_ECG_TIME_PD_P_dCM" }, { 6762, 137834, "MDC_ECG_TIME_PD_P_CM1" }, { 6817, 137889, "MDC_ECG_TIME_PD_P_dCM1" }, { 6763, 137835, "MDC_ECG_TIME_PD_P_CM2" }, { 6818, 137890, "MDC_ECG_TIME_PD_P_dCM2" }, { 6764, 137836, "MDC_ECG_TIME_PD_P_CM3" }, { 6819, 137891, "MDC_ECG_TIME_PD_P_dCM3" }, { 6765, 137837, "MDC_ECG_TIME_PD_P_CM4" }, { 6820, 137892, "MDC_ECG_TIME_PD_P_dCM4" }, { 6766, 137838, "MDC_ECG_TIME_PD_P_CM6" }, { 6821, 137893, "MDC_ECG_TIME_PD_P_dCM6" }, { 6777, 137849, "MDC_ECG_TIME_PD_P_CM7" }, { 6822, 137894, "MDC_ECG_TIME_PD_P_dCM7" }, { 6778, 137850, "MDC_ECG_TIME_PD_P_CH5" }, { 6823, 137895, "MDC_ECG_TIME_PD_P_dCH5" }, { 6779, 137851, "MDC_ECG_TIME_PD_P_CS5" }, { 6824, 137896, "MDC_ECG_TIME_PD_P_dCS5" }, { 6780, 137852, "MDC_ECG_TIME_PD_P_CB5" }, { 6825, 137897, "MDC_ECG_TIME_PD_P_dCB5" }, { 6781, 137853, "MDC_ECG_TIME_PD_P_CR5" }, { 6826, 137898, "MDC_ECG_TIME_PD_P_dCR5" }, { 6782, 137854, "MDC_ECG_TIME_PD_P_ML" }, { 6827, 137899, "MDC_ECG_TIME_PD_P_dML" }, { 6783, 137855, "MDC_ECG_TIME_PD_P_AB1" }, { 6828, 137900, "MDC_ECG_TIME_PD_P_dAB1" }, { 6784, 137856, "MDC_ECG_TIME_PD_P_AB2" }, { 6829, 137901, "MDC_ECG_TIME_PD_P_dAB2" }, { 6785, 137857, "MDC_ECG_TIME_PD_P_AB3" }, { 6830, 137902, "MDC_ECG_TIME_PD_P_dAB3" }, { 6786, 137858, "MDC_ECG_TIME_PD_P_AB4" }, { 6831, 137903, "MDC_ECG_TIME_PD_P_dAB4" }, { 6787, 137859, "MDC_ECG_TIME_PD_P_ES" }, { 6832, 137904, "MDC_ECG_TIME_PD_P_dES" }, { 6788, 137860, "MDC_ECG_TIME_PD_P_AS" }, { 6833, 137905, "MDC_ECG_TIME_PD_P_dAS" }, { 6789, 137861, "MDC_ECG_TIME_PD_P_AI" }, { 6834, 137906, "MDC_ECG_TIME_PD_P_dAI" }, { 6790, 137862, "MDC_ECG_TIME_PD_P_S" }, { 6835, 137907, "MDC_ECG_TIME_PD_P_dS" }, { 6803, 137875, "MDC_ECG_TIME_PD_P_RL" }, { 6836, 137908, "MDC_ECG_TIME_PD_P_dRL" }, { 6804, 137876, "MDC_ECG_TIME_PD_P_CV5RL" }, { 6837, 137909, "MDC_ECG_TIME_PD_P_dCV5RL" }, { 6805, 137877, "MDC_ECG_TIME_PD_P_CV6LL" }, { 6838, 137910, "MDC_ECG_TIME_PD_P_dCV6LL" }, { 6806, 137878, "MDC_ECG_TIME_PD_P_CV6LU" }, { 6839, 137911, "MDC_ECG_TIME_PD_P_dCV6LU" }, { 6807, 137879, "MDC_ECG_TIME_PD_P_V10" }, { 6840, 137912, "MDC_ECG_TIME_PD_P_dV10" }, { 5888, 136960, "MDC_ECG_TIME_END_P" }, { 4608, 135680, "MDC_ECG_TIME_PD_P1" }, { 4864, 135936, "MDC_ECG_TIME_PD_P2" }, { 9472, 140544, "MDC_ECG_TIME_START_P" }, { 5120, 136192, "MDC_ECG_TIME_PD_P3" }, { 7168, 138240, "MDC_ECG_TIME_PD_PR" }, { 7680, 138752, "MDC_ECG_TIME_PD_Q" }, { 7936, 139008, "MDC_ECG_TIME_PD_QRS" }, { 6144, 137216, "MDC_ECG_TIME_END_QRS" }, { 9728, 140800, "MDC_ECG_TIME_START_QRS" }, { 8192, 139264, "MDC_ECG_TIME_PD_QT" }, { 8448, 139520, "MDC_ECG_TIME_PD_QT_CORR" }, { 11264, 142336, "MDC_ECG_TIME_PD_R_1" }, { 11520, 142592, "MDC_ECG_TIME_PD_R_2" }, { 11776, 142848, "MDC_ECG_TIME_PD_R_3" }, { 12032, 143104, "MDC_ECG_TIME_PD_S_1" }, { 12288, 143360, "MDC_ECG_TIME_PD_S_2" }, { 12544, 143616, "MDC_ECG_TIME_PD_S_3" }, { 6400, 137472, "MDC_ECG_TIME_END_QRS" }, { 9984, 141056, "MDC_ECG_TIME_START_T" }, { 11008, 142080, "MDC_ECG_TIME_PD_VENT_ACTIV" }, { 256, 131328, "MDC_ECG_ELEC_POTL" }, { 1024, 132096, "MDC_ECG_AMPL_J" }, { 14848, 145920, "MDC_ECG_ELEC_POTL_ST_20" }, { 15104, 146176, "MDC_ECG_ELEC_POTL_ST_40" }, { 14336, 145408, "MDC_ECG_ELEC_POTL_ST_60" }, { 14592, 145664, "MDC_ECG_ELEC_POTL_ST_80" }, { 1280, 132352, "MDC_ECG_AMPL_P_MAX" }, { 1536, 132608, "MDC_ECG_AMPL_P_MIN" }, { 3072, 134144, "MDC_ECG_AMPL_P3" }, { 1792, 132864, "MDC_ECG_AMPL_Q" }, { 2048, 133120, "MDC_ECG_AMPL_R" }, { 12800, 143872, "MDC_ECG_ELEC_POTL_R_1" }, { 13056, 144128, "MDC_ECG_ELEC_POTL_R_2" }, { 13312, 144384, "MDC_ECG_ELEC_POTL_R_3" }, { 2304, 133376, "MDC_ECG_AMPL_S" }, { 13568, 144640, "MDC_ECG_ELEC_POTL_S_1" }, { 13824, 144896, "MDC_ECG_ELEC_POTL_S_2" }, { 14080, 145152, "MDC_ECG_ELEC_POTL_S_3" }, { 2560, 133632, "MDC_ECG_AMPL_T_MAX" }, { 2816, 133888, "MDC_ECG_AMPL_T_MIN" }, { 256, 131328, "MDC_ECG_ELEC_POTL" }, { 768, 131840, "MDC_ECG_AMPL_ST" }, { 6912, 137984, "MDC_ECG_INTEGRAL_P" }, { 3840, 134912, "MDC_ECG_AREA_P" }, { 7424, 138496, "MDC_ECG_INTEGRAL_Q" }, { 3328, 134400, "MDC_ECG_AREA_Q" }, { 8704, 139776, "MDC_ECG_INTEGRAL_QRS" }, { 4096, 135168, "MDC_ECG_AREA_QRS" }, { 9216, 140288, "MDC_ECG_INTEGRAL_ST" }, { 4352, 135424, "MDC_ECG_AREA_ST" }, { 8960, 140032, "MDC_ECG_INTEGRAL_T" }, { 3584, 134656, "MDC_ECG_AREA_T" }, { 5376, 136448, "MDC_ECG_SLOPE_ST" }, { 32768, 163840, "MDC_ECG_TIME_PD_PP" }, { 33024, 164096, "MDC_ECG_TIME_PD_RR" }, { 33280, 164352, "MDC_ECG_TIME_PD_PQ" }, { 33536, 164608, "MDC_ECG_TIME_PD_PQ_SEG" }, { 33792, 164864, "MDC_ECG_TIME_PD_QTc" }, { 34048, 165120, "MDC_ECG_TIME_PD_QTcB" }, { 34304, 165376, "MDC_ECG_TIME_PD_QTcF" }, { 34560, 165632, "MDC_ECG_TIME_PD_QTU" }, { 34816, 165888, "MDC_ECG_SHAPE_ST" }, { 35072, 166144, "MDC_ECG_SHAPE_ST_T" }, { 11264, 666624, "MDC_ECG_LDSYS_12LD_UNSPECIFIED" }, { 11265, 666625, "MDC_ECG_LDSYS_12LD_STD" }, { 11266, 666626, "MDC_ECG_LDSYS_12LD_MASON_LIKAR" }, { 11267, 666627, "MDC_ECG_LDSYS_12LD_VPAD" }, { 11268, 666628, "MDC_ECG_LDSYS_12LD_PAD" }, { 11269, 666629, "MDC_ECG_LDSYS_12LD_FROM_FRANK" }, { 11270, 666630, "MDC_ECG_LDSYS_12LD_NON_STANDARD" }, { 11271, 666631, "MDC_ECG_LDSYS_12LD_BICYCLE" }, { 11272, 666632, "MDC_ECG_LDSYS_12LD_RAISED_INTERCOSTAL" }, { 11273, 666633, "MDC_ECG_LDSYS_XYZ_UNSPECIFIED" }, { 11274, 666634, "MDC_ECG_LDSYS_XYZ_FRANK" }, { 11275, 666635, "MDC_ECG_LDSYS_XYZ_MCFEE_PARUNAGO" }, { 11276, 666636, "MDC_ECG_LDSYS_XYZ_CUBE" }, { 11277, 666637, "MDC_ECG_LDSYS_XYZ_BIPOLAR" }, { 11278, 666638, "MDC_ECG_LDSYS_XYZ_PSEUDO_ORTH" }, { 11279, 666639, "MDC_ECG_LDSYS_XYZ_FROM_12LD" }, { 11280, 666640, "MDC_ECG_LDSYS_3LD_NEHB" }, { 11281, 666641, "MDC_ECG_LDSYS_3LD_CC5_CM5_ML" }, { 11282, 666642, "MDC_ECG_LDSYS_3LD_CM5_CC5_CH5" }, { 11283, 666643, "MDC_ECG_LDSYS_12LD_FROM_DOWER" }, { 11284, 666644, "MDC_ECG_LDSYS_12LD_FROM_EASI" }, { 11285, 666645, "MDC_ECG_LDSYS_12LD_FROM_LIMB" }, { 11286, 666646, "MDC_ECG_LDSYS_12LD_STD_AND_XYZ" }, { 11287, 666647, "MDC_ECG_LDSYS_12LD_STD_AND_NEHB" }, { 11288, 666648, "MDC_ECG_LDSYS_12LD_STD_AND_CC5_CM5_ML" }, { 11289, 666649, "MDC_ECG_LDSYS_12LD_STD_AND_CM5_CC5_CH5" }, { 11290, 666650, "MDC_ECG_LDSYS_12LD_STD_EXTD" }, { 11291, 666651, "MDC_ECG_LDSYS_12LD_STD_EXTD_RIGHT" }, { 11292, 666652, "MDC_ECG_LDSYS_12LD_STD_EXTD_LEFT" }, { 11392, 666752, "MDC_ECG_CTL_VBL" }, { 11393, 666753, "MDC_ECG_CTL_VBL_SAMPLE_RATE" }, { 11394, 666754, "MDC_ECG_CTL_VBL_SENSITIVITY" }, { 11395, 666755, "MDC_ECG_CTL_VBL_ZERO_OFFSET" }, { 11396, 666756, "MDC_ECG_CTL_VBL_VALID_RANGE" }, { 11397, 666757, "MDC_ECG_CTL_VBL_PAD_VALUE" }, { 11398, 666758, "MDC_ECG_CTL_VBL_TIME_SKEW" }, { 11399, 666759, "MDC_ECG_CTL_VBL_SAMPLE_SKEW" }, { 11400, 666760, "MDC_ECG_CTL_VBL_TIME_OFFSET" }, { 11401, 666761, "MDC_ECG_CTL_VBL_QTC_METHOD" }, { 11402, 666762, "MDC_ECG_CTL_VBL_ATTR_FILTER_LOW_PASS" }, { 11403, 666763, "MDC_ECG_CTL_VBL_ATTR_FILTER_CUTOFF_FREQ" }, { 11404, 666764, "MDC_ECG_CTL_VBL_ATTR_FILTER_HIGH_PASS" }, { 11405, 666765, "MDC_ECG_CTL_VBL_ATTR_FILTER_ORDER" }, { 11406, 666766, "MDC_ECG_CTL_VBL_ATTR_FILTER_DESCRIPTION" }, { 11407, 666767, "MDC_ECG_CTL_VBL_ATTR_FILTER_NOTCH" }, { 11408, 666768, "MDC_ECG_CTL_VBL_ATTR_FILTER_NOTCH_FREQ" }, { 11409, 666769, "MDC_ECG_CTL_VBL_ATTR_FILTER_NOTCH_BANDWIDTH" }, { 11410, 666770, "MDC_ECG_CTL_VBL_ATTR_FILTER_DESCRIPTION" }, { 11411, 666771, "MDC_ECG_CTL_VBL_BASELINE" }, { 11412, 666772, "MDC_ECG_CTL_VBL_BASELINE_DESC" }, { 11413, 666773, "MDC_ECG_CTL_VBL_BASELINE_ORDER" }, { 11414, 666774, "MDC_ECG_CTL_VBL_INTERPOLATOR" }, { 11415, 666775, "MDC_ECG_CTL_VBL_INTERPOLATOR_SRC_SAMP_RATE" }, { 11416, 666776, "MDC_ECG_CTL_VBL_INTERPOLATOR_DESC" }, { 11417, 666777, "MDC_ECG_CTL_VBL_INTERPOLATOR_ORDER" }, { 11418, 666778, "MDC_ECG_CTL_VBL_INTERPOLATOR_SNR" }, { 11419, 666779, "MDC_ECG_CTL_VBL_DISPLAYED_SIZE" }, { 11420, 666780, "MDC_ECG_CTL_VBL_DISPLAYED_COLOR" }, { 11421, 666781, "MDC_ECG_CTL_VBL_DISPLAYED_SWEEP_RATE" }, { 11422, 666782, "MDC_ECG_CTL_VBL_ATTR_RHTYHM" }, { 11423, 666783, "MDC_ECG_CTL_VBL_ATTR_AV_COND" }, { 11424, 666784, "MDC_ECG_CTL_VBL_ATTR_SA_COND" }, { 11425, 666785, "MDC_ECG_CTL_VBL_ATTR_RHYTHM_CRITERIA" }, { 11426, 666786, "MDC_ECG_CTL_VBL_ATTR_RHYTHM_CODE" }, { 11427, 666787, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_HIGH_GT" }, { 11428, 666788, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_HIGH_GE" }, { 11429, 666789, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_LOW_LT" }, { 11430, 666790, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_LOW_LE" }, { 11431, 666791, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_LOW_GT" }, { 11432, 666792, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_LOW_GE" }, { 11433, 666793, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_HIGH_LT" }, { 11434, 666794, "MDC_ECG_CTL_VBL_ATTR_RATE_LIMIT_HIGH_LE" }, { 16188, 147260, "MDC_ECG_QRS_TYPE" }, { 11328, 666688, "MDC_ECG_QRS_MORPH_NUM" }, { 11329, 666689, "MDC_ECG_VPC_FOCUS_NUM" }, { 11330, 666690, "MDC_ECG_NOISE_TYPE" }, { 11331, 666691, "MDC_ECG_BEAT_TOC" }, { 11332, 666692, "MDC_ECG_RHYTHM_TYPE" }, { 11333, 666693, "MDC_ECG_RHYTHM_AV_COND" }, { 11334, 666694, "MDC_ECG_RHYTHM_SA_COND" }, { 11335, 666695, "MDC_ECG_WAVC_TYPE" }, { 11336, 666696, "MDC_ECG_WAVP_TYPE" }, { 11337, 666697, "MDC_ECG_WAVC_ONSET" }, { 11338, 666698, "MDC_ECG_WAVC_OFFSET" }, { 11339, 666699, "MDC_ECG_WAVC_PEAK" }, { 11340, 666700, "MDC_ECG_WAVC_OTHER" }, { 11341, 666701, "MDC_ECG_INTERPRETATION" }, { 11342, 666702, "MDC_ECG_INTERPRETATION_STATEMENT" }, { 11343, 666703, "MDC_ECG_INTERPRETATION_COMMENT" }, { 11344, 666704, "MDC_ECG_INTERPRETATION_SUMMARY" }, biosig-2.3.3/biosig4c++/src/0000775000175000017500000000000014105434233015576 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/src/ttl2trig.c0000664000175000017500000003000614105434233017514 0ustar schloeglschloegl/* $Id$ Copyright (C) Alois Schloegl, IST Austria 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 3 of the License, 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, see . */ #include #include #include #include #include #include #ifdef WITH_BIOSIG #include "../biosig2.h" #ifdef NDEBUG #define VERBOSE_LEVEL 0 // turn off debugging information #else extern int VERBOSE_LEVEL; // used for debugging #endif #endif int VERBOSE=3; #define TO_STOP_PRESS_ANY_KEY #ifdef TO_STOP_PRESS_ANY_KEY /* copied from http://ubuntuforums.org/showthread.php?t=936816 on 2011-Oct-28 */ #include #include #include #include int is_key_pressed(void) { struct timeval tv; fd_set fds; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); return FD_ISSET(STDIN_FILENO, &fds); } #endif int main(int argc, const char* argv[]) { #if defined(WITH_BIOSIG) && !defined(NDEBUG) // set verbose level of libbiosig VERBOSE_LEVEL = VERBOSE; #endif /********************************************* read arguments **********************************************/ const char *cmd = NULL; const char *cmdf = NULL; const char *cmdr = NULL; int k; int rc; int size; const char *pcm_name=NULL; snd_pcm_t *pcm_handle; snd_pcm_hw_params_t *hwparams; int dir; snd_pcm_uframes_t frames; int16_t *buffer; unsigned int Fs = 44100; unsigned chan = 0; // default channel unsigned winlen = 0; const float WINLEN = 0.001; // window lengths for computing steepness: default is 1 ms float TH = NAN; #ifdef TO_STOP_PRESS_ANY_KEY /* initialization for IS_KEY_PRESSED() */ struct termios old_terminal_settings, new_terminal_settings; // Get the current terminal settings if (tcgetattr(0, &old_terminal_settings) < 0) perror("tcgetattr()"); memcpy(&new_terminal_settings, &old_terminal_settings, sizeof(struct termios)); // disable canonical mode processing in the line discipline driver new_terminal_settings.c_lflag &= ~ICANON; // apply our new settings if (tcsetattr(0, TCSANOW, &new_terminal_settings) < 0) perror("tcsetattr ICANON"); #endif #ifdef WITH_BIOSIG const char *outFile = NULL; HDRTYPE *hdr = NULL; #endif const char help[]= "TTL2TRIG reads a signal from an audio channel, in order to trigger the execution of a shell command\n" " Whenever the difference within a distance of 1ms exceeds the threshold, the command string is executed.\n" " Copyright (C) 2011 Alois Schloegl, IST Austria, .\n" " This program is licensed under the GNU GPL v3 or later.\n\n" "Usage: ttl2trig -c \"command string\" -i hw --chan=1 --Threshold=+0.5 [-o outfile]\n" " -c \"command string executed on raising edge when TH>0 or on falling edge when TH<0\"\n" " -r \"command string executed on raising edge when slope becomes larger than abs(TH)\"\n" " -f \"command string executed on falling edge when slope becomes smaller than -abs(TH)\"\n" " --chan=# # represents than channel number used for triggering, default 1\n" " -th TH\n" " --threshold=TH\n" " when y( t ) - y(t - 1 ms) becomes larger than +abs(TH), a raising edge is detected,\n" " when y( t ) - y(t - 1 ms) becomes smaller than -abs(TH), a falling edge is detected,\n" #ifdef WITH_BIOSIG " -o outfile, logs the recorded signal data; this can be useful for debugging and for identifying the proper threshold and window length.\n" #endif " -i or \n" " --hwparams= where is the input channel like hw:2,0 \n" " The later arguments have higher precedence than the earlier ones.\n" " Specifically -c overrides -r and -f; and -r and -f override -c. \n\n" " Example:\n\t./bin/ttl2trig -c \"date\" -i hw:2,0 --chan=0 --Threshold=.25 \n\n" ; if (argc<2) { fprintf(stdout,"%s",help); exit(0); } k = 0; while (k3) fprintf(stdout,"%i/%i\t%s\n",k,argc,argv[k]); if (0) { } else if (isdigit(argv[k][0]) && ( strstr(argv[k],"hz") || strstr(argv[k],"Hz") ) ) { char *tmp; Fs = strtod(argv[k],&tmp); } else if (!strcmp(argv[k],"-c")) { cmd = argv[++k]; cmdf = NULL; cmdr = NULL; } else if (!strcmp(argv[k],"-r")) { cmdr = argv[++k]; cmd = NULL; } else if (!strcmp(argv[k],"-f")) { cmdf = argv[++k]; cmd = NULL; } else if (!strncmp(argv[k],"--chan=",7)) { chan = atoi(argv[k]+7); if (chan>0) chan--; // change from one-based to zero-based indexing } else if (!strncmp(argv[k],"--threshold=",12) || !strncmp(argv[k],"--Threshold=",12) ) { TH = atof(argv[k]+12); } else if ( !strcmp(argv[k],"-th") ) { TH = atof(argv[++k]); } else if (!strncmp(argv[k],"-v",2)) { VERBOSE = atoi(argv[k]+2); #if defined(WITH_BIOSIG) && !defined(NDEBUG) // set verbose level of libbiosig VERBOSE_LEVEL = VERBOSE; #endif } else if (!strcmp(argv[k],"-h") || !strcmp(argv[k],"--help")) { fprintf(stdout,"%s",help); exit(0); } #ifdef WITH_BIOSIG else if (!strcmp(argv[k],"-o")) { k++; outFile = argv[k]; } #endif else if (!strcmp(argv[k],"--hwparams=")) { pcm_name = argv[k]+11; } else if (!strcmp(argv[k],"-i")) { k++; pcm_name = argv[k]; } k++; } /* Sanity checks of input arguments */ if ( (TH==0) || (TH != TH) ) { fprintf(stderr,"Threshold %g undefined or invalid\n",TH); // exit(-1); } if (VERBOSE>6) fprintf(stdout,"pcm_name:\t%s \n", pcm_name); if (VERBOSE>7) { int val; printf("ALSA library version: %s\n", SND_LIB_VERSION_STR); printf("\nPCM stream types:\n"); for (val = 0; val <= SND_PCM_STREAM_LAST; val++) printf(" %s\n", snd_pcm_stream_name((snd_pcm_stream_t)val)); printf("\nPCM access types:\n"); for (val = 0; val <= SND_PCM_ACCESS_LAST; val++) printf(" %s\n", snd_pcm_access_name((snd_pcm_access_t)val)); printf("\nPCM formats:\n"); for (val = 0; val <= SND_PCM_FORMAT_LAST; val++) if (snd_pcm_format_name((snd_pcm_format_t)val)!= NULL) printf(" %s (%s)\n", snd_pcm_format_name((snd_pcm_format_t)val), snd_pcm_format_description((snd_pcm_format_t)val)); printf("\nPCM subformats:\n"); for (val = 0; val <= SND_PCM_SUBFORMAT_LAST; val++) printf(" %s (%s)\n", snd_pcm_subformat_name((snd_pcm_subformat_t)val), snd_pcm_subformat_description((snd_pcm_subformat_t)val)); printf("\nPCM states:\n"); for (val = 0; val <= SND_PCM_STATE_LAST; val++) printf(" %s\n", snd_pcm_state_name((snd_pcm_state_t)val)); } /********************************************* initialization **********************************************/ /* Open PCM device for recording (capture). */ rc = snd_pcm_open(&pcm_handle, pcm_name, SND_PCM_STREAM_CAPTURE, 0); if (rc < 0) { fprintf(stderr, "unable to open pcm device: %s\n", snd_strerror(rc)); exit(1); } /* Allocate a hardware parameters object. */ snd_pcm_hw_params_alloca(&hwparams); /* Fill it in with default values. */ snd_pcm_hw_params_any(pcm_handle, hwparams); /* Set the desired hardware parameters. */ /* Interleaved mode */ snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED); /* Signed 16-bit little-endian format */ snd_pcm_hw_params_set_format(pcm_handle, hwparams, SND_PCM_FORMAT_S16_LE); // snd_pcm_hw_params_set_format(pcm_handle, hwparams, SND_PCM_FORMAT_FLOAT_LE ); #ifdef WITH_BIOSIG uint16_t gdftyp = 3; double DigMax = ldexp(1,15)-1; double PhysMax = 1; TH *= DigMax/PhysMax; #endif /* Two channels (stereo) */ unsigned int minChan, maxChan; snd_pcm_hw_params_get_channels_min(hwparams, &minChan); snd_pcm_hw_params_get_channels_max(hwparams, &maxChan); if (VERBOSE>7) printf("chans = [%i %i]\n", minChan, maxChan); if ( chan >= minChan) { fprintf(stderr,"ERROR: Channel %i not available.\n", chan); snd_pcm_close(pcm_handle); exit(-1); } snd_pcm_hw_params_set_channels(pcm_handle, hwparams, minChan); /* 44100 bits/second sampling rate (CD quality) */ snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &Fs, &dir); /* Set period size to 32 frames. */ frames = 1;//Fs*0.01; // 10 ms winlen = Fs*WINLEN; // window length // frames = 2*winlen; snd_pcm_hw_params_set_period_size_near(pcm_handle, hwparams, &frames, &dir); /* Write the parameters to the driver */ rc = snd_pcm_hw_params(pcm_handle, hwparams); if (rc < 0) { fprintf(stderr, "unable to set hw parameters: %s\n", snd_strerror(rc)); exit(1); } /* Use a buffer large enough to hold one period */ snd_pcm_hw_params_get_period_size(hwparams, &frames, &dir); size = frames * 2; /* 2 bytes/sample, 2 channels */ size = 2 * winlen * minChan * 2; /* 2 bytes/sample, 2 channels */ buffer = (int16_t *) malloc(size*2); for (k=0; k < size; k++) buffer[k] = 0x8000; #ifdef WITH_BIOSIG if (outFile) { hdr = constructHDR(minChan,0); hdr->SampleRate = Fs; hdr->SPR = 1; hdr->NRec = -1; hdr->EVENT.N = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->LeadIdCode = 0; strcpy(hc->Label,"chan "); hc->Label[6]= k + '0'; hc->GDFTYP = gdftyp; hc->SPR = hdr->SPR; hc->PhysMax = PhysMax; hc->PhysMin =-PhysMax; hc->DigMax = DigMax; hc->DigMin =-DigMax; } hdr->FLAG.UCAL = 0; hdr->TYPE = GDF; hdr->VERSION = 3.0; hdr->FileName = strdup(outFile); sopen(outFile, "w", hdr); if (VERBOSE>6) hdr2ascii(hdr, stdout, 3); if (hdr->FILE.OPEN < 2) { destructHDR(hdr); hdr = NULL; } } #endif #ifdef TO_STOP_PRESS_ANY_KEY fprintf(stdout, "\n ====== PRESS ANY KEY TO STOP ======\n"); #else fprintf(stdout, "\n ====== PRESS TO STOP ======\n"); // set stdin to non-blocking int flags = fcntl(0, F_GETFL, 0); /* get current file status flags */ flags |= O_NONBLOCK; /* turn off blocking flag */ fcntl(0, F_SETFL, flags); /* set up non-blocking read */ #endif size_t count = 0, pos = 0; float delta, lastdelta = NAN; while (1) { /* stop when key pressed */ #ifdef TO_STOP_PRESS_ANY_KEY if (is_key_pressed()) break; #else char tmpbuf[4]; if (fgets(tmpbuf, sizeof(tmpbuf), stdin) != NULL) break; #endif /* read data from alsa */ int16_t *buf = buffer + pos % size; rc = snd_pcm_readi(pcm_handle, buf, 1); pos += rc * minChan; if (rc == -EPIPE) { /* EPIPE means overrun */ fprintf(stderr, "overrun occurred\n"); snd_pcm_prepare(pcm_handle); } else if (rc < 0) { fprintf(stderr, "error from read: %s\n", snd_strerror(rc)); } #ifdef WITH_BIOSIG if (hdr) { /* write data to GDF file */ count += fwrite(buf, 2*hdr->NS, rc, hdr->FILE.FID); } #else count = rc; #endif /********************************************* trigger command **********************************************/ /* compute dY and compare with Threshold */ delta = buf[chan] - buffer[ (pos - winlen + chan) % size ]; if ( ( (TH > 0.0) && (delta > TH) && (lastdelta < TH) ) || ( (TH < 0.0) && (delta < TH) && (lastdelta > TH) ) ) { if (cmd) system(cmd); } if ( (cmdr != NULL) && (delta > TH) && (lastdelta < TH)) { system(cmdr); } if ( (cmdf != NULL) && (delta < -TH) && (lastdelta > -TH) ) { system(cmdf); } lastdelta = delta; } fprintf(stdout, "\n ====== STOPPED ====== \n"); snd_pcm_drain(pcm_handle); snd_pcm_close(pcm_handle); free(buffer); /********************************************* clean up **********************************************/ #ifdef WITH_BIOSIG if (hdr) { hdr->NRec = count; sclose(hdr); destructHDR(hdr); } #endif } biosig-2.3.3/biosig4c++/src/flowmon2.c0000664000175000017500000005321514105434233017513 0ustar schloeglschloegl/* # Copyright (C) 2011,2012 Alois Schloegl, IST Austria # # 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 3 of the License, 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, see . */ /* Supported Device(s): Flow Meter GSM-D3KA-BN00 from Vögtlin Instruments DONE(+)/TODO(-): - units of flow l/min oder m^3/h ?? + graceful handling of exit (close all handles even when stopped with -C + one file per day, appending + autostart - file management, data compression, (/var/spool/... /etc/flowmon.conf - init.d (flowmon start/stop) - fix appending to *.log.gdf file after restart - javascript interface Requirements: g++ libz 1.2.5 or higher libbiosig.a (v1.2 or higher) available from http://biosig.sf.net */ #include "../biosig.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #define LENBUF 300 #define BAUDRATE B9600 #define MODEMDEVICE "/dev/ttyUSB0" #define _POSIX_SOURCE 1 //POSIX compliant source #define FALSE 0 #define TRUE 1 int wait_flag=TRUE; //TRUE while no signal received //void signal_handler_IO (int status); //definition of signal handler char buf[LENBUF+1] __attribute__ ((deprecated)); uint8_t idata[LENBUF]; uint8_t odata[LENBUF]; char manufacturer[1000]; int fd; FILE *fid=NULL; FILE *fid2=NULL; // biosig HDRTYPE *hdr = NULL; struct termios oldtio, newtio; //place for old and new port settings for serial port void stop() { // reset terminal if (fd>2) { tcsetattr(fd, TCSANOW, &oldtio); close(fd); } // close gdf file if (hdr) destructHDR(hdr); // close debug file if (fid2) fclose(fid2); } const void *outPtr = odata+3; /* crc16_a001: computes crc of a modbus packet and writes it at the end; (remark: its not CCITT's crc16 but uses 0xA001 polynomial) input : data : packet with its crc n : length of data without the crc ouput : crc16 value */ #if defined(__LITTLE_ENDIAN) uint16_t crc16_a001(uint8_t data[], size_t n) { uint8_t flag; size_t i,j; union { uint16_t u16; uint8_t u8[2]; } crc; crc.u16 = 0xffff; for (i=0; i> 1; if (flag) crc.u16 = crc.u16^0xa001; } } // write crc to end of data block *(uint16_t*)(data+n) = crc.u16; return (uint16_t)crc.u16; } int read_register(uint8_t slave, uint8_t cmd, uint16_t reg) { idata[0] = slave; // address idata[1] = 3; //cmd; // read - *(uint16_t*)(idata+2) = bswap_16((uint16_t)reg); // register *(uint16_t*)(idata+4) = bswap_16(0x0004); // length crc16_a001(idata,6); // compute crc and add at and tcflush(fd, TCIOFLUSH); int c = write(fd,idata,8); if (VERBOSE_LEVEL>8) fprintf(stdout,"\n======= SENT %i bytes\n",c); usleep(100000); c = read(fd,odata,16); if (VERBOSE_LEVEL>8) fprintf(stdout,"\n======= RECEIVED %i bytes\n",c); if (c<9 || odata[0] != slave) return (-1); if (VERBOSE_LEVEL==6) fprintf(stdout,"\n======= REG:0x%04x RECEIVED %2i bytes U16[2]: 0x%08x %08x %08x %08x F:%10g %10g<%s> ",\ reg,c,beu32p(odata),beu32p(odata+4),beu32p(odata+8),beu32p(odata+12), \ (double)bef32p(odata+3), (double)bef32p(odata+7), (char*)(odata+3)); uint16_t crc=bswap_16(crc16_a001(odata,c-2)); if (VERBOSE_LEVEL>8) fprintf(stdout,"crc 0x%04x 0x%04x",bswap_16(crc),beu16p(odata+c-2)); usleep(10000); if (crc!=beu16p(odata+c-2)) return -1; return 0; } #else #error CRC16 function not defined for big endian platform #endif int main(int argc, char *argv[]) { char *devicename = "/dev/ttyUSB0"; const char *outFile = NULL; const char *debugFile = NULL; // 00 = NONE, 01 = Odd, 02 = Even, 03 = Mark, 04 = Space struct timeval tv; struct timezone tz; struct tm *tm; struct tm T; uint32_t oldDay=0, newDay; gdf_time gdfTime; char flag_GZIP = 0; char logfile[48] = "flowmonYYYYMMDD.log.gdf"; char debugfile[] = "flowmonDD.log.txt"; /*************************************************************************** * * input arguments * ***************************************************************************/ const char help[]= "FLOWMON reads data of the flow sensor through the serial terminal and stores it into a data file for archiving.\n" " The current measurement values are also written into the file /var/www/flowsensor.html.\n" " This software supports the device 'Flow Meter GSM-D3KA-BN00 (BHT Rotary Gas Meter) from Vögtlin Instruments'.\n\n" "Usage: flowmon -d devicename [-o outfile] [-D debugfile] [-V#]\n" " devicename: default value is /dev/ttyS0\n" " outfile: logs the recorded data\n" " If no outfile is provided, the data will be logged into daily files named flowmon<$date>.log.gdf \n" " debugfile: logs the data in ascii text\n" " If no outfile is provided, the data will be logged into daily files named flowmon<$day-of-month>.log.txt \n" " -V# verbose level #=0 is no messages, #=9 is highest level(debugging) messages\n" " -h, --help: display this help text\n" " -z save outfile in gzipped format\n" " \n\n" ; if (argc<2) { fprintf(stdout,"%s",help); return(0); } /* Sanity checks of input arguments */ int k = 0; while (k3) fprintf(stdout,"%i/%i\t%s\n",k,argc,argv[k]); if (0) { } else if (!strcmp(argv[k],"-d")) { devicename = argv[++k]; } else if (!strcmp(argv[k],"-h") || !strcmp(argv[k],"--help") ) { fprintf(stdout,"%s",help); return 0; } else if (!strcmp(argv[k],"-o")) { k++; outFile = argv[k]; } else if (!strcmp(argv[k],"-D")) { k++; debugFile = argv[k]; } else if (!strncmp(argv[k],"-V",2)) { char c = argv[k][2]; #ifndef VERBOSE_LEVEL if ('0'<=c && c<='9') VERBOSE_LEVEL = c-'0'; #endif } else if (!strcmp(argv[k],"-z")) { flag_GZIP = 1; } k++; } /*************************************************************************** * * initialization * ***************************************************************************/ // clean up at exit atexit(&stop); gettimeofday(&tv, &tz); tm = gmtime(&tv.tv_sec); gdfTime = tm_time2gdf_time(gmtime(&tv.tv_sec)) + (uint64_t)ldexp(tv.tv_usec*1e-6/(24*3600),32); newDay = gdfTime>>32; gdf_time2tm_time_r(gdfTime, &T); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): err %d\n",__FILE__,__LINE__,errno); //open the device(com port) to be non-blocking (read will return immediately) fd = open(devicename, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { perror(devicename); exit(EXIT_FAILURE); } tcgetattr(fd,&oldtio); // save current port settings if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): fd=%d\n",__FILE__,__LINE__,fd); // set new port settings for canonical input processing // newtio.c_cflag = BAUD | CRTSCTS | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD; newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD | CSTOPB; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; newtio.c_lflag = 0; //ICANON; newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME]= 0; tcflush(fd, TCIOFLUSH); tcsetattr(fd,TCSANOW,&newtio); if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): err %d\n",__FILE__,__LINE__,errno); if (errno) { fprintf(stderr,"%s (line %d) %d %s\n", __FILE__, __LINE__, errno, strerror(errno)); stop(); return(errno); } #if 1 if (debugFile) fid2 = fopen(debugFile,"a"); else { sprintf(debugfile,"flowmon%02d.log.txt",tm->tm_mday); fid2 = fopen(debugfile,"a"); } { hdr = constructHDR(4 ,0); hdr->SampleRate = 1; hdr->SPR = 1; hdr->NRec = -1; hdr->EVENT.N = 0; hdr->FILE.COMPRESSION = 0; { // channel 1: time stamp CHANNEL_TYPE *hc = hdr->CHANNEL + 0; hc->LeadIdCode = 0; strcpy(hc->Label,"time "); hc->GDFTYP = 8; // uint64 hc->SPR = hdr->SPR; hc->PhysMax = ldexp(1,32); hc->PhysMin = 0; hc->DigMax = ldexp(1,64); hc->DigMin = 0; hc->PhysDimCode = PhysDimCode("d"); // days hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } { // channel 2: volume CHANNEL_TYPE *hc = hdr->CHANNEL + 1; hc->LeadIdCode = 0; strcpy(hc->Label,"total volume "); hc->GDFTYP = 6; // uint32 hc->GDFTYP = 16; // float32 hc->SPR = hdr->SPR; hc->PhysMax = ldexp(1,32); hc->PhysMin = -hc->PhysMax; hc->DigMax = hc->PhysMax; hc->DigMin = hc->PhysMin; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; read_register(247, 3, 0x6384) ; // f32: Skalierung Totalisator, and s8: Einheit des Totalisatorwertes mit 4 Byte offset. //read_register(247, 3, 0x6386) ; // s8: Einheit des Totalisatorwertes if (!strcmp((char*)(outPtr+4),"ln")) hc->PhysDimCode = PhysDimCode("l"); else hc->PhysDimCode = 0; // "unknown" } { // channel 3: flow CHANNEL_TYPE *hc = hdr->CHANNEL + 2; hc->LeadIdCode = 0; strcpy(hc->Label,"flow "); hc->GDFTYP = 3; // int16 hc->GDFTYP = 16; // float32 hc->SPR = hdr->SPR; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; read_register(247, 3, 0x6020) ; // f32: Endwert Messbereich hc->PhysMax = bef32p(outPtr); hc->PhysMin = -hc->PhysMax; hc->DigMax = hc->PhysMax; hc->DigMin = hc->PhysMin; read_register(247, 3, 0x6022) ; // s50: Bezeichnung Medium Lang strncpy(hc->Transducer,(char*)(outPtr+1),MAX_LENGTH_TRANSDUCER); read_register(247, 3, 0x6042) ; // s8: Bezeichnung Medium kurz strncpy(hc->Transducer,(char*)(outPtr),MAX_LENGTH_LABEL); read_register(247, 3, 0x6046) ; // s8: Einheit Messwert if (!strcmp((char*)outPtr,"ln/h")) { //hc->PhysDimCode = 3072; // "l min-1" hc->PhysDimCode = 3104; // "l h-1" } else hc->PhysDimCode = 0; // "unknown" // read_register(247, 3, 0x6046) ; // s8: Einheit Messwert read_register(247, 3, 0x6120) ; // u16: Verstärkung, Amplification; und u16 Heizleistung (2 byte offset), und u16: Dynamik (4 Byte offset) //read_register(247, 3, 0x6121) ; // u16: Heizleistung //read_register(247, 3, 0x6122) ; // u16: Dynamik } { // channel 4: temparature CHANNEL_TYPE *hc = hdr->CHANNEL + 3; hc->LeadIdCode = 0; strcpy(hc->Label,"Temperature"); hc->GDFTYP = 16; // float32 hc->SPR = hdr->SPR; hc->PhysMax = 500; hc->PhysMin = -500; hc->DigMax = 500; hc->DigMin = -500; hc->PhysDimCode = 6048; // degree Celsius hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } if (hdr->NS > 4) { // channel 5: type of gas CHANNEL_TYPE *hc = hdr->CHANNEL + 4; hc->LeadIdCode = 0; strcpy(hc->Label,"typ of gas"); hc->GDFTYP = 2; // uint8 hc->SPR = hdr->SPR; hc->PhysMax = 255; hc->PhysMin = 0; hc->DigMax = 255; hc->DigMin = 0; hc->PhysDimCode = 0; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->LeadIdCode = 0; hc->SPR = 1; } hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); hdr->ID.Manufacturer.Name = "Voegtlin"; /* hdr->ID.Manufacturer.Model = "Flow Meter"; hdr->ID.Manufacturer.Version = "GSM-D3KA-BN00"; hdr->ID.Manufacturer.SerialNumber = "150427"; */ read_register(247, 3, 0x0023) ; // Typencode 1: Gerätebezeichnung Teil 1 hdr->ID.Manufacturer.Model = (char*)manufacturer; strcpy(manufacturer,"FlowMeter "); strcat(manufacturer, outPtr); read_register(247, 3, 0x1004) ; // Typencode 2: Gerätebezeichnung Teil 2 strcat(manufacturer, outPtr); read_register(247, 3, 0x0020); // u16: Hardware Version number, uint16_t HardWareVersion = beu16p(outPtr); // read_register(247, 3, 0x0021); // u16: Software Version number: is available also from previous request with 2 byte offset uint16_t SoftWareVersion = beu16p(outPtr+2); // u16: Software Version number hdr->ID.Manufacturer.Version = manufacturer+strlen(manufacturer)+1; sprintf((char*)(hdr->ID.Manufacturer.Version),"Hardware: %d.%d.%d Software: %d.%d.%d", \ HardWareVersion>>8, \ (HardWareVersion & 0xF0)>>4, \ HardWareVersion & 0x0F, \ SoftWareVersion>>8, \ (SoftWareVersion & 0xF0)>>4, \ SoftWareVersion & 0x0F \ ); read_register(247, 3, 0x001e) ; // u32: serial number hdr->ID.Manufacturer.SerialNumber = hdr->ID.Manufacturer.Version+strlen(hdr->ID.Manufacturer.Version)+1; sprintf((char*)(hdr->ID.Manufacturer.SerialNumber),"%d",beu32p(outPtr)); hdr->FLAG.UCAL = 1; hdr->TYPE = GDF; hdr->VERSION = 2.0; if (outFile) hdr->FileName = strdup(outFile); } #endif read_register(247, 3, 0x0000) ; // float32: Messwert Gasdurchfluss read_register(247, 3, 0x0002) ; // float32: Temperatur // read_register(247, 3, 0x0006) ; // float32: Sollwert Gasdurchfluss // read_register(247, 3, 0x0008) ; // float32: Messwert Analogeingang read_register(247, 3, 0x000c) ; // u16: Alarmmeldungen read_register(247, 3, 0x000d) ; // u16: Hardwarefehler //read_register(247, 3, 0x000e) ; // u16: Regelmode //read_register(247, 3, 0x000f) ; // u16: Ramp read_register(247, 3, 0x0013) ; // device address: default 247 (0xf7) //read_register(247, 3, 0x0020) ; //read_register(247, 3, 0x0021) ; // read_register(247, 3, 0x5200) ; // u16: baud rate read_register(247, 3, 0x0004) ; // f32: Totalisator 1 read_register(247, 3, 0x6380) ; // f32: Totalisator 1, and f32 Totalisator 2 with 4 Byte offset. //read_register(247, 3, 0x6382) ; // f32: Totalisator 2 - nicht rückstellbar read_register(247, 3, 0x6384) ; // f32: Skalierung Totalisator, and s8: Einheit des Totalisatorwertes mit 4 Byte offset. //read_register(247, 3, 0x6386) ; // s8: Einheit des Totalisatorwertes if (outFile) { // open once write all data into single log file hdr->FILE.COMPRESSION = flag_GZIP; hdr = sopen(outFile, "a", hdr); if (VERBOSE_LEVEL>7) hdr2ascii(hdr,stdout,4); if (serror2(hdr)) { destructHDR(hdr); return(EXIT_FAILURE); } if (hdr->FILE.OPEN < 2) { destructHDR(hdr); hdr = NULL; fprintf(stderr,"Could not open output file %s\n", outFile); exit(-1); } hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); if (hdr->NRec < 0) hdr->NRec = 0; } /*************************************************************************** * * processing: data is continuosly read from serial interface and written to log and debug file * ***************************************************************************/ fid = fdopen(fd, "r+"); while (1) { /*** get data ***/ if (read_register(247, 3, 0x0004)) continue; // f32: Totalisator 1 float TotalVolume = bef32p(outPtr); if (read_register(247, 3, 0x0000)) continue; // float32: Messwert Gasdurchfluss, and f32: Temperatur with 4 byte offset //read_register(247, 3, 0x0002) ; // float32: Temperatur float Flow = bef32p(outPtr); float Temperature = bef32p(outPtr+4); /* if (read_register(247, 3, 0x6380)) continue; // f32: Totalisator 2 float TotalVolume2 = bef32p(outPtr); float TotalVolume3 = bef32p(outPtr+4); */ gettimeofday(&tv, &tz); tm = gmtime(&tv.tv_sec); gdfTime = tm_time2gdf_time(gmtime(&tv.tv_sec)) + (uint64_t)ldexp(tv.tv_usec*1e-6/(24*3600),32); newDay = gdfTime>>32; gdf_time2tm_time_r(gdfTime, &T); if ( (newDay != oldDay) && !outFile) { // open/close daily log file sclose(hdr); hdr->NRec = -1; sprintf(logfile,"flowmon%04d%02d%02d.log.gdf",T.tm_year+1900,T.tm_mon+1,T.tm_mday); hdr->FILE.COMPRESSION = flag_GZIP; hdr = sopen(logfile, "a", hdr); if (serror2(hdr)) { destructHDR(hdr); return(EXIT_FAILURE); } if (!hdr->FILE.OPEN) { destructHDR(hdr); hdr = NULL; fprintf(stderr,"Could not open output file %s\n", logfile); } hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); if (hdr->NRec<0) hdr->NRec = 0; } if ( (newDay != oldDay) && !debugFile) { // open/close daily debug file if (fid2>0) fclose(fid2); sprintf(debugfile,"flowmon%02d.log.txt",T.tm_mday); fid2 = fopen(debugfile,"a"); } if (newDay != oldDay) { oldDay = newDay; }; /*** parse data ***/ memcpy(hdr->AS.rawdata+hdr->CHANNEL[0].bi,&gdfTime,8); *(float*)(hdr->AS.rawdata+hdr->CHANNEL[1].bi)=TotalVolume; *(float*)(hdr->AS.rawdata+hdr->CHANNEL[2].bi)=Flow; *(float*)(hdr->AS.rawdata+hdr->CHANNEL[3].bi)=Temperature; if (hdr) { if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 230 %i, %i, %i\n", (int)hdr->NRec, hdr->AS.bpb, hdr->FILE.OPEN); if (VERBOSE_LEVEL>8) fprintf(stdout,"FLOWMON 240 %g, %g, %g\n", TotalVolume,Flow,Temperature); hdr->NRec += ifwrite(hdr->AS.rawdata, hdr->AS.bpb, 1, hdr); ifflush(hdr); /******************************************************************* * Write HTML file *******************************************************************/ char buf[100]; strfgdftime(buf,100,"%Y-%m-%d %H:%M:%S UTC",gdfTime); FILE *fid3 = fopen("/var/www/flowsensor.html","w"); if (fid3 != NULL) { fprintf(fid3,"

Carbogen FlowSensor


Time:\t\t%s\n",buf);
                                fprintf(fid3,"Manufacturer:\t%s \nModel:\t\t%s\nSerialNo:\t%s\nVersion:\t%s\n",hdr->ID.Manufacturer.Name, hdr->ID.Manufacturer.Model,hdr->ID.Manufacturer.SerialNumber,hdr->ID.Manufacturer.Version);
                                fprintf(fid3,"Total Volume:\t%10.3f  l_n\n",TotalVolume);
                                //fprintf(fid3,"Total Volume 2:\t%10.3f  l_n (nicht ruecksetzbar)\n",TotalVolume2);
                                //fprintf(fid3,"Total Volume -:\t%10.3f  l_n (nicht ruecksetzbar)\n",TotalVolume3);
                                fprintf(fid3,"Flow:\t\t %10.4f l_n/h\n",Flow);
                                fprintf(fid3,"Temperature:\t%6.3f C\n
",Temperature); fclose(fid3); } } } stop(); return(0); } biosig-2.3.3/biosig4c++/src/flowmon.c0000664000175000017500000003753014105434233017433 0ustar schloeglschloegl/* # Copyright (C) 2011,2012 Alois Schloegl, IST Austria # # 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 3 of the License, 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, see . */ /* Device supported: VPFlowMate inline from VPInstruments DONE(+)/TODO(-): + units of flow l/min oder m^3/h ?? + graceful handling of exit (close all handles even when stopped with -C + one file per day, appending + autostart - file management, data compression - init.d (flowmon start/stop) - fix appending to *.log.gdf file after restart - configure serial number, type etc. + graceful handling of exit (close all handles even when stopped with -C + one file per day */ #include "../biosig.h" #include #include #include #include #include #include #include #include #include #include #include #define LENBUF 100 #define BAUDRATE B9600 #define MODEMDEVICE "/dev/ttyS0" #define _POSIX_SOURCE 1 //POSIX compliant source #define FALSE 0 #define TRUE 1 int wait_flag=TRUE; //TRUE while no signal received void signal_handler_IO (int status); //definition of signal handler char buf[LENBUF+1]; int fd; FILE *fid=NULL; FILE *fid2=NULL; // biosig HDRTYPE *hdr = NULL; struct termios oldtio, newtio; //place for old and new port settings for serial port void stop() { // reset terminal if ( (fd>2) && memcmp(&oldtio,&newtio,sizeof(oldtio)) ) tcsetattr(fd,TCSANOW,&oldtio); if (fid) fclose(fid); // close gdf file if (hdr) destructHDR(hdr); // close debug file if (fid2) fclose(fid2); } int main(int argc, char *argv[]) { const char *devicename = "/dev/ttyS0"; const char *outFile = NULL; const char *debugFile = NULL; struct sigaction saio; //definition of signal action long BAUD; // derived baud rate from command line long DATABITS; long STOPBITS; long PARITYON; long PARITY; int Data_Bits = 8; // Number of data bits int Stop_Bits = 1; // Number of stop bits int Parity = 0; // Parity as follows: // 00 = NONE, 01 = Odd, 02 = Even, 03 = Mark, 04 = Space struct timeval tv; struct timezone tz; struct tm *tm; struct tm T; uint32_t oldDay=0, newDay; gdf_time gdfTime; char flag_GZIP = 0; char logfile[] = "flowmonYYYYMMDD.log.gdf"; char debugfile[] = "flowmonDD.log.txt"; /*************************************************************************** * * input arguments * ***************************************************************************/ const char help[]= "FLOWMON reads data of the flow sensor through the serial terminal and stores it into a data file for archiving.\n" " This software supports the device 'VPFlowMate inline from VPInstruments'.\n\n" "Usage: flowmon -d devicename [-o outfile] [-D debugfile] [-V#]\n" " devicename: default value is /dev/ttyS0\n" " outfile: logs the recorded data\n" " If no outfile is provided, the data will be logged into daily files named flowmon<$date>.log.gdf \n" " debugfile: logs the data in ascii text" " If no outfile is provided, the data will be logged into daily files named flowmon<$day-of-month>.log.txt \n" " -V# verbose level #=0 is no messages, #=9 is highest level(debugging) messages\n" " -z save outfile in gzipped format" " \n\n" ; if (argc<2) { fprintf(stdout,"%s",help); // exit(0); } /* Sanity checks of input arguments */ int k = 0; while (k3) fprintf(stdout,"%i/%i\t%s\n",k,argc,argv[k]); if (0) { } else if (!strcmp(argv[k],"-d")) { devicename = argv[++k]; } else if (!strcmp(argv[k],"-o")) { k++; outFile = argv[k]; } else if (!strcmp(argv[k],"-D")) { k++; debugFile = argv[k]; } else if (!strncmp(argv[k],"-V",2)) { char c = argv[k][2]; if ('0'<=c && c<='9') VERBOSE_LEVEL = c-'0'; } else if (!strcmp(argv[k],"-z")) { flag_GZIP = 1; } k++; } /*************************************************************************** * * initialization * ***************************************************************************/ // clean up at exit atexit(&stop); gettimeofday(&tv, &tz); tm = gmtime(&tv.tv_sec); gdfTime = tm_time2gdf_time(gmtime(&tv.tv_sec)) + (uint64_t)ldexp(tv.tv_usec*1e-6/(24*3600),32); newDay = gdfTime>>32; gdf_time2tm_time_r(gdfTime, &T); if (debugFile) fid2 = fopen(debugFile,"a"); else { sprintf(debugfile,"flowmon%02d.log.txt",tm->tm_mday); fid2 = fopen(debugfile,"a"); } { hdr = constructHDR(4,0); hdr->SampleRate = 1; hdr->SPR = 1; hdr->NRec = -1; hdr->EVENT.N = 0; hdr->FILE.COMPRESSION = 0; { // channel 0: time stamp CHANNEL_TYPE *hc = hdr->CHANNEL + 0; hc->LeadIdCode = 0; strcpy(hc->Label,"time "); hc->GDFTYP = 8; // uint64 hc->SPR = hdr->SPR; hc->PhysMax = ldexp(1,32); hc->PhysMin = 0; hc->DigMax = ldexp(1,64); hc->DigMin = 0; hc->PhysDimCode = PhysDimCode("d"); // days hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } { // channel 1: volume CHANNEL_TYPE *hc = hdr->CHANNEL + 1; hc->LeadIdCode = 0; strcpy(hc->Label,"total volume "); hc->GDFTYP = 6; // uint32 hc->SPR = hdr->SPR; hc->PhysMax = ldexp(1,32); hc->PhysMin = 0; hc->DigMax = ldexp(1,32); hc->DigMin = 0; hc->PhysDimCode = PhysDimCode("l"); hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } { // channel 2: flow CHANNEL_TYPE *hc = hdr->CHANNEL + 2; hc->LeadIdCode = 0; strcpy(hc->Label,"flow "); hc->GDFTYP = 3; // int16 hc->SPR = hdr->SPR; hc->PhysMax = (ldexp(1,15)-1)/10; hc->PhysMin =-ldexp(1,15)/10; hc->DigMax = ldexp(1,15)-1; hc->DigMin =-ldexp(1,15); hc->PhysDimCode = 3072; // "l min-1" hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } { // channel 3: type of gas CHANNEL_TYPE *hc = hdr->CHANNEL + 3; hc->LeadIdCode = 0; strcpy(hc->Label,"typ of gas"); hc->GDFTYP = 2; // uint8 hc->SPR = hdr->SPR; hc->PhysMax = 255; hc->PhysMin = 0; hc->DigMax = 255; hc->DigMin = 0; hc->PhysDimCode = 0; hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3; } for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->LeadIdCode = 0; hc->SPR = 1; } hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); hdr->ID.Manufacturer.Name = "VPInstruments"; hdr->ID.Manufacturer.Model = "VPFlowMate"; hdr->ID.Manufacturer.Version = "VPF-R0030-M050-D1-S110-E200"; hdr->ID.Manufacturer.SerialNumber = "103569"; hdr->FLAG.UCAL = 1; hdr->TYPE = GDF; hdr->VERSION = 2.22; hdr->FileName = outFile; } if (outFile) { // open once write all data into single log file hdr->FILE.COMPRESSION = flag_GZIP; hdr = sopen(outFile, "a", hdr); // hdr2ascii(hdr,stdout,4); if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 010 %i\n", (int)hdr->NRec); if (serror2(hdr)) { destructHDR(hdr); return(EXIT_FAILURE); } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 020\n"); // if (VERBOSE_LEVEL>6) hdr2ascii(hdr, stdout, 3); if (hdr->FILE.OPEN < 2) { destructHDR(hdr); hdr = NULL; fprintf(stderr,"Could not open output file %s\n", outFile); exit(-1); } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 030\n"); hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); if (hdr->NRec < 0) hdr->NRec = 0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 090\n"); //open the device(com port) to be non-blocking (read will return immediately) fd = open(devicename, O_RDWR | O_NOCTTY); if (fd < 0) { perror(devicename); exit(EXIT_FAILURE); } //install the serial handler before making the device asynchronous saio.sa_handler = signal_handler_IO; sigemptyset(&saio.sa_mask); //saio.sa_mask = 0; saio.sa_flags = 0; saio.sa_restorer = NULL; sigaction(SIGIO,&saio,NULL); // allow the process to receive SIGIO fcntl(fd, F_SETOWN, getpid()); // Make the file descriptor asynchronous (the manual page says only // O_APPEND and O_NONBLOCK, will work with F_SETFL...) fcntl(fd, F_SETFL, FASYNC); tcgetattr(fd,&oldtio); // save current port settings // set new port settings for canonical input processing // newtio.c_cflag = BAUD | CRTSCTS | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD; newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; newtio.c_lflag = 0; //ICANON; newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME]= 0; tcflush(fd, TCIFLUSH); tcsetattr(fd,TCSANOW,&newtio); /*************************************************************************** * * processing: data is continuosly read from serial interface and written to log and debug file * ***************************************************************************/ fid = fdopen(fd, "r"); double data[4]; while (1) { /*** get data ***/ fgets(buf, LENBUF, fid); gettimeofday(&tv, &tz); tm = gmtime(&tv.tv_sec); gdfTime = tm_time2gdf_time(gmtime(&tv.tv_sec)) + (uint64_t)ldexp(tv.tv_usec*1e-6/(24*3600),32); newDay = gdfTime>>32; gdf_time2tm_time_r(gdfTime, &T); if ( (newDay != oldDay) && !outFile) { // open/close daily log file if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 110\n"); sclose(hdr); hdr->NRec = -1; hdr->CHANNEL[2].PhysDimCode = 2976; // make sure stored unit is in "m3/h" sprintf(logfile,"flowmon%04i%02i%02i.log.gdf",T.tm_year+1900,T.tm_mon+1,T.tm_mday); hdr->FILE.COMPRESSION = flag_GZIP; hdr = sopen(logfile, "a", hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 120 %p\n", hdr); if (serror2(hdr)) { destructHDR(hdr); return(EXIT_FAILURE); } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 125 %i\n", (int)hdr->NRec); if (!hdr->FILE.OPEN) { destructHDR(hdr); hdr = NULL; fprintf(stderr,"Could not open output file %s\n", logfile); } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 130\n"); hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb); if (hdr->NRec<0) hdr->NRec = 0; } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 140\n"); if ( (newDay != oldDay) && !debugFile) { // open/close daily debug file if (fid2>0) fclose(fid2); sprintf(debugfile,"flowmon%02d.log.txt",T.tm_mday); fid2 = fopen(debugfile,"a"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 150\n"); if (newDay != oldDay) { oldDay = newDay; }; if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 190\n"); /*** parse data ***/ size_t i=0,pos[4]; pos[0]=0; pos[1]=0; pos[2]=0; pos[3]=strlen(buf); while (i7) fprintf(stdout,"FLOWMON 210\n"); buf[pos[1]] = 0; buf[pos[2]] = 0; buf[pos[3]-2] = 0; // fprintf(stdout,"%i\t%x\t%c\t%i\t%i\t%i\n",i, (uint8_t)buf[i], buf[i],pos[0],pos[1],pos[2]); if (pos[2] > 0) { fprintf(fid2,"|%s|\t|%s|\t|%s|\n",buf+4,buf+pos[1]+4,buf+pos[2]+4); // volume: data[1] = atof(&(buf[pos[2]+4])); // flow: data[2] = atof(buf+4)*10; char *t = strchr(buf+4,'.'); t[0]=t[1]; t[1]='.'; // shift decimal point by one digit, multiply by 10 // uint16_t flow10 = atol(buf+4); // gas: data[3] = buf[pos[1]+4]; memcpy(hdr->AS.rawdata+hdr->CHANNEL[0].bi,&gdfTime,8); *(uint32_t*)(hdr->AS.rawdata+hdr->CHANNEL[1].bi) = (uint32_t)atol(buf+pos[2]+4); *(uint16_t*)(hdr->AS.rawdata+hdr->CHANNEL[2].bi) = (uint16_t)atof(buf+4); *(uint8_t *)(hdr->AS.rawdata+hdr->CHANNEL[3].bi) = (uint8_t)buf[pos[1]+4]; /*** write data ***/ fprintf(fid2,"%04d-%02d-%02d %02d:%02d:%02d.%02d \t%u\t%lu\n",tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec, data[2], data[1]); fprintf(fid2,"%f\t%u\t%u\t%u\n",ldexp(gdfTime,-32),*(uint32_t*)(hdr->AS.rawdata+hdr->CHANNEL[1].bi),*(uint16_t*)(hdr->AS.rawdata+hdr->CHANNEL[2].bi),*(uint8_t *)(hdr->AS.rawdata+hdr->CHANNEL[3].bi)); //if (hdr) swrite(data,1,hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 220\n"); if (hdr) { if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 230 %i, %i, %i\n", (int)hdr->NRec, hdr->AS.bpb, hdr->FILE.OPEN); hdr->NRec += ifwrite(hdr->AS.rawdata, hdr->AS.bpb, 1, hdr); ifflush(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 290 %i\n", (int)hdr->NRec); } } } stop(); return(0); } /*************************************************************************** * signal handler. sets wait_flag to FALSE, to indicate above loop that * * characters have been received. * ***************************************************************************/ void signal_handler_IO (int status) { // printf("received SIGIO signal.\n"); wait_flag = FALSE; } biosig-2.3.3/biosig4c++/t240/0000775000175000017500000000000014105434245015503 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/t240/FilterType.c0000664000175000017500000000711514105434233017737 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "FilterType.h" int FilterType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void FilterType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void FilterType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { FilterType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int FilterType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { FilterType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t FilterType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { FilterType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t FilterType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { FilterType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t FilterType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { FilterType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t FilterType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { FilterType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_FilterType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_FilterType = { "FilterType", "FilterType", FilterType_free, FilterType_print, FilterType_constraint, FilterType_decode_ber, FilterType_encode_der, FilterType_decode_xer, FilterType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_FilterType_tags_1, sizeof(asn_DEF_FilterType_tags_1) /sizeof(asn_DEF_FilterType_tags_1[0]), /* 1 */ asn_DEF_FilterType_tags_1, /* Same as above */ sizeof(asn_DEF_FilterType_tags_1) /sizeof(asn_DEF_FilterType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/DeviceCode.c0000664000175000017500000000710614105434233017642 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DeviceCode.h" int DeviceCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void DeviceCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void DeviceCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { DeviceCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int DeviceCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { DeviceCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t DeviceCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { DeviceCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t DeviceCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { DeviceCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t DeviceCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { DeviceCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t DeviceCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { DeviceCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_DeviceCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_DeviceCode = { "DeviceCode", "DeviceCode", DeviceCode_free, DeviceCode_print, DeviceCode_constraint, DeviceCode_decode_ber, DeviceCode_encode_der, DeviceCode_decode_xer, DeviceCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DeviceCode_tags_1, sizeof(asn_DEF_DeviceCode_tags_1) /sizeof(asn_DEF_DeviceCode_tags_1[0]), /* 1 */ asn_DEF_DeviceCode_tags_1, /* Same as above */ sizeof(asn_DEF_DeviceCode_tags_1) /sizeof(asn_DEF_DeviceCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MedicalDeviceSystemSection.c0000664000175000017500000003074514105434233023065 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MedicalDeviceSystemSection.h" static asn_TYPE_member_t asn_MBR_systemspecification_10[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SystemSpecEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_systemspecification_tags_10[] = { (ASN_TAG_CLASS_APPLICATION | (2437 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_systemspecification_specs_10 = { sizeof(struct MedicalDeviceSystemSection__systemspecification), offsetof(struct MedicalDeviceSystemSection__systemspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_systemspecification_10 = { "systemspecification", "systemspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_systemspecification_tags_10, sizeof(asn_DEF_systemspecification_tags_10) /sizeof(asn_DEF_systemspecification_tags_10[0]) - 1, /* 1 */ asn_DEF_systemspecification_tags_10, /* Same as above */ sizeof(asn_DEF_systemspecification_tags_10) /sizeof(asn_DEF_systemspecification_tags_10[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_systemspecification_10, 1, /* Single element */ &asn_SPC_systemspecification_specs_10 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_productionspecification_12[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ProdSpecEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_productionspecification_tags_12[] = { (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_productionspecification_specs_12 = { sizeof(struct MedicalDeviceSystemSection__productionspecification), offsetof(struct MedicalDeviceSystemSection__productionspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_productionspecification_12 = { "productionspecification", "productionspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_productionspecification_tags_12, sizeof(asn_DEF_productionspecification_tags_12) /sizeof(asn_DEF_productionspecification_tags_12[0]) - 1, /* 1 */ asn_DEF_productionspecification_tags_12, /* Same as above */ sizeof(asn_DEF_productionspecification_tags_12) /sizeof(asn_DEF_productionspecification_tags_12[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_productionspecification_12, 1, /* Single element */ &asn_SPC_productionspecification_specs_12 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_MedicalDeviceSystemSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, systemtype), (ASN_TAG_CLASS_APPLICATION | (2438 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_DeviceCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "systemtype" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, systemmodel), (ASN_TAG_CLASS_APPLICATION | (2344 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SystemModel, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "systemmodel" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, systemid), (ASN_TAG_CLASS_APPLICATION | (2436 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "systemid" }, { ATF_POINTER, 1, offsetof(struct MedicalDeviceSystemSection, compatibilityid), (ASN_TAG_CLASS_APPLICATION | (2336 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compatibilityid" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, nomenclatureversion), (ASN_TAG_CLASS_APPLICATION | (2376 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nomenclatureversion" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, requirednomenclatureversion), (ASN_TAG_CLASS_APPLICATION | (6013 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "requirednomenclatureversion" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceSystemSection, usednomenclatureversion), (ASN_TAG_CLASS_APPLICATION | (6014 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "usednomenclatureversion" }, { ATF_POINTER, 10, offsetof(struct MedicalDeviceSystemSection, systemspecification), (ASN_TAG_CLASS_APPLICATION | (2437 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_systemspecification_10, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "systemspecification" }, { ATF_POINTER, 9, offsetof(struct MedicalDeviceSystemSection, productionspecification), (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_productionspecification_12, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "productionspecification" }, { ATF_POINTER, 8, offsetof(struct MedicalDeviceSystemSection, bedlabel), (ASN_TAG_CLASS_APPLICATION | (2334 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bedlabel" }, { ATF_POINTER, 7, offsetof(struct MedicalDeviceSystemSection, softid), (ASN_TAG_CLASS_APPLICATION | (2350 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "softid" }, { ATF_POINTER, 6, offsetof(struct MedicalDeviceSystemSection, operatingmode), (ASN_TAG_CLASS_APPLICATION | (2374 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "operatingmode" }, { ATF_POINTER, 5, offsetof(struct MedicalDeviceSystemSection, applicationarea), (ASN_TAG_CLASS_APPLICATION | (2317 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ApplicationArea, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "applicationarea" }, { ATF_POINTER, 4, offsetof(struct MedicalDeviceSystemSection, powerstatus), (ASN_TAG_CLASS_APPLICATION | (2389 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PowerStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "powerstatus" }, { ATF_POINTER, 3, offsetof(struct MedicalDeviceSystemSection, altitude), (ASN_TAG_CLASS_APPLICATION | (2316 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "altitude" }, { ATF_POINTER, 2, offsetof(struct MedicalDeviceSystemSection, linefrequency), (ASN_TAG_CLASS_APPLICATION | (2357 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_LineFrequency, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "linefrequency" }, { ATF_POINTER, 1, offsetof(struct MedicalDeviceSystemSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_POINTER, 0, offsetof(struct MedicalDeviceSystemSection, components), -1 /* Ambiguous tag (CHOICE?) */, 0, &asn_DEF_MedicalDeviceComponents, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "components" }, }; static ber_tlv_tag_t asn_DEF_MedicalDeviceSystemSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MedicalDeviceSystemSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2316 << 2)), 15, 0, 0 }, /* altitude at 544 */ { (ASN_TAG_CLASS_APPLICATION | (2317 << 2)), 13, 0, 0 }, /* applicationarea at 539 */ { (ASN_TAG_CLASS_APPLICATION | (2334 << 2)), 10, 0, 0 }, /* bedlabel at 529 */ { (ASN_TAG_CLASS_APPLICATION | (2336 << 2)), 4, 0, 0 }, /* compatibilityid at 501 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 486 */ { (ASN_TAG_CLASS_APPLICATION | (2344 << 2)), 2, 0, 0 }, /* systemmodel at 493 */ { (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), 9, 0, 0 }, /* productionspecification at 525 */ { (ASN_TAG_CLASS_APPLICATION | (2350 << 2)), 11, 0, 0 }, /* softid at 533 */ { (ASN_TAG_CLASS_APPLICATION | (2357 << 2)), 16, 0, 0 }, /* linefrequency at 547 */ { (ASN_TAG_CLASS_APPLICATION | (2374 << 2)), 12, 0, 0 }, /* operatingmode at 537 */ { (ASN_TAG_CLASS_APPLICATION | (2376 << 2)), 5, 0, 0 }, /* nomenclatureversion at 504 */ { (ASN_TAG_CLASS_APPLICATION | (2389 << 2)), 14, 0, 0 }, /* powerstatus at 541 */ { (ASN_TAG_CLASS_APPLICATION | (2436 << 2)), 3, 0, 0 }, /* systemid at 497 */ { (ASN_TAG_CLASS_APPLICATION | (2437 << 2)), 8, 0, 0 }, /* systemspecification at 520 */ { (ASN_TAG_CLASS_APPLICATION | (2438 << 2)), 1, 0, 0 }, /* systemtype at 489 */ { (ASN_TAG_CLASS_APPLICATION | (6013 << 2)), 6, 0, 0 }, /* requirednomenclatureversion at 508 */ { (ASN_TAG_CLASS_APPLICATION | (6014 << 2)), 7, 0, 0 }, /* usednomenclatureversion at 513 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 17, 0, 0 }, /* placeholder at 550 */ { (ASN_TAG_CLASS_APPLICATION | (7009 << 2)), 18, 0, 0 }, /* medicaldevice at 596 */ { (ASN_TAG_CLASS_APPLICATION | (7010 << 2)), 18, 0, 0 }, /* medicaldevices at 600 */ { (ASN_TAG_CLASS_APPLICATION | (7011 << 2)), 18, 0, 0 } /* subsystems at 606 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MedicalDeviceSystemSection_specs_1 = { sizeof(struct MedicalDeviceSystemSection), offsetof(struct MedicalDeviceSystemSection, _asn_ctx), asn_MAP_MedicalDeviceSystemSection_tag2el_1, 21, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MedicalDeviceSystemSection = { "MedicalDeviceSystemSection", "MedicalDeviceSystemSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MedicalDeviceSystemSection_tags_1, sizeof(asn_DEF_MedicalDeviceSystemSection_tags_1) /sizeof(asn_DEF_MedicalDeviceSystemSection_tags_1[0]), /* 1 */ asn_DEF_MedicalDeviceSystemSection_tags_1, /* Same as above */ sizeof(asn_DEF_MedicalDeviceSystemSection_tags_1) /sizeof(asn_DEF_MedicalDeviceSystemSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MedicalDeviceSystemSection_1, 19, /* Elements count */ &asn_SPC_MedicalDeviceSystemSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PowerStatus.h0000664000175000017500000000177714105434233020165 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PowerStatus_H_ #define _PowerStatus_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum PowerStatus { PowerStatus_onMains = 0, PowerStatus_onBattery = 1, PowerStatus_chargingFull = 8, PowerStatus_chargingTrickle = 9, PowerStatus_chargingOff = 10 } e_PowerStatus; /* PowerStatus */ typedef BIT_STRING_t PowerStatus_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PowerStatus; asn_struct_free_f PowerStatus_free; asn_struct_print_f PowerStatus_print; asn_constr_check_f PowerStatus_constraint; ber_type_decoder_f PowerStatus_decode_ber; der_type_encoder_f PowerStatus_encode_der; xer_type_decoder_f PowerStatus_decode_xer; xer_type_encoder_f PowerStatus_encode_xer; #ifdef __cplusplus } #endif #endif /* _PowerStatus_H_ */ biosig-2.3.3/biosig4c++/t240/SystemSpecEntry.h0000664000175000017500000000135314105434233020774 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SystemSpecEntry_H_ #define _SystemSpecEntry_H_ #include /* Including external dependencies */ #include "PrivateCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* SystemSpecEntry */ typedef struct SystemSpecEntry { PrivateCode_t component_capab_id; ANY_t component_spec; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SystemSpecEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SystemSpecEntry; #ifdef __cplusplus } #endif #endif /* _SystemSpecEntry_H_ */ biosig-2.3.3/biosig4c++/t240/AlertFlags.h0000664000175000017500000000202014105434233017667 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertFlags_H_ #define _AlertFlags_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum AlertFlags { AlertFlags_localaudible = 1, AlertFlags_remoteaudible = 2, AlertFlags_visuallatching = 3, AlertFlags_audiblelatching = 4, AlertFlags_derived = 6, AlertFlags_recordinhibit = 8 } e_AlertFlags; /* AlertFlags */ typedef BIT_STRING_t AlertFlags_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertFlags; asn_struct_free_f AlertFlags_free; asn_struct_print_f AlertFlags_print; asn_constr_check_f AlertFlags_constraint; ber_type_decoder_f AlertFlags_decode_ber; der_type_encoder_f AlertFlags_encode_der; xer_type_decoder_f AlertFlags_decode_xer; xer_type_encoder_f AlertFlags_encode_xer; #ifdef __cplusplus } #endif #endif /* _AlertFlags_H_ */ biosig-2.3.3/biosig4c++/t240/LineFrequency.h0000664000175000017500000000174314105434233020427 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _LineFrequency_H_ #define _LineFrequency_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum LineFrequency { LineFrequency_line_f_unspec = 0, LineFrequency_line_f_50hz = 1, LineFrequency_line_f_60hz = 2 } e_LineFrequency; /* LineFrequency */ typedef INTEGER_t LineFrequency_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_LineFrequency; asn_struct_free_f LineFrequency_free; asn_struct_print_f LineFrequency_print; asn_constr_check_f LineFrequency_constraint; ber_type_decoder_f LineFrequency_decode_ber; der_type_encoder_f LineFrequency_encode_der; xer_type_decoder_f LineFrequency_decode_xer; xer_type_encoder_f LineFrequency_encode_xer; #ifdef __cplusplus } #endif #endif /* _LineFrequency_H_ */ biosig-2.3.3/biosig4c++/t240/ChoiceOfEnumTimeStamp.c0000664000175000017500000001712514105434233022002 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ChoiceOfEnumTimeStamp.h" static asn_TYPE_member_t asn_MBR_absolutetimestamparray_3[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (24 << 2)), 0, &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_absolutetimestamparray_tags_3[] = { (ASN_TAG_CLASS_APPLICATION | (6042 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_absolutetimestamparray_specs_3 = { sizeof(struct ChoiceOfEnumTimeStamp__absolutetimestamparray), offsetof(struct ChoiceOfEnumTimeStamp__absolutetimestamparray, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_absolutetimestamparray_3 = { "absolutetimestamparray", "absolutetimestamparray", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_absolutetimestamparray_tags_3, sizeof(asn_DEF_absolutetimestamparray_tags_3) /sizeof(asn_DEF_absolutetimestamparray_tags_3[0]) - 1, /* 1 */ asn_DEF_absolutetimestamparray_tags_3, /* Same as above */ sizeof(asn_DEF_absolutetimestamparray_tags_3) /sizeof(asn_DEF_absolutetimestamparray_tags_3[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_absolutetimestamparray_3, 1, /* Single element */ &asn_SPC_absolutetimestamparray_specs_3 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_relativetimestamparray_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_RelativeTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_relativetimestamparray_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6043 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_relativetimestamparray_specs_5 = { sizeof(struct ChoiceOfEnumTimeStamp__relativetimestamparray), offsetof(struct ChoiceOfEnumTimeStamp__relativetimestamparray, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_relativetimestamparray_5 = { "relativetimestamparray", "relativetimestamparray", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_relativetimestamparray_tags_5, sizeof(asn_DEF_relativetimestamparray_tags_5) /sizeof(asn_DEF_relativetimestamparray_tags_5[0]) - 1, /* 1 */ asn_DEF_relativetimestamparray_tags_5, /* Same as above */ sizeof(asn_DEF_relativetimestamparray_tags_5) /sizeof(asn_DEF_relativetimestamparray_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_relativetimestamparray_5, 1, /* Single element */ &asn_SPC_relativetimestamparray_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_hirestimestamparray_7[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HighResRelativeTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_hirestimestamparray_tags_7[] = { (ASN_TAG_CLASS_APPLICATION | (6044 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_hirestimestamparray_specs_7 = { sizeof(struct ChoiceOfEnumTimeStamp__hirestimestamparray), offsetof(struct ChoiceOfEnumTimeStamp__hirestimestamparray, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_hirestimestamparray_7 = { "hirestimestamparray", "hirestimestamparray", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_hirestimestamparray_tags_7, sizeof(asn_DEF_hirestimestamparray_tags_7) /sizeof(asn_DEF_hirestimestamparray_tags_7[0]) - 1, /* 1 */ asn_DEF_hirestimestamparray_tags_7, /* Same as above */ sizeof(asn_DEF_hirestimestamparray_tags_7) /sizeof(asn_DEF_hirestimestamparray_tags_7[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_hirestimestamparray_7, 1, /* Single element */ &asn_SPC_hirestimestamparray_specs_7 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ChoiceOfEnumTimeStamp_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumTimeStamp, choice.timestamp), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ObservationTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timestamp" }, { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumTimeStamp, choice.absolutetimestamparray), (ASN_TAG_CLASS_APPLICATION | (6042 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_absolutetimestamparray_3, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "absolutetimestamparray" }, { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumTimeStamp, choice.relativetimestamparray), (ASN_TAG_CLASS_APPLICATION | (6043 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_relativetimestamparray_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "relativetimestamparray" }, { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumTimeStamp, choice.hirestimestamparray), (ASN_TAG_CLASS_APPLICATION | (6044 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_hirestimestamparray_7, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "hirestimestamparray" }, }; static asn_TYPE_tag2member_t asn_MAP_ChoiceOfEnumTimeStamp_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* timestamp at 1367 */ { (ASN_TAG_CLASS_APPLICATION | (6042 << 2)), 1, 0, 0 }, /* absolutetimestamparray at 1368 */ { (ASN_TAG_CLASS_APPLICATION | (6043 << 2)), 2, 0, 0 }, /* relativetimestamparray at 1369 */ { (ASN_TAG_CLASS_APPLICATION | (6044 << 2)), 3, 0, 0 } /* hirestimestamparray at 1371 */ }; static asn_CHOICE_specifics_t asn_SPC_ChoiceOfEnumTimeStamp_specs_1 = { sizeof(struct ChoiceOfEnumTimeStamp), offsetof(struct ChoiceOfEnumTimeStamp, _asn_ctx), offsetof(struct ChoiceOfEnumTimeStamp, present), sizeof(((struct ChoiceOfEnumTimeStamp *)0)->present), asn_MAP_ChoiceOfEnumTimeStamp_tag2el_1, 4, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ChoiceOfEnumTimeStamp = { "ChoiceOfEnumTimeStamp", "ChoiceOfEnumTimeStamp", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_ChoiceOfEnumTimeStamp_1, 4, /* Elements count */ &asn_SPC_ChoiceOfEnumTimeStamp_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ObservationTime.c0000664000175000017500000000531214105434233020757 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ObservationTime.h" static asn_TYPE_member_t asn_MBR_ObservationTime_1[] = { { ATF_POINTER, 3, offsetof(struct ObservationTime, absolutetimestamp), (ASN_TAG_CLASS_APPLICATION | (2448 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "absolutetimestamp" }, { ATF_POINTER, 2, offsetof(struct ObservationTime, relativetimestamp), (ASN_TAG_CLASS_APPLICATION | (2449 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_RelativeTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "relativetimestamp" }, { ATF_POINTER, 1, offsetof(struct ObservationTime, hirestimerelativestamp), (ASN_TAG_CLASS_APPLICATION | (2537 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HighResRelativeTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "hirestimerelativestamp" }, }; static ber_tlv_tag_t asn_DEF_ObservationTime_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ObservationTime_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2448 << 2)), 0, 0, 0 }, /* absolutetimestamp at 158 */ { (ASN_TAG_CLASS_APPLICATION | (2449 << 2)), 1, 0, 0 }, /* relativetimestamp at 159 */ { (ASN_TAG_CLASS_APPLICATION | (2537 << 2)), 2, 0, 0 } /* hirestimerelativestamp at 160 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ObservationTime_specs_1 = { sizeof(struct ObservationTime), offsetof(struct ObservationTime, _asn_ctx), asn_MAP_ObservationTime_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ObservationTime = { "ObservationTime", "ObservationTime", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ObservationTime_tags_1, sizeof(asn_DEF_ObservationTime_tags_1) /sizeof(asn_DEF_ObservationTime_tags_1[0]), /* 1 */ asn_DEF_ObservationTime_tags_1, /* Same as above */ sizeof(asn_DEF_ObservationTime_tags_1) /sizeof(asn_DEF_ObservationTime_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ObservationTime_1, 3, /* Elements count */ &asn_SPC_ObservationTime_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PersonName.c0000664000175000017500000000574014105434233017721 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PersonName.h" static asn_TYPE_member_t asn_MBR_PersonName_1[] = { { ATF_POINTER, 4, offsetof(struct PersonName, ungroupedname), (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ungroupedname" }, { ATF_POINTER, 3, offsetof(struct PersonName, characternamegroup), (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "characternamegroup" }, { ATF_POINTER, 2, offsetof(struct PersonName, ideographicnamegroup), (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ideographicnamegroup" }, { ATF_POINTER, 1, offsetof(struct PersonName, phoneticnamegroup), (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "phoneticnamegroup" }, }; static ber_tlv_tag_t asn_DEF_PersonName_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_PersonName_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), 0, 0, 0 }, /* ungroupedname at 195 */ { (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), 1, 0, 0 }, /* characternamegroup at 196 */ { (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), 2, 0, 0 }, /* ideographicnamegroup at 197 */ { (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), 3, 0, 0 } /* phoneticnamegroup at 198 */ }; static asn_SEQUENCE_specifics_t asn_SPC_PersonName_specs_1 = { sizeof(struct PersonName), offsetof(struct PersonName, _asn_ctx), asn_MAP_PersonName_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_PersonName = { "PersonName", "PersonName", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PersonName_tags_1, sizeof(asn_DEF_PersonName_tags_1) /sizeof(asn_DEF_PersonName_tags_1[0]), /* 1 */ asn_DEF_PersonName_tags_1, /* Same as above */ sizeof(asn_DEF_PersonName_tags_1) /sizeof(asn_DEF_PersonName_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_PersonName_1, 4, /* Elements count */ &asn_SPC_PersonName_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/FEFString.h0000664000175000017500000000142014105434233017435 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _FEFString_H_ #define _FEFString_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* FEFString */ typedef UTF8String_t FEFString_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_FEFString; asn_struct_free_f FEFString_free; asn_struct_print_f FEFString_print; asn_constr_check_f FEFString_constraint; ber_type_decoder_f FEFString_decode_ber; der_type_encoder_f FEFString_encode_der; xer_type_decoder_f FEFString_decode_xer; xer_type_encoder_f FEFString_encode_xer; #ifdef __cplusplus } #endif #endif /* _FEFString_H_ */ biosig-2.3.3/biosig4c++/t240/SessionTestSection.h0000664000175000017500000000341214105434233021461 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SessionTestSection_H_ #define _SessionTestSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "FEFString.h" #include "AbsoluteTime.h" #include "Placeholder.h" #include "MedicalDeviceSystemSection.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ArchiveProtection; struct MultimediaSection; struct SessionPhaseSection; /* SessionTestSection */ typedef struct SessionTestSection { Handle_t handle; FEFString_t st_archive_id; FEFString_t st_archive_name; FEFString_t *st_archive_comments /* OPTIONAL */; AbsoluteTime_t starttime; AbsoluteTime_t stoptime; struct ArchiveProtection *protection /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; MedicalDeviceSystemSection_t medicaldevicesystem; struct SessionTestSection__multimedia { A_SEQUENCE_OF(struct MultimediaSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *multimedia; struct SessionTestSection__phases { A_SEQUENCE_OF(struct SessionPhaseSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } phases; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SessionTestSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SessionTestSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ArchiveProtection.h" #include "MultimediaSection.h" #include "SessionPhaseSection.h" #endif /* _SessionTestSection_H_ */ biosig-2.3.3/biosig4c++/t240/Comments.c0000664000175000017500000000410214105434233017426 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Comments.h" static asn_TYPE_member_t asn_MBR_Comments_1[] = { { ATF_NOFLAGS, 0, offsetof(struct Comments, commenttext), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "commenttext" }, { ATF_NOFLAGS, 0, offsetof(struct Comments, commentator), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "commentator" }, }; static ber_tlv_tag_t asn_DEF_Comments_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_Comments_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* commenttext at 713 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* commentator at 716 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Comments_specs_1 = { sizeof(struct Comments), offsetof(struct Comments, _asn_ctx), asn_MAP_Comments_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Comments = { "Comments", "Comments", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Comments_tags_1, sizeof(asn_DEF_Comments_tags_1) /sizeof(asn_DEF_Comments_tags_1[0]), /* 1 */ asn_DEF_Comments_tags_1, /* Same as above */ sizeof(asn_DEF_Comments_tags_1) /sizeof(asn_DEF_Comments_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_Comments_1, 2, /* Elements count */ &asn_SPC_Comments_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/asn_codecs.h0000664000175000017500000000654514105434233017764 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _ASN_CODECS_H_ #define _ASN_CODECS_H_ #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * This structure defines a set of parameters that may be passed * to every ASN.1 encoder or decoder function. * WARNING: if max_stack_size member is set, and you are calling the * function pointers of the asn_TYPE_descriptor_t directly, * this structure must be ALLOCATED ON THE STACK! * If you can't always satisfy this requirement, use ber_decode(), * xer_decode() and uper_decode() functions instead. */ typedef struct asn_codec_ctx_s { /* * Limit the decoder routines to use no (much) more stack than a given * number of bytes. Most of decoders are stack-based, and this * would protect against stack overflows if the number of nested * encodings is high. * The OCTET STRING, BIT STRING and ANY BER decoders are heap-based, * and are safe from this kind of overflow. * A value from getrlimit(RLIMIT_STACK) may be used to initialize * this variable. Be careful in multithreaded environments, as the * stack size is rather limited. */ size_t max_stack_size; /* 0 disables stack bounds checking */ } asn_codec_ctx_t; /* * Type of the return value of the encoding functions (der_encode, xer_encode). */ typedef struct asn_enc_rval_s { /* * Number of bytes encoded. * -1 indicates failure to encode the structure. * In this case, the members below this one are meaningful. */ ssize_t encoded; /* * Members meaningful when (encoded == -1), for post mortem analysis. */ /* Type which cannot be encoded */ struct asn_TYPE_descriptor_s *failed_type; /* Pointer to the structure of that type */ void *structure_ptr; } asn_enc_rval_t; #define _ASN_ENCODE_FAILED do { \ asn_enc_rval_t tmp_error; \ tmp_error.encoded = -1; \ tmp_error.failed_type = td; \ tmp_error.structure_ptr = sptr; \ ASN_DEBUG("Failed to encode element %s", td->name); \ return tmp_error; \ } while(0) #define _ASN_ENCODED_OK(rval) do { \ rval.structure_ptr = 0; \ rval.failed_type = 0; \ return rval; \ } while(0) /* * Type of the return value of the decoding functions (ber_decode, xer_decode) * * Please note that the number of consumed bytes is ALWAYS meaningful, * even if code==RC_FAIL. This is to indicate the number of successfully * decoded bytes, hence providing a possibility to fail with more diagnostics * (i.e., print the offending remainder of the buffer). */ enum asn_dec_rval_code_e { RC_OK, /* Decoded successfully */ RC_WMORE, /* More data expected, call again */ RC_FAIL /* Failure to decode data */ }; typedef struct asn_dec_rval_s { enum asn_dec_rval_code_e code; /* Result code */ size_t consumed; /* Number of bytes consumed */ } asn_dec_rval_t; #define _ASN_DECODE_FAILED do { \ asn_dec_rval_t tmp_error; \ tmp_error.code = RC_FAIL; \ tmp_error.consumed = 0; \ ASN_DEBUG("Failed to decode element %s", td->name); \ return tmp_error; \ } while(0) #define _ASN_DECODE_STARVED do { \ asn_dec_rval_t tmp_error; \ tmp_error.code = RC_WMORE; \ tmp_error.consumed = 0; \ return tmp_error; \ } while(0) #ifdef __cplusplus } #endif #endif /* _ASN_CODECS_H_ */ biosig-2.3.3/biosig4c++/t240/Makefile.in0000664000175000017500000000317614105434233017554 0ustar schloeglschloegl-include modules.mk # This file may be used as an input for make(3) # Remove the lines below to convert it into a pure .am file WIN32 = ../win32/libcnsfef.a ../win32/libcnsfef.dll WIN64 = ../win64/libcnsfef.a ../win64/libcnsfef.dll CFLAGS += -pipe -fPIC -Wall -O2 -Wextra -I. OBJS=${ASN_MODULE_SOURCES:.c=.o} WINOBJS=${ASN_MODULE_SOURCES:.c=.obj} W64OBJS=${ASN_MODULE_SOURCES:.c=.o64} ifeq (Darwin,$(shell uname)) CFLAGS += -mmacosx-version-min=10.7 endif CC ?= gcc MinGWCC = $(CROSS)-gcc MinGW64CC = $(CROSS64)-gcc all: libcnsfef.a $(WIN32) libcnsfef.a: $(OBJS) $(AR) libcnsfef.a $(OBJS) ../win32/libcnsfef.a: $(WINOBJS) $(CROSS)-$(AR) ../win32/libcnsfef.a $(WINOBJS) ../win64/libcnsfef.a: $(W64OBJS) $(CROSS64)-$(AR) ../win64/libcnsfef.a $(W64OBJS) ../win32/libcnsfef.dll: $(WINOBJS) $(MinGWCC) -shared -fPIC $(WINOBJS) -Wl,--output-def,../win32/libcnsfef.def,--out-implib,../win32/libcnsfef.dll ../win64/libcnsfef.dll: $(WINOBJS) $(MinGW64CC) -shared -fPIC $(W64OBJS) -Wl,--output-def,../win64/libcnsfef.def,--out-implib,../win64/libcnsfef.dll .SUFFIXES: .SUFFIXES: .c .o %.obj: %.c $(CROSS)-$(CC) $(CFLAGS) -o "$@" -c "$<" %.o64: %.c $(CROSS64)-$(CC) $(CFLAGS) -o "$@" -c "$<" .c.o: $(CC) $(CFLAGS) -o "$@" -c "$<" clean: # rm -f $(ASN_MODULE_HEADERS) # rm -f $(ASN_MODULE_SOURCES) rm -f libcnsfef.a $(WIN32) rm -f $(OBJS) rm -f $(WINOBJS) rm -f $(W64OBJS) rm -f Makefile.am.sample libfef.a regen: regenerate-from-asn1-source regenerate-from-asn1-source: asn1c -fcompound-names fef.asn awk '/^#/ {exit} {print}' Makefile.am.sample >modules.mk rm -f converter-sample.c Makefile.am.sample libfef.a biosig-2.3.3/biosig4c++/t240/Fraction.h0000664000175000017500000000123114105434233017413 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Fraction_H_ #define _Fraction_H_ #include /* Including external dependencies */ #include #include #ifdef __cplusplus extern "C" { #endif /* Fraction */ typedef struct Fraction { INTEGER_t numerator; INTEGER_t denominator; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } Fraction_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Fraction; #ifdef __cplusplus } #endif #endif /* _Fraction_H_ */ biosig-2.3.3/biosig4c++/t240/Placeholder.h0000664000175000017500000000145614105434233020101 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Placeholder_H_ #define _Placeholder_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Placeholder */ typedef OCTET_STRING_t Placeholder_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Placeholder; asn_struct_free_f Placeholder_free; asn_struct_print_f Placeholder_print; asn_constr_check_f Placeholder_constraint; ber_type_decoder_f Placeholder_decode_ber; der_type_encoder_f Placeholder_encode_der; xer_type_decoder_f Placeholder_decode_xer; xer_type_encoder_f Placeholder_encode_xer; #ifdef __cplusplus } #endif #endif /* _Placeholder_H_ */ biosig-2.3.3/biosig4c++/t240/OID-Type.h0000664000175000017500000000137514105434233017211 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _OID_Type_H_ #define _OID_Type_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* OID-Type */ typedef INTEGER_t OID_Type_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_OID_Type; asn_struct_free_f OID_Type_free; asn_struct_print_f OID_Type_print; asn_constr_check_f OID_Type_constraint; ber_type_decoder_f OID_Type_decode_ber; der_type_encoder_f OID_Type_encode_der; xer_type_decoder_f OID_Type_decode_xer; xer_type_encoder_f OID_Type_encode_xer; #ifdef __cplusplus } #endif #endif /* _OID_Type_H_ */ biosig-2.3.3/biosig4c++/t240/DistributionSampleArrayDescriptiveDataSection.h0000664000175000017500000001222214105434233027011 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DistributionSampleArrayDescriptiveDataSection_H_ #define _DistributionSampleArrayDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include "SaSpec.h" #include "ScaleRangeSpec.h" #include "FEFFloat.h" #include "DsaRangeSpec.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct AbsoluteRange; struct SaSignalFrequency; struct MetricCalEntry; struct SaGridEntry; struct SaCalData; struct SaFilterEntry; /* DistributionSampleArrayDescriptiveDataSection */ typedef struct DistributionSampleArrayDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct DistributionSampleArrayDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct DistributionSampleArrayDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct DistributionSampleArrayDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct DistributionSampleArrayDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct DistributionSampleArrayDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct DistributionSampleArrayDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct DistributionSampleArrayDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; SaSpec_t saspecification; PrivateCode_t *compression /* OPTIONAL */; ScaleRangeSpec_t scaleandrangespec; struct AbsoluteRange *saphysiologicalrange /* OPTIONAL */; struct DistributionSampleArrayDescriptiveDataSection__visualgrid { A_SEQUENCE_OF(struct SaGridEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *visualgrid; struct DistributionSampleArrayDescriptiveDataSection__sacalibrationdata { A_SEQUENCE_OF(struct SaCalData) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *sacalibrationdata; struct DistributionSampleArrayDescriptiveDataSection__filterspecification { A_SEQUENCE_OF(struct SaFilterEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *filterspecification; struct SaSignalFrequency *sasignalfrequency /* OPTIONAL */; FEFFloat_t *sameasureresolution /* OPTIONAL */; DsaRangeSpec_t distributionrangespec; UnitsOfMeasurementCode_t *xunitcode /* OPTIONAL */; FEFString_t *xunitlabelstring /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DistributionSampleArrayDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DistributionSampleArrayDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "AbsoluteRange.h" #include "SaSignalFrequency.h" #include "MetricCalEntry.h" #include "SaGridEntry.h" #include "SaCalData.h" #include "SaFilterEntry.h" #endif /* _DistributionSampleArrayDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/MarkerEntryRelTim.h0000664000175000017500000000137314105434233021235 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MarkerEntryRelTim_H_ #define _MarkerEntryRelTim_H_ #include /* Including external dependencies */ #include "MetricsCode.h" #include "RelativeTime.h" #include #ifdef __cplusplus extern "C" { #endif /* MarkerEntryRelTim */ typedef struct MarkerEntryRelTim { MetricsCode_t markerid; RelativeTime_t marktime; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MarkerEntryRelTim_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MarkerEntryRelTim; #ifdef __cplusplus } #endif #endif /* _MarkerEntryRelTim_H_ */ biosig-2.3.3/biosig4c++/t240/EnumRecordMetric.c0000664000175000017500000000415514105434233021060 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumRecordMetric.h" static asn_TYPE_member_t asn_MBR_EnumRecordMetric_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumRecordMetric, record_type_code), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "record-type-code" }, { ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct EnumRecordMetric, record_data), -1 /* Ambiguous tag (ANY?) */, 0, &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "record-data" }, }; static ber_tlv_tag_t asn_DEF_EnumRecordMetric_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumRecordMetric_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* record-type-code at 1358 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumRecordMetric_specs_1 = { sizeof(struct EnumRecordMetric), offsetof(struct EnumRecordMetric, _asn_ctx), asn_MAP_EnumRecordMetric_tag2el_1, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumRecordMetric = { "EnumRecordMetric", "EnumRecordMetric", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumRecordMetric_tags_1, sizeof(asn_DEF_EnumRecordMetric_tags_1) /sizeof(asn_DEF_EnumRecordMetric_tags_1[0]), /* 1 */ asn_DEF_EnumRecordMetric_tags_1, /* Same as above */ sizeof(asn_DEF_EnumRecordMetric_tags_1) /sizeof(asn_DEF_EnumRecordMetric_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumRecordMetric_1, 2, /* Elements count */ &asn_SPC_EnumRecordMetric_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/FEFString.c0000664000175000017500000000712114105434233017434 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "FEFString.h" int FEFString_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_UTF8String.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using UTF8String, * so here we adjust the DEF accordingly. */ static void FEFString_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_UTF8String.free_struct; td->print_struct = asn_DEF_UTF8String.print_struct; td->ber_decoder = asn_DEF_UTF8String.ber_decoder; td->der_encoder = asn_DEF_UTF8String.der_encoder; td->xer_decoder = asn_DEF_UTF8String.xer_decoder; td->xer_encoder = asn_DEF_UTF8String.xer_encoder; td->uper_decoder = asn_DEF_UTF8String.uper_decoder; td->uper_encoder = asn_DEF_UTF8String.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_UTF8String.per_constraints; td->elements = asn_DEF_UTF8String.elements; td->elements_count = asn_DEF_UTF8String.elements_count; td->specifics = asn_DEF_UTF8String.specifics; } void FEFString_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { FEFString_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int FEFString_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { FEFString_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t FEFString_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { FEFString_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t FEFString_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { FEFString_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t FEFString_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { FEFString_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t FEFString_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { FEFString_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_FEFString_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)) }; asn_TYPE_descriptor_t asn_DEF_FEFString = { "FEFString", "FEFString", FEFString_free, FEFString_print, FEFString_constraint, FEFString_decode_ber, FEFString_encode_der, FEFString_decode_xer, FEFString_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_FEFString_tags_1, sizeof(asn_DEF_FEFString_tags_1) /sizeof(asn_DEF_FEFString_tags_1[0]), /* 1 */ asn_DEF_FEFString_tags_1, /* Same as above */ sizeof(asn_DEF_FEFString_tags_1) /sizeof(asn_DEF_FEFString_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/constr_SET_OF.h0000664000175000017500000000204614105434233020262 0ustar schloeglschloegl/*- * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _CONSTR_SET_OF_H_ #define _CONSTR_SET_OF_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct asn_SET_OF_specifics_s { /* * Target structure description. */ int struct_size; /* Size of the target structure. */ int ctx_offset; /* Offset of the asn_struct_ctx_t member */ /* XER-specific stuff */ int as_XMLValueList; /* The member type must be encoded like this */ } asn_SET_OF_specifics_t; /* * A set specialized functions dealing with the SET OF type. */ asn_struct_free_f SET_OF_free; asn_struct_print_f SET_OF_print; asn_constr_check_f SET_OF_constraint; ber_type_decoder_f SET_OF_decode_ber; der_type_encoder_f SET_OF_encode_der; xer_type_decoder_f SET_OF_decode_xer; xer_type_encoder_f SET_OF_encode_xer; per_type_decoder_f SET_OF_decode_uper; per_type_encoder_f SET_OF_encode_uper; #ifdef __cplusplus } #endif #endif /* _CONSTR_SET_OF_H_ */ biosig-2.3.3/biosig4c++/t240/asn_SET_OF.c0000664000175000017500000000325214105434233017526 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Add another element into the set. */ int asn_set_add(void *asn_set_of_x, void *ptr) { asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x); if(as == 0 || ptr == 0) { errno = EINVAL; /* Invalid arguments */ return -1; } /* * Make sure there's enough space to insert an element. */ if(as->count == as->size) { int _newsize = as->size ? (as->size << 1) : 4; void *_new_arr; _new_arr = REALLOC(as->array, _newsize * sizeof(as->array[0])); if(_new_arr) { as->array = (void **)_new_arr; as->size = _newsize; } else { /* ENOMEM */ return -1; } } as->array[as->count++] = ptr; return 0; } void asn_set_del(void *asn_set_of_x, int number, int _do_free) { asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x); if(as) { void *ptr; if(number < 0 || number >= as->count) return; if(_do_free && as->free) { ptr = as->array[number]; } else { ptr = 0; } as->array[number] = as->array[--as->count]; /* * Invoke the third-party function only when the state * of the parent structure is consistent. */ if(ptr) as->free(ptr); } } /* * Free the contents of the set, do not free the set itself. */ void asn_set_empty(void *asn_set_of_x) { asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x); if(as) { if(as->array) { if(as->free) { while(as->count--) as->free(as->array[as->count]); } FREEMEM(as->array); as->array = 0; } as->count = 0; as->size = 0; } } biosig-2.3.3/biosig4c++/t240/ApplicationArea.c0000664000175000017500000000735514105434233020712 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ApplicationArea.h" int ApplicationArea_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void ApplicationArea_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void ApplicationArea_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { ApplicationArea_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int ApplicationArea_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { ApplicationArea_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t ApplicationArea_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { ApplicationArea_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t ApplicationArea_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { ApplicationArea_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t ApplicationArea_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { ApplicationArea_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t ApplicationArea_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { ApplicationArea_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_ApplicationArea_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_ApplicationArea = { "ApplicationArea", "ApplicationArea", ApplicationArea_free, ApplicationArea_print, ApplicationArea_constraint, ApplicationArea_decode_ber, ApplicationArea_encode_der, ApplicationArea_decode_xer, ApplicationArea_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ApplicationArea_tags_1, sizeof(asn_DEF_ApplicationArea_tags_1) /sizeof(asn_DEF_ApplicationArea_tags_1[0]), /* 1 */ asn_DEF_ApplicationArea_tags_1, /* Same as above */ sizeof(asn_DEF_ApplicationArea_tags_1) /sizeof(asn_DEF_ApplicationArea_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/NativeEnumerated.c0000664000175000017500000001342614105434233021112 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2007 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Read the NativeInteger.h for the explanation wrt. differences between * INTEGER and NativeInteger. * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this * implementation deals with the standard (machine-specific) representation * of them instead of using the platform-independent buffer. */ #include #include /* * NativeEnumerated basic type description. */ static ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = { "ENUMERATED", /* The ASN.1 type is still ENUMERATED */ "ENUMERATED", NativeInteger_free, NativeInteger_print, asn_generic_no_constraint, NativeInteger_decode_ber, NativeInteger_encode_der, NativeInteger_decode_xer, NativeEnumerated_encode_xer, NativeEnumerated_decode_uper, NativeEnumerated_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_NativeEnumerated_tags, sizeof(asn_DEF_NativeEnumerated_tags) / sizeof(asn_DEF_NativeEnumerated_tags[0]), asn_DEF_NativeEnumerated_tags, /* Same as above */ sizeof(asn_DEF_NativeEnumerated_tags) / sizeof(asn_DEF_NativeEnumerated_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_enc_rval_t er; const long *native = (const long *)sptr; const asn_INTEGER_enum_map_t *el; (void)ilevel; (void)flags; if(!native) _ASN_ENCODE_FAILED; el = INTEGER_map_value2enum(specs, *native); if(el) { size_t srcsize = el->enum_len + 5; char *src = (char *)alloca(srcsize); er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name); assert(er.encoded > 0 && (size_t)er.encoded < srcsize); if(cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } else { ASN_DEBUG("ASN.1 forbids dealing with " "unknown value of ENUMERATED type"); _ASN_ENCODE_FAILED; } } asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics; asn_dec_rval_t rval = { RC_OK, 0 }; long *native = (long *)*sptr; asn_per_constraint_t *ct; long value; (void)opt_codec_ctx; if(constraints) ct = &constraints->value; else if(td->per_constraints) ct = &td->per_constraints->value; else _ASN_DECODE_FAILED; /* Mandatory! */ if(!specs) _ASN_DECODE_FAILED; if(!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); if(!native) _ASN_DECODE_FAILED; } ASN_DEBUG("Decoding %s as NativeEnumerated", td->name); if(ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); if(inext < 0) _ASN_DECODE_STARVED; if(inext) ct = 0; } if(ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); if(value < 0) _ASN_DECODE_STARVED; if(value >= (specs->extension ? specs->extension - 1 : specs->map_count)) _ASN_DECODE_FAILED; } else { if(!specs->extension) _ASN_DECODE_FAILED; /* * X.691, #10.6: normally small non-negative whole number; */ value = uper_get_nsnnwn(pd); if(value < 0) _ASN_DECODE_STARVED; value += specs->extension - 1; if(value >= specs->map_count) _ASN_DECODE_FAILED; } *native = specs->value2enum[value].nat_value; ASN_DEBUG("Decoded %s = %ld", td->name, *native); return rval; } static int NativeEnumerated__compar_value2enum(const void *ap, const void *bp) { const asn_INTEGER_enum_map_t *a = ap; const asn_INTEGER_enum_map_t *b = bp; if(a->nat_value == b->nat_value) return 0; if(a->nat_value < b->nat_value) return -1; return 1; } asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics; asn_enc_rval_t er; long native, value; asn_per_constraint_t *ct; int inext = 0; asn_INTEGER_enum_map_t key; asn_INTEGER_enum_map_t *kf; if(!sptr) _ASN_ENCODE_FAILED; if(!specs) _ASN_ENCODE_FAILED; if(constraints) ct = &constraints->value; else if(td->per_constraints) ct = &td->per_constraints->value; else _ASN_ENCODE_FAILED; /* Mandatory! */ ASN_DEBUG("Encoding %s as NativeEnumerated", td->name); er.encoded = 0; native = *(long *)sptr; if(native < 0) _ASN_ENCODE_FAILED; key.nat_value = native; kf = bsearch(&key, specs->value2enum, specs->map_count, sizeof(key), NativeEnumerated__compar_value2enum); if(!kf) { ASN_DEBUG("No element corresponds to %ld", native); _ASN_ENCODE_FAILED; } value = kf - specs->value2enum; if(ct->range_bits >= 0) { int cmpWith = specs->extension ? specs->extension - 1 : specs->map_count; if(value >= cmpWith) inext = 1; } if(ct->flags & APC_EXTENSIBLE) { if(per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; if(inext) ct = 0; } else if(inext) { _ASN_ENCODE_FAILED; } if(ct && ct->range_bits >= 0) { if(per_put_few_bits(po, value, ct->range_bits)) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } if(!specs->extension) _ASN_ENCODE_FAILED; /* * X.691, #10.6: normally small non-negative whole number; */ ASN_DEBUG("value = %ld, ext = %d, inext = %d, res = %ld", value, specs->extension, inext, value - (inext ? (specs->extension - 1) : 0)); if(uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0))) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } biosig-2.3.3/biosig4c++/t240/Comments.h0000664000175000017500000000127014105434233017436 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Comments_H_ #define _Comments_H_ #include /* Including external dependencies */ #include "FEFString.h" #include "HandleRef.h" #include #ifdef __cplusplus extern "C" { #endif /* Comments */ typedef struct Comments { FEFString_t commenttext; HandleRef_t commentator; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } Comments_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Comments; #ifdef __cplusplus } #endif #endif /* _Comments_H_ */ biosig-2.3.3/biosig4c++/t240/ber_tlv_length.h0000664000175000017500000000277514105434233020662 0ustar schloeglschloegl/*- * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _BER_TLV_LENGTH_H_ #define _BER_TLV_LENGTH_H_ #ifdef __cplusplus extern "C" { #endif typedef ssize_t ber_tlv_len_t; /* * This function tries to fetch the length of the BER TLV value and place it * in *len_r. * RETURN VALUES: * 0: More data expected than bufptr contains. * -1: Fatal error deciphering length. * >0: Number of bytes used from bufptr. * On return with >0, len_r is constrained as -1..MAX, where -1 mean * that the value is of indefinite length. */ ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size, ber_tlv_len_t *len_r); /* * This function expects bufptr to be positioned over L in TLV. * It returns number of bytes occupied by L and V together, suitable * for skipping. The function properly handles indefinite length. * RETURN VALUES: * Standard {-1,0,>0} convention. */ ssize_t ber_skip_length( struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */ int _is_constructed, const void *bufptr, size_t size); /* * This function serializes the length (L from TLV) in DER format. * It always returns number of bytes necessary to represent the length, * it is a caller's responsibility to check the return value * against the supplied buffer's size. */ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size); #ifdef __cplusplus } #endif #endif /* _BER_TLV_LENGTH_H_ */ biosig-2.3.3/biosig4c++/t240/NumericMeasuredDataSection.h0000664000175000017500000000160614105434233023063 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _NumericMeasuredDataSection_H_ #define _NumericMeasuredDataSection_H_ #include /* Including external dependencies */ #include "HandleRef.h" #include "ChoiceOfNuObsValue.h" #include "ObservationTime.h" #include #ifdef __cplusplus extern "C" { #endif /* NumericMeasuredDataSection */ typedef struct NumericMeasuredDataSection { HandleRef_t metricref; ChoiceOfNuObsValue_t nuobservedvalue; ObservationTime_t timestamp; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } NumericMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_NumericMeasuredDataSection; #ifdef __cplusplus } #endif #endif /* _NumericMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/xer_encoder.h0000664000175000017500000000324114105434233020146 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _XER_ENCODER_H_ #define _XER_ENCODER_H_ #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */ enum xer_encoder_flags_e { /* Mode of encoding */ XER_F_BASIC = 0x01, /* BASIC-XER (pretty-printing) */ XER_F_CANONICAL = 0x02 /* Canonical XER (strict rules) */ }; /* * The XER encoder of any type. May be invoked by the application. */ asn_enc_rval_t xer_encode(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ enum xer_encoder_flags_e xer_flags, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key /* Arbitrary callback argument */ ); /* * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC) * output into the chosen file pointer. * RETURN VALUES: * 0: The structure is printed. * -1: Problem printing the structure. * WARNING: No sensible errno value is returned. */ int xer_fprint(FILE *stream, struct asn_TYPE_descriptor_s *td, void *sptr); /* * Type of the generic XER encoder. */ typedef asn_enc_rval_t (xer_type_encoder_f)( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ int ilevel, /* Level of indentation */ enum xer_encoder_flags_e xer_flags, asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */ void *app_key /* Arbitrary callback argument */ ); #ifdef __cplusplus } #endif #endif /* _XER_ENCODER_H_ */ biosig-2.3.3/biosig4c++/t240/SampleArrayMeasuredDataSection.c0000664000175000017500000001136514105434233023677 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SampleArrayMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_metriclist_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriclist_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriclist_specs_5 = { sizeof(struct SampleArrayMeasuredDataSection__metriclist), offsetof(struct SampleArrayMeasuredDataSection__metriclist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriclist_5 = { "metriclist", "metriclist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriclist_tags_5, sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]) - 1, /* 1 */ asn_DEF_metriclist_tags_5, /* Same as above */ sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriclist_5, 1, /* Single element */ &asn_SPC_metriclist_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SampleArrayMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SampleArrayMeasuredDataSection, numberofsubblocks), (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numberofsubblocks" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayMeasuredDataSection, subblocklength), (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocklength" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayMeasuredDataSection, subblocksize), (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocksize" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayMeasuredDataSection, metriclist), (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriclist_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriclist" }, }; static ber_tlv_tag_t asn_DEF_SampleArrayMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SampleArrayMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), 0, 0, 0 }, /* numberofsubblocks at 1220 */ { (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), 1, 0, 0 }, /* subblocklength at 1222 */ { (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), 2, 0, 0 }, /* subblocksize at 1225 */ { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), 3, 0, 0 } /* metriclist at 1230 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SampleArrayMeasuredDataSection_specs_1 = { sizeof(struct SampleArrayMeasuredDataSection), offsetof(struct SampleArrayMeasuredDataSection, _asn_ctx), asn_MAP_SampleArrayMeasuredDataSection_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SampleArrayMeasuredDataSection = { "SampleArrayMeasuredDataSection", "SampleArrayMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SampleArrayMeasuredDataSection_tags_1, sizeof(asn_DEF_SampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_SampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_SampleArrayMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_SampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_SampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SampleArrayMeasuredDataSection_1, 4, /* Elements count */ &asn_SPC_SampleArrayMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/Handle.c0000664000175000017500000000676614105434233017056 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Handle.h" int Handle_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void Handle_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void Handle_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Handle_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int Handle_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Handle_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t Handle_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { Handle_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t Handle_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Handle_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t Handle_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { Handle_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t Handle_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Handle_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_Handle_tags_1[] = { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_Handle = { "Handle", "Handle", Handle_free, Handle_print, Handle_constraint, Handle_decode_ber, Handle_encode_der, Handle_decode_xer, Handle_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Handle_tags_1, sizeof(asn_DEF_Handle_tags_1) /sizeof(asn_DEF_Handle_tags_1[0]) - 1, /* 1 */ asn_DEF_Handle_tags_1, /* Same as above */ sizeof(asn_DEF_Handle_tags_1) /sizeof(asn_DEF_Handle_tags_1[0]), /* 2 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MetricMeasure.c0000664000175000017500000000412214105434233020410 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricMeasure.h" static asn_TYPE_member_t asn_MBR_MetricMeasure_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MetricMeasure, value), (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), 0, &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "value" }, { ATF_NOFLAGS, 0, offsetof(struct MetricMeasure, m_unit), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "m-unit" }, }; static ber_tlv_tag_t asn_DEF_MetricMeasure_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MetricMeasure_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* m-unit at 31 */ { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), 0, 0, 0 } /* value at 29 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MetricMeasure_specs_1 = { sizeof(struct MetricMeasure), offsetof(struct MetricMeasure, _asn_ctx), asn_MAP_MetricMeasure_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MetricMeasure = { "MetricMeasure", "MetricMeasure", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricMeasure_tags_1, sizeof(asn_DEF_MetricMeasure_tags_1) /sizeof(asn_DEF_MetricMeasure_tags_1[0]), /* 1 */ asn_DEF_MetricMeasure_tags_1, /* Same as above */ sizeof(asn_DEF_MetricMeasure_tags_1) /sizeof(asn_DEF_MetricMeasure_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MetricMeasure_1, 2, /* Elements count */ &asn_SPC_MetricMeasure_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ChoiceOfEnumObsValue.c0000664000175000017500000000740414105434233021616 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ChoiceOfEnumObsValue.h" static asn_TYPE_member_t asn_MBR_compoundenumobservedvalue_3[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_EnumObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_compoundenumobservedvalue_tags_3[] = { (ASN_TAG_CLASS_APPLICATION | (2463 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_compoundenumobservedvalue_specs_3 = { sizeof(struct ChoiceOfEnumObsValue__compoundenumobservedvalue), offsetof(struct ChoiceOfEnumObsValue__compoundenumobservedvalue, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_compoundenumobservedvalue_3 = { "compoundenumobservedvalue", "compoundenumobservedvalue", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_compoundenumobservedvalue_tags_3, sizeof(asn_DEF_compoundenumobservedvalue_tags_3) /sizeof(asn_DEF_compoundenumobservedvalue_tags_3[0]) - 1, /* 1 */ asn_DEF_compoundenumobservedvalue_tags_3, /* Same as above */ sizeof(asn_DEF_compoundenumobservedvalue_tags_3) /sizeof(asn_DEF_compoundenumobservedvalue_tags_3[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_compoundenumobservedvalue_3, 1, /* Single element */ &asn_SPC_compoundenumobservedvalue_specs_3 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ChoiceOfEnumObsValue_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumObsValue, choice.enumobservedvalue), (ASN_TAG_CLASS_APPLICATION | (2462 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_EnumObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumobservedvalue" }, { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfEnumObsValue, choice.compoundenumobservedvalue), (ASN_TAG_CLASS_APPLICATION | (2463 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_compoundenumobservedvalue_3, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compoundenumobservedvalue" }, }; static asn_TYPE_tag2member_t asn_MAP_ChoiceOfEnumObsValue_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2462 << 2)), 0, 0, 0 }, /* enumobservedvalue at 1330 */ { (ASN_TAG_CLASS_APPLICATION | (2463 << 2)), 1, 0, 0 } /* compoundenumobservedvalue at 1333 */ }; static asn_CHOICE_specifics_t asn_SPC_ChoiceOfEnumObsValue_specs_1 = { sizeof(struct ChoiceOfEnumObsValue), offsetof(struct ChoiceOfEnumObsValue, _asn_ctx), offsetof(struct ChoiceOfEnumObsValue, present), sizeof(((struct ChoiceOfEnumObsValue *)0)->present), asn_MAP_ChoiceOfEnumObsValue_tag2el_1, 2, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ChoiceOfEnumObsValue = { "ChoiceOfEnumObsValue", "ChoiceOfEnumObsValue", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_ChoiceOfEnumObsValue_1, 2, /* Elements count */ &asn_SPC_ChoiceOfEnumObsValue_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PatientRace.c0000664000175000017500000000715514105434233020053 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PatientRace.h" int PatientRace_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void PatientRace_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void PatientRace_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { PatientRace_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int PatientRace_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { PatientRace_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t PatientRace_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { PatientRace_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t PatientRace_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { PatientRace_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t PatientRace_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { PatientRace_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t PatientRace_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { PatientRace_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_PatientRace_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_PatientRace = { "PatientRace", "PatientRace", PatientRace_free, PatientRace_print, PatientRace_constraint, PatientRace_decode_ber, PatientRace_encode_der, PatientRace_decode_xer, PatientRace_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PatientRace_tags_1, sizeof(asn_DEF_PatientRace_tags_1) /sizeof(asn_DEF_PatientRace_tags_1[0]), /* 1 */ asn_DEF_PatientRace_tags_1, /* Same as above */ sizeof(asn_DEF_PatientRace_tags_1) /sizeof(asn_DEF_PatientRace_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MetricCalType.h0000664000175000017500000000177614105434233020371 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricCalType_H_ #define _MetricCalType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MetricCalType { MetricCalType_cal_unspec = 0, MetricCalType_cal_offset = 1, MetricCalType_cal_gain = 2, MetricCalType_cal_two_point = 3 } e_MetricCalType; /* MetricCalType */ typedef INTEGER_t MetricCalType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricCalType; asn_struct_free_f MetricCalType_free; asn_struct_print_f MetricCalType_print; asn_constr_check_f MetricCalType_constraint; ber_type_decoder_f MetricCalType_decode_ber; der_type_encoder_f MetricCalType_encode_der; xer_type_decoder_f MetricCalType_decode_xer; xer_type_encoder_f MetricCalType_encode_xer; #ifdef __cplusplus } #endif #endif /* _MetricCalType_H_ */ biosig-2.3.3/biosig4c++/t240/HandleRef.c0000664000175000017500000000704614105434233017503 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "HandleRef.h" int HandleRef_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void HandleRef_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void HandleRef_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { HandleRef_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int HandleRef_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { HandleRef_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t HandleRef_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { HandleRef_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t HandleRef_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { HandleRef_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t HandleRef_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { HandleRef_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t HandleRef_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { HandleRef_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_HandleRef_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_HandleRef = { "HandleRef", "HandleRef", HandleRef_free, HandleRef_print, HandleRef_constraint, HandleRef_decode_ber, HandleRef_encode_der, HandleRef_decode_xer, HandleRef_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_HandleRef_tags_1, sizeof(asn_DEF_HandleRef_tags_1) /sizeof(asn_DEF_HandleRef_tags_1[0]), /* 1 */ asn_DEF_HandleRef_tags_1, /* Same as above */ sizeof(asn_DEF_HandleRef_tags_1) /sizeof(asn_DEF_HandleRef_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/asn_codecs_prim.c0000664000175000017500000001523114105434233020776 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Decode an always-primitive type. */ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buf_ptr, size_t size, int tag_mode) { ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr; asn_dec_rval_t rval; ber_tlv_len_t length; /* * If the structure is not there, allocate it. */ if(st == NULL) { st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st)); if(st == NULL) _ASN_DECODE_FAILED; *sptr = (void *)st; } ASN_DEBUG("Decoding %s as plain primitive (tm=%d)", td->name, tag_mode); /* * Check tags and extract value length. */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); if(rval.code != RC_OK) return rval; ASN_DEBUG("%s length is %d bytes", td->name, (int)length); /* * Make sure we have this length. */ buf_ptr = ((const char *)buf_ptr) + rval.consumed; size -= rval.consumed; if(length > (ber_tlv_len_t)size) { rval.code = RC_WMORE; rval.consumed = 0; return rval; } st->size = (int)length; /* The following better be optimized away. */ if(sizeof(st->size) != sizeof(length) && (ber_tlv_len_t)st->size != length) { st->size = 0; _ASN_DECODE_FAILED; } st->buf = (uint8_t *)MALLOC(length + 1); if(!st->buf) { st->size = 0; _ASN_DECODE_FAILED; } memcpy(st->buf, buf_ptr, length); st->buf[length] = '\0'; /* Just in case */ rval.code = RC_OK; rval.consumed += length; ASN_DEBUG("Took %ld/%ld bytes to encode %s", (long)rval.consumed, (long)length, td->name); return rval; } /* * Encode an always-primitive type using DER. */ asn_enc_rval_t der_encode_primitive(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t erval; ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr; ASN_DEBUG("%s %s as a primitive type (tm=%d)", cb?"Encoding":"Estimating", td->name, tag_mode); erval.encoded = der_write_tags(td, st->size, tag_mode, 0, tag, cb, app_key); ASN_DEBUG("%s wrote tags %d", td->name, (int)erval.encoded); if(erval.encoded == -1) { erval.failed_type = td; erval.structure_ptr = sptr; return erval; } if(cb && st->buf) { if(cb(st->buf, st->size, app_key) < 0) { erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = sptr; return erval; } } else { assert(st->buf || st->size == 0); } erval.encoded += st->size; _ASN_ENCODED_OK(erval); } void ASN__PRIMITIVE_TYPE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr; if(!td || !sptr) return; ASN_DEBUG("Freeing %s as a primitive type", td->name); if(st->buf) FREEMEM(st->buf); if(!contents_only) FREEMEM(st); } /* * Local internal type passed around as an argument. */ struct xdp_arg_s { asn_TYPE_descriptor_t *type_descriptor; void *struct_key; xer_primitive_body_decoder_f *prim_body_decoder; int decoded_something; int want_more; }; static int xer_decode__unexpected_tag(void *key, const void *chunk_buf, size_t chunk_size) { struct xdp_arg_s *arg = (struct xdp_arg_s *)key; enum xer_pbd_rval bret; if(arg->decoded_something) { if(xer_is_whitespace(chunk_buf, chunk_size)) return 0; /* Skip it. */ /* * Decoding was done once already. Prohibit doing it again. */ return -1; } bret = arg->prim_body_decoder(arg->type_descriptor, arg->struct_key, chunk_buf, chunk_size); switch(bret) { case XPBD_SYSTEM_FAILURE: case XPBD_DECODER_LIMIT: case XPBD_BROKEN_ENCODING: break; case XPBD_BODY_CONSUMED: /* Tag decoded successfully */ arg->decoded_something = 1; /* Fall through */ case XPBD_NOT_BODY_IGNORE: /* Safe to proceed further */ return 0; } return -1; } static ssize_t xer_decode__body(void *key, const void *chunk_buf, size_t chunk_size, int have_more) { struct xdp_arg_s *arg = (struct xdp_arg_s *)key; enum xer_pbd_rval bret; if(arg->decoded_something) { if(xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size; /* * Decoding was done once already. Prohibit doing it again. */ return -1; } if(!have_more) { /* * If we've received something like "1", we can't really * tell whether it is really `1` or `123`, until we know * that there is no more data coming. * The have_more argument will be set to 1 once something * like this is available to the caller of this callback: * "1want_more = 1; return -1; } bret = arg->prim_body_decoder(arg->type_descriptor, arg->struct_key, chunk_buf, chunk_size); switch(bret) { case XPBD_SYSTEM_FAILURE: case XPBD_DECODER_LIMIT: case XPBD_BROKEN_ENCODING: break; case XPBD_BODY_CONSUMED: /* Tag decoded successfully */ arg->decoded_something = 1; /* Fall through */ case XPBD_NOT_BODY_IGNORE: /* Safe to proceed further */ return chunk_size; } return -1; } asn_dec_rval_t xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size, xer_primitive_body_decoder_f *prim_body_decoder ) { const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; asn_struct_ctx_t s_ctx; struct xdp_arg_s s_arg; asn_dec_rval_t rc; /* * Create the structure if does not exist. */ if(!*sptr) { *sptr = CALLOC(1, struct_size); if(!*sptr) _ASN_DECODE_FAILED; } memset(&s_ctx, 0, sizeof(s_ctx)); s_arg.type_descriptor = td; s_arg.struct_key = *sptr; s_arg.prim_body_decoder = prim_body_decoder; s_arg.decoded_something = 0; s_arg.want_more = 0; rc = xer_decode_general(opt_codec_ctx, &s_ctx, &s_arg, xml_tag, buf_ptr, size, xer_decode__unexpected_tag, xer_decode__body); switch(rc.code) { case RC_OK: if(!s_arg.decoded_something) { char ch; ASN_DEBUG("Primitive body is not recognized, " "supplying empty one"); /* * Decoding opportunity has come and gone. * Where's the result? * Try to feed with empty body, see if it eats it. */ if(prim_body_decoder(s_arg.type_descriptor, s_arg.struct_key, &ch, 0) != XPBD_BODY_CONSUMED) { /* * This decoder does not like empty stuff. */ _ASN_DECODE_FAILED; } } break; case RC_WMORE: /* * Redo the whole thing later. * We don't have a context to save intermediate parsing state. */ rc.consumed = 0; break; case RC_FAIL: rc.consumed = 0; if(s_arg.want_more) rc.code = RC_WMORE; else _ASN_DECODE_FAILED; break; } return rc; } biosig-2.3.3/biosig4c++/t240/PatMeasure.c0000664000175000017500000000412714105434233017716 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PatMeasure.h" static asn_TYPE_member_t asn_MBR_PatMeasure_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PatMeasure, value), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "value" }, { ATF_NOFLAGS, 0, offsetof(struct PatMeasure, m_unit), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "m-unit" }, }; static ber_tlv_tag_t asn_DEF_PatMeasure_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_PatMeasure_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* value at 421 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* m-unit at 424 */ }; static asn_SEQUENCE_specifics_t asn_SPC_PatMeasure_specs_1 = { sizeof(struct PatMeasure), offsetof(struct PatMeasure, _asn_ctx), asn_MAP_PatMeasure_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_PatMeasure = { "PatMeasure", "PatMeasure", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PatMeasure_tags_1, sizeof(asn_DEF_PatMeasure_tags_1) /sizeof(asn_DEF_PatMeasure_tags_1[0]), /* 1 */ asn_DEF_PatMeasure_tags_1, /* Same as above */ sizeof(asn_DEF_PatMeasure_tags_1) /sizeof(asn_DEF_PatMeasure_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_PatMeasure_1, 2, /* Elements count */ &asn_SPC_PatMeasure_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/AlertType.h0000664000175000017500000000177614105434233017575 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertType_H_ #define _AlertType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum AlertType { AlertType_noalert = 0, AlertType_lowprital = 1, AlertType_medprital = 2, AlertType_hiprital = 4, AlertType_lowpripal = 256, AlertType_medpripal = 512, AlertType_hipripal = 1024 } e_AlertType; /* AlertType */ typedef INTEGER_t AlertType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertType; asn_struct_free_f AlertType_free; asn_struct_print_f AlertType_print; asn_constr_check_f AlertType_constraint; ber_type_decoder_f AlertType_decode_ber; der_type_encoder_f AlertType_encode_der; xer_type_decoder_f AlertType_decode_xer; xer_type_encoder_f AlertType_encode_xer; #ifdef __cplusplus } #endif #endif /* _AlertType_H_ */ biosig-2.3.3/biosig4c++/t240/EnumerationMeasuredDataSection.c0000664000175000017500000000641314105434233023743 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumerationMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_EnumerationMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumerationMeasuredDataSection, metricref), (ASN_TAG_CLASS_APPLICATION | (6050 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricref" }, { ATF_NOFLAGS, 0, offsetof(struct EnumerationMeasuredDataSection, enumobservedvalue), -1 /* Ambiguous tag (CHOICE?) */, 0, &asn_DEF_ChoiceOfEnumObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumobservedvalue" }, { ATF_NOFLAGS, 0, offsetof(struct EnumerationMeasuredDataSection, enumtimestamp), -1 /* Ambiguous tag (CHOICE?) */, 0, &asn_DEF_ChoiceOfEnumTimeStamp, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumtimestamp" }, }; static ber_tlv_tag_t asn_DEF_EnumerationMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumerationMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, 0, 0 }, /* timestamp at 1367 */ { (ASN_TAG_CLASS_APPLICATION | (2462 << 2)), 1, 0, 0 }, /* enumobservedvalue at 1330 */ { (ASN_TAG_CLASS_APPLICATION | (2463 << 2)), 1, 0, 0 }, /* compoundenumobservedvalue at 1333 */ { (ASN_TAG_CLASS_APPLICATION | (6042 << 2)), 2, 0, 0 }, /* absolutetimestamparray at 1368 */ { (ASN_TAG_CLASS_APPLICATION | (6043 << 2)), 2, 0, 0 }, /* relativetimestamparray at 1369 */ { (ASN_TAG_CLASS_APPLICATION | (6044 << 2)), 2, 0, 0 }, /* hirestimestamparray at 1371 */ { (ASN_TAG_CLASS_APPLICATION | (6050 << 2)), 0, 0, 0 } /* metricref at 1313 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumerationMeasuredDataSection_specs_1 = { sizeof(struct EnumerationMeasuredDataSection), offsetof(struct EnumerationMeasuredDataSection, _asn_ctx), asn_MAP_EnumerationMeasuredDataSection_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumerationMeasuredDataSection = { "EnumerationMeasuredDataSection", "EnumerationMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumerationMeasuredDataSection_tags_1, sizeof(asn_DEF_EnumerationMeasuredDataSection_tags_1) /sizeof(asn_DEF_EnumerationMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_EnumerationMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_EnumerationMeasuredDataSection_tags_1) /sizeof(asn_DEF_EnumerationMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumerationMeasuredDataSection_1, 3, /* Elements count */ &asn_SPC_EnumerationMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SaSignalFrequency.h0000664000175000017500000000133614105434233021237 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaSignalFrequency_H_ #define _SaSignalFrequency_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include #ifdef __cplusplus extern "C" { #endif /* SaSignalFrequency */ typedef struct SaSignalFrequency { FEFFloat_t lowedgefreq; FEFFloat_t highedgefreq; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SaSignalFrequency_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaSignalFrequency; #ifdef __cplusplus } #endif #endif /* _SaSignalFrequency_H_ */ biosig-2.3.3/biosig4c++/t240/EnumVal.c0000664000175000017500000000657514105434233017230 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumVal.h" static asn_TYPE_member_t asn_MBR_EnumVal_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_obj_id), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_EnumObject, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-obj-id" }, { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_text_string), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-text-string" }, { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_external_code), (ASN_TAG_CLASS_CONTEXT | (8 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-external-code" }, { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_bit_str), (ASN_TAG_CLASS_CONTEXT | (16 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_BIT_STRING, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-bit-str" }, { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_record), (ASN_TAG_CLASS_CONTEXT | (33 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_EnumRecordMetric, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-record" }, { ATF_NOFLAGS, 0, offsetof(struct EnumVal, choice.enum_record_oo), (ASN_TAG_CLASS_CONTEXT | (34 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_EnumRecordOO, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-record-oo" }, }; static asn_TYPE_tag2member_t asn_MAP_EnumVal_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* enum-obj-id at 1340 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* enum-text-string at 1341 */ { (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 2, 0, 0 }, /* enum-external-code at 1342 */ { (ASN_TAG_CLASS_CONTEXT | (16 << 2)), 3, 0, 0 }, /* enum-bit-str at 1343 */ { (ASN_TAG_CLASS_CONTEXT | (33 << 2)), 4, 0, 0 }, /* enum-record at 1344 */ { (ASN_TAG_CLASS_CONTEXT | (34 << 2)), 5, 0, 0 } /* enum-record-oo at 1346 */ }; static asn_CHOICE_specifics_t asn_SPC_EnumVal_specs_1 = { sizeof(struct EnumVal), offsetof(struct EnumVal, _asn_ctx), offsetof(struct EnumVal, present), sizeof(((struct EnumVal *)0)->present), asn_MAP_EnumVal_tag2el_1, 6, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_EnumVal = { "EnumVal", "EnumVal", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_EnumVal_1, 6, /* Elements count */ &asn_SPC_EnumVal_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ChannelStatus.c0000664000175000017500000000732714105434233020431 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ChannelStatus.h" int ChannelStatus_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void ChannelStatus_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void ChannelStatus_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { ChannelStatus_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int ChannelStatus_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { ChannelStatus_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t ChannelStatus_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { ChannelStatus_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t ChannelStatus_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { ChannelStatus_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t ChannelStatus_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { ChannelStatus_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t ChannelStatus_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { ChannelStatus_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_ChannelStatus_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_ChannelStatus = { "ChannelStatus", "ChannelStatus", ChannelStatus_free, ChannelStatus_print, ChannelStatus_constraint, ChannelStatus_decode_ber, ChannelStatus_encode_der, ChannelStatus_decode_xer, ChannelStatus_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ChannelStatus_tags_1, sizeof(asn_DEF_ChannelStatus_tags_1) /sizeof(asn_DEF_ChannelStatus_tags_1[0]), /* 1 */ asn_DEF_ChannelStatus_tags_1, /* Same as above */ sizeof(asn_DEF_ChannelStatus_tags_1) /sizeof(asn_DEF_ChannelStatus_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/Address.h0000664000175000017500000000136414105434233017242 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Address_H_ #define _Address_H_ #include /* Including external dependencies */ #include "FEFString.h" #ifdef __cplusplus extern "C" { #endif /* Address */ typedef FEFString_t Address_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Address; asn_struct_free_f Address_free; asn_struct_print_f Address_print; asn_constr_check_f Address_constraint; ber_type_decoder_f Address_decode_ber; der_type_encoder_f Address_encode_der; xer_type_decoder_f Address_decode_xer; xer_type_encoder_f Address_encode_xer; #ifdef __cplusplus } #endif #endif /* _Address_H_ */ biosig-2.3.3/biosig4c++/t240/der_encoder.h0000664000175000017500000000363114105434233020125 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _DER_ENCODER_H_ #define _DER_ENCODER_H_ #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * The DER encoder of any type. May be invoked by the application. * The ber_decode() function (ber_decoder.h) is an opposite of der_encode(). */ asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ asn_app_consume_bytes_f *consume_bytes_cb, void *app_key /* Arbitrary callback argument */ ); /* A variant of der_encode() which encodes data into the pre-allocated buffer */ asn_enc_rval_t der_encode_to_buffer( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ void *buffer, /* Pre-allocated buffer */ size_t buffer_size /* Initial buffer size (maximum) */ ); /* * Type of the generic DER encoder. */ typedef asn_enc_rval_t (der_type_encoder_f)( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */ void *app_key /* Arbitrary callback argument */ ); /******************************* * INTERNALLY USEFUL FUNCTIONS * *******************************/ /* * Write out leading TL[v] sequence according to the type definition. */ ssize_t der_write_tags( struct asn_TYPE_descriptor_s *type_descriptor, size_t struct_length, int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ int last_tag_form, /* {0,!0}: prim, constructed */ ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, void *app_key ); #ifdef __cplusplus } #endif #endif /* _DER_ENCODER_H_ */ biosig-2.3.3/biosig4c++/t240/MetricStatus.c0000664000175000017500000000726714105434233020307 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricStatus.h" int MetricStatus_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void MetricStatus_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void MetricStatus_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MetricStatus_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MetricStatus_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MetricStatus_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MetricStatus_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MetricStatus_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MetricStatus_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MetricStatus_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MetricStatus_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MetricStatus_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MetricStatus_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MetricStatus_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MetricStatus_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MetricStatus = { "MetricStatus", "MetricStatus", MetricStatus_free, MetricStatus_print, MetricStatus_constraint, MetricStatus_decode_ber, MetricStatus_encode_der, MetricStatus_decode_xer, MetricStatus_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricStatus_tags_1, sizeof(asn_DEF_MetricStatus_tags_1) /sizeof(asn_DEF_MetricStatus_tags_1[0]), /* 1 */ asn_DEF_MetricStatus_tags_1, /* Same as above */ sizeof(asn_DEF_MetricStatus_tags_1) /sizeof(asn_DEF_MetricStatus_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/HighResRelativeTime.c0000664000175000017500000000754614105434233021524 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "HighResRelativeTime.h" int HighResRelativeTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void HighResRelativeTime_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void HighResRelativeTime_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int HighResRelativeTime_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t HighResRelativeTime_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t HighResRelativeTime_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t HighResRelativeTime_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t HighResRelativeTime_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { HighResRelativeTime_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_HighResRelativeTime_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_HighResRelativeTime = { "HighResRelativeTime", "HighResRelativeTime", HighResRelativeTime_free, HighResRelativeTime_print, HighResRelativeTime_constraint, HighResRelativeTime_decode_ber, HighResRelativeTime_encode_der, HighResRelativeTime_decode_xer, HighResRelativeTime_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_HighResRelativeTime_tags_1, sizeof(asn_DEF_HighResRelativeTime_tags_1) /sizeof(asn_DEF_HighResRelativeTime_tags_1[0]), /* 1 */ asn_DEF_HighResRelativeTime_tags_1, /* Same as above */ sizeof(asn_DEF_HighResRelativeTime_tags_1) /sizeof(asn_DEF_HighResRelativeTime_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/FilterType.h0000664000175000017500000000166514105434233017750 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _FilterType_H_ #define _FilterType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum FilterType { FilterType_other = 0, FilterType_lowpass = 1, FilterType_highpass = 2, FilterType_notch = 3 } e_FilterType; /* FilterType */ typedef INTEGER_t FilterType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_FilterType; asn_struct_free_f FilterType_free; asn_struct_print_f FilterType_print; asn_constr_check_f FilterType_constraint; ber_type_decoder_f FilterType_decode_ber; der_type_encoder_f FilterType_encode_der; xer_type_decoder_f FilterType_decode_xer; xer_type_encoder_f FilterType_encode_xer; #ifdef __cplusplus } #endif #endif /* _FilterType_H_ */ biosig-2.3.3/biosig4c++/t240/Authorization.h0000664000175000017500000000134014105434233020507 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Authorization_H_ #define _Authorization_H_ #include /* Including external dependencies */ #include "PrivateCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* Authorization */ typedef struct Authorization { PrivateCode_t authorization_type; ANY_t authorization_key; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } Authorization_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Authorization; #ifdef __cplusplus } #endif #endif /* _Authorization_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCategory.h0000664000175000017500000000222314105434233020571 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricCategory_H_ #define _MetricCategory_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MetricCategory { MetricCategory_mcat_unspec = 0, MetricCategory_auto_measurement = 1, MetricCategory_manual_measurement = 2, MetricCategory_auto_setting = 3, MetricCategory_manual_setting = 4, MetricCategory_auto_calculation = 5, MetricCategory_manual_calculation = 6 } e_MetricCategory; /* MetricCategory */ typedef INTEGER_t MetricCategory_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricCategory; asn_struct_free_f MetricCategory_free; asn_struct_print_f MetricCategory_print; asn_constr_check_f MetricCategory_constraint; ber_type_decoder_f MetricCategory_decode_ber; der_type_encoder_f MetricCategory_encode_der; xer_type_decoder_f MetricCategory_decode_xer; xer_type_encoder_f MetricCategory_encode_xer; #ifdef __cplusplus } #endif #endif /* _MetricCategory_H_ */ biosig-2.3.3/biosig4c++/t240/ANY.c0000664000175000017500000000613014105434233016273 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include static asn_OCTET_STRING_specifics_t asn_DEF_ANY_specs = { sizeof(ANY_t), offsetof(ANY_t, _asn_ctx), ASN_OSUBV_ANY }; asn_TYPE_descriptor_t asn_DEF_ANY = { "ANY", "ANY", OCTET_STRING_free, OCTET_STRING_print, asn_generic_no_constraint, OCTET_STRING_decode_ber, OCTET_STRING_encode_der, OCTET_STRING_decode_xer_hex, ANY_encode_xer, 0, 0, 0, /* Use generic outmost tag fetcher */ 0, 0, 0, 0, 0, /* No PER visible constraints */ 0, 0, /* No members */ &asn_DEF_ANY_specs, }; asn_enc_rval_t ANY_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { if(flags & XER_F_CANONICAL) { /* * Canonical XER-encoding of ANY type is not supported. */ _ASN_ENCODE_FAILED; } /* Dump as binary */ return OCTET_STRING_encode_xer(td, sptr, ilevel, flags, cb, app_key); } struct _callback_arg { uint8_t *buffer; size_t offset; size_t size; }; static int ANY__consume_bytes(const void *buffer, size_t size, void *key); int ANY_fromType(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr) { struct _callback_arg arg; asn_enc_rval_t erval; if(!st || !td) { errno = EINVAL; return -1; } if(!sptr) { if(st->buf) FREEMEM(st->buf); st->size = 0; return 0; } arg.offset = arg.size = 0; arg.buffer = 0; erval = der_encode(td, sptr, ANY__consume_bytes, &arg); if(erval.encoded == -1) { if(arg.buffer) FREEMEM(arg.buffer); return -1; } assert((size_t)erval.encoded == arg.offset); if(st->buf) FREEMEM(st->buf); st->buf = arg.buffer; st->size = arg.offset; return 0; } ANY_t * ANY_new_fromType(asn_TYPE_descriptor_t *td, void *sptr) { ANY_t tmp; ANY_t *st; if(!td || !sptr) { errno = EINVAL; return 0; } memset(&tmp, 0, sizeof(tmp)); if(ANY_fromType(&tmp, td, sptr)) return 0; st = (ANY_t *)CALLOC(1, sizeof(ANY_t)); if(st) { *st = tmp; return st; } else { FREEMEM(tmp.buf); return 0; } } int ANY_to_type(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) { asn_dec_rval_t rval; void *newst = 0; if(!st || !td || !struct_ptr) { errno = EINVAL; return -1; } if(st->buf == 0) { /* Nothing to convert, make it empty. */ *struct_ptr = (void *)0; return 0; } rval = ber_decode(0, td, (void **)&newst, st->buf, st->size); if(rval.code == RC_OK) { *struct_ptr = newst; return 0; } else { /* Remove possibly partially decoded data. */ ASN_STRUCT_FREE(*td, newst); return -1; } } static int ANY__consume_bytes(const void *buffer, size_t size, void *key) { struct _callback_arg *arg = (struct _callback_arg *)key; if((arg->offset + size) >= arg->size) { size_t nsize = (arg->size ? arg->size << 2 : 16) + size; void *p = REALLOC(arg->buffer, nsize); if(!p) return -1; arg->buffer = (uint8_t *)p; arg->size = nsize; } memcpy(arg->buffer + arg->offset, buffer, size); arg->offset += size; assert(arg->offset < arg->size); return 0; } biosig-2.3.3/biosig4c++/t240/OID-Type.c0000664000175000017500000000700614105434233017201 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "OID-Type.h" int OID_Type_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void OID_Type_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void OID_Type_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { OID_Type_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int OID_Type_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { OID_Type_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t OID_Type_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { OID_Type_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t OID_Type_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { OID_Type_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t OID_Type_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { OID_Type_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t OID_Type_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { OID_Type_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_OID_Type_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_OID_Type = { "OID-Type", "OID-Type", OID_Type_free, OID_Type_print, OID_Type_constraint, OID_Type_decode_ber, OID_Type_encode_der, OID_Type_decode_xer, OID_Type_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_OID_Type_tags_1, sizeof(asn_DEF_OID_Type_tags_1) /sizeof(asn_DEF_OID_Type_tags_1[0]), /* 1 */ asn_DEF_OID_Type_tags_1, /* Same as above */ sizeof(asn_DEF_OID_Type_tags_1) /sizeof(asn_DEF_OID_Type_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/AlertControls.c0000664000175000017500000000732714105434233020450 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertControls.h" int AlertControls_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void AlertControls_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void AlertControls_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { AlertControls_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int AlertControls_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { AlertControls_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t AlertControls_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { AlertControls_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t AlertControls_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { AlertControls_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t AlertControls_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { AlertControls_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t AlertControls_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { AlertControls_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_AlertControls_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_AlertControls = { "AlertControls", "AlertControls", AlertControls_free, AlertControls_print, AlertControls_constraint, AlertControls_decode_ber, AlertControls_encode_der, AlertControls_decode_xer, AlertControls_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertControls_tags_1, sizeof(asn_DEF_AlertControls_tags_1) /sizeof(asn_DEF_AlertControls_tags_1[0]), /* 1 */ asn_DEF_AlertControls_tags_1, /* Same as above */ sizeof(asn_DEF_AlertControls_tags_1) /sizeof(asn_DEF_AlertControls_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/AlertControls.h0000664000175000017500000000200314105434233020437 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertControls_H_ #define _AlertControls_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum AlertControls { AlertControls_acobjoff = 0, AlertControls_acchanoff = 1, AlertControls_acallobjaloff = 3, AlertControls_acalertoff = 4 } e_AlertControls; /* AlertControls */ typedef BIT_STRING_t AlertControls_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertControls; asn_struct_free_f AlertControls_free; asn_struct_print_f AlertControls_print; asn_constr_check_f AlertControls_constraint; ber_type_decoder_f AlertControls_decode_ber; der_type_encoder_f AlertControls_encode_der; xer_type_decoder_f AlertControls_decode_xer; xer_type_encoder_f AlertControls_encode_xer; #ifdef __cplusplus } #endif #endif /* _AlertControls_H_ */ biosig-2.3.3/biosig4c++/t240/MsmtPrinciple.h0000664000175000017500000000226314105434233020442 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MsmtPrinciple_H_ #define _MsmtPrinciple_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MsmtPrinciple { MsmtPrinciple_msp_chemical = 1, MsmtPrinciple_msp_electrical = 2, MsmtPrinciple_msp_impedance = 3, MsmtPrinciple_msp_nuclear = 4, MsmtPrinciple_msp_optical = 5, MsmtPrinciple_msp_thermal = 6, MsmtPrinciple_msp_biological = 7, MsmtPrinciple_msp_mechanical = 8, MsmtPrinciple_msp_manual = 15 } e_MsmtPrinciple; /* MsmtPrinciple */ typedef BIT_STRING_t MsmtPrinciple_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MsmtPrinciple; asn_struct_free_f MsmtPrinciple_free; asn_struct_print_f MsmtPrinciple_print; asn_constr_check_f MsmtPrinciple_constraint; ber_type_decoder_f MsmtPrinciple_decode_ber; der_type_encoder_f MsmtPrinciple_encode_der; xer_type_decoder_f MsmtPrinciple_decode_xer; xer_type_encoder_f MsmtPrinciple_encode_xer; #ifdef __cplusplus } #endif #endif /* _MsmtPrinciple_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCalState.h0000664000175000017500000000176614105434233020527 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricCalState_H_ #define _MetricCalState_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MetricCalState { MetricCalState_not_calibrated = 0, MetricCalState_cal_required = 1, MetricCalState_calibrated = 2 } e_MetricCalState; /* MetricCalState */ typedef INTEGER_t MetricCalState_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricCalState; asn_struct_free_f MetricCalState_free; asn_struct_print_f MetricCalState_print; asn_constr_check_f MetricCalState_constraint; ber_type_decoder_f MetricCalState_decode_ber; der_type_encoder_f MetricCalState_encode_der; xer_type_decoder_f MetricCalState_decode_xer; xer_type_encoder_f MetricCalState_encode_xer; #ifdef __cplusplus } #endif #endif /* _MetricCalState_H_ */ biosig-2.3.3/biosig4c++/t240/HealthCareProviderId.h0000664000175000017500000000163114105434233021642 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _HealthCareProviderId_H_ #define _HealthCareProviderId_H_ #include /* Including external dependencies */ #include "INT-U16.h" #ifdef __cplusplus extern "C" { #endif /* HealthCareProviderId */ typedef INT_U16_t HealthCareProviderId_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_HealthCareProviderId; asn_struct_free_f HealthCareProviderId_free; asn_struct_print_f HealthCareProviderId_print; asn_constr_check_f HealthCareProviderId_constraint; ber_type_decoder_f HealthCareProviderId_decode_ber; der_type_encoder_f HealthCareProviderId_encode_der; xer_type_decoder_f HealthCareProviderId_decode_xer; xer_type_encoder_f HealthCareProviderId_encode_xer; #ifdef __cplusplus } #endif #endif /* _HealthCareProviderId_H_ */ biosig-2.3.3/biosig4c++/t240/per_decoder.h0000664000175000017500000000330014105434233020120 0ustar schloeglschloegl/*- * Copyright (c) 2005, 2007 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _PER_DECODER_H_ #define _PER_DECODER_H_ #include #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * Unaligned PER decoder of a "complete encoding" as per X.691#10.1. * On success, this call always returns (.consumed >= 1), as per X.691#10.1.3. */ asn_dec_rval_t uper_decode_complete(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */ void **struct_ptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size /* Size of data buffer */ ); /* * Unaligned PER decoder of any ASN.1 type. May be invoked by the application. * WARNING: This call returns the number of BITS read from the stream. Beware. */ asn_dec_rval_t uper_decode(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */ void **struct_ptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size, /* Size of data buffer */ int skip_bits, /* Number of unused leading bits, 0..7 */ int unused_bits /* Number of unused tailing bits, 0..7 */ ); /* * Type of the type-specific PER decoder function. */ typedef asn_dec_rval_t (per_type_decoder_f)(asn_codec_ctx_t *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, asn_per_constraints_t *constraints, void **struct_ptr, asn_per_data_t *per_data ); #ifdef __cplusplus } #endif #endif /* _PER_DECODER_H_ */ biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificBinary.h0000664000175000017500000000146214105434233023123 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ManufacturerSpecificBinary_H_ #define _ManufacturerSpecificBinary_H_ #include /* Including external dependencies */ #include "PrivateCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* ManufacturerSpecificBinary */ typedef struct ManufacturerSpecificBinary { PrivateCode_t code; OCTET_STRING_t data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ManufacturerSpecificBinary_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificBinary; #ifdef __cplusplus } #endif #endif /* _ManufacturerSpecificBinary_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I16.h0000664000175000017500000000136114105434233016641 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_I16_H_ #define _INT_I16_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-I16 */ typedef long INT_I16_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_I16; asn_struct_free_f INT_I16_free; asn_struct_print_f INT_I16_print; asn_constr_check_f INT_I16_constraint; ber_type_decoder_f INT_I16_decode_ber; der_type_encoder_f INT_I16_encode_der; xer_type_decoder_f INT_I16_decode_xer; xer_type_encoder_f INT_I16_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_I16_H_ */ biosig-2.3.3/biosig4c++/t240/INT-U8.c0000664000175000017500000000736714105434233016605 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-U8.h" int INT_U8_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= 0 && value <= 255)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void INT_U8_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeInteger.free_struct; td->print_struct = asn_DEF_NativeInteger.print_struct; td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; td->der_encoder = asn_DEF_NativeInteger.der_encoder; td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeInteger.per_constraints; td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; } void INT_U8_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_U8_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_U8_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_U8_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_U8_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_U8_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_U8_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_U8_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_U8_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_U8_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_U8_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_U8_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_U8_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_U8 = { "INT-U8", "INT-U8", INT_U8_free, INT_U8_print, INT_U8_constraint, INT_U8_decode_ber, INT_U8_encode_der, INT_U8_decode_xer, INT_U8_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_U8_tags_1, sizeof(asn_DEF_INT_U8_tags_1) /sizeof(asn_DEF_INT_U8_tags_1[0]), /* 1 */ asn_DEF_INT_U8_tags_1, /* Same as above */ sizeof(asn_DEF_INT_U8_tags_1) /sizeof(asn_DEF_INT_U8_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/constraints.c0000664000175000017500000000425714105434233020223 0ustar schloeglschloegl#include "asn_internal.h" #include "constraints.h" int asn_generic_no_constraint(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) { (void)type_descriptor; /* Unused argument */ (void)struct_ptr; /* Unused argument */ (void)cb; /* Unused argument */ (void)key; /* Unused argument */ /* Nothing to check */ return 0; } int asn_generic_unknown_constraint(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) { (void)type_descriptor; /* Unused argument */ (void)struct_ptr; /* Unused argument */ (void)cb; /* Unused argument */ (void)key; /* Unused argument */ /* Unknown how to check */ return 0; } struct errbufDesc { asn_TYPE_descriptor_t *failed_type; const void *failed_struct_ptr; char *errbuf; size_t errlen; }; static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const char *fmt, ...) { struct errbufDesc *arg = key; va_list ap; ssize_t vlen; ssize_t maxlen; arg->failed_type = td; arg->failed_struct_ptr = sptr; maxlen = arg->errlen; if(maxlen <= 0) return; va_start(ap, fmt); vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap); va_end(ap); if(vlen >= maxlen) { arg->errbuf[maxlen-1] = '\0'; /* Ensuring libc correctness */ arg->errlen = maxlen - 1; /* Not counting termination */ return; } else if(vlen >= 0) { arg->errbuf[vlen] = '\0'; /* Ensuring libc correctness */ arg->errlen = vlen; /* Not counting termination */ } else { /* * The libc on this system is broken. */ vlen = sizeof("") - 1; maxlen--; arg->errlen = vlen < maxlen ? vlen : maxlen; memcpy(arg->errbuf, "", arg->errlen); arg->errbuf[arg->errlen] = 0; } return; } int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, char *errbuf, size_t *errlen) { struct errbufDesc arg; int ret; arg.failed_type = 0; arg.failed_struct_ptr = 0; arg.errbuf = errbuf; arg.errlen = errlen ? *errlen : 0; ret = type_descriptor->check_constraints(type_descriptor, struct_ptr, _asn_i_ctfailcb, &arg); if(ret == -1 && errlen) *errlen = arg.errlen; return ret; } biosig-2.3.3/biosig4c++/t240/AbsoluteTime.h0000664000175000017500000000150114105434233020243 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AbsoluteTime_H_ #define _AbsoluteTime_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* AbsoluteTime */ typedef GeneralizedTime_t AbsoluteTime_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AbsoluteTime; asn_struct_free_f AbsoluteTime_free; asn_struct_print_f AbsoluteTime_print; asn_constr_check_f AbsoluteTime_constraint; ber_type_decoder_f AbsoluteTime_decode_ber; der_type_encoder_f AbsoluteTime_encode_der; xer_type_decoder_f AbsoluteTime_decode_xer; xer_type_encoder_f AbsoluteTime_encode_xer; #ifdef __cplusplus } #endif #endif /* _AbsoluteTime_H_ */ biosig-2.3.3/biosig4c++/t240/constr_SET.h0000664000175000017500000000441314105434233017676 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _CONSTR_SET_H_ #define _CONSTR_SET_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct asn_SET_specifics_s { /* * Target structure description. */ int struct_size; /* Size of the target structure. */ int ctx_offset; /* Offset of the asn_struct_ctx_t member */ int pres_offset; /* Offset of _presence_map member */ /* * Tags to members mapping table (sorted). * Sometimes suitable for DER encoding (untagged CHOICE is present); * if so, tag2el_count will be greater than td->elements_count. */ asn_TYPE_tag2member_t *tag2el; int tag2el_count; /* * Tags to members mapping table, second edition. * Suitable for CANONICAL-XER encoding. */ asn_TYPE_tag2member_t *tag2el_cxer; int tag2el_cxer_count; /* * Extensions-related stuff. */ int extensible; /* Whether SET is extensible */ unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ } asn_SET_specifics_t; /* * A set specialized functions dealing with the SET type. */ asn_struct_free_f SET_free; asn_struct_print_f SET_print; asn_constr_check_f SET_constraint; ber_type_decoder_f SET_decode_ber; der_type_encoder_f SET_encode_der; xer_type_decoder_f SET_decode_xer; xer_type_encoder_f SET_encode_xer; per_type_decoder_f SET_decode_uper; per_type_encoder_f SET_encode_uper; /*********************** * Some handy helpers. * ***********************/ /* * Figure out whether the SET member indicated by PR_x has already been decoded. * It is very simple bitfield test, despite its visual complexity. */ #define ASN_SET_ISPRESENT(set_ptr, PR_x) \ ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map), PR_x) #define ASN_SET_ISPRESENT2(map_ptr, PR_x) \ (((unsigned int *)(map_ptr)) \ [(PR_x) / (8 * sizeof(unsigned int))] \ & (1 << ((8 * sizeof(unsigned int)) - 1 \ - ((PR_x) % (8 * sizeof(unsigned int)))))) #define ASN_SET_MKPRESENT(map_ptr, PR_x) \ (((unsigned int *)(map_ptr)) \ [(PR_x) / (8 * sizeof(unsigned int))] \ |= (1 << ((8 * sizeof(unsigned int)) - 1 \ - ((PR_x) % (8 * sizeof(unsigned int)))))) #ifdef __cplusplus } #endif #endif /* _CONSTR_SET_H_ */ biosig-2.3.3/biosig4c++/t240/ExtNomenRef.c0000664000175000017500000000401714105434233020040 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ExtNomenRef.h" static asn_TYPE_member_t asn_MBR_ExtNomenRef_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ExtNomenRef, nomenclatureid), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_ExtNomenclatureCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nomenclatureid" }, { ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct ExtNomenRef, nomenclaturecode), -1 /* Ambiguous tag (ANY?) */, 0, &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nomenclaturecode" }, }; static ber_tlv_tag_t asn_DEF_ExtNomenRef_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ExtNomenRef_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* nomenclatureid at 178 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ExtNomenRef_specs_1 = { sizeof(struct ExtNomenRef), offsetof(struct ExtNomenRef, _asn_ctx), asn_MAP_ExtNomenRef_tag2el_1, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ExtNomenRef = { "ExtNomenRef", "ExtNomenRef", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ExtNomenRef_tags_1, sizeof(asn_DEF_ExtNomenRef_tags_1) /sizeof(asn_DEF_ExtNomenRef_tags_1[0]), /* 1 */ asn_DEF_ExtNomenRef_tags_1, /* Same as above */ sizeof(asn_DEF_ExtNomenRef_tags_1) /sizeof(asn_DEF_ExtNomenRef_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ExtNomenRef_1, 2, /* Elements count */ &asn_SPC_ExtNomenRef_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/asn_SET_OF.h0000664000175000017500000000323314105434233017532 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_SET_OF_H #define ASN_SET_OF_H #ifdef __cplusplus extern "C" { #endif #define A_SET_OF(type) \ struct { \ type **array; \ int count; /* Meaningful size */ \ int size; /* Allocated size */ \ void (*free)(type *); \ } #define ASN_SET_ADD(headptr, ptr) \ asn_set_add((headptr), (ptr)) /******************************************* * Implementation of the SET OF structure. */ /* * Add another structure into the set by its pointer. * RETURN VALUES: * 0 for success and -1/errno for failure. */ int asn_set_add(void *asn_set_of_x, void *ptr); /* * Delete the element from the set by its number (base 0). * This is a constant-time operation. The order of elements before the * deleted ones is guaranteed, the order of elements after the deleted * one is NOT guaranteed. * If _do_free is given AND the (*free) is initialized, the element * will be freed using the custom (*free) function as well. */ void asn_set_del(void *asn_set_of_x, int number, int _do_free); /* * Empty the contents of the set. Will free the elements, if (*free) is given. * Will NOT free the set itself. */ void asn_set_empty(void *asn_set_of_x); /* * Cope with different conversions requirements to/from void in C and C++. * This is mostly useful for support library. */ typedef A_SET_OF(void) asn_anonymous_set_; #define _A_SET_FROM_VOID(ptr) ((asn_anonymous_set_ *)(ptr)) #define _A_CSET_FROM_VOID(ptr) ((const asn_anonymous_set_ *)(ptr)) #ifdef __cplusplus } #endif #endif /* ASN_SET_OF_H */ biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificSection.c0000664000175000017500000001347414105434233023304 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ManufacturerSpecificSection.h" static asn_TYPE_member_t asn_MBR_encodedentries_3[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ManufacturerSpecificEncoded, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_encodedentries_tags_3[] = { (ASN_TAG_CLASS_APPLICATION | (6006 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_encodedentries_specs_3 = { sizeof(struct ManufacturerSpecificSection__encodedentries), offsetof(struct ManufacturerSpecificSection__encodedentries, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_encodedentries_3 = { "encodedentries", "encodedentries", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_encodedentries_tags_3, sizeof(asn_DEF_encodedentries_tags_3) /sizeof(asn_DEF_encodedentries_tags_3[0]) - 1, /* 1 */ asn_DEF_encodedentries_tags_3, /* Same as above */ sizeof(asn_DEF_encodedentries_tags_3) /sizeof(asn_DEF_encodedentries_tags_3[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_encodedentries_3, 1, /* Single element */ &asn_SPC_encodedentries_specs_3 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_binaryentries_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ManufacturerSpecificBinary, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_binaryentries_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6007 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_binaryentries_specs_5 = { sizeof(struct ManufacturerSpecificSection__binaryentries), offsetof(struct ManufacturerSpecificSection__binaryentries, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_binaryentries_5 = { "binaryentries", "binaryentries", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_binaryentries_tags_5, sizeof(asn_DEF_binaryentries_tags_5) /sizeof(asn_DEF_binaryentries_tags_5[0]) - 1, /* 1 */ asn_DEF_binaryentries_tags_5, /* Same as above */ sizeof(asn_DEF_binaryentries_tags_5) /sizeof(asn_DEF_binaryentries_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_binaryentries_5, 1, /* Single element */ &asn_SPC_binaryentries_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ManufacturerSpecificSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ManufacturerSpecificSection, manufacturerid), (ASN_TAG_CLASS_APPLICATION | (6005 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ManufacturerID, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "manufacturerid" }, { ATF_POINTER, 2, offsetof(struct ManufacturerSpecificSection, encodedentries), (ASN_TAG_CLASS_APPLICATION | (6006 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_encodedentries_3, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "encodedentries" }, { ATF_POINTER, 1, offsetof(struct ManufacturerSpecificSection, binaryentries), (ASN_TAG_CLASS_APPLICATION | (6007 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_binaryentries_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "binaryentries" }, }; static ber_tlv_tag_t asn_DEF_ManufacturerSpecificSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ManufacturerSpecificSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6005 << 2)), 0, 0, 0 }, /* manufacturerid at 258 */ { (ASN_TAG_CLASS_APPLICATION | (6006 << 2)), 1, 0, 0 }, /* encodedentries at 263 */ { (ASN_TAG_CLASS_APPLICATION | (6007 << 2)), 2, 0, 0 } /* binaryentries at 267 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ManufacturerSpecificSection_specs_1 = { sizeof(struct ManufacturerSpecificSection), offsetof(struct ManufacturerSpecificSection, _asn_ctx), asn_MAP_ManufacturerSpecificSection_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificSection = { "ManufacturerSpecificSection", "ManufacturerSpecificSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ManufacturerSpecificSection_tags_1, sizeof(asn_DEF_ManufacturerSpecificSection_tags_1) /sizeof(asn_DEF_ManufacturerSpecificSection_tags_1[0]), /* 1 */ asn_DEF_ManufacturerSpecificSection_tags_1, /* Same as above */ sizeof(asn_DEF_ManufacturerSpecificSection_tags_1) /sizeof(asn_DEF_ManufacturerSpecificSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ManufacturerSpecificSection_1, 3, /* Elements count */ &asn_SPC_ManufacturerSpecificSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/DescriptiveDataSection.h0000664000175000017500000000473314105434233022260 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DescriptiveDataSection_H_ #define _DescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "Placeholder.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct RealTimeSampleArrayDescriptiveDataSection; struct TimeSampleArrayDescriptiveDataSection; struct DistributionSampleArrayDescriptiveDataSection; struct NumericDescriptiveDataSection; struct EnumerationDescriptiveDataSection; /* DescriptiveDataSection */ typedef struct DescriptiveDataSection { Handle_t handle; Placeholder_t *placeholder /* OPTIONAL */; struct DescriptiveDataSection__realtimesadescs { A_SEQUENCE_OF(struct RealTimeSampleArrayDescriptiveDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *realtimesadescs; struct DescriptiveDataSection__timesadescs { A_SEQUENCE_OF(struct TimeSampleArrayDescriptiveDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *timesadescs; struct DescriptiveDataSection__distributionsadescs { A_SEQUENCE_OF(struct DistributionSampleArrayDescriptiveDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *distributionsadescs; struct DescriptiveDataSection__numericdescs { A_SEQUENCE_OF(struct NumericDescriptiveDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *numericdescs; struct DescriptiveDataSection__enumerationdescs { A_SEQUENCE_OF(struct EnumerationDescriptiveDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *enumerationdescs; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "RealTimeSampleArrayDescriptiveDataSection.h" #include "TimeSampleArrayDescriptiveDataSection.h" #include "DistributionSampleArrayDescriptiveDataSection.h" #include "NumericDescriptiveDataSection.h" #include "EnumerationDescriptiveDataSection.h" #endif /* _DescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/SessionArchiveSection.c0000664000175000017500000002250614105434233022123 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SessionArchiveSection.h" static asn_TYPE_member_t asn_MBR_sessions_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SessionTestSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_sessions_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (7015 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_sessions_specs_13 = { sizeof(struct SessionArchiveSection__sessions), offsetof(struct SessionArchiveSection__sessions, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_sessions_13 = { "sessions", "sessions", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_sessions_tags_13, sizeof(asn_DEF_sessions_tags_13) /sizeof(asn_DEF_sessions_tags_13[0]) - 1, /* 1 */ asn_DEF_sessions_tags_13, /* Same as above */ sizeof(asn_DEF_sessions_tags_13) /sizeof(asn_DEF_sessions_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_sessions_13, 1, /* Single element */ &asn_SPC_sessions_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_notes_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SessionNotesSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_notes_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (7016 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_notes_specs_15 = { sizeof(struct SessionArchiveSection__notes), offsetof(struct SessionArchiveSection__notes, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_notes_15 = { "notes", "notes", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_notes_tags_15, sizeof(asn_DEF_notes_tags_15) /sizeof(asn_DEF_notes_tags_15[0]) - 1, /* 1 */ asn_DEF_notes_tags_15, /* Same as above */ sizeof(asn_DEF_notes_tags_15) /sizeof(asn_DEF_notes_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_notes_15, 1, /* Single element */ &asn_SPC_notes_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SessionArchiveSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, s_archive_id), (ASN_TAG_CLASS_APPLICATION | (2507 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "s-archive-id" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, s_archive_name), (ASN_TAG_CLASS_APPLICATION | (2513 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "s-archive-name" }, { ATF_POINTER, 1, offsetof(struct SessionArchiveSection, s_archive_comments), (ASN_TAG_CLASS_APPLICATION | (2530 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "s-archive-comments" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 4, offsetof(struct SessionArchiveSection, protection), (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ArchiveProtection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "protection" }, { ATF_POINTER, 3, offsetof(struct SessionArchiveSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_POINTER, 2, offsetof(struct SessionArchiveSection, manufacturerspecific), (ASN_TAG_CLASS_APPLICATION | (7002 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ManufacturerSpecificSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "manufacturerspecific" }, { ATF_POINTER, 1, offsetof(struct SessionArchiveSection, healthcareprovider), (ASN_TAG_CLASS_APPLICATION | (7003 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HealthCareProviderSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "healthcareprovider" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, demographics), (ASN_TAG_CLASS_APPLICATION | (7004 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatientDemographicsSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "demographics" }, { ATF_NOFLAGS, 0, offsetof(struct SessionArchiveSection, sessions), (ASN_TAG_CLASS_APPLICATION | (7015 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_sessions_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sessions" }, { ATF_POINTER, 1, offsetof(struct SessionArchiveSection, notes), (ASN_TAG_CLASS_APPLICATION | (7016 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_notes_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "notes" }, }; static ber_tlv_tag_t asn_DEF_SessionArchiveSection_tags_1[] = { (ASN_TAG_CLASS_APPLICATION | (7001 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SessionArchiveSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 215 */ { (ASN_TAG_CLASS_APPLICATION | (2507 << 2)), 1, 0, 0 }, /* s-archive-id at 218 */ { (ASN_TAG_CLASS_APPLICATION | (2513 << 2)), 2, 0, 0 }, /* s-archive-name at 220 */ { (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), 6, 0, 0 }, /* protection at 228 */ { (ASN_TAG_CLASS_APPLICATION | (2530 << 2)), 3, 0, 0 }, /* s-archive-comments at 222 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 4, 0, 0 }, /* starttime at 224 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 5, 0, 0 }, /* stoptime at 226 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 7, 0, 0 }, /* placeholder at 230 */ { (ASN_TAG_CLASS_APPLICATION | (7002 << 2)), 8, 0, 0 }, /* manufacturerspecific at 232 */ { (ASN_TAG_CLASS_APPLICATION | (7003 << 2)), 9, 0, 0 }, /* healthcareprovider at 234 */ { (ASN_TAG_CLASS_APPLICATION | (7004 << 2)), 10, 0, 0 }, /* demographics at 236 */ { (ASN_TAG_CLASS_APPLICATION | (7015 << 2)), 11, 0, 0 }, /* sessions at 239 */ { (ASN_TAG_CLASS_APPLICATION | (7016 << 2)), 12, 0, 0 } /* notes at 243 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SessionArchiveSection_specs_1 = { sizeof(struct SessionArchiveSection), offsetof(struct SessionArchiveSection, _asn_ctx), asn_MAP_SessionArchiveSection_tag2el_1, 13, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SessionArchiveSection = { "SessionArchiveSection", "SessionArchiveSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SessionArchiveSection_tags_1, sizeof(asn_DEF_SessionArchiveSection_tags_1) /sizeof(asn_DEF_SessionArchiveSection_tags_1[0]) - 1, /* 1 */ asn_DEF_SessionArchiveSection_tags_1, /* Same as above */ sizeof(asn_DEF_SessionArchiveSection_tags_1) /sizeof(asn_DEF_SessionArchiveSection_tags_1[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_SessionArchiveSection_1, 13, /* Elements count */ &asn_SPC_SessionArchiveSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PersonName.h0000664000175000017500000000171214105434233017721 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PersonName_H_ #define _PersonName_H_ #include /* Including external dependencies */ #include "FEFString.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct PersonNameGroup; /* PersonName */ typedef struct PersonName { FEFString_t *ungroupedname /* OPTIONAL */; struct PersonNameGroup *characternamegroup /* OPTIONAL */; struct PersonNameGroup *ideographicnamegroup /* OPTIONAL */; struct PersonNameGroup *phoneticnamegroup /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } PersonName_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PersonName; #ifdef __cplusplus } #endif /* Referred external types */ #include "PersonNameGroup.h" #endif /* _PersonName_H_ */ biosig-2.3.3/biosig4c++/t240/MultimediaSection.h0000664000175000017500000000213714105434233021273 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MultimediaSection_H_ #define _MultimediaSection_H_ #include /* Including external dependencies */ #include "AbsoluteTime.h" #include "FEFString.h" #include "Placeholder.h" #include "ContentOrReference.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct Comments; /* MultimediaSection */ typedef struct MultimediaSection { AbsoluteTime_t starttime; AbsoluteTime_t stoptime; FEFString_t mimetype; struct Comments *comments /* OPTIONAL */; FEFString_t *originallocation /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; ContentOrReference_t contentorreference; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MultimediaSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MultimediaSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "Comments.h" #endif /* _MultimediaSection_H_ */ biosig-2.3.3/biosig4c++/t240/AlertSection.h0000664000175000017500000000214514105434233020247 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertSection_H_ #define _AlertSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "AlertCode.h" #include "FEFString.h" #include "ObservationTime.h" #include "AlertCondition.h" #include "HandleRef.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct LimitSpecEntry; /* AlertSection */ typedef struct AlertSection { Handle_t handle; AlertCode_t alerttype; FEFString_t *labelstring /* OPTIONAL */; ObservationTime_t timestamp; AlertCondition_t alertcondition; struct LimitSpecEntry *limitspec /* OPTIONAL */; HandleRef_t *vmoreference /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } AlertSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "LimitSpecEntry.h" #endif /* _AlertSection_H_ */ biosig-2.3.3/biosig4c++/t240/PatientSex.h0000664000175000017500000000170014105434233017733 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PatientSex_H_ #define _PatientSex_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum PatientSex { PatientSex_sex_unknown = 0, PatientSex_male = 1, PatientSex_female = 2, PatientSex_sex_unspecified = 9 } e_PatientSex; /* PatientSex */ typedef INTEGER_t PatientSex_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PatientSex; asn_struct_free_f PatientSex_free; asn_struct_print_f PatientSex_print; asn_constr_check_f PatientSex_constraint; ber_type_decoder_f PatientSex_decode_ber; der_type_encoder_f PatientSex_encode_der; xer_type_decoder_f PatientSex_decode_xer; xer_type_encoder_f PatientSex_encode_xer; #ifdef __cplusplus } #endif #endif /* _PatientSex_H_ */ biosig-2.3.3/biosig4c++/t240/asn_SEQUENCE_OF.h0000664000175000017500000000273514105434233020315 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_SEQUENCE_OF_H #define ASN_SEQUENCE_OF_H #include #ifdef __cplusplus extern "C" { #endif /* * SEQUENCE OF is the same as SET OF with a tiny difference: * the delete operation preserves the initial order of elements * and thus MAY operate in non-constant time. */ #define A_SEQUENCE_OF(type) A_SET_OF(type) #define ASN_SEQUENCE_ADD(headptr, ptr) \ asn_sequence_add((headptr), (ptr)) /*********************************************** * Implementation of the SEQUENCE OF structure. */ #define asn_sequence_add asn_set_add #define asn_sequence_empty asn_set_empty /* * Delete the element from the set by its number (base 0). * This is NOT a constant-time operation. * The order of elements is preserved. * If _do_free is given AND the (*free) is initialized, the element * will be freed using the custom (*free) function as well. */ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free); /* * Cope with different conversions requirements to/from void in C and C++. * This is mostly useful for support library. */ typedef A_SEQUENCE_OF(void) asn_anonymous_sequence_; #define _A_SEQUENCE_FROM_VOID(ptr) ((asn_anonymous_sequence_ *)(ptr)) #define _A_CSEQUENCE_FROM_VOID(ptr) ((const asn_anonymous_sequence_ *)(ptr)) #ifdef __cplusplus } #endif #endif /* ASN_SEQUENCE_OF_H */ biosig-2.3.3/biosig4c++/t240/TimeSampleArrayMeasuredDataSection.c0000664000175000017500000001606514105434233024520 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "TimeSampleArrayMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_metriclist_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriclist_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriclist_specs_5 = { sizeof(struct TimeSampleArrayMeasuredDataSection__metriclist), offsetof(struct TimeSampleArrayMeasuredDataSection__metriclist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriclist_5 = { "metriclist", "metriclist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriclist_tags_5, sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]) - 1, /* 1 */ asn_DEF_metriclist_tags_5, /* Same as above */ sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriclist_5, 1, /* Single element */ &asn_SPC_metriclist_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_tsamarkerlist_7[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MarkerEntryRelTim, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_tsamarkerlist_tags_7[] = { (ASN_TAG_CLASS_APPLICATION | (2452 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_tsamarkerlist_specs_7 = { sizeof(struct TimeSampleArrayMeasuredDataSection__tsamarkerlist), offsetof(struct TimeSampleArrayMeasuredDataSection__tsamarkerlist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_tsamarkerlist_7 = { "tsamarkerlist", "tsamarkerlist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_tsamarkerlist_tags_7, sizeof(asn_DEF_tsamarkerlist_tags_7) /sizeof(asn_DEF_tsamarkerlist_tags_7[0]) - 1, /* 1 */ asn_DEF_tsamarkerlist_tags_7, /* Same as above */ sizeof(asn_DEF_tsamarkerlist_tags_7) /sizeof(asn_DEF_tsamarkerlist_tags_7[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_tsamarkerlist_7, 1, /* Single element */ &asn_SPC_tsamarkerlist_specs_7 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_TimeSampleArrayMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayMeasuredDataSection, numberofsubblocks), (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numberofsubblocks" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayMeasuredDataSection, subblocklength), (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocklength" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayMeasuredDataSection, subblocksize), (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocksize" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayMeasuredDataSection, metriclist), (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriclist_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriclist" }, { ATF_POINTER, 1, offsetof(struct TimeSampleArrayMeasuredDataSection, tsamarkerlist), (ASN_TAG_CLASS_APPLICATION | (2452 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_tsamarkerlist_7, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "tsamarkerlist" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayMeasuredDataSection, data), (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 0, &asn_DEF_SampleArrayMeasuredDataBlock, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "data" }, }; static ber_tlv_tag_t asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_TimeSampleArrayMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2452 << 2)), 4, 0, 0 }, /* tsamarkerlist at 1254 */ { (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), 0, 0, 0 }, /* numberofsubblocks at 1220 */ { (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), 1, 0, 0 }, /* subblocklength at 1222 */ { (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), 2, 0, 0 }, /* subblocksize at 1225 */ { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), 3, 0, 0 }, /* metriclist at 1230 */ { (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 5, 0, 0 } /* data at 1259 */ }; static asn_SEQUENCE_specifics_t asn_SPC_TimeSampleArrayMeasuredDataSection_specs_1 = { sizeof(struct TimeSampleArrayMeasuredDataSection), offsetof(struct TimeSampleArrayMeasuredDataSection, _asn_ctx), asn_MAP_TimeSampleArrayMeasuredDataSection_tag2el_1, 6, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_TimeSampleArrayMeasuredDataSection = { "TimeSampleArrayMeasuredDataSection", "TimeSampleArrayMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1, sizeof(asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_TimeSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_TimeSampleArrayMeasuredDataSection_1, 6, /* Elements count */ &asn_SPC_TimeSampleArrayMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/AlertFlags.c0000664000175000017500000000716714105434233017703 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertFlags.h" int AlertFlags_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void AlertFlags_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void AlertFlags_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { AlertFlags_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int AlertFlags_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { AlertFlags_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t AlertFlags_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { AlertFlags_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t AlertFlags_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { AlertFlags_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t AlertFlags_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { AlertFlags_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t AlertFlags_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { AlertFlags_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_AlertFlags_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_AlertFlags = { "AlertFlags", "AlertFlags", AlertFlags_free, AlertFlags_print, AlertFlags_constraint, AlertFlags_decode_ber, AlertFlags_encode_der, AlertFlags_decode_xer, AlertFlags_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertFlags_tags_1, sizeof(asn_DEF_AlertFlags_tags_1) /sizeof(asn_DEF_AlertFlags_tags_1[0]), /* 1 */ asn_DEF_AlertFlags_tags_1, /* Same as above */ sizeof(asn_DEF_AlertFlags_tags_1) /sizeof(asn_DEF_AlertFlags_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/EnumerationMeasuredDataSection.h0000664000175000017500000000167014105434233023750 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumerationMeasuredDataSection_H_ #define _EnumerationMeasuredDataSection_H_ #include /* Including external dependencies */ #include "HandleRef.h" #include "ChoiceOfEnumObsValue.h" #include "ChoiceOfEnumTimeStamp.h" #include #ifdef __cplusplus extern "C" { #endif /* EnumerationMeasuredDataSection */ typedef struct EnumerationMeasuredDataSection { HandleRef_t metricref; ChoiceOfEnumObsValue_t enumobservedvalue; ChoiceOfEnumTimeStamp_t enumtimestamp; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumerationMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumerationMeasuredDataSection; #ifdef __cplusplus } #endif #endif /* _EnumerationMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/MedicalDeviceComponents.h0000664000175000017500000000347514105434233022406 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MedicalDeviceComponents_H_ #define _MedicalDeviceComponents_H_ #include /* Including external dependencies */ #include "VirtualMedicalDeviceSection.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MedicalDeviceComponents_PR { MedicalDeviceComponents_PR_NOTHING, /* No components present */ MedicalDeviceComponents_PR_medicaldevice, MedicalDeviceComponents_PR_medicaldevices, MedicalDeviceComponents_PR_subsystems } MedicalDeviceComponents_PR; /* Forward declarations */ struct VirtualMedicalDeviceSection; struct MedicalDeviceSystemSection; /* MedicalDeviceComponents */ typedef struct MedicalDeviceComponents { MedicalDeviceComponents_PR present; union MedicalDeviceComponents_u { VirtualMedicalDeviceSection_t medicaldevice; struct MedicalDeviceComponents__medicaldevices { A_SEQUENCE_OF(struct VirtualMedicalDeviceSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } medicaldevices; struct MedicalDeviceComponents__subsystems { A_SEQUENCE_OF(struct MedicalDeviceSystemSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } subsystems; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MedicalDeviceComponents_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MedicalDeviceComponents; #ifdef __cplusplus } #endif /* Referred external types */ #include "VirtualMedicalDeviceSection.h" #include "MedicalDeviceSystemSection.h" #endif /* _MedicalDeviceComponents_H_ */ biosig-2.3.3/biosig4c++/t240/DispResolution.c0000664000175000017500000000425714105434233020637 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DispResolution.h" static asn_TYPE_member_t asn_MBR_DispResolution_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DispResolution, prepoint), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "prepoint" }, { ATF_NOFLAGS, 0, offsetof(struct DispResolution, postpoint), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "postpoint" }, }; static ber_tlv_tag_t asn_DEF_DispResolution_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DispResolution_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* prepoint at 1306 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* postpoint at 1308 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DispResolution_specs_1 = { sizeof(struct DispResolution), offsetof(struct DispResolution, _asn_ctx), asn_MAP_DispResolution_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DispResolution = { "DispResolution", "DispResolution", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DispResolution_tags_1, sizeof(asn_DEF_DispResolution_tags_1) /sizeof(asn_DEF_DispResolution_tags_1[0]), /* 1 */ asn_DEF_DispResolution_tags_1, /* Same as above */ sizeof(asn_DEF_DispResolution_tags_1) /sizeof(asn_DEF_DispResolution_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DispResolution_1, 2, /* Elements count */ &asn_SPC_DispResolution_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/BIT_STRING.h0000664000175000017500000000147014105434233017357 0ustar schloeglschloegl/*- * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _BIT_STRING_H_ #define _BIT_STRING_H_ #include /* Some help from OCTET STRING */ #ifdef __cplusplus extern "C" { #endif typedef struct BIT_STRING_s { uint8_t *buf; /* BIT STRING body */ int size; /* Size of the above buffer */ int bits_unused;/* Unused trailing bits in the last octet (0..7) */ asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */ } BIT_STRING_t; extern asn_TYPE_descriptor_t asn_DEF_BIT_STRING; asn_struct_print_f BIT_STRING_print; /* Human-readable output */ asn_constr_check_f BIT_STRING_constraint; xer_type_encoder_f BIT_STRING_encode_xer; #ifdef __cplusplus } #endif #endif /* _BIT_STRING_H_ */ biosig-2.3.3/biosig4c++/t240/constr_SET.c0000664000175000017500000005657514105434233017711 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include /* Check that all the mandatory members are present */ static int _SET_is_populated(asn_TYPE_descriptor_t *td, void *st); /* * Number of bytes left for this structure. * (ctx->left) indicates the number of bytes _transferred_ for the structure. * (size) contains the number of bytes in the buffer passed. */ #define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) /* * If the subprocessor function returns with an indication that it wants * more data, it may well be a fatal decoding problem, because the * size is constrained by the 's L, even if the buffer size allows * reading more data. * For example, consider the buffer containing the following TLVs: * ... * The TLV length clearly indicates that one byte is expected in V, but * if the V processor returns with "want more data" even if the buffer * contains way more data than the V processor have seen. */ #define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) /* * This macro "eats" the part of the buffer which is definitely "consumed", * i.e. was correctly converted into local representation or rightfully skipped. */ #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ ptr = ((const char *)ptr) + num;\ size -= num; \ if(ctx->left >= 0) \ ctx->left -= num; \ consumed_myself += num; \ } while(0) /* * Switch to the next phase of parsing. */ #undef NEXT_PHASE #define NEXT_PHASE(ctx) do { \ ctx->phase++; \ ctx->step = 0; \ } while(0) /* * Return a standardized complex structure. */ #undef RETURN #define RETURN(_code) do { \ rval.code = _code; \ rval.consumed = consumed_myself;\ return rval; \ } while(0) /* * Tags are canonically sorted in the tag2element map. */ static int _t2e_cmp(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; int a_class = BER_TAG_CLASS(a->el_tag); int b_class = BER_TAG_CLASS(b->el_tag); if(a_class == b_class) { ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag); ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); if(a_value == b_value) return 0; else if(a_value < b_value) return -1; else return 1; } else if(a_class < b_class) { return -1; } else { return 1; } } /* * The decoder of the SET type. */ asn_dec_rval_t SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *ptr, size_t size, int tag_mode) { /* * Bring closer parts of structure description. */ asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; asn_TYPE_member_t *elements = td->elements; /* * Parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ ber_tlv_tag_t tlv_tag; /* T from TLV */ asn_dec_rval_t rval; /* Return code from subparsers */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* SET element's index */ ASN_DEBUG("Decoding %s as SET", td->name); if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) { RETURN(RC_FAIL); } } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Start to parse where left previously */ switch(ctx->phase) { case 0: /* * PHASE 0. * Check that the set of tags associated with given structure * perfectly fits our expectations. */ rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, 1, &ctx->left, 0); if(rval.code != RC_OK) { ASN_DEBUG("%s tagging check failed: %d", td->name, rval.code); return rval; } if(ctx->left >= 0) ctx->left += rval.consumed; /* ?Substracted below! */ ADVANCE(rval.consumed); NEXT_PHASE(ctx); ASN_DEBUG("Structure advertised %ld bytes, " "buffer contains %ld", (long)ctx->left, (long)size); /* Fall through */ case 1: /* * PHASE 1. * From the place where we've left it previously, * try to decode the next member from the list of * this structure's elements. * Note that elements in BER may arrive out of * order, yet DER mandates that they shall arive in the * canonical order of their tags. So, there is a room * for optimization. */ for(;; ctx->step = 0) { asn_TYPE_tag2member_t *t2m; asn_TYPE_tag2member_t key; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ ssize_t tag_len; /* Length of TLV's T */ if(ctx->step & 1) { edx = ctx->step >> 1; goto microphase2; } /* * MICROPHASE 1: Synchronize decoding. */ if(ctx->left == 0) /* * No more things to decode. * Exit out of here and check whether all mandatory * elements have been received (in the next phase). */ break; /* * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { /* * Found the terminator of the * indefinite length structure. * Invoke the generic finalization function. */ goto phase3; } } key.el_tag = tlv_tag; t2m = (asn_TYPE_tag2member_t *)bsearch(&key, specs->tag2el, specs->tag2el_count, sizeof(specs->tag2el[0]), _t2e_cmp); if(t2m) { /* * Found the element corresponding to the tag. */ edx = t2m->el_no; ctx->step = (edx << 1) + 1; ASN_DEBUG("Got tag %s (%s), edx %d", ber_tlv_tag_string(tlv_tag), td->name, edx); } else if(specs->extensible == 0) { ASN_DEBUG("Unexpected tag %s " "in non-extensible SET %s", ber_tlv_tag_string(tlv_tag), td->name); RETURN(RC_FAIL); } else { /* Skip this tag */ ssize_t skip; ASN_DEBUG("Skipping unknown tag %s", ber_tlv_tag_string(tlv_tag)); skip = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tag_len, LEFT - tag_len); switch(skip) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } ADVANCE(skip + tag_len); continue; /* Try again with the next tag */ } /* * MICROPHASE 2: Invoke the member-specific decoder. */ microphase2: /* * Check for duplications: must not overwrite * already decoded elements. */ if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset, edx)) { ASN_DEBUG("SET %s: Duplicate element %s (%d)", td->name, elements[edx].name, edx); RETURN(RC_FAIL); } /* * Compute the position of the member inside a structure, * and also a type of containment (it may be contained * as pointer or using inline inclusion). */ if(elements[edx].flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset); } else { /* * A pointer to a pointer * holding the start of the structure */ memb_ptr = (char *)st + elements[edx].memb_offset; memb_ptr2 = &memb_ptr; } /* * Invoke the member fetch routine according to member's type */ rval = elements[edx].type->ber_decoder(opt_codec_ctx, elements[edx].type, memb_ptr2, ptr, LEFT, elements[edx].tag_mode); switch(rval.code) { case RC_OK: ASN_SET_MKPRESENT((char *)st + specs->pres_offset, edx); break; case RC_WMORE: /* More data expected */ if(!SIZE_VIOLATION) { ADVANCE(rval.consumed); RETURN(RC_WMORE); } /* Fail through */ case RC_FAIL: /* Fatal error */ RETURN(RC_FAIL); } /* switch(rval) */ ADVANCE(rval.consumed); } /* for(all structure members) */ phase3: ctx->phase = 3; /* Fall through */ case 3: case 4: /* Only 00 is expected */ ASN_DEBUG("SET %s Leftover: %ld, size = %ld", td->name, (long)ctx->left, (long)size); /* * Skip everything until the end of the SET. */ while(ctx->left) { ssize_t tl, ll; tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); switch(tl) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } /* * If expected <0><0>... */ if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { /* * Correctly finished with <0><0>. */ ADVANCE(2); ctx->left++; ctx->phase = 4; continue; } } if(specs->extensible == 0 || ctx->phase == 4) { ASN_DEBUG("Unexpected continuation " "of a non-extensible type %s " "(ptr=%02x)", td->name, *(const uint8_t *)ptr); RETURN(RC_FAIL); } ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tl, LEFT - tl); switch(ll) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } ADVANCE(tl + ll); } ctx->phase = 5; case 5: /* Check that all mandatory elements are present. */ if(!_SET_is_populated(td, st)) RETURN(RC_FAIL); NEXT_PHASE(ctx); } RETURN(RC_OK); } static int _SET_is_populated(asn_TYPE_descriptor_t *td, void *st) { asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; int edx; /* * Check that all mandatory elements are present. */ for(edx = 0; edx < td->elements_count; edx += (8 * sizeof(specs->_mandatory_elements[0]))) { unsigned int midx, pres, must; midx = edx/(8 * sizeof(specs->_mandatory_elements[0])); pres = ((unsigned int *)((char *)st+specs->pres_offset))[midx]; must = sys_ntohl(specs->_mandatory_elements[midx]); if((pres & must) == must) { /* * Yes, everything seems to be in place. */ } else { ASN_DEBUG("One or more mandatory elements " "of a SET %s %d (%08x.%08x)=%08x " "are not present", td->name, midx, pres, must, (~(pres & must) & must) ); return 0; } } return 1; } /* * The DER encoder of the SET type. */ asn_enc_rval_t SET_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; size_t computed_size = 0; asn_enc_rval_t er; int t2m_build_own = (specs->tag2el_count != td->elements_count); asn_TYPE_tag2member_t *t2m; int t2m_count; ssize_t ret; int edx; /* * Use existing, or build our own tags map. */ if(t2m_build_own) { t2m = (asn_TYPE_tag2member_t *)alloca( td->elements_count * sizeof(t2m[0])); if(!t2m) _ASN_ENCODE_FAILED; /* There are such platforms */ t2m_count = 0; } else { /* * There is no untagged CHOICE in this SET. * Employ existing table. */ t2m = specs->tag2el; t2m_count = specs->tag2el_count; } /* * Gather the length of the underlying members sequence. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; asn_enc_rval_t tmper; void *memb_ptr; /* * Compute the length of the encoding of this member. */ if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) { if(!elm->optional) /* Mandatory elements missing */ _ASN_ENCODE_FAILED; if(t2m_build_own) { t2m[t2m_count].el_no = edx; t2m[t2m_count].el_tag = 0; t2m_count++; } continue; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } tmper = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(tmper.encoded == -1) return tmper; computed_size += tmper.encoded; /* * Remember the outmost tag of this member. */ if(t2m_build_own) { t2m[t2m_count].el_no = edx; t2m[t2m_count].el_tag = asn_TYPE_outmost_tag( elm->type, memb_ptr, elm->tag_mode, elm->tag); t2m_count++; } else { /* * No dynamic sorting is necessary. */ } } /* * Finalize order of the components. */ assert(t2m_count == td->elements_count); if(t2m_build_own) { /* * Sort the underlying members according to their * canonical tags order. DER encoding mandates it. */ qsort(t2m, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp); } else { /* * Tags are already sorted by the compiler. */ } /* * Encode the TLV for the sequence itself. */ ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); if(ret == -1) _ASN_ENCODE_FAILED; er.encoded = computed_size + ret; if(!cb) _ASN_ENCODED_OK(er); /* * Encode all members. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm; asn_enc_rval_t tmper; void *memb_ptr; /* Encode according to the tag order */ elm = &td->elements[t2m[edx].el_no]; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) continue; } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } tmper = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(tmper.encoded == -1) return tmper; computed_size -= tmper.encoded; } if(computed_size != 0) { /* * Encoded size is not equal to the computed size. */ _ASN_ENCODE_FAILED; } _ASN_ENCODED_OK(er); } #undef XER_ADVANCE #define XER_ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ buf_ptr = ((const char *)buf_ptr) + num;\ size -= num; \ consumed_myself += num; \ } while(0) /* * Decode the XER (XML) data. */ asn_dec_rval_t SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const char *opt_mname, const void *buf_ptr, size_t size) { /* * Bring closer parts of structure description. */ asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; asn_TYPE_member_t *elements = td->elements; const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; /* * ... and parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ asn_dec_rval_t rval; /* Return value from a decoder */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* Element index */ /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) RETURN(RC_FAIL); } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Phases of XER/XML processing: * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. * Phase 2: Processing inner type. * Phase 3: Skipping unknown extensions. * Phase 4: PHASED OUT */ for(edx = ctx->step; ctx->phase <= 3;) { pxer_chunk_type_e ch_type; /* XER chunk type */ ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ asn_TYPE_member_t *elm; /* * Go inside the inner member of a set. */ if(ctx->phase == 2) { asn_dec_rval_t tmprval; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset, edx)) { ASN_DEBUG("SET %s: Duplicate element %s (%d)", td->name, elements[edx].name, edx); RETURN(RC_FAIL); } elm = &elements[edx]; if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } /* Invoke the inner type decoder, m.b. multiple times */ tmprval = elm->type->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); if(tmprval.code != RC_OK) RETURN(tmprval.code); ctx->phase = 1; /* Back to body processing */ ASN_SET_MKPRESENT((char *)st + specs->pres_offset, edx); ASN_DEBUG("XER/SET phase => %d", ctx->phase); /* Fall through */ } /* * Get the next part of the XML stream. */ ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type); switch(ch_size) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); default: switch(ch_type) { case PXER_COMMENT: /* Got XML comment */ case PXER_TEXT: /* Ignore free-standing text */ XER_ADVANCE(ch_size); /* Skip silently */ continue; case PXER_TAG: break; /* Check the rest down there */ } } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); ASN_DEBUG("XER/SET: tcv = %d, ph=%d", tcv, ctx->phase); /* Skip the extensions section */ if(ctx->phase == 3) { switch(xer_skip_unknown(tcv, &ctx->left)) { case -1: ctx->phase = 4; RETURN(RC_FAIL); case 1: ctx->phase = 1; /* Fall through */ case 0: XER_ADVANCE(ch_size); continue; case 2: ctx->phase = 1; break; } } switch(tcv) { case XCT_CLOSING: if(ctx->phase == 0) break; ctx->phase = 0; /* Fall through */ case XCT_BOTH: if(ctx->phase == 0) { if(_SET_is_populated(td, st)) { XER_ADVANCE(ch_size); ctx->phase = 4; /* Phase out */ RETURN(RC_OK); } else { ASN_DEBUG("Premature end of XER SET"); RETURN(RC_FAIL); } } /* Fall through */ case XCT_OPENING: if(ctx->phase == 0) { XER_ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; } /* Fall through */ case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: ASN_DEBUG("XER/SET: tcv=%d, ph=%d", tcv, ctx->phase); if(ctx->phase != 1) break; /* Really unexpected */ /* * Search which member corresponds to this tag. */ for(edx = 0; edx < td->elements_count; edx++) { switch(xer_check_tag(buf_ptr, ch_size, elements[edx].name)) { case XCT_BOTH: case XCT_OPENING: /* * Process this member. */ ctx->step = edx; ctx->phase = 2; break; case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: continue; default: edx = td->elements_count; break; /* Phase out */ } break; } if(edx != td->elements_count) continue; /* It is expected extension */ if(specs->extensible) { ASN_DEBUG("Got anticipated extension"); /* * Check for (XCT_BOTH or XCT_UNKNOWN_BO) * By using a mask. Only record a pure * tags. */ if(tcv & XCT_CLOSING) { /* Found without body */ } else { ctx->left = 1; ctx->phase = 3; /* Skip ...'s */ } XER_ADVANCE(ch_size); continue; } /* Fall through */ default: break; } ASN_DEBUG("Unexpected XML tag in SET, expected \"%s\"", xml_tag); break; } ctx->phase = 4; /* "Phase out" on hard failure */ RETURN(RC_FAIL); } asn_enc_rval_t SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; asn_enc_rval_t er; int xcan = (flags & XER_F_CANONICAL); asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer; int t2m_count = specs->tag2el_cxer_count; int edx; if(!sptr) _ASN_ENCODE_FAILED; assert(t2m_count == td->elements_count); er.encoded = 0; for(edx = 0; edx < t2m_count; edx++) { asn_enc_rval_t tmper; asn_TYPE_member_t *elm; void *memb_ptr; const char *mname; unsigned int mlen; elm = &td->elements[t2m[edx].el_no]; mname = elm->name; mlen = strlen(elm->name); if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; /* Mandatory element missing */ _ASN_ENCODE_FAILED; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } int SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { int edx; int ret; if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; /* Dump preamble */ if(cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) return -1; for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; /* Print line */ /* Fall through */ } } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } _i_INDENT(1); /* Print the member's name and stuff */ if(cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) return -1; /* Print the member itself */ ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } ilevel--; _i_INDENT(1); return (cb("}", 1, app_key) < 0) ? -1 : 0; } void SET_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { int edx; if(!td || !ptr) return; ASN_DEBUG("Freeing %s as SET", td->name); for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)ptr + elm->memb_offset); if(memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); } else { memb_ptr = (void *)((char *)ptr + elm->memb_offset); ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr); } } if(!contents_only) { FREEMEM(ptr); } } int SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { int edx; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } /* * Iterate over structure members and check their validity. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; _ASN_CTFAIL(app_key, td, sptr, "%s: mandatory element %s absent (%s:%d)", td->name, elm->name, __FILE__, __LINE__); return -1; } } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } if(elm->memb_constraints) { int ret = elm->memb_constraints(elm->type, memb_ptr, ctfailcb, app_key); if(ret) return ret; } else { int ret = elm->type->check_constraints(elm->type, memb_ptr, ctfailcb, app_key); if(ret) return ret; /* * Cannot inherit it earlier: * need to make sure we get the updated version. */ elm->memb_constraints = elm->type->check_constraints; } } return 0; } biosig-2.3.3/biosig4c++/t240/DistributionSampleArrayMeasuredDataSection.c0000664000175000017500000001263214105434233026275 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DistributionSampleArrayMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_metriclist_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriclist_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriclist_specs_5 = { sizeof(struct DistributionSampleArrayMeasuredDataSection__metriclist), offsetof(struct DistributionSampleArrayMeasuredDataSection__metriclist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriclist_5 = { "metriclist", "metriclist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriclist_tags_5, sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]) - 1, /* 1 */ asn_DEF_metriclist_tags_5, /* Same as above */ sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriclist_5, 1, /* Single element */ &asn_SPC_metriclist_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_DistributionSampleArrayMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayMeasuredDataSection, numberofsubblocks), (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numberofsubblocks" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayMeasuredDataSection, subblocklength), (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocklength" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayMeasuredDataSection, subblocksize), (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocksize" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayMeasuredDataSection, metriclist), (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriclist_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriclist" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayMeasuredDataSection, data), (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 0, &asn_DEF_SampleArrayMeasuredDataBlock, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "data" }, }; static ber_tlv_tag_t asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DistributionSampleArrayMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), 0, 0, 0 }, /* numberofsubblocks at 1220 */ { (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), 1, 0, 0 }, /* subblocklength at 1222 */ { (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), 2, 0, 0 }, /* subblocksize at 1225 */ { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), 3, 0, 0 }, /* metriclist at 1230 */ { (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 4, 0, 0 } /* data at 1275 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DistributionSampleArrayMeasuredDataSection_specs_1 = { sizeof(struct DistributionSampleArrayMeasuredDataSection), offsetof(struct DistributionSampleArrayMeasuredDataSection, _asn_ctx), asn_MAP_DistributionSampleArrayMeasuredDataSection_tag2el_1, 5, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DistributionSampleArrayMeasuredDataSection = { "DistributionSampleArrayMeasuredDataSection", "DistributionSampleArrayMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1, sizeof(asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_DistributionSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DistributionSampleArrayMeasuredDataSection_1, 5, /* Elements count */ &asn_SPC_DistributionSampleArrayMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/VirtualMedicalDeviceSection.h0000664000175000017500000000314314105434233023224 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _VirtualMedicalDeviceSection_H_ #define _VirtualMedicalDeviceSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "DeviceCode.h" #include "FEFString.h" #include #include "ParameterGroupCode.h" #include "MsmtPrinciple.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct SystemModel; struct ProdSpecEntry; /* VirtualMedicalDeviceSection */ typedef struct VirtualMedicalDeviceSection { Handle_t handle; DeviceCode_t devicetype; FEFString_t *labelstring /* OPTIONAL */; struct SystemModel *vmdmodel /* OPTIONAL */; struct VirtualMedicalDeviceSection__productionspecification { A_SEQUENCE_OF(struct ProdSpecEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *productionspecification; INTEGER_t *compatibilityid /* OPTIONAL */; ParameterGroupCode_t *parametergroup /* OPTIONAL */; INTEGER_t *position /* OPTIONAL */; MsmtPrinciple_t *measurementprinciple /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } VirtualMedicalDeviceSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_VirtualMedicalDeviceSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "SystemModel.h" #include "ProdSpecEntry.h" #endif /* _VirtualMedicalDeviceSection_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCategory.c0000664000175000017500000000731514105434233020573 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricCategory.h" int MetricCategory_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void MetricCategory_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void MetricCategory_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MetricCategory_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MetricCategory_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MetricCategory_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MetricCategory_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MetricCategory_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MetricCategory_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MetricCategory_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MetricCategory_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MetricCategory_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MetricCategory_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MetricCategory_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MetricCategory_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MetricCategory = { "MetricCategory", "MetricCategory", MetricCategory_free, MetricCategory_print, MetricCategory_constraint, MetricCategory_decode_ber, MetricCategory_encode_der, MetricCategory_decode_xer, MetricCategory_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricCategory_tags_1, sizeof(asn_DEF_MetricCategory_tags_1) /sizeof(asn_DEF_MetricCategory_tags_1[0]), /* 1 */ asn_DEF_MetricCategory_tags_1, /* Same as above */ sizeof(asn_DEF_MetricCategory_tags_1) /sizeof(asn_DEF_MetricCategory_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/GeneralString.c0000664000175000017500000000217514105434233020415 0ustar schloeglschloegl/*- * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include /* * GeneralString basic type description. */ static ber_tlv_tag_t asn_DEF_GeneralString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (27 << 2)), /* [UNIVERSAL 27] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; asn_TYPE_descriptor_t asn_DEF_GeneralString = { "GeneralString", "GeneralString", OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ asn_generic_unknown_constraint, OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, OCTET_STRING_decode_xer_hex, OCTET_STRING_encode_xer, 0, 0, 0, /* Use generic outmost tag fetcher */ asn_DEF_GeneralString_tags, sizeof(asn_DEF_GeneralString_tags) / sizeof(asn_DEF_GeneralString_tags[0]) - 1, asn_DEF_GeneralString_tags, sizeof(asn_DEF_GeneralString_tags) / sizeof(asn_DEF_GeneralString_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/UnitCode.c0000664000175000017500000000733014105434233017361 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "UnitCode.h" int UnitCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_UnitsOfMeasurementCode.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using UnitsOfMeasurementCode, * so here we adjust the DEF accordingly. */ static void UnitCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_UnitsOfMeasurementCode.free_struct; td->print_struct = asn_DEF_UnitsOfMeasurementCode.print_struct; td->ber_decoder = asn_DEF_UnitsOfMeasurementCode.ber_decoder; td->der_encoder = asn_DEF_UnitsOfMeasurementCode.der_encoder; td->xer_decoder = asn_DEF_UnitsOfMeasurementCode.xer_decoder; td->xer_encoder = asn_DEF_UnitsOfMeasurementCode.xer_encoder; td->uper_decoder = asn_DEF_UnitsOfMeasurementCode.uper_decoder; td->uper_encoder = asn_DEF_UnitsOfMeasurementCode.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_UnitsOfMeasurementCode.per_constraints; td->elements = asn_DEF_UnitsOfMeasurementCode.elements; td->elements_count = asn_DEF_UnitsOfMeasurementCode.elements_count; td->specifics = asn_DEF_UnitsOfMeasurementCode.specifics; } void UnitCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { UnitCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int UnitCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { UnitCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t UnitCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { UnitCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t UnitCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { UnitCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t UnitCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { UnitCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t UnitCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { UnitCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_UnitCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_UnitCode = { "UnitCode", "UnitCode", UnitCode_free, UnitCode_print, UnitCode_constraint, UnitCode_decode_ber, UnitCode_encode_der, UnitCode_decode_xer, UnitCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_UnitCode_tags_1, sizeof(asn_DEF_UnitCode_tags_1) /sizeof(asn_DEF_UnitCode_tags_1[0]), /* 1 */ asn_DEF_UnitCode_tags_1, /* Same as above */ sizeof(asn_DEF_UnitCode_tags_1) /sizeof(asn_DEF_UnitCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/EnumRecordOO.c0000664000175000017500000000402614105434233020147 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumRecordOO.h" static asn_TYPE_member_t asn_MBR_EnumRecordOO_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumRecordOO, record_type_code), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_OID_Type, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "record-type-code" }, { ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct EnumRecordOO, record_data), -1 /* Ambiguous tag (ANY?) */, 0, &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "record-data" }, }; static ber_tlv_tag_t asn_DEF_EnumRecordOO_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumRecordOO_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* record-type-code at 1362 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumRecordOO_specs_1 = { sizeof(struct EnumRecordOO), offsetof(struct EnumRecordOO, _asn_ctx), asn_MAP_EnumRecordOO_tag2el_1, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumRecordOO = { "EnumRecordOO", "EnumRecordOO", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumRecordOO_tags_1, sizeof(asn_DEF_EnumRecordOO_tags_1) /sizeof(asn_DEF_EnumRecordOO_tags_1[0]), /* 1 */ asn_DEF_EnumRecordOO_tags_1, /* Same as above */ sizeof(asn_DEF_EnumRecordOO_tags_1) /sizeof(asn_DEF_EnumRecordOO_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumRecordOO_1, 2, /* Elements count */ &asn_SPC_EnumRecordOO_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SaGridEntry.c0000664000175000017500000000416714105434233020047 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaGridEntry.h" static asn_TYPE_member_t asn_MBR_SaGridEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SaGridEntry, absolute_value), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "absolute-value" }, { ATF_NOFLAGS, 0, offsetof(struct SaGridEntry, level), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "level" }, }; static ber_tlv_tag_t asn_DEF_SaGridEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SaGridEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* absolute-value at 1059 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 1, 0, 0 } /* level at 1061 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SaGridEntry_specs_1 = { sizeof(struct SaGridEntry), offsetof(struct SaGridEntry, _asn_ctx), asn_MAP_SaGridEntry_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SaGridEntry = { "SaGridEntry", "SaGridEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaGridEntry_tags_1, sizeof(asn_DEF_SaGridEntry_tags_1) /sizeof(asn_DEF_SaGridEntry_tags_1[0]), /* 1 */ asn_DEF_SaGridEntry_tags_1, /* Same as above */ sizeof(asn_DEF_SaGridEntry_tags_1) /sizeof(asn_DEF_SaGridEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SaGridEntry_1, 2, /* Elements count */ &asn_SPC_SaGridEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SystemModel.c0000664000175000017500000000420714105434233020114 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SystemModel.h" static asn_TYPE_member_t asn_MBR_SystemModel_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SystemModel, manufacturer), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "manufacturer" }, { ATF_NOFLAGS, 0, offsetof(struct SystemModel, model_number), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "model-number" }, }; static ber_tlv_tag_t asn_DEF_SystemModel_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SystemModel_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* manufacturer at 556 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* model-number at 558 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SystemModel_specs_1 = { sizeof(struct SystemModel), offsetof(struct SystemModel, _asn_ctx), asn_MAP_SystemModel_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SystemModel = { "SystemModel", "SystemModel", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SystemModel_tags_1, sizeof(asn_DEF_SystemModel_tags_1) /sizeof(asn_DEF_SystemModel_tags_1[0]), /* 1 */ asn_DEF_SystemModel_tags_1, /* Same as above */ sizeof(asn_DEF_SystemModel_tags_1) /sizeof(asn_DEF_SystemModel_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SystemModel_1, 2, /* Elements count */ &asn_SPC_SystemModel_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PersonNameGroup.c0000664000175000017500000000716414105434233020740 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PersonNameGroup.h" static asn_TYPE_member_t asn_MBR_PersonNameGroup_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, familyname), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "familyname" }, { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, givenname), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "givenname" }, { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, middlename), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "middlename" }, { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, prefix), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "prefix" }, { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, suffix), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "suffix" }, { ATF_NOFLAGS, 0, offsetof(struct PersonNameGroup, degree), (ASN_TAG_CLASS_CONTEXT | (6 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "degree" }, }; static ber_tlv_tag_t asn_DEF_PersonNameGroup_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_PersonNameGroup_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* familyname at 186 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* givenname at 187 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* middlename at 188 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 }, /* prefix at 189 */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 4, 0, 0 }, /* suffix at 190 */ { (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 5, 0, 0 } /* degree at 192 */ }; static asn_SEQUENCE_specifics_t asn_SPC_PersonNameGroup_specs_1 = { sizeof(struct PersonNameGroup), offsetof(struct PersonNameGroup, _asn_ctx), asn_MAP_PersonNameGroup_tag2el_1, 6, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_PersonNameGroup = { "PersonNameGroup", "PersonNameGroup", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PersonNameGroup_tags_1, sizeof(asn_DEF_PersonNameGroup_tags_1) /sizeof(asn_DEF_PersonNameGroup_tags_1[0]), /* 1 */ asn_DEF_PersonNameGroup_tags_1, /* Same as above */ sizeof(asn_DEF_PersonNameGroup_tags_1) /sizeof(asn_DEF_PersonNameGroup_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_PersonNameGroup_1, 6, /* Elements count */ &asn_SPC_PersonNameGroup_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SessionNotesSection.h0000664000175000017500000000336214105434233021636 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SessionNotesSection_H_ #define _SessionNotesSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "FEFString.h" #include "AbsoluteTime.h" #include "Placeholder.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ArchiveProtection; struct ExtNomenRef; /* SessionNotesSection */ typedef struct SessionNotesSection { Handle_t handle; FEFString_t sn_id; FEFString_t sn_name; FEFString_t *sn_comments /* OPTIONAL */; AbsoluteTime_t starttime; AbsoluteTime_t stoptime; FEFString_t *findings /* OPTIONAL */; struct SessionNotesSection__diagnosticscodes { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *diagnosticscodes; FEFString_t *diagnosisdescription /* OPTIONAL */; struct SessionNotesSection__procedurecodes { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *procedurecodes; FEFString_t *proceduredescription /* OPTIONAL */; struct ArchiveProtection *protection /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SessionNotesSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SessionNotesSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ArchiveProtection.h" #include "ExtNomenRef.h" #endif /* _SessionNotesSection_H_ */ biosig-2.3.3/biosig4c++/t240/ProdSpecEntryType.c0000664000175000017500000000745514105434233021262 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ProdSpecEntryType.h" int ProdSpecEntryType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void ProdSpecEntryType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void ProdSpecEntryType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int ProdSpecEntryType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t ProdSpecEntryType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t ProdSpecEntryType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t ProdSpecEntryType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t ProdSpecEntryType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { ProdSpecEntryType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_ProdSpecEntryType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_ProdSpecEntryType = { "ProdSpecEntryType", "ProdSpecEntryType", ProdSpecEntryType_free, ProdSpecEntryType_print, ProdSpecEntryType_constraint, ProdSpecEntryType_decode_ber, ProdSpecEntryType_encode_der, ProdSpecEntryType_decode_xer, ProdSpecEntryType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ProdSpecEntryType_tags_1, sizeof(asn_DEF_ProdSpecEntryType_tags_1) /sizeof(asn_DEF_ProdSpecEntryType_tags_1[0]), /* 1 */ asn_DEF_ProdSpecEntryType_tags_1, /* Same as above */ sizeof(asn_DEF_ProdSpecEntryType_tags_1) /sizeof(asn_DEF_ProdSpecEntryType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/modules.mk0000664000175000017500000001732714105434233017513 0ustar schloeglschloeglASN_MODULE_SOURCES= \ Address.c \ MetricMeasure.c \ UnitCode.c \ HealthCareProviderId.c \ INT-U64.c \ INT-I64.c \ INT-U32.c \ INT-I32.c \ INT-U16.c \ INT-I16.c \ INT-U8.c \ INT-I8.c \ BITS-32.c \ BITS-16.c \ BITS-8.c \ FEFString.c \ FEFFloat.c \ Fraction.c \ AbsoluteRange.c \ Handle.c \ HandleRef.c \ DeviceCode.c \ UnitsOfMeasurementCode.c \ MetricsCode.c \ BodySiteCode.c \ AlertCode.c \ ExtNomenclatureCode.c \ ParameterGroupCode.c \ PrivateCode.c \ Placeholder.c \ ManufacturerID.c \ AbsoluteTime.c \ RelativeTime.c \ HighResRelativeTime.c \ ObservationTime.c \ SimpleColour.c \ ExtNomenRef.c \ PersonNameGroup.c \ PersonName.c \ OID-Type.c \ SessionArchiveSection.c \ ArchiveProtection.c \ ManufacturerSpecificSection.c \ ManufacturerSpecificEncoded.c \ ManufacturerSpecificBinary.c \ HealthCareProviderSection.c \ HealthCareProfessionalSection.c \ Authorization.c \ PatientDemographicsSection.c \ PatMeasure.c \ PatientSex.c \ PatientType.c \ PatientRace.c \ SessionTestSection.c \ MedicalDeviceSystemSection.c \ SystemModel.c \ SystemSpecEntry.c \ ProdSpecEntryType.c \ ProdSpecEntry.c \ ApplicationArea.c \ PowerStatus.c \ LineFrequency.c \ MedicalDeviceComponents.c \ VirtualMedicalDeviceSection.c \ MsmtPrinciple.c \ ChannelDescriptionSection.c \ ChannelStatus.c \ MultimediaSection.c \ Comments.c \ ContentOrReference.c \ SessionPhaseSection.c \ DescriptiveDataSection.c \ MetricDescriptiveDataSection.c \ MetricStatus.c \ MetricCategory.c \ MetricCalEntry.c \ MetricCalType.c \ MetricCalState.c \ MeasurementStatus.c \ SampleArrayDescriptiveDataSection.c \ SaSpec.c \ StorageDataType.c \ SaFlags.c \ ScaleRangeSpec.c \ SaFilterEntry.c \ FilterType.c \ SaGridEntry.c \ SaCalData.c \ SaCalDataType.c \ SaSignalFrequency.c \ RealTimeSampleArrayDescriptiveDataSection.c \ TimeSampleArrayDescriptiveDataSection.c \ DistributionSampleArrayDescriptiveDataSection.c \ DsaRangeSpec.c \ NumericDescriptiveDataSection.c \ EnumerationDescriptiveDataSection.c \ MeasuredDataSection.c \ SampleArrayMeasuredDataSection.c \ SampleArrayMeasuredDataBlock.c \ RealTimeSampleArrayMeasuredDataSection.c \ TimeSampleArrayMeasuredDataSection.c \ MarkerEntryRelTim.c \ DistributionSampleArrayMeasuredDataSection.c \ NumericMeasuredDataSection.c \ ChoiceOfNuObsValue.c \ NuObsValue.c \ DispResolution.c \ EnumerationMeasuredDataSection.c \ ChoiceOfEnumObsValue.c \ EnumObsValue.c \ EnumVal.c \ EnumObject.c \ EnumRecordMetric.c \ EnumRecordOO.c \ ChoiceOfEnumTimeStamp.c \ AlertSection.c \ AlertCondition.c \ AlertControls.c \ AlertFlags.c \ AlertType.c \ LimitSpecEntry.c \ CurLimAlStat.c \ DynamicAttributeChangeSection.c \ SessionNotesSection.c ASN_MODULE_HEADERS= \ Address.h \ MetricMeasure.h \ UnitCode.h \ HealthCareProviderId.h \ INT-U64.h \ INT-I64.h \ INT-U32.h \ INT-I32.h \ INT-U16.h \ INT-I16.h \ INT-U8.h \ INT-I8.h \ BITS-32.h \ BITS-16.h \ BITS-8.h \ FEFString.h \ FEFFloat.h \ Fraction.h \ AbsoluteRange.h \ Handle.h \ HandleRef.h \ DeviceCode.h \ UnitsOfMeasurementCode.h \ MetricsCode.h \ BodySiteCode.h \ AlertCode.h \ ExtNomenclatureCode.h \ ParameterGroupCode.h \ PrivateCode.h \ Placeholder.h \ ManufacturerID.h \ AbsoluteTime.h \ RelativeTime.h \ HighResRelativeTime.h \ ObservationTime.h \ SimpleColour.h \ ExtNomenRef.h \ PersonNameGroup.h \ PersonName.h \ OID-Type.h \ SessionArchiveSection.h \ ArchiveProtection.h \ ManufacturerSpecificSection.h \ ManufacturerSpecificEncoded.h \ ManufacturerSpecificBinary.h \ HealthCareProviderSection.h \ HealthCareProfessionalSection.h \ Authorization.h \ PatientDemographicsSection.h \ PatMeasure.h \ PatientSex.h \ PatientType.h \ PatientRace.h \ SessionTestSection.h \ MedicalDeviceSystemSection.h \ SystemModel.h \ SystemSpecEntry.h \ ProdSpecEntryType.h \ ProdSpecEntry.h \ ApplicationArea.h \ PowerStatus.h \ LineFrequency.h \ MedicalDeviceComponents.h \ VirtualMedicalDeviceSection.h \ MsmtPrinciple.h \ ChannelDescriptionSection.h \ ChannelStatus.h \ MultimediaSection.h \ Comments.h \ ContentOrReference.h \ SessionPhaseSection.h \ DescriptiveDataSection.h \ MetricDescriptiveDataSection.h \ MetricStatus.h \ MetricCategory.h \ MetricCalEntry.h \ MetricCalType.h \ MetricCalState.h \ MeasurementStatus.h \ SampleArrayDescriptiveDataSection.h \ SaSpec.h \ StorageDataType.h \ SaFlags.h \ ScaleRangeSpec.h \ SaFilterEntry.h \ FilterType.h \ SaGridEntry.h \ SaCalData.h \ SaCalDataType.h \ SaSignalFrequency.h \ RealTimeSampleArrayDescriptiveDataSection.h \ TimeSampleArrayDescriptiveDataSection.h \ DistributionSampleArrayDescriptiveDataSection.h \ DsaRangeSpec.h \ NumericDescriptiveDataSection.h \ EnumerationDescriptiveDataSection.h \ MeasuredDataSection.h \ SampleArrayMeasuredDataSection.h \ SampleArrayMeasuredDataBlock.h \ RealTimeSampleArrayMeasuredDataSection.h \ TimeSampleArrayMeasuredDataSection.h \ MarkerEntryRelTim.h \ DistributionSampleArrayMeasuredDataSection.h \ NumericMeasuredDataSection.h \ ChoiceOfNuObsValue.h \ NuObsValue.h \ DispResolution.h \ EnumerationMeasuredDataSection.h \ ChoiceOfEnumObsValue.h \ EnumObsValue.h \ EnumVal.h \ EnumObject.h \ EnumRecordMetric.h \ EnumRecordOO.h \ ChoiceOfEnumTimeStamp.h \ AlertSection.h \ AlertCondition.h \ AlertControls.h \ AlertFlags.h \ AlertType.h \ LimitSpecEntry.h \ CurLimAlStat.h \ DynamicAttributeChangeSection.h \ SessionNotesSection.h ASN_MODULE_HEADERS+=ANY.h ASN_MODULE_SOURCES+=ANY.c ASN_MODULE_HEADERS+=UTF8String.h ASN_MODULE_HEADERS+=INTEGER.h ASN_MODULE_HEADERS+=NativeEnumerated.h ASN_MODULE_HEADERS+=GeneralizedTime.h ASN_MODULE_SOURCES+=GeneralizedTime.c ASN_MODULE_SOURCES+=INTEGER.c ASN_MODULE_SOURCES+=NativeEnumerated.c ASN_MODULE_HEADERS+=NativeInteger.h ASN_MODULE_SOURCES+=NativeInteger.c ASN_MODULE_HEADERS+=REAL.h ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.c ASN_MODULE_SOURCES+=REAL.c ASN_MODULE_SOURCES+=UTF8String.c ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c ASN_MODULE_HEADERS+=asn_SET_OF.h ASN_MODULE_SOURCES+=asn_SET_OF.c ASN_MODULE_HEADERS+=constr_CHOICE.h ASN_MODULE_SOURCES+=constr_CHOICE.c ASN_MODULE_HEADERS+=constr_SEQUENCE.h ASN_MODULE_SOURCES+=constr_SEQUENCE.c ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c ASN_MODULE_HEADERS+=constr_SET_OF.h ASN_MODULE_SOURCES+=constr_SET_OF.c ASN_MODULE_HEADERS+=asn_application.h ASN_MODULE_HEADERS+=asn_system.h ASN_MODULE_HEADERS+=asn_codecs.h ASN_MODULE_HEADERS+=asn_internal.h ASN_MODULE_HEADERS+=OCTET_STRING.h ASN_MODULE_SOURCES+=OCTET_STRING.c ASN_MODULE_HEADERS+=BIT_STRING.h ASN_MODULE_SOURCES+=BIT_STRING.c ASN_MODULE_SOURCES+=asn_codecs_prim.c ASN_MODULE_HEADERS+=asn_codecs_prim.h ASN_MODULE_HEADERS+=ber_tlv_length.h ASN_MODULE_SOURCES+=ber_tlv_length.c ASN_MODULE_HEADERS+=ber_tlv_tag.h ASN_MODULE_SOURCES+=ber_tlv_tag.c ASN_MODULE_HEADERS+=ber_decoder.h ASN_MODULE_SOURCES+=ber_decoder.c ASN_MODULE_HEADERS+=constr_TYPE.h ASN_MODULE_SOURCES+=constr_TYPE.c ASN_MODULE_HEADERS+=constraints.h ASN_MODULE_SOURCES+=constraints.c ASN_MODULE_HEADERS+=der_encoder.h ASN_MODULE_SOURCES+=der_encoder.c ASN_MODULE_HEADERS+=xer_support.h ASN_MODULE_SOURCES+=xer_support.c ASN_MODULE_HEADERS+=xer_decoder.h ASN_MODULE_SOURCES+=xer_decoder.c ASN_MODULE_HEADERS+=xer_encoder.h ASN_MODULE_SOURCES+=xer_encoder.c ASN_MODULE_HEADERS+=per_opentype.h ASN_MODULE_SOURCES+=per_opentype.c ASN_MODULE_HEADERS+=per_support.h ASN_MODULE_SOURCES+=per_support.c ASN_MODULE_HEADERS+=per_decoder.h ASN_MODULE_SOURCES+=per_decoder.c ASN_MODULE_HEADERS+=per_encoder.h ASN_MODULE_SOURCES+=per_encoder.c ASN_CONVERTER_SOURCES+=converter-sample.c lib_LTLIBRARIES=libsomething.la libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS) biosig-2.3.3/biosig4c++/t240/EnumObsValue.c0000664000175000017500000000475214105434233020221 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumObsValue.h" static asn_TYPE_member_t asn_MBR_EnumObsValue_1[] = { { ATF_POINTER, 2, offsetof(struct EnumObsValue, metric_id), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metric-id" }, { ATF_POINTER, 1, offsetof(struct EnumObsValue, state), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "state" }, { ATF_NOFLAGS, 0, offsetof(struct EnumObsValue, value), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_EnumVal, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "value" }, }; static ber_tlv_tag_t asn_DEF_EnumObsValue_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumObsValue_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* metric-id at 1335 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* state at 1336 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 } /* value at 1338 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumObsValue_specs_1 = { sizeof(struct EnumObsValue), offsetof(struct EnumObsValue, _asn_ctx), asn_MAP_EnumObsValue_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumObsValue = { "EnumObsValue", "EnumObsValue", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumObsValue_tags_1, sizeof(asn_DEF_EnumObsValue_tags_1) /sizeof(asn_DEF_EnumObsValue_tags_1[0]), /* 1 */ asn_DEF_EnumObsValue_tags_1, /* Same as above */ sizeof(asn_DEF_EnumObsValue_tags_1) /sizeof(asn_DEF_EnumObsValue_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumObsValue_1, 3, /* Elements count */ &asn_SPC_EnumObsValue_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/INTEGER.c0000664000175000017500000005435414105434233016754 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* Encoder and decoder of a primitive type */ #include /* * INTEGER basic type description. */ static ber_tlv_tag_t asn_DEF_INTEGER_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INTEGER = { "INTEGER", "INTEGER", ASN__PRIMITIVE_TYPE_free, INTEGER_print, asn_generic_no_constraint, ber_decode_primitive, INTEGER_encode_der, INTEGER_decode_xer, INTEGER_encode_xer, INTEGER_decode_uper, /* Unaligned PER decoder */ INTEGER_encode_uper, /* Unaligned PER encoder */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INTEGER_tags, sizeof(asn_DEF_INTEGER_tags) / sizeof(asn_DEF_INTEGER_tags[0]), asn_DEF_INTEGER_tags, /* Same as above */ sizeof(asn_DEF_INTEGER_tags) / sizeof(asn_DEF_INTEGER_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; /* * Encode INTEGER type using DER. */ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INTEGER_t *st = (INTEGER_t *)sptr; ASN_DEBUG("%s %s as INTEGER (tm=%d)", cb?"Encoding":"Estimating", td->name, tag_mode); /* * Canonicalize integer in the buffer. * (Remove too long sign extension, remove some first 0x00 bytes) */ if(st->buf) { uint8_t *buf = st->buf; uint8_t *end1 = buf + st->size - 1; int shift; /* Compute the number of superfluous leading bytes */ for(; buf < end1; buf++) { /* * If the contents octets of an integer value encoding * consist of more than one octet, then the bits of the * first octet and bit 8 of the second octet: * a) shall not all be ones; and * b) shall not all be zero. */ switch(*buf) { case 0x00: if((buf[1] & 0x80) == 0) continue; break; case 0xff: if((buf[1] & 0x80)) continue; break; } break; } /* Remove leading superfluous bytes from the integer */ shift = buf - st->buf; if(shift) { uint8_t *nb = st->buf; uint8_t *end; st->size -= shift; /* New size, minus bad bytes */ end = nb + st->size; for(; nb < end; nb++, buf++) *nb = *buf; } } /* if(1) */ return der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key); } static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop); /* * INTEGER specific human-readable output. */ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; char scratch[32]; /* Enough for 64-bit integer */ uint8_t *buf = st->buf; uint8_t *buf_end = st->buf + st->size; signed long accum; ssize_t wrote = 0; char *p; int ret; /* * Advance buf pointer until the start of the value's body. * This will make us able to process large integers using simple case, * when the actual value is small * (0x0000000000abcdef would yield a fine 0x00abcdef) */ /* Skip the insignificant leading bytes */ for(; buf < buf_end-1; buf++) { switch(*buf) { case 0x00: if((buf[1] & 0x80) == 0) continue; break; case 0xff: if((buf[1] & 0x80) != 0) continue; break; } break; } /* Simple case: the integer size is small */ if((size_t)(buf_end - buf) <= sizeof(accum)) { const asn_INTEGER_enum_map_t *el; size_t scrsize; char *scr; if(buf == buf_end) { accum = 0; } else { accum = (*buf & 0x80) ? -1 : 0; for(; buf < buf_end; buf++) accum = (accum << 8) | *buf; } el = INTEGER_map_value2enum(specs, accum); if(el) { scrsize = el->enum_len + 32; scr = (char *)alloca(scrsize); if(plainOrXER == 0) ret = snprintf(scr, scrsize, "%ld (%s)", accum, el->enum_name); else ret = snprintf(scr, scrsize, "<%s/>", el->enum_name); } else if(plainOrXER && specs && specs->strict_enumeration) { ASN_DEBUG("ASN.1 forbids dealing with " "unknown value of ENUMERATED type"); errno = EPERM; return -1; } else { scrsize = sizeof(scratch); scr = scratch; ret = snprintf(scr, scrsize, (specs && specs->field_unsigned) ?"%lu":"%ld", accum); } assert(ret > 0 && (size_t)ret < scrsize); return (cb(scr, ret, app_key) < 0) ? -1 : ret; } else if(plainOrXER && specs && specs->strict_enumeration) { /* * Here and earlier, we cannot encode the ENUMERATED values * if there is no corresponding identifier. */ ASN_DEBUG("ASN.1 forbids dealing with " "unknown value of ENUMERATED type"); errno = EPERM; return -1; } /* Output in the long xx:yy:zz... format */ /* TODO: replace with generic algorithm (Knuth TAOCP Vol 2, 4.3.1) */ for(p = scratch; buf < buf_end; buf++) { static const char *h2c = "0123456789ABCDEF"; if((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) { /* Flush buffer */ if(cb(scratch, p - scratch, app_key) < 0) return -1; wrote += p - scratch; p = scratch; } *p++ = h2c[*buf >> 4]; *p++ = h2c[*buf & 0x0F]; *p++ = 0x3a; /* ":" */ } if(p != scratch) p--; /* Remove the last ":" */ wrote += p - scratch; return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote; } /* * INTEGER specific human-readable output. */ int INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const INTEGER_t *st = (const INTEGER_t *)sptr; ssize_t ret; (void)td; (void)ilevel; if(!st || !st->buf) ret = cb("", 8, app_key); else ret = INTEGER__dump(td, st, cb, app_key, 0); return (ret < 0) ? -1 : 0; } struct e2v_key { const char *start; const char *stop; asn_INTEGER_enum_map_t *vemap; unsigned int *evmap; }; static int INTEGER__compar_enum2value(const void *kp, const void *am) { const struct e2v_key *key = (const struct e2v_key *)kp; const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am; const char *ptr, *end, *name; /* Remap the element (sort by different criterion) */ el = key->vemap + key->evmap[el - key->vemap]; /* Compare strings */ for(ptr = key->start, end = key->stop, name = el->enum_name; ptr < end; ptr++, name++) { if(*ptr != *name) return *(const unsigned char *)ptr - *(const unsigned char *)name; } return name[0] ? -1 : 0; } static const asn_INTEGER_enum_map_t * INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop) { asn_INTEGER_enum_map_t *el_found; int count = specs ? specs->map_count : 0; struct e2v_key key; const char *lp; if(!count) return NULL; /* Guaranteed: assert(lstart < lstop); */ /* Figure out the tag name */ for(lstart++, lp = lstart; lp < lstop; lp++) { switch(*lp) { case 9: case 10: case 11: case 12: case 13: case 32: /* WSP */ case 0x2f: /* '/' */ case 0x3e: /* '>' */ break; default: continue; } break; } if(lp == lstop) return NULL; /* No tag found */ lstop = lp; key.start = lstart; key.stop = lstop; key.vemap = specs->value2enum; key.evmap = specs->enum2value; el_found = (asn_INTEGER_enum_map_t *)bsearch(&key, specs->value2enum, count, sizeof(specs->value2enum[0]), INTEGER__compar_enum2value); if(el_found) { /* Remap enum2value into value2enum */ el_found = key.vemap + key.evmap[el_found - key.vemap]; } return el_found; } static int INTEGER__compar_value2enum(const void *kp, const void *am) { long a = *(const long *)kp; const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am; long b = el->nat_value; if(a < b) return -1; else if(a == b) return 0; else return 1; } const asn_INTEGER_enum_map_t * INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value) { int count = specs ? specs->map_count : 0; if(!count) return 0; return (asn_INTEGER_enum_map_t *)bsearch(&value, specs->value2enum, count, sizeof(specs->value2enum[0]), INTEGER__compar_value2enum); } static int INTEGER_st_prealloc(INTEGER_t *st, int min_size) { void *p = MALLOC(min_size + 1); if(p) { void *b = st->buf; st->size = 0; st->buf = p; FREEMEM(b); return 0; } else { return -1; } } /* * Decode the chunk of XML text encoding INTEGER. */ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) { INTEGER_t *st = (INTEGER_t *)sptr; long sign = 1; long value; const char *lp; const char *lstart = (const char *)chunk_buf; const char *lstop = lstart + chunk_size; enum { ST_SKIPSPACE, ST_SKIPSPHEX, ST_WAITDIGITS, ST_DIGITS, ST_HEXDIGIT1, ST_HEXDIGIT2, ST_HEXCOLON, ST_EXTRASTUFF } state = ST_SKIPSPACE; if(chunk_size) ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (long)chunk_size, *lstart, lstop[-1]); /* * We may have received a tag here. It will be processed inline. * Use strtoul()-like code and serialize the result. */ for(value = 0, lp = lstart; lp < lstop; lp++) { int lv = *lp; switch(lv) { case 0x09: case 0x0a: case 0x0d: case 0x20: switch(state) { case ST_SKIPSPACE: case ST_SKIPSPHEX: continue; case ST_HEXCOLON: if(xer_is_whitespace(lp, lstop - lp)) { lp = lstop - 1; continue; } break; default: break; } break; case 0x2d: /* '-' */ if(state == ST_SKIPSPACE) { sign = -1; state = ST_WAITDIGITS; continue; } break; case 0x2b: /* '+' */ if(state == ST_SKIPSPACE) { state = ST_WAITDIGITS; continue; } break; case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: switch(state) { case ST_DIGITS: break; case ST_SKIPSPHEX: /* Fall through */ case ST_HEXDIGIT1: value = (lv - 0x30) << 4; state = ST_HEXDIGIT2; continue; case ST_HEXDIGIT2: value += (lv - 0x30); state = ST_HEXCOLON; st->buf[st->size++] = (uint8_t)value; continue; case ST_HEXCOLON: return XPBD_BROKEN_ENCODING; default: state = ST_DIGITS; break; } { long new_value = value * 10; if(new_value / 10 != value) /* Overflow */ return XPBD_DECODER_LIMIT; value = new_value + (lv - 0x30); /* Check for two's complement overflow */ if(value < 0) { /* Check whether it is a LONG_MIN */ if(sign == -1 && (unsigned long)value == ~((unsigned long)-1 >> 1)) { sign = 1; } else { /* Overflow */ return XPBD_DECODER_LIMIT; } } } continue; case 0x3c: /* '<' */ if(state == ST_SKIPSPACE) { const asn_INTEGER_enum_map_t *el; el = INTEGER_map_enum2value( (asn_INTEGER_specifics_t *) td->specifics, lstart, lstop); if(el) { ASN_DEBUG("Found \"%s\" => %ld", el->enum_name, el->nat_value); state = ST_DIGITS; value = el->nat_value; lp = lstop - 1; continue; } ASN_DEBUG("Unknown identifier for INTEGER"); } return XPBD_BROKEN_ENCODING; case 0x3a: /* ':' */ if(state == ST_HEXCOLON) { /* This colon is expected */ state = ST_HEXDIGIT1; continue; } else if(state == ST_DIGITS) { /* The colon here means that we have * decoded the first two hexadecimal * places as a decimal value. * Switch decoding mode. */ ASN_DEBUG("INTEGER re-evaluate as hex form"); if(INTEGER_st_prealloc(st, (chunk_size/3) + 1)) return XPBD_SYSTEM_FAILURE; state = ST_SKIPSPHEX; lp = lstart - 1; continue; } else { ASN_DEBUG("state %d at %d", state, lp - lstart); break; } /* [A-Fa-f] */ case 0x41:case 0x42:case 0x43:case 0x44:case 0x45:case 0x46: case 0x61:case 0x62:case 0x63:case 0x64:case 0x65:case 0x66: switch(state) { case ST_SKIPSPHEX: case ST_SKIPSPACE: /* Fall through */ case ST_HEXDIGIT1: value = lv - ((lv < 0x61) ? 0x41 : 0x61); value += 10; value <<= 4; state = ST_HEXDIGIT2; continue; case ST_HEXDIGIT2: value += lv - ((lv < 0x61) ? 0x41 : 0x61); value += 10; st->buf[st->size++] = (uint8_t)value; state = ST_HEXCOLON; continue; case ST_DIGITS: ASN_DEBUG("INTEGER re-evaluate as hex form"); if(INTEGER_st_prealloc(st, (chunk_size/3) + 1)) return XPBD_SYSTEM_FAILURE; state = ST_SKIPSPHEX; lp = lstart - 1; continue; default: break; } break; } /* Found extra non-numeric stuff */ ASN_DEBUG("Found non-numeric 0x%2x at %d", lv, lp - lstart); state = ST_EXTRASTUFF; break; } switch(state) { case ST_DIGITS: /* Everything is cool */ break; case ST_HEXCOLON: st->buf[st->size] = 0; /* Just in case termination */ return XPBD_BODY_CONSUMED; case ST_HEXDIGIT1: case ST_HEXDIGIT2: case ST_SKIPSPHEX: return XPBD_BROKEN_ENCODING; default: if(xer_is_whitespace(lp, lstop - lp)) { if(state != ST_EXTRASTUFF) return XPBD_NOT_BODY_IGNORE; break; } else { ASN_DEBUG("INTEGER: No useful digits (state %d)", state); return XPBD_BROKEN_ENCODING; /* No digits */ } break; } value *= sign; /* Change sign, if needed */ if(asn_long2INTEGER(st, value)) return XPBD_SYSTEM_FAILURE; return XPBD_BODY_CONSUMED; } asn_dec_rval_t INTEGER_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return xer_decode_primitive(opt_codec_ctx, td, sptr, sizeof(INTEGER_t), opt_mname, buf_ptr, size, INTEGER__xer_body_decode); } asn_enc_rval_t INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { const INTEGER_t *st = (const INTEGER_t *)sptr; asn_enc_rval_t er; (void)ilevel; (void)flags; if(!st || !st->buf) _ASN_ENCODE_FAILED; er.encoded = INTEGER__dump(td, st, cb, app_key, 1); if(er.encoded < 0) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_dec_rval_t rval = { RC_OK, 0 }; INTEGER_t *st = (INTEGER_t *)*sptr; asn_per_constraint_t *ct; int repeat; (void)opt_codec_ctx; if(!st) { st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st))); if(!st) _ASN_DECODE_FAILED; } if(!constraints) constraints = td->per_constraints; ct = constraints ? &constraints->value : 0; if(ct && ct->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); if(inext < 0) _ASN_DECODE_STARVED; if(inext) ct = 0; } FREEMEM(st->buf); st->buf = 0; st->size = 0; if(ct) { if(ct->flags & APC_SEMI_CONSTRAINED) { st->buf = (uint8_t *)CALLOC(1, 2); if(!st->buf) _ASN_DECODE_FAILED; st->size = 1; } else if(ct->flags & APC_CONSTRAINED && ct->range_bits >= 0) { size_t size = (ct->range_bits + 7) >> 3; st->buf = (uint8_t *)MALLOC(1 + size + 1); if(!st->buf) _ASN_DECODE_FAILED; st->size = size; } } /* X.691, #12.2.2 */ if(ct && ct->flags != APC_UNCONSTRAINED) { /* #10.5.6 */ ASN_DEBUG("Integer with range %d bits", ct->range_bits); if(ct->range_bits >= 0) { long value; if(ct->range_bits == 32) { long lhalf; value = per_get_few_bits(pd, 16); if(value < 0) _ASN_DECODE_STARVED; lhalf = per_get_few_bits(pd, 16); if(lhalf < 0) _ASN_DECODE_STARVED; value = (value << 16) | lhalf; } else { value = per_get_few_bits(pd, ct->range_bits); if(value < 0) _ASN_DECODE_STARVED; } ASN_DEBUG("Got value %ld + low %ld", value, ct->lower_bound); value += ct->lower_bound; if((specs && specs->field_unsigned) ? asn_ulong2INTEGER(st, value) : asn_long2INTEGER(st, value)) _ASN_DECODE_FAILED; return rval; } } else { ASN_DEBUG("Decoding unconstrained integer %s", td->name); } /* X.691, #12.2.3, #12.2.4 */ do { ssize_t len; void *p; int ret; /* Get the PER length */ len = uper_get_length(pd, -1, &repeat); if(len < 0) _ASN_DECODE_STARVED; p = REALLOC(st->buf, st->size + len + 1); if(!p) _ASN_DECODE_FAILED; st->buf = (uint8_t *)p; ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len); if(ret < 0) _ASN_DECODE_STARVED; st->size += len; } while(repeat); st->buf[st->size] = 0; /* JIC */ /* #12.2.3 */ if(ct && ct->lower_bound) { /* * TODO: replace by in-place arithmetics. */ long value; if(asn_INTEGER2long(st, &value)) _ASN_DECODE_FAILED; if(asn_long2INTEGER(st, value + ct->lower_bound)) _ASN_DECODE_FAILED; } return rval; } asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_enc_rval_t er; INTEGER_t *st = (INTEGER_t *)sptr; const uint8_t *buf; const uint8_t *end; asn_per_constraint_t *ct; long value = 0; if(!st || st->size == 0) _ASN_ENCODE_FAILED; if(!constraints) constraints = td->per_constraints; ct = constraints ? &constraints->value : 0; er.encoded = 0; if(ct) { int inext = 0; if(specs && specs->field_unsigned) { unsigned long uval; if(asn_INTEGER2ulong(st, &uval)) _ASN_ENCODE_FAILED; /* Check proper range */ if(ct->flags & APC_SEMI_CONSTRAINED) { if(uval < (unsigned long)ct->lower_bound) inext = 1; } else if(ct->range_bits >= 0) { if(uval < (unsigned long)ct->lower_bound || uval > (unsigned long)ct->upper_bound) inext = 1; } ASN_DEBUG("Value %lu (%02x/%d) lb %lu ub %lu %s", uval, st->buf[0], st->size, ct->lower_bound, ct->upper_bound, inext ? "ext" : "fix"); value = uval; } else { if(asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED; /* Check proper range */ if(ct->flags & APC_SEMI_CONSTRAINED) { if(value < ct->lower_bound) inext = 1; } else if(ct->range_bits >= 0) { if(value < ct->lower_bound || value > ct->upper_bound) inext = 1; } ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", value, st->buf[0], st->size, ct->lower_bound, ct->upper_bound, inext ? "ext" : "fix"); } if(ct->flags & APC_EXTENSIBLE) { if(per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; if(inext) ct = 0; } else if(inext) { _ASN_ENCODE_FAILED; } } /* X.691, #12.2.2 */ if(ct && ct->range_bits >= 0) { /* #10.5.6 */ ASN_DEBUG("Encoding integer with range %d bits", ct->range_bits); if(ct->range_bits == 32) { /* TODO: extend to >32 bits */ long v = value - ct->lower_bound; if(per_put_few_bits(po, v >> 1, 31) || per_put_few_bits(po, v, 1)) _ASN_ENCODE_FAILED; } else { if(per_put_few_bits(po, value - ct->lower_bound, ct->range_bits)) _ASN_ENCODE_FAILED; } _ASN_ENCODED_OK(er); } if(ct && ct->lower_bound) { ASN_DEBUG("Adjust lower bound to %ld", ct->lower_bound); /* TODO: adjust lower bound */ _ASN_ENCODE_FAILED; } for(buf = st->buf, end = st->buf + st->size; buf < end;) { ssize_t mayEncode = uper_put_length(po, end - buf); if(mayEncode < 0) _ASN_ENCODE_FAILED; if(per_put_many_bits(po, buf, 8 * mayEncode)) _ASN_ENCODE_FAILED; buf += mayEncode; } _ASN_ENCODED_OK(er); } int asn_INTEGER2long(const INTEGER_t *iptr, long *lptr) { uint8_t *b, *end; size_t size; long l; /* Sanity checking */ if(!iptr || !iptr->buf || !lptr) { errno = EINVAL; return -1; } /* Cache the begin/end of the buffer */ b = iptr->buf; /* Start of the INTEGER buffer */ size = iptr->size; end = b + size; /* Where to stop */ if(size > sizeof(long)) { uint8_t *end1 = end - 1; /* * Slightly more advanced processing, * able to >sizeof(long) bytes, * when the actual value is small * (0x0000000000abcdef would yield a fine 0x00abcdef) */ /* Skip out the insignificant leading bytes */ for(; b < end1; b++) { switch(*b) { case 0x00: if((b[1] & 0x80) == 0) continue; break; case 0xff: if((b[1] & 0x80) != 0) continue; break; } break; } size = end - b; if(size > sizeof(long)) { /* Still cannot fit the long */ errno = ERANGE; return -1; } } /* Shortcut processing of a corner case */ if(end == b) { *lptr = 0; return 0; } /* Perform the sign initialization */ /* Actually l = -(*b >> 7); gains nothing, yet unreadable! */ if((*b >> 7)) l = -1; else l = 0; /* Conversion engine */ for(; b < end; b++) l = (l << 8) | *b; *lptr = l; return 0; } int asn_INTEGER2ulong(const INTEGER_t *iptr, unsigned long *lptr) { uint8_t *b, *end; unsigned long l; size_t size; if(!iptr || !iptr->buf || !lptr) { errno = EINVAL; return -1; } b = iptr->buf; size = iptr->size; end = b + size; /* If all extra leading bytes are zeroes, ignore them */ for(; size > sizeof(unsigned long); b++, size--) { if(*b) { /* Value won't fit unsigned long */ errno = ERANGE; return -1; } } /* Conversion engine */ for(l = 0; b < end; b++) l = (l << 8) | *b; *lptr = l; return 0; } int asn_ulong2INTEGER(INTEGER_t *st, unsigned long value) { uint8_t *buf; uint8_t *end; uint8_t *b; int shr; if(value <= LONG_MAX) return asn_long2INTEGER(st, value); buf = (uint8_t *)MALLOC(1 + sizeof(value)); if(!buf) return -1; end = buf + (sizeof(value) + 1); buf[0] = 0; for(b = buf + 1, shr = (sizeof(long)-1)*8; b < end; shr -= 8, b++) *b = (uint8_t)(value >> shr); if(st->buf) FREEMEM(st->buf); st->buf = buf; st->size = 1 + sizeof(value); return 0; } int asn_long2INTEGER(INTEGER_t *st, long value) { uint8_t *buf, *bp; uint8_t *p; uint8_t *pstart; uint8_t *pend1; int littleEndian = 1; /* Run-time detection */ int add; if(!st) { errno = EINVAL; return -1; } buf = (uint8_t *)MALLOC(sizeof(value)); if(!buf) return -1; if(*(char *)&littleEndian) { pstart = (uint8_t *)&value + sizeof(value) - 1; pend1 = (uint8_t *)&value; add = -1; } else { pstart = (uint8_t *)&value; pend1 = pstart + sizeof(value) - 1; add = 1; } /* * If the contents octet consists of more than one octet, * then bits of the first octet and bit 8 of the second octet: * a) shall not all be ones; and * b) shall not all be zero. */ for(p = pstart; p != pend1; p += add) { switch(*p) { case 0x00: if((*(p+add) & 0x80) == 0) continue; break; case 0xff: if((*(p+add) & 0x80)) continue; break; } break; } /* Copy the integer body */ for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p; if(st->buf) FREEMEM(st->buf); st->buf = buf; st->size = bp - buf; return 0; } biosig-2.3.3/biosig4c++/t240/DispResolution.h0000664000175000017500000000130014105434233020626 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DispResolution_H_ #define _DispResolution_H_ #include /* Including external dependencies */ #include #include #ifdef __cplusplus extern "C" { #endif /* DispResolution */ typedef struct DispResolution { INTEGER_t prepoint; INTEGER_t postpoint; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DispResolution_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DispResolution; #ifdef __cplusplus } #endif #endif /* _DispResolution_H_ */ biosig-2.3.3/biosig4c++/t240/ContentOrReference.c0000664000175000017500000000400014105434233021370 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ContentOrReference.h" static asn_TYPE_member_t asn_MBR_ContentOrReference_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ContentOrReference, choice.content), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "content" }, { ATF_NOFLAGS, 0, offsetof(struct ContentOrReference, choice.reference), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "reference" }, }; static asn_TYPE_tag2member_t asn_MAP_ContentOrReference_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* content at 718 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* reference at 720 */ }; static asn_CHOICE_specifics_t asn_SPC_ContentOrReference_specs_1 = { sizeof(struct ContentOrReference), offsetof(struct ContentOrReference, _asn_ctx), offsetof(struct ContentOrReference, present), sizeof(((struct ContentOrReference *)0)->present), asn_MAP_ContentOrReference_tag2el_1, 2, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ContentOrReference = { "ContentOrReference", "ContentOrReference", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_ContentOrReference_1, 2, /* Elements count */ &asn_SPC_ContentOrReference_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SaCalDataType.h0000664000175000017500000000166314105434233020276 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaCalDataType_H_ #define _SaCalDataType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum SaCalDataType { SaCalDataType_bar = 0, SaCalDataType_stair = 1 } e_SaCalDataType; /* SaCalDataType */ typedef INTEGER_t SaCalDataType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaCalDataType; asn_struct_free_f SaCalDataType_free; asn_struct_print_f SaCalDataType_print; asn_constr_check_f SaCalDataType_constraint; ber_type_decoder_f SaCalDataType_decode_ber; der_type_encoder_f SaCalDataType_encode_der; xer_type_decoder_f SaCalDataType_decode_xer; xer_type_encoder_f SaCalDataType_encode_xer; #ifdef __cplusplus } #endif #endif /* _SaCalDataType_H_ */ biosig-2.3.3/biosig4c++/t240/EnumVal.h0000664000175000017500000000235614105434233017226 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumVal_H_ #define _EnumVal_H_ #include /* Including external dependencies */ #include "EnumObject.h" #include "FEFString.h" #include "ExtNomenRef.h" #include #include "EnumRecordMetric.h" #include "EnumRecordOO.h" #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum EnumVal_PR { EnumVal_PR_NOTHING, /* No components present */ EnumVal_PR_enum_obj_id, EnumVal_PR_enum_text_string, EnumVal_PR_enum_external_code, EnumVal_PR_enum_bit_str, EnumVal_PR_enum_record, EnumVal_PR_enum_record_oo } EnumVal_PR; /* EnumVal */ typedef struct EnumVal { EnumVal_PR present; union EnumVal_u { EnumObject_t enum_obj_id; FEFString_t enum_text_string; ExtNomenRef_t enum_external_code; BIT_STRING_t enum_bit_str; EnumRecordMetric_t enum_record; EnumRecordOO_t enum_record_oo; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumVal_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumVal; #ifdef __cplusplus } #endif #endif /* _EnumVal_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I32.h0000664000175000017500000000136114105434233016637 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_I32_H_ #define _INT_I32_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-I32 */ typedef long INT_I32_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_I32; asn_struct_free_f INT_I32_free; asn_struct_print_f INT_I32_print; asn_constr_check_f INT_I32_constraint; ber_type_decoder_f INT_I32_decode_ber; der_type_encoder_f INT_I32_encode_der; xer_type_decoder_f INT_I32_decode_xer; xer_type_encoder_f INT_I32_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_I32_H_ */ biosig-2.3.3/biosig4c++/t240/SaFilterEntry.c0000664000175000017500000000502714105434233020403 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaFilterEntry.h" static asn_TYPE_member_t asn_MBR_SaFilterEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SaFilterEntry, filtertype), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FilterType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filtertype" }, { ATF_NOFLAGS, 0, offsetof(struct SaFilterEntry, frequency), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "frequency" }, { ATF_NOFLAGS, 0, offsetof(struct SaFilterEntry, filterorder), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filterorder" }, }; static ber_tlv_tag_t asn_DEF_SaFilterEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SaFilterEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* filtertype at 1046 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* frequency at 1047 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 } /* filterorder at 1049 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SaFilterEntry_specs_1 = { sizeof(struct SaFilterEntry), offsetof(struct SaFilterEntry, _asn_ctx), asn_MAP_SaFilterEntry_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SaFilterEntry = { "SaFilterEntry", "SaFilterEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaFilterEntry_tags_1, sizeof(asn_DEF_SaFilterEntry_tags_1) /sizeof(asn_DEF_SaFilterEntry_tags_1[0]), /* 1 */ asn_DEF_SaFilterEntry_tags_1, /* Same as above */ sizeof(asn_DEF_SaFilterEntry_tags_1) /sizeof(asn_DEF_SaFilterEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SaFilterEntry_1, 3, /* Elements count */ &asn_SPC_SaFilterEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificSection.h0000664000175000017500000000272714105434233023310 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ManufacturerSpecificSection_H_ #define _ManufacturerSpecificSection_H_ #include /* Including external dependencies */ #include "ManufacturerID.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ManufacturerSpecificEncoded; struct ManufacturerSpecificBinary; /* ManufacturerSpecificSection */ typedef struct ManufacturerSpecificSection { ManufacturerID_t manufacturerid; struct ManufacturerSpecificSection__encodedentries { A_SEQUENCE_OF(struct ManufacturerSpecificEncoded) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *encodedentries; struct ManufacturerSpecificSection__binaryentries { A_SEQUENCE_OF(struct ManufacturerSpecificBinary) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *binaryentries; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ManufacturerSpecificSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ManufacturerSpecificEncoded.h" #include "ManufacturerSpecificBinary.h" #endif /* _ManufacturerSpecificSection_H_ */ biosig-2.3.3/biosig4c++/t240/NumericMeasuredDataSection.c0000664000175000017500000000560014105434233023054 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "NumericMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_NumericMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct NumericMeasuredDataSection, metricref), (ASN_TAG_CLASS_APPLICATION | (6050 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricref" }, { ATF_NOFLAGS, 0, offsetof(struct NumericMeasuredDataSection, nuobservedvalue), -1 /* Ambiguous tag (CHOICE?) */, 0, &asn_DEF_ChoiceOfNuObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nuobservedvalue" }, { ATF_NOFLAGS, 0, offsetof(struct NumericMeasuredDataSection, timestamp), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ObservationTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timestamp" }, }; static ber_tlv_tag_t asn_DEF_NumericMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_NumericMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, 0, 0 }, /* timestamp at 1286 */ { (ASN_TAG_CLASS_APPLICATION | (2379 << 2)), 1, 0, 0 }, /* compoundnuobservedvalue at 1297 */ { (ASN_TAG_CLASS_APPLICATION | (2384 << 2)), 1, 0, 0 }, /* nuobservedvalue at 1289 */ { (ASN_TAG_CLASS_APPLICATION | (6050 << 2)), 0, 0, 0 } /* metricref at 1280 */ }; static asn_SEQUENCE_specifics_t asn_SPC_NumericMeasuredDataSection_specs_1 = { sizeof(struct NumericMeasuredDataSection), offsetof(struct NumericMeasuredDataSection, _asn_ctx), asn_MAP_NumericMeasuredDataSection_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_NumericMeasuredDataSection = { "NumericMeasuredDataSection", "NumericMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_NumericMeasuredDataSection_tags_1, sizeof(asn_DEF_NumericMeasuredDataSection_tags_1) /sizeof(asn_DEF_NumericMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_NumericMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_NumericMeasuredDataSection_tags_1) /sizeof(asn_DEF_NumericMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_NumericMeasuredDataSection_1, 3, /* Elements count */ &asn_SPC_NumericMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/AlertCode.h0000664000175000017500000000141214105434233017511 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertCode_H_ #define _AlertCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* AlertCode */ typedef INTEGER_t AlertCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertCode; asn_struct_free_f AlertCode_free; asn_struct_print_f AlertCode_print; asn_constr_check_f AlertCode_constraint; ber_type_decoder_f AlertCode_decode_ber; der_type_encoder_f AlertCode_encode_der; xer_type_decoder_f AlertCode_decode_xer; xer_type_encoder_f AlertCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _AlertCode_H_ */ biosig-2.3.3/biosig4c++/t240/SessionPhaseSection.h0000664000175000017500000000244714105434233021611 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SessionPhaseSection_H_ #define _SessionPhaseSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "AbsoluteTime.h" #include "Placeholder.h" #include "DescriptiveDataSection.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct MeasuredDataSection; /* SessionPhaseSection */ typedef struct SessionPhaseSection { Handle_t handle; AbsoluteTime_t starttime; AbsoluteTime_t stoptime; Placeholder_t *placeholder /* OPTIONAL */; DescriptiveDataSection_t descriptivedata; struct SessionPhaseSection__measureddata { A_SEQUENCE_OF(struct MeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } measureddata; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SessionPhaseSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SessionPhaseSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "MeasuredDataSection.h" #endif /* _SessionPhaseSection_H_ */ biosig-2.3.3/biosig4c++/t240/SaSignalFrequency.c0000664000175000017500000000440214105434233021227 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaSignalFrequency.h" static asn_TYPE_member_t asn_MBR_SaSignalFrequency_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SaSignalFrequency, lowedgefreq), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "lowedgefreq" }, { ATF_NOFLAGS, 0, offsetof(struct SaSignalFrequency, highedgefreq), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "highedgefreq" }, }; static ber_tlv_tag_t asn_DEF_SaSignalFrequency_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SaSignalFrequency_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* lowedgefreq at 1079 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* highedgefreq at 1081 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SaSignalFrequency_specs_1 = { sizeof(struct SaSignalFrequency), offsetof(struct SaSignalFrequency, _asn_ctx), asn_MAP_SaSignalFrequency_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SaSignalFrequency = { "SaSignalFrequency", "SaSignalFrequency", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaSignalFrequency_tags_1, sizeof(asn_DEF_SaSignalFrequency_tags_1) /sizeof(asn_DEF_SaSignalFrequency_tags_1[0]), /* 1 */ asn_DEF_SaSignalFrequency_tags_1, /* Same as above */ sizeof(asn_DEF_SaSignalFrequency_tags_1) /sizeof(asn_DEF_SaSignalFrequency_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SaSignalFrequency_1, 2, /* Elements count */ &asn_SPC_SaSignalFrequency_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PowerStatus.c0000664000175000017500000000722714105434233020154 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PowerStatus.h" int PowerStatus_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void PowerStatus_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void PowerStatus_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { PowerStatus_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int PowerStatus_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { PowerStatus_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t PowerStatus_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { PowerStatus_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t PowerStatus_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { PowerStatus_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t PowerStatus_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { PowerStatus_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t PowerStatus_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { PowerStatus_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_PowerStatus_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_PowerStatus = { "PowerStatus", "PowerStatus", PowerStatus_free, PowerStatus_print, PowerStatus_constraint, PowerStatus_decode_ber, PowerStatus_encode_der, PowerStatus_decode_xer, PowerStatus_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PowerStatus_tags_1, sizeof(asn_DEF_PowerStatus_tags_1) /sizeof(asn_DEF_PowerStatus_tags_1[0]), /* 1 */ asn_DEF_PowerStatus_tags_1, /* Same as above */ sizeof(asn_DEF_PowerStatus_tags_1) /sizeof(asn_DEF_PowerStatus_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/per_support.h0000664000175000017500000000754114105434233020242 0ustar schloeglschloegl/* * Copyright (c) 2005, 2006, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _PER_SUPPORT_H_ #define _PER_SUPPORT_H_ #include /* Platform-specific types */ #ifdef __cplusplus extern "C" { #endif /* * Pre-computed PER constraints. */ typedef struct asn_per_constraint_s { enum asn_per_constraint_flags { APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */ APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */ APC_CONSTRAINED = 0x2, /* Fully constrained */ APC_EXTENSIBLE = 0x4 /* May have extension */ } flags; int range_bits; /* Full number of bits in the range */ int effective_bits; /* Effective bits */ long lower_bound; /* "lb" value */ long upper_bound; /* "ub" value */ } asn_per_constraint_t; typedef struct asn_per_constraints_s { asn_per_constraint_t value; asn_per_constraint_t size; int (*value2code)(unsigned int value); int (*code2value)(unsigned int code); } asn_per_constraints_t; /* * This structure describes a position inside an incoming PER bit stream. */ typedef struct asn_per_data_s { const uint8_t *buffer; /* Pointer to the octet stream */ size_t nboff; /* Bit offset to the meaningful bit */ size_t nbits; /* Number of bits in the stream */ size_t moved; /* Number of bits moved through this bit stream */ int (*refill)(struct asn_per_data_s *); void *refill_key; } asn_per_data_t; /* * Extract a small number of bits (<= 31) from the specified PER data pointer. * This function returns -1 if the specified number of bits could not be * extracted due to EOD or other conditions. */ int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits); /* Undo the immediately preceeding "get_few_bits" operation */ void per_get_undo(asn_per_data_t *per_data, int get_nbits); /* * Extract a large number of bits from the specified PER data pointer. * This function returns -1 if the specified number of bits could not be * extracted due to EOD or other conditions. */ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align, int get_nbits); /* * Get the length "n" from the Unaligned PER stream. */ ssize_t uper_get_length(asn_per_data_t *pd, int effective_bound_bits, int *repeat); /* * Get the normally small length "n". */ ssize_t uper_get_nslength(asn_per_data_t *pd); /* * Get the normally small non-negative whole number. */ ssize_t uper_get_nsnnwn(asn_per_data_t *pd); /* Non-thread-safe debugging function, don't use it */ char *per_data_string(asn_per_data_t *pd); /* * This structure supports forming PER output. */ typedef struct asn_per_outp_s { uint8_t *buffer; /* Pointer into the (tmpspace) */ size_t nboff; /* Bit offset to the meaningful bit */ size_t nbits; /* Number of bits left in (tmpspace) */ uint8_t tmpspace[32]; /* Preliminary storage to hold data */ int (*outper)(const void *data, size_t size, void *op_key); void *op_key; /* Key for (outper) data callback */ size_t flushed_bytes; /* Bytes already flushed through (outper) */ } asn_per_outp_t; /* Output a small number of bits (<= 31) */ int per_put_few_bits(asn_per_outp_t *per_data, uint32_t bits, int obits); /* Output a large number of bits */ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits); /* * Put the length "n" to the Unaligned PER stream. * This function returns the number of units which may be flushed * in the next units saving iteration. */ ssize_t uper_put_length(asn_per_outp_t *po, size_t whole_length); /* * Put the normally small length "n" to the Unaligned PER stream. * Returns 0 or -1. */ int uper_put_nslength(asn_per_outp_t *po, size_t length); /* * Put the normally small non-negative whole number. */ int uper_put_nsnnwn(asn_per_outp_t *po, int n); #ifdef __cplusplus } #endif #endif /* _PER_SUPPORT_H_ */ biosig-2.3.3/biosig4c++/t240/DeviceCode.h0000664000175000017500000000142714105434233017647 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DeviceCode_H_ #define _DeviceCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* DeviceCode */ typedef INTEGER_t DeviceCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DeviceCode; asn_struct_free_f DeviceCode_free; asn_struct_print_f DeviceCode_print; asn_constr_check_f DeviceCode_constraint; ber_type_decoder_f DeviceCode_decode_ber; der_type_encoder_f DeviceCode_encode_der; xer_type_decoder_f DeviceCode_decode_xer; xer_type_encoder_f DeviceCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _DeviceCode_H_ */ biosig-2.3.3/biosig4c++/t240/ArchiveProtection.c0000664000175000017500000000441214105434233021275 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ArchiveProtection.h" static asn_TYPE_member_t asn_MBR_ArchiveProtection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ArchiveProtection, protectiontype), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "protectiontype" }, { ATF_NOFLAGS, 0, offsetof(struct ArchiveProtection, protectionkey), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "protectionkey" }, }; static ber_tlv_tag_t asn_DEF_ArchiveProtection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ArchiveProtection_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* protectiontype at 250 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* protectionkey at 251 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ArchiveProtection_specs_1 = { sizeof(struct ArchiveProtection), offsetof(struct ArchiveProtection, _asn_ctx), asn_MAP_ArchiveProtection_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ArchiveProtection = { "ArchiveProtection", "ArchiveProtection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ArchiveProtection_tags_1, sizeof(asn_DEF_ArchiveProtection_tags_1) /sizeof(asn_DEF_ArchiveProtection_tags_1[0]), /* 1 */ asn_DEF_ArchiveProtection_tags_1, /* Same as above */ sizeof(asn_DEF_ArchiveProtection_tags_1) /sizeof(asn_DEF_ArchiveProtection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ArchiveProtection_1, 2, /* Elements count */ &asn_SPC_ArchiveProtection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ScaleRangeSpec.c0000664000175000017500000000576214105434233020475 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ScaleRangeSpec.h" static asn_TYPE_member_t asn_MBR_ScaleRangeSpec_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ScaleRangeSpec, lowerabsolutevalue), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "lowerabsolutevalue" }, { ATF_NOFLAGS, 0, offsetof(struct ScaleRangeSpec, upperabsolutevalue), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "upperabsolutevalue" }, { ATF_NOFLAGS, 0, offsetof(struct ScaleRangeSpec, lowervaluescaled), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "lowervaluescaled" }, { ATF_NOFLAGS, 0, offsetof(struct ScaleRangeSpec, uppervaluescaled), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "uppervaluescaled" }, }; static ber_tlv_tag_t asn_DEF_ScaleRangeSpec_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ScaleRangeSpec_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* lowerabsolutevalue at 1040 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* upperabsolutevalue at 1041 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* lowervaluescaled at 1042 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 } /* uppervaluescaled at 1044 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ScaleRangeSpec_specs_1 = { sizeof(struct ScaleRangeSpec), offsetof(struct ScaleRangeSpec, _asn_ctx), asn_MAP_ScaleRangeSpec_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ScaleRangeSpec = { "ScaleRangeSpec", "ScaleRangeSpec", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ScaleRangeSpec_tags_1, sizeof(asn_DEF_ScaleRangeSpec_tags_1) /sizeof(asn_DEF_ScaleRangeSpec_tags_1[0]), /* 1 */ asn_DEF_ScaleRangeSpec_tags_1, /* Same as above */ sizeof(asn_DEF_ScaleRangeSpec_tags_1) /sizeof(asn_DEF_ScaleRangeSpec_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ScaleRangeSpec_1, 4, /* Elements count */ &asn_SPC_ScaleRangeSpec_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/xer_decoder.h0000664000175000017500000000641014105434233020135 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _XER_DECODER_H_ #define _XER_DECODER_H_ #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * The XER decoder of any ASN.1 type. May be invoked by the application. */ asn_dec_rval_t xer_decode(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size /* Size of data buffer */ ); /* * Type of the type-specific XER decoder function. */ typedef asn_dec_rval_t (xer_type_decoder_f)(asn_codec_ctx_t *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, const char *opt_mname, /* Member name */ const void *buf_ptr, size_t size ); /******************************* * INTERNALLY USEFUL FUNCTIONS * *******************************/ /* * Generalized function for decoding the primitive values. * Used by more specialized functions, such as OCTET_STRING_decode_xer_utf8 * and others. This function should not be used by applications, as its API * is subject to changes. */ asn_dec_rval_t xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx, /* Type decoder context */ void *struct_key, /* Treated as opaque pointer */ const char *xml_tag, /* Expected XML tag name */ const void *buf_ptr, size_t size, int (*opt_unexpected_tag_decoder) (void *struct_key, const void *chunk_buf, size_t chunk_size), ssize_t (*body_receiver) (void *struct_key, const void *chunk_buf, size_t chunk_size, int have_more) ); /* * Fetch the next XER (XML) token from the stream. * The function returns the number of bytes occupied by the chunk type, * returned in the _ch_type. The _ch_type is only set (and valid) when * the return value is greater than 0. */ typedef enum pxer_chunk_type { PXER_TAG, /* Complete XER tag */ PXER_TEXT, /* Plain text between XER tags */ PXER_COMMENT /* A comment, may be part of */ } pxer_chunk_type_e; ssize_t xer_next_token(int *stateContext, const void *buffer, size_t size, pxer_chunk_type_e *_ch_type); /* * This function checks the buffer against the tag name is expected to occur. */ typedef enum xer_check_tag { XCT_BROKEN = 0, /* The tag is broken */ XCT_OPENING = 1, /* This is the tag */ XCT_CLOSING = 2, /* This is the tag */ XCT_BOTH = 3, /* This is the tag */ XCT__UNK__MASK = 4, /* Mask of everything unexpected */ XCT_UNKNOWN_OP = 5, /* Unexpected tag */ XCT_UNKNOWN_CL = 6, /* Unexpected tag */ XCT_UNKNOWN_BO = 7 /* Unexpected tag */ } xer_check_tag_e; xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, const char *need_tag); /* * Check whether this buffer consists of entirely XER whitespace characters. * RETURN VALUES: * 1: Whitespace or empty string * 0: Non-whitespace */ int xer_is_whitespace(const void *chunk_buf, size_t chunk_size); /* * Skip the series of anticipated extensions. */ int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth); #ifdef __cplusplus } #endif #endif /* _XER_DECODER_H_ */ biosig-2.3.3/biosig4c++/t240/MetricsCode.h0000664000175000017500000000144414105434233020055 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricsCode_H_ #define _MetricsCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* MetricsCode */ typedef INTEGER_t MetricsCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricsCode; asn_struct_free_f MetricsCode_free; asn_struct_print_f MetricsCode_print; asn_constr_check_f MetricsCode_constraint; ber_type_decoder_f MetricsCode_decode_ber; der_type_encoder_f MetricsCode_encode_der; xer_type_decoder_f MetricsCode_decode_xer; xer_type_encoder_f MetricsCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _MetricsCode_H_ */ biosig-2.3.3/biosig4c++/t240/ber_decoder.h0000664000175000017500000000377714105434233020124 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _BER_DECODER_H_ #define _BER_DECODER_H_ #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ struct asn_codec_ctx_s; /* Forward declaration */ /* * The BER decoder of any type. * This function may be invoked directly from the application. * The der_encode() function (der_encoder.h) is an opposite to ber_decode(). */ asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, /* Pointer to a target structure's pointer */ const void *buffer, /* Data to be decoded */ size_t size /* Size of that buffer */ ); /* * Type of generic function which decodes the byte stream into the structure. */ typedef asn_dec_rval_t (ber_type_decoder_f)( struct asn_codec_ctx_s *opt_codec_ctx, struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, const void *buf_ptr, size_t size, int tag_mode); /******************************* * INTERNALLY USEFUL FUNCTIONS * *******************************/ /* * Check that all tags correspond to the type definition (as given in head). * On return, last_length would contain either a non-negative length of the * value part of the last TLV, or the negative number of expected * "end of content" sequences. The number may only be negative if the * head->last_tag_form is non-zero. */ asn_dec_rval_t ber_check_tags( struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */ struct asn_TYPE_descriptor_s *type_descriptor, asn_struct_ctx_t *opt_ctx, /* saved decoding context */ const void *ptr, size_t size, int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ int last_tag_form, /* {-1,0:1}: any, primitive, constr */ ber_tlv_len_t *last_length, int *opt_tlv_form /* optional tag form */ ); #ifdef __cplusplus } #endif #endif /* _BER_DECODER_H_ */ biosig-2.3.3/biosig4c++/t240/RealTimeSampleArrayDescriptiveDataSection.h0000664000175000017500000001201314105434233026032 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _RealTimeSampleArrayDescriptiveDataSection_H_ #define _RealTimeSampleArrayDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include "SaSpec.h" #include "ScaleRangeSpec.h" #include "FEFFloat.h" #include "Fraction.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct AbsoluteRange; struct SaSignalFrequency; struct MetricCalEntry; struct SaGridEntry; struct SaCalData; struct SaFilterEntry; /* RealTimeSampleArrayDescriptiveDataSection */ typedef struct RealTimeSampleArrayDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct RealTimeSampleArrayDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct RealTimeSampleArrayDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct RealTimeSampleArrayDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct RealTimeSampleArrayDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct RealTimeSampleArrayDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; SaSpec_t saspecification; PrivateCode_t *compression /* OPTIONAL */; ScaleRangeSpec_t scaleandrangespec; struct AbsoluteRange *saphysiologicalrange /* OPTIONAL */; struct RealTimeSampleArrayDescriptiveDataSection__visualgrid { A_SEQUENCE_OF(struct SaGridEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *visualgrid; struct RealTimeSampleArrayDescriptiveDataSection__sacalibrationdata { A_SEQUENCE_OF(struct SaCalData) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *sacalibrationdata; struct RealTimeSampleArrayDescriptiveDataSection__filterspecification { A_SEQUENCE_OF(struct SaFilterEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *filterspecification; struct SaSignalFrequency *sasignalfrequency /* OPTIONAL */; FEFFloat_t *sameasureresolution /* OPTIONAL */; Fraction_t sampleperiod; struct MetricMeasure *sweepspeed /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } RealTimeSampleArrayDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_RealTimeSampleArrayDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "AbsoluteRange.h" #include "SaSignalFrequency.h" #include "MetricCalEntry.h" #include "SaGridEntry.h" #include "SaCalData.h" #include "SaFilterEntry.h" #endif /* _RealTimeSampleArrayDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/SystemSpecEntry.c0000664000175000017500000000435714105434233020776 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SystemSpecEntry.h" static asn_TYPE_member_t asn_MBR_SystemSpecEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SystemSpecEntry, component_capab_id), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "component-capab-id" }, { ATF_NOFLAGS, 0, offsetof(struct SystemSpecEntry, component_spec), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "component-spec" }, }; static ber_tlv_tag_t asn_DEF_SystemSpecEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SystemSpecEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* component-capab-id at 560 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* component-spec at 561 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SystemSpecEntry_specs_1 = { sizeof(struct SystemSpecEntry), offsetof(struct SystemSpecEntry, _asn_ctx), asn_MAP_SystemSpecEntry_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SystemSpecEntry = { "SystemSpecEntry", "SystemSpecEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SystemSpecEntry_tags_1, sizeof(asn_DEF_SystemSpecEntry_tags_1) /sizeof(asn_DEF_SystemSpecEntry_tags_1[0]), /* 1 */ asn_DEF_SystemSpecEntry_tags_1, /* Same as above */ sizeof(asn_DEF_SystemSpecEntry_tags_1) /sizeof(asn_DEF_SystemSpecEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SystemSpecEntry_1, 2, /* Elements count */ &asn_SPC_SystemSpecEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ChoiceOfEnumTimeStamp.h0000664000175000017500000000362614105434233022010 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ChoiceOfEnumTimeStamp_H_ #define _ChoiceOfEnumTimeStamp_H_ #include /* Including external dependencies */ #include "ObservationTime.h" #include "AbsoluteTime.h" #include #include #include "RelativeTime.h" #include "HighResRelativeTime.h" #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ChoiceOfEnumTimeStamp_PR { ChoiceOfEnumTimeStamp_PR_NOTHING, /* No components present */ ChoiceOfEnumTimeStamp_PR_timestamp, ChoiceOfEnumTimeStamp_PR_absolutetimestamparray, ChoiceOfEnumTimeStamp_PR_relativetimestamparray, ChoiceOfEnumTimeStamp_PR_hirestimestamparray } ChoiceOfEnumTimeStamp_PR; /* ChoiceOfEnumTimeStamp */ typedef struct ChoiceOfEnumTimeStamp { ChoiceOfEnumTimeStamp_PR present; union ChoiceOfEnumTimeStamp_u { ObservationTime_t timestamp; struct ChoiceOfEnumTimeStamp__absolutetimestamparray { A_SEQUENCE_OF(AbsoluteTime_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } absolutetimestamparray; struct ChoiceOfEnumTimeStamp__relativetimestamparray { A_SEQUENCE_OF(RelativeTime_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } relativetimestamparray; struct ChoiceOfEnumTimeStamp__hirestimestamparray { A_SEQUENCE_OF(HighResRelativeTime_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } hirestimestamparray; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ChoiceOfEnumTimeStamp_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ChoiceOfEnumTimeStamp; #ifdef __cplusplus } #endif #endif /* _ChoiceOfEnumTimeStamp_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCalState.c0000664000175000017500000000731514105434233020516 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricCalState.h" int MetricCalState_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void MetricCalState_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void MetricCalState_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MetricCalState_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MetricCalState_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalState_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MetricCalState_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MetricCalState_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MetricCalState_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalState_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MetricCalState_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MetricCalState_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MetricCalState_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalState_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MetricCalState_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MetricCalState = { "MetricCalState", "MetricCalState", MetricCalState_free, MetricCalState_print, MetricCalState_constraint, MetricCalState_decode_ber, MetricCalState_encode_der, MetricCalState_decode_xer, MetricCalState_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricCalState_tags_1, sizeof(asn_DEF_MetricCalState_tags_1) /sizeof(asn_DEF_MetricCalState_tags_1[0]), /* 1 */ asn_DEF_MetricCalState_tags_1, /* Same as above */ sizeof(asn_DEF_MetricCalState_tags_1) /sizeof(asn_DEF_MetricCalState_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/AlertCondition.c0000664000175000017500000001000414105434233020555 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertCondition.h" static asn_TYPE_member_t asn_MBR_AlertCondition_1[] = { { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, objreference), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "objreference" }, { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, controls), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertControls, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "controls" }, { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, alertflags), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertFlags, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alertflags" }, { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, alertsource), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alertsource" }, { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, alertcode), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alertcode" }, { ATF_NOFLAGS, 0, offsetof(struct AlertCondition, alerttype), (ASN_TAG_CLASS_CONTEXT | (6 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alerttype" }, { ATF_POINTER, 1, offsetof(struct AlertCondition, alertinfoid), (ASN_TAG_CLASS_CONTEXT | (7 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alertinfoid" }, }; static ber_tlv_tag_t asn_DEF_AlertCondition_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_AlertCondition_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* objreference at 1401 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* controls at 1402 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* alertflags at 1403 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 }, /* alertsource at 1404 */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 4, 0, 0 }, /* alertcode at 1405 */ { (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 5, 0, 0 }, /* alerttype at 1406 */ { (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 6, 0, 0 } /* alertinfoid at 1407 */ }; static asn_SEQUENCE_specifics_t asn_SPC_AlertCondition_specs_1 = { sizeof(struct AlertCondition), offsetof(struct AlertCondition, _asn_ctx), asn_MAP_AlertCondition_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_AlertCondition = { "AlertCondition", "AlertCondition", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertCondition_tags_1, sizeof(asn_DEF_AlertCondition_tags_1) /sizeof(asn_DEF_AlertCondition_tags_1[0]), /* 1 */ asn_DEF_AlertCondition_tags_1, /* Same as above */ sizeof(asn_DEF_AlertCondition_tags_1) /sizeof(asn_DEF_AlertCondition_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_AlertCondition_1, 7, /* Elements count */ &asn_SPC_AlertCondition_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/MetricDescriptiveDataSection.c0000664000175000017500000005626314105434233023424 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct MetricDescriptiveDataSection__vmosourcelist), offsetof(struct MetricDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct MetricDescriptiveDataSection__metricsourcelist), offsetof(struct MetricDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct MetricDescriptiveDataSection__msmtsitelist), offsetof(struct MetricDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct MetricDescriptiveDataSection__msmtsitelistext), offsetof(struct MetricDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct MetricDescriptiveDataSection__bodysitelist), offsetof(struct MetricDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct MetricDescriptiveDataSection__bodysitelistext), offsetof(struct MetricDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct MetricDescriptiveDataSection__metriccalibration), offsetof(struct MetricDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_MetricDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MetricDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct MetricDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct MetricDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 24, offsetof(struct MetricDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 23, offsetof(struct MetricDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 22, offsetof(struct MetricDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 21, offsetof(struct MetricDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 20, offsetof(struct MetricDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 19, offsetof(struct MetricDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 18, offsetof(struct MetricDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 17, offsetof(struct MetricDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 16, offsetof(struct MetricDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 15, offsetof(struct MetricDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 14, offsetof(struct MetricDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 13, offsetof(struct MetricDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 12, offsetof(struct MetricDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 11, offsetof(struct MetricDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 10, offsetof(struct MetricDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 9, offsetof(struct MetricDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 8, offsetof(struct MetricDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 7, offsetof(struct MetricDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 6, offsetof(struct MetricDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 5, offsetof(struct MetricDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 4, offsetof(struct MetricDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 3, offsetof(struct MetricDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 2, offsetof(struct MetricDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 1, offsetof(struct MetricDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, }; static ber_tlv_tag_t asn_DEF_MetricDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MetricDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MetricDescriptiveDataSection_specs_1 = { sizeof(struct MetricDescriptiveDataSection), offsetof(struct MetricDescriptiveDataSection, _asn_ctx), asn_MAP_MetricDescriptiveDataSection_tag2el_1, 27, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MetricDescriptiveDataSection = { "MetricDescriptiveDataSection", "MetricDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricDescriptiveDataSection_tags_1, sizeof(asn_DEF_MetricDescriptiveDataSection_tags_1) /sizeof(asn_DEF_MetricDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_MetricDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_MetricDescriptiveDataSection_tags_1) /sizeof(asn_DEF_MetricDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MetricDescriptiveDataSection_1, 27, /* Elements count */ &asn_SPC_MetricDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ProdSpecEntry.h0000664000175000017500000000143614105434233020416 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ProdSpecEntry_H_ #define _ProdSpecEntry_H_ #include /* Including external dependencies */ #include "ProdSpecEntryType.h" #include "PrivateCode.h" #include "FEFString.h" #include #ifdef __cplusplus extern "C" { #endif /* ProdSpecEntry */ typedef struct ProdSpecEntry { ProdSpecEntryType_t spec_type; PrivateCode_t component_id; FEFString_t prod_spec; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ProdSpecEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ProdSpecEntry; #ifdef __cplusplus } #endif #endif /* _ProdSpecEntry_H_ */ biosig-2.3.3/biosig4c++/t240/EnumRecordOO.h0000664000175000017500000000131314105434233020150 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumRecordOO_H_ #define _EnumRecordOO_H_ #include /* Including external dependencies */ #include "OID-Type.h" #include #include #ifdef __cplusplus extern "C" { #endif /* EnumRecordOO */ typedef struct EnumRecordOO { OID_Type_t record_type_code; ANY_t record_data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumRecordOO_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumRecordOO; #ifdef __cplusplus } #endif #endif /* _EnumRecordOO_H_ */ biosig-2.3.3/biosig4c++/t240/constr_SEQUENCE_OF.c0000664000175000017500000001240514105434233021032 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * The DER encoder of the SEQUENCE OF type. */ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_TYPE_member_t *elm = td->elements; asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(ptr); size_t computed_size = 0; ssize_t encoding_size = 0; asn_enc_rval_t erval; int edx; ASN_DEBUG("Estimating size of SEQUENCE OF %s", td->name); /* * Gather the length of the underlying members sequence. */ for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; if(!memb_ptr) continue; erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0); if(erval.encoded == -1) return erval; computed_size += erval.encoded; } /* * Encode the TLV for the sequence itself. */ encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); if(encoding_size == -1) { erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; return erval; } computed_size += encoding_size; if(!cb) { erval.encoded = computed_size; _ASN_ENCODED_OK(erval); } ASN_DEBUG("Encoding members of SEQUENCE OF %s", td->name); /* * Encode all members. */ for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; if(!memb_ptr) continue; erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb, app_key); if(erval.encoded == -1) return erval; encoding_size += erval.encoded; } if(computed_size != (size_t)encoding_size) { /* * Encoded size is not equal to the computed size. */ erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; } else { erval.encoded = computed_size; erval.structure_ptr = 0; erval.failed_type = 0; } return erval; } asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er; asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *elm = td->elements; asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr); const char *mname = specs->as_XMLValueList ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); unsigned int mlen = mname ? strlen(mname) : 0; int xcan = (flags & XER_F_CANONICAL); int i; if(!sptr) _ASN_ENCODE_FAILED; er.encoded = 0; for(i = 0; i < list->count; i++) { asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; if(!memb_ptr) continue; if(mname) { if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; if(tmper.encoded == 0 && specs->as_XMLValueList) { const char *name = elm->type->xml_tag; size_t len = strlen(name); if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1); _ASN_CALLBACK3("<", 1, name, len, "/>", 2); } if(mname) { _ASN_CALLBACK3("", 1); er.encoded += 5; } er.encoded += (2 * mlen) + tmper.encoded; } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_anonymous_sequence_ *list; asn_per_constraint_t *ct; asn_enc_rval_t er; asn_TYPE_member_t *elm = td->elements; int seq; if(!sptr) _ASN_ENCODE_FAILED; list = _A_SEQUENCE_FROM_VOID(sptr); er.encoded = 0; ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count); if(constraints) ct = &constraints->size; else if(td->per_constraints) ct = &td->per_constraints->size; else ct = 0; /* If extensible constraint, check if size is in root */ if(ct) { int not_in_root = (list->count < ct->lower_bound || list->count > ct->upper_bound); ASN_DEBUG("lb %ld ub %ld %s", ct->lower_bound, ct->upper_bound, ct->flags & APC_EXTENSIBLE ? "ext" : "fix"); if(ct->flags & APC_EXTENSIBLE) { /* Declare whether size is in extension root */ if(per_put_few_bits(po, not_in_root, 1)) _ASN_ENCODE_FAILED; if(not_in_root) ct = 0; } else if(not_in_root && ct->effective_bits >= 0) _ASN_ENCODE_FAILED; } if(ct && ct->effective_bits >= 0) { /* X.691, #19.5: No length determinant */ if(per_put_few_bits(po, list->count - ct->lower_bound, ct->effective_bits)) _ASN_ENCODE_FAILED; } for(seq = -1; seq < list->count;) { ssize_t mayEncode; if(seq < 0) seq = 0; if(ct && ct->effective_bits >= 0) { mayEncode = list->count; } else { mayEncode = uper_put_length(po, list->count - seq); if(mayEncode < 0) _ASN_ENCODE_FAILED; } while(mayEncode--) { void *memb_ptr = list->array[seq++]; if(!memb_ptr) _ASN_ENCODE_FAILED; er = elm->type->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); if(er.encoded == -1) _ASN_ENCODE_FAILED; } } _ASN_ENCODED_OK(er); } biosig-2.3.3/biosig4c++/t240/SaSpec.h0000664000175000017500000000146214105434233017032 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaSpec_H_ #define _SaSpec_H_ #include /* Including external dependencies */ #include #include "StorageDataType.h" #include "SaFlags.h" #include #ifdef __cplusplus extern "C" { #endif /* SaSpec */ typedef struct SaSpec { INTEGER_t storagesize; INTEGER_t *significantbits /* OPTIONAL */; StorageDataType_t storagedatatype; SaFlags_t *flags /* DEFAULT {} */; INTEGER_t arraysize; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SaSpec_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaSpec; #ifdef __cplusplus } #endif #endif /* _SaSpec_H_ */ biosig-2.3.3/biosig4c++/t240/MeasuredDataSection.h0000664000175000017500000000537714105434233021551 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MeasuredDataSection_H_ #define _MeasuredDataSection_H_ #include /* Including external dependencies */ #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct RealTimeSampleArrayMeasuredDataSection; struct TimeSampleArrayMeasuredDataSection; struct DistributionSampleArrayMeasuredDataSection; struct NumericMeasuredDataSection; struct EnumerationMeasuredDataSection; struct AlertSection; struct DynamicAttributeChangeSection; /* MeasuredDataSection */ typedef struct MeasuredDataSection { struct MeasuredDataSection__realtimesas { A_SEQUENCE_OF(struct RealTimeSampleArrayMeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *realtimesas; struct MeasuredDataSection__timesas { A_SEQUENCE_OF(struct TimeSampleArrayMeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *timesas; struct MeasuredDataSection__distributionsas { A_SEQUENCE_OF(struct DistributionSampleArrayMeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *distributionsas; struct MeasuredDataSection__numerics { A_SEQUENCE_OF(struct NumericMeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *numerics; struct MeasuredDataSection__enumerations { A_SEQUENCE_OF(struct EnumerationMeasuredDataSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *enumerations; struct MeasuredDataSection__alerts { A_SEQUENCE_OF(struct AlertSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *alerts; struct MeasuredDataSection__attributechanges { A_SEQUENCE_OF(struct DynamicAttributeChangeSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *attributechanges; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MeasuredDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "RealTimeSampleArrayMeasuredDataSection.h" #include "TimeSampleArrayMeasuredDataSection.h" #include "DistributionSampleArrayMeasuredDataSection.h" #include "NumericMeasuredDataSection.h" #include "EnumerationMeasuredDataSection.h" #include "AlertSection.h" #include "DynamicAttributeChangeSection.h" #endif /* _MeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/FEFFloat.c0000664000175000017500000000673414105434233017244 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "FEFFloat.h" int FEFFloat_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_REAL.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using REAL, * so here we adjust the DEF accordingly. */ static void FEFFloat_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_REAL.free_struct; td->print_struct = asn_DEF_REAL.print_struct; td->ber_decoder = asn_DEF_REAL.ber_decoder; td->der_encoder = asn_DEF_REAL.der_encoder; td->xer_decoder = asn_DEF_REAL.xer_decoder; td->xer_encoder = asn_DEF_REAL.xer_encoder; td->uper_decoder = asn_DEF_REAL.uper_decoder; td->uper_encoder = asn_DEF_REAL.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_REAL.per_constraints; td->elements = asn_DEF_REAL.elements; td->elements_count = asn_DEF_REAL.elements_count; td->specifics = asn_DEF_REAL.specifics; } void FEFFloat_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { FEFFloat_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int FEFFloat_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { FEFFloat_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t FEFFloat_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { FEFFloat_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t FEFFloat_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { FEFFloat_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t FEFFloat_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { FEFFloat_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t FEFFloat_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { FEFFloat_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_FEFFloat_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)) }; asn_TYPE_descriptor_t asn_DEF_FEFFloat = { "FEFFloat", "FEFFloat", FEFFloat_free, FEFFloat_print, FEFFloat_constraint, FEFFloat_decode_ber, FEFFloat_encode_der, FEFFloat_decode_xer, FEFFloat_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_FEFFloat_tags_1, sizeof(asn_DEF_FEFFloat_tags_1) /sizeof(asn_DEF_FEFFloat_tags_1[0]), /* 1 */ asn_DEF_FEFFloat_tags_1, /* Same as above */ sizeof(asn_DEF_FEFFloat_tags_1) /sizeof(asn_DEF_FEFFloat_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SampleArrayDescriptiveDataSection.c0000664000175000017500000007726414105434233024425 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SampleArrayDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct SampleArrayDescriptiveDataSection__vmosourcelist), offsetof(struct SampleArrayDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct SampleArrayDescriptiveDataSection__metricsourcelist), offsetof(struct SampleArrayDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct SampleArrayDescriptiveDataSection__msmtsitelist), offsetof(struct SampleArrayDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct SampleArrayDescriptiveDataSection__msmtsitelistext), offsetof(struct SampleArrayDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct SampleArrayDescriptiveDataSection__bodysitelist), offsetof(struct SampleArrayDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct SampleArrayDescriptiveDataSection__bodysitelistext), offsetof(struct SampleArrayDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct SampleArrayDescriptiveDataSection__metriccalibration), offsetof(struct SampleArrayDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_visualgrid_40[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaGridEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_visualgrid_tags_40[] = { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_visualgrid_specs_40 = { sizeof(struct SampleArrayDescriptiveDataSection__visualgrid), offsetof(struct SampleArrayDescriptiveDataSection__visualgrid, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_visualgrid_40 = { "visualgrid", "visualgrid", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_visualgrid_tags_40, sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]) - 1, /* 1 */ asn_DEF_visualgrid_tags_40, /* Same as above */ sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_visualgrid_40, 1, /* Single element */ &asn_SPC_visualgrid_specs_40 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_sacalibrationdata_42[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaCalData, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_sacalibrationdata_tags_42[] = { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_sacalibrationdata_specs_42 = { sizeof(struct SampleArrayDescriptiveDataSection__sacalibrationdata), offsetof(struct SampleArrayDescriptiveDataSection__sacalibrationdata, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_sacalibrationdata_42 = { "sacalibrationdata", "sacalibrationdata", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_sacalibrationdata_tags_42, sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]) - 1, /* 1 */ asn_DEF_sacalibrationdata_tags_42, /* Same as above */ sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_sacalibrationdata_42, 1, /* Single element */ &asn_SPC_sacalibrationdata_specs_42 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_filterspecification_44[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaFilterEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_filterspecification_tags_44[] = { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_filterspecification_specs_44 = { sizeof(struct SampleArrayDescriptiveDataSection__filterspecification), offsetof(struct SampleArrayDescriptiveDataSection__filterspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_filterspecification_44 = { "filterspecification", "filterspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_filterspecification_tags_44, sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]) - 1, /* 1 */ asn_DEF_filterspecification_tags_44, /* Same as above */ sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_filterspecification_44, 1, /* Single element */ &asn_SPC_filterspecification_specs_44 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SampleArrayDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SampleArrayDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 24, offsetof(struct SampleArrayDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 23, offsetof(struct SampleArrayDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 22, offsetof(struct SampleArrayDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 21, offsetof(struct SampleArrayDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 20, offsetof(struct SampleArrayDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 19, offsetof(struct SampleArrayDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 18, offsetof(struct SampleArrayDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 17, offsetof(struct SampleArrayDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 16, offsetof(struct SampleArrayDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 15, offsetof(struct SampleArrayDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 14, offsetof(struct SampleArrayDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 13, offsetof(struct SampleArrayDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 12, offsetof(struct SampleArrayDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 11, offsetof(struct SampleArrayDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 10, offsetof(struct SampleArrayDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 9, offsetof(struct SampleArrayDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 8, offsetof(struct SampleArrayDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 7, offsetof(struct SampleArrayDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 6, offsetof(struct SampleArrayDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 5, offsetof(struct SampleArrayDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 4, offsetof(struct SampleArrayDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 3, offsetof(struct SampleArrayDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 2, offsetof(struct SampleArrayDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 1, offsetof(struct SampleArrayDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayDescriptiveDataSection, saspecification), (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saspecification" }, { ATF_POINTER, 1, offsetof(struct SampleArrayDescriptiveDataSection, compression), (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compression" }, { ATF_NOFLAGS, 0, offsetof(struct SampleArrayDescriptiveDataSection, scaleandrangespec), (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ScaleRangeSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "scaleandrangespec" }, { ATF_POINTER, 6, offsetof(struct SampleArrayDescriptiveDataSection, saphysiologicalrange), (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saphysiologicalrange" }, { ATF_POINTER, 5, offsetof(struct SampleArrayDescriptiveDataSection, visualgrid), (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_visualgrid_40, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "visualgrid" }, { ATF_POINTER, 4, offsetof(struct SampleArrayDescriptiveDataSection, sacalibrationdata), (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_sacalibrationdata_42, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sacalibrationdata" }, { ATF_POINTER, 3, offsetof(struct SampleArrayDescriptiveDataSection, filterspecification), (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_filterspecification_44, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filterspecification" }, { ATF_POINTER, 2, offsetof(struct SampleArrayDescriptiveDataSection, sasignalfrequency), (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSignalFrequency, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sasignalfrequency" }, { ATF_POINTER, 1, offsetof(struct SampleArrayDescriptiveDataSection, sameasureresolution), (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sameasureresolution" }, }; static ber_tlv_tag_t asn_DEF_SampleArrayDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SampleArrayDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), 28, 0, 0 }, /* compression at 962 */ { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), 33, 0, 0 }, /* filterspecification at 983 */ { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), 31, 0, 0 }, /* visualgrid at 973 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), 32, 0, 0 }, /* sacalibrationdata at 978 */ { (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), 34, 0, 0 }, /* sasignalfrequency at 986 */ { (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), 35, 0, 0 }, /* sameasureresolution at 989 */ { (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), 30, 0, 0 }, /* saphysiologicalrange at 969 */ { (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), 27, 0, 0 }, /* saspecification at 959 */ { (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), 29, 0, 0 }, /* scaleandrangespec at 965 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SampleArrayDescriptiveDataSection_specs_1 = { sizeof(struct SampleArrayDescriptiveDataSection), offsetof(struct SampleArrayDescriptiveDataSection, _asn_ctx), asn_MAP_SampleArrayDescriptiveDataSection_tag2el_1, 36, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SampleArrayDescriptiveDataSection = { "SampleArrayDescriptiveDataSection", "SampleArrayDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SampleArrayDescriptiveDataSection_tags_1, sizeof(asn_DEF_SampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_SampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_SampleArrayDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_SampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_SampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SampleArrayDescriptiveDataSection_1, 36, /* Elements count */ &asn_SPC_SampleArrayDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/MedicalDeviceComponents.c0000664000175000017500000001261314105434233022373 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MedicalDeviceComponents.h" static asn_TYPE_member_t asn_MBR_medicaldevices_3[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_VirtualMedicalDeviceSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_medicaldevices_tags_3[] = { (ASN_TAG_CLASS_APPLICATION | (7010 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_medicaldevices_specs_3 = { sizeof(struct MedicalDeviceComponents__medicaldevices), offsetof(struct MedicalDeviceComponents__medicaldevices, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_medicaldevices_3 = { "medicaldevices", "medicaldevices", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_medicaldevices_tags_3, sizeof(asn_DEF_medicaldevices_tags_3) /sizeof(asn_DEF_medicaldevices_tags_3[0]) - 1, /* 1 */ asn_DEF_medicaldevices_tags_3, /* Same as above */ sizeof(asn_DEF_medicaldevices_tags_3) /sizeof(asn_DEF_medicaldevices_tags_3[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_medicaldevices_3, 1, /* Single element */ &asn_SPC_medicaldevices_specs_3 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_subsystems_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MedicalDeviceSystemSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_subsystems_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (7011 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_subsystems_specs_5 = { sizeof(struct MedicalDeviceComponents__subsystems), offsetof(struct MedicalDeviceComponents__subsystems, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_subsystems_5 = { "subsystems", "subsystems", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_subsystems_tags_5, sizeof(asn_DEF_subsystems_tags_5) /sizeof(asn_DEF_subsystems_tags_5[0]) - 1, /* 1 */ asn_DEF_subsystems_tags_5, /* Same as above */ sizeof(asn_DEF_subsystems_tags_5) /sizeof(asn_DEF_subsystems_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_subsystems_5, 1, /* Single element */ &asn_SPC_subsystems_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_MedicalDeviceComponents_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceComponents, choice.medicaldevice), (ASN_TAG_CLASS_APPLICATION | (7009 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_VirtualMedicalDeviceSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "medicaldevice" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceComponents, choice.medicaldevices), (ASN_TAG_CLASS_APPLICATION | (7010 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_medicaldevices_3, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "medicaldevices" }, { ATF_NOFLAGS, 0, offsetof(struct MedicalDeviceComponents, choice.subsystems), (ASN_TAG_CLASS_APPLICATION | (7011 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_subsystems_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subsystems" }, }; static asn_TYPE_tag2member_t asn_MAP_MedicalDeviceComponents_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (7009 << 2)), 0, 0, 0 }, /* medicaldevice at 596 */ { (ASN_TAG_CLASS_APPLICATION | (7010 << 2)), 1, 0, 0 }, /* medicaldevices at 600 */ { (ASN_TAG_CLASS_APPLICATION | (7011 << 2)), 2, 0, 0 } /* subsystems at 606 */ }; static asn_CHOICE_specifics_t asn_SPC_MedicalDeviceComponents_specs_1 = { sizeof(struct MedicalDeviceComponents), offsetof(struct MedicalDeviceComponents, _asn_ctx), offsetof(struct MedicalDeviceComponents, present), sizeof(((struct MedicalDeviceComponents *)0)->present), asn_MAP_MedicalDeviceComponents_tag2el_1, 3, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_MedicalDeviceComponents = { "MedicalDeviceComponents", "MedicalDeviceComponents", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_MedicalDeviceComponents_1, 3, /* Elements count */ &asn_SPC_MedicalDeviceComponents_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/per_opentype.h0000664000175000017500000000123214105434233020360 0ustar schloeglschloegl/* * Copyright (c) 2007 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _PER_OPENTYPE_H_ #define _PER_OPENTYPE_H_ #ifdef __cplusplus extern "C" { #endif asn_dec_rval_t uper_open_type_get(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int uper_open_type_skip(asn_codec_ctx_t *opt_codec_ctx, asn_per_data_t *pd); int uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po); #ifdef __cplusplus } #endif #endif /* _PER_OPENTYPE_H_ */ biosig-2.3.3/biosig4c++/t240/UnitCode.h0000664000175000017500000000143314105434233017364 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _UnitCode_H_ #define _UnitCode_H_ #include /* Including external dependencies */ #include "UnitsOfMeasurementCode.h" #ifdef __cplusplus extern "C" { #endif /* UnitCode */ typedef UnitsOfMeasurementCode_t UnitCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_UnitCode; asn_struct_free_f UnitCode_free; asn_struct_print_f UnitCode_print; asn_constr_check_f UnitCode_constraint; ber_type_decoder_f UnitCode_decode_ber; der_type_encoder_f UnitCode_encode_der; xer_type_decoder_f UnitCode_decode_xer; xer_type_encoder_f UnitCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _UnitCode_H_ */ biosig-2.3.3/biosig4c++/t240/NuObsValue.c0000664000175000017500000000546214105434233017676 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "NuObsValue.h" static asn_TYPE_member_t asn_MBR_NuObsValue_1[] = { { ATF_POINTER, 3, offsetof(struct NuObsValue, metricid), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 2, offsetof(struct NuObsValue, state), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "state" }, { ATF_POINTER, 1, offsetof(struct NuObsValue, unitcode), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_NOFLAGS, 0, offsetof(struct NuObsValue, value), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "value" }, }; static ber_tlv_tag_t asn_DEF_NuObsValue_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_NuObsValue_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* metricid at 1299 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* state at 1300 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* unitcode at 1301 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 } /* value at 1303 */ }; static asn_SEQUENCE_specifics_t asn_SPC_NuObsValue_specs_1 = { sizeof(struct NuObsValue), offsetof(struct NuObsValue, _asn_ctx), asn_MAP_NuObsValue_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_NuObsValue = { "NuObsValue", "NuObsValue", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_NuObsValue_tags_1, sizeof(asn_DEF_NuObsValue_tags_1) /sizeof(asn_DEF_NuObsValue_tags_1[0]), /* 1 */ asn_DEF_NuObsValue_tags_1, /* Same as above */ sizeof(asn_DEF_NuObsValue_tags_1) /sizeof(asn_DEF_NuObsValue_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_NuObsValue_1, 4, /* Elements count */ &asn_SPC_NuObsValue_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ber_tlv_tag.h0000664000175000017500000000345414105434233020147 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _BER_TLV_TAG_H_ #define _BER_TLV_TAG_H_ #ifdef __cplusplus extern "C" { #endif enum asn_tag_class { ASN_TAG_CLASS_UNIVERSAL = 0, /* 0b00 */ ASN_TAG_CLASS_APPLICATION = 1, /* 0b01 */ ASN_TAG_CLASS_CONTEXT = 2, /* 0b10 */ ASN_TAG_CLASS_PRIVATE = 3 /* 0b11 */ }; typedef unsigned ber_tlv_tag_t; /* BER TAG from Tag-Length-Value */ /* * Tag class is encoded together with tag value for optimization purposes. */ #define BER_TAG_CLASS(tag) ((tag) & 0x3) #define BER_TAG_VALUE(tag) ((tag) >> 2) #define BER_TLV_CONSTRUCTED(tagptr) (((*(const uint8_t *)tagptr)&0x20)?1:0) #define BER_TAGS_EQUAL(tag1, tag2) ((tag1) == (tag2)) /* * Several functions for printing the TAG in the canonical form * (i.e. "[PRIVATE 0]"). * Return values correspond to their libc counterparts (if any). */ ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t buflen); ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *); char *ber_tlv_tag_string(ber_tlv_tag_t tag); /* * This function tries to fetch the tag from the input stream. * RETURN VALUES: * 0: More data expected than bufptr contains. * -1: Fatal error deciphering tag. * >0: Number of bytes used from bufptr. tag_r will contain the tag. */ ssize_t ber_fetch_tag(const void *bufptr, size_t size, ber_tlv_tag_t *tag_r); /* * This function serializes the tag (T from TLV) in BER format. * It always returns number of bytes necessary to represent the tag, * it is a caller's responsibility to check the return value * against the supplied buffer's size. */ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufptr, size_t size); #ifdef __cplusplus } #endif #endif /* _BER_TLV_TAG_H_ */ biosig-2.3.3/biosig4c++/t240/SystemModel.h0000664000175000017500000000127014105434233020116 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SystemModel_H_ #define _SystemModel_H_ #include /* Including external dependencies */ #include "FEFString.h" #include #ifdef __cplusplus extern "C" { #endif /* SystemModel */ typedef struct SystemModel { FEFString_t manufacturer; FEFString_t model_number; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SystemModel_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SystemModel; #ifdef __cplusplus } #endif #endif /* _SystemModel_H_ */ biosig-2.3.3/biosig4c++/t240/xer_decoder.c0000664000175000017500000002101414105434233020125 0ustar schloeglschloegl/* * Copyright (c) 2004, 2005 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* XER/XML parsing support */ /* * Decode the XER encoding of a given type. */ asn_dec_rval_t xer_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *buffer, size_t size) { asn_codec_ctx_t s_codec_ctx; /* * Stack checker requires that the codec context * must be allocated on the stack. */ if(opt_codec_ctx) { if(opt_codec_ctx->max_stack_size) { s_codec_ctx = *opt_codec_ctx; opt_codec_ctx = &s_codec_ctx; } } else { /* If context is not given, be security-conscious anyway */ memset(&s_codec_ctx, 0, sizeof(s_codec_ctx)); s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX; opt_codec_ctx = &s_codec_ctx; } /* * Invoke type-specific decoder. */ return td->xer_decoder(opt_codec_ctx, td, struct_ptr, 0, buffer, size); } struct xer__cb_arg { pxml_chunk_type_e chunk_type; size_t chunk_size; const void *chunk_buf; int callback_not_invoked; }; static int xer__token_cb(pxml_chunk_type_e type, const void *_chunk_data, size_t _chunk_size, void *key) { struct xer__cb_arg *arg = (struct xer__cb_arg *)key; arg->chunk_type = type; arg->chunk_size = _chunk_size; arg->chunk_buf = _chunk_data; arg->callback_not_invoked = 0; return -1; /* Terminate the XML parsing */ } /* * Fetch the next token from the XER/XML stream. */ ssize_t xer_next_token(int *stateContext, const void *buffer, size_t size, pxer_chunk_type_e *ch_type) { struct xer__cb_arg arg; int new_stateContext = *stateContext; ssize_t ret; arg.callback_not_invoked = 1; ret = pxml_parse(&new_stateContext, buffer, size, xer__token_cb, &arg); if(ret < 0) return -1; if(arg.callback_not_invoked) { assert(ret == 0); /* No data was consumed */ return 0; /* Try again with more data */ } else { assert(arg.chunk_size); assert(arg.chunk_buf == buffer); } /* * Translate the XML chunk types into more convenient ones. */ switch(arg.chunk_type) { case PXML_TEXT: *ch_type = PXER_TEXT; break; case PXML_TAG: return 0; /* Want more */ case PXML_TAG_END: *ch_type = PXER_TAG; break; case PXML_COMMENT: case PXML_COMMENT_END: *ch_type = PXER_COMMENT; break; } *stateContext = new_stateContext; return arg.chunk_size; } #define CSLASH 0x2f /* '/' */ #define LANGLE 0x3c /* '<' */ #define RANGLE 0x3e /* '>' */ xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, const char *need_tag) { const char *buf = (const char *)buf_ptr; const char *end; xer_check_tag_e ct = XCT_OPENING; if(size < 2 || buf[0] != LANGLE || buf[size-1] != RANGLE) { if(size >= 2) ASN_DEBUG("Broken XML tag: \"%c...%c\"", buf[0], buf[size - 1]); return XCT_BROKEN; } /* * Determine the tag class. */ if(buf[1] == CSLASH) { buf += 2; /* advance past "" */ ct = XCT_CLOSING; if(size > 0 && buf[size-1] == CSLASH) return XCT_BROKEN; /* */ } else { buf++; /* advance past "<" */ size -= 2; /* strip "<" and ">" */ if(size > 0 && buf[size-1] == CSLASH) { ct = XCT_BOTH; size--; /* One more, for "/" */ } } /* Sometimes we don't care about the tag */ if(!need_tag || !*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); /* * Determine the tag name. */ for(end = buf + size; buf < end; buf++, need_tag++) { int b = *buf, n = *need_tag; if(b != n) { if(n == 0) { switch(b) { case 0x09: case 0x0a: case 0x0c: case 0x0d: case 0x20: /* "": whitespace is normal */ return ct; } } return (xer_check_tag_e)(XCT__UNK__MASK | ct); } if(b == 0) return XCT_BROKEN; /* Embedded 0 in buf?! */ } if(*need_tag) return (xer_check_tag_e)(XCT__UNK__MASK | ct); return ct; } #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = (num_bytes); \ buf_ptr = ((const char *)buf_ptr) + num; \ size -= num; \ consumed_myself += num; \ } while(0) #undef RETURN #define RETURN(_code) do { \ rval.code = _code; \ rval.consumed = consumed_myself; \ if(rval.code != RC_OK) \ ASN_DEBUG("Failed with %d", rval.code); \ return rval; \ } while(0) #define XER_GOT_BODY(chunk_buf, chunk_size, size) do { \ ssize_t converted_size = body_receiver \ (struct_key, chunk_buf, chunk_size, \ (size_t)chunk_size < size); \ if(converted_size == -1) RETURN(RC_FAIL); \ if(converted_size == 0 \ && size == (size_t)chunk_size) \ RETURN(RC_WMORE); \ chunk_size = converted_size; \ } while(0) #define XER_GOT_EMPTY() do { \ if(body_receiver(struct_key, 0, 0, size > 0) == -1) \ RETURN(RC_FAIL); \ } while(0) /* * Generalized function for decoding the primitive values. */ asn_dec_rval_t xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx, /* Type decoder context */ void *struct_key, const char *xml_tag, /* Expected XML tag */ const void *buf_ptr, size_t size, int (*opt_unexpected_tag_decoder) (void *struct_key, const void *chunk_buf, size_t chunk_size), ssize_t (*body_receiver) (void *struct_key, const void *chunk_buf, size_t chunk_size, int have_more) ) { asn_dec_rval_t rval; ssize_t consumed_myself = 0; (void)opt_codec_ctx; /* * Phases of XER/XML processing: * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. */ if(ctx->phase > 1) RETURN(RC_FAIL); for(;;) { pxer_chunk_type_e ch_type; /* XER chunk type */ ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ /* * Get the next part of the XML stream. */ ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type); switch(ch_size) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); default: switch(ch_type) { case PXER_COMMENT: /* Got XML comment */ ADVANCE(ch_size); /* Skip silently */ continue; case PXER_TEXT: if(ctx->phase == 0) { /* * We have to ignore whitespace here, * but in order to be forward compatible * with EXTENDED-XER (EMBED-VALUES, #25) * any text is just ignored here. */ } else { XER_GOT_BODY(buf_ptr, ch_size, size); } ADVANCE(ch_size); continue; case PXER_TAG: break; /* Check the rest down there */ } } assert(ch_type == PXER_TAG && size); tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); /* * Phase 0: * Expecting the opening tag * for the type being processed. * Phase 1: * Waiting for the closing XML tag. */ switch(tcv) { case XCT_BOTH: if(ctx->phase) break; /* Finished decoding of an empty element */ XER_GOT_EMPTY(); ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); case XCT_OPENING: if(ctx->phase) break; ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; case XCT_CLOSING: if(!ctx->phase) break; ADVANCE(ch_size); ctx->phase = 2; /* Phase out */ RETURN(RC_OK); case XCT_UNKNOWN_BO: /* * Certain tags in the body may be expected. */ if(opt_unexpected_tag_decoder && opt_unexpected_tag_decoder(struct_key, buf_ptr, ch_size) >= 0) { /* Tag's processed fine */ ADVANCE(ch_size); if(!ctx->phase) { /* We are not expecting * the closing tag anymore. */ ctx->phase = 2; /* Phase out */ RETURN(RC_OK); } continue; } /* Fall through */ default: break; /* Unexpected tag */ } ASN_DEBUG("Unexpected XML tag (expected \"%s\")", xml_tag); break; /* Dark and mysterious things have just happened */ } RETURN(RC_FAIL); } int xer_is_whitespace(const void *chunk_buf, size_t chunk_size) { const char *p = (const char *)chunk_buf; const char *pend = p + chunk_size; for(; p < pend; p++) { switch(*p) { /* X.693, #8.1.4 * HORISONTAL TAB (9) * LINE FEED (10) * CARRIAGE RETURN (13) * SPACE (32) */ case 0x09: case 0x0a: case 0x0d: case 0x20: break; default: return 0; } } return 1; /* All whitespace */ } /* * This is a vastly simplified, non-validating XML tree skipper. */ int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth) { assert(*depth > 0); switch(tcv) { case XCT_BOTH: case XCT_UNKNOWN_BO: /* These negate each other. */ return 0; case XCT_OPENING: case XCT_UNKNOWN_OP: ++(*depth); return 0; case XCT_CLOSING: case XCT_UNKNOWN_CL: if(--(*depth) == 0) return (tcv == XCT_CLOSING) ? 2 : 1; return 0; default: return -1; } } biosig-2.3.3/biosig4c++/t240/DynamicAttributeChangeSection.h0000664000175000017500000000165314105434233023561 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DynamicAttributeChangeSection_H_ #define _DynamicAttributeChangeSection_H_ #include /* Including external dependencies */ #include "ObservationTime.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* DynamicAttributeChangeSection */ typedef struct DynamicAttributeChangeSection { ObservationTime_t timestamp; HandleRef_t handle; INTEGER_t attribute; ANY_t *value /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DynamicAttributeChangeSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DynamicAttributeChangeSection; #ifdef __cplusplus } #endif #endif /* _DynamicAttributeChangeSection_H_ */ biosig-2.3.3/biosig4c++/t240/asn_application.h0000664000175000017500000000271614105434233021023 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2006 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Application-level ASN.1 callbacks. */ #ifndef _ASN_APPLICATION_H_ #define _ASN_APPLICATION_H_ #include "asn_system.h" /* for platform-dependent types */ #include "asn_codecs.h" /* for ASN.1 codecs specifics */ #ifdef __cplusplus extern "C" { #endif /* * Generic type of an application-defined callback to return various * types of data to the application. * EXPECTED RETURN VALUES: * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ typedef int (asn_app_consume_bytes_f)(const void *buffer, size_t size, void *application_specific_key); /* * A callback of this type is called whenever constraint validation fails * on some ASN.1 type. See "constraints.h" for more details on constraint * validation. * This callback specifies a descriptor of the ASN.1 type which failed * the constraint check, as well as human readable message on what * particular constraint has failed. */ typedef void (asn_app_constraint_failed_f)(void *application_specific_key, struct asn_TYPE_descriptor_s *type_descriptor_which_failed, const void *structure_which_failed_ptr, const char *error_message_format, ...) GCC_PRINTFLIKE(4, 5); #ifdef __cplusplus } #endif #include "constr_TYPE.h" /* for asn_TYPE_descriptor_t */ #endif /* _ASN_APPLICATION_H_ */ biosig-2.3.3/biosig4c++/t240/asn_SEQUENCE_OF.c0000664000175000017500000000156014105434233020303 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include typedef A_SEQUENCE_OF(void) asn_sequence; void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) { asn_sequence *as = (asn_sequence *)asn_sequence_of_x; if(as) { void *ptr; int n; if(number < 0 || number >= as->count) return; /* Nothing to delete */ if(_do_free && as->free) { ptr = as->array[number]; } else { ptr = 0; } /* * Shift all elements to the left to hide the gap. */ --as->count; for(n = number; n < as->count; n++) as->array[n] = as->array[n+1]; /* * Invoke the third-party function only when the state * of the parent structure is consistent. */ if(ptr) as->free(ptr); } } biosig-2.3.3/biosig4c++/t240/Makefile0000664000175000017500000000317614105434245017152 0ustar schloeglschloegl-include modules.mk # This file may be used as an input for make(3) # Remove the lines below to convert it into a pure .am file WIN32 = ../win32/libcnsfef.a ../win32/libcnsfef.dll WIN64 = ../win64/libcnsfef.a ../win64/libcnsfef.dll CFLAGS += -pipe -fPIC -Wall -O2 -Wextra -I. OBJS=${ASN_MODULE_SOURCES:.c=.o} WINOBJS=${ASN_MODULE_SOURCES:.c=.obj} W64OBJS=${ASN_MODULE_SOURCES:.c=.o64} ifeq (Darwin,$(shell uname)) CFLAGS += -mmacosx-version-min=10.7 endif CC ?= gcc MinGWCC = $(CROSS)-gcc MinGW64CC = $(CROSS64)-gcc all: libcnsfef.a $(WIN32) libcnsfef.a: $(OBJS) $(AR) libcnsfef.a $(OBJS) ../win32/libcnsfef.a: $(WINOBJS) $(CROSS)-$(AR) ../win32/libcnsfef.a $(WINOBJS) ../win64/libcnsfef.a: $(W64OBJS) $(CROSS64)-$(AR) ../win64/libcnsfef.a $(W64OBJS) ../win32/libcnsfef.dll: $(WINOBJS) $(MinGWCC) -shared -fPIC $(WINOBJS) -Wl,--output-def,../win32/libcnsfef.def,--out-implib,../win32/libcnsfef.dll ../win64/libcnsfef.dll: $(WINOBJS) $(MinGW64CC) -shared -fPIC $(W64OBJS) -Wl,--output-def,../win64/libcnsfef.def,--out-implib,../win64/libcnsfef.dll .SUFFIXES: .SUFFIXES: .c .o %.obj: %.c $(CROSS)-$(CC) $(CFLAGS) -o "$@" -c "$<" %.o64: %.c $(CROSS64)-$(CC) $(CFLAGS) -o "$@" -c "$<" .c.o: $(CC) $(CFLAGS) -o "$@" -c "$<" clean: # rm -f $(ASN_MODULE_HEADERS) # rm -f $(ASN_MODULE_SOURCES) rm -f libcnsfef.a $(WIN32) rm -f $(OBJS) rm -f $(WINOBJS) rm -f $(W64OBJS) rm -f Makefile.am.sample libfef.a regen: regenerate-from-asn1-source regenerate-from-asn1-source: asn1c -fcompound-names fef.asn awk '/^#/ {exit} {print}' Makefile.am.sample >modules.mk rm -f converter-sample.c Makefile.am.sample libfef.a biosig-2.3.3/biosig4c++/t240/ProdSpecEntryType.h0000664000175000017500000000230114105434233021250 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ProdSpecEntryType_H_ #define _ProdSpecEntryType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ProdSpecEntryType { ProdSpecEntryType_unspecified = 0, ProdSpecEntryType_serial_number = 1, ProdSpecEntryType_part_number = 2, ProdSpecEntryType_hw_revision = 3, ProdSpecEntryType_sw_revision = 4, ProdSpecEntryType_fw_revision = 5, ProdSpecEntryType_protocol_revision = 6 } e_ProdSpecEntryType; /* ProdSpecEntryType */ typedef INTEGER_t ProdSpecEntryType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ProdSpecEntryType; asn_struct_free_f ProdSpecEntryType_free; asn_struct_print_f ProdSpecEntryType_print; asn_constr_check_f ProdSpecEntryType_constraint; ber_type_decoder_f ProdSpecEntryType_decode_ber; der_type_encoder_f ProdSpecEntryType_encode_der; xer_type_decoder_f ProdSpecEntryType_decode_xer; xer_type_encoder_f ProdSpecEntryType_encode_xer; #ifdef __cplusplus } #endif #endif /* _ProdSpecEntryType_H_ */ biosig-2.3.3/biosig4c++/t240/asn_system.h0000664000175000017500000000643014105434233020041 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Miscellaneous system-dependent types. */ #ifndef _ASN_SYSTEM_H_ #define _ASN_SYSTEM_H_ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include /* For snprintf(3) */ #include /* For *alloc(3) */ #include /* For memcpy(3) */ #include /* For size_t */ #include /* For LONG_MAX */ #include /* For va_start */ #include /* for offsetof and ptrdiff_t */ #ifdef WIN32 #include #define snprintf _snprintf #define vsnprintf _vsnprintf /* To avoid linking with ws2_32.lib, here's the definition of ntohl() */ #define sys_ntohl(l) ((((l) << 24) & 0xff000000) \ | (((l) << 16) & 0xff0000) \ | (((l) << 8) & 0xff00) \ | ((l) & 0xff)) #ifdef _MSC_VER /* MSVS.Net */ #ifndef __cplusplus #define inline __inline #endif #ifndef ASSUMESTDTYPES /* Standard types have been defined elsewhere */ #define ssize_t SSIZE_T typedef char int8_t; typedef short int16_t; typedef int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #endif /* ASSUMESTDTYPES */ #define WIN32_LEAN_AND_MEAN #include #include #define isnan _isnan #define finite _finite #define copysign _copysign #define ilogb _logb #else /* !_MSC_VER */ #include #endif /* _MSC_VER */ #else /* !WIN32 */ #if defined(__vxworks) #include #else /* !defined(__vxworks) */ #include /* C99 specifies this file */ /* * 1. Earlier FreeBSD version didn't have , * but was present. * 2. Sun Solaris requires for alloca(3), * but does not have . */ #if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_)) #if defined(sun) #include /* For alloca(3) */ #include /* for finite(3) */ #elif defined(__hpux) #ifdef __GNUC__ #include /* For alloca(3) */ #else /* !__GNUC__ */ #define inline #endif /* __GNUC__ */ #else #include /* SUSv2+ and C99 specify this file, for uintXX_t */ #endif /* defined(sun) */ #endif #include /* for ntohl() */ #define sys_ntohl(foo) ntohl(foo) #endif /* defined(__vxworks) */ #endif /* WIN32 */ #if __GNUC__ >= 3 #ifndef GCC_PRINTFLIKE #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #endif #ifndef GCC_NOTUSED #define GCC_NOTUSED __attribute__((unused)) #endif #else #ifndef GCC_PRINTFLIKE #define GCC_PRINTFLIKE(fmt,var) /* nothing */ #endif #ifndef GCC_NOTUSED #define GCC_NOTUSED #endif #endif /* Figure out if thread safety is requested */ #if !defined(ASN_THREAD_SAFE) && (defined(THREAD_SAFE) || defined(_REENTRANT)) #define ASN_THREAD_SAFE #endif /* Thread safety */ #ifndef offsetof /* If not defined by */ #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) #endif /* offsetof */ #ifndef MIN /* Suitable for comparing primitive types (integers) */ #if defined(__GNUC__) #define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \ ((_a)<(_b)?(_a):(_b)); }) #else /* !__GNUC__ */ #define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */ #endif /* __GNUC__ */ #endif /* MIN */ #endif /* _ASN_SYSTEM_H_ */ biosig-2.3.3/biosig4c++/t240/SimpleColour.c0000664000175000017500000000721514105434233020266 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SimpleColour.h" int SimpleColour_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void SimpleColour_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void SimpleColour_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { SimpleColour_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int SimpleColour_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { SimpleColour_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t SimpleColour_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { SimpleColour_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t SimpleColour_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { SimpleColour_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t SimpleColour_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { SimpleColour_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t SimpleColour_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { SimpleColour_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_SimpleColour_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_SimpleColour = { "SimpleColour", "SimpleColour", SimpleColour_free, SimpleColour_print, SimpleColour_constraint, SimpleColour_decode_ber, SimpleColour_encode_der, SimpleColour_decode_xer, SimpleColour_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SimpleColour_tags_1, sizeof(asn_DEF_SimpleColour_tags_1) /sizeof(asn_DEF_SimpleColour_tags_1[0]), /* 1 */ asn_DEF_SimpleColour_tags_1, /* Same as above */ sizeof(asn_DEF_SimpleColour_tags_1) /sizeof(asn_DEF_SimpleColour_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SessionNotesSection.c0000664000175000017500000002263314105434233021633 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SessionNotesSection.h" static asn_TYPE_member_t asn_MBR_diagnosticscodes_9[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_diagnosticscodes_tags_9[] = { (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_diagnosticscodes_specs_9 = { sizeof(struct SessionNotesSection__diagnosticscodes), offsetof(struct SessionNotesSection__diagnosticscodes, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_diagnosticscodes_9 = { "diagnosticscodes", "diagnosticscodes", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_diagnosticscodes_tags_9, sizeof(asn_DEF_diagnosticscodes_tags_9) /sizeof(asn_DEF_diagnosticscodes_tags_9[0]) - 1, /* 1 */ asn_DEF_diagnosticscodes_tags_9, /* Same as above */ sizeof(asn_DEF_diagnosticscodes_tags_9) /sizeof(asn_DEF_diagnosticscodes_tags_9[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_diagnosticscodes_9, 1, /* Single element */ &asn_SPC_diagnosticscodes_specs_9 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_procedurecodes_12[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_procedurecodes_tags_12[] = { (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_procedurecodes_specs_12 = { sizeof(struct SessionNotesSection__procedurecodes), offsetof(struct SessionNotesSection__procedurecodes, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_procedurecodes_12 = { "procedurecodes", "procedurecodes", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_procedurecodes_tags_12, sizeof(asn_DEF_procedurecodes_tags_12) /sizeof(asn_DEF_procedurecodes_tags_12[0]) - 1, /* 1 */ asn_DEF_procedurecodes_tags_12, /* Same as above */ sizeof(asn_DEF_procedurecodes_tags_12) /sizeof(asn_DEF_procedurecodes_tags_12[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_procedurecodes_12, 1, /* Single element */ &asn_SPC_procedurecodes_specs_12 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SessionNotesSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SessionNotesSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct SessionNotesSection, sn_id), (ASN_TAG_CLASS_APPLICATION | (2505 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sn-id" }, { ATF_NOFLAGS, 0, offsetof(struct SessionNotesSection, sn_name), (ASN_TAG_CLASS_APPLICATION | (2511 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sn-name" }, { ATF_POINTER, 1, offsetof(struct SessionNotesSection, sn_comments), (ASN_TAG_CLASS_APPLICATION | (2528 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sn-comments" }, { ATF_NOFLAGS, 0, offsetof(struct SessionNotesSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_NOFLAGS, 0, offsetof(struct SessionNotesSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 7, offsetof(struct SessionNotesSection, findings), (ASN_TAG_CLASS_APPLICATION | (2500 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "findings" }, { ATF_POINTER, 6, offsetof(struct SessionNotesSection, diagnosticscodes), (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_diagnosticscodes_9, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "diagnosticscodes" }, { ATF_POINTER, 5, offsetof(struct SessionNotesSection, diagnosisdescription), (ASN_TAG_CLASS_APPLICATION | (2494 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "diagnosisdescription" }, { ATF_POINTER, 4, offsetof(struct SessionNotesSection, procedurecodes), (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_procedurecodes_12, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "procedurecodes" }, { ATF_POINTER, 3, offsetof(struct SessionNotesSection, proceduredescription), (ASN_TAG_CLASS_APPLICATION | (2495 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "proceduredescription" }, { ATF_POINTER, 2, offsetof(struct SessionNotesSection, protection), (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ArchiveProtection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "protection" }, { ATF_POINTER, 1, offsetof(struct SessionNotesSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, }; static ber_tlv_tag_t asn_DEF_SessionNotesSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SessionNotesSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 1479 */ { (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), 7, 0, 0 }, /* diagnosticscodes at 1496 */ { (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), 9, 0, 0 }, /* procedurecodes at 1502 */ { (ASN_TAG_CLASS_APPLICATION | (2494 << 2)), 8, 0, 0 }, /* diagnosisdescription at 1498 */ { (ASN_TAG_CLASS_APPLICATION | (2495 << 2)), 10, 0, 0 }, /* proceduredescription at 1504 */ { (ASN_TAG_CLASS_APPLICATION | (2500 << 2)), 6, 0, 0 }, /* findings at 1492 */ { (ASN_TAG_CLASS_APPLICATION | (2505 << 2)), 1, 0, 0 }, /* sn-id at 1482 */ { (ASN_TAG_CLASS_APPLICATION | (2511 << 2)), 2, 0, 0 }, /* sn-name at 1484 */ { (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), 11, 0, 0 }, /* protection at 1506 */ { (ASN_TAG_CLASS_APPLICATION | (2528 << 2)), 3, 0, 0 }, /* sn-comments at 1486 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 4, 0, 0 }, /* starttime at 1488 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 5, 0, 0 }, /* stoptime at 1490 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 12, 0, 0 } /* placeholder at 1508 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SessionNotesSection_specs_1 = { sizeof(struct SessionNotesSection), offsetof(struct SessionNotesSection, _asn_ctx), asn_MAP_SessionNotesSection_tag2el_1, 13, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SessionNotesSection = { "SessionNotesSection", "SessionNotesSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SessionNotesSection_tags_1, sizeof(asn_DEF_SessionNotesSection_tags_1) /sizeof(asn_DEF_SessionNotesSection_tags_1[0]), /* 1 */ asn_DEF_SessionNotesSection_tags_1, /* Same as above */ sizeof(asn_DEF_SessionNotesSection_tags_1) /sizeof(asn_DEF_SessionNotesSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SessionNotesSection_1, 13, /* Elements count */ &asn_SPC_SessionNotesSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SampleArrayMeasuredDataBlock.c0000664000175000017500000001037414105434233023324 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SampleArrayMeasuredDataBlock.h" int SampleArrayMeasuredDataBlock_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_OCTET_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using OCTET_STRING, * so here we adjust the DEF accordingly. */ static void SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_OCTET_STRING.free_struct; td->print_struct = asn_DEF_OCTET_STRING.print_struct; td->ber_decoder = asn_DEF_OCTET_STRING.ber_decoder; td->der_encoder = asn_DEF_OCTET_STRING.der_encoder; td->xer_decoder = asn_DEF_OCTET_STRING.xer_decoder; td->xer_encoder = asn_DEF_OCTET_STRING.xer_encoder; td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder; td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; td->elements = asn_DEF_OCTET_STRING.elements; td->elements_count = asn_DEF_OCTET_STRING.elements_count; td->specifics = asn_DEF_OCTET_STRING.specifics; } void SampleArrayMeasuredDataBlock_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int SampleArrayMeasuredDataBlock_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t SampleArrayMeasuredDataBlock_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t SampleArrayMeasuredDataBlock_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t SampleArrayMeasuredDataBlock_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t SampleArrayMeasuredDataBlock_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { SampleArrayMeasuredDataBlock_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_SampleArrayMeasuredDataBlock_tags_1[] = { (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) }; asn_TYPE_descriptor_t asn_DEF_SampleArrayMeasuredDataBlock = { "SampleArrayMeasuredDataBlock", "SampleArrayMeasuredDataBlock", SampleArrayMeasuredDataBlock_free, SampleArrayMeasuredDataBlock_print, SampleArrayMeasuredDataBlock_constraint, SampleArrayMeasuredDataBlock_decode_ber, SampleArrayMeasuredDataBlock_encode_der, SampleArrayMeasuredDataBlock_decode_xer, SampleArrayMeasuredDataBlock_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SampleArrayMeasuredDataBlock_tags_1, sizeof(asn_DEF_SampleArrayMeasuredDataBlock_tags_1) /sizeof(asn_DEF_SampleArrayMeasuredDataBlock_tags_1[0]) - 1, /* 1 */ asn_DEF_SampleArrayMeasuredDataBlock_tags_1, /* Same as above */ sizeof(asn_DEF_SampleArrayMeasuredDataBlock_tags_1) /sizeof(asn_DEF_SampleArrayMeasuredDataBlock_tags_1[0]), /* 2 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/INTEGER.h0000664000175000017500000000426714105434233016757 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2005 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _INTEGER_H_ #define _INTEGER_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef ASN__PRIMITIVE_TYPE_t INTEGER_t; extern asn_TYPE_descriptor_t asn_DEF_INTEGER; /* Map with to integer value association */ typedef struct asn_INTEGER_enum_map_s { long nat_value; /* associated native integer value */ size_t enum_len; /* strlen("tag") */ const char *enum_name; /* "tag" */ } asn_INTEGER_enum_map_t; /* This type describes an enumeration for INTEGER and ENUMERATED types */ typedef struct asn_INTEGER_specifics_s { asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */ unsigned int *enum2value; /* "tag" => N; sorted by tag */ int map_count; /* Elements in either map */ int extension; /* This map is extensible */ int strict_enumeration; /* Enumeration set is fixed */ int field_width; /* Size of native integer */ int field_unsigned; /* Signed=0, unsigned=1 */ } asn_INTEGER_specifics_t; asn_struct_print_f INTEGER_print; ber_type_decoder_f INTEGER_decode_ber; der_type_encoder_f INTEGER_encode_der; xer_type_decoder_f INTEGER_decode_xer; xer_type_encoder_f INTEGER_encode_xer; per_type_decoder_f INTEGER_decode_uper; per_type_encoder_f INTEGER_encode_uper; /*********************************** * Some handy conversion routines. * ***********************************/ /* * Returns 0 if it was possible to convert, -1 otherwise. * -1/EINVAL: Mandatory argument missing * -1/ERANGE: Value encoded is out of range for long representation * -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()). */ int asn_INTEGER2long(const INTEGER_t *i, long *l); int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l); int asn_long2INTEGER(INTEGER_t *i, long l); int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l); /* * Convert the integer value into the corresponding enumeration map entry. */ const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value); #ifdef __cplusplus } #endif #endif /* _INTEGER_H_ */ biosig-2.3.3/biosig4c++/t240/EnumerationDescriptiveDataSection.h0000664000175000017500000000756614105434233024476 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumerationDescriptiveDataSection_H_ #define _EnumerationDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct MetricCalEntry; /* EnumerationDescriptiveDataSection */ typedef struct EnumerationDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct EnumerationDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct EnumerationDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct EnumerationDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct EnumerationDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct EnumerationDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct EnumerationDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct EnumerationDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; struct EnumerationDescriptiveDataSection__enummeasurerange { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *enummeasurerange; BIT_STRING_t *enummeasurerangebits /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumerationDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumerationDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "MetricCalEntry.h" #endif /* _EnumerationDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/UnitsOfMeasurementCode.c0000664000175000017500000000770614105434233022246 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "UnitsOfMeasurementCode.h" int UnitsOfMeasurementCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void UnitsOfMeasurementCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int UnitsOfMeasurementCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t UnitsOfMeasurementCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t UnitsOfMeasurementCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t UnitsOfMeasurementCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t UnitsOfMeasurementCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { UnitsOfMeasurementCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_UnitsOfMeasurementCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_UnitsOfMeasurementCode = { "UnitsOfMeasurementCode", "UnitsOfMeasurementCode", UnitsOfMeasurementCode_free, UnitsOfMeasurementCode_print, UnitsOfMeasurementCode_constraint, UnitsOfMeasurementCode_decode_ber, UnitsOfMeasurementCode_encode_der, UnitsOfMeasurementCode_decode_xer, UnitsOfMeasurementCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_UnitsOfMeasurementCode_tags_1, sizeof(asn_DEF_UnitsOfMeasurementCode_tags_1) /sizeof(asn_DEF_UnitsOfMeasurementCode_tags_1[0]), /* 1 */ asn_DEF_UnitsOfMeasurementCode_tags_1, /* Same as above */ sizeof(asn_DEF_UnitsOfMeasurementCode_tags_1) /sizeof(asn_DEF_UnitsOfMeasurementCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/HandleRef.h0000664000175000017500000000141214105434233017477 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _HandleRef_H_ #define _HandleRef_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* HandleRef */ typedef INTEGER_t HandleRef_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_HandleRef; asn_struct_free_f HandleRef_free; asn_struct_print_f HandleRef_print; asn_constr_check_f HandleRef_constraint; ber_type_decoder_f HandleRef_decode_ber; der_type_encoder_f HandleRef_encode_der; xer_type_decoder_f HandleRef_decode_xer; xer_type_encoder_f HandleRef_encode_xer; #ifdef __cplusplus } #endif #endif /* _HandleRef_H_ */ biosig-2.3.3/biosig4c++/t240/INT-U32.c0000664000175000017500000000757314105434233016661 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-U32.h" int INT_U32_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(asn_INTEGER2long(st, &value)) { _ASN_CTFAIL(app_key, td, sptr, "%s: value too large (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if((value >= 0 && value <= 4294967295)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void INT_U32_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void INT_U32_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_U32_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_U32_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_U32_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_U32_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_U32_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_U32_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_U32_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_U32_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_U32_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_U32_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_U32_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_U32_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_U32 = { "INT-U32", "INT-U32", INT_U32_free, INT_U32_print, INT_U32_constraint, INT_U32_decode_ber, INT_U32_encode_der, INT_U32_decode_xer, INT_U32_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_U32_tags_1, sizeof(asn_DEF_INT_U32_tags_1) /sizeof(asn_DEF_INT_U32_tags_1[0]), /* 1 */ asn_DEF_INT_U32_tags_1, /* Same as above */ sizeof(asn_DEF_INT_U32_tags_1) /sizeof(asn_DEF_INT_U32_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/DsaRangeSpec.c0000664000175000017500000000430314105434233020143 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DsaRangeSpec.h" static asn_TYPE_member_t asn_MBR_DsaRangeSpec_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DsaRangeSpec, first_element_value), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "first-element-value" }, { ATF_NOFLAGS, 0, offsetof(struct DsaRangeSpec, last_element_value), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "last-element-value" }, }; static ber_tlv_tag_t asn_DEF_DsaRangeSpec_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DsaRangeSpec_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* first-element-value at 1131 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* last-element-value at 1133 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DsaRangeSpec_specs_1 = { sizeof(struct DsaRangeSpec), offsetof(struct DsaRangeSpec, _asn_ctx), asn_MAP_DsaRangeSpec_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DsaRangeSpec = { "DsaRangeSpec", "DsaRangeSpec", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DsaRangeSpec_tags_1, sizeof(asn_DEF_DsaRangeSpec_tags_1) /sizeof(asn_DEF_DsaRangeSpec_tags_1[0]), /* 1 */ asn_DEF_DsaRangeSpec_tags_1, /* Same as above */ sizeof(asn_DEF_DsaRangeSpec_tags_1) /sizeof(asn_DEF_DsaRangeSpec_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DsaRangeSpec_1, 2, /* Elements count */ &asn_SPC_DsaRangeSpec_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/HealthCareProviderSection.c0000664000175000017500000001232014105434233022702 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "HealthCareProviderSection.h" static asn_TYPE_member_t asn_MBR_healthcareprofessionals_6[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_HealthCareProfessionalSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_healthcareprofessionals_tags_6[] = { (ASN_TAG_CLASS_APPLICATION | (7008 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_healthcareprofessionals_specs_6 = { sizeof(struct HealthCareProviderSection__healthcareprofessionals), offsetof(struct HealthCareProviderSection__healthcareprofessionals, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_healthcareprofessionals_6 = { "healthcareprofessionals", "healthcareprofessionals", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_healthcareprofessionals_tags_6, sizeof(asn_DEF_healthcareprofessionals_tags_6) /sizeof(asn_DEF_healthcareprofessionals_tags_6[0]) - 1, /* 1 */ asn_DEF_healthcareprofessionals_tags_6, /* Same as above */ sizeof(asn_DEF_healthcareprofessionals_tags_6) /sizeof(asn_DEF_healthcareprofessionals_tags_6[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_healthcareprofessionals_6, 1, /* Single element */ &asn_SPC_healthcareprofessionals_specs_6 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_HealthCareProviderSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct HealthCareProviderSection, identification), (ASN_TAG_CLASS_APPLICATION | (6008 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HealthCareProviderId, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "identification" }, { ATF_NOFLAGS, 0, offsetof(struct HealthCareProviderSection, name), (ASN_TAG_CLASS_APPLICATION | (6009 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "name" }, { ATF_POINTER, 3, offsetof(struct HealthCareProviderSection, address), (ASN_TAG_CLASS_APPLICATION | (6010 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Address, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "address" }, { ATF_POINTER, 2, offsetof(struct HealthCareProviderSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_POINTER, 1, offsetof(struct HealthCareProviderSection, healthcareprofessionals), (ASN_TAG_CLASS_APPLICATION | (7008 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_healthcareprofessionals_6, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "healthcareprofessionals" }, }; static ber_tlv_tag_t asn_DEF_HealthCareProviderSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_HealthCareProviderSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6008 << 2)), 0, 0, 0 }, /* identification at 285 */ { (ASN_TAG_CLASS_APPLICATION | (6009 << 2)), 1, 0, 0 }, /* name at 288 */ { (ASN_TAG_CLASS_APPLICATION | (6010 << 2)), 2, 0, 0 }, /* address at 291 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 3, 0, 0 }, /* placeholder at 294 */ { (ASN_TAG_CLASS_APPLICATION | (7008 << 2)), 4, 0, 0 } /* healthcareprofessionals at 298 */ }; static asn_SEQUENCE_specifics_t asn_SPC_HealthCareProviderSection_specs_1 = { sizeof(struct HealthCareProviderSection), offsetof(struct HealthCareProviderSection, _asn_ctx), asn_MAP_HealthCareProviderSection_tag2el_1, 5, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_HealthCareProviderSection = { "HealthCareProviderSection", "HealthCareProviderSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_HealthCareProviderSection_tags_1, sizeof(asn_DEF_HealthCareProviderSection_tags_1) /sizeof(asn_DEF_HealthCareProviderSection_tags_1[0]), /* 1 */ asn_DEF_HealthCareProviderSection_tags_1, /* Same as above */ sizeof(asn_DEF_HealthCareProviderSection_tags_1) /sizeof(asn_DEF_HealthCareProviderSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_HealthCareProviderSection_1, 5, /* Elements count */ &asn_SPC_HealthCareProviderSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/Handle.h0000664000175000017500000000134314105434233017045 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _Handle_H_ #define _Handle_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Handle */ typedef INTEGER_t Handle_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Handle; asn_struct_free_f Handle_free; asn_struct_print_f Handle_print; asn_constr_check_f Handle_constraint; ber_type_decoder_f Handle_decode_ber; der_type_encoder_f Handle_encode_der; xer_type_decoder_f Handle_decode_xer; xer_type_encoder_f Handle_encode_xer; #ifdef __cplusplus } #endif #endif /* _Handle_H_ */ biosig-2.3.3/biosig4c++/t240/constr_TYPE.h0000664000175000017500000001505614105434233020031 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * This file contains the declaration structure called "ASN.1 Type Definition", * which holds all information necessary for encoding and decoding routines. * This structure even contains pointer to these encoding and decoding routines * for each defined ASN.1 type. */ #ifndef _CONSTR_TYPE_H_ #define _CONSTR_TYPE_H_ #include #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ struct asn_TYPE_member_s; /* Forward declaration */ /* * This type provides the context information for various ASN.1 routines, * primarily ones doing decoding. A member _asn_ctx of this type must be * included into certain target language's structures, such as compound types. */ typedef struct asn_struct_ctx_s { short phase; /* Decoding phase */ short step; /* Elementary step of a phase */ int context; /* Other context information */ void *ptr; /* Decoder-specific stuff (stack elements) */ ber_tlv_len_t left; /* Number of bytes left, -1 for indefinite */ } asn_struct_ctx_t; #include /* Basic Encoding Rules decoder */ #include /* Distinguished Encoding Rules encoder */ #include /* Decoder of XER (XML, text) */ #include /* Encoder into XER (XML, text) */ #include /* Packet Encoding Rules decoder */ #include /* Packet Encoding Rules encoder */ #include /* Subtype constraints support */ /* * Free the structure according to its specification. * If (free_contents_only) is set, the wrapper structure itself (struct_ptr) * will not be freed. (It may be useful in case the structure is allocated * statically or arranged on the stack, yet its elements are allocated * dynamically.) */ typedef void (asn_struct_free_f)( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, int free_contents_only); #define ASN_STRUCT_FREE(asn_DEF, ptr) (asn_DEF).free_struct(&(asn_DEF),ptr,0) #define ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF, ptr) \ (asn_DEF).free_struct(&(asn_DEF),ptr,1) /* * Print the structure according to its specification. */ typedef int (asn_struct_print_f)( struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, int level, /* Indentation level */ asn_app_consume_bytes_f *callback, void *app_key); /* * Return the outmost tag of the type. * If the type is untagged CHOICE, the dynamic operation is performed. * NOTE: This function pointer type is only useful internally. * Do not use it in your application. */ typedef ber_tlv_tag_t (asn_outmost_tag_f)( struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag); /* The instance of the above function type; used internally. */ asn_outmost_tag_f asn_TYPE_outmost_tag; /* * The definitive description of the destination language's structure. */ typedef struct asn_TYPE_descriptor_s { char *name; /* A name of the ASN.1 type. "" in some cases. */ char *xml_tag; /* Name used in XML tag */ /* * Generalized functions for dealing with the specific type. * May be directly invoked by applications. */ asn_struct_free_f *free_struct; /* Free the structure */ asn_struct_print_f *print_struct; /* Human readable output */ asn_constr_check_f *check_constraints; /* Constraints validator */ ber_type_decoder_f *ber_decoder; /* Generic BER decoder */ der_type_encoder_f *der_encoder; /* Canonical DER encoder */ xer_type_decoder_f *xer_decoder; /* Generic XER decoder */ xer_type_encoder_f *xer_encoder; /* [Canonical] XER encoder */ per_type_decoder_f *uper_decoder; /* Unaligned PER decoder */ per_type_encoder_f *uper_encoder; /* Unaligned PER encoder */ /*********************************************************************** * Internally useful members. Not to be used by applications directly. * **********************************************************************/ /* * Tags that are expected to occur. */ asn_outmost_tag_f *outmost_tag; /* */ ber_tlv_tag_t *tags; /* Effective tags sequence for this type */ int tags_count; /* Number of tags which are expected */ ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */ int all_tags_count; /* Number of tags */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */ /* * An ASN.1 production type members (members of SEQUENCE, SET, CHOICE). */ struct asn_TYPE_member_s *elements; int elements_count; /* * Additional information describing the type, used by appropriate * functions above. */ void *specifics; } asn_TYPE_descriptor_t; /* * This type describes an element of the constructed type, * i.e. SEQUENCE, SET, CHOICE, etc. */ enum asn_TYPE_flags_e { ATF_NOFLAGS, ATF_POINTER = 0x01, /* Represented by the pointer */ ATF_OPEN_TYPE = 0x02 /* ANY type, without meaningful tag */ }; typedef struct asn_TYPE_member_s { enum asn_TYPE_flags_e flags; /* Element's presentation flags */ int optional; /* Following optional members, including current */ int memb_offset; /* Offset of the element */ ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */ asn_TYPE_descriptor_t *type; /* Member type descriptor */ asn_constr_check_f *memb_constraints; /* Constraints validator */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */ int (*default_value)(int setval, void **sptr); /* DEFAULT */ char *name; /* ASN.1 identifier of the element */ } asn_TYPE_member_t; /* * BER tag to element number mapping. */ typedef struct asn_TYPE_tag2member_s { ber_tlv_tag_t el_tag; /* Outmost tag of the member */ int el_no; /* Index of the associated member, base 0 */ int toff_first; /* First occurence of the el_tag, relative */ int toff_last; /* Last occurence of the el_tag, relatvie */ } asn_TYPE_tag2member_t; /* * This function is a wrapper around (td)->print_struct, which prints out * the contents of the target language's structure (struct_ptr) into the * file pointer (stream) in human readable form. * RETURN VALUES: * 0: The structure is printed. * -1: Problem dumping the structure. * (See also xer_fprint() in xer_encoder.h) */ int asn_fprint(FILE *stream, /* Destination stream descriptor */ asn_TYPE_descriptor_t *td, /* ASN.1 type descriptor */ const void *struct_ptr); /* Structure to be printed */ #ifdef __cplusplus } #endif #endif /* _CONSTR_TYPE_H_ */ biosig-2.3.3/biosig4c++/t240/MetricStatus.h0000664000175000017500000000205214105434233020277 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricStatus_H_ #define _MetricStatus_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MetricStatus { MetricStatus_metric_off = 0, MetricStatus_metric_not_ready = 1, MetricStatus_metric_standby = 2, MetricStatus_metric_transduc_discon = 8, MetricStatus_metric_hw_discon = 9 } e_MetricStatus; /* MetricStatus */ typedef BIT_STRING_t MetricStatus_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricStatus; asn_struct_free_f MetricStatus_free; asn_struct_print_f MetricStatus_print; asn_constr_check_f MetricStatus_constraint; ber_type_decoder_f MetricStatus_decode_ber; der_type_encoder_f MetricStatus_encode_der; xer_type_decoder_f MetricStatus_decode_xer; xer_type_encoder_f MetricStatus_encode_xer; #ifdef __cplusplus } #endif #endif /* _MetricStatus_H_ */ biosig-2.3.3/biosig4c++/t240/LimitSpecEntry.h0000664000175000017500000000160114105434233020562 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _LimitSpecEntry_H_ #define _LimitSpecEntry_H_ #include /* Including external dependencies */ #include "HandleRef.h" #include "MetricsCode.h" #include "UnitCode.h" #include "CurLimAlStat.h" #include "AbsoluteRange.h" #include #ifdef __cplusplus extern "C" { #endif /* LimitSpecEntry */ typedef struct LimitSpecEntry { HandleRef_t sectionhandle; MetricsCode_t alsourceid; UnitCode_t unitcode; CurLimAlStat_t limalstat; AbsoluteRange_t limalval; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } LimitSpecEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_LimitSpecEntry; #ifdef __cplusplus } #endif #endif /* _LimitSpecEntry_H_ */ biosig-2.3.3/biosig4c++/t240/Placeholder.c0000664000175000017500000000733414105434233020075 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Placeholder.h" int Placeholder_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_OCTET_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using OCTET_STRING, * so here we adjust the DEF accordingly. */ static void Placeholder_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_OCTET_STRING.free_struct; td->print_struct = asn_DEF_OCTET_STRING.print_struct; td->ber_decoder = asn_DEF_OCTET_STRING.ber_decoder; td->der_encoder = asn_DEF_OCTET_STRING.der_encoder; td->xer_decoder = asn_DEF_OCTET_STRING.xer_decoder; td->xer_encoder = asn_DEF_OCTET_STRING.xer_encoder; td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder; td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_OCTET_STRING.per_constraints; td->elements = asn_DEF_OCTET_STRING.elements; td->elements_count = asn_DEF_OCTET_STRING.elements_count; td->specifics = asn_DEF_OCTET_STRING.specifics; } void Placeholder_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Placeholder_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int Placeholder_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Placeholder_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t Placeholder_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { Placeholder_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t Placeholder_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Placeholder_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t Placeholder_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { Placeholder_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t Placeholder_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Placeholder_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_Placeholder_tags_1[] = { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) }; asn_TYPE_descriptor_t asn_DEF_Placeholder = { "Placeholder", "Placeholder", Placeholder_free, Placeholder_print, Placeholder_constraint, Placeholder_decode_ber, Placeholder_encode_der, Placeholder_decode_xer, Placeholder_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Placeholder_tags_1, sizeof(asn_DEF_Placeholder_tags_1) /sizeof(asn_DEF_Placeholder_tags_1[0]) - 1, /* 1 */ asn_DEF_Placeholder_tags_1, /* Same as above */ sizeof(asn_DEF_Placeholder_tags_1) /sizeof(asn_DEF_Placeholder_tags_1[0]), /* 2 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MedicalDeviceSystemSection.h0000664000175000017500000000450514105434233023065 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MedicalDeviceSystemSection_H_ #define _MedicalDeviceSystemSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "DeviceCode.h" #include "SystemModel.h" #include "FEFString.h" #include #include "AbsoluteTime.h" #include "PrivateCode.h" #include "ApplicationArea.h" #include "PowerStatus.h" #include "LineFrequency.h" #include "Placeholder.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct MedicalDeviceComponents; struct SystemSpecEntry; struct ProdSpecEntry; /* MedicalDeviceSystemSection */ typedef struct MedicalDeviceSystemSection { Handle_t handle; DeviceCode_t systemtype; SystemModel_t systemmodel; FEFString_t systemid; INTEGER_t *compatibilityid /* OPTIONAL */; INTEGER_t nomenclatureversion; AbsoluteTime_t requirednomenclatureversion; AbsoluteTime_t usednomenclatureversion; struct MedicalDeviceSystemSection__systemspecification { A_SEQUENCE_OF(struct SystemSpecEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *systemspecification; struct MedicalDeviceSystemSection__productionspecification { A_SEQUENCE_OF(struct ProdSpecEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *productionspecification; FEFString_t *bedlabel /* OPTIONAL */; FEFString_t *softid /* OPTIONAL */; PrivateCode_t *operatingmode /* OPTIONAL */; ApplicationArea_t *applicationarea /* OPTIONAL */; PowerStatus_t *powerstatus /* OPTIONAL */; INTEGER_t *altitude /* OPTIONAL */; LineFrequency_t *linefrequency /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; struct MedicalDeviceComponents *components; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MedicalDeviceSystemSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MedicalDeviceSystemSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "MedicalDeviceComponents.h" #include "SystemSpecEntry.h" #include "ProdSpecEntry.h" #endif /* _MedicalDeviceSystemSection_H_ */ biosig-2.3.3/biosig4c++/t240/AlertCondition.h0000664000175000017500000000176614105434233020601 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AlertCondition_H_ #define _AlertCondition_H_ #include /* Including external dependencies */ #include "HandleRef.h" #include "AlertControls.h" #include "AlertFlags.h" #include "MetricsCode.h" #include "AlertCode.h" #include "AlertType.h" #include "PrivateCode.h" #include #ifdef __cplusplus extern "C" { #endif /* AlertCondition */ typedef struct AlertCondition { HandleRef_t objreference; AlertControls_t controls; AlertFlags_t alertflags; MetricsCode_t alertsource; AlertCode_t alertcode; AlertType_t alerttype; PrivateCode_t *alertinfoid /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } AlertCondition_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AlertCondition; #ifdef __cplusplus } #endif #endif /* _AlertCondition_H_ */ biosig-2.3.3/biosig4c++/t240/DsaRangeSpec.h0000664000175000017500000000131114105434233020144 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DsaRangeSpec_H_ #define _DsaRangeSpec_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include #ifdef __cplusplus extern "C" { #endif /* DsaRangeSpec */ typedef struct DsaRangeSpec { FEFFloat_t first_element_value; FEFFloat_t last_element_value; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DsaRangeSpec_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DsaRangeSpec; #ifdef __cplusplus } #endif #endif /* _DsaRangeSpec_H_ */ biosig-2.3.3/biosig4c++/t240/asn_internal.h0000664000175000017500000000671714105434233020341 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Declarations internally useful for the ASN.1 support code. */ #ifndef _ASN_INTERNAL_H_ #define _ASN_INTERNAL_H_ #include "asn_application.h" /* Application-visible API */ #ifndef __NO_ASSERT_H__ /* Include assert.h only for internal use. */ #include /* for assert() macro */ #endif #ifdef __cplusplus extern "C" { #endif /* Environment version might be used to avoid running with the old library */ #define ASN1C_ENVIRONMENT_VERSION 922 /* Compile-time version */ int get_asn1c_environment_version(void); /* Run-time version */ #define CALLOC(nmemb, size) calloc(nmemb, size) #define MALLOC(size) malloc(size) #define REALLOC(oldptr, size) realloc(oldptr, size) #define FREEMEM(ptr) free(ptr) /* * A macro for debugging the ASN.1 internals. * You may enable or override it. */ #ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */ #if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */ #ifdef __GNUC__ #ifdef ASN_THREAD_SAFE #define asn_debug_indent 0 #else /* !ASN_THREAD_SAFE */ int asn_debug_indent; #endif /* ASN_THREAD_SAFE */ #define ASN_DEBUG(fmt, args...) do { \ int adi = asn_debug_indent; \ while(adi--) fprintf(stderr, " "); \ fprintf(stderr, fmt, ##args); \ fprintf(stderr, " (%s:%d)\n", \ __FILE__, __LINE__); \ } while(0) #else /* !__GNUC__ */ void ASN_DEBUG_f(const char *fmt, ...); #define ASN_DEBUG ASN_DEBUG_f #endif /* __GNUC__ */ #else /* EMIT_ASN_DEBUG != 1 */ static inline void ASN_DEBUG(const char *fmt, ...) { (void)fmt; } #endif /* EMIT_ASN_DEBUG */ #endif /* ASN_DEBUG */ /* * Invoke the application-supplied callback and fail, if something is wrong. */ #define __ASN_E_cbc(buf, size) (cb((buf), (size), app_key) < 0) #define _ASN_E_CALLBACK(foo) do { \ if(foo) goto cb_failed; \ } while(0) #define _ASN_CALLBACK(buf, size) \ _ASN_E_CALLBACK(__ASN_E_cbc(buf, size)) #define _ASN_CALLBACK2(buf1, size1, buf2, size2) \ _ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) || __ASN_E_cbc(buf2, size2)) #define _ASN_CALLBACK3(buf1, size1, buf2, size2, buf3, size3) \ _ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) \ || __ASN_E_cbc(buf2, size2) \ || __ASN_E_cbc(buf3, size3)) #define _i_ASN_TEXT_INDENT(nl, level) do { \ int __level = (level); \ int __nl = ((nl) != 0); \ int __i; \ if(__nl) _ASN_CALLBACK("\n", 1); \ if(__level < 0) __level = 0; \ for(__i = 0; __i < __level; __i++) \ _ASN_CALLBACK(" ", 4); \ er.encoded += __nl + 4 * __level; \ } while(0) #define _i_INDENT(nl) do { \ int __i; \ if((nl) && cb("\n", 1, app_key) < 0) return -1; \ for(__i = 0; __i < ilevel; __i++) \ if(cb(" ", 4, app_key) < 0) return -1; \ } while(0) /* * Check stack against overflow, if limit is set. */ #define _ASN_DEFAULT_STACK_MAX (30000) static inline int _ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) { if(ctx && ctx->max_stack_size) { /* ctx MUST be allocated on the stack */ ptrdiff_t usedstack = ((char *)ctx - (char *)&ctx); if(usedstack > 0) usedstack = -usedstack; /* grows up! */ /* double negative required to avoid int wrap-around */ if(usedstack < -(ptrdiff_t)ctx->max_stack_size) { ASN_DEBUG("Stack limit %ld reached", (long)ctx->max_stack_size); return -1; } } return 0; } #ifdef __cplusplus } #endif #endif /* _ASN_INTERNAL_H_ */ biosig-2.3.3/biosig4c++/t240/PatientSex.c0000664000175000017500000000711514105434233017734 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PatientSex.h" int PatientSex_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void PatientSex_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void PatientSex_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { PatientSex_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int PatientSex_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { PatientSex_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t PatientSex_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { PatientSex_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t PatientSex_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { PatientSex_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t PatientSex_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { PatientSex_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t PatientSex_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { PatientSex_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_PatientSex_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_PatientSex = { "PatientSex", "PatientSex", PatientSex_free, PatientSex_print, PatientSex_constraint, PatientSex_decode_ber, PatientSex_encode_der, PatientSex_decode_xer, PatientSex_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PatientSex_tags_1, sizeof(asn_DEF_PatientSex_tags_1) /sizeof(asn_DEF_PatientSex_tags_1[0]), /* 1 */ asn_DEF_PatientSex_tags_1, /* Same as above */ sizeof(asn_DEF_PatientSex_tags_1) /sizeof(asn_DEF_PatientSex_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/HealthCareProfessionalSection.h0000664000175000017500000000302214105434233023560 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _HealthCareProfessionalSection_H_ #define _HealthCareProfessionalSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "FEFString.h" #include "Placeholder.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct PersonNameGroup; struct ExtNomenRef; struct Authorization; /* HealthCareProfessionalSection */ typedef struct HealthCareProfessionalSection { Handle_t handle; FEFString_t *ungroupedname /* OPTIONAL */; struct PersonNameGroup *characternamegroup /* OPTIONAL */; struct PersonNameGroup *ideographicnamegroup /* OPTIONAL */; struct PersonNameGroup *phoneticnamegroup /* OPTIONAL */; FEFString_t *identification /* OPTIONAL */; struct ExtNomenRef *identificationcode /* OPTIONAL */; struct Authorization *authorization_level /* OPTIONAL */; FEFString_t *function /* OPTIONAL */; struct ExtNomenRef *functioncode /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } HealthCareProfessionalSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_HealthCareProfessionalSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "PersonNameGroup.h" #include "ExtNomenRef.h" #include "Authorization.h" #endif /* _HealthCareProfessionalSection_H_ */ biosig-2.3.3/biosig4c++/t240/TimeSampleArrayDescriptiveDataSection.h0000664000175000017500000001170714105434233025237 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _TimeSampleArrayDescriptiveDataSection_H_ #define _TimeSampleArrayDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include "SaSpec.h" #include "ScaleRangeSpec.h" #include "FEFFloat.h" #include "Fraction.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct AbsoluteRange; struct SaSignalFrequency; struct MetricCalEntry; struct SaGridEntry; struct SaCalData; struct SaFilterEntry; /* TimeSampleArrayDescriptiveDataSection */ typedef struct TimeSampleArrayDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct TimeSampleArrayDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct TimeSampleArrayDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct TimeSampleArrayDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct TimeSampleArrayDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct TimeSampleArrayDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct TimeSampleArrayDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct TimeSampleArrayDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; SaSpec_t saspecification; PrivateCode_t *compression /* OPTIONAL */; ScaleRangeSpec_t scaleandrangespec; struct AbsoluteRange *saphysiologicalrange /* OPTIONAL */; struct TimeSampleArrayDescriptiveDataSection__visualgrid { A_SEQUENCE_OF(struct SaGridEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *visualgrid; struct TimeSampleArrayDescriptiveDataSection__sacalibrationdata { A_SEQUENCE_OF(struct SaCalData) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *sacalibrationdata; struct TimeSampleArrayDescriptiveDataSection__filterspecification { A_SEQUENCE_OF(struct SaFilterEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *filterspecification; struct SaSignalFrequency *sasignalfrequency /* OPTIONAL */; FEFFloat_t *sameasureresolution /* OPTIONAL */; Fraction_t sampleperiod; struct MetricMeasure *sweepspeed /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } TimeSampleArrayDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_TimeSampleArrayDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "AbsoluteRange.h" #include "SaSignalFrequency.h" #include "MetricCalEntry.h" #include "SaGridEntry.h" #include "SaCalData.h" #include "SaFilterEntry.h" #endif /* _TimeSampleArrayDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/EnumObsValue.h0000664000175000017500000000145014105434233020216 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumObsValue_H_ #define _EnumObsValue_H_ #include /* Including external dependencies */ #include "MetricsCode.h" #include "MeasurementStatus.h" #include "EnumVal.h" #include #ifdef __cplusplus extern "C" { #endif /* EnumObsValue */ typedef struct EnumObsValue { MetricsCode_t *metric_id /* OPTIONAL */; MeasurementStatus_t *state /* DEFAULT {} */; EnumVal_t value; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumObsValue_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumObsValue; #ifdef __cplusplus } #endif #endif /* _EnumObsValue_H_ */ biosig-2.3.3/biosig4c++/t240/SaCalData.c0000664000175000017500000000552714105434233017432 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaCalData.h" static asn_TYPE_member_t asn_MBR_SaCalData_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SaCalData, lowerabsolutevalue), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "lowerabsolutevalue" }, { ATF_NOFLAGS, 0, offsetof(struct SaCalData, upperabsolutevalue), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "upperabsolutevalue" }, { ATF_NOFLAGS, 0, offsetof(struct SaCalData, increment), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "increment" }, { ATF_NOFLAGS, 0, offsetof(struct SaCalData, cal_type), (ASN_TAG_CLASS_CONTEXT | (6 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaCalDataType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "cal-type" }, }; static ber_tlv_tag_t asn_DEF_SaCalData_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SaCalData_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* lowerabsolutevalue at 1065 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* upperabsolutevalue at 1066 */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 2, 0, 0 }, /* increment at 1067 */ { (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 3, 0, 0 } /* cal-type at 1070 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SaCalData_specs_1 = { sizeof(struct SaCalData), offsetof(struct SaCalData, _asn_ctx), asn_MAP_SaCalData_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SaCalData = { "SaCalData", "SaCalData", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaCalData_tags_1, sizeof(asn_DEF_SaCalData_tags_1) /sizeof(asn_DEF_SaCalData_tags_1[0]), /* 1 */ asn_DEF_SaCalData_tags_1, /* Same as above */ sizeof(asn_DEF_SaCalData_tags_1) /sizeof(asn_DEF_SaCalData_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SaCalData_1, 4, /* Elements count */ &asn_SPC_SaCalData_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/INT-U32.h0000664000175000017500000000136014105434233016652 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_U32_H_ #define _INT_U32_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-U32 */ typedef INTEGER_t INT_U32_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_U32; asn_struct_free_f INT_U32_free; asn_struct_print_f INT_U32_print; asn_constr_check_f INT_U32_constraint; ber_type_decoder_f INT_U32_decode_ber; der_type_encoder_f INT_U32_encode_der; xer_type_decoder_f INT_U32_decode_xer; xer_type_encoder_f INT_U32_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_U32_H_ */ biosig-2.3.3/biosig4c++/t240/per_support.c0000664000175000017500000002312314105434233020227 0ustar schloeglschloegl/* * Copyright (c) 2005, 2006, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include char * per_data_string(asn_per_data_t *pd) { static char buf[2][32]; static int n; n = (n+1) % 2; snprintf(buf[n], sizeof(buf), "{m=%d span %+d[%d..%d] (%d)}", pd->moved, (((int)pd->buffer) & 0xf), pd->nboff, pd->nbits, pd->nbits - pd->nboff); return buf[n]; } void per_get_undo(asn_per_data_t *pd, int nbits) { if((ssize_t)pd->nboff < nbits) { assert((ssize_t)pd->nboff < nbits); } else { pd->nboff -= nbits; pd->moved -= nbits; } } /* * Extract a small number of bits (<= 31) from the specified PER data pointer. */ int32_t per_get_few_bits(asn_per_data_t *pd, int nbits) { size_t off; /* Next after last bit offset */ ssize_t nleft; /* Number of bits left in this stream */ uint32_t accum; const uint8_t *buf; if(nbits < 0) return -1; nleft = pd->nbits - pd->nboff; if(nbits > nleft) { int32_t tailv, vhead; if(!pd->refill || nbits > 31) return -1; /* Accumulate unused bytes before refill */ ASN_DEBUG("Obtain the rest %d bits (want %d)", nleft, nbits); tailv = per_get_few_bits(pd, nleft); if(tailv < 0) return -1; /* Refill (replace pd contents with new data) */ if(pd->refill(pd)) return -1; nbits -= nleft; vhead = per_get_few_bits(pd, nbits); /* Combine the rest of previous pd with the head of new one */ tailv = (tailv << nbits) | vhead; /* Could == -1 */ return tailv; } /* * Normalize position indicator. */ if(pd->nboff >= 8) { pd->buffer += (pd->nboff >> 3); pd->nbits -= (pd->nboff & ~0x07); pd->nboff &= 0x07; } pd->moved += nbits; pd->nboff += nbits; off = pd->nboff; buf = pd->buffer; /* * Extract specified number of bits. */ if(off <= 8) accum = nbits ? (buf[0]) >> (8 - off) : 0; else if(off <= 16) accum = ((buf[0] << 8) + buf[1]) >> (16 - off); else if(off <= 24) accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); else if(off <= 31) accum = ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3])) >> (32 - off); else if(nbits <= 31) { asn_per_data_t tpd = *pd; /* Here are we with our 31-bits limit plus 1..7 bits offset. */ per_get_undo(&tpd, nbits); /* The number of available bits in the stream allow * for the following operations to take place without * invoking the ->refill() function */ accum = per_get_few_bits(&tpd, nbits - 24) << 24; accum |= per_get_few_bits(&tpd, 24); } else { per_get_undo(pd, nbits); return -1; } accum &= (((uint32_t)1 << nbits) - 1); ASN_DEBUG(" [PER got %2d<=%2d bits => span %d %+d[%d..%d]:%02x (%d) => 0x%x]", nbits, nleft, pd->moved, (((int)pd->buffer) & 0xf), pd->nboff, pd->nbits, pd->buffer[0], pd->nbits - pd->nboff, (int)accum); return accum; } /* * Extract a large number of bits from the specified PER data pointer. */ int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int alright, int nbits) { int32_t value; if(alright && (nbits & 7)) { /* Perform right alignment of a first few bits */ value = per_get_few_bits(pd, nbits & 0x07); if(value < 0) return -1; *dst++ = value; /* value is already right-aligned */ nbits &= ~7; } while(nbits) { if(nbits >= 24) { value = per_get_few_bits(pd, 24); if(value < 0) return -1; *(dst++) = value >> 16; *(dst++) = value >> 8; *(dst++) = value; nbits -= 24; } else { value = per_get_few_bits(pd, nbits); if(value < 0) return -1; if(nbits & 7) { /* implies left alignment */ value <<= 8 - (nbits & 7), nbits += 8 - (nbits & 7); if(nbits > 24) *dst++ = value >> 24; } if(nbits > 16) *dst++ = value >> 16; if(nbits > 8) *dst++ = value >> 8; *dst++ = value; break; } } return 0; } /* * Get the length "n" from the stream. */ ssize_t uper_get_length(asn_per_data_t *pd, int ebits, int *repeat) { ssize_t value; *repeat = 0; if(ebits >= 0) return per_get_few_bits(pd, ebits); value = per_get_few_bits(pd, 8); if(value < 0) return -1; if((value & 128) == 0) /* #10.9.3.6 */ return (value & 0x7F); if((value & 64) == 0) { /* #10.9.3.7 */ value = ((value & 63) << 8) | per_get_few_bits(pd, 8); if(value < 0) return -1; return value; } value &= 63; /* this is "m" from X.691, #10.9.3.8 */ if(value < 1 || value > 4) return -1; *repeat = 1; return (16384 * value); } /* * Get the normally small length "n". * This procedure used to decode length of extensions bit-maps * for SET and SEQUENCE types. */ ssize_t uper_get_nslength(asn_per_data_t *pd) { ssize_t length; ASN_DEBUG("Getting normally small length"); if(per_get_few_bits(pd, 1) == 0) { length = per_get_few_bits(pd, 6) + 1; if(length <= 0) return -1; ASN_DEBUG("l=%d", length); return length; } else { int repeat; length = uper_get_length(pd, -1, &repeat); if(length >= 0 && !repeat) return length; return -1; /* Error, or do not support >16K extensions */ } } /* * Get the normally small non-negative whole number. * X.691, #10.6 */ ssize_t uper_get_nsnnwn(asn_per_data_t *pd) { ssize_t value; value = per_get_few_bits(pd, 7); if(value & 64) { /* implicit (value < 0) */ value &= 63; value <<= 2; value |= per_get_few_bits(pd, 2); if(value & 128) /* implicit (value < 0) */ return -1; if(value == 0) return 0; if(value >= 3) return -1; value = per_get_few_bits(pd, 8 * value); return value; } return value; } /* * Put the normally small non-negative whole number. * X.691, #10.6 */ int uper_put_nsnnwn(asn_per_outp_t *po, int n) { int bytes; if(n <= 63) { if(n < 0) return -1; return per_put_few_bits(po, n, 7); } if(n < 256) bytes = 1; else if(n < 65536) bytes = 2; else if(n < 256 * 65536) bytes = 3; else return -1; /* This is not a "normally small" value */ if(per_put_few_bits(po, bytes, 8)) return -1; return per_put_few_bits(po, n, 8 * bytes); } /* * Put a small number of bits (<= 31). */ int per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) { size_t off; /* Next after last bit offset */ size_t omsk; /* Existing last byte meaningful bits mask */ uint8_t *buf; if(obits <= 0 || obits >= 32) return obits ? -1 : 0; ASN_DEBUG("[PER put %d bits %x to %p+%d bits]", obits, (int)bits, po->buffer, po->nboff); /* * Normalize position indicator. */ if(po->nboff >= 8) { po->buffer += (po->nboff >> 3); po->nbits -= (po->nboff & ~0x07); po->nboff &= 0x07; } /* * Flush whole-bytes output, if necessary. */ if(po->nboff + obits > po->nbits) { int complete_bytes = (po->buffer - po->tmpspace); ASN_DEBUG("[PER output %d complete + %d]", complete_bytes, po->flushed_bytes); if(po->outper(po->tmpspace, complete_bytes, po->op_key) < 0) return -1; if(po->nboff) po->tmpspace[0] = po->buffer[0]; po->buffer = po->tmpspace; po->nbits = 8 * sizeof(po->tmpspace); po->flushed_bytes += complete_bytes; } /* * Now, due to sizeof(tmpspace), we are guaranteed large enough space. */ buf = po->buffer; omsk = ~((1 << (8 - po->nboff)) - 1); off = (po->nboff += obits); /* Clear data of debris before meaningful bits */ bits &= (((uint32_t)1 << obits) - 1); ASN_DEBUG("[PER out %d %u/%x (t=%d,o=%d) %x&%x=%x]", obits, (int)bits, (int)bits, po->nboff - obits, off, buf[0], omsk&0xff, buf[0] & omsk); if(off <= 8) /* Completely within 1 byte */ bits <<= (8 - off), buf[0] = (buf[0] & omsk) | bits; else if(off <= 16) bits <<= (16 - off), buf[0] = (buf[0] & omsk) | (bits >> 8), buf[1] = bits; else if(off <= 24) bits <<= (24 - off), buf[0] = (buf[0] & omsk) | (bits >> 16), buf[1] = bits >> 8, buf[2] = bits; else if(off <= 31) bits <<= (32 - off), buf[0] = (buf[0] & omsk) | (bits >> 24), buf[1] = bits >> 16, buf[2] = bits >> 8, buf[3] = bits; else { ASN_DEBUG("->[PER out split %d]", obits); per_put_few_bits(po, bits >> 8, 24); per_put_few_bits(po, bits, obits - 24); ASN_DEBUG("<-[PER out split %d]", obits); } ASN_DEBUG("[PER out %u/%x => %02x buf+%d]", (int)bits, (int)bits, buf[0], po->buffer - po->tmpspace); return 0; } /* * Output a large number of bits. */ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int nbits) { while(nbits) { uint32_t value; if(nbits >= 24) { value = (src[0] << 16) | (src[1] << 8) | src[2]; src += 3; nbits -= 24; if(per_put_few_bits(po, value, 24)) return -1; } else { value = src[0]; if(nbits > 8) value = (value << 8) | src[1]; if(nbits > 16) value = (value << 8) | src[2]; if(nbits & 0x07) value >>= (8 - (nbits & 0x07)); if(per_put_few_bits(po, value, nbits)) return -1; break; } } return 0; } /* * Put the length "n" (or part of it) into the stream. */ ssize_t uper_put_length(asn_per_outp_t *po, size_t length) { if(length <= 127) /* #10.9.3.6 */ return per_put_few_bits(po, length, 8) ? -1 : (ssize_t)length; else if(length < 16384) /* #10.9.3.7 */ return per_put_few_bits(po, length|0x8000, 16) ? -1 : (ssize_t)length; length >>= 14; if(length > 4) length = 4; return per_put_few_bits(po, 0xC0 | length, 8) ? -1 : (ssize_t)(length << 14); } /* * Put the normally small length "n" into the stream. * This procedure used to encode length of extensions bit-maps * for SET and SEQUENCE types. */ int uper_put_nslength(asn_per_outp_t *po, size_t length) { if(length <= 64) { /* #10.9.3.4 */ if(length == 0) return -1; return per_put_few_bits(po, length-1, 7) ? -1 : 0; } else { if(uper_put_length(po, length) != (ssize_t)length) { /* This might happen in case of >16K extensions */ return -1; } } return 0; } biosig-2.3.3/biosig4c++/t240/HighResRelativeTime.h0000664000175000017500000000161414105434233021517 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _HighResRelativeTime_H_ #define _HighResRelativeTime_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* HighResRelativeTime */ typedef INTEGER_t HighResRelativeTime_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_HighResRelativeTime; asn_struct_free_f HighResRelativeTime_free; asn_struct_print_f HighResRelativeTime_print; asn_constr_check_f HighResRelativeTime_constraint; ber_type_decoder_f HighResRelativeTime_decode_ber; der_type_encoder_f HighResRelativeTime_encode_der; xer_type_decoder_f HighResRelativeTime_decode_xer; xer_type_encoder_f HighResRelativeTime_encode_xer; #ifdef __cplusplus } #endif #endif /* _HighResRelativeTime_H_ */ biosig-2.3.3/biosig4c++/t240/ParameterGroupCode.c0000664000175000017500000000750614105434233021404 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ParameterGroupCode.h" int ParameterGroupCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void ParameterGroupCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void ParameterGroupCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int ParameterGroupCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t ParameterGroupCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t ParameterGroupCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t ParameterGroupCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t ParameterGroupCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { ParameterGroupCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_ParameterGroupCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_ParameterGroupCode = { "ParameterGroupCode", "ParameterGroupCode", ParameterGroupCode_free, ParameterGroupCode_print, ParameterGroupCode_constraint, ParameterGroupCode_decode_ber, ParameterGroupCode_encode_der, ParameterGroupCode_decode_xer, ParameterGroupCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ParameterGroupCode_tags_1, sizeof(asn_DEF_ParameterGroupCode_tags_1) /sizeof(asn_DEF_ParameterGroupCode_tags_1[0]), /* 1 */ asn_DEF_ParameterGroupCode_tags_1, /* Same as above */ sizeof(asn_DEF_ParameterGroupCode_tags_1) /sizeof(asn_DEF_ParameterGroupCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/GeneralizedTime.h0000664000175000017500000000424114105434233020722 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _GeneralizedTime_H_ #define _GeneralizedTime_H_ #include #ifdef __cplusplus extern "C" { #endif typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_GeneralizedTime; asn_struct_print_f GeneralizedTime_print; asn_constr_check_f GeneralizedTime_constraint; der_type_encoder_f GeneralizedTime_encode_der; xer_type_encoder_f GeneralizedTime_encode_xer; /*********************** * Some handy helpers. * ***********************/ struct tm; /* */ /* * Convert a GeneralizedTime structure into time_t * and optionally into struct tm. * If as_gmt is given, the resulting _optional_tm4fill will have a GMT zone, * instead of default local one. * On error returns -1 and errno set to EINVAL */ time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill, int as_gmt); /* A version of the above function also returning the fractions of seconds */ time_t asn_GT2time_frac(const GeneralizedTime_t *, int *frac_value, int *frac_digits, /* (value / (10 ^ digits)) */ struct tm *_optional_tm4fill, int as_gmt); /* * Another version returning fractions with defined precision * For example, parsing of the time ending with ".1" seconds * with frac_digits=3 (msec) would yield frac_value = 100. */ time_t asn_GT2time_prec(const GeneralizedTime_t *, int *frac_value, int frac_digits, struct tm *_optional_tm4fill, int as_gmt); /* * Convert a struct tm into GeneralizedTime. * If _optional_gt is not given, this function will try to allocate one. * If force_gmt is given, the resulting GeneralizedTime will be forced * into a GMT time zone (encoding ends with a "Z"). * On error, this function returns 0 and sets errno. */ GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *_optional_gt, const struct tm *, int force_gmt); GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *_optional_gt, const struct tm *, int frac_value, int frac_digits, int force_gmt); #ifdef __cplusplus } #endif #endif /* _GeneralizedTime_H_ */ biosig-2.3.3/biosig4c++/t240/SaFilterEntry.h0000664000175000017500000000140614105434233020405 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaFilterEntry_H_ #define _SaFilterEntry_H_ #include /* Including external dependencies */ #include "FilterType.h" #include "FEFFloat.h" #include #include #ifdef __cplusplus extern "C" { #endif /* SaFilterEntry */ typedef struct SaFilterEntry { FilterType_t filtertype; FEFFloat_t frequency; INTEGER_t filterorder; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SaFilterEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaFilterEntry; #ifdef __cplusplus } #endif #endif /* _SaFilterEntry_H_ */ biosig-2.3.3/biosig4c++/t240/DescriptiveDataSection.c0000664000175000017500000002724614105434233022257 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DescriptiveDataSection.h" static asn_TYPE_member_t asn_MBR_realtimesadescs_4[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_RealTimeSampleArrayDescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_realtimesadescs_tags_4[] = { (ASN_TAG_CLASS_APPLICATION | (7020 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_realtimesadescs_specs_4 = { sizeof(struct DescriptiveDataSection__realtimesadescs), offsetof(struct DescriptiveDataSection__realtimesadescs, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_realtimesadescs_4 = { "realtimesadescs", "realtimesadescs", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_realtimesadescs_tags_4, sizeof(asn_DEF_realtimesadescs_tags_4) /sizeof(asn_DEF_realtimesadescs_tags_4[0]) - 1, /* 1 */ asn_DEF_realtimesadescs_tags_4, /* Same as above */ sizeof(asn_DEF_realtimesadescs_tags_4) /sizeof(asn_DEF_realtimesadescs_tags_4[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_realtimesadescs_4, 1, /* Single element */ &asn_SPC_realtimesadescs_specs_4 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_timesadescs_6[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_TimeSampleArrayDescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_timesadescs_tags_6[] = { (ASN_TAG_CLASS_APPLICATION | (7021 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_timesadescs_specs_6 = { sizeof(struct DescriptiveDataSection__timesadescs), offsetof(struct DescriptiveDataSection__timesadescs, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_timesadescs_6 = { "timesadescs", "timesadescs", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_timesadescs_tags_6, sizeof(asn_DEF_timesadescs_tags_6) /sizeof(asn_DEF_timesadescs_tags_6[0]) - 1, /* 1 */ asn_DEF_timesadescs_tags_6, /* Same as above */ sizeof(asn_DEF_timesadescs_tags_6) /sizeof(asn_DEF_timesadescs_tags_6[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_timesadescs_6, 1, /* Single element */ &asn_SPC_timesadescs_specs_6 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_distributionsadescs_8[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_DistributionSampleArrayDescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_distributionsadescs_tags_8[] = { (ASN_TAG_CLASS_APPLICATION | (7022 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_distributionsadescs_specs_8 = { sizeof(struct DescriptiveDataSection__distributionsadescs), offsetof(struct DescriptiveDataSection__distributionsadescs, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_distributionsadescs_8 = { "distributionsadescs", "distributionsadescs", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_distributionsadescs_tags_8, sizeof(asn_DEF_distributionsadescs_tags_8) /sizeof(asn_DEF_distributionsadescs_tags_8[0]) - 1, /* 1 */ asn_DEF_distributionsadescs_tags_8, /* Same as above */ sizeof(asn_DEF_distributionsadescs_tags_8) /sizeof(asn_DEF_distributionsadescs_tags_8[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_distributionsadescs_8, 1, /* Single element */ &asn_SPC_distributionsadescs_specs_8 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_numericdescs_10[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_NumericDescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_numericdescs_tags_10[] = { (ASN_TAG_CLASS_APPLICATION | (7023 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_numericdescs_specs_10 = { sizeof(struct DescriptiveDataSection__numericdescs), offsetof(struct DescriptiveDataSection__numericdescs, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_numericdescs_10 = { "numericdescs", "numericdescs", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_numericdescs_tags_10, sizeof(asn_DEF_numericdescs_tags_10) /sizeof(asn_DEF_numericdescs_tags_10[0]) - 1, /* 1 */ asn_DEF_numericdescs_tags_10, /* Same as above */ sizeof(asn_DEF_numericdescs_tags_10) /sizeof(asn_DEF_numericdescs_tags_10[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_numericdescs_10, 1, /* Single element */ &asn_SPC_numericdescs_specs_10 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_enumerationdescs_12[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_EnumerationDescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_enumerationdescs_tags_12[] = { (ASN_TAG_CLASS_APPLICATION | (7024 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_enumerationdescs_specs_12 = { sizeof(struct DescriptiveDataSection__enumerationdescs), offsetof(struct DescriptiveDataSection__enumerationdescs, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_enumerationdescs_12 = { "enumerationdescs", "enumerationdescs", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_enumerationdescs_tags_12, sizeof(asn_DEF_enumerationdescs_tags_12) /sizeof(asn_DEF_enumerationdescs_tags_12[0]) - 1, /* 1 */ asn_DEF_enumerationdescs_tags_12, /* Same as above */ sizeof(asn_DEF_enumerationdescs_tags_12) /sizeof(asn_DEF_enumerationdescs_tags_12[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_enumerationdescs_12, 1, /* Single element */ &asn_SPC_enumerationdescs_specs_12 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_DescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_POINTER, 6, offsetof(struct DescriptiveDataSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_POINTER, 5, offsetof(struct DescriptiveDataSection, realtimesadescs), (ASN_TAG_CLASS_APPLICATION | (7020 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_realtimesadescs_4, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "realtimesadescs" }, { ATF_POINTER, 4, offsetof(struct DescriptiveDataSection, timesadescs), (ASN_TAG_CLASS_APPLICATION | (7021 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_timesadescs_6, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timesadescs" }, { ATF_POINTER, 3, offsetof(struct DescriptiveDataSection, distributionsadescs), (ASN_TAG_CLASS_APPLICATION | (7022 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_distributionsadescs_8, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "distributionsadescs" }, { ATF_POINTER, 2, offsetof(struct DescriptiveDataSection, numericdescs), (ASN_TAG_CLASS_APPLICATION | (7023 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_numericdescs_10, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numericdescs" }, { ATF_POINTER, 1, offsetof(struct DescriptiveDataSection, enumerationdescs), (ASN_TAG_CLASS_APPLICATION | (7024 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_enumerationdescs_12, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumerationdescs" }, }; static ber_tlv_tag_t asn_DEF_DescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 748 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 1, 0, 0 }, /* placeholder at 751 */ { (ASN_TAG_CLASS_APPLICATION | (7020 << 2)), 2, 0, 0 }, /* realtimesadescs at 755 */ { (ASN_TAG_CLASS_APPLICATION | (7021 << 2)), 3, 0, 0 }, /* timesadescs at 759 */ { (ASN_TAG_CLASS_APPLICATION | (7022 << 2)), 4, 0, 0 }, /* distributionsadescs at 763 */ { (ASN_TAG_CLASS_APPLICATION | (7023 << 2)), 5, 0, 0 }, /* numericdescs at 767 */ { (ASN_TAG_CLASS_APPLICATION | (7024 << 2)), 6, 0, 0 } /* enumerationdescs at 771 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DescriptiveDataSection_specs_1 = { sizeof(struct DescriptiveDataSection), offsetof(struct DescriptiveDataSection, _asn_ctx), asn_MAP_DescriptiveDataSection_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DescriptiveDataSection = { "DescriptiveDataSection", "DescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DescriptiveDataSection_tags_1, sizeof(asn_DEF_DescriptiveDataSection_tags_1) /sizeof(asn_DEF_DescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_DescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_DescriptiveDataSection_tags_1) /sizeof(asn_DEF_DescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DescriptiveDataSection_1, 7, /* Elements count */ &asn_SPC_DescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/asn_codecs_prim.h0000664000175000017500000000313514105434233021003 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_CODECS_PRIM_H #define ASN_CODECS_PRIM_H #include #ifdef __cplusplus extern "C" { #endif typedef struct ASN__PRIMITIVE_TYPE_s { uint8_t *buf; /* Buffer with consecutive primitive encoding bytes */ int size; /* Size of the buffer */ } ASN__PRIMITIVE_TYPE_t; /* Do not use this type directly! */ asn_struct_free_f ASN__PRIMITIVE_TYPE_free; ber_type_decoder_f ber_decode_primitive; der_type_encoder_f der_encode_primitive; /* * A callback specification for the xer_decode_primitive() function below. */ enum xer_pbd_rval { XPBD_SYSTEM_FAILURE, /* System failure (memory shortage, etc) */ XPBD_DECODER_LIMIT, /* Hit some decoder limitation or deficiency */ XPBD_BROKEN_ENCODING, /* Encoding of a primitive body is broken */ XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */ XPBD_BODY_CONSUMED /* Body is recognized and consumed */ }; typedef enum xer_pbd_rval (xer_primitive_body_decoder_f) (asn_TYPE_descriptor_t *td, void *struct_ptr, const void *chunk_buf, size_t chunk_size); /* * Specific function to decode simple primitive types. * Also see xer_decode_general() in xer_decoder.h */ asn_dec_rval_t xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr, size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size, xer_primitive_body_decoder_f *prim_body_decoder ); #ifdef __cplusplus } #endif #endif /* ASN_CODECS_PRIM_H */ biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificEncoded.c0000664000175000017500000000464314105434233023237 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ManufacturerSpecificEncoded.h" static asn_TYPE_member_t asn_MBR_ManufacturerSpecificEncoded_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ManufacturerSpecificEncoded, code), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "code" }, { ATF_NOFLAGS, 0, offsetof(struct ManufacturerSpecificEncoded, data), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "data" }, }; static ber_tlv_tag_t asn_DEF_ManufacturerSpecificEncoded_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ManufacturerSpecificEncoded_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* code at 271 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* data at 272 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ManufacturerSpecificEncoded_specs_1 = { sizeof(struct ManufacturerSpecificEncoded), offsetof(struct ManufacturerSpecificEncoded, _asn_ctx), asn_MAP_ManufacturerSpecificEncoded_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificEncoded = { "ManufacturerSpecificEncoded", "ManufacturerSpecificEncoded", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ManufacturerSpecificEncoded_tags_1, sizeof(asn_DEF_ManufacturerSpecificEncoded_tags_1) /sizeof(asn_DEF_ManufacturerSpecificEncoded_tags_1[0]), /* 1 */ asn_DEF_ManufacturerSpecificEncoded_tags_1, /* Same as above */ sizeof(asn_DEF_ManufacturerSpecificEncoded_tags_1) /sizeof(asn_DEF_ManufacturerSpecificEncoded_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ManufacturerSpecificEncoded_1, 2, /* Elements count */ &asn_SPC_ManufacturerSpecificEncoded_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/AbsoluteRange.h0000664000175000017500000000127714105434233020413 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _AbsoluteRange_H_ #define _AbsoluteRange_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include #ifdef __cplusplus extern "C" { #endif /* AbsoluteRange */ typedef struct AbsoluteRange { FEFFloat_t lowervalue; FEFFloat_t uppervalue; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } AbsoluteRange_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_AbsoluteRange; #ifdef __cplusplus } #endif #endif /* _AbsoluteRange_H_ */ biosig-2.3.3/biosig4c++/t240/ManufacturerID.c0000664000175000017500000000470114105434233020517 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ManufacturerID.h" static int memb_uuid_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; size_t size; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } size = st->size; if((size == 16)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } static asn_TYPE_member_t asn_MBR_ManufacturerID_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ManufacturerID, choice.oid), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_OBJECT_IDENTIFIER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "oid" }, { ATF_NOFLAGS, 0, offsetof(struct ManufacturerID, choice.uuid), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, memb_uuid_constraint_1, 0, /* PER is not compiled, use -gen-PER */ 0, "uuid" }, }; static asn_TYPE_tag2member_t asn_MAP_ManufacturerID_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* oid at 142 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* uuid at 145 */ }; static asn_CHOICE_specifics_t asn_SPC_ManufacturerID_specs_1 = { sizeof(struct ManufacturerID), offsetof(struct ManufacturerID, _asn_ctx), offsetof(struct ManufacturerID, present), sizeof(((struct ManufacturerID *)0)->present), asn_MAP_ManufacturerID_tag2el_1, 2, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ManufacturerID = { "ManufacturerID", "ManufacturerID", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_ManufacturerID_1, 2, /* Elements count */ &asn_SPC_ManufacturerID_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/LimitSpecEntry.c0000664000175000017500000000642714105434233020570 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "LimitSpecEntry.h" static asn_TYPE_member_t asn_MBR_LimitSpecEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct LimitSpecEntry, sectionhandle), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sectionhandle" }, { ATF_NOFLAGS, 0, offsetof(struct LimitSpecEntry, alsourceid), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alsourceid" }, { ATF_NOFLAGS, 0, offsetof(struct LimitSpecEntry, unitcode), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_NOFLAGS, 0, offsetof(struct LimitSpecEntry, limalstat), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_CurLimAlStat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "limalstat" }, { ATF_NOFLAGS, 0, offsetof(struct LimitSpecEntry, limalval), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "limalval" }, }; static ber_tlv_tag_t asn_DEF_LimitSpecEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_LimitSpecEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* sectionhandle at 1441 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* alsourceid at 1442 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* unitcode at 1443 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 }, /* limalstat at 1444 */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 4, 0, 0 } /* limalval at 1446 */ }; static asn_SEQUENCE_specifics_t asn_SPC_LimitSpecEntry_specs_1 = { sizeof(struct LimitSpecEntry), offsetof(struct LimitSpecEntry, _asn_ctx), asn_MAP_LimitSpecEntry_tag2el_1, 5, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_LimitSpecEntry = { "LimitSpecEntry", "LimitSpecEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_LimitSpecEntry_tags_1, sizeof(asn_DEF_LimitSpecEntry_tags_1) /sizeof(asn_DEF_LimitSpecEntry_tags_1[0]), /* 1 */ asn_DEF_LimitSpecEntry_tags_1, /* Same as above */ sizeof(asn_DEF_LimitSpecEntry_tags_1) /sizeof(asn_DEF_LimitSpecEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_LimitSpecEntry_1, 5, /* Elements count */ &asn_SPC_LimitSpecEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SimpleColour.h0000664000175000017500000000212114105434233020262 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SimpleColour_H_ #define _SimpleColour_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum SimpleColour { SimpleColour_colblack = 0, SimpleColour_colred = 1, SimpleColour_colgreen = 2, SimpleColour_colyellow = 3, SimpleColour_colblue = 4, SimpleColour_colmagenta = 5, SimpleColour_colcyan = 6, SimpleColour_colwhite = 7 } e_SimpleColour; /* SimpleColour */ typedef INTEGER_t SimpleColour_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SimpleColour; asn_struct_free_f SimpleColour_free; asn_struct_print_f SimpleColour_print; asn_constr_check_f SimpleColour_constraint; ber_type_decoder_f SimpleColour_decode_ber; der_type_encoder_f SimpleColour_encode_der; xer_type_decoder_f SimpleColour_decode_xer; xer_type_encoder_f SimpleColour_encode_xer; #ifdef __cplusplus } #endif #endif /* _SimpleColour_H_ */ biosig-2.3.3/biosig4c++/t240/HealthCareProviderSection.h0000664000175000017500000000256314105434233022717 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _HealthCareProviderSection_H_ #define _HealthCareProviderSection_H_ #include /* Including external dependencies */ #include "HealthCareProviderId.h" #include "FEFString.h" #include "Address.h" #include "Placeholder.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct HealthCareProfessionalSection; /* HealthCareProviderSection */ typedef struct HealthCareProviderSection { HealthCareProviderId_t identification; FEFString_t name; Address_t *address /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; struct HealthCareProviderSection__healthcareprofessionals { A_SEQUENCE_OF(struct HealthCareProfessionalSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *healthcareprofessionals; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } HealthCareProviderSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_HealthCareProviderSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "HealthCareProfessionalSection.h" #endif /* _HealthCareProviderSection_H_ */ biosig-2.3.3/biosig4c++/t240/ChannelStatus.h0000664000175000017500000000205714105434233020431 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ChannelStatus_H_ #define _ChannelStatus_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ChannelStatus { ChannelStatus_chn_off = 0, ChannelStatus_chn_not_ready = 1, ChannelStatus_chn_standby = 2, ChannelStatus_chn_transduc_discon = 8, ChannelStatus_chn_hw_discon = 9 } e_ChannelStatus; /* ChannelStatus */ typedef BIT_STRING_t ChannelStatus_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ChannelStatus; asn_struct_free_f ChannelStatus_free; asn_struct_print_f ChannelStatus_print; asn_constr_check_f ChannelStatus_constraint; ber_type_decoder_f ChannelStatus_decode_ber; der_type_encoder_f ChannelStatus_encode_der; xer_type_decoder_f ChannelStatus_decode_xer; xer_type_encoder_f ChannelStatus_encode_xer; #ifdef __cplusplus } #endif #endif /* _ChannelStatus_H_ */ biosig-2.3.3/biosig4c++/t240/ber_tlv_length.c0000664000175000017500000000731014105434233020643 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size, ber_tlv_len_t *len_r) { const uint8_t *buf = (const uint8_t *)bufptr; unsigned oct; if(size == 0) return 0; /* Want more */ oct = *(const uint8_t *)buf; if((oct & 0x80) == 0) { /* * Short definite length. */ *len_r = oct; /* & 0x7F */ return 1; } else { ber_tlv_len_t len; size_t skipped; if(_is_constructed && oct == 0x80) { *len_r = -1; /* Indefinite length */ return 1; } if(oct == 0xff) { /* Reserved in standard for future use. */ return -1; } oct &= 0x7F; /* Leave only the 7 LS bits */ for(len = 0, buf++, skipped = 1; oct && (++skipped <= size); buf++, oct--) { len = (len << 8) | *buf; if(len < 0 || (len >> ((8 * sizeof(len)) - 8) && oct > 1)) { /* * Too large length value. */ return -1; } } if(oct == 0) { ber_tlv_len_t lenplusepsilon = (size_t)len + 1024; /* * Here length may be very close or equal to 2G. * However, the arithmetics used in some decoders * may add some (small) quantities to the length, * to check the resulting value against some limits. * This may result in integer wrap-around, which * we try to avoid by checking it earlier here. */ if(lenplusepsilon < 0) { /* Too large length value */ return -1; } *len_r = len; return skipped; } return 0; /* Want more */ } } ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, const void *ptr, size_t size) { ber_tlv_len_t vlen; /* Length of V in TLV */ ssize_t tl; /* Length of L in TLV */ ssize_t ll; /* Length of L in TLV */ size_t skip; /* * Make sure we didn't exceed the maximum stack size. */ if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) return -1; /* * Determine the size of L in TLV. */ ll = ber_fetch_length(_is_constructed, ptr, size, &vlen); if(ll <= 0) return ll; /* * Definite length. */ if(vlen >= 0) { skip = ll + vlen; if(skip > size) return 0; /* Want more */ return skip; } /* * Indefinite length! */ ASN_DEBUG("Skipping indefinite length"); for(skip = ll, ptr = ((const char *)ptr) + ll, size -= ll;;) { ber_tlv_tag_t tag; /* Fetch the tag */ tl = ber_fetch_tag(ptr, size, &tag); if(tl <= 0) return tl; ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), ((const char *)ptr) + tl, size - tl); if(ll <= 0) return ll; skip += tl + ll; /* * This may be the end of the indefinite length structure, * two consecutive 0 octets. * Check if it is true. */ if(((const uint8_t *)ptr)[0] == 0 && ((const uint8_t *)ptr)[1] == 0) return skip; ptr = ((const char *)ptr) + tl + ll; size -= tl + ll; } /* UNREACHABLE */ } size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) { size_t required_size; /* Size of len encoding */ uint8_t *buf = (uint8_t *)bufp; uint8_t *end; size_t i; if(len <= 127) { /* Encoded in 1 octet */ if(size) *buf = (uint8_t)len; return 1; } /* * Compute the size of the subsequent bytes. */ for(required_size = 1, i = 8; i < 8 * sizeof(len); i += 8) { if(len >> i) required_size++; else break; } if(size <= required_size) return required_size + 1; *buf++ = (uint8_t)(0x80 | required_size); /* Length of the encoding */ /* * Produce the len encoding, space permitting. */ end = buf + required_size; for(i -= 8; buf < end; i -= 8, buf++) *buf = (uint8_t)(len >> i); return required_size + 1; } biosig-2.3.3/biosig4c++/t240/SampleArrayDescriptiveDataSection.h0000664000175000017500000001144014105434233024412 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SampleArrayDescriptiveDataSection_H_ #define _SampleArrayDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include "SaSpec.h" #include "ScaleRangeSpec.h" #include "FEFFloat.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct AbsoluteRange; struct SaSignalFrequency; struct MetricCalEntry; struct SaGridEntry; struct SaCalData; struct SaFilterEntry; /* SampleArrayDescriptiveDataSection */ typedef struct SampleArrayDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct SampleArrayDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct SampleArrayDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct SampleArrayDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct SampleArrayDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct SampleArrayDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct SampleArrayDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct SampleArrayDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; SaSpec_t saspecification; PrivateCode_t *compression /* OPTIONAL */; ScaleRangeSpec_t scaleandrangespec; struct AbsoluteRange *saphysiologicalrange /* OPTIONAL */; struct SampleArrayDescriptiveDataSection__visualgrid { A_SEQUENCE_OF(struct SaGridEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *visualgrid; struct SampleArrayDescriptiveDataSection__sacalibrationdata { A_SEQUENCE_OF(struct SaCalData) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *sacalibrationdata; struct SampleArrayDescriptiveDataSection__filterspecification { A_SEQUENCE_OF(struct SaFilterEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *filterspecification; struct SaSignalFrequency *sasignalfrequency /* OPTIONAL */; FEFFloat_t *sameasureresolution /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SampleArrayDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SampleArrayDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "AbsoluteRange.h" #include "SaSignalFrequency.h" #include "MetricCalEntry.h" #include "SaGridEntry.h" #include "SaCalData.h" #include "SaFilterEntry.h" #endif /* _SampleArrayDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/per_encoder.h0000664000175000017500000000417714105434233020147 0ustar schloeglschloegl/*- * Copyright (c) 2006, 2007 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _PER_ENCODER_H_ #define _PER_ENCODER_H_ #include #include #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * Unaligned PER encoder of any ASN.1 type. May be invoked by the application. * WARNING: This function returns the number of encoded bits in the .encoded * field of the return value. Use the following formula to convert to bytes: * bytes = ((.encoded + 7) / 8) */ asn_enc_rval_t uper_encode(struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */ void *app_key /* Arbitrary callback argument */ ); /* * A variant of uper_encode() which encodes data into the existing buffer * WARNING: This function returns the number of encoded bits in the .encoded * field of the return value. */ asn_enc_rval_t uper_encode_to_buffer( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, /* Structure to be encoded */ void *buffer, /* Pre-allocated buffer */ size_t buffer_size /* Initial buffer size (max) */ ); /* * A variant of uper_encode_to_buffer() which allocates buffer itself. * Returns the number of bytes in the buffer or -1 in case of failure. * WARNING: This function produces a "Production of the complete encoding", * with length of at least one octet. Contrast this to precise bit-packing * encoding of uper_encode() and uper_encode_to_buffer(). */ ssize_t uper_encode_to_new_buffer( struct asn_TYPE_descriptor_s *type_descriptor, asn_per_constraints_t *constraints, void *struct_ptr, /* Structure to be encoded */ void **buffer_r /* Buffer allocated and returned */ ); /* * Type of the generic PER encoder function. */ typedef asn_enc_rval_t (per_type_encoder_f)( struct asn_TYPE_descriptor_s *type_descriptor, asn_per_constraints_t *constraints, void *struct_ptr, asn_per_outp_t *per_output ); #ifdef __cplusplus } #endif #endif /* _PER_ENCODER_H_ */ biosig-2.3.3/biosig4c++/t240/PatientType.h0000664000175000017500000000172314105434233020122 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PatientType_H_ #define _PatientType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum PatientType { PatientType_pt_unspecified = 0, PatientType_adult = 1, PatientType_pediatric = 2, PatientType_neonatal = 3 } e_PatientType; /* PatientType */ typedef INTEGER_t PatientType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PatientType; asn_struct_free_f PatientType_free; asn_struct_print_f PatientType_print; asn_constr_check_f PatientType_constraint; ber_type_decoder_f PatientType_decode_ber; der_type_encoder_f PatientType_encode_der; xer_type_decoder_f PatientType_decode_xer; xer_type_encoder_f PatientType_encode_xer; #ifdef __cplusplus } #endif #endif /* _PatientType_H_ */ biosig-2.3.3/biosig4c++/t240/ApplicationArea.h0000664000175000017500000000202514105434233020704 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ApplicationArea_H_ #define _ApplicationArea_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ApplicationArea { ApplicationArea_area_unspec = 0, ApplicationArea_area_operating_room = 1, ApplicationArea_area_intensive_care = 2 } e_ApplicationArea; /* ApplicationArea */ typedef INTEGER_t ApplicationArea_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ApplicationArea; asn_struct_free_f ApplicationArea_free; asn_struct_print_f ApplicationArea_print; asn_constr_check_f ApplicationArea_constraint; ber_type_decoder_f ApplicationArea_decode_ber; der_type_encoder_f ApplicationArea_encode_der; xer_type_decoder_f ApplicationArea_decode_xer; xer_type_encoder_f ApplicationArea_encode_xer; #ifdef __cplusplus } #endif #endif /* _ApplicationArea_H_ */ biosig-2.3.3/biosig4c++/t240/constr_TYPE.c0000664000175000017500000000334214105434233020017 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Version of the ASN.1 infrastructure shipped with compiler. */ int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; } static asn_app_consume_bytes_f _print2fp; /* * Return the outmost tag of the type. */ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) { if(tag_mode) return tag; if(type_descriptor->tags_count) return type_descriptor->tags[0]; return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0); } /* * Print the target language's structure in human readable form. */ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) { if(!stream) stream = stdout; if(!td || !struct_ptr) { errno = EINVAL; return -1; } /* Invoke type-specific printer */ if(td->print_struct(td, struct_ptr, 1, _print2fp, stream)) return -1; /* Terminate the output */ if(_print2fp("\n", 1, stream)) return -1; return fflush(stream); } /* Dump the data into the specified stdio stream */ static int _print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; if(fwrite(buffer, 1, size, stream) != size) return -1; return 0; } /* * Some compilers do not support variable args macros. * This function is a replacement of ASN_DEBUG() macro. */ void ASN_DEBUG_f(const char *fmt, ...); void ASN_DEBUG_f(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); va_end(ap); } biosig-2.3.3/biosig4c++/t240/GeneralizedTime.c0000664000175000017500000003753314105434233020727 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #define _POSIX_PTHREAD_SEMANTICS /* for Sun */ #define _REENTRANT /* for Sun */ #include #include #include #ifdef __CYGWIN__ #include "/usr/include/time.h" #else #include #endif /* __CYGWIN__ */ #if defined(WIN32) #pragma message( "PLEASE STOP AND READ!") #pragma message( " localtime_r is implemented via localtime(), which may be not thread-safe.") #pragma message( " gmtime_r is implemented via gmtime(), which may be not thread-safe.") #pragma message( " ") #pragma message( " You must fix the code by inserting appropriate locking") #pragma message( " if you want to use asn_GT2time() or asn_UT2time().") #pragma message( "PLEASE STOP AND READ!") static struct tm *localtime_r(const time_t *tloc, struct tm *result) { struct tm *tm; if((tm = localtime(tloc))) return memcpy(result, tm, sizeof(struct tm)); return 0; } static struct tm *gmtime_r(const time_t *tloc, struct tm *result) { struct tm *tm; if((tm = gmtime(tloc))) return memcpy(result, tm, sizeof(struct tm)); return 0; } #define tzset() _tzset() #define putenv(c) _putenv(c) #define _EMULATE_TIMEGM #endif /* WIN32 */ #if defined(sun) || defined(_sun_) || defined(__solaris__) #define _EMULATE_TIMEGM #endif /* * Where to look for offset from GMT, Phase I. * Several platforms are known. */ #if defined(__FreeBSD__) \ || (defined(__GNUC__) && defined(__APPLE_CC__)) \ || (defined __GLIBC__ && __GLIBC__ >= 2) #undef HAVE_TM_GMTOFF #define HAVE_TM_GMTOFF #endif /* BSDs and newer glibc */ /* * Where to look for offset from GMT, Phase II. */ #ifdef HAVE_TM_GMTOFF #define GMTOFF(tm) ((tm).tm_gmtoff) #else /* HAVE_TM_GMTOFF */ #define GMTOFF(tm) (-timezone) #endif /* HAVE_TM_GMTOFF */ #if (defined(_EMULATE_TIMEGM) || !defined(HAVE_TM_GMTOFF)) #warning "PLEASE STOP AND READ!" #warning " timegm() is implemented via getenv(\"TZ\")/setenv(\"TZ\"), which may be not thread-safe." #warning " " #warning " You must fix the code by inserting appropriate locking" #warning " if you want to use asn_GT2time() or asn_UT2time()." #warning "PLEASE STOP AND READ!" #endif /* _EMULATE_TIMEGM */ /* * Override our GMTOFF decision for other known platforms. */ #ifdef __CYGWIN__ #undef GMTOFF static long GMTOFF(struct tm a){ struct tm *lt; time_t local_time, gmt_time; long zone; tzset(); gmt_time = time (NULL); lt = gmtime(&gmt_time); local_time = mktime(lt); return (gmt_time - local_time); } #endif /* __CYGWIN__ */ #ifdef __MINGW32__ #define ATZVARS do { \ char tzoldbuf[64]; \ char *tzold #define ATZSAVETZ do { \ tzold = getenv("TZ"); \ if(tzold) { \ size_t tzlen = strlen(tzold); \ if(tzlen < sizeof(tzoldbuf)) { \ tzold = memcpy(tzoldbuf, tzold, tzlen + 1); \ } else { \ char *dupptr = tzold; \ tzold = MALLOC(tzlen + 1); \ if(tzold) memcpy(tzold, dupptr, tzlen + 1); \ } \ putenv("TZ= UTC"); \ } \ tzset(); \ } while(0) #define ATZOLDTZ do { \ if (tzold) { \ putenv("TZ= UTC"); \ *tzoldbuf = 0; \ if(tzold != tzoldbuf) \ FREEMEM(tzold); \ } else { \ putenv("TZ= "); \ } \ tzset(); \ } while(0); } while(0); #else //******* not defined __MinGW32__ ***/ #define ATZVARS do { \ char tzoldbuf[64]; \ char *tzold #define ATZSAVETZ do { \ tzold = getenv("TZ"); \ if(tzold) { \ size_t tzlen = strlen(tzold); \ if(tzlen < sizeof(tzoldbuf)) { \ tzold = memcpy(tzoldbuf, tzold, tzlen + 1); \ } else { \ char *dupptr = tzold; \ tzold = MALLOC(tzlen + 1); \ if(tzold) memcpy(tzold, dupptr, tzlen + 1); \ } \ setenv("TZ", "UTC", 1); \ } \ tzset(); \ } while(0) #define ATZOLDTZ do { \ if (tzold) { \ setenv("TZ", tzold, 1); \ *tzoldbuf = 0; \ if(tzold != tzoldbuf) \ FREEMEM(tzold); \ } else { \ unsetenv("TZ"); \ } \ tzset(); \ } while(0); } while(0); #endif #ifdef _EMULATE_TIMEGM static time_t timegm(struct tm *tm) { time_t tloc; ATZVARS; ATZSAVETZ; tloc = mktime(tm); ATZOLDTZ; return tloc; } #endif /* _EMULATE_TIMEGM */ #ifndef __ASN_INTERNAL_TEST_MODE__ /* * GeneralizedTime basic type description. */ static ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (24 << 2)), /* [UNIVERSAL 24] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; static asn_per_constraints_t asn_DEF_GeneralizedTime_constraints = { { APC_CONSTRAINED, 7, 7, 0x20, 0x7e }, /* Value */ { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { "GeneralizedTime", "GeneralizedTime", OCTET_STRING_free, GeneralizedTime_print, GeneralizedTime_constraint, /* Check validity of time */ OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ GeneralizedTime_encode_der, OCTET_STRING_decode_xer_utf8, GeneralizedTime_encode_xer, OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]) - 2, asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]), &asn_DEF_GeneralizedTime_constraints, 0, 0, /* No members */ 0 /* No specifics */ }; #endif /* __ASN_INTERNAL_TEST_MODE__ */ /* * Check that the time looks like the time. */ int GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr; time_t tloc; errno = EPERM; /* Just an unlikely error code */ tloc = asn_GT2time(st, 0, 0); if(tloc == -1 && errno != EPERM) { _ASN_CTFAIL(app_key, td, sptr, "%s: Invalid time format: %s (%s:%d)", td->name, strerror(errno), __FILE__, __LINE__); return -1; } return 0; } asn_enc_rval_t GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { GeneralizedTime_t *st = (GeneralizedTime_t *)sptr; asn_enc_rval_t erval; int fv, fd; /* seconds fraction value and number of digits */ struct tm tm; time_t tloc; /* * Encode as a canonical DER. */ errno = EPERM; tloc = asn_GT2time_frac(st, &fv, &fd, &tm, 1); /* Recognize time */ if(tloc == -1 && errno != EPERM) /* Failed to recognize time. Fail completely. */ _ASN_ENCODE_FAILED; st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */ if(!st) _ASN_ENCODE_FAILED; /* Memory allocation failure. */ erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key); FREEMEM(st->buf); FREEMEM(st); return erval; } #ifndef __ASN_INTERNAL_TEST_MODE__ asn_enc_rval_t GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { if(flags & XER_F_CANONICAL) { GeneralizedTime_t *gt; asn_enc_rval_t rv; int fv, fd; /* fractional parts */ struct tm tm; errno = EPERM; if(asn_GT2time_frac((GeneralizedTime_t *)sptr, &fv, &fd, &tm, 1) == -1 && errno != EPERM) _ASN_ENCODE_FAILED; gt = asn_time2GT_frac(0, &tm, fv, fd, 1); if(!gt) _ASN_ENCODE_FAILED; rv = OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); ASN_STRUCT_FREE(asn_DEF_GeneralizedTime, gt); return rv; } else { return OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); } } #endif /* __ASN_INTERNAL_TEST_MODE__ */ int GeneralizedTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(st && st->buf) { char buf[32]; struct tm tm; int ret; errno = EPERM; if(asn_GT2time(st, &tm, 1) == -1 && errno != EPERM) return (cb("", 11, app_key) < 0) ? -1 : 0; ret = snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d (GMT)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); assert(ret > 0 && ret < (int)sizeof(buf)); return (cb(buf, ret, app_key) < 0) ? -1 : 0; } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } time_t asn_GT2time(const GeneralizedTime_t *st, struct tm *ret_tm, int as_gmt) { return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); } time_t asn_GT2time_prec(const GeneralizedTime_t *st, int *frac_value, int frac_digits, struct tm *ret_tm, int as_gmt) { time_t tloc; int fv, fd = 0; if(frac_value) tloc = asn_GT2time_frac(st, &fv, &fd, ret_tm, as_gmt); else return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); if(fd == 0 || frac_digits <= 0) { *frac_value = 0; } else { while(fd > frac_digits) fv /= 10, fd--; while(fd < frac_digits) { int new_fv = fv * 10; if(new_fv / 10 != fv) { /* Too long precision request */ fv = 0; break; } fv = new_fv, fd++; } *frac_value = fv; } return tloc; } time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, int *frac_digits, struct tm *ret_tm, int as_gmt) { struct tm tm_s; uint8_t *buf; uint8_t *end; int gmtoff_h = 0; int gmtoff_m = 0; int gmtoff = 0; /* h + m */ int offset_specified = 0; int fvalue = 0; int fdigits = 0; time_t tloc; if(!st || !st->buf) { errno = EINVAL; return -1; } else { buf = st->buf; end = buf + st->size; } if(st->size < 10) { errno = EINVAL; return -1; } /* * Decode first 10 bytes: "AAAAMMJJhh" */ memset(&tm_s, 0, sizeof(tm_s)); #undef B2F #undef B2T #define B2F(var) do { \ unsigned ch = *buf; \ if(ch < 0x30 || ch > 0x39) { \ errno = EINVAL; \ return -1; \ } else { \ var = var * 10 + (ch - 0x30); \ buf++; \ } \ } while(0) #define B2T(var) B2F(tm_s.var) B2T(tm_year); /* 1: A */ B2T(tm_year); /* 2: A */ B2T(tm_year); /* 3: A */ B2T(tm_year); /* 4: A */ B2T(tm_mon); /* 5: M */ B2T(tm_mon); /* 6: M */ B2T(tm_mday); /* 7: J */ B2T(tm_mday); /* 8: J */ B2T(tm_hour); /* 9: h */ B2T(tm_hour); /* 0: h */ if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^^ */ switch(*buf) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: tm_s.tm_min = (*buf++) - 0x30; if(buf == end) { errno = EINVAL; return -1; } B2T(tm_min); break; case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^^ */ switch(*buf) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: tm_s.tm_sec = (*buf++) - 0x30; if(buf == end) { errno = EINVAL; return -1; } B2T(tm_sec); break; case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^ ^ */ switch(*buf) { case 0x2C: case 0x2E: /* (.|,) */ /* * Process fractions of seconds. */ for(buf++; buf < end; buf++) { int v = *buf; int new_fvalue; switch(v) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: new_fvalue = fvalue * 10 + (v - 0x30); if(new_fvalue / 10 != fvalue) { /* Not enough precision, ignore */ } else { fvalue = new_fvalue; fdigits++; } continue; default: break; } break; } } if(buf == end) goto local_finish; switch(*buf) { case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } offset: if(end - buf < 3) { errno = EINVAL; return -1; } buf++; B2F(gmtoff_h); B2F(gmtoff_h); if(buf[-3] == 0x2D) /* Negative */ gmtoff = -1; else gmtoff = 1; if((end - buf) == 2) { B2F(gmtoff_m); B2F(gmtoff_m); } else if(end != buf) { errno = EINVAL; return -1; } gmtoff = gmtoff * (3600 * gmtoff_h + 60 * gmtoff_m); /* Fall through */ utc_finish: offset_specified = 1; /* Fall through */ local_finish: /* * Validation. */ if((tm_s.tm_mon > 12 || tm_s.tm_mon < 1) || (tm_s.tm_mday > 31 || tm_s.tm_mday < 1) || (tm_s.tm_hour > 23) || (tm_s.tm_sec > 60) ) { errno = EINVAL; return -1; } /* Canonicalize */ tm_s.tm_mon -= 1; /* 0 - 11 */ tm_s.tm_year -= 1900; tm_s.tm_isdst = -1; tm_s.tm_sec -= gmtoff; /*** AT THIS POINT tm_s is either GMT or local (unknown) ****/ if(offset_specified) { tloc = timegm(&tm_s); } else { /* * Without an offset (or "Z"), * we can only guess that it is a local zone. * Interpret it in this fashion. */ tloc = mktime(&tm_s); } if(tloc == -1) { errno = EINVAL; return -1; } if(ret_tm) { if(as_gmt) { if(offset_specified) { *ret_tm = tm_s; } else { if(gmtime_r(&tloc, ret_tm) == 0) { errno = EINVAL; return -1; } } } else { if(localtime_r(&tloc, ret_tm) == 0) { errno = EINVAL; return -1; } } } /* Fractions of seconds */ if(frac_value) *frac_value = fvalue; if(frac_digits) *frac_digits = fdigits; return tloc; } GeneralizedTime_t * asn_time2GT(GeneralizedTime_t *opt_gt, const struct tm *tm, int force_gmt) { return asn_time2GT_frac(opt_gt, tm, 0, 0, force_gmt); } GeneralizedTime_t * asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, int frac_value, int frac_digits, int force_gmt) { struct tm tm_s; long gmtoff; const unsigned int buf_size = 4 + 2 + 2 /* yyyymmdd */ + 2 + 2 + 2 /* hhmmss */ + 1 + 6 /* .ffffff */ + 1 + 4 /* +hhmm */ + 1 /* '\0' */ ; char *buf; char *p; int size; /* Check arguments */ if(!tm) { errno = EINVAL; return 0; } /* Pre-allocate a buffer of sufficient yet small length */ buf = (char *)MALLOC(buf_size); if(!buf) return 0; gmtoff = GMTOFF(*tm); if(force_gmt && gmtoff) { tm_s = *tm; tm_s.tm_sec -= gmtoff; timegm(&tm_s); /* Fix the time */ tm = &tm_s; #ifdef HAVE_TM_GMTOFF assert(!GMTOFF(tm_s)); /* Will fix itself */ #else /* !HAVE_TM_GMTOFF */ gmtoff = 0; #endif } size = snprintf(buf, buf_size, "%04d%02d%02d%02d%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec ); if(size != 14) { /* Could be assert(size == 14); */ FREEMEM(buf); errno = EINVAL; return 0; } p = buf + size; /* * Deal with fractions. */ if(frac_value > 0 && frac_digits > 0) { char *end = p + 1 + 6; /* '.' + maximum 6 digits */ char *z = p; long fbase; *z++ = '.'; /* Place bounds on precision */ while(frac_digits-- > 6) frac_value /= 10; /* emulate fbase = pow(10, frac_digits) */ for(fbase = 1; frac_digits--;) fbase *= 10; do { int digit = frac_value / fbase; if(digit > 9) { z = 0; break; } *z++ = digit + 0x30; frac_value %= fbase; fbase /= 10; } while(fbase > 0 && frac_value > 0 && z < end); if(z) { for(--z; *z == 0x30; --z); /* Strip zeroes */ p = z + (*z != '.'); size = p - buf; } } if(force_gmt) { *p++ = 0x5a; /* "Z" */ *p++ = 0; size++; } else { int ret; gmtoff %= 86400; ret = snprintf(p, buf_size - size, "%+03ld%02ld", gmtoff / 3600, labs(gmtoff % 3600)); if(ret != 5) { FREEMEM(buf); errno = EINVAL; return 0; } size += ret; } if(opt_gt) { if(opt_gt->buf) FREEMEM(opt_gt->buf); } else { opt_gt = (GeneralizedTime_t *)CALLOC(1, sizeof *opt_gt); if(!opt_gt) { FREEMEM(buf); return 0; } } opt_gt->buf = (unsigned char *)buf; opt_gt->size = size; return opt_gt; } biosig-2.3.3/biosig4c++/t240/constr_SET_OF.c0000664000175000017500000005577614105434233020277 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Number of bytes left for this structure. * (ctx->left) indicates the number of bytes _transferred_ for the structure. * (size) contains the number of bytes in the buffer passed. */ #define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) /* * If the subprocessor function returns with an indication that it wants * more data, it may well be a fatal decoding problem, because the * size is constrained by the 's L, even if the buffer size allows * reading more data. * For example, consider the buffer containing the following TLVs: * ... * The TLV length clearly indicates that one byte is expected in V, but * if the V processor returns with "want more data" even if the buffer * contains way more data than the V processor have seen. */ #define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) /* * This macro "eats" the part of the buffer which is definitely "consumed", * i.e. was correctly converted into local representation or rightfully skipped. */ #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ ptr = ((const char *)ptr) + num;\ size -= num; \ if(ctx->left >= 0) \ ctx->left -= num; \ consumed_myself += num; \ } while(0) /* * Switch to the next phase of parsing. */ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ ctx->phase++; \ ctx->step = 0; \ } while(0) #define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) /* * Return a standardized complex structure. */ #undef RETURN #define RETURN(_code) do { \ rval.code = _code; \ rval.consumed = consumed_myself;\ return rval; \ } while(0) /* * The decoder of the SET OF type. */ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *ptr, size_t size, int tag_mode) { /* * Bring closer parts of structure description. */ asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *elm = td->elements; /* Single one */ /* * Parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ ber_tlv_tag_t tlv_tag; /* T from TLV */ asn_dec_rval_t rval; /* Return code from subparsers */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ ASN_DEBUG("Decoding %s as SET OF", td->name); /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) { RETURN(RC_FAIL); } } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Start to parse where left previously */ switch(ctx->phase) { case 0: /* * PHASE 0. * Check that the set of tags associated with given structure * perfectly fits our expectations. */ rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, 1, &ctx->left, 0); if(rval.code != RC_OK) { ASN_DEBUG("%s tagging check failed: %d", td->name, rval.code); return rval; } if(ctx->left >= 0) ctx->left += rval.consumed; /* ?Substracted below! */ ADVANCE(rval.consumed); ASN_DEBUG("Structure consumes %ld bytes, " "buffer %ld", (long)ctx->left, (long)size); NEXT_PHASE(ctx); /* Fall through */ case 1: /* * PHASE 1. * From the place where we've left it previously, * try to decode the next item. */ for(;; ctx->step = 0) { ssize_t tag_len; /* Length of TLV's T */ if(ctx->step & 1) goto microphase2; /* * MICROPHASE 1: Synchronize decoding. */ if(ctx->left == 0) { ASN_DEBUG("End of SET OF %s", td->name); /* * No more things to decode. * Exit out of here. */ PHASE_OUT(ctx); RETURN(RC_OK); } /* * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { /* * Found the terminator of the * indefinite length structure. */ break; } } /* Outmost tag may be unknown and cannot be fetched/compared */ if(elm->tag != (ber_tlv_tag_t)-1) { if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) { /* * The new list member of expected type has arrived. */ } else { ASN_DEBUG("Unexpected tag %s fixed SET OF %s", ber_tlv_tag_string(tlv_tag), td->name); ASN_DEBUG("%s SET OF has tag %s", td->name, ber_tlv_tag_string(elm->tag)); RETURN(RC_FAIL); } } /* * MICROPHASE 2: Invoke the member-specific decoder. */ ctx->step |= 1; /* Confirm entering next microphase */ microphase2: /* * Invoke the member fetch routine according to member's type */ rval = elm->type->ber_decoder(opt_codec_ctx, elm->type, &ctx->ptr, ptr, LEFT, 0); ASN_DEBUG("In %s SET OF %s code %d consumed %d", td->name, elm->type->name, rval.code, (int)rval.consumed); switch(rval.code) { case RC_OK: { asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if(ASN_SET_ADD(list, ctx->ptr) != 0) RETURN(RC_FAIL); else ctx->ptr = 0; } break; case RC_WMORE: /* More data expected */ if(!SIZE_VIOLATION) { ADVANCE(rval.consumed); RETURN(RC_WMORE); } /* Fall through */ case RC_FAIL: /* Fatal error */ ASN_STRUCT_FREE(*elm->type, ctx->ptr); ctx->ptr = 0; RETURN(RC_FAIL); } /* switch(rval) */ ADVANCE(rval.consumed); } /* for(all list members) */ NEXT_PHASE(ctx); case 2: /* * Read in all "end of content" TLVs. */ while(ctx->left < 0) { if(LEFT < 2) { if(LEFT > 0 && ((const char *)ptr)[0] != 0) { /* Unexpected tag */ RETURN(RC_FAIL); } else { RETURN(RC_WMORE); } } if(((const char *)ptr)[0] == 0 && ((const char *)ptr)[1] == 0) { ADVANCE(2); ctx->left++; } else { RETURN(RC_FAIL); } } PHASE_OUT(ctx); } RETURN(RC_OK); } /* * Internally visible buffer holding a single encoded element. */ struct _el_buffer { uint8_t *buf; size_t length; size_t size; }; /* Append bytes to the above structure */ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; if(el_buf->length + size > el_buf->size) return -1; memcpy(el_buf->buf + el_buf->length, buffer, size); el_buf->length += size; return 0; } static int _el_buf_cmp(const void *ap, const void *bp) { const struct _el_buffer *a = (const struct _el_buffer *)ap; const struct _el_buffer *b = (const struct _el_buffer *)bp; int ret; size_t common_len; if(a->length < b->length) common_len = a->length; else common_len = b->length; ret = memcmp(a->buf, b->buf, common_len); if(ret == 0) { if(a->length < b->length) ret = -1; else if(a->length > b->length) ret = 1; } return ret; } /* * The DER encoder of the SET OF type. */ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_TYPE_member_t *elm = td->elements; asn_TYPE_descriptor_t *elm_type = elm->type; der_type_encoder_f *der_encoder = elm_type->der_encoder; asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); size_t computed_size = 0; ssize_t encoding_size = 0; struct _el_buffer *encoded_els; ssize_t eels_count = 0; size_t max_encoded_len = 1; asn_enc_rval_t erval; int ret; int edx; ASN_DEBUG("Estimating size for SET OF %s", td->name); /* * Gather the length of the underlying members sequence. */ for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; if(!memb_ptr) continue; erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); if(erval.encoded == -1) return erval; computed_size += erval.encoded; /* Compute maximum encoding's size */ if(max_encoded_len < (size_t)erval.encoded) max_encoded_len = erval.encoded; } /* * Encode the TLV for the sequence itself. */ encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); if(encoding_size == -1) { erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; return erval; } computed_size += encoding_size; if(!cb || list->count == 0) { erval.encoded = computed_size; _ASN_ENCODED_OK(erval); } /* * DER mandates dynamic sorting of the SET OF elements * according to their encodings. Build an array of the * encoded elements. */ encoded_els = (struct _el_buffer *)MALLOC( list->count * sizeof(encoded_els[0])); if(encoded_els == NULL) { erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; return erval; } ASN_DEBUG("Encoding members of %s SET OF", td->name); /* * Encode all members. */ for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; struct _el_buffer *encoded_el = &encoded_els[eels_count]; if(!memb_ptr) continue; /* * Prepare space for encoding. */ encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len); if(encoded_el->buf) { encoded_el->length = 0; encoded_el->size = max_encoded_len; } else { for(edx--; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); FREEMEM(encoded_els); erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; return erval; } /* * Encode the member into the prepared space. */ erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, _el_addbytes, encoded_el); if(erval.encoded == -1) { for(; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf); FREEMEM(encoded_els); return erval; } encoding_size += erval.encoded; eels_count++; } /* * Sort the encoded elements according to their encoding. */ qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); /* * Report encoded elements to the application. * Dispose of temporary sorted members table. */ ret = 0; for(edx = 0; edx < eels_count; edx++) { struct _el_buffer *encoded_el = &encoded_els[edx]; /* Report encoded chunks to the application */ if(ret == 0 && cb(encoded_el->buf, encoded_el->length, app_key) < 0) ret = -1; FREEMEM(encoded_el->buf); } FREEMEM(encoded_els); if(ret || computed_size != (size_t)encoding_size) { /* * Standard callback failed, or * encoded size is not equal to the computed size. */ erval.encoded = -1; erval.failed_type = td; erval.structure_ptr = ptr; } else { erval.encoded = computed_size; } _ASN_ENCODED_OK(erval); } #undef XER_ADVANCE #define XER_ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ buf_ptr = ((const char *)buf_ptr) + num;\ size -= num; \ consumed_myself += num; \ } while(0) /* * Decode the XER (XML) data. */ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const char *opt_mname, const void *buf_ptr, size_t size) { /* * Bring closer parts of structure description. */ asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *element = td->elements; const char *elm_tag; const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; /* * ... and parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ asn_dec_rval_t rval; /* Return value from a decoder */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) RETURN(RC_FAIL); } /* Which tag is expected for the downstream */ if(specs->as_XMLValueList) { elm_tag = (specs->as_XMLValueList == 1) ? 0 : ""; } else { elm_tag = (*element->name) ? element->name : element->type->xml_tag; } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Phases of XER/XML processing: * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. * Phase 2: Processing inner type. */ for(; ctx->phase <= 2;) { pxer_chunk_type_e ch_type; /* XER chunk type */ ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ /* * Go inside the inner member of a set. */ if(ctx->phase == 2) { asn_dec_rval_t tmprval; /* Invoke the inner type decoder, m.b. multiple times */ ASN_DEBUG("XER/SET OF element [%s]", elm_tag); tmprval = element->type->xer_decoder(opt_codec_ctx, element->type, &ctx->ptr, elm_tag, buf_ptr, size); if(tmprval.code == RC_OK) { asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); if(ASN_SET_ADD(list, ctx->ptr) != 0) RETURN(RC_FAIL); ctx->ptr = 0; XER_ADVANCE(tmprval.consumed); } else { XER_ADVANCE(tmprval.consumed); RETURN(tmprval.code); } ctx->phase = 1; /* Back to body processing */ ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); /* Fall through */ } /* * Get the next part of the XML stream. */ ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type); switch(ch_size) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); default: switch(ch_type) { case PXER_COMMENT: /* Got XML comment */ case PXER_TEXT: /* Ignore free-standing text */ XER_ADVANCE(ch_size); /* Skip silently */ continue; case PXER_TAG: break; /* Check the rest down there */ } } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", tcv, ctx->phase, xml_tag); switch(tcv) { case XCT_CLOSING: if(ctx->phase == 0) break; ctx->phase = 0; /* Fall through */ case XCT_BOTH: if(ctx->phase == 0) { /* No more things to decode */ XER_ADVANCE(ch_size); ctx->phase = 3; /* Phase out */ RETURN(RC_OK); } /* Fall through */ case XCT_OPENING: if(ctx->phase == 0) { XER_ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; } /* Fall through */ case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); if(ctx->phase == 1) { /* * Process a single possible member. */ ctx->phase = 2; continue; } /* Fall through */ default: break; } ASN_DEBUG("Unexpected XML tag in SET OF"); break; } ctx->phase = 3; /* "Phase out" on hard failure */ RETURN(RC_FAIL); } typedef struct xer_tmp_enc_s { void *buffer; size_t offset; size_t size; } xer_tmp_enc_t; static int SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) { xer_tmp_enc_t *t = (xer_tmp_enc_t *)key; if(t->offset + size >= t->size) { size_t newsize = (t->size << 2) + size; void *p = REALLOC(t->buffer, newsize); if(!p) return -1; t->buffer = p; t->size = newsize; } memcpy((char *)t->buffer + t->offset, buffer, size); t->offset += size; return 0; } static int SET_OF_xer_order(const void *aptr, const void *bptr) { const xer_tmp_enc_t *a = (const xer_tmp_enc_t *)aptr; const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; size_t minlen = a->offset; int ret; if(b->offset < minlen) minlen = b->offset; /* Well-formed UTF-8 has this nice lexicographical property... */ ret = memcmp(a->buffer, b->buffer, minlen); if(ret != 0) return ret; if(a->offset == b->offset) return 0; if(a->offset == minlen) return -1; return 1; } asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er; asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *elm = td->elements; asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr); const char *mname = specs->as_XMLValueList ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); size_t mlen = mname ? strlen(mname) : 0; int xcan = (flags & XER_F_CANONICAL); xer_tmp_enc_t *encs = 0; size_t encs_count = 0; void *original_app_key = app_key; asn_app_consume_bytes_f *original_cb = cb; int i; if(!sptr) _ASN_ENCODE_FAILED; if(xcan) { encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); if(!encs) _ASN_ENCODE_FAILED; cb = SET_OF_encode_xer_callback; } er.encoded = 0; for(i = 0; i < list->count; i++) { asn_enc_rval_t tmper; void *memb_ptr = list->array[i]; if(!memb_ptr) continue; if(encs) { memset(&encs[encs_count], 0, sizeof(encs[0])); app_key = &encs[encs_count]; encs_count++; } if(mname) { if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); } if(!xcan && specs->as_XMLValueList == 1) _i_ASN_TEXT_INDENT(1, ilevel + 1); tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2), flags, cb, app_key); if(tmper.encoded == -1) { td = tmper.failed_type; sptr = tmper.structure_ptr; goto cb_failed; } if(tmper.encoded == 0 && specs->as_XMLValueList) { const char *name = elm->type->xml_tag; size_t len = strlen(name); _ASN_CALLBACK3("<", 1, name, len, "/>", 2); } if(mname) { _ASN_CALLBACK3("", 1); er.encoded += 5; } er.encoded += (2 * mlen) + tmper.encoded; } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); if(encs) { xer_tmp_enc_t *enc = encs; xer_tmp_enc_t *end = encs + encs_count; ssize_t control_size = 0; cb = original_cb; app_key = original_app_key; qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order); for(; enc < end; enc++) { _ASN_CALLBACK(enc->buffer, enc->offset); FREEMEM(enc->buffer); enc->buffer = 0; control_size += enc->offset; } assert(control_size == er.encoded); } goto cleanup; cb_failed: er.encoded = -1; er.failed_type = td; er.structure_ptr = sptr; cleanup: if(encs) { while(encs_count-- > 0) { if(encs[encs_count].buffer) FREEMEM(encs[encs_count].buffer); } FREEMEM(encs); } _ASN_ENCODED_OK(er); } int SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { asn_TYPE_member_t *elm = td->elements; const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); int ret; int i; if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; /* Dump preamble */ if(cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) return -1; for(i = 0; i < list->count; i++) { const void *memb_ptr = list->array[i]; if(!memb_ptr) continue; _i_INDENT(1); ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } ilevel--; _i_INDENT(1); return (cb("}", 1, app_key) < 0) ? -1 : 0; } void SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { if(td && ptr) { asn_SET_OF_specifics_t *specs; asn_TYPE_member_t *elm = td->elements; asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); asn_struct_ctx_t *ctx; /* Decoder context */ int i; /* * Could not use set_of_empty() because of (*free) * incompatibility. */ for(i = 0; i < list->count; i++) { void *memb_ptr = list->array[i]; if(memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); } list->count = 0; /* No meaningful elements left */ asn_set_empty(list); /* Remove (list->array) */ specs = (asn_SET_OF_specifics_t *)td->specifics; ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset); if(ctx->ptr) { ASN_STRUCT_FREE(*elm->type, ctx->ptr); ctx->ptr = 0; } if(!contents_only) { FREEMEM(ptr); } } } int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { asn_TYPE_member_t *elm = td->elements; asn_constr_check_f *constr; const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); int i; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } constr = elm->memb_constraints; if(!constr) constr = elm->type->check_constraints; /* * Iterate over the members of an array. * Validate each in turn, until one fails. */ for(i = 0; i < list->count; i++) { const void *memb_ptr = list->array[i]; int ret; if(!memb_ptr) continue; ret = constr(elm->type, memb_ptr, ctfailcb, app_key); if(ret) return ret; } /* * Cannot inherit it eralier: * need to make sure we get the updated version. */ if(!elm->memb_constraints) elm->memb_constraints = elm->type->check_constraints; return 0; } asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_dec_rval_t rv; asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *elm = td->elements; /* Single one */ void *st = *sptr; asn_anonymous_set_ *list; asn_per_constraint_t *ct; int repeat = 0; ssize_t nelems; if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; /* * Create the target structure if it is not present already. */ if(!st) { st = *sptr = CALLOC(1, specs->struct_size); if(!st) _ASN_DECODE_FAILED; } list = _A_SET_FROM_VOID(st); /* Figure out which constraints to use */ if(constraints) ct = &constraints->size; else if(td->per_constraints) ct = &td->per_constraints->size; else ct = 0; if(ct && ct->flags & APC_EXTENSIBLE) { int value = per_get_few_bits(pd, 1); if(value < 0) _ASN_DECODE_STARVED; if(value) ct = 0; /* Not restricted! */ } if(ct && ct->effective_bits >= 0) { /* X.691, #19.5: No length determinant */ nelems = per_get_few_bits(pd, ct->effective_bits); ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s", (long)nelems, ct->lower_bound, td->name); if(nelems < 0) _ASN_DECODE_STARVED; nelems += ct->lower_bound; } else { nelems = -1; } do { int i; if(nelems < 0) { nelems = uper_get_length(pd, ct ? ct->effective_bits : -1, &repeat); ASN_DEBUG("Got to decode %d elements (eff %d)", (int)nelems, (int)ct ? ct->effective_bits : -1); if(nelems < 0) _ASN_DECODE_STARVED; } for(i = 0; i < nelems; i++) { void *ptr = 0; ASN_DEBUG("SET OF %s decoding", elm->type->name); rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, &ptr, pd); ASN_DEBUG("%s SET OF %s decoded %d, %p", td->name, elm->type->name, rv.code, ptr); if(rv.code == RC_OK) { if(ASN_SET_ADD(list, ptr) == 0) continue; ASN_DEBUG("Failed to add element into %s", td->name); /* Fall through */ rv.code = RC_FAIL; } else { ASN_DEBUG("Failed decoding %s of %s (SET OF)", elm->type->name, td->name); } if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); return rv; } nelems = -1; /* Allow uper_get_length() */ } while(repeat); ASN_DEBUG("Decoded %s as SET OF", td->name); rv.code = RC_OK; rv.consumed = 0; return rv; } biosig-2.3.3/biosig4c++/t240/constr_SEQUENCE_OF.h0000664000175000017500000000164214105434233021040 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2005 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _CONSTR_SEQUENCE_OF_H_ #define _CONSTR_SEQUENCE_OF_H_ #include #include /* Implemented using SET OF */ #ifdef __cplusplus extern "C" { #endif /* * A set specialized functions dealing with the SEQUENCE OF type. * Generally implemented using SET OF. */ #define SEQUENCE_OF_free SET_OF_free #define SEQUENCE_OF_print SET_OF_print #define SEQUENCE_OF_constraint SET_OF_constraint #define SEQUENCE_OF_decode_ber SET_OF_decode_ber #define SEQUENCE_OF_decode_xer SET_OF_decode_xer #define SEQUENCE_OF_decode_uper SET_OF_decode_uper der_type_encoder_f SEQUENCE_OF_encode_der; xer_type_encoder_f SEQUENCE_OF_encode_xer; per_type_encoder_f SEQUENCE_OF_encode_uper; #ifdef __cplusplus } #endif #endif /* _CONSTR_SET_OF_H_ */ biosig-2.3.3/biosig4c++/t240/RelativeTime.c0000664000175000017500000000720614105434233020243 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "RelativeTime.h" int RelativeTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void RelativeTime_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void RelativeTime_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { RelativeTime_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int RelativeTime_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { RelativeTime_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t RelativeTime_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { RelativeTime_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t RelativeTime_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { RelativeTime_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t RelativeTime_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { RelativeTime_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t RelativeTime_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { RelativeTime_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_RelativeTime_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_RelativeTime = { "RelativeTime", "RelativeTime", RelativeTime_free, RelativeTime_print, RelativeTime_constraint, RelativeTime_decode_ber, RelativeTime_encode_der, RelativeTime_decode_xer, RelativeTime_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_RelativeTime_tags_1, sizeof(asn_DEF_RelativeTime_tags_1) /sizeof(asn_DEF_RelativeTime_tags_1[0]), /* 1 */ asn_DEF_RelativeTime_tags_1, /* Same as above */ sizeof(asn_DEF_RelativeTime_tags_1) /sizeof(asn_DEF_RelativeTime_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/BITS-32.h0000664000175000017500000000136614105434233016642 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _BITS_32_H_ #define _BITS_32_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* BITS-32 */ typedef BIT_STRING_t BITS_32_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_BITS_32; asn_struct_free_f BITS_32_free; asn_struct_print_f BITS_32_print; asn_constr_check_f BITS_32_constraint; ber_type_decoder_f BITS_32_decode_ber; der_type_encoder_f BITS_32_encode_der; xer_type_decoder_f BITS_32_decode_xer; xer_type_encoder_f BITS_32_encode_xer; #ifdef __cplusplus } #endif #endif /* _BITS_32_H_ */ biosig-2.3.3/biosig4c++/t240/INT-U16.c0000664000175000017500000000743114105434233016654 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-U16.h" int INT_U16_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= 0 && value <= 65535)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void INT_U16_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeInteger.free_struct; td->print_struct = asn_DEF_NativeInteger.print_struct; td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; td->der_encoder = asn_DEF_NativeInteger.der_encoder; td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeInteger.per_constraints; td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; } void INT_U16_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_U16_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_U16_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_U16_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_U16_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_U16_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_U16_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_U16_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_U16_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_U16_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_U16_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_U16_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_U16_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_U16 = { "INT-U16", "INT-U16", INT_U16_free, INT_U16_print, INT_U16_constraint, INT_U16_decode_ber, INT_U16_encode_der, INT_U16_decode_xer, INT_U16_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_U16_tags_1, sizeof(asn_DEF_INT_U16_tags_1) /sizeof(asn_DEF_INT_U16_tags_1[0]), /* 1 */ asn_DEF_INT_U16_tags_1, /* Same as above */ sizeof(asn_DEF_INT_U16_tags_1) /sizeof(asn_DEF_INT_U16_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/AbsoluteTime.c0000664000175000017500000000736714105434233020256 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AbsoluteTime.h" int AbsoluteTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_GeneralizedTime.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using GeneralizedTime, * so here we adjust the DEF accordingly. */ static void AbsoluteTime_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_GeneralizedTime.free_struct; td->print_struct = asn_DEF_GeneralizedTime.print_struct; td->ber_decoder = asn_DEF_GeneralizedTime.ber_decoder; td->der_encoder = asn_DEF_GeneralizedTime.der_encoder; td->xer_decoder = asn_DEF_GeneralizedTime.xer_decoder; td->xer_encoder = asn_DEF_GeneralizedTime.xer_encoder; td->uper_decoder = asn_DEF_GeneralizedTime.uper_decoder; td->uper_encoder = asn_DEF_GeneralizedTime.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_GeneralizedTime.per_constraints; td->elements = asn_DEF_GeneralizedTime.elements; td->elements_count = asn_DEF_GeneralizedTime.elements_count; td->specifics = asn_DEF_GeneralizedTime.specifics; } void AbsoluteTime_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { AbsoluteTime_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int AbsoluteTime_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { AbsoluteTime_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t AbsoluteTime_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { AbsoluteTime_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t AbsoluteTime_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { AbsoluteTime_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t AbsoluteTime_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { AbsoluteTime_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t AbsoluteTime_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { AbsoluteTime_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_AbsoluteTime_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (24 << 2)) }; asn_TYPE_descriptor_t asn_DEF_AbsoluteTime = { "AbsoluteTime", "AbsoluteTime", AbsoluteTime_free, AbsoluteTime_print, AbsoluteTime_constraint, AbsoluteTime_decode_ber, AbsoluteTime_encode_der, AbsoluteTime_decode_xer, AbsoluteTime_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AbsoluteTime_tags_1, sizeof(asn_DEF_AbsoluteTime_tags_1) /sizeof(asn_DEF_AbsoluteTime_tags_1[0]), /* 1 */ asn_DEF_AbsoluteTime_tags_1, /* Same as above */ sizeof(asn_DEF_AbsoluteTime_tags_1) /sizeof(asn_DEF_AbsoluteTime_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/GeneralizedTime.c.modified0000664000175000017500000003600614105434233022500 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #define _POSIX_PTHREAD_SEMANTICS /* for Sun */ #define _REENTRANT /* for Sun */ #include #include #include #ifdef __CYGWIN__ #include "/usr/include/time.h" #else #include #endif /* __CYGWIN__ */ #if defined(WIN32) #pragma message( "PLEASE STOP AND READ!") #pragma message( " localtime_r is implemented via localtime(), which may be not thread-safe.") #pragma message( " gmtime_r is implemented via gmtime(), which may be not thread-safe.") #pragma message( " ") #pragma message( " You must fix the code by inserting appropriate locking") #pragma message( " if you want to use asn_GT2time() or asn_UT2time().") #pragma message( "PLEASE STOP AND READ!") static struct tm *localtime_r(const time_t *tloc, struct tm *result) { struct tm *tm; if((tm = localtime(tloc))) return memcpy(result, tm, sizeof(struct tm)); return 0; } static struct tm *gmtime_r(const time_t *tloc, struct tm *result) { struct tm *tm; if((tm = gmtime(tloc))) return memcpy(result, tm, sizeof(struct tm)); return 0; } #define tzset() _tzset() #define putenv(c) _putenv(c) #define _EMULATE_TIMEGM #endif /* WIN32 */ #if defined(sun) || defined(_sun_) || defined(__solaris__) #define _EMULATE_TIMEGM #endif /* * Where to look for offset from GMT, Phase I. * Several platforms are known. */ #if defined(__FreeBSD__) \ || (defined(__GNUC__) && defined(__APPLE_CC__)) \ || (defined __GLIBC__ && __GLIBC__ >= 2) #undef HAVE_TM_GMTOFF #define HAVE_TM_GMTOFF #endif /* BSDs and newer glibc */ /* * Where to look for offset from GMT, Phase II. */ #ifdef HAVE_TM_GMTOFF #define GMTOFF(tm) ((tm).tm_gmtoff) #else /* HAVE_TM_GMTOFF */ #define GMTOFF(tm) (-timezone) #endif /* HAVE_TM_GMTOFF */ #if (defined(_EMULATE_TIMEGM) || !defined(HAVE_TM_GMTOFF)) #warning "PLEASE STOP AND READ!" #warning " timegm() is implemented via getenv(\"TZ\")/setenv(\"TZ\"), which may be not thread-safe." #warning " " #warning " You must fix the code by inserting appropriate locking" #warning " if you want to use asn_GT2time() or asn_UT2time()." #warning "PLEASE STOP AND READ!" #endif /* _EMULATE_TIMEGM */ /* * Override our GMTOFF decision for other known platforms. */ #ifdef __CYGWIN__ #undef GMTOFF static long GMTOFF(struct tm a){ struct tm *lt; time_t local_time, gmt_time; long zone; tzset(); gmt_time = time (NULL); lt = gmtime(&gmt_time); local_time = mktime(lt); return (gmt_time - local_time); } #define _EMULATE_TIMEGM #endif /* __CYGWIN__ */ #define ATZVARS do { \ char tzoldbuf[64]; \ char *tzold #define ATZSAVETZ do { \ tzold = getenv("TZ"); \ if(tzold) { \ size_t tzlen = strlen(tzold); \ if(tzlen < sizeof(tzoldbuf)) \ tzold = memcpy(tzoldbuf, tzold, tzlen + 1); \ else \ tzold = strdup(tzold); /* Ignore error */ \ #ifdef __MINGW32__ \ putenv("TZ= UTC"); \ #else \ setenv("TZ", "UTC", 1); \ #endif \ } \ tzset(); \ } while(0) #define ATZOLDTZ do { \ if (tzold) { \ #ifdef __MINGW32__ \ putenv("TZ= UTC"); \ #else \ setenv("TZ", tzold, 1); \ #endif \ *tzoldbuf = 0; \ if(tzold != tzoldbuf) \ FREEMEM(tzold); \ } else { \ #ifdef __MINGW32__ \ putenv("TZ= "); \ #else \ unsetenv("TZ"); \ #endif \ } \ tzset(); \ } while(0); } while(0); #ifdef _EMULATE_TIMEGM static time_t timegm(struct tm *tm) { time_t tloc; ATZVARS; ATZSAVETZ; tloc = mktime(tm); ATZOLDTZ; return tloc; } #endif /* _EMULATE_TIMEGM */ #ifndef __ASN_INTERNAL_TEST_MODE__ /* * GeneralizedTime basic type description. */ static ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (24 << 2)), /* [UNIVERSAL 24] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { "GeneralizedTime", "GeneralizedTime", OCTET_STRING_free, GeneralizedTime_print, GeneralizedTime_constraint, /* Check validity of time */ OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ GeneralizedTime_encode_der, OCTET_STRING_decode_xer_utf8, GeneralizedTime_encode_xer, 0, 0, 0, /* Use generic outmost tag fetcher */ asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]) - 2, asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; #endif /* __ASN_INTERNAL_TEST_MODE__ */ /* * Check that the time looks like the time. */ int GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr; time_t tloc; errno = EPERM; /* Just an unlikely error code */ tloc = asn_GT2time(st, 0, 0); if(tloc == -1 && errno != EPERM) { _ASN_CTFAIL(app_key, td, "%s: Invalid time format: %s (%s:%d)", td->name, strerror(errno), __FILE__, __LINE__); return -1; } return 0; } asn_enc_rval_t GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { GeneralizedTime_t *st = (GeneralizedTime_t *)sptr; asn_enc_rval_t erval; int fv, fd; /* seconds fraction value and number of digits */ struct tm tm; time_t tloc; /* * Encode as a canonical DER. */ errno = EPERM; tloc = asn_GT2time_frac(st, &fv, &fd, &tm, 1); /* Recognize time */ if(tloc == -1 && errno != EPERM) /* Failed to recognize time. Fail completely. */ _ASN_ENCODE_FAILED; st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */ if(!st) _ASN_ENCODE_FAILED; /* Memory allocation failure. */ erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key); FREEMEM(st->buf); FREEMEM(st); return erval; } #ifndef __ASN_INTERNAL_TEST_MODE__ asn_enc_rval_t GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { if(flags & XER_F_CANONICAL) { GeneralizedTime_t *gt; asn_enc_rval_t rv; int fv, fd; /* fractional parts */ struct tm tm; errno = EPERM; if(asn_GT2time_frac((GeneralizedTime_t *)sptr, &fv, &fd, &tm, 1) == -1 && errno != EPERM) _ASN_ENCODE_FAILED; gt = asn_time2GT_frac(0, &tm, fv, fd, 1); if(!gt) _ASN_ENCODE_FAILED; rv = OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); ASN_STRUCT_FREE(asn_DEF_GeneralizedTime, gt); return rv; } else { return OCTET_STRING_encode_xer_utf8(td, sptr, ilevel, flags, cb, app_key); } } #endif /* __ASN_INTERNAL_TEST_MODE__ */ int GeneralizedTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(st && st->buf) { char buf[32]; struct tm tm; int ret; errno = EPERM; if(asn_GT2time(st, &tm, 1) == -1 && errno != EPERM) return (cb("", 11, app_key) < 0) ? -1 : 0; ret = snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d (GMT)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); assert(ret > 0 && ret < (int)sizeof(buf)); return (cb(buf, ret, app_key) < 0) ? -1 : 0; } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } time_t asn_GT2time(const GeneralizedTime_t *st, struct tm *ret_tm, int as_gmt) { return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); } time_t asn_GT2time_prec(const GeneralizedTime_t *st, int *frac_value, int frac_digits, struct tm *ret_tm, int as_gmt) { time_t tloc; int fv, fd = 0; if(frac_value) tloc = asn_GT2time_frac(st, &fv, &fd, ret_tm, as_gmt); else return asn_GT2time_frac(st, 0, 0, ret_tm, as_gmt); if(fd == 0 || frac_digits <= 0) { *frac_value = 0; } else { while(fd > frac_digits) fv /= 10, fd--; while(fd < frac_digits) { int new_fv = fv * 10; if(new_fv / 10 != fv) { /* Too long precision request */ fv = 0; break; } fv = new_fv, fd++; } *frac_value = fv; } return tloc; } time_t asn_GT2time_frac(const GeneralizedTime_t *st, int *frac_value, int *frac_digits, struct tm *ret_tm, int as_gmt) { struct tm tm_s; uint8_t *buf; uint8_t *end; int gmtoff_h = 0; int gmtoff_m = 0; int gmtoff = 0; /* h + m */ int offset_specified = 0; int fvalue = 0; int fdigits = 0; time_t tloc; if(!st || !st->buf) { errno = EINVAL; return -1; } else { buf = st->buf; end = buf + st->size; } if(st->size < 10) { errno = EINVAL; return -1; } /* * Decode first 10 bytes: "AAAAMMJJhh" */ memset(&tm_s, 0, sizeof(tm_s)); #undef B2F #undef B2T #define B2F(var) do { \ unsigned ch = *buf; \ if(ch < 0x30 || ch > 0x39) { \ errno = EINVAL; \ return -1; \ } else { \ var = var * 10 + (ch - 0x30); \ buf++; \ } \ } while(0) #define B2T(var) B2F(tm_s.var) B2T(tm_year); /* 1: A */ B2T(tm_year); /* 2: A */ B2T(tm_year); /* 3: A */ B2T(tm_year); /* 4: A */ B2T(tm_mon); /* 5: M */ B2T(tm_mon); /* 6: M */ B2T(tm_mday); /* 7: J */ B2T(tm_mday); /* 8: J */ B2T(tm_hour); /* 9: h */ B2T(tm_hour); /* 0: h */ if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^^ */ switch(*buf) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: tm_s.tm_min = (*buf++) - 0x30; if(buf == end) { errno = EINVAL; return -1; } B2T(tm_min); break; case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^^ */ switch(*buf) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: tm_s.tm_sec = (*buf++) - 0x30; if(buf == end) { errno = EINVAL; return -1; } B2T(tm_sec); break; case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } if(buf == end) goto local_finish; /* * Parse [mm[ss[(.|,)ffff]]] * ^ ^ */ switch(*buf) { case 0x2C: case 0x2E: /* (.|,) */ /* * Process fractions of seconds. */ for(buf++; buf < end; buf++) { int v = *buf; int new_fvalue; switch(v) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: new_fvalue = fvalue * 10 + (v - 0x30); if(new_fvalue / 10 != fvalue) { /* Not enough precision, ignore */ } else { fvalue = new_fvalue; fdigits++; } continue; default: break; } break; } } if(buf == end) goto local_finish; switch(*buf) { case 0x2B: case 0x2D: /* +, - */ goto offset; case 0x5A: /* Z */ goto utc_finish; default: errno = EINVAL; return -1; } offset: if(end - buf < 3) { errno = EINVAL; return -1; } buf++; B2F(gmtoff_h); B2F(gmtoff_h); if(buf[-3] == 0x2D) /* Negative */ gmtoff = -1; else gmtoff = 1; if((end - buf) == 2) { B2F(gmtoff_m); B2F(gmtoff_m); } else if(end != buf) { errno = EINVAL; return -1; } gmtoff = gmtoff * (3600 * gmtoff_h + 60 * gmtoff_m); /* Fall through */ utc_finish: offset_specified = 1; /* Fall through */ local_finish: /* * Validation. */ if((tm_s.tm_mon > 12 || tm_s.tm_mon < 1) || (tm_s.tm_mday > 31 || tm_s.tm_mday < 1) || (tm_s.tm_hour > 23) || (tm_s.tm_sec > 60) ) { errno = EINVAL; return -1; } /* Canonicalize */ tm_s.tm_mon -= 1; /* 0 - 11 */ tm_s.tm_year -= 1900; tm_s.tm_isdst = -1; tm_s.tm_sec -= gmtoff; /*** AT THIS POINT tm_s is either GMT or local (unknown) ****/ if(offset_specified) { tloc = timegm(&tm_s); } else { /* * Without an offset (or "Z"), * we can only guess that it is a local zone. * Interpret it in this fashion. */ tloc = mktime(&tm_s); } if(tloc == -1) { errno = EINVAL; return -1; } if(ret_tm) { if(as_gmt) { if(offset_specified) { *ret_tm = tm_s; } else { if(gmtime_r(&tloc, ret_tm) == 0) { errno = EINVAL; return -1; } } } else { if(localtime_r(&tloc, ret_tm) == 0) { errno = EINVAL; return -1; } } } /* Fractions of seconds */ if(frac_value) *frac_value = fvalue; if(frac_digits) *frac_digits = fdigits; return tloc; } GeneralizedTime_t * asn_time2GT(GeneralizedTime_t *opt_gt, const struct tm *tm, int force_gmt) { return asn_time2GT_frac(opt_gt, tm, 0, 0, force_gmt); } GeneralizedTime_t * asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, int frac_value, int frac_digits, int force_gmt) { struct tm tm_s; long gmtoff; const unsigned int buf_size = 4 + 2 + 2 /* yyyymmdd */ + 2 + 2 + 2 /* hhmmss */ + 1 + 6 /* .ffffff */ + 1 + 4 /* +hhmm */ + 1 /* '\0' */ ; char *buf; char *p; int size; /* Check arguments */ if(!tm) { errno = EINVAL; return 0; } /* Pre-allocate a buffer of sufficient yet small length */ buf = (char *)MALLOC(buf_size); if(!buf) return 0; gmtoff = GMTOFF(*tm); if(force_gmt && gmtoff) { tm_s = *tm; tm_s.tm_sec -= gmtoff; timegm(&tm_s); /* Fix the time */ tm = &tm_s; #ifdef HAVE_TM_GMTOFF assert(!GMTOFF(tm_s)); /* Will fix itself */ #else /* !HAVE_TM_GMTOFF */ gmtoff = 0; #endif } size = snprintf(buf, buf_size, "%04d%02d%02d%02d%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec ); if(size != 14) { /* Could be assert(size == 14); */ FREEMEM(buf); errno = EINVAL; return 0; } p = buf + size; /* * Deal with fractions. */ if(frac_value > 0 && frac_digits > 0) { char *end = p + 1 + 6; /* '.' + maximum 6 digits */ char *z = p; long fbase; *z++ = '.'; /* Place bounds on precision */ while(frac_digits-- > 6) frac_value /= 10; /* emulate fbase = pow(10, frac_digits) */ for(fbase = 1; frac_digits--;) fbase *= 10; do { int digit = frac_value / fbase; if(digit > 9) { z = 0; break; } *z++ = digit + 0x30; frac_value %= fbase; fbase /= 10; } while(fbase > 0 && frac_value > 0 && z < end); if(z) { for(--z; *z == 0x30; --z); /* Strip zeroes */ p = z + (*z != '.'); size = p - buf; } } if(force_gmt) { *p++ = 0x5a; /* "Z" */ *p++ = 0; size++; } else { int ret; gmtoff %= 86400; ret = snprintf(p, buf_size - size, "%+03ld%02ld", gmtoff / 3600, labs(gmtoff % 3600)); if(ret != 5) { FREEMEM(buf); errno = EINVAL; return 0; } size += ret; } if(opt_gt) { if(opt_gt->buf) FREEMEM(opt_gt->buf); } else { opt_gt = (GeneralizedTime_t *)CALLOC(1, sizeof *opt_gt); if(!opt_gt) { FREEMEM(buf); return 0; } } opt_gt->buf = (unsigned char *)buf; opt_gt->size = size; return opt_gt; } biosig-2.3.3/biosig4c++/t240/xer_support.h0000664000175000017500000000342414105434233020246 0ustar schloeglschloegl/* * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com. * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _XER_SUPPORT_H_ #define _XER_SUPPORT_H_ #include /* Platform-specific types */ #ifdef __cplusplus extern "C" { #endif /* * Types of data transferred to the application. */ typedef enum { PXML_TEXT, /* Plain text between XML tags. */ PXML_TAG, /* A tag, starting with '<'. */ PXML_COMMENT, /* An XML comment, including "". */ /* * The following chunk types are reported if the chunk * terminates the specified XML element. */ PXML_TAG_END, /* Tag ended */ PXML_COMMENT_END /* Comment ended */ } pxml_chunk_type_e; /* * Callback function that is called by the parser when parsed data is * available. The _opaque is the pointer to a field containing opaque user * data specified in pxml_create() call. The chunk type is _type and the text * data is the piece of buffer identified by _bufid (as supplied to * pxml_feed() call) starting at offset _offset and of _size bytes size. * The chunk is NOT '\0'-terminated. */ typedef int (pxml_callback_f)(pxml_chunk_type_e _type, const void *_chunk_data, size_t _chunk_size, void *_key); /* * Parse the given buffer as it were a chunk of XML data. * Invoke the specified callback each time the meaninful data is found. * This function returns number of bytes consumed from the bufer. * It will always be lesser than or equal to the specified _size. * The next invocation of this function must account the difference. */ ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size, pxml_callback_f *cb, void *_key); #ifdef __cplusplus } #endif #endif /* _XER_SUPPORT_H_ */ biosig-2.3.3/biosig4c++/t240/REAL.c0000664000175000017500000003723514105434233016401 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2006 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #if defined(__alpha) #define _ISOC99_SOURCE /* For quiet NAN, through bits/nan.h */ #define _BSD_SOURCE /* To reintroduce finite(3) */ #include /* For INFINITY */ #endif #include #include /* for strtod(3) */ #include #include #include #include #undef INT_MAX #define INT_MAX ((int)(((unsigned int)-1) >> 1)) #if !(defined(NAN) || defined(INFINITY)) static volatile double real_zero GCC_NOTUSED = 0.0; #endif #ifndef NAN #define NAN (real_zero/real_zero) #endif #ifndef INFINITY #define INFINITY (1.0/real_zero) #endif /* * REAL basic type description. */ static ber_tlv_tag_t asn_DEF_REAL_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)) }; asn_TYPE_descriptor_t asn_DEF_REAL = { "REAL", "REAL", ASN__PRIMITIVE_TYPE_free, REAL_print, asn_generic_no_constraint, ber_decode_primitive, der_encode_primitive, REAL_decode_xer, REAL_encode_xer, REAL_decode_uper, REAL_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_REAL_tags, sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), asn_DEF_REAL_tags, /* Same as above */ sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; typedef enum specialRealValue { SRV__NOT_A_NUMBER, SRV__MINUS_INFINITY, SRV__PLUS_INFINITY } specialRealValue_e; static struct specialRealValue_s { char *string; size_t length; long dv; } specialRealValue[] = { #define SRV_SET(foo, val) { foo, sizeof(foo) - 1, val } SRV_SET("", 0), SRV_SET("", -1), SRV_SET("", 1), #undef SRV_SET }; ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key) { char local_buf[64]; char *buf = local_buf; ssize_t buflen = sizeof(local_buf); const char *fmt = canonical?"%.15E":"%.15f"; ssize_t ret; /* * Check whether it is a special value. */ /* fpclassify(3) is not portable yet */ if(isnan(d)) { buf = specialRealValue[SRV__NOT_A_NUMBER].string; buflen = specialRealValue[SRV__NOT_A_NUMBER].length; return (cb(buf, buflen, app_key) < 0) ? -1 : buflen; } else if(!finite(d)) { if(copysign(1.0, d) < 0.0) { buf = specialRealValue[SRV__MINUS_INFINITY].string; buflen = specialRealValue[SRV__MINUS_INFINITY].length; } else { buf = specialRealValue[SRV__PLUS_INFINITY].string; buflen = specialRealValue[SRV__PLUS_INFINITY].length; } return (cb(buf, buflen, app_key) < 0) ? -1 : buflen; } else if(ilogb(d) <= -INT_MAX) { if(copysign(1.0, d) < 0.0) { buf = "-0"; buflen = 2; } else { buf = "0"; buflen = 1; } return (cb(buf, buflen, app_key) < 0) ? -1 : buflen; } /* * Use the libc's double printing, hopefully they got it right. */ do { ret = snprintf(buf, buflen, fmt, d); if(ret < 0) { buflen <<= 1; } else if(ret >= buflen) { buflen = ret + 1; } else { buflen = ret; break; } if(buf != local_buf) FREEMEM(buf); buf = (char *)MALLOC(buflen); if(!buf) return -1; } while(1); if(canonical) { /* * Transform the "[-]d.dddE+-dd" output into "[-]d.dddE[-]d" * Check that snprintf() constructed the output correctly. */ char *dot, *E; char *end = buf + buflen; char *last_zero; dot = (buf[0] == 0x2d /* '-' */) ? (buf + 2) : (buf + 1); if(*dot >= 0x30) { errno = EINVAL; return -1; /* Not a dot, really */ } *dot = 0x2e; /* Replace possible comma */ for(last_zero = dot + 2, E = dot; dot < end; E++) { if(*E == 0x45) { char *expptr = ++E; char *s = expptr; int sign; if(*expptr == 0x2b /* '+' */) { /* Skip the "+" */ buflen -= 1; sign = 0; } else { sign = 1; s++; } expptr++; if(expptr > end) { errno = EINVAL; return -1; } if(*expptr == 0x30) { buflen--; expptr++; } if(*last_zero == 0x30) { *last_zero = 0x45; /* E */ buflen -= s - (last_zero + 1); s = last_zero + 1; if(sign) { *s++ = 0x2d /* '-' */; buflen++; } } for(; expptr <= end; s++, expptr++) *s = *expptr; break; } else if(*E == 0x30) { if(*last_zero != 0x30) last_zero = E; } } if(E == end) { errno = EINVAL; return -1; /* No promised E */ } } else { /* * Remove trailing zeros. */ char *end = buf + buflen; char *last_zero = end; int stoplooking = 0; char *z; for(z = end - 1; z > buf; z--) { switch(*z) { case 0x30: if(!stoplooking) last_zero = z; continue; case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: stoplooking = 1; continue; default: /* Catch dot and other separators */ /* * Replace possible comma (which may even * be not a comma at all: locale-defined). */ *z = 0x2e; if(last_zero == z + 1) { /* leave x.0 */ last_zero++; } buflen = last_zero - buf; *last_zero = '\0'; break; } break; } } ret = cb(buf, buflen, app_key); if(buf != local_buf) FREEMEM(buf); return (ret < 0) ? -1 : buflen; } int REAL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const REAL_t *st = (const REAL_t *)sptr; ssize_t ret; double d; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(!st || !st->buf) ret = cb("", 8, app_key); else if(asn_REAL2double(st, &d)) ret = cb("", 7, app_key); else ret = REAL__dump(d, 0, cb, app_key); return (ret < 0) ? -1 : 0; } asn_enc_rval_t REAL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { REAL_t *st = (REAL_t *)sptr; asn_enc_rval_t er; double d; (void)ilevel; if(!st || !st->buf || asn_REAL2double(st, &d)) _ASN_ENCODE_FAILED; er.encoded = REAL__dump(d, flags & XER_F_CANONICAL, cb, app_key); if(er.encoded < 0) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } /* * Decode the chunk of XML text encoding REAL. */ static enum xer_pbd_rval REAL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) { REAL_t *st = (REAL_t *)sptr; double value; const char *xerdata = (const char *)chunk_buf; char *endptr = 0; char *b; (void)td; if(!chunk_size) return XPBD_BROKEN_ENCODING; /* * Decode an XMLSpecialRealValue: , etc. */ if(xerdata[0] == 0x3c /* '<' */) { size_t i; for(i = 0; i < sizeof(specialRealValue) / sizeof(specialRealValue[0]); i++) { struct specialRealValue_s *srv = &specialRealValue[i]; double dv; if(srv->length != chunk_size || memcmp(srv->string, chunk_buf, chunk_size)) continue; /* * It could've been done using * (double)srv->dv / real_zero, * but it summons fp exception on some platforms. */ switch(srv->dv) { case -1: dv = - INFINITY; break; case 0: dv = NAN; break; case 1: dv = INFINITY; break; default: return XPBD_SYSTEM_FAILURE; } if(asn_double2REAL(st, dv)) return XPBD_SYSTEM_FAILURE; return XPBD_BODY_CONSUMED; } ASN_DEBUG("Unknown XMLSpecialRealValue"); return XPBD_BROKEN_ENCODING; } /* * Copy chunk into the nul-terminated string, and run strtod. */ b = (char *)MALLOC(chunk_size + 1); if(!b) return XPBD_SYSTEM_FAILURE; memcpy(b, chunk_buf, chunk_size); b[chunk_size] = 0; /* nul-terminate */ value = strtod(b, &endptr); FREEMEM(b); if(endptr == b) return XPBD_BROKEN_ENCODING; if(asn_double2REAL(st, value)) return XPBD_SYSTEM_FAILURE; return XPBD_BODY_CONSUMED; } asn_dec_rval_t REAL_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return xer_decode_primitive(opt_codec_ctx, td, sptr, sizeof(REAL_t), opt_mname, buf_ptr, size, REAL__xer_body_decode); } asn_dec_rval_t REAL_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { (void)constraints; /* No PER visible constraints */ return OCTET_STRING_decode_uper(opt_codec_ctx, td, 0, sptr, pd); } asn_enc_rval_t REAL_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { (void)constraints; /* No PER visible constraints */ return OCTET_STRING_encode_uper(td, 0, sptr, po); } int asn_REAL2double(const REAL_t *st, double *dbl_value) { unsigned int octv; if(!st || !st->buf) { errno = EINVAL; return -1; } if(st->size == 0) { *dbl_value = 0; return 0; } octv = st->buf[0]; /* unsigned byte */ switch(octv & 0xC0) { case 0x40: /* X.690: 8.5.8 */ /* "SpecialRealValue" */ /* Be liberal in what you accept... if(st->size != 1) ... */ switch(st->buf[0]) { case 0x40: /* 01000000: PLUS-INFINITY */ *dbl_value = INFINITY; return 0; case 0x41: /* 01000001: MINUS-INFINITY */ *dbl_value = - INFINITY; return 0; /* * The following cases are defined by * X.690 Amendment 1 (10/03) */ case 0x42: /* 01000010: NOT-A-NUMBER */ *dbl_value = NAN; return 0; case 0x43: /* 01000011: minus zero */ *dbl_value = -0.0; return 0; } errno = EINVAL; return -1; case 0x00: { /* X.690: 8.5.6 */ /* * Decimal. NR{1,2,3} format. */ double d; assert(st->buf[st->size - 1] == 0); /* Security, vashu mat' */ d = strtod((char *)st->buf, 0); if(finite(d)) { *dbl_value = d; return 0; } else { errno = ERANGE; return 0; } } } /* * Binary representation. */ { double m; int expval; /* exponent value */ unsigned int elen; /* exponent value length, in octets */ unsigned int scaleF; unsigned int baseF; uint8_t *ptr; uint8_t *end; int sign; switch((octv & 0x30) >> 4) { case 0x00: baseF = 1; break; /* base 2 */ case 0x01: baseF = 3; break; /* base 8 */ case 0x02: baseF = 4; break; /* base 16 */ default: /* Reserved field, can't parse now. */ errno = EINVAL; return -1; } sign = (octv & 0x40); /* bit 7 */ scaleF = (octv & 0x0C) >> 2; /* bits 4 to 3 */ if(st->size <= (int)(1 + (octv & 0x03))) { errno = EINVAL; return -1; } elen = (octv & 0x03); /* bits 2 to 1; 8.5.6.4 */ if(elen == 0x03) { /* bits 2 to 1 = 11; 8.5.6.4, case d) */ elen = st->buf[1]; /* unsigned binary number */ if(elen == 0 || st->size <= (int)(2 + elen)) { errno = EINVAL; return -1; } /* FIXME: verify constraints of case d) */ ptr = &st->buf[2]; } else { ptr = &st->buf[1]; } /* Fetch the multibyte exponent */ expval = (int)(*(int8_t *)ptr); end = ptr + elen + 1; for(ptr++; ptr < end; ptr++) expval = (expval * 256) + *ptr; m = 0.0; /* Initial mantissa value */ /* Okay, the exponent is here. Now, what about mantissa? */ end = st->buf + st->size; if(ptr < end) { for(; ptr < end; ptr++) m = ldexp(m, 8) + *ptr; } if(0) ASN_DEBUG("m=%.10f, scF=%d, bF=%d, expval=%d, ldexp()=%f, ldexp()=%f", m, scaleF, baseF, expval, ldexp(m, expval * baseF + scaleF), ldexp(m, scaleF) * pow(pow(2, baseF), expval) ); /* * (S * N * 2^F) * B^E * Essentially: m = ldexp(m, scaleF) * pow(pow(2, base), expval); */ m = ldexp(m, expval * baseF + scaleF); if(finite(m)) { *dbl_value = sign ? -m : m; } else { errno = ERANGE; return -1; } } /* if(binary_format) */ return 0; } /* * Assume IEEE 754 floating point: standard 64 bit double. * [1 bit sign] [11 bits exponent] [52 bits mantissa] */ int asn_double2REAL(REAL_t *st, double dbl_value) { #ifdef WORDS_BIGENDIAN /* Known to be big-endian */ int littleEndian = 0; #else /* need to test: have no explicit information */ unsigned int LE = 1; int littleEndian = *(unsigned char *)&LE; #endif uint8_t buf[16]; /* More than enough for 8-byte dbl_value */ uint8_t dscr[sizeof(dbl_value)]; /* double value scratch pad */ /* Assertion guards: won't even compile, if unexpected double size */ char assertion_buffer1[9 - sizeof(dbl_value)] GCC_NOTUSED; char assertion_buffer2[sizeof(dbl_value) - 7] GCC_NOTUSED; uint8_t *ptr = buf; uint8_t *mstop; /* Last byte of mantissa */ unsigned int mval; /* Value of the last byte of mantissa */ unsigned int bmsign; /* binary mask with sign */ unsigned int buflen; unsigned int accum; int expval; if(!st) { errno = EINVAL; return -1; } /* * ilogb(+-0) returns -INT_MAX or INT_MIN (platform-dependent) * ilogb(+-inf) returns INT_MAX, logb(+-inf) returns +inf * ilogb(NaN) returns INT_MIN or INT_MAX (platform-dependent) */ expval = ilogb(dbl_value); if(expval <= -INT_MAX /* Also catches +-0 and maybe isnan() */ || expval == INT_MAX /* catches isfin() and maybe isnan() */ ) { if(!st->buf || st->size < 2) { ptr = (uint8_t *)MALLOC(2); if(!ptr) return -1; st->buf = ptr; } /* fpclassify(3) is not portable yet */ if(isnan(dbl_value)) { st->buf[0] = 0x42; /* NaN */ st->buf[1] = 0; st->size = 1; } else if(!finite(dbl_value)) { if(copysign(1.0, dbl_value) < 0.0) { st->buf[0] = 0x41; /* MINUS-INFINITY */ } else { st->buf[0] = 0x40; /* PLUS-INFINITY */ } st->buf[1] = 0; st->size = 1; } else { if(copysign(1.0, dbl_value) < 0.0) { st->buf[0] = 0x80 | 0x40; st->buf[1] = 0; st->size = 2; } else { /* no content octets: positive zero */ st->buf[0] = 0; /* JIC */ st->size = 0; } } return 0; } if(littleEndian) { uint8_t *s = ((uint8_t *)&dbl_value) + sizeof(dbl_value) - 2; uint8_t *start = ((uint8_t *)&dbl_value); uint8_t *d; bmsign = 0x80 | ((s[1] >> 1) & 0x40); /* binary mask & - */ for(mstop = d = dscr; s >= start; d++, s--) { *d = *s; if(*d) mstop = d; } } else { uint8_t *s = ((uint8_t *)&dbl_value) + 1; uint8_t *end = ((uint8_t *)&dbl_value) + sizeof(double); uint8_t *d; bmsign = 0x80 | ((s[-1] >> 1) & 0x40); /* binary mask & - */ for(mstop = d = dscr; s < end; d++, s++) { *d = *s; if(*d) mstop = d; } } /* Remove parts of the exponent, leave mantissa and explicit 1. */ dscr[0] = 0x10 | (dscr[0] & 0x0f); /* Adjust exponent in a very unobvious way */ expval -= 8 * ((mstop - dscr) + 1) - 4; /* This loop ensures DER conformance by forcing mantissa odd: 11.3.1 */ mval = *mstop; if(mval && !(mval & 1)) { unsigned int shift_count = 1; unsigned int ishift; uint8_t *mptr; /* * Figure out what needs to be done to make mantissa odd. */ if(!(mval & 0x0f)) /* Speed-up a little */ shift_count = 4; while(((mval >> shift_count) & 1) == 0) shift_count++; ishift = 8 - shift_count; accum = 0; /* Go over the buffer, shifting it shift_count bits right. */ for(mptr = dscr; mptr <= mstop; mptr++) { mval = *mptr; *mptr = accum | (mval >> shift_count); accum = mval << ishift; } /* Adjust mantissa appropriately. */ expval += shift_count; } if(expval < 0) { if((expval >> 7) == -1) { *ptr++ = bmsign | 0x00; *ptr++ = expval; } else if((expval >> 15) == -1) { *ptr++ = bmsign | 0x01; *ptr++ = expval >> 8; *ptr++ = expval; } else { *ptr++ = bmsign | 0x02; *ptr++ = expval >> 16; *ptr++ = expval >> 8; *ptr++ = expval; } } else if(expval <= 0x7f) { *ptr++ = bmsign | 0x00; *ptr++ = expval; } else if(expval <= 0x7fff) { *ptr++ = bmsign | 0x01; *ptr++ = expval >> 8; *ptr++ = expval; } else { assert(expval <= 0x7fffff); *ptr++ = bmsign | 0x02; *ptr++ = expval >> 16; *ptr++ = expval >> 8; *ptr++ = expval; } buflen = (mstop - dscr) + 1; memcpy(ptr, dscr, buflen); ptr += buflen; buflen = ptr - buf; ptr = (uint8_t *)MALLOC(buflen + 1); if(!ptr) return -1; memcpy(ptr, buf, buflen); buf[buflen] = 0; /* JIC */ if(st->buf) FREEMEM(st->buf); st->buf = ptr; st->size = buflen; return 0; } biosig-2.3.3/biosig4c++/t240/SaGridEntry.h0000664000175000017500000000130414105434233020042 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaGridEntry_H_ #define _SaGridEntry_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include #include #ifdef __cplusplus extern "C" { #endif /* SaGridEntry */ typedef struct SaGridEntry { FEFFloat_t absolute_value; INTEGER_t level; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SaGridEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaGridEntry; #ifdef __cplusplus } #endif #endif /* _SaGridEntry_H_ */ biosig-2.3.3/biosig4c++/t240/AlertCode.c0000664000175000017500000000704614105434233017515 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertCode.h" int AlertCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void AlertCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void AlertCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { AlertCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int AlertCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { AlertCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t AlertCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { AlertCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t AlertCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { AlertCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t AlertCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { AlertCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t AlertCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { AlertCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_AlertCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_AlertCode = { "AlertCode", "AlertCode", AlertCode_free, AlertCode_print, AlertCode_constraint, AlertCode_decode_ber, AlertCode_encode_der, AlertCode_decode_xer, AlertCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertCode_tags_1, sizeof(asn_DEF_AlertCode_tags_1) /sizeof(asn_DEF_AlertCode_tags_1[0]), /* 1 */ asn_DEF_AlertCode_tags_1, /* Same as above */ sizeof(asn_DEF_AlertCode_tags_1) /sizeof(asn_DEF_AlertCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/NativeInteger.h0000664000175000017500000000210414105434233020412 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * This type differs from the standard INTEGER in that it is modelled using * the fixed machine type (long, int, short), so it can hold only values of * limited length. There is no type (i.e., NativeInteger_t, any integer type * will do). * This type may be used when integer range is limited by subtype constraints. */ #ifndef _NativeInteger_H_ #define _NativeInteger_H_ #include #include #ifdef __cplusplus extern "C" { #endif extern asn_TYPE_descriptor_t asn_DEF_NativeInteger; asn_struct_free_f NativeInteger_free; asn_struct_print_f NativeInteger_print; ber_type_decoder_f NativeInteger_decode_ber; der_type_encoder_f NativeInteger_encode_der; xer_type_decoder_f NativeInteger_decode_xer; xer_type_encoder_f NativeInteger_encode_xer; per_type_decoder_f NativeInteger_decode_uper; per_type_encoder_f NativeInteger_encode_uper; #ifdef __cplusplus } #endif #endif /* _NativeInteger_H_ */ biosig-2.3.3/biosig4c++/t240/RelativeTime.h0000664000175000017500000000146114105434233020245 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _RelativeTime_H_ #define _RelativeTime_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* RelativeTime */ typedef INTEGER_t RelativeTime_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_RelativeTime; asn_struct_free_f RelativeTime_free; asn_struct_print_f RelativeTime_print; asn_constr_check_f RelativeTime_constraint; ber_type_decoder_f RelativeTime_decode_ber; der_type_encoder_f RelativeTime_encode_der; xer_type_decoder_f RelativeTime_decode_xer; xer_type_encoder_f RelativeTime_encode_xer; #ifdef __cplusplus } #endif #endif /* _RelativeTime_H_ */ biosig-2.3.3/biosig4c++/t240/ChannelDescriptionSection.h0000664000175000017500000000231514105434233022753 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ChannelDescriptionSection_H_ #define _ChannelDescriptionSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricStatus.h" #include "ParameterGroupCode.h" #include #include "MsmtPrinciple.h" #include #ifdef __cplusplus extern "C" { #endif /* ChannelDescriptionSection */ typedef struct ChannelDescriptionSection { Handle_t handle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricsCode_t *channelid /* OPTIONAL */; MetricStatus_t *channelstatus /* DEFAULT {} */; ParameterGroupCode_t *parametergroup /* OPTIONAL */; INTEGER_t *physicalchannelnr /* DEFAULT 65535 */; MsmtPrinciple_t *measurementprinciple /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ChannelDescriptionSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ChannelDescriptionSection; #ifdef __cplusplus } #endif #endif /* _ChannelDescriptionSection_H_ */ biosig-2.3.3/biosig4c++/t240/SaFlags.h0000664000175000017500000000157614105434233017202 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaFlags_H_ #define _SaFlags_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum SaFlags { SaFlags_smoothcurve = 0, SaFlags_delayedcurve = 1, SaFlags_saextvalrange = 3 } e_SaFlags; /* SaFlags */ typedef BIT_STRING_t SaFlags_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaFlags; asn_struct_free_f SaFlags_free; asn_struct_print_f SaFlags_print; asn_constr_check_f SaFlags_constraint; ber_type_decoder_f SaFlags_decode_ber; der_type_encoder_f SaFlags_encode_der; xer_type_decoder_f SaFlags_decode_xer; xer_type_encoder_f SaFlags_encode_xer; #ifdef __cplusplus } #endif #endif /* _SaFlags_H_ */ biosig-2.3.3/biosig4c++/t240/ChoiceOfEnumObsValue.h0000664000175000017500000000265214105434233021623 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ChoiceOfEnumObsValue_H_ #define _ChoiceOfEnumObsValue_H_ #include /* Including external dependencies */ #include "EnumObsValue.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ChoiceOfEnumObsValue_PR { ChoiceOfEnumObsValue_PR_NOTHING, /* No components present */ ChoiceOfEnumObsValue_PR_enumobservedvalue, ChoiceOfEnumObsValue_PR_compoundenumobservedvalue } ChoiceOfEnumObsValue_PR; /* Forward declarations */ struct EnumObsValue; /* ChoiceOfEnumObsValue */ typedef struct ChoiceOfEnumObsValue { ChoiceOfEnumObsValue_PR present; union ChoiceOfEnumObsValue_u { EnumObsValue_t enumobservedvalue; struct ChoiceOfEnumObsValue__compoundenumobservedvalue { A_SEQUENCE_OF(struct EnumObsValue) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } compoundenumobservedvalue; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ChoiceOfEnumObsValue_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ChoiceOfEnumObsValue; #ifdef __cplusplus } #endif /* Referred external types */ #include "EnumObsValue.h" #endif /* _ChoiceOfEnumObsValue_H_ */ biosig-2.3.3/biosig4c++/t240/NuObsValue.h0000664000175000017500000000156314105434233017701 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _NuObsValue_H_ #define _NuObsValue_H_ #include /* Including external dependencies */ #include "MetricsCode.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "FEFFloat.h" #include #ifdef __cplusplus extern "C" { #endif /* NuObsValue */ typedef struct NuObsValue { MetricsCode_t *metricid /* OPTIONAL */; MeasurementStatus_t *state /* DEFAULT {} */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFFloat_t value; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } NuObsValue_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_NuObsValue; #ifdef __cplusplus } #endif #endif /* _NuObsValue_H_ */ biosig-2.3.3/biosig4c++/t240/OBJECT_IDENTIFIER.c0000664000175000017500000004407014105434233020321 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include #include /* for CHAR_BIT */ #include /* * OBJECT IDENTIFIER basic type description. */ static ber_tlv_tag_t asn_DEF_OBJECT_IDENTIFIER_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)) }; asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = { "OBJECT IDENTIFIER", "OBJECT_IDENTIFIER", ASN__PRIMITIVE_TYPE_free, OBJECT_IDENTIFIER_print, OBJECT_IDENTIFIER_constraint, ber_decode_primitive, der_encode_primitive, OBJECT_IDENTIFIER_decode_xer, OBJECT_IDENTIFIER_encode_xer, OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_OBJECT_IDENTIFIER_tags, sizeof(asn_DEF_OBJECT_IDENTIFIER_tags) / sizeof(asn_DEF_OBJECT_IDENTIFIER_tags[0]), asn_DEF_OBJECT_IDENTIFIER_tags, /* Same as above */ sizeof(asn_DEF_OBJECT_IDENTIFIER_tags) / sizeof(asn_DEF_OBJECT_IDENTIFIER_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; int OBJECT_IDENTIFIER_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr; if(st && st->buf) { if(st->size < 1) { _ASN_CTFAIL(app_key, td, sptr, "%s: at least one numerical value " "expected (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } else { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } return 0; } int OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed int add, void *rvbufp, unsigned int rvsize) { unsigned LE GCC_NOTUSED = 1; /* Little endian (x86) */ uint8_t *arcend = arcbuf + arclen; /* End of arc */ unsigned int cache = 0; /* No more than 14 significant bits */ unsigned char *rvbuf = (unsigned char *)rvbufp; unsigned char *rvstart = rvbuf; /* Original start of the value buffer */ int inc; /* Return value growth direction */ rvsize *= CHAR_BIT; /* bytes to bits */ arclen *= 7; /* bytes to bits */ /* * The arc has the number of bits * cannot be represented using supplied return value type. */ if(arclen > rvsize) { if(arclen > (rvsize + CHAR_BIT)) { errno = ERANGE; /* Overflow */ return -1; } else { /* * Even if the number of bits in the arc representation * is higher than the width of supplied * return value * type, there is still possible to fit it when there * are few unused high bits in the arc value * representaion. * * Moreover, there is a possibility that the * number could actually fit the arc space, given * that add is negative, but we don't handle * such "temporary lack of precision" situation here. * May be considered as a bug. */ uint8_t mask = (0xff << (7-(arclen - rvsize))) & 0x7f; if((*arcbuf & mask)) { errno = ERANGE; /* Overflow */ return -1; } /* Fool the routine computing unused bits */ arclen -= 7; cache = *arcbuf & 0x7f; arcbuf++; } } /* Faster path for common size */ if(rvsize == (CHAR_BIT * sizeof(unsigned long))) { unsigned long accum; /* Gather all bits into the accumulator */ for(accum = cache; arcbuf < arcend; arcbuf++) accum = (accum << 7) | (*arcbuf & ~0x80); if(accum < (unsigned)-add) { errno = ERANGE; /* Overflow */ return -1; } *(unsigned long *)rvbuf = accum + add; /* alignment OK! */ return 0; } #ifndef WORDS_BIGENDIAN if(*(unsigned char *)&LE) { /* Little endian (x86) */ /* "Convert" to big endian */ rvbuf += rvsize / CHAR_BIT - 1; rvstart--; inc = -1; /* Descending */ } else #endif /* !WORDS_BIGENDIAN */ inc = +1; /* Big endian is known [at compile time] */ { int bits; /* typically no more than 3-4 bits */ /* Clear the high unused bits */ for(bits = rvsize - arclen; bits > CHAR_BIT; rvbuf += inc, bits -= CHAR_BIT) *rvbuf = 0; /* Fill the body of a value */ for(; arcbuf < arcend; arcbuf++) { cache = (cache << 7) | (*arcbuf & 0x7f); bits += 7; if(bits >= CHAR_BIT) { bits -= CHAR_BIT; *rvbuf = (cache >> bits); rvbuf += inc; } } if(bits) { *rvbuf = cache; rvbuf += inc; } } if(add) { for(rvbuf -= inc; rvbuf != rvstart; rvbuf -= inc) { int v = add + *rvbuf; if(v & (-1 << CHAR_BIT)) { *rvbuf = (unsigned char)(v + (1 << CHAR_BIT)); add = -1; } else { *rvbuf = v; break; } } if(rvbuf == rvstart) { /* No space to carry over */ errno = ERANGE; /* Overflow */ return -1; } } return 0; } ssize_t OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add, asn_app_consume_bytes_f *cb, void *app_key) { char scratch[64]; /* Conservative estimate */ unsigned long accum; /* Bits accumulator */ char *p; /* Position in the scratch buffer */ if(OBJECT_IDENTIFIER_get_single_arc(arcbuf, arclen, add, &accum, sizeof(accum))) return -1; if(accum) { ssize_t len; /* Fill the scratch buffer in reverse. */ p = scratch + sizeof(scratch); for(; accum; accum /= 10) *(--p) = (char)(accum % 10) + 0x30; /* Put a digit */ len = sizeof(scratch) - (p - scratch); if(cb(p, len, app_key) < 0) return -1; return len; } else { *scratch = 0x30; if(cb(scratch, 1, app_key) < 0) return -1; return 1; } } int OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add, asn_app_consume_bytes_f *cb, void *app_key) { if(OBJECT_IDENTIFIER__dump_arc(arcbuf, arclen, add, cb, app_key) < 0) return -1; return 0; } static ssize_t OBJECT_IDENTIFIER__dump_body(const OBJECT_IDENTIFIER_t *st, asn_app_consume_bytes_f *cb, void *app_key) { ssize_t wrote_len = 0; int startn; int add = 0; int i; for(i = 0, startn = 0; i < st->size; i++) { uint8_t b = st->buf[i]; if((b & 0x80)) /* Continuation expected */ continue; if(startn == 0) { /* * First two arcs are encoded through the backdoor. */ if(i) { add = -80; if(cb("2", 1, app_key) < 0) return -1; } else if(b <= 39) { add = 0; if(cb("0", 1, app_key) < 0) return -1; } else if(b < 79) { add = -40; if(cb("1", 1, app_key) < 0) return -1; } else { add = -80; if(cb("2", 1, app_key) < 0) return -1; } wrote_len += 1; } if(cb(".", 1, app_key) < 0) /* Separate arcs */ return -1; add = OBJECT_IDENTIFIER__dump_arc(&st->buf[startn], i - startn + 1, add, cb, app_key); if(add < 0) return -1; wrote_len += 1 + add; startn = i + 1; add = 0; } return wrote_len; } static enum xer_pbd_rval OBJECT_IDENTIFIER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) { OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)sptr; const char *chunk_end = (const char *)chunk_buf + chunk_size; const char *endptr; long s_arcs[10]; long *arcs = s_arcs; int arcs_count; int ret; (void)td; arcs_count = OBJECT_IDENTIFIER_parse_arcs( (const char *)chunk_buf, chunk_size, arcs, sizeof(s_arcs)/sizeof(s_arcs[0]), &endptr); if(arcs_count <= 0) { /* Expecting more than zero arcs */ return XPBD_BROKEN_ENCODING; } if(endptr < chunk_end) { /* We have a tail of unrecognized data. Check its safety. */ if(!xer_is_whitespace(endptr, chunk_end - endptr)) return XPBD_BROKEN_ENCODING; } if((size_t)arcs_count > sizeof(s_arcs)/sizeof(s_arcs[0])) { arcs = (long *)MALLOC(arcs_count * sizeof(long)); if(!arcs) return XPBD_SYSTEM_FAILURE; ret = OBJECT_IDENTIFIER_parse_arcs( (const char *)chunk_buf, chunk_size, arcs, arcs_count, &endptr); if(ret != arcs_count) return XPBD_SYSTEM_FAILURE; /* assert?.. */ } /* * Convert arcs into BER representation. */ ret = OBJECT_IDENTIFIER_set_arcs(st, arcs, sizeof(*arcs), arcs_count); if(arcs != s_arcs) FREEMEM(arcs); return ret ? XPBD_SYSTEM_FAILURE : XPBD_BODY_CONSUMED; } asn_dec_rval_t OBJECT_IDENTIFIER_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return xer_decode_primitive(opt_codec_ctx, td, sptr, sizeof(OBJECT_IDENTIFIER_t), opt_mname, buf_ptr, size, OBJECT_IDENTIFIER__xer_body_decode); } asn_enc_rval_t OBJECT_IDENTIFIER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr; asn_enc_rval_t er; (void)ilevel; (void)flags; if(!st || !st->buf) _ASN_ENCODE_FAILED; er.encoded = OBJECT_IDENTIFIER__dump_body(st, cb, app_key); if(er.encoded < 0) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } int OBJECT_IDENTIFIER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(!st || !st->buf) return (cb("", 8, app_key) < 0) ? -1 : 0; /* Dump preamble */ if(cb("{ ", 2, app_key) < 0) return -1; if(OBJECT_IDENTIFIER__dump_body(st, cb, app_key) < 0) return -1; return (cb(" }", 2, app_key) < 0) ? -1 : 0; } int OBJECT_IDENTIFIER_get_arcs(OBJECT_IDENTIFIER_t *oid, void *arcs, unsigned int arc_type_size, unsigned int arc_slots) { void *arcs_end = (char *)arcs + (arc_type_size * arc_slots); int num_arcs = 0; int startn = 0; int add = 0; int i; if(!oid || !oid->buf || (arc_slots && arc_type_size <= 1)) { errno = EINVAL; return -1; } for(i = 0; i < oid->size; i++) { uint8_t b = oid->buf[i]; if((b & 0x80)) /* Continuation expected */ continue; if(num_arcs == 0) { /* * First two arcs are encoded through the backdoor. */ unsigned LE = 1; /* Little endian */ int first_arc; num_arcs++; if(!arc_slots) { num_arcs++; continue; } if(i) first_arc = 2; else if(b <= 39) first_arc = 0; else if(b < 79) first_arc = 1; else first_arc = 2; add = -40 * first_arc; memset(arcs, 0, arc_type_size); *(unsigned char *)((char *)arcs + ((*(char *)&LE)?0:(arc_type_size - 1))) = first_arc; arcs = ((char *)arcs) + arc_type_size; } /* Decode, if has space */ if(arcs < arcs_end) { if(OBJECT_IDENTIFIER_get_single_arc(&oid->buf[startn], i - startn + 1, add, arcs, arc_type_size)) return -1; startn = i + 1; arcs = ((char *)arcs) + arc_type_size; add = 0; } num_arcs++; } return num_arcs; } /* * Save the single value as an object identifier arc. */ int OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, const void *arcval, unsigned int arcval_size, int prepared_order) { /* * The following conditions must hold: * assert(arcval); * assert(arcval_size > 0); * assert(arcval_size <= 16); * assert(arcbuf); */ #ifdef WORDS_BIGENDIAN const unsigned isLittleEndian = 0; #else unsigned LE = 1; unsigned isLittleEndian = *(char *)&LE; #endif const uint8_t *tend, *tp; unsigned int cache; uint8_t *bp = arcbuf; int bits; uint8_t buffer[16]; if(isLittleEndian && !prepared_order) { const uint8_t *a = (const unsigned char *)arcval + arcval_size - 1; const uint8_t *aend = (const uint8_t *)arcval; uint8_t *msb = buffer + arcval_size - 1; uint8_t *tb; for(tb = buffer; a >= aend; tb++, a--) if((*tb = *a) && (tb < msb)) msb = tb; tend = &buffer[arcval_size]; tp = msb; /* Most significant non-zero byte */ } else { /* Look for most significant non-zero byte */ tend = (const unsigned char *)arcval + arcval_size; for(tp = (const uint8_t *)arcval; tp < tend - 1; tp++) if(*tp) break; } /* * Split the value in 7-bits chunks. */ bits = ((tend - tp) * CHAR_BIT) % 7; if(bits) { cache = *tp >> (CHAR_BIT - bits); if(cache) { *bp++ = cache | 0x80; cache = *tp++; bits = CHAR_BIT - bits; } else { bits = -bits; } } else { cache = 0; } for(; tp < tend; tp++) { cache = (cache << CHAR_BIT) + *tp; bits += CHAR_BIT; while(bits >= 7) { bits -= 7; *bp++ = 0x80 | (cache >> bits); } } if(bits) *bp++ = cache; bp[-1] &= 0x7f; /* Clear the last bit */ return bp - arcbuf; } int OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid, const void *arcs, unsigned int arc_type_size, unsigned int arc_slots) { uint8_t *buf; uint8_t *bp; unsigned LE = 1; /* Little endian (x86) */ unsigned isLittleEndian = *((char *)&LE); unsigned int arc0; unsigned int arc1; unsigned size; unsigned i; if(!oid || !arcs || arc_type_size < 1 || arc_type_size > 16 || arc_slots < 2) { errno = EINVAL; return -1; } switch(arc_type_size) { case sizeof(char): arc0 = ((const unsigned char *)arcs)[0]; arc1 = ((const unsigned char *)arcs)[1]; break; case sizeof(short): arc0 = ((const unsigned short *)arcs)[0]; arc1 = ((const unsigned short *)arcs)[1]; break; case sizeof(int): arc0 = ((const unsigned int *)arcs)[0]; arc1 = ((const unsigned int *)arcs)[1]; break; default: arc1 = arc0 = 0; if(isLittleEndian) { /* Little endian (x86) */ const unsigned char *ps, *pe; /* If more significant bytes are present, * make them > 255 quick */ for(ps = (const unsigned char *)arcs + 1, pe = ps+arc_type_size; ps < pe; ps++) arc0 |= *ps, arc1 |= *(ps + arc_type_size); arc0 <<= CHAR_BIT, arc1 <<= CHAR_BIT; arc0 = *((const unsigned char *)arcs + 0); arc1 = *((const unsigned char *)arcs + arc_type_size); } else { const unsigned char *ps, *pe; /* If more significant bytes are present, * make them > 255 quick */ for(ps = (const unsigned char *)arcs, pe = ps+arc_type_size - 1; ps < pe; ps++) arc0 |= *ps, arc1 |= *(ps + arc_type_size); arc0 = *((const unsigned char *)arcs + arc_type_size - 1); arc1 = *((const unsigned char *)arcs +(arc_type_size<< 1)-1); } } /* * The previous chapter left us with the first and the second arcs. * The values are not precise (that is, they are valid only if * they're less than 255), but OK for the purposes of making * the sanity test below. */ if(arc0 <= 1) { if(arc1 >= 39) { /* 8.19.4: At most 39 subsequent values (including 0) */ errno = ERANGE; return -1; } } else if(arc0 > 2) { /* 8.19.4: Only three values are allocated from the root node */ errno = ERANGE; return -1; } /* * After above tests it is known that the value of arc0 is completely * trustworthy (0..2). However, the arc1's value is still meaningless. */ /* * Roughly estimate the maximum size necessary to encode these arcs. * This estimation implicitly takes in account the following facts, * that cancel each other: * * the first two arcs are encoded in a single value. * * the first value may require more space (+1 byte) * * the value of the first arc which is in range (0..2) */ size = ((arc_type_size * CHAR_BIT + 6) / 7) * arc_slots; bp = buf = (uint8_t *)MALLOC(size + 1); if(!buf) { /* ENOMEM */ return -1; } /* * Encode the first two arcs. * These require special treatment. */ { uint8_t *tp; uint8_t first_value[1 + 16]; /* of two arcs */ uint8_t *fv = first_value; /* * Simulate first_value = arc0 * 40 + arc1; */ /* Copy the second (1'st) arcs[1] into the first_value */ *fv++ = 0; arcs = ((const char *)arcs) + arc_type_size; if(isLittleEndian) { const uint8_t *aend = (const unsigned char *)arcs - 1; const uint8_t *a1 = (const unsigned char *)arcs + arc_type_size - 1; for(; a1 > aend; fv++, a1--) *fv = *a1; } else { const uint8_t *a1 = (const uint8_t *)arcs; const uint8_t *aend = a1 + arc_type_size; for(; a1 < aend; fv++, a1++) *fv = *a1; } /* Increase the first_value by arc0 */ arc0 *= 40; /* (0..80) */ for(tp = first_value + arc_type_size; tp >= first_value; tp--) { unsigned int v = *tp; v += arc0; *tp = v; if(v >= (1 << CHAR_BIT)) arc0 = v >> CHAR_BIT; else break; } assert(tp >= first_value); bp += OBJECT_IDENTIFIER_set_single_arc(bp, first_value, fv - first_value, 1); } /* * Save the rest of arcs. */ for(arcs = ((const char *)arcs) + arc_type_size, i = 2; i < arc_slots; i++, arcs = ((const char *)arcs) + arc_type_size) { bp += OBJECT_IDENTIFIER_set_single_arc(bp, arcs, arc_type_size, 0); } assert((unsigned)(bp - buf) <= size); /* * Replace buffer. */ oid->size = bp - buf; bp = oid->buf; oid->buf = buf; if(bp) FREEMEM(bp); return 0; } int OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length, long *arcs, unsigned int arcs_slots, const char **opt_oid_text_end) { unsigned int arcs_count = 0; const char *oid_end; long value = 0; enum { ST_SKIPSPACE, ST_WAITDIGITS, /* Next character is expected to be a digit */ ST_DIGITS } state = ST_SKIPSPACE; if(!oid_text || oid_txt_length < -1 || (arcs_slots && !arcs)) { if(opt_oid_text_end) *opt_oid_text_end = oid_text; errno = EINVAL; return -1; } if(oid_txt_length == -1) oid_txt_length = strlen(oid_text); for(oid_end = oid_text + oid_txt_length; oid_text #include "PatientType.h" int PatientType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void PatientType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void PatientType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { PatientType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int PatientType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { PatientType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t PatientType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { PatientType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t PatientType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { PatientType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t PatientType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { PatientType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t PatientType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { PatientType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_PatientType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_PatientType = { "PatientType", "PatientType", PatientType_free, PatientType_print, PatientType_constraint, PatientType_decode_ber, PatientType_encode_der, PatientType_decode_xer, PatientType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PatientType_tags_1, sizeof(asn_DEF_PatientType_tags_1) /sizeof(asn_DEF_PatientType_tags_1[0]), /* 1 */ asn_DEF_PatientType_tags_1, /* Same as above */ sizeof(asn_DEF_PatientType_tags_1) /sizeof(asn_DEF_PatientType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/OCTET_STRING.h0000664000175000017500000000540314105434233017617 0ustar schloeglschloegl/*- * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _OCTET_STRING_H_ #define _OCTET_STRING_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct OCTET_STRING { uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */ int size; /* Size of the buffer */ asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */ } OCTET_STRING_t; extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING; asn_struct_free_f OCTET_STRING_free; asn_struct_print_f OCTET_STRING_print; asn_struct_print_f OCTET_STRING_print_utf8; ber_type_decoder_f OCTET_STRING_decode_ber; der_type_encoder_f OCTET_STRING_encode_der; xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */ xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */ xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */ xer_type_encoder_f OCTET_STRING_encode_xer; xer_type_encoder_f OCTET_STRING_encode_xer_utf8; per_type_decoder_f OCTET_STRING_decode_uper; per_type_encoder_f OCTET_STRING_encode_uper; /****************************** * Handy conversion routines. * ******************************/ /* * This function clears the previous value of the OCTET STRING (if any) * and then allocates a new memory with the specified content (str/size). * If size = -1, the size of the original string will be determined * using strlen(str). * If str equals to NULL, the function will silently clear the * current contents of the OCTET STRING. * Returns 0 if it was possible to perform operation, -1 otherwise. */ int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size); /* Handy conversion from the C string into the OCTET STRING. */ #define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1) /* * Allocate and fill the new OCTET STRING and return a pointer to the newly * allocated object. NULL is permitted in str: the function will just allocate * empty OCTET STRING. */ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td, const char *str, int size); /**************************** * Internally useful stuff. * ****************************/ typedef struct asn_OCTET_STRING_specifics_s { /* * Target structure description. */ int struct_size; /* Size of the structure */ int ctx_offset; /* Offset of the asn_struct_ctx_t member */ enum asn_OS_Subvariant { ASN_OSUBV_ANY, /* The open type (ANY) */ ASN_OSUBV_BIT, /* BIT STRING */ ASN_OSUBV_STR, /* String types, not {BMP,Universal}String */ ASN_OSUBV_U16, /* 16-bit character (BMPString) */ ASN_OSUBV_U32 /* 32-bit character (UniversalString) */ } subvariant; } asn_OCTET_STRING_specifics_t; #ifdef __cplusplus } #endif #endif /* _OCTET_STRING_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCalType.c0000664000175000017500000000725514105434233020362 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricCalType.h" int MetricCalType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void MetricCalType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void MetricCalType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MetricCalType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MetricCalType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MetricCalType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MetricCalType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MetricCalType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MetricCalType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MetricCalType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MetricCalType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MetricCalType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MetricCalType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MetricCalType = { "MetricCalType", "MetricCalType", MetricCalType_free, MetricCalType_print, MetricCalType_constraint, MetricCalType_decode_ber, MetricCalType_encode_der, MetricCalType_decode_xer, MetricCalType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricCalType_tags_1, sizeof(asn_DEF_MetricCalType_tags_1) /sizeof(asn_DEF_MetricCalType_tags_1[0]), /* 1 */ asn_DEF_MetricCalType_tags_1, /* Same as above */ sizeof(asn_DEF_MetricCalType_tags_1) /sizeof(asn_DEF_MetricCalType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MetricDescriptiveDataSection.h0000664000175000017500000000702614105434233023422 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricDescriptiveDataSection_H_ #define _MetricDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct MetricCalEntry; /* MetricDescriptiveDataSection */ typedef struct MetricDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct MetricDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct MetricDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct MetricDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct MetricDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct MetricDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct MetricDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct MetricDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MetricDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "MetricCalEntry.h" #endif /* _MetricDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/constraints.h0000664000175000017500000000365714105434233020233 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2006 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _ASN1_CONSTRAINTS_VALIDATOR_H_ #define _ASN1_CONSTRAINTS_VALIDATOR_H_ #include /* Platform-dependent types */ #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ /* * Validate the structure according to the ASN.1 constraints. * If errbuf and errlen are given, they shall be pointing to the appropriate * buffer space and its length before calling this function. Alternatively, * they could be passed as NULL's. If constraints validation fails, * errlen will contain the actual number of bytes taken from the errbuf * to encode an error message (properly 0-terminated). * * RETURN VALUES: * This function returns 0 in case all ASN.1 constraints are met * and -1 if one or more constraints were failed. */ int asn_check_constraints(struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, /* Target language's structure */ char *errbuf, /* Returned error description */ size_t *errlen /* Length of the error description */ ); /* * Generic type for constraint checking callback, * associated with every type descriptor. */ typedef int (asn_constr_check_f)( struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, asn_app_constraint_failed_f *optional_callback, /* Log the error */ void *optional_app_key /* Opaque key passed to a callback */ ); /******************************* * INTERNALLY USEFUL FUNCTIONS * *******************************/ asn_constr_check_f asn_generic_no_constraint; /* No constraint whatsoever */ asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */ /* * Invoke the callback with a complete error message. */ #define _ASN_CTFAIL if(ctfailcb) ctfailcb #ifdef __cplusplus } #endif #endif /* _ASN1_CONSTRAINTS_VALIDATOR_H_ */ biosig-2.3.3/biosig4c++/t240/BodySiteCode.h0000664000175000017500000000146114105434233020170 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _BodySiteCode_H_ #define _BodySiteCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* BodySiteCode */ typedef INTEGER_t BodySiteCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_BodySiteCode; asn_struct_free_f BodySiteCode_free; asn_struct_print_f BodySiteCode_print; asn_constr_check_f BodySiteCode_constraint; ber_type_decoder_f BodySiteCode_decode_ber; der_type_encoder_f BodySiteCode_encode_der; xer_type_decoder_f BodySiteCode_decode_xer; xer_type_encoder_f BodySiteCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _BodySiteCode_H_ */ biosig-2.3.3/biosig4c++/t240/MetricCalEntry.h0000664000175000017500000000144414105434233020541 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricCalEntry_H_ #define _MetricCalEntry_H_ #include /* Including external dependencies */ #include "MetricCalType.h" #include "MetricCalState.h" #include "AbsoluteTime.h" #include #ifdef __cplusplus extern "C" { #endif /* MetricCalEntry */ typedef struct MetricCalEntry { MetricCalType_t cal_type; MetricCalState_t cal_state; AbsoluteTime_t cal_time; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MetricCalEntry_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricCalEntry; #ifdef __cplusplus } #endif #endif /* _MetricCalEntry_H_ */ biosig-2.3.3/biosig4c++/t240/ExtNomenRef.h0000664000175000017500000000133514105434233020045 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ExtNomenRef_H_ #define _ExtNomenRef_H_ #include /* Including external dependencies */ #include "ExtNomenclatureCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* ExtNomenRef */ typedef struct ExtNomenRef { ExtNomenclatureCode_t nomenclatureid; ANY_t nomenclaturecode; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ExtNomenRef_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ExtNomenRef; #ifdef __cplusplus } #endif #endif /* _ExtNomenRef_H_ */ biosig-2.3.3/biosig4c++/t240/per_decoder.c0000664000175000017500000000475214105434233020127 0ustar schloeglschloegl#include #include #include /* * Decode a "Production of a complete encoding", X.691#10.1. * The complete encoding contains at least one byte, and is an integral * multiple of 8 bytes. */ asn_dec_rval_t uper_decode_complete(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size) { asn_dec_rval_t rval; rval = uper_decode(opt_codec_ctx, td, sptr, buffer, size, 0, 0); if(rval.consumed) { /* * We've always given 8-aligned data, * so convert bits to integral bytes. */ rval.consumed += 7; rval.consumed >>= 3; } else if(rval.code == RC_OK) { if(size) { if(((uint8_t *)buffer)[0] == 0) { rval.consumed = 1; /* 1 byte */ } else { ASN_DEBUG("Expecting single zeroed byte"); rval.code = RC_FAIL; } } else { /* Must contain at least 8 bits. */ rval.code = RC_WMORE; } } return rval; } asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size, int skip_bits, int unused_bits) { asn_codec_ctx_t s_codec_ctx; asn_dec_rval_t rval; asn_per_data_t pd; if(skip_bits < 0 || skip_bits > 7 || unused_bits < 0 || unused_bits > 7 || (unused_bits > 0 && !size)) _ASN_DECODE_FAILED; /* * Stack checker requires that the codec context * must be allocated on the stack. */ if(opt_codec_ctx) { if(opt_codec_ctx->max_stack_size) { s_codec_ctx = *opt_codec_ctx; opt_codec_ctx = &s_codec_ctx; } } else { /* If context is not given, be security-conscious anyway */ memset(&s_codec_ctx, 0, sizeof(s_codec_ctx)); s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX; opt_codec_ctx = &s_codec_ctx; } /* Fill in the position indicator */ memset(&pd, 0, sizeof(pd)); pd.buffer = (const uint8_t *)buffer; pd.nboff = skip_bits; pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from */ if(pd.nboff > pd.nbits) _ASN_DECODE_FAILED; /* * Invoke type-specific decoder. */ if(!td->uper_decoder) _ASN_DECODE_FAILED; /* PER is not compiled in */ rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd); if(rval.code == RC_OK) { /* Return the number of consumed bits */ rval.consumed = ((pd.buffer - (const uint8_t *)buffer) << 3) + pd.nboff - skip_bits; ASN_DEBUG("PER decoding consumed %d, counted %d", rval.consumed, pd.moved); assert(rval.consumed == pd.moved); } else { /* PER codec is not a restartable */ rval.consumed = 0; } return rval; } biosig-2.3.3/biosig4c++/t240/UnitsOfMeasurementCode.h0000664000175000017500000000166314105434233022247 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _UnitsOfMeasurementCode_H_ #define _UnitsOfMeasurementCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* UnitsOfMeasurementCode */ typedef INTEGER_t UnitsOfMeasurementCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_UnitsOfMeasurementCode; asn_struct_free_f UnitsOfMeasurementCode_free; asn_struct_print_f UnitsOfMeasurementCode_print; asn_constr_check_f UnitsOfMeasurementCode_constraint; ber_type_decoder_f UnitsOfMeasurementCode_decode_ber; der_type_encoder_f UnitsOfMeasurementCode_encode_der; xer_type_decoder_f UnitsOfMeasurementCode_decode_xer; xer_type_encoder_f UnitsOfMeasurementCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _UnitsOfMeasurementCode_H_ */ biosig-2.3.3/biosig4c++/t240/LineFrequency.c0000664000175000017500000000725514105434233020426 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "LineFrequency.h" int LineFrequency_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void LineFrequency_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void LineFrequency_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { LineFrequency_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int LineFrequency_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { LineFrequency_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t LineFrequency_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { LineFrequency_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t LineFrequency_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { LineFrequency_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t LineFrequency_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { LineFrequency_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t LineFrequency_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { LineFrequency_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_LineFrequency_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_LineFrequency = { "LineFrequency", "LineFrequency", LineFrequency_free, LineFrequency_print, LineFrequency_constraint, LineFrequency_decode_ber, LineFrequency_encode_der, LineFrequency_decode_xer, LineFrequency_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_LineFrequency_tags_1, sizeof(asn_DEF_LineFrequency_tags_1) /sizeof(asn_DEF_LineFrequency_tags_1[0]), /* 1 */ asn_DEF_LineFrequency_tags_1, /* Same as above */ sizeof(asn_DEF_LineFrequency_tags_1) /sizeof(asn_DEF_LineFrequency_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SaCalDataType.c0000664000175000017500000000725514105434233020274 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaCalDataType.h" int SaCalDataType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void SaCalDataType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void SaCalDataType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { SaCalDataType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int SaCalDataType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { SaCalDataType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t SaCalDataType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { SaCalDataType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t SaCalDataType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { SaCalDataType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t SaCalDataType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { SaCalDataType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t SaCalDataType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { SaCalDataType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_SaCalDataType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_SaCalDataType = { "SaCalDataType", "SaCalDataType", SaCalDataType_free, SaCalDataType_print, SaCalDataType_constraint, SaCalDataType_decode_ber, SaCalDataType_encode_der, SaCalDataType_decode_xer, SaCalDataType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaCalDataType_tags_1, sizeof(asn_DEF_SaCalDataType_tags_1) /sizeof(asn_DEF_SaCalDataType_tags_1[0]), /* 1 */ asn_DEF_SaCalDataType_tags_1, /* Same as above */ sizeof(asn_DEF_SaCalDataType_tags_1) /sizeof(asn_DEF_SaCalDataType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SaCalData.h0000664000175000017500000000140214105434233017423 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SaCalData_H_ #define _SaCalData_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include "SaCalDataType.h" #include #ifdef __cplusplus extern "C" { #endif /* SaCalData */ typedef struct SaCalData { FEFFloat_t lowerabsolutevalue; FEFFloat_t upperabsolutevalue; FEFFloat_t increment; SaCalDataType_t cal_type; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SaCalData_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SaCalData; #ifdef __cplusplus } #endif #endif /* _SaCalData_H_ */ biosig-2.3.3/biosig4c++/t240/AbsoluteRange.c0000664000175000017500000000424314105434233020402 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AbsoluteRange.h" static asn_TYPE_member_t asn_MBR_AbsoluteRange_1[] = { { ATF_NOFLAGS, 0, offsetof(struct AbsoluteRange, lowervalue), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "lowervalue" }, { ATF_NOFLAGS, 0, offsetof(struct AbsoluteRange, uppervalue), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "uppervalue" }, }; static ber_tlv_tag_t asn_DEF_AbsoluteRange_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_AbsoluteRange_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* lowervalue at 102 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* uppervalue at 104 */ }; static asn_SEQUENCE_specifics_t asn_SPC_AbsoluteRange_specs_1 = { sizeof(struct AbsoluteRange), offsetof(struct AbsoluteRange, _asn_ctx), asn_MAP_AbsoluteRange_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_AbsoluteRange = { "AbsoluteRange", "AbsoluteRange", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AbsoluteRange_tags_1, sizeof(asn_DEF_AbsoluteRange_tags_1) /sizeof(asn_DEF_AbsoluteRange_tags_1[0]), /* 1 */ asn_DEF_AbsoluteRange_tags_1, /* Same as above */ sizeof(asn_DEF_AbsoluteRange_tags_1) /sizeof(asn_DEF_AbsoluteRange_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_AbsoluteRange_1, 2, /* Elements count */ &asn_SPC_AbsoluteRange_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/MetricCalEntry.c0000664000175000017500000000505114105434233020532 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricCalEntry.h" static asn_TYPE_member_t asn_MBR_MetricCalEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MetricCalEntry, cal_type), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCalType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "cal-type" }, { ATF_NOFLAGS, 0, offsetof(struct MetricCalEntry, cal_state), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCalState, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "cal-state" }, { ATF_NOFLAGS, 0, offsetof(struct MetricCalEntry, cal_time), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "cal-time" }, }; static ber_tlv_tag_t asn_DEF_MetricCalEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MetricCalEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* cal-type at 920 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* cal-state at 921 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 } /* cal-time at 923 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MetricCalEntry_specs_1 = { sizeof(struct MetricCalEntry), offsetof(struct MetricCalEntry, _asn_ctx), asn_MAP_MetricCalEntry_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MetricCalEntry = { "MetricCalEntry", "MetricCalEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricCalEntry_tags_1, sizeof(asn_DEF_MetricCalEntry_tags_1) /sizeof(asn_DEF_MetricCalEntry_tags_1[0]), /* 1 */ asn_DEF_MetricCalEntry_tags_1, /* Same as above */ sizeof(asn_DEF_MetricCalEntry_tags_1) /sizeof(asn_DEF_MetricCalEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MetricCalEntry_1, 3, /* Elements count */ &asn_SPC_MetricCalEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/TimeSampleArrayMeasuredDataSection.h0000664000175000017500000000307014105434233024515 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _TimeSampleArrayMeasuredDataSection_H_ #define _TimeSampleArrayMeasuredDataSection_H_ #include /* Including external dependencies */ #include #include "Fraction.h" #include "SampleArrayMeasuredDataBlock.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct MarkerEntryRelTim; /* TimeSampleArrayMeasuredDataSection */ typedef struct TimeSampleArrayMeasuredDataSection { INTEGER_t numberofsubblocks; Fraction_t subblocklength; INTEGER_t subblocksize; struct TimeSampleArrayMeasuredDataSection__metriclist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } metriclist; struct TimeSampleArrayMeasuredDataSection__tsamarkerlist { A_SEQUENCE_OF(struct MarkerEntryRelTim) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *tsamarkerlist; SampleArrayMeasuredDataBlock_t data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } TimeSampleArrayMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_TimeSampleArrayMeasuredDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "MarkerEntryRelTim.h" #endif /* _TimeSampleArrayMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/ScaleRangeSpec.h0000664000175000017500000000142414105434233020471 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ScaleRangeSpec_H_ #define _ScaleRangeSpec_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include #ifdef __cplusplus extern "C" { #endif /* ScaleRangeSpec */ typedef struct ScaleRangeSpec { FEFFloat_t lowerabsolutevalue; FEFFloat_t upperabsolutevalue; FEFFloat_t lowervaluescaled; FEFFloat_t uppervaluescaled; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ScaleRangeSpec_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ScaleRangeSpec; #ifdef __cplusplus } #endif #endif /* _ScaleRangeSpec_H_ */ biosig-2.3.3/biosig4c++/t240/PatMeasure.h0000664000175000017500000000132314105434233017716 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PatMeasure_H_ #define _PatMeasure_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include "UnitsOfMeasurementCode.h" #include #ifdef __cplusplus extern "C" { #endif /* PatMeasure */ typedef struct PatMeasure { FEFFloat_t value; UnitsOfMeasurementCode_t m_unit; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } PatMeasure_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PatMeasure; #ifdef __cplusplus } #endif #endif /* _PatMeasure_H_ */ biosig-2.3.3/biosig4c++/t240/EnumerationDescriptiveDataSection.c0000664000175000017500000006350014105434233024457 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumerationDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct EnumerationDescriptiveDataSection__vmosourcelist), offsetof(struct EnumerationDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct EnumerationDescriptiveDataSection__metricsourcelist), offsetof(struct EnumerationDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct EnumerationDescriptiveDataSection__msmtsitelist), offsetof(struct EnumerationDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct EnumerationDescriptiveDataSection__msmtsitelistext), offsetof(struct EnumerationDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct EnumerationDescriptiveDataSection__bodysitelist), offsetof(struct EnumerationDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct EnumerationDescriptiveDataSection__bodysitelistext), offsetof(struct EnumerationDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct EnumerationDescriptiveDataSection__metriccalibration), offsetof(struct EnumerationDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_enummeasurerange_36[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_enummeasurerange_tags_36[] = { (ASN_TAG_CLASS_APPLICATION | (2561 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_enummeasurerange_specs_36 = { sizeof(struct EnumerationDescriptiveDataSection__enummeasurerange), offsetof(struct EnumerationDescriptiveDataSection__enummeasurerange, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_enummeasurerange_36 = { "enummeasurerange", "enummeasurerange", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_enummeasurerange_tags_36, sizeof(asn_DEF_enummeasurerange_tags_36) /sizeof(asn_DEF_enummeasurerange_tags_36[0]) - 1, /* 1 */ asn_DEF_enummeasurerange_tags_36, /* Same as above */ sizeof(asn_DEF_enummeasurerange_tags_36) /sizeof(asn_DEF_enummeasurerange_tags_36[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_enummeasurerange_36, 1, /* Single element */ &asn_SPC_enummeasurerange_specs_36 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_EnumerationDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumerationDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct EnumerationDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct EnumerationDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 26, offsetof(struct EnumerationDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 25, offsetof(struct EnumerationDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 24, offsetof(struct EnumerationDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 23, offsetof(struct EnumerationDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 22, offsetof(struct EnumerationDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 21, offsetof(struct EnumerationDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 20, offsetof(struct EnumerationDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 19, offsetof(struct EnumerationDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 18, offsetof(struct EnumerationDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 17, offsetof(struct EnumerationDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 16, offsetof(struct EnumerationDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 15, offsetof(struct EnumerationDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 14, offsetof(struct EnumerationDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 13, offsetof(struct EnumerationDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 12, offsetof(struct EnumerationDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 11, offsetof(struct EnumerationDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 10, offsetof(struct EnumerationDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 9, offsetof(struct EnumerationDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 8, offsetof(struct EnumerationDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 7, offsetof(struct EnumerationDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 6, offsetof(struct EnumerationDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 5, offsetof(struct EnumerationDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 4, offsetof(struct EnumerationDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 3, offsetof(struct EnumerationDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_POINTER, 2, offsetof(struct EnumerationDescriptiveDataSection, enummeasurerange), (ASN_TAG_CLASS_APPLICATION | (2561 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_enummeasurerange_36, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enummeasurerange" }, { ATF_POINTER, 1, offsetof(struct EnumerationDescriptiveDataSection, enummeasurerangebits), (ASN_TAG_CLASS_APPLICATION | (2568 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_BIT_STRING, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enummeasurerangebits" }, }; static ber_tlv_tag_t asn_DEF_EnumerationDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumerationDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (2561 << 2)), 27, 0, 0 }, /* enummeasurerange at 1169 */ { (ASN_TAG_CLASS_APPLICATION | (2568 << 2)), 28, 0, 0 }, /* enummeasurerangebits at 1174 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumerationDescriptiveDataSection_specs_1 = { sizeof(struct EnumerationDescriptiveDataSection), offsetof(struct EnumerationDescriptiveDataSection, _asn_ctx), asn_MAP_EnumerationDescriptiveDataSection_tag2el_1, 29, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumerationDescriptiveDataSection = { "EnumerationDescriptiveDataSection", "EnumerationDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumerationDescriptiveDataSection_tags_1, sizeof(asn_DEF_EnumerationDescriptiveDataSection_tags_1) /sizeof(asn_DEF_EnumerationDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_EnumerationDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_EnumerationDescriptiveDataSection_tags_1) /sizeof(asn_DEF_EnumerationDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumerationDescriptiveDataSection_1, 29, /* Elements count */ &asn_SPC_EnumerationDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/RealTimeSampleArrayMeasuredDataSection.h0000664000175000017500000000242014105434233025317 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _RealTimeSampleArrayMeasuredDataSection_H_ #define _RealTimeSampleArrayMeasuredDataSection_H_ #include /* Including external dependencies */ #include #include "Fraction.h" #include "SampleArrayMeasuredDataBlock.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* RealTimeSampleArrayMeasuredDataSection */ typedef struct RealTimeSampleArrayMeasuredDataSection { INTEGER_t numberofsubblocks; Fraction_t subblocklength; INTEGER_t subblocksize; struct RealTimeSampleArrayMeasuredDataSection__metriclist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } metriclist; SampleArrayMeasuredDataBlock_t data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } RealTimeSampleArrayMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_RealTimeSampleArrayMeasuredDataSection; #ifdef __cplusplus } #endif #endif /* _RealTimeSampleArrayMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/ProdSpecEntry.c0000664000175000017500000000504014105434233020404 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ProdSpecEntry.h" static asn_TYPE_member_t asn_MBR_ProdSpecEntry_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ProdSpecEntry, spec_type), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ProdSpecEntryType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "spec-type" }, { ATF_NOFLAGS, 0, offsetof(struct ProdSpecEntry, component_id), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "component-id" }, { ATF_NOFLAGS, 0, offsetof(struct ProdSpecEntry, prod_spec), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "prod-spec" }, }; static ber_tlv_tag_t asn_DEF_ProdSpecEntry_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ProdSpecEntry_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* spec-type at 573 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* component-id at 574 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 } /* prod-spec at 576 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ProdSpecEntry_specs_1 = { sizeof(struct ProdSpecEntry), offsetof(struct ProdSpecEntry, _asn_ctx), asn_MAP_ProdSpecEntry_tag2el_1, 3, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ProdSpecEntry = { "ProdSpecEntry", "ProdSpecEntry", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ProdSpecEntry_tags_1, sizeof(asn_DEF_ProdSpecEntry_tags_1) /sizeof(asn_DEF_ProdSpecEntry_tags_1[0]), /* 1 */ asn_DEF_ProdSpecEntry_tags_1, /* Same as above */ sizeof(asn_DEF_ProdSpecEntry_tags_1) /sizeof(asn_DEF_ProdSpecEntry_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ProdSpecEntry_1, 3, /* Elements count */ &asn_SPC_ProdSpecEntry_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/per_encoder.c0000664000175000017500000000715614105434233020142 0ustar schloeglschloegl#include #include #include static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); asn_enc_rval_t uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { return uper_encode_internal(td, 0, sptr, cb, app_key); } /* * Argument type and callback necessary for uper_encode_to_buffer(). */ typedef struct enc_to_buf_arg { void *buffer; size_t left; } enc_to_buf_arg; static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) { enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if(arg->left < size) return -1; /* Data exceeds the available buffer size */ memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; arg->left -= size; return 0; } asn_enc_rval_t uper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr, void *buffer, size_t buffer_size) { enc_to_buf_arg key; key.buffer = buffer; key.left = buffer_size; if(td) ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name); return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key); } typedef struct enc_dyn_arg { void *buffer; size_t length; size_t allocated; } enc_dyn_arg; static int encode_dyn_cb(const void *buffer, size_t size, void *key) { enc_dyn_arg *arg = key; if(arg->length + size >= arg->allocated) { void *p; arg->allocated = arg->allocated ? (arg->allocated << 2) : size; p = REALLOC(arg->buffer, arg->allocated); if(!p) { FREEMEM(arg->buffer); memset(arg, 0, sizeof(*arg)); return -1; } arg->buffer = p; } memcpy(((char *)arg->buffer) + arg->length, buffer, size); arg->length += size; return 0; } ssize_t uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, void **buffer_r) { asn_enc_rval_t er; enc_dyn_arg key; memset(&key, 0, sizeof(key)); er = uper_encode_internal(td, constraints, sptr, encode_dyn_cb, &key); switch(er.encoded) { case -1: FREEMEM(key.buffer); return -1; case 0: FREEMEM(key.buffer); key.buffer = MALLOC(1); if(key.buffer) { *(char *)key.buffer = '\0'; *buffer_r = key.buffer; return 1; } else { return -1; } default: *buffer_r = key.buffer; ASN_DEBUG("Complete encoded in %d bits", er.encoded); return ((er.encoded + 7) >> 3); } } /* * Internally useful functions. */ /* Flush partially filled buffer */ static int _uper_encode_flush_outp(asn_per_outp_t *po) { uint8_t *buf; if(po->nboff == 0 && po->buffer == po->tmpspace) return 0; buf = po->buffer + (po->nboff >> 3); /* Make sure we account for the last, partially filled */ if(po->nboff & 0x07) { buf[0] &= 0xff << (8 - (po->nboff & 0x07)); buf++; } return po->outper(po->tmpspace, buf - po->tmpspace, po->op_key); } static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { asn_per_outp_t po; asn_enc_rval_t er; /* * Invoke type-specific encoder. */ if(!td || !td->uper_encoder) _ASN_ENCODE_FAILED; /* PER is not compiled in */ po.buffer = po.tmpspace; po.nboff = 0; po.nbits = 8 * sizeof(po.tmpspace); po.outper = cb; po.op_key = app_key; po.flushed_bytes = 0; er = td->uper_encoder(td, constraints, sptr, &po); if(er.encoded != -1) { size_t bits_to_flush; bits_to_flush = ((po.buffer - po.tmpspace) << 3) + po.nboff; /* Set number of bits encoded to a firm value */ er.encoded = (po.flushed_bytes << 3) + bits_to_flush; if(_uper_encode_flush_outp(&po)) _ASN_ENCODE_FAILED; } return er; } biosig-2.3.3/biosig4c++/t240/HealthCareProfessionalSection.c0000664000175000017500000001416514105434233023565 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "HealthCareProfessionalSection.h" static asn_TYPE_member_t asn_MBR_HealthCareProfessionalSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct HealthCareProfessionalSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_POINTER, 10, offsetof(struct HealthCareProfessionalSection, ungroupedname), (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ungroupedname" }, { ATF_POINTER, 9, offsetof(struct HealthCareProfessionalSection, characternamegroup), (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "characternamegroup" }, { ATF_POINTER, 8, offsetof(struct HealthCareProfessionalSection, ideographicnamegroup), (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ideographicnamegroup" }, { ATF_POINTER, 7, offsetof(struct HealthCareProfessionalSection, phoneticnamegroup), (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "phoneticnamegroup" }, { ATF_POINTER, 6, offsetof(struct HealthCareProfessionalSection, identification), (ASN_TAG_CLASS_APPLICATION | (6011 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "identification" }, { ATF_POINTER, 5, offsetof(struct HealthCareProfessionalSection, identificationcode), (ASN_TAG_CLASS_APPLICATION | (6012 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "identificationcode" }, { ATF_POINTER, 4, offsetof(struct HealthCareProfessionalSection, authorization_level), (ASN_TAG_CLASS_APPLICATION | (2481 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Authorization, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "authorization-level" }, { ATF_POINTER, 3, offsetof(struct HealthCareProfessionalSection, function), (ASN_TAG_CLASS_APPLICATION | (6048 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "function" }, { ATF_POINTER, 2, offsetof(struct HealthCareProfessionalSection, functioncode), (ASN_TAG_CLASS_APPLICATION | (6049 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "functioncode" }, { ATF_POINTER, 1, offsetof(struct HealthCareProfessionalSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, }; static ber_tlv_tag_t asn_DEF_HealthCareProfessionalSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_HealthCareProfessionalSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 305 */ { (ASN_TAG_CLASS_APPLICATION | (2481 << 2)), 7, 0, 0 }, /* authorization-level at 317 */ { (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), 1, 0, 0 }, /* ungroupedname at 195 */ { (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), 2, 0, 0 }, /* characternamegroup at 196 */ { (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), 3, 0, 0 }, /* ideographicnamegroup at 197 */ { (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), 4, 0, 0 }, /* phoneticnamegroup at 198 */ { (ASN_TAG_CLASS_APPLICATION | (6011 << 2)), 5, 0, 0 }, /* identification at 311 */ { (ASN_TAG_CLASS_APPLICATION | (6012 << 2)), 6, 0, 0 }, /* identificationcode at 314 */ { (ASN_TAG_CLASS_APPLICATION | (6048 << 2)), 8, 0, 0 }, /* function at 320 */ { (ASN_TAG_CLASS_APPLICATION | (6049 << 2)), 9, 0, 0 }, /* functioncode at 323 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 10, 0, 0 } /* placeholder at 326 */ }; static asn_SEQUENCE_specifics_t asn_SPC_HealthCareProfessionalSection_specs_1 = { sizeof(struct HealthCareProfessionalSection), offsetof(struct HealthCareProfessionalSection, _asn_ctx), asn_MAP_HealthCareProfessionalSection_tag2el_1, 11, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_HealthCareProfessionalSection = { "HealthCareProfessionalSection", "HealthCareProfessionalSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_HealthCareProfessionalSection_tags_1, sizeof(asn_DEF_HealthCareProfessionalSection_tags_1) /sizeof(asn_DEF_HealthCareProfessionalSection_tags_1[0]), /* 1 */ asn_DEF_HealthCareProfessionalSection_tags_1, /* Same as above */ sizeof(asn_DEF_HealthCareProfessionalSection_tags_1) /sizeof(asn_DEF_HealthCareProfessionalSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_HealthCareProfessionalSection_1, 11, /* Elements count */ &asn_SPC_HealthCareProfessionalSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/der_encoder.c0000664000175000017500000001164514105434233020124 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, asn_app_consume_bytes_f *cb, void *app_key, int constructed); /* * The DER encoder of any type. */ asn_enc_rval_t der_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr, asn_app_consume_bytes_f *consume_bytes, void *app_key) { ASN_DEBUG("DER encoder invoked for %s", type_descriptor->name); /* * Invoke type-specific encoder. */ return type_descriptor->der_encoder(type_descriptor, struct_ptr, /* Pointer to the destination structure */ 0, 0, consume_bytes, app_key); } /* * Argument type and callback necessary for der_encode_to_buffer(). */ typedef struct enc_to_buf_arg { void *buffer; size_t left; } enc_to_buf_arg; static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) { enc_to_buf_arg *arg = (enc_to_buf_arg *)key; if(arg->left < size) return -1; /* Data exceeds the available buffer size */ memcpy(arg->buffer, buffer, size); arg->buffer = ((char *)arg->buffer) + size; arg->left -= size; return 0; } /* * A variant of the der_encode() which encodes the data into the provided buffer */ asn_enc_rval_t der_encode_to_buffer(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr, void *buffer, size_t buffer_size) { enc_to_buf_arg arg; asn_enc_rval_t ec; arg.buffer = buffer; arg.left = buffer_size; ec = type_descriptor->der_encoder(type_descriptor, struct_ptr, /* Pointer to the destination structure */ 0, 0, encode_to_buffer_cb, &arg); if(ec.encoded != -1) { assert(ec.encoded == (ssize_t)(buffer_size - arg.left)); /* Return the encoded contents size */ } return ec; } /* * Write out leading TL[v] sequence according to the type definition. */ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, int tag_mode, int last_tag_form, ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */ asn_app_consume_bytes_f *cb, void *app_key) { ber_tlv_tag_t *tags; /* Copy of tags stream */ int tags_count; /* Number of tags */ size_t overall_length; ssize_t *lens; int i; ASN_DEBUG("Writing tags (%s, tm=%d, tc=%d, tag=%s, mtc=%d)", sd->name, tag_mode, sd->tags_count, ber_tlv_tag_string(tag), tag_mode ?(sd->tags_count+1 -((tag_mode == -1) && sd->tags_count)) :sd->tags_count ); if(tag_mode) { /* * Instead of doing shaman dance like we do in ber_check_tags(), * allocate a small array on the stack * and initialize it appropriately. */ int stag_offset; tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t)); if(!tags) { /* Can fail on !x86 */ errno = ENOMEM; return -1; } tags_count = sd->tags_count + 1 /* EXPLICIT or IMPLICIT tag is given */ - ((tag_mode == -1) && sd->tags_count); /* Copy tags over */ tags[0] = tag; stag_offset = -1 + ((tag_mode == -1) && sd->tags_count); for(i = 1; i < tags_count; i++) tags[i] = sd->tags[i + stag_offset]; } else { tags = sd->tags; tags_count = sd->tags_count; } /* No tags to write */ if(tags_count == 0) return 0; lens = (ssize_t *)alloca(tags_count * sizeof(lens[0])); if(!lens) { errno = ENOMEM; return -1; } /* * Array of tags is initialized. * Now, compute the size of the TLV pairs, from right to left. */ overall_length = struct_length; for(i = tags_count - 1; i >= 0; --i) { lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0); if(lens[i] == -1) return -1; overall_length += lens[i]; lens[i] = overall_length - lens[i]; } if(!cb) return overall_length - struct_length; ASN_DEBUG("%s %s TL sequence (%d elements)", cb?"Encoding":"Estimating", sd->name, tags_count); /* * Encode the TL sequence for real. */ for(i = 0; i < tags_count; i++) { ssize_t len; int _constr; /* Check if this tag happens to be constructed */ _constr = (last_tag_form || i < (tags_count - 1)); len = der_write_TL(tags[i], lens[i], cb, app_key, _constr); if(len == -1) return -1; } return overall_length - struct_length; } static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, asn_app_consume_bytes_f *cb, void *app_key, int constructed) { uint8_t buf[32]; size_t size = 0; int buf_size = cb?sizeof(buf):0; ssize_t tmp; /* Serialize tag (T from TLV) into possibly zero-length buffer */ tmp = ber_tlv_tag_serialize(tag, buf, buf_size); if(tmp == -1 || tmp > (ssize_t)sizeof(buf)) return -1; size += tmp; /* Serialize length (L from TLV) into possibly zero-length buffer */ tmp = der_tlv_length_serialize(len, buf+size, buf_size?buf_size-size:0); if(tmp == -1) return -1; size += tmp; if(size > sizeof(buf)) return -1; /* * If callback is specified, invoke it, and check its return value. */ if(cb) { if(constructed) *buf |= 0x20; if(cb(buf, size, app_key) < 0) return -1; } return size; } biosig-2.3.3/biosig4c++/t240/SessionPhaseSection.c0000664000175000017500000001227614105434233021605 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SessionPhaseSection.h" static asn_TYPE_member_t asn_MBR_measureddata_7[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_measureddata_tags_7[] = { (ASN_TAG_CLASS_APPLICATION | (7019 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_measureddata_specs_7 = { sizeof(struct SessionPhaseSection__measureddata), offsetof(struct SessionPhaseSection__measureddata, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_measureddata_7 = { "measureddata", "measureddata", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_measureddata_tags_7, sizeof(asn_DEF_measureddata_tags_7) /sizeof(asn_DEF_measureddata_tags_7[0]) - 1, /* 1 */ asn_DEF_measureddata_tags_7, /* Same as above */ sizeof(asn_DEF_measureddata_tags_7) /sizeof(asn_DEF_measureddata_tags_7[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_measureddata_7, 1, /* Single element */ &asn_SPC_measureddata_specs_7 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SessionPhaseSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SessionPhaseSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct SessionPhaseSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_NOFLAGS, 0, offsetof(struct SessionPhaseSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 1, offsetof(struct SessionPhaseSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_NOFLAGS, 0, offsetof(struct SessionPhaseSection, descriptivedata), (ASN_TAG_CLASS_APPLICATION | (7018 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_DescriptiveDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "descriptivedata" }, { ATF_NOFLAGS, 0, offsetof(struct SessionPhaseSection, measureddata), (ASN_TAG_CLASS_APPLICATION | (7019 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_measureddata_7, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureddata" }, }; static ber_tlv_tag_t asn_DEF_SessionPhaseSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SessionPhaseSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 726 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 1, 0, 0 }, /* starttime at 729 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 2, 0, 0 }, /* stoptime at 731 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 3, 0, 0 }, /* placeholder at 733 */ { (ASN_TAG_CLASS_APPLICATION | (7018 << 2)), 4, 0, 0 }, /* descriptivedata at 735 */ { (ASN_TAG_CLASS_APPLICATION | (7019 << 2)), 5, 0, 0 } /* measureddata at 741 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SessionPhaseSection_specs_1 = { sizeof(struct SessionPhaseSection), offsetof(struct SessionPhaseSection, _asn_ctx), asn_MAP_SessionPhaseSection_tag2el_1, 6, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SessionPhaseSection = { "SessionPhaseSection", "SessionPhaseSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SessionPhaseSection_tags_1, sizeof(asn_DEF_SessionPhaseSection_tags_1) /sizeof(asn_DEF_SessionPhaseSection_tags_1[0]), /* 1 */ asn_DEF_SessionPhaseSection_tags_1, /* Same as above */ sizeof(asn_DEF_SessionPhaseSection_tags_1) /sizeof(asn_DEF_SessionPhaseSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SessionPhaseSection_1, 6, /* Elements count */ &asn_SPC_SessionPhaseSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ChannelDescriptionSection.c0000664000175000017500000001241314105434233022746 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ChannelDescriptionSection.h" static int asn_DFL_8_set_65535(int set_value, void **sptr) { INTEGER_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 65535 */ return asn_long2INTEGER(st, 65535); } else { /* Test default value 65535 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 65535); } } static asn_TYPE_member_t asn_MBR_ChannelDescriptionSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ChannelDescriptionSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct ChannelDescriptionSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 6, offsetof(struct ChannelDescriptionSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 5, offsetof(struct ChannelDescriptionSection, channelid), (ASN_TAG_CLASS_APPLICATION | (2318 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "channelid" }, { ATF_POINTER, 4, offsetof(struct ChannelDescriptionSection, channelstatus), (ASN_TAG_CLASS_APPLICATION | (2320 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "channelstatus" }, { ATF_POINTER, 3, offsetof(struct ChannelDescriptionSection, parametergroup), (ASN_TAG_CLASS_APPLICATION | (2346 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ParameterGroupCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "parametergroup" }, { ATF_POINTER, 2, offsetof(struct ChannelDescriptionSection, physicalchannelnr), (ASN_TAG_CLASS_APPLICATION | (2319 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_8_set_65535, /* DEFAULT 65535 */ "physicalchannelnr" }, { ATF_POINTER, 1, offsetof(struct ChannelDescriptionSection, measurementprinciple), (ASN_TAG_CLASS_APPLICATION | (2560 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MsmtPrinciple, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementprinciple" }, }; static ber_tlv_tag_t asn_DEF_ChannelDescriptionSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ChannelDescriptionSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2318 << 2)), 3, 0, 0 }, /* channelid at 672 */ { (ASN_TAG_CLASS_APPLICATION | (2319 << 2)), 6, 0, 0 }, /* physicalchannelnr at 683 */ { (ASN_TAG_CLASS_APPLICATION | (2320 << 2)), 4, 0, 0 }, /* channelstatus at 677 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 663 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 2, 0, 0 }, /* labelstring at 669 */ { (ASN_TAG_CLASS_APPLICATION | (2346 << 2)), 5, 0, 0 }, /* parametergroup at 680 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 1, 0, 0 }, /* metrictype at 666 */ { (ASN_TAG_CLASS_APPLICATION | (2560 << 2)), 7, 0, 0 } /* measurementprinciple at 687 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ChannelDescriptionSection_specs_1 = { sizeof(struct ChannelDescriptionSection), offsetof(struct ChannelDescriptionSection, _asn_ctx), asn_MAP_ChannelDescriptionSection_tag2el_1, 8, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ChannelDescriptionSection = { "ChannelDescriptionSection", "ChannelDescriptionSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ChannelDescriptionSection_tags_1, sizeof(asn_DEF_ChannelDescriptionSection_tags_1) /sizeof(asn_DEF_ChannelDescriptionSection_tags_1[0]), /* 1 */ asn_DEF_ChannelDescriptionSection_tags_1, /* Same as above */ sizeof(asn_DEF_ChannelDescriptionSection_tags_1) /sizeof(asn_DEF_ChannelDescriptionSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ChannelDescriptionSection_1, 8, /* Elements count */ &asn_SPC_ChannelDescriptionSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/sopen_fef_read.c0000664000175000017500000003241314105434233020606 0ustar schloeglschloegl/* sandbox is used for development and under constraction work The functions here are either under construction or experimental. The functions will be either fixed, then they are moved to another place; or the functions are discarded. Do not rely on the interface in this function $Id$ Copyright (C) 2009,2012 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include #include #include #include #include #include "../biosig-dev.h" #ifdef WITH_FEF #include "SessionArchiveSection.h" #endif EXTERN_C void sopen_fef_read(HDRTYPE* hdr) { #ifndef WITH_FEF B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "ASN1/FEF currently not supported"; #else fprintf(stdout,"ASN1: Warning FEF/ASN.1 decoding very experimental. Tested only with TaskForceMonitor (TFM). You are warned. \n"); static asn_TYPE_descriptor_t *pduType = &asn_DEF_SessionArchiveSection; SessionArchiveSection_t *SAS = NULL; SessionTestSection_t *STS = NULL; SessionPhaseSection_t *SPS = NULL; /* Decoded structure */ asn_codec_ctx_t *opt_codec_ctx = 0; asn_dec_rval_t rval; long ival; double val; if (VERBOSE_LEVEL>7) fprintf(stdout,"ASN1: BER DECODING\n"); size_t pos =32; rval = ber_decode(0, pduType, (void **)&SAS, hdr->AS.Header+32, hdr->HeadLen-32); pos += rval.consumed; /* backup info for proper freeing of memery */ hdr->aECG = malloc(sizeof(struct asn1)); { struct asn1 *asn1info = (struct asn1*)hdr->aECG; asn1info->pduType = pduType; asn1info->SAS = SAS; } /* while (posHeadLen) { fprintf(stdout,"%i/%i\n",pos,hdr->HeadLen); rval = ber_decode(opt_codec_ctx, pduType, (void **)&SAS, hdr->AS.Header+pos, hdr->HeadLen-32); pos += rval.consumed; } */ if (VERBOSE_LEVEL>7) fprintf(stdout,"%i/%i\nASN1: BER DECODING DONE\n",(unsigned)pos,hdr->HeadLen); if (VERBOSE_LEVEL>8) { // asn_fprint(stdout, &asn_DEF_SessionArchiveSection, SAS); // SAS->s_archive_id asn_fprint(stdout, &asn_DEF_FEFString, &SAS->s_archive_id); asn_fprint(stdout, &asn_DEF_FEFString, &SAS->s_archive_name); asn_fprint(stdout, &asn_DEF_FEFString, SAS->s_archive_comments); /********************************** Manufacturer information **********************************/ asn_fprint(stdout, &asn_DEF_ManufacturerSpecificSection, SAS->manufacturerspecific); /********************************** Health Care provider **********************************/ asn_fprint(stdout, &asn_DEF_HealthCareProviderSection, SAS->healthcareprovider); asn_fprint(stdout, &asn_DEF_PatientDemographicsSection, &SAS->demographics); } /********************************** demographic information **********************************/ if (!asn_INTEGER2long(SAS->demographics.sex, &ival)) hdr->Patient.Sex = ival; { if (!asn_REAL2double(&SAS->demographics.patientweight->value, &val)) hdr->Patient.Weight = (uint8_t)val; if (!asn_REAL2double(&SAS->demographics.patientheight->value, &val)) hdr->Patient.Height = (uint8_t)val; char *str1 = (char*)SAS->demographics.characternamegroup->givenname.buf; char *str2 = (char*)SAS->demographics.characternamegroup->middlename.buf; char *str3 = (char*)SAS->demographics.characternamegroup->familyname.buf; size_t l1 = strlen(str1); size_t l2 = strlen(str2); size_t l3 = strlen(str3); if (l1 <= MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name, str1); } if (l1+l2+1 <= MAX_LENGTH_NAME) { hdr->Patient.Name[l1]=' '; strcpy(hdr->Patient.Name+1 + l1, str2); // Flawfinder: ignore } if (l1+l2+l3+2 <= MAX_LENGTH_NAME) { hdr->Patient.Name[l1+l2+1]=' '; strcpy(hdr->Patient.Name+2+l1+l2, str3); // Flawfinder: ignore } } /********************************** Test Section information **********************************/ // asn_fprint(stdout, &asn_DEF_SessionTestSection, SAS->sessions.list.array[0]); // asn_fprint(stdout, &asn_DEF_SessionTestSection, SAS->sessions.list.array[k]); if (VERBOSE_LEVEL>7) fprintf(stdout,"Number of TestSections %i\n",SAS->sessions.list.count); size_t N = SAS->sessions.list.count; if (N>1) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(FEF): multiple test sections are not supported, yet"); STS = SAS->sessions.list.array[0]; // asn_fprint(stdout, &asn_DEF_SessionTestSection, STS); /******* Manufacturer ************/ // asn_fprint(stdout, &asn_DEF_MedicalDeviceSystemSection, &STS->medicaldevicesystem); strncpy(hdr->ID.Manufacturer._field, (const char*)STS->medicaldevicesystem.systemmodel.manufacturer.buf, MAX_LENGTH_MANUF); int LEN = strlen(hdr->ID.Manufacturer._field)+1; hdr->ID.Manufacturer.Name = hdr->ID.Manufacturer._field; strncpy(hdr->ID.Manufacturer._field+LEN, (const char*)STS->medicaldevicesystem.systemmodel.model_number.buf, MAX_LENGTH_MANUF-LEN); hdr->ID.Manufacturer.Model = hdr->ID.Manufacturer._field+LEN; /******* Multimedia ************/ /******* Session Phase Section SPS ************/ // asn_fprint(stdout, &asn_DEF_SessionTestSection, SAS->sessions.list.array[0]); // asn_fprint(stdout, &asn_DEF_SessionTestSection, SAS->sessions.list.array[k]); N = STS->phases.list.count; if (N>1) biosigERROR(hdr, B4C_FORMAT_UNSUPPORTED, "Error SOPEN(FEF): multiple test sections are not supported, yet"); SPS = STS->phases.list.array[0]; // asn_fprint(stdout, &asn_DEF_SessionPhaseSection, SPS); // asn_fprint(stdout, &asn_DEF_DescriptiveDataSection, &SPS->descriptivedata); /**************** Descriptive Data Section DescDS ****************/ // SPS->descriptivedata->realtimesadescs // asn_fprint(stdout, &asn_DEF_SessionTestSection, SAS->sessions.list.array[0]); N = SPS->descriptivedata.realtimesadescs->list.count; hdr->NS = N; hdr->CHANNEL = (CHANNEL_TYPE*)calloc(hdr->NS,sizeof(CHANNEL_TYPE)); typeof(hdr->NS) k; uint64_t FsN=1,FsD=1; for (k=0; kNS; k++) { RealTimeSampleArrayDescriptiveDataSection_t *RTSADDS = SPS->descriptivedata.realtimesadescs->list.array[k]; if (VERBOSE_LEVEL>8) { fprintf(stdout,"[FEF 212] #=%i/%i\n",k,hdr->NS); asn_fprint(stdout, &asn_DEF_RealTimeSampleArrayDescriptiveDataSection, RTSADDS); } CHANNEL_TYPE *hc = hdr->CHANNEL+k; strncpy(hc->Label, (const char*)RTSADDS->labelstring->buf, MAX_LENGTH_LABEL); if (!asn_INTEGER2long(RTSADDS->unitcode,&ival)) hc->PhysDimCode= (uint16_t)ival; else hc->PhysDimCode= 0; if (!hc->PhysDimCode) hc->PhysDimCode = PhysDimCode((const char*)RTSADDS->unitlabelstring->buf); //******************* samplerate *****************/ long int n=0, d=0; asn_INTEGER2long(&RTSADDS->sampleperiod.denominator, &d); asn_INTEGER2long(&RTSADDS->sampleperiod.numerator,&n); if (VERBOSE_LEVEL>7) fprintf(stdout,"#%i: %li %li\n",k,n,d); if (n && d) { FsN = lcm(FsN,n); FsD = lcm(FsD,d); } hc->SPR = d; // double Fs = (double)n / d; //******************* scaling *****************/ hc->PhysMax = +100; hc->PhysMin = -100; hc->DigMax = +2047; hc->DigMin = -2048; if (asn_REAL2double(&RTSADDS->scaleandrangespec.lowerabsolutevalue,&hc->PhysMin) || asn_REAL2double(&RTSADDS->scaleandrangespec.upperabsolutevalue,&hc->PhysMax) || asn_REAL2double(&RTSADDS->scaleandrangespec.lowervaluescaled,&hc->DigMin) || asn_REAL2double(&RTSADDS->scaleandrangespec.uppervaluescaled,&hc->DigMax) ) fprintf(stderr,"Warning (FEF): scaling factors in channel %i not available\n",k+1); hc->Cal = (hc->PhysMax-hc->PhysMin)/(hc->DigMax-hc->DigMin); hc->Off = hc->PhysMin-hc->Cal*hc->DigMin; //******************* bits *****************/ long int bits=-1,dt=-1; asn_INTEGER2long(&RTSADDS->saspecification.storagesize,&bits); asn_INTEGER2long(&RTSADDS->saspecification.storagedatatype,&dt); hc->GDFTYP = 0; if (dt==2) // ieee 754 { if (bits==32) hc->GDFTYP = 16; // float32 else if (bits==64) hc->GDFTYP = 17; // float64 else if (bits==128) hc->GDFTYP = 18; // float128 } else if (dt==1) // signed { if (bits==8) hc->GDFTYP = 1; // else if (bits==16) hc->GDFTYP = 3; // else if (bits==24) hc->GDFTYP = 255+24; // else if (bits==32) hc->GDFTYP = 5; // else if (bits==64) hc->GDFTYP = 7; // } else if (dt==0) // unsigned { if (bits==8) hc->GDFTYP = 2; // else if (bits==16) hc->GDFTYP = 4; // else if (bits==24) hc->GDFTYP = 511+24; // else if (bits==32) hc->GDFTYP = 6; // else if (bits==64) hc->GDFTYP = 8; // } long int arraysize=0; asn_INTEGER2long(&RTSADDS->saspecification.storagesize,&arraysize); if (!arraysize) hc->SPR = arraysize; // else /* Number of samples of this signal in a subblock of SAMDB. Arraysize is actually redundant information in other cases than distribution sample array. Therefore, if arraysize = 0, the number of samples is calculated as divided by of the signal. */ //******************* filters *****************/ if (RTSADDS->sasignalfrequency) { double d; asn_REAL2double(&RTSADDS->sasignalfrequency->lowedgefreq, &d); hc->HighPass = d; asn_REAL2double(&RTSADDS->sasignalfrequency->highedgefreq, &d); hc->LowPass = d; } else { hc->HighPass = -1; hc->LowPass = INFINITY; } // TODO: MetricCalEntry, MetricCalType, // TODO: hc->LeadIdCode= 0; strcpy(hc->Transducer, ""); hc->bi = 0; hc->OnOff = 1; hc->Notch = -1; hc->Impedance = INFINITY; hc->XYZ[0] = 0.0; hc->XYZ[1] = 0.0; hc->XYZ[2] = 0.0; } size_t d = gcd(FsD,FsN); if (VERBOSE_LEVEL>7) fprintf(stdout,"Fs=%i/%i\n",(unsigned)FsN,(unsigned)FsD); hdr->SampleRate = ((double)(FsD/d))/((double)(FsN/d)); hdr->SPR = FsD; /************** Measured Data Section MeasDS ***********************/ N = SPS->measureddata.list.count; if (VERBOSE_LEVEL>7) fprintf(stdout,"Number of MeasuredData %i\n",(unsigned)N); // asn_fprint(stdout, &asn_DEF_SessionPhaseSection, SPS); for (k=0; kmeasureddata.list.array[k]; // asn_fprint(stdout, &asn_DEF_RealTimeSampleArrayMeasuredDataSection, RTSAMDS); unsigned n2; size_t listlen = MDS->realtimesas->list.count; hdr->SPR = 1; for (n2=0; n2 CHANNEL+n2; RealTimeSampleArrayMeasuredDataSection_t *RTSAMDS = MDS->realtimesas->list.array[n2]; // if (VERBOSE_LEVEL>7) // asn_fprint(stdout, &asn_DEF_RealTimeSampleArrayMeasuredDataSection, MDS->realtimesas->list.array[n2]); asn_INTEGER2long(&RTSAMDS->numberofsubblocks,&nrec); asn_INTEGER2long(&RTSAMDS->subblocklength.numerator,&n); asn_INTEGER2long(&RTSAMDS->subblocklength.denominator,&d); asn_INTEGER2long(&RTSAMDS->subblocksize,&spr); // &RTSAMDS->metriclist // if (VERBOSE_LEVEL>7) fprintf(stdout,"%i/%i blk: %i/%i #subblocks:%i subblocklength:%i/%i subblocksize:%i size:%i \n",(int)n2,(int)listlen,(int)k,(int)N,(int)nrec,(int)n,(int)d,(int)spr,(int)RTSAMDS->data.size); //RTSAMDS->data->buf //RTSAMDS->data.size hc->bufptr = RTSAMDS->data.buf; hc->SPR = (RTSAMDS->data.size<<3)/GDFTYP_BITS[hc->GDFTYP]; if (hdr->SPR < hc->SPR) hdr->SPR = hc->SPR; } } for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; double d = ((double)hdr->SPR)/hc->SPR; hc->OnOff = (d==floor(d)) && hc->SPR>8; // do not show non-signal data. TODO: use this data to decode event information hc->bi = 0; hc->bi8 = 0; } hdr->NRec = 1; hdr->AS.first = 0; hdr->AS.length = 1; /****** Notes Section information SNS **********************************/ if (VERBOSE_LEVEL>7) for (k=0; knotes->list.count; k++) { asn_fprint(stdout, &asn_DEF_SessionNotesSection, SAS->notes->list.array[k++]); } /******* post checks ************/ /* if(errno) { fprintf(stdout,"Error FEF: %s\n",strerror(errno)); // Error message is already printed // exit(-1); } */ /* Check ASN.1 constraints */ char errbuf[128]; size_t errlen = sizeof(errbuf); if(asn_check_constraints(pduType, SAS, errbuf, &errlen)) { fprintf(stdout, "SOPEN_FEF_READ: ASN.1 constraint " "check failed: %s\n", errbuf); } // asn_fprint(stdout, pduType, structure); // ASN_STRUCT_FREE(*pduType, SAS); #endif } EXTERN_C void sclose_fef_read(HDRTYPE* hdr) { if (VERBOSE_LEVEL>7) fprintf(stdout,"sclose_FEF_read\n"); #ifdef WITH_FEF if (hdr->aECG) { struct asn1 *asn1info = (struct asn1*)hdr->aECG; ASN_STRUCT_FREE((*(asn_TYPE_descriptor_t *)(asn1info->pduType)), ((SessionArchiveSection_t*)asn1info->SAS)); free(hdr->aECG); hdr->aECG = NULL; } #endif } biosig-2.3.3/biosig4c++/t240/MeasurementStatus.h0000664000175000017500000000242414105434233021344 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MeasurementStatus_H_ #define _MeasurementStatus_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum MeasurementStatus { MeasurementStatus_invalid = 0, MeasurementStatus_questionable = 1, MeasurementStatus_not_available = 2, MeasurementStatus_calibration_ongoing = 3, MeasurementStatus_test_data = 4, MeasurementStatus_demo_data = 5, MeasurementStatus_validated_data = 8, MeasurementStatus_early_indication = 9, MeasurementStatus_msmt_ongoing = 10 } e_MeasurementStatus; /* MeasurementStatus */ typedef BIT_STRING_t MeasurementStatus_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MeasurementStatus; asn_struct_free_f MeasurementStatus_free; asn_struct_print_f MeasurementStatus_print; asn_constr_check_f MeasurementStatus_constraint; ber_type_decoder_f MeasurementStatus_decode_ber; der_type_encoder_f MeasurementStatus_encode_der; xer_type_decoder_f MeasurementStatus_decode_xer; xer_type_encoder_f MeasurementStatus_encode_xer; #ifdef __cplusplus } #endif #endif /* _MeasurementStatus_H_ */ biosig-2.3.3/biosig4c++/t240/NativeEnumerated.h0000664000175000017500000000160114105434233021107 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2005, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * This type differs from the standard ENUMERATED in that it is modelled using * the fixed machine type (long, int, short), so it can hold only values of * limited length. There is no type (i.e., NativeEnumerated_t, any integer type * will do). * This type may be used when integer range is limited by subtype constraints. */ #ifndef _NativeEnumerated_H_ #define _NativeEnumerated_H_ #include #ifdef __cplusplus extern "C" { #endif extern asn_TYPE_descriptor_t asn_DEF_NativeEnumerated; xer_type_encoder_f NativeEnumerated_encode_xer; per_type_decoder_f NativeEnumerated_decode_uper; per_type_encoder_f NativeEnumerated_encode_uper; #ifdef __cplusplus } #endif #endif /* _NativeEnumerated_H_ */ biosig-2.3.3/biosig4c++/t240/Fraction.c0000664000175000017500000000406614105434233017417 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Fraction.h" static asn_TYPE_member_t asn_MBR_Fraction_1[] = { { ATF_NOFLAGS, 0, offsetof(struct Fraction, numerator), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numerator" }, { ATF_NOFLAGS, 0, offsetof(struct Fraction, denominator), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "denominator" }, }; static ber_tlv_tag_t asn_DEF_Fraction_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_Fraction_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* numerator at 95 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* denominator at 97 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Fraction_specs_1 = { sizeof(struct Fraction), offsetof(struct Fraction, _asn_ctx), asn_MAP_Fraction_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Fraction = { "Fraction", "Fraction", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Fraction_tags_1, sizeof(asn_DEF_Fraction_tags_1) /sizeof(asn_DEF_Fraction_tags_1[0]), /* 1 */ asn_DEF_Fraction_tags_1, /* Same as above */ sizeof(asn_DEF_Fraction_tags_1) /sizeof(asn_DEF_Fraction_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_Fraction_1, 2, /* Elements count */ &asn_SPC_Fraction_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/NumericDescriptiveDataSection.h0000664000175000017500000000764114105434233023604 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _NumericDescriptiveDataSection_H_ #define _NumericDescriptiveDataSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "HandleRef.h" #include "MetricsCode.h" #include "FEFString.h" #include "MetricCategory.h" #include "MetricStatus.h" #include "MeasurementStatus.h" #include "UnitsOfMeasurementCode.h" #include "SimpleColour.h" #include "PrivateCode.h" #include "AbsoluteTime.h" #include "FEFFloat.h" #include #include #include "BodySiteCode.h" #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ExtNomenRef; struct MetricMeasure; struct AbsoluteRange; struct DispResolution; struct MetricCalEntry; /* NumericDescriptiveDataSection */ typedef struct NumericDescriptiveDataSection { Handle_t handle; HandleRef_t devicehandle; MetricsCode_t metrictype; FEFString_t *labelstring /* OPTIONAL */; MetricCategory_t *metriccategory /* DEFAULT 0 */; MetricStatus_t *metricstatus /* DEFAULT {} */; MeasurementStatus_t *measurementstatus /* DEFAULT {} */; MetricsCode_t *metricid /* OPTIONAL */; struct ExtNomenRef *metricidext /* OPTIONAL */; UnitsOfMeasurementCode_t *unitcode /* OPTIONAL */; FEFString_t *unitlabelstring /* OPTIONAL */; struct NumericDescriptiveDataSection__vmosourcelist { A_SEQUENCE_OF(MetricsCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *vmosourcelist; struct NumericDescriptiveDataSection__metricsourcelist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metricsourcelist; struct NumericDescriptiveDataSection__msmtsitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelist; struct NumericDescriptiveDataSection__msmtsitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *msmtsitelistext; struct NumericDescriptiveDataSection__bodysitelist { A_SEQUENCE_OF(BodySiteCode_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelist; struct NumericDescriptiveDataSection__bodysitelistext { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *bodysitelistext; struct NumericDescriptiveDataSection__metriccalibration { A_SEQUENCE_OF(struct MetricCalEntry) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *metriccalibration; SimpleColour_t *colour /* OPTIONAL */; PrivateCode_t *measuremode /* OPTIONAL */; struct MetricMeasure *measureperiod /* OPTIONAL */; struct MetricMeasure *averagingperiod /* OPTIONAL */; AbsoluteTime_t *starttime /* OPTIONAL */; AbsoluteTime_t *stoptime /* OPTIONAL */; FEFString_t *metricinfolabelstring /* OPTIONAL */; struct ExtNomenRef *substance /* OPTIONAL */; FEFString_t *substancelabelstring /* OPTIONAL */; struct AbsoluteRange *numeasurerange /* OPTIONAL */; struct AbsoluteRange *nuphysiologicalrange /* OPTIONAL */; FEFFloat_t *numeasureresolution /* OPTIONAL */; struct DispResolution *displayresolution /* OPTIONAL */; FEFFloat_t *accuracy /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } NumericDescriptiveDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_NumericDescriptiveDataSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ExtNomenRef.h" #include "MetricMeasure.h" #include "AbsoluteRange.h" #include "DispResolution.h" #include "MetricCalEntry.h" #endif /* _NumericDescriptiveDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/BITS-8.h0000664000175000017500000000135114105434233016557 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _BITS_8_H_ #define _BITS_8_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* BITS-8 */ typedef BIT_STRING_t BITS_8_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_BITS_8; asn_struct_free_f BITS_8_free; asn_struct_print_f BITS_8_print; asn_constr_check_f BITS_8_constraint; ber_type_decoder_f BITS_8_decode_ber; der_type_encoder_f BITS_8_encode_der; xer_type_decoder_f BITS_8_decode_xer; xer_type_encoder_f BITS_8_encode_xer; #ifdef __cplusplus } #endif #endif /* _BITS_8_H_ */ biosig-2.3.3/biosig4c++/t240/UTF8String.c0000664000175000017500000001123614105434233017564 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include /* * UTF8String basic type description. */ static ber_tlv_tag_t asn_DEF_UTF8String_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), /* [UNIVERSAL 12] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), /* ... OCTET STRING */ }; asn_TYPE_descriptor_t asn_DEF_UTF8String = { "UTF8String", "UTF8String", OCTET_STRING_free, UTF8String_print, UTF8String_constraint, /* Check for invalid codes, etc. */ OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, OCTET_STRING_decode_xer_utf8, OCTET_STRING_encode_xer_utf8, OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_UTF8String_tags, sizeof(asn_DEF_UTF8String_tags) / sizeof(asn_DEF_UTF8String_tags[0]) - 1, asn_DEF_UTF8String_tags, sizeof(asn_DEF_UTF8String_tags) / sizeof(asn_DEF_UTF8String_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; /* * This is the table of length expectations. * The second half of this table is only applicable to the long sequences. */ static int UTF8String_ht[2][16] = { { /* 0x0 ... 0x7 */ /* 0000..0111 */ 1, 1, 1, 1, 1, 1, 1, 1, /* 1000..1011(0), 1100..1101(2), 1110(3), 1111(-1) */ 0, 0, 0, 0, 2, 2, 3, -1 }, { /* 0xF0 .. 0xF7 */ /* 11110000..11110111 */ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, -1, -1 } }; static int32_t UTF8String_mv[7] = { 0, 0, 0x00000080, 0x00000800, 0x00010000, 0x00200000, 0x04000000 }; /* Internal aliases for return codes */ #define U8E_TRUNC -1 /* UTF-8 sequence truncated */ #define U8E_ILLSTART -2 /* Illegal UTF-8 sequence start */ #define U8E_NOTCONT -3 /* Continuation expectation failed */ #define U8E_NOTMIN -4 /* Not minimal length encoding */ #define U8E_EINVAL -5 /* Invalid arguments */ int UTF8String_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { ssize_t len = UTF8String_length((const UTF8String_t *)sptr); switch(len) { case U8E_EINVAL: _ASN_CTFAIL(app_key, td, sptr, "%s: value not given", td->name); break; case U8E_TRUNC: _ASN_CTFAIL(app_key, td, sptr, "%s: truncated UTF-8 sequence (%s:%d)", td->name, __FILE__, __LINE__); break; case U8E_ILLSTART: _ASN_CTFAIL(app_key, td, sptr, "%s: UTF-8 illegal start of encoding (%s:%d)", td->name, __FILE__, __LINE__); break; case U8E_NOTCONT: _ASN_CTFAIL(app_key, td, sptr, "%s: UTF-8 not continuation (%s:%d)", td->name, __FILE__, __LINE__); break; case U8E_NOTMIN: _ASN_CTFAIL(app_key, td, sptr, "%s: UTF-8 not minimal sequence (%s:%d)", td->name, __FILE__, __LINE__); break; } return (len < 0) ? -1 : 0; } static ssize_t UTF8String__process(const UTF8String_t *st, uint32_t *dst, size_t dstlen) { size_t length; uint8_t *buf = st->buf; uint8_t *end = buf + st->size; uint32_t *dstend = dst + dstlen; for(length = 0; buf < end; length++) { int ch = *buf; uint8_t *cend; int32_t value; int want; /* Compute the sequence length */ want = UTF8String_ht[0][ch >> 4]; switch(want) { case -1: /* Second half of the table, long sequence */ want = UTF8String_ht[1][ch & 0x0F]; if(want != -1) break; /* Fall through */ case 0: return U8E_ILLSTART; } /* assert(want >= 1 && want <= 6) */ /* Check character sequence length */ if(buf + want > end) return U8E_TRUNC; value = ch & (0xff >> want); cend = buf + want; for(buf++; buf < cend; buf++) { ch = *buf; if(ch < 0x80 || ch > 0xbf) return U8E_NOTCONT; value = (value << 6) | (ch & 0x3F); } if(value < UTF8String_mv[want]) return U8E_NOTMIN; if(dst < dstend) *dst++ = value; /* Record value */ } if(dst < dstend) *dst = 0; /* zero-terminate */ return length; } ssize_t UTF8String_length(const UTF8String_t *st) { if(st && st->buf) { return UTF8String__process(st, 0, 0); } else { return U8E_EINVAL; } } size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen) { if(st && st->buf) { ssize_t ret = UTF8String__process(st, dst, dstlen); return (ret < 0) ? 0 : ret; } else { return 0; } } int UTF8String_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const UTF8String_t *st = (const UTF8String_t *)sptr; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(st && st->buf) { return (cb(st->buf, st->size, app_key) < 0) ? -1 : 0; } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } biosig-2.3.3/biosig4c++/t240/CurLimAlStat.h0000664000175000017500000000172214105434233020157 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _CurLimAlStat_H_ #define _CurLimAlStat_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum CurLimAlStat { CurLimAlStat_limalertoff = 0, CurLimAlStat_limlowoff = 1, CurLimAlStat_limhighoff = 2 } e_CurLimAlStat; /* CurLimAlStat */ typedef BIT_STRING_t CurLimAlStat_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_CurLimAlStat; asn_struct_free_f CurLimAlStat_free; asn_struct_print_f CurLimAlStat_print; asn_constr_check_f CurLimAlStat_constraint; ber_type_decoder_f CurLimAlStat_decode_ber; der_type_encoder_f CurLimAlStat_encode_der; xer_type_decoder_f CurLimAlStat_decode_xer; xer_type_encoder_f CurLimAlStat_encode_xer; #ifdef __cplusplus } #endif #endif /* _CurLimAlStat_H_ */ biosig-2.3.3/biosig4c++/t240/PrivateCode.h0000664000175000017500000000144414105434233020061 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PrivateCode_H_ #define _PrivateCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* PrivateCode */ typedef INTEGER_t PrivateCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PrivateCode; asn_struct_free_f PrivateCode_free; asn_struct_print_f PrivateCode_print; asn_constr_check_f PrivateCode_constraint; ber_type_decoder_f PrivateCode_decode_ber; der_type_encoder_f PrivateCode_encode_der; xer_type_decoder_f PrivateCode_decode_xer; xer_type_encoder_f PrivateCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _PrivateCode_H_ */ biosig-2.3.3/biosig4c++/t240/BIT_STRING.c0000664000175000017500000001074014105434233017352 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * BIT STRING basic type description. */ static ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; static asn_OCTET_STRING_specifics_t asn_DEF_BIT_STRING_specs = { sizeof(BIT_STRING_t), offsetof(BIT_STRING_t, _asn_ctx), ASN_OSUBV_BIT }; asn_TYPE_descriptor_t asn_DEF_BIT_STRING = { "BIT STRING", "BIT_STRING", OCTET_STRING_free, /* Implemented in terms of OCTET STRING */ BIT_STRING_print, BIT_STRING_constraint, OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ OCTET_STRING_decode_xer_binary, BIT_STRING_encode_xer, OCTET_STRING_decode_uper, /* Unaligned PER decoder */ OCTET_STRING_encode_uper, /* Unaligned PER encoder */ 0, /* Use generic outmost tag fetcher */ asn_DEF_BIT_STRING_tags, sizeof(asn_DEF_BIT_STRING_tags) / sizeof(asn_DEF_BIT_STRING_tags[0]), asn_DEF_BIT_STRING_tags, /* Same as above */ sizeof(asn_DEF_BIT_STRING_tags) / sizeof(asn_DEF_BIT_STRING_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ &asn_DEF_BIT_STRING_specs }; /* * BIT STRING generic constraint. */ int BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; if(st && st->buf) { if((st->size == 0 && st->bits_unused) || st->bits_unused < 0 || st->bits_unused > 7) { _ASN_CTFAIL(app_key, td, sptr, "%s: invalid padding byte (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } else { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } return 0; } static char *_bit_pattern[16] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }; asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er; char scratch[128]; char *p = scratch; char *scend = scratch + (sizeof(scratch) - 10); const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; int xcan = (flags & XER_F_CANONICAL); uint8_t *buf; uint8_t *end; if(!st || !st->buf) _ASN_ENCODE_FAILED; er.encoded = 0; buf = st->buf; end = buf + st->size - 1; /* Last byte is special */ /* * Binary dump */ for(; buf < end; buf++) { int v = *buf; int nline = xcan?0:(((buf - st->buf) % 8) == 0); if(p >= scend || nline) { er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; if(nline) _i_ASN_TEXT_INDENT(1, ilevel); } memcpy(p + 0, _bit_pattern[v >> 4], 4); memcpy(p + 4, _bit_pattern[v & 0x0f], 4); p += 8; } if(!xcan && ((buf - st->buf) % 8) == 0) _i_ASN_TEXT_INDENT(1, ilevel); er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); p = scratch; if(buf == end) { int v = *buf; int ubits = st->bits_unused; int i; for(i = 7; i >= ubits; i--) *p++ = (v & (1 << i)) ? 0x31 : 0x30; er.encoded += p - scratch; _ASN_CALLBACK(scratch, p - scratch); } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } /* * BIT STRING specific contents printer. */ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { static const char *h2c = "0123456789ABCDEF"; char scratch[64]; const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; uint8_t *buf; uint8_t *end; char *p = scratch; (void)td; /* Unused argument */ if(!st || !st->buf) return (cb("", 8, app_key) < 0) ? -1 : 0; ilevel++; buf = st->buf; end = buf + st->size; /* * Hexadecimal dump. */ for(; buf < end; buf++) { if((buf - st->buf) % 16 == 0 && (st->size > 16) && buf != st->buf) { _i_INDENT(1); /* Dump the string */ if(cb(scratch, p - scratch, app_key) < 0) return -1; p = scratch; } *p++ = h2c[*buf >> 4]; *p++ = h2c[*buf & 0x0F]; *p++ = 0x20; } if(p > scratch) { p--; /* Eat the tailing space */ if((st->size > 16)) { _i_INDENT(1); } /* Dump the incomplete 16-bytes row */ if(cb(scratch, p - scratch, app_key) < 0) return -1; } return 0; } biosig-2.3.3/biosig4c++/t240/per_opentype.c0000664000175000017500000002167314105434233020366 0ustar schloeglschloegl/* * Copyright (c) 2007 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include #include typedef struct uper_ugot_key { asn_per_data_t oldpd; /* Old per data source */ size_t unclaimed; size_t ot_moved; /* Number of bits moved by OT processing */ int repeat; } uper_ugot_key; static int uper_ugot_refill(asn_per_data_t *pd); static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int asn_debug_indent; /* * Encode an "open type field". * #10.1, #10.2 */ int uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { void *buf; void *bptr; ssize_t size; size_t toGo; ASN_DEBUG("Open type put %s ...", td->name); size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); if(size <= 0) return -1; for(bptr = buf, toGo = size; toGo;) { ssize_t maySave = uper_put_length(po, toGo); if(maySave < 0) break; if(per_put_many_bits(po, bptr, maySave * 8)) break; bptr = (char *)bptr + maySave; toGo -= maySave; } FREEMEM(buf); if(toGo) return -1; ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", td->name, size); return 0; } static asn_dec_rval_t uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_dec_rval_t rv; ssize_t chunk_bytes; int repeat; uint8_t *buf = 0; size_t bufLen = 0; size_t bufSize = 0; asn_per_data_t spd; size_t padding; _ASN_STACK_OVERFLOW_CHECK(ctx); ASN_DEBUG("Getting open type %s...", td->name); do { chunk_bytes = uper_get_length(pd, -1, &repeat); if(chunk_bytes < 0) { FREEMEM(buf); _ASN_DECODE_STARVED; } if(bufLen + chunk_bytes > bufSize) { void *ptr; bufSize = chunk_bytes + (bufSize << 2); ptr = REALLOC(buf, bufSize); if(!ptr) { FREEMEM(buf); _ASN_DECODE_FAILED; } buf = ptr; } if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) { FREEMEM(buf); _ASN_DECODE_STARVED; } bufLen += chunk_bytes; } while(repeat); ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, bufLen); memset(&spd, 0, sizeof(spd)); spd.buffer = buf; spd.nbits = bufLen << 3; asn_debug_indent += 4; rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); asn_debug_indent -= 4; if(rv.code == RC_OK) { /* Check padding validity */ padding = spd.nbits - spd.nboff; if(padding < 8 && per_get_few_bits(&spd, padding) == 0) { /* Everything is cool */ FREEMEM(buf); return rv; } FREEMEM(buf); if(padding >= 8) { ASN_DEBUG("Too large padding %d in open type", padding); _ASN_DECODE_FAILED; } else { ASN_DEBUG("Non-zero padding"); _ASN_DECODE_FAILED; } } else { FREEMEM(buf); /* rv.code could be RC_WMORE, nonsense in this context */ rv.code = RC_FAIL; /* Noone would give us more */ } return rv; } static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { uper_ugot_key arg; asn_dec_rval_t rv; ssize_t padding; _ASN_STACK_OVERFLOW_CHECK(ctx); ASN_DEBUG("Getting open type %s from %s", td->name, per_data_string(pd)); arg.oldpd = *pd; arg.unclaimed = 0; arg.ot_moved = 0; arg.repeat = 1; pd->refill = uper_ugot_refill; pd->refill_key = &arg; pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ pd->moved = 0; /* This now counts the open type size in bits */ asn_debug_indent += 4; rv = td->uper_decoder(ctx, td, constraints, sptr, pd); asn_debug_indent -= 4; #define UPDRESTOREPD do { \ /* buffer and nboff are valid, preserve them. */ \ pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ pd->refill = arg.oldpd.refill; \ pd->refill_key = arg.oldpd.refill_key; \ } while(0) if(rv.code != RC_OK) { UPDRESTOREPD; return rv; } ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d" , td->name, per_data_string(pd), per_data_string(&arg.oldpd), arg.unclaimed, arg.repeat); padding = pd->moved % 8; if(padding) { int32_t pvalue; if(padding > 7) { ASN_DEBUG("Too large padding %d in open type", padding); rv.code = RC_FAIL; UPDRESTOREPD; return rv; } padding = 8 - padding; ASN_DEBUG("Getting padding of %d bits", padding); pvalue = per_get_few_bits(pd, padding); switch(pvalue) { case -1: ASN_DEBUG("Padding skip failed"); UPDRESTOREPD; _ASN_DECODE_STARVED; case 0: break; default: ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", padding, (int)pvalue); UPDRESTOREPD; _ASN_DECODE_FAILED; } } if(pd->nboff != pd->nbits) { ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, per_data_string(pd), per_data_string(&arg.oldpd)); if(1) { UPDRESTOREPD; _ASN_DECODE_FAILED; } else { arg.unclaimed += pd->nbits - pd->nboff; } } /* Adjust pd back so it points to original data */ UPDRESTOREPD; /* Skip data not consumed by the decoder */ if(arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); if(arg.unclaimed) { switch(per_skip_bits(pd, arg.unclaimed)) { case -1: ASN_DEBUG("Claim of %d failed", arg.unclaimed); _ASN_DECODE_STARVED; case 0: ASN_DEBUG("Got claim of %d", arg.unclaimed); break; default: /* Padding must be blank */ ASN_DEBUG("Non-blank unconsumed padding"); _ASN_DECODE_FAILED; } arg.unclaimed = 0; } if(arg.repeat) { ASN_DEBUG("Not consumed the whole thing"); rv.code = RC_FAIL; return rv; } return rv; } asn_dec_rval_t uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { return uper_open_type_get_simple(ctx, td, constraints, sptr, pd); } int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { asn_TYPE_descriptor_t s_td; asn_dec_rval_t rv; s_td.name = ""; s_td.uper_decoder = uper_sot_suck; rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); if(rv.code != RC_OK) return -1; else return 0; } /* * Internal functions. */ static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_dec_rval_t rv; (void)ctx; (void)td; (void)constraints; (void)sptr; while(per_get_few_bits(pd, 24) >= 0); rv.code = RC_OK; rv.consumed = pd->moved; return rv; } static int uper_ugot_refill(asn_per_data_t *pd) { uper_ugot_key *arg = pd->refill_key; ssize_t next_chunk_bytes, next_chunk_bits; ssize_t avail; asn_per_data_t *oldpd = &arg->oldpd; ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", pd->moved, oldpd->moved); /* Advance our position to where pd is */ oldpd->buffer = pd->buffer; oldpd->nboff = pd->nboff; oldpd->nbits -= pd->moved - arg->ot_moved; oldpd->moved += pd->moved - arg->ot_moved; arg->ot_moved = pd->moved; if(arg->unclaimed) { /* Refill the container */ if(per_get_few_bits(oldpd, 1)) return -1; if(oldpd->nboff == 0) { assert(0); return -1; } pd->buffer = oldpd->buffer; pd->nboff = oldpd->nboff - 1; pd->nbits = oldpd->nbits; ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); return 0; } if(!arg->repeat) { ASN_DEBUG("Want more but refill doesn't have it"); return -1; } next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", next_chunk_bytes, oldpd->moved, arg->repeat); if(next_chunk_bytes < 0) return -1; if(next_chunk_bytes == 0) { pd->refill = 0; /* No more refills, naturally */ assert(!arg->repeat); /* Implementation guarantee */ } next_chunk_bits = next_chunk_bytes << 3; avail = oldpd->nbits - oldpd->nboff; if(avail >= next_chunk_bits) { pd->nbits = oldpd->nboff + next_chunk_bits; arg->unclaimed = 0; ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", next_chunk_bits, oldpd->moved, oldpd->nboff, oldpd->nbits, oldpd->nbits - oldpd->nboff); } else { pd->nbits = oldpd->nbits; arg->unclaimed = next_chunk_bits - avail; ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); } pd->buffer = oldpd->buffer; pd->nboff = oldpd->nboff; ASN_DEBUG("Refilled pd%s old%s", per_data_string(pd), per_data_string(oldpd)); return 0; } static int per_skip_bits(asn_per_data_t *pd, int skip_nbits) { int hasNonZeroBits = 0; while(skip_nbits > 0) { int skip; if(skip_nbits < skip) skip = skip_nbits; else skip = 24; skip_nbits -= skip; switch(per_get_few_bits(pd, skip)) { case -1: return -1; /* Starving */ case 0: continue; /* Skipped empty space */ default: hasNonZeroBits = 1; continue; } } return hasNonZeroBits; } biosig-2.3.3/biosig4c++/t240/MeasurementStatus.c0000664000175000017500000000752714105434233021350 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MeasurementStatus.h" int MeasurementStatus_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void MeasurementStatus_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void MeasurementStatus_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MeasurementStatus_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MeasurementStatus_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MeasurementStatus_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MeasurementStatus_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MeasurementStatus_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MeasurementStatus_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MeasurementStatus_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MeasurementStatus_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MeasurementStatus_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MeasurementStatus_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MeasurementStatus_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MeasurementStatus_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MeasurementStatus = { "MeasurementStatus", "MeasurementStatus", MeasurementStatus_free, MeasurementStatus_print, MeasurementStatus_constraint, MeasurementStatus_decode_ber, MeasurementStatus_encode_der, MeasurementStatus_decode_xer, MeasurementStatus_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MeasurementStatus_tags_1, sizeof(asn_DEF_MeasurementStatus_tags_1) /sizeof(asn_DEF_MeasurementStatus_tags_1[0]), /* 1 */ asn_DEF_MeasurementStatus_tags_1, /* Same as above */ sizeof(asn_DEF_MeasurementStatus_tags_1) /sizeof(asn_DEF_MeasurementStatus_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SaSpec.c0000664000175000017500000000614014105434233017023 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaSpec.h" static asn_TYPE_member_t asn_MBR_SaSpec_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SaSpec, storagesize), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "storagesize" }, { ATF_POINTER, 1, offsetof(struct SaSpec, significantbits), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "significantbits" }, { ATF_NOFLAGS, 0, offsetof(struct SaSpec, storagedatatype), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_StorageDataType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "storagedatatype" }, { ATF_POINTER, 1, offsetof(struct SaSpec, flags), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaFlags, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "flags" }, { ATF_NOFLAGS, 0, offsetof(struct SaSpec, arraysize), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "arraysize" }, }; static ber_tlv_tag_t asn_DEF_SaSpec_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SaSpec_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* storagesize at 994 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* significantbits at 997 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 }, /* storagedatatype at 1001 */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 3, 0, 0 }, /* flags at 1002 */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 4, 0, 0 } /* arraysize at 1005 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SaSpec_specs_1 = { sizeof(struct SaSpec), offsetof(struct SaSpec, _asn_ctx), asn_MAP_SaSpec_tag2el_1, 5, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SaSpec = { "SaSpec", "SaSpec", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaSpec_tags_1, sizeof(asn_DEF_SaSpec_tags_1) /sizeof(asn_DEF_SaSpec_tags_1[0]), /* 1 */ asn_DEF_SaSpec_tags_1, /* Same as above */ sizeof(asn_DEF_SaSpec_tags_1) /sizeof(asn_DEF_SaSpec_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SaSpec_1, 5, /* Elements count */ &asn_SPC_SaSpec_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/MarkerEntryRelTim.c0000664000175000017500000000436414105434233021233 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MarkerEntryRelTim.h" static asn_TYPE_member_t asn_MBR_MarkerEntryRelTim_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MarkerEntryRelTim, markerid), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "markerid" }, { ATF_NOFLAGS, 0, offsetof(struct MarkerEntryRelTim, marktime), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_RelativeTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "marktime" }, }; static ber_tlv_tag_t asn_DEF_MarkerEntryRelTim_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MarkerEntryRelTim_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* markerid at 1262 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* marktime at 1264 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MarkerEntryRelTim_specs_1 = { sizeof(struct MarkerEntryRelTim), offsetof(struct MarkerEntryRelTim, _asn_ctx), asn_MAP_MarkerEntryRelTim_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MarkerEntryRelTim = { "MarkerEntryRelTim", "MarkerEntryRelTim", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MarkerEntryRelTim_tags_1, sizeof(asn_DEF_MarkerEntryRelTim_tags_1) /sizeof(asn_DEF_MarkerEntryRelTim_tags_1[0]), /* 1 */ asn_DEF_MarkerEntryRelTim_tags_1, /* Same as above */ sizeof(asn_DEF_MarkerEntryRelTim_tags_1) /sizeof(asn_DEF_MarkerEntryRelTim_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MarkerEntryRelTim_1, 2, /* Elements count */ &asn_SPC_MarkerEntryRelTim_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/MultimediaSection.c0000664000175000017500000001031414105434233021262 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MultimediaSection.h" static asn_TYPE_member_t asn_MBR_MultimediaSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct MultimediaSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_NOFLAGS, 0, offsetof(struct MultimediaSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_NOFLAGS, 0, offsetof(struct MultimediaSection, mimetype), (ASN_TAG_CLASS_APPLICATION | (6017 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "mimetype" }, { ATF_POINTER, 3, offsetof(struct MultimediaSection, comments), (ASN_TAG_CLASS_APPLICATION | (6018 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Comments, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "comments" }, { ATF_POINTER, 2, offsetof(struct MultimediaSection, originallocation), (ASN_TAG_CLASS_APPLICATION | (6019 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "originallocation" }, { ATF_POINTER, 1, offsetof(struct MultimediaSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_NOFLAGS, 0, offsetof(struct MultimediaSection, contentorreference), (ASN_TAG_CLASS_APPLICATION | (6020 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ContentOrReference, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "contentorreference" }, }; static ber_tlv_tag_t asn_DEF_MultimediaSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MultimediaSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 0, 0, 0 }, /* starttime at 703 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 1, 0, 0 }, /* stoptime at 704 */ { (ASN_TAG_CLASS_APPLICATION | (6017 << 2)), 2, 0, 0 }, /* mimetype at 705 */ { (ASN_TAG_CLASS_APPLICATION | (6018 << 2)), 3, 0, 0 }, /* comments at 706 */ { (ASN_TAG_CLASS_APPLICATION | (6019 << 2)), 4, 0, 0 }, /* originallocation at 707 */ { (ASN_TAG_CLASS_APPLICATION | (6020 << 2)), 6, 0, 0 }, /* contentorreference at 710 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 5, 0, 0 } /* placeholder at 708 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MultimediaSection_specs_1 = { sizeof(struct MultimediaSection), offsetof(struct MultimediaSection, _asn_ctx), asn_MAP_MultimediaSection_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MultimediaSection = { "MultimediaSection", "MultimediaSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MultimediaSection_tags_1, sizeof(asn_DEF_MultimediaSection_tags_1) /sizeof(asn_DEF_MultimediaSection_tags_1[0]), /* 1 */ asn_DEF_MultimediaSection_tags_1, /* Same as above */ sizeof(asn_DEF_MultimediaSection_tags_1) /sizeof(asn_DEF_MultimediaSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MultimediaSection_1, 7, /* Elements count */ &asn_SPC_MultimediaSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/INT-U64.c0000664000175000017500000000674614105434233016667 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-U64.h" int INT_U64_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void INT_U64_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void INT_U64_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_U64_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_U64_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_U64_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_U64_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_U64_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_U64_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_U64_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_U64_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_U64_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_U64_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_U64_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_U64_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_U64 = { "INT-U64", "INT-U64", INT_U64_free, INT_U64_print, INT_U64_constraint, INT_U64_decode_ber, INT_U64_encode_der, INT_U64_decode_xer, INT_U64_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_U64_tags_1, sizeof(asn_DEF_INT_U64_tags_1) /sizeof(asn_DEF_INT_U64_tags_1[0]), /* 1 */ asn_DEF_INT_U64_tags_1, /* Same as above */ sizeof(asn_DEF_INT_U64_tags_1) /sizeof(asn_DEF_INT_U64_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/AlertSection.c0000664000175000017500000000774414105434233020254 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertSection.h" static asn_TYPE_member_t asn_MBR_AlertSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct AlertSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct AlertSection, alerttype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alerttype" }, { ATF_POINTER, 1, offsetof(struct AlertSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_NOFLAGS, 0, offsetof(struct AlertSection, timestamp), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ObservationTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timestamp" }, { ATF_NOFLAGS, 0, offsetof(struct AlertSection, alertcondition), (ASN_TAG_CLASS_APPLICATION | (2476 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AlertCondition, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alertcondition" }, { ATF_POINTER, 2, offsetof(struct AlertSection, limitspec), (ASN_TAG_CLASS_APPLICATION | (2477 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_LimitSpecEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "limitspec" }, { ATF_POINTER, 1, offsetof(struct AlertSection, vmoreference), (ASN_TAG_CLASS_APPLICATION | (6045 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmoreference" }, }; static ber_tlv_tag_t asn_DEF_AlertSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_AlertSection_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 3, 0, 0 }, /* timestamp at 1387 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 1378 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 2, 0, 0 }, /* labelstring at 1384 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 1, 0, 0 }, /* alerttype at 1381 */ { (ASN_TAG_CLASS_APPLICATION | (2476 << 2)), 4, 0, 0 }, /* alertcondition at 1390 */ { (ASN_TAG_CLASS_APPLICATION | (2477 << 2)), 5, 0, 0 }, /* limitspec at 1392 */ { (ASN_TAG_CLASS_APPLICATION | (6045 << 2)), 6, 0, 0 } /* vmoreference at 1395 */ }; static asn_SEQUENCE_specifics_t asn_SPC_AlertSection_specs_1 = { sizeof(struct AlertSection), offsetof(struct AlertSection, _asn_ctx), asn_MAP_AlertSection_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_AlertSection = { "AlertSection", "AlertSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertSection_tags_1, sizeof(asn_DEF_AlertSection_tags_1) /sizeof(asn_DEF_AlertSection_tags_1[0]), /* 1 */ asn_DEF_AlertSection_tags_1, /* Same as above */ sizeof(asn_DEF_AlertSection_tags_1) /sizeof(asn_DEF_AlertSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_AlertSection_1, 7, /* Elements count */ &asn_SPC_AlertSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/PersonNameGroup.h0000664000175000017500000000145314105434233020740 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PersonNameGroup_H_ #define _PersonNameGroup_H_ #include /* Including external dependencies */ #include "FEFString.h" #include #ifdef __cplusplus extern "C" { #endif /* PersonNameGroup */ typedef struct PersonNameGroup { FEFString_t familyname; FEFString_t givenname; FEFString_t middlename; FEFString_t prefix; FEFString_t suffix; FEFString_t degree; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } PersonNameGroup_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PersonNameGroup; #ifdef __cplusplus } #endif #endif /* _PersonNameGroup_H_ */ biosig-2.3.3/biosig4c++/t240/PrivateCode.c0000664000175000017500000000714614105434233020061 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PrivateCode.h" int PrivateCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void PrivateCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void PrivateCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { PrivateCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int PrivateCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { PrivateCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t PrivateCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { PrivateCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t PrivateCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { PrivateCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t PrivateCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { PrivateCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t PrivateCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { PrivateCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_PrivateCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_PrivateCode = { "PrivateCode", "PrivateCode", PrivateCode_free, PrivateCode_print, PrivateCode_constraint, PrivateCode_decode_ber, PrivateCode_encode_der, PrivateCode_decode_xer, PrivateCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PrivateCode_tags_1, sizeof(asn_DEF_PrivateCode_tags_1) /sizeof(asn_DEF_PrivateCode_tags_1[0]), /* 1 */ asn_DEF_PrivateCode_tags_1, /* Same as above */ sizeof(asn_DEF_PrivateCode_tags_1) /sizeof(asn_DEF_PrivateCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/StorageDataType.c0000664000175000017500000000735514105434233020716 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "StorageDataType.h" int StorageDataType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void StorageDataType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void StorageDataType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { StorageDataType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int StorageDataType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { StorageDataType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t StorageDataType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { StorageDataType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t StorageDataType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { StorageDataType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t StorageDataType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { StorageDataType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t StorageDataType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { StorageDataType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_StorageDataType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_StorageDataType = { "StorageDataType", "StorageDataType", StorageDataType_free, StorageDataType_print, StorageDataType_constraint, StorageDataType_decode_ber, StorageDataType_encode_der, StorageDataType_decode_xer, StorageDataType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_StorageDataType_tags_1, sizeof(asn_DEF_StorageDataType_tags_1) /sizeof(asn_DEF_StorageDataType_tags_1[0]), /* 1 */ asn_DEF_StorageDataType_tags_1, /* Same as above */ sizeof(asn_DEF_StorageDataType_tags_1) /sizeof(asn_DEF_StorageDataType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/INT-U8.h0000664000175000017500000000134414105434233016577 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_U8_H_ #define _INT_U8_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-U8 */ typedef long INT_U8_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_U8; asn_struct_free_f INT_U8_free; asn_struct_print_f INT_U8_print; asn_constr_check_f INT_U8_constraint; ber_type_decoder_f INT_U8_decode_ber; der_type_encoder_f INT_U8_encode_der; xer_type_decoder_f INT_U8_decode_xer; xer_type_encoder_f INT_U8_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_U8_H_ */ biosig-2.3.3/biosig4c++/t240/SessionTestSection.c0000664000175000017500000002064114105434233021457 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SessionTestSection.h" static asn_TYPE_member_t asn_MBR_multimedia_11[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MultimediaSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_multimedia_tags_11[] = { (ASN_TAG_CLASS_APPLICATION | (7006 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_multimedia_specs_11 = { sizeof(struct SessionTestSection__multimedia), offsetof(struct SessionTestSection__multimedia, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_multimedia_11 = { "multimedia", "multimedia", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_multimedia_tags_11, sizeof(asn_DEF_multimedia_tags_11) /sizeof(asn_DEF_multimedia_tags_11[0]) - 1, /* 1 */ asn_DEF_multimedia_tags_11, /* Same as above */ sizeof(asn_DEF_multimedia_tags_11) /sizeof(asn_DEF_multimedia_tags_11[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_multimedia_11, 1, /* Single element */ &asn_SPC_multimedia_specs_11 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_phases_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SessionPhaseSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_phases_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (7017 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_phases_specs_13 = { sizeof(struct SessionTestSection__phases), offsetof(struct SessionTestSection__phases, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_phases_13 = { "phases", "phases", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_phases_tags_13, sizeof(asn_DEF_phases_tags_13) /sizeof(asn_DEF_phases_tags_13[0]) - 1, /* 1 */ asn_DEF_phases_tags_13, /* Same as above */ sizeof(asn_DEF_phases_tags_13) /sizeof(asn_DEF_phases_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_phases_13, 1, /* Single element */ &asn_SPC_phases_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_SessionTestSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, st_archive_id), (ASN_TAG_CLASS_APPLICATION | (2506 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "st-archive-id" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, st_archive_name), (ASN_TAG_CLASS_APPLICATION | (2512 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "st-archive-name" }, { ATF_POINTER, 1, offsetof(struct SessionTestSection, st_archive_comments), (ASN_TAG_CLASS_APPLICATION | (2529 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "st-archive-comments" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 2, offsetof(struct SessionTestSection, protection), (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ArchiveProtection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "protection" }, { ATF_POINTER, 1, offsetof(struct SessionTestSection, placeholder), (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 0, &asn_DEF_Placeholder, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "placeholder" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, medicaldevicesystem), (ASN_TAG_CLASS_APPLICATION | (7005 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MedicalDeviceSystemSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "medicaldevicesystem" }, { ATF_POINTER, 1, offsetof(struct SessionTestSection, multimedia), (ASN_TAG_CLASS_APPLICATION | (7006 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_multimedia_11, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "multimedia" }, { ATF_NOFLAGS, 0, offsetof(struct SessionTestSection, phases), (ASN_TAG_CLASS_APPLICATION | (7017 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_phases_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "phases" }, }; static ber_tlv_tag_t asn_DEF_SessionTestSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_SessionTestSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 453 */ { (ASN_TAG_CLASS_APPLICATION | (2506 << 2)), 1, 0, 0 }, /* st-archive-id at 456 */ { (ASN_TAG_CLASS_APPLICATION | (2512 << 2)), 2, 0, 0 }, /* st-archive-name at 458 */ { (ASN_TAG_CLASS_APPLICATION | (2519 << 2)), 6, 0, 0 }, /* protection at 466 */ { (ASN_TAG_CLASS_APPLICATION | (2529 << 2)), 3, 0, 0 }, /* st-archive-comments at 460 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 4, 0, 0 }, /* starttime at 462 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 5, 0, 0 }, /* stoptime at 464 */ { (ASN_TAG_CLASS_APPLICATION | (6499 << 2)), 7, 0, 0 }, /* placeholder at 468 */ { (ASN_TAG_CLASS_APPLICATION | (7005 << 2)), 8, 0, 0 }, /* medicaldevicesystem at 470 */ { (ASN_TAG_CLASS_APPLICATION | (7006 << 2)), 9, 0, 0 }, /* multimedia at 473 */ { (ASN_TAG_CLASS_APPLICATION | (7017 << 2)), 10, 0, 0 } /* phases at 478 */ }; static asn_SEQUENCE_specifics_t asn_SPC_SessionTestSection_specs_1 = { sizeof(struct SessionTestSection), offsetof(struct SessionTestSection, _asn_ctx), asn_MAP_SessionTestSection_tag2el_1, 11, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_SessionTestSection = { "SessionTestSection", "SessionTestSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SessionTestSection_tags_1, sizeof(asn_DEF_SessionTestSection_tags_1) /sizeof(asn_DEF_SessionTestSection_tags_1[0]), /* 1 */ asn_DEF_SessionTestSection_tags_1, /* Same as above */ sizeof(asn_DEF_SessionTestSection_tags_1) /sizeof(asn_DEF_SessionTestSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_SessionTestSection_1, 11, /* Elements count */ &asn_SPC_SessionTestSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/SampleArrayMeasuredDataSection.h0000664000175000017500000000217714105434233023705 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SampleArrayMeasuredDataSection_H_ #define _SampleArrayMeasuredDataSection_H_ #include /* Including external dependencies */ #include #include "Fraction.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* SampleArrayMeasuredDataSection */ typedef struct SampleArrayMeasuredDataSection { INTEGER_t numberofsubblocks; Fraction_t subblocklength; INTEGER_t subblocksize; struct SampleArrayMeasuredDataSection__metriclist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } metriclist; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SampleArrayMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SampleArrayMeasuredDataSection; #ifdef __cplusplus } #endif #endif /* _SampleArrayMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/ObservationTime.h0000664000175000017500000000157714105434233020775 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ObservationTime_H_ #define _ObservationTime_H_ #include /* Including external dependencies */ #include "AbsoluteTime.h" #include "RelativeTime.h" #include "HighResRelativeTime.h" #include #ifdef __cplusplus extern "C" { #endif /* ObservationTime */ typedef struct ObservationTime { AbsoluteTime_t *absolutetimestamp /* OPTIONAL */; RelativeTime_t *relativetimestamp /* OPTIONAL */; HighResRelativeTime_t *hirestimerelativestamp /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ObservationTime_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ObservationTime; #ifdef __cplusplus } #endif #endif /* _ObservationTime_H_ */ biosig-2.3.3/biosig4c++/t240/DistributionSampleArrayDescriptiveDataSection.c0000664000175000017500000010353314105434233027012 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DistributionSampleArrayDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__vmosourcelist), offsetof(struct DistributionSampleArrayDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__metricsourcelist), offsetof(struct DistributionSampleArrayDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__msmtsitelist), offsetof(struct DistributionSampleArrayDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__msmtsitelistext), offsetof(struct DistributionSampleArrayDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__bodysitelist), offsetof(struct DistributionSampleArrayDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__bodysitelistext), offsetof(struct DistributionSampleArrayDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__metriccalibration), offsetof(struct DistributionSampleArrayDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_visualgrid_40[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaGridEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_visualgrid_tags_40[] = { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_visualgrid_specs_40 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__visualgrid), offsetof(struct DistributionSampleArrayDescriptiveDataSection__visualgrid, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_visualgrid_40 = { "visualgrid", "visualgrid", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_visualgrid_tags_40, sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]) - 1, /* 1 */ asn_DEF_visualgrid_tags_40, /* Same as above */ sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_visualgrid_40, 1, /* Single element */ &asn_SPC_visualgrid_specs_40 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_sacalibrationdata_42[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaCalData, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_sacalibrationdata_tags_42[] = { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_sacalibrationdata_specs_42 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__sacalibrationdata), offsetof(struct DistributionSampleArrayDescriptiveDataSection__sacalibrationdata, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_sacalibrationdata_42 = { "sacalibrationdata", "sacalibrationdata", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_sacalibrationdata_tags_42, sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]) - 1, /* 1 */ asn_DEF_sacalibrationdata_tags_42, /* Same as above */ sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_sacalibrationdata_42, 1, /* Single element */ &asn_SPC_sacalibrationdata_specs_42 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_filterspecification_44[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaFilterEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_filterspecification_tags_44[] = { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_filterspecification_specs_44 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection__filterspecification), offsetof(struct DistributionSampleArrayDescriptiveDataSection__filterspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_filterspecification_44 = { "filterspecification", "filterspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_filterspecification_tags_44, sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]) - 1, /* 1 */ asn_DEF_filterspecification_tags_44, /* Same as above */ sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_filterspecification_44, 1, /* Single element */ &asn_SPC_filterspecification_specs_44 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_DistributionSampleArrayDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 24, offsetof(struct DistributionSampleArrayDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 23, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 22, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 21, offsetof(struct DistributionSampleArrayDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 20, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 19, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 18, offsetof(struct DistributionSampleArrayDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 17, offsetof(struct DistributionSampleArrayDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 16, offsetof(struct DistributionSampleArrayDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 15, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 14, offsetof(struct DistributionSampleArrayDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 13, offsetof(struct DistributionSampleArrayDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 12, offsetof(struct DistributionSampleArrayDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 11, offsetof(struct DistributionSampleArrayDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 10, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 9, offsetof(struct DistributionSampleArrayDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 8, offsetof(struct DistributionSampleArrayDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 7, offsetof(struct DistributionSampleArrayDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 6, offsetof(struct DistributionSampleArrayDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 5, offsetof(struct DistributionSampleArrayDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 4, offsetof(struct DistributionSampleArrayDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 3, offsetof(struct DistributionSampleArrayDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 2, offsetof(struct DistributionSampleArrayDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 1, offsetof(struct DistributionSampleArrayDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, saspecification), (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saspecification" }, { ATF_POINTER, 1, offsetof(struct DistributionSampleArrayDescriptiveDataSection, compression), (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compression" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, scaleandrangespec), (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ScaleRangeSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "scaleandrangespec" }, { ATF_POINTER, 6, offsetof(struct DistributionSampleArrayDescriptiveDataSection, saphysiologicalrange), (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saphysiologicalrange" }, { ATF_POINTER, 5, offsetof(struct DistributionSampleArrayDescriptiveDataSection, visualgrid), (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_visualgrid_40, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "visualgrid" }, { ATF_POINTER, 4, offsetof(struct DistributionSampleArrayDescriptiveDataSection, sacalibrationdata), (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_sacalibrationdata_42, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sacalibrationdata" }, { ATF_POINTER, 3, offsetof(struct DistributionSampleArrayDescriptiveDataSection, filterspecification), (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_filterspecification_44, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filterspecification" }, { ATF_POINTER, 2, offsetof(struct DistributionSampleArrayDescriptiveDataSection, sasignalfrequency), (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSignalFrequency, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sasignalfrequency" }, { ATF_POINTER, 1, offsetof(struct DistributionSampleArrayDescriptiveDataSection, sameasureresolution), (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sameasureresolution" }, { ATF_NOFLAGS, 0, offsetof(struct DistributionSampleArrayDescriptiveDataSection, distributionrangespec), (ASN_TAG_CLASS_APPLICATION | (2403 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_DsaRangeSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "distributionrangespec" }, { ATF_POINTER, 2, offsetof(struct DistributionSampleArrayDescriptiveDataSection, xunitcode), (ASN_TAG_CLASS_APPLICATION | (2455 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "xunitcode" }, { ATF_POINTER, 1, offsetof(struct DistributionSampleArrayDescriptiveDataSection, xunitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2458 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "xunitlabelstring" }, }; static ber_tlv_tag_t asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DistributionSampleArrayDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), 28, 0, 0 }, /* compression at 962 */ { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), 33, 0, 0 }, /* filterspecification at 983 */ { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), 31, 0, 0 }, /* visualgrid at 973 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2403 << 2)), 36, 0, 0 }, /* distributionrangespec at 1120 */ { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), 32, 0, 0 }, /* sacalibrationdata at 978 */ { (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), 34, 0, 0 }, /* sasignalfrequency at 986 */ { (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), 35, 0, 0 }, /* sameasureresolution at 989 */ { (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), 30, 0, 0 }, /* saphysiologicalrange at 969 */ { (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), 27, 0, 0 }, /* saspecification at 959 */ { (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), 29, 0, 0 }, /* scaleandrangespec at 965 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2455 << 2)), 37, 0, 0 }, /* xunitcode at 1123 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2458 << 2)), 38, 0, 0 }, /* xunitlabelstring at 1126 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DistributionSampleArrayDescriptiveDataSection_specs_1 = { sizeof(struct DistributionSampleArrayDescriptiveDataSection), offsetof(struct DistributionSampleArrayDescriptiveDataSection, _asn_ctx), asn_MAP_DistributionSampleArrayDescriptiveDataSection_tag2el_1, 39, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DistributionSampleArrayDescriptiveDataSection = { "DistributionSampleArrayDescriptiveDataSection", "DistributionSampleArrayDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1, sizeof(asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_DistributionSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DistributionSampleArrayDescriptiveDataSection_1, 39, /* Elements count */ &asn_SPC_DistributionSampleArrayDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/BITS-16.c0000664000175000017500000000755514105434233016645 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "BITS-16.h" int BITS_16_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; size_t size; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(st->size > 0) { /* Size in bits */ size = 8 * st->size - (st->bits_unused & 0x07); } else { size = 0; } if((size == 16)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void BITS_16_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void BITS_16_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { BITS_16_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int BITS_16_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { BITS_16_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t BITS_16_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { BITS_16_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t BITS_16_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { BITS_16_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t BITS_16_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { BITS_16_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t BITS_16_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { BITS_16_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_BITS_16_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_BITS_16 = { "BITS-16", "BITS-16", BITS_16_free, BITS_16_print, BITS_16_constraint, BITS_16_decode_ber, BITS_16_encode_der, BITS_16_decode_xer, BITS_16_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_BITS_16_tags_1, sizeof(asn_DEF_BITS_16_tags_1) /sizeof(asn_DEF_BITS_16_tags_1[0]), /* 1 */ asn_DEF_BITS_16_tags_1, /* Same as above */ sizeof(asn_DEF_BITS_16_tags_1) /sizeof(asn_DEF_BITS_16_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/xer_encoder.c0000664000175000017500000000300514105434233020137 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * The XER encoder of any type. May be invoked by the application. */ asn_enc_rval_t xer_encode(asn_TYPE_descriptor_t *td, void *sptr, enum xer_encoder_flags_e xer_flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er, tmper; const char *mname; size_t mlen; int xcan = (xer_flags & XER_F_CANONICAL) ? 1 : 2; if(!td || !sptr) goto cb_failed; mname = td->xml_tag; mlen = strlen(mname); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); if(tmper.encoded == -1) return tmper; _ASN_CALLBACK3("\n", xcan); er.encoded = 4 + xcan + (2 * mlen) + tmper.encoded; _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } /* * This is a helper function for xer_fprint, which directs all incoming data * into the provided file descriptor. */ static int xer__print2fp(const void *buffer, size_t size, void *app_key) { FILE *stream = (FILE *)app_key; if(fwrite(buffer, 1, size, stream) != size) return -1; return 0; } int xer_fprint(FILE *stream, asn_TYPE_descriptor_t *td, void *sptr) { asn_enc_rval_t er; if(!stream) stream = stdout; if(!td || !sptr) return -1; er = xer_encode(td, sptr, XER_F_BASIC, xer__print2fp, stream); if(er.encoded == -1) return -1; return fflush(stream); } biosig-2.3.3/biosig4c++/t240/RealTimeSampleArrayMeasuredDataSection.c0000664000175000017500000001246214105434233025321 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "RealTimeSampleArrayMeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_metriclist_5[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriclist_tags_5[] = { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriclist_specs_5 = { sizeof(struct RealTimeSampleArrayMeasuredDataSection__metriclist), offsetof(struct RealTimeSampleArrayMeasuredDataSection__metriclist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriclist_5 = { "metriclist", "metriclist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriclist_tags_5, sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]) - 1, /* 1 */ asn_DEF_metriclist_tags_5, /* Same as above */ sizeof(asn_DEF_metriclist_tags_5) /sizeof(asn_DEF_metriclist_tags_5[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriclist_5, 1, /* Single element */ &asn_SPC_metriclist_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_RealTimeSampleArrayMeasuredDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayMeasuredDataSection, numberofsubblocks), (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numberofsubblocks" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayMeasuredDataSection, subblocklength), (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocklength" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayMeasuredDataSection, subblocksize), (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "subblocksize" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayMeasuredDataSection, metriclist), (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriclist_5, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriclist" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayMeasuredDataSection, data), (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 0, &asn_DEF_SampleArrayMeasuredDataBlock, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "data" }, }; static ber_tlv_tag_t asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_RealTimeSampleArrayMeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (6035 << 2)), 0, 0, 0 }, /* numberofsubblocks at 1220 */ { (ASN_TAG_CLASS_APPLICATION | (6036 << 2)), 1, 0, 0 }, /* subblocklength at 1222 */ { (ASN_TAG_CLASS_APPLICATION | (6037 << 2)), 2, 0, 0 }, /* subblocksize at 1225 */ { (ASN_TAG_CLASS_APPLICATION | (6038 << 2)), 3, 0, 0 }, /* metriclist at 1230 */ { (ASN_TAG_CLASS_APPLICATION | (6039 << 2)), 4, 0, 0 } /* data at 1245 */ }; static asn_SEQUENCE_specifics_t asn_SPC_RealTimeSampleArrayMeasuredDataSection_specs_1 = { sizeof(struct RealTimeSampleArrayMeasuredDataSection), offsetof(struct RealTimeSampleArrayMeasuredDataSection, _asn_ctx), asn_MAP_RealTimeSampleArrayMeasuredDataSection_tag2el_1, 5, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_RealTimeSampleArrayMeasuredDataSection = { "RealTimeSampleArrayMeasuredDataSection", "RealTimeSampleArrayMeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1, sizeof(asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1) /sizeof(asn_DEF_RealTimeSampleArrayMeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_RealTimeSampleArrayMeasuredDataSection_1, 5, /* Elements count */ &asn_SPC_RealTimeSampleArrayMeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/OBJECT_IDENTIFIER.h0000664000175000017500000001136714105434233020331 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _OBJECT_IDENTIFIER_H_ #define _OBJECT_IDENTIFIER_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef ASN__PRIMITIVE_TYPE_t OBJECT_IDENTIFIER_t; extern asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER; asn_struct_print_f OBJECT_IDENTIFIER_print; asn_constr_check_f OBJECT_IDENTIFIER_constraint; der_type_encoder_f OBJECT_IDENTIFIER_encode_der; xer_type_decoder_f OBJECT_IDENTIFIER_decode_xer; xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer; /********************************** * Some handy conversion routines * **********************************/ /* * This function fills an (_arcs) array with OBJECT IDENTIFIER arcs * up to specified (_arc_slots) elements. * * EXAMPLE: * void print_arcs(OBJECT_IDENTIFIER_t *oid) { * unsigned long fixed_arcs[10]; // Try with fixed space first * unsigned long *arcs = fixed_arcs; * int arc_type_size = sizeof(fixed_arcs[0]); // sizeof(long) * int arc_slots = sizeof(fixed_arcs)/sizeof(fixed_arcs[0]); // 10 * int count; // Real number of arcs. * int i; * * count = OBJECT_IDENTIFIER_get_arcs(oid, arcs, * arc_type_size, arc_slots); * // If necessary, reallocate arcs array and try again. * if(count > arc_slots) { * arc_slots = count; * arcs = malloc(arc_type_size * arc_slots); * if(!arcs) return; * count = OBJECT_IDENTIFIER_get_arcs(oid, arcs, * arc_type_size, arc_slots); * assert(count == arc_slots); * } * * // Print the contents of the arcs array. * for(i = 0; i < count; i++) * printf("%d\n", arcs[i]); * * // Avoid memory leak. * if(arcs != fixed_arcs) free(arcs); * } * * RETURN VALUES: * -1/EINVAL: Invalid arguments (oid is missing) * -1/ERANGE: One or more arcs have value out of array cell type range. * >=0: Number of arcs contained in the OBJECT IDENTIFIER * * WARNING: The function always returns the real number of arcs, * even if there is no sufficient (_arc_slots) provided. */ int OBJECT_IDENTIFIER_get_arcs(OBJECT_IDENTIFIER_t *_oid, void *_arcs, /* e.g., unsigned int arcs[N] */ unsigned int _arc_type_size, /* e.g., sizeof(arcs[0]) */ unsigned int _arc_slots /* e.g., N */); /* * This functions initializes the OBJECT IDENTIFIER object with * the given set of arcs. * The minimum of two arcs must be present; some restrictions apply. * RETURN VALUES: * -1/EINVAL: Invalid arguments * -1/ERANGE: The first two arcs do not conform to ASN.1 restrictions. * -1/ENOMEM: Memory allocation failed * 0: The object was initialized with new arcs. */ int OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *_oid, const void *_arcs, /* e.g., unsigned int arcs[N] */ unsigned int _arc_type_size, /* e.g., sizeof(arcs[0]) */ unsigned int _arc_slots /* e.g., N */); /* * Print the specified OBJECT IDENTIFIER arc. */ int OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add, /* Arbitrary offset, required to process the first two arcs */ asn_app_consume_bytes_f *cb, void *app_key); /* Same as above, but returns the number of written digits, instead of 0 */ ssize_t OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add, asn_app_consume_bytes_f *cb, void *app_key); /* * Parse the OBJECT IDENTIFIER textual representation ("1.3.6.1.4.1.9363"). * No arc can exceed the (0..signed_long_max) range (typically, 0..2G if L32). * This function is not specific to OBJECT IDENTIFIER, it may be used to parse * the RELATIVE-OID data, or any other data consisting of dot-separated * series of numeric values. * * If (oid_txt_length == -1), the strlen() will be invoked to determine the * size of the (oid_text) string. * * After return, the optional (opt_oid_text_end) is set to the character after * the last parsed one. (opt_oid_text_end) is never less than (oid_text). * * RETURN VALUES: * -1: Parse error. * >= 0: Number of arcs contained in the OBJECT IDENTIFIER. * * WARNING: The function always returns the real number of arcs, * even if there is no sufficient (_arc_slots) provided. * This is useful for (_arc_slots) value estimation. */ int OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length, long arcs[], unsigned int arcs_slots, const char **opt_oid_text_end); /* * Internal functions. * Used by RELATIVE-OID implementation in particular. */ int OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed int add, void *value, unsigned int value_size); int OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, const void *arcval, unsigned int arcval_size, int _prepared_order); #ifdef __cplusplus } #endif #endif /* _OBJECT_IDENTIFIER_H_ */ biosig-2.3.3/biosig4c++/t240/REAL.h0000664000175000017500000000215114105434233016373 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_TYPE_REAL_H #define ASN_TYPE_REAL_H #include #include #ifdef __cplusplus extern "C" { #endif typedef ASN__PRIMITIVE_TYPE_t REAL_t; extern asn_TYPE_descriptor_t asn_DEF_REAL; asn_struct_print_f REAL_print; xer_type_decoder_f REAL_decode_xer; xer_type_encoder_f REAL_encode_xer; per_type_decoder_f REAL_decode_uper; per_type_encoder_f REAL_encode_uper; /*********************************** * Some handy conversion routines. * ***********************************/ ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key); /* * Convert between native double type and REAL representation (DER). * RETURN VALUES: * 0: Value converted successfully * -1: An error occured while converting the value: invalid format. */ int asn_REAL2double(const REAL_t *real_ptr, double *d); int asn_double2REAL(REAL_t *real_ptr, double d); #ifdef __cplusplus } #endif #endif /* ASN_TYPE_REAL_H */ biosig-2.3.3/biosig4c++/t240/HealthCareProviderId.c0000664000175000017500000001015314105434233021634 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "HealthCareProviderId.h" int HealthCareProviderId_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= 0 && value <= 65535)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using INT_U16, * so here we adjust the DEF accordingly. */ static void HealthCareProviderId_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INT_U16.free_struct; td->print_struct = asn_DEF_INT_U16.print_struct; td->ber_decoder = asn_DEF_INT_U16.ber_decoder; td->der_encoder = asn_DEF_INT_U16.der_encoder; td->xer_decoder = asn_DEF_INT_U16.xer_decoder; td->xer_encoder = asn_DEF_INT_U16.xer_encoder; td->uper_decoder = asn_DEF_INT_U16.uper_decoder; td->uper_encoder = asn_DEF_INT_U16.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INT_U16.per_constraints; td->elements = asn_DEF_INT_U16.elements; td->elements_count = asn_DEF_INT_U16.elements_count; td->specifics = asn_DEF_INT_U16.specifics; } void HealthCareProviderId_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int HealthCareProviderId_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t HealthCareProviderId_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t HealthCareProviderId_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t HealthCareProviderId_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t HealthCareProviderId_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { HealthCareProviderId_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_HealthCareProviderId_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_HealthCareProviderId = { "HealthCareProviderId", "HealthCareProviderId", HealthCareProviderId_free, HealthCareProviderId_print, HealthCareProviderId_constraint, HealthCareProviderId_decode_ber, HealthCareProviderId_encode_der, HealthCareProviderId_decode_xer, HealthCareProviderId_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_HealthCareProviderId_tags_1, sizeof(asn_DEF_HealthCareProviderId_tags_1) /sizeof(asn_DEF_HealthCareProviderId_tags_1[0]), /* 1 */ asn_DEF_HealthCareProviderId_tags_1, /* Same as above */ sizeof(asn_DEF_HealthCareProviderId_tags_1) /sizeof(asn_DEF_HealthCareProviderId_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/INT-I8.c0000664000175000017500000000737214105434233016565 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-I8.h" int INT_I8_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= -128 && value <= 127)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void INT_I8_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeInteger.free_struct; td->print_struct = asn_DEF_NativeInteger.print_struct; td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; td->der_encoder = asn_DEF_NativeInteger.der_encoder; td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeInteger.per_constraints; td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; } void INT_I8_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_I8_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_I8_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_I8_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_I8_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_I8_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_I8_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_I8_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_I8_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_I8_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_I8_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_I8_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_I8_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_I8 = { "INT-I8", "INT-I8", INT_I8_free, INT_I8_print, INT_I8_constraint, INT_I8_decode_ber, INT_I8_encode_der, INT_I8_decode_xer, INT_I8_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_I8_tags_1, sizeof(asn_DEF_INT_I8_tags_1) /sizeof(asn_DEF_INT_I8_tags_1[0]), /* 1 */ asn_DEF_INT_I8_tags_1, /* Same as above */ sizeof(asn_DEF_INT_I8_tags_1) /sizeof(asn_DEF_INT_I8_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/BITS-8.c0000664000175000017500000000751414105434233016561 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "BITS-8.h" int BITS_8_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; size_t size; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(st->size > 0) { /* Size in bits */ size = 8 * st->size - (st->bits_unused & 0x07); } else { size = 0; } if((size == 8)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void BITS_8_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void BITS_8_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { BITS_8_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int BITS_8_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { BITS_8_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t BITS_8_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { BITS_8_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t BITS_8_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { BITS_8_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t BITS_8_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { BITS_8_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t BITS_8_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { BITS_8_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_BITS_8_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_BITS_8 = { "BITS-8", "BITS-8", BITS_8_free, BITS_8_print, BITS_8_constraint, BITS_8_decode_ber, BITS_8_encode_der, BITS_8_decode_xer, BITS_8_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_BITS_8_tags_1, sizeof(asn_DEF_BITS_8_tags_1) /sizeof(asn_DEF_BITS_8_tags_1[0]), /* 1 */ asn_DEF_BITS_8_tags_1, /* Same as above */ sizeof(asn_DEF_BITS_8_tags_1) /sizeof(asn_DEF_BITS_8_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/INT-U16.h0000664000175000017500000000136114105434233016655 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_U16_H_ #define _INT_U16_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-U16 */ typedef long INT_U16_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_U16; asn_struct_free_f INT_U16_free; asn_struct_print_f INT_U16_print; asn_constr_check_f INT_U16_constraint; ber_type_decoder_f INT_U16_decode_ber; der_type_encoder_f INT_U16_encode_der; xer_type_decoder_f INT_U16_decode_xer; xer_type_encoder_f INT_U16_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_U16_H_ */ biosig-2.3.3/biosig4c++/t240/NumericDescriptiveDataSection.c0000664000175000017500000006245014105434233023576 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "NumericDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct NumericDescriptiveDataSection__vmosourcelist), offsetof(struct NumericDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct NumericDescriptiveDataSection__metricsourcelist), offsetof(struct NumericDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct NumericDescriptiveDataSection__msmtsitelist), offsetof(struct NumericDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct NumericDescriptiveDataSection__msmtsitelistext), offsetof(struct NumericDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct NumericDescriptiveDataSection__bodysitelist), offsetof(struct NumericDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct NumericDescriptiveDataSection__bodysitelistext), offsetof(struct NumericDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct NumericDescriptiveDataSection__metriccalibration), offsetof(struct NumericDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_NumericDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct NumericDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct NumericDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct NumericDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 29, offsetof(struct NumericDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 28, offsetof(struct NumericDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 27, offsetof(struct NumericDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 26, offsetof(struct NumericDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 25, offsetof(struct NumericDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 24, offsetof(struct NumericDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 23, offsetof(struct NumericDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 22, offsetof(struct NumericDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 21, offsetof(struct NumericDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 20, offsetof(struct NumericDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 19, offsetof(struct NumericDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 18, offsetof(struct NumericDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 17, offsetof(struct NumericDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 16, offsetof(struct NumericDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 15, offsetof(struct NumericDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 14, offsetof(struct NumericDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 13, offsetof(struct NumericDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 12, offsetof(struct NumericDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 11, offsetof(struct NumericDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 10, offsetof(struct NumericDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 9, offsetof(struct NumericDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 8, offsetof(struct NumericDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 7, offsetof(struct NumericDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 6, offsetof(struct NumericDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_POINTER, 5, offsetof(struct NumericDescriptiveDataSection, numeasurerange), (ASN_TAG_CLASS_APPLICATION | (2382 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numeasurerange" }, { ATF_POINTER, 4, offsetof(struct NumericDescriptiveDataSection, nuphysiologicalrange), (ASN_TAG_CLASS_APPLICATION | (2383 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nuphysiologicalrange" }, { ATF_POINTER, 3, offsetof(struct NumericDescriptiveDataSection, numeasureresolution), (ASN_TAG_CLASS_APPLICATION | (2381 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numeasureresolution" }, { ATF_POINTER, 2, offsetof(struct NumericDescriptiveDataSection, displayresolution), (ASN_TAG_CLASS_APPLICATION | (2327 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_DispResolution, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "displayresolution" }, { ATF_POINTER, 1, offsetof(struct NumericDescriptiveDataSection, accuracy), (ASN_TAG_CLASS_APPLICATION | (2378 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "accuracy" }, }; static ber_tlv_tag_t asn_DEF_NumericDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_NumericDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2327 << 2)), 30, 0, 0 }, /* displayresolution at 1153 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2378 << 2)), 31, 0, 0 }, /* accuracy at 1157 */ { (ASN_TAG_CLASS_APPLICATION | (2381 << 2)), 29, 0, 0 }, /* numeasureresolution at 1149 */ { (ASN_TAG_CLASS_APPLICATION | (2382 << 2)), 27, 0, 0 }, /* numeasurerange at 1142 */ { (ASN_TAG_CLASS_APPLICATION | (2383 << 2)), 28, 0, 0 }, /* nuphysiologicalrange at 1145 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_NumericDescriptiveDataSection_specs_1 = { sizeof(struct NumericDescriptiveDataSection), offsetof(struct NumericDescriptiveDataSection, _asn_ctx), asn_MAP_NumericDescriptiveDataSection_tag2el_1, 32, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_NumericDescriptiveDataSection = { "NumericDescriptiveDataSection", "NumericDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_NumericDescriptiveDataSection_tags_1, sizeof(asn_DEF_NumericDescriptiveDataSection_tags_1) /sizeof(asn_DEF_NumericDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_NumericDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_NumericDescriptiveDataSection_tags_1) /sizeof(asn_DEF_NumericDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_NumericDescriptiveDataSection_1, 32, /* Elements count */ &asn_SPC_NumericDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/EnumObject.c0000664000175000017500000000415414105434233017703 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "EnumObject.h" static asn_TYPE_member_t asn_MBR_EnumObject_1[] = { { ATF_NOFLAGS, 0, offsetof(struct EnumObject, enum_obj_id), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enum-obj-id" }, { ATF_POINTER, 1, offsetof(struct EnumObject, enumadditionaldata), (ASN_TAG_CLASS_APPLICATION | (2498 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumadditionaldata" }, }; static ber_tlv_tag_t asn_DEF_EnumObject_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_EnumObject_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* enum-obj-id at 1350 */ { (ASN_TAG_CLASS_APPLICATION | (2498 << 2)), 1, 0, 0 } /* enumadditionaldata at 1351 */ }; static asn_SEQUENCE_specifics_t asn_SPC_EnumObject_specs_1 = { sizeof(struct EnumObject), offsetof(struct EnumObject, _asn_ctx), asn_MAP_EnumObject_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_EnumObject = { "EnumObject", "EnumObject", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_EnumObject_tags_1, sizeof(asn_DEF_EnumObject_tags_1) /sizeof(asn_DEF_EnumObject_tags_1[0]), /* 1 */ asn_DEF_EnumObject_tags_1, /* Same as above */ sizeof(asn_DEF_EnumObject_tags_1) /sizeof(asn_DEF_EnumObject_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_EnumObject_1, 2, /* Elements count */ &asn_SPC_EnumObject_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/NativeInteger.c0000664000175000017500000002077614105434233020424 0ustar schloeglschloegl/*- * Copyright (c) 2004, 2005, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Read the NativeInteger.h for the explanation wrt. differences between * INTEGER and NativeInteger. * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this * implementation deals with the standard (machine-specific) representation * of them instead of using the platform-independent buffer. */ #include #include /* * NativeInteger basic type description. */ static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_NativeInteger = { "INTEGER", /* The ASN.1 type is still INTEGER */ "INTEGER", NativeInteger_free, NativeInteger_print, asn_generic_no_constraint, NativeInteger_decode_ber, NativeInteger_encode_der, NativeInteger_decode_xer, NativeInteger_encode_xer, NativeInteger_decode_uper, /* Unaligned PER decoder */ NativeInteger_encode_uper, /* Unaligned PER encoder */ 0, /* Use generic outmost tag fetcher */ asn_DEF_NativeInteger_tags, sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), asn_DEF_NativeInteger_tags, /* Same as above */ sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; /* * Decode INTEGER type. */ asn_dec_rval_t NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; long *native = (long *)*nint_ptr; asn_dec_rval_t rval; ber_tlv_len_t length; /* * If the structure is not there, allocate it. */ if(native == NULL) { native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native))); if(native == NULL) { rval.code = RC_FAIL; rval.consumed = 0; return rval; } } ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", td->name, tag_mode); /* * Check tags. */ rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0, &length, 0); if(rval.code != RC_OK) return rval; ASN_DEBUG("%s length is %d bytes", td->name, (int)length); /* * Make sure we have this length. */ buf_ptr = ((const char *)buf_ptr) + rval.consumed; size -= rval.consumed; if(length > (ber_tlv_len_t)size) { rval.code = RC_WMORE; rval.consumed = 0; return rval; } /* * ASN.1 encoded INTEGER: buf_ptr, length * Fill the native, at the same time checking for overflow. * If overflow occured, return with RC_FAIL. */ { INTEGER_t tmp; union { const void *constbuf; void *nonconstbuf; } unconst_buf; long l; unconst_buf.constbuf = buf_ptr; tmp.buf = (uint8_t *)unconst_buf.nonconstbuf; tmp.size = length; if((specs&&specs->field_unsigned) ? asn_INTEGER2ulong(&tmp, &l) : asn_INTEGER2long(&tmp, &l)) { rval.code = RC_FAIL; rval.consumed = 0; return rval; } *native = l; } rval.code = RC_OK; rval.consumed += length; ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)", (long)rval.consumed, (long)length, td->name, (long)*native); return rval; } /* * Encode the NativeInteger using the standard INTEGER type DER encoder. */ asn_enc_rval_t NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */ asn_enc_rval_t erval; INTEGER_t tmp; #ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ tmp.buf = (uint8_t *)&native; tmp.size = sizeof(native); #else /* Works even if WORDS_BIGENDIAN is not set where should've been */ uint8_t buf[sizeof(native)]; uint8_t *p; /* Prepare a fake INTEGER */ for(p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) *p = (uint8_t)native; tmp.buf = buf; tmp.size = sizeof(buf); #endif /* WORDS_BIGENDIAN */ /* Encode fake INTEGER */ erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); if(erval.encoded == -1) { assert(erval.structure_ptr == &tmp); erval.structure_ptr = ptr; } return erval; } /* * Decode the chunk of XML text encoding INTEGER. */ asn_dec_rval_t NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_dec_rval_t rval; INTEGER_t st; void *st_ptr = (void *)&st; long *native = (long *)*sptr; if(!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); if(!native) _ASN_DECODE_FAILED; } memset(&st, 0, sizeof(st)); rval = INTEGER_decode_xer(opt_codec_ctx, td, &st_ptr, opt_mname, buf_ptr, size); if(rval.code == RC_OK) { long l; if((specs&&specs->field_unsigned) ? asn_INTEGER2ulong(&st, &l) : asn_INTEGER2long(&st, &l)) { rval.code = RC_FAIL; rval.consumed = 0; } else { *native = l; } } else { /* * Cannot restart from the middle; * there is no place to save state in the native type. * Request a continuation from the very beginning. */ rval.consumed = 0; } ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st); return rval; } asn_enc_rval_t NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; char scratch[32]; /* Enough for 64-bit int */ asn_enc_rval_t er; const long *native = (const long *)sptr; (void)ilevel; (void)flags; if(!native) _ASN_ENCODE_FAILED; er.encoded = snprintf(scratch, sizeof(scratch), (specs && specs->field_unsigned) ? "%lu" : "%ld", *native); if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) || cb(scratch, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_dec_rval_t rval; long *native = (long *)*sptr; INTEGER_t tmpint; void *tmpintptr = &tmpint; (void)opt_codec_ctx; ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name); if(!native) { native = (long *)(*sptr = CALLOC(1, sizeof(*native))); if(!native) _ASN_DECODE_FAILED; } memset(&tmpint, 0, sizeof tmpint); rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints, &tmpintptr, pd); if(rval.code == RC_OK) { if((specs&&specs->field_unsigned) ? asn_INTEGER2ulong(&tmpint, native) : asn_INTEGER2long(&tmpint, native)) rval.code = RC_FAIL; else ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native); } ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); return rval; } asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; asn_enc_rval_t er; long native; INTEGER_t tmpint; if(!sptr) _ASN_ENCODE_FAILED; native = *(long *)sptr; ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native); memset(&tmpint, 0, sizeof(tmpint)); if((specs&&specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native) : asn_long2INTEGER(&tmpint, native)) _ASN_ENCODE_FAILED; er = INTEGER_encode_uper(td, constraints, &tmpint, po); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); return er; } /* * INTEGER specific human-readable output. */ int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; const long *native = (const long *)sptr; char scratch[32]; /* Enough for 64-bit int */ int ret; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(native) { ret = snprintf(scratch, sizeof(scratch), (specs && specs->field_unsigned) ? "%lu" : "%ld", *native); assert(ret > 0 && (size_t)ret < sizeof(scratch)); return (cb(scratch, ret, app_key) < 0) ? -1 : 0; } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { if(!td || !ptr) return; ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", td->name, contents_only, ptr); if(!contents_only) { FREEMEM(ptr); } } biosig-2.3.3/biosig4c++/t240/BITS-32.c0000664000175000017500000000755514105434233016643 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "BITS-32.h" int BITS_32_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; size_t size; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(st->size > 0) { /* Size in bits */ size = 8 * st->size - (st->bits_unused & 0x07); } else { size = 0; } if((size == 32)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void BITS_32_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void BITS_32_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { BITS_32_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int BITS_32_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { BITS_32_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t BITS_32_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { BITS_32_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t BITS_32_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { BITS_32_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t BITS_32_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { BITS_32_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t BITS_32_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { BITS_32_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_BITS_32_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_BITS_32 = { "BITS-32", "BITS-32", BITS_32_free, BITS_32_print, BITS_32_constraint, BITS_32_decode_ber, BITS_32_encode_der, BITS_32_decode_xer, BITS_32_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_BITS_32_tags_1, sizeof(asn_DEF_BITS_32_tags_1) /sizeof(asn_DEF_BITS_32_tags_1[0]), /* 1 */ asn_DEF_BITS_32_tags_1, /* Same as above */ sizeof(asn_DEF_BITS_32_tags_1) /sizeof(asn_DEF_BITS_32_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/CurLimAlStat.c0000664000175000017500000000726714105434233020164 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "CurLimAlStat.h" int CurLimAlStat_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void CurLimAlStat_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void CurLimAlStat_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { CurLimAlStat_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int CurLimAlStat_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { CurLimAlStat_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t CurLimAlStat_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { CurLimAlStat_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t CurLimAlStat_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { CurLimAlStat_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t CurLimAlStat_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { CurLimAlStat_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t CurLimAlStat_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { CurLimAlStat_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_CurLimAlStat_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_CurLimAlStat = { "CurLimAlStat", "CurLimAlStat", CurLimAlStat_free, CurLimAlStat_print, CurLimAlStat_constraint, CurLimAlStat_decode_ber, CurLimAlStat_encode_der, CurLimAlStat_decode_xer, CurLimAlStat_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_CurLimAlStat_tags_1, sizeof(asn_DEF_CurLimAlStat_tags_1) /sizeof(asn_DEF_CurLimAlStat_tags_1[0]), /* 1 */ asn_DEF_CurLimAlStat_tags_1, /* Same as above */ sizeof(asn_DEF_CurLimAlStat_tags_1) /sizeof(asn_DEF_CurLimAlStat_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/ChoiceOfNuObsValue.c0000664000175000017500000000725614105434233021301 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ChoiceOfNuObsValue.h" static asn_TYPE_member_t asn_MBR_compoundnuobservedvalue_3[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_NuObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_compoundnuobservedvalue_tags_3[] = { (ASN_TAG_CLASS_APPLICATION | (2379 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_compoundnuobservedvalue_specs_3 = { sizeof(struct ChoiceOfNuObsValue__compoundnuobservedvalue), offsetof(struct ChoiceOfNuObsValue__compoundnuobservedvalue, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_compoundnuobservedvalue_3 = { "compoundnuobservedvalue", "compoundnuobservedvalue", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_compoundnuobservedvalue_tags_3, sizeof(asn_DEF_compoundnuobservedvalue_tags_3) /sizeof(asn_DEF_compoundnuobservedvalue_tags_3[0]) - 1, /* 1 */ asn_DEF_compoundnuobservedvalue_tags_3, /* Same as above */ sizeof(asn_DEF_compoundnuobservedvalue_tags_3) /sizeof(asn_DEF_compoundnuobservedvalue_tags_3[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_compoundnuobservedvalue_3, 1, /* Single element */ &asn_SPC_compoundnuobservedvalue_specs_3 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ChoiceOfNuObsValue_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfNuObsValue, choice.nuobservedvalue), (ASN_TAG_CLASS_APPLICATION | (2384 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_NuObsValue, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "nuobservedvalue" }, { ATF_NOFLAGS, 0, offsetof(struct ChoiceOfNuObsValue, choice.compoundnuobservedvalue), (ASN_TAG_CLASS_APPLICATION | (2379 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_compoundnuobservedvalue_3, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compoundnuobservedvalue" }, }; static asn_TYPE_tag2member_t asn_MAP_ChoiceOfNuObsValue_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2379 << 2)), 1, 0, 0 }, /* compoundnuobservedvalue at 1297 */ { (ASN_TAG_CLASS_APPLICATION | (2384 << 2)), 0, 0, 0 } /* nuobservedvalue at 1289 */ }; static asn_CHOICE_specifics_t asn_SPC_ChoiceOfNuObsValue_specs_1 = { sizeof(struct ChoiceOfNuObsValue), offsetof(struct ChoiceOfNuObsValue, _asn_ctx), offsetof(struct ChoiceOfNuObsValue, present), sizeof(((struct ChoiceOfNuObsValue *)0)->present), asn_MAP_ChoiceOfNuObsValue_tag2el_1, 2, /* Count of tags in the map */ 0, -1 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ChoiceOfNuObsValue = { "ChoiceOfNuObsValue", "ChoiceOfNuObsValue", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ 0, /* No PER visible constraints */ asn_MBR_ChoiceOfNuObsValue_1, 2, /* Elements count */ &asn_SPC_ChoiceOfNuObsValue_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/TimeSampleArrayDescriptiveDataSection.c0000664000175000017500000010143314105434233025226 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "TimeSampleArrayDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__vmosourcelist), offsetof(struct TimeSampleArrayDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__metricsourcelist), offsetof(struct TimeSampleArrayDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__msmtsitelist), offsetof(struct TimeSampleArrayDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__msmtsitelistext), offsetof(struct TimeSampleArrayDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__bodysitelist), offsetof(struct TimeSampleArrayDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__bodysitelistext), offsetof(struct TimeSampleArrayDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__metriccalibration), offsetof(struct TimeSampleArrayDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_visualgrid_40[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaGridEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_visualgrid_tags_40[] = { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_visualgrid_specs_40 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__visualgrid), offsetof(struct TimeSampleArrayDescriptiveDataSection__visualgrid, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_visualgrid_40 = { "visualgrid", "visualgrid", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_visualgrid_tags_40, sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]) - 1, /* 1 */ asn_DEF_visualgrid_tags_40, /* Same as above */ sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_visualgrid_40, 1, /* Single element */ &asn_SPC_visualgrid_specs_40 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_sacalibrationdata_42[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaCalData, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_sacalibrationdata_tags_42[] = { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_sacalibrationdata_specs_42 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__sacalibrationdata), offsetof(struct TimeSampleArrayDescriptiveDataSection__sacalibrationdata, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_sacalibrationdata_42 = { "sacalibrationdata", "sacalibrationdata", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_sacalibrationdata_tags_42, sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]) - 1, /* 1 */ asn_DEF_sacalibrationdata_tags_42, /* Same as above */ sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_sacalibrationdata_42, 1, /* Single element */ &asn_SPC_sacalibrationdata_specs_42 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_filterspecification_44[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaFilterEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_filterspecification_tags_44[] = { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_filterspecification_specs_44 = { sizeof(struct TimeSampleArrayDescriptiveDataSection__filterspecification), offsetof(struct TimeSampleArrayDescriptiveDataSection__filterspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_filterspecification_44 = { "filterspecification", "filterspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_filterspecification_tags_44, sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]) - 1, /* 1 */ asn_DEF_filterspecification_tags_44, /* Same as above */ sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_filterspecification_44, 1, /* Single element */ &asn_SPC_filterspecification_specs_44 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_TimeSampleArrayDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 24, offsetof(struct TimeSampleArrayDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 23, offsetof(struct TimeSampleArrayDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 22, offsetof(struct TimeSampleArrayDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 21, offsetof(struct TimeSampleArrayDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 20, offsetof(struct TimeSampleArrayDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 19, offsetof(struct TimeSampleArrayDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 18, offsetof(struct TimeSampleArrayDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 17, offsetof(struct TimeSampleArrayDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 16, offsetof(struct TimeSampleArrayDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 15, offsetof(struct TimeSampleArrayDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 14, offsetof(struct TimeSampleArrayDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 13, offsetof(struct TimeSampleArrayDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 12, offsetof(struct TimeSampleArrayDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 11, offsetof(struct TimeSampleArrayDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 10, offsetof(struct TimeSampleArrayDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 9, offsetof(struct TimeSampleArrayDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 8, offsetof(struct TimeSampleArrayDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 7, offsetof(struct TimeSampleArrayDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 6, offsetof(struct TimeSampleArrayDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 5, offsetof(struct TimeSampleArrayDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 4, offsetof(struct TimeSampleArrayDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 3, offsetof(struct TimeSampleArrayDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 2, offsetof(struct TimeSampleArrayDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 1, offsetof(struct TimeSampleArrayDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, saspecification), (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saspecification" }, { ATF_POINTER, 1, offsetof(struct TimeSampleArrayDescriptiveDataSection, compression), (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compression" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, scaleandrangespec), (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ScaleRangeSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "scaleandrangespec" }, { ATF_POINTER, 6, offsetof(struct TimeSampleArrayDescriptiveDataSection, saphysiologicalrange), (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saphysiologicalrange" }, { ATF_POINTER, 5, offsetof(struct TimeSampleArrayDescriptiveDataSection, visualgrid), (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_visualgrid_40, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "visualgrid" }, { ATF_POINTER, 4, offsetof(struct TimeSampleArrayDescriptiveDataSection, sacalibrationdata), (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_sacalibrationdata_42, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sacalibrationdata" }, { ATF_POINTER, 3, offsetof(struct TimeSampleArrayDescriptiveDataSection, filterspecification), (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_filterspecification_44, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filterspecification" }, { ATF_POINTER, 2, offsetof(struct TimeSampleArrayDescriptiveDataSection, sasignalfrequency), (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSignalFrequency, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sasignalfrequency" }, { ATF_POINTER, 1, offsetof(struct TimeSampleArrayDescriptiveDataSection, sameasureresolution), (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sameasureresolution" }, { ATF_NOFLAGS, 0, offsetof(struct TimeSampleArrayDescriptiveDataSection, sampleperiod), (ASN_TAG_CLASS_APPLICATION | (2445 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sampleperiod" }, { ATF_POINTER, 1, offsetof(struct TimeSampleArrayDescriptiveDataSection, sweepspeed), (ASN_TAG_CLASS_APPLICATION | (2431 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sweepspeed" }, }; static ber_tlv_tag_t asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_TimeSampleArrayDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), 28, 0, 0 }, /* compression at 962 */ { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), 33, 0, 0 }, /* filterspecification at 983 */ { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), 31, 0, 0 }, /* visualgrid at 973 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), 32, 0, 0 }, /* sacalibrationdata at 978 */ { (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), 34, 0, 0 }, /* sasignalfrequency at 986 */ { (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), 35, 0, 0 }, /* sameasureresolution at 989 */ { (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), 30, 0, 0 }, /* saphysiologicalrange at 969 */ { (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), 27, 0, 0 }, /* saspecification at 959 */ { (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), 29, 0, 0 }, /* scaleandrangespec at 965 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2431 << 2)), 37, 0, 0 }, /* sweepspeed at 1109 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2445 << 2)), 36, 0, 0 }, /* sampleperiod at 1106 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_TimeSampleArrayDescriptiveDataSection_specs_1 = { sizeof(struct TimeSampleArrayDescriptiveDataSection), offsetof(struct TimeSampleArrayDescriptiveDataSection, _asn_ctx), asn_MAP_TimeSampleArrayDescriptiveDataSection_tag2el_1, 38, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_TimeSampleArrayDescriptiveDataSection = { "TimeSampleArrayDescriptiveDataSection", "TimeSampleArrayDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1, sizeof(asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_TimeSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_TimeSampleArrayDescriptiveDataSection_1, 38, /* Elements count */ &asn_SPC_TimeSampleArrayDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/constr_SEQUENCE.c0000664000175000017500000010723614105434233020455 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Number of bytes left for this structure. * (ctx->left) indicates the number of bytes _transferred_ for the structure. * (size) contains the number of bytes in the buffer passed. */ #define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) /* * If the subprocessor function returns with an indication that it wants * more data, it may well be a fatal decoding problem, because the * size is constrained by the 's L, even if the buffer size allows * reading more data. * For example, consider the buffer containing the following TLVs: * ... * The TLV length clearly indicates that one byte is expected in V, but * if the V processor returns with "want more data" even if the buffer * contains way more data than the V processor have seen. */ #define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) /* * This macro "eats" the part of the buffer which is definitely "consumed", * i.e. was correctly converted into local representation or rightfully skipped. */ #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ ptr = ((const char *)ptr) + num;\ size -= num; \ if(ctx->left >= 0) \ ctx->left -= num; \ consumed_myself += num; \ } while(0) /* * Switch to the next phase of parsing. */ #undef NEXT_PHASE #undef PHASE_OUT #define NEXT_PHASE(ctx) do { \ ctx->phase++; \ ctx->step = 0; \ } while(0) #define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) /* * Return a standardized complex structure. */ #undef RETURN #define RETURN(_code) do { \ rval.code = _code; \ rval.consumed = consumed_myself;\ return rval; \ } while(0) /* * Check whether we are inside the extensions group. */ #define IN_EXTENSION_GROUP(specs, memb_idx) \ ( ((memb_idx) > (specs)->ext_after) \ &&((memb_idx) < (specs)->ext_before)) /* * Tags are canonically sorted in the tag2element map. */ static int _t2e_cmp(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; int a_class = BER_TAG_CLASS(a->el_tag); int b_class = BER_TAG_CLASS(b->el_tag); if(a_class == b_class) { ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag); ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); if(a_value == b_value) { if(a->el_no > b->el_no) return 1; /* * Important: we do not check * for a->el_no <= b->el_no! */ return 0; } else if(a_value < b_value) return -1; else return 1; } else if(a_class < b_class) { return -1; } else { return 1; } } /* * The decoder of the SEQUENCE type. */ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *ptr, size_t size, int tag_mode) { /* * Bring closer parts of structure description. */ asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; asn_TYPE_member_t *elements = td->elements; /* * Parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ ber_tlv_tag_t tlv_tag; /* T from TLV */ asn_dec_rval_t rval; /* Return code from subparsers */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* SEQUENCE element's index */ ASN_DEBUG("Decoding %s as SEQUENCE", td->name); /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) { RETURN(RC_FAIL); } } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Start to parse where left previously */ switch(ctx->phase) { case 0: /* * PHASE 0. * Check that the set of tags associated with given structure * perfectly fits our expectations. */ rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, 1, &ctx->left, 0); if(rval.code != RC_OK) { ASN_DEBUG("%s tagging check failed: %d", td->name, rval.code); return rval; } if(ctx->left >= 0) ctx->left += rval.consumed; /* ?Substracted below! */ ADVANCE(rval.consumed); NEXT_PHASE(ctx); ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", (long)ctx->left, (long)size); /* Fall through */ case 1: /* * PHASE 1. * From the place where we've left it previously, * try to decode the next member from the list of * this structure's elements. * (ctx->step) stores the member being processed * between invocations and the microphase {0,1} of parsing * that member: * step = ( * 2 + ). */ for(edx = (ctx->step >> 1); edx < td->elements_count; edx++, ctx->step = (ctx->step & ~1) + 2) { void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ ssize_t tag_len; /* Length of TLV's T */ int opt_edx_end; /* Next non-optional element */ int use_bsearch; int n; if(ctx->step & 1) goto microphase2; /* * MICROPHASE 1: Synchronize decoding. */ ASN_DEBUG("In %s SEQUENCE left %d, edx=%d flags=%d" " opt=%d ec=%d", td->name, (int)ctx->left, edx, elements[edx].flags, elements[edx].optional, td->elements_count); if(ctx->left == 0 /* No more stuff is expected */ && ( /* Explicit OPTIONAL specification reaches the end */ (edx + elements[edx].optional == td->elements_count) || /* All extensions are optional */ (IN_EXTENSION_GROUP(specs, edx) && specs->ext_before > td->elements_count) ) ) { ASN_DEBUG("End of SEQUENCE %s", td->name); /* * Found the legitimate end of the structure. */ PHASE_OUT(ctx); RETURN(RC_OK); } /* * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); ASN_DEBUG("Current tag in %s SEQUENCE for element %d " "(%s) is %s encoded in %d bytes, of frame %ld", td->name, edx, elements[edx].name, ber_tlv_tag_string(tlv_tag), (int)tag_len, (long)LEFT); switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { ASN_DEBUG("edx = %d, opt = %d, ec=%d", edx, elements[edx].optional, td->elements_count); if((edx + elements[edx].optional == td->elements_count) || (IN_EXTENSION_GROUP(specs, edx) && specs->ext_before > td->elements_count)) { /* * Yeah, baby! Found the terminator * of the indefinite length structure. */ /* * Proceed to the canonical * finalization function. * No advancing is necessary. */ goto phase3; } } } /* * Find the next available type with this tag. */ use_bsearch = 0; opt_edx_end = edx + elements[edx].optional + 1; if(opt_edx_end > td->elements_count) opt_edx_end = td->elements_count; /* Cap */ else if(opt_edx_end - edx > 8) { /* Limit the scope of linear search... */ opt_edx_end = edx + 8; use_bsearch = 1; /* ... and resort to bsearch() */ } for(n = edx; n < opt_edx_end; n++) { if(BER_TAGS_EQUAL(tlv_tag, elements[n].tag)) { /* * Found element corresponding to the tag * being looked at. * Reposition over the right element. */ edx = n; ctx->step = 1 + 2 * edx; /* Remember! */ goto microphase2; } else if(elements[n].flags & ATF_OPEN_TYPE) { /* * This is the ANY type, which may bear * any flag whatsoever. */ edx = n; ctx->step = 1 + 2 * edx; /* Remember! */ goto microphase2; } else if(elements[n].tag == (ber_tlv_tag_t)-1) { use_bsearch = 1; break; } } if(use_bsearch) { /* * Resort to a binary search over * sorted array of tags. */ asn_TYPE_tag2member_t *t2m; asn_TYPE_tag2member_t key; key.el_tag = tlv_tag; key.el_no = edx; t2m = (asn_TYPE_tag2member_t *)bsearch(&key, specs->tag2el, specs->tag2el_count, sizeof(specs->tag2el[0]), _t2e_cmp); if(t2m) { asn_TYPE_tag2member_t *best = 0; asn_TYPE_tag2member_t *t2m_f, *t2m_l; int edx_max = edx + elements[edx].optional; /* * Rewind to the first element with that tag, * `cause bsearch() does not guarantee order. */ t2m_f = t2m + t2m->toff_first; t2m_l = t2m + t2m->toff_last; for(t2m = t2m_f; t2m <= t2m_l; t2m++) { if(t2m->el_no > edx_max) break; if(t2m->el_no < edx) continue; best = t2m; } if(best) { edx = best->el_no; ctx->step = 1 + 2 * edx; goto microphase2; } } n = opt_edx_end; } if(n == opt_edx_end) { /* * If tag is unknown, it may be either * an unknown (thus, incorrect) tag, * or an extension (...), * or an end of the indefinite-length structure. */ if(!IN_EXTENSION_GROUP(specs, edx + elements[edx].optional)) { ASN_DEBUG("Unexpected tag %s (at %d)", ber_tlv_tag_string(tlv_tag), edx); ASN_DEBUG("Expected tag %s (%s)%s", ber_tlv_tag_string(elements[edx].tag), elements[edx].name, elements[edx].optional ?" or alternatives":""); RETURN(RC_FAIL); } else { /* Skip this tag */ ssize_t skip; edx += elements[edx].optional; ASN_DEBUG("Skipping unexpected %s (at %d)", ber_tlv_tag_string(tlv_tag), edx); skip = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tag_len, LEFT - tag_len); ASN_DEBUG("Skip length %d in %s", (int)skip, td->name); switch(skip) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } ADVANCE(skip + tag_len); ctx->step -= 2; edx--; continue; /* Try again with the next tag */ } } /* * MICROPHASE 2: Invoke the member-specific decoder. */ ctx->step |= 1; /* Confirm entering next microphase */ microphase2: ASN_DEBUG("Inside SEQUENCE %s MF2", td->name); /* * Compute the position of the member inside a structure, * and also a type of containment (it may be contained * as pointer or using inline inclusion). */ if(elements[edx].flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset); } else { /* * A pointer to a pointer * holding the start of the structure */ memb_ptr = (char *)st + elements[edx].memb_offset; memb_ptr2 = &memb_ptr; } /* * Invoke the member fetch routine according to member's type */ rval = elements[edx].type->ber_decoder(opt_codec_ctx, elements[edx].type, memb_ptr2, ptr, LEFT, elements[edx].tag_mode); ASN_DEBUG("In %s SEQUENCE decoded %d %s of %d " "in %d bytes rval.code %d, size=%d", td->name, edx, elements[edx].type->name, (int)LEFT, (int)rval.consumed, rval.code, (int)size); switch(rval.code) { case RC_OK: break; case RC_WMORE: /* More data expected */ if(!SIZE_VIOLATION) { ADVANCE(rval.consumed); RETURN(RC_WMORE); } ASN_DEBUG("Size violation (c->l=%ld <= s=%ld)", (long)ctx->left, (long)size); /* Fall through */ case RC_FAIL: /* Fatal error */ RETURN(RC_FAIL); } /* switch(rval) */ ADVANCE(rval.consumed); } /* for(all structure members) */ phase3: ctx->phase = 3; case 3: /* 00 and other tags expected */ case 4: /* only 00's expected */ ASN_DEBUG("SEQUENCE %s Leftover: %ld, size = %ld", td->name, (long)ctx->left, (long)size); /* * Skip everything until the end of the SEQUENCE. */ while(ctx->left) { ssize_t tl, ll; tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); switch(tl) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } /* * If expected <0><0>... */ if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { /* * Correctly finished with <0><0>. */ ADVANCE(2); ctx->left++; ctx->phase = 4; continue; } } if(!IN_EXTENSION_GROUP(specs, td->elements_count) || ctx->phase == 4) { ASN_DEBUG("Unexpected continuation " "of a non-extensible type " "%s (SEQUENCE): %s", td->name, ber_tlv_tag_string(tlv_tag)); RETURN(RC_FAIL); } ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tl, LEFT - tl); switch(ll) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } ADVANCE(tl + ll); } PHASE_OUT(ctx); } RETURN(RC_OK); } /* * The DER encoder of the SEQUENCE type. */ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { size_t computed_size = 0; asn_enc_rval_t erval; ssize_t ret; int edx; ASN_DEBUG("%s %s as SEQUENCE", cb?"Encoding":"Estimating", td->name); /* * Gather the length of the underlying members sequence. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(erval.encoded == -1) return erval; computed_size += erval.encoded; ASN_DEBUG("Member %d %s estimated %ld bytes", edx, elm->name, (long)erval.encoded); } /* * Encode the TLV for the sequence itself. */ ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key); ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size); if(ret == -1) _ASN_ENCODE_FAILED; erval.encoded = computed_size + ret; if(!cb) _ASN_ENCODED_OK(erval); /* * Encode all members. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; asn_enc_rval_t tmperval; void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) continue; } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } tmperval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(tmperval.encoded == -1) return tmperval; computed_size -= tmperval.encoded; ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %ld bytes", edx, elm->name, td->name, (long)tmperval.encoded); } if(computed_size != 0) /* * Encoded size is not equal to the computed size. */ _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(erval); } #undef XER_ADVANCE #define XER_ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ buf_ptr = ((const char *)buf_ptr) + num;\ size -= num; \ consumed_myself += num; \ } while(0) /* * Decode the XER (XML) data. */ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const char *opt_mname, const void *buf_ptr, size_t size) { /* * Bring closer parts of structure description. */ asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; asn_TYPE_member_t *elements = td->elements; const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; /* * ... and parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ asn_dec_rval_t rval; /* Return value from a decoder */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* Element index */ int edx_end; /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) RETURN(RC_FAIL); } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Phases of XER/XML processing: * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. * Phase 2: Processing inner type. * Phase 3: Skipping unknown extensions. * Phase 4: PHASED OUT */ for(edx = ctx->step; ctx->phase <= 3;) { pxer_chunk_type_e ch_type; /* XER chunk type */ ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ asn_TYPE_member_t *elm; int n; /* * Go inside the inner member of a sequence. */ if(ctx->phase == 2) { asn_dec_rval_t tmprval; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ elm = &td->elements[edx]; if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } /* Invoke the inner type decoder, m.b. multiple times */ tmprval = elm->type->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); if(tmprval.code != RC_OK) RETURN(tmprval.code); ctx->phase = 1; /* Back to body processing */ ctx->step = ++edx; ASN_DEBUG("XER/SEQUENCE phase => %d, step => %d", ctx->phase, ctx->step); /* Fall through */ } /* * Get the next part of the XML stream. */ ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type); switch(ch_size) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); default: switch(ch_type) { case PXER_COMMENT: /* Got XML comment */ case PXER_TEXT: /* Ignore free-standing text */ XER_ADVANCE(ch_size); /* Skip silently */ continue; case PXER_TAG: break; /* Check the rest down there */ } } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); ASN_DEBUG("XER/SEQUENCE: tcv = %d, ph=%d [%s]", tcv, ctx->phase, xml_tag); /* Skip the extensions section */ if(ctx->phase == 3) { switch(xer_skip_unknown(tcv, &ctx->left)) { case -1: ctx->phase = 4; RETURN(RC_FAIL); case 0: XER_ADVANCE(ch_size); continue; case 1: XER_ADVANCE(ch_size); ctx->phase = 1; continue; case 2: ctx->phase = 1; break; } } switch(tcv) { case XCT_CLOSING: if(ctx->phase == 0) break; ctx->phase = 0; /* Fall through */ case XCT_BOTH: if(ctx->phase == 0) { if(edx >= td->elements_count || /* Explicit OPTIONAL specs reaches the end */ (edx + elements[edx].optional == td->elements_count) || /* All extensions are optional */ (IN_EXTENSION_GROUP(specs, edx) && specs->ext_before > td->elements_count) ) { XER_ADVANCE(ch_size); ctx->phase = 4; /* Phase out */ RETURN(RC_OK); } else { ASN_DEBUG("Premature end of XER SEQUENCE"); RETURN(RC_FAIL); } } /* Fall through */ case XCT_OPENING: if(ctx->phase == 0) { XER_ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; } /* Fall through */ case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d, edx=%d", tcv, ctx->phase, edx); if(ctx->phase != 1) { break; /* Really unexpected */ } if(edx < td->elements_count) { /* * Search which member corresponds to this tag. */ edx_end = edx + elements[edx].optional + 1; if(edx_end > td->elements_count) edx_end = td->elements_count; for(n = edx; n < edx_end; n++) { elm = &td->elements[n]; tcv = xer_check_tag(buf_ptr, ch_size, elm->name); switch(tcv) { case XCT_BOTH: case XCT_OPENING: /* * Process this member. */ ctx->step = edx = n; ctx->phase = 2; break; case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: continue; default: n = edx_end; break; /* Phase out */ } break; } if(n != edx_end) continue; } else { ASN_DEBUG("Out of defined members: %d/%d", edx, td->elements_count); } /* It is expected extension */ if(IN_EXTENSION_GROUP(specs, edx + (edx < td->elements_count ? elements[edx].optional : 0))) { ASN_DEBUG("Got anticipated extension at %d", edx); /* * Check for (XCT_BOTH or XCT_UNKNOWN_BO) * By using a mask. Only record a pure * tags. */ if(tcv & XCT_CLOSING) { /* Found without body */ } else { ctx->left = 1; ctx->phase = 3; /* Skip ...'s */ } XER_ADVANCE(ch_size); continue; } /* Fall through */ default: break; } ASN_DEBUG("Unexpected XML tag in SEQUENCE [%c%c%c%c%c%c]", size>0?((const char *)buf_ptr)[0]:'.', size>1?((const char *)buf_ptr)[1]:'.', size>2?((const char *)buf_ptr)[2]:'.', size>3?((const char *)buf_ptr)[3]:'.', size>4?((const char *)buf_ptr)[4]:'.', size>5?((const char *)buf_ptr)[5]:'.'); break; } ctx->phase = 4; /* "Phase out" on hard failure */ RETURN(RC_FAIL); } asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er; int xcan = (flags & XER_F_CANONICAL); int edx; if(!sptr) _ASN_ENCODE_FAILED; er.encoded = 0; for(edx = 0; edx < td->elements_count; edx++) { asn_enc_rval_t tmper; asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; const char *mname = elm->name; unsigned int mlen = strlen(mname); if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { int edx; int ret; if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; /* Dump preamble */ if(cb(td->name, strlen(td->name), app_key) < 0 || cb(" ::= {", 6, app_key) < 0) return -1; for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; /* Print line */ /* Fall through */ } } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } /* Indentation */ _i_INDENT(1); /* Print the member's name and stuff */ if(cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) return -1; /* Print the member itself */ ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } ilevel--; _i_INDENT(1); return (cb("}", 1, app_key) < 0) ? -1 : 0; } void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { int edx; if(!td || !sptr) return; ASN_DEBUG("Freeing %s as SEQUENCE", td->name); for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr); } } if(!contents_only) { FREEMEM(sptr); } } int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { int edx; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } /* * Iterate over structure members and check their validity. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) continue; _ASN_CTFAIL(app_key, td, sptr, "%s: mandatory element %s absent (%s:%d)", td->name, elm->name, __FILE__, __LINE__); return -1; } } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } if(elm->memb_constraints) { int ret = elm->memb_constraints(elm->type, memb_ptr, ctfailcb, app_key); if(ret) return ret; } else { int ret = elm->type->check_constraints(elm->type, memb_ptr, ctfailcb, app_key); if(ret) return ret; /* * Cannot inherit it earlier: * need to make sure we get the updated version. */ elm->memb_constraints = elm->type->check_constraints; } } return 0; } asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; void *st = *sptr; /* Target structure. */ int extpresent; /* Extension additions are present */ uint8_t *opres; /* Presence of optional root members */ asn_per_data_t opmd; asn_dec_rval_t rv; int edx; (void)constraints; if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; if(!st) { st = *sptr = CALLOC(1, specs->struct_size); if(!st) _ASN_DECODE_FAILED; } ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name); /* Handle extensions */ if(specs->ext_before >= 0) { extpresent = per_get_few_bits(pd, 1); if(extpresent < 0) _ASN_DECODE_STARVED; } else { extpresent = 0; } /* Prepare a place and read-in the presence bitmap */ memset(&opmd, 0, sizeof(opmd)); if(specs->roms_count) { opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1); if(!opres) _ASN_DECODE_FAILED; /* Get the presence map */ if(per_get_many_bits(pd, opres, 0, specs->roms_count)) { FREEMEM(opres); _ASN_DECODE_STARVED; } opmd.buffer = opres; opmd.nbits = specs->roms_count; ASN_DEBUG("Read in presence bitmap for %s of %d bits (%x..)", td->name, specs->roms_count, *opres); } else { opres = 0; } /* * Get the sequence ROOT elements. */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ if(IN_EXTENSION_GROUP(specs, edx)) continue; /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } /* Deal with optionality */ if(elm->optional) { int present = per_get_few_bits(&opmd, 1); ASN_DEBUG("Member %s->%s is optional, p=%d (%d->%d)", td->name, elm->name, present, (int)opmd.nboff, (int)opmd.nbits); if(present == 0) { /* This element is not present */ if(elm->default_value) { /* Fill-in DEFAULT */ if(elm->default_value(1, memb_ptr2)) { FREEMEM(opres); _ASN_DECODE_FAILED; } ASN_DEBUG("Filled-in default"); } /* The member is just not present */ continue; } /* Fall through */ } /* Fetch the member from the stream */ ASN_DEBUG("Decoding member %s in %s", elm->name, td->name); rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); if(rv.code != RC_OK) { ASN_DEBUG("Failed decode %s in %s", elm->name, td->name); FREEMEM(opres); return rv; } } /* Optionality map is not needed anymore */ FREEMEM(opres); /* * Deal with extensions. */ if(extpresent) { ssize_t bmlength; uint8_t *epres; /* Presence of extension members */ asn_per_data_t epmd; bmlength = uper_get_nslength(pd); if(bmlength < 0) _ASN_DECODE_STARVED; ASN_DEBUG("Extensions %d present in %s", bmlength, td->name); epres = (uint8_t *)MALLOC((bmlength + 15) >> 3); if(!epres) _ASN_DECODE_STARVED; /* Get the extensions map */ if(per_get_many_bits(pd, epres, 0, bmlength)) _ASN_DECODE_STARVED; memset(&epmd, 0, sizeof(epmd)); epmd.buffer = epres; epmd.nbits = bmlength; ASN_DEBUG("Read in extensions bitmap for %s of %d bits (%x..)", td->name, bmlength, *epres); /* Go over extensions and read them in */ for(edx = specs->ext_after + 1; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ int present; if(!IN_EXTENSION_GROUP(specs, edx)) { ASN_DEBUG("%d is not extension", edx); continue; } /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (void *)((char *)st + elm->memb_offset); memb_ptr2 = &memb_ptr; } present = per_get_few_bits(&epmd, 1); if(present <= 0) { if(present < 0) break; /* No more extensions */ continue; } ASN_DEBUG("Decoding member %s in %s %p", elm->name, td->name, *memb_ptr2); rv = uper_open_type_get(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); if(rv.code != RC_OK) { FREEMEM(epres); return rv; } } /* Skip over overflow extensions which aren't present * in this system's version of the protocol */ for(;;) { ASN_DEBUG("Getting overflow extensions"); switch(per_get_few_bits(&epmd, 1)) { case -1: break; case 0: continue; default: if(uper_open_type_skip(opt_codec_ctx, pd)) { FREEMEM(epres); _ASN_DECODE_STARVED; } } break; } FREEMEM(epres); } /* Fill DEFAULT members in extensions */ for(edx = specs->roms_count; edx < specs->roms_count + specs->aoms_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void **memb_ptr2; /* Pointer to member pointer */ if(!elm->default_value) continue; /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)st + elm->memb_offset); if(*memb_ptr2) continue; } else { continue; /* Extensions are all optionals */ } /* Set default value */ if(elm->default_value(1, memb_ptr2)) { _ASN_DECODE_FAILED; } } rv.consumed = 0; rv.code = RC_OK; return rv; } static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr, asn_per_outp_t *po1, asn_per_outp_t *po2) { asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; int exts_present = 0; int exts_count = 0; int edx; if(specs->ext_before < 0) return 0; /* Find out which extensions are present */ for(edx = specs->ext_after + 1; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ int present; if(!IN_EXTENSION_GROUP(specs, edx)) { ASN_DEBUG("%s (@%d) is not extension", elm->type->name, edx); continue; } /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)sptr + elm->memb_offset); present = (*memb_ptr2 != 0); } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); memb_ptr2 = &memb_ptr; present = 1; } ASN_DEBUG("checking %s (@%d) present => %d", elm->type->name, edx, present); exts_count++; exts_present += present; /* Encode as presence marker */ if(po1 && per_put_few_bits(po1, present, 1)) return -1; /* Encode as open type field */ if(po2 && present && uper_open_type_put(elm->type, elm->per_constraints, *memb_ptr2, po2)) return -1; } return exts_present ? exts_count : 0; } asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; asn_enc_rval_t er; int n_extensions; int edx; int i; (void)constraints; if(!sptr) _ASN_ENCODE_FAILED; er.encoded = 0; ASN_DEBUG("Encoding %s as SEQUENCE (UPER)", td->name); /* * X.691#18.1 Whether structure is extensible * and whether to encode extensions */ if(specs->ext_before >= 0) { n_extensions = SEQUENCE_handle_extensions(td, sptr, 0, 0); per_put_few_bits(po, n_extensions ? 1 : 0, 1); } else { n_extensions = 0; /* There are no extensions to encode */ } /* Encode a presence bitmap */ for(i = 0; i < specs->roms_count; i++) { asn_TYPE_member_t *elm; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ int present; edx = specs->oms[i]; elm = &td->elements[edx]; /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)sptr + elm->memb_offset); present = (*memb_ptr2 != 0); } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); memb_ptr2 = &memb_ptr; present = 1; } /* Eliminate default values */ if(present && elm->default_value && elm->default_value(0, memb_ptr2) == 1) present = 0; ASN_DEBUG("Element %s %s %s->%s is %s", elm->flags & ATF_POINTER ? "ptr" : "inline", elm->default_value ? "def" : "wtv", td->name, elm->name, present ? "present" : "absent"); if(per_put_few_bits(po, present, 1)) _ASN_ENCODE_FAILED; } /* * Encode the sequence ROOT elements. */ ASN_DEBUG("ext_after = %d, ec = %d, eb = %d", specs->ext_after, td->elements_count, specs->ext_before); for(edx = 0; edx < ((specs->ext_after < 0) ? td->elements_count : specs->ext_before - 1); edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ if(IN_EXTENSION_GROUP(specs, edx)) continue; ASN_DEBUG("About to encode %s", elm->type->name); /* Fetch the pointer to this member */ if(elm->flags & ATF_POINTER) { memb_ptr2 = (void **)((char *)sptr + elm->memb_offset); if(!*memb_ptr2) { ASN_DEBUG("Element %s %d not present", elm->name, edx); if(elm->optional) continue; /* Mandatory element is missing */ _ASN_ENCODE_FAILED; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); memb_ptr2 = &memb_ptr; } /* Eliminate default values */ if(elm->default_value && elm->default_value(0, memb_ptr2) == 1) continue; ASN_DEBUG("Encoding %s->%s", td->name, elm->name); er = elm->type->uper_encoder(elm->type, elm->per_constraints, *memb_ptr2, po); if(er.encoded == -1) return er; } /* No extensions to encode */ if(!n_extensions) _ASN_ENCODED_OK(er); ASN_DEBUG("Length of %d bit-map", n_extensions); /* #18.8. Write down the presence bit-map length. */ if(uper_put_nslength(po, n_extensions)) _ASN_ENCODE_FAILED; ASN_DEBUG("Bit-map of %d elements", n_extensions); /* #18.7. Encoding the extensions presence bit-map. */ /* TODO: act upon NOTE in #18.7 for canonical PER */ if(SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions) _ASN_ENCODE_FAILED; ASN_DEBUG("Writing %d extensions", n_extensions); /* #18.9. Encode extensions as open type fields. */ if(SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } biosig-2.3.3/biosig4c++/t240/ExtNomenclatureCode.h0000664000175000017500000000161414105434233021563 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ExtNomenclatureCode_H_ #define _ExtNomenclatureCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* ExtNomenclatureCode */ typedef INTEGER_t ExtNomenclatureCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ExtNomenclatureCode; asn_struct_free_f ExtNomenclatureCode_free; asn_struct_print_f ExtNomenclatureCode_print; asn_constr_check_f ExtNomenclatureCode_constraint; ber_type_decoder_f ExtNomenclatureCode_decode_ber; der_type_encoder_f ExtNomenclatureCode_encode_der; xer_type_decoder_f ExtNomenclatureCode_decode_xer; xer_type_encoder_f ExtNomenclatureCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _ExtNomenclatureCode_H_ */ biosig-2.3.3/biosig4c++/t240/xer_support.c0000664000175000017500000001265514105434233020247 0ustar schloeglschloegl/* * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com. * Copyright (c) 2003, 2004, 2005 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include /* Parser states */ typedef enum { ST_TEXT, ST_TAG_START, ST_TAG_BODY, ST_TAG_QUOTE_WAIT, ST_TAG_QUOTED_STRING, ST_TAG_UNQUOTED_STRING, ST_COMMENT_WAIT_DASH1, /* ""[0] */ ST_COMMENT_CLO_RT /* "-->"[1] */ } pstate_e; static pxml_chunk_type_e final_chunk_type[] = { PXML_TEXT, PXML_TAG_END, PXML_COMMENT_END, PXML_TAG_END, PXML_COMMENT_END, }; static int _charclass[256] = { 0,0,0,0,0,0,0,0, 0,1,1,0,1,1,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 2,2,2,2,2,2,2,2, 2,2,0,0,0,0,0,0, /* 01234567 89 */ 0,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3, /* ABCDEFG HIJKLMNO */ 3,3,3,3,3,3,3,3, 3,3,3,0,0,0,0,0, /* PQRSTUVW XYZ */ 0,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3, /* abcdefg hijklmno */ 3,3,3,3,3,3,3,3, 3,3,3,0,0,0,0,0 /* pqrstuvw xyz */ }; #define WHITESPACE(c) (_charclass[(unsigned char)(c)] == 1) #define ALNUM(c) (_charclass[(unsigned char)(c)] >= 2) #define ALPHA(c) (_charclass[(unsigned char)(c)] == 3) /* Aliases for characters, ASCII/UTF-8 */ #define EXCLAM 0x21 /* '!' */ #define CQUOTE 0x22 /* '"' */ #define CDASH 0x2d /* '-' */ #define CSLASH 0x2f /* '/' */ #define LANGLE 0x3c /* '<' */ #define CEQUAL 0x3d /* '=' */ #define RANGLE 0x3e /* '>' */ #define CQUEST 0x3f /* '?' */ /* Invoke token callback */ #define TOKEN_CB_CALL(type, _ns, _current_too, _final) do { \ int _ret; \ pstate_e ns = _ns; \ ssize_t _sz = (p - chunk_start) + _current_too; \ if (!_sz) { \ /* Shortcut */ \ state = _ns; \ break; \ } \ _ret = cb(type, chunk_start, _sz, key); \ if(_ret < _sz) { \ if(_current_too && _ret == -1) \ state = ns; \ goto finish; \ } \ chunk_start = p + _current_too; \ state = ns; \ } while(0) #define TOKEN_CB(_type, _ns, _current_too) \ TOKEN_CB_CALL(_type, _ns, _current_too, 0) #define TOKEN_CB_FINAL(_type, _ns, _current_too) \ TOKEN_CB_CALL(final_chunk_type[_type], _ns, _current_too, 1) /* * Parser itself */ ssize_t pxml_parse(int *stateContext, const void *xmlbuf, size_t size, pxml_callback_f *cb, void *key) { pstate_e state = (pstate_e)*stateContext; const char *chunk_start = (const char *)xmlbuf; const char *p = chunk_start; const char *end = p + size; for(; p < end; p++) { int C = *(const unsigned char *)p; switch(state) { case ST_TEXT: /* * Initial state: we're in the middle of some text, * or just have started. */ if (C == LANGLE) /* We're now in the tag, probably */ TOKEN_CB(PXML_TEXT, ST_TAG_START, 0); break; case ST_TAG_START: if (ALPHA(C) || (C == CSLASH)) state = ST_TAG_BODY; else if (C == EXCLAM) state = ST_COMMENT_WAIT_DASH1; else /* * Not characters and not whitespace. * Must be something like "3 < 4". */ TOKEN_CB(PXML_TEXT, ST_TEXT, 1);/* Flush as data */ break; case ST_TAG_BODY: switch(C) { case RANGLE: /* End of the tag */ TOKEN_CB_FINAL(PXML_TAG, ST_TEXT, 1); break; case LANGLE: /* * The previous tag wasn't completed, but still * recognized as valid. (Mozilla-compatible) */ TOKEN_CB_FINAL(PXML_TAG, ST_TAG_START, 0); break; case CEQUAL: state = ST_TAG_QUOTE_WAIT; break; } break; case ST_TAG_QUOTE_WAIT: /* * State after the equal sign ("=") in the tag. */ switch(C) { case CQUOTE: state = ST_TAG_QUOTED_STRING; break; case RANGLE: /* End of the tag */ TOKEN_CB_FINAL(PXML_TAG, ST_TEXT, 1); break; default: if(!WHITESPACE(C)) /* Unquoted string value */ state = ST_TAG_UNQUOTED_STRING; } break; case ST_TAG_QUOTED_STRING: /* * Tag attribute's string value in quotes. */ if(C == CQUOTE) { /* Return back to the tag state */ state = ST_TAG_BODY; } break; case ST_TAG_UNQUOTED_STRING: if(C == RANGLE) { /* End of the tag */ TOKEN_CB_FINAL(PXML_TAG, ST_TEXT, 1); } else if(WHITESPACE(C)) { /* Return back to the tag state */ state = ST_TAG_BODY; } break; case ST_COMMENT_WAIT_DASH1: if(C == CDASH) { state = ST_COMMENT_WAIT_DASH2; } else { /* Some ordinary tag. */ state = ST_TAG_BODY; } break; case ST_COMMENT_WAIT_DASH2: if(C == CDASH) { /* Seen "<--" */ state = ST_COMMENT; } else { /* Some ordinary tag */ state = ST_TAG_BODY; } break; case ST_COMMENT: if(C == CDASH) { state = ST_COMMENT_CLO_DASH2; } break; case ST_COMMENT_CLO_DASH2: if(C == CDASH) { state = ST_COMMENT_CLO_RT; } else { /* This is not an end of a comment */ state = ST_COMMENT; } break; case ST_COMMENT_CLO_RT: if(C == RANGLE) { TOKEN_CB_FINAL(PXML_COMMENT, ST_TEXT, 1); } else if(C == CDASH) { /* Maintain current state, still waiting for '>' */ } else { state = ST_COMMENT; } break; } /* switch(*ptr) */ } /* for() */ /* * Flush the partially processed chunk, state permitting. */ if(p - chunk_start) { switch (state) { case ST_COMMENT: TOKEN_CB(PXML_COMMENT, state, 0); break; case ST_TEXT: TOKEN_CB(PXML_TEXT, state, 0); break; default: break; /* a no-op */ } } finish: *stateContext = (int)state; return chunk_start - (const char *)xmlbuf; } biosig-2.3.3/biosig4c++/t240/INT-I8.h0000664000175000017500000000134414105434233016563 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_I8_H_ #define _INT_I8_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-I8 */ typedef long INT_I8_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_I8; asn_struct_free_f INT_I8_free; asn_struct_print_f INT_I8_print; asn_constr_check_f INT_I8_constraint; ber_type_decoder_f INT_I8_decode_ber; der_type_encoder_f INT_I8_encode_der; xer_type_decoder_f INT_I8_decode_xer; xer_type_encoder_f INT_I8_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_I8_H_ */ biosig-2.3.3/biosig4c++/t240/MsmtPrinciple.c0000664000175000017500000000732714105434233020443 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MsmtPrinciple.h" int MsmtPrinciple_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void MsmtPrinciple_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void MsmtPrinciple_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MsmtPrinciple_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MsmtPrinciple_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MsmtPrinciple_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MsmtPrinciple_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MsmtPrinciple_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MsmtPrinciple_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MsmtPrinciple_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MsmtPrinciple = { "MsmtPrinciple", "MsmtPrinciple", MsmtPrinciple_free, MsmtPrinciple_print, MsmtPrinciple_constraint, MsmtPrinciple_decode_ber, MsmtPrinciple_encode_der, MsmtPrinciple_decode_xer, MsmtPrinciple_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MsmtPrinciple_tags_1, sizeof(asn_DEF_MsmtPrinciple_tags_1) /sizeof(asn_DEF_MsmtPrinciple_tags_1[0]), /* 1 */ asn_DEF_MsmtPrinciple_tags_1, /* Same as above */ sizeof(asn_DEF_MsmtPrinciple_tags_1) /sizeof(asn_DEF_MsmtPrinciple_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/PatientDemographicsSection.c0000664000175000017500000004250714105434233023133 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "PatientDemographicsSection.h" static asn_TYPE_member_t asn_MBR_diagnosticcodes_26[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_diagnosticcodes_tags_26[] = { (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_diagnosticcodes_specs_26 = { sizeof(struct PatientDemographicsSection__diagnosticcodes), offsetof(struct PatientDemographicsSection__diagnosticcodes, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_diagnosticcodes_26 = { "diagnosticcodes", "diagnosticcodes", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_diagnosticcodes_tags_26, sizeof(asn_DEF_diagnosticcodes_tags_26) /sizeof(asn_DEF_diagnosticcodes_tags_26[0]) - 1, /* 1 */ asn_DEF_diagnosticcodes_tags_26, /* Same as above */ sizeof(asn_DEF_diagnosticcodes_tags_26) /sizeof(asn_DEF_diagnosticcodes_tags_26[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_diagnosticcodes_26, 1, /* Single element */ &asn_SPC_diagnosticcodes_specs_26 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_procedurecodes_32[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_procedurecodes_tags_32[] = { (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_procedurecodes_specs_32 = { sizeof(struct PatientDemographicsSection__procedurecodes), offsetof(struct PatientDemographicsSection__procedurecodes, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_procedurecodes_32 = { "procedurecodes", "procedurecodes", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_procedurecodes_tags_32, sizeof(asn_DEF_procedurecodes_tags_32) /sizeof(asn_DEF_procedurecodes_tags_32[0]) - 1, /* 1 */ asn_DEF_procedurecodes_tags_32, /* Same as above */ sizeof(asn_DEF_procedurecodes_tags_32) /sizeof(asn_DEF_procedurecodes_tags_32[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_procedurecodes_32, 1, /* Single element */ &asn_SPC_procedurecodes_specs_32 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_PatientDemographicsSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PatientDemographicsSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_POINTER, 31, offsetof(struct PatientDemographicsSection, patientid), (ASN_TAG_CLASS_APPLICATION | (2394 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientid" }, { ATF_POINTER, 30, offsetof(struct PatientDemographicsSection, ungroupedname), (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ungroupedname" }, { ATF_POINTER, 29, offsetof(struct PatientDemographicsSection, characternamegroup), (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "characternamegroup" }, { ATF_POINTER, 28, offsetof(struct PatientDemographicsSection, ideographicnamegroup), (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "ideographicnamegroup" }, { ATF_POINTER, 27, offsetof(struct PatientDemographicsSection, phoneticnamegroup), (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonNameGroup, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "phoneticnamegroup" }, { ATF_POINTER, 26, offsetof(struct PatientDemographicsSection, birthname), (ASN_TAG_CLASS_APPLICATION | (2398 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "birthname" }, { ATF_POINTER, 25, offsetof(struct PatientDemographicsSection, sex), (ASN_TAG_CLASS_APPLICATION | (2401 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatientSex, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sex" }, { ATF_POINTER, 24, offsetof(struct PatientDemographicsSection, race), (ASN_TAG_CLASS_APPLICATION | (2526 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatientRace, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "race" }, { ATF_POINTER, 23, offsetof(struct PatientDemographicsSection, patienttype), (ASN_TAG_CLASS_APPLICATION | (2402 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatientType, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patienttype" }, { ATF_POINTER, 22, offsetof(struct PatientDemographicsSection, dateofbirth), (ASN_TAG_CLASS_APPLICATION | (2392 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "dateofbirth" }, { ATF_POINTER, 21, offsetof(struct PatientDemographicsSection, patientgeninfo), (ASN_TAG_CLASS_APPLICATION | (2393 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientgeninfo" }, { ATF_POINTER, 20, offsetof(struct PatientDemographicsSection, patientage), (ASN_TAG_CLASS_APPLICATION | (2520 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientage" }, { ATF_POINTER, 19, offsetof(struct PatientDemographicsSection, gestationalage), (ASN_TAG_CLASS_APPLICATION | (2521 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "gestationalage" }, { ATF_POINTER, 18, offsetof(struct PatientDemographicsSection, patientheight), (ASN_TAG_CLASS_APPLICATION | (2524 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientheight" }, { ATF_POINTER, 17, offsetof(struct PatientDemographicsSection, patientweight), (ASN_TAG_CLASS_APPLICATION | (2527 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientweight" }, { ATF_POINTER, 16, offsetof(struct PatientDemographicsSection, patientbirthlength), (ASN_TAG_CLASS_APPLICATION | (2522 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientbirthlength" }, { ATF_POINTER, 15, offsetof(struct PatientDemographicsSection, patientbirthweight), (ASN_TAG_CLASS_APPLICATION | (2523 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientbirthweight" }, { ATF_POINTER, 14, offsetof(struct PatientDemographicsSection, motherpatientid), (ASN_TAG_CLASS_APPLICATION | (2504 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "motherpatientid" }, { ATF_POINTER, 13, offsetof(struct PatientDemographicsSection, mothername), (ASN_TAG_CLASS_APPLICATION | (2525 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PersonName, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "mothername" }, { ATF_POINTER, 12, offsetof(struct PatientDemographicsSection, patientheadcircumference), (ASN_TAG_CLASS_APPLICATION | (2490 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientheadcircumference" }, { ATF_POINTER, 11, offsetof(struct PatientDemographicsSection, patientbsa), (ASN_TAG_CLASS_APPLICATION | (2390 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PatMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "patientbsa" }, { ATF_POINTER, 10, offsetof(struct PatientDemographicsSection, bedid), (ASN_TAG_CLASS_APPLICATION | (2501 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bedid" }, { ATF_POINTER, 9, offsetof(struct PatientDemographicsSection, diagnosticinfo), (ASN_TAG_CLASS_APPLICATION | (2496 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "diagnosticinfo" }, { ATF_POINTER, 8, offsetof(struct PatientDemographicsSection, diagnosticcodes), (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_diagnosticcodes_26, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "diagnosticcodes" }, { ATF_POINTER, 7, offsetof(struct PatientDemographicsSection, admittingphysician), (ASN_TAG_CLASS_APPLICATION | (2515 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "admittingphysician" }, { ATF_POINTER, 6, offsetof(struct PatientDemographicsSection, attendingphysician), (ASN_TAG_CLASS_APPLICATION | (2516 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "attendingphysician" }, { ATF_POINTER, 5, offsetof(struct PatientDemographicsSection, dateofprocedure), (ASN_TAG_CLASS_APPLICATION | (2518 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "dateofprocedure" }, { ATF_POINTER, 4, offsetof(struct PatientDemographicsSection, proceduredescription), (ASN_TAG_CLASS_APPLICATION | (2495 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "proceduredescription" }, { ATF_POINTER, 3, offsetof(struct PatientDemographicsSection, procedurecodes), (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_procedurecodes_32, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "procedurecodes" }, { ATF_POINTER, 2, offsetof(struct PatientDemographicsSection, anaesthetist), (ASN_TAG_CLASS_APPLICATION | (2479 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "anaesthetist" }, { ATF_POINTER, 1, offsetof(struct PatientDemographicsSection, surgeon), (ASN_TAG_CLASS_APPLICATION | (2532 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "surgeon" }, }; static ber_tlv_tag_t asn_DEF_PatientDemographicsSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_PatientDemographicsSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 340 */ { (ASN_TAG_CLASS_APPLICATION | (2390 << 2)), 21, 0, 0 }, /* patientbsa at 383 */ { (ASN_TAG_CLASS_APPLICATION | (2392 << 2)), 10, 0, 0 }, /* dateofbirth at 357 */ { (ASN_TAG_CLASS_APPLICATION | (2393 << 2)), 11, 0, 0 }, /* patientgeninfo at 359 */ { (ASN_TAG_CLASS_APPLICATION | (2394 << 2)), 1, 0, 0 }, /* patientid at 343 */ { (ASN_TAG_CLASS_APPLICATION | (2398 << 2)), 6, 0, 0 }, /* birthname at 348 */ { (ASN_TAG_CLASS_APPLICATION | (2401 << 2)), 7, 0, 0 }, /* sex at 351 */ { (ASN_TAG_CLASS_APPLICATION | (2402 << 2)), 9, 0, 0 }, /* patienttype at 355 */ { (ASN_TAG_CLASS_APPLICATION | (2479 << 2)), 30, 0, 0 }, /* anaesthetist at 412 */ { (ASN_TAG_CLASS_APPLICATION | (2490 << 2)), 20, 0, 0 }, /* patientheadcircumference at 381 */ { (ASN_TAG_CLASS_APPLICATION | (2492 << 2)), 24, 0, 0 }, /* diagnosticcodes at 392 */ { (ASN_TAG_CLASS_APPLICATION | (2493 << 2)), 29, 0, 0 }, /* procedurecodes at 408 */ { (ASN_TAG_CLASS_APPLICATION | (2495 << 2)), 28, 0, 0 }, /* proceduredescription at 403 */ { (ASN_TAG_CLASS_APPLICATION | (2496 << 2)), 23, 0, 0 }, /* diagnosticinfo at 388 */ { (ASN_TAG_CLASS_APPLICATION | (2501 << 2)), 22, 0, 0 }, /* bedid at 386 */ { (ASN_TAG_CLASS_APPLICATION | (2504 << 2)), 18, 0, 0 }, /* motherpatientid at 376 */ { (ASN_TAG_CLASS_APPLICATION | (2515 << 2)), 25, 0, 0 }, /* admittingphysician at 394 */ { (ASN_TAG_CLASS_APPLICATION | (2516 << 2)), 26, 0, 0 }, /* attendingphysician at 397 */ { (ASN_TAG_CLASS_APPLICATION | (2518 << 2)), 27, 0, 0 }, /* dateofprocedure at 400 */ { (ASN_TAG_CLASS_APPLICATION | (2520 << 2)), 12, 0, 0 }, /* patientage at 362 */ { (ASN_TAG_CLASS_APPLICATION | (2521 << 2)), 13, 0, 0 }, /* gestationalage at 365 */ { (ASN_TAG_CLASS_APPLICATION | (2522 << 2)), 16, 0, 0 }, /* patientbirthlength at 372 */ { (ASN_TAG_CLASS_APPLICATION | (2523 << 2)), 17, 0, 0 }, /* patientbirthweight at 374 */ { (ASN_TAG_CLASS_APPLICATION | (2524 << 2)), 14, 0, 0 }, /* patientheight at 368 */ { (ASN_TAG_CLASS_APPLICATION | (2525 << 2)), 19, 0, 0 }, /* mothername at 378 */ { (ASN_TAG_CLASS_APPLICATION | (2526 << 2)), 8, 0, 0 }, /* race at 353 */ { (ASN_TAG_CLASS_APPLICATION | (2527 << 2)), 15, 0, 0 }, /* patientweight at 370 */ { (ASN_TAG_CLASS_APPLICATION | (2532 << 2)), 31, 0, 0 }, /* surgeon at 415 */ { (ASN_TAG_CLASS_APPLICATION | (6001 << 2)), 2, 0, 0 }, /* ungroupedname at 195 */ { (ASN_TAG_CLASS_APPLICATION | (6002 << 2)), 3, 0, 0 }, /* characternamegroup at 196 */ { (ASN_TAG_CLASS_APPLICATION | (6003 << 2)), 4, 0, 0 }, /* ideographicnamegroup at 197 */ { (ASN_TAG_CLASS_APPLICATION | (6004 << 2)), 5, 0, 0 } /* phoneticnamegroup at 198 */ }; static asn_SEQUENCE_specifics_t asn_SPC_PatientDemographicsSection_specs_1 = { sizeof(struct PatientDemographicsSection), offsetof(struct PatientDemographicsSection, _asn_ctx), asn_MAP_PatientDemographicsSection_tag2el_1, 32, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_PatientDemographicsSection = { "PatientDemographicsSection", "PatientDemographicsSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_PatientDemographicsSection_tags_1, sizeof(asn_DEF_PatientDemographicsSection_tags_1) /sizeof(asn_DEF_PatientDemographicsSection_tags_1[0]), /* 1 */ asn_DEF_PatientDemographicsSection_tags_1, /* Same as above */ sizeof(asn_DEF_PatientDemographicsSection_tags_1) /sizeof(asn_DEF_PatientDemographicsSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_PatientDemographicsSection_1, 32, /* Elements count */ &asn_SPC_PatientDemographicsSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/ParameterGroupCode.h0000664000175000017500000000157714105434233021413 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ParameterGroupCode_H_ #define _ParameterGroupCode_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* ParameterGroupCode */ typedef INTEGER_t ParameterGroupCode_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ParameterGroupCode; asn_struct_free_f ParameterGroupCode_free; asn_struct_print_f ParameterGroupCode_print; asn_constr_check_f ParameterGroupCode_constraint; ber_type_decoder_f ParameterGroupCode_decode_ber; der_type_encoder_f ParameterGroupCode_encode_der; xer_type_decoder_f ParameterGroupCode_decode_xer; xer_type_encoder_f ParameterGroupCode_encode_xer; #ifdef __cplusplus } #endif #endif /* _ParameterGroupCode_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I64.h0000664000175000017500000000136014105434233016643 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_I64_H_ #define _INT_I64_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-I64 */ typedef INTEGER_t INT_I64_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_I64; asn_struct_free_f INT_I64_free; asn_struct_print_f INT_I64_print; asn_constr_check_f INT_I64_constraint; ber_type_decoder_f INT_I64_decode_ber; der_type_encoder_f INT_I64_encode_der; xer_type_decoder_f INT_I64_decode_xer; xer_type_encoder_f INT_I64_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_I64_H_ */ biosig-2.3.3/biosig4c++/t240/RealTimeSampleArrayDescriptiveDataSection.c0000664000175000017500000010211714105434233026032 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "RealTimeSampleArrayDescriptiveDataSection.h" static int asn_DFL_6_set_0(int set_value, void **sptr) { MetricCategory_t *st = *sptr; if(!st) { if(!set_value) return -1; /* Not a default value */ st = (*sptr = CALLOC(1, sizeof(*st))); if(!st) return -1; } if(set_value) { /* Install default value 0 */ return asn_long2INTEGER(st, 0); } else { /* Test default value 0 */ long value; if(asn_INTEGER2long(st, &value)) return -1; return (value == 0); } } static asn_TYPE_member_t asn_MBR_vmosourcelist_13[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_vmosourcelist_tags_13[] = { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_vmosourcelist_specs_13 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__vmosourcelist), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__vmosourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_vmosourcelist_13 = { "vmosourcelist", "vmosourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_vmosourcelist_tags_13, sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]) - 1, /* 1 */ asn_DEF_vmosourcelist_tags_13, /* Same as above */ sizeof(asn_DEF_vmosourcelist_tags_13) /sizeof(asn_DEF_vmosourcelist_tags_13[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_vmosourcelist_13, 1, /* Single element */ &asn_SPC_vmosourcelist_specs_13 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metricsourcelist_15[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metricsourcelist_tags_15[] = { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metricsourcelist_specs_15 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__metricsourcelist), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__metricsourcelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metricsourcelist_15 = { "metricsourcelist", "metricsourcelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metricsourcelist_tags_15, sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]) - 1, /* 1 */ asn_DEF_metricsourcelist_tags_15, /* Same as above */ sizeof(asn_DEF_metricsourcelist_tags_15) /sizeof(asn_DEF_metricsourcelist_tags_15[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metricsourcelist_15, 1, /* Single element */ &asn_SPC_metricsourcelist_specs_15 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelist_17[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelist_tags_17[] = { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelist_specs_17 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelist), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelist_17 = { "msmtsitelist", "msmtsitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelist_tags_17, sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]) - 1, /* 1 */ asn_DEF_msmtsitelist_tags_17, /* Same as above */ sizeof(asn_DEF_msmtsitelist_tags_17) /sizeof(asn_DEF_msmtsitelist_tags_17[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelist_17, 1, /* Single element */ &asn_SPC_msmtsitelist_specs_17 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_msmtsitelistext_19[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_msmtsitelistext_tags_19[] = { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_msmtsitelistext_specs_19 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelistext), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__msmtsitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_msmtsitelistext_19 = { "msmtsitelistext", "msmtsitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_msmtsitelistext_tags_19, sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]) - 1, /* 1 */ asn_DEF_msmtsitelistext_tags_19, /* Same as above */ sizeof(asn_DEF_msmtsitelistext_tags_19) /sizeof(asn_DEF_msmtsitelistext_tags_19[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_msmtsitelistext_19, 1, /* Single element */ &asn_SPC_msmtsitelistext_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelist_21[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, &asn_DEF_BodySiteCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelist_tags_21[] = { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelist_specs_21 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__bodysitelist), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__bodysitelist, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelist_21 = { "bodysitelist", "bodysitelist", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelist_tags_21, sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]) - 1, /* 1 */ asn_DEF_bodysitelist_tags_21, /* Same as above */ sizeof(asn_DEF_bodysitelist_tags_21) /sizeof(asn_DEF_bodysitelist_tags_21[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelist_21, 1, /* Single element */ &asn_SPC_bodysitelist_specs_21 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_bodysitelistext_23[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_bodysitelistext_tags_23[] = { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_bodysitelistext_specs_23 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__bodysitelistext), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__bodysitelistext, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_bodysitelistext_23 = { "bodysitelistext", "bodysitelistext", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_bodysitelistext_tags_23, sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]) - 1, /* 1 */ asn_DEF_bodysitelistext_tags_23, /* Same as above */ sizeof(asn_DEF_bodysitelistext_tags_23) /sizeof(asn_DEF_bodysitelistext_tags_23[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_bodysitelistext_23, 1, /* Single element */ &asn_SPC_bodysitelistext_specs_23 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_metriccalibration_25[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_MetricCalEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_metriccalibration_tags_25[] = { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_metriccalibration_specs_25 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__metriccalibration), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__metriccalibration, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_metriccalibration_25 = { "metriccalibration", "metriccalibration", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_metriccalibration_tags_25, sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]) - 1, /* 1 */ asn_DEF_metriccalibration_tags_25, /* Same as above */ sizeof(asn_DEF_metriccalibration_tags_25) /sizeof(asn_DEF_metriccalibration_tags_25[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_metriccalibration_25, 1, /* Single element */ &asn_SPC_metriccalibration_specs_25 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_visualgrid_40[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaGridEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_visualgrid_tags_40[] = { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_visualgrid_specs_40 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__visualgrid), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__visualgrid, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_visualgrid_40 = { "visualgrid", "visualgrid", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_visualgrid_tags_40, sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]) - 1, /* 1 */ asn_DEF_visualgrid_tags_40, /* Same as above */ sizeof(asn_DEF_visualgrid_tags_40) /sizeof(asn_DEF_visualgrid_tags_40[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_visualgrid_40, 1, /* Single element */ &asn_SPC_visualgrid_specs_40 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_sacalibrationdata_42[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaCalData, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_sacalibrationdata_tags_42[] = { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_sacalibrationdata_specs_42 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__sacalibrationdata), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__sacalibrationdata, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_sacalibrationdata_42 = { "sacalibrationdata", "sacalibrationdata", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_sacalibrationdata_tags_42, sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]) - 1, /* 1 */ asn_DEF_sacalibrationdata_tags_42, /* Same as above */ sizeof(asn_DEF_sacalibrationdata_tags_42) /sizeof(asn_DEF_sacalibrationdata_tags_42[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_sacalibrationdata_42, 1, /* Single element */ &asn_SPC_sacalibrationdata_specs_42 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_filterspecification_44[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_SaFilterEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_filterspecification_tags_44[] = { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_filterspecification_specs_44 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection__filterspecification), offsetof(struct RealTimeSampleArrayDescriptiveDataSection__filterspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_filterspecification_44 = { "filterspecification", "filterspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_filterspecification_tags_44, sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]) - 1, /* 1 */ asn_DEF_filterspecification_tags_44, /* Same as above */ sizeof(asn_DEF_filterspecification_tags_44) /sizeof(asn_DEF_filterspecification_tags_44[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_filterspecification_44, 1, /* Single element */ &asn_SPC_filterspecification_specs_44 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_RealTimeSampleArrayDescriptiveDataSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, devicehandle), (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicehandle" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metrictype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metrictype" }, { ATF_POINTER, 24, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 23, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metriccategory), (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricCategory, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ asn_DFL_6_set_0, /* DEFAULT 0 */ "metriccategory" }, { ATF_POINTER, 22, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metricstatus), (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricstatus" }, { ATF_POINTER, 21, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, measurementstatus), (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MeasurementStatus, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementstatus" }, { ATF_POINTER, 20, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metricid), (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricsCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricid" }, { ATF_POINTER, 19, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metricidext), (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricidext" }, { ATF_POINTER, 18, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, unitcode), (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UnitsOfMeasurementCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitcode" }, { ATF_POINTER, 17, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, unitlabelstring), (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "unitlabelstring" }, { ATF_POINTER, 16, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, vmosourcelist), (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_vmosourcelist_13, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmosourcelist" }, { ATF_POINTER, 15, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metricsourcelist), (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metricsourcelist_15, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricsourcelist" }, { ATF_POINTER, 14, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, msmtsitelist), (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelist_17, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelist" }, { ATF_POINTER, 13, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, msmtsitelistext), (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_msmtsitelistext_19, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "msmtsitelistext" }, { ATF_POINTER, 12, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, bodysitelist), (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelist_21, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelist" }, { ATF_POINTER, 11, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, bodysitelistext), (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_bodysitelistext_23, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "bodysitelistext" }, { ATF_POINTER, 10, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metriccalibration), (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_metriccalibration_25, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metriccalibration" }, { ATF_POINTER, 9, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, colour), (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SimpleColour, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "colour" }, { ATF_POINTER, 8, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, measuremode), (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measuremode" }, { ATF_POINTER, 7, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, measureperiod), (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measureperiod" }, { ATF_POINTER, 6, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, averagingperiod), (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "averagingperiod" }, { ATF_POINTER, 5, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, starttime), (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "starttime" }, { ATF_POINTER, 4, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, stoptime), (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "stoptime" }, { ATF_POINTER, 3, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, metricinfolabelstring), (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "metricinfolabelstring" }, { ATF_POINTER, 2, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, substance), (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ExtNomenRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substance" }, { ATF_POINTER, 1, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, substancelabelstring), (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "substancelabelstring" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, saspecification), (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saspecification" }, { ATF_POINTER, 1, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, compression), (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compression" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, scaleandrangespec), (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ScaleRangeSpec, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "scaleandrangespec" }, { ATF_POINTER, 6, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, saphysiologicalrange), (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_AbsoluteRange, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "saphysiologicalrange" }, { ATF_POINTER, 5, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, visualgrid), (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_visualgrid_40, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "visualgrid" }, { ATF_POINTER, 4, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, sacalibrationdata), (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_sacalibrationdata_42, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sacalibrationdata" }, { ATF_POINTER, 3, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, filterspecification), (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_filterspecification_44, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "filterspecification" }, { ATF_POINTER, 2, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, sasignalfrequency), (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SaSignalFrequency, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sasignalfrequency" }, { ATF_POINTER, 1, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, sameasureresolution), (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFFloat, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sameasureresolution" }, { ATF_NOFLAGS, 0, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, sampleperiod), (ASN_TAG_CLASS_APPLICATION | (2445 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_Fraction, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sampleperiod" }, { ATF_POINTER, 1, offsetof(struct RealTimeSampleArrayDescriptiveDataSection, sweepspeed), (ASN_TAG_CLASS_APPLICATION | (2431 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MetricMeasure, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "sweepspeed" }, }; static ber_tlv_tag_t asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_RealTimeSampleArrayDescriptiveDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2321 << 2)), 18, 0, 0 }, /* colour at 859 */ { (ASN_TAG_CLASS_APPLICATION | (2322 << 2)), 28, 0, 0 }, /* compression at 962 */ { (ASN_TAG_CLASS_APPLICATION | (2329 << 2)), 33, 0, 0 }, /* filterspecification at 983 */ { (ASN_TAG_CLASS_APPLICATION | (2331 << 2)), 31, 0, 0 }, /* visualgrid at 973 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 779 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 3, 0, 0 }, /* labelstring at 790 */ { (ASN_TAG_CLASS_APPLICATION | (2347 << 2)), 7, 0, 0 }, /* metricid at 803 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 2, 0, 0 }, /* metrictype at 787 */ { (ASN_TAG_CLASS_APPLICATION | (2362 << 2)), 17, 0, 0 }, /* metriccalibration at 856 */ { (ASN_TAG_CLASS_APPLICATION | (2365 << 2)), 24, 0, 0 }, /* metricinfolabelstring at 880 */ { (ASN_TAG_CLASS_APPLICATION | (2366 << 2)), 12, 0, 0 }, /* metricsourcelist at 828 */ { (ASN_TAG_CLASS_APPLICATION | (2367 << 2)), 4, 0, 0 }, /* metriccategory at 793 */ { (ASN_TAG_CLASS_APPLICATION | (2368 << 2)), 5, 0, 0 }, /* metricstatus at 797 */ { (ASN_TAG_CLASS_APPLICATION | (2373 << 2)), 19, 0, 0 }, /* measuremode at 862 */ { (ASN_TAG_CLASS_APPLICATION | (2375 << 2)), 6, 0, 0 }, /* measurementstatus at 800 */ { (ASN_TAG_CLASS_APPLICATION | (2405 << 2)), 32, 0, 0 }, /* sacalibrationdata at 978 */ { (ASN_TAG_CLASS_APPLICATION | (2408 << 2)), 34, 0, 0 }, /* sasignalfrequency at 986 */ { (ASN_TAG_CLASS_APPLICATION | (2409 << 2)), 35, 0, 0 }, /* sameasureresolution at 989 */ { (ASN_TAG_CLASS_APPLICATION | (2411 << 2)), 30, 0, 0 }, /* saphysiologicalrange at 969 */ { (ASN_TAG_CLASS_APPLICATION | (2413 << 2)), 27, 0, 0 }, /* saspecification at 959 */ { (ASN_TAG_CLASS_APPLICATION | (2416 << 2)), 29, 0, 0 }, /* scaleandrangespec at 965 */ { (ASN_TAG_CLASS_APPLICATION | (2429 << 2)), 15, 0, 0 }, /* bodysitelist at 846 */ { (ASN_TAG_CLASS_APPLICATION | (2430 << 2)), 13, 0, 0 }, /* msmtsitelist at 834 */ { (ASN_TAG_CLASS_APPLICATION | (2431 << 2)), 37, 0, 0 }, /* sweepspeed at 1093 */ { (ASN_TAG_CLASS_APPLICATION | (2443 << 2)), 20, 0, 0 }, /* measureperiod at 865 */ { (ASN_TAG_CLASS_APPLICATION | (2445 << 2)), 36, 0, 0 }, /* sampleperiod at 1090 */ { (ASN_TAG_CLASS_APPLICATION | (2454 << 2)), 9, 0, 0 }, /* unitcode at 814 */ { (ASN_TAG_CLASS_APPLICATION | (2457 << 2)), 10, 0, 0 }, /* unitlabelstring at 817 */ { (ASN_TAG_CLASS_APPLICATION | (2467 << 2)), 11, 0, 0 }, /* vmosourcelist at 822 */ { (ASN_TAG_CLASS_APPLICATION | (2502 << 2)), 8, 0, 0 }, /* metricidext at 808 */ { (ASN_TAG_CLASS_APPLICATION | (2508 << 2)), 26, 0, 0 }, /* substancelabelstring at 890 */ { (ASN_TAG_CLASS_APPLICATION | (2535 << 2)), 21, 0, 0 }, /* averagingperiod at 869 */ { (ASN_TAG_CLASS_APPLICATION | (2538 << 2)), 22, 0, 0 }, /* starttime at 873 */ { (ASN_TAG_CLASS_APPLICATION | (2539 << 2)), 23, 0, 0 }, /* stoptime at 877 */ { (ASN_TAG_CLASS_APPLICATION | (2542 << 2)), 25, 0, 0 }, /* substance at 885 */ { (ASN_TAG_CLASS_APPLICATION | (2550 << 2)), 16, 0, 0 }, /* bodysitelistext at 851 */ { (ASN_TAG_CLASS_APPLICATION | (2551 << 2)), 14, 0, 0 }, /* msmtsitelistext at 840 */ { (ASN_TAG_CLASS_APPLICATION | (6034 << 2)), 1, 0, 0 } /* devicehandle at 782 */ }; static asn_SEQUENCE_specifics_t asn_SPC_RealTimeSampleArrayDescriptiveDataSection_specs_1 = { sizeof(struct RealTimeSampleArrayDescriptiveDataSection), offsetof(struct RealTimeSampleArrayDescriptiveDataSection, _asn_ctx), asn_MAP_RealTimeSampleArrayDescriptiveDataSection_tag2el_1, 38, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_RealTimeSampleArrayDescriptiveDataSection = { "RealTimeSampleArrayDescriptiveDataSection", "RealTimeSampleArrayDescriptiveDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1, sizeof(asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1) /sizeof(asn_DEF_RealTimeSampleArrayDescriptiveDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_RealTimeSampleArrayDescriptiveDataSection_1, 38, /* Elements count */ &asn_SPC_RealTimeSampleArrayDescriptiveDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/AlertType.c0000664000175000017500000000705514105434233017564 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "AlertType.h" int AlertType_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void AlertType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void AlertType_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { AlertType_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int AlertType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { AlertType_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t AlertType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { AlertType_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t AlertType_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { AlertType_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t AlertType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { AlertType_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t AlertType_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { AlertType_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_AlertType_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_AlertType = { "AlertType", "AlertType", AlertType_free, AlertType_print, AlertType_constraint, AlertType_decode_ber, AlertType_encode_der, AlertType_decode_xer, AlertType_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_AlertType_tags_1, sizeof(asn_DEF_AlertType_tags_1) /sizeof(asn_DEF_AlertType_tags_1[0]), /* 1 */ asn_DEF_AlertType_tags_1, /* Same as above */ sizeof(asn_DEF_AlertType_tags_1) /sizeof(asn_DEF_AlertType_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/ber_tlv_tag.c0000664000175000017500000000615614105434233020144 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include ssize_t ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) { ber_tlv_tag_t val; ber_tlv_tag_t tclass; size_t skipped; if(size == 0) return 0; val = *(const uint8_t *)ptr; tclass = (val >> 6); if((val &= 0x1F) != 0x1F) { /* * Simple form: everything encoded in a single octet. * Tag Class is encoded using two least significant bits. */ *tag_r = (val << 2) | tclass; return 1; } /* * Each octet contains 7 bits of useful information. * The MSB is 0 if it is the last octet of the tag. */ for(val = 0, ptr = ((const char *)ptr) + 1, skipped = 2; skipped <= size; ptr = ((const char *)ptr) + 1, skipped++) { unsigned int oct = *(const uint8_t *)ptr; if(oct & 0x80) { val = (val << 7) | (oct & 0x7F); /* * Make sure there are at least 9 bits spare * at the MS side of a value. */ if(val >> ((8 * sizeof(val)) - 9)) { /* * We would not be able to accomodate * any more tag bits. */ return -1; } } else { val = (val << 7) | oct; *tag_r = (val << 2) | tclass; return skipped; } } return 0; /* Want more */ } ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *f) { char buf[sizeof("[APPLICATION ]") + 32]; ssize_t ret; ret = ber_tlv_tag_snprint(tag, buf, sizeof(buf)); if(ret >= (ssize_t)sizeof(buf) || ret < 2) { errno = EPERM; return -1; } return fwrite(buf, 1, ret, f); } ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size) { char *type = 0; int ret; switch(tag & 0x3) { case ASN_TAG_CLASS_UNIVERSAL: type = "UNIVERSAL "; break; case ASN_TAG_CLASS_APPLICATION: type = "APPLICATION "; break; case ASN_TAG_CLASS_CONTEXT: type = ""; break; case ASN_TAG_CLASS_PRIVATE: type = "PRIVATE "; break; } ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2); if(ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */ return ret; } char * ber_tlv_tag_string(ber_tlv_tag_t tag) { static char buf[sizeof("[APPLICATION ]") + 32]; (void)ber_tlv_tag_snprint(tag, buf, sizeof(buf)); return buf; } size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) { int tclass = BER_TAG_CLASS(tag); ber_tlv_tag_t tval = BER_TAG_VALUE(tag); uint8_t *buf = (uint8_t *)bufp; uint8_t *end; size_t required_size; size_t i; if(tval <= 30) { /* Encoded in 1 octet */ if(size) buf[0] = (tclass << 6) | tval; return 1; } else if(size) { *buf++ = (tclass << 6) | 0x1F; size--; } /* * Compute the size of the subsequent bytes. */ for(required_size = 1, i = 7; i < 8 * sizeof(tval); i += 7) { if(tval >> i) required_size++; else break; } if(size < required_size) return required_size + 1; /* * Fill in the buffer, space permitting. */ end = buf + required_size - 1; for(i -= 7; buf < end; i -= 7, buf++) *buf = 0x80 | ((tval >> i) & 0x7F); *buf = (tval & 0x7F); /* Last octet without high bit */ return required_size + 1; } biosig-2.3.3/biosig4c++/t240/ExtNomenclatureCode.c0000664000175000017500000000754614105434233021570 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ExtNomenclatureCode.h" int ExtNomenclatureCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void ExtNomenclatureCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void ExtNomenclatureCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int ExtNomenclatureCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t ExtNomenclatureCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t ExtNomenclatureCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t ExtNomenclatureCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t ExtNomenclatureCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { ExtNomenclatureCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_ExtNomenclatureCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_ExtNomenclatureCode = { "ExtNomenclatureCode", "ExtNomenclatureCode", ExtNomenclatureCode_free, ExtNomenclatureCode_print, ExtNomenclatureCode_constraint, ExtNomenclatureCode_decode_ber, ExtNomenclatureCode_encode_der, ExtNomenclatureCode_decode_xer, ExtNomenclatureCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ExtNomenclatureCode_tags_1, sizeof(asn_DEF_ExtNomenclatureCode_tags_1) /sizeof(asn_DEF_ExtNomenclatureCode_tags_1[0]), /* 1 */ asn_DEF_ExtNomenclatureCode_tags_1, /* Same as above */ sizeof(asn_DEF_ExtNomenclatureCode_tags_1) /sizeof(asn_DEF_ExtNomenclatureCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/MetricsCode.c0000664000175000017500000000714614105434233020055 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MetricsCode.h" int MetricsCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void MetricsCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void MetricsCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { MetricsCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int MetricsCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { MetricsCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t MetricsCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { MetricsCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t MetricsCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { MetricsCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t MetricsCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { MetricsCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t MetricsCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { MetricsCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_MetricsCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_MetricsCode = { "MetricsCode", "MetricsCode", MetricsCode_free, MetricsCode_print, MetricsCode_constraint, MetricsCode_decode_ber, MetricsCode_encode_der, MetricsCode_decode_xer, MetricsCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MetricsCode_tags_1, sizeof(asn_DEF_MetricsCode_tags_1) /sizeof(asn_DEF_MetricsCode_tags_1[0]), /* 1 */ asn_DEF_MetricsCode_tags_1, /* Same as above */ sizeof(asn_DEF_MetricsCode_tags_1) /sizeof(asn_DEF_MetricsCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/constr_SEQUENCE.h0000664000175000017500000000276414105434233020462 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _CONSTR_SEQUENCE_H_ #define _CONSTR_SEQUENCE_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct asn_SEQUENCE_specifics_s { /* * Target structure description. */ int struct_size; /* Size of the target structure. */ int ctx_offset; /* Offset of the asn_struct_ctx_t member */ /* * Tags to members mapping table (sorted). */ asn_TYPE_tag2member_t *tag2el; int tag2el_count; /* * Optional members of the extensions root (roms) or additions (aoms). * Meaningful for PER. */ int *oms; /* Optional MemberS */ int roms_count; /* Root optional members count */ int aoms_count; /* Additions optional members count */ /* * Description of an extensions group. */ int ext_after; /* Extensions start after this member */ int ext_before; /* Extensions stop before this member */ } asn_SEQUENCE_specifics_t; /* * A set specialized functions dealing with the SEQUENCE type. */ asn_struct_free_f SEQUENCE_free; asn_struct_print_f SEQUENCE_print; asn_constr_check_f SEQUENCE_constraint; ber_type_decoder_f SEQUENCE_decode_ber; der_type_encoder_f SEQUENCE_encode_der; xer_type_decoder_f SEQUENCE_decode_xer; xer_type_encoder_f SEQUENCE_encode_xer; per_type_decoder_f SEQUENCE_decode_uper; per_type_encoder_f SEQUENCE_encode_uper; #ifdef __cplusplus } #endif #endif /* _CONSTR_SEQUENCE_H_ */ biosig-2.3.3/biosig4c++/t240/ANY.h0000664000175000017500000000255614105434233016310 0ustar schloeglschloegl/*- * Copyright (c) 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef ASN_TYPE_ANY_H #define ASN_TYPE_ANY_H #include /* Implemented via OCTET STRING type */ #ifdef __cplusplus extern "C" { #endif typedef struct ANY { uint8_t *buf; /* BER-encoded ANY contents */ int size; /* Size of the above buffer */ asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */ } ANY_t; extern asn_TYPE_descriptor_t asn_DEF_ANY; asn_struct_free_f ANY_free; asn_struct_print_f ANY_print; ber_type_decoder_f ANY_decode_ber; der_type_encoder_f ANY_encode_der; xer_type_encoder_f ANY_encode_xer; /****************************** * Handy conversion routines. * ******************************/ /* Convert another ASN.1 type into the ANY. This implies DER encoding. */ int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr); ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr); /* Convert the contents of the ANY type into the specified type. */ int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr); #define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size)) #define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \ &asn_DEF_ANY, (buf), (size)) #ifdef __cplusplus } #endif #endif /* ASN_TYPE_ANY_H */ biosig-2.3.3/biosig4c++/t240/FEFFloat.h0000664000175000017500000000136714105434233017246 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _FEFFloat_H_ #define _FEFFloat_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* FEFFloat */ typedef REAL_t FEFFloat_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_FEFFloat; asn_struct_free_f FEFFloat_free; asn_struct_print_f FEFFloat_print; asn_constr_check_f FEFFloat_constraint; ber_type_decoder_f FEFFloat_decode_ber; der_type_encoder_f FEFFloat_encode_der; xer_type_decoder_f FEFFloat_decode_xer; xer_type_encoder_f FEFFloat_encode_xer; #ifdef __cplusplus } #endif #endif /* _FEFFloat_H_ */ biosig-2.3.3/biosig4c++/t240/DistributionSampleArrayMeasuredDataSection.h0000664000175000017500000000246014105434233026300 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _DistributionSampleArrayMeasuredDataSection_H_ #define _DistributionSampleArrayMeasuredDataSection_H_ #include /* Including external dependencies */ #include #include "Fraction.h" #include "SampleArrayMeasuredDataBlock.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* DistributionSampleArrayMeasuredDataSection */ typedef struct DistributionSampleArrayMeasuredDataSection { INTEGER_t numberofsubblocks; Fraction_t subblocklength; INTEGER_t subblocksize; struct DistributionSampleArrayMeasuredDataSection__metriclist { A_SEQUENCE_OF(HandleRef_t) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } metriclist; SampleArrayMeasuredDataBlock_t data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } DistributionSampleArrayMeasuredDataSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_DistributionSampleArrayMeasuredDataSection; #ifdef __cplusplus } #endif #endif /* _DistributionSampleArrayMeasuredDataSection_H_ */ biosig-2.3.3/biosig4c++/t240/constr_CHOICE.h0000664000175000017500000000256614105434233020204 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _CONSTR_CHOICE_H_ #define _CONSTR_CHOICE_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct asn_CHOICE_specifics_s { /* * Target structure description. */ int struct_size; /* Size of the target structure. */ int ctx_offset; /* Offset of the asn_codec_ctx_t member */ int pres_offset; /* Identifier of the present member */ int pres_size; /* Size of the identifier (enum) */ /* * Tags to members mapping table. */ asn_TYPE_tag2member_t *tag2el; int tag2el_count; /* Canonical ordering of CHOICE elements, for PER */ int *canonical_order; /* * Extensions-related stuff. */ int ext_start; /* First member of extensions, or -1 */ } asn_CHOICE_specifics_t; /* * A set specialized functions dealing with the CHOICE type. */ asn_struct_free_f CHOICE_free; asn_struct_print_f CHOICE_print; asn_constr_check_f CHOICE_constraint; ber_type_decoder_f CHOICE_decode_ber; der_type_encoder_f CHOICE_encode_der; xer_type_decoder_f CHOICE_decode_xer; xer_type_encoder_f CHOICE_encode_xer; per_type_decoder_f CHOICE_decode_uper; per_type_encoder_f CHOICE_encode_uper; asn_outmost_tag_f CHOICE_outmost_tag; #ifdef __cplusplus } #endif #endif /* _CONSTR_CHOICE_H_ */ biosig-2.3.3/biosig4c++/t240/SaFlags.c0000664000175000017500000000702714105434233017172 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "SaFlags.h" int SaFlags_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_BIT_STRING.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using BIT_STRING, * so here we adjust the DEF accordingly. */ static void SaFlags_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_BIT_STRING.free_struct; td->print_struct = asn_DEF_BIT_STRING.print_struct; td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; td->der_encoder = asn_DEF_BIT_STRING.der_encoder; td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_BIT_STRING.per_constraints; td->elements = asn_DEF_BIT_STRING.elements; td->elements_count = asn_DEF_BIT_STRING.elements_count; td->specifics = asn_DEF_BIT_STRING.specifics; } void SaFlags_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { SaFlags_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int SaFlags_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { SaFlags_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t SaFlags_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { SaFlags_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t SaFlags_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { SaFlags_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t SaFlags_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { SaFlags_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t SaFlags_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { SaFlags_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_SaFlags_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) }; asn_TYPE_descriptor_t asn_DEF_SaFlags = { "SaFlags", "SaFlags", SaFlags_free, SaFlags_print, SaFlags_constraint, SaFlags_decode_ber, SaFlags_encode_der, SaFlags_decode_xer, SaFlags_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_SaFlags_tags_1, sizeof(asn_DEF_SaFlags_tags_1) /sizeof(asn_DEF_SaFlags_tags_1[0]), /* 1 */ asn_DEF_SaFlags_tags_1, /* Same as above */ sizeof(asn_DEF_SaFlags_tags_1) /sizeof(asn_DEF_SaFlags_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* Defined elsewhere */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/SessionArchiveSection.h0000664000175000017500000000407614105434233022132 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SessionArchiveSection_H_ #define _SessionArchiveSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "FEFString.h" #include "AbsoluteTime.h" #include "Placeholder.h" #include "PatientDemographicsSection.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct ArchiveProtection; struct ManufacturerSpecificSection; struct HealthCareProviderSection; struct SessionTestSection; struct SessionNotesSection; /* SessionArchiveSection */ typedef struct SessionArchiveSection { Handle_t handle; FEFString_t s_archive_id; FEFString_t s_archive_name; FEFString_t *s_archive_comments /* OPTIONAL */; AbsoluteTime_t starttime; AbsoluteTime_t stoptime; struct ArchiveProtection *protection /* OPTIONAL */; Placeholder_t *placeholder /* OPTIONAL */; struct ManufacturerSpecificSection *manufacturerspecific /* OPTIONAL */; struct HealthCareProviderSection *healthcareprovider /* OPTIONAL */; PatientDemographicsSection_t demographics; struct SessionArchiveSection__sessions { A_SEQUENCE_OF(struct SessionTestSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } sessions; struct SessionArchiveSection__notes { A_SEQUENCE_OF(struct SessionNotesSection) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *notes; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } SessionArchiveSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SessionArchiveSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "ArchiveProtection.h" #include "ManufacturerSpecificSection.h" #include "HealthCareProviderSection.h" #include "SessionTestSection.h" #include "SessionNotesSection.h" #endif /* _SessionArchiveSection_H_ */ biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificEncoded.h0000664000175000017500000000144714105434233023243 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ManufacturerSpecificEncoded_H_ #define _ManufacturerSpecificEncoded_H_ #include /* Including external dependencies */ #include "PrivateCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* ManufacturerSpecificEncoded */ typedef struct ManufacturerSpecificEncoded { PrivateCode_t code; ANY_t data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ManufacturerSpecificEncoded_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificEncoded; #ifdef __cplusplus } #endif #endif /* _ManufacturerSpecificEncoded_H_ */ biosig-2.3.3/biosig4c++/t240/ContentOrReference.h0000664000175000017500000000202614105434233021403 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ContentOrReference_H_ #define _ContentOrReference_H_ #include /* Including external dependencies */ #include #include "FEFString.h" #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ContentOrReference_PR { ContentOrReference_PR_NOTHING, /* No components present */ ContentOrReference_PR_content, ContentOrReference_PR_reference } ContentOrReference_PR; /* ContentOrReference */ typedef struct ContentOrReference { ContentOrReference_PR present; union ContentOrReference_u { OCTET_STRING_t content; FEFString_t reference; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ContentOrReference_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ContentOrReference; #ifdef __cplusplus } #endif #endif /* _ContentOrReference_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I16.c0000664000175000017500000000743614105434233016645 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-I16.h" int INT_I16_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= -32768 && value <= 32767)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void INT_I16_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeInteger.free_struct; td->print_struct = asn_DEF_NativeInteger.print_struct; td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; td->der_encoder = asn_DEF_NativeInteger.der_encoder; td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeInteger.per_constraints; td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; } void INT_I16_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_I16_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_I16_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_I16_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_I16_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_I16_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_I16_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_I16_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_I16_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_I16_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_I16_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_I16_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_I16_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_I16 = { "INT-I16", "INT-I16", INT_I16_free, INT_I16_print, INT_I16_constraint, INT_I16_decode_ber, INT_I16_encode_der, INT_I16_decode_xer, INT_I16_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_I16_tags_1, sizeof(asn_DEF_INT_I16_tags_1) /sizeof(asn_DEF_INT_I16_tags_1[0]), /* 1 */ asn_DEF_INT_I16_tags_1, /* Same as above */ sizeof(asn_DEF_INT_I16_tags_1) /sizeof(asn_DEF_INT_I16_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/INT-U64.h0000664000175000017500000000136014105434233016657 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _INT_U64_H_ #define _INT_U64_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* INT-U64 */ typedef INTEGER_t INT_U64_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_INT_U64; asn_struct_free_f INT_U64_free; asn_struct_print_f INT_U64_print; asn_constr_check_f INT_U64_constraint; ber_type_decoder_f INT_U64_decode_ber; der_type_encoder_f INT_U64_encode_der; xer_type_decoder_f INT_U64_decode_xer; xer_type_encoder_f INT_U64_encode_xer; #ifdef __cplusplus } #endif #endif /* _INT_U64_H_ */ biosig-2.3.3/biosig4c++/t240/VirtualMedicalDeviceSection.c0000664000175000017500000001552614105434233023227 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "VirtualMedicalDeviceSection.h" static asn_TYPE_member_t asn_MBR_productionspecification_6[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ProdSpecEntry, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_productionspecification_tags_6[] = { (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_productionspecification_specs_6 = { sizeof(struct VirtualMedicalDeviceSection__productionspecification), offsetof(struct VirtualMedicalDeviceSection__productionspecification, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_productionspecification_6 = { "productionspecification", "productionspecification", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_productionspecification_tags_6, sizeof(asn_DEF_productionspecification_tags_6) /sizeof(asn_DEF_productionspecification_tags_6[0]) - 1, /* 1 */ asn_DEF_productionspecification_tags_6, /* Same as above */ sizeof(asn_DEF_productionspecification_tags_6) /sizeof(asn_DEF_productionspecification_tags_6[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_productionspecification_6, 1, /* Single element */ &asn_SPC_productionspecification_specs_6 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_VirtualMedicalDeviceSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct VirtualMedicalDeviceSection, handle), (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, &asn_DEF_Handle, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct VirtualMedicalDeviceSection, devicetype), (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_DeviceCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "devicetype" }, { ATF_POINTER, 7, offsetof(struct VirtualMedicalDeviceSection, labelstring), (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_FEFString, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "labelstring" }, { ATF_POINTER, 6, offsetof(struct VirtualMedicalDeviceSection, vmdmodel), (ASN_TAG_CLASS_APPLICATION | (2344 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_SystemModel, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "vmdmodel" }, { ATF_POINTER, 5, offsetof(struct VirtualMedicalDeviceSection, productionspecification), (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_productionspecification_6, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "productionspecification" }, { ATF_POINTER, 4, offsetof(struct VirtualMedicalDeviceSection, compatibilityid), (ASN_TAG_CLASS_APPLICATION | (2336 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "compatibilityid" }, { ATF_POINTER, 3, offsetof(struct VirtualMedicalDeviceSection, parametergroup), (ASN_TAG_CLASS_APPLICATION | (2346 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ParameterGroupCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "parametergroup" }, { ATF_POINTER, 2, offsetof(struct VirtualMedicalDeviceSection, position), (ASN_TAG_CLASS_APPLICATION | (2348 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "position" }, { ATF_POINTER, 1, offsetof(struct VirtualMedicalDeviceSection, measurementprinciple), (ASN_TAG_CLASS_APPLICATION | (2560 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_MsmtPrinciple, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "measurementprinciple" }, }; static ber_tlv_tag_t asn_DEF_VirtualMedicalDeviceSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_VirtualMedicalDeviceSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (2336 << 2)), 5, 0, 0 }, /* compatibilityid at 632 */ { (ASN_TAG_CLASS_APPLICATION | (2337 << 2)), 0, 0, 0 }, /* handle at 613 */ { (ASN_TAG_CLASS_APPLICATION | (2343 << 2)), 2, 0, 0 }, /* labelstring at 619 */ { (ASN_TAG_CLASS_APPLICATION | (2344 << 2)), 3, 0, 0 }, /* vmdmodel at 622 */ { (ASN_TAG_CLASS_APPLICATION | (2346 << 2)), 6, 0, 0 }, /* parametergroup at 635 */ { (ASN_TAG_CLASS_APPLICATION | (2348 << 2)), 7, 0, 0 }, /* position at 638 */ { (ASN_TAG_CLASS_APPLICATION | (2349 << 2)), 4, 0, 0 }, /* productionspecification at 627 */ { (ASN_TAG_CLASS_APPLICATION | (2351 << 2)), 1, 0, 0 }, /* devicetype at 616 */ { (ASN_TAG_CLASS_APPLICATION | (2560 << 2)), 8, 0, 0 } /* measurementprinciple at 642 */ }; static asn_SEQUENCE_specifics_t asn_SPC_VirtualMedicalDeviceSection_specs_1 = { sizeof(struct VirtualMedicalDeviceSection), offsetof(struct VirtualMedicalDeviceSection, _asn_ctx), asn_MAP_VirtualMedicalDeviceSection_tag2el_1, 9, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_VirtualMedicalDeviceSection = { "VirtualMedicalDeviceSection", "VirtualMedicalDeviceSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_VirtualMedicalDeviceSection_tags_1, sizeof(asn_DEF_VirtualMedicalDeviceSection_tags_1) /sizeof(asn_DEF_VirtualMedicalDeviceSection_tags_1[0]), /* 1 */ asn_DEF_VirtualMedicalDeviceSection_tags_1, /* Same as above */ sizeof(asn_DEF_VirtualMedicalDeviceSection_tags_1) /sizeof(asn_DEF_VirtualMedicalDeviceSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_VirtualMedicalDeviceSection_1, 9, /* Elements count */ &asn_SPC_VirtualMedicalDeviceSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/StorageDataType.h0000664000175000017500000000177614105434233020724 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _StorageDataType_H_ #define _StorageDataType_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum StorageDataType { StorageDataType_unsigned = 0, StorageDataType_signed = 1, StorageDataType_ieee754float = 2 } e_StorageDataType; /* StorageDataType */ typedef INTEGER_t StorageDataType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_StorageDataType; asn_struct_free_f StorageDataType_free; asn_struct_print_f StorageDataType_print; asn_constr_check_f StorageDataType_constraint; ber_type_decoder_f StorageDataType_decode_ber; der_type_encoder_f StorageDataType_encode_der; xer_type_decoder_f StorageDataType_decode_xer; xer_type_encoder_f StorageDataType_encode_xer; #ifdef __cplusplus } #endif #endif /* _StorageDataType_H_ */ biosig-2.3.3/biosig4c++/t240/BITS-16.h0000664000175000017500000000136614105434233016644 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _BITS_16_H_ #define _BITS_16_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* BITS-16 */ typedef BIT_STRING_t BITS_16_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_BITS_16; asn_struct_free_f BITS_16_free; asn_struct_print_f BITS_16_print; asn_constr_check_f BITS_16_constraint; ber_type_decoder_f BITS_16_decode_ber; der_type_encoder_f BITS_16_encode_der; xer_type_decoder_f BITS_16_decode_xer; xer_type_encoder_f BITS_16_encode_xer; #ifdef __cplusplus } #endif #endif /* _BITS_16_H_ */ biosig-2.3.3/biosig4c++/t240/ManufacturerSpecificBinary.c0000664000175000017500000000462714105434233023124 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "ManufacturerSpecificBinary.h" static asn_TYPE_member_t asn_MBR_ManufacturerSpecificBinary_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ManufacturerSpecificBinary, code), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "code" }, { ATF_NOFLAGS, 0, offsetof(struct ManufacturerSpecificBinary, data), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_OCTET_STRING, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "data" }, }; static ber_tlv_tag_t asn_DEF_ManufacturerSpecificBinary_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_ManufacturerSpecificBinary_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* code at 276 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* data at 277 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ManufacturerSpecificBinary_specs_1 = { sizeof(struct ManufacturerSpecificBinary), offsetof(struct ManufacturerSpecificBinary, _asn_ctx), asn_MAP_ManufacturerSpecificBinary_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_ManufacturerSpecificBinary = { "ManufacturerSpecificBinary", "ManufacturerSpecificBinary", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_ManufacturerSpecificBinary_tags_1, sizeof(asn_DEF_ManufacturerSpecificBinary_tags_1) /sizeof(asn_DEF_ManufacturerSpecificBinary_tags_1[0]), /* 1 */ asn_DEF_ManufacturerSpecificBinary_tags_1, /* Same as above */ sizeof(asn_DEF_ManufacturerSpecificBinary_tags_1) /sizeof(asn_DEF_ManufacturerSpecificBinary_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_ManufacturerSpecificBinary_1, 2, /* Elements count */ &asn_SPC_ManufacturerSpecificBinary_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/Address.c0000664000175000017500000000700314105434233017231 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Address.h" int Address_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_FEFString.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using FEFString, * so here we adjust the DEF accordingly. */ static void Address_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_FEFString.free_struct; td->print_struct = asn_DEF_FEFString.print_struct; td->ber_decoder = asn_DEF_FEFString.ber_decoder; td->der_encoder = asn_DEF_FEFString.der_encoder; td->xer_decoder = asn_DEF_FEFString.xer_decoder; td->xer_encoder = asn_DEF_FEFString.xer_encoder; td->uper_decoder = asn_DEF_FEFString.uper_decoder; td->uper_encoder = asn_DEF_FEFString.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_FEFString.per_constraints; td->elements = asn_DEF_FEFString.elements; td->elements_count = asn_DEF_FEFString.elements_count; td->specifics = asn_DEF_FEFString.specifics; } void Address_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Address_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int Address_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Address_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t Address_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { Address_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t Address_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Address_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t Address_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { Address_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t Address_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Address_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_Address_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)) }; asn_TYPE_descriptor_t asn_DEF_Address = { "Address", "Address", Address_free, Address_print, Address_constraint, Address_decode_ber, Address_encode_der, Address_decode_xer, Address_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Address_tags_1, sizeof(asn_DEF_Address_tags_1) /sizeof(asn_DEF_Address_tags_1[0]), /* 1 */ asn_DEF_Address_tags_1, /* Same as above */ sizeof(asn_DEF_Address_tags_1) /sizeof(asn_DEF_Address_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/PatientRace.h0000664000175000017500000000174414105434233020056 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PatientRace_H_ #define _PatientRace_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum PatientRace { PatientRace_race_unspecified = 0, PatientRace_race_caucasian = 1, PatientRace_race_black = 2, PatientRace_race_oriental = 3 } e_PatientRace; /* PatientRace */ typedef INTEGER_t PatientRace_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PatientRace; asn_struct_free_f PatientRace_free; asn_struct_print_f PatientRace_print; asn_constr_check_f PatientRace_constraint; ber_type_decoder_f PatientRace_decode_ber; der_type_encoder_f PatientRace_encode_der; xer_type_decoder_f PatientRace_decode_xer; xer_type_encoder_f PatientRace_encode_xer; #ifdef __cplusplus } #endif #endif /* _PatientRace_H_ */ biosig-2.3.3/biosig4c++/t240/Authorization.c0000664000175000017500000000431614105434233020510 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "Authorization.h" static asn_TYPE_member_t asn_MBR_Authorization_1[] = { { ATF_NOFLAGS, 0, offsetof(struct Authorization, authorization_type), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_PrivateCode, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "authorization-type" }, { ATF_NOFLAGS, 0, offsetof(struct Authorization, authorization_key), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "authorization-key" }, }; static ber_tlv_tag_t asn_DEF_Authorization_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_Authorization_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* authorization-type at 331 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 } /* authorization-key at 333 */ }; static asn_SEQUENCE_specifics_t asn_SPC_Authorization_specs_1 = { sizeof(struct Authorization), offsetof(struct Authorization, _asn_ctx), asn_MAP_Authorization_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_Authorization = { "Authorization", "Authorization", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_Authorization_tags_1, sizeof(asn_DEF_Authorization_tags_1) /sizeof(asn_DEF_Authorization_tags_1[0]), /* 1 */ asn_DEF_Authorization_tags_1, /* Same as above */ sizeof(asn_DEF_Authorization_tags_1) /sizeof(asn_DEF_Authorization_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_Authorization_1, 2, /* Elements count */ &asn_SPC_Authorization_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/DynamicAttributeChangeSection.c0000664000175000017500000000634314105434233023555 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "DynamicAttributeChangeSection.h" static asn_TYPE_member_t asn_MBR_DynamicAttributeChangeSection_1[] = { { ATF_NOFLAGS, 0, offsetof(struct DynamicAttributeChangeSection, timestamp), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_ObservationTime, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timestamp" }, { ATF_NOFLAGS, 0, offsetof(struct DynamicAttributeChangeSection, handle), (ASN_TAG_CLASS_APPLICATION | (6041 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HandleRef, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "handle" }, { ATF_NOFLAGS, 0, offsetof(struct DynamicAttributeChangeSection, attribute), (ASN_TAG_CLASS_APPLICATION | (6046 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_INTEGER, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "attribute" }, { ATF_POINTER, 1, offsetof(struct DynamicAttributeChangeSection, value), (ASN_TAG_CLASS_APPLICATION | (6047 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ANY, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "value" }, }; static ber_tlv_tag_t asn_DEF_DynamicAttributeChangeSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_DynamicAttributeChangeSection_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* timestamp at 1461 */ { (ASN_TAG_CLASS_APPLICATION | (6041 << 2)), 1, 0, 0 }, /* handle at 1464 */ { (ASN_TAG_CLASS_APPLICATION | (6046 << 2)), 2, 0, 0 }, /* attribute at 1467 */ { (ASN_TAG_CLASS_APPLICATION | (6047 << 2)), 3, 0, 0 } /* value at 1470 */ }; static asn_SEQUENCE_specifics_t asn_SPC_DynamicAttributeChangeSection_specs_1 = { sizeof(struct DynamicAttributeChangeSection), offsetof(struct DynamicAttributeChangeSection, _asn_ctx), asn_MAP_DynamicAttributeChangeSection_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_DynamicAttributeChangeSection = { "DynamicAttributeChangeSection", "DynamicAttributeChangeSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_DynamicAttributeChangeSection_tags_1, sizeof(asn_DEF_DynamicAttributeChangeSection_tags_1) /sizeof(asn_DEF_DynamicAttributeChangeSection_tags_1[0]), /* 1 */ asn_DEF_DynamicAttributeChangeSection_tags_1, /* Same as above */ sizeof(asn_DEF_DynamicAttributeChangeSection_tags_1) /sizeof(asn_DEF_DynamicAttributeChangeSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_DynamicAttributeChangeSection_1, 4, /* Elements count */ &asn_SPC_DynamicAttributeChangeSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/t240/OCTET_STRING.c0000664000175000017500000013323514105434233017617 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* for .bits_unused member */ #include /* * OCTET STRING basic type description. */ static ber_tlv_tag_t asn_DEF_OCTET_STRING_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) }; static asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = { sizeof(OCTET_STRING_t), offsetof(OCTET_STRING_t, _asn_ctx), ASN_OSUBV_STR }; static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = { { APC_CONSTRAINED, 8, 8, 0, 255 }, { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 }; asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { "OCTET STRING", /* Canonical name */ "OCTET_STRING", /* XML tag name */ OCTET_STRING_free, OCTET_STRING_print, /* non-ascii stuff, generally */ asn_generic_no_constraint, OCTET_STRING_decode_ber, OCTET_STRING_encode_der, OCTET_STRING_decode_xer_hex, OCTET_STRING_encode_xer, OCTET_STRING_decode_uper, /* Unaligned PER decoder */ OCTET_STRING_encode_uper, /* Unaligned PER encoder */ 0, /* Use generic outmost tag fetcher */ asn_DEF_OCTET_STRING_tags, sizeof(asn_DEF_OCTET_STRING_tags) / sizeof(asn_DEF_OCTET_STRING_tags[0]), asn_DEF_OCTET_STRING_tags, /* Same as above */ sizeof(asn_DEF_OCTET_STRING_tags) / sizeof(asn_DEF_OCTET_STRING_tags[0]), 0, /* No PER visible constraints */ 0, 0, /* No members */ &asn_DEF_OCTET_STRING_specs }; #undef _CH_PHASE #undef NEXT_PHASE #undef PREV_PHASE #define _CH_PHASE(ctx, inc) do { \ if(ctx->phase == 0) \ ctx->context = 0; \ ctx->phase += inc; \ } while(0) #define NEXT_PHASE(ctx) _CH_PHASE(ctx, +1) #define PREV_PHASE(ctx) _CH_PHASE(ctx, -1) #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = (num_bytes); \ buf_ptr = ((const char *)buf_ptr) + num; \ size -= num; \ consumed_myself += num; \ } while(0) #undef RETURN #define RETURN(_code) do { \ asn_dec_rval_t tmprval; \ tmprval.code = _code; \ tmprval.consumed = consumed_myself; \ return tmprval; \ } while(0) #undef APPEND #define APPEND(bufptr, bufsize) do { \ size_t _bs = (bufsize); /* Append size */ \ size_t _ns = ctx->context; /* Allocated now */ \ size_t _es = st->size + _bs; /* Expected size */ \ /* int is really a typeof(st->size): */ \ if((int)_es < 0) RETURN(RC_FAIL); \ if(_ns <= _es) { \ void *ptr; \ /* Be nice and round to the memory allocator */ \ do { _ns = _ns ? _ns << 1 : 16; } \ while(_ns <= _es); \ /* int is really a typeof(st->size): */ \ if((int)_ns < 0) RETURN(RC_FAIL); \ ptr = REALLOC(st->buf, _ns); \ if(ptr) { \ st->buf = (uint8_t *)ptr; \ ctx->context = _ns; \ } else { \ RETURN(RC_FAIL); \ } \ ASN_DEBUG("Reallocating into %ld", (long)_ns); \ } \ memcpy(st->buf + st->size, bufptr, _bs); \ /* Convenient nul-termination */ \ st->buf[_es] = '\0'; \ st->size = _es; \ } while(0) /* * The main reason why ASN.1 is still alive is that too much time and effort * is necessary for learning it more or less adequately, thus creating a gut * necessity to demonstrate that aquired skill everywhere afterwards. * No, I am not going to explain what the following stuff is. */ struct _stack_el { ber_tlv_len_t left; /* What's left to read (or -1) */ ber_tlv_len_t got; /* What was actually processed */ int cont_level; /* Depth of subcontainment */ int want_nulls; /* Want null "end of content" octets? */ int bits_chopped; /* Flag in BIT STRING mode */ ber_tlv_tag_t tag; /* For debugging purposes */ struct _stack_el *prev; struct _stack_el *next; }; struct _stack { struct _stack_el *tail; struct _stack_el *cur_ptr; }; static struct _stack_el * OS__add_stack_el(struct _stack *st) { struct _stack_el *nel; /* * Reuse the old stack frame or allocate a new one. */ if(st->cur_ptr && st->cur_ptr->next) { nel = st->cur_ptr->next; nel->bits_chopped = 0; nel->got = 0; /* Retain the nel->cont_level, it's correct. */ } else { nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el)); if(nel == NULL) return NULL; if(st->tail) { /* Increase a subcontainment depth */ nel->cont_level = st->tail->cont_level + 1; st->tail->next = nel; } nel->prev = st->tail; st->tail = nel; } st->cur_ptr = nel; return nel; } static struct _stack * _new_stack() { return (struct _stack *)CALLOC(1, sizeof(struct _stack)); } /* * Decode OCTET STRING type. */ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buf_ptr, size_t size, int tag_mode) { asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; BIT_STRING_t *st = (BIT_STRING_t *)*sptr; asn_dec_rval_t rval; asn_struct_ctx_t *ctx; ssize_t consumed_myself = 0; struct _stack *stck; /* Expectations stack structure */ struct _stack_el *sel = 0; /* Stack element */ int tlv_constr; enum asn_OS_Subvariant type_variant = specs->subvariant; ASN_DEBUG("Decoding %s as %s (frame %ld)", td->name, (type_variant == ASN_OSUBV_STR) ? "OCTET STRING" : "OS-SpecialCase", (long)size); /* * Create the string if does not exist. */ if(st == NULL) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); if(st == NULL) RETURN(RC_FAIL); } /* Restore parsing context */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); switch(ctx->phase) { case 0: /* * Check tags. */ rval = ber_check_tags(opt_codec_ctx, td, ctx, buf_ptr, size, tag_mode, -1, &ctx->left, &tlv_constr); if(rval.code != RC_OK) return rval; if(tlv_constr) { /* * Complex operation, requires stack of expectations. */ ctx->ptr = _new_stack(); if(ctx->ptr) { stck = (struct _stack *)ctx->ptr; } else { RETURN(RC_FAIL); } } else { /* * Jump into stackless primitive decoding. */ _CH_PHASE(ctx, 3); if(type_variant == ASN_OSUBV_ANY && tag_mode != 1) APPEND(buf_ptr, rval.consumed); ADVANCE(rval.consumed); goto phase3; } NEXT_PHASE(ctx); /* Fall through */ case 1: phase1: /* * Fill the stack with expectations. */ stck = (struct _stack *)ctx->ptr; sel = stck->cur_ptr; do { ber_tlv_tag_t tlv_tag; ber_tlv_len_t tlv_len; ber_tlv_tag_t expected_tag; ssize_t tl, ll, tlvl; /* This one works even if (sel->left == -1) */ ssize_t Left = ((!sel||(size_t)sel->left >= size) ?(ssize_t)size:sel->left); ASN_DEBUG("%p, s->l=%ld, s->wn=%ld, s->g=%ld\n", sel, (long)(sel?sel->left:0), (long)(sel?sel->want_nulls:0), (long)(sel?sel->got:0) ); if(sel && sel->left <= 0 && sel->want_nulls == 0) { if(sel->prev) { struct _stack_el *prev = sel->prev; if(prev->left != -1) { if(prev->left < sel->got) RETURN(RC_FAIL); prev->left -= sel->got; } prev->got += sel->got; sel = stck->cur_ptr = prev; if(!sel) break; tlv_constr = 1; continue; } else { sel = stck->cur_ptr = 0; break; /* Nothing to wait */ } } tl = ber_fetch_tag(buf_ptr, Left, &tlv_tag); ASN_DEBUG("fetch tag(size=%ld,L=%ld), %sstack, left=%ld, wn=%ld, tl=%ld", (long)size, (long)Left, sel?"":"!", (long)(sel?sel->left:0), (long)(sel?sel->want_nulls:0), (long)tl); switch(tl) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } tlv_constr = BER_TLV_CONSTRUCTED(buf_ptr); ll = ber_fetch_length(tlv_constr, (const char *)buf_ptr + tl,Left - tl,&tlv_len); ASN_DEBUG("Got tag=%s, tc=%d, left=%ld, tl=%ld, len=%ld, ll=%ld", ber_tlv_tag_string(tlv_tag), tlv_constr, (long)Left, (long)tl, (long)tlv_len, (long)ll); switch(ll) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } if(sel && sel->want_nulls && ((const uint8_t *)buf_ptr)[0] == 0 && ((const uint8_t *)buf_ptr)[1] == 0) { ASN_DEBUG("Eat EOC; wn=%d--", sel->want_nulls); if(type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) APPEND("\0\0", 2); ADVANCE(2); sel->got += 2; if(sel->left != -1) { sel->left -= 2; /* assert(sel->left >= 2) */ } sel->want_nulls--; if(sel->want_nulls == 0) { /* Move to the next expectation */ sel->left = 0; tlv_constr = 1; } continue; } /* * Set up expected tags, * depending on ASN.1 type being decoded. */ switch(type_variant) { case ASN_OSUBV_BIT: /* X.690: 8.6.4.1, NOTE 2 */ /* Fall through */ case ASN_OSUBV_STR: default: if(sel) { int level = sel->cont_level; if(level < td->all_tags_count) { expected_tag = td->all_tags[level]; break; } else if(td->all_tags_count) { expected_tag = td->all_tags [td->all_tags_count - 1]; break; } /* else, Fall through */ } /* Fall through */ case ASN_OSUBV_ANY: expected_tag = tlv_tag; break; } if(tlv_tag != expected_tag) { char buf[2][32]; ber_tlv_tag_snprint(tlv_tag, buf[0], sizeof(buf[0])); ber_tlv_tag_snprint(td->tags[td->tags_count-1], buf[1], sizeof(buf[1])); ASN_DEBUG("Tag does not match expectation: %s != %s", buf[0], buf[1]); RETURN(RC_FAIL); } tlvl = tl + ll; /* Combined length of T and L encoding */ if((tlv_len + tlvl) < 0) { /* tlv_len value is too big */ ASN_DEBUG("TLV encoding + length (%ld) is too big", (long)tlv_len); RETURN(RC_FAIL); } /* * Append a new expectation. */ sel = OS__add_stack_el(stck); if(!sel) RETURN(RC_FAIL); sel->tag = tlv_tag; sel->want_nulls = (tlv_len==-1); if(sel->prev && sel->prev->left != -1) { /* Check that the parent frame is big enough */ if(sel->prev->left < tlvl + (tlv_len==-1?0:tlv_len)) RETURN(RC_FAIL); if(tlv_len == -1) sel->left = sel->prev->left - tlvl; else sel->left = tlv_len; } else { sel->left = tlv_len; } if(type_variant == ASN_OSUBV_ANY && (tag_mode != 1 || sel->cont_level)) APPEND(buf_ptr, tlvl); sel->got += tlvl; ADVANCE(tlvl); ASN_DEBUG("+EXPECT2 got=%ld left=%ld, wn=%d, clvl=%d", (long)sel->got, (long)sel->left, sel->want_nulls, sel->cont_level); } while(tlv_constr); if(sel == NULL) { /* Finished operation, "phase out" */ ASN_DEBUG("Phase out"); _CH_PHASE(ctx, +3); break; } NEXT_PHASE(ctx); /* Fall through */ case 2: stck = (struct _stack *)ctx->ptr; sel = stck->cur_ptr; ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d", (long)sel->left, (long)size, (long)sel->got, sel->want_nulls); { ber_tlv_len_t len; assert(sel->left >= 0); len = ((ber_tlv_len_t)size < sel->left) ? (ber_tlv_len_t)size : sel->left; if(len > 0) { if(type_variant == ASN_OSUBV_BIT && sel->bits_chopped == 0) { /* Put the unused-bits-octet away */ st->bits_unused = *(const uint8_t *)buf_ptr; APPEND(((const char *)buf_ptr+1), (len - 1)); sel->bits_chopped = 1; } else { APPEND(buf_ptr, len); } ADVANCE(len); sel->left -= len; sel->got += len; } if(sel->left) { ASN_DEBUG("OS left %ld, size = %ld, wn=%d\n", (long)sel->left, (long)size, sel->want_nulls); RETURN(RC_WMORE); } PREV_PHASE(ctx); goto phase1; } break; case 3: phase3: /* * Primitive form, no stack required. */ assert(ctx->left >= 0); if(size < (size_t)ctx->left) { if(!size) RETURN(RC_WMORE); if(type_variant == ASN_OSUBV_BIT && !ctx->context) { st->bits_unused = *(const uint8_t *)buf_ptr; ctx->left--; ADVANCE(1); } APPEND(buf_ptr, size); assert(ctx->context > 0); ctx->left -= size; ADVANCE(size); RETURN(RC_WMORE); } else { if(type_variant == ASN_OSUBV_BIT && !ctx->context && ctx->left) { st->bits_unused = *(const uint8_t *)buf_ptr; ctx->left--; ADVANCE(1); } APPEND(buf_ptr, ctx->left); ADVANCE(ctx->left); ctx->left = 0; NEXT_PHASE(ctx); } break; } if(sel) { ASN_DEBUG("3sel p=%p, wn=%d, l=%ld, g=%ld, size=%ld", sel->prev, sel->want_nulls, (long)sel->left, (long)sel->got, (long)size); if(sel->prev || sel->want_nulls > 1 || sel->left > 0) { RETURN(RC_WMORE); } } /* * BIT STRING-specific processing. */ if(type_variant == ASN_OSUBV_BIT && st->size) { /* Finalize BIT STRING: zero out unused bits. */ st->buf[st->size-1] &= 0xff << st->bits_unused; } ASN_DEBUG("Took %ld bytes to encode %s: [%s]:%ld", (long)consumed_myself, td->name, (type_variant == ASN_OSUBV_STR) ? (char *)st->buf : "", (long)st->size); RETURN(RC_OK); } /* * Encode OCTET STRING type using DER. */ asn_enc_rval_t OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_enc_rval_t er; asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; BIT_STRING_t *st = (BIT_STRING_t *)sptr; enum asn_OS_Subvariant type_variant = specs->subvariant; int fix_last_byte = 0; ASN_DEBUG("%s %s as OCTET STRING", cb?"Estimating":"Encoding", td->name); /* * Write tags. */ if(type_variant != ASN_OSUBV_ANY || tag_mode == 1) { er.encoded = der_write_tags(td, (type_variant == ASN_OSUBV_BIT) + st->size, tag_mode, type_variant == ASN_OSUBV_ANY, tag, cb, app_key); if(er.encoded == -1) { er.failed_type = td; er.structure_ptr = sptr; return er; } } else { /* Disallow: [] IMPLICIT ANY */ assert(type_variant != ASN_OSUBV_ANY || tag_mode != -1); er.encoded = 0; } if(!cb) { er.encoded += (type_variant == ASN_OSUBV_BIT) + st->size; _ASN_ENCODED_OK(er); } /* * Prepare to deal with the last octet of BIT STRING. */ if(type_variant == ASN_OSUBV_BIT) { uint8_t b = st->bits_unused & 0x07; if(b && st->size) fix_last_byte = 1; _ASN_CALLBACK(&b, 1); er.encoded++; } /* Invoke callback for the main part of the buffer */ _ASN_CALLBACK(st->buf, st->size - fix_last_byte); /* The last octet should be stripped off the unused bits */ if(fix_last_byte) { uint8_t b = st->buf[st->size-1] & (0xff << st->bits_unused); _ASN_CALLBACK(&b, 1); } er.encoded += st->size; _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { static const char *h2c = "0123456789ABCDEF"; const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; asn_enc_rval_t er; char scratch[16 * 3 + 4]; char *p = scratch; uint8_t *buf; uint8_t *end; size_t i; if(!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; er.encoded = 0; /* * Dump the contents of the buffer in hexadecimal. */ buf = st->buf; end = buf + st->size; if(flags & XER_F_CANONICAL) { char *scend = scratch + (sizeof(scratch) - 2); for(; buf < end; buf++) { if(p >= scend) { _ASN_CALLBACK(scratch, p - scratch); er.encoded += p - scratch; p = scratch; } *p++ = h2c[(*buf >> 4) & 0x0F]; *p++ = h2c[*buf & 0x0F]; } _ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */ er.encoded += p - scratch; } else { for(i = 0; buf < end; buf++, i++) { if(!(i % 16) && (i || st->size > 16)) { _ASN_CALLBACK(scratch, p-scratch); er.encoded += (p-scratch); p = scratch; _i_ASN_TEXT_INDENT(1, ilevel); } *p++ = h2c[(*buf >> 4) & 0x0F]; *p++ = h2c[*buf & 0x0F]; *p++ = 0x20; } if(p - scratch) { p--; /* Remove the tail space */ _ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */ er.encoded += p - scratch; if(st->size > 16) _i_ASN_TEXT_INDENT(1, ilevel-1); } } _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } static struct OCTET_STRING__xer_escape_table_s { char *string; int size; } OCTET_STRING__xer_escape_table[] = { #define OSXET(s) { s, sizeof(s) - 1 } OSXET("\074\156\165\154\057\076"), /* */ OSXET("\074\163\157\150\057\076"), /* */ OSXET("\074\163\164\170\057\076"), /* */ OSXET("\074\145\164\170\057\076"), /* */ OSXET("\074\145\157\164\057\076"), /* */ OSXET("\074\145\156\161\057\076"), /* */ OSXET("\074\141\143\153\057\076"), /* */ OSXET("\074\142\145\154\057\076"), /* */ OSXET("\074\142\163\057\076"), /* */ OSXET("\011"), /* \t */ OSXET("\012"), /* \n */ OSXET("\074\166\164\057\076"), /* */ OSXET("\074\146\146\057\076"), /* */ OSXET("\015"), /* \r */ OSXET("\074\163\157\057\076"), /* */ OSXET("\074\163\151\057\076"), /* */ OSXET("\074\144\154\145\057\076"), /* */ OSXET("\074\144\143\061\057\076"), /* */ OSXET("\074\144\143\062\057\076"), /* */ OSXET("\074\144\143\063\057\076"), /* */ OSXET("\074\144\143\064\057\076"), /* */ OSXET("\074\156\141\153\057\076"), /* */ OSXET("\074\163\171\156\057\076"), /* */ OSXET("\074\145\164\142\057\076"), /* */ OSXET("\074\143\141\156\057\076"), /* */ OSXET("\074\145\155\057\076"), /* */ OSXET("\074\163\165\142\057\076"), /* */ OSXET("\074\145\163\143\057\076"), /* */ OSXET("\074\151\163\064\057\076"), /* */ OSXET("\074\151\163\063\057\076"), /* */ OSXET("\074\151\163\062\057\076"), /* */ OSXET("\074\151\163\061\057\076"), /* */ { 0, 0 }, /* " " */ { 0, 0 }, /* ! */ { 0, 0 }, /* \" */ { 0, 0 }, /* # */ { 0, 0 }, /* $ */ { 0, 0 }, /* % */ OSXET("\046\141\155\160\073"), /* & */ { 0, 0 }, /* ' */ {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, /* ()*+,-./ */ {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, /* 01234567 */ {0,0},{0,0},{0,0},{0,0}, /* 89:; */ OSXET("\046\154\164\073"), /* < */ { 0, 0 }, /* = */ OSXET("\046\147\164\073"), /* > */ }; static int OS__check_escaped_control_char(const void *buf, int size) { size_t i; /* * Inefficient algorithm which translates the escape sequences * defined above into characters. Returns -1 if not found. * TODO: replace by a faster algorithm (bsearch(), hash or * nested table lookups). */ for(i = 0; i < 32 /* Don't spend time on the bottom half */; i++) { struct OCTET_STRING__xer_escape_table_s *el; el = &OCTET_STRING__xer_escape_table[i]; if(el->size == size && memcmp(buf, el->string, size) == 0) return i; } return -1; } static int OCTET_STRING__handle_control_chars(void *struct_ptr, const void *chunk_buf, size_t chunk_size) { /* * This might be one of the escape sequences * for control characters. Check it out. * #11.15.5 */ int control_char = OS__check_escaped_control_char(chunk_buf,chunk_size); if(control_char >= 0) { OCTET_STRING_t *st = (OCTET_STRING_t *)struct_ptr; void *p = REALLOC(st->buf, st->size + 2); if(p) { st->buf = (uint8_t *)p; st->buf[st->size++] = control_char; st->buf[st->size] = '\0'; /* nul-termination */ return 0; } } return -1; /* No, it's not */ } asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; asn_enc_rval_t er; uint8_t *buf, *end; uint8_t *ss; /* Sequence start */ ssize_t encoded_len = 0; (void)ilevel; /* Unused argument */ (void)flags; /* Unused argument */ if(!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; buf = st->buf; end = buf + st->size; for(ss = buf; buf < end; buf++) { unsigned int ch = *buf; int s_len; /* Special encoding sequence length */ /* * Escape certain characters: X.680/11.15 */ if(ch < sizeof(OCTET_STRING__xer_escape_table) /sizeof(OCTET_STRING__xer_escape_table[0]) && (s_len = OCTET_STRING__xer_escape_table[ch].size)) { if(((buf - ss) && cb(ss, buf - ss, app_key) < 0) || cb(OCTET_STRING__xer_escape_table[ch].string, s_len, app_key) < 0) _ASN_ENCODE_FAILED; encoded_len += (buf - ss) + s_len; ss = buf + 1; } } encoded_len += (buf - ss); if((buf - ss) && cb(ss, buf - ss, app_key) < 0) _ASN_ENCODE_FAILED; er.encoded = encoded_len; _ASN_ENCODED_OK(er); } /* * Convert from hexadecimal format (cstring): "AB CD EF" */ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr, const void *chunk_buf, size_t chunk_size, int have_more) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; const char *chunk_stop = (const char *)chunk_buf; const char *p = chunk_stop; const char *pend = p + chunk_size; unsigned int clv = 0; int half = 0; /* Half bit */ uint8_t *buf; /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 1) / 2; void *nptr = REALLOC(st->buf, _ns + 1); if(!nptr) return -1; st->buf = (uint8_t *)nptr; buf = st->buf + st->size; /* * If something like " a b c " appears here, the " a b":3 will be * converted, and the rest skipped. That is, unless buf_size is greater * than chunk_size, then it'll be equivalent to "ABC0". */ for(; p < pend; p++) { int ch = *(const unsigned char *)p; switch(ch) { case 0x09: case 0x0a: case 0x0c: case 0x0d: case 0x20: /* Ignore whitespace */ continue; case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: /*01234*/ case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: /*56789*/ clv = (clv << 4) + (ch - 0x30); break; case 0x41: case 0x42: case 0x43: /* ABC */ case 0x44: case 0x45: case 0x46: /* DEF */ clv = (clv << 4) + (ch - 0x41 + 10); break; case 0x61: case 0x62: case 0x63: /* abc */ case 0x64: case 0x65: case 0x66: /* def */ clv = (clv << 4) + (ch - 0x61 + 10); break; default: *buf = 0; /* JIC */ return -1; } if(half++) { half = 0; *buf++ = clv; chunk_stop = p + 1; } } /* * Check partial decoding. */ if(half) { if(have_more) { /* * Partial specification is fine, * because no more more PXER_TEXT data is available. */ *buf++ = clv << 4; chunk_stop = p; } } else { chunk_stop = p; } st->size = buf - st->buf; /* Adjust the buffer size */ assert(st->size <= _ns); st->buf[st->size] = 0; /* Courtesy termination */ return (chunk_stop - (const char *)chunk_buf); /* Converted size */ } /* * Convert from binary format: "00101011101" */ static ssize_t OCTET_STRING__convert_binary(void *sptr, const void *chunk_buf, size_t chunk_size, int have_more) { BIT_STRING_t *st = (BIT_STRING_t *)sptr; const char *p = (const char *)chunk_buf; const char *pend = p + chunk_size; int bits_unused = st->bits_unused & 0x7; uint8_t *buf; /* Reallocate buffer according to high cap estimation */ ssize_t _ns = st->size + (chunk_size + 7) / 8; void *nptr = REALLOC(st->buf, _ns + 1); if(!nptr) return -1; st->buf = (uint8_t *)nptr; buf = st->buf + st->size; (void)have_more; if(bits_unused == 0) bits_unused = 8; else if(st->size) buf--; /* * Convert series of 0 and 1 into the octet string. */ for(; p < pend; p++) { int ch = *(const unsigned char *)p; switch(ch) { case 0x09: case 0x0a: case 0x0c: case 0x0d: case 0x20: /* Ignore whitespace */ break; case 0x30: case 0x31: if(bits_unused-- <= 0) { *++buf = 0; /* Clean the cell */ bits_unused = 7; } *buf |= (ch&1) << bits_unused; break; default: st->bits_unused = bits_unused; return -1; } } if(bits_unused == 8) { st->size = buf - st->buf; st->bits_unused = 0; } else { st->size = buf - st->buf + 1; st->bits_unused = bits_unused; } assert(st->size <= _ns); st->buf[st->size] = 0; /* Courtesy termination */ return chunk_size; /* Converted in full */ } /* * Something like strtod(), but with stricter rules. */ static int OS__strtoent(int base, const char *buf, const char *end, int32_t *ret_value) { int32_t val = 0; const char *p; for(p = buf; p < end; p++) { int ch = *p; /* Strange huge value */ if((val * base + base) < 0) return -1; switch(ch) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: /*01234*/ case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: /*56789*/ val = val * base + (ch - 0x30); break; case 0x41: case 0x42: case 0x43: /* ABC */ case 0x44: case 0x45: case 0x46: /* DEF */ val = val * base + (ch - 0x41 + 10); break; case 0x61: case 0x62: case 0x63: /* abc */ case 0x64: case 0x65: case 0x66: /* def */ val = val * base + (ch - 0x61 + 10); break; case 0x3b: /* ';' */ *ret_value = val; return (p - buf) + 1; default: return -1; /* Character set error */ } } *ret_value = -1; return (p - buf); } /* * Convert from the plain UTF-8 format, expanding entity references: "2 < 3" */ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, size_t chunk_size, int have_more) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; const char *p = (const char *)chunk_buf; const char *pend = p + chunk_size; uint8_t *buf; /* Reallocate buffer */ ssize_t _ns = st->size + chunk_size; void *nptr = REALLOC(st->buf, _ns + 1); if(!nptr) return -1; st->buf = (uint8_t *)nptr; buf = st->buf + st->size; /* * Convert series of 0 and 1 into the octet string. */ for(; p < pend; p++) { int ch = *(const unsigned char *)p; int len; /* Length of the rest of the chunk */ if(ch != 0x26 /* '&' */) { *buf++ = ch; continue; /* That was easy... */ } /* * Process entity reference. */ len = chunk_size - (p - (const char *)chunk_buf); if(len == 1 /* "&" */) goto want_more; if(p[1] == 0x23 /* '#' */) { const char *pval; /* Pointer to start of digits */ int32_t val = 0; /* Entity reference value */ int base; if(len == 2 /* "&#" */) goto want_more; if(p[2] == 0x78 /* 'x' */) pval = p + 3, base = 16; else pval = p + 2, base = 10; len = OS__strtoent(base, pval, p + len, &val); if(len == -1) { /* Invalid charset. Just copy verbatim. */ *buf++ = ch; continue; } if(!len || pval[len-1] != 0x3b) goto want_more; assert(val > 0); p += (pval - p) + len - 1; /* Advance past entref */ if(val < 0x80) { *buf++ = (char)val; } else if(val < 0x800) { *buf++ = 0xc0 | ((val >> 6)); *buf++ = 0x80 | ((val & 0x3f)); } else if(val < 0x10000) { *buf++ = 0xe0 | ((val >> 12)); *buf++ = 0x80 | ((val >> 6) & 0x3f); *buf++ = 0x80 | ((val & 0x3f)); } else if(val < 0x200000) { *buf++ = 0xf0 | ((val >> 18)); *buf++ = 0x80 | ((val >> 12) & 0x3f); *buf++ = 0x80 | ((val >> 6) & 0x3f); *buf++ = 0x80 | ((val & 0x3f)); } else if(val < 0x4000000) { *buf++ = 0xf8 | ((val >> 24)); *buf++ = 0x80 | ((val >> 18) & 0x3f); *buf++ = 0x80 | ((val >> 12) & 0x3f); *buf++ = 0x80 | ((val >> 6) & 0x3f); *buf++ = 0x80 | ((val & 0x3f)); } else { *buf++ = 0xfc | ((val >> 30) & 0x1); *buf++ = 0x80 | ((val >> 24) & 0x3f); *buf++ = 0x80 | ((val >> 18) & 0x3f); *buf++ = 0x80 | ((val >> 12) & 0x3f); *buf++ = 0x80 | ((val >> 6) & 0x3f); *buf++ = 0x80 | ((val & 0x3f)); } } else { /* * Ugly, limited parsing of & > < */ char *sc = (char *)memchr(p, 0x3b, len > 5 ? 5 : len); if(!sc) goto want_more; if((sc - p) == 4 && p[1] == 0x61 /* 'a' */ && p[2] == 0x6d /* 'm' */ && p[3] == 0x70 /* 'p' */) { *buf++ = 0x26; p = sc; continue; } if((sc - p) == 3) { if(p[1] == 0x6c) { *buf = 0x3c; /* '<' */ } else if(p[1] == 0x67) { *buf = 0x3e; /* '>' */ } else { /* Unsupported entity reference */ *buf++ = ch; continue; } if(p[2] != 0x74) { /* Unsupported entity reference */ *buf++ = ch; continue; } buf++; p = sc; continue; } /* Unsupported entity reference */ *buf++ = ch; } continue; want_more: if(have_more) { /* * We know that no more data (of the same type) * is coming. Copy the rest verbatim. */ *buf++ = ch; continue; } chunk_size = (p - (const char *)chunk_buf); /* Processing stalled: need more data */ break; } st->size = buf - st->buf; assert(st->size <= _ns); st->buf[st->size] = 0; /* Courtesy termination */ return chunk_size; /* Converted in full */ } /* * Decode OCTET STRING from the XML element's body. */ static asn_dec_rval_t OCTET_STRING__decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size, int (*opt_unexpected_tag_decoder) (void *struct_ptr, const void *chunk_buf, size_t chunk_size), ssize_t (*body_receiver) (void *struct_ptr, const void *chunk_buf, size_t chunk_size, int have_more) ) { OCTET_STRING_t *st = (OCTET_STRING_t *)*sptr; asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; asn_struct_ctx_t *ctx; /* Per-structure parser context */ asn_dec_rval_t rval; /* Return value from the decoder */ int st_allocated; /* * Create the string if does not exist. */ if(!st) { st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size); *sptr = (void *)st; if(!st) goto sta_failed; st_allocated = 1; } else { st_allocated = 0; } if(!st->buf) { /* This is separate from above section */ st->buf = (uint8_t *)CALLOC(1, 1); if(!st->buf) { if(st_allocated) { *sptr = 0; goto stb_failed; } else { goto sta_failed; } } } /* Restore parsing context */ ctx = (asn_struct_ctx_t *)(((char *)*sptr) + specs->ctx_offset); return xer_decode_general(opt_codec_ctx, ctx, *sptr, xml_tag, buf_ptr, size, opt_unexpected_tag_decoder, body_receiver); stb_failed: FREEMEM(st); sta_failed: rval.code = RC_FAIL; rval.consumed = 0; return rval; } /* * Decode OCTET STRING from the hexadecimal data. */ asn_dec_rval_t OCTET_STRING_decode_xer_hex(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname, buf_ptr, size, 0, OCTET_STRING__convert_hexadecimal); } /* * Decode OCTET STRING from the binary (0/1) data. */ asn_dec_rval_t OCTET_STRING_decode_xer_binary(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname, buf_ptr, size, 0, OCTET_STRING__convert_binary); } /* * Decode OCTET STRING from the string (ASCII/UTF-8) data. */ asn_dec_rval_t OCTET_STRING_decode_xer_utf8(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, const void *buf_ptr, size_t size) { return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname, buf_ptr, size, OCTET_STRING__handle_control_chars, OCTET_STRING__convert_entrefs); } static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf, size_t units, unsigned int bpc, unsigned int unit_bits, long lb, long ub, asn_per_constraints_t *pc) { uint8_t *end = buf + units * bpc; ASN_DEBUG("Expanding %d characters into (%ld..%ld):%d", (int)units, lb, ub, unit_bits); /* X.691: 27.5.4 */ if((unsigned long)ub <= ((unsigned long)2 << (unit_bits - 1))) { /* Decode without translation */ lb = 0; } else if(pc && pc->code2value) { if(unit_bits > 16) return 1; /* FATAL: can't have constrained * UniversalString with more than * 16 million code points */ for(; buf < end; buf += bpc) { int value; int code = per_get_few_bits(po, unit_bits); if(code < 0) return -1; /* WMORE */ value = pc->code2value(code); if(value < 0) { ASN_DEBUG("Code %d (0x%02x) is" " not in map (%ld..%ld)", code, code, lb, ub); return 1; /* FATAL */ } switch(bpc) { case 1: *buf = value; break; case 2: buf[0] = value >> 8; buf[1] = value; break; case 4: buf[0] = value >> 24; buf[1] = value >> 16; buf[2] = value >> 8; buf[3] = value; break; } } return 0; } /* Shortcut the no-op copying to the aligned structure */ if(lb == 0 && (unit_bits == 8 * bpc)) { return per_get_many_bits(po, buf, 0, unit_bits * units); } for(; buf < end; buf += bpc) { int code = per_get_few_bits(po, unit_bits); int ch = code + lb; if(code < 0) return -1; /* WMORE */ if(ch > ub) { ASN_DEBUG("Code %d is out of range (%ld..%ld)", ch, lb, ub); return 1; /* FATAL */ } switch(bpc) { case 1: *buf = ch; break; case 2: buf[0] = ch >> 8; buf[1] = ch; break; case 4: buf[0] = ch >> 24; buf[1] = ch >> 16; buf[2] = ch >> 8; buf[3] = ch; break; } } return 0; } static int OCTET_STRING_per_put_characters(asn_per_outp_t *po, const uint8_t *buf, size_t units, unsigned int bpc, unsigned int unit_bits, long lb, long ub, asn_per_constraints_t *pc) { const uint8_t *end = buf + units * bpc; ASN_DEBUG("Squeezing %d characters into (%ld..%ld):%d (%d bpc)", (int)units, lb, ub, unit_bits, bpc); /* X.691: 27.5.4 */ if((unsigned long)ub <= ((unsigned long)2 << (unit_bits - 1))) { /* Encode as is */ lb = 0; } else if(pc && pc->value2code) { for(; buf < end; buf += bpc) { int code; uint32_t value; switch(bpc) { case 1: value = *(const uint8_t *)buf; break; case 2: value = (buf[0] << 8) | buf[1]; break; case 4: value = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; break; default: return -1; } code = pc->value2code(value); if(code < 0) { ASN_DEBUG("Character %d (0x%02x) is" " not in map (%ld..%ld)", *buf, *buf, lb, ub); return -1; } if(per_put_few_bits(po, code, unit_bits)) return -1; } } /* Shortcut the no-op copying to the aligned structure */ if(lb == 0 && (unit_bits == 8 * bpc)) { return per_put_many_bits(po, buf, unit_bits * units); } for(ub -= lb; buf < end; buf += bpc) { int ch; uint32_t value; switch(bpc) { case 1: value = *(const uint8_t *)buf; break; case 2: value = (buf[0] << 8) | buf[1]; break; case 4: value = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; break; default: return -1; } ch = value - lb; if(ch < 0 || ch > ub) { ASN_DEBUG("Character %d (0x%02x)" " is out of range (%ld..%ld)", *buf, *buf, lb, ub + lb); return -1; } if(per_put_few_bits(po, ch, unit_bits)) return -1; } return 0; } asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; asn_per_constraints_t *pc = constraints ? constraints : td->per_constraints; asn_per_constraint_t *cval; asn_per_constraint_t *csiz; asn_dec_rval_t rval = { RC_OK, 0 }; BIT_STRING_t *st = (BIT_STRING_t *)*sptr; ssize_t consumed_myself = 0; int repeat; enum { OS__BPC_BIT = 0, OS__BPC_CHAR = 1, OS__BPC_U16 = 2, OS__BPC_U32 = 4 } bpc; /* Bytes per character */ unsigned int unit_bits; unsigned int canonical_unit_bits; (void)opt_codec_ctx; if(pc) { cval = &pc->value; csiz = &pc->size; } else { cval = &asn_DEF_OCTET_STRING_constraints.value; csiz = &asn_DEF_OCTET_STRING_constraints.size; } switch(specs->subvariant) { default: case ASN_OSUBV_ANY: ASN_DEBUG("Unrecognized subvariant %d", specs->subvariant); RETURN(RC_FAIL); case ASN_OSUBV_BIT: canonical_unit_bits = unit_bits = 1; bpc = OS__BPC_BIT; break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_CHAR; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_U16; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_U32; break; } /* * Allocate the string. */ if(!st) { st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); if(!st) RETURN(RC_FAIL); } ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d", csiz->flags & APC_EXTENSIBLE ? "extensible" : "non-extensible", csiz->lower_bound, csiz->upper_bound, csiz->effective_bits); if(csiz->flags & APC_EXTENSIBLE) { int inext = per_get_few_bits(pd, 1); if(inext < 0) RETURN(RC_WMORE); if(inext) { csiz = &asn_DEF_OCTET_STRING_constraints.size; cval = &asn_DEF_OCTET_STRING_constraints.value; unit_bits = canonical_unit_bits; } } if(csiz->effective_bits >= 0) { FREEMEM(st->buf); if(bpc) { st->size = csiz->upper_bound * bpc; } else { st->size = (csiz->upper_bound + 7) >> 3; } st->buf = (uint8_t *)MALLOC(st->size + 1); if(!st->buf) { st->size = 0; RETURN(RC_FAIL); } } /* X.691, #16.5: zero-length encoding */ /* X.691, #16.6: short fixed length encoding (up to 2 octets) */ /* X.691, #16.7: long fixed length encoding (up to 64K octets) */ if(csiz->effective_bits == 0) { int ret; if(bpc) { ASN_DEBUG("Encoding OCTET STRING size %ld", csiz->upper_bound); ret = OCTET_STRING_per_get_characters(pd, st->buf, csiz->upper_bound, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); if(ret > 0) RETURN(RC_FAIL); } else { ASN_DEBUG("Encoding BIT STRING size %ld", csiz->upper_bound); ret = per_get_many_bits(pd, st->buf, 0, unit_bits * csiz->upper_bound); } if(ret < 0) RETURN(RC_WMORE); consumed_myself += unit_bits * csiz->upper_bound; st->buf[st->size] = 0; if(bpc == 0) { int ubs = (csiz->upper_bound & 0x7); st->bits_unused = ubs ? 8 - ubs : 0; } RETURN(RC_OK); } st->size = 0; do { ssize_t raw_len; ssize_t len_bytes; ssize_t len_bits; void *p; int ret; /* Get the PER length */ raw_len = uper_get_length(pd, csiz->effective_bits, &repeat); if(raw_len < 0) RETURN(RC_WMORE); raw_len += csiz->lower_bound; ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)", (long)csiz->effective_bits, (long)raw_len, repeat ? "repeat" : "once", td->name); if(bpc) { len_bytes = raw_len * bpc; len_bits = len_bytes * unit_bits; } else { len_bits = raw_len; len_bytes = (len_bits + 7) >> 3; if(len_bits & 0x7) st->bits_unused = 8 - (len_bits & 0x7); /* len_bits be multiple of 16K if repeat is set */ } p = REALLOC(st->buf, st->size + len_bytes + 1); if(!p) RETURN(RC_FAIL); st->buf = (uint8_t *)p; if(bpc) { ret = OCTET_STRING_per_get_characters(pd, &st->buf[st->size], raw_len, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); if(ret > 0) RETURN(RC_FAIL); } else { ret = per_get_many_bits(pd, &st->buf[st->size], 0, len_bits); } if(ret < 0) RETURN(RC_WMORE); st->size += len_bytes; } while(repeat); st->buf[st->size] = 0; /* nul-terminate */ return rval; } asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; asn_per_constraints_t *pc = constraints ? constraints : td->per_constraints; asn_per_constraint_t *cval; asn_per_constraint_t *csiz; const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; asn_enc_rval_t er = { 0, 0, 0 }; int inext = 0; /* Lies not within extension root */ unsigned int unit_bits; unsigned int canonical_unit_bits; unsigned int sizeinunits; const uint8_t *buf; int ret; enum { OS__BPC_BIT = 0, OS__BPC_CHAR = 1, OS__BPC_U16 = 2, OS__BPC_U32 = 4 } bpc; /* Bytes per character */ int ct_extensible; if(!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED; if(pc) { cval = &pc->value; csiz = &pc->size; } else { cval = &asn_DEF_OCTET_STRING_constraints.value; csiz = &asn_DEF_OCTET_STRING_constraints.size; } ct_extensible = csiz->flags & APC_EXTENSIBLE; switch(specs->subvariant) { default: case ASN_OSUBV_ANY: _ASN_ENCODE_FAILED; case ASN_OSUBV_BIT: canonical_unit_bits = unit_bits = 1; bpc = OS__BPC_BIT; sizeinunits = st->size * 8 - (st->bits_unused & 0x07); ASN_DEBUG("BIT STRING of %d bytes, %d bits unused", sizeinunits, st->bits_unused); break; case ASN_OSUBV_STR: canonical_unit_bits = unit_bits = 8; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_CHAR; sizeinunits = st->size; break; case ASN_OSUBV_U16: canonical_unit_bits = unit_bits = 16; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_U16; sizeinunits = st->size / 2; break; case ASN_OSUBV_U32: canonical_unit_bits = unit_bits = 32; if(cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits; bpc = OS__BPC_U32; sizeinunits = st->size / 4; break; } ASN_DEBUG("Encoding %s into %d units of %d bits" " (%ld..%ld, effective %d)%s", td->name, sizeinunits, unit_bits, csiz->lower_bound, csiz->upper_bound, csiz->effective_bits, ct_extensible ? " EXT" : ""); /* Figure out wheter size lies within PER visible constraint */ if(csiz->effective_bits >= 0) { if((int)sizeinunits < csiz->lower_bound || (int)sizeinunits > csiz->upper_bound) { if(ct_extensible) { cval = &asn_DEF_OCTET_STRING_constraints.value; csiz = &asn_DEF_OCTET_STRING_constraints.size; unit_bits = canonical_unit_bits; inext = 1; } else _ASN_ENCODE_FAILED; } } else { inext = 0; } if(ct_extensible) { /* Declare whether length is [not] within extension root */ if(per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED; } /* X.691, #16.5: zero-length encoding */ /* X.691, #16.6: short fixed length encoding (up to 2 octets) */ /* X.691, #16.7: long fixed length encoding (up to 64K octets) */ if(csiz->effective_bits >= 0) { ASN_DEBUG("Encoding %d bytes (%ld), length in %d bits", st->size, sizeinunits - csiz->lower_bound, csiz->effective_bits); ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound, csiz->effective_bits); if(ret) _ASN_ENCODE_FAILED; if(bpc) { ret = OCTET_STRING_per_put_characters(po, st->buf, sizeinunits, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); } else { ret = per_put_many_bits(po, st->buf, sizeinunits * unit_bits); } if(ret) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } ASN_DEBUG("Encoding %d bytes", st->size); if(sizeinunits == 0) { if(uper_put_length(po, 0)) _ASN_ENCODE_FAILED; _ASN_ENCODED_OK(er); } buf = st->buf; while(sizeinunits) { ssize_t maySave = uper_put_length(po, sizeinunits); if(maySave < 0) _ASN_ENCODE_FAILED; ASN_DEBUG("Encoding %ld of %ld", (long)maySave, (long)sizeinunits); if(bpc) { ret = OCTET_STRING_per_put_characters(po, buf, maySave, bpc, unit_bits, cval->lower_bound, cval->upper_bound, pc); } else { ret = per_put_many_bits(po, buf, maySave * unit_bits); } if(ret) _ASN_ENCODE_FAILED; if(bpc) buf += maySave * bpc; else buf += maySave >> 3; sizeinunits -= maySave; assert(!(maySave & 0x07) || !sizeinunits); } _ASN_ENCODED_OK(er); } int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { static const char *h2c = "0123456789ABCDEF"; const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; char scratch[16 * 3 + 4]; char *p = scratch; uint8_t *buf; uint8_t *end; size_t i; (void)td; /* Unused argument */ if(!st || (!st->buf && st->size)) return (cb("", 8, app_key) < 0) ? -1 : 0; /* * Dump the contents of the buffer in hexadecimal. */ buf = st->buf; end = buf + st->size; for(i = 0; buf < end; buf++, i++) { if(!(i % 16) && (i || st->size > 16)) { if(cb(scratch, p - scratch, app_key) < 0) return -1; _i_INDENT(1); p = scratch; } *p++ = h2c[(*buf >> 4) & 0x0F]; *p++ = h2c[*buf & 0x0F]; *p++ = 0x20; } if(p > scratch) { p--; /* Remove the tail space */ if(cb(scratch, p - scratch, app_key) < 0) return -1; } return 0; } int OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(st && (st->buf || !st->size)) { return (cb(st->buf, st->size, app_key) < 0) ? -1 : 0; } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; asn_struct_ctx_t *ctx = (asn_struct_ctx_t *) ((char *)st + specs->ctx_offset); struct _stack *stck; if(!td || !st) return; ASN_DEBUG("Freeing %s as OCTET STRING", td->name); if(st->buf) { FREEMEM(st->buf); st->buf = 0; } /* * Remove decode-time stack. */ stck = (struct _stack *)ctx->ptr; if(stck) { while(stck->tail) { struct _stack_el *sel = stck->tail; stck->tail = sel->prev; FREEMEM(sel); } FREEMEM(stck); } if(!contents_only) { FREEMEM(st); } } /* * Conversion routines. */ int OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len) { void *buf; if(st == 0 || (str == 0 && len)) { errno = EINVAL; return -1; } /* * Clear the OCTET STRING. */ if(str == NULL) { FREEMEM(st->buf); st->buf = 0; st->size = 0; return 0; } /* Determine the original string size, if not explicitly given */ if(len < 0) len = strlen(str); /* Allocate and fill the memory */ buf = MALLOC(len + 1); if(buf == NULL) return -1; memcpy(buf, str, len); ((uint8_t *)buf)[len] = '\0'; /* Couldn't use memcpy(len+1)! */ FREEMEM(st->buf); st->buf = (uint8_t *)buf; st->size = len; return 0; } OCTET_STRING_t * OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td, const char *str, int len) { asn_OCTET_STRING_specifics_t *specs = td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; OCTET_STRING_t *st; st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size); if(st && str && OCTET_STRING_fromBuf(st, str, len)) { FREEMEM(st); st = NULL; } return st; } biosig-2.3.3/biosig4c++/t240/ber_decoder.c0000664000175000017500000001677014105434233020114 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ ptr = ((const char *)ptr) + num; \ size -= num; \ consumed_myself += num; \ } while(0) #undef RETURN #define RETURN(_code) do { \ asn_dec_rval_t rval; \ rval.code = _code; \ if(opt_ctx) opt_ctx->step = step; /* Save context */ \ if(_code == RC_OK || opt_ctx) \ rval.consumed = consumed_myself; \ else \ rval.consumed = 0; /* Context-free */ \ return rval; \ } while(0) /* * The BER decoder of any type. */ asn_dec_rval_t ber_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr, const void *ptr, size_t size) { asn_codec_ctx_t s_codec_ctx; /* * Stack checker requires that the codec context * must be allocated on the stack. */ if(opt_codec_ctx) { if(opt_codec_ctx->max_stack_size) { s_codec_ctx = *opt_codec_ctx; opt_codec_ctx = &s_codec_ctx; } } else { /* If context is not given, be security-conscious anyway */ memset(&s_codec_ctx, 0, sizeof(s_codec_ctx)); s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX; opt_codec_ctx = &s_codec_ctx; } /* * Invoke type-specific decoder. */ return type_descriptor->ber_decoder(opt_codec_ctx, type_descriptor, struct_ptr, /* Pointer to the destination structure */ ptr, size, /* Buffer and its size */ 0 /* Default tag mode is 0 */ ); } /* * Check the set of >> tags matches the definition. */ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx, const void *ptr, size_t size, int tag_mode, int last_tag_form, ber_tlv_len_t *last_length, int *opt_tlv_form) { ssize_t consumed_myself = 0; ssize_t tag_len; ssize_t len_len; ber_tlv_tag_t tlv_tag; ber_tlv_len_t tlv_len; ber_tlv_len_t limit_len = -1; int expect_00_terminators = 0; int tlv_constr = -1; /* If CHOICE, opt_tlv_form is not given */ int step = opt_ctx ? opt_ctx->step : 0; /* Where we left previously */ int tagno; /* * Make sure we didn't exceed the maximum stack size. */ if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) RETURN(RC_FAIL); /* * So what does all this implicit skip stuff mean? * Imagine two types, * A ::= [5] IMPLICIT T * B ::= [2] EXPLICIT T * Where T is defined as * T ::= [4] IMPLICIT SEQUENCE { ... } * * Let's say, we are starting to decode type A, given the * following TLV stream: <5> <0>. What does this mean? * It means that the type A contains type T which is, * in turn, empty. * Remember though, that we are still in A. We cannot * just pass control to the type T decoder. Why? Because * the type T decoder expects <4> <0>, not <5> <0>. * So, we must make sure we are going to receive <5> while * still in A, then pass control to the T decoder, indicating * that the tag <4> was implicitly skipped. The decoder of T * hence will be prepared to treat <4> as valid tag, and decode * it appropriately. */ tagno = step /* Continuing where left previously */ + (tag_mode==1?-1:0) ; ASN_DEBUG("ber_check_tags(%s, size=%ld, tm=%d, step=%d, tagno=%d)", td->name, (long)size, tag_mode, step, tagno); /* assert(td->tags_count >= 1) May not be the case for CHOICE or ANY */ if(tag_mode == 0 && tagno == td->tags_count) { /* * This must be the _untagged_ ANY type, * which outermost tag isn't known in advance. * Fetch the tag and length separately. */ tag_len = ber_fetch_tag(ptr, size, &tlv_tag); switch(tag_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } tlv_constr = BER_TLV_CONSTRUCTED(ptr); len_len = ber_fetch_length(tlv_constr, (const char *)ptr + tag_len, size - tag_len, &tlv_len); switch(len_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } ASN_DEBUG("Advancing %ld in ANY case", (long)(tag_len + len_len)); ADVANCE(tag_len + len_len); } else { assert(tagno < td->tags_count); /* At least one loop */ } for((void)tagno; tagno < td->tags_count; tagno++, step++) { /* * Fetch and process T from TLV. */ tag_len = ber_fetch_tag(ptr, size, &tlv_tag); ASN_DEBUG("Fetching tag from {%p,%ld}: " "len %ld, step %d, tagno %d got %s", ptr, (long)size, (long)tag_len, step, tagno, ber_tlv_tag_string(tlv_tag)); switch(tag_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } tlv_constr = BER_TLV_CONSTRUCTED(ptr); /* * If {I}, don't check anything. * If {I,B,C}, check B and C unless we're at I. */ if(tag_mode != 0 && step == 0) { /* * We don't expect tag to match here. * It's just because we don't know how the tag * is supposed to look like. */ } else { assert(tagno >= 0); /* Guaranteed by the code above */ if(tlv_tag != td->tags[tagno]) { /* * Unexpected tag. Too bad. */ ASN_DEBUG("Expected: %s, " "expectation failed (tn=%d, tm=%d)", ber_tlv_tag_string(td->tags[tagno]), tagno, tag_mode ); RETURN(RC_FAIL); } } /* * Attention: if there are more tags expected, * ensure that the current tag is presented * in constructed form (it contains other tags!). * If this one is the last one, check that the tag form * matches the one given in descriptor. */ if(tagno < (td->tags_count - 1)) { if(tlv_constr == 0) { ASN_DEBUG("tlv_constr = %d, expfail", tlv_constr); RETURN(RC_FAIL); } } else { if(last_tag_form != tlv_constr && last_tag_form != -1) { ASN_DEBUG("last_tag_form %d != %d", last_tag_form, tlv_constr); RETURN(RC_FAIL); } } /* * Fetch and process L from TLV. */ len_len = ber_fetch_length(tlv_constr, (const char *)ptr + tag_len, size - tag_len, &tlv_len); ASN_DEBUG("Fetchinig len = %ld", (long)len_len); switch(len_len) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); } /* * FIXME * As of today, the chain of tags * must either contain several indefinite length TLVs, * or several definite length ones. * No mixing is allowed. */ if(tlv_len == -1) { /* * Indefinite length. */ if(limit_len == -1) { expect_00_terminators++; } else { ASN_DEBUG("Unexpected indefinite length " "in a chain of definite lengths"); RETURN(RC_FAIL); } ADVANCE(tag_len + len_len); continue; } else { if(expect_00_terminators) { ASN_DEBUG("Unexpected definite length " "in a chain of indefinite lengths"); RETURN(RC_FAIL); } } /* * Check that multiple TLVs specify ever decreasing length, * which is consistent. */ if(limit_len == -1) { limit_len = tlv_len + tag_len + len_len; if(limit_len < 0) { /* Too great tlv_len value? */ RETURN(RC_FAIL); } } else if(limit_len != tlv_len + tag_len + len_len) { /* * Inner TLV specifies length which is inconsistent * with the outer TLV's length value. */ ASN_DEBUG("Outer TLV is %ld and inner is %ld", (long)limit_len, (long)tlv_len); RETURN(RC_FAIL); } ADVANCE(tag_len + len_len); limit_len -= (tag_len + len_len); if((ssize_t)size > limit_len) { /* * Make sure that we won't consume more bytes * from the parent frame than the inferred limit. */ size = limit_len; } } if(opt_tlv_form) *opt_tlv_form = tlv_constr; if(expect_00_terminators) *last_length = -expect_00_terminators; else *last_length = tlv_len; RETURN(RC_OK); } biosig-2.3.3/biosig4c++/t240/EnumObject.h0000664000175000017500000000132414105434233017704 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumObject_H_ #define _EnumObject_H_ #include /* Including external dependencies */ #include "MetricsCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* EnumObject */ typedef struct EnumObject { MetricsCode_t enum_obj_id; ANY_t *enumadditionaldata /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumObject_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumObject; #ifdef __cplusplus } #endif #endif /* _EnumObject_H_ */ biosig-2.3.3/biosig4c++/t240/ChoiceOfNuObsValue.h0000664000175000017500000000257014105434233021300 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ChoiceOfNuObsValue_H_ #define _ChoiceOfNuObsValue_H_ #include /* Including external dependencies */ #include "NuObsValue.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ChoiceOfNuObsValue_PR { ChoiceOfNuObsValue_PR_NOTHING, /* No components present */ ChoiceOfNuObsValue_PR_nuobservedvalue, ChoiceOfNuObsValue_PR_compoundnuobservedvalue } ChoiceOfNuObsValue_PR; /* Forward declarations */ struct NuObsValue; /* ChoiceOfNuObsValue */ typedef struct ChoiceOfNuObsValue { ChoiceOfNuObsValue_PR present; union ChoiceOfNuObsValue_u { NuObsValue_t nuobservedvalue; struct ChoiceOfNuObsValue__compoundnuobservedvalue { A_SEQUENCE_OF(struct NuObsValue) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } compoundnuobservedvalue; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ChoiceOfNuObsValue_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ChoiceOfNuObsValue; #ifdef __cplusplus } #endif /* Referred external types */ #include "NuObsValue.h" #endif /* _ChoiceOfNuObsValue_H_ */ biosig-2.3.3/biosig4c++/t240/UTF8String.h0000664000175000017500000000242114105434233017565 0ustar schloeglschloegl/*- * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #ifndef _UTF8String_H_ #define _UTF8String_H_ #include #ifdef __cplusplus extern "C" { #endif typedef OCTET_STRING_t UTF8String_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_UTF8String; asn_struct_print_f UTF8String_print; asn_constr_check_f UTF8String_constraint; /* * Returns length of the given UTF-8 string in characters, * or a negative error code: * -1: UTF-8 sequence truncated * -2: Illegal UTF-8 sequence start * -3: Continuation expectation failed * -4: Not minimal length encoding * -5: Invalid arguments */ ssize_t UTF8String_length(const UTF8String_t *st); /* * Convert the UTF-8 string into a sequence of wide characters. * Returns the number of characters necessary. * Returned value might be greater than dstlen. * In case of conversion error, 0 is returned. * * If st points to a valid UTF-8 string, calling * UTF8String_to_wcs(st, 0, 0); * is equivalent to * UTF8String_length(const UTF8String_t *st); */ size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen); #ifdef __cplusplus } #endif #endif /* _UTF8String_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I64.c0000664000175000017500000000674614105434233016653 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-I64.h" int INT_I64_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void INT_I64_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void INT_I64_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_I64_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_I64_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_I64_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_I64_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_I64_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_I64_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_I64_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_I64_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_I64_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_I64_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_I64_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_I64_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_I64 = { "INT-I64", "INT-I64", INT_I64_free, INT_I64_print, INT_I64_constraint, INT_I64_decode_ber, INT_I64_encode_der, INT_I64_decode_xer, INT_I64_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_I64_tags_1, sizeof(asn_DEF_INT_I64_tags_1) /sizeof(asn_DEF_INT_I64_tags_1[0]), /* 1 */ asn_DEF_INT_I64_tags_1, /* Same as above */ sizeof(asn_DEF_INT_I64_tags_1) /sizeof(asn_DEF_INT_I64_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/EnumRecordMetric.h0000664000175000017500000000135514105434233021064 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _EnumRecordMetric_H_ #define _EnumRecordMetric_H_ #include /* Including external dependencies */ #include "MetricsCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* EnumRecordMetric */ typedef struct EnumRecordMetric { MetricsCode_t record_type_code; ANY_t record_data; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } EnumRecordMetric_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_EnumRecordMetric; #ifdef __cplusplus } #endif #endif /* _EnumRecordMetric_H_ */ biosig-2.3.3/biosig4c++/t240/INT-I32.c0000664000175000017500000000745014105434233016637 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "INT-I32.h" int INT_I32_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } value = *(const long *)sptr; if((value >= -2147483648 && value <= 2147483647)) { /* Constraint check succeeded */ return 0; } else { _ASN_CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void INT_I32_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_NativeInteger.free_struct; td->print_struct = asn_DEF_NativeInteger.print_struct; td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; td->der_encoder = asn_DEF_NativeInteger.der_encoder; td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; td->uper_decoder = asn_DEF_NativeInteger.uper_decoder; td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_NativeInteger.per_constraints; td->elements = asn_DEF_NativeInteger.elements; td->elements_count = asn_DEF_NativeInteger.elements_count; td->specifics = asn_DEF_NativeInteger.specifics; } void INT_I32_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { INT_I32_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int INT_I32_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { INT_I32_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t INT_I32_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { INT_I32_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t INT_I32_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { INT_I32_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t INT_I32_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { INT_I32_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t INT_I32_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { INT_I32_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_INT_I32_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_INT_I32 = { "INT-I32", "INT-I32", INT_I32_free, INT_I32_print, INT_I32_constraint, INT_I32_decode_ber, INT_I32_encode_der, INT_I32_decode_xer, INT_I32_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_INT_I32_tags_1, sizeof(asn_DEF_INT_I32_tags_1) /sizeof(asn_DEF_INT_I32_tags_1[0]), /* 1 */ asn_DEF_INT_I32_tags_1, /* Same as above */ sizeof(asn_DEF_INT_I32_tags_1) /sizeof(asn_DEF_INT_I32_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/ArchiveProtection.h0000664000175000017500000000136414105434233021305 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ArchiveProtection_H_ #define _ArchiveProtection_H_ #include /* Including external dependencies */ #include "PrivateCode.h" #include #include #ifdef __cplusplus extern "C" { #endif /* ArchiveProtection */ typedef struct ArchiveProtection { PrivateCode_t protectiontype; ANY_t protectionkey; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ArchiveProtection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ArchiveProtection; #ifdef __cplusplus } #endif #endif /* _ArchiveProtection_H_ */ biosig-2.3.3/biosig4c++/t240/SampleArrayMeasuredDataBlock.h0000664000175000017500000000201314105434233023320 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _SampleArrayMeasuredDataBlock_H_ #define _SampleArrayMeasuredDataBlock_H_ #include /* Including external dependencies */ #include #ifdef __cplusplus extern "C" { #endif /* SampleArrayMeasuredDataBlock */ typedef OCTET_STRING_t SampleArrayMeasuredDataBlock_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_SampleArrayMeasuredDataBlock; asn_struct_free_f SampleArrayMeasuredDataBlock_free; asn_struct_print_f SampleArrayMeasuredDataBlock_print; asn_constr_check_f SampleArrayMeasuredDataBlock_constraint; ber_type_decoder_f SampleArrayMeasuredDataBlock_decode_ber; der_type_encoder_f SampleArrayMeasuredDataBlock_encode_der; xer_type_decoder_f SampleArrayMeasuredDataBlock_decode_xer; xer_type_encoder_f SampleArrayMeasuredDataBlock_encode_xer; #ifdef __cplusplus } #endif #endif /* _SampleArrayMeasuredDataBlock_H_ */ biosig-2.3.3/biosig4c++/t240/constr_CHOICE.c0000664000175000017500000006764614105434233020211 0ustar schloeglschloegl/* * Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include #include #include /* * Number of bytes left for this structure. * (ctx->left) indicates the number of bytes _transferred_ for the structure. * (size) contains the number of bytes in the buffer passed. */ #define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) /* * If the subprocessor function returns with an indication that it wants * more data, it may well be a fatal decoding problem, because the * size is constrained by the 's L, even if the buffer size allows * reading more data. * For example, consider the buffer containing the following TLVs: * ... * The TLV length clearly indicates that one byte is expected in V, but * if the V processor returns with "want more data" even if the buffer * contains way more data than the V processor have seen. */ #define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) /* * This macro "eats" the part of the buffer which is definitely "consumed", * i.e. was correctly converted into local representation or rightfully skipped. */ #undef ADVANCE #define ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ ptr = ((const char *)ptr) + num;\ size -= num; \ if(ctx->left >= 0) \ ctx->left -= num; \ consumed_myself += num; \ } while(0) /* * Switch to the next phase of parsing. */ #undef NEXT_PHASE #define NEXT_PHASE(ctx) do { \ ctx->phase++; \ ctx->step = 0; \ } while(0) /* * Return a standardized complex structure. */ #undef RETURN #define RETURN(_code) do { \ rval.code = _code; \ rval.consumed = consumed_myself;\ return rval; \ } while(0) /* * See the definitions. */ static int _fetch_present_idx(const void *struct_ptr, int off, int size); static void _set_present_idx(void *sptr, int offset, int size, int pres); /* * Tags are canonically sorted in the tag to member table. */ static int _search4tag(const void *ap, const void *bp) { const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap; const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp; int a_class = BER_TAG_CLASS(a->el_tag); int b_class = BER_TAG_CLASS(b->el_tag); if(a_class == b_class) { ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag); ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); if(a_value == b_value) return 0; else if(a_value < b_value) return -1; else return 1; } else if(a_class < b_class) { return -1; } else { return 1; } } /* * The decoder of the CHOICE type. */ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *ptr, size_t size, int tag_mode) { /* * Bring closer parts of structure description. */ asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; asn_TYPE_member_t *elements = td->elements; /* * Parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ ber_tlv_tag_t tlv_tag; /* T from TLV */ ssize_t tag_len; /* Length of TLV's T */ asn_dec_rval_t rval; /* Return code from subparsers */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ ASN_DEBUG("Decoding %s as CHOICE", td->name); /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) { RETURN(RC_FAIL); } } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); /* * Start to parse where left previously */ switch(ctx->phase) { case 0: /* * PHASE 0. * Check that the set of tags associated with given structure * perfectly fits our expectations. */ if(tag_mode || td->tags_count) { rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, tag_mode, -1, &ctx->left, 0); if(rval.code != RC_OK) { ASN_DEBUG("%s tagging check failed: %d", td->name, rval.code); return rval; } if(ctx->left >= 0) { /* ?Substracted below! */ ctx->left += rval.consumed; } ADVANCE(rval.consumed); } else { ctx->left = -1; } NEXT_PHASE(ctx); ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", (long)ctx->left, (long)size); /* Fall through */ case 1: /* * Fetch the T from TLV. */ tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); ASN_DEBUG("In %s CHOICE tag length %d", td->name, (int)tag_len); switch(tag_len) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } do { asn_TYPE_tag2member_t *t2m; asn_TYPE_tag2member_t key; key.el_tag = tlv_tag; t2m = (asn_TYPE_tag2member_t *)bsearch(&key, specs->tag2el, specs->tag2el_count, sizeof(specs->tag2el[0]), _search4tag); if(t2m) { /* * Found the element corresponding to the tag. */ NEXT_PHASE(ctx); ctx->step = t2m->el_no; break; } else if(specs->ext_start == -1) { ASN_DEBUG("Unexpected tag %s " "in non-extensible CHOICE %s", ber_tlv_tag_string(tlv_tag), td->name); RETURN(RC_FAIL); } else { /* Skip this tag */ ssize_t skip; ASN_DEBUG("Skipping unknown tag %s", ber_tlv_tag_string(tlv_tag)); skip = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr), (const char *)ptr + tag_len, LEFT - tag_len); switch(skip) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } ADVANCE(skip + tag_len); RETURN(RC_OK); } } while(0); case 2: /* * PHASE 2. * Read in the element. */ do { asn_TYPE_member_t *elm;/* CHOICE's element */ void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ elm = &elements[ctx->step]; /* * Compute the position of the member inside a structure, * and also a type of containment (it may be contained * as pointer or using inline inclusion). */ if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { /* * A pointer to a pointer * holding the start of the structure */ memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } /* Set presence to be able to free it properly at any time */ _set_present_idx(st, specs->pres_offset, specs->pres_size, ctx->step + 1); /* * Invoke the member fetch routine according to member's type */ rval = elm->type->ber_decoder(opt_codec_ctx, elm->type, memb_ptr2, ptr, LEFT, elm->tag_mode); switch(rval.code) { case RC_OK: break; case RC_WMORE: /* More data expected */ if(!SIZE_VIOLATION) { ADVANCE(rval.consumed); RETURN(RC_WMORE); } RETURN(RC_FAIL); case RC_FAIL: /* Fatal error */ RETURN(rval.code); } /* switch(rval) */ ADVANCE(rval.consumed); } while(0); NEXT_PHASE(ctx); /* Fall through */ case 3: ASN_DEBUG("CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d", td->name, (long)ctx->left, (long)size, tag_mode, td->tags_count); if(ctx->left > 0) { /* * The type must be fully decoded * by the CHOICE member-specific decoder. */ RETURN(RC_FAIL); } if(ctx->left == -1 && !(tag_mode || td->tags_count)) { /* * This is an untagged CHOICE. * It doesn't contain nothing * except for the member itself, including all its tags. * The decoding is completed. */ NEXT_PHASE(ctx); break; } /* * Read in the "end of data chunks"'s. */ while(ctx->left < 0) { ssize_t tl; tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); switch(tl) { case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); /* Fall through */ case -1: RETURN(RC_FAIL); } /* * Expected <0><0>... */ if(((const uint8_t *)ptr)[0] == 0) { if(LEFT < 2) { if(SIZE_VIOLATION) RETURN(RC_FAIL); else RETURN(RC_WMORE); } else if(((const uint8_t *)ptr)[1] == 0) { /* * Correctly finished with <0><0>. */ ADVANCE(2); ctx->left++; continue; } } else { ASN_DEBUG("Unexpected continuation in %s", td->name); RETURN(RC_FAIL); } /* UNREACHABLE */ } NEXT_PHASE(ctx); case 4: /* No meaningful work here */ break; } RETURN(RC_OK); } asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; asn_TYPE_member_t *elm; /* CHOICE element */ asn_enc_rval_t erval; void *memb_ptr; size_t computed_size = 0; int present; if(!sptr) _ASN_ENCODE_FAILED; ASN_DEBUG("%s %s as CHOICE", cb?"Encoding":"Estimating", td->name); present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); /* * If the structure was not initialized, it cannot be encoded: * can't deduce what to encode in the choice type. */ if(present <= 0 || present > td->elements_count) { if(present == 0 && td->elements_count == 0) { /* The CHOICE is empty?! */ erval.encoded = 0; _ASN_ENCODED_OK(erval); } _ASN_ENCODE_FAILED; } /* * Seek over the present member of the structure. */ elm = &td->elements[present-1]; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(memb_ptr == 0) { if(elm->optional) { erval.encoded = 0; _ASN_ENCODED_OK(erval); } /* Mandatory element absent */ _ASN_ENCODE_FAILED; } } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } /* * If the CHOICE itself is tagged EXPLICIT: * T ::= [2] EXPLICIT CHOICE { ... } * Then emit the appropriate tags. */ if(tag_mode == 1 || td->tags_count) { /* * For this, we need to pre-compute the member. */ ssize_t ret; /* Encode member with its tag */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(erval.encoded == -1) return erval; /* Encode CHOICE with parent or my own tag */ ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag, cb, app_key); if(ret == -1) _ASN_ENCODE_FAILED; computed_size += ret; } /* * Encode the single underlying member. */ erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(erval.encoded == -1) return erval; ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", (long)erval.encoded, (long)computed_size); erval.encoded += computed_size; return erval; } ber_tlv_tag_t CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; assert(tag_mode == 0); (void)tag_mode; assert(tag == 0); (void)tag; /* * Figure out which CHOICE element is encoded. */ present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); if(present > 0 || present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present-1]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *) ((const char *)ptr + elm->memb_offset); } else { memb_ptr = (const void *) ((const char *)ptr + elm->memb_offset); } return asn_TYPE_outmost_tag(elm->type, memb_ptr, elm->tag_mode, elm->tag); } else { return (ber_tlv_tag_t)-1; } } int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } /* * Figure out which CHOICE element is encoded. */ present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size); if(present > 0 && present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present-1]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) { if(elm->optional) return 0; _ASN_CTFAIL(app_key, td, sptr, "%s: mandatory CHOICE element %s absent (%s:%d)", td->name, elm->name, __FILE__, __LINE__); return -1; } } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } if(elm->memb_constraints) { return elm->memb_constraints(elm->type, memb_ptr, ctfailcb, app_key); } else { int ret = elm->type->check_constraints(elm->type, memb_ptr, ctfailcb, app_key); /* * Cannot inherit it eralier: * need to make sure we get the updated version. */ elm->memb_constraints = elm->type->check_constraints; return ret; } } else { _ASN_CTFAIL(app_key, td, sptr, "%s: no CHOICE element given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } #undef XER_ADVANCE #define XER_ADVANCE(num_bytes) do { \ size_t num = num_bytes; \ buf_ptr = ((const char *)buf_ptr) + num;\ size -= num; \ consumed_myself += num; \ } while(0) /* * Decode the XER (XML) data. */ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const char *opt_mname, const void *buf_ptr, size_t size) { /* * Bring closer parts of structure description. */ asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; /* * Parts of the structure being constructed. */ void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ asn_dec_rval_t rval; /* Return value of a decoder */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ int edx; /* Element index */ /* * Create the target structure if it is not present already. */ if(st == 0) { st = *struct_ptr = CALLOC(1, specs->struct_size); if(st == 0) RETURN(RC_FAIL); } /* * Restore parsing context. */ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); if(ctx->phase == 0 && !*xml_tag) ctx->phase = 1; /* Skip the outer tag checking phase */ /* * Phases of XER/XML processing: * Phase 0: Check that the opening tag matches our expectations. * Phase 1: Processing body and reacting on closing tag. * Phase 2: Processing inner type. * Phase 3: Only waiting for closing tag. * Phase 4: Skipping unknown extensions. * Phase 5: PHASED OUT */ for(edx = ctx->step; ctx->phase <= 4;) { pxer_chunk_type_e ch_type; /* XER chunk type */ ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ asn_TYPE_member_t *elm; /* * Go inside the member. */ if(ctx->phase == 2) { asn_dec_rval_t tmprval; void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ elm = &td->elements[edx]; if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } /* Start/Continue decoding the inner member */ tmprval = elm->type->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", elm->type->name, tmprval.code); if(tmprval.code != RC_OK) RETURN(tmprval.code); assert(_fetch_present_idx(st, specs->pres_offset, specs->pres_size) == 0); /* Record what we've got */ _set_present_idx(st, specs->pres_offset, specs->pres_size, edx + 1); ctx->phase = 3; /* Fall through */ } /* No need to wait for closing tag; special mode. */ if(ctx->phase == 3 && !*xml_tag) { ctx->phase = 5; /* Phase out */ RETURN(RC_OK); } /* * Get the next part of the XML stream. */ ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type); switch(ch_size) { case -1: RETURN(RC_FAIL); case 0: RETURN(RC_WMORE); default: switch(ch_type) { case PXER_COMMENT: /* Got XML comment */ case PXER_TEXT: /* Ignore free-standing text */ XER_ADVANCE(ch_size); /* Skip silently */ continue; case PXER_TAG: break; /* Check the rest down there */ } } tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); ASN_DEBUG("XER/CHOICE checked [%c%c%c%c] vs [%s], tcv=%d", ch_size>0?((const uint8_t *)buf_ptr)[0]:'?', ch_size>1?((const uint8_t *)buf_ptr)[1]:'?', ch_size>2?((const uint8_t *)buf_ptr)[2]:'?', ch_size>3?((const uint8_t *)buf_ptr)[3]:'?', xml_tag, tcv); /* Skip the extensions section */ if(ctx->phase == 4) { ASN_DEBUG("skip_unknown(%d, %ld)", tcv, (long)ctx->left); switch(xer_skip_unknown(tcv, &ctx->left)) { case -1: ctx->phase = 5; RETURN(RC_FAIL); continue; case 1: ctx->phase = 3; /* Fall through */ case 0: XER_ADVANCE(ch_size); continue; case 2: ctx->phase = 3; break; } } switch(tcv) { case XCT_BOTH: break; /* No CHOICE? */ case XCT_CLOSING: if(ctx->phase != 3) break; XER_ADVANCE(ch_size); ctx->phase = 5; /* Phase out */ RETURN(RC_OK); case XCT_OPENING: if(ctx->phase == 0) { XER_ADVANCE(ch_size); ctx->phase = 1; /* Processing body phase */ continue; } /* Fall through */ case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: if(ctx->phase != 1) break; /* Really unexpected */ /* * Search which inner member corresponds to this tag. */ for(edx = 0; edx < td->elements_count; edx++) { elm = &td->elements[edx]; tcv = xer_check_tag(buf_ptr,ch_size,elm->name); switch(tcv) { case XCT_BOTH: case XCT_OPENING: /* * Process this member. */ ctx->step = edx; ctx->phase = 2; break; case XCT_UNKNOWN_OP: case XCT_UNKNOWN_BO: continue; default: edx = td->elements_count; break; /* Phase out */ } break; } if(edx != td->elements_count) continue; /* It is expected extension */ if(specs->ext_start != -1) { ASN_DEBUG("Got anticipated extension"); /* * Check for (XCT_BOTH or XCT_UNKNOWN_BO) * By using a mask. Only record a pure * tags. */ if(tcv & XCT_CLOSING) { /* Found without body */ ctx->phase = 3; /* Terminating */ } else { ctx->left = 1; ctx->phase = 4; /* Skip ...'s */ } XER_ADVANCE(ch_size); continue; } /* Fall through */ default: break; } ASN_DEBUG("Unexpected XML tag [%c%c%c%c] in CHOICE [%s]" " (ph=%d, tag=%s)", ch_size>0?((const uint8_t *)buf_ptr)[0]:'?', ch_size>1?((const uint8_t *)buf_ptr)[1]:'?', ch_size>2?((const uint8_t *)buf_ptr)[2]:'?', ch_size>3?((const uint8_t *)buf_ptr)[3]:'?', td->name, ctx->phase, xml_tag); break; } ctx->phase = 5; /* Phase out, just in case */ RETURN(RC_FAIL); } asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { asn_CHOICE_specifics_t *specs=(asn_CHOICE_specifics_t *)td->specifics; asn_enc_rval_t er; int present; if(!sptr) _ASN_ENCODE_FAILED; /* * Figure out which CHOICE element is encoded. */ present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size); if(present <= 0 || present > td->elements_count) { _ASN_ENCODE_FAILED; } else { asn_enc_rval_t tmper; asn_TYPE_member_t *elm = &td->elements[present-1]; void *memb_ptr; const char *mname = elm->name; unsigned int mlen = strlen(mname); if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) _ASN_ENCODE_FAILED; } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } er.encoded = 0; if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel); _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; _ASN_CALLBACK3("", 1); er.encoded += 5 + (2 * mlen) + tmper.encoded; } if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1); _ASN_ENCODED_OK(er); cb_failed: _ASN_ENCODE_FAILED; } asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; asn_dec_rval_t rv; asn_per_constraint_t *ct; asn_TYPE_member_t *elm; /* CHOICE's element */ void *memb_ptr; void **memb_ptr2; void *st = *sptr; int value; if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED; /* * Create the target structure if it is not present already. */ if(!st) { st = *sptr = CALLOC(1, specs->struct_size); if(!st) _ASN_DECODE_FAILED; } if(constraints) ct = &constraints->value; else if(td->per_constraints) ct = &td->per_constraints->value; else ct = 0; if(ct && ct->flags & APC_EXTENSIBLE) { value = per_get_few_bits(pd, 1); if(value < 0) _ASN_DECODE_STARVED; if(value) ct = 0; /* Not restricted */ } if(ct && ct->range_bits >= 0) { value = per_get_few_bits(pd, ct->range_bits); if(value < 0) _ASN_DECODE_STARVED; ASN_DEBUG("CHOICE %s got index %d in range %d", td->name, value, ct->range_bits); if(value > ct->upper_bound) _ASN_DECODE_FAILED; } else { if(specs->ext_start == -1) _ASN_DECODE_FAILED; value = uper_get_nsnnwn(pd); if(value < 0) _ASN_DECODE_STARVED; value += specs->ext_start; if(value >= td->elements_count) _ASN_DECODE_FAILED; } /* Adjust if canonical order is different from natural order */ if(specs->canonical_order) value = specs->canonical_order[value]; /* Set presence to be able to free it later */ _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1); elm = &td->elements[value]; if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr2 = (void **)((char *)st + elm->memb_offset); } else { memb_ptr = (char *)st + elm->memb_offset; memb_ptr2 = &memb_ptr; } ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name); if(ct && ct->range_bits >= 0) { rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); } else { rv = uper_open_type_get(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); } if(rv.code != RC_OK) ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, rv.code); return rv; } asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; asn_TYPE_member_t *elm; /* CHOICE's element */ asn_per_constraint_t *ct; void *memb_ptr; int present; if(!sptr) _ASN_ENCODE_FAILED; ASN_DEBUG("Encoding %s as CHOICE", td->name); if(constraints) ct = &constraints->value; else if(td->per_constraints) ct = &td->per_constraints->value; else ct = 0; present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); /* * If the structure was not initialized properly, it cannot be encoded: * can't deduce what to encode in the choice type. */ if(present <= 0 || present > td->elements_count) _ASN_ENCODE_FAILED; else present--; /* Adjust if canonical order is different from natural order */ if(specs->canonical_order) present = specs->canonical_order[present]; ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present); if(ct && ct->range_bits >= 0) { if(present < ct->lower_bound || present > ct->upper_bound) { if(ct->flags & APC_EXTENSIBLE) { if(per_put_few_bits(po, 1, 1)) _ASN_ENCODE_FAILED; } else { _ASN_ENCODE_FAILED; } ct = 0; } } if(ct && ct->flags & APC_EXTENSIBLE) if(per_put_few_bits(po, 0, 1)) _ASN_ENCODE_FAILED; elm = &td->elements[present]; if(elm->flags & ATF_POINTER) { /* Member is a pointer to another structure */ memb_ptr = *(void **)((char *)sptr + elm->memb_offset); if(!memb_ptr) _ASN_ENCODE_FAILED; } else { memb_ptr = (char *)sptr + elm->memb_offset; } if(ct && ct->range_bits >= 0) { if(per_put_few_bits(po, present, ct->range_bits)) _ASN_ENCODE_FAILED; return elm->type->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); } else { asn_enc_rval_t rval; if(specs->ext_start == -1) _ASN_ENCODE_FAILED; if(uper_put_nsnnwn(po, present - specs->ext_start)) _ASN_ENCODE_FAILED; if(uper_open_type_put(elm->type, elm->per_constraints, memb_ptr, po)) _ASN_ENCODE_FAILED; rval.encoded = 0; _ASN_ENCODED_OK(rval); } } int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; /* * Figure out which CHOICE element is encoded. */ present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size); /* * Print that element. */ if(present > 0 && present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present-1]; const void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); if(!memb_ptr) return (cb("", 8, app_key) < 0) ? -1 : 0; } else { memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); } /* Print member's name and stuff */ if(0) { if(cb(elm->name, strlen(elm->name), app_key) < 0 || cb(": ", 2, app_key) < 0) return -1; } return elm->type->print_struct(elm->type, memb_ptr, ilevel, cb, app_key); } else { return (cb("", 8, app_key) < 0) ? -1 : 0; } } void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; int present; if(!td || !ptr) return; ASN_DEBUG("Freeing %s as CHOICE", td->name); /* * Figure out which CHOICE element is encoded. */ present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); /* * Free that element. */ if(present > 0 && present <= td->elements_count) { asn_TYPE_member_t *elm = &td->elements[present-1]; void *memb_ptr; if(elm->flags & ATF_POINTER) { memb_ptr = *(void **)((char *)ptr + elm->memb_offset); if(memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr); } else { memb_ptr = (void *)((char *)ptr + elm->memb_offset); ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr); } } if(!contents_only) { FREEMEM(ptr); } } /* * The following functions functions offer protection against -fshort-enums, * compatible with little- and big-endian machines. * If assertion is triggered, either disable -fshort-enums, or add an entry * here with the ->pres_size of your target stracture. * Unless the target structure is packed, the ".present" member * is guaranteed to be aligned properly. ASN.1 compiler itself does not * produce packed code. */ static int _fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) { const void *present_ptr; int present; present_ptr = ((const char *)struct_ptr) + pres_offset; switch(pres_size) { case sizeof(int): present = *(const int *)present_ptr; break; case sizeof(short): present = *(const short *)present_ptr; break; case sizeof(char): present = *(const char *)present_ptr; break; default: /* ANSI C mandates enum to be equivalent to integer */ assert(pres_size != sizeof(int)); return 0; /* If not aborted, pass back safe value */ } return present; } static void _set_present_idx(void *struct_ptr, int pres_offset, int pres_size, int present) { void *present_ptr; present_ptr = ((char *)struct_ptr) + pres_offset; switch(pres_size) { case sizeof(int): *(int *)present_ptr = present; break; case sizeof(short): *(short *)present_ptr = present; break; case sizeof(char): *(char *)present_ptr = present; break; default: /* ANSI C mandates enum to be equivalent to integer */ assert(pres_size != sizeof(int)); } } biosig-2.3.3/biosig4c++/t240/PatientDemographicsSection.h0000664000175000017500000000566114105434233023140 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _PatientDemographicsSection_H_ #define _PatientDemographicsSection_H_ #include /* Including external dependencies */ #include "Handle.h" #include "FEFString.h" #include "PatientSex.h" #include "PatientRace.h" #include "PatientType.h" #include "AbsoluteTime.h" #include "HandleRef.h" #include #include #include #ifdef __cplusplus extern "C" { #endif /* Forward declarations */ struct PersonNameGroup; struct PatMeasure; struct PersonName; struct ExtNomenRef; /* PatientDemographicsSection */ typedef struct PatientDemographicsSection { Handle_t handle; FEFString_t *patientid /* OPTIONAL */; FEFString_t *ungroupedname /* OPTIONAL */; struct PersonNameGroup *characternamegroup /* OPTIONAL */; struct PersonNameGroup *ideographicnamegroup /* OPTIONAL */; struct PersonNameGroup *phoneticnamegroup /* OPTIONAL */; FEFString_t *birthname /* OPTIONAL */; PatientSex_t *sex /* OPTIONAL */; PatientRace_t *race /* OPTIONAL */; PatientType_t *patienttype /* OPTIONAL */; AbsoluteTime_t *dateofbirth /* OPTIONAL */; FEFString_t *patientgeninfo /* OPTIONAL */; struct PatMeasure *patientage /* OPTIONAL */; struct PatMeasure *gestationalage /* OPTIONAL */; struct PatMeasure *patientheight /* OPTIONAL */; struct PatMeasure *patientweight /* OPTIONAL */; struct PatMeasure *patientbirthlength /* OPTIONAL */; struct PatMeasure *patientbirthweight /* OPTIONAL */; FEFString_t *motherpatientid /* OPTIONAL */; struct PersonName *mothername /* OPTIONAL */; struct PatMeasure *patientheadcircumference /* OPTIONAL */; struct PatMeasure *patientbsa /* OPTIONAL */; FEFString_t *bedid /* OPTIONAL */; FEFString_t *diagnosticinfo /* OPTIONAL */; struct PatientDemographicsSection__diagnosticcodes { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *diagnosticcodes; HandleRef_t *admittingphysician /* OPTIONAL */; HandleRef_t *attendingphysician /* OPTIONAL */; AbsoluteTime_t *dateofprocedure /* OPTIONAL */; FEFString_t *proceduredescription /* OPTIONAL */; struct PatientDemographicsSection__procedurecodes { A_SEQUENCE_OF(struct ExtNomenRef) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } *procedurecodes; HandleRef_t *anaesthetist /* OPTIONAL */; HandleRef_t *surgeon /* OPTIONAL */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } PatientDemographicsSection_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PatientDemographicsSection; #ifdef __cplusplus } #endif /* Referred external types */ #include "PersonNameGroup.h" #include "PatMeasure.h" #include "PersonName.h" #include "ExtNomenRef.h" #endif /* _PatientDemographicsSection_H_ */ biosig-2.3.3/biosig4c++/t240/MetricMeasure.h0000664000175000017500000000135014105434233020415 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _MetricMeasure_H_ #define _MetricMeasure_H_ #include /* Including external dependencies */ #include "FEFFloat.h" #include "UnitsOfMeasurementCode.h" #include #ifdef __cplusplus extern "C" { #endif /* MetricMeasure */ typedef struct MetricMeasure { FEFFloat_t value; UnitsOfMeasurementCode_t m_unit; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } MetricMeasure_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_MetricMeasure; #ifdef __cplusplus } #endif #endif /* _MetricMeasure_H_ */ biosig-2.3.3/biosig4c++/t240/BodySiteCode.c0000664000175000017500000000720614105434233020166 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "BodySiteCode.h" int BodySiteCode_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void BodySiteCode_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->uper_decoder = asn_DEF_INTEGER.uper_decoder; td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) td->per_constraints = asn_DEF_INTEGER.per_constraints; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics; } void BodySiteCode_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { BodySiteCode_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } int BodySiteCode_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { BodySiteCode_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } asn_dec_rval_t BodySiteCode_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const void *bufptr, size_t size, int tag_mode) { BodySiteCode_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); } asn_enc_rval_t BodySiteCode_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { BodySiteCode_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } asn_dec_rval_t BodySiteCode_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, const void *bufptr, size_t size) { BodySiteCode_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); } asn_enc_rval_t BodySiteCode_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { BodySiteCode_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); } static ber_tlv_tag_t asn_DEF_BodySiteCode_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; asn_TYPE_descriptor_t asn_DEF_BodySiteCode = { "BodySiteCode", "BodySiteCode", BodySiteCode_free, BodySiteCode_print, BodySiteCode_constraint, BodySiteCode_decode_ber, BodySiteCode_encode_der, BodySiteCode_decode_xer, BodySiteCode_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_BodySiteCode_tags_1, sizeof(asn_DEF_BodySiteCode_tags_1) /sizeof(asn_DEF_BodySiteCode_tags_1[0]), /* 1 */ asn_DEF_BodySiteCode_tags_1, /* Same as above */ sizeof(asn_DEF_BodySiteCode_tags_1) /sizeof(asn_DEF_BodySiteCode_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ 0, 0, /* No members */ 0 /* No specifics */ }; biosig-2.3.3/biosig4c++/t240/fef.asn0000664000175000017500000014464614105434233016762 0ustar schloeglschloegl/* ASN.1 specification of the File Exchange Format for Vital Signs The info was manually extracted from CEN/TC251/PT-40/4002N005 A number of bugs and typos were fixed. $Id$ Copyright (C) 2009 Alois Schloegl This file is part of BioSig http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ ModuleTest DEFINITIONS ::= BEGIN /* B.1.1 ASN.1 built-in types used INTEGER ISO/IEC 8824-1:1998 Ch. 18 REAL ISO/IEC 8824-1:1998 Ch. 20 BIT-STRING ISO/IEC 8824-1:1998 Ch. 21 OCTET-STRING ISO/IEC 8824-1:1998 Ch. 22 SEQUENCE ISO/IEC 8824-1:1998 Ch. 24 SEQUENCE-OF ISO/IEC 8824-1:1998 Ch. 25 CHOICE ISO/IEC 8824-1:1998 Ch. 28 Tagged types ISO/IEC 8824-1:1998 Ch. 30 UTF8String ISO/IEC 8824-1:1998 Ch. 36.13; ISO/IEC 10646-1 Generalized time ISO/IEC 8824-1:1998 Ch. 41; ISO 8601 Constrained types ISO/IEC 8824-1:1998 Ch. 44 */ INT-U64 ::= INTEGER -- (0 .. 18446744073709551615) /* make asn1c v0.9.22 happy */ INT-I64 ::= INTEGER -- (-9223372036854775808 .. 9223372036854775807) /* reduced to make asn1c v0.9.22 happy */ INT-U32 ::= INTEGER (0 .. 4294967295) INT-I32 ::= INTEGER (-2147483648 .. 2147483647) INT-U16 ::= INTEGER (0 .. 65535) INT-I16 ::= INTEGER (-32768 .. 32767) INT-U8 ::= INTEGER (0 .. 255) INT-I8 ::= INTEGER (-128 .. 127) BITS-32 ::= BIT STRING SIZE (32) BITS-16 ::= BIT STRING SIZE (16) BITS-8 ::= BIT STRING SIZE (8) FEFString ::= UTF8String FEFFloat ::= REAL Fraction ::= SEQUENCE { numerator [1] INT-I32, -- INT-32 is not defined denominator [2] INT-I32 } AbsoluteRange ::= SEQUENCE { lowervalue [1] FEFFloat, uppervalue [2] FEFFloat } Handle ::= [APPLICATION 2337] INT-U16 HandleRef ::= INT-U16 DeviceCode ::= INT-U16 -- block A: Device Nomenclature UnitsOfMeasurementCode ::= INT-U16 -- block B: Units of Measurement MetricsCode ::= INT-U16 -- block C: Metrics BodySiteCode ::= INT-U16 -- block D: Body Sites AlertCode ::= INT-U16 -- block E: Alert Codes ExtNomenclatureCode ::= INT-U16 -- block F: External Nomenclatures ParameterGroupCode ::= INT-U16 -- unassigned block: Parameter Groups PrivateCode ::= INT-U16 -- code specified by the user or manufacturer -- ENV 13734 uses the term “PrivateOID†here Placeholder ::= [APPLICATION 6499] OCTET STRING -- missing definitions HealthCareProviderId ::= FEFString Address ::= FEFString UnitCode ::= FEFString ManufacturerID ::= CHOICE { oid [1] OBJECT IDENTIFIER, -- ISO 8824 object identifier uuid [2] OCTET STRING SIZE (16) -- ISO 11578 universal unique identifier } AbsoluteTime ::= GeneralizedTime RelativeTime ::= INT-U32 HighResRelativeTime ::= INT-U64 ObservationTime ::= SEQUENCE { absolutetimestamp [APPLICATION 2448] AbsoluteTime, --OPTIONAL, relativetimestamp [APPLICATION 2449] RelativeTime, --OPTIONAL, hirestimerelativestamp [APPLICATION 2537] HighResRelativeTime --OPTIONAL } SimpleColour ::= INTEGER { colblack (0), -- RGB=000 colred (1), -- RGB=100 colgreen (2), -- RGB=010 colyellow (3), -- RGB=110 colblue (4), -- RGB=001 colmagenta (5), -- RGB=101 colcyan (6), -- RGB=011 colwhite (7) -- RGB=111 } (0..65535) ExtNomenRef ::= SEQUENCE { nomenclatureid ExtNomenclatureCode, nomenclaturecode ANY DEFINED BY nomenclatureid } MetricMeasure ::= SEQUENCE { metricmeasurevalue [1] FEFFloat, metricmeasuremnit [2] UnitsOfMeasurementCode } PersonNameGroup ::= SEQUENCE { familyname [1] FEFString, givenname [2] FEFString, middlename [3] FEFString, prefix [4] FEFString, suffix [5] FEFString, degree [6] FEFString } PersonName ::= SEQUENCE { ungroupedname [APPLICATION 6001] FEFString OPTIONAL, characternamegroup [APPLICATION 6002] PersonNameGroup OPTIONAL, ideographicnamegroup [APPLICATION 6003] PersonNameGroup OPTIONAL, phoneticnamegroup [APPLICATION 6004] PersonNameGroup OPTIONAL -- at least one of the groups must be present -- this will be the characternamegroup for European names } -- -- Object Identifier Type as defined in nomenclature -- (do not confuse with ASN.1 OBJECT IDENTIFIER) -- OID-Type ::= INT-U16 -- 16 bit integer type SessionArchiveSection ::= [APPLICATION 7001] SEQUENCE { handle Handle, -- unique (within a file) handle s-archive-id [APPLICATION 2507] FEFString, s-archive-name [APPLICATION 2513] FEFString, s-archive-comments [APPLICATION 2530] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL, manufacturerspecific [APPLICATION 7002] ManufacturerSpecificSection OPTIONAL, healthcareprovider [APPLICATION 7003] HealthCareProviderSection OPTIONAL, demographics [APPLICATION 7004] PatientDemographicsSection, sessions [APPLICATION 7015] SEQUENCE SIZE (1..MAX) OF SessionTestSection, /* SIZE (1..*), -- to make asn1c v0.9.22 happy */ notes [APPLICATION 7016] SEQUENCE OF SessionNotesSection DEFAULT {} } ArchiveProtection ::= SEQUENCE { protectiontype [1] PrivateCode, protectionkey [2] ANY DEFINED BY protection-type } ManufacturerSpecificSection ::= SEQUENCE { manufacturerid [APPLICATION 6005] ManufacturerID, -- encodedentries [APPLICATION 6006] SEQUENCE OF ManufacturerSpecificEncoded DEFAULT {}, binaryentries [APPLICATION 6007] SEQUENCE OF ManufacturerSpecificBinary DEFAULT {} } ManufacturerSpecificEncoded ::= SEQUENCE { code [1] PrivateCode, data [2] ANY DEFINED BY code } ManufacturerSpecificBinary ::= SEQUENCE { code [1] PrivateCode, data [2] OCTET STRING } HealthCareProviderSection ::= SEQUENCE { identification [APPLICATION 6008] HealthCareProviderId, -- name [APPLICATION 6009] FEFString, -- address [APPLICATION 6010] Address OPTIONAL, -- placeholder Placeholder OPTIONAL, healthcareprofessionals [APPLICATION 7008] SEQUENCE OF HealthCareProfessionalSection DEFAULT {} } HealthCareProfessionalSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle COMPONENTS OF PersonName, -- use common person name attributes identification [APPLICATION 6011] FEFString OPTIONAL, -- optional textual unique identification identificationcode [APPLICATION 6012] ExtNomenRef OPTIONAL, -- optional coded unique identification authorization-level [APPLICATION 2481] Authorization OPTIONAL, -- optional organisation specific code function [APPLICATION 6048] FEFString OPTIONAL, -- optional textual function specification functioncode [APPLICATION 6049] ExtNomenRef OPTIONAL, -- optional coded function specification placeholder Placeholder OPTIONAL } Authorization ::= SEQUENCE { authorization-type [1] PrivateCode, authorization-key [2] ANY DEFINED BY authorization-type } PatientDemographicsSection ::= SEQUENCE { handle Handle, -- unique (within file) handle patientid [APPLICATION 2394] FEFString OPTIONAL, COMPONENTS OF PersonName, -- use common person name attributes birthname [APPLICATION 2398] FEFString OPTIONAL, -- maiden name sex [APPLICATION 2401] PatientSex OPTIONAL, race [APPLICATION 2526] PatientRace OPTIONAL, patienttype [APPLICATION 2402] PatientType OPTIONAL, dateofbirth [APPLICATION 2392] AbsoluteTime OPTIONAL, patientgeninfo [APPLICATION 2393] FEFString OPTIONAL, -- textual Patient related Information patientage [APPLICATION 2520] PatMeasure OPTIONAL, -- for neonatal, e.g. in hours or in weeks gestationalage [APPLICATION 2521] PatMeasure OPTIONAL, -- for neonatal patientheight [APPLICATION 2524] PatMeasure OPTIONAL, patientweight [APPLICATION 2527] PatMeasure OPTIONAL, patientbirthlength [APPLICATION 2522] PatMeasure OPTIONAL, patientbirthweight [APPLICATION 2523] PatMeasure OPTIONAL, motherpatientid [APPLICATION 2504] FEFString OPTIONAL, mothername [APPLICATION 2525] PersonName OPTIONAL, -- for neonatal patientheadcircumference[APPLICATION 2490] PatMeasure OPTIONAL, patientbsa [APPLICATION 2390] PatMeasure OPTIONAL, -- Body Surface Area, can be calculated bedid [APPLICATION 2501] FEFString OPTIONAL, diagnosticinfo [APPLICATION 2496] FEFString OPTIONAL, diagnosticcodes [APPLICATION 2492] SEQUENCE OF ExtNomenRef DEFAULT {}, admittingphysician [APPLICATION 2515] HandleRef OPTIONAL, -- for ICU; references HealthCareProfessionalSection attendingphysician [APPLICATION 2516] HandleRef OPTIONAL, -- for ICU; references HealthCareProfessionalSection dateofprocedure [APPLICATION 2518] AbsoluteTime OPTIONAL, -- for OR proceduredescription [APPLICATION 2495] FEFString OPTIONAL, -- for OR procedurecodes [APPLICATION 2493] SEQUENCE OF ExtNomenRef DEFAULT {}, -- for OR - procedure codes are specified in a -- nomenclature scheme not defined in this standard anaesthetist [APPLICATION 2479] HandleRef OPTIONAL, -- for OR; references HealthCareProfessionalSection surgeon [APPLICATION 2532] HandleRef OPTIONAL -- for OR; references HealthCareProfessionalSection } PatMeasure ::= SEQUENCE { value [1] FEFFloat, m-unit [2] UnitsOfMeasurementCode -- code for units of measure } -- Patient Sex according to ISO 5218 PatientSex ::= INTEGER { sex-unknown (0), male (1), female (2), sex-unspecified (9) } (0..65535) PatientType ::= INTEGER { pt-unspecified (0), adult (1), pediatric (2), neonatal (3) } (0..65535) -- Patient Race according to SCP ECG PatientRace ::= INTEGER { race-unspecified (0), race-caucasian (1), race-black (2), race-oriental (3) } (0..65535) SessionTestSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle st-archive-id [APPLICATION 2506] FEFString, st-archive-name [APPLICATION 2512] FEFString, st-archive-comments [APPLICATION 2529] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL, medicaldevicesystem [APPLICATION 7005] MedicalDeviceSystemSection, multimedia [APPLICATION 7006] SEQUENCE OF MultimediaSection DEFAULT {}, phases [APPLICATION 7017] SEQUENCE SIZE (1..MAX) OF SessionPhaseSection /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ } MedicalDeviceSystemSection ::= SEQUENCE { handle Handle, -- unique (within file) handle systemtype [APPLICATION 2438] DeviceCode, -- e.g. ventilator, monitor as -- defined in nomenclature systemmodel [APPLICATION 2344] SystemModel, -- model describes manufacturer and -- model no systemid [APPLICATION 2436] FEFString, -- manufacturer specified system ID -- e.g. serial number compatibilityid [APPLICATION 2336] INT-U32 OPTIONAL, -- for manufacturer use nomenclatureversion [APPLICATION 2376] INT-U32, -- version of nomenclature used by -- the system requirednomenclatureversion [APPLICATION 6013] AbsoluteTime, -- required revision of nomenclature to -- interpret any information from -- this medical device system usednomenclatureversion [APPLICATION 6014] AbsoluteTime, -- revision of nomenclature to -- interpret all information from -- this medical device system systemspecification [APPLICATION 2437] SEQUENCE OF SystemSpecEntry DEFAULT {}, -- defines functional components productionspecification [APPLICATION 2349] SEQUENCE OF ProdSpecEntry DEFAULT {}, -- component revisions, serial -- numbers etc. bedlabel [APPLICATION 2334] FEFString OPTIONAL, -- printable string identifying -- system location softid [APPLICATION 2350] FEFString OPTIONAL, -- settable, e.g. hospital -- inventory number operatingmode [APPLICATION 2374] PrivateCode OPTIONAL, applicationarea [APPLICATION 2317] ApplicationArea OPTIONAL, powerstatus [APPLICATION 2389] PowerStatus OPTIONAL, -- onBatteryoronMains altitude [APPLICATION 2316] INT-I16 OPTIONAL, -- above or below sea level in metres linefrequency [APPLICATION 2357] LineFrequency OPTIONAL, -- frequency of mains placeholder Placeholder OPTIONAL, components MedicalDeviceComponents } SystemModel ::= SEQUENCE { manufacturer [1] FEFString, model-number [2] FEFString } SystemSpecEntry ::= SEQUENCE { component-capab-id [1] PrivateCode, component-spec [2] ANY DEFINED BY component-capab-id } ProdSpecEntryType ::= INTEGER { unspecified (0), serial-number (1), part-number (2), hw-revision (3), sw-revision (4), fw-revision (5), protocol-revision (6) } (0..65535) ProdSpecEntry ::= SEQUENCE { spec-type [1] ProdSpecEntryType, component-id [2] PrivateCode, prod-spec [3] FEFString } ApplicationArea ::= INTEGER { area-unspec (0), area-operating-room (1), area-intensive-care (2) } (0..65535) PowerStatus ::= BIT STRING { onMains (0), onBattery (1), chargingFull (8), chargingTrickle (9), chargingOff (10) } SIZE(16) LineFrequency ::= INTEGER { line-f-unspec (0), line-f-50hz (1), line-f-60hz (2) } (0..65535) MedicalDeviceComponents ::= CHOICE { medicaldevice [APPLICATION 7009] VirtualMedicalDeviceSection, -- Simple MDS medicaldevices [APPLICATION 7010] SEQUENCE SIZE (2..MAX) OF VirtualMedicalDeviceSection, /* SIZE (2..*), -- to make asn1c v0.9.22 happy */ -- Hydra MDS subsystems [APPLICATION 7011] SEQUENCE SIZE (1..MAX) OF MedicalDeviceSystemSection /* SIZE (1..*), -- to make asn1c v0.9.22 happy */ -- Composite Single Bed MDS } VirtualMedicalDeviceSection ::= SEQUENCE { handle Handle, -- unique (within file) handle devicetype [APPLICATION 2351] DeviceCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of devicetype vmdmodel [APPLICATION 2344] SystemModel OPTIONAL, -- manufacturer and model number productionspecification [APPLICATION 2349] SEQUENCE OF ProdSpecEntry DEFAULT {}, -- serial numbers and revisions, -- only present if VMD represents an -- independent subsystem compatibilityid [APPLICATION 2336] INT-U32 OPTIONAL, -- static for manufacturer use parametergroup [APPLICATION 2346] ParameterGroupCode OPTIONAL, -- e.g. cardiovascular position [APPLICATION 2348] INT-U16 OPTIONAL, -- e.g. slot number, 0xffff marks -- an invalid or unknown position measurementprinciple [APPLICATION 2560] MsmtPrinciple OPTIONAL -- describes the physical principle -- of the measurement } MsmtPrinciple ::= BIT STRING { msp-chemical (1), msp-electrical (2), msp-impedance (3), msp-nuclear (4), msp-optical (5), msp-thermal (6), msp-biological (7), msp-mechanical (8), msp-manual (15) } SIZE(16) ChannelDescriptionSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle metrictype [APPLICATION 2351] MetricsCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of metrictype channelid [APPLICATION 2318] MetricsCode OPTIONAL, -- contains dynamic identification (e.g. a specific -- blood pressure label) compared to the -- static identification is in metrictype channelstatus [APPLICATION 2320] MetricStatus DEFAULT {}, -- usually part of an dynamic attribute change section parametergroup [APPLICATION 2346] ParameterGroupCode OPTIONAL, -- e.g. cardiovascular physicalchannelnr [APPLICATION 2319] INT-U16 DEFAULT 65535, -- e.g. ADC channel, 65535 (0xffff) marks -- an invalid or unknown channel measurementprinciple [APPLICATION 2560] MsmtPrinciple OPTIONAL -- describes the physical principle -- of the measurement } ChannelStatus ::= BIT STRING { chn-off (0), chn-not-ready (1), chn-standby (2), chn-transduc-discon (8), chn-hw-discon (9) } SIZE(16) MultimediaSection ::= SEQUENCE { starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, mimetype [APPLICATION 6017] FEFString, comments [APPLICATION 6018] Comments OPTIONAL, originallocation [APPLICATION 6019] FEFString OPTIONAL, placeholder [APPLICATION 6499] Placeholder OPTIONAL, contentorreference [APPLICATION 6020] ContentOrReference } Comments ::= SEQUENCE { commenttext [1] FEFString, commentator [2] HandleRef -- references HealthCareProfessionalSection } ContentOrReference ::= CHOICE { content [1] OCTET STRING, reference [2] FEFString } SessionPhaseSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, placeholder Placeholder OPTIONAL, descriptivedata [APPLICATION 7018] DescriptiveDataSection, measureddata [APPLICATION 7019] SEQUENCE SIZE (1..MAX) OF MeasuredDataSection /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ -- size = 1 except for streaming mode profile } DescriptiveDataSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle placeholder Placeholder OPTIONAL, realtimesadescs [APPLICATION 7020] SEQUENCE OF RealTimeSampleArrayDescriptiveDataSection DEFAULT {}, timesadescs [APPLICATION 7021] SEQUENCE OF TimeSampleArrayDescriptiveDataSection DEFAULT {}, distributionsadescs [APPLICATION 7022] SEQUENCE OF RealTimeSampleArrayDescriptiveDataSection DEFAULT {}, numericdescs [APPLICATION 7023] SEQUENCE OF NumericDescriptiveDataSection DEFAULT {}, enumerationdescs [APPLICATION 7024] SEQUENCE OF EnumerationDescriptiveDataSection DEFAULT {} } MetricDescriptiveDataSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle devicehandle [APPLICATION 6034] HandleRef, -- references the Virtual Medical Device Section or -- Channel Description Section this metric -- originates from metrictype [APPLICATION 2351] MetricsCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of metrictype metriccategory [APPLICATION 2367] MetricCategory DEFAULT mcat-unspec, -- the other COMPONENTS-OF MetricSpecification -- are not applicable for storage metricstatus [APPLICATION 2368] MetricStatus DEFAULT {}, -- usually part of an dynamic attribute change section measurementstatus [APPLICATION 2375] MeasurementStatus DEFAULT {}, -- usually part of an dynamic attribute change section metricid [APPLICATION 2347] MetricsCode OPTIONAL, -- contains dynamic identification (e.g. a specific -- blood pressure label) compared to the -- static identification is in metrictype metricidext [APPLICATION 2502] ExtNomenRef OPTIONAL, -- dynamic identification of the metric in a -- different nomenclature or dictionary. Use of -- this attribute severely limits interoperability -- of applications. unitcode [APPLICATION 2454] UnitsOfMeasurementCode OPTIONAL, -- dimension, e.g. 'mV' unitlabelstring [APPLICATION 2457] FEFString OPTIONAL, -- textual representation of dimension vmosourcelist [APPLICATION 2467] SEQUENCE OF MetricsCode DEFAULT {}, -- indicates sources of this metric in -- the form of references to other metrics metricsourcelist [APPLICATION 2366] SEQUENCE OF HandleRef DEFAULT {}, -- indicates sources of this metric in -- the form of a list of metric IDs msmtsitelist [APPLICATION 2430] SEQUENCE OF BodySiteCode DEFAULT {}, -- Measurement Sites, specified in -- internal nomenclature msmtsitelistext [APPLICATION 2551] SEQUENCE OF ExtNomenRef DEFAULT {}, -- Measurement Sites, specified in -- external nomenclature bodysitelist [APPLICATION 2429] SEQUENCE OF BodySiteCode DEFAULT {}, -- Body Sites, specified in internal nomenclature bodysitelistext [APPLICATION 2550] SEQUENCE OF ExtNomenRef DEFAULT {}, -- Body Sites, specified in external nomenclature metriccalibration [APPLICATION 2362] SEQUENCE OF MetricCalEntry DEFAULT {}, -- list time and state of calibrations colour [APPLICATION 2321] SimpleColour OPTIONAL, -- colour for representation measuremode [APPLICATION 2373] PrivateCode OPTIONAL, -- manufacturer measurement specific info measureperiod [APPLICATION 2443] MetricMeasure OPTIONAL, -- measurement repetition time, not necessarily -- the same as update period averagingperiod [APPLICATION 2535] MetricMeasure OPTIONAL, -- Time period used to average values, e.g. for -- an average flow of last hour metric starttime [APPLICATION 2538] AbsoluteTime OPTIONAL, -- time when measurement activity was started -- (e.g. when infusion was started) stoptime [APPLICATION 2539] AbsoluteTime OPTIONAL, -- Time when measurement activity was stopped metricinfolabelstring [APPLICATION 2365] FEFString OPTIONAL, -- textual attribute, allows e.g. to specify -- electrode displacements or other specific -- information about the measurement substance [APPLICATION 2542] ExtNomenRef OPTIONAL, -- substance that Metric pertains to, expressed -- in nomenclature that is defined outside of -- this standard substancelabelstring [APPLICATION 2508] FEFString OPTIONAL -- textual attribute that identifies the substance } /* already earlier defined PatMeasure ::= SEQUENCE { value [1] FEFFloat, m-unit [2] UnitsOfMeasurementCode -- code for units of measure } */ MetricStatus ::= BIT STRING { metric-off (0), metric-not-ready (1), metric-standby (2), metric-transduc-discon (8), metric-hw-discon (9) } SIZE(16) MetricCategory ::= INTEGER { mcat-unspec (0), auto-measurement (1), manual-measurement (2), auto-setting (3), manual-setting (4), auto-calculation (5), manual-calculation (6) } (0..65535) MetricCalEntry ::= SEQUENCE { cal-type [1] MetricCalType, cal-state [2] MetricCalState, cal-time [3] AbsoluteTime } MetricCalType ::= INTEGER { cal-unspec (0), cal-offset (1), cal-gain (2), cal-two-point (3) } (0..65535) MetricCalState ::= INTEGER { not-calibrated (0), cal-required (1), calibrated (2) } (0..65535) MeasurementStatus ::= BIT STRING { invalid (0), questionable (1), not-available (2), calibration-ongoing (3), test-data (4), demo-data (5), validated-data (8), -- relevant e.g. in an archive early-indication (9), -- early estimate of value msmt-ongoing (10) -- indicates that a new msmt is just -- being taken (episodic) } SIZE(16) SampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS-OF super class saspecification [APPLICATION 2413] SaSpec, -- static description of sample array and sample types compression [APPLICATION 2322] PrivateCode OPTIONAL, -- defines potential compression algorithm scaleandrangespec [APPLICATION 2416] ScaleRangeSpec, -- defines mapping between samples and actual -- values as well as measurement range, saphysiologicalrange[APPLICATION 2411] AbsoluteRange OPTIONAL, -- for optimum display scaling the physiological -- meaningful range is specified visualgrid [APPLICATION 2331] SEQUENCE OF SaGridEntry DEFAULT {}, -- defines gridline positions on displays -- and recorders -- (Note: tag NOM_ATTR_GRID_VIS_I32 used) sacalibrationdata [APPLICATION 2405] SEQUENCE OF SaCalData DEFAULT {}, -- defines positions of calibration markers on -- display and recorders -- (Note: tag NOM_ATTR_SA_CALIB_I32 used) filterspecification [APPLICATION 2329] SEQUENCE OF SaFilterEntry DEFAULT {}, -- ... sasignalfrequency [APPLICATION 2408] SaSignalFrequency OPTIONAL, -- max. signal frequency sameasureresolution [APPLICATION 2409] FEFFloat OPTIONAL -- ... } SaSpec ::= SEQUENCE { storagesize [1] INT-U8, -- e.g. 8 for 8bit samples, 16 for 16bit samples, significantbits [2] INT-U8 OPTIONAL, -- defines significant bits in one sample -- when not identical to storagesize storagedatatype [3] StorageDataType, flags [4] SaFlags DEFAULT {}, arraysize [5] INT-U16 -- defines the number of samples per -- signal in a subblock of a SAMDB } StorageDataType ::= INTEGER { unsigned (0), signed (1), ieee754float (2) } (0..255) -- allowed combinations of storagedatatype and storagedatasize are: -- storagedatatype storagesize -- unsigned 8 -- unsigned 16 -- unsigned 32 -- signed 8 -- signed 16 -- signed 32 -- ieee754float 32 -- ieee754float 64 SaFlags ::= BIT STRING { smoothcurve (0), -- for optimum display, use a smoothing algorithm delayedcurve (1), -- curve is delayed (not real time) saextvalrange (3) -- The non-significant bits in a sample are -- not 0 (or sign extended in the signed case) } SIZE(16) -- The scale and range definition attribute describes a relation between -- scaled values and absolute values. -- Note: If a wave does not represent absolute values, the absolute value -- fields should be equal to the scaled value fields. -- lowerabsolutevalue shall be smaller than upperabsolutevalue -- lowervaluescaled is the scaled value representing the absolute value -- lowerabsolutevalue -- uppervaluescaled is the scaled value representing the absolute value -- upperabsolutevalue ScaleRangeSpec ::= SEQUENCE { lowerabsolutevalue [1] FEFFloat, upperabsolutevalue [2] FEFFloat, lowervaluescaled [3] FEFFloat, uppervaluescaled [4] FEFFloat } SaFilterEntry ::= SEQUENCE { filtertype [1] FilterType, frequency [2] FEFFloat, filterorder [3] INT-I16 -- e.g. -1: 6 dB/oct } FilterType ::= INTEGER { other (0), lowpass (1), highpass (2), notch (3) } (0..65535) -- The visual grid definition attribute defines grid lines at different levels -- of grid lines. SaGridEntry ::= SEQUENCE { absolute-value [1] FEFFloat, level [3] INT-I16 } -- The calibration data definition attribute defines calibration markers -- on a display or on a recording strip. SaCalData ::= SEQUENCE { lowerabsolutevalue [1] FEFFloat, upperabsolutevalue [2] FEFFloat, increment [5] FEFFloat, -- value for each step of the stair cal-type [6] SaCalDataType } SaCalDataType ::= INTEGER { bar (0), -- display a calibration bar stair (1) -- display a calibration stair } (0..65535) -- Specification of signal frequency SaSignalFrequency ::= SEQUENCE { lowedgefreq [1] FEFFloat, -- in Hz highedgefreq [2] FEFFloat -- in Hz } RealTimeSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS OF super class sampleperiod [APPLICATION 2445] Fraction, -- in seconds, expressed as fraction sweepspeed [APPLICATION 2431] MetricMeasure OPTIONAL -- e.g. mm/s } TimeSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS-OF super class sampleperiod [APPLICATION 2445] Fraction, -- in seconds, expressed as fraction sweepspeed [APPLICATION 2431] MetricMeasure OPTIONAL -- e.g. mm/s } DistributionSampleArrayDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayDescriptiveDataSection, -- include COMPONENTS-OF super class distributionrangespec [APPLICATION 2403] DsaRangeSpec, -- maps array index to absolute value xunitcode [APPLICATION 2455] UnitsOfMeasurementCode OPTIONAL, -- applies to x-axis xunitlabelstring [APPLICATION 2458] FEFString OPTIONAL -- applies to x-axis } DsaRangeSpec ::= SEQUENCE { first-element-value [1] FEFFloat, last-element-value [2] FEFFloat } NumericDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS-OF super class numeasurerange [APPLICATION 2382] AbsoluteRange OPTIONAL, -- potential measurement range nuphysiologicalrange [APPLICATION 2383] AbsoluteRange OPTIONAL, -- physiological reasonable range (note that -- this is not an alarming range) numeasureresolution [APPLICATION 2381] FEFFloat OPTIONAL, -- resolution of measurement, minimum -- difference between two observed values displayresolution [APPLICATION 2327] DispResolution OPTIONAL, -- if different resolution is needed when -- value is displayed accuracy [APPLICATION 2378] FEFFloat OPTIONAL -- max. deviation of actual value from reported -- observed value (if it can be specified) } EnumerationDescriptiveDataSection ::= SEQUENCE { COMPONENTS OF MetricDescriptiveDataSection, -- include COMPONENTS OF super class enummeasurerange [APPLICATION 2561] SEQUENCE OF MetricsCode DEFAULT {}, -- list of possible observed value object OIDs, -- optional if the OID type is present in the -- observed value, out of scope otherwise enummeasurerangebits [APPLICATION 2568] BITS-32 OPTIONAL -- list of possible observed value bits in the -- bit string data type, optional if the BITS-32 -- type is used in the observed value, out of -- scope otherwise } MeasuredDataSection ::= SEQUENCE { realtimesas [APPLICATION 7025] SEQUENCE OF RealTimeSampleArrayMeasuredDataSection DEFAULT {}, timesas [APPLICATION 7026] SEQUENCE OF TimeSampleArrayMeasuredDataSection DEFAULT {}, distributionsas [APPLICATION 7027] SEQUENCE OF RealTimeSampleArrayMeasuredDataSection DEFAULT {}, numerics [APPLICATION 7028] SEQUENCE OF NumericMeasuredDataSection DEFAULT {}, enumerations [APPLICATION 7029] SEQUENCE OF EnumerationMeasuredDataSection DEFAULT {}, alerts [APPLICATION 7007] SEQUENCE OF AlertSection DEFAULT {}, attributechanges [APPLICATION 7030] SEQUENCE OF DynamicAttributeChangeSection DEFAULT {} } SampleArrayMeasuredDataSection ::= SEQUENCE { numberofsubblocks [APPLICATION 6035] INT-U32, subblocklength [APPLICATION 6036] Fraction, -- in seconds subblocksize [APPLICATION 6037] INT-U32, -- in octets metriclist [APPLICATION 6038] SEQUENCE SIZE (1..MAX) OF HandleRef /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ -- references to SampleArrayDescriptiveDataSection } SampleArrayMeasuredDataBlock ::= [APPLICATION 6039] OCTET STRING RealTimeSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } TimeSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, -- include COMPONENTS OF super class tsamarkerlist [APPLICATION 2452] SEQUENCE OF MarkerEntryRelTim DEFAULT {}, -- marks positions in wave snippets data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } MarkerEntryRelTim ::= SEQUENCE { markerid [1] MetricsCode, marktime [2] RelativeTime } DistributionSampleArrayMeasuredDataSection ::= SEQUENCE { COMPONENTS OF SampleArrayMeasuredDataSection, -- include COMPONENTS OF super class data SampleArrayMeasuredDataBlock -- measured data as SampleArrayMeasuredDataBlock } NumericMeasuredDataSection ::= SEQUENCE { metricref [APPLICATION 6050] HandleRef, -- reference to -- NumericDescriptiveDataSection nuobservedvalue ChoiceOfNuObsValue, -- simple or compound timestamp ObservationTime } ChoiceOfNuObsValue ::= CHOICE { nuobservedvalue [APPLICATION 2384] NuObsValue, -- e.g. measurement value, should also contain -- validity information to be useful! compoundnuobservedvalue [APPLICATION 2379] SEQUENCE SIZE (2..MAX) OF NuObsValue /* SIZE (2..*) -- to make asn1 v0.9.22 happy */ -- used when multiple values are represented -- in a single NU object (Structure is compound) } NuObsValue ::= SEQUENCE { metricid [1] MetricsCode OPTIONAL, state [2] MeasurementStatus DEFAULT {}, unitcode [3] UnitsOfMeasurementCode OPTIONAL, value [4] FEFFloat } -- value representation on a display (may be lower resolution) DispResolution ::= SEQUENCE { prepoint [1] INT-U8, -- digits before decimal point postpoint [2] INT-U8 -- digits after decimal point } -- ASN.1 source defining EnumerationMeasuredDataSection EnumerationMeasuredDataSection ::= SEQUENCE { metricref [APPLICATION 6050] HandleRef, -- reference to -- EnumerationDescriptiveDataSection enumobservedvalue ChoiceOfEnumObsValue, -- simple or compound enumadditionaldata [APPLICATION 2498] ANY DEFINED BY enumobservedvalue OPTIONAL, -- additional non normative event specific -- information can be provided (e.g. pacer -- parameters of pace pulse detect). Requires -- use of enum-obj-id in observed value! enumtimestamp ChoiceOfEnumTimeStamp -- one or more timestamps } EnumObsValue ::= SEQUENCE { metric-id [1] MetricsCode OPTIONAL, state [2] MeasurementStatus DEFAULT {}, value [3] EnumVal } ChoiceOfEnumObsValue ::= CHOICE { enumobservedvalue [APPLICATION 2462] EnumObsValue, compoundenumobservedvalue [APPLICATION 2463] SEQUENCE SIZE (1..MAX) OF EnumObsValue /* SIZE (1..*) -- to make asn1c v0.9.22 happy */ } EnumVal ::= CHOICE { enum-obj-id [1] MetricsCode, -- id of the metric enum-text-string [2] FEFString, -- free text enum-external-code [8] ExtNomenRef, -- code defined in other coding system enum-bit-str [16] BITS-32, -- bit string enum-record [33] EnumRecordMetric, -- record type defined Metric ID enum-record-oo [34] EnumRecordOO -- record type defined OO ID } EnumRecordMetric ::= SEQUENCE { record-type-code MetricsCode, record-data ANY DEFINED BY record-type-code } EnumRecordOO ::= SEQUENCE { record-type-code OID-Type, -- from OO Partition record-data ANY DEFINED BY record-type-code } ChoiceOfEnumTimeStamp ::= CHOICE { timestamp ObservationTime, absolutetimestamparray [APPLICATION 6042] SEQUENCE OF AbsoluteTime, relativetimestamparray [APPLICATION 6043] SEQUENCE OF RelativeTime, hirestimestamparray [APPLICATION 6044] SEQUENCE OF HighResRelativeTime } AlertSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle alerttype [APPLICATION 2351] AlertCode, -- static, mandatory type specification labelstring [APPLICATION 2343] FEFString OPTIONAL, -- textual representation of alerttype timestamp ObservationTime, -- time of change alertcondition [APPLICATION 2476] AlertCondition, limitspec [APPLICATION 2477] LimitSpecEntry OPTIONAL, -- specification of the supervised limit vmoreference [APPLICATION 6045] HandleRef OPTIONAL -- reference to MDSS, VMD or MDDS } AlertCondition ::= SEQUENCE { objreference [1] HandleRef, controls [2] AlertControls, alertflags [3] AlertFlags, -- supporting flags alertsource [4] MetricsCode, alertcode [5] AlertCode, alerttype [6] AlertType, -- defines type and severity of condition alertinfoid [7] PrivateCode OPTIONAL, -- specific info can be appended alertinfo [8] ANY DEFINED BY alertinfoid OPTIONAL } -- Alert Controls define flags to communicate status information -- relevant for alarm processor AlertControls ::= BIT STRING { acobjoff (0), -- the object supervised by the alert is off acchanoff (1), -- channel is off acallobjaloff (3), -- all alerts supervising the reference objects are off acalertoff (4) -- this alert supervisor process is off } SIZE(16) -- Alert Flags give additional support information how to process the condition, AlertFlags ::= BIT STRING { localaudible (1), -- indicates that the condition is audible -- at the local system remoteaudible (2), -- condition can be audible at remote (not suppressed) visuallatching (3), -- visible latching of the condition is allowed audiblelatching (4), -- audio latching of the condition is allowed derived (6), recordinhibit (8) -- do not start alarm recording } SIZE(16) -- Alert Type allows to distinguish severity of technical and -- physiological alarms AlertType ::= INTEGER { noalert (0), lowprital (1), -- low priority technical alarm medprital (2), -- medium priority technical alarm hiprital (4), -- high priority technical alarm lowpripal (256), -- awareness condition medpripal (512), -- prompt response required (abnormal condition) hipripal (1024) -- immediate response required (emergency condition) } (0..65535) -- Specification of the supervised limit range LimitSpecEntry ::= SEQUENCE { sectionhandle [1] HandleRef, alsourceid [2] MetricsCode, -- typically the metric ID of the measurement unitcode [3] UnitCode, -- from DIM partition limalstat [4] CurLimAlStat, limalval [5] AbsoluteRange } -- Current Limit Alert State - -- NOTE: The bits refer to the Limit Alarm only, not to the global alert -- state of the metric! CurLimAlStat ::= BIT STRING { limalertoff (0), -- if this bit is set, all alerts (both -- high and low) are off limlowoff (1), -- low limit violation detection is off limhighoff (2) -- high limit violation detection is off } SIZE(16) DynamicAttributeChangeSection ::= SEQUENCE { timestamp ObservationTime, -- time of change handle [APPLICATION 6041] HandleRef, -- reference to section whose attribute changed attribute [APPLICATION 6046] INT-U16, -- attribute code value [APPLICATION 6047] ANY DEFINED BY attribute OPTIONAL -- new value -- or removal of optional attribute if absent } -- ASN.1 source defining SessionNotesSection SessionNotesSection ::= SEQUENCE { handle Handle, -- unique (within a file) handle sn-id [APPLICATION 2505] FEFString, sn-name [APPLICATION 2511] FEFString, sn-comments [APPLICATION 2528] FEFString OPTIONAL, starttime [APPLICATION 2538] AbsoluteTime, stoptime [APPLICATION 2539] AbsoluteTime, findings [APPLICATION 2500] FEFString OPTIONAL, diagnosticscodes [APPLICATION 2492] SEQUENCE OF ExtNomenRef DEFAULT {}, diagnosisdescription [APPLICATION 2494] FEFString OPTIONAL, procedurecodes [APPLICATION 2493] SEQUENCE OF ExtNomenRef DEFAULT {}, proceduredescription [APPLICATION 2495] FEFString OPTIONAL, protection [APPLICATION 2519] ArchiveProtection OPTIONAL, placeholder Placeholder OPTIONAL } END biosig-2.3.3/biosig4c++/t240/ManufacturerID.h0000664000175000017500000000173414105434233020527 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #ifndef _ManufacturerID_H_ #define _ManufacturerID_H_ #include /* Including external dependencies */ #include #include #include #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum ManufacturerID_PR { ManufacturerID_PR_NOTHING, /* No components present */ ManufacturerID_PR_oid, ManufacturerID_PR_uuid } ManufacturerID_PR; /* ManufacturerID */ typedef struct ManufacturerID { ManufacturerID_PR present; union ManufacturerID_u { OBJECT_IDENTIFIER_t oid; OCTET_STRING_t uuid; } choice; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } ManufacturerID_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_ManufacturerID; #ifdef __cplusplus } #endif #endif /* _ManufacturerID_H_ */ biosig-2.3.3/biosig4c++/t240/MeasuredDataSection.c0000664000175000017500000003405214105434233021534 0ustar schloeglschloegl/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #include "MeasuredDataSection.h" static asn_TYPE_member_t asn_MBR_realtimesas_2[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_RealTimeSampleArrayMeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_realtimesas_tags_2[] = { (ASN_TAG_CLASS_APPLICATION | (7025 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_realtimesas_specs_2 = { sizeof(struct MeasuredDataSection__realtimesas), offsetof(struct MeasuredDataSection__realtimesas, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_realtimesas_2 = { "realtimesas", "realtimesas", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_realtimesas_tags_2, sizeof(asn_DEF_realtimesas_tags_2) /sizeof(asn_DEF_realtimesas_tags_2[0]) - 1, /* 1 */ asn_DEF_realtimesas_tags_2, /* Same as above */ sizeof(asn_DEF_realtimesas_tags_2) /sizeof(asn_DEF_realtimesas_tags_2[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_realtimesas_2, 1, /* Single element */ &asn_SPC_realtimesas_specs_2 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_timesas_4[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_TimeSampleArrayMeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_timesas_tags_4[] = { (ASN_TAG_CLASS_APPLICATION | (7026 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_timesas_specs_4 = { sizeof(struct MeasuredDataSection__timesas), offsetof(struct MeasuredDataSection__timesas, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_timesas_4 = { "timesas", "timesas", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_timesas_tags_4, sizeof(asn_DEF_timesas_tags_4) /sizeof(asn_DEF_timesas_tags_4[0]) - 1, /* 1 */ asn_DEF_timesas_tags_4, /* Same as above */ sizeof(asn_DEF_timesas_tags_4) /sizeof(asn_DEF_timesas_tags_4[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_timesas_4, 1, /* Single element */ &asn_SPC_timesas_specs_4 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_distributionsas_6[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_DistributionSampleArrayMeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_distributionsas_tags_6[] = { (ASN_TAG_CLASS_APPLICATION | (7027 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_distributionsas_specs_6 = { sizeof(struct MeasuredDataSection__distributionsas), offsetof(struct MeasuredDataSection__distributionsas, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_distributionsas_6 = { "distributionsas", "distributionsas", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_distributionsas_tags_6, sizeof(asn_DEF_distributionsas_tags_6) /sizeof(asn_DEF_distributionsas_tags_6[0]) - 1, /* 1 */ asn_DEF_distributionsas_tags_6, /* Same as above */ sizeof(asn_DEF_distributionsas_tags_6) /sizeof(asn_DEF_distributionsas_tags_6[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_distributionsas_6, 1, /* Single element */ &asn_SPC_distributionsas_specs_6 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_numerics_8[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_NumericMeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_numerics_tags_8[] = { (ASN_TAG_CLASS_APPLICATION | (7028 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_numerics_specs_8 = { sizeof(struct MeasuredDataSection__numerics), offsetof(struct MeasuredDataSection__numerics, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_numerics_8 = { "numerics", "numerics", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_numerics_tags_8, sizeof(asn_DEF_numerics_tags_8) /sizeof(asn_DEF_numerics_tags_8[0]) - 1, /* 1 */ asn_DEF_numerics_tags_8, /* Same as above */ sizeof(asn_DEF_numerics_tags_8) /sizeof(asn_DEF_numerics_tags_8[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_numerics_8, 1, /* Single element */ &asn_SPC_numerics_specs_8 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_enumerations_10[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_EnumerationMeasuredDataSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_enumerations_tags_10[] = { (ASN_TAG_CLASS_APPLICATION | (7029 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_enumerations_specs_10 = { sizeof(struct MeasuredDataSection__enumerations), offsetof(struct MeasuredDataSection__enumerations, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_enumerations_10 = { "enumerations", "enumerations", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_enumerations_tags_10, sizeof(asn_DEF_enumerations_tags_10) /sizeof(asn_DEF_enumerations_tags_10[0]) - 1, /* 1 */ asn_DEF_enumerations_tags_10, /* Same as above */ sizeof(asn_DEF_enumerations_tags_10) /sizeof(asn_DEF_enumerations_tags_10[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_enumerations_10, 1, /* Single element */ &asn_SPC_enumerations_specs_10 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_alerts_12[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_AlertSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_alerts_tags_12[] = { (ASN_TAG_CLASS_APPLICATION | (7007 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_alerts_specs_12 = { sizeof(struct MeasuredDataSection__alerts), offsetof(struct MeasuredDataSection__alerts, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_alerts_12 = { "alerts", "alerts", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_alerts_tags_12, sizeof(asn_DEF_alerts_tags_12) /sizeof(asn_DEF_alerts_tags_12[0]) - 1, /* 1 */ asn_DEF_alerts_tags_12, /* Same as above */ sizeof(asn_DEF_alerts_tags_12) /sizeof(asn_DEF_alerts_tags_12[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_alerts_12, 1, /* Single element */ &asn_SPC_alerts_specs_12 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_attributechanges_14[] = { { ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, &asn_DEF_DynamicAttributeChangeSection, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static ber_tlv_tag_t asn_DEF_attributechanges_tags_14[] = { (ASN_TAG_CLASS_APPLICATION | (7030 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_attributechanges_specs_14 = { sizeof(struct MeasuredDataSection__attributechanges), offsetof(struct MeasuredDataSection__attributechanges, _asn_ctx), 0, /* XER encoding is XMLDelimitedItemList */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_attributechanges_14 = { "attributechanges", "attributechanges", SEQUENCE_OF_free, SEQUENCE_OF_print, SEQUENCE_OF_constraint, SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_decode_xer, SEQUENCE_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_attributechanges_tags_14, sizeof(asn_DEF_attributechanges_tags_14) /sizeof(asn_DEF_attributechanges_tags_14[0]) - 1, /* 1 */ asn_DEF_attributechanges_tags_14, /* Same as above */ sizeof(asn_DEF_attributechanges_tags_14) /sizeof(asn_DEF_attributechanges_tags_14[0]), /* 2 */ 0, /* No PER visible constraints */ asn_MBR_attributechanges_14, 1, /* Single element */ &asn_SPC_attributechanges_specs_14 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_MeasuredDataSection_1[] = { { ATF_POINTER, 7, offsetof(struct MeasuredDataSection, realtimesas), (ASN_TAG_CLASS_APPLICATION | (7025 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_realtimesas_2, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "realtimesas" }, { ATF_POINTER, 6, offsetof(struct MeasuredDataSection, timesas), (ASN_TAG_CLASS_APPLICATION | (7026 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_timesas_4, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "timesas" }, { ATF_POINTER, 5, offsetof(struct MeasuredDataSection, distributionsas), (ASN_TAG_CLASS_APPLICATION | (7027 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_distributionsas_6, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "distributionsas" }, { ATF_POINTER, 4, offsetof(struct MeasuredDataSection, numerics), (ASN_TAG_CLASS_APPLICATION | (7028 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_numerics_8, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "numerics" }, { ATF_POINTER, 3, offsetof(struct MeasuredDataSection, enumerations), (ASN_TAG_CLASS_APPLICATION | (7029 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_enumerations_10, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "enumerations" }, { ATF_POINTER, 2, offsetof(struct MeasuredDataSection, alerts), (ASN_TAG_CLASS_APPLICATION | (7007 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_alerts_12, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "alerts" }, { ATF_POINTER, 1, offsetof(struct MeasuredDataSection, attributechanges), (ASN_TAG_CLASS_APPLICATION | (7030 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_attributechanges_14, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "attributechanges" }, }; static ber_tlv_tag_t asn_DEF_MeasuredDataSection_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_MeasuredDataSection_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (7007 << 2)), 5, 0, 0 }, /* alerts at 1209 */ { (ASN_TAG_CLASS_APPLICATION | (7025 << 2)), 0, 0, 0 }, /* realtimesas at 1189 */ { (ASN_TAG_CLASS_APPLICATION | (7026 << 2)), 1, 0, 0 }, /* timesas at 1193 */ { (ASN_TAG_CLASS_APPLICATION | (7027 << 2)), 2, 0, 0 }, /* distributionsas at 1197 */ { (ASN_TAG_CLASS_APPLICATION | (7028 << 2)), 3, 0, 0 }, /* numerics at 1201 */ { (ASN_TAG_CLASS_APPLICATION | (7029 << 2)), 4, 0, 0 }, /* enumerations at 1205 */ { (ASN_TAG_CLASS_APPLICATION | (7030 << 2)), 6, 0, 0 } /* attributechanges at 1212 */ }; static asn_SEQUENCE_specifics_t asn_SPC_MeasuredDataSection_specs_1 = { sizeof(struct MeasuredDataSection), offsetof(struct MeasuredDataSection, _asn_ctx), asn_MAP_MeasuredDataSection_tag2el_1, 7, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_MeasuredDataSection = { "MeasuredDataSection", "MeasuredDataSection", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ asn_DEF_MeasuredDataSection_tags_1, sizeof(asn_DEF_MeasuredDataSection_tags_1) /sizeof(asn_DEF_MeasuredDataSection_tags_1[0]), /* 1 */ asn_DEF_MeasuredDataSection_tags_1, /* Same as above */ sizeof(asn_DEF_MeasuredDataSection_tags_1) /sizeof(asn_DEF_MeasuredDataSection_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_MeasuredDataSection_1, 7, /* Elements count */ &asn_SPC_MeasuredDataSection_specs_1 /* Additional specs */ }; biosig-2.3.3/biosig4c++/tcl/0000775000175000017500000000000014105434245015574 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/tcl/Makefile.in0000664000175000017500000000116614105434233017642 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Tcl interface is available here # http://www.swig.org/Doc1.3/Tcl.html#Tcl all: swig -c++ -tcl biosig.i gcc -fPIC -c biosig_wrap.cxx -I/usr/include/tcl gcc -shared biosig_wrap.o ../libbiosig.so -o biosig.so clean: -rm *.cxx -rm *.o -rm *.so biosig-2.3.3/biosig4c++/tcl/Makefile0000664000175000017500000000116614105434245017240 0ustar schloeglschloegl####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile 2526 2010-08-27 21:46:28Z schloegl $ ### Copyright (C) 2010 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## # More information on SWIG-Tcl interface is available here # http://www.swig.org/Doc1.3/Tcl.html#Tcl all: swig -c++ -tcl biosig.i gcc -fPIC -c biosig_wrap.cxx -I/usr/include/tcl gcc -shared biosig_wrap.o ../libbiosig.so -o biosig.so clean: -rm *.cxx -rm *.o -rm *.so biosig-2.3.3/biosig4c++/tcl/biosig.i0000664000175000017500000002447414105434233017232 0ustar schloeglschloegl/* % % $Id$ % Copyright (C) 2008,2009 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ // swig.i %module biosig %{ #include "../biosig.h" %} %include typedef int64_t gdf_time; /* gdf time is represented in 64 bits */ typedef int64_t nrec_t; /* type for number of records */ /* list of file formats */ enum FileFormat { noFile, unknown, ABF, ACQ, ACR_NEMA, AIFC, AIFF, AINF, alpha, ARFF, ASCII_IBI, ASCII, AU, ASF, ATES, ATF, AVI, Axona, BCI2000, BDF, BESA, BIN, BKR, BLSC, BMP, BNI, BSCS, BrainVision, BrainVisionVAmp, BrainVisionMarker, BZ2, CDF, CFS, CFWB, CNT, CTF, DICOM, DEMG, EBS, EDF, EEG1100, EEProbe, EEProbe2, EEProbeAvr, EGI, EGIS, ELF, EMBLA, ePrime, ET_MEG, ETG4000, EVENT, EXIF, FAMOS, FEF, FITS, FLAC, GDF, GDF1, GIF, GTF, GZIP, HDF, HL7aECG, HEKA, ISHNE, ITX, JPEG, JSON, Lexicor, Matlab, MFER, MIDI, MIT, MM, MSI, MSVCLIB, MS_LNK, native, NeuroLoggerHEX, NetCDF, NEURON, NEX1, NIFTI, OGG, OpenXDF, PBMA, PBMN, PDF, PDP, Persyst, PGMA, PGMB, PLEXON, PNG, PNM, POLY5, PPMA, PPMB, PS, RDF, RIFF, SASXPT, SCP_ECG, SIGIF, Sigma, SMA, SND, SQLite, SPSS, STATA, SVG, SXI, SYNERGY, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK, WAV, WG1, WinEEG, WMF, XML, XPM, Z, ZIP, ZIP2, }; typedef struct CHANNEL_STRUCT { double PhysMin; /* physical minimum */ double PhysMax; /* physical maximum */ double DigMin; /* digital minimum */ double DigMax; /* digital maximum */ double Cal; /* gain factor */ double Off; /* bias */ char OnOff; char Label[MAX_LENGTH_LABEL+1]; /* Label of channel */ uint16_t LeadIdCode; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1]; /* transducer e.g. EEG: Ag-AgCl electrodes */ // char PhysDim[MAX_LENGTH_PHYSDIM+1] ; /* physical dimension */ /*PhysDim is now obsolete - use function PhysDim3(PhysDimCode) instead */ uint16_t PhysDimCode; /* code for physical dimension */ /* char* PreFilt; // pre-filtering */ float TOffset; /* time delay of sampling */ float LowPass; /* lowpass filter */ float HighPass; /* high pass */ float Notch; /* notch filter */ float XYZ[3]; /* sensor position */ // float Orientation[3]; // sensor direction // float Area; // area of sensor (e.g. for MEG) union { /* context specific channel information */ float Impedance; /* Electrode Impedance in Ohm, defined only if PhysDim = _Volt */ float fZ; /* ICG probe frequency, defined only if PhysDim = _Ohm */ }; uint16_t GDFTYP; /* data type */ uint32_t SPR; /* samples per record (block) */ } CHANNEL_TYPE; /* This structure defines the general (fixed) header */ typedef struct { float VERSION; /* GDF version number */ const char* FileName; enum FileFormat TYPE; /* type of file format */ struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint8_t IPaddr[16]; /* IP address of recording device (if applicable) */ double SampleRate; /* Sampling rate */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ gdf_time T0; /* starttime of recording */ uint32_t HeadLen; /* length of header in bytes */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ uint16_t NS; /* number of channels */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ #endif CHANNEL_TYPE *rerefCHANNEL; /* Patient specific information */ struct { gdf_time Birthday; /* Birthday of Patient */ // Age; /* the age is HDR.T0 - HDR.Patient.Birthday, even if T0 and Birthday are not known */ uint16_t Headsize[3]; /* circumference, nasion-inion, left-right mastoid in millimeter; */ char Name[MAX_LENGTH_NAME+1]; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ // char* Name; /* because for privacy protection it is by default not supported, support is turned on with FLAG.ANONYMOUS */ char Id[MAX_LENGTH_PID+1]; /* patient identification, identification code as used in hospital */ uint8_t Weight; /* weight in kilograms [kg] 0:unkown, 255: overflow */ uint8_t Height; /* height in centimeter [cm] 0:unkown, 255: overflow */ // BMI; /* the body-mass index = weight[kg]/height[m]^2 */ /* Patient classification */ int Sex; /* 0:Unknown, 1: Male, 2: Female */ int Handedness; /* 0:Unknown, 1: Right, 2: Left, 3: Equal */ int Smoking; /* 0:Unknown, 1: NO, 2: YES */ int AlcoholAbuse; /* 0:Unknown, 1: NO, 2: YES */ int DrugAbuse; /* 0:Unknown, 1: NO, 2: YES */ int Medication; /* 0:Unknown, 1: NO, 2: YES */ struct { int Visual; /* 0:Unknown, 1: NO, 2: YES, 3: Corrected */ int Heart; /* 0:Unknown, 1: NO, 2: YES, 3: Pacemaker */ } Impairment; } Patient; struct { char Recording[MAX_LENGTH_RID+1]; /* HL7, EDF, GDF, BDF replaces HDR.AS.RID */ char Technician; char* Hospital; uint64_t Equipment; /* identifies this software */ struct { /* see SCP: section1, tag14, MFER: tag23: "Manufacturer^model^version number^serial number" GDF: tag3: "Manufacturer\0model\0version\0number\0serial number\0" */ // char _field[MAX_LENGTH_MANUF+1]; /* buffer */ char* Name; char* Model; char* Version; char* SerialNumber; } Manufacturer; } ID; /* position of electrodes; see also HDR.CHANNEL[k].XYZ */ struct { float REF[3]; /* XYZ position of reference electrode */ float GND[3]; /* XYZ position of ground electrode */ } ELEC; /* EVENTTABLE */ struct { double SampleRate; /* for converting POS and DUR into seconds */ uint16_t *TYP; /* defined at ../biosig4matlab/doc/eventcodes.txt */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ #if (BIOSIG_VERSION >= 10500) gdf_time *TimeStamp ATT_ALI; /* store time stamps */ #endif char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ uint32_t N; /* number of events */ uint16_t LenCodeDesc; /* length of CodeDesc Table */ } EVENT; struct { /* flags */ char OVERFLOWDETECTION; /* overflow & saturation detection 0: OFF, !=0 ON */ char UCAL; /* UnCalibration 0: scaling !=0: NO scaling - raw data return */ char ANONYMOUS; /* 1: anonymous mode, no personal names are processed */ char ROW_BASED_CHANNELS; /* 0: column-based data [default]; 1: row-based data */ char TARGETSEGMENT; /* in multi-segment files (like Nihon-Khoden, EEG1100), it is used to select a segment */ } FLAG; CHANNEL_TYPE *CHANNEL; struct { /* File specific data */ #ifdef ZLIB_H gzFile gzFID; #endif #ifdef _BZLIB_H // BZFILE* bzFID; #endif FILE* FID; /* file handle */ size_t POS; /* current reading/writing position [in blocks] */ // int Des; /* file descriptor */ uint8_t OPEN; /* 0: closed, 1:read, 2: write */ uint8_t LittleEndian; uint8_t COMPRESSION; /* 0: no compression 9: best compression */ // int DES; /* descriptor for streams */ } FILE; /* internal variables (not public) */ struct { const char* B4C_ERRMSG; /* error message */ // char PID[MAX_LENGTH_PID+1]; /* use HDR.Patient.Id instead */ // char* RID; /* recording identification */ // uint32_t spb; /* total samples per block */ // uint32_t bpb; /* total bytes per block */ // uint32_t bpb8; /* total bits per block */ uint8_t* Header; // uint8_t* rawEventData; // uint8_t* rawdata; /* raw data block */ // char flag_collapsed_rawdata; /*0 if rawdata contain obsolete channels, too. */ // nrec_t first; /* first block loaded in buffer - this is equivalent to hdr->FILE.POS */ // nrec_t length; /* number of block(s) loaded in buffer */ uint8_t* auxBUF; /* auxillary buffer - used for storing EVENT.CodeDesc, MIT FMT infor */ char* bci2000; // uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ enum B4C_ERROR B4C_ERRNUM; /* error code */ // char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ } AS; void *aECG; } HDRTYPE; HDRTYPE* constructHDR(const unsigned NS, const unsigned N_EVENT); void destructHDR(HDRTYPE* hdr); HDRTYPE* sopen(const char* FileName, const char* MODE, HDRTYPE* hdr); int sclose(HDRTYPE* hdr); size_t sread(biosig_data_type* data, size_t start, size_t length, HDRTYPE* hdr); size_t swrite(const biosig_data_type *data, size_t nelem, HDRTYPE* hdr); int seof(HDRTYPE* hdr); void srewind(HDRTYPE* hdr); int sseek(HDRTYPE* hdr, long int offset, int whence); long int stell(HDRTYPE* hdr); int serror2(HDRTYPE* hdr); int hdr2ascii(HDRTYPE* hdr, FILE *fid, int verbosity); int RerefCHANNEL(HDRTYPE *hdr, void *ReRef, char rrtype); const char* GetFileTypeString(enum FileFormat FMT); uint16_t PhysDimCode(char* PhysDim0); char* PhysDim3(uint16_t PhysDimCode); /* HDRTYPE* sopen(char *filename); %{ HDRTYPE* sopen(char *filename) { HDRTYPE *hdr = constructHDR(0,0); hdr = sopen(filename, "r", hdr); return hdr; } %} int sclose(HDRTYPE *hdr); %{ int sclose(HDRTYPE *hdr) { sclose(hdr); destructHDR(hdr); return 0; } %} */ void serror(); %{ void _serror() { fprintf(stderr,"Use of SERROR is deprecated - use serror2(HDR) instead"); serror(); } %} void hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig-2.3.3/biosig4c++/biosig-dev.h0000775000175000017500000011517614105434233017226 0ustar schloeglschloegl/* % Copyright (C) 2005-2020 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, or (at your option) any later version. */ /* Internal definitions (external API is defined in biosig.h) */ /****************************************************************************/ /** **/ /** CONSTANTS and Global variables **/ /** **/ /****************************************************************************/ #ifndef __BIOSIG_INTERNAL_H__ #define __BIOSIG_INTERNAL_H__ #include #include #include #if defined(__MINGW32__) #include #endif #include #include "physicalunits.h" #ifdef __cplusplus extern "C" { #endif #ifdef NDEBUG #define VERBOSE_LEVEL 0 // turn off debugging information, but its only used without NDEBUG #else extern int VERBOSE_LEVEL; // used for debugging, variable is always defined #endif /* Including ZLIB enables reading gzipped files (they are decompressed on-the-fly) The output files can be zipped, too. */ #ifdef HAVE_ZLIB #include #ifndef ZLIB_H #if defined(__MINGW64__) #include "win64/zlib/zlib.h" #elif defined(__MINGW32__) #include "win32/zlib/include/zlib.h" #endif #endif #endif #ifdef HAVE_CHOLMOD #ifdef __APPLE__ #include #else #include #endif #endif #ifdef HAVE_HDF5 #include #endif #ifdef WITH_NIFTI #include #endif #ifdef WITH_GSL #include #endif #ifdef __WIN32__ #define FILESEP '\\' char *getlogin (void); #else #define FILESEP '/' #endif /* test whether HDR.CHANNEL[].{bi,bi8} can be replaced, reduction of header size by about 3% currently this is not working, because FAMOS seems to need it. //#define NO_BI */ /* External API definitions - this was part of old biosig.h */ // #include "biosig.h" /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ #define BIOSIG_VERSION_MAJOR 3 #define BIOSIG_VERSION_MINOR 0 #define BIOSIG_PATCHLEVEL 1 // for backward compatibility #define BIOSIG_VERSION_STEPPING BIOSIG_PATCHLEVEL #define BIOSIG_VERSION (BIOSIG_VERSION_MAJOR * 10000 + BIOSIG_VERSION_MINOR * 100 + BIOSIG_PATCHLEVEL) // biosigCHECK_VERSION returns true if BIOSIG_VERSION is at least a.b.c #define biosigCHECK_VERSION(a,b,c) (BIOSIG_VERSION >= ( 10000*(a) + 100*(b) + (c) ) ) #if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_WIN64) typedef __int64 ssize_t; typedef unsigned __int64 size_t; #else typedef __int32 ssize_t; typedef unsigned __int32 size_t; #endif typedef unsigned __int64 uint64_t; typedef __int64 int64_t; typedef unsigned __int32 uint32_t; typedef __int32 int32_t; typedef __int16 int16_t; typedef unsigned __int8 uint8_t; typedef __int8 int8_t; #else #include #endif #include "gdftime.h" /* * pack structures to fulfil following requirements: * (1) Matlab v7.3+ requires 8 byte alignment * (2) in order to use mingw-compiled libbiosig with MS' VisualStudio, * the structurs must be packed in a MS compatible way. */ #pragma pack(push, 8) //* this is probably redundant to the #pragma pack(8) statement, its here to do it the gnu way, too. */ #ifdef __GNUC__ #define ATT_ALI __attribute__ ((aligned (8))) #define ATT_DEPREC __attribute__ ((deprecated)) #else #define ATT_ALI #define ATT_DEPREC #endif #if defined(_MINGW32__) || defined(__CYGWIN__) #pragma ms_struct on #define ATT_MSSTRUCT __attribute__ ((ms_struct)) #else #define ATT_MSSTRUCT #endif /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * biosig_data_type data type of internal data format * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ typedef double biosig_data_type; /****************************************************************************/ /** **/ /** CONSTANTS and Global variables **/ /** **/ /****************************************************************************/ /* for error handling */ enum B4C_ERROR { B4C_NO_ERROR=0, B4C_FORMAT_UNKNOWN, B4C_FORMAT_UNSUPPORTED, B4C_CANNOT_OPEN_FILE, B4C_CANNOT_WRITE_FILE, B4C_CANNOT_APPEND_FILE, B4C_INSUFFICIENT_MEMORY, B4C_ENDIAN_PROBLEM, B4C_CRC_ERROR, B4C_DATATYPE_UNSUPPORTED, B4C_SCLOSE_FAILED, B4C_DECOMPRESSION_FAILED, B4C_MEMORY_ALLOCATION_FAILED, B4C_RAWDATA_COLLAPSING_FAILED, B4C_REREF_FAILED, B4C_INCOMPLETE_FILE, B4C_UNSPECIFIC_ERROR, B4C_CHAR_ENCODING_UNSUPPORTED }; #ifdef BIN #undef BIN // needed for biosig4perl #endif #ifdef EVENT #undef EVENT // defined by MS VC++ #endif /* list of file formats */ enum FileFormat { noFile, unknown, ABF, ABF2, ACQ, ACR_NEMA, AIFC, AIFF, AINF, alpha, ARFF, ASCII_IBI, ASCII, AU, ASF, ATES, ATF, AVI, AXG, Axona, BCI2000, BDF, BESA, BIN, BKR, BLSC, BMP, BNI, BSCS, BrainVision, BrainVisionVAmp, BrainVisionMarker, BZ2, CDF, CFS, CFWB, CNT, CTF, DICOM, DEMG, EBS, EDF, EEG1100, EEProbe, EEProbe2, EEProbeAvr, EGI, EGIS, ELF, EMBLA, EMSA, ePrime, ET_MEG, ETG4000, EVENT, EXIF, FAMOS, FEF, FIFF, FITS, FLAC, GDF, GDF1, GIF, GTF, GZIP, HDF, HL7aECG, HEKA, IBW, ISHNE, ITX, JPEG, JSON, Lexicor, Matlab, MFER, MIDI, MIT, MM, MSI, MSVCLIB, MS_LNK, MX, native, NeuroLoggerHEX, NetCDF, NEURON, NEV, NEX1, NIFTI, NUMPY, OGG, OpenXDF, PBMA, PBMN, PDF, PDP, Persyst, PGMA, PGMB, PLEXON, PNG, PNM, POLY5, PPMA, PPMB, PS, RDF, RIFF, SASXPT, SCP_ECG, SIGIF, Sigma, SMA, SMR, SND, SQLite, SPSS, STATA, SVG, SXI, SYNERGY, TDMS, TIFF, TMS32, TMSiLOG, TRC, UNIPRO, VRML, VTK, WAV, WCP, WG1, WinEEG, WMF, XML, XPM, Z, ZIP, ZIP2, RHD2000, RHS2000, IntanCLP, EBNEURO, SigViewerEventsCSV, XDF, EAS, EZ3, ARC, LastPlaceHolder, invalid=0xffff }; /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ typedef int64_t nrec_t; /* type for number of records */ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /* This structure defines the header for each channel (variable header) */ // TODO: change fixed length strings to dynamically allocated strings #define MAX_LENGTH_LABEL 80 // TMS: 40, AXG: 79 #define MAX_LENGTH_TRANSDUCER 80 #if (BIOSIG_VERSION < 10600) #define MAX_LENGTH_PHYSDIM 20 // DEPRECATED - DO NOT USE #else #undef MAX_LENGTH_PHYSDIM #endif #define MAX_LENGTH_PID 80 // length of Patient ID: MFER<65, GDF<67, EDF/BDF<81, etc. #define MAX_LENGTH_RID 80 // length of Recording ID: EDF,GDF,BDF<80, HL7 ? #define MAX_LENGTH_NAME 132 // max length of personal name: MFER<=128, EBS<=33*4 #define MAX_LENGTH_MANUF 128 // max length of manufacturer field: MFER<128 #define MAX_LENGTH_TECHNICIAN 128 // max length of manufacturer field: SCP<41 typedef struct CHANNEL_STRUCT { double PhysMin ATT_ALI; /* physical minimum */ double PhysMax ATT_ALI; /* physical maximum */ double DigMin ATT_ALI; /* digital minimum */ double DigMax ATT_ALI; /* digital maximum */ double Cal ATT_ALI; /* gain factor */ double Off ATT_ALI; /* bias */ char Label[MAX_LENGTH_LABEL+1] ATT_ALI; /* Label of channel */ char OnOff ATT_ALI; /* 0: channel is off, not consider for data output; 1: channel is turned on; 2: channel containing time axis */ uint16_t LeadIdCode ATT_ALI; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1] ATT_ALI; /* transducer e.g. EEG: Ag-AgCl electrodes */ #ifdef MAX_LENGTH_PHYSDIM char PhysDim[MAX_LENGTH_PHYSDIM+1] ATT_ALI ATT_DEPREC; /* DONOT USE - use PhysDim3(PhysDimCode) instead */ #endif uint16_t PhysDimCode ATT_ALI; /* code for physical dimension - PhysDim3(PhysDimCode) returns corresponding string */ float TOffset ATT_ALI; /* time delay of sampling */ float LowPass ATT_ALI; /* lowpass filter */ float HighPass ATT_ALI; /* high pass */ float Notch ATT_ALI; /* notch filter */ float XYZ[3] ATT_ALI; /* sensor position */ union { /* context specific channel information */ float Impedance ATT_ALI; /* Electrode Impedance in Ohm, defined only if PhysDim = _Volt */ float fZ ATT_ALI; /* ICG probe frequency, defined only if PhysDim = _Ohm */ } ATT_ALI; /* this part should not be used by application programs */ uint8_t* bufptr ATT_ALI; /* pointer to buffer: NRec<=1 and bi,bi8 not used */ uint32_t SPR ATT_ALI; /* samples per record (block) */ uint32_t bi ATT_ALI; /* start byte (byte index) of channel within data block */ uint32_t bi8 ATT_ALI; /* start bit (bit index) of channel within data block */ uint16_t GDFTYP ATT_ALI; /* data type */ } CHANNEL_TYPE ATT_ALI ATT_MSSTRUCT; /* This structure defines the general (fixed) header */ typedef struct HDR_STRUCT { char* FileName ATT_ALI; /* FileName - dynamically allocated, local copy of file name */ union { // workaround for transition to cleaner fieldnames float VERSION; /* GDF version number */ float Version; /* GDF version number */ } ATT_ALI; union { // workaround for transition to cleaner fieldnames enum FileFormat TYPE; /* type of file format */ enum FileFormat Type; /* type of file format */ } ATT_ALI; struct { size_t size[2] ATT_ALI; /* size {rows, columns} of data block */ biosig_data_type* block ATT_ALI; /* data block */ } data ATT_ALI; uint8_t IPaddr[16] ATT_ALI; /* IP address of recording device (if applicable) */ double SampleRate ATT_ALI; /* Sampling rate */ nrec_t NRec ATT_ALI; /* number of records/blocks -1 indicates length is unknown. */ gdf_time T0 ATT_ALI; /* starttime of recording */ uint32_t HeadLen ATT_ALI; /* length of header in bytes */ uint32_t SPR ATT_ALI; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ uint32_t LOC[4] ATT_ALI; /* location of recording according to RFC1876 */ uint16_t NS ATT_ALI; /* number of channels */ int16_t tzmin ATT_ALI; /* time zone : minutes east of UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib ATT_ALI; /* re-referencing matrix */ #else void *Calib ATT_ALI; /* re-referencing matrix */ #endif CHANNEL_TYPE *rerefCHANNEL ATT_ALI; /* Patient specific information */ struct { gdf_time Birthday; /* Birthday of Patient */ // Age; // the age is HDR.T0 - HDR.Patient.Birthday, even if T0 and Birthday are not known uint16_t Headsize[3]; /* circumference, nasion-inion, left-right mastoid in millimeter; */ /* Patient Name: * can consist of up to three components, separated by the unit separator ascii(31), 0x1f, containing in that order Last name, first name, second last name (see also SCP-ECG specification EN1064, Section 1, tag 0, 1, and 3) * for privacy protection this field is by default not supported, support can be turned on with FLAG.ANONYMOUS */ char Name[MAX_LENGTH_NAME+1]; char Id[MAX_LENGTH_PID+1]; /* patient identification, identification code as used in hospital */ uint8_t Weight; /* weight in kilograms [kg] 0:unkown, 255: overflow */ uint8_t Height; /* height in centimeter [cm] 0:unkown, 255: overflow */ // BMI; // the body-mass index = weight[kg]/height[m]^2 /* Patient classification */ int8_t Sex; /* 0:Unknown, 1: Male, 2: Female */ int8_t Handedness; /* 0:Unknown, 1: Right, 2: Left, 3: Equal */ int8_t Smoking; /* 0:Unknown, 1: NO, 2: YES */ int8_t AlcoholAbuse; /* 0:Unknown, 1: NO, 2: YES */ int8_t DrugAbuse; /* 0:Unknown, 1: NO, 2: YES */ int8_t Medication; /* 0:Unknown, 1: NO, 2: YES */ struct { int8_t Visual; /* 0:Unknown, 1: NO, 2: YES, 3: Corrected */ int8_t Heart; /* 0:Unknown, 1: NO, 2: YES, 3: Pacemaker */ } Impairment; } Patient ATT_ALI; struct { char Recording[MAX_LENGTH_RID+1]; /* HL7, EDF, GDF, BDF replaces HDR.AS.RID */ char* Technician; char* Hospital; /* recording institution */ uint64_t Equipment; /* identifies this software */ struct { /* see SCP: section1, tag14, MFER: tag23: "Manufacturer^model^version number^serial number" */ const char* Name; const char* Model; const char* Version; const char* SerialNumber; char _field[MAX_LENGTH_MANUF+1]; /* buffer */ } Manufacturer; } ID ATT_ALI; /* position of electrodes; see also HDR.CHANNEL[k].XYZ */ struct { float REF[3]; /* XYZ position of reference electrode */ float GND[3]; /* XYZ position of ground electrode */ } ELEC ATT_ALI; /* EVENTTABLE */ struct { double SampleRate ATT_ALI; /* for converting POS and DUR into seconds */ uint16_t *TYP ATT_ALI; /* defined at http://biosig.svn.sourceforge.net/viewvc/biosig/trunk/biosig/doc/eventcodes.txt */ uint32_t *POS ATT_ALI; /* starting position [in samples] using a 0-based indexing */ uint32_t *DUR ATT_ALI; /* duration [in samples] */ uint16_t *CHN ATT_ALI; /* channel number; 0: all channels */ #if (BIOSIG_VERSION >= 10500) gdf_time *TimeStamp ATT_ALI; /* store time stamps */ #endif const char* *CodeDesc ATT_ALI; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ uint32_t N ATT_ALI; /* number of events */ uint16_t LenCodeDesc ATT_ALI; /* length of CodeDesc Table */ } EVENT ATT_ALI; struct { /* flags */ char OVERFLOWDETECTION; /* overflow & saturation detection 0: OFF, !=0 ON */ char UCAL; /* UnCalibration 0: scaling !=0: NO scaling - raw data return */ char ANONYMOUS; /* 1: anonymous mode, no personal names are processed */ char ROW_BASED_CHANNELS; /* 0: column-based data [default]; 1: row-based data */ char TARGETSEGMENT; /* in multi-segment files (like Nihon-Khoden, EEG1100), it is used to select a segment */ } FLAG ATT_ALI; CHANNEL_TYPE *CHANNEL ATT_ALI; // moving CHANNEL after the next struct (HDR.FILE) gives problems at AMD64 MEX-file. // perhaps some alignment problem. struct { /* File specific data */ #ifdef ZLIB_H gzFile gzFID; #else void* gzFID; #endif #ifdef _BZLIB_H // BZFILE* bzFID; #endif FILE* FID; /* file handle */ size_t size; /* size of file - experimental: only partly supported */ size_t POS; /* current reading/writing position [in blocks] */ //size_t POS2; // current reading/writing position [in samples] */ int Des; /* file descriptor */ int DES; /* descriptor for streams */ uint8_t OPEN; /* 0: closed, 1:read, 2: write */ uint8_t LittleEndian; /* 1 if file is LittleEndian data format and 0 for big endian data format*/ uint8_t COMPRESSION; /* 0: no compression 9: best compression */ } FILE ATT_ALI; /* internal variables (not public) */ struct { const char* B4C_ERRMSG; /* error message */ // char PID[MAX_LENGTH_PID+1]; // use HDR.Patient.Id instead // char* RID; // recording identification uint32_t bpb; /* total bytes per block */ uint32_t bpb8; /* total bits per block */ uint8_t* Header; uint8_t* rawEventData; uint8_t* rawdata; /* raw data block */ size_t first; /* first block loaded in buffer - this is equivalent to hdr->FILE.POS */ size_t length; /* number of block(s) loaded in buffer */ uint8_t* auxBUF; /* auxillary buffer - used for storing EVENT.CodeDesc, MIT FMT infor, alpha:rawdata header */ union { char* bci2000; /* application specific free text field */ char* fpulse; char* stimfit; }; uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ enum B4C_ERROR B4C_ERRNUM; /* error code */ char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ } AS ATT_ALI; void *aECG; /* used as an pointer to (non-standard) auxilary information - mostly used for hacks */ uint64_t viewtime; /* used by edfbrowser */ #if (BIOSIG_VERSION >= 10500) struct { /* This part contains Section 7-11 of the SCP-ECG format without its 16 byte "Section ID header". These sections are also stored in GDF Header 3 (tag 9-13) It is mostly used for SCP<->GDF conversion. The pointers points into hdr->AS.Header, so do not dynamically re-allocate the pointers. */ const uint8_t* Section7; const uint8_t* Section8; const uint8_t* Section9; const uint8_t* Section10; const uint8_t* Section11; uint32_t Section7Length; uint32_t Section8Length; uint32_t Section9Length; uint32_t Section10Length; uint32_t Section11Length; } SCP; #endif } HDRTYPE ATT_MSSTRUCT; /* This structure defines codes and groups of the event table */ // Desription of event codes struct etd_t { uint16_t typ; // used in HDR.EVENT.TYP uint16_t groupid; // defines the group id as used in EventCodeGroups below const char* desc; // name/description of event code // const decrease signifitiantly number of warning } ATT_MSSTRUCT; // Groups of event codes struct event_groups_t { uint16_t groupid; const char* GroupDescription; // const decrease signifitiantly number of warning } ATT_MSSTRUCT; struct FileFormatStringTable_t { enum FileFormat fmt; const char* FileTypeString; } ATT_MSSTRUCT; struct NomenclatureAnnotatedECG_t { uint16_t part; uint16_t code10; uint32_t cf_code10; const char *refid; } ATT_MSSTRUCT; extern const struct etd_t ETD [] __attribute__ ((visibility ("default") )); extern const struct event_groups_t EventCodeGroups [] __attribute__ ((visibility ("default") )); extern const struct FileFormatStringTable_t FileFormatStringTable []; typedef struct { const char *free_text_event_limiter; } biosig_options_type; HDRTYPE* sopen_extended(const char* FileName, const char* MODE, HDRTYPE* hdr, biosig_options_type* options) __attribute__ ((visibility ("default") )); /* reset structure packing to default settings */ #pragma pack(pop) #if defined(_MINGW32__) || defined(__CYGWIN__) #pragma ms_struct reset #endif #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if 0 #elif defined(__linux__) # include # include #elif defined(__GLIBC__) // for Hurd # include # include #elif defined(__CYGWIN__) # include # include #elif defined(__WIN32__) || defined(_WIN32) # include # define __BIG_ENDIAN 4321 # define __LITTLE_ENDIAN 1234 # define __BYTE_ORDER __LITTLE_ENDIAN # define bswap_16(x) __builtin_bswap16(x) # define bswap_32(x) __builtin_bswap32(x) # define bswap_64(x) __builtin_bswap64(x) # include # if defined(__MINGW32__) # include # endif # if BYTE_ORDER == LITTLE_ENDIAN # define htobe16(x) htons(x) # define htole16(x) (x) # define be16toh(x) ntohs(x) # define le16toh(x) (x) # define htobe32(x) htonl(x) # define htole32(x) (x) # define be32toh(x) ntohl(x) # define le32toh(x) (x) # define htole64(x) (x) # if defined(__MINGW32__) # define htobe64(x) __builtin_bswap64(x) # define be64toh(x) __builtin_bswap64(x) # else # define ntohll(x) (((_int64)(ntohl((int)((x << 32) >> 32))) << 32) | (unsigned int)ntohl(((int)(x >> 32)))) # define htonll(x) ntohll(x) # define htobe64(x) htonll(x) # define be64toh(x) ntohll(x) # endif # define le64toh(x) (x) # elif BYTE_ORDER == BIG_ENDIAN /* that would be xbox 360 */ # define htobe16(x) (x) # define htole16(x) __builtin_bswap16(x) # define be16toh(x) (x) # define le16toh(x) __builtin_bswap16(x) # define htobe32(x) (x) # define htole32(x) __builtin_bswap32(x) # define be32toh(x) (x) # define le32toh(x) __builtin_bswap32(x) # define htobe64(x) (x) # define htole64(x) __builtin_bswap64(x) # define be64toh(x) (x) # define le64toh(x) __builtin_bswap64(x) # else # error byte order not supported # endif #elif defined(__NetBSD__) # include # define __BIG_ENDIAN _BIG_ENDIAN # define __LITTLE_ENDIAN _LITTLE_ENDIAN # define __BYTE_ORDER _BYTE_ORDER # define bswap_16(x) bswap16(x) # define bswap_32(x) bswap32(x) # define bswap_64(x) bswap64(x) #elif defined(__APPLE__) # define __BIG_ENDIAN 4321 # define __LITTLE_ENDIAN 1234 #if (defined(__LITTLE_ENDIAN__) && (__LITTLE_ENDIAN__ == 1)) #define __BYTE_ORDER __LITTLE_ENDIAN #else #define __BYTE_ORDER __BIG_ENDIAN #endif # include # define bswap_16 OSSwapInt16 # define bswap_32 OSSwapInt32 # define bswap_64 OSSwapInt64 # define htobe16(x) OSSwapHostToBigInt16(x) # define htole16(x) OSSwapHostToLittleInt16(x) # define be16toh(x) OSSwapBigToHostInt16(x) # define le16toh(x) OSSwapLittleToHostInt16(x) # define htobe32(x) OSSwapHostToBigInt32(x) # define htole32(x) OSSwapHostToLittleInt32(x) # define be32toh(x) OSSwapBigToHostInt32(x) # define le32toh(x) OSSwapLittleToHostInt32(x) # define htobe64(x) OSSwapHostToBigInt64(x) # define htole64(x) OSSwapHostToLittleInt64(x) # define be64toh(x) OSSwapBigToHostInt64(x) # define le64toh(x) OSSwapLittleToHostInt64(x) #elif defined(__OpenBSD__) # include # define bswap_16 __swap16 # define bswap_32 __swap32 # define bswap_64 __swap64 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) # include # define be16toh(x) betoh16(x) # define le16toh(x) letoh16(x) # define be32toh(x) betoh32(x) # define le32toh(x) letoh32(x) # define be64toh(x) betoh64(x) # define le64toh(x) letoh64(x) #elif (defined(BSD) && (BSD >= 199103)) && !defined(__GLIBC__) # include # define __BIG_ENDIAN _BIG_ENDIAN # define __LITTLE_ENDIAN _LITTLE_ENDIAN # define __BYTE_ORDER _BYTE_ORDER # define bswap_16(x) __bswap16(x) # define bswap_32(x) __bswap32(x) # define bswap_64(x) __bswap64(x) #elif defined(__GNUC__) /* use byteswap macros from the host system, hopefully optimized ones ;-) */ # include # include # define bswap_16(x) __bswap_16 (x) # define bswap_32(x) __bswap_32 (x) # define bswap_64(x) __bswap_64 (x) #elif defined(__sparc__) # define __BIG_ENDIAN 4321 # define __LITTLE_ENDIAN 1234 # define __BYTE_ORDER __BIG_ENDIAN #else # error Unknown platform #endif #if defined(__sparc__) # ifndef bswap_16 # define bswap_16(x) \ ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8)) # endif # ifndef bswap_32 # define bswap_32(x) \ ((((x) & 0xff000000) >> 24) \ | (((x) & 0x00ff0000) >> 8) \ | (((x) & 0x0000ff00) << 8) \ | (((x) & 0x000000ff) << 24)) # endif # ifndef bswap_64 # define bswap_64(x) \ ((((x) & 0xff00000000000000ull) >> 56) \ | (((x) & 0x00ff000000000000ull) >> 40) \ | (((x) & 0x0000ff0000000000ull) >> 24) \ | (((x) & 0x000000ff00000000ull) >> 8) \ | (((x) & 0x00000000ff000000ull) << 8) \ | (((x) & 0x0000000000ff0000ull) << 24) \ | (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x00000000000000ffull) << 56)) # endif #endif #if !defined(__BIG_ENDIAN) && !defined(__LITTLE_ENDIAN) #error ENDIANITY is not known #endif static inline uint16_t leu16p(const void* i) { uint16_t a; memcpy(&a, i, sizeof(a)); return (le16toh(a)); } static inline int16_t lei16p(const void* i) { uint16_t a; memcpy(&a, i, sizeof(a)); return ((int16_t)le16toh(a)); } static inline uint32_t leu32p(const void* i) { uint32_t a; memcpy(&a, i, sizeof(a)); return (le32toh(a)); } static inline int32_t lei32p(const void* i) { uint32_t a; memcpy(&a, i, sizeof(a)); return ((int32_t)le32toh(a)); } static inline uint64_t leu64p(const void* i) { uint64_t a; memcpy(&a, i, sizeof(a)); return (le64toh(a)); } static inline int64_t lei64p(const void* i) { uint64_t a; memcpy(&a, i, sizeof(a)); return ((int64_t)le64toh(a)); } static inline uint16_t beu16p(const void* i) { uint16_t a; memcpy(&a, i, sizeof(a)); return ((int16_t)be16toh(a)); } static inline int16_t bei16p(const void* i) { uint16_t a; memcpy(&a, i, sizeof(a)); return ((int16_t)be16toh(a)); } static inline uint32_t beu32p(const void* i) { uint32_t a; memcpy(&a, i, sizeof(a)); return (be32toh(a)); } static inline int32_t bei32p(const void* i) { uint32_t a; memcpy(&a, i, sizeof(a)); return ((int32_t)be32toh(a)); } static inline uint64_t beu64p(const void* i) { uint64_t a; memcpy(&a, i, sizeof(a)); return ((int64_t)be64toh(a)); } static inline int64_t bei64p(const void* i) { uint64_t a; memcpy(&a, i, sizeof(a)); return ((int64_t)be64toh(a)); } static inline void leu16a(uint16_t i, void* r) { i = htole16(i); memcpy(r, &i, sizeof(i)); } static inline void lei16a( int16_t i, void* r) { i = htole16(i); memcpy(r, &i, sizeof(i)); } static inline void leu32a(uint32_t i, void* r) { i = htole32(i); memcpy(r, &i, sizeof(i)); } static inline void lei32a( int32_t i, void* r) { i = htole32(i); memcpy(r, &i, sizeof(i)); } static inline void leu64a(uint64_t i, void* r) { i = htole64(i); memcpy(r, &i, sizeof(i)); } static inline void lei64a( int64_t i, void* r) { i = htole64(i); memcpy(r, &i, sizeof(i)); } static inline void beu16a(uint16_t i, void* r) { i = htobe16(i); memcpy(r, &i, sizeof(i)); }; static inline void bei16a( int16_t i, void* r) { i = htobe16(i); memcpy(r, &i, sizeof(i)); } static inline void beu32a(uint32_t i, void* r) { i = htobe32(i); memcpy(r, &i, sizeof(i)); } static inline void bei32a( int32_t i, void* r) { i = htobe32(i); memcpy(r, &i, sizeof(i)); } static inline void beu64a(uint64_t i, void* r) { i = htobe64(i); memcpy(r, &i, sizeof(i)); } static inline void bei64a( int64_t i, void* r) { i = htobe64(i); memcpy(r, &i, sizeof(i)); } static inline float lef32p(const void* i) { // decode little endian float pointer uint32_t o; union { uint32_t i; float r; } c; memcpy(&o,i,4); c.i = le32toh(o); return(c.r); } static inline double lef64p(const void* i) { // decode little endian double pointer uint64_t o=0; union { uint64_t i; double r; } c; memcpy(&o,i,8); c.i = le64toh(o); return(c.r); } static inline float bef32p(const void* i) { // decode little endian float pointer uint32_t o; union { uint32_t i; float r; } c; memcpy(&o,i,4); c.i = be32toh(o); return(c.r); } static inline double bef64p(const void* i) { // decode little endian double pointer uint64_t o=0; union { uint64_t i; double r; } c; memcpy(&o,i,8); c.i = be64toh(o); return(c.r); } static inline void lef32a( float i, void* r) { uint32_t i32; memcpy(&i32, &i, sizeof(i)); i32 = le32toh(i32); memcpy(r, &i32, sizeof(i32)); } static inline void lef64a( double i, void* r) { uint64_t i64; memcpy(&i64, &i, sizeof(i)); i64 = le64toh(i64); memcpy(r, &i64, sizeof(i64)); } static inline void bef32a( float i, void* r) { uint32_t i32; memcpy(&i32, &i, sizeof(i)); i32 = be32toh(i32); memcpy(r, &i32, sizeof(i32)); } static inline void bef64a( double i, void* r) { uint64_t i64; memcpy(&i64, &i, sizeof(i)); i64 = be64toh(i64); memcpy(r, &i64, sizeof(i64)); } #ifndef NAN # define NAN (0.0/0.0) /* used for encoding of missing values */ #endif #ifndef INFINITY # define INFINITY (1.0/0.0) /* positive infinity */ #endif #ifndef isfinite # define isfinite(a) (-INFINITY < (a) && (a) < INFINITY) #endif /* The macro IS_SET() can be used to test for defines in if (IS_SET(...)) { } as well as in #if (IS_SET(...)) #endif http://www.thepowerbase.com/2012/04/latest-release-of-linux-contains-code-developed-via-google-plus/ */ #define macrotest_1 , #define IS_SET(macro) is_set_(macro) #define is_set_(value) is_set__(macrotest_##value) #define is_set__(comma) is_set___(comma 1, 0) #define is_set___(_, v, ...) v /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * global constants and variables * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /* This structure defines the fields used for "VitalFEF" */ typedef struct asn1 { void *pduType; void *SAS; } ASN1_t; /* This structure defines the fields used for "Annotated ECG" */ typedef struct aecg { char* test; /* test field for annotated ECG */ float diastolicBloodPressure; /* in mmHg */ float systolicBloodPressure; /* in mmHg */ char* MedicationDrugs; char* ReferringPhysician; char* LatestConfirmingPhysician; char* Diagnosis; uint8_t EmergencyLevel; /* 0: routine 1-10: increased emergency level */ float HeartRate; float P_wave[2]; /* start and end */ float QRS_wave[2]; /* start and end */ float T_wave[2]; /* start and end */ float P_QRS_T_axes[3]; /***** SCP only fields *****/ struct { uint8_t HUFFMAN; uint8_t REF_BEAT; uint8_t DIFF; uint8_t BIMODAL; } FLAG; struct { //uint8_t tag14[41],tag15[41]; struct { uint16_t INST_NUMBER; /* tag 14, byte 1-2 */ uint16_t DEPT_NUMBER; /* tag 14, byte 3-4 */ uint16_t DEVICE_ID; /* tag 14, byte 5-6 */ uint8_t DeviceType; /* tag 14, byte 7: 0: Cart, 1: System (or Host) */ uint8_t MANUF_CODE; /* tag 14, byte 8 (MANUF_CODE has to be 255) */ char* MOD_DESC; /* tag 14, byte 9 (MOD_DESC has to be "Cart1") */ uint8_t VERSION; /* tag 14, byte 15 (VERSION has to be 20) */ uint8_t PROT_COMP_LEVEL; /* tag 14, byte 16 (PROT_COMP_LEVEL has to be 0xA0 => level II) */ uint8_t LANG_SUPP_CODE; /* tag 14, byte 17 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code) */ uint8_t ECG_CAP_DEV; /* tag 14, byte 18 (ECG_CAP_DEV has to be 0xD0 => Acquire, (No Analysis), Print and Store) */ uint8_t MAINS_FREQ; /* tag 14, byte 19 (MAINS_FREQ has to be 0: unspecified, 1: 50 Hz, 2: 60Hz) */ char reserved[22]; /* char[35-19] reserved; */ char* ANAL_PROG_REV_NUM; char* SERIAL_NUMBER_ACQ_DEV; char* ACQ_DEV_SYS_SW_ID; char* ACQ_DEV_SCP_SW; /* tag 14, byte 38 (SCP_IMPL_SW has to be "OpenECG XML-SCP 1.00") */ char* ACQ_DEV_MANUF; /* tag 14, byte 38 (ACQ_DEV_MANUF has to be "Manufacturer") */ } Tag14, Tag15; } Section1; struct { size_t StartPtr; size_t Length; } Section5; struct { size_t StartPtr; size_t Length; } Section6; struct { char Confirmed; // 0: original report (not overread); 1:Confirmed report; 2: Overread report (not confirmed) struct tm t; uint8_t NumberOfStatements; char **Statements; } Section8; struct { char* StartPtr; size_t Length; } Section9; struct { size_t StartPtr; size_t Length; } Section10; struct { char Confirmed; // 0: original report (not overread); 1:Confirmed report; 2: Overread report (not confirmed) struct tm t; uint8_t NumberOfStatements; char **Statements; } Section11; struct { size_t StartPtr; size_t Length; } Section12; } aECG_TYPE; /****************************************************************************/ /** **/ /** INTERNAL FUNCTIONS **/ /** **/ /****************************************************************************/ #pragma GCC visibility push(default) /* file access wrapper: use ZLIB (if available) or STDIO */ HDRTYPE* ifopen(HDRTYPE* hdr, const char* mode ); int ifclose(HDRTYPE* hdr); int ifeof(HDRTYPE* hdr); int ifflush(HDRTYPE* hdr); size_t ifread(void* buf, size_t size, size_t nmemb, HDRTYPE* hdr); size_t ifwrite(void* buf, size_t size, size_t nmemb, HDRTYPE* hdr); int ifprintf(HDRTYPE* hdr, const char *format, va_list arg); int ifputc(int c, HDRTYPE* hdr); int ifgetc(HDRTYPE* hdr); char* ifgets(char *str, int n, HDRTYPE* hdr); int ifseek(HDRTYPE* hdr, ssize_t offset, int whence ); ssize_t iftell(HDRTYPE* hdr); int ifgetpos(HDRTYPE* hdr, size_t *pos); int iferror(HDRTYPE* hdr); /* various utility functions */ uint32_t gcd(uint32_t A, uint32_t B); uint32_t lcm(uint32_t A, uint32_t B); #pragma GCC visibility pop extern const uint16_t GDFTYP_BITS[] __attribute__ ((visibility ("default") )) ; extern const char *LEAD_ID_TABLE[]; uint16_t CRCEvaluate(uint8_t* datablock, uint32_t datalength); int16_t CRCCheck(uint8_t* datablock, uint32_t datalength); #if (BIOSIG_VERSION < 10700) // this deprecated since Aug 2013, v1.5.7 #ifndef _WIN32 ATT_DEPREC int strcmpi(const char* str1, const char* str2); // use strcasecmp() instead #endif ATT_DEPREC int strncmpi(const char* str1, const char* str2, size_t n); // use strncasecmp() instead #endif int month_string2int(const char *s); int u32cmp(const void *a, const void *b); void biosigERROR(HDRTYPE *hdr, enum B4C_ERROR errnum, const char *errmsg) __attribute__ ((visibility ("default") )); /* sets the local and the (deprecated) global error variables B4C_ERRNUM and B4C_ERRMSG the global error variables are kept for backwards compatibility. */ /* some important functions used internally, the interface for these functios is a bit clumsy and are therefore not exported to standard user applications. */ void struct2gdfbin(HDRTYPE *hdr) __attribute__ ((visibility ("default") )); int gdfbin2struct(HDRTYPE *hdr) __attribute__ ((visibility ("default") )); /* struct2gdfbin and gdfbin2struct convert between the streamed header information (as in a GDF file or on a network connection) and the header structure HDRTYPE Specifically, the fixed header, the variable hadder and the optional header information (header 1,2 and 3). This incluedes the description of the user-specified events (TYP=1..255), but not the event table itself. ------------------------------------------------------------------------*/ size_t hdrEVT2rawEVT(HDRTYPE *hdr) __attribute__ ((visibility ("default") )); void rawEVT2hdrEVT(HDRTYPE *hdr, size_t length_rawEventTable) __attribute__ ((visibility ("default") )); /* rawEVT2hdrEVT and hdrEVT2rawEVT convert between streamed event table and the structure HDRTYPE.EVENT. ------------------------------------------------------------------------*/ int NumberOfChannels(HDRTYPE *hdr) __attribute__ ((visibility ("default") )); /* returns the number of channels returned by SREAD. This might be different than the number of data channels in the file because of status,event and annotation channels, and because some rereferencing is applied ------------------------------------------------------------------------*/ size_t reallocEventTable(HDRTYPE *hdr, size_t EventN); /* allocate, and resize memory of event table ------------------------------------------------------------------------*/ void FreeGlobalEventCodeTable(); /* free memory allocated for global event code ------------------------------------------------------------------------*/ size_t sread_raw(size_t START, size_t LEN, HDRTYPE* hdr, char flag, void *buf, size_t bufsize) __attribute__ ((visibility ("default") )); /* sread_raw: LEN data segments are read from file associated with hdr, starting from segment START. If buf==NULL, a sufficient amount of memory is (re-)allocated in hdr->AS.rawdata and the data is copied into hdr->AS.rawdata, and LEN*hdr->AS.bpb bytes are read and stored. If buf points to some memory location of size bufsize, the data is stored in buf, no reallocation of memory is possible, and only the minimum(bufsize, LEN*hdr->AS.bpb) is stored. No Overflowdetection or calibration is applied. The number of successfully read data blocks is returned, this can be smaller than LEN at the end of the file, of when bufsize is not large enough. The data can be "cached", this means that more than the requested number of blocks is available in hdr->AS.rawdata. hdr->AS.first and hdr->AS.length contain the number of the first block and the number of blocks, respectively. --------------------------------------------------------------- */ size_t bpb8_collapsed_rawdata(HDRTYPE *hdr) __attribute__ ((visibility ("default") )); /* bpb8_collapsed_rawdata computes the bits per block when rawdata is collapsed --------------------------------------------------------------- */ HDRTYPE* getfiletype(HDRTYPE* hdr); /* identify file format from header information input: hdr->AS.Header contains header of hdr->HeadLen bytes hdr->TYPE must be unknown, otherwise no FileFormat evaluation is performed output: hdr->TYPE file format hdr->VERSION is defined for some selected formats e.g. ACQ, EDF, BDF, GDF --------------------------------------------------------------- */ const char* GetFileTypeString(enum FileFormat FMT) __attribute__ ((visibility ("default") )); /* returns a string with file format --------------------------------------------------------------- */ enum FileFormat GetFileTypeFromString(const char *) __attribute__ ((visibility ("default") )); /* returns file format from string --------------------------------------------------------------- */ #ifdef __cplusplus } #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #endif /* BIOSIG_INTERNAL_H */ biosig-2.3.3/biosig4c++/biosig_server.c0000664000175000017500000006704214105434233020026 0ustar schloeglschloegl/* Copyright (C) 2009,2016 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, 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, see . */ #include "biosig-network.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef WITH_MICROMED void sopen_trc_read(HDRTYPE *hdr); #endif #ifdef WITH_PDP void sopen_pdp_read(HDRTYPE *hdr); #endif const char *LOGFILE = "/tmp/biosig/biosigd.log"; /* Key ID table and related functions */ struct IDTABLE_T { uint64_t id; uint64_t gtime; // time of file generation struct sockaddr_in addr; } *IdTablePtr; size_t IdTableLen; /* compare uint32_t */ int u64cmp(const void *a,const void *b) { unsigned int k=7; int r=0; while (!r && (k0)) { IdTablePtr[k].id = IdTablePtr[k-1].id; k--; } IdTablePtr[k].id = c; IdTablePtr[k].gtime = t_time2gdf_time(time(NULL)); // memcpy(&IdTablePtr[k].addr, addr, sizeof(struct sockaddr_in)); return(c); }; /*TODO: semaphore */ size_t LoadIdTable(const char *path) { IdTableLen = 0; DIR *d = opendir(path); if (d==NULL) { mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); return(0); } uint64_t ID; size_t N=0; struct dirent *dp; do { errno = 0; if ((dp = readdir(d)) != NULL) { IdTablePtr = (IDTABLE_T*)realloc(IdTablePtr,(N+1)*sizeof(IDTABLE_T)); cat64(dp->d_name,&ID); if (ID != 0) { IdTablePtr[N].id = ID; N++; } } } while (dp != NULL); closedir(d); qsort(IdTablePtr,N,sizeof(IDTABLE_T),&u64cmp); IdTableLen = N; fprintf(stdout,"Load Id Table: %i entries found.\n",N); if (VERBOSE_LEVEL>8) for (int k=0; k 0); } //#define VERBOSE_LEVEL 8 const char path[] = "/tmp/biosig/\0 .gdf"; void DoJob(int ns) { char fullfilename[] = "/tmp/biosig/ .gdf"; const size_t pathlen = strlen(path); char *filename = fullfilename+pathlen; // size_t sizbuf = BSCS_MAX_BUFSIZ+8; uint8_t inbuf[BSCS_MAX_BUFSIZ+8]; HDRTYPE *hdr = NULL; uint64_t ID = 0; uint32_t STATUS = STATE_INIT; char stopflag = 0; size_t datalen = 0; mesg_t msg; if ((VERBOSE_LEVEL>7) && errno) { errno = 0; fprintf(stdout,"## errno=%i %s\n",errno,strerror(errno)); } /* Create a new SID for the child process */ pid_t sid = setsid(); if (sid < 0) { exit(-1); } /*server identification */ const char *greeting="Hi there,\n this is your experimental BSCS server. \n It is useful for testing the BioSig client-server architecture.\n"; msg.STATE = BSCS_VERSION_01 | BSCS_SEND_MSG | STATE_INIT | BSCS_NO_ERROR; msg.LEN = htobe32(strlen(greeting)); int s; s = send(ns,&msg,8,0); s = send(ns, greeting, strlen(greeting), 0); while (!stopflag) // wait for command { fprintf(stdout,":> "); ssize_t count = recv(ns, &msg, 8, 0); fprintf(stdout,"STATUS=%08x c=%i MSG=%08x len=%i,errno=%i %s\n",STATUS,count,be32toh(msg.STATE),be32toh(msg.LEN),errno,strerror(errno)); size_t LEN = be32toh(msg.LEN); FILE *fid = fopen(LOGFILE,"a"); fprintf(stdout,"STATUS=%08x c=%i MSG=%08x len=%i,errno=%i %s\n",STATUS,count,be32toh(msg.STATE),be32toh(msg.LEN),errno,strerror(errno)); fclose(fid); errno = 0; if (count==0) { fprintf(stdout,"connection lost! %i %i %i %s\n",stopflag,count,errno,strerror(errno)); LEN = 0; stopflag=1; continue; } else if (count<0) { fprintf(stdout,"invalid packet! %i %i %i %s\n",stopflag,count,errno,strerror(errno)); LEN = 0; } else if ((msg.STATE & CMD_MASK) == BSCS_NOP) { // no operation count = 0; while (count7) fprintf(stdout,"open %i %i %016lx\n",LEN,count,ID); hdr = constructHDR(0,0); if (LEN==0) //|| ((LEN==8) && (ID==0))) // no ID, send back id, open(w) { ID = GetNewId(); c64ta(ID, filename); hdr->FLAG.ANONYMOUS = 1; // do not store name STATUS = STATE_OPEN_WRITE_HDR; msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_W | BSCS_REPLY | STATE_OPEN_WRITE_HDR; msg.LEN = htobe32(8); leu64a(ID, &msg.LOAD); s = send(ns, &msg, 16, 0); FILE *fid = fopen(LOGFILE,"a"); fprintf(fid,"\t> %s",filename); fclose(fid); } else if (LEN == 8) // open(r) { count = recv(ns, &msg.LOAD, 8, 0); ID = leu64p((uint8_t*)&msg.LOAD); c64ta(ID, filename); // ToDo: replace SOPEN with simple function, e.g. access to event table not needed here hdr->FLAG.ANONYMOUS = 1; // do not store name hdr->FileName = fullfilename; hdr = sopen(fullfilename,"r",hdr); msg.LEN = htobe32(0); if (hdr->FILE.OPEN==0) { msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_R | BSCS_REPLY | STATE_INIT | BSCS_ERROR_CANNOT_OPEN_FILE; STATUS = STATE_INIT; } else if (serror2(hdr) || (hdr->NRec < 0)) { sclose(hdr); msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_R | BSCS_REPLY | STATE_INIT | BSCS_ERROR_CANNOT_OPEN_FILE; STATUS = STATE_INIT; } else { msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_R | BSCS_REPLY | STATE_OPEN_READ; STATUS = STATE_OPEN_READ; } s = send(ns, &msg, 8, 0); FILE *fid = fopen(LOGFILE,"a"); fprintf(fid,"\t< %s",filename); fclose(fid); } else //if (LEN != 8) { STATUS = STATE_INIT; msg.STATE = BSCS_VERSION_01 | BSCS_OPEN_W | BSCS_REPLY | STATE_INIT | BSCS_ERROR_INCORRECT_PACKET_LENGTH; msg.LEN = htobe32(0); s = send(ns, &msg, 8, 0); } } else if ((STATUS == (msg.STATE & STATE_MASK)) && (LEN == 0) && ((msg.STATE & (VER_MASK | CMD_MASK)) == (BSCS_VERSION_01 | BSCS_CLOSE))) { // close /**************************************************************************************** CLOSE FILE ****************************************************************************************/ if (STATUS != (msg.STATE & STATE_MASK)) fprintf(stdout,"Close: status does not fit\n"); msg.STATE = BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY | STATE_INIT; msg.LEN = htobe32(0); if (LEN != 0) msg.STATE = BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY | STATE_INIT | BSCS_ERROR_INCORRECT_PACKET_LENGTH; if ((STATUS == STATE_OPEN_WRITE_HDR) || (STATUS == STATE_OPEN_WRITE)) { if (hdr->NRec != datalen/hdr->AS.bpb) hdr->NRec = -1; // this triggers sclose to compute the correct size } if ((hdr!=NULL) && ((STATUS != STATE_OPEN_READ) || (STATUS != STATE_OPEN_READ)) ) sclose(hdr); if (STATUS != STATE_INIT) { destructHDR(hdr); hdr = NULL; } hdr = NULL; if (serror2(hdr)) msg.STATE = BSCS_VERSION_01 | BSCS_CLOSE | BSCS_REPLY | STATE_INIT | BSCS_ERROR_CLOSE_FILE; STATUS = STATE_INIT; s = send(ns, &msg, 8, 0); } else if ((STATUS == STATE_OPEN_WRITE_HDR) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_SEND_HDR | STATE_OPEN_WRITE_HDR))) { /**************************************************************************************** SEND HEADER ****************************************************************************************/ //case BSCS_SEND_HDR: // send header information hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,LEN); hdr->HeadLen = LEN; count = 0; while (count8) fprintf(stdout,"SND HDR: c=%i,LEN=%i\n",count,LEN); count += recv(ns, hdr->AS.Header+count, LEN-count, 0); } if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR: c=%i,LEN=%i\n",count,LEN); hdr->TYPE = GDF; hdr->FLAG.ANONYMOUS = 1; // do not store name gdfbin2struct(hdr); hdr->EVENT.N = 0; hdr->EVENT.POS = NULL; hdr->EVENT.TYP = NULL; hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; c64ta(ID, filename); hdr->FileName = fullfilename; hdr->FILE.COMPRESSION = 0; ifopen(hdr,"w"); hdr->FILE.OPEN = 2; count=ifwrite(hdr->AS.Header, 1, hdr->HeadLen, hdr); datalen = 0; if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR: count=%i\n",count); if (errno) { // check for errors in gdfbin2struct, ifopen and ifwrite STATUS = STATE_OPEN_WRITE_HDR; msg.STATE = BSCS_VERSION_01 | BSCS_SEND_HDR | BSCS_REPLY | STATE_OPEN_WRITE_HDR | BSCS_ERROR_COULD_NOT_WRITE_HDR; } else { STATUS = STATE_OPEN_WRITE; msg.STATE = BSCS_VERSION_01 | BSCS_SEND_HDR | BSCS_REPLY | STATE_OPEN_WRITE; } msg.LEN = htobe32(0); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND HDR RPLY: %08x\n",msg.STATE); s = send(ns, &msg, 8, 0); } else if ((STATUS == STATE_OPEN_WRITE) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_SEND_DAT | STATE_OPEN_WRITE))) { /**************************************************************************************** SEND DATA ****************************************************************************************/ //case BSCS_SEND_DAT: // send data block // ToDo: check corrupt packet count = 0; while (count0) { size_t n = hdr->EVENT.N; hdr->EVENT.N += N; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP) ); hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, hdr->EVENT.N*sizeof(*hdr->EVENT.DUR) ); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, hdr->EVENT.N*sizeof(*hdr->EVENT.CHN) ); // read EVENT.POS count = 0; LEN = N*sizeof(*hdr->EVENT.POS); while (count < LEN) { count += recv(ns, (uint8_t*)(hdr->EVENT.POS+n)+count, LEN-count, 0); } // read EVENT.TYP count = 0; LEN = N*sizeof(*hdr->EVENT.TYP); while (count < LEN) { count += recv(ns, (uint8_t*)(hdr->EVENT.TYP+n)+count, LEN-count, 0); } // read EVENT.DUR and EVENT.CHN if (flag==3) { count = 0; LEN = N*sizeof(*hdr->EVENT.POS); while (count < LEN) { count += recv(ns, (uint8_t*)(hdr->EVENT.DUR+n)+count, LEN-count, 0); } count = 0; LEN = N*sizeof(*hdr->EVENT.TYP); while (count < LEN) { count += recv(ns, (uint8_t*)(hdr->EVENT.CHN+n)+count, LEN-count, 0); } } else { for (size_t k=n; kEVENT.N; k++) { hdr->EVENT.DUR[k] = 0; hdr->EVENT.CHN[k] = 0; } } #if __BYTE_ORDER == __BIG_ENDIAN // do byte swapping if needed for (size_t k=n; kEVENT.N; k++) { hdr->EVENT.POS[k] = htole32(hdr->EVENT.POS[k]); hdr->EVENT.TYP[k] = htole16(hdr->EVENT.TYP[k]); } if (flag==3) { for (size_t k=n; kEVENT.N; k++) { hdr->EVENT.DUR[k] = htole32(hdr->EVENT.DUR[k]); hdr->EVENT.CHN[k] = htole16(hdr->EVENT.CHN[k]); } } #endif msg.STATE = BSCS_VERSION_01 | BSCS_SEND_EVT | BSCS_REPLY | STATE_OPEN_WRITE; } msg.LEN = htobe32(0); s = send(ns, &msg, 8, 0); } else if ((msg.STATE & CMD_MASK) == BSCS_SEND_MSG ) { // might become obsolet (?) // ToDo: check corrupt packet count = 0; ssize_t c=0; while (count\n",(char*)(inbuf)); count += c; } //system((char*)(inbuf)); // TODO: reply message } else if ((STATUS == STATE_OPEN_READ) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_REQU_HDR | STATE_OPEN_READ))) { /**************************************************************************************** REQUEST HEADER ****************************************************************************************/ msg.STATE = BSCS_VERSION_01 | BSCS_REQU_HDR | BSCS_REPLY | STATE_OPEN_READ; msg.LEN = htobe32(hdr->HeadLen); s = send(ns, &msg, 8, 0); s = send(ns, hdr->AS.Header, hdr->HeadLen, 0); } else if ((STATUS == STATE_OPEN_READ) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_REQU_DAT | STATE_OPEN_READ))) { /**************************************************************************************** REQUEST DATA ****************************************************************************************/ count += recv(ns, inbuf, 8, 0); size_t length = leu32p(inbuf); size_t start = leu32p(inbuf+4); sread_raw(start, length, hdr, 0); length = min(length, hdr->AS.first + hdr->AS.length - start); msg.STATE = BSCS_VERSION_01 | BSCS_REQU_DAT | BSCS_REPLY | STATE_OPEN_READ; msg.LEN = htobe32(hdr->AS.bpb*length); s = send(ns, &msg, 8, 0); s = send(ns, hdr->AS.rawdata + hdr->AS.bpb*(start-hdr->AS.first), hdr->AS.bpb*length, 0); //send(ns, hdr->AS.rawdata, (hdr->AS.length-hdr->AS.first)*hdr->AS.bpb,0); } else if ((STATUS == STATE_OPEN_READ) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_REQU_EVT | STATE_OPEN_READ))) { /**************************************************************************************** REQUEST EVENT TABLE ****************************************************************************************/ size_t len = 0; if ((hdr->TYPE == GDF) && (hdr->AS.rawEventData == NULL) && (hdr->NRec>=0)) { // event table from GDF file ifseek(hdr, hdr->HeadLen + hdr->AS.bpb*hdr->NRec, SEEK_SET); // READ EVENTTABLE hdr->AS.rawEventData = (uint8_t*)realloc(hdr->AS.rawEventData,8); int c = ifread(hdr->AS.rawEventData, sizeof(uint8_t), 8, hdr); uint8_t *buf = hdr->AS.rawEventData; if (c<8) { hdr->EVENT.N = 0; } else if (hdr->VERSION < 1.94) { hdr->EVENT.N = leu32p(buf + 4); } else { hdr->EVENT.N = buf[1] + (buf[2] + buf[3]*256)*256; } int sze = (buf[0]>1) ? 12 : 6; len = 8+hdr->EVENT.N*sze; hdr->AS.rawEventData = (uint8_t*)realloc(hdr->AS.rawEventData,len); ifread(hdr->AS.rawEventData+8, 1, len-8, hdr); ifseek(hdr, hdr->HeadLen+hdr->AS.bpb*hdr->FILE.POS, SEEK_SET); // note: no conversion to HDR.EVENT structure needed on server-side } else if ((hdr->TYPE != GDF) && (hdr->AS.rawEventData == NULL)) len = hdrEVT2rawEVT(hdr); else if ((hdr->TYPE == GDF) && (hdr->AS.rawEventData != NULL)){ uint8_t *buf = hdr->AS.rawEventData; if (hdr->VERSION < 1.94) hdr->EVENT.N = leu32p(buf + 4); else hdr->EVENT.N = buf[1] + (buf[2] + buf[3]*256)*256; int sze = (buf[0]>1) ? 12 : 6; if (hdr->EVENT.N>0) { len = 8+sze*hdr->EVENT.N; } } msg.STATE = BSCS_VERSION_01 | BSCS_REQU_HDR | BSCS_REPLY | STATE_OPEN_READ; if (len <= 8) { msg.LEN = htobe32(0); s = send(ns, &msg, 8, 0); } else { msg.LEN = htobe32(len); s = send(ns, &msg, 8, 0); s = send(ns, hdr->AS.rawEventData, len, 0); } } else if ((STATUS == STATE_OPEN_WRITE_HDR) && ((msg.STATE & ~ERR_MASK) == (BSCS_VERSION_01 | BSCS_PUT_FILE | STATE_OPEN_WRITE_HDR))) { /**************************************************************************************** PUT FILE ****************************************************************************************/ //case BSCS_PUT_FILE: // send header information uint32_t errcode = 0; c64ta(ID, filename); char *f2 = (char*)malloc(strlen(fullfilename)+5); strcpy(f2,fullfilename); strcat(f2,".tmp"); /*********** temporary file - not checked *********/ int sdo = open(f2,O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); HDRTYPE *hdr = constructHDR(0,0); hdr->FileName = f2; #ifdef WITH_PDP hdr->AS.Header = (uint8_t*) malloc(LEN+1); #endif const int BUFLEN = 1024; char buf[BUFLEN]; count = 0; while (countAS.Header+count,buf,len); #endif count += write(sdo, buf, len); //fprintf(stdout,"\b\b\b\b%02i%% ",100.0*count/LEN); } close(sdo); hdr->AS.Header[count]=0; hdr->HeadLen = count; if (LEN-count) { errcode = 1; //fprintf(stdout,"errcode=1 %i\n",LEN-count); } else { /************ read temporary file, ... ************/ int status = 0; #ifdef WITH_PDP sopen_pdp_read(hdr); sread(NULL,0,hdr->NRec,hdr); // rawdata -> data.block status=serror2(hdr); if (status) { errcode = 2; #else { #endif sopen(f2,"r",hdr); if ((status=serror2(hdr))) errcode = 11; else { count = sread(NULL,0,hdr->NRec,hdr); if ((status=serror2(hdr))) errcode = 12; sclose(hdr); if ((status=serror2(hdr))) errcode = 13; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"put file: errcode=%i\n",errcode); /********* ... and convert to GDF file *************/ if (!status) { hdr->FileName = fullfilename; hdr->TYPE = GDF; hdr->VERSION = 2; sopen(fullfilename,"w",hdr); if ((status=serror2(hdr))) { errcode = 21; } else { //count = swrite(hdr->data.block, hdr->NRec, hdr); ifwrite(hdr->AS.rawdata,hdr->AS.bpb,hdr->NRec,hdr); if ((status=serror2(hdr))) errcode = 22; sclose(hdr); if ((status=serror2(hdr))) errcode = 23; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"put file: errcode=%i\n",errcode); } destructHDR(hdr); free(f2); STATUS = STATE_INIT; msg.STATE = BSCS_VERSION_01 | BSCS_PUT_FILE | BSCS_REPLY | STATE_INIT | htobe32(errcode); msg.LEN = htobe32(0); s = send(ns, &msg, 8, 0); } else if (( (msg.STATE & ~ERR_MASK & ~STATE_MASK) == (BSCS_VERSION_01 | BSCS_GET_FILE))) { /**************************************************************************************** GET FILE ****************************************************************************************/ count = recv(ns, &msg.LOAD, 8, 0); ID = leu64p((uint8_t*)&msg.LOAD); c64ta(ID, filename); if (VERBOSE_LEVEL>7) fprintf(stdout,"get file: %s\n",filename); fprintf(stdout,"get file: %016lx\n",ID); int sdi = open(fullfilename,O_RDONLY,S_IFREG); fprintf(stdout,"get file: %016lx %i\n",ID,sdi); if (sdi<0) { msg.STATE = BSCS_VERSION_01 | BSCS_GET_FILE | BSCS_REPLY | STATUS | BSCS_ERROR_CANNOT_OPEN_FILE; msg.LEN = htobe32(0); s = send(ns, &msg, 8, 0); } else { struct stat FileBuf; stat(fullfilename,&FileBuf); uint32_t LEN = FileBuf.st_size; msg.STATE = BSCS_VERSION_01 | BSCS_GET_FILE | BSCS_REPLY | STATUS | BSCS_NO_ERROR; msg.LEN = htobe32(LEN); s = send(ns, &msg, 8, 0); const int BUFLEN = 1024; char *buf[BUFLEN]; count = 0; while (countai_next) { if ((sd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("server: socket"); continue; } if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { perror("setsockopt"); exit(1); } if (bind(sd, p->ai_addr, p->ai_addrlen) == -1) { close(sd); perror("server: bind"); continue; } break; } if (p == NULL) { fprintf(stderr, "server: failed to bind\n"); return(BSCS_CANNOT_BIND_PORT); } freeaddrinfo(servinfo); // all done with this structure #else struct sockaddr_in sain; fromlen = sizeof(sain); /* * Get a socket to work with. This socket will * be in the UNIX domain, and will be a * stream socket. */ if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("server: socket"); exit(1); } /* bind server port */ sain.sin_family = AF_INET; sain.sin_addr.s_addr = htonl(INADDR_ANY); sain.sin_port = htons(SERVER_PORT); if(bind(sd, (struct sockaddr *) &sain, sizeof(sain))<0) { perror("cannot bind port "); return(-1); } #endif /* * Listen on the socket. */ if (listen(sd, 10) < 0) { perror("server: listen"); exit(1); } sa.sa_handler = sigchld_handler; // reap all dead processes sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction(SIGCHLD, &sa, NULL) == -1) { perror("sigaction"); exit(1); } printf("server: waiting for connections...\n"); while(1) { /* * Accept connections. When we accept one, ns * will be connected to the client. fsain will * contain the address of the client. */ fromlen = sizeof(sain); if ((ns = accept(sd, (struct sockaddr*)&sain, &fromlen)) < 0) { perror("server: accept"); exit(1); } #ifdef IPv6 inet_ntop(sain.ss_family, get_in_addr((struct sockaddr *)&sain),s, sizeof s); printf("server: got connection from %s\n", s); #else char hostname[100],service[100]; bzero(hostname,100); bzero(service,100); addrlen = sizeof(struct sockaddr); if (getnameinfo((struct sockaddr *)&sain,addrlen,hostname,100,service,100,0) != 0) { fprintf(stdout,"--- errno=%i %s\n",errno,strerror(errno)); // perror("getnameinfo"); } printf("Connection received from host (%s) on remote port (%s)\n",hostname,service); #endif #ifndef VERBOSE_LEVEL //VERBOSE_LEVEL = 8; #endif // TODO: LOG FILE char dst[INET6_ADDRSTRLEN]; inet_ntop(AF_INET, &sain.sin_addr,dst, INET6_ADDRSTRLEN); timer=time(NULL); char *t = asctime(localtime(&timer)); t[24]=0; FILE *fid = fopen(LOGFILE,"a"); fprintf(fid,"\n%s\t%s\t%s",t,dst,hostname); fclose(fid); if (!fork()) { // this is the child process close(sd); // child doesn't need the listener /* Change the file mode mask */ umask(0); /* Change the current working directory. This prevents the current directory from being locked; hence not being able to remove it. */ if ((chdir("/")) < 0) { syslog( LOG_ERR, "unable to change directory to %s, code %d (%s)","/", errno, strerror(errno) ); exit(-1); } /* Redirect standard files to /dev/null */ freopen( "/dev/null", "r", stdin); freopen( "/dev/null", "w", stdout); freopen( "/dev/null", "w", stderr); if (VERBOSE_LEVEL>7) fprintf(stdout,"server123 err=%i %s\n",errno,strerror(errno)); errno = 0; DoJob(ns); close(ns); exit(0); } close(ns); } close(sd); exit(0); } biosig-2.3.3/biosig4c++/save2scp0000775000175000017500000000022714105434233016464 0ustar schloeglschloegl#!/bin/sh # SAVE2SCP converts short-term ECG data into # the EN1094 SCP-ECG format. # ### conversion into SCP-ECG (EN1064) standard save2gdf -f=SCP $@ biosig-2.3.3/biosig4c++/biosig_fhir.c0000664000175000017500000001341314105434233017441 0ustar schloeglschloegl/* % Copyright (C) 2016 Alois Schloegl % This file is part of the "BioSig for C/C++" repository % (biosig4c++) at http://biosig.sf.net/ 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 3 of the License, 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, see . */ #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include "biosig-dev.h" #include "biosig.h" #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) /* https://www.hl7.org/fhir/binary.html https://catalyze.io/learn/the-fhir-resource-object-the-core-building-block */ /* biosig_hdr2gdf_base64(..) converts biosig data into GDF-stream encoded in base64 hdr: biosig header structure, file must be open in order to read data section fid: stream for data output */ int biosig_hdr2gdf_base64(HDRTYPE *hdr, FILE *fid) { hdr->TYPE=GDF; hdr->VERSION=3.0; struct2gdfbin(hdr); size_t len3 = hdrEVT2rawEVT(hdr); size_t len0 = hdr->HeadLen + hdr->NRec*hdr->AS.bpb + len3; size_t buflen = max(max(len3,hdr->HeadLen),hdr->AS.bpb); char *buf = (char*)malloc(buflen*2); char *mem = (char*)malloc(buflen); base64_encodestate B64STATE; base64_init_encodestate(&B64STATE); // write header int c = base64_encode_block((char*)hdr->AS.Header, (int)hdr->HeadLen, buf, &B64STATE); fwrite(buf,1,c,fid); // write data block size_t count = 0; size_t bpb = bpb8_collapsed_rawdata(hdr)>>3; size_t blks= buflen/hdr->AS.bpb; for (size_t nrec=0; nrec < hdr->NRec; nrec+=blks) { count = sread_raw(nrec, min(blks, hdr->NRec-nrec), hdr, 1, mem, blks*hdr->AS.bpb); c = base64_encode_block(mem, bpb, buf, &B64STATE); fwrite(buf,1,c,fid); } // write event table c = base64_encode_block((char*)hdr->AS.rawEventData, (int)len3, buf, &B64STATE); fwrite(buf,1,c,fid); c = base64_encode_blockend(buf, &B64STATE); fwrite(buf,1,c,fid); if (buf) free(buf); if (mem) free(mem); return(0); } /* biosig_fhir_binary_json_template: opens a biosig file, and generates binary json template according to fhir */ char* biosig_fhir_binary_xml_template(const char *filename, FILE *fid) { // generate XML template /* */ HDRTYPE *hdr = NULL; hdr = sopen(filename, "r", hdr); fprintf(fid,"\n" " \n" " \n" " \n" "\n"); destructHDR(hdr); return(0); } char* biosig_fhir_binary_json_template(const char *filename, FILE *fid) { /* generate json template { "resourceType" : "Binary", "id" : filename, "meta" : { asprintf_hdr2json(&str, filename), // from Resource: id, meta, implicitRules, and language "contentType" : "", // R! MimeType of the binary content "content" : "" // R! The actual content } */ int status; HDRTYPE *hdr = NULL; hdr = sopen(filename, "r", hdr); if ((status=serror2(hdr))) { destructHDR(hdr); exit(status); } fprintf(fid,"{\n" " \"resourceType\" : \"Binary\",\n" " \"id\" : \"%s\",\n" " \"meta\" : ", hdr->FileName); fprintf_hdr2json(fid, hdr); fprintf(fid, ", \"contentType\" : \"X-biosig/gdf\",\n" " \"content\" : \""); biosig_hdr2gdf_base64(hdr, fid); fprintf(fid, "\"\n}\n"); destructHDR(hdr); return(0); } #ifndef NDEBUG extern int VERBOSE_LEVEL; #endif #ifdef __cplusplus } #endif const char *help = "%s provides fhir binary template for biosignal data\n\n" " Usage: %s [-json|-xml|-base64] \n\n" " reads filename and converts it fhir-(json|xml)-binary-template\n" " or a media-type X-biosig/gdf (i.e. base64-encoded GDF stream).\n" " libbiosig version %06x is used to read the file.\n\n"; int main(int argc, char **argv) { #ifndef NDEBUG VERBOSE_LEVEL = 0; #endif enum {BASE64,JSON,XML} flag_output_format = JSON; if (argc<2) { fprintf(stderr,help, argv[0], argv[0], get_biosig_version()); exit; } char **opt = argv+1; for (; *opt!=NULL; opt++) { if (!strcasecmp(*opt, "-base64")) { flag_output_format = BASE64; } if (!strcasecmp(*opt, "-json")) { flag_output_format = JSON; } else if (!strcasecmp(*opt, "-xml")) { flag_output_format = XML; } #ifndef NDEBUG else if (!strncmp(*opt, "-V", 2)) { VERBOSE_LEVEL = (*opt)[2]-'0'; } #endif else if (!strcasecmp(*opt, "-h") || !strcasecmp(*opt, "--help")) { fprintf(stderr,help, argv[0], argv[0], get_biosig_version()); } else if (*opt[0] != '-') { HDRTYPE *hdr = NULL; const char *filename = *opt; switch (flag_output_format) { case BASE64: hdr = sopen(filename, "r", hdr); biosig_hdr2gdf_base64(hdr, stdout); destructHDR(hdr); break; case JSON: biosig_fhir_binary_json_template(filename, stdout); break; case XML: biosig_fhir_binary_xml_template(filename, stdout); break; } } } } biosig-2.3.3/biosig4c++/magic/0000775000175000017500000000000014105434244016071 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/magic/biosig0000664000175000017500000001166614105434233017300 0ustar schloeglschloegl######################################################################################################## # # Magic ids for biomedical signal file formats # Copyright (C) 2018 Alois Schloegl # # The list has been derived from biosig projects # http://biosig.sourceforge.net # https://pub.ist.ac.at/~schloegl/matlab/eeg/ # http://pub.ist.ac.at/~schloegl/biosig/TESTED # # This file is part of the "BioSig" repository at http://biosig.sf.net/ # and dual licenses with "GPL v3 or later" and "2-clause BSD license" # ######################################################################################################## # 0 string ABF\x20 Biosig/Axon Binary format !:mime biosig/abf2 0 string ABF2\0\0 Biosig/Axon Binary format !:mime biosig/abf2 # 0 string ATES\x20MEDICA\x20SOFT.\x20EEG\x20for\x20Windows Biosig/ATES MEDICA SOFT. EEG for Windows !:mime biosig/ates # 0 string ATF\x09 Biosig/Axon Text fomrat !:mime biosig/atf # 0 string ADU1 Biosig/Axona file format !:mime biosig/axona 0 string ADU2 Biosig/Axona file format !:mime biosig/axona # 0 string ALPHA-TRACE-MEDICAL Biosig/alpha trace !:mime biosig/alpha # 0 string AxGr Biosig/AXG 0 string axgx Biosig/AXG !:mime biosig/axg # 0 string HeaderLen= Biosig/BCI2000 0 string BCI2000V Biosig/BCI2000 !:mime biosig/bci2000 # ### Specification: https://www.biosemi.com/faq/file_format.htm 0 string \xffBIOSEMI Biosig/Biosemi data format !:mime biosig/bdf # 0 string Brain\x20Vision\x20Data\x20Exchange\x20Header\x20File Biosig/Brainvision data file 0 string Brain\x20Vision\x20V-Amp\x20Data\x20Header\x20File\x20Version Biosig/Brainvision V-Amp file 0 string Brain\x20Vision\x20Data\x20Exchange\x20Marker\x20File,\x20Version Biosig/Brainvision Marker file !:mime biosig/brainvision # 0 string CEDFILE Biosig/CFS: Cambridge Electronic devices File format !:mime biosig/ced # ### Specification: https://www.edfplus.info/specs/index.html 0 string 0\x20\x20\x20\x20\x20\x20\x20 Biosig/EDF: European Data format !:mime biosig/edf # ### Specifications: https://arxiv.org/abs/cs/0608052 0 string GDF Biosig/GDF: General data format for biosignals !:mime biosig/gdf # 0 string DATA\0\0\0\0 Biosig/Heka Patchmaster 0 string DAT1\0\0\0\0 Biosig/Heka Patchmaster 0 string DAT2\0\0\0\0 Biosig/Heka Patchmaster !:mime biosig/heka # 0 string (C)\x20CED\x2087 Biosig/CED SMR !:mime biosig/ced-smr # 0 string CFWB\1\0\0\0 Biosig/CFWB !:mime biosig/cfwb # 0 string DEMG Biosig/DEMG !:mime biosig/demg # 0 string EBS\x94\x0a\x13\x1a\x0d Biosig/EBS !:mime biosig/ebs # 0 string Embla\x20data\x20file Biosig/Embla !:mime biosig/embla # 0 string Header\r\nFile Version Biosig/ETG4000 !:mime biosig/etg4000 # 0 string GALILEO\x20EEG\x20TRACE\x20FILE Biosig/Galileo !:mime biosig/galileo # 0 string IGOR Biosig/IgorPro ITX file !:mime biosig/igorpro # # Specification: http://www.ampsmedical.com/uploads/2017-12-7/The_ISHNE_Format.pdf 0 string ISHNE1.0 Biosig/ISHNE !:mime biosig/ishne # # CEN/ISO 11073/22077 series, http://www.mfer.org/en/document.htm 0 string @\x20\x20MFER\x20 Biosig/MFER 0 string @\x20MFR\x20 Biosig/MFER !:mime biosig/mfer # 0 string NEURALEV Biosig/NEV 0 string N.EV.\0 Biosig/NEV !:mime biosig/nev # 0 string NEX1 Biosig/NEX !:mime biosig/nex1 # 0 string PLEX Biosig/Plexon v1.0 10 string PLEXON Biosig/Plexon v2.0 !:mime biosig/plexon # 0 string \x02\x27\x91\xC6 Biosig/RHD2000: Intan RHD2000 format # # Specification: CEN 1064:2005/ISO 11073:91064 16 string SCPECG\0\0 Biosig/SCP-ECG format CEN 1064:2005/ISO 11073:91064 !:mime biosig/scpecg # 0 string IAvSFo Biosig/SIGIF !:mime biosig/sigif # 0 string POLY\x20SAMPLE\x20FILEversion\x20 Biosig/TMS32 !:mime biosig/tms32 # 0 string FileId=TMSi\x20PortiLab\x20sample\x20log\x20file\x0a\x0dVersion= Biosig/TMSiLOG !:mime biosig/tmsilog # 4 string Synergy\0\48\49\50\46\48\48\51\46\48\48\48\46\48\48\48\0\28\0\0\0\2\0\0\0 >63 string CRawDataElement >>85 string CRawDataBuffer Biosig/SYNERGY !:mime biosig/synergy # 4 string \40\0\4\1\44\1\102\2\146\3\44\0\190\3 Biosig/UNIPRO !:mime biosig/unipro # 0 string VER=9\r\nCTIME= Biosig/WCP !:mime biosig/wcp # 0 string \xAF\xFE\xDA\xDA Biosig/Walter Graphtek 0 string \xDA\xDA\xFE\xAF Biosig/Walter Graphtek 0 string \x55\x55\xFE\xAF Biosig/Walter Graphtek !:mime biosig/walter-graphtek # 0 string V3.0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 >32 string [PatInfo] Biosig/Sigma !:mime biosig/sigma # 0 string \067\069\078\013\010\0x1a\04\0x84 Biosig/File exchange format (FEF) !:mime biosig/fef 0 string \67\69\78\0x13\0x10\0x1a\4\0x84 Biosig/File exchange format (FEF) !:mime biosig/fef # 0 string \0\0\0\x64\0\0\0\x1f\0\0\0\x14\0\0\0\0\0\1 >36 string \0\0\0\x65\0\0\0\3\0\0\0\4\0\0 >>56 string \0\0\0\x6a\0\0\0\3\0\0\0\4\0\0\0\0\xff\xff\xff\xff\0\0 Biosig/FIFF !:mime biosig/fiff # biosig-2.3.3/biosig4c++/magic/Makefile.in0000664000175000017500000000041414105434233020133 0ustar schloeglschloeglbiosig.mgc: biosig file -C -m biosig test: biosig.mgc file.list file -m biosig.mgc -f file.list file.list: echo "set up file.list containing list files for testing. this can done like" echo " ls -1 >file.list" echo " find . >file.list" clean: rm *.mgc biosig-2.3.3/biosig4c++/magic/Makefile0000664000175000017500000000041414105434244017530 0ustar schloeglschloeglbiosig.mgc: biosig file -C -m biosig test: biosig.mgc file.list file -m biosig.mgc -f file.list file.list: echo "set up file.list containing list files for testing. this can done like" echo " ls -1 >file.list" echo " find . >file.list" clean: rm *.mgc biosig-2.3.3/biosig4c++/XMLParser/0000775000175000017500000000000014105434233016624 5ustar schloeglschloeglbiosig-2.3.3/biosig4c++/XMLParser/tinystr.h0000664000175000017500000002000614105434233020507 0ustar schloeglschloegl/* www.sourceforge.net/projects/tinyxml This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TIXML_USE_STL #ifndef TIXML_STRING_INCLUDED #define TIXML_STRING_INCLUDED #include #include /* The support for explicit isn't that universal, and it isn't really required - it is used to check that the TiXmlString class isn't incorrectly used. Be nice to old compilers and macro it here: */ #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) // Microsoft visual studio, version 6 and higher. #define TIXML_EXPLICIT explicit #elif defined(__GNUC__) && (__GNUC__ >= 3 ) // GCC version 3 and higher.s #define TIXML_EXPLICIT explicit #else #define TIXML_EXPLICIT #endif /* TiXmlString is an emulation of a subset of the std::string template. Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. Only the member functions relevant to the TinyXML project have been implemented. The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase a string and there's no more room, we allocate a buffer twice as big as we need. */ class TiXmlString { public : // The size type used typedef size_t size_type; // Error value for find primitive static const size_type npos; // = -1; // TiXmlString empty constructor TiXmlString () : rep_(&nullrep_) { } // TiXmlString copy constructor TiXmlString ( const TiXmlString & copy) : rep_(0) { init(copy.length()); memcpy(start(), copy.data(), length()); } // TiXmlString constructor, based on a string TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) { init( static_cast( strlen(copy) )); memcpy(start(), copy, length()); } // TiXmlString constructor, based on a string TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) { init(len); memcpy(start(), str, len); } // TiXmlString destructor ~TiXmlString () { quit(); } TiXmlString& operator = (const char * copy) { return assign( copy, (size_type)strlen(copy)); } TiXmlString& operator = (const TiXmlString & copy) { return assign(copy.start(), copy.length()); } // += operator. Maps to append TiXmlString& operator += (const char * suffix) { return append(suffix, static_cast( strlen(suffix) )); } // += operator. Maps to append TiXmlString& operator += (char single) { return append(&single, 1); } // += operator. Maps to append TiXmlString& operator += (const TiXmlString & suffix) { return append(suffix.data(), suffix.length()); } // Convert a TiXmlString into a null-terminated char * const char * c_str () const { return rep_->str; } // Convert a TiXmlString into a char * (need not be null terminated). const char * data () const { return rep_->str; } // Return the length of a TiXmlString size_type length () const { return rep_->size; } // Alias for length() size_type size () const { return rep_->size; } // Checks if a TiXmlString is empty bool empty () const { return rep_->size == 0; } // Return capacity of string size_type capacity () const { return rep_->capacity; } // single char extraction const char& at (size_type index) const { assert( index < length() ); return rep_->str[ index ]; } // [] operator char& operator [] (size_type index) const { assert( index < length() ); return rep_->str[ index ]; } // find a char in a string. Return TiXmlString::npos if not found size_type find (char lookup) const { return find(lookup, 0); } // find a char in a string from an offset. Return TiXmlString::npos if not found size_type find (char tofind, size_type offset) const { if (offset >= length()) return npos; for (const char* p = c_str() + offset; *p != '\0'; ++p) { if (*p == tofind) return static_cast< size_type >( p - c_str() ); } return npos; } void clear () { //Lee: //The original was just too strange, though correct: // TiXmlString().swap(*this); //Instead use the quit & re-init: quit(); init(0,0); } /* Function to reserve a big amount of data when we know we'll need it. Be aware that this function DOES NOT clear the content of the TiXmlString if any exists. */ void reserve (size_type cap); TiXmlString& assign (const char* str, size_type len); TiXmlString& append (const char* str, size_type len); void swap (TiXmlString& other) { Rep* r = rep_; rep_ = other.rep_; other.rep_ = r; } private: void init(size_type sz) { init(sz, sz); } void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } char* start() const { return rep_->str; } char* finish() const { return rep_->str + rep_->size; } struct Rep { size_type size, capacity; char str[1]; }; void init(size_type sz, size_type cap) { if (cap) { // Lee: the original form: // rep_ = static_cast(operator new(sizeof(Rep) + cap)); // doesn't work in some cases of new being overloaded. Switching // to the normal allocation, although use an 'int' for systems // that are overly picky about structure alignment. const size_type bytesNeeded = sizeof(Rep) + cap; const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); rep_ = reinterpret_cast( new int[ intsNeeded ] ); rep_->str[ rep_->size = sz ] = '\0'; rep_->capacity = cap; } else { rep_ = &nullrep_; } } void quit() { if (rep_ != &nullrep_) { // The rep_ is really an array of ints. (see the allocator, above). // Cast it back before delete, so the compiler won't incorrectly call destructors. delete [] ( reinterpret_cast( rep_ ) ); } } Rep * rep_; static Rep nullrep_; } ; inline bool operator == (const TiXmlString & a, const TiXmlString & b) { return ( a.length() == b.length() ) // optimization on some platforms && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare } inline bool operator < (const TiXmlString & a, const TiXmlString & b) { return strcmp(a.c_str(), b.c_str()) < 0; } inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); TiXmlString operator + (const TiXmlString & a, const char* b); TiXmlString operator + (const char* a, const TiXmlString & b); /* TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. Only the operators that we need for TinyXML have been developped. */ class TiXmlOutStream : public TiXmlString { public : // TiXmlOutStream << operator. TiXmlOutStream & operator << (const TiXmlString & in) { *this += in; return *this; } // TiXmlOutStream << operator. TiXmlOutStream & operator << (const char * in) { *this += in; return *this; } } ; #endif // TIXML_STRING_INCLUDED #endif // TIXML_USE_STL biosig-2.3.3/biosig4c++/XMLParser/tinystr.cpp0000664000175000017500000000471314105434233021051 0ustar schloeglschloegl/* www.sourceforge.net/projects/tinyxml This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TIXML_USE_STL #include "tinystr.h" // Error value for find primitive const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); // Null rep. TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; void TiXmlString::reserve (size_type cap) { if (cap > capacity()) { TiXmlString tmp; tmp.init(length(), cap); memcpy(tmp.start(), data(), length()); swap(tmp); } } TiXmlString& TiXmlString::assign(const char* str, size_type len) { size_type cap = capacity(); if (len > cap || cap > 3*(len + 8)) { TiXmlString tmp; tmp.init(len); memcpy(tmp.start(), str, len); swap(tmp); } else { memmove(start(), str, len); set_size(len); } return *this; } TiXmlString& TiXmlString::append(const char* str, size_type len) { size_type newsize = length() + len; if (newsize > capacity()) { reserve (newsize + capacity()); } memmove(finish(), str, len); set_size(newsize); return *this; } TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) { TiXmlString tmp; tmp.reserve(a.length() + b.length()); tmp += a; tmp += b; return tmp; } TiXmlString operator + (const TiXmlString & a, const char* b) { TiXmlString tmp; TiXmlString::size_type b_len = static_cast( strlen(b) ); tmp.reserve(a.length() + b_len); tmp += a; tmp.append(b, b_len); return tmp; } TiXmlString operator + (const char* a, const TiXmlString & b) { TiXmlString tmp; TiXmlString::size_type a_len = static_cast( strlen(a) ); tmp.reserve(a_len + b.length()); tmp.append(a, a_len); tmp += b; return tmp; } #endif // TIXML_USE_STL biosig-2.3.3/biosig4c++/XMLParser/tinyxml.cpp0000664000175000017500000013235114105434233021041 0ustar schloeglschloegl/* www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Modified: Copyright (C) 2009 Alois Schloegl add support for zlib-compressed (gzipped) XML data $Id: tinyxml.h,v 1.5 2009/04/09 09:12:09 schloegl Exp $ Copyright (C) 2009,2011 Alois Schloegl This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ #include #include #ifdef TIXML_USE_STL #include #include #endif #include "tinyxml.h" FILE* TiXmlFOpen( const char* filename, const char* mode ); bool TiXmlBase::condenseWhiteSpace = true; // Microsoft compiler security FILE* TiXmlFOpen( const char* filename, const char* mode ) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) FILE* fp = 0; errno_t err = fopen_s( &fp, filename, mode ); if ( !err && fp ) return fp; return 0; #else return fopen( filename, mode ); #endif } void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) { int i=0; while( i<(int)str.length() ) { unsigned char c = (unsigned char) str[i]; if ( c == '&' && i < ( (int)str.length() - 2 ) && str[i+1] == '#' && str[i+2] == 'x' ) { // Hexadecimal character reference. // Pass through unchanged. // © -- copyright symbol, for example. // // The -1 is a bug fix from Rob Laveaux. It keeps // an overflow from happening if there is no ';'. // There are actually 2 ways to exit this loop - // while fails (error case) and break (semicolon found). // However, there is no mechanism (currently) for // this function to return an error. while ( i<(int)str.length()-1 ) { outString->append( str.c_str() + i, 1 ); ++i; if ( str[i] == ';' ) break; } } else if ( c == '&' ) { outString->append( entity[0].str, entity[0].strLength ); ++i; } else if ( c == '<' ) { outString->append( entity[1].str, entity[1].strLength ); ++i; } else if ( c == '>' ) { outString->append( entity[2].str, entity[2].strLength ); ++i; } else if ( c == '\"' ) { outString->append( entity[3].str, entity[3].strLength ); ++i; } else if ( c == '\'' ) { outString->append( entity[4].str, entity[4].strLength ); ++i; } else if ( c < 32 ) { // Easy pass at non-alpha/numeric/symbol // Below 32 is symbolic. char buf[ 32 ]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); #else sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); #endif //*ME: warning C4267: convert 'size_t' to 'int' //*ME: Int-Cast to make compiler happy ... outString->append( buf, (int)strlen( buf ) ); ++i; } else { //char realc = (char) c; //outString->append( &realc, 1 ); *outString += (char) c; // somewhat more efficient function call. ++i; } } } TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { parent = 0; type = _type; firstChild = 0; lastChild = 0; prev = 0; next = 0; } TiXmlNode::~TiXmlNode() { TiXmlNode* node = firstChild; TiXmlNode* temp = 0; while ( node ) { temp = node; node = node->next; delete temp; } } void TiXmlNode::CopyTo( TiXmlNode* target ) const { target->SetValue (value.c_str() ); target->userData = userData; target->location = location; } void TiXmlNode::Clear() { TiXmlNode* node = firstChild; TiXmlNode* temp = 0; while ( node ) { temp = node; node = node->next; delete temp; } firstChild = 0; lastChild = 0; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { assert( node->parent == 0 || node->parent == this ); assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) { delete node; if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } node->parent = this; node->prev = lastChild; node->next = 0; if ( lastChild ) lastChild->next = node; else firstChild = node; // it was an empty list. lastChild = node; return node; } TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; return LinkEndChild( node ); } TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) { if ( !beforeThis || beforeThis->parent != this ) { return 0; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; node->parent = this; node->next = beforeThis; node->prev = beforeThis->prev; if ( beforeThis->prev ) { beforeThis->prev->next = node; } else { assert( firstChild == beforeThis ); firstChild = node; } beforeThis->prev = node; return node; } TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { if ( !afterThis || afterThis->parent != this ) { return 0; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; node->parent = this; node->prev = afterThis; node->next = afterThis->next; if ( afterThis->next ) { afterThis->next->prev = node; } else { assert( lastChild == afterThis ); lastChild = node; } afterThis->next = node; return node; } TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { if ( !replaceThis ) return 0; if ( replaceThis->parent != this ) return 0; if ( withThis.ToDocument() ) { // A document can never be a child. Thanks to Noam. TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = withThis.Clone(); if ( !node ) return 0; node->next = replaceThis->next; node->prev = replaceThis->prev; if ( replaceThis->next ) replaceThis->next->prev = node; else lastChild = node; if ( replaceThis->prev ) replaceThis->prev->next = node; else firstChild = node; delete replaceThis; node->parent = this; return node; } bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) { if ( !removeThis ) { return false; } if ( removeThis->parent != this ) { assert( 0 ); return false; } if ( removeThis->next ) removeThis->next->prev = removeThis->prev; else lastChild = removeThis->prev; if ( removeThis->prev ) removeThis->prev->next = removeThis->next; else firstChild = removeThis->next; delete removeThis; return true; } const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const { const TiXmlNode* node; for ( node = firstChild; node; node = node->next ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const { const TiXmlNode* node; for ( node = lastChild; node; node = node->prev ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const { if ( !previous ) { return FirstChild(); } else { assert( previous->parent == this ); return previous->NextSibling(); } } const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const { if ( !previous ) { return FirstChild( val ); } else { assert( previous->parent == this ); return previous->NextSibling( val ); } } const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const { const TiXmlNode* node; for ( node = next; node; node = node->next ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const { const TiXmlNode* node; for ( node = prev; node; node = node->prev ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } void TiXmlElement::RemoveAttribute( const char * name ) { #ifdef TIXML_USE_STL TIXML_STRING str( name ); TiXmlAttribute* node = attributeSet.Find( str ); #else TiXmlAttribute* node = attributeSet.Find( name ); #endif if ( node ) { attributeSet.Remove( node ); delete node; } } const TiXmlElement* TiXmlNode::FirstChildElement() const { const TiXmlNode* node; for ( node = FirstChild(); node; node = node->NextSibling() ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const { const TiXmlNode* node; for ( node = FirstChild( _value ); node; node = node->NextSibling( _value ) ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement() const { const TiXmlNode* node; for ( node = NextSibling(); node; node = node->NextSibling() ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const { const TiXmlNode* node; for ( node = NextSibling( _value ); node; node = node->NextSibling( _value ) ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlDocument* TiXmlNode::GetDocument() const { const TiXmlNode* node; for( node = this; node; node = node->parent ) { if ( node->ToDocument() ) return node->ToDocument(); } return 0; } TiXmlElement::TiXmlElement (const char * _value) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; value = _value; } #ifdef TIXML_USE_STL TiXmlElement::TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; value = _value; } #endif TiXmlElement::TiXmlElement( const TiXmlElement& copy) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; copy.CopyTo( this ); } TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) { ClearThis(); base.CopyTo( this ); return *this; } TiXmlElement::~TiXmlElement() { ClearThis(); } void TiXmlElement::ClearThis() { Clear(); while( attributeSet.First() ) { TiXmlAttribute* node = attributeSet.First(); attributeSet.Remove( node ); delete node; } } const char* TiXmlElement::Attribute( const char* name ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) return node->Value(); return 0; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( attrib ) return &attrib->ValueStr(); return 0; } #endif const char* TiXmlElement::Attribute( const char* name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* result = 0; if ( attrib ) { result = attrib->Value(); if ( i ) { attrib->QueryIntValue( i ); } } return result; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* result = 0; if ( attrib ) { result = &attrib->ValueStr(); if ( i ) { attrib->QueryIntValue( i ); } } return result; } #endif const char* TiXmlElement::Attribute( const char* name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* result = 0; if ( attrib ) { result = attrib->Value(); if ( d ) { attrib->QueryDoubleValue( d ); } } return result; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* result = 0; if ( attrib ) { result = &attrib->ValueStr(); if ( d ) { attrib->QueryDoubleValue( d ); } } return result; } #endif int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryIntValue( ival ); } int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; int ival = 0; int result = node->QueryIntValue( &ival ); *value = (unsigned)ival; return result; } int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; int result = TIXML_WRONG_TYPE; if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) { *bval = true; result = TIXML_SUCCESS; } else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) { *bval = false; result = TIXML_SUCCESS; } return result; } #ifdef TIXML_USE_STL int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryIntValue( ival ); } #endif int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryDoubleValue( dval ); } #ifdef TIXML_USE_STL int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryDoubleValue( dval ); } #endif void TiXmlElement::SetAttribute( const char * name, int val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetIntValue( val ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& name, int val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetIntValue( val ); } } #endif void TiXmlElement::SetDoubleAttribute( const char * name, double val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetDoubleValue( val ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetDoubleValue( val ); } } #endif void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); if ( attrib ) { attrib->SetValue( cvalue ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); if ( attrib ) { attrib->SetValue( _value ); } } #endif void TiXmlElement::Print( FILE* cfile, int depth ) const { int i; assert( cfile ); for ( i=0; iNext() ) { fprintf( cfile, " " ); attrib->Print( cfile, depth ); } // There are 3 different formatting approaches: // 1) An element without children is printed as a node // 2) An element with only a text child is printed as text // 3) An element with children is printed on multiple lines. TiXmlNode* node; if ( !firstChild ) { fprintf( cfile, " />" ); } else if ( firstChild == lastChild && firstChild->ToText() ) { fprintf( cfile, ">" ); firstChild->Print( cfile, depth + 1 ); fprintf( cfile, "", value.c_str() ); } else { fprintf( cfile, ">" ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) { fprintf( cfile, "\n" ); } node->Print( cfile, depth+1 ); } fprintf( cfile, "\n" ); for( i=0; i", value.c_str() ); } } #ifdef ZLIB_H void TiXmlElement::gzPrint( gzFile cfile, int depth ) const { int i; assert( cfile ); for ( i=0; iNext() ) { gzprintf( cfile, " " ); attrib->gzPrint( cfile, depth ); } // There are 3 different formatting approaches: // 1) An element without children is printed as a node // 2) An element with only a text child is printed as text // 3) An element with children is printed on multiple lines. TiXmlNode* node; if ( !firstChild ) { gzprintf( cfile, " />" ); } else if ( firstChild == lastChild && firstChild->ToText() ) { gzprintf( cfile, ">" ); firstChild->gzPrint( cfile, depth + 1 ); gzprintf( cfile, "", value.c_str() ); } else { gzprintf( cfile, ">" ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) { gzprintf( cfile, "\n" ); } node->gzPrint( cfile, depth+1 ); } gzprintf( cfile, "\n" ); for( i=0; i", value.c_str() ); } } #endif void TiXmlElement::CopyTo( TiXmlElement* target ) const { // superclass: TiXmlNode::CopyTo( target ); // Element class: // Clone the attributes, then clone the children. const TiXmlAttribute* attribute = 0; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) { target->SetAttribute( attribute->Name(), attribute->Value() ); } TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); } } bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const { if ( visitor->VisitEnter( *this, attributeSet.First() ) ) { for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { if ( !node->Accept( visitor ) ) break; } } return visitor->VisitExit( *this ); } TiXmlNode* TiXmlElement::Clone() const { TiXmlElement* clone = new TiXmlElement( Value() ); if ( !clone ) return 0; CopyTo( clone ); return clone; } const char* TiXmlElement::GetText() const { const TiXmlNode* child = this->FirstChild(); if ( child ) { const TiXmlText* childText = child->ToText(); if ( childText ) { return childText->Value(); } } return 0; } TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; ClearError(); } TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; value = documentName; ClearError(); } #ifdef TIXML_USE_STL TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; value = documentName; ClearError(); } #endif TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { copy.CopyTo( this ); } TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) { Clear(); copy.CopyTo( this ); return *this; } bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) { return LoadFile( Value(), encoding ); } bool TiXmlDocument::SaveFile() const { return SaveFile( Value() ); } bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) { TIXML_STRING filename( _filename ); value = filename; // reading in binary mode so that tinyxml can normalize the EOL #ifdef ZLIB_H gzFile file; file = gzopen( value.c_str(), "rb" ); if ( file ) { bool result = LoadFile( file, encoding ); gzclose( file ); return result; } #else FILE* file = TiXmlFOpen( value.c_str (), "rb" ); if ( file ) { bool result = LoadFile( file, encoding ); fclose( file ); return result; } #endif else { SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } } bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) { if ( !file ) { SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } // Delete the existing data: Clear(); location.Clear(); // Get the file size, so we can pre-allocate the string. HUGE speed impact. size_t length = 0; fseek( file, 0, SEEK_END ); length = ftell( file ); fseek( file, 0, SEEK_SET ); // Strange case, but good to handle up front. if ( length <= 0 ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } // Subtle bug here. TinyXml did use fgets. But from the XML spec: // 2.11 End-of-Line Handling // // // ...the XML processor MUST behave as if it normalized all line breaks in external // parsed entities (including the document entity) on input, before parsing, by translating // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to // a single #xA character. // // // It is not clear fgets does that, and certainly isn't clear it works cross platform. // Generally, you expect fgets to translate from the convention of the OS to the c/unix // convention, and not work generally. /* while( fgets( buf, sizeof(buf), file ) ) { data += buf; } */ char* buf = new char[ length+1 ]; buf[0] = 0; if ( fread( buf, length, 1, file ) != 1 ) { delete [] buf; SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } #if defined(_ICONV_H) || defined (_LIBICONV_H) // convert utf-16 to utf-8 if needed const char XML_UTF16LE[] = "\xff\xfe<\0?\0x\0m\0l\0 \0v\0e\0r\0s\0i\0o\0n\0=\0\"\0001\0.\0000\0\"\0 \0e\0n\0c\0o\0d\0i\0n\0g\0=\0\"\0U\0T\0F\0-\0001\0006\0\"\0?\0>\0"; if (!memcmp(buf, XML_UTF16LE, sizeof(XML_UTF16LE)-1 ) ) { char *buf2 = (char*)malloc(length); size_t outlen = length; char *inbuf = buf; char *outbuf = buf2; iconv_t CD = iconv_open ("UTF-8","UTF-16LE"); size_t iconv_res = iconv (CD, &inbuf, &length, &outbuf, &outlen); iconv_close (CD); if (iconv_res != (size_t)(-1)) { free(buf); outbuf[0] = 0; buf = buf2; length = strlen(buf); } else { free(buf2); fprintf(stderr,"SOPEN_HL7aECG: attempt to convert UTF-16 to UTF-8 failed\n"); } } #else fprintf(stderr,"SOPEN_HL7aECG: conversion of UTF-16 to UTF-8 is not supported\n"); #endif // Process the buffer in place to normalize new lines. (See comment above.) // Copies from the 'p' to 'q' pointer, where p can advance faster if // a newline-carriage return is hit. // // Wikipedia: // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 const char* p = buf; // the read head char* q = buf; // the write head const char CR = 0x0d; const char LF = 0x0a; buf[length] = 0; while( *p ) { assert( p < (buf+length) ); assert( q <= (buf+length) ); assert( q <= p ); if ( *p == CR ) { *q++ = LF; p++; if ( *p == LF ) { // check for CR+LF (and skip LF) p++; } } else { *q++ = *p++; } } assert( q <= (buf+length) ); *q = 0; Parse( buf, 0, encoding ); delete [] buf; return !Error(); } #ifdef ZLIB_H bool TiXmlDocument::LoadFile(gzFile file, TiXmlEncoding encoding ) { char *buf = NULL; size_t length = 0; // file is loaded in hdr->AS.Header; size_t buflen = 1l<<18; while (!gzeof(file)) { buf = (char*)realloc(buf, buflen); length += gzread(file, buf+length, buflen-length-1); buflen *= 2; } buf[length] = 0; buf = (char*)realloc(buf,length+1); #ifdef _ICONV_H // convert utf-16 to utf-8 if needed const char XML_UTF16LE[] = "\xff\xfe<\0?\0x\0m\0l\0 \0v\0e\0r\0s\0i\0o\0n\0=\0\"\0001\0.\0000\0\"\0 \0e\0n\0c\0o\0d\0i\0n\0g\0=\0\"\0U\0T\0F\0-\0001\0006\0\"\0?\0>\0"; if (!memcmp(buf, XML_UTF16LE, sizeof(XML_UTF16LE)-1 ) ) { char *buf2 = (char*)malloc(length); size_t outlen = length; char *inbuf = buf; char *outbuf = buf2; iconv_t CD = iconv_open ("UTF-8","UTF-16LE"); size_t iconv_res = iconv (CD, &inbuf, &length, &outbuf, &outlen); iconv_close (CD); if (iconv_res != (size_t)(-1)) { free(buf); outbuf[0] = 0; buf = buf2; length = strlen(buf); } else { free(buf2); fprintf(stderr,"SOPEN_HL7aECG: attempt to convert UTF-16 to UTF-8 failed\n"); } } #endif // Process the buffer in place to normalize new lines. (See comment above.) // Copies from the 'p' to 'q' pointer, where p can advance faster if // a newline-carriage return is hit. // // Wikipedia: // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 const char* p = buf; // the read head char* q = buf; // the write head const char CR = 0x0d; const char LF = 0x0a; while( *p ) { assert( p < (buf+length) ); assert( q <= (buf+length) ); assert( q <= p ); if ( *p == CR ) { *q++ = LF; p++; if ( *p == LF ) { // check for CR+LF (and skip LF) p++; } } else { *q++ = *p++; } } assert( q <= (buf+length) ); *q = 0; Parse( buf, 0, encoding ); delete [] buf; return !Error(); } #endif bool TiXmlDocument::SaveFile( const char * filename, char compression ) const { // The old c stuff lives on... if (compression) { #ifdef ZLIB_H gzFile fid = gzopen(filename, "wb" ); if (fid) { bool result = SaveFile(fid); gzclose(fid); return result; } #else fprintf(stdout,"warning: zlib compression not supported\n"); #endif } else { FILE *fid = fopen(filename, "wb" ); if (fid) { bool result = SaveFile(fid); fclose(fid); return result; } } return false; } bool TiXmlDocument::SaveFile( const char * filename ) const { // The old c stuff lives on... FILE* fp = TiXmlFOpen( filename, "w" ); if ( fp ) { bool result = SaveFile( fp ); fclose( fp ); return result; } return false; } bool TiXmlDocument::SaveFile( FILE* fp ) const { if ( useMicrosoftBOM ) { const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; fputc( TIXML_UTF_LEAD_0, fp ); fputc( TIXML_UTF_LEAD_1, fp ); fputc( TIXML_UTF_LEAD_2, fp ); } Print( fp, 0 ); return (ferror(fp) == 0); } #ifdef ZLIB_H bool TiXmlDocument::SaveFile( gzFile fp ) const { if ( useMicrosoftBOM ) { const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; gzputc( fp, TIXML_UTF_LEAD_0 ); gzputc( fp, TIXML_UTF_LEAD_1 ); gzputc( fp, TIXML_UTF_LEAD_2 ); } gzPrint( fp, 0 ); int err; gzerror(fp,&err); return (err!=0); } #endif void TiXmlDocument::CopyTo( TiXmlDocument* target ) const { TiXmlNode::CopyTo( target ); target->error = error; target->errorId = errorId; target->errorDesc = errorDesc; target->tabsize = tabsize; target->errorLocation = errorLocation; target->useMicrosoftBOM = useMicrosoftBOM; TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); } } TiXmlNode* TiXmlDocument::Clone() const { TiXmlDocument* clone = new TiXmlDocument(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlDocument::Print( FILE* cfile, int depth ) const { assert( cfile ); for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { node->Print( cfile, depth ); fprintf( cfile, "\n" ); } } #ifdef ZLIB_H void TiXmlDocument::gzPrint( gzFile cfile, int depth ) const { assert( cfile ); for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { node->gzPrint( cfile, depth ); gzprintf( cfile, "\n" ); } } #endif bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const { if ( visitor->VisitEnter( *this ) ) { for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { if ( !node->Accept( visitor ) ) break; } } return visitor->VisitExit( *this ); } const TiXmlAttribute* TiXmlAttribute::Next() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) return 0; return next; } /* TiXmlAttribute* TiXmlAttribute::Next() { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) return 0; return next; } */ const TiXmlAttribute* TiXmlAttribute::Previous() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) return 0; return prev; } /* TiXmlAttribute* TiXmlAttribute::Previous() { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) return 0; return prev; } */ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if (value.find ('\"') == TIXML_STRING::npos) { if ( cfile ) { fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; } } else { if ( cfile ) { fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; } } } #ifdef ZLIB_H void TiXmlAttribute::gzPrint( gzFile cfile, int /*depth*/, TIXML_STRING* str ) const { TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if (value.find ('\"') == TIXML_STRING::npos) { if ( cfile ) { gzprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; } } else { if ( cfile ) { gzprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; } } } #endif int TiXmlAttribute::QueryIntValue( int* ival ) const { if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int TiXmlAttribute::QueryDoubleValue( double* dval ) const { if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } void TiXmlAttribute::SetIntValue( int _value ) { char buf [64]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); #else sprintf (buf, "%d", _value); #endif SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { char buf [256]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); #else sprintf (buf, "%g", _value); #endif SetValue (buf); } int TiXmlAttribute::IntValue() const { return atoi (value.c_str ()); } double TiXmlAttribute::DoubleValue() const { return atof (value.c_str ()); } TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { copy.CopyTo( this ); } TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) { Clear(); base.CopyTo( this ); return *this; } void TiXmlComment::Print( FILE* cfile, int depth ) const { assert( cfile ); for ( int i=0; i", value.c_str() ); } #ifdef ZLIB_H void TiXmlComment::gzPrint( gzFile cfile, int depth ) const { assert( cfile ); for ( int i=0; i", value.c_str() ); } #endif void TiXmlComment::CopyTo( TiXmlComment* target ) const { TiXmlNode::CopyTo( target ); } bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlComment::Clone() const { TiXmlComment* clone = new TiXmlComment(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlText::Print( FILE* cfile, int depth ) const { assert( cfile ); if ( cdata ) { int i; fprintf( cfile, "\n" ); for ( i=0; i\n", value.c_str() ); // unformatted output } else { TIXML_STRING buffer; EncodeString( value, &buffer ); fprintf( cfile, "%s", buffer.c_str() ); } } #ifdef ZLIB_H void TiXmlText::gzPrint( gzFile cfile, int depth ) const { assert( cfile ); if ( cdata ) { int i; gzprintf( cfile, "\n" ); for ( i=0; i\n", value.c_str() ); // unformatted output } else { TIXML_STRING buffer; EncodeString( value, &buffer ); gzprintf( cfile, "%s", buffer.c_str() ); } } #endif void TiXmlText::CopyTo( TiXmlText* target ) const { TiXmlNode::CopyTo( target ); target->cdata = cdata; } bool TiXmlText::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlText::Clone() const { TiXmlText* clone = 0; clone = new TiXmlText( "" ); if ( !clone ) return 0; CopyTo( clone ); return clone; } TiXmlDeclaration::TiXmlDeclaration( const char * _version, const char * _encoding, const char * _standalone ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { version = _version; encoding = _encoding; standalone = _standalone; } #ifdef TIXML_USE_STL TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, const std::string& _encoding, const std::string& _standalone ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { version = _version; encoding = _encoding; standalone = _standalone; } #endif TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { copy.CopyTo( this ); } TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) { Clear(); copy.CopyTo( this ); return *this; } void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { if ( cfile ) fprintf( cfile, "" ); if ( str ) (*str) += "?>"; } #ifdef ZLIB_H void TiXmlDeclaration::gzPrint( gzFile cfile, int /*depth*/, TIXML_STRING* str ) const { if ( cfile ) gzprintf( cfile, "" ); if ( str ) (*str) += "?>"; } #endif void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const { TiXmlNode::CopyTo( target ); target->version = version; target->encoding = encoding; target->standalone = standalone; } bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlDeclaration::Clone() const { TiXmlDeclaration* clone = new TiXmlDeclaration(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlUnknown::Print( FILE* cfile, int depth ) const { for ( int i=0; i", value.c_str() ); } #ifdef ZLIB_H void TiXmlUnknown::gzPrint( gzFile cfile, int depth ) const { for ( int i=0; i", value.c_str() ); } #endif void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const { TiXmlNode::CopyTo( target ); } bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlUnknown::Clone() const { TiXmlUnknown* clone = new TiXmlUnknown(); if ( !clone ) return 0; CopyTo( clone ); return clone; } TiXmlAttributeSet::TiXmlAttributeSet() { sentinel.next = &sentinel; sentinel.prev = &sentinel; } TiXmlAttributeSet::~TiXmlAttributeSet() { assert( sentinel.next == &sentinel ); assert( sentinel.prev == &sentinel ); } void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) { #ifdef TIXML_USE_STL assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. #else assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. #endif addMe->next = &sentinel; addMe->prev = sentinel.prev; sentinel.prev->next = addMe; sentinel.prev = addMe; } void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { TiXmlAttribute* node; for( node = sentinel.next; node != &sentinel; node = node->next ) { if ( node == removeMe ) { node->prev->next = node->next; node->next->prev = node->prev; node->next = 0; node->prev = 0; return; } } assert( 0 ); // we tried to remove a non-linked attribute. } #ifdef TIXML_USE_STL TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const { for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) { if ( node->name == name ) return node; } return 0; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) { TiXmlAttribute* attrib = Find( _name ); if ( !attrib ) { attrib = new TiXmlAttribute(); Add( attrib ); attrib->SetName( _name ); } return attrib; } #endif TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const { for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) { if ( strcmp( node->name.c_str(), name ) == 0 ) return node; } return 0; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) { TiXmlAttribute* attrib = Find( _name ); if ( !attrib ) { attrib = new TiXmlAttribute(); Add( attrib ); attrib->SetName( _name ); } return attrib; } #ifdef TIXML_USE_STL std::istream& operator>> (std::istream & in, TiXmlNode & base) { TIXML_STRING tag; tag.reserve( 8 * 1000 ); base.StreamIn( &in, &tag ); base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); return in; } #endif #ifdef TIXML_USE_STL std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) { TiXmlPrinter printer; printer.SetStreamPrinting(); base.Accept( &printer ); out << printer.Str(); return out; } std::string& operator<< (std::string& out, const TiXmlNode& base ) { TiXmlPrinter printer; printer.SetStreamPrinting(); base.Accept( &printer ); out.append( printer.Str() ); return out; } #endif TiXmlHandle TiXmlHandle::FirstChild() const { if ( node ) { TiXmlNode* child = node->FirstChild(); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const { if ( node ) { TiXmlNode* child = node->FirstChild( value ); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement() const { if ( node ) { TiXmlElement* child = node->FirstChildElement(); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const { if ( node ) { TiXmlElement* child = node->FirstChildElement( value ); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( int count ) const { if ( node ) { int i; TiXmlNode* child = node->FirstChild(); for ( i=0; child && iNextSibling(), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const { if ( node ) { int i; TiXmlNode* child = node->FirstChild( value ); for ( i=0; child && iNextSibling( value ), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( int count ) const { if ( node ) { int i; TiXmlElement* child = node->FirstChildElement(); for ( i=0; child && iNextSiblingElement(), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const { if ( node ) { int i; TiXmlElement* child = node->FirstChildElement( value ); for ( i=0; child && iNextSiblingElement( value ), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) { return true; } bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) { return true; } bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { DoIndent(); buffer += "<"; buffer += element.Value(); for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { buffer += " "; attrib->Print( 0, 0, &buffer ); } if ( !element.FirstChild() ) { buffer += " />"; DoLineBreak(); } else { buffer += ">"; if ( element.FirstChild()->ToText() && element.LastChild() == element.FirstChild() && element.FirstChild()->ToText()->CDATA() == false ) { simpleTextPrint = true; // no DoLineBreak()! } else { DoLineBreak(); } } ++depth; return true; } bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) { --depth; if ( !element.FirstChild() ) { // nothing. } else { if ( simpleTextPrint ) { simpleTextPrint = false; } else { DoIndent(); } buffer += ""; DoLineBreak(); } return true; } bool TiXmlPrinter::Visit( const TiXmlText& text ) { if ( text.CDATA() ) { DoIndent(); buffer += ""; DoLineBreak(); } else if ( simpleTextPrint ) { TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; } else { DoIndent(); TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; DoLineBreak(); } return true; } bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { DoIndent(); declaration.Print( 0, 0, &buffer ); DoLineBreak(); return true; } bool TiXmlPrinter::Visit( const TiXmlComment& comment ) { DoIndent(); buffer += ""; DoLineBreak(); return true; } bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) { DoIndent(); buffer += "<"; buffer += unknown.Value(); buffer += ">"; DoLineBreak(); return true; } biosig-2.3.3/biosig4c++/XMLParser/tinyxmlerror.cpp0000664000175000017500000000337714105434233022120 0ustar schloeglschloegl/* www.sourceforge.net/projects/tinyxml Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "tinyxml.h" // The goal of the seperate error file is to make the first // step towards localization. tinyxml (currently) only supports // english error messages, but the could now be translated. // // It also cleans up the code a bit. // const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = { "No error", "Error", "Failed to open file", "Error parsing Element.", "Failed to read Element name", "Error reading Element value.", "Error reading Attributes.", "Error: empty tag.", "Error reading end tag.", "Error parsing Unknown.", "Error parsing Comment.", "Error parsing Declaration.", "Error document empty.", "Error null (0) or unexpected EOF found in input stream.", "Error parsing CDATA.", "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", }; biosig-2.3.3/biosig4c++/XMLParser/tinyxmlparser.cpp0000664000175000017500000011057214105434233022257 0ustar schloeglschloegl/* www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include #include #include "tinyxml.h" //#define DEBUG_PARSER #if defined( DEBUG_PARSER ) # if defined( DEBUG ) && defined( _MSC_VER ) # include # define TIXML_LOG OutputDebugString # else # define TIXML_LOG printf # endif #endif // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries // or order will break putstring. TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = { { "&", 5, '&' }, { "<", 4, '<' }, { ">", 4, '>' }, { """, 6, '\"' }, { "'", 6, '\'' } }; // Bunch of unicode info at: // http://www.unicode.org/faq/utf_bom.html // Including the basic of this table, which determines the #bytes in the // sequence from the lead byte. 1 placed for invalid sequences -- // although the result will be junk, pass it through as much as possible. // Beware of the non-characters in UTF-8: // ef bb bf (Microsoft "lead bytes") // ef bf be // ef bf bf const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; const int TiXmlBase::utf8ByteTable[256] = { // 0 1 2 3 4 5 6 7 8 9 a b c d e f 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid }; void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) { const unsigned long BYTE_MASK = 0xBF; const unsigned long BYTE_MARK = 0x80; const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; if (input < 0x80) *length = 1; else if ( input < 0x800 ) *length = 2; else if ( input < 0x10000 ) *length = 3; else if ( input < 0x200000 ) *length = 4; else { *length = 0; return; } // This code won't covert this correctly anyway. output += *length; // Scary scary fall throughs. switch (*length) { case 4: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 3: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 2: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 1: --output; *output = (char)(input | FIRST_BYTE_MARK[*length]); } } /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying // to figure out alhabetical vs. not across encoding. So take a very // conservative approach. // if ( encoding == TIXML_ENCODING_UTF8 ) // { if ( anyByte < 127 ) return isalpha( anyByte ); else return 1; // What else to do? The unicode set is huge...get the english ones right. // } // else // { // return isalpha( anyByte ); // } } /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying // to figure out alhabetical vs. not across encoding. So take a very // conservative approach. // if ( encoding == TIXML_ENCODING_UTF8 ) // { if ( anyByte < 127 ) return isalnum( anyByte ); else return 1; // What else to do? The unicode set is huge...get the english ones right. // } // else // { // return isalnum( anyByte ); // } } class TiXmlParsingData { friend class TiXmlDocument; public: void Stamp( const char* now, TiXmlEncoding encoding ); const TiXmlCursor& Cursor() const { return cursor; } private: // Only used by the document! TiXmlParsingData( const char* start, int _tabsize, int row, int col ) { assert( start ); stamp = start; tabsize = _tabsize; cursor.row = row; cursor.col = col; } TiXmlCursor cursor; const char* stamp; int tabsize; }; void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) { assert( now ); // Do nothing if the tabsize is 0. if ( tabsize < 1 ) { return; } // Get the current row, column. int row = cursor.row; int col = cursor.col; const char* p = stamp; assert( p ); while ( p < now ) { // Treat p as unsigned, so we have a happy compiler. const unsigned char* pU = (const unsigned char*)p; // Code contributed by Fletcher Dunn: (modified by lee) switch (*pU) { case 0: // We *should* never get here, but in case we do, don't // advance past the terminating null character, ever return; case '\r': // bump down to the next line ++row; col = 0; // Eat the character ++p; // Check for \r\n sequence, and treat this as a single character if (*p == '\n') { ++p; } break; case '\n': // bump down to the next line ++row; col = 0; // Eat the character ++p; // Check for \n\r sequence, and treat this as a single // character. (Yes, this bizarre thing does occur still // on some arcane platforms...) if (*p == '\r') { ++p; } break; case '\t': // Eat the character ++p; // Skip to next tab stop col = (col / tabsize + 1) * tabsize; break; case TIXML_UTF_LEAD_0: if ( encoding == TIXML_ENCODING_UTF8 ) { if ( *(p+1) && *(p+2) ) { // In these cases, don't advance the column. These are // 0-width spaces. if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) p += 3; else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) p += 3; else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) p += 3; else { p +=3; ++col; } // A normal character. } } else { ++p; ++col; } break; default: if ( encoding == TIXML_ENCODING_UTF8 ) { // Eat the 1 to 4 byte utf8 character. int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; if ( step == 0 ) step = 1; // Error case from bad encoding, but handle gracefully. p += step; // Just advance one column, of course. ++col; } else { ++p; ++col; } break; } } cursor.row = row; cursor.col = col; assert( cursor.row >= -1 ); assert( cursor.col >= -1 ); stamp = p; assert( stamp ); } const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) { if ( !p || !*p ) { return 0; } if ( encoding == TIXML_ENCODING_UTF8 ) { while ( *p ) { const unsigned char* pU = (const unsigned char*)p; // Skip the stupid Microsoft UTF-8 Byte order marks if ( *(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) { p += 3; continue; } else if(*(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==0xbfU && *(pU+2)==0xbeU ) { p += 3; continue; } else if(*(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==0xbfU && *(pU+2)==0xbfU ) { p += 3; continue; } if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. ++p; else break; } } else { while ( *p && IsWhiteSpace( *p ) ) ++p; } return p; } #ifdef TIXML_USE_STL /*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) { for( ;; ) { if ( !in->good() ) return false; int c = in->peek(); // At this scope, we can't get to a document. So fail silently. if ( !IsWhiteSpace( c ) || c <= 0 ) return true; *tag += (char) in->get(); } } /*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) { //assert( character > 0 && character < 128 ); // else it won't work in utf-8 while ( in->good() ) { int c = in->peek(); if ( c == character ) return true; if ( c <= 0 ) // Silent failure: can't get document at this scope return false; in->get(); *tag += (char) c; } return false; } #endif // One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The // "assign" optimization removes over 10% of the execution time. // const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) { // Oddly, not supported on some comilers, //name->clear(); // So use this: *name = ""; assert( p ); // Names start with letters or underscores. // Of course, in unicode, tinyxml has no idea what a letter *is*. The // algorithm is generous. // // After that, they can be letters, underscores, numbers, // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) if ( p && *p && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) { const char* start = p; while( p && *p && ( IsAlphaNum( (unsigned char ) *p, encoding ) || *p == '_' || *p == '-' || *p == '.' || *p == ':' ) ) { //(*name) += *p; // expensive ++p; } if ( p-start > 0 ) { name->assign( start, p-start ); } return p; } return 0; } const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) { // Presume an entity, and pull it out. TIXML_STRING ent; int i; *length = 0; if ( *(p+1) && *(p+1) == '#' && *(p+2) ) { unsigned long ucs = 0; ptrdiff_t delta = 0; unsigned mult = 1; if ( *(p+2) == 'x' ) { // Hexadecimal. if ( !*(p+3) ) return 0; const char* q = p+3; q = strchr( q, ';' ); if ( !q || !*q ) return 0; delta = q-p; --q; while ( *q != 'x' ) { if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else if ( *q >= 'a' && *q <= 'f' ) ucs += mult * (*q - 'a' + 10); else if ( *q >= 'A' && *q <= 'F' ) ucs += mult * (*q - 'A' + 10 ); else return 0; mult *= 16; --q; } } else { // Decimal. if ( !*(p+2) ) return 0; const char* q = p+2; q = strchr( q, ';' ); if ( !q || !*q ) return 0; delta = q-p; --q; while ( *q != '#' ) { if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else return 0; mult *= 10; --q; } } if ( encoding == TIXML_ENCODING_UTF8 ) { // convert the UCS to UTF-8 ConvertUTF32ToUTF8( ucs, value, length ); } else { *value = (char)ucs; *length = 1; } return p + delta + 1; } // Now try to match it. for( i=0; iappend( cArr, len ); } } else { bool whitespace = false; // Remove leading white space: p = SkipWhiteSpace( p, encoding ); while ( p && *p && !StringEqual( p, endTag, caseInsensitive, encoding ) ) { if ( *p == '\r' || *p == '\n' ) { whitespace = true; ++p; } else if ( IsWhiteSpace( *p ) ) { whitespace = true; ++p; } else { // If we've found whitespace, add it before the // new character. Any whitespace just becomes a space. if ( whitespace ) { (*text) += ' '; whitespace = false; } int len; char cArr[4] = { 0, 0, 0, 0 }; p = GetChar( p, cArr, &len, encoding ); if ( len == 1 ) (*text) += cArr[0]; // more efficient else text->append( cArr, len ); } } } if ( p && *p ) p += strlen( endTag ); return ( p && *p ) ? p : 0; } #ifdef TIXML_USE_STL void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) { // The basic issue with a document is that we don't know what we're // streaming. Read something presumed to be a tag (and hope), then // identify it, and call the appropriate stream method on the tag. // // This "pre-streaming" will never read the closing ">" so the // sub-tag can orient itself. if ( !StreamTo( in, '<', tag ) ) { SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } while ( in->good() ) { int tagIndex = (int) tag->length(); while ( in->good() && in->peek() != '>' ) { int c = in->get(); if ( c <= 0 ) { SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); break; } (*tag) += (char) c; } if ( in->good() ) { // We now have something we presume to be a node of // some sort. Identify it, and call the node to // continue streaming. TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); if ( node ) { node->StreamIn( in, tag ); bool isElement = node->ToElement() != 0; delete node; node = 0; // If this is the root element, we're done. Parsing will be // done by the >> operator. if ( isElement ) { return; } } else { SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } } } // We should have returned sooner. SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); } #endif const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) { ClearError(); // Parse away, at the document level. Since a document // contains nothing but other tags, most of what happens // here is skipping white space. if ( !p || !*p ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } // Note that, for a document, this needs to come // before the while space skip, so that parsing // starts from the pointer we are given. location.Clear(); if ( prevData ) { location.row = prevData->cursor.row; location.col = prevData->cursor.col; } else { location.row = 0; location.col = 0; } TiXmlParsingData data( p, TabSize(), location.row, location.col ); location = data.Cursor(); if ( encoding == TIXML_ENCODING_UNKNOWN ) { // Check for the Microsoft UTF-8 lead bytes. const unsigned char* pU = (const unsigned char*)p; if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) { encoding = TIXML_ENCODING_UTF8; useMicrosoftBOM = true; } } p = SkipWhiteSpace( p, encoding ); if ( !p ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } while ( p && *p ) { TiXmlNode* node = Identify( p, encoding ); if ( node ) { p = node->Parse( p, &data, encoding ); LinkEndChild( node ); } else { break; } // Did we get encoding info? if ( encoding == TIXML_ENCODING_UNKNOWN && node->ToDeclaration() ) { TiXmlDeclaration* dec = node->ToDeclaration(); const char* enc = dec->Encoding(); assert( enc ); if ( *enc == 0 ) encoding = TIXML_ENCODING_UTF8; else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) encoding = TIXML_ENCODING_UTF8; else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice else encoding = TIXML_ENCODING_LEGACY; } p = SkipWhiteSpace( p, encoding ); } // Was this empty? if ( !firstChild ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); return 0; } // All is well. return p; } void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) { // The first error in a chain is more accurate - don't set again! if ( error ) return; assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); error = true; errorId = err; errorDesc = errorString[ errorId ]; errorLocation.Clear(); if ( pError && data ) { data->Stamp( pError, encoding ); errorLocation = data->Cursor(); } } TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) { TiXmlNode* returnNode = 0; p = SkipWhiteSpace( p, encoding ); if( !p || !*p || *p != '<' ) { return 0; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { return 0; } // What is this thing? // - Elements start with a letter or underscore, but xml is reserved. // - Comments: "; if ( !StringEqual( p, startTag, false, encoding ) ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); return 0; } p += strlen( startTag ); // [ 1475201 ] TinyXML parses entities in comments // Oops - ReadText doesn't work, because we don't want to parse the entities. // p = ReadText( p, &value, false, endTag, false, encoding ); // // from the XML spec: /* [Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments. An example of a comment: */ value = ""; // Keep all the white space. while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) { value.append( p, 1 ); ++p; } if ( p && *p ) p += strlen( endTag ); return p; } const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) return 0; if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } // Read the name, the '=' and the value. const char* pErr = p; p = ReadName( p, &name, encoding ); if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); return 0; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p || *p != '=' ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } ++p; // skip '=' p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } const char* end; const char SINGLE_QUOTE = '\''; const char DOUBLE_QUOTE = '\"'; if ( *p == SINGLE_QUOTE ) { ++p; end = "\'"; // single quote in string p = ReadText( p, &value, false, end, false, encoding ); } else if ( *p == DOUBLE_QUOTE ) { ++p; end = "\""; // double quote in string p = ReadText( p, &value, false, end, false, encoding ); } else { // All attribute values should be in single or double quotes. // But this is such a common error that the parser will try // its best, even without them. value = ""; while ( p && *p // existence && !IsWhiteSpace( *p ) // whitespace && *p != '/' && *p != '>' ) // tag end { if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { // [ 1451649 ] Attribute values with trailing quotes not handled correctly // We did not have an opening quote but seem to have a // closing one. Give up and throw an error. if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } value += *p; ++p; } } return p; } #ifdef TIXML_USE_STL void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { int c = in->peek(); if ( !cdata && (c == '<' ) ) { return; } if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; in->get(); // "commits" the peek made above if ( cdata && c == '>' && tag->size() >= 3 ) { size_t len = tag->size(); if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { // terminator of cdata. return; } } } } #endif const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { value = ""; TiXmlDocument* document = GetDocument(); if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } const char* const startTag = ""; if ( cdata || StringEqual( p, startTag, false, encoding ) ) { cdata = true; if ( !StringEqual( p, startTag, false, encoding ) ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); return 0; } p += strlen( startTag ); // Keep all the white space, ignore the encoding, etc. while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) { value += *p; ++p; } TIXML_STRING dummy; p = ReadText( p, &dummy, false, endTag, false, encoding ); return p; } else { bool ignoreWhite = true; const char* end = "<"; p = ReadText( p, &value, ignoreWhite, end, false, encoding ); if ( p && *p ) return p-1; // don't truncate the '<' return 0; } } #ifdef TIXML_USE_STL void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { int c = in->get(); if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; if ( c == '>' ) { // All is well. return; } } } #endif const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) { p = SkipWhiteSpace( p, _encoding ); // Find the beginning, find the end, and look for // the stuff in-between. TiXmlDocument* document = GetDocument(); if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); return 0; } if ( data ) { data->Stamp( p, _encoding ); location = data->Cursor(); } p += 5; version = ""; encoding = ""; standalone = ""; while ( p && *p ) { if ( *p == '>' ) { ++p; return p; } p = SkipWhiteSpace( p, _encoding ); if ( StringEqual( p, "version", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); version = attrib.Value(); } else if ( StringEqual( p, "encoding", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); encoding = attrib.Value(); } else if ( StringEqual( p, "standalone", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); standalone = attrib.Value(); } else { // Read over whatever it is. while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) ++p; } } return 0; } bool TiXmlText::Blank() const { for ( unsigned i=0; i This file is part of the "BioSig for C/C++" repository (biosig4c++) at http://biosig.sf.net/ BioSig 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 3 of the License, or (at your option) any later version. */ #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED #ifndef TIXML_USE_STL #define TIXML_USE_STL #endif #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4530 ) #pragma warning( disable : 4786 ) #endif #include #include #include #include #include #ifdef HAVE_ZLIB #include #ifndef ZLIB_H #if defined(__MINGW64__) #include "../win64/zlib/zlib.h" #elif defined(__MINGW32__) #include "../win32/zlib/include/zlib.h" #endif #endif #endif // Help out windows: #if defined( _DEBUG ) && !defined( DEBUG ) #define DEBUG #endif #ifdef TIXML_USE_STL #include #include #include #define TIXML_STRING std::string #else #include "tinystr.h" #define TIXML_STRING TiXmlString #endif // Deprecated library function hell. Compilers want to use the // new safe versions. This probably doesn't fully address the problem, // but it gets closer. There are too many compilers for me to fully // test. If you get compilation troubles, undefine TIXML_SAFE #define TIXML_SAFE #ifdef TIXML_SAFE #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) // Microsoft visual studio, version 2005 and higher. #define TIXML_SNPRINTF _snprintf_s #define TIXML_SSCANF sscanf_s #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) // Microsoft visual studio, version 6 and higher. //#pragma message( "Using _sn* functions." ) #define TIXML_SNPRINTF _snprintf /* Flawfinder: ignore *** Buffer size checked in each case */ #define TIXML_SSCANF sscanf /* Flawfinder: ignore *** Only %d and %lf are used */ #elif defined(__GNUC__) && (__GNUC__ >= 3 ) // GCC version 3 and higher.s //#warning( "Using sn* functions." ) #define TIXML_SNPRINTF snprintf /* Flawfinder: ignore *** Buffer size checked in each case */ #define TIXML_SSCANF sscanf /* Flawfinder: ignore *** Only %d and %lf are used */ #else #define TIXML_SNPRINTF snprintf /* Flawfinder: ignore *** Buffer size checked in each case */ #define TIXML_SSCANF sscanf /* Flawfinder: ignore *** Only %d and %lf are used */ #endif #endif class TiXmlDocument; class TiXmlElement; class TiXmlComment; class TiXmlUnknown; class TiXmlAttribute; class TiXmlText; class TiXmlDeclaration; class TiXmlParsingData; const int TIXML_MAJOR_VERSION = 2; const int TIXML_MINOR_VERSION = 6; const int TIXML_PATCH_VERSION = 2; /* Internal structure for tracking location of items in the XML file. */ struct TiXmlCursor { TiXmlCursor() { Clear(); } void Clear() { row = col = -1; } int row; // 0 based. int col; // 0 based. }; /** Implements the interface to the "Visitor pattern" (see the Accept() method.) If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks. For nodes that contain other nodes (Document, Element) you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves are simply called with Visit(). If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its sibilings will be Visited. All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you. Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. You should never change the document from a callback. @sa TiXmlNode::Accept() */ class TiXmlVisitor { public: virtual ~TiXmlVisitor() {} /// Visit a document. virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } /// Visit a document. virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } /// Visit an element. virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } /// Visit an element. virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } /// Visit a declaration virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } /// Visit a text node virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } /// Visit a comment node virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } /// Visit an unknown node virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } }; // Only used by Attribute::Query functions enum { TIXML_SUCCESS, TIXML_NO_ATTRIBUTE, TIXML_WRONG_TYPE }; // Used by the parsing routines. enum TiXmlEncoding { TIXML_ENCODING_UNKNOWN, TIXML_ENCODING_UTF8, TIXML_ENCODING_LEGACY }; const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; /** TiXmlBase is a base class for every class in TinyXml. It does little except to establish that TinyXml classes can be printed and provide some utility functions. In XML, the document and elements can contain other elements and other types of nodes. @verbatim A Document can contain: Element (container or leaf) Comment (leaf) Unknown (leaf) Declaration( leaf ) An Element can contain: Element (container or leaf) Text (leaf) Attributes (not on tree) Comment (leaf) Unknown (leaf) A Decleration contains: Attributes (not on tree) @endverbatim */ class TiXmlBase { friend class TiXmlNode; friend class TiXmlElement; friend class TiXmlDocument; public: TiXmlBase() : userData(0) {} virtual ~TiXmlBase() {} /** All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null. This is a formatted print, and will insert tabs and newlines. (For an unformatted stream, use the << operator.) */ virtual void Print( FILE* cfile, int depth ) const = 0; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth ) const = 0; #endif /** The world does not agree on whether white space should be kept or not. In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this value is not thread safe. */ static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } /// Return the current white space setting. static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } /** Return the position, in the original source file, of this node or attribute. The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value. Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>. The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document. There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. @sa TiXmlDocument::SetTabSize() */ int Row() const { return location.row + 1; } int Column() const { return location.col + 1; } ///< See Row() void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. // Table that returs, for a given lead byte, the total number of bytes // in the UTF-8 sequence. static const int utf8ByteTable[256]; virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities! */ static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); enum { TIXML_NO_ERROR = 0, TIXML_ERROR, TIXML_ERROR_OPENING_FILE, TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ATTRIBUTES, TIXML_ERROR_PARSING_EMPTY, TIXML_ERROR_READING_END_TAG, TIXML_ERROR_PARSING_UNKNOWN, TIXML_ERROR_PARSING_COMMENT, TIXML_ERROR_PARSING_DECLARATION, TIXML_ERROR_DOCUMENT_EMPTY, TIXML_ERROR_EMBEDDED_NULL, TIXML_ERROR_PARSING_CDATA, TIXML_ERROR_DOCUMENT_TOP_ONLY, TIXML_ERROR_STRING_COUNT }; protected: static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); inline static bool IsWhiteSpace( char c ) { return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); } inline static bool IsWhiteSpace( int c ) { if ( c < 256 ) return IsWhiteSpace( (char) c ); return false; // Again, only truly correct for English/Latin...but usually works. } #ifdef TIXML_USE_STL static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); #endif /* Reads an XML name into the string provided. Returns a pointer just past the last character of the name, or 0 if the function has an error. */ static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); /* Reads text. Returns a pointer past the given end tag. Wickedly complex options, but it keeps the (sensitive) code in one place. */ static const char* ReadText( const char* in, // where to start TIXML_STRING* text, // the string read bool ignoreWhiteSpace, // whether to keep the white space const char* endTag, // what ends this text bool ignoreCase, // whether to ignore case in the end tag TiXmlEncoding encoding ); // the current encoding // If an entity has been found, transform it into a character. static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); // Get a character, while interpreting entities. // The length can be from 0 to 4 bytes. inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) { assert( p ); if ( encoding == TIXML_ENCODING_UTF8 ) { *length = utf8ByteTable[ *((const unsigned char*)p) ]; assert( *length >= 0 && *length < 5 ); } else { *length = 1; } if ( *length == 1 ) { if ( *p == '&' ) return GetEntity( p, _value, length, encoding ); *_value = *p; return p+1; } else if ( *length ) { //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), // and the null terminator isn't needed for( int i=0; p[i] && i<*length; ++i ) { _value[i] = p[i]; } return p + (*length); } else { // Not valid text. return 0; } } // Return true if the next characters in the stream are any of the endTag sequences. // Ignore case only works for english, and should only be relied on when comparing // to English words: StringEqual( p, "version", true ) is fine. static bool StringEqual( const char* p, const char* endTag, bool ignoreCase, TiXmlEncoding encoding ); static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; TiXmlCursor location; /// Field containing a generic user pointer void* userData; // None of these methods are reliable for any language except English. // Good for approximation, not great for accuracy. static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); inline static int ToLower( int v, TiXmlEncoding encoding ) { if ( encoding == TIXML_ENCODING_UTF8 ) { if ( v < 128 ) return tolower( v ); return v; } else { return tolower( v ); } } static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); private: TiXmlBase( const TiXmlBase& ); // not implemented. void operator=( const TiXmlBase& base ); // not allowed. struct Entity { const char* str; unsigned int strLength; char chr; }; enum { NUM_ENTITY = 5, MAX_ENTITY_LENGTH = 6 }; static Entity entity[ NUM_ENTITY ]; static bool condenseWhiteSpace; }; /** The parent class for everything in the Document Object Model. (Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type. */ class TiXmlNode : public TiXmlBase { friend class TiXmlDocument; friend class TiXmlElement; public: #ifdef TIXML_USE_STL /** An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. */ friend std::istream& operator >> (std::istream& in, TiXmlNode& base); /** An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines. The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines. But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind. A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. */ friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); /// Appends the XML node or attribute to a std::string. friend std::string& operator<< (std::string& out, const TiXmlNode& base ); #endif /** The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.) */ enum NodeType { TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, TINYXML_DECLARATION, TINYXML_TYPECOUNT }; virtual ~TiXmlNode(); /** The meaning of 'value' changes for the specific type of TiXmlNode. @verbatim Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string @endverbatim The subclasses will wrap this function. */ const char *Value() const { return value.c_str (); } #ifdef TIXML_USE_STL /** Return Value() as a std::string. If you only use STL, this is more efficient than calling Value(). Only available in STL mode. */ const std::string& ValueStr() const { return value; } #endif const TIXML_STRING& ValueTStr() const { return value; } /** Changes the value of the node. Defined as: @verbatim Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string @endverbatim */ void SetValue(const char * _value) { value = _value;} #ifdef TIXML_USE_STL /// STL std::string form. void SetValue( const std::string& _value ) { value = _value; } #endif /// Delete all the children of this node. Does not affect 'this'. void Clear(); /// One step up the DOM. TiXmlNode* Parent() { return parent; } const TiXmlNode* Parent() const { return parent; } const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. TiXmlNode* FirstChild() { return firstChild; } const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. /// The first child of this node with the matching 'value'. Will be null if none found. TiXmlNode* FirstChild( const char * _value ) { // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) // call the method, cast the return back to non-const. return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); } const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. TiXmlNode* LastChild() { return lastChild; } const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. TiXmlNode* LastChild( const char * _value ) { return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); } #ifdef TIXML_USE_STL const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. #endif /** An alternate way to walk the children of a node. One way to iterate over nodes is: @verbatim for( child = parent->FirstChild(); child; child = child->NextSibling() ) @endverbatim IterateChildren does the same thing with the syntax: @verbatim child = 0; while( child = parent->IterateChildren( child ) ) @endverbatim IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done. */ const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const TiXmlNode* previous ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); } /// This flavor of IterateChildren searches for children with a particular 'value' const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); } #ifdef TIXML_USE_STL const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. #endif /** Add a new node related to this. Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); /** Add a new node related to this. Adds a child past the LastChild. NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions. @sa InsertEndChild */ TiXmlNode* LinkEndChild( TiXmlNode* addThis ); /** Add a new node related to this. Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); /** Add a new node related to this. Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); /** Replace a child of this node. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); /// Delete a child of this node. bool RemoveChild( TiXmlNode* removeThis ); /// Navigate to a sibling node. const TiXmlNode* PreviousSibling() const { return prev; } TiXmlNode* PreviousSibling() { return prev; } /// Navigate to a sibling node. const TiXmlNode* PreviousSibling( const char * ) const; TiXmlNode* PreviousSibling( const char *_prev ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); } #ifdef TIXML_USE_STL const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. #endif /// Navigate to a sibling node. const TiXmlNode* NextSibling() const { return next; } TiXmlNode* NextSibling() { return next; } /// Navigate to a sibling node with the given 'value'. const TiXmlNode* NextSibling( const char * ) const; TiXmlNode* NextSibling( const char* _next ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ const TiXmlElement* NextSiblingElement() const; TiXmlElement* NextSiblingElement() { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ const TiXmlElement* NextSiblingElement( const char * ) const; TiXmlElement* NextSiblingElement( const char *_next ) { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); } #ifdef TIXML_USE_STL const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. #endif /// Convenience function to get through elements. const TiXmlElement* FirstChildElement() const; TiXmlElement* FirstChildElement() { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); } /// Convenience function to get through elements. const TiXmlElement* FirstChildElement( const char * _value ) const; TiXmlElement* FirstChildElement( const char * _value ) { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); } #ifdef TIXML_USE_STL const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. #endif /** Query the type (as an enumerated value, above) of this node. The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. */ int Type() const { return type; } /** Return a pointer to the Document this node lives in. Returns null if not in a document. */ const TiXmlDocument* GetDocument() const; TiXmlDocument* GetDocument() { return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); } /// Returns true if this node has no children. bool NoChildren() const { return !firstChild; } virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. /** Create an exact duplicate of this node and return it. The memory must be deleted by the caller. */ virtual TiXmlNode* Clone() const = 0; /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface. This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.) The interface has been based on ideas from: - http://www.saxproject.org/ - http://c2.com/cgi/wiki?HierarchicalVisitorPattern Which are both good references for "visiting". An example of using Accept(): @verbatim TiXmlPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); @endverbatim */ virtual bool Accept( TiXmlVisitor* visitor ) const = 0; protected: TiXmlNode( NodeType _type ); // Copy to the allocated object. Shared functionality between Clone, Copy constructor, // and the assignment operator. void CopyTo( TiXmlNode* target ) const; #ifdef TIXML_USE_STL // The real work of the input operator. virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; #endif // Figure out what is at *p, and parse it. Returns null if it is not an xml node. TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); TiXmlNode* parent; NodeType type; TiXmlNode* firstChild; TiXmlNode* lastChild; TIXML_STRING value; TiXmlNode* prev; TiXmlNode* next; private: TiXmlNode( const TiXmlNode& ); // not implemented. void operator=( const TiXmlNode& base ); // not allowed. }; /** An attribute is a name-value pair. Elements have an arbitrary number of attributes, each with a unique name. @note The attributes are not TiXmlNodes, since they are not part of the tinyXML document object model. There are other suggested ways to look at this problem. */ class TiXmlAttribute : public TiXmlBase { friend class TiXmlAttributeSet; public: /// Construct an empty attribute. TiXmlAttribute() : TiXmlBase() { document = 0; prev = next = 0; } #ifdef TIXML_USE_STL /// std::string constructor. TiXmlAttribute( const std::string& _name, const std::string& _value ) { name = _name; value = _value; document = 0; prev = next = 0; } #endif /// Construct an attribute with a name and value. TiXmlAttribute( const char * _name, const char * _value ) { name = _name; value = _value; document = 0; prev = next = 0; } const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. #ifdef TIXML_USE_STL const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. #endif int IntValue() const; ///< Return the value of this attribute, converted to an integer. double DoubleValue() const; ///< Return the value of this attribute, converted to a double. // Get the tinyxml string representation const TIXML_STRING& NameTStr() const { return name; } /** QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls. */ int QueryIntValue( int* _value ) const; /// QueryDoubleValue examines the value string. See QueryIntValue(). int QueryDoubleValue( double* _value ) const; void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. void SetValue( const char* _value ) { value = _value; } ///< Set the value. void SetIntValue( int _value ); ///< Set the value from an integer. void SetDoubleValue( double _value ); ///< Set the value from a double. #ifdef TIXML_USE_STL /// STL std::string form. void SetName( const std::string& _name ) { name = _name; } /// STL std::string form. void SetValue( const std::string& _value ) { value = _value; } #endif /// Get the next sibling attribute in the DOM. Returns null at end. const TiXmlAttribute* Next() const; TiXmlAttribute* Next() { return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); } /// Get the previous sibling attribute in the DOM. Returns null at beginning. const TiXmlAttribute* Previous() const; TiXmlAttribute* Previous() { return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); } bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } /* Attribute parsing starts: first letter of the name returns: the next char after the value end quote */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); // Prints this Attribute to a FILE stream. virtual void Print( FILE* cfile, int depth ) const { Print( cfile, depth, 0 ); } void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; #ifdef ZLIB_H // Print through zlib virtual void gzPrint( gzFile cfile, int depth ) const { gzPrint( cfile, depth, 0); } void gzPrint( gzFile cfile, int depth, TIXML_STRING* str ) const; #endif // [internal use] // Set the document pointer so the attribute can report errors. void SetDocument( TiXmlDocument* doc ) { document = doc; } private: TiXmlAttribute( const TiXmlAttribute& ); // not implemented. void operator=( const TiXmlAttribute& base ); // not allowed. TiXmlDocument* document; // A pointer back to a document, for error reporting. TIXML_STRING name; TIXML_STRING value; TiXmlAttribute* prev; TiXmlAttribute* next; }; /* A class used to manage a group of attributes. It is only used internally, both by the ELEMENT and the DECLARATION. The set can be changed transparent to the Element and Declaration classes that use it, but NOT transparent to the Attribute which has to implement a next() and previous() method. Which makes it a bit problematic and prevents the use of STL. This version is implemented with circular lists because: - I like circular lists - it demonstrates some independence from the (typical) doubly linked list. */ class TiXmlAttributeSet { public: TiXmlAttributeSet(); ~TiXmlAttributeSet(); void Add( TiXmlAttribute* attribute ); void Remove( TiXmlAttribute* attribute ); const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Find( const char* _name ) const; TiXmlAttribute* FindOrCreate( const char* _name ); # ifdef TIXML_USE_STL TiXmlAttribute* Find( const std::string& _name ) const; TiXmlAttribute* FindOrCreate( const std::string& _name ); # endif private: //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), //*ME: this class must be also use a hidden/disabled copy-constructor !!! TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) TiXmlAttribute sentinel; }; /** The element is a container class. It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes. */ class TiXmlElement : public TiXmlNode { public: /// Construct an element. TiXmlElement (const char * in_value); #ifdef TIXML_USE_STL /// std::string constructor. TiXmlElement( const std::string& _value ); #endif TiXmlElement( const TiXmlElement& ); TiXmlElement& operator=( const TiXmlElement& base ); virtual ~TiXmlElement(); /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. */ const char* Attribute( const char* name ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an integer, the integer value will be put in the return 'i', if 'i' is non-null. */ const char* Attribute( const char* name, int* i ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an double, the double value will be put in the return 'd', if 'd' is non-null. */ const char* Attribute( const char* name, double* d ) const; /** QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. */ int QueryIntAttribute( const char* name, int* _value ) const; /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). Note that '1', 'true', or 'yes' are considered true, while '0', 'false' and 'no' are considered false. */ int QueryBoolAttribute( const char* name, bool* _value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). int QueryDoubleAttribute( const char* name, double* _value ) const; /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). int QueryFloatAttribute( const char* name, float* _value ) const { double d; int result = QueryDoubleAttribute( name, &d ); if ( result == TIXML_SUCCESS ) { *_value = (float)d; } return result; } #ifdef TIXML_USE_STL /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). int QueryStringAttribute( const char* name, std::string* _value ) const { const char* cstr = Attribute( name ); if ( cstr ) { *_value = std::string( cstr ); return TIXML_SUCCESS; } return TIXML_NO_ATTRIBUTE; } /** Template form of the attribute query which will try to read the attribute into the specified type. Very easy, very powerful, but be careful to make sure to call this with the correct type. NOTE: This method doesn't work correctly for 'string' types that contain spaces. @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE */ template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; std::stringstream sstream( node->ValueStr() ); sstream >> *outValue; if ( !sstream.fail() ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int QueryValueAttribute( const std::string& name, std::string* outValue ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; *outValue = node->ValueStr(); return TIXML_SUCCESS; } #endif /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetAttribute( const char* name, const char * _value ); #ifdef TIXML_USE_STL const std::string* Attribute( const std::string& name ) const; const std::string* Attribute( const std::string& name, int* i ) const; const std::string* Attribute( const std::string& name, double* d ) const; int QueryIntAttribute( const std::string& name, int* _value ) const; int QueryDoubleAttribute( const std::string& name, double* _value ) const; /// STL std::string form. void SetAttribute( const std::string& name, const std::string& _value ); ///< STL std::string form. void SetAttribute( const std::string& name, int _value ); ///< STL std::string form. void SetDoubleAttribute( const std::string& name, double value ); #endif /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetAttribute( const char * name, int value ); /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetDoubleAttribute( const char * name, double value ); /** Deletes an attribute with the given name. */ void RemoveAttribute( const char * name ); #ifdef TIXML_USE_STL void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. #endif const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly. If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned. This is a convenient method for getting the text of simple contained text: @verbatim This is text const char* str = fooElement->GetText(); @endverbatim 'str' will be a pointer to "This is text". Note that this function can be misleading. If the element foo was created from this XML: @verbatim This is text @endverbatim then the value of str would be null. The first child node isn't a text node, it is another element. From this XML: @verbatim This is text @endverbatim GetText() will return "This is ". WARNING: GetText() accesses a child node - don't become confused with the similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are safe type casts on the referenced node. */ const char* GetText() const; /// Creates a new Element and returns it - the returned element is a copy. virtual TiXmlNode* Clone() const; // Print the Element to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth ) const; #endif /* Attribtue parsing starts: next char past '<' returns: next char past '>' */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlElement* target ) const; void ClearThis(); // like clear, but initializes 'this' object as well // Used to be public [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif /* [internal use] Reads the "value" of the element -- another element, or text. This should terminate with the current end tag. */ const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); private: TiXmlAttributeSet attributeSet; }; /** An XML comment. */ class TiXmlComment : public TiXmlNode { public: /// Constructs an empty comment. TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} /// Construct a comment from text. TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { SetValue( _value ); } TiXmlComment( const TiXmlComment& ); TiXmlComment& operator=( const TiXmlComment& base ); virtual ~TiXmlComment() {} /// Returns a copy of this Comment. virtual TiXmlNode* Clone() const; // Write this Comment to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth ) const; #endif /* Attribtue parsing starts: at the ! of the !-- returns: next char past '>' */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlComment* target ) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif // virtual void StreamOut( TIXML_OSTREAM * out ) const; private: }; /** XML text. A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA(). */ class TiXmlText : public TiXmlNode { friend class TiXmlElement; public: /** Constructor for text element. By default, it is treated as normal, encoded text. If you want it be output as a CDATA text element, set the parameter _cdata to 'true' */ TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) { SetValue( initValue ); cdata = false; } virtual ~TiXmlText() {} #ifdef TIXML_USE_STL /// Constructor. TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) { SetValue( initValue ); cdata = false; } #endif TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; } // Write this text object to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth ) const; #endif /// Queries whether this represents text using a CDATA section. bool CDATA() const { return cdata; } /// Turns on or off a CDATA representation of text. void SetCDATA( bool _cdata ) { cdata = _cdata; } virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected : /// [internal use] Creates a new Element and returns it. virtual TiXmlNode* Clone() const; void CopyTo( TiXmlText* target ) const; bool Blank() const; // returns true if all white space and new lines // [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: bool cdata; // true if this should be input and output as a CDATA style text element }; /** In correct XML the declaration is the first entry in the file. @verbatim @endverbatim TinyXml will happily read or write files without a declaration, however. There are 3 possible attributes to the declaration: version, encoding, and standalone. Note: In this version of the code, the attributes are handled as special cases, not generic attributes, simply because there can only be at most 3 and they are always the same. */ class TiXmlDeclaration : public TiXmlNode { public: /// Construct an empty declaration. TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} #ifdef TIXML_USE_STL /// Constructor. TiXmlDeclaration( const std::string& _version, const std::string& _encoding, const std::string& _standalone ); #endif /// Construct. TiXmlDeclaration( const char* _version, const char* _encoding, const char* _standalone ); TiXmlDeclaration( const TiXmlDeclaration& copy ); TiXmlDeclaration& operator=( const TiXmlDeclaration& copy ); virtual ~TiXmlDeclaration() {} /// Version. Will return an empty string if none was found. const char *Version() const { return version.c_str (); } /// Encoding. Will return an empty string if none was found. const char *Encoding() const { return encoding.c_str (); } /// Is this a standalone document? const char *Standalone() const { return standalone.c_str (); } /// Creates a copy of this Declaration and returns it. virtual TiXmlNode* Clone() const; // Print this declaration to a FILE stream. virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; virtual void Print( FILE* cfile, int depth ) const { Print( cfile, depth, 0 ); } #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth, TIXML_STRING* str ) const; virtual void gzPrint( gzFile cfile, int depth ) const { gzPrint( cfile, depth, 0 ); } #endif virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlDeclaration* target ) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: TIXML_STRING version; TIXML_STRING encoding; TIXML_STRING standalone; }; /** Any tag that tinyXml doesn't recognize is saved as an unknown. It is a tag of text, but should not be modified. It will be written back to the XML, unchanged, when the file is saved. DTD tags get thrown into TiXmlUnknowns. */ class TiXmlUnknown : public TiXmlNode { public: TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} virtual ~TiXmlUnknown() {} TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; } /// Creates a copy of this Unknown and returns it. virtual TiXmlNode* Clone() const; // Print this Unknown to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth ) const; #endif virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected: void CopyTo( TiXmlUnknown* target ) const; #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: }; /** Always the top level node. A document binds together all the XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name. */ class TiXmlDocument : public TiXmlNode { public: /// Create an empty document, that has no name. TiXmlDocument(); /// Create a document with a name. The name of the document is also the filename of the xml. TiXmlDocument( const char * documentName ); #ifdef TIXML_USE_STL /// Constructor. TiXmlDocument( const std::string& documentName ); #endif TiXmlDocument( const TiXmlDocument& copy ); TiXmlDocument& operator=( const TiXmlDocument& copy ); virtual ~TiXmlDocument() {} /** Load a file using the current document value. Returns true if successful. Will delete any existing document data before loading. */ bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; /// Load a file using the given filename. Returns true if successful. bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the given filename. Returns true if successful. bool SaveFile( const char * filename ) const; bool SaveFile( const char * filename, char compression ) const; /** Load a file using the given FILE*. Returns true if successful. Note that this method doesn't stream - the entire object pointed at by the FILE* will be interpreted as an XML file. TinyXML doesn't stream in XML from the current file location. Streaming may be added in the future. */ bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the given FILE*. Returns true if successful. bool SaveFile( FILE* ) const; #ifdef ZLIB_H bool LoadFile( gzFile, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); bool SaveFile( gzFile ) const; #endif #ifdef TIXML_USE_STL bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. { return LoadFile( filename.c_str(), encoding ); } bool SaveFile( const std::string& filename ) const ///< STL std::string version. { return SaveFile( filename.c_str() ); } #endif /** Parse the given null terminated block of xml data. Passing in an encoding to this method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml to use that encoding, regardless of what TinyXml might otherwise try to detect. */ virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /** Get the root element -- the only top level element -- of the document. In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level. */ const TiXmlElement* RootElement() const { return FirstChildElement(); } TiXmlElement* RootElement() { return FirstChildElement(); } /** If an error occurs, Error will be set to true. Also, - The ErrorId() will contain the integer identifier of the error (not generally useful) - The ErrorDesc() method will return the name of the error. (very useful) - The ErrorRow() and ErrorCol() will return the location of the error (if known) */ bool Error() const { return error; } /// Contains a textual (english) description of the error if one occurs. const char * ErrorDesc() const { return errorDesc.c_str (); } /** Generally, you probably want the error string ( ErrorDesc() ). But if you prefer the ErrorId, this function will fetch it. */ int ErrorId() const { return errorId; } /** Returns the location (if known) of the error. The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.) @sa SetTabSize, Row, Column */ int ErrorRow() const { return errorLocation.row+1; } int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column. It does not change the output or input in any way. By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to the source file. The tab size is required for calculating the location of nodes. If not set, the default of 4 is used. The tabsize is set per document. Setting the tabsize to 0 disables row/column tracking. Note that row and column tracking is not supported when using operator>>. The tab size needs to be enabled before the parse or load. Correct usage: @verbatim TiXmlDocument doc; doc.SetTabSize( 8 ); doc.Load( "myfile.xml" ); @endverbatim @sa Row, Column */ void SetTabSize( int _tabsize ) { tabsize = _tabsize; } int TabSize() const { return tabsize; } /** If you have handled the error, it can be reset with this call. The error state is automatically cleared if you Parse a new XML block. */ void ClearError() { error = false; errorId = 0; errorDesc = ""; errorLocation.row = errorLocation.col = 0; //errorLocation.last = 0; } /** Write the document to standard out using formatted printing ("pretty print"). */ void Print() const { Print( stdout, 0 ); } /* Write the document to a string using formatted printing ("pretty print"). This will allocate a character array (new char[]) and return it as a pointer. The calling code pust call delete[] on the return char* to avoid a memory leak. */ //char* PrintToMemory() const; /// Print this Document to a FILE stream. virtual void Print( FILE* cfile, int depth = 0 ) const; #ifdef ZLIB_H virtual void gzPrint( gzFile cfile, int depth = 0 ) const; #endif // [internal use] void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected : // [internal use] virtual TiXmlNode* Clone() const; #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: void CopyTo( TiXmlDocument* target ) const; bool error; int errorId; TIXML_STRING errorDesc; int tabsize; TiXmlCursor errorLocation; bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. }; /** A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml DOM structure. It is a separate utility class. Take an example: @verbatim @endverbatim Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a *lot* of code that looks like: @verbatim TiXmlElement* root = document.FirstChildElement( "Document" ); if ( root ) { TiXmlElement* element = root->FirstChildElement( "Element" ); if ( element ) { TiXmlElement* child = element->FirstChildElement( "Child" ); if ( child ) { TiXmlElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful. @endverbatim And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity of such code. A TiXmlHandle checks for null pointers so it is perfectly safe and correct to use: @verbatim TiXmlHandle docHandle( &document ); TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); if ( child2 ) { // do something useful @endverbatim Which is MUCH more concise and useful. It is also safe to copy handles - internally they are nothing more than node pointers. @verbatim TiXmlHandle handleCopy = handle; @endverbatim What they should not be used for is iteration: @verbatim int i=0; while ( true ) { TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); if ( !child ) break; // do something ++i; } @endverbatim It seems reasonable, but it is in fact two embedded while loops. The Child method is a linear walk to find the element, so this code would iterate much more than it needs to. Instead, prefer: @verbatim TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); for( child; child; child=child->NextSiblingElement() ) { // do something } @endverbatim */ class TiXmlHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } /// Copy constructor TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; } /// Return a handle to the first child node. TiXmlHandle FirstChild() const; /// Return a handle to the first child node with the given name. TiXmlHandle FirstChild( const char * value ) const; /// Return a handle to the first child element. TiXmlHandle FirstChildElement() const; /// Return a handle to the first child element with the given name. TiXmlHandle FirstChildElement( const char * value ) const; /** Return a handle to the "index" child with the given name. The first child is 0, the second 1, etc. */ TiXmlHandle Child( const char* value, int index ) const; /** Return a handle to the "index" child. The first child is 0, the second 1, etc. */ TiXmlHandle Child( int index ) const; /** Return a handle to the "index" child element with the given name. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ TiXmlHandle ChildElement( const char* value, int index ) const; /** Return a handle to the "index" child element. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ TiXmlHandle ChildElement( int index ) const; #ifdef TIXML_USE_STL TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } #endif /** Return the handle as a TiXmlNode. This may return null. */ TiXmlNode* ToNode() const { return node; } /** Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } /** Return the handle as a TiXmlText. This may return null. */ TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } /** Return the handle as a TiXmlUnknown. This may return null. */ TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } /** @deprecated use ToNode. Return the handle as a TiXmlNode. This may return null. */ TiXmlNode* Node() const { return ToNode(); } /** @deprecated use ToElement. Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* Element() const { return ToElement(); } /** @deprecated use ToText() Return the handle as a TiXmlText. This may return null. */ TiXmlText* Text() const { return ToText(); } /** @deprecated use ToUnknown() Return the handle as a TiXmlUnknown. This may return null. */ TiXmlUnknown* Unknown() const { return ToUnknown(); } private: TiXmlNode* node; }; /** Print to memory functionality. The TiXmlPrinter is useful when you need to: -# Print to memory (especially in non-STL mode) -# Control formatting (line endings, etc.) When constructed, the TiXmlPrinter is in its default "pretty printing" mode. Before calling Accept() you can call methods to control the printing of the XML document. After TiXmlNode::Accept() is called, the printed document can be accessed via the CStr(), Str(), and Size() methods. TiXmlPrinter uses the Visitor API. @verbatim TiXmlPrinter printer; printer.SetIndent( "\t" ); doc.Accept( &printer ); fprintf( stdout, "%s", printer.CStr() ); @endverbatim */ class TiXmlPrinter : public TiXmlVisitor { public: TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), buffer(), indent( " " ), lineBreak( "\n" ) {} virtual bool VisitEnter( const TiXmlDocument& doc ); virtual bool VisitExit( const TiXmlDocument& doc ); virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); virtual bool VisitExit( const TiXmlElement& element ); virtual bool Visit( const TiXmlDeclaration& declaration ); virtual bool Visit( const TiXmlText& text ); virtual bool Visit( const TiXmlComment& comment ); virtual bool Visit( const TiXmlUnknown& unknown ); /** Set the indent characters for printing. By default 4 spaces but tab (\t) is also useful, or null/empty string for no indentation. */ void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } /// Query the indention string. const char* Indent() { return indent.c_str(); } /** Set the line breaking string. By default set to newline (\n). Some operating systems prefer other characters, or can be set to the null/empty string for no indenation. */ void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } /// Query the current line breaking string. const char* LineBreak() { return lineBreak.c_str(); } /** Switch over to "stream printing" which is the most dense formatting without linebreaks. Common when the XML is needed for network transmission. */ void SetStreamPrinting() { indent = ""; lineBreak = ""; } /// Return the result. const char* CStr() { return buffer.c_str(); } /// Return the length of the result string. size_t Size() { return buffer.size(); } #ifdef TIXML_USE_STL /// Return the result. const std::string& Str() { return buffer; } #endif private: void DoIndent() { for( int i=0; i r MATLAB = / {printf("%s/bin/matlab",$5)}')], [:]) AC_PATH_PROG([MKOCTFILE], [mkoctfile], [:]) AC_PATH_PROG([OCTAVE], [octave], [:]) # PHP AC_PATH_PROG([PHP], [php], [:]) AC_PATH_PROG([PEAR], [pear], [:]) AC_PATH_PROG([PECL], [pecl], [:]) # PYTHON AC_PATH_PROG([PYTHON], [python], [:]) AC_PATH_PROG([PYTHON2], [python2], [:]) AC_PATH_PROG([PYTHON3], [python3], [:]) # R AC_PATH_PROG([R], [R], [:]) # FIXME: Replace `main' with a function in `-llibmex': AC_CHECK_LIB([libmex], [main]) # FIXME: Replace `main' with a function in `-llibmx': AC_CHECK_LIB([libmx], [main]) AC_CHECK_LIB([m], [round], AC_SUBST(HAVE_LIBM, "1") ) # Wolfram/Mathematica Mathlink interface AC_CHECK_LIB([mathlink], [MLPutRealArray], AC_SUBST(HAVE_MATHEMATICA,"1")) AC_CHECK_LIB([uuid], [uuid_generate], AC_SUBST(HAVE_UUID, "1")) #AC_CHECK_LIB([pthread], [pthread_mutex_lock]) # FIXME: Replace `main' with a function in `-lssp': #AC_CHECK_LIB([ssp], [main]) # Checks for header files. AC_FUNC_ALLOCA AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL AC_C_INLINE AC_TYPE_INT16_T AC_TYPE_INT32_T AC_TYPE_INT64_T AC_TYPE_INT8_T AC_TYPE_MODE_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T AC_CHECK_TYPES([ptrdiff_t]) # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_MKTIME AC_FUNC_REALLOC AC_FUNC_STRNLEN AC_FUNC_STRTOD AC_CHECK_FUNCS([alarm atexit bzero dup2 floor getcwd getdelim gethostbyname gethostname gettimeofday localtime_r memchr memmove memset mkdir modf pow putenv rmdir select setenv setlocale socket strcasecmp strchr strcspn strdup strerror strncasecmp strndup strpbrk strrchr strspn strstr strtol strtoul strtoumax tzset]) AC_CONFIG_FILES([Makefile biosig4c++/Makefile biosig4c++/examples/Makefile biosig4c++/igor/Makefile biosig4c++/java/Makefile biosig4c++/magic/Makefile biosig4c++/mex/Makefile biosig4c++/mma/Makefile biosig4c++/perl/Makefile biosig4c++/php/Makefile biosig4c++/python/Makefile biosig4c++/python/setup.py biosig4c++/python/README.md biosig4c++/R/Makefile biosig4c++/R/DESCRIPTION biosig4c++/ruby/Makefile biosig4c++/t240/Makefile biosig4c++/t241/Makefile biosig4c++/tcl/Makefile]) AC_OUTPUT biosig-2.3.3/biosig4matlab/0000775000175000017500000000000014105434233015677 5ustar schloeglschloeglbiosig-2.3.3/biosig4matlab/PKG_ADD0000664000175000017500000000060114105434233016710 0ustar schloeglschloegl% % % subdirs={'doc', 't200_FileAccess', 't210_Events', 't250_ArtifactPreProcessingQualityControl', 't300_FeatureExtraction', 't330_StimFit', 't340_MachineLearningOptimalDetection', 't400_Classification', 't450_MultipleTestStatistic', 't490_EvaluationCriteria', 't500_Visualization', 't501_VisualizeCoupling'}; addpath (fullfile (fileparts (mfilename ('fullpath')), subdirs){:}); biosig-2.3.3/biosig4matlab/t500_Visualization/0000775000175000017500000000000014105434233021310 5ustar schloeglschloeglbiosig-2.3.3/biosig4matlab/t500_Visualization/plota.m0000664000175000017500000034410014105434233022607 0ustar schloeglschloeglfunction H=plota(X,arg2,arg3,arg4,arg5,arg6,arg7) % PLOTA plots all kind of data types % % PLOTA(Labels,'ELPOS') % displays 2-D location of EEG channels described by Labels % PLOTA(Labels,'ELPOS3') % displays 3-D location of EEG channels described by Labels % % PLOTA(X [,Mode]) % PLOTA(X, 'SCATTER') Scatter plot % data is organized in columns % % PLOTA(X, 'BLAND-ALTMAN') Bland-Altman plot, or mean-difference plot % data is organized in columns % % PLOTA(HDR, 'ISI') % PLOTA(filename, 'ISI') % plot Inter-spike-Interval % PLOTA(HDR, 'HRV') % PLOTA(filename, 'HRV') % PLOTA(HDR, 'RRI') % PLOTA(filename, 'RRI') % R-R interval, instantaneous Heart rate % % if X.TYPE=='EVENT' and X.EVENT % % % X.datatype determines type of data % DATATYPE Mode % 'MVAR' 'AutoSpectrum' % 'MVAR' 'SPECTRUM','logS' % 'MVAR' 'logH' % 'MVAR' 'Phase' % 'MVAR' 'COHERENCE' % 'MVAR' 'iCOH' imaginary coherence % 'MVAR' 'iSpectrum' imaginary part of spectrum % 'MVAR' 'DTF' % 'MVAR' 'PDC' % 'MVAR' 'dDTF' % 'MVAR' 'ffDTF' % 'TF-MVAR' Time-frequency MVAR analysis % e.g. plota(X, 'PDC', alpha [, Y]); % % % 'MEAN+STD' % plota(X,hf,minmean,maxmean,maxstd [,trigger]) % arg1 ... R = evoked_potential(...); % arg2 ... hf (handles to figures) % arg3 ... minmean (minimum of mean) % arg4 ... maxmean (maximum of mean) % arg5 ... maxstd (maximum of standard deviation) % arg6 ... trigger (trigger instant) [optional] % % 'QRS_events' shows inter-beat-interval (IBI) of the ecg % % 'HISTOGRAM' 'log' chansel % 'HISTOGRAM' 'log+' chansel % 'HISTOGRAM' 'log ' chansel % 'HISTOGRAM' 'lin' chansel % 'HISTOGRAM' 'PDF' chansel % 'HISTOGRAM' 'logPDF' chansel % % 'SIESTA_HISTOGRAM' chansel % % 'DBI-EPs' % 'TSD1' % 'TSD_BCI7' % 'MDist-matrix' % 'MD' % 'SCATTER' % 'STAT2' % '' % '' % 'REV' Mode='3D' % 'REV' Mode='2D' % % REFERENCE(S): % $Id$ % Copyright (C) 2006,2007,2008,2009,2011 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % % BioSig 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 3 of the License, or % (at your option) any later version. % % BioSig 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 BioSig. If not, see . h = []; if nargin>1, if strncmpi(arg2,'ELPOS',5), if ~isstruct(X), tmp = X; X=[]; X.Label = cellstr(tmp); end; X.datatype = upper(arg2); clf; elseif strcmpi(arg2,'SCATTER') || strcmpi(arg2,'BLAND-ALTMAN'), tmp = X; X=[]; X.datatype = upper(arg2); if isnumeric(tmp) X.data = tmp; if nargin<3, arg3='x'; end; plota(X,arg3); return; end; end; end; if isfield(X,'datatype'); elseif isfield(X,'TYPE'); if strcmp(X.TYPE,'EVENT') if any(X.EVENT.TYP==hex2dec('0501')); X.datatype = 'QRS_events'; H = X; end elseif strcmp(X.TYPE,'ELPOS') if isfield(X,'ELEC') && isfield(X,'Label'); if isfield(X.ELEC,'XYZ'); X.datatype = 'ELPOS'; end; end; end; elseif (nargin>1) else return; end; if 0, elseif (nargin>1) && ( strcmp(arg2,'ISI') || strcmp(arg2,'HRV') || strcmp(arg2,'RRI') ) if strcmp(arg2,'ISI') TYP = hex2dec('0201'); % spike/action potential YLABEL = 'inter-spike interval [s]'; elseif strcmp(arg2,'HRV') || strcmp(arg2,'RRI') TYP = hex2dec('0501'); % fiducial QRS point YLABEL = 'R-R interval [s]'; end; if isstruct(X) && isfield(X,'EVENT') && isfield(X.EVENT,'POS') HDR = X; elseif ischar(X) && exist(X,'file') HDR = sopen(X); %%%%% here, an automated event detection could be include. % candiates are QRS_DETECT, and DETECT_SPIKE_BURST % however, the methods are currently not good enough for a fully automated detection % so, the user should be aware what's going, therefore this is currently not included. HDR = sclose(HDR); else error('1st input argument unknown/unsupported') end; ix = find(HDR.EVENT.TYP==TYP | HDR.EVENT.TYP==hex2dec('7ffe')); T = HDR.EVENT.POS(ix); T(HDR.EVENT.TYP(ix)==hex2dec('7ffe'))=NaN; % segment limit, do not compute interval across segments if isfield(HDR.EVENT,'CHN'); CHN = HDR.EVENT.CHN(ix); else CHN = []; end; if 0, length(unique(CHN))>1, %% FIXME error('events of multiple channels are not supported.'); end; d = diff(T); d = d(~isnan(d))/HDR.SampleRate; if 0, %% coloured ISI's C = 0:size(T,1)-2; CC = zeros(size(C)); ix = diff(T) > 50e-3*HDR.SampleRate; CC(ix) = C(ix); C = C - cumsum(CC) + 1; end; semilogy((T(1:end-1)+T(2:end)) / (2*HDR.EVENT.SampleRate), diff(T)/HDR.EVENT.SampleRate, '.'); title(HDR.FileName); ylabel(YLABEL); xlabel('time [s]'); elseif strcmp(X.datatype,'MVAR'), if ~isfield(X,'A') || ~isfield(X,'B'), fprintf(2,'Error PLOTA: MVAR missing input data\n'); return; end; [K1,K2] = size(X.A); p = K2/K1-1; [K1,K2] = size(X.B); q = K2/K1-1; if ~isfield(X,'C'); X.C=ones(K1,K1); end; if isfield(X,'SampleRate'); Fs = X.SampleRate; elseif nargin < 4, Fs = 1; pi*2; else Fs = arg4; end; if nargin<2, Mode= 'DTF'; Fs = 1; else Mode = arg2; end; if nargin<3, N=512; else N=arg3; end; if all(size(N)==1) f = (0:N)/(2*N)*Fs; else f = N; N = length(N); end; if isfield(X,'Label'); Label = cellstr(X.Label); elseif isfield(X,'ElectrodeName'); if isstruct(X.ElectrodeName); Label = X.ElectrodeName; else for k=1:K1, Label{k}=X.ElectrodeName(k,:); end; end; else for k=1:K1, Label{k}=sprintf('#%02i',k); end; end; if strcmpi(Mode,'Eigen'), [S, Serr, per, tau, exctn, lambda] = armode2(-X.A(:,K1+1:end), X.C); [per(1,:)',Fs./per(1,:)',tau(1,:)'/Fs,exctn',lambda] return; end; [S,h,PDC,COH,DTF,DC,pCOH,dDTF,ffDTF, pCOH2, PDCF, coh, GGC, Af, GPDC, GGC2, DCOH]=mvfreqz(X.B,X.A,X.C,f,Fs); Phase = zeros(size(h)); for k1=1:K1; for k2=1:K2; Phase(k1,k2,:) = unwrap(squeeze(angle(S(k1,k2,:))))*180/pi; end; end; dT = Phase./reshape(repmat(360*f(:)',[K1*K1,1]),[K1,K1,length(f)]); range = [0,1]; % default range if ~isempty(strfind(Mode,'Auto')), if 0, elseif strcmpi(Mode,'AutoSpectrum'), R = abs(S); range = [min(R(:)),max(R(:))]; range = [1e-8,1e0]; else error(['unknown MVAR-parameter: ',arg2]) end; M = size(S,1); K1 = ceil(sqrt(M)); K2 = ceil(M/K1); for k1=1:M; subplot(K1,K2,k1); semilogy(f,squeeze(R(k1,k1,:))); axis([0,max(f),range]); ylabel(Label{k1}); end; else YTICK = []; YTICKLABEL = []; if 0, elseif strcmpi(Mode,'Spectrum') || strcmpi(Mode,'logS'), R = abs(S); range = [min(R(:)),max(R(:))]; range(1) = min(range(1),range(2)/100); %range=[1e-2,1e2]; elseif strcmpi(Mode,'logh'), R = abs(h); range = [min(R(:)),max(R(:))]; range(1) = min(range(1),range(2)/100); %range=[1e-2,1e2]; elseif strcmpi(Mode,'iSpectrum'), R = imag(S); range = [min(R(:)),max(R(:))]; elseif strcmpi(Mode,'rSpectrum'), R = real(S); range = [min(R(:)),max(R(:))]; elseif strcmpi(Mode,'Phase') || strcmpi(Mode,'phaseS') , R = zeros(size(S)); for k1=1:K1; for k2=1:K2; R(k1,k2,:) = unwrap(squeeze(angle(S(k1,k2,:))))*180/pi; end; end; range = [-180,180]*2; range = [min(R(:)),max(R(:))]; elseif strcmpi(Mode,'Phase') || strcmpi(Mode,'phaseh') , R = zeros(size(h)); for k1=1:K1; for k2=1:K2; R(k1,k2,:) = unwrap(squeeze(angle(h(k1,k2,:))))*180/pi; end; end; range = [-180,180]*2; range = [min(R(:)),max(R(:))]; YTICK = -180:90:180; elseif strcmpi(Mode,'PDC'), R = PDC; YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'GPDC'), R = GPDC; YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'Coherence') || strcmp(Mode,'COH'), R = abs(COH); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmp(Mode,'iCOH') || strcmp(Mode,'imagCOH'), R = imag(COH); range = [-1,1]; YTICK = -1:.5:1; YTICKLABEL = {[],'-0.5','0','0.5',[]}; elseif strcmpi(Mode,'pCOH'), R = abs(pCOH); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'pCOH2'), R = abs(pCOH2); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmp(Mode,'coh'), R = abs(coh); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmp(Mode,'icoh'), R = imag(coh); range = [-1,1]; YTICK = -1:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'GGC'), R = log10(GGC); range = [min(R(:)),max(R(:))]; range = [.1,max(R(:))]; elseif strcmpi(Mode,'GGC2'), R = (GGC2); range = [min(R(:)),max(R(:))]; %range = [.1,max(R(:))]; elseif strcmpi(Mode,'DCOH')||strcmpi(Mode,'GDTF'), R = DCOH; YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'Af'), R = abs(Af); for k=1:size(R,1), % R(k,k,:)=NaN; end; range = [min(R(:)),max(R(:))].*[.9,2]; %range = [[.001,1]*max(R(:))] range = [0,max(R(:))]; R = abs(Af); elseif strcmpi(Mode,'Af1'), R = log10(abs(Af))+3; range = [min(R(:)),max(R(:))]; %range = [[.001,1]*max(R(:))] elseif strcmpi(Mode,'PDCF'), R = real(PDCF); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'DTF'), R = DTF; YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'dDTF'), R = real(dDTF); YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'ffDTF'), R = ffDTF; YTICK = 0:.5:1; YTICKLABEL = {'0','0.5',[]}; elseif strcmpi(Mode,'dT'), R = dT; tmp = dT(isfinite(dT(:))); range = [min(tmp(:)),max(tmp(:))]; elseif strcmpi(Mode,'DCF1'), R = S; for k1=1:K1, for k2=1:K1, R(k1,k2,:) = sqrt(X.C(k2,k2)/(2*pi*Fs))*abs(h(k1,k2,:))./sqrt(S(k1,k1,:)); end; end; range = [0,1]; % range = [min(R(:)),max(R(:))]; elseif strcmpi(Mode,'DCF2'), R = S; for k1=1:K1, for k2=1:K1, R(k1,k2,:) = abs(h(k1,k2,:))./sqrt(S(k1,k1,:)); end; end; range = [0,1]; elseif strcmpi(Mode,'DCF'), tmp = S; for k=1:K1, tmp(k,:,:) = tmp(k,repmat(k,1,K1),:); end; R = h./sqrt(tmp); range = [-1,1]; % range = [min(R(:)),max(R(:))]; else error(['unknown MVAR-parameter: ',arg2]) end; for k1=1:K1; for k2=1:K2; subplot(K1,K2,k2+(k1-1)*K1); if strcmpi(Mode,'logS') %| strcmpi(Mode,'Af'), h=semilogy(f,squeeze(R(k1,k2,:))); else h=area(f,squeeze(R(k1,k2,:))); end; axis([0,max(f),range]); set(gca,'position',get(gca,'position').*[1,1,1.2,1.2]), set(gca,'box','off','fontsize',16); if 0, % set(gca,'xticklabelmode','manual','yticklabelmode','manual') if ~isempty(YTICK) set(gca,'ytick',YTICK); end; if ~isempty(YTICKLABEL) set(gca,'yticklabel',YTICKLABEL); end; XTICKLABEL = {'0',[],'0.2',[],'0.4',[]}; XTICKLABEL = []; YTICKLABEL = []; set(gca,'xtickmode','manual','ytickmode','manual','xtick',0:.1:.5); set(gca,'xticklabelmode','manual','yticklabelmode','manual','xticklabel',XTICKLABEL); set(gca,'yticklabel',YTICKLABEL); end; if k2==1; ylabel(Label{k1}); else set(gca,'yticklabel',[]) end; if k1==1; title(Label{k2}); end; if k11), XT = (X.T(1,:)+X.T(2,:))/(2*X.SampleRate); else XT = X.T; end; if isfield(Y,'SampleRate') if (size(Y.T,1) > 1), YT = (Y.T(1,:)+Y.T(2,:))/(2*Y.SampleRate); end; end; gf = arg2; AUTO = ~isempty(strfind(lower(gf),'auto')); if AUTO, gf = strrep(gf,'Auto',''); end; GF = strtok(gf); if strcmpi(arg2,'Eigen'), [K1,K2] = size(X.M.AR); Fs = X.SampleRate; [S, Serr, per, tau, exctn, lambda] = armode2(-X.M.AR(:,K1+1:end), X.M.C); fprintf(1,'Periode [s]\tf0 [Hz] \ttau [s] \texcitation [?]\tlambda\n') fprintf(1,'%8.3f\t%8.3f\t%8.3f\t%8.3f\t%8.3f\n',[per(1,:)',Fs./per(1,:)',tau(1,:)'/Fs,exctn',lambda]'); return; elseif ~isfield(X.M,GF) warning('PLOTA TFMVAR_ALL: field %s is unknown\n',GF); end; MONO = strcmp(GF,'logS1') || strcmp(GF,'S1'); if strcmp(GF,'AR1') || strcmp(GF,'C1'); MONO=1; f = 1:size(getfield(X.M,GF),2); else f = X.F; end; fidx = repmat(logical(1),size(f)); % selection of frequency band nix = repmat(logical(1),size(XT)); if 0, % ERD MVAR chapter warning('use project-specific setting: f<45Hz, t<7.0s') fidx = (f<=45)&(f>0); % selection of frequency band nix(XT>=7) = 0; % selection of segments (in time) nix(XT< 2.0) = 0; % selection of segments (in time) nix(1) = 0; % hack to remove reference segment nix = logical(nix); end; nix(1) = logical(0); % hack to remove reference segment nix = logical(nix); M = size(X.M.AR,1); tmp = size(X.M.AR); MOP = tmp(2)/tmp(1); if ~isfield(X,'Label'), for k1 = 1:M, Label{k1}=['# ',int2str(k1)]; end; elseif ischar(X.Label), Label = cellstr(X.Label); else Label = X.Label; end; nr = ceil(sqrt(M)); nc = ceil(M/nr); if 0, nargin>2, hf = arg3; elseif AUTO || MONO, NR = ceil(sqrt(M)); NC = ceil(M/NR); for k1 = 1:M, hf(k1) = subplot(NR,NC,k1); end; elseif M*M<200, for k1 = 1:M, for k2 = 1:M, % hf(k1,k2)=subplot(M,M,(k2-1)*M+k1); %transposed end; end; else subplot(111); end; if strcmp(X.datatype,'TF-MVAR') % warning('TF-MVAR 1.0 has'); Xnormfactor = X.N; else Xnormfactor = 1; Ynormfactor = 1; end; type = ''; if ~isempty(strfind(gf,'eventrelated')) [tmp] = str2double(gf); [gf,r] = strtok(gf); [t2,r] = strtok(r); [t3,r] = strtok(r); %suche das erste vorkommen des Zeitfenstermittelpunktes, der als %Parameter hinter 'eventrelated' übergeben wurde - dieses TW ist %das Referenzfenster für den eventrelated-Vergleich (meistens BL) ix = min( find(XT == max(tmp) )); % nix(ix) = 0; rix = repmat(ix,1,sum(nix)); m = real(getfield(X.M,gf)); se = real(getfield(X.SE,gf))*Xnormfactor; if MONO, x0 = m(:,fidx,nix) - m(:,fidx,rix); ci0 = sqrt(se(:,fidx,nix).^2 + se(:,fidx,rix).^2); else x0 = m(:,:,fidx,nix) - m(:,:,fidx,rix); ci0 = sqrt(se(:,:,fidx,nix).^2 + se(:,:,fidx,rix).^2); end; x0(~isfinite(x0))=NaN; clim = [-1,1]*max(abs(x0(:))); if isfield(X,'SampleRate') type = [' - eventrelated with : ' , sprintf('%i - %i s', X.T(:,ix)/X.SampleRate) ]; else type = [' - eventrelated with : ' , sprintf('%i s', X.T(ix)) ]; end; elseif isempty(Y); x0 = real(getfield(X.M,gf)); ci0 = getfield(X.SE,gf)*Xnormfactor; if MONO, x0 = x0(:,fidx,nix); ci0 = ci0(:,fidx,nix); else x0 = x0(:,:,fidx,nix); ci0 = ci0(:,:,fidx,nix); end; x0(~isfinite(x0))=NaN; clim = [min(x0(:)),max(x0(:))]; else x0 = (real(getfield(X.M,gf)) - real(getfield(Y.M,gf))); ci0 = sqrt((real(getfield(X.SE,gf))*Xnormfactor).^2 + (real(getfield(Y.SE,gf))*Ynormfactor).^2); x0 = x0(:,:,fidx,nix); ci0 = ci0(:,:,fidx,nix); x0(~isfinite(x0))=NaN; clim = [-1,1]*max(abs(x0(:))); end; XT = XT(:,nix); tmp = diff(XT); if isempty(tmp) sz = size(X.M.A); X.A = [eye(sz(1)), -reshape(X.M.A,[sz(1),sz(2)*sz(3)])]; X.B = eye(size(X.M.A,1)); X.C = X.M.C; % X.SampleRate = 2*max(X.F); X.datatype='MVAR'; m = getfield(X.M,arg2); se = getfield(X.SE,arg2); if strmatch(upper(arg2),{'PDC','DTF','COH','ICOH','PCOH'}) range = [0,.4]; elseif strcmpi(arg2,'Af') tmp=m; for k=1:size(m,1), tmp(k,k,:)=NaN; end; range=[min(tmp(:)-se(:)),max(tmp(:)+se(:))] else range=[min(m(:)),max(m(:))]; end; for k1=1:sz(1), for k2=1:sz(2), subplot(sz(1),sz(2),(k1-1)*sz(2)+k2); %area(X.F,squeeze(m(k1,k2,:))); errorbar(X.F,squeeze(m(k1,k2,:)),squeeze(se(k1,k2,:))); axis([min(X.F),max(X.F),range]) %set(gca,'YLIM',range); if isfield(X,'Label') if k2==1, ylabel(X.Label{k1}); end; if k1==1, title(X.Label{k2}); end; end; end; end; H = X; fprintf(2,'Warning PLOTA: single time segment not implemented, yet.\n'); return; elseif any(tmp-tmp(1)) warning('time scale is not equidistant - xlabels are incorrect') end; if (strcmp(gf,'DC') || strcmp(gf,'C')) caxis(clim); cm = colormap; for k1 = 1:M, for k2 = 1:M, subplot(hf(k1*M-M+k2)); x = x0(k1,k2,1,:); ci = ci0(k1,k2,1,:); if 0, elseif alpha < .5, xc = 2 + round(62*(squeeze(x)-clim(1))/diff(clim)); sz = size(x); %x = x(:); bf = prod(size(x)); %xc(abs(x) < (ci*norminv(1-alpha/(2*bf)))) = 1; x(abs(x) < (ci*tinv(1-alpha/2,X.N))) = NaN; %x(abs(x) < .5) = NaN; %x = reshape(x,sz); cm(1,:) = [1,1,1]; colormap(cm); else xc = 1+round(63*(squeeze(x)-clim(1))/diff(clim)); colormap('default'); end; %h = semilogy(XT,[x(:),ci(:)]*[1,1,1;0,-1,1]); h = plot(XT,[x(:),ci(:)]*[1,1,1;0,-1,1]); set(h(1),'color',[0,0,1]); set(h(2),'color',[0.5,0.5,1]); set(h(3),'color',[0.5,0.5,1]); v = axis; v(1)=min(XT);v(2)=max(XT);axis(v); axis([min(X.T),max(XT),clim]) %h = imagesc(XT,X.F,squeeze(x),clim); if k2==1, title(Label{k1}); end; if k1==1, ylabel(Label{k2});end; end; end; elseif AUTO || MONO, caxis(clim); cm = colormap; for k1 = 1:M, subplot(hf(k1)); if MONO, x = x0(k1,:,:); ci = ci0(k1,:,:); else x = x0(k1,k1,1:length(X.F),:); ci = ci0(k1,k1,1:length(X.F),:); end; if alpha < .5, xc = 2 + round(62*(squeeze(x)-clim(1))/diff(clim)); sz = size(x); %x = x(:); bf = prod(size(x)); %xc(abs(x) < (ci*norminv(1-alpha/(2*bf)))) = 1; xc(abs(x) < (ci*tinv(1-alpha/2,X.N))) = 1; %x(abs(x) < .5) = NaN; %x = reshape(x,sz); cm(1,:) = [1,1,1]; colormap(cm); else xc = 1+round(63*(squeeze(x)-clim(1))/diff(clim)); colormap('default'); end; x1 = reshape(cm(xc,1),size(xc)); x2 = reshape(cm(xc,2),size(xc)); x3 = reshape(cm(xc,3),size(xc)); %h = imagesc(XT,X.F,cat(3,x1,x2,x3)*diff(clim)+clim(1),clim); h = imagesc(XT,f(fidx),cat(3,x1,x2,x3),clim); %h = imagesc(XT,X.F,squeeze(x),clim); ylabel(Label{k1}); end; elseif M*M<200, caxis(clim); cm = colormap; for k1 = 1:M, for k2 = 1:M, % subplot(hf(k1*M-M+k2)); % display transposed because of predefined hf above subplot(M,M,(k1-1)*M+k2); % display transposed % subplot(M,M,(k2-1)*M+k1); x = x0(k1,k2,:,:); ci = ci0(k1,k2,:,:); if alpha < .5, xc = 2 + round(62*(squeeze(x)-clim(1))/diff(clim)); sz = size(x); %x = x(:); bf = prod(size(x)); xc(abs(x) < (ci*norminv(1-alpha/(2*bf)))) = 1; %xc(abs(x) <= (ci*tinv(1-alpha/2,X.N))) = 1; %x(abs(x) < .5) = NaN; %x = reshape(x,sz); cm(1,:) = [1,1,1]; colormap(cm); else xc = 1+round(63*(squeeze(x)-clim(1))/diff(clim)); colormap('default'); end; xc(xc~=xc)=1; x1 = reshape(cm(xc,1),size(xc)); x2 = reshape(cm(xc,2),size(xc)); x3 = reshape(cm(xc,3),size(xc)); %h = imagesc(XT,X.F,cat(3,x1,x2,x3)*diff(clim)+clim(1),clim); h = imagesc(XT,X.F(fidx),cat(3,x1,x2,x3),clim); if k1==1, title(Label{k2}); end; if k1 Zeile * Spalte * RGB-Floats H.xKord = repmat(XT,1,sz(1)); %X-Koordinaten H.yKord = repmat(X.F(fidx),1,sz(2)); %Y-Koordinaten H.farbwerte = squeeze(cat(3,x1,x2,x3)); %Farbwerte if isfield(X,'Label') H.Label = X.Label; else H.Label = cellstr(sprintf('#03i',[1:size(X.M.S,1)]')); end; H.type = type; H.method = gf; H.clim = clim; H.F = X.F; H.T = XT; H.zuPlottendeTW = nix; if(isfield(H,'cond')) H.cond = X.cond; else H.cond = ''; end; if(isfield(H,'subj')) H.subj = X.subj; else H.subj = ''; end; % Method to plot the matrixes that were calculated with calc_TF_Matrix % the input argument is the output of calc_TF_Matrix if ~exist('OCTAVE_VERSION','builtin'); imagesc(H.xKord, H.yKord, H.farbwerte, H.clim); else cm = load('cm.txt'); colormap(cm); imagesc(H.xKord*10, H.yKord, x); end; %set data proporties-------------------------- numPlots = size(H.Label,1); % Number of channels numXIntervalle = size(H.T,2); % Anzahl der Intervalle auf der X-Achse je Kanal (Auflösung Zeitfenster) numYIntervalle = size(H.F,2); % Anzahl der Intervalle auf der Y-Achse je Kanal (Frequenzen) %Vertical lines---------------------------- axisTmp = axis; %Achsenminima und -maxima xDim = axisTmp(2) - axisTmp(1); xInterval = xDim / (numPlots); %Größe eine Subplots auf der X-Achse xVerLines = [1:numPlots+1] * xInterval + axisTmp(1); %X-Koordinaten der vertikalen Linien v = get(gca); for k=1:numPlots+1 lh = line([xVerLines(k) xVerLines(k)] , [0 200]); set(lh,'Color',[.25 .25 .25]); end; %Horizontal lines------------------------- yDim = axisTmp(4) - axisTmp(3); yInterval = yDim / numPlots; %Größe eines Subplots auf der Y-Achse HorLines = [1:numPlots] * yInterval + axisTmp(3); %Y-Koordinaten der horizontalen Linien v = get(gca); for k=1:numPlots lh = line([0 200],[HorLines(k) HorLines(k)]); set(lh,'Color',[.25 .25 .25]); end; %Y-Labels------------------------------------ ylabel('') % Label ausschalten %X-Labels------------------------------------ xlabel('') title('') for k=0:numPlots-1 text(k * xInterval + (xInterval/2) + axisTmp(1) -0.01, axisTmp(3)-1 , H.Label(k+1)) % UNDYNAMISCH !!!!!!! end; %XTicks-------------------------------------- xNumTicks = 5;% Fall ohne eventrelated if ~isempty(strfind(H.type,'eventrelated')) xNumTicks = xNumTicks -1; end; xTicks = [1:((numPlots+1)*xNumTicks)-1] * xInterval/xNumTicks; %alle TW durchgehen xTicks = xTicks + axisTmp(1) ; set(gca,'XTick',xTicks); %XTick-Labels TWlength = 0.150; %lnegth of one TWs - HAS TO BE ENTERED MANUALLY ind = H.T; %create a label for each TW s = size(H.T,2); %Number of TWs ind = ind([1:floor(s/(xNumTicks-1)):s]); %select only as many TWs as xNumTicks ind = cat(2,ind(2:end) , ind(1)); %place the first element at the end - because labelling starts at the second element xtickLables = ind - TWlength/2; %substract TWlength of the center point xtickLables = round(xtickLables*10)/10; set(gca,'XTickLabel',xtickLables); %YTicks-------------------------------------- ynumTicks = 5; yTicks = [1:(numPlots+1)*ynumTicks] * yInterval/ynumTicks; yTicks = yTicks + axisTmp(3); %- yInterval /(2*numYIntervalle) set(gca,'YTick',yTicks); %YTick-Labels %Frequenzzahlen in Array schreiben ytickLables = ([1:ynumTicks] * ( H.F(end) - H.F(1) ) / ynumTicks ) + H.F(1) ; for l=1:length(ytickLables) ytickLablesStr{l} = num2str(ytickLables(l)); %Zahlen zu Strings formatieren end; ytickLablesStr = repmat(ytickLablesStr,1,numPlots); %den Array so oft wie es Channels gibt aneinanderkopieren ytickLablesStrLab = ytickLablesStr; %an den mittleren TickLabel wird der Name des Chanels vorne ankonkarteniert for k=0:numPlots-1 index = k*ynumTicks + floor(ynumTicks/2 +1); ytickLablesStrLab{index} = [H.Label{k+1} ' ' ytickLablesStr{k+1}]; end; set(gca,'YTickLabel',ytickLablesStrLab); suptitle([ H.method , H.type , ' - Subject ', H.subj , ' - Condition ', H.cond ]); end elseif strcmp(X.datatype,'coupling'), clim = [min(0,min(X.data(:))),max(1,max(X.data(:)))]; ndim = length(size(X.data)); for k1=1:size(X.data,1) for k2=1:size(X.data,2) subplot(size(X.data,1),size(X.data,2),(k1-1)*size(X.data,2)+k2); if ndim==3, area(X.f,squeeze(X.data(k1,k2,:))); set(gca,'YLim',clim); elseif ndim==4, imagesc(X.t,X.f,squeeze(X.data(k1,k2,:,:))); set(gca,'CLim',clim); end; end; end; elseif strcmp(X.datatype,'confusion'), if nargin>1, [kap,sd,H,z,OA,SA,MI]=kappa(X.data); fprintf(1,'%s\n',repmat('-',1,8*(size(X.data,1)+1))); fprintf(1,'Kappa = %5.3f %c %4.3f(%s z=%4.2f)\tOverall Accuracy = %4.1f%%\n',kap,177,sd,repmat('*',sum(-z1, H = X.S(:,c+X.NS*(0:X.NC)); F = 0:size(X.S,1)-1; else for k3 = 1:X.NC+1; ix = c + X.NS*(k3-1); [H(:,k3), F] = freqz(sqrt(X.PE(ix,end)/X.SampleRate),ar2poly(X.AR(ix,:)),f,X.SampleRate); end end; subplot(nc,nr,c); semilogy(F,abs(H),'-'); legend({'ref','1','2'}); ylabel(sprintf('%s/[%s]^{1/2}',X.PhysDim,X.samplerate_units)); v=axis;v(2:4)=[max(F),1e-2,10];axis(v); %hold on; grid on; if isfield(X,'Label'); if iscell(X.Label) title(X.Label{c}); else title(X.Label(c,:)); end; else title(['channel # ',int2str(c)]); end; end end; elseif strcmpi(X.datatype,'spectrum') || strcmp(X.datatype,'qualitycontrol'), if nargin>1, Mode=arg2; else Mode='log'; end; if iscell(X.PhysDim), X.PhysDim = strvcat(X.PhysDim); end; if strcmp(X.datatype,'qualitycontrol'), fprintf(1,'\n [%s]',X.PhysDim(1,:)); fprintf(1,'\t#%02i',1:size(X.AR,1)); fprintf(1,'\nMEAN '); fprintf(1,'\t%+7.3f',X.MEAN); fprintf(1,'\nRMS'); fprintf(1,'\t%+7.3f',X.RMS); fprintf(1,'\nSTD'); fprintf(1,'\t%+7.3f',X.STD); fprintf(1,'\nQuant'); fprintf(1,'\t%+7.3f',X.QUANT); fprintf(1,'\n [bit]\nEntropy'); fprintf(1,'\t%+4.1f',X.ENTROPY); fprintf(1,'\n\n'); end; if ~isfield(X,'samplerate_units') X.samplerate_units = 'Hz'; end; if ~isfield(X,'PhysDim') X.PhysDim = '[1]'; end; if ~isfield(X,'QUANT') X.QUANT = 0; end; if ~isfield(X,'Impedance') X.Impedance=5000; %5kOHM end; if isfield(X,'Label') Label = cellstr(X.Label); else NS = size(X.AR,1); Q.Label = [repmat('#',NS,1),int2str([1:NS]')]; end; [n,p] = size(X.AR); H=[]; F=[]; for k=1:size(X.AR,1); [h,f] = freqz(sqrt(X.PE(k,size(X.AR,2)+1)/(X.SampleRate*2*pi)),ar2poly(X.AR(k,:)),(0:64*p)/(128*p)*X.SampleRate',X.SampleRate); H(:,k)=h(:);F(:,k)=f(:); end; if strcmp(lower(Mode),'log') h=semilogy(F,abs(H),'-',[0,X.SampleRate/2]',[1;1]*mean(X.QUANT)/sqrt(12*X.SampleRate),'k:',[0,X.SampleRate/2]',1e6*[1;1]*sqrt(4*310*138e-25*X.Impedance),'k'); ylabel(sprintf('%s/[%s]^{1/2}',X.PhysDim(1,:),X.samplerate_units)); Label = [Label;{'Quantization'};{'Impedance'}]; elseif strcmp(lower(Mode),'log2') semilogy(F,real(H).^2+imag(H).^2,'-',[0,X.SampleRate/2]',[1;1]*X.QUANT.^2/(12*X.SampleRate),'k:'); ylabel(sprintf('[%s]^2/%s',X.PhysDim(1,:),X.samplerate_units)); Label = [Label;{'Quantization'}]; elseif strcmp(lower(Mode),'lin') plot(F,abs(H),'-',[0,X.SampleRate/2]',[1;1]*X.QUANT/sqrt(12*X.SampleRate),'k:'); ylabel(sprintf('%s/[%s]^{1/2}',X.PhysDim(1,:),X.samplerate_units)); Label = [Label;{'Quantization'}]; elseif strcmp(lower(Mode),'lin2') plot(F,real(H).^2+imag(H).^2,'-',[0,X.SampleRate/2]',[1;1]*X.QUANT.^2/(12*X.SampleRate),'k:'); ylabel(sprintf('[%s]^2/%s',X.PhysDim(1,:),X.samplerate_units)); Label = [Label;{'Quantization'}]; end; xlabel(sprintf('f [%s]',X.samplerate_units)); if isfield(X,'Title'), title(X.Title); elseif isfield(X,'FileName'); tmp=X.FileName; tmp(tmp=='_')=' '; title(tmp); end H = X; legend(Label); elseif strcmp(X.datatype,'SIESTA_HISTOGRAM') if nargin<2, chansel=0; else chansel=arg2; end; cname=computer; if cname(1:2)=='PC', PFAD='s:/'; else PFAD='/home/schloegl/'; end; H = load([PFAD,'siesta/t300/',lower(X.filename),'his.mat']); R = load([PFAD,'siesta/t300/',lower(X.filename),'res.mat']); fn=[PFAD,'siesta/t900/',lower(X.filename),'th.mat']; if exist(fn)==2, T = load(fn); else fprintf(2,'Warning: no thresholds available for %s\n',X.filename); T = []; end; H.X = [ones(2^16,1),repmat((-2^15:2^15-1)',1,R.EDF.NS)]*R.EDF.Calib; if chansel>0, H.H = H.HISTOG(:,chansel); else H.H = H.HISTOG; chansel = 1:R.EDF.NS; end; H.datatype = 'HISTOGRAM'; H.N = full(sum(H.H,1)); if ~isempty(T), if any(T.TRESHOLD>=2^15), T.TRESHOLD=T.TRESHOLD-2^15-1; fprintf(2,'Thresholds in %s were by 2^15+1 to high: corrected\n',X.filename); end; %T.TRESHOLD(:,1)=max(T.TRESHOLD(:,1),R.RES.MU'-7*sqrt(R.RES.SD2')); %T.TRESHOLD(:,2)=min(T.TRESHOLD(:,2),R.RES.MU'+7*sqrt(R.RES.SD2')); else %T.TRESHOLD = ones(R.EDF.NS,1)*[-2^15,2^15-1]; %repmat(nan,R.EDF.NS,2); T.TRESHOLD = repmat([2^15-1,-2^15],R.EDF.NS,1)'; H.Threshold = [ones(2,1),T.TRESHOLD']*R.EDF.Calib(:,chansel); end; plota(H,'log+'); suptitle(X.filename); elseif strcmp(X.datatype,'qc:histo') if nargin<2, yscale = 'log+'; else yscale = arg2; end; if nargin<3, chansel = 0; else chansel = arg3; end; if chansel<=0, chansel = 1:size(X.HIS.H,2); end; N = ceil(sqrt(length(chansel))); Ny= ceil(length(chansel)/N); for k = 1:length(chansel); K = chansel(k); h = X.HIS.H(:,K); if isfield(X,'FLAG') && isfield(X.FLAG,'UCAL') && X.FLAG.UCAL, t = X.HIS.X(:,min(K,size(X.HIS.X,2)))*X.Calib(K+1,K)+X.Calib(1,K); else t = X.HIS.X(:,min(K,size(X.HIS.X,2))); end; if isfield(X,'THRESHOLD'), if isfield(X,'FLAG') && isfield(X.FLAG,'UCAL') && X.FLAG.UCAL, MaxMin=X.THRESHOLD(K,[2,1])*X.Calib(K+1,K)+X.Calib(1,K); else MaxMin=X.THRESHOLD(K,[2,1]); end; elseif isfield(X,'Threshold'), %%% will become OBSOLETE MaxMin=X.Threshold(K,:); MaxMin=[max(MaxMin),min(MaxMin)]; else MaxMin=[max(t) min(t)]; end; h2 = h; h2(~xor(t>min(MaxMin),t0)),max(t(h>0))]; xrange = xrange + [-1,1]*(diff(xrange)/2+eps); if strcmp(yscale,'lin '), subplot(Ny,N,k); plot(t,[h],'-'); elseif strcmp(yscale,'lin+'), subplot(Ny,N,k); plot(t,[h],'-'); elseif strcmp(yscale,'lin+'), subplot(Ny,N,k); tmp=max(h)/2; tmp=sum(h)/sqrt(2*pi*sd2)*dT/2; %plot(t,[h],'-',t,exp(-(t-mu).^2./sd2/2)./sqrt(2*pi*sd2).*sum(h),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx' ); plot(t,[h]+.01,'-',t,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dT,'c',t,h2+.01,'r',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); v=axis; v=[xrange 1 max(X.HIS.H(:))]; axis(v); elseif strcmp(yscale,'stem'), subplot(Ny,N,k); tmp=max(h)/2; tmp=sum(h)/sqrt(2*pi*sd2)*dT/2; stem(t(h>0),h(h>0),'+'); hold on plot(t,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dT,'c',t,h2+.01,'r',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); hold off v=axis; v=[xrange 1 max(X.HIS.H(:))]; axis(v); elseif strcmp(yscale,'log ') || strcmp(yscale,'log'), subplot(Ny,N,k); tmp = sqrt(sum(h)/sqrt(2*pi*sd2)*dT); semilogy(t,[h+.01,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dT,h2+.01]); elseif strcmp(yscale,'log+'), subplot(Ny,N,k); tmp = sqrt(sum(h(h>0))/sqrt(2*pi*sd2)*dT); semilogy(t,[h+.01,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h(h>0))*dT,h2+.01],'-',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); v=axis; v=[xrange 1 max(X.HIS.H(:))]; axis(v); elseif strcmp(yscale,'qq'), subplot(Ny,N,k); tmp=.5;sum(h)/2; plot(cumsum(h)/sum(h),normcdf(t,mu,sqrt(sd2)),'xb',[0,1],[0,1],'-c'); elseif strcmp(yscale,'csum'), subplot(Ny,N,k); tmp=.5;sum(h)/2; h2 = cumsum(h); h2((t>min(MaxMin)) & (tmin(MaxMin)) & (t0)'*h(h>0))/X.N(K); %sumskipnan(repmat(t,size(h)./size(t)).*h,1)./sumskipnan(h,1); x = t-mu; %(repmat(t,size(h)./size(t))-repmat(mu,size(h)./size(mu))); sd2= sumskipnan((x(h>0).^2).*h(h>0),1)./X.N(K); [tmp,tmp2]=find(h>0); if isfield(X,'Threshold'), MaxMin=X.Threshold(:,K)'; MaxMin=[max(MaxMin),min(MaxMin)]; else MaxMin=t([max(tmp) min(tmp)]); end; if strcmp(yscale,'lin '), subplot(ceil(size(X.H,2)/N),N,K); plot(t,[h],'-'); elseif strcmp(yscale,'lin+'), subplot(ceil(size(X.H,2)/N),N,K); tmp = diff(t); dQ = 1;min(tmp(tmp>0)); tmp=max(h)/2; tmp=sum(h)/sqrt(2*pi*sd2)*dQ/2; %plot(t,[h],'-',t,exp(-(t-mu).^2./sd2/2)./sqrt(2*pi*sd2).*sum(h),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx' ); plot(t,[h]+.01,'-',t,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dQ,'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); v=axis; v=[MaxMin(2) MaxMin(1) 1 max(h)]; axis(v); elseif strcmp(yscale,'log ') || strcmp(yscale,'log'), subplot(ceil(size(X.H,2)/N),N,K); tmp = diff(t); dQ = min(tmp(tmp>0)); tmp = sqrt(sum(h)/sqrt(2*pi*sd2)*dQ); %semilogy(t,[h],'-') semilogy(t,[h+.01,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dQ]); elseif strcmp(yscale,'log+'), subplot(ceil(size(X.H,2)/N),N,K); tmp = diff(t); if any(tmp>0) dQ = min(tmp(tmp>0)); else dQ = 1; end; tmp = sqrt(sum(h(h>0))/sqrt(2*pi*sd2)*dQ); %semilogy(t,[h]+.01,'-',t,exp(-(t*ones(size(mu))-ones(size(t))*mu).^2./(ones(size(t))*sd2)/2)./(ones(size(t))*(sqrt(2*pi*sd2)./sum(h))),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); %semilogy(t,[h]+.01,'-',t,exp(-(t(:,ones(size(mu)))-mu(ones(size(t)),:)).^2./sd2(ones(size(t)),:)/2)./sqrt(2*pi*sd2(ones(size(t)),:)).*(ones(size(t))*sum(h)),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5],tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); %semilogy(t,[h]+.01,'-',t,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h)*dQ,'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); semilogy(t,[h+.01,exp(-((t-mu).^2)/(sd2*2))/sqrt(2*pi*sd2)*sum(h(h>0))*dQ],'-',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); v=axis; v=[MaxMin(2)+0.1*diff(MaxMin)-50*eps MaxMin(1)-0.1*diff(MaxMin)+50*eps 1 max(h)]; axis(v); v=axis; v=[v(1:2) 1 max(h)]; axis(v); elseif strcmp(yscale,'qq'), subplot(ceil(size(X.H,2)/N),N,K); tmp=.5;sum(h)/2; %plot(t,cumsum(h)/sum(h),'-',t,cumsum(exp(-(t-mu).^2/sd2/2)/sqrt(2*pi*sd2)/X.N(K)),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); plot(cumsum(h)/sum(h),normcdf(t,mu,sqrt(sd2)),'xb',[0,1],[0,1],'-c'); elseif strcmp(yscale,'csum'), subplot(ceil(size(X.H,2)/N),N,K); tmp=.5;sum(h)/2; %plot(t,cumsum(h)/sum(h),'-',t,cumsum(exp(-(t-mu).^2/sd2/2)/sqrt(2*pi*sd2)/X.N(K)),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); plot(t,cumsum(h)/sum(h),'-',t,normcdf(t,mu,sqrt(sd2)),'c',mu+sqrt(sd2)*[-5 -3 -1 0 1 3 5]',tmp*ones(7,1),'+-',MaxMin,tmp,'rx'); v=axis; v(1:2)=[MaxMin(2)+0.1*diff(MaxMin) MaxMin(1)-0.1*diff(MaxMin)]; axis(v); elseif strcmp(yscale,'CDF'), %subplot(ceil(size(X.H,2)/N),N,K); tmp=sum(h)/2; %semilogx(X.X,cumsum(X.H,1)./X.N(ones(size(X.X,1),1),:),'-'); plot([X.X(1,:)-eps;X.X],[zeros(1,size(X.H,2));cumsum(X.H,1)]./X.N(ones(size(X.X,1)+1,1),:),'-'); t = [t(1)-eps;t]; %plot(t,[cumsum([0;h])/X.N(K),normcdf(t,mu,sqrt(sd2))]) %plot(t,cumsum([0;h])/X.N(K)) %v=axis; v(1:2)=[MaxMin(2)+0.1*diff(MaxMin) MaxMin(1)-0.1*diff(MaxMin)]; axis(v); v=axis; v(3:4)=[0,1]; axis(v); elseif strcmp(yscale,'stacked'), bar(t,h,'stacked'); elseif strcmp(yscale,'PDF'), subplot(ceil(size(X.H,2)/N),N,K); plot(t, h ./ ( [t(2)-t(1); t(3:end)-t(1:end-2); t(end)-t(end-1)]*sum(h) ) , 'x'); elseif strcmp(yscale,'logPDF'), subplot(ceil(size(X.H,2)/N),N,K); semilogy(t, h ./ ( [t(2)-t(1); t(3:end)-t(1:end-2); t(end)-t(end-1)]*sum(h) ) , 'x'); elseif 0; warning('plota(histo(...),''PDF'') is very experimental - you are warned'); for k = 1:size(X.H,2), x = [-inf;X.X(:,max(1,size(X.X,2)))]; y = [0; cumsum(X.H(:,k))]; dx = (x(end)-x(2))/20000; xi = x(2):dx:x(end); yi = interp1(x,y/y(end),xi); n = 1000; yi = filter([1,zeros(1,n-2),-1]', 1, yi); plot(xi(1:end-n/2), (dx*yi(n/2+1:end)) ); ylabel(sprintf('PDF')); end; end; end; elseif strcmp(X.datatype,'DBI-EPs'), if nargin<2, arg2='b'; end; if nargin<3, arg3=100; end; for k=1:length(X.eegchan), subplot(13,10,k); mu=X.RES(k).SUM./X.RES(k).N; sd=sqrt((X.RES(k).SSQ-X.RES(k).SUM.*mu)./max(X.RES(k).N,0)); se=sd./sqrt(X.RES(k).N); h=plot(X.t,[mu(:),sd(:),se(:)]*[1,1,1,1,1;-1,1,0,0,0;0,0,-1,1,0],arg2); set(h(5),'linewidQh',2); set(h(1),'color',[0,.75,.75]); set(h(2),'color',[0,.75,.75]); set(h(3),'color',[.5,.5,1]); set(h(4),'color',[.5,.5,1]); axis([-3,3,-arg3,arg3]); title(sprintf('#%i',X.eegchan(k))); end; elseif strcmpi(X.datatype,'BLAND-ALTMAN'), s='x'; if nargin<2, elseif nargin==2, if length(arg2)<3, s = arg2; else Labels=arg2; end elseif nargin>2, s = arg2; Labels = arg3; end; if ~exist('Labels','var'), Labels = cellstr(int2str([1:size(X.data,2)]')); end; if length(X)==1, [nr,nc] = size(X.data) nc=nc-1; for k = 1:nc, for l = k+1:nc+1,%[1:k-1,k+1:nc], h = subplot(nc,nc,(k-1)*nc+l-1); a = X.data(:,l)+X.data(:,k); d = X.data(:,l)-X.data(:,k); m = mean(d); sd=std(d); plot(a,d,s,[min(a),max(a)],[1;1]*[m,sd*norminv(.025)*[1,-1]],'--k'); text(max(a),m+.1*sd,'Mean'); text(max(a),m-.2*sd,sprintf('%5.2f',m)); text(max(a),m+2*sd,'+1.96 SD'); text(max(a),m+1.8*sd,sprintf('%5.2f',m+sd*norminv(.975))); text(max(a),m-1.9*sd,'-1.96 SD'); text(max(a),m-2.1*sd,sprintf('%5.2f',m+sd*norminv(.025))); ht=title(sprintf('%s - %s',Labels{k}, Labels{l})); %ht=title(sprintf('r = %.4f %s',X.R(k,l),char('*'*(X.p(k,l)<[.05,.01,.001])))); pos=get(ht,'position'); %pos(2)=max(X.data(k)); %set(ht,'position',pos); % title gives the r-value, its confidence interval (see CORRCOFF for which level), % and indicates the significance for alpha=0.05 (*), 0.01(**) and 0.001(***) if l == (k+1), xlabel(Labels{l}); ylabel(Labels{k}); end% else end; end; end elseif strcmp(X.datatype,'SCATTER'), s='x'; if nargin<2, elseif nargin==2, if length(arg2)<3, s = arg2; else Labels=arg2; end elseif nargin>2, s = arg2; Labels = arg3; end; if ~exist('Labels','var'), Labels = cellstr(int2str([1:size(X.data,2)]')); end; if isfield(X,'Classlabel') CL = unique(X.Classlabel); else CL = 1; end; if length(X)==1, if ~isfield(X,'R'); [X.R,X.p,X.CIL,X.CIU] = corrcoef(X.data,'Rank'); end; [nr,nc] = size(X.data) nc=nc-1; for k = 1:nc, for l = k+1:nc+1,%[1:k-1,k+1:nc], h=subplot(nc,nc,(k-1)*nc+l-1); if length(CL)==1, plot(X.data(:,l),X.data(:,k),s); elseif length(CL)==2, plot(X.data(X.Classlabel==CL(1),l),X.data(X.Classlabel==CL(1),k),'bx',X.data(X.Classlabel==CL(2),l),X.data(X.Classlabel==CL(2),k),'ro'); end; ht=title(sprintf('r=%.3f %s [%.3f,%.3f]',X.R(k,l),char('*'*(X.p(k,l)<[.05,.01,.001])),X.CIL(k,l),X.CIU(k,l))); %ht=title(sprintf('r = %.4f %s',X.R(k,l),char('*'*(X.p(k,l)<[.05,.01,.001])))); pos=get(ht,'position'); %pos(2)=max(X.data(k)); %set(ht,'position',pos); % title gives the r-value, its confidence interval (see CORRCOFF for which level), % and indicates the significance for alpha=0.05 (*), 0.01(**) and 0.001(***) if l == (k+1), xlabel(Labels{l}); ylabel(Labels{k}); else set(h,'xtick',[]); set(h,'ytick',[]); end; end; end; else if ~isfield(X,'R'); [X.R,X.p,X.CIL,X.CIU] = corrcoef(X(1).data,X(2).data,'Rank'); end; [nr,nc2] = size(X(2).data); for k = 1:nc, for l = 1:nc2,%[1:k-1,k+1:nc], h=subplot(nc,nc2,(k-1)*nc2+l-1); plot(X(2).data(:,l),X(1).data(:,k),s); ht=title(sprintf('r=%.3f %s [%.3f,%.3f]',X.R(k,l),char('*'*(X.p(k,l)<[.05,.01,.001])),X.CIL(k,l),X.CIU(k,l))); %ht=title(sprintf('r = %.4f %s',X.R(k,l),char('*'*(X.p(k,l)<[.05,.01,.001])))); pos=get(ht,'position'); %pos(2)=max(X.data(k)); %set(ht,'position',pos); % title gives the r-value, its confidence interval (see CORRCOFF for which level), % and indicates the significance for alpha=0.05 (*), 0.01(**) and 0.001(***) if l == 1, %xlabel(arg3{l}); ylabel(arg3{k}); else %set(h,'xtick',[]); set(h,'ytick',[]); end; end; if k == nc, xlabel(arg3{l}); %ylabel(arg3{k}); else set(h,'xtick',[]); %set(h,'ytick',[]); end; end; end; elseif strcmp(X.datatype,'STAT2'), if nargin<2, arg2='b'; end; if isfield(X,'t') t=X.t; else t=1:length(X.SUM); end; if nargin>2 t=arg3; end; mu=X.SUM./X.N; sd=sqrt((X.SSQ-X.SUM.*mu)./max(X.N-1,0)); se=sd./sqrt(X.N); h=plot(t,[mu(:),sd(:),se(:)]*[1,1,1,1,1;0,-1,1,0,0;0,0,0,-1,1],arg2); set(h(1),'linewidQh',2); tmp=get(h(1),'color'); set(h(2),'color',1-(1-tmp)/2); set(h(3),'color',1-(1-tmp)/2); %set(h(4),'color',[0,0,1]); %set(h(5),'color',[0,0,1]); elseif strcmp(X.datatype,'TSD1'), if nargin<2, arg2='b'; end; h=plot(X.t,[X.mu,X.sd]*[1,1,1;0,-1,1],arg2); set(h(1),'linewidQh',2); hold on h=plot(X.TI(:),1,'.k'); elseif strcmp(X.datatype,'MEAN+STD') if isfield(X,'MEAN'); sz = [size(X.MEAN),1]; elseif isfield(X,'SUM'); sz = [size(X.SUM),1]; end; nchns = sz(2); % Number of channels if nargin < 2 clf; nf = []; else nf = arg2; % Handles to subplots end; if isempty(nf) for k0 = 1:sz(3), if sz(3)>1, figure(k0); end; for k = 1:nchns nf(k0,k) = subplot(ceil(nchns/ceil(sqrt(nchns))),ceil(sqrt(nchns)),k); % Handles to subplots end; end; end; if isfield(X,'Label') if ischar(X.Label) X.Label = cellstr(X.Label); end; end; if (~isfield(X,'MEAN') || ~isfield(X,'SEM')) %& isfield(X,'SUM') & isfield(X,'N') & isfield(X,'SSQ') X.MEAN = X.SUM./X.N; % mean X.MSQ = X.SSQ./X.N;; % mean square X.RMS = sqrt(X.MSQ); % root mean square %X.SSQ0 = X.SSQ-X.SUM.*X.MEAN; % sum square of mean removed X.SSQ0 = X.SSQ - real(X.SUM).*real(X.MEAN) - imag(X.SUM).*imag(X.MEAN); % sum square of mean removed n1 = max(X.N-1,0); % in case of n=0 and n=1, the (biased) variance, STD and SEM are INF X.VAR = X.SSQ0./n1; % variance (unbiased) X.STD = sqrt(X.VAR); % standard deviation X.SEM = sqrt(X.SSQ0./(X.N.*n1)); % standard error of the mean end; if nargin>2 minmean = arg3; maxmean = arg4; maxstd = arg5; else minmean = floor(min(X.MEAN(:))); maxmean = ceil(max(X.MEAN(:))); maxstd = ceil(max(X.SEM(:))); end; for k0 = 1:sz(3), if sz(3)>1, figure(k0); end; for k = 1:sz(2) % For each channel %subplot(nf(k0,k)); set (gcf(), 'currentaxes', nf(k0,k)); ax = plot(X.T,[X.MEAN(:,k,k0),X.SEM(:,k,k0)]*[1,1,1;0,-1,1],'k'); set(ax(2),'color',[1,1,1]/2); set(ax(3),'color',[1,1,1]/2); if 0, % [ax,h1,h2] = plotyy(X.T,X.MEAN(:,k,k0),X.T,X.STD(:,k,k0)); drawnow; set(ax(1),'FontSize',8); set(ax(2),'FontSize',8); % Sets the axes limits to avoid overlapping of the two functions set(ax(1),'YLim',[minmean-maxstd maxmean]); set(ax(2),'YLim',[0 -minmean+maxstd+maxmean]); set(ax,'XLim',[min(X.T) max(X.T)]); set(ax,'YTickLabel',[]); set(ax,'YTick',[]); % Label y1-axis (mean) temp = [floor(minmean/10) * 10 : 10 : ceil(maxmean/10) * 10]; % Label only ..., -20, -10, 0, 10, 20, 30, ... temp = [0:5]/5*(maxmean-minmean)+minmean; % [floor(minmean/10) * 10 : 10 : ceil(maxmean/10) * 10]; % Label only ..., -20, -10, 0, 10, 20, 30, ... set(ax(1),'YTick',temp); set(ax(1),'YTickLabel',temp); % Label y2-axis (standard deviation) temp = [0 : 5] * ceil(maxstd/5); % Label only 0, 10, 20, 30, ... set(ax(2),'YTick',temp); set(ax(2),'YTickLabel',temp); % Label x-axis xlabel('Time (s)'); grid on; end; if isfield(X,'Label') % Print label of each channel (if such a label exists) if k <= length(X.Label) title(X.Label{k},'FontSize',8,'Interpreter','none'); end; end; if isfield(X,'trigger') % Mark trigger line([X.T(X.trigger),X.T(X.trigger)],[minmean-maxstd,maxmean],'Color',[1 0 0]); end; end; end; drawnow; h = ax; %set(0,'DefaultTextInterpreter','none'); % Avoid having TeX interpretation in title string %suptitle(X.Title); elseif strcmp(X.datatype,'CORRELATION_WITH_REFERENCE') if isfield(X,'ELEC') || isfield(X,'ELPOS') fprintf(2,'PLOTA: X.ELPOS, X.ELEC not supported yet.\n'); end; FLAG.TOPOMAP = 1; if nargin>1, if ~exist(arg2,'file'); fprintf(2,'Warning PLOTA: electrode position file not found.\n'); FLAG.TOPOMAP = 0; end; else % fprintf(2,'Warning PLOTA: electrode position file not specified.\n'); FLAG.TOPOMAP = 0; end; if FLAG.TOPOMAP, topoplot(X.corr,arg2,'maplimits',[-1,1]); colorbar; else plot(X.corr); axis([1,length(X.corr),-1,1]); end; elseif strcmp(X.datatype,'Classifier') if ~isfield(X,'tsc'), X.tsc=X.TI*16+[-15,1]; end; if (nargin==1); arg2 = 'all'; for k=1:4, hf(k) = subplot(1,4,k); end elseif (nargin==2); if isnumeric(arg2) hf = arg2; if length(hf)==3, arg2='all'; elseif length(hf)==1, arg2='acc'; subplot(hf); end; else % arg2=arg2; end elseif (nargin==3); if isnumeric(arg2) hf = arg2; arg2 = arg3; else hf = arg3; end; else end; if ~isfield(X,'T'); %X.T = (1:size(X.acc,1))'; X.T = (1:size(X.MDA.ACC00,1))'; if isfield(X,'Fs'), X.T = X.T/X.Fs; end; else; end; LEG = []; if isfield(X,'Classes'), if ischar(X.Classes) LEG = X.Classes; elseif isnumeric(X.Classes) LEG = num2str(X.Classes(:)); end; end; if strncmpi(arg2,'acc',3) if isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0]*100,[1,1,1]*.8); end; hold on; %plot(X.T,X.acc*100,'-',X.T([1,end]),[100,100]./size(X.acc,2),'k:'); plot(X.T,X.MDA.ACC00*100,'-',X.T([1,end]),[100,100]./size(X.MDA.ACC00,2),'k:'); hold off; v=axis;v(3:4)=[0,100];axis(v); ylabel('Accuracy [%]'); grid on; if ~isempty(LEG) legend(LEG); end elseif strcmpi(arg2,'fixed') || strcmpi(arg2,'fixed-MDA'), if 0,isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0]*100,[1,1,1]*.8); end; hold on; plot(X.T,X.MDA.acc*100,'-',X.T([1,end]),[100,100]./size(X.MDA.acc,2),'k:'); hold off; v=axis;v(3:4)=[0,100];axis(v); ylabel('mean recognistion rate [%]'); grid on; if ~isempty(LEG) legend(LEG); end elseif strcmpi(arg2,'fixed-LLH') if 0,isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0]*100,[1,1,1]*.8); end; hold on; plot(X.T,X.LLH.acc*100,'-',X.T([1,end]),[100,100]./size(X.LLH.acc,2),'k:'); hold off; v=axis;v(3:4)=[0,100];axis(v); ylabel('Accuracy [%]'); grid on; if ~isempty(LEG) legend(LEG); end elseif strcmpi(arg2,'KAPPA') || strcmpi(arg2,'KAPPA-MDA') if isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0]*100,[1,1,1]*.8); end; hold on; plot(X.T,[X.MDA.KAP00,X.MDA.ACC00]*100); hold off; grid on; %v=axis; v(3:4)=[-10,100]; axis(v); v=axis; v(3:4)=[0,100]; axis(v); ylabel('Kappa [%], Accuracy [%]') xlabel('time t [s]'); legend('Kappa', 'Accuracy'); elseif strcmpi(arg2,'KAPPA-LLH') if isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0]*100,[1,1,1]*.8); end; hold on; plot(X.T,[X.LLH.KAP00,X.LLH.ACC00]*100); hold off; grid on; %v=axis; v(3:4)=[-10,100]; axis(v); v=axis; v(3:4)=[0,100]; axis(v); ylabel('Kappa [%], Accuracy [%]') xlabel('time t [s]'); legend('Kappa', 'Accuracy'); elseif strncmpi(arg2,'MI',2) if isfield(X,'tsc'), patch(X.T(X.tsc([1,1,2,2,1])),[0,1,1,0,0],[1,1,1]*.8); end; hold on; if isfield(X,'I0') %& any(X.I0(:)~=0); h=plot(X.T,[X.I0,X.I]) else h=plot(X.T,[X.MD2.I0,sum(X.MD2.I0,2)]); %h=plot(X.T,[X.GRB.I0,X.GRB.I2]); end; hold off grid on; v=axis; v(3:4)=[0,1]; axis(v); set(h(end),'linewidQh',2) ylabel('MI [bit]'); xlabel('time t [s]'); if ~isempty(LEG) legend(LEG); end elseif strncmpi(arg2,'all',3) plota(X,'acc',hf(1)); plota(X,'KAPPA',hf(2)); plota(X,'fixed',hf(3)); plota(X,'MI',hf(4)); end; elseif strncmp(X.datatype,'TSD_BCI',7) && (nargin>1) && strcmpi(arg2,'TSD'); N = length(X.CL); if N>2, for k=1:N, nf(k)=subplot(ceil(sqrt(N)),N/ceil(sqrt(N)),k); end; end; if N==2, N=1; end; for k=1:N, if N>1, %subplot(nf(k)); set (gcf(), 'currentaxes', nf(k)); end; h=plot(X.T,[X.MEAN1(:,k),X.MEAN2(:,k),X.SD1(:,k),X.SD2(:,k)]*[1,0,1,0,1,0; 0,1,0,1,0,1; 0,0,1,0,-1,0; 0,0,0,1,0,-1]); set(h(1),'linewidQh',2); set(h(2),'linewidQh',2); mset(h(3:6),'linewidQh',1); mset(h([1,3,5]),'color','b'); mset(h([2,4,6]),'color','g'); ylabel('Average TSD'); v=axis;v(1:2)=[min(X.T),max(X.T)];axis(v); end; elseif isfield(X,'TSD') && isfield(X.TSD,'datatype') && strcmp(X.TSD.datatype,'TSD_BCI9') if nargin<2, clf; for k=1:6, nf(k)=subplot(3,2,k); end; else nf=arg2; end; fid = 1; tix = X.TSD.tix(1); N = length(X.TSD.CL); c = (N-1)/N; fprintf(fid,'Classifier: %s\n',X.datatype); if isfield(X,'hyperparameters') f = fieldnames(X.hyperparameters); for k=1:length(f), fprintf(fid,' %s = %f\n',f{k},getfield(X.hyperparameters,f{k})); end; end; fprintf(fid,'Error: %4.1f %% \n',100-X.TSD.ACC00(tix)*100); fprintf(fid,'Accuracy: %4.1f %% \nspecific Accuracy: ',X.TSD.ACC00(tix)*100); [kap,sd,H,z,OA,SA,MI] = kappa(X.TSD.optCMX); fprintf(fid,'%4.1f ',SA*100); fprintf(fid,'\nKappa: %4.2f %c %4.2f\n',X.TSD.KAP00(tix),177,X.TSD.Ksd00(tix)); fprintf(fid,'I(Wolpaw): %4.2f bit\n',wolpaw_entropy(X.TSD.ACC00(tix),N)); fprintf(fid,'I(Nykopp): %4.2f bit\n',X.TSD.I_Nykopp(tix)); if ~isfield(X,'T') || ~isfield(X.T,'t') X.T.t = X.TSD.T; end; if ~isfield(X.T,'t0') X.T.t0 = 0; end; if isfield(X.TSD,'I'), fprintf(fid,'I(Continous): SUM = %4.2f [ ',sumskipnan(X.TSD.I(tix,:))*c); fprintf(fid,'%4.2f ',X.TSD.I(tix,:)); t = X.T.t-X.T.t0; t(t<.5)=NaN; fprintf(fid,' ] \nSTMI: %4.2f [ ',max([sum(X.TSD.I,2)]./t)*c); fprintf(fid,' %4.2f',max(X.TSD.I./[t(:,ones(1,size(X.TSD.I,2)))])); fprintf(fid,' ] \nSNR: ') fprintf(fid,'%4.2f ',X.TSD.SNR(tix,:)); fprintf(fid,'\ncorrelation (parametric): ') fprintf(fid,'%4.2f ',X.TSD.r(tix,:)); fprintf(fid,'\nrank correlation: '); fprintf(fid,'\nAUC: '); fprintf(fid,'%4.2f ',X.TSD.AUC(tix,:)); fprintf(fid,'\n'); end; if isfield(X,'rankcorrelation'); fprintf(fid,'%4.2f ',X.TSD.rankcorrelation(tix,:)); end; xlim = [min(0,X.T.t(1)),max(X.T.t(end))]; %subplot(nf(1)); set (gcf(), 'currentaxes', nf(1)); if ~isfield(X.TSD,'Labels') for k = 1:length(X.TSD.CL), Labels{k}=int2str(X.TSD.CL(k)); end; else Labels = X.TSD.Labels; end; %plota(X); plot(X.T.t, 100*[X.TSD.ACC00, X.TSD.KAP00]) axis([xlim,-20,100]) xlabel('time [s]') title('Accuracy and Kappa') legend({'Accuracy [%]','Kappa [%]'}) %subplot(nf(3)); set (gcf(), 'currentaxes', nf(3)); plot(X.T.t,[sum(X.TSD.I,2)*c,X.TSD.I_Nykopp(:),wolpaw_entropy(X.TSD.ACC00,N)]) legend({'I_{continous}','I_{Nykopp}','I_{Wolpaw}'}) title('Mutual information') ylabel('I [bit]'); xlabel('time [s]') v=axis; axis([xlim,0,1.5]); if 0, %subplot(nf(5)); set (gcf(), 'currentaxes', nf(5)); plot(X.T.t,X.MEAN2) hold on plot(X.T.t,X.MEAN1) hold off Title('average output of one-vs-rest classifiers') ylabel('TSD') xlabel('time [s]') tmp = strvcat(Labels); legend(cellstr([tmp,repmat('(+)',size(tmp,1),1);tmp,repmat('(-)',size(tmp,1),1)])) v=axis; axis([xlim,v(3:4)]); else set (gcf(), 'currentaxes', nf(5)); %subplot(nf(5)); t = X.T.t-X.T.t0; %t(t < 3.5)=NaN; t(t < 0.5)=NaN; plot(X.T.t,[sum(X.TSD.I,2)*c,X.TSD.I_Nykopp(:),wolpaw_entropy(X.TSD.ACC00,N)]./repmat(t,1,3)) legend({'STMI_{C}','STMI_{N}','STMI_{W}'}) title('Steepness of Mutual information') ylabel('STMI [bit/s]'); xlabel('time [s]') v=axis; axis([xlim,0,1]); end; set (gcf(), 'currentaxes', nf(2)); plot(X.T.t,X.TSD.AUC) xlabel('time [s]') ylabel('AUC [1]') title('area-under-the-(ROC)-curve'); legend(Labels) v=axis; axis([xlim,.4,1]); %subplot(nf(4)); set (gcf(), 'currentaxes', nf(4)); plot(X.T.t,[X.TSD.I,sum(X.TSD.I,2)*c,]) xlabel('time [s]') ylabel('I [bit]'); title('Mutual Information of continous output'); legend([Labels,{'SUM'}]) v=axis; axis([xlim,0,1.5]); %subplot(nf(6)); set (gcf(), 'currentaxes', nf(6)); if isfield(X.TSD,'N') % show significance interval alpha = .05; ci = tanh(sqrt(2)*erfinv(1-2*alpha)./sqrt(X.TSD.N-3)); % confidence interval for alpha of z plot(X.T.t,X.TSD.r,'-',X.T.t,ci*[-1,1],'k:'); LEG = [Labels,{sprintf('alpha=%f',alpha)}]; else plot(X.T.t,X.TSD.r,'-'); LEG = Labels; end; xlabel('time [s]') ylabel('r [1]') title('correlation coefficient (parametric)'); legend(LEG); v=axis; axis([xlim,-.2,1]); h = nf; for k=1:length(nf) %subplot(nf(k)); set (gcf(), 'currentaxes', nf(k)); hold on; v = axis; if isfield(X,'T') && isfield(X.T,'t0') && isfield(X.T,'t') ylim = v([3,4])*[1,.9;0,.1]; h=patch(X.T.t(X.TC([1,1,end,end,1])),ylim([1,2,2,1,1]),[1,1,1]*0); % set(h,'FaceAlpha',.2,'EdgeAlpha',1) else plot(X.T.t([X.TC;X.TC])-X.T.t0,[.9;1]*v(4)*ones(1,length(X.TC)),'k-'); end; hold off; end; elseif strcmp(X.datatype,'TSD_BCI9') if nargin<2, clf; for k=1:6, nf(k)=subplot(3,2,k); end; else nf=arg2; end; fid = 1; tix = X.tix(1); N = length(X.CL); c = (N-1)/N; fprintf(fid,'Classifier: %s\n',X.datatype); if isfield(X,'hyperparameters') f = getfields(X.hyperparameters); for k=1:length(f), fprintf(fid,' %s = %f\n',f{k},getfield(X.hyperparameters,f)); end; end; fprintf(fid,'Error: %4.1f %% \n',100-X.ACC00(tix)*100); fprintf(fid,'Accuracy: %4.1f %% \nspecific Accuracy: ',X.ACC00(tix)*100); [kap,sd,H,z,OA,SA,MI] = kappa(X.optCMX); fprintf(fid,'%4.1f ',SA*100); fprintf(fid,'\nKappa: %4.2f %c %4.2f\n',X.KAP00(tix),177,X.Ksd00(tix)); fprintf(fid,'I(Wolpaw): %4.2f bit\n',wolpaw_entropy(X.ACC00(tix),N)); fprintf(fid,'I(Nykopp): %4.2f bit\n',X.I_Nykopp(tix)); if isfield(X,'I'), fprintf(fid,'I(Continous): SUM = %4.2f [ ',sumskipnan(X.I(tix,:))*c); fprintf(fid,'%4.2f ',X.I(tix,:)); t = X.T; t(t<.5)=NaN; fprintf(fid,' ] \nSTMI: %4.2f [ ',max([sum(X.I,2)]./t)*c); fprintf(fid,' %4.2f',max(X.I./[t(:,ones(1,size(X.I,2)))-3])); fprintf(fid,' ] \nSNR: ') fprintf(fid,'%4.2f ',X.SNR(tix,:)); fprintf(fid,'\ncorrelation (parametric): ') fprintf(fid,'%4.2f ',X.r(tix,:)); fprintf(fid,'\nrank correlation: '); fprintf(fid,'\nAUC: '); fprintf(fid,'%4.2f ',X.AUC(tix,:)); fprintf(fid,'\n'); end; if isfield(X,'rankcorrelation'); fprintf(fid,'%4.2f ',X.rankcorrelation(tix,:)); end; xlim = [min(0,X.T(1)),max(X.T(end))]; %subplot(nf(1)); set (gcf(), 'currentaxes', nf(1)); if ~isfield(X,'Labels') for k = 1:length(X.CL), Labels{k}=int2str(X.CL(k)); end; else Labels = X.Labels; end; %plota(X); plot(X.T, 100*[X.ACC00, X.KAP00]) axis([xlim,-20,100]) xlabel('time [s]') title('Accuracy and Kappa') legend({'Accuracy [%]','Kappa [%]'}) %subplot(nf(3)); set (gcf(), 'currentaxes', nf(3)); plot(X.T,[sum(X.I,2)*c,X.I_Nykopp(:),wolpaw_entropy(X.ACC00,N)]) legend({'I_{continous}','I_{Nykopp}','I_{Wolpaw}'}) title('Mutual information') ylabel('I [bit]'); xlabel('time [s]') v=axis; axis([xlim,0,1.5]); if 0, %subplot(nf(5)); set (gcf(), 'currentaxes', nf(5)); plot(X.T,X.MEAN2) hold on plot(X.T,X.MEAN1) hold off Title('average output of one-vs-rest classifiers') ylabel('TSD') xlabel('time [s]') tmp = strvcat(Labels); legend(cellstr([tmp,repmat('(+)',size(tmp,1),1);tmp,repmat('(-)',size(tmp,1),1)])) v=axis; axis([xlim,v(3:4)]); else %subplot(nf(5)); set (gcf(), 'currentaxes', nf(5)); t = X.T; %t(t < 3.5)=NaN; t(t < 0.5)=NaN; plot(X.T,[sum(X.I,2)*c,X.I_Nykopp(:),wolpaw_entropy(X.ACC00,N)]./repmat(t,1,3)) legend({'STMI_{C}','STMI_{N}','STMI_{W}'}) title('Steepness of Mutual information') ylabel('STMI [bit/s]'); xlabel('time [s]') v=axis; axis([xlim,0,1]); end; %subplot(nf(2)); set (gcf(), 'currentaxes', nf(2)); plot(X.T,X.AUC) xlabel('time [s]') ylabel('AUC [1]') title('area-under-the-(ROC)-curve'); legend(Labels) v=axis; axis([xlim,.4,1]); %subplot(nf(4)); set (gcf(), 'currentaxes', nf(4)); plot(X.T,[X.I,sum(X.I,2)*c,]) xlabel('time [s]') ylabel('I [bit]'); title('Mutual Information of continous output'); legend([Labels,{'SUM'}]) v=axis; axis([xlim,0,1.5]); %subplot(nf(6)); set (gcf(), 'currentaxes', nf(6)); if isfield(X,'N') % show significance interval alpha = .05; ci = tanh(sqrt(2)*erfinv(1-2*alpha)./sqrt(X.N-3)); % confidence interval for alpha of z plot(X.T,X.r,'-',X.T,ci*[-1,1],'k:'); LEG = [Labels,{sprintf('alpha=%f',alpha)}]; else plot(X.T,X.r,'-'); LEG = Labels; end; xlabel('time [s]') ylabel('r [1]') title('correlation coefficient (parametric)'); legend(LEG); v=axis; axis([xlim,-.2,1]); h = nf; elseif strcmp(X.datatype,'TSD_BCI8') % obsolote if ~isfield(X,'T'); X.T = [1:size(X.ACC00,1)]'; end; h = plot(X.T, 100*[X.ACC00, X.KAP00*[1,1,1,0] + X.Ksd00*[0,-1,1,1]],'-k'); v = axis; v(3:4)=[-20,129];axis(v) set(h(1),'color',[0,0,1]); set(h(2),'color',[0,.5,0]); set(h(3),'color',[0,1,0]); set(h(4),'color',[0,1,0]); legend('Accuracy [%]','kappa ± s.d. [%]') xlabel('t [s]'); elseif strcmp(X.datatype,'TSD_BCI7') % obsolete if (nargin>1) && strcmpi(arg2,'balken2'); %elseif strcmpi(X.datatype,'Balken_Diagramm'), dy = 0.3; F = 25; mn = rs([X.MEAN2(:),X.MEAN1(:)],F,1)'; pc = rs([X.BCG2(:),X.BCG1(:)],F,1)'; barh(rs(X.T,F,1),rs([1-2*X.BCG1,X.BCG2*2-1],F,1)) elseif (nargin>1) && strcmpi(arg2,'balken'); %elseif strcmpi(X.datatype,'Balken_Diagramm'), dy = 0.3; F = 125; if isfield(X,'Fs'), if X.Fs==125, F = 50; elseif X.Fs == 128, F = 32; end end; mn = [rs(X.MEAN2(:),F,1)';rs(X.MEAN1(:),F,1)']; pc = [rs(X.BCG2(:),F,1)';rs(X.BCG1(:),F,1)']; %barh(rs(X.T,F,1),rs([X.BCG1,X.BCG2],F,1),1) samples = (1:length(mn))'; time = X.T(F:F:end)'; %time = time - time(1); % the following sequence is from R. Scherer for k = 1:size(mn, 2), if abs(mn(1,k)) > abs(mn(2,k)) patch([0 0 mn(1,k) mn(1,k) 0], [k-dy k+dy k+dy k-dy k-dy], 'k'); patch([0 0 mn(2,k) mn(2,k) 0], [k-dy k+dy k+dy k-dy k-dy], 'w'); else patch([0 0 mn(2,k) mn(2,k) 0], [k-dy k+dy k+dy k-dy k-dy], 'w'); patch([0 0 mn(1,k) mn(1,k) 0], [k-dy k+dy k+dy k-dy k-dy], 'k'); end pos1 = min(min(mn(:,k)), 0); pos2 = max(max(mn(:,k)), 0); text(pos1, k, [' ' num2str(100*pc(1,k), '%.0f') '% '], 'HorizontalAlignment', 'Right'); text(pos2, k, [' ' num2str(100*pc(2,k), '%.0f') '% '], 'HorizontalAlignment', 'Left'); end mx = max(max(mn)); mn = min(min(mn)); %xlim(1.2 * [mn mx]); xlim([-1,1]); set(gca, 'ytick', 1:length(time), 'yticklabel', num2str(time(:), '%02.2f')); ylabel('time in seconds'); xlabel('distance') ylim([0.5 length(samples)+0.5]); % title(caption); pos = get(gca, 'position'); axes('position', pos, 'color', 'none', 'YTick', [], 'XTick', []); set(gca, 'YAxisLocation', 'right'); xlim(1.2 * [mn mx]); ylim([0.5 length(samples)+0.5]); set(gca, 'ytick', 1:length(time), 'yticklabel', num2str(100*mean(pc)', '%.0f')); ylabel('overall classification result') %elseif strcmp(X.datatype,'TSD_BCI7') | strcmp(X.datatype,'SNR'), , else if nargin<2, clf; for k=1:3, nf(k)=subplot(1,3,k); end; else nf=arg2; end; if isfield(X,'KAP00'); if nargin<2, hf(1) = subplot(121); hf(2) = subplot(122); else hf = arg2; end; if ~isfield(X,'T') X.T=(1:size(X.KAP00,1)); end; subplot(hf(1)); plot(X.T,[X.KAP00,X.ACC00]*100); grid on; v=axis; v(3:4)=[-10,100]; axis(v); ylabel('Kappa [%], Accuracy [%]') xlabel('time t [s]'); legend('Kappa', 'Accuracy'); subplot(hf(2)); h=plot(X.T,[X.I0,X.I]); grid on; v=axis; v(3:4)=[0,1]; axis(v); set(h(end),'linewidQh',2) ylabel('MI [bit]'); xlabel('time t [s]'); LEG=[]; for k = 1:length(X.MD), LEG{k} = int2str(k); end; LEG{k+1}='all'; %legend(LEG); return; end; if ~isfield(X,'Fs'), X.Fs=128; end; N=length(X.I); if isfield(X,'T') t=X.T;%(min(X.T(:)):max(X.T(:)))/X.Fs; else t=(1:N)/X.Fs; end; %subplot(nf(1)); set (gcf(), 'currentaxes', nf(1)); plot(t,X.ERR*100); grid on; ylabel('Error rate [%]') v=axis;v=[0,max(t),0,100];axis(v); %subplot(nf(2)); set (gcf(), 'currentaxes', nf(2)); %if strcmp(X.datatype,'SNR'), if isfield(X,'MEAN1'), h=plot(t,[X.MEAN1(:),X.MEAN2(:),X.SD1(:),X.SD2(:)]*[1,0,0,0; 0,1,0,0; 1,0,1,0; 1,0,-1,0; 0,1,0,1; 0,1,0,-1]','b',t([1,length(t)]),[0,0],'k'); else h=plot(t,[X.M1(:),X.M2(:),X.SD1(:),X.SD2(:)]*[1,0,0,0; 0,1,0,0; 1,0,1,0; 1,0,-1,0; 0,1,0,1; 0,1,0,-1]','b',t([1,length(t)]),[0,0],'k'); end; set(h(1),'linewidQh',2); set(h(2),'linewidQh',2); set(h(7),'linewidQh',2); set(h(2),'color','g'); set(h(5),'color','g'); set(h(6),'color','g'); ylabel('Average TSD'); v=axis;v(1:2)=[0,max(t)];axis(v); %subplot(nf(3)); set (gcf(), 'currentaxes', nf(3)); if isfield(X,'T') tmp = repmat(NaN,size(X.T)); tmp((X.T>=3.5) & X.ERR<=.50) = 0; plot(t,[X.I,X.I./(X.T-3)+tmp]); else plot(t,X.I); end; ylabel('Mutual Information [bits]') v=axis;v=[0,max(t),0,.5];axis(v); if length(nf)>3, axes(nf(4)) plota(X,'balken'); elseif 0, plot(t,X.corcov) v=axis;v=[0,10,-1,1];axis(v); grid('on') ylabel('correlation coefficient') end; end; elseif strcmp(X.datatype,'ERDS'), if nargin==1, plotaERDS(X) elseif nargin==2, plotaERDS(X,arg2) end; elseif strcmp(X.datatype,'QRS_events'), ix0 = find(X.EVENT.TYP==hex2dec('0501')); if ~isfield(X.EVENT,'CHN') CHAN = 0; elseif ~isempty(ix0) CHAN = unique(X.EVENT.CHN(ix0)); end if (length(CHAN)==1) ix = X.EVENT.POS(ix0) / X.EVENT.SampleRate; if nargin<2, semilogy((ix(1:end-1)+ix(2:end))/2,diff(ix)); elseif strcmp(arg2,'lin') plot((ix(1:end-1)+ix(2:end))/2,diff(ix)); else semilogy((ix(1:end-1)+ix(2:end))/2,diff(ix),arg2); end; ylabel('Inter-Beat-Interval (IBI) [s]') xlabel('time [s]') else for k = 1:length(CHAN), ix = find(X.EVENT.CHN(ix0)==CHAN(k)); ix = X.EVENT.POS(ix0(ix)) / X.EVENT.SampleRate; semilogy((ix(1:end-1)+ix(2:end))/2,diff(ix)); hold on; end; hold off; end; elseif strcmp(X.datatype,'AMARMA') if X.MOP(3)~=0, return; end; if (X.MOP(1)==1) && (size(X.AAR,2)==X.MOP(2)+1), m0 = X.AAR(:,1)./(1-sum(X.AAR(:,2:end),2)); ix_aar = 2:X.MOP(2)+1; elseif (X.MOP(1)==0) && (size(X.AAR,2)==X.MOP(2)), m0 = zeros(size(X.AAR,1),1); ix_aar = 1:X.MOP(2); else return; end; MODE = []; if ~isempty(findstr(upper(arg3),'TIME')), MODE = [MODE,1]; end; if ~isempty(findstr(upper(arg3),'VLHF')), MODE = [MODE,2]; end; if ~isempty(findstr(upper(arg3),'IMAGE')), MODE = [MODE,3]; end; if ~isempty(findstr(upper(arg3),'3D')), MODE = [MODE,4]; end; if ~isempty(findstr(upper(arg3),'n.u.')), MODE = [MODE,5]; end; if ~isempty(findstr(upper(arg3),'LF-BW')), MODE = [MODE,6]; end; if ~isempty(findstr(upper(arg3),'F0')), MODE = [MODE,7]; end; if ~isempty(findstr(upper(arg3),'F0+-B')), MODE = [MODE,8]; end; if ~isempty(findstr(upper(arg3),'ALL')), MODE = [1,2,3,6]; end; if nargin<4, if any(MODE==4) hf = gca; else for k = 1:length(MODE); hf(k) = subplot(length(MODE),1,k); end; end; else hf = arg4; end; if ~isfield(X,'T') X.T = (0:size(X.AAR,1)-1)'; X.xlabel = 'beats [1]'; end; HHHH = []; K = 0; if any(MODE==1) K = K + 1; subplot(hf(K)); %plot(X.T,[signal,m0,sqrt([tmp(:,8),X.PE])]); if isfield(X,'S') ha=plot(X.T,[X.S,m0,sqrt(X.PE)]); MM1 = max([X.S,m0,sqrt(X.PE)]); MM2 = min([X.S,m0,sqrt(X.PE)]); else ha=plot(X.T,[m0,sqrt(X.PE)]); MM1 = max([m0,sqrt(X.PE)]); MM2 = min([m0,sqrt(X.PE)]); end; MM = [max(MM1),min(MM2)]; if isfield(X,'EVENT') hold on %text(X.EVENT.POS,repmat(sqrt(max(X.PE))*2,length(X.EVENT.POS),1),'r+'); plot(X.T(X.EVENT.POS)*[1,1],MM*[1.2,0;-.20,1],':k'); for k = 1:length(X.EVENT.POS), ha(k)=text(X.T(X.EVENT.POS(k)),MM*[1;0],X.EVENT.Desc{k}); set(ha(k),'VerticalAlignment','top'); set(ha(k),'Rotation',90); end; hold off end; HHHH = ha; v = axis; v(2) = max(X.T); v(3)=0; axis(v); ylabel([X.Label,' [',deblank(X.PhysDim),']']); hc= colorbar; pos=get(gca,'position'); delete(hc); set(gca,'position',pos); if isfield(X,'S') legend('Raw','Mean','RMS') else legend('mean','RMS') end; end; if prod(size(arg2))==1, f0 = repmat(arg2,size(X.AAR,1),1); elseif prod(size(arg2))>1, f0 = arg2; end; if any(MODE==2) [w,A,B,R,P,F,ip] = ar_spa(X.AAR(:,ix_aar),f0,X.PE); ix = (imag(F)==0); elseif any(MODE==5) || any(MODE==6) || any(MODE==7) || any(MODE==8) [w,A,B,R,P,F,ip] = ar_spa(X.AAR(:,ix_aar),1,X.PE); ix = (imag(F)==0); end; if any(MODE==2) ixVLF = ((w>=0) & (w<.04)); F1 = real(F); F1(~ixVLF)= NaN; ixLF = (w>=.04) & (w<=.15); F2 = real(F); F2(~ixLF) = NaN; ixHF = (w>.15) & (w<=.4) ; F3 = real(F); F3(~ixHF) = NaN; tmp = [sumskipnan(real(F),2), sumskipnan(F1,2), sumskipnan(F2,2), sumskipnan(F3,2)]; tmp(:,5) = tmp(:,3)./tmp(:,4); tmp(:,6) = tmp(:,3)./(tmp(:,1)-tmp(:,2)); tmp(:,7) = tmp(:,4)./(tmp(:,1)-tmp(:,2)); tmp(:,8) = sum(tmp(:,2:4),2); K = K + 1; subplot(hf(K)); semilogy(X.T,tmp(:,[3,4,8,1])); % 1 v = axis; v(2) = max(X.T); axis(v); ylabel(sprintf('%s [%s^2]',X.Label,X.PhysDim)); hc= colorbar; pos=get(gca,'position'); delete(hc); set(gca,'position',pos); %ylabel(sprintf('%s [%s^2/%s]',X.Label,X.PhysDim,'s')); legend({'LF','HF','VLF+LF+HF','total'}) end; if any(MODE==5) ixVLF = ((w>=0) & (w<.04)); F1 = real(F); F1(~ixVLF)= NaN; ixLF = (w>=.04) & (w<=.15); F2 = real(F); F2(~ixLF) = NaN; %ixHF = (w>.15) & (w<=.4) ; ixHF = (w>.17*f0(:,ones(1,size(w,2)))) & (w<=.40*f0(:,ones(1,size(w,2)))); F3 = real(F); F3(~ixHF) = NaN; tmp = [sumskipnan(real(F),2), sumskipnan(F1,2), sumskipnan(F2,2), sumskipnan(F3,2)]; tmp(:,5) = tmp(:,3)./tmp(:,4); tmp(:,6) = tmp(:,3)./(tmp(:,1)-tmp(:,2)); tmp(:,7) = tmp(:,4)./(tmp(:,1)-tmp(:,2)); tmp(:,8) = sum(tmp(:,2:4),2); K = K + 1; subplot(hf(K)); %semilogy(X.T,tmp(:,[3,4,8])); % 1 plot(X.T,tmp(:,[6,7])*100); % 1 v = axis; v(2:4) = [max(X.T),0,100]; axis(v); ylabel(sprintf('%s [n.u. %%]',X.Label)); hc= colorbar; pos=get(gca,'position'); delete(hc); set(gca,'position',pos); %ylabel(sprintf('%s [%s^2/%s]',X.Label,X.PhysDim,'s')); legend({'LF (0.05-0.15Hz)','HF (0.15*f0-0.40*f0)'}) end; if any(MODE==3), DN = max(1,ceil(size(X.AAR,1)/1000)); %assume 1000 pixels N = size(X.AAR,1); clear h h2 F3 h2 = repmat(NaN,101,length(1:DN:N)); t = repmat(NaN,size(h2,1),1); for l = 1:DN:N, %N/2; [k,size(sdf),N],%length(AR); k = ceil(l/DN); % [h(:,k),F(:,k)] = freqz(sqrt(X.PE(l)/(2*pi*X.AAR(l,1))),[1, -X.AAR(l,2:end)]',128,f0(l,1)); %[h2(:,k),F3] = freqz(sqrt(X.PE(l)/(2*pi*X.AAR(l,1))),[1, -X.AAR(l,ix_aar)]',[0:100]'/64,f0(l,1)); [h2(:,k),F3] = freqz(sqrt(X.PE(l)/(2*pi*f0(l,1))),[1, -X.AAR(l,ix_aar)]',[0:100]'/64,f0(l,1)); h2(find(F3>f0(l,1)/2),k)=NaN; t(k) = X.T(l); end; K = K + 1; subplot(hf(K)); if 0;%FB{1}=='B'; HHHH = imagesc(X.T(1:DN:N),F3,2*log10(abs(h2(:,end:-1:1)))); elseif 0; HHHH = imagesc(X.T(1:DN:N),F3,2*log10(abs(h2))); else HHHH = imagesc(t(~isnan(t)),F3,2*log10(abs(h2(:,~isnan(t))))); end; % xlabel(X.xlabel); ylabel('f [1/s]'); pos0 = get(gca,'position'); hc= colorbar; %pos1 = get(gca,'position') v = get(hc,'yticklabel'); v = 10.^str2num(v)*2; pos2 = get(hc,'position'); %pos2(1) = 1 - (1 - pos0(1) - pos0(3))/4; %pos2(1) = pos0(1) + pos0(3) + pos2(3)/2; %pos2(3) = pos2(3)/2 %set(hc,'yticklabel',v,'position',pos2); if 0,isfield(X,'EVENT') hold on %text(X.EVENT.POS,repmat(sqrt(max(X.PE))*2,length(X.EVENT.POS),1),'r+'); plot(X.T(X.EVENT.POS)*[1,1],[1.6,0],':k'); for k = 1:length(X.EVENT.POS), %[tmp,ix] = min(abs(t-X.EVENT.POS(k))); %plot(ix*[1,1],[1.6,0],':k'); %plot(X.T(X.EVENT.POS(k))*[1,1],[1.6,0],':k'); ha(k)=text(X.T(X.EVENT.POS(k)),0,X.EVENT.Desc{k}); %ha(k)=text(ix,0,X.EVENT.Desc{k}); set(ha(k),'VerticalAlignment','top'); set(ha(k),'Rotation',90); end; hold off end; %set(gca,'position',pos0); title(sprintf('%s [%s^2/%s]',deblank(X.Label),deblank(X.PhysDim),'s')); end; if any(MODE==4), DN = 8; %10; N = size(X.AAR,1); clear h h2 F3 for l = 1:DN:N, %N/2; [k,size(sdf),N],%length(AR); k = ceil(l/DN); [h(:,k),F4(:,k)] = freqz(sqrt(X.PE(l)/(2*pi*X.AAR(l,1))),[1, -X.AAR(l,2:end)]',128,f0(l,1)); % [h2(:,k),F3] = freqz(sqrt(X.PE(l)/(2*pi*X.AAR(l,1))),[1, -X.AAR(l,2:end)]',[0:70]'/64,f0(l,1)); % h2(find(F3>f0(l,1)/2),k)=NaN; end; K = K + 1; ah=subplot(hf(K)); plot3(repmat(1:DN:ceil(N),128,1),F4,6+2*log10(abs(h))); xlabel(X.xlabel); ylabel('f [1/s]'); zlabel(sprintf('%s [%s^2/%s]',X.Label,X.PhysDim,'s')); v = get(ah,'zticklabel'); v = 10.^str2num(v)*2; set(ah,'zticklabel',v); view([60,-45]); pos=get(ah,'position'); %pos(4)=.5; set(ah,'position',pos); set(1,'PaperUnits','inches','PaperOrientation','portrait','PaperPosition',[0.25 .5 8 10]); HHHH = ah; end; if any(MODE==6) ixVLF = ((w>=0) & (w<.04)); F1 = real(F); F1(~ixVLF)= NaN; ixLF = (w>=.04) & (w<=.15); F2 = real(F); F2(~ixLF) = NaN; ixHF = (w>.15) & (w<=.4) ; F3 = real(F); F3(~ixHF) = NaN; B2 = B; B2(~ixLF) = NaN; w2 = w; w2(~ixLF) = NaN; HHHH = mean(mean(B2,2).*f0); fprintf(1,'Mean LF BandwidQh %f\n',HHHH); K = K + 1; subplot(hf(K)); plot(X.T, [mean(w2,2), mean(B2,2).*f0]); % hold on % errorbar(X.T,mean(w2,2),mean(B2,2)); % hold off; v = axis; v(2:4) = [max(X.T),0,.2]; axis(v); hc= colorbar; pos=get(gca,'position'); delete(hc); set(gca,'position',pos); %legend('f0(LF)','bandwidQh(LF)'); xlabel(X.xlabel); ylabel('f [Hz]'); legend('f0(LF)','bandwidQh(LF)'); drawnow end; if any(MODE==7) clim = [0,max(A(:))]; cm = colormap; B2 = B; B2(w<0) = NaN; w2 = w; w2(w<0) = NaN; for k2 = 1:size(w2,2), for k1 = 1:size(w2,1), if w2(k1,k2)>0, H = plot(X.T(k1),w2(k1,k2),'d'); set(H,'color',cm(ceil(A(k1,k2)/clim(2)*size(cm,1)),:)); end; end; end; end; if any(MODE==8) B2 = B; B2(w<0) = NaN; w2 = w; w2(w<0) = NaN; HHHH = plot(X.T,w2,'d', X.T,w2+B,'v', X.T,w2-B,'^'); end; h = HHHH; elseif strcmp(X.datatype,'ELPOS2'), X = leadidcodexyz(X); XYZ = X.ELEC.XYZ; Label = cellstr(X.Label); ix = find(X.LeadIdCode>=0)'; x = XYZ(:,1); y = XYZ(:,2); R = sqrt(sum(XYZ.^2,2)); Theta = acos(XYZ(:,3)./R)./sqrt(sum(XYZ(:,1:2).^2,2)); x = x.*Theta; y = y.*Theta; plot(x,y,'x',x(ix),y(ix),'ro'); for k=1:length(Label); %ix(:)', text(x(k),y(k),[int2str(k),': ',Label{k}]); end; set(gca,'xtick',0,'ytick',0) h = X; if nargin>2, c = arg3; c = ceil(c*10); for k1=1:size(c,1), for k2=1:size(c,2), %%%% FIXME: Add 2D or 3D connections %% if c(k1,k2)>0, e= line(x([k1,k2]),y([k1,k2])); set(e,'linewidth',c(k1,k2)); end; end; end; end; elseif strncmp(X.datatype,'ELPOS',5), X = leadidcodexyz(X); XYZ = X.ELEC.XYZ; Label = cellstr(X.Label); ix = find(X.LeadIdCode>0)'; plot3(XYZ(:,1),XYZ(:,2),XYZ(:,3),'x',XYZ(ix,1),XYZ(ix,2),XYZ(ix,3),'ro'); for k=1:length(Label); %ix(:)', text(XYZ(k,1),XYZ(k,2),XYZ(k,3),[int2str(k),': ',Label{k}]); end; set(gca,'xtick',0,'ytick',0) h = X; if nargin>2, c = arg3; c = ceil(c*10); for k1=1:size(c,1), for k2=1:size(c,2), %%%% FIXME: Add 2D or 3D connections %% if c(k1,k2)>0, e= line(XYZ([k1,k2],1),XYZ([k1,k2],2),XYZ([k1,k2],3)); set(e,'linewidth',c(k1,k2)); end; end; end; end; elseif strcmp(X.datatype,'REV'), if nargin<2 arg2=[]; end; if strcmpi(arg2,'3d') R=X.REV; [mxR,ix]=min(R); [myR,iy]=min(R'); [IX,IY]=find(R==min(R(:))); [IX,IY], h=mesh(R');hold on plot3(ix,1:length(ix),mxR,'go-') plot3(1:length(iy),iy,myR,'cx-') plot3(IX,IY,min(R(:)),'r*'); hold off %v=axis;v(5:6)=[0.1,.2];axis(v); a=gca; set(a,'xtick',X.P); t=1:5:length(X.UC); set(a,'ytick',t); set(a,'yticklabel',X.UC(t)); ylabel('update coefficent UC') xlabel('model order p') zlabel('REV = MSE/MSY') else %if strcmpi(arg2,'2d') subplot(121) semilogx(X.UC,X.REV') v=axis;v=[1e-6,1e-1,0.1,.15];axis(v); xlabel('update coefficent UC') ylabel('REV = MSE/MSY') subplot(122) h=plot(X.P,X.REV) v=axis;v(3:4)=[0.1,.15];axis(v); xlabel('model order p') ylabel('REV = MSE/MSY') end; elseif strcmp(X.datatype,'MDist-matrix'), if nargin<2 arg2=[]; end; h=mesh(X.D) h=get(gca,'xtick'); %set(gca,'xticklabel',X.t(h(h>0))) h=get(gca,'ytick'); %set(gca,'yticklabel',X.t(h(h>0))) elseif strcmp(X.datatype,'MD'), if nargin<2 arg2=[]; end; if strcmpi(arg2,'3d') R=X.REV; [mxR,ix]=max(R); [myR,iy]=max(R'); [IX,IY]=find(R==max(R(:))); h=mesh(R');hold on plot3(ix,1:length(ix),mxR,'go-') plot3(1:length(iy),iy,myR,'cx-') plot3(IX,IY,min(R(:)),'r*'); hold off % v=axis;v(5:6)=[0.1,.2];axis(v); a=gca; set(a,'xtick',X.P); t=1:5:length(X.UC); set(a,'ytick',t); set(a,'yticklabel',X.UC(t)); ylabel('update coefficent UC') xlabel('model order p') zlabel('log_{10}(MD)') else %if strcmpi(arg2,'2d') subplot(121) semilogx(X.UC,X.REV') % v=axis;v=[1e-6,1e-1,0.1,.15];axis(v); xlabel('update coefficent UC') ylabel('log_{10}(MD)') subplot(122) h=plot(X.P,X.REV) % v=axis;v(3:4)=[0.1,.15];axis(v); xlabel('model order p') ylabel('log_{10}(MD)') end; end; if nargout, H = h; end; biosig-2.3.3/biosig4matlab/t500_Visualization/sview.m0000664000175000017500000002364114105434233022631 0ustar schloeglschloeglfunction [argout,s]=sview(s,varargin), % SVIEW - a simple signal viewer % SVIEW(filename) % SVIEW(HDR) % SVIEW(S,HDR) % % SVIEW(filename, ...) % optional arguments are the same as in SLOAD % % See also: SLOAD % Copyright (c) 2004-2012,2021 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % 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 3 % of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. argout = {}; if nargin<2, varargin={}; end; if length(varargin), H=varargin{1}; arg2=varargin{1}; else arg2=''; H = []; end; if ~isempty(H) CHAN = 1:size(s,2); elseif ischar(s) || iscell(s), [s,H] = sload(s,varargin{:}); CHAN = 1:size(s,2); elseif isstruct(s) [s,H] = sload(s); CHAN = 1:size(s,2); elseif isnumeric(s) && (length(H.InChanSelect)==size(s,2)) CHAN = 1:size(s,2); H.Label = H.Label(H.InChanSelect,:); else if nargout, argout=H; end; return; end; %if strmatch(H.TYPE,{'BMP','PBMA','PGMA','PPMA','PBMB','PGMB','PPMB','XPM'}), if isfield(H,'IMAGE'); if exist('OCTAVE_VERSION','builtin') if (length(size(s))==3) && (size(s,3)==3) imshow(s(:,:,1),s(:,:,2),s(:,:,3)); else imshow(s); end; else image(s); end; if nargout, argout=H; end; return; elseif ischar(arg2) && (strcmp(H.TYPE,'ELPOS') || (isfield(H,'ELEC') && strncmpi(arg2,'ELPOS',5))); XYZ = H.ELEC.XYZ; K = 1:size(XYZ,1); if ~isempty(strfind(arg2,'2d')) T=0:.001:2*pi; r = sqrt(sum(XYZ(:,1:2).^2,2)); Rmax = max(r); R = Rmax * 11/10; r = 10/11*atan(r./XYZ(:,3)); XY = XYZ(:,1:2).*r(:,[1,1]); plot(XY(:,1),XY(:,2),'x',XY(K,1),XY(K,2),'ro',R*sin(T),R*cos(T),'b-',-R+R/10*sin(-T/2),R/11*cos(-T/2),'b-',R/11*sin(T/2)+R,R/11*cos(T/2),'b-',[-R 0 R]/11,[R R*1.1 R],'b-'); for k=1:size(XYZ,1), text(XY(k,1),XY(k,2),H.Label(k,:)); end; else plot3(XYZ(:,1),XYZ(:,2),XYZ(:,3),'x',XYZ(K,1),XYZ(K,2),XYZ(K,3),'ro'); for k=1:size(XYZ,1), text(XYZ(k,1),XYZ(k,2),XYZ(k,3),H.Label(k,:)); end; end; if nargout, argout=H; end; return; elseif isfield(H,'LeadIdCode') && all((H.LeadIdCode>0) & (H.LeadIdCode<256)) && all(H.PhysDimCode==H.PhysDimCode(1)) % 12-lead, 10s ECG xlen = 5; Fs = round(H.SampleRate); d = repmat(NaN,Fs*xlen,12); pos = [1,2,61:64,3:8]; x = leadidcodexyz(pos); [tmp, scale] = physicalunits(H.PhysDimCode); CH = zeros(1,12); for k=1:length(pos), ch = find(pos(k)==H.LeadIdCode); if ~isempty(ch) CH(ch) = k; d(1:xlen*Fs-1,k)=s(1:xlen*Fs-1,ch); else switch k case 3 d(:,3)=d(:,1:2)*[-1;1]; case 4 d(:,4)=d(:,1:2)*[1;1]/2; case 5 d(:,5)=d(:,1:2)*[1;-1/2]; case 6 d(:,6)=d(:,1:2)*[-1/2;1]; end; end; end; d = reshape(permute(reshape(d,[Fs*xlen,3,4]),[1,3,2]),[Fs*xlen*4,3]); d = [(abs([-(Fs/2):(Fs/2)])' < (Fs/4))*ones(1,3)*1e-3/scale(1); repmat(NaN,1,3); d]; plot([1:Fs*(xlen*4+1)+2]'/Fs-1, d + ones(size(d,1),1)*[0,-1,-2]*3*1e-3/scale(1),'k'); grid on set(gca,'xMinorTick','on','yMinorTick','on','xMinorGrid','on','yMinorGrid','on','box','off'); set(gca,'gridlinestyle','-','minorgridlinestyle',':'); for k=1:length(pos), h=text(xlen*floor((k-1)/3)+1,(1-3*mod(k-1,3))*1e-3/scale(1),x.Label(k)); end; text(.1-1,-2e-4/scale(1),'0.5s / 1 mV'); set(gca,'xlim',[-1,4*xlen]); gender='UMFX'; sex=gender(H.Patient.Sex+1); if isfield(H.Patient,'Age') age=H.Patient.Age; elseif isfield(H.Patient,'Birthday') age = H.T0 - H.Patient.Birthday; if (numel(H.T0)==6) H.T0 = datenum(H.T0); end; if (numel(H.Patient.Birthday)>1) H.Patient.Birthday = datenum(H.Patient.Birthday); end; age = (H.T0 - H.Patient.Birthday)/365.25; else age = -1; end; id = H.Patient.Id; id(id=='_')=' '; title(sprintf('Patient Id: %s Age=%i y Sex=%c',id,age,sex)); tmp = physicalunits(H.PhysDimCode(1)); ylabel(tmp{1}); xlabel('time [s]'); if nargout, argout=H; end; return; elseif strcmp(H.TYPE,'unknown'); if nargout, argout=H; end; return; end; %s(abs(s)>1e3)=NaN; [p,f,e]=fileparts(H.FileName); %fn=dir(fullfile(p,[f,'EOG',e])); if 1, % no EOG corrections elseif 1 nx = sparse(28,3); nx(23:24,1) = [1;-1]; nx(24:25,2) = [1;-1]; nx(26,3) = 1; [R,s] = regress_eog(H.FileName,1:22,nx); size(s), [u,s0,v] = svd(s(~any(isnan(s),2),:),0); size(u) s = s*v; elseif 1 [R,s] = regress_eog(s,1:60,61); end; if ~isfield(H,'Label'), LEG = ''; elseif all(size(CHAN)>1) LEG = 'rereferenced'; elseif all(CHAN>0) LEG = H.Label(CHAN); elseif size(H.Label,1)0), [p,f,e]=fileparts(which('sopen.m')); [p,f,e]=fileparts(p); g = sopen(fullfile(p,'doc','eventcodes.txt'));g=sclose(g); ix = sparse(g.EVENT.CodeIndex,1,1:length(g.EVENT.CodeIndex)); EVENT = H.EVENT; try, EVENT.Desc = {g.EVENT.CodeDesc{ix(H.EVENT.TYP)}}; catch fprintf(2,'SVIEW: unknown eventcodes in file %s',H.FileName) end else EVENT.POS = []; end; if H.NS==1, plot(t(:),s,'-'); else plot(t(:),((s+(ones(size(s,1),1)*(1:size(s,2)))*dd/(-2)+4*dd)),'-'); end; %box('off'); ix = find(EVENT.POS>0 & EVENT.POS<=length(t)); if isfield(EVENT,'Desc') && ~isempty(ix) %& ~exist('OCTAVE_VERSION','builtin') ix2 = find((EVENT.POS>0) & (EVENT.POS<=length(t))); % & (EVENT.DUR>0)); v = axis; hold on; N = length(EVENT.POS); plot([1;1]*t(EVENT.POS(ix))',v(3:4),':k'); if isfield(EVENT,'DUR') && (length(EVENT.DUR)==length(EVENT.POS)), for k=1:length(ix2), x = t(EVENT.POS(ix2(k))+[0,EVENT.DUR(ix2(k))])'; y = v(3:4); if exist('OCTAVE_VERSION','builtin'); patch(x([1,1,2,2,1]),y([1,2,2,1,1]),'b'); else ha=patch(x([1,1,2,2,1]),y([1,2,2,1,1]),[1,1,1]/4*3); set(ha,'FaceAlpha',.5); set(ha,'EdgeAlpha',.5); end; end; end; ix = ix2; for k=1:length(ix), txt = EVENT.Desc{ix(k)}; if isempty(txt),txt='';end; txt(txt=='_')=' '; if exist('text','builtin'); if exist('OCTAVE_VERSION','builtin'); text(t(EVENT.POS(ix(k))),v(3:4)*[-.2;.8],txt); else ha=text(t(EVENT.POS(ix(k))),v(3:4)*[-.2;.8],txt); set(ha,'Rotation',90,'VerticalAlignment','top'); end end; end; %v(4) = v(3:4)*[-.7;1.3]; axis(v); hold off; end; if 0, length(H.EVENT.POS) > 0, hold on; if 0, elseif isfield(H.EVENT,'DUR') && isfield(H.EVENT,'CHN'); plot([H.EVENT.POS,H.EVENT.POS+H.EVENT.DUR]'/H.SampleRate,[dd;dd]*H.EVENT.CHN','+-'); elseif isfield(H.EVENT,'CHN'); plot(H.EVENT.POS/H.SampleRate, H.EVENT.CHN*dd, 'x'); elseif isfield(H.EVENT,'DUR'); plot([H.EVENT.POS,H.EVENT.POS+H.EVENT.DUR]'/H.SampleRate,[dd;dd]*H.EVENT.CHN','+-'); else; plot(H.EVENT.POS/H.SampleRate,dd*ones(H.EVENT.N,1),'^'); end; hold off; LEG = strvcat(LEG,'Events'); end; if length(H.FILE)==1, tmp = H.FileName; tmp(find(tmp==92))='/'; tmp(find(tmp=='_'))=' '; else tmp = ''; end; title([tmp, ' generated with BIOSIG tools for Octave and Matlab(R)']); xlabel(X_Label); PhysDim = ''; if ~isempty(H.PhysDim), PhysDim = deblank(H.PhysDim{CHAN(1)}); end; ylabel(sprintf('Amplitude [%s]',PhysDim)); if exist('OCTAVE_VERSION')<5; if ~isempty(LEG); legend(LEG); end; end; if nargout, argout=H; end; biosig-2.3.3/biosig4matlab/t500_Visualization/topo2.m0000664000175000017500000000462314105434233022536 0ustar schloeglschloeglfunction topo2(V,HDR,maplimits) % TOPO2 makes a 2-D topographic map % % topo2(value,HDR [,limits]); % % % % $Id$ % Copyright (C) 2007,2008 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % % BioSig 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 3 of the License, or % (at your option) any later version. % % BioSig 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 BioSig. If not, see . Label = []; if isstruct(HDR) if isfield(HDR,'ELEC') XYZ = HDR.ELEC.XYZ; Label = HDR.Label; elseif isfield(HDR,'XYZ') XYZ = HDR.XYZ; end; elseif isnumeric(HDR), XYZ = HDR; end; size(XYZ),size(V), ix = find(all(~isnan(XYZ),2) & ~isnan(V(:))); R = sqrt(sum(XYZ(ix,:).^2,2)); th = atan(XYZ(ix,2)./XYZ(ix,1)) + pi*(XYZ(ix,1)<0); rd = acos(XYZ(ix,3)./R); th(isnan(th))=0; V = V(ix); Label = Label(ix); if nargin<3, maplimits=[-1,1]*max(abs(V)); %elseif isnumeric(maplimits) elseif ischar(maplimits) if strcmp(maplimits,'absmax'); maplimits=[-1,1]*max(abs(V)); elseif strcmp(maplimits,'maxmin'); maplimits=[min(V),max(V)]; end; end; r = max(rd)*1.05; x = -rd.*sin(th-pi/2); y = rd.*cos(th-pi/2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% interpolation %%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GRID_SCALE = 67; xi = linspace(-r,+r,GRID_SCALE); yi = linspace(-r,+r,GRID_SCALE); [Xi,Yi,Zi] = griddata(x,y,V,xi',yi,'invdist'); % interpolate data Zi(Xi.^2 + Yi.^2 > r.^2) = NaN; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% make topographic plot %%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %surf(Xi,Yi,Zi); caxis(maplimits); surface(Xi,Yi,zeros(size(Zi)),Zi,'EdgeColor','none','FaceColor','flat'); hold on; %contour(Xi,Yi,Zi,6,'k'); t = 0:.01:2*pi; plot(x,y,'k.',r*sin([-.1,0,.1]'),r*[cos([-.1,0,.1]')+[0,.1,0]'],'k-',r*sin(t),r*cos(t),'k-'); %for k=1:length(V),text(x(k),y(k),Label{k}),end; set(gca,'visible','off','xlim',[-1,1]*r,'ylim',[-1,1.1]*r); hold off; biosig-2.3.3/biosig4matlab/t500_Visualization/elpos.m0000664000175000017500000000461214105434233022613 0ustar schloeglschloeglfunction [XY,code]=elpos(Label); % ELPOS provides electrode positions in 2-D according to [1] % % [XYZ,code]=elpos(Label); % % see also: ELPOS3 % % Reference(s): % [1] FEF: % File Exchange Format for Vital Signs - Normative Annex A (Normative). % The Medical Data Information Base (MDIB), Nomenclature, Data Dictionary and Codes % Table A.6.3: Nomenclature and Codes for Electrode Sites % for Electroencephalography according to the International 10-20 system. % CEN/TC251/PT-40 (2001) % $Id$ % Copyright (c) 1997,1998,2004,2007,2010 by Alois Schloegl % alois.schloegl@gmail.com % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % 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 3 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 for more details. % % You should have received a copy of the GNU Library General Public % License along with this library; if not, write to the % Free Software Foundation, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, USA. tmp = leadidcodexyz('Fp1'); % make sure BIOSIG_GLOBAL.XYZ is loaded global BIOSIG_GLOBAL if nargin<1, Label=''; end [nr,nc]=size(Label); code=zeros(nr,1); XYZ = BIOSIG_GLOBAL.XYZ; Phi = atan(XYZ(:,1)./XYZ(:,2))*180/pi; Theta = acos(XYZ(:,3)./sqrt(sum(XYZ.^2,2))); xy = Theta.*exp(i*angle(XYZ*[1;i;0]))*180/pi; for k=1:nr; for l=1:length(BIOSIG_GLOBAL.Label), if iscell(Label) && strcmp(upper(deblank(Label{k}(5:end))),upper(BIOSIG_GLOBAL.Label{l})), code(k)=l; break; elseif ischar(Label) && strcmp(upper(deblank(Label(k,5:end))),upper(BIOSIG_GLOBAL.Label{l})) code(k)=l; break; end; end; end; K=code(code>0)'; XY = [real(xy(K)),imag(xy(K))]; T=0:.001:2*pi; R=180/pi*2; plot(real(xy),imag(xy),'x',real(xy(K)),imag(xy(K)),'ro',R*sin(T),R*cos(T),'b-',-R+R/10*sin(-T/2),10*cos(-T/2),'b-',10*sin(T/2)+R,10*cos(T/2),'b-',[-10 0 10],[R R+10 R],'b-'); for k=1:size(XYZ,1), if all(~isnan(XYZ(k,:))), text(real(xy(k)),imag(xy(k)),BIOSIG_GLOBAL.Label{k}); end; end; set(gca,'xtick',0,'ytick',0,'xticklabel','','yticklabel','') biosig-2.3.3/biosig4matlab/t500_Visualization/Contents.m0000664000175000017500000000064114105434233023264 0ustar schloeglschloegl% BIOSIG/T500 display functions % % PLOTA general display functions for BIOSIG % SVIEW simple signal viewer % TOPO2 topographic map % % ELPOS 2-D electrode positions % ELPOS3 3-D electrode positions % % % see also: % % % REFERENCES: % % $Id$ % Copyright (c) 2003,2004,2007,2008 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ biosig-2.3.3/biosig4matlab/t500_Visualization/elpos3.m0000664000175000017500000000415514105434233022700 0ustar schloeglschloeglfunction [xyz,code]=elpos3(Label); % ELPOS3 provides electrode positions in 3-D according to FEF % % [YX,code]=elpos3(Label); % % see also: ELPOS % % Reference(s): % [1] FEF: % File Exchange Format for Vital Signs - Normative Annex A (Normative). % The Medical Data Information Base (MDIB), Nomenclature, Data Dictionary and Codes % Table A.6.3: Nomenclature and Codes for Electrode Sites % for Electroencephalography according to the International 10-20 system. % CEN/TC251/PT-40 (2001) % $Id$ % Copyright (c) 1997,1998,2004,2007,2010 by Alois Schloegl % alois.schloegl@gmail.com % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % 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 3 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 for more details. % % You should have received a copy of the GNU Library General Public % License along with this library; if not, write to the % Free Software Foundation, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, USA. tmp = leadidcodexyz('Fp1'); % make sure BIOSIG_GLOBAL.XYZ is loaded global BIOSIG_GLOBAL if nargin<1, Label=''; end [nr,nc]=size(Label); code=zeros(nr,1); xyz=ones(nr,3); XYZ = BIOSIG_GLOBAL.XYZ; for k=1:nr, for l=1:length(BIOSIG_GLOBAL.Label), if iscell(Label) && strcmp(upper(deblank(Label{k}(5:end))),upper(BIOSIG_GLOBAL.Label{l})), code(k)=l; break; elseif ischar(Label) && strcmp(upper(deblank(Label(k,5:end))),upper(BIOSIG_GLOBAL.Label{l})) code(k)=l; break; end; end; end; K=code(code>0)' plot3(XYZ(:,1),XYZ(:,2),XYZ(:,3),'x',XYZ(K,1),XYZ(K,2),XYZ(K,3),'ro'); for k=1:size(XYZ,1), if all(~isnan(XYZ(k,:))), text(XYZ(k,1),XYZ(k,2),XYZ(k,3),BIOSIG_GLOBAL.Label{k}); end; end; set(gca,'xtick',0,'ytick',0) XYX = XYZ(k,:); biosig-2.3.3/biosig4matlab/t340_MachineLearningOptimalDetection/0000775000175000017500000000000014105434233024662 5ustar schloeglschloeglbiosig-2.3.3/biosig4matlab/t340_MachineLearningOptimalDetection/demo_mod.m0000664000175000017500000002246314105434233026632 0ustar schloeglschloegl% demo_mod shows the essential steps of using MOD for % detecting EPSP/EPSCs as described in [1] and applied in [2]. % % In order to run this demo, the following software packages % are needed: % - Octave (or Matlab) and the Signal Processing toolbox or package % - Biosig [3] % - NaN-toolbox [4] % - SigViewer [5] - for scoring the data and visualization of the % resulting detections % % Copyright (C) 2016-2021 Alois Schlögl, IST Austria % % References: % [1] Zhang X, Schlögl A, Vandael D, Jonas P, % MOD: A novel machine-learning optimal-filtering method for accurate and efficient % detection of subthreshold synaptic events in vivo. % Journal of Neuroscience Methods, 2021. % doi:10.1016/j.jneumeth.2021.109125 % [2] Xiaomin Zhang, Alois Schlögl, Peter Jonas % Selective Routing of Spatial Information Flow from Input to Output in Hippocampal Granule Cells, Neuron, 2020. % https://doi.org/10.1016/j.neuron.2020.07.006 % http://www.sciencedirect.com/science/article/pii/S0896627320305237 % [3] Biosig - an Free and Ppen source software library for biomedical signal processing % http://biosig.sourceforge.net/index.html % [4] The NaN-toolbox: A statistics and machine learning toolbox for Octave and Matlab® % for data with and w/o MISSING VALUES encoded as NaN's. % https://pub.ist.ac.at/~schloegl/matlab/NaN/ % [5] SigViewer (v0.51, or v0.65) % https://github.com/cbrnr/sigviewer % https://git.ist.ac.at/alois.schloegl/sigviewer.git % https://pub.ist.ac.at/~schloegl/software/sigviewer/sigviewer-0.6.4-win64.exe if exist('OCTAVE_VERSION','builtin') try pkg load biosig end try pkg load mexbiosig end pkg load nan pkg load tsa pkg load signal end %% check prerequisites if ~exist('sumskipnan','file') || ~exist('roc','file') addpath(fullfile(pwd,'NaN','src')); addpath(fullfile(pwd,'NaN','inst')); fprintf(2,'Warning: sumskipnan() is missing - installing NaN-toolbox\n'); end if isnan(mean([1,3,NaN])) addpath(fullfile(pwd,'NaN','src')); addpath(fullfile(pwd,'NaN','inst')); fprintf(2,'Warning: mean() from NaN-toolbox is missing - install NaN-toolbox\n'); end tmp=roc(randn(100,1),[1:100]'<50); if ~isfield(tmp,'H_kappa') error('roc() from NaN-toolbox is missing - install NaN-toolbox'); end if sum(isnan(detrend([1,NaN,3])))>1 addpath(fullfile(pwd,'NaN','src')); addpath(fullfile(pwd,'NaN','inst')); fprintf(2,'Warning: detrend() from NaN-toolbox is missing - install NaN-toolbox\n'); end if ~exist('mexSLOAD','file') error('mexSLOAD is missing - mexBiosig or Biosig need to be installed'); end if ~exist('detect_spikes_bursts','file') fprintf(2,'Error: detect_spikes_bursts() is missing - Biosig need to be installed\n'); end % read channel of raw data, the example data is available from here: % https://pub.ist.ac.at/~schloegl/software/mod/ filename='data/XM160126-02.dat'; chan=1; if ~exist(filename,'file'), error(sprintf('file %s not available - you can download the example file from https://pub.ist.ac.at/~schloegl/software/mod/data/')); end [s,HDR]=mexSLOAD(filename,chan); HDR.SampleRate=round(HDR.SampleRate); HDR.EVENT.SampleRate=round(HDR.EVENT.SampleRate); % clean up data, everything before this marker can be ignored. if isfield(HDR.EVENT,'CodeDesc') typ = find(strcmp(HDR.EVENT.CodeDesc,'IV-1000')); if length(typ)>0, START = max(HDR.EVENT.POS(HDR.EVENT.TYP==typ)); s(1:START) = NaN; end end % load the two segments of the scoring from Export E1 [e11,EVT]=mexSLOAD('data/XM160126-02_E1S1.evt'); event_pos1 = EVT.EVENT.POS(EVT.EVENT.TYP==10); [e12,EVT]=mexSLOAD('data/XM160126-02_E1S2.evt'); event_pos2 = EVT.EVENT.POS(EVT.EVENT.TYP==10); % Here are some standard parameters we have used in [1,2]. if HDR.SampleRate < 50000, Fs=HDR.SampleRate; else Fs=25000; end TemplateLength=0.040*Fs; % filterlength Twin=0.004; % window length in seconds [s] WINLEN=round(Twin*Fs); % load the two segment of the scoring from Export E2 % we ignore this here for the sake of simplicity % [e2,HDR] =mexSLOAD('data/XM160126-02_E2S12.evt') % identify action potentials AP = []; if exist('detect_spikes_bursts','file') AP = detect_spikes_bursts(filename, chan); end % downsample to 25 kHz if (HDR.SampleRate ~= Fs) DIV = round(HDR.SampleRate/Fs); s = rs(s,DIV,1); % adapt event positions to new sampling rate HDR.EVENT.POS = round((HDR.EVENT.POS-1)*Fs/HDR.EVENT.SampleRate)+1; if isfield(HDR.EVENT,'DUR'); HDR.EVENT.DUR = round(HDR.EVENT.DUR*Fs/HDR.EVENT.SampleRate); end HDR.SampleRate = Fs; HDR.EVENT.SampleRate = Fs; event_pos1 = round(event_pos1/DIV); event_pos2 = round(event_pos2/DIV); AP.EVENT.POS = round((AP.EVENT.POS-1)*Fs/AP.EVENT.SampleRate)+1; if isfield(HDR.EVENT,'DUR'); AP.EVENT.DUR = round(AP.EVENT.DUR*Fs/AP.EVENT.SampleRate); end AP.EVENT.SampleRate = Fs; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % remove AP's and spikelets and replace with blanks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ~isempty(AP) apix = find(AP.EVENT.TYP==hex2dec('0201')); [ix,iy]=meshgrid(apix,[0:TemplateLength]-round(TemplateLength/4)); ix=ix(:)+iy(:); ix((ix<1) | (ix>length(s)))=[]; s(ix)=NaN; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % generate scoring trace %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TiS1=[min(event_pos1);max(event_pos1)]; TiS2=[min(event_pos2);max(event_pos2)]; C = repmat(NaN,size(s)); % set to NaN for unscored periods C(TiS1(1):TiS1(2))=0; % scored periods are now initialized C(TiS2(1):TiS2(2))=0; [ix,iy]=meshgrid([event_pos1(:);event_pos2(:)],round(-WINLEN/2):round(WINLEN/2)); ix=ix(:)+iy(:); ix(ix<1)=[]; ix(ix>length(s))=[]; C(ix) = 1; % set the events with window size WINLEN in the scoring trace % remove linear trend S = detrend(s); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % cross-validation (XV) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if 0, % disable or enable XV % Grouping for S1-S2 cross-validation (XV) G1 = zeros(size(s)); G1(TiS1(1):TiS1(2))=1; G1(TiS2(1):TiS2(2))=2; % Grouping for A1B2-A2B1 cross-validation(XV) G2 = zeros(size(s)); ti3=[sum(TiS1),sum(TiS2)]/2; G2(TiS1(1):ti3(1))=1; G2(ti3(1):TiS1(2))=2; G2(TiS2(1):ti3(2))=2; G2(ti3(2):TiS2(2))=1; % XV: S1->S2 cross-validiation ixtrain=find(G1==1); ixtest=find(G1==2); RES12S=mod_optimal_detection_filter(S, C, TemplateLength, ixtrain, ixtest); % XV: S2->S1 cross-validiation ixtrain=find(G1==2); ixtest=find(G1==1); RES21S=mod_optimal_detection_filter(S, C, TemplateLength, ixtrain, ixtest); % In [1,2], we combined the output from the two testing sets, and % and applied the ROC analysis to this trace. % for the sake of simplicity, this is omitted here. % XV: A1B2->A2B1 cross-validiation ixtrain=find(G2==1); ixtest=find(G2==2); RES1A2B=mod_optimal_detection_filter(S, C, TemplateLength, ixtrain, ixtest); % XV: A2B1->A1B2 cross-validiation ixtrain=find(G2==2); ixtest=find(G2==1); RES2A1B=mod_optimal_detection_filter(S, C, TemplateLength, ixtrain, ixtest); % In [1,2], we combined the output from the two testing sets, and % and applied the ROC analysis to this trace. % for the sake of simplicity, this is omitted here. fprintf(1,'AUC: (XV:S1->S2):\t %g\n', RES12S.test.AUC); fprintf(1,'AUC: (XV:S2->S1):\t %g\n', RES21S.test.AUC); fprintf(1,'AUC: (XV:A1B2->A2B1):\t %g\n', RES1A2B.test.AUC); fprintf(1,'AUC: (XV:A2B1->A1B2):\t %g\n', RES2A1B.test.AUC); % XV: LOOM % this is not implemented here, essentially the idea is to % concatenate the data from multiple cells, and use the data % of m-1 cells for training, and the data from the remaining cell for % testing. end % w/o XV: scored data is used for training ixtrain=find(~isnan(C)); % use the scored data for training % avoid edge issues when computing correlation functions ixtrain=ixtrain((2*TemplateLengthTH], [], pos, WINLEN, Fs, H0, AP); % apply a smoothing filter as discribed in [1] - this might not be needed D = filter(RES.CLASSIFIER.A,1,S); WinHann = 13; A = hann(WinHann); A=A/sum(A); nix = isnan(D); D(nix) = mean(D); D = filtfilt(A,1,D); D(nix)=NaN; D = [D(delay+1:end);repmat(NaN,delay,1)]; pos = get_local_maxima_above_threshold(D,TH,4,0.001*Fs); % save results in a GDF file for visualization with SigViewer H0 = []; [tmp_p,tmp_f,tmp_e] = fileparts(HDR.FileName); H0.FileName = sprintf('output/%s.%s.w%d.e1.h%d.gdf', tmp_f, 'mod', round(Twin*1000), WinHann); H2 = minidet2gdf([s, D, D>TH], [], pos, WINLEN, Fs, H0, AP); biosig-2.3.3/biosig4matlab/t340_MachineLearningOptimalDetection/minidet2gdf.m0000664000175000017500000002165214105434233027242 0ustar schloeglschloeglfunction HDR = minidet2gdf(S,POS,pos,WINLEN,Fs,fn, AP_Events) % MINIDET2GDF writes results of miniature detection results to a GDF file. % % % Usage: % HDR = minidet2gdf(S,POS,pos,Twin,Fs,fn, AP_Events) % HDR = minidet2gdf([S, D, D>TH], [], pos, Twin, Fs, H0, []); % % Input: % S: raw data % D: raw detection trace % TH: detection threshold, such that (D>TH) produced binary detection trace % POS: (optional) export scoring % pos: detected event times, typically these are obtained by % pos = get_local_maxima_above_threshold(D,TH,1,0.01*Fs); % Twin: windows length when translating expert scoring into scoring trace. % Fs: sampling rate in Hertz % HDR: out file structure such that % HDR.FileName indicates the output file name. % The resulting file will be stored in GDF format [2,3], which can be read % by Biosig, Sigviewer and other software. % AP_Events: if AP's have been detected % and should be indicated as such in the output file. % % Output: % HDR: header structure of the output file HDR.FileName. % % % see also: % AUC, MINIDET2GDF, GET_LOCAL_MAXIMA_ABOVE_THRESHOLD, % % References: % [1] Zhang X, Schlögl A, Vandael D, Jonas P, % MOD: A novel machine-learning optimal-filtering method for accurate and efficient % detection of subthreshold synaptic events in vivo. % Journal of Neuroscience Methods, 2021. % doi:10.1016/j.jneumeth.2021.109125 % [2] Xiaomin Zhang, Alois Schlögl, Peter Jonas % Selective Routing of Spatial Information Flow from Input to Output in Hippocampal Granule Cells, Neuron, 2020. % https://doi.org/10.1016/j.neuron.2020.07.006 % http://www.sciencedirect.com/science/article/pii/S0896627320305237 % [3] A. Schlögl, GDF - A general dataformat for biosignals, Technical Report. % Version 2.x (2006) available at: GDF 2.0 % [4] ON K2204:2015 A general dataformat for biosignals, Austrian Standards, 2015 % Copyright (C) 2017-2021 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % % BioSig 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 3 of the License, or % (at your option) any later version. % % BioSig 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 BioSig. If not, see . % HDR.FileName = sprintf('/fs3/home/schloegl/projects/minis/Xiaomin/optim_mini_detect.%s_%5.3f.gdf',METHODS{k3},WINLEN(k1)); if isstruct(fn) HDR=fn; else HDR.FileName = fn; end; if nargin<7 AP_Events = []; end; if isfield(AP_Events,'EVENT'); AP_Events = AP_Events.EVENT; end if ~isfield(AP_Events,'POS') || ~isfield(AP_Events,'TYP') || ~isfield(AP_Events,'DUR') || ~isfield(AP_Events,'CHN') AP.POS=[]; AP.TYP=[]; AP.DUR=[]; AP.CHN=[]; fprintf('Warning, No AP events provided'); else AP = AP_Events; % select only events ix = ((hex2dec('200') <= AP.TYP) & (AP.TYP < hex2dec('020F'))); AP.POS = round((AP.POS(ix)-1)*Fs/AP.SampleRate)+1; AP.TYP = AP.TYP(ix); AP.DUR = round(AP.DUR(ix)*Fs/AP.SampleRate); AP.CHN = AP.CHN(ix); end VER = version; cname = computer; % select file format HDR.TYPE='GDF'; % description of recording device HDR.Manufacturer.Name = 'BioSig'; HDR.Manufacturer.Model = 'demo_mod'; HDR.Manufacturer.Version = '1.1'; HDR.Manufacturer.SerialNumber = '00000000'; % recording identification, max 80 char. HDR.RID = 'TestFile 001'; %StudyID/Investigation [consecutive number]; HDR.REC.Hospital = 'Biosig Laboratory'; HDR.REC.Technician = get_current_username(); HDR.REC.Equipment = 'biosig'; HDR.REC.IPaddr = [127,0,0,1]; % IP address of recording system HDR.Patient.Name = 'anonymous'; HDR.Patient.Id = 'X'; HDR.Patient.Birthday = [0 0 0 0 0 0]; HDR.Patient.Weight = 0; % undefined HDR.Patient.Height = 0; % undefined HDR.Patient.Sex = 0; % 0: undefined, 1: male, 2: female HDR.Patient.Birthday = zeros(1,6); % undefined HDR.Patient.Impairment.Heart = 0; % 0: unknown 1: NO 2: YES 3: pacemaker HDR.Patient.Impairment.Visual = 0; % 0: unknown 1: NO 2: YES 3: corrected (with visual aid) HDR.Patient.Smoking = 0; % 0: unknown 1: NO 2: YES HDR.Patient.AlcoholAbuse = 0; % 0: unknown 1: NO 2: YES HDR.Patient.DrugAbuse = 0; % 0: unknown 1: NO 2: YES HDR.Patient.Handedness = 0; % unknown, 1:left, 2:right, 3: equal % recording time [YYYY MM DD hh mm ss.ccc] if ~isfield(HDR,'T0') HDR.T0 = clock; end % number of channels HDR.NS = size(S,2); assert(HDR.NS==3) % Duration of one block in seconds HDR.SampleRate = Fs; HDR.SPR = 1; HDR.Dur = HDR.SPR/HDR.SampleRate; % Samples within 1 block HDR.AS.SPR = ones(HDR.NS,1); % samples per block; 0 indicates a channel with sparse sampling %HDR.AS.SampleRate = [1000;100;200;100;20;0]; % samplerate of each channel % channel identification, max 80 char. per channel HDR.Label={'raw';'detection trace';'x>TH'}; % Transducer, mx 80 char per channel HDR.Transducer = {'-'; '-'; '-'}; % define datatypes (GDF only, see GDFDATATYPE.M for more details) HDR.GDFTYP = 16*ones(1,HDR.NS); % define scaling factors p1=max(S);m1=min(S); p2=p1 + (p1-m1)/100; m2=m1 + (m1-p1)/100; HDR.PhysMax = p2; HDR.PhysMin = m2; HDR.DigMax = p2; HDR.DigMin = m2; HDR.FLAG.UCAL = 1; % data S is already converted to internal (usually integer) values (no rescaling within swrite); HDR.FLAG.UCAL = 0; % data S will be converted from physical to digital values within swrite. % define filter settings HDR.Filter.Lowpass = [NaN,NaN,NaN]; HDR.Filter.Highpass = [0,0,0]; HDR.Filter.Notch = [0,0,0]; % define sampling delay between channels HDR.TOffset = [0,0,0]; % define physical dimension HDR.PhysDim = {'a.u.';'1';'1'}; %% must be encoded in unicode (UTF8) HDR.Impedance = repmat(NaN,1,HDR.NS); % electrode impedance (in Ohm) for voltage channels HDR.fZ = repmat(NaN,1,HDR.NS); % probe frequency in Hz for Impedance channel [p,f,e]=fileparts(HDR.FileName); mini_epsp_position = pos/Fs; %%%%%%%%%%%%%%%%%%%%%%%%%%%% % EPSP Amplitude %%%%%%%%%%%%%%%%%%%%%%%%%%%% % baseline time interval T01=-0.008; T02=-0.004; % peak time interval T03=-0.001; T04=+0.001; % save triggered data T=[-0.04*Fs,0.04*Fs]; t=[T(1):T(2)]'/Fs; [x,sx]=trigg(S,pos,T(1),T(2)); x=reshape(x,sx); baseline = mean(x(1,(T01 % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % % BioSig 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 3 of the License, or % (at your option) any later version. % % BioSig 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 BioSig. If not, see . if nargin<6, method.preproc='wiener2'; elseif ischar(method) tmp=method; clear method; method.preproc=tmp; end; %NAN_BLOCK=repmat(NaN,maxlag,1); %data = [NAN_BLOCK; data; NAN_BLOCK]; %C = [NAN_BLOCK; C; NAN_BLOCK]; %ixtrain = ixtrain+maxlag; %ixtest = ixtest+maxlag; if isempty(ixtest) ixtest = ixtrain; ixtest0 = [2*maxlag:size(data,1)]'; else ixtest0 = ixtest; end % if isfield(method,'preproc') && strcmp(method.preproc,'wopt2') && (size(data,2)==1) if 1 ID0=tic(); cput0=cputime(); Rdc=repmat(NaN,2*maxlag+1,1); Rdd=repmat(NaN,2*maxlag+1,1); dl=length(data); if (any(ixtest > dl-maxlag) || any(ixtest <= maxlag)) warning('ixtest should be limited to the range MAXLAG+1:length(data)-MAXLEN') end if (any(ixtrain > dl-maxlag) || any(ixtrain <= maxlag)) warning('ixtrain should be limited to the range MAXLAG+1:length(data)-MAXLEN') end data((end+1) : (ixtest0(end)+maxlag*1.5)) = NaN; c = center(C(ixtrain)); TTLabel{1} = 'length-of-data'; TTLabel{2} = 'number-of-lags'; TTLabel{3} = 'length-ixtrain'; TTLabel{4} = 'sum-ixtrain'; TT=[size(data,1), 3*maxlag,length(ixtrain),sum(ixtrain)]; ID1=tic(); cput1=cputime(); for k=-maxlag*2:maxlag*2, Rdc(k+1+maxlag*2)=mean(data(ixtrain-k).*c); Rdd(k+1+maxlag*2)=mean(data(ixtrain-k).*data(ixtrain)); end; TT=[TT, toc(ID1), cputime()-cput1]; ID1=tic(); cput1=cputime(); TTLabel{end+1} = 'wallclock-acf+ccf'; TTLabel{end+1} = 'cputime-acf+ccf'; TT2Label={'wallclock-toeplitz'}; TT2Label{end+1} = 'cputime-toeplitz'; TT2Label{end+1} = 'wallclock-filter(*2)'; TT2Label{end+1} = 'cputime-filter(*2)'; TT2Label{end+1} = 'wallclock-auc(*2)'; TT2Label{end+1} = 'cputime-auc(*2)'; A=[]; B=[]; %DLIST=0:5:1000; if isfield(method,'DLIST') DLIST=method.DLIST; % 10 ms else DLIST=-maxlag/4:25:maxlag; end AUC=repmat(NaN,length(DLIST),4); for k=1:length(DLIST) ID2=tic(); cput2=cputime(); delay = DLIST(k); A = toeplitz(Rdd(maxlag*2+(0:maxlag))) \ Rdc(maxlag*2+1-delay+[0:maxlag]); B = toeplitz(Rdd(maxlag*2+(0:maxlag))) \ Rdc(maxlag*2+1+delay-[0:maxlag]); TT2(k,1:2)=[toc(ID2), cputime()-cput2]; ID2=tic(); cput2=cputime(); out1a = filter(A,1,data); %out1b = filter(B,1,data); TT2(k,3:4)=[toc(ID2), cputime()-cput2]; ID2=tic(); cput2=cputime(); %AUC(k,1:2)=[auc(out1a(ixtest+delay),C(ixtest)), auc(out1b(ixtest+delay),C(ixtest))]; tmp = roc(out1a(ixtest+delay),C(ixtest)); AUC(k,1) = tmp.AUC; TT2(k,5:6) = [toc(ID2), cputime()-cput2]; ID2=tic(); cput2=cputime(); if 0, %try out2a = filter(A,1,data); out2b = filter(B,1,data); AUC(k,3:4)=[auc(out2a(ixtest+delay),C(ixtest)), auc(out2b(ixtest+delay),C(ixtest))]; end RES.WOPT.A(:,k) = A; RES.WOPT.B(:,k) = B; end TT=[TT, k, toc(ID1), cputime()-cput1]; ID1=tic(); cput1=cputime(); TTLabel{end+1}='number-of-delays'; TTLabel{end+1}='wallclock-find-delay(wiener+auc)'; TTLabel{end+1}='cputime-find-delay(wiener+auc)'; RES.WOPT.DLIST = DLIST(:); RES.WOPT.AUC = AUC; % AUC, [tmpAUC,tmpix]=max(AUC,[],1); [tmpm,mix] = max(tmpAUC); if 1, %mix==1 RES.CLASSIFIER.A = RES.WOPT.A(:,tmpix(mix)); RES.CLASSIFIER.delay = DLIST(tmpix(mix)); elseif mix==2 RES.CLASSIFIER.A = RES.WOPT.B(:,tmpix(mix)); RES.CLASSIFIER.delay = DLIST(tmpix(mix)); elseif mix==3 RES.CLASSIFIER.A = RES.WOPT.A(:,tmpix(mix)); RES.CLASSIFIER.delay = -DLIST(tmpix(mix)); elseif mix==4 RES.CLASSIFIER.A = RES.WOPT.B(:,tmpix(mix)); RES.CLASSIFIER.delay = -DLIST(tmpix(mix)); end RES.WOPT.delay=RES.CLASSIFIER.delay; ID1=tic(); cput1=cputime(); out = filter(RES.CLASSIFIER.A, 1, data); TT=[TT, toc(ID1), cputime()-cput1]; ID1=tic(); cput1=cputime(); TTLabel{end+1}='wallclock-filtering-all-data'; TTLabel{end+1}='cputime-filtering-all-data'; ROC.train = roc(out(ixtrain+RES.CLASSIFIER.delay), C(ixtrain)); ROC.test = roc(out(ixtest0+RES.CLASSIFIER.delay), C(ixtest0)); RES.CLASSIFIER.CM = ROC.test.H_kappa; RES.CLASSIFIER.THRESHOLD = ROC.test.THRESHOLD.maxKAPPA; RES.CLASSIFIER.AUC = ROC.test.AUC; RES.train.AUC = ROC.train.AUC; RES.test.AUC = ROC.test.AUC; RES.THRESHOLD = ROC.train.THRESHOLD.maxKAPPA; RES.train.CM = ROC.train.H_kappa; RES.test.CM = ROC.test.H_kappa; [RES.train.Kappa,sd,H] = kappa(ROC.train.H_kappa); [RES.test.Kappa,sd,H] = kappa(ROC.test.H_kappa); TT=[TT toc(ID1), cputime()-cput1]; ID1=tic(); cput1=cputime(); TTLabel{end+1}='wallclock-auc'; TTLabel{end+1}='cputime-auc'; RES.output = out(ixtest0+RES.CLASSIFIER.delay); TT=[TT, toc(ID0), cputime()-cput0, mean(TT2)/2]; TTLabel{end+1}='wallclock-total'; TTLabel{end+1}='cputime-total'; TTLabel{end+1}='wallclock-toeplitz-average(x2)'; TTLabel{end+1}='cputime-toeplitz-average(x2)'; TTLabel{end+1}='wallclock-filter-training-data-average(x2)'; TTLabel{end+1}='cputime-filter-training-data-average(x2)'; TTLabel{end+1}='wallclock-auc-average(x2)'; TTLabel{end+1}='cputime-auc-average(x2)'; RES.TT=TT; RES.TT2=TT2; RES.TTLabel=TTLabel; RES.TT2Label=TT2Label; fprintf(1,'TimeLabels:\t'); fprintf(1,'%s\t',TTLabel{:}); fprintf(1,'%s\nTiming:\t'); fprintf(1,'%g\t',TT); fprintf(1,'\n'); else whos method error('invalid input argumments') end biosig-2.3.3/biosig4matlab/t501_VisualizeCoupling/0000775000175000017500000000000014105434233022124 5ustar schloeglschloeglbiosig-2.3.3/biosig4matlab/t501_VisualizeCoupling/locs_2470000664000175000017500000002750714105434233023416 0ustar schloeglschloegl 5.7346000e-002 1.3960000e-003 1.7042320e-001 5.5954000e-002 2.4036000e-002 1.6800330e-001 -8.5555000e-003 8.5160000e-002 1.4004000e-001 -2.3693500e-002 7.3203300e-002 1.4888240e-001 -3.6252000e-002 5.8509100e-002 1.5608270e-001 -4.5570400e-002 4.0182900e-002 1.6178180e-001 -5.1591800e-002 2.0168500e-002 1.6490130e-001 -5.3198100e-002 -8.2300000e-005 1.6552850e-001 -5.1507200e-002 -2.0388800e-002 1.6371470e-001 -4.4705700e-002 -4.0099600e-002 1.6058280e-001 -3.5092100e-002 -5.7875000e-002 1.5452660e-001 -2.2454600e-002 -7.1537700e-002 1.4767620e-001 3.7470600e-002 2.1516500e-002 1.7710840e-001 -6.8483000e-003 -8.3335100e-002 1.3790910e-001 1.0211300e-002 -9.0081900e-002 1.2779210e-001 2.7731000e-002 -9.2036500e-002 1.1728490e-001 4.4928000e-002 -9.2129400e-002 1.0298960e-001 6.3400600e-002 -9.0074000e-002 9.0923800e-002 8.0621300e-002 -8.8209900e-002 8.0275600e-002 9.9196700e-002 -8.3366200e-002 6.6962500e-002 1.1616410e-001 -7.3482900e-002 5.7081800e-002 1.2995330e-001 -5.8592000e-002 4.8112600e-002 1.4096100e-001 -4.0680600e-002 4.1595800e-002 3.6515200e-002 1.7504000e-003 1.7950110e-001 1.4739040e-001 -1.9981700e-002 3.6783100e-002 1.4348770e-001 3.0652000e-003 1.5630700e-002 1.4093770e-001 2.6446500e-002 1.7459200e-002 1.3361380e-001 4.8528200e-002 2.2217300e-002 1.2126620e-001 6.6970500e-002 2.9245200e-002 1.0572560e-001 8.2111600e-002 3.8661400e-002 8.7510600e-002 9.2842600e-002 4.9094000e-002 6.6879100e-002 9.7791900e-002 6.1661300e-002 5.0028400e-002 9.9844400e-002 7.2235900e-002 3.0844700e-002 1.0152810e-001 8.4180300e-002 3.7959000e-002 -1.8903800e-002 1.7684410e-001 1.4942700e-002 1.0182200e-001 1.0017680e-001 -4.8376000e-003 9.9164100e-002 1.1146590e-001 -2.3208700e-002 9.1789700e-002 1.2178460e-001 -3.9341700e-002 7.8585800e-002 1.3153730e-001 -5.2836800e-002 6.2528800e-002 1.3928790e-001 -6.2820000e-002 4.3692500e-002 1.4495540e-001 -6.8746800e-002 2.2522700e-002 1.4877250e-001 -7.1027000e-002 -1.8540000e-004 1.4978360e-001 -6.8075200e-002 -2.2637800e-002 1.4826590e-001 -6.1763400e-002 -4.3574400e-002 1.4457640e-001 5.6448800e-002 -2.1110900e-002 1.6781420e-001 -5.0774900e-002 -6.1876400e-002 1.3902610e-001 -3.6646400e-002 -7.8263900e-002 1.3066800e-001 -2.0461300e-002 -8.9661500e-002 1.2100040e-001 -2.1923000e-003 -9.6954600e-002 1.1012100e-001 1.7296500e-002 -9.9116300e-002 9.9278700e-002 3.3386000e-002 -9.8551400e-002 8.3555100e-002 5.2207600e-002 -9.6164600e-002 7.1798200e-002 6.9701100e-002 -9.4125900e-002 6.0798300e-002 8.9678100e-002 -8.8606600e-002 4.8667000e-002 1.0770450e-001 -7.7990900e-002 3.8587700e-002 7.4542400e-002 -2.1467600e-002 1.5571240e-001 1.2307330e-001 -6.2417800e-002 2.8981800e-002 1.3408540e-001 -4.3176500e-002 2.1661000e-002 1.4118670e-001 -2.1563800e-002 1.6969700e-002 9.0110500e-002 8.7609900e-002 2.4361300e-002 7.4313700e-002 9.5259400e-002 3.2380400e-002 5.5062900e-002 9.9568400e-002 4.3313600e-002 3.0089900e-002 1.0649060e-001 5.2360700e-002 1.1647500e-002 1.0818620e-001 6.3488700e-002 -7.0871000e-003 1.0998970e-001 7.4178500e-002 -2.4630600e-002 9.7650800e-002 1.0052360e-001 9.3102600e-002 -2.0657900e-002 1.4229520e-001 -4.1276200e-002 8.8627000e-002 1.0978350e-001 -5.7091700e-002 7.3693400e-002 1.1931870e-001 -6.9533900e-002 5.5542200e-002 1.2673560e-001 -7.7938300e-002 3.4316700e-002 1.3180160e-001 -8.1924300e-002 1.1184300e-002 1.3488840e-001 -8.1838900e-002 -1.1486800e-002 1.3412850e-001 -7.7258400e-002 -3.3979700e-002 1.3096490e-001 -6.7905400e-002 -5.5338000e-002 1.2571630e-001 -5.5564700e-002 -7.2549500e-002 1.1810940e-001 -3.9861000e-002 -8.6623000e-002 1.0852370e-001 1.0919430e-001 -2.0302900e-002 1.3034020e-001 -2.2287300e-002 -9.6028600e-002 9.8460000e-002 -4.6571000e-003 -1.0757180e-001 7.3254100e-002 1.3611600e-002 -1.0542280e-001 6.2717000e-002 3.3087200e-002 -1.0342620e-001 5.1213200e-002 5.8176300e-002 -9.5752800e-002 4.2095300e-002 7.6491700e-002 -9.1271400e-002 3.1188000e-002 9.3050700e-002 -8.2535600e-002 2.3189100e-002 7.5454800e-002 9.1135900e-002 5.7863000e-003 6.0917800e-002 9.8021500e-002 1.6840500e-002 4.3786200e-002 9.9943400e-002 2.4582100e-002 1.2610440e-001 -1.8364500e-002 1.1598890e-001 -2.8943600e-002 1.1127590e-001 7.0263400e-002 -4.1967600e-002 9.4082000e-002 8.9776100e-002 -5.8819700e-002 8.2594600e-002 9.9277800e-002 -7.3047500e-002 6.4625200e-002 1.0899110e-001 -8.3835400e-002 4.5467000e-002 1.1428090e-001 -9.0974900e-002 2.3257000e-002 1.1810870e-001 -9.2608300e-002 -7.7690000e-004 1.1883670e-001 -8.9716100e-002 -2.4801500e-002 1.1720710e-001 -8.2717300e-002 -4.5319100e-002 1.1277330e-001 -7.1306200e-002 -6.4261600e-002 1.0743850e-001 1.3968670e-001 3.5057000e-003 9.9847200e-002 -5.6419900e-002 -8.1256100e-002 9.8916800e-002 -4.0126600e-002 -9.2246100e-002 8.9143800e-002 -2.6365200e-002 -1.0981220e-001 7.0380600e-002 4.7237300e-002 -9.6545500e-002 2.3428200e-002 6.2940200e-002 -9.3852100e-002 1.4740900e-002 7.8033200e-002 -8.6879100e-002 6.5115000e-003 1.5948200e-002 1.0693450e-001 2.7766400e-002 -3.4184000e-003 1.0857410e-001 3.9104400e-002 -2.2106600e-002 1.1116250e-001 5.0349000e-002 -5.9380600e-002 8.9394700e-002 7.8302800e-002 7.5384700e-002 1.6490000e-003 1.5762860e-001 1.3591180e-001 2.8696900e-002 9.8538800e-002 -7.5431200e-002 7.4680800e-002 8.7820500e-002 -8.8464500e-002 5.6497600e-002 9.6410900e-002 -9.7375800e-002 3.3589800e-002 1.0245350e-001 -9.9964400e-002 1.1210500e-002 1.0323510e-001 -1.0036330e-001 -1.2201500e-002 1.0303210e-001 -9.3023400e-002 -3.5687100e-002 1.0018320e-001 -8.6411800e-002 -5.5202500e-002 9.5052500e-002 -7.3373100e-002 -7.3466900e-002 8.7723300e-002 -5.7431400e-002 -8.7158200e-002 7.8455600e-002 -1.8988200e-002 -1.0946020e-001 4.9516300e-002 1.2336500e-001 4.3542700e-002 1.0789000e-001 -3.5790000e-004 -1.0636630e-001 3.7947500e-002 1.8434600e-002 -1.0440370e-001 2.6982300e-002 5.1772900e-002 9.5560000e-002 -4.9759000e-003 3.3090900e-002 9.9082900e-002 6.4131000e-003 -4.3363500e-002 1.1161420e-001 4.6418700e-002 -6.0534100e-002 9.3955300e-002 5.7965100e-002 -7.7286400e-002 8.2949000e-002 6.7687300e-002 -9.1356000e-002 6.5854700e-002 7.5841900e-002 -1.0280230e-001 4.6698700e-002 8.2954100e-002 -1.0838410e-001 2.3705800e-002 8.8402000e-002 1.0454580e-001 4.6925000e-002 1.2372510e-001 -1.1074490e-001 1.0406000e-003 8.8834400e-002 -1.0799650e-001 -2.4089600e-002 8.6346900e-002 -1.0075090e-001 -4.5721400e-002 8.2296400e-002 -8.9267100e-002 -6.3836600e-002 7.6246900e-002 -7.5117800e-002 -8.0130500e-002 6.7583100e-002 -5.8093000e-002 -9.3204800e-002 5.6988300e-002 -4.0362900e-002 -1.1021690e-001 4.6018600e-002 3.5902300e-002 -9.6118100e-002 5.3225000e-003 5.3850200e-002 -9.1937900e-002 -4.7076000e-003 3.2294200e-002 9.9320300e-002 -1.7777100e-002 8.7770800e-002 4.6928700e-002 1.3565110e-001 1.6894000e-002 1.0170490e-001 -8.1067000e-003 2.5840000e-003 1.0707890e-001 3.5604000e-003 -1.7406600e-002 1.0961010e-001 1.4840500e-002 -3.6049500e-002 1.1062210e-001 2.7114600e-002 -7.8506800e-002 8.8820300e-002 4.7465400e-002 -9.3094200e-002 7.4100200e-002 5.7403700e-002 -1.0779670e-001 5.6903400e-002 6.4441600e-002 -1.1620300e-001 3.5428600e-002 6.8294700e-002 -1.1993900e-001 1.0576000e-002 7.3225700e-002 -1.1912280e-001 -1.1967400e-002 7.1892200e-002 6.9563400e-002 4.7338400e-002 1.4833190e-001 -1.1419550e-001 -3.5285800e-002 6.9171000e-002 -1.0546500e-001 -5.5878900e-002 6.3731400e-002 -9.2699500e-002 -7.3865100e-002 5.6807400e-002 -7.5995400e-002 -8.8220600e-002 4.8025800e-002 -3.2726300e-002 -1.0887620e-001 2.5400600e-002 -1.4492300e-002 -1.0651550e-001 1.4847900e-002 1.9361800e-002 -9.8854200e-002 -8.3676000e-003 3.5305700e-002 -9.5956300e-002 -1.7652000e-002 5.2318200e-002 4.6608900e-002 1.6112010e-001 3.0283200e-002 4.3136100e-002 1.7228780e-001 1.4866700e-002 2.5344200e-002 1.8086690e-001 1.3715300e-002 1.4298000e-003 1.8386840e-001 1.5935800e-002 -2.2938000e-002 1.8074210e-001 9.4207600e-002 2.8191000e-003 1.4431410e-001 3.0998100e-002 -4.0119300e-002 1.7194590e-001 5.3212500e-002 -4.3133800e-002 1.6114340e-001 7.1176900e-002 -4.4028100e-002 1.4823580e-001 8.8980800e-002 -4.2830700e-002 1.3549830e-001 1.0569460e-001 -4.2232800e-002 1.2308600e-001 1.2406380e-001 -3.8841900e-002 1.0755860e-001 1.3688390e-001 -2.3316800e-002 9.8236400e-002 1.4797810e-001 2.1156000e-003 8.0020200e-002 1.4456440e-001 2.6469900e-002 7.9696100e-002 1.3291560e-001 4.6512300e-002 8.8523900e-002 1.1063200e-001 3.0167000e-003 1.3257450e-001 1.1711660e-001 6.1195200e-002 9.7805700e-002 9.9836200e-002 6.5609900e-002 1.1117640e-001 8.2990400e-002 6.6274900e-002 1.2332950e-001 6.5965200e-002 6.7173600e-002 1.3491930e-001 4.9819500e-002 6.5947100e-002 1.4790100e-001 3.1649800e-002 6.4022000e-002 1.5869950e-001 1.3403700e-002 5.6235400e-002 1.6785800e-001 4.1100000e-005 4.1302200e-002 1.7597790e-001 -6.8912000e-003 2.2367000e-002 1.8119840e-001 -9.6662000e-003 1.5707000e-003 1.8326570e-001 1.2747360e-001 3.0329000e-003 1.1785630e-001 -6.2054000e-003 -2.0353700e-002 1.8101010e-001 7.7650000e-004 -3.9665500e-002 1.7576330e-001 1.4782100e-002 -5.3839000e-002 1.6756270e-001 3.3025800e-002 -6.1469700e-002 1.5866010e-001 5.3403200e-002 -6.2506100e-002 1.4958600e-001 6.7731300e-002 -6.3721500e-002 1.3472570e-001 8.4939800e-002 -6.2326800e-002 1.2286770e-001 1.0144660e-001 -6.0760600e-002 1.1056810e-001 1.1830200e-001 -5.6118700e-002 9.7493900e-002 1.3384140e-001 -4.2370800e-002 8.8710200e-002 1.2581260e-001 2.3388900e-002 1.1563750e-001 1.4493190e-001 -2.1005500e-002 7.9512800e-002 1.5141720e-001 2.8114000e-003 5.8260000e-002 1.4860600e-001 2.5647700e-002 5.9476900e-002 1.3950480e-001 4.7435600e-002 6.5188400e-002 1.2578320e-001 6.4592200e-002 7.3203300e-002 1.0800840e-001 7.6859600e-002 8.3739300e-002 8.8304000e-002 8.1243300e-002 9.7491000e-002 7.1535200e-002 8.2324500e-002 1.0914420e-001 5.3428400e-002 8.3806100e-002 1.2123810e-001 3.6553300e-002 8.2574400e-002 1.3575290e-001 1.0933920e-001 2.5246400e-002 1.3022740e-001 1.8527900e-002 7.9145100e-002 1.4690770e-001 1.4510000e-003 7.0241700e-002 1.5698810e-001 -1.2219600e-002 5.7455700e-002 1.6543470e-001 -2.3304800e-002 4.0967600e-002 1.7174900e-001 -3.0854600e-002 2.1538200e-002 1.7539680e-001 -3.2653500e-002 4.5400000e-004 1.7671110e-001 -3.0097900e-002 -2.0808900e-002 1.7504510e-001 -2.2815900e-002 -4.0376100e-002 1.7075300e-001 -1.1293700e-002 -5.6740100e-002 1.6434310e-001 2.9800000e-003 -6.9156800e-002 1.5578240e-001 9.2446700e-002 2.5097500e-002 1.4223590e-001 2.0409500e-002 -7.7402800e-002 1.4570020e-001 3.8428100e-002 -7.9747400e-002 1.3464460e-001 5.5417600e-002 -8.0774600e-002 1.2055250e-001 7.3525300e-002 -7.9024000e-002 1.0825430e-001 9.0433200e-002 -7.6843700e-002 9.7286700e-002 1.0996510e-001 -7.1964200e-002 8.3435700e-002 1.2702670e-001 -5.9874600e-002 7.3315500e-002 1.4044020e-001 -4.1994000e-002 6.5282100e-002 1.4905180e-001 -2.0599600e-002 5.8623900e-002 1.5000260e-001 2.7768000e-003 3.6645800e-002 1.0281170e-001 3.6878200e-002 1.9466680e-001 1.4639840e-001 2.6020600e-002 3.7242300e-002 1.4008190e-001 4.5540200e-002 4.2572500e-002 1.2885510e-001 6.3690600e-002 4.8758000e-002 1.1415840e-001 7.7489900e-002 5.6883000e-002 9.6495600e-002 8.7644300e-002 6.7428400e-002 7.8045100e-002 9.1927900e-002 8.0270200e-002 6.1280000e-002 9.3412900e-002 9.1769400e-002 4.2607000e-002 9.4964900e-002 1.0355130e-001 2.6368100e-002 9.4424700e-002 1.1940690e-001 8.5353000e-003 9.2278000e-002 1.2983270e-001 biosig-2.3.3/biosig4matlab/t501_VisualizeCoupling/plot_coupling.m0000664000175000017500000001716214105434233025167 0ustar schloeglschloeglfunction plot_coupling(data,locs,pars); % usage plot_coupling(data,locs,pars); % makes head-in-head plots % data is an NxN matrix where N is the number of channels % locs is (ideally) an Nx5 matrix: % 1st column: a channel i gets a circle only if locs(i,1)>.5 % if locs is an Mx5 matrix with M2 if isfield(pars,'scale') scal=pars.scale; if length(scal)==1 scal=[-scal scal]; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; end if isfield(pars,'global_size'); global_size=pars.global_size; else global_size=1; end if isfield(pars,'relative_size'); rel_size=pars.relative_size; else rel_size=1; end if isfield(pars,'resolution') resolution=pars.resolution; else resolution=25; end if isfield(pars,'head_right') head_right=pars.head_right; else head_right=0; end if isfield(pars,'head_up') head_up=pars.head_up; else head_up=0; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; resolution=25; global_size=1; rel_size=1; head_right=0; head_up=0; end [n,m]=size(locs); locs_all=locs; [nall,ndum]=size(locs_all); ind2chan=(1:nall)'; [nc,nc]=size(data); if m==5 if nc>n ind2chan=abs(locs(:,1)); end indd=ind2chan(locs(:,1)>.5); locs=locs(locs(:,1)>.5,:); end [n,m]=size(locs); if m==2; locs=[(1:n)',locs,locs]; elseif m==3 locs=[locs,locs(:,2:3)]; elseif m==4 locs=[(1:n)',locs]; end %ind2chan=locs(:,1); locs(:,5)=detrend(locs(:,5),'constant'); %locs(:,4)=detrend(locs(:,4),'constant'); coor=locs(:,4:5); ymin=min(coor(:,1)); ymax=max(coor(:,1)); xmin=max(coor(:,1)); xmax=max(coor(:,1)); %minmin=mindis(coor(:,1),coor(:,2)); [minmin,minmax,meanmin]=mindis(coor(:,1),coor(:,2)); tot_scale=max(abs([xmin,xmax,ymin,ymax]))+minmin/2; tot_scale=tot_scale/1.1; locs(:,2:5)=locs(:,2:5)*.5/tot_scale; meanmin=meanmin*.5/tot_scale; no=zeros(n,1); for i=1:n no(i)=norm(coor(i,:)); end faktor=1/max(no)/2/1.3; %wfaktor=faktor*1.3 wfaktor=meanmin/1.6; wfaktor=wfaktor*global_size; meanx=mean(faktor*locs(:,4)*.85+.45); meany=mean(faktor*locs(:,5)*.85+.45); rad=max(sqrt( (faktor*locs(:,4)*.85+.45-meanx).^2+(faktor*locs(:,5)*.85+.45-meany).^2 )); cirx=(rad*cos((1:1000)*2*pi/1000)+meanx)';ciry=(rad*sin((1:1000)*2*pi/1000)+meany)'; faktor=.75; faktor=faktor*global_size*rel_size; nplot=n; for chan=1:n zp=data(indd(chan),ind2chan)'; %zp=z(ind2chan); subplot(nplot,nplot,n*chan); % set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.070 wfaktor*0.088]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.+.01)+.45 wfaktor wfaktor*.088/.07]); plot_elec_empty_lowres(zp,locs_all(:,2:3),scal,indd(chan),resolution); set(gca,'visible','off'); set(gca,'xTick',[]) set(gca,'yTick',[]) caxis('manual'); caxis(scal); if chan==1 %set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.08 wfaktor*0.08]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.+.01)+.45 wfaktor*1.1 wfaktor*.088/.07]); h1=colorbar; set(h1,'position',[.85 .1 .05 .8]); end end; caxis('manual'); caxis(scal); subplot(nplot,nplot,1); set(gca,'Position',[0.12 0.01 .7/.88 .99]); %set(gca,'Position',[0.12 0.01 1 1]); scalx=1.0; drawhead(meanx+wfaktor/4+head_right,.45+wfaktor/4+head_up,.43,scalx); axis([ 0 1 0 1]); %text(.1,.85,figtitle,'HorizontalAlignment','center'); %title('Titel') set(gca,'visible','off'); %get(h1) %h=colorbar; %set(h,'yticklabel', return; function plot_elec_empty_lowres(z,loc,skal,chan,resolution); x=loc(:,1); y=loc(:,2); xlin = linspace(1.4*min(x),1.4*max(x),resolution); ylin = linspace(1.4*min(y),1.4*max(y),resolution); [X,Y] = meshgrid(xlin,ylin); %Z = griddata(x,y,z,X,Y,'invdist'); Z = griddata(x,y,z,X,Y,'nearest'); % Take data within head rmax=1.1*max(sqrt(x.^2+y.^2)); mask = (sqrt(X.^2+Y.^2) <= rmax); ii = find(mask == 0); Z(ii) = NaN; surface(X,Y,zeros(size(Z)),Z,'edgecolor','none');shading interp; %caxis([ - max(abs(z)) max(abs(z))]); %disp([ - max(abs(z)) max(abs(z))]); %caxis([ -skal skal]); %disp([ -skal skal]); hold on; %plot(x,y,'.k'); axis([-rmax rmax -rmax rmax]); %colorbar; plot(loc(chan,1),loc(chan,2),'.k'); %set(gcf,'color','none'); set(gca,'xTick',[]) set(gca,'yTick',[]) plot(.985*rmax*sin((0:1000)/1000*2*pi), .985*rmax*cos((0:1000)/1000*2*pi),'linewidth',2,'color','k'); %set(gcf,'color','none'); return; function drawhead(x,y,size,scalx); cirx=(x+scalx*size*cos((1:1000)*2*pi/1000) )';ciry=(y+size*sin((1:1000)*2*pi/1000))'; plot(cirx,ciry,'k','linewidth',1); hold on; ndiff=20; plot( [x cirx(250-ndiff) ],[y+1.1*size ciry(250-ndiff)],'k','linewidth',1); plot( [x cirx(250+ndiff) ],[y+1.1*size ciry(250+ndiff)],'k','linewidth',1); return; function [minmin,minmax,meanmin]=mindis(x,y); [n,m]=size(x); minall=zeros(n,1); for i=1:n md=1.e8; for j=1:n if j~=i %dis=max( abs(x(i)-x(j)),abs(y(i)-y(j))); dis=norm([x(i)-x(j),y(i)-y(j)]); if dis1 if isfield(pars,'rot'); rot=pars.rot; else rot=0; end if isfield(pars,'nin'); nin=pars.nin; else nin=ns_ori; end if isfield(pars,'indices'); indices=pars.indices; else indices=[1:ns_ori]'; end if isfield(pars,'circle_shift'); shift_cont=pars.circle_shift; else shift_cont=1; end else rot=0; nin=ns_ori; indices=[1:ns_ori]'; shift_cont=1; end if nin0 loc_phys_sparse=locphys2locphys([[1:ns]',s2d_n]); else loc_phys_sparse=[[1:ns]',s2d_n,s2d_n]; figure; for i=1:ns; text(s2d_n(i,1),s2d_n(i,2),num2str(i)); end axis([-.6 .6 -.6 .6]); end if nin1 if lr==1 locs=[-locs(:,1),locs(:,2)]; end end if nargin>2 if ud==1 locs=[locs(:,1),-locs(:,2)]; end end locs=locs/max(max(abs(locs)))/2; s2d=locs; return; biosig-2.3.3/biosig4matlab/t501_VisualizeCoupling/sphfit.m0000664000175000017500000000356314105434233023606 0ustar schloeglschloeglfunction [center,radius]=sphfit(vc) % SPHFIT fits a sphere to a set of surface points % % input: % vc nx3 matrix, where each row represents the location % of one surface point. vc can have more than 3 columns % (e.g. orientations) - then only the first 3 columns are used % % center 1x3 vector denoting the center % radius scalar denoting the radius % $Id$ % Copyright (C) 2003,2004 Guido Nolte % Adapted by Alois Schloegl % This function is part of the BioSig project % http://biosig.sf.net/ % 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 % of the License, or (at your option) any later version. % vc=vc(:,1:3); [nvc,ndum]=size(vc); center_0=mean(vc); vcx=vc-repmat(center_0,nvc,1); radius_0=mean(sqrt(vcx(:,1).^2+vcx(:,2).^2+vcx(:,3).^2)); alpha=1; err_0=costfun(vc,center_0,radius_0); for k=1:50; [center_new,radius_new]=lm1step(vc,center_0,radius_0,alpha); err_new=costfun(vc,center_new,radius_new); %disp([k,err_0,err_new,center_new,radius_new]); if err_new.5 % if locs is an Mx5 matrix with M2 if isfield(pars,'scale') scal=pars.scale; if length(scal)==1 scal=[-scal scal]; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; end if isfield(pars,'dot_size'); dot_size=pars.dot_size; end if isfield(pars,'global_size'); global_size=pars.global_size; else global_size=1; end if isfield(pars,'relative_size'); rel_size=pars.relative_size; else rel_size=1; end if isfield(pars,'resolution') resolution=pars.resolution; else resolution=25; end if isfield(pars,'head_right') head_right=pars.head_right; else head_right=0; end if isfield(pars,'head_up') head_up=pars.head_up; else head_up=0; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; resolution=25; global_size=1; rel_size=1; head_right=0; head_up=0; end [n,m]=size(locs); locs_all=locs; [nall,ndum]=size(locs_all); ind2chan=(1:nall)'; [nc,nc]=size(data); if m==5 if nc>n ind2chan=abs(locs(:,1)); end indd=ind2chan(locs(:,1)>.5); locs=locs(locs(:,1)>.5,:); end [n,m]=size(locs); if m==2; locs=[(1:n)',locs,locs]; elseif m==3 locs=[locs,locs(:,2:3)]; elseif m==4 locs=[(1:n)',locs]; end %ind2chan=locs(:,1); locs(:,5)=detrend(locs(:,5),'constant'); %locs(:,4)=detrend(locs(:,4),'constant'); coor=locs(:,4:5); ymin=min(coor(:,1)); ymax=max(coor(:,1)); xmin=max(coor(:,1)); xmax=max(coor(:,1)); %minmin=mindis(coor(:,1),coor(:,2)); [minmin,minmax,meanmin]=mindis(coor(:,1),coor(:,2)); tot_scale=max(abs([xmin,xmax,ymin,ymax]))+minmin/2; tot_scale=tot_scale/1.1; locs(:,2:5)=locs(:,2:5)*.5/tot_scale; meanmin=meanmin*.5/tot_scale; no=zeros(n,1); for i=1:n no(i)=norm(coor(i,:)); end faktor=1/max(no)/2/1.3; %wfaktor=faktor*1.3 wfaktor=meanmin/1.6; wfaktor=wfaktor*global_size; meanx=mean(faktor*locs(:,4)*.85+.45); meany=mean(faktor*locs(:,5)*.85+.45); rad=max(sqrt( (faktor*locs(:,4)*.85+.45-meanx).^2+(faktor*locs(:,5)*.85+.45-meany).^2 )); cirx=(rad*cos((1:1000)*2*pi/1000)+meanx)';ciry=(rad*sin((1:1000)*2*pi/1000)+meany)'; faktor=.75; faktor=faktor*global_size*rel_size; nplot=n; for chan=1:n zp=data(indd(chan),ind2chan)'; %zp=z(ind2chan); subplot(nplot,nplot,n*chan); % set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.070 wfaktor*0.088]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor wfaktor*.088/.07]); %plot_elec_empty_lowres(zp,locs_all(:,2:3),scal,indd(chan),resolution); plot_dots(zp,locs_all(:,2:3),scal,indd(chan),dot_size); set(gca,'visible','off'); set(gca,'xTick',[]) set(gca,'yTick',[]) caxis('manual'); caxis(scal); if chan==1 %set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.08 wfaktor*0.08]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*1.1 wfaktor*.088/.07]); h1=colorbar; set(h1,'position',[.85 .1 .05 .8]); end end; caxis('manual'); caxis(scal); subplot(nplot,nplot,1); set(gca,'Position',[0.12 0.01 .7/.88 .99]); %set(gca,'Position',[0.12 0.01 1 1]); scalx=1.0; drawhead(meanx+wfaktor/4+head_right,.45+wfaktor/4+head_up,.43,scalx); axis([ 0 1 0 1]); %text(.1,.85,figtitle,'HorizontalAlignment','center'); %title('Titel') set(gca,'visible','off'); %get(h1) %h=colorbar; %set(h,'yticklabel', return; function plot_elec_empty_lowres(z,loc,skal,chan,resolution); x=loc(:,1); y=loc(:,2); xlin = linspace(1.4*min(x),1.4*max(x),resolution); ylin = linspace(1.4*min(y),1.4*max(y),resolution); [X,Y] = meshgrid(xlin,ylin); Z = griddata(x,y,z,X,Y,'invdist'); %Z = griddata(x,y,z,X,Y,'nearest'); % Take data within head rmax=1.1*max(sqrt(x.^2+y.^2)); mask = (sqrt(X.^2+Y.^2) <= rmax); ii = find(mask == 0); Z(ii) = NaN; surface(X,Y,zeros(size(Z)),Z,'edgecolor','none');shading interp; %caxis([ - max(abs(z)) max(abs(z))]); %disp([ - max(abs(z)) max(abs(z))]); %caxis([ -skal skal]); %disp([ -skal skal]); hold on; %plot(x,y,'.k'); axis([-rmax rmax -rmax rmax]); %colorbar; plot(loc(chan,1),loc(chan,2),'.k'); %set(gcf,'color','none'); set(gca,'xTick',[]) set(gca,'yTick',[]) plot(.985*rmax*sin((0:1000)/1000*2*pi), .985*rmax*cos((0:1000)/1000*2*pi),'linewidth',2,'color','k'); %set(gcf,'color','none'); return; function plot_dots(z,loc,skal,chan,dot_size); x=loc(:,1); y=loc(:,2); xlin = linspace(1.4*min(x),1.4*max(x),resolution); ylin = linspace(1.4*min(y),1.4*max(y),resolution); [X,Y] = meshgrid(xlin,ylin); Z = griddata(x,y,z,X,Y,'invdist'); %Z = griddata(x,y,z,X,Y,'nearest'); % Take data within head rmax=1.1*max(sqrt(x.^2+y.^2)); mask = (sqrt(X.^2+Y.^2) <= rmax); ii = find(mask == 0); Z(ii) = NaN; ndot=length(x); % for i=1:ndot % plot(x(i),y(i), % surface(X,Y,zeros(size(Z)),Z,'edgecolor','none'); shading interp; %caxis([ - max(abs(z)) max(abs(z))]); %disp([ - max(abs(z)) max(abs(z))]); %caxis([ -skal skal]); %disp([ -skal skal]); hold on; %plot(x,y,'.k'); axis([-rmax rmax -rmax rmax]); %colorbar; plot(loc(chan,1),loc(chan,2),'.k'); %set(gcf,'color','none'); set(gca,'xTick',[]) set(gca,'yTick',[]) plot(.985*rmax*sin((0:1000)/1000*2*pi), .985*rmax*cos((0:1000)/1000*2*pi),'linewidth',2,'color','k'); %set(gcf,'color','none'); return; function drawhead(x,y,size,scalx); cirx=(x+scalx*size*cos((1:1000)*2*pi/1000) )';ciry=(y+size*sin((1:1000)*2*pi/1000))'; plot(cirx,ciry,'k','linewidth',1); hold on; ndiff=20; plot( [x cirx(250-ndiff) ],[y+1.1*size ciry(250-ndiff)],'k','linewidth',1); plot( [x cirx(250+ndiff) ],[y+1.1*size ciry(250+ndiff)],'k','linewidth',1); return; function [minmin,minmax,meanmin]=mindis(x,y); [n,m]=size(x); minall=zeros(n,1); for i=1:n md=1.e8; for j=1:n if j~=i %dis=max( abs(x(i)-x(j)),abs(y(i)-y(j))); dis=norm([x(i)-x(j),y(i)-y(j)]); if dis.5 % if locs is an Mx5 matrix with M2 if isfield(pars,'scale') scal=pars.scale; if length(scal)==1 scal=[-scal scal]; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; end if isfield(pars,'global_size'); global_size=pars.global_size; else global_size=1; end if isfield(pars,'relative_size'); rel_size=pars.relative_size; else rel_size=1; end if isfield(pars,'resolution') resolution=pars.resolution; else resolution=25; end if isfield(pars,'head_right') head_right=pars.head_right; else head_right=0; end if isfield(pars,'head_up') head_up=pars.head_up; else head_up=0; end else scal=[-max(max(abs(data))),max(max(abs(data)))]; resolution=25; global_size=1; rel_size=1; head_right=0; head_up=0; end [n,m]=size(locs); locs_all=locs; [nall,ndum]=size(locs_all); ind2chan=(1:nall)'; [nc,nc]=size(data); if m==5 if nc>n ind2chan=abs(locs(:,1)); end indd=ind2chan(locs(:,1)>.5); locs=locs(locs(:,1)>.5,:); end [n,m]=size(locs); if m==2; locs=[(1:n)',locs,locs]; elseif m==3 locs=[locs,locs(:,2:3)]; elseif m==4 locs=[(1:n)',locs]; end %ind2chan=locs(:,1); locs(:,5)=detrend(locs(:,5),'constant'); %locs(:,4)=detrend(locs(:,4),'constant'); coor=locs(:,4:5); ymin=min(coor(:,1)); ymax=max(coor(:,1)); xmin=max(coor(:,1)); xmax=max(coor(:,1)); %minmin=mindis(coor(:,1),coor(:,2)); [minmin,minmax,meanmin]=mindis(coor(:,1),coor(:,2)); tot_scale=max(abs([xmin,xmax,ymin,ymax]))+minmin/2; tot_scale=tot_scale/1.1; locs(:,2:5)=locs(:,2:5)*.5/tot_scale; meanmin=meanmin*.5/tot_scale; no=zeros(n,1); for i=1:n no(i)=norm(coor(i,:)); end faktor=1/max(no)/2/1.3; %wfaktor=faktor*1.3 wfaktor=meanmin/1.6; wfaktor=wfaktor*global_size; meanx=mean(faktor*locs(:,4)*.85+.45); meany=mean(faktor*locs(:,5)*.85+.45); rad=max(sqrt( (faktor*locs(:,4)*.85+.45-meanx).^2+(faktor*locs(:,5)*.85+.45-meany).^2 )); cirx=(rad*cos((1:1000)*2*pi/1000)+meanx)';ciry=(rad*sin((1:1000)*2*pi/1000)+meany)'; faktor=.75; faktor=faktor*global_size*rel_size; nplot=n; for chan=1:n zp=data(indd(chan),ind2chan)'; %zp=z(ind2chan); %subplot(nplot,nplot,n*chan); subplot(nplot,nplot,n); % set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.070 wfaktor*0.088]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.+.01)+.45 wfaktor wfaktor*.088/.07]); plot_elec_empty_lowres(zp,locs_all(:,2:3),scal,indd(chan),resolution); set(gca,'visible','off'); set(gca,'xTick',[]) set(gca,'yTick',[]) caxis('manual'); caxis(scal); if chan==1 %set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.-.05)+.45 wfaktor*0.08 wfaktor*0.08]); set(gca,'Position',[faktor*locs(chan,4)*.85+.45 faktor*(locs(chan,5)*1.+.01)+.45 wfaktor*1.1 wfaktor*.088/.07]); h1=colorbar; set(h1,'position',[.85 .1 .05 .8]); end end; caxis('manual'); caxis(scal); subplot(nplot,nplot,1); set(gca,'Position',[0.12 0.01 .7/.88 .99]); %set(gca,'Position',[0.12 0.01 1 1]); scalx=1.0; drawhead(meanx+wfaktor/4+head_right,.45+wfaktor/4+head_up,.43,scalx); axis([ 0 1 0 1]); %text(.1,.85,figtitle,'HorizontalAlignment','center'); %title('Titel') set(gca,'visible','off'); %get(h1) %h=colorbar; %set(h,'yticklabel', return; function plot_elec_empty_lowres(z,loc,skal,chan,resolution); x=loc(:,1); y=loc(:,2); xlin = linspace(1.4*min(x),1.4*max(x),resolution); ylin = linspace(1.4*min(y),1.4*max(y),resolution); [X,Y] = meshgrid(xlin,ylin); Z = griddata(x,y,z,X,Y,'invdist'); %Z = griddata(x,y,z,X,Y,'nearest'); % Take data within head rmax=1.1*max(sqrt(x.^2+y.^2)); mask = (sqrt(X.^2+Y.^2) <= rmax); ii = find(mask == 0); Z(ii) = NaN; surface(X,Y,zeros(size(Z)),Z,'edgecolor','none');shading interp; %caxis([ - max(abs(z)) max(abs(z))]); %disp([ - max(abs(z)) max(abs(z))]); %caxis([ -skal skal]); %disp([ -skal skal]); hold on; %plot(x,y,'.k'); axis([-rmax rmax -rmax rmax]); %colorbar; plot(loc(chan,1),loc(chan,2),'.k'); %set(gcf,'color','none'); set(gca,'xTick',[]) set(gca,'yTick',[]) plot(.985*rmax*sin((0:1000)/1000*2*pi), .985*rmax*cos((0:1000)/1000*2*pi),'linewidth',2,'color','k'); %set(gcf,'color','none'); return; function drawhead(x,y,size,scalx); cirx=(x+scalx*size*cos((1:1000)*2*pi/1000) )';ciry=(y+size*sin((1:1000)*2*pi/1000))'; plot(cirx,ciry,'k','linewidth',1); hold on; ndiff=20; plot( [x cirx(250-ndiff) ],[y+1.1*size ciry(250-ndiff)],'k','linewidth',1); plot( [x cirx(250+ndiff) ],[y+1.1*size ciry(250+ndiff)],'k','linewidth',1); return; function [minmin,minmax,meanmin]=mindis(x,y); [n,m]=size(x); minall=zeros(n,1); for i=1:n md=1.e8; for j=1:n if j~=i %dis=max( abs(x(i)-x(j)),abs(y(i)-y(j))); dis=norm([x(i)-x(j),y(i)-y(j)]); if dis.01 xn(i)=x(i)+step*fallx; end if abs(y(i))>.01 yn(i)=y(i)+step*fally; end end x=xn;y=yn; return; function [fx,fy]=force(x1,x2,y1,y2,d,mag); dis=max(abs(x1-x2),abs(y1-y2)); dis=norm([x1-x2,y1-y2]); diffvec=[x2-x1;y2-y1];diffvec=diffvec/norm(diffvec); fx=0;fy=0; if dis2 if isfield(pars,'scale') scal=pars.scale; if length(scal)==1 scal=[-scal scal]; end else scal=[-max(max(abs(z))),max(max(abs(z)))]; end if isfield(pars,'figkont') figkont=pars.figkont; end else scal=[-max(max(abs(z))),max(max(abs(z)))]; end [n,m]=size(loc); if m==2; x=loc(:,1); y=loc(:,2); else; x=loc(:,2); y=loc(:,3); end xlin = linspace(1.4*min(x),1.4*max(x),250); ylin = linspace(1.4*min(y),1.4*max(y),250); [X,Y] = meshgrid(xlin,ylin); Z = griddata(x,y,z,X,Y,'invdist'); %Z = griddata(x,y,z,X,Y,'nearest'); % Take data within head rmax=1.02*max(sqrt(x.^2+y.^2)); mask = (sqrt(X.^2+Y.^2) <= rmax); ii = find(mask == 0); Z(ii) = NaN; surface(X,Y,zeros(size(Z)),Z,'edgecolor','none');shading interp; %caxis([ - max(abs(z)) max(abs(z))]); caxis(scal); hold on; plot(x,y,'.k','markersize',2); %meanx=mean(loc(:,2)*.85+.45); %meany=mean(loc(:,3)*.85+.45); scalx=1; drawhead(0,.0,rmax,scalx); set(gca,'visible','off'); %axis([-1.2*rmax 1.2*rmax -1.0*rmax 1.4*rmax]); if figkont==1 axis([-1.2*rmax 1.2*rmax -1.0*rmax 1.4*rmax]); h=colorbar;set(h,'fontweight','bold') else axis([-1.4*rmax 1.4*rmax -1.0*rmax 1.4*rmax]); end %plot(.985*rmax*sin((0:1000)/1000*2*pi), .985*rmax*cos((0:1000)/1000*2*pi),'linewidth',2,'color','k'); return; function drawhead(x,y,size,scalx); cirx=(x+scalx*size*cos((1:1000)*2*pi/1000) )';ciry=(y+size*sin((1:1000)*2*pi/1000))'; plot(cirx,ciry,'k','linewidth',1); hold on; ndiff=20; plot( [x cirx(250-ndiff) ],[y+1.1*size ciry(250-ndiff)],'k','linewidth',1); plot( [x cirx(250+ndiff) ],[y+1.1*size ciry(250+ndiff)],'k','linewidth',1); return; biosig-2.3.3/biosig4matlab/install.m0000664000175000017500000001256214105434233017531 0ustar schloeglschloegl% BIOSIG runs on Matlab and Octave. % This is a script installing all components in an automatically. % % 1) extract the files and % 2) save the BIOSIG files in % 3) start matlab % cd % biosig_installer % 4) For a permanent installation, save the default path with % PATH2RC or % PATHTOOL and click on the "SAVE" button. % 5) For removing the toolbox % remove the path to % HOME/tsa % HOME/NaN % HOME/BIOSIG/ and all its subdirectories % % NOTE: by default also the NaN-toolbox is installed - % - a statistical toolbox for handling missing values - which % changes the behaviour of some standard functions. For more % information see NaN/README.TXT . In case you do not want this, % you can excluded the path to NaN/*. The BIOSIG tools will still % work, but does not support the handling of NaN's. % Copyright (C) 2003-2010,2013,2015,2020 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ if ~exist('BIOSIG_MATLAB_PATH','var') BIOSIG_MATLAB_PATH = getenv('BIOSIG_MATLAB_PATH'); end if isempty(BIOSIG_MATLAB_PATH) if exist('./t200_FileAccess','dir') BIOSIG_MATLAB_PATH = pwd; elseif exist('./biosig/t200_FileAccess','dir') BIOSIG_MATLAB_PATH = fullfile(pwd,'biosig'); else fprintf(2,'Error: biosig subdirectories not found\n'); return; end; end; subdirs = {'doc', 't200_FileAccess', 't210_Events', 't250_ArtifactPreProcessingQualityControl', 't300_FeatureExtraction', 't330_StimFit', 't340_MachineLearningOptimalDetection', 't400_Classification', 't450_MultipleTestStatistic', 't490_EvaluationCriteria', 't500_Visualization', 't501_VisualizeCoupling'}; for k = 1:length(subdirs) addpath(fullfile(BIOSIG_MATLAB_PATH,subdirs{k})) end if ~exist('OCTAVE_VERSION','builtin'), %% Matlab path([BIOSIG_MATLAB_PATH,'/viewer'],path); % viewer path([BIOSIG_MATLAB_PATH,'/viewer/utils'],path); % viewer path([BIOSIG_MATLAB_PATH,'/viewer/help'],path); % viewer path([BIOSIG_MATLAB_PATH,'/tsa'],path); % Time Series Analysis path([BIOSIG_MATLAB_PATH,'/tsa/inst'],path); % Time Series Analysis path([BIOSIG_MATLAB_PATH,'/tsa/src'],path); % Time Series Analysis if exist([BIOSIG_MATLAB_PATH,'/freetb4matlab'],'dir') path(path,[BIOSIG_MATLAB_PATH,'/freetb4matlab/oct2mat']); % some basic functions used in Octave but not available in Matlab path(path,[BIOSIG_MATLAB_PATH,'/freetb4matlab/general']); % some basic functions used in Octave but not available in Matlab end fprintf(1,'\nThe NaN-toolbox is going to be installed\n'); fprintf(1,'The NaN-toolbox is a powerful statistical and machine learning toolbox, \nwhich is also able to handle data with missing values.\n'); fprintf(1,'Typically, samples with NaNs are simply skipped.\n'); fprintf(1,'If your data contains NaNs, installing the NaN-toolbox will \nmodify the following functions in order to ignore NaNs:\n'); fprintf(1,'\tcor, corrcoef, cov, geomean, harmmean, iqr, kurtosis, mad, mahal, mean, \n\tmedian, moment, quantile, prctile, skewness, std, var.\n'); fprintf(1,'If you do not have NaN, the behaviour is the same; if you have NaNs in your data, you will get more often a reasonable result instead of a NaN-result.\n'); fprintf(1,'If you do not want this behaviour, remove the directory NaN/inst from your path.\n'); fprintf(1,'Moreover, NaN-provides also a number of other useful functions. Installing NaN-toolbox is recommended.\n\n'); %% add NaN-toolbox: a toolbox for statistics and machine learning for data with Missing Values path([BIOSIG_MATLAB_PATH,'/NaN'],path); %% support both types of directory structure if exist([BIOSIG_MATLAB_PATH,'/NaN/inst'],'dir') path([BIOSIG_MATLAB_PATH,'/NaN/inst'],path); end; if exist([BIOSIG_MATLAB_PATH,'/NaN/src'],'dir') path([BIOSIG_MATLAB_PATH,'/NaN/src'],path); end end tmp_biosig_helper_directory = pwd; try if 0, % ~exist('OCTAVE_VERSION','builtin') && ~ispc mex -setup end; if ~ispc && exist([BIOSIG_MATLAB_PATH,'/NaN/src'],'dir'); cd([BIOSIG_MATLAB_PATH,'/NaN/src']); make end; catch fprintf(1,'Compilation of Mex-files failed - precompiled binary mex-files are used instead\n'); end; cd(tmp_biosig_helper_directory); clear tmp_biosig_helper_directory; try x = betainv(.5, 1, 2); catch path(path,[BIOSIG_MATLAB_PATH,'/freetb4matlab/statistics/distributions']); % Octave-Forge statistics toolbox converted with freetb4matlab path(path,[BIOSIG_MATLAB_PATH,'/freetb4matlab/statistics/tests']); % Octave-Forge statistics toolbox converted with freetb4matlab disp('statistics/distribution toolbox (betainv) from freetb4matlab added'); end; try x = mod(1:10,3)'-1; [Pxx,f] = periodogram(x, [], 10, 100); [b,a] = butter(5, [.08,.096]); catch path(path,[BIOSIG_MATLAB_PATH,'/freetb4matlab/signal'],'-end'); % Octave-Forge signal processing toolbox converted with freetb4matlab disp('signal processing toolbox (butter,periodogram) from freetb4matlab added'); end; % test of installation fun = {'butter','periodogram','betainv'}; for k = 1:length(fun), x = which(fun{k}); if isempty(x) || strcmp(x,'undefined'), fprintf(2,'Function %s is missing\n',upper(fun{k})); end; end; disp('BIOSIG-toolbox activated'); disp(' If you want BIOSIG permanently installed, use the command SAVEPATH.') disp(' or use PATHTOOL to select and deselect certain components.') biosig-2.3.3/biosig4matlab/t310_ERDSMaps/0000775000175000017500000000000014105434233020024 5ustar schloeglschloeglbiosig-2.3.3/biosig4matlab/t310_ERDSMaps/prepareData.m0000664000175000017500000000426314105434233022437 0ustar schloeglschloegl% Template for using the EEG analysis toolbox. % % This batch file serves as a template for the EEG analysis toolbox. It shows % examples of how to call specific functions, such as plotting ERDS maps. Just % copy and paste the commands you need into your own batch file and adapt the % parameters. For help on specific commands, see the corresponding help texts. % Copyright by Clemens Brunner % $Revision: 0.3 $ $Date: 10/09/2008 15:10:29 $ % E-Mail: clemens.brunner@tugraz.at % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. %% Load data name = 'sample'; path_name = './'; data = '*.gdf'; channels = 0; % 0 ... All channels classes = [1]; % [] ... All classes method = 'bp'; % 'bp' or 'fft' refmethod = 'classic'; % 'classic' or 'trial' [s, h] = sload([path_name, data], channels, 'OVERFLOWDETECTION:OFF'); s(isnan(s)) = 0; %% ERDS maps r1 = calcErdsMap(s, h, [0, 0.05, 5], [5, 40], 'method', method, 'class', classes, 'ref', [0.25, 0.75], 'f_bandwidths', [2], 'f_steps', [1], 'sig', 'boxcox', 'lambda', 1, 'alpha', 0.05, 'heading', name, 'montage', [1 1 1 1], 'cue', 3, 'refmethod', refmethod); plotErdsMap(r1); %% Average/variance r2 = calcAveVar(s, h, [0, 0.05, 8], 'class', classes, 'heading', name, 'montage', [1 1 1 1], 'cue', 3); plotAveVar(r2); %% Combination of ERDS maps and average/variance r3 = calcCombiMap(s, h, [0, 0.05, 8], [5, 18, 40], 'method', method, 'class', classes, 'ref', [0.5, 1.5], 'f_bandwidths', [2, 4], 'f_steps', [1, 1], 'sig', 'boxcox', 'lambda', 1, 'alpha', 0.05, 'heading', name, 'montage', [1 1 1 1], 'cue', 3); plotCombiMap(r3);biosig-2.3.3/biosig4matlab/t310_ERDSMaps/calcErdsMap.m0000664000175000017500000002704314105434233022366 0ustar schloeglschloeglfunction r = calcErdsMap(s, h, t, f_borders, varargin) % Calculates time-frequency (ERDS) maps. % % This function calculates time-frequency (ERDS) maps by using either bandpower, % FFT or wavelets to estimate the power in specific frequency bands. Maps can be % calculated for more than one channel at once. % % Usage: % r = calcErdsMap(s, h, t, f_borders); % % Input parameters: % s ... Input signal (as obtained by sload) . % h ... Header structure (as obtained by sload) <1x1 struct>. Only the % following fields are required: h.SampleRate, h.TRIG, % h.Classlabel. % t ... Start point, time resolution and end point within a trial (in % s) <1x3>. If the second value is 0, the time resolution % corresponds to 1/fs. % Example: % t = [0, 0.25, 8]; % This corresponds to a trial that starts 0s after the trial % start event and lasts until second 8. 4 values per second % are calculated. % f_borders ... Frequency borders (in Hz) <1xF>. Contains the borders of the % frequency bands and can be used with the optional parameters % 'f_bandwidths' and 'f_steps' (see below). % Examples: % f_borders = [6, 30]; % The maps are calculated from 6Hz to 30Hz with the default % bandwidth and in the default frequency step size. % % f_borders = [4, 12, 20, 40]; % The maps are calculated for the segments 4-12Hz, 12-20Hz, % and 20-40Hz with the default bandwidths and step sizes. % % Optional input parameters (variable argument list): % 'method' ... Calculation method . User one of the following % methods: 'bp', 'fft', 'wavelet'. % Default: 'bp'. % 'f_bandwidths' ... Bandwidths for the segments specified in f_borders (in % Hz) <1xF-1>. % Default: 2Hz in all segments. % 'f_steps' ... Frequency step sizes for the segments specified in % f_borders (in Hz) <1xF-1>. % Default: 1Hz in all segments. % 'class' ... List of classes used in the calculation <1xM>. % Default: all available classes are used. % 'ref' ... Reference interval (in s) <1x2>. % Default: the whole trial is used as reference. % 'submean' ... Subtract the mean signal to suppress evoked components % <1x1 logical>. % Default: true. % 'sig' ... Method to calculate the significance . User one % of the following methods: 'boot', 'boxcox' or 'none'. % Default: 'none'. % 'lambda' ... Parameter of the Box-Cox transform <1x1>. If lambda is 0, % the transform is a log-transform. % Default: 0. % 'alpha' ... Significance level <1x1>. If 'sig' is set to 'none', this % value is ignored. % Default: 0.01. % 'heading' ... Heading of the plot . % Default: No heading is used. % 'montage' ... Topographic layout of channels . This matrix % consists of zeros and ones. The channels are arranged in % N rows and M columns on the plot, and they are located % where the values of the matrix are equal to 1. % Default: A rectangular layout is used. % 'cue' ... Draws a vertical line at the location of the cue (in s) % <1x1>. % Default: No cue is drawn. % 'wide_trials' ... Use samples before and after the trial definition to get % rid of border effects when using the FFT method % <1x1 logical>. Note that samples before the beginning of % the first and after the end of the last trial are % required. % Default: true. % 'refmethod' ... Calculation mode . 'classic' uses the classical % approach with an averaged reference interval. 'trial' % uses an individual reference for each trial. 'absolute' % does not use references, but calculates bandpower maps % instead. % Default: 'classic'. % % Output parameter: % r ... Structure containing the results <1x1 struct>. % Copyright by Clemens Brunner % $Revision: 0.99 $ $Date: 10/29/2009 13:13:00 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.99: Added new calculation mode that uses an individual reference for each % trial (right now only working with BP method). % 0.91: Add 'wide_trials' option for FFT maps. % 0.90: Clean up code, move unnecessary parameters to plot function. Enhance % functionality such as the support for different spacings in multiple % frequency bands. % 0.80: Complete rewrite (make this function a wrapper for bandpower, FFT, and % wavelet maps). % 0.70: Implement all optional arguments as a variable argument list. % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if (nargin < 1) error('No input signal specified.'); end; if (nargin < 2) error('No header structure specified.'); end; if (nargin < 3) error('Trial timing definition not specified (start, time resolution, end).'); end; if (nargin < 4) error('Frequency definition not specified.'); end; if length(t) == 2 % If only start and end time are provided, use full resolution t = [t(1), 0, t(2)]; end; % Default parameters, can be overwritten by varargin method = 'bp'; % Use bandpower method to calculate the maps f_bandwidths = 2 * ones(1, length(f_borders) - 1); % Use 2Hz bands for all segments f_steps = ones(1, length(f_borders) - 1); % Use step size of 1Hz for all segments class = []; % All classes are used in the calculation ref = [t(1), t(3)]; % Take the whole trial as reference submean = true; % Subtract mean before calculation sig = 'none'; % No significance test alpha = 0.01; % Default significance level of 1% lambda = 0; % Default Box-Cox transform: log transform heading = []; % Default heading montage = []; % Default montage cue = []; % Default do not draw cue wide_trials = true; % Default use additional samples outside of trial for FFT method refmethod = 'classic'; warning('The parameter "refmethod" is currently only working with the BP method.'); % Overwriting default values with optional input parameters if ~isempty(varargin) % Are there optional parameters available? k = 1; while k <= length(varargin) if strcmp(varargin{k}, 'method') method = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'f_bandwidths') f_bandwidths = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'f_steps') f_steps = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'class') class = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'ref') ref = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'submean') submean = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'sig') sig = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'lambda') lambda = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'alpha') alpha = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'heading') heading = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'montage') montage = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'cue') cue = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'wide_trials') wide_trials = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'refmethod') refmethod = varargin{k + 1}; k = k + 2; else % Ignore unknown parameters k = k + 2; end; end; end; if isempty(class) class = unique(h.Classlabel); end; fs = h.SampleRate; % Test if the input frequency range makes sense if f_borders(1) < 0 error('Starting frequency (%d) cannot be negative.', f_borders(1)); end; if f_borders(end) > fs/2 error('End frequency (%d) must be smaller than or equal to the Nyquist frequency (%d).', f_borders(end), fs/2); end; if ~issorted(f_borders) error('Frequencies must be monotonically increasing.'); end; if length(f_bandwidths) ~= length(f_borders) - 1 error('The number of bandwidths is incorrect.'); end; if length(f_steps) ~= length(f_borders) - 1 error('The number of frequency steps is incorrect.'); end; % Test if the input start and end values make sense if h.TRIG(1) + t(1)*fs < 0 error('Not enough data before first trial available.'); end; if h.TRIG(end)+t(3)*fs > size(s,1) error('Not enough data after the last trial available.'); end; if t(3) <= t(1) error('Trial end point must be greater than starting point.'); end; % Test if the reference interval is within the trial time window if ref(1) < t(1) || ref(2) > t(3) error('Reference interval must be within the trial time window.') end; switch lower(method) case 'bp' r = calcErdsMapBP(s, h, t, f_borders, f_bandwidths, f_steps, class, ref, submean, sig, lambda, alpha, refmethod); case 'fft' r = calcErdsMapFFT(s, h, t, f_borders, f_bandwidths, f_steps, class, ref, submean, sig, lambda, alpha, wide_trials); case 'wavelet' error('The wavelet method has not been implemented yet.'); otherwise error('Unknown calculation method %s.', method); end; r.f_borders = f_borders; r.f_bandwidths = f_bandwidths; r.f_steps = f_steps; % Create time vector if t(2) ~= 0 r.t_plot = t(1):t(2):t(3); else % Full time resolution r.t_plot = t(1):1/fs:t(3); end; r.t = t; r.fs = fs; if isfield(h, 'FILE') if isfield(h.FILE, 'Name') && isfield(h.FILE, 'Ext') if length(h.FILE) > 1 for k = 1:length(h.FILE) r.fname{k} = [h.FILE(k).Name, '.', h.FILE(k).Ext]; end; else r.fname = [h.FILE.Name, '.', h.FILE.Ext]; end; end; end; r.date_calc = datestr(clock); if isfield(h, 'T0') % Recording date r.date_rec = datestr(h.T0); end; r.class = class; r.ref = ref; r.submean = submean; r.sig = sig; r.alpha = alpha; r.lambda = lambda; if ~isempty(heading) r.heading = heading; end; if ~isempty(class) r.classes = class; else r.classes = unique(h.Classlabel); end; if ~isempty(montage) r.montage = montage; end; if ~isempty(cue) r.cue = cue; end; r.ERDS_method = method;biosig-2.3.3/biosig4matlab/t310_ERDSMaps/calcCombiMap.m0000664000175000017500000001760514105434233022525 0ustar schloeglschloeglfunction r = calcCombiMap(s, h, t, f_borders, varargin) % Calculates time-frequency (ERDS) maps. % % This function calculates time-frequency (ERDS) maps by using either bandpower, % FFT or wavelets to estimate the power in specific frequency bands. Maps can be % calculated for more than one channel at once. % % Usage: % r = calcErdsMap(s, h, t, f_borders); % % Input parameters: % s ... Input signal (as obtained by sload) . % h ... Header structure (as obtained by sload) <1x1 struct>. Only the % following fields are required: h.SampleRate, h.TRIG, % h.Classlabel. % t ... Start point, time resolution and end point within a trial (in % s) <1x3>. If the second value is 0, the time resolution % corresponds to 1/fs. % Example: % t = [0, 0.25, 8]; % This corresponds to a trial that starts 0s after the trial % start event and lasts until second 8. 4 values per second % are calculated. % f_borders ... Frequency borders (in Hz) <1xF>. Contains the borders of the % frequency bands and can be used with the optional parameters % 'f_bandwidths' and 'f_steps' (see below). % Examples: % f_borders = [6, 30]; % The maps are calculated from 6Hz to 30Hz with the default % bandwidth and in the default frequency step size. % % f_borders = [4, 12, 20, 40]; % The maps are calculated for the segments 4-12Hz, 12-20Hz, % and 20-40Hz with the default bandwidths and step sizes. % % Optional input parameters (variable argument list): % 'method' ... Calculation method . User one of the following % methods: 'bp', 'fft', 'wavelet'. % Default: 'bp'. % 'f_bandwidths' ... Bandwidths for the segments specified in f_borders (in % Hz) <1xF-1>. % Default: 2Hz in all segments. % 'f_steps' ... Frequency step sizes for the segments specified in % f_borders (in Hz) <1xF-1>. % Default: 1Hz in all segments. % 'class' ... List of classes used in the calculation <1xM>. % Default: all available classes are used. % 'ref' ... Reference interval (in s) <1x2>. % Default: the whole trial is used as reference. % 'submean' ... Subtract the mean signal to suppress evoked components % <1x1 logical>. % Default: true. % 'sig' ... Method to calculate the significance . User one % of the following methods: 'boot', 'boxcox' or 'none'. % Default: 'none'. % 'lambda' ... Parameter of the Box-Cox transform <1x1>. If lambda is 0, % the transform is a log-transform. % Default: 0. % 'alpha' ... Significance level <1x1>. If 'sig' is set to 'none', this % value is ignored. % Default: 0.01. % 'heading' ... Heading of the plot . % Default: No heading is used. % 'montage' ... Topographic layout of channels . This matrix % consists of zeros and ones. The channels are arranged in % N rows and M columns on the plot, and they are located % where the values of the matrix are equal to 1. % Default: A rectangular layout is used. % 'cue' ... Draws a vertical line at the location of the cue (in s) % <1x1>. % Default: No cue is drawn. % % Output parameter: % r ... Structure containing the results <1x1 struct>. % Copyright by Clemens Brunner, Christoph Nausner % $Revision: 0.9 $ $Date: 10/22/2008 11:23:00 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.9: Clean up code, move unnecessary parameters to plot function. Enhance % functionality such as the support for different spacings in multiple % frequency bands. % 0.8: Complete rewrite (make this function a wrapper for bandpower, FFT, and % wavelet maps) % 0.7: Implement all optional arguments as a variable argument list % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if (nargin < 1) error('No input signal specified.'); end; if (nargin < 2) error('No header structure specified.'); end; if (nargin < 3) error('Trial timing definition not specified (start, time resolution, end).'); end; if (nargin < 4) error('Frequency definition not specified.'); end; % if length(t) == 2 % If only start and end time are provided, use full resolution % t = [t(1), 0, t(2)]; % end; % % % Default parameters, can be overwritten by varargin % method = 'bp'; % Use bandpower method to calculate the maps % f_bandwidths = 2 * ones(1, length(f_borders) - 1); % Use 2Hz bands for all segments % f_steps = ones(1, length(f_borders) - 1); % Use step size of 1Hz for all segments % class = []; % All classes are used in the calculation % ref = [t(1), t(3)]; % Take the whole trial as reference % submean = true; % Subtract mean before calculation % sig = 'none'; % No significance test % alpha = 0.01; % Default significance level of 1% % lambda = 0; % Default Box-Cox transform: log transform % heading = []; % Default heading % montage = []; % Default montage % cue = []; % Default do not draw cue % % % Overwriting default values with optional input parameters % if ~isempty(varargin) % Are there optional parameters available? % k = 1; % while k <= length(varargin) % if strcmp(varargin{k}, 'method') % method = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'f_bandwidths') % f_bandwidths = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'f_steps') % f_steps = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'class') % class = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'ref') % ref = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'submean') % submean = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'sig') % sig = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'lambda') % lambda = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'alpha') % alpha = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'heading') % heading = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'montage') % montage = varargin{k + 1}; % k = k + 2; % elseif strcmp(varargin{k}, 'cue') % cue = varargin{k + 1}; % k = k + 2; % else % Unknown parameter % error('Unknown parameter %s.', varargin{k}); % end; % end; % end; r1 = calcErdsMap(s, h, t, f_borders, varargin{:}); r2 = calcAveVar(s, h, t, varargin{:}); r1.AveVar = r2.AveVar; r = r1;biosig-2.3.3/biosig4matlab/t310_ERDSMaps/plotErdsMap.m0000664000175000017500000002252114105434233022436 0ustar schloeglschloeglfunction plotErdsMap(r, varargin) % Displays time-frequency (ERDS) maps. % % This function plots ERDS maps as calculated by calcErdsMap.m. % % Usage: % plotErdsMap(r); % % Input parameters: % r ... Input structure calculated with calcErdsMap. % % Optional input parameters (variable argument list): % 't_range' ... Time range to plot <1x2>. Specify start and end points within a % trial (in s) to plot only a specific time range. % Default: The whole time range is plotted. % Copyright by Clemens Brunner % $Revision: 0.8 $ $Date: 03/10/2009 14:46:00 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.8: Add 'range' option to plot only a specific segment of time. % 0.7: Another complete rewrite to adapt to new versions of the map function. % 0.6: Complete rewrite of the function using axes commands that makes the % whole thing much more customizable. % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if (nargin < 1) error('No input ERDS map specified.'); end; % Default parameters, can be overwritten by varargin t_range = []; % Plot the whole time range % Overwriting default values with optional input parameters if ~isempty(varargin) % Are there optional parameters available? k = 1; while k <= length(varargin) if strcmp(varargin{k}, 't_range') t_range = varargin{k + 1}; k = k + 2; else % Ignore unknown parameters k = k + 2; end; end; end; if ~isfield(r, 'refmethod') r.refmethod = 'classic'; end; % Does the range interval lie inside the calculated time segment? if ~isempty(t_range) if numel(t_range) ~= 2 error('Argument t_range must be a <1x2> vector containing the start and end point (in s).'); end; if t_range(1) >= t_range(2) error('First element of t_range must be less than the second element.'); end; if t_range(1) < r.t_plot(1) || t_range(2) > r.t_plot(end) error('Argument t_range must lie inside calculated time segment.'); end; % Cut out time segment to plot [temp, pos] = find(r.t_plot >= t_range(1) & r.t_plot <= t_range(2)); r.t_plot = r.t_plot(pos); for k = 1:length(r.ERDS) r.ERDS{k}.erds = r.ERDS{k}.erds(pos,:); end; if ~strcmp(r.sig, 'none') for k = 1:length(r.ERDS) r.ERDS{k}.cl = r.ERDS{k}.cl(pos,:); r.ERDS{k}.cu = r.ERDS{k}.cu(pos,:); end; end; end; border = 0.1; % Border around figure border_plots = 0.01; % Border around each plot plot_area = 1 - 2 * border; % Topographic layout if isfield(r, 'montage') plot_index = find(r.montage' == 1); n_rows = size(r.montage, 1); n_cols = size(r.montage, 2); else % create default layout plot_index = 1:length(r.ERDS); n_cols = ceil(sqrt(length(r.ERDS))); if (length(r.ERDS) > 2) n_rows = n_cols; else n_rows = 1; end; end; i_width = plot_area / n_cols; % Width of one subplot i_height = plot_area / n_rows; % Height of one subplot font_size = 1/32; % Default normalized axes font size f = figure; set(f, 'PaperOrientation', 'landscape'); if ~exist('OCTAVE_VERSION','builtin') set(f, 'PaperType', 'A4'); end; set(f, 'PaperUnits', 'centimeters'); set(f, 'PaperPosition', [1, 1, 27.7, 19]); set(f, 'Color', [1 1 1]); set(f, 'DefaultAxesFontUnits', 'normalized'); set(f, 'DefaultAxesFontSize', font_size); % If significance information exists, plot only significant data if ~strcmp(r.sig, 'none') for chn = 1:length(r.ERDS) sig_matrix = (r.ERDS{chn}.cl > 0 & r.ERDS{chn}.cu > 0) | ... (r.ERDS{chn}.cl < 0 & r.ERDS{chn}.cu < 0); r.ERDS{chn}.erds = sig_matrix .* r.ERDS{chn}.erds; end; end; % Invert color map so that ERS is blue and ERD is red load erdscolormap; colormap(erdcolormap); counter_total = 1; % Iterates through all rows and columns counter_plots = 1; % Iterates through all subplots a = cell(1, length(plot_index)); % Contains the axes of the ERDS subplots for i_rows = 1:n_rows for i_cols = 1:n_cols if sum(counter_total == plot_index) == 1 a{counter_plots} = axes('position', [border + border_plots + i_width * (i_cols - 1), plot_area + border + border_plots - i_height * i_rows, i_width - border_plots, i_height - border_plots]); set(f, 'CurrentAxes', a{counter_plots}); if strcmp(r.refmethod, 'absolute') imagesc(r.t_plot, r.f_plot, r.ERDS{counter_plots}.erds'); else imagesc(r.t_plot, r.f_plot, r.ERDS{counter_plots}.erds', [-1, 1.5]); end; %set(gca, 'Tag', num2str(counter_plots)); set(a{counter_plots}, 'ydir', 'normal'); if sum(counter_total + n_cols == plot_index) == 1 % Draw x-labels only if there is no subplot below set(a{counter_plots}, 'XTickLabel', ''); end; if sum(counter_total - 1 == plot_index) == 1 && i_cols ~= 1 % Draw y-labels only if there is no subplot to the left set(a{counter_plots}, 'YTickLabel', ''); end; % Draw lines for reference interval and cue v = axis; line([r.ref(1), r.ref(1)], [v(3), v(4)], 'LineStyle', ':', 'Color', 'k'); line([r.ref(2), r.ref(2)], [v(3), v(4)], 'LineStyle', ':', 'Color', 'k'); if isfield(r, 'cue') line([r.cue, r.cue], [v(3), v(4)], 'Color', 'k'); end; counter_plots = counter_plots + 1; end; counter_total = counter_total + 1; end; end; % Heading if isfield(r, 'heading') % Recording date axes('position', [border + border_plots, 1 - 3/4* border, 1 - 2 * (border + border_plots), border], 'visible', 'off'); text(0.5, 0, r.heading, 'FontUnits', 'normalized', 'FontSize', 1/4, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'Bottom', 'Interpreter', 'none', 'FontWeight', 'bold'); end; %line([0, 1], [0, 0], 'Color', 'k'); % Additional text axes('position', [border + border_plots, 3/4*border, 1 - 2 * (border + border_plots), 3/4*border], 'visible', 'off'); temp_str{1} = ['{\bfERDS maps 0.7 (', upper(r.ERDS_method), ').}{\rm Calculated on ', r.date_calc, '.}']; if length(r.classes) > 1 classes_str = '['; for k = 1:length(r.classes) classes_str = [classes_str, num2str(r.classes(k))]; if k < length(r.classes) classes_str = [classes_str, ', ']; end; end; classes_str = [classes_str, ']']; else classes_str = num2str(r.classes); end; t_str = ['[', num2str(r.t(1)), ', ', num2str(r.t(2)), ', ', num2str(r.t(3)), ']s']; f_borders_str = '['; for k = 1:length(r.f_borders) f_borders_str = [f_borders_str, num2str(r.f_borders(k))]; if k < length(r.f_borders) f_borders_str = [f_borders_str, ', ']; end; end; f_borders_str = [f_borders_str, ']Hz']; if length(r.f_bandwidths) > 1 f_bandwidths_str = '['; for k = 1:length(r.f_bandwidths) f_bandwidths_str = [f_bandwidths_str, num2str(r.f_bandwidths(k))]; if k < length(r.f_bandwidths) f_bandwidths_str = [f_bandwidths_str, ', ']; end; end; f_bandwidths_str = [f_bandwidths_str, ']']; else f_bandwidths_str = num2str(r.f_bandwidths); end; f_bandwidths_str = [f_bandwidths_str, 'Hz']; if length(r.f_steps) > 1 f_steps_str = '['; for k = 1:length(r.f_steps) f_steps_str = [f_steps_str, num2str(r.f_steps(k))]; if k < length(r.f_steps) f_steps_str = [f_steps_str, ', ']; end; end; f_steps_str = [f_steps_str, ']']; else f_steps_str = num2str(r.f_steps); end; f_steps_str = [f_steps_str, 'Hz']; ref_str = ['[', num2str(r.ref(1)), ', ', num2str(r.ref(2)), ']s']; temp_str{2} = ['Trials: ', num2str(r.n_trials), ', classes: ', classes_str, ', fs: ', num2str(r.fs), 'Hz, time: ', t_str, ', ref: ', ref_str]; temp_str{3} = ['f borders: ', f_borders_str, ', f bandwidths: ', f_bandwidths_str, ', f steps: ', f_steps_str, ', ']; if strcmp(r.sig, 'boot') temp_str{3} = [temp_str{3}, 'Bootstrap significance test (\alpha = ', num2str(r.alpha), ')']; elseif strcmp(r.sig, 'boxcox') temp_str{3} = [temp_str{3}, 'Box-Cox significance test (\alpha = ', num2str(r.alpha), ', \lambda = ', num2str(r.lambda), ')']; else temp_str{3} = [temp_str{3}, 'no significance test.']; end; if exist('OCTAVE_VERSION','builtin') text([0,0,0], [0,1,2], temp_str, 'FontUnits', 'normalized', 'FontSize', 1/6, 'VerticalAlignment', 'Top', 'Interpreter', 'Tex'); else text(0, 0, temp_str, 'FontUnits', 'normalized', 'FontSize', 1/6, 'VerticalAlignment', 'Top', 'Interpreter', 'Tex'); end %line([0, 1], [0, 0], 'Color', 'k'); %hndl = findobj('parent', gcf, 'type', 'axes'); %for a = 1:length(hndl) % set(findobj('parent', hndl(a)), 'ButtonDownFcn', 'zoomMap(r)'); %end;biosig-2.3.3/biosig4matlab/t310_ERDSMaps/getMontage.m0000664000175000017500000002003514105434233022274 0ustar schloeglschloeglfunction [lap, plot_index, n_rows, n_cols] = getMontage(montage, outfile) % Calculates spatial filter matrix for Laplacian derivations. % % Returns a spatial filter matrix used to calculate Laplacian derivations as % well as indices used to plot in a topographical layout. % Assuming that the data vector s is of dimension , the % Laplacian derivation s_lap can then be calculated by s_lap = s * lap. % % Usage: % [lap, plot_index, n_rows, n_cols] = getMontage(montage); % [...] = getMontage(montage, rrfile); % % Input parameters: % montage ... Matrix containing the topographical layout of the channels. The % content of this matrix can be one of the following formats: % (1) Channel numbers where channels are located and zeros % elsewhere ; % (2) Ones where channels are located and zeros elsewhere ; % (3) Predefined layout . % Examples for each format: % (1) montage = [0 3 0; ... % 4 1 2; ... % 0 5 0]; % (2) montage = [0 1 0; ... % 1 1 1; ... % 0 1 0]; % (3) montage = '16ch'; % % Optional input parameters: % rrfile ... Name of the re-referencing file defining the spatial filter % . If the extension is empty, '.mtx' (MatrixMarket format) % is added to the filename. This file can then be used with % (1) save2gdf -r=rrfile ... % (2) mexSLOAD(file, rrfile, ... % (3) SigViewer % % Output parameters: % lap ... Laplacian filter matrix % plot_index ... Indices for plotting the montage % n_rows ... Number of rows of the montage % n_cols ... Number of columns of the montage % Copyright by Clemens Brunner, Robert Leeb, Alois Schlögl % $Revision: 0.31 $ $Date: 10/27/2009 11:41:07 $ % $Id$ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.31: Cosmetic changes. % 0.30: Include export of re-referencing matrix (MarketMatrix). % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if ischar(montage) % Predefined layouts switch montage case '16ch' temp = [0 0 1 0 0;... 0 1 1 1 0;... 0 1 1 1 0;... 1 1 1 1 1;... 0 1 1 1 0;... 0 0 1 0 0]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '22ch' temp = [0 0 0 1 0 0 0;... 0 1 1 1 1 1 0;... 1 1 1 1 1 1 1;... 0 1 1 1 1 1 0;... 0 0 1 1 1 0 0;... 0 0 0 1 0 0 0]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '24ch' temp = [0 1 0 0 1 0 0 1 0;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 0 1 0 0 1 0 0 1 0]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '28ch' temp = [0 0 0 1 0 0 0;... 0 1 1 1 1 1 0;... 1 1 1 1 1 1 1;... 0 1 1 1 1 1 0;... 0 0 1 1 1 0 0;... 0 0 0 1 0 0 0;... 1 1 1 0 1 1 1]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '30ch' temp = [0 0 0 1 1 1 0 0 0;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '58ch' temp = [0 0 1 1 1 1 1 0 0;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 1 1 1 1 1 1 1 1 1;... 0 0 1 1 1 1 1 0 0;... 0 0 0 1 1 1 0 0 0];... plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); case '60ch' temp = [0 0 0 0 0 1 0 0 0 0 0;... 0 0 0 0 1 1 1 0 0 0 0;... 0 0 0 1 1 1 1 1 0 0 0;... 0 0 1 1 1 1 1 1 1 0 0;... 0 1 1 1 1 1 1 1 1 1 0;... 1 1 1 1 1 1 1 1 1 1 1;... 0 1 1 1 1 1 1 1 1 1 0;... 0 0 1 1 1 1 1 1 1 0 0;... 0 0 0 1 1 1 1 1 0 0 0;... 0 0 0 0 1 1 1 0 0 0 0]; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); end; else % User-defined layouts in the form of a matrix temp = montage; plot_index = find(temp' == 1); n_rows = size(temp, 1); n_cols = size(temp, 2); end; counter = 1; temp = temp'; lap = zeros(size(temp,1), size(temp,2)); % Used electrode positions instead of ones (format (1)) positions = []; if sum(sum(temp)) ~= (sum(sum(temp>0))) [tmp, positions] = sort(temp(find(temp))); temp = temp > 0; end; for k = 1:numel(temp) if temp(k) == 1 lap(k) = counter; counter = counter + 1; end; end; neighbors = ones(counter - 1, 4) * nan; electrode = 0; for (k = 1:numel(lap)) if lap(k) ~= 0 col = 1; electrode = electrode + 1; if (k - size(lap, 1) > 0 && lap(k - size(lap, 1)) ~= 0) % T neighbors(electrode, col) = lap(k - size(lap, 1)); col = col + 1; end; if (mod(k+1, size(lap, 1)) ~= 1 && k < numel(lap) && lap(k+1) ~= 0) % L neighbors(electrode, col) = lap(k+1); col = col + 1; end; if (mod(k-1, size(lap, 1)) ~= 0 && k > 1 && lap(k-1) ~= 0) % R neighbors(electrode, col) = lap(k-1); col = col + 1; end; if (k + size(lap, 1) < numel(lap) && lap(k + size(lap, 1)) ~= 0) % B neighbors(electrode, col) = lap(k + size(lap, 1)); col = col + 1; end; end; end; lap = eye(length(neighbors)); for k = 1:length(neighbors) temp = neighbors(k, ~isnan(neighbors(k,:))); % Neighbors of electrode k lap(k,temp) = -1/length(temp); end; if ~isempty(positions) lap = lap(positions,positions); end lap = lap'; if nargin>1, [f,p,e] = fileparts(outfile); if isempty(e) e='.mtx'; end; HDR.TYPE = 'MatrixMarket'; HDR.Calib = lap; HDR.FileName = fullfile(f,[p,e]); if 0, %% brief version using sopen HDR = sopen(HDR,'w'); sclose(HDR); elseif 1 if ischar(montage) m = montage; else m = '? (user specified)'; end; save2mm(HDR.FileName,HDR.Calib,m); else %% obsolete [I,J,V] = find(HDR.Calib); fid = fopen(HDR.FileName,'w+'); fprintf(fid,'%%%%MatrixMarket matrix coordinate real general\n'); fprintf(fid,'%% generated on %04i-%02i-%02i %02i:%02i:%02.0f\n',clock); if ischar(montage) m = montage; else m = '? (user specified)'; end; fprintf(fid,'%% Spatial Laplacian Filter for Montage %s \n',m); fprintf(fid,'%i %i %i\n',size(HDR.Calib),length(V)); for k = 1:length(V), fprintf(fid,'%2i %2i %f\n',I(k),J(k),V(k)); end; fclose(fid); end; end; biosig-2.3.3/biosig4matlab/t310_ERDSMaps/calcAveVar.m0000664000175000017500000001410514105434233022212 0ustar schloeglschloeglfunction r = calcAveVar(s, h, t, varargin) % Calculates the mean and variance of each channel. % % This function calculates the mean and variance of each channel. The results % can be displayed with the function plotAveVar. % % Usage: % r = calcAveVar(s, h, t); % % Input parameters: % s ... Input signal (as obtained by sload) . % h ... Header structure (as obtained by sload) <1x1 struct>. Only the % following fields are required: h.SampleRate, h.TRIG, % h.Classlabel. % t ... Start point, time resolution and end point within a trial (in % s) <1x3>. If the second value is 0, the time resolution % corresponds to 1/fs. % Example: % t = [0, 0.25, 8]; % This corresponds to a trial that starts 0s after the trial % start event and lasts until second 8. 4 values per second % are calculated. % % Optional input parameters (variable argument list): % 'class' ... List of classes used in the calculation <1xM>. % Default: all available classes are used. % 'bandpass' ... Bandpass filter cutoff frequencies (in Hz) <1 x 2>. % Default: No bandpass filter. % 'heading' ... Heading of the plot . % Default: No heading is used. % 'montage' ... Topographic layout of channels . This matrix consists of % zeros and ones. The channels are arranged in N rows and M % columns on the plot, and they are located where the values of % the matrix are equal to 1. % Default: A rectangular layout is used. % 'cue' ... Draws a vertical line at the location of the cue (in s) % <1x1>. % Default: No cue is drawn. % % Output parameter: % r ... Structure containing the results <1x1 struct>. % Copyright by Clemens Brunner % $Revision: 0.61 $ $Date: 02/23/2009 15:54:05 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.61: Rounded all conversions from time to samples. % 0.60: Complete rewrite of the code to adapt it to the new toolbox. % 0.50: Triggering of artifact-selected data always works now % 0.40: Implement all optional arguments as a variable argument list % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if (nargin < 1) error('No input signal specified.'); end; if (nargin < 2) error('No header structure specified.'); end; if (nargin < 3) error('Trial timing definition not specified (start, time resolution, end).'); end; if length(t) == 2 % If only start and end time are provided, use full resolution t = [t(1), 0, t(2)]; end; % Default parameters, can be overwritten by varargin class = []; % All classes are used in the calculation bandpass = []; % No bandpass filter heading = []; % Default heading montage = []; % Default montage cue = []; % Default do not draw cue % Overwriting default values with optional input parameters if ~isempty(varargin) % Are there optional parameters available? k = 1; while k<=length(varargin) if strcmp(varargin{k}, 'class') class = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'montage') montage = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'bandpass') bandpass = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'cue') cue = varargin{k + 1}; k = k + 2; elseif strcmp(varargin{k}, 'heading') heading = varargin{k + 1}; k = k + 2; else % Ignore unknown parameters k = k + 2; end; end; end; if isempty(class) class = unique(h.Classlabel); end; fs = h.SampleRate; triallen = round((t(3) - t(1)) * fs) + 1; % Trial length (in samples) n_trials = length(h.TRIG(ismember(h.Classlabel, class))); if t(2) ~= 0 t_vec_r = t(1):t(2):t(3); % Time vector, reduced resolution end; if ~isempty(bandpass) b = fir1(fs, bandpass/(fs/2)); s = filtfilt(b, 1, s); end; % Trigger data s_t = trigg(s, h.TRIG(ismember(h.Classlabel, class)), round(t(1)*fs), round(t(3)*fs)); for chn = 1:size(s, 2) temp = reshape(s_t(chn,:)', triallen, n_trials)'; if t(2) ~= 0 idx = round(t_vec_r*fs) + 1; % Indices of reduced resolution in original time vector average = mean(temp); stdev = std(temp); r.AveVar{chn}.average = average(idx); r.AveVar{chn}.stdev = stdev(idx); else r.AveVar{chn}.average = mean(temp); r.AveVar{chn}.stdev = std(temp); end; end; % Create time vector if t(2) ~= 0 r.t_plot = t(1):t(2):t(3); else % Full time resolution r.t_plot = t(1):1/fs:t(3); end; r.t = t; r.fs = fs; if isfield(h, 'FILE') if isfield(h.FILE, 'Name') && isfield(h.FILE, 'Ext') if length(h.FILE) > 1 for k = 1:length(h.FILE) r.fname{k} = [h.FILE(k).Name, '.', h.FILE(k).Ext]; end; else r.fname = [h.FILE.Name, '.', h.FILE.Ext]; end; end; end; r.date_calc = datestr(clock); if isfield(h, 'T0') % Recording date r.date_rec = datestr(h.T0); end; r.n_trials = n_trials; if ~isempty(heading) r.heading = heading; end; if ~isempty(class) r.classes = class; else r.classes = unique(h.Classlabel); end; if ~isempty(montage) r.montage = montage; end; if ~isempty(cue) r.cue = cue; end;biosig-2.3.3/biosig4matlab/t310_ERDSMaps/plotAveVar.m0000664000175000017500000002054314105434233022271 0ustar schloeglschloeglfunction plotAveVar(r, varargin) % Displays the mean and standard deviation of each channel. % % This function displays the mean and standard deviation of each channel in a % topographical layout as calculated by calcAveVar.m. % % Usage: % plotAveVar(r); % % Input parameters: % r ... Input structure calculated with calcAveVar. % % Optional input parameters (variable argument list): % 't_range' ... Time range to plot <1x2>. Specify start and end points within a % trial (in s) to plot only a specific time range. % Default: The whole time range is plotted. % Copyright by Clemens Brunner % $Revision: 0.5 $ $Date: 03/12/2009 14:43:05 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.5: Add 'range' option to plot only a specific segment of time. % 0.4: Another complete rewrite for the new toolbox. % 0.3: Complete rewrite of the function using axes commands that makes the % whole thing much more customizable % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. if (nargin < 1) error('No input average/variance map specified.'); end; % Default parameters, can be overwritten by varargin t_range = []; % Plot the whole time range % Overwriting default values with optional input parameters if ~isempty(varargin) % Are there optional parameters available? k = 1; while k <= length(varargin) if strcmp(varargin{k}, 't_range') t_range = varargin{k + 1}; k = k + 2; else % Ignore unknown parameters k = k + 2; end; end; end; % Does the range interval lie inside the calculated time segment? if ~isempty(t_range) if numel(t_range) ~= 2 error('Argument t_range must be a <1x2> vector containing the start and end point (in s).'); end; if t_range(1) >= t_range(2) error('First element of t_range must be less than the second element.'); end; if t_range(1) < r.t_plot(1) || t_range(2) > r.t_plot(end) error('Argument t_range must lie inside calculated time segment.'); end; % Cut out time segment to plot [temp, pos] = find(r.t_plot >= t_range(1) & r.t_plot <= t_range(2)); r.t_plot = r.t_plot(pos); for k = 1:length(r.AveVar) r.AveVar{k}.average = r.AveVar{k}.average(pos); r.AveVar{k}.stdev = r.AveVar{k}.stdev(pos); end; end; border = 0.1; % Border around figure border_plots = 0.01; % Border around each plot plot_area = 1 - 2 * border; % Topographic layout if isfield(r, 'montage') plot_index = find(r.montage' == 1); n_rows = size(r.montage, 1); n_cols = size(r.montage, 2); else % create default layout plot_index = 1:length(r.AveVar); n_cols = ceil(sqrt(length(r.AveVar))); if (length(r.AveVar) > 2) n_rows = n_cols; else n_rows = 1; end; end; i_width = plot_area / n_cols; % Width of one subplot i_height = plot_area / n_rows; % Height of one subplot font_size = 1/32; % Default normalized axes font size f = figure; set(f, 'PaperOrientation', 'landscape'); set(f, 'PaperType', 'A4'); set(f, 'PaperUnits', 'centimeters'); set(f, 'PaperPosition', [1, 1, 27.7, 19]); set(f, 'Color', [1 1 1]); set(f, 'DefaultAxesFontUnits', 'normalized'); set(f, 'DefaultAxesFontSize', font_size); counter_total = 1; % Iterates through all rows and columns counter_plots = 1; % Iterates through all subplots peaks1 = [0 0]; % Contains global minimum and maximum of averages over all subplots peaks2 = [0 0]; % Contains global minimum and maximum of stds over all subplots a1 = cell(1, length(plot_index)); % Contains the axes of the average subplots a2 = cell(1, length(plot_index)); % Contains the axes of the variance subplots for i_rows = 1:n_rows for i_cols = 1:n_cols if sum(counter_total == plot_index) == 1 a1{counter_plots} = axes('position', [border + border_plots + i_width * (i_cols - 1), plot_area + border + border_plots - i_height * i_rows, i_width - border_plots, 2 * (i_height - border_plots) / 3]); a2{counter_plots} = axes('position', [border + border_plots + i_width * (i_cols - 1), plot_area + border + border_plots - i_height * i_rows + 2 * (i_height - border_plots) / 3, i_width - border_plots, (i_height - border_plots) / 3]); set(f, 'CurrentAxes', a1{counter_plots}); set(gca, 'FontSize', font_size/2*3); plot(r.t_plot, r.AveVar{counter_plots}.average); set(f, 'CurrentAxes', a2{counter_plots}); set(gca, 'FontSize', font_size/1*3); plot(r.t_plot, r.AveVar{counter_plots}.stdev.^2, 'r'); % Identical scaling for each plot if min(r.AveVar{counter_plots}.average) < peaks1(1) peaks1(1) = min(r.AveVar{counter_plots}.average); end; if max(r.AveVar{counter_plots}.average) > peaks1(2) peaks1(2) = max(r.AveVar{counter_plots}.average); end; if min(r.AveVar{counter_plots}.stdev.^2) < peaks2(1) peaks2(1) = min(r.AveVar{counter_plots}.stdev.^2); end; if max(r.AveVar{counter_plots}.stdev.^2) > peaks2(2) peaks2(2) = max(r.AveVar{counter_plots}.stdev.^2); end; if sum(counter_total + n_cols == plot_index) == 1 % Draw x-labels only if there is no subplot below set(a1{counter_plots}, 'XTickLabel', ''); end; if sum(counter_total - 1 == plot_index) == 1 && i_cols ~= 1 % Draw y-labels only if there is no subplot to the left set(a1{counter_plots}, 'YTickLabel', ''); set(a2{counter_plots}, 'YTickLabel', ''); end; set(a2{counter_plots}, 'XTickLabel', ''); counter_plots = counter_plots + 1; end; counter_total = counter_total + 1; end; end; for k = 1:length(a1) axis(a1{k}, [r.t_plot(1), r.t_plot(end), peaks1(1), peaks1(2)]); % Draw line for cue if isfield(r, 'cue') set(f, 'CurrentAxes', a1{k}); v = axis; line([r.cue, r.cue], [v(3), v(4)], 'Color', 'k'); end; end; for k = 1:length(a2) axis(a2{k}, [r.t_plot(1), r.t_plot(end), peaks2(1), peaks2(2)]); % Draw line for cue if isfield(r, 'cue') set(f, 'CurrentAxes', a2{k}); v = axis; line([r.cue, r.cue], [v(3), v(4)], 'Color', 'k'); end; end; % Heading if isfield(r, 'heading') % Recording date axes('position', [border + border_plots, 1 - 3/4* border, 1 - 2 * (border + border_plots), border], 'visible', 'off'); text(0.5, 0, r.heading, 'FontUnits', 'normalized', 'FontSize', 1/4, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'Bottom', 'Interpreter', 'none', 'FontWeight', 'bold'); end; %line([0, 1], [0, 0], 'Color', 'k'); % Additional text axes('position', [border + border_plots, 3/4*border, 1 - 2 * (border + border_plots), 3/4*border], 'visible', 'off'); temp_str{1} = ['{\bfAverage/variance maps 0.7.}{\rm Calculated on ', r.date_calc, '.}']; if length(r.classes) > 1 classes_str = '['; for k = 1:length(r.classes) classes_str = [classes_str, num2str(r.classes(k))]; if k < length(r.classes) classes_str = [classes_str, ', ']; end; end; classes_str = [classes_str, ']']; else classes_str = num2str(r.classes); end; t_str = ['[', num2str(r.t(1)), ', ', num2str(r.t(2)), ', ', num2str(r.t(3)), ']s']; temp_str{2} = ['Trials: ', num2str(r.n_trials), ', classes: ', classes_str, ', fs: ', num2str(r.fs), 'Hz, time: ', t_str]; text(0, 0, temp_str, 'FontUnits', 'normalized', 'FontSize', 1/6, 'VerticalAlignment', 'Top', 'Interpreter', 'Tex'); %line([0, 1], [0, 0], 'Color', 'k'); %hndl = findobj('parent', gcf, 'type', 'axes'); %for a = 1:length(hndl) % set(findobj('parent', hndl(a)), 'ButtonDownFcn', 'zoomMap(r)'); %end;biosig-2.3.3/biosig4matlab/t310_ERDSMaps/calcErdsMapBP.m0000664000175000017500000003104314105434233022603 0ustar schloeglschloeglfunction r = calcErdsMapBP(s, h, t, f_borders, f_bandwidths, f_steps, class, ref, submean, sig, lambda, alpha, refmethod) % Calculates time-frequency (ERDS) maps based on the bandpower (BP) method. % % This function calculates time-frequency (ERDS) maps by using a bandpass filter % and subsequent squaring of the signals to estimate the power in specific % frequency bands. Maps can be calculated for more than one channel at once. % Note that this function should not be used directly, use calcErdsMap instead % and specify 'bp' as the calculation method. % % Usage: % r = calcErdsMapBP(s, h, t, f_borders, f_bandwidths, f_steps, class, ref, % submean, sig, lambda, alpha); % % Input parameters: % s ... Input signal (as obtained by sload) . % h ... Header structure (as obtained by sload) <1x1 struct>. Only the % following fields are required: h.SampleRate, h.TRIG, % h.Classlabel. % t ... Start point, time resolution and end point within a trial (in % s) <1x3>. If the second value is 0, the time resolution % corresponds to 1/fs. % Example: % t = [0, 0.25, 8]; % This corresponds to a trial that starts 0s after the trial % start event and lasts until second 8. 4 values per second % are calculated. % f_borders ... Frequency borders (in Hz) <1xF>. Contains the borders of the % frequency bands and can be used with the optional parameters % 'f_bandwidths' and 'f_steps' (see below). % Examples: % f_borders = [6, 30]; % The maps are calculated from 6Hz to 30Hz with the default % bandwidth and in the default frequency step size. % % f_borders = [4, 12, 20, 40]; % The maps are calculated for the segments 4-12Hz, 12-20Hz, % and 20-40Hz with the default bandwidths and step sizes. % f_bandwidths ... Bandwidths for the segments specified in f_borders (in Hz) % <1xF-1>. % f_steps ... Frequency step sizes for the segments specified in % f_borders (in Hz) <1xF-1>. % class ... List of classes used in the calculation <1xM>. % ref ... Reference interval (in s) <1x2>. % submean ... Subtract the mean signal to suppress evoked components % <1x1 logical>. % sig ... Method to calculate the significance . User one of % the following methods: 'boot', 'boxcox' or 'none'. % lambda ... Parameter of the Box-Cox transform <1x1>. If lambda is 0, % the transform is a log-transform. % alpha ... Significance level <1x1>. If 'sig' is set to 'none', this % value is ignored. % refmethod ... Calculation mode . 'classic' uses the classical % approach with an averaged reference interval. 'trial' uses % an individual reference for each trial. % % Output parameter: % r ... Structure containing the results <1x1 struct>. % Copyright by Clemens Brunner % $Revision: 0.30 $ $Date: 10/29/2009 13:11:00 $ % E-Mail: clemens.brunner@tugraz.at % Revision history: % 0.30: Added new calculation mode that uses an individual reference for each % trial. % 0.21: Rounded all conversions from time to samples % 0.20: Modifications concerning the interface and computations. % 0.10: Initial version. % 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 of the License, 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., 59 Temple % Place - Suite 330, Boston, MA 02111-1307, USA. fs = h.SampleRate; n_butter = 4; % Filter order of Butterworth filter triallen = round((t(3) - t(1)) * fs) + 1; % Trial length (in samples) if t(2) ~= 0 t_vec_r = t(1):t(2):t(3); % Time vector, reduced resolution end; % Determine indices of reference interval ref(1) = round(ref(1) * fs) + 1 - round(t(1) * fs); ref(2) = round(ref(2) * fs) + 1 - round(t(1) * fs); f_plot = []; % Center frequencies in the plot f_low = []; % Lower frequency border for each center frequency f_up = []; % Upper frequency border for each center frequency for k = 1:length(f_borders) - 1 f_plot = [f_plot, f_borders(k):f_steps(k):f_borders(k + 1)-f_steps(k)]; f_low = [f_low, f_borders(k) - f_bandwidths(k)/2:f_steps(k):f_borders(k + 1) - f_steps(k) - f_bandwidths(k)/2]; f_up = [f_up, f_borders(k) + f_bandwidths(k)/2:f_steps(k):f_borders(k + 1) - f_steps(k) + f_bandwidths(k)/2]; end; f_plot = [f_plot, f_borders(end)]; f_low = [f_low, f_borders(end) - f_bandwidths(end)/2]; f_up = [f_up, f_borders(end) + f_bandwidths(end)/2]; fn = fs/2; for chn = 1:size(s,2) % Loop over all channels if submean % Subtract evoked components? s_t = trigg(s(:, chn), h.TRIG(ismember(h.Classlabel, class)), round(t(1)*fs), round(t(3)*fs)); temp = reshape(s_t, triallen, length(s_t)/triallen); % Reshape to samples x trials average = mean(temp, 2); temp = zeros(length(s), 1); for k = 1:length(h.TRIG) temp(h.TRIG(k) + round(t(1)*fs) : h.TRIG(k) + round(t(1)*fs) + length(average)-1) = average; end; s(:, chn) = s(:, chn) - temp; end; if strcmp(refmethod, 'classic') % 1 reference per frequency band refp = zeros(1, length(f_plot)); else % References for each trial per frequency band if submean % s_t was already defined refp = zeros(length(s_t)/triallen, length(f_plot)); else s_t = trigg(s(:, chn), h.TRIG(ismember(h.Classlabel, class)), round(t(1)*fs), round(t(3)*fs)); refp = zeros(length(s_t)/triallen, length(f_plot)); end; end; erds = zeros(triallen, length(f_plot)); for k = 1:length(f_plot) % Loop over frequency bands [b, a] = butter(n_butter, [f_low(k), f_up(k)]./fn); smooth_length = ceil(2*fs/f_low(k)); s_f = filtfilt(ones(1, smooth_length)/smooth_length, 1, filtfilt(b, a, s(:,chn)).^2); % Trigger data s_t = trigg(s_f, h.TRIG(ismember(h.Classlabel, class)), round(t(1)*fs), round(t(3)*fs)); if strcmp(refmethod, 'classic') % Use classical calculation scheme with trial-averaged reference % The variable pre_erds is needed for the bootstrap statistics, it contains the single-trial ERDS values % pre_erds{frequency band} =