home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 600-699 / ff631.lha / KeyBang / Source / Startup.c < prev    next >
C/C++ Source or Header  |  1992-04-06  |  2KB  |  97 lines

  1. #include <workbench/workbench.h>
  2. #include <workbench/startup.h>
  3. #include <workbench/icon.h>
  4. #include <functions.h>
  5.  
  6. /******************************************************************************\
  7. *                                    Startup                                   *
  8. *                                    -------                                   *
  9. *                                 by Mike Stark                                *
  10. *      GetOptions is a routine to parse arguments from the command line or     *
  11. * from the Tooltypes array if the program was called from the workbench.  This *
  12. * is designed to be compiled with Aztec C 3.6 which passes the Workbench       *
  13. * startup message as argv.  The main routine should call GetOptions with       *
  14. * GetOptions(argc, argv);.                                                     *
  15. \******************************************************************************/
  16.  
  17. extern int Depth;
  18. extern BOOL OneShape;
  19.  
  20. extern struct Library *IconBase;
  21.  
  22. GetOptions(Count, Args)
  23. int Count;
  24. char **Args;
  25.  
  26. {
  27.   struct WBStartup *WBenchMsg;
  28.   struct DiskObject *DiskObject;
  29.   int Colors, Length, i;
  30.   BOOL Match;
  31.   char *TempString;
  32.  
  33.   Colors = 16;
  34.   OneShape = FALSE;
  35.   if (Count)
  36.   {
  37.     for (i = 1; i < Count; i++)
  38.     {
  39.       Length = strlen(Args[i]);
  40.       if ((Args[i][0] == '-') && (Length > 1))
  41.       {
  42.     Match = FALSE;
  43.     if (!strncmp("oneshape", &Args[i][1], Length < 9 ? Length - 1 : 8))
  44.     {
  45.       Match = TRUE;
  46.       OneShape = TRUE;
  47.     }
  48.     if (!strncmp("colors", &Args[i][1], Length < 7 ? Length - 1 : 6))
  49.     {
  50.       if (Count == i + 1) CleanUp(TRUE);
  51.       Match = TRUE;
  52.       Colors = atoi(Args[++i]);
  53.     }
  54.     if (!Match) CleanUp(TRUE);
  55.       }
  56.       else
  57.       {
  58.     CleanUp(TRUE);
  59.       }
  60.     }
  61.   }
  62.   else
  63.   {
  64.     if (IconBase = OpenLibrary(ICONNAME, 0))
  65.     {
  66.       WBenchMsg = (struct WBenchMsg *)Args;
  67.       if (DiskObject = GetDiskObject(WBenchMsg->sm_ArgList->wa_Name))
  68.       {
  69.     if (TempString = FindToolType(DiskObject->do_ToolTypes, "COLORS"))
  70.       Colors = atoi(TempString);
  71.     if (FindToolType(DiskObject->do_ToolTypes, "ONESHAPE"))
  72.       OneShape = TRUE;
  73.     FreeDiskObject(DiskObject);
  74.       }
  75.       CloseLibrary(IconBase);
  76.     }
  77.   }
  78.   switch (Colors)
  79.   {
  80.     case 2:
  81.      Depth = 1;
  82.      break;
  83.     case 4:
  84.      Depth = 2;
  85.      break;
  86.     case 8:
  87.      Depth = 3;
  88.      break;
  89.     case 16:
  90.      Depth = 4;
  91.      break;
  92.     default:
  93.      CleanUp(Count);
  94.      break;
  95.   }
  96. }
  97.