home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
074.lha
/
Exec
/
ListLibs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-20
|
3KB
|
140 lines
/*
* ListLibs.c
*
* This program produces a list of libraries on it's standard.
* output.
*
* Program Date Action
* D. Thomas 24 April 1987 v1.0 Initial Coding.
*
*/
#include "exec/execbase.h"
#include "exec/memory.h"
#include "functions.h"
extern struct ExecBase *SysBase; /* Exec's base ptr */
main ()
{
register struct Library *t; /* ptr to lib list */
register struct List head; /* for my copy of the lib list */
char *flag;
NewList (&head);
Disable ();
if (getlist (&SysBase->LibList, &head))
cleanup (&head);
Enable ();
puts ("Flags NegS PosS Version Revision OpenCnt Name");
while (t = (struct Library *) RemHead (&head)) {
if (t->lib_Flags & LIBF_SUMMING)
flag = "Summing";
else if (t->lib_Flags & LIBF_CHANGED)
flag = "Changed";
else if (t->lib_Flags & LIBF_SUMUSED)
flag = "Sumused";
else if (t->lib_Flags & LIBF_DELEXP)
flag = "Expunge";
else
flag = "";
printf ("%-7.7s ", flag);
printf ("%4x %4x %7u %8u %7u %s\n",
t->lib_NegSize, t->lib_PosSize, t->lib_Version, t->lib_Revision,
t->lib_OpenCnt,
(t->lib_Node.ln_Name ? t->lib_Node.ln_Name : "<unset>"));
if (t->lib_Node.ln_Name)
FreeMem (t->lib_Node.ln_Name, (long) strlen (t->lib_Node.ln_Name) + 1);
FreeMem (t, (long) sizeof *t);
}
exit (0);
}
freelist (l)
struct List *l;
{
struct Library *t;
while (t = (struct Library *) RemHead (l)) {
if (t->lib_Node.ln_Name)
FreeMem (t->lib_Node.ln_Name, (long) strlen (t->lib_Node.ln_Name) + 1);
FreeMem (t, (long) sizeof *t);
}
}
cleanup (l)
struct List *l;
{
Enable ();
freelist (l);
puts ("Out of Memory!");
exit (0);
}
getlist (tl, l)
struct List *tl;
struct List *l;
{
register struct Library *t;
for (t = (struct Library *) tl->lh_Head;
t->lib_Node.ln_Succ;
t = (struct Library *) t->lib_Node.ln_Succ)
if (onenode (t, l))
return TRUE;
return FALSE;
}
onenode (t, l)
struct Library *t;
struct List *l;
{
register struct Library *tc;
if (!(tc = (struct Library *) AllocMem ((long) sizeof *t, MEMF_CLEAR)))
return TRUE;
*tc = *t;
if (t->lib_Node.ln_Name) {
if (!(tc->lib_Node.ln_Name = (char *) AllocMem ((long) strlen (t->lib_Node.ln_Name) + 1, 0L))) {
FreeMem (tc, (long) sizeof *tc);
return TRUE;
}
strcpy (tc->lib_Node.ln_Name, t->lib_Node.ln_Name);
}
AddTail (l, tc);
return FALSE;
}