# ctaSetGlobalTraceMask

Sets the global trace mask.

#### Prototype

DWORD ctaSetGlobalTraceMask ( CTAHD ctahd, unsigned tracemask)

Argument | Description
ctahd | Context handle for the server on which the global trace mask is changed. ctahd can be a void context handle.
tracemask | The new global trace mask.

#### Returned Values

Return value | Description
SUCCESS |
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

ctaSetGlobalTraceMask sets the global trace mask for the Natural Access Server (ctdaemon) specified by ctahd. CTA_TRACEMASK macros accepted by ctaSetTraceLevel can be used for the tracemask argument.

#### See also

ctaSetTraceLevel

#### Example

int DemoRemoteTrace(CTAQUEUEHD ctaqueuehd, CTAHD ctahd)
{
DWORD ret;
/* Start tracing */
ret = ctaStartTrace(ctahd);
if ( ret != SUCCESS )
return ret;
/* Set tracemask on server */
ret = ctaSetGlobalTraceMask(ctahd,CTA_TRACEMASK_ALL_COMMANDS);
if ( ret != SUCCESS )
return ret;
for (;!kbhit();)
{
// Retrieve an event from the event queue.
CTA_EVENT cta_event;
ret = ctaWaitEvent( ctaqueuehd, &cta_event, 1000 );
// Check if buffer is owned by Natual Access and must be freed by
// us below.
bool const bCtaOwnsBuf = (cta_event.buffer != NULL &&
(cta_event.size & CTA_INTERNAL_BUFFER));
if (bCtaOwnsBuf)
{
cta_event.size &= ~CTA_INTERNAL_BUFFER;
// clear flag from size
}
if (cta_event.id == CTAEVN_TRACE_MESSAGE)
// if it's a trace event
{
if (!cta_event.buffer)
{
continue;
}
const char * const pszText = (char*)cta_event.buffer;
printf( "%s", pszText );
}
if (bCtaOwnsBuf)
{
ctaFreeBuffer( cta_event.buffer );
// our reponsibility to free
}
}
/* Stop tracing */
ret = ctaStopTrace( ctahd );
if ( ret != SUCCESS )
return ret;
return SUCCESS;
}