home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / workbench / libs / iffparse / openclipboard.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-03  |  2.3 KB  |  111 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openclipboard.c,v 1.1 1997/02/03 16:44:26 digulla Exp $
  4.  
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "iffparse_intern.h"
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <proto/iffparse.h>
  14.  
  15.     AROS_LH1(struct ClipboardHandle *, OpenClipboard,
  16.  
  17. /*  SYNOPSIS */
  18.     AROS_LHA(LONG, unitNumber, D0),
  19.  
  20. /*  LOCATION */
  21.     struct Library *, IFFParseBase, 41, IFFParse)
  22.  
  23. /*  FUNCTION
  24.     Opens the clipboard.device with the specified unit.
  25.     Allocates and initializes a ClipboardHandle struct which should
  26.     be put into the iff_Stream field of the IFFHandle when the
  27.     handle is initialized with InitIFFasClip().
  28.  
  29.  
  30.     INPUTS
  31.     unitNumber  - a clipboard device unit number (usually PRIMARY_CLIP).
  32.  
  33.     RESULT
  34.     ch        -  pointer to ClipboarHandle struct or NULL if unsuccessfull.
  35.  
  36.     NOTES
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     InitIFFasClip(), CloseClipboard()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.   27-11-96    digulla automatically created from
  49.       iffparse_lib.fd and clib/iffparse_protos.h
  50.  
  51. *****************************************************************************/
  52. {
  53.     AROS_LIBFUNC_INIT
  54.     AROS_LIBBASE_EXT_DECL(struct Library *,IFFParseBase)
  55.     struct ClipboardHandle * ch;
  56.     struct IOClipReq       * req;
  57.     struct Task        * thistask;
  58.  
  59.     /* Allocate a ClipBoardHandle */
  60.  
  61.     ch = AllocMem
  62.     (
  63.     sizeof (struct ClipboardHandle),
  64.     MEMF_ANY | MEMF_CLEAR | MEMF_PUBLIC
  65.     );
  66.     if (ch);
  67.     {
  68.     /* Get a ponter to the ioClipReq, so we
  69.       don't need all that type casting.
  70.     */
  71.     req = &(ch->cbh_Req);
  72.  
  73.  
  74.     thistask = FindTask(0L);
  75.  
  76.     if (InitPort( &(ch->cbh_CBport), thistask, IPB(IFFParseBase)))
  77.     {
  78.         if (InitPort( &(ch->cbh_SatisfyPort), thistask, IPB(IFFParseBase)))
  79.         {
  80.         /* Initialize the IORequest structure.
  81.         Basically CreateIORequest without memory allocation.
  82.         */
  83.         req->io_Message.mn_ReplyPort = &(ch->cbh_CBport);
  84.  
  85.         if
  86.         (!OpenDevice
  87.             (
  88.             "clipboard.device",
  89.             unitNumber,
  90.             (struct IORequest*)req,
  91.             0L
  92.             )
  93.         )
  94.         {
  95.  
  96.             return (ch);
  97.         }
  98.  
  99.         ClosePort( &(ch->cbh_SatisfyPort), IPB(IFFParseBase));
  100.         }
  101.  
  102.         ClosePort( &(ch->cbh_CBport), IPB(IFFParseBase));
  103.     }
  104.     FreeMem(ch, sizeof (struct ClipboardHandle));
  105.     }
  106.     return (FALSE);
  107.  
  108.  
  109.     AROS_LIBFUNC_EXIT
  110. } /* OpenClipboard */
  111.