#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <libraries/dosextens.h>

#include <dlg/user.h>
#include <dlg/resman.h>
#include <dlg/log.h>

#include <dlg_private/dlg.h>

#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/dlg.h>

#include <pragmas/dlg.h>

static char version[]="$VER: Goodbye 2.1 © 1995-1997 by DLG Development ("__AMIGADATE__")";

struct USER_DATA UserDat;
struct Ram_File  RStruct;
char             Ext[4] = "";

void  main(void);
void _CXBRK(void);

struct LangStruct *ls;
char             **SA;
BPTR               sout;
struct Library    *DLGBase = NULL;

void main(void)
{
   sout = Output();

   DLGBase = OpenLibrary(DLGNAME,DLGVERSION);
   if (!DLGBase)               exit(5);

   if (GetDevName(Ext)==-1)   _CXBRK();
   if (!(ls = GetLang(Ext)))  _CXBRK();
   SA = ls->strings; 

   if (!ReadUser(&RStruct, &UserDat, Ext))
   {
      AFPrintf(NULL,sout,SA[884]);
      _CXBRK();
   }

   if (!RStruct.Command_Stack)  AFPrintf(NULL,sout,"\n\n");
   _CXBRK();
}


void _CXBRK()
{
   if (Ext[0])  LogOut(&RStruct, &UserDat, Ext, "GoodBye");
   CloseLibrary(DLGBase);
   exit(0);
}

