2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Rexx stub for AllocMem system function
9 #include <proto/exec.h>
10 #include <proto/dos.h>
11 #include <proto/rexxsyslib.h>
12 #include <exec/types.h>
13 #include <exec/memory.h>
15 #include <dos/dosextens.h>
16 #include <rexx/storage.h>
17 #include <rexx/errors.h>
22 #include "rexxsupport_intern.h"
23 #include "rxfunctions.h"
25 #ifndef AROS_BSTR_ADDR
26 # define AROS_BSTR_ADDR(s) (((STRPTR)BADDR(s))+1)
29 LONG
rxsupp_showlist(struct Library
*RexxSupportBase
, struct RexxMsg
*msg
, UBYTE
**argstring
)
31 UBYTE argc
= msg
->rm_Action
& RXARGMASK
;
34 struct List
*execl
= NULL
;
36 UBYTE
*string
, *name
= NULL
;
39 if (RXARG(msg
, 1) == NULL
|| LengthArgstring(RXARG(msg
, 1)) == 0)
44 switch (tolower(RXARG(msg
, 1)[0]))
48 dosflags
= LDF_READ
| LDF_ASSIGNS
;
53 execl
= &SysBase
->DeviceList
;
58 dosflags
= LDF_READ
| LDF_DEVICES
;
63 execl
= &SysBase
->IntrList
;
68 execl
= &SysBase
->LibList
;
73 execl
= &SysBase
->MemList
;
78 execl
= &SysBase
->PortList
;
83 execl
= &SysBase
->ResourceList
;
88 execl
= &SysBase
->SemaphoreList
;
93 execl
= &SysBase
->TaskReady
;
98 dosflags
= LDF_READ
| LDF_VOLUMES
;
103 execl
= &SysBase
->TaskWait
;
111 if (argc
< 2 || RXARG(msg
, 2) == NULL
)
114 name
= RXARG(msg
, 2);
116 if (argc
< 3 || RXARG(msg
, 3) == NULL
|| LengthArgstring(RXARG(msg
, 3)) == 0)
119 delim
= RXARG(msg
, 3)[0];
124 string
= AllocMem(ssize
, MEMF_ANY
);
132 ForeachNode(execl
, n
)
134 slen
= strlen(string
);
135 totlen
= slen
+ strlen(n
->ln_Name
) + 2;
138 ULONG oldsize
= ssize
;
139 UBYTE
*oldstring
= string
;
141 ssize
= ((totlen
/1024)+1)*1024;
142 string
= AllocMem(ssize
, MEMF_ANY
);
143 strcpy(string
, oldstring
);
144 FreeMem(oldstring
, oldsize
);
148 string
[slen
] = delim
;
151 strcat(string
, n
->ln_Name
);
157 struct DosList
*dosl
= LockDosList(dosflags
);
161 while ((dosl
= NextDosEntry(dosl
, dosflags
)) != NULL
)
163 name
= (STRPTR
)AROS_BSTR_ADDR(dosl
->dol_Name
);
164 slen
= strlen(string
);
165 totlen
= slen
+ strlen(name
) + 2;
168 ULONG oldsize
= ssize
;
169 UBYTE
*oldstring
= string
;
171 ssize
= ((totlen
/1024)+1)*1024;
172 string
= AllocMem(ssize
, MEMF_ANY
);
173 strcpy(string
, oldstring
);
174 FreeMem(oldstring
, oldsize
);
178 string
[slen
] = delim
;
181 strncat(string
, name
, *(UBYTE
*)dosl
->dol_Name
);
183 UnLockDosList(dosflags
);
185 *argstring
= CreateArgstring(string
, strlen(string
));
186 FreeMem(string
, ssize
);
188 else /* name != NULL */
197 ForeachNode(execl
, n
)
199 found
= strcmp(name
, n
->ln_Name
)==0;
207 struct DosList
*dosl
= LockDosList(dosflags
);
209 while(!found
&& (dosl
= NextDosEntry(dosl
, dosflags
))!=NULL
)
210 found
= strncmp(name
, (STRPTR
)BADDR(dosl
->dol_Name
)+1, *(UBYTE
*)dosl
->dol_Name
)==0;
212 UnLockDosList(dosflags
);
215 *argstring
= CreateArgstring("1",1);
217 *argstring
= CreateArgstring("0",1);