2 Copyright © 1995-2006, 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>
14 #include <dos/exall.h>
15 #include <rexx/storage.h>
16 #include <rexx/errors.h>
21 #include "rexxsupport_intern.h"
22 #include "rxfunctions.h"
24 LONG
rxsupp_showdir(struct Library
*RexxSupportBase
, struct RexxMsg
*msg
, UBYTE
**argstring
)
26 UBYTE argc
= msg
->rm_Action
& RXARGMASK
;
27 UBYTE type
= 0; /* 0 == all, 1 == file, 2 == dir */
32 struct ExAllData
*buffer
, *exalldata
;
33 struct ExAllControl
*exallctrl
;
44 if (RXARG(msg
,3) == NULL
|| LengthArgstring(RXARG(msg
,3)) != 0)
45 delim
= RXARG(msg
,3)[0];
47 if (RXARG(msg
,2) == NULL
|| LengthArgstring(RXARG(msg
,2)) == 0)
50 switch (tolower(RXARG(msg
,2)[0]))
73 lock
= Lock(RXARG(msg
,1), ACCESS_READ
);
76 *argstring
= CreateArgstring("", 0);
81 struct FileInfoBlock
*fib
= AllocDosObject(DOS_FIB
, NULL
);
88 if (fib
->fib_DirEntryType
<0)
90 FreeDosObject(DOS_FIB
, fib
);
91 *argstring
= CreateArgstring("", 0);
94 FreeDosObject(DOS_FIB
, fib
);
97 buffer
= AllocMem(1024, MEMF_ANY
);
99 string
= AllocMem(ssize
, MEMF_ANY
);
101 exallctrl
= AllocDosObject(DOS_EXALLCONTROL
, NULL
);
102 exallctrl
->eac_LastKey
= 0;
104 done
= ExAll(lock
, buffer
, 1024, ED_TYPE
, exallctrl
);
105 if (exallctrl
->eac_Entries
>0)
107 exalldata
= (struct ExAllData
*)buffer
;
108 while (exalldata
!= NULL
)
111 (type
== 1 && exalldata
->ed_Type
< 0) ||
112 (type
== 2 && exalldata
->ed_Type
>= 0))
114 ULONG newlen
= strlen(string
) + strlen(exalldata
->ed_Name
) + 2, len
= strlen(string
);
117 UBYTE
*oldstring
= string
;
118 ULONG oldsize
= ssize
;
119 ssize
= ((newlen
/1024)+1)*1024;
120 string
= AllocMem(ssize
, MEMF_ANY
);
121 strcpy(string
, oldstring
);
122 FreeMem(oldstring
, oldsize
);
129 strcat(string
, exalldata
->ed_Name
);
131 exalldata
= exalldata
->ed_Next
;
136 *argstring
= CreateArgstring(string
, strlen(string
));
137 FreeMem(buffer
, 1024);
138 FreeMem(string
, ssize
);
139 FreeDosObject(DOS_EXALLCONTROL
, exallctrl
);