-
Notifications
You must be signed in to change notification settings - Fork 1
/
calcCov_main.c
129 lines (113 loc) · 3.41 KB
/
calcCov_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* MATLAB Compiler: 4.13 (R2010a)
* Date: Mon Feb 27 23:25:18 2012
* Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe" "calcCov.m"
*/
#include <stdio.h>
#include "mclmcrrt.h"
#ifdef __cplusplus
extern "C" {
#endif
extern mclComponentData __MCC_calcCov_component_data;
#ifdef __cplusplus
}
#endif
static HMCRINSTANCE _mcr_inst = NULL;
#ifdef __cplusplus
extern "C" {
#endif
static int mclDefaultPrintHandler(const char *s)
{
return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s));
}
#ifdef __cplusplus
} /* End extern "C" block */
#endif
#ifdef __cplusplus
extern "C" {
#endif
static int mclDefaultErrorHandler(const char *s)
{
int written = 0;
size_t len = 0;
len = strlen(s);
written = mclWrite(2 /* stderr */, s, sizeof(char)*len);
if (len > 0 && s[ len-1 ] != '\n')
written += mclWrite(2 /* stderr */, "\n", sizeof(char));
return written;
}
#ifdef __cplusplus
} /* End extern "C" block */
#endif
#ifndef LIB_calcCov_C_API
#define LIB_calcCov_C_API /* No special import/export declaration */
#endif
LIB_calcCov_C_API
bool MW_CALL_CONV calcCovInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler)
{
int bResult = 0;
if (_mcr_inst != NULL)
return true;
if (!mclmcrInitialize())
return false;
{
mclCtfStream ctfStream =
mclGetEmbeddedCtfStream(NULL,
64255);
if (ctfStream) {
bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst,
&__MCC_calcCov_component_data,
true,
NoObjectType,
ExeTarget,
error_handler,
print_handler,
ctfStream,
64255);
mclDestroyStream(ctfStream);
} else {
bResult = 0;
}
}
if (!bResult)
return false;
return true;
}
LIB_calcCov_C_API
bool MW_CALL_CONV calcCovInitialize(void)
{
return calcCovInitializeWithHandlers(mclDefaultErrorHandler, mclDefaultPrintHandler);
}
LIB_calcCov_C_API
void MW_CALL_CONV calcCovTerminate(void)
{
if (_mcr_inst != NULL)
mclTerminateInstance(&_mcr_inst);
}
int run_main(int argc, const char **argv)
{
int _retval;
/* Generate and populate the path_to_component. */
char path_to_component[(PATH_MAX*2)+1];
separatePathName(argv[0], path_to_component, (PATH_MAX*2)+1);
__MCC_calcCov_component_data.path_to_component = path_to_component;
if (!calcCovInitialize()) {
return -1;
}
argc = mclSetCmdLineUserData(mclGetID(_mcr_inst), argc, argv);
_retval = mclMain(_mcr_inst, argc, argv, "calcCov", 0);
if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL);
calcCovTerminate();
mclTerminateApplication();
return _retval;
}
int main(int argc, const char **argv)
{
if (!mclInitializeApplication(
__MCC_calcCov_component_data.runtime_options,
__MCC_calcCov_component_data.runtime_option_count))
return 0;
return mclRunMain(run_main, argc, argv);
}