home *** CD-ROM | disk | FTP | other *** search
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
- #include <workbench/icon.h>
- #include <functions.h>
-
- /******************************************************************************\
- * Startup *
- * ------- *
- * by Mike Stark *
- * GetOptions is a routine to parse arguments from the command line or *
- * from the Tooltypes array if the program was called from the workbench. This *
- * is designed to be compiled with Aztec C 3.6 which passes the Workbench *
- * startup message as argv. The main routine should call GetOptions with *
- * GetOptions(argc, argv);. *
- \******************************************************************************/
-
- extern int Depth;
- extern BOOL OneShape;
-
- extern struct Library *IconBase;
-
- GetOptions(Count, Args)
- int Count;
- char **Args;
-
- {
- struct WBStartup *WBenchMsg;
- struct DiskObject *DiskObject;
- int Colors, Length, i;
- BOOL Match;
- char *TempString;
-
- Colors = 16;
- OneShape = FALSE;
- if (Count)
- {
- for (i = 1; i < Count; i++)
- {
- Length = strlen(Args[i]);
- if ((Args[i][0] == '-') && (Length > 1))
- {
- Match = FALSE;
- if (!strncmp("oneshape", &Args[i][1], Length < 9 ? Length - 1 : 8))
- {
- Match = TRUE;
- OneShape = TRUE;
- }
- if (!strncmp("colors", &Args[i][1], Length < 7 ? Length - 1 : 6))
- {
- if (Count == i + 1) CleanUp(TRUE);
- Match = TRUE;
- Colors = atoi(Args[++i]);
- }
- if (!Match) CleanUp(TRUE);
- }
- else
- {
- CleanUp(TRUE);
- }
- }
- }
- else
- {
- if (IconBase = OpenLibrary(ICONNAME, 0))
- {
- WBenchMsg = (struct WBenchMsg *)Args;
- if (DiskObject = GetDiskObject(WBenchMsg->sm_ArgList->wa_Name))
- {
- if (TempString = FindToolType(DiskObject->do_ToolTypes, "COLORS"))
- Colors = atoi(TempString);
- if (FindToolType(DiskObject->do_ToolTypes, "ONESHAPE"))
- OneShape = TRUE;
- FreeDiskObject(DiskObject);
- }
- CloseLibrary(IconBase);
- }
- }
- switch (Colors)
- {
- case 2:
- Depth = 1;
- break;
- case 4:
- Depth = 2;
- break;
- case 8:
- Depth = 3;
- break;
- case 16:
- Depth = 4;
- break;
- default:
- CleanUp(Count);
- break;
- }
- }
-