/*
**	$VER: accountslib.c 1.7 (02.11.94)
**
**	accounts.library standard functions
**
**	© Copyright 1994 by Norbert Püschel
**	All Rights Reserved
*/

#include <proto/exec.h>
#include "daemon.h"
#include <debug.h>

struct DosLibrary *DOSBase;
extern struct Library *AccountsBase;

volatile struct Daemon guardian;
extern void guardian_func(void);

BOOL __saveds LibInit(void)

{
  DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",37);
  if(DOSBase) {
    D(bug("dos.library opened\n"));
    InitDaemon(&guardian);
    return(TRUE);
  }
  else {
    D(bug("dos.library could not be opened\n"));
  }
  return(FALSE);
}

BOOL __saveds LibOpen(void)

{
  if(!DaemonOK(&guardian))
    return(StartDaemon(&guardian,guardian_func,"Accounts Daemon",0));
  else
    return(TRUE);
}

BOOL __saveds LibClose(void)

{
  if(AccountsBase->lib_OpenCnt == 0) StopDaemon(&guardian);
  return(TRUE);
}

BOOL __saveds LibExpunge(void) 

{
  CloseLibrary((struct Library *)DOSBase);
  return(TRUE);
}
