> > ggiBseAttach()
> >      +-->ggiOvlAttach()
> >      |         +--->ggiGAAttach()
> >      |         |        +--->ggiExtensionAttach() succeeds
> >      |         +--->ggiExtensionAttach() succeeds
> >      +-->ggiBltAttach()
> >                +--->ggiGAAttach()
> >                         +--->ggiExtensionAttach() fails
> BTW: The return code is "1" instead "GGI_OK" (which is "0").

Look in lib/libggi/ggi/init.c (UTSL):

/*
  Make an extension available for a given visual.
  The extension has to be registered for that.
  RC: negative  Error.
       x        for the number of times this extension had already been
                registered to that visual. So
       0        means you installed the extension as the first one. Note that
     >=0        should be regarded as "success". It is legal to attach an
                extension multiple times. You might want to set up private
                data if RC==0.
*/
int ggiExtensionAttach(ggi_visual *vis, ggi_extid id)

> > Why does ggiExtensionAttach fail?

It does not fail - see above.

> > Is that a bug or a feature?

This is a feature and correct. The point is, that you will want to
initialize private datastructures when you _FIRST_ attach to a visual.

>From the misc extension:

int ggiMiscAttach(ggi_visual_t vis)
{
        int rc;

        rc = ggiExtensionAttach(vis, ggiMiscID);
        GGIDPRINT("Attached Misc extension to %p. rc=%i\n", vis, rc);

        if (rc == 0) {
                /* We are actually creating the primary instance. */
                memset(LIBGGI_MISCEXT(vis), 0, sizeof(miscext));
                LIBGGI_MISCEXT(vis)->priv = NULL;

                /* Now fake an "API change" so the right libs get loaded */
                changed(vis,GGI_CHG_APILIST);
        }

        return rc;
}

The same applies for detaching BTW, as you will wnat to destroy private data
on the last detach.

The usual beahviour for the Attach and Detach funtions of the extension
itself is to pass through the returncode BTW, so the application also knows
if it was the first attach, which might be useful sometimes.

That is: For attach/Detach, negative returncodes indicate an error, positive
are o.k.

> > Do I anything wrong?

Apart from not reading the in source docs: no.

CU, ANdy

-- 
= Andreas Beck                    |  Email :  <[EMAIL PROTECTED]>        =

Reply via email to