ctaStopTrace

Stops tracing on a remote server.

Prototype

DWORD ctaStopTrace ( CTAHD ctahd)

Argument

Description

ctahd

Context handle for the server on which tracing is stopped. ctahd cannot be a void context handle because void contexts do not have queues.


Return 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_INITIALIZED

Natural Access is not initialized. Call ctaInitialize first.

CTAERR_SVR_COMM

Server communication error.


Details

After an application initiates a call to ctaStopTrace, the server specified by ctahd no longer receives trace messages.

See also

ctaSetGlobalTraceMask, ctaStartTrace

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;
          
}