void __regargs __autoopenfail(char *);

#include <constructor.h>
#include <proto/envoy.h>

extern struct Library *OpenLibrary( UBYTE *libName, unsigned long version );
extern void CloseLibrary( struct Library *library );

struct Library *EnvoyBase ;
static void *libbase;
extern long __netlibversion;

CBMLIB_CONSTRUCTOR(openenvoy)
{
    EnvoyBase = libbase = (void *)OpenLibrary("envoy.library", __netlibversion);
    if (EnvoyBase == NULL)
    {
        __autoopenfail("envoy.library");
        return 1;
    }
    
    return 0;
}

CBMLIB_DESTRUCTOR(closeenvoy)
{
   if (libbase)
   {
      CloseLibrary((struct Library *)libbase);
      libbase = EnvoyBase = NULL;
   }
}
