/*
 * MATLAB Compiler: 4.11 (R2009b)
 * Date: Sun May 20 13:57:56 2012
 * Arguments: "-B" "macro_default" "-o" "BCH_kody" "-W" "WinMain:BCH_kody" "-d"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\kompilace\BCH_kody\src" "-T" "link:exe" "-v"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\main_gui.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\BCH_gui.fig" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\BCH_gui.m"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bchbmdek.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bchbmdeksim.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\bchenk.m"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bcheuklidek.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bcheuklideksim.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bchpgzdek.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bchpgzdeksim.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\BM_matlab.jpg" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\bmdec.m"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\bmdeksim.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\BMdiagram.fig" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\BMdiagram.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\logo.jpg"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\main_gui.fig" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\main_gui.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\PGZ_mat.jpg" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\pgzdek.m"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\pgzdeksim.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\PGZdiagram.fig" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\PGZdiagram.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\prenosovykanal.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5 1500\pokus\rsencpz.m"
 * "-a" "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\simulace_gui.fig" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\simulace_gui.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\vyberkod.m" "-a"
 * "D:\Jakub\skola\magistr\4.semestr\diplomka\zaloha 16.5
 * 1500\pokus\vypocticas.m" 
 */
#include <stdio.h>
#include "mclmcrrt.h"
#ifdef __cplusplus
extern "C" {
#endif

extern mclComponentData __MCC_BCH_kody_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_BCH_kody_C_API
#define LIB_BCH_kody_C_API /* No special import/export declaration */
#endif

LIB_BCH_kody_C_API 
bool MW_CALL_CONV BCH_kodyInitializeWithHandlers(
    mclOutputHandlerFcn error_handler,
    mclOutputHandlerFcn print_handler)
{
  if (_mcr_inst != NULL)
    return true;
  if (!mclmcrInitialize())
    return false;
  if (!mclInitializeComponentInstanceWithEmbeddedCTF(&_mcr_inst, 
                                                     &__MCC_BCH_kody_component_data, 
                                                     true, NoObjectType, ExeTarget, 
                                                     error_handler, print_handler, 
                                                     1215835, NULL))
    return false;
  return true;
}

LIB_BCH_kody_C_API 
bool MW_CALL_CONV BCH_kodyInitialize(void)
{
  return BCH_kodyInitializeWithHandlers(mclDefaultErrorHandler, mclDefaultPrintHandler);
}
LIB_BCH_kody_C_API 
void MW_CALL_CONV BCH_kodyTerminate(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_BCH_kody_component_data.path_to_component = path_to_component; 
  if (!BCH_kodyInitialize()) {
    return -1;
  }
  argc = mclSetCmdLineUserData(mclGetID(_mcr_inst), argc, argv);
  _retval = mclMain(_mcr_inst, argc, argv, "main_gui", 0);
  if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL);
  BCH_kodyTerminate();
#if defined( _MSC_VER)
  PostQuitMessage(0);
#endif
  mclTerminateApplication();
  return _retval;
}

#if defined( _MSC_VER)

#define argc __argc
#define argv __argv

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
#else
int main(int argc, const char **argv)

#endif
{
  if (!mclInitializeApplication(
    __MCC_BCH_kody_component_data.runtime_options, 
    __MCC_BCH_kody_component_data.runtime_option_count))
    return 0;

  return mclRunMain(run_main, argc, argv);
}
