]> gerrit.simantics Code Review - simantics/fmil.git/blobdiff - org.simantics.fmil.core/native/FMILibrary/Test/FMI1/compress_test_fmu_zip.c
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / Test / FMI1 / compress_test_fmu_zip.c
diff --git a/org.simantics.fmil.core/native/FMILibrary/Test/FMI1/compress_test_fmu_zip.c b/org.simantics.fmil.core/native/FMILibrary/Test/FMI1/compress_test_fmu_zip.c
new file mode 100644 (file)
index 0000000..58e1f2f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+    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>.
+*/
+
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <JM/jm_types.h>\r
+#include <JM/jm_callbacks.h>\r
+#include <FMI/fmi_zip_zip.h>\r
+\r
+static void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
+{
+        printf("module = %s, log level = %d: %s\n", module, log_level, message);
+}\r
+
+int main(int argc, char *argv[])\r
+{\r
+       jm_status_enu_t status;\r
+       jm_callbacks callbacks;\r
+       char* output_name;      \r
+       const char** files_to_zip;\r
+       int n_files_to_zip;\r
+\r
+       callbacks.malloc = malloc;
+    callbacks.calloc = calloc;
+    callbacks.realloc = realloc;
+    callbacks.free = free;
+    callbacks.logger = importlogger;
+       callbacks.log_level = jm_log_level_debug;\r
+
+    callbacks.context = 0;\r
+\r
+       if (argc < 3) {\r
+               printf("Not enought input arguments\n");\r
+               return 1;\r
+       }\r
+\r
+       output_name = argv[1];\r
+       files_to_zip = &argv[2];\r
+       n_files_to_zip = argc - 2;\r
+\r
+       status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks);\r
+\r
+       if (status == jm_status_error) {\r
+               printf("Failed to compress the file\n");\r
+               return 1;\r
+       } else {\r
+               printf("Succesfully compressed the file\n");\r
+               return 0;\r
+       }       \r
+       \r
+}
\ No newline at end of file