fix usage of krnspinlock & wip changes to scheduling code. move tasks in TS_SPIN...
[AROS.git] / workbench / c / ResList.c
blob2f493294809873746ee2d3ec910281bdb9338fb1
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 /******************************************************************************
12 NAME
14 ResList
16 SYNOPSIS
18 (N/A)
20 LOCATION
24 FUNCTION
26 Prints a list of all resources.
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 HISTORY
44 ******************************************************************************/
46 #include <exec/memory.h>
47 #include <exec/tasks.h>
48 #include <exec/execbase.h>
49 #include <proto/exec.h>
50 #include <dos/dosextens.h>
51 #include <proto/dos.h>
53 const TEXT version[] = "$VER: reslist 41.3 (11.3.2015)\n";
55 struct res
57 STRPTR name;
58 APTR address;
61 static int addres(struct Node *r, struct res **l, STRPTR *e)
63 STRPTR s1, s2;
65 (*l)->address = r;
67 s1 = r->ln_Name;
69 if(s1!=NULL)
71 s2=s1;
72 while(*s2++)
74 while(s2>s1)
76 if(*e<=(STRPTR)*l)
77 return 0;
78 *--(*e)=*--s2;
81 if((STRPTR)(*l+1)>*e)
82 return 0;
84 (*l)->name=*e;
85 ++*l;
87 return 1;
90 static int fillbuffer(struct res **buffer, IPTR size)
92 STRPTR end=(STRPTR)*buffer+size;
93 struct Node *r;
94 Forbid();
95 for(r=(struct Node *)SysBase->ResourceList.lh_Head;
96 r->ln_Succ!=NULL;
97 r=(struct Node *)r->ln_Succ)
99 if(!addres(r,buffer,&end))
101 Permit();
102 return 0;
105 Permit();
106 return 1;
109 int __nocommandline;
111 int main(void)
113 IPTR size;
114 struct res *buffer,*ress,*ress2;
115 for(size=2048;;size+=2048)
117 buffer=AllocVec(size,MEMF_ANY);
118 if(buffer==NULL)
120 FPuts(Output(),"Not Enough memory for library buffer\n");
121 return 20;
123 ress=buffer;
124 if(fillbuffer(&ress,size))
126 FPuts(Output(),"address\t\tname\n"
127 "------------------------------------------------------------\n");
128 for(ress2=buffer;ress2<ress;ress2++)
130 IPTR args[2];
131 args[0] = (IPTR)ress2->address;
132 args[1] = (IPTR)ress2->name;
134 VPrintf("0x%08.lx\t%s\n", args);
136 FreeVec(buffer);
137 return 0;
139 FreeVec(buffer);