# adiGetContextInfo

Retrieves configuration information about a specified context.

#### Supported board types

- AG

- CG

#### Prototype

DWORD adiGetContextInfo ( CTAHD ctahd, ADI_CONTEXT_INFO *info, unsigned size)

Argument | Description
ctahd | Context handle returned by ctaCreateContext or ctaAttachContext.
info | Pointer to a buffer to receive the information. The ADI_CONTEXT_INFO structure is shown: typedef struct { /* User accessible CONTEXT INFO structure:*/ DWORD size; /* returned size of this structure */ DWORD queueid; /* not used */ DWORD userid; /* not used */ INT32 agliberr; /* last error code after calling AGLIB */ DWORD channel; /* AG Channel */ DWORD board; /* AG Board number */ DWORD stream; /* MVIP stream of this port */ DWORD timeslot; /* MVIP slot of this port */ DWORD mode; /* MVIP mode of operation of this port */ DWORD maxbufsize; /* maximum board buffer size */ char tcpname[12]; /* Current Protocol */ DWORD state; /* port state */ DWORD stream95; /* MVIP-95 base stream number */ } ADI_CONTEXT_INFO; Refer to the Details section for a description of these fields.
size | Amount of memory available at info, which must be large enough to receive the ADI_CONTEXT_INFO size return value.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | info is NULL.
CTAERR_BAD_SIZE | size is smaller than the size of DWORD.
CTAERR_INVALID_CTAHD | Context handle is invalid.
CTAERR_SVR_COMM | Server communication error.

#### Details

Use adiGetContextInfo to return information about the current state of a specified context.

Up to size bytes of the ADI_CONTEXT_INFO structure are copied to the address at info. If size is greater than or equal to sizeof (ADI_CONTEXT_INFO), the complete structure is copied. The number of bytes actually copied is returned in the ADI_CONTEXT_INFO size field.

Note: If you are using the Natural Call Control service, adiGetContextInfo does not fill in the tcpname field of the ADI_CONTEXT_INFO structure. To retrieve this information, the application must call nccGetLineStatusInfo.

The following table summarizes the ADI_CONTEXT_INFO structure. Many of these context characteristics are described in other functions, as noted:

Field | Description | Related functions
--- | --- | ---
size | Returned size. | N/A
queueid | Not used. | N/A
userid | Not used. | N/A
agliberr | Reserved for internal use. | N/A
channel | Reserved for internal use. | N/A
board | Board number on which the context's DSP resides. | ctaCreateContext
stream | Base MVIP stream for the context. | ctaCreateContext
timeslot | Context's MVIP-90 timeslot. | ctaCreateContext
mode | Context's MVIP mode. | ctaCreateContext
maxbufsize | Board physical buffer size. | adiGetEncodingInfo
tcpname | Protocol executing on the context. | adiStartProtocol
state | Context state. | N/A
stream95 | Base MVIP-95 stream. | N/A

#### Example

int myShowContextState( CTAHD ctahd )
{
ADI_CONTEXT_INFO info;
if( adiGetContextInfo( ctahd, &info, sizeof info ) != SUCCESS )
return MYFAILURE;
printf( " Queue ID = %d\n", info.queueid );
printf( " User ID = %08Xh\n", info.userid );
printf( " AG Channel = %08Xh\n", info.channel );
printf( "Last AGLIB Error = %d \n", info.agliberr );
printf( " AG Buffer Size = %d\n", info.maxbufsize );
printf( " Protocol = %s\n", info.tcpname );
printf( " Board Number = %d\n", info.board );
printf( "Stream:Slot,Mode = %d:%d,", info.stream, info.timeslot );
switch( info.mode )
{
case ADI_FULL_DUPLEX : puts("ADI_FULL_DUPLEX" ); break;
case ADI_VOICE_DUPLEX : puts("ADI_VOICE_DUPLEX" ); break;
case ADI_SIGNAL_DUPLEX : puts("ADI_SIGNAL_DUPLEX" ); break;
default:
if( info.mode & ADI_VOICE_INPUT ) printf( "+ADI_VOICE_INPUT" );
if( info.mode & ADI_VOICE_OUTPUT ) printf( "+ADI_VOICE_OUTPUT" );
if( info.mode & ADI_SIGNAL_INPUT ) printf( "+ADI_SIGNAL_INPUT" );
if( info.mode & ADI_SIGNAL_OUTPUT) printf( "+ADI_SIGNAL_OUTPUT");
printf( "\n" );
break;
}
printf("\n");
return SUCCESS;
}