/* Main-Header File inserted by GenCodeC */
/* Libraries */
#include <libraries/mui.h>
#include <libraries/gadtools.h> /* for BARLABEL in MenuItem */

/* Prototypes */
#ifdef __SASC
#include <clib/muimaster_protos.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#else
#include <proto/muimaster.h>
#include <proto/exec.h>
#include <proto/alib.h>
#include <proto/dos.h>
#endif

/*  Pragmas  */
#include <pragmas/muimaster_pragmas.h>

/*  Ansi  */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* Increase stack size */
LONG __stack=8192;
/* GenCodeC header end */

/* Include generated by GenCodeC */
#include "FreeCheckGUI.h"
#include "FreeCheckExtern.h"
#include "Hook_Utility.h"

struct ObjApp * App; /* Object */

/* Declarations for libraries (inserted by GenCodeC) */
struct Library * IntuitionBase;
struct Library * MUIMasterBase;
struct Library * LocaleBase;

/* Init() function */
void init( void )
{
	if (!(IntuitionBase = OpenLibrary("intuition.library",37)))
	{
		printf("Can't Open Intuition Library\n");
		exit(20);
	}
	if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
	{
		printf("Can't Open MUIMaster Library\n");
		CloseLibrary(IntuitionBase);
		exit(20);
	}
	if (!(LocaleBase = OpenLibrary("locale.library",38)))
	{
		printf("Can't Open Locale Library\n");
		printf("Built-in Language will be used !!!\n");
	}
	OpenAppCatalog(NULL,NULL);
}
/* GenCodeC init() end */

/* End() function */
void end( void )
{
	CloseAppCatalog();
	if (LocaleBase)
		CloseLibrary(LocaleBase);
	CloseLibrary(MUIMasterBase);
	CloseLibrary(IntuitionBase);
	exit(20);
}
/* GenCodeC end() end */

/* Main Function inserted by GenCodeC */
int main(int argc,char **argv)
{
	BOOL	running = TRUE;
	ULONG	signal;
  
  static struct Hook CarregaConfigHook;
  static struct Hook CarregaUpdateHook;

  InstallHook(&CarregaConfigHook, CarregaConfig, NULL);
  InstallHook(&CarregaUpdateHook, CarregaUpdate, NULL);


	/* Program initialisation : generated by GenCodeC */
	init();

	/* Create Object : generated by GenCodeC */
	if (!(App = CreateApp()))
	{
		printf("Can't Create App\n");
		end();
	}

  DoMethod(App->App, MUIM_CallHook, &CarregaConfigHook);
  DoMethod(App->App, MUIM_CallHook, &CarregaUpdateHook);

	while (running)
	{
		switch (DoMethod(App->App,MUIM_Application_Input,&signal))
		{
			case MUIV_Application_ReturnID_Quit:
				running = FALSE;
				break;

			/* Insert your code between the "case" statement and comment "end of case ..." */
			/* End computing of IDCMP */

			default:
				break;
		}
		if (running && signal) Wait(signal);
	}
	DisposeApp(App);
	end();
}
