2 Copyright © 1995-2007, 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 *****************************************************************************/
61 mem
= AllocMem(sizeof(struct FileHandle
), MEMF_CLEAR
);
65 struct FileHandle
*fh
= (struct FileHandle
*)mem
;
67 /* We set fh->fh_Arg1 to point back to 'fh' to make packet
69 fh
->fh_CompatibilityHack
= fh
;
73 SetIoErr(ERROR_NO_FREE_STORE
);
79 mem
= AllocMem(sizeof(struct FileInfoBlock
), MEMF_CLEAR
);
82 SetIoErr(ERROR_NO_FREE_STORE
);
88 struct StandardPacket
*sp
= AllocMem(sizeof(struct StandardPacket
), MEMF_CLEAR
);
91 SetIoErr(ERROR_NO_FREE_STORE
);
95 sp
->sp_Pkt
.dp_Link
= &(sp
->sp_Msg
);
96 sp
->sp_Msg
.mn_Node
.ln_Name
= (char *) &(sp
->sp_Pkt
);
98 return (APTR
) &(sp
->sp_Pkt
);
101 case DOS_EXALLCONTROL
:
102 mem
= AllocMem(sizeof(struct InternalExAllControl
), MEMF_CLEAR
);
105 SetIoErr(ERROR_NO_FREE_STORE
);
111 struct CommandLineInterface
*cli
= NULL
;
112 struct TagItem defaults
[] =
114 /* 0 */ { ADO_DirLen
, 255 },
115 /* 1 */ { ADO_CommNameLen
, 255 },
116 /* 2 */ { ADO_CommFileLen
, 255 },
117 /* 3 */ { ADO_PromptLen
, 255 },
122 STRPTR command
= NULL
;
124 STRPTR prompt
= NULL
;
126 /* C has no exceptions. This is a simple replacement. */
127 #define ENOMEM_IF(a) if(a) goto enomem /* Throw out of memory. */
129 cli
= AllocMem(sizeof(struct CommandLineInterface
), MEMF_CLEAR
);
130 ENOMEM_IF(cli
== NULL
);
132 cli
->cli_FailLevel
= RETURN_ERROR
;
133 cli
->cli_Background
= DOSTRUE
;
134 ApplyTagChanges(defaults
, tags
);
136 dir
= AllocVec(defaults
[0].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
137 ENOMEM_IF(dir
== NULL
);
139 AROS_BSTR_setstrlen(MKBADDR(dir
), 0);
140 cli
->cli_SetName
= MKBADDR(dir
);
142 command
= AllocVec(defaults
[1].ti_Data
+ 1,
143 MEMF_PUBLIC
| MEMF_CLEAR
);
144 ENOMEM_IF(command
== NULL
);
146 AROS_BSTR_setstrlen(MKBADDR(command
), 0);
147 cli
->cli_CommandName
= MKBADDR(command
);
149 file
= AllocVec(defaults
[2].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
150 ENOMEM_IF(file
== NULL
);
152 AROS_BSTR_setstrlen(MKBADDR(file
), 0);
153 cli
->cli_CommandFile
= MKBADDR(file
);
155 prompt
= AllocVec(defaults
[3].ti_Data
+ 1,
156 MEMF_PUBLIC
| MEMF_CLEAR
);
157 ENOMEM_IF(prompt
== NULL
);
159 AROS_BSTR_setstrlen(MKBADDR(prompt
), 0);
160 cli
->cli_Prompt
= MKBADDR(prompt
);
166 FreeMem(cli
, sizeof(struct CommandLineInterface
));
173 SetIoErr(ERROR_NO_FREE_STORE
);
179 return AllocVec(sizeof(struct RDArgs
), MEMF_CLEAR
);
182 SetIoErr(ERROR_BAD_NUMBER
);
187 } /* AllocDosObject */