pax_global_header00006660000000000000000000000064117572420010014511gustar00rootroot0000000000000052 comment=aa59592790d621b7907038560bed59c7465198fc biosig4c++-1.3.0/000077500000000000000000000000001175724200100133435ustar00rootroot00000000000000biosig4c++-1.3.0/INSTALL000066400000000000000000000214121175724200100143740ustar00rootroot00000000000000INSTALLATION ============ General remarks: ---------------- Please check the Makefile and (un)define the corresponding defines: The following DEFINES are recommended and required: -D=WITH_CHOLMOD used for re-referencing of data, REQUIREMENT: cholmod from libsuitesparse -D=WITH_ZLIB used to handle gzip-ped files, REQUIREMENT: zlib (http://zlib.net/) -D=WITH_GSL provides interface to GSL, REQUIREMENT: GNU Scientific Library (GSL), -D=WITH_FEF includes support for FEF-format from CNSystems (fails with MinGW) -D=WITH_FAMOS includes (partial) support for FAMOS format -D=__4HAERTEL__ support for special flavor of FAMOS format (experimental) Other flags are used for experimental development -D=WITH_DICOM, -D=WITH_GDCM experimental DICOM support If some libraries are not available on your system, remove the corresponding DEFINES in Makefile. Prerequisites: -------------- 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-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/mxe/mxe.git cd mxe make zlib suitesparse libgomp qt patch -p0 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 libbiosig.a # makes a static 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. The main incompatibility is the use of the typeof() operator. Since typeof() is very convinient, I'm not planning to change this. However, you can easy replace any typeof()-operator by the appropriate type, and the code should compile on MSVC as well. # Other platforms (Windows+MSVC, MacOSX, Solaris, etc. ) Not tested (yet). Let me know about successful compilations, or tell me what changes are needed. 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. $Id$ Copyright (C) 2005,2006,2007,2008,2009,2011,2012, Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig4c++-1.3.0/LICENSE000066400000000000000000001045131175724200100143540ustar00rootroot00000000000000 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 . biosig4c++-1.3.0/Makefile000066400000000000000000001165651175724200100150210ustar00rootroot00000000000000####### Makefile for "BioSig for C/C++" ##################### ### ### $Id$ ### Copyright (C) 2006,2007,2008,2009,2010,2011,2012 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ##### Target: GNU/Linux ## 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 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 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.a, libbiosig.dll, for MSWindows, requires MinGW ## make win64 - makes save2gdf.exe, libbiosig.a, libbiosig.dll for 64bit Windows, requires mce-w64 ## 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 ############################### # 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/usr/bin/i686-pc-mingw32 ## local MXE ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = $(shell pwd)/../mxe/usr/bin/i686-pc-mingw32 endif ifeq "$(wildcard $(CROSS)-gcc)" "" CROSS = /usr/local/src/mxe/usr/bin/i686-pc-mingw32 endif CROSS64 = $(HOME)/src/mce-w64/usr/bin/x86_64-w64-mingw32 ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = $(shell pwd)/../mce-w64/usr/bin/i686-pc-mingw32 endif ifeq "$(wildcard $(CROSS64)-gcc)" "" CROSS64 = /usr/local/src/mce-w64/usr/bin/i686-pc-mingw32 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 ## default options CC = gcc CXX = g++ #DEFINES = -D=WITHOUT_SCP_DECODE DEFINES = -D=WITH_ZLIB #DEFINES += -D=WITH_CURL DEFINES += -D=__4HAERTEL__ DEFINES += -D=WITH_FAMOS DEFINES += -D=WITH_CHOLMOD DEFINES += -D=WITHOUT_NETWORK #DEFINES += -D=WITH_HDF #DEFINES += -D=WITH_MATIO #DEFINES += -D=WITH_LIBXML2 #DEFINES += -D=WITH_FEF #DEFINES += -D=WITH_PDP #DEFINES += -D=WITH_DICOM #DEFINES += -D=WITH_GDCM #DEFINES += -D=WITH_GSL #DEFINES += -D=WITH_EEPROBE #DEFINES += -D=SOFTCODED_PHYSDIMTABLE # obsolete #DEFINES += -D=CNT32 # for 32bit Neuroscan format CFLAGS = -pipe -fPIC -Wall -fno-builtin-memcmp -O2 $(DEFINES) -Wextra # -I cntopenlib/include/ CXXFLAGS = -pipe -fPIC -Wall -fno-builtin-memcmp -O2 $(DEFINES) -Wextra # -I cntopenlib/include/ AR = ar crs INCPATH = -I /usr/include/libxml2/ -I/opt/local/include/ #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/opt/local/lib -L. LIBS_dynamic = -lbiosig LFLAGS_static = -L/usr/local/lib/ -L/opt/local/lib LIBS_static = libbiosig.a ifeq ($(LIBEXT),so) LFLAGS = $(LFLAGS_dynamic) LIBS = $(LIBS_dynamic) else LFLAGS = $(LFLAGS_static) LIBS = $(LIBS_static) endif ifneq (,$(findstring WITH_ZLIB, $(DEFINES))) LDLIBS += -lz endif ifneq (,$(findstring WITH_CHOLMOD, $(DEFINES))) LDLIBS += -lcholmod endif ifneq (,$(findstring WITH_LIBXML2, $(DEFINES))) LDLIBS += -lxml2 endif ifneq (,$(findstring WITH_CURL, $(DEFINES))) LDLIBS += -lcurl endif ifneq (,$(findstring WITH_HDF, $(DEFINES))) LDLIBS += -lhdf5 endif ifneq (,$(findstring WITH_MATIO, $(DEFINES))) LDLIBS += -lmatio endif LIBS += $(LDLIBS) DELETE = rm COPY = cp -f DATA_DIR = data/ TEMP_DIR = test/ ########################################################## ## 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 # Octave - global install (e.g. from debian package) OCTAVE_VERSION = # Octave - local install (e.g. compiled from sources) #OCTAVE_VERSION = -3.6.1 OCT := mkoctfile$(OCTAVE_VERSION) ########################################################## ########################################################## ## set variables for Python SWIG := swig PYTHON := python PYTHONVER := $(shell $(PYTHON) -c "import sys; print sys.version[:3]") PYTHON_INC := $(shell $(PYTHON) -c 'import numpy.distutils.system_info as si; print " -I".join(si.numpy_info().get_include_dirs())') NUMPY_INC := $(shell $(PYTHON) -c 'import numpy.distutils.misc_util as mu; print " -I".join(mu.get_numpy_include_dirs())') ########################################################## ########################################################## ## 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/ -lws2_32 $(LDLIBS) # static MinGWLINK = $(MinGWCXX) MinGW64CC = $(CROSS64)-gcc MinGW64CXX = $(CROSS64)-g++ MinGW64CFLAGS = -pipe -fPIC -O2 -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -Iwin32 -I$(PathToMinGW64)/include/ MinGW64LIBS = win64/libbiosig.a -L$(PathToMinGW64)/lib/ -lws2_32 $(LDLIBS) # static MinGW64LINK = $(MinGW64CXX) ########################################################## # 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_PATCHLEVEL' biosig.h)) TODAY := $(shell date +%Y%m%d) ####### Output directory OBJ = ./obj BIN = $(DESTDIR)/usr/bin LIB = $(DESTDIR)/usr/lib ####### Files SOURCES = biosig.c \ 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 \ xgethostname.c \ physicalunits.c \ biosig-network.c \ save2gdf.c \ biosig_client.c \ biosig_server.c ifeq (,$(findstring WITH_LIBXML2, $(DEFINES))) ## TinyXML is used when built without libxml2 SOURCES += XMLParser/tinyxml.cpp \ XMLParser/tinyxmlparser.cpp \ XMLParser/tinyxmlerror.cpp \ XMLParser/tinystr.cpp endif OBJECTS = \ crc4scp.o \ biosig.o \ sopen_scp_read.o \ sopen_alpha_read.o \ sopen_scp_write.o \ sopen_hl7aecg.o \ biosig-network.o \ sandbox.o \ xgethostname.o MinGWOBJECTS = \ win32/crc4scp.obj \ win32/biosig.obj \ win32/getlogin.obj \ win32/strndup.obj \ win32/strnlen.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 \ 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))) 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 ifeq (,$(findstring WITH_LIBXML2, $(DEFINES))) ## TinyXML is used when built without libxml2 OBJECTS += tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o endif ifeq (,$(findstring WITH_LIBXML2, $(DEFINES))) ## TinyXML is used when built without libxml2 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 first: $(TARGET) all: $(TARGET) mex4o biosig4python sigviewer win32 win64 win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer lib: libbiosig.a win32/libbiosig.dll win32/libbiosig.a win64/libbiosig.a ############################################################# # 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: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" .c.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" %.o: %.c biosig.h biosig-dev.h Makefile $(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 Makefile $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" %.o: XMLParser/%.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" win32/%.obj: %.c biosig-dev.h biosig.h Makefile $(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: test0/%.c biosig-dev.h biosig.h Makefile $(MinGWCC) -c $(MinGWCFLAGS) -I t240 $(INCPATH) -o "$@" "$<" win32/%.obj: win32/%.c $(MinGWCC) -c $(MinGWCFLAGS) -I win32 $(INCPATH) -o "$@" "$<" win32/%.obj: XMLParser/%.cpp $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win64/%.obj: %.c biosig-dev.h biosig.h Makefile $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/%.obj: t210/%.c biosig-dev.h biosig.h $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/%.obj: t220/%.c biosig-dev.h biosig.h $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/%.obj: t230/%.c biosig-dev.h biosig.h $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/%.obj: t240/%.c biosig-dev.h biosig.h $(MinGW64CC) -c $(MinGW64CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" win64/%.obj: test0/%.c biosig-dev.h biosig.h Makefile $(MinGW64CC) -c $(MinGW64CFLAGS) -I t240 $(INCPATH) -o "$@" "$<" win64/%.obj: win32/%.c $(MinGW64CC) -c $(MinGW64CFLAGS) -I win32 $(INCPATH) -o "$@" "$<" win64/%.obj: XMLParser/%.cpp $(MinGW64CXX) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" ############################################################# # eventcodes and units: conversion from ascii to C code ############################################################# biosig.o win32/biosig.obj win64/biosig.obj: eventcodes.i eventcodegroups.i units.i biosig.c biosig.h biosig-dev.h Makefile eventcodes.i eventcodegroups.i : extern/eventcodes.txt gawk -f eventcodes.awk "$<" units.i : extern/units.csv gawk -f units.awk "$<" > "$@" ############################################################# # Compilation: exceptions, explicit rules ############################################################# 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 $(CXX) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" sopen_scp_read.o: t210/sopen_scp_read.c biosig-dev.h biosig.h biosig.h t210/structures.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" scp-decode.o: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" #getlogin_r.o: win32/getlogin_r.c # $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" ########### WIN32 ################## win32/sopen_scp_read.obj: t210/sopen_scp_read.c biosig-dev.h biosig.h t210/structures.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 $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/sopen_hl7aecg.obj: t230/sopen_hl7aecg.c biosig-dev.h biosig.h $(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" win32/getlogin_r.obj: win32/getlogin_r.c $(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<" $(PathToSigViewerWIN32): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win32 $(PathToSigViewerWIN32)/src/src.pro: $(PathToSigViewerWIN32) svn up ../sigviewer4win32 win32/sigviewer.exe: win32/libbiosig.a win32/libbiosig.dll $(PathToSigViewerWIN32) #-$(COPY) ../biosig/doc/eventcodes.txt $(PathToSigViewerWIN32)/src/ -$(DELETE) $(PathToSigViewerWIN32)/extern/include/*.h -$(COPY) biosig.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 -(cd $(PathToSigViewerWIN32)/src; $(CROSS)-qmake; make) #-(cd $(PathToSigViewerWIN32); svn revert -R .; svn up -r 556; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.1-as.4-DisplayHeaderInfo+EventTableAlways4Columns+SampleRateChanged2FLOAT64+libbiosigEventTable.diff; cd src; $(CROSS32)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN32)/bin/release/sigviewer.exe win32/sigviewer-$(shell cat $(PathToSigViewerWIN32)/src/version.txt)-win32.exe ########### WIN64 ################## win64/sopen_scp_read.obj: t210/sopen_scp_read.c biosig-dev.h biosig.h t210/structures.h $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/scp-decode.obj: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/sopen_hl7aecg.obj: t230/sopen_hl7aecg.c biosig-dev.h biosig.h $(MinGW64CXX) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" win64/getlogin_r.obj: win32/getlogin_r.c $(MinGW64CC) -c $(MinGW64CFLAGS) $(INCPATH) -o "$@" "$<" $(PathToSigViewerWIN64): svn co https://sigviewer.svn.sourceforge.net/svnroot/sigviewer/trunk ../sigviewer4win64 $(PathToSigViewerWIN64)/src/src.pro: $(PathToSigViewerWIN64) svn up ../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 $(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 -(cd $(PathToSigViewerWIN64)/src; $(CROSS64)-qmake; make) #-(cd $(PathToSigViewerWIN64); svn revert -R .; svn up -r 556; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.1-as.4-DisplayHeaderInfo+EventTableAlways4Columns+SampleRateChanged2FLOAT64+libbiosigEventTable.diff; cd src; $(CROSS64)-qmake; $(MAKE);) -$(COPY) $(PathToSigViewerWIN64)/bin/release/sigviewer.exe win64/sigviewer-$(shell cat $(PathToSigViewerWIN64)/src/version.txt)-win64.exe ############################################################# # 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$(NUMPY_INC) -o python/swig_wrap.cxx python/swig.i python/_biosig.so : python/swig_wrap.cxx libbiosig.$(LIBEXT) $(CXX) -c $(CXXFLAGS) -I$(PYTHON_INC) -I$(NUMPY_INC) -I$(INCPATH) python/swig_wrap.cxx -o python/swig_wrap.o $(CXX) -shared python/swig_wrap.o $(LFLAGS) $(LIBS) -lpython$(PYTHONVER) -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: $(MinGWOBJECTS) win32/libcnsfef.a biosig.h biosig-dev.h -$(DELETE) "$@" $(CROSS)-$(AR) "$@" $(MinGWOBJECTS) t240/*.obj -touch ../sigviewer4win32/src/file_context.cpp # trigger to rebuild sigviewer 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 "$@" -Wl,--output-def,win32/libbiosig.def,--out-implib,win32/libbiosig.dll.a -$(COPY) "$@" $(PathToSigViewerWIN32)/extern/lib/ win32/save2gdf.exe: save2gdf.c win32/libbiosig.a $(MinGWLINK) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32/pdp2gdf.exe: pdp2gdf.c win32/libbiosig.a $(MinGWLINK) $(MinGWCFLAGS) "$<" $(MinGWLIBS) -o "$@" win32 exe: win32/save2gdf.exe win32/libbiosig.dll win32/libbiosig.a #mexw32 win32mma ############################################################# # WIN64 - BUILD ############################################################# win64/libbiosig.lib: win64/libbiosig.a $(COPY) "$<" "$@" win64/libbiosig.a: $(MinGW64OBJECTS) win64/libcnsfef.a biosig.h biosig-dev.h -$(DELETE) "$@" $(CROSS64)-$(AR) "$@" $(MinGW64OBJECTS) t240/*.o64 -touch ../sigviewer4win64/src/file_context.cpp # trigger to rebuild sigviewer win64/libcnsfef.a: $(MAKE) CROSS64=$(CROSS64) -C t240 ../win64/libcnsfef.a win64/libbiosig.dll: $(MinGW64OBJECTS) biosig.h biosig-dev.h $(MinGW64LINK) -shared -fPIC $(MinGW64OBJECTS) $(MinGW64LIBS) -o "$@" -Wl,--output-def,win32/libbiosig.def,--out-implib,win32/libbiosig.dll.a -$(COPY) "$@" $(PathToSigViewerWIN64)/extern/lib/ win64/save2gdf.exe: save2gdf.c win64/libbiosig.a $(MinGW64LINK) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64/pdp2gdf.exe: pdp2gdf.c win64/libbiosig.a $(MinGW64LINK) $(MinGW64CFLAGS) "$<" $(MinGW64LIBS) -o "$@" win64: win64/save2gdf.exe win64/libbiosig.dll win64/libbiosig.a #mexw64 win64mma ############################################################# # GNU/Linux - BUILD ############################################################# t240/libcnsfef.a: # $(MAKE) -C t240 regen # $(MAKE) -C t240 libcnsfef.a # generate t240/*.o files libbiosig.a: $(OBJECTS) t240/libcnsfef.a biosig.h biosig-dev.h -$(DELETE) libbiosig.a $(AR) libbiosig.a $(OBJECTS) t240/*.o -touch ../sigviewer/src/file_context.cpp # trigger to rebuild sigviewer 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.$(LIBEXT) $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" sload win32mma: win32/libbiosig.a $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" sload.exe win64mma: win64/libbiosig.a $(MAKE) -C mma CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" sload.w64.exe ############################################################# # MEX-files for Octave and Matlab ############################################################# mex mex4m mex4o oct: libbiosig.a $(MAKE) -C mex DEFINES="$(DEFINES)" CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" OCTAVE_VERSION=$(OCTAVE_VERSION) $@ -cp mex/*.mex* ../biosig/t200_FileAccess/ mexw32: win32/libbiosig.a $(MAKE) -C mex DEFINES="$(DEFINES)" CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" $(@F) -cp mex/*.mexw32 ../biosig/t200_FileAccess/ mexw64: win64/libbiosig.a $(MAKE) -C mex DEFINES="$(DEFINES)" CROSS=$(CROSS) CROSS64=$(CROSS64) LDLIBS="$(LDLIBS)" $(@F) -cp mex/*.mexw64 ../biosig/t200_FileAccess/ ############################################################# # SigViewer ############################################################# sigviewer: $(PathToSigViewer)/bin/sigviewer $(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer-$(TODAY) $(COPY) $(PathToSigViewer)/bin/release/sigviewer bin/sigviewer-$(shell cat $(PathToSigViewer)/src/version.txt) ln -sf sigviewer-$(TODAY) bin/sigviewer $(PathToSigViewer)/bin/sigviewer: libbiosig.$(LIBEXT) biosig.h -$(DELETE) $(PathToSigViewer)/extern/include/* -$(COPY) biosig.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 (cd $(PathToSigViewer)/src; qmake; $(MAKE);) #(cd $(PathToSigViewer); svn revert -R .; svn up -r 556; patch -p0 <../biosig4c++/patches/patch_sigviewer_0.5.1-as.4-DisplayHeaderInfo+EventTableAlways4Columns+SampleRateChanged2FLOAT64+libbiosigEventTable.diff; cd 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 ############################################################# # TTL2TRIG, FLOWMON ############################################################# ### TTL2TRIG ifeq (1,0) ### for debugging bin/ttl2trig : src/ttl2trig.c libbiosig.a $(CXX) $(INCPATH) $(DEFINES) -D=WITH_BIOSIG "$<" -Wall -Wextra -lasound $(LIBS) -o "$@" else bin/ttl2trig : src/ttl2trig.c $(CXX) $(INCPATH) $(DEFINES) "$<" -Wall -Wextra -lasound -o "$@" endif ### FLOWMON bin/flowmon : src/flowmon.c $(CXX) $(INCPATH) $(DEFINES) "$<" -I. -Wall -Wextra $(LIBS) -o "$@" ############################################################# # INSTALL and DE-INSTALL ############################################################# .PHONY: clean distclean install remove install_sigviewer install_octave asc bin testscp testhl7 testbin test test6 zip distclean: -$(DELETE) *.a -$(DELETE) *.i -$(DELETE) *.o -$(DELETE) *.lib -$(DELETE) *.so -$(DELETE) *.so.* -$(DELETE) *.mex* -$(DELETE) *.oct -$(DELETE) t5.scp t6.scp save2gdf gztest test_scp_decode biosig_server biosig_client -$(DELETE) t?.[bge]df* t?.hl7* t?.scp* t?.cfw* t?.gd1* t?.*.gz *.fil $(TEMP_DIR)/t1.* $(DATA_DIR)/t1.* -$(DELETE) python/swig_wrap.* python/biosig.py* python/_biosig.so -$(DELETE) QMakefile -$(DELETE) igor/libIgor.a -$(DELETE) win32/*.a win32/*.lib win32/libbiosig.* win32/*.obj win32/*.exe -$(DELETE) win64/*.a win64/*.lib win64/libbiosig.* win64/*.obj win64/*.exe -$(DELETE) -rf win32/zlib -$(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 -$(MAKE) -C mex clean clean: -$(DELETE) *~ -$(DELETE) *.a -$(DELETE) *.i -$(DELETE) *.o -$(DELETE) *.so -$(DELETE) *.so.* -$(DELETE) *.mex* -$(DELETE) *.oct -$(DELETE) $(TEMP_DIR)/t1.* -$(DELETE) python/biosig.py* _biosig.so -$(DELETE) python/swig_wrap.* -$(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) t240/libbiosig.* -$(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 -$(MAKE) -C mex clean install_sigviewer: sigviewer install $(PathToSigViewer)/bin/release/sigviewer $(BIN) install_ttl2trig: bin/ttl2trig install bin/ttl2trig $(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_libbiosig: libbiosig.a libbiosig.so 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) install: save2gdf libbiosig.a libbiosig.so doc/save2gdf.1 install -d $(BIN) install save2gdf $(BIN) install heka2itx $(BIN) install save2aecg $(BIN) install save2scp $(BIN) -install bin/tt2trig $(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 uninstall remove: -rm $(BIN)/save2gdf -rm $(BIN)/heka2itx -rm $(BIN)/save2scp -rm $(BIN)/save2aecg -rm $(BIN)/ttl2trig #-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 $(TEMP_DIR)t2.log cat $(TEMP_DIR)t2.log $(TEMP_DIR)scp/redred/PFE103.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 $(DATA_DIR)t1.scp: $(TEMP_DIR)scp/redred/PFE103.scp $(COPY) $(TEMP_DIR)scp/redred/PFE103.scp $(DATA_DIR)t1.scp touch $(DATA_DIR)t1.scp #"$(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) $(DATA_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" $(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) $(DATA_DIR)t1.edf: $(TEMP_DIR)Osas2002plusQRS.edf cp "$(TEMP_DIR)Osas2002plusQRS.edf" $(DATA_DIR)t1.edf touch $(DATA_DIR)t1.edf asc: save2gdf ./save2gdf -f=ASCII t0.xxx $(TEMP_DIR)t1.asc bin: save2gdf ./save2gdf -f=BIN t0.xxx $(TEMP_DIR)t1.bin json: save2gdf ./save2gdf -JSON t0.xxx >$(TEMP_DIR)t1.xxx.json testbin: save2gdf $(DATA_DIR)t1.edf ./save2gdf -f=BIN $(DATA_DIR)t1.edf $(TEMP_DIR)t1.hdr ./save2gdf -f=GDF $(TEMP_DIR)t1.edf >$(TEMP_DIR)t1.edf.json ./save2gdf -f=BIN $(TEMP_DIR)t1.hdr $(TEMP_DIR)t2.hdr ./save2gdf -f=GDF $(TEMP_DIR)t2.hdr $(TEMP_DIR)t2.gdf testscp: save2gdf $(DATA_DIR)t1.scp # test converting SCP data ./save2gdf -f=HL7 $(DATA_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 $(DATA_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: $(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 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 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 biosig4c++-1.3.0/Makefile.win32000066400000000000000000000672371175724200100157630ustar00rootroot00000000000000####### 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 ############################################################# distclean: -$(DELETE) *.a -$(DELETE) eventcodes.i -$(DELETE) *.o -$(DELETE) *.lib -$(DELETE) *.so -$(DELETE) *.so.* -$(DELETE) *.mex* -$(DELETE) *.oct -$(DELETE) t5.scp t6.scp save2gdf gztest test_scp_decode biosig_server biosig_client -$(DELETE) t?.[bge]df* t?.hl7* t?.scp* t?.cfw* t?.gd1* t?.*.gz *.fil $(TEMP_DIR)/t1.* -$(DELETE) python/swig_wrap.* python/biosig.py* python/_biosig.so -$(DELETE) QMakefile -$(DELETE) win32/*.a -$(DELETE) win32/*.lib -$(DELETE) win32/libbiosig.* -$(DELETE) win32/*.obj -$(DELETE) win32/*.exe -$(DELETE) -rf win32/zlib -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 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 biosig4c++-1.3.0/README000066400000000000000000000123041175724200100142230ustar00rootroot00000000000000Introduction: --------------- The aim of this repository is providing a C/C++ software library for biomedical signal processing. This library is called "BioSig for C/C++" and is complementary to "BioSig for Octave and Matlab". BioSig4C++ provides several tools: (1) "libbiosig" provides a library for accessing different dataformats. The supported data formats are listed here: http://pub.ist.ac.at/~schloegl/biosig/TESTED The following DEFINES are recommended and require: -D=WITH_CHOLMOD used for re-referencing of data, REQUIREMENT: cholmod from libsuitesparse -D=WITH_ZLIB used to handle gzip-ped files, REQUIREMENT: zlib (http://zlib.net/) -D=WITH_GSL provides interface to GSL, REQUIREMENT: GNU Scientific Library (GSL), -D=WITH_FEF includes support for FEF-format from CNSystems (fails with MinGW) -D=WITH_FAMOS includes (partial) support for FAMOS format -D=__4HAERTEL__ support for special flavor of FAMOS format (experimental) Other flags are used for experimental development -D=WITH_DICOM, -D=WITH_GDCM experimental DICOM support -D=WITH_LIBXML2 experimental: tinyxml is replaced by libxml2 If some libraries are not available on your system, remove the corresponding DEFINES in Makefile. (2) "save2gdf" is a converter between different file formats, including but not limited to SCP-ECG(EN1064), HL7aECG (FDA-XML), GDF, EDF, BDF, CWFB. save2gdf can be also used to upload or retrieve data from a bscs server. (3) "mexSLOAD" is a MEX-interface for Octave and Matlab for details see mex/README (4) "biosig4python" is an interface to python. Requirement: python, python-dev, python-numpy, swig (http://www.swig.org/) for Debian/Ubuntu: sudo aptitude install python python-dev python-numpy swig see ./python/example.py and ./python/demo.py for more information Interfaces to other languages (including Java, PHP, Perl, Ruby and TCL) are also provided through SWIG. However, these are very experimental (5) SigViewer Requirement: qmake, Qt4 (6) Precompiled binaries for Win32 win32/save2gdf.exe binary converter win32/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 (7) MathLink interface to Mathematica see ../mma/ for more details. 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 Open Issue(s) of the SCP-ECG <-> HL7aECG converter: --------------------------------------------------- The following fields of SCP-ECG are not converted to HL7. = Mandatory fields (prEN1064:2007 p.18, chp 5.4.3.1) not propagated to HL7: - time zone information, (tag34, section 1) - "ID of acquiring device" (tag14, section 1) = "Highly recommended" fields (prEN1064:2007 p.18, chp 5.4.3.1) not propagated to HL7: - "ID of analysing device", Patient first name, = Other fields of the SCP-ECG standard, - section 1: blood pressure, medication, etc - section 4 (QRS location), 7 (global measurements), 8-11 (interpretative statements) The following fields of HL7aECG are not converted to SCP-ECG. - study, treatment group, clinical trial, clinical trial protocol, trial sponsor, investigator etc. 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 $Id$ Copyright (C) 2005,2006,2007,2008,2009,2010,2012 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig4c++-1.3.0/THANKS000066400000000000000000000003301175724200100142520ustar00rootroot00000000000000Thanks 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 biosig4c++-1.3.0/XMLParser/000077500000000000000000000000001175724200100151605ustar00rootroot00000000000000biosig4c++-1.3.0/XMLParser/tinystr.cpp000066400000000000000000000047131175724200100174050ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/XMLParser/tinystr.h000066400000000000000000000200061175724200100170430ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/XMLParser/tinyxml.cpp000066400000000000000000001321601175724200100173730ustar00rootroot00000000000000/* 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; } #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; 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; } biosig4c++-1.3.0/XMLParser/tinyxml.h000066400000000000000000002030621175724200100170400ustar00rootroot00000000000000/* 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 by Alois Schlögl Apr 6, 2009: add support for zlib-compressed (gzipped) XML data Jan 2011: update to latest TinyXML $Id: tinyxml.h,v 1.6 2009/04/15 20:31:54 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. */ #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4530 ) #pragma warning( disable : 4786 ) #endif #include #include #include #include #include #ifdef WITH_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 #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/ ./save2gdf -f=GDF $1 $2 $3 $4 $5 $6 $7 biosig4c++-1.3.0/biosig-dev.h000066400000000000000000000442751175724200100155600ustar00rootroot00000000000000/* % % $Id: biosig-dev.h,v 1.17 2009/04/08 12:49:54 schloegl Exp $ % Copyright (C) 2005,2006,2007,2008,2009,2011 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 **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ #ifndef __BIOSIG_INTERNAL_H__ #define __BIOSIG_INTERNAL_H__ #include "biosig.h" #include #include #include #include #include #ifdef __WIN32__ #define FILESEP '\\' char *getlogin (void); char *strndup (char const *s, size_t n); #else #define FILESEP '/' #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(__MINGW32__) /* use local version because MINGW does not provide byteswap.h */ # define __BIG_ENDIAN 4321 # define __LITTLE_ENDIAN 1234 # define __BYTE_ORDER __LITTLE_ENDIAN #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__) # include # 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 # define bswap_16(x) CFSwapInt16(x) # define bswap_32(x) CFSwapInt32(x) # define bswap_64(x) CFSwapInt64(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(__MINGW32__) || 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 #if !defined(bswap_16) || !defined(bswap_32) || !defined(bswap_64) #error SWAP operation not available #endif #ifdef __cplusplus EXTERN_C { #endif #if __BYTE_ORDER == __BIG_ENDIAN #define l_endian_u16(x) ((uint16_t)bswap_16((uint16_t)(x))) #define l_endian_u32(x) ((uint32_t)bswap_32((uint32_t)(x))) #define l_endian_u64(x) ((uint64_t)bswap_64((uint64_t)(x))) #define l_endian_i16(x) ((int16_t)bswap_16((int16_t)(x))) #define l_endian_i32(x) ((int32_t)bswap_32((int32_t)(x))) #define l_endian_i64(x) ((int64_t)bswap_64((int64_t)(x))) float l_endian_f32(float x); double l_endian_f64(double x); #define b_endian_u16(x) ((uint16_t)(x)) #define b_endian_u32(x) ((uint32_t)(x)) #define b_endian_u64(x) ((uint64_t)(x)) #define b_endian_i16(x) ((int16_t)(x)) #define b_endian_i32(x) ((int32_t)(x)) #define b_endian_i64(x) ((int64_t)(x)) #define b_endian_f32(x) ((float)(x)) #define b_endian_f64(x) ((double)(x)) #elif __BYTE_ORDER==__LITTLE_ENDIAN #define l_endian_u16(x) ((uint16_t)(x)) #define l_endian_u32(x) ((uint32_t)(x)) #define l_endian_u64(x) ((uint64_t)(x)) #define l_endian_i16(x) ((int16_t)(x)) #define l_endian_i32(x) ((int32_t)(x)) #define l_endian_i64(x) ((int64_t)(x)) #define l_endian_f32(x) ((float)(x)) #define l_endian_f64(x) ((double)(x)) #define b_endian_u16(x) ((uint16_t)bswap_16((uint16_t)(x))) #define b_endian_u32(x) ((uint32_t)bswap_32((uint32_t)(x))) #define b_endian_u64(x) ((uint64_t)bswap_64((uint64_t)(x))) #define b_endian_i16(x) ((int16_t)bswap_16((int16_t)(x))) #define b_endian_i32(x) ((int32_t)bswap_32((int32_t)(x))) #define b_endian_i64(x) ((int64_t)bswap_64((int64_t)(x))) float b_endian_f32(float x); double b_endian_f64(double x); #endif /* __BYTE_ORDER */ #if !defined(__sparc__) && !defined(__ia64__) // if misaligned data words can be handled #define leu16p(i) l_endian_u16(*(uint16_t*)(i)) #define lei16p(i) l_endian_i16(*( int16_t*)(i)) #define leu32p(i) l_endian_u32(*(uint32_t*)(i)) #define lei32p(i) l_endian_i32(*( int32_t*)(i)) #define leu64p(i) l_endian_u64(*(uint64_t*)(i)) #define lei64p(i) l_endian_i64(*( int64_t*)(i)) #define lef32p(i) l_endian_f32(*(float*)(i)) #define lef64p(i) l_endian_f64(*(double*)(i)) #define beu16p(i) b_endian_u16(*(uint16_t*)(i)) #define bei16p(i) b_endian_i16(*( int16_t*)(i)) #define beu32p(i) b_endian_u32(*(uint32_t*)(i)) #define bei32p(i) b_endian_i32(*( int32_t*)(i)) #define beu64p(i) b_endian_u64(*(uint64_t*)(i)) #define bei64p(i) b_endian_i64(*( int64_t*)(i)) #define bef32p(i) b_endian_f32(*(float*)(i)) #define bef64p(i) b_endian_f64(*(double*)(i)) #define leu16a(i,r) (*(uint16_t*)(r) = l_endian_u16(i)) #define lei16a(i,r) (*( int16_t*)(r) = l_endian_i16(i)) #define leu32a(i,r) (*(uint32_t*)(r) = l_endian_u32(i)) #define lei32a(i,r) (*( int32_t*)(r) = l_endian_i32(i)) #define leu64a(i,r) (*(uint64_t*)(r) = l_endian_u64(i)) #define lei64a(i,r) (*( int64_t*)(r) = l_endian_i64(i)) #define lef32a(i,r) (*( float*)(r) = l_endian_f32(i)) #define lef64a(i,r) (*( double*)(r) = l_endian_f64(i)) #define beu16a(i,r) (*(uint16_t*)(r) = b_endian_u16(i)) #define bei16a(i,r) (*( int16_t*)(r) = b_endian_i16(i)) #define beu32a(i,r) (*(uint32_t*)(r) = b_endian_u32(i)) #define bei32a(i,r) (*( int32_t*)(r) = b_endian_i32(i)) #define beu64a(i,r) (*(uint64_t*)(r) = b_endian_u64(i)) #define bei64a(i,r) (*( int64_t*)(r) = b_endian_i64(i)) #define bef32a(i,r) (*( float*)(r) = b_endian_f32(i)) #define bef64a(i,r) (*( double*)(r) = b_endian_f64(i)) #else /* SPARC,IA64: missing alignment must be explicitly handled */ uint16_t leu16p(uint8_t* i); int16_t lei16p(uint8_t* i); uint32_t leu32p(uint8_t* i); int32_t lei32p(uint8_t* i); uint64_t leu64p(uint8_t* i); int64_t lei64p(uint8_t* i); float lef32p(uint8_t* i); double lef64p(uint8_t* i); uint16_t beu16p(uint8_t* i); int16_t bei16p(uint8_t* i); uint32_t beu32p(uint8_t* i); int32_t bei32p(uint8_t* i); uint64_t beu64p(uint8_t* i); int64_t bei64p(uint8_t* i); float bef32p(uint8_t* i); double bef64p(uint8_t* i); void leu16a(uint16_t i, uint8_t* r); void lei16a( int16_t i, uint8_t* r); void leu32a(uint32_t i, uint8_t* r); void lei32a( int32_t i, uint8_t* r); void leu64a(uint64_t i, uint8_t* r); void lei64a( int64_t i, uint8_t* r); void lef32a( float i, uint8_t* r); void lef64a( double i, uint8_t* r); void beu16a(uint16_t i, uint8_t* r); void bei16a( int16_t i, uint8_t* r); void beu32a(uint32_t i, uint8_t* r); void bei32a( int32_t i, uint8_t* r); void beu64a(uint64_t i, uint8_t* r); void bei64a( int64_t i, uint8_t* r); void bef32a( float i, uint8_t* r); void bef64a( double i, uint8_t* r); #endif #ifdef __cplusplus } #endif #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 #ifndef isnan # define isnan(a) (a!=a) #endif #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #define fix(m) (m<0 ? ceil(m) : floor(m)) /* 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 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef VERBOSE_LEVEL extern int VERBOSE_LEVEL; // used for debugging #endif /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /* This structure defines the fields used for "VitalFEF" */ typedef struct { void *pduType; void *SAS; } ASN1_t; /* This structure defines the fields used for "Annotated ECG" */ typedef struct { 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; } aECG_TYPE; /****************************************************************************/ /** **/ /** INTERNAL FUNCTIONS **/ /** **/ /****************************************************************************/ /* file access wrapper: use ZLIB (if available) or STDIO */ #ifdef __cplusplus EXTERN_C { #endif 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, long offset, int whence ); long 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); extern const uint16_t GDFTYP_BITS[]; extern const char *LEAD_ID_TABLE[]; uint16_t CRCEvaluate(uint8_t* datablock, uint32_t datalength); int16_t CRCCheck(uint8_t* datablock, uint32_t datalength); #ifndef _WIN32 int strcmpi(const char* str1, const char* str2); #endif int strncmpi(const char* str1, const char* str2, size_t n); int u32cmp(const void *a, const void *b); //double strtod (const char *nptr, char **endptr); // no locale dependency /* some important functions used internally, the interface for these functios is a bit clumsy and is (therefore) not */ void struct2gdfbin(HDRTYPE *hdr); int gdfbin2struct(HDRTYPE *hdr); /* 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); void rawEVT2hdrEVT(HDRTYPE *hdr); /* rawEVT2hdrEVT and hdrEVT2rawEVT convert between streamed event table and the structure HDRTYPE.EVENT. ------------------------------------------------------------------------*/ int NumberOfChannels(HDRTYPE *hdr); /* 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 ------------------------------------------------------------------------*/ void FreeGlobalEventCodeTable(); void FreeTextEvent(HDRTYPE* hdr,size_t N_EVENT, char* annotation); /*------------------------------------------------------------------------ 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. ------------------------------------------------------------------------*/ size_t sread_raw(size_t START, size_t LEN, HDRTYPE* hdr, char flag); /* sread_raw: LEN data segments are read from file associated with hdr, starting from segment START. A sufficient amount of memory is (re-)allocated in hdr->AS.rawdata and the data is copied into hdr->AS.rawdata Typically, LEN*hdr->AS.bpb bytes are read and stored in its native format. 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. 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); /* bpb8_collapsed_rawdata computes the bits per block when rawdata is collapsed --------------------------------------------------------------- */ #ifdef __cplusplus } #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #endif /* BIOSIG_INTERNAL_H */ biosig4c++-1.3.0/biosig-network.c000066400000000000000000000554461175724200100164700ustar00rootroot00000000000000/* $Id: biosig-network.c,v 1.12 2009-04-08 15:56:00 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 "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=%016lx TXT=%s\n",ID,txt); } /* 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=%016lx 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 #if 0 // IPv4 and IPv6 int status; struct addrinfo hints, *servinfo, *p; char s[INET6_ADDRSTRLEN]; memset(&hints, 0, sizeof hints); // make sure the struct is empty hints.ai_family = AF_UNSPEC; // don't care IPv4 or IPv6 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets // get ready to connect status = getaddrinfo(hostname, "SERVER_PORT", &hints, &servinfo); if(status) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status)); return(BSCS_UNKNOWN_HOST); } if(servinfo==NULL) return(BSCS_UNKNOWN_HOST); // loop through all the results and connect to the first we can for(p = servinfo; 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) { #ifndef _WIN32 close(sd); #else closesocket(sd); WSACleanup(); #endif perror("client: connect"); continue; } break; } if (p == NULL) { fprintf(stderr, "client: failed to connect\n"); return(BSCS_CANNOT_CONNECT); } inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s, sizeof s); printf("client: connecting to %s\n", s); freeaddrinfo(servinfo); // 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 = b_endian_u32(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 = b_endian_u32(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"); #if __LP64__ fprintf(fid,"bscs://%s/%016lx\n",B4C_HOSTNAME,B4C_ID); #else fprintf(fid,"bscs://%s/%016Lx\n",B4C_HOSTNAME,B4C_ID); #endif 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: %16lx %16lx\n",*ID,msg.LOAD); msg.LEN = b_endian_u32(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 = b_endian_u32(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"BSCS_OPEN %i:%i: ID=%16Lx LEN=%x STATE=0x%08x\n",s,count,*ID,msg.LEN,b_endian_u32(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 = l_endian_u64(*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= %08x %08x len=%i\n",b_endian_u32(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: %08x \n",msg.STATE); msg.LEN = b_endian_u32(0); if (VERBOSE_LEVEL>8) fprintf(stdout,"close2: %08x %i %i\n",msg.STATE,sizeof(msg),msg.LEN); s = send(sd, TC &msg, 8, 0); if (VERBOSE_LEVEL>8) fprintf(stdout,"close3: %08x %i\n",msg.STATE,s); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = b_endian_u32(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"s=%i state= %08x len=%i %i %08x\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= %08x len=%i\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 = b_endian_u32(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 %i %08x\n",hdr->HeadLen,s,count,msg.STATE); size_t LEN = b_endian_u32(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 = b_endian_u32(len); if (VERBOSE_LEVEL>8) fprintf(stdout,"SND DAT %i %08x\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 %i %08x %i \n",len,msg.STATE,s); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = b_endian_u32(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"SND DAT RPLY %i %08x \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=%i\n",len); msg.STATE = BSCS_VERSION_01 | BSCS_SEND_EVT | STATE_OPEN_WRITE | BSCS_NO_ERROR; msg.LEN = b_endian_u32(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: %08x len=%i\n",msg.STATE,len); // wait for reply ssize_t count = recv(sd, TC &msg, 8, 0); LEN = b_endian_u32(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>8) fprintf(stdout,"write evt2: %08x len=%i count=%i\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 = b_endian_u32(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 = b_endian_u32(8); *(uint32_t*)(msg.LOAD+4) = l_endian_u32(start); *(uint32_t*)(msg.LOAD+0) = l_endian_u32(length); int s = send(sd, TC &msg, 16, 0); ssize_t count = recv(sd, TC &msg, 8, 0); LEN = b_endian_u32(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: %i %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: %i %i\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 = b_endian_u32(0); int s = send(sd, TC &msg, 8, 0); // wait for reply s = recv(sd, TC &msg, 8, 0); LEN = b_endian_u32(msg.LEN); if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ EVT: %i %i \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); // TODO: replace this function because it is inefficient } if (VERBOSE_LEVEL>8) fprintf(stdout,"REQ EVT: %i %i \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 = b_endian_u32(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,"%i LEN=%i %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; *(uint64_t*)&msg.LOAD = l_endian_u64(ID); LEN = BSCS_ID_BITLEN>>3; msg.LEN = b_endian_u32(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 = b_endian_u32(msg.LEN); SERVER_STATE = msg.STATE & STATE_MASK; if (VERBOSE_LEVEL>7) fprintf(stdout,"get file (3) %i\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) %i\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 = b_endian_u32(0); int s = send(sd, TC &msg, 8, 0); } biosig4c++-1.3.0/biosig-network.h000066400000000000000000000233031175724200100164600ustar00rootroot00000000000000/* % $Id: biosig-network.h,v 1.5 2009/03/23 22:01:51 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/ 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 #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 #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<>3)] __attribute__ ((aligned (8))); // must fit at leat 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__ */ biosig4c++-1.3.0/biosig.c000066400000000000000000015006761175724200100150020ustar00rootroot00000000000000/* $Id$ Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2012 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 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 very alloc() */ #include #include #include #include #include #include #include #ifdef WITH_CURL # include #endif #include "biosig-dev.h" #include "biosig-network.h" #ifdef _WIN32 #include #define FILESEP '\\' #else #include #include #include #define FILESEP '/' #endif char * xgethostname (void); int B4C_ERRNUM = 0; const char *B4C_ERRMSG; #ifdef WITH_CHOLMOD #ifdef __APPLE__ #include #else #include #endif 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 VERBOSE_LEVEL int VERBOSE_LEVEL = 0; #endif #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_alpha_read (HDRTYPE* hdr); void sopen_FAMOS_read (HDRTYPE* hdr); int sclose_HL7aECG_write(HDRTYPE* hdr); int sopen_trc_read (HDRTYPE* hdr); int sopen_unipro_read (HDRTYPE* hdr); int sopen_fef_read(HDRTYPE* hdr); void sopen_heka(HDRTYPE* hdr,FILE *fid); int sclose_fef_read(HDRTYPE* hdr); int sopen_zzztest(HDRTYPE* hdr); #ifdef WITH_HDF int sopen_hdf5(HDRTYPE *hdr); #endif #ifdef WITH_MATIO int sopen_matlab(HDRTYPE *hdr); #endif #ifdef WITH_DICOM int sopen_dicom_read(HDRTYPE* hdr); #endif #ifdef __cplusplus } #endif const uint16_t GDFTYP_BITS[] = { 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 /* 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) ""}; /* --------------------------------------------------- * * Global Event Code Table * * --------------------------------------------------- */ static uint8_t GLOBAL_EVENTCODES_ISLOADED = 0; struct global_t { uint16_t LenCodeDesc; uint16_t *CodeIndex; const char **CodeDesc; char *EventCodesTextBuffer; } Global; // 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); B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "Computing LCM failed."; } return((uint32_t)A64); }; #if __BYTE_ORDER == __BIG_ENDIAN float l_endian_f32(float x) #elif __BYTE_ORDER == __LITTLE_ENDIAN float b_endian_f32(float x) #endif { union { float f32; uint32_t u32; } b1; b1.f32 = x; b1.u32 = bswap_32(b1.u32); return(b1.f32); } #if __BYTE_ORDER == __BIG_ENDIAN double l_endian_f64(double x) #elif __BYTE_ORDER == __LITTLE_ENDIAN double b_endian_f64(double x) #endif { union { double f64; uint64_t u64; } b1; b1.f64 = x; b1.u64 = bswap_64(b1.u64); return(b1.f64); } #ifndef leu16p /* SPARC, ia64: missing alignment must be explicitly handled */ uint16_t leu16p(uint8_t* i) { // decode little endian uint16 pointer return ((*i) + ((uint16_t)*(i+1) << 8)); } int16_t lei16p(uint8_t* i) { // decode little endian int16 pointer uint16_t o = ((*i) + ((uint16_t)*(i+1) << 8)); return(*(int16_t*)(&o)); } uint32_t leu32p(uint8_t* i) { // decode little endian uint32 pointer uint32_t o=0; char k; for (k=0; k<4; k++) o += ((uint32_t)*(i+k))<<(k*8); return(o); } int32_t lei32p(uint8_t* i) { // decode little endian int32 pointer uint32_t o=0; char k; for (k=0; k<4; k++) o += ((uint32_t)*(i+k))<<(k*8); return(*(int32_t*)(&o)); } uint64_t leu64p(uint8_t* i) { // decode little endian uint64 pointer uint64_t o=0; char k; for (k=0; k<8; k++) o += ((uint64_t)*(i+k))<<(k*8); return(o); } int64_t lei64p(uint8_t* i) { // decode little endian int64 pointer uint64_t o=0; char k; for (k=0; k<8; k++) o += ((uint64_t)*(i+k))<<(k*8); return(*(int64_t*)(&o)); } float lef32p(uint8_t* i) { // decode little endian float pointer uint32_t o; char k; for (k=0, o=0; k<4; k++) o += ((uint32_t)*(i+k))<<(k*8); return(*(float*)(&o)); } double lef64p(uint8_t* i) { // decode little endian double pointer uint64_t o=0; char k; for (k=0; k<8; k++) o += ((uint64_t)*(i+k))<<(k*8); return(*(double*)(&o)); } uint16_t beu16p(uint8_t* i) { // decode big endian uint16 pointer return (((uint16_t)*i<<8) + (*(i+1))); } int16_t bei16p(uint8_t* i) { // decode big endian int16 pointer uint16_t o = (((uint16_t)*i << 8) + (*(i+1))); return(*(int16_t*)(&o)); } uint32_t beu32p(uint8_t* i) { // decode big endian uint32 pointer uint32_t o=0; char k; for (k=0; k<4; k++) { o<<=8; o += *(i+k); } return(o); } int32_t bei32p(uint8_t* i) { // decode big endian int32 pointer uint32_t o=0; char k; for (k=0; k<4; k++) { o<<=8; o += *(i+k); } return(*(int32_t*)(&o)); } uint64_t beu64p(uint8_t* i) { // decode big endian uint64 pointer uint64_t o=0; char k; for (k=0; k<8; k++) { o<<=8; o += *(i+k); } return(o); } int64_t bei64p(uint8_t* i) { // decode big endian int64 pointer uint64_t o=0; char k; for (k=0; k<8; k++){ o<<=8; o += *(i+k); } return(*(int64_t*)(&o)); } float bef32p(uint8_t* i) { // decode big endian float pointer uint32_t o=0; char k; for (k=0; k<4; k++) { o<<=8; o += *(i+k); } return(*(float*)(&o)); } double bef64p(uint8_t* i) { // decode big endian double pointer uint64_t o=0; char k; for (k=0; k<8; k++) { o<<=8; o += *(i+k); } return(*(double*)(&o)); } void leu16a(uint16_t i, uint8_t* r) { i = l_endian_u16(i); memcpy(r, &i, sizeof(i)); } void lei16a( int16_t i, uint8_t* r) { i = l_endian_i16(i); memcpy(r, &i, sizeof(i)); } void leu32a(uint32_t i, uint8_t* r) { i = l_endian_u32(i); memcpy(r, &i, sizeof(i)); } void lei32a( int32_t i, uint8_t* r) { i = l_endian_i32(i); memcpy(r, &i, sizeof(i)); } void leu64a(uint64_t i, uint8_t* r) { i = l_endian_u64(i); memcpy(r, &i, sizeof(i)); } void lei64a( int64_t i, uint8_t* r) { i = l_endian_i64(i); memcpy(r, &i, sizeof(i)); } void lef32a( float i, uint8_t* r) { uint32_t i32 = l_endian_u32(*(uint32_t*)(&i)); memcpy(r, &i32, sizeof(i32)); } void lef64a( double i, uint8_t* r) { uint64_t i64 = l_endian_u64(*(uint64_t*)(&i)); memcpy(r, &i64, sizeof(i64)); } void beu16a(uint16_t i, uint8_t* r) { i = b_endian_u16(i); memcpy(r, &i, sizeof(i)); }; void bei16a( int16_t i, uint8_t* r) { i = b_endian_i16(i); memcpy(r, &i, sizeof(i)); } void beu32a(uint32_t i, uint8_t* r) { i = b_endian_u32(i); memcpy(r, &i, sizeof(i)); } void bei32a( int32_t i, uint8_t* r) { i = b_endian_i32(i); memcpy(r, &i, sizeof(i)); } void beu64a(uint64_t i, uint8_t* r) { i = b_endian_u64(i); memcpy(r, &i, sizeof(i)); } void bei64a( int64_t i, uint8_t* r) { i = b_endian_i64(i); memcpy(r, &i, sizeof(i)); } void bef32a( float i, uint8_t* r) { uint32_t i32 = b_endian_u32(*(uint32_t*)(&i)); memcpy(r, &i32, sizeof(i32)); } void bef64a( double i, uint8_t* r) { uint64_t i64 = b_endian_u64(*(uint64_t*)(&i)); memcpy(r, &i64, sizeof(i64)); } #endif 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 typedef uint64_t iType; #if __BYTE_ORDER == __BIG_ENDIAN if (FLAG_SWAP) { unsigned k; for (k=len; k < sizeof(iType); buf[k++]=0); *(iType*)buf = bswap_64(*(iType*)buf); } else *(iType*)buf >>= (sizeof(iType)-len)*8; #elif __BYTE_ORDER == __LITTLE_ENDIAN if (FLAG_SWAP) *(iType*)buf = bswap_64(*(iType*)buf) >> (sizeof(iType)-len)*8; else { unsigned k; for (k=len; k < sizeof(iType); 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-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) )); } /* 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 first n characters of two strings, ignore case */ int strncmpi(const char* str1, const char* str2, size_t n) { size_t k=0; char r=0; while (r==0 && str1[k]!='\0' && str2[k]!='\0' && (k 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]); } char* PhysDim(uint16_t PhysDimCode, char *PhysDim) { // 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); } 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); 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); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ gdf_time tm_time2gdf_time(struct tm *t){ /* 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 */ 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); } int gdf_time2tm_time_r(gdf_time t, struct tm *t3) { /* 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 // 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;} t3->tm_year = y-1900; t3->tm_mon = (int)m-1; t3->tm_mday = (int)d; t3->tm_hour = (int)(floor (s / 3600)); s = s - 3600 * t3->tm_hour; t3->tm_min = (int)(floor (s / 60)); t3->tm_sec = (int)(s) - 60 * t3->tm_min; //t3->tm_gmtoff = 3600; return(0); } /* 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, long 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 return(fseek(hdr->FILE.FID,offset,whence)); } long int 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__ 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__ *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__ *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 ------------------------------------------------------------------------*/ typedef struct { uint32_t POS; uint32_t DUR; uint16_t TYP; uint16_t CHN; } entry_t; int compare_eventpos(const void *e1, const void *e2) { return(((entry_t*)(e1))->POS - ((entry_t*)(e2))->POS); } void sort_eventtable(HDRTYPE *hdr) { size_t k; entry_t *entry = (entry_t*) calloc(hdr->EVENT.N,sizeof(entry_t)); if ((hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL)) for (k=0; kEVENT.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; kEVENT.N;k++) { entry[k].TYP = hdr->EVENT.TYP[k]; entry[k].POS = hdr->EVENT.POS[k]; } qsort(entry,hdr->EVENT.N,sizeof(entry_t),&compare_eventpos); if ((hdr->EVENT.DUR != NULL) && (hdr->EVENT.CHN != NULL)) for (k=0; kEVENT.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; kEVENT.N;k++) { hdr->EVENT.TYP[k] = entry[k].TYP; hdr->EVENT.POS[k] = entry[k].POS; } free(entry); } /*------------------------------------------------------------------------ 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 (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)); 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]; 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 ------------------------------------------------------------------------*/ 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] = l_endian_u32(hdr->EVENT.POS[k32u]); hdr->EVENT.TYP[k32u] = l_endian_u16(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] = l_endian_u32(hdr->EVENT.DUR[k32u]); hdr->EVENT.CHN[k32u] = l_endian_u16(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); } } /*------------------------------------------------------------------------ Load Table of Event Codes ------------------------------------------------------------------------*/ void FreeGlobalEventCodeTable() { // if (VERBOSE_LEVEL>8) fprintf(stdout,"FreeGlobalEventTable(start)%i\n",GLOBAL_EVENTCODES_ISLOADED); Global.LenCodeDesc = 0; if (Global.EventCodesTextBuffer) free(Global.EventCodesTextBuffer); Global.EventCodesTextBuffer = NULL; if (Global.CodeDesc) free(Global.CodeDesc); Global.CodeDesc = NULL; if (Global.CodeIndex) free(Global.CodeIndex); Global.CodeIndex = NULL; GLOBAL_EVENTCODES_ISLOADED = 0; // if (VERBOSE_LEVEL>8) fprintf(stdout,"FreeGlobalEventTable(end)%i\n",GLOBAL_EVENTCODES_ISLOADED); } void LoadGlobalEventCodeTable() { size_t N = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"LoadGlobalEventTable(start)%i\n",GLOBAL_EVENTCODES_ISLOADED); if (GLOBAL_EVENTCODES_ISLOADED) return; // table is already loaded atexit(&FreeGlobalEventCodeTable); // TODO: move user-specified events into hdr Global.CodeDesc = NULL; Global.CodeIndex = NULL; Global.EventCodesTextBuffer = NULL; Global.LenCodeDesc = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"LoadGlobalEventTable(101)%i %i\n",GLOBAL_EVENTCODES_ISLOADED,Global.LenCodeDesc); while (ETD[N].desc != NULL) N++; N += 256; // make sure there is enough space for free text events Global.CodeIndex = (uint16_t*)realloc(Global.CodeIndex, N*sizeof(uint16_t)); Global.CodeDesc = (const char**)realloc(Global.CodeDesc, N*sizeof(char*)); while (ETD[Global.LenCodeDesc].desc != NULL) { Global.CodeDesc[Global.LenCodeDesc] =(char*) ETD[Global.LenCodeDesc].desc; Global.CodeIndex[Global.LenCodeDesc] = ETD[Global.LenCodeDesc].typ; Global.LenCodeDesc++; } GLOBAL_EVENTCODES_ISLOADED = 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"LoadGlobalEventTable(end)%i\n",Global.LenCodeDesc); } /*------------------------------------------------------------------------ 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, char* annotation) { /* free text annotations encoded as user specific events (codes 1-255) */ 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; } // First, compare text with any global event description if (!GLOBAL_EVENTCODES_ISLOADED) LoadGlobalEventCodeTable(); for (k=0; k255) { if (!strcmp(Global.CodeDesc[k], annotation)) { // annotation is already a globally defined event hdr->EVENT.TYP[N_EVENT] = Global.CodeIndex[k]; 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.TYP[N_EVENT] = hdr->EVENT.LenCodeDesc; hdr->EVENT.CodeDesc[hdr->EVENT.LenCodeDesc] = annotation; hdr->EVENT.LenCodeDesc++; } if (hdr->EVENT.LenCodeDesc > 255) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "Maximum number of user-defined events (256) exceeded"; } } /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** 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 set the 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); if ((LittleEndian) && (__BYTE_ORDER == __BIG_ENDIAN)) { B4C_ERRNUM = B4C_ENDIAN_PROBLEM; B4C_ERRMSG = "Panic: mixed results on Endianity test."; return(NULL); } if ((!LittleEndian) && (__BYTE_ORDER == __LITTLE_ENDIAN)) { B4C_ERRNUM = B4C_ENDIAN_PROBLEM; B4C_ERRMSG = "Panic: mixed results on Endianity test."; return(NULL); } 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.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 = (gdf_time)0; hdr->tzmin = 0; hdr->ID.Equipment = *(uint64_t*) & "b4c_1.2 "; 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; /* TODO: check whether memory leak in glibc's getpwuid is fixed. for details see: http://sourceware.org/bugzilla/show_bug.cgi?id=14122 struct passwd *p = NULL; //getpwuid(geteuid()); if (p != NULL) username = p->pw_gecos; */ if (username == NULL) username = getlogin(); 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) { // TODO: replace gethostbyname by getaddrinfo (for IPv6) struct hostent *host = gethostbyname(localhostname); if (host) memcpy(hdr->IPaddr, host->h_addr, host->h_length); 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.CNT32 = 0; // assume 16-bit CNT format 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++) { uint32_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)); } else { hdr->EVENT.POS = NULL; hdr->EVENT.TYP = NULL; hdr->EVENT.DUR = NULL; hdr->EVENT.CHN = NULL; } // initialize specialized fields hdr->aECG = NULL; hdr->AS.bci2000 = NULL; 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 (hdr->aECG != NULL) { if (((aECG_TYPE*)hdr->aECG)->Section8.NumberOfStatements>0) free(((aECG_TYPE*)hdr->aECG)->Section8.Statements); if (((aECG_TYPE*)hdr->aECG)->Section11.NumberOfStatements>0) free(((aECG_TYPE*)hdr->aECG)->Section11.Statements); free(hdr->aECG); } 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); 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 (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; } /* 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,"[GETFILETYPE 101]! %i\n", hdr->HeadLen); 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<=42)) { 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>=41.0) & (U32 ==1944)) hdr->TYPE = ACQ; if (hdr->TYPE == ACQ) { hdr->HeadLen = U32; // length of fixed header return(hdr); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"[GETFILETYPE 200] %x %x!\n",leu16p(hdr->AS.Header),leu16p(hdr->AS.Header+154)); if (hdr->TYPE != unknown) return(hdr); else if (beu32p(hdr->AS.Header) == 0x41424620) { // 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(Header1,"ABF2",4)) { else if (beu32p(hdr->AS.Header) == 0x41424632) { hdr->TYPE = ABF; hdr->VERSION = beu32p(hdr->AS.Header+4); } 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,"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,"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,"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; 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) == b_endian_u32(0x7f454c46)) hdr->TYPE = ELF; else if ( (hdr->HeadLen > 14) && !memcmp(Header1,"Embla data file",15)) hdr->TYPE = EMBLA; 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 = strndup((char*)hdr->AS.Header+8,8); hdr->VERSION = (float)atol(tmp); free(tmp); } else if (!memcmp(Header1,"fLaC",4)) hdr->TYPE = FLAC; else if (!memcmp(Header1,"GDF",3) && (hdr->HeadLen > 255)) { hdr->TYPE = GDF; char *tmp = strndup((char*)hdr->AS.Header+3,5); hdr->VERSION = strtod(tmp,NULL); free(tmp); } 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",4)) 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 (!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 ( (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,"NEX1",4)) 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,"SXDF",4)) hdr->TYPE = OpenXDF; else if (!memcmp(Header1,"PLEX",4)) hdr->TYPE = PLEXON; 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 < 250) && ((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; hdr->VERSION = *(hdr->AS.Header+14)/10.0; } /* // 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 ((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 ((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 = strndup((char*)Header1+23,3); hdr->VERSION = strtod(tmp,NULL); free(tmp); } else if (!strncmp(Header1,"Serial number",13)) hdr->TYPE = ASCII_IBI; else if (!memcmp(Header1,MAGIC_NUMBER_Z,3)) hdr->TYPE = Z; 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 (!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,"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; } if (VERBOSE_LEVEL>9) fprintf(stdout,"[228] %i %s %s \n",hdr->TYPE,GetFileTypeString(hdr->TYPE),hdr->FileName); return(hdr); } const struct FileFormatStringTable_t FileFormatStringTable[] = { { unknown, "unknown" }, { alpha, "alpha" }, { ABF, "ABF" }, { ACQ, "ACQ" }, { ACR_NEMA, "ACR_NEMA" }, { AINF, "AINF" }, { AIFC, "AIFC" }, { AIFF, "AIFF" }, { ARFF, "ARFF" }, { ASCII, "ASCII" }, { ATES, "ATES" }, { ATF, "ATF" }, { AU, "AU" }, { 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" }, { EBS, "EBS" }, { EDF, "EDF" }, { EEG1100, "EEG1100" }, { EEProbe, "EEProbe" }, { EGI, "EGI" }, { EGIS, "EGIS" }, { ELF, "ELF" }, { EMBLA, "EMBLA" }, { ePrime, "ePrime" }, { ET_MEG, "ET-MEG" }, { ETG4000, "ETG4000" }, { EVENT, "EVENT" }, { EXIF, "EXIF" }, { FAMOS, "FAMOS" }, { FEF, "FEF" }, { FITS, "FITS" }, { FLAC, "FLAC" }, { GDF, "GDF" }, { GIF, "GIF" }, { GTF, "GTF" }, { GZIP, "GZIP" }, { HDF, "HDF" }, { HEKA, "HEKA" }, { HL7aECG, "HL7aECG" }, { 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" }, { native, "native" }, { NeuroLoggerHEX, "NeuroLoggerHEX"}, { NetCDF, "NetCDF" }, { NEX1, "NEX1" }, { NIFTI, "NIFTI" }, { NEURON, "NEURON" }, { OGG, "OGG" }, { PDP, "PDP" }, { RDF, "RDF" }, { RIFF, "RIFF" }, { SASXPT, "SAS_XPORT" }, { SCP_ECG, "SCP" }, { SIGIF, "SIGIF" }, { Sigma, "Sigma" }, { SMA, "SMA" }, { SND, "SND" }, { SPSS, "SPSS" }, { SQLite, "SQLite" }, { STATA, "STATA" }, { SVG, "SVG" }, { SYNERGY, "SYNERGY"}, { TIFF, "TIFF" }, { TMS32, "TMS32" }, { TMSiLOG, "TMSiLOG" }, { TRC, "TRC" }, { UNIPRO, "UNIPRO" }, { VRML, "VRML" }, { VTK, "VTK" }, { WAV, "WAV" }, { WG1, "Walter Graphtek" }, { WMF, "WMF" }, { 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,"GDFw 101 %i \n", hdr->HeadLen); /****** * 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 currently only tag=1 is used for storing user-specific events (i.e. free text annotations */ uint32_t TagNLen[] = {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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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>8) fprintf(stdout,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); 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,"GDFw101 %i %i %i\n",tag, hdr->HeadLen,TagNLen[1]); /* end */ if (hdr->TYPE==GDF) { hdr->VERSION = 2.22; if (hdr->HeadLen & 0x00ff) // in case of GDF v2, make HeadLen a multiple of 256. hdr->HeadLen = (hdr->HeadLen & 0xff00) + 256; } else if (hdr->TYPE==GDF1) { hdr->VERSION = 1.25; hdr->TYPE = GDF; } else if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw101 %i %i\n",hdr->HeadLen,TagNLen[1]); hdr->AS.Header = (uint8_t*) realloc(hdr->AS.Header, hdr->HeadLen); if (hdr->AS.Header == NULL) { B4C_ERRNUM = B4C_MEMORY_ALLOCATION_FAILED; return; } 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) = l_endian_u32( *(uint32_t*) (Header1+152) ); *(uint32_t*) (Header1+156) = l_endian_u32( *(uint32_t*) (Header1+156) ); *(uint32_t*) (Header1+160) = l_endian_u32( *(uint32_t*) (Header1+160) ); *(uint32_t*) (Header1+164) = l_endian_u32( *(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,"GDFw109 %i %x\n",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); /* 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; if (hdr->CHANNEL[k].LeadIdCode) tmpstr = LEAD_ID_TABLE[hdr->CHANNEL[k].LeadIdCode]; else tmpstr = hdr->CHANNEL[k].Label; len = strlen(tmpstr); 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; PhysDim(hdr->CHANNEL[k].PhysDimCode, tmp); len = strlen(tmp); if (hdr->VERSION < 1.9) memcpy(Header2+ 8*k2 + 96*NS, tmp, min(8,len)); else { memcpy(Header2+ 6*k2 + 96*NS, tmp, 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,"GDFw 444 %i %s\n", 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; } if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw tag2\n"); tag = 2; 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,"GDFw tag3 %i %i\n",tag, 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,"GDFw tag4\n"); /* tag = 4; if (TagNLen[tag]>0) { *(uint32_t*)(Header2) = l_endian_u32(tag + (TagNLen[tag]<<8)); // Tag=4 & Length of Tag 4 Header2 += 4; for (k=0; kNS; k++) { *(float*)(Header2 + 4*k) = l_endian_f32(hdr->CHANNEL[k].Orientation[0]); *(float*)(Header2 + 4*k + 4*hdr->NS) = l_endian_f32(hdr->CHANNEL[k].Orientation[1]); *(float*)(Header2 + 4*k + 8*hdr->NS) = l_endian_f32(hdr->CHANNEL[k].Orientation[2]); *(float*)(Header2 + 4*k +12*hdr->NS) = l_endian_f32(hdr->CHANNEL[k].Area); } Header2 += 4*sizeof(float)*hdr->NS; } */ if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw tag5\n"); tag = 5; 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]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw tag6\n"); tag = 6; 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]; } if (VERBOSE_LEVEL>7) fprintf(stdout,"GDFw tag7\n"); tag = 7; 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]; } while (Header2 < (hdr->AS.Header + hdr->HeadLen) ) { *Header2 = 0; Header2++; } 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,"[GDFBIN2STRUCT 202] #%i \n",hdr->NS); strncpy(tmp,(char*)(hdr->AS.Header+3),5); tmp[5]=0; if (VERBOSE_LEVEL>7) fprintf(stdout,"[GDFBIN2STRUCT 202] #%i Ver=<%s>\n",hdr->NS,tmp); hdr->VERSION = atof(tmp); if (VERBOSE_LEVEL>7) fprintf(stdout,"[GDFBIN2STRUCT 202] #%i Ver=<%s>\n",hdr->NS,tmp); hdr->NRec = lei64p(hdr->AS.Header+236); hdr->NS = leu16p(hdr->AS.Header+252); 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,"[GDFBIN2STRUCT 212] #%i Ver=%f\n", 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,"[202] FMT=%s Ver=%4.2f\n",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,"[203] FMT=%s Ver=%4.2f\n",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>8) fprintf(stdout,"[209] FMT=%s Ver=%4.2f\n",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 { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Error SOPEN(GDF); invalid version number."; return(B4C_ERRNUM); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[GDFBIN2STRUCT 242] #%i Ver=%f\n", hdr->NS, hdr->VERSION); if (hdr->HeadLen < (256u * (hdr->NS + 1u))) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "(GDF) Length of Header is too small"; return(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,"[GDF 252] #=%i/%i\n",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; uint32_t nbits = (GDFTYP_BITS[hc->GDFTYP]*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); // PhysDim(hc->PhysDimCode,hc->PhysDim); 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "GDF: Invalid or unsupported GDFTYP"; return(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); } /* 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,"[GDF 217] #=%li\n",iftell(hdr)); return(B4C_ERRNUM); } /********************************************************************************* hdrEVT2rawEVT(HDRTYPE *hdr) converts structure HDR.EVENT into raw event data (hdr->AS.rawEventData) *********************************************************************************/ size_t hdrEVT2rawEVT(HDRTYPE *hdr) { size_t k32u; char 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]; int sze = flag ? 12 : 6; 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 ? 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); }; 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) = l_endian_u32(hdr->EVENT.POS[k32u]+1); // convert from 0-based (biosig4c++) to 1-based (GDF) indexing *(uint16_t*)(buf2+k32u*2) = l_endian_u16(hdr->EVENT.TYP[k32u]); } if (flag) { 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) = l_endian_u16(hdr->EVENT.CHN[k32u]); *(uint32_t*)(buf2+k32u*4) = l_endian_u32(hdr->EVENT.DUR[k32u]); } } return(len); } /********************************************************************************* rawEVT2hdrEVT(HDRTYPE *hdr) converts raw event data (hdr->AS.rawEventData) into structure HDR.EVENT *********************************************************************************/ void rawEVT2hdrEVT(HDRTYPE *hdr) { // TODO: avoid additional copying size_t k; uint8_t *buf = hdr->AS.rawEventData; if (buf==NULL) { 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); } // int sze = (buf[0]>1) ? 12 : 6; 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++) { 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 (buf[0]>1) { 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; } } int NumberOfChannels(HDRTYPE *hdr) { unsigned int k,NS; for (k=0, NS=0; kNS; k++) if (hdr->CHANNEL[k].OnOff) 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 B4C_ERRNUM = B4C_REREF_FAILED; B4C_ERRMSG = "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((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) { B4C_ERRNUM = B4C_REREF_FAILED; B4C_ERRMSG = "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,"READ_HEADER: %i %i %f\n", (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,"READ_HEADER: %i %i %i %f\n", (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 (count < hdr->HeadLen) { if (VERBOSE_LEVEL>7) fprintf(stdout,"ambigous GDF header size: %i %i\n",(int)count,hdr->HeadLen); B4C_ERRNUM = B4C_INCOMPLETE_FILE; B4C_ERRMSG = "reading GDF header failed"; return(-2); } if (VERBOSE_LEVEL>7) fprintf(stdout,"READ_HEADER: %i %i %i %f\n", (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); if ( gdfbin2struct(hdr) ) { if (VERBOSE_LEVEL>7) fprintf(stdout,"READ_HEADER--: %i %i %i %f\n", (int)hdr->FILE.size, (int)hdr->HeadLen, (int)count, hdr->VERSION); return(-2); } if (VERBOSE_LEVEL>7) fprintf(stdout,"READ_HEADER: %i %i %i %f\n", (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 (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.SampleRate = hdr->SampleRate; hdr->EVENT.N = 0; } else 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); } if (VERBOSE_LEVEL > 7) fprintf(stdout,"EVENT.N = %i,%i\n",hdr->EVENT.N,(int)c); int sze = (buf[0]>1) ? 12 : 6; 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) { B4C_ERRNUM = B4C_INCOMPLETE_FILE; B4C_ERRMSG = "reading GDF eventtable failed"; return(-3); } rawEVT2hdrEVT(hdr); } 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) /* MODE="r" reads file and returns HDR MODE="w" writes HDR into file */ { 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}; // unsigned int k2; // uint32_t k32u; size_t count; char tmp[81]; // double Dur; char* ptr_str; struct tm tm_time; // time_t tt; uint16_t BCI2000_StatusVectorLength=0; // specific for BCI2000 format if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN( %s, %s) \n",FileName, MODE); if (FileName == NULL) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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 B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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 B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "SOPEN-NETWORK: file identifier not specifed"; return(hdr); } *t=0; cat64(t+1, &ID); int sd,s; sd = bscs_connect(hostname); if (sd<0) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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); } #endif hdr->AS.Header = (uint8_t*)malloc(513); size_t k,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; #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); B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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, 512, hdr); hdr->AS.Header[512]=0; } } else #endif { if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN 101: <%s>\n",hdr->FileName); /* 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); } hdr->FILE.COMPRESSION = 0; hdr = ifopen(hdr,"rb"); if (!hdr->FILE.OPEN) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "Error SOPEN(READ); Cannot open file."; return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN 101:\n"); count = ifread(hdr->AS.Header, 1, 512, hdr); hdr->AS.Header[count]=0; 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, 512, hdr); hdr->AS.Header[512]=0; #else B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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,"[201] FMT=%s Ver=%4.2f\n",GetFileTypeString(hdr->TYPE),hdr->VERSION); if (hdr->TYPE != unknown) ; else if (!memcmp(Header1,FileName,strspn(FileName,".")) && (!strcmp(FileExt,"HEA") || !strcmp(FileExt,"hea") )) hdr->TYPE = MIT; if (hdr->TYPE == unknown) { B4C_ERRNUM = B4C_FORMAT_UNKNOWN; B4C_ERRMSG = "ERROR BIOSIG4C++ SOPEN(read): Dataformat not known.\n"; ifclose(hdr); return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[201] FMT=%s Ver=%4.2f\n",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) { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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); B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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 (hdr->TYPE == GDF) { struct stat FileBuf; if (stat(hdr->FileName,&FileBuf)==0) hdr->FILE.size = FileBuf.st_size; if ( read_header(hdr) ) { return (hdr); } } else if ((hdr->TYPE == EDF) || (hdr->TYPE == BDF)) { if (count < 256) { B4C_ERRNUM = B4C_INCOMPLETE_FILE; B4C_ERRMSG = "reading BDF/EDF fixed header failed"; return(hdr); } typeof(hdr->NS) AnnotationChannel = 0; typeof(hdr->NS) StatusChannel = 0; strncpy(hdr->Patient.Id,Header1+8,min(MAX_LENGTH_PID,80)); memcpy(hdr->ID.Recording,Header1+88,min(80,MAX_LENGTH_RID)); hdr->ID.Recording[MAX_LENGTH_RID]=0; if (VERBOSE_LEVEL>8) fprintf(stdout,"[EDF 211] #=%li\nT0=<%16s>",iftell(hdr),Header1+168); // TODO: sanity check of T0 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; hdr->NS = atoi(strncpy(tmp,Header1+252,4)); hdr->HeadLen = atoi(strncpy(tmp,Header1+184,8)); if (hdr->HeadLen != ((hdr->NS+1u)<<8)) { B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "EDF/BDF corrupted: HDR.NS and HDR.HeadLen do not fit"; if (VERBOSE_LEVEL>8) 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)) { char ListOfMonth[12][4] = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}; 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)) { strcpy(hdr->Patient.Name,tmpptr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 211c] #=%li\n",iftell(hdr)); if (strlen(ptr_str)==11) { struct tm t1; t1.tm_mday = atoi(strtok(ptr_str,"-")); strcpy(tmp,strtok(NULL,"-")); for (k=0; kPatient.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); 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; count += ifread(hdr->AS.Header+count, 1, hdr->HeadLen-count, hdr); if (count < hdr->HeadLen) { B4C_ERRNUM = B4C_INCOMPLETE_FILE; B4C_ERRMSG = "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; strncpy(hc->Label,Header2 + 16*k,min(MAX_LENGTH_LABEL,16)); hc->Label[min(MAX_LENGTH_LABEL,16)]=0; int k1; for (k1=strlen(hc->Label)-1; isspace(hc->Label[k1]) && k1; k1--) hc->Label[k1] = 0; // deblank strncpy(hc->Transducer, Header2+80*k+16*hdr->NS, min(80,MAX_LENGTH_TRANSDUCER)); for (k1=strlen(hc->Transducer)-1; isspace(hc->Transducer[k1]) && k1; k1--) hc->Transducer[k1]='\0'; // deblank if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 214] #%i/%i\n",(int)k,hdr->NS); // PhysDim -> PhysDimCode memcpy(p,Header2 + 8*k + 96*hdr->NS,8); if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 215-] #%i/%i\n",(int)k,hdr->NS); p[8] = 0; // remove trailing blanks for (k1=7; (k1>0) && isspace(p[k1]); p[k1--]=0) {}; if (VERBOSE_LEVEL>7) fprintf(stdout,"[EDF 215] #%i/%i\n",(int)k,hdr->NS); 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; hdr->SPR = lcm(hdr->SPR, hc->SPR); hc->bi = hdr->AS.bpb; hc->bi8 = BitsPerBlock; uint32_t nbits = GDFTYP_BITS[hc->GDFTYP]*hc->SPR; BitsPerBlock += nbits; uint32_t nbytes = nbits>>3; hdr->AS.bpb += nbytes; if (VERBOSE_LEVEL>8) 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; // 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>8) 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>8) fprintf(stdout,"#%i# HP: %fHz LP:%fHz NOTCH=%f\n",(int)k,hc->HighPass,hc->LowPass,hc->Notch); if ((hdr->TYPE==EDF) && !strncmp(Header1+192,"EDF+",4) && !strcmp(hc->Label,"EDF Annotations")) { hc->OnOff = 0; AnnotationChannel = k+1; } else if ((hdr->TYPE==BDF) && !strncmp(Header1+192,"BDF+",4) && !strcmp(hc->Label,"BDF Annotations")) { hc->OnOff = 0; AnnotationChannel = k+1; } if ((hdr->TYPE==BDF) && !strcmp(hc->Label,"Status")) { hc->OnOff = 1; StatusChannel = k+1; } 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] #=%li\n",iftell(hdr)); if (hdr->NRec <= 0) { struct stat FileBuf; stat(hdr->FileName,&FileBuf); hdr->NRec = (FileBuf.st_size - hdr->HeadLen)/hdr->AS.bpb; } if (AnnotationChannel) { /* read Annotation and Status channel and extract event information */ CHANNEL_TYPE *hc = hdr->CHANNEL+AnnotationChannel-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 EDF+/BDF+ annotation channel into event table */ char *p0,*p1,*p2; N_EVENT=0; Marker[len]=255; // stop marker; double Onset,Duration; char FLAG_NONZERO_DURATION = 0; p1 = (char*)Marker; for (k=0; k=len) break; if (N_EVENT+1 >= hdr->EVENT.N) { hdr->EVENT.N += 2560; hdr->EVENT.POS = (uint32_t*)realloc(hdr->EVENT.POS, hdr->EVENT.N*sizeof(*hdr->EVENT.POS)); hdr->EVENT.DUR = (uint32_t*)realloc(hdr->EVENT.DUR, hdr->EVENT.N*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.TYP = (uint16_t*)realloc(hdr->EVENT.TYP, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.CHN = (uint16_t*)realloc(hdr->EVENT.CHN, hdr->EVENT.N*sizeof(*hdr->EVENT.CHN)); } Onset = strtod(p1+k, &p2); p0 = p2; if (*p2==21) { Duration = strtod(p2+1,&p0); FLAG_NONZERO_DURATION = 1; } else if (*p2==20) Duration = 0; else { /* sanity check */ fprintf(stdout,"Warning EDF+: corrupted annotation channel - decoding of event #%i <%s> failed.\n",(int)N_EVENT+1,p1+k); break; // do not decode any further events. } p0[strlen(p0)-1] = 0; // remove last ascii(20) hdr->EVENT.POS[N_EVENT] = (uint32_t)round(Onset * hdr->EVENT.SampleRate); // 0-based indexing hdr->EVENT.DUR[N_EVENT] = (uint32_t)round(Duration * hdr->EVENT.SampleRate); hdr->EVENT.CHN[N_EVENT] = 0; hdr->EVENT.TYP[N_EVENT] = min(255,strlen(p0+1)); // this is a hack, maps all codes into "user specific events" /* conversion from free text annotations to biosig event codes */ if (!strcmp(p0+1,"QRS")) hdr->EVENT.TYP[N_EVENT] = 0x0501; else { FreeTextEvent(hdr,N_EVENT,p0+1); } // if (VERBOSE_LEVEL>8) // fprintf(stdout,"%i,EDF+: %i\t%i\t%03i:\t%f\t%f\t%s\t%s\n",sizeof(char**),len,k,N_EVENT,Onset,Duration,p2+1,p0+1); N_EVENT++; while ((Marker[k] > 0) && (kEVENT.N = N_EVENT; if (!FLAG_NONZERO_DURATION){ free(hdr->EVENT.DUR); hdr->EVENT.DUR = NULL; free(hdr->EVENT.CHN); hdr->EVENT.CHN = NULL; } 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 = ((uint32_t)Marker[2]<<16) + ((uint32_t)Marker[1]<<8) + (uint32_t)Marker[0]; for (k=1; kEVENT.N; hdr->EVENT.N += N_EVENT+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 (hdr->EVENT.DUR && hdr->EVENT.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.DUR)); memset(hdr->EVENT.DUR + N, 0, (N_EVENT+1)*sizeof(*hdr->EVENT.DUR) ); memset(hdr->EVENT.CHN + N, 0, (N_EVENT+1)*sizeof(*hdr->EVENT.CHN) ); } d0 = ((uint32_t)Marker[2]<<16) + ((uint32_t)Marker[1]<<8) + (uint32_t)Marker[0]; hdr->EVENT.POS[0] = 0; // 0-based indexing hdr->EVENT.TYP[0] = d0 & 0x00ffff; for (N_EVENT=1, k=1; kEVENT.POS[N_EVENT] = k; // 0-based indexing hdr->EVENT.TYP[N_EVENT] = 0x7ffe; ++N_EVENT; } if ((d1 & 0x00ffff) != (d0 & 0x00ffff)) { hdr->EVENT.POS[N_EVENT] = k; // 0-based indexing uint16_t d2 = d1 & 0x00ffff; if (!d2) d2 = (uint16_t)(d0 & 0x00ffff) | 0x8000; hdr->EVENT.TYP[N_EVENT] = d2; ++N_EVENT; if (d2==0x7ffe) fprintf(stdout,"Warning: BDF file %s uses ambigous code 0x7ffe; For details see file eventcodes.txt. \n",hdr->FileName); } d0 = d1; } free(Marker); } /* End reading BDF Status channel */ ifseek(hdr, hdr->HeadLen, SEEK_SET); } else if (hdr->TYPE==ABF) { fprintf(stdout,"Warning ABF v%4.2f: implementation is not complete!\n",hdr->VERSION); if (hdr->VERSION < 2.0) { // ABF v1.x } else { // ABF 2.0+ hdr->HeadLen = leu32p(hdr->AS.Header+8); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,hdr->HeadLen); count += ifread(Header1+count, 1, hdr->HeadLen-count, hdr); //uint16_t gdftyp = 3; float fADCRange; float fDACRange; long lADCResolution; long lDACResolution; uint8_t* b = NULL; int k1; for (k1=0; k1<18; ++k1) { size_t BlockIndex = leu32p(hdr->AS.Header + k1*16 + 19*4); size_t BlockSize = leu32p(hdr->AS.Header + k1*16 + 19*4+4); uint64_t numBlocks = leu64p(hdr->AS.Header + k1*16 + 19*4+8); if (VERBOSE_LEVEL>8) fprintf(stdout,"ABF %02i: %04i %04i %08i\n",k1,(int)BlockIndex,(int)BlockSize,(int)numBlocks); ifseek(hdr, BlockIndex*512, SEEK_SET); b = (uint8_t*)realloc(b,numBlocks*BlockSize); ifread(b,numBlocks,BlockSize,hdr); if (BlockIndex==1) { hdr->SampleRate = 1.0 / lef32p(b+k*BlockSize+2); hdr->NRec = leu32p(b+k*BlockSize+36); fADCRange = lef32p(b+k*BlockSize+108); fDACRange = lef32p(b+k*BlockSize+112); lADCResolution = leu32p(b+k*BlockSize+116); lDACResolution = leu32p(b+k*BlockSize+120); } else if (BlockIndex==2) { hdr->NS = numBlocks; 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; // initialize fields hc->Label[0] = 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->GDFTYP = 3; // int16 hc->SPR = leu32p(b+k*BlockSize+20); hc->OnOff = 1; hc->Notch = 50; hc->Impedance = INFINITY; hc->fZ = NAN; hc->bi = hdr->AS.bpb; hdr->AS.bpb += (GDFTYP_BITS[hc->GDFTYP]*hc->SPR)>>3; } uint16_t ch; for (k=0;kNS;k++) { ch = leu16p(b+k*BlockSize); hdr->CHANNEL[ch].LeadIdCode= 0; hdr->CHANNEL[ch].OnOff = 1; hdr->CHANNEL[ch].Cal = lef32p(b+k*BlockSize+48); hdr->CHANNEL[ch].Off = lef32p(b+k*BlockSize+52); hdr->CHANNEL[ch].LowPass = lef32p(b+k*BlockSize+56); hdr->CHANNEL[ch].HighPass= lef32p(b+k*BlockSize+60); } } else if (BlockIndex==11) { // fprintf(stdout,"%i: %s\n",c,buf); } } free(b); } } else if (hdr->TYPE==ACQ) { /* 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; // 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 // Version 3.7.3+ hdr->HeadLen += hdr->NS*254; 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); 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); hdr->HeadLen += 4*hdr->NS; hdr->AS.Header = (uint8_t*)realloc(Header1,hdr->HeadLen+8); count += ifread(Header1+POS, 1, hdr->HeadLen-POS, hdr); // 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); strncpy(hc->Label,(char*)Header2+6,min(MAX_LENGTH_LABEL,40)); strncpy(tmp,(char*)Header2+68,20); tmp[20]=0; if (!strcmp(tmp,"Volts")) hc->PhysDimCode = 4256; 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 hdr->SPR = lcm(hdr->SPR, hc->SPR); } 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; /// foreign data section - skip POS += leu16p(hdr->AS.Header+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 = hdr->SPR/hc->SPR; // convert DIVIDER into SPR switch ((leu16p(hdr->AS.Header+POS+2))) { 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: B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "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); /* ### 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); 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 = 4096; 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); 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; sscanf(t,"%d %as %d %lf %lf",&chno1,&label,&chno2,&f1,&f2); k = hdr->NS++; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL,hdr->NS*sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *hc = hdr->CHANNEL+k; sprintf(hc->Label,"%s %03i",label,chno2); 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==Axona) { fprintf(stdout, "Axona: is currently very experimental. \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 < hdr->NS - 4; k++) { hc = hdr->CHANNEL + k + 4; sprintf(hc->Label, "#%02i", (int)k+1); 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); } 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,"Recording.IPaddress")) { /* ###FIXME: IPv6 are currently not supported. gethostbyaddr will become obsolete, use getaddrinfo instead */ #ifndef WITHOUT_NETWORK #ifdef _WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(1,1), &wsadata); #endif struct hostent *host = gethostbyaddr(val,strlen(val),AF_INET); // TODO: replace gethostbyaddr: getaddrinfo, getnameinfo() if (host!=NULL) memcpy(hdr->IPaddr, host->h_addr, host->h_length); #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->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 = 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 { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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 (((GDFTYP_BITS[cp->GDFTYP]*cp->SPR >> 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 %i\n",(int)k+1, hdr->AS.bpb-hdr->CHANNEL[k].bi,GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP]*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 += 4096; hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, N*sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, N*sizeof(*hdr->EVENT.TYP) ); hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, N*sizeof(*hdr->EVENT.DUR)); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, N*sizeof(*hdr->EVENT.CHN)); } 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 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>8) fprintf(stdout,"[201] start reading BCI2000 data!\n"); char *ptr, *t1; /* decode header length */ hdr->HeadLen = 0; ptr = strstr((char*)hdr->AS.Header,"HeaderLen="); if (ptr==NULL) B4C_ERRNUM = B4C_FORMAT_UNKNOWN; 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) B4C_ERRNUM = B4C_FORMAT_UNKNOWN; else hdr->NS = (typeof(hdr->NS)) strtod(ptr+9,&ptr); /* decode length of state vector */ ptr = strstr(t1,"StatevectorLen="); if (ptr==NULL) B4C_ERRNUM = B4C_FORMAT_UNKNOWN; 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 B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; if (B4C_ERRNUM) { /* return if any error has occured. */ B4C_ERRMSG = "ERROR 1234 SOPEN(BCI2000): invalid file format .\n"; 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; 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] * 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; sscanf(ptr,"%as %i %i %i %i",&item,i,i+1,i+2,i+3); 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"); } 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; if (!strcmp(tmp,"Jan")) tm_time.tm_mon = 0; else if (!strcmp(tmp,"Feb")) tm_time.tm_mon = 1; else if (!strcmp(tmp,"Mar")) tm_time.tm_mon = 2; else if (!strcmp(tmp,"Apr")) tm_time.tm_mon = 3; else if (!strcmp(tmp,"May")) tm_time.tm_mon = 4; else if (!strcmp(tmp,"Jun")) tm_time.tm_mon = 5; else if (!strcmp(tmp,"Jul")) tm_time.tm_mon = 6; else if (!strcmp(tmp,"Aug")) tm_time.tm_mon = 7; else if (!strcmp(tmp,"Sep")) tm_time.tm_mon = 8; else if (!strcmp(tmp,"Oct")) tm_time.tm_mon = 9; else if (!strcmp(tmp,"Nov")) tm_time.tm_mon = 10; else if (!strcmp(tmp,"Dec")) tm_time.tm_mon = 11; 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; 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)); } /* 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); 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 (!strncmpi(line,"Sex",3)) hdr->Patient.Sex = 1*(toupper(val[0])=='M')+2*(toupper(val[0])=='F'); else if (!strncmpi(line,"medication",11)) hdr->Patient.Medication = val==NULL ? 1 : 2; else if (!strncmpi(line,"diagnosis",10)) { } else if (!strncmpi(line,"MontageRaw",9)) Label = val; else if (!strncmpi(line,"Age",3)) age = atol(val); else if (!strncmpi(line,"Date",c1)) sscanf(val,"%02i/%02i/%02i",&t.tm_mon,&t.tm_mday,&t.tm_year); else if (!strncmpi(line,"Time",c1)) sscanf(val,"%02i:%02i:%02i",&t.tm_hour,&t.tm_min,&t.tm_sec); else if (!strncmpi(line,"Rate",c1)) hdr->SampleRate = atol(val); else if (!strncmpi(line,"NchanFile",9)) hdr->NS = atol(val); else if (!strncmpi(line,"UvPerBit",c1)) cal = atof(val); else if (!strncmpi(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 = 4096; 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); 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; 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.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 (!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); hdr->FileName = tmpfile; char* ext = strrchr((char*)hdr->FileName,'.')+1; while (!ifeof(hdr)) { size_t bufsiz = 4096; 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); 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>8) fprintf(stdout,"[212]: %i pos=%i <%s>, ERR=%i\n",seq,(int)pos,t,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; // B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; // B4C_ERRMSG = "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; hc->bi8 = k*hdr->SPR*GDFTYP_BITS[gdftyp]; hc->bi = hc->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); strcpy(strrchr(mrkfile,FILESEP)+1,t+11); } else strcpy(mrkfile,t+11); 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); B4C_ERRNUM = 0; // 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; // B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; // B4C_ERRMSG = "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)) { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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)) { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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,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)) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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) { #define H1LEN (8+14+4+8+8+2+2+2+2+2+4+2+2+74+4+40) 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; uint8_t k; hdr->NS = leu16p(hdr->AS.Header+42); /* General Header */ // uint32_t filesize = leu32p(hdr->AS.Header+22); // unused hdr->NS = leu16p(hdr->AS.Header+42); // 6 number of channels uint8_t n = leu16p(hdr->AS.Header+44); // 7 number of file variables uint16_t d = leu16p(hdr->AS.Header+46); // 8 number of data section variables uint16_t FileHeaderSize = leu16p(hdr->AS.Header+48); // 9 byte size of file header uint16_t DataHeaderSize = leu16p(hdr->AS.Header+50); // 10 byte size of data section header uint32_t LastDataSectionHeaderOffset = leu32p(hdr->AS.Header+52); // 11 last data section header offset uint16_t NumberOfDataSections = leu16p(hdr->AS.Header+56); // 12 last data section header offset if (NumberOfDataSections) { hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP, (hdr->EVENT.N + NumberOfDataSections - 1) * sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS, (hdr->EVENT.N + NumberOfDataSections - 1) * sizeof(*hdr->EVENT.POS)); hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) realloc(hdr->EVENT.CHN, (hdr->EVENT.N + NumberOfDataSections - 1) * sizeof(*hdr->EVENT.CHN)); hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR, (hdr->EVENT.N + NumberOfDataSections - 1) * sizeof(*hdr->EVENT.DUR)); } if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 131 - %d,%d,%d,0x%x,0x%x,0x%x,%d,0x%x\n",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 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; uint8_t len = min(21, MAX_LENGTH_LABEL); strncpy(hc->Label, H2 + 1 + k*H2LEN, len); len = strlen(hc->Label); while (isspace(hc->Label[len])) len--; // remove trailing blanks hc->Label[len+1] = 0; hc->PhysDimCode = PhysDimCode (H2 + 22 + 1 + k*H2LEN); xPhysDimScale[k] = PhysDimScale(PhysDimCode(H2 + 32 + 1 + k*H2LEN)); uint8_t gdftyp = H2[42 + k*H2LEN]; hc->GDFTYP = gdftyp < 5 ? gdftyp+1 : gdftyp+11; if (H2[43 + k * H2LEN]) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "(CFS)Subsidiary or Matrix data not supported"; } hc->LowPass = NAN; hc->HighPass = NAN; hc->Notch = NAN; if (VERBOSE_LEVEL>7) fprintf(stdout,"Channel #%i: [%s](%i/%i) <%s>/<%s> ByteSpace%i,Next#%i\n",k+1, H2 + 1 + k*H2LEN, gdftyp, H2[43], H2 + 23 + k*H2LEN, H2 + 33 + k*H2LEN, leu16p(H2+44+k*H2LEN), leu16p(H2+46+k*H2LEN)); } size_t datapos = H1LEN + H2LEN*hdr->NS; /* file variable information */ // n*36 bytes if (VERBOSE_LEVEL>7) fprintf(stdout,"\n******* file variable information *********\n"); for (k = 0; k < n; k++) { int i=-1; double f=NAN; size_t pos = datapos + k*36; uint16_t typ = leu16p(hdr->AS.Header+pos+22); uint16_t off = leu16p(hdr->AS.Header+pos+34); //fprintf(stdout,"\n%3i @0x%6x: <%s> %i [%s] %i ",k, pos, hdr->AS.Header+pos+1,typ,hdr->AS.Header+pos+25,off); size_t p3 = H1LEN + H2LEN*hdr->NS + (n+d)*36 + off + 42; 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>7) { if (typ<5) fprintf(stdout," *0x%x = [%d]",(int)p3,i); else if (typ<7) fprintf(stdout," *0x%x = [%g]",(int)p3,f); else if (typ==7) fprintf(stdout," *0x%x = <%s>",(int)p3,hdr->AS.Header+p3); } } if (VERBOSE_LEVEL>7) fprintf(stdout,"\n******* DS variable information *********\n"); 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 (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; size_t SPR = 0, SZ = 0; for (m = 0; m < NumberOfDataSections; m++) { datapos = DATAPOS[m]; 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, spb = 0, spr = 0; hdr->AS.first = 0; hdr->AS.length = 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 p = leu32p(pos); hc->SPR = leu32p(pos+4); hc->Cal = lef32p(pos+8); hc->Off = lef32p(pos+12); double Xcal = lef32p(pos+16); //double Xoff = lef32p(pos+20);// unused hc->OnOff = 1; hc->bi = sz; if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 409: %i #%i: SPR=%i=%i=%i x%f+-%f %i\n",m,k,spr,(int)SPR,hc->SPR,hc->Cal,hc->Off,p); double Fs = 1.0 / (xPhysDimScale[k] * Xcal); if (!m && !k) { hdr->SampleRate = Fs; } else if (fabs(hdr->SampleRate - Fs) > 1e-3) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "CED/CFS: different sampling rates are not supported"; } spr = hc->SPR; spb += hc->SPR; sz += hc->SPR * GDFTYP_BITS[hc->GDFTYP] >> 3; bpb += GDFTYP_BITS[hc->GDFTYP]>>3; // per single sample hdr->AS.length += hc->SPR; } if (NumberOfDataSections > 1) { // hack: copy data into a single block, only if more than one section hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata, (hdr->NS * SPR + spb) * sizeof(double)); /* if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 411: @%p %i @%p\n",hdr->AS.rawdata, (hdr->NS * SPR + spb), srcaddr); */ hdr->AS.first = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; uint32_t memoffset = leu32p(hdr->AS.Header + datapos + 30 + 24 * k); uint8_t *srcaddr = hdr->AS.Header+leu32p(hdr->AS.Header+datapos + 4) + memoffset; if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 412 #%i %i: @%p %i\n", k, hc->SPR, srcaddr, leu32p(hdr->AS.Header+datapos + 4) + leu32p(hdr->AS.Header + datapos + 30 + 24 * k)); int16_t szz = (GDFTYP_BITS[hc->GDFTYP]>>3); size_t k2; for (k2 = 0; k2 < hc->SPR; k2++) { uint8_t *ptr = srcaddr + k2*szz; double val; switch (hc->GDFTYP) { // reorder for performance reasons - more frequent gdftyp's come first case 3: val = lei16p(ptr); break; case 4: val = leu16p(ptr); break; case 16: val = lef32p(ptr); break; case 17: val = lef64p(ptr); break; case 0: val = *( char*) ptr; break; case 1: val = *( int8_t*) ptr; break; case 2: val = *(uint8_t*) ptr; break; case 5: val = lei32p(ptr); break; case 6: val = leu32p(ptr); break; case 7: val = lei64p(ptr); break; case 8: val = leu64p(ptr); break; default: val = NAN; B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "CED/CFS: invalid data type"; } if (VERBOSE_LEVEL>8) fprintf(stdout,"CFS read: %2i #%2i:%5i [%i,%i]: %f -> %f @%p\n",m,k,(int)k2,bpb,(int)SPR,val,val*hc->Cal + hc->Off, hdr->AS.rawdata + ((SPR + k2) * hdr->NS + k) * sizeof(double)); *(double*) (hdr->AS.rawdata + k * sizeof(double) + (SPR + k2) * hdr->NS * sizeof(double)) = val * hc->Cal + hc->Off; } // srcaddr += hdr->CHANNEL[k].SPR * GDFTYP_BITS[hdr->CHANNEL[k].GDFTYP] >> 3; } } else { hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,sz); memcpy(hdr->AS.rawdata, hdr->AS.Header + leu32p(hdr->AS.Header+datapos + 4), leu32p(hdr->AS.Header+datapos + 8)); hdr->AS.bpb = sz; } if (m>0) { hdr->EVENT.TYP[hdr->EVENT.N] = 0x7ffe; hdr->EVENT.POS[hdr->EVENT.N] = SPR; hdr->EVENT.CHN[hdr->EVENT.N] = 0; hdr->EVENT.DUR[hdr->EVENT.N] = 0; hdr->EVENT.N++; } SPR += spr; SZ += sz; if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 414: SPR=%i,%i,%i NRec=%i, @%p\n",spr,(int)SPR,hdr->SPR,(int)hdr->NRec, hdr->AS.rawdata); #if 0 // for (k = 0; k < d; k++) { for (k = 0; k < 0; k++) { // read data variables of each block - this currently broken. //size_t pos = leu16p(hdr->AS.Header + datapos + 30 + hdr->NS * 24 + k * 36 + 34); size_t pos = datapos + 30 + hdr->NS * 24; int i; double f; uint16_t typ = leu16p(hdr->AS.Header + pos + 22 + k*36) ; uint16_t off = leu16p(hdr->AS.Header + pos + 34 + k*36); uint32_t p3 = pos + off; if (VERBOSE_LEVEL>7) fprintf(stdout,"\n[DS#%3i/%3i] @0x%6x+0x%3x: <%s> %i [%s] :", m, k, pos, off, hdr->AS.Header+pos+off+1, typ, hdr->AS.Header+pos+off+25); 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>7) { if (typ<5) fprintf(stdout," *0x%x = %d",p3,i); else if (typ<7) fprintf(stdout," *0x%x = %g", p3,f); else if (typ==7) fprintf(stdout," *0x%x = <%s>",p3,hdr->AS.Header+p3); } } #endif datapos = leu32p(hdr->AS.Header + datapos); } free(DATAPOS); if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 419: SPR=%i=%i NRec=%i @%p\n",(int)SPR,hdr->SPR,(int)hdr->NRec, hdr->AS.rawdata); hdr->AS.first = 0; hdr->EVENT.SampleRate = hdr->SampleRate; if (NumberOfDataSections < 1) { hdr->SPR = 0; } else if (NumberOfDataSections == 1) { // hack: copy data into a single block, only if more than one section hdr->FLAG.UCAL = 0; hdr->SPR = SPR; hdr->NRec = 1; hdr->AS.length = 1; } else { hdr->FLAG.UCAL = 1; hdr->SPR = 1; hdr->NRec = SPR; hdr->AS.bpb = hdr->NS * sizeof(double); hdr->AS.length = SPR; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL + k; hc->GDFTYP = 17; // double hc->bi = sizeof(double)*k; hc->SPR = hdr->SPR; hc->Cal = 1.0; hc->Off = 0.0; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"CFS 429: SPR=%i=%i NRec=%i\n",(int)SPR,hdr->SPR,(int)hdr->NRec); datapos = FileHeaderSize; //+DataHeaderSize; if (flag_ChanInfoChanged) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "CED/CFS: varying channel information not supported"; } for (k = 0; k < hdr->NS; k++) { switch (hdr->CHANNEL[k].GDFTYP) { case 0: case 1: hdr->CHANNEL[k].DigMax = 127; hdr->CHANNEL[k].DigMin = -128; break; case 2: hdr->CHANNEL[k].DigMax = 255; hdr->CHANNEL[k].DigMin = 0; break; case 3: hdr->CHANNEL[k].DigMax = (int16_t)0x7fff; hdr->CHANNEL[k].DigMin = (int16_t)0x8000; break; case 4: hdr->CHANNEL[k].DigMax = 0xffff; hdr->CHANNEL[k].DigMin = 0; break; case 16: case 17: hdr->CHANNEL[k].DigMax = 1e9; hdr->CHANNEL[k].DigMin = -1e9; break; } hdr->CHANNEL[k].PhysMax = hdr->CHANNEL[k].DigMax * hdr->CHANNEL[k].Cal + hdr->CHANNEL[k].Off; hdr->CHANNEL[k].PhysMin = hdr->CHANNEL[k].DigMin * hdr->CHANNEL[k].Cal + hdr->CHANNEL[k].Off; } hdr->FLAG.UCAL = 0; #undef H1LEN } 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[MAX_LENGTH_PHYSDIM+1]; strncpy(p, (char*)Header2+32, min(16,MAX_LENGTH_PHYSDIM)); p[MAX_LENGTH_PHYSDIM] = 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,"SOPEN: Neuroscan format \n"); // TODO: fix handling of AVG and EEG files hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 900); hdr->VERSION = atof((char*)hdr->AS.Header + 8); count += ifread(hdr->AS.Header+count, 1, 900-count, hdr); 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,"SOPEN: Neuroscan format: minor revision %i eventtablepos: %i nextfilepos: %i\n", 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; 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,"SOPEN: Neuroscan format: minor rev=%i bpb2:%i bpb4:%i\n", minor_revision, (unsigned)hdr->AS.bpb, (unsigned)bpb4); switch (minor_revision) { case 9: // TODO: FIXME fprintf(stderr,"Warning biosig/sopen (CNT/EEG): minor revision %i is experimental\n", 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/sopen (CNT/EEG): minor revision %i not tested\n", minor_revision); if (VERBOSE_LEVEL>7) fprintf(stdout,"biosig/sopen (CNT/EEG): %i %i %i %i %i %i \n", (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 { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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); hdr->FLAG.CNT32 = (ifgetc(hdr)==1); ifseek (hdr,count,SEEK_SET); } gdftyp = hdr->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/sopen (CNT): %i %i %i %i %i \n", (int)hdr->NRec, hdr->SPR, hdr->NS, (int)eventtablepos, (int)(hdr->AS.bpb * hdr->NRec + hdr->HeadLen) ); } hdr->AS.Header = (uint8_t*) realloc(Header1,hdr->HeadLen); count += ifread(Header1+900, 1, hdr->NS*75, 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); 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 (hdr->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 += 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; 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 = 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 SOPEN(CNT) event %i: both, stimulus and response, codes (%i/%i) are non-zero. response code is ignored.\n",(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; } 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,"CTF[101]: %s\n",hdr->FileName); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,1844); hdr->HeadLen = 1844; char *f0 = hdr->FileName; char *f1 = (char*)malloc(strlen(f0)+6); strcpy(f1,f0); strcpy(strrchr(f1,'.')+1,"res4"); 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; } 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->AS.Header = (uint8_t*)realloc(hdr->AS.Header,1844+CTF_RunSize+2); count += ifread(hdr->AS.Header+count,1,CTF_RunSize+2,hdr); int16_t CTF_NumberOfFilters = bei16p(hdr->AS.Header+1844+CTF_RunSize); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header,count+CTF_NumberOfFilters*26+hdr->NS*(32+48+1280)); count += ifread(hdr->AS.Header+count,1,CTF_NumberOfFilters*26+hdr->NS*(32+48+1280),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->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); strcpy(strrchr(f2,FILESEP)+1,"MarkerFile.mrk"); hdr->EVENT.SampleRate = hdr->SampleRate; hdr->EVENT.N = 0; hdr->FileName = f2; hdr = ifopen(hdr,"rb"); if (hdr->FILE.OPEN) { size_t bufsiz = 4096; count = 0; char *vmrk=NULL; while (!ifeof(hdr)) { vmrk = (char*)realloc(vmrk,count+bufsiz+1); count += ifread(vmrk+count,1,bufsiz,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; 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.POS)); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, hdr->EVENT.N*sizeof(*hdr->EVENT.TYP)); } 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; 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==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: hdr->ID.Hospital = strndup(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); int c = 0; char physdim[MAX_LENGTH_PHYSDIM+1]; while (bei32p(ptr)) { if (VERBOSE_LEVEL>8) fprintf(stdout,"0x03: [%i %i] %c\n",k,c,*ptr); if (*ptr && (c<=MAX_LENGTH_PHYSDIM)) { physdim[c++] = *ptr; } ptr++; } ptr += 4; physdim[c] = 0; hc->PhysDimCode = PhysDimCode(physdim); } } 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: B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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); char *LOG=NULL; /* read .pnt */ if (strrchr(fn,FILESEP)) strcpy(strrchr(fn,FILESEP)+1, (char*)(hdr->AS.Header + 32)); else strcpy(fn, (char*)(hdr->AS.Header + 32)); FILE *fid = fopen(fn,"rb"); if (fid != NULL) { count = 0; while (!feof(fid)) { LOG = (char*) realloc(LOG,count+1025); count += fread(LOG+count,1,1024,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); } hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,(hdr->EVENT.N+n2)*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,(hdr->EVENT.N+n2)*sizeof(*hdr->EVENT.POS)); hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) realloc(hdr->EVENT.CHN,(hdr->EVENT.N+n2)*sizeof(*hdr->EVENT.CHN)); hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR,(hdr->EVENT.N+n2)*sizeof(*hdr->EVENT.DUR)); // if (n2>1) fprintf(stdout,"EEG1100: more than 1 segment [%i,%i] not supported.\n",n1,n2); 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; 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); hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,(hdr->EVENT.N+N)*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,(hdr->EVENT.N+N)*sizeof(*hdr->EVENT.POS)); hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) realloc(hdr->EVENT.CHN,(hdr->EVENT.N+N)*sizeof(*hdr->EVENT.CHN)); hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR,(hdr->EVENT.N+N)*sizeof(*hdr->EVENT.DUR)); 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; 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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; 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. 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.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR, N*sizeof(*hdr->EVENT.DUR)); } 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]; 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]; 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->FLAG.LittleEndian; #elif __BYTE_ORDER == __LITTLE_ENDIAN char FLAG_SWAP = hdr->FLAG.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); 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) { strncpy(hdr->CHANNEL[k].Label,buf+0x116,MAX_LENGTH_LABEL); } #endif 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); hdr->EVENT.POS = (uint32_t*) realloc(hdr->EVENT.POS, N_EVENTS * sizeof(*hdr->EVENT.POS) ); hdr->EVENT.TYP = (uint16_t*) realloc(hdr->EVENT.TYP, N_EVENTS * sizeof(*hdr->EVENT.TYP) ); hdr->EVENT.DUR = (uint32_t*) realloc(hdr->EVENT.DUR, N_EVENTS * sizeof(*hdr->EVENT.DUR) ); hdr->EVENT.CHN = (uint16_t*) realloc(hdr->EVENT.CHN, N_EVENTS * sizeof(*hdr->EVENT.CHN) ); } // 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; 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; 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==ET_MEG) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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; //fprintf(stdout,"%s\n",asctime(&tm_time)); 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, ((hdr->NRec+1) * hdr->NS * GDFTYP_BITS[gdftyp])>>3); for (k=0; k < hdr->NS; k++) { if (gdftyp==16) *(float*)(hdr->AS.rawdata + ((hdr->NRec*hdr->NS+k)*GDFTYP_BITS[gdftyp]>>3)) = (float)atof(strtok(NULL,dlm)); else if (gdftyp==17) *(double*)(hdr->AS.rawdata + ((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) ); } hdr->EVENT.POS[hdr->EVENT.N] = pos; // 0-based indexing hdr->EVENT.TYP[hdr->EVENT.N] = Mark; 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) ); 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; 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",count); sopen_fef_read(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"ASN1 [491]\n"); #else B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "VITAL/FEF Format not supported\n"; return(hdr); #endif } else if (hdr->TYPE==HDF) { #ifdef WITH_HDF if (sopen_hdf5(hdr) != 0) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Error reading HDF file\n"; } #else B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Format HDF not supported\n"; 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==ITX) { #define IGOR_MAXLENLINE 400 char line[IGOR_MAXLENLINE+1]; char flagData = 0; char flagSupported = 1; if (VERBOSE_LEVEL>7) fprintf(stdout,"[701] start reading %s,v%4.2f format (%i)\n",GetFileTypeString(hdr->TYPE),hdr->VERSION,ifeof(hdr)); typeof(hdr->SPR) SPR = 0, spr = 0; typeof(hdr->NS) ns = 0; int chanNo=0, PrevChanNo=0, sweepNo=0, PrevSweepNo=0; hdr->SPR = 0; hdr->NRec= 0; /* 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)) { 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; hdr->CHANNEL[ns].bi = SPR*sizeof(double); } else if (!strncmp(line,"END",3)) { flagData = 0; if ((SPR!=0) && (SPR != spr)) flagSupported = 0; else SPR = spr; PrevChanNo = chanNo; PrevSweepNo = sweepNo; 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 } } else if (!strncmp(line,"WAVES",5)) { char *p; p = strrchr(line,'_'); chanNo = atoi(p+1); ns = chanNo ? chanNo - 1 : 0; // if decoding fails, assume there is only a single channel p[0] = 0; p = strrchr(line,'_'); sweepNo = atoi(p+1); if (sweepNo == 0) hdr->NRec = 1; // if decoding fails, assume there is only a single sweep else if (sweepNo > hdr->NRec) hdr->NRec = sweepNo; p[0] = 0; flagSupported &= (ns==0) || (chanNo == PrevChanNo+1); // reset flag if channel number does not increment by one. flagSupported &= (ns==0 && sweepNo==PrevSweepNo+1) || (sweepNo == PrevSweepNo); // reset flag if sweep number does not increment by one when chanNo==0. if (ns >= hdr->NS) { hdr->NS = ns+1; hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); } CHANNEL_TYPE* hc = hdr->CHANNEL + ns; strncpy(hc->Label, line+6, MAX_LENGTH_LABEL); 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,"[776]<%s>#%i: %i/%i\n",line,(int)ns,(int)spr,(int)hdr->SPR); } else if (flagData) spr++; } if (VERBOSE_LEVEL>7) fprintf(stdout,"[751] scaning %s,v%4.2f format \n",GetFileTypeString(hdr->TYPE),hdr->VERSION); if (!flagSupported) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "This ITX format is not supported. Possible reasons: not generated by Heka-Patchmaster, corrupted, physical units do not match between sweeos, or do not fullfil some other requirements\n"; return(hdr); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[781] [%i,%i,%i] = %i\n",(int)hdr->NS,(int)hdr->SPR,(int)hdr->NRec,(int)hdr->NRec*hdr->SPR*hdr->NS); 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)); 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; nsNS; 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 char *p; p = strrchr(line,'_'); chanNo = atoi(p+1); chanNo = chanNo ? chanNo-1 : 0; // if decoding fails, assume there is only a single channel. p[0] = 0; p = strrchr(line,'_'); sweepNo = atoi(p+1); if (sweepNo) sweepNo--; // if decoding fails, assume there is only a single sweep p[0] = 0; spr = 0; if (sweepNo > 0 && chanNo==0) { hdr->EVENT.POS[sweepNo-1] = SPR; hdr->EVENT.TYP[sweepNo-1] = 0x7ffe; } } else if (flagData) { double val = atof(line); data[hdr->NS*(SPR + spr) + chanNo] = val; spr++; } } if (VERBOSE_LEVEL>7) fprintf(stdout,"[791] reading %s,v%4.2f format finished \n",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 } else if (hdr->TYPE==ISHNE) { 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 = 522 + lei32p(hdr->AS.Header+10); 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); int offsetData = lei32p(hdr->AS.Header+22); hdr->VERSION = (float)lei16p(hdr->AS.Header+26); if (!hdr->FLAG.ANONYMOUS) { len = min(80,MAX_LENGTH_NAME); strncpy(hdr->Patient.Name, (char*)(hdr->AS.Header+28), len); hdr->Patient.Name[len] = 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); /* TODO: decoding of Birthday and Recording Date is very exeripmental, the current solution is based on reverse engineering of a single file The decoding used previously did not work of that specific file (S1123.ecg). If anyone has an official documentation of the format, or can test this part, it would be very helpful. */ t.tm_mday = lei16p(hdr->AS.Header + 138); t.tm_mon = lei16p(hdr->AS.Header + 140) - 1; t.tm_year = lei16p(hdr->AS.Header + 142) - 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]); } hdr->Patient.Birthday = tm_time2gdf_time(&t); t.tm_mday = leu16p(hdr->AS.Header+144); t.tm_mon = leu16p(hdr->AS.Header+146)-1; t.tm_year = leu16p(hdr->AS.Header+148)-1900; t.tm_hour = lei16p(hdr->AS.Header + 150); t.tm_min = lei16p(hdr->AS.Header + 152); t.tm_sec = lei16p(hdr->AS.Header + 154); hdr->T0 = tm_time2gdf_time(&t); hdr->NS = lei16p(hdr->AS.Header + 156); hdr->SPR = 1; hdr->NRec = lei32p(hdr->AS.Header+14)/hdr->NS; hdr->AS.bpb = hdr->NS*2; hdr->SampleRate = lei16p(hdr->AS.Header + 272); hdr->Patient.Impairment.Heart = lei16p(hdr->AS.Header+230) ? 3 : 0; // Pacemaker 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,offsetData,SEEK_SET); hdr->FILE.POS = 0; } else if (hdr->TYPE==Matlab) { #ifdef WITH_MATIO if (sopen_matlab(hdr) != 0) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Error reading MATLAB file\n"; } #else B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Format MAT not supported\n"; ifclose(hdr); #endif return(hdr); } else if (hdr->TYPE==MFER) { // ISO/TS 11073-92001:2007(E), Table 5, p.9 /* ### FIXME: some units are not encoded */ 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; /* TAG */ uint8_t tag = hdr->AS.Header[0]; ifseek(hdr,1,SEEK_SET); int curPos = 1; 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; } 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); } else if (tag==5) //0x05: number of channels { 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); hdr->CHANNEL = (CHANNEL_TYPE*)realloc(hdr->CHANNEL, hdr->NS*sizeof(CHANNEL_TYPE)); for (k=0; kNS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; hc->SPR = 0; hc->PhysDimCode = 0; hc->Cal = 1.0; hc->LeadIdCode = 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); } 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; } 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==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); hdr->CHANNEL[chan].SPR = *(int64_t*) mfer_swap8b(buf, len2, SWAP); } 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==11) { // sampling resolution 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, buf[1]); if (buf[0]==1) // s fval = 1.0/fval; hdr->CHANNEL[chan].SPR = lround(hdr->SPR * fval / hdr->SampleRate); } else if (tag2==12) { // sensitivity 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 (tag2==0x0c) // block length ; */ else { ifseek(hdr,len2,SEEK_CUR); curPos += len2; if (VERBOSE_LEVEL==9) fprintf(stdout,"tag=63-%i (len=%i) not supported\n",tag,len); } } } else if (tag==64) //0x40 { // preamble curPos += ifread(tmp,1,len,hdr); if (VERBOSE_LEVEL>7) { fprintf(stdout,"Preamble: pos=%i|",curPos); for (k=0; k2) { hdr->EVENT.N++; if (VERBOSE_LEVEL>8) fprintf(stdout,"MFER-event: N=%i\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.CHN[hdr->EVENT.N] = 0; hdr->EVENT.DUR[hdr->EVENT.N] = 0; if (SWAP) { hdr->EVENT.TYP[hdr->EVENT.N] = bswap_16(*(uint16_t*)ptrbuf); hdr->EVENT.POS[hdr->EVENT.N] = bswap_32(*(uint32_t*)(buf+2)); // 0-based indexing if (len>6) hdr->EVENT.DUR[hdr->EVENT.N] = bswap_32(*(uint32_t*)(buf+6)); } else { hdr->EVENT.TYP[hdr->EVENT.N] = *(uint16_t*)ptrbuf; hdr->EVENT.POS[hdr->EVENT.N] = *(uint32_t*)(buf+2); // 0-based indexing if (len>6) hdr->EVENT.DUR[hdr->EVENT.N] = *(uint32_t*)(buf+6); } } } else if (tag==66) //0x42: NIPB, SpO2(value) { } 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 { curPos += len; ifseek(hdr,len,SEEK_CUR); if (VERBOSE_LEVEL==9) 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; 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; hc->GDFTYP = gdftyp; if (gdftyp<16) if (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); // hdr2ascii(hdr,stdout,4); } else if (hdr->TYPE==MIT) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 111]: %i \n",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,"[MIT 112]: %s\n",(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,"[MIT 113]:<%s>\n",ptr); if (strchr(line,'/') != NULL) { NumberOfSegments = atol(strchr(line,'/')+1); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank: multi-segment records are not supported\n"; } hdr->NS = (typeof(hdr->NS))strtod(ptr+1,&ptr); // number of channels if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 121]: NS=%i\n",hdr->NS); if ((ptr != NULL) && strlen(ptr)) { if (VERBOSE_LEVEL>8) fprintf(stdout,"123: <%s>\n",ptr); hdr->SampleRate = strtod(ptr,&ptr); if (ptr[0]=='/') { double CounterFrequency = strtod(ptr+1,&ptr); if (fabs(CounterFrequency-hdr->SampleRate) > 1e-5) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT format: Sampling rate and counter frequency differ - this is currently not supported !"; } } if (ptr[0]=='(') { double BaseCounterValue = strtod(ptr+1,&ptr); if (BaseCounterValue) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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>7) hdr2ascii(hdr,stdout,4); 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; do line = strtok(NULL,"\x0d\x0a"); while (line[0]=='#'); // read next line if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 111] #%i/%i <%s>\n",(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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank: different formats within a single data set is not supported\n"; } 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 (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 (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 (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); hc->Cal = 1/ADCgain; hc->Off = -ADCzero*hc->Cal; hc->OnOff = 1; hc->Transducer[0] = '\0'; hc->LowPass = -1; hc->HighPass = -1; // 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; B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank format 8(diff) not supported.\n"; break; case 80: gdftyp = 2; // uint8; hc->Off= -128*hc->Cal; hc->DigMax = 255.0; hc->DigMin = 0.0; break; case 16: 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); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank format 310/311 not supported.\n"; break; default: gdftyp = 0xffff; B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank: unknown format.\n"; } 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; } hdr->SampleRate *= MUL; hdr->SPR *= MUL; if (VERBOSE_LEVEL>7) hdr2ascii(hdr,stdout,4); /* 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,"[MIT 177] #%i: (%i) %s FMT=%i + %i\n",(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); strcpy(strrchr(f1,'.')+1,"atr"); hdr->FileName = f1; hdr = ifopen(hdr,"r"); if (!hdr->FILE.OPEN) { // if no *.atr file, try *.qrs strcpy(strrchr(f1,'.')+1,"qrs"); hdr = ifopen(hdr,"r"); } if (!hdr->FILE.OPEN) { // *.ecg strcpy(strrchr(f1,'.')+1,"ecg"); hdr = ifopen(hdr,"r"); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 179] <%s> %i %i\n",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)); for (k=0; strlen(MIT_EVENT_DESC[k])>0; k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 182] %i\n",(int)k); //hdr->EVENT.CodeDesc[k+1] = MIT_EVENT_DESC[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,"[MIT 182] %i %s %s\n",(int)k,MIT_EVENT_DESC[k],hdr->EVENT.CodeDesc[k]); } hdr->EVENT.LenCodeDesc = k+1; if (VERBOSE_LEVEL>7) fprintf(stdout,"[MIT 183] %s %i\n",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,"[MIT 183] k=%i/%i N=%i A=%i l=%i\n", (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,"[MIT 185] \n"); /* 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,"[MIT 198] #%i: (%i) %s FMT=%i\n",(int)k+1,(int)nDatFiles,DatFiles[0],fmt); free(DatFiles); free(ByteOffset); if (VERBOSE_LEVEL > 7) fprintf(stdout,"[MIT 199] #%i: (%i) %s FMT=%i\n",(int)k+1,(int)nDatFiles,DatFiles[0],fmt); if (nDatFiles != 1) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "MIT/HEA/PhysioBank: multiply data files within a single data set is not supported\n"; 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; 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; 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; B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "NeuroLogger HEX format not supported, 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"); 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); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Format NIFTI not supported\n"; return(hdr); } else if (hdr->TYPE==Persyst) { 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; ifclose(hdr); int status = 0; size_t pos=0; char *line = strtok(Header1,"\n\r"); while (posFILE.FID = fopen('' else if (!strncmp(line,"File",4)) ; } */ line = strtok(NULL,"\n\r"); } B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Format Persyst not supported,yet."; } 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 */ typedef 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 */ } RAWHDR; 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->LeadIdCode = 0; } B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Format RDF (UCSD ERPSS) not supported,yet."; } else if (hdr->TYPE==SCP_ECG) { hdr->HeadLen = leu32p(hdr->AS.Header+2); 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) { B4C_ERRNUM = B4C_CRC_ERROR; B4C_ERRMSG = "Warning SOPEN(SCP-READ): Bad CRC!"; } sopen_SCP_read(hdr); serror(); // 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); 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; 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; 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; } } else if (hdr->TYPE==TMS32) { hdr->VERSION = lei16p(hdr->AS.Header+31); hdr->SampleRate = lei16p(hdr->AS.Header+114); size_t NS = lei16p(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]; 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 += (GDFTYP_BITS[hc->GDFTYP] * hc->SPR)>>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; */ int 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); } 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: multiple data files not supported\n"; } 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); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: multiple data files not supported\n"; } } 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: data file not specified\n"; } 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: data file not found\n"; } 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) ) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: Binary file corrupted\n"; } else { size_t sz = 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: data file not found\n"; } 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "TMSiLOG: Binary file corrupted\n"; } 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 = 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 } 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 } } 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; 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); 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 += 4096; 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; } #ifdef WITH_DICOM 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 (serror()) 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 (serror()) return(hdr); // hdr->FLAG.SWAP = 0; } else if (hdr->TYPE==WG1) { uint32_t VER = leu32p(hdr->AS.Header); if (VER==0xAFFE5555) { // TODO: this version is currently not supported. if (count < 5120) { hdr->AS.Header = realloc(hdr->AS.Header, 5120); count += ifread(hdr->AS.Header,5120-count,1,hdr); } hdr->HeadLen = count; uint16_t gdftyp = 1; hdr->NS = leu16p(hdr->AS.Header+0x40); hdr->NRec = leu16p(hdr->AS.Header+0x110); // total number of blocks uint16_t startblock = leu16p(hdr->AS.Header+0x112); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "ERROR BIOSIG SOPEN(READ): WG1 0x5555FEAF format is not supported yet"; } else { hdr->SampleRate = 1e6 / leu32p(Header1+16); hdr->NS = leu16p(Header1+22); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "ERROR BIOSIG SOPEN(READ): WG1 data format is not supported yet"; } return(hdr); } else { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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) PhysDim(k1,hdr->CHANNEL[k].PhysDim); else hdr->CHANNEL[k].PhysDimCode = PhysDimCode(hdr->CHANNEL[k].PhysDim); */ // 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; strcmpi(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]); } if (!hdr->EVENT.SampleRate) hdr->EVENT.SampleRate = hdr->SampleRate; /* convert2to4_event_table(hdr->EVENT); 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>\n",hostname); B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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/%016lx\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)); 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); struct tm *t = gdf_time2tm_time(hdr->T0); fprintf(fid,"Recording.Time \t= %04i-%02i-%02i %02i:%02i:%02i\t# YYYY-MM-DD hh:mm:ss\n",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); fprintf(fid,"Patient.Id \t= %s\n",hdr->Patient.Id); t = gdf_time2tm_time(hdr->Patient.Birthday); fprintf(fid,"Patient.Birthday \t= %04i-%02i-%02i %02i:%02i:%02i\t# YYYY-MM-DD hh:mm:ss\n",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); 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+1; } *e = (hdr->TYPE == ASCII ? 'a' : 's'); e++; 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",PhysDim(hdr->CHANNEL[k].PhysDimCode,tmp)); 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\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"); if (!GLOBAL_EVENTCODES_ISLOADED) LoadGlobalEventCodeTable(); 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) fprintf(fid,"%f\t%d\t",hdr->EVENT.DUR[k]/hdr->EVENT.SampleRate,hdr->EVENT.CHN[k]); else fprintf(fid,"\t\t"); if (hdr->EVENT.TYP[k] == 0x7fff) fprintf(fid,"%i\t# sparse sample ",hdr->EVENT.DUR[k]); // value of sparse samples else if (hdr->EVENT.TYP[k] == 0) {} else if (hdr->EVENT.TYP[k] < hdr->EVENT.LenCodeDesc) fprintf(fid,"%s",hdr->EVENT.CodeDesc[hdr->EVENT.TYP[k]]); else if (GLOBAL_EVENTCODES_ISLOADED) { uint16_t k1; for (k1=0; (k1 < Global.LenCodeDesc) && (hdr->EVENT.TYP[k] != Global.CodeIndex[k1]); k1++) {}; if (hdr->EVENT.TYP[k] == Global.CodeIndex[k1]) fprintf(fid,"%s",Global.CodeDesc[k1]); } } fclose(fid); free(fn); } 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); char* ext = strrchr(tmpfile,'.'); if (ext != NULL) strcpy(ext+1,"vhdr"); else strcat(tmpfile,".vhdr"); 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 = 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 physdim[MAX_LENGTH_PHYSDIM+1]; char Label[MAX_LENGTH_LABEL+1]; strcpy(Label,hdr->CHANNEL[k].Label); 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,PhysDim(hdr->CHANNEL[k].PhysDimCode,physdim)); } 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); struct tm *t = gdf_time2tm_time(hdr->T0); leu32a(t->tm_year + 1900, hdr->AS.Header+16); leu32a(t->tm_mon + 1, hdr->AS.Header+20); leu32a(t->tm_mday, hdr->AS.Header+24); leu32a(t->tm_hour, hdr->AS.Header+28); leu32a(t->tm_min, hdr->AS.Header+32); lef64a(t->tm_sec, hdr->AS.Header+36); 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)); PhysDim(hdr->CHANNEL[k].PhysDimCode, tmp); len = strlen(tmp); memcpy(Header2+96*k2+32, tmp, 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 if ((hdr->TYPE==GDF) || (hdr->TYPE==GDF1)) { 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>8) fprintf(stdout,"GDFw h3\n"); } 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'; } /* obsolete tt = gdf_time2t_time(hdr->Patient.Birthday); if (hdr->Patient.Birthday>1) strftime(tmp,81,"%d-%b-%Y",localtime(&tt)); */ struct tm *t = gdf_time2tm_time(hdr->Patient.Birthday); if (hdr->Patient.Birthday>1) strftime(tmp,81,"%02d-%b-%04Y",t); 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) sprintf(cmd,"%s %c %s %s",hdr->Patient.Id,GENDER[hdr->Patient.Sex],tmp,hdr->Patient.Name); else sprintf(cmd,"%s %c %s X",hdr->Patient.Id,GENDER[hdr->Patient.Sex],tmp); memcpy(Header1+8, cmd, strlen(cmd)); t = gdf_time2tm_time(hdr->T0); if (hdr->T0>1) strftime(tmp,81,"%02d-%b-%04Y",t); else strcpy(tmp,"X"); char *tmpstr = hdr->ID.Technician; if (!tmpstr || !strlen(tmp)) tmpstr = "X"; size_t len = sprintf(cmd,"Startdate %s X %s ", tmp, tmpstr); memcpy(Header1+88, cmd, len); memcpy(Header1+88+len, &hdr->ID.Equipment, 8); t = gdf_time2tm_time(hdr->T0); strftime(tmp,81,"%d.%m.%y%H.%M.%S",t); 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)); PhysDim(hdr->CHANNEL[k].PhysDimCode, tmp); len = strlen(tmp); if (len>8) fprintf(stderr,"Warning: Physical Dimension (%s) of channel %i is too long (%i>8).\n",tmp,k,(int)len); memcpy(Header2 + 8*k2 + 96*NS, tmp, 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,"SOPEN_SCP_WRITE -112\n"); sopen_SCP_write(hdr); if (serror()) 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); char tmp[MAX_LENGTH_PHYSDIM+1]; PhysDim(hdr->CHANNEL[k].PhysDimCode,tmp); fprintf(fid,"Signal%04d.UnitName=%s\n\r",k+1,tmp); 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); strcpy(strrchr(fn2,'.'),".asc"); // hdr->FileName = fn2; fid = fopen(fn2,"wb"); fprintf(fid,"%d\tHz\n\r\n\rN",hdr->SampleRate); for (k=0; kNS; k++) { char tmp[MAX_LENGTH_PHYSDIM+1]; PhysDim(hdr->CHANNEL[k].PhysDimCode,tmp); fprintf(fid,"\t%s(%s)",hdr->CHANNEL[k].Label,tmp); } 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 else { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "ERROR: Writing of format not supported\n"; return(NULL); } if ((hdr->TYPE != ASCII) && (hdr->TYPE != BIN) && (hdr->TYPE != HL7aECG) && (hdr->TYPE != TMSiLOG)){ hdr = ifopen(hdr,"wb"); if (!hdr->FILE.COMPRESSION && (hdr->FILE.FID == NULL) ){ B4C_ERRNUM = B4C_CANNOT_WRITE_FILE; B4C_ERRMSG = "ERROR: Unable to open file for writing.\n"; return(NULL); } #ifdef ZLIB_H else if (hdr->FILE.COMPRESSION && (hdr->FILE.gzFID == NULL) ){ B4C_ERRNUM = B4C_CANNOT_WRITE_FILE; B4C_ERRMSG = "ERROR: Unable to open file for writing.\n"; 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; if (hdr->TYPE==AINF) { hdr->AS.bpb = 4; bpb8 = 32; } else 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 //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) FILE.POS=%d is not zero.\n",hdr->TYPE,(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>8) fprintf(stdout,"sopen{return} %i %s\n", 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 += 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. re-allocates buffer (buf) to hold collapsed data bpb are the bytes per block. ****************************************************************************/ void collapse_rawdata(HDRTYPE *hdr) { CHANNEL_TYPE *CHptr; size_t bpb; // char bitflag = 0; size_t k1,k4,count,SZ; if (VERBOSE_LEVEL>8) fprintf(stdout,"collapse: started\n"); bpb = bpb8_collapsed_rawdata(hdr); if (bpb == hdr->AS.bpb<<3) return; // no collapsing needed if ((bpb & 7) || (hdr->AS.bpb8 & 7)) { B4C_ERRNUM = B4C_RAWDATA_COLLAPSING_FAILED; B4C_ERRMSG = "collapse_rawdata: does not support bitfields"; } bpb >>= 3; if (VERBOSE_LEVEL>8) fprintf(stdout,"collapse: bpb=%i/%i\n",(int)bpb,hdr->AS.bpb); count = hdr->AS.length; uint8_t *buf = (uint8_t*) malloc(count*bpb); size_t bi = 0; for (k1=0; k1NS; k1++) { CHptr = hdr->CHANNEL+k1; SZ = CHptr->SPR*GDFTYP_BITS[CHptr->GDFTYP]; if (SZ & 7) { B4C_ERRNUM = B4C_RAWDATA_COLLAPSING_FAILED; B4C_ERRMSG = "collapse_rawdata: does not support bitfields"; } SZ >>= 3; if (CHptr->OnOff) /* read selected channels only */ if (CHptr->SPR > 0) { if (VERBOSE_LEVEL>8) fprintf(stdout,"%i: %i %i %i %i \n",(int)k1,(int)bi,CHptr->bi,(int)bpb,hdr->AS.bpb); for (k4 = 0; k4 < count; k4++) { size_t off1 = k4*hdr->AS.bpb + CHptr->bi; size_t off2 = k4*bpb + bi; if (VERBOSE_LEVEL>8) fprintf(stdout,"%i %i: %i %i \n",(int)k1,(int)k4,(int)off1,(int)off2); memcpy(buf + off2, hdr->AS.rawdata + off1, SZ); } bi += SZ; } } free(hdr->AS.rawdata); hdr->AS.rawdata = buf; hdr->AS.flag_collapsed_rawdata = 1; // rawdata is now "collapsed" if (VERBOSE_LEVEL>8) fprintf(stdout,"collapse: finished\n"); } /****************************************************************************/ /** SREAD_RAW : segment-based **/ /****************************************************************************/ size_t sread_raw(size_t start, size_t length, HDRTYPE* hdr, char flag) { /* * 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 */ 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,"####SREAD-RAW########## start=%d length=%d bpb=%i\n",(int)start,(int)length, hdr->AS.bpb); if (VERBOSE_LEVEL>7) fprintf(stdout,"sread raw 211: %d %d %d %d\n",(int)start, (int)length, (int)hdr->NRec, (int)hdr->FILE.POS); if ((nrec_t)start > hdr->NRec) return(0); else if ((ssize_t)start < 0) start = hdr->FILE.POS; if (VERBOSE_LEVEL>7) fprintf(stdout,"sread raw 216: %d %d %d %d\n",(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,"sread raw 221: %i %i %i %i %i\n",(int)start, (int)length, (int)nelem, (int)hdr->NRec, (int)hdr->FILE.POS); if (VERBOSE_LEVEL>7) fprintf(stdout,"sread raw 221 %i=?=%i %i=?=%i \n", (int)start,(int)hdr->AS.first,(int)(start+nelem),(int)hdr->AS.length); if ((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,"sread-raw: 222\n"); } #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 { if (VERBOSE_LEVEL>7) fprintf(stdout,"sread-raw: 223\n"); // 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,"sread-raw: 224 %i\n",hdr->AS.bpb); // allocate AS.rawdata void *tmpptr = realloc(hdr->AS.rawdata, hdr->AS.bpb*nelem); if (tmpptr!=NULL || hdr->AS.bpb*nelem==0) hdr->AS.rawdata = (uint8_t*) tmpptr; else { B4C_ERRNUM = B4C_MEMORY_ALLOCATION_FAILED; B4C_ERRMSG = "memory allocation failed - not enough memory!"; 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(hdr->AS.rawdata, hdr->AS.bpb, nelem, hdr); hdr->AS.flag_collapsed_rawdata = 0; // is rawdata not collapsed // if ((countNRec < 0) || (hdr->NRec > start+count))) hdr->NRec = start+count; // get NRec if NRec undefined, not tested yet. if (count < nelem) { fprintf(stderr,"warning: less then 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)); } // else fprintf(stderr," %i %i blocks read (bpb=%i,pos=%li)\n",count,nelem,hdr->AS.bpb,iftell(hdr)); hdr->AS.first = start; hdr->AS.length= count; } // (uncollapsed) data is now in buffer hdr->AS.rawdata if (flag) { collapse_rawdata(hdr); } 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); 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,SZ,NS;//bi,bi8; uint16_t GDFTYP; size_t DIV; uint8_t *ptr=NULL; // *buffer; CHANNEL_TYPE *CHptr; int32_t int32_value; biosig_data_type sample_value=NAN; size_t toffset; // time offset for rawdata biosig_data_type *data1=NULL; if (VERBOSE_LEVEL>6) fprintf(stdout,"SREAD( %p, %i, %i, %s ) MODE=%i\n",data, (int)start, (int)length, hdr->FileName, hdr->FILE.OPEN); if (start >= (size_t)hdr->NRec) return(0); count = sread_raw(start, length, hdr, 0); if (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,"SREAD: count=%i pos=[%i,%i,%i,%i], size of data = %ix%ix%ix%i = %i\n",(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 B4C_ERRNUM = B4C_MEMORY_ALLOCATION_FAILED; B4C_ERRMSG = "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 { B4C_ERRNUM = B4C_MEMORY_ALLOCATION_FAILED; B4C_ERRMSG = "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 uint16_t MITTYP=0; int stride = 1; if (hdr->TYPE==MIT) { MITTYP = *(uint16_t*)hdr->AS.auxBUF; if (VERBOSE_LEVEL>7) fprintf(stdout,"0x%x 0x%x \n",*(uint32_t*)hdr->AS.rawdata,*(uint32_t*)hdr->AS.rawdata); } else if (hdr->TYPE==Axona) stride = 64; if (VERBOSE_LEVEL>7) fprintf(stdout,"sread 223 alpha12bit=%i SWAP=%i spr=%i %p\n", ALPHA12BIT, SWAP, hdr->SPR, hdr->AS.rawdata); for (k1=0,k2=0; k1NS; k1++) { CHptr = hdr->CHANNEL+k1; if (VERBOSE_LEVEL>7) fprintf(stdout,"sread 223a #%i#%i: alpha12bit=%i SWAP=%i spr=%i %p | bi=%i bpb=%i \n", (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) { DIV = hdr->SPR/CHptr->SPR; GDFTYP = CHptr->GDFTYP; SZ = GDFTYP_BITS[GDFTYP]; 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; if (hdr->TYPE == FEF) { ptr1 = CHptr->bufptr; } else ptr1 = hdr->AS.rawdata + (k4+toffset)*hdr->AS.bpb + CHptr->bi; for (k5 = 0; k5 < CHptr->SPR; k5++) { // size_t off = (k4+toffset)*hdr->AS.bpb + CHptr->bi + (k5*SZ>>3); // ptr = hdr->AS.rawdata + off; ptr = ptr1 + (stride * k5 * SZ >> 3); if (VERBOSE_LEVEL>8) fprintf(stdout,"SREAD 555: k_i = [%d %d %d %d ] 0x%08x[%g] @%p => ",(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 (hdr->TYPE==TMS32) { ptr = hdr->AS.rawdata + (k4+toffset)*hdr->AS.bpb + (k1+k5*hdr->NS)*(SZ>>3)+86; #if __BYTE_ORDER == __BIG_ENDIAN sample_value = (biosig_data_type)(int16_t)bswap_16(*(int16_t*)ptr); #elif __BYTE_ORDER == __LITTLE_ENDIAN sample_value = (biosig_data_type)(*(int16_t*)ptr); #endif } else 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 (hdr->TYPE==TMS32) { ptr = hdr->AS.rawdata + (k4+toffset)*hdr->AS.bpb + (k1+k5*hdr->NS)*(SZ>>3)+86; #if __BYTE_ORDER == __BIG_ENDIAN u.i32 = bswap_32(*(uint32_t*)(ptr)); sample_value = (biosig_data_type)(u.f32); #elif __BYTE_ORDER == __LITTLE_ENDIAN sample_value = (biosig_data_type)(*(float*)(ptr)); #endif } else 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) >> (4-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 (MITTYP==212) ; else if (MITTYP==310) ; else if (MITTYP==311) ; else */ B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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 else 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++) { 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] = NAN; // row-based channels } else { for (k5 = 0; k5 < hdr->SPR*count; k5++) data1[k2*count*hdr->SPR + k5] = NAN; // 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)) { ptr = (uint8_t*)(hdr->EVENT.DUR + k1); k2 = ChanList[hdr->EVENT.CHN[k1]]-1; CHptr = hdr->CHANNEL+k2; DIV = (uint32_t)ceil(hdr->SampleRate/hdr->EVENT.SampleRate); GDFTYP = CHptr->GDFTYP; SZ = GDFTYP_BITS[GDFTYP]>>3; 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 { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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 else 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>8) fprintf(stdout,"E%02i: s(1)= %d %e %e %e\n",(int)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,"SWRITE( %p, %i, %s ) MODE=%i\n",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,"swrite 307 <%s> sz=%i\n",hdr->FileName,(int)(hdr->NRec*bpb8>>3)); 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) { B4C_ERRNUM = B4C_INSUFFICIENT_MEMORY; B4C_ERRMSG = "SWRITE: memory allocation failed."; return(0); } else hdr->AS.rawdata = (uint8_t*)ptr; } if (VERBOSE_LEVEL>7) fprintf(stdout,"swrite 311: %i %i\n",(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,"swrite 312=#%i gdftyp=%i %i %i %i %f %f %f %f %i\n",(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,"swrite 313- #%i: [%i %i] %i %i %i %i %i\n",(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,"swrite 313a #%i: [%i %i] %i %i %i %i %i\n",(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,"swrite 313+: [%i %i %i %i %i] %i %i %i %i %i %i\n",(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,"swrite 313b: %f/%i\n",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,"swrite 313e %i %i %i %f\n",(int)k4,(int)k5,(int)(off>>3),sample_value); // 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: B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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 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+1; } *e = (hdr->TYPE == ASCII ? 'a' : 's'); e++; for (k1=0; k1NS; k1++) if (hdr->CHANNEL[k1].OnOff) { 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) { DIV = hdr->SPR/CHptr->SPR; size_t k2; for (k2=0; k2 < CHptr->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,"%f\n",i/DIV); else #endif fprintf(H1.FILE.FID,"%f\n",i/DIV); } } else if (hdr->TYPE == BIN) { uint32_t nbytes = (GDFTYP_BITS[hdr->CHANNEL[k1].GDFTYP]*hdr->CHANNEL[k1].SPR)>>3; ifwrite(hdr->AS.rawdata+hdr->CHANNEL[k1].bi, nbytes, hdr->NRec, &H1); } ifclose(&H1); } count = hdr->NRec; free(fn); } else 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 CHOLMOD_H 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, long int 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 **/ /****************************************************************************/ long int stell(HDRTYPE* hdr) { long int 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) { int32_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,"sclose(121)\n"); 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,"sclose(122) OPEN=%i %s\n",hdr->FILE.OPEN,GetFileTypeString(hdr->TYPE)); #ifdef WITH_FEF if (hdr->TYPE == FEF) sclose_fef_read(hdr); #endif #ifndef WITHOUT_NETWORK if (hdr->FILE.Des>0) { // network connection if (hdr->FILE.OPEN > 1) bscs_send_evt(hdr->FILE.Des,hdr); int s = bscs_close(hdr->FILE.Des); if (s) { B4C_ERRNUM = B4C_SCLOSE_FAILED; B4C_ERRMSG = "bscs_close failed"; } 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 = l_endian_i64(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); } } 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; aECG_TYPE* aECG = (aECG_TYPE*)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); } // 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; } if (hdr->FILE.OPEN > 0) { int status = ifclose(hdr); if (status) iferror(hdr); hdr->FILE.OPEN = 0; } return(0); } /****************************************************************************/ /** SERROR **/ /****************************************************************************/ int serror() { int status = B4C_ERRNUM; if (status) { fprintf(stderr,"ERROR %i: %s\n",B4C_ERRNUM,B4C_ERRMSG); B4C_ERRNUM = B4C_NO_ERROR; } return(status); } /****************************************************************************/ /* 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); long int 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 hdr2json(HDRTYPE* hdr, FILE *fid) { size_t k; char tmp[41]; fprintf(fid,"\n{\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 (!isnan(hdr->SampleRate)) fprintf(fid,"\t\"Samplingrate\"\t: %f,\n",hdr->SampleRate); strftime(tmp,40,"%Y-%m-%d %H:%M:%S",gdf_time2tm_time(hdr->T0)); fprintf(fid,"\t\"StartOfRecording\"\t: \"%s\",\n",tmp); fprintf(fid,"\t\"Patient\"\t: {\n"); fprintf(fid,"\t\t\"Name\"\t: \"%s\",\n", hdr->Patient.Name); 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 fprintf(fid,"\t\"Manufacturer\"\t: {\n"); fprintf(fid,"\t\t\"Name\"\t: \"%s\",\n", hdr->ID.Manufacturer.Name); fprintf(fid,"\t\t\"Model\"\t: \"%s\",\n", hdr->ID.Manufacturer.Model); fprintf(fid,"\t\t\"Version\"\t: \"%s\",\n", hdr->ID.Manufacturer.Version); fprintf(fid,"\t\t\"SerialNumber\"\t: \"%s\"\n", hdr->ID.Manufacturer.SerialNumber); // no comma at the end because its the last element fprintf(fid,"\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); fprintf(fid,"\t\t\"Transducer\"\t: \"%s\",\n", hc->Transducer); fprintf(fid,"\t\t\"PhysicalUnit\"\t: \"%s\",\n", PhysDim(hc->PhysDimCode,tmp)); 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); /* TODO: fix for NAN and INFINITY fprintf(fid,"\t\t\"Filter\" : {\n\t\t\t\"Lowpass\"\t: %g,\n\t\t\t\"Highpass\"\t: %g,\n\t\t\t\"Notch\"\t: %g\n\t\t},\n", hc->LowPass,hc->HighPass,hc->Notch); */ 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; } double fs = hdr->SampleRate * hc->SPR/hdr->SPR; if (!isnan(fs)) fprintf(fid,"\t\t\"Samplingrate\"\t: %f", fs); // 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) { fprintf(fid,",\n\t\"EVENT\"\t: ["); for (k = 0; k < hdr->EVENT.N; k++) { if (k>0) 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\",\n", hdr->EVENT.POS[k]/hdr->EVENT.SampleRate); if (hdr->EVENT.CHN && hdr->EVENT.DUR) { fprintf(fid,"\t\t\"CHN\"\t: \"0x%04x\",\n", hdr->EVENT.CHN[k]); fprintf(fid,"\t\t\"DUR\"\t: \"%f\",\n", hdr->EVENT.DUR[k]/hdr->EVENT.SampleRate); } 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 else if (hdr->EVENT.TYP[k] < hdr->EVENT.LenCodeDesc) fprintf(fid,"\t\t\"Description\"\t: \"%s\"\n",hdr->EVENT.CodeDesc[hdr->EVENT.TYP[k]]); // no comma at the end because its the last element else if (GLOBAL_EVENTCODES_ISLOADED) { uint16_t k1; for (k1=0; (k1 < Global.LenCodeDesc) && (hdr->EVENT.TYP[k] != Global.CodeIndex[k1]); k1++) {}; if (k1 < Global.LenCodeDesc) fprintf(fid,"\t\t\"Description\"\t: \"%s\"\n", Global.CodeDesc[k1]); // no comma at the end because its the last element } fprintf(fid,"\t\t}"); } 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 (!GLOBAL_EVENTCODES_ISLOADED) LoadGlobalEventCodeTable(); if (VERBOSE==7) { T0 = gdf_time2tm_time(hdr->T0); char tmp[60]; strftime(tmp, 59, "%x %X %Z", T0); fprintf(fid,"\tStartOfRecording: %s\n",tmp); return(0); } if (VERBOSE==-1) { return(hdr2json(hdr,fid)); } 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 %#.16lx\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); fprintf(fid, "\tName : %s\n",hdr->Patient.Name); 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) { T0 = gdf_time2tm_time(hdr->Patient.Birthday); fprintf(fid,"\tAge : %4.1f years\n\tBirthday : (%.6f) %s ",age,ldexp(hdr->Patient.Birthday,-32),asctime(T0)); } else fprintf(fid,"\tAge : ----\n\tBirthday : unknown\n"); T0 = gdf_time2tm_time(hdr->T0); strftime(tmp, 59, "%x %X %Z", T0); fprintf(fid,"\tStartOfRecording: (%.6f) %s\n",ldexp(hdr->T0,-32),asctime(T0)); if (hdr->AS.bci2000 != NULL) { 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); } 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 char p[MAX_LENGTH_PHYSDIM+1]; const char *label = cp->Label; if (label==NULL || strlen(label)==0) label = LEAD_ID_TABLE[cp->LeadIdCode]; if (cp->PhysDimCode) PhysDim(cp->PhysDimCode, p); else p[0] = 0; fprintf(fid,"\n#%02i: %3i %i %-17s\t%5f %5i", (int)k+1, cp->LeadIdCode, cp->bi8, label, 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); 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, p, 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] N=%i Fs=%f",hdr->EVENT.N,hdr->EVENT.SampleRate); fprintf(fid,"\nNo\tTYP\tPOS\tDUR\tCHN\tVAL\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.DUR != NULL) fprintf(fid,"\t%5d\t%d",hdr->EVENT.DUR[k],hdr->EVENT.CHN[k]); if ((hdr->EVENT.TYP[k] == 0x7fff) && (hdr->TYPE==GDF)) fprintf(fid,"\t[neds]"); else if (hdr->EVENT.TYP[k] < hdr->EVENT.LenCodeDesc) fprintf(fid,"\t\t%s",hdr->EVENT.CodeDesc[hdr->EVENT.TYP[k]]); else if (GLOBAL_EVENTCODES_ISLOADED) { uint16_t k1; for (k1=0; (k1 < Global.LenCodeDesc) && (hdr->EVENT.TYP[k] != Global.CodeIndex[k1]); k1++) {}; if (k1 < Global.LenCodeDesc) fprintf(fid,"\t\t%s",Global.CodeDesc[k1]); } } } if (VERBOSE>4) { if (hdr->aECG && (hdr->TYPE==SCP_ECG)) { aECG_TYPE* aECG = (aECG_TYPE*)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); const char* StatusString; switch (aECG->Section8.Confirmed) { case 0: StatusString = "Original (not overread)"; break; case 1: StatusString = "Confirmed"; break; case 2: StatusString = "Overread (not confirmed)"; break; default: StatusString = "unknown"; break; } 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); 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); 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); } } fprintf(fid,"\n\n"); return(0); } /* end of HDR2ASCII */ /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ biosig4c++-1.3.0/biosig.h000066400000000000000000000670441175724200100150030ustar00rootroot00000000000000/* % $Id: biosig.h,v 1.140 2009/04/09 15:06:55 schloegl Exp $ % Copyright (C) 2005,2006,2007,2008,2009,2010,2011 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 . */ /* 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 */ /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ #ifndef __BIOSIG_EXT_H__ #define __BIOSIG_EXT_H__ #ifdef _VCPP_DEF #define __BYTE_ORDER __LITTLE_ENDIAN typedef unsigned __int64 uint64_t; typedef __int64 int64_t; typedef unsigned long uint32_t; typedef long int32_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef char int8_t; #else #include #endif #ifdef WITH_HDF5 #include #endif #ifdef WITH_NIFTI #include #endif #ifdef __cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C #endif /* Including ZLIB enables reading gzipped files (they are decompressed on-the-fly) The output files can be zipped, too. */ #ifdef WITH_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 WITH_CHOLMOD #ifdef __APPLE__ #include #else #include #endif #endif #ifdef WITH_GSL #include #endif #include #include /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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, }; #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, 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, }; extern int B4C_ERRNUM; extern const char *B4C_ERRMSG; #define BIOSIG_VERSION_MAJOR 1 #define BIOSIG_VERSION_MINOR 3 #define BIOSIG_PATCHLEVEL 0 // for backward compatibility #define BIOSIG_VERSION_STEPPING BIOSIG_PATCHLEVEL #define BIOSIG_VERSION (BIOSIG_VERSION_MAJOR * 10000 + BIOSIG_VERSION_MINOR * 100 + BIOSIG_PATCHLEVEL) extern int VERBOSE_LEVEL; // used for debugging //#define VERBOSE_LEVEL 7 // turn on debugging information //#define VERBOSE_LEVEL 0 // turn off debugging information /****************************************************************************/ /** **/ /** DEFINITIONS, TYPEDEFS AND MACROS **/ /** **/ /****************************************************************************/ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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; /* gdf time is represented in 64 bits */ #define t_time2gdf_time(t) ((gdf_time)floor(ldexp(((double)(t))/86400.0 + 719529.0, 32))) #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)) #ifdef __cplusplus EXTERN_C { #endif /* * converts struct tm into gdf_time format */ gdf_time tm_time2gdf_time(struct tm *t); /* * gdf_time2tm_time converts gdf-time into struct tm format, */ struct tm *gdf_time2tm_time(gdf_time t); /* * re-entrant version of gdf_time2tm_time, memory for t must be allocated */ int gdf_time2tm_time_r(gdf_time t, struct tm *tm); #ifdef __cplusplus } #endif typedef int64_t nrec_t; /* type for number of records */ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /* This structure defines the header for each channel (variable header) */ #define MAX_LENGTH_LABEL 40 // TMS: 40 #define MAX_LENGTH_TRANSDUCER 80 #define MAX_LENGTH_PHYSDIM 20 #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 #ifdef __GNUC__ #define ATT_ALI __attribute__ ((aligned (8))) /* Matlab v7.3+ requires 8 byte alignment*/ #define ATT_DEPREC __attribute__ ((deprecated)) #else /* TODO (FIXME): not clear whether this alignment definition is equivalent to the one above: This might be crucial for a mixed compiler environment e.g. libbiosig compiled with MinGW used in a MS VC++ project */ #pragma pack(8) #define ATT_ALI #define ATT_DEPREC #endif 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 OnOff ATT_ALI; char Label[MAX_LENGTH_LABEL+1] ATT_ALI; /* Label of channel */ uint16_t LeadIdCode ATT_ALI; /* Lead identification code */ char Transducer[MAX_LENGTH_TRANSDUCER+1] ATT_ALI; /* transducer e.g. EEG: Ag-AgCl electrodes */ char PhysDim[MAX_LENGTH_PHYSDIM+1] ATT_ALI ATT_DEPREC; /* physical dimension */ /*PhysDim is now obsolete - use function PhysDim(PhysDimCode,PhysDimText) instead */ uint16_t PhysDimCode ATT_ALI; /* code for physical dimension */ /* char* PreFilt; // pre-filtering */ 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; uint16_t GDFTYP ATT_ALI; /* data type */ 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 */ uint8_t* bufptr ATT_ALI; /* pointer to buffer: NRec<=1 and bi,bi8 not used */ } CHANNEL_TYPE ATT_ALI; /* This structure defines the general (fixed) header */ typedef struct { enum FileFormat TYPE ATT_ALI; /* type of file format */ float VERSION ATT_ALI; /* GDF version number */ char* FileName ATT_ALI; /* FileName - dynamically allocated, local copy of file name */ struct { size_t size[2] ATT_ALI; /* size {rows, columns} of data block */ biosig_data_type* block ATT_ALI; /* data block */ } data ATT_ALI; uint32_t HeadLen ATT_ALI; /* length of header in bytes */ uint16_t NS ATT_ALI; /* number of channels */ uint32_t SPR ATT_ALI; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ nrec_t NRec ATT_ALI; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate ATT_ALI; /* Sampling rate */ uint8_t IPaddr[16] ATT_ALI; /* IP address of recording device (if applicable) */ uint32_t LOC[4] ATT_ALI; /* location of recording according to RFC1876 */ gdf_time T0 ATT_ALI; /* starttime of recording */ int16_t tzmin ATT_ALI; /* time zone (minutes of difference to 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 { 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 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 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" */ char _field[MAX_LENGTH_MANUF+1]; /* buffer */ const char* Name; const char* Model; const char* Version; const char* SerialNumber; } 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 */ uint32_t N ATT_ALI; /* number of events */ uint16_t *TYP ATT_ALI; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ 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 */ char **CodeDesc ATT_ALI; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 */ char CNT32; /* 0: assume CNT format is 16 bit [default], <>0: CNT format is 32 bit*/ } 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 { // 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 */ char flag_collapsed_rawdata; /* 0 if rawdata contain obsolete channels, too. */ 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 */ uint32_t SegSel[5]; /* segment selection in a hirachical data formats, e.g. sweeps in HEKA/PatchMaster format */ char* bci2000; } AS ATT_ALI; void *aECG; /* used as an pointer to (non-standard) auxilary information - mostly used for hacks */ } HDRTYPE; /* 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 }; // Groups of event codes struct event_groups_t { uint16_t groupid; const char* GroupDescription; // const decrease signifitiantly number of warning }; struct FileFormatStringTable_t { enum FileFormat fmt; const char* FileTypeString; }; extern const struct etd_t ETD []; extern const struct event_groups_t EventCodeGroups []; extern const struct FileFormatStringTable_t FileFormatStringTable []; /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ #ifdef __cplusplus EXTERN_C { #endif 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* getfiletype(HDRTYPE* hdr); /* identify file format from header information input: hdr->AS.Header contains header of hdr->HeadLen bytes hdr->TYPE must CHANNEL_TYPE *CHANNEL ATT_ALI; 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 --------------------------------------------------------------- */ 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. 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, long int offset, int whence); /* positions file pointer * * Currently, this function is meaning less because sread requires always the start value --------------------------------------------------------------- */ long int stell(HDRTYPE* hdr); /* returns position of file point in segments --------------------------------------------------------------- */ 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. --------------------------------------------------------------- */ 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 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 --------------------------------------------------------------- */ 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*) ------------------------------------------------------------------------*/ const char* GetFileTypeString(enum FileFormat FMT); /* returns a string with file format --------------------------------------------------------------- */ enum FileFormat GetFileTypeFromString(const char *); /* returns file format from string --------------------------------------------------------------- */ uint16_t PhysDimCode(const char* PhysDim0); /* 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); /* 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) --------------------------------------------------------------- */ double PhysDimScale(uint16_t PhysDimCode); /* returns scaling factor of physical dimension e.g. 0.001 for milli, 1000 for kilo etc. --------------------------------------------------------------- */ void sort_eventtable(HDRTYPE *hdr); /* sort event table with respect to hdr->EVENT.POS --------------------------------------------------------------*/ 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 -------------------------------------------------------------- */ #ifdef __cplusplus } #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/ #endif /* __BIOSIG_EXT_H__ */ biosig4c++-1.3.0/biosig.pro000066400000000000000000000006071175724200100153440ustar00rootroot00000000000000TEMPLATE = 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 biosig4c++-1.3.0/biosig_client.c000066400000000000000000000174031175724200100163260ustar00rootroot00000000000000/* $Id: biosig_client.c,v 1.5 2009-02-27 09:21:11 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 "biosig-network.h" #include #include #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 = strcpy(path2keys,getenv("HOME")); str += strlen(path2keys); str[0] = FILESEP; str = 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 (!strncmpi(clbuf,"exit",4) || !strncmpi(clbuf,"bye",3)) { fprintf(stdout,"\n%p>\n",cmd); bscs_close(sd); close(sd); break; } // fprintf(stdout,"cmd=<%s> %i\n",cmd,strncmpi(cmd,"close",5)); if (cmd[0]=='!') system(cmd+1); else if (!strncmpi(cmd,"ow+c",4)) { ID = 0; s=bscs_open(sd, &ID); fprintf(stdout,"ow ID=%16Lx s=%i %08x\n",ID,s,s); s=bscs_close(sd); fprintf(stdout,"c ID=%16Lx s=%i %08x\n",ID,s,s); } else if (!strncmpi(cmd,"or+c",4)) { ID = l_endian_u64(0x233ab6dfc96f664fLL); s=bscs_open(sd, &ID); fprintf(stdout,"or ID=%16Lx 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=%16Lx s=%i %08x\n",ID,s,s); } else if (!strncmpi(cmd,"openr",5)) { ID = l_endian_u64(0x233ab6dfc96f664fLL); ID = l_endian_u64(0x233ab6dfc96f664fLL); fprintf(stdout,"or ID=%16Lx s=%i %08x\n",ID,s,s); s=bscs_open(sd, &ID); } else if (!strncmpi(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=%16Lx s=%i %08x\n",ID,s,s); } else if (!strncmpi(cmd,"sendhdr",7)) { s= bscs_send_hdr(sd, hdr); } else if (!strncmpi(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 (!strncmpi(cmd,"sendevt",7)) { if (hdr->TYPE != GDF) hdrEVT2rawEVT(hdr); if (hdr->EVENT.N>0) s= bscs_send_evt(sd, hdr); } else if (!strncmpi(cmd,"hdr",3)) { bscs_requ_hdr(sd,hdr); } else if (!strncmpi(cmd,"show1",5)) { hdr2ascii(hdr,stdout,1); } else if (!strncmpi(cmd,"show2",5)) { hdr2ascii(hdr,stdout,2); } else if (!strncmpi(cmd,"show3",5)) { hdr2ascii(hdr,stdout,3); } else if (!strncmpi(cmd,"show4",5)) { hdr2ascii(hdr,stdout,4); } else if (!strncmpi(cmd,"dat",3)) { bscs_requ_dat(sd,0,hdr->NRec,hdr); } else if (!strncmpi(cmd,"evt",3)) { bscs_requ_evt(sd,hdr); } else if (!strncmpi(cmd,"ow",2)) { ID = 0; s=bscs_open(sd, &ID); fprintf(stdout,"ow ID=%16Lx s=%i %08x\n",ID,s,s); } else if (!strncmpi(cmd,"close",5)) { s=bscs_close(sd); fprintf(stdout,"oc ID=%16Lx s=%i %08x\n",ID,s,s); } else if (!strncmpi(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 (!strncmpi(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 (serror()) { 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=%16Lx ",argv[1],ID); fclose(fid); fprintf(stdout,"open_w ID=%Lx\n",ID); hdr->HeadLen = count; bscs_send_dat(sd, buf, count); bscs_close(sd); } free(buf); } } else { sread_raw(0,hdr->NRec,hdr,1); // collapse rawdata (remove obsolete channels) size_t bpb = bpb8_collapsed_rawdata(hdr)>>3; if (serror()) { 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/%16Lx",argv[1],ID); fclose(fid); fprintf(stdout,"open_w ID=%16Lx len=%i\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 %i\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); } biosig4c++-1.3.0/biosig_server.c000066400000000000000000000673111175724200100163610ustar00rootroot00000000000000/* $Id: biosig_server.c,v 1.7 2009-04-08 15:55:56 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 "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 = b_endian_u32(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,b_endian_u32(msg.STATE),b_endian_u32(msg.LEN),errno,strerror(errno)); size_t LEN = b_endian_u32(msg.LEN); FILE *fid = fopen(LOGFILE,"a"); fprintf(stdout,"STATUS=%08x c=%i MSG=%08x len=%i,errno=%i %s\n",STATUS,count,b_endian_u32(msg.STATE),b_endian_u32(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 = b_endian_u32(8); *(uint64_t*)&msg.LOAD = l_endian_u64(ID); 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(&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 = b_endian_u32(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 (serror() || (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 = b_endian_u32(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 = b_endian_u32(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 (serror()) 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 = b_endian_u32(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] = l_endian_u32(hdr->EVENT.POS[k]); hdr->EVENT.TYP[k] = l_endian_u16(hdr->EVENT.TYP[k]); } if (flag==3) { for (size_t k=n; kEVENT.N; k++) { hdr->EVENT.DUR[k] = l_endian_u32(hdr->EVENT.DUR[k]); hdr->EVENT.CHN[k] = l_endian_u16(hdr->EVENT.CHN[k]); } } #endif msg.STATE = BSCS_VERSION_01 | BSCS_SEND_EVT | BSCS_REPLY | STATE_OPEN_WRITE; } msg.LEN = b_endian_u32(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 = b_endian_u32(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 = b_endian_u32(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 = b_endian_u32(0); s = send(ns, &msg, 8, 0); } else { msg.LEN = b_endian_u32(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=serror(); if (status) { errcode = 2; #else { #endif sopen(f2,"r",hdr); if ((status=serror())) errcode = 11; else { count = sread(NULL,0,hdr->NRec,hdr); if ((status=serror())) errcode = 12; sclose(hdr); if ((status=serror())) 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=serror())) { errcode = 21; } else { //count = swrite(hdr->data.block, hdr->NRec, hdr); ifwrite(hdr->AS.rawdata,hdr->AS.bpb,hdr->NRec,hdr); if ((status=serror())) errcode = 22; sclose(hdr); if ((status=serror())) 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 | b_endian_u32(errcode); msg.LEN = b_endian_u32(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(&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 = b_endian_u32(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 = b_endian_u32(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); } biosig4c++-1.3.0/doc/000077500000000000000000000000001175724200100141105ustar00rootroot00000000000000biosig4c++-1.3.0/doc/heka2itx.1000066400000000000000000000016171175724200100157160ustar00rootroot00000000000000.TH HEKA2ITX 1 .SH NAME heka2itx - converts different biomedical signal file formats. .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 exeripment 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,2011,2011 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 http://biosig.sf.net biosig4c++-1.3.0/doc/mexSLOAD.1000066400000000000000000000020571175724200100155520ustar00rootroot00000000000000.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,2010 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 http://biosig.sf.net biosig4c++-1.3.0/doc/save2gdf.1000066400000000000000000000021321175724200100156710ustar00rootroot00000000000000.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,2010 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 http://biosig.sf.net biosig4c++-1.3.0/doc/sigviewer.1000066400000000000000000000016351175724200100162030ustar00rootroot00000000000000.TH SigViewer 1 .SH NAME SigViewer - a viewing and scoring tools for biomedical signals. .SH SYNOPSIS .R 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) 2008,2010 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 http://biosig.sf.net biosig4c++-1.3.0/eventcodes.awk000077500000000000000000000041601175724200100162120ustar00rootroot00000000000000#!/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]) | "sort >> 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]) | "sort >> eventcodes.i" } } biosig4c++-1.3.0/heka2itx000077500000000000000000000001371175724200100150110ustar00rootroot00000000000000#!/bin/sh #conversion from HEKA DAT2 to ITX format format save2gdf -f=ITX $1 $2 $3 $4 $5 $6 $7 biosig4c++-1.3.0/igor/000077500000000000000000000000001175724200100143035ustar00rootroot00000000000000biosig4c++-1.3.0/igor/Makefile000066400000000000000000000074151175724200100157520ustar00rootroot00000000000000# 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 distclean: rm *.o *.xop *~ biosig4c++-1.3.0/igor/README000066400000000000000000000023111175724200100151600ustar00rootroot00000000000000# 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 biosig4c++-1.3.0/igor/patchIgorXOPs.diff000066400000000000000000000323731175724200100176370ustar00rootroot00000000000000diff -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 biosig4c++-1.3.0/igor/patchMinGW_utils_reimp.diff000066400000000000000000000013471175724200100215570ustar00rootroot00000000000000? 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) biosig4c++-1.3.0/igor/xopSLOAD.c000066400000000000000000000077771175724200100160620ustar00rootroot00000000000000// // 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 = serror(); if (p->res) return(0); // read data biosig_data_type* data = NULL; sread(data, 0, -1, hdr); p->res = serror(); if (p->res) return(0); // close file sclose(hdr); p->res = serror(); return(0); } int UFPE_BioSigOpen( inSOpen_t* p) // IGOR wrapper for Biosig.SOpen() { int hState; hdr = sopen( p->FileName, "r", hdr ); p->res = (double)B4C_ERRNUM; // if ( B4C_ERRNUM ) { char buf[500]; sprintf( buf, "\t\tUFPE_BioSigOpen...receives '%s' : %s, returns code=%d \r", p->FileName, B4C_ERRMSG, B4C_ERRNUM ); XOPNotice( buf ); 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 = serror(); // ..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 ///////////////////////////////////////////////////////////////////////////////////////// */ biosig4c++-1.3.0/java/000077500000000000000000000000001175724200100142645ustar00rootroot00000000000000biosig4c++-1.3.0/java/Makefile000066400000000000000000000012741175724200100157300ustar00rootroot00000000000000####### 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-Java interface is available here # http://www.swig.org/Doc1.3/Java.html all: swig -c++ -java biosig.i g++ -fPIC -c biosig_wrap.cxx -I/usr/lib/gcc/x86_64-linux-gnu/4.4/include/ -I/usr/lib/jvm/java-1.5.0-gcj-4.4/include ld -G biosig_wrap.o -o libbiosig4java.so clean: -rm *.java -rm *.o -rm *.cxx -rm *.so biosig4c++-1.3.0/java/biosig.i000066400000000000000000000242551175724200100157220ustar00rootroot00000000000000/* % % $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, 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 PhysDim(PhysDimCode,PhysDimText) 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 { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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; %immutable; 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 { // 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 */ 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; } AS; void *aECG; %mutable; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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 hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/mex/000077500000000000000000000000001175724200100141345ustar00rootroot00000000000000biosig4c++-1.3.0/mex/Makefile000066400000000000000000000114451175724200100156010ustar00rootroot00000000000000####### Makefile for "BioSig for C/C++" ##################### ### ### $Id$ ### Copyright (C) 2006,2007,2008,2009,2011,2012 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ### modify directories according to your needs INCOCTAVE = -I /usr/include/octave MATLABDIR = /usr/local/MATLAB/R2010b/ # comment the following line if you use MATLAB on 32-bit operating system MEX_OPTION += -largeArrayDims # LIBEXT. Setting it to 'a' links statically, 'so' links dynamically LIBEXT = a #LIBEXT = so # # include directory for Win32-Matlab include W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ GNUMEX = $(HOME)/bin/win32/gnumex GNUMEX64 = $(HOME)/bin/win64/gnumex ############################### ### User-specified options: its likely you want to change this MEX_OPTION = -largeArrayDims # turn on for 64 bit Matlab, otherwise empty LIBS = -lbiosig $(LDLIBS) LFLAGS = -L.. COPY = cp mex: mex4m mex4o win32 win mexw32: mexSLOAD.mexw32 mexSOPEN.mexw32 mexSSAVE.mexw32 win64 mexw64: mexSLOAD.mexw64 mexSOPEN.mexw64 mexSSAVE.mexw64 all: mex4m mex4o win32 win64 clean: -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex* ########################################################## ## 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 # Octave - global install (e.g. from debian package) # - defined as variable by calling function # OCTAVE_VERSION = OCT = mkoctfile$(OCTAVE_VERSION) ########################################################## ../libbiosig.$(LIBEXT): $(MAKE) -C .. libbiosig.$(LIBEXT) ../win32/libbiosig.a: $(MAKE) -C .. win32/libbiosig.a ############################################################# # MEX-Interface for Octave and Matlab ############################################################# mex: mex4m mex4o ifneq ($(shell which matlab), ) mex4m: mexSLOAD.$(MEX_EXT) mexSOPEN.$(MEX_EXT) mexSSAVE.$(MEX_EXT) mexSLOAD: mexSLOAD.$(MEX_EXT) mexSOPEN: mexSOPEN.$(MEX_EXT) %.$(MEX_EXT): %.cpp ../libbiosig.$(LIBEXT) Makefile $(MEX) $(MEX_OPTION) $(DEFINES) $< $(LFLAGS) $(LIBS) -$(COPY) $@ ../../biosig/t200_FileAccess/ mexSOPEN.$(MEX_EXT): mexSLOAD.cpp ../libbiosig.$(LIBEXT) Makefile $(MEX) $(MEX_OPTION) -DmexSOPEN $(DEFINES) mexSLOAD.cpp $(LFLAGS) $(LIBS) -output mexSOPEN -$(COPY) mexSOPEN.$(MEX_EXT) ../../biosig/t200_FileAccess/ endif ### MEX-files for Octave mex4o: mexSLOAD.mex mexSOPEN.mex mexSSAVE.mex %.mex: %.cpp ../libbiosig.$(LIBEXT) Makefile $(OCT) $(DEFINES) -v -g --mex $< $(LFLAGS) $(LIBS) -$(COPY) $@ ../../biosig/t200_FileAccess/ mexSOPEN.mex: mexSLOAD.cpp ../libbiosig.$(LIBEXT) Makefile $(OCT) -D=mexSOPEN $(DEFINES) -v -g --mex mexSLOAD.cpp $(LFLAGS) $(LIBS) -o mexSOPEN.mex -$(COPY) mexSOPEN.mex ../../biosig/t200_FileAccess/ #physicalunits.mex: physicalunits.cpp libbiosig.$(LIBEXT) # $(OCT) -v -g --mex physicalunits.cpp $(LFLAGS) $(LIBS) oct: mexSLOAD.oct mexSLOAD.oct: mexSLOAD.cpp ../libbiosig.$(LIBEXT) Makefile $(OCT) $(DEFINES) mexSLOAD.cpp $(LFLAGS) $(LIBS) $(OCT) -D=mexSOPEN $(DEFINES) mexSLOAD.cpp $(LFLAGS) $(LIBS) -o mexSOPEN.oct -$(COPY) mexSOPEN.oct ../../biosig/t200_FileAccess/ -$(COPY) mexSOPEN.oct ../../biosig/t200_FileAccess/ ######################################################### # MATLAB/WIN32 ######################################################### %.obj: %.cpp $(CROSS)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 $< %.obj: %.c $(CROSS)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 $< mexSOPEN.obj: mexSLOAD.cpp $(CROSS)-$(CXX) -c -DMATLAB_MEX_FILE -D=mexSOPEN -x c++ -o $@ -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 $< %.mexw32: %.obj ../win32/libbiosig.a $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o $@ -L$(GNUMEX) -s $< -llibmx -llibmex ../win32/libbiosig.a $(LDLIBS) -lws2_32 ######################################################### # MATLAB/WIN64 ######################################################### %.o64: %.cpp $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W64MAT_INC) -O2 $< %.o64: %.c $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o $@ -I$(W64MAT_INC) -O2 $< mexSOPEN.o64: mexSLOAD.cpp $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -D=mexSOPEN -x c++ -o $@ -I$(W64MAT_INC) -O2 $< %.mexw64: %.o64 ../win64/libbiosig.a $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o $@ -L$(GNUMEX64) -s $< -llibmx -llibmex ../win64/libbiosig.a $(LDLIBS) -lws2_32 biosig4c++-1.3.0/mex/README000066400000000000000000000026611175724200100150210ustar00rootroot00000000000000This 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. The prerequisites are sudo apt-get install zlib1g-dev libsuitesparse-dev octave-headers The mex files for Octave are generated with make mex4o == Matlab on Linux ======================= Prerequisites: sudo apt-get install zlib1g-dev libsuitesparse-dev octave-headers Edit Makefile and set the correct path to Matlab: The mex files for Matlab are generated with 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 $Id: README,v 1.26 2009/02/27 09:18:33 schloegl Exp $ Copyright (C) 2011 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig4c++-1.3.0/mex/mexSLOAD.cpp000066400000000000000000000660151175724200100162240ustar00rootroot00000000000000/* $Id$ Copyright (C) 2007,2008,2009,2010 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 "../biosig-dev.h" #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; #endif #endif typedef mwSize Int; #define TRUE (1) #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 */ Int stype /* -1: lower, 0: unsymmetric, 1: upper */ ) { Int *Ap ; A->nrow = mxGetM (Amatlab) ; A->ncol = mxGetN (Amatlab) ; A->p = (Int *) mxGetJc (Amatlab) ; A->i = (Int *) mxGetIr (Amatlab) ; Ap = (Int*)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; char FLAG_CNT32 = 0; int argSweepSel = -1; #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(" 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"); mexPrintf("\t[s,HDR]=mexSLOAD(f,ReRef)\n\t\treref is a (sparse) matrix for rerefencing\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'...')\n"); mexPrintf("\t[s,HDR]=mexSLOAD(f,chan,'CNT32')\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(" Input:\n\tf\tfilename\n"); mexPrintf("\tchan\tlist of selected channels; 0=all channels [default]\n"); mexPrintf("\tCNT32: needed to read 32bit CNT files \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"); 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 } #ifdef CHOLMOD_H else if ((k==1) && mxIsSparse(arg)) { rr = sputil_get_sparse(arg,&RR,&dummy,0); } #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")) FLAG_CNT32 = 1; 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 (!strcmpi(mxArrayToString(prhs[k]), "SWEEP") && (prhs[k+1] != NULL) && mxIsNumeric(prhs[k+1])) argSweepSel = ++k; } else { #ifndef mexSOPEN mexPrintf("mexSLOAD: argument #%i is invalid.",k+1); mexErrMsgTxt("mexSLOAD failes 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); hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = FlagUCAL; hdr->FLAG.CNT32 = FLAG_CNT32; #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++; } } if (VERBOSE_LEVEL>7) mexPrintf("120: going to sopen\n"); hdr = sopen(FileName, "r", hdr); /* #ifdef WITH_PDP if (B4C_ERRNUM) { B4C_ERRNUM = 0; sopen_pdp_read(hdr); } #endif */ if (VERBOSE_LEVEL>7) mexPrintf("121: sopen done\n"); if ((status=serror())) { const char* fields[]={"TYPE","VERSION","FileName","FLAG","ErrNum","ErrMsg"}; HDR = mxCreateStructMatrix(1, 1, 6, fields); mxSetField(HDR,0,"FileName",mxCreateString(hdr->FileName)); 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) { const char *p = GetFileTypeString(hdr->TYPE); if (p) mxSetField(HDR,0,"TYPE",mxCreateString(p)); } #else mxSetField(HDR,0,"TYPE",mxCreateString(GetFileTypeString(hdr->TYPE))); #endif mxSetField(HDR,0,"VERSION",mxCreateDoubleScalar(hdr->VERSION)); 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,GetFileTypeString(hdr->TYPE)); /* 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, GetFileTypeString(hdr->TYPE), 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, GetFileTypeString(hdr->TYPE), 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 mexSLOAD: Overflowdetection not supported in file %s\n",hdr->FileName); if (hdr->FLAG.UCAL != FlagUCAL) mexPrintf("Warning mexSLOAD: Flag UCAL is %i instead of %i (%s)\n",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=serror())) return; if (VERBOSE_LEVEL>7) fprintf(stderr,"\n[129] SREAD/SCLOSE on %s successful [%i,%i] [%Li,%i] %i.\n",hdr->FileName,hdr->data.size[0],hdr->data.size[1],hdr->NRec,count,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","FILE","Patient",\ "HeadLen","NS","SPR","NRec","SampleRate", "FLAG", \ "EVENT","Label","LeadIdCode","PhysDimCode","PhysDim","Filter",\ "PhysMax","PhysMin","DigMax","DigMin","Transducer","Cal","Off","GDFTYP","TOffset",\ "LowPass","HighPass","Notch","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))); /* 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)); mxSetCell(Transducer,k1,mxCreateString(hdr->CHANNEL[k].Transducer)); char p[MAX_LENGTH_PHYSDIM+1]; PhysDim(hdr->CHANNEL[k].PhysDimCode,p); mxSetCell(PhysDim1,k1,mxCreateString(p)); 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","Orientation","Area","GND","REF",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); 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[1]; if (hdr->Patient.Name) { strarray[0] = hdr->Patient.Name; mxSetField(Patient,0,"Name",mxCreateCharMatrixFromStrings(1,strarray)); } if (hdr->Patient.Id) { strarray[0] = hdr->Patient.Id; mxSetField(Patient,0,"Id",mxCreateCharMatrixFromStrings(1,strarray)); } 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); if (hdr->ID.Manufacturer.Name) { strarray[0] = hdr->ID.Manufacturer.Name; mxSetField(Manufacturer,0,"Name",mxCreateCharMatrixFromStrings(1,strarray)); } if (hdr->ID.Manufacturer.Model) { strarray[0] = hdr->ID.Manufacturer.Model; mxSetField(Manufacturer,0,"Model",mxCreateCharMatrixFromStrings(1,strarray)); } if (hdr->ID.Manufacturer.Version) { strarray[0] = hdr->ID.Manufacturer.Version; mxSetField(Manufacturer,0,"Version",mxCreateCharMatrixFromStrings(1,strarray)); } if (hdr->ID.Manufacturer.SerialNumber) { strarray[0] = hdr->ID.Manufacturer.SerialNumber; mxSetField(Manufacturer,0,"SerialNumber",mxCreateCharMatrixFromStrings(1,strarray)); } 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"); }; biosig4c++-1.3.0/mex/mexSSAVE.cpp000066400000000000000000000367611175724200100162500ustar00rootroot00000000000000/* $Id$ Copyright (C) 2011 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 "../biosig-dev.h" #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; #endif #endif typedef mwSize Int; #define TRUE (1) //#define VERBOSE_LEVEL 9 //extern int VERBOSE_LEVEL; //#define DEBUG 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); } 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; char FLAG_CNT32 = 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; hdr->FLAG.CNT32 = FLAG_CNT32; #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, "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 ( (p1 = mxGetField(p, 0, "CNT32") ) != NULL ) hdr->FLAG.CNT32 = (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 = (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 (serror()) mexErrMsgTxt("mexSSAVE: sopen failed \n"); swrite((biosig_data_type*)data, hdr->NRec, hdr); if (serror()) mexErrMsgTxt("mexSSAVE: swrite failed \n"); destructHDR(hdr); if (serror()) mexErrMsgTxt("mexSSAVE: sclose failed \n"); }; biosig4c++-1.3.0/mma/000077500000000000000000000000001175724200100141155ustar00rootroot00000000000000biosig4c++-1.3.0/mma/INSTALL000066400000000000000000000023461175724200100151530ustar00rootroot00000000000000 == Compling for Linux/Unix/Mac platform =============== adapt biosig4c++/Makefile and biosig4c++/mma/Makefile with the correct directory in the section "userspecified variables" and run cd biosig4c++/mma/ make sload == Compiling on Windows =============================== Prerequisites: MinGW Mathematica (tested with v7.0) Download and extract sources of biosig4c++ (v0.96.2 or later) Start MinGW shell cd biosig4c++/mma make -f Makefile.win32 sload.exe == 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 Alois Schloegl [1] http://pub.ist.ac.at/~schloegl/biosig/TESTED biosig4c++-1.3.0/mma/Makefile000066400000000000000000000073621175724200100155650ustar00rootroot00000000000000####### Makefile to compile sload.exe for loading data supported by libbiosig into Mathematica ### ### $Id$ ### Copyright (C) 2010,2011,2012 Alois Schloegl, IST Austria ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## ########################################### # user-defined variables ########################################### ########################################################## ## set Mathematica variables MLINKDIR = /usr/local/Wolfram/gridMathematicaServer/7.0/SystemFiles/Links/MathLink/DeveloperKit MLINKDIR = /usr/local/Wolfram/Mathematica/8.0/SystemFiles/Links/MathLink/DeveloperKit ifneq ($(shell which mathematica), ) MLINKDIR := $(dir $(shell readlink -f $(shell which mathematica) ) )../SystemFiles/Links/MathLink/DeveloperKit endif SYS = Linux-x86-64# Set this value with the result of evaluating $SystemID MLLIB = ML64i3 # ML32i3 # Set this to ML64i3 if using a 64-bit system # # Windows #MLINKDIR = /usr/local/Wolfram/gridMathematicaServer/7.0/SystemFiles/Links/MathLink/DeveloperKit SYSwin = Windows# Set this value with the result of evaluating $SystemID MLLIBwin = ml32i3m# Set this to ML64i3 if using a 64-bit system ########################################### CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions INCDIR = ${CADDSDIR} LIBDIR = ${CADDSDIR} EXTRALIBS = -lm -lpthread -lrt -lstdc++ $(LDLIBS) -L.. -lbiosig# Set these with appropriate libs for your system. MPREP = ${CADDSDIR}/mprep all : sload sload.exe sload.w64.exe win win32 : sload.exe ../libbiosig.a: make -C .. libbiosig.a ../win32/libbiosig.a: make -C .. win32/libbiosig.a ../win64/libbiosig.a: make -C .. win64/libbiosig.a .c.o : ${CC} -c -I${INCDIR} $< sloadtm.c : sload.tm ${MPREP} $< -o $@ sload : sload.o sloadtm.o ../libbiosig.a ${CC} sloadtm.o sload.o -L${LIBDIR} -l${MLLIB} ${EXTRALIBS} -o $@ ########################################### # Win32 - cross-compilation ########################################### CCw32 = $(CROSS)-gcc CADDSDIRwin = ${MLINKDIR}/${SYSwin}/CompilerAdditions/mldev32 INCDIRwin = ${CADDSDIRwin}/include LIBDIRwin = ${CADDSDIRwin}/lib EXTRALIBSwin = ../win32/libbiosig.a -lgdi32 -lm -lpthread -lstdc++ -lws2_32 $(LDLIBS) # Set these with appropriate libs for your system. MPREPwin = ${CADDSDIRwin}/bin/mprep.exe sloadtm.win32.c : sload.tm wine ${MPREPwin} $? -o $@ sload.obj : sload.c ${CCw32} -c -I${INCDIRwin} $< -o $@ sloadtm.obj : sloadtm.win32.c ${CCw32} -c -I${INCDIRwin} $< -o $@ sload.exe : sload.obj sloadtm.obj ../win32/libbiosig.a ${CCw32} sload.obj sloadtm.obj -static-libgcc -static-libstdc++ -L${LIBDIRwin} -l${MLLIBwin} ${EXTRALIBSwin} -o $@ ########################################### # Win64 - cross-compilation ########################################### CCw64 = $(CROSS64)-gcc CADDSDIRwin64 = ${MLINKDIR}/${SYSwin}/CompilerAdditions/mldev64 INCDIRwin64 = ${CADDSDIRwin64}/include LIBDIRwin64 = ${CADDSDIRwin64}/lib EXTRALIBSwin64 = ../win64/libbiosig.a -lgdi32 -lm -lpthread -lstdc++ -lws2_32 $(LDLIBS) # Set these with appropriate libs for your system. MPREPwin64 = ${CADDSDIRwin64}/bin/mprep.exe sloadtm.win64.c : sload.tm wine ${MPREPwin64} $? -o $@ sload.w64.obj : sload.c ${CCw64} -c -I${INCDIRwin64} $< -o $@ sloadtm.w64.obj : sloadtm.win64.c ${CCw64} -c -I${INCDIRwin64} $< -o $@ sload.w64.exe : sload.obj sloadtm.w64.obj ../win64/libbiosig.a ${CCw64} sload.w64.obj sloadtm.w64.obj -static-libgcc -static-libstdc++ -L${LIBDIRwin64} -l${MLLIBwin64} ${EXTRALIBSwin64} -o $@ ########################################### clean: -$(RM) *.o -$(RM) *.obj -$(RM) *tm.c -$(RM) sload.exe -$(RM) sload biosig4c++-1.3.0/mma/Makefile.win32000066400000000000000000000023721175724200100165220ustar00rootroot00000000000000# 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 biosig4c++-1.3.0/mma/README000066400000000000000000000005271175724200100150010ustar00rootroot00000000000000This 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] Copyright (C) 2011 Alois Schloegl [1] http://pub.ist.ac.at/~schloegl/biosig/TESTED biosig4c++-1.3.0/mma/mySLOAD.nb000066400000000000000000000227061175724200100156550ustar00rootroot00000000000000(* 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[ 9471, 205] NotebookOptionsPosition[ 9193, 191] NotebookOutlinePosition[ 9530, 206] CellTagsIndexPosition[ 9487, 203] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{"(*", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ "Platform", " ", "independent", " ", "loading", " ", "of", " ", "biosignal", " ", "data", "\[IndentingNewLine]", " ", "Copyright", " ", "2011", " ", "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[{ RowBox[{"mySLOAD", "[", RowBox[{"filename_", ",", " ", "sweeps_"}], "]"}], ":=", " ", RowBox[{"Module", " ", "[", RowBox[{ RowBox[{"{", RowBox[{"link", ",", " ", "data"}], "}"}], ",", " ", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"mySLOAD", ":", " ", RowBox[{"makes", " ", "it", " ", "platform", " ", "independent"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"link", "=", RowBox[{"Install", "[", RowBox[{"Switch", "[", RowBox[{ "$SystemID", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\""}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"data", " ", "=", " ", RowBox[{"sload", "[", RowBox[{"filename", ",", "sweeps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Uninstall", "[", "link", "]"}], ";", "\[IndentingNewLine]", "data"}]}], " ", RowBox[{"(*", " ", RowBox[{"return", " ", "data"}], " ", "*)"}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", "\[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}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ "This", " ", "demonstrates", " ", "the", " ", "usage", " ", "of", " ", "the", " ", "above", " ", "module", " ", "mySLOAD", "\[IndentingNewLine]", "On", " ", "Windows", " ", "platform", " ", "the", " ", "directory", " ", "separators", " ", "must", " ", "be", " ", "either", " ", "a", " ", "single", " ", "forward", " ", "slash", " ", "\"\\"", " ", "or", " ", "double", " ", "backward", " ", "slashes", " ", "\"\<\\\\\>\""}], "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"filename", " ", "=", " ", RowBox[{"Switch", "[", RowBox[{ "$SystemID", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\"", ",", "\[IndentingNewLine]", "\"\\"", ",", " ", "\"\\""}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"data", " ", "=", " ", RowBox[{"mySLOAD", "[", RowBox[{"filename", ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"signal", " ", "=", " ", RowBox[{"data", "[", RowBox[{"[", "1", "]"}], "]"}]}], " ", RowBox[{"(*", " ", RowBox[{"sampled", " ", "data"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"t", " ", "=", " ", RowBox[{"data", "[", RowBox[{"[", "2", "]"}], "]"}]}], " ", RowBox[{"(*", " ", RowBox[{"sampling", " ", "time", " ", "points"}], " ", "*)"}], "\[IndentingNewLine]"}]}]], "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}}] }, WindowSize->{740, 867}, WindowMargins->{{124, Automatic}, {Automatic, 3}}, 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, 6389, 121, 669, "Input"], Cell[6949, 143, 2240, 46, 282, "Input"] } ] *) (* End of internal cache information *) biosig4c++-1.3.0/mma/sload.c000066400000000000000000000046521175724200100153720ustar00rootroot00000000000000/* % $Id$ % Copyright (C) 2010, 2011 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 "mathlink.h" #include "../biosig.h" #include #define VERBOSE_LEVEL 0 void sload(const char *fn, int *SZ, long SZlen) { HDRTYPE *hdr = constructHDR(0,0); if (VERBOSE_LEVEL > 5) fprintf(stdout,"=== start sload ===\n"); // contains [experiment,series,sweep,trace] numbers for selecting data. size_t k = 0; while (k < SZlen && k < 5) { hdr->AS.SegSel[k] = (uint32_t)SZ[k]; k++; } // ********* open file and read header ************ hdr = sopen(fn, "r", hdr); if (serror()) { fprintf(stdout,"Cannot open file <%s>\n", fn); return; } if (VERBOSE_LEVEL > 5) fprintf(stdout,"open filename <%s>NoOfChans=%i\n", fn, hdr->NS); // ********** read data ******************** hdr->FLAG.ROW_BASED_CHANNELS = 1; sread(NULL, 0, hdr->NRec*hdr->SPR, hdr); #ifdef _WIN32 long int sz[2]; #else size_t sz[2]; #endif sz[0] = hdr->data.size[1]; sz[1] = hdr->data.size[0]; MLPutFunction(stdlink, "List", 2); // write data matrix MLPutRealArray(stdlink, hdr->data.block, sz, NULL, 2); // generate and write time axis double *t = (double*)malloc(hdr->NRec*hdr->SPR*sizeof(double)); for (k=0; kNRec*hdr->SPR;) { t[k] = (++k)/hdr->SampleRate; } MLPutRealList(stdlink, t, hdr->NRec*hdr->SPR); free(t); if (VERBOSE_LEVEL > 5) { for (k=0;kNS;k++) fprintf(stdout,"%f ",hdr->data.block[k]); fprintf(stdout,"\n\nopen filename <%s>@%p sz=[%i,%i]\n", fn, hdr->data.block, hdr->data.size[0], hdr->data.size[1]); } // *********** close file ********************* sclose(hdr); destructHDR(hdr); return; } int main(int argc, char *argv[]) { return MLMain(argc, argv); } biosig4c++-1.3.0/mma/sload.tm000066400000000000000000000017741175724200100155720ustar00rootroot00000000000000:Begin: :Function: sload :Pattern: sload[fn_String, i_List] :Arguments: {fn, i} :ArgumentTypes: {String, IntegerList} :ReturnType: Manual :End: :Evaluate: sload::usage = "data = 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: 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 with two elements, the first containing the 2-dim array of data samples, the second contains the time axis in seconds.\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)." biosig4c++-1.3.0/patches/000077500000000000000000000000001175724200100147725ustar00rootroot00000000000000biosig4c++-1.3.0/patches/patch_mce-w64_io_h.diff000066400000000000000000000017631175724200100211720ustar00rootroot00000000000000*** io.h.orig 2011-02-09 22:58:42.000000000 +0100 --- io.h 2011-05-07 00:01:11.979900542 +0200 *************** *** 340,346 **** int __cdecl open(const char *_Filename,int _OpenFlag,...); int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount); int __cdecl setmode(int _FileHandle,int _Mode); ! int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...); long __cdecl tell(int _FileHandle); int __cdecl umask(int _Mode); int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount); --- 340,346 ---- int __cdecl open(const char *_Filename,int _OpenFlag,...); int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount); int __cdecl setmode(int _FileHandle,int _Mode); ! // int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...); long __cdecl tell(int _FileHandle); int __cdecl umask(int _Mode); int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount); biosig4c++-1.3.0/patches/patch_mingw_io_h.diff000066400000000000000000000025061175724200100211250ustar00rootroot00000000000000*** ../mingw-cross-env/usr/i686-pc-mingw32/include/io.h.orig Wed Feb 2 13:57:17 2011 --- ../mingw-cross-env/usr/i686-pc-mingw32/include/io.h Wed Feb 2 13:57:42 2011 *************** *** 451,457 **** --- 451,459 ---- _CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...); _CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int); _CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int); + #if !__UNISTD_H_SOURCED__ _CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...); + #endif _CRTIMP long __cdecl __MINGW_NOTHROW tell (int); _CRTIMP int __cdecl __MINGW_NOTHROW umask (int); _CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*); *** ../mxe/usr/i686-pc-mingw32/include/io.h.orig Wed Feb 2 13:57:17 2011 --- ../mxe/usr/i686-pc-mingw32/include/io.h Wed Feb 2 13:57:42 2011 *************** *** 451,457 **** --- 451,459 ---- _CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...); _CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int); _CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int); + #if !__UNISTD_H_SOURCED__ _CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...); + #endif _CRTIMP long __cdecl __MINGW_NOTHROW tell (int); _CRTIMP int __cdecl __MINGW_NOTHROW umask (int); _CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*); biosig4c++-1.3.0/patches/patch_sigviewer-0.5.0.diff000066400000000000000000000031441175724200100214470ustar00rootroot00000000000000Index: src/src.pro =================================================================== --- src/src.pro (revision 543) +++ src/src.pro (working copy) @@ -34,7 +34,7 @@ $$_PRO_FILE_PWD_/. LIBS += -L$$_PRO_FILE_PWD_/../extern/lib \ -lbiosig \ - -lGDF + -lGDF -lcholmod -lz RESOURCES = src.qrc win32:RC_FILE = src.rc Index: src/version.txt =================================================================== --- src/version.txt (revision 543) +++ src/version.txt (working copy) @@ -1,2 +1,2 @@ -0.5.0 +0.5.1-as Index: src/file_handling_impl/biosig_reader.cpp =================================================================== --- src/file_handling_impl/biosig_reader.cpp (revision 543) +++ src/file_handling_impl/biosig_reader.cpp (working copy) @@ -56,6 +56,12 @@ FILE_SIGNAL_READER_REGISTRATION(cnt, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(eeg, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(bkr, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(gz, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(itx, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(rec, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(acq, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(bva, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(vhdr, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(evt, BioSigReader); @@ -192,7 +198,7 @@ destructHDR(biosig_header_); biosig_header_ = 0; delete c_file_name; - return "file not supported"; + return B4C_ERRMSG; } // (C) 2008 AS: EVENT.DUR and EVENT.CHN are optional in SOPEN, but SigViewer needs them. patch_sigviewer_0.5.1-as.3-DisplayHeaderInfo+EventTableAlways4Columns+SampleRateChanged2FLOAT64.diff000066400000000000000000000662071175724200100367360ustar00rootroot00000000000000biosig4c++-1.3.0/patchesIndex: src/file_handling/channel_manager.h =================================================================== --- src/file_handling/channel_manager.h (revision 556) +++ src/file_handling/channel_manager.h (working copy) @@ -43,13 +43,13 @@ unsigned length) const = 0; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const = 0; + virtual float64 getDurationInSec () const = 0; //------------------------------------------------------------------------- virtual uint32 getNumberSamples () const = 0; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const = 0; + virtual float64 getSampleRate () const = 0; //------------------------------------------------------------------------- void addDownsampledMinMaxVersion (ChannelID id, QSharedPointer min, Index: src/src.pro =================================================================== --- src/src.pro (revision 556) +++ src/src.pro (working copy) @@ -33,8 +33,7 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/../extern/include \ $$_PRO_FILE_PWD_/. LIBS += -L$$_PRO_FILE_PWD_/../extern/lib \ - -lbiosig# \ - #-lGDF + -lbiosig -lcholmod -lz RESOURCES = src.qrc win32:RC_FILE = src.rc Index: src/version.txt =================================================================== --- src/version.txt (revision 556) +++ src/version.txt (working copy) @@ -1,2 +1,2 @@ -0.5.1 +0.5.1-as.3 Index: src/file_handling_impl/biosig_reader.cpp =================================================================== --- src/file_handling_impl/biosig_reader.cpp (revision 556) +++ src/file_handling_impl/biosig_reader.cpp (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2005,2006,2007 Copyright (C) Christoph Eibel 2007,2008 Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 Copyright (C) Oliver Terbu 2008 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -57,6 +57,11 @@ FILE_SIGNAL_READER_REGISTRATION(cnt, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(vhdr, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(bkr, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(gz, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(itx, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(rec, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(acq, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(bva, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(evt, BioSigReader); @@ -181,7 +186,7 @@ destructHDR(biosig_header_); biosig_header_ = 0; delete c_file_name; - return "file not supported"; + return B4C_ERRMSG; } // (C) 2008 AS: EVENT.DUR and EVENT.CHN are optional in SOPEN, but SigViewer needs them. @@ -281,10 +286,10 @@ void BioSigReader::bufferAllEvents () const { unsigned number_events = biosig_header_->EVENT.N; + // Hack Hack: Transforming Events to have the same sample rate as the signals + double rate_transition = basic_header_->getEventSamplerate() / biosig_header_->EVENT.SampleRate; for (unsigned index = 0; index < number_events; index++) { - // Hack Hack: Transforming Events to have the same sample rate as the signals - double rate_transition = basic_header_->getEventSamplerate() / biosig_header_->EVENT.SampleRate; QSharedPointer event (new SignalEvent (biosig_header_->EVENT.POS[index] * rate_transition, biosig_header_->EVENT.TYP[index], biosig_header_->EVENT.SampleRate * rate_transition)); @@ -295,7 +300,12 @@ else event->setChannel (biosig_header_->EVENT.CHN[index] - 1); event->setDuration (biosig_header_->EVENT.DUR[index] * rate_transition); - } + } + else + { + event->setChannel (UNDEFINED_CHANNEL); + event->setDuration (1); + } events_.append (event); } Index: src/file_handling_impl/sinus_dummy_reader.cpp =================================================================== --- src/file_handling_impl/sinus_dummy_reader.cpp (revision 556) +++ src/file_handling_impl/sinus_dummy_reader.cpp (working copy) @@ -29,11 +29,11 @@ data->push_back (sin(sample_index / ((i*i+1)))); QSharedPointer data_block (new FixedDataBlock (data, 100)); data_.insert(i, data_block); - +/* QSharedPointer channel (new SignalChannel(i, QString::number(i))); header->addDummyChannel(i, channel); - header_ = header; +*/ header_ = header; } for (int i = 0; i < 40; i++) Index: src/file_handling_impl/channel_manager_impl.cpp =================================================================== --- src/file_handling_impl/channel_manager_impl.cpp (revision 556) +++ src/file_handling_impl/channel_manager_impl.cpp (working copy) @@ -66,7 +66,7 @@ } //----------------------------------------------------------------------------- -float32 ChannelManagerImpl::getDurationInSec () const +float64 ChannelManagerImpl::getDurationInSec () const { return reader_->getBasicHeader()->getNumberOfSamples() / reader_->getBasicHeader()->getSampleRate(); @@ -80,7 +80,7 @@ } //----------------------------------------------------------------------------- -float32 ChannelManagerImpl::getSampleRate () const +float64 ChannelManagerImpl::getSampleRate () const { return reader_->getBasicHeader()->getSampleRate(); } Index: src/file_handling_impl/biosig_basic_header.cpp =================================================================== --- src/file_handling_impl/biosig_basic_header.cpp (revision 556) +++ src/file_handling_impl/biosig_basic_header.cpp (working copy) @@ -1,3 +1,26 @@ +/* + + $Id$ + Copyright (C) Christoph Eibel 2010, 2011 + Copyright (C) Alois Schloegl 2011 + This file is part of the "SigViewer" 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 . + +*/ + #include "biosig_basic_header.h" #include @@ -48,6 +71,7 @@ { for (unsigned channel_index = 0; channel_index < raw_header->NS; channel_index++) { +/* QString label = QString (QByteArray(raw_header->CHANNEL[channel_index].Label, MAX_LENGTH_LABEL)).trimmed(); char p[MAX_LENGTH_PHYSDIM+1]; @@ -56,8 +80,8 @@ QString phys_y_dim_label = QString (p).trimmed(); if (phys_y_dim_label.compare("uV") == 0) phys_y_dim_label = QString (QChar((ushort)0xb5)).append("V"); - QSharedPointer channel (new SignalChannel(channel_index, label, - phys_y_dim_label)); +*/ + QSharedPointer channel (new SignalChannel(channel_index, raw_header)); addChannel (channel_index, channel); } } Index: src/file_handling_impl/channel_manager_impl.h =================================================================== --- src/file_handling_impl/channel_manager_impl.h (revision 556) +++ src/file_handling_impl/channel_manager_impl.h (working copy) @@ -41,13 +41,13 @@ unsigned length) const; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const; + virtual float64 getDurationInSec () const; //------------------------------------------------------------------------- virtual uint32 getNumberSamples () const; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const; + virtual float64 getSampleRate () const; private: FileSignalReader* reader_; Index: src/gui_impl/dialogs/basic_header_info_dialog.cpp =================================================================== --- src/gui_impl/dialogs/basic_header_info_dialog.cpp (revision 556) +++ src/gui_impl/dialogs/basic_header_info_dialog.cpp (working copy) @@ -1,3 +1,26 @@ +/* + + $Id: biosig_reader.cpp,v 1.36 2009/03/03 11:57:07 cle1109 Exp $ + Copyright (C) Christoph Eibel 2010, 2011 + Copyright (C) Alois Schloegl 2011 + This file is part of the "SigViewer" 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 . + +*/ + // basic_header_info_dialog.cpp #include "basic_header_info_dialog.h" @@ -176,7 +199,9 @@ tmp_item = new QTreeWidgetItem(channel_item); tmp_item->setText(0, tr("Sample Rate")); - tmp_item->setText(1, QString::number(basic_header_->getSampleRate())); + float64 fs = channel->getSampleRate(); + if (fs < 0.0) fs = basic_header_->getSampleRate(); + tmp_item->setText(1, QString::number(fs)); tmp_item->setText(2, tr("Hz")); tmp_item = new QTreeWidgetItem(channel_item); Index: src/gui_impl/dialogs/about_dialog.ui =================================================================== --- src/gui_impl/dialogs/about_dialog.ui (revision 556) +++ src/gui_impl/dialogs/about_dialog.ui (working copy) @@ -47,7 +47,7 @@ <tr> <td style="border: none;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt; font-weight:600;">SigViewer [VERSION-NUMBER]</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sigviewer.sf.net"><span style=" font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;">http://sigviewer.sourceforge.net/</span></a></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sigviewer.sf.net"><span style=" font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;">http://biosig.sourceforge.net/</span></a></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Clemens Brunner (Coordinator)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Christoph Eibel</span></p> Index: src/gui_impl/processed_signal_channel_manager.cpp =================================================================== --- src/gui_impl/processed_signal_channel_manager.cpp (revision 556) +++ src/gui_impl/processed_signal_channel_manager.cpp (working copy) @@ -4,7 +4,7 @@ { //------------------------------------------------------------------------- -ProcessedSignalChannelManager::ProcessedSignalChannelManager (float32 sample_rate, unsigned length, QObject* parent) +ProcessedSignalChannelManager::ProcessedSignalChannelManager (float64 sample_rate, unsigned length, QObject* parent) : QObject (parent), sample_rate_ (sample_rate), length_ (length) @@ -69,9 +69,9 @@ } //------------------------------------------------------------------------- -float32 ProcessedSignalChannelManager::getDurationInSec () const +float64 ProcessedSignalChannelManager::getDurationInSec () const { - return static_cast(length_) / sample_rate_; + return static_cast(length_) / sample_rate_; } //------------------------------------------------------------------------- @@ -81,7 +81,7 @@ } //------------------------------------------------------------------------- -float32 ProcessedSignalChannelManager::getSampleRate () const +float64 ProcessedSignalChannelManager::getSampleRate () const { return sample_rate_; } Index: src/gui_impl/processed_signal_channel_manager.h =================================================================== --- src/gui_impl/processed_signal_channel_manager.h (revision 556) +++ src/gui_impl/processed_signal_channel_manager.h (working copy) @@ -13,7 +13,7 @@ { public: //------------------------------------------------------------------------- - ProcessedSignalChannelManager (float32 sample_rate, unsigned length, QObject* parent); + ProcessedSignalChannelManager (float64 sample_rate, unsigned length, QObject* parent); //------------------------------------------------------------------------- void addChannel (ChannelID id, QSharedPointer data_block, @@ -44,13 +44,13 @@ unsigned length) const; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const; + virtual float64 getDurationInSec () const; //------------------------------------------------------------------------- virtual uint32 getNumberSamples () const; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const; + virtual float64 getSampleRate () const; private: float32 sample_rate_; Index: src/base/signal_channel.cpp =================================================================== --- src/base/signal_channel.cpp (revision 556) +++ src/base/signal_channel.cpp (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2006,2007 Copyright (C) Christoph Eibel 2007,2008, Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -31,14 +31,60 @@ { //----------------------------------------------------------------------------- +SignalChannel::SignalChannel (unsigned ch, + const HDRTYPE* hdr) : + number_ (ch), + label_ (QString(hdr->CHANNEL[ch].Label).trimmed()), + physical_maximum_(hdr->CHANNEL[ch].PhysMax), + digital_maximum_(hdr->CHANNEL[ch].DigMax), + physical_minimum_(hdr->CHANNEL[ch].PhysMin), + digital_minimum_(hdr->CHANNEL[ch].DigMin), + data_type_(hdr->CHANNEL[ch].GDFTYP), + lowpass_(hdr->CHANNEL[ch].LowPass), + highpass_(hdr->CHANNEL[ch].HighPass), + notch_(hdr->CHANNEL[ch].Notch) + +{ +/* + scale_ = (C.PhysMax - C.PhysMin) / (C.DigMax - C.DigMin); + offset_ = C.PhysMin - C.DigMin * scale_; +*/ + char p[MAX_LENGTH_PHYSDIM+1]; + PhysDim(hdr->CHANNEL[ch].PhysDimCode,p); + phys_y_dimension_label_ = QString(p); + samplerate_ = hdr->SampleRate * hdr->CHANNEL[ch].SPR / hdr->SPR; +} + SignalChannel::SignalChannel (unsigned number, - QString const& label, - QString const& phys_y_dimension_label) : + CHANNEL_STRUCT C) : + + /* obsolete */ number_ (number), - label_ (label), - phys_y_dimension_label_ (phys_y_dimension_label) + label_ (QString(C.Label).trimmed()), + physical_maximum_(C.PhysMax), + digital_maximum_(C.DigMax), + physical_minimum_(C.PhysMin), + digital_minimum_(C.DigMin), + data_type_(C.GDFTYP), + lowpass_(C.LowPass), + highpass_(C.HighPass), + notch_(C.Notch) + { +/* + scale_ = (C.PhysMax - C.PhysMin) / (C.DigMax - C.DigMin); + offset_ = C.PhysMin - C.DigMin * scale_; +*/ + char p[MAX_LENGTH_PHYSDIM+1]; + PhysDim(C.PhysDimCode,p); + phys_y_dimension_label_ = QString(p); + samplerate_ = -1.0; +} +//----------------------------------------------------------------------------- +float64 SignalChannel::getSampleRate() const +{ + return samplerate_; } //----------------------------------------------------------------------------- Index: src/base/signal_channel.h =================================================================== --- src/base/signal_channel.h (revision 556) +++ src/base/signal_channel.h (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2006,2007 Copyright (C) Christoph Eibel 2007,2008, Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -32,6 +32,7 @@ #include #include +#include "biosig.h" namespace SigViewer_ { @@ -43,9 +44,8 @@ { public: //------------------------------------------------------------------------- - SignalChannel (unsigned number, - QString const& label, - QString const& phys_y_dimension_label = ""); +SignalChannel (unsigned ch, const HDRTYPE* hdr); +SignalChannel (unsigned number, CHANNEL_STRUCT C); /* obsolete, deprecated */ //------------------------------------------------------------------------- QString typeString() const; @@ -59,6 +59,7 @@ float64 getDigitalMaximum() const; float64 getPhysicalMinimum() const; float64 getDigitalMinimum() const; + float64 getSampleRate() const; private: // from GDF format @@ -95,6 +96,7 @@ uint16_t data_type_; float64 lowpass_; float64 highpass_; + float64 samplerate_; bool notch_; }; Index: src/eventcodes.txt =================================================================== --- src/eventcodes.txt (revision 556) +++ src/eventcodes.txt (working copy) @@ -1,10 +1,28 @@ ### Table of event codes. -# This file is part of the biosig project http://biosig.sf.net/ -# Copyright (C) 2004,2005,2006 Alois Schloegl -# $Id: eventcodes.txt,v 1.4 2008-04-27 10:03:09 cle1109 Exp $ +# 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,2005,2006,2008,2009,2010,2011 Alois Schloegl +# $Id: eventcodes.txt,v 1.15 2009-01-20 16:09:46 schloegl Exp $ +# +# The latest version is available from here: +# http://biosig.svn.sourceforge.net/viewvc/biosig/trunk/biosig/doc/eventcodes.txt # +# 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. +# +# Alternative license: +# This table of event codes can be used in any application +# (without the restrictions of GPL) under the condition that this table +# is not modified, changed, converted or transformed. No +# derivative of any kind are allowed. Suggestions for improvement +# and changes should be addressed to the author. +# ### table of event codes: lines starting with # are omitted -### add 0x8000 to indicate end of event +### add 0x8000 to indicate the end (i.e. offset) of an event # ### 0x010_ EEG artifacts 0x0101 artifact:EOG (blinks, fast, large amplitude) @@ -40,22 +58,25 @@ 0x0132 SSAEP 0x0133 SSSEP ### 0x014_ Response -0x0144 Go -0x0145 NoGo +0x0144 Go +0x0145 NoGo +### 0x02__ Neural spikes, and spike trains +0x0201 Spike onset, action potential +0x0202 Burst ### 0x03__ BCI: Trigger, cues, classlabels, 0x0300 Start of Trial, Trigger at t=0s -0x0301 Left - cue onset (BCI experiment) -0x0302 Right - cue onset (BCI experiment) -0x0303 Foot - cue onset (BCI experiment) -0x0304 Tongue - cue onset (BCI experiment) -0x0305 class5 - cue onset -0x0306 Down - cue onset (BCI experiment) -0x0307 class7 - cue onset -0x0308 class8 - cue onset -0x0309 class9 - cue onset -0x030A class10 - cue onset -0x030B class11 - cue onset -0x030C Up - cue onset (BCI experiment) +0x0301 class1, Left hand - cue onset (BCI experiment) +0x0302 class2, Right hand - cue onset (BCI experiment) +0x0303 class3, Foot, towards Right - cue onset (BCI experiment) +0x0304 class4, Tongue - cue onset (BCI experiment) +0x0305 class5 - cue onset +0x0306 class6, towards Down - cue onset (BCI experiment) +0x0307 class7 - cue onset +0x0308 class8 - cue onset +0x0309 class9, towards Left - cue onset +0x030A class10 - cue onset +0x030B class11 - cue onset +0x030C class12, towards Up - cue onset (BCI experiment) 0x030D Feedback (continuous) - onset (BCI experiment) 0x030E Feedback (discrete) - onset (BCI experiment) 0x030F cue unknown/undefined (used for BCI competition) @@ -67,34 +88,51 @@ 0x0382 target missed, task not reached, incorrect classification 0x03ff Rejection of whole trial ### 0x040_ Respiratory Events -0x0401 Obstructive Apnea/Hypopnea Event (OAHE) -0x0402 Respiratory Effort Related Arousal (RERA) +0x0401 Obstructive apnea/Hypopnea event (OAHE) +0x0402 RERA #(Respiratory Effort Related Arousal) 0x0403 Central Apnea/Hypopnea Event (CAHE) -0x0404 Cheyne-Stokes Breathing (CSB) -0x0405 Sleep Hypoventilation -0x040e (time of) maximum inspiration -0x040f Start of inspiration, (end of expiration) -### 0x041_ Sleep stages according to Rechtschaffen&Kales -0x0410 Wake -0x0411 Stage 1 -0x0412 Stage 2 -0x0413 Stage 3 -0x0414 Stage 4 -0x0415 REM +0x0404 CS Breathing #(Cheyne-Stokes Breathing) +0x0405 Hypoventilation +0x0406 Apnea +0x0407 Obstructive apnea +0x0408 Central apnea +0x0409 Mixed apnea +0x040A Hypopnea +0x040B Periodic Breathing +0x040C Limb movement +0x040D PLMS +0x040E (time of) maximum inspiration +0x040F Start of inspiration, (end of expiration) +### 0x041_ Sleep stages according to Rechtschaffen&Kales and AASM'07 +0x0410 Sleep stage Wake +0x0411 Sleep stage 1 +0x0412 Sleep stage 2 +0x0413 Sleep stage 3 +0x0414 Sleep stage 4 +0x0415 Sleep stage REM +0x0416 Sleep stage ? +0x0417 Movement time +0x0418 Bruxism +0x0419 RBD #(Rapid eye movement sleep behaviour disorder) +0x041A RMD #(Sleep related rhythmic movement disorder) +0x041B Sleep stage N +0x041C Sleep stage N1 +0x041D Sleep stage N2 +0x041E Sleep stage N3 ### 0x042_ Sleep 0x0420 Lights on #0x8420 Lights off ### 0x043_ Eye movements -0x0430 Eye activity -0x0431 Eyes left -0x0432 Eyes right -0x0433 Eyes up -0x0434 Eyes down -0x0435 Horizontal eye movement -0x0436 Vertical eye movement -0x0437 Eye rotation (clockwise) -0x0438 Eye rotation (counterclockwise) -0x0439 Eye blinks +#0x0430 [obsolete] merged with 0x0115 +0x0431 eyes left +0x0432 eyes right +0x0433 eyes up +0x0434 eyes down +0x0435 horizontal eye movement +0x0436 vertical eye movement +0x0437 eye rotation (clockwise) +0x0438 eye rotation (counterclockwise) +0x0439 eye blinks #0x043f [obsolete] merged with 0x0114 ### 0x044_ muscle activity (for checking on EEG artifacts) 0x0441 left hand movement @@ -104,22 +142,32 @@ 0x0445 swallowing 0x0446 biting, chewing, teeth griding 0x0447 foot movement -%0x0448 foot (right) movement +#0x0448 foot (right) movement 0x0449 arm movement 0x044a arm (right) movement ### 0x050_ ECG events 0x0501 ecg:Fiducial point of QRS complex -0x0502 ecg:P-wave -0x0503 ecg:QRS-complex +0x0502 ecg:P-wave-onset +#0x8502 ecg:P-wave-end +0x0503 ecg:Q-wave-onset, QRS-onset +#0x8503 ecg:Q-wave-peak, Q-wave-end 0x0504 ecg:R-point -0x0506 ecg:T-wave -0x0507 ecg:U-wave +0x0505 ecg:S-wave-onset, S-wave-peak +#0x8505 ecg:S-wave-end, J-point, QRS-end +0x0506 ecg:T-wave-onset +#0x8506 ecg:T-wave-end +0x0507 ecg:U-wave-onset +#0x8507 ecg:U-wave-end +# # related but non-concordant defintions can be found in # - WFDB/MIT-BIH http://www.physionet.org/physiotools/wfdb/lib/ecgcodes.h # - SCP-ECG http://www.centc251.org/TCmeet/doclist/TCdoc02/N02-015-prEN1064.pdf # - FEF/Vital/11073 p.83 # Unification is desired # +# see also 0x2000-0x22ff: +# +# ### 0x058_ ergometric events 0x0580 start 0x0581 25 Watt @@ -137,8 +185,14 @@ 0x058d 325 Watt 0x058e 350 Watt #0x8580 end +### 0x100_ neural spikes +# +### 0x2000-22ff reserved for ECG events (see HL7 10102 Annotated ECG) +# ### 0x00__ user specific events -# the use of these types is discouraged, because of ambigous definitions. +# Often, 1-127 are used for stimulus codes, and 129-255 for response code. +# the use of the following types is discouraged, because of possible ambiguities. +#0x0000 empty event, reserved for special use 0x0001 condition 1 0x0002 condition 2 0x0003 condition 3 @@ -197,12 +251,19 @@ 0x0060 condition 96 0x0063 condition 99 0x0080 condition 128 +0x0081 condition 129 +0x0082 condition 130 +0x0084 condition 131 +0x0085 condition 132 +0x0086 condition 133 +0x0087 condition 134 0x00a6 condition 166 0x00a7 condition 167 0x00a8 condition 168 0x00a9 condition 169 +### 0x4___ up to 4096 different stimuli ### 0x7f__ special codes 0x7ffe start of a new segment (after a break) -0x7fff non-equidistant sampling value +0x7fff non-equidistant sampling value # Index: deb_building_stuff/deb_control_template =================================================================== --- deb_building_stuff/deb_control_template (revision 556) +++ deb_building_stuff/deb_control_template (working copy) @@ -6,6 +6,6 @@ Depends: libqtcore4 (>=4.7), libqtgui4 (>=4.7), libqt4-xml (>=4.7) Replaces: sigviewer (<< ) Installed-Size: -Maintainer: Christoph Eibel -Homepage: http://sigviewer.sourceforge.net +Maintainer: Alois Schloegl +Homepage: http://biosig.sourceforge.net Description: SigViewer is a powerful viewing application for biosignals, originally designed to display electroencephalographic (EEG) data. a858c8c3324967ec48d66eb05ae0bb73f155464e.paxheader00006660000000000000000000000233117572420010020445xustar00rootroot00000000000000155 path=biosig4c++-1.3.0/patches/patch_sigviewer_0.5.1-as.4-DisplayHeaderInfo+EventTableAlways4Columns+SampleRateChanged2FLOAT64+libbiosigEventTable.diff a858c8c3324967ec48d66eb05ae0bb73f155464e.data000066400000000000000000001304121175724200100173060ustar00rootroot00000000000000Index: src/file_handling/basic_header.h =================================================================== --- src/file_handling/basic_header.h (revision 556) +++ src/file_handling/basic_header.h (working copy) @@ -38,7 +38,7 @@ {return recording_info_;} //------------------------------------------------------------------------- - float getSampleRate () const; + float64 getSampleRate () const; //------------------------------------------------------------------------- QSharedPointer getChannel (ChannelID id) const; @@ -47,7 +47,7 @@ unsigned getNumberChannels() const; //------------------------------------------------------------------------- - virtual uint32 getNumberOfSamples () const = 0; + virtual size_t getNumberOfSamples () const = 0; //------------------------------------------------------------------------- virtual QMap getNamesOfUserSpecificEvents () const @@ -73,7 +73,7 @@ //------------------------------------------------------------------------- /// required - void setSampleRate (float sample_rate); + void setSampleRate (float64 sample_rate); //------------------------------------------------------------------------- /// required @@ -92,7 +92,7 @@ private: QString const file_path_; QString file_type_string_; - float sample_rate_; + float64 sample_rate_; QMap > channels_; QMap recording_info_; QMap patient_info_; Index: src/file_handling/channel_manager.h =================================================================== --- src/file_handling/channel_manager.h (revision 556) +++ src/file_handling/channel_manager.h (working copy) @@ -43,13 +43,13 @@ unsigned length) const = 0; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const = 0; + virtual float64 getDurationInSec () const = 0; //------------------------------------------------------------------------- - virtual uint32 getNumberSamples () const = 0; + virtual size_t getNumberSamples () const = 0; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const = 0; + virtual float64 getSampleRate () const = 0; //------------------------------------------------------------------------- void addDownsampledMinMaxVersion (ChannelID id, QSharedPointer min, Index: src/file_handling/basic_header.cpp =================================================================== --- src/file_handling/basic_header.cpp (revision 556) +++ src/file_handling/basic_header.cpp (working copy) @@ -12,7 +12,7 @@ } //----------------------------------------------------------------------------- -float32 BasicHeader::getSampleRate () const +float64 BasicHeader::getSampleRate () const { return sample_rate_; } @@ -61,7 +61,7 @@ } //------------------------------------------------------------------------- -void BasicHeader::setSampleRate (float sample_rate) +void BasicHeader::setSampleRate (float64 sample_rate) { sample_rate_ = sample_rate; } Index: src/src.pro =================================================================== --- src/src.pro (revision 556) +++ src/src.pro (working copy) @@ -33,7 +33,7 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/../extern/include \ $$_PRO_FILE_PWD_/. LIBS += -L$$_PRO_FILE_PWD_/../extern/lib \ - -lbiosig# \ + -lbiosig -lcholmod -lz -lcurl \ #-lGDF RESOURCES = src.qrc Index: src/version.txt =================================================================== --- src/version.txt (revision 556) +++ src/version.txt (working copy) @@ -1,2 +1,2 @@ -0.5.1 +0.5.1-as.5 Index: src/file_handling_impl/sinus_dummy_reader.cpp =================================================================== --- src/file_handling_impl/sinus_dummy_reader.cpp (revision 556) +++ src/file_handling_impl/sinus_dummy_reader.cpp (working copy) @@ -29,10 +29,11 @@ data->push_back (sin(sample_index / ((i*i+1)))); QSharedPointer data_block (new FixedDataBlock (data, 100)); data_.insert(i, data_block); - +/* QSharedPointer channel (new SignalChannel(i, QString::number(i))); header->addDummyChannel(i, channel); +*/ header_ = header; } Index: src/file_handling_impl/biosig_reader.cpp =================================================================== --- src/file_handling_impl/biosig_reader.cpp (revision 556) +++ src/file_handling_impl/biosig_reader.cpp (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2005,2006,2007 Copyright (C) Christoph Eibel 2007,2008 Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 Copyright (C) Oliver Terbu 2008 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -57,6 +57,12 @@ FILE_SIGNAL_READER_REGISTRATION(cnt, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(vhdr, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(bkr, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(gz, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(itx, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(rec, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(acq, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(bva, BioSigReader); +FILE_SIGNAL_READER_REGISTRATION(hea, BioSigReader); FILE_SIGNAL_READER_REGISTRATION(evt, BioSigReader); @@ -101,10 +107,8 @@ void BioSigReader::doClose () const { if (biosig_header_) - { - sclose (biosig_header_); destructHDR (biosig_header_); - } + biosig_header_ = 0; } @@ -181,7 +185,7 @@ destructHDR(biosig_header_); biosig_header_ = 0; delete c_file_name; - return "file not supported"; + return B4C_ERRMSG; } // (C) 2008 AS: EVENT.DUR and EVENT.CHN are optional in SOPEN, but SigViewer needs them. @@ -281,10 +285,10 @@ void BioSigReader::bufferAllEvents () const { unsigned number_events = biosig_header_->EVENT.N; + // Hack Hack: Transforming Events to have the same sample rate as the signals + double rate_transition = basic_header_->getEventSamplerate() / biosig_header_->EVENT.SampleRate; for (unsigned index = 0; index < number_events; index++) { - // Hack Hack: Transforming Events to have the same sample rate as the signals - double rate_transition = basic_header_->getEventSamplerate() / biosig_header_->EVENT.SampleRate; QSharedPointer event (new SignalEvent (biosig_header_->EVENT.POS[index] * rate_transition, biosig_header_->EVENT.TYP[index], biosig_header_->EVENT.SampleRate * rate_transition)); @@ -295,7 +299,12 @@ else event->setChannel (biosig_header_->EVENT.CHN[index] - 1); event->setDuration (biosig_header_->EVENT.DUR[index] * rate_transition); - } + } + else + { + event->setChannel (UNDEFINED_CHANNEL); + event->setDuration (1); + } events_.append (event); } Index: src/file_handling_impl/biosig_writer.cpp =================================================================== --- src/file_handling_impl/biosig_writer.cpp (revision 556) +++ src/file_handling_impl/biosig_writer.cpp (working copy) @@ -73,7 +73,7 @@ std::set const& types) { if (file_formats_support_event_saving_.count(target_type_) == 0) - return QObject::tr("Can't write events to that file that file type!"); + return QObject::tr("Can't write events to that file type!"); QList events; @@ -109,7 +109,6 @@ if (error) QMessageBox::critical(0, "Events not saved!!!", QString::number(error)); - sclose (header); destructHDR (header); return ""; Index: src/file_handling_impl/event_table_file_reader.cpp =================================================================== --- src/file_handling_impl/event_table_file_reader.cpp (revision 556) +++ src/file_handling_impl/event_table_file_reader.cpp (working copy) @@ -1,3 +1,25 @@ +/* + + $Id$ + Copyright (C) Christoph Eibel 2010 + Copyright (C) Alois Schloegl 2011 + and others ??? + + 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 "event_table_file_reader.h" #include @@ -16,9 +38,8 @@ //------------------------------------------------------------------------------------------------- EventTableFileReader::EventTableFileReader() { - QSettings settings; - QString event_codes_file = settings.value ("eventcodes_file", ":/eventcodes.txt").toString(); - load (event_codes_file); + load (); + event_group_ids_.append (UNKNOWN_GROUP_ID); group_id2name_[UNKNOWN_GROUP_ID] = UNKNOWN_GROUP_ID; } @@ -29,60 +50,28 @@ // nothing } -// load -bool EventTableFileReader::load(const QString& file_name) +// load pre-defined event codes from libbiosig +bool EventTableFileReader::load() { - event_file_path_ = file_name; - QFile file(file_name); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return false; - - // load event type table - QTextStream file_stream(&file); - QString group_id; - while (true) - { - QString one_line = file_stream.readLine(); - if (one_line.isEmpty()) - { - break; - } - if (one_line.indexOf("### 0x") == 0) - { - group_id = one_line.mid(4, 6); - if (!group_id2name_.contains(group_id)) - { - QString group_name; - int32 begin_name = one_line.indexOf(QRegExp("[^ \t]"), 10); - if (begin_name != -1) - { - group_name = one_line.mid(begin_name); - } - group_id2name_[group_id] = group_name; + char g[10]; + uint16_t k; + for (k = 0; EventCodeGroups[k].groupid < 0xffff; k++) { + sprintf(g,"0x%04x", EventCodeGroups[k].groupid); + QString group_id = QString(g); + group_id2name_[group_id] = QString(EventCodeGroups[k].GroupDescription); event_group_ids_ << group_id; - } - } - else if (one_line.indexOf("0x") == 0) - { - uint16 event_type_id = one_line.mid(0, 6).toInt(0, 16); - if (!event_type2name_.contains(event_type_id)) - { - EventItem item; - int32 begin_name = one_line.indexOf(QRegExp("[^ \t]"), 6); - if (begin_name != -1) - { - item.name = one_line.mid(begin_name); - } + } + + EventItem item; + for (k=0; ETD[k].typ ; k++) { + sprintf(g,"0x%04x", ETD[k].groupid); + QString group_id = QString(g); + item.name = QString(ETD[k].desc); item.group_id = group_id; - event_type2name_[event_type_id] = item; - event_types_ << event_type_id; - } - } - } - file.close(); - qSort(event_types_); - qSort(event_group_ids_); - return true; + event_type2name_[ETD[k].typ] = item; + event_types_ << ETD[k].typ; + } + return true; } // get group id begin @@ -127,7 +116,7 @@ //----------------------------------------------------------------------------- void EventTableFileReader::restoreEventNames () { - load (event_file_path_); + load (); } //----------------------------------------------------------------------------- Index: src/file_handling_impl/file_handling_impl.pri =================================================================== --- src/file_handling_impl/file_handling_impl.pri (revision 556) +++ src/file_handling_impl/file_handling_impl.pri (working copy) @@ -5,8 +5,8 @@ file_handling_impl/event_table_file_reader.h \ file_handling_impl/channel_manager_impl.h \ file_handling_impl/biosig_basic_header.h \ - file_handling_impl/sinus_dummy_reader.h \ - file_handling_impl/sinus_dummy_header.h \ + #file_handling_impl/sinus_dummy_reader.h \ + #file_handling_impl/sinus_dummy_header.h \ file_handling_impl/file_handler_factory_registrator.h #\ #file_handling_impl/gdf/gdf_file_signal_writer.h \ #file_handling_impl/gdf/gdf_file_signal_reader.h \ @@ -23,8 +23,8 @@ file_handling_impl/event_table_file_reader.cpp \ file_handling_impl/channel_manager_impl.cpp \ file_handling_impl/biosig_basic_header.cpp \ - file_handling_impl/sinus_dummy_reader.cpp \ - file_handling_impl/sinus_dummy_header.cpp #\ + #file_handling_impl/sinus_dummy_reader.cpp \ + #file_handling_impl/sinus_dummy_header.cpp #\ #file_handling_impl/gdf/gdf_file_signal_writer.cpp \ #file_handling_impl/gdf/gdf_file_signal_reader.cpp \ #file_handling_impl/gdf/gdf_basic_header.cpp \ Index: src/file_handling_impl/event_table_file_reader.h =================================================================== --- src/file_handling_impl/event_table_file_reader.h (revision 556) +++ src/file_handling_impl/event_table_file_reader.h (working copy) @@ -1,3 +1,27 @@ +/* + + $Id$ + Copyright (C) Christoph Eibel 2010 + Copyright (C) Alois Schloegl 2011 + and others ??? + This file is part of the "SigViewer" 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 . + +*/ + // event_table_file_reader.h #ifndef EVENT_TABLE_FILE_READER @@ -4,6 +28,7 @@ #define EVENT_TABLE_FILE_READER #include "base/sigviewer_user_types.h" +#include "biosig.h" #include #include @@ -11,6 +36,7 @@ #include + class QTextStream; namespace SigViewer_ @@ -53,8 +79,7 @@ std::set getAllEventTypes () const; private: - bool load(const QString& file_name); - + bool load(); static QString const UNKNOWN_GROUP_ID; struct EventItem @@ -69,11 +94,11 @@ Q_DISABLE_COPY(EventTableFileReader) QList event_types_; + Int2EventItemMap event_type2name_; + QStringList event_group_ids_; - Int2EventItemMap event_type2name_; String2StringMap group_id2name_; - QString event_file_path_; }; } // namespace SigViewer_ Index: src/file_handling_impl/channel_manager_impl.cpp =================================================================== --- src/file_handling_impl/channel_manager_impl.cpp (revision 556) +++ src/file_handling_impl/channel_manager_impl.cpp (working copy) @@ -66,7 +66,7 @@ } //----------------------------------------------------------------------------- -float32 ChannelManagerImpl::getDurationInSec () const +float64 ChannelManagerImpl::getDurationInSec () const { return reader_->getBasicHeader()->getNumberOfSamples() / reader_->getBasicHeader()->getSampleRate(); @@ -74,13 +74,13 @@ //----------------------------------------------------------------------------- -uint32 ChannelManagerImpl::getNumberSamples () const +size_t ChannelManagerImpl::getNumberSamples () const { return reader_->getBasicHeader()->getNumberOfSamples(); } //----------------------------------------------------------------------------- -float32 ChannelManagerImpl::getSampleRate () const +float64 ChannelManagerImpl::getSampleRate () const { return reader_->getBasicHeader()->getSampleRate(); } Index: src/file_handling_impl/biosig_basic_header.cpp =================================================================== --- src/file_handling_impl/biosig_basic_header.cpp (revision 556) +++ src/file_handling_impl/biosig_basic_header.cpp (working copy) @@ -1,3 +1,26 @@ +/* + + $Id$ + Copyright (C) Christoph Eibel 2010, 2011 + Copyright (C) Alois Schloegl 2011 + This file is part of the "SigViewer" 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 . + +*/ + #include "biosig_basic_header.h" #include @@ -16,14 +39,14 @@ for (unsigned index = 0; index < raw_header->EVENT.LenCodeDesc; index++) { if (raw_header->EVENT.CodeDesc[index]) - user_defined_event_map_[index+1] = QString(raw_header->EVENT.CodeDesc[index]); + user_defined_event_map_[index] = QString(raw_header->EVENT.CodeDesc[index]); } } setFileTypeString (QString (GetFileTypeString(raw_header->TYPE)).append(" v").append(QString::number(raw_header->VERSION))); - float sampling_rate = raw_header->SampleRate; + float64 sampling_rate = raw_header->SampleRate; setSampleRate (sampling_rate); readChannelsInfo (raw_header); @@ -32,7 +55,7 @@ } //----------------------------------------------------------------------------- -uint32 BiosigBasicHeader::getNumberOfSamples () const +size_t BiosigBasicHeader::getNumberOfSamples () const { return ceil(static_cast(number_samples_)); } @@ -48,6 +71,7 @@ { for (unsigned channel_index = 0; channel_index < raw_header->NS; channel_index++) { +/* QString label = QString (QByteArray(raw_header->CHANNEL[channel_index].Label, MAX_LENGTH_LABEL)).trimmed(); char p[MAX_LENGTH_PHYSDIM+1]; @@ -56,8 +80,8 @@ QString phys_y_dim_label = QString (p).trimmed(); if (phys_y_dim_label.compare("uV") == 0) phys_y_dim_label = QString (QChar((ushort)0xb5)).append("V"); - QSharedPointer channel (new SignalChannel(channel_index, label, - phys_y_dim_label)); +*/ + QSharedPointer channel (new SignalChannel(channel_index, raw_header)); addChannel (channel_index, channel); } } Index: src/file_handling_impl/channel_manager_impl.h =================================================================== --- src/file_handling_impl/channel_manager_impl.h (revision 556) +++ src/file_handling_impl/channel_manager_impl.h (working copy) @@ -41,13 +41,13 @@ unsigned length) const; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const; + virtual float64 getDurationInSec () const; //------------------------------------------------------------------------- - virtual uint32 getNumberSamples () const; + virtual size_t getNumberSamples () const; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const; + virtual float64 getSampleRate () const; private: FileSignalReader* reader_; Index: src/file_handling_impl/sinus_dummy_header.h =================================================================== --- src/file_handling_impl/sinus_dummy_header.h (revision 556) +++ src/file_handling_impl/sinus_dummy_header.h (working copy) @@ -13,7 +13,7 @@ SinusDummyHeader (); //------------------------------------------------------------------------- - virtual uint32 getNumberOfSamples () const {return 10000;} + virtual size_t getNumberOfSamples () const {return 10000;} //------------------------------------------------------------------------- void addDummyChannel (ChannelID id, QSharedPointer channel) Index: src/file_handling_impl/biosig_basic_header.h =================================================================== --- src/file_handling_impl/biosig_basic_header.h (revision 556) +++ src/file_handling_impl/biosig_basic_header.h (working copy) @@ -14,7 +14,7 @@ BiosigBasicHeader (HDRTYPE* raw_header, QString const& file_path); //------------------------------------------------------------------------- - virtual uint32 getNumberOfSamples () const; + virtual size_t getNumberOfSamples () const; //------------------------------------------------------------------------- virtual QMap getNamesOfUserSpecificEvents () const; Index: src/gui_impl/signal_browser/signal_browser_model_4.cpp =================================================================== --- src/gui_impl/signal_browser/signal_browser_model_4.cpp (revision 556) +++ src/gui_impl/signal_browser/signal_browser_model_4.cpp (working copy) @@ -358,7 +358,7 @@ //------------------------------------------------------------------------- void SignalBrowserModel::goToSample (unsigned sample) { - float32 position = 0; + float64 position = 0; while (position < getSignalViewSettings()->getPixelsPerSample() * sample) position += getSignalViewSettings()->getPixelsPerSample(); position -= getSignalViewSettings()->getPixelsPerSample(); Index: src/gui_impl/dialogs/basic_header_info_dialog.cpp =================================================================== --- src/gui_impl/dialogs/basic_header_info_dialog.cpp (revision 556) +++ src/gui_impl/dialogs/basic_header_info_dialog.cpp (working copy) @@ -1,3 +1,26 @@ +/* + + $Id: biosig_reader.cpp,v 1.36 2009/03/03 11:57:07 cle1109 Exp $ + Copyright (C) Christoph Eibel 2010, 2011 + Copyright (C) Alois Schloegl 2011 + This file is part of the "SigViewer" 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 . + +*/ + // basic_header_info_dialog.cpp #include "basic_header_info_dialog.h" @@ -176,7 +199,9 @@ tmp_item = new QTreeWidgetItem(channel_item); tmp_item->setText(0, tr("Sample Rate")); - tmp_item->setText(1, QString::number(basic_header_->getSampleRate())); + float64 fs = channel->getSampleRate(); + if (fs < 0.0) fs = basic_header_->getSampleRate(); + tmp_item->setText(1, QString::number(fs)); tmp_item->setText(2, tr("Hz")); tmp_item = new QTreeWidgetItem(channel_item); Index: src/gui_impl/dialogs/about_dialog.ui =================================================================== --- src/gui_impl/dialogs/about_dialog.ui (revision 556) +++ src/gui_impl/dialogs/about_dialog.ui (working copy) @@ -47,17 +47,11 @@ <tr> <td style="border: none;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt; font-weight:600;">SigViewer [VERSION-NUMBER]</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sigviewer.sf.net"><span style=" font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;">http://sigviewer.sourceforge.net/</span></a></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sigviewer.sf.net"><span style=" font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;">http://biosig.sourceforge.net/</span></a></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Clemens Brunner (Coordinator)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Christoph Eibel</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Thomas Brunner</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Laboratory of Brain-Computer Interfaces</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Graz University of Technology</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://bci.tugraz.at"><span style=" font-family:'Sans Serif'; font-size:8pt; text-decoration: underline; color:#0000ff;">http://bci.tugraz.at/</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Thanks to:</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Alois Schlögl (</span><a href="http://biosig.sourceforge.net/"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">BioSig</span></a><span style=" font-family:'Sans Serif'; font-size:8pt;">)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:8pt;">Laurent de Soras (</span><a href="http://ldesoras.free.fr/prod.html"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">FFTReal</span></a><span style=" font-family:'Sans Serif'; font-size:8pt;">)</span></p></td></tr></table></body></html> Index: src/gui_impl/processed_signal_channel_manager.cpp =================================================================== --- src/gui_impl/processed_signal_channel_manager.cpp (revision 556) +++ src/gui_impl/processed_signal_channel_manager.cpp (working copy) @@ -4,7 +4,7 @@ { //------------------------------------------------------------------------- -ProcessedSignalChannelManager::ProcessedSignalChannelManager (float32 sample_rate, unsigned length, QObject* parent) +ProcessedSignalChannelManager::ProcessedSignalChannelManager (float64 sample_rate, unsigned length, QObject* parent) : QObject (parent), sample_rate_ (sample_rate), length_ (length) @@ -69,19 +69,19 @@ } //------------------------------------------------------------------------- -float32 ProcessedSignalChannelManager::getDurationInSec () const +float64 ProcessedSignalChannelManager::getDurationInSec () const { return static_cast(length_) / sample_rate_; } //------------------------------------------------------------------------- -uint32 ProcessedSignalChannelManager::getNumberSamples () const +size_t ProcessedSignalChannelManager::getNumberSamples () const { return length_; } //------------------------------------------------------------------------- -float32 ProcessedSignalChannelManager::getSampleRate () const +float64 ProcessedSignalChannelManager::getSampleRate () const { return sample_rate_; } Index: src/gui_impl/processed_signal_channel_manager.h =================================================================== --- src/gui_impl/processed_signal_channel_manager.h (revision 556) +++ src/gui_impl/processed_signal_channel_manager.h (working copy) @@ -13,7 +13,7 @@ { public: //------------------------------------------------------------------------- - ProcessedSignalChannelManager (float32 sample_rate, unsigned length, QObject* parent); + ProcessedSignalChannelManager (float64 sample_rate, unsigned length, QObject* parent); //------------------------------------------------------------------------- void addChannel (ChannelID id, QSharedPointer data_block, @@ -44,13 +44,13 @@ unsigned length) const; //------------------------------------------------------------------------- - virtual float32 getDurationInSec () const; + virtual float64 getDurationInSec () const; //------------------------------------------------------------------------- - virtual uint32 getNumberSamples () const; + virtual size_t getNumberSamples () const; //------------------------------------------------------------------------- - virtual float32 getSampleRate () const; + virtual float64 getSampleRate () const; private: float32 sample_rate_; Index: src/gui_impl/commands/adapt_event_view_gui_command.cpp =================================================================== --- src/gui_impl/commands/adapt_event_view_gui_command.cpp (revision 556) +++ src/gui_impl/commands/adapt_event_view_gui_command.cpp (working copy) @@ -128,8 +128,8 @@ QSharedPointer event = events.first(); - float32 width = currentVisModel()->view()->getViewportWidth(); - float32 desired_pixel_per_sample = width / event->getDuration (); + float64 width = currentVisModel()->view()->getViewportWidth(); + float64 desired_pixel_per_sample = width / event->getDuration (); currentSignalViewSettings()->setPixelsPerSample (desired_pixel_per_sample); currentVisModel()->goToSample (event->getPosition ()); Index: src/base/fixed_data_block.cpp =================================================================== --- src/base/fixed_data_block.cpp (revision 556) +++ src/base/fixed_data_block.cpp (working copy) @@ -10,7 +10,7 @@ //------------------------------------------------------------------------------------------------- FixedDataBlock::FixedDataBlock (QSharedPointer > data, - float32 sample_rate_per_unit) + float64 sample_rate_per_unit) : DataBlock (data->size(), sample_rate_per_unit), data_ (data), start_index_ (0) @@ -135,7 +135,7 @@ std::list >::const_iterator it = data_blocks.begin(); QSharedPointer > mean (new QVector); - float32 sample_rate = (*it)->getSampleRatePerUnit (); + float64 sample_rate = (*it)->getSampleRatePerUnit (); float32 tmp_mean = 0; for (unsigned index = 0; index < (*(data_blocks.begin()))->size(); index++) { @@ -174,7 +174,7 @@ return QSharedPointer(0); std::list >::const_iterator it = data_blocks.begin(); - float32 sample_rate = (*it)->getSampleRatePerUnit (); + float64 sample_rate = (*it)->getSampleRatePerUnit (); float32 tmp_stddev = 0; for (unsigned index = 0; index < (*(data_blocks.begin()))->size(); index++) { Index: src/base/signal_channel.cpp =================================================================== --- src/base/signal_channel.cpp (revision 556) +++ src/base/signal_channel.cpp (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2006,2007 Copyright (C) Christoph Eibel 2007,2008, Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -31,14 +31,60 @@ { //----------------------------------------------------------------------------- +SignalChannel::SignalChannel (unsigned ch, + const HDRTYPE* hdr) : + number_ (ch), + label_ (QString(hdr->CHANNEL[ch].Label).trimmed()), + physical_maximum_(hdr->CHANNEL[ch].PhysMax), + digital_maximum_(hdr->CHANNEL[ch].DigMax), + physical_minimum_(hdr->CHANNEL[ch].PhysMin), + digital_minimum_(hdr->CHANNEL[ch].DigMin), + data_type_(hdr->CHANNEL[ch].GDFTYP), + lowpass_(hdr->CHANNEL[ch].LowPass), + highpass_(hdr->CHANNEL[ch].HighPass), + notch_(hdr->CHANNEL[ch].Notch) + +{ +/* + scale_ = (C.PhysMax - C.PhysMin) / (C.DigMax - C.DigMin); + offset_ = C.PhysMin - C.DigMin * scale_; +*/ + char p[MAX_LENGTH_PHYSDIM+1]; + PhysDim(hdr->CHANNEL[ch].PhysDimCode,p); + phys_y_dimension_label_ = QString(p); + samplerate_ = hdr->SampleRate * hdr->CHANNEL[ch].SPR / hdr->SPR; +} + SignalChannel::SignalChannel (unsigned number, - QString const& label, - QString const& phys_y_dimension_label) : + CHANNEL_STRUCT C) : + + /* obsolete */ number_ (number), - label_ (label), - phys_y_dimension_label_ (phys_y_dimension_label) + label_ (QString(C.Label).trimmed()), + physical_maximum_(C.PhysMax), + digital_maximum_(C.DigMax), + physical_minimum_(C.PhysMin), + digital_minimum_(C.DigMin), + data_type_(C.GDFTYP), + lowpass_(C.LowPass), + highpass_(C.HighPass), + notch_(C.Notch) + { +/* + scale_ = (C.PhysMax - C.PhysMin) / (C.DigMax - C.DigMin); + offset_ = C.PhysMin - C.DigMin * scale_; +*/ + char p[MAX_LENGTH_PHYSDIM+1]; + PhysDim(C.PhysDimCode,p); + phys_y_dimension_label_ = QString(p); + samplerate_ = -1.0; +} +//----------------------------------------------------------------------------- +float64 SignalChannel::getSampleRate() const +{ + return samplerate_; } //----------------------------------------------------------------------------- Index: src/base/fixed_data_block.h =================================================================== --- src/base/fixed_data_block.h (revision 556) +++ src/base/fixed_data_block.h (working copy) @@ -22,7 +22,7 @@ /// @param sample_rate_per_unit as a data_block must not represent data which /// is associated to time, the sample_rate is given /// in "per unit" (e.g. "s" or "hz", etc.) - FixedDataBlock (QSharedPointer > data, float32 sample_rate_per_unit); + FixedDataBlock (QSharedPointer > data, float64 sample_rate_per_unit); //------------------------------------------------------------------------- virtual ~FixedDataBlock () {} Index: src/base/math_utils.cpp =================================================================== --- src/base/math_utils.cpp (revision 556) +++ src/base/math_utils.cpp (working copy) @@ -55,7 +55,7 @@ } //----------------------------------------------------------------------------- -int sampleRateToDecimalPrecision (float sample_rate) +int sampleRateToDecimalPrecision (float64 sample_rate) { int precision = 0; for (; sample_rate > 10; sample_rate /= 10) Index: src/base/signal_channel.h =================================================================== --- src/base/signal_channel.h (revision 556) +++ src/base/signal_channel.h (working copy) @@ -4,7 +4,7 @@ Copyright (C) Thomas Brunner 2006,2007 Copyright (C) Christoph Eibel 2007,2008, Copyright (C) Clemens Brunner 2006,2007,2008 - Copyright (C) Alois Schloegl 2008,2009 + Copyright (C) Alois Schloegl 2008,2009,2011 This file is part of the "SigViewer" repository at http://biosig.sf.net/ @@ -29,6 +29,7 @@ #define SIGNAL_CHANNEL_H #include "sigviewer_user_types.h" +#include "biosig.h" #include #include @@ -43,9 +44,8 @@ { public: //------------------------------------------------------------------------- - SignalChannel (unsigned number, - QString const& label, - QString const& phys_y_dimension_label = ""); +SignalChannel (unsigned ch, const HDRTYPE* hdr); +SignalChannel (unsigned number, CHANNEL_STRUCT C); /* obsolete, deprecated */ //------------------------------------------------------------------------- QString typeString() const; @@ -59,6 +59,7 @@ float64 getDigitalMaximum() const; float64 getPhysicalMinimum() const; float64 getDigitalMinimum() const; + float64 getSampleRate() const; private: // from GDF format @@ -95,6 +96,7 @@ uint16_t data_type_; float64 lowpass_; float64 highpass_; + float64 samplerate_; bool notch_; }; Index: src/base/math_utils.h =================================================================== --- src/base/math_utils.h (revision 556) +++ src/base/math_utils.h (working copy) @@ -42,7 +42,7 @@ //----------------------------------------------------------------------------- /// @return number of decimals needed to display time intervals correctly -int sampleRateToDecimalPrecision (float sample_rate); +int sampleRateToDecimalPrecision (float64 sample_rate); } Index: src/base/signal_event.cpp =================================================================== --- src/base/signal_event.cpp (revision 556) +++ src/base/signal_event.cpp (working copy) @@ -79,9 +79,9 @@ } //----------------------------------------------------------------------------- -float32 SignalEvent::getPositionInSec() const +float64 SignalEvent::getPositionInSec() const { - return static_cast(position_) / sample_rate_; + return static_cast(position_) / sample_rate_; } @@ -104,15 +104,15 @@ } //----------------------------------------------------------------------------- -float32 SignalEvent::getDurationInSec() const +float64 SignalEvent::getDurationInSec() const { - return static_cast(duration_) / sample_rate_; + return static_cast(duration_) / sample_rate_; } //----------------------------------------------------------------------------- -float32 SignalEvent::getEndInSec () const +float64 SignalEvent::getEndInSec () const { - return (static_cast(duration_ + position_)) / sample_rate_; + return (static_cast(duration_ + position_)) / sample_rate_; } //----------------------------------------------------------------------------- Index: src/base/data_block.cpp =================================================================== --- src/base/data_block.cpp (revision 556) +++ src/base/data_block.cpp (working copy) @@ -12,7 +12,7 @@ unsigned DataBlock::instance_count_ = 0; //----------------------------------------------------------------------------- -DataBlock::DataBlock (unsigned length, float32 sample_rate_per_unit) +DataBlock::DataBlock (unsigned length, float64 sample_rate_per_unit) : length_ (length), sample_rate_per_unit_ (sample_rate_per_unit) { @@ -79,7 +79,7 @@ } //------------------------------------------------------------------------- -float32 DataBlock::getSampleRatePerUnit () const +float64 DataBlock::getSampleRatePerUnit () const { return sample_rate_per_unit_; } Index: src/base/signal_event.h =================================================================== --- src/base/signal_event.h (revision 556) +++ src/base/signal_event.h (working copy) @@ -24,12 +24,12 @@ int32 getId() const; uint32 getPosition() const; - float32 getPositionInSec() const; + float64 getPositionInSec() const; uint16 getType() const; ChannelID getChannel() const; uint32 getDuration() const; - float32 getDurationInSec() const; - float32 getEndInSec () const; + float64 getDurationInSec() const; + float64 getEndInSec () const; float64 getSampleRate () const; void setId (EventID id); Index: src/base/data_block.h =================================================================== --- src/base/data_block.h (revision 556) +++ src/base/data_block.h (working copy) @@ -59,16 +59,16 @@ std::string getYUnitLabel () const; //------------------------------------------------------------------------- - float32 getSampleRatePerUnit () const; + float64 getSampleRatePerUnit () const; protected: // protected constructors here: - DataBlock (unsigned length, float32 sample_rate_per_unit); + DataBlock (unsigned length, float64 sample_rate_per_unit); DataBlock (DataBlock const& src, unsigned new_length); private: uint32 length_; - float32 sample_rate_per_unit_; + float64 sample_rate_per_unit_; std::string label_; std::string x_unit_label_; Index: src/src.qrc =================================================================== --- src/src.qrc (revision 556) +++ src/src.qrc (working copy) @@ -27,7 +27,6 @@ images/file_16x16.png images/info_16x16.png images/patient_16x16.png - eventcodes.txt images/zoom_in_vertical_22x22.png images/icons/fileclose.png images/icons/fileopen.png Index: deb_building_stuff/deb_control_template =================================================================== --- deb_building_stuff/deb_control_template (revision 556) +++ deb_building_stuff/deb_control_template (working copy) @@ -7,5 +7,5 @@ Replaces: sigviewer (<< ) Installed-Size: Maintainer: Christoph Eibel -Homepage: http://sigviewer.sourceforge.net +Homepage: http://biosig.sourceforge.net Description: SigViewer is a powerful viewing application for biosignals, originally designed to display electroencephalographic (EEG) data. biosig4c++-1.3.0/patches/tinyxml.diff000066400000000000000000000315431175724200100173360ustar00rootroot00000000000000Only in ../tinyxml: changes.txt Only in ../tinyxml: demotest.xml Only in ../tinyxml: dox Only in ../tinyxml: dream.xml Only in ../tinyxml: echo.cpp Only in ../tinyxml: .git Only in ../tinyxml: hamlet.xml Only in ../tinyxml: makedistlinux Only in ../tinyxml: makedistwin.bat Only in ../tinyxml: Makefile Only in ../tinyxml: midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml Only in ../tinyxml: readme.txt Only in ../tinyxml: SConstruct Only in ../tinyxml: setversion.py Only in XMLParser: .svn Only in ../tinyxml: test0.xml Only in ../tinyxml: test1.xml Only in ../tinyxml: test2.xml Only in ../tinyxml: test5.xml Only in ../tinyxml: test6.xml Only in ../tinyxml: test7.xml Only in ../tinyxml: testout.xml Only in ../tinyxml: textfile.txt diff -r ../tinyxml/tinyxml.cpp XMLParser/tinyxml.cpp 22a23,37 > > > 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. > 25a41 > #include 851a868,922 > #ifdef ZLIB_H > void TiXmlElement::gzPrint( gzFile cfile, int depth ) const > { > assert( cfile ); > int i; > assert( cfile ); > for ( i=0; i gzprintf( cfile, " " ); > } > > gzprintf( cfile, "<%s", value.c_str() ); > > const TiXmlAttribute* attrib; > for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) > { > 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 gzprintf( cfile, " " ); > } > gzprintf( cfile, "", value.c_str() ); > } > } > #endif > 970a1042,1051 > #ifdef ZLIB_H > gzFile file; > file = gzopen( value.c_str(), "rb" ); > if ( file ) > { > bool result = LoadFile( file, encoding ); > gzclose( file ); > return result; > } > #else 978a1060 > #endif 999c1081 < long length = 0; --- > size_t length = 0; 1040a1123,1151 > > #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 > > 1083a1195,1310 > #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; > } > > 1113a1341,1361 > #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 > > 1155a1404,1416 > #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 > > 1234a1496,1522 > #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 > 1306a1595,1605 > #ifdef ZLIB_H > void TiXmlComment::gzPrint( gzFile cfile, int depth ) const > { > assert( cfile ); > for ( int i=0; i { > gzprintf( cfile, " " ); > } > gzprintf( cfile, "", value.c_str() ); > } > #endif 1351a1651,1672 > #ifdef ZLIB_H > void TiXmlText::gzPrint( gzFile cfile, int depth ) const > { > assert( cfile ); > if ( cdata ) > { > int i; > gzprintf( cfile, "\n" ); > for ( i=0; i gzprintf( cfile, " " ); > } > gzprintf( cfile, "\n", value.c_str() ); // unformatted output > } > else > { > TIXML_STRING buffer; > EncodeString( value, &buffer ); > gzprintf( cfile, "%s", buffer.c_str() ); > } > } > #endif > 1438a1760,1782 > #ifdef ZLIB_H > void TiXmlDeclaration::gzPrint( gzFile cfile, int /*depth*/, TIXML_STRING* str ) const > { > if ( cfile ) gzprintf( cfile, " if ( str ) (*str) += " > if ( !version.empty() ) { > if ( cfile ) gzprintf (cfile, "version=\"%s\" ", version.c_str ()); > if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; } > } > if ( !encoding.empty() ) { > if ( cfile ) gzprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); > if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; } > } > if ( !standalone.empty() ) { > if ( cfile ) gzprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); > if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; } > } > if ( cfile ) gzprintf( cfile, "?>" ); > if ( str ) (*str) += "?>"; > } > #endif > 1474a1819,1826 > #ifdef ZLIB_H > void TiXmlUnknown::gzPrint( gzFile cfile, int depth ) const > { > for ( int i=0; i gzprintf( cfile, " " ); > gzprintf( cfile, "<%s>", value.c_str() ); > } > #endif Only in ../tinyxml: tinyxml.cpp.orig Only in ../tinyxml: tinyxml.cpp.rej Only in ../tinyxml: tinyxml.dsw diff -r ../tinyxml/tinyxml.h XMLParser/tinyxml.h 22a23,37 > > Modified by Alois Schlögl > Apr 6, 2009: add support for zlib-compressed (gzipped) XML data > Jan 2011: update to latest TinyXML > > $Id: tinyxml.h,v 1.6 2009/04/15 20:31:54 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. > 40a56,66 > #ifdef WITH_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 > 213a240,242 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth ) const = 0; > #endif 874a904,911 > #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 > 1126a1164,1166 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth ) const; > #endif 1179a1220,1222 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth ) const; > #endif 1240a1284,1286 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth ) const; > #endif 1321a1368,1373 > #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 1366a1419,1421 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth ) const; > #endif 1421a1477 > bool SaveFile( const char * filename, char compression ) const; 1429a1486,1489 > #ifdef ZLIB_H > bool LoadFile( gzFile, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); > bool SaveFile( gzFile ) const; > #endif 1528a1589,1592 > #ifdef ZLIB_H > virtual void gzPrint( gzFile cfile, int depth = 0 ) const; > #endif > Only in ../tinyxml: tinyxml.h.orig Only in ../tinyxml: tinyxml_lib.vcxproj Only in ../tinyxml: tinyxml.sln Only in ../tinyxml: tinyxmlSTL.vcxproj Only in ../tinyxml: tinyXmlTestSTL.vcxproj Only in ../tinyxml: tinyXmlTest.vcxproj Only in ../tinyxml: tutorial_gettingStarted.txt Only in ../tinyxml: utf8test.gif Only in ../tinyxml: utf8testout.xml Only in ../tinyxml: utf8testverify.xml Only in ../tinyxml: utf8test.xml Only in ../tinyxml: xmltest.cpp biosig4c++-1.3.0/pdp2gdf.c000066400000000000000000000122741175724200100150430ustar00rootroot00000000000000/* $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); } biosig4c++-1.3.0/perl/000077500000000000000000000000001175724200100143055ustar00rootroot00000000000000biosig4c++-1.3.0/perl/Makefile000066400000000000000000000012351175724200100157460ustar00rootroot00000000000000####### 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 biosig4c++-1.3.0/perl/biosig.i000066400000000000000000000237411175724200100157420ustar00rootroot00000000000000/* % % $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, 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 PhysDim(PhysDimCode,PhysDimText) 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 { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 { // 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 */ 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; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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 hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/php/000077500000000000000000000000001175724200100141325ustar00rootroot00000000000000biosig4c++-1.3.0/php/Makefile000066400000000000000000000012061175724200100155710ustar00rootroot00000000000000####### 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 *.php -rm *.so biosig4c++-1.3.0/php/biosig.i000066400000000000000000000243111175724200100155610ustar00rootroot00000000000000/* % % $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, 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 PhysDim(PhysDimCode,PhysDimText) 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 { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 { // 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; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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 hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/physicalunits.c000066400000000000000000000055611175724200100164150ustar00rootroot00000000000000/* $Id: physicalunits.c,v 1.1 2008-06-18 19:33:04 schloegl Exp $ Copyright (C) 2008 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 #include "biosig.h" #ifndef INF #define INF (1.0/0.0) #endif int main(int argc, char **argv){ if (argc<1) return(0); int k=1; if (!strcmp(argv[k],"-v") || !strcmp(argv[k],"--version") ) { fprintf(stdout,"physicalunits (BioSig4C++) v0.64\n"); fprintf(stdout,"Written by Alois Schloegl\n\n"); fprintf(stdout,"This program is free software; you can redistribute it and/or modify\n"); fprintf(stdout,"it under the terms of the GNU General Public License as published by\n"); fprintf(stdout,"the Free Software Foundation; either version 3 of the License, or\n"); fprintf(stdout,"(at your option) any later version.\n"); } else if (!strcmp(argv[k],"-h") || !strcmp(argv[k],"--help") ) { fprintf(stdout,"PHYSICALUNITS encodes and decodes physical dimensions \n"); fprintf(stdout,"according to ISO/DIS 11073-10101:2003. "); fprintf(stdout,"The lower 5 bits \nencode the prefix, the upper 11 bits are used to encode the base unit.\n"); fprintf(stdout,"\nusage: physicalunits p.u. \n"); fprintf(stdout," returns the code for physical unit p.u."); fprintf(stdout,"\nusage: physicalunits NNN \n"); fprintf(stdout," returns the physical unit encoded by NNN.\n"); fprintf(stdout,"\nExample(s):"); fprintf(stdout,"\n physicalunits \"mA m-1\" returns\n"); fprintf(stdout,"\tPhysDimCode(mA m-1) => 4242 (0x1092)"); fprintf(stdout,"\n physicalunits 4242 returns\n"); fprintf(stdout,"\tPhysDim(4242) = \"mA m-1\"\n\n"); return(0); } else if (!strncmp(argv[k],"-",1)) { fprintf(stderr,"error: unknown option %s .\n",argv[k]); return(0); } else { int c,q; q=sscanf(argv[k],"%i ",&c); char s[MAX_LENGTH_PHYSDIM+1]; if (q>0) { fprintf(stdout,"PhysDim(%i) = \"%s\"\n",c,PhysDim(c,s)); } else { c = PhysDimCode(argv[k]); fprintf(stdout,"PhysDimCode(%s) => %i (0x%04x)\n",argv[k],c,c); } } } biosig4c++-1.3.0/python/000077500000000000000000000000001175724200100146645ustar00rootroot00000000000000biosig4c++-1.3.0/python/Makefile000066400000000000000000000006551175724200100163320ustar00rootroot00000000000000####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile,v 1.72 2009/03/03 11:46:57 schloegl Exp $ ### Copyright (C) 2006,2007,2008,2009,2012 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## all, biosig4python: make -C .. biosig4python biosig4c++-1.3.0/python/Makefile.win32000066400000000000000000000030641175724200100172700ustar00rootroot00000000000000####### Makefile for "BioSig for C/C++" ##################### ### ### $Id: Makefile,v 1.72 2009/03/03 11:46:57 schloegl Exp $ ### Copyright (C) 2006,2007,2008,2009 Alois Schloegl ### Copyright (C) 2010 Brice Rebsamen ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) at http://biosig.sf.net/ ### ############################################################## CXX = g++ DEFINES = -D=_NO_OLDNAMES #-D=WITH_ZLIB #-D=WITH_CHOLMOD -D=__4HAERTEL__ -D=WITH_FAMOS #-D=WITH_FEF -D=WITH_DICOM #-D=WITH_GDCM #-D=WITH_GSL #-D=WITH_EEPROBE #-D=SOFTCODED_PHYSDIMTABLE # if you have zlib CXXFLAGS = -pipe -fPIC -Wall -O2 -Wextra $(DEFINES) # -I cntopenlib/include/ LIBS = ../libbiosig.a -lws2_32 #-lz #-lcholmod # t240/libfef.a #-lgdcmDSED -lgsl -lgslcblas -lm # static SWIG = swig DELETE = del COPY = copy MAKE = mingw32-make PYTHONDIR = C:\Python25 INC = -I$(PYTHONDIR)\include -I$(PYTHONDIR)\Lib\site-packages\numpy\core\include\numpy TARGET = biosig4python first: $(TARGET) ../libbiosig.a: $(MAKE) -C .. -f Makefile.win32 libbiosig.a biosig4python : _biosig.pyd biosig.py biosig.py swig_wrap.cxx : $(SOURCES) ../libbiosig.a swig.i $(SWIG) -c++ -python $(INC) -o swig_wrap.cxx swig.i _biosig.pyd : swig_wrap.o $(CXX) -shared swig_wrap.o $(LIBS) -L$(PYTHONDIR)/libs -lpython25 -o _biosig.pyd swig_wrap.o : swig_wrap.cxx $(CXX) -c $(CXXFLAGS) swig_wrap.cxx -o swig_wrap.o $(INC) clean: -$(DELETE) biosig.py* _biosig.pyd -$(DELETE) swig_wrap.*biosig4c++-1.3.0/python/demo.py000066400000000000000000000033531175724200100161660ustar00rootroot00000000000000####### Demo for Python interface to BioSig" ##################### ### ### $Id$ ### Copyright (C) 2009 Alois Schloegl ### This file is part of the "BioSig for C/C++" repository ### (biosig4c++) 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 biosig import numpy as S filename = '/scratch/schloegl/R/data/test/CFS/example_6channels.dat' #filename = '/home/as/data/test/CFS/example_6channels.dat' print 'open file ',filename HDR = biosig.constructHDR(0, 0) HDR = biosig.sopen(filename , 'r', HDR) status = biosig.serror() # save and reset error status if status: print 'Can not open file ',filename else: # show header information biosig.hdr2ascii(HDR,3) for k in range(HDR.NS): # convert C to Python string: get rid of everything after \x00, then remove leading and trailing whitespace str = HDR.CHANNEL[k].Label HDR.CHANNEL[k].Label = str[0:str.find(chr(0))].strip() str = HDR.CHANNEL[k].Transducer HDR.CHANNEL[k].Transducer = str[0:str.find(chr(0))].strip() print k,'<',HDR.CHANNEL[k].Label,'>,<',HDR.CHANNEL[k].Transducer,'>' # turn off all channels # for i in range(HDR.NS): # HDR.CHANNEL[i].OnOff = 0 # # turn on specific channels # HDR.CHANNEL[0].OnOff = 1 # HDR.CHANNEL[1].OnOff = 1 # HDR.CHANNEL[HDR.NS-1].OnOff = 1 # # read data data = biosig.sread(0, HDR.NRec, HDR) # # close file biosig.sclose(HDR) # # release allocated memory biosig.destructHDR(HDR) # #return data biosig4c++-1.3.0/python/example.py000066400000000000000000000026651175724200100167020ustar00rootroot00000000000000import biosig import numpy as S def load(fname): HDR = biosig.constructHDR(0, 0) HDR = biosig.sopen(fname, "r", HDR); # turn off all channels # for i in range(HDR.NS): # HDR.CHANNEL[i].OnOff = 0 # turn on specific channels # HDR.CHANNEL[0].OnOff = 1 # HDR.CHANNEL[1].OnOff = 1 # HDR.CHANNEL[HDR.NS-1].OnOff = 1 data = biosig.sread(0, HDR.NRec, HDR) biosig.sclose(HDR) biosig.destructHDR(HDR) return data 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 = load(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) biosig4c++-1.3.0/python/swig.i000066400000000000000000000260511175724200100160130ustar00rootroot00000000000000/* % % $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 %{ #define SWIG_FILE_WITH_INIT #include "../biosig.h" #include %} %include // import_array() call initialises Numpy %init %{ import_array(); %} 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 PhysDim(PhysDimCode,PhysDimText) 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; %extend CHANNEL_TYPE { CHANNEL_TYPE *__getitem__(int index) { return self+index; } }; /* This structure defines the general (fixed) header */ typedef struct { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 { // 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; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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; } %} */ PyObject* sread(size_t start, size_t length, HDRTYPE* hdr); %{ PyObject* sread(size_t start, size_t length, HDRTYPE* hdr) { int i, dims[2]; PyArrayObject *_array; size_t count; dims[0] = 0; dims[1] = length * hdr->SPR; for(i = 0; i < hdr->NS; ++i) if(hdr->CHANNEL[i].OnOff) ++dims[0]; hdr->FLAG.ROW_BASED_CHANNELS = 0; if(sizeof(biosig_data_type) != sizeof(double)) return NULL; /* create the NumPy array and copy the data into it */ _array = (PyArrayObject *)PyArray_FromDims(2, dims, PyArray_DOUBLE); count = sread((double*)(_array->data), start, length, hdr); /* the block of data is now owned by _array, destructHDR should not destroy it */ hdr->data.block = NULL; /* if(count != length) {} */ return PyArray_Return(_array); } %} void hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/rec2bin000077500000000000000000000004451175724200100146200ustar00rootroot00000000000000# Converts data into ascii-Header and each channel into a separate binary data file # # Copyright (C) 2008 Alois Schloegl # This file is part of the "BioSig for C/C++" repository # (biosig4c++) at http://biosig.sf.net/ ./save2gdf -f=BIN $1 $2 $3 $4 $5 $6 $7 biosig4c++-1.3.0/ruby/000077500000000000000000000000001175724200100143245ustar00rootroot00000000000000biosig4c++-1.3.0/ruby/Makefile000066400000000000000000000013221175724200100157620ustar00rootroot00000000000000####### 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-Ruby interface is available here # http://www.swig.org/Doc1.3/Ruby.html#Ruby ### INC must be the directory containing ruby.h INC = /usr/lib/ruby/1.8/x86_64-linux/ all: swig -c++ -ruby biosig.i g++ -fPIC -c biosig_wrap.cxx -I$(INC) g++ -fPIC -shared biosig_wrap.o ../libbiosig.so -o biosig.so clean: -rm *.o -rm *.so -rm *.c* biosig4c++-1.3.0/ruby/biosig.i000066400000000000000000000237411175724200100157610ustar00rootroot00000000000000/* % % $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, 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 PhysDim(PhysDimCode,PhysDimText) 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 { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 { // 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 */ 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; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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 hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/ruby/extconf.rb000066400000000000000000000000521175724200100163140ustar00rootroot00000000000000require 'mkmf' create_makefile('biosig') biosig4c++-1.3.0/save2aecg000077500000000000000000000001251175724200100151270ustar00rootroot00000000000000#!/bin/sh #conversion into HL7aECG data format save2gdf -f=HL7 $1 $2 $3 $4 $5 $6 $7 biosig4c++-1.3.0/save2gdf.c000066400000000000000000000465441175724200100152250ustar00rootroot00000000000000/* $Id$ Copyright (C) 2000,2005,2007-2012 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 "biosig-dev.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){ HDRTYPE *hdr; size_t count, k1, ne=0; uint16_t numopt = 0; char *source, *dest, *tmpstr; enum FileFormat SOURCE_TYPE, TARGET_TYPE=GDF; // type of file format int COMPRESSION_LEVEL=0; int status; uint16_t k; int TARGETSEGMENT=1; // select segment in multi-segment file format EEG1100 (Nihon Kohden) int VERBOSE = 1; char FLAG_CNT32 = 0; // assume CNT format is 16bit char FLAG_JSON = 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 duriation 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," -cnt32\n\tmust be set for reading 32 bit CNT files\n"); fprintf(stdout," -f=FMT \n\tconverts data into format FMT\n"); fprintf(stdout," -JSON \n\tshows header, and events in JSON format\n"); fprintf(stdout,"\tFMT must represent a valid target file format\n"); fprintf(stdout,"\tCurrently are supported: HL7aECG, SCP_ECG (EN1064), GDF, EDF, BDF, CFWB, BIN, ASCII, BVA (BrainVision)\n\tas well as HEKA v2 -> ITX\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,"\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 VERBOSE_LEVEL // then VERBOSE_LEVEL is not a constant but a variable VERBOSE_LEVEL = VERBOSE; #endif } else if (!strncmpi(argv[k],"-SWEEP=",7)) { argsweep = argv[k]+6; } else if (!strcmpi(argv[k],"-JSON")) FLAG_JSON = 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=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=GDF1; else if (!strncmp(argv[k],"-f=HL7",6)) TARGET_TYPE=HL7aECG; else if (!strncmp(argv[k],"-f=MFER",7)) TARGET_TYPE=MFER; else if (!strncmp(argv[k],"-f=SCP",6)) TARGET_TYPE=SCP_ECG; // 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 (!strncmp(argv[k],"-cnt32",3)) { FLAG_CNT32 = 1; } 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 { numopt = k-1; break; } if (VERBOSE_LEVEL>7) fprintf(stdout,"[103] save2gdf: arg%i = <%s>\n", k, argv[k]); } source = NULL; dest = NULL; switch (argc - numopt) { case 1: 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 3: dest = argv[numopt+2]; case 2: source = argv[numopt+1]; } if (VERBOSE_LEVEL<0) VERBOSE=1; // default if (VERBOSE_LEVEL>7) fprintf(stdout,"[108] SAVE2GDF %s %s started \n", source, dest ); tzset(); hdr = constructHDR(0,0); // hdr->FLAG.OVERFLOWDETECTION = FlagOverflowDetection; hdr->FLAG.UCAL = ((TARGET_TYPE==BIN) || (TARGET_TYPE==ASCII)); hdr->FLAG.TARGETSEGMENT = TARGETSEGMENT; hdr->FLAG.CNT32 = FLAG_CNT32; // hdr->FLAG.ANONYMOUS = 0; // personal names are processed 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(source, "r", hdr); #ifdef WITH_PDP if (B4C_ERRNUM) { B4C_ERRNUM = 0; 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"); B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; } } #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,"[112] SOPEN-R finished\n"); if ((status=serror())) { 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); B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "blocks must not be split"; } if ((status=serror())) { destructHDR(hdr); exit(status); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[113] SOPEN-R finished\n"); hdr2ascii(hdr,stdout, FLAG_JSON ? -1 : VERBOSE); // all channels are converted - channel selection currently not supported for (k=0; kNS; k++) { if (!hdr->CHANNEL[k].OnOff && 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 && (TARGET_TYPE==SCP_ECG); hdr->FLAG.ROW_BASED_CHANNELS = flagREREF; #ifdef CHOLMOD_H if (VERBOSE_LEVEL>7) fprintf(stdout,"[121] %p %p Flag.ReRef=%i\n",hdr->Calib, hdr->rerefCHANNEL,flagREREF); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"\n[123] SREAD [%f,%f].\n",t1,t2); if (t2+t1 > hdr->NRec) t2 = hdr->NRec - t1; if (dest != NULL) 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,"[125] UCAL=%i %e %e %e \n",hdr->FLAG.UCAL,data[100],data[110],data[500+hdr->SPR]); if ((status=serror())) { destructHDR(hdr); exit(status); }; if (VERBOSE_LEVEL>7) fprintf(stdout,"\n[129] SREAD on %s successful [%i,%i].\n",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[130] File %s =%i/%i\n",hdr->FileName,hdr->FILE.OPEN,hdr->FILE.Des); if (dest==NULL) { 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,"[131] going for SCLOSE\n"); sclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[137] SCLOSE(HDR) finished\n"); destructHDR(hdr); exit(serror()); } if (hdr->FILE.OPEN) { sclose(hdr); free(hdr->AS.Header); hdr->AS.Header = NULL; if (VERBOSE_LEVEL>7) fprintf(stdout,"[138] file closed\n"); } if (VERBOSE_LEVEL>7 ) fprintf(stdout,"\n[139] File %s closed sd=%i/%i\n",hdr->FileName,hdr->FILE.OPEN,hdr->FILE.Des); SOURCE_TYPE = hdr->TYPE; hdr->TYPE = TARGET_TYPE; if ((hdr->TYPE==GDF) && (hdr->VERSION<2)) hdr->VERSION = 2.0; 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,"[199] %p %p\n",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,"[204] #%i\n",k); 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) { if (PhysMaxValue0 < val) PhysMaxValue0 = val; if (PhysMinValue0 > val) PhysMinValue0 = val; 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; if (PhysMaxValue0 < MaxValueF) PhysMaxValue0 = MaxValueF; MinValueF = MinValue * hdr->CHANNEL[k].Cal + hdr->CHANNEL[k].Off; if (PhysMinValue0 > MinValue) PhysMinValue0 = MinValueF; MaxValueD = MaxValue; MinValueD = MinValue; } 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; } else if ((SOURCE_TYPE==GDF) && (TARGET_TYPE==GDF)) ; else if (SOURCE_TYPE==HEKA) ; 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 ((hdr->CHANNEL[k].GDFTYP<10 ) && (TARGET_TYPE==GDF || TARGET_TYPE==CFWB)) { /* heuristic to determine optimal data type */ if ((MaxValue <= 127) && (MinValue >= -128)) hdr->CHANNEL[k].GDFTYP = 1; else if ((MaxValue <= 255.0) && (MinValue >= 0.0)) hdr->CHANNEL[k].GDFTYP = 2; else if ((MaxValue <= ldexp(1.0,15)-1.0) && (MinValue >= ldexp(-1.0,15))) hdr->CHANNEL[k].GDFTYP = 3; else if ((MaxValue <= ldexp(1.0,16)-1.0) && (MinValue >= 0.0)) hdr->CHANNEL[k].GDFTYP = 4; else if ((MaxValue <= ldexp(1.0,31)-1.0) && (MinValue >= ldexp(-1.0,31))) hdr->CHANNEL[k].GDFTYP = 5; else if ((MaxValue <= ldexp(1.0,32)-1.0) && (MinValue >= 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,"[205] UCAL=%i\n", hdr->FLAG.UCAL); /* 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,"[211] z=%i sd=%i\n",hdr->FILE.COMPRESSION,hdr->FILE.Des); hdr->FLAG.ANONYMOUS = 1; // no personal names are processed hdr = sopen(tmp, "wb", hdr); free(tmp); if ((status=serror())) { destructHDR(hdr); exit(status); } #ifndef WITHOUT_NETWORK if (hdr->FILE.Des>0) savelink(source); #endif if (VERBOSE_LEVEL>7) fprintf(stdout,"\n[221] File %s opened. %i %i %i Des=%i\n",hdr->FileName,hdr->AS.bpb,hdr->NS,(int)(hdr->NRec),hdr->FILE.Des); swrite(data, hdr->NRec, hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[231] SWRITE finishes\n"); if ((status=serror())) { destructHDR(hdr); exit(status); } if (VERBOSE_LEVEL>7) fprintf(stdout,"[236] SCLOSE finished\n"); sclose(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"[241] SCLOSE finished\n"); destructHDR(hdr); exit(serror()); } biosig4c++-1.3.0/save2scp000077500000000000000000000001371175724200100150200ustar00rootroot00000000000000#!/bin/sh ### conversion into SCP-ECG (EN1064) standard save2gdf -f=SCP $1 $2 $3 $4 $5 $6 $7 biosig4c++-1.3.0/src/000077500000000000000000000000001175724200100141325ustar00rootroot00000000000000biosig4c++-1.3.0/src/flowmon.c000066400000000000000000000376751175724200100160010ustar00rootroot00000000000000/* # 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-dev.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 (serror()) { fprintf(stderr,"%s (%i)\n",B4C_ERRMSG,B4C_ERRNUM); return(-1); } 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, "w", hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 120 %p\n", hdr); if (serror()) { fprintf(stderr,"%s (%i)\n",B4C_ERRMSG,B4C_ERRNUM); return(-1); } 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; } biosig4c++-1.3.0/src/ttl2trig.c000066400000000000000000000273231175724200100160600ustar00rootroot00000000000000/* $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 "../biosig.h" extern int VERBOSE_LEVEL; #else int VERBOSE_LEVEL=3; #endif #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[]) { /********************************************* 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_LEVEL = atoi(argv[k]+2); } 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_LEVEL>6) fprintf(stdout,"pcm_name:\t%s \n", pcm_name); if (VERBOSE_LEVEL>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_LEVEL>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 = outFile; sopen(outFile, "w", hdr); if (VERBOSE_LEVEL>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 } biosig4c++-1.3.0/t210/000077500000000000000000000000001175724200100140315ustar00rootroot00000000000000biosig4c++-1.3.0/t210/LICENSE000066400000000000000000000431311175724200100150400ustar00rootroot00000000000000 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. biosig4c++-1.3.0/t210/codes.h000066400000000000000000000336371175724200100153130ustar00rootroot00000000000000/* --------------------------------------------------------------------------- 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[]={-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__*/ biosig4c++-1.3.0/t210/scp-decode.cpp000066400000000000000000003056141175724200100165540ustar00rootroot00000000000000/* $Id: scp-decode.cpp,v 1.24 2008-07-12 20:46:58 schloegl Exp $ Copyright (C) 2011 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; //______________________________________________________________________________ // 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 U_int_L _COUNT_BYTE=1UL; // counter of bytes read static U_int_L _DIM_FILE; // file length in byte static const U_int_S _NUM_SECTION=12U; // sections over 11 are not considered //______________________________________________________________________________ // section 2 U_int_S Input_Bit(U_int_S*,U_int_M&,U_int_M,U_int_S&,bool&); int_M Input_Bits(U_int_S*,U_int_M&,U_int_M,U_int_S&,U_int_S,bool&); void decompress(TREE_NODE*,int_M*,U_int_S&,U_int_M&,int_L*,U_int_M,U_int_M&,table_H*,U_int_M*,U_int_M&); void Tree_Destroy(TREE_NODE*); TREE_NODE *Tree_Create(TREE_NODE*,U_int_M,table_H*,U_int_M); void Huffman(int_L*,U_int_M*,U_int_S*,U_int_M&,U_int_M,table_H*,U_int_M*); void InitHuffman(table_H*); //inizialize default Huffman table //______________________________________________________________________________ // sections 3, 4, 5 and 6 template void Differences(int_L*,t1,U_int_S); void Multiply(int_L*,U_int_L,U_int_M); void Interpolate(int_L*,int_L*,f_lead,lead*,f_Res,Protected_Area*,U_int_L); void ExecFilter(int_L*,int_L*,U_int_L&,U_int_M); void DoFilter(int_L*,int_L*,f_Res,f_lead,lead*,Protected_Area*,Subtraction_Zone*); void DoAdd(int_L*,int_L*,f_Res,int_L*,f_BdR0,Subtraction_Zone*,f_lead,lead*); void Opt_Filter(int_L*, int_L*, f_Res, f_lead, lead*, Protected_Area*); //______________________________________________________________________________ // INTERNAL FUNCTIONS char* ReadString(char*,U_int_M); //read a string char *FindString(char*,U_int_M); // calculate the length of a string and write it down int_M Look(alfabetic*,U_int_M,U_int_M,U_int_M); //look at a number in alfabetic and give the position of the array //______________________________________________________________________________ template void ReadByte(t1&); //read a byte from stream void Skip(U_int_M); //skip some bytes //______________________________________________________________________________ U_int_M ReadCRC(); //read first 6 bytes of the file bool Check_CRC(U_int_M,U_int_L,U_int_L); // CRC check //______________________________________________________________________________ U_int_L ID_section(U_int_L, int_S &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&,U_int_M&); void section_1_11(demographic&); void section_1_12(demographic&); void section_1_13(clinic&,U_int_M&); 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&,U_int_M&); void section_1_31(device&); void section_1_32(clinic&,U_int_M&, int_S version); void section_1_33(device&); void section_1_34(device&); void section_1_35(clinic&,U_int_M&); 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&, int_S version); //read section 7 void section_8(pointer_section,DATA_INFO&); //read section 8 void section_10(pointer_section,DATA_RECORD&, int_S 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&, int_S version); //read section 3 void section_4(pointer_section,DATA_DECODE&, int_S 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 U_int_S *num, dim=sizeof(t1); U_int_S mask=0xFF; if(dim!=0 && (num=(U_int_S*)mymalloc(dim))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } ifread(num,dim,1,in); // *num = *(U_int_S*)(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) { U_int_M CRC; U_int_L 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, U_int_M 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 { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } _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 int_M Look(alfabetic *code_, U_int_M a, U_int_M b, U_int_M key_) // look num in code_.number and give the element position { U_int_M 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, */ U_int_S 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 U_int_M ReadCRC() // read the CRC of the entire file or of a section and convert it to decimal. { U_int_M dim; ReadByte(dim); return dim; }//end ReadCRC bool Check_CRC(U_int_M CRC, U_int_L pos, U_int_L 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. */ { U_int_L i; U_int_S A, B; U_int_S 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 U_int_L ID_section(U_int_L pos, int_S &version) //read section Header { U_int_L dim; U_int_M 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 { U_int_S 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 { U_int_L pos, dim, ini; U_int_M ind; U_int_S i; int_S 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 { U_int_S tag; U_int_L num=info_sections.length+_COUNT_BYTE; U_int_M dim=0U; int_S 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 { U_int_M 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 { U_int_M 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 { U_int_M dim; ReadByte(dim); ana.ID=ReadString(ana.ID,dim); }//end section_1_2 void section_1_3(demographic &ana) // section 1 tag 3 { U_int_M 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 { U_int_M 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 { U_int_M dim; U_int_S m, g; U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M dim; ReadByte(dim); ReadByte(ana.race); if(ana.race>3) ana.race=0; }//end section_1_9 void section_1_10(clinic &cli, U_int_M &dim) // section 1 tag 10 { U_int_M val; U_int_S code_; char *temp_string=NULL, *pos_char; int_M 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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 { U_int_M 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 { U_int_M dim; ReadByte(dim); if(dim) ReadByte(ana.diastolic_pressure); else ana.diastolic_pressure=0; }//end section_1_12 void section_1_13(clinic &cli, U_int_M &dim) // section 1 tag 13 { U_int_M 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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 { U_int_M dim, dim_to_skip; U_int_S i, mask, code_; int_M 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 { U_int_M dim; U_int_S i, mask, code_; int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M 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 { U_int_M dim; ReadByte(dim); des.room=ReadString(des.room,dim); }//end section_1_23 void section_1_24(descriptive &des) // section 1 tag 24 { U_int_M dim; ReadByte(dim); ReadByte(des.stat_code); }//end section_1_24 void section_1_25(device &dev) // section 1 tag 25 { U_int_M dim; U_int_S m, g; U_int_M 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 { U_int_M dim; U_int_S 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 { U_int_M dim; ReadByte(dim); ReadByte(dev.baseline_filter); }//end section_1_27 void section_1_28(device &dev) // section 1 tag 28 { U_int_M dim; ReadByte(dim); ReadByte(dev.lowpass_filter); }//end section_1_28 void section_1_29(device &dev) // section 1 tag 29 { U_int_M dim; U_int_S 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 { U_int_M 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, U_int_M &dim) // section 1 tag 35 { U_int_M 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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 { U_int_M dim; ReadByte(dim); Skip(dim); }//end section_1_ void section_1_255() // section 1 tag 255 { U_int_M 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 { U_int_M nt, i, j, ns=0, pos, dim; //fpos_t filepos; long filepos; int_S 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=(U_int_M*)mymalloc(sizeof(U_int_M)*(nt+1)))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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) { fprintf(stderr,"Cannot read data!!!"); exit(2); } if(ns!=0 && (data.t_Huffman=(table_H*)mymalloc(sizeof(table_H)*ns))==NULL) //array of 5 columns and ns rows { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } 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,int_S version) { U_int_M i; int_S 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) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } for(i=0;i2) data.flag_BdR0.encoding=0; Skip(1); if(data.flag_lead.number!=0 && (data.length_BdR0=(U_int_M*)mymalloc(sizeof(U_int_M)*data.flag_lead.number))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim=0; for(i=0;i>=1; dim*=sizeof(int_L); if(dim!=0 && (data.Median=(int_L*)mymalloc(dim))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim/=sizeof(int_L); 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) { U_int_M i; U_int_L t, dim; U_int_M value; int_S 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=(U_int_M*)mymalloc(sizeof(U_int_M)*data.flag_lead.number))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim=0; for(i=0;i>=1; dim*=sizeof(int_L); if(dim!=0 && (data.Residual=(int_L*)mymalloc(dim))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } dim/=sizeof(int_L); 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, int_S version) { U_int_M i, j, dim; U_int_S lung; //fpos_t filepos; long filepos; int_S version_loc; U_int_L 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=(U_int_S*)mymalloc(sizeof(U_int_S)*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) { U_int_S m, g, h, s, i; U_int_M a, dim; char *c; //fpos_t filepos; long filepos; int_S 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. */ { U_int_S m, g, h, s, i, j; U_int_M a, dim; char *temp_string=0, *punt, c; //fpos_t filepos; long filepos; int_S 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(int_L *dati, t1 flag, U_int_S num) { U_int_S i; U_int_M j; for(i=0;inext_0); Tree_Destroy(radix->next_1); free(radix); } return; } TREE_NODE *Tree_Create(TREE_NODE *tree, U_int_M n_of_struct, table_H *table, U_int_M pos) //build a tree { U_int_S i,j; U_int_L 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 U_int_S Input_Bit(U_int_S *raw, U_int_M &pos, U_int_M max, U_int_S &mask, bool &err) { U_int_S 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 int_M Input_Bits(U_int_S *raw, U_int_M &pos, U_int_M max, U_int_S &mask, U_int_S bit_count, bool &err) { U_int_M temp; int_M 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(int_L *out_data, U_int_M *length, U_int_S *in_data, U_int_M &n_samples, U_int_M n_lead, table_H *t_Huffman, U_int_M *flag_Huffman) { TREE_NODE *tree = NULL; U_int_M pos_in, pos_out, pos_tH; U_int_S 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 (int_L) ) //data.flag_Res.number_samples = samples of the decimated signal //dim_R_ = number of bytes of the reconstructed signal (4 bytes (int_L) ) //number_samples_ = samples of the reconstructed signal data.flag_Res.number_samples=number_samples_; //number of samples per lead number_samples_=dim_R/(sizeof(int_L)*data.flag_lead.number); dim_R=dim_R_; dim_R_=(dim_R/sizeof(int_L))*sizeof(dec_S)*2; //dim_R_ = number of bytes of decimated signal (4 bytes (int_L) ) //number_samples_ = samples of the decimated signal //dim_R = number of bytes of the reconstructed signal (4 bytes (int_L) ) //data.flag_Res.number_samples = samples of the reconstructed signal if(dim_R_!=0 && (dati_Res_=(int_L*)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=(int_L*)mymalloc(dim_R))==NULL) { fprintf(stderr,"Not enough memory"); // no, exit // exit(2); } */ unsigned dim_RR=dim_R/sizeof(int_L); // 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. */ { U_int_M a, b; //interpolation range float v; //interpolation value U_int_S j; //working variable U_int_M dim; //number of samples (to skip) into a protected zone U_int_M mINS, mCOPY; //number of samples to insert, copy int_M num; //number of samples to interpolate U_int_L pos_in, pos_out; U_int_M nz; //index of protected zones, i.e. index of QRS U_int_S 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(int_L *raw_in, int_L *raw_out, U_int_L &pos, U_int_M dim) //filter from pos for dim samples { int_L v; //value U_int_M 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(int_L *raw_out, int_L *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. { U_int_M a, b=0; //interval int_M num; U_int_L pos; U_int_M nz; U_int_S 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(int_L *raw_out, int_L *raw_R, f_Res flag_R, int_L *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 { U_int_M pos_B; U_int_L pos_R, pos_out; U_int_M ns, a , b, num; U_int_S 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(int_L *raw_out, int_L *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() { U_int_M a, b=0; //interval for filtering int_M num; U_int_L pos; U_int_M nz; U_int_S ne; //lead index pos=0; for(ne=0;ne0) { raw_out[pos]=raw_in[pos]; pos++; } } }//for nz } // for ne }//end Opt_Filter biosig4c++-1.3.0/t210/sopen_alpha_read.c000066400000000000000000000370161175724200100174700ustar00rootroot00000000000000/* $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-dev.h" 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); 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); else strcpy(fn,f2); 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); else strcpy(fn,f2); 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; strcpy(hc->Label, t); 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; sscanf(t1, "%f, %f, %f, %f, %as", &HighPass,&LowPass, &tmp1,&tmp2, &pd); 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); else strcpy(fn,f2); 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 ambigous 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); else strcpy(fn,f2); 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); } t = strtok(NULL,"\xA\xD"); } hdr->T0 = tm_time2gdf_time(&T); } f2 = "marker"; if (tmpstr) strcpy(tmpstr+1,f2); else strcpy(fn,f2); 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); else strcpy(fn,f2); 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); hdr->Patient.Name[l0] = ' '; strcpy(hdr->Patient.Name + l0 + 1, Lastname); } else strncpy(hdr->Patient.Name, Lastname, MAX_LENGTH_NAME); } strcpy(fn,hdr->FileName); tmpstr = strrchr(fn,FILESEP); f2 = "rawdata"; if (tmpstr) strcpy(tmpstr+1,f2); else strcpy(fn,f2); 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; } biosig4c++-1.3.0/t210/sopen_famos_read.c000066400000000000000000000347371175724200100175170ustar00rootroot00000000000000/* $Id: sopen_famos_read.c,v 1.5 2009/04/06 07:38:33 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/ 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" /* 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "FAMOS: more than one buffer not supported (yet)"; } // 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "FAMOS: more than one group not supported (yet)"; } 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; // B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; // B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_UNSPECIFIC_ERROR; B4C_ERRMSG = "FAMOS: too many CC definitions in group"; } CHAN = hdr->NS - NoChanCurrentGroup--; if (CHAN==0) hdr->SampleRate = Fs; else if (OnOff && (abs(hdr->SampleRate - Fs)>1e-9*Fs)) { fprintf(stdout,"ERR2: %i %f %f\n",CHAN,hdr->SampleRate, Fs); // B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; // B4C_ERRMSG = "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)) { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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__ B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "FAMOS: Offset != 0 not supported"; #endif }; // DirekteFolgeAnzahl t2 += p+1; p = strcspn(t2,","); t2[p] = 0; if (atoi(t2) != 1) { B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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__ B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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; B4C_ERRNUM = B4C_DATATYPE_UNSUPPORTED; B4C_ERRMSG = "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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "FAMOS: more than one CS section not supported (yet)"; } 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 biosig4c++-1.3.0/t210/sopen_scp_read.c000066400000000000000000001272571175724200100171770ustar00rootroot00000000000000/* $Id: sopen_scp_read.c,v 1.66 2009/04/09 15:08:14 schloegl Exp $ Copyright (C) 2005,2006,2007,2011 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 "../biosig-dev.h" #include "structures.h" static const uint8_t _NUM_SECTION = 12U; //consider first 11 sections of SCP static bool add_filter = true; // additional filtering gives better shape, but use with care #ifndef WITHOUT_SCP_DECODE EXTERN_C int scp_decode(HDRTYPE* hdr, struct pointer_section *section, struct DATA_DECODE*, struct DATA_RECORD*, struct DATA_INFO*, bool ); EXTERN_C 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 uint16_t *inlen; 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 { B4C_ERRMSG = "Empty node in Huffman table! Do not know what to do !\n"; B4C_ERRNUM = B4C_DECOMPRESSION_FAILED; return(-1); } } else { if (node->child0 != NULL) node = node->child0; else { B4C_ERRMSG = "Empty node in Huffman table! Do not know what to do !\n"; B4C_ERRNUM = B4C_DECOMPRESSION_FAILED; 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 (; k1HDR 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. */ aECG_TYPE* aECG; en1064.Section5.inlen = NULL; en1064.Section5.datablock = NULL; en1064.Section3.lead = NULL; en1064.Section4.beat = NULL; en1064.Section6.inlen = NULL; if (hdr->aECG == NULL) { hdr->aECG = malloc(sizeof(aECG_TYPE)); aECG = (aECG_TYPE*)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 = (aECG_TYPE*)hdr->aECG; aECG->Section1.Tag14.VERSION = 0; // acquiring.protocol_revision_number aECG->Section1.Tag15.VERSION = 0; // analyzing.protocol_revision_number aECG->FLAG.HUFFMAN = 0; aECG->FLAG.DIFF = 0; aECG->FLAG.REF_BEAT = 0; aECG->FLAG.BIMODAL = 0; aECG->Section8.NumberOfStatements = 0; aECG->Section8.Statements = NULL; aECG->Section11.NumberOfStatements = 0; aECG->Section11.Statements = NULL; en1064.FLAG.HUFFMAN = 0; en1064.FLAG.DIFF = 0; en1064.FLAG.REF_BEAT = 0; en1064.FLAG.BIMODAL = 0; en1064.Section4.len_ms = 0; #ifndef WITHOUT_SCP_DECODE struct pointer_section section[_NUM_SECTION]; 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 = min((len-16)/10,_NUM_SECTION); 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 = K; section[K].length = 0; section[K].index = 0; } for (K=1; K8) fprintf(stdout,"%s(%i) ",hdr->FileName,K); curSect = section[K].ID; len = section[K].length; sectionStart = section[K].index; if (VERBOSE_LEVEL>8) fprintf(stdout,"SCP Section %i %i len=%i secStart=%i HeaderLength=%i\n",K,curSect,len,(int)sectionStart,hdr->HeadLen); if (len==0) continue; /***** empty section *****/ if (sectionStart + len > hdr->HeadLen) { B4C_ERRNUM = B4C_INCOMPLETE_FILE; B4C_ERRMSG = "SOPEN(SCP-READ): File inclomplete - 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); #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)); #endif uint8_t versionSection = *(ptr+sectionStart+8); uint8_t versionProtocol = *(ptr+sectionStart+9); #ifndef ANDROID if (versionSection != 13 && versionSection != 20) 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) fprintf(stderr,"Warning SOPEN(SCP-READ): Version of Protocol is not 13 or 20 but %i. This is not tested.\n", versionProtocol); #endif curSectPos = 16; /**** SECTION 0 ****/ if (curSect==0) { } /**** SECTION 1 ****/ 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>8) fprintf(stdout,"SCP(r): Section 1 Tag %i Len %i\n",tag,len1); 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) { if (!hdr->FLAG.ANONYMOUS) strncpy(hdr->Patient.Name, (char*)(PtrCurSect+curSectPos),min(len1,MAX_LENGTH_NAME)); } else if (tag==1) { // hdr->Patient.FirstName = (char*)(PtrCurSect+curSectPos); } else if (tag==2) { if (len1 > MAX_LENGTH_PID) { #ifndef ANDROID fprintf(stdout,"Warning SCP(read): length of Patient Id (section1 tag2) exceeds %i>%i\n",len1,MAX_LENGTH_PID); #endif } strncpy(hdr->Patient.Id,(char*)(PtrCurSect+curSectPos),min(len1,MAX_LENGTH_PID)); hdr->Patient.Id[MAX_LENGTH_PID] = 0; if (!strcmp(hdr->Patient.Id,"UNKNOWN")) hdr->Patient.Id[0] = 0; } else if (tag==3) { } 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) { } else if (tag==11) { aECG->systolicBloodPressure = leu16p(PtrCurSect+curSectPos); } else if (tag==12) { aECG->diastolicBloodPressure = leu16p(PtrCurSect+curSectPos); } else if (tag==13) { aECG->Diagnosis = (char*)(PtrCurSect+curSectPos); } else if (tag==14) { #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") } else if (tag==15) { //memcpy(hdr->aECG->Section1.tag15,PtrCurSect+curSectPos,40); aECG->Section1.Tag15.VERSION = *(PtrCurSect+curSectPos+14); } else if (tag==16) { hdr->ID.Hospital = strndup(PtrCurSect+curSectPos+14,len1); } else if (tag==17) { } else if (tag==18) { } else if (tag==19) { } else if (tag==20) { aECG->ReferringPhysician = (char*)(PtrCurSect+curSectPos); } else if (tag==21) { aECG->MedicationDrugs = (char*)(PtrCurSect+curSectPos); } else if (tag==22) { hdr->ID.Technician = (char*)realloc(hdr->ID.Technician,len1+1); memcpy(hdr->ID.Technician,(char*)(PtrCurSect+curSectPos),len1); hdr->ID.Technician[len1] = 0; } else if (tag==23) { } 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) { } else if (tag==31) { } else if (tag==32) { 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) { } else if (tag==34) { int16_t tzmin = lei16p(PtrCurSect+curSectPos); if (tzmin != 0x7fff) { if (abs(tzmin)<=780) t0.tm_min += 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 { } curSectPos += len1; } // t0.tm_gmtoff = 60*tzminutes; // t0.tm_isdst = -1; hdr->T0 = tm_time2gdf_time(&t0); } /**** SECTION 2 ****/ else if (curSect==2) { aECG->FLAG.HUFFMAN = 1; en1064.FLAG.HUFFMAN = 1; NHT = leu16p(PtrCurSect+curSectPos); curSectPos += 2; 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.FLAG.REF_BEAT = (*(PtrCurSect+curSectPos+1) & 0x01); en1064.Section3.flags = *(PtrCurSect+curSectPos+1); if (en1064.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; en1064.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); hdr->CHANNEL[i].SPR = en1064.Section3.lead[i].end - en1064.Section3.lead[i].start + 1; hdr->SPR = lcm(hdr->SPR,hdr->CHANNEL[i].SPR); hdr->CHANNEL[i].LeadIdCode = *(PtrCurSect+curSectPos+8); 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 ****/ else if (curSect==4) { en1064.Section4.len_ms = leu16p(PtrCurSect+curSectPos); en1064.Section4.fiducial_sample = leu16p(PtrCurSect+curSectPos+2); en1064.Section4.N = leu16p(PtrCurSect+curSectPos+4); 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) { en1064.FLAG.REF_BEAT = 0; } } /**** SECTION 5 ****/ 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*sizeof(*en1064.Section5.inlen)); for (i=0; i < hdr->NS; i++) { en1064.Section5.inlen[i] = leu16p(PtrCurSect+curSectPos+6+2*i); if (!section[4].length && (en1064.Section5.LengthNS * 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); if (en1064.FLAG.HUFFMAN) { if (B4C_ERRNUM) { deallocEN1064(en1064); return(-1); } DecodeHuffman(HTrees, Huffman, Ptr2datablock, en1064.Section5.inlen[i], en1064.Section5.datablock + en1064.Section5.Length*i, en1064.Section5.Length); } 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) { hdr->NRec = 1; en1064.Section6.inlen = (typeof(en1064.Section6.inlen))malloc(hdr->NS*sizeof(*en1064.Section6.inlen)); 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); en1064.Section6.BIMODAL = *(PtrCurSect+curSectPos+5); en1064.FLAG.BIMODAL = *(PtrCurSect+curSectPos+5); Cal6 = leu16p(PtrCurSect+curSectPos); en1064.Section6.dT_us = leu16p(PtrCurSect+curSectPos+2); aECG->FLAG.DIFF = *(PtrCurSect+curSectPos+4); aECG->FLAG.BIMODAL = *(PtrCurSect+curSectPos+5); 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 (Cal5==0 && Cal6 >0) Cal0 = Cal6; else if (Cal5 >0 && Cal6==0) Cal0 = Cal5; else if (Cal5 >0 && Cal6 >0) Cal0 = gcd(Cal5,Cal6); uint16_t cal5 = Cal5/Cal0; uint16_t cal6 = Cal6/Cal0; 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>8) 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; en1064.Section6.inlen[i] = leu16p(PtrCurSect+curSectPos+6+2*i); if (en1064.FLAG.HUFFMAN) { if (B4C_ERRNUM) { deallocEN1064(en1064); return(-1); } DecodeHuffman(HTrees, Huffman, Ptr2datablock, en1064.Section6.inlen[i], data + i*hdr->SPR, hdr->SPR); } else { for (k1=0, ix = i*hdr->SPR; k1 < SPR; k1++) data[ix+k1] = lei16p(Ptr2datablock + 2*k1); } len += en1064.Section6.inlen[i]; Ptr2datablock += en1064.Section6.inlen[i]; 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 || en1064.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 (en1064.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) { 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) { 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); } } /**** SECTION 9 ****/ else if (curSect==9) { aECG->Section9.StartPtr = (char*)(PtrCurSect+curSectPos); aECG->Section9.Length = len; } /**** SECTION 10 ****/ else if (curSect==10) { } /**** SECTION 11 ****/ else if (curSect==11) { if(lenSection11.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); } } /**** SECTION 12 ****/ else if (curSect==12) { } /**** SECTION 13 ****/ else if (curSect==13) { } /**** SECTION 14 ****/ else if (curSect==14) { } else { } } /* free allocated memory */ deallocEN1064(en1064); #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 fprintf(stdout, "\nUse SCP_DECODE (Huffman=%i RefBeat=%i Bimodal=%i)\n", 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; 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 { B4C_ERRNUM = B4C_CANNOT_OPEN_FILE; B4C_ERRMSG = "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 }; biosig4c++-1.3.0/t210/structures.h000066400000000000000000000176471175724200100164440ustar00rootroot00000000000000/* --------------------------------------------------------------------------- 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 #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 { U_int_M number; const char *sentence; }; struct numeric { U_int_M value; U_int_S unit; } ; struct section_header { U_int_M CRC; U_int_M ID; U_int_L length; U_int_S version; U_int_S protocol_version; char *word; }; struct file_header { U_int_M CRC; U_int_L length; }; struct pointer_section { U_int_L index; U_int_M ID; U_int_L length; }; struct device_info { U_int_M institution_number; U_int_M department_number; U_int_M ID; U_int_S type; U_int_S manifacturer; char *model_description; U_int_S protocol_revision_number; U_int_S category; U_int_S language; U_int_S capability[4]; U_int_S 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 { U_int_S table; U_int_S classes; U_int_S drug_code; U_int_M length; }; struct Time_Zone { int_M offset; U_int_M 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; U_int_S sex; U_int_S race; U_int_M systolic_pressure; U_int_M diastolic_pressure; }; struct clinic { U_int_M number_drug; struct info_drug *drug; char *text_drug; U_int_M number_diagnose; struct numeric *diagnose; char *text_diagnose; char *referring_physician; char *latest_confirming_physician; char *technician_description; U_int_M number_text; struct numeric *free_text; char *text_free_text; U_int_M number_hystory; struct numeric *medical_hystory; U_int_M 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; U_int_S stat_code; }; struct device { time_t date_acquisition2; // by E.C. feb 2006 time_t time_acquisition2; // by E.C. feb 2006 U_int_M baseline_filter; U_int_M lowpass_filter; U_int_S other_filter[4]; char *sequence_number; struct numeric electrode_configuration; struct Time_Zone TZ; }; struct table_H { U_int_S bit_prefix; U_int_S bit_code; U_int_S TMS; int_M base_value; U_int_L base_code; }; struct f_lead { U_int_S number; bool subtraction; bool all_simultaneously; U_int_S number_simultaneously; }; struct lead { U_int_S ID; U_int_L start; U_int_L end; }; struct Subtraction_Zone { U_int_M beat_type; U_int_L SB; U_int_L fc; U_int_L SE; }; struct Protected_Area { U_int_L QB; U_int_L QE; }; struct f_BdR0 { U_int_M length; U_int_M fcM; U_int_M AVM; U_int_M STM; U_int_M number_samples; U_int_S encoding; }; struct f_Res { U_int_M AVM; U_int_M STM; U_int_M number; U_int_M number_samples; U_int_S encoding; bool bimodal; U_int_S decimation_factor; }; struct spike { U_int_M time; int_M amplitude; U_int_S type; U_int_S source; U_int_S index; U_int_M pulse_width; }; struct global_measurement { U_int_S number; U_int_M number_QRS; U_int_S number_spike; U_int_M average_RR; U_int_M average_PP; U_int_M ventricular_rate; U_int_M atrial_rate; U_int_M QT_corrected; U_int_S formula_type; U_int_M number_tag; }; struct additional_measurement { U_int_S ID; U_int_S byte[5]; }; struct BdR_measurement { U_int_M P_onset; U_int_M P_offset; U_int_M QRS_onset; U_int_M QRS_offset; U_int_M T_offset; int_M P_axis; int_M QRS_axis; int_M T_axis; }; struct info { U_int_S type; char *date; char *time; U_int_S number; }; struct header_lead_measurement { U_int_M number_lead; U_int_M number_lead_measurement; }; struct lead_measurement_block { U_int_M ID; int_M P_duration; int_M PR_interval; int_M QRS_duration; int_M QT_interval; int_M Q_duration; int_M R_duration; int_M S_duration; int_M R1_duration; int_M S1_duration; int_M Q_amplitude; int_M R_amplitude; int_M S_amplitude; int_M R1_amplitude; int_M S1_amplitude; int_M J_point_amplitude; int_M Pp_amplitude; int_M Pm_amplitude; int_M Tp_amplitude; int_M Tm_amplitude; int_M ST_slope; int_M P_morphology; int_M T_morphology; int_M iso_electric_segment_onset_QRS; int_M iso_electric_segment_offset_QRS; int_M intrinsicoid_deflection; U_int_M quality_recording[8]; int_M ST_amplitude_Jplus20; int_M ST_amplitude_Jplus60; int_M ST_amplitude_Jplus80; int_M ST_amplitude_JplusRR16; int_M ST_amplitude_JplusRR8; }; struct statement_coded { U_int_S sequence_number; U_int_M length; U_int_S type; U_int_M number_field; }; //_____________________________________ //structs for sections: 2, 3, 4, 5, 6 //_____________________________________ struct DATA_DECODE { struct table_H *t_Huffman; U_int_M *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; U_int_M *length_BdR0; U_int_S *samples_BdR0; int_L *Median; struct f_Res flag_Res; U_int_M *length_Res; U_int_S *samples_Res; int_L *Residual; int_L *Reconstructed; }; struct TREE_NODE //struttura di un nodo dell'albero { struct TREE_NODE *next_0; struct TREE_NODE *next_1; int_M row; }; //_____________________________________ //structs for sections: 7, 10 //_____________________________________ struct DATA_RECORD { struct global_measurement data_global; struct spike *data_spike; U_int_S *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__*/ //_____________________________________ biosig4c++-1.3.0/t220/000077500000000000000000000000001175724200100140325ustar00rootroot00000000000000biosig4c++-1.3.0/t220/crc4scp.c000066400000000000000000000066271175724200100155520ustar00rootroot00000000000000/* --------------------------------------------------------------------------- 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$ --------------------------------------------------------------------------- */ #ifdef _VCPP_DEF typedef unsigned __int64 uint64_t; typedef __int64 int64_t; typedef unsigned long uint32_t; typedef long int32_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef char 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 biosig4c++-1.3.0/t220/sopen_scp_write.c000066400000000000000000000537501175724200100174130ustar00rootroot00000000000000/* $Id: sopen_scp_write.c,v 1.42 2009-04-09 15:08:14 schloegl Exp $ Copyright (C) 2005,2006,2007 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 "../biosig-dev.h" EXTERN_C int sopen_SCP_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: 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 int curSect; uint32_t len; uint16_t crc; uint32_t i; uint32_t sectionStart; struct tm* T0_tm; double AVM, avm; uint16_t avm16; aECG_TYPE* aECG; if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN_SCP_WRITE 101\n"); if ((fabs(hdr->VERSION - 1.3)<0.01) && (fabs(hdr->VERSION-2.0)<0.01)) fprintf(stderr,"Warning SOPEN (SCP-WRITE): Version %f not supported\n",hdr->VERSION); uint8_t VERSION = 20; // (uint8_t)round(hdr->VERSION*10); // implemented version number if (hdr->aECG==NULL) { fprintf(stderr,"Warning SOPEN_SCP_WRITE: No aECG info defined\n"); hdr->aECG = malloc(sizeof(aECG_TYPE)); aECG = (aECG_TYPE*)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; aECG->Section8.NumberOfStatements = 0; aECG->Section8.Statements = NULL; aECG->Section11.NumberOfStatements = 0; aECG->Section11.Statements = NULL; } else aECG = (aECG_TYPE*)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 = VERSION; // 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) aECG->Section1.Tag14.LANG_SUPP_CODE = 0x00; // tag 14, byte 17 (LANG_SUPP_CODE has to be 0x00 => Ascii only, latin and 1-byte code) 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; if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN_SCP_WRITE 111\n"); ptr = (uint8_t*)hdr->AS.Header; int NSections = 12; // initialize section 0 sectionStart = 6+16+NSections*10; ptr = (uint8_t*)realloc(ptr,sectionStart); memset(ptr,0,sectionStart); uint32_t curSectLen = 0; // 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,"Section %i %p\n",curSect,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; memcpy(ptr+16,"SCPECG",6); // reserved curSectLen += NSections*10; } else if (curSect==1) // SECTION 1 { ptr = (uint8_t*)realloc(ptr,sectionStart+10000); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 0 \n"); // Tag 0 (max len = 64) if (!hdr->FLAG.ANONYMOUS && (hdr->Patient.Name != NULL)) { *(ptr+sectionStart+curSectLen) = 0; // tag len = strlen(hdr->Patient.Name) + 1; leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,hdr->Patient.Name,len); // field curSectLen += len+3; } if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 1 \n"); // Tag 1 (max len = 64) Firstname /* *(ptr+sectionStart+curSectLen) = 1; // tag len = strlen(hdr->Patient.Name) + 1; leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy((char*)ptr+sectionStart+curSectLen+3,hdr->Patient.Name,len); // field 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; } // fprintf(stdout,"Section %i Len %i %x\n",curSect,curSectLen,sectionStart); // Tag 3 (max len = 64) Second Last Name /* *(ptr+sectionStart+curSectLen) = 3; // tag len = strlen(hdr->Patient.Name) + 1; leu16a(len, ptr+sectionStart+curSectLen+1); // length strncpy(ptr+sectionStart+curSectLen+3,hdr->Patient.Name,len); // field 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) = VERSION; // 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 = strlen(hdr->ID.Hospital); 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 ) len = strlen(hdr->ID.Technician); if (VERBOSE_LEVEL>7) fprintf(stdout,"Section 1 Tag 22 \n"); 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 (hdr->NS>0) { // Tag 27 (len = 3) highpass filter *(ptr+sectionStart+curSectLen) = 27; // tag leu16a(2, ptr+sectionStart+curSectLen+1); // length leu16a((uint16_t)hdr->CHANNEL[1].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)hdr->CHANNEL[1].LowPass, ptr+sectionStart+curSectLen+3); // hour curSectLen += 5; // Tag 29 (len = 1) filter bitmap uint8_t bitmap = 0; if (fabs(hdr->CHANNEL[1].LowPass-60.0)<0.01) bitmap = 1; else if (fabs(hdr->CHANNEL[1].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 // FIXME: compensation for daylight saving time not included #ifdef __APPLE__ // ### FIXME: for some (unknown) reason, timezone does not work on MacOSX lei16a(0x7fff, ptr+sectionStart+curSectLen+3); printf("Warning SOPEN(SCP,write): timezone not supported\n"); #else lei16a((int16_t)lrint(-timezone/60.0), ptr+sectionStart+curSectLen+3); #endif //lei16a((int16_t)round(T0_tm->tm_gmtoff/60), 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*hdr->NS+1); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length // Number of leads enclosed *(ptr+sectionStart+curSectLen++) = hdr->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++) = (hdr->NS<<3) | 0x04; for (i = 0; i < hdr->NS; i++) { leu32a(1L, ptr+sectionStart+curSectLen); leu32a(hdr->data.size[0], ptr+sectionStart+curSectLen+4); *(ptr+sectionStart+curSectLen+8) = (uint8_t)hdr->CHANNEL[i].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 { uint16_t GDFTYP = 3; size_t SZ = GDFTYP_BITS[GDFTYP]>>3; for (i = 0; i < hdr->NS; i++) hdr->CHANNEL[i].GDFTYP = GDFTYP; ptr = (uint8_t*)realloc(ptr,sectionStart+16+6+2*hdr->NS+SZ*(hdr->data.size[0]*hdr->data.size[1])); PtrCurSect = ptr+sectionStart; curSectLen = 16; // current section length // Create all the fields // Amplitude Value Multiplier (AVM) i = 0; AVM = hdr->CHANNEL[i].Cal * 1e9 * PhysDimScale(hdr->CHANNEL[i].PhysDimCode); for (i = 1; i < hdr->NS; i++) { // check for physical dimension and adjust scaling factor to "nV" avm = hdr->CHANNEL[i].Cal * 1e9 * PhysDimScale(hdr->CHANNEL[i].PhysDimCode); // 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 < hdr->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 // free(hdr->AS.rawdata); // hdr->AS.rawdata = PtrCurSect+16+6+2*hdr->NS; curSectLen += SZ*(hdr->data.size[0]*hdr->data.size[1]); // 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 { } else if (curSect==8) // SECTION 8 { } else if (curSect==9) // SECTION 9 { } else if (curSect==10) // SECTION 10 { } else if (curSect==11) // SECTION 11 { } 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] = VERSION; // Section Version Number ptr[sectionStart+9] = VERSION; // Protocol Version Number 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 hdr->AS.rawdata = ptr+aECG->Section6.StartPtr+16+6+2*hdr->NS; hdr->AS.Header = ptr; if (VERBOSE_LEVEL>7) fprintf(stdout,"SOPEN_SCP_WRITE 400\n"); return(0); } biosig4c++-1.3.0/t230/000077500000000000000000000000001175724200100140335ustar00rootroot00000000000000biosig4c++-1.3.0/t230/sopen_hl7aecg.c000066400000000000000000001460401175724200100167220ustar00rootroot00000000000000/* $Id: sopen_hl7aecg.c,v 1.36 2009/04/09 13:54:04 schloegl Exp $ Copyright (C) 2006,2007,2009,2011 Alois Schloegl Copyright (C) 2007 Elias Apostolopoulos 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. */ #include // system includes #include #include "../biosig-dev.h" #ifdef WITH_LIBXML2 # include # include #else # include "../XMLParser/tinyxml.h" #endif /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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"); #ifdef WITH_LIBXML2 fprintf(stderr,"Warning: LIBXML2 is used instead of TinyXML - support for HL7aECG is very experimental and must not be used for production use! You are warned\n"); #else TiXmlDocument doc(hdr->FileName); if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7r: [411]\n"); if ( doc.LoadFile() ) { if (VERBOSE_LEVEL > 7) fprintf(stdout,"hl7r: [412]\n"); 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"); 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 ambigous\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("firstname"); 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("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("name").FirstChild("lastname"); 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->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] = ' '; 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 (!strcmpi("yes",H.FirstChild("Filter50Hz").Element()->GetText())) Notch = 50; else if (!strcmpi("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->LeadIdCode = 0; size_t j; for (j=0; strcmpi(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 implmented 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); 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); if (l1+l2+2 <= MAX_LENGTH_NAME) { strcpy(hdr->Patient.Name, str1); strcpy(hdr->Patient.Name+l1, ", "); strcpy(hdr->Patient.Name+l1+2, str2); } } } 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(strcpy(tmp,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(strcpy(tmp,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"); 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",B4C_ERRNUM); hdr2ascii(hdr,stdout,3); fprintf(stdout,"hl7r: [431] %i\n",B4C_ERRNUM); } } else { fprintf(stderr, "%s : failed to parse (2)\n", hdr->FileName); } } else fprintf(stderr, "%s : failed to parse (1)\n", hdr->FileName); #endif 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]; #ifdef WITH_LIBXML2 fprintf(stderr,"Warning: LIBXML2 is used instead of TinyXML - support for HL7aECG is very experimental and must not be used for production use! You are warned\n"); xmlDoc *doc = xmlNewDoc("1.0"); xmlNode *root = xmlNewNode(NULL, "root"); xmlDocSetRootElement(doc, root); xmlNode *node = xmlNewNode(NULL, "element"); xmlAddChild(node, xmlNewText("some text here")); xmlAddChild(root, node); if (ifopen(hdr, "w")) { B4C_ERRNUM = B4C_CANNOT_WRITE_FILE; B4C_ERRMSG = "Cannot open file for writing"; } else if (hdr->FILE.COMPRESSION) xmlElemDump(hdr->FILE.gzFID, doc, root); else xmlElemDump(hdr->FILE.FID, doc, root); ifclose(hdr); xmlFreeDoc(doc); xmlCleanupParser(); #else TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); doc.LinkEndChild(decl); 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"); 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); t0 = gdf_time2tm_time(t1); t2 = tm_time2gdf_time(t0); double dT; dT = ldexp(t1-t2,-32)*(3600*24); dT = round(dT*1000); sprintf(timelow, "%4d%2d%2d%2d%2d%2d.%3d", t0->tm_year+1900, t0->tm_mon+1, t0->tm_mday, t0->tm_hour, t0->tm_min, t0->tm_sec,(int)ceil(dT)); t1 = hdr->T0 + ldexp((hdr->SPR/hdr->SampleRate)/(3600.0*24),32); t0 = gdf_time2tm_time(t1); t2 = tm_time2gdf_time(t0); dT = ldexp(t1-t2,-32)*(3600*24); dT = floor(dT*1000); sprintf(timehigh, "%4d%2d%2d%2d%2d%2d.%3d", t0->tm_year+1900, t0->tm_mon+1, t0->tm_mday, t0->tm_hour, t0->tm_min, t0->tm_sec,(int)ceil(dT)); 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"); TiXmlText *nameText = new TiXmlText(hdr->Patient.Name); subjectDemographicPersonName->LinkEndChild(nameText); 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.000", 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); 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); 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_"); strcat(tmp,LEAD_ID_TABLE[hdr->CHANNEL[i].LeadIdCode]); } else strcpy(tmp,hdr->CHANNEL[i].Label); 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); // store physical unit in tmp PhysDim(hdr->CHANNEL[i].PhysDimCode,tmp); valueHead = new TiXmlElement("origin"); valueHead->SetDoubleAttribute("value", hdr->CHANNEL[i].Off); // valueHead->SetDoubleAttribute("value", 0); valueHead->SetAttribute("unit", tmp); sequenceValue->LinkEndChild(valueHead); valueIncrement = new TiXmlElement("scale"); valueIncrement->SetDoubleAttribute("value", hdr->CHANNEL[i].Cal); //valueIncrement->SetDoubleAttribute("value", 1); valueIncrement->SetAttribute("unit", tmp); 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; } int status = doc.SaveFile(hdr->FileName, (char)hdr->FILE.COMPRESSION); // doc.SaveFile(hdr); if (VERBOSE_LEVEL>7) fprintf(stdout,"hl7c 989 (%i)\n",status); #endif return(0); }; biosig4c++-1.3.0/t240/000077500000000000000000000000001175724200100140345ustar00rootroot00000000000000biosig4c++-1.3.0/t240/ANY.c000066400000000000000000000061301175724200100146270ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/ANY.h000066400000000000000000000025561175724200100146440ustar00rootroot00000000000000/*- * 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 */ biosig4c++-1.3.0/t240/AbsoluteRange.c000066400000000000000000000042431175724200100167360ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AbsoluteRange.h000066400000000000000000000012771175724200100167470ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AbsoluteTime.c000066400000000000000000000073671175724200100166120ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AbsoluteTime.h000066400000000000000000000015011175724200100165770ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Address.c000066400000000000000000000070031175724200100155650ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Address.h000066400000000000000000000013641175724200100155760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertCode.c000066400000000000000000000070461175724200100160510ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertCode.h000066400000000000000000000014121175724200100160450ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertCondition.c000066400000000000000000000100041175724200100171110ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertCondition.h000066400000000000000000000017661175724200100171350ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertControls.c000066400000000000000000000073271175724200100170040ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertControls.h000066400000000000000000000020031175724200100167730ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertFlags.c000066400000000000000000000071671175724200100162370ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertFlags.h000066400000000000000000000020201175724200100162230ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertSection.c000066400000000000000000000077441175724200100166100ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertSection.h000066400000000000000000000021451175724200100166030ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/AlertType.c000066400000000000000000000070551175724200100161200ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/AlertType.h000066400000000000000000000017761175724200100161310ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ApplicationArea.c000066400000000000000000000073551175724200100172460ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ApplicationArea.h000066400000000000000000000020251175724200100172400ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ArchiveProtection.c000066400000000000000000000044121175724200100176310ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ArchiveProtection.h000066400000000000000000000013641175724200100176410ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Authorization.c000066400000000000000000000043161175724200100170440ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Authorization.h000066400000000000000000000013401175724200100170430ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/BITS-16.c000066400000000000000000000075551175724200100152010ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/BITS-16.h000066400000000000000000000013661175724200100152000ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/BITS-32.c000066400000000000000000000075551175724200100151770ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/BITS-32.h000066400000000000000000000013661175724200100151760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/BITS-8.c000066400000000000000000000075141175724200100151150ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/BITS-8.h000066400000000000000000000013511175724200100151130ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/BIT_STRING.c000066400000000000000000000107401175724200100157060ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/BIT_STRING.h000066400000000000000000000014701175724200100157130ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/BodySiteCode.c000066400000000000000000000072061175724200100165220ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/BodySiteCode.h000066400000000000000000000014611175724200100165240ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ChannelDescriptionSection.c000066400000000000000000000124131175724200100213020ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ChannelDescriptionSection.h000066400000000000000000000023151175724200100213070ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ChannelStatus.c000066400000000000000000000073271175724200100167650ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ChannelStatus.h000066400000000000000000000020571175724200100167650ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ChoiceOfEnumObsValue.c000066400000000000000000000074041175724200100201520ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ChoiceOfEnumObsValue.h000066400000000000000000000026521175724200100201570ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ChoiceOfEnumTimeStamp.c000066400000000000000000000171251175724200100203360ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ChoiceOfEnumTimeStamp.h000066400000000000000000000036261175724200100203440ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ChoiceOfNuObsValue.c000066400000000000000000000072561175724200100176350ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ChoiceOfNuObsValue.h000066400000000000000000000025701175724200100176340ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Comments.c000066400000000000000000000041021175724200100157620ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Comments.h000066400000000000000000000012701175724200100157720ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ContentOrReference.c000066400000000000000000000040001175724200100177240ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ContentOrReference.h000066400000000000000000000020261175724200100177370ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/CurLimAlStat.c000066400000000000000000000072671175724200100165200ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/CurLimAlStat.h000066400000000000000000000017221175724200100165130ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DescriptiveDataSection.c000066400000000000000000000272461175724200100206130ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DescriptiveDataSection.h000066400000000000000000000047331175724200100206140ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DeviceCode.c000066400000000000000000000071061175724200100161760ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DeviceCode.h000066400000000000000000000014271175724200100162030ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DispResolution.c000066400000000000000000000042571175724200100171730ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DispResolution.h000066400000000000000000000013001175724200100171620ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DistributionSampleArrayDescriptiveDataSection.c000066400000000000000000001035331175724200100253460ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DistributionSampleArrayDescriptiveDataSection.h000066400000000000000000000122221175724200100253450ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DistributionSampleArrayMeasuredDataSection.c000066400000000000000000000126321175724200100246310ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DistributionSampleArrayMeasuredDataSection.h000066400000000000000000000024601175724200100246340ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DsaRangeSpec.c000066400000000000000000000043031175724200100164770ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DsaRangeSpec.h000066400000000000000000000013111175724200100165000ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/DynamicAttributeChangeSection.c000066400000000000000000000063431175724200100221110ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/DynamicAttributeChangeSection.h000066400000000000000000000016531175724200100221150ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumObject.c000066400000000000000000000041541175724200100162370ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumObject.h000066400000000000000000000013241175724200100162400ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumObsValue.c000066400000000000000000000047521175724200100165550ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumObsValue.h000066400000000000000000000014501175724200100165520ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumRecordMetric.c000066400000000000000000000041551175724200100174140ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumRecordMetric.h000066400000000000000000000013551175724200100174200ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumRecordOO.c000066400000000000000000000040261175724200100165030ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumRecordOO.h000066400000000000000000000013131175724200100165040ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumVal.c000066400000000000000000000065751175724200100155640ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumVal.h000066400000000000000000000023561175724200100155620ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumerationDescriptiveDataSection.c000066400000000000000000000635001175724200100230130ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumerationDescriptiveDataSection.h000066400000000000000000000075661175724200100230320ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/EnumerationMeasuredDataSection.c000066400000000000000000000064131175724200100222770ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/EnumerationMeasuredDataSection.h000066400000000000000000000016701175724200100223040ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ExtNomenRef.c000066400000000000000000000040171175724200100163740ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ExtNomenRef.h000066400000000000000000000013351175724200100164010ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ExtNomenclatureCode.c000066400000000000000000000075461175724200100201240ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ExtNomenclatureCode.h000066400000000000000000000016141175724200100201170ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/FEFFloat.c000066400000000000000000000067341175724200100156000ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/FEFFloat.h000066400000000000000000000013671175724200100156020ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/FEFString.c000066400000000000000000000071211175724200100157700ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/FEFString.h000066400000000000000000000014201175724200100157710ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/FilterType.c000066400000000000000000000071151175724200100162730ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/FilterType.h000066400000000000000000000016651175724200100163040ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Fraction.c000066400000000000000000000040661175724200100157530ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Fraction.h000066400000000000000000000012311175724200100157470ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/GeneralString.c000066400000000000000000000021751175724200100167510ustar00rootroot00000000000000/*- * 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 */ }; biosig4c++-1.3.0/t240/GeneralizedTime.c000066400000000000000000000361011175724200100172510ustar00rootroot00000000000000/*- * 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 { \ 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); #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; } biosig4c++-1.3.0/t240/GeneralizedTime.c.modified000066400000000000000000000360061175724200100210340ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/GeneralizedTime.h000066400000000000000000000042411175724200100172560ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/Handle.c000066400000000000000000000067661175724200100154120ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Handle.h000066400000000000000000000013431175724200100154010ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/HandleRef.c000066400000000000000000000070461175724200100160370ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/HandleRef.h000066400000000000000000000014121175724200100160330ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/HealthCareProfessionalSection.c000066400000000000000000000141651175724200100221210ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/HealthCareProfessionalSection.h000066400000000000000000000030221175724200100221140ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/HealthCareProviderId.c000066400000000000000000000101531175724200100201700ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/HealthCareProviderId.h000066400000000000000000000016311175724200100201760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/HealthCareProviderSection.c000066400000000000000000000123201175724200100212360ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/HealthCareProviderSection.h000066400000000000000000000025631175724200100212530ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/HighResRelativeTime.c000066400000000000000000000075461175724200100200600ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/HighResRelativeTime.h000066400000000000000000000016141175724200100200530ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-I16.c000066400000000000000000000074361175724200100152010ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-I16.h000066400000000000000000000013611175724200100151750ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-I32.c000066400000000000000000000074501175724200100151730ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-I32.h000066400000000000000000000013611175724200100151730ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-I64.c000066400000000000000000000067461175724200100152070ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-I64.h000066400000000000000000000013601175724200100151770ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-I8.c000066400000000000000000000073721175724200100151210ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-I8.h000066400000000000000000000013441175724200100151170ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-U16.c000066400000000000000000000074311175724200100152100ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-U16.h000066400000000000000000000013611175724200100152110ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-U32.c000066400000000000000000000075731175724200100152150ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-U32.h000066400000000000000000000013601175724200100152060ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-U64.c000066400000000000000000000067461175724200100152230ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-U64.h000066400000000000000000000013601175724200100152130ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INT-U8.c000066400000000000000000000073671175724200100151410ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/INT-U8.h000066400000000000000000000013441175724200100151330ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/INTEGER.c000066400000000000000000000543541175724200100153100ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/INTEGER.h000066400000000000000000000042671175724200100153130ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/LimitSpecEntry.c000066400000000000000000000064271175724200100171240ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/LimitSpecEntry.h000066400000000000000000000016011175724200100171160ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/LineFrequency.c000066400000000000000000000072551175724200100167620ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/LineFrequency.h000066400000000000000000000017431175724200100167630ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Makefile000066400000000000000000000226171175724200100155040ustar00rootroot00000000000000ASN_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) # 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 TARGET = libcnsfef.a $(WIN32) 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} W64OBJS=${ASN_MODULE_SOURCES:.c=.o64} ${ASN_CONVERTER_SOURCES:.c=.o64} CC = gcc AR = ar crs MinGWCC = $(CROSS)-gcc MinGW64CC = $(CROSS64)-gcc all: $(TARGET) #$(TARGET): ${OBJS} # $(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS) 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 $(TARGET) 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 ../annexb-snacc-122001.asn1 rm -f converter-sample.c Makefile.am.sample libfef.a biosig4c++-1.3.0/t240/ManufacturerID.c000066400000000000000000000047011175724200100170530ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ManufacturerID.h000066400000000000000000000017341175724200100170630ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ManufacturerSpecificBinary.c000066400000000000000000000046271175724200100214600ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ManufacturerSpecificBinary.h000066400000000000000000000014621175724200100214570ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ManufacturerSpecificEncoded.c000066400000000000000000000046431175724200100215730ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ManufacturerSpecificEncoded.h000066400000000000000000000014471175724200100215770ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ManufacturerSpecificSection.c000066400000000000000000000134741175724200100216400ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ManufacturerSpecificSection.h000066400000000000000000000027271175724200100216440ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MarkerEntryRelTim.c000066400000000000000000000043641175724200100175670ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MarkerEntryRelTim.h000066400000000000000000000013731175724200100175710ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MeasuredDataSection.c000066400000000000000000000340521175724200100200700ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MeasuredDataSection.h000066400000000000000000000053771175724200100201050ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MeasurementStatus.c000066400000000000000000000075271175724200100177040ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MeasurementStatus.h000066400000000000000000000024241175724200100177000ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MedicalDeviceComponents.c000066400000000000000000000126131175724200100207270ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MedicalDeviceComponents.h000066400000000000000000000034751175724200100207420ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MedicalDeviceSystemSection.c000066400000000000000000000307451175724200100214210ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MedicalDeviceSystemSection.h000066400000000000000000000045051175724200100214210ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricCalEntry.c000066400000000000000000000050511175724200100170660ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricCalEntry.h000066400000000000000000000014441175724200100170750ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricCalState.c000066400000000000000000000073151175724200100170520ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricCalState.h000066400000000000000000000017661175724200100170630ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricCalType.c000066400000000000000000000072551175724200100167160ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricCalType.h000066400000000000000000000017761175724200100167250ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricCategory.c000066400000000000000000000073151175724200100171270ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricCategory.h000066400000000000000000000022231175724200100171250ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricDescriptiveDataSection.c000066400000000000000000000562631175724200100217600ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricDescriptiveDataSection.h000066400000000000000000000070261175724200100217560ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricMeasure.c000066400000000000000000000041221175724200100167440ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricMeasure.h000066400000000000000000000013501175724200100167510ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricStatus.c000066400000000000000000000072671175724200100166430ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricStatus.h000066400000000000000000000020521175724200100166330ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MetricsCode.c000066400000000000000000000071461175724200100164110ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MetricsCode.h000066400000000000000000000014441175724200100164110ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MsmtPrinciple.c000066400000000000000000000073271175724200100167770ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MsmtPrinciple.h000066400000000000000000000022631175724200100167760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/MultimediaSection.c000066400000000000000000000103141175724200100176160ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/MultimediaSection.h000066400000000000000000000021371175724200100176270ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/NativeEnumerated.c000066400000000000000000000134261175724200100174460ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/NativeEnumerated.h000066400000000000000000000016011175724200100174430ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/NativeInteger.c000066400000000000000000000207761175724200100167600ustar00rootroot00000000000000/*- * 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); } } biosig4c++-1.3.0/t240/NativeInteger.h000066400000000000000000000021041175724200100167460ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/NuObsValue.c000066400000000000000000000054621175724200100162320ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/NuObsValue.h000066400000000000000000000015631175724200100162350ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/NumericDescriptiveDataSection.c000066400000000000000000000624501175724200100221320ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/NumericDescriptiveDataSection.h000066400000000000000000000076411175724200100221400ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/NumericMeasuredDataSection.c000066400000000000000000000056001175724200100214100ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/NumericMeasuredDataSection.h000066400000000000000000000016061175724200100214170ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/OBJECT_IDENTIFIER.c000066400000000000000000000440701175724200100166550ustar00rootroot00000000000000/*- * 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. * 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_ */ biosig4c++-1.3.0/t240/OCTET_STRING.c000066400000000000000000001332351175724200100161530ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/OCTET_STRING.h000066400000000000000000000054031175724200100161530ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/OID-Type.c000066400000000000000000000070061175724200100155350ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/OID-Type.h000066400000000000000000000013751175724200100155450ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ObservationTime.c000066400000000000000000000053121175724200100173130ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ObservationTime.h000066400000000000000000000015771175724200100173310ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ParameterGroupCode.c000066400000000000000000000075061175724200100177400ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ParameterGroupCode.h000066400000000000000000000015771175724200100177470ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PatMeasure.c000066400000000000000000000041271175724200100162520ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PatMeasure.h000066400000000000000000000013231175724200100162520ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PatientDemographicsSection.c000066400000000000000000000425071175724200100214670ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PatientDemographicsSection.h000066400000000000000000000056611175724200100214740ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PatientRace.c000066400000000000000000000071551175724200100164070ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PatientRace.h000066400000000000000000000017441175724200100164120ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PatientSex.c000066400000000000000000000071151175724200100162700ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PatientSex.h000066400000000000000000000017001175724200100162670ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PatientType.c000066400000000000000000000071551175724200100164560ustar00rootroot00000000000000/* * Generated by asn1c-0.9.21 (http://lionet.info/asn1c) * From ASN.1 module "FEF-IntermediateDraft" * found in "../annexb-snacc-122001.asn1" */ #include #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 */ }; biosig4c++-1.3.0/t240/PatientType.h000066400000000000000000000017231175724200100164560ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PersonName.c000066400000000000000000000057401175724200100162550ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PersonName.h000066400000000000000000000017121175724200100162550ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PersonNameGroup.c000066400000000000000000000071641175724200100172740ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PersonNameGroup.h000066400000000000000000000014531175724200100172740ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/Placeholder.c000066400000000000000000000073341175724200100164310ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/Placeholder.h000066400000000000000000000014561175724200100164350ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PowerStatus.c000066400000000000000000000072271175724200100165100ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PowerStatus.h000066400000000000000000000017771175724200100165210ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/PrivateCode.c000066400000000000000000000071461175724200100164150ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/PrivateCode.h000066400000000000000000000014441175724200100164150ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ProdSpecEntry.c000066400000000000000000000050401175724200100167400ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ProdSpecEntry.h000066400000000000000000000014361175724200100167520ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ProdSpecEntryType.c000066400000000000000000000074551175724200100176160ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ProdSpecEntryType.h000066400000000000000000000023011175724200100176040ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/REAL.c000066400000000000000000000372351175724200100147350ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/REAL.h000066400000000000000000000021511175724200100147270ustar00rootroot00000000000000/*- * 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 */ biosig4c++-1.3.0/t240/RealTimeSampleArrayDescriptiveDataSection.c000066400000000000000000001021171175724200100243660ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/RealTimeSampleArrayDescriptiveDataSection.h000066400000000000000000000120131175724200100243660ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/RealTimeSampleArrayMeasuredDataSection.c000066400000000000000000000124621175724200100236550ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/RealTimeSampleArrayMeasuredDataSection.h000066400000000000000000000024201175724200100236530ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/RelativeTime.c000066400000000000000000000072061175724200100165770ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/RelativeTime.h000066400000000000000000000014611175724200100166010ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaCalData.c000066400000000000000000000055271175724200100157660ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaCalData.h000066400000000000000000000014021175724200100157570ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaCalDataType.c000066400000000000000000000072551175724200100166300ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaCalDataType.h000066400000000000000000000016631175724200100166320ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaFilterEntry.c000066400000000000000000000050271175724200100167370ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaFilterEntry.h000066400000000000000000000014061175724200100167410ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaFlags.c000066400000000000000000000070271175724200100155260ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaFlags.h000066400000000000000000000015761175724200100155360ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaGridEntry.c000066400000000000000000000041671175724200100164030ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaGridEntry.h000066400000000000000000000013041175724200100163760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaSignalFrequency.c000066400000000000000000000044021175724200100175630ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaSignalFrequency.h000066400000000000000000000013361175724200100175730ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SaSpec.c000066400000000000000000000061401175724200100153570ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SaSpec.h000066400000000000000000000014621175724200100153660ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SampleArrayDescriptiveDataSection.c000066400000000000000000000772641175724200100227610ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SampleArrayDescriptiveDataSection.h000066400000000000000000000114401175724200100227460ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SampleArrayMeasuredDataBlock.c000066400000000000000000000103741175724200100216600ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SampleArrayMeasuredDataBlock.h000066400000000000000000000020131175724200100216540ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SampleArrayMeasuredDataSection.c000066400000000000000000000113651175724200100222330ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SampleArrayMeasuredDataSection.h000066400000000000000000000021771175724200100222410ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/ScaleRangeSpec.c000066400000000000000000000057621175724200100170310ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/ScaleRangeSpec.h000066400000000000000000000014241175724200100170250ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SessionArchiveSection.c000066400000000000000000000225061175724200100204570ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SessionArchiveSection.h000066400000000000000000000040761175724200100204660ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SessionNotesSection.c000066400000000000000000000226331175724200100201670ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SessionNotesSection.h000066400000000000000000000033621175724200100201720ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SessionPhaseSection.c000066400000000000000000000122761175724200100201410ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SessionPhaseSection.h000066400000000000000000000024471175724200100201450ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SessionTestSection.c000066400000000000000000000206411175724200100200130ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SessionTestSection.h000066400000000000000000000034121175724200100200150ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SimpleColour.c000066400000000000000000000072151175724200100166220ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SimpleColour.h000066400000000000000000000021211175724200100166160ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/StorageDataType.c000066400000000000000000000073551175724200100172520ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/StorageDataType.h000066400000000000000000000017761175724200100172600ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SystemModel.c000066400000000000000000000042071175724200100164500ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SystemModel.h000066400000000000000000000012701175724200100164520ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/SystemSpecEntry.c000066400000000000000000000043571175724200100173320ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/SystemSpecEntry.h000066400000000000000000000013531175724200100173300ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/TimeSampleArrayDescriptiveDataSection.c000066400000000000000000001014331175724200100235620ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/TimeSampleArrayDescriptiveDataSection.h000066400000000000000000000117071175724200100235730ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/TimeSampleArrayMeasuredDataSection.c000066400000000000000000000160651175724200100230540ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/TimeSampleArrayMeasuredDataSection.h000066400000000000000000000030701175724200100230510ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/UTF8String.c000066400000000000000000000112361175724200100161200ustar00rootroot00000000000000/*- * 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; } } biosig4c++-1.3.0/t240/UTF8String.h000066400000000000000000000024211175724200100161210ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/UnitCode.c000066400000000000000000000073301175724200100157150ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/UnitCode.h000066400000000000000000000014331175724200100157200ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/UnitsOfMeasurementCode.c000066400000000000000000000077061175724200100206020ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/UnitsOfMeasurementCode.h000066400000000000000000000016631175724200100206030ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/VirtualMedicalDeviceSection.c000066400000000000000000000155261175724200100215630ustar00rootroot00000000000000/* * 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 */ }; biosig4c++-1.3.0/t240/VirtualMedicalDeviceSection.h000066400000000000000000000031431175724200100215600ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/asn_SEQUENCE_OF.c000066400000000000000000000015601175724200100166370ustar00rootroot00000000000000/*- * 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); } } biosig4c++-1.3.0/t240/asn_SEQUENCE_OF.h000066400000000000000000000027351175724200100166510ustar00rootroot00000000000000/*- * 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 */ biosig4c++-1.3.0/t240/asn_SET_OF.c000066400000000000000000000032521175724200100160620ustar00rootroot00000000000000/*- * 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; } } biosig4c++-1.3.0/t240/asn_SET_OF.h000066400000000000000000000032331175724200100160660ustar00rootroot00000000000000/*- * 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 */ biosig4c++-1.3.0/t240/asn_application.h000066400000000000000000000027161175724200100173570ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/asn_codecs.h000066400000000000000000000065451175724200100163200ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/asn_codecs_prim.c000066400000000000000000000152311175724200100173320ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/asn_codecs_prim.h000066400000000000000000000031351175724200100173370ustar00rootroot00000000000000/*- * 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 */ biosig4c++-1.3.0/t240/asn_internal.h000066400000000000000000000067171175724200100166750ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/asn_system.h000066400000000000000000000064301175724200100163750ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/ber_decoder.c000066400000000000000000000167701175724200100164500ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/ber_decoder.h000066400000000000000000000037771175724200100164600ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/ber_tlv_length.c000066400000000000000000000073101175724200100171770ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/ber_tlv_length.h000066400000000000000000000027751175724200100172160ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/ber_tlv_tag.c000066400000000000000000000061561175724200100165000ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/ber_tlv_tag.h000066400000000000000000000034541175724200100165030ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_CHOICE.c000066400000000000000000000676461175724200100165450ustar00rootroot00000000000000/* * 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)); } } biosig4c++-1.3.0/t240/constr_CHOICE.h000066400000000000000000000025661175724200100165400ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_SEQUENCE.c000066400000000000000000001072361175724200100170110ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/constr_SEQUENCE.h000066400000000000000000000027641175724200100170160ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_SEQUENCE_OF.c000066400000000000000000000124051175724200100173660ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/constr_SEQUENCE_OF.h000066400000000000000000000016421175724200100173740ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_SET.c000066400000000000000000000565751175724200100162450ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/constr_SET.h000066400000000000000000000044131175724200100162320ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_SET_OF.c000066400000000000000000000557761175724200100166330ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/constr_SET_OF.h000066400000000000000000000020461175724200100166160ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constr_TYPE.c000066400000000000000000000033421175724200100163530ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/constr_TYPE.h000066400000000000000000000150561175724200100163650ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/constraints.c000066400000000000000000000042571175724200100165570ustar00rootroot00000000000000#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; } biosig4c++-1.3.0/t240/constraints.h000066400000000000000000000036571175724200100165670ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/der_encoder.c000066400000000000000000000116451175724200100164600ustar00rootroot00000000000000/*- * 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; } biosig4c++-1.3.0/t240/der_encoder.h000066400000000000000000000036311175724200100164610ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/fef.asn000066400000000000000000001446461175724200100153160ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/t240/per_decoder.c000066400000000000000000000047521175724200100164630ustar00rootroot00000000000000#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; } biosig4c++-1.3.0/t240/per_decoder.h000066400000000000000000000033001175724200100164540ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/per_encoder.c000066400000000000000000000071561175724200100164760ustar00rootroot00000000000000#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; } biosig4c++-1.3.0/t240/per_encoder.h000066400000000000000000000041771175724200100165030ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/per_opentype.c000066400000000000000000000216731175724200100167220ustar00rootroot00000000000000/* * 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; } biosig4c++-1.3.0/t240/per_opentype.h000066400000000000000000000012321175724200100167140ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/per_support.c000066400000000000000000000231231175724200100165630ustar00rootroot00000000000000/* * 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; } biosig4c++-1.3.0/t240/per_support.h000066400000000000000000000075411175724200100165760ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t240/sopen_fef_read.c000066400000000000000000000313671175724200100171510ustar00rootroot00000000000000/* 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: sandbox.c$ 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 "../biosig-dev.h" #ifdef WITH_FEF #include "SessionArchiveSection.h" #endif EXTERN_C int VERBOSE_LEVEL; EXTERN_C void sopen_fef_read(HDRTYPE* hdr) { #ifndef WITH_FEF B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "ASN1/FEF currently not supported"; #else 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(ASN1_t)); { ASN1_t *asn1info = (ASN1_t*)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",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 = SAS->demographics.characternamegroup->givenname.buf; char *str2 = SAS->demographics.characternamegroup->middlename.buf; char *str3 = 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,MAX_LENGTH_NAME); if (l1+l2+1 <= MAX_LENGTH_NAME) { hdr->Patient.Name[l1]=' '; strcpy(hdr->Patient.Name+1+l1,str2); } if (l1+l2+l3+2 <= MAX_LENGTH_NAME) { hdr->Patient.Name[l1+l2+1]=' '; strcpy(hdr->Patient.Name+2+l1+l2,str3); } } /********************************** 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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,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, 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "FEF: multiple phases 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)); int 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, 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(RTSADDS->unitlabelstring->buf); //******************* samplerate *****************/ unsigned long 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 = INF; } // TODO: MetricCalEntry, MetricCalType, // TODO: hc->LeadIdCode= 0; strcpy(hc->Transducer, ""); hc->bi = 0; hc->OnOff = 1; hc->Notch = -1; hc->Impedance = INF; 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",FsN,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",N); // asn_fprint(stdout, &asn_DEF_SessionPhaseSection, SPS); for (k=0; kmeasureddata.list.array[k]; // asn_fprint(stdout, &asn_DEF_RealTimeSampleArrayMeasuredDataSection, RTSAMDS); int n2,N2 = 0; hdr->SPR = 1; for (n2=0; n2 < MDS->realtimesas->list.count; n2++) { CHANNEL_TYPE *hc = hdr->CHANNEL+n2; RealTimeSampleArrayMeasuredDataSection_t *RTSAMDS = MDS->realtimesas->list.array[n2]; // if (VERBOSE_LEVEL>8) // 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 blk: %i #subblocks:%i subblocklength:%i/%i subblocksize:%i size:%i \n",n2,k,nrec,n,d,spr,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 (hc->SPR>9) { // FIXME: hdr->SPR = lcm(hdr->SPR,hc->SPR); } hc->OnOff = (hc->SPR>9); 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) { ASN1_t *asn1info = (ASN1_t*)hdr->aECG; ASN_STRUCT_FREE((*(asn_TYPE_descriptor_t *)(asn1info->pduType)), ((SessionArchiveSection_t*)asn1info->SAS)); free(hdr->aECG); hdr->aECG = NULL; } #endif } biosig4c++-1.3.0/t240/xer_decoder.c000066400000000000000000000210141175724200100164610ustar00rootroot00000000000000/* * 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; } } biosig4c++-1.3.0/t240/xer_decoder.h000066400000000000000000000064101175724200100164710ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/xer_encoder.c000066400000000000000000000030051175724200100164730ustar00rootroot00000000000000/*- * 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); } biosig4c++-1.3.0/t240/xer_encoder.h000066400000000000000000000032411175724200100165020ustar00rootroot00000000000000/*- * 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_ */ biosig4c++-1.3.0/t240/xer_support.c000066400000000000000000000126551175724200100166030ustar00rootroot00000000000000/* * 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; } biosig4c++-1.3.0/t240/xer_support.h000066400000000000000000000034241175724200100166020ustar00rootroot00000000000000/* * 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_ */ biosig4c++-1.3.0/t241/000077500000000000000000000000001175724200100140355ustar00rootroot00000000000000biosig4c++-1.3.0/t241/CENTS14271-2003.asn1000066400000000000000000001446501175724200100164700ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/t241/ISO11073-10404.asn1000066400000000000000000000036021175724200100163160ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/t241/ISO11073-10417.asn1000066400000000000000000000016721175724200100163270ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/t241/ISO11073-10471.asn1000066400000000000000000000175471175724200100163370ustar00rootroot00000000000000/* 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 biosig4c++-1.3.0/t241/ISO11073-20601.asn1000066400000000000000000002042421175724200100163210ustar00rootroot00000000000000/* 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 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 /* General This annex provides ASN.1 definitions relevant for the PHD protocol. Some are imported from other parts of the ISO/IEEE 11073 series 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 I. 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) -- -- 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 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 ::= INT-U16 { 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, 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 Std 11073-10101. The nomenclature consists of a set of partitions, where each partition covers a specific concept and has its own 16-bit codes. This means that a specific code is either 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 utilizes is called out within the 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 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, 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), 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), -- ECG extensions partition nom-part-phd-dm(128), -- Disease Mgmt (New, needs to be added) nom-part-phd-hf(129), -- Health & Fitness (New, needs to be added) nom-part-phd-ai(130), -- Aging Independently (New, needs to be added) nom-part-ret-code(255), -- return codes partition (New, needs to be added) nom-part-ext-nom(256), -- IDs of other nomenclatures and dictionaries nom-part-priv(1024) -- private partition } (0..65535) /* Attribute value assertion data type The Attribute Value Assertion (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, 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 data type (FLOAT-Type) The floating point type data type (FLOAT-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 E.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: 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 data type (SFLOAT-Type) The short floating point type data type (SFLOAT-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 ‎E.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 2’s complement form Special values are assigned to express: NaN (not a number) [exponent 0, mantissa +(2**11 -1)  0x07FF] NRes (not at this resolution) [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 [least significant bit (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 one microsecond 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 one hundredth of a second and can represent time -- adjustments of plus or minus 44505 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 hour time notion (i.e., from 0 to 23). The values in the structure shall be BCD-encoded (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-based 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 second if available } /* Note that the Agent defines the actual time resolution used (i.e. if the clock resolution is one second, then sec-fractions is always zero). Agents should have a resolution of one second or better. 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) } (0..65535) /* Attribute data types MDS attributes */ -- -- System Model 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 } -- -- Production Specification deals with serial numbers, part numbers, revisions, and etc. -- Note that an Agent may have multiple components so 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 EN ISO 15225 Nomenclature – -- Specification for a nomenclature system for medical devices for the purpose of regulatory data exchange, -- and was developed under the auspices of CEN TC257 SC1. -- -- Power State defines whether device is on battery or on mains. Upper bits define the charging state. -- PowerStatus ::= BIT STRING { onMains(0), onBattery(1), chargingFull(8), chargingTrickle(9), chargingOff(10) } (SIZE(16)) -- -- 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 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 IEEE 11073 documents and shall not be used for a different -- purpose. -- 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 a new msmt is just being taken (episodic) } (SIZE(16)) /* Numeric attributes */ -- -- NuObsValue (Numeric Observed Value) attribute 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 */ -- -- Sample Array Specification -- SaSpec ::= SEQUENCE { array-size INT-U16, -- number of samples per metric update period sample-type SampleType, flags SaFlags } -- -- Sample Type, 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 INTEGER -- defines significant bits in one sample { signed-samples(255)} (0..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 2s complement form. } -- -- SaFlags define additional wave form properties -- SaFlags ::= BIT STRING { 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 non-significant 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 -- non-significant bits in the field). } (SIZE(16)) -- -- 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 */ -- -- Enum-Observed-Value attribute -- 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 } -- The enumeration value data type 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 Std 11073-10201 are not included here as they are not -- relevant for PHD -- 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 */ -- -- Confirm-Mode attribute 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 */ -- -- Sample Algorithm describes how samples are derived, 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 */ -- -- Date/time to be set -- SetTimeInvoke ::= SEQUENCE { date-time AbsoluteTime, accuracy FLOAT-Type -- accounts for set time (e.g., 2min error); -- value is defined in seconds. This parameter is -- inherited from ISO/IEEE Std 11073-10201, but not -- used. Thus, it shall be zero (0) } -- -- The 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 don’t 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 } -- -- The SegmIdList selects PM-Segments by ID -- SegmIdList ::= SEQUENCE OF InstNumber -- -- The Time Range allows selection of PM-Segments by time period -- AbsTimeRange ::= SEQUENCE { from-time AbsoluteTime, to-time AbsoluteTime } -- -- The SegmentInfoList data type 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 */ -- -- Time protocol ID indicates the time protocols that are supported/used by the device -- TimeProtocolId ::= OID-Type -- from the nom-part-infrastruct nomenclature partition /* PHD protocol frame The following data type represents the top level message frame of the PHD 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 PDU [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 only be used in AareApdu 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 ::= BIT STRING { assoc-version1(0) -- This bit shall be set if version 1 of the association -- protocol is supported } (SIZE(32)) -- All unassigned " ProtocolVersion " bit values are reserved for future expansion and shall be set to zero. ProtocolVersion ::= BIT STRING { protocol-version1(0) -- This bit shall be set if version 1 of the data -- exchange protocol is supported } (SIZE(32)) -- --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 ::= BIT STRING { 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 } (SIZE(16)) -- All unassigned " NomenclatureVersion " bit values are reserved for future expansion and -- shall be set to zero. NomenclatureVersion ::= BIT STRING { -- values reference a specific nomenclature standard nom-version1(0) -- This bit shall be set if version 1 is supported } (SIZE(32)) -- All unassigned " FunctionalUnits " bit values are reserved for future expansion and shall be set to zero. FunctionalUnits ::= BIT STRING { fun-units-unidirectional(0), -- Reserved for future use. This bit shall be set if -- the Agent is uni-directional 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 } (SIZE(32)) -- All unassigned " SystemType " bit values are reserved for future expansion and shall be set to zero. SystemType ::= BIT STRING { sys-type-manager(0), sys-type-agent(8) } (SIZE(32)) 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 Std 11073-20101 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 Std 11073-20101. RoerErrorValue ::= INTEGER { -- no-such-object-instance is returned when referencing an illegal handle or when there -- 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, 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) -- The RejectResult shall be used when a message is rejected. 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 version, 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 -- Sub-partition NOTI (MDC_NOTI_*) event-info ANY DEFINED BY event-type } -- For event reports defined in this version, 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 -- Sub-partition NOTI (MDC_NOTI_*) event-reply-info ANY DEFINED BY event-type } /* Get service */ -- For GETs defined in this version, 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 GETs defined in this version, obj-handle shall either be 0 to represent the MDS object -- or a handle representing a PM-Store object. -- 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 the ISO/IEEE Std 11073-10101 document, communication -- nom-part-infrastruct partition, sub-partition 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 version, 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 that the returned value could differ from the requested value. SetResultSimple ::= SEQUENCE { obj-handle HANDLE, attribute-list AttributeList } /* Action service */ -- For actions defined in this version, 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, SegmSelection, or TrigSegmDataXferReq ActionArgumentSimple ::= SEQUENCE { obj-handle HANDLE, action-type OID-Type, -- From the nom-part-obj partition -- Sub-partition ACT (MDC_ACT_*) action-info-args ANY DEFINED BY action-type } -- For actions defined in this version, obj-handle shall either be 0 to represent the MDS object or -- a handle representing a PM-Store object. -- 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 -- Sub-partition 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/8ms time-resolution-abs-time INT-U16, -- Resolution of the Agent’s -- absolute time clock. -- 0 if unknown, otherwise -- the number of 1/100 seconds -- that elapse with each clock -- increment. For example, if an -- Agent has a clock that clicks at -- 1 second intervals, this value -- would be 100. time-resolution-rel-time INT-U16, -- Resolution of the Agent’s -- relative time clock. 0 if -- unknown, otherwise the number -- of 125 microseconds that elapse -- with each clock increment. For -- example, if an Agent has a clock -- that clicks at 1 second 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 -- the number of microseconds -- that elapse with each clock -- increment. For example, if an -- Agent has a clock that clicks -- at 1 second intervals, this value -- would be 1000000. } -- All unassigned " MdsTimeCapState " bit values are reserved for future expansion and shall be set to zero. MdsTimeCapState ::= BIT STRING { mds-time-capab-real-time-clock(0), -- device supports an internal RTC mds-time-capab-set-clock(1), -- device supports Set Time 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-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 is encouraged to -- set the time } (SIZE(16)) -- ************ -- A list of various regulatory and certification compliance items that the Agent claims adherence to. -- ************ 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 Std -- 11073-10201. It defines availability, periodicity and category of the measurement. -- If the metric corresponds to default values (no bits set) the attribute is not required. -- All unassigned " MetricSpecSmall " bit values are reserved for future expansion and shall be set to zero. -- MetricSpecSmall ::= BIT STRING { 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. } (SIZE(16)) -- This attribute is partly inherited from ISO/IEEE Std 11073-10201, but enhanced by -- value ms-struct::fix-comp-no. -- 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 Std 11073-10201 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 compoments/ 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 measurements -- that were sampled. There are two vectors: A) single person or multiple person and -- B) variable format fixed format, or grouped format leading 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 metric 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 INT-U16, 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 (i.e. if an Agent has two buttons -- to distinguish between two people, the Agent may use id 1 and 2 or 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 INT-U16, 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 -- Sub-partition 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 only used 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 Sub-partition -- 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 ::= BIT STRING { 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) } (SIZE(16)) 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 only be -- set 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 ::= BIT STRING { -- 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 } (SIZE(16)) -- 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, 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 -- Sub-partition 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 non-existant -- data-req-id. } (0..65535) /* Scanner Services See A.11.5 for MDS Services type definitions which are re-used 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 ::=BIT STRING { pmsc-var-no-of-segm(0), -- indicates that the number of PM-Segments -- contained in this PM-Store is dynamic and may -- change 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 pmsc-clear-segm-by-list-sup(7), -- clearing a list of segments is supported pmsc-clear-segm-by-time-sup(8), -- clearing segments by time range is supported 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-multi-person(12) -- The PM-Store supports PM-Segment for more -- than one person } (SIZE(16)) -- -- 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 ::= BIT STRING { 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) } (SIZE(16)) 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 ::= BIT STRING { 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 repeat the last event) sevtsta-manager-abort(12) -- sent in reply by Manager, Agent shall stop sending -- messages) } (SIZE(16)) 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 biosig4c++-1.3.0/t241/Makefile000066400000000000000000000221131175724200100154740ustar00rootroot00000000000000ASN_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 biosig4c++-1.3.0/tcl/000077500000000000000000000000001175724200100141255ustar00rootroot00000000000000biosig4c++-1.3.0/tcl/Makefile000066400000000000000000000011661175724200100155710ustar00rootroot00000000000000####### 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 biosig4c++-1.3.0/tcl/biosig.i000066400000000000000000000237671175724200100155720ustar00rootroot00000000000000/* % % $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, 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 PhysDim(PhysDimCode,PhysDimText) 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 { enum FileFormat TYPE; /* type of file format */ float VERSION; /* GDF version number */ const char* FileName; struct { size_t size[2]; /* size {rows, columns} of data block */ biosig_data_type* block; /* data block */ } data; uint32_t HeadLen; /* length of header in bytes */ uint16_t NS; /* number of channels */ uint32_t SPR; /* samples per block (when different sampling rates are used, this is the LCM(CHANNEL[..].SPR) */ int64_t NRec; /* number of records/blocks -1 indicates length is unknown. */ double SampleRate; /* Sampling rate */ uint8_t IPaddr[6]; /* IP address of recording device (if applicable) */ uint32_t LOC[4]; /* location of recording according to RFC1876 */ gdf_time T0; /* starttime of recording */ int16_t tzmin; /* time zone (minutes of difference to UTC */ #ifdef CHOLMOD_H cholmod_sparse *Calib; /* re-referencing matrix */ CHANNEL_TYPE *rerefCHANNEL; #endif /* Patient specific information */ struct { 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 */ 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 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[MAX_LENGTH_TECHNICIAN+1]; 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 */ uint32_t N; /* number of events */ uint16_t *TYP; /* defined at http://cvs.sourceforge.net/viewcvs.py/biosig/biosig/t200/eventcodes.txt?view=markup */ uint32_t *POS; /* starting position [in samples] */ uint32_t *DUR; /* duration [in samples] */ uint16_t *CHN; /* channel number; 0: all channels */ char **CodeDesc; /* describtion of "free text"/"user specific" events (encoded with TYP=0..255 */ 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 { // 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 */ 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; } 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 serror(); 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* PhysDim(uint16_t PhysDimCode, char *PhysDimText); void sort_eventtable(HDRTYPE *hdr); void convert2to4_eventtable(HDRTYPE *hdr); void convert4to2_eventtable(HDRTYPE *hdr); /* 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 hdr2ascii(HDRTYPE* hdr, int verbosity); %{ void hdr2ascii(HDRTYPE* hdr, int verbosity) { hdr2ascii(hdr, stdout, verbosity); } %} biosig4c++-1.3.0/test0/000077500000000000000000000000001175724200100144025ustar00rootroot00000000000000biosig4c++-1.3.0/test0/gztest.c000066400000000000000000000047171175724200100160770ustar00rootroot00000000000000/* $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); } */ } biosig4c++-1.3.0/test0/sandbox.c000066400000000000000000001405351175724200100162140ustar00rootroot00000000000000/* 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: sandbox.c,v 1.5 2009-04-16 20:19:17 schloegl Exp $ Copyright (C) 2008,2009,2010,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 . */ #include #include #include #include #include "../biosig-dev.h" // these functios are stubs #ifdef WITH_DCMTK #undef WITH_DICOM #undef WITH_GDCM extern "C" int sopen_dicom_read(HDRTYPE* hdr) { fprintf(stdout,"DCMTK is used to read dicom files.\n"); } #endif #ifdef WITH_HDF #include #endif #ifdef WITH_MATIO #include #endif #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 "gdcmReader.h" #include "gdcmImageReader.h" #include "gdcmWriter.h" #include "gdcmDataSet.h" #include #include extern "C" int sopen_dicom_read(HDRTYPE* hdr) { fprintf(stdout,"GDCM is used to read dicom files.\n"); gdcm::Reader r; const gdcm::DataElement *de; r.SetFileName( hdr->FileName ); if( !r.Read() ) return 1; gdcm::File &file = r.GetFile(); gdcm::FileMetaInformation &header = file.GetHeader(); if ( header.FindDataElement( gdcm::Tag(0x0002, 0x0013 ) ) ) const gdcm::DataElement &de = header.GetDataElement( gdcm::Tag(0x0002, 0x0013) ); gdcm::DataSet &ds = file.GetDataSet(); if ( header.FindDataElement( gdcm::Tag(0x0002, 0x0010 ) ) ) de = &header.GetDataElement( gdcm::Tag(0x0002, 0x0010) ); fprintf(stdout,"attr <0x0002,0x0010> len=%i\n",de->GetByteValue() ); /* { gdcm::Attribute<0x28,0x100> at; at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); if( at.GetValue() != 8 ) return 1; //at.SetValue( 32 ); //ds.Replace( at.GetAsDataElement() ); } { fprintf(stdout,"attr <0x0008,0x002a>\n"); gdcm::Attribute<0x0008,0x002a> at; fprintf(stdout,"attr <0x0008,0x002a>\n"); ds.GetDataElement( at.GetTag() ); fprintf(stdout,"attr <0x0008,0x002a>\n"); at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); fprintf(stdout,"DCM: [0008,002a]: %i %p\n",at.GetNumberOfValues(), at.GetValue()); } */ { fprintf(stdout,"attr <0x0008,0x0023>\n"); gdcm::Attribute<0x0008,0x0023> at; fprintf(stdout,"attr <0x0008,0x0023>\n"); ds.GetDataElement( at.GetTag() ); fprintf(stdout,"attr <0x0008,0x0023>\n"); // at.SetFromDataElement( ds.GetDataElement( at.GetTag() ) ); // fprintf(stdout,"DCM: [0008,0023]: %i %p\n",at.GetNumberOfValues(), at.GetValue()); } /* { 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; } */ } #endif #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]; } } for (k=0; kNS; 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); } #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 WITH_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 void sopen_heka(HDRTYPE* hdr, FILE *itx) { size_t count = hdr->HeadLen; if (hdr->TYPE==HEKA && hdr->VERSION > 0) { /* TODO: HEKA support of eventtable + support for resampling (needed by mexSLOAD, SigViewer, save2gdf) + support for selection of experiment,series,sweep,trace (needed by MMA) + make event-table aware of Sweep Selection - event-table -> MMA */ 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; ifseek(hdr,0,SEEK_SET); hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 1024); count = ifread(hdr->AS.Header, 1, 1024, hdr); while (!ifeof(hdr)) { hdr->AS.Header = (uint8_t*)realloc(hdr->AS.Header, 2*count); count += ifread(hdr->AS.Header+count, 1, count, hdr); } hdr->HeadLen = count; if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA 114\n"); 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)); double oTime; uint32_t nItems; if (hdr->FILE.LittleEndian) { oTime = lef64p(hdr->AS.Header+40); nItems = leu32p(hdr->AS.Header+48); } else { oTime = bef64p(hdr->AS.Header+40); nItems = beu32p(hdr->AS.Header+48); } if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA 121 nItems=%i\n",nItems); if (hdr->VERSION == 1) { Sizes.Rec.Root = 544; Sizes.Rec.Group = 128; Sizes.Rec.Series = 1120; Sizes.Rec.Sweep = 160; Sizes.Rec.Root = 296; } else if (hdr->VERSION == 2) for (k=0; k < min(12,nItems); k++) { if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA 131 nItems=%i\n",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,"HEKA #%i: <%s> [%i:+%i]\n",k,ext,start,length); if (!start) break; 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) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster format with more than 5 levels not supported;"; return; } if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA124 #%i Levels=%i\n",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,"HEKA #%i %i\n",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,"HEKA 989: \n"); // if (!Sizes) free(Sizes); Sizes=NULL; /* TODO: 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) and Label fit amoung 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; char flagModifiedTraceHeaders = 0; double t; size_t pos; if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA 995 %i %i \n",StartOfPulse, Sizes.Rec.Root); // 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,"HEKA 997\n"); t -= 1580970496; if (t<0) t += 4294967296; t += 9561652096; hdr->T0 = (uint64_t)ldexp(t/(24.0*60*60) + 584755, 32); // +datenum(1601,1,1)); hdr->SampleRate = 0.0; double *DT = NULL; // list of sampling intervals per channel hdr->SPR = 0; if (VERBOSE_LEVEL>7) fprintf(stdout,"HEKA 999 %p\n",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 t = *(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)); 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); 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; hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,EventN*sizeof(*hdr->EVENT.TYP)); hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,EventN*sizeof(*hdr->EVENT.POS)); if (hdr->EVENT.CHN != NULL && hdr->EVENT.DUR != NULL) { hdr->EVENT.CHN = (typeof(hdr->EVENT.CHN)) realloc(hdr->EVENT.CHN,EventN*sizeof(*hdr->EVENT.CHN)); hdr->EVENT.DUR = (typeof(hdr->EVENT.DUR)) realloc(hdr->EVENT.DUR,EventN*sizeof(*hdr->EVENT.DUR)); } } 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 hdr->EVENT.N++; } for (k3=0; k3NRec++; // increase number of sweeps uint32_t SPR = 0, spr = 0; // double t = *(double*)(hdr->AS.Header+pos+48); // time of sweep. TODO: this should be taken into account 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 (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; 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 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 YRange = (*(double*)(hdr->AS.Header+pos+128)); double YOffset = (*(double*)(hdr->AS.Header+pos+136)); 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; //int16 DigMax = (double)(int16_t)0x7fff; DigMin = (double)(int16_t)0x8000; break; case 1: gdftyp = 5; //int32 DigMax = (double)(int32_t)0x7fffffff; DigMin = (double)(int32_t)0x80000000; 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; B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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; } double Cal = 2 * YRange / (DigMax - DigMin); double Off = YOffset; double Fs = round(1.0 / dT); if (flagSweepSelected) { if (hdr->SampleRate <= 0.0) hdr->SampleRate = Fs; if (fabs(hdr->SampleRate - Fs) > 1e-9) { unsigned long DIV1 = 1, DIV2 = 1; unsigned long F0 = lcm(round(hdr->SampleRate), Fs); DIV1 = F0 / hdr->SampleRate; if (DIV1 > 1) { hdr->SPR *= DIV1; size_t n = 0; while (n < hdr->EVENT.N) hdr->EVENT.POS[n++] *= DIV1; } DIV2 = F0 / Fs; if (DIV2 > 1) spr *= DIV2; hdr->SampleRate = F0; } // samples per sweep if (k4==0) SPR = spr; else if (SPR != spr) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: number of samples amoung 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); if (ns >= hdr->NS) { hdr->NS = ns + 1; hdr->CHANNEL = (CHANNEL_TYPE*) realloc(hdr->CHANNEL, hdr->NS * sizeof(CHANNEL_TYPE)); CHANNEL_TYPE *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->Cal = 1.0; hc->Off = 0.0; hc->PhysDimCode = pdc; hc->OnOff = 1; hc->GDFTYP = gdftyp; hc->LeadIdCode = 0; hc->DigMin = DigMin; hc->DigMax = DigMax; // hc->PhysMax = PhysMax; // hc->PhysMin = PhysMin; hc->PhysMax = YRange+YOffset; hc->PhysMin = -YRange-YOffset; hc->Cal = Cal; hc->Off = Off; hc->TOffset = Toffset; /* TODO: fix remaining channel header */ /* LowPass, HighPass, Notch, Impedance, */ DT = (double*) realloc(DT, hdr->NS*sizeof(double)); DT[ns] = dT; } else { if (hdr->CHANNEL[ns].PhysMax < PhysMax) hdr->CHANNEL[ns].PhysMax = PhysMax; if (hdr->CHANNEL[ns].PhysMin > PhysMin) hdr->CHANNEL[ns].PhysMin = PhysMin; if (fabs(hdr->CHANNEL[ns].Cal - Cal) > 1e-9*Cal) flagModifiedTraceHeaders = 1; if (fabs(hdr->CHANNEL[ns].Off - Off) > 1e-9*Off) flagModifiedTraceHeaders = 1; if (hdr->CHANNEL[ns].GDFTYP < gdftyp) { hdr->CHANNEL[ns].GDFTYP = gdftyp; // OBSOLETE flagModifiedTraceHeaders = 1; } } if (YOffset) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: Yoffset is not zero."; } if (hdr->AS.Header[pos+220] != 1) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: ValidYRange not set."; } /* OBSOLETE if (hdr->CHANNEL[ns].GDFTYP != gdftyp) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: data types do not match."; } */ if ((pdc & 0xFFE0) != (hdr->CHANNEL[ns].PhysDimCode & 0xFFE0)) { fprintf(stdout, "Warning: Yunits do not match #%i,%f-%fHz\n",ns, DT[ns],dT); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: Yunits do not match."; } if ( abs( DT[ns] - dT) > 1e-9 * dT) { fprintf(stdout, "Warning sampling intervals do not match #%i,%f-%fHz\n",ns, DT[ns],dT); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: sampling intervals do not match."; } 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); pos += Sizes.Rec.Trace+4; // read number of children -- this should be 0 - ALWAYS; K5 = (*(uint32_t*)(hdr->AS.Header+pos-4)); if (K5) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster: Level 4 has some children."; } } // end loop k4 // if sweep is selected, add number of samples to counter if (flagSweepSelected) hdr->SPR += SPR; } // end loop k3 } // end loop k2 } // end loop k1 hdr->EVENT.SampleRate = hdr->SampleRate; #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; hdr->NRec = 1; hdr->AS.bpb = 0; for (k = 0; k < hdr->NS; k++) { CHANNEL_TYPE *hc = hdr->CHANNEL+k; #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; } if (B4C_ERRNUM) { #ifdef NO_BI if (BI) free(BI); #endif return; } void* tmpptr = realloc(hdr->AS.rawdata, hdr->NRec * hdr->AS.bpb); if (tmpptr!=NULL) hdr->AS.rawdata = (uint8_t*) tmpptr; else { B4C_ERRNUM = B4C_MEMORY_ALLOCATION_FAILED; B4C_ERRMSG = "memory allocation failed - not enough memory!"; return; } memset(hdr->AS.rawdata, 0xff, hdr->NRec * 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 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); } 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; k3AS.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 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 YRange = (*(double*)(hdr->AS.Header+pos+128)); double YOffset = (*(double*)(hdr->AS.Header+pos+136)); 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: B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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); #ifdef NO_BI #define _BI (BI[ns]) #else #define _BI (hc->bi) #endif if (itx) { uint32_t k5; double Cal = hdr->CHANNEL[ns].Cal; double Off = hdr->CHANNEL[ns].Off; 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); } // 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) { 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } else if (hdr->TYPE==HEKA) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "Heka/Patchmaster format has unsupported version number."; } } int sopen_zzztest(HDRTYPE* hdr) { if (hdr->TYPE==ITX) { fprintf(stdout,"Warning: support for ITX is very experimental\n"); /* while (~ifeof(hdr)) { hdr->Header = realloc(hdr->Header,count*2+1); count += ifread(hdr->Header+count,1,count,hdr); } hdr->Header[count]=0; */ char line[ITX_MAXLINELENGTH+1]; char flag = 0; double *data = NULL; size_t ns=0, NS=0, spr = 0, SPR = 0; size_t ngroup=0, nseries=0, nsweep=0; double deltaT = -INFINITY; hdr->SPR = 0; ifseek(hdr, 0, SEEK_SET); while (!ifeof(hdr)) { ifgets(line, ITX_MAXLINELENGTH, hdr); if (!strlen(line)) ; else if (!strncmp(line,"BEGIN",5)) { flag = 1; spr = 0; } else if (!strncmp(line,"END",3)) { flag = 0; hdr->CHANNEL[ns].SPR += spr; } else if (!strncmp(line,"X SetScale/P x,",15)) { strtok(line,","); strtok(NULL,","); 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)); } if (deltaT < 0.0) { deltaT = dur; hdr->SampleRate = 1.0 / dur; } else if (deltaT != dur) { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "different sampling rates not supported for ITX format"; } } 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; hdr->CHANNEL[ns].PhysDimCode = PhysDimCode(p); } ns++; } else if (!strncmp(line,"WAVES",5)) { // get properties of current trace, allocate new channel when needed IgorChanLabel(line+6, hdr, &ngroup, &nseries, &nsweep, &ns); CHANNEL_TYPE *hc = hdr->CHANNEL+ns; hc->OnOff = 1; hc->SPR = 0; hc->GDFTYP = 17; hc->DigMax = (double)(int16_t)(0x7fff); hc->DigMin = (double)(int16_t)(0x8000); hc->Cal = 1.0; 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; } else if (flag) spr++; } hdr->NS = ns; hdr->SPR = 0; for (ns=0; nsCHANNEL[ns].bi = SPR*sizeof(double); #endif SPR += hdr->CHANNEL[ns].SPR; if (hdr->SPR < hdr->CHANNEL[ns].SPR) hdr->SPR = hdr->CHANNEL[ns].SPR; hdr->CHANNEL[ns].SPR = 0; // reset } data = (double*)realloc(hdr->AS.rawdata, SPR*sizeof(double)); hdr->FILE.LittleEndian = (__BYTE_ORDER == __LITTLE_ENDIAN); // no swapping hdr->AS.rawdata = (uint8_t*) data; ifseek(hdr, 0, SEEK_SET); while (!ifeof(hdr)) { ifgets(line, ITX_MAXLINELENGTH, hdr); if (!strncmp(line,"BEGIN",5)) { flag = 1; spr = 0; } else if (!strncmp(line,"END",3)) { flag = 0; hdr->CHANNEL[ns].SPR += spr; } else if (!strncmp(line,"WAVES",5)) { // get properties of current trace IgorChanLabel(line+6, hdr, &ngroup, &nseries, &nsweep, &ns); } else if (flag) { #ifndef NO_BI data[hdr->CHANNEL[ns].SPR + hdr->CHANNEL[ns].bi + spr++] = atof(line); #else #error .bi not defined yet #endif } } hdr->NRec = 1; hdr->AS.first = 0; hdr->AS.length = 1; } 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); B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "UNIPRO not supported"; return(0); } #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-8,"UL",2)) c = leu32p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-8,"SL",2)) c = lei32p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-8,"US",2)) c = leu16p(hdr->AS.Header+pos); else if (!memcmp(hdr->AS.Header+pos-8,"SS",2)) c = lei16p(hdr->AS.Header+pos); else { B4C_ERRNUM = B4C_FORMAT_UNSUPPORTED; B4C_ERRMSG = "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_NAME); 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); 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 biosig4c++-1.3.0/test0/test.py000066400000000000000000000005451175724200100157370ustar00rootroot00000000000000import 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(); biosig4c++-1.3.0/test0/test01.m000066400000000000000000000036011175724200100157000ustar00rootroot00000000000000%%% 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); biosig4c++-1.3.0/test0/test_scp_decode.c000066400000000000000000000043561175724200100177050ustar00rootroot00000000000000/* $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 */ #ifdef _VCPP_DEF #define WIN32 #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); } biosig4c++-1.3.0/test0/test_ttl2trig.sh000077500000000000000000000002701175724200100175520ustar00rootroot00000000000000#!/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 biosig4c++-1.3.0/todo.txt000066400000000000000000000023661175724200100150600ustar00rootroot00000000000000 - Investigate whether and/or which rules should be applied to biosig This posting http://0pointer.de/blog/projects/libabc.html suggests to follow these rules: https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git;a=blob_plain;f=README - use of autotools: perhaps a good idea, if it simplifies Makefile, it should be done - avoid using global variables B4C_ERRNUM, B4C_ERRMSG for error handling VERBOSE_LEVEL for debugging messages Global holds table of Event code description - use prefix for exported functions sopen -> biosig_sopen sread -> biosig_sread seof swrite stell sseek ... - hide symbols of external libraries tinyxml - do not expose complex structures in the API, avoid fixed-sized strings in structs: CHANNEL_TYPE HDRTYPE use biosig_new(), biosig_free(), biosig_ref(), biosig_unref(), get(), set() instead - do not call exit() - functions should return int and negative numbers for errors - provide pkgconfig files ? - hide all internal symbols - provide logging/debugging, do not use stdout/stderr - make distcheck ? - use ./autogen.sh to bootstrap git repo ? - do not expose fixed size strings in api Label, Transducer, PhysDim , PID, RID, NAME, MANUF, TECHNICIAN biosig4c++-1.3.0/units.awk000077500000000000000000000023021175724200100152110ustar00rootroot00000000000000#!/usr/bin/awk -f # # Converts units.csv into units.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 = ","; 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]); } biosig4c++-1.3.0/win32/000077500000000000000000000000001175724200100143055ustar00rootroot00000000000000biosig4c++-1.3.0/win32/README000066400000000000000000000041441175724200100151700ustar00rootroot00000000000000Introduction: --------------- The directory ../biosig4c++/win{32,64} contains the pre-compiled (i.e. executable) file format converter SAVE2GDF for Windows platform. If you compile with -D=WITH_ZLIB, You need to copy zlib1.dll to the SYSTEM or the SYSTEM32 directory. File(s): ------------- README this file save2gdf.exe converter between various file formats. libbiosig.{a,dll} biosig library rec2bin.bat converts any raw data format into BIN-format an ASCII-header and Binary channels file bin2rec.bat converts the BIN formated data into any other format (default=GDF) sigviewer*.exe sigviewer - a standalone viewing and scoring software == Matlab binding == mexSLOAD.mexw32 load whole data file mexSOPEN.mexw32 read header information mexSSAVE.mexw32 save file == Mathematica == sload.exe mathlink/mathematica binding mySLOAD.nb mathematica notebook - how to use sload in Mathematica Compilation: ------------- The files were already compiled with MinGW and WITH_ZLIB for the i386-platform. # MinGW Crosscompiler on Linux for Windows Currently, only the file converter save2gdf is supported. - install mingw32 mingw32-binutils mingw32-runtime - If you want to have zlib-support - patch mingw include fil(e) with patch_mingw_avoid_io_h.diff - in Makefile add -D=WITH_ZLIB to MinGWDEF - adapt the path to mingw in Makefile - run the command make win32 # Windows + MinGW Only the file converter save2gdf is supported. - You need MinGW with g++ and make. - run the make command make -f Makefile.win32 save2gdf.exe Installation: ------------- Copy the files from the current directory into some directory 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 $Id$ Copyright (C) 2008,2009,2010,2012 Alois Schloegl This function is part of the "BioSig for C/C++" repository (BioSig4C++) at http://biosig.sf.net/ biosig4c++-1.3.0/win32/bin2rec.bat000077500000000000000000000013031175724200100163210ustar00rootroot00000000000000: Conversion of ASCII-Header and binary channels into REC(GDF,EDF) data format : : $Id: bin2rec.bat,v 1.1 2008-08-11 07:55:24 schloegl Exp $ : Copyright (C) 2008 Alois Schloegl : This file is part of the "BioSig for C/C++" repository : (biosig4c++) at http://biosig.sf.net/ echo off echo REC2BIN is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo BIN2REC Copyright 2008 Alois Schloegl 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 -f=GDF %1 %2 %3 %4 %5 %6 %7 biosig4c++-1.3.0/win32/byteswap.h000066400000000000000000000125111175724200100163140ustar00rootroot00000000000000/* Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library 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 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _BYTESWAP_H #define _BYTESWAP_H 1 /***** #include ********************************************/ #if defined __x86_64__ # define __WORDSIZE 64 # define __WORDSIZE_COMPAT32 1 #else # define __WORDSIZE 32 #endif /***** #include ********************************************/ /* Get the machine specific, optimized definitions. */ /* Swap bytes in 16 bit value. */ #define __bswap_constant_16(x) \ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) #if defined __GNUC__ && __GNUC__ >= 2 # define __bswap_16(x) \ (__extension__ \ ({ register unsigned short int __v, __x = (x); \ if (__builtin_constant_p (__x)) \ __v = __bswap_constant_16 (__x); \ else \ __asm__ ("rorw $8, %w0" \ : "=r" (__v) \ : "0" (__x) \ : "cc"); \ __v; })) #else /* This is better than nothing. */ # define __bswap_16(x) \ (__extension__ \ ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); })) #endif /* Swap bytes in 32 bit value. */ #define __bswap_constant_32(x) \ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) #if defined __GNUC__ && __GNUC__ >= 2 # if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__ \ || defined __pentiumpro__ || defined __pentium4__ \ || defined __k8__ || defined __athlon__ \ || defined __k6__ || defined __nocona__ \ || defined __core2__ || defined __geode__ \ || defined __amdfam10__) /* To swap the bytes in a word the i486 processors and up provide the `bswap' opcode. On i386 we have to use three instructions. */ # define __bswap_32(x) \ (__extension__ \ ({ register unsigned int __v, __x = (x); \ if (__builtin_constant_p (__x)) \ __v = __bswap_constant_32 (__x); \ else \ __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); \ __v; })) # else # define __bswap_32(x) \ (__extension__ \ ({ register unsigned int __v, __x = (x); \ if (__builtin_constant_p (__x)) \ __v = __bswap_constant_32 (__x); \ else \ __asm__ ("rorw $8, %w0;" \ "rorl $16, %0;" \ "rorw $8, %w0" \ : "=r" (__v) \ : "0" (__x) \ : "cc"); \ __v; })) # endif #else # define __bswap_32(x) \ (__extension__ \ ({ register unsigned int __x = (x); __bswap_constant_32 (__x); })) #endif #if defined __GNUC__ && __GNUC__ >= 2 /* Swap bytes in 64 bit value. */ # define __bswap_constant_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)) # if __WORDSIZE == 64 # define __bswap_64(x) \ (__extension__ \ ({ register unsigned long __v, __x = (x); \ if (__builtin_constant_p (__x)) \ __v = __bswap_constant_64 (__x); \ else \ __asm__ ("bswap %q0" : "=r" (__v) : "0" (__x)); \ __v; })) # else # define __bswap_64(x) \ (__extension__ \ ({ union { __extension__ unsigned long long int __ll; \ unsigned int __l[2]; } __w, __r; \ if (__builtin_constant_p (x)) \ __r.__ll = __bswap_constant_64 (x); \ else \ { \ __w.__ll = (x); \ __r.__l[0] = __bswap_32 (__w.__l[1]); \ __r.__l[1] = __bswap_32 (__w.__l[0]); \ } \ __r.__ll; })) # endif #endif #endif biosig4c++-1.3.0/win32/config.h000066400000000000000000000000001175724200100157110ustar00rootroot00000000000000biosig4c++-1.3.0/win32/getlogin.c000066400000000000000000000023221175724200100162600ustar00rootroot00000000000000/* 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. */ #include /* 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; } biosig4c++-1.3.0/win32/heka2itx.bat000077500000000000000000000013721175724200100165220ustar00rootroot00000000000000: Conversion of HEKA/Patchmaster data into ITX (Igor Text) format : : $Id$ : Copyright (C) 2008, 2011 Alois Schloegl : This file is part of the "BioSig for C/C++" repository : (biosig4c++) at http://biosig.sf.net/ echo off echo HEKA2ITX is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo HEKA2ITX Copyright 2008,2011 Alois Schloegl echo HEKA2ITX converts BIN data into other biosignal data formats (default GDF) 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 biosig4c++-1.3.0/win32/make.m000066400000000000000000000032241175724200100154010ustar00rootroot00000000000000% Matlab script to generate mexSLOAD.mexw32/mexSOPEN.mexw32 % % Requirements: % Windows % Matlab for Windows v7.1 or later % MinGW with gcc 4.x (tested with MinGWtdm) % gnumex available frome here http://gnumex.sourceforge.net/ % zlib 1.2.3.x % win32/libbiosig[.a/.lib] % either from % the pre-compiled binary from biosig4c++/win32/ % or % Windows % MinGW % mingw32-make -f Makefile.win32 libbiosig.a % or % Linux % mingw32 % make % make win32/libbiosig.lib % $Id$ % Copyright (C) 2009,2010 by Alois Schloegl % This is part of the BIOSIG-toolbox http://biosig.sf.net/ % LICENSE: % 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 % mex ..\mexSLOAD.cpp -l ..\win32\libbiosig.lib -l ..\win32\zlib\lib\zdll.lib -l C:\MinGW\lib\libws2_32.a mex -D=mexSOPEN ..\mexSLOAD.cpp -l ..\win32\libbiosig.lib -l ..\win32\zlib\lib\zdll.lib -l C:\MinGW\lib\libws2_32.a -output mexSOPEN biosig4c++-1.3.0/win32/patch_mingw_avoid_io_h.diff000066400000000000000000000011221175724200100216130ustar00rootroot00000000000000*** include/unistd.h.orig Mon Nov 22 10:54:17 2010 --- include/unistd.h Mon Nov 22 11:02:56 2010 *************** *** 9,15 **** #define _UNISTD_H #define __UNISTD_H_SOURCED__ 1 - #include #include #include --- 9,14 ---- *************** *** 36,41 **** --- 35,42 ---- int __cdecl __MINGW_NOTHROW usleep(useconds_t useconds); #endif /* Not __NO_ISOCEXT */ + _CRTIMP int __cdecl __MINGW_NOTHROW _chsize (int, long); + /* This is defined as a real library function to allow autoconf to verify its existence. */ int ftruncate(int, off_t); biosig4c++-1.3.0/win32/rec2bin.bat000077500000000000000000000013061175724200100163240ustar00rootroot00000000000000: Converts data into ascii-Header and each channel into a separate binary data file : : $Id: rec2bin.bat,v 1.1 2008-08-11 07:55:24 schloegl Exp $ : Copyright (C) 2008 Alois Schloegl : This file is part of the "BioSig for C/C++" repository : (biosig4c++) at http://biosig.sf.net/ echo off echo REC2BIN is part of BioSig http://biosig.sf.net and licensed with GNU GPL v3. echo REC2BIN Copyright 2008 Alois Schloegl 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 -f=BIN %1 %2 %3 %4 %5 %6 %7 biosig4c++-1.3.0/win32/strndup.c000066400000000000000000000020241175724200100161460ustar00rootroot00000000000000/* A replacement function, for systems that lack strndup. Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-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 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 . */ #include #include #include char * strndup (char const *s, size_t n) { size_t len = strnlen (s, n); char *new = malloc (len + 1); if (new == NULL) return NULL; new[len] = '\0'; return memcpy (new, s, len); } biosig4c++-1.3.0/win32/strnlen.c000066400000000000000000000021641175724200100161410ustar00rootroot00000000000000/* Find the length of STRING, but scan at most MAXLEN characters. Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc. Written by Simon Josefsson. 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 . */ #include #include /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char *string, size_t maxlen) { const char *end = memchr (string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; } biosig4c++-1.3.0/xgethostname.c000066400000000000000000000057711175724200100162270ustar00rootroot00000000000000/* 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 */