2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/exall.h>
11 #include <utility/tagitem.h>
12 #include <proto/utility.h>
13 #include <dos/rdargs.h>
14 #include <dos/dostags.h>
15 #include "dos_intern.h"
17 /*****************************************************************************
20 #include <proto/dos.h>
22 AROS_LH2(APTR
, AllocDosObject
,
25 AROS_LHA(ULONG
, type
, D1
),
26 AROS_LHA(struct TagItem
*, tags
, D2
),
29 struct DosLibrary
*, DOSBase
, 38, Dos
)
32 Creates a new dos object of a given type. This memory has to be
33 freed with FreeDosObject().
37 tags - Pointer to taglist array with additional information. See
38 <dos/dostags.h> for a list of all supported tags.
41 Pointer to new object or NULL, to indicate an error.
53 *****************************************************************************/
56 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
62 mem
= AllocMem(sizeof(struct FileHandle
), MEMF_CLEAR
);
66 struct FileHandle
*fh
= (struct FileHandle
*)mem
;
68 /* We set fh->fh_Arg1 to point back to 'fh' to make packet
70 fh
->fh_CompatibilityHack
= fh
;
74 SetIoErr(ERROR_NO_FREE_STORE
);
80 mem
= AllocMem(sizeof(struct FileInfoBlock
), MEMF_CLEAR
);
83 SetIoErr(ERROR_NO_FREE_STORE
);
88 mem
= AllocMem(sizeof(struct StandardPacket
), MEMF_CLEAR
);
91 SetIoErr(ERROR_NO_FREE_STORE
);
93 return &((struct StandardPacket
*)mem
)->sp_Pkt
;
95 case DOS_EXALLCONTROL
:
96 mem
= AllocMem(sizeof(struct InternalExAllControl
), MEMF_CLEAR
);
99 SetIoErr(ERROR_NO_FREE_STORE
);
105 struct CommandLineInterface
*cli
= NULL
;
106 struct TagItem defaults
[] =
108 /* 0 */ { ADO_DirLen
, 255 },
109 /* 1 */ { ADO_CommNameLen
, 255 },
110 /* 2 */ { ADO_CommFileLen
, 255 },
111 /* 3 */ { ADO_PromptLen
, 255 },
116 STRPTR command
= NULL
;
118 STRPTR prompt
= NULL
;
120 /* C has no exceptions. This is a simple replacement. */
121 #define ENOMEM_IF(a) if(a) goto enomem /* Throw out of memory. */
123 cli
= AllocMem(sizeof(struct CommandLineInterface
), MEMF_CLEAR
);
124 ENOMEM_IF(cli
== NULL
);
126 cli
->cli_FailLevel
= RETURN_ERROR
;
127 cli
->cli_Background
= DOSTRUE
;
128 ApplyTagChanges(defaults
, tags
);
130 dir
= AllocVec(defaults
[0].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
131 ENOMEM_IF(dir
== NULL
);
133 cli
->cli_SetName
= MKBADDR(dir
);
135 command
= AllocVec(defaults
[1].ti_Data
+ 1,
136 MEMF_PUBLIC
| MEMF_CLEAR
);
137 ENOMEM_IF(command
== NULL
);
139 cli
->cli_CommandName
= MKBADDR(command
);
141 file
= AllocVec(defaults
[2].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
142 ENOMEM_IF(file
== NULL
);
144 cli
->cli_CommandFile
= MKBADDR(file
);
146 prompt
= AllocVec(defaults
[3].ti_Data
+ 1,
147 MEMF_PUBLIC
| MEMF_CLEAR
);
148 ENOMEM_IF(prompt
== NULL
);
150 cli
->cli_Prompt
= MKBADDR(prompt
);
156 FreeMem(cli
, sizeof(struct CommandLineInterface
));
163 SetIoErr(ERROR_NO_FREE_STORE
);
169 return AllocVec(sizeof(struct RDArgs
), MEMF_CLEAR
);
172 SetIoErr(ERROR_BAD_NUMBER
);
177 } /* AllocDosObject */