#include <exec/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>

#include "/dlgmail/version.h"
#include "/dlgmail/defines.h"
#include "/dlgmail/top.h"

#include <link/io.h>

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

#include <private/Version.h>
#define  ObjRev "1"
const UBYTE version[]="\0$VER: DLGMail Command Helper " BUILDVER "." ObjRev " ©" COPYRIGHT " by Digerati Dreams "__AMIGADATE__;

BPTR sout;
struct Library *DLGBase;


main(int argc, char **argv)
{
   char *class[]={" ","INSNT","IMMED","BKGND","PHONE","PROCS"};
   int i;
   int j;

   sout = Output();

   DLGBase = OpenLibrary("dlg.library",2L);

   AFPrintf(NULL,sout,"\n\nDLGMail ARexx commands supported:\n\n");

   AFPrintf(NULL,sout,"%s\n\n",ID_STRING);

   AFPrintf(NULL,sout,"Command       Class Pri  Template\n");
   AFPrintf(NULL,sout,"------------- ----- ---  ----------------------------------------------\n");

   j=-2;

   for(i=0;*tokens[i].tk_command;i++)
   {
      Chk_Abort();

      if(j!=tokens[i].tk_class)
      {
         AFPrintf(NULL,sout,"\n");
         j=tokens[i].tk_class;
      }

      AFPrintf(NULL,sout,"%-12.12s  %5.5s  %2d  %s\n",
         tokens[i].tk_command,
         class[tokens[i].tk_class+2],
         tokens[i].tk_pri,
         tokens[i].tk_template);

      if(argc>1)
      {
         AFPrintf(NULL,sout,"--%s\n\n",tokens[i].tk_help);

      }
   }

   AFPrintf(NULL,sout,"\n");

   if(DLGBase) CloseLibrary(DLGBase);
}

