#include <exec/types.h>
#include <inline/exec.h>
#include <clib/dos_protos.h>
struct Library *MathTransBase;
struct Library *MathBase;
struct Library *MathIeeeDoubBasBase;
struct Library *MathIeeeDoubTransBase;

void close_math(void)
{
	struct Library *lib;

	if(MathBase)
		{ lib=(struct Library *)MathBase;				CloseLibrary(lib); }
	if(MathTransBase)
		{ lib=(struct Library *)MathTransBase; 			CloseLibrary(lib); }
	if(MathIeeeDoubBasBase)
		{ lib=(struct Library *)MathIeeeDoubBasBase;	CloseLibrary(lib); }
	if(MathIeeeDoubTransBase)
		{ lib=(struct Library *)MathIeeeDoubTransBase;	CloseLibrary(lib); }
}

BOOL init_math(void)
{
	atexit(close_math);

	MathBase              = OpenLibrary((STRPTR)"mathffp.library",0L);
	MathTransBase         = OpenLibrary((STRPTR)"mathtrans.library",0L);
	MathIeeeDoubTransBase = OpenLibrary((STRPTR)"mathieeedoubtrans.library",0L);
	MathIeeeDoubBasBase   = OpenLibrary((STRPTR)"mathieeedoubbas.library",0L);

	if(MathBase && MathTransBase && MathIeeeDoubTransBase && MathIeeeDoubBasBase)
		return TRUE;
	else return FALSE;
}


int main(void )
{
	float pi=3.14159265;
	float e=2.71;
	if(init_math())
	{
		/* now we can calculate something */

		return e*pi;	/* will be truncated to an int */
	}
	else
	{
		Printf("Not able to open all math-libraries !\n");
		return 20;
	}
}
