2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
9 /******************************************************************************
26 Prints a list of all devices.
44 ******************************************************************************/
46 #include <exec/memory.h>
47 #include <exec/tasks.h>
48 #include <exec/execbase.h>
49 #include <exec/devices.h>
50 #include <proto/exec.h>
51 #include <dos/dosextens.h>
52 #include <proto/dos.h>
54 const TEXT version
[] = "$VER: DevList 41.1 (14.3.1997)\n";
66 static int adddev(struct Device
*dev
, struct dev
**l
, STRPTR
*e
)
71 (*l
)->version
= dev
->dd_Library
.lib_Version
;
72 (*l
)->revision
= dev
->dd_Library
.lib_Revision
;
73 (*l
)->opencnt
= dev
->dd_Library
.lib_OpenCnt
;
74 (*l
)->flags
= dev
->dd_Library
.lib_Flags
;
76 s1
= dev
->dd_Library
.lib_Node
.ln_Name
;
85 if(*e
<=(STRPTR
)(*l
+2))
99 static int fillbuffer(struct dev
**buffer
, IPTR size
)
101 STRPTR end
=(STRPTR
)*buffer
+size
;
104 for(dev
=(struct Device
*)SysBase
->DeviceList
.lh_Head
;
105 dev
->dd_Library
.lib_Node
.ln_Succ
!=NULL
;
106 dev
=(struct Device
*)dev
->dd_Library
.lib_Node
.ln_Succ
)
107 if(!adddev(dev
,buffer
,&end
))
116 int __nocommandline
= 1;
121 struct dev
*buffer
,*devs
,*devs2
;
122 LONG error
=RETURN_OK
;
124 for(size
=2048;;size
+=2048)
126 buffer
=AllocVec(size
,MEMF_ANY
);
129 FPuts(Output(),"Not Enough memory for device buffer\n");
133 if(fillbuffer(&devs
,size
))
135 FPuts(Output(),"address\t\tversion\trev\topencnt\tflags\tname\n"
136 "------------------------------------------------------------\n");
137 for(devs2
=buffer
;devs2
<devs
;devs2
++)
139 Printf("0x%08.lx\t%ld\t%ld\t%ld\t0x%lx\t%s\n",
140 devs2
->address
, devs2
->version
,
141 devs2
->revision
, devs2
->opencnt
,
142 devs2
->flags
, devs2
->name
);
143 if(SetSignal(0L,SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
)
146 SetIoErr(ERROR_BREAK
);
155 if (error
!= RETURN_OK
)
157 PrintFault(IoErr(), NULL
);