]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/Test/fmi_zip_unzip_test.c
Merge "Added getters and setters for all FMI data types."
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / Test / fmi_zip_unzip_test.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 */\r
15 \r
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stdarg.h>
19 #include <string.h>
20 #include <errno.h>\r
21 \r
22 #include <JM/jm_types.h>\r
23 #include <JM/jm_callbacks.h>\r
24 #include <FMI/fmi_zip_unzip.h>\r
25 #include "config_test.h"\r
26 \r
27 \r
28 void do_exit(int code)
29 {
30         printf("Press any key to exit\n");
31         /* getchar(); */
32         exit(code);
33 }\r
34 \r
35 /* Logger function */\r
36 void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
37 {
38         printf("module = %s, log level = %d: %s\n", module, log_level, message);
39 }\r
40 \r
41 /**\r
42  * \brief Unzip test. Tests the fmi_zip_unzip function by uncompressing some file.\r
43  *\r
44  */\r
45 int main(int argc, char *argv[])\r
46 {\r
47         jm_callbacks callbacks;\r
48         jm_status_enu_t status; \r
49 \r
50         callbacks.malloc = malloc;
51     callbacks.calloc = calloc;
52     callbacks.realloc = realloc;
53     callbacks.free = free;
54     callbacks.logger = importlogger;
55         callbacks.log_level = jm_log_level_debug;
56     callbacks.context = 0;\r
57 \r
58         status = fmi_zip_unzip(UNCOMPRESSED_DUMMY_FILE_PATH_SRC, UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST, &callbacks);\r
59 \r
60         if (status == jm_status_error) {\r
61                 printf("Failed to uncompress the file\n");\r
62                 do_exit(CTEST_RETURN_FAIL);\r
63         } else {\r
64                 printf("Succesfully uncompressed the file\n");\r
65                 do_exit(CTEST_RETURN_SUCCESS);\r
66         }\r
67 }\r
68 \r
69 \r