Intel 05-1832-002 IP Phone User Manual


 
386 Voice API for Windows Operating Systems Library Reference — November 2003
dx_sethook( ) — provide control of the hook switch status
/* take the channel off-hook */
if (
dx_sethook(chdev,DX_OFFHOOK,EV_SYNC)
== -1) {
/* error setting hook state */
}
.
.
}
!
!!
! Example 2
This example illustrates how to use dx_sethook( ) in asynchronous mode.
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
#define MAXCHAN 24
int sethook_hdlr();
main()
{
int i, chdev[MAXCHAN];
char *chnamep;
int srlmode;
/* Set SRL to run in polled mode. */
srlmode = SR_POLLMODE;
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&srlmode) == -1) {
/* process error */
}
for (i=0; i<MAXCHAN; i++) {
/* Set chnamep to the channel name - e.g, dxxxB1C1, dxxxB1C2,... */
/* open a channel with chdev[i] as descriptor */
if ((chdev[i] = dx_open(chnamep,NULL)) == -1) {
/* process error */
}
/* Using sr_enbhdlr(), set up handler function to handle sethook
* events on this channel.
*/
if (sr_enbhdlr(chdev[i], TDX_SETHOOK, sethook_hdlr) == -1) {
/* process error */
}
/* put the channel on-hook */
if
(dx_sethook(chdev[i],DX_ONHOOK,EV_ASYNC) ==
-1) {
/* error setting hook state */
}
}
/* Use sr_waitevt() to wait for the completion of dx_sethook().
* On receiving the completion event, TDX_SETHOOK, control is transferred
* to the handler function previously established using sr_enbhdlr().
*/
.
.
}
int sethook_hdlr()
{
DX_CST *cstp;