chengji_main.c

来自「matlab开发的GUI程序」· C语言 代码 · 共 98 行

C
98
字号
/*
 * MATLAB Compiler: 4.1 (R14SP1)
 * Date: Mon May 11 14:46:20 2009
 * Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe" "chengji" 
 */

#include <stdio.h>
#include "mclmcr.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char __MCC_chengji_public_data[];
extern const char *__MCC_chengji_name_data;
extern const char *__MCC_chengji_root_data;
extern const unsigned char __MCC_chengji_session_data[];
extern const char *__MCC_chengji_matlabpath_data[];
extern const int __MCC_chengji_matlabpath_data_count;
extern const char *__MCC_chengji_classpath_data[];
extern const int __MCC_chengji_classpath_data_count;
extern const char *__MCC_chengji_mcr_runtime_options[];
extern const int __MCC_chengji_mcr_runtime_option_count;
extern const char *__MCC_chengji_mcr_application_options[];
extern const int __MCC_chengji_mcr_application_option_count;
#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;
}

bool chengjiInitializeWithHandlers(
    mclOutputHandlerFcn error_handler,
    mclOutputHandlerFcn print_handler
)
{
    if (_mcr_inst != NULL)
        return true;
    if (!mclmcrInitialize())
        return false;
    if (!mclInitializeComponentInstance(&_mcr_inst, __MCC_chengji_public_data,
                                        __MCC_chengji_name_data,
                                        __MCC_chengji_root_data,
                                        __MCC_chengji_session_data,
                                        __MCC_chengji_matlabpath_data,
                                        __MCC_chengji_matlabpath_data_count,
                                        __MCC_chengji_classpath_data,
                                        __MCC_chengji_classpath_data_count,
                                        __MCC_chengji_mcr_runtime_options,
                                        __MCC_chengji_mcr_runtime_option_count,
                                        true, NoObjectType, ExeTarget, NULL,
                                        error_handler, print_handler))
        return false;
    return true;
}

bool chengjiInitialize(void)
{
    return chengjiInitializeWithHandlers(mclDefaultErrorHandler,
                                         mclDefaultPrintHandler);
}

void chengjiTerminate(void)
{
    if (_mcr_inst != NULL)
        mclTerminateInstance(&_mcr_inst);
}

int main(int argc, const char **argv)
{
    int _retval;
    if (!mclInitializeApplication(__MCC_chengji_mcr_application_options,
                                  __MCC_chengji_mcr_application_option_count))
        return 0;
    
    if (!chengjiInitialize())
        return -1;
    _retval = mclMain(_mcr_inst, argc, argv, "chengji", 1);
    if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL);
    chengjiTerminate();
    mclTerminateApplication();
    return _retval;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?