Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / mui_obtainpen.c
blobc384aad90306e70711fc57573b8775f3423e68bf
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <proto/graphics.h>
8 #include <proto/muimaster.h>
10 #include <string.h>
11 #include <stdlib.h>
13 #include "mui.h"
14 #include "penspec.h"
15 #include "muimaster_intern.h"
17 /*****************************************************************************
19 NAME */
20 AROS_LH3(LONG, MUI_ObtainPen,
22 /* SYNOPSIS */
23 AROS_LHA(struct MUI_RenderInfo *, mri, A0),
24 AROS_LHA(struct MUI_PenSpec *, spec, A1),
25 AROS_LHA(ULONG, flags, D0),
27 /* LOCATION */
28 struct Library *, MUIMasterBase, 22, MUIMaster)
30 /* FUNCTION
31 Turns struct MUI_PenSpec (the result of a Poppen object) into
32 a pen for SetAPen().
34 INPUTS
36 RESULT
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 MUI_ReleasePen()
47 INTERNALS
49 HISTORY
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 LONG retval = -1;
56 struct MUI_PenSpec_intern intern;
58 if (!spec || !mri || !mri->mri_Colormap) return -1;
60 if (!zune_pen_spec_to_intern(spec, &intern))
61 return -1;
62 if (!zune_penspec_setup(&intern, mri))
63 return -1;
64 retval = intern.p_pen;
65 if ((retval != -1) && (intern.p_is_allocated))
67 /* flag to indicate that ReleasePen() needs to be called
68 in MUI_ReleasePen() */
70 retval |= 0x10000;
73 return retval;
75 AROS_LIBFUNC_EXIT
77 } /* MUIA_ObtainPen */