home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 355.lha / Xtools_v1.0 / XTools.c < prev    next >
C/C++ Source or Header  |  1990-03-12  |  2KB  |  95 lines

  1. /* XTools M. Laliberté/ J. Toebes, TransAmiga, dec 1988, p.69 */
  2.  
  3. #include <exec/types.h>
  4. #include <intuition/intuition.h>
  5. #include <workbench/workbench.h>
  6. #include <workbench/startup.h>
  7. #include <workbench/icon.h>
  8. #include <libraries/dosextens.h>
  9. #include <dos.h>
  10. #define U_ARGS(a) a
  11. #include <proto/exec.h>
  12. #include <proto/intuition.h>
  13. #include <proto/dos.h>
  14. #include <string.h>
  15.  
  16. #define MAXSTRINGS 26
  17. extern struct WBStartup *WBenchMsg;
  18. struct IntuitionBase *IntuitionBase;
  19. struct Library *IconBase;
  20.  
  21. struct DiskObject *diskobj;
  22. char **findtools U_ARGS((char *,BPTR));
  23.  
  24. void main (argc, argv)
  25. int argc;
  26. char **argv;
  27. {
  28. char *(strings[MAXSTRINGS]);
  29. int count, i;
  30. struct WBArg *wbarg;
  31. char **toolptr,*name,lookup[8];
  32. if ((IntuitionBase = (struct IntuitionBase *) 
  33.     OpenLibrary("intuition.library",0)) == NULL ) {
  34.         goto done;
  35.         }
  36. if ((IconBase = (struct IconBase *) 
  37.     OpenLibrary("icon.library",0)) == NULL ) {
  38.         goto done;
  39.         }
  40.  
  41. if (argc)
  42.     toolptr = findtools(argv[0],
  43.         ((struct Process *)FindTask(NULL))->pr_CurrentDir);
  44.     else
  45.     {
  46.         wbarg = &(WBenchMsg->sm_ArgList[WBenchMsg->sm_NumArgs-1]);
  47.         toolptr = findtools(wbarg->wa_Name,wbarg->wa_Lock);    
  48.     }
  49.  
  50. strcpy(lookup,"A");
  51. count = 0;
  52. for (i=0;i < MAXSTRINGS;i++)
  53. {
  54.     if ((name=FindToolType(toolptr,lookup)) != NULL) {
  55.         strings[count] = name;
  56.         Execute(strings[count++],0,0);
  57.         }
  58.     lookup[0]++;
  59. }
  60.  
  61. done:
  62. if (diskobj) {
  63.     FreeDiskObject(diskobj);
  64.     diskobj = NULL;
  65.     }
  66. if (IntuitionBase) {
  67.     CloseLibrary ((struct Library *)IntuitionBase);
  68.     IntuitionBase = NULL;
  69.     }
  70. if (IconBase) {
  71.     CloseLibrary(IconBase);
  72.     IconBase = NULL;
  73.     }
  74.  
  75. }
  76.  
  77.  
  78. char **findtools(name,lock)
  79. char *name;
  80. BPTR lock;
  81. {
  82. BPTR olddir;
  83. char **tools = NULL;
  84.  
  85. if(lock == NULL) return (NULL);
  86. olddir = CurrentDir(lock);
  87. if((diskobj=GetDiskObject(name)) != NULL)
  88.     tools=diskobj->do_ToolTypes;
  89. CurrentDir(olddir);
  90. return(tools);
  91. }
  92.  
  93. void MemCleanup() {}
  94.  
  95.