home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
makcl.exe
/
MAKECALL.C
< prev
Wrap
C/C++ Source or Header
|
1994-10-24
|
7KB
|
239 lines
/****************************************************************************
** File: MAKECALL.C
**
** Desc: Sample telephony program
**
** This NetWare Telephony Services program opens a stream,
** makes a call, and closes the stream.
**
** This program is written for Borland C 4.0 for Windows 3.1. It
** is compiled as an EASYWIN program, so that I didn't have to
** include all the Windows "overhead" code but can just get to
** the good stuff.
**
**
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** KVW Kevin V White Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 07-21-94 kvw First code.
** 07-22-94 kvw Added disclaimer
** 09-16-94 kvw Changed acsCloseStream() to acsAbortStream
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <string.h>
/*------------------------------------------------------------------------
** Windows
*/
#include <windows.h>
/*------------------------------------------------------------------------
** Telephony
*/
#include <acs.h>
#include <csta.h>
/****************************************************************************
** This function is the entire program, as it is very simple.
** Prompt user for input, open a stream, make a call, close the stream.
*/
void main(void)
{
/*------------------------------------------------------------------
** The following are defined for the first call, acsOpenStream
*/
ACSHandle_t acsHandle;
InvokeIDType_t invokeIDType;
InvokeID_t invokeID;
StreamType_t streamType;
ServerID_t serverID;
LoginID_t loginID;
Passwd_t passwd;
AppName_t applicationName;
Level_t acsLevelReq;
Version_t apiVer;
unsigned short sendQSize;
unsigned short sendExtraBufs;
unsigned short recvQSize;
unsigned short recvExtraBufs;
PrivateData_t *privateData;
RetCode_t rCode;
/*------------------------------------------------------------------
** The following are additional variables necessary for
** acsGetEventBlock
*/
CSTAEvent_t eventBuffer;
unsigned short eventBufferSize;
unsigned short numEvents;
/*------------------------------------------------------------------
** The following are for the cstaMakeCall
*/
DeviceID_t caller,callee;
/*------------------------------------------------------------------
** Miscellaneous variables
*/
short done=0;
/*------------------------------------------------------------------
** Setup parameters for call to open stream. Also, prompt user for
** input.
*/
invokeIDType=LIB_GEN_ID;
invokeID=0; /* don't need it, but set to zero anyway */
streamType=ST_CSTA; /* want to use csta functions */
strcpy(serverID,"ATT#G3_SWITCH#CSTA#KVWHITETEL");
printf("\nEnter your user name:");
scanf("%s",loginID);
printf("\nEnter your password:");
scanf("%s",passwd);
printf("\nEnter your extension:");
scanf("%s",caller);
printf("\nEnter the extension you want to call:");
scanf("%s",callee);
strcpy(applicationName,"Simple App");
acsLevelReq=ACS_LEVEL1;
strcpy(apiVer,CSTA_API_VERSION);
sendQSize=0; /* default size queue*/
sendExtraBufs=0; /* use default number */
recvQSize=0; /* use default size */
recvExtraBufs=0; /* use default number */
privateData=NULL; /* no private data */
/*------------------------------------------------------------------
** Open the stream with above parameters
*/
rCode=acsOpenStream(&acsHandle,invokeIDType,invokeID,streamType,
&serverID,&loginID,&passwd,&applicationName,acsLevelReq,
&apiVer,sendQSize,sendExtraBufs,recvQSize,recvExtraBufs,
privateData);
if (rCode < 0)
{
printf("acsOpenStream failure...");
return;
}
else
{
printf("acsOpenStream success\n");
invokeID=rCode;
}
/*------------------------------------------------------------------
** Block until the confirmation has been received that the stream
** was successfully opened. Just because NetWare returned the function
** code doesn't mean the stream has been opened yet.
*/
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(acsHandle,&eventBuffer,&eventBufferSize,
privateData,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType == ACS_OPEN_STREAM_CONF)
{
printf("ACS_OPEN_STREAM_CONF message has been received\n");
}
else
{
printf("event type is incorrect...");
return;
}
}
else
{
printf("acsGetEventBlock failure...");
return;
}
/*------------------------------------------------------------------
** Now that the stream has been successfully opened, go ahead and
** issue the make call function.
*/
rCode=cstaMakeCall(acsHandle,invokeID,&caller,&callee,
privateData);
/*------------------------------------------------------------------
** Now we need to poll for events until a confirmation has been
** received that the PBX has been able to make the call. Note that
** if something is invalid, the program will enter an infinite loop,
** as this simple program just sits and waits until a confirmation
** returns that is successful.
*/
while (!done)
{
rCode=acsGetEventPoll(acsHandle,&eventBuffer,&eventBufferSize,
privateData,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType == CSTA_MAKE_CALL_CONF)
{
printf("CSTA_MAKE_CALL_CONF message has been received\n");
done=1;
}
else
{
printf("event type is incorrect...");
}
}
}
/*------------------------------------------------------------------
** All done! Time to close the stream now.
*/
rCode=acsAbortStream(acsHandle,privateData);
if (rCode < 0)
{
printf("acsAbortStream failure...");
return;
}
else
{
printf("acsAbortStream success\n");
}
return;
}