2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
8 #include <proto/camd.h>
13 struct Library
*CamdBase
=NULL
;
15 #ifndef GetMidiLinkAttrs
16 ULONG
GetMidiLinkAttrs(struct MidiLink
*ml
, Tag tag
, ...){
17 return GetMidiLinkAttrsA(ml
, (struct TagItem
*)&tag
);
22 ULONG
GetMidiAttrs(struct MidiNode
*ml
, Tag tag
, ...){
23 return GetMidiAttrsA(ml
, (struct TagItem
*)&tag
);
27 struct MidiLink
*GetMidiLinkFromOwnerNode(struct MinNode
*node
){
28 struct MidiLink dummy
;
29 return (struct MidiLink
*)((char *)((char *)(node
)-((char *)&dummy
.ml_OwnerNode
-(char *)&dummy
)));
32 void printSpaces(int level
){
34 for(lokke
=0;lokke
<level
*TABSIZE
;lokke
++){
39 void printLink_brancheNodes(struct MidiLink
*midilink
,int level
,int maxlevel
);
40 void printLink_brancheClusters(struct MidiLink
*midilink
,int level
,int maxlevel
);
41 void printCluster(struct MidiCluster
*cluster
,int level
,int maxlevel
);
44 void printNode(struct MidiNode
*midinode
,int level
,int maxlevel
){
48 if(level
==maxlevel
) return;
50 GetMidiAttrs(midinode
,MIDI_Name
,(IPTR
)&nodename
,TAG_END
);
59 if(level
+1==maxlevel
) return;
61 if( ! (IsListEmpty(&midinode
->mi_OutLinks
))){
63 printf(" -OutLinks:\n");
64 node
=midinode
->mi_OutLinks
.mlh_Head
;
65 while(node
->mln_Succ
!=NULL
){
66 printLink_brancheClusters(GetMidiLinkFromOwnerNode(node
),level
+1,maxlevel
);
71 if( ! (IsListEmpty(&midinode
->mi_InLinks
))){
73 printf(" -InLinks:\n");
74 node
=midinode
->mi_InLinks
.mlh_Head
;
75 while(node
->mln_Succ
!=NULL
){
76 printLink_brancheClusters(GetMidiLinkFromOwnerNode(node
),level
+1,maxlevel
);
83 BOOL
printLink(struct MidiLink
*midilink
){
86 if(midilink
->ml_Node
.ln_Type
==NT_USER
-MLTYPE_Receiver
|| midilink
->ml_Node
.ln_Type
==NT_USER
-MLTYPE_Sender
){
87 GetMidiLinkAttrs(midilink
,MLINK_Name
,(IPTR
)&linkname
,TAG_END
);
96 printf("%p, <driverdata> (private)\n",midilink
);
100 void printLink_brancheNodes(struct MidiLink
*midilink
,int level
,int maxlevel
){
101 struct MidiNode
*midinode
;
103 if(level
==maxlevel
) return;
106 if(printLink(midilink
)==TRUE
){
107 midinode
=midilink
->ml_MidiNode
;
109 printf(" -Owner (MidiNode): \n");
110 printNode(midinode
,level
+1,maxlevel
);
114 void printLink_brancheClusters(struct MidiLink
*midilink
,int level
,int maxlevel
){
115 if(level
==maxlevel
) return;
120 if(level
+1==maxlevel
) return;
123 printf(" -Cluster: \n");
124 printCluster(midilink
->ml_Location
,level
+1,maxlevel
);
128 void printCluster(struct MidiCluster
*cluster
,int level
,int maxlevel
){
129 struct MidiLink
*midilink
;
131 if(level
==maxlevel
) return;
134 printf("clustername: -%s-\n",cluster
->mcl_Node
.ln_Name
);
136 if(level
+1==maxlevel
) return;
138 if(!(IsListEmpty(&cluster
->mcl_Receivers
))){
141 printf("-Receiver links:\n");
143 midilink
=(struct MidiLink
*)cluster
->mcl_Receivers
.lh_Head
;
144 while(midilink
->ml_Node
.ln_Succ
!=NULL
){
145 printLink_brancheNodes(midilink
,level
+1,maxlevel
);
146 midilink
=(struct MidiLink
*)midilink
->ml_Node
.ln_Succ
;
150 if(!(IsListEmpty(&cluster
->mcl_Senders
))){
153 printf("-Sender links:\n");
154 midilink
=(struct MidiLink
*)cluster
->mcl_Senders
.lh_Head
;
155 while(midilink
->ml_Node
.ln_Succ
!=NULL
){
156 printLink_brancheNodes(midilink
,level
+1,maxlevel
);
157 midilink
=(struct MidiLink
*)midilink
->ml_Node
.ln_Succ
;
166 struct MidiCluster
*cluster
;
168 CamdBase
=OpenLibrary("camd.library",40L);
172 lock
=LockCAMD(CD_Linkages
);
174 cluster
=NextCluster(NULL
);
177 printf("No clusters available.\n");
181 printf("-Clusters:\n\n");
183 printCluster(cluster
,1,6);
185 cluster
=NextCluster(cluster
);
186 }while(cluster
!=NULL
);
191 CloseLibrary(CamdBase
);
194 printf("Could not open at least V40 of camd.library.\n");