Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

Process initialization

The following tasks should be performed by an IRAPI program when execution starts:

  1. Register the process with the system with the irRegister(3IRAPI) function. This function must be passed a unique process name. Upon successful completion, a message queue key is returned.

    For example, the chantest.c application uses the irRegister(3IRAPI) function as follows:

    if ((qid=irRegister("chantest")) < 0) {
    irPError ("Error on irRegister");
    exit (1);
    }

  2. Allocate and initialize per-channel process data. Multi-channel IRAPI applications may use the irNumChans(3IRAPI) function to get the number of channels configured in the system and allocate per-channel data structures accordingly.

    As chantest.c is a multi-channel application, it uses irNumChans(3IRAPI) to obtain the number of channels in the system and allocates a CHLDATA data structure for each channel. By allocating one data structure for every channel in the system, it can be assigned to handle any or all channels simultaneously:

    if (initData(irNumChans(IRD_REAL)) < 0) {
    printf("Initialization failed\\\n");
    exit(1);
    }

    The following code shows the chantest's initData() routine:

    /* Global variables */
    struct CHLDATA {
    int State;
    int RetryCount;
    int PlayDone;
    ir_event_t InputDoneEvent;
    } *Chl;

    int initData(int nchans)
    {
    if(nchans <= 0) return(-1);
    if((Chl = (struct CHLDATA *)calloc(nchans,
    sizeof(struct CHLDATA))) == 0)
    {
    return(-1);
    }
    return(0);
    }

© 2006 Avaya Inc. All Rights Reserved.