Removed EBF_SILENTSTART, it was not meant to be included with rev 36660.
[AROS.git] / test / camdtree.c
blob451e0ab705b59ec6a6e90f1258b3a85405319a0f
3 #include <stdio.h>
4 #include <proto/exec.h>
5 #include <proto/camd.h>
6 #include <midi/camd.h>
8 #define TABSIZE 4
10 struct Library *CamdBase=NULL;
12 #ifndef GetMidiLinkAttrs
13 ULONG GetMidiLinkAttrs(struct MidiLink *ml, Tag tag, ...){
14 return GetMidiLinkAttrsA(ml, (struct TagItem *)&tag );
16 #endif
18 #ifndef GetMidiAttrs
19 ULONG GetMidiAttrs(struct MidiNode *ml, Tag tag, ...){
20 return GetMidiAttrsA(ml, (struct TagItem *)&tag );
22 #endif
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){
30 int lokke;
31 for(lokke=0;lokke<level*TABSIZE;lokke++){
32 printf(" ");
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){
42 char *nodename=NULL;
43 struct MinNode *node;
45 if(level==maxlevel) return;
47 GetMidiAttrs(midinode,MIDI_Name,(IPTR)&nodename,TAG_END);
49 printSpaces(level);
50 printf(
51 "%p, -%s-\n",
52 midinode,
53 nodename
56 if(level+1==maxlevel) return;
58 if( ! (IsListEmpty((struct List *)&midinode->mi_OutLinks))){
59 printSpaces(level);
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);
64 node=node->mln_Succ;
68 if( ! (IsListEmpty((struct List *)&midinode->mi_InLinks))){
69 printSpaces(level);
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);
74 node=node->mln_Succ;
80 BOOL printLink(struct MidiLink *midilink){
81 char *linkname=NULL;
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);
85 printf(
86 "%p, -%s-\n",
87 midilink,
88 linkname
90 return TRUE;
93 printf("%p, <driverdata> (private)\n",midilink);
94 return FALSE;
97 void printLink_brancheNodes(struct MidiLink *midilink,int level,int maxlevel){
98 struct MidiNode *midinode;
100 if(level==maxlevel) return;
102 printSpaces(level);
103 if(printLink(midilink)==TRUE){
104 midinode=midilink->ml_MidiNode;
105 printSpaces(level);
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;
114 printSpaces(level);
115 printLink(midilink);
117 if(level+1==maxlevel) return;
119 printSpaces(level);
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;
130 printSpaces(level);
131 printf("clustername: -%s-\n",cluster->mcl_Node.ln_Name);
133 if(level+1==maxlevel) return;
135 if(!(IsListEmpty(&cluster->mcl_Receivers))){
136 printSpaces(level);
137 printf(" ");
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))){
148 printSpaces(level);
149 printf(" ");
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;
160 int main(){
162 APTR lock;
163 struct MidiCluster *cluster;
165 CamdBase=OpenLibrary("camd.library",40L);
167 if(CamdBase!=NULL){
169 lock=LockCAMD(CD_Linkages);
171 cluster=NextCluster(NULL);
172 if(cluster==NULL){
174 printf("No clusters available.\n");
176 }else{
178 printf("-Clusters:\n\n");
180 printCluster(cluster,1,6);
181 printf("\n");
182 cluster=NextCluster(cluster);
183 }while(cluster!=NULL);
187 UnlockCAMD(lock);
188 CloseLibrary(CamdBase);
190 }else{
191 printf("Could not open at least V40 of camd.library.\n");
192 return 1;
195 return 0;