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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: exithandler.c,v 1.1 1997/02/03 16:44:23 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_LH6(LONG, ExitHandler,
  16.  
  17. /*  SYNOPSIS */
  18.     AROS_LHA(struct IFFHandle *, iff, A0),
  19.     AROS_LHA(LONG              , type, D0),
  20.     AROS_LHA(LONG              , id, D1),
  21.     AROS_LHA(LONG              , position, D2),
  22.     AROS_LHA(struct Hook      *, handler, A1),
  23.     AROS_LHA(APTR              , object, A2),
  24.  
  25. /*  LOCATION */
  26.     struct Library *, IFFParseBase, 18, IFFParse)
  27.  
  28. /*  FUNCTION
  29.     Installs an exit handler for a specific chunk type
  30.     that wil be called whenever a chunk of that type is popped off the contextstack
  31.     via ParseIFF().
  32.  
  33.  
  34.     INPUTS
  35.     iff        - pointer to an iffhandle struct.
  36.     type      - type code for the chunk to handle. (ex: "ILBM").
  37.     id      -  ID code for the chunk to handle. (ex: "CMAP")
  38.     position  -  position of localcontextitem. See StoreLocalItem for
  39.             more info.
  40.     handler    -  an initialised Hook structure for the handler function.
  41.     object      -  pointer to some kind of object that will be passed to
  42.             your handler function.
  43.  
  44.     RESULT
  45.     error - 0 If successfull, IFFERR_#? elsewise.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.      EntryHandler(), StoreLocalItem(), StoreItemInContext()
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.   27-11-96    digulla automatically created from
  60.       iffparse_lib.fd and clib/iffparse_protos.h
  61.  
  62. *****************************************************************************/
  63. {
  64.     AROS_LIBFUNC_INIT
  65.     AROS_LIBBASE_EXT_DECL(struct Library *,IFFParseBase)
  66.  
  67.     struct LocalContextItem *lci;
  68.     struct HandlerInfo *hi;
  69.  
  70.     if
  71.     (
  72.     !(lci = AllocLocalItem
  73.         (
  74.         type,
  75.         id,
  76.         IFFLCI_EXITHANDLER,
  77.         sizeof (struct HandlerInfo)
  78.         )
  79.     )
  80.     )
  81.     return (IFFERR_NOMEM);
  82.  
  83.     /* Get pointer to the user contining a HandlerInfo structure data */
  84.     hi = LocalItemData(lci);
  85.  
  86.     hi->hi_Hook  = handler;
  87.  
  88.     hi->hi_Object  = object;
  89.  
  90.     return
  91.     (
  92.     StoreLocalItem
  93.     (
  94.         iff,
  95.         lci,
  96.         position
  97.     )
  98.     );
  99.  
  100.  
  101.     AROS_LIBFUNC_EXIT
  102. } /* ExitHandler */
  103.