// Name:						OpenLibraryClass
// Programmtyp:			Hilfsroutine für
//								Fakturierprogramm
//	Programmiersprache:	C++ (AT&T Standard 3.0)
// Computersystem:		Commodore AMIGA
// Betriebssystem:		AMIGA OS2.0 oder höher
// Autor:					Manfred Tremmel
// © Copyright:			1997-2000 by MT Graphic & Design
// Version:					V1.08
//
//    Copyright (C) 1997-2000 Manfred Tremmel
//
//    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 USA

// Includes:
#include <stdio.h>
#include "MTOpenLibrary.h"
#include "MTLocale.h"
#include "LocaleStrings.h"

struct ExecBase		*ExecBase		= NULL;		// exec.library-Struktur
struct Library 		*LocaleBase		= NULL;		// locale.library-Struktur
struct IntuitionBase *IntuitionBase = NULL;		// intuition.library-Struktur
struct Library			*AslBase			= NULL;		// asl.library-Struktur
struct Library			*GadToolsBase	= NULL;		// gadtools.library-Struktur
struct Library			*UtilityBase	= NULL;		// utility.library-Struktur
struct Library			*WizardBase		= NULL;		// wizard.library-Struktur
struct Library			*IconBase		= NULL;		// icon.library-Struktur
struct Library			*CxBase			= NULL;		// commodities.library-Struktur
struct RxsLib			*RexxSysBase	= NULL;		// rexxsys.library-Struktur
struct Library			*KeymapBase		= NULL;		// keymap.library-Struktur

// Funktionen zur OpenExecLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenExecLibrary::OpenExecLibrary( ULONG Version )
{
	if((ExecBase = (struct ExecBase *)OpenLibrary("exec.library",Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "exec.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destrukotor Library wieder schließen
OpenExecLibrary::~OpenExecLibrary()
{
	if( ExecBase )
		CloseLibrary( (struct Library *)ExecBase );
}

// Funktionen zur OpenLocaleLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenLocaleLibrary::OpenLocaleLibrary( ULONG Version )
{
	if((LocaleBase = OpenLibrary("locale.library", Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "locale.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destrukotor Library wieder schließen
OpenLocaleLibrary::~OpenLocaleLibrary()
{
	if( LocaleBase )
		CloseLibrary( LocaleBase );
}

// Funktionen zur OpenIntuitionLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenIntuitionLibrary::OpenIntuitionLibrary( ULONG Version )
{
	if((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "intuition.library", Version);
		cout << (STRPTR)Fehler << "\n";
		exit(1);
	}
}

// Destruktor Library wieder schließen
OpenIntuitionLibrary::~OpenIntuitionLibrary()
{
	if( IntuitionBase )
		CloseLibrary( (struct Library *)IntuitionBase );
}

// Funktionen zur OpenAslLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenAslLibrary::OpenAslLibrary( ULONG Version )
{
	if((AslBase = OpenLibrary("asl.library", Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "asl.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenAslLibrary::~OpenAslLibrary()
{
	if( AslBase )
		CloseLibrary( AslBase );
}

// Funktionen zur OpenGadToolsLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenGadToolsLibrary::OpenGadToolsLibrary( ULONG Version )
{
	if((GadToolsBase = OpenLibrary("gadtools.library",Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "gadtools.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenGadToolsLibrary::~OpenGadToolsLibrary()
{
	if( GadToolsBase )
		CloseLibrary( GadToolsBase );
}

// Funktionen zur OpenWizardLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenWizardLibrary::OpenWizardLibrary( ULONG Version )
{
	if((WizardBase = OpenLibrary("wizard.library",Version)) == NULL)
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "wizard.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenWizardLibrary::~OpenWizardLibrary()
{
	if( WizardBase )
		CloseLibrary( WizardBase );
}

// Funktionen zur OpenUtilityLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenUtilityLibrary::OpenUtilityLibrary( ULONG Version )
{
	if((UtilityBase = OpenLibrary("utility.library",Version)) == NULL )
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "utility.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenUtilityLibrary::~OpenUtilityLibrary()
{
	if( UtilityBase )
		CloseLibrary( UtilityBase );
}

// Funktionen zur OpenIconLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenIconLibrary::OpenIconLibrary( ULONG Version )
{
	if((IconBase = OpenLibrary("icon.library",Version)) == NULL )
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "icon.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenIconLibrary::~OpenIconLibrary()
{
	if( IconBase )
		CloseLibrary( IconBase );
}

// Funktionen zur OpenCxLibrary Klasse
// Öffnen der Library (Konstruktor)
// OpenCxLibrary::OpenCxLibrary( ULONG Version )
// {
//	if((CxBase = OpenLibrary("commodities.library",Version)) == NULL )
//	{
//		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "commodities.library", Version);
//		throw (STRPTR)Fehler;
//	}
// }

// Destruktor Library wieder schließen
// OpenCxLibrary::~OpenCxLibrary()
// {
//	if( CxBase )
//		CloseLibrary( CxBase );
// }

// Funktionen zur OpenRexxSysLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenRexxSysLibrary::OpenRexxSysLibrary( ULONG Version )
{
	if((RexxSysBase = (struct RxsLib *)OpenLibrary(RXSNAME,Version)) == NULL )
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], RXSNAME, Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenRexxSysLibrary::~OpenRexxSysLibrary()
{
	if( RexxSysBase )
		CloseLibrary( (struct Library *)RexxSysBase );
}

// Funktionen zur OpenKeymapLibrary Klasse
// Öffnen der Library (Konstruktor)
OpenKeymapLibrary::OpenKeymapLibrary( ULONG Version )
{
	if((KeymapBase = OpenLibrary("keymap.library",Version)) == NULL )
	{
		sprintf( Fehler, AppStrings[MSG_ReQuest_Library], "Keymap.library", Version);
		throw (STRPTR)Fehler;
	}
}

// Destruktor Library wieder schließen
OpenKeymapLibrary::~OpenKeymapLibrary()
{
	if( KeymapBase )
		CloseLibrary( KeymapBase );
}

