revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / camd / nextcluster.c
blobc054fd9ade9462a7d5d40eed8e05b1e5bfa59e44
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
11 #include "camd_intern.h"
13 /*****************************************************************************
15 NAME */
17 AROS_LH1(struct MidiCluster *, NextCluster,
19 /* SYNOPSIS */
20 AROS_LHA(struct MidiCluster *, last, A0),
22 /* LOCATION */
23 struct CamdBase *, CamdBase, 21, Camd)
25 /* FUNCTION
26 Finds the next cluster in camds list of clusters.
28 INPUTS
29 last - cluster to start searching for.
31 RESULT
32 Next cluster in list, or first if 'last' is NULL.
34 NOTES
35 - CL_Linkages must be locked.
37 - Often, a program wants to use this function for finding available
38 clusters a user can choose from. It is then recommended to also
39 let the user have the possibility to write in the name of a new cluster,
40 so that camd can make new clusters automatically to be used for
41 communication between various applications without having hardware-drivers
42 etc. interfere with the datastreams. Applications do
43 not need to make special concerns about how cluster works or
44 what they contain; that is all managed by camd.
46 EXAMPLE
48 #include <stdio.h>
49 #include <proto/exec.h>
50 #include <proto/camd.h>
51 #include <midi/camd.h>
53 int main(){
55 APTR lock;
56 struct MidiCluster *cluster;
58 struct Library *CamdBase=OpenLibrary("camd.library",0L);
59 if(CamdBase!=NULL){
61 lock=LockCAMD(CD_Linkages);
63 cluster=NextCluster(NULL);
64 if(cluster==NULL){
66 printf("No clusters available.\n");
68 }else{
70 do{
71 printf("clustername: -%s-\n",cluster->mcl_Node.ln_Name);
72 cluster=NextCluster(cluster);
73 }while(cluster!=NULL);
77 UnlockCAMD(lock);
78 CloseLibrary(CamdBase);
80 }else{
81 printf("Could not open camd.library.\n");
82 return 1;
85 return 0;
89 BUGS
91 SEE ALSO
92 NextMidiLink(), NextMidi(), FindCluster()
94 INTERNALS
96 HISTORY
98 2001-01-12 ksvalast first created
100 *****************************************************************************/
102 AROS_LIBFUNC_INIT
104 if(last==NULL){
105 if(IsListEmpty(&CB(CamdBase)->midiclusters)){
106 return NULL;
108 return (struct MidiCluster *)CB(CamdBase)->midiclusters.lh_Head;
110 if(last->mcl_Node.ln_Succ->ln_Succ==NULL) return NULL;
112 return (struct MidiCluster *)last->mcl_Node.ln_Succ;
114 AROS_LIBFUNC_EXIT