--- /dev/null
+/*
+ Copyright (C) 2012 Modelon AB
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the BSD style license.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ FMILIB_License.txt file for more details.
+
+ You should have received a copy of the FMILIB_License.txt file
+ along with this program. If not, contact Modelon AB <http://www.modelon.com>.
+*/\r
+\r
+#include <assert.h>\r
+#include <string.h>\r
+#include <stdio.h>\r
+#include <FMI/fmi_util.h>\r
+\r
+char* fmi_construct_dll_dir_name(jm_callbacks* callbacks, const char* fmu_unzipped_path) {\r
+ char* dir_path;\r
+ size_t len;\r
+\r
+ assert( fmu_unzipped_path && callbacks);\r
+\r
+ len = \r
+ strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP)\r
+ + strlen(FMI_BINARIES) + strlen(FMI_FILE_SEP) \r
+ + strlen(FMI_PLATFORM) + strlen(FMI_FILE_SEP) + 1;\r
+\r
+ dir_path = (char*)callbacks->malloc(len);\r
+ if (dir_path == NULL) {\r
+ jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory.");\r
+ return NULL;\r
+ }\r
+\r
+ sprintf(dir_path, "%s%s%s%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_BINARIES, FMI_FILE_SEP, FMI_PLATFORM, FMI_FILE_SEP);/*safe */\r
+\r
+ return dir_path;\r
+}\r
+\r
+char* fmi_construct_dll_file_name(jm_callbacks* callbacks, const char* dll_dir_name, const char* model_identifier) {
+ char* fname;
+ size_t len;
+ assert(callbacks && model_identifier);
+ len =
+ strlen(dll_dir_name) +
+ strlen(model_identifier)
+ + strlen(FMI_DLL_EXT) + 1;
+ fname = (char*)callbacks->malloc(len);\r
+ if (fname == NULL) {\r
+ jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory.");\r
+ return NULL;\r
+ }\r
+ sprintf(fname, "%s%s%s", dll_dir_name, model_identifier, FMI_DLL_EXT);/*safe */\r
+\r
+ return fname;\r
+}