[Contents] [Index] [Help] [Retrace] [browse <] [Browse >]


NAME
    EntryHandler -- Add an entry handler to the iffhandle context.

SYNOPSIS
    error = EntryHandler (iff, type, id, position, hook, object)
     d0                   a0    d0   d1    d2       a1     a2

    LONG             error;
    struct iffhandle *iff;
    LONG             type, id, position;
    struct hook     *hook;
    APTR             object;

FUNCTION
    Installs an entry handler vector for a specific type of chunk into
    the context for the given iffhandle struct.  type and id are the
    longword identifiers for the chunk to handle.  The hook is a client-
    supplied standard 2.0 hook structure, properly initialized.  position
    tells where to put the handler in the context.  The handler will be
    called whenever the parser enters a chunk of the given type, so the
    IFF stream will be positioned to read the first data byte in the
    chunk.  The handler will execute in the same context as whoever
    called parseiff().  the handler will be called (through the hook)
    with the following arguments:

            A0:     the hook pointer you passed.
            A2:     the 'object' pointer you passed.
            A1:     pointer to a LONG containing the value
                    IFFCMD_ENTRY.

    The error code your call-back routine returns will affect the parser
    in three different ways:

    Return value            Result
    ------------            ------
    0:                      Normal success;  parseiff() will continue
                            through the file.
    IFF_RETURN2CLIENT:      parseiff() will stop and return the value 0.
                            (StopChunk() is internally implemented using
                            this return value.)
    Any other value:        parseiff() will stop and return the value
                            you supplied.  This is how errors should be
                            returned.

INPUTS
    iff     - pointer to iffhandle struct.
    type    - type code for chunk to handle (ex. "ILBM").
    id      - ID code for chunk to handle (ex. "CMAP").
    position- Local context item position.  One of the IFFSLI_#? codes.
    hook    - pointer to hook structure.
    object  - a client-defined pointer which is passed in A2 during call-
              back.

RESULT
    error   - 0 if successful or an IFFERR_#? error code if not
              successful.

EXAMPLE

NOTES

BUGS
    Returning the values IFFERR_EOF or IFFERR_EOC from the call-back
    routine *may* confuse the parser.

    There is no way to explicitly remove a handler once installed.
    However, by installing a do-nothing handler using IFFSLI_TOP,
    previous handlers will be overridden until the context expires.

SEE ALSO
    exithandler(), storelocalitem(), storeitemincontext(),
    utility/hooks.h