- Services are opened on a CTA context by calling ctaOpenServices, passing a CTA context handle and a list of service descriptors. The service descriptor specifies the name of the service, service manager, and service-specific arguments (e.g., MVIP address).
- The NFX service must be opened on a CTA context in order to use NaturalFax's library of C functions. The NaturalFax (NFX) service does not require any service-specific arguments.
- The Fax Manager service (FXM) service provides the hardware interface for the NaturalFax service. When opening the FXM service, the board, MVIP address, and mode are specified. When sending or receiving a fax, the NFX service will use the hardware resources (board and port) specified by the FXM service opened on the same CTA context.
- In order to place and receive calls, the ADI service must be opened. The ADI service is opened with service-specific arguments such as AG board, MVIP address, and mode.
- The following code excerpt demonstrates creating the CTA context and opening the NFX, FXM, and ADI services.
static DWORD create_context (CTAQUEUEHD queue,
DWORD board,
DWORD stream,
DWORD timeslot,
DWORD closure,
char * contextname,
CTAHD * contextptr)
{
DWORD status;
CTA_SERVICE_DESC services [3];
DWORD service_count = 0;
CTA_EVENT event;
status = ctaCreateContext (queue, closure, contextname, contextptr);
if (status != SUCCESS)
{
show_error (NULL_CTAHD, status, "CT Access context creation failed");
return status;
}
/*
* Now that we have a valid CT Access context, we can use ctaGetText
* to get proper error messages.
*/
memset (& services, 0, sizeof services);
services[service_count].name.svcname = "ADI";
services[service_count].name.svcmgrname = "ADIMGR";
services[service_count].mvipaddr.board = board;
services[service_count].mvipaddr.stream = stream;
services[service_count].mvipaddr.timeslot = timeslot;
services[service_count].mvipaddr.mode = ADI_FULL_DUPLEX;
service_count += 1;
services[service_count].name.svcname = "FXM";
services[service_count].name.svcmgrname = "ADIMGR";
services[service_count].mvipaddr.board = board;
services[service_count].mvipaddr.stream = stream;
services[service_count].mvipaddr.timeslot = timeslot;
services[service_count].mvipaddr.mode = ADI_FULL_DUPLEX;
service_count += 1;
services[service_count].name.svcname = "NFX";
services[service_count].name.svcmgrname = "NFXMGR";
services[service_count].mvipaddr.board = board;
services[service_count].mvipaddr.stream = stream;
services[service_count].mvipaddr.timeslot = timeslot;
services[service_count].mvipaddr.mode = ADI_FULL_DUPLEX;
service_count += 1;
status = ctaOpenServices (* contextptr, services, service_count);
if (status != SUCCESS)
{
show_error (* contextptr, status, "open services failed");
return status;
}
/* Now we need to wait for the CTAEVN_OPEN_SERVICES_DONE event. */
status = wait_event (queue, * contextptr, CTAEVN_OPEN_SERVICES_DONE,
NULL, 0, & event);
if (status != SUCCESS)
{
show_error (* contextptr, status, "open services failed");
return status;
}
else if (event.value != CTA_REASON_FINISHED)
{
show_error (* contextptr, event.value, "open services done event");
return event.value;
}
else
return SUCCESS;
}