Minor fixes to comments.
[AROS.git] / rom / intuition / getmonitorlist.c
blobd34b09187ac140e0b47abffa708101099adcce04
1 /*
2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Get a copy of monitors list
6 */
8 #include <intuition/extensions.h>
9 #include <proto/exec.h>
10 #include <proto/utility.h>
12 #include "intuition_intern.h"
13 #include "monitorclass_private.h"
15 /*****************************************************************************
17 NAME */
19 #include <proto/intuition.h>
21 AROS_LH1(Object **, GetMonitorList,
23 /* SYNOPSIS */
24 AROS_LHA(struct TagItem *, tags, A1),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 161, Intuition)
29 /* FUNCTION
30 Obtain an array of monitorclass objects installed in the
31 system
33 INPUTS
34 tags - an optional pointer to a taglist with additional options.
35 Currently only one tag is defined:
37 GMLA_DisplayID - list only monitors matching the given
38 display ID
40 RESULT
41 A pointer to a NULL-terminated array of BOOPSI object pointers.
42 This is a copy of internal list, you need to free it using
43 FreeMonitorList()
45 NOTES
46 This function is compatible with MorphOS v2.
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 FreeMonitorList()
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
64 struct MinNode *n;
65 Object **res;
66 ULONG num = 1;
67 ULONG id = GetTagData(GMLA_DisplayID, INVALID_ID, tags);
69 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
71 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
72 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
73 num++;
76 res = AllocVec(num * sizeof(Object *), MEMF_ANY);
78 if (res) {
79 num = 0;
80 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
81 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
82 res[num++] = (Object *)n;
84 res[num] = NULL;
87 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
89 return res;
91 AROS_LIBFUNC_EXIT