#include <stdio.h>
#include <string.h>
#include <intuition/intuition.h>
#include <pragma/dos_lib.h>
#include <pragma/icon_lib.h>
#include <pragma/exec_lib.h>
#include <pragma/intuition_lib.h>

#include <wbstartup.h>

int EasyReq(struct Window *,char *,char *, char *);

static unsigned char *version = "$VER: ActXDx 1.0  ("__DATE__") by Jens Weyer";

struct Library *IconBase = NULL;
struct DiskObject *Icon = NULL;
char Unit[3];
char Exe[6];
BOOL Quiet = FALSE;

void main(int argc, char *argv[])
{
  IconBase = OpenLibrary("icon.library",36L);
  if (IconBase != NULL)
  {
    Icon = GetDiskObject(argv[0]);
    if (Icon != NULL)
    {
      char *Type;
      if (Type = FindToolType((UBYTE **)Icon->do_ToolTypes,"UNIT"))
      {
        strcpy(Unit,Type);
        strcpy(Exe,"XD");
        strcat(Exe,Unit);
        strcat(Exe,":");
        Execute(Exe,0,0);
        if (Type = FindToolType((UBYTE **)Icon->do_ToolTypes,"QUIET"))
        {
          Quiet = TRUE;
        }
        else
        {
          Quiet = FALSE;
        }
        FreeDiskObject(Icon);
        CloseLibrary(IconBase);
        if (Quiet == FALSE)
        {
          EasyReq(NULL,"ActXDx - Message","ActXDx v1.0\nCopyright (c)1997 by Jens Weyer\n\nSpecified Unit should be\nactivated in a few seconds !","Ok");
        }
      }
      else
      {
        printf("No unit is specified !\n");
      }
    }
    else
    {
      printf("Unable to find my icon !\n");
    }
  }
  else
  {
    printf("Unable to open Icon.library v36++\n");
  }
}

int EasyReq(struct Window *Wnd,char *Titel,char *Text, char *Gads)
{
  struct EasyStruct	ez={sizeof(struct EasyStruct),0,Titel,Text,Gads};

  int Result = EasyRequestArgs(Wnd,&ez,0,NULL);

  return( Result );
}
