transfer scheduler for CTRL and INT. Rest to be added soon
[AROS.git] / workbench / prefs / appearance / args.c
blobee5d2a48d584d2a6abea3a9dad1eed1ae50862d4
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/rdargs.h>
7 #include <workbench/startup.h>
9 #include <proto/dos.h>
10 #include <proto/icon.h>
12 #include "args.h"
13 #include "misc.h"
15 /*** Global Variables *******************************************************/
16 STATIC CONST_STRPTR TEMPLATE = "FROM,USE/S,SAVE/S";
17 STATIC IPTR args[COUNT];
18 STATIC struct RDArgs *rdargs;
19 STATIC BPTR olddir = (BPTR)-1;
21 /*** Functions **************************************************************/
22 BOOL ReadArguments(int argc, char **argv)
24 if (argc)
26 rdargs = ReadArgs(TEMPLATE, args, NULL);
27 return rdargs != NULL;
29 else
31 struct WBStartup *wbmsg = (struct WBStartup *)argv;
32 struct WBArg *wbarg = wbmsg->sm_ArgList;
33 struct DiskObject *dobj;
34 STRPTR *toolarray;
35 STRPTR tooltype;
37 if (wbmsg->sm_NumArgs > 1)
39 wbarg++;
40 if (wbarg->wa_Lock && *wbarg->wa_Name)
42 olddir = CurrentDir(wbarg->wa_Lock);
43 dobj = GetDiskObject(wbarg->wa_Name);
44 if (dobj)
46 args[FROM] = (IPTR)wbarg->wa_Name;
47 toolarray = dobj->do_ToolTypes;
48 tooltype = FindToolType(toolarray, "ACTION");
49 if (tooltype)
51 if (MatchToolValue(tooltype, "USE"))
53 args[USE] = TRUE;
55 else if (MatchToolValue(tooltype, "SAVE"))
57 args[SAVE] = TRUE;
60 FreeDiskObject(dobj);
61 return TRUE;
63 else
65 ShowMessage("Couldn't read DiskObject\n");
69 else if (wbmsg->sm_NumArgs == 1)
71 return TRUE;
74 return FALSE;
77 VOID FreeArguments(VOID)
79 FreeArgs(rdargs);
81 if (olddir != (BPTR)-1)
82 CurrentDir(olddir);
85 IPTR GetArgument(enum Argument id)
87 if ((id >= 0) && (id < COUNT))
88 return args[id];
90 return 0;