New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / c / LibList.c
bloba068c92b46cddbc7721b8a2b5212a927c1962d2c
1 /*
2 Copyright © 1995-2001, 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 static const char version[] = "$VER: liblist 41.2 (10.10.2005)\n";
18 struct lib
20 STRPTR name;
21 APTR address;
22 WORD version;
23 WORD revision;
24 WORD opencnt;
25 UBYTE flags;
28 static int addlib(struct Library *lib, struct lib **l, STRPTR *e)
30 STRPTR s1, s2;
32 (*l)->address = lib;
33 (*l)->version = lib->lib_Version;
34 (*l)->revision = lib->lib_Revision;
35 (*l)->opencnt = lib->lib_OpenCnt;
36 (*l)->flags = lib->lib_Flags;
38 s1 = lib->lib_Node.ln_Name;
40 if(s1!=NULL)
42 s2=s1;
43 while(*s2++)
45 while(s2>s1)
47 if(*e<=(STRPTR)l)
48 return 0;
49 *--(*e)=*--s2;
52 if((STRPTR)(*l+1)>*e)
53 return 0;
55 (*l)->name=*e;
56 ++*l;
58 return 1;
61 static int fillbuffer(struct lib **buffer, IPTR size)
63 STRPTR end=(STRPTR)*buffer+size;
64 struct Library *lib;
65 Forbid();
66 for(lib=(struct Library *)SysBase->LibList.lh_Head;
67 lib->lib_Node.ln_Succ!=NULL;
68 lib=(struct Library *)lib->lib_Node.ln_Succ)
69 if(!addlib(lib,buffer,&end))
71 Permit();
72 return 0;
74 Permit();
75 return 1;
78 int __nocommandline;
80 int main(void)
82 IPTR size;
83 struct lib *buffer,*libs,*libs2;
84 LONG error=RETURN_OK;
86 for(size=2048;;size+=2048)
88 buffer=AllocVec(size,MEMF_ANY);
89 if(buffer==NULL)
91 FPuts(Output(),"Not Enough memory for library buffer\n");
92 SetIoErr(ERROR_NO_FREE_STORE);
93 error = RETURN_FAIL;
94 break;
96 libs=buffer;
97 if(fillbuffer(&libs,size))
99 FPuts(Output(),"address\t\tversion\trev\topencnt\tflags\tname\n"
100 "------------------------------------------------------------\n");
101 for(libs2=buffer;libs2<libs;libs2++)
103 IPTR args[6];
104 args[0] = (IPTR)libs2->address;
105 args[1] = (IPTR)libs2->version;
106 args[2] = (IPTR)libs2->revision;
107 args[3] = (IPTR)libs2->opencnt;
108 args[4] = (IPTR)libs2->flags;
109 args[5] = (IPTR)libs2->name;
111 VPrintf("0x%08.lx\t%ld\t%ld\t%ld\t0x%lx\t%s\n", args);
112 if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
114 error = RETURN_FAIL;
115 SetIoErr(ERROR_BREAK);
116 break;
119 FreeVec(buffer);
120 break;
122 FreeVec(buffer);
125 if (error != RETURN_OK)
127 PrintFault(IoErr(), NULL);
130 return error;