first previous next last contents

The Callback Function

The callback function must be of the following prototype:

void function(
        GapIO     *io,
        int        contig,
        void      *fdata,
        reg_data  *jdata);

Here fdata will be the client_data specified when registering. The first task within our callback function will be to cast this to a useful type. As the type of this fdata will change depending on what piece of data is registered this is a required, but tedious, action.

The next task at hand is to see exactly why the callback function was called. This is listed in the reg_data parameter. Specifically jdata->job will be one of the many notification types. The suggested coding method is to perform a switch on this field as follows:

static void some_callback(GapIO *io, int contig, void *fdata, reg_data *jdata)
    some_type_t *s = (some_type_t *)fdata;

    switch(jdata->job) {
    case REG_QUERY_NAME:
        sprintf(jdata->name.line, "Some name");

    case REG_QUIT:
    case REG_DELETE:

REG_QUERY_NAME, REG_QUIT, REG_DELETE and REG_PARAMS are required to be accepted by all registered items.

In general the callback function will also be interested in changes to the contig that the data is registered with. These involve the REG_JOIN_TO, REG_COMPLEMENT, REG_LENGTH, REG_NUMBER_CHANGE and REG_ANNO requests.

For precise details on handling the various notifications, please see the following section.

first previous next last contents
This page is maintained by staden-package. Last generated on 1 March 2001.