-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatCompute_main.c
More file actions
104 lines (89 loc) · 2.65 KB
/
catCompute_main.c
File metadata and controls
104 lines (89 loc) · 2.65 KB
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
/*
* MATLAB Compiler: 4.3 (R14SP3)
* Date: Wed Jan 17 16:46:15 2007
* Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe"
* "catCompute"
*/
#include <stdio.h>
#include "mclmcr.h"
#ifdef __cplusplus
extern "C" {
#endif
extern mclComponentData __MCC_catCompute_component_data;
#ifdef __cplusplus
}
#endif
static HMCRINSTANCE _mcr_inst = NULL;
static int mclDefaultPrintHandler(const char *s)
{
return fwrite(s, sizeof(char), strlen(s), stdout);
}
static int mclDefaultErrorHandler(const char *s)
{
int written = 0, len = 0;
len = strlen(s);
written = fwrite(s, sizeof(char), len, stderr);
if (len > 0 && s[ len-1 ] != '\n')
written += fwrite("\n", sizeof(char), 1, stderr);
return written;
}
/* This symbol is defined in shared libraries. Define it here
* (to nothing) in case this isn't a shared library.
*/
#ifndef LIB_catCompute_C_API
#define LIB_catCompute_C_API /* No special import/export declaration */
#endif
LIB_catCompute_C_API
bool catComputeInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler
)
{
if (_mcr_inst != NULL)
return true;
if (!mclmcrInitialize())
return false;
if (!mclInitializeComponentInstance(&_mcr_inst,
&__MCC_catCompute_component_data,
true, NoObjectType, ExeTarget,
error_handler, print_handler))
return false;
return true;
}
LIB_catCompute_C_API
bool catComputeInitialize(void)
{
return catComputeInitializeWithHandlers(mclDefaultErrorHandler,
mclDefaultPrintHandler);
}
LIB_catCompute_C_API
void catComputeTerminate(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 = separatePathName(argv[0]);
__MCC_catCompute_component_data.path_to_component = path_to_component;
if (!catComputeInitialize()) {
free(path_to_component);
return -1;
}
_retval = mclMain(_mcr_inst, argc, argv, "catCompute", 0);
if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL);
catComputeTerminate();
free(path_to_component);
mclTerminateApplication();
return _retval;
}
int main(int argc, const char **argv)
{
if (!mclInitializeApplication(
__MCC_catCompute_component_data.application_options,
__MCC_catCompute_component_data.application_option_count))
return 0;
return mclRunMain(run_main, argc, argv);
}