grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / intuition / getmonitorlist.c
blob9a507da294057816f91e678df6ec9f7a63125f43
1 /*
2 Copyright © 2010-2013, 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 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
62 struct MinNode *n;
63 Object **res;
64 ULONG num = 1;
65 ULONG id = GetTagData(GMLA_DisplayID, INVALID_ID, tags);
67 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
69 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
70 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
71 num++;
74 res = AllocVec(num * sizeof(Object *), MEMF_ANY);
76 if (res) {
77 num = 0;
78 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
79 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
80 res[num++] = (Object *)n;
82 res[num] = NULL;
85 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
87 return res;
89 AROS_LIBFUNC_EXIT