-
Notifications
You must be signed in to change notification settings - Fork 1
/
calcMean_main.c
129 lines (113 loc) · 3.43 KB
/
calcMean_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: Tue May 31 13:41:35 2011
* Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe" "calcMean"
*/
#include <stdio.h>
#include "mclmcrrt.h"
#ifdef __cplusplus
extern "C" {
#endif
extern mclComponentData __MCC_calcMean_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_calcMean_C_API
#define LIB_calcMean_C_API /* No special import/export declaration */
#endif
LIB_calcMean_C_API
bool MW_CALL_CONV calcMeanInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler)
{
int bResult = 0;
if (_mcr_inst != NULL)
return true;
if (!mclmcrInitialize())
return false;
{
mclCtfStream ctfStream =
mclGetEmbeddedCtfStream(NULL,
55338);
if (ctfStream) {
bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst,
&__MCC_calcMean_component_data,
true,
NoObjectType,
ExeTarget,
error_handler,
print_handler,
ctfStream,
55338);
mclDestroyStream(ctfStream);
} else {
bResult = 0;
}
}
if (!bResult)
return false;
return true;
}
LIB_calcMean_C_API
bool MW_CALL_CONV calcMeanInitialize(void)
{
return calcMeanInitializeWithHandlers(mclDefaultErrorHandler, mclDefaultPrintHandler);
}
LIB_calcMean_C_API
void MW_CALL_CONV calcMeanTerminate(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_calcMean_component_data.path_to_component = path_to_component;
if (!calcMeanInitialize()) {
return -1;
}
argc = mclSetCmdLineUserData(mclGetID(_mcr_inst), argc, argv);
_retval = mclMain(_mcr_inst, argc, argv, "calcMean", 0);
if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL);
calcMeanTerminate();
mclTerminateApplication();
return _retval;
}
int main(int argc, const char **argv)
{
if (!mclInitializeApplication(
__MCC_calcMean_component_data.runtime_options,
__MCC_calcMean_component_data.runtime_option_count))
return 0;
return mclRunMain(run_main, argc, argv);
}