2 Copyright © 1995-2008, 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(const 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
= (SIPTR
)fh
;
74 return AllocMem(sizeof(struct FileInfoBlock
), MEMF_CLEAR
);
78 struct StandardPacket
*sp
= AllocMem(sizeof(struct StandardPacket
), MEMF_CLEAR
);
83 sp
->sp_Pkt
.dp_Link
= &(sp
->sp_Msg
);
84 sp
->sp_Msg
.mn_Node
.ln_Name
= (char *) &(sp
->sp_Pkt
);
86 return (APTR
) &(sp
->sp_Pkt
);
89 case DOS_EXALLCONTROL
:
90 return AllocMem(sizeof(struct InternalExAllControl
), MEMF_CLEAR
);
94 struct CommandLineInterface
*cli
= NULL
;
95 struct TagItem defaults
[] =
97 /* 0 */ { ADO_DirLen
, 255 },
98 /* 1 */ { ADO_CommNameLen
, 255 },
99 /* 2 */ { ADO_CommFileLen
, 255 },
100 /* 3 */ { ADO_PromptLen
, 255 },
105 STRPTR command
= NULL
;
107 STRPTR prompt
= NULL
;
109 /* C has no exceptions. This is a simple replacement. */
110 #define ENOMEM_IF(a) if(a) goto enomem /* Throw out of memory. */
112 cli
= AllocMem(sizeof(struct CommandLineInterface
), MEMF_CLEAR
);
113 ENOMEM_IF(cli
== NULL
);
115 cli
->cli_FailLevel
= RETURN_ERROR
;
116 cli
->cli_Background
= DOSTRUE
;
117 ApplyTagChanges(defaults
, tags
);
119 dir
= AllocVec(defaults
[0].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
120 ENOMEM_IF(dir
== NULL
);
122 AROS_BSTR_setstrlen(MKBADDR(dir
), 0);
123 cli
->cli_SetName
= MKBADDR(dir
);
125 command
= AllocVec(defaults
[1].ti_Data
+ 1,
126 MEMF_PUBLIC
| MEMF_CLEAR
);
127 ENOMEM_IF(command
== NULL
);
129 AROS_BSTR_setstrlen(MKBADDR(command
), 0);
130 cli
->cli_CommandName
= MKBADDR(command
);
132 file
= AllocVec(defaults
[2].ti_Data
+ 1, MEMF_PUBLIC
| MEMF_CLEAR
);
133 ENOMEM_IF(file
== NULL
);
135 AROS_BSTR_setstrlen(MKBADDR(file
), 0);
136 cli
->cli_CommandFile
= MKBADDR(file
);
138 prompt
= AllocVec(defaults
[3].ti_Data
+ 1,
139 MEMF_PUBLIC
| MEMF_CLEAR
);
140 ENOMEM_IF(prompt
== NULL
);
142 AROS_BSTR_setstrlen(MKBADDR(prompt
), 0);
143 cli
->cli_Prompt
= MKBADDR(prompt
);
149 FreeMem(cli
, sizeof(struct CommandLineInterface
));
156 SetIoErr(ERROR_NO_FREE_STORE
);
162 return AllocVec(sizeof(struct RDArgs
), MEMF_CLEAR
);
165 SetIoErr(ERROR_BAD_NUMBER
);
170 } /* AllocDosObject */