diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..74d19bc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,73 @@
+all:
+ (cd fmu10; $(MAKE))
+ (cd fmu20; $(MAKE))
+
+clean:
+ (cd fmu10; $(MAKE) clean)
+ (cd fmu20; $(MAKE) clean)
+
+distclean: clean
+ rm -f fmu10/bin/fmusim_cs* fmu10/bin/fmusim_me*
+ rm -f fmu20/bin/fmusim_cs* fmu20/bin/fmusim_me*
+ rm -rf fmu10/fmu
+ rm -rf fmu20/fmu
+ rm -rf fmuTmp*
+ rm -f *.csv
+ find . -name "*~" -exec rm {} \;
+ find . -name "#*~" -exec rm {} \;
+
+run_all: run_all_fmu10 run_all_fmu20
+
+# Run all the fmu10 fmus. Args are from run_all.bat
+run_all_fmu10:
+ fmu10/bin/fmusim_me fmu10/fmu/me/bouncingBall.fmu 4 0.01 0 c
+ mv result.csv result_me10_bouncingBall.csv
+ fmu10/bin/fmusim_cs fmu10/fmu/cs/bouncingBall.fmu 4 0.01 0 c
+ mv result.csv result_cs10_bouncingBall.csv
+ #
+ fmu10/bin/fmusim_me fmu10/fmu/me/vanDerPol.fmu 5 0.1 0 c
+ mv result.csv result_me10_vanDerPol.csv
+ fmu10/bin/fmusim_cs fmu10/fmu/cs/vanDerPol.fmu 5 0.1 0 c
+ mv result.csv result_cs10_vanDerPol.csv
+ #
+ fmu10/bin/fmusim_me fmu10/fmu/me/dq.fmu 1 0.1 0 c
+ mv result.csv result_me10_dq.csv
+ fmu10/bin/fmusim_cs fmu10/fmu/cs/dq.fmu 1 0.1 0 c
+ mv result.csv result_cs10_dq.csv
+ #
+ fmu10/bin/fmusim_me fmu10/fmu/me/inc.fmu 15 0.1 0 c
+ mv result.csv result_me10_inc.csv
+ fmu10/bin/fmusim_cs fmu10/fmu/cs/inc.fmu 15 0.1 0 c
+ mv result.csv result_cs10_inc.csv
+ #
+ fmu10/bin/fmusim_me fmu10/fmu/me/values.fmu 12 0.1 0 c
+ mv result.csv result_me10_values.csv
+ fmu10/bin/fmusim_cs fmu10/fmu/cs/values.fmu 12 0.1 0 c
+ mv result.csv result_cs10_values.csv
+
+# Run all the fmu20 fmus. Args are from run_all.bat
+run_all_fmu20:
+ fmu20/bin/fmusim_me fmu20/fmu/me/bouncingBall.fmu 4 0.01 0 c
+ mv result.csv result_me20_bouncingBall.csv
+ fmu20/bin/fmusim_cs fmu20/fmu/cs/bouncingBall.fmu 4 0.01 0 c
+ mv result.csv result_cs20_bouncingBall.csv
+ #
+ fmu20/bin/fmusim_me fmu20/fmu/me/vanDerPol.fmu 5 0.1 0 c
+ mv result.csv result_me20_vanDerPol.csv
+ fmu20/bin/fmusim_cs fmu20/fmu/cs/vanDerPol.fmu 5 0.1 0 c
+ mv result.csv result_cs20_vanDerPol.csv
+ #
+ fmu20/bin/fmusim_me fmu20/fmu/me/dq.fmu 1 0.1 0 c
+ mv result.csv result_me20_dq.csv
+ fmu20/bin/fmusim_cs fmu20/fmu/cs/dq.fmu 1 0.1 0 c
+ mv result.csv result_cs20_dq.csv
+ #
+ fmu20/bin/fmusim_me fmu20/fmu/me/inc.fmu 15 0.1 0 c
+ mv result.csv result_me20_inc.csv
+ fmu20/bin/fmusim_cs fmu20/fmu/cs/inc.fmu 15 0.1 0 c
+ mv result.csv result_cs20_inc.csv
+ #
+ fmu20/bin/fmusim_me fmu20/fmu/me/values.fmu 12 0.1 0 c
+ mv result.csv result_me20_values.csv
+ fmu20/bin/fmusim_cs fmu20/fmu/cs/values.fmu 12 0.1 0 c
+ mv result.csv result_cs20_values.csv
diff --git a/doc/FmuSdk_reference.html b/doc/FmuSdk_reference.html
new file mode 100644
index 0000000..d32cc71
--- /dev/null
+++ b/doc/FmuSdk_reference.html
@@ -0,0 +1,310 @@
+
+
+ Documentation for FMU SDK 2.0.6
+
+
+
+ FMU SDK 2.0.6
+ The FMU SDK is a free software development kit provided by
+ QTronic.
+ The FMU SDK demonstrates basic use of Functional Mockup Units (FMUs)
+ as defined by the following specifications
+
+ The FMI specifications are available from
+ here.
+ A short overview on FMUs and the FMI specification can be found
+ here.
+ The FMU SDK can also serve as starting point for developing applications
+ that create or process FMUs.
+
+ For each of the supported FMI versions (currently 1.0 and 2.0),
+ the FMU SDK contains the C sources for various discrete and continuous
+ FMU models, a batch file for compiling and zip'ing these models,
+ an XML parser for parsing the model description of an FMU and two simple
+ simulation programs that run a given FMU and output the result as CSV file.
+
+ The FMU SDK 2.0.6 can be downloaded from
+
+ http://www.qtronic.de/doc/fmusdk.zip.
+ For bug reports, questions or comments regarding the FMU SDK, please
+ mail to fmu@qtronic.de.
+ Questions or comments regarding the FMU specification should be sent to
+ info@functional-mockup-interface.org.
+
+
+
+
+Table of Contents
+
+
+
+
+The FMU SDK runs on all 32 bit and 64 bit Windows platforms, Linux and Mac OS X platforms.
+Download the FMU SDK from here,
+and unzip the file in a directory where you have write access.
+That directory is called FMUSDK_HOME below and may contain white space, such as in "C:\Program Files\fmusdk".
+The FMU SDK contains only the C sources of the FMUs and the simulators, not the executables,
+and should compile on all Windows, Linux and Mac OS X platforms.
+
+To build Windows 32 bit versions of all FMUs and simulators of the FMU SDK,
+double click on FMUSDK_HOME\install.bat.
+This should create fmus in FMUSDK_HOME\fmu10\fmu and FMUSDK_HOME\fmu20\fmu, as well as four
+simulators in FMUSDK_HOME\fmu10\bin and FMUSDK_HOME\fmu20\bin.
+
+To build Windows 64 bit versions of all FMUs and simulators, open a command shell and run "install -win64".
+This creates additional fmus in the x64 subdirectories in FMUSDK_HOME\fmu10\fmu and FMUSDK_HOME\fmu20\fmu, as well
+as additional simulators in FMUSDK_HOME\fmu10\bin\x64 and FMUSDK_HOME\fmu20\bin\x64. Building these 64 bit versions works also on 32 bit
+Windows platforms. Execution of the 64 bit simulators and fmus requires however a 64 bit version of Windows.
+
+Compilation using install.bat requires that you have installed one of
+Microsoft Visual Studio 2005 (VS8), 2008 (VS9), 2010 (VS10), 2012 (VS11), 2013 (VS12) or 2015 (VS14),
+for example the free Express Edition.
+To compile with another compiler, adapt the batch files.
+
+To build Linux or Mac OS X binaries of all FMUs and simulators, open command shell and run "make".
+The build requires that you have installed the C and C++ compilers, libexpat and libxml2 libraries.
+To install these dependencies on Linux you can use a package manager like
+"sudo apt install g++", "sudo apt install libexpat1-dev", "sudo apt install libxml2-dev".
+
+
+
+On Windows, to run a given FMU with one of the FMU simulators, open a command shell in
+directory FMUSDK_HOME and run the command fmusim
+
+fmusim simulator model.fmu [tEnd [h [loggingOn [csvSeparator]]]] [-win64]
+ simulator ..... cs10 or cs20 for co-simulation, me10 or me20 for model exchange, required
+ model.fmu ..... path to FMU, relative to current dir or absolute, required
+ tEnd .......... end time of simulation, optional, defaults to 1.0 sec
+ h ............. step size of simulation, optional, defaults to 0.1 sec
+ loggingOn ..... 1 to activate logging, optional, defaults to 0
+ csvSeparator .. c for comma, s for semicolon, optional, defaults to c
+ -win64 ........ to use a 64 bit simulator. By default, the 32 bit version is used
+
+This unzips the given FMU, parses the contained modelDescription.xml file, simulates
+the FMU from t=0 to t=tEnd, and writes the solution to file 'result.csv'. The file
+is written in CSV format (comma-separated values), using ';' to separate columns and
+using ',' instead of '.' as decimal dot to print floating-point numbers.
+To change the result file format, use the 'csv separator' option.
+The logging option activates logging of the simulated FMU. The FMI specification does
+not specify, what exactly to log in this case. However, when logging is switched on,
+the sample FMUs of the FMU SDK log every single FMU function call. Moreover, the
+fmusim simulators log every step and every event that is detected.
+
+Example command:
+
+> fmusim me10 fmu10/fmu/me/bouncingBall.fmu 5 0.1 0 s
+FMU Simulator: run 'fmu/bouncingBall.fmu' from t=0..5 with step size h=0.1, loggingOn=0, csv separator=';'
+Simulation from 0 to 5 terminated successful
+ steps ............ 51
+ fixed step size .. 0.1
+ time events ...... 0
+ state events ..... 14
+ step events ...... 0
+CSV file 'result.csv' written
+
+On Linux and Mac OS X get inspired by run_all
target inside FMUSDK_HOME\makefile.
+
+To plot the result file, open it e.g. in a spread-sheet program, such as Miscrosoft Excel or OpenOffice Calc.
+The figure below shows the result of the above simulation when plotted using OpenOffice Calc 3.0.
+Note that the height h of the bouncing ball as computed by fmusim becomes negative at the contact points,
+while the true solution of the FMU does actually not contain negative height values.
+This is not a limitation of the FMU, but of fmusim_me, which does not attempt to locate the
+exact time of state events.
+To improve this, either reduce the step size or add your own procedure for state-event location to fmusim_me.
+
+
+
+
+
+The FMU SDK contains a few sample FMUs
+
+ - dq the Dahlquist test function x = -k der(x)
+ - inc increments an integer counter every second
+ - values demonstrates the use of all scalar FMU data types
+ - vanDerPol ODE with 2 continuous states
+ - bouncingBall a bouncing ball that defines state events
+
+To implement your own FMU using the FMU SDK, create a directory - say xy - in FMUSDK_HOME\fmu10\src\models,
+or FMUSDK_HOME\fmu20\src\models, and create files xy.c there.
+The name of the new directory and of the .c file must be the same.
+The content of the .c file should follow the existing FMU examples, see the comments in the example code.
+For FMI 1.0, add also file modelDescription.xml.
+The XML file must not contain the <implementation>
+element and the closing <fmiModelDescription>
tag, because this is added automatically during build.
+For FMI 2.0, add file modelDescription_cs.xml and modelDescription_me.xml.
+When done with editing xy.c and the xml file (or files), open a command shell in FMUSDK_HOME\fmu10\src\models
+or in FMUSDK_HOME\fmu20\src\models to run the build command.
+
+On Windows, run command build_fmu me xy
to build an FMU for model-exchange, or
+build_fmu cs xy
to build an FMU for co-simulation.
+This should create a 32 bit FMU file xy.fmu in the corresponding subdirectory of FMUSDK_HOME\fmu10 or FMUSDK_HOME\fmu20.
+To build a 64-bit FMU, append option -win64 to the build command.
+
+For Linux and Mac OS X get inspired by all
target inside FMUSDK_HOME\fmu10\src\models\makefile and FMUSDK_HOME\fmu20\src\models\makefile.
+
+The figure below might help to create or process the XML file modelDescription.xml.
+It shows all XML elements (without attributes) used in the schema files (XSD) for
+model exchange and co-simulation 1.0. Notation: UML class diagram.
+
+
+For the case of FMU 2.0, see the corresponding overview figure in the
+FMI specification 2.0.
+
+
+
+
+- 07.02.2010, Version 1.0
+
+ - First release
+ - demo FMI for Model Exchange 1.0
+
+
+- 05.03.2010, Version 1.0.1
+
+ - demo FMI for Model Exchange 1.0
+ - bug-fix in fmuTemplate.c: fmiSetString now copies the passed
+ string argument and fmiFreeModelInstance frees all string copies
+
+ - fmusim/main.c: removed strerror(GetLastError()) from error messages
+
+
+
+- 22.08.2011, Version 1.0.2
+
+ - demo FMI for Model Exchange 1.0 and FMI for Co-Simulation 1.0
+ - added support for FMI for Co-Simulation 1.0 (standalone, no tool coupling)
+ - bug-fix in fmusim/main.c: added missing calls to fmiTerminate and fmiFreeModelInstance
+
+
+- 07.03.2014, Version 2.0.0
+
+ - demo FMI for versions 1.0 and 2.0 RC1
+ - added support for FMI 2.0 RC1
+ - added 64 bit support
+ - more compilers recognized by the installer
+
+
+- 16.04.2014, Version 2.0.1
+
+ - bug-fix in modelDescription.xml files: remove alias parameter, add derivative attribute to suitable variables
+ - bug-fix in fmu20/fmuTemplate.c: allow modules to request termination of simulation, better time event
+ handling, initialize() moved from fmiEnterInitialization to fmiExitInitialization, correct logging message
+ format in fmiDoStep
+ - bug-fix in Co-Simulation and Model Exchange simulators: set fmu location for 1.0 and fmu resources location
+ for 2.0 at instantiation of model
+
+
+- 02.07.2014, Version 2.0.2
+
+ - added support for FMI 2.0 RC2
+ - remove support for exporting FMI 2.0 RC1. Co-Simulation and Model Exchange simulators still support FMI 2.0 RC1
+ - fmi2setDebugLogging called with 0 categories, set all categories to loggingOn value
+
+
+- 27.08.2014, Version 2.0.3
+
+ - track all states of Model-exchange and Co-simulation and check the allowed calling sequences for FMI 2.0
+ - added explicit 'isTimeEvent' parameter for eventUpdate function in the user's models
+ - lazy computation of computed values
+ - bug-fix in modelDescription.xml: set initial attribute to local and output variables,
+ add unknown variables in <ModelStructure><InitialUnknowns> section
+
+
+- 20.10.2015, Version 2.0.4
+
+ - added explicit 'isNewEventIteration' parameter for eventUpdate function in the user's models
+ - bouncingBall example improvement: demonstrate tunable parameters, avoid 'fall through effect' due to numerical calculation
+ - bug-fix: allow to declare real variables and zero states in a model
+ - bug-fix: allow to simulate FMI 2.0 RC1 models
+ - bug-fix: remove memory leaks and compilation warnings
+
+
+- 8.12.2017, Version 2.0.5
+
+ - added support for Linux and Mac OS X. Thanks to Christopher Brooks (https://github.com/cxbrooks)
+ - added support for building with Microsoft VS 2015
+ - location of simulators changes to FMUSDK_HOME\fmu10\bin and FMUSDK_HOME\fmu20\bin instead of FMUSDK_HOME\bin
+ - fmu20 build define DISABLE_PREFIX to not use prefixed FMI functions
+ - fmu20 models declare source files in ModelDescription.xml
+ - log error messages regardless of loggingOn flag when functions return fmi2Error
+ - bug-fix: allow to declare real variables and zero states
+
+
+- 20.07.2018, Version 2.0.6
+
+ - update libxml2.lib to work for windows 7 and Visual Studio 2013 and 2015
+ - linux - give exec right to build_fmu.sh before executing it
+ - copy .h model files with rsync to avoid missing file error
+
+
+
+
+
+The FMU SDK is provided by QTronic under the
+BSD License.
+
+
+FMU SDK license
+
+Copyright © 2008-2018, QTronic GmbH. All rights reserved.
+The FmuSdk is licensed by the copyright holder under the BSD License
+(http://www.opensource.org/licenses/bsd-license.html):
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY QTRONIC GMBH "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 QTRONIC GMBH 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.
+
+
+
+The following additional tools are distributed with the FMU SDK under their
+respective licenses
+
+ - 7z 4.57
+ by Igor Pavlov. Used here to zip and unzip FMUs,
+ license is here.
+ - eXpat 2.0.1
+ by James Clark. Used here to parse the modelDescription.xml file of an FMU 1.0,
+ license is here.
+ - libxml,
+ the XML C parser and toolkit of Gnome.
+ Used here to parse the modelDescription.xml file of an FMU 2.0,
+ license is here.
+
+
+
+
+
diff --git a/doc/bouncingBallCalc.png b/doc/bouncingBallCalc.png
new file mode 100644
index 0000000..1944a62
Binary files /dev/null and b/doc/bouncingBallCalc.png differ
diff --git a/doc/fmu10-xml-schema.png b/doc/fmu10-xml-schema.png
new file mode 100644
index 0000000..772eaf6
Binary files /dev/null and b/doc/fmu10-xml-schema.png differ
diff --git a/doc/fmus.jpg b/doc/fmus.jpg
new file mode 100644
index 0000000..d7eec87
Binary files /dev/null and b/doc/fmus.jpg differ
diff --git a/doc/fmusdk_license.txt b/doc/fmusdk_license.txt
new file mode 100644
index 0000000..ecc306e
--- /dev/null
+++ b/doc/fmusdk_license.txt
@@ -0,0 +1,24 @@
+
+FMU SDK license
+
+Copyright © 2008-2018, QTronic GmbH. All rights reserved.
+The FmuSdk is licensed by the copyright holder under the BSD License
+(http://www.opensource.org/licenses/bsd-license.html):
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY QTRONIC GMBH "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 QTRONIC GMBH 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.
\ No newline at end of file
diff --git a/fmu10/Makefile b/fmu10/Makefile
new file mode 100644
index 0000000..23e6446
--- /dev/null
+++ b/fmu10/Makefile
@@ -0,0 +1,11 @@
+all:
+ (cd src; $(MAKE))
+
+clean:
+ (cd src; $(MAKE) clean)
+
+distclean: clean
+ rm -f bin/fmusim_cs* bin/fmusim_me*
+ rm -rf fmu
+ find . -name "*~" -exec rm {} \;
+ find . -name "#*~" -exec rm {} \;
diff --git a/fmu10/bin/7z.dll b/fmu10/bin/7z.dll
new file mode 100644
index 0000000..4d72895
Binary files /dev/null and b/fmu10/bin/7z.dll differ
diff --git a/fmu10/bin/7z.exe b/fmu10/bin/7z.exe
new file mode 100644
index 0000000..efb5fc9
Binary files /dev/null and b/fmu10/bin/7z.exe differ
diff --git a/fmu10/bin/License.txt b/fmu10/bin/License.txt
new file mode 100644
index 0000000..44802a8
--- /dev/null
+++ b/fmu10/bin/License.txt
@@ -0,0 +1,57 @@
+ 7-Zip
+ ~~~~~
+ License for use and distribution
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 7-Zip Copyright (C) 1999-2007 Igor Pavlov.
+
+ Licenses for files are:
+
+ 1) 7z.dll: GNU LGPL + unRAR restriction
+ 2) All other files: GNU LGPL
+
+ The GNU LGPL + unRAR restriction means that you must follow both
+ GNU LGPL rules and unRAR restriction rules.
+
+
+ Note:
+ You can use 7-Zip on any computer, including a computer in a commercial
+ organization. You don't need to register or pay for 7-Zip.
+
+
+ GNU LGPL information
+ --------------------
+
+ This 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.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ unRAR restriction
+ -----------------
+
+ The decompression engine for RAR archives was developed using source
+ code of unRAR program.
+ All copyrights to original unRAR code are owned by Alexander Roshal.
+
+ The license for original unRAR code has the following restriction:
+
+ The unRAR sources cannot be used to re-create the RAR compression algorithm,
+ which is proprietary. Distribution of modified unRAR sources in separate form
+ or as a part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+
+ --
+ Igor Pavlov
diff --git a/fmu10/src/Makefile b/fmu10/src/Makefile
new file mode 100644
index 0000000..e98385b
--- /dev/null
+++ b/fmu10/src/Makefile
@@ -0,0 +1,77 @@
+# fmusim makefile for Mac OS X
+
+EXECS = \
+ fmusim_cs \
+ fmusim_me
+
+# Build simulators for co_simulation and model_exchange and then build the .fmu files.
+all: $(EXECS)
+ (cd models; $(MAKE))
+
+clean:
+ rm -f $(EXECS)
+ rm -rf *.dSYM
+ rm -f cosimulation/fmusim_cs/*.o
+ rm -f model_exchange/fmusim_me/*.o
+ (cd models; $(MAKE) clean)
+
+# Sources shared between co-simulation and model exchange
+SHARED_SRCS = \
+ shared/sim_support.c \
+ shared/stack.c \
+ shared/xml_parser.c \
+ shared/xmlVersionParser.c
+
+# Dependencies for only fmusim_cs
+CO_SIMULATION_DEPS = \
+ co_simulation/fmusim_cs/main.c \
+ co_simulation/fmusim_cs/fmi_cs.h \
+ co_simulation/include/fmiFunctions.h \
+ co_simulation/include/fmiPlatformTypes.h
+
+# Dependencies for only fmusim_me
+MODEL_EXCHANGE_DEPS = \
+ model_exchange/fmusim_me/main.c \
+ model_exchange/fmusim_me/fmi_me.h \
+ model_exchange/include/fmiModelFunctions.h \
+ model_exchange/include/fmiModelTypes.h
+
+# Dependencies shared between both fmusim_cs and fmusim_me
+SHARED_DEPS = \
+ shared/expat.h \
+ shared/expat_external.h \
+ shared/sim_support.c \
+ shared/sim_support.h \
+ shared/stack.c \
+ shared/stack.h \
+ shared/xml_parser.c \
+ shared/xml_parser.h \
+ shared/xmlVersionParser.c \
+ shared/xmlVersionParser.h
+
+# Set CFLAGS to -m32 to build for linux32
+#CFLAGS=-m32
+# See also models/build_fmu
+
+# Create the binaries in the current directory because co_simulation already has
+# a directory named "fmusim_cs"
+fmusim_cs: $(CO_SIMULATION_DEPS) $(SHARED_DEPS) ../bin/
+ $(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION -DSTANDALONE_XML_PARSER \
+ -Ico_simulation/fmusim_cs -Ico_simulation/include \
+ -Ishared \
+ co_simulation/fmusim_cs/main.c $(SHARED_SRCS) \
+ -o $@ -lexpat -lxml2 -ldl
+ cp fmusim_cs ../bin/
+
+fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) ../bin/
+ $(CC) $(CFLAGS) -g -Wall -DSTANDALONE_XML_PARSER \
+ -Imodel_exchange/fmusim_me -Imodel_exchange/include -Ishared \
+ model_exchange/fmusim_me/main.c $(SHARED_SRCS) \
+ -o $@ -lexpat -lxml2 -ldl
+ cp fmusim_me ../bin/
+
+../bin/:
+ if [ ! -d ../bin ]; then \
+ echo "Creating ../bin/"; \
+ mkdir ../bin/; \
+ fi
\ No newline at end of file
diff --git a/fmu10/src/build_all.bat b/fmu10/src/build_all.bat
new file mode 100644
index 0000000..fb250e9
--- /dev/null
+++ b/fmu10/src/build_all.bat
@@ -0,0 +1,27 @@
+@echo off
+
+rem ------------------------------------------------------------
+rem This batch builds both simulators and all FMUs of the FmuSDK
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+rem First argument %1 should be empty for win32, and '-win64' for win64 build.
+call build_fmusim_me %1
+call build_fmusim_cs %1
+echo -----------------------------------------------------------
+echo Making the FMUs of the FmuSDK ...
+pushd models
+
+call build_fmu me dq %1
+call build_fmu me inc %1
+call build_fmu me values %1
+call build_fmu me vanDerPol %1
+call build_fmu me bouncingBall %1
+
+call build_fmu cs dq %1
+call build_fmu cs inc %1
+call build_fmu cs values %1
+call build_fmu cs vanDerPol %1
+call build_fmu cs bouncingBall %1
+
+popd
\ No newline at end of file
diff --git a/fmu10/src/build_fmusim_cs.bat b/fmu10/src/build_fmusim_cs.bat
new file mode 100644
index 0000000..e67a328
--- /dev/null
+++ b/fmu10/src/build_fmusim_cs.bat
@@ -0,0 +1,68 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds the FMU simulator fmusim_cs.exe
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+echo building fmusim_cs.exe - FMI for Co-Simulation 1.0
+echo -----------------------------------------------------------
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%1"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if not exist ..\bin\x64 mkdir ..\bin\x64
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+set SRC=fmusim_cs\main.c ..\shared\xmlVersionParser.c ..\shared\xml_parser.c ..\shared\stack.c ..\shared\sim_support.c
+set INC=/Iinclude /I../shared /Ifmusim_cs
+set OPTIONS=/DSTANDALONE_XML_PARSER /nologo /DFMI_COSIMULATION /DLIBXML_STATIC
+
+rem create fmusim_cs.exe in the fmusim_cs dir
+pushd co_simulation
+cl %SRC% %INC% %OPTIONS% /Fefmusim_cs.exe /link ..\shared\%x64%libexpatMT.lib /LIBPATH:..\shared\%x64%
+del *.obj
+popd
+if not exist co_simulation\fmusim_cs.exe goto compileError
+move /Y co_simulation\fmusim_cs.exe ..\bin\%x64%
+goto done
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of fmusim_cs.exe failed
+
+:done
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu10/src/build_fmusim_me.bat b/fmu10/src/build_fmusim_me.bat
new file mode 100644
index 0000000..e91fd42
--- /dev/null
+++ b/fmu10/src/build_fmusim_me.bat
@@ -0,0 +1,68 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds the FMU simulator fmusim_me.exe
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+echo building fmusim_me.exe - FMI for Model Exchange 1.0
+echo -----------------------------------------------------------
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%1"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if not exist ..\bin\x64 mkdir ..\bin\x64
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+set SRC=fmusim_me\main.c ..\shared\xmlVersionParser.c ..\shared\xml_parser.c ..\shared\stack.c ..\shared\sim_support.c
+set INC=/Iinclude /I../shared /Ifmusim_me
+set OPTIONS=/nologo /DSTANDALONE_XML_PARSER /DLIBXML_STATIC
+
+rem create fmusim_me.exe in the fmusim_me dir
+pushd model_exchange
+cl %SRC% %INC% %OPTIONS% /Fefmusim_me.exe /link ..\shared\%x64%libexpatMT.lib /LIBPATH:..\shared\%x64%
+del *.obj
+popd
+if not exist model_exchange\fmusim_me.exe goto compileError
+move /Y model_exchange\fmusim_me.exe ..\bin\%x64%
+goto done
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of fmusim_me.exe failed
+
+:done
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu10/src/co_simulation/fmusim_cs/fmi_cs.h b/fmu10/src/co_simulation/fmusim_cs/fmi_cs.h
new file mode 100644
index 0000000..f852683
--- /dev/null
+++ b/fmu10/src/co_simulation/fmusim_cs/fmi_cs.h
@@ -0,0 +1,93 @@
+/* -------------------------------------------------------------------------
+ * fmi_cs.h
+ * Function types for all function of the "FMI for Co-Simulation 1.0"
+ * and a struct with the corresponding function pointers.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#ifndef FMI_CS_H
+#define FMI_CS_H
+
+#ifdef _MSC_VER
+#include
+#define WINDOWS 1
+#if (_MSC_VER >= 1900)
+#pragma comment(lib, "legacy_stdio_definitions.lib")
+#endif /* _MSC_VER >= 1900 */
+#else /* _MSC_VER */
+#include
+#define WINDOWS 0
+#define TRUE 1
+#define FALSE 0
+#define min(a,b) (a>b ? b : a)
+#define HANDLE void *
+/* See http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html */
+#include
+#endif /* _MSC_VER */
+
+#include "fmiFunctions.h"
+#include "xml_parser.h"
+
+typedef const char* (*fGetTypesPlatform)();
+typedef const char* (*fGetVersion)();
+typedef fmiStatus (*fSetDebugLogging) (fmiComponent c, fmiBoolean loggingOn);
+typedef fmiStatus (*fSetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]);
+typedef fmiStatus (*fSetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);
+typedef fmiStatus (*fSetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);
+typedef fmiStatus (*fSetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]);
+typedef fmiStatus (*fGetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]);
+typedef fmiStatus (*fGetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);
+typedef fmiStatus (*fGetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);
+typedef fmiStatus (*fGetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]);
+typedef fmiComponent (*fInstantiateSlave) (fmiString instanceName, fmiString fmuGUID, fmiString fmuLocation,
+ fmiString mimeType, fmiReal timeout, fmiBoolean visible, fmiBoolean interactive,
+ fmiCallbackFunctions functions, fmiBoolean loggingOn);
+typedef fmiStatus (*fInitializeSlave)(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop);
+typedef fmiStatus (*fTerminateSlave) (fmiComponent c);
+typedef fmiStatus (*fResetSlave) (fmiComponent c);
+typedef void (*fFreeSlaveInstance)(fmiComponent c);
+typedef fmiStatus (*fSetRealInputDerivatives)(fmiComponent c, const fmiValueReference vr[], size_t nvr,
+ const fmiInteger order[], const fmiReal value[]);
+typedef fmiStatus (*fGetRealOutputDerivatives)(fmiComponent c, const fmiValueReference vr[], size_t nvr,
+ const fmiInteger order[], fmiReal value[]);
+typedef fmiStatus (*fCancelStep)(fmiComponent c);
+typedef fmiStatus (*fDoStep)(fmiComponent c, fmiReal currentCommunicationPoint,
+ fmiReal communicationStepSize, fmiBoolean newStep);
+typedef fmiStatus (*fGetStatus) (fmiComponent c, const fmiStatusKind s, fmiStatus* value);
+typedef fmiStatus (*fGetRealStatus) (fmiComponent c, const fmiStatusKind s, fmiReal* value);
+typedef fmiStatus (*fGetIntegerStatus)(fmiComponent c, const fmiStatusKind s, fmiInteger* value);
+typedef fmiStatus (*fGetBooleanStatus)(fmiComponent c, const fmiStatusKind s, fmiBoolean* value);
+typedef fmiStatus (*fGetStringStatus) (fmiComponent c, const fmiStatusKind s, fmiString* value);
+
+typedef struct {
+ ModelDescription* modelDescription;
+ HANDLE dllHandle;
+ fGetTypesPlatform getTypesPlatform;
+ fGetVersion getVersion;
+ fSetDebugLogging setDebugLogging;
+ fSetReal setReal;
+ fSetInteger setInteger;
+ fSetBoolean setBoolean;
+ fSetString setString;
+ fGetReal getReal;
+ fGetInteger getInteger;
+ fGetBoolean getBoolean;
+ fGetString getString;
+ fInstantiateSlave instantiateSlave;
+ fInitializeSlave initializeSlave;
+ fTerminateSlave terminateSlave;
+ fResetSlave resetSlave;
+ fFreeSlaveInstance freeSlaveInstance;
+ fGetRealOutputDerivatives getRealOutputDerivatives;
+ fSetRealInputDerivatives setRealInputDerivatives;
+ fDoStep doStep;
+ fCancelStep cancelStep;
+ fGetStatus getStatus;
+ fGetRealStatus getRealStatus;
+ fGetIntegerStatus getIntegerStatus;
+ fGetBooleanStatus getBooleanStatus;
+ fGetStringStatus getStringStatus;
+} FMU;
+
+#endif // FMI_CS_H
+
diff --git a/fmu10/src/co_simulation/fmusim_cs/main.c b/fmu10/src/co_simulation/fmusim_cs/main.c
new file mode 100644
index 0000000..e910f3f
--- /dev/null
+++ b/fmu10/src/co_simulation/fmusim_cs/main.c
@@ -0,0 +1,135 @@
+/* -------------------------------------------------------------------------
+ * main.c
+ * Implements simulation of a single FMU instance
+ * that implements the "FMI for Co-Simulation 1.0" interface.
+ * Command syntax: see printHelp()
+ * Simulates the given FMU from t = 0 .. tEnd with fixed step size h and
+ * writes the computed solution to file 'result.csv'.
+ * The CSV file (comma-separated values) may e.g. be plotted using
+ * OpenOffice Calc or Microsoft Excel.
+ * This progamm demonstrates basic use of an FMU.
+ * Real applications may use advanced master algorithms to cosimulate
+ * many FMUs, limit the numerical error using error estimation
+ * and back-stepping, provide graphical plotting utilities, debug support,
+ * and user control of parameter and start values, or perform a clean
+ * error handling (e.g. call freeSlaveInstance when a call to the fmu
+ * returns with error). All this is missing here.
+ *
+ * Revision history
+ * 22.08.2011 initial version released in FMU SDK 1.0.2
+ *
+ * Free libraries and tools used to implement this simulator:
+ * - header files from the FMU specification
+ * - eXpat 2.0.1 XML parser, see http://expat.sourceforge.net
+ * - 7z.exe 4.57 zip and unzip tool, see http://www.7-zip.org
+ * Author: Jakob Mauss
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include "fmi_cs.h"
+#include "sim_support.h"
+
+FMU fmu; // the fmu to simulate
+
+// simulate the given FMU from tStart = 0 to tEnd.
+static int simulate(FMU* fmu, double tEnd, double h, fmiBoolean loggingOn, char separator) {
+ double time;
+ double tStart = 0; // start time
+ const char* guid; // global unique id of the fmu
+ fmiComponent c; // instance of the fmu
+ fmiStatus fmiFlag; // return code of the fmu functions
+ char* fmuLocation = getTempFmuLocation(); // path to the fmu as URL, "file://C:\QTronic\sales"
+ const char* mimeType = "application/x-fmu-sharedlibrary"; // denotes tool in case of tool coupling
+ fmiReal timeout = 1000; // wait period in milli seconds, 0 for unlimited wait period"
+ fmiBoolean visible = fmiFalse; // no simulator user interface
+ fmiBoolean interactive = fmiFalse; // simulation run without user interaction
+ fmiCallbackFunctions callbacks; // called by the model during simulation
+ ModelDescription* md; // handle to the parsed XML file
+ int nSteps = 0;
+ double hh = h;
+ FILE* file;
+
+ // instantiate the fmu
+ md = fmu->modelDescription;
+ guid = getString(md, att_guid);
+ callbacks.logger = fmuLogger;
+ callbacks.allocateMemory = calloc;
+ callbacks.freeMemory = free;
+ callbacks.stepFinished = NULL; // fmiDoStep has to be carried out synchronously
+ c = fmu->instantiateSlave(getModelIdentifier(md), guid, fmuLocation, mimeType,
+ timeout, visible, interactive, callbacks, loggingOn);
+ free(fmuLocation);
+ if (!c) return error("could not instantiate model");
+
+ // open result file
+ if (!(file=fopen(RESULT_FILE, "w"))) {
+ printf("could not write %s because:\n", RESULT_FILE);
+ printf(" %s\n", strerror(errno));
+ return 0; // failure
+ }
+
+ // StopTimeDefined=fmiFalse means: ignore value of tEnd
+ fmiFlag = fmu->initializeSlave(c, tStart, fmiTrue, tEnd);
+ if (fmiFlag > fmiWarning) return error("could not initialize model");
+
+ // output solution for time t0
+ outputRow(fmu, c, tStart, file, separator, fmiTrue); // output column names
+ outputRow(fmu, c, tStart, file, separator, fmiFalse); // output values
+
+ // enter the simulation loop
+ time = tStart;
+ while (time < tEnd) {
+ // check not to pass over end time
+ if (h > tEnd - time) {
+ hh = tEnd - time;
+ }
+ fmiFlag = fmu->doStep(c, time, hh, fmiTrue);
+ if (fmiFlag != fmiOK) return error("could not complete simulation of the model");
+ time += hh;
+ outputRow(fmu, c, time, file, separator, fmiFalse); // output values for this step
+ nSteps++;
+ }
+
+ // end simulation
+ fmiFlag = fmu->terminateSlave(c);
+ fmu->freeSlaveInstance(c);
+ fclose(file);
+
+ // print simulation summary
+ printf("Simulation from %g to %g terminated successful\n", tStart, tEnd);
+ printf(" steps ............ %d\n", nSteps);
+ printf(" fixed step size .. %g\n", h);
+ return 1; // success
+}
+
+int main(int argc, char *argv[]) {
+ const char* fmuFileName;
+
+ // parse command line arguments and load the FMU
+ double tEnd = 1.0;
+ double h=0.1;
+ int loggingOn = 0;
+ char csv_separator = ',';
+ parseArguments(argc, argv, &fmuFileName, &tEnd, &h, &loggingOn, &csv_separator);
+ loadFMU(fmuFileName);
+
+ // run the simulation
+ printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c'\n",
+ fmuFileName, tEnd, h, loggingOn, csv_separator);
+ simulate(&fmu, tEnd, h, loggingOn, csv_separator);
+ printf("CSV file '%s' written\n", RESULT_FILE);
+
+ // release FMU
+#if WINDOWS
+ FreeLibrary(fmu.dllHandle);
+#else /* WINDOWS */
+ dlclose(fmu.dllHandle);
+#endif /* WINDOWS */
+ freeElement(fmu.modelDescription);
+ deleteUnzippedFiles();
+ return EXIT_SUCCESS;
+}
+
diff --git a/fmu10/src/co_simulation/include/fmiFunctions.h b/fmu10/src/co_simulation/include/fmiFunctions.h
new file mode 100644
index 0000000..bc08c36
--- /dev/null
+++ b/fmu10/src/co_simulation/include/fmiFunctions.h
@@ -0,0 +1,230 @@
+#ifndef fmiFunctions_h
+#define fmiFunctions_h
+
+/* This header file must be utilized when compiling a FMU.
+ It defines all functions of Co-Simulation Interface.
+ In order to have unique function names even if several FMUs
+ are compiled together (e.g. for embedded systems), every "real" function name
+ is constructed by prepending the function name by
+ "MODEL_IDENTIFIER" + "_" where "MODEL_IDENTIFIER" is the short name
+ of the model used as the name of the zip-file where the model is stored.
+ Therefore, the typical usage is:
+
+ #define MODEL_IDENTIFIER MyModel
+ #include "fmiFunctions.h"
+
+ As a result, a function that is defined as "fmiGetDerivatives" in this header file,
+ is actually getting the name "MyModel_fmiGetDerivatives".
+
+ Revisions:
+ - November 4, 2010: Adapted to specification text:
+ o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
+ o fmiInstantiateSlave: Argument GUID replaced by fmuGUID
+ Argument mimetype replaced by mimeType
+ o tabs replaced by spaces
+ - October 16, 2010: First public Version
+
+
+ Copyright © 2008-2010, MODELISAR consortium. All rights reserved.
+ This file is licensed by the copyright holders under the BSD License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+*/
+
+#include "fmiPlatformTypes.h"
+#include
+
+/* Export fmi functions on Windows */
+#ifdef _MSC_VER
+#define DllExport __declspec( dllexport )
+#else
+#define DllExport
+#endif
+
+/* Macros to construct the real function name
+ (prepend function name by MODEL_IDENTIFIER + "_") */
+
+#define fmiPaste(a,b) a ## b
+#define fmiPasteB(a,b) fmiPaste(a,b)
+#define fmiFullName(name) fmiPasteB(MODEL_IDENTIFIER, name)
+
+/***************************************************
+Common Functions
+****************************************************/
+#define fmiGetTypesPlatform fmiFullName(_fmiGetTypesPlatform)
+#define fmiGetVersion fmiFullName(_fmiGetVersion)
+#define fmiSetDebugLogging fmiFullName(_fmiSetDebugLogging)
+
+/*Data Exchange*/
+#define fmiSetReal fmiFullName(_fmiSetReal)
+#define fmiSetInteger fmiFullName(_fmiSetInteger)
+#define fmiSetBoolean fmiFullName(_fmiSetBoolean)
+#define fmiSetString fmiFullName(_fmiSetString)
+
+#define fmiGetReal fmiFullName(_fmiGetReal)
+#define fmiGetInteger fmiFullName(_fmiGetInteger)
+#define fmiGetBoolean fmiFullName(_fmiGetBoolean)
+#define fmiGetString fmiFullName(_fmiGetString)
+
+/***************************************************
+Functions for FMI for Co-Simulation
+****************************************************/
+#define fmiInstantiateSlave fmiFullName(_fmiInstantiateSlave)
+#define fmiInitializeSlave fmiFullName(_fmiInitializeSlave)
+#define fmiTerminateSlave fmiFullName(_fmiTerminateSlave)
+#define fmiResetSlave fmiFullName(_fmiResetSlave)
+#define fmiFreeSlaveInstance fmiFullName(_fmiFreeSlaveInstance)
+#define fmiSetRealInputDerivatives fmiFullName(_fmiSetRealInputDerivatives)
+#define fmiGetRealOutputDerivatives fmiFullName(_fmiGetRealOutputDerivatives)
+#define fmiDoStep fmiFullName(_fmiDoStep)
+#define fmiCancelStep fmiFullName(_fmiCancelStep)
+#define fmiGetStatus fmiFullName(_fmiGetStatus)
+#define fmiGetRealStatus fmiFullName(_fmiGetRealStatus)
+#define fmiGetIntegerStatus fmiFullName(_fmiGetIntegerStatus)
+#define fmiGetBooleanStatus fmiFullName(_fmiGetBooleanStatus)
+#define fmiGetStringStatus fmiFullName(_fmiGetStringStatus)
+
+/* Version number */
+#define fmiVersion "1.0"
+
+/* make sure all compiler use the same alignment policies for structures */
+#ifdef _MSC_VER
+#pragma pack(push,8)
+#endif
+
+/* Type definitions */
+ typedef enum {fmiOK,
+ fmiWarning,
+ fmiDiscard,
+ fmiError,
+ fmiFatal,
+ fmiPending} fmiStatus;
+
+ typedef void (*fmiCallbackLogger) (fmiComponent c, fmiString instanceName, fmiStatus status,
+ fmiString category, fmiString message, ...);
+ typedef void* (*fmiCallbackAllocateMemory)(size_t nobj, size_t size);
+ typedef void (*fmiCallbackFreeMemory) (void* obj);
+ typedef void (*fmiStepFinished) (fmiComponent c, fmiStatus status);
+
+ typedef struct {
+ fmiCallbackLogger logger;
+ fmiCallbackAllocateMemory allocateMemory;
+ fmiCallbackFreeMemory freeMemory;
+ fmiStepFinished stepFinished;
+ } fmiCallbackFunctions;
+
+ typedef struct {
+ fmiBoolean iterationConverged;
+ fmiBoolean stateValueReferencesChanged;
+ fmiBoolean stateValuesChanged;
+ fmiBoolean terminateSimulation;
+ fmiBoolean upcomingTimeEvent;
+ fmiReal nextEventTime;
+ } fmiEventInfo;
+
+/* reset alignment policy to the one set before reading this file */
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif
+
+/***************************************************
+Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files */
+ DllExport const char* fmiGetTypesPlatform();
+ DllExport const char* fmiGetVersion();
+
+ DllExport fmiStatus fmiSetDebugLogging (fmiComponent c, fmiBoolean loggingOn);
+
+/* Data Exchange Functions*/
+ DllExport fmiStatus fmiGetReal (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]);
+ DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);
+ DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);
+ DllExport fmiStatus fmiGetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]);
+
+ DllExport fmiStatus fmiSetReal (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]);
+ DllExport fmiStatus fmiSetInteger (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);
+ DllExport fmiStatus fmiSetBoolean (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);
+ DllExport fmiStatus fmiSetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]);
+
+/***************************************************
+Functions for FMI for Co-Simulation
+****************************************************/
+
+/* Creation and destruction of slave instances and setting debug status */
+ DllExport fmiComponent fmiInstantiateSlave(fmiString instanceName,
+ fmiString fmuGUID,
+ fmiString fmuLocation,
+ fmiString mimeType,
+ fmiReal timeout,
+ fmiBoolean visible,
+ fmiBoolean interactive,
+ fmiCallbackFunctions functions,
+ fmiBoolean loggingOn);
+
+ DllExport fmiStatus fmiInitializeSlave(fmiComponent c,
+ fmiReal tStart,
+ fmiBoolean StopTimeDefined,
+ fmiReal tStop);
+
+ DllExport fmiStatus fmiTerminateSlave (fmiComponent c);
+ DllExport fmiStatus fmiResetSlave (fmiComponent c);
+ DllExport void fmiFreeSlaveInstance(fmiComponent c);
+
+ DllExport fmiStatus fmiSetRealInputDerivatives(fmiComponent c,
+ const fmiValueReference vr[],
+ size_t nvr,
+ const fmiInteger order[],
+ const fmiReal value[]);
+
+ DllExport fmiStatus fmiGetRealOutputDerivatives(fmiComponent c,
+ const fmiValueReference vr[],
+ size_t nvr,
+ const fmiInteger order[],
+ fmiReal value[]);
+
+ DllExport fmiStatus fmiCancelStep(fmiComponent c);
+ DllExport fmiStatus fmiDoStep (fmiComponent c,
+ fmiReal currentCommunicationPoint,
+ fmiReal communicationStepSize,
+ fmiBoolean newStep);
+
+
+ typedef enum {fmiDoStepStatus,
+ fmiPendingStatus,
+ fmiLastSuccessfulTime} fmiStatusKind;
+
+ DllExport fmiStatus fmiGetStatus (fmiComponent c, const fmiStatusKind s, fmiStatus* value);
+ DllExport fmiStatus fmiGetRealStatus (fmiComponent c, const fmiStatusKind s, fmiReal* value);
+ DllExport fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value);
+ DllExport fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value);
+ DllExport fmiStatus fmiGetStringStatus (fmiComponent c, const fmiStatusKind s, fmiString* value);
+
+
+#endif // fmiFunctions_h
diff --git a/fmu10/src/co_simulation/include/fmiPlatformTypes.h b/fmu10/src/co_simulation/include/fmiPlatformTypes.h
new file mode 100644
index 0000000..e714496
--- /dev/null
+++ b/fmu10/src/co_simulation/include/fmiPlatformTypes.h
@@ -0,0 +1,73 @@
+#ifndef fmiPlatformTypes_h
+#define fmiPlatformTypes_h
+
+/* Standard header file to define the argument types of the
+ functions of the Model Execution Interface.
+ This header file must be utilized both by the model and
+ by the simulation engine.
+
+ Revisions:
+ - October 2010: First public Version
+
+
+ Copyright © 2008-2010, MODELISAR consortium. All rights reserved.
+ This file is licensed by the copyright holders under the BSD License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+*/
+
+/* Platform (combination of machine, compiler, operating system) */
+#define fmiPlatform "standard32"
+
+/* Type definitions of variables passed as arguments
+ Version "standard32" means:
+
+ fmiComponent : 32 bit pointer
+ fmiValueReference: 32 bit
+ fmiReal : 64 bit
+ fmiInteger : 32 bit
+ fmiBoolean : 8 bit
+ fmiString : 32 bit pointer
+
+*/
+ typedef void* fmiComponent;
+ typedef unsigned int fmiValueReference;
+ typedef double fmiReal ;
+ typedef int fmiInteger;
+ typedef char fmiBoolean;
+ typedef const char* fmiString ;
+
+/* Values for fmiBoolean */
+#define fmiTrue 1
+#define fmiFalse 0
+
+/* Undefined value for fmiValueReference (largest unsigned int value) */
+#define fmiUndefinedValueReference (fmiValueReference)(-1)
+
+#endif
diff --git a/fmu10/src/model_exchange/fmusim_me/fmi_me.h b/fmu10/src/model_exchange/fmusim_me/fmi_me.h
new file mode 100644
index 0000000..058e78d
--- /dev/null
+++ b/fmu10/src/model_exchange/fmusim_me/fmi_me.h
@@ -0,0 +1,104 @@
+/* -------------------------------------------------------------------------
+ * fmi_me.h
+ * Function types for all function of the "FMI for Model Exchange 1.0"
+ * and a struct with the corresponding function pointers.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#ifndef FMI_ME_H
+#define FMI_ME_H
+
+#ifdef _MSC_VER
+#include
+#define WINDOWS 1
+#if (_MSC_VER >= 1900)
+#pragma comment(lib, "legacy_stdio_definitions.lib")
+#endif /* _MSC_VER >= 1900 */
+#else /* _MSC_VER */
+#include
+#define WINDOWS 0
+#define TRUE 1
+#define FALSE 0
+#define min(a,b) (a>b ? b : a)
+#define HANDLE void *
+/* See http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html */
+#include
+#endif /* _MSC_VER */
+
+#include "fmiModelFunctions.h"
+#include "xml_parser.h"
+
+typedef const char* (*fGetModelTypesPlatform)();
+typedef const char* (*fGetVersion)();
+typedef fmiComponent (*fInstantiateModel)(fmiString instanceName, fmiString GUID,
+ fmiCallbackFunctions functions, fmiBoolean loggingOn);
+typedef void (*fFreeModelInstance) (fmiComponent c);
+typedef fmiStatus (*fSetDebugLogging) (fmiComponent c, fmiBoolean loggingOn);
+typedef fmiStatus (*fSetTime) (fmiComponent c, fmiReal time);
+typedef fmiStatus (*fSetContinuousStates)(fmiComponent c, const fmiReal x[], size_t nx);
+typedef fmiStatus (*fCompletedIntegratorStep)(fmiComponent c, fmiBoolean* callEventUpdate);
+typedef fmiStatus (*fSetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]);
+typedef fmiStatus (*fSetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);
+typedef fmiStatus (*fSetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);
+typedef fmiStatus (*fSetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]);
+typedef fmiStatus (*fInitialize)(fmiComponent c, fmiBoolean toleranceControlled,
+ fmiReal relativeTolerance, fmiEventInfo* eventInfo);
+typedef fmiStatus (*fGetDerivatives) (fmiComponent c, fmiReal derivatives[] , size_t nx);
+typedef fmiStatus (*fGetEventIndicators)(fmiComponent c, fmiReal eventIndicators[], size_t ni);
+typedef fmiStatus (*fGetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]);
+typedef fmiStatus (*fGetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);
+typedef fmiStatus (*fGetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);
+typedef fmiStatus (*fGetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]);
+typedef fmiStatus (*fEventUpdate) (fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo);
+typedef fmiStatus (*fGetContinuousStates) (fmiComponent c, fmiReal states[], size_t nx);
+typedef fmiStatus (*fGetNominalContinuousStates)(fmiComponent c, fmiReal x_nominal[], size_t nx);
+typedef fmiStatus (*fGetStateValueReferences) (fmiComponent c, fmiValueReference vrx[], size_t nx);
+typedef fmiStatus (*fTerminate) (fmiComponent c);
+
+typedef struct {
+ ModelDescription* modelDescription;
+ HANDLE dllHandle;
+ fGetModelTypesPlatform getModelTypesPlatform;
+ fGetVersion getVersion;
+ fInstantiateModel instantiateModel;
+ fFreeModelInstance freeModelInstance;
+ fSetDebugLogging setDebugLogging;
+ fSetTime setTime;
+ fSetContinuousStates setContinuousStates;
+ fCompletedIntegratorStep completedIntegratorStep;
+ fSetReal setReal;
+ fSetInteger setInteger;
+ fSetBoolean setBoolean;
+ fSetString setString;
+ fInitialize initialize;
+ fGetDerivatives getDerivatives;
+ fGetEventIndicators getEventIndicators;
+ fGetReal getReal;
+ fGetInteger getInteger;
+ fGetBoolean getBoolean;
+ fGetString getString;
+ fEventUpdate eventUpdate;
+ fGetContinuousStates getContinuousStates;
+ fGetNominalContinuousStates getNominalContinuousStates;
+ fGetStateValueReferences getStateValueReferences;
+ fTerminate terminate;
+/*
+ fInstantiateSlave instantiateSlave;
+ fInitializeSlave initializeSlave;
+ fTerminateSlave terminateSlave;
+ fResetSlave resetSlave;
+ fFreeSlaveInstance freeSlaveInstance;
+ fGetRealOutputDerivatives getRealOutputDerivatives;
+ fSetRealInputDerivatives setRealInputDerivatives;
+ fDoStep doStep;
+ fCancelStep cancelStep;
+ fGetStatus getStatus;
+ fGetRealStatus getRealStatus;
+ fGetIntegerStatus getIntegerStatus;
+ fGetBooleanStatus getBooleanStatus;
+ fGetStringStatus getStringStatus;
+*/
+} FMU;
+
+#endif // FMI_ME_H
+
diff --git a/fmu10/src/model_exchange/fmusim_me/main.c b/fmu10/src/model_exchange/fmusim_me/main.c
new file mode 100644
index 0000000..cfcbdfb
--- /dev/null
+++ b/fmu10/src/model_exchange/fmusim_me/main.c
@@ -0,0 +1,244 @@
+/* -------------------------------------------------------------------------
+ * main.c
+ * Implements simulation of a single FMU instance using the forward Euler
+ * method for numerical integration.
+ * Command syntax: see printHelp()
+ * Simulates the given FMU from t = 0 .. tEnd with fixed step size h and
+ * writes the computed solution to file 'result.csv'.
+ * The CSV file (comma-separated values) may e.g. be plotted using
+ * OpenOffice Calc or Microsoft Excel.
+ * This program demonstrates basic use of an FMU.
+ * Real applications may use advanced numerical solvers instead, means to
+ * exactly locate state events in time, graphical plotting utilities, support
+ * for co-execution of many FMUs, stepping and debug support, user control
+ * of parameter and start values etc.
+ * All this is missing here.
+ *
+ * Revision history
+ * 07.02.2010 initial version released in FMU SDK 1.0
+ * 05.03.2010 bug fix: removed strerror(GetLastError()) from error messages
+ * 11.06.2010 bug fix: replaced win32 API call to OpenFile in getFmuPath
+ * which restricted path length to FMU to 128 chars. New limit is MAX_PATH.
+ * 15.07.2010 fixed wrong label in xml parser: deault instead of default
+ * 13.12.2010 added check for undefined 'declared type' to xml parser
+ * 31.07.2011 bug fix: added missing freeModelInstance(c)
+ * 31.07.2011 bug fix: added missing terminate(c)
+ * 30.08.2012 fixed access violation in xmlParser after reporting unknown attribute name
+ *
+ * Free libraries and tools used to implement this simulator:
+ * - header files from the FMU specification
+ * - eXpat 2.0.1 XML parser, see http://expat.sourceforge.net
+ * - 7z.exe 4.57 zip and unzip tool, see http://www.7-zip.org
+ * Author: Jakob Mauss
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include //strerror()
+#include "fmi_me.h"
+#include "sim_support.h"
+
+FMU fmu; // the fmu to simulate
+
+// simulate the given FMU using the forward euler method.
+// time events are processed by reducing step size to exactly hit tNext.
+// state events are checked and fired only at the end of an Euler step.
+// the simulator may therefore miss state events and fires state events typically too late.
+static int simulate(FMU* fmu, double tEnd, double h, fmiBoolean loggingOn, char separator) {
+ int i, n;
+ double dt, tPre;
+ fmiBoolean timeEvent, stateEvent, stepEvent;
+ double time;
+ int nx; // number of state variables
+ int nz; // number of state event indicators
+ double *x; // continuous states
+ double *xdot; // the crresponding derivatives in same order
+ double *z = NULL; // state event indicators
+ double *prez = NULL; // previous values of state event indicators
+ fmiEventInfo eventInfo; // updated by calls to initialize and eventUpdate
+ ModelDescription* md; // handle to the parsed XML file
+ const char* guid; // global unique id of the fmu
+ fmiCallbackFunctions callbacks; // called by the model during simulation
+ fmiComponent c; // instance of the fmu
+ fmiStatus fmiFlag; // return code of the fmu functions
+ fmiReal t0 = 0; // start time
+ fmiBoolean toleranceControlled = fmiFalse;
+ int nSteps = 0;
+ int nTimeEvents = 0;
+ int nStepEvents = 0;
+ int nStateEvents = 0;
+ FILE* file;
+
+ // instantiate the fmu
+ md = fmu->modelDescription;
+ guid = getString(md, att_guid);
+ callbacks.logger = fmuLogger;
+ callbacks.allocateMemory = calloc;
+ callbacks.freeMemory = free;
+ c = fmu->instantiateModel(getModelIdentifier(md), guid, callbacks, loggingOn);
+ if (!c) return error("could not instantiate model");
+
+ // allocate memory
+ nx = getNumberOfStates(md);
+ nz = getNumberOfEventIndicators(md);
+ x = (double *) calloc(nx, sizeof(double));
+ xdot = (double *) calloc(nx, sizeof(double));
+ if (nz>0) {
+ z = (double *) calloc(nz, sizeof(double));
+ prez = (double *) calloc(nz, sizeof(double));
+ }
+ if ((!x || !xdot) || (nz>0 && (!z || !prez))) return error("out of memory");
+
+ // open result file
+ if (!(file=fopen(RESULT_FILE, "w"))) {
+ printf("could not write %s because:\n", RESULT_FILE);
+ printf(" %s\n", strerror(errno));
+ free(x);
+ free(xdot);
+ free(z);
+ free(prez);
+
+ return 0; // failure
+ }
+
+ // set the start time and initialize
+ time = t0;
+ fmiFlag = fmu->setTime(c, t0);
+ if (fmiFlag > fmiWarning) return error("could not set time");
+ fmiFlag = fmu->initialize(c, toleranceControlled, t0, &eventInfo);
+ if (fmiFlag > fmiWarning) return error("could not initialize model");
+ if (eventInfo.terminateSimulation) {
+ printf("model requested termination at init");
+ tEnd = time;
+ }
+
+ // output solution for time t0
+ outputRow(fmu, c, t0, file, separator, fmiTrue); // output column names
+ outputRow(fmu, c, t0, file, separator, fmiFalse); // output values
+
+ // enter the simulation loop
+ while (time < tEnd) {
+ // get current state and derivatives
+ fmiFlag = fmu->getContinuousStates(c, x, nx);
+ if (fmiFlag > fmiWarning) return error("could not retrieve states");
+ fmiFlag = fmu->getDerivatives(c, xdot, nx);
+ if (fmiFlag > fmiWarning) return error("could not retrieve derivatives");
+
+ // advance time
+ tPre = time;
+ time = min(time+h, tEnd);
+ timeEvent = eventInfo.upcomingTimeEvent && eventInfo.nextEventTime < time;
+ if (timeEvent) time = eventInfo.nextEventTime;
+ dt = time - tPre;
+ fmiFlag = fmu->setTime(c, time);
+ if (fmiFlag > fmiWarning) error("could not set time");
+
+ // perform one step
+ for (i=0; isetContinuousStates(c, x, nx);
+ if (fmiFlag > fmiWarning) return error("could not set states");
+ if (loggingOn) printf("Step %d to t=%.16g\n", nSteps, time);
+
+ // Check for step event, e.g. dynamic state selection
+ fmiFlag = fmu->completedIntegratorStep(c, &stepEvent);
+ if (fmiFlag > fmiWarning) return error("could not complete integrator step");
+
+ // Check for state event
+ for (i=0; igetEventIndicators(c, z, nz);
+ if (fmiFlag > fmiWarning) return error("could not retrieve event indicators");
+ stateEvent = FALSE;
+ for (i=0; i0 && z[i]<0) ? "-\\-" : "-/-", i, time);
+ }
+ if (stepEvent) {
+ nStepEvents++;
+ if (loggingOn) printf("step event at t=%.16g\n", time);
+ }
+
+ // event iteration in one step, ignoring intermediate results
+ fmiFlag = fmu->eventUpdate(c, fmiFalse, &eventInfo);
+ if (fmiFlag > fmiWarning) return error("could not perform event update");
+
+ // terminate simulation, if requested by the model
+ if (eventInfo.terminateSimulation) {
+ printf("model requested termination at t=%.16g\n", time);
+ break; // success
+ }
+
+ // check for change of value of states
+ if (eventInfo.stateValuesChanged && loggingOn) {
+ printf("state values changed at t=%.16g\n", time);
+ }
+
+ // check for selection of new state variables
+ if (eventInfo.stateValueReferencesChanged && loggingOn) {
+ printf("new state variables selected at t=%.16g\n", time);
+ }
+
+ } // if event
+ outputRow(fmu, c, time, file, separator, fmiFalse); // output values for this step
+ nSteps++;
+ } // while
+
+ // cleanup
+ if(! eventInfo.terminateSimulation) fmu->terminate(c);
+ fmu->freeModelInstance(c);
+ fclose(file);
+ if (x!=NULL) free(x);
+ if (xdot!= NULL) free(xdot);
+ if (z!= NULL) free(z);
+ if (prez!= NULL) free(prez);
+
+ // print simulation summary
+ printf("Simulation from %g to %g terminated successful\n", t0, tEnd);
+ printf(" steps ............ %d\n", nSteps);
+ printf(" fixed step size .. %g\n", h);
+ printf(" time events ...... %d\n", nTimeEvents);
+ printf(" state events ..... %d\n", nStateEvents);
+ printf(" step events ...... %d\n", nStepEvents);
+
+ return 1; // success
+}
+
+int main(int argc, char *argv[]) {
+ const char* fmuFileName;
+
+ // parse command line arguments and load the FMU
+ double tEnd = 1.0;
+ double h=0.1;
+ int loggingOn = 0;
+ char csv_separator = ',';
+ parseArguments(argc, argv, &fmuFileName, &tEnd, &h, &loggingOn, &csv_separator);
+ loadFMU(fmuFileName);
+
+ // run the simulation
+ printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c'\n",
+ fmuFileName, tEnd, h, loggingOn, csv_separator);
+ simulate(&fmu, tEnd, h, loggingOn, csv_separator);
+ printf("CSV file '%s' written\n", RESULT_FILE);
+
+ // release FMU
+#if WINDOWS
+ FreeLibrary(fmu.dllHandle);
+#else /* WINDOWS */
+ dlclose(fmu.dllHandle);
+#endif /* WINDOWS */
+ freeElement(fmu.modelDescription);
+ deleteUnzippedFiles();
+ return EXIT_SUCCESS;
+}
diff --git a/fmu10/src/model_exchange/include/fmiModelFunctions.h b/fmu10/src/model_exchange/include/fmiModelFunctions.h
new file mode 100644
index 0000000..695f4c6
--- /dev/null
+++ b/fmu10/src/model_exchange/include/fmiModelFunctions.h
@@ -0,0 +1,206 @@
+#ifndef fmiModelFunctions_h
+#define fmiModelFunctions_h
+
+/* This header file must be utilized when compiling a model.
+ It defines all functions of the Model Execution Interface.
+ In order to have unique function names even if several models
+ are compiled together (e.g. for embedded systems), every "real" function name
+ is constructed by prepending the function name by
+ "MODEL_IDENTIFIER" + "_" where "MODEL_IDENTIFIER" is the short name
+ of the model used as the name of the zip-file where the model is stored.
+ Therefore, the typical usage is:
+
+ #define MODEL_IDENTIFIER MyModel
+ #include "fmiModelFunctions.h"
+
+ As a result, a function that is defined as "fmiGetDerivatives" in this header file,
+ is actually getting the name "MyModel_fmiGetDerivatives".
+
+ Revisions:
+ - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
+ (by M. Otter, DLR)
+ Added WIN32 pragma to define the struct layout (ticket #34)
+ (by J. Mauss, QTronic)
+ - Jan. 4, 2010: Removed argument intermediateResults from fmiInitialize
+ Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
+ Renamed macro fmiModelFunctionsVersion to fmiVersion
+ Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
+ (by J. Mauss, QTronic)
+ - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
+ - Dez. 14, 2009: Added eventInfo to meInitialize and added
+ meGetNominalContinuousStates (by Martin Otter, DLR)
+ - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
+ (by A. Junghanns, QTronic)
+ - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+ meInquireModelTypesVersion -> meGetModelTypesPlatform
+ meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
+ meSetStates -> meSetContinuousStates
+ meGetStates -> meGetContinuousStates
+ removal of meInitializeModelClass
+ removal of meGetTime
+ change of arguments of meInstantiateModel
+ change of arguments of meCompletedIntegratorStep
+ (by Martin Otter, DLR):
+ - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
+ - March 2, 2009: Changed function definitions according to the last design
+ meeting with additional improvements (by Martin Otter, DLR).
+ - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
+
+
+ Copyright © 2008-2009, MODELISAR consortium. All rights reserved.
+ This file is licensed by the copyright holders under the BSD License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+
+ with the extension:
+
+ You may distribute or publicly perform any modification only under the
+ terms of this license.
+*/
+
+#include "fmiModelTypes.h"
+#include
+
+/* Export fmi functions on Windows */
+#ifdef _MSC_VER
+#define DllExport __declspec( dllexport )
+#else
+#define DllExport
+#endif
+
+/* Macros to construct the real function name
+ (prepend function name by MODEL_IDENTIFIER + "_") */
+
+#define fmiPaste(a,b) a ## b
+#define fmiPasteB(a,b) fmiPaste(a,b)
+#define fmiFullName(name) fmiPasteB(MODEL_IDENTIFIER, name)
+
+#define fmiGetModelTypesPlatform fmiFullName(_fmiGetModelTypesPlatform)
+#define fmiGetVersion fmiFullName(_fmiGetVersion)
+#define fmiInstantiateModel fmiFullName(_fmiInstantiateModel)
+#define fmiFreeModelInstance fmiFullName(_fmiFreeModelInstance)
+#define fmiSetDebugLogging fmiFullName(_fmiSetDebugLogging)
+#define fmiSetTime fmiFullName(_fmiSetTime)
+#define fmiSetContinuousStates fmiFullName(_fmiSetContinuousStates)
+#define fmiCompletedIntegratorStep fmiFullName(_fmiCompletedIntegratorStep)
+#define fmiSetReal fmiFullName(_fmiSetReal)
+#define fmiSetInteger fmiFullName(_fmiSetInteger)
+#define fmiSetBoolean fmiFullName(_fmiSetBoolean)
+#define fmiSetString fmiFullName(_fmiSetString)
+#define fmiInitialize fmiFullName(_fmiInitialize)
+#define fmiGetDerivatives fmiFullName(_fmiGetDerivatives)
+#define fmiGetEventIndicators fmiFullName(_fmiGetEventIndicators)
+#define fmiGetReal fmiFullName(_fmiGetReal)
+#define fmiGetInteger fmiFullName(_fmiGetInteger)
+#define fmiGetBoolean fmiFullName(_fmiGetBoolean)
+#define fmiGetString fmiFullName(_fmiGetString)
+#define fmiEventUpdate fmiFullName(_fmiEventUpdate)
+#define fmiGetContinuousStates fmiFullName(_fmiGetContinuousStates)
+#define fmiGetNominalContinuousStates fmiFullName(_fmiGetNominalContinuousStates)
+#define fmiGetStateValueReferences fmiFullName(_fmiGetStateValueReferences)
+#define fmiTerminate fmiFullName(_fmiTerminate)
+
+
+/* Version number */
+#define fmiVersion "1.0"
+
+/* Inquire version numbers of header files */
+ DllExport const char* fmiGetModelTypesPlatform();
+ DllExport const char* fmiGetVersion();
+
+/* make sure all compiler use the same alignment policies for structures */
+#pragma pack(push,8)
+
+/* Type definitions */
+ typedef enum {fmiOK,
+ fmiWarning,
+ fmiDiscard,
+ fmiError,
+ fmiFatal} fmiStatus;
+
+ typedef void (*fmiCallbackLogger) (fmiComponent c, fmiString instanceName, fmiStatus status,
+ fmiString category, fmiString message, ...);
+ typedef void* (*fmiCallbackAllocateMemory)(size_t nobj, size_t size);
+ typedef void (*fmiCallbackFreeMemory) (void* obj);
+
+ typedef struct {
+ fmiCallbackLogger logger;
+ fmiCallbackAllocateMemory allocateMemory;
+ fmiCallbackFreeMemory freeMemory;
+ } fmiCallbackFunctions;
+
+ typedef struct {
+ fmiBoolean iterationConverged;
+ fmiBoolean stateValueReferencesChanged;
+ fmiBoolean stateValuesChanged;
+ fmiBoolean terminateSimulation;
+ fmiBoolean upcomingTimeEvent;
+ fmiReal nextEventTime;
+ } fmiEventInfo;
+
+/* reset alignment policy to the one set before reading this file */
+#pragma pack(pop)
+
+/* Creation and destruction of model instances and setting debug status */
+ DllExport fmiComponent fmiInstantiateModel (fmiString instanceName,
+ fmiString GUID,
+ fmiCallbackFunctions functions,
+ fmiBoolean loggingOn);
+ DllExport void fmiFreeModelInstance(fmiComponent c);
+ DllExport fmiStatus fmiSetDebugLogging (fmiComponent c, fmiBoolean loggingOn);
+
+
+/* Providing independent variables and re-initialization of caching */
+ DllExport fmiStatus fmiSetTime (fmiComponent c, fmiReal time);
+ DllExport fmiStatus fmiSetContinuousStates (fmiComponent c, const fmiReal x[], size_t nx);
+ DllExport fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate);
+ DllExport fmiStatus fmiSetReal (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]);
+ DllExport fmiStatus fmiSetInteger (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);
+ DllExport fmiStatus fmiSetBoolean (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);
+ DllExport fmiStatus fmiSetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]);
+
+
+/* Evaluation of the model equations */
+ DllExport fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled,
+ fmiReal relativeTolerance, fmiEventInfo* eventInfo);
+
+ DllExport fmiStatus fmiGetDerivatives (fmiComponent c, fmiReal derivatives[] , size_t nx);
+ DllExport fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni);
+
+ DllExport fmiStatus fmiGetReal (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]);
+ DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);
+ DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);
+ DllExport fmiStatus fmiGetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]);
+
+ DllExport fmiStatus fmiEventUpdate (fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo);
+ DllExport fmiStatus fmiGetContinuousStates (fmiComponent c, fmiReal states[], size_t nx);
+ DllExport fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx);
+ DllExport fmiStatus fmiGetStateValueReferences (fmiComponent c, fmiValueReference vrx[], size_t nx);
+ DllExport fmiStatus fmiTerminate (fmiComponent c);
+
+#endif // fmiModelFunctions_h
diff --git a/fmu10/src/model_exchange/include/fmiModelTypes.h b/fmu10/src/model_exchange/include/fmiModelTypes.h
new file mode 100644
index 0000000..41db809
--- /dev/null
+++ b/fmu10/src/model_exchange/include/fmiModelTypes.h
@@ -0,0 +1,91 @@
+#ifndef fmiModelTypes_h
+#define fmiModelTypes_h
+
+/* Standard header file to define the argument types of the
+ functions of the Model Execution Interface.
+ This header file must be utilized both by the model and
+ by the simulation engine.
+
+ Revisions:
+ - Jan. 4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
+ - Dec. 21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
+ according to meeting on Dec. 18 (by Martin Otter, DLR)
+ - Dec. 6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
+ - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+ Changed "version" to "platform", "standard" to "standard32",
+ Added a precise definition of "standard32" as comment
+ (by Martin Otter, DLR)
+ - July 19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
+ and changed meValueReferenced from int to unsigned int
+ (by Martin Otter, DLR).
+ - March 2, 2009: Moved enums and function pointer definitions to
+ ModelFunctions.h (by Martin Otter, DLR).
+ - Dec. 3, 2008 : First version by Martin Otter (DLR) and
+ Hans Olsson (Dynasim).
+
+
+ Copyright © 2008-2010, MODELISAR consortium. All rights reserved.
+ This file is licensed by the copyright holders under the BSD License
+ (http://www.opensource.org/licenses/bsd-license.html)
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+
+ with the extension:
+
+ You may distribute or publicly perform any modification only under the
+ terms of this license.
+*/
+
+/* Platform (combination of machine, compiler, operating system) */
+#define fmiModelTypesPlatform "standard32"
+
+/* Type definitions of variables passed as arguments
+ Version "standard32" means:
+
+ fmiComponent : 32 bit pointer
+ fmiValueReference: 32 bit
+ fmiReal : 64 bit
+ fmiInteger : 32 bit
+ fmiBoolean : 8 bit
+ fmiString : 32 bit pointer
+
+*/
+ typedef void* fmiComponent;
+ typedef unsigned int fmiValueReference;
+ typedef double fmiReal ;
+ typedef int fmiInteger;
+ typedef char fmiBoolean;
+ typedef const char* fmiString ;
+
+/* Values for fmiBoolean */
+#define fmiTrue 1
+#define fmiFalse 0
+
+/* Undefined value for fmiValueReference (largest unsigned int value) */
+#define fmiUndefinedValueReference (fmiValueReference)(-1)
+
+#endif
diff --git a/fmu10/src/models/Makefile b/fmu10/src/models/Makefile
new file mode 100644
index 0000000..0fad3ae
--- /dev/null
+++ b/fmu10/src/models/Makefile
@@ -0,0 +1,72 @@
+# Build the .fmu files for both co-simulation and model-exchange.
+#
+# The build_fmu script calls make with the appropriate makefile variables set.
+
+# The architecture: linux32, linux64, darwin32, darwin64
+ARCH = darwin64
+
+# Either cs for co-simuluation or me for model exchange.
+CSORME = cs
+CSORME_INCLUDE = -DFMI_COSIMULATION -I../../co_simulation/include
+#CSORME = me
+#CSORME_INCLUDE = -I../../model_exchange/include
+
+# The suffix for shared libraries.
+# dylib for Mac OS X, so for Linux
+SHARED_LIBRARY_SUFFIX = dylib
+#SHARED_LIBRARY_SUFFIX = so
+
+# Empty for Mac OS X, -fPIC for Linux
+PIC =
+#PIC = -fPIC
+
+# Build the .fmu files for both co-simulation and model-exchange
+all:
+ chmod 777 build_fmu
+ ./build_fmu me bouncingBall
+ ./build_fmu me dq
+ ./build_fmu me inc
+ ./build_fmu me values
+ ./build_fmu me vanDerPol
+ ./build_fmu cs bouncingBall
+ ./build_fmu cs dq
+ ./build_fmu cs inc
+ ./build_fmu cs values
+ ./build_fmu cs vanDerPol
+
+# CBITSFLAGS is set to -m32 to build linux32 fmus
+
+%.o: %.c
+ echo `pwd`
+ $(CC) -g -c $(CBITSFLAGS) $(PIC) -Wall $(CSORME_INCLUDE) $(CFLAGS) $< -o $@
+
+%.so: %.o
+ $(CC) $(CBITSFLAGS) -shared -Wl,-soname,$@ -o $@ $<
+
+%.dylib: %.o
+ $(CC) -dynamiclib -o $@ $<
+
+%.fmu: %.$(SHARED_LIBRARY_SUFFIX)
+ rm -rf fmu
+ mkdir -p fmu/binaries/$(ARCH) fmu/sources fmu/documentation
+ cp $< fmu/binaries/$(ARCH)
+ -cp *.c fmu/sources
+ rsync -av --ignore-missing-args ./*.h ./fmu/sources
+ -cp *.html *.png fmu/documentation
+ cat modelDescription.xml ../$(CSORME).xml > fmu/modelDescription.xml
+ cp model.png fmu
+ @if [ ! -d ../../../fmu/$(CSORME) ]; then \
+ echo "mkdir -p ../../../fmu/$(CSORME)"; \
+ mkdir -p ../../../fmu/$(CSORME); \
+ fi
+ (cd fmu; zip -q -r ../../../../fmu/$(CSORME)/$@ *)
+
+clean:
+ (cd bouncingBall; make dirclean)
+ (cd dq; make dirclean)
+ (cd inc; make dirclean)
+ (cd values; make dirclean)
+ (cd vanDerPol; make dirclean)
+
+dirclean:
+ rm -rf *.so *.dylib *.o *.fmu *~ fmu
diff --git a/fmu10/src/models/bouncingBall/Makefile b/fmu10/src/models/bouncingBall/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu10/src/models/bouncingBall/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu10/src/models/bouncingBall/bouncingBall.c b/fmu10/src/models/bouncingBall/bouncingBall.c
new file mode 100644
index 0000000..00698ac
--- /dev/null
+++ b/fmu10/src/models/bouncingBall/bouncingBall.c
@@ -0,0 +1,104 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - a bouncing ball.
+ * This demonstrates the use of state events and reinit of states.
+ * Equations:
+ * der(h) = v;
+ * der(v) = -g;
+ * when h<0 then v := -e * v;
+ * where
+ * h height [m], used as state, start = 1
+ * v velocity of ball [m/s], used as state
+ * der(h) velocity of ball [m/s]
+ * der(v) acceleration of ball [m/s2]
+ * g acceleration of gravity [m/s2], a parameter, start = 9.81
+ * e a dimensionless parameter, start = 0.7
+ *
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER bouncingBall
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f003}"
+
+// define model size
+#define NUMBER_OF_REALS 6
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 2
+#define NUMBER_OF_EVENT_INDICATORS 1
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define h_ 0
+#define der_h_ 1
+#define v_ 2
+#define der_v_ 3
+#define g_ 4
+#define e_ 5
+
+// define initial state vector as vector of value references
+#define STATES { h_, v_ }
+
+// called by fmiInstantiateModel
+// Set values for all variables that define a start value
+// Settings used unless changed by fmiSetX before fmiInitialize
+void setStartValues(ModelInstance *comp) {
+ r(h_) = 1;
+ r(v_) = 0;
+ r(der_v_) = -9.81;
+ r(g_) = 9.81;
+ r(e_) = 0.7;
+ pos(0) = r(h_) > 0;
+}
+
+// called by fmiGetReal, fmiGetContinuousStates and fmiGetDerivatives
+fmiReal getReal(ModelInstance* comp, fmiValueReference vr){
+ switch (vr) {
+ case h_ : return r(h_);
+ case der_h_ : return r(v_);
+ case v_ : return r(v_);
+ case der_v_ : return r(der_v_);
+ case g_ : return r(g_);
+ case e_ : return r(e_);
+ default: return 0;
+ }
+}
+
+// called by fmiInitialize() after setting eventInfo to defaults
+// Used to set the first time event, if any.
+void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ r(der_v_) = -r(g_);
+}
+
+// offset for event indicator, adds hysteresis and prevents z=0 at restart
+#define EPS_INDICATORS 1e-14
+
+fmiReal getEventIndicator(ModelInstance* comp, int z) {
+ switch (z) {
+ case 0 : return r(h_) + (pos(0) ? EPS_INDICATORS : -EPS_INDICATORS);
+ default: return 0;
+ }
+}
+
+// Used to set the next time event, if any.
+void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ if (pos(0)) {
+ r(v_) = - r(e_) * r(v_);
+ }
+ pos(0) = r(h_) > 0;
+ eventInfo->iterationConverged = fmiTrue;
+ eventInfo->stateValueReferencesChanged = fmiFalse;
+ eventInfo->stateValuesChanged = fmiTrue;
+ eventInfo->terminateSimulation = fmiFalse;
+ eventInfo->upcomingTimeEvent = fmiFalse;
+ }
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu10/src/models/bouncingBall/index.html b/fmu10/src/models/bouncingBall/index.html
new file mode 100644
index 0000000..35a59f0
--- /dev/null
+++ b/fmu10/src/models/bouncingBall/index.html
@@ -0,0 +1,55 @@
+
+
+ Documentation for bouncingBall.fmu
+
+
+
+bouncingBall.fmu
+The bouncingBall implements the following equation:
+
+- der(h) = v;
+
- der(v) = -g;
+
- when h<0 then v := -e* v
+
+with start values h=1, e=0.7, g = 9.81 and
+
+- h: height [m], used as state
+
- v: velocity of ball [m/s], used as state
+
- der(h): velocity of ball [m/s]
+
- der(v): acceleration of ball [m/s2]
+
- g: acceleration of gravity [m/s2], a parameter
+
- e: a dimensionless parameter
+
+
+
+
+
+The figure shows the solution computed with Silver
+for height h of the ball for the start values given above.
+
+
+The chain of events during simulation is as follows
+
+- initially h>0 and pos(0)=true
+- continuous integration until a state event is detected, i.e.
+ until h + EPS_INDICATORS = 0.
+ At this time h < 0, the EPS_INDICATORS adds hysteresis.
+- the simulator calls eventUpdate once which reverses the speed direction
+ v of the ball: v = -e * v, and sets pos(0)=false
+- continuous integration until state event is detected, i.e.
+ until h - EPS_INDICATORS = 0.
+ At this time h > 0, the EPS_INDICATORS adds hysteresis.
+- the simulator calls eventUpdate once more which sets pos(0)=true.
+- goto 2
+
+The above description refers to the variables used
+in file bouncingBall.c
.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
diff --git a/fmu10/src/models/bouncingBall/model.png b/fmu10/src/models/bouncingBall/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu10/src/models/bouncingBall/model.png differ
diff --git a/fmu10/src/models/bouncingBall/modelDescription.xml b/fmu10/src/models/bouncingBall/modelDescription.xml
new file mode 100644
index 0000000..58e1285
--- /dev/null
+++ b/fmu10/src/models/bouncingBall/modelDescription.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu10/src/models/bouncingBall/plot_h.PNG b/fmu10/src/models/bouncingBall/plot_h.PNG
new file mode 100644
index 0000000..ced85c4
Binary files /dev/null and b/fmu10/src/models/bouncingBall/plot_h.PNG differ
diff --git a/fmu10/src/models/build_fmu b/fmu10/src/models/build_fmu
new file mode 100644
index 0000000..8f04254
--- /dev/null
+++ b/fmu10/src/models/build_fmu
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Build a model exchange or co-simulation fmu
+# Usage: build_fmu cs|me directory
+
+if [ $# -ne 2 ]; then
+ echo "Usage: $0 cs|me directory"
+ exit 2
+fi
+
+csOrMe=$1
+directory=$2
+
+# Error checking
+if [ "$csOrMe" != "me" -a "$csOrMe" != "cs" ]; then
+ echo "$0: first argument must be either 'me' or 'cs', not $csOrMe"
+ exit 3
+fi
+
+if [ ! -d $directory ]; then
+ echo "$0: directory $directory does not exist"
+ exit 4
+fi
+
+if [ "$csOrMe" = "cs" ]; then
+ csOrMeInclude="-DFMI_COSIMULATION -I../../co_simulation/include"
+else
+ csOrMeInclude=-I../../model_exchange/include
+fi
+
+case "`uname -s`" in
+ CYGWIN*) arch=win
+ sharedLibrarySuffix=dll;;
+ Darwin) arch=darwin
+ sharedLibrarySuffix=dylib;;
+ Linux) arch=linux
+ pic=-fPIC
+ sharedLibrarySuffix=so;;
+esac
+
+# Number of bits, default to 64
+bits=64
+case "`uname -m`" in
+ *64) bits=64;;
+ *32) bits=32;;
+ *i[3-6]86) bits=32;;
+esac
+
+# Uncomment the next line to force building 32-bit
+#bits=32
+# See also ../Makefile
+
+if [ $arch = linux -a $bits = 32 ]; then
+ CBITSFLAGS=-m32
+fi
+
+set -x
+(cd $directory; \
+ make dirclean; \
+ make ARCH=${arch}${bits} CBITSFLAGS=${CBITSFLAGS} CSORME=${csOrMe} CSORME_INCLUDE="${csOrMeInclude}" PIC=${pic} SHARED_LIBRARY_SUFFIX=${sharedLibrarySuffix} $directory.fmu)
diff --git a/fmu10/src/models/build_fmu.bat b/fmu10/src/models/build_fmu.bat
new file mode 100644
index 0000000..15610a4
--- /dev/null
+++ b/fmu10/src/models/build_fmu.bat
@@ -0,0 +1,95 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds an FMU of the FMU SDK
+rem Usage: build_fmu (me|cs)
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+if %1==cs (^
+echo building FMU %2 - FMI for Co-Simulation 1.0) else ^
+echo building FMU %2 - FMI for Model Exchange 1.0
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%3"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+rem create the %2.dll in the temp dir
+if not exist temp mkdir temp
+pushd temp
+if exist *.dll del /Q *.dll
+
+if %1==cs (set FMI_DIR=co_simulation) else set FMI_DIR=model_exchange
+if %1==cs (set DEF=/DFMI_COSIMULATION) else set DEF=
+cl /LD /nologo %DEF% ..\%2\%2.c /I ..\. /I ..\..\%FMI_DIR%\include
+if not exist %2.dll goto compileError
+
+rem create FMU dir structure with root 'fmu'
+if defined x64 (set BIN_DIR=fmu\binaries\win64) else set BIN_DIR=fmu\binaries\win32
+set SRC_DIR=fmu\sources
+set DOC_DIR=fmu\documentation
+if not exist %BIN_DIR% mkdir %BIN_DIR%
+if not exist %SRC_DIR% mkdir %SRC_DIR%
+if not exist %DOC_DIR% mkdir %DOC_DIR%
+move /Y %2.dll %BIN_DIR%
+if exist ..\%2\*~ del /Q ..\%2\*~
+copy ..\%2\%2.c %SRC_DIR%
+type ..\%2\modelDescription.xml ..\%1.xml > fmu\modelDescription.xml
+copy ..\%2\model.png fmu
+copy ..\fmuTemplate.c %SRC_DIR%
+copy ..\fmuTemplate.h %SRC_DIR%
+copy ..\%2\*.html %DOC_DIR%
+copy ..\%2\*.png %DOC_DIR%
+del %DOC_DIR%\model.png
+
+rem zip the directory tree and move to fmu directory
+cd fmu
+set FMU_FILE=..\..\..\..\fmu\%1\%x64%%2.fmu
+if exist %FMU_FILE% del %FMU_FILE%
+..\..\..\..\bin\7z.exe a -tzip %FMU_FILE% ^
+ modelDescription.xml model.png binaries sources documentation
+goto cleanup
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of %2 failed
+
+:cleanup
+popd
+if exist temp rmdir /S /Q temp
+
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu10/src/models/cs.xml b/fmu10/src/models/cs.xml
new file mode 100644
index 0000000..9e38bc4
--- /dev/null
+++ b/fmu10/src/models/cs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/fmu10/src/models/dq/Makefile b/fmu10/src/models/dq/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu10/src/models/dq/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu10/src/models/dq/dq.c b/fmu10/src/models/dq/dq.c
new file mode 100644
index 0000000..84bb681
--- /dev/null
+++ b/fmu10/src/models/dq/dq.c
@@ -0,0 +1,64 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - the Dahlquist test equation.
+ *
+ * der(x) = - k * x and x(0) = 1.
+ * Analytical solution: x(t) = exp(-k*t).
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER dq
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f000}"
+
+// define model size
+#define NUMBER_OF_REALS 3
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 1
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x_ 0
+#define der_x_ 1
+#define k_ 2
+
+// define state vector as vector of value references
+#define STATES { x_ }
+
+// called by fmiInstantiateModel
+// Set values for all variables that define a start value
+// Settings used unless changed by fmiSetX before fmiInitialize
+void setStartValues(ModelInstance *comp) {
+ r(x_) = 1;
+ r(k_) = 1;
+}
+
+// called by fmiInitialize() after setting eventInfo to defaults
+// Used to set the first time event, if any.
+void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {
+}
+
+// called by fmiGetReal, fmiGetContinuousStates and fmiGetDerivatives
+fmiReal getReal(ModelInstance* comp, fmiValueReference vr){
+ switch (vr) {
+ case x_ : return r(x_);
+ case der_x_ : return - r(k_) * r(x_);
+ case k_ : return r(k_);
+ default: return 0;
+ }
+}
+
+// Used to set the next time event, if any.
+void eventUpdate(fmiComponent comp, fmiEventInfo* eventInfo) {
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu10/src/models/dq/index.html b/fmu10/src/models/dq/index.html
new file mode 100644
index 0000000..833f256
--- /dev/null
+++ b/fmu10/src/models/dq/index.html
@@ -0,0 +1,33 @@
+
+
+Documentation for dq.fmu
+
+
+
+dq.fmu
+This FMU implements the equation
+
+The analytical solution of this system is
+
+The above equation is also known as
+Dahlquist
+test equation.
+
+
+
+The figure shows the solution for x computed with Silver
+for start values k = 1 and x = 1.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu10/src/models/dq/model.png b/fmu10/src/models/dq/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu10/src/models/dq/model.png differ
diff --git a/fmu10/src/models/dq/modelDescription.xml b/fmu10/src/models/dq/modelDescription.xml
new file mode 100644
index 0000000..daf9fbf
--- /dev/null
+++ b/fmu10/src/models/dq/modelDescription.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu10/src/models/dq/plot_x.PNG b/fmu10/src/models/dq/plot_x.PNG
new file mode 100644
index 0000000..b28fa66
Binary files /dev/null and b/fmu10/src/models/dq/plot_x.PNG differ
diff --git a/fmu10/src/models/fmuTemplate.c b/fmu10/src/models/fmuTemplate.c
new file mode 100644
index 0000000..9b874f0
--- /dev/null
+++ b/fmu10/src/models/fmuTemplate.c
@@ -0,0 +1,796 @@
+/* ---------------------------------------------------------------------------*
+ * Implementation of the FMI interface based on functions and macros to
+ * be defined by the includer of this file.
+ * If FMI_COSIMULATION is defined, this implements "FMI for Co-Simulation 1.0",
+ * otherwise "FMI for Model Exchange 1.0".
+ * The "FMI for Co-Simulation 1.0", implementation assumes that exactly the
+ * following capability flags are set to fmiTrue:
+ * canHandleVariableCommunicationStepSize, i.e. fmiDoStep step size can vary
+ * canHandleEvents, i.e. fmiDoStep step size can be zero
+ * and all other capability flags are set to default, i.e. to fmiFalse or 0.
+ *
+ * Revision history
+ * 07.02.2010 initial version for "Model Exchange 1.0" released in FMU SDK 1.0
+ * 05.03.2010 bug fix: fmiSetString now copies the passed string argument
+ * and fmiFreeModelInstance frees all string copies
+ * 11.12.2010 replaced calloc by functions.allocateMemory in fmiInstantiateModel
+ * 04.08.2011 added support for "FMI for Co-Simulation 1.0"
+ * 02.08.2013 fixed a bug in instantiateModel reported by Markus Ende, TH Nuernberg
+ * 02.04.2014 better time event handling
+ * 02.06.2014 copy instanceName and GUID at instantiation
+ *
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// array of value references of states
+#if NUMBER_OF_STATES>0
+fmiValueReference vrStates[NUMBER_OF_STATES] = STATES;
+#endif
+
+#ifndef max
+#define max(a,b) ((a)>(b) ? (a) : (b))
+#endif
+
+// ---------------------------------------------------------------------------
+// Private helpers used below to validate function arguments
+// ---------------------------------------------------------------------------
+
+static fmiBoolean invalidNumber(ModelInstance* comp, const char* f, const char* arg, int n, int nExpected){
+ if (n != nExpected) {
+ comp->state = modelError;
+ comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+ "%s: Invalid argument %s = %d. Expected %d.", f, arg, n, nExpected);
+ return fmiTrue;
+ }
+ return fmiFalse;
+}
+
+static fmiBoolean invalidState(ModelInstance* comp, const char* f, int statesExpected){
+ if (!comp)
+ return fmiTrue;
+ if (!(comp->state & statesExpected)) {
+ comp->state = modelError;
+ comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+ "%s: Illegal call sequence.", f);
+ return fmiTrue;
+ }
+ return fmiFalse;
+}
+
+static fmiBoolean nullPointer(ModelInstance* comp, const char* f, const char* arg, const void* p){
+ if (!p) {
+ comp->state = modelError;
+ comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+ "%s: Invalid argument %s = NULL.", f, arg);
+ return fmiTrue;
+ }
+ return fmiFalse;
+}
+
+static fmiBoolean vrOutOfRange(ModelInstance* comp, const char* f, fmiValueReference vr, int end) {
+ if (vr >= end) {
+ comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+ "%s: Illegal value reference %u.", f, vr);
+ comp->state = modelError;
+ return fmiTrue;
+ }
+ return fmiFalse;
+}
+
+// ---------------------------------------------------------------------------
+// Private helpers used below to implement functions
+// ---------------------------------------------------------------------------
+
+fmiStatus setString(fmiComponent comp, fmiValueReference vr, fmiString value){
+ return fmiSetString(comp, &vr, 1, &value);
+}
+
+// fname is fmiInstantiateModel or fmiInstantiateSlave
+static fmiComponent instantiateModel(char* fname, fmiString instanceName, fmiString GUID,
+ fmiCallbackFunctions functions, fmiBoolean loggingOn) {
+ ModelInstance* comp;
+ if (!functions.logger)
+ return NULL; // we cannot even log this problem
+ if (!instanceName || strlen(instanceName)==0) {
+ functions.logger(NULL, "?", fmiError, "error",
+ "%s: Missing instance name.", fname);
+ return NULL;
+ }
+ if (!GUID || strlen(GUID)==0) {
+ functions.logger(NULL, instanceName, fmiError, "error",
+ "%s: Missing GUID.", fname);
+ return NULL;
+ }
+ if (!functions.allocateMemory || !functions.freeMemory){
+ functions.logger(NULL, instanceName, fmiError, "error",
+ "%s: Missing callback function.", fname);
+ return NULL;
+ }
+ if (strcmp(GUID, MODEL_GUID)) {
+ functions.logger(NULL, instanceName, fmiError, "error",
+ "%s: Wrong GUID %s. Expected %s.", fname, GUID, MODEL_GUID);
+ return NULL;
+ }
+ comp = (ModelInstance *)functions.allocateMemory(1, sizeof(ModelInstance));
+ if (comp) {
+ comp->r = (fmiReal *)functions.allocateMemory(NUMBER_OF_REALS, sizeof(fmiReal));
+ comp->i = (fmiInteger *)functions.allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmiInteger));
+ comp->b = (fmiBoolean *)functions.allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmiBoolean));
+ comp->s = (fmiString *)functions.allocateMemory(NUMBER_OF_STRINGS, sizeof(fmiString));
+ comp->isPositive = (fmiBoolean *)functions.allocateMemory(NUMBER_OF_EVENT_INDICATORS, sizeof(fmiBoolean));
+ comp->instanceName = (char *)functions.allocateMemory(1 + strlen(instanceName), sizeof(char));
+ comp->GUID = (char *)functions.allocateMemory(1 + strlen(GUID), sizeof(char));
+ }
+ if (!comp || !comp->r || !comp->i || !comp->b || !comp->s || !comp->isPositive
+ || !comp->instanceName || !comp->GUID) {
+ functions.logger(NULL, instanceName, fmiError, "error",
+ "%s: Out of memory.", fname);
+ return NULL;
+ }
+ if (loggingOn) functions.logger(NULL, instanceName, fmiOK, "log",
+ "%s: GUID=%s", fname, GUID);
+
+ strcpy((char *)comp->instanceName, (char *)instanceName);
+ strcpy((char *)comp->GUID, (char *)GUID);
+ comp->functions = functions;
+ comp->loggingOn = loggingOn;
+ comp->state = modelInstantiated;
+ setStartValues(comp); // to be implemented by the includer of this file
+ return comp;
+}
+
+// fname is fmiInitialize or fmiInitializeSlave
+static fmiStatus init(char* fname, fmiComponent c, fmiBoolean toleranceControlled, fmiReal relativeTolerance,
+ fmiEventInfo* eventInfo) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, fname, modelInstantiated))
+ return fmiError;
+ if (nullPointer(comp, fname, "eventInfo", eventInfo))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "%s: toleranceControlled=%d relativeTolerance=%g",
+ fname, toleranceControlled, relativeTolerance);
+ eventInfo->iterationConverged = fmiTrue;
+ eventInfo->stateValueReferencesChanged = fmiFalse;
+ eventInfo->stateValuesChanged = fmiFalse;
+ eventInfo->terminateSimulation = fmiFalse;
+ eventInfo->upcomingTimeEvent = fmiFalse;
+ initialize(comp, eventInfo); // to be implemented by the includer of this file
+ comp->state = modelInitialized;
+ return fmiOK;
+}
+
+// fname is fmiTerminate or fmiTerminateSlave
+static fmiStatus terminate(char* fname, fmiComponent c){
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, fname, modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", fname);
+ comp->state = modelTerminated;
+ return fmiOK;
+}
+
+// fname is freeModelInstance of freeSlaveInstance
+void freeInstance(char* fname, fmiComponent c) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (!comp) return;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", fname);
+ if (comp->r) comp->functions.freeMemory(comp->r);
+ if (comp->i) comp->functions.freeMemory(comp->i);
+ if (comp->b) comp->functions.freeMemory(comp->b);
+ if (comp->s) {
+ int i;
+ for (i=0; is[i]) comp->functions.freeMemory((void *)comp->s[i]);
+ }
+ comp->functions.freeMemory((void *)comp->s);
+ }
+ if (comp->isPositive) comp->functions.freeMemory(comp->isPositive);
+ if (comp->instanceName) comp->functions.freeMemory((void *)comp->instanceName);
+ if (comp->GUID) comp->functions.freeMemory((void *)comp->GUID);
+ comp->functions.freeMemory(comp);
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: class methods not depending of a specific model instance
+// ---------------------------------------------------------------------------
+
+const char* fmiGetVersion() {
+ return fmiVersion;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: for FMI Model Exchange 1.0 and for FMI Co-Simulation 1.0
+// logging control, setters and getters for Real, Integer, Boolean, String
+// ---------------------------------------------------------------------------
+
+fmiStatus fmiSetDebugLogging(fmiComponent c, fmiBoolean loggingOn) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetDebugLogging", not_modelError))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetDebugLogging: loggingOn=%d", loggingOn);
+ comp->loggingOn = loggingOn;
+ return fmiOK;
+}
+
+fmiStatus fmiSetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetReal", modelInstantiated|modelInitialized))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetReal", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetReal", "value[]", value))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetReal: nvr = %d", nvr);
+ // no check whether setting the value is allowed in the current state
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetReal: #r%d# = %.16g", vr[i], value[i]);
+ comp->r[vr[i]] = value[i];
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiSetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetInteger", modelInstantiated|modelInitialized))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetInteger", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetInteger", "value[]", value))
+ return fmiError;
+ if (comp->loggingOn)
+ comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetInteger: nvr = %d", nvr);
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetInteger: #i%d# = %d", vr[i], value[i]);
+ comp->i[vr[i]] = value[i];
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiSetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetBoolean", modelInstantiated|modelInitialized))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetBoolean", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetBoolean", "value[]", value))
+ return fmiError;
+ if (comp->loggingOn)
+ comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetBoolean: nvr = %d", nvr);
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetBoolean: #b%d# = %s", vr[i], value[i] ? "true" : "false");
+ comp->b[vr[i]] = value[i];
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiSetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetString", modelInstantiated|modelInitialized))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetString", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiSetString", "value[]", value))
+ return fmiError;
+ if (comp->loggingOn)
+ comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetString: nvr = %d", nvr);
+ for (i=0; is[vr[i]];
+ if (vrOutOfRange(comp, "fmiSetString", vr[i], NUMBER_OF_STRINGS))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetString: #s%d# = '%s'", vr[i], value[i]);
+ if (value[i] == NULL) {
+ if (string) comp->functions.freeMemory(string);
+ comp->s[vr[i]] = NULL;
+ comp->functions.logger(comp, comp->instanceName, fmiWarning, "warning",
+ "fmiSetString: string argument value[%d] = NULL.", i);
+ } else {
+ if (string==NULL || strlen(string) < strlen(value[i])) {
+ if (string) comp->functions.freeMemory(string);
+ comp->s[vr[i]] = (char *)comp->functions.allocateMemory(1+strlen(value[i]), sizeof(char));
+ if (!comp->s[vr[i]]) {
+ comp->state = modelError;
+ comp->functions.logger(NULL, comp->instanceName, fmiError, "error", "fmiSetString: Out of memory.");
+ return fmiError;
+ }
+ }
+ strcpy((char *)comp->s[vr[i]], (char *)value[i]);
+ }
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetReal", not_modelError))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetReal", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetReal", "value[]", value))
+ return fmiError;
+#if NUMBER_OF_REALS>0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetReal: #r%u# = %.16g", vr[i], value[i]);
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetInteger", not_modelError))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetInteger", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetInteger", "value[]", value))
+ return fmiError;
+ for (i=0; ii[vr[i]];
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetInteger: #i%u# = %d", vr[i], value[i]);
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetBoolean", not_modelError))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetBoolean", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetBoolean", "value[]", value))
+ return fmiError;
+ for (i=0; ib[vr[i]];
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetBoolean: #b%u# = %s", vr[i], value[i]? "true" : "false");
+ }
+ return fmiOK;
+}
+
+fmiStatus fmiGetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetString", not_modelError))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetString", "vr[]", vr))
+ return fmiError;
+ if (nvr>0 && nullPointer(comp, "fmiGetString", "value[]", value))
+ return fmiError;
+ for (i=0; is[vr[i]];
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetString: #s%u# = '%s'", vr[i], value[i]);
+ }
+ return fmiOK;
+}
+
+#ifdef FMI_COSIMULATION
+// ---------------------------------------------------------------------------
+// FMI functions: only for FMI Co-Simulation 1.0
+// ---------------------------------------------------------------------------
+
+const char* fmiGetTypesPlatform() {
+ return fmiPlatform;
+}
+
+fmiComponent fmiInstantiateSlave(fmiString instanceName, fmiString GUID,
+ fmiString fmuLocation, fmiString mimeType, fmiReal timeout, fmiBoolean visible,
+ fmiBoolean interactive, fmiCallbackFunctions functions, fmiBoolean loggingOn) {
+ // ignoring arguments: fmuLocation, mimeType, timeout, visible, interactive
+ return instantiateModel("fmiInstantiateSlave", instanceName, GUID, functions, loggingOn);
+}
+
+fmiStatus fmiInitializeSlave(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop) {
+ ModelInstance* comp = (ModelInstance *)c;
+ fmiBoolean toleranceControlled = fmiFalse;
+ fmiReal relativeTolerance = 0;
+ fmiStatus flag = fmiOK;
+ comp->eventInfo.iterationConverged = 0;
+ while (flag==fmiOK && !comp->eventInfo.iterationConverged) {
+ // ignoring arguments: tStart, StopTimeDefined, tStop
+ flag = init("fmiInitializeSlave", c, toleranceControlled, relativeTolerance, &comp->eventInfo);
+ }
+ return flag;
+}
+
+fmiStatus fmiTerminateSlave(fmiComponent c) {
+ return terminate("fmiTerminateSlave", c);
+}
+
+fmiStatus fmiResetSlave(fmiComponent c) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiResetSlave", modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiResetSlave");
+ comp->state = modelInstantiated;
+ setStartValues(comp); // to be implemented by the includer of this file
+ return fmiOK;
+}
+
+void fmiFreeSlaveInstance(fmiComponent c) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiFreeSlaveInstance", modelTerminated))
+ return;
+ freeInstance("fmiFreeSlaveInstance", c);
+}
+
+fmiStatus fmiSetRealInputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr,
+ const fmiInteger order[], const fmiReal value[]) {
+ ModelInstance* comp = (ModelInstance *)c;
+ fmiCallbackLogger log = comp->functions.logger;
+ if (invalidState(comp, "fmiSetRealInputDerivatives", modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) log(c, comp->instanceName, fmiOK, "log", "fmiSetRealInputDerivatives: nvr= %d", nvr);
+ log(c, comp->instanceName, fmiError, "warning", "fmiSetRealInputDerivatives: ignoring function call."
+ " This model cannot interpolate inputs: canInterpolateInputs=\"fmiFalse\"");
+ return fmiWarning;
+}
+
+fmiStatus fmiGetRealOutputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr,
+ const fmiInteger order[], fmiReal value[]) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ fmiCallbackLogger log = comp->functions.logger;
+ if (invalidState(comp, "fmiGetRealOutputDerivatives", modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) log(c, comp->instanceName, fmiOK, "log", "fmiGetRealOutputDerivatives: nvr= %d", nvr);
+ log(c, comp->instanceName, fmiError, "warning", "fmiGetRealOutputDerivatives: ignoring function call."
+ " This model cannot compute derivatives of outputs: MaxOutputDerivativeOrder=\"0\"");
+ for (i=0; ifunctions.logger;
+ if (invalidState(comp, "fmiCancelStep", modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) log(c, comp->instanceName, fmiOK, "log", "fmiCancelStep");
+ log(c, comp->instanceName, fmiError, "error",
+ "fmiCancelStep: Can be called when fmiDoStep returned fmiPending."
+ " This is not the case.");
+ return fmiError;
+}
+
+fmiStatus fmiDoStep(fmiComponent c, fmiReal currentCommunicationPoint,
+ fmiReal communicationStepSize, fmiBoolean newStep) {
+ ModelInstance* comp = (ModelInstance *)c;
+ fmiCallbackLogger log = comp->functions.logger;
+ double h = communicationStepSize / 10;
+ int k,i;
+ const int n = 10; // how many Euler steps to perform for one do step
+ double prevState[max(NUMBER_OF_STATES, 1)];
+ double prevEventIndicators[max(NUMBER_OF_EVENT_INDICATORS, 1)];
+ int stateEvent = 0;
+
+ if (invalidState(comp, "fmiDoStep", modelInitialized))
+ return fmiError;
+
+ if (comp->loggingOn) log(c, comp->instanceName, fmiOK, "log", "fmiDoStep: "
+ "currentCommunicationPoint = %g, "
+ "communicationStepSize = %g, "
+ "newStep = fmi%s",
+ currentCommunicationPoint, communicationStepSize, newStep ? "True" : "False");
+
+ // Treat also case of zero step, i.e. during an event iteration
+ if (communicationStepSize == 0) {
+ return fmiOK;
+ }
+
+#if NUMBER_OF_EVENT_INDICATORS>0
+ // initialize previous event indicators with current values
+ for (i=0; itime = currentCommunicationPoint;
+ for (k=0; ktime += h;
+
+#if NUMBER_OF_STATES>0
+ for (i=0; i0
+ // check for state event
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiDoStep: state event at %g, z%d crosses zero -%c-", comp->time, i, ei<0 ? '\\' : '/');
+ stateEvent++;
+ }
+ prevEventIndicators[i] = ei;
+ }
+ if (stateEvent) {
+ eventUpdate(comp, &comp->eventInfo);
+ stateEvent = 0;
+ }
+#endif
+ // check for time event
+ if (comp->eventInfo.upcomingTimeEvent && ((comp->time - comp->eventInfo.nextEventTime) > -0.0000000001)) {
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiDoStep: time event detected at %g", comp->time);
+ eventUpdate(comp, &comp->eventInfo);
+ }
+
+ // terminate simulation, if requested by the model
+ if (comp->eventInfo.terminateSimulation) {
+ comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiDoStep: model requested termination at t=%g", comp->time);
+ return fmiError; // enforce termination of the simulation loop
+ }
+ }
+ return fmiOK;
+}
+
+static fmiStatus getStatus(char* fname, fmiComponent c, const fmiStatusKind s) {
+ const char* statusKind[3] = {"fmiDoStepStatus","fmiPendingStatus","fmiLastSuccessfulTime"};
+ ModelInstance* comp = (ModelInstance *)c;
+ fmiCallbackLogger log = comp->functions.logger;
+ if (invalidState(comp, fname, modelInstantiated|modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) log(c, comp->instanceName, fmiOK, "log", "$s: fmiStatusKind = %s", fname, statusKind[s]);
+ switch(s) {
+ case fmiDoStepStatus: log(c, comp->instanceName, fmiError, "error",
+ "%s: Can be called with fmiDoStepStatus when fmiDoStep returned fmiPending."
+ " This is not the case.", fname);
+ break;
+ case fmiPendingStatus: log(c, comp->instanceName, fmiError, "error",
+ "%s: Can be called with fmiPendingStatus when fmiDoStep returned fmiPending."
+ " This is not the case.", fname);
+ break;
+ case fmiLastSuccessfulTime: log(c, comp->instanceName, fmiError, "error",
+ "%s: Can be called with fmiLastSuccessfulTime when fmiDoStep returned fmiDiscard."
+ " This is not the case.", fname);
+ break;
+ }
+ return fmiError;
+}
+
+fmiStatus fmiGetStatus(fmiComponent c, const fmiStatusKind s, fmiStatus* value) {
+ return getStatus("fmiGetStatus", c, s);
+}
+
+fmiStatus fmiGetRealStatus(fmiComponent c, const fmiStatusKind s, fmiReal* value){
+ return getStatus("fmiGetRealStatus", c, s);
+}
+
+fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value){
+ return getStatus("fmiGetIntegerStatus", c, s);
+}
+
+fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value){
+ return getStatus("fmiGetBooleanStatus", c, s);
+}
+
+fmiStatus fmiGetStringStatus(fmiComponent c, const fmiStatusKind s, fmiString* value){
+ return getStatus("fmiGetStringStatus", c, s);
+}
+
+#else
+// ---------------------------------------------------------------------------
+// FMI functions: only for Model Exchange 1.0
+// ---------------------------------------------------------------------------
+
+const char* fmiGetModelTypesPlatform() {
+ return fmiModelTypesPlatform;
+}
+
+fmiComponent fmiInstantiateModel(fmiString instanceName, fmiString GUID,
+ fmiCallbackFunctions functions, fmiBoolean loggingOn) {
+ return instantiateModel("fmiInstantiateModel", instanceName, GUID, functions, loggingOn);
+}
+
+fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled, fmiReal relativeTolerance,
+ fmiEventInfo* eventInfo) {
+ return init("fmiInitialize", c, toleranceControlled, relativeTolerance, eventInfo);
+}
+
+fmiStatus fmiSetTime(fmiComponent c, fmiReal time) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiSetTime", modelInstantiated|modelInitialized))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetTime: time=%.16g", time);
+ comp->time = time;
+ return fmiOK;
+}
+
+fmiStatus fmiSetContinuousStates(fmiComponent c, const fmiReal x[], size_t nx){
+ ModelInstance* comp = (ModelInstance *)c;
+ int i;
+ if (invalidState(comp, "fmiSetContinuousStates", modelInitialized))
+ return fmiError;
+ if (invalidNumber(comp, "fmiSetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmiError;
+ if (nullPointer(comp, "fmiSetContinuousStates", "x[]", x))
+ return fmiError;
+#if NUMBER_OF_STATES>0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiSetContinuousStates: #r%d#=%.16g", vr, x[i]);
+ assert(vrr[vr] = x[i];
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiEventUpdate(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiEventUpdate", modelInitialized))
+ return fmiError;
+ if (nullPointer(comp, "fmiEventUpdate", "eventInfo", eventInfo))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiEventUpdate: intermediateResults = %d", intermediateResults);
+ eventInfo->iterationConverged = fmiTrue;
+ eventInfo->stateValueReferencesChanged = fmiFalse;
+ eventInfo->stateValuesChanged = fmiFalse;
+ eventInfo->terminateSimulation = fmiFalse;
+ eventInfo->upcomingTimeEvent = fmiFalse;
+ eventUpdate(comp, eventInfo); // to be implemented by the includer of this file
+ return fmiOK;
+}
+
+fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate){
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiCompletedIntegratorStep", modelInitialized))
+ return fmiError;
+ if (nullPointer(comp, "fmiCompletedIntegratorStep", "callEventUpdate", callEventUpdate))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiCompletedIntegratorStep");
+ *callEventUpdate = fmiFalse;
+ return fmiOK;
+}
+
+fmiStatus fmiGetStateValueReferences(fmiComponent c, fmiValueReference vrx[], size_t nx){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetStateValueReferences", not_modelError))
+ return fmiError;
+ if (invalidNumber(comp, "fmiGetStateValueReferences", "nx", nx, NUMBER_OF_STATES))
+ return fmiError;
+ if (nullPointer(comp, "fmiGetStateValueReferences", "vrx[]", vrx))
+ return fmiError;
+#if NUMBER_OF_STATES>0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetStateValueReferences: vrx[%d] = %d", i, vrx[i]);
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiGetContinuousStates(fmiComponent c, fmiReal states[], size_t nx){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetContinuousStates", not_modelError))
+ return fmiError;
+ if (invalidNumber(comp, "fmiGetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmiError;
+ if (nullPointer(comp, "fmiGetContinuousStates", "states[]", states))
+ return fmiError;
+#if NUMBER_OF_STATES>0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetContinuousStates: #r%u# = %.16g", vr, states[i]);
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx){
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetNominalContinuousStates", not_modelError))
+ return fmiError;
+ if (invalidNumber(comp, "fmiGetNominalContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmiError;
+ if (nullPointer(comp, "fmiGetNominalContinuousStates", "x_nominal[]", x_nominal))
+ return fmiError;
+ if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetNominalContinuousStates: x_nominal[0..%d] = 1.0", nx-1);
+ for (i=0; i0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetDerivatives: #r%d# = %.16g", vr, derivatives[i]);
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmiGetEventIndicators", not_modelError))
+ return fmiError;
+ if (invalidNumber(comp, "fmiGetEventIndicators", "ni", ni, NUMBER_OF_EVENT_INDICATORS))
+ return fmiError;
+#if NUMBER_OF_EVENT_INDICATORS>0
+ for (i=0; iloggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+ "fmiGetEventIndicators: z%d = %.16g", i, eventIndicators[i]);
+ }
+#endif
+ return fmiOK;
+}
+
+fmiStatus fmiTerminate(fmiComponent c){
+ return terminate("fmiTerminate", c);
+}
+
+void fmiFreeModelInstance(fmiComponent c) {
+ freeInstance("fmiFreeModelInstance", c);
+}
+
+#endif // Model Exchange 1.0
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
diff --git a/fmu10/src/models/fmuTemplate.h b/fmu10/src/models/fmuTemplate.h
new file mode 100644
index 0000000..2364b23
--- /dev/null
+++ b/fmu10/src/models/fmuTemplate.h
@@ -0,0 +1,59 @@
+/* ---------------------------------------------------------------------------*
+ * fmuTemplate.h
+ * Definitions used in fmiModelFunctions.c and by the includer of this file
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FMI_COSIMULATION
+#include "fmiFunctions.h"
+#else
+#include "fmiModelFunctions.h"
+#endif
+
+// macros used to define variables
+#define r(vr) comp->r[vr]
+#define i(vr) comp->i[vr]
+#define b(vr) comp->b[vr]
+#define s(vr) comp->s[vr]
+#define pos(z) comp->isPositive[z]
+#define copy(vr, value) setString(comp, vr, value)
+
+fmiStatus setString(fmiComponent comp, fmiValueReference vr, fmiString value);
+
+#define not_modelError (modelInstantiated|modelInitialized|modelTerminated)
+
+typedef enum {
+ modelInstantiated = 1<<0,
+ modelInitialized = 1<<1,
+ modelTerminated = 1<<2,
+ modelError = 1<<3
+} ModelState;
+
+typedef struct {
+ fmiReal *r;
+ fmiInteger *i;
+ fmiBoolean *b;
+ fmiString *s;
+ fmiBoolean *isPositive;
+ fmiReal time;
+ fmiString instanceName;
+ fmiString GUID;
+ fmiCallbackFunctions functions;
+ fmiBoolean loggingOn;
+ ModelState state;
+#ifdef FMI_COSIMULATION
+ fmiEventInfo eventInfo;
+#endif
+} ModelInstance;
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
diff --git a/fmu10/src/models/inc/Makefile b/fmu10/src/models/inc/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu10/src/models/inc/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu10/src/models/inc/inc.c b/fmu10/src/models/inc/inc.c
new file mode 100644
index 0000000..7e59b4e
--- /dev/null
+++ b/fmu10/src/models/inc/inc.c
@@ -0,0 +1,55 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - increments an int counter every second.
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER inc
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f008}"
+
+// define model size
+#define NUMBER_OF_REALS 0
+#define NUMBER_OF_INTEGERS 1
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 0
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define counter_ 0
+
+// called by fmiInstantiateModel
+// Set values for all variables that define a start value
+// Settings used unless changed by fmiSetX before fmiInitialize
+void setStartValues(ModelInstance *comp) {
+ i(counter_) = 1;
+}
+
+// called by fmiInitialize() after setting eventInfo to defaults
+// Used to set the first time event, if any.
+void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ eventInfo->upcomingTimeEvent = fmiTrue;
+ eventInfo->nextEventTime = 1 + comp->time;
+}
+
+// called by fmiEventUpdate() after setting eventInfo to defaults
+// Used to set the next time event, if any.
+void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ i(counter_) += 1;
+ if (i(counter_) == 13)
+ eventInfo->terminateSimulation = fmiTrue;
+ else {
+ eventInfo->upcomingTimeEvent = fmiTrue;
+ eventInfo->nextEventTime = 1 + comp->time;
+ }
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu10/src/models/inc/index.html b/fmu10/src/models/inc/index.html
new file mode 100644
index 0000000..6d4827a
--- /dev/null
+++ b/fmu10/src/models/inc/index.html
@@ -0,0 +1,22 @@
+
+
+ Documentation for inc.fmu
+
+
+
+inc.fmu
+This FMU generates time events to increment an integer counter every second and terminates simulation at t=12 sec.
+
+
+
+The figure shows the solution computed with Silver.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu10/src/models/inc/model.png b/fmu10/src/models/inc/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu10/src/models/inc/model.png differ
diff --git a/fmu10/src/models/inc/modelDescription.xml b/fmu10/src/models/inc/modelDescription.xml
new file mode 100644
index 0000000..58ce6f8
--- /dev/null
+++ b/fmu10/src/models/inc/modelDescription.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/fmu10/src/models/inc/plot_counter.PNG b/fmu10/src/models/inc/plot_counter.PNG
new file mode 100644
index 0000000..d3ec25d
Binary files /dev/null and b/fmu10/src/models/inc/plot_counter.PNG differ
diff --git a/fmu10/src/models/me.xml b/fmu10/src/models/me.xml
new file mode 100644
index 0000000..5ecace6
--- /dev/null
+++ b/fmu10/src/models/me.xml
@@ -0,0 +1 @@
+
diff --git a/fmu10/src/models/values/Makefile b/fmu10/src/models/values/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu10/src/models/values/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu10/src/models/values/index.html b/fmu10/src/models/values/index.html
new file mode 100644
index 0000000..b6a16b9
--- /dev/null
+++ b/fmu10/src/models/values/index.html
@@ -0,0 +1,23 @@
+
+
+ Documentation for values.fmu
+
+
+
+ values.fmu
+ This FMU demonstrates the use of all four scalar FMU data types
+ and terminates simulation at t=12 sec.
+
+
+The figure shows the solution computed with fmusim using the command
+fmusim me fmu\me\values.fmu 12 12
.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu10/src/models/values/model.png b/fmu10/src/models/values/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu10/src/models/values/model.png differ
diff --git a/fmu10/src/models/values/modelDescription.xml b/fmu10/src/models/values/modelDescription.xml
new file mode 100644
index 0000000..3673a61
--- /dev/null
+++ b/fmu10/src/models/values/modelDescription.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu10/src/models/values/values.PNG b/fmu10/src/models/values/values.PNG
new file mode 100644
index 0000000..45eaf96
Binary files /dev/null and b/fmu10/src/models/values/values.PNG differ
diff --git a/fmu10/src/models/values/values.c b/fmu10/src/models/values/values.c
new file mode 100644
index 0000000..ca76c9b
--- /dev/null
+++ b/fmu10/src/models/values/values.c
@@ -0,0 +1,84 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU.
+ * This demonstrates the use of all FMU variable types.
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER values
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f004}"
+
+// define model size
+#define NUMBER_OF_REALS 2
+#define NUMBER_OF_INTEGERS 2
+#define NUMBER_OF_BOOLEANS 2
+#define NUMBER_OF_STRINGS 2
+#define NUMBER_OF_STATES 1
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x_ 0
+#define der_x_ 1
+#define int_in_ 0
+#define int_out_ 1
+#define bool_in_ 0
+#define bool_out_ 1
+#define string_in_ 0
+#define string_out_ 1
+
+// define state vector as vector of value references
+#define STATES { x_ }
+
+const char* month[] = {
+ "jan","feb","march","april","may","june","july",
+ "august","sept","october","november","december"
+};
+
+// called by fmiInstantiateModel
+// Set values for all variables that define a start value
+// Settings used unless changed by fmiSetX before fmiInitialize
+void setStartValues(ModelInstance *comp) {
+ r(x_) = 1;
+ i(int_in_) = 2;
+ i(int_out_) = 0;
+ b(bool_in_) = fmiTrue;
+ b(bool_out_) = fmiFalse;
+ copy(string_in_, "QTronic");
+ copy(string_out_, month[0]);
+}
+
+// called by fmiInitialize() after setting eventInfo to defaults
+// Used to set the first time event, if any.
+void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ eventInfo->upcomingTimeEvent = fmiTrue;
+ eventInfo->nextEventTime = 1 + comp->time;
+}
+
+// called by fmiGetReal, fmiGetContinuousStates and fmiGetDerivatives
+fmiReal getReal(ModelInstance* comp, fmiValueReference vr){
+ switch (vr) {
+ case x_ : return r(x_);
+ case der_x_ : return - r(x_);
+ default: return 0;
+ }
+}
+
+// called by fmiEventUpdate() after setting eventInfo to defaults
+void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {
+ eventInfo->upcomingTimeEvent = fmiTrue;
+ eventInfo->nextEventTime = 1 + comp->time;
+ i(int_out_) += 1;
+ b(bool_out_) = !b(bool_out_);
+ if (i(int_out_)<12) copy(string_out_, month[i(int_out_)]);
+ else eventInfo->terminateSimulation = fmiTrue;
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu10/src/models/vanDerPol/Makefile b/fmu10/src/models/vanDerPol/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu10/src/models/vanDerPol/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu10/src/models/vanDerPol/index.html b/fmu10/src/models/vanDerPol/index.html
new file mode 100644
index 0000000..528fe10
--- /dev/null
+++ b/fmu10/src/models/vanDerPol/index.html
@@ -0,0 +1,27 @@
+
+
+Documentation for vanDerPol.fmu
+
+
+
+vanDerPol.fmu
+This FMU implements the famous
+Van der Pol oscillator.
+
+- der(x0) = x1
+- der(x1) = mu * ((1 - x0 * x0) * x1) - x0
+
+
+
+The figure shows the solution computed with Silver
+for start values x0 = 2, x1 = 0, mu = 1.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu10/src/models/vanDerPol/model.png b/fmu10/src/models/vanDerPol/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu10/src/models/vanDerPol/model.png differ
diff --git a/fmu10/src/models/vanDerPol/modelDescription.xml b/fmu10/src/models/vanDerPol/modelDescription.xml
new file mode 100644
index 0000000..ca44c3f
--- /dev/null
+++ b/fmu10/src/models/vanDerPol/modelDescription.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu10/src/models/vanDerPol/plot_states.png b/fmu10/src/models/vanDerPol/plot_states.png
new file mode 100644
index 0000000..05761cd
Binary files /dev/null and b/fmu10/src/models/vanDerPol/plot_states.png differ
diff --git a/fmu10/src/models/vanDerPol/vanDerPol.c b/fmu10/src/models/vanDerPol/vanDerPol.c
new file mode 100644
index 0000000..ee6eeb8
--- /dev/null
+++ b/fmu10/src/models/vanDerPol/vanDerPol.c
@@ -0,0 +1,74 @@
+/* ---------------------------------------------------------------------------*
+ * Copyright QTronic GmbH. All rights reserved.
+ * Sample implementation of an FMU - the Van der Pol oscillator.
+ * See http://en.wikipedia.org/wiki/Van_der_Pol_oscillator
+ *
+ * der(x0) = x1
+ * der(x1) = mu * ((1 - x0 ^ 2) * x1) - x0;
+ *
+ * start values: x0=2, x1=0, mue=1
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER vanDerPol
+#define MODEL_GUID "{8c4e810f-3da3-4a00-8276-176fa3c9f000}"
+
+// define model size
+#define NUMBER_OF_REALS 5
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 2
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x0_ 0
+#define der_x0_ 1
+#define x1_ 2
+#define der_x1_ 3
+#define mu_ 4
+
+// define state vector as vector of value references
+#define STATES { x0_, x1_ }
+
+// called by fmiInstantiateModel
+// Set values for all variables that define a start value
+// Settings used unless changed by fmiSetX before fmiInitialize
+void setStartValues(ModelInstance *comp) {
+ r(x0_) = 2;
+ r(x1_) = 0;
+ r(mu_) = 1;
+}
+
+// called by fmiInitialize() after setting eventInfo to defaults
+// Used to set the first time event, if any.
+void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {
+}
+
+// called by fmiGetReal, fmiGetContinuousStates and fmiGetDerivatives
+fmiReal getReal(ModelInstance* comp, fmiValueReference vr){
+ switch (vr) {
+ case x0_ : return r(x0_);
+ case x1_ : return r(x1_);
+ case der_x0_ : return r(x1_);
+ case der_x1_ : return r(mu_) * ((1.0-r(x0_)*r(x0_))*r(x1_)) - r(x0_);
+ case mu_ : return r(mu_);
+ default: return 0;
+ }
+}
+
+// Used to set the next time event, if any.
+void eventUpdate(fmiComponent comp, fmiEventInfo* eventInfo) {
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
+
+
diff --git a/fmu10/src/shared/COPYING.txt b/fmu10/src/shared/COPYING.txt
new file mode 100644
index 0000000..9042217
--- /dev/null
+++ b/fmu10/src/shared/COPYING.txt
@@ -0,0 +1,24 @@
+Files expat.h, expat_external.h and libexpatMT.lib
+
+Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+ and Clark Cooper
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/fmu10/src/shared/expat.h b/fmu10/src/shared/expat.h
new file mode 100644
index 0000000..6c2b6ff
--- /dev/null
+++ b/fmu10/src/shared/expat.h
@@ -0,0 +1,1014 @@
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
+*/
+
+#ifndef Expat_INCLUDED
+#define Expat_INCLUDED 1
+
+#ifdef __VMS
+/* 0 1 2 3 0 1 2 3
+ 1234567890123456789012345678901 1234567890123456789012345678901 */
+#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
+#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler
+#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler
+#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg
+#endif
+
+#include
+#include "expat_external.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct XML_ParserStruct;
+typedef struct XML_ParserStruct *XML_Parser;
+
+/* Should this be defined using stdbool.h when C99 is available? */
+typedef unsigned char XML_Bool;
+#define XML_TRUE ((XML_Bool) 1)
+#define XML_FALSE ((XML_Bool) 0)
+
+/* The XML_Status enum gives the possible return values for several
+ API functions. The preprocessor #defines are included so this
+ stanza can be added to code that still needs to support older
+ versions of Expat 1.95.x:
+
+ #ifndef XML_STATUS_OK
+ #define XML_STATUS_OK 1
+ #define XML_STATUS_ERROR 0
+ #endif
+
+ Otherwise, the #define hackery is quite ugly and would have been
+ dropped.
+*/
+enum XML_Status {
+ XML_STATUS_ERROR = 0,
+#define XML_STATUS_ERROR XML_STATUS_ERROR
+ XML_STATUS_OK = 1,
+#define XML_STATUS_OK XML_STATUS_OK
+ XML_STATUS_SUSPENDED = 2
+#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
+};
+
+enum XML_Error {
+ XML_ERROR_NONE,
+ XML_ERROR_NO_MEMORY,
+ XML_ERROR_SYNTAX,
+ XML_ERROR_NO_ELEMENTS,
+ XML_ERROR_INVALID_TOKEN,
+ XML_ERROR_UNCLOSED_TOKEN,
+ XML_ERROR_PARTIAL_CHAR,
+ XML_ERROR_TAG_MISMATCH,
+ XML_ERROR_DUPLICATE_ATTRIBUTE,
+ XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
+ XML_ERROR_PARAM_ENTITY_REF,
+ XML_ERROR_UNDEFINED_ENTITY,
+ XML_ERROR_RECURSIVE_ENTITY_REF,
+ XML_ERROR_ASYNC_ENTITY,
+ XML_ERROR_BAD_CHAR_REF,
+ XML_ERROR_BINARY_ENTITY_REF,
+ XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
+ XML_ERROR_MISPLACED_XML_PI,
+ XML_ERROR_UNKNOWN_ENCODING,
+ XML_ERROR_INCORRECT_ENCODING,
+ XML_ERROR_UNCLOSED_CDATA_SECTION,
+ XML_ERROR_EXTERNAL_ENTITY_HANDLING,
+ XML_ERROR_NOT_STANDALONE,
+ XML_ERROR_UNEXPECTED_STATE,
+ XML_ERROR_ENTITY_DECLARED_IN_PE,
+ XML_ERROR_FEATURE_REQUIRES_XML_DTD,
+ XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
+ /* Added in 1.95.7. */
+ XML_ERROR_UNBOUND_PREFIX,
+ /* Added in 1.95.8. */
+ XML_ERROR_UNDECLARING_PREFIX,
+ XML_ERROR_INCOMPLETE_PE,
+ XML_ERROR_XML_DECL,
+ XML_ERROR_TEXT_DECL,
+ XML_ERROR_PUBLICID,
+ XML_ERROR_SUSPENDED,
+ XML_ERROR_NOT_SUSPENDED,
+ XML_ERROR_ABORTED,
+ XML_ERROR_FINISHED,
+ XML_ERROR_SUSPEND_PE,
+ /* Added in 2.0. */
+ XML_ERROR_RESERVED_PREFIX_XML,
+ XML_ERROR_RESERVED_PREFIX_XMLNS,
+ XML_ERROR_RESERVED_NAMESPACE_URI
+};
+
+enum XML_Content_Type {
+ XML_CTYPE_EMPTY = 1,
+ XML_CTYPE_ANY,
+ XML_CTYPE_MIXED,
+ XML_CTYPE_NAME,
+ XML_CTYPE_CHOICE,
+ XML_CTYPE_SEQ
+};
+
+enum XML_Content_Quant {
+ XML_CQUANT_NONE,
+ XML_CQUANT_OPT,
+ XML_CQUANT_REP,
+ XML_CQUANT_PLUS
+};
+
+/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
+ XML_CQUANT_NONE, and the other fields will be zero or NULL.
+ If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
+ numchildren will contain number of elements that may be mixed in
+ and children point to an array of XML_Content cells that will be
+ all of XML_CTYPE_NAME type with no quantification.
+
+ If type == XML_CTYPE_NAME, then the name points to the name, and
+ the numchildren field will be zero and children will be NULL. The
+ quant fields indicates any quantifiers placed on the name.
+
+ CHOICE and SEQ will have name NULL, the number of children in
+ numchildren and children will point, recursively, to an array
+ of XML_Content cells.
+
+ The EMPTY, ANY, and MIXED types will only occur at top level.
+*/
+
+typedef struct XML_cp XML_Content;
+
+struct XML_cp {
+ enum XML_Content_Type type;
+ enum XML_Content_Quant quant;
+ XML_Char * name;
+ unsigned int numchildren;
+ XML_Content * children;
+};
+
+
+/* This is called for an element declaration. See above for
+ description of the model argument. It's the caller's responsibility
+ to free model when finished with it.
+*/
+typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
+ const XML_Char *name,
+ XML_Content *model);
+
+XMLPARSEAPI(void)
+XML_SetElementDeclHandler(XML_Parser parser,
+ XML_ElementDeclHandler eldecl);
+
+/* The Attlist declaration handler is called for *each* attribute. So
+ a single Attlist declaration with multiple attributes declared will
+ generate multiple calls to this handler. The "default" parameter
+ may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
+ keyword. The "isrequired" parameter will be true and the default
+ value will be NULL in the case of "#REQUIRED". If "isrequired" is
+ true and default is non-NULL, then this is a "#FIXED" default.
+*/
+typedef void (XMLCALL *XML_AttlistDeclHandler) (
+ void *userData,
+ const XML_Char *elname,
+ const XML_Char *attname,
+ const XML_Char *att_type,
+ const XML_Char *dflt,
+ int isrequired);
+
+XMLPARSEAPI(void)
+XML_SetAttlistDeclHandler(XML_Parser parser,
+ XML_AttlistDeclHandler attdecl);
+
+/* The XML declaration handler is called for *both* XML declarations
+ and text declarations. The way to distinguish is that the version
+ parameter will be NULL for text declarations. The encoding
+ parameter may be NULL for XML declarations. The standalone
+ parameter will be -1, 0, or 1 indicating respectively that there
+ was no standalone parameter in the declaration, that it was given
+ as no, or that it was given as yes.
+*/
+typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData,
+ const XML_Char *version,
+ const XML_Char *encoding,
+ int standalone);
+
+XMLPARSEAPI(void)
+XML_SetXmlDeclHandler(XML_Parser parser,
+ XML_XmlDeclHandler xmldecl);
+
+
+typedef struct {
+ void *(*malloc_fcn)(size_t size);
+ void *(*realloc_fcn)(void *ptr, size_t size);
+ void (*free_fcn)(void *ptr);
+} XML_Memory_Handling_Suite;
+
+/* Constructs a new parser; encoding is the encoding specified by the
+ external protocol or NULL if there is none specified.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreate(const XML_Char *encoding);
+
+/* Constructs a new parser and namespace processor. Element type
+ names and attribute names that belong to a namespace will be
+ expanded; unprefixed attribute names are never expanded; unprefixed
+ element type names are expanded only if there is a default
+ namespace. The expanded name is the concatenation of the namespace
+ URI, the namespace separator character, and the local part of the
+ name. If the namespace separator is '\0' then the namespace URI
+ and the local part will be concatenated without any separator.
+ It is a programming error to use the separator '\0' with namespace
+ triplets (see XML_SetReturnNSTriplet).
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
+
+
+/* Constructs a new parser using the memory management suite referred to
+ by memsuite. If memsuite is NULL, then use the standard library memory
+ suite. If namespaceSeparator is non-NULL it creates a parser with
+ namespace processing as described above. The character pointed at
+ will serve as the namespace separator.
+
+ All further memory operations used for the created parser will come from
+ the given suite.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreate_MM(const XML_Char *encoding,
+ const XML_Memory_Handling_Suite *memsuite,
+ const XML_Char *namespaceSeparator);
+
+/* Prepare a parser object to be re-used. This is particularly
+ valuable when memory allocation overhead is disproportionatly high,
+ such as when a large number of small documnents need to be parsed.
+ All handlers are cleared from the parser, except for the
+ unknownEncodingHandler. The parser's external state is re-initialized
+ except for the values of ns and ns_triplets.
+
+ Added in Expat 1.95.3.
+*/
+XMLPARSEAPI(XML_Bool)
+XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
+
+/* atts is array of name/value pairs, terminated by 0;
+ names and values are 0 terminated.
+*/
+typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
+ const XML_Char *name,
+ const XML_Char **atts);
+
+typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
+ const XML_Char *name);
+
+
+/* s is not 0 terminated. */
+typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
+ const XML_Char *s,
+ int len);
+
+/* target and data are 0 terminated */
+typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
+ void *userData,
+ const XML_Char *target,
+ const XML_Char *data);
+
+/* data is 0 terminated */
+typedef void (XMLCALL *XML_CommentHandler) (void *userData,
+ const XML_Char *data);
+
+typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
+typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
+
+/* This is called for any characters in the XML document for which
+ there is no applicable handler. This includes both characters that
+ are part of markup which is of a kind that is not reported
+ (comments, markup declarations), or characters that are part of a
+ construct which could be reported but for which no handler has been
+ supplied. The characters are passed exactly as they were in the XML
+ document except that they will be encoded in UTF-8 or UTF-16.
+ Line boundaries are not normalized. Note that a byte order mark
+ character is not passed to the default handler. There are no
+ guarantees about how characters are divided between calls to the
+ default handler: for example, a comment might be split between
+ multiple calls.
+*/
+typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
+ const XML_Char *s,
+ int len);
+
+/* This is called for the start of the DOCTYPE declaration, before
+ any DTD or internal subset is parsed.
+*/
+typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
+ void *userData,
+ const XML_Char *doctypeName,
+ const XML_Char *sysid,
+ const XML_Char *pubid,
+ int has_internal_subset);
+
+/* This is called for the start of the DOCTYPE declaration when the
+ closing > is encountered, but after processing any external
+ subset.
+*/
+typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
+
+/* This is called for entity declarations. The is_parameter_entity
+ argument will be non-zero if the entity is a parameter entity, zero
+ otherwise.
+
+ For internal entities (), value will
+ be non-NULL and systemId, publicID, and notationName will be NULL.
+ The value string is NOT nul-terminated; the length is provided in
+ the value_length argument. Since it is legal to have zero-length
+ values, do not use this argument to test for internal entities.
+
+ For external entities, value will be NULL and systemId will be
+ non-NULL. The publicId argument will be NULL unless a public
+ identifier was provided. The notationName argument will have a
+ non-NULL value only for unparsed entity declarations.
+
+ Note that is_parameter_entity can't be changed to XML_Bool, since
+ that would break binary compatibility.
+*/
+typedef void (XMLCALL *XML_EntityDeclHandler) (
+ void *userData,
+ const XML_Char *entityName,
+ int is_parameter_entity,
+ const XML_Char *value,
+ int value_length,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName);
+
+XMLPARSEAPI(void)
+XML_SetEntityDeclHandler(XML_Parser parser,
+ XML_EntityDeclHandler handler);
+
+/* OBSOLETE -- OBSOLETE -- OBSOLETE
+ This handler has been superceded by the EntityDeclHandler above.
+ It is provided here for backward compatibility.
+
+ This is called for a declaration of an unparsed (NDATA) entity.
+ The base argument is whatever was set by XML_SetBase. The
+ entityName, systemId and notationName arguments will never be
+ NULL. The other arguments may be.
+*/
+typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
+ void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName);
+
+/* This is called for a declaration of notation. The base argument is
+ whatever was set by XML_SetBase. The notationName will never be
+ NULL. The other arguments can be.
+*/
+typedef void (XMLCALL *XML_NotationDeclHandler) (
+ void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+
+/* When namespace processing is enabled, these are called once for
+ each namespace declaration. The call to the start and end element
+ handlers occur between the calls to the start and end namespace
+ declaration handlers. For an xmlns attribute, prefix will be
+ NULL. For an xmlns="" attribute, uri will be NULL.
+*/
+typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
+ void *userData,
+ const XML_Char *prefix,
+ const XML_Char *uri);
+
+typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
+ void *userData,
+ const XML_Char *prefix);
+
+/* This is called if the document is not standalone, that is, it has an
+ external subset or a reference to a parameter entity, but does not
+ have standalone="yes". If this handler returns XML_STATUS_ERROR,
+ then processing will not continue, and the parser will return a
+ XML_ERROR_NOT_STANDALONE error.
+ If parameter entity parsing is enabled, then in addition to the
+ conditions above this handler will only be called if the referenced
+ entity was actually read.
+*/
+typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
+
+/* This is called for a reference to an external parsed general
+ entity. The referenced entity is not automatically parsed. The
+ application can parse it immediately or later using
+ XML_ExternalEntityParserCreate.
+
+ The parser argument is the parser parsing the entity containing the
+ reference; it can be passed as the parser argument to
+ XML_ExternalEntityParserCreate. The systemId argument is the
+ system identifier as specified in the entity declaration; it will
+ not be NULL.
+
+ The base argument is the system identifier that should be used as
+ the base for resolving systemId if systemId was relative; this is
+ set by XML_SetBase; it may be NULL.
+
+ The publicId argument is the public identifier as specified in the
+ entity declaration, or NULL if none was specified; the whitespace
+ in the public identifier will have been normalized as required by
+ the XML spec.
+
+ The context argument specifies the parsing context in the format
+ expected by the context argument to XML_ExternalEntityParserCreate;
+ context is valid only until the handler returns, so if the
+ referenced entity is to be parsed later, it must be copied.
+ context is NULL only when the entity is a parameter entity.
+
+ The handler should return XML_STATUS_ERROR if processing should not
+ continue because of a fatal error in the handling of the external
+ entity. In this case the calling parser will return an
+ XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
+
+ Note that unlike other handlers the first argument is the parser,
+ not userData.
+*/
+typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
+ XML_Parser parser,
+ const XML_Char *context,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+
+/* This is called in two situations:
+ 1) An entity reference is encountered for which no declaration
+ has been read *and* this is not an error.
+ 2) An internal entity reference is read, but not expanded, because
+ XML_SetDefaultHandler has been called.
+ Note: skipped parameter entities in declarations and skipped general
+ entities in attribute values cannot be reported, because
+ the event would be out of sync with the reporting of the
+ declarations or attribute values
+*/
+typedef void (XMLCALL *XML_SkippedEntityHandler) (
+ void *userData,
+ const XML_Char *entityName,
+ int is_parameter_entity);
+
+/* This structure is filled in by the XML_UnknownEncodingHandler to
+ provide information to the parser about encodings that are unknown
+ to the parser.
+
+ The map[b] member gives information about byte sequences whose
+ first byte is b.
+
+ If map[b] is c where c is >= 0, then b by itself encodes the
+ Unicode scalar value c.
+
+ If map[b] is -1, then the byte sequence is malformed.
+
+ If map[b] is -n, where n >= 2, then b is the first byte of an
+ n-byte sequence that encodes a single Unicode scalar value.
+
+ The data member will be passed as the first argument to the convert
+ function.
+
+ The convert function is used to convert multibyte sequences; s will
+ point to a n-byte sequence where map[(unsigned char)*s] == -n. The
+ convert function must return the Unicode scalar value represented
+ by this byte sequence or -1 if the byte sequence is malformed.
+
+ The convert function may be NULL if the encoding is a single-byte
+ encoding, that is if map[b] >= -1 for all bytes b.
+
+ When the parser is finished with the encoding, then if release is
+ not NULL, it will call release passing it the data member; once
+ release has been called, the convert function will not be called
+ again.
+
+ Expat places certain restrictions on the encodings that are supported
+ using this mechanism.
+
+ 1. Every ASCII character that can appear in a well-formed XML document,
+ other than the characters
+
+ $@\^`{}~
+
+ must be represented by a single byte, and that byte must be the
+ same byte that represents that character in ASCII.
+
+ 2. No character may require more than 4 bytes to encode.
+
+ 3. All characters encoded must have Unicode scalar values <=
+ 0xFFFF, (i.e., characters that would be encoded by surrogates in
+ UTF-16 are not allowed). Note that this restriction doesn't
+ apply to the built-in support for UTF-8 and UTF-16.
+
+ 4. No Unicode character may be encoded by more than one distinct
+ sequence of bytes.
+*/
+typedef struct {
+ int map[256];
+ void *data;
+ int (XMLCALL *convert)(void *data, const char *s);
+ void (XMLCALL *release)(void *data);
+} XML_Encoding;
+
+/* This is called for an encoding that is unknown to the parser.
+
+ The encodingHandlerData argument is that which was passed as the
+ second argument to XML_SetUnknownEncodingHandler.
+
+ The name argument gives the name of the encoding as specified in
+ the encoding declaration.
+
+ If the callback can provide information about the encoding, it must
+ fill in the XML_Encoding structure, and return XML_STATUS_OK.
+ Otherwise it must return XML_STATUS_ERROR.
+
+ If info does not describe a suitable encoding, then the parser will
+ return an XML_UNKNOWN_ENCODING error.
+*/
+typedef int (XMLCALL *XML_UnknownEncodingHandler) (
+ void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info);
+
+XMLPARSEAPI(void)
+XML_SetElementHandler(XML_Parser parser,
+ XML_StartElementHandler start,
+ XML_EndElementHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartElementHandler(XML_Parser parser,
+ XML_StartElementHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetEndElementHandler(XML_Parser parser,
+ XML_EndElementHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetCharacterDataHandler(XML_Parser parser,
+ XML_CharacterDataHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetProcessingInstructionHandler(XML_Parser parser,
+ XML_ProcessingInstructionHandler handler);
+XMLPARSEAPI(void)
+XML_SetCommentHandler(XML_Parser parser,
+ XML_CommentHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetCdataSectionHandler(XML_Parser parser,
+ XML_StartCdataSectionHandler start,
+ XML_EndCdataSectionHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartCdataSectionHandler(XML_Parser parser,
+ XML_StartCdataSectionHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndCdataSectionHandler(XML_Parser parser,
+ XML_EndCdataSectionHandler end);
+
+/* This sets the default handler and also inhibits expansion of
+ internal entities. These entity references will be passed to the
+ default handler, or to the skipped entity handler, if one is set.
+*/
+XMLPARSEAPI(void)
+XML_SetDefaultHandler(XML_Parser parser,
+ XML_DefaultHandler handler);
+
+/* This sets the default handler but does not inhibit expansion of
+ internal entities. The entity reference will not be passed to the
+ default handler.
+*/
+XMLPARSEAPI(void)
+XML_SetDefaultHandlerExpand(XML_Parser parser,
+ XML_DefaultHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetDoctypeDeclHandler(XML_Parser parser,
+ XML_StartDoctypeDeclHandler start,
+ XML_EndDoctypeDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartDoctypeDeclHandler(XML_Parser parser,
+ XML_StartDoctypeDeclHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndDoctypeDeclHandler(XML_Parser parser,
+ XML_EndDoctypeDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
+ XML_UnparsedEntityDeclHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetNotationDeclHandler(XML_Parser parser,
+ XML_NotationDeclHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetNamespaceDeclHandler(XML_Parser parser,
+ XML_StartNamespaceDeclHandler start,
+ XML_EndNamespaceDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartNamespaceDeclHandler(XML_Parser parser,
+ XML_StartNamespaceDeclHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndNamespaceDeclHandler(XML_Parser parser,
+ XML_EndNamespaceDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetNotStandaloneHandler(XML_Parser parser,
+ XML_NotStandaloneHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetExternalEntityRefHandler(XML_Parser parser,
+ XML_ExternalEntityRefHandler handler);
+
+/* If a non-NULL value for arg is specified here, then it will be
+ passed as the first argument to the external entity ref handler
+ instead of the parser object.
+*/
+XMLPARSEAPI(void)
+XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
+ void *arg);
+
+XMLPARSEAPI(void)
+XML_SetSkippedEntityHandler(XML_Parser parser,
+ XML_SkippedEntityHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetUnknownEncodingHandler(XML_Parser parser,
+ XML_UnknownEncodingHandler handler,
+ void *encodingHandlerData);
+
+/* This can be called within a handler for a start element, end
+ element, processing instruction or character data. It causes the
+ corresponding markup to be passed to the default handler.
+*/
+XMLPARSEAPI(void)
+XML_DefaultCurrent(XML_Parser parser);
+
+/* If do_nst is non-zero, and namespace processing is in effect, and
+ a name has a prefix (i.e. an explicit namespace qualifier) then
+ that name is returned as a triplet in a single string separated by
+ the separator character specified when the parser was created: URI
+ + sep + local_name + sep + prefix.
+
+ If do_nst is zero, then namespace information is returned in the
+ default manner (URI + sep + local_name) whether or not the name
+ has a prefix.
+
+ Note: Calling XML_SetReturnNSTriplet after XML_Parse or
+ XML_ParseBuffer has no effect.
+*/
+
+XMLPARSEAPI(void)
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
+
+/* This value is passed as the userData argument to callbacks. */
+XMLPARSEAPI(void)
+XML_SetUserData(XML_Parser parser, void *userData);
+
+/* Returns the last value set by XML_SetUserData or NULL. */
+#define XML_GetUserData(parser) (*(void **)(parser))
+
+/* This is equivalent to supplying an encoding argument to
+ XML_ParserCreate. On success XML_SetEncoding returns non-zero,
+ zero otherwise.
+ Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
+ has no effect and returns XML_STATUS_ERROR.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
+
+/* If this function is called, then the parser will be passed as the
+ first argument to callbacks instead of userData. The userData will
+ still be accessible using XML_GetUserData.
+*/
+XMLPARSEAPI(void)
+XML_UseParserAsHandlerArg(XML_Parser parser);
+
+/* If useDTD == XML_TRUE is passed to this function, then the parser
+ will assume that there is an external subset, even if none is
+ specified in the document. In such a case the parser will call the
+ externalEntityRefHandler with a value of NULL for the systemId
+ argument (the publicId and context arguments will be NULL as well).
+ Note: For the purpose of checking WFC: Entity Declared, passing
+ useDTD == XML_TRUE will make the parser behave as if the document
+ had a DTD with an external subset.
+ Note: If this function is called, then this must be done before
+ the first call to XML_Parse or XML_ParseBuffer, since it will
+ have no effect after that. Returns
+ XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
+ Note: If the document does not have a DOCTYPE declaration at all,
+ then startDoctypeDeclHandler and endDoctypeDeclHandler will not
+ be called, despite an external subset being parsed.
+ Note: If XML_DTD is not defined when Expat is compiled, returns
+ XML_ERROR_FEATURE_REQUIRES_XML_DTD.
+*/
+XMLPARSEAPI(enum XML_Error)
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
+
+
+/* Sets the base to be used for resolving relative URIs in system
+ identifiers in declarations. Resolving relative identifiers is
+ left to the application: this value will be passed through as the
+ base argument to the XML_ExternalEntityRefHandler,
+ XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
+ argument will be copied. Returns XML_STATUS_ERROR if out of memory,
+ XML_STATUS_OK otherwise.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_SetBase(XML_Parser parser, const XML_Char *base);
+
+XMLPARSEAPI(const XML_Char *)
+XML_GetBase(XML_Parser parser);
+
+/* Returns the number of the attribute/value pairs passed in last call
+ to the XML_StartElementHandler that were specified in the start-tag
+ rather than defaulted. Each attribute/value pair counts as 2; thus
+ this correspondds to an index into the atts array passed to the
+ XML_StartElementHandler.
+*/
+XMLPARSEAPI(int)
+XML_GetSpecifiedAttributeCount(XML_Parser parser);
+
+/* Returns the index of the ID attribute passed in the last call to
+ XML_StartElementHandler, or -1 if there is no ID attribute. Each
+ attribute/value pair counts as 2; thus this correspondds to an
+ index into the atts array passed to the XML_StartElementHandler.
+*/
+XMLPARSEAPI(int)
+XML_GetIdAttributeIndex(XML_Parser parser);
+
+/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
+ detected. The last call to XML_Parse must have isFinal true; len
+ may be zero for this call (or any other).
+
+ Though the return values for these functions has always been
+ described as a Boolean value, the implementation, at least for the
+ 1.95.x series, has always returned exactly one of the XML_Status
+ values.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
+
+XMLPARSEAPI(void *)
+XML_GetBuffer(XML_Parser parser, int len);
+
+XMLPARSEAPI(enum XML_Status)
+XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
+
+/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
+ Must be called from within a call-back handler, except when aborting
+ (resumable = 0) an already suspended parser. Some call-backs may
+ still follow because they would otherwise get lost. Examples:
+ - endElementHandler() for empty elements when stopped in
+ startElementHandler(),
+ - endNameSpaceDeclHandler() when stopped in endElementHandler(),
+ and possibly others.
+
+ Can be called from most handlers, including DTD related call-backs,
+ except when parsing an external parameter entity and resumable != 0.
+ Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
+ Possible error codes:
+ - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
+ - XML_ERROR_FINISHED: when the parser has already finished.
+ - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
+
+ When resumable != 0 (true) then parsing is suspended, that is,
+ XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
+ Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
+ return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
+
+ *Note*:
+ This will be applied to the current parser instance only, that is, if
+ there is a parent parser then it will continue parsing when the
+ externalEntityRefHandler() returns. It is up to the implementation of
+ the externalEntityRefHandler() to call XML_StopParser() on the parent
+ parser (recursively), if one wants to stop parsing altogether.
+
+ When suspended, parsing can be resumed by calling XML_ResumeParser().
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_StopParser(XML_Parser parser, XML_Bool resumable);
+
+/* Resumes parsing after it has been suspended with XML_StopParser().
+ Must not be called from within a handler call-back. Returns same
+ status codes as XML_Parse() or XML_ParseBuffer().
+ Additional error code XML_ERROR_NOT_SUSPENDED possible.
+
+ *Note*:
+ This must be called on the most deeply nested child parser instance
+ first, and on its parent parser only after the child parser has finished,
+ to be applied recursively until the document entity's parser is restarted.
+ That is, the parent parser will not resume by itself and it is up to the
+ application to call XML_ResumeParser() on it at the appropriate moment.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_ResumeParser(XML_Parser parser);
+
+enum XML_Parsing {
+ XML_INITIALIZED,
+ XML_PARSING,
+ XML_FINISHED,
+ XML_SUSPENDED
+};
+
+typedef struct {
+ enum XML_Parsing parsing;
+ XML_Bool finalBuffer;
+} XML_ParsingStatus;
+
+/* Returns status of parser with respect to being initialized, parsing,
+ finished, or suspended and processing the final buffer.
+ XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
+ XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
+*/
+XMLPARSEAPI(void)
+XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
+
+/* Creates an XML_Parser object that can parse an external general
+ entity; context is a '\0'-terminated string specifying the parse
+ context; encoding is a '\0'-terminated string giving the name of
+ the externally specified encoding, or NULL if there is no
+ externally specified encoding. The context string consists of a
+ sequence of tokens separated by formfeeds (\f); a token consisting
+ of a name specifies that the general entity of the name is open; a
+ token of the form prefix=uri specifies the namespace for a
+ particular prefix; a token of the form =uri specifies the default
+ namespace. This can be called at any point after the first call to
+ an ExternalEntityRefHandler so longer as the parser has not yet
+ been freed. The new parser is completely independent and may
+ safely be used in a separate thread. The handlers and userData are
+ initialized from the parser argument. Returns NULL if out of memory.
+ Otherwise returns a new XML_Parser object.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ExternalEntityParserCreate(XML_Parser parser,
+ const XML_Char *context,
+ const XML_Char *encoding);
+
+enum XML_ParamEntityParsing {
+ XML_PARAM_ENTITY_PARSING_NEVER,
+ XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
+ XML_PARAM_ENTITY_PARSING_ALWAYS
+};
+
+/* Controls parsing of parameter entities (including the external DTD
+ subset). If parsing of parameter entities is enabled, then
+ references to external parameter entities (including the external
+ DTD subset) will be passed to the handler set with
+ XML_SetExternalEntityRefHandler. The context passed will be 0.
+
+ Unlike external general entities, external parameter entities can
+ only be parsed synchronously. If the external parameter entity is
+ to be parsed, it must be parsed during the call to the external
+ entity ref handler: the complete sequence of
+ XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
+ XML_ParserFree calls must be made during this call. After
+ XML_ExternalEntityParserCreate has been called to create the parser
+ for the external parameter entity (context must be 0 for this
+ call), it is illegal to make any calls on the old parser until
+ XML_ParserFree has been called on the newly created parser.
+ If the library has been compiled without support for parameter
+ entity parsing (ie without XML_DTD being defined), then
+ XML_SetParamEntityParsing will return 0 if parsing of parameter
+ entities is requested; otherwise it will return non-zero.
+ Note: If XML_SetParamEntityParsing is called after XML_Parse or
+ XML_ParseBuffer, then it has no effect and will always return 0.
+*/
+XMLPARSEAPI(int)
+XML_SetParamEntityParsing(XML_Parser parser,
+ enum XML_ParamEntityParsing parsing);
+
+/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
+ XML_GetErrorCode returns information about the error.
+*/
+XMLPARSEAPI(enum XML_Error)
+XML_GetErrorCode(XML_Parser parser);
+
+/* These functions return information about the current parse
+ location. They may be called from any callback called to report
+ some parse event; in this case the location is the location of the
+ first of the sequence of characters that generated the event. When
+ called from callbacks generated by declarations in the document
+ prologue, the location identified isn't as neatly defined, but will
+ be within the relevant markup. When called outside of the callback
+ functions, the position indicated will be just past the last parse
+ event (regardless of whether there was an associated callback).
+
+ They may also be called after returning from a call to XML_Parse
+ or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
+ the location is the location of the character at which the error
+ was detected; otherwise the location is the location of the last
+ parse event, as described above.
+*/
+XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
+XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
+XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
+
+/* Return the number of bytes in the current event.
+ Returns 0 if the event is in an internal entity.
+*/
+XMLPARSEAPI(int)
+XML_GetCurrentByteCount(XML_Parser parser);
+
+/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
+ the integer pointed to by offset to the offset within this buffer
+ of the current parse position, and sets the integer pointed to by size
+ to the size of this buffer (the number of input bytes). Otherwise
+ returns a NULL pointer. Also returns a NULL pointer if a parse isn't
+ active.
+
+ NOTE: The character pointer returned should not be used outside
+ the handler that makes the call.
+*/
+XMLPARSEAPI(const char *)
+XML_GetInputContext(XML_Parser parser,
+ int *offset,
+ int *size);
+
+/* For backwards compatibility with previous versions. */
+#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
+#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
+#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
+
+/* Frees the content model passed to the element declaration handler */
+XMLPARSEAPI(void)
+XML_FreeContentModel(XML_Parser parser, XML_Content *model);
+
+/* Exposing the memory handling functions used in Expat */
+XMLPARSEAPI(void *)
+XML_MemMalloc(XML_Parser parser, size_t size);
+
+XMLPARSEAPI(void *)
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
+
+XMLPARSEAPI(void)
+XML_MemFree(XML_Parser parser, void *ptr);
+
+/* Frees memory used by the parser. */
+XMLPARSEAPI(void)
+XML_ParserFree(XML_Parser parser);
+
+/* Returns a string describing the error. */
+XMLPARSEAPI(const XML_LChar *)
+XML_ErrorString(enum XML_Error code);
+
+/* Return a string containing the version number of this expat */
+XMLPARSEAPI(const XML_LChar *)
+XML_ExpatVersion(void);
+
+typedef struct {
+ int major;
+ int minor;
+ int micro;
+} XML_Expat_Version;
+
+/* Return an XML_Expat_Version structure containing numeric version
+ number information for this version of expat.
+*/
+XMLPARSEAPI(XML_Expat_Version)
+XML_ExpatVersionInfo(void);
+
+/* Added in Expat 1.95.5. */
+enum XML_FeatureEnum {
+ XML_FEATURE_END = 0,
+ XML_FEATURE_UNICODE,
+ XML_FEATURE_UNICODE_WCHAR_T,
+ XML_FEATURE_DTD,
+ XML_FEATURE_CONTEXT_BYTES,
+ XML_FEATURE_MIN_SIZE,
+ XML_FEATURE_SIZEOF_XML_CHAR,
+ XML_FEATURE_SIZEOF_XML_LCHAR,
+ XML_FEATURE_NS,
+ XML_FEATURE_LARGE_SIZE
+ /* Additional features must be added to the end of this enum. */
+};
+
+typedef struct {
+ enum XML_FeatureEnum feature;
+ const XML_LChar *name;
+ long int value;
+} XML_Feature;
+
+XMLPARSEAPI(const XML_Feature *)
+XML_GetFeatureList(void);
+
+
+/* Expat follows the GNU/Linux convention of odd number minor version for
+ beta/development releases and even number minor version for stable
+ releases. Micro is bumped with each release, and set to 0 with each
+ change to major or minor version.
+*/
+#define XML_MAJOR_VERSION 2
+#define XML_MINOR_VERSION 0
+#define XML_MICRO_VERSION 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not Expat_INCLUDED */
diff --git a/fmu10/src/shared/expat_external.h b/fmu10/src/shared/expat_external.h
new file mode 100644
index 0000000..bb83a99
--- /dev/null
+++ b/fmu10/src/shared/expat_external.h
@@ -0,0 +1,115 @@
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
+*/
+
+#ifndef Expat_External_INCLUDED
+#define Expat_External_INCLUDED 1
+
+/* External API definitions */
+
+#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
+#define XML_USE_MSC_EXTENSIONS 1
+#endif
+
+/* Expat tries very hard to make the API boundary very specifically
+ defined. There are two macros defined to control this boundary;
+ each of these can be defined before including this header to
+ achieve some different behavior, but doing so it not recommended or
+ tested frequently.
+
+ XMLCALL - The calling convention to use for all calls across the
+ "library boundary." This will default to cdecl, and
+ try really hard to tell the compiler that's what we
+ want.
+
+ XMLIMPORT - Whatever magic is needed to note that a function is
+ to be imported from a dynamically loaded library
+ (.dll, .so, or .sl, depending on your platform).
+
+ The XMLCALL macro was added in Expat 1.95.7. The only one which is
+ expected to be directly useful in client code is XMLCALL.
+
+ Note that on at least some Unix versions, the Expat library must be
+ compiled with the cdecl calling convention as the default since
+ system headers may assume the cdecl convention.
+*/
+#ifndef XMLCALL
+#if defined(_MSC_VER)
+#define XMLCALL __cdecl
+#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
+#define XMLCALL __attribute__((cdecl))
+#else
+/* For any platform which uses this definition and supports more than
+ one calling convention, we need to extend this definition to
+ declare the convention used on that platform, if it's possible to
+ do so.
+
+ If this is the case for your platform, please file a bug report
+ with information on how to identify your platform via the C
+ pre-processor and how to specify the same calling convention as the
+ platform's malloc() implementation.
+*/
+#define XMLCALL
+#endif
+#endif /* not defined XMLCALL */
+
+
+#if !defined(XML_STATIC) && !defined(XMLIMPORT)
+#ifndef XML_BUILDING_EXPAT
+/* using Expat from an application */
+
+#ifdef XML_USE_MSC_EXTENSIONS
+#define XMLIMPORT __declspec(dllimport)
+#endif
+
+#endif
+#endif /* not defined XML_STATIC */
+
+
+/* If we didn't define it above, define it away: */
+#ifndef XMLIMPORT
+#define XMLIMPORT
+#endif
+
+
+#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef XML_UNICODE_WCHAR_T
+#define XML_UNICODE
+#endif
+
+#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
+#ifdef XML_UNICODE_WCHAR_T
+typedef wchar_t XML_Char;
+typedef wchar_t XML_LChar;
+#else
+typedef unsigned short XML_Char;
+typedef char XML_LChar;
+#endif /* XML_UNICODE_WCHAR_T */
+#else /* Information is UTF-8 encoded. */
+typedef char XML_Char;
+typedef char XML_LChar;
+#endif /* XML_UNICODE */
+
+#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
+#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
+typedef __int64 XML_Index;
+typedef unsigned __int64 XML_Size;
+#else
+typedef long long XML_Index;
+typedef unsigned long long XML_Size;
+#endif
+#else
+typedef long XML_Index;
+typedef unsigned long XML_Size;
+#endif /* XML_LARGE_SIZE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not Expat_External_INCLUDED */
diff --git a/fmu10/src/shared/libexpatMT.lib b/fmu10/src/shared/libexpatMT.lib
new file mode 100644
index 0000000..2436f61
Binary files /dev/null and b/fmu10/src/shared/libexpatMT.lib differ
diff --git a/fmu10/src/shared/libxml/SAX.h b/fmu10/src/shared/libxml/SAX.h
new file mode 100644
index 0000000..20093ce
--- /dev/null
+++ b/fmu10/src/shared/libxml/SAX.h
@@ -0,0 +1,173 @@
+/*
+ * Summary: Old SAX version 1 handler, deprecated
+ * Description: DEPRECATED set of SAX version 1 interfaces used to
+ * build the DOM tree.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+
+#ifndef __XML_SAX_H__
+#define __XML_SAX_H__
+
+#include
+#include
+#include
+#include
+#include
+
+#ifdef LIBXML_LEGACY_ENABLED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+XMLPUBFUN const xmlChar * XMLCALL
+ getPublicId (void *ctx);
+XMLPUBFUN const xmlChar * XMLCALL
+ getSystemId (void *ctx);
+XMLPUBFUN void XMLCALL
+ setDocumentLocator (void *ctx,
+ xmlSAXLocatorPtr loc);
+
+XMLPUBFUN int XMLCALL
+ getLineNumber (void *ctx);
+XMLPUBFUN int XMLCALL
+ getColumnNumber (void *ctx);
+
+XMLPUBFUN int XMLCALL
+ isStandalone (void *ctx);
+XMLPUBFUN int XMLCALL
+ hasInternalSubset (void *ctx);
+XMLPUBFUN int XMLCALL
+ hasExternalSubset (void *ctx);
+
+XMLPUBFUN void XMLCALL
+ internalSubset (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN void XMLCALL
+ externalSubset (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ getEntity (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ getParameterEntity (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ resolveEntity (void *ctx,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+
+XMLPUBFUN void XMLCALL
+ entityDecl (void *ctx,
+ const xmlChar *name,
+ int type,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ xmlChar *content);
+XMLPUBFUN void XMLCALL
+ attributeDecl (void *ctx,
+ const xmlChar *elem,
+ const xmlChar *fullname,
+ int type,
+ int def,
+ const xmlChar *defaultValue,
+ xmlEnumerationPtr tree);
+XMLPUBFUN void XMLCALL
+ elementDecl (void *ctx,
+ const xmlChar *name,
+ int type,
+ xmlElementContentPtr content);
+XMLPUBFUN void XMLCALL
+ notationDecl (void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+XMLPUBFUN void XMLCALL
+ unparsedEntityDecl (void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ const xmlChar *notationName);
+
+XMLPUBFUN void XMLCALL
+ startDocument (void *ctx);
+XMLPUBFUN void XMLCALL
+ endDocument (void *ctx);
+XMLPUBFUN void XMLCALL
+ attribute (void *ctx,
+ const xmlChar *fullname,
+ const xmlChar *value);
+XMLPUBFUN void XMLCALL
+ startElement (void *ctx,
+ const xmlChar *fullname,
+ const xmlChar **atts);
+XMLPUBFUN void XMLCALL
+ endElement (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN void XMLCALL
+ reference (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN void XMLCALL
+ characters (void *ctx,
+ const xmlChar *ch,
+ int len);
+XMLPUBFUN void XMLCALL
+ ignorableWhitespace (void *ctx,
+ const xmlChar *ch,
+ int len);
+XMLPUBFUN void XMLCALL
+ processingInstruction (void *ctx,
+ const xmlChar *target,
+ const xmlChar *data);
+XMLPUBFUN void XMLCALL
+ globalNamespace (void *ctx,
+ const xmlChar *href,
+ const xmlChar *prefix);
+XMLPUBFUN void XMLCALL
+ setNamespace (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN xmlNsPtr XMLCALL
+ getNamespace (void *ctx);
+XMLPUBFUN int XMLCALL
+ checkNamespace (void *ctx,
+ xmlChar *nameSpace);
+XMLPUBFUN void XMLCALL
+ namespaceDecl (void *ctx,
+ const xmlChar *href,
+ const xmlChar *prefix);
+XMLPUBFUN void XMLCALL
+ comment (void *ctx,
+ const xmlChar *value);
+XMLPUBFUN void XMLCALL
+ cdataBlock (void *ctx,
+ const xmlChar *value,
+ int len);
+
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN void XMLCALL
+ initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
+ int warning);
+#ifdef LIBXML_HTML_ENABLED
+XMLPUBFUN void XMLCALL
+ inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
+#endif
+#ifdef LIBXML_DOCB_ENABLED
+XMLPUBFUN void XMLCALL
+ initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
+#endif
+#endif /* LIBXML_SAX1_ENABLED */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_LEGACY_ENABLED */
+
+#endif /* __XML_SAX_H__ */
diff --git a/fmu10/src/shared/libxml/SAX2.h b/fmu10/src/shared/libxml/SAX2.h
new file mode 100644
index 0000000..daafd17
--- /dev/null
+++ b/fmu10/src/shared/libxml/SAX2.h
@@ -0,0 +1,176 @@
+/*
+ * Summary: SAX2 parser interface used to build the DOM tree
+ * Description: those are the default SAX2 interfaces used by
+ * the library when building DOM tree.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+
+#ifndef __XML_SAX2_H__
+#define __XML_SAX2_H__
+
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlSAX2GetPublicId (void *ctx);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlSAX2GetSystemId (void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlSAX2SetDocumentLocator (void *ctx,
+ xmlSAXLocatorPtr loc);
+
+XMLPUBFUN int XMLCALL
+ xmlSAX2GetLineNumber (void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlSAX2GetColumnNumber (void *ctx);
+
+XMLPUBFUN int XMLCALL
+ xmlSAX2IsStandalone (void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlSAX2HasInternalSubset (void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlSAX2HasExternalSubset (void *ctx);
+
+XMLPUBFUN void XMLCALL
+ xmlSAX2InternalSubset (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN void XMLCALL
+ xmlSAX2ExternalSubset (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlSAX2GetEntity (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlSAX2GetParameterEntity (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ xmlSAX2ResolveEntity (void *ctx,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+
+XMLPUBFUN void XMLCALL
+ xmlSAX2EntityDecl (void *ctx,
+ const xmlChar *name,
+ int type,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ xmlChar *content);
+XMLPUBFUN void XMLCALL
+ xmlSAX2AttributeDecl (void *ctx,
+ const xmlChar *elem,
+ const xmlChar *fullname,
+ int type,
+ int def,
+ const xmlChar *defaultValue,
+ xmlEnumerationPtr tree);
+XMLPUBFUN void XMLCALL
+ xmlSAX2ElementDecl (void *ctx,
+ const xmlChar *name,
+ int type,
+ xmlElementContentPtr content);
+XMLPUBFUN void XMLCALL
+ xmlSAX2NotationDecl (void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+XMLPUBFUN void XMLCALL
+ xmlSAX2UnparsedEntityDecl (void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ const xmlChar *notationName);
+
+XMLPUBFUN void XMLCALL
+ xmlSAX2StartDocument (void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlSAX2EndDocument (void *ctx);
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+XMLPUBFUN void XMLCALL
+ xmlSAX2StartElement (void *ctx,
+ const xmlChar *fullname,
+ const xmlChar **atts);
+XMLPUBFUN void XMLCALL
+ xmlSAX2EndElement (void *ctx,
+ const xmlChar *name);
+#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlSAX2StartElementNs (void *ctx,
+ const xmlChar *localname,
+ const xmlChar *prefix,
+ const xmlChar *URI,
+ int nb_namespaces,
+ const xmlChar **namespaces,
+ int nb_attributes,
+ int nb_defaulted,
+ const xmlChar **attributes);
+XMLPUBFUN void XMLCALL
+ xmlSAX2EndElementNs (void *ctx,
+ const xmlChar *localname,
+ const xmlChar *prefix,
+ const xmlChar *URI);
+XMLPUBFUN void XMLCALL
+ xmlSAX2Reference (void *ctx,
+ const xmlChar *name);
+XMLPUBFUN void XMLCALL
+ xmlSAX2Characters (void *ctx,
+ const xmlChar *ch,
+ int len);
+XMLPUBFUN void XMLCALL
+ xmlSAX2IgnorableWhitespace (void *ctx,
+ const xmlChar *ch,
+ int len);
+XMLPUBFUN void XMLCALL
+ xmlSAX2ProcessingInstruction (void *ctx,
+ const xmlChar *target,
+ const xmlChar *data);
+XMLPUBFUN void XMLCALL
+ xmlSAX2Comment (void *ctx,
+ const xmlChar *value);
+XMLPUBFUN void XMLCALL
+ xmlSAX2CDataBlock (void *ctx,
+ const xmlChar *value,
+ int len);
+
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlSAXDefaultVersion (int version);
+#endif /* LIBXML_SAX1_ENABLED */
+
+XMLPUBFUN int XMLCALL
+ xmlSAXVersion (xmlSAXHandler *hdlr,
+ int version);
+XMLPUBFUN void XMLCALL
+ xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr,
+ int warning);
+#ifdef LIBXML_HTML_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
+XMLPUBFUN void XMLCALL
+ htmlDefaultSAXHandlerInit (void);
+#endif
+#ifdef LIBXML_DOCB_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
+XMLPUBFUN void XMLCALL
+ docbDefaultSAXHandlerInit (void);
+#endif
+XMLPUBFUN void XMLCALL
+ xmlDefaultSAXHandlerInit (void);
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_SAX2_H__ */
diff --git a/fmu10/src/shared/libxml/dict.h b/fmu10/src/shared/libxml/dict.h
new file mode 100644
index 0000000..7022ec8
--- /dev/null
+++ b/fmu10/src/shared/libxml/dict.h
@@ -0,0 +1,80 @@
+/*
+ * Summary: string dictionnary
+ * Description: dictionary of reusable strings, just used to avoid allocation
+ * and freeing operations.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_DICT_H__
+#define __XML_DICT_H__
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The dictionnary.
+ */
+typedef struct _xmlDict xmlDict;
+typedef xmlDict *xmlDictPtr;
+
+/*
+ * Initializer
+ */
+XMLPUBFUN int XMLCALL xmlInitializeDict(void);
+
+/*
+ * Constructor and destructor.
+ */
+XMLPUBFUN xmlDictPtr XMLCALL
+ xmlDictCreate (void);
+XMLPUBFUN size_t XMLCALL
+ xmlDictSetLimit (xmlDictPtr dict,
+ size_t limit);
+XMLPUBFUN size_t XMLCALL
+ xmlDictGetUsage (xmlDictPtr dict);
+XMLPUBFUN xmlDictPtr XMLCALL
+ xmlDictCreateSub(xmlDictPtr sub);
+XMLPUBFUN int XMLCALL
+ xmlDictReference(xmlDictPtr dict);
+XMLPUBFUN void XMLCALL
+ xmlDictFree (xmlDictPtr dict);
+
+/*
+ * Lookup of entry in the dictionnary.
+ */
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlDictLookup (xmlDictPtr dict,
+ const xmlChar *name,
+ int len);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlDictExists (xmlDictPtr dict,
+ const xmlChar *name,
+ int len);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlDictQLookup (xmlDictPtr dict,
+ const xmlChar *prefix,
+ const xmlChar *name);
+XMLPUBFUN int XMLCALL
+ xmlDictOwns (xmlDictPtr dict,
+ const xmlChar *str);
+XMLPUBFUN int XMLCALL
+ xmlDictSize (xmlDictPtr dict);
+
+/*
+ * Cleanup function
+ */
+XMLPUBFUN void XMLCALL
+ xmlDictCleanup (void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ! __XML_DICT_H__ */
diff --git a/fmu10/src/shared/libxml/encoding.h b/fmu10/src/shared/libxml/encoding.h
new file mode 100644
index 0000000..7967cc6
--- /dev/null
+++ b/fmu10/src/shared/libxml/encoding.h
@@ -0,0 +1,240 @@
+/*
+ * Summary: interface for the encoding conversion functions
+ * Description: interface for the encoding conversion functions needed for
+ * XML basic encoding and iconv() support.
+ *
+ * Related specs are
+ * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
+ * [ISO-10646] UTF-8 and UTF-16 in Annexes
+ * [ISO-8859-1] ISO Latin-1 characters codes.
+ * [UNICODE] The Unicode Consortium, "The Unicode Standard --
+ * Worldwide Character Encoding -- Version 1.0", Addison-
+ * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
+ * described in Unicode Technical Report #4.
+ * [US-ASCII] Coded Character Set--7-bit American Standard Code for
+ * Information Interchange, ANSI X3.4-1986.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_CHAR_ENCODING_H__
+#define __XML_CHAR_ENCODING_H__
+
+#include
+
+#ifdef LIBXML_ICONV_ENABLED
+#include
+#endif
+#ifdef LIBXML_ICU_ENABLED
+#include
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * xmlCharEncoding:
+ *
+ * Predefined values for some standard encodings.
+ * Libxml does not do beforehand translation on UTF8 and ISOLatinX.
+ * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.
+ *
+ * Anything else would have to be translated to UTF8 before being
+ * given to the parser itself. The BOM for UTF16 and the encoding
+ * declaration are looked at and a converter is looked for at that
+ * point. If not found the parser stops here as asked by the XML REC. A
+ * converter can be registered by the user using xmlRegisterCharEncodingHandler
+ * but the current form doesn't allow stateful transcoding (a serious
+ * problem agreed !). If iconv has been found it will be used
+ * automatically and allow stateful transcoding, the simplest is then
+ * to be sure to enable iconv and to provide iconv libs for the encoding
+ * support needed.
+ *
+ * Note that the generic "UTF-16" is not a predefined value. Instead, only
+ * the specific UTF-16LE and UTF-16BE are present.
+ */
+typedef enum {
+ XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
+ XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
+ XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
+ XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
+ XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
+ XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
+ XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
+ XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
+ XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
+ XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
+ XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
+ XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
+ XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
+ XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
+ XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
+ XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
+ XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
+ XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
+ XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
+ XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
+ XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
+ XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
+ XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
+ XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
+} xmlCharEncoding;
+
+/**
+ * xmlCharEncodingInputFunc:
+ * @out: a pointer to an array of bytes to store the UTF-8 result
+ * @outlen: the length of @out
+ * @in: a pointer to an array of chars in the original encoding
+ * @inlen: the length of @in
+ *
+ * Take a block of chars in the original encoding and try to convert
+ * it to an UTF-8 block of chars out.
+ *
+ * Returns the number of bytes written, -1 if lack of space, or -2
+ * if the transcoding failed.
+ * The value of @inlen after return is the number of octets consumed
+ * if the return value is positive, else unpredictiable.
+ * The value of @outlen after return is the number of octets consumed.
+ */
+typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
+ const unsigned char *in, int *inlen);
+
+
+/**
+ * xmlCharEncodingOutputFunc:
+ * @out: a pointer to an array of bytes to store the result
+ * @outlen: the length of @out
+ * @in: a pointer to an array of UTF-8 chars
+ * @inlen: the length of @in
+ *
+ * Take a block of UTF-8 chars in and try to convert it to another
+ * encoding.
+ * Note: a first call designed to produce heading info is called with
+ * in = NULL. If stateful this should also initialize the encoder state.
+ *
+ * Returns the number of bytes written, -1 if lack of space, or -2
+ * if the transcoding failed.
+ * The value of @inlen after return is the number of octets consumed
+ * if the return value is positive, else unpredictiable.
+ * The value of @outlen after return is the number of octets produced.
+ */
+typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
+ const unsigned char *in, int *inlen);
+
+
+/*
+ * Block defining the handlers for non UTF-8 encodings.
+ * If iconv is supported, there are two extra fields.
+ */
+#ifdef LIBXML_ICU_ENABLED
+struct _uconv_t {
+ UConverter *uconv; /* for conversion between an encoding and UTF-16 */
+ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
+};
+typedef struct _uconv_t uconv_t;
+#endif
+
+typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
+typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
+struct _xmlCharEncodingHandler {
+ char *name;
+ xmlCharEncodingInputFunc input;
+ xmlCharEncodingOutputFunc output;
+#ifdef LIBXML_ICONV_ENABLED
+ iconv_t iconv_in;
+ iconv_t iconv_out;
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ uconv_t *uconv_in;
+ uconv_t *uconv_out;
+#endif /* LIBXML_ICU_ENABLED */
+};
+
+#ifdef __cplusplus
+}
+#endif
+#include
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Interfaces for encoding handlers.
+ */
+XMLPUBFUN void XMLCALL
+ xmlInitCharEncodingHandlers (void);
+XMLPUBFUN void XMLCALL
+ xmlCleanupCharEncodingHandlers (void);
+XMLPUBFUN void XMLCALL
+ xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
+XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+ xmlGetCharEncodingHandler (xmlCharEncoding enc);
+XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+ xmlFindCharEncodingHandler (const char *name);
+XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
+ xmlNewCharEncodingHandler (const char *name,
+ xmlCharEncodingInputFunc input,
+ xmlCharEncodingOutputFunc output);
+
+/*
+ * Interfaces for encoding names and aliases.
+ */
+XMLPUBFUN int XMLCALL
+ xmlAddEncodingAlias (const char *name,
+ const char *alias);
+XMLPUBFUN int XMLCALL
+ xmlDelEncodingAlias (const char *alias);
+XMLPUBFUN const char * XMLCALL
+ xmlGetEncodingAlias (const char *alias);
+XMLPUBFUN void XMLCALL
+ xmlCleanupEncodingAliases (void);
+XMLPUBFUN xmlCharEncoding XMLCALL
+ xmlParseCharEncoding (const char *name);
+XMLPUBFUN const char * XMLCALL
+ xmlGetCharEncodingName (xmlCharEncoding enc);
+
+/*
+ * Interfaces directly used by the parsers.
+ */
+XMLPUBFUN xmlCharEncoding XMLCALL
+ xmlDetectCharEncoding (const unsigned char *in,
+ int len);
+
+XMLPUBFUN int XMLCALL
+ xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
+ xmlBufferPtr out,
+ xmlBufferPtr in);
+
+XMLPUBFUN int XMLCALL
+ xmlCharEncInFunc (xmlCharEncodingHandler *handler,
+ xmlBufferPtr out,
+ xmlBufferPtr in);
+XMLPUBFUN int XMLCALL
+ xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
+ xmlBufferPtr out,
+ xmlBufferPtr in);
+XMLPUBFUN int XMLCALL
+ xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
+
+/*
+ * Export a few useful functions
+ */
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN int XMLCALL
+ UTF8Toisolat1 (unsigned char *out,
+ int *outlen,
+ const unsigned char *in,
+ int *inlen);
+#endif /* LIBXML_OUTPUT_ENABLED */
+XMLPUBFUN int XMLCALL
+ isolat1ToUTF8 (unsigned char *out,
+ int *outlen,
+ const unsigned char *in,
+ int *inlen);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_CHAR_ENCODING_H__ */
diff --git a/fmu10/src/shared/libxml/entities.h b/fmu10/src/shared/libxml/entities.h
new file mode 100644
index 0000000..cefb97f
--- /dev/null
+++ b/fmu10/src/shared/libxml/entities.h
@@ -0,0 +1,150 @@
+/*
+ * Summary: interface for the XML entities handling
+ * Description: this module provides some of the entity API needed
+ * for the parser and applications.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_ENTITIES_H__
+#define __XML_ENTITIES_H__
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The different valid entity types.
+ */
+typedef enum {
+ XML_INTERNAL_GENERAL_ENTITY = 1,
+ XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
+ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
+ XML_INTERNAL_PARAMETER_ENTITY = 4,
+ XML_EXTERNAL_PARAMETER_ENTITY = 5,
+ XML_INTERNAL_PREDEFINED_ENTITY = 6
+} xmlEntityType;
+
+/*
+ * An unit of storage for an entity, contains the string, the value
+ * and the linkind data needed for the linking in the hash table.
+ */
+
+struct _xmlEntity {
+ void *_private; /* application data */
+ xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
+ const xmlChar *name; /* Entity name */
+ struct _xmlNode *children; /* First child link */
+ struct _xmlNode *last; /* Last child link */
+ struct _xmlDtd *parent; /* -> DTD */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+
+ xmlChar *orig; /* content without ref substitution */
+ xmlChar *content; /* content or ndata if unparsed */
+ int length; /* the content length */
+ xmlEntityType etype; /* The entity type */
+ const xmlChar *ExternalID; /* External identifier for PUBLIC */
+ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
+
+ struct _xmlEntity *nexte; /* unused */
+ const xmlChar *URI; /* the full URI as computed */
+ int owner; /* does the entity own the childrens */
+ int checked; /* was the entity content checked */
+ /* this is also used to count entites
+ * references done from that entity */
+};
+
+/*
+ * All entities are stored in an hash table.
+ * There is 2 separate hash tables for global and parameter entities.
+ */
+
+typedef struct _xmlHashTable xmlEntitiesTable;
+typedef xmlEntitiesTable *xmlEntitiesTablePtr;
+
+/*
+ * External functions:
+ */
+
+#ifdef LIBXML_LEGACY_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlInitializePredefinedEntities (void);
+#endif /* LIBXML_LEGACY_ENABLED */
+
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlNewEntity (xmlDocPtr doc,
+ const xmlChar *name,
+ int type,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID,
+ const xmlChar *content);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlAddDocEntity (xmlDocPtr doc,
+ const xmlChar *name,
+ int type,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID,
+ const xmlChar *content);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlAddDtdEntity (xmlDocPtr doc,
+ const xmlChar *name,
+ int type,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID,
+ const xmlChar *content);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlGetPredefinedEntity (const xmlChar *name);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlGetDocEntity (xmlDocPtr doc,
+ const xmlChar *name);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlGetDtdEntity (xmlDocPtr doc,
+ const xmlChar *name);
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlGetParameterEntity (xmlDocPtr doc,
+ const xmlChar *name);
+#ifdef LIBXML_LEGACY_ENABLED
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlEncodeEntities (xmlDocPtr doc,
+ const xmlChar *input);
+#endif /* LIBXML_LEGACY_ENABLED */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlEncodeEntitiesReentrant(xmlDocPtr doc,
+ const xmlChar *input);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlEncodeSpecialChars (xmlDocPtr doc,
+ const xmlChar *input);
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+ xmlCreateEntitiesTable (void);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+ xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlDumpEntitiesTable (xmlBufferPtr buf,
+ xmlEntitiesTablePtr table);
+XMLPUBFUN void XMLCALL
+ xmlDumpEntityDecl (xmlBufferPtr buf,
+ xmlEntityPtr ent);
+#endif /* LIBXML_OUTPUT_ENABLED */
+#ifdef LIBXML_LEGACY_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlCleanupPredefinedEntities(void);
+#endif /* LIBXML_LEGACY_ENABLED */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+# endif /* __XML_ENTITIES_H__ */
diff --git a/fmu10/src/shared/libxml/globals.h b/fmu10/src/shared/libxml/globals.h
new file mode 100644
index 0000000..9d688e0
--- /dev/null
+++ b/fmu10/src/shared/libxml/globals.h
@@ -0,0 +1,502 @@
+/*
+ * Summary: interface for all global variables of the library
+ * Description: all the global variables and thread handling for
+ * those variables is handled by this module.
+ *
+ * The bottom of this file is automatically generated by build_glob.py
+ * based on the description file global.data
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Gary Pennington , Daniel Veillard
+ */
+
+#ifndef __XML_GLOBALS_H
+#define __XML_GLOBALS_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XMLPUBFUN void XMLCALL xmlInitGlobals(void);
+XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
+
+/**
+ * xmlParserInputBufferCreateFilenameFunc:
+ * @URI: the URI to read from
+ * @enc: the requested source encoding
+ *
+ * Signature for the function doing the lookup for a suitable input method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
+ * method was found.
+ */
+typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc);
+
+/**
+ * xmlOutputBufferCreateFilenameFunc:
+ * @URI: the URI to write to
+ * @enc: the requested target encoding
+ *
+ * Signature for the function doing the lookup for a suitable output method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlOutputBufferPtr in case of success or NULL if no
+ * method was found.
+ */
+typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression);
+
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
+XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc
+XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);
+
+/*
+ * Externally global symbols which need to be protected for backwards
+ * compatibility support.
+ */
+
+#undef docbDefaultSAXHandler
+#undef htmlDefaultSAXHandler
+#undef oldXMLWDcompatibility
+#undef xmlBufferAllocScheme
+#undef xmlDefaultBufferSize
+#undef xmlDefaultSAXHandler
+#undef xmlDefaultSAXLocator
+#undef xmlDoValidityCheckingDefaultValue
+#undef xmlFree
+#undef xmlGenericError
+#undef xmlStructuredError
+#undef xmlGenericErrorContext
+#undef xmlStructuredErrorContext
+#undef xmlGetWarningsDefaultValue
+#undef xmlIndentTreeOutput
+#undef xmlTreeIndentString
+#undef xmlKeepBlanksDefaultValue
+#undef xmlLineNumbersDefaultValue
+#undef xmlLoadExtDtdDefaultValue
+#undef xmlMalloc
+#undef xmlMallocAtomic
+#undef xmlMemStrdup
+#undef xmlParserDebugEntities
+#undef xmlParserVersion
+#undef xmlPedanticParserDefaultValue
+#undef xmlRealloc
+#undef xmlSaveNoEmptyTags
+#undef xmlSubstituteEntitiesDefaultValue
+#undef xmlRegisterNodeDefaultValue
+#undef xmlDeregisterNodeDefaultValue
+#undef xmlLastError
+#undef xmlParserInputBufferCreateFilenameValue
+#undef xmlOutputBufferCreateFilenameValue
+
+/**
+ * xmlRegisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the registration callback of a created node
+ */
+typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
+/**
+ * xmlDeregisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the deregistration callback of a discarded node
+ */
+typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
+
+typedef struct _xmlGlobalState xmlGlobalState;
+typedef xmlGlobalState *xmlGlobalStatePtr;
+struct _xmlGlobalState
+{
+ const char *xmlParserVersion;
+
+ xmlSAXLocator xmlDefaultSAXLocator;
+ xmlSAXHandlerV1 xmlDefaultSAXHandler;
+ xmlSAXHandlerV1 docbDefaultSAXHandler;
+ xmlSAXHandlerV1 htmlDefaultSAXHandler;
+
+ xmlFreeFunc xmlFree;
+ xmlMallocFunc xmlMalloc;
+ xmlStrdupFunc xmlMemStrdup;
+ xmlReallocFunc xmlRealloc;
+
+ xmlGenericErrorFunc xmlGenericError;
+ xmlStructuredErrorFunc xmlStructuredError;
+ void *xmlGenericErrorContext;
+
+ int oldXMLWDcompatibility;
+
+ xmlBufferAllocationScheme xmlBufferAllocScheme;
+ int xmlDefaultBufferSize;
+
+ int xmlSubstituteEntitiesDefaultValue;
+ int xmlDoValidityCheckingDefaultValue;
+ int xmlGetWarningsDefaultValue;
+ int xmlKeepBlanksDefaultValue;
+ int xmlLineNumbersDefaultValue;
+ int xmlLoadExtDtdDefaultValue;
+ int xmlParserDebugEntities;
+ int xmlPedanticParserDefaultValue;
+
+ int xmlSaveNoEmptyTags;
+ int xmlIndentTreeOutput;
+ const char *xmlTreeIndentString;
+
+ xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
+ xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
+
+ xmlMallocFunc xmlMallocAtomic;
+ xmlError xmlLastError;
+
+ xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
+ xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
+
+ void *xmlStructuredErrorContext;
+};
+
+#ifdef __cplusplus
+}
+#endif
+#include
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs);
+
+XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
+
+XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
+
+XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
+XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
+XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
+XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
+
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
+ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
+ xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
+
+/** DOC_DISABLE */
+/*
+ * In general the memory allocation entry points are not kept
+ * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
+ * - xmlMalloc
+ * - xmlMallocAtomic
+ * - xmlRealloc
+ * - xmlMemStrdup
+ * - xmlFree
+ */
+
+#ifdef LIBXML_THREAD_ALLOC_ENABLED
+#ifdef LIBXML_THREAD_ENABLED
+XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void);
+#define xmlMalloc \
+(*(__xmlMalloc()))
+#else
+XMLPUBVAR xmlMallocFunc xmlMalloc;
+#endif
+
+#ifdef LIBXML_THREAD_ENABLED
+XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void);
+#define xmlMallocAtomic \
+(*(__xmlMallocAtomic()))
+#else
+XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
+#endif
+
+#ifdef LIBXML_THREAD_ENABLED
+XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void);
+#define xmlRealloc \
+(*(__xmlRealloc()))
+#else
+XMLPUBVAR xmlReallocFunc xmlRealloc;
+#endif
+
+#ifdef LIBXML_THREAD_ENABLED
+XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void);
+#define xmlFree \
+(*(__xmlFree()))
+#else
+XMLPUBVAR xmlFreeFunc xmlFree;
+#endif
+
+#ifdef LIBXML_THREAD_ENABLED
+XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void);
+#define xmlMemStrdup \
+(*(__xmlMemStrdup()))
+#else
+XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
+#endif
+
+#else /* !LIBXML_THREAD_ALLOC_ENABLED */
+XMLPUBVAR xmlMallocFunc xmlMalloc;
+XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
+XMLPUBVAR xmlReallocFunc xmlRealloc;
+XMLPUBVAR xmlFreeFunc xmlFree;
+XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
+#endif /* LIBXML_THREAD_ALLOC_ENABLED */
+
+#ifdef LIBXML_DOCB_ENABLED
+XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define docbDefaultSAXHandler \
+(*(__docbDefaultSAXHandler()))
+#else
+XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
+#endif
+#endif
+
+#ifdef LIBXML_HTML_ENABLED
+XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define htmlDefaultSAXHandler \
+(*(__htmlDefaultSAXHandler()))
+#else
+XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
+#endif
+#endif
+
+XMLPUBFUN xmlError * XMLCALL __xmlLastError(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlLastError \
+(*(__xmlLastError()))
+#else
+XMLPUBVAR xmlError xmlLastError;
+#endif
+
+/*
+ * Everything starting from the line below is
+ * Automatically generated by build_glob.py.
+ * Do not modify the previous line.
+ */
+
+
+XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define oldXMLWDcompatibility \
+(*(__oldXMLWDcompatibility()))
+#else
+XMLPUBVAR int oldXMLWDcompatibility;
+#endif
+
+XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlBufferAllocScheme \
+(*(__xmlBufferAllocScheme()))
+#else
+XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
+#endif
+XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
+
+XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlDefaultBufferSize \
+(*(__xmlDefaultBufferSize()))
+#else
+XMLPUBVAR int xmlDefaultBufferSize;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v);
+
+XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlDefaultSAXHandler \
+(*(__xmlDefaultSAXHandler()))
+#else
+XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
+#endif
+
+XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlDefaultSAXLocator \
+(*(__xmlDefaultSAXLocator()))
+#else
+XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;
+#endif
+
+XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlDoValidityCheckingDefaultValue \
+(*(__xmlDoValidityCheckingDefaultValue()))
+#else
+XMLPUBVAR int xmlDoValidityCheckingDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v);
+
+XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlGenericError \
+(*(__xmlGenericError()))
+#else
+XMLPUBVAR xmlGenericErrorFunc xmlGenericError;
+#endif
+
+XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlStructuredError \
+(*(__xmlStructuredError()))
+#else
+XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;
+#endif
+
+XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlGenericErrorContext \
+(*(__xmlGenericErrorContext()))
+#else
+XMLPUBVAR void * xmlGenericErrorContext;
+#endif
+
+XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlStructuredErrorContext \
+(*(__xmlStructuredErrorContext()))
+#else
+XMLPUBVAR void * xmlStructuredErrorContext;
+#endif
+
+XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlGetWarningsDefaultValue \
+(*(__xmlGetWarningsDefaultValue()))
+#else
+XMLPUBVAR int xmlGetWarningsDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v);
+
+XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlIndentTreeOutput \
+(*(__xmlIndentTreeOutput()))
+#else
+XMLPUBVAR int xmlIndentTreeOutput;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v);
+
+XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlTreeIndentString \
+(*(__xmlTreeIndentString()))
+#else
+XMLPUBVAR const char * xmlTreeIndentString;
+#endif
+XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v);
+
+XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlKeepBlanksDefaultValue \
+(*(__xmlKeepBlanksDefaultValue()))
+#else
+XMLPUBVAR int xmlKeepBlanksDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v);
+
+XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlLineNumbersDefaultValue \
+(*(__xmlLineNumbersDefaultValue()))
+#else
+XMLPUBVAR int xmlLineNumbersDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v);
+
+XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlLoadExtDtdDefaultValue \
+(*(__xmlLoadExtDtdDefaultValue()))
+#else
+XMLPUBVAR int xmlLoadExtDtdDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v);
+
+XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlParserDebugEntities \
+(*(__xmlParserDebugEntities()))
+#else
+XMLPUBVAR int xmlParserDebugEntities;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v);
+
+XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlParserVersion \
+(*(__xmlParserVersion()))
+#else
+XMLPUBVAR const char * xmlParserVersion;
+#endif
+
+XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlPedanticParserDefaultValue \
+(*(__xmlPedanticParserDefaultValue()))
+#else
+XMLPUBVAR int xmlPedanticParserDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v);
+
+XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlSaveNoEmptyTags \
+(*(__xmlSaveNoEmptyTags()))
+#else
+XMLPUBVAR int xmlSaveNoEmptyTags;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v);
+
+XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlSubstituteEntitiesDefaultValue \
+(*(__xmlSubstituteEntitiesDefaultValue()))
+#else
+XMLPUBVAR int xmlSubstituteEntitiesDefaultValue;
+#endif
+XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v);
+
+XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlRegisterNodeDefaultValue \
+(*(__xmlRegisterNodeDefaultValue()))
+#else
+XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
+#endif
+
+XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlDeregisterNodeDefaultValue \
+(*(__xmlDeregisterNodeDefaultValue()))
+#else
+XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
+#endif
+
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlParserInputBufferCreateFilenameValue \
+(*(__xmlParserInputBufferCreateFilenameValue()))
+#else
+XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
+#endif
+
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlOutputBufferCreateFilenameValue \
+(*(__xmlOutputBufferCreateFilenameValue()))
+#else
+XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_GLOBALS_H */
diff --git a/fmu10/src/shared/libxml/hash.h b/fmu10/src/shared/libxml/hash.h
new file mode 100644
index 0000000..dc8ab7e
--- /dev/null
+++ b/fmu10/src/shared/libxml/hash.h
@@ -0,0 +1,233 @@
+/*
+ * Summary: Chained hash tables
+ * Description: This module implements the hash table support used in
+ * various places in the library.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Bjorn Reese
+ */
+
+#ifndef __XML_HASH_H__
+#define __XML_HASH_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The hash table.
+ */
+typedef struct _xmlHashTable xmlHashTable;
+typedef xmlHashTable *xmlHashTablePtr;
+
+#ifdef __cplusplus
+}
+#endif
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Recent version of gcc produce a warning when a function pointer is assigned
+ * to an object pointer, or vice versa. The following macro is a dirty hack
+ * to allow suppression of the warning. If your architecture has function
+ * pointers which are a different size than a void pointer, there may be some
+ * serious trouble within the library.
+ */
+/**
+ * XML_CAST_FPTR:
+ * @fptr: pointer to a function
+ *
+ * Macro to do a casting from an object pointer to a
+ * function pointer without encountering a warning from
+ * gcc
+ *
+ * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
+ * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
+ * so it is disabled now
+ */
+
+#define XML_CAST_FPTR(fptr) fptr
+
+
+/*
+ * function types:
+ */
+/**
+ * xmlHashDeallocator:
+ * @payload: the data in the hash
+ * @name: the name associated
+ *
+ * Callback to free data from a hash.
+ */
+typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
+/**
+ * xmlHashCopier:
+ * @payload: the data in the hash
+ * @name: the name associated
+ *
+ * Callback to copy data from a hash.
+ *
+ * Returns a copy of the data or NULL in case of error.
+ */
+typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
+/**
+ * xmlHashScanner:
+ * @payload: the data in the hash
+ * @data: extra scannner data
+ * @name: the name associated
+ *
+ * Callback when scanning data in a hash with the simple scanner.
+ */
+typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name);
+/**
+ * xmlHashScannerFull:
+ * @payload: the data in the hash
+ * @data: extra scannner data
+ * @name: the name associated
+ * @name2: the second name associated
+ * @name3: the third name associated
+ *
+ * Callback when scanning data in a hash with the full scanner.
+ */
+typedef void (*xmlHashScannerFull)(void *payload, void *data,
+ const xmlChar *name, const xmlChar *name2,
+ const xmlChar *name3);
+
+/*
+ * Constructor and destructor.
+ */
+XMLPUBFUN xmlHashTablePtr XMLCALL
+ xmlHashCreate (int size);
+XMLPUBFUN xmlHashTablePtr XMLCALL
+ xmlHashCreateDict(int size,
+ xmlDictPtr dict);
+XMLPUBFUN void XMLCALL
+ xmlHashFree (xmlHashTablePtr table,
+ xmlHashDeallocator f);
+
+/*
+ * Add a new entry to the hash table.
+ */
+XMLPUBFUN int XMLCALL
+ xmlHashAddEntry (xmlHashTablePtr table,
+ const xmlChar *name,
+ void *userdata);
+XMLPUBFUN int XMLCALL
+ xmlHashUpdateEntry(xmlHashTablePtr table,
+ const xmlChar *name,
+ void *userdata,
+ xmlHashDeallocator f);
+XMLPUBFUN int XMLCALL
+ xmlHashAddEntry2(xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ void *userdata);
+XMLPUBFUN int XMLCALL
+ xmlHashUpdateEntry2(xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ void *userdata,
+ xmlHashDeallocator f);
+XMLPUBFUN int XMLCALL
+ xmlHashAddEntry3(xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ const xmlChar *name3,
+ void *userdata);
+XMLPUBFUN int XMLCALL
+ xmlHashUpdateEntry3(xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ const xmlChar *name3,
+ void *userdata,
+ xmlHashDeallocator f);
+
+/*
+ * Remove an entry from the hash table.
+ */
+XMLPUBFUN int XMLCALL
+ xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
+ xmlHashDeallocator f);
+XMLPUBFUN int XMLCALL
+ xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
+ const xmlChar *name2, xmlHashDeallocator f);
+XMLPUBFUN int XMLCALL
+ xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
+ const xmlChar *name2, const xmlChar *name3,
+ xmlHashDeallocator f);
+
+/*
+ * Retrieve the userdata.
+ */
+XMLPUBFUN void * XMLCALL
+ xmlHashLookup (xmlHashTablePtr table,
+ const xmlChar *name);
+XMLPUBFUN void * XMLCALL
+ xmlHashLookup2 (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2);
+XMLPUBFUN void * XMLCALL
+ xmlHashLookup3 (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ const xmlChar *name3);
+XMLPUBFUN void * XMLCALL
+ xmlHashQLookup (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *prefix);
+XMLPUBFUN void * XMLCALL
+ xmlHashQLookup2 (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *prefix,
+ const xmlChar *name2,
+ const xmlChar *prefix2);
+XMLPUBFUN void * XMLCALL
+ xmlHashQLookup3 (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *prefix,
+ const xmlChar *name2,
+ const xmlChar *prefix2,
+ const xmlChar *name3,
+ const xmlChar *prefix3);
+
+/*
+ * Helpers.
+ */
+XMLPUBFUN xmlHashTablePtr XMLCALL
+ xmlHashCopy (xmlHashTablePtr table,
+ xmlHashCopier f);
+XMLPUBFUN int XMLCALL
+ xmlHashSize (xmlHashTablePtr table);
+XMLPUBFUN void XMLCALL
+ xmlHashScan (xmlHashTablePtr table,
+ xmlHashScanner f,
+ void *data);
+XMLPUBFUN void XMLCALL
+ xmlHashScan3 (xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ const xmlChar *name3,
+ xmlHashScanner f,
+ void *data);
+XMLPUBFUN void XMLCALL
+ xmlHashScanFull (xmlHashTablePtr table,
+ xmlHashScannerFull f,
+ void *data);
+XMLPUBFUN void XMLCALL
+ xmlHashScanFull3(xmlHashTablePtr table,
+ const xmlChar *name,
+ const xmlChar *name2,
+ const xmlChar *name3,
+ xmlHashScannerFull f,
+ void *data);
+#ifdef __cplusplus
+}
+#endif
+#endif /* ! __XML_HASH_H__ */
diff --git a/fmu10/src/shared/libxml/list.h b/fmu10/src/shared/libxml/list.h
new file mode 100644
index 0000000..0504e0c
--- /dev/null
+++ b/fmu10/src/shared/libxml/list.h
@@ -0,0 +1,137 @@
+/*
+ * Summary: lists interfaces
+ * Description: this module implement the list support used in
+ * various place in the library.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Gary Pennington
+ */
+
+#ifndef __XML_LINK_INCLUDE__
+#define __XML_LINK_INCLUDE__
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _xmlLink xmlLink;
+typedef xmlLink *xmlLinkPtr;
+
+typedef struct _xmlList xmlList;
+typedef xmlList *xmlListPtr;
+
+/**
+ * xmlListDeallocator:
+ * @lk: the data to deallocate
+ *
+ * Callback function used to free data from a list.
+ */
+typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
+/**
+ * xmlListDataCompare:
+ * @data0: the first data
+ * @data1: the second data
+ *
+ * Callback function used to compare 2 data.
+ *
+ * Returns 0 is equality, -1 or 1 otherwise depending on the ordering.
+ */
+typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
+/**
+ * xmlListWalker:
+ * @data: the data found in the list
+ * @user: extra user provided data to the walker
+ *
+ * Callback function used when walking a list with xmlListWalk().
+ *
+ * Returns 0 to stop walking the list, 1 otherwise.
+ */
+typedef int (*xmlListWalker) (const void *data, const void *user);
+
+/* Creation/Deletion */
+XMLPUBFUN xmlListPtr XMLCALL
+ xmlListCreate (xmlListDeallocator deallocator,
+ xmlListDataCompare compare);
+XMLPUBFUN void XMLCALL
+ xmlListDelete (xmlListPtr l);
+
+/* Basic Operators */
+XMLPUBFUN void * XMLCALL
+ xmlListSearch (xmlListPtr l,
+ void *data);
+XMLPUBFUN void * XMLCALL
+ xmlListReverseSearch (xmlListPtr l,
+ void *data);
+XMLPUBFUN int XMLCALL
+ xmlListInsert (xmlListPtr l,
+ void *data) ;
+XMLPUBFUN int XMLCALL
+ xmlListAppend (xmlListPtr l,
+ void *data) ;
+XMLPUBFUN int XMLCALL
+ xmlListRemoveFirst (xmlListPtr l,
+ void *data);
+XMLPUBFUN int XMLCALL
+ xmlListRemoveLast (xmlListPtr l,
+ void *data);
+XMLPUBFUN int XMLCALL
+ xmlListRemoveAll (xmlListPtr l,
+ void *data);
+XMLPUBFUN void XMLCALL
+ xmlListClear (xmlListPtr l);
+XMLPUBFUN int XMLCALL
+ xmlListEmpty (xmlListPtr l);
+XMLPUBFUN xmlLinkPtr XMLCALL
+ xmlListFront (xmlListPtr l);
+XMLPUBFUN xmlLinkPtr XMLCALL
+ xmlListEnd (xmlListPtr l);
+XMLPUBFUN int XMLCALL
+ xmlListSize (xmlListPtr l);
+
+XMLPUBFUN void XMLCALL
+ xmlListPopFront (xmlListPtr l);
+XMLPUBFUN void XMLCALL
+ xmlListPopBack (xmlListPtr l);
+XMLPUBFUN int XMLCALL
+ xmlListPushFront (xmlListPtr l,
+ void *data);
+XMLPUBFUN int XMLCALL
+ xmlListPushBack (xmlListPtr l,
+ void *data);
+
+/* Advanced Operators */
+XMLPUBFUN void XMLCALL
+ xmlListReverse (xmlListPtr l);
+XMLPUBFUN void XMLCALL
+ xmlListSort (xmlListPtr l);
+XMLPUBFUN void XMLCALL
+ xmlListWalk (xmlListPtr l,
+ xmlListWalker walker,
+ const void *user);
+XMLPUBFUN void XMLCALL
+ xmlListReverseWalk (xmlListPtr l,
+ xmlListWalker walker,
+ const void *user);
+XMLPUBFUN void XMLCALL
+ xmlListMerge (xmlListPtr l1,
+ xmlListPtr l2);
+XMLPUBFUN xmlListPtr XMLCALL
+ xmlListDup (const xmlListPtr old);
+XMLPUBFUN int XMLCALL
+ xmlListCopy (xmlListPtr cur,
+ const xmlListPtr old);
+/* Link operators */
+XMLPUBFUN void * XMLCALL
+ xmlLinkGetData (xmlLinkPtr lk);
+
+/* xmlListUnique() */
+/* xmlListSwap */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_LINK_INCLUDE__ */
diff --git a/fmu10/src/shared/libxml/parser.h b/fmu10/src/shared/libxml/parser.h
new file mode 100644
index 0000000..e1346e4
--- /dev/null
+++ b/fmu10/src/shared/libxml/parser.h
@@ -0,0 +1,1240 @@
+/*
+ * Summary: the core parser module
+ * Description: Interfaces, constants and types related to the XML parser
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_PARSER_H__
+#define __XML_PARSER_H__
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * XML_DEFAULT_VERSION:
+ *
+ * The default version of XML used: 1.0
+ */
+#define XML_DEFAULT_VERSION "1.0"
+
+/**
+ * xmlParserInput:
+ *
+ * An xmlParserInput is an input flow for the XML processor.
+ * Each entity parsed is associated an xmlParserInput (except the
+ * few predefined ones). This is the case both for internal entities
+ * - in which case the flow is already completely in memory - or
+ * external entities - in which case we use the buf structure for
+ * progressive reading and I18N conversions to the internal UTF-8 format.
+ */
+
+/**
+ * xmlParserInputDeallocate:
+ * @str: the string to deallocate
+ *
+ * Callback for freeing some parser input allocations.
+ */
+typedef void (* xmlParserInputDeallocate)(xmlChar *str);
+
+struct _xmlParserInput {
+ /* Input buffer */
+ xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
+
+ const char *filename; /* The file analyzed, if any */
+ const char *directory; /* the directory/base of the file */
+ const xmlChar *base; /* Base of the array to parse */
+ const xmlChar *cur; /* Current char being parsed */
+ const xmlChar *end; /* end of the array to parse */
+ int length; /* length if known */
+ int line; /* Current line */
+ int col; /* Current column */
+ /*
+ * NOTE: consumed is only tested for equality in the parser code,
+ * so even if there is an overflow this should not give troubles
+ * for parsing very large instances.
+ */
+ unsigned long consumed; /* How many xmlChars already consumed */
+ xmlParserInputDeallocate free; /* function to deallocate the base */
+ const xmlChar *encoding; /* the encoding string for entity */
+ const xmlChar *version; /* the version string for entity */
+ int standalone; /* Was that entity marked standalone */
+ int id; /* an unique identifier for the entity */
+};
+
+/**
+ * xmlParserNodeInfo:
+ *
+ * The parser can be asked to collect Node informations, i.e. at what
+ * place in the file they were detected.
+ * NOTE: This is off by default and not very well tested.
+ */
+typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
+typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
+
+struct _xmlParserNodeInfo {
+ const struct _xmlNode* node;
+ /* Position & line # that text that created the node begins & ends on */
+ unsigned long begin_pos;
+ unsigned long begin_line;
+ unsigned long end_pos;
+ unsigned long end_line;
+};
+
+typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
+typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
+struct _xmlParserNodeInfoSeq {
+ unsigned long maximum;
+ unsigned long length;
+ xmlParserNodeInfo* buffer;
+};
+
+/**
+ * xmlParserInputState:
+ *
+ * The parser is now working also as a state based parser.
+ * The recursive one use the state info for entities processing.
+ */
+typedef enum {
+ XML_PARSER_EOF = -1, /* nothing is to be parsed */
+ XML_PARSER_START = 0, /* nothing has been parsed */
+ XML_PARSER_MISC, /* Misc* before int subset */
+ XML_PARSER_PI, /* Within a processing instruction */
+ XML_PARSER_DTD, /* within some DTD content */
+ XML_PARSER_PROLOG, /* Misc* after internal subset */
+ XML_PARSER_COMMENT, /* within a comment */
+ XML_PARSER_START_TAG, /* within a start tag */
+ XML_PARSER_CONTENT, /* within the content */
+ XML_PARSER_CDATA_SECTION, /* within a CDATA section */
+ XML_PARSER_END_TAG, /* within a closing tag */
+ XML_PARSER_ENTITY_DECL, /* within an entity declaration */
+ XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
+ XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
+ XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
+ XML_PARSER_EPILOG, /* the Misc* after the last end tag */
+ XML_PARSER_IGNORE, /* within an IGNORED section */
+ XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
+} xmlParserInputState;
+
+/**
+ * XML_DETECT_IDS:
+ *
+ * Bit in the loadsubset context field to tell to do ID/REFs lookups.
+ * Use it to initialize xmlLoadExtDtdDefaultValue.
+ */
+#define XML_DETECT_IDS 2
+
+/**
+ * XML_COMPLETE_ATTRS:
+ *
+ * Bit in the loadsubset context field to tell to do complete the
+ * elements attributes lists with the ones defaulted from the DTDs.
+ * Use it to initialize xmlLoadExtDtdDefaultValue.
+ */
+#define XML_COMPLETE_ATTRS 4
+
+/**
+ * XML_SKIP_IDS:
+ *
+ * Bit in the loadsubset context field to tell to not do ID/REFs registration.
+ * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
+ */
+#define XML_SKIP_IDS 8
+
+/**
+ * xmlParserMode:
+ *
+ * A parser can operate in various modes
+ */
+typedef enum {
+ XML_PARSE_UNKNOWN = 0,
+ XML_PARSE_DOM = 1,
+ XML_PARSE_SAX = 2,
+ XML_PARSE_PUSH_DOM = 3,
+ XML_PARSE_PUSH_SAX = 4,
+ XML_PARSE_READER = 5
+} xmlParserMode;
+
+/**
+ * xmlParserCtxt:
+ *
+ * The parser context.
+ * NOTE This doesn't completely define the parser state, the (current ?)
+ * design of the parser uses recursive function calls since this allow
+ * and easy mapping from the production rules of the specification
+ * to the actual code. The drawback is that the actual function call
+ * also reflect the parser state. However most of the parsing routines
+ * takes as the only argument the parser context pointer, so migrating
+ * to a state based parser for progressive parsing shouldn't be too hard.
+ */
+struct _xmlParserCtxt {
+ struct _xmlSAXHandler *sax; /* The SAX handler */
+ void *userData; /* For SAX interface only, used by DOM build */
+ xmlDocPtr myDoc; /* the document being built */
+ int wellFormed; /* is the document well formed */
+ int replaceEntities; /* shall we replace entities ? */
+ const xmlChar *version; /* the XML version string */
+ const xmlChar *encoding; /* the declared encoding, if any */
+ int standalone; /* standalone document */
+ int html; /* an HTML(1)/Docbook(2) document
+ * 3 is HTML after
+ * 10 is HTML after
+ */
+
+ /* Input stream stack */
+ xmlParserInputPtr input; /* Current input stream */
+ int inputNr; /* Number of current input streams */
+ int inputMax; /* Max number of input streams */
+ xmlParserInputPtr *inputTab; /* stack of inputs */
+
+ /* Node analysis stack only used for DOM building */
+ xmlNodePtr node; /* Current parsed Node */
+ int nodeNr; /* Depth of the parsing stack */
+ int nodeMax; /* Max depth of the parsing stack */
+ xmlNodePtr *nodeTab; /* array of nodes */
+
+ int record_info; /* Whether node info should be kept */
+ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
+
+ int errNo; /* error code */
+
+ int hasExternalSubset; /* reference and external subset */
+ int hasPErefs; /* the internal subset has PE refs */
+ int external; /* are we parsing an external entity */
+
+ int valid; /* is the document valid */
+ int validate; /* shall we try to validate ? */
+ xmlValidCtxt vctxt; /* The validity context */
+
+ xmlParserInputState instate; /* current type of input */
+ int token; /* next char look-ahead */
+
+ char *directory; /* the data directory */
+
+ /* Node name stack */
+ const xmlChar *name; /* Current parsed Node */
+ int nameNr; /* Depth of the parsing stack */
+ int nameMax; /* Max depth of the parsing stack */
+ const xmlChar * *nameTab; /* array of nodes */
+
+ long nbChars; /* number of xmlChar processed */
+ long checkIndex; /* used by progressive parsing lookup */
+ int keepBlanks; /* ugly but ... */
+ int disableSAX; /* SAX callbacks are disabled */
+ int inSubset; /* Parsing is in int 1/ext 2 subset */
+ const xmlChar * intSubName; /* name of subset */
+ xmlChar * extSubURI; /* URI of external subset */
+ xmlChar * extSubSystem; /* SYSTEM ID of external subset */
+
+ /* xml:space values */
+ int * space; /* Should the parser preserve spaces */
+ int spaceNr; /* Depth of the parsing stack */
+ int spaceMax; /* Max depth of the parsing stack */
+ int * spaceTab; /* array of space infos */
+
+ int depth; /* to prevent entity substitution loops */
+ xmlParserInputPtr entity; /* used to check entities boundaries */
+ int charset; /* encoding of the in-memory content
+ actually an xmlCharEncoding */
+ int nodelen; /* Those two fields are there to */
+ int nodemem; /* Speed up large node parsing */
+ int pedantic; /* signal pedantic warnings */
+ void *_private; /* For user data, libxml won't touch it */
+
+ int loadsubset; /* should the external subset be loaded */
+ int linenumbers; /* set line number in element content */
+ void *catalogs; /* document's own catalog */
+ int recovery; /* run in recovery mode */
+ int progressive; /* is this a progressive parsing */
+ xmlDictPtr dict; /* dictionnary for the parser */
+ const xmlChar * *atts; /* array for the attributes callbacks */
+ int maxatts; /* the size of the array */
+ int docdict; /* use strings from dict to build tree */
+
+ /*
+ * pre-interned strings
+ */
+ const xmlChar *str_xml;
+ const xmlChar *str_xmlns;
+ const xmlChar *str_xml_ns;
+
+ /*
+ * Everything below is used only by the new SAX mode
+ */
+ int sax2; /* operating in the new SAX mode */
+ int nsNr; /* the number of inherited namespaces */
+ int nsMax; /* the size of the arrays */
+ const xmlChar * *nsTab; /* the array of prefix/namespace name */
+ int *attallocs; /* which attribute were allocated */
+ void * *pushTab; /* array of data for push */
+ xmlHashTablePtr attsDefault; /* defaulted attributes if any */
+ xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
+ int nsWellFormed; /* is the document XML Nanespace okay */
+ int options; /* Extra options */
+
+ /*
+ * Those fields are needed only for treaming parsing so far
+ */
+ int dictNames; /* Use dictionary names for the tree */
+ int freeElemsNr; /* number of freed element nodes */
+ xmlNodePtr freeElems; /* List of freed element nodes */
+ int freeAttrsNr; /* number of freed attributes nodes */
+ xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
+
+ /*
+ * the complete error informations for the last error.
+ */
+ xmlError lastError;
+ xmlParserMode parseMode; /* the parser mode */
+ unsigned long nbentities; /* number of entities references */
+ unsigned long sizeentities; /* size of parsed entities */
+
+ /* for use by HTML non-recursive parser */
+ xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */
+ int nodeInfoNr; /* Depth of the parsing stack */
+ int nodeInfoMax; /* Max depth of the parsing stack */
+ xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
+
+ int input_id; /* we need to label inputs */
+};
+
+/**
+ * xmlSAXLocator:
+ *
+ * A SAX Locator.
+ */
+struct _xmlSAXLocator {
+ const xmlChar *(*getPublicId)(void *ctx);
+ const xmlChar *(*getSystemId)(void *ctx);
+ int (*getLineNumber)(void *ctx);
+ int (*getColumnNumber)(void *ctx);
+};
+
+/**
+ * xmlSAXHandler:
+ *
+ * A SAX handler is bunch of callbacks called by the parser when processing
+ * of the input generate data or structure informations.
+ */
+
+/**
+ * resolveEntitySAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @publicId: The public ID of the entity
+ * @systemId: The system ID of the entity
+ *
+ * Callback:
+ * The entity loader, to control the loading of external entities,
+ * the application can either:
+ * - override this resolveEntity() callback in the SAX block
+ * - or better use the xmlSetExternalEntityLoader() function to
+ * set up it's own entity resolution routine
+ *
+ * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
+ */
+typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+/**
+ * internalSubsetSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: the root element name
+ * @ExternalID: the external ID
+ * @SystemID: the SYSTEM ID (e.g. filename or URL)
+ *
+ * Callback on internal subset declaration.
+ */
+typedef void (*internalSubsetSAXFunc) (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+/**
+ * externalSubsetSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: the root element name
+ * @ExternalID: the external ID
+ * @SystemID: the SYSTEM ID (e.g. filename or URL)
+ *
+ * Callback on external subset declaration.
+ */
+typedef void (*externalSubsetSAXFunc) (void *ctx,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+/**
+ * getEntitySAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The entity name
+ *
+ * Get an entity by name.
+ *
+ * Returns the xmlEntityPtr if found.
+ */
+typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
+ const xmlChar *name);
+/**
+ * getParameterEntitySAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The entity name
+ *
+ * Get a parameter entity by name.
+ *
+ * Returns the xmlEntityPtr if found.
+ */
+typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
+ const xmlChar *name);
+/**
+ * entityDeclSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: the entity name
+ * @type: the entity type
+ * @publicId: The public ID of the entity
+ * @systemId: The system ID of the entity
+ * @content: the entity value (without processing).
+ *
+ * An entity definition has been parsed.
+ */
+typedef void (*entityDeclSAXFunc) (void *ctx,
+ const xmlChar *name,
+ int type,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ xmlChar *content);
+/**
+ * notationDeclSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The name of the notation
+ * @publicId: The public ID of the entity
+ * @systemId: The system ID of the entity
+ *
+ * What to do when a notation declaration has been parsed.
+ */
+typedef void (*notationDeclSAXFunc)(void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId);
+/**
+ * attributeDeclSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @elem: the name of the element
+ * @fullname: the attribute name
+ * @type: the attribute type
+ * @def: the type of default value
+ * @defaultValue: the attribute default value
+ * @tree: the tree of enumerated value set
+ *
+ * An attribute definition has been parsed.
+ */
+typedef void (*attributeDeclSAXFunc)(void *ctx,
+ const xmlChar *elem,
+ const xmlChar *fullname,
+ int type,
+ int def,
+ const xmlChar *defaultValue,
+ xmlEnumerationPtr tree);
+/**
+ * elementDeclSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: the element name
+ * @type: the element type
+ * @content: the element value tree
+ *
+ * An element definition has been parsed.
+ */
+typedef void (*elementDeclSAXFunc)(void *ctx,
+ const xmlChar *name,
+ int type,
+ xmlElementContentPtr content);
+/**
+ * unparsedEntityDeclSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The name of the entity
+ * @publicId: The public ID of the entity
+ * @systemId: The system ID of the entity
+ * @notationName: the name of the notation
+ *
+ * What to do when an unparsed entity declaration is parsed.
+ */
+typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
+ const xmlChar *name,
+ const xmlChar *publicId,
+ const xmlChar *systemId,
+ const xmlChar *notationName);
+/**
+ * setDocumentLocatorSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @loc: A SAX Locator
+ *
+ * Receive the document locator at startup, actually xmlDefaultSAXLocator.
+ * Everything is available on the context, so this is useless in our case.
+ */
+typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
+ xmlSAXLocatorPtr loc);
+/**
+ * startDocumentSAXFunc:
+ * @ctx: the user data (XML parser context)
+ *
+ * Called when the document start being processed.
+ */
+typedef void (*startDocumentSAXFunc) (void *ctx);
+/**
+ * endDocumentSAXFunc:
+ * @ctx: the user data (XML parser context)
+ *
+ * Called when the document end has been detected.
+ */
+typedef void (*endDocumentSAXFunc) (void *ctx);
+/**
+ * startElementSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The element name, including namespace prefix
+ * @atts: An array of name/value attributes pairs, NULL terminated
+ *
+ * Called when an opening tag has been processed.
+ */
+typedef void (*startElementSAXFunc) (void *ctx,
+ const xmlChar *name,
+ const xmlChar **atts);
+/**
+ * endElementSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The element name
+ *
+ * Called when the end of an element has been detected.
+ */
+typedef void (*endElementSAXFunc) (void *ctx,
+ const xmlChar *name);
+/**
+ * attributeSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The attribute name, including namespace prefix
+ * @value: The attribute value
+ *
+ * Handle an attribute that has been read by the parser.
+ * The default handling is to convert the attribute into an
+ * DOM subtree and past it in a new xmlAttr element added to
+ * the element.
+ */
+typedef void (*attributeSAXFunc) (void *ctx,
+ const xmlChar *name,
+ const xmlChar *value);
+/**
+ * referenceSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @name: The entity name
+ *
+ * Called when an entity reference is detected.
+ */
+typedef void (*referenceSAXFunc) (void *ctx,
+ const xmlChar *name);
+/**
+ * charactersSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @ch: a xmlChar string
+ * @len: the number of xmlChar
+ *
+ * Receiving some chars from the parser.
+ */
+typedef void (*charactersSAXFunc) (void *ctx,
+ const xmlChar *ch,
+ int len);
+/**
+ * ignorableWhitespaceSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @ch: a xmlChar string
+ * @len: the number of xmlChar
+ *
+ * Receiving some ignorable whitespaces from the parser.
+ * UNUSED: by default the DOM building will use characters.
+ */
+typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
+ const xmlChar *ch,
+ int len);
+/**
+ * processingInstructionSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @target: the target name
+ * @data: the PI data's
+ *
+ * A processing instruction has been parsed.
+ */
+typedef void (*processingInstructionSAXFunc) (void *ctx,
+ const xmlChar *target,
+ const xmlChar *data);
+/**
+ * commentSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @value: the comment content
+ *
+ * A comment has been parsed.
+ */
+typedef void (*commentSAXFunc) (void *ctx,
+ const xmlChar *value);
+/**
+ * cdataBlockSAXFunc:
+ * @ctx: the user data (XML parser context)
+ * @value: The pcdata content
+ * @len: the block length
+ *
+ * Called when a pcdata block has been parsed.
+ */
+typedef void (*cdataBlockSAXFunc) (
+ void *ctx,
+ const xmlChar *value,
+ int len);
+/**
+ * warningSAXFunc:
+ * @ctx: an XML parser context
+ * @msg: the message to display/transmit
+ * @...: extra parameters for the message display
+ *
+ * Display and format a warning messages, callback.
+ */
+typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * errorSAXFunc:
+ * @ctx: an XML parser context
+ * @msg: the message to display/transmit
+ * @...: extra parameters for the message display
+ *
+ * Display and format an error messages, callback.
+ */
+typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * fatalErrorSAXFunc:
+ * @ctx: an XML parser context
+ * @msg: the message to display/transmit
+ * @...: extra parameters for the message display
+ *
+ * Display and format fatal error messages, callback.
+ * Note: so far fatalError() SAX callbacks are not used, error()
+ * get all the callbacks for errors.
+ */
+typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * isStandaloneSAXFunc:
+ * @ctx: the user data (XML parser context)
+ *
+ * Is this document tagged standalone?
+ *
+ * Returns 1 if true
+ */
+typedef int (*isStandaloneSAXFunc) (void *ctx);
+/**
+ * hasInternalSubsetSAXFunc:
+ * @ctx: the user data (XML parser context)
+ *
+ * Does this document has an internal subset.
+ *
+ * Returns 1 if true
+ */
+typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
+
+/**
+ * hasExternalSubsetSAXFunc:
+ * @ctx: the user data (XML parser context)
+ *
+ * Does this document has an external subset?
+ *
+ * Returns 1 if true
+ */
+typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
+
+/************************************************************************
+ * *
+ * The SAX version 2 API extensions *
+ * *
+ ************************************************************************/
+/**
+ * XML_SAX2_MAGIC:
+ *
+ * Special constant found in SAX2 blocks initialized fields
+ */
+#define XML_SAX2_MAGIC 0xDEEDBEAF
+
+/**
+ * startElementNsSAX2Func:
+ * @ctx: the user data (XML parser context)
+ * @localname: the local name of the element
+ * @prefix: the element namespace prefix if available
+ * @URI: the element namespace name if available
+ * @nb_namespaces: number of namespace definitions on that node
+ * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
+ * @nb_attributes: the number of attributes on that node
+ * @nb_defaulted: the number of defaulted attributes. The defaulted
+ * ones are at the end of the array
+ * @attributes: pointer to the array of (localname/prefix/URI/value/end)
+ * attribute values.
+ *
+ * SAX2 callback when an element start has been detected by the parser.
+ * It provides the namespace informations for the element, as well as
+ * the new namespace declarations on the element.
+ */
+
+typedef void (*startElementNsSAX2Func) (void *ctx,
+ const xmlChar *localname,
+ const xmlChar *prefix,
+ const xmlChar *URI,
+ int nb_namespaces,
+ const xmlChar **namespaces,
+ int nb_attributes,
+ int nb_defaulted,
+ const xmlChar **attributes);
+
+/**
+ * endElementNsSAX2Func:
+ * @ctx: the user data (XML parser context)
+ * @localname: the local name of the element
+ * @prefix: the element namespace prefix if available
+ * @URI: the element namespace name if available
+ *
+ * SAX2 callback when an element end has been detected by the parser.
+ * It provides the namespace informations for the element.
+ */
+
+typedef void (*endElementNsSAX2Func) (void *ctx,
+ const xmlChar *localname,
+ const xmlChar *prefix,
+ const xmlChar *URI);
+
+
+struct _xmlSAXHandler {
+ internalSubsetSAXFunc internalSubset;
+ isStandaloneSAXFunc isStandalone;
+ hasInternalSubsetSAXFunc hasInternalSubset;
+ hasExternalSubsetSAXFunc hasExternalSubset;
+ resolveEntitySAXFunc resolveEntity;
+ getEntitySAXFunc getEntity;
+ entityDeclSAXFunc entityDecl;
+ notationDeclSAXFunc notationDecl;
+ attributeDeclSAXFunc attributeDecl;
+ elementDeclSAXFunc elementDecl;
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
+ setDocumentLocatorSAXFunc setDocumentLocator;
+ startDocumentSAXFunc startDocument;
+ endDocumentSAXFunc endDocument;
+ startElementSAXFunc startElement;
+ endElementSAXFunc endElement;
+ referenceSAXFunc reference;
+ charactersSAXFunc characters;
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
+ processingInstructionSAXFunc processingInstruction;
+ commentSAXFunc comment;
+ warningSAXFunc warning;
+ errorSAXFunc error;
+ fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
+ getParameterEntitySAXFunc getParameterEntity;
+ cdataBlockSAXFunc cdataBlock;
+ externalSubsetSAXFunc externalSubset;
+ unsigned int initialized;
+ /* The following fields are extensions available only on version 2 */
+ void *_private;
+ startElementNsSAX2Func startElementNs;
+ endElementNsSAX2Func endElementNs;
+ xmlStructuredErrorFunc serror;
+};
+
+/*
+ * SAX Version 1
+ */
+typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
+typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
+struct _xmlSAXHandlerV1 {
+ internalSubsetSAXFunc internalSubset;
+ isStandaloneSAXFunc isStandalone;
+ hasInternalSubsetSAXFunc hasInternalSubset;
+ hasExternalSubsetSAXFunc hasExternalSubset;
+ resolveEntitySAXFunc resolveEntity;
+ getEntitySAXFunc getEntity;
+ entityDeclSAXFunc entityDecl;
+ notationDeclSAXFunc notationDecl;
+ attributeDeclSAXFunc attributeDecl;
+ elementDeclSAXFunc elementDecl;
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
+ setDocumentLocatorSAXFunc setDocumentLocator;
+ startDocumentSAXFunc startDocument;
+ endDocumentSAXFunc endDocument;
+ startElementSAXFunc startElement;
+ endElementSAXFunc endElement;
+ referenceSAXFunc reference;
+ charactersSAXFunc characters;
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
+ processingInstructionSAXFunc processingInstruction;
+ commentSAXFunc comment;
+ warningSAXFunc warning;
+ errorSAXFunc error;
+ fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
+ getParameterEntitySAXFunc getParameterEntity;
+ cdataBlockSAXFunc cdataBlock;
+ externalSubsetSAXFunc externalSubset;
+ unsigned int initialized;
+};
+
+
+/**
+ * xmlExternalEntityLoader:
+ * @URL: The System ID of the resource requested
+ * @ID: The Public ID of the resource requested
+ * @context: the XML parser context
+ *
+ * External entity loaders types.
+ *
+ * Returns the entity input parser.
+ */
+typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
+ const char *ID,
+ xmlParserCtxtPtr context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Init/Cleanup
+ */
+XMLPUBFUN void XMLCALL
+ xmlInitParser (void);
+XMLPUBFUN void XMLCALL
+ xmlCleanupParser (void);
+
+/*
+ * Input functions
+ */
+XMLPUBFUN int XMLCALL
+ xmlParserInputRead (xmlParserInputPtr in,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlParserInputGrow (xmlParserInputPtr in,
+ int len);
+
+/*
+ * Basic parsing Interfaces
+ */
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlParseDoc (const xmlChar *cur);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlParseFile (const char *filename);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlParseMemory (const char *buffer,
+ int size);
+#endif /* LIBXML_SAX1_ENABLED */
+XMLPUBFUN int XMLCALL
+ xmlSubstituteEntitiesDefault(int val);
+XMLPUBFUN int XMLCALL
+ xmlKeepBlanksDefault (int val);
+XMLPUBFUN void XMLCALL
+ xmlStopParser (xmlParserCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlPedanticParserDefault(int val);
+XMLPUBFUN int XMLCALL
+ xmlLineNumbersDefault (int val);
+
+#ifdef LIBXML_SAX1_ENABLED
+/*
+ * Recovery mode
+ */
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlRecoverDoc (const xmlChar *cur);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlRecoverMemory (const char *buffer,
+ int size);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlRecoverFile (const char *filename);
+#endif /* LIBXML_SAX1_ENABLED */
+
+/*
+ * Less common routines and SAX interfaces
+ */
+XMLPUBFUN int XMLCALL
+ xmlParseDocument (xmlParserCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
+ void *user_data,
+ const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
+ void *user_data,
+ const char *buffer,
+ int size);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseDoc (xmlSAXHandlerPtr sax,
+ const xmlChar *cur,
+ int recovery);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseMemory (xmlSAXHandlerPtr sax,
+ const char *buffer,
+ int size,
+ int recovery);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
+ const char *buffer,
+ int size,
+ int recovery,
+ void *data);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseFile (xmlSAXHandlerPtr sax,
+ const char *filename,
+ int recovery);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
+ const char *filename,
+ int recovery,
+ void *data);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlSAXParseEntity (xmlSAXHandlerPtr sax,
+ const char *filename);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlParseEntity (const char *filename);
+#endif /* LIBXML_SAX1_ENABLED */
+
+#ifdef LIBXML_VALID_ENABLED
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlSAXParseDTD (xmlSAXHandlerPtr sax,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlParseDTD (const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlIOParseDTD (xmlSAXHandlerPtr sax,
+ xmlParserInputBufferPtr input,
+ xmlCharEncoding enc);
+#endif /* LIBXML_VALID_ENABLE */
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlParseBalancedChunkMemory(xmlDocPtr doc,
+ xmlSAXHandlerPtr sax,
+ void *user_data,
+ int depth,
+ const xmlChar *string,
+ xmlNodePtr *lst);
+#endif /* LIBXML_SAX1_ENABLED */
+XMLPUBFUN xmlParserErrors XMLCALL
+ xmlParseInNodeContext (xmlNodePtr node,
+ const char *data,
+ int datalen,
+ int options,
+ xmlNodePtr *lst);
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
+ xmlSAXHandlerPtr sax,
+ void *user_data,
+ int depth,
+ const xmlChar *string,
+ xmlNodePtr *lst,
+ int recover);
+XMLPUBFUN int XMLCALL
+ xmlParseExternalEntity (xmlDocPtr doc,
+ xmlSAXHandlerPtr sax,
+ void *user_data,
+ int depth,
+ const xmlChar *URL,
+ const xmlChar *ID,
+ xmlNodePtr *lst);
+#endif /* LIBXML_SAX1_ENABLED */
+XMLPUBFUN int XMLCALL
+ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
+ const xmlChar *URL,
+ const xmlChar *ID,
+ xmlNodePtr *lst);
+
+/*
+ * Parser contexts handling.
+ */
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlNewParserCtxt (void);
+XMLPUBFUN int XMLCALL
+ xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
+#ifdef LIBXML_SAX1_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
+ const xmlChar* buffer,
+ const char *filename);
+#endif /* LIBXML_SAX1_ENABLED */
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlCreateDocParserCtxt (const xmlChar *cur);
+
+#ifdef LIBXML_LEGACY_ENABLED
+/*
+ * Reading/setting optional parsing features.
+ */
+XMLPUBFUN int XMLCALL
+ xmlGetFeaturesList (int *len,
+ const char **result);
+XMLPUBFUN int XMLCALL
+ xmlGetFeature (xmlParserCtxtPtr ctxt,
+ const char *name,
+ void *result);
+XMLPUBFUN int XMLCALL
+ xmlSetFeature (xmlParserCtxtPtr ctxt,
+ const char *name,
+ void *value);
+#endif /* LIBXML_LEGACY_ENABLED */
+
+#ifdef LIBXML_PUSH_ENABLED
+/*
+ * Interfaces for the Push mode.
+ */
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
+ void *user_data,
+ const char *chunk,
+ int size,
+ const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlParseChunk (xmlParserCtxtPtr ctxt,
+ const char *chunk,
+ int size,
+ int terminate);
+#endif /* LIBXML_PUSH_ENABLED */
+
+/*
+ * Special I/O mode.
+ */
+
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
+ void *user_data,
+ xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ xmlCharEncoding enc);
+
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
+ xmlParserInputBufferPtr input,
+ xmlCharEncoding enc);
+
+/*
+ * Node infos.
+ */
+XMLPUBFUN const xmlParserNodeInfo* XMLCALL
+ xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
+ const xmlNodePtr node);
+XMLPUBFUN void XMLCALL
+ xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
+XMLPUBFUN void XMLCALL
+ xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
+XMLPUBFUN unsigned long XMLCALL
+ xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
+ const xmlNodePtr node);
+XMLPUBFUN void XMLCALL
+ xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
+ const xmlParserNodeInfoPtr info);
+
+/*
+ * External entities handling actually implemented in xmlIO.
+ */
+
+XMLPUBFUN void XMLCALL
+ xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
+XMLPUBFUN xmlExternalEntityLoader XMLCALL
+ xmlGetExternalEntityLoader(void);
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ xmlLoadExternalEntity (const char *URL,
+ const char *ID,
+ xmlParserCtxtPtr ctxt);
+
+/*
+ * Index lookup, actually implemented in the encoding module
+ */
+XMLPUBFUN long XMLCALL
+ xmlByteConsumed (xmlParserCtxtPtr ctxt);
+
+/*
+ * New set of simpler/more flexible APIs
+ */
+/**
+ * xmlParserOption:
+ *
+ * This is the set of XML parser options that can be passed down
+ * to the xmlReadDoc() and similar calls.
+ */
+typedef enum {
+ XML_PARSE_RECOVER = 1<<0, /* recover on errors */
+ XML_PARSE_NOENT = 1<<1, /* substitute entities */
+ XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
+ XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
+ XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
+ XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
+ XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
+ XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
+ XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
+ XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
+ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
+ XML_PARSE_NONET = 1<<11,/* Forbid network access */
+ XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
+ XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
+ XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
+ XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
+ XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
+ the tree allowed afterwards (will possibly
+ crash if you try to modify the tree) */
+ XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
+ XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
+ XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
+ XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
+ XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
+ XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
+} xmlParserOption;
+
+XMLPUBFUN void XMLCALL
+ xmlCtxtReset (xmlParserCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
+ const char *chunk,
+ int size,
+ const char *filename,
+ const char *encoding);
+XMLPUBFUN int XMLCALL
+ xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlReadDoc (const xmlChar *cur,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlReadFile (const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlReadMemory (const char *buffer,
+ int size,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlReadFd (int fd,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlReadIO (xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
+ const xmlChar *cur,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
+ const char *filename,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
+ const char *buffer,
+ int size,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
+ int fd,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
+ xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ const char *URL,
+ const char *encoding,
+ int options);
+
+/*
+ * Library wide options
+ */
+/**
+ * xmlFeature:
+ *
+ * Used to examine the existance of features that can be enabled
+ * or disabled at compile-time.
+ * They used to be called XML_FEATURE_xxx but this clashed with Expat
+ */
+typedef enum {
+ XML_WITH_THREAD = 1,
+ XML_WITH_TREE = 2,
+ XML_WITH_OUTPUT = 3,
+ XML_WITH_PUSH = 4,
+ XML_WITH_READER = 5,
+ XML_WITH_PATTERN = 6,
+ XML_WITH_WRITER = 7,
+ XML_WITH_SAX1 = 8,
+ XML_WITH_FTP = 9,
+ XML_WITH_HTTP = 10,
+ XML_WITH_VALID = 11,
+ XML_WITH_HTML = 12,
+ XML_WITH_LEGACY = 13,
+ XML_WITH_C14N = 14,
+ XML_WITH_CATALOG = 15,
+ XML_WITH_XPATH = 16,
+ XML_WITH_XPTR = 17,
+ XML_WITH_XINCLUDE = 18,
+ XML_WITH_ICONV = 19,
+ XML_WITH_ISO8859X = 20,
+ XML_WITH_UNICODE = 21,
+ XML_WITH_REGEXP = 22,
+ XML_WITH_AUTOMATA = 23,
+ XML_WITH_EXPR = 24,
+ XML_WITH_SCHEMAS = 25,
+ XML_WITH_SCHEMATRON = 26,
+ XML_WITH_MODULES = 27,
+ XML_WITH_DEBUG = 28,
+ XML_WITH_DEBUG_MEM = 29,
+ XML_WITH_DEBUG_RUN = 30,
+ XML_WITH_ZLIB = 31,
+ XML_WITH_ICU = 32,
+ XML_WITH_LZMA = 33,
+ XML_WITH_NONE = 99999 /* just to be sure of allocation size */
+} xmlFeature;
+
+XMLPUBFUN int XMLCALL
+ xmlHasFeature (xmlFeature feature);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_PARSER_H__ */
diff --git a/fmu10/src/shared/libxml/relaxng.h b/fmu10/src/shared/libxml/relaxng.h
new file mode 100644
index 0000000..bdb0a7d
--- /dev/null
+++ b/fmu10/src/shared/libxml/relaxng.h
@@ -0,0 +1,213 @@
+/*
+ * Summary: implementation of the Relax-NG validation
+ * Description: implementation of the Relax-NG validation
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_RELAX_NG__
+#define __XML_RELAX_NG__
+
+#include
+#include
+#include
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _xmlRelaxNG xmlRelaxNG;
+typedef xmlRelaxNG *xmlRelaxNGPtr;
+
+
+/**
+ * xmlRelaxNGValidityErrorFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of an error callback from a Relax-NG validation
+ */
+typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * xmlRelaxNGValidityWarningFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of a warning callback from a Relax-NG validation
+ */
+typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * A schemas validation context
+ */
+typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;
+typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;
+
+typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;
+typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;
+
+/*
+ * xmlRelaxNGValidErr:
+ *
+ * List of possible Relax NG validation errors
+ */
+typedef enum {
+ XML_RELAXNG_OK = 0,
+ XML_RELAXNG_ERR_MEMORY,
+ XML_RELAXNG_ERR_TYPE,
+ XML_RELAXNG_ERR_TYPEVAL,
+ XML_RELAXNG_ERR_DUPID,
+ XML_RELAXNG_ERR_TYPECMP,
+ XML_RELAXNG_ERR_NOSTATE,
+ XML_RELAXNG_ERR_NODEFINE,
+ XML_RELAXNG_ERR_LISTEXTRA,
+ XML_RELAXNG_ERR_LISTEMPTY,
+ XML_RELAXNG_ERR_INTERNODATA,
+ XML_RELAXNG_ERR_INTERSEQ,
+ XML_RELAXNG_ERR_INTEREXTRA,
+ XML_RELAXNG_ERR_ELEMNAME,
+ XML_RELAXNG_ERR_ATTRNAME,
+ XML_RELAXNG_ERR_ELEMNONS,
+ XML_RELAXNG_ERR_ATTRNONS,
+ XML_RELAXNG_ERR_ELEMWRONGNS,
+ XML_RELAXNG_ERR_ATTRWRONGNS,
+ XML_RELAXNG_ERR_ELEMEXTRANS,
+ XML_RELAXNG_ERR_ATTREXTRANS,
+ XML_RELAXNG_ERR_ELEMNOTEMPTY,
+ XML_RELAXNG_ERR_NOELEM,
+ XML_RELAXNG_ERR_NOTELEM,
+ XML_RELAXNG_ERR_ATTRVALID,
+ XML_RELAXNG_ERR_CONTENTVALID,
+ XML_RELAXNG_ERR_EXTRACONTENT,
+ XML_RELAXNG_ERR_INVALIDATTR,
+ XML_RELAXNG_ERR_DATAELEM,
+ XML_RELAXNG_ERR_VALELEM,
+ XML_RELAXNG_ERR_LISTELEM,
+ XML_RELAXNG_ERR_DATATYPE,
+ XML_RELAXNG_ERR_VALUE,
+ XML_RELAXNG_ERR_LIST,
+ XML_RELAXNG_ERR_NOGRAMMAR,
+ XML_RELAXNG_ERR_EXTRADATA,
+ XML_RELAXNG_ERR_LACKDATA,
+ XML_RELAXNG_ERR_INTERNAL,
+ XML_RELAXNG_ERR_ELEMWRONG,
+ XML_RELAXNG_ERR_TEXTWRONG
+} xmlRelaxNGValidErr;
+
+/*
+ * xmlRelaxNGParserFlags:
+ *
+ * List of possible Relax NG Parser flags
+ */
+typedef enum {
+ XML_RELAXNGP_NONE = 0,
+ XML_RELAXNGP_FREE_DOC = 1,
+ XML_RELAXNGP_CRNG = 2
+} xmlRelaxNGParserFlag;
+
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGInitTypes (void);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGCleanupTypes (void);
+
+/*
+ * Interfaces for parsing.
+ */
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+ xmlRelaxNGNewParserCtxt (const char *URL);
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+ xmlRelaxNGNewMemParserCtxt (const char *buffer,
+ int size);
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+ xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc);
+
+XMLPUBFUN int XMLCALL
+ xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt,
+ int flag);
+
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
+ xmlRelaxNGValidityErrorFunc err,
+ xmlRelaxNGValidityWarningFunc warn,
+ void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
+ xmlRelaxNGValidityErrorFunc *err,
+ xmlRelaxNGValidityWarningFunc *warn,
+ void **ctx);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGSetParserStructuredErrors(
+ xmlRelaxNGParserCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror,
+ void *ctx);
+XMLPUBFUN xmlRelaxNGPtr XMLCALL
+ xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGFree (xmlRelaxNGPtr schema);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGDump (FILE *output,
+ xmlRelaxNGPtr schema);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGDumpTree (FILE * output,
+ xmlRelaxNGPtr schema);
+#endif /* LIBXML_OUTPUT_ENABLED */
+/*
+ * Interfaces for validating
+ */
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
+ xmlRelaxNGValidityErrorFunc err,
+ xmlRelaxNGValidityWarningFunc warn,
+ void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
+ xmlRelaxNGValidityErrorFunc *err,
+ xmlRelaxNGValidityWarningFunc *warn,
+ void **ctx);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror, void *ctx);
+XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
+ xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema);
+XMLPUBFUN void XMLCALL
+ xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt,
+ xmlDocPtr doc);
+/*
+ * Interfaces for progressive validation when possible
+ */
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
+ const xmlChar *data,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem);
+XMLPUBFUN int XMLCALL
+ xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_SCHEMAS_ENABLED */
+
+#endif /* __XML_RELAX_NG__ */
diff --git a/fmu10/src/shared/libxml/threads.h b/fmu10/src/shared/libxml/threads.h
new file mode 100644
index 0000000..d31f16a
--- /dev/null
+++ b/fmu10/src/shared/libxml/threads.h
@@ -0,0 +1,84 @@
+/**
+ * Summary: interfaces for thread handling
+ * Description: set of generic threading related routines
+ * should work with pthreads, Windows native or TLS threads
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_THREADS_H__
+#define __XML_THREADS_H__
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * xmlMutex are a simple mutual exception locks.
+ */
+typedef struct _xmlMutex xmlMutex;
+typedef xmlMutex *xmlMutexPtr;
+
+/*
+ * xmlRMutex are reentrant mutual exception locks.
+ */
+typedef struct _xmlRMutex xmlRMutex;
+typedef xmlRMutex *xmlRMutexPtr;
+
+#ifdef __cplusplus
+}
+#endif
+#include
+#ifdef __cplusplus
+extern "C" {
+#endif
+XMLPUBFUN xmlMutexPtr XMLCALL
+ xmlNewMutex (void);
+XMLPUBFUN void XMLCALL
+ xmlMutexLock (xmlMutexPtr tok);
+XMLPUBFUN void XMLCALL
+ xmlMutexUnlock (xmlMutexPtr tok);
+XMLPUBFUN void XMLCALL
+ xmlFreeMutex (xmlMutexPtr tok);
+
+XMLPUBFUN xmlRMutexPtr XMLCALL
+ xmlNewRMutex (void);
+XMLPUBFUN void XMLCALL
+ xmlRMutexLock (xmlRMutexPtr tok);
+XMLPUBFUN void XMLCALL
+ xmlRMutexUnlock (xmlRMutexPtr tok);
+XMLPUBFUN void XMLCALL
+ xmlFreeRMutex (xmlRMutexPtr tok);
+
+/*
+ * Library wide APIs.
+ */
+XMLPUBFUN void XMLCALL
+ xmlInitThreads (void);
+XMLPUBFUN void XMLCALL
+ xmlLockLibrary (void);
+XMLPUBFUN void XMLCALL
+ xmlUnlockLibrary(void);
+XMLPUBFUN int XMLCALL
+ xmlGetThreadId (void);
+XMLPUBFUN int XMLCALL
+ xmlIsMainThread (void);
+XMLPUBFUN void XMLCALL
+ xmlCleanupThreads(void);
+XMLPUBFUN xmlGlobalStatePtr XMLCALL
+ xmlGetGlobalState(void);
+
+#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
+int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __XML_THREADS_H__ */
diff --git a/fmu10/src/shared/libxml/tree.h b/fmu10/src/shared/libxml/tree.h
new file mode 100644
index 0000000..7e06686
--- /dev/null
+++ b/fmu10/src/shared/libxml/tree.h
@@ -0,0 +1,1303 @@
+/*
+ * Summary: interfaces for tree manipulation
+ * Description: this module describes the structures found in an tree resulting
+ * from an XML or HTML parsing, as well as the API provided for
+ * various processing on that tree
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_TREE_H__
+#define __XML_TREE_H__
+
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Some of the basic types pointer to structures:
+ */
+/* xmlIO.h */
+typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
+typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
+
+typedef struct _xmlOutputBuffer xmlOutputBuffer;
+typedef xmlOutputBuffer *xmlOutputBufferPtr;
+
+/* parser.h */
+typedef struct _xmlParserInput xmlParserInput;
+typedef xmlParserInput *xmlParserInputPtr;
+
+typedef struct _xmlParserCtxt xmlParserCtxt;
+typedef xmlParserCtxt *xmlParserCtxtPtr;
+
+typedef struct _xmlSAXLocator xmlSAXLocator;
+typedef xmlSAXLocator *xmlSAXLocatorPtr;
+
+typedef struct _xmlSAXHandler xmlSAXHandler;
+typedef xmlSAXHandler *xmlSAXHandlerPtr;
+
+/* entities.h */
+typedef struct _xmlEntity xmlEntity;
+typedef xmlEntity *xmlEntityPtr;
+
+/**
+ * BASE_BUFFER_SIZE:
+ *
+ * default buffer size 4000.
+ */
+#define BASE_BUFFER_SIZE 4096
+
+/**
+ * LIBXML_NAMESPACE_DICT:
+ *
+ * Defines experimental behaviour:
+ * 1) xmlNs gets an additional field @context (a xmlDoc)
+ * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc.
+ */
+/* #define LIBXML_NAMESPACE_DICT */
+
+/**
+ * xmlBufferAllocationScheme:
+ *
+ * A buffer allocation scheme can be defined to either match exactly the
+ * need or double it's allocated size each time it is found too small.
+ */
+
+typedef enum {
+ XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
+ XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
+ XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
+ XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
+ XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */
+} xmlBufferAllocationScheme;
+
+/**
+ * xmlBuffer:
+ *
+ * A buffer structure, this old construct is limited to 2GB and
+ * is being deprecated, use API with xmlBuf instead
+ */
+typedef struct _xmlBuffer xmlBuffer;
+typedef xmlBuffer *xmlBufferPtr;
+struct _xmlBuffer {
+ xmlChar *content; /* The buffer content UTF8 */
+ unsigned int use; /* The buffer size used */
+ unsigned int size; /* The buffer size */
+ xmlBufferAllocationScheme alloc; /* The realloc method */
+ xmlChar *contentIO; /* in IO mode we may have a different base */
+};
+
+/**
+ * xmlBuf:
+ *
+ * A buffer structure, new one, the actual structure internals are not public
+ */
+
+typedef struct _xmlBuf xmlBuf;
+
+/**
+ * xmlBufPtr:
+ *
+ * A pointer to a buffer structure, the actual structure internals are not
+ * public
+ */
+
+typedef xmlBuf *xmlBufPtr;
+
+/*
+ * A few public routines for xmlBuf. As those are expected to be used
+ * mostly internally the bulk of the routines are internal in buf.h
+ */
+XMLPUBFUN xmlChar* XMLCALL xmlBufContent (const xmlBufPtr buf);
+XMLPUBFUN xmlChar* XMLCALL xmlBufEnd (const xmlBufPtr buf);
+XMLPUBFUN size_t XMLCALL xmlBufUse (const xmlBufPtr buf);
+XMLPUBFUN size_t XMLCALL xmlBufShrink (xmlBufPtr buf, size_t len);
+
+/*
+ * LIBXML2_NEW_BUFFER:
+ *
+ * Macro used to express that the API use the new buffers for
+ * xmlParserInputBuffer and xmlOutputBuffer. The change was
+ * introduced in 2.9.0.
+ */
+#define LIBXML2_NEW_BUFFER
+
+/**
+ * XML_XML_NAMESPACE:
+ *
+ * This is the namespace for the special xml: prefix predefined in the
+ * XML Namespace specification.
+ */
+#define XML_XML_NAMESPACE \
+ (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
+
+/**
+ * XML_XML_ID:
+ *
+ * This is the name for the special xml:id attribute
+ */
+#define XML_XML_ID (const xmlChar *) "xml:id"
+
+/*
+ * The different element types carried by an XML tree.
+ *
+ * NOTE: This is synchronized with DOM Level1 values
+ * See http://www.w3.org/TR/REC-DOM-Level-1/
+ *
+ * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
+ * be deprecated to use an XML_DTD_NODE.
+ */
+typedef enum {
+ XML_ELEMENT_NODE= 1,
+ XML_ATTRIBUTE_NODE= 2,
+ XML_TEXT_NODE= 3,
+ XML_CDATA_SECTION_NODE= 4,
+ XML_ENTITY_REF_NODE= 5,
+ XML_ENTITY_NODE= 6,
+ XML_PI_NODE= 7,
+ XML_COMMENT_NODE= 8,
+ XML_DOCUMENT_NODE= 9,
+ XML_DOCUMENT_TYPE_NODE= 10,
+ XML_DOCUMENT_FRAG_NODE= 11,
+ XML_NOTATION_NODE= 12,
+ XML_HTML_DOCUMENT_NODE= 13,
+ XML_DTD_NODE= 14,
+ XML_ELEMENT_DECL= 15,
+ XML_ATTRIBUTE_DECL= 16,
+ XML_ENTITY_DECL= 17,
+ XML_NAMESPACE_DECL= 18,
+ XML_XINCLUDE_START= 19,
+ XML_XINCLUDE_END= 20
+#ifdef LIBXML_DOCB_ENABLED
+ ,XML_DOCB_DOCUMENT_NODE= 21
+#endif
+} xmlElementType;
+
+
+/**
+ * xmlNotation:
+ *
+ * A DTD Notation definition.
+ */
+
+typedef struct _xmlNotation xmlNotation;
+typedef xmlNotation *xmlNotationPtr;
+struct _xmlNotation {
+ const xmlChar *name; /* Notation name */
+ const xmlChar *PublicID; /* Public identifier, if any */
+ const xmlChar *SystemID; /* System identifier, if any */
+};
+
+/**
+ * xmlAttributeType:
+ *
+ * A DTD Attribute type definition.
+ */
+
+typedef enum {
+ XML_ATTRIBUTE_CDATA = 1,
+ XML_ATTRIBUTE_ID,
+ XML_ATTRIBUTE_IDREF ,
+ XML_ATTRIBUTE_IDREFS,
+ XML_ATTRIBUTE_ENTITY,
+ XML_ATTRIBUTE_ENTITIES,
+ XML_ATTRIBUTE_NMTOKEN,
+ XML_ATTRIBUTE_NMTOKENS,
+ XML_ATTRIBUTE_ENUMERATION,
+ XML_ATTRIBUTE_NOTATION
+} xmlAttributeType;
+
+/**
+ * xmlAttributeDefault:
+ *
+ * A DTD Attribute default definition.
+ */
+
+typedef enum {
+ XML_ATTRIBUTE_NONE = 1,
+ XML_ATTRIBUTE_REQUIRED,
+ XML_ATTRIBUTE_IMPLIED,
+ XML_ATTRIBUTE_FIXED
+} xmlAttributeDefault;
+
+/**
+ * xmlEnumeration:
+ *
+ * List structure used when there is an enumeration in DTDs.
+ */
+
+typedef struct _xmlEnumeration xmlEnumeration;
+typedef xmlEnumeration *xmlEnumerationPtr;
+struct _xmlEnumeration {
+ struct _xmlEnumeration *next; /* next one */
+ const xmlChar *name; /* Enumeration name */
+};
+
+/**
+ * xmlAttribute:
+ *
+ * An Attribute declaration in a DTD.
+ */
+
+typedef struct _xmlAttribute xmlAttribute;
+typedef xmlAttribute *xmlAttributePtr;
+struct _xmlAttribute {
+ void *_private; /* application data */
+ xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
+ const xmlChar *name; /* Attribute name */
+ struct _xmlNode *children; /* NULL */
+ struct _xmlNode *last; /* NULL */
+ struct _xmlDtd *parent; /* -> DTD */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+
+ struct _xmlAttribute *nexth; /* next in hash table */
+ xmlAttributeType atype; /* The attribute type */
+ xmlAttributeDefault def; /* the default */
+ const xmlChar *defaultValue; /* or the default value */
+ xmlEnumerationPtr tree; /* or the enumeration tree if any */
+ const xmlChar *prefix; /* the namespace prefix if any */
+ const xmlChar *elem; /* Element holding the attribute */
+};
+
+/**
+ * xmlElementContentType:
+ *
+ * Possible definitions of element content types.
+ */
+typedef enum {
+ XML_ELEMENT_CONTENT_PCDATA = 1,
+ XML_ELEMENT_CONTENT_ELEMENT,
+ XML_ELEMENT_CONTENT_SEQ,
+ XML_ELEMENT_CONTENT_OR
+} xmlElementContentType;
+
+/**
+ * xmlElementContentOccur:
+ *
+ * Possible definitions of element content occurrences.
+ */
+typedef enum {
+ XML_ELEMENT_CONTENT_ONCE = 1,
+ XML_ELEMENT_CONTENT_OPT,
+ XML_ELEMENT_CONTENT_MULT,
+ XML_ELEMENT_CONTENT_PLUS
+} xmlElementContentOccur;
+
+/**
+ * xmlElementContent:
+ *
+ * An XML Element content as stored after parsing an element definition
+ * in a DTD.
+ */
+
+typedef struct _xmlElementContent xmlElementContent;
+typedef xmlElementContent *xmlElementContentPtr;
+struct _xmlElementContent {
+ xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
+ xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
+ const xmlChar *name; /* Element name */
+ struct _xmlElementContent *c1; /* first child */
+ struct _xmlElementContent *c2; /* second child */
+ struct _xmlElementContent *parent; /* parent */
+ const xmlChar *prefix; /* Namespace prefix */
+};
+
+/**
+ * xmlElementTypeVal:
+ *
+ * The different possibilities for an element content type.
+ */
+
+typedef enum {
+ XML_ELEMENT_TYPE_UNDEFINED = 0,
+ XML_ELEMENT_TYPE_EMPTY = 1,
+ XML_ELEMENT_TYPE_ANY,
+ XML_ELEMENT_TYPE_MIXED,
+ XML_ELEMENT_TYPE_ELEMENT
+} xmlElementTypeVal;
+
+#ifdef __cplusplus
+}
+#endif
+#include
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlElement:
+ *
+ * An XML Element declaration from a DTD.
+ */
+
+typedef struct _xmlElement xmlElement;
+typedef xmlElement *xmlElementPtr;
+struct _xmlElement {
+ void *_private; /* application data */
+ xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
+ const xmlChar *name; /* Element name */
+ struct _xmlNode *children; /* NULL */
+ struct _xmlNode *last; /* NULL */
+ struct _xmlDtd *parent; /* -> DTD */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+
+ xmlElementTypeVal etype; /* The type */
+ xmlElementContentPtr content; /* the allowed element content */
+ xmlAttributePtr attributes; /* List of the declared attributes */
+ const xmlChar *prefix; /* the namespace prefix if any */
+#ifdef LIBXML_REGEXP_ENABLED
+ xmlRegexpPtr contModel; /* the validating regexp */
+#else
+ void *contModel;
+#endif
+};
+
+
+/**
+ * XML_LOCAL_NAMESPACE:
+ *
+ * A namespace declaration node.
+ */
+#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
+typedef xmlElementType xmlNsType;
+
+/**
+ * xmlNs:
+ *
+ * An XML namespace.
+ * Note that prefix == NULL is valid, it defines the default namespace
+ * within the subtree (until overridden).
+ *
+ * xmlNsType is unified with xmlElementType.
+ */
+
+typedef struct _xmlNs xmlNs;
+typedef xmlNs *xmlNsPtr;
+struct _xmlNs {
+ struct _xmlNs *next; /* next Ns link for this node */
+ xmlNsType type; /* global or local */
+ const xmlChar *href; /* URL for the namespace */
+ const xmlChar *prefix; /* prefix for the namespace */
+ void *_private; /* application data */
+ struct _xmlDoc *context; /* normally an xmlDoc */
+};
+
+/**
+ * xmlDtd:
+ *
+ * An XML DTD, as defined by parent link */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+
+ /* End of common part */
+ void *notations; /* Hash table for notations if any */
+ void *elements; /* Hash table for elements if any */
+ void *attributes; /* Hash table for attributes if any */
+ void *entities; /* Hash table for entities if any */
+ const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
+ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
+ void *pentities; /* Hash table for param entities if any */
+};
+
+/**
+ * xmlAttr:
+ *
+ * An attribute on an XML node.
+ */
+typedef struct _xmlAttr xmlAttr;
+typedef xmlAttr *xmlAttrPtr;
+struct _xmlAttr {
+ void *_private; /* application data */
+ xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
+ const xmlChar *name; /* the name of the property */
+ struct _xmlNode *children; /* the value of the property */
+ struct _xmlNode *last; /* NULL */
+ struct _xmlNode *parent; /* child->parent link */
+ struct _xmlAttr *next; /* next sibling link */
+ struct _xmlAttr *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+ xmlNs *ns; /* pointer to the associated namespace */
+ xmlAttributeType atype; /* the attribute type if validating */
+ void *psvi; /* for type/PSVI informations */
+};
+
+/**
+ * xmlID:
+ *
+ * An XML ID instance.
+ */
+
+typedef struct _xmlID xmlID;
+typedef xmlID *xmlIDPtr;
+struct _xmlID {
+ struct _xmlID *next; /* next ID */
+ const xmlChar *value; /* The ID name */
+ xmlAttrPtr attr; /* The attribute holding it */
+ const xmlChar *name; /* The attribute if attr is not available */
+ int lineno; /* The line number if attr is not available */
+ struct _xmlDoc *doc; /* The document holding the ID */
+};
+
+/**
+ * xmlRef:
+ *
+ * An XML IDREF instance.
+ */
+
+typedef struct _xmlRef xmlRef;
+typedef xmlRef *xmlRefPtr;
+struct _xmlRef {
+ struct _xmlRef *next; /* next Ref */
+ const xmlChar *value; /* The Ref name */
+ xmlAttrPtr attr; /* The attribute holding it */
+ const xmlChar *name; /* The attribute if attr is not available */
+ int lineno; /* The line number if attr is not available */
+};
+
+/**
+ * xmlNode:
+ *
+ * A node in an XML tree.
+ */
+typedef struct _xmlNode xmlNode;
+typedef xmlNode *xmlNodePtr;
+struct _xmlNode {
+ void *_private; /* application data */
+ xmlElementType type; /* type number, must be second ! */
+ const xmlChar *name; /* the name of the node, or the entity */
+ struct _xmlNode *children; /* parent->childs link */
+ struct _xmlNode *last; /* last child link */
+ struct _xmlNode *parent; /* child->parent link */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* the containing document */
+
+ /* End of common part */
+ xmlNs *ns; /* pointer to the associated namespace */
+ xmlChar *content; /* the content */
+ struct _xmlAttr *properties;/* properties list */
+ xmlNs *nsDef; /* namespace definitions on this node */
+ void *psvi; /* for type/PSVI informations */
+ unsigned short line; /* line number */
+ unsigned short extra; /* extra data for XPath/XSLT */
+};
+
+/**
+ * XML_GET_CONTENT:
+ *
+ * Macro to extract the content pointer of a node.
+ */
+#define XML_GET_CONTENT(n) \
+ ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content)
+
+/**
+ * XML_GET_LINE:
+ *
+ * Macro to extract the line number of an element node.
+ */
+#define XML_GET_LINE(n) \
+ (xmlGetLineNo(n))
+
+/**
+ * xmlDocProperty
+ *
+ * Set of properties of the document as found by the parser
+ * Some of them are linked to similary named xmlParserOption
+ */
+typedef enum {
+ XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */
+ XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */
+ XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */
+ XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */
+ XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */
+ XML_DOC_USERBUILT = 1<<5, /* Document was built using the API
+ and not by parsing an instance */
+ XML_DOC_INTERNAL = 1<<6, /* built for internal processing */
+ XML_DOC_HTML = 1<<7 /* parsed or built HTML document */
+} xmlDocProperties;
+
+/**
+ * xmlDoc:
+ *
+ * An XML document.
+ */
+typedef struct _xmlDoc xmlDoc;
+typedef xmlDoc *xmlDocPtr;
+struct _xmlDoc {
+ void *_private; /* application data */
+ xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
+ char *name; /* name/filename/URI of the document */
+ struct _xmlNode *children; /* the document tree */
+ struct _xmlNode *last; /* last child link */
+ struct _xmlNode *parent; /* child->parent link */
+ struct _xmlNode *next; /* next sibling link */
+ struct _xmlNode *prev; /* previous sibling link */
+ struct _xmlDoc *doc; /* autoreference to itself */
+
+ /* End of common part */
+ int compression;/* level of zlib compression */
+ int standalone; /* standalone document (no external refs)
+ 1 if standalone="yes"
+ 0 if standalone="no"
+ -1 if there is no XML declaration
+ -2 if there is an XML declaration, but no
+ standalone attribute was specified */
+ struct _xmlDtd *intSubset; /* the document internal subset */
+ struct _xmlDtd *extSubset; /* the document external subset */
+ struct _xmlNs *oldNs; /* Global namespace, the old way */
+ const xmlChar *version; /* the XML version string */
+ const xmlChar *encoding; /* external initial encoding, if any */
+ void *ids; /* Hash table for ID attributes if any */
+ void *refs; /* Hash table for IDREFs attributes if any */
+ const xmlChar *URL; /* The URI for that document */
+ int charset; /* encoding of the in-memory content
+ actually an xmlCharEncoding */
+ struct _xmlDict *dict; /* dict used to allocate names or NULL */
+ void *psvi; /* for type/PSVI informations */
+ int parseFlags; /* set of xmlParserOption used to parse the
+ document */
+ int properties; /* set of xmlDocProperties for this document
+ set at the end of parsing */
+};
+
+
+typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt;
+typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;
+
+/**
+ * xmlDOMWrapAcquireNsFunction:
+ * @ctxt: a DOM wrapper context
+ * @node: the context node (element or attribute)
+ * @nsName: the requested namespace name
+ * @nsPrefix: the requested namespace prefix
+ *
+ * A function called to acquire namespaces (xmlNs) from the wrapper.
+ *
+ * Returns an xmlNsPtr or NULL in case of an error.
+ */
+typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt,
+ xmlNodePtr node,
+ const xmlChar *nsName,
+ const xmlChar *nsPrefix);
+
+/**
+ * xmlDOMWrapCtxt:
+ *
+ * Context for DOM wrapper-operations.
+ */
+struct _xmlDOMWrapCtxt {
+ void * _private;
+ /*
+ * The type of this context, just in case we need specialized
+ * contexts in the future.
+ */
+ int type;
+ /*
+ * Internal namespace map used for various operations.
+ */
+ void * namespaceMap;
+ /*
+ * Use this one to acquire an xmlNsPtr intended for node->ns.
+ * (Note that this is not intended for elem->nsDef).
+ */
+ xmlDOMWrapAcquireNsFunction getNsForNodeFunc;
+};
+
+/**
+ * xmlChildrenNode:
+ *
+ * Macro for compatibility naming layer with libxml1. Maps
+ * to "children."
+ */
+#ifndef xmlChildrenNode
+#define xmlChildrenNode children
+#endif
+
+/**
+ * xmlRootNode:
+ *
+ * Macro for compatibility naming layer with libxml1. Maps
+ * to "children".
+ */
+#ifndef xmlRootNode
+#define xmlRootNode children
+#endif
+
+/*
+ * Variables.
+ */
+
+/*
+ * Some helper functions
+ */
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+XMLPUBFUN int XMLCALL
+ xmlValidateNCName (const xmlChar *value,
+ int space);
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN int XMLCALL
+ xmlValidateQName (const xmlChar *value,
+ int space);
+XMLPUBFUN int XMLCALL
+ xmlValidateName (const xmlChar *value,
+ int space);
+XMLPUBFUN int XMLCALL
+ xmlValidateNMToken (const xmlChar *value,
+ int space);
+#endif
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlBuildQName (const xmlChar *ncname,
+ const xmlChar *prefix,
+ xmlChar *memory,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlSplitQName2 (const xmlChar *name,
+ xmlChar **prefix);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlSplitQName3 (const xmlChar *name,
+ int *len);
+
+/*
+ * Handling Buffers, the old ones see @xmlBuf for the new ones.
+ */
+
+XMLPUBFUN void XMLCALL
+ xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
+XMLPUBFUN xmlBufferAllocationScheme XMLCALL
+ xmlGetBufferAllocationScheme(void);
+
+XMLPUBFUN xmlBufferPtr XMLCALL
+ xmlBufferCreate (void);
+XMLPUBFUN xmlBufferPtr XMLCALL
+ xmlBufferCreateSize (size_t size);
+XMLPUBFUN xmlBufferPtr XMLCALL
+ xmlBufferCreateStatic (void *mem,
+ size_t size);
+XMLPUBFUN int XMLCALL
+ xmlBufferResize (xmlBufferPtr buf,
+ unsigned int size);
+XMLPUBFUN void XMLCALL
+ xmlBufferFree (xmlBufferPtr buf);
+XMLPUBFUN int XMLCALL
+ xmlBufferDump (FILE *file,
+ xmlBufferPtr buf);
+XMLPUBFUN int XMLCALL
+ xmlBufferAdd (xmlBufferPtr buf,
+ const xmlChar *str,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlBufferAddHead (xmlBufferPtr buf,
+ const xmlChar *str,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlBufferCat (xmlBufferPtr buf,
+ const xmlChar *str);
+XMLPUBFUN int XMLCALL
+ xmlBufferCCat (xmlBufferPtr buf,
+ const char *str);
+XMLPUBFUN int XMLCALL
+ xmlBufferShrink (xmlBufferPtr buf,
+ unsigned int len);
+XMLPUBFUN int XMLCALL
+ xmlBufferGrow (xmlBufferPtr buf,
+ unsigned int len);
+XMLPUBFUN void XMLCALL
+ xmlBufferEmpty (xmlBufferPtr buf);
+XMLPUBFUN const xmlChar* XMLCALL
+ xmlBufferContent (const xmlBufferPtr buf);
+XMLPUBFUN xmlChar* XMLCALL
+ xmlBufferDetach (xmlBufferPtr buf);
+XMLPUBFUN void XMLCALL
+ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
+ xmlBufferAllocationScheme scheme);
+XMLPUBFUN int XMLCALL
+ xmlBufferLength (const xmlBufferPtr buf);
+
+/*
+ * Creating/freeing new structures.
+ */
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlCreateIntSubset (xmlDocPtr doc,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlNewDtd (xmlDocPtr doc,
+ const xmlChar *name,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID);
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlGetIntSubset (xmlDocPtr doc);
+XMLPUBFUN void XMLCALL
+ xmlFreeDtd (xmlDtdPtr cur);
+#ifdef LIBXML_LEGACY_ENABLED
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlNewGlobalNs (xmlDocPtr doc,
+ const xmlChar *href,
+ const xmlChar *prefix);
+#endif /* LIBXML_LEGACY_ENABLED */
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlNewNs (xmlNodePtr node,
+ const xmlChar *href,
+ const xmlChar *prefix);
+XMLPUBFUN void XMLCALL
+ xmlFreeNs (xmlNsPtr cur);
+XMLPUBFUN void XMLCALL
+ xmlFreeNsList (xmlNsPtr cur);
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlNewDoc (const xmlChar *version);
+XMLPUBFUN void XMLCALL
+ xmlFreeDoc (xmlDocPtr cur);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlNewDocProp (xmlDocPtr doc,
+ const xmlChar *name,
+ const xmlChar *value);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlNewProp (xmlNodePtr node,
+ const xmlChar *name,
+ const xmlChar *value);
+#endif
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlNewNsProp (xmlNodePtr node,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *value);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlNewNsPropEatName (xmlNodePtr node,
+ xmlNsPtr ns,
+ xmlChar *name,
+ const xmlChar *value);
+XMLPUBFUN void XMLCALL
+ xmlFreePropList (xmlAttrPtr cur);
+XMLPUBFUN void XMLCALL
+ xmlFreeProp (xmlAttrPtr cur);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlCopyProp (xmlNodePtr target,
+ xmlAttrPtr cur);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlCopyPropList (xmlNodePtr target,
+ xmlAttrPtr cur);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlCopyDtd (xmlDtdPtr dtd);
+#endif /* LIBXML_TREE_ENABLED */
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlCopyDoc (xmlDocPtr doc,
+ int recursive);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
+/*
+ * Creating new nodes.
+ */
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocNode (xmlDocPtr doc,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocNodeEatName (xmlDocPtr doc,
+ xmlNsPtr ns,
+ xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewNode (xmlNsPtr ns,
+ const xmlChar *name);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewNodeEatName (xmlNsPtr ns,
+ xmlChar *name);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewChild (xmlNodePtr parent,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *content);
+#endif
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocText (xmlDocPtr doc,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewText (const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocPI (xmlDocPtr doc,
+ const xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewPI (const xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocTextLen (xmlDocPtr doc,
+ const xmlChar *content,
+ int len);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewTextLen (const xmlChar *content,
+ int len);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocComment (xmlDocPtr doc,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewComment (const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewCDataBlock (xmlDocPtr doc,
+ const xmlChar *content,
+ int len);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewCharRef (xmlDocPtr doc,
+ const xmlChar *name);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewReference (xmlDocPtr doc,
+ const xmlChar *name);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlCopyNode (const xmlNodePtr node,
+ int recursive);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocCopyNode (const xmlNodePtr node,
+ xmlDocPtr doc,
+ int recursive);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocCopyNodeList (xmlDocPtr doc,
+ const xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlCopyNodeList (const xmlNodePtr node);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewTextChild (xmlNodePtr parent,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocRawNode (xmlDocPtr doc,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *content);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocFragment (xmlDocPtr doc);
+#endif /* LIBXML_TREE_ENABLED */
+
+/*
+ * Navigating.
+ */
+XMLPUBFUN long XMLCALL
+ xmlGetLineNo (xmlNodePtr node);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNodePath (xmlNodePtr node);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocGetRootElement (xmlDocPtr doc);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlGetLastChild (xmlNodePtr parent);
+XMLPUBFUN int XMLCALL
+ xmlNodeIsText (xmlNodePtr node);
+XMLPUBFUN int XMLCALL
+ xmlIsBlankNode (xmlNodePtr node);
+
+/*
+ * Changing the structure.
+ */
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocSetRootElement (xmlDocPtr doc,
+ xmlNodePtr root);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlNodeSetName (xmlNodePtr cur,
+ const xmlChar *name);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlAddChild (xmlNodePtr parent,
+ xmlNodePtr cur);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlAddChildList (xmlNodePtr parent,
+ xmlNodePtr cur);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlReplaceNode (xmlNodePtr old,
+ xmlNodePtr cur);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlAddPrevSibling (xmlNodePtr cur,
+ xmlNodePtr elem);
+#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlAddSibling (xmlNodePtr cur,
+ xmlNodePtr elem);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlAddNextSibling (xmlNodePtr cur,
+ xmlNodePtr elem);
+XMLPUBFUN void XMLCALL
+ xmlUnlinkNode (xmlNodePtr cur);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlTextMerge (xmlNodePtr first,
+ xmlNodePtr second);
+XMLPUBFUN int XMLCALL
+ xmlTextConcat (xmlNodePtr node,
+ const xmlChar *content,
+ int len);
+XMLPUBFUN void XMLCALL
+ xmlFreeNodeList (xmlNodePtr cur);
+XMLPUBFUN void XMLCALL
+ xmlFreeNode (xmlNodePtr cur);
+XMLPUBFUN void XMLCALL
+ xmlSetTreeDoc (xmlNodePtr tree,
+ xmlDocPtr doc);
+XMLPUBFUN void XMLCALL
+ xmlSetListDoc (xmlNodePtr list,
+ xmlDocPtr doc);
+/*
+ * Namespaces.
+ */
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlSearchNs (xmlDocPtr doc,
+ xmlNodePtr node,
+ const xmlChar *nameSpace);
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlSearchNsByHref (xmlDocPtr doc,
+ xmlNodePtr node,
+ const xmlChar *href);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlNsPtr * XMLCALL
+ xmlGetNsList (xmlDocPtr doc,
+ xmlNodePtr node);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */
+
+XMLPUBFUN void XMLCALL
+ xmlSetNs (xmlNodePtr node,
+ xmlNsPtr ns);
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlCopyNamespace (xmlNsPtr cur);
+XMLPUBFUN xmlNsPtr XMLCALL
+ xmlCopyNamespaceList (xmlNsPtr cur);
+
+/*
+ * Changing the content.
+ */
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlSetProp (xmlNodePtr node,
+ const xmlChar *name,
+ const xmlChar *value);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlSetNsProp (xmlNodePtr node,
+ xmlNsPtr ns,
+ const xmlChar *name,
+ const xmlChar *value);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNoNsProp (xmlNodePtr node,
+ const xmlChar *name);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetProp (xmlNodePtr node,
+ const xmlChar *name);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlHasProp (xmlNodePtr node,
+ const xmlChar *name);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlHasNsProp (xmlNodePtr node,
+ const xmlChar *name,
+ const xmlChar *nameSpace);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNsProp (xmlNodePtr node,
+ const xmlChar *name,
+ const xmlChar *nameSpace);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlStringGetNodeList (xmlDocPtr doc,
+ const xmlChar *value);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlStringLenGetNodeList (xmlDocPtr doc,
+ const xmlChar *value,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeListGetString (xmlDocPtr doc,
+ xmlNodePtr list,
+ int inLine);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeListGetRawString (xmlDocPtr doc,
+ xmlNodePtr list,
+ int inLine);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlNodeSetContent (xmlNodePtr cur,
+ const xmlChar *content);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlNodeSetContentLen (xmlNodePtr cur,
+ const xmlChar *content,
+ int len);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlNodeAddContent (xmlNodePtr cur,
+ const xmlChar *content);
+XMLPUBFUN void XMLCALL
+ xmlNodeAddContentLen (xmlNodePtr cur,
+ const xmlChar *content,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetContent (xmlNodePtr cur);
+
+XMLPUBFUN int XMLCALL
+ xmlNodeBufGetContent (xmlBufferPtr buffer,
+ xmlNodePtr cur);
+XMLPUBFUN int XMLCALL
+ xmlBufGetNodeContent (xmlBufPtr buf,
+ xmlNodePtr cur);
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetLang (xmlNodePtr cur);
+XMLPUBFUN int XMLCALL
+ xmlNodeGetSpacePreserve (xmlNodePtr cur);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlNodeSetLang (xmlNodePtr cur,
+ const xmlChar *lang);
+XMLPUBFUN void XMLCALL
+ xmlNodeSetSpacePreserve (xmlNodePtr cur,
+ int val);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetBase (xmlDocPtr doc,
+ xmlNodePtr cur);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
+XMLPUBFUN void XMLCALL
+ xmlNodeSetBase (xmlNodePtr cur,
+ const xmlChar *uri);
+#endif
+
+/*
+ * Removing content.
+ */
+XMLPUBFUN int XMLCALL
+ xmlRemoveProp (xmlAttrPtr cur);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN int XMLCALL
+ xmlUnsetNsProp (xmlNodePtr node,
+ xmlNsPtr ns,
+ const xmlChar *name);
+XMLPUBFUN int XMLCALL
+ xmlUnsetProp (xmlNodePtr node,
+ const xmlChar *name);
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
+
+/*
+ * Internal, don't use.
+ */
+XMLPUBFUN void XMLCALL
+ xmlBufferWriteCHAR (xmlBufferPtr buf,
+ const xmlChar *string);
+XMLPUBFUN void XMLCALL
+ xmlBufferWriteChar (xmlBufferPtr buf,
+ const char *string);
+XMLPUBFUN void XMLCALL
+ xmlBufferWriteQuotedString(xmlBufferPtr buf,
+ const xmlChar *string);
+
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,
+ xmlDocPtr doc,
+ xmlAttrPtr attr,
+ const xmlChar *string);
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * Namespace handling.
+ */
+XMLPUBFUN int XMLCALL
+ xmlReconciliateNs (xmlDocPtr doc,
+ xmlNodePtr tree);
+#endif
+
+#ifdef LIBXML_OUTPUT_ENABLED
+/*
+ * Saving.
+ */
+XMLPUBFUN void XMLCALL
+ xmlDocDumpFormatMemory (xmlDocPtr cur,
+ xmlChar **mem,
+ int *size,
+ int format);
+XMLPUBFUN void XMLCALL
+ xmlDocDumpMemory (xmlDocPtr cur,
+ xmlChar **mem,
+ int *size);
+XMLPUBFUN void XMLCALL
+ xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
+ xmlChar **doc_txt_ptr,
+ int * doc_txt_len,
+ const char *txt_encoding);
+XMLPUBFUN void XMLCALL
+ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
+ xmlChar **doc_txt_ptr,
+ int * doc_txt_len,
+ const char *txt_encoding,
+ int format);
+XMLPUBFUN int XMLCALL
+ xmlDocFormatDump (FILE *f,
+ xmlDocPtr cur,
+ int format);
+XMLPUBFUN int XMLCALL
+ xmlDocDump (FILE *f,
+ xmlDocPtr cur);
+XMLPUBFUN void XMLCALL
+ xmlElemDump (FILE *f,
+ xmlDocPtr doc,
+ xmlNodePtr cur);
+XMLPUBFUN int XMLCALL
+ xmlSaveFile (const char *filename,
+ xmlDocPtr cur);
+XMLPUBFUN int XMLCALL
+ xmlSaveFormatFile (const char *filename,
+ xmlDocPtr cur,
+ int format);
+XMLPUBFUN size_t XMLCALL
+ xmlBufNodeDump (xmlBufPtr buf,
+ xmlDocPtr doc,
+ xmlNodePtr cur,
+ int level,
+ int format);
+XMLPUBFUN int XMLCALL
+ xmlNodeDump (xmlBufferPtr buf,
+ xmlDocPtr doc,
+ xmlNodePtr cur,
+ int level,
+ int format);
+
+XMLPUBFUN int XMLCALL
+ xmlSaveFileTo (xmlOutputBufferPtr buf,
+ xmlDocPtr cur,
+ const char *encoding);
+XMLPUBFUN int XMLCALL
+ xmlSaveFormatFileTo (xmlOutputBufferPtr buf,
+ xmlDocPtr cur,
+ const char *encoding,
+ int format);
+XMLPUBFUN void XMLCALL
+ xmlNodeDumpOutput (xmlOutputBufferPtr buf,
+ xmlDocPtr doc,
+ xmlNodePtr cur,
+ int level,
+ int format,
+ const char *encoding);
+
+XMLPUBFUN int XMLCALL
+ xmlSaveFormatFileEnc (const char *filename,
+ xmlDocPtr cur,
+ const char *encoding,
+ int format);
+
+XMLPUBFUN int XMLCALL
+ xmlSaveFileEnc (const char *filename,
+ xmlDocPtr cur,
+ const char *encoding);
+
+#endif /* LIBXML_OUTPUT_ENABLED */
+/*
+ * XHTML
+ */
+XMLPUBFUN int XMLCALL
+ xmlIsXHTML (const xmlChar *systemID,
+ const xmlChar *publicID);
+
+/*
+ * Compression.
+ */
+XMLPUBFUN int XMLCALL
+ xmlGetDocCompressMode (xmlDocPtr doc);
+XMLPUBFUN void XMLCALL
+ xmlSetDocCompressMode (xmlDocPtr doc,
+ int mode);
+XMLPUBFUN int XMLCALL
+ xmlGetCompressMode (void);
+XMLPUBFUN void XMLCALL
+ xmlSetCompressMode (int mode);
+
+/*
+* DOM-wrapper helper functions.
+*/
+XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL
+ xmlDOMWrapNewCtxt (void);
+XMLPUBFUN void XMLCALL
+ xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt,
+ xmlNodePtr elem,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt,
+ xmlDocPtr sourceDoc,
+ xmlNodePtr node,
+ xmlDocPtr destDoc,
+ xmlNodePtr destParent,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr node,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt,
+ xmlDocPtr sourceDoc,
+ xmlNodePtr node,
+ xmlNodePtr *clonedNode,
+ xmlDocPtr destDoc,
+ xmlNodePtr destParent,
+ int deep,
+ int options);
+
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * 5 interfaces from DOM ElementTraversal, but different in entities
+ * traversal.
+ */
+XMLPUBFUN unsigned long XMLCALL
+ xmlChildElementCount (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNextElementSibling (xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlFirstElementChild (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlLastElementChild (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlPreviousElementSibling (xmlNodePtr node);
+#endif
+#ifdef __cplusplus
+}
+#endif
+#ifndef __XML_PARSER_H__
+#include
+#endif
+
+#endif /* __XML_TREE_H__ */
+
diff --git a/fmu10/src/shared/libxml/valid.h b/fmu10/src/shared/libxml/valid.h
new file mode 100644
index 0000000..2bc7b38
--- /dev/null
+++ b/fmu10/src/shared/libxml/valid.h
@@ -0,0 +1,458 @@
+/*
+ * Summary: The DTD validation
+ * Description: API for the DTD handling and the validity checking
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+
+#ifndef __XML_VALID_H__
+#define __XML_VALID_H__
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Validation state added for non-determinist content model.
+ */
+typedef struct _xmlValidState xmlValidState;
+typedef xmlValidState *xmlValidStatePtr;
+
+/**
+ * xmlValidityErrorFunc:
+ * @ctx: usually an xmlValidCtxtPtr to a validity error context,
+ * but comes from ctxt->userData (which normally contains such
+ * a pointer); ctxt->userData can be changed by the user.
+ * @msg: the string to format *printf like vararg
+ * @...: remaining arguments to the format
+ *
+ * Callback called when a validity error is found. This is a message
+ * oriented function similar to an *printf function.
+ */
+typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * xmlValidityWarningFunc:
+ * @ctx: usually an xmlValidCtxtPtr to a validity error context,
+ * but comes from ctxt->userData (which normally contains such
+ * a pointer); ctxt->userData can be changed by the user.
+ * @msg: the string to format *printf like vararg
+ * @...: remaining arguments to the format
+ *
+ * Callback called when a validity warning is found. This is a message
+ * oriented function similar to an *printf function.
+ */
+typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+
+#ifdef IN_LIBXML
+/**
+ * XML_CTXT_FINISH_DTD_0:
+ *
+ * Special value for finishDtd field when embedded in an xmlParserCtxt
+ */
+#define XML_CTXT_FINISH_DTD_0 0xabcd1234
+/**
+ * XML_CTXT_FINISH_DTD_1:
+ *
+ * Special value for finishDtd field when embedded in an xmlParserCtxt
+ */
+#define XML_CTXT_FINISH_DTD_1 0xabcd1235
+#endif
+
+/*
+ * xmlValidCtxt:
+ * An xmlValidCtxt is used for error reporting when validating.
+ */
+typedef struct _xmlValidCtxt xmlValidCtxt;
+typedef xmlValidCtxt *xmlValidCtxtPtr;
+struct _xmlValidCtxt {
+ void *userData; /* user specific data block */
+ xmlValidityErrorFunc error; /* the callback in case of errors */
+ xmlValidityWarningFunc warning; /* the callback in case of warning */
+
+ /* Node analysis stack used when validating within entities */
+ xmlNodePtr node; /* Current parsed Node */
+ int nodeNr; /* Depth of the parsing stack */
+ int nodeMax; /* Max depth of the parsing stack */
+ xmlNodePtr *nodeTab; /* array of nodes */
+
+ unsigned int finishDtd; /* finished validating the Dtd ? */
+ xmlDocPtr doc; /* the document */
+ int valid; /* temporary validity check result */
+
+ /* state state used for non-determinist content validation */
+ xmlValidState *vstate; /* current state */
+ int vstateNr; /* Depth of the validation stack */
+ int vstateMax; /* Max depth of the validation stack */
+ xmlValidState *vstateTab; /* array of validation states */
+
+#ifdef LIBXML_REGEXP_ENABLED
+ xmlAutomataPtr am; /* the automata */
+ xmlAutomataStatePtr state; /* used to build the automata */
+#else
+ void *am;
+ void *state;
+#endif
+};
+
+/*
+ * ALL notation declarations are stored in a table.
+ * There is one table per DTD.
+ */
+
+typedef struct _xmlHashTable xmlNotationTable;
+typedef xmlNotationTable *xmlNotationTablePtr;
+
+/*
+ * ALL element declarations are stored in a table.
+ * There is one table per DTD.
+ */
+
+typedef struct _xmlHashTable xmlElementTable;
+typedef xmlElementTable *xmlElementTablePtr;
+
+/*
+ * ALL attribute declarations are stored in a table.
+ * There is one table per DTD.
+ */
+
+typedef struct _xmlHashTable xmlAttributeTable;
+typedef xmlAttributeTable *xmlAttributeTablePtr;
+
+/*
+ * ALL IDs attributes are stored in a table.
+ * There is one table per document.
+ */
+
+typedef struct _xmlHashTable xmlIDTable;
+typedef xmlIDTable *xmlIDTablePtr;
+
+/*
+ * ALL Refs attributes are stored in a table.
+ * There is one table per document.
+ */
+
+typedef struct _xmlHashTable xmlRefTable;
+typedef xmlRefTable *xmlRefTablePtr;
+
+/* Notation */
+XMLPUBFUN xmlNotationPtr XMLCALL
+ xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
+ xmlDtdPtr dtd,
+ const xmlChar *name,
+ const xmlChar *PublicID,
+ const xmlChar *SystemID);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlNotationTablePtr XMLCALL
+ xmlCopyNotationTable (xmlNotationTablePtr table);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlFreeNotationTable (xmlNotationTablePtr table);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlDumpNotationDecl (xmlBufferPtr buf,
+ xmlNotationPtr nota);
+XMLPUBFUN void XMLCALL
+ xmlDumpNotationTable (xmlBufferPtr buf,
+ xmlNotationTablePtr table);
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+/* Element Content */
+/* the non Doc version are being deprecated */
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlNewElementContent (const xmlChar *name,
+ xmlElementContentType type);
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlCopyElementContent (xmlElementContentPtr content);
+XMLPUBFUN void XMLCALL
+ xmlFreeElementContent (xmlElementContentPtr cur);
+/* the new versions with doc argument */
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlNewDocElementContent (xmlDocPtr doc,
+ const xmlChar *name,
+ xmlElementContentType type);
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlCopyDocElementContent(xmlDocPtr doc,
+ xmlElementContentPtr content);
+XMLPUBFUN void XMLCALL
+ xmlFreeDocElementContent(xmlDocPtr doc,
+ xmlElementContentPtr cur);
+XMLPUBFUN void XMLCALL
+ xmlSnprintfElementContent(char *buf,
+ int size,
+ xmlElementContentPtr content,
+ int englob);
+#ifdef LIBXML_OUTPUT_ENABLED
+/* DEPRECATED */
+XMLPUBFUN void XMLCALL
+ xmlSprintfElementContent(char *buf,
+ xmlElementContentPtr content,
+ int englob);
+#endif /* LIBXML_OUTPUT_ENABLED */
+/* DEPRECATED */
+
+/* Element */
+XMLPUBFUN xmlElementPtr XMLCALL
+ xmlAddElementDecl (xmlValidCtxtPtr ctxt,
+ xmlDtdPtr dtd,
+ const xmlChar *name,
+ xmlElementTypeVal type,
+ xmlElementContentPtr content);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlElementTablePtr XMLCALL
+ xmlCopyElementTable (xmlElementTablePtr table);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlFreeElementTable (xmlElementTablePtr table);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlDumpElementTable (xmlBufferPtr buf,
+ xmlElementTablePtr table);
+XMLPUBFUN void XMLCALL
+ xmlDumpElementDecl (xmlBufferPtr buf,
+ xmlElementPtr elem);
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+/* Enumeration */
+XMLPUBFUN xmlEnumerationPtr XMLCALL
+ xmlCreateEnumeration (const xmlChar *name);
+XMLPUBFUN void XMLCALL
+ xmlFreeEnumeration (xmlEnumerationPtr cur);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlEnumerationPtr XMLCALL
+ xmlCopyEnumeration (xmlEnumerationPtr cur);
+#endif /* LIBXML_TREE_ENABLED */
+
+/* Attribute */
+XMLPUBFUN xmlAttributePtr XMLCALL
+ xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
+ xmlDtdPtr dtd,
+ const xmlChar *elem,
+ const xmlChar *name,
+ const xmlChar *ns,
+ xmlAttributeType type,
+ xmlAttributeDefault def,
+ const xmlChar *defaultValue,
+ xmlEnumerationPtr tree);
+#ifdef LIBXML_TREE_ENABLED
+XMLPUBFUN xmlAttributeTablePtr XMLCALL
+ xmlCopyAttributeTable (xmlAttributeTablePtr table);
+#endif /* LIBXML_TREE_ENABLED */
+XMLPUBFUN void XMLCALL
+ xmlFreeAttributeTable (xmlAttributeTablePtr table);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlDumpAttributeTable (xmlBufferPtr buf,
+ xmlAttributeTablePtr table);
+XMLPUBFUN void XMLCALL
+ xmlDumpAttributeDecl (xmlBufferPtr buf,
+ xmlAttributePtr attr);
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+/* IDs */
+XMLPUBFUN xmlIDPtr XMLCALL
+ xmlAddID (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ const xmlChar *value,
+ xmlAttrPtr attr);
+XMLPUBFUN void XMLCALL
+ xmlFreeIDTable (xmlIDTablePtr table);
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlGetID (xmlDocPtr doc,
+ const xmlChar *ID);
+XMLPUBFUN int XMLCALL
+ xmlIsID (xmlDocPtr doc,
+ xmlNodePtr elem,
+ xmlAttrPtr attr);
+XMLPUBFUN int XMLCALL
+ xmlRemoveID (xmlDocPtr doc,
+ xmlAttrPtr attr);
+
+/* IDREFs */
+XMLPUBFUN xmlRefPtr XMLCALL
+ xmlAddRef (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ const xmlChar *value,
+ xmlAttrPtr attr);
+XMLPUBFUN void XMLCALL
+ xmlFreeRefTable (xmlRefTablePtr table);
+XMLPUBFUN int XMLCALL
+ xmlIsRef (xmlDocPtr doc,
+ xmlNodePtr elem,
+ xmlAttrPtr attr);
+XMLPUBFUN int XMLCALL
+ xmlRemoveRef (xmlDocPtr doc,
+ xmlAttrPtr attr);
+XMLPUBFUN xmlListPtr XMLCALL
+ xmlGetRefs (xmlDocPtr doc,
+ const xmlChar *ID);
+
+/**
+ * The public function calls related to validity checking.
+ */
+#ifdef LIBXML_VALID_ENABLED
+/* Allocate/Release Validation Contexts */
+XMLPUBFUN xmlValidCtxtPtr XMLCALL
+ xmlNewValidCtxt(void);
+XMLPUBFUN void XMLCALL
+ xmlFreeValidCtxt(xmlValidCtxtPtr);
+
+XMLPUBFUN int XMLCALL
+ xmlValidateRoot (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc);
+XMLPUBFUN int XMLCALL
+ xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlElementPtr elem);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlValidNormalizeAttributeValue(xmlDocPtr doc,
+ xmlNodePtr elem,
+ const xmlChar *name,
+ const xmlChar *value);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem,
+ const xmlChar *name,
+ const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlAttributePtr attr);
+XMLPUBFUN int XMLCALL
+ xmlValidateAttributeValue(xmlAttributeType type,
+ const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNotationPtr nota);
+XMLPUBFUN int XMLCALL
+ xmlValidateDtd (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlDtdPtr dtd);
+XMLPUBFUN int XMLCALL
+ xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc);
+XMLPUBFUN int XMLCALL
+ xmlValidateDocument (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc);
+XMLPUBFUN int XMLCALL
+ xmlValidateElement (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem);
+XMLPUBFUN int XMLCALL
+ xmlValidateOneElement (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem);
+XMLPUBFUN int XMLCALL
+ xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem,
+ xmlAttrPtr attr,
+ const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem,
+ const xmlChar *prefix,
+ xmlNsPtr ns,
+ const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc);
+#endif /* LIBXML_VALID_ENABLED */
+
+#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN int XMLCALL
+ xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ const xmlChar *notationName);
+#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
+
+XMLPUBFUN int XMLCALL
+ xmlIsMixedElement (xmlDocPtr doc,
+ const xmlChar *name);
+XMLPUBFUN xmlAttributePtr XMLCALL
+ xmlGetDtdAttrDesc (xmlDtdPtr dtd,
+ const xmlChar *elem,
+ const xmlChar *name);
+XMLPUBFUN xmlAttributePtr XMLCALL
+ xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
+ const xmlChar *elem,
+ const xmlChar *name,
+ const xmlChar *prefix);
+XMLPUBFUN xmlNotationPtr XMLCALL
+ xmlGetDtdNotationDesc (xmlDtdPtr dtd,
+ const xmlChar *name);
+XMLPUBFUN xmlElementPtr XMLCALL
+ xmlGetDtdQElementDesc (xmlDtdPtr dtd,
+ const xmlChar *name,
+ const xmlChar *prefix);
+XMLPUBFUN xmlElementPtr XMLCALL
+ xmlGetDtdElementDesc (xmlDtdPtr dtd,
+ const xmlChar *name);
+
+#ifdef LIBXML_VALID_ENABLED
+
+XMLPUBFUN int XMLCALL
+ xmlValidGetPotentialChildren(xmlElementContent *ctree,
+ const xmlChar **names,
+ int *len,
+ int max);
+
+XMLPUBFUN int XMLCALL
+ xmlValidGetValidElements(xmlNode *prev,
+ xmlNode *next,
+ const xmlChar **names,
+ int max);
+XMLPUBFUN int XMLCALL
+ xmlValidateNameValue (const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateNamesValue (const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateNmtokenValue (const xmlChar *value);
+XMLPUBFUN int XMLCALL
+ xmlValidateNmtokensValue(const xmlChar *value);
+
+#ifdef LIBXML_REGEXP_ENABLED
+/*
+ * Validation based on the regexp support
+ */
+XMLPUBFUN int XMLCALL
+ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
+ xmlElementPtr elem);
+
+XMLPUBFUN int XMLCALL
+ xmlValidatePushElement (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem,
+ const xmlChar *qname);
+XMLPUBFUN int XMLCALL
+ xmlValidatePushCData (xmlValidCtxtPtr ctxt,
+ const xmlChar *data,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlValidatePopElement (xmlValidCtxtPtr ctxt,
+ xmlDocPtr doc,
+ xmlNodePtr elem,
+ const xmlChar *qname);
+#endif /* LIBXML_REGEXP_ENABLED */
+#endif /* LIBXML_VALID_ENABLED */
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_VALID_H__ */
diff --git a/fmu10/src/shared/libxml/xlink.h b/fmu10/src/shared/libxml/xlink.h
new file mode 100644
index 0000000..a209a99
--- /dev/null
+++ b/fmu10/src/shared/libxml/xlink.h
@@ -0,0 +1,189 @@
+/*
+ * Summary: unfinished XLink detection module
+ * Description: unfinished XLink detection module
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XLINK_H__
+#define __XML_XLINK_H__
+
+#include
+#include
+
+#ifdef LIBXML_XPTR_ENABLED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Various defines for the various Link properties.
+ *
+ * NOTE: the link detection layer will try to resolve QName expansion
+ * of namespaces. If "foo" is the prefix for "http://foo.com/"
+ * then the link detection layer will expand role="foo:myrole"
+ * to "http://foo.com/:myrole".
+ * NOTE: the link detection layer will expand URI-Refences found on
+ * href attributes by using the base mechanism if found.
+ */
+typedef xmlChar *xlinkHRef;
+typedef xmlChar *xlinkRole;
+typedef xmlChar *xlinkTitle;
+
+typedef enum {
+ XLINK_TYPE_NONE = 0,
+ XLINK_TYPE_SIMPLE,
+ XLINK_TYPE_EXTENDED,
+ XLINK_TYPE_EXTENDED_SET
+} xlinkType;
+
+typedef enum {
+ XLINK_SHOW_NONE = 0,
+ XLINK_SHOW_NEW,
+ XLINK_SHOW_EMBED,
+ XLINK_SHOW_REPLACE
+} xlinkShow;
+
+typedef enum {
+ XLINK_ACTUATE_NONE = 0,
+ XLINK_ACTUATE_AUTO,
+ XLINK_ACTUATE_ONREQUEST
+} xlinkActuate;
+
+/**
+ * xlinkNodeDetectFunc:
+ * @ctx: user data pointer
+ * @node: the node to check
+ *
+ * This is the prototype for the link detection routine.
+ * It calls the default link detection callbacks upon link detection.
+ */
+typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
+
+/*
+ * The link detection module interact with the upper layers using
+ * a set of callback registered at parsing time.
+ */
+
+/**
+ * xlinkSimpleLinkFunk:
+ * @ctx: user data pointer
+ * @node: the node carrying the link
+ * @href: the target of the link
+ * @role: the role string
+ * @title: the link title
+ *
+ * This is the prototype for a simple link detection callback.
+ */
+typedef void
+(*xlinkSimpleLinkFunk) (void *ctx,
+ xmlNodePtr node,
+ const xlinkHRef href,
+ const xlinkRole role,
+ const xlinkTitle title);
+
+/**
+ * xlinkExtendedLinkFunk:
+ * @ctx: user data pointer
+ * @node: the node carrying the link
+ * @nbLocators: the number of locators detected on the link
+ * @hrefs: pointer to the array of locator hrefs
+ * @roles: pointer to the array of locator roles
+ * @nbArcs: the number of arcs detected on the link
+ * @from: pointer to the array of source roles found on the arcs
+ * @to: pointer to the array of target roles found on the arcs
+ * @show: array of values for the show attributes found on the arcs
+ * @actuate: array of values for the actuate attributes found on the arcs
+ * @nbTitles: the number of titles detected on the link
+ * @title: array of titles detected on the link
+ * @langs: array of xml:lang values for the titles
+ *
+ * This is the prototype for a extended link detection callback.
+ */
+typedef void
+(*xlinkExtendedLinkFunk)(void *ctx,
+ xmlNodePtr node,
+ int nbLocators,
+ const xlinkHRef *hrefs,
+ const xlinkRole *roles,
+ int nbArcs,
+ const xlinkRole *from,
+ const xlinkRole *to,
+ xlinkShow *show,
+ xlinkActuate *actuate,
+ int nbTitles,
+ const xlinkTitle *titles,
+ const xmlChar **langs);
+
+/**
+ * xlinkExtendedLinkSetFunk:
+ * @ctx: user data pointer
+ * @node: the node carrying the link
+ * @nbLocators: the number of locators detected on the link
+ * @hrefs: pointer to the array of locator hrefs
+ * @roles: pointer to the array of locator roles
+ * @nbTitles: the number of titles detected on the link
+ * @title: array of titles detected on the link
+ * @langs: array of xml:lang values for the titles
+ *
+ * This is the prototype for a extended link set detection callback.
+ */
+typedef void
+(*xlinkExtendedLinkSetFunk) (void *ctx,
+ xmlNodePtr node,
+ int nbLocators,
+ const xlinkHRef *hrefs,
+ const xlinkRole *roles,
+ int nbTitles,
+ const xlinkTitle *titles,
+ const xmlChar **langs);
+
+/**
+ * This is the structure containing a set of Links detection callbacks.
+ *
+ * There is no default xlink callbacks, if one want to get link
+ * recognition activated, those call backs must be provided before parsing.
+ */
+typedef struct _xlinkHandler xlinkHandler;
+typedef xlinkHandler *xlinkHandlerPtr;
+struct _xlinkHandler {
+ xlinkSimpleLinkFunk simple;
+ xlinkExtendedLinkFunk extended;
+ xlinkExtendedLinkSetFunk set;
+};
+
+/*
+ * The default detection routine, can be overridden, they call the default
+ * detection callbacks.
+ */
+
+XMLPUBFUN xlinkNodeDetectFunc XMLCALL
+ xlinkGetDefaultDetect (void);
+XMLPUBFUN void XMLCALL
+ xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
+
+/*
+ * Routines to set/get the default handlers.
+ */
+XMLPUBFUN xlinkHandlerPtr XMLCALL
+ xlinkGetDefaultHandler (void);
+XMLPUBFUN void XMLCALL
+ xlinkSetDefaultHandler (xlinkHandlerPtr handler);
+
+/*
+ * Link detection module itself.
+ */
+XMLPUBFUN xlinkType XMLCALL
+ xlinkIsLink (xmlDocPtr doc,
+ xmlNodePtr node);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_XPTR_ENABLED */
+
+#endif /* __XML_XLINK_H__ */
diff --git a/fmu10/src/shared/libxml/xmlIO.h b/fmu10/src/shared/libxml/xmlIO.h
new file mode 100644
index 0000000..6c241a8
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlIO.h
@@ -0,0 +1,366 @@
+/*
+ * Summary: interface for the I/O interfaces used by the parser
+ * Description: interface for the I/O interfaces used by the parser
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_IO_H__
+#define __XML_IO_H__
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Those are the functions and datatypes for the parser input
+ * I/O structures.
+ */
+
+/**
+ * xmlInputMatchCallback:
+ * @filename: the filename or URI
+ *
+ * Callback used in the I/O Input API to detect if the current handler
+ * can provide input fonctionnalities for this resource.
+ *
+ * Returns 1 if yes and 0 if another Input module should be used
+ */
+typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
+/**
+ * xmlInputOpenCallback:
+ * @filename: the filename or URI
+ *
+ * Callback used in the I/O Input API to open the resource
+ *
+ * Returns an Input context or NULL in case or error
+ */
+typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
+/**
+ * xmlInputReadCallback:
+ * @context: an Input context
+ * @buffer: the buffer to store data read
+ * @len: the length of the buffer in bytes
+ *
+ * Callback used in the I/O Input API to read the resource
+ *
+ * Returns the number of bytes read or -1 in case of error
+ */
+typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);
+/**
+ * xmlInputCloseCallback:
+ * @context: an Input context
+ *
+ * Callback used in the I/O Input API to close the resource
+ *
+ * Returns 0 or -1 in case of error
+ */
+typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
+
+#ifdef LIBXML_OUTPUT_ENABLED
+/*
+ * Those are the functions and datatypes for the library output
+ * I/O structures.
+ */
+
+/**
+ * xmlOutputMatchCallback:
+ * @filename: the filename or URI
+ *
+ * Callback used in the I/O Output API to detect if the current handler
+ * can provide output fonctionnalities for this resource.
+ *
+ * Returns 1 if yes and 0 if another Output module should be used
+ */
+typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
+/**
+ * xmlOutputOpenCallback:
+ * @filename: the filename or URI
+ *
+ * Callback used in the I/O Output API to open the resource
+ *
+ * Returns an Output context or NULL in case or error
+ */
+typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
+/**
+ * xmlOutputWriteCallback:
+ * @context: an Output context
+ * @buffer: the buffer of data to write
+ * @len: the length of the buffer in bytes
+ *
+ * Callback used in the I/O Output API to write to the resource
+ *
+ * Returns the number of bytes written or -1 in case of error
+ */
+typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,
+ int len);
+/**
+ * xmlOutputCloseCallback:
+ * @context: an Output context
+ *
+ * Callback used in the I/O Output API to close the resource
+ *
+ * Returns 0 or -1 in case of error
+ */
+typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct _xmlParserInputBuffer {
+ void* context;
+ xmlInputReadCallback readcallback;
+ xmlInputCloseCallback closecallback;
+
+ xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
+
+ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */
+ xmlBufPtr raw; /* if encoder != NULL buffer for raw input */
+ int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
+ int error;
+ unsigned long rawconsumed;/* amount consumed from raw */
+};
+
+
+#ifdef LIBXML_OUTPUT_ENABLED
+struct _xmlOutputBuffer {
+ void* context;
+ xmlOutputWriteCallback writecallback;
+ xmlOutputCloseCallback closecallback;
+
+ xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
+
+ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
+ xmlBufPtr conv; /* if encoder != NULL buffer for output */
+ int written; /* total number of byte written */
+ int error;
+};
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+/*
+ * Interfaces for input
+ */
+XMLPUBFUN void XMLCALL
+ xmlCleanupInputCallbacks (void);
+
+XMLPUBFUN int XMLCALL
+ xmlPopInputCallbacks (void);
+
+XMLPUBFUN void XMLCALL
+ xmlRegisterDefaultInputCallbacks (void);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlAllocParserInputBuffer (xmlCharEncoding enc);
+
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateFilename (const char *URI,
+ xmlCharEncoding enc);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateFile (FILE *file,
+ xmlCharEncoding enc);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateFd (int fd,
+ xmlCharEncoding enc);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateMem (const char *mem, int size,
+ xmlCharEncoding enc);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateStatic (const char *mem, int size,
+ xmlCharEncoding enc);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ xmlCharEncoding enc);
+XMLPUBFUN int XMLCALL
+ xmlParserInputBufferRead (xmlParserInputBufferPtr in,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlParserInputBufferPush (xmlParserInputBufferPtr in,
+ int len,
+ const char *buf);
+XMLPUBFUN void XMLCALL
+ xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
+XMLPUBFUN char * XMLCALL
+ xmlParserGetDirectory (const char *filename);
+
+XMLPUBFUN int XMLCALL
+ xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
+ xmlInputOpenCallback openFunc,
+ xmlInputReadCallback readFunc,
+ xmlInputCloseCallback closeFunc);
+
+xmlParserInputBufferPtr
+ __xmlParserInputBufferCreateFilename(const char *URI,
+ xmlCharEncoding enc);
+
+#ifdef LIBXML_OUTPUT_ENABLED
+/*
+ * Interfaces for output
+ */
+XMLPUBFUN void XMLCALL
+ xmlCleanupOutputCallbacks (void);
+XMLPUBFUN void XMLCALL
+ xmlRegisterDefaultOutputCallbacks(void);
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
+
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlOutputBufferCreateFilename (const char *URI,
+ xmlCharEncodingHandlerPtr encoder,
+ int compression);
+
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlOutputBufferCreateFile (FILE *file,
+ xmlCharEncodingHandlerPtr encoder);
+
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
+ xmlCharEncodingHandlerPtr encoder);
+
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlOutputBufferCreateFd (int fd,
+ xmlCharEncodingHandlerPtr encoder);
+
+XMLPUBFUN xmlOutputBufferPtr XMLCALL
+ xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
+ xmlOutputCloseCallback ioclose,
+ void *ioctx,
+ xmlCharEncodingHandlerPtr encoder);
+
+/* Couple of APIs to get the output without digging into the buffers */
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlOutputBufferGetContent (xmlOutputBufferPtr out);
+XMLPUBFUN size_t XMLCALL
+ xmlOutputBufferGetSize (xmlOutputBufferPtr out);
+
+XMLPUBFUN int XMLCALL
+ xmlOutputBufferWrite (xmlOutputBufferPtr out,
+ int len,
+ const char *buf);
+XMLPUBFUN int XMLCALL
+ xmlOutputBufferWriteString (xmlOutputBufferPtr out,
+ const char *str);
+XMLPUBFUN int XMLCALL
+ xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
+ const xmlChar *str,
+ xmlCharEncodingOutputFunc escaping);
+
+XMLPUBFUN int XMLCALL
+ xmlOutputBufferFlush (xmlOutputBufferPtr out);
+XMLPUBFUN int XMLCALL
+ xmlOutputBufferClose (xmlOutputBufferPtr out);
+
+XMLPUBFUN int XMLCALL
+ xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
+ xmlOutputOpenCallback openFunc,
+ xmlOutputWriteCallback writeFunc,
+ xmlOutputCloseCallback closeFunc);
+
+xmlOutputBufferPtr
+ __xmlOutputBufferCreateFilename(const char *URI,
+ xmlCharEncodingHandlerPtr encoder,
+ int compression);
+
+#ifdef LIBXML_HTTP_ENABLED
+/* This function only exists if HTTP support built into the library */
+XMLPUBFUN void XMLCALL
+ xmlRegisterHTTPPostCallbacks (void );
+#endif /* LIBXML_HTTP_ENABLED */
+
+#endif /* LIBXML_OUTPUT_ENABLED */
+
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
+ xmlParserInputPtr ret);
+
+/*
+ * A predefined entity loader disabling network accesses
+ */
+XMLPUBFUN xmlParserInputPtr XMLCALL
+ xmlNoNetExternalEntityLoader (const char *URL,
+ const char *ID,
+ xmlParserCtxtPtr ctxt);
+
+/*
+ * xmlNormalizeWindowsPath is obsolete, don't use it.
+ * Check xmlCanonicPath in uri.h for a better alternative.
+ */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNormalizeWindowsPath (const xmlChar *path);
+
+XMLPUBFUN int XMLCALL
+ xmlCheckFilename (const char *path);
+/**
+ * Default 'file://' protocol callbacks
+ */
+XMLPUBFUN int XMLCALL
+ xmlFileMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlFileOpen (const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlFileRead (void * context,
+ char * buffer,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlFileClose (void * context);
+
+/**
+ * Default 'http://' protocol callbacks
+ */
+#ifdef LIBXML_HTTP_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlIOHTTPOpen (const char *filename);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void * XMLCALL
+ xmlIOHTTPOpenW (const char * post_uri,
+ int compression );
+#endif /* LIBXML_OUTPUT_ENABLED */
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPRead (void * context,
+ char * buffer,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPClose (void * context);
+#endif /* LIBXML_HTTP_ENABLED */
+
+/**
+ * Default 'ftp://' protocol callbacks
+ */
+#ifdef LIBXML_FTP_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlIOFTPMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlIOFTPOpen (const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlIOFTPRead (void * context,
+ char * buffer,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlIOFTPClose (void * context);
+#endif /* LIBXML_FTP_ENABLED */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_IO_H__ */
diff --git a/fmu10/src/shared/libxml/xmlautomata.h b/fmu10/src/shared/libxml/xmlautomata.h
new file mode 100644
index 0000000..bf1b131
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlautomata.h
@@ -0,0 +1,146 @@
+/*
+ * Summary: API to build regexp automata
+ * Description: the API to build regexp automata
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_AUTOMATA_H__
+#define __XML_AUTOMATA_H__
+
+#include
+#include
+
+#ifdef LIBXML_REGEXP_ENABLED
+#ifdef LIBXML_AUTOMATA_ENABLED
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlAutomataPtr:
+ *
+ * A libxml automata description, It can be compiled into a regexp
+ */
+typedef struct _xmlAutomata xmlAutomata;
+typedef xmlAutomata *xmlAutomataPtr;
+
+/**
+ * xmlAutomataStatePtr:
+ *
+ * A state int the automata description,
+ */
+typedef struct _xmlAutomataState xmlAutomataState;
+typedef xmlAutomataState *xmlAutomataStatePtr;
+
+/*
+ * Building API
+ */
+XMLPUBFUN xmlAutomataPtr XMLCALL
+ xmlNewAutomata (void);
+XMLPUBFUN void XMLCALL
+ xmlFreeAutomata (xmlAutomataPtr am);
+
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataGetInitState (xmlAutomataPtr am);
+XMLPUBFUN int XMLCALL
+ xmlAutomataSetFinalState (xmlAutomataPtr am,
+ xmlAutomataStatePtr state);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewState (xmlAutomataPtr am);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewTransition (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewTransition2 (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ const xmlChar *token2,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewNegTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ const xmlChar *token2,
+ void *data);
+
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewCountTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ int min,
+ int max,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewCountTrans2 (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ const xmlChar *token2,
+ int min,
+ int max,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewOnceTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ int min,
+ int max,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ const xmlChar *token,
+ const xmlChar *token2,
+ int min,
+ int max,
+ void *data);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewAllTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ int lax);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewEpsilon (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewCountedTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ int counter);
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
+ xmlAutomataNewCounterTrans (xmlAutomataPtr am,
+ xmlAutomataStatePtr from,
+ xmlAutomataStatePtr to,
+ int counter);
+XMLPUBFUN int XMLCALL
+ xmlAutomataNewCounter (xmlAutomataPtr am,
+ int min,
+ int max);
+
+XMLPUBFUN xmlRegexpPtr XMLCALL
+ xmlAutomataCompile (xmlAutomataPtr am);
+XMLPUBFUN int XMLCALL
+ xmlAutomataIsDeterminist (xmlAutomataPtr am);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_AUTOMATA_ENABLED */
+#endif /* LIBXML_REGEXP_ENABLED */
+
+#endif /* __XML_AUTOMATA_H__ */
diff --git a/fmu10/src/shared/libxml/xmlerror.h b/fmu10/src/shared/libxml/xmlerror.h
new file mode 100644
index 0000000..48ea145
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlerror.h
@@ -0,0 +1,944 @@
+/*
+ * Summary: error handling
+ * Description: the API used to report errors
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#include
+
+#ifndef __XML_ERROR_H__
+#define __XML_ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlErrorLevel:
+ *
+ * Indicates the level of an error
+ */
+typedef enum {
+ XML_ERR_NONE = 0,
+ XML_ERR_WARNING = 1, /* A simple warning */
+ XML_ERR_ERROR = 2, /* A recoverable error */
+ XML_ERR_FATAL = 3 /* A fatal error */
+} xmlErrorLevel;
+
+/**
+ * xmlErrorDomain:
+ *
+ * Indicates where an error may have come from
+ */
+typedef enum {
+ XML_FROM_NONE = 0,
+ XML_FROM_PARSER, /* The XML parser */
+ XML_FROM_TREE, /* The tree module */
+ XML_FROM_NAMESPACE, /* The XML Namespace module */
+ XML_FROM_DTD, /* The XML DTD validation with parser context*/
+ XML_FROM_HTML, /* The HTML parser */
+ XML_FROM_MEMORY, /* The memory allocator */
+ XML_FROM_OUTPUT, /* The serialization code */
+ XML_FROM_IO, /* The Input/Output stack */
+ XML_FROM_FTP, /* The FTP module */
+ XML_FROM_HTTP, /* The HTTP module */
+ XML_FROM_XINCLUDE, /* The XInclude processing */
+ XML_FROM_XPATH, /* The XPath module */
+ XML_FROM_XPOINTER, /* The XPointer module */
+ XML_FROM_REGEXP, /* The regular expressions module */
+ XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */
+ XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */
+ XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */
+ XML_FROM_RELAXNGP, /* The Relax-NG parser module */
+ XML_FROM_RELAXNGV, /* The Relax-NG validator module */
+ XML_FROM_CATALOG, /* The Catalog module */
+ XML_FROM_C14N, /* The Canonicalization module */
+ XML_FROM_XSLT, /* The XSLT engine from libxslt */
+ XML_FROM_VALID, /* The XML DTD validation with valid context */
+ XML_FROM_CHECK, /* The error checking module */
+ XML_FROM_WRITER, /* The xmlwriter module */
+ XML_FROM_MODULE, /* The dynamically loaded module module*/
+ XML_FROM_I18N, /* The module handling character conversion */
+ XML_FROM_SCHEMATRONV,/* The Schematron validator module */
+ XML_FROM_BUFFER, /* The buffers module */
+ XML_FROM_URI /* The URI module */
+} xmlErrorDomain;
+
+/**
+ * xmlError:
+ *
+ * An XML Error instance.
+ */
+
+typedef struct _xmlError xmlError;
+typedef xmlError *xmlErrorPtr;
+struct _xmlError {
+ int domain; /* What part of the library raised this error */
+ int code; /* The error code, e.g. an xmlParserError */
+ char *message;/* human-readable informative error message */
+ xmlErrorLevel level;/* how consequent is the error */
+ char *file; /* the filename */
+ int line; /* the line number if available */
+ char *str1; /* extra string information */
+ char *str2; /* extra string information */
+ char *str3; /* extra string information */
+ int int1; /* extra number information */
+ int int2; /* column number of the error or 0 if N/A (todo: rename this field when we would break ABI) */
+ void *ctxt; /* the parser context if available */
+ void *node; /* the node in the tree */
+};
+
+/**
+ * xmlParserError:
+ *
+ * This is an error that the XML (or HTML) parser can generate
+ */
+typedef enum {
+ XML_ERR_OK = 0,
+ XML_ERR_INTERNAL_ERROR, /* 1 */
+ XML_ERR_NO_MEMORY, /* 2 */
+ XML_ERR_DOCUMENT_START, /* 3 */
+ XML_ERR_DOCUMENT_EMPTY, /* 4 */
+ XML_ERR_DOCUMENT_END, /* 5 */
+ XML_ERR_INVALID_HEX_CHARREF, /* 6 */
+ XML_ERR_INVALID_DEC_CHARREF, /* 7 */
+ XML_ERR_INVALID_CHARREF, /* 8 */
+ XML_ERR_INVALID_CHAR, /* 9 */
+ XML_ERR_CHARREF_AT_EOF, /* 10 */
+ XML_ERR_CHARREF_IN_PROLOG, /* 11 */
+ XML_ERR_CHARREF_IN_EPILOG, /* 12 */
+ XML_ERR_CHARREF_IN_DTD, /* 13 */
+ XML_ERR_ENTITYREF_AT_EOF, /* 14 */
+ XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */
+ XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */
+ XML_ERR_ENTITYREF_IN_DTD, /* 17 */
+ XML_ERR_PEREF_AT_EOF, /* 18 */
+ XML_ERR_PEREF_IN_PROLOG, /* 19 */
+ XML_ERR_PEREF_IN_EPILOG, /* 20 */
+ XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */
+ XML_ERR_ENTITYREF_NO_NAME, /* 22 */
+ XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */
+ XML_ERR_PEREF_NO_NAME, /* 24 */
+ XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */
+ XML_ERR_UNDECLARED_ENTITY, /* 26 */
+ XML_WAR_UNDECLARED_ENTITY, /* 27 */
+ XML_ERR_UNPARSED_ENTITY, /* 28 */
+ XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */
+ XML_ERR_ENTITY_IS_PARAMETER, /* 30 */
+ XML_ERR_UNKNOWN_ENCODING, /* 31 */
+ XML_ERR_UNSUPPORTED_ENCODING, /* 32 */
+ XML_ERR_STRING_NOT_STARTED, /* 33 */
+ XML_ERR_STRING_NOT_CLOSED, /* 34 */
+ XML_ERR_NS_DECL_ERROR, /* 35 */
+ XML_ERR_ENTITY_NOT_STARTED, /* 36 */
+ XML_ERR_ENTITY_NOT_FINISHED, /* 37 */
+ XML_ERR_LT_IN_ATTRIBUTE, /* 38 */
+ XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */
+ XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */
+ XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */
+ XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */
+ XML_ERR_LITERAL_NOT_STARTED, /* 43 */
+ XML_ERR_LITERAL_NOT_FINISHED, /* 44 */
+ XML_ERR_COMMENT_NOT_FINISHED, /* 45 */
+ XML_ERR_PI_NOT_STARTED, /* 46 */
+ XML_ERR_PI_NOT_FINISHED, /* 47 */
+ XML_ERR_NOTATION_NOT_STARTED, /* 48 */
+ XML_ERR_NOTATION_NOT_FINISHED, /* 49 */
+ XML_ERR_ATTLIST_NOT_STARTED, /* 50 */
+ XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */
+ XML_ERR_MIXED_NOT_STARTED, /* 52 */
+ XML_ERR_MIXED_NOT_FINISHED, /* 53 */
+ XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */
+ XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */
+ XML_ERR_XMLDECL_NOT_STARTED, /* 56 */
+ XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */
+ XML_ERR_CONDSEC_NOT_STARTED, /* 58 */
+ XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */
+ XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */
+ XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */
+ XML_ERR_MISPLACED_CDATA_END, /* 62 */
+ XML_ERR_CDATA_NOT_FINISHED, /* 63 */
+ XML_ERR_RESERVED_XML_NAME, /* 64 */
+ XML_ERR_SPACE_REQUIRED, /* 65 */
+ XML_ERR_SEPARATOR_REQUIRED, /* 66 */
+ XML_ERR_NMTOKEN_REQUIRED, /* 67 */
+ XML_ERR_NAME_REQUIRED, /* 68 */
+ XML_ERR_PCDATA_REQUIRED, /* 69 */
+ XML_ERR_URI_REQUIRED, /* 70 */
+ XML_ERR_PUBID_REQUIRED, /* 71 */
+ XML_ERR_LT_REQUIRED, /* 72 */
+ XML_ERR_GT_REQUIRED, /* 73 */
+ XML_ERR_LTSLASH_REQUIRED, /* 74 */
+ XML_ERR_EQUAL_REQUIRED, /* 75 */
+ XML_ERR_TAG_NAME_MISMATCH, /* 76 */
+ XML_ERR_TAG_NOT_FINISHED, /* 77 */
+ XML_ERR_STANDALONE_VALUE, /* 78 */
+ XML_ERR_ENCODING_NAME, /* 79 */
+ XML_ERR_HYPHEN_IN_COMMENT, /* 80 */
+ XML_ERR_INVALID_ENCODING, /* 81 */
+ XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */
+ XML_ERR_CONDSEC_INVALID, /* 83 */
+ XML_ERR_VALUE_REQUIRED, /* 84 */
+ XML_ERR_NOT_WELL_BALANCED, /* 85 */
+ XML_ERR_EXTRA_CONTENT, /* 86 */
+ XML_ERR_ENTITY_CHAR_ERROR, /* 87 */
+ XML_ERR_ENTITY_PE_INTERNAL, /* 88 */
+ XML_ERR_ENTITY_LOOP, /* 89 */
+ XML_ERR_ENTITY_BOUNDARY, /* 90 */
+ XML_ERR_INVALID_URI, /* 91 */
+ XML_ERR_URI_FRAGMENT, /* 92 */
+ XML_WAR_CATALOG_PI, /* 93 */
+ XML_ERR_NO_DTD, /* 94 */
+ XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */
+ XML_ERR_VERSION_MISSING, /* 96 */
+ XML_WAR_UNKNOWN_VERSION, /* 97 */
+ XML_WAR_LANG_VALUE, /* 98 */
+ XML_WAR_NS_URI, /* 99 */
+ XML_WAR_NS_URI_RELATIVE, /* 100 */
+ XML_ERR_MISSING_ENCODING, /* 101 */
+ XML_WAR_SPACE_VALUE, /* 102 */
+ XML_ERR_NOT_STANDALONE, /* 103 */
+ XML_ERR_ENTITY_PROCESSING, /* 104 */
+ XML_ERR_NOTATION_PROCESSING, /* 105 */
+ XML_WAR_NS_COLUMN, /* 106 */
+ XML_WAR_ENTITY_REDEFINED, /* 107 */
+ XML_ERR_UNKNOWN_VERSION, /* 108 */
+ XML_ERR_VERSION_MISMATCH, /* 109 */
+ XML_ERR_NAME_TOO_LONG, /* 110 */
+ XML_NS_ERR_XML_NAMESPACE = 200,
+ XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
+ XML_NS_ERR_QNAME, /* 202 */
+ XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */
+ XML_NS_ERR_EMPTY, /* 204 */
+ XML_NS_ERR_COLON, /* 205 */
+ XML_DTD_ATTRIBUTE_DEFAULT = 500,
+ XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */
+ XML_DTD_ATTRIBUTE_VALUE, /* 502 */
+ XML_DTD_CONTENT_ERROR, /* 503 */
+ XML_DTD_CONTENT_MODEL, /* 504 */
+ XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */
+ XML_DTD_DIFFERENT_PREFIX, /* 506 */
+ XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */
+ XML_DTD_ELEM_NAMESPACE, /* 508 */
+ XML_DTD_ELEM_REDEFINED, /* 509 */
+ XML_DTD_EMPTY_NOTATION, /* 510 */
+ XML_DTD_ENTITY_TYPE, /* 511 */
+ XML_DTD_ID_FIXED, /* 512 */
+ XML_DTD_ID_REDEFINED, /* 513 */
+ XML_DTD_ID_SUBSET, /* 514 */
+ XML_DTD_INVALID_CHILD, /* 515 */
+ XML_DTD_INVALID_DEFAULT, /* 516 */
+ XML_DTD_LOAD_ERROR, /* 517 */
+ XML_DTD_MISSING_ATTRIBUTE, /* 518 */
+ XML_DTD_MIXED_CORRUPT, /* 519 */
+ XML_DTD_MULTIPLE_ID, /* 520 */
+ XML_DTD_NO_DOC, /* 521 */
+ XML_DTD_NO_DTD, /* 522 */
+ XML_DTD_NO_ELEM_NAME, /* 523 */
+ XML_DTD_NO_PREFIX, /* 524 */
+ XML_DTD_NO_ROOT, /* 525 */
+ XML_DTD_NOTATION_REDEFINED, /* 526 */
+ XML_DTD_NOTATION_VALUE, /* 527 */
+ XML_DTD_NOT_EMPTY, /* 528 */
+ XML_DTD_NOT_PCDATA, /* 529 */
+ XML_DTD_NOT_STANDALONE, /* 530 */
+ XML_DTD_ROOT_NAME, /* 531 */
+ XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */
+ XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */
+ XML_DTD_UNKNOWN_ELEM, /* 534 */
+ XML_DTD_UNKNOWN_ENTITY, /* 535 */
+ XML_DTD_UNKNOWN_ID, /* 536 */
+ XML_DTD_UNKNOWN_NOTATION, /* 537 */
+ XML_DTD_STANDALONE_DEFAULTED, /* 538 */
+ XML_DTD_XMLID_VALUE, /* 539 */
+ XML_DTD_XMLID_TYPE, /* 540 */
+ XML_DTD_DUP_TOKEN, /* 541 */
+ XML_HTML_STRUCURE_ERROR = 800,
+ XML_HTML_UNKNOWN_TAG, /* 801 */
+ XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000,
+ XML_RNGP_ATTR_CONFLICT, /* 1001 */
+ XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */
+ XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */
+ XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */
+ XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */
+ XML_RNGP_CHOICE_CONTENT, /* 1006 */
+ XML_RNGP_CHOICE_EMPTY, /* 1007 */
+ XML_RNGP_CREATE_FAILURE, /* 1008 */
+ XML_RNGP_DATA_CONTENT, /* 1009 */
+ XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */
+ XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */
+ XML_RNGP_DEFINE_EMPTY, /* 1012 */
+ XML_RNGP_DEFINE_MISSING, /* 1013 */
+ XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */
+ XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */
+ XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */
+ XML_RNGP_ELEMENT_EMPTY, /* 1017 */
+ XML_RNGP_ELEMENT_CONTENT, /* 1018 */
+ XML_RNGP_ELEMENT_NAME, /* 1019 */
+ XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */
+ XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */
+ XML_RNGP_EMPTY, /* 1022 */
+ XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */
+ XML_RNGP_EMPTY_CONTENT, /* 1024 */
+ XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */
+ XML_RNGP_ERROR_TYPE_LIB, /* 1026 */
+ XML_RNGP_EXCEPT_EMPTY, /* 1027 */
+ XML_RNGP_EXCEPT_MISSING, /* 1028 */
+ XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */
+ XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */
+ XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */
+ XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */
+ XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */
+ XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */
+ XML_RNGP_FOREIGN_ELEMENT, /* 1035 */
+ XML_RNGP_GRAMMAR_CONTENT, /* 1036 */
+ XML_RNGP_GRAMMAR_EMPTY, /* 1037 */
+ XML_RNGP_GRAMMAR_MISSING, /* 1038 */
+ XML_RNGP_GRAMMAR_NO_START, /* 1039 */
+ XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */
+ XML_RNGP_HREF_ERROR, /* 1041 */
+ XML_RNGP_INCLUDE_EMPTY, /* 1042 */
+ XML_RNGP_INCLUDE_FAILURE, /* 1043 */
+ XML_RNGP_INCLUDE_RECURSE, /* 1044 */
+ XML_RNGP_INTERLEAVE_ADD, /* 1045 */
+ XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */
+ XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */
+ XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */
+ XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */
+ XML_RNGP_INVALID_URI, /* 1050 */
+ XML_RNGP_INVALID_VALUE, /* 1051 */
+ XML_RNGP_MISSING_HREF, /* 1052 */
+ XML_RNGP_NAME_MISSING, /* 1053 */
+ XML_RNGP_NEED_COMBINE, /* 1054 */
+ XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */
+ XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */
+ XML_RNGP_NSNAME_NO_NS, /* 1057 */
+ XML_RNGP_PARAM_FORBIDDEN, /* 1058 */
+ XML_RNGP_PARAM_NAME_MISSING, /* 1059 */
+ XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */
+ XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */
+ XML_RNGP_PARENTREF_NO_NAME, /* 1062 */
+ XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */
+ XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */
+ XML_RNGP_PARSE_ERROR, /* 1065 */
+ XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */
+ XML_RNGP_PAT_ATTR_ATTR, /* 1067 */
+ XML_RNGP_PAT_ATTR_ELEM, /* 1068 */
+ XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */
+ XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */
+ XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */
+ XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */
+ XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */
+ XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */
+ XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */
+ XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */
+ XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */
+ XML_RNGP_PAT_LIST_ATTR, /* 1078 */
+ XML_RNGP_PAT_LIST_ELEM, /* 1079 */
+ XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */
+ XML_RNGP_PAT_LIST_LIST, /* 1081 */
+ XML_RNGP_PAT_LIST_REF, /* 1082 */
+ XML_RNGP_PAT_LIST_TEXT, /* 1083 */
+ XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */
+ XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */
+ XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */
+ XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */
+ XML_RNGP_PAT_START_ATTR, /* 1088 */
+ XML_RNGP_PAT_START_DATA, /* 1089 */
+ XML_RNGP_PAT_START_EMPTY, /* 1090 */
+ XML_RNGP_PAT_START_GROUP, /* 1091 */
+ XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */
+ XML_RNGP_PAT_START_LIST, /* 1093 */
+ XML_RNGP_PAT_START_ONEMORE, /* 1094 */
+ XML_RNGP_PAT_START_TEXT, /* 1095 */
+ XML_RNGP_PAT_START_VALUE, /* 1096 */
+ XML_RNGP_PREFIX_UNDEFINED, /* 1097 */
+ XML_RNGP_REF_CREATE_FAILED, /* 1098 */
+ XML_RNGP_REF_CYCLE, /* 1099 */
+ XML_RNGP_REF_NAME_INVALID, /* 1100 */
+ XML_RNGP_REF_NO_DEF, /* 1101 */
+ XML_RNGP_REF_NO_NAME, /* 1102 */
+ XML_RNGP_REF_NOT_EMPTY, /* 1103 */
+ XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */
+ XML_RNGP_START_CONTENT, /* 1105 */
+ XML_RNGP_START_EMPTY, /* 1106 */
+ XML_RNGP_START_MISSING, /* 1107 */
+ XML_RNGP_TEXT_EXPECTED, /* 1108 */
+ XML_RNGP_TEXT_HAS_CHILD, /* 1109 */
+ XML_RNGP_TYPE_MISSING, /* 1110 */
+ XML_RNGP_TYPE_NOT_FOUND, /* 1111 */
+ XML_RNGP_TYPE_VALUE, /* 1112 */
+ XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */
+ XML_RNGP_UNKNOWN_COMBINE, /* 1114 */
+ XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */
+ XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */
+ XML_RNGP_URI_FRAGMENT, /* 1117 */
+ XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */
+ XML_RNGP_VALUE_EMPTY, /* 1119 */
+ XML_RNGP_VALUE_NO_CONTENT, /* 1120 */
+ XML_RNGP_XMLNS_NAME, /* 1121 */
+ XML_RNGP_XML_NS, /* 1122 */
+ XML_XPATH_EXPRESSION_OK = 1200,
+ XML_XPATH_NUMBER_ERROR, /* 1201 */
+ XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */
+ XML_XPATH_START_LITERAL_ERROR, /* 1203 */
+ XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */
+ XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */
+ XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */
+ XML_XPATH_EXPR_ERROR, /* 1207 */
+ XML_XPATH_UNCLOSED_ERROR, /* 1208 */
+ XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */
+ XML_XPATH_INVALID_OPERAND, /* 1210 */
+ XML_XPATH_INVALID_TYPE, /* 1211 */
+ XML_XPATH_INVALID_ARITY, /* 1212 */
+ XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */
+ XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */
+ XML_XPATH_MEMORY_ERROR, /* 1215 */
+ XML_XPTR_SYNTAX_ERROR, /* 1216 */
+ XML_XPTR_RESOURCE_ERROR, /* 1217 */
+ XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */
+ XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */
+ XML_XPATH_ENCODING_ERROR, /* 1220 */
+ XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */
+ XML_TREE_INVALID_HEX = 1300,
+ XML_TREE_INVALID_DEC, /* 1301 */
+ XML_TREE_UNTERMINATED_ENTITY, /* 1302 */
+ XML_TREE_NOT_UTF8, /* 1303 */
+ XML_SAVE_NOT_UTF8 = 1400,
+ XML_SAVE_CHAR_INVALID, /* 1401 */
+ XML_SAVE_NO_DOCTYPE, /* 1402 */
+ XML_SAVE_UNKNOWN_ENCODING, /* 1403 */
+ XML_REGEXP_COMPILE_ERROR = 1450,
+ XML_IO_UNKNOWN = 1500,
+ XML_IO_EACCES, /* 1501 */
+ XML_IO_EAGAIN, /* 1502 */
+ XML_IO_EBADF, /* 1503 */
+ XML_IO_EBADMSG, /* 1504 */
+ XML_IO_EBUSY, /* 1505 */
+ XML_IO_ECANCELED, /* 1506 */
+ XML_IO_ECHILD, /* 1507 */
+ XML_IO_EDEADLK, /* 1508 */
+ XML_IO_EDOM, /* 1509 */
+ XML_IO_EEXIST, /* 1510 */
+ XML_IO_EFAULT, /* 1511 */
+ XML_IO_EFBIG, /* 1512 */
+ XML_IO_EINPROGRESS, /* 1513 */
+ XML_IO_EINTR, /* 1514 */
+ XML_IO_EINVAL, /* 1515 */
+ XML_IO_EIO, /* 1516 */
+ XML_IO_EISDIR, /* 1517 */
+ XML_IO_EMFILE, /* 1518 */
+ XML_IO_EMLINK, /* 1519 */
+ XML_IO_EMSGSIZE, /* 1520 */
+ XML_IO_ENAMETOOLONG, /* 1521 */
+ XML_IO_ENFILE, /* 1522 */
+ XML_IO_ENODEV, /* 1523 */
+ XML_IO_ENOENT, /* 1524 */
+ XML_IO_ENOEXEC, /* 1525 */
+ XML_IO_ENOLCK, /* 1526 */
+ XML_IO_ENOMEM, /* 1527 */
+ XML_IO_ENOSPC, /* 1528 */
+ XML_IO_ENOSYS, /* 1529 */
+ XML_IO_ENOTDIR, /* 1530 */
+ XML_IO_ENOTEMPTY, /* 1531 */
+ XML_IO_ENOTSUP, /* 1532 */
+ XML_IO_ENOTTY, /* 1533 */
+ XML_IO_ENXIO, /* 1534 */
+ XML_IO_EPERM, /* 1535 */
+ XML_IO_EPIPE, /* 1536 */
+ XML_IO_ERANGE, /* 1537 */
+ XML_IO_EROFS, /* 1538 */
+ XML_IO_ESPIPE, /* 1539 */
+ XML_IO_ESRCH, /* 1540 */
+ XML_IO_ETIMEDOUT, /* 1541 */
+ XML_IO_EXDEV, /* 1542 */
+ XML_IO_NETWORK_ATTEMPT, /* 1543 */
+ XML_IO_ENCODER, /* 1544 */
+ XML_IO_FLUSH, /* 1545 */
+ XML_IO_WRITE, /* 1546 */
+ XML_IO_NO_INPUT, /* 1547 */
+ XML_IO_BUFFER_FULL, /* 1548 */
+ XML_IO_LOAD_ERROR, /* 1549 */
+ XML_IO_ENOTSOCK, /* 1550 */
+ XML_IO_EISCONN, /* 1551 */
+ XML_IO_ECONNREFUSED, /* 1552 */
+ XML_IO_ENETUNREACH, /* 1553 */
+ XML_IO_EADDRINUSE, /* 1554 */
+ XML_IO_EALREADY, /* 1555 */
+ XML_IO_EAFNOSUPPORT, /* 1556 */
+ XML_XINCLUDE_RECURSION=1600,
+ XML_XINCLUDE_PARSE_VALUE, /* 1601 */
+ XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */
+ XML_XINCLUDE_NO_HREF, /* 1603 */
+ XML_XINCLUDE_NO_FALLBACK, /* 1604 */
+ XML_XINCLUDE_HREF_URI, /* 1605 */
+ XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */
+ XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */
+ XML_XINCLUDE_INVALID_CHAR, /* 1608 */
+ XML_XINCLUDE_BUILD_FAILED, /* 1609 */
+ XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */
+ XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */
+ XML_XINCLUDE_XPTR_FAILED, /* 1612 */
+ XML_XINCLUDE_XPTR_RESULT, /* 1613 */
+ XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */
+ XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */
+ XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */
+ XML_XINCLUDE_DEPRECATED_NS, /* 1617 */
+ XML_XINCLUDE_FRAGMENT_ID, /* 1618 */
+ XML_CATALOG_MISSING_ATTR = 1650,
+ XML_CATALOG_ENTRY_BROKEN, /* 1651 */
+ XML_CATALOG_PREFER_VALUE, /* 1652 */
+ XML_CATALOG_NOT_CATALOG, /* 1653 */
+ XML_CATALOG_RECURSION, /* 1654 */
+ XML_SCHEMAP_PREFIX_UNDEFINED = 1700,
+ XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */
+ XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */
+ XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */
+ XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */
+ XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */
+ XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */
+ XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */
+ XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */
+ XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */
+ XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */
+ XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */
+ XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */
+ XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */
+ XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */
+ XML_SCHEMAP_INVALID_ENUM, /* 1715 */
+ XML_SCHEMAP_INVALID_FACET, /* 1716 */
+ XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */
+ XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */
+ XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */
+ XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */
+ XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */
+ XML_SCHEMAP_NOATTR_NOREF, /* 1722 */
+ XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */
+ XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */
+ XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */
+ XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */
+ XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */
+ XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */
+ XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */
+ XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */
+ XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */
+ XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */
+ XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */
+ XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */
+ XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */
+ XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */
+ XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */
+ XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */
+ XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */
+ XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */
+ XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */
+ XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */
+ XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */
+ XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */
+ XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */
+ XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */
+ XML_SCHEMAP_UNKNOWN_REF, /* 1747 */
+ XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */
+ XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */
+ XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */
+ XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */
+ XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */
+ XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */
+ XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */
+ XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */
+ XML_SCHEMAP_REGEXP_INVALID, /* 1756 */
+ XML_SCHEMAP_FAILED_LOAD, /* 1757 */
+ XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */
+ XML_SCHEMAP_NOROOT, /* 1759 */
+ XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */
+ XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */
+ XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */
+ XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */
+ XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */
+ XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */
+ XML_SCHEMAP_FAILED_PARSE, /* 1766 */
+ XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */
+ XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */
+ XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */
+ XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */
+ XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */
+ XML_SCHEMAP_NOT_SCHEMA, /* 1772 */
+ XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */
+ XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */
+ XML_SCHEMAP_RECURSIVE, /* 1775 */
+ XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */
+ XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */
+ XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */
+ XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */
+ XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */
+ XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */
+ XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */
+ XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */
+ XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */
+ XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */
+ XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */
+ XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */
+ XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */
+ XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */
+ XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */
+ XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */
+ XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */
+ XML_SCHEMAV_NOROOT = 1801,
+ XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */
+ XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */
+ XML_SCHEMAV_MISSING, /* 1804 */
+ XML_SCHEMAV_WRONGELEM, /* 1805 */
+ XML_SCHEMAV_NOTYPE, /* 1806 */
+ XML_SCHEMAV_NOROLLBACK, /* 1807 */
+ XML_SCHEMAV_ISABSTRACT, /* 1808 */
+ XML_SCHEMAV_NOTEMPTY, /* 1809 */
+ XML_SCHEMAV_ELEMCONT, /* 1810 */
+ XML_SCHEMAV_HAVEDEFAULT, /* 1811 */
+ XML_SCHEMAV_NOTNILLABLE, /* 1812 */
+ XML_SCHEMAV_EXTRACONTENT, /* 1813 */
+ XML_SCHEMAV_INVALIDATTR, /* 1814 */
+ XML_SCHEMAV_INVALIDELEM, /* 1815 */
+ XML_SCHEMAV_NOTDETERMINIST, /* 1816 */
+ XML_SCHEMAV_CONSTRUCT, /* 1817 */
+ XML_SCHEMAV_INTERNAL, /* 1818 */
+ XML_SCHEMAV_NOTSIMPLE, /* 1819 */
+ XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */
+ XML_SCHEMAV_ATTRINVALID, /* 1821 */
+ XML_SCHEMAV_VALUE, /* 1822 */
+ XML_SCHEMAV_FACET, /* 1823 */
+ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */
+ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */
+ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */
+ XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */
+ XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */
+ XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */
+ XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */
+ XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */
+ XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */
+ XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */
+ XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */
+ XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */
+ XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */
+ XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */
+ XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */
+ XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */
+ XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */
+ XML_SCHEMAV_CVC_ELT_1, /* 1845 */
+ XML_SCHEMAV_CVC_ELT_2, /* 1846 */
+ XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */
+ XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */
+ XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */
+ XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */
+ XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */
+ XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */
+ XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */
+ XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */
+ XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */
+ XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */
+ XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */
+ XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */
+ XML_SCHEMAV_CVC_ELT_6, /* 1859 */
+ XML_SCHEMAV_CVC_ELT_7, /* 1860 */
+ XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */
+ XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */
+ XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */
+ XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */
+ XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */
+ XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */
+ XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */
+ XML_SCHEMAV_CVC_AU, /* 1874 */
+ XML_SCHEMAV_CVC_TYPE_1, /* 1875 */
+ XML_SCHEMAV_CVC_TYPE_2, /* 1876 */
+ XML_SCHEMAV_CVC_IDC, /* 1877 */
+ XML_SCHEMAV_CVC_WILDCARD, /* 1878 */
+ XML_SCHEMAV_MISC, /* 1879 */
+ XML_XPTR_UNKNOWN_SCHEME = 1900,
+ XML_XPTR_CHILDSEQ_START, /* 1901 */
+ XML_XPTR_EVAL_FAILED, /* 1902 */
+ XML_XPTR_EXTRA_OBJECTS, /* 1903 */
+ XML_C14N_CREATE_CTXT = 1950,
+ XML_C14N_REQUIRES_UTF8, /* 1951 */
+ XML_C14N_CREATE_STACK, /* 1952 */
+ XML_C14N_INVALID_NODE, /* 1953 */
+ XML_C14N_UNKNOW_NODE, /* 1954 */
+ XML_C14N_RELATIVE_NAMESPACE, /* 1955 */
+ XML_FTP_PASV_ANSWER = 2000,
+ XML_FTP_EPSV_ANSWER, /* 2001 */
+ XML_FTP_ACCNT, /* 2002 */
+ XML_FTP_URL_SYNTAX, /* 2003 */
+ XML_HTTP_URL_SYNTAX = 2020,
+ XML_HTTP_USE_IP, /* 2021 */
+ XML_HTTP_UNKNOWN_HOST, /* 2022 */
+ XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000,
+ XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */
+ XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */
+ XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */
+ XML_SCHEMAP_SRC_RESOLVE, /* 3004 */
+ XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */
+ XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */
+ XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */
+ XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */
+ XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */
+ XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */
+ XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */
+ XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */
+ XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */
+ XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */
+ XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */
+ XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */
+ XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */
+ XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */
+ XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */
+ XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */
+ XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */
+ XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */
+ XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */
+ XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */
+ XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */
+ XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */
+ XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */
+ XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */
+ XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */
+ XML_SCHEMAP_SRC_INCLUDE, /* 3050 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */
+ XML_SCHEMAP_NO_XMLNS, /* 3056 */
+ XML_SCHEMAP_NO_XSI, /* 3057 */
+ XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */
+ XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */
+ XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */
+ XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */
+ XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */
+ XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */
+ XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */
+ XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */
+ XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */
+ XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */
+ XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */
+ XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */
+ XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */
+ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */
+ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */
+ XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */
+ XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */
+ XML_SCHEMAP_SRC_CT_1, /* 3076 */
+ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */
+ XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */
+ XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */
+ XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */
+ XML_SCHEMAP_SRC_REDEFINE, /* 3081 */
+ XML_SCHEMAP_SRC_IMPORT, /* 3082 */
+ XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */
+ XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */
+ XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */
+ XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */
+ XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */
+ XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */
+ XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */
+ XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */
+ XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */
+ XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */
+ XML_SCHEMATRONV_REPORT,
+ XML_MODULE_OPEN = 4900, /* 4900 */
+ XML_MODULE_CLOSE, /* 4901 */
+ XML_CHECK_FOUND_ELEMENT = 5000,
+ XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */
+ XML_CHECK_FOUND_TEXT, /* 5002 */
+ XML_CHECK_FOUND_CDATA, /* 5003 */
+ XML_CHECK_FOUND_ENTITYREF, /* 5004 */
+ XML_CHECK_FOUND_ENTITY, /* 5005 */
+ XML_CHECK_FOUND_PI, /* 5006 */
+ XML_CHECK_FOUND_COMMENT, /* 5007 */
+ XML_CHECK_FOUND_DOCTYPE, /* 5008 */
+ XML_CHECK_FOUND_FRAGMENT, /* 5009 */
+ XML_CHECK_FOUND_NOTATION, /* 5010 */
+ XML_CHECK_UNKNOWN_NODE, /* 5011 */
+ XML_CHECK_ENTITY_TYPE, /* 5012 */
+ XML_CHECK_NO_PARENT, /* 5013 */
+ XML_CHECK_NO_DOC, /* 5014 */
+ XML_CHECK_NO_NAME, /* 5015 */
+ XML_CHECK_NO_ELEM, /* 5016 */
+ XML_CHECK_WRONG_DOC, /* 5017 */
+ XML_CHECK_NO_PREV, /* 5018 */
+ XML_CHECK_WRONG_PREV, /* 5019 */
+ XML_CHECK_NO_NEXT, /* 5020 */
+ XML_CHECK_WRONG_NEXT, /* 5021 */
+ XML_CHECK_NOT_DTD, /* 5022 */
+ XML_CHECK_NOT_ATTR, /* 5023 */
+ XML_CHECK_NOT_ATTR_DECL, /* 5024 */
+ XML_CHECK_NOT_ELEM_DECL, /* 5025 */
+ XML_CHECK_NOT_ENTITY_DECL, /* 5026 */
+ XML_CHECK_NOT_NS_DECL, /* 5027 */
+ XML_CHECK_NO_HREF, /* 5028 */
+ XML_CHECK_WRONG_PARENT,/* 5029 */
+ XML_CHECK_NS_SCOPE, /* 5030 */
+ XML_CHECK_NS_ANCESTOR, /* 5031 */
+ XML_CHECK_NOT_UTF8, /* 5032 */
+ XML_CHECK_NO_DICT, /* 5033 */
+ XML_CHECK_NOT_NCNAME, /* 5034 */
+ XML_CHECK_OUTSIDE_DICT, /* 5035 */
+ XML_CHECK_WRONG_NAME, /* 5036 */
+ XML_CHECK_NAME_NOT_NULL, /* 5037 */
+ XML_I18N_NO_NAME = 6000,
+ XML_I18N_NO_HANDLER, /* 6001 */
+ XML_I18N_EXCESS_HANDLER, /* 6002 */
+ XML_I18N_CONV_FAILED, /* 6003 */
+ XML_I18N_NO_OUTPUT, /* 6004 */
+ XML_BUF_OVERFLOW = 7000
+} xmlParserErrors;
+
+/**
+ * xmlGenericErrorFunc:
+ * @ctx: a parsing context
+ * @msg: the message
+ * @...: the extra arguments of the varags to format the message
+ *
+ * Signature of the function to use when there is an error and
+ * no parsing or validity context available .
+ */
+typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * xmlStructuredErrorFunc:
+ * @userData: user provided data for the error callback
+ * @error: the error being raised.
+ *
+ * Signature of the function to use when there is an error and
+ * the module handles the new error reporting mechanism.
+ */
+typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);
+
+/*
+ * Use the following function to reset the two global variables
+ * xmlGenericError and xmlGenericErrorContext.
+ */
+XMLPUBFUN void XMLCALL
+ xmlSetGenericErrorFunc (void *ctx,
+ xmlGenericErrorFunc handler);
+XMLPUBFUN void XMLCALL
+ initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler);
+
+XMLPUBFUN void XMLCALL
+ xmlSetStructuredErrorFunc (void *ctx,
+ xmlStructuredErrorFunc handler);
+/*
+ * Default message routines used by SAX and Valid context for error
+ * and warning reporting.
+ */
+XMLPUBFUN void XMLCDECL
+ xmlParserError (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
+ xmlParserWarning (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
+ xmlParserValidityError (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
+ xmlParserValidityWarning (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCALL
+ xmlParserPrintFileInfo (xmlParserInputPtr input);
+XMLPUBFUN void XMLCALL
+ xmlParserPrintFileContext (xmlParserInputPtr input);
+
+/*
+ * Extended error information routines
+ */
+XMLPUBFUN xmlErrorPtr XMLCALL
+ xmlGetLastError (void);
+XMLPUBFUN void XMLCALL
+ xmlResetLastError (void);
+XMLPUBFUN xmlErrorPtr XMLCALL
+ xmlCtxtGetLastError (void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlCtxtResetLastError (void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlResetError (xmlErrorPtr err);
+XMLPUBFUN int XMLCALL
+ xmlCopyError (xmlErrorPtr from,
+ xmlErrorPtr to);
+
+#ifdef IN_LIBXML
+/*
+ * Internal callback reporting routine
+ */
+XMLPUBFUN void XMLCALL
+ __xmlRaiseError (xmlStructuredErrorFunc schannel,
+ xmlGenericErrorFunc channel,
+ void *data,
+ void *ctx,
+ void *node,
+ int domain,
+ int code,
+ xmlErrorLevel level,
+ const char *file,
+ int line,
+ const char *str1,
+ const char *str2,
+ const char *str3,
+ int int1,
+ int col,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(16,17);
+XMLPUBFUN void XMLCALL
+ __xmlSimpleError (int domain,
+ int code,
+ xmlNodePtr node,
+ const char *msg,
+ const char *extra);
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_ERROR_H__ */
diff --git a/fmu10/src/shared/libxml/xmlexports.h b/fmu10/src/shared/libxml/xmlexports.h
new file mode 100644
index 0000000..2c79f81
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlexports.h
@@ -0,0 +1,162 @@
+/*
+ * Summary: macros for marking symbols as exportable/importable.
+ * Description: macros for marking symbols as exportable/importable.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Igor Zlatovic
+ */
+
+#ifndef __XML_EXPORTS_H__
+#define __XML_EXPORTS_H__
+
+/**
+ * XMLPUBFUN, XMLPUBVAR, XMLCALL
+ *
+ * Macros which declare an exportable function, an exportable variable and
+ * the calling convention used for functions.
+ *
+ * Please use an extra block for every platform/compiler combination when
+ * modifying this, rather than overlong #ifdef lines. This helps
+ * readability as well as the fact that different compilers on the same
+ * platform might need different definitions.
+ */
+
+/**
+ * XMLPUBFUN:
+ *
+ * Macros which declare an exportable function
+ */
+#define XMLPUBFUN
+/**
+ * XMLPUBVAR:
+ *
+ * Macros which declare an exportable variable
+ */
+#define XMLPUBVAR extern
+/**
+ * XMLCALL:
+ *
+ * Macros which declare the called convention for exported functions
+ */
+#define XMLCALL
+/**
+ * XMLCDECL:
+ *
+ * Macro which declares the calling convention for exported functions that
+ * use '...'.
+ */
+#define XMLCDECL
+
+/** DOC_DISABLE */
+
+/* Windows platform with MS compiler */
+#if defined(_WIN32) && defined(_MSC_VER)
+ #undef XMLPUBFUN
+ #undef XMLPUBVAR
+ #undef XMLCALL
+ #undef XMLCDECL
+ #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
+ #define XMLPUBFUN __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport)
+ #else
+ #define XMLPUBFUN
+ #if !defined(LIBXML_STATIC)
+ #define XMLPUBVAR __declspec(dllimport) extern
+ #else
+ #define XMLPUBVAR extern
+ #endif
+ #endif
+ #if defined(LIBXML_FASTCALL)
+ #define XMLCALL __fastcall
+ #else
+ #define XMLCALL __cdecl
+ #endif
+ #define XMLCDECL __cdecl
+ #if !defined _REENTRANT
+ #define _REENTRANT
+ #endif
+#endif
+
+/* Windows platform with Borland compiler */
+#if defined(_WIN32) && defined(__BORLANDC__)
+ #undef XMLPUBFUN
+ #undef XMLPUBVAR
+ #undef XMLCALL
+ #undef XMLCDECL
+ #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
+ #define XMLPUBFUN __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport) extern
+ #else
+ #define XMLPUBFUN
+ #if !defined(LIBXML_STATIC)
+ #define XMLPUBVAR __declspec(dllimport) extern
+ #else
+ #define XMLPUBVAR extern
+ #endif
+ #endif
+ #define XMLCALL __cdecl
+ #define XMLCDECL __cdecl
+ #if !defined _REENTRANT
+ #define _REENTRANT
+ #endif
+#endif
+
+/* Windows platform with GNU compiler (Mingw) */
+#if defined(_WIN32) && defined(__MINGW32__)
+ #undef XMLPUBFUN
+ #undef XMLPUBVAR
+ #undef XMLCALL
+ #undef XMLCDECL
+ /*
+ * if defined(IN_LIBXML) this raises problems on mingw with msys
+ * _imp__xmlFree listed as missing. Try to workaround the problem
+ * by also making that declaration when compiling client code.
+ */
+ #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
+ #define XMLPUBFUN __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport) extern
+ #else
+ #define XMLPUBFUN
+ #if !defined(LIBXML_STATIC)
+ #define XMLPUBVAR __declspec(dllimport) extern
+ #else
+ #define XMLPUBVAR extern
+ #endif
+ #endif
+ #define XMLCALL __cdecl
+ #define XMLCDECL __cdecl
+ #if !defined _REENTRANT
+ #define _REENTRANT
+ #endif
+#endif
+
+/* Cygwin platform, GNU compiler */
+#if defined(_WIN32) && defined(__CYGWIN__)
+ #undef XMLPUBFUN
+ #undef XMLPUBVAR
+ #undef XMLCALL
+ #undef XMLCDECL
+ #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
+ #define XMLPUBFUN __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport)
+ #else
+ #define XMLPUBFUN
+ #if !defined(LIBXML_STATIC)
+ #define XMLPUBVAR __declspec(dllimport) extern
+ #else
+ #define XMLPUBVAR
+ #endif
+ #endif
+ #define XMLCALL __cdecl
+ #define XMLCDECL __cdecl
+#endif
+
+/* Compatibility */
+#if !defined(LIBXML_DLL_IMPORT)
+#define LIBXML_DLL_IMPORT XMLPUBVAR
+#endif
+
+#endif /* __XML_EXPORTS_H__ */
+
+
diff --git a/fmu10/src/shared/libxml/xmlmemory.h b/fmu10/src/shared/libxml/xmlmemory.h
new file mode 100644
index 0000000..17e375a
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlmemory.h
@@ -0,0 +1,224 @@
+/*
+ * Summary: interface for the memory allocator
+ * Description: provides interfaces for the memory allocator,
+ * including debugging capabilities.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+
+#ifndef __DEBUG_MEMORY_ALLOC__
+#define __DEBUG_MEMORY_ALLOC__
+
+#include
+#include
+
+/**
+ * DEBUG_MEMORY:
+ *
+ * DEBUG_MEMORY replaces the allocator with a collect and debug
+ * shell to the libc allocator.
+ * DEBUG_MEMORY should only be activated when debugging
+ * libxml i.e. if libxml has been configured with --with-debug-mem too.
+ */
+/* #define DEBUG_MEMORY_FREED */
+/* #define DEBUG_MEMORY_LOCATION */
+
+#ifdef DEBUG
+#ifndef DEBUG_MEMORY
+#define DEBUG_MEMORY
+#endif
+#endif
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * DEBUG_MEMORY_LOCATION should be activated only when debugging
+ * libxml i.e. if libxml has been configured with --with-debug-mem too.
+ */
+#ifdef DEBUG_MEMORY_LOCATION
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The XML memory wrapper support 4 basic overloadable functions.
+ */
+/**
+ * xmlFreeFunc:
+ * @mem: an already allocated block of memory
+ *
+ * Signature for a free() implementation.
+ */
+typedef void (XMLCALL *xmlFreeFunc)(void *mem);
+/**
+ * xmlMallocFunc:
+ * @size: the size requested in bytes
+ *
+ * Signature for a malloc() implementation.
+ *
+ * Returns a pointer to the newly allocated block or NULL in case of error.
+ */
+typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size);
+
+/**
+ * xmlReallocFunc:
+ * @mem: an already allocated block of memory
+ * @size: the new size requested in bytes
+ *
+ * Signature for a realloc() implementation.
+ *
+ * Returns a pointer to the newly reallocated block or NULL in case of error.
+ */
+typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size);
+
+/**
+ * xmlStrdupFunc:
+ * @str: a zero terminated string
+ *
+ * Signature for an strdup() implementation.
+ *
+ * Returns the copy of the string or NULL in case of error.
+ */
+typedef char *(XMLCALL *xmlStrdupFunc)(const char *str);
+
+/*
+ * The 4 interfaces used for all memory handling within libxml.
+LIBXML_DLL_IMPORT xmlFreeFunc xmlFree;
+LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;
+LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;
+LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;
+LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;
+ */
+
+/*
+ * The way to overload the existing functions.
+ * The xmlGc function have an extra entry for atomic block
+ * allocations useful for garbage collected memory allocators
+ */
+XMLPUBFUN int XMLCALL
+ xmlMemSetup (xmlFreeFunc freeFunc,
+ xmlMallocFunc mallocFunc,
+ xmlReallocFunc reallocFunc,
+ xmlStrdupFunc strdupFunc);
+XMLPUBFUN int XMLCALL
+ xmlMemGet (xmlFreeFunc *freeFunc,
+ xmlMallocFunc *mallocFunc,
+ xmlReallocFunc *reallocFunc,
+ xmlStrdupFunc *strdupFunc);
+XMLPUBFUN int XMLCALL
+ xmlGcMemSetup (xmlFreeFunc freeFunc,
+ xmlMallocFunc mallocFunc,
+ xmlMallocFunc mallocAtomicFunc,
+ xmlReallocFunc reallocFunc,
+ xmlStrdupFunc strdupFunc);
+XMLPUBFUN int XMLCALL
+ xmlGcMemGet (xmlFreeFunc *freeFunc,
+ xmlMallocFunc *mallocFunc,
+ xmlMallocFunc *mallocAtomicFunc,
+ xmlReallocFunc *reallocFunc,
+ xmlStrdupFunc *strdupFunc);
+
+/*
+ * Initialization of the memory layer.
+ */
+XMLPUBFUN int XMLCALL
+ xmlInitMemory (void);
+
+/*
+ * Cleanup of the memory layer.
+ */
+XMLPUBFUN void XMLCALL
+ xmlCleanupMemory (void);
+/*
+ * These are specific to the XML debug memory wrapper.
+ */
+XMLPUBFUN int XMLCALL
+ xmlMemUsed (void);
+XMLPUBFUN int XMLCALL
+ xmlMemBlocks (void);
+XMLPUBFUN void XMLCALL
+ xmlMemDisplay (FILE *fp);
+XMLPUBFUN void XMLCALL
+ xmlMemDisplayLast(FILE *fp, long nbBytes);
+XMLPUBFUN void XMLCALL
+ xmlMemShow (FILE *fp, int nr);
+XMLPUBFUN void XMLCALL
+ xmlMemoryDump (void);
+XMLPUBFUN void * XMLCALL
+ xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN void * XMLCALL
+ xmlMemRealloc (void *ptr,size_t size);
+XMLPUBFUN void XMLCALL
+ xmlMemFree (void *ptr);
+XMLPUBFUN char * XMLCALL
+ xmlMemoryStrdup (const char *str);
+XMLPUBFUN void * XMLCALL
+ xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN void * XMLCALL
+ xmlReallocLoc (void *ptr, size_t size, const char *file, int line);
+XMLPUBFUN void * XMLCALL
+ xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN char * XMLCALL
+ xmlMemStrdupLoc (const char *str, const char *file, int line);
+
+
+#ifdef DEBUG_MEMORY_LOCATION
+/**
+ * xmlMalloc:
+ * @size: number of bytes to allocate
+ *
+ * Wrapper for the malloc() function used in the XML library.
+ *
+ * Returns the pointer to the allocated area or NULL in case of error.
+ */
+#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)
+/**
+ * xmlMallocAtomic:
+ * @size: number of bytes to allocate
+ *
+ * Wrapper for the malloc() function used in the XML library for allocation
+ * of block not containing pointers to other areas.
+ *
+ * Returns the pointer to the allocated area or NULL in case of error.
+ */
+#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)
+/**
+ * xmlRealloc:
+ * @ptr: pointer to the existing allocated area
+ * @size: number of bytes to allocate
+ *
+ * Wrapper for the realloc() function used in the XML library.
+ *
+ * Returns the pointer to the allocated area or NULL in case of error.
+ */
+#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)
+/**
+ * xmlMemStrdup:
+ * @str: pointer to the existing string
+ *
+ * Wrapper for the strdup() function, xmlStrdup() is usually preferred.
+ *
+ * Returns the pointer to the allocated area or NULL in case of error.
+ */
+#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
+
+#endif /* DEBUG_MEMORY_LOCATION */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifndef __XML_GLOBALS_H
+#ifndef __XML_THREADS_H__
+#include
+#include
+#endif
+#endif
+
+#endif /* __DEBUG_MEMORY_ALLOC__ */
+
diff --git a/fmu10/src/shared/libxml/xmlreader.h b/fmu10/src/shared/libxml/xmlreader.h
new file mode 100644
index 0000000..6964482
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlreader.h
@@ -0,0 +1,424 @@
+/*
+ * Summary: the XMLReader implementation
+ * Description: API of the XML streaming API based on C# interfaces.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_XMLREADER_H__
+#define __XML_XMLREADER_H__
+
+#include
+#include
+#include
+#ifdef LIBXML_SCHEMAS_ENABLED
+#include
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlParserSeverities:
+ *
+ * How severe an error callback is when the per-reader error callback API
+ * is used.
+ */
+typedef enum {
+ XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
+ XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
+ XML_PARSER_SEVERITY_WARNING = 3,
+ XML_PARSER_SEVERITY_ERROR = 4
+} xmlParserSeverities;
+
+#ifdef LIBXML_READER_ENABLED
+
+/**
+ * xmlTextReaderMode:
+ *
+ * Internal state values for the reader.
+ */
+typedef enum {
+ XML_TEXTREADER_MODE_INITIAL = 0,
+ XML_TEXTREADER_MODE_INTERACTIVE = 1,
+ XML_TEXTREADER_MODE_ERROR = 2,
+ XML_TEXTREADER_MODE_EOF =3,
+ XML_TEXTREADER_MODE_CLOSED = 4,
+ XML_TEXTREADER_MODE_READING = 5
+} xmlTextReaderMode;
+
+/**
+ * xmlParserProperties:
+ *
+ * Some common options to use with xmlTextReaderSetParserProp, but it
+ * is better to use xmlParserOption and the xmlReaderNewxxx and
+ * xmlReaderForxxx APIs now.
+ */
+typedef enum {
+ XML_PARSER_LOADDTD = 1,
+ XML_PARSER_DEFAULTATTRS = 2,
+ XML_PARSER_VALIDATE = 3,
+ XML_PARSER_SUBST_ENTITIES = 4
+} xmlParserProperties;
+
+/**
+ * xmlReaderTypes:
+ *
+ * Predefined constants for the different types of nodes.
+ */
+typedef enum {
+ XML_READER_TYPE_NONE = 0,
+ XML_READER_TYPE_ELEMENT = 1,
+ XML_READER_TYPE_ATTRIBUTE = 2,
+ XML_READER_TYPE_TEXT = 3,
+ XML_READER_TYPE_CDATA = 4,
+ XML_READER_TYPE_ENTITY_REFERENCE = 5,
+ XML_READER_TYPE_ENTITY = 6,
+ XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,
+ XML_READER_TYPE_COMMENT = 8,
+ XML_READER_TYPE_DOCUMENT = 9,
+ XML_READER_TYPE_DOCUMENT_TYPE = 10,
+ XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,
+ XML_READER_TYPE_NOTATION = 12,
+ XML_READER_TYPE_WHITESPACE = 13,
+ XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,
+ XML_READER_TYPE_END_ELEMENT = 15,
+ XML_READER_TYPE_END_ENTITY = 16,
+ XML_READER_TYPE_XML_DECLARATION = 17
+} xmlReaderTypes;
+
+/**
+ * xmlTextReader:
+ *
+ * Structure for an xmlReader context.
+ */
+typedef struct _xmlTextReader xmlTextReader;
+
+/**
+ * xmlTextReaderPtr:
+ *
+ * Pointer to an xmlReader context.
+ */
+typedef xmlTextReader *xmlTextReaderPtr;
+
+/*
+ * Constructors & Destructor
+ */
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlNewTextReader (xmlParserInputBufferPtr input,
+ const char *URI);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlNewTextReaderFilename(const char *URI);
+
+XMLPUBFUN void XMLCALL
+ xmlFreeTextReader (xmlTextReaderPtr reader);
+
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSetup(xmlTextReaderPtr reader,
+ xmlParserInputBufferPtr input, const char *URL,
+ const char *encoding, int options);
+
+/*
+ * Iterators
+ */
+XMLPUBFUN int XMLCALL
+ xmlTextReaderRead (xmlTextReaderPtr reader);
+
+#ifdef LIBXML_WRITER_ENABLED
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadInnerXml (xmlTextReaderPtr reader);
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadOuterXml (xmlTextReaderPtr reader);
+#endif
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadString (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader);
+
+/*
+ * Attributes of the node
+ */
+XMLPUBFUN int XMLCALL
+ xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderDepth (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderHasValue(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderIsDefault (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderNodeType (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderQuoteChar (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderReadState (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
+
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstName (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstPrefix (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstString (xmlTextReaderPtr reader,
+ const xmlChar *str);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstValue (xmlTextReaderPtr reader);
+
+/*
+ * use the Const version of the routine for
+ * better performance and simpler code
+ */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderBaseUri (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderLocalName (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderName (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderPrefix (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderXmlLang (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderValue (xmlTextReaderPtr reader);
+
+/*
+ * Methods of the XmlTextReader
+ */
+XMLPUBFUN int XMLCALL
+ xmlTextReaderClose (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
+ int no);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderGetAttribute (xmlTextReaderPtr reader,
+ const xmlChar *name);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
+ const xmlChar *localName,
+ const xmlChar *namespaceURI);
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+ xmlTextReaderGetRemainder (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
+ const xmlChar *prefix);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
+ int no);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
+ const xmlChar *name);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
+ const xmlChar *localName,
+ const xmlChar *namespaceURI);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderMoveToElement (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderNormalization (xmlTextReaderPtr reader);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstEncoding (xmlTextReaderPtr reader);
+
+/*
+ * Extensions
+ */
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSetParserProp (xmlTextReaderPtr reader,
+ int prop,
+ int value);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderGetParserProp (xmlTextReaderPtr reader,
+ int prop);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlTextReaderCurrentNode (xmlTextReaderPtr reader);
+
+XMLPUBFUN int XMLCALL
+ xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);
+
+XMLPUBFUN int XMLCALL
+ xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
+
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlTextReaderPreserve (xmlTextReaderPtr reader);
+#ifdef LIBXML_PATTERN_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
+ const xmlChar *pattern,
+ const xmlChar **namespaces);
+#endif /* LIBXML_PATTERN_ENABLED */
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlTextReaderExpand (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderNext (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderNextSibling (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderIsValid (xmlTextReaderPtr reader);
+#ifdef LIBXML_SCHEMAS_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
+ const char *rng);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
+ xmlRelaxNGPtr schema);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
+ const char *xsd);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
+ xmlSchemaValidCtxtPtr ctxt,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSetSchema (xmlTextReaderPtr reader,
+ xmlSchemaPtr schema);
+#endif
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderStandalone (xmlTextReaderPtr reader);
+
+
+/*
+ * Index lookup
+ */
+XMLPUBFUN long XMLCALL
+ xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
+
+/*
+ * New more complete APIs for simpler creation and reuse of readers
+ */
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderWalker (xmlDocPtr doc);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderForDoc (const xmlChar * cur,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderForFile (const char *filename,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderForMemory (const char *buffer,
+ int size,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderForFd (int fd,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN xmlTextReaderPtr XMLCALL
+ xmlReaderForIO (xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ const char *URL,
+ const char *encoding,
+ int options);
+
+XMLPUBFUN int XMLCALL
+ xmlReaderNewWalker (xmlTextReaderPtr reader,
+ xmlDocPtr doc);
+XMLPUBFUN int XMLCALL
+ xmlReaderNewDoc (xmlTextReaderPtr reader,
+ const xmlChar * cur,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlReaderNewFile (xmlTextReaderPtr reader,
+ const char *filename,
+ const char *encoding,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlReaderNewMemory (xmlTextReaderPtr reader,
+ const char *buffer,
+ int size,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlReaderNewFd (xmlTextReaderPtr reader,
+ int fd,
+ const char *URL,
+ const char *encoding,
+ int options);
+XMLPUBFUN int XMLCALL
+ xmlReaderNewIO (xmlTextReaderPtr reader,
+ xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx,
+ const char *URL,
+ const char *encoding,
+ int options);
+/*
+ * Error handling extensions
+ */
+typedef void * xmlTextReaderLocatorPtr;
+
+/**
+ * xmlTextReaderErrorFunc:
+ * @arg: the user argument
+ * @msg: the message
+ * @severity: the severity of the error
+ * @locator: a locator indicating where the error occured
+ *
+ * Signature of an error callback from a reader parser
+ */
+typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
+ const char *msg,
+ xmlParserSeverities severity,
+ xmlTextReaderLocatorPtr locator);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
+/*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
+XMLPUBFUN void XMLCALL
+ xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc f,
+ void *arg);
+XMLPUBFUN void XMLCALL
+ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
+ xmlStructuredErrorFunc f,
+ void *arg);
+XMLPUBFUN void XMLCALL
+ xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc *f,
+ void **arg);
+
+#endif /* LIBXML_READER_ENABLED */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XMLREADER_H__ */
+
diff --git a/fmu10/src/shared/libxml/xmlregexp.h b/fmu10/src/shared/libxml/xmlregexp.h
new file mode 100644
index 0000000..7009645
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlregexp.h
@@ -0,0 +1,222 @@
+/*
+ * Summary: regular expressions handling
+ * Description: basic API for libxml regular expressions handling used
+ * for XML Schemas and validation.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_REGEXP_H__
+#define __XML_REGEXP_H__
+
+#include
+
+#ifdef LIBXML_REGEXP_ENABLED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlRegexpPtr:
+ *
+ * A libxml regular expression, they can actually be far more complex
+ * thank the POSIX regex expressions.
+ */
+typedef struct _xmlRegexp xmlRegexp;
+typedef xmlRegexp *xmlRegexpPtr;
+
+/**
+ * xmlRegExecCtxtPtr:
+ *
+ * A libxml progressive regular expression evaluation context
+ */
+typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
+typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
+
+#ifdef __cplusplus
+}
+#endif
+#include
+#include
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The POSIX like API
+ */
+XMLPUBFUN xmlRegexpPtr XMLCALL
+ xmlRegexpCompile (const xmlChar *regexp);
+XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp);
+XMLPUBFUN int XMLCALL
+ xmlRegexpExec (xmlRegexpPtr comp,
+ const xmlChar *value);
+XMLPUBFUN void XMLCALL
+ xmlRegexpPrint (FILE *output,
+ xmlRegexpPtr regexp);
+XMLPUBFUN int XMLCALL
+ xmlRegexpIsDeterminist(xmlRegexpPtr comp);
+
+/**
+ * xmlRegExecCallbacks:
+ * @exec: the regular expression context
+ * @token: the current token string
+ * @transdata: transition data
+ * @inputdata: input data
+ *
+ * Callback function when doing a transition in the automata
+ */
+typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
+ const xmlChar *token,
+ void *transdata,
+ void *inputdata);
+
+/*
+ * The progressive API
+ */
+XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
+ xmlRegNewExecCtxt (xmlRegexpPtr comp,
+ xmlRegExecCallbacks callback,
+ void *data);
+XMLPUBFUN void XMLCALL
+ xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);
+XMLPUBFUN int XMLCALL
+ xmlRegExecPushString(xmlRegExecCtxtPtr exec,
+ const xmlChar *value,
+ void *data);
+XMLPUBFUN int XMLCALL
+ xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
+ const xmlChar *value,
+ const xmlChar *value2,
+ void *data);
+
+XMLPUBFUN int XMLCALL
+ xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
+ int *nbval,
+ int *nbneg,
+ xmlChar **values,
+ int *terminal);
+XMLPUBFUN int XMLCALL
+ xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
+ const xmlChar **string,
+ int *nbval,
+ int *nbneg,
+ xmlChar **values,
+ int *terminal);
+#ifdef LIBXML_EXPR_ENABLED
+/*
+ * Formal regular expression handling
+ * Its goal is to do some formal work on content models
+ */
+
+/* expressions are used within a context */
+typedef struct _xmlExpCtxt xmlExpCtxt;
+typedef xmlExpCtxt *xmlExpCtxtPtr;
+
+XMLPUBFUN void XMLCALL
+ xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);
+XMLPUBFUN xmlExpCtxtPtr XMLCALL
+ xmlExpNewCtxt (int maxNodes,
+ xmlDictPtr dict);
+
+XMLPUBFUN int XMLCALL
+ xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
+
+/* Expressions are trees but the tree is opaque */
+typedef struct _xmlExpNode xmlExpNode;
+typedef xmlExpNode *xmlExpNodePtr;
+
+typedef enum {
+ XML_EXP_EMPTY = 0,
+ XML_EXP_FORBID = 1,
+ XML_EXP_ATOM = 2,
+ XML_EXP_SEQ = 3,
+ XML_EXP_OR = 4,
+ XML_EXP_COUNT = 5
+} xmlExpNodeType;
+
+/*
+ * 2 core expressions shared by all for the empty language set
+ * and for the set with just the empty token
+ */
+XMLPUBVAR xmlExpNodePtr forbiddenExp;
+XMLPUBVAR xmlExpNodePtr emptyExp;
+
+/*
+ * Expressions are reference counted internally
+ */
+XMLPUBFUN void XMLCALL
+ xmlExpFree (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr);
+XMLPUBFUN void XMLCALL
+ xmlExpRef (xmlExpNodePtr expr);
+
+/*
+ * constructors can be either manual or from a string
+ */
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpParse (xmlExpCtxtPtr ctxt,
+ const char *expr);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpNewAtom (xmlExpCtxtPtr ctxt,
+ const xmlChar *name,
+ int len);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpNewOr (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr left,
+ xmlExpNodePtr right);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpNewSeq (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr left,
+ xmlExpNodePtr right);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpNewRange (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr subset,
+ int min,
+ int max);
+/*
+ * The really interesting APIs
+ */
+XMLPUBFUN int XMLCALL
+ xmlExpIsNillable(xmlExpNodePtr expr);
+XMLPUBFUN int XMLCALL
+ xmlExpMaxToken (xmlExpNodePtr expr);
+XMLPUBFUN int XMLCALL
+ xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr,
+ const xmlChar**langList,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlExpGetStart (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr,
+ const xmlChar**tokList,
+ int len);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpStringDerive(xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr,
+ const xmlChar *str,
+ int len);
+XMLPUBFUN xmlExpNodePtr XMLCALL
+ xmlExpExpDerive (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr,
+ xmlExpNodePtr sub);
+XMLPUBFUN int XMLCALL
+ xmlExpSubsume (xmlExpCtxtPtr ctxt,
+ xmlExpNodePtr expr,
+ xmlExpNodePtr sub);
+XMLPUBFUN void XMLCALL
+ xmlExpDump (xmlBufferPtr buf,
+ xmlExpNodePtr expr);
+#endif /* LIBXML_EXPR_ENABLED */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_REGEXP_ENABLED */
+
+#endif /*__XML_REGEXP_H__ */
diff --git a/fmu10/src/shared/libxml/xmlschemas.h b/fmu10/src/shared/libxml/xmlschemas.h
new file mode 100644
index 0000000..97930c7
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlschemas.h
@@ -0,0 +1,246 @@
+/*
+ * Summary: incomplete XML Schemas structure implementation
+ * Description: interface to the XML Schemas handling and schema validity
+ * checking, it is incomplete right now.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+
+#ifndef __XML_SCHEMA_H__
+#define __XML_SCHEMA_H__
+
+#include
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This error codes are obsolete; not used any more.
+ */
+typedef enum {
+ XML_SCHEMAS_ERR_OK = 0,
+ XML_SCHEMAS_ERR_NOROOT = 1,
+ XML_SCHEMAS_ERR_UNDECLAREDELEM,
+ XML_SCHEMAS_ERR_NOTTOPLEVEL,
+ XML_SCHEMAS_ERR_MISSING,
+ XML_SCHEMAS_ERR_WRONGELEM,
+ XML_SCHEMAS_ERR_NOTYPE,
+ XML_SCHEMAS_ERR_NOROLLBACK,
+ XML_SCHEMAS_ERR_ISABSTRACT,
+ XML_SCHEMAS_ERR_NOTEMPTY,
+ XML_SCHEMAS_ERR_ELEMCONT,
+ XML_SCHEMAS_ERR_HAVEDEFAULT,
+ XML_SCHEMAS_ERR_NOTNILLABLE,
+ XML_SCHEMAS_ERR_EXTRACONTENT,
+ XML_SCHEMAS_ERR_INVALIDATTR,
+ XML_SCHEMAS_ERR_INVALIDELEM,
+ XML_SCHEMAS_ERR_NOTDETERMINIST,
+ XML_SCHEMAS_ERR_CONSTRUCT,
+ XML_SCHEMAS_ERR_INTERNAL,
+ XML_SCHEMAS_ERR_NOTSIMPLE,
+ XML_SCHEMAS_ERR_ATTRUNKNOWN,
+ XML_SCHEMAS_ERR_ATTRINVALID,
+ XML_SCHEMAS_ERR_VALUE,
+ XML_SCHEMAS_ERR_FACET,
+ XML_SCHEMAS_ERR_,
+ XML_SCHEMAS_ERR_XXX
+} xmlSchemaValidError;
+
+/*
+* ATTENTION: Change xmlSchemaSetValidOptions's check
+* for invalid values, if adding to the validation
+* options below.
+*/
+/**
+ * xmlSchemaValidOption:
+ *
+ * This is the set of XML Schema validation options.
+ */
+typedef enum {
+ XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
+ /* Default/fixed: create an attribute node
+ * or an element's text node on the instance.
+ */
+} xmlSchemaValidOption;
+
+/*
+ XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
+ * assemble schemata using
+ * xsi:schemaLocation and
+ * xsi:noNamespaceSchemaLocation
+*/
+
+/**
+ * The schemas related types are kept internal
+ */
+typedef struct _xmlSchema xmlSchema;
+typedef xmlSchema *xmlSchemaPtr;
+
+/**
+ * xmlSchemaValidityErrorFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of an error callback from an XSD validation
+ */
+typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * xmlSchemaValidityWarningFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of a warning callback from an XSD validation
+ */
+typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * A schemas validation context
+ */
+typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
+typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
+
+typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
+typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
+
+/**
+ * xmlSchemaValidityLocatorFunc:
+ * @ctx: user provided context
+ * @file: returned file information
+ * @line: returned line information
+ *
+ * A schemas validation locator, a callback called by the validator.
+ * This is used when file or node informations are not available
+ * to find out what file and line number are affected
+ *
+ * Returns: 0 in case of success and -1 in case of error
+ */
+
+typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
+ const char **file, unsigned long *line);
+
+/*
+ * Interfaces for parsing.
+ */
+XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+ xmlSchemaNewParserCtxt (const char *URL);
+XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+ xmlSchemaNewMemParserCtxt (const char *buffer,
+ int size);
+XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+ xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
+XMLPUBFUN void XMLCALL
+ xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
+ xmlSchemaValidityErrorFunc err,
+ xmlSchemaValidityWarningFunc warn,
+ void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror,
+ void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
+ xmlSchemaValidityErrorFunc * err,
+ xmlSchemaValidityWarningFunc * warn,
+ void **ctx);
+XMLPUBFUN int XMLCALL
+ xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
+
+XMLPUBFUN xmlSchemaPtr XMLCALL
+ xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
+XMLPUBFUN void XMLCALL
+ xmlSchemaFree (xmlSchemaPtr schema);
+#ifdef LIBXML_OUTPUT_ENABLED
+XMLPUBFUN void XMLCALL
+ xmlSchemaDump (FILE *output,
+ xmlSchemaPtr schema);
+#endif /* LIBXML_OUTPUT_ENABLED */
+/*
+ * Interfaces for validating
+ */
+XMLPUBFUN void XMLCALL
+ xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
+ xmlSchemaValidityErrorFunc err,
+ xmlSchemaValidityWarningFunc warn,
+ void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror,
+ void *ctx);
+XMLPUBFUN int XMLCALL
+ xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
+ xmlSchemaValidityErrorFunc *err,
+ xmlSchemaValidityWarningFunc *warn,
+ void **ctx);
+XMLPUBFUN int XMLCALL
+ xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
+ int options);
+XMLPUBFUN void XMLCALL
+ xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
+ const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
+
+XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
+ xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
+XMLPUBFUN void XMLCALL
+ xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
+XMLPUBFUN int XMLCALL
+ xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
+ xmlDocPtr instance);
+XMLPUBFUN int XMLCALL
+ xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
+ xmlNodePtr elem);
+XMLPUBFUN int XMLCALL
+ xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
+ xmlParserInputBufferPtr input,
+ xmlCharEncoding enc,
+ xmlSAXHandlerPtr sax,
+ void *user_data);
+XMLPUBFUN int XMLCALL
+ xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
+ const char * filename,
+ int options);
+
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
+
+/*
+ * Interface to insert Schemas SAX validation in a SAX stream
+ */
+typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
+typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
+
+XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
+ xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
+ xmlSAXHandlerPtr *sax,
+ void **user_data);
+XMLPUBFUN int XMLCALL
+ xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
+
+
+XMLPUBFUN void XMLCALL
+ xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
+ xmlSchemaValidityLocatorFunc f,
+ void *ctxt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBXML_SCHEMAS_ENABLED */
+#endif /* __XML_SCHEMA_H__ */
diff --git a/fmu10/src/shared/libxml/xmlstring.h b/fmu10/src/shared/libxml/xmlstring.h
new file mode 100644
index 0000000..2036236
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlstring.h
@@ -0,0 +1,140 @@
+/*
+ * Summary: set of routines to process strings
+ * Description: type and interfaces needed for the internal string handling
+ * of the library, especially UTF8 processing.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_STRING_H__
+#define __XML_STRING_H__
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xmlChar:
+ *
+ * This is a basic byte in an UTF-8 encoded string.
+ * It's unsigned allowing to pinpoint case where char * are assigned
+ * to xmlChar * (possibly making serialization back impossible).
+ */
+typedef unsigned char xmlChar;
+
+/**
+ * BAD_CAST:
+ *
+ * Macro to cast a string to an xmlChar * when one know its safe.
+ */
+#define BAD_CAST (xmlChar *)
+
+/*
+ * xmlChar handling
+ */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrdup (const xmlChar *cur);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrndup (const xmlChar *cur,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlCharStrndup (const char *cur,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlCharStrdup (const char *cur);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrsub (const xmlChar *str,
+ int start,
+ int len);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlStrchr (const xmlChar *str,
+ xmlChar val);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlStrstr (const xmlChar *str,
+ const xmlChar *val);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlStrcasestr (const xmlChar *str,
+ const xmlChar *val);
+XMLPUBFUN int XMLCALL
+ xmlStrcmp (const xmlChar *str1,
+ const xmlChar *str2);
+XMLPUBFUN int XMLCALL
+ xmlStrncmp (const xmlChar *str1,
+ const xmlChar *str2,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlStrcasecmp (const xmlChar *str1,
+ const xmlChar *str2);
+XMLPUBFUN int XMLCALL
+ xmlStrncasecmp (const xmlChar *str1,
+ const xmlChar *str2,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlStrEqual (const xmlChar *str1,
+ const xmlChar *str2);
+XMLPUBFUN int XMLCALL
+ xmlStrQEqual (const xmlChar *pref,
+ const xmlChar *name,
+ const xmlChar *str);
+XMLPUBFUN int XMLCALL
+ xmlStrlen (const xmlChar *str);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrcat (xmlChar *cur,
+ const xmlChar *add);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrncat (xmlChar *cur,
+ const xmlChar *add,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlStrncatNew (const xmlChar *str1,
+ const xmlChar *str2,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlStrPrintf (xmlChar *buf,
+ int len,
+ const xmlChar *msg,
+ ...);
+XMLPUBFUN int XMLCALL
+ xmlStrVPrintf (xmlChar *buf,
+ int len,
+ const xmlChar *msg,
+ va_list ap);
+
+XMLPUBFUN int XMLCALL
+ xmlGetUTF8Char (const unsigned char *utf,
+ int *len);
+XMLPUBFUN int XMLCALL
+ xmlCheckUTF8 (const unsigned char *utf);
+XMLPUBFUN int XMLCALL
+ xmlUTF8Strsize (const xmlChar *utf,
+ int len);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlUTF8Strndup (const xmlChar *utf,
+ int len);
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlUTF8Strpos (const xmlChar *utf,
+ int pos);
+XMLPUBFUN int XMLCALL
+ xmlUTF8Strloc (const xmlChar *utf,
+ const xmlChar *utfchar);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlUTF8Strsub (const xmlChar *utf,
+ int start,
+ int len);
+XMLPUBFUN int XMLCALL
+ xmlUTF8Strlen (const xmlChar *utf);
+XMLPUBFUN int XMLCALL
+ xmlUTF8Size (const xmlChar *utf);
+XMLPUBFUN int XMLCALL
+ xmlUTF8Charcmp (const xmlChar *utf1,
+ const xmlChar *utf2);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_STRING_H__ */
diff --git a/fmu10/src/shared/libxml/xmlversion.h b/fmu10/src/shared/libxml/xmlversion.h
new file mode 100644
index 0000000..f8915dc
--- /dev/null
+++ b/fmu10/src/shared/libxml/xmlversion.h
@@ -0,0 +1,480 @@
+/*
+ * Summary: compile-time version informations
+ * Description: compile-time version informations for the XML library
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_VERSION_H__
+#define __XML_VERSION_H__
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * use those to be sure nothing nasty will happen if
+ * your library and includes mismatch
+ */
+#ifndef LIBXML2_COMPILING_MSCCDEF
+XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
+#endif /* LIBXML2_COMPILING_MSCCDEF */
+
+/**
+ * LIBXML_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXML_DOTTED_VERSION "2.9.0"
+
+/**
+ * LIBXML_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXML_VERSION 20900
+
+/**
+ * LIBXML_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXML_VERSION_STRING "20900"
+
+/**
+ * LIBXML_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define LIBXML_VERSION_EXTRA ""
+
+/**
+ * LIBXML_TEST_VERSION:
+ *
+ * Macro to check that the libxml version in use is compatible with
+ * the version the software has been compiled against
+ */
+#define LIBXML_TEST_VERSION xmlCheckVersion(20900);
+
+#ifndef VMS
+#if 0
+/**
+ * WITH_TRIO:
+ *
+ * defined if the trio support need to be configured in
+ */
+#define WITH_TRIO
+#else
+/**
+ * WITHOUT_TRIO:
+ *
+ * defined if the trio support should not be configured in
+ */
+#define WITHOUT_TRIO
+#endif
+#else /* VMS */
+/**
+ * WITH_TRIO:
+ *
+ * defined if the trio support need to be configured in
+ */
+#define WITH_TRIO 1
+#endif /* VMS */
+
+/**
+ * LIBXML_THREAD_ENABLED:
+ *
+ * Whether the thread support is configured in
+ */
+#if 1
+#if defined(_REENTRANT) || defined(__MT__) || \
+ (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
+#define LIBXML_THREAD_ENABLED
+#endif
+#endif
+
+/**
+ * LIBXML_TREE_ENABLED:
+ *
+ * Whether the DOM like tree manipulation API support is configured in
+ */
+#if 1
+#define LIBXML_TREE_ENABLED
+#endif
+
+/**
+ * LIBXML_OUTPUT_ENABLED:
+ *
+ * Whether the serialization/saving support is configured in
+ */
+#if 1
+#define LIBXML_OUTPUT_ENABLED
+#endif
+
+/**
+ * LIBXML_PUSH_ENABLED:
+ *
+ * Whether the push parsing interfaces are configured in
+ */
+#if 1
+#define LIBXML_PUSH_ENABLED
+#endif
+
+/**
+ * LIBXML_READER_ENABLED:
+ *
+ * Whether the xmlReader parsing interface is configured in
+ */
+#if 1
+#define LIBXML_READER_ENABLED
+#endif
+
+/**
+ * LIBXML_PATTERN_ENABLED:
+ *
+ * Whether the xmlPattern node selection interface is configured in
+ */
+#if 1
+#define LIBXML_PATTERN_ENABLED
+#endif
+
+/**
+ * LIBXML_WRITER_ENABLED:
+ *
+ * Whether the xmlWriter saving interface is configured in
+ */
+#if 1
+#define LIBXML_WRITER_ENABLED
+#endif
+
+/**
+ * LIBXML_SAX1_ENABLED:
+ *
+ * Whether the older SAX1 interface is configured in
+ */
+#if 1
+#define LIBXML_SAX1_ENABLED
+#endif
+
+/**
+ * LIBXML_FTP_ENABLED:
+ *
+ * Whether the FTP support is configured in
+ */
+#if 1
+#define LIBXML_FTP_ENABLED
+#endif
+
+/**
+ * LIBXML_HTTP_ENABLED:
+ *
+ * Whether the HTTP support is configured in
+ */
+#if 1
+#define LIBXML_HTTP_ENABLED
+#endif
+
+/**
+ * LIBXML_VALID_ENABLED:
+ *
+ * Whether the DTD validation support is configured in
+ */
+#if 1
+#define LIBXML_VALID_ENABLED
+#endif
+
+/**
+ * LIBXML_HTML_ENABLED:
+ *
+ * Whether the HTML support is configured in
+ */
+#if 1
+#define LIBXML_HTML_ENABLED
+#endif
+
+/**
+ * LIBXML_LEGACY_ENABLED:
+ *
+ * Whether the deprecated APIs are compiled in for compatibility
+ */
+#if 1
+#define LIBXML_LEGACY_ENABLED
+#endif
+
+/**
+ * LIBXML_C14N_ENABLED:
+ *
+ * Whether the Canonicalization support is configured in
+ */
+#if 1
+#define LIBXML_C14N_ENABLED
+#endif
+
+/**
+ * LIBXML_CATALOG_ENABLED:
+ *
+ * Whether the Catalog support is configured in
+ */
+#if 1
+#define LIBXML_CATALOG_ENABLED
+#endif
+
+/**
+ * LIBXML_DOCB_ENABLED:
+ *
+ * Whether the SGML Docbook support is configured in
+ */
+#if 1
+#define LIBXML_DOCB_ENABLED
+#endif
+
+/**
+ * LIBXML_XPATH_ENABLED:
+ *
+ * Whether XPath is configured in
+ */
+#if 1
+#define LIBXML_XPATH_ENABLED
+#endif
+
+/**
+ * LIBXML_XPTR_ENABLED:
+ *
+ * Whether XPointer is configured in
+ */
+#if 1
+#define LIBXML_XPTR_ENABLED
+#endif
+
+/**
+ * LIBXML_XINCLUDE_ENABLED:
+ *
+ * Whether XInclude is configured in
+ */
+#if 1
+#define LIBXML_XINCLUDE_ENABLED
+#endif
+
+/**
+ * LIBXML_ICONV_ENABLED:
+ *
+ * Whether iconv support is available
+ */
+#if 0
+#define LIBXML_ICONV_ENABLED
+#endif
+
+/**
+ * LIBXML_ICU_ENABLED:
+ *
+ * Whether icu support is available
+ */
+#if 0
+#define LIBXML_ICU_ENABLED
+#endif
+
+/**
+ * LIBXML_ISO8859X_ENABLED:
+ *
+ * Whether ISO-8859-* support is made available in case iconv is not
+ */
+#if 0
+#define LIBXML_ISO8859X_ENABLED
+#endif
+
+/**
+ * LIBXML_DEBUG_ENABLED:
+ *
+ * Whether Debugging module is configured in
+ */
+#if 1
+#define LIBXML_DEBUG_ENABLED
+#endif
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * Whether the memory debugging is configured in
+ */
+#if 0
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * LIBXML_DEBUG_RUNTIME:
+ *
+ * Whether the runtime debugging is configured in
+ */
+#if 0
+#define LIBXML_DEBUG_RUNTIME
+#endif
+
+/**
+ * LIBXML_UNICODE_ENABLED:
+ *
+ * Whether the Unicode related interfaces are compiled in
+ */
+#if 1
+#define LIBXML_UNICODE_ENABLED
+#endif
+
+/**
+ * LIBXML_REGEXP_ENABLED:
+ *
+ * Whether the regular expressions interfaces are compiled in
+ */
+#if 1
+#define LIBXML_REGEXP_ENABLED
+#endif
+
+/**
+ * LIBXML_AUTOMATA_ENABLED:
+ *
+ * Whether the automata interfaces are compiled in
+ */
+#if 1
+#define LIBXML_AUTOMATA_ENABLED
+#endif
+
+/**
+ * LIBXML_EXPR_ENABLED:
+ *
+ * Whether the formal expressions interfaces are compiled in
+ */
+#if 1
+#define LIBXML_EXPR_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMAS_ENABLED:
+ *
+ * Whether the Schemas validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMAS_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMATRON_ENABLED:
+ *
+ * Whether the Schematron validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMATRON_ENABLED
+#endif
+
+/**
+ * LIBXML_MODULES_ENABLED:
+ *
+ * Whether the module interfaces are compiled in
+ */
+#if 1
+#define LIBXML_MODULES_ENABLED
+/**
+ * LIBXML_MODULE_EXTENSION:
+ *
+ * the string suffix used by dynamic modules (usually shared libraries)
+ */
+#define LIBXML_MODULE_EXTENSION ".dll"
+#endif
+
+/**
+ * LIBXML_ZLIB_ENABLED:
+ *
+ * Whether the Zlib support is compiled in
+ */
+#if 0
+#define LIBXML_ZLIB_ENABLED
+#endif
+
+/**
+ * LIBXML_LZMA_ENABLED:
+ *
+ * Whether the Lzma support is compiled in
+ */
+#if 0
+#define LIBXML_LZMA_ENABLED
+#endif
+
+#ifdef __GNUC__
+#ifdef HAVE_ANSIDECL_H
+#include
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+
+#ifndef ATTRIBUTE_UNUSED
+# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
+# define ATTRIBUTE_UNUSED __attribute__((unused))
+# else
+# define ATTRIBUTE_UNUSED
+# endif
+#endif
+
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+
+#ifndef LIBXML_ATTR_ALLOC_SIZE
+# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
+# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# else
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+# endif
+#else
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+#endif
+
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+
+#ifndef LIBXML_ATTR_FORMAT
+# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+# else
+# define LIBXML_ATTR_FORMAT(fmt,args)
+# endif
+#else
+# define LIBXML_ATTR_FORMAT(fmt,args)
+#endif
+
+#else /* ! __GNUC__ */
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+#define ATTRIBUTE_UNUSED
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+#define LIBXML_ATTR_ALLOC_SIZE(x)
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+#define LIBXML_ATTR_FORMAT(fmt,args)
+#endif /* __GNUC__ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
+
+
diff --git a/fmu10/src/shared/libxml2.lib b/fmu10/src/shared/libxml2.lib
new file mode 100644
index 0000000..90b103c
Binary files /dev/null and b/fmu10/src/shared/libxml2.lib differ
diff --git a/fmu10/src/shared/sim_support.c b/fmu10/src/shared/sim_support.c
new file mode 100644
index 0000000..44d0ede
--- /dev/null
+++ b/fmu10/src/shared/sim_support.c
@@ -0,0 +1,602 @@
+/* -------------------------------------------------------------------------
+ * sim_support.c
+ * Functions used by both FMU simulators fmu10sim_me and fmu10sim_cs
+ * to parse command-line arguments, to unzip and load an fmu,
+ * to write CSV file, and more.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include
+#include
+
+#ifdef FMI_COSIMULATION
+#include "fmi_cs.h"
+#else
+#include "fmi_me.h"
+#endif
+
+#include "xmlVersionParser.h"
+#include "sim_support.h"
+
+#if !WINDOWS
+#define MAX_PATH 1024
+#include // mkdtemp()
+#include //dlsym()
+#endif /* WINDOWS */
+
+extern FMU fmu;
+
+#if WINDOWS
+int unzip(const char *zipPath, const char *outPath) {
+ int code;
+ char binPath[BUFSIZE];
+ int n = BUFSIZE + strlen(UNZIP_CMD) + strlen(outPath) + 3 + strlen(zipPath) + 9;
+ char* cmd = (char*)calloc(sizeof(char), n);
+
+ // %FMUSDK_HOME%\bin to find 7z.dll and 7z.exe
+ if (!GetEnvironmentVariable("FMUSDK_HOME", binPath, BUFSIZE)) {
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+ printf ("error: Environment variable FMUSDK_HOME not defined\n");
+ }
+ else {
+ printf ("error: Could not get value of FMUSDK_HOME\n");
+ }
+ return 0; // error
+ }
+ strcat(binPath, "\\fmu10\\bin");
+ // run the unzip command
+ // remove "> NUL" to see the unzip protocol
+ sprintf(cmd, "%s\\%s\"%s\" \"%s\" > NUL", binPath, UNZIP_CMD, outPath, zipPath);
+ // printf("cmd='%s'\n", cmd);
+ code = system(cmd);
+ free(cmd);
+ if (code!=SEVEN_ZIP_NO_ERROR) {
+ printf("7z: ");
+ switch (code) {
+ case SEVEN_ZIP_WARNING: printf("warning\n"); break;
+ case SEVEN_ZIP_ERROR: printf("error\n"); break;
+ case SEVEN_ZIP_COMMAND_LINE_ERROR: printf("command line error\n"); break;
+ case SEVEN_ZIP_OUT_OF_MEMORY: printf("out of memory\n"); break;
+ case SEVEN_ZIP_STOPPED_BY_USER: printf("stopped by user\n"); break;
+ default: printf("unknown problem\n");
+ }
+ }
+
+ return (code==SEVEN_ZIP_NO_ERROR || code==SEVEN_ZIP_WARNING) ? 1 : 0;
+}
+
+#else /* WINDOWS */
+
+int unzip(const char *zipPath, const char *outPath) {
+ int code;
+ int n;
+ char* cmd;
+
+ // run the unzip command
+ n = strlen(UNZIP_CMD) + strlen(outPath) + 1 + strlen(zipPath) + 16;
+ cmd = (char*)calloc(sizeof(char), n);
+ sprintf(cmd, "%s%s \"%s\" > /dev/null", UNZIP_CMD, outPath, zipPath);
+ printf("cmd='%s'\n", cmd);
+ code = system(cmd);
+ free(cmd);
+ if (code!=SEVEN_ZIP_NO_ERROR) {
+ printf("%s: ", UNZIP_CMD);
+ switch (code) {
+ case 1: printf("warning\n"); break;
+ case 2: printf("error\n"); break;
+ case 3: printf("severe error\n"); break;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ printf("out of memory\n"); break;
+ case 10: printf("command line error\n"); break;
+ default: printf("unknown problem %d\n", code);
+ }
+ }
+ return (code==SEVEN_ZIP_NO_ERROR || code==SEVEN_ZIP_WARNING) ? 1 : 0;
+}
+#endif /* WINDOWS */
+
+#if WINDOWS
+// fileName is an absolute path, e.g. C:\test\a.fmu
+// or relative to the current dir, e.g. ..\test\a.fmu
+// Does not check for existence of the file
+static char* getFmuPath(const char* fileName){
+ char pathName[MAX_PATH];
+ int n = GetFullPathName(fileName, MAX_PATH, pathName, NULL);
+ return n ? strdup(pathName) : NULL;
+}
+
+static char* getTmpPath() {
+ char tmpPath[BUFSIZE];
+ if(! GetTempPath(BUFSIZE, tmpPath)) {
+ printf ("error: Could not find temporary disk space\n");
+ return NULL;
+ }
+ strcat(tmpPath, "fmu\\");
+ return strdup(tmpPath);
+}
+
+#else /* WINDOWS */
+// fmuFileName is an absolute path, e.g. "C:\test\a.fmu"
+// or relative to the current dir, e.g. "..\test\a.fmu"
+static char* getFmuPath(const char* fmuFileName){
+ /* Not sure why this is useful. Just returning the filename. */
+ return strdup(fmuFileName);
+}
+static char* getTmpPath() {
+ char template[13]; // Lenght of "fmuTmpXXXXXX" + null
+ sprintf(template, "%s", "fmuTmpXXXXXX");
+ //char *tmp = mkdtemp(strdup("fmuTmpXXXXXX"));
+ char *tmp = mkdtemp(template);
+ if (tmp==NULL) {
+ fprintf(stderr, "Couldn't create temporary directory\n");
+ exit(1);
+ }
+ char * results = calloc(sizeof(char), strlen(tmp) + 2);
+ strncat(results, tmp, strlen(tmp));
+ return strcat(results, "/");
+}
+#endif /* WINDOWS */
+
+char *getTempFmuLocation() {
+ char *tempPath = getTmpPath();
+ char *fmuLocation = (char *)calloc(sizeof(char), 8 + strlen(tempPath));
+ strcpy(fmuLocation, "file://");
+ strcat(fmuLocation, tempPath);
+ free(tempPath);
+ return fmuLocation;
+}
+
+static void* getAdr(int* s, FMU *fmu, const char* functionName){
+ char name[BUFSIZE];
+ void* fp;
+ sprintf(name, "%s_%s", getModelIdentifier(fmu->modelDescription), functionName);
+#if WINDOWS
+ fp = GetProcAddress(fmu->dllHandle, name);
+#else /* WINDOWS */
+ fp = dlsym(fmu->dllHandle, name);
+#endif /* WINDOWS */
+ if (!fp) {
+ printf ("warning: Function %s not found in dll\n", name);
+#if WINDOWS
+#else /* WINDOWS */
+ printf ("Error was: %s\n", dlerror());
+#endif /* WINDOWS */
+ *s = 0; // mark dll load as 'failed'
+ }
+ return fp;
+}
+
+// Load the given dll and set function pointers in fmu
+// Return 0 to indicate failure
+static int loadDll(const char* dllPath, FMU *fmu) {
+ int s = 1;
+#if WINDOWS
+ HANDLE h = LoadLibrary(dllPath);
+#else /* WINDOWS */
+ HANDLE h = dlopen(dllPath, RTLD_LAZY);
+#endif /* WINDOWS */
+ if (!h) {
+#if WINDOWS
+#else
+ printf("The error was: %s\n", dlerror());
+#endif
+ printf("error: Could not load %s\n", dllPath);
+ return 0; // failure
+ }
+ fmu->dllHandle = h;
+
+#ifdef FMI_COSIMULATION
+ fmu->getTypesPlatform = (fGetTypesPlatform) getAdr(&s, fmu, "fmiGetTypesPlatform");
+ if (s==0) {
+ s = 1; // work around bug for FMUs exported using Dymola 2012 and SimulationX 3.x
+ fmu->getTypesPlatform = (fGetTypesPlatform) getAdr(&s, fmu, "fmiGetModelTypesPlatform");
+ if (s==1) printf(" using fmiGetModelTypesPlatform instead\n");
+ }
+ fmu->instantiateSlave = (fInstantiateSlave) getAdr(&s, fmu, "fmiInstantiateSlave");
+ fmu->initializeSlave = (fInitializeSlave) getAdr(&s, fmu, "fmiInitializeSlave");
+ fmu->terminateSlave = (fTerminateSlave) getAdr(&s, fmu, "fmiTerminateSlave");
+ fmu->resetSlave = (fResetSlave) getAdr(&s, fmu, "fmiResetSlave");
+ fmu->freeSlaveInstance = (fFreeSlaveInstance) getAdr(&s, fmu, "fmiFreeSlaveInstance");
+ fmu->setRealInputDerivatives = (fSetRealInputDerivatives) getAdr(&s, fmu, "fmiSetRealInputDerivatives");
+ fmu->getRealOutputDerivatives = (fGetRealOutputDerivatives) getAdr(&s, fmu, "fmiGetRealOutputDerivatives");
+ fmu->cancelStep = (fCancelStep) getAdr(&s, fmu, "fmiCancelStep");
+ fmu->doStep = (fDoStep) getAdr(&s, fmu, "fmiDoStep");
+ // SimulationX 3.4 and 3.5 do not yet export getStatus and getXStatus: do not count this as failure here
+ fmu->getStatus = (fGetStatus) getAdr(&s, fmu, "fmiGetStatus");
+ fmu->getRealStatus = (fGetRealStatus) getAdr(&s, fmu, "fmiGetRealStatus");
+ fmu->getIntegerStatus = (fGetIntegerStatus) getAdr(&s, fmu, "fmiGetIntegerStatus");
+ fmu->getBooleanStatus = (fGetBooleanStatus) getAdr(&s, fmu, "fmiGetBooleanStatus");
+ fmu->getStringStatus = (fGetStringStatus) getAdr(&s, fmu, "fmiGetStringStatus");
+
+#else // FMI for Model Exchange 1.0
+ fmu->getModelTypesPlatform = (fGetModelTypesPlatform) getAdr(&s, fmu, "fmiGetModelTypesPlatform");
+ fmu->instantiateModel = (fInstantiateModel) getAdr(&s, fmu, "fmiInstantiateModel");
+ fmu->freeModelInstance = (fFreeModelInstance) getAdr(&s, fmu, "fmiFreeModelInstance");
+ fmu->setTime = (fSetTime) getAdr(&s, fmu, "fmiSetTime");
+ fmu->setContinuousStates = (fSetContinuousStates)getAdr(&s, fmu, "fmiSetContinuousStates");
+ fmu->completedIntegratorStep = (fCompletedIntegratorStep)getAdr(&s, fmu, "fmiCompletedIntegratorStep");
+ fmu->initialize = (fInitialize) getAdr(&s, fmu, "fmiInitialize");
+ fmu->getDerivatives = (fGetDerivatives) getAdr(&s, fmu, "fmiGetDerivatives");
+ fmu->getEventIndicators = (fGetEventIndicators) getAdr(&s, fmu, "fmiGetEventIndicators");
+ fmu->eventUpdate = (fEventUpdate) getAdr(&s, fmu, "fmiEventUpdate");
+ fmu->getContinuousStates = (fGetContinuousStates)getAdr(&s, fmu, "fmiGetContinuousStates");
+ fmu->getNominalContinuousStates = (fGetNominalContinuousStates)getAdr(&s, fmu, "fmiGetNominalContinuousStates");
+ fmu->getStateValueReferences = (fGetStateValueReferences)getAdr(&s, fmu, "fmiGetStateValueReferences");
+ fmu->terminate = (fTerminate) getAdr(&s, fmu, "fmiTerminate");
+#endif
+ fmu->getVersion = (fGetVersion) getAdr(&s, fmu, "fmiGetVersion");
+ fmu->setDebugLogging = (fSetDebugLogging) getAdr(&s, fmu, "fmiSetDebugLogging");
+ fmu->setReal = (fSetReal) getAdr(&s, fmu, "fmiSetReal");
+ fmu->setInteger = (fSetInteger) getAdr(&s, fmu, "fmiSetInteger");
+ fmu->setBoolean = (fSetBoolean) getAdr(&s, fmu, "fmiSetBoolean");
+ fmu->setString = (fSetString) getAdr(&s, fmu, "fmiSetString");
+ fmu->getReal = (fGetReal) getAdr(&s, fmu, "fmiGetReal");
+ fmu->getInteger = (fGetInteger) getAdr(&s, fmu, "fmiGetInteger");
+ fmu->getBoolean = (fGetBoolean) getAdr(&s, fmu, "fmiGetBoolean");
+ fmu->getString = (fGetString) getAdr(&s, fmu, "fmiGetString");
+ return s;
+}
+
+static void printModelDescription(ModelDescription* md){
+ Element* e = (Element*)md;
+ int i;
+ printf("%s\n", elmNames[e->type]);
+ for (i=0; in; i+=2)
+ printf(" %s=%s\n", e->attributes[i], e->attributes[i+1]);
+#ifdef FMI_COSIMULATION
+ if (!md->cosimulation) {
+ printf("error: No Implementation element found in model description. This FMU is not for Co-Simulation.\n");
+ exit(EXIT_FAILURE);
+ }
+ e = md->cosimulation->capabilities;
+ printf("%s\n", elmNames[e->type]);
+ for (i=0; in; i+=2)
+ printf(" %s=%s\n", e->attributes[i], e->attributes[i+1]);
+#endif // FMI_COSIMULATION
+}
+
+void loadFMU(const char* fmuFileName) {
+ char* fmuPath;
+ char* tmpPath;
+ char* xmlPath;
+ char* dllPath;
+
+ // get absolute path to FMU, NULL if not found
+ fmuPath = getFmuPath(fmuFileName);
+ if (!fmuPath) exit(EXIT_FAILURE);
+
+ // unzip the FMU to the tmpPath directory
+ tmpPath = getTmpPath();
+ if (!unzip(fmuPath, tmpPath)) exit(EXIT_FAILURE);
+
+ // parse tmpPath\modelDescription.xml
+ xmlPath = calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1);
+ sprintf(xmlPath, "%s%s", tmpPath, XML_FILE);
+
+ // parse tmpPath\modelDescription.xml
+ xmlPath = calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1);
+ sprintf(xmlPath, "%s%s", tmpPath, XML_FILE);
+ // check FMI version of the FMU to match current simulator version
+ if (!checkFmiVersion(xmlPath)) {
+ free(xmlPath);
+ free(fmuPath);
+ free(tmpPath);
+ exit(EXIT_FAILURE);
+ }
+
+ fmu.modelDescription = parse(xmlPath);
+ free(xmlPath);
+ if (!fmu.modelDescription) exit(EXIT_FAILURE);
+ printModelDescription(fmu.modelDescription);
+
+ // load the FMU dll
+ dllPath = calloc(sizeof(char), strlen(tmpPath) + strlen(DLL_DIR)
+ + strlen( getModelIdentifier(fmu.modelDescription)) + strlen(DLL_SUFFIX) + 1);
+ sprintf(dllPath,"%s%s%s%s", tmpPath, DLL_DIR, getModelIdentifier(fmu.modelDescription), DLL_SUFFIX);
+ if (!loadDll(dllPath, &fmu)) {
+ free(dllPath);
+ free(fmuPath);
+ free(tmpPath);
+ exit(EXIT_FAILURE);
+ }
+ free(dllPath);
+ free(fmuPath);
+ free(tmpPath);
+}
+
+int checkFmiVersion(const char *xmlPath) {
+ char *xmlFmiVersion = extractVersion(xmlPath);
+ if (xmlFmiVersion == NULL) {
+ printf("The FMI version of the FMU could not be read: %s", xmlPath);
+ return 0;
+ } else if (strcmp(xmlFmiVersion, fmiVersion) == 0) {
+ free(xmlFmiVersion);
+ return 1;
+ }
+ printf("The FMU to simulate is FMI %s standard, but expected a FMI %s standard FMU", fmiVersion, xmlFmiVersion);
+ free(xmlFmiVersion);
+ return 0;
+}
+
+void deleteUnzippedFiles() {
+ char *fmuTempPath = getTmpPath();
+ char *cmd = (char *)calloc(15 + strlen(fmuTempPath), sizeof(char));
+#if WINDOWS
+ sprintf(cmd, "rmdir /S /Q %s", fmuTempPath);
+#else /* WINDOWS */
+ sprintf(cmd, "rm -rf %s", fmuTempPath);
+#endif /* WINDOWS */
+ system(cmd);
+ free(cmd);
+ free(fmuTempPath);
+}
+
+static void doubleToCommaString(char* buffer, double r){
+ char* comma;
+ sprintf(buffer, "%.16g", r);
+ comma = strchr(buffer, '.');
+ if (comma) *comma = ',';
+}
+
+// output time and all non-alias variables in CSV format
+// if separator is ',', columns are separated by ',' and '.' is used for floating-point numbers.
+// otherwise, the given separator (e.g. ';' or '\t') is to separate columns, and ',' is used
+// as decimal dot in floating-point numbers.
+void outputRow(FMU *fmu, fmiComponent c, double time, FILE* file, char separator, fmiBoolean header) {
+ int k;
+ fmiReal r;
+ fmiInteger i;
+ fmiBoolean b;
+ fmiString s;
+ fmiValueReference vr;
+ ScalarVariable** vars = fmu->modelDescription->modelVariables;
+ char buffer[32];
+
+ // print first column
+ if (header)
+ fprintf(file, "time");
+ else {
+ if (separator==',')
+ fprintf(file, "%.16g", time);
+ else {
+ // separator is e.g. ';' or '\t'
+ doubleToCommaString(buffer, time);
+ fprintf(file, "%s", buffer);
+ }
+ }
+
+ // print all other columns(void *)
+ for (k=0; vars[k]; k++) {
+ ScalarVariable* sv = vars[k];
+ if (getAlias(sv)!=enu_noAlias) continue;
+ if (header) {
+ // output names only
+ if (separator==',') {
+ // treat array element, e.g. print a[1, 2] as a[1.2]
+ const char* s = getName(sv);
+ fprintf(file, "%c", separator);
+ while (*s) {
+ if (*s!=' ') fprintf(file, "%c", *s==',' ? '.' : *s);
+ s++;
+ }
+ }
+ else
+ fprintf(file, "%c%s", separator, getName(sv));
+ }
+ else {
+ // output values
+ vr = getValueReference(sv);
+ switch (sv->typeSpec->type){
+ case elm_Real:
+ fmu->getReal(c, &vr, 1, &r);
+ if (separator==',')
+ fprintf(file, ",%.16g", r);
+ else {
+ // separator is e.g. ';' or '\t'
+ doubleToCommaString(buffer, r);
+ fprintf(file, "%c%s", separator, buffer);
+ }
+ break;
+ case elm_Integer:
+ case elm_Enumeration:
+ fmu->getInteger(c, &vr, 1, &i);
+ fprintf(file, "%c%d", separator, i);
+ break;
+ case elm_Boolean:
+ fmu->getBoolean(c, &vr, 1, &b);
+ fprintf(file, "%c%d", separator, b);
+ break;
+ case elm_String:
+ fmu->getString(c, &vr, 1, &s);
+ fprintf(file, "%c%s", separator, s);
+ break;
+ default:
+ fprintf(file, "%cNoValueForType=%d", separator,sv->typeSpec->type);
+ }
+ }
+ } // for
+
+ // terminate this row
+ fprintf(file, "\n");
+}
+
+static const char* fmiStatusToString(fmiStatus status){
+ switch (status){
+ case fmiOK: return "ok";
+ case fmiWarning: return "warning";
+ case fmiDiscard: return "discard";
+ case fmiError: return "error";
+ case fmiFatal: return "fatal";
+#ifdef FMI_COSIMULATION
+ case fmiPending: return "fmiPending";
+#endif
+ default: return "?";
+ }
+}
+
+// search a fmu for the given variable
+// return NULL if not found or vr = fmiUndefinedValueReference
+static ScalarVariable* getSV(FMU* fmu, char type, fmiValueReference vr) {
+ int i;
+ Elm tp;
+ ScalarVariable** vars = fmu->modelDescription->modelVariables;
+ if (vr==fmiUndefinedValueReference) return NULL;
+ switch (type) {
+ case 'r': tp = elm_Real; break;
+ case 'i': tp = elm_Integer; break;
+ case 'b': tp = elm_Boolean; break;
+ case 's': tp = elm_String; break;
+ default: tp = elm_BAD_DEFINED; break;
+ }
+ for (i=0; vars[i]; i++) {
+ ScalarVariable* sv = vars[i];
+ if (vr==getValueReference(sv) && tp==sv->typeSpec->type)
+ return sv;
+ }
+ return NULL;
+}
+
+// replace e.g. #r1365# by variable name and ## by # in message
+// copies the result to buffer
+static void replaceRefsInMessage(const char* msg, char* buffer, int nBuffer, FMU* fmu){
+ int i=0; // position in msg
+ int k=0; // position in buffer
+ int n;
+ char c = msg[i];
+ while (c!='\0' && k < nBuffer) {
+ if (c!='#') {
+ buffer[k++]=c;
+ i++;
+ c = msg[i];
+ } else if (strlen(msg + i + 1) >= 3
+ && (strncmp(msg + i + 1, "IND", 3) == 0 || strncmp(msg + i + 1, "INF", 3) == 0)) {
+ // 1.#IND, 1.#INF
+ buffer[k++]=c;
+ i++;
+ c = msg[i];
+ } else {
+ char* end = strchr(msg+i+1, '#');
+ if (!end) {
+ printf("unmatched '#' in '%s'\n", msg);
+ buffer[k++]='#';
+ break;
+ }
+ n = end - (msg+i);
+ if (n==1) {
+ // ## detected, output #
+ buffer[k++]='#';
+ i += 2;
+ c = msg[i];
+ }
+ else {
+ char type = msg[i+1]; // one of ribs
+ fmiValueReference vr;
+ int nvr = sscanf(msg+i+2, "%u", &vr);
+ if (nvr==1) {
+ // vr of type detected, e.g. #r12#
+ ScalarVariable* sv = getSV(fmu, type, vr);
+ const char* name = sv ? getName(sv) : "?";
+ sprintf(buffer+k, "%s", name);
+ k += strlen(name);
+ i += (n+1);
+ c = msg[i];
+ }
+ else {
+ // could not parse the number
+ printf("illegal value reference at position %d in '%s'\n", i+2, msg);
+ buffer[k++]='#';
+ break;
+ }
+ }
+ }
+ } // while
+ buffer[k] = '\0';
+}
+
+#define MAX_MSG_SIZE 1000
+void fmuLogger(fmiComponent c, fmiString instanceName, fmiStatus status,
+ fmiString category, fmiString message, ...) {
+ char msg[MAX_MSG_SIZE];
+ char* copy;
+ va_list argp;
+
+ // replace C format strings
+ va_start(argp, message);
+ vsprintf(msg, message, argp);
+ va_end(argp);
+
+ // replace e.g. ## and #r12#
+ copy = strdup(msg);
+ replaceRefsInMessage(copy, msg, MAX_MSG_SIZE, &fmu);
+ free(copy);
+
+ // print the final message
+ if (!instanceName) instanceName = "?";
+ if (!category) category = "?";
+ printf("%s %s (%s): %s\n", fmiStatusToString(status), instanceName, category, msg);
+}
+
+int error(const char* message){
+ printf("%s\n", message);
+ return 0;
+}
+
+void parseArguments(int argc, char *argv[], const char** fmuFileName, double* tEnd, double* h, int* loggingOn, char* csv_separator) {
+ // parse command line arguments
+ if (argc>1) {
+ *fmuFileName = argv[1];
+ }
+ else {
+ printf("error: no fmu file\n");
+ printHelp(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ if (argc>2) {
+ if (sscanf(argv[2],"%lf", tEnd) != 1) {
+ printf("error: The given end time (%s) is not a number\n", argv[2]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (argc>3) {
+ if (sscanf(argv[3],"%lf", h) != 1) {
+ printf("error: The given stepsize (%s) is not a number\n", argv[3]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (argc>4) {
+ if (sscanf(argv[4],"%d", loggingOn) != 1 || *loggingOn<0 || *loggingOn>1) {
+ printf("error: The given logging flag (%s) is not boolean\n", argv[4]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (argc>5) {
+ if (strlen(argv[5]) != 1) {
+ printf("error: The given CSV separator char (%s) is not valid\n", argv[5]);
+ exit(EXIT_FAILURE);
+ }
+ switch (argv[5][0]) {
+ case 'c': *csv_separator = ','; break; // comma
+ case 's': *csv_separator = ';'; break; // semicolon
+ default: *csv_separator = argv[5][0]; break; // any other char
+ }
+ }
+ if (argc>6) {
+ printf("warning: Ignoring %d additional arguments: %s ...\n", argc-6, argv[6]);
+ printHelp(argv[0]);
+ }
+}
+
+void printHelp(const char* fmusim) {
+ printf("command syntax: %s \n", fmusim);
+ printf(" .... path to FMU, relative to current dir or absolute, required\n");
+ printf(" ......... end time of simulation, optional, defaults to 1.0 sec\n");
+ printf(" ............ step size of simulation, optional, defaults to 0.1 sec\n");
+ printf(" .... 1 to activate logging, optional, defaults to 0\n");
+ printf(" . separator in csv file, optional, c for ',', s for';', defaults to c\n");
+}
diff --git a/fmu10/src/shared/sim_support.h b/fmu10/src/shared/sim_support.h
new file mode 100644
index 0000000..8eb0e98
--- /dev/null
+++ b/fmu10/src/shared/sim_support.h
@@ -0,0 +1,69 @@
+/* -------------------------------------------------------------------------
+ * sim_support.h
+ * Functions used by the FMU simulation fmusim_me and fmusim_cs.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#if WINDOWS
+// Used 7z options, version 4.57:
+// -x Extracts files from an archive with their full paths in the current dir, or in an output dir if specified
+// -aoa Overwrite All existing files without prompt
+// -o Specifies a destination directory where files are to be extracted
+#define UNZIP_CMD "7z x -aoa -o"
+#else /* WINDOWS */
+// -o Overwrite existing files without prompting
+// -d The directory in which to write files.
+#define UNZIP_CMD "unzip -o -d "
+#endif /* WINDOWS */
+
+#define XML_FILE "modelDescription.xml"
+#define RESULT_FILE "result.csv"
+#define BUFSIZE 4096
+
+#if WINDOWS
+#ifdef _WIN64
+#define DLL_DIR "binaries\\win64\\"
+#else /* _WIN64 */
+#define DLL_DIR "binaries\\win32\\"
+#endif /* _WIN64 */
+
+#define DLL_SUFFIX ".dll"
+
+#else /* WINDOWS */
+#if __APPLE__
+
+// Use these for platforms other than OpenModelica
+#define DLL_DIR "binaries/darwin64/"
+#define DLL_SUFFIX ".dylib"
+
+#else /* __APPLE__ */
+// Linux
+#ifdef __x86_64
+#define DLL_DIR "binaries/linux64/"
+#else
+// It may be necessary to compile with -m32, see ../Makefile
+#define DLL_DIR "binaries/linux32/"
+#endif /*__x86_64*/
+#define DLL_SUFFIX ".so"
+
+#endif /* __APPLE__ */
+#endif /* WINDOWS */
+
+// return codes of the 7z command line tool
+#define SEVEN_ZIP_NO_ERROR 0 // success
+#define SEVEN_ZIP_WARNING 1 // e.g., one or more files were locked during zip
+#define SEVEN_ZIP_ERROR 2
+#define SEVEN_ZIP_COMMAND_LINE_ERROR 7
+#define SEVEN_ZIP_OUT_OF_MEMORY 8
+#define SEVEN_ZIP_STOPPED_BY_USER 255
+
+void fmuLogger(fmiComponent c, fmiString instanceName, fmiStatus status, fmiString category, fmiString message, ...);
+int unzip(const char *zipPath, const char *outPath);
+void parseArguments(int argc, char *argv[], const char** fmuFileName, double* tEnd, double* h, int* loggingOn, char* csv_separator);
+void loadFMU(const char* fmuFileName);
+int checkFmiVersion(const char *xmlPath);
+void deleteUnzippedFiles();
+void outputRow(FMU *fmu, fmiComponent c, double time, FILE* file, char separator, fmiBoolean header);
+int error(const char* message);
+void printHelp(const char* fmusim);
+char *getTempFmuLocation(); // caller has to free the result
diff --git a/fmu10/src/shared/stack.c b/fmu10/src/shared/stack.c
new file mode 100644
index 0000000..0807df2
--- /dev/null
+++ b/fmu10/src/shared/stack.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* -------------------------------------------------------------------------
+ * stack.c
+ * A stack of pointers.
+ * Author: Jakob Mauss
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include "stack.h"
+
+Stack* stackNew(int initialSize, int inc){
+ Stack* s = (Stack*)malloc(sizeof(Stack));
+ s->stack = NULL;
+ s->stackSize = 0;
+ s->stackPos = -1;
+ s->initialSize = initialSize;
+ s->inc = inc;
+ return s;
+}
+
+int stackIsEmpty(Stack* s) {
+ return s->stackPos == -1;
+}
+
+// add an element to stack and grow stack if required
+// returns 1 to indicate success and 0 for error
+int stackPush(Stack* s, void* e) {
+ s->stackPos++;
+ if (s->stackPos==s->stackSize){
+ s->stackSize += (s->stack ? s->inc: s->initialSize);
+ s->stack = (void**) realloc(s->stack, s->stackSize * sizeof(void*));
+ if (!s->stack) return 0; // error;
+ }
+ s->stack[s->stackPos] = e;
+ return 1; // success
+}
+
+// return top element (possibly NULL), if stack not empty
+// runtime error if stack is empty
+void* stackPeek(Stack* s){
+ assert(!stackIsEmpty(s));
+ return s->stack[s->stackPos];
+}
+
+// remove top element (possibly NULL) from stack and return it
+// runtime error if stack is empty
+void* stackPop(Stack* s){
+ assert(!stackIsEmpty(s));
+ return s->stack[s->stackPos--];
+}
+
+// return the last n elements as null terminated array,
+// or NULL if memory allocation fails
+void** stackLastPopedAsArray0(Stack* s, int n){
+ int i;
+ void** array = (void**)malloc((n + 1)*sizeof(void*));
+ if (! array) return NULL; // failure
+ for (i=0; istack[i+ s->stackPos + 1];
+ }
+ array[n]=NULL; // terminating NULL
+ return array;
+}
+
+// return stack as possibly empty array, or NULL if memory allocation fails
+// On successful return, the stack is empty.
+void** stackPopAllAsArray(Stack* s, int *size) {
+ int i;
+ void** array = (void**)malloc((s->stackPos + 1)*sizeof(void*));
+ if (! array) return NULL; // failure
+ *size = s->stackPos + 1;
+ for (i=0; i<*size; i++)
+ array[i] = s->stack[i];
+ s->stackPos = -1;
+ return array;
+}
+
+// release the given stack
+void stackFree(Stack* s){
+ if (s->stack) free(s->stack);
+ free(s);
+}
+
+
diff --git a/fmu10/src/shared/stack.h b/fmu10/src/shared/stack.h
new file mode 100644
index 0000000..d0ac639
--- /dev/null
+++ b/fmu10/src/shared/stack.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* -------------------------------------------------------------------------
+ * stack.c
+ * A stack of pointers.
+ * Author: Jakob Mauss, January 2010.
+ * -------------------------------------------------------------------------*/
+
+#ifndef STACK_H
+#define STACK_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ void** stack;
+ int stackSize; // allocated size of stack
+ int stackPos; // array index of top element, -1 if stack is empty.
+ int initialSize; // how many element to allocate initially
+ int inc; // how many elements to allocate when stack gets full
+} Stack;
+
+Stack* stackNew(int initialSize, int inc);
+int stackIsEmpty(Stack* s);
+int stackPush(Stack* s, void* e);
+void* stackPeek(Stack* s);
+void* stackPop(Stack* s);
+void** stackPopAllAsArray(Stack* s, int *size);
+void** stackLastPopedAsArray0(Stack* s, int n);
+void stackFree(Stack* s);
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
+#endif // STACK_H
\ No newline at end of file
diff --git a/fmu10/src/shared/x64/libexpatMT.lib b/fmu10/src/shared/x64/libexpatMT.lib
new file mode 100644
index 0000000..271d2bb
Binary files /dev/null and b/fmu10/src/shared/x64/libexpatMT.lib differ
diff --git a/fmu10/src/shared/x64/libxml2.lib b/fmu10/src/shared/x64/libxml2.lib
new file mode 100644
index 0000000..93e6f5e
Binary files /dev/null and b/fmu10/src/shared/x64/libxml2.lib differ
diff --git a/fmu10/src/shared/xmlVersionParser.c b/fmu10/src/shared/xmlVersionParser.c
new file mode 100644
index 0000000..a025cea
--- /dev/null
+++ b/fmu10/src/shared/xmlVersionParser.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* ---------------------------------------------------------------------------*
+ * xmlVersionParser.c
+ *
+ * Author: Adrian Tirea
+ * ---------------------------------------------------------------------------*/
+
+#ifdef STANDALONE_XML_PARSER
+#include
+#define logThis(n, ...) printf(__VA_ARGS__); printf("\n")
+#define checkStrdup(str) strdup(str)
+#define BOOL int
+#define TRUE 1
+#define FALSE 0
+#else
+#include "GlobalIncludes.h"
+#include "logging.h" // logThis
+#include "minutil.h" // checkStrdup
+#endif // STANDALONE_XML_PARSER
+
+#include
+#include "xmlVersionParser.h"
+
+// Element and attribute that identify the fmiVersion.
+#define ELM_fmiModelDescription_NAME "fmiModelDescription"
+#define ATT_fmiVersion_NAME "fmiVersion"
+
+static BOOL readNextInXml(xmlTextReaderPtr xmlReader) {
+ int ret;
+ do {
+ ret = xmlTextReaderRead(xmlReader);
+ } while (ret == 1 && xmlTextReaderNodeType(xmlReader) == XML_READER_TYPE_COMMENT);
+
+ if (ret != 1) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// The receiver must free the return.
+static char *extractFmiVersionAttribute(xmlTextReaderPtr xmlReader) {
+ char *value = (char *)xmlTextReaderGetAttribute(xmlReader, ATT_fmiVersion_NAME);
+ char *result = value ? (char *)checkStrdup(value) : NULL;
+ xmlFree(value);
+ return result;
+}
+
+// The receiver must free the return.
+static char *streamFile(const char *xmlPath) {
+ xmlTextReaderPtr xmlReader;
+ char *fmiVersion = NULL;
+ xmlReader = xmlReaderForFile(xmlPath, NULL, 0);
+ if (xmlReader != NULL) {
+ if (readNextInXml(xmlReader)) {
+ // I expect that first element is fmiModelDescription.
+ if (0 != strcmp((char *)xmlTextReaderConstLocalName(xmlReader), ELM_fmiModelDescription_NAME)) {
+ logThis(ERROR_ERROR, "Expected '%s' element. Found instead: '%s'",
+ ELM_fmiModelDescription_NAME, xmlTextReaderConstLocalName(xmlReader));
+ } else {
+ fmiVersion = extractFmiVersionAttribute(xmlReader);
+ }
+ } else {
+ logThis(ERROR_ERROR, "Syntax error parsing xml file '%s'", xmlPath);
+ }
+ xmlFreeTextReader(xmlReader);
+ } else {
+ logThis(ERROR_ERROR, "Cannot open file '%s'", xmlPath);
+ }
+ return fmiVersion;
+}
+
+// Returns NULL to indicate failure
+// Otherwise, return the version of this FMU.
+// The receiver must free the returned string.
+char *extractVersion(const char *xmlDescriptionPath) {
+ char *fmiVersion;
+
+ fmiVersion = streamFile(xmlDescriptionPath);
+ // do NOT call here xmlCleanupParser() because we don't know all other modules linked into this DLL that
+ // might be using libxml2. For memory leak detections call xmlCleanupParser() just before exit()
+ //xmlCleanupParser();
+ return fmiVersion;
+}
diff --git a/fmu10/src/shared/xmlVersionParser.h b/fmu10/src/shared/xmlVersionParser.h
new file mode 100644
index 0000000..ccf4905
--- /dev/null
+++ b/fmu10/src/shared/xmlVersionParser.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* ---------------------------------------------------------------------------*
+ * xmlVersionParser.h
+ * Parse a xml model description of a FMI 1.0 or FMI 2.0 model to extract its
+ * fmi version.
+ *
+ * Author: Adrian Tirea
+ * ---------------------------------------------------------------------------*/
+
+#ifndef xmlVersionParser_h
+#define xmlVersionParser_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MSC_VER
+#pragma comment(lib, "libxml2.lib")
+#pragma comment(lib, "wsock32.lib")
+#endif /* _MSC_VER */
+
+char *extractVersion(const char *xmlDescriptionPath);
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
+#endif // xmlVersionParser_h
diff --git a/fmu10/src/shared/xml_parser.c b/fmu10/src/shared/xml_parser.c
new file mode 100644
index 0000000..3079a4c
--- /dev/null
+++ b/fmu10/src/shared/xml_parser.c
@@ -0,0 +1,960 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* -------------------------------------------------------------------------
+ * xml_Parser.c
+ * A parser for file modelVariables.xml of an FMU.
+ * The parser creates an AST (abstract syntax tree) for a given XML file.
+ * The root node of the AST is of type ModelDescription.
+ * Validation already performed by this parser
+ * - check for match of open/close elements (performed by Expat)
+ * - check element, attribute and enum value names, all case sensitive
+ * - check for each element that is has the expected parent element
+ * - check for correct sequence of elements
+ * - check for each attribute value that it is of the expected type
+ * - check that all declaredType values reference an existing Type
+ * Validation to be performed by this parser
+ * - check that required attributes are present
+ * - check that dependencies are only declared for outputs and
+ * refer only to inputs
+ * Author: Jakob Mauss, January 2010.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include
+
+#ifdef STANDALONE_XML_PARSER
+#define logThis(n, ...) printf(__VA_ARGS__);printf("\n")
+#else
+#include "GlobalIncludes.h"
+#include "logging.h" // logThis
+#endif // STANDALONE_XML_PARSER
+
+#include "xml_parser.h"
+
+const char *elmNames[SIZEOF_ELM] = {
+ "fmiModelDescription","UnitDefinitions","BaseUnit","DisplayUnitDefinition","TypeDefinitions",
+ "Type","RealType","IntegerType","BooleanType","StringType","EnumerationType","Item",
+ "DefaultExperiment","VendorAnnotations","Tool","Annotation", "ModelVariables","ScalarVariable",
+ "DirectDependency", "Name", "Real","Integer","Boolean","String","Enumeration",
+ "Implementation","CoSimulation_StandAlone","CoSimulation_Tool","Model","File","Capabilities"
+};
+
+const char *attNames[SIZEOF_ATT] = {
+ "fmiVersion","displayUnit","gain","offset","unit","name","description","quantity", "relativeQuantity",
+ "min","max","nominal","declaredType","start","fixed","startTime","stopTime","tolerance","value",
+ "valueReference","variability","causality","alias", "modelName","modelIdentifier","guid","author",
+ "version","generationTool","generationDateAndTime","variableNamingConvention","numberOfContinuousStates",
+ "numberOfEventIndicators","input",
+ "canHandleVariableCommunicationStepSize","canHandleEvents","canRejectSteps","canInterpolateInputs",
+ "maxOutputDerivativeOrder","canRunAsynchronuously","canSignalEvents","canBeInstantiatedOnlyOncePerProcess",
+ "canNotUseMemoryManagementFunctions","file","entryPoint","manualStart","type"
+};
+
+const char *enuNames[SIZEOF_ENU] = {
+ "flat","structured","constant","parameter","discrete","continuous",
+ "input","output", "internal","none","noAlias","alias","negatedAlias"
+};
+
+#define XMLBUFSIZE 1024
+char text[XMLBUFSIZE]; // XML file is parsed in chunks of length XMLBUFZIZE
+XML_Parser parser = NULL; // non-NULL during parsing
+Stack* stack = NULL; // the parser stack
+char* data = NULL; // buffer that holds element content, see handleData
+int skipData=0; // 1 to ignore element content, 0 when recording content
+
+// -------------------------------------------------------------------------
+// Low-level functions for inspecting the model description
+
+const char* getString(void* element, Att a){
+ Element* e = (Element*)element;
+ const char** attr = e->attributes;
+ int i;
+ for (i=0; in; i+=2)
+ if (attr[i]==attNames[a]) return attr[i+1];
+ return NULL;
+}
+
+double getDouble(void* element, Att a, ValueStatus* vs){
+ double d = 0;
+ const char* value = getString(element, a);
+ if (!value) { *vs=valueMissing; return d; }
+ *vs = (1==sscanf(value, "%lf", &d)) ? valueDefined : valueIllegal;
+ return d;
+}
+
+// getInt() is also used to retrieve Enumeration values from XML,
+// e.g. the start value for a variable of user-defined enumeration type.
+int getInt(void* element, Att a, ValueStatus* vs){
+ int n = 0;
+ const char* value = getString(element, a);
+ if (!value) { *vs=valueMissing; return n; }
+ *vs = (1==sscanf(value, "%d", &n)) ? valueDefined : valueIllegal;
+ return n;
+}
+
+unsigned int getUInt(void* element, Att a, ValueStatus* vs){
+ unsigned int u = -1;
+ const char* value = getString(element, a);
+ if (!value) { *vs=valueMissing; return u; }
+ *vs = (1==sscanf(value, "%u", &u)) ? valueDefined : valueIllegal;
+ return u;
+}
+
+char getBoolean(void* element, Att a, ValueStatus* vs){
+ const char* value = getString(element, a);
+ if (!value) { *vs=valueMissing; return 0; };
+ *vs = valueDefined;
+ if (!strcmp(value, "true")) return 1;
+ if (!strcmp(value, "false")) return 0;
+ *vs = valueIllegal;
+ return 0;
+}
+
+static Enu checkEnumValue(const char* enu);
+
+// Retrieve the value of the given built-in enum attribute.
+// If the value is missing, this is marked in the ValueStatus
+// and the corresponding default is returned.
+// Returns enu_BAD_DEFINED or a globally unique id for the value such that
+// enuNames[id] is the string representation of the enum value.
+Enu getEnumValue(void* element, Att a, ValueStatus* vs) {
+ const char* value = getString(element, a);
+ Enu id;
+ *vs = valueDefined;
+ if (!value) {
+ *vs = valueMissing;
+ switch (a) {
+ case att_variableNamingConvention: return enu_flat;
+ case att_variability: return enu_continuous;
+ case att_causality: return enu_internal;
+ case att_alias: return enu_noAlias;
+ default: return enu_BAD_DEFINED;
+ }
+ }
+ id = checkEnumValue(value);
+ if (id == enu_BAD_DEFINED) *vs = valueIllegal;
+ return id;
+}
+
+// -------------------------------------------------------------------------
+// Convenience methods for accessing the model description.
+// Use is only safe after the ast has been successfully validated.
+
+const char* getModelIdentifier(ModelDescription* md) {
+ const char* modelId = getString(md, att_modelIdentifier);
+ assert(modelId); // this is a required attribute
+ return modelId;
+}
+
+int getNumberOfStates(ModelDescription* md) {
+ ValueStatus vs;
+ int n = getUInt(md, att_numberOfContinuousStates, &vs);
+ assert(vs==valueDefined); // this is a required attribute
+ return n;
+}
+
+int getNumberOfEventIndicators(ModelDescription* md) {
+ ValueStatus vs;
+ int n = getInt(md, att_numberOfEventIndicators, &vs);
+ assert(vs==valueDefined); // this is a required attribute
+ return n;
+}
+
+// name is a required attribute of ScalarVariable, Type, Item, Annotation, and Tool
+const char* getName(void* element) {
+ const char* name = getString(element, att_name);
+ assert(name); // this is a required attribute
+ return name;
+}
+
+// returns one of: input, output, internal, none
+// if value is missing, the default internal is returned
+Enu getCausality(void* scalarVariable) {
+ ValueStatus vs;
+ return getEnumValue(scalarVariable, att_causality, &vs);
+}
+
+// returns one of constant, parameter, discrete, continuous
+// if value is missing, the default continuous is returned
+Enu getVariability(void* scalarVariable) {
+ ValueStatus vs;
+ return getEnumValue(scalarVariable, att_variability, &vs);
+}
+
+// returns one of noAlias, alias, negatedAlias
+// if value is missing, the default noAlias is returned
+Enu getAlias(void* scalarVariable) {
+ ValueStatus vs;
+ return getEnumValue(scalarVariable, att_alias, &vs);
+}
+
+// the vr is unique only for one of the 4 base data types r,i,b,s and
+// may also be fmiUndefinedValueReference = 4294967295 = 0xFFFFFFFF
+// here, i means integer or enumeration
+fmiValueReference getValueReference(void* scalarVariable) {
+ ValueStatus vs;
+ fmiValueReference vr = getUInt(scalarVariable, att_valueReference, &vs);
+ assert(((Element*)scalarVariable)->type == elm_ScalarVariable);
+ assert(vs==valueDefined); // this is a required attribute
+ return vr;
+}
+
+// the name is unique within a fmu
+ScalarVariable* getVariableByName(ModelDescription* md, const char* name) {
+ int i;
+ if (md->modelVariables) {
+ for (i=0; md->modelVariables[i]; i++){
+ ScalarVariable* sv = (ScalarVariable*)md->modelVariables[i];
+ if (!strcmp(getName(sv), name)) return sv;
+ }
+ }
+ return NULL;
+}
+
+// Enumeration and Integer have the same base type while
+// Real, String, Boolean define own base types.
+int sameBaseType(Elm t1, Elm t2){
+ return t1==t2 ||
+ t1==elm_Enumeration && t2==elm_Integer ||
+ t2==elm_Enumeration && t1==elm_Integer;
+}
+
+// returns NULL if variable not found or vr==fmiUndefinedValueReference
+// problem: vr/type in not a unique key, may return alias
+ScalarVariable* getVariable(ModelDescription* md, fmiValueReference vr, Elm type){
+ int i;
+ if (md->modelVariables && vr!=fmiUndefinedValueReference)
+ for (i=0; md->modelVariables[i]; i++){
+ ScalarVariable* sv = (ScalarVariable*)md->modelVariables[i];
+ if (sameBaseType(type, sv->typeSpec->type) && getValueReference(sv) == vr)
+ return sv;
+ }
+ return NULL;
+}
+
+// returns NULL if variable not found or vr==fmiUndefinedValueReference
+// problem: vr/type in not a unique key, return just the non alias variable
+ScalarVariable* getNonAliasVariable(ModelDescription* md, fmiValueReference vr, Elm type){
+ int i;
+ if (md->modelVariables && vr!=fmiUndefinedValueReference)
+ for (i=0; md->modelVariables[i]; i++){
+ ScalarVariable* sv = (ScalarVariable*)md->modelVariables[i];
+ if (sameBaseType(type, sv->typeSpec->type) && getValueReference(sv) == vr && getAlias(sv) == enu_noAlias)
+ return sv;
+ }
+ return NULL;
+}
+
+Type* getDeclaredType(ModelDescription* md, const char* declaredType){
+ int i;
+ if (declaredType && md->typeDefinitions)
+ for (i=0; md->typeDefinitions[i]; i++){
+ Type* tp = (Type*)md->typeDefinitions[i];
+ if (!strcmp(declaredType, getName(tp))) return tp;
+ }
+ return NULL;
+}
+
+// Get attribute value from variable or from declared type, or NULL.
+const char* getString2(ModelDescription* md, void* tp, Att a) {
+ Type* type;
+ const char* value = getString(tp, a);
+ if (value) return value; // found
+ // search declared type, if any
+ type = getDeclaredType(md, getString(tp, att_declaredType));
+ return type ? getString(type->typeSpec, a) : NULL;
+}
+
+// Get description from variable or from declared type, or NULL.
+const char * getDescription(ModelDescription* md, ScalarVariable* sv){
+ const char* value = getString(sv, att_description);
+ Type* type;
+ if (value) return value; // found
+ // search declared type, if any
+ type = getDeclaredType(md, getString(sv->typeSpec, att_declaredType));
+ return type ? getString(type, att_description) : NULL;
+}
+
+// Get attribute value from scalar variable given by vr and type,
+// incl. default value provided by declared type, if any.
+const char *getVariableAttributeString(ModelDescription* md,
+ fmiValueReference vr, Elm type, Att a) {
+ const char* value;
+ Type* tp;
+ ScalarVariable* sv = getVariable(md, vr, type);
+ if (!sv) return NULL;
+ value = getString(sv->typeSpec, a);
+ if (value) return value; // found
+ // search declared type, if any
+ tp = getDeclaredType(md, getString(sv->typeSpec, att_declaredType));
+ return tp ? getString(tp->typeSpec, a) : NULL;
+}
+
+// Get attribute value from scalar variable given by vr and type,
+// incl. default value provided by declared type, if any.
+double getVariableAttributeDouble(ModelDescription* md,
+ fmiValueReference vr, Elm type, Att a, ValueStatus* vs){
+ double d = 0;
+ const char* value = getVariableAttributeString(md, vr, type, a);
+ if (!value) { *vs = valueMissing; return d; }
+ *vs = (1==sscanf(value, "%lf", &d)) ? valueDefined : valueIllegal;
+ return d;
+}
+
+// Get nominal value from real variable or its declared type.
+// Return 1, if no nominal value is defined.
+double getNominal(ModelDescription* md, fmiValueReference vr){
+ ValueStatus vs;
+ double nominal = getVariableAttributeDouble(md, vr, elm_Real, att_nominal, &vs);
+ return vs==valueDefined ? nominal : 1.0;
+}
+
+// -------------------------------------------------------------------------
+// Various checks that log an error and stop the parser
+
+// Returns 0 to indicate error
+static int checkPointer(const void* ptr){
+ if (! ptr) {
+ logThis(ERROR_FATAL, "Out of memory");
+ if (parser) XML_StopParser(parser, XML_FALSE);
+ return 0; // error
+ }
+ return 1; // success
+}
+
+static int checkName(const char* name, const char* kind, const char* array[], int n){
+ int i;
+ for (i=0; itype == e) return 1; // success
+ logFatalTypeError(elmNames[e], elm->type);
+ return 0; // error
+}
+
+// Returns 0 to indicate error
+// Verify that the next stack element exists and is of the given type
+// If e==elm_BAD_DEFINED, the type check is omitted
+static int checkPeek(Elm e) {
+ if (stackIsEmpty(stack)) {
+ logThis(ERROR_FATAL, "Illegal document structure, expected %s",
+ e==elm_BAD_DEFINED ? "xml element" : elmNames[e]);
+ XML_StopParser(parser, XML_FALSE);
+ return 0; // error
+ }
+ return e==elm_BAD_DEFINED ? 1 : checkElementType(stackPeek(stack), e);
+}
+
+// Returns NULL to indicate error
+// Get the next stack element, it is of the given type.
+// If e==elm_BAD_DEFINED, the type check is omitted
+static void* checkPop(Elm e){
+ return checkPeek(e) ? stackPop(stack) : NULL;
+}
+
+// -------------------------------------------------------------------------
+// Helper
+
+AstNodeType getAstNodeType(Elm e){
+ switch (e) {
+ case elm_fmiModelDescription:
+ return astModelDescription;
+ case elm_Type:
+ return astType;
+ case elm_ScalarVariable:
+ return astScalarVariable;
+ case elm_CoSimulation_StandAlone:
+ case elm_CoSimulation_Tool:
+ return astCoSimulation;
+ case elm_BaseUnit:
+ case elm_EnumerationType:
+ case elm_Tool:
+ case elm_UnitDefinitions:
+ case elm_TypeDefinitions:
+ case elm_VendorAnnotations:
+ case elm_ModelVariables:
+ case elm_DirectDependency:
+ case elm_Model:
+ return astListElement;
+ default:
+ return astElement;
+ }
+}
+
+// Returns 0 to indicate error
+// Copies the attr array and all values.
+// Replaces all attribute names by constant literal strings.
+// Converts the null-terminated array into an array of known size n.
+int addAttributes(Element* el, const char** attr) {
+ int n;
+ Att a;
+ const char** att = NULL;
+ for (n=0; attr[n]; n+=2);
+ if (n>0) {
+ att = (const char **)calloc(n, sizeof(char*));
+ if (!checkPointer(att)) return 0;
+ }
+ for (n=0; attr[n]; n+=2) {
+ char* value = strdup(attr[n+1]);
+ if (!checkPointer(value)) {
+ free((void *)att);
+ return 0;
+ }
+ a = checkAttribute(attr[n]);
+ if (a == att_BAD_DEFINED) {
+ free(value);
+ free((void *)att);
+ return 0; // illegal attribute error
+ }
+ att[n ] = attNames[a]; // no heap memory
+ att[n+1] = value; // heap memory
+ }
+ el->attributes = att; // NULL if n=0
+ el->n = n;
+ return 1; // success
+}
+
+// Returns NULL to indicate error
+Element* newElement(Elm type, int size, const char** attr) {
+ Element* e = (Element*)calloc(1, size);
+ if (!checkPointer(e)) return NULL;
+ e->type = type;
+ e->attributes = NULL;
+ e->n=0;
+ if (!addAttributes(e, attr)) {
+ free(e);
+ return NULL;
+ }
+ return e;
+}
+
+// -------------------------------------------------------------------------
+// callback functions called by the XML parser
+
+// Create and push a new element node
+static void XMLCALL startElement(void *context, const char *elm, const char **attr) {
+ Elm el;
+ void* e;
+ int size;
+ //logThis(ERROR_INFO, "start %s", elm);
+ el = checkElement(elm);
+ if (el==elm_BAD_DEFINED) return; // error
+ skipData = (el != elm_Name); // skip element content for all elements but Name
+ switch(getAstNodeType(el)){
+ case astElement: size = sizeof(Element); break;
+ case astListElement: size = sizeof(ListElement); break;
+ case astType: size = sizeof(Type); break;
+ case astScalarVariable: size = sizeof(ScalarVariable); break;
+ case astCoSimulation: size = sizeof(CoSimulation); break;
+ case astModelDescription: size = sizeof(ModelDescription); break;
+ default: assert(0);
+ }
+ e = newElement(el, size, attr);
+ if (checkPointer(e)) stackPush(stack, e);
+}
+
+// Pop all elements of the given type from stack and
+// add it to the ListElement that follows.
+// The ListElement remains on the stack.
+static void popList(Elm e) {
+ int n = 0;
+ Element** array;
+ Element* elm = (Element *)stackPop(stack);
+ while (elm->type == e) {
+ elm = (Element *)stackPop(stack);
+ n++;
+ }
+ stackPush(stack, elm); // push ListElement back to stack
+ array = (Element**)stackLastPopedAsArray0(stack, n); // NULL terminated list
+ if (getAstNodeType(elm->type)!=astListElement) {
+ free(array);
+ return; // failure
+ }
+ ((ListElement*)elm)->list = array;
+ return; // success only if list!=NULL
+}
+
+// Pop the children from the stack and
+// check for correct type and sequence of children
+static void XMLCALL endElement(void *context, const char *elm) {
+ Elm el;
+ //logThis(ERROR_INFO, " end %s", elm);
+ el = checkElement(elm);
+ switch(el) {
+ case elm_fmiModelDescription:
+ {
+ ModelDescription* md;
+ ListElement** ud = NULL; // NULL or list of BaseUnits
+ Type** td = NULL; // NULL or list of Types
+ Element* de = NULL; // NULL or DefaultExperiment
+ ListElement** va = NULL; // NULL or list of Tools
+ ScalarVariable** mv = NULL; // NULL or list of ScalarVariable
+ CoSimulation *cs = NULL; // NULL or CoSimulation
+ ListElement* child;
+
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (child->type == elm_CoSimulation_StandAlone || child->type == elm_CoSimulation_Tool) {
+ cs = (CoSimulation*)child;
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (child->type == elm_ModelVariables){
+ mv = (ScalarVariable**)child->list;
+ free(child);
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (child->type == elm_VendorAnnotations){
+ va = (ListElement**)child->list;
+ free(child);
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (child->type == elm_DefaultExperiment){
+ de = (Element*)child;
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (child->type == elm_TypeDefinitions){
+ td = (Type**)child->list;
+ free(child);
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (child->type == elm_UnitDefinitions){
+ ud = (ListElement**)child->list;
+ free(child);
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ // work around bug of SimulationX 3.x which places Implementation at wrong location
+ if (!cs && (child->type == elm_CoSimulation_StandAlone || child->type == elm_CoSimulation_Tool)) {
+ cs = (CoSimulation*)child;
+ child = (ListElement *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+
+ if (!checkElementType(child, elm_fmiModelDescription)) return;
+ md = (ModelDescription*)child;
+ md->modelVariables = mv;
+ md->vendorAnnotations = va;
+ md->defaultExperiment = de;
+ md->typeDefinitions = td;
+ md->unitDefinitions = ud;
+ md->cosimulation = cs;
+ stackPush(stack, md);
+ break;
+ }
+ case elm_Implementation:
+ {
+ // replace Implementation element
+ void* cs = checkPop(elm_BAD_DEFINED);
+ void* im = checkPop(elm_Implementation);
+ if (!cs || !im) return;
+ stackPush(stack, cs);
+ //printf("im=%x att=%x\n",im,((Element*)im)->attributes);
+ free(im);
+ el = ((Element*)cs)->type;
+ break;
+ }
+ case elm_CoSimulation_StandAlone:
+ {
+ Element* ca = (Element *)checkPop(elm_Capabilities);
+ CoSimulation* cs = (CoSimulation *)checkPop(elm_CoSimulation_StandAlone);
+ if (!ca || !cs) return;
+ cs->capabilities = ca;
+ stackPush(stack, cs);
+ break;
+ }
+ case elm_CoSimulation_Tool:
+ {
+ ListElement* mo = (ListElement *)checkPop(elm_Model);
+ Element* ca = (Element *)checkPop(elm_Capabilities);
+ CoSimulation* cs = (CoSimulation *)checkPop(elm_CoSimulation_Tool);
+ if (!ca || !mo || !cs) return;
+ cs->capabilities = ca;
+ cs->model = mo;
+ stackPush(stack, cs);
+ break;
+ }
+ case elm_Type:
+ {
+ Type* tp;
+ Element* ts = (Element *)checkPop(elm_BAD_DEFINED);
+ if (!ts) return;
+ if (!checkPeek(elm_Type)) return;
+ tp = (Type*)stackPeek(stack);
+ switch (ts->type) {
+ case elm_RealType:
+ case elm_IntegerType:
+ case elm_BooleanType:
+ case elm_StringType:
+ case elm_EnumerationType:
+ break;
+ default:
+ logFatalTypeError("RealType or similar", ts->type);
+ return;
+ }
+ tp->typeSpec = ts;
+ break;
+ }
+ case elm_ScalarVariable:
+ {
+ ScalarVariable* sv;
+ Element** list = NULL;
+ Element* child = (Element *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ if (child->type==elm_DirectDependency){
+ list = ((ListElement*)child)->list;
+ free(child);
+ child = (Element *)checkPop(elm_BAD_DEFINED);
+ if (!child) return;
+ }
+ if (!checkPeek(elm_ScalarVariable)) return;
+ sv = (ScalarVariable*)stackPeek(stack);
+ switch (child->type) {
+ case elm_Real:
+ case elm_Integer:
+ case elm_Boolean:
+ case elm_String:
+ case elm_Enumeration:
+ break;
+ default:
+ logFatalTypeError("Real or similar", child->type);
+ return;
+ }
+ sv->directDependencies = list;
+ sv->typeSpec = child;
+ break;
+ }
+ case elm_ModelVariables: popList(elm_ScalarVariable); break;
+ case elm_VendorAnnotations: popList(elm_Tool);break;
+ case elm_Tool: popList(elm_Annotation); break;
+ case elm_TypeDefinitions: popList(elm_Type); break;
+ case elm_EnumerationType: popList(elm_Item); break;
+ case elm_UnitDefinitions: popList(elm_BaseUnit); break;
+ case elm_BaseUnit: popList(elm_DisplayUnitDefinition); break;
+ case elm_DirectDependency: popList(elm_Name); break;
+ case elm_Model: popList(elm_File); break;
+ case elm_Name:
+ {
+ // Exception: the name value is represented as element content.
+ // All other values of the XML file are represented using attributes.
+ Element* name = (Element *)checkPop(elm_Name);
+ if (!name) return;
+ name->n = 2;
+ name->attributes = (const char **)malloc(2*sizeof(char*));
+ name->attributes[0] = attNames[att_input];
+ name->attributes[1] = data;
+ data = NULL;
+ skipData = 1; // stop recording element content
+ stackPush(stack, name);
+ break;
+ }
+ case elm_BAD_DEFINED: return; // illegal element error
+ default: // must be a leaf Element
+ assert(getAstNodeType(el)==astElement);
+ break;
+ }
+ // All children of el removed from the stack.
+ // The top element must be of type el now.
+ checkPeek(el);
+}
+
+// Called to handle element data, e.g. "xy" in xy
+// Can be called many times, e.g. with "x" and then with "y" in the example above.
+// Feature in expat:
+// For some reason, if the element data is the empty string (Eg. )
+// instead of an empty string with len == 0 we get "\n". The workaround is
+// to replace this with the empty string whenever we encounter "\n".
+void XMLCALL handleData(void *context, const XML_Char *s, int len) {
+ int n;
+ if (skipData) return;
+ if (!data) {
+ // start a new data string
+ if (len == 1 && s[0] == '\n') {
+ data = strdup("");
+ } else {
+ data = (char *)malloc(len + 1);
+ strncpy(data, s, len);
+ data[len] = '\0';
+ }
+ }
+ else {
+ // continue existing string
+ n = strlen(data) + len;
+ data = (char *)realloc(data, n+1);
+ strncat(data, s, len);
+ data[n] = '\0';
+ }
+ return;
+}
+
+
+#ifdef STANDALONE_XML_PARSER
+// -------------------------------------------------------------------------
+// printing
+
+static void printList(int indent, void** list);
+
+void printElement(int indent, void* element){
+ int i;
+ Element* e = (Element*)element;
+ if (!e) return;
+ // print attributes
+ for (i=0; itype]);
+ for (i=0; in; i+=2)
+ printf(" %s=%s", e->attributes[i], e->attributes[i+1]);
+ printf("\n");
+ // print child nodes
+ indent += 2;
+ switch (getAstNodeType(e->type)) {
+ case astElement:
+ // we already printed the attributes
+ break;
+ case astListElement:
+ printList(indent, (void **)((ListElement*)e)->list);
+ break;
+ case astScalarVariable:
+ printElement(indent, ((Type*)e)->typeSpec);
+ printList(indent, (void **)((ScalarVariable*)e)->directDependencies);
+ break;
+ case astType:
+ printElement(indent, ((Type*)e)->typeSpec);
+ break;
+ case astCoSimulation: {
+ CoSimulation* cs = (CoSimulation*)e;
+ printElement(indent, cs->capabilities);
+ printElement(indent, cs->model);
+ break;
+ }
+ case astModelDescription: {
+ ModelDescription *md = (ModelDescription*)e;
+ printList(indent, (void **)md->unitDefinitions);
+ printList(indent, (void **)md->typeDefinitions);
+ printElement(indent, md->defaultExperiment);
+ printList(indent, (void **)md->vendorAnnotations);
+ printList(indent, (void **)md->modelVariables);
+ printElement(indent, md->cosimulation);
+ break;
+ }
+ }
+}
+
+static void printList(int indent, void** list){
+ int i;
+ if (list) for (i=0; list[i]; i++)
+ printElement(indent, list[i]);
+}
+
+#endif // STANDALONE_XML_PARSER
+
+// -------------------------------------------------------------------------
+// free memory of the AST
+
+static void freeList(void** list);
+
+void freeElement(void* element){
+ int i;
+ Element* e = (Element *)element;
+ if (!e) return;
+ // free attributes
+ for (i=0; in; i+=2)
+ free((void *)e->attributes[i+1]);
+ if (e->attributes) free((void *)e->attributes);
+ // free child nodes
+ switch (getAstNodeType(e->type)) {
+ case astElement:
+ // we already freed the attributes
+ break;
+ case astListElement:
+ freeList((void **)((ListElement*)e)->list);
+ break;
+ case astScalarVariable:
+ freeList((void **)((ScalarVariable*)e)->directDependencies);
+ case astType:
+ freeElement(((Type*)e)->typeSpec);
+ break;
+ case astCoSimulation: {
+ CoSimulation* cs = (CoSimulation*)e;
+ freeElement(cs->capabilities);
+ freeElement(cs->model);
+ break;
+ }
+ case astModelDescription: {
+ ModelDescription* md = (ModelDescription*)e;
+ freeList((void **)md->unitDefinitions);
+ freeList((void **)md->typeDefinitions);
+ freeElement(md->defaultExperiment);
+ freeList((void **)md->vendorAnnotations);
+ freeList((void **)md->modelVariables);
+ freeElement(md->cosimulation);
+ break;
+ }
+ }
+ // free the struct
+ free(e);
+}
+
+static void freeList(void** list){
+ int i;
+ if (!list) return;
+ for (i=0; list[i]; i++)
+ freeElement(list[i]);
+ free(list);
+}
+
+// -------------------------------------------------------------------------
+// Validation - done after parsing to report all errors
+
+ModelDescription* validate(ModelDescription* md) {
+ int error = 0;
+ int i;
+ if (md->modelVariables)
+ for (i=0; md->modelVariables[i]; i++){
+ ScalarVariable* sv = (ScalarVariable*)md->modelVariables[i];
+ const char* declaredType = getString(sv->typeSpec, att_declaredType);
+ Type* declType = getDeclaredType(md, declaredType);
+ if (declaredType && declType==NULL) {
+ logThis(ERROR_WARNING, "Declared type %s of variable %s not found in modelDescription.xml", declaredType, getName(sv));
+ error++;
+ }
+ }
+ if (error) {
+ logThis(ERROR_ERROR, "Found %d error in modelDescription.xml", error);
+ return NULL;
+ }
+ return md;
+}
+
+// -------------------------------------------------------------------------
+// Entry function parse() of the XML parser
+
+static void cleanup(FILE *file) {
+ stackFree(stack);
+ stack = NULL;
+ XML_ParserFree(parser);
+ parser = NULL;
+ fclose(file);
+}
+
+ModelDescription* parse_encoding(const char* xmlPath, const char *encoding) {
+ ModelDescription* md = NULL;
+ FILE *file;
+ int done = 0;
+ stack = stackNew(100, 10);
+ if (!checkPointer(stack)) return NULL; // failure
+ parser = XML_ParserCreate(encoding);
+ if (!checkPointer(parser)) return NULL; // failure
+ XML_SetElementHandler(parser, startElement, endElement);
+ XML_SetCharacterDataHandler(parser, handleData);
+ file = fopen(xmlPath, "rb");
+ if (file == NULL) {
+ logThis(ERROR_ERROR, "Cannot open file '%s'", xmlPath);
+ XML_ParserFree(parser);
+ return NULL; // failure
+ }
+ logThis(ERROR_INFO, "parse %s", xmlPath);
+ while (!done) {
+ int n = fread(text, sizeof(char), XMLBUFSIZE, file);
+ if (n != XMLBUFSIZE) done = 1;
+ if (!XML_Parse(parser, text, n, done)){
+ logThis(ERROR_ERROR, "Parse error in file %s at line %d:\n%s\n",
+ xmlPath,
+ XML_GetCurrentLineNumber(parser),
+ XML_ErrorString(XML_GetErrorCode(parser)));
+ while (!stackIsEmpty(stack)) md = (ModelDescription *)stackPop(stack);
+ if (md) freeElement(md);
+ cleanup(file);
+ return NULL; // failure
+ }
+ }
+ md = (ModelDescription *)stackPop(stack);
+ assert(stackIsEmpty(stack));
+ cleanup(file);
+ //printElement(1, md); // debug
+ return validate(md); // success if all refs are valid
+}
+
+// Returns NULL to indicate failure
+// Otherwise, return the root node md of the AST.
+// The receiver must call freeElement(md) to release AST memory.
+ModelDescription* parse(const char* xmlPath) {
+ // UTF-8
+ // ISO-8859-1
+ // US-ASCII
+ // UTF-16
+ ModelDescription* md = NULL;
+ md = parse_encoding(xmlPath, "UTF-8");
+ if (md != NULL) {
+ return md;
+ }
+ logThis(ERROR_WARNING, "Failed to parse using UTF-8, will try ISO-8859-1 encoding. %s", xmlPath);
+ md = parse_encoding(xmlPath, "ISO-8859-1");
+ if (md != NULL) {
+ return md;
+ }
+ logThis(ERROR_WARNING, "Failed to parse using ISO-8859-1, will try US-ASCII encoding. %s", xmlPath);
+ md = parse_encoding(xmlPath, "US-ASCII");
+ if (md != NULL) {
+ return md;
+ }
+ logThis(ERROR_ERROR, "Failed to parse xml because of wrong encoding. %s", xmlPath);
+ return NULL;
+}
+
+// #define TEST
+#ifdef TEST
+int main(int argc, char**argv) {
+ ModelDescription* md;
+ // { char c='c'; while(c!='g') scanf("%c", &c); } // to debug: wait for the g key
+
+ if (argc!=2) {
+ printf("usage: xml_parser ");
+ return;
+ }
+ logThis(ERROR_INFO, "Parsing %s ...\n", argv[1]);
+ md = parse(argv[1]);
+ if (md) {
+ printf("Successfully parsed %s\n", argv[1]);
+ printElement(1, md);
+ freeElement(md);
+ }
+ dumpMemoryLeaks();
+}
+#endif // TEST
diff --git a/fmu10/src/shared/xml_parser.h b/fmu10/src/shared/xml_parser.h
new file mode 100644
index 0000000..74b3801
--- /dev/null
+++ b/fmu10/src/shared/xml_parser.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* -------------------------------------------------------------------------
+ * xml_parser.h
+ * A parser for file modelVariables.xml of an FMU.
+ * Supports "FMI for Model Exchange 1.0" and "FMI for Co-Simulation 1.0".
+ * Author: Jakob Mauss, January 2010.
+ * -------------------------------------------------------------------------*/
+
+#ifndef xml_parser_h
+#define xml_parser_h
+
+// define XML_STATIC before including expat.h
+// to prevent error when linking with libexpatMT.lib
+#define XML_STATIC
+#include "expat.h"
+#include "stack.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef fmiModelTypes_h
+#ifndef fmiPlatformTypes_h
+typedef unsigned int fmiValueReference;
+#endif
+#endif
+
+#define fmiUndefinedValueReference (fmiValueReference)(-1)
+
+#define SIZEOF_ELM 31
+extern const char *elmNames[SIZEOF_ELM];
+
+#define SIZEOF_ATT 47
+extern const char *attNames[SIZEOF_ATT];
+
+#define SIZEOF_ENU 13
+extern const char *enuNames[SIZEOF_ENU];
+
+// Attributes
+typedef enum {
+ elm_BAD_DEFINED = -1,
+ elm_fmiModelDescription,elm_UnitDefinitions,elm_BaseUnit,elm_DisplayUnitDefinition,elm_TypeDefinitions,
+ elm_Type,elm_RealType,elm_IntegerType,elm_BooleanType,elm_StringType,elm_EnumerationType,elm_Item,
+ elm_DefaultExperiment,elm_VendorAnnotations,elm_Tool,elm_Annotation,elm_ModelVariables,elm_ScalarVariable,
+ elm_DirectDependency,elm_Name,elm_Real,elm_Integer,elm_Boolean,elm_String,elm_Enumeration,
+ elm_Implementation,elm_CoSimulation_StandAlone,elm_CoSimulation_Tool,elm_Model,elm_File,elm_Capabilities
+} Elm;
+
+// Attributes
+typedef enum {
+ att_BAD_DEFINED = -1,
+ att_fmiVersion,att_displayUnit,att_gain,att_offset,att_unit,att_name,att_description,att_quantity,att_relativeQuantity,
+ att_min,att_max,att_nominal,att_declaredType,att_start,att_fixed,att_startTime,att_stopTime,att_tolerance,att_value,
+ att_valueReference,att_variability,att_causality,att_alias,att_modelName,att_modelIdentifier,att_guid,att_author,
+ att_version,att_generationTool,att_generationDateAndTime,att_variableNamingConvention,att_numberOfContinuousStates,
+ att_numberOfEventIndicators,att_input,
+ att_canHandleVariableCommunicationStepSize,att_canHandleEvents,att_canRejectSteps,att_canInterpolateInputs,
+ att_maxOutputDerivativeOrder,att_canRunAsynchronuously,att_canSignalEvents,att_canBeInstantiatedOnlyOncePerProcess,
+ att_canNotUseMemoryManagementFunctions,att_entryPoint,att_manualStart,att_type
+} Att;
+
+// Enumeration values
+typedef enum {
+ enu_BAD_DEFINED = -1,
+ enu_flat,enu_structured,enu_constant,enu_parameter,enu_discrete,enu_continuous,
+ enu_input,enu_output,enu_internal,enu_none,enu_noAlias,enu_alias,enu_negatedAlias
+} Enu;
+
+// AST node for element
+// DisplayUnitDefinition, RealType, IntegerType, BooleanType, StringType, DefaultExperiment,
+// Item, Annotation, Name, Real, Integer, Boolean, String, Enumeration, Capabilities, File
+typedef struct {
+ Elm type; // element type
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, even number
+} Element;
+
+// AST node for element that has a list of elements
+// BaseUnit, EnumerationType, Tool, DirectDependency, Model
+typedef struct {
+ Elm type; // element type
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, even number
+ Element** list; // null-terminated array of pointers to elements, not null
+} ListElement;
+
+// AST node for element Type
+typedef struct {
+ Elm type; // element type
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, an even number
+ Element* typeSpec; // one of RealType, IntegerType etc.
+} Type;
+
+// AST node for element ScalarVariable
+typedef struct {
+ Elm type; // element type
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, even number
+ Element* typeSpec; // one of Real, Integer, etc
+ Element** directDependencies; // null or null-terminated list of Name
+ int modelIdx; // only used in fmu10
+} ScalarVariable;
+
+// AST node for element CoSimulation_StandAlone and CoSimulation_Tool
+typedef struct {
+ Elm type; // one of elm_CoSimulation_StandAlone and elm_CoSimulation_Tool
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, even number
+ Element* capabilities; // a set of capability attributes
+ ListElement* model; // non-NULL to support tool coupling, NULL for standalone
+} CoSimulation;
+
+// AST node for element ModelDescription
+typedef struct {
+ Elm type; // element type
+ const char** attributes; // null or n attribute value strings
+ int n; // size of attributes, even number
+ ListElement** unitDefinitions; // NULL or null-terminated list of BaseUnits
+ Type** typeDefinitions; // NULL or null-terminated list of Types
+ Element* defaultExperiment; // NULL or DefaultExperiment
+ ListElement** vendorAnnotations; // NULL or null-terminated list of Tools
+ ScalarVariable** modelVariables; // NULL or null-terminated list of ScalarVariable
+ CoSimulation* cosimulation; // NULL if this ModelDescription is for model exchange only
+} ModelDescription;
+
+// types of AST nodes used to represent an element
+typedef enum {
+ astElement,
+ astListElement,
+ astType,
+ astScalarVariable,
+ astCoSimulation,
+ astModelDescription
+} AstNodeType;
+
+// Possible results when retrieving an attribute value from an element
+typedef enum {
+ valueMissing,
+ valueDefined,
+ valueIllegal
+} ValueStatus;
+
+// Public methods: Parsing and low-level AST access
+ModelDescription* parse(const char* xmlPath);
+const char* getString(void* element, Att a);
+double getDouble (void* element, Att a, ValueStatus* vs);
+int getInt (void* element, Att a, ValueStatus* vs);
+unsigned int getUInt (void* element, Att a, ValueStatus* vs);
+char getBoolean (void* element, Att a, ValueStatus* vs);
+Enu getEnumValue (void* element, Att a, ValueStatus* vs);
+void freeElement (void* element);
+
+// Convenience methods for AST access. To be used after successful validation only.
+const char* getModelIdentifier(ModelDescription* md);
+int getNumberOfStates(ModelDescription* md);
+int getNumberOfEventIndicators(ModelDescription* md);
+const char* getName(void* element);
+Enu getCausality(void* scalarVariable);
+Enu getVariability(void* scalarVariable);
+Enu getAlias(void* scalarVariable);
+fmiValueReference getValueReference(void* scalarVariable);
+ScalarVariable* getVariableByName(ModelDescription* md, const char* name);
+ScalarVariable* getVariable(ModelDescription* md, fmiValueReference vr, Elm type);
+ScalarVariable* getNonAliasVariable(ModelDescription* md, fmiValueReference vr, Elm type);
+Type* getDeclaredType(ModelDescription* md, const char* declaredType);
+const char* getString2(ModelDescription* md, void* sv, Att a);
+const char * getDescription(ModelDescription* md, ScalarVariable* sv);
+const char * getVariableAttributeString(ModelDescription* md, fmiValueReference vr, Elm type, Att a);
+double getVariableAttributeDouble(ModelDescription* md, fmiValueReference vr, Elm type, Att a, ValueStatus* vs);
+//double getNominal(ModelDescription* md, ScalarVariable* sv);
+double getNominal(ModelDescription* md, fmiValueReference vr);
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
+#endif // xml_parser_h
diff --git a/fmu20/Makefile b/fmu20/Makefile
new file mode 100644
index 0000000..23e6446
--- /dev/null
+++ b/fmu20/Makefile
@@ -0,0 +1,11 @@
+all:
+ (cd src; $(MAKE))
+
+clean:
+ (cd src; $(MAKE) clean)
+
+distclean: clean
+ rm -f bin/fmusim_cs* bin/fmusim_me*
+ rm -rf fmu
+ find . -name "*~" -exec rm {} \;
+ find . -name "#*~" -exec rm {} \;
diff --git a/fmu20/bin/7z.dll b/fmu20/bin/7z.dll
new file mode 100644
index 0000000..4d72895
Binary files /dev/null and b/fmu20/bin/7z.dll differ
diff --git a/fmu20/bin/7z.exe b/fmu20/bin/7z.exe
new file mode 100644
index 0000000..efb5fc9
Binary files /dev/null and b/fmu20/bin/7z.exe differ
diff --git a/fmu20/bin/License.txt b/fmu20/bin/License.txt
new file mode 100644
index 0000000..44802a8
--- /dev/null
+++ b/fmu20/bin/License.txt
@@ -0,0 +1,57 @@
+ 7-Zip
+ ~~~~~
+ License for use and distribution
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 7-Zip Copyright (C) 1999-2007 Igor Pavlov.
+
+ Licenses for files are:
+
+ 1) 7z.dll: GNU LGPL + unRAR restriction
+ 2) All other files: GNU LGPL
+
+ The GNU LGPL + unRAR restriction means that you must follow both
+ GNU LGPL rules and unRAR restriction rules.
+
+
+ Note:
+ You can use 7-Zip on any computer, including a computer in a commercial
+ organization. You don't need to register or pay for 7-Zip.
+
+
+ GNU LGPL information
+ --------------------
+
+ This 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.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ unRAR restriction
+ -----------------
+
+ The decompression engine for RAR archives was developed using source
+ code of unRAR program.
+ All copyrights to original unRAR code are owned by Alexander Roshal.
+
+ The license for original unRAR code has the following restriction:
+
+ The unRAR sources cannot be used to re-create the RAR compression algorithm,
+ which is proprietary. Distribution of modified unRAR sources in separate form
+ or as a part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+
+ --
+ Igor Pavlov
diff --git a/fmu20/src/Makefile b/fmu20/src/Makefile
new file mode 100644
index 0000000..05b50c9
--- /dev/null
+++ b/fmu20/src/Makefile
@@ -0,0 +1,86 @@
+# fmusim makefile for Mac OS X
+
+EXECS = \
+ fmusim_cs \
+ fmusim_me
+
+# Build simulators for co_simulation and model_exchange and then build the .fmu files.
+all: $(EXECS)
+ (cd models; $(MAKE))
+
+clean:
+ rm -f $(EXECS)
+ rm -rf *.dSYM
+ rm -f cosimulation/*.o
+ rm -f model_exchange/*.o
+ (cd models; $(MAKE) clean)
+
+# Sources shared between co-simulation and model exchange
+SHARED_SRCS = \
+ shared/sim_support.c \
+ shared/xmlVersionParser.c
+
+CPP_SRCS = \
+ shared/parser/XmlElement.cpp \
+ shared/parser/XmlParser.cpp \
+ shared/parser/XmlParserCApi.cpp
+
+# Dependencies for only fmusim_cs
+CO_SIMULATION_DEPS = \
+ co_simulation/main.c
+
+# Dependencies for only fmusim_me
+MODEL_EXCHANGE_DEPS = \
+ model_exchange/main.c
+
+# Dependencies shared between both fmusim_cs and fmusim_me
+SHARED_DEPS = \
+ shared/fmi2.h \
+ shared/include/fmi2Functions.h \
+ shared/include/fmi2FunctionTypes.h \
+ shared/include/fmi2TypesPlatform.h \
+ shared/parser/fmu20/XmlElement.h \
+ shared/parser/fmu20/XmlParser.h \
+ shared/parser/fmu20/XmlParserException.h \
+ shared/parser/XmlParserCApi.h \
+ shared/xmlVersionParser.c \
+ shared/xmlVersionParser.h
+
+# Set CFLAGS to -m32 to build for linux32
+#CFLAGS=-m32
+# See also models/build_fmu
+
+CXX=c++
+# Create the binaries in the current directory because co_simulation already has
+# a directory named "fmusim_cs"
+fmusim_cs: $(CO_SIMULATION_DEPS) $(SHARED_DEPS) ../bin/
+ $(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
+ -DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+ -Ishared/include -Ishared/parser -Ishared \
+ co_simulation/main.c $(SHARED_SRCS) \
+ -c
+ $(CXX) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
+ -DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+ -Ishared/include -Ishared/parser -Ishared \
+ main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
+ -o $@ -ldl -lxml2
+ cp fmusim_cs ../bin/
+
+fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) ../bin/
+ $(CC) $(CFLAGS) -g -Wall \
+ -DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+ -Ishared/include -Ishared/parser/libxml -Ishared/parser -Ishared \
+ model_exchange/main.c $(SHARED_SRCS) \
+ -c
+ $(CXX) $(CFLAGS) -g -Wall \
+ -DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
+ -Ishared/include -Ishared/parser/libxml -Ishared/parser -Ishared \
+ main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
+ -o $@ -ldl -lxml2
+ cp fmusim_me ../bin/
+
+../bin/:
+ if [ ! -d ../bin ]; then \
+ echo "Creating ../bin/"; \
+ mkdir ../bin/; \
+ fi
diff --git a/fmu20/src/build_all.bat b/fmu20/src/build_all.bat
new file mode 100644
index 0000000..346713a
--- /dev/null
+++ b/fmu20/src/build_all.bat
@@ -0,0 +1,29 @@
+@echo off
+
+rem ------------------------------------------------------------
+rem This batch builds both simulators and all FMUs of the FmuSDK
+rem Copyright QTronic GmbH. All rights reserved.
+rem ------------------------------------------------------------
+
+rem First argument %1 should be empty for win32, and '-win64' for win64 build.
+call build_fmusim_me %1
+call build_fmusim_cs %1
+echo -----------------------------------------------------------
+echo Making the FMUs of the FmuSDK ...
+pushd models
+
+call build_fmu me dq %1
+call build_fmu me inc %1
+call build_fmu me values %1
+call build_fmu me vanDerPol %1
+call build_fmu me bouncingBall %1
+
+call build_fmu cs dq %1
+call build_fmu cs inc %1
+call build_fmu cs values %1
+call build_fmu cs vanDerPol %1
+call build_fmu cs bouncingBall %1
+
+popd
+
+
diff --git a/fmu20/src/build_fmusim_cs.bat b/fmu20/src/build_fmusim_cs.bat
new file mode 100644
index 0000000..59a37dc
--- /dev/null
+++ b/fmu20/src/build_fmusim_cs.bat
@@ -0,0 +1,69 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds the FMU simulator fmu20sim_cs.exe
+rem Usage: build_fmusim_cs.bat (-win64)
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+echo building fmusim_cs.exe - FMI for Co-Simulation 2.0
+echo -----------------------------------------------------------
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%1"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if not exist ..\bin\x64 mkdir ..\bin\x64
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+set SRC=main.c ..\shared\sim_support.c ..\shared\xmlVersionParser.c ..\shared\parser\XmlParser.cpp ..\shared\parser\XmlElement.cpp ..\shared\parser\XmlParserCApi.cpp
+set INC=/I..\shared\include /I..\shared /I..\shared\parser
+set OPTIONS=/DFMI_COSIMULATION /nologo /EHsc /DSTANDALONE_XML_PARSER /DLIBXML_STATIC
+
+rem create fmusim_cs.exe in co_simulation dir
+pushd co_simulation
+cl %SRC% %INC% %OPTIONS% /Fefmusim_cs.exe /link /LIBPATH:..\shared\parser\%x64%
+del *.obj
+popd
+if not exist co_simulation\fmusim_cs.exe goto compileError
+move /Y co_simulation\fmusim_cs.exe ..\bin\%x64%
+goto done
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of fmusim_cs.exe failed
+
+:done
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu20/src/build_fmusim_me.bat b/fmu20/src/build_fmusim_me.bat
new file mode 100644
index 0000000..cd12290
--- /dev/null
+++ b/fmu20/src/build_fmusim_me.bat
@@ -0,0 +1,69 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds the FMU simulator fmusim_me.exe
+rem Usage: build_fmusim_me.bat (-win64)
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+echo building fmusim_me.exe - FMI for Model Exchange 2.0
+echo -----------------------------------------------------------
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%1"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if not exist ..\bin\x64 mkdir ..\bin\x64
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+set SRC=main.c ..\shared\sim_support.c ..\shared\xmlVersionParser.c ..\shared\parser\XmlParser.cpp ..\shared\parser\XmlElement.cpp ..\shared\parser\XmlParserCApi.cpp
+set INC=/I..\shared\include /I..\shared /I..\shared\parser
+set OPTIONS= /nologo /EHsc /DSTANDALONE_XML_PARSER /DLIBXML_STATIC
+
+rem create fmusim_me.exe in the model_exchange dir
+pushd model_exchange
+cl %SRC% %INC% %OPTIONS% /Fefmusim_me.exe /link /LIBPATH:..\shared\parser\%x64%
+del *.obj
+popd
+if not exist model_exchange\fmusim_me.exe goto compileError
+move /Y model_exchange\fmusim_me.exe ..\bin\%x64%
+goto done
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of fmusim_me.exe failed
+
+:done
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu20/src/co_simulation/main.c b/fmu20/src/co_simulation/main.c
new file mode 100644
index 0000000..1ec2356
--- /dev/null
+++ b/fmu20/src/co_simulation/main.c
@@ -0,0 +1,181 @@
+/* -------------------------------------------------------------------------
+ * main.c
+ * Implements simulation of a single FMU instance
+ * that implements the "FMI for Co-Simulation 2.0" interface.
+ * Command syntax: see printHelp()
+ * Simulates the given FMU from t = 0 .. tEnd with fixed step size h and
+ * writes the computed solution to file 'result.csv'.
+ * The CSV file (comma-separated values) may e.g. be plotted using
+ * OpenOffice Calc or Microsoft Excel.
+ * This program demonstrates basic use of an FMU.
+ * Real applications may use advanced master algorithms to co-simulate
+ * many FMUs, limit the numerical error using error estimation
+ * and back-stepping, provide graphical plotting utilities, debug support,
+ * and user control of parameter and start values, or perform a clean
+ * error handling (e.g. call freeSlaveInstance when a call to the fmu
+ * returns with error). All this is missing here.
+ *
+ * Revision history
+ * 07.03.2014 initial version released in FMU SDK 2.0.0
+ *
+ * Free libraries and tools used to implement this simulator:
+ * - header files from the FMI specification
+ * - libxml2 XML parser, see http://xmlsoft.org
+ * - 7z.exe 4.57 zip and unzip tool, see http://www.7-zip.org
+ * Author: Adrian Tirea
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include "fmi2.h"
+#include "sim_support.h"
+
+FMU fmu; // the fmu to simulate
+
+// simulate the given FMU from tStart = 0 to tEnd.
+static int simulate(FMU* fmu, double tEnd, double h, fmi2Boolean loggingOn, char separator,
+ int nCategories, char **categories) {
+ double time;
+ double tStart = 0; // start time
+ const char *guid; // global unique id of the fmu
+ const char *instanceName; // instance name
+ fmi2Component c; // instance of the fmu
+ fmi2Status fmi2Flag; // return code of the fmu functions
+ char *fmuResourceLocation = getTempResourcesLocation(); // path to the fmu resources as URL, "file://C:\QTronic\sales"
+ fmi2Boolean visible = fmi2False; // no simulator user interface
+
+ fmi2CallbackFunctions callbacks = {fmuLogger, calloc, free, NULL, fmu}; // called by the model during simulation
+ ModelDescription* md; // handle to the parsed XML file
+ fmi2Boolean toleranceDefined = fmi2False; // true if model description define tolerance
+ fmi2Real tolerance = 0; // used in setting up the experiment
+ ValueStatus vs;
+ int nSteps = 0;
+ double hh = h;
+ Element *defaultExp;
+ FILE* file;
+
+ // instantiate the fmu
+ md = fmu->modelDescription;
+ guid = getAttributeValue((Element *)md, att_guid);
+ instanceName = getAttributeValue((Element *)getCoSimulation(md), att_modelIdentifier);
+ c = fmu->instantiate(instanceName, fmi2CoSimulation, guid, fmuResourceLocation,
+ &callbacks, visible, loggingOn);
+ free(fmuResourceLocation);
+ if (!c) return error("could not instantiate model");
+
+ if (nCategories > 0) {
+ fmi2Flag = fmu->setDebugLogging(c, fmi2True, nCategories, categories);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI set debug logging");
+ }
+ }
+
+ defaultExp = getDefaultExperiment(md);
+ if (defaultExp) tolerance = getAttributeDouble(defaultExp, att_tolerance, &vs);
+ if (vs == valueDefined) {
+ toleranceDefined = fmi2True;
+ }
+
+ fmi2Flag = fmu->setupExperiment(c, toleranceDefined, tolerance, tStart, fmi2True, tEnd);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI setup experiment");
+ }
+ fmi2Flag = fmu->enterInitializationMode(c);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI enter initialization mode");
+ }
+ fmi2Flag = fmu->exitInitializationMode(c);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI exit initialization mode");
+ }
+
+ // open result file
+ if (!(file = fopen(RESULT_FILE, "w"))) {
+ printf("could not write %s because:\n", RESULT_FILE);
+ printf(" %s\n", strerror(errno));
+ return 0; // failure
+ }
+
+ // output solution for time t0
+ outputRow(fmu, c, tStart, file, separator, fmi2True); // output column names
+ outputRow(fmu, c, tStart, file, separator, fmi2False); // output values
+
+ // enter the simulation loop
+ time = tStart;
+ while (time < tEnd) {
+ // check not to pass over end time
+ if (h > tEnd - time) {
+ hh = tEnd - time;
+ }
+ fmi2Flag = fmu->doStep(c, time, hh, fmi2True);
+ if (fmi2Flag == fmi2Discard) {
+ fmi2Boolean b;
+ // check if model requests to end simulation
+ if (fmi2OK != fmu->getBooleanStatus(c, fmi2Terminated, &b)) {
+ return error("could not complete simulation of the model. getBooleanStatus return other than fmi2OK");
+ }
+ if (b == fmi2True) {
+ return error("the model requested to end the simulation");
+ }
+ return error("could not complete simulation of the model");
+ }
+ if (fmi2Flag != fmi2OK) return error("could not complete simulation of the model");
+ time += hh;
+ outputRow(fmu, c, time, file, separator, fmi2False); // output values for this step
+ nSteps++;
+ }
+
+ // end simulation
+ fmu->terminate(c);
+ fmu->freeInstance(c);
+ fclose(file);
+
+ // print simulation summary
+ printf("Simulation from %g to %g terminated successful\n", tStart, tEnd);
+ printf(" steps ............ %d\n", nSteps);
+ printf(" fixed step size .. %g\n", h);
+ return 1; // success
+}
+
+int main(int argc, char *argv[]) {
+ const char* fmuFileName;
+ int i;
+
+ // parse command line arguments and load the FMU
+ // default arguments value
+ double tEnd = 1.0;
+ double h=0.1;
+ int loggingOn = 0;
+ char csv_separator = ',';
+ char **categories = NULL;
+ int nCategories = 0;
+
+ parseArguments(argc, argv, &fmuFileName, &tEnd, &h, &loggingOn, &csv_separator, &nCategories, &categories);
+ loadFMU(fmuFileName);
+
+ // run the simulation
+ printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c' ",
+ fmuFileName, tEnd, h, loggingOn, csv_separator);
+ printf("log categories={ ");
+ for (i = 0; i < nCategories; i++) printf("%s ", categories[i]);
+ printf("}\n");
+
+ simulate(&fmu, tEnd, h, loggingOn, csv_separator, nCategories, categories);
+ printf("CSV file '%s' written\n", RESULT_FILE);
+
+ // release FMU
+#if WINDOWS
+ FreeLibrary(fmu.dllHandle);
+#else /* WINDOWS */
+ dlclose(fmu.dllHandle);
+#endif /* WINDOWS */
+ freeModelDescription(fmu.modelDescription);
+ if (categories) free(categories);
+
+ // delete temp files obtained by unzipping the FMU
+ deleteUnzippedFiles();
+
+ return EXIT_SUCCESS;
+}
diff --git a/fmu20/src/model_exchange/main.c b/fmu20/src/model_exchange/main.c
new file mode 100644
index 0000000..4b94a86
--- /dev/null
+++ b/fmu20/src/model_exchange/main.c
@@ -0,0 +1,288 @@
+/* -------------------------------------------------------------------------
+ * main.c
+ * Implements simulation of a single FMU instance using the forward Euler
+ * method for numerical integration.
+ * Command syntax: see printHelp()
+ * Simulates the given FMU from t = 0 .. tEnd with fixed step size h and
+ * writes the computed solution to file 'result.csv'.
+ * The CSV file (comma-separated values) may e.g. be plotted using
+ * OpenOffice Calc or Microsoft Excel.
+ * This program demonstrates basic use of an FMU.
+ * Real applications may use advanced numerical solvers instead, means to
+ * exactly locate state events in time, graphical plotting utilities, support
+ * for co-execution of many FMUs, stepping and debug support, user control
+ * of parameter and start values etc.
+ * All this is missing here.
+ *
+ * Revision history
+ * 07.03.2014 initial version released in FMU SDK 2.0.0
+ *
+ * Free libraries and tools used to implement this simulator:
+ * - header files from the FMU specification
+ * - libxml2 XML parser, see http://xmlsoft.org
+ * - 7z.exe 4.57 zip and unzip tool, see http://www.7-zip.org
+ * Author: Adrian Tirea
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include
+#include
+#include "fmi2.h"
+#include "sim_support.h"
+
+FMU fmu; // the fmu to simulate
+
+// simulate the given FMU using the forward euler method.
+// time events are processed by reducing step size to exactly hit tNext.
+// state events are checked and fired only at the end of an Euler step.
+// the simulator may therefore miss state events and fires state events typically too late.
+static int simulate(FMU* fmu, double tEnd, double h, fmi2Boolean loggingOn, char separator,
+ int nCategories, char **categories) {
+ int i;
+ double dt, tPre;
+ fmi2Boolean timeEvent, stateEvent, stepEvent, terminateSimulation;
+ double time;
+ int nx; // number of state variables
+ int nz; // number of state event indicators
+ double *x = NULL; // continuous states
+ double *xdot = NULL; // the corresponding derivatives in same order
+ double *z = NULL; // state event indicators
+ double *prez = NULL; // previous values of state event indicators
+ fmi2EventInfo eventInfo; // updated by calls to initialize and eventUpdate
+ ModelDescription* md; // handle to the parsed XML file
+ const char* guid; // global unique id of the fmu
+ fmi2CallbackFunctions callbacks = {fmuLogger, calloc, free, NULL, fmu}; // called by the model during simulation
+ fmi2Component c; // instance of the fmu
+ fmi2Status fmi2Flag; // return code of the fmu functions
+ fmi2Real tStart = 0; // start time
+ fmi2Boolean toleranceDefined = fmi2False; // true if model description define tolerance
+ fmi2Real tolerance = 0; // used in setting up the experiment
+ fmi2Boolean visible = fmi2False; // no simulator user interface
+ const char *instanceName; // instance name
+ char *fmuResourceLocation = getTempResourcesLocation(); // path to the fmu resources as URL, "file://C:\QTronic\sales"
+ int nSteps = 0;
+ int nTimeEvents = 0;
+ int nStepEvents = 0;
+ int nStateEvents = 0;
+ FILE* file;
+ ValueStatus vs;
+
+ // instantiate the fmu
+ md = fmu->modelDescription;
+ guid = getAttributeValue((Element *)md, att_guid);
+ instanceName = getAttributeValue((Element *)getModelExchange(md), att_modelIdentifier);
+ c = fmu->instantiate(instanceName, fmi2ModelExchange, guid, fmuResourceLocation,
+ &callbacks, visible, loggingOn);
+ free(fmuResourceLocation);
+ if (!c) return error("could not instantiate model");
+
+ if (nCategories > 0) {
+ fmi2Flag = fmu->setDebugLogging(c, fmi2True, nCategories, categories);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI set debug logging");
+ }
+ }
+
+ // allocate memory
+ nx = getDerivativesSize(getModelStructure(md)); // number of continuous states is number of derivatives
+ // declared in model structure
+ nz = getAttributeInt((Element *)md, att_numberOfEventIndicators, &vs); // number of event indicators
+ x = (double *) calloc(nx, sizeof(double));
+ xdot = (double *) calloc(nx, sizeof(double));
+ if (nz>0) {
+ z = (double *) calloc(nz, sizeof(double));
+ prez = (double *) calloc(nz, sizeof(double));
+ }
+ if ((!x || !xdot) || (nz>0 && (!z || !prez))) return error("out of memory");
+
+ // open result file
+ if (!(file = fopen(RESULT_FILE, "w"))) {
+ printf("could not write %s because:\n", RESULT_FILE);
+ printf(" %s\n", strerror(errno));
+ free (x);
+ free(xdot);
+ free(z);
+ free(prez);
+ return 0; // failure
+ }
+
+ // setup the experiment, set the start time
+ time = tStart;
+ fmi2Flag = fmu->setupExperiment(c, toleranceDefined, tolerance, tStart, fmi2True, tEnd);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI setup experiment");
+ }
+
+ // initialize
+ fmi2Flag = fmu->enterInitializationMode(c);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI enter initialization mode");
+ }
+ fmi2Flag = fmu->exitInitializationMode(c);
+ if (fmi2Flag > fmi2Warning) {
+ return error("could not initialize model; failed FMI exit initialization mode");
+ }
+
+ // event iteration
+ eventInfo.newDiscreteStatesNeeded = fmi2True;
+ eventInfo.terminateSimulation = fmi2False;
+ while (eventInfo.newDiscreteStatesNeeded && !eventInfo.terminateSimulation) {
+ // update discrete states
+ fmi2Flag = fmu->newDiscreteStates(c, &eventInfo);
+ if (fmi2Flag > fmi2Warning) return error("could not set a new discrete state");
+ }
+
+ if (eventInfo.terminateSimulation) {
+ printf("model requested termination at t=%.16g\n", time);
+ } else {
+ // enter Continuous-Time Mode
+ fmu->enterContinuousTimeMode(c);
+ // output solution for time tStart
+ outputRow(fmu, c, tStart, file, separator, fmi2True); // output column names
+ outputRow(fmu, c, tStart, file, separator, fmi2False); // output values
+
+ // enter the simulation loop
+ while (time < tEnd) {
+ // get current state and derivatives
+ fmi2Flag = fmu->getContinuousStates(c, x, nx);
+ if (fmi2Flag > fmi2Warning) return error("could not retrieve states");
+ fmi2Flag = fmu->getDerivatives(c, xdot, nx);
+ if (fmi2Flag > fmi2Warning) return error("could not retrieve derivatives");
+
+ // advance time
+ tPre = time;
+ time = min(time+h, tEnd);
+ timeEvent = eventInfo.nextEventTimeDefined && eventInfo.nextEventTime < time;
+ if (timeEvent) time = eventInfo.nextEventTime;
+ dt = time - tPre;
+ fmi2Flag = fmu->setTime(c, time);
+ if (fmi2Flag > fmi2Warning) error("could not set time");
+
+ // perform one step
+ for (i = 0; i < nx; i++) x[i] += dt * xdot[i]; // forward Euler method
+ fmi2Flag = fmu->setContinuousStates(c, x, nx);
+ if (fmi2Flag > fmi2Warning) return error("could not set states");
+ if (loggingOn) printf("Step %d to t=%.16g\n", nSteps, time);
+
+ // check for state event
+ for (i = 0; i < nz; i++) prez[i] = z[i];
+ fmi2Flag = fmu->getEventIndicators(c, z, nz);
+ if (fmi2Flag > fmi2Warning) return error("could not retrieve event indicators");
+ stateEvent = FALSE;
+ for (i=0; icompletedIntegratorStep(c, fmi2True, &stepEvent, &terminateSimulation);
+ if (fmi2Flag > fmi2Warning) return error("could not complete intgrator step");
+ if (terminateSimulation) {
+ printf("model requested termination at t=%.16g\n", time);
+ break; // success
+ }
+
+ // handle events
+ if (timeEvent || stateEvent || stepEvent) {
+ fmu->enterEventMode(c);
+ if (timeEvent) {
+ nTimeEvents++;
+ if (loggingOn) printf("time event at t=%.16g\n", time);
+ }
+ if (stateEvent) {
+ nStateEvents++;
+ if (loggingOn) for (i=0; i0 && z[i]<0) ? "-\\-" : "-/-", i, time);
+ }
+ if (stepEvent) {
+ nStepEvents++;
+ if (loggingOn) printf("step event at t=%.16g\n", time);
+ }
+
+ // event iteration in one step, ignoring intermediate results
+ eventInfo.newDiscreteStatesNeeded = fmi2True;
+ eventInfo.terminateSimulation = fmi2False;
+ while (eventInfo.newDiscreteStatesNeeded && !eventInfo.terminateSimulation) {
+ // update discrete states
+ fmi2Flag = fmu->newDiscreteStates(c, &eventInfo);
+ if (fmi2Flag > fmi2Warning) return error("could not set a new discrete state");
+
+ // check for change of value of states
+ if (eventInfo.valuesOfContinuousStatesChanged && loggingOn) {
+ printf("continuous state values changed at t=%.16g\n", time);
+ }
+ if (eventInfo.nominalsOfContinuousStatesChanged && loggingOn){
+ printf("nominals of continuous state changed at t=%.16g\n", time);
+ }
+ }
+ if (eventInfo.terminateSimulation) {
+ printf("model requested termination at t=%.16g\n", time);
+ break; // success
+ }
+
+ // enter Continuous-Time Mode
+ fmu->enterContinuousTimeMode(c);
+ } // if event
+ outputRow(fmu, c, time, file, separator, fmi2False); // output values for this step
+ nSteps++;
+ } // while
+ }
+ // cleanup
+ fmu->terminate(c);
+ fmu->freeInstance(c);
+ fclose(file);
+ if (x != NULL) free(x);
+ if (xdot != NULL) free(xdot);
+ if (z != NULL) free(z);
+ if (prez != NULL) free(prez);
+
+ // print simulation summary
+ printf("Simulation from %g to %g terminated successful\n", tStart, tEnd);
+ printf(" steps ............ %d\n", nSteps);
+ printf(" fixed step size .. %g\n", h);
+ printf(" time events ...... %d\n", nTimeEvents);
+ printf(" state events ..... %d\n", nStateEvents);
+ printf(" step events ...... %d\n", nStepEvents);
+
+ return 1; // success
+}
+
+int main(int argc, char *argv[]) {
+ const char* fmuFileName;
+ int i;
+
+ // parse command line arguments and load the FMU
+ // default arguments value
+ double tEnd = 1.0;
+ double h=0.1;
+ int loggingOn = 0;
+ char csv_separator = ',';
+ char **categories = NULL;
+ int nCategories = 0;
+
+ parseArguments(argc, argv, &fmuFileName, &tEnd, &h, &loggingOn, &csv_separator, &nCategories, &categories);
+ loadFMU(fmuFileName);
+
+ // run the simulation
+ printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c' ",
+ fmuFileName, tEnd, h, loggingOn, csv_separator);
+ printf("log categories={ ");
+ for (i = 0; i < nCategories; i++) printf("%s ", categories[i]);
+ printf("}\n");
+
+ simulate(&fmu, tEnd, h, loggingOn, csv_separator, nCategories, categories);
+ printf("CSV file '%s' written\n", RESULT_FILE);
+
+ // release FMU
+#if WINDOWS
+ FreeLibrary(fmu.dllHandle);
+#else /* WINDOWS */
+ dlclose(fmu.dllHandle);
+#endif /* WINDOWS */
+ freeModelDescription(fmu.modelDescription);
+ if (categories) free(categories);
+
+ // delete temp files obtained by unzipping the FMU
+ deleteUnzippedFiles();
+
+ return EXIT_SUCCESS;
+}
diff --git a/fmu20/src/models/Makefile b/fmu20/src/models/Makefile
new file mode 100644
index 0000000..f21c97a
--- /dev/null
+++ b/fmu20/src/models/Makefile
@@ -0,0 +1,72 @@
+# Build the .fmu files for both co-simulation and model-exchange.
+#
+# The build_fmu script calls make with the appropriate makefile variables set.
+
+# The architecture: linux32, linux64, darwin32, darwin64
+ARCH = darwin64
+
+# Either cs for co-simuluation or me for model exchange.
+CSORME = cs
+INCLUDE = -I../../co_simulation/include
+
+# The suffix for shared libraries.
+# dylib for Mac OS X, so for Linux
+SHARED_LIBRARY_SUFFIX = dylib
+#SHARED_LIBRARY_SUFFIX = so
+
+# Empty for Mac OS X, -fPIC for Linux
+PIC =
+#PIC = -fPIC
+
+# Build the .fmu files for both co-simulation and model-exchange
+all:
+ chmod 777 build_fmu
+ ./build_fmu me bouncingBall
+ ./build_fmu me dq
+ ./build_fmu me inc
+ ./build_fmu me values
+ ./build_fmu me vanDerPol
+ ./build_fmu cs bouncingBall
+ ./build_fmu cs dq
+ ./build_fmu cs inc
+ ./build_fmu cs values
+ ./build_fmu cs vanDerPol
+
+# CBITSFLAGS is set to -m32 to build linux32 fmus
+
+%.o: %.c
+ echo `pwd`
+ $(CC) -g -c $(CBITSFLAGS) $(PIC) -Wall $(INCLUDE) $(CFLAGS) $< -o $@
+
+# Under Linux, compile with -fvisibility=hidden, see
+# https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
+%.so: %.o
+ $(CC) $(CBITSFLAGS) -fvisibility=hidden -shared -Wl,-soname,$@ -o $@ $<
+
+%.dylib: %.o
+ $(CC) -dynamiclib -o $@ $<
+
+%.fmu: %.$(SHARED_LIBRARY_SUFFIX)
+ rm -rf fmu
+ mkdir -p fmu/binaries/$(ARCH) fmu/sources fmu/documentation
+ cp $< fmu/binaries/$(ARCH)
+ -cp *.c fmu/sources
+ rsync -av --ignore-missing-args ./*.h ./fmu/sources
+ -cp *.html *.png fmu/documentation
+ cp modelDescription_$(CSORME).xml fmu/modelDescription.xml
+ cp model.png fmu
+ @if [ ! -d ../../../fmu/$(CSORME) ]; then \
+ echo "mkdir -p ../../../fmu/$(CSORME)"; \
+ mkdir -p ../../../fmu/$(CSORME); \
+ fi
+ (cd fmu; zip -q -r ../../../../fmu/$(CSORME)/$@ *)
+
+clean:
+ (cd bouncingBall; make dirclean)
+ (cd dq; make dirclean)
+ (cd inc; make dirclean)
+ (cd values; make dirclean)
+ (cd vanDerPol; make dirclean)
+
+dirclean:
+ rm -rf *.so *.dylib *.o *.fmu *~ fmu
diff --git a/fmu20/src/models/bouncingBall/Makefile b/fmu20/src/models/bouncingBall/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu20/src/models/bouncingBall/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu20/src/models/bouncingBall/bouncingBall.c b/fmu20/src/models/bouncingBall/bouncingBall.c
new file mode 100644
index 0000000..7878d88
--- /dev/null
+++ b/fmu20/src/models/bouncingBall/bouncingBall.c
@@ -0,0 +1,121 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - a bouncing ball.
+ * This demonstrates the use of state events and reinit of states.
+ * Equations:
+ * der(h) = v;
+ * der(v) = -g;
+ * when h<0 then v := -e * v;
+ * where
+ * h height [m], used as state, start = 1
+ * v velocity of ball [m/s], used as state
+ * der(h) velocity of ball [m/s]
+ * der(v) acceleration of ball [m/s2]
+ * g acceleration of gravity [m/s2], a parameter, start = 9.81
+ * e a dimensionless parameter, start = 0.7
+ *
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER bouncingBall
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f003}"
+
+// define model size
+#define NUMBER_OF_REALS 6
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 2
+#define NUMBER_OF_EVENT_INDICATORS 1
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define h_ 0
+#define der_h_ 1
+#define v_ 2
+#define der_v_ 3
+#define g_ 4
+#define e_ 5
+
+// define initial state vector as vector of value references
+#define STATES { h_, v_ }
+
+// called by fmi2Instantiate
+// Set values for all variables that define a start value
+// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
+void setStartValues(ModelInstance *comp) {
+ r(h_) = 1;
+ r(v_) = 0;
+ r(g_) = 9.81;
+ r(e_) = 0.7;
+}
+
+// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
+// if setStartValues or environment set new values through fmi2SetXXX.
+// Lazy set values for all variable that are computed from other variables.
+void calculateValues(ModelInstance *comp) {
+ if (comp->state == modelInitializationMode) {
+ r(der_v_) = -r(g_);
+ pos(0) = r(h_) > 0;
+
+ // set first time event, if any, using comp->eventInfo.nextEventTime
+ }
+}
+
+// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
+fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr) {
+ switch (vr) {
+ case h_ : return r(h_);
+ case der_h_ : return r(v_);
+ case v_ : return r(v_);
+ case der_v_ : return r(der_v_);
+ case g_ : return r(g_);
+ case e_ : return r(e_);
+ default: return 0;
+ }
+}
+
+// offset for event indicator, adds hysteresis and prevents z=0 at restart
+#define EPS_INDICATORS 1e-14
+
+fmi2Real getEventIndicator(ModelInstance* comp, int z) {
+ switch (z) {
+ case 0 : return r(h_) + (pos(0) ? EPS_INDICATORS : -EPS_INDICATORS);
+ default: return 0;
+ }
+}
+
+// previous value of r(v_).
+fmi2Real prevV;
+
+// used to set the next time event, if any.
+void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
+ if (isNewEventIteration) {
+ prevV = r(v_);
+ }
+ pos(0) = r(h_) > 0;
+ if (!pos(0)) {
+ fmi2Real tempV = - r(e_) * prevV;
+ if (r(v_) != tempV) {
+ r(v_) = tempV;
+ eventInfo->valuesOfContinuousStatesChanged = fmi2True;
+ }
+ // avoid fall-through effect. The ball will not jump high enough, so v and der_v is set to 0 at this surface impact.
+ if (r(v_) < 1e-3) {
+ r(v_) = 0;
+ r(der_v_) = 0; // turn off gravity.
+ }
+ }
+ eventInfo->nominalsOfContinuousStatesChanged = fmi2False;
+ eventInfo->terminateSimulation = fmi2False;
+ eventInfo->nextEventTimeDefined = fmi2False;
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu20/src/models/bouncingBall/index.html b/fmu20/src/models/bouncingBall/index.html
new file mode 100644
index 0000000..35a59f0
--- /dev/null
+++ b/fmu20/src/models/bouncingBall/index.html
@@ -0,0 +1,55 @@
+
+
+ Documentation for bouncingBall.fmu
+
+
+
+bouncingBall.fmu
+The bouncingBall implements the following equation:
+
+- der(h) = v;
+
- der(v) = -g;
+
- when h<0 then v := -e* v
+
+with start values h=1, e=0.7, g = 9.81 and
+
+- h: height [m], used as state
+
- v: velocity of ball [m/s], used as state
+
- der(h): velocity of ball [m/s]
+
- der(v): acceleration of ball [m/s2]
+
- g: acceleration of gravity [m/s2], a parameter
+
- e: a dimensionless parameter
+
+
+
+
+
+The figure shows the solution computed with Silver
+for height h of the ball for the start values given above.
+
+
+The chain of events during simulation is as follows
+
+- initially h>0 and pos(0)=true
+- continuous integration until a state event is detected, i.e.
+ until h + EPS_INDICATORS = 0.
+ At this time h < 0, the EPS_INDICATORS adds hysteresis.
+- the simulator calls eventUpdate once which reverses the speed direction
+ v of the ball: v = -e * v, and sets pos(0)=false
+- continuous integration until state event is detected, i.e.
+ until h - EPS_INDICATORS = 0.
+ At this time h > 0, the EPS_INDICATORS adds hysteresis.
+- the simulator calls eventUpdate once more which sets pos(0)=true.
+- goto 2
+
+The above description refers to the variables used
+in file bouncingBall.c
.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
diff --git a/fmu20/src/models/bouncingBall/model.png b/fmu20/src/models/bouncingBall/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu20/src/models/bouncingBall/model.png differ
diff --git a/fmu20/src/models/bouncingBall/modelDescription_cs.xml b/fmu20/src/models/bouncingBall/modelDescription_cs.xml
new file mode 100644
index 0000000..5c642ff
--- /dev/null
+++ b/fmu20/src/models/bouncingBall/modelDescription_cs.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/bouncingBall/modelDescription_me.xml b/fmu20/src/models/bouncingBall/modelDescription_me.xml
new file mode 100644
index 0000000..621e410
--- /dev/null
+++ b/fmu20/src/models/bouncingBall/modelDescription_me.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/bouncingBall/plot_h.PNG b/fmu20/src/models/bouncingBall/plot_h.PNG
new file mode 100644
index 0000000..303ede5
Binary files /dev/null and b/fmu20/src/models/bouncingBall/plot_h.PNG differ
diff --git a/fmu20/src/models/build_fmu b/fmu20/src/models/build_fmu
new file mode 100644
index 0000000..a58f366
--- /dev/null
+++ b/fmu20/src/models/build_fmu
@@ -0,0 +1,55 @@
+#!/bin/sh
+# Build a model exchange or co-simulation fmu
+# Usage: build_fmu cs|me directory
+
+if [ $# -ne 2 ]; then
+ echo "Usage: $0 cs|me directory"
+ exit 2
+fi
+
+csOrMe=$1
+directory=$2
+
+# Error checking
+if [ "$csOrMe" != "me" -a "$csOrMe" != "cs" ]; then
+ echo "$0: first argument must be either 'me' or 'cs', not $csOrMe"
+ exit 3
+fi
+
+if [ ! -d $directory ]; then
+ echo "$0: directory $directory does not exist"
+ exit 4
+fi
+
+include="-DDISABLE_PREFIX -I../../shared/include"
+
+case "`uname -s`" in
+ CYGWIN*) arch=win
+ sharedLibrarySuffix=dll;;
+ Darwin) arch=darwin
+ sharedLibrarySuffix=dylib;;
+ Linux) arch=linux
+ pic=-fPIC
+ sharedLibrarySuffix=so;;
+esac
+
+# Number of bits, default to 64
+bits=64
+case "`uname -m`" in
+ *64) bits=64;;
+ *32) bits=32;;
+ *i[3-6]86) bits=32;;
+esac
+
+# Uncomment the next line to force building 32-bit
+#bits=32
+# See also ../Makefile
+
+if [ $arch = linux -a $bits = 32 ]; then
+ CBITSFLAGS=-m32
+fi
+
+set -x
+(cd $directory; \
+ make dirclean; \
+ make ARCH=${arch}${bits} CBITSFLAGS=${CBITSFLAGS} CSORME=${csOrMe} INCLUDE="${include}" PIC=${pic} SHARED_LIBRARY_SUFFIX=${sharedLibrarySuffix} $directory.fmu)
diff --git a/fmu20/src/models/build_fmu.bat b/fmu20/src/models/build_fmu.bat
new file mode 100644
index 0000000..ea6e214
--- /dev/null
+++ b/fmu20/src/models/build_fmu.bat
@@ -0,0 +1,93 @@
+@echo off
+rem ------------------------------------------------------------
+rem This batch builds an FMU of the FMU SDK
+rem Usage: build_fmu (me|cs) (-win64)
+rem Copyright QTronic GmbH. All rights reserved
+rem ------------------------------------------------------------
+
+setlocal
+
+echo -----------------------------------------------------------
+if %1==cs (^
+echo building FMU %2 - FMI for Co-Simulation 2.0) else ^
+echo building FMU %2 - FMI for Model Exchange 2.0
+
+rem save env variable settings
+set PREV_PATH=%PATH%
+if defined INCLUDE set PREV_INCLUDE=%INLUDE%
+if defined LIB set PREV_LIB=%LIB%
+if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
+
+if "%3"=="-win64" (set x64=x64\) else set x64=
+
+rem setup the compiler
+if defined x64 (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
+goto noCompiler
+) else (
+if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
+if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
+if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
+if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
+if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
+if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
+goto noCompiler
+)
+
+rem create the %2.dll in the temp dir
+if not exist temp mkdir temp
+pushd temp
+if exist *.dll del /Q *.dll
+
+cl /LD /nologo /DDISABLE_PREFIX ..\%2\%2.c /I ..\. /I ..\..\shared\include
+if not exist %2.dll goto compileError
+
+rem create FMU dir structure with root 'fmu'
+if defined x64 (set BIN_DIR=fmu\binaries\win64) else set BIN_DIR=fmu\binaries\win32
+set SRC_DIR=fmu\sources
+set DOC_DIR=fmu\documentation
+if not exist %BIN_DIR% mkdir %BIN_DIR%
+if not exist %SRC_DIR% mkdir %SRC_DIR%
+if not exist %DOC_DIR% mkdir %DOC_DIR%
+move /Y %2.dll %BIN_DIR%
+if exist ..\%2\*~ del /Q ..\%2\*~
+copy ..\%2\%2.c %SRC_DIR%
+type ..\%2\modelDescription_%1.xml > fmu\modelDescription.xml
+copy ..\%2\model.png fmu
+copy ..\fmuTemplate.c %SRC_DIR%
+copy ..\fmuTemplate.h %SRC_DIR%
+copy ..\%2\*.html %DOC_DIR%
+copy ..\%2\*.png %DOC_DIR%
+del %DOC_DIR%\model.png
+
+rem zip the directory tree and move to fmu directory
+cd fmu
+set FMU_FILE=..\..\..\..\fmu\%1\%x64%%2.fmu
+if exist %FMU_FILE% del %FMU_FILE%
+..\..\..\..\bin\7z.exe a -tzip %FMU_FILE% ^
+ modelDescription.xml model.png binaries sources documentation
+goto cleanup
+
+:noCompiler
+echo No Microsoft Visual C compiler found
+
+:compileError
+echo build of %2 failed
+
+:cleanup
+popd
+if exist temp rmdir /S /Q temp
+
+rem undo variable settings performed by vsvars32.bat
+set PATH=%PREV_PATH%
+if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
+if defined PREV_LIB set LIB=%PREV_LIB%
+if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
+echo done.
+
+endlocal
diff --git a/fmu20/src/models/dq/Makefile b/fmu20/src/models/dq/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu20/src/models/dq/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu20/src/models/dq/dq.c b/fmu20/src/models/dq/dq.c
new file mode 100644
index 0000000..38bea97
--- /dev/null
+++ b/fmu20/src/models/dq/dq.c
@@ -0,0 +1,71 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - the Dahlquist test equation.
+ *
+ * der(x) = - k * x and x(0) = 1.
+ * Analytical solution: x(t) = exp(-k*t).
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER dq
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f000}"
+
+// define model size
+#define NUMBER_OF_REALS 3
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 1
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x_ 0
+#define der_x_ 1
+#define k_ 2
+
+// define state vector as vector of value references
+#define STATES { x_ }
+
+// called by fmi2Instantiate
+// Set values for all variables that define a start value
+// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
+void setStartValues(ModelInstance *comp) {
+ r(x_) = 1;
+ r(k_) = 1;
+}
+
+// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
+// if setStartValues or environment set new values through fmi2SetXXX.
+// Lazy set values for all variable that are computed from other variables.
+void calculateValues(ModelInstance *comp) {
+ //if (comp->state == modelInitializationMode) {
+ // initialization code here
+ // set first time event, if any, using comp->eventInfo.nextEventTime
+ //}
+}
+
+// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
+fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr){
+ switch (vr) {
+ case x_ : return r(x_);
+ case der_x_ : return - r(k_) * r(x_);
+ case k_ : return r(k_);
+ default: return 0;
+ }
+}
+
+// used to set the next time event, if any.
+void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
+
+
diff --git a/fmu20/src/models/dq/index.html b/fmu20/src/models/dq/index.html
new file mode 100644
index 0000000..833f256
--- /dev/null
+++ b/fmu20/src/models/dq/index.html
@@ -0,0 +1,33 @@
+
+
+Documentation for dq.fmu
+
+
+
+dq.fmu
+This FMU implements the equation
+
+The analytical solution of this system is
+
+The above equation is also known as
+Dahlquist
+test equation.
+
+
+
+The figure shows the solution for x computed with Silver
+for start values k = 1 and x = 1.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu20/src/models/dq/model.png b/fmu20/src/models/dq/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu20/src/models/dq/model.png differ
diff --git a/fmu20/src/models/dq/modelDescription_cs.xml b/fmu20/src/models/dq/modelDescription_cs.xml
new file mode 100644
index 0000000..25bc698
--- /dev/null
+++ b/fmu20/src/models/dq/modelDescription_cs.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/dq/modelDescription_me.xml b/fmu20/src/models/dq/modelDescription_me.xml
new file mode 100644
index 0000000..5dadf70
--- /dev/null
+++ b/fmu20/src/models/dq/modelDescription_me.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/dq/plot_x.PNG b/fmu20/src/models/dq/plot_x.PNG
new file mode 100644
index 0000000..b28fa66
Binary files /dev/null and b/fmu20/src/models/dq/plot_x.PNG differ
diff --git a/fmu20/src/models/fmuTemplate.c b/fmu20/src/models/fmuTemplate.c
new file mode 100644
index 0000000..dce4285
--- /dev/null
+++ b/fmu20/src/models/fmuTemplate.c
@@ -0,0 +1,921 @@
+/* ---------------------------------------------------------------------------*
+ * fmuTemplate.c
+ * Implementation of the FMI interface based on functions and macros to
+ * be defined by the includer of this file.
+ * The "FMI for Co-Simulation 2.0", implementation assumes that exactly the
+ * following capability flags are set to fmi2True:
+ * canHandleVariableCommunicationStepSize, i.e. fmi2DoStep step size can vary
+ * and all other capability flags are set to default, i.e. to fmi2False or 0.
+ *
+ * Revision history
+ * 07.03.2014 initial version released in FMU SDK 2.0.0
+ * 02.04.2014 allow modules to request termination of simulation, better time
+ * event handling, initialize() moved from fmi2EnterInitialization to
+ * fmi2ExitInitialization, correct logging message format in fmi2DoStep.
+ * 10.04.2014 use FMI 2.0 headers that prefix function and types names with 'fmi2'.
+ * 13.06.2014 when fmi2setDebugLogging is called with 0 categories, set all
+ * categories to loggingOn value.
+ * 09.07.2014 track all states of Model-exchange and Co-simulation and check
+ * the allowed calling sequences, explicit isTimeEvent parameter for
+ * eventUpdate function of the model, lazy computation of computed values.
+ *
+ * Author: Adrian Tirea
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// macro to be used to log messages. The macro check if current
+// log category is valid and, if true, call the logger provided by simulator.
+#define FILTERED_LOG(instance, status, categoryIndex, message, ...) if (status == fmi2Error || status == fmi2Fatal || isCategoryLogged(instance, categoryIndex)) \
+ instance->functions->logger(instance->functions->componentEnvironment, instance->instanceName, status, \
+ logCategoriesNames[categoryIndex], message, ##__VA_ARGS__);
+
+static fmi2String logCategoriesNames[] = {"logAll", "logError", "logFmiCall", "logEvent"};
+
+// array of value references of states
+#if NUMBER_OF_STATES>0
+fmi2ValueReference vrStates[NUMBER_OF_STATES] = STATES;
+#endif
+
+#ifndef max
+#define max(a,b) ((a)>(b) ? (a) : (b))
+#endif
+
+// ---------------------------------------------------------------------------
+// Private helpers used below to validate function arguments
+// ---------------------------------------------------------------------------
+
+fmi2Boolean isCategoryLogged(ModelInstance *comp, int categoryIndex);
+
+static fmi2Boolean invalidNumber(ModelInstance *comp, const char *f, const char *arg, int n, int nExpected) {
+ if (n != nExpected) {
+ comp->state = modelError;
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Invalid argument %s = %d. Expected %d.", f, arg, n, nExpected)
+ return fmi2True;
+ }
+ return fmi2False;
+}
+
+static fmi2Boolean invalidState(ModelInstance *comp, const char *f, int statesExpected) {
+ if (!comp)
+ return fmi2True;
+ if (!(comp->state & statesExpected)) {
+ comp->state = modelError;
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Illegal call sequence.", f)
+ return fmi2True;
+ }
+ return fmi2False;
+}
+
+static fmi2Boolean nullPointer(ModelInstance* comp, const char *f, const char *arg, const void *p) {
+ if (!p) {
+ comp->state = modelError;
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Invalid argument %s = NULL.", f, arg)
+ return fmi2True;
+ }
+ return fmi2False;
+}
+
+static fmi2Boolean vrOutOfRange(ModelInstance *comp, const char *f, fmi2ValueReference vr, int end) {
+ if (vr >= end) {
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Illegal value reference %u.", f, vr)
+ comp->state = modelError;
+ return fmi2True;
+ }
+ return fmi2False;
+}
+
+static fmi2Status unsupportedFunction(fmi2Component c, const char *fName, int statesExpected) {
+ ModelInstance *comp = (ModelInstance *)c;
+ fmi2CallbackLogger log = comp->functions->logger;
+ if (invalidState(comp, fName, statesExpected))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, fName);
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Function not implemented.", fName)
+ return fmi2Error;
+}
+
+fmi2Status setString(fmi2Component comp, fmi2ValueReference vr, fmi2String value) {
+ return fmi2SetString(comp, &vr, 1, &value);
+}
+
+// ---------------------------------------------------------------------------
+// Private helpers logger
+// ---------------------------------------------------------------------------
+
+// return fmi2True if logging category is on. Else return fmi2False.
+fmi2Boolean isCategoryLogged(ModelInstance *comp, int categoryIndex) {
+ if (categoryIndex < NUMBER_OF_CATEGORIES
+ && (comp->logCategories[categoryIndex] || comp->logCategories[LOG_ALL])) {
+ return fmi2True;
+ }
+ return fmi2False;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions
+// ---------------------------------------------------------------------------
+fmi2Component fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID,
+ fmi2String fmuResourceLocation, const fmi2CallbackFunctions *functions,
+ fmi2Boolean visible, fmi2Boolean loggingOn) {
+ // ignoring arguments: fmuResourceLocation, visible
+ ModelInstance *comp;
+ if (!functions->logger) {
+ return NULL;
+ }
+
+ if (!functions->allocateMemory || !functions->freeMemory) {
+ functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
+ "fmi2Instantiate: Missing callback function.");
+ return NULL;
+ }
+ if (!instanceName || strlen(instanceName) == 0) {
+ functions->logger(functions->componentEnvironment, "?", fmi2Error, "error",
+ "fmi2Instantiate: Missing instance name.");
+ return NULL;
+ }
+ if (!fmuGUID || strlen(fmuGUID) == 0) {
+ functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
+ "fmi2Instantiate: Missing GUID.");
+ return NULL;
+ }
+ if (strcmp(fmuGUID, MODEL_GUID)) {
+ functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
+ "fmi2Instantiate: Wrong GUID %s. Expected %s.", fmuGUID, MODEL_GUID);
+ return NULL;
+ }
+ comp = (ModelInstance *)functions->allocateMemory(1, sizeof(ModelInstance));
+ if (comp) {
+ int i;
+ comp->r = (fmi2Real *) functions->allocateMemory(NUMBER_OF_REALS, sizeof(fmi2Real));
+ comp->i = (fmi2Integer *)functions->allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmi2Integer));
+ comp->b = (fmi2Boolean *)functions->allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmi2Boolean));
+ comp->s = (fmi2String *) functions->allocateMemory(NUMBER_OF_STRINGS, sizeof(fmi2String));
+ comp->isPositive = (fmi2Boolean *)functions->allocateMemory(NUMBER_OF_EVENT_INDICATORS,
+ sizeof(fmi2Boolean));
+ comp->instanceName = (char *)functions->allocateMemory(1 + strlen(instanceName), sizeof(char));
+ comp->GUID = (char *)functions->allocateMemory(1 + strlen(fmuGUID), sizeof(char));
+
+ // set all categories to on or off. fmi2SetDebugLogging should be called to choose specific categories.
+ for (i = 0; i < NUMBER_OF_CATEGORIES; i++) {
+ comp->logCategories[i] = loggingOn;
+ }
+ }
+ if (!comp || !comp->r || !comp->i || !comp->b || !comp->s || !comp->isPositive
+ || !comp->instanceName || !comp->GUID) {
+
+ functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
+ "fmi2Instantiate: Out of memory.");
+ return NULL;
+ }
+ comp->time = 0; // overwrite in fmi2SetupExperiment, fmi2SetTime
+ strcpy((char *)comp->instanceName, (char *)instanceName);
+ comp->type = fmuType;
+ strcpy((char *)comp->GUID, (char *)fmuGUID);
+ comp->functions = functions;
+ comp->componentEnvironment = functions->componentEnvironment;
+ comp->loggingOn = loggingOn;
+ comp->state = modelInstantiated;
+ setStartValues(comp); // to be implemented by the includer of this file
+ comp->isDirtyValues = fmi2True; // because we just called setStartValues
+ comp->isNewEventIteration = fmi2False;
+
+ comp->eventInfo.newDiscreteStatesNeeded = fmi2False;
+ comp->eventInfo.terminateSimulation = fmi2False;
+ comp->eventInfo.nominalsOfContinuousStatesChanged = fmi2False;
+ comp->eventInfo.valuesOfContinuousStatesChanged = fmi2False;
+ comp->eventInfo.nextEventTimeDefined = fmi2False;
+ comp->eventInfo.nextEventTime = 0;
+
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Instantiate: GUID=%s", fmuGUID)
+
+ return comp;
+}
+
+fmi2Status fmi2SetupExperiment(fmi2Component c, fmi2Boolean toleranceDefined, fmi2Real tolerance,
+ fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime) {
+
+ // ignore arguments: stopTimeDefined, stopTime
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetupExperiment", MASK_fmi2SetupExperiment))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetupExperiment: toleranceDefined=%d tolerance=%g",
+ toleranceDefined, tolerance)
+
+ comp->time = startTime;
+ return fmi2OK;
+}
+
+fmi2Status fmi2EnterInitializationMode(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2EnterInitializationMode", MASK_fmi2EnterInitializationMode))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2EnterInitializationMode")
+
+ comp->state = modelInitializationMode;
+ return fmi2OK;
+}
+
+fmi2Status fmi2ExitInitializationMode(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2ExitInitializationMode", MASK_fmi2ExitInitializationMode))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2ExitInitializationMode")
+
+ // if values were set and no fmi2GetXXX triggered update before,
+ // ensure calculated values are updated now
+ if (comp->isDirtyValues) {
+ calculateValues(comp);
+ comp->isDirtyValues = fmi2False;
+ }
+
+ if (comp->type == fmi2ModelExchange) {
+ comp->state = modelEventMode;
+ comp->isNewEventIteration = fmi2True;
+ }
+ else comp->state = modelStepComplete;
+ return fmi2OK;
+}
+
+fmi2Status fmi2Terminate(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2Terminate", MASK_fmi2Terminate))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Terminate")
+
+ comp->state = modelTerminated;
+ return fmi2OK;
+}
+
+fmi2Status fmi2Reset(fmi2Component c) {
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2Reset", MASK_fmi2Reset))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Reset")
+
+ comp->state = modelInstantiated;
+ setStartValues(comp); // to be implemented by the includer of this file
+ comp->isDirtyValues = fmi2True; // because we just called setStartValues
+ return fmi2OK;
+}
+
+void fmi2FreeInstance(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (!comp) return;
+ if (invalidState(comp, "fmi2FreeInstance", MASK_fmi2FreeInstance))
+ return;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2FreeInstance")
+
+ if (comp->r) comp->functions->freeMemory(comp->r);
+ if (comp->i) comp->functions->freeMemory(comp->i);
+ if (comp->b) comp->functions->freeMemory(comp->b);
+ if (comp->s) {
+ int i;
+ for (i = 0; i < NUMBER_OF_STRINGS; i++){
+ if (comp->s[i]) comp->functions->freeMemory((void *)comp->s[i]);
+ }
+ comp->functions->freeMemory((void *)comp->s);
+ }
+ if (comp->isPositive) comp->functions->freeMemory(comp->isPositive);
+ if (comp->instanceName) comp->functions->freeMemory((void *)comp->instanceName);
+ if (comp->GUID) comp->functions->freeMemory((void *)comp->GUID);
+ comp->functions->freeMemory(comp);
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: class methods not depending of a specific model instance
+// ---------------------------------------------------------------------------
+
+const char* fmi2GetVersion() {
+ return fmi2Version;
+}
+
+const char* fmi2GetTypesPlatform() {
+ return fmi2TypesPlatform;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: logging control, setters and getters for Real, Integer,
+// Boolean, String
+// ---------------------------------------------------------------------------
+
+fmi2Status fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[]) {
+ int i, j;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetDebugLogging", MASK_fmi2SetDebugLogging))
+ return fmi2Error;
+ comp->loggingOn = loggingOn;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetDebugLogging")
+
+ // reset all categories
+ for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
+ comp->logCategories[j] = fmi2False;
+ }
+
+ if (nCategories == 0) {
+ // no category specified, set all categories to have loggingOn value
+ for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
+ comp->logCategories[j] = loggingOn;
+ }
+ } else {
+ // set specific categories on
+ for (i = 0; i < nCategories; i++) {
+ fmi2Boolean categoryFound = fmi2False;
+ for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
+ if (strcmp(logCategoriesNames[j], categories[i]) == 0) {
+ comp->logCategories[j] = loggingOn;
+ categoryFound = fmi2True;
+ break;
+ }
+ }
+ if (!categoryFound) {
+ comp->functions->logger(comp->componentEnvironment, comp->instanceName, fmi2Warning,
+ logCategoriesNames[LOG_ERROR],
+ "logging category '%s' is not supported by model", categories[i]);
+ }
+ }
+ }
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetReal (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetReal", MASK_fmi2GetReal))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "vr[]", vr))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "value[]", value))
+ return fmi2Error;
+ if (nvr > 0 && comp->isDirtyValues) {
+ calculateValues(comp);
+ comp->isDirtyValues = fmi2False;
+ }
+#if NUMBER_OF_REALS > 0
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2GetReal", vr[i], NUMBER_OF_REALS))
+ return fmi2Error;
+ value[i] = getReal(comp, vr[i]); // to be implemented by the includer of this file
+
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetReal: #r%u# = %.16g", vr[i], value[i])
+ }
+#endif
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetInteger", MASK_fmi2GetInteger))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetInteger", "vr[]", vr))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetInteger", "value[]", value))
+ return fmi2Error;
+ if (nvr > 0 && comp->isDirtyValues) {
+ calculateValues(comp);
+ comp->isDirtyValues = fmi2False;
+ }
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2GetInteger", vr[i], NUMBER_OF_INTEGERS))
+ return fmi2Error;
+ value[i] = comp->i[vr[i]];
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetInteger: #i%u# = %d", vr[i], value[i])
+ }
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetBoolean", MASK_fmi2GetBoolean))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetBoolean", "vr[]", vr))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2GetBoolean", "value[]", value))
+ return fmi2Error;
+ if (nvr > 0 && comp->isDirtyValues) {
+ calculateValues(comp);
+ comp->isDirtyValues = fmi2False;
+ }
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2GetBoolean", vr[i], NUMBER_OF_BOOLEANS))
+ return fmi2Error;
+ value[i] = comp->b[vr[i]];
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetBoolean: #b%u# = %s", vr[i], value[i]? "true" : "false")
+ }
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetString (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetString", MASK_fmi2GetString))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2GetString", "vr[]", vr))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2GetString", "value[]", value))
+ return fmi2Error;
+ if (nvr > 0 && comp->isDirtyValues) {
+ calculateValues(comp);
+ comp->isDirtyValues = fmi2False;
+ }
+ for (i=0; is[vr[i]];
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetString: #s%u# = '%s'", vr[i], value[i])
+ }
+ return fmi2OK;
+}
+
+fmi2Status fmi2SetReal (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetReal", MASK_fmi2SetReal))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2SetReal", "vr[]", vr))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2SetReal", "value[]", value))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetReal: nvr = %d", nvr)
+ // no check whether setting the value is allowed in the current state
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2SetReal", vr[i], NUMBER_OF_REALS))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetReal: #r%d# = %.16g", vr[i], value[i])
+ comp->r[vr[i]] = value[i];
+ }
+ if (nvr > 0) comp->isDirtyValues = fmi2True;
+ return fmi2OK;
+}
+
+fmi2Status fmi2SetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetInteger", MASK_fmi2SetInteger))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2SetInteger", "vr[]", vr))
+ return fmi2Error;
+ if (nvr > 0 && nullPointer(comp, "fmi2SetInteger", "value[]", value))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetInteger: nvr = %d", nvr)
+
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2SetInteger", vr[i], NUMBER_OF_INTEGERS))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetInteger: #i%d# = %d", vr[i], value[i])
+ comp->i[vr[i]] = value[i];
+ }
+ if (nvr > 0) comp->isDirtyValues = fmi2True;
+ return fmi2OK;
+}
+
+fmi2Status fmi2SetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetBoolean", MASK_fmi2SetBoolean))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2SetBoolean", "vr[]", vr))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2SetBoolean", "value[]", value))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetBoolean: nvr = %d", nvr)
+
+ for (i = 0; i < nvr; i++) {
+ if (vrOutOfRange(comp, "fmi2SetBoolean", vr[i], NUMBER_OF_BOOLEANS))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetBoolean: #b%d# = %s", vr[i], value[i] ? "true" : "false")
+ comp->b[vr[i]] = value[i];
+ }
+ if (nvr > 0) comp->isDirtyValues = fmi2True;
+ return fmi2OK;
+}
+
+fmi2Status fmi2SetString (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) {
+ int i, n;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetString", MASK_fmi2SetString))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2SetString", "vr[]", vr))
+ return fmi2Error;
+ if (nvr>0 && nullPointer(comp, "fmi2SetString", "value[]", value))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetString: nvr = %d", nvr)
+
+ for (i = 0; i < nvr; i++) {
+ char *string = (char *)comp->s[vr[i]];
+ if (vrOutOfRange(comp, "fmi2SetString", vr[i], NUMBER_OF_STRINGS))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetString: #s%d# = '%s'", vr[i], value[i])
+
+ if (value[i] == NULL) {
+ if (string) comp->functions->freeMemory(string);
+ comp->s[vr[i]] = NULL;
+ FILTERED_LOG(comp, fmi2Warning, LOG_ERROR, "fmi2SetString: string argument value[%d] = NULL.", i);
+ } else {
+ if (string == NULL || strlen(string) < strlen(value[i])) {
+ if (string) comp->functions->freeMemory(string);
+ comp->s[vr[i]] = (char *)comp->functions->allocateMemory(1 + strlen(value[i]), sizeof(char));
+ if (!comp->s[vr[i]]) {
+ comp->state = modelError;
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "fmi2SetString: Out of memory.")
+ return fmi2Error;
+ }
+ }
+ strcpy((char *)comp->s[vr[i]], (char *)value[i]);
+ }
+ }
+ if (nvr > 0) comp->isDirtyValues = fmi2True;
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetFMUstate (fmi2Component c, fmi2FMUstate* FMUstate) {
+ return unsupportedFunction(c, "fmi2GetFMUstate", MASK_fmi2GetFMUstate);
+}
+fmi2Status fmi2SetFMUstate (fmi2Component c, fmi2FMUstate FMUstate) {
+ return unsupportedFunction(c, "fmi2SetFMUstate", MASK_fmi2SetFMUstate);
+}
+fmi2Status fmi2FreeFMUstate(fmi2Component c, fmi2FMUstate* FMUstate) {
+ return unsupportedFunction(c, "fmi2FreeFMUstate", MASK_fmi2FreeFMUstate);
+}
+fmi2Status fmi2SerializedFMUstateSize(fmi2Component c, fmi2FMUstate FMUstate, size_t *size) {
+ return unsupportedFunction(c, "fmi2SerializedFMUstateSize", MASK_fmi2SerializedFMUstateSize);
+}
+fmi2Status fmi2SerializeFMUstate (fmi2Component c, fmi2FMUstate FMUstate, fmi2Byte serializedState[], size_t size) {
+ return unsupportedFunction(c, "fmi2SerializeFMUstate", MASK_fmi2SerializeFMUstate);
+}
+fmi2Status fmi2DeSerializeFMUstate (fmi2Component c, const fmi2Byte serializedState[], size_t size,
+ fmi2FMUstate* FMUstate) {
+ return unsupportedFunction(c, "fmi2DeSerializeFMUstate", MASK_fmi2DeSerializeFMUstate);
+}
+
+fmi2Status fmi2GetDirectionalDerivative(fmi2Component c, const fmi2ValueReference vUnknown_ref[], size_t nUnknown,
+ const fmi2ValueReference vKnown_ref[] , size_t nKnown,
+ const fmi2Real dvKnown[], fmi2Real dvUnknown[]) {
+ return unsupportedFunction(c, "fmi2GetDirectionalDerivative", MASK_fmi2GetDirectionalDerivative);
+}
+
+// ---------------------------------------------------------------------------
+// Functions for FMI for Co-Simulation
+// ---------------------------------------------------------------------------
+/* Simulating the slave */
+fmi2Status fmi2SetRealInputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
+ const fmi2Integer order[], const fmi2Real value[]) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetRealInputDerivatives", MASK_fmi2SetRealInputDerivatives)) {
+ return fmi2Error;
+ }
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetRealInputDerivatives: nvr= %d", nvr)
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "fmi2SetRealInputDerivatives: ignoring function call."
+ " This model cannot interpolate inputs: canInterpolateInputs=\"fmi2False\"")
+ return fmi2Error;
+}
+
+fmi2Status fmi2GetRealOutputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
+ const fmi2Integer order[], fmi2Real value[]) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetRealOutputDerivatives", MASK_fmi2GetRealOutputDerivatives))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetRealOutputDerivatives: nvr= %d", nvr)
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR,"fmi2GetRealOutputDerivatives: ignoring function call."
+ " This model cannot compute derivatives of outputs: MaxOutputDerivativeOrder=\"0\"")
+ for (i = 0; i < nvr; i++) value[i] = 0;
+ return fmi2Error;
+}
+
+fmi2Status fmi2CancelStep(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2CancelStep", MASK_fmi2CancelStep)) {
+ // always fmi2CancelStep is invalid, because model is never in modelStepInProgress state.
+ return fmi2Error;
+ }
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2CancelStep")
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR,"fmi2CancelStep: Can be called when fmi2DoStep returned fmi2Pending."
+ " This is not the case.");
+ // comp->state = modelStepCanceled;
+ return fmi2Error;
+}
+
+fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint,
+ fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint) {
+ ModelInstance *comp = (ModelInstance *)c;
+ double h = communicationStepSize / 10;
+ int k,i;
+ const int n = 10; // how many Euler steps to perform for one do step
+ double prevState[max(NUMBER_OF_STATES, 1)];
+ double prevEventIndicators[max(NUMBER_OF_EVENT_INDICATORS, 1)];
+ int stateEvent = 0;
+ int timeEvent = 0;
+
+ if (invalidState(comp, "fmi2DoStep", MASK_fmi2DoStep))
+ return fmi2Error;
+
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2DoStep: "
+ "currentCommunicationPoint = %g, "
+ "communicationStepSize = %g, "
+ "noSetFMUStatePriorToCurrentPoint = fmi2%s",
+ currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint ? "True" : "False")
+
+ if (communicationStepSize <= 0) {
+ FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
+ "fmi2DoStep: communication step size must be > 0. Fount %g.", communicationStepSize)
+ comp->state = modelError;
+ return fmi2Error;
+ }
+
+#if NUMBER_OF_EVENT_INDICATORS>0
+ // initialize previous event indicators with current values
+ for (i = 0; i < NUMBER_OF_EVENT_INDICATORS; i++) {
+ prevEventIndicators[i] = getEventIndicator(comp, i);
+ }
+#endif
+
+ // break the step into n steps and do forward Euler.
+ comp->time = currentCommunicationPoint;
+ for (k = 0; k < n; k++) {
+ comp->time += h;
+
+#if NUMBER_OF_STATES>0
+ for (i = 0; i < NUMBER_OF_STATES; i++) {
+ prevState[i] = r(vrStates[i]);
+ }
+ for (i = 0; i < NUMBER_OF_STATES; i++) {
+ fmi2ValueReference vr = vrStates[i];
+ r(vr) += h * getReal(comp, vr + 1); // forward Euler step
+ }
+#endif
+
+#if NUMBER_OF_EVENT_INDICATORS>0
+ // check for state event
+ for (i = 0; i < NUMBER_OF_EVENT_INDICATORS; i++) {
+ double ei = getEventIndicator(comp, i);
+ if (ei * prevEventIndicators[i] < 0) {
+ FILTERED_LOG(comp, fmi2OK, LOG_EVENT,
+ "fmi2DoStep: state event at %g, z%d crosses zero -%c-", comp->time, i, ei < 0 ? '\\' : '/')
+ stateEvent++;
+ }
+ prevEventIndicators[i] = ei;
+ }
+#endif
+ // check for time event
+ if (comp->eventInfo.nextEventTimeDefined && ((comp->time - comp->eventInfo.nextEventTime) > -0.0000000001)) {
+ FILTERED_LOG(comp, fmi2OK, LOG_EVENT, "fmi2DoStep: time event detected at %g", comp->time)
+ timeEvent = 1;
+ }
+
+ if (stateEvent || timeEvent) {
+ eventUpdate(comp, &comp->eventInfo, timeEvent, fmi2True);
+ timeEvent = 0;
+ stateEvent = 0;
+ }
+
+ // terminate simulation, if requested by the model in the previous step
+ if (comp->eventInfo.terminateSimulation) {
+ FILTERED_LOG(comp, fmi2Discard, LOG_ALL, "fmi2DoStep: model requested termination at t=%g", comp->time)
+ comp->state = modelStepFailed;
+ return fmi2Discard; // enforce termination of the simulation loop
+ }
+ }
+ return fmi2OK;
+}
+
+/* Inquire slave status */
+static fmi2Status getStatus(char* fname, fmi2Component c, const fmi2StatusKind s) {
+ const char *statusKind[3] = {"fmi2DoStepStatus","fmi2PendingStatus","fmi2LastSuccessfulTime"};
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, fname, MASK_fmi2GetStatus)) // all get status have the same MASK_fmi2GetStatus
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "$s: fmi2StatusKind = %s", fname, statusKind[s])
+
+ switch(s) {
+ case fmi2DoStepStatus: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
+ "%s: Can be called with fmi2DoStepStatus when fmi2DoStep returned fmi2Pending."
+ " This is not the case.", fname)
+ break;
+ case fmi2PendingStatus: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
+ "%s: Can be called with fmi2PendingStatus when fmi2DoStep returned fmi2Pending."
+ " This is not the case.", fname)
+ break;
+ case fmi2LastSuccessfulTime: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
+ "%s: Can be called with fmi2LastSuccessfulTime when fmi2DoStep returned fmi2Discard."
+ " This is not the case.", fname)
+ break;
+ case fmi2Terminated: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
+ "%s: Can be called with fmi2Terminated when fmi2DoStep returned fmi2Discard."
+ " This is not the case.", fname)
+ break;
+ }
+ return fmi2Discard;
+}
+
+fmi2Status fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status *value) {
+ return getStatus("fmi2GetStatus", c, s);
+}
+
+fmi2Status fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real *value) {
+ if (s == fmi2LastSuccessfulTime) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetRealStatus", MASK_fmi2GetRealStatus))
+ return fmi2Error;
+ *value = comp->time;
+ return fmi2OK;
+ }
+ return getStatus("fmi2GetRealStatus", c, s);
+}
+
+fmi2Status fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value) {
+ return getStatus("fmi2GetIntegerStatus", c, s);
+}
+
+fmi2Status fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value) {
+ if (s == fmi2Terminated) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetBooleanStatus", MASK_fmi2GetBooleanStatus))
+ return fmi2Error;
+ *value = comp->eventInfo.terminateSimulation;
+ return fmi2OK;
+ }
+ return getStatus("fmi2GetBooleanStatus", c, s);
+}
+
+fmi2Status fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String *value) {
+ return getStatus("fmi2GetStringStatus", c, s);
+}
+
+// ---------------------------------------------------------------------------
+// Functions for FMI2 for Model Exchange
+// ---------------------------------------------------------------------------
+/* Enter and exit the different modes */
+fmi2Status fmi2EnterEventMode(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2EnterEventMode", MASK_fmi2EnterEventMode))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2EnterEventMode")
+
+ comp->state = modelEventMode;
+ comp->isNewEventIteration = fmi2True;
+ return fmi2OK;
+}
+
+fmi2Status fmi2NewDiscreteStates(fmi2Component c, fmi2EventInfo *eventInfo) {
+ ModelInstance *comp = (ModelInstance *)c;
+ int timeEvent = 0;
+ if (invalidState(comp, "fmi2NewDiscreteStates", MASK_fmi2NewDiscreteStates))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2NewDiscreteStates")
+
+ comp->eventInfo.newDiscreteStatesNeeded = fmi2False;
+ comp->eventInfo.terminateSimulation = fmi2False;
+ comp->eventInfo.nominalsOfContinuousStatesChanged = fmi2False;
+ comp->eventInfo.valuesOfContinuousStatesChanged = fmi2False;
+
+ if (comp->eventInfo.nextEventTimeDefined && comp->eventInfo.nextEventTime <= comp->time) {
+ timeEvent = 1;
+ }
+ eventUpdate(comp, &comp->eventInfo, timeEvent, comp->isNewEventIteration);
+ comp->isNewEventIteration = fmi2False;
+
+ // copy internal eventInfo of component to output eventInfo
+ eventInfo->newDiscreteStatesNeeded = comp->eventInfo.newDiscreteStatesNeeded;
+ eventInfo->terminateSimulation = comp->eventInfo.terminateSimulation;
+ eventInfo->nominalsOfContinuousStatesChanged = comp->eventInfo.nominalsOfContinuousStatesChanged;
+ eventInfo->valuesOfContinuousStatesChanged = comp->eventInfo.valuesOfContinuousStatesChanged;
+ eventInfo->nextEventTimeDefined = comp->eventInfo.nextEventTimeDefined;
+ eventInfo->nextEventTime = comp->eventInfo.nextEventTime;
+
+ return fmi2OK;
+}
+
+fmi2Status fmi2EnterContinuousTimeMode(fmi2Component c) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2EnterContinuousTimeMode", MASK_fmi2EnterContinuousTimeMode))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL,"fmi2EnterContinuousTimeMode")
+
+ comp->state = modelContinuousTimeMode;
+ return fmi2OK;
+}
+
+fmi2Status fmi2CompletedIntegratorStep(fmi2Component c, fmi2Boolean noSetFMUStatePriorToCurrentPoint,
+ fmi2Boolean *enterEventMode, fmi2Boolean *terminateSimulation) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2CompletedIntegratorStep", MASK_fmi2CompletedIntegratorStep))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2CompletedIntegratorStep", "enterEventMode", enterEventMode))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2CompletedIntegratorStep", "terminateSimulation", terminateSimulation))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL,"fmi2CompletedIntegratorStep")
+ *enterEventMode = fmi2False;
+ *terminateSimulation = fmi2False;
+ return fmi2OK;
+}
+
+/* Providing independent variables and re-initialization of caching */
+fmi2Status fmi2SetTime(fmi2Component c, fmi2Real time) {
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2SetTime", MASK_fmi2SetTime))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetTime: time=%.16g", time)
+ comp->time = time;
+ return fmi2OK;
+}
+
+fmi2Status fmi2SetContinuousStates(fmi2Component c, const fmi2Real x[], size_t nx){
+ ModelInstance *comp = (ModelInstance *)c;
+ int i;
+ if (invalidState(comp, "fmi2SetContinuousStates", MASK_fmi2SetContinuousStates))
+ return fmi2Error;
+ if (invalidNumber(comp, "fmi2SetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2SetContinuousStates", "x[]", x))
+ return fmi2Error;
+#if NUMBER_OF_STATES>0
+ for (i = 0; i < nx; i++) {
+ fmi2ValueReference vr = vrStates[i];
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetContinuousStates: #r%d#=%.16g", vr, x[i])
+ assert(vr < NUMBER_OF_REALS);
+ comp->r[vr] = x[i];
+ }
+#endif
+ return fmi2OK;
+}
+
+/* Evaluation of the model equations */
+fmi2Status fmi2GetDerivatives(fmi2Component c, fmi2Real derivatives[], size_t nx) {
+ int i;
+ ModelInstance* comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetDerivatives", MASK_fmi2GetDerivatives))
+ return fmi2Error;
+ if (invalidNumber(comp, "fmi2GetDerivatives", "nx", nx, NUMBER_OF_STATES))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2GetDerivatives", "derivatives[]", derivatives))
+ return fmi2Error;
+#if NUMBER_OF_STATES>0
+ for (i = 0; i < nx; i++) {
+ fmi2ValueReference vr = vrStates[i] + 1;
+ derivatives[i] = getReal(comp, vr); // to be implemented by the includer of this file
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetDerivatives: #r%d# = %.16g", vr, derivatives[i])
+ }
+#endif
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetEventIndicators(fmi2Component c, fmi2Real eventIndicators[], size_t ni) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetEventIndicators", MASK_fmi2GetEventIndicators))
+ return fmi2Error;
+ if (invalidNumber(comp, "fmi2GetEventIndicators", "ni", ni, NUMBER_OF_EVENT_INDICATORS))
+ return fmi2Error;
+#if NUMBER_OF_EVENT_INDICATORS>0
+ for (i = 0; i < ni; i++) {
+ eventIndicators[i] = getEventIndicator(comp, i); // to be implemented by the includer of this file
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetEventIndicators: z%d = %.16g", i, eventIndicators[i])
+ }
+#endif
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetContinuousStates(fmi2Component c, fmi2Real states[], size_t nx) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetContinuousStates", MASK_fmi2GetContinuousStates))
+ return fmi2Error;
+ if (invalidNumber(comp, "fmi2GetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2GetContinuousStates", "states[]", states))
+ return fmi2Error;
+#if NUMBER_OF_STATES>0
+ for (i = 0; i < nx; i++) {
+ fmi2ValueReference vr = vrStates[i];
+ states[i] = getReal(comp, vr); // to be implemented by the includer of this file
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetContinuousStates: #r%u# = %.16g", vr, states[i])
+ }
+#endif
+ return fmi2OK;
+}
+
+fmi2Status fmi2GetNominalsOfContinuousStates(fmi2Component c, fmi2Real x_nominal[], size_t nx) {
+ int i;
+ ModelInstance *comp = (ModelInstance *)c;
+ if (invalidState(comp, "fmi2GetNominalsOfContinuousStates", MASK_fmi2GetNominalsOfContinuousStates))
+ return fmi2Error;
+ if (invalidNumber(comp, "fmi2GetNominalContinuousStates", "nx", nx, NUMBER_OF_STATES))
+ return fmi2Error;
+ if (nullPointer(comp, "fmi2GetNominalContinuousStates", "x_nominal[]", x_nominal))
+ return fmi2Error;
+ FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetNominalContinuousStates: x_nominal[0..%d] = 1.0", nx-1)
+ for (i = 0; i < nx; i++)
+ x_nominal[i] = 1;
+ return fmi2OK;
+}
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
diff --git a/fmu20/src/models/fmuTemplate.h b/fmu20/src/models/fmuTemplate.h
new file mode 100644
index 0000000..5b7e545
--- /dev/null
+++ b/fmu20/src/models/fmuTemplate.h
@@ -0,0 +1,170 @@
+/* ---------------------------------------------------------------------------*
+ * fmuTemplate.h
+ * Definitions by the includer of this file
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+
+// C-code FMUs have functions names prefixed with MODEL_IDENTIFIER_.
+// Define DISABLE_PREFIX to build a binary FMU.
+#ifndef DISABLE_PREFIX
+#define pasteA(a,b) a ## b
+#define pasteB(a,b) pasteA(a,b)
+#define FMI2_FUNCTION_PREFIX pasteB(MODEL_IDENTIFIER, _)
+#endif
+#include "fmi2Functions.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// macros used to define variables
+#define r(vr) comp->r[vr]
+#define i(vr) comp->i[vr]
+#define b(vr) comp->b[vr]
+#define s(vr) comp->s[vr]
+#define pos(z) comp->isPositive[z]
+#define copy(vr, value) setString(comp, vr, value)
+
+fmi2Status setString(fmi2Component comp, fmi2ValueReference vr, fmi2String value);
+
+// categories of logging supported by model.
+// Value is the index in logCategories of a ModelInstance.
+#define LOG_ALL 0
+#define LOG_ERROR 1
+#define LOG_FMI_CALL 2
+#define LOG_EVENT 3
+
+#define NUMBER_OF_CATEGORIES 4
+
+typedef enum {
+ modelStartAndEnd = 1<<0,
+ modelInstantiated = 1<<1,
+ modelInitializationMode = 1<<2,
+
+ // ME states
+ modelEventMode = 1<<3,
+ modelContinuousTimeMode = 1<<4,
+ // CS states
+ modelStepComplete = 1<<5,
+ modelStepInProgress = 1<<6,
+ modelStepFailed = 1<<7,
+ modelStepCanceled = 1<<8,
+
+ modelTerminated = 1<<9,
+ modelError = 1<<10,
+ modelFatal = 1<<11,
+} ModelState;
+
+// ---------------------------------------------------------------------------
+// Function calls allowed state masks for both Model-exchange and Co-simulation
+// ---------------------------------------------------------------------------
+#define MASK_fmi2GetTypesPlatform (modelStartAndEnd | modelInstantiated | modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepInProgress | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+#define MASK_fmi2GetVersion MASK_fmi2GetTypesPlatform
+#define MASK_fmi2SetDebugLogging (modelInstantiated | modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepInProgress | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+#define MASK_fmi2Instantiate (modelStartAndEnd)
+#define MASK_fmi2FreeInstance (modelInstantiated | modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+#define MASK_fmi2SetupExperiment modelInstantiated
+#define MASK_fmi2EnterInitializationMode modelInstantiated
+#define MASK_fmi2ExitInitializationMode modelInitializationMode
+#define MASK_fmi2Terminate (modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepFailed)
+#define MASK_fmi2Reset MASK_fmi2FreeInstance
+#define MASK_fmi2GetReal (modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+#define MASK_fmi2GetInteger MASK_fmi2GetReal
+#define MASK_fmi2GetBoolean MASK_fmi2GetReal
+#define MASK_fmi2GetString MASK_fmi2GetReal
+#define MASK_fmi2SetReal (modelInstantiated | modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete)
+#define MASK_fmi2SetInteger (modelInstantiated | modelInitializationMode \
+ | modelEventMode \
+ | modelStepComplete)
+#define MASK_fmi2SetBoolean MASK_fmi2SetInteger
+#define MASK_fmi2SetString MASK_fmi2SetInteger
+#define MASK_fmi2GetFMUstate MASK_fmi2FreeInstance
+#define MASK_fmi2SetFMUstate MASK_fmi2FreeInstance
+#define MASK_fmi2FreeFMUstate MASK_fmi2FreeInstance
+#define MASK_fmi2SerializedFMUstateSize MASK_fmi2FreeInstance
+#define MASK_fmi2SerializeFMUstate MASK_fmi2FreeInstance
+#define MASK_fmi2DeSerializeFMUstate MASK_fmi2FreeInstance
+#define MASK_fmi2GetDirectionalDerivative (modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelStepComplete | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+
+// ---------------------------------------------------------------------------
+// Function calls allowed state masks for Model-exchange
+// ---------------------------------------------------------------------------
+#define MASK_fmi2EnterEventMode (modelEventMode | modelContinuousTimeMode)
+#define MASK_fmi2NewDiscreteStates modelEventMode
+#define MASK_fmi2EnterContinuousTimeMode modelEventMode
+#define MASK_fmi2CompletedIntegratorStep modelContinuousTimeMode
+#define MASK_fmi2SetTime (modelEventMode | modelContinuousTimeMode)
+#define MASK_fmi2SetContinuousStates modelContinuousTimeMode
+#define MASK_fmi2GetEventIndicators (modelInitializationMode \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelTerminated | modelError)
+#define MASK_fmi2GetContinuousStates MASK_fmi2GetEventIndicators
+#define MASK_fmi2GetDerivatives (modelEventMode | modelContinuousTimeMode \
+ | modelTerminated | modelError)
+#define MASK_fmi2GetNominalsOfContinuousStates ( modelInstantiated \
+ | modelEventMode | modelContinuousTimeMode \
+ | modelTerminated | modelError)
+
+// ---------------------------------------------------------------------------
+// Function calls allowed state masks for Co-simulation
+// ---------------------------------------------------------------------------
+#define MASK_fmi2SetRealInputDerivatives (modelInstantiated | modelInitializationMode \
+ | modelStepComplete)
+#define MASK_fmi2GetRealOutputDerivatives (modelStepComplete | modelStepFailed | modelStepCanceled \
+ | modelTerminated | modelError)
+#define MASK_fmi2DoStep modelStepComplete
+#define MASK_fmi2CancelStep modelStepInProgress
+#define MASK_fmi2GetStatus (modelStepComplete | modelStepInProgress | modelStepFailed \
+ | modelTerminated)
+#define MASK_fmi2GetRealStatus MASK_fmi2GetStatus
+#define MASK_fmi2GetIntegerStatus MASK_fmi2GetStatus
+#define MASK_fmi2GetBooleanStatus MASK_fmi2GetStatus
+#define MASK_fmi2GetStringStatus MASK_fmi2GetStatus
+
+typedef struct {
+ fmi2Real *r;
+ fmi2Integer *i;
+ fmi2Boolean *b;
+ fmi2String *s;
+ fmi2Boolean *isPositive;
+
+ fmi2Real time;
+ fmi2String instanceName;
+ fmi2Type type;
+ fmi2String GUID;
+ const fmi2CallbackFunctions *functions;
+ fmi2Boolean loggingOn;
+ fmi2Boolean logCategories[NUMBER_OF_CATEGORIES];
+
+ fmi2ComponentEnvironment componentEnvironment;
+ ModelState state;
+ fmi2EventInfo eventInfo;
+ fmi2Boolean isDirtyValues;
+ fmi2Boolean isNewEventIteration;
+} ModelInstance;
+
+#ifdef __cplusplus
+} // closing brace for extern "C"
+#endif
diff --git a/fmu20/src/models/inc/Makefile b/fmu20/src/models/inc/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu20/src/models/inc/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu20/src/models/inc/inc.c b/fmu20/src/models/inc/inc.c
new file mode 100644
index 0000000..6d78925
--- /dev/null
+++ b/fmu20/src/models/inc/inc.c
@@ -0,0 +1,61 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - increments an int counter every second.
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER inc
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f008}"
+
+// define model size
+#define NUMBER_OF_REALS 0
+#define NUMBER_OF_INTEGERS 1
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 0
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define counter_ 0
+
+// called by fmi2Instantiate
+// Set values for all variables that define a start value
+// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
+void setStartValues(ModelInstance *comp) {
+ i(counter_) = 1;
+}
+
+// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
+// if setStartValues or environment set new values through fmi2SetXXX.
+// Lazy set values for all variable that are computed from other variables.
+void calculateValues(ModelInstance *comp) {
+ if (comp->state == modelInitializationMode) {
+ // set first time event
+ comp->eventInfo.nextEventTimeDefined = fmi2True;
+ comp->eventInfo.nextEventTime = 1 + comp->time;
+ }
+}
+
+// used to set the next time event, if any.
+void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int timeEvent, int isNewEventIteration) {
+ if (timeEvent) {
+ i(counter_) += 1;
+ if (i(counter_) == 13) {
+ eventInfo->terminateSimulation = fmi2True;
+ eventInfo->nextEventTimeDefined = fmi2False;
+ } else {
+ eventInfo->nextEventTimeDefined = fmi2True;
+ eventInfo->nextEventTime = 1 + comp->time;
+ }
+ }
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu20/src/models/inc/index.html b/fmu20/src/models/inc/index.html
new file mode 100644
index 0000000..6d4827a
--- /dev/null
+++ b/fmu20/src/models/inc/index.html
@@ -0,0 +1,22 @@
+
+
+ Documentation for inc.fmu
+
+
+
+inc.fmu
+This FMU generates time events to increment an integer counter every second and terminates simulation at t=12 sec.
+
+
+
+The figure shows the solution computed with Silver.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu20/src/models/inc/model.png b/fmu20/src/models/inc/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu20/src/models/inc/model.png differ
diff --git a/fmu20/src/models/inc/modelDescription_cs.xml b/fmu20/src/models/inc/modelDescription_cs.xml
new file mode 100644
index 0000000..6f57531
--- /dev/null
+++ b/fmu20/src/models/inc/modelDescription_cs.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/inc/modelDescription_me.xml b/fmu20/src/models/inc/modelDescription_me.xml
new file mode 100644
index 0000000..7b4b1cf
--- /dev/null
+++ b/fmu20/src/models/inc/modelDescription_me.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/inc/plot_counter.PNG b/fmu20/src/models/inc/plot_counter.PNG
new file mode 100644
index 0000000..d3ec25d
Binary files /dev/null and b/fmu20/src/models/inc/plot_counter.PNG differ
diff --git a/fmu20/src/models/values/Makefile b/fmu20/src/models/values/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu20/src/models/values/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu20/src/models/values/index.html b/fmu20/src/models/values/index.html
new file mode 100644
index 0000000..b6a16b9
--- /dev/null
+++ b/fmu20/src/models/values/index.html
@@ -0,0 +1,23 @@
+
+
+ Documentation for values.fmu
+
+
+
+ values.fmu
+ This FMU demonstrates the use of all four scalar FMU data types
+ and terminates simulation at t=12 sec.
+
+
+The figure shows the solution computed with fmusim using the command
+fmusim me fmu\me\values.fmu 12 12
.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu20/src/models/values/model.png b/fmu20/src/models/values/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu20/src/models/values/model.png differ
diff --git a/fmu20/src/models/values/modelDescription_cs.xml b/fmu20/src/models/values/modelDescription_cs.xml
new file mode 100644
index 0000000..115102b
--- /dev/null
+++ b/fmu20/src/models/values/modelDescription_cs.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/values/modelDescription_me.xml b/fmu20/src/models/values/modelDescription_me.xml
new file mode 100644
index 0000000..61b999a
--- /dev/null
+++ b/fmu20/src/models/values/modelDescription_me.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/values/values.PNG b/fmu20/src/models/values/values.PNG
new file mode 100644
index 0000000..45eaf96
Binary files /dev/null and b/fmu20/src/models/values/values.PNG differ
diff --git a/fmu20/src/models/values/values.c b/fmu20/src/models/values/values.c
new file mode 100644
index 0000000..2ea48a7
--- /dev/null
+++ b/fmu20/src/models/values/values.c
@@ -0,0 +1,90 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU.
+ * This demonstrates the use of all FMU variable types.
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER values
+#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f004}"
+
+// define model size
+#define NUMBER_OF_REALS 2
+#define NUMBER_OF_INTEGERS 2
+#define NUMBER_OF_BOOLEANS 2
+#define NUMBER_OF_STRINGS 2
+#define NUMBER_OF_STATES 1
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x_ 0
+#define der_x_ 1
+#define int_in_ 0
+#define int_out_ 1
+#define bool_in_ 0
+#define bool_out_ 1
+#define string_in_ 0
+#define string_out_ 1
+
+// define state vector as vector of value references
+#define STATES { x_ }
+
+const char *month[] = {
+ "jan","feb","march","april","may","june","july",
+ "august","sept","october","november","december"
+};
+
+// called by fmi2Instantiate
+// Set values for all variables that define a start value
+// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
+void setStartValues(ModelInstance *comp) {
+ r(x_) = 1;
+ i(int_in_) = 2;
+ i(int_out_) = 0;
+ b(bool_in_) = fmi2True;
+ b(bool_out_) = fmi2False;
+ copy(string_in_, "QTronic");
+ copy(string_out_, month[0]);
+}
+
+// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
+// if setStartValues or environment set new values through fmi2SetXXX.
+// Lazy set values for all variable that are computed from other variables.
+void calculateValues(ModelInstance *comp) {
+ if (comp->state == modelInitializationMode) {
+ // set first time event
+ comp->eventInfo.nextEventTimeDefined = fmi2True;
+ comp->eventInfo.nextEventTime = 1 + comp->time;
+ }
+}
+
+// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
+fmi2Real getReal(ModelInstance *comp, fmi2ValueReference vr){
+ switch (vr) {
+ case x_ : return r(x_);
+ case der_x_ : return - r(x_);
+ default: return 0;
+ }
+}
+
+// used to set the next time event, if any.
+void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
+ if (isTimeEvent) {
+ eventInfo->nextEventTimeDefined = fmi2True;
+ eventInfo->nextEventTime = 1 + comp->time;
+ i(int_out_) += 1;
+ b(bool_out_) = !b(bool_out_);
+ if (i(int_out_) < 12) copy(string_out_, month[i(int_out_)]);
+ else eventInfo->terminateSimulation = fmi2True;
+ }
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu20/src/models/vanDerPol/Makefile b/fmu20/src/models/vanDerPol/Makefile
new file mode 100644
index 0000000..6bc47da
--- /dev/null
+++ b/fmu20/src/models/vanDerPol/Makefile
@@ -0,0 +1,3 @@
+CFLAGS = -I..
+
+include ../Makefile
diff --git a/fmu20/src/models/vanDerPol/index.html b/fmu20/src/models/vanDerPol/index.html
new file mode 100644
index 0000000..528fe10
--- /dev/null
+++ b/fmu20/src/models/vanDerPol/index.html
@@ -0,0 +1,27 @@
+
+
+Documentation for vanDerPol.fmu
+
+
+
+vanDerPol.fmu
+This FMU implements the famous
+Van der Pol oscillator.
+
+- der(x0) = x1
+- der(x1) = mu * ((1 - x0 * x0) * x1) - x0
+
+
+
+The figure shows the solution computed with Silver
+for start values x0 = 2, x1 = 0, mu = 1.
+
+
+The FMU is provided by QTronic under the
+BSD License.
+
+
+
diff --git a/fmu20/src/models/vanDerPol/model.png b/fmu20/src/models/vanDerPol/model.png
new file mode 100644
index 0000000..8d23e9a
Binary files /dev/null and b/fmu20/src/models/vanDerPol/model.png differ
diff --git a/fmu20/src/models/vanDerPol/modelDescription_cs.xml b/fmu20/src/models/vanDerPol/modelDescription_cs.xml
new file mode 100644
index 0000000..6538901
--- /dev/null
+++ b/fmu20/src/models/vanDerPol/modelDescription_cs.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/vanDerPol/modelDescription_me.xml b/fmu20/src/models/vanDerPol/modelDescription_me.xml
new file mode 100644
index 0000000..9de59d5
--- /dev/null
+++ b/fmu20/src/models/vanDerPol/modelDescription_me.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fmu20/src/models/vanDerPol/plot_states.png b/fmu20/src/models/vanDerPol/plot_states.png
new file mode 100644
index 0000000..05761cd
Binary files /dev/null and b/fmu20/src/models/vanDerPol/plot_states.png differ
diff --git a/fmu20/src/models/vanDerPol/vanDerPol.c b/fmu20/src/models/vanDerPol/vanDerPol.c
new file mode 100644
index 0000000..7f77de1
--- /dev/null
+++ b/fmu20/src/models/vanDerPol/vanDerPol.c
@@ -0,0 +1,77 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - the Van der Pol oscillator.
+ * See http://en.wikipedia.org/wiki/Van_der_Pol_oscillator
+ *
+ * der(x0) = x1
+ * der(x1) = mu * ((1 - x0 ^ 2) * x1) - x0;
+ *
+ * start values: x0=2, x1=0, mue=1
+ * Copyright QTronic GmbH. All rights reserved.
+ * ---------------------------------------------------------------------------*/
+
+// define class name and unique id
+#define MODEL_IDENTIFIER vanDerPol
+#define MODEL_GUID "{8c4e810f-3da3-4a00-8276-176fa3c9f000}"
+
+// define model size
+#define NUMBER_OF_REALS 5
+#define NUMBER_OF_INTEGERS 0
+#define NUMBER_OF_BOOLEANS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_STATES 2
+#define NUMBER_OF_EVENT_INDICATORS 0
+
+// include fmu header files, typedefs and macros
+#include "fmuTemplate.h"
+
+// define all model variables and their value references
+// conventions used here:
+// - if x is a variable, then macro x_ is its variable reference
+// - the vr of a variable is its index in array r, i, b or s
+// - if k is the vr of a real state, then k+1 is the vr of its derivative
+#define x0_ 0
+#define der_x0_ 1
+#define x1_ 2
+#define der_x1_ 3
+#define mu_ 4
+
+// define state vector as vector of value references
+#define STATES { x0_, x1_ }
+
+// called by fmi2Instantiate
+// Set values for all variables that define a start value
+// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
+void setStartValues(ModelInstance *comp) {
+ r(x0_) = 2;
+ r(x1_) = 0;
+ r(mu_) = 1;
+}
+
+// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
+// if setStartValues or environment set new values through fmi2SetXXX.
+// Lazy set values for all variable that are computed from other variables.
+void calculateValues(ModelInstance *comp) {
+ //if (comp->state == modelInitializationMode) {
+ // initialization code here
+ // set first time event, if any, using comp->eventInfo.nextEventTime
+ //}
+}
+
+// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
+fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr){
+ switch (vr) {
+ case x0_ : return r(x0_);
+ case x1_ : return r(x1_);
+ case der_x0_ : return r(x1_);
+ case der_x1_ : return r(mu_) * ((1.0-r(x0_)*r(x0_))*r(x1_)) - r(x0_);
+ case mu_ : return r(mu_);
+ default: return 0;
+ }
+}
+
+// used to set the next time event, if any.
+void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
+}
+
+// include code that implements the FMI based on the above definitions
+#include "fmuTemplate.c"
diff --git a/fmu20/src/shared/fmi2.h b/fmu20/src/shared/fmi2.h
new file mode 100644
index 0000000..e65e5e5
--- /dev/null
+++ b/fmu20/src/shared/fmi2.h
@@ -0,0 +1,91 @@
+/* -------------------------------------------------------------------------
+ * fmi.h
+ * Struct with the corresponding function pointers for FMI 2.0.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#ifndef FMI_H
+#define FMI_H
+
+#ifdef _MSC_VER
+#include
+#define WINDOWS 1
+#if (_MSC_VER >= 1900)
+#pragma comment(lib, "legacy_stdio_definitions.lib")
+#endif /* _MSC_VER >= 1900 */
+#else /* _MSC_VER */
+#include
+#define WINDOWS 0
+#define TRUE 1
+#define FALSE 0
+#define min(a,b) (a>b ? b : a)
+#define HMODULE void *
+/* See http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html */
+#include
+#endif /* _MSC_VER */
+
+#include "fmi2Functions.h"
+
+#include "XmlParserCApi.h"
+
+typedef struct {
+ ModelDescription* modelDescription;
+
+ HMODULE dllHandle; // fmu.dll handle
+ /***************************************************
+ Common Functions
+ ****************************************************/
+ fmi2GetTypesPlatformTYPE *getTypesPlatform;
+ fmi2GetVersionTYPE *getVersion;
+ fmi2SetDebugLoggingTYPE *setDebugLogging;
+ fmi2InstantiateTYPE *instantiate;
+ fmi2FreeInstanceTYPE *freeInstance;
+ fmi2SetupExperimentTYPE *setupExperiment;
+ fmi2EnterInitializationModeTYPE *enterInitializationMode;
+ fmi2ExitInitializationModeTYPE *exitInitializationMode;
+ fmi2TerminateTYPE *terminate;
+ fmi2ResetTYPE *reset;
+ fmi2GetRealTYPE *getReal;
+ fmi2GetIntegerTYPE *getInteger;
+ fmi2GetBooleanTYPE *getBoolean;
+ fmi2GetStringTYPE *getString;
+ fmi2SetRealTYPE *setReal;
+ fmi2SetIntegerTYPE *setInteger;
+ fmi2SetBooleanTYPE *setBoolean;
+ fmi2SetStringTYPE *setString;
+ fmi2GetFMUstateTYPE *getFMUstate;
+ fmi2SetFMUstateTYPE *setFMUstate;
+ fmi2FreeFMUstateTYPE *freeFMUstate;
+ fmi2SerializedFMUstateSizeTYPE *serializedFMUstateSize;
+ fmi2SerializeFMUstateTYPE *serializeFMUstate;
+ fmi2DeSerializeFMUstateTYPE *deSerializeFMUstate;
+ fmi2GetDirectionalDerivativeTYPE *getDirectionalDerivative;
+ /***************************************************
+ Functions for FMI2 for Co-Simulation
+ ****************************************************/
+ fmi2SetRealInputDerivativesTYPE *setRealInputDerivatives;
+ fmi2GetRealOutputDerivativesTYPE *getRealOutputDerivatives;
+ fmi2DoStepTYPE *doStep;
+ fmi2CancelStepTYPE *cancelStep;
+ fmi2GetStatusTYPE *getStatus;
+ fmi2GetRealStatusTYPE *getRealStatus;
+ fmi2GetIntegerStatusTYPE *getIntegerStatus;
+ fmi2GetBooleanStatusTYPE *getBooleanStatus;
+ fmi2GetStringStatusTYPE *getStringStatus;
+ /***************************************************
+ Functions for FMI2 for Model Exchange
+ ****************************************************/
+ fmi2EnterEventModeTYPE *enterEventMode;
+ fmi2NewDiscreteStatesTYPE *newDiscreteStates;
+ fmi2EnterContinuousTimeModeTYPE *enterContinuousTimeMode;
+ fmi2CompletedIntegratorStepTYPE *completedIntegratorStep;
+ fmi2SetTimeTYPE *setTime;
+ fmi2SetContinuousStatesTYPE *setContinuousStates;
+ fmi2GetDerivativesTYPE *getDerivatives;
+ fmi2GetEventIndicatorsTYPE *getEventIndicators;
+ fmi2GetContinuousStatesTYPE *getContinuousStates;
+ fmi2GetNominalsOfContinuousStatesTYPE *getNominalsOfContinuousStates;
+} FMU;
+
+#endif // FMI_H
+
diff --git a/fmu20/src/shared/include/fmi2FunctionTypes.h b/fmu20/src/shared/include/fmi2FunctionTypes.h
new file mode 100644
index 0000000..348c76e
--- /dev/null
+++ b/fmu20/src/shared/include/fmi2FunctionTypes.h
@@ -0,0 +1,243 @@
+#ifndef fmi2FunctionTypes_h
+#define fmi2FunctionTypes_h
+
+#include "fmi2TypesPlatform.h"
+
+/* This header file must be utilized when compiling an FMU or an FMI master.
+ It declares data and function types for FMI 2.0
+
+ Revisions:
+ - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+ - Apr. 3, 2014: Added #include for size_t definition
+ - Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179)
+ - Mar. 26, 2014: Introduced function argument "void" for the functions (#171)
+ fmiGetTypesPlatformTYPE and fmiGetVersionTYPE
+ - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+ fmiInstantiateModelTYPE , fmiInstantiateSlaveTYPE -> fmiInstantiateTYPE
+ fmiFreeModelInstanceTYPE, fmiFreeSlaveInstanceTYPE -> fmiFreeInstanceTYPE
+ fmiEnterModelInitializationModeTYPE, fmiEnterSlaveInitializationModeTYPE -> fmiEnterInitializationModeTYPE
+ fmiExitModelInitializationModeTYPE , fmiExitSlaveInitializationModeTYPE -> fmiExitInitializationModeTYPE
+ fmiTerminateModelTYPE , fmiTerminateSlaveTYPE -> fmiTerminate
+ fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+ Functions renamed
+ fmiUpdateDiscreteStatesTYPE -> fmiNewDiscreteStatesTYPE
+ Renamed elements of the enumeration fmiEventInfo
+ upcomingTimeEvent -> nextEventTimeDefined // due to generic naming scheme: varDefined + var
+ newUpdateDiscreteStatesNeeded -> newDiscreteStatesNeeded;
+ - June 13, 2013: Changed type fmiEventInfo
+ Functions removed:
+ fmiInitializeModelTYPE
+ fmiEventUpdateTYPE
+ fmiCompletedEventIterationTYPE
+ fmiInitializeSlaveTYPE
+ Functions added:
+ fmiEnterModelInitializationModeTYPE
+ fmiExitModelInitializationModeTYPE
+ fmiEnterEventModeTYPE
+ fmiUpdateDiscreteStatesTYPE
+ fmiEnterContinuousTimeModeTYPE
+ fmiEnterSlaveInitializationModeTYPE;
+ fmiExitSlaveInitializationModeTYPE;
+ - Feb. 17, 2013: Added third argument to fmiCompletedIntegratorStepTYPE
+ Changed function name "fmiTerminateType" to "fmiTerminateModelType" (due to #113)
+ Changed function name "fmiGetNominalContinuousStateTYPE" to
+ "fmiGetNominalsOfContinuousStatesTYPE"
+ Removed fmiGetStateValueReferencesTYPE.
+ - Nov. 14, 2011: First public Version
+
+
+ Copyright © 2011 MODELISAR consortium,
+ 2012-2013 Modelica Association Project "FMI"
+ All rights reserved.
+ This file is licensed by the copyright holders under the BSD 2-Clause License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+
+ with the extension:
+
+ You may distribute or publicly perform any modification only under the
+ terms of this license.
+ (Note, this means that if you distribute a modified file,
+ the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* make sure all compiler use the same alignment policies for structures */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(push,8)
+#endif
+
+/* Include stddef.h, in order that size_t etc. is defined */
+#include
+
+
+/* Type definitions */
+typedef enum {
+ fmi2OK,
+ fmi2Warning,
+ fmi2Discard,
+ fmi2Error,
+ fmi2Fatal,
+ fmi2Pending
+} fmi2Status;
+
+typedef enum {
+ fmi2ModelExchange,
+ fmi2CoSimulation
+} fmi2Type;
+
+typedef enum {
+ fmi2DoStepStatus,
+ fmi2PendingStatus,
+ fmi2LastSuccessfulTime,
+ fmi2Terminated
+} fmi2StatusKind;
+
+typedef void (*fmi2CallbackLogger) (fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...);
+typedef void* (*fmi2CallbackAllocateMemory)(size_t, size_t);
+typedef void (*fmi2CallbackFreeMemory) (void*);
+typedef void (*fmi2StepFinished) (fmi2ComponentEnvironment, fmi2Status);
+
+typedef struct {
+ const fmi2CallbackLogger logger;
+ const fmi2CallbackAllocateMemory allocateMemory;
+ const fmi2CallbackFreeMemory freeMemory;
+ const fmi2StepFinished stepFinished;
+ const fmi2ComponentEnvironment componentEnvironment;
+} fmi2CallbackFunctions;
+
+typedef struct {
+ fmi2Boolean newDiscreteStatesNeeded;
+ fmi2Boolean terminateSimulation;
+ fmi2Boolean nominalsOfContinuousStatesChanged;
+ fmi2Boolean valuesOfContinuousStatesChanged;
+ fmi2Boolean nextEventTimeDefined;
+ fmi2Real nextEventTime;
+} fmi2EventInfo;
+
+
+/* reset alignment policy to the one set before reading this file */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(pop)
+#endif
+
+
+/* Define fmi2 function pointer types to simplify dynamic loading */
+
+/***************************************************
+Types for Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files and setting logging status */
+ typedef const char* fmi2GetTypesPlatformTYPE(void);
+ typedef const char* fmi2GetVersionTYPE(void);
+ typedef fmi2Status fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]);
+
+/* Creation and destruction of FMU instances and setting debug status */
+ typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean);
+ typedef void fmi2FreeInstanceTYPE(fmi2Component);
+
+/* Enter and exit initialization mode, terminate and reset */
+ typedef fmi2Status fmi2SetupExperimentTYPE (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real);
+ typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component);
+ typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component);
+ typedef fmi2Status fmi2TerminateTYPE (fmi2Component);
+ typedef fmi2Status fmi2ResetTYPE (fmi2Component);
+
+/* Getting and setting variable values */
+ typedef fmi2Status fmi2GetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real []);
+ typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]);
+ typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]);
+ typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []);
+
+ typedef fmi2Status fmi2SetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real []);
+ typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]);
+ typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]);
+ typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []);
+
+/* Getting and setting the internal FMU state */
+ typedef fmi2Status fmi2GetFMUstateTYPE (fmi2Component, fmi2FMUstate*);
+ typedef fmi2Status fmi2SetFMUstateTYPE (fmi2Component, fmi2FMUstate);
+ typedef fmi2Status fmi2FreeFMUstateTYPE (fmi2Component, fmi2FMUstate*);
+ typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component, fmi2FMUstate, size_t*);
+ typedef fmi2Status fmi2SerializeFMUstateTYPE (fmi2Component, fmi2FMUstate, fmi2Byte[], size_t);
+ typedef fmi2Status fmi2DeSerializeFMUstateTYPE (fmi2Component, const fmi2Byte[], size_t, fmi2FMUstate*);
+
+/* Getting partial derivatives */
+ typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component, const fmi2ValueReference[], size_t,
+ const fmi2ValueReference[], size_t,
+ const fmi2Real[], fmi2Real[]);
+
+/***************************************************
+Types for Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+ typedef fmi2Status fmi2EnterEventModeTYPE (fmi2Component);
+ typedef fmi2Status fmi2NewDiscreteStatesTYPE (fmi2Component, fmi2EventInfo*);
+ typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component);
+ typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*);
+
+/* Providing independent variables and re-initialization of caching */
+ typedef fmi2Status fmi2SetTimeTYPE (fmi2Component, fmi2Real);
+ typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t);
+
+/* Evaluation of the model equations */
+ typedef fmi2Status fmi2GetDerivativesTYPE (fmi2Component, fmi2Real[], size_t);
+ typedef fmi2Status fmi2GetEventIndicatorsTYPE (fmi2Component, fmi2Real[], size_t);
+ typedef fmi2Status fmi2GetContinuousStatesTYPE (fmi2Component, fmi2Real[], size_t);
+ typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t);
+
+
+/***************************************************
+Types for Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+ typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []);
+ typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []);
+
+ typedef fmi2Status fmi2DoStepTYPE (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean);
+ typedef fmi2Status fmi2CancelStepTYPE (fmi2Component);
+
+/* Inquire slave status */
+ typedef fmi2Status fmi2GetStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2Status* );
+ typedef fmi2Status fmi2GetRealStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2Real* );
+ typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*);
+ typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*);
+ typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* );
+
+
+#ifdef __cplusplus
+} /* end of extern "C" { */
+#endif
+
+#endif /* fmi2FunctionTypes_h */
diff --git a/fmu20/src/shared/include/fmi2Functions.h b/fmu20/src/shared/include/fmi2Functions.h
new file mode 100644
index 0000000..a23697f
--- /dev/null
+++ b/fmu20/src/shared/include/fmi2Functions.h
@@ -0,0 +1,333 @@
+#ifndef fmi2Functions_h
+#define fmi2Functions_h
+
+/* This header file must be utilized when compiling a FMU.
+ It defines all functions of the
+ FMI 2.0 Model Exchange and Co-Simulation Interface.
+
+ In order to have unique function names even if several FMUs
+ are compiled together (e.g. for embedded systems), every "real" function name
+ is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
+ Therefore, the typical usage is:
+
+ #define FMI2_FUNCTION_PREFIX MyModel_
+ #include "fmi2Functions.h"
+
+ As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
+ is actually getting the name "MyModel_fmi2GetDerivatives".
+
+ This only holds if the FMU is shipped in C source code, or is compiled in a
+ static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
+ names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
+
+ Revisions:
+ - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+ - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX
+ are not defined (#173)
+ - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+ fmiInstantiateModel , fmiInstantiateSlave -> fmiInstantiate
+ fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
+ fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
+ fmiExitModelInitializationMode , fmiExitSlaveInitializationMode -> fmiExitInitializationMode
+ fmiTerminateModel, fmiTerminateSlave -> fmiTerminate
+ fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+ Functions renamed:
+ fmiUpdateDiscreteStates -> fmiNewDiscreteStates
+ - June 13, 2013: Functions removed:
+ fmiInitializeModel
+ fmiEventUpdate
+ fmiCompletedEventIteration
+ fmiInitializeSlave
+ Functions added:
+ fmiEnterModelInitializationMode
+ fmiExitModelInitializationMode
+ fmiEnterEventMode
+ fmiUpdateDiscreteStates
+ fmiEnterContinuousTimeMode
+ fmiEnterSlaveInitializationMode;
+ fmiExitSlaveInitializationMode;
+ - Feb. 17, 2013: Portability improvements:
+ o DllExport changed to FMI_Export
+ o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
+ o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
+ Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
+ Changed function name "fmiGetNominalContinuousState" to
+ "fmiGetNominalsOfContinuousStates"
+ Removed fmiGetStateValueReferences.
+ - Nov. 14, 2011: Adapted to FMI 2.0:
+ o Split into two files (fmiFunctions.h, fmiTypes.h) in order
+ that code that dynamically loads an FMU can directly
+ utilize the header files).
+ o Added C++ encapsulation of C-part, in order that the header
+ file can be directly utilized in C++ code.
+ o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
+ o stepFinished within fmiCallbackFunctions has as first
+ argument "fmiComponentEnvironment" and not "fmiComponent".
+ o New functions to get and set the complete FMU state
+ and to compute partial derivatives.
+ - Nov. 4, 2010: Adapted to specification text:
+ o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
+ o fmiInstantiateSlave: Argument GUID replaced by fmuGUID
+ Argument mimetype replaced by mimeType
+ o tabs replaced by spaces
+ - Oct. 16, 2010: Functions for FMI for Co-simulation added
+ - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
+ (by M. Otter, DLR)
+ Added WIN32 pragma to define the struct layout (ticket #34)
+ (by J. Mauss, QTronic)
+ - Jan. 4, 2010: Removed argument intermediateResults from fmiInitialize
+ Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
+ Renamed macro fmiModelFunctionsVersion to fmiVersion
+ Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
+ (by J. Mauss, QTronic)
+ - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
+ - Dez. 14, 2009: Added eventInfo to meInitialize and added
+ meGetNominalContinuousStates (by Martin Otter, DLR)
+ - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
+ (by A. Junghanns, QTronic)
+ - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+ meInquireModelTypesVersion -> meGetModelTypesPlatform
+ meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
+ meSetStates -> meSetContinuousStates
+ meGetStates -> meGetContinuousStates
+ removal of meInitializeModelClass
+ removal of meGetTime
+ change of arguments of meInstantiateModel
+ change of arguments of meCompletedIntegratorStep
+ (by Martin Otter, DLR):
+ - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
+ - March 2, 2009: Changed function definitions according to the last design
+ meeting with additional improvements (by Martin Otter, DLR).
+ - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
+
+ Copyright © 2008-2011 MODELISAR consortium,
+ 2012-2013 Modelica Association Project "FMI"
+ All rights reserved.
+ This file is licensed by the copyright holders under the BSD 2-Clause License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+
+ with the extension:
+
+ You may distribute or publicly perform any modification only under the
+ terms of this license.
+ (Note, this means that if you distribute a modified file,
+ the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "fmi2TypesPlatform.h"
+#include "fmi2FunctionTypes.h"
+#include
+
+
+/*
+ Export FMI2 API functions on Windows and under GCC.
+ If custom linking is desired then the FMI2_Export must be
+ defined before including this file. For instance,
+ it may be set to __declspec(dllimport).
+*/
+#if !defined(FMI2_Export)
+ #if !defined(FMI2_FUNCTION_PREFIX)
+ #if defined _WIN32 || defined __CYGWIN__
+ /* Note: both gcc & MSVC on Windows support this syntax. */
+ #define FMI2_Export __declspec(dllexport)
+ #else
+ #if __GNUC__ >= 4
+ #define FMI2_Export __attribute__ ((visibility ("default")))
+ #else
+ #define FMI2_Export
+ #endif
+ #endif
+ #else
+ #define FMI2_Export
+ #endif
+#endif
+
+/* Macros to construct the real function name
+ (prepend function name by FMI2_FUNCTION_PREFIX) */
+#if defined(FMI2_FUNCTION_PREFIX)
+ #define fmi2Paste(a,b) a ## b
+ #define fmi2PasteB(a,b) fmi2Paste(a,b)
+ #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
+#else
+ #define fmi2FullName(name) name
+#endif
+
+/***************************************************
+Common Functions
+****************************************************/
+#define fmi2GetTypesPlatform fmi2FullName(fmi2GetTypesPlatform)
+#define fmi2GetVersion fmi2FullName(fmi2GetVersion)
+#define fmi2SetDebugLogging fmi2FullName(fmi2SetDebugLogging)
+#define fmi2Instantiate fmi2FullName(fmi2Instantiate)
+#define fmi2FreeInstance fmi2FullName(fmi2FreeInstance)
+#define fmi2SetupExperiment fmi2FullName(fmi2SetupExperiment)
+#define fmi2EnterInitializationMode fmi2FullName(fmi2EnterInitializationMode)
+#define fmi2ExitInitializationMode fmi2FullName(fmi2ExitInitializationMode)
+#define fmi2Terminate fmi2FullName(fmi2Terminate)
+#define fmi2Reset fmi2FullName(fmi2Reset)
+#define fmi2GetReal fmi2FullName(fmi2GetReal)
+#define fmi2GetInteger fmi2FullName(fmi2GetInteger)
+#define fmi2GetBoolean fmi2FullName(fmi2GetBoolean)
+#define fmi2GetString fmi2FullName(fmi2GetString)
+#define fmi2SetReal fmi2FullName(fmi2SetReal)
+#define fmi2SetInteger fmi2FullName(fmi2SetInteger)
+#define fmi2SetBoolean fmi2FullName(fmi2SetBoolean)
+#define fmi2SetString fmi2FullName(fmi2SetString)
+#define fmi2GetFMUstate fmi2FullName(fmi2GetFMUstate)
+#define fmi2SetFMUstate fmi2FullName(fmi2SetFMUstate)
+#define fmi2FreeFMUstate fmi2FullName(fmi2FreeFMUstate)
+#define fmi2SerializedFMUstateSize fmi2FullName(fmi2SerializedFMUstateSize)
+#define fmi2SerializeFMUstate fmi2FullName(fmi2SerializeFMUstate)
+#define fmi2DeSerializeFMUstate fmi2FullName(fmi2DeSerializeFMUstate)
+#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+#define fmi2EnterEventMode fmi2FullName(fmi2EnterEventMode)
+#define fmi2NewDiscreteStates fmi2FullName(fmi2NewDiscreteStates)
+#define fmi2EnterContinuousTimeMode fmi2FullName(fmi2EnterContinuousTimeMode)
+#define fmi2CompletedIntegratorStep fmi2FullName(fmi2CompletedIntegratorStep)
+#define fmi2SetTime fmi2FullName(fmi2SetTime)
+#define fmi2SetContinuousStates fmi2FullName(fmi2SetContinuousStates)
+#define fmi2GetDerivatives fmi2FullName(fmi2GetDerivatives)
+#define fmi2GetEventIndicators fmi2FullName(fmi2GetEventIndicators)
+#define fmi2GetContinuousStates fmi2FullName(fmi2GetContinuousStates)
+#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+#define fmi2SetRealInputDerivatives fmi2FullName(fmi2SetRealInputDerivatives)
+#define fmi2GetRealOutputDerivatives fmi2FullName(fmi2GetRealOutputDerivatives)
+#define fmi2DoStep fmi2FullName(fmi2DoStep)
+#define fmi2CancelStep fmi2FullName(fmi2CancelStep)
+#define fmi2GetStatus fmi2FullName(fmi2GetStatus)
+#define fmi2GetRealStatus fmi2FullName(fmi2GetRealStatus)
+#define fmi2GetIntegerStatus fmi2FullName(fmi2GetIntegerStatus)
+#define fmi2GetBooleanStatus fmi2FullName(fmi2GetBooleanStatus)
+#define fmi2GetStringStatus fmi2FullName(fmi2GetStringStatus)
+
+/* Version number */
+#define fmi2Version "2.0"
+
+
+/***************************************************
+Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files */
+ FMI2_Export fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;
+ FMI2_Export fmi2GetVersionTYPE fmi2GetVersion;
+ FMI2_Export fmi2SetDebugLoggingTYPE fmi2SetDebugLogging;
+
+/* Creation and destruction of FMU instances */
+ FMI2_Export fmi2InstantiateTYPE fmi2Instantiate;
+ FMI2_Export fmi2FreeInstanceTYPE fmi2FreeInstance;
+
+/* Enter and exit initialization mode, terminate and reset */
+ FMI2_Export fmi2SetupExperimentTYPE fmi2SetupExperiment;
+ FMI2_Export fmi2EnterInitializationModeTYPE fmi2EnterInitializationMode;
+ FMI2_Export fmi2ExitInitializationModeTYPE fmi2ExitInitializationMode;
+ FMI2_Export fmi2TerminateTYPE fmi2Terminate;
+ FMI2_Export fmi2ResetTYPE fmi2Reset;
+
+/* Getting and setting variables values */
+ FMI2_Export fmi2GetRealTYPE fmi2GetReal;
+ FMI2_Export fmi2GetIntegerTYPE fmi2GetInteger;
+ FMI2_Export fmi2GetBooleanTYPE fmi2GetBoolean;
+ FMI2_Export fmi2GetStringTYPE fmi2GetString;
+
+ FMI2_Export fmi2SetRealTYPE fmi2SetReal;
+ FMI2_Export fmi2SetIntegerTYPE fmi2SetInteger;
+ FMI2_Export fmi2SetBooleanTYPE fmi2SetBoolean;
+ FMI2_Export fmi2SetStringTYPE fmi2SetString;
+
+/* Getting and setting the internal FMU state */
+ FMI2_Export fmi2GetFMUstateTYPE fmi2GetFMUstate;
+ FMI2_Export fmi2SetFMUstateTYPE fmi2SetFMUstate;
+ FMI2_Export fmi2FreeFMUstateTYPE fmi2FreeFMUstate;
+ FMI2_Export fmi2SerializedFMUstateSizeTYPE fmi2SerializedFMUstateSize;
+ FMI2_Export fmi2SerializeFMUstateTYPE fmi2SerializeFMUstate;
+ FMI2_Export fmi2DeSerializeFMUstateTYPE fmi2DeSerializeFMUstate;
+
+/* Getting partial derivatives */
+ FMI2_Export fmi2GetDirectionalDerivativeTYPE fmi2GetDirectionalDerivative;
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+ FMI2_Export fmi2EnterEventModeTYPE fmi2EnterEventMode;
+ FMI2_Export fmi2NewDiscreteStatesTYPE fmi2NewDiscreteStates;
+ FMI2_Export fmi2EnterContinuousTimeModeTYPE fmi2EnterContinuousTimeMode;
+ FMI2_Export fmi2CompletedIntegratorStepTYPE fmi2CompletedIntegratorStep;
+
+/* Providing independent variables and re-initialization of caching */
+ FMI2_Export fmi2SetTimeTYPE fmi2SetTime;
+ FMI2_Export fmi2SetContinuousStatesTYPE fmi2SetContinuousStates;
+
+/* Evaluation of the model equations */
+ FMI2_Export fmi2GetDerivativesTYPE fmi2GetDerivatives;
+ FMI2_Export fmi2GetEventIndicatorsTYPE fmi2GetEventIndicators;
+ FMI2_Export fmi2GetContinuousStatesTYPE fmi2GetContinuousStates;
+ FMI2_Export fmi2GetNominalsOfContinuousStatesTYPE fmi2GetNominalsOfContinuousStates;
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+ FMI2_Export fmi2SetRealInputDerivativesTYPE fmi2SetRealInputDerivatives;
+ FMI2_Export fmi2GetRealOutputDerivativesTYPE fmi2GetRealOutputDerivatives;
+
+ FMI2_Export fmi2DoStepTYPE fmi2DoStep;
+ FMI2_Export fmi2CancelStepTYPE fmi2CancelStep;
+
+/* Inquire slave status */
+ FMI2_Export fmi2GetStatusTYPE fmi2GetStatus;
+ FMI2_Export fmi2GetRealStatusTYPE fmi2GetRealStatus;
+ FMI2_Export fmi2GetIntegerStatusTYPE fmi2GetIntegerStatus;
+ FMI2_Export fmi2GetBooleanStatusTYPE fmi2GetBooleanStatus;
+ FMI2_Export fmi2GetStringStatusTYPE fmi2GetStringStatus;
+
+#ifdef __cplusplus
+} /* end of extern "C" { */
+#endif
+
+#endif /* fmi2Functions_h */
\ No newline at end of file
diff --git a/fmu20/src/shared/include/fmi2TypesPlatform.h b/fmu20/src/shared/include/fmi2TypesPlatform.h
new file mode 100644
index 0000000..03c7339
--- /dev/null
+++ b/fmu20/src/shared/include/fmi2TypesPlatform.h
@@ -0,0 +1,115 @@
+#ifndef fmi2TypesPlatform_h
+#define fmi2TypesPlatform_h
+
+/* Standard header file to define the argument types of the
+ functions of the Functional Mock-up Interface 2.0.
+ This header file must be utilized both by the model and
+ by the simulation engine.
+
+ Revisions:
+ - Apr. 9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+ - Mar 31, 2014: New datatype fmiChar introduced.
+ - Feb. 17, 2013: Changed fmiTypesPlatform from "standard32" to "default".
+ Removed fmiUndefinedValueReference since no longer needed
+ (because every state is defined in ScalarVariables).
+ - March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
+ - Nov. 14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
+ both for "FMI for model exchange" and for "FMI for co-simulation"
+ New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
+ The implementation of "fmiBoolean" is change from "char" to "int".
+ The #define "fmiPlatform" changed to "fmiTypesPlatform"
+ (in order that #define and function call are consistent)
+ - Oct. 4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
+ for the co-simulation interface
+ - Jan. 4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
+ - Dec. 21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
+ according to meeting on Dec. 18 (by Martin Otter, DLR)
+ - Dec. 6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
+ - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+ Changed "version" to "platform", "standard" to "standard32",
+ Added a precise definition of "standard32" as comment
+ (by Martin Otter, DLR)
+ - July 19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
+ and changed meValueReferenced from int to unsigned int
+ (by Martin Otter, DLR).
+ - March 2, 2009: Moved enums and function pointer definitions to
+ ModelFunctions.h (by Martin Otter, DLR).
+ - Dec. 3, 2008 : First version by Martin Otter (DLR) and
+ Hans Olsson (Dynasim).
+
+
+ Copyright © 2008-2011 MODELISAR consortium,
+ 2012-2013 Modelica Association Project "FMI"
+ All rights reserved.
+ This file is licensed by the copyright holders under the BSD 2-Clause License
+ (http://www.opensource.org/licenses/bsd-license.html):
+
+ ----------------------------------------------------------------------------
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+ ----------------------------------------------------------------------------
+
+ with the extension:
+
+ You may distribute or publicly perform any modification only under the
+ terms of this license.
+ (Note, this means that if you distribute a modified file,
+ the modified file must also be provided under this license).
+*/
+
+/* Platform (unique identification of this header file) */
+#define fmi2TypesPlatform "default"
+
+/* Type definitions of variables passed as arguments
+ Version "default" means:
+
+ fmi2Component : an opaque object pointer
+ fmi2ComponentEnvironment: an opaque object pointer
+ fmi2FMUstate : an opaque object pointer
+ fmi2ValueReference : handle to the value of a variable
+ fmi2Real : double precision floating-point data type
+ fmi2Integer : basic signed integer data type
+ fmi2Boolean : basic signed integer data type
+ fmi2Char : character data type
+ fmi2String : a pointer to a vector of fmi2Char characters
+ ('\0' terminated, UTF8 encoded)
+ fmi2Byte : smallest addressable unit of the machine, typically one byte.
+*/
+ typedef void* fmi2Component; /* Pointer to FMU instance */
+ typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+ typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+ typedef unsigned int fmi2ValueReference;
+ typedef double fmi2Real ;
+ typedef int fmi2Integer;
+ typedef int fmi2Boolean;
+ typedef char fmi2Char;
+ typedef const fmi2Char* fmi2String;
+ typedef char fmi2Byte;
+
+/* Values for fmi2Boolean */
+#define fmi2True 1
+#define fmi2False 0
+
+
+#endif /* fmi2TypesPlatform_h */
diff --git a/fmu20/src/shared/parser/XmlElement.cpp b/fmu20/src/shared/parser/XmlElement.cpp
new file mode 100644
index 0000000..9645652
--- /dev/null
+++ b/fmu20/src/shared/parser/XmlElement.cpp
@@ -0,0 +1,676 @@
+/*
+ * Copyright QTronic GmbH. All rights reserved.
+ */
+
+/* ---------------------------------------------------------------------------*
+ * XmlElement.cpp
+ * Elements implementation that describe content of model description of a
+ * FMI 2.0 model. All elements have Element as parent class. Elements have
+ * attributes and other specific content.
+ *
+ * Author: Adrian Tirea
+ * ---------------------------------------------------------------------------*/
+
+#include "fmu20/XmlElement.h"
+#include
+#include