home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / cdity / EasyTM_src.lha / EasyTM-src / Prefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-27  |  2.0 KB  |  86 lines

  1. //**************************
  2. //
  3. //  Prefs.c
  4. //
  5. //**************************
  6.  
  7. //**** Header files
  8.  
  9. #include <workbench/workbench.h>
  10. #include <workbench/startup.h>
  11.  
  12. #include <clib/exec_protos.h>
  13. #include <clib/dos_protos.h>
  14. #include <clib/icon_protos.h>
  15.  
  16. #include <pragmas/exec_pragmas.h>
  17. #include <pragmas/dos_pragmas.h>
  18. #include <pragmas/icon_pragmas.h>
  19.  
  20. #include <string.h>
  21. #include <stdlib.h>
  22. //#include <stdio.h>
  23.  
  24. #include "Librarian.h"
  25. #include "Prefs.h"
  26.  
  27.  
  28. //**** Local Storage
  29.  
  30. char *ToolsFileName;
  31. char *ToolsArcName;
  32. char *PrefsProgName;
  33. char *PrefsProgDir;
  34. LONG my_cx_pri=0L;
  35.  
  36.  
  37. //**** Function Prototypes
  38.  
  39.  
  40. //**** Module Routines
  41.  
  42. int ReadIcon(int argc, char **argv) {
  43.   struct WBStartup *wbs;
  44.   char **toolArray;
  45.   char *value;
  46.   BPTR oldp;
  47.   struct DiskObject *dobj;
  48.  
  49.   if (0==argc) { // started from Workbench
  50.     wbs=(struct WBStartup *)argv;
  51.  
  52.     // move to program dir, and try to get the icon
  53.     oldp=CurrentDir(wbs->sm_ArgList->wa_Lock);
  54.     if (dobj=GetDiskObject(wbs->sm_ArgList->wa_Name)) {
  55.        toolArray=dobj->do_ToolTypes;
  56.  
  57.        if (value=FindToolType(toolArray,"CX_PRIORITY"))
  58.          StrToLong(value,&my_cx_pri);
  59.  
  60.        value=FindToolType(toolArray,"TOOLSFILE");
  61.        if (NULL==value) value="ENV:EasyTM.Config";
  62.        ToolsFileName=strcpy(AllocVec(strlen(value)+1,NULL),value);
  63.  
  64.        value=FindToolType(toolArray,"TOOLSARC");
  65.        if (NULL==value) value="ENVARC:EasyTM.Config";
  66.        ToolsArcName=strcpy(AllocVec(strlen(value)+1,NULL),value);
  67.  
  68.        value=FindToolType(toolArray,"PREFSPRG");
  69.        if (NULL==value) value="SYS:Prefs/EasyTM-Prefs";
  70.        PrefsProgDir=strcpy(AllocVec(strlen(value)+1,NULL),value);
  71.        PrefsProgName=FilePart(PrefsProgDir);
  72.        value=PathPart(PrefsProgDir);
  73.        *value=0;
  74.  
  75.        FreeDiskObject(dobj);
  76.     } // if GetDiskObject
  77.     CurrentDir(oldp);
  78.     return 1;
  79.   } else { // started from SHELL
  80.     FPuts( Output(), "This should be started from the workbench\n" );
  81.     return 0;
  82.   } // if 0==argc
  83. } // ReadIcon
  84.  
  85. //**** End of file
  86.