4 #include <proto/exec.h>
5 #include <proto/camd.h>
10 struct Library
*CamdBase
=NULL
;
12 #ifndef GetMidiLinkAttrs
13 ULONG
GetMidiLinkAttrs(struct MidiLink
*ml
, Tag tag
, ...){
14 return GetMidiLinkAttrsA(ml
, (struct TagItem
*)&tag
);
19 ULONG
GetMidiAttrs(struct MidiNode
*ml
, Tag tag
, ...){
20 return GetMidiAttrsA(ml
, (struct TagItem
*)&tag
);
24 struct MidiLink
*GetMidiLinkFromOwnerNode(struct MinNode
*node
){
25 struct MidiLink dummy
;
26 return (struct MidiLink
*)((char *)((char *)(node
)-((char *)&dummy
.ml_OwnerNode
-(char *)&dummy
)));
29 void printSpaces(int level
){
31 for(lokke
=0;lokke
<level
*TABSIZE
;lokke
++){
36 void printLink_brancheNodes(struct MidiLink
*midilink
,int level
,int maxlevel
);
37 void printLink_brancheClusters(struct MidiLink
*midilink
,int level
,int maxlevel
);
38 void printCluster(struct MidiCluster
*cluster
,int level
,int maxlevel
);
41 void printNode(struct MidiNode
*midinode
,int level
,int maxlevel
){
45 if(level
==maxlevel
) return;
47 GetMidiAttrs(midinode
,MIDI_Name
,(IPTR
)&nodename
,TAG_END
);
56 if(level
+1==maxlevel
) return;
58 if( ! (IsListEmpty((struct List
*)&midinode
->mi_OutLinks
))){
60 printf(" -OutLinks:\n");
61 node
=midinode
->mi_OutLinks
.mlh_Head
;
62 while(node
->mln_Succ
!=NULL
){
63 printLink_brancheClusters(GetMidiLinkFromOwnerNode(node
),level
+1,maxlevel
);
68 if( ! (IsListEmpty((struct List
*)&midinode
->mi_InLinks
))){
70 printf(" -InLinks:\n");
71 node
=midinode
->mi_InLinks
.mlh_Head
;
72 while(node
->mln_Succ
!=NULL
){
73 printLink_brancheClusters(GetMidiLinkFromOwnerNode(node
),level
+1,maxlevel
);
80 BOOL
printLink(struct MidiLink
*midilink
){
83 if(midilink
->ml_Node
.ln_Type
==NT_USER
-MLTYPE_Receiver
|| midilink
->ml_Node
.ln_Type
==NT_USER
-MLTYPE_Sender
){
84 GetMidiLinkAttrs(midilink
,MLINK_Name
,(IPTR
)&linkname
,TAG_END
);
93 printf("%p, <driverdata> (private)\n",midilink
);
97 void printLink_brancheNodes(struct MidiLink
*midilink
,int level
,int maxlevel
){
98 struct MidiNode
*midinode
;
100 if(level
==maxlevel
) return;
103 if(printLink(midilink
)==TRUE
){
104 midinode
=midilink
->ml_MidiNode
;
106 printf(" -Owner (MidiNode): \n");
107 printNode(midinode
,level
+1,maxlevel
);
111 void printLink_brancheClusters(struct MidiLink
*midilink
,int level
,int maxlevel
){
112 if(level
==maxlevel
) return;
117 if(level
+1==maxlevel
) return;
120 printf(" -Cluster: \n");
121 printCluster(midilink
->ml_Location
,level
+1,maxlevel
);
125 void printCluster(struct MidiCluster
*cluster
,int level
,int maxlevel
){
126 struct MidiLink
*midilink
;
128 if(level
==maxlevel
) return;
131 printf("clustername: -%s-\n",cluster
->mcl_Node
.ln_Name
);
133 if(level
+1==maxlevel
) return;
135 if(!(IsListEmpty(&cluster
->mcl_Receivers
))){
138 printf("-Receiver links:\n");
140 midilink
=(struct MidiLink
*)cluster
->mcl_Receivers
.lh_Head
;
141 while(midilink
->ml_Node
.ln_Succ
!=NULL
){
142 printLink_brancheNodes(midilink
,level
+1,maxlevel
);
143 midilink
=(struct MidiLink
*)midilink
->ml_Node
.ln_Succ
;
147 if(!(IsListEmpty(&cluster
->mcl_Senders
))){
150 printf("-Sender links:\n");
151 midilink
=(struct MidiLink
*)cluster
->mcl_Senders
.lh_Head
;
152 while(midilink
->ml_Node
.ln_Succ
!=NULL
){
153 printLink_brancheNodes(midilink
,level
+1,maxlevel
);
154 midilink
=(struct MidiLink
*)midilink
->ml_Node
.ln_Succ
;
163 struct MidiCluster
*cluster
;
165 CamdBase
=OpenLibrary("camd.library",40L);
169 lock
=LockCAMD(CD_Linkages
);
171 cluster
=NextCluster(NULL
);
174 printf("No clusters available.\n");
178 printf("-Clusters:\n\n");
180 printCluster(cluster
,1,6);
182 cluster
=NextCluster(cluster
);
183 }while(cluster
!=NULL
);
188 CloseLibrary(CamdBase
);
191 printf("Could not open at least V40 of camd.library.\n");