]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/Test/FMI1/fmi_zip_zip_test.c
Merge "Added getters and setters for all FMI data types."
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / Test / FMI1 / fmi_zip_zip_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 */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include <JM/jm_types.h>
20 #include <JM/jm_callbacks.h>
21 #include <FMI/fmi_zip_zip.h>
22 #include "config_test.h"
23
24 #define PRINT_MY_DEBUG printf("Line: %d \t File: %s \n",__LINE__, __FILE__)
25
26
27
28 void do_exit(int code)
29 {
30         printf("Press any key to exit\n");
31         /* getchar(); */
32         exit(code);
33 }
34
35 /* Logger function */
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 }
40
41 /**
42  * \brief Zip test. Tests the fmi_zip_zip function by compressing some file.
43  *
44  */
45 int main(int argc, char *argv[])
46 {
47         jm_status_enu_t status;
48         jm_callbacks callbacks;
49         
50         const char* files_to_zip[] = {COMPRESS_DUMMY_FILE_PATH_SRC};
51         int n_files_to_zip = 1;
52
53         callbacks.malloc = malloc;
54     callbacks.calloc = calloc;
55     callbacks.realloc = realloc;
56     callbacks.free = free;
57     callbacks.logger = importlogger;
58         callbacks.log_level = jm_log_level_debug;
59
60     callbacks.context = 0;
61
62         status = fmi_zip_zip(COMPRESS_DUMMY_FILE_PATH_DIST, n_files_to_zip, files_to_zip, &callbacks);
63
64         if (status == jm_status_error) {
65                 printf("Failed to compress the file\n");
66                 do_exit(CTEST_RETURN_FAIL);
67         } else {
68                 printf("Succesfully compressed the file\n");
69                 do_exit(CTEST_RETURN_SUCCESS);
70         }
71     return 0;
72 }
73
74