# ctaSetEventSources

Provides a list of services from which the specified context receives events.

#### Prototype

DWORD ctaSetEventSources ( CTAHD ctahd, char *svcname, unsigned nsvcs)

Argument | Description
ctahd | Context handle.
svcname | Pointer to an array containing a list of services from which the application receives events.
nsvcs | Number of services in the svcname list.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | Invalid svcname was specified.
CTAERR_INVALID_CTAHD | An invalid context handle was passed as an argument to a function, or the context was destroyed by another thread.
CTAERR_NOT_IMPLEMENTED | Function is not available in the execution mode associated with the specified context.
CTAERR_NOT_INITIALIZED | Natural Access is not initialized. Call ctaInitialize first.
CTAERR_SVR_COMM | Server communication error.

#### Details

ctaSetEventSources specifies the types of events Natural Access sends to an event queue associated with a shared context. Each client application that uses the shared context can keep its own list of services. Natural Access sends to the event queue only events corresponding to entries in the svcname list.

Note: By default, if a context is created in Declared Access mode, applications that attach to it receive service events only for services they explicitly open (even if other services are opened by other client applications). If a context is created in Common Access mode, all applications that attach to it receive events for all service instances opened on the context.

The specified svcname list can include service instances not yet opened on the shared context. Reset the event mask by invoking ctaSetEventSources again and specifying a different svcname list.

Applications can retrieve the current list of svcnames in the existing event mask by invoking ctaGetEventSources.

Refer to Receiving events on event queues for more information.

#### See also

ctaAttachContext, ctaCreateContextEx

#### Example

case PAIR('S', 'M' ): /* Set Event Mask */
{
char *svcarr[MAX_SERVICES];
int nsvcs;
if (!Ioffline)
printf("Enter list of services to mask; Press Enter to end list\n")
nsvcs = PromptForStrings("Enter service name", svcarr,
MAX_SVC_NAME_LEN);
ret = ctaSetEventSources(ctahd, svcname, nsvcs);
for ( ; nsvcs >= 0; nsvcs--)
{
free(svcarr[nsvcs]);
} break;
}