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

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

#include <link/io.h>

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

#include <pragmas/dlg.h>

#include <private/Version.h>
#define  ObjRev "1"
const UBYTE version[]="\0$VER: Goodbye " BUILDVER "." ObjRev " ©" COPYRIGHT " by Digerati Dreams "__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))
   {	// "Can't read users data\n\n"
      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);
}

