1 #ifndef SHCOMMANDS_EMBEDDED_H
4 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
10 #include <proto/exec.h>
11 #include <aros/symbolsets.h>
13 /* This defines many of the macros we will be using.
15 #include <aros/shcommands_notembedded.h>
17 DECLARESET(SHCOMMANDS
)
27 /* We only need to override __AROS_SH_ARGS */
29 #define __AROS_SH_ARGS(name, version, numargs, defl, templ, help) \
30 static ULONG name##_main(CONST_STRPTR , IPTR *, \
31 struct ExecBase *_SysBase, \
32 struct DosLibrary *_DOSBase); \
33 AROS_UFP2S(LONG, name##_entry, \
34 AROS_UFPA(char *,argstr,A0), \
35 AROS_UFPA(ULONG,argsize,D0) \
37 static const struct shcommand __##name##_##shcommand = \
39 .sh_Name = stringify(name), \
40 .sh_Command = (IPTR)name##_entry, \
41 .sh_NumArgs = numargs, \
42 .sh_Template = templ \
45 ADD2SET(__##name##_##shcommand, SHCOMMANDS, 0); \
47 AROS_UFH2S(LONG, name##_entry, \
48 AROS_UFHA(char *,argstr,A0), \
49 AROS_UFHA(ULONG,argsize,D0) \
53 extern struct ExecBase *SysBase; \
56 LONG __retcode = RETURN_FAIL; \
57 IPTR __shargs[numargs] = defl; \
58 struct RDArgs *__rda = NULL; \
59 struct RDArgs *__rda2 = NULL; \
61 DOSBase = OpenLibrary(DOSNAME, 0); \
65 /* Can't use SetIOErr(), since DOSBase is not open! */ \
66 ((struct Process *)FindTask(NULL))->pr_Result2 = \
67 ERROR_INVALID_RESIDENT_LIBRARY; \
73 __rda2 = (struct RDArgs *)AllocDosObject(DOS_RDARGS, NULL); \
76 PrintFault(IoErr(), stringify(name)); \
79 __rda2->RDA_ExtHelp = help; \
82 __rda = ReadArgs(templ, __shargs, __rda2); \
86 PrintFault(IoErr(), stringify(name)); \
90 __retcode = name##_main(argstr, __shargs, SysBase, DOSBase); \
93 if (__rda) FreeArgs(__rda); \
94 if (help[0] && __rda2) FreeDosObject(DOS_RDARGS, __rda2); \
95 if (DOSBase) CloseLibrary(DOSBase); \
101 DEFINE_SysBase_global \
102 DEFINE_DOSBase_global \
103 static ULONG name##_main(CONST_STRPTR __argstr, \
105 struct ExecBase *_SysBase, \
106 struct DosLibrary *_DOSBase) \
108 DEFINE_SysBase_local \
109 DEFINE_DOSBase_local \
110 SysBase = _SysBase; DOSBase = _DOSBase;