Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / iffparse / openclipboard.c
blob954036f026faa2049086e28a9d5fd17332ebbb78
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "iffparse_intern.h"
8 /*****************************************************************************
10 NAME */
11 #include <proto/iffparse.h>
13 AROS_LH1(struct ClipboardHandle *, OpenClipboard,
15 /* SYNOPSIS */
16 AROS_LHA(LONG, unitNumber, D0),
18 /* LOCATION */
19 struct Library *, IFFParseBase, 41, IFFParse)
21 /* FUNCTION
22 Opens the clipboard.device with the specified unit.
23 Allocates and initializes a ClipboardHandle struct which should
24 be put into the iff_Stream field of the IFFHandle when the
25 handle is initialized with InitIFFasClip().
28 INPUTS
29 unitNumber - a clipboard device unit number (usually PRIMARY_CLIP).
31 RESULT
32 ch - pointer to ClipboarHandle struct or NULL if unsuccessfull.
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
41 InitIFFasClip(), CloseClipboard()
43 INTERNALS
45 *****************************************************************************/
47 AROS_LIBFUNC_INIT
48 struct ClipboardHandle * ch;
49 struct IOClipReq * req;
50 struct Task * thistask;
52 /* Allocate a ClipBoardHandle */
54 ch = AllocMem
56 sizeof (struct ClipboardHandle),
57 MEMF_ANY | MEMF_CLEAR | MEMF_PUBLIC
59 if (ch)
61 /* Get a ponter to the ioClipReq, so we
62 don't need all that type casting.
64 req = &(ch->cbh_Req);
67 thistask = FindTask(0L);
69 if (InitPort( &(ch->cbh_CBport), thistask, IPB(IFFParseBase)))
71 if (InitPort( &(ch->cbh_SatisfyPort), thistask, IPB(IFFParseBase)))
73 /* Initialize the IORequest structure.
74 Basically CreateIORequest without memory allocation.
76 req->io_Message.mn_ReplyPort = &(ch->cbh_CBport);
77 req->io_Message.mn_Length = sizeof(struct IOClipReq);
80 (!OpenDevice
82 "clipboard.device",
83 unitNumber,
84 (struct IORequest*)req,
90 return (ch);
93 ClosePort( &(ch->cbh_SatisfyPort), IPB(IFFParseBase));
96 ClosePort( &(ch->cbh_CBport), IPB(IFFParseBase));
98 FreeMem(ch, sizeof (struct ClipboardHandle));
100 return (FALSE);
103 AROS_LIBFUNC_EXIT
104 } /* OpenClipboard */