
Description | Cautions | Example | Errors | See Also
Name: |
int cc_SetUsrAttr(linedev, usrattr) | |
Inputs: |
LINEDEV linedev |
|
long usrattr |
| |
Returns: |
0 on success | |
Includes: |
cclib.h | |
Category: |
System tools | |
Mode: |
synchronous | |
Technology: |
BRI/2; BRI/SC; PRI | |
The cc_SetUsrAttr( ) function sets the user attribute for a line device for later retrieval. The user attribute value can be a memory pointer used to identify a board and a channel on a board. The value can also be a pointer to a user-defined structure such as the current state or the active call reference number.
For example, the application can use the first two digits to identify a board and the last two digits to identify a channel on a board, with a '0' inserted between the numbers to separate them. The number '12024' would indicate the 24th channel on board 12.
Parameter |
Description |
linedev: |
The line device handle. |
usrattr: |
The user-defined attribute. Applications can recall this number by calling the cc_GetUsrAttr( ) function. |
None
#include <windows.h> /* For Windows applications only */
#include <stdio.h>
#include <errno.h>
#include "srllib.h"
#include "dtilib.h"
#include "cclib.h"
main()
{
int chan = 1;
char devname[16];
.
.
.
.
if ( sr_enbhdlr( devhdl, CCEV_DISCONNECTED, discCallHdlr ) < 0 )
{
printf( "dtiEnable for DISCONNECT failed: %s\n",
ATDV_ERRMSGP( SRL_DEVICE ) );
return( 1 );
}
printf(devname,"dtiB1T%d",chan);
if ( cc_Open(&devhdl, devname, 0) < 0 )
{
printf("Error opening device: errno = %d\n", errno);
exit(1);
}
if ( cc_SetUsrAttr(devhdl, chan))
procdevfail(devhdl);
.
.
.
.
while (1)
{
/* wait for network event */
sr_waitcvt(-1);
}
cc_Close(devhdl);
}
/***************************************************/
/* discCallHdlr - disconnect the active call */
/***************************************************/
int discCallHdlr( )
{
int devindx;
int dev;
int len;
void *datap;
CRN crn;
long chan;
dev = sr_getevtdev();
len = sr_getevtlen();
datap = sr_getevtdatap();
cc_GetCRN(&crn, datap);
if ( cc_GetUsrAttr(dev,&chan))
procdevfail(dev);
else
printf("Call disconnected at chan %ld\n",chan);
if ( cc_DropCall(crn, NORMAL_CLEARING, EV_ASYNC) < 0 )
procdevfail(dev);
return( 0 );
}
int callfail(CRN crn)
{
LINEDEV ld;
cc_CRN2LineDev(crn,&ld);
procdevfail(ld);
}
int procdevfail(LINEDEV handle)
{
int reason;
char *msg;
reason = cc_CauseValue(handle);
cc_ResultMsg(handle, reason, &msg);
printf(""reason = %x - %s\n"",reason,msg);
}
If the function returns < 0 to indicate failure, use the cc_CauseValue( ) function to retrieve the reason code for the failure. The cc_ResultMsg( ) function can be used to interpret the reason code. Error codes are defined in the files ccerr.h, isdnerr.h, and isdncmd.h.
Typically, a < 0 return code for the cc_SetUsrAttr( ) function indicates that the function reference (the device handle) is not valid for the function call.
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation