/**************************************/
/***** FILLIN							 *****/
/***** (c) 1996 by Dirk Holtwick  *****/
/**************************************/

#define WBWINNAME "con:20/20/300/100/ERRORS of FillIn 1.2/close/auto/wait"

#include <wbstartup.h> 
#include <exec/memory.h>
#include <workbench/workbench.h>
#include <clib/icon_protos.h>
#include <libraries/mui.h>
#include <clib/muimaster_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <pragma/muimaster_lib.h>
#include <pragma/exec_lib.h>
#include <pragma/asl_lib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#include "cat.h"
#include "fillout.h"

struct Library * LocaleBase=0;
struct Library * MUIMasterBase;
struct ObjApp * App = NULL;
char	*text=0,*lister=0;

#include "hooks.c"

/*************************/
/***** Hauptschleife *****/
/*************************/

static void init( void ){
	if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))){
		printf("Can't Open MUIMaster Library");
		exit(20);
	}
}

void main(int argc, char *argv[]){
	BOOL	running = TRUE;
	ULONG	signal;

	init();

   LocaleBase = OpenLibrary("locale.library", 38);
   OpenFillInCatalog(NULL, NULL);

	if(App = CreateApp()){

		if(argc>1){
			set (App->str_file, MUIA_String_Contents, argv[1]);
			do_load();
		}

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

		DisposeApp(App);
	}else puts("Couldn't open MUI-Application");

	if(text)		free(text);
	if(lister)	free(lister);

   CloseFillInCatalog();
   if (LocaleBase != NULL) CloseLibrary(LocaleBase);

	CloseLibrary(MUIMasterBase);
	exit(0);
}

