#include <exec/types.h>
#include <libraries/dos.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>

#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/icon_protos.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct Library *IconBase=NULL;
void sr(char *s);

main(int argc,char *argv[])
{
  char name[200];
  char *s;
  struct DiskObject *dobj;
  char *olddeftool;
  char **oldtooltypes;
  BOOL success=FALSE;
  if(argc!=2)
  {
     printf("GetObj version 1.0, written by Joseph Hodge\n");
     printf("\n\n");
     exit(0);
  }
  strcpy(name,argv[1]);


  sr(name);

  IconBase=OpenLibrary("icon.library",0L);
  if(dobj=GetDiskObject(name))
  {
    printf("Found Object\n");
    oldtooltypes=dobj->do_ToolType;
    olddeftool=dobj->do_DefaultTool;
    
    while(s=(char *)FindToolType(oldtooltypes,"DLPATH"))
    {
       strcpy(name,s);
       printf("ToolType= %s.\n",name);
    }
    FreeDiskObject(dobj);
  }
  CloseLibrary(IconBase);
  exit(0);
}

void sr(char *s)
{
   register int i;
   i=strlen(s)-1;
   while(i>-1)
   {
     if(*(s+i)<=32) *(s+i)='\0'; else break;
     i--;
   }
}
