
#include <exec/types.h>
#include "hh:template.h"
#define L_V ((LONG)LIBRARY_VERSION)

#ifndef _CDECL
#define _CDECL(a) ()
#endif

BYTE *Custom = (BYTE *)0x00FFD000L;

struct DosBase   *DosBase             = NULL ;
struct ExecBase  *ExecBase            = NULL ;
struct Intuition *IntuitionBase       = NULL ;
struct GfxBase   *GfxBase             = NULL ;

extern struct Library *OpenLibrary  _CDECL((TEXT *, ULONG));
extern VOID            CloseLibrary _CDECL((struct Library *));
extern VOID            program      _CDECL((ULONG, TEXT **));
extern VOID            exit         _CDECL((LONG));

VOID main _CDECL((int, TEXT **));
VOID quit _CDECL((LONG));


 VOID
main(argc,argv)
 int argc;
 TEXT *argv[];
{
 if (!(DosBase=(struct DosBase *)OpenLibrary("dos.library",L_V))) {
    puts("Could not open dos.library!");
    quit(0L);
 }
 if (!(ExecBase=(struct ExecBase *)OpenLibrary("exec.library",L_V))) {
    puts("Could not open exec.library!");
    quit(0L);
 }
 if (!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",L_V))) {
    puts("Could not open intuition.library!");
    quit(0L);
 }
 if (!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",L_V))) {
    puts("Could not open graphics.library!");
    quit(0L);
 }
 if (FetchTemplate((LONG)argc,argv)) {
    program((LONG)argc,argv);
 } else {
    quit(5L);
 }
 quit(0L);
}


 VOID
quit(value)
 LONG value;
{
 ReleaseTemplate();
 if (GfxBase) {
    CloseLibrary((struct Library *)GfxBase);
 }
 if (IntuitionBase) {
    CloseLibrary((struct Library *)IntuitionBase);
 }
 if (ExecBase) {
    CloseLibrary((struct Library *)ExecBase);
 }
 if (DosBase) {
    CloseLibrary((struct Library *)DosBase);
 }
 exit((int)value);
}


