]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/Test/FMI1/compress_test_fmu_zip.c
Switch to full JavaSE-11+ compatibility
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / Test / FMI1 / compress_test_fmu_zip.c
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
7      This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10     FMILIB_License.txt file for more details.
11
12     You should have received a copy of the FMILIB_License.txt file
13     along with this program. If not, contact Modelon AB <http://www.modelon.com>.
14 */
15
16 #include <stdio.h>\r
17 #include <stdlib.h>\r
18 #include <JM/jm_types.h>\r
19 #include <JM/jm_callbacks.h>\r
20 #include <FMI/fmi_zip_zip.h>\r
21 \r
22 static void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
23 {
24         printf("module = %s, log level = %d: %s\n", module, log_level, message);
25 }\r
26
27 int main(int argc, char *argv[])\r
28 {\r
29         jm_status_enu_t status;\r
30         jm_callbacks callbacks;\r
31         char* output_name;      \r
32         const char** files_to_zip;\r
33         int n_files_to_zip;\r
34 \r
35         callbacks.malloc = malloc;
36     callbacks.calloc = calloc;
37     callbacks.realloc = realloc;
38     callbacks.free = free;
39     callbacks.logger = importlogger;
40         callbacks.log_level = jm_log_level_debug;\r
41
42     callbacks.context = 0;\r
43 \r
44         if (argc < 3) {\r
45                 printf("Not enought input arguments\n");\r
46                 return 1;\r
47         }\r
48 \r
49         output_name = argv[1];\r
50         files_to_zip = &argv[2];\r
51         n_files_to_zip = argc - 2;\r
52 \r
53         status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks);\r
54 \r
55         if (status == jm_status_error) {\r
56                 printf("Failed to compress the file\n");\r
57                 return 1;\r
58         } else {\r
59                 printf("Succesfully compressed the file\n");\r
60                 return 0;\r
61         }       \r
62         \r
63 }