8. Application Guidelines
351
Reference and the Voice Software Reference - Standard Runtime Library for the
appropriate operating system for more information.
8.2.1. Handling Errors
Each Dialogic ISDN API library function returns a value < 0 on failure. Be sure to
check any call to a Dialogic ISDN API library function for a return value that
indicates an error. The following code samples demonstrate how to handle errors
done in asynchronous and synchronous modes.
Asynchronous Mode
sr_waitevt(-1);
code = sr_getevttype( );
if (code&DT_CC) == DT_CC) { /* comments */
switch(code) {
case CCEV_DISCONNECTED:
cc_ResultValue( );
break;
}
}
Synchronous Mode
char *msg;
if (cc_XXX(ldev) == CC_ERROR) {
error = cc_CauseValue(ldev);
error = cc_ResultMsg(ldev, &msg);
printf(“error msg = %s\n”, msg);
}
8.2.2. Handling Events
When an event occurs, the application may use sr_getevttype( ) to retrieve the
event type. For example:
switch (sr_getevttype()) {
case CCEV_OFFERED:
.
.
.
case CCEV_CONNECTED:
.
.