Title.mui: minor code cleanup
[AROS.git] / workbench / libs / rexxsupport / statef.c
blob70883530777cb18b1c925ba13720cf03439910e2
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Rexx stub for AllocMem system function
6 Lang: English
7 */
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/rexxsyslib.h>
13 #include <exec/types.h>
14 #include <exec/memory.h>
15 #include <dos/exall.h>
16 #include <rexx/storage.h>
17 #include <rexx/errors.h>
19 #include <ctype.h>
20 #include <string.h>
22 #include "rexxsupport_intern.h"
23 #include "rxfunctions.h"
25 AROS_UFH2(void, __putChr,
26 AROS_UFHA(UBYTE, chr, D0),
27 AROS_UFHA(STRPTR *, p, A3))
29 AROS_USERFUNC_INIT;
31 *(*p)++ = chr;
33 AROS_USERFUNC_EXIT;
36 void my_sprintf(struct Library *RexxSupportBase, UBYTE *buffer, UBYTE *format, ...)
38 RawDoFmt(format, &format+1, (VOID_FUNC)__putChr, &buffer);
41 LONG rxsupp_statef(struct Library *RexxSupportBase, struct RexxMsg *msg, UBYTE **argstring)
43 BPTR lock;
44 UBYTE *string;
46 lock = Lock(RXARG(msg,1), ACCESS_READ);
47 if (lock == BNULL)
49 *argstring = CreateArgstring("", 0);
50 return RC_OK;
52 else
54 struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, NULL);
55 if (fib == NULL)
57 *argstring = NULL;
58 return ERR10_003;
60 Examine(lock, fib);
61 string = AllocMem(1024, MEMF_ANY);
62 my_sprintf(RexxSupportBase, string, "%s %ld %ld %s%s%s%s%s%s%s%s %ld %ld %ld",
63 fib->fib_DirEntryType<0 ? "FILE" : "DIR",
64 fib->fib_Size,
65 fib->fib_NumBlocks,
66 fib->fib_Protection & 1<<8 ? "H" : "-",
67 fib->fib_Protection & FIBF_SCRIPT ? "S" : "-",
68 fib->fib_Protection & FIBF_PURE ? "P" : "-",
69 fib->fib_Protection & FIBF_ARCHIVE ? "A" : "-",
70 fib->fib_Protection & FIBF_READ ? "-" : "R",
71 fib->fib_Protection & FIBF_WRITE ? "-" : "W",
72 fib->fib_Protection & FIBF_EXECUTE ? "-" : "E",
73 fib->fib_Protection & FIBF_DELETE ? "-" : "D",
74 fib->fib_Date.ds_Days,
75 fib->fib_Date.ds_Minute,
76 fib->fib_Date.ds_Tick);
77 FreeDosObject(DOS_FIB, fib);
80 *argstring = CreateArgstring(string, strlen(string));
81 FreeMem(string, 1024);
82 return RC_OK;