revert between 56095 -> 55830 in arch
[AROS.git] / workbench / prefs / locale / args.c
blobfee1590ecb8ec23c0cc93fb5ac3a281e8dcd7f68
1 /*
2 Copyright © 2004-2010, 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);
80 if (olddir != (BPTR)-1)
81 CurrentDir(olddir);
84 IPTR GetArgument(enum Argument id)
86 if (id >= 0 && id < COUNT) return args[id];
87 else return 0;