pass -static-libstdc++ via LDFLAGS
[AROS.git] / workbench / c / LibList.c
blob243f9ef4504474256a6747f70dc3bdf545bcf62b
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 /******************************************************************************
12 NAME
14 LibList
16 SYNOPSIS
18 (N/A)
20 LOCATION
24 FUNCTION
26 Print list of all libraries.
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 #if defined(__AROSPLATFORM_SMP__)
54 #include <aros/types/spinlock_s.h>
55 #include <proto/execlock.h>
56 #include <resources/execlock.h>
57 #endif
59 const TEXT version[] = "$VER: LibList 41.3 (11.3.2015)\n";
61 struct lib
63 STRPTR name;
64 APTR address;
65 WORD version;
66 WORD revision;
67 WORD opencnt;
68 UBYTE flags;
71 static int addlib(struct Library *lib, struct lib **l, STRPTR *e)
73 STRPTR s1, s2;
75 (*l)->address = lib;
76 (*l)->version = lib->lib_Version;
77 (*l)->revision = lib->lib_Revision;
78 (*l)->opencnt = lib->lib_OpenCnt;
79 (*l)->flags = lib->lib_Flags;
81 s1 = lib->lib_Node.ln_Name;
83 if(s1!=NULL)
85 s2=s1;
86 while(*s2++)
88 while(s2>s1)
90 if(*e<=(STRPTR)*l)
91 return 0;
92 *--(*e)=*--s2;
95 if((STRPTR)(*l+1)>*e)
96 return 0;
98 (*l)->name=*e;
99 ++*l;
101 return 1;
104 static int fillbuffer(struct lib **buffer, IPTR size)
106 STRPTR end=(STRPTR)*buffer+size;
107 struct Library *lib;
108 #if defined(__AROSPLATFORM_SMP__)
109 void *ExecLockBase = OpenResource("execlock.resource");
110 #endif
112 #if defined(__AROSPLATFORM_SMP__)
113 if (ExecLockBase)
114 ObtainSystemLock(&SysBase->LibList, SPINLOCK_MODE_READ, LOCKF_FORBID);
115 else
116 Forbid();
117 #else
118 Forbid();
119 #endif
120 for(lib=(struct Library *)SysBase->LibList.lh_Head;
121 lib->lib_Node.ln_Succ!=NULL;
122 lib=(struct Library *)lib->lib_Node.ln_Succ)
124 if(!addlib(lib,buffer,&end))
126 #if defined(__AROSPLATFORM_SMP__)
127 if (ExecLockBase)
128 ReleaseSystemLock(&SysBase->LibList, LOCKF_FORBID);
129 else
130 Permit();
131 #else
132 Permit();
133 #endif
134 return 0;
137 #if defined(__AROSPLATFORM_SMP__)
138 if (ExecLockBase)
139 ReleaseSystemLock(&SysBase->LibList, LOCKF_FORBID);
140 else
141 Permit();
142 #else
143 Permit();
144 #endif
146 return 1;
149 int __nocommandline;
151 int main(void)
153 IPTR size;
154 struct lib *buffer,*libs,*libs2;
155 LONG error=RETURN_OK;
157 for(size=2048;;size+=2048)
159 buffer=AllocVec(size,MEMF_ANY);
160 if(buffer==NULL)
162 FPuts(Output(),"Not Enough memory for library buffer\n");
163 SetIoErr(ERROR_NO_FREE_STORE);
164 error = RETURN_FAIL;
165 break;
167 libs=buffer;
168 if(fillbuffer(&libs,size))
170 #if (__WORDSIZE == 64)
171 FPuts(Output()," Address Version Rev OpenCnt Flags name\n");
172 #else
173 FPuts(Output(),"address\t\tversion\trev\topencnt\tflags\tname\n");
174 #endif
175 for(libs2=buffer;libs2<libs;libs2++)
177 #if (__WORDSIZE == 64)
178 Printf("0x%012.ix %7ld %4ld %7ld 0x%02lx %s\n",
179 #else
180 Printf("0x%08.ix\t%ld\t%ld\t%ld\t0x%lx\t%s\n",
181 #endif
182 libs2->address, (ULONG)libs2->version,
183 (ULONG)libs2->revision,
184 (ULONG)libs2->opencnt,
185 (ULONG)libs2->flags,
186 libs2->name);
187 if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
189 error = RETURN_FAIL;
190 SetIoErr(ERROR_BREAK);
191 break;
194 FreeVec(buffer);
195 break;
197 FreeVec(buffer);
200 if (error != RETURN_OK)
202 PrintFault(IoErr(), NULL);
205 return error;