Metatarget for copying of testfile fixed.
[AROS.git] / workbench / c / ResList.c
blob27c7335c49678986327876294f32d690ef1e9ad8
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <exec/memory.h>
10 #include <exec/tasks.h>
11 #include <exec/execbase.h>
12 #include <proto/exec.h>
13 #include <dos/dosextens.h>
14 #include <proto/dos.h>
16 const TEXT version[] = "$VER: reslist 41.2 (20.7.2001)\n";
18 struct res
20 STRPTR name;
21 APTR address;
24 static int addres(struct Node *r, struct res **l, STRPTR *e)
26 STRPTR s1, s2;
28 (*l)->address = r;
30 s1 = r->ln_Name;
32 if(s1!=NULL)
34 s2=s1;
35 while(*s2++)
37 while(s2>s1)
39 if(*e<=(STRPTR)l)
40 return 0;
41 *--(*e)=*--s2;
44 if((STRPTR)(*l+1)>*e)
45 return 0;
47 (*l)->name=*e;
48 ++*l;
50 return 1;
53 static int fillbuffer(struct res **buffer, IPTR size)
55 STRPTR end=(STRPTR)*buffer+size;
56 struct Node *r;
57 Forbid();
58 for(r=(struct Node *)SysBase->ResourceList.lh_Head;
59 r->ln_Succ!=NULL;
60 r=(struct Node *)r->ln_Succ)
61 if(!addres(r,buffer,&end))
63 Permit();
64 return 0;
66 Permit();
67 return 1;
70 int __nocommandline;
72 int main(void)
74 IPTR size;
75 struct res *buffer,*ress,*ress2;
76 for(size=2048;;size+=2048)
78 buffer=AllocVec(size,MEMF_ANY);
79 if(buffer==NULL)
81 FPuts(Output(),"Not Enough memory for library buffer\n");
82 return 20;
84 ress=buffer;
85 if(fillbuffer(&ress,size))
87 FPuts(Output(),"address\t\tname\n"
88 "------------------------------------------------------------\n");
89 for(ress2=buffer;ress2<ress;ress2++)
91 IPTR args[2];
92 args[0] = (IPTR)ress2->address;
93 args[1] = (IPTR)ress2->name;
95 VPrintf("0x%08.lx\t%s\n", args);
97 FreeVec(buffer);
98 return 0;
100 FreeVec(buffer);