grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / c / HDTool / main.c
blob6d735c564e5109b89d56f4b2b2d822872d3912be
1 #include <stdio.h>
2 #include <string.h>
3 #include <proto/dos.h>
4 #include <aros/debug.h>
6 #include "install.h"
7 #include "list.h"
8 #include "setup.h"
10 char *template = "COMMAND/A,ARGS/F";
11 char *cmdtemplate = "LIST/S,SETUPS/S,INSTALL/S";
13 LONG doCommand(char *name, STRPTR command, STRPTR args) {
14 LONG retval = RETURN_FAIL;
15 IPTR myargs[]={0,0,0,0};
16 struct RDArgs *rdargs;
17 struct RDArgs rda = {{command, strlen(command), 0}, 0, 0, 0, NULL, 0};
19 rda.RDA_Source.CS_Buffer[rda.RDA_Source.CS_Length]='\n';
20 rdargs = ReadArgs(cmdtemplate, myargs, &rda);
21 if (rdargs)
23 if (myargs[0])
24 retval = list(name, args);
25 if (myargs[1])
26 retval = setup(name, args);
27 if (myargs[2])
28 retval = install(name, args);
29 FreeArgs(rdargs);
31 else
32 PrintFault(IoErr(), name);
33 return retval;
36 int main(int argc, char **argv) {
37 int retval = RETURN_FAIL;
38 IPTR myargs[]={0,0};
39 struct RDArgs *rdargs;
41 rdargs = ReadArgs(template, myargs, NULL);
42 if (rdargs)
44 retval = doCommand(argv[0], (STRPTR)myargs[0], (STRPTR)myargs[1]);
45 FreeArgs(rdargs);
47 else
48 PrintFault(IoErr(), argv[0]);
49 return retval;