/*  Copyright (C) 2002 Tom Parker (tom@carrott.org),
                       Matthias Münch (matthias@amigaworld.de)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    In addition, as a special exception, Tom Parker and Matthias Münch give
    permission to link the code of this program with a TCP stack of your 
    choice, any official MUI libraries or classes and any custom MUI classes
    that should be necessary for the operation of this program.  This 
    exception also gives you permission to distribute linked combinations 
    including this software with any of the before-mentioned libraries and 
    classes.  You must obey the GNU General Public License in all respects for
    all of the code used other than that provided by the before-mentioned 
    libraries and classes.  As part of this exception you are obliged to 
    follow the license terms of the before-mentioned libraries, this license
    does not compel you to follow those terms, but if you do not then you may
    not link with those libraries.  If you modify this file, you may extend
    this exception to your version of the file, but you are not obligated to
    do so.  If you do not wish to do so, delete this exception statement from
    your version.
*/
/*
** main entry point
*/

#include "common.h"

#include <proto/exec.h>
#include <dos/dos.h>

#include "madthread.h"

long __stack = JABBERWOCKY_STACK;

struct IntuitionBase *IntuitionBase = NULL;
/* struct LocaleBase *LocaleBase = NULL; */
struct UtilityBase *UtilityBase = NULL;
struct GfxBase *GfxBase = NULL;
struct Library *IconBase = NULL;


int main(int argc, char *argv[])
{
	IntuitionBase = OpenLibrary("intuition.library", 0);
	UtilityBase = OpenLibrary("utility.library", 0);
	GfxBase = OpenLibrary("graphics.library", 0);
	IconBase = OpenLibrary("icon.library", 0);

/*	IksemelBase = OpenLibrary("iksemel.library", 0);
	if(!IksemelBase)
	{
		printf("Cannot open iksemel.library\n");
		return RETURN_FAIL;
	}
*/
	if(!mt_setup())
	{
/*		CloseLibrary(IksemelBase); */
		return RETURN_FAIL;
	}

	prf_setup(argc, argv);


	gui_run();


	mt_cleanup();

/*	CloseLibrary(IksemelBase); */

	CloseLibrary(IconBase);
	CloseLibrary(GfxBase);
	CloseLibrary(UtilityBase);
	CloseLibrary(IntuitionBase);

	return RETURN_OK;
}
