diff --git a/C20LIB/DOS/CAPI20L.LIB b/C20LIB/DOS/CAPI20L.LIB new file mode 100644 index 0000000..0e2c097 Binary files /dev/null and b/C20LIB/DOS/CAPI20L.LIB differ diff --git a/C20LIB/DOS/CAPI20LD.LIB b/C20LIB/DOS/CAPI20LD.LIB new file mode 100644 index 0000000..d4429bc Binary files /dev/null and b/C20LIB/DOS/CAPI20LD.LIB differ diff --git a/C20LIB/DOS/CAPI20S.LIB b/C20LIB/DOS/CAPI20S.LIB new file mode 100644 index 0000000..41c4bf4 Binary files /dev/null and b/C20LIB/DOS/CAPI20S.LIB differ diff --git a/C20LIB/DOS/CAPI20SD.LIB b/C20LIB/DOS/CAPI20SD.LIB new file mode 100644 index 0000000..0161327 Binary files /dev/null and b/C20LIB/DOS/CAPI20SD.LIB differ diff --git a/C20LIB/LINUX.MAK b/C20LIB/LINUX.MAK new file mode 100644 index 0000000..e8fcb7f --- /dev/null +++ b/C20LIB/LINUX.MAK @@ -0,0 +1,19 @@ + +vpath %.c source + +CFLAGS := $(CFLAGS) -DTARGET_32BIT -DCPROT -DCPROT_LINUX -g -Wall + +CFILES=clinux.c func.c msg.c gcmsglin.c + +OFILES=$(patsubst %.c,linux/%.o,$(CFILES)) + +LIB=linux/libc20.a + +all: $(LIB) + +$(LIB): $(OFILES) + $(RM) $@ + $(AR) cq $@ $^ + +linux/%.o: %.c + $(CC) $(CFLAGS) -c $^ -o $@ diff --git a/C20LIB/LINUX/LIBC20.A b/C20LIB/LINUX/LIBC20.A new file mode 100644 index 0000000..585d79f Binary files /dev/null and b/C20LIB/LINUX/LIBC20.A differ diff --git a/C20LIB/MKDOS.BAT b/C20LIB/MKDOS.BAT new file mode 100644 index 0000000..3766747 --- /dev/null +++ b/C20LIB/MKDOS.BAT @@ -0,0 +1,39 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 Development Kit +@rem library with the Microsoft Visual C compiler for a DOS +@rem environment. +@rem +@rem This makefile expects as first parameter a letter that specifies +@rem the memory model to compile with, for example L (large model), +@rem S (small model). +@rem If as second parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ +@if "%1" == "" goto NoMemoryModel +@if "%2" == "dbg" goto dbg +@ +@ set cl=/c /Zl /A%1 /W4 /Isource /nologo /DTARGET_16BIT + cl source\func.c source\msg.c source\gcmsgdos.c source\cdos.c + del dos\capi20%1.lib +@ lib /NOLOGO dos\capi20%1.lib; + lib /NOLOGO dos\capi20%1.lib +msg+cdos+func+gcmsgdos; + del *.obj + del dos\*.bak +@ goto ende +@ +:dbg +@ +@ set cl=/c /Zl /A%1 /W4 /Isource /nologo /DTARGET_16BIT /DCPROT + cl source\func.c source\msg.c source\gcmsgdos.c source\cdos.c + del dos\capi20%1d.lib +@ lib /NOLOGO dos\capi20%1d.lib; + lib /NOLOGO dos\capi20%1d.lib +msg+cdos+func+gcmsgdos; + del *.obj + del dos\*.bak +@ goto ende +@ +:NoMemoryModel +@echo No memory model specified !! +@ +:ende diff --git a/C20LIB/MKNW.BAT b/C20LIB/MKNW.BAT new file mode 100644 index 0000000..f637b34 --- /dev/null +++ b/C20LIB/MKNW.BAT @@ -0,0 +1,33 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 AVM Development Kit +@rem library with the WATCOM CPP 10.5 C compiler for a 32 bit +@rem NetWare environment. +@rem We assume that the Environment variable WATCOM contains the Install +@rem directory of your Watcom C Compiler (e.g. C:\wc105) +@rem +@rem If as parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ set COMP=%WATCOM%\BINW\wcc386 +@ +@if "%1" == "dbg" goto dbg +@ set wcc386=/d1 /s /3s /oi /zq /wx /DB1 /DAVM /DTARGET_32BIT /DNDEBUG /DCPROT /Isource +@ set LIBNAME=cap2032.lib +@ goto compile +:dbg +@ set wcc386=/d2 /s /3s /oid /zq /wx /DB1 /DAVM /DTARGET_32BIT /DDEBUG /DCPROT /Isource +@ set LIBNAME=cap2032d.lib +@ goto compile + +:compile + %COMP% /bt=netware /fonetware\func.obj source\func.c + %COMP% /bt=netware /fonetware\msg.obj source\msg.c + %COMP% /bt=netware /fonetware\gcmsg_nw.obj source\gcmsg_nw.c + %COMP% /bt=netware /fonetware\c_nw.obj source\c_nw.c + + del netware\%LIBNAME% + %WATCOM%\BINW\wlib netware\%LIBNAME% +netware\msg +netware\c_nw +netware\func +netware\gcmsg_nw + del netware\*.obj +@ goto ende +@ +:ende diff --git a/C20LIB/MKOS2.CMD b/C20LIB/MKOS2.CMD new file mode 100644 index 0000000..d85d007 --- /dev/null +++ b/C20LIB/MKOS2.CMD @@ -0,0 +1,28 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 Development Kit +@rem library with the IBM VisualAge C++ compiler for a 32 bit +@rem OS/2 environment. +@rem +@rem If as parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ +@if "%1" == "dbg" goto dbg +@ +@ set icc=/C+ /Isource /DTARGET_32BIT + icc source\func.c source\msg.c source\gcmsgos2.c source\cos2.c + if exist os2\capi20.lib del os2\capi20.lib + ilib /nobrowse os2\capi20.lib msg.obj cos2.obj func.obj gcmsgos2.obj os2\capi20i.lib; + del *.obj +@ goto end +@ +:dbg +@ +@ set icc=/C+ /Isource /DTARGET_32BIT /DCPROT + icc source\func.c source\msg.c source\gcmsgos2.c source\cos2.c + if exist os2\capi20d.lib del os2\capi20d.lib + ilib /nobrowse os2\capi20d.lib msg.obj cos2.obj func.obj gcmsgos2.obj os2\capi20i.lib; + del *.obj +@ goto end +@ +:end diff --git a/C20LIB/MKVXD.BAT b/C20LIB/MKVXD.BAT new file mode 100644 index 0000000..e55b60e --- /dev/null +++ b/C20LIB/MKVXD.BAT @@ -0,0 +1,29 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 Development Kit +@rem library with the Microsoft Visual C compiler for a 32 bit +@rem VxD driver environment. You have to run this with a installed +@rem Win95 DDK (%DDKROOT%). +@rem +@rem If as parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ +@if "%1" == "dbg" goto dbg +@ +@ set cl=/Zdp /Gs /DIS_32 /Zl /c /W3 /Isource /I%DDKROOT%\INC32 /nologo /DTARGET_32BIT + cl source\func.c source\msg.c source\gcmsgvxd.c source\cvxd.c + del vxd\capi20.clb + lib /OUT:vxd\capi20.clb msg.obj cvxd.obj func.obj gcmsgvxd.obj + del *.obj +@ goto ende +@ +:dbg +@ +@ set cl=/Zdp /Gs /DIS_32 /Zl /c /W3 /Isource /I%DDKROOT%\INC32 /nologo /DTARGET_32BIT /DCPROT + cl source\func.c source\msg.c source\gcmsgvxd.c source\cvxd.c + del vxd\capi20d.clb + lib /OUT:vxd\capi20d.clb msg.obj cvxd.obj func.obj gcmsgvxd.obj + del *.obj +@ goto ende +@ +:ende diff --git a/C20LIB/MKWIN16.BAT b/C20LIB/MKWIN16.BAT new file mode 100644 index 0000000..68c3d8a --- /dev/null +++ b/C20LIB/MKWIN16.BAT @@ -0,0 +1,39 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 Development Kit +@rem library with the Microsoft Visual C compiler for a 16 bit +@rem Windows environment. +@rem +@rem This makefile expects as first parameter a letter that specifies +@rem the memory model to compile with, for example L (large model), +@rem S (small model). +@rem If as second parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ +@if "%1" == "" goto NoMemoryModel +@if "%2" == "dbg" goto dbg +@ +@ set cl=/c /GA /A%1 /W4 /Isource /nologo /DTARGET_16BIT + cl source\func.c source\msg.c source\gcmsgwin.c source\cwin16.c + del win16\capi20%1.lib +@ lib /NOLOGO win16\capi20%1.lib; + lib /NOLOGO win16\capi20%1.lib +msg+cwin16+func+gcmsgwin+win16\capi20w.lib; + del *.obj + del win16\*.bak +@ goto ende +@ +:dbg +@ +@ set cl=/c /GA /A%1 /W4 /Isource /nologo /DTARGET_16BIT /DCPROT + cl source\func.c source\msg.c source\gcmsgwin.c source\cwin16.c + del win16\capi20%1d.lib +@ lib /NOLOGO win16\capi20%1d.lib; + lib /NOLOGO win16\capi20%1d.lib +msg+cwin16+func+gcmsgwin+win16\capi20w.lib; + del *.obj + del win16\*.bak +@ goto ende +@ +:NoMemoryModel +@echo No memory model specified !! +@ +:ende diff --git a/C20LIB/MKWIN32.BAT b/C20LIB/MKWIN32.BAT new file mode 100644 index 0000000..9072e0d --- /dev/null +++ b/C20LIB/MKWIN32.BAT @@ -0,0 +1,28 @@ +@rem +@rem This is a demo makefile for making the CAPI 2.0 Development Kit +@rem library with the Microsoft Visual C compiler for a 32 bit +@rem Windows environment. +@rem +@rem If as parameter dbg is given, the symbol CPROT is defined +@rem and the library will be build including the protocol functions +@ +@ +@if "%1" == "dbg" goto dbg +@ +@ set cl=/c /Zl /W3 /Isource /nologo /DTARGET_32BIT + cl source\func.c source\msg.c source\gcmsgwin.c source\cwin32.c + del win32\cap2032.lib + lib /OUT:win32\cap2032.lib msg.obj cwin32.obj func.obj gcmsgwin.obj win32\capi2032.lib + del *.obj +@ goto ende +@ +:dbg +@ +@ set cl=/c /Zl /W3 /Isource /nologo /DTARGET_32BIT /DCPROT + cl source\func.c source\msg.c source\gcmsgwin.c source\cwin32.c + del win32\cap2032d.lib + lib /OUT:win32\cap2032d.lib msg.obj cwin32.obj func.obj gcmsgwin.obj win32\capi2032.lib + del *.obj +@ goto ende +@ +:ende diff --git a/C20LIB/NETWARE/CAP2032.LIB b/C20LIB/NETWARE/CAP2032.LIB new file mode 100644 index 0000000..a811ea4 Binary files /dev/null and b/C20LIB/NETWARE/CAP2032.LIB differ diff --git a/C20LIB/NETWARE/CAP2032D.LIB b/C20LIB/NETWARE/CAP2032D.LIB new file mode 100644 index 0000000..c4459ee Binary files /dev/null and b/C20LIB/NETWARE/CAP2032D.LIB differ diff --git a/C20LIB/OS2/CAPI20.LIB b/C20LIB/OS2/CAPI20.LIB new file mode 100644 index 0000000..7453436 Binary files /dev/null and b/C20LIB/OS2/CAPI20.LIB differ diff --git a/C20LIB/OS2/CAPI20D.LIB b/C20LIB/OS2/CAPI20D.LIB new file mode 100644 index 0000000..67fa8fa Binary files /dev/null and b/C20LIB/OS2/CAPI20D.LIB differ diff --git a/C20LIB/OS2/CAPI20I.LIB b/C20LIB/OS2/CAPI20I.LIB new file mode 100644 index 0000000..06af701 Binary files /dev/null and b/C20LIB/OS2/CAPI20I.LIB differ diff --git a/C20LIB/SOURCE/C2IMP_NW.H b/C20LIB/SOURCE/C2IMP_NW.H new file mode 100644 index 0000000..abcb30c --- /dev/null +++ b/C20LIB/SOURCE/C2IMP_NW.H @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + + C2IMP_NW.H Version 1.0 1998 AVM + + CAPI 2.0 Development Kit NetWare + + This file contains the NetWare specific import symbols for CAPI 2.0. +\*---------------------------------------------------------------------------*/ +#ifndef c2imp_nw_inc +#define c2imp_nw_inc +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#define IMPORT _cdecl +/*---------------------------------------------------------------------------*\ + external symbols for CAPI20 functions +\*---------------------------------------------------------------------------*/ +extern DWORD IMPORT CAPI_Register (WORD, WORD, WORD, WORD, WORD*, WORD, DWORD, DWORD); +extern DWORD IMPORT CAPI_Release (WORD ); +extern DWORD IMPORT CAPI_PutMessage (WORD, BYTE* ); +extern DWORD IMPORT CAPI_GetMessage (WORD, BYTE** ); +extern DWORD IMPORT CAPI_GetManufacturer (DWORD, BYTE* ); +extern DWORD IMPORT CAPI_GetVersion (DWORD, WORD*, WORD*, WORD*, WORD*, WORD*, WORD*); +extern DWORD IMPORT CAPI_GetSerialNumber (DWORD, BYTE* ); +extern DWORD IMPORT CAPI_GetProfile (void*, DWORD ); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif diff --git a/C20LIB/SOURCE/C2MGR_NW.H b/C20LIB/SOURCE/C2MGR_NW.H new file mode 100644 index 0000000..c3de409 --- /dev/null +++ b/C20LIB/SOURCE/C2MGR_NW.H @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + + C2MGR_NW.H Version 1.0 1998 AVM + + CAPI 2.0 Development Kit internal definitions for NetWare + +\*---------------------------------------------------------------------------*/ +#ifndef _C2MGR_NW_H_ /* avoid multiple inclusion */ +#define _C2MGR_NW_H_ + +/* -------------------------------------------------- + signal type constants for application registration + -------------------------------------------------- */ +#define SIGNAL_TYPE_LOCAL_SEMAPHORE 0x0001 +#define SIGNAL_TYPE_CALLBACK 0x0002 + +/* --------------------------------------------------- + additional CAPI Manager specific CAPI info values + --------------------------------------------------- */ +#define CRE_INVALID_SIGNAL_TYPE 0x10F0 +#define CRE_INVALID_FUNCTION_ARRAY 0x10F1 +#define CRE_INVALID_CONTROLLER_INFO 0x10F2 + +#define CME_INVALID_CONTROLLER 0x11F0 +#define CME_INVALID_CONTROLLER_INFO 0x11F1 +#define CME_NO_MATCHING_CONTROLLER 0x11F2 +#define CME_LOCK_FAILED 0x11F3 +#define CME_INVALID_LOCK_HANDLE 0x11F4 + +#define CSE_CTLR_NOT_RESPONDING 0x3F01 + +/* ----------------------------------------- + CAPI Manager specific messages extensions + ----------------------------------------- */ +#define MANUFACTURER_ID_NWCAPI 0x4D43574E /* NWCM */ + +#define NW_CAPI_EXTENSION 0x00F0 +#define BIND_APPL 0x0010 +#define UNBIND_APPL 0x0011 +#define CTLR_UNLOAD 0x0012 +#define CTLR_FAILURE 0x0013 + +#define INFO_MASK_CTLR_UNLOAD 0x0080 +#define INFO_MASK_CTLR_FAILURE 0x0100 +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif /* _C2MGR_NW_H_ */ diff --git a/C20LIB/SOURCE/CAPI20.H b/C20LIB/SOURCE/CAPI20.H new file mode 100644 index 0000000..39ad907 --- /dev/null +++ b/C20LIB/SOURCE/CAPI20.H @@ -0,0 +1,973 @@ +/*--------------------------------------------------------------------------*\ + + CAPI20.H Version 1.2 1997 AVM + + Header file of CAPI20.LIB + type definitions, CAPI functions, parameter definitions + see CAPI 2.0 spec. february 1994 + +\*--------------------------------------------------------------------------*/ +#ifndef _capi20_h_ +#define _capi20_h_ + +#ifdef __cplusplus +extern "C" { +#endif + + +#if defined (TARGET_32BIT) +# define __far +#endif + + +/*----- basic-type definitions -----*/ + +typedef unsigned char __far *CAPI_MESSAGE; +typedef unsigned char _cbyte; +typedef unsigned short _cword; +typedef unsigned long _cdword; +typedef CAPI_MESSAGE _cstruct; +typedef enum { + CAPI_COMPOSE, + CAPI_DEFAULT +} _cmstruct; + +/*----- errornumbers -----*/ + +typedef enum { + CapiToManyAppls =0x1001, + CapiLogBlkSizeToSmall =0x1002, + CapiBuffExeceeds64k =0x1003, + CapiMsgBufSizeToSmall =0x1004, + CapiAnzLogConnNotSupported =0x1005, + CapiRegReserved =0x1006, + CapiRegBusy =0x1007, + CapiRegOSResourceErr =0x1008, + CapiRegNotInstalled =0x1009, + CapiRegCtrlerNotSupportExtEquip =0x100a, + CapiRegCtrlerOnlySupportExtEquip =0x100b +} CAPI_REGISTER_ERROR; + +typedef enum { + CapiNoError =0x0000, + CapiIllAppNr =0x1101, + CapiIllCmdOrSubcmdOrMsgToSmall =0x1102, + CapiSendQueueFull =0x1103, + CapiReceiveQueueEmpty =0x1104, + CapiReceiveOverflow =0x1105, + CapiUnknownNotPar =0x1106, + CapiMsgBusy =0x1107, + CapiMsgOSResourceErr =0x1108, + CapiMsgNotInstalled =0x1109, + CapiMsgCtrlerNotSupportExtEquip =0x110a, + CapiMsgCtrlerOnlySupportExtEquip =0x110b +} MESSAGE_EXCHANGE_ERROR; + +/*----- CAPI commands -----*/ + +#define CAPI_ALERT 0x01 +#define CAPI_CONNECT 0x02 +#define CAPI_CONNECT_ACTIVE 0x03 +#define CAPI_CONNECT_B3_ACTIVE 0x83 +#define CAPI_CONNECT_B3 0x82 +#define CAPI_CONNECT_B3_T90_ACTIVE 0x88 +#define CAPI_DATA_B3 0x86 +#define CAPI_DISCONNECT_B3 0x84 +#define CAPI_DISCONNECT 0x04 +#define CAPI_FACILITY 0x80 +#define CAPI_INFO 0x08 +#define CAPI_LISTEN 0x05 +#define CAPI_MANUFACTURER 0xff +#define CAPI_RESET_B3 0x87 +#define CAPI_SELECT_B_PROTOCOL 0x41 + +/*----- CAPI subcommands -----*/ + +#define CAPI_REQ 0x80 +#define CAPI_CONF 0x81 +#define CAPI_IND 0x82 +#define CAPI_RESP 0x83 + +/*--------------------------------------------------------------------------*\ + The _cmsg structure contains all possible CAPI 2.0 parameter. + All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE + assembles the parameter and builds CAPI2.0 conform messages. + CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the + parameter in the _cmsg structure +\*--------------------------------------------------------------------------*/ + +typedef struct { + /* Header */ + _cword ApplId; + _cbyte Command; + _cbyte Subcommand; + _cword Messagenumber; + + /* Parameter */ + union { + _cdword adrController; + _cdword adrPLCI; + _cdword adrNCCI; + } adr; + + _cmstruct AdditionalInfo; + _cstruct B1configuration; + _cword B1protocol; + _cstruct B2configuration; + _cword B2protocol; + _cstruct B3configuration; + _cword B3protocol; + _cstruct BC; + _cstruct BChannelinformation; + _cmstruct BProtocol; + _cstruct CalledPartyNumber; + _cstruct CalledPartySubaddress; + _cstruct CallingPartyNumber; + _cstruct CallingPartySubaddress; + _cdword CIPmask; + _cdword CIPmask2; + _cword CIPValue; + _cdword Class; + _cstruct ConnectedNumber; + _cstruct ConnectedSubaddress; + _cdword Data; + _cword DataHandle; + _cword DataLength; + _cstruct FacilityConfirmationParameter; + _cstruct Facilitydataarray; + _cstruct FacilityIndicationParameter; + _cstruct FacilityRequestParameter; + _cstruct FacilityResponseParameters; + _cword FacilitySelector; + _cword Flags; + _cdword Function; + _cstruct HLC; + _cword Info; + _cstruct InfoElement; + _cdword InfoMask; + _cword InfoNumber; + _cstruct Keypadfacility; + _cstruct LLC; + _cstruct ManuData; + _cdword ManuID; + _cstruct NCPI; + _cword Reason; + _cword Reason_B3; + _cword Reject; + _cstruct Useruserdata; + + /* intern */ + unsigned l,p; + unsigned char *par; + CAPI_MESSAGE m; +} _cmsg; + +/*--------------------------------------------------------------------------*\ + CAPI_CMSG_2_MESSAGE assembles the parameter from _cmsg to a CAPI 2.0 + conform message +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_CMSG_2_MESSAGE (_cmsg __far *cmsg, CAPI_MESSAGE msg); + +/*--------------------------------------------------------------------------*\ + CAPI_MESSAGE_2_CMSG disassembles a CAPI message an writes the parameter + into _cmsg for easy access +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_MESSAGE_2_CMSG (_cmsg __far *cmsg, CAPI_MESSAGE msg); + +/*--------------------------------------------------------------------------*\ + CAPI_PUT_CMSG works like CAPI_PUT_MESSAGE but it converts the _cmsg + first with CAPI_CMSG_2_MESSAGE. Possible errors from CAPI_PUT_MESSAGE + will be returned. +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg); + +/*--------------------------------------------------------------------------*\ + CAPI_GET_CMSG works like CAPI_GET_MESSAGE and converts the CAPI message + to a _cmsg with CAPI_MESSAGE_2_CMSG. Possible errors from CAPI_GET_MESSAGE + will be returned. +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid); + +/*--------------------------------------------------------------------------*\ + CAPI_CMSG_HEADER fills the _cmsg structure with default values, so only + parameter with non default values must be changed before sending the + message. +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_CMSG_HEADER (_cmsg __far *cmsg, _cword _ApplId, _cbyte _Command, _cbyte _Subcommand, _cword _Messagenumber, _cdword _Controller); + +/*--------------------------------------------------------------------------*\ + CAPI_CMSG_ANSWER is used to answer indications. It changes the header + of an indication to a response, and leaves all other parameters the same +\*--------------------------------------------------------------------------*/ +unsigned __far CAPI_CMSG_ANSWER (_cmsg __far *cmsg); + +/*----- if the symbol CPROT is defined, protocol functions are included -----*/ + +#if defined (CPROT) +typedef enum { + CAPI_PROTOCOL_HEADER, /*----- occurs only once when CAPI_PROTOCOL_INIT is executed -----*/ + CAPI_PROTOCOL_MSG, /*----- the protocol-output is a CAPI Message -----*/ + CAPI_PROTOCOL_TXT, /*----- the output is text caused by CAPI_PROTOCOL_TEXT -----*/ +} CAPI_PROTOCOL_TYP; + +#define CAPI_PROTOCOL_INIT_BUF_SIZE (9*1024) + +/*--------------------------------------------------------------------------*\ + CAPI_PROTOCOL_INIT wants as first parameter a buffer with the size + CAPI_PROTOCOL_INIT_BUF_SIZE. The second parameter is the address of + a callback function with 3 parameter which is called whenever there is + protocoltext to give out. The callback functions parameters are a pointer + to the (ASCII) message, the type of the message and a pointer to the CAPI + Message if the type is CAPI_PROTOCOL_MSG. +\*--------------------------------------------------------------------------*/ +void __far CAPI_PROTOCOL_INIT (char *_buf, void (*_signal)(char *, CAPI_PROTOCOL_TYP, CAPI_MESSAGE)); + +/*--------------------------------------------------------------------------*\ + CAPI_PROTOCOL_MESSAGE prints the specified CAPI message on the protocol +\*--------------------------------------------------------------------------*/ +void __far CAPI_PROTOCOL_MESSAGE (CAPI_MESSAGE msg); + +/*--------------------------------------------------------------------------*\ + CAPI_PROTOCOL_TEXT prints the specified text on the protocol. + It has the same syntax as printf +\*--------------------------------------------------------------------------*/ +void __far CAPI_PROTOCOL_TEXT (char *fmt, ...); +#endif + +/*----- defines to access specific parameter -----*/ + +#define ALERT_REQ_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define ALERT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional info elements */ +#define ALERT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define ALERT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define ALERT_REQ_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define ALERT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define ALERT_CONF_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define ALERT_CONF_INFO(x) ((x)->Info) + /* 0: alert initiated */ + /* 0x0003: alert already sent by another application */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal PLCI */ + /* 0x2007: illegal message parameter coding */ +#define CONNECT_REQ_CONTROLLER(x) ((x)->adr.adrController) +#define CONNECT_REQ_CIPVALUE(x) ((x)->CIPValue) + /* Compatibility Information Profile */ +#define CONNECT_REQ_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber) + /* Called party number */ +#define CONNECT_REQ_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber) + /* Calling party number */ +#define CONNECT_REQ_CALLEDPARTYSUBADDRESS(x) ((x)->CalledPartySubaddress) + /* Called party subaddress */ +#define CONNECT_REQ_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress) + /* Calling party subaddress */ +#define CONNECT_REQ_BPROTOCOL(x) ((x)->BProtocol) + /* B protocol to be used */ +#define CONNECT_REQ_B1PROTOCOL(x) ((x)->B1protocol) + /* Physical layer and framing */ +#define CONNECT_REQ_B2PROTOCOL(x) ((x)->B2protocol) + /* Data link layer */ +#define CONNECT_REQ_B3PROTOCOL(x) ((x)->B3protocol) + /* Network layer */ +#define CONNECT_REQ_B1CONFIGURATION(x) ((x)->B1configuration) + /* Physical layer and framing parameter */ +#define CONNECT_REQ_B2CONFIGURATION(x) ((x)->B2configuration) + /* Data link layer parameter */ +#define CONNECT_REQ_B3CONFIGURATION(x) ((x)->B3configuration) + /* Network layer parameter */ +#define CONNECT_REQ_BC(x) ((x)->BC) + /* Bearer Capability */ +#define CONNECT_REQ_LLC(x) ((x)->LLC) + /* Low Layer Compatibility */ +#define CONNECT_REQ_HLC(x) ((x)->HLC) + /* High Layer Compatibility */ +#define CONNECT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional information elements */ +#define CONNECT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define CONNECT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_REQ_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define CONNECT_CONF_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_CONF_INFO(x) ((x)->Info) + /* 0: connect initiated */ + /* 0x2002: illegal controller */ + /* 0x2003: out of PLCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x3001: B1 protocol not supported */ + /* 0x3002: B2 protocol not supported */ + /* 0x3003: B3 protocol not supported */ + /* 0x3004: B1 protocol parameter not supported */ + /* 0x3005: B2 protocol parameter not supported */ + /* 0x3006: B3 protocol parameter not supported */ + /* 0x3007: B protocol combination not supported */ + /* 0x300A: CIP Value unknown */ +#define CONNECT_IND_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_IND_CIPVALUE(x) ((x)->CIPValue) + /* Compatibility Information Profile */ +#define CONNECT_IND_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber) + /* Called party number */ +#define CONNECT_IND_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber) + /* Calling party number */ +#define CONNECT_IND_CALLEDPARTYSUBADDRESS(x) ((x)->CalledPartySubaddress) + /* Called party subaddress */ +#define CONNECT_IND_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress) + /* Calling party subaddress */ +#define CONNECT_IND_BC(x) ((x)->BC) + /* Bearer compatibility */ +#define CONNECT_IND_LLC(x) ((x)->LLC) + /* Low Layer Compatibility */ +#define CONNECT_IND_HLC(x) ((x)->HLC) + /* High Layer Compatibility */ +#define CONNECT_IND_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional information elements */ +#define CONNECT_IND_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define CONNECT_IND_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_IND_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_IND_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define CONNECT_RESP_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_RESP_REJECT(x) ((x)->Reject) + /* 0: accept call */ + /* 1: ignore call */ + /* 2: reject call, normal call clearing */ + /* 3: reject call, user busy */ + /* 4: reject call, requestet circuit/channel not available */ + /* 5: reject call, facility rejected */ + /* 6: reject call, channel unacceptable */ + /* 7: reject call, incompatible destination */ + /* 8: reject call, destination out of order */ +#define CONNECT_RESP_BPROTOCOL(x) ((x)->BProtocol) + /* B protocol to be used */ +#define CONNECT_RESP_B1PROTOCOL(x) ((x)->B1protocol) + /* Physical layer and framing */ +#define CONNECT_RESP_B2PROTOCOL(x) ((x)->B2protocol) + /* Data link layer */ +#define CONNECT_RESP_B3PROTOCOL(x) ((x)->B3protocol) + /* Network layer */ +#define CONNECT_RESP_B1CONFIGURATION(x) ((x)->B1configuration) + /* Physical layer and framing parameter */ +#define CONNECT_RESP_B2CONFIGURATION(x) ((x)->B2configuration) + /* Data link layer parameter */ +#define CONNECT_RESP_B3CONFIGURATION(x) ((x)->B3configuration) + /* Network layer parameter */ +#define CONNECT_RESP_CONNECTEDNUMBER(x) ((x)->ConnectedNumber) + /* Connected number */ +#define CONNECT_RESP_CONNECTEDSUBADDRESS(x) ((x)->ConnectedSubaddress) + /* Connected subaddress */ +#define CONNECT_RESP_LLC(x) ((x)->LLC) + /* Low Layer Compatibility */ +#define CONNECT_RESP_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional information elements */ +#define CONNECT_RESP_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define CONNECT_RESP_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_RESP_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define CONNECT_RESP_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define CONNECT_ACTIVE_IND_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_ACTIVE_IND_CONNECTEDNUMBER(x) ((x)->ConnectedNumber) + /* Connected number */ +#define CONNECT_ACTIVE_IND_CONNECTEDSUBADDRESS(x) ((x)->ConnectedSubaddress) + /* Connected subaddress */ +#define CONNECT_ACTIVE_IND_LLC(x) ((x)->LLC) + /* Low Layer Compatibility */ +#define CONNECT_ACTIVE_RESP_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_B3_ACTIVE_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_ACTIVE_IND_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define CONNECT_B3_ACTIVE_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_REQ_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define CONNECT_B3_REQ_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define CONNECT_B3_CONF_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_CONF_INFO(x) ((x)->Info) + /* 0: connect initiated */ + /* 0x0001: NCPI not supported by current protocol, NCPI ignored */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal PLCI */ + /* 0x2004: out of NCCI */ + /* 0x3008: NCPI not supported */ +#define CONNECT_B3_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_IND_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define CONNECT_B3_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_RESP_REJECT(x) ((x)->Reject) + /* 0: accept call */ + /* 2: reject call, normal call clearing */ +#define CONNECT_B3_RESP_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define CONNECT_B3_T90_ACTIVE_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define CONNECT_B3_T90_ACTIVE_IND_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define CONNECT_B3_T90_ACTIVE_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DATA_B3_REQ_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DATA_B3_REQ_DATA(x) ((x)->Data) + /* Pointer to the data to be sent */ +#define DATA_B3_REQ_DATALENGTH(x) ((x)->DataLength) + /* Size of data area to be sent */ +#define DATA_B3_REQ_DATAHANDLE(x) ((x)->DataHandle) + /* Referenced in DATA_B3_CONF */ +#define DATA_B3_REQ_FLAGS(x) ((x)->Flags) + /* [0]: qualifier bit */ + /* [1]: more data bit */ + /* [2]: delivery confirmation bit */ + /* [3]: expedited data */ + /* [4] to [15]: reserved */ +#define DATA_B3_CONF_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DATA_B3_CONF_DATAHANDLE(x) ((x)->DataHandle) + /* Identifies the data area of corresponding DATA_B3_REQ */ +#define DATA_B3_CONF_INFO(x) ((x)->Info) + /* 0: data transmission initiated */ + /* 0x0002: flags not supported by current protocol, flags ignored */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal NCCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x300A: flags not supported (reserved bits) */ + /* 0x300C: data length not supported by current protocol */ +#define DATA_B3_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DATA_B3_IND_DATA(x) ((x)->Data) + /* Pointer to data received */ +#define DATA_B3_IND_DATALENGTH(x) ((x)->DataLength) + /* Size of data area received */ +#define DATA_B3_IND_DATAHANDLE(x) ((x)->DataHandle) + /* handle to data area, referenced in DATA_B3_RESP */ +#define DATA_B3_IND_FLAGS(x) ((x)->Flags) + /* 0: qualifier bit */ + /* 1: more-data bit */ + /* 2: delivery confirmation bit */ + /* 3: expedited data */ + /* 4 to 14: reserved */ + /* [15]: framing error bit, data may be invalid (only with corresponding B2 protocol) */ +#define DATA_B3_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DATA_B3_RESP_DATAHANDLE(x) ((x)->DataHandle) + /* Data area reference in corresponding DATA_B3_IND */ +#define DISCONNECT_B3_REQ_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DISCONNECT_B3_REQ_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define DISCONNECT_B3_CONF_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DISCONNECT_B3_CONF_INFO(x) ((x)->Info) + /* 0: disconnect initiated */ + /* 0x0001: NCPI not supported by current protocol, NCPI ignored */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal NCCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x3008: NCPI not supported */ +#define DISCONNECT_B3_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DISCONNECT_B3_IND_REASON_B3(x) ((x)->Reason_B3) + /* 0: clearing according to protocol */ + /* 0x3301: protocol error layer 1 */ + /* 0x3302: protocol error layer 2 */ + /* 0x3303: protocol error layer 3 */ + /* protocol dependent values are described in chapter 6 */ +#define DISCONNECT_B3_IND_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define DISCONNECT_B3_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define DISCONNECT_REQ_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define DISCONNECT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional information elements */ +#define DISCONNECT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define DISCONNECT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define DISCONNECT_REQ_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define DISCONNECT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define DISCONNECT_CONF_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define DISCONNECT_CONF_INFO(x) ((x)->Info) + /* 0: disconnect initiated */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal PLCI */ + /* 0x2007: illegal message parameter coding */ +#define DISCONNECT_IND_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define DISCONNECT_IND_REASON(x) ((x)->Reason) + /* 0: no cause available */ + /* 0x3301: protocol error layer 1 */ + /* 0x3302: protocol error layer 2 */ + /* 0x3303: protocol error layer 3 */ + /* 0x3304: another application got that call */ + /* 0x34xx: disconnect cause from the network according to Q.931/ETS 300 102-1. In the field 'xx' the cause value received within a cause information element (octet 4) from the network is indicated. */ +#define DISCONNECT_RESP_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define FACILITY_REQ_CONTROLLER(x) ((x)->adr.adrController) +#define FACILITY_REQ_PLCI(x) ((x)->adr.adrPLCI) +#define FACILITY_REQ_NCCI(x) ((x)->adr.adrNCCI) + /* Depending on the facility selector */ +#define FACILITY_REQ_FACILITYSELECTOR(x) ((x)->FacilitySelector) + /* 0: Handset Support */ + /* 1: DTMF */ + /* 2 to n: reserved */ +#define FACILITY_REQ_FACILITYREQUESTPARAMETER(x) ((x)->FacilityRequestParameter) + /* Facility depending parameters */ +#define FACILITY_CONF_CONTROLLER(x) ((x)->adr.adrController) +#define FACILITY_CONF_PLCI(x) ((x)->adr.adrPLCI) +#define FACILITY_CONF_NCCI(x) ((x)->adr.adrNCCI) + /* Depending on the facility selector */ +#define FACILITY_CONF_INFO(x) ((x)->Info) + /* 0: request accepted */ + /* 0x2001: message not supported in current state */ + /* 0x2002: incorrect Controller/PLCI/NCCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x300B: facility not supported */ +#define FACILITY_CONF_FACILITYSELECTOR(x) ((x)->FacilitySelector) + /* 0: Handset Support */ + /* 1: DTMF */ + /* 2 to n: reserved */ +#define FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(x) ((x)->FacilityConfirmationParameter) + /* Facility-depending parameters */ +#define FACILITY_IND_CONTROLLER(x) ((x)->adr.adrController) +#define FACILITY_IND_PLCI(x) ((x)->adr.adrPLCI) +#define FACILITY_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Depending on the facility selector */ +#define FACILITY_IND_FACILITYSELECTOR(x) ((x)->FacilitySelector) + /* 0: Handset Support */ + /* 1: DTMF */ + /* 2 to n: reserved */ +#define FACILITY_IND_FACILITYINDICATIONPARAMETER(x) ((x)->FacilityIndicationParameter) + /* Facility-depending parameters */ +#define FACILITY_RESP_CONTROLLER(x) ((x)->adr.adrController) +#define FACILITY_RESP_PLCI(x) ((x)->adr.adrPLCI) +#define FACILITY_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Depending on the facility selector */ +#define FACILITY_RESP_FACILITYSELECTOR(x) ((x)->FacilitySelector) + /* 0: Handset Support */ + /* 1: DTMF */ + /* 2 to n: reserved */ +#define FACILITY_RESP_FACILITYRESPONSEPARAMETERS(x) ((x)->FacilityResponseParameters) + /* Facility-depending parameters */ +#define INFO_REQ_CONTROLLER(x) ((x)->adr.adrController) +#define INFO_REQ_PLCI(x) ((x)->adr.adrPLCI) + /* See note */ +#define INFO_REQ_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber) + /* Called party number */ +#define INFO_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo) + /* Additional information elements */ +#define INFO_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation) +#define INFO_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility) + /* coded according to ETS 300 102-1 / Q.931 */ +#define INFO_REQ_USERUSERDATA(x) ((x)->Useruserdata) + /* coded according to ETS 300 102-1 / Q.931 */ +#define INFO_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray) + /* which is used to transfer additional parameters coded */ + /* according to ETS 300 102-1 / Q.931 starting from octet 1. */ + /* This field is used to transport one or more complete facility */ + /* data information elements. */ +#define INFO_CONF_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define INFO_CONF_INFO(x) ((x)->Info) + /* 0: transmission of information initiated */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal Controller/PLCI */ + /* 0x2003: out of PLCI */ + /* 0x2007: illegal message parameter coding */ +#define INFO_IND_CONTROLLER(x) ((x)->adr.adrController) +#define INFO_IND_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define INFO_IND_INFONUMBER(x) ((x)->InfoNumber) + /* Information element identifier */ +#define INFO_IND_INFOELEMENT(x) ((x)->InfoElement) + /* Information element dependent structure */ +#define INFO_RESP_CONTROLLER(x) ((x)->adr.adrController) +#define INFO_RESP_PLCI(x) ((x)->adr.adrPLCI) + /* As in INFO_IND */ +#define LISTEN_REQ_CONTROLLER(x) ((x)->adr.adrController) +#define LISTEN_REQ_INFOMASK(x) ((x)->InfoMask) + /* Bit field, coding as follows: */ + /* 0: cause */ + /* 1: date/Time */ + /* 2: display */ + /* 3: user-user information */ + /* 4: call progression */ + /* 5: facility */ + /* 6: charging */ + /* 7 to 31: reserved */ +#define LISTEN_REQ_CIPMASK(x) ((x)->CIPmask) + /* Bit field, coding as follows: */ + /* 0: any match */ + /* 1: speech */ + /* 2: unrestricted digital information */ + /* 3: restricted digital information */ + /* 4: 3.1 kHz audio */ + /* 5: 7.0 kHz audio */ + /* 6: video */ + /* 7: packet mode */ + /* 8: 56 kBit/s rate adaptation */ + /* 9: unrestricted digital information with tones/announcements */ + /* 10..15: reserved */ + /* 16: telephony */ + /* 17: fax group 2/3 */ + /* 18: fax group 4 class 1 */ + /* 19: Teletex service (basic and mixed), fax group 4 class 2 */ + /* 20: Teletex service (basic and processable) */ + /* 21: Teletex service (basic) */ + /* 22: Videotex */ + /* 23: Telex */ + /* reserved for additional services */ + /* 25: OSI applications according X.200 */ + /* 26: 7 kHz Telephony */ + /* 27: Video Telephony F.721, first connection */ + /* 28: Video Telephony F.721, second connection */ + /* 29 to 31: reserved */ +#define LISTEN_REQ_CIPMASK2(x) ((x)->CIPmask2) + /* reserved for additional services */ +#define LISTEN_REQ_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber) + /* Calling party number */ +#define LISTEN_REQ_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress) + /* Calling party subaddress */ +#define LISTEN_CONF_CONTROLLER(x) ((x)->adr.adrController) +#define LISTEN_CONF_INFO(x) ((x)->Info) + /* 0: listen is active */ + /* 0x2002: illegal controller */ + /* 0x2005: out of LISTEN-Resources */ + /* 0x2007: illegal message parameter coding */ +#define MANUFACTURER_REQ_CONTROLLER(x) ((x)->adr.adrController) +#define MANUFACTURER_REQ_MANUID(x) ((x)->ManuID) + /* Manufacturer specific ID (should be unique) */ + /* Manufacturer specific */ +#define MANUFACTURER_REQ_CLASS(x) ((x)->Class) +#define MANUFACTURER_REQ_FUNCTION(x) ((x)->Function) +#define MANUFACTURER_REQ_MANUDATA(x) ((x)->ManuData) + /* Manufacturer specific data */ +#define MANUFACTURER_CONF_CONTROLLER(x) ((x)->adr.adrController) +#define MANUFACTURER_CONF_MANUID(x) ((x)->ManuID) + /* Manufacturer specific ID (should be unique) */ + /* Manufacturer specific */ +#define MANUFACTURER_CONF_CLASS(x) ((x)->Class) +#define MANUFACTURER_CONF_FUNCTION(x) ((x)->Function) +#define MANUFACTURER_CONF_MANUDATA(x) ((x)->ManuData) + /* Manufacturer specific data */ +#define MANUFACTURER_IND_CONTROLLER(x) ((x)->adr.adrController) +#define MANUFACTURER_IND_MANUID(x) ((x)->ManuID) + /* Manufacturer specific ID (should be unique) */ + /* Manufacturer specific */ +#define MANUFACTURER_IND_CLASS(x) ((x)->Class) +#define MANUFACTURER_IND_FUNCTION(x) ((x)->Function) +#define MANUFACTURER_IND_MANUDATA(x) ((x)->ManuData) + /* Manufacturer specific data */ +#define MANUFACTURER_RESP_CONTROLLER(x) ((x)->adr.adrController) +#define MANUFACTURER_RESP_MANUID(x) ((x)->ManuID) + /* Manufacturer specific ID (should be unique) */ + /* Manufacturer specific */ +#define MANUFACTURER_RESP_CLASS(x) ((x)->Class) +#define MANUFACTURER_RESP_FUNCTION(x) ((x)->Function) +#define MANUFACTURER_RESP_MANUDATA(x) ((x)->ManuData) + /* Manufacturer specific data */ +#define RESET_B3_REQ_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define RESET_B3_REQ_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define RESET_B3_CONF_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define RESET_B3_CONF_INFO(x) ((x)->Info) + /* 0: reset initiated */ + /* 0x0001: NCPI not supported by current protocol, NCPI ignored */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal NCCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x3008: NCPI not supported */ + /* 0x300D: reset procedure not supported by current protocol */ +#define RESET_B3_IND_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define RESET_B3_IND_NCPI(x) ((x)->NCPI) + /* Network Control Protocol Information */ +#define RESET_B3_RESP_NCCI(x) ((x)->adr.adrNCCI) + /* Network Control Connection Identifier */ +#define SELECT_B_PROTOCOL_REQ_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define SELECT_B_PROTOCOL_REQ_BPROTOCOL(x) ((x)->BProtocol) + /* Protocol definition */ +#define SELECT_B_PROTOCOL_REQ_B1PROTOCOL(x) ((x)->B1protocol) + /* Physical layer and framing */ +#define SELECT_B_PROTOCOL_REQ_B2PROTOCOL(x) ((x)->B2protocol) + /* Data link layer */ +#define SELECT_B_PROTOCOL_REQ_B3PROTOCOL(x) ((x)->B3protocol) + /* Network layer */ +#define SELECT_B_PROTOCOL_REQ_B1CONFIGURATION(x) ((x)->B1configuration) + /* Physical layer and framing parameter */ +#define SELECT_B_PROTOCOL_REQ_B2CONFIGURATION(x) ((x)->B2configuration) + /* Data link layer parameter */ +#define SELECT_B_PROTOCOL_REQ_B3CONFIGURATION(x) ((x)->B3configuration) + /* Network layer parameter */ +#define SELECT_B_PROTOCOL_CONF_PLCI(x) ((x)->adr.adrPLCI) + /* Physical Link Connection Identifier */ +#define SELECT_B_PROTOCOL_CONF_INFO(x) ((x)->Info) + /* 0: protocol switch successful */ + /* 0x2001: message not supported in current state */ + /* 0x2002: illegal PLCI */ + /* 0x2007: illegal message parameter coding */ + /* 0x3001: B1 protocol not supported */ + /* 0x3002: B2 protocol not supported */ + /* 0x3003: B3 protocol not supported */ + /* 0x3004: B1 protocol parameter not supported */ + /* 0x3005: B2 protocol parameter not supported */ + /* 0x3006: B3 protocol parameter not supported */ + /* 0x3007: B protocol combination not supported */ + +/*----- tests for specific commands -----*/ + +#define IS_CONNECT_IND(m) ((m)->Command==0x02 && (m)->Subcommand==0x82) +#define IS_CONNECT_ACTIVE_IND(m) ((m)->Command==0x03 && (m)->Subcommand==0x82) +#define IS_CONNECT_B3_ACTIVE_IND(m) ((m)->Command==0x83 && (m)->Subcommand==0x82) +#define IS_CONNECT_B3_IND(m) ((m)->Command==0x82 && (m)->Subcommand==0x82) +#define IS_CONNECT_B3_T90_ACTIVE_IND(m) ((m)->Command==0x88 && (m)->Subcommand==0x82) +#define IS_DATA_B3_IND(m) ((m)->Command==0x86 && (m)->Subcommand==0x82) +#define IS_DISCONNECT_B3_IND(m) ((m)->Command==0x84 && (m)->Subcommand==0x82) +#define IS_DISCONNECT_IND(m) ((m)->Command==0x04 && (m)->Subcommand==0x82) +#define IS_FACILITY_IND(m) ((m)->Command==0x80 && (m)->Subcommand==0x82) +#define IS_INFO_IND(m) ((m)->Command==0x08 && (m)->Subcommand==0x82) +#define IS_MANUFACTURER_IND(m) ((m)->Command==0xff && (m)->Subcommand==0x82) +#define IS_RESET_B3_IND(m) ((m)->Command==0x87 && (m)->Subcommand==0x82) +#define IS_ALERT_CONF(m) ((m)->Command==0x01 && (m)->Subcommand==0x81) +#define IS_CONNECT_CONF(m) ((m)->Command==0x02 && (m)->Subcommand==0x81) +#define IS_CONNECT_B3_CONF(m) ((m)->Command==0x82 && (m)->Subcommand==0x81) +#define IS_DATA_B3_CONF(m) ((m)->Command==0x86 && (m)->Subcommand==0x81) +#define IS_DISCONNECT_B3_CONF(m) ((m)->Command==0x84 && (m)->Subcommand==0x81) +#define IS_DISCONNECT_CONF(m) ((m)->Command==0x04 && (m)->Subcommand==0x81) +#define IS_FACILITY_CONF(m) ((m)->Command==0x80 && (m)->Subcommand==0x81) +#define IS_INFO_CONF(m) ((m)->Command==0x08 && (m)->Subcommand==0x81) +#define IS_LISTEN_CONF(m) ((m)->Command==0x05 && (m)->Subcommand==0x81) +#define IS_MANUFACTURER_CONF(m) ((m)->Command==0xff && (m)->Subcommand==0x81) +#define IS_RESET_B3_CONF(m) ((m)->Command==0x87 && (m)->Subcommand==0x81) +#define IS_SELECT_B_PROTOCOL_CONF(m) ((m)->Command==0x41 && (m)->Subcommand==0x81) + +/*----- header functions that fill the _cmsg structure with default -----*/ +/*----- values. Only nonstandard parameter need to be changed -----*/ + +#define ALERT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x01,0x80,Messagenumber,adr) +#define CONNECT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x02,0x80,Messagenumber,adr) +#define CONNECT_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x82,0x80,Messagenumber,adr) +#define DATA_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x86,0x80,Messagenumber,adr) +#define DISCONNECT_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x84,0x80,Messagenumber,adr) +#define DISCONNECT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x04,0x80,Messagenumber,adr) +#define FACILITY_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x80,0x80,Messagenumber,adr) +#define INFO_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x08,0x80,Messagenumber,adr) +#define LISTEN_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x05,0x80,Messagenumber,adr) +#define MANUFACTURER_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0xff,0x80,Messagenumber,adr) +#define RESET_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x87,0x80,Messagenumber,adr) +#define SELECT_B_PROTOCOL_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x41,0x80,Messagenumber,adr) +#define CONNECT_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x02,0x83,Messagenumber,adr) +#define CONNECT_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x03,0x83,Messagenumber,adr) +#define CONNECT_B3_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x83,0x83,Messagenumber,adr) +#define CONNECT_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x82,0x83,Messagenumber,adr) +#define CONNECT_B3_T90_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x88,0x83,Messagenumber,adr) +#define DATA_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x86,0x83,Messagenumber,adr) +#define DISCONNECT_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x84,0x83,Messagenumber,adr) +#define DISCONNECT_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x04,0x83,Messagenumber,adr) +#define FACILITY_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x80,0x83,Messagenumber,adr) +#define INFO_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x08,0x83,Messagenumber,adr) +#define MANUFACTURER_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0xff,0x83,Messagenumber,adr) +#define RESET_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \ + CAPI_CMSG_HEADER(cmsg,ApplId,0x87,0x83,Messagenumber,adr) + +/*--------------------------------------------------------------------------*\ + CAPI-functions that correspond to the CAPI messages specified in the + CAPI 2.0 specification. All possible parameter have to be specified. + The CAPI message is sent immediately when calling these functions, + return values are the same as in CAPI_PUT_MESSAGE +\*--------------------------------------------------------------------------*/ + +unsigned ALERT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct BChannelinformation + ,_cstruct Keypadfacility + ,_cstruct Useruserdata + ,_cstruct Facilitydataarray); +unsigned CONNECT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword CIPValue + ,_cstruct CalledPartyNumber + ,_cstruct CallingPartyNumber + ,_cstruct CalledPartySubaddress + ,_cstruct CallingPartySubaddress + ,_cword B1protocol + ,_cword B2protocol + ,_cword B3protocol + ,_cstruct B1configuration + ,_cstruct B2configuration + ,_cstruct B3configuration + ,_cstruct BC + ,_cstruct LLC + ,_cstruct HLC + ,_cstruct BChannelinformation + ,_cstruct Keypadfacility + ,_cstruct Useruserdata + ,_cstruct Facilitydataarray); +unsigned CONNECT_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct NCPI); +unsigned DATA_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cdword Data + ,_cword DataLength + ,_cword DataHandle + ,_cword Flags); +unsigned DISCONNECT_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct NCPI); +unsigned DISCONNECT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct BChannelinformation + ,_cstruct Keypadfacility + ,_cstruct Useruserdata + ,_cstruct Facilitydataarray); +unsigned FACILITY_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword FacilitySelector + ,_cstruct FacilityRequestParameter); +unsigned INFO_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct CalledPartyNumber + ,_cstruct BChannelinformation + ,_cstruct Keypadfacility + ,_cstruct Useruserdata + ,_cstruct Facilitydataarray); +unsigned LISTEN_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cdword InfoMask + ,_cdword CIPmask + ,_cdword CIPmask2 + ,_cstruct CallingPartyNumber + ,_cstruct CallingPartySubaddress); +unsigned MANUFACTURER_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cdword ManuID + ,_cdword Class + ,_cdword Function + ,_cstruct ManuData); +unsigned RESET_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cstruct NCPI); +unsigned SELECT_B_PROTOCOL_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword B1protocol + ,_cword B2protocol + ,_cword B3protocol + ,_cstruct B1configuration + ,_cstruct B2configuration + ,_cstruct B3configuration); +unsigned CONNECT_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword Reject + ,_cword B1protocol + ,_cword B2protocol + ,_cword B3protocol + ,_cstruct B1configuration + ,_cstruct B2configuration + ,_cstruct B3configuration + ,_cstruct ConnectedNumber + ,_cstruct ConnectedSubaddress + ,_cstruct LLC + ,_cstruct BChannelinformation + ,_cstruct Keypadfacility + ,_cstruct Useruserdata + ,_cstruct Facilitydataarray); +unsigned CONNECT_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned CONNECT_B3_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned CONNECT_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword Reject + ,_cstruct NCPI); +unsigned CONNECT_B3_T90_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned DATA_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword DataHandle); +unsigned DISCONNECT_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned DISCONNECT_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned FACILITY_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cword FacilitySelector + ,_cstruct FacilityResponseParameters); +unsigned INFO_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); +unsigned MANUFACTURER_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr + ,_cdword ManuID + ,_cdword Class + ,_cdword Function + ,_cstruct ManuData); +unsigned RESET_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber + ,_cdword adr); + + +#ifdef __cplusplus +} +#endif + +#endif /*----- _capi20_h_ -----*/ diff --git a/C20LIB/SOURCE/CDOS.C b/C20LIB/SOURCE/CDOS.C new file mode 100644 index 0000000..1e3c26e --- /dev/null +++ b/C20LIB/SOURCE/CDOS.C @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + + CDOS.C Version 1.2 1997 AVM + + This file contains the source of the operating system specific + CAPI functions, here for DOS. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include +#include + +#include "capi20.h" + +#define CAPI_REGISTER_NR 0x01 +#define CAPI_RELEASE_NR 0x02 +#define CAPI_PUT_MESSAGE_NR 0x03 +#define CAPI_GET_MESSAGE_NR 0x04 +#define CAPI_SET_SIGNAL_NR 0x05 +#define CAPI_DEINSTALL_NR 0x06 +#define CAPI_GET_MANUFACTURER_NR 0xF0 +#define CAPI_GET_VERSION_NR 0xF1 +#define CAPI_GET_SERIAL_NUMBER_NR 0xF2 +#define CAPI_GET_PROFILE_NR 0xF3 +#define CAPI_MANUFACTURER_NR 0xFF + +static int TrapNumber = 0xF1; + +/*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + char __far *p = (char __far *) (long) _dos_getvect (TrapNumber); + return 0 == _fmemcmp (p+11, "CAPI20", 6); +} + +/*---------------------------------------------------------------------------*/ +void CAPI20_SET_TRAP (unsigned char Number) { + TrapNumber = Number; +} + +/*---------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (CAPI_MESSAGE Buffer, unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_REGISTER_NR; + + Regs.x.cx = MsgBufSize; + Regs.x.dx = MaxB3Connection; + Regs.x.si = MaxB3Blks; + Regs.x.di = MaxSizeB3; + + Regs.x.bx = _FP_OFF (Buffer); + Segs.es = _FP_SEG (Buffer); + + _int86x (TrapNumber, &Regs, &Regs, &Segs); + + *ErrorCode = (CAPI_REGISTER_ERROR) Regs.x.bx; + +#if defined (CPROT) + if (Regs.x.ax == 0x0000) + CAPI_PROTOCOL_TEXT ("CAPI_REGISTER error \n", Regs.x.bx); +#endif + + return (_cword) Regs.x.ax; +} + +/*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_RELEASE_NR; + + Regs.x.dx = Appl_Id; + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + +#if defined (CPROT) + if (Regs.x.ax != 0x0000) + CAPI_PROTOCOL_TEXT ("CAPI_RELEASE error 0x%04x\n", Regs.x.ax); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Regs.x.ax; +} + +/*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_PUT_MESSAGE_NR; + + Regs.x.dx = Appl_Id; + Regs.x.bx = _FP_OFF (Msg); + Segs.es = _FP_SEG (Msg); + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + +#if defined (CPROT) + if (Regs.x.ax == 0x0000) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Regs.x.ax); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Regs.x.ax; +} + +/*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE __far * ReturnMessage) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_GET_MESSAGE_NR; + + Regs.x.dx = Appl_Id; + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + + (*((unsigned __far *)&(*ReturnMessage))) = Regs.x.bx; + (*((unsigned __far *)&(*ReturnMessage) + 1)) = Segs.es; + +#if defined (CPROT) + if (Regs.x.ax == 0x0000) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Regs.x.ax != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Regs.x.ax); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Regs.x.ax; +} +/*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL (unsigned ApplId, void (__far * CallBack) (void), void __far *CallBackPar) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_SET_SIGNAL_NR; + + Regs.x.dx = ApplId; + Regs.x.di = _FP_OFF (CallBackPar); + Regs.x.si = _FP_SEG (CallBackPar); + + Regs.x.bx = _FP_OFF (CallBack); + Segs.es = _FP_SEG (CallBack); + + _int86x (TrapNumber, &Regs, &Regs, &Segs); + +#if defined (CPROT) + if (Regs.x.ax != 0x0000) + CAPI_PROTOCOL_TEXT ("CAPI_SET_SIGNAL error \n", Regs.x.ax); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Regs.x.ax; +} + +/*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_GET_MANUFACTURER_NR; + + Regs.x.bx = _FP_OFF (LpBuffer); + Segs.es = _FP_SEG (LpBuffer); + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + return LpBuffer; +} + +/*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_GET_VERSION_NR; + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + + version[0] = Regs.h.ah; + version[1] = Regs.h.al; + version[2] = Regs.h.dh; + version[3] = Regs.h.dl; + return version; +} + +/*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_GET_SERIAL_NUMBER_NR; + + Regs.x.bx = _FP_OFF (LpBuffer); + Segs.es = _FP_SEG (LpBuffer); + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + return LpBuffer; +} + +/*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + struct _SREGS Segs; + union _REGS Regs; + + Regs.h.ah = 20; + Regs.h.al = CAPI_GET_PROFILE_NR; + + Regs.x.cx = Controller; + Regs.x.bx = _FP_OFF (LpBuffer); + Segs.es = _FP_SEG (LpBuffer); + + _int86x(TrapNumber, &Regs, &Regs, &Segs); + +#if defined (CPROT) + if (Regs.x.ax != 0x0000) + CAPI_PROTOCOL_TEXT ("CAPI_GET_PROFILE error \n", Regs.x.ax); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Regs.x.ax; +} diff --git a/C20LIB/SOURCE/CDOS.H b/C20LIB/SOURCE/CDOS.H new file mode 100644 index 0000000..2627a57 --- /dev/null +++ b/C20LIB/SOURCE/CDOS.H @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------*\ + + CDOS.H Version 1.1 1995 AVM + + Operation system specific CAPI 2.0 functions for DOS + +\*--------------------------------------------------------------------------*/ +#ifndef _cdos_h_ +#define _cdos_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "capi20.h" + +unsigned CAPI20_ISINSTALLED (void); +void CAPI20_SET_TRAP (unsigned char Number); +_cword CAPI20_REGISTER (CAPI_MESSAGE Buffer, unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE __far * ReturnMessage); +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL (unsigned ApplId, void (__far * CallBack) (void), void __far *CallBackPar); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); + +#ifdef __cplusplus +} +#endif + +#endif /*----- _cdos_h_ -----*/ diff --git a/C20LIB/SOURCE/CLINUX.C b/C20LIB/SOURCE/CLINUX.C new file mode 100644 index 0000000..8b331a0 --- /dev/null +++ b/C20LIB/SOURCE/CLINUX.C @@ -0,0 +1,317 @@ +/*---------------------------------------------------------------------------*\ + + CLINUX.C Version 1.0 1997 AVM + + This file contains the source of the operating system specific + CAPI functions, here for LINUX user-mode applications. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "capi20.h" + + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static int capi_fd = -1; +static capi_ioctl_struct ioctl_data; +static unsigned char rcvbuf[128+2048]; /*----- message + data -----*/ +static unsigned char sndbuf[128+2048]; /*----- message + data -----*/ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) +{ + if (capi_fd >= 0) + return 1; + + /*----- open managment link -----*/ + if ((capi_fd = open("/dev/capi20", O_RDWR, 0666)) < 0) + return 0; + + return ioctl(capi_fd, CAPI_INSTALLED, 0) == 0; +} + +/*---------------------------------------------------------------------------*\ + managment of application ids +\*---------------------------------------------------------------------------*/ +static struct capi_applidmap { + int used; + int fd; +} capi_applidmap[CAPI_MAXAPPL] = {0}; + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static inline _cword allocapplid(int fd) +{ + _cword i; + for (i=0; i < CAPI_MAXAPPL; i++) { + if (capi_applidmap[i].used == 0) { + capi_applidmap[i].used = 1; + capi_applidmap[i].fd = fd; + return i+1; + } + } + return 0; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static inline void freeapplid(_cword applid) +{ + capi_applidmap[applid-1].used = 0; + capi_applidmap[applid-1].fd = -1; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static inline int validapplid(_cword applid) +{ + return applid > 0 && applid <= CAPI_MAXAPPL + && capi_applidmap[applid-1].used; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static inline int applid2fd(_cword applid) +{ + return capi_applidmap[applid-1].fd; +} + +/*---------------------------------------------------------------------------*\ + CAPI2.0 functions +\*---------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MaxB3Connection, + unsigned MaxB3Blks, + unsigned MaxSizeB3, + CAPI_REGISTER_ERROR *ErrorCode) +{ + _cword applid; + char buf[PATH_MAX]; + int i, fd = -1; + + if (!CAPI20_ISINSTALLED()) { + *ErrorCode = CapiRegNotInstalled; + return 0; + } + + *ErrorCode = CapiRegOSResourceErr; + + for (i=0; fd < 0; i++) { + /*----- open pseudo-clone device -----*/ + sprintf(buf, "/dev/capi20.%02d", i); + if ((fd = open(buf, O_RDWR|O_NONBLOCK, 0666)) < 0) { + switch (errno) { + case EEXIST: + break; + default: + return 0; + } + } + } + + if ((applid = allocapplid(fd)) == 0) + return 0; + + ioctl_data.rparams.level3cnt = MaxB3Connection; + ioctl_data.rparams.datablkcnt = MaxB3Blks; + ioctl_data.rparams.datablklen = MaxSizeB3; + + if (ioctl(fd, CAPI_REGISTER, &ioctl_data) < 0) { + if (errno == EIO) { + if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) + return 0; + *ErrorCode = ioctl_data.errcode; + } + return 0; + } + return applid; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) +{ + if (!CAPI20_ISINSTALLED()) + return CapiRegNotInstalled; + if (!validapplid(Appl_Id)) + return CapiIllAppNr; + (void)close(applid2fd(Appl_Id)); + freeapplid(Appl_Id); + return CapiNoError; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) +{ + MESSAGE_EXCHANGE_ERROR ret; + int len = (Msg[0] | (Msg[1] << 8)); + int cmd = Msg[4]; + int subcmd = Msg[5]; + int rc; + int fd; + + if (!CAPI20_ISINSTALLED()) + return CapiRegNotInstalled; + + if (!validapplid(Appl_Id)) + return CapiIllAppNr; + + fd = applid2fd(Appl_Id); + + memcpy(sndbuf, Msg, len); + + if (cmd == CAPI_DATA_B3 && subcmd == CAPI_REQ) { + int datalen = (Msg[16] | (Msg[17] << 8)); + void *dataptr = (void *)(Msg[12]|(Msg[13]<<8)|(Msg[14]<<16)|(Msg[15]<<24)); + memcpy(sndbuf+len, dataptr, datalen); + len += datalen; + } + + ret = CapiNoError; + errno = 0; + + if ((rc = write(fd, sndbuf, len)) != len) { + switch (errno) { + case EFAULT: + case EINVAL: + ret = CapiIllCmdOrSubcmdOrMsgToSmall; + break; + case EBADF: + ret = CapiIllAppNr; + break; + case EIO: + if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) + ret = CapiMsgOSResourceErr; + else ret = (MESSAGE_EXCHANGE_ERROR)ioctl_data.errcode; + break; + default: + ret = CapiMsgOSResourceErr; + break; + } + } + +#if defined (CPROT_LINUX) + if (ret == CapiNoError) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", ret); +#endif + + return ret; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE *ReturnMessage) +{ + MESSAGE_EXCHANGE_ERROR ret; + int rc, fd; + + if (!CAPI20_ISINSTALLED()) + return CapiRegNotInstalled; + + if (!validapplid(Appl_Id)) + return CapiIllAppNr; + + fd = applid2fd(Appl_Id); + + *ReturnMessage = rcvbuf; + if ((rc = read(fd, rcvbuf, sizeof(rcvbuf))) > 0) { +#if defined (CPROT_LINUX) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); +#endif + return CapiNoError; + } + + if (rc == 0) + return CapiReceiveQueueEmpty; + + switch (errno) { + case EMSGSIZE: + ret = CapiIllCmdOrSubcmdOrMsgToSmall; + break; + case EAGAIN: + return CapiReceiveQueueEmpty; + default: + ret = CapiMsgOSResourceErr; + break; + } + +#if defined (CPROT_LINUX) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", ret); +#endif + + return ret; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) +{ + if (!CAPI20_ISINSTALLED()) + return 0; + ioctl_data.contr = 0; + if (ioctl(capi_fd, CAPI_GET_MANUFACTURER, &ioctl_data) < 0) + return 0; + strncpy(LpBuffer, ioctl_data.manufacturer, CAPI_MANUFACTURER_LEN); + return LpBuffer; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) +{ + if (!CAPI20_ISINSTALLED()) + return 0; + ioctl_data.contr = 0; + if (ioctl(capi_fd, CAPI_GET_VERSION, &ioctl_data) < 0) + return 0; + memcpy(version, &ioctl_data.version, sizeof(capi_version)); + return version; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) +{ + if (!CAPI20_ISINSTALLED()) + return 0; + ioctl_data.contr = 0; + if (ioctl(capi_fd, CAPI_GET_SERIAL, &ioctl_data) < 0) + return 0; + memcpy(LpBuffer, &ioctl_data.serial, CAPI_SERIAL_LEN); + return LpBuffer; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) +{ + if (!CAPI20_ISINSTALLED()) + return CapiMsgNotInstalled; + + ioctl_data.contr = Controller; + if (ioctl(capi_fd, CAPI_GET_PROFILE, &ioctl_data) < 0) { + if (errno != EIO) + return CapiMsgOSResourceErr; + if (ioctl(capi_fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) + return CapiMsgOSResourceErr; + return (MESSAGE_EXCHANGE_ERROR)ioctl_data.errcode; + } + if (Controller) + memcpy(LpBuffer, &ioctl_data.profile, CAPI_SERIAL_LEN); + else + memcpy(LpBuffer, &ioctl_data.profile.ncontroller, + sizeof(ioctl_data.profile.ncontroller)); + return CapiNoError; +} +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ diff --git a/C20LIB/SOURCE/CLINUX.H b/C20LIB/SOURCE/CLINUX.H new file mode 100644 index 0000000..1c3e405 --- /dev/null +++ b/C20LIB/SOURCE/CLINUX.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + + Clinux.H Version 1.0 1997 AVM + + Operation system specific CAPI 2.0 functions for the Linux interface + +\*---------------------------------------------------------------------------*/ +#ifndef _linux_h_ +#define _linux_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include +#include "capi20.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); + +_cword CAPI20_REGISTER (unsigned MaxB3Connection, + unsigned MaxB3Blks, + unsigned MaxSizeB3, + CAPI_REGISTER_ERROR *ErrorCode); + +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id); + +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id); + +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE *ReturnMessage); + +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); + +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); + +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); + +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif diff --git a/C20LIB/SOURCE/COS2.C b/C20LIB/SOURCE/COS2.C new file mode 100644 index 0000000..28e856e --- /dev/null +++ b/C20LIB/SOURCE/COS2.C @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + + COS2.C Version 1.0 1997 AVM + + This file contains the source of the operating system specific + CAPI functions, here for OS/2 applications. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include "cos2.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +typedef unsigned short WORD; +typedef unsigned long DWORD; +/*---------------------------------------------------------------------------*\ + defined in capi20 runtime DLL +\*---------------------------------------------------------------------------*/ +extern DWORD APIENTRY CAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID); +extern DWORD APIENTRY CAPI_RELEASE (DWORD ApplID); +extern DWORD APIENTRY CAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage); +extern DWORD APIENTRY CAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage); +extern DWORD APIENTRY CAPI_SET_SIGNAL (DWORD ApplID, DWORD hEventSem); +extern void APIENTRY CAPI_GET_MANUFACTURER (PVOID SzBuffer); +extern DWORD APIENTRY CAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor); +extern DWORD APIENTRY CAPI_GET_SERIAL_NUMBER (PVOID SzBuffer); +extern DWORD APIENTRY CAPI_GET_PROFILE (PBYTE SzBuffer, WORD CtrlNr); +extern DWORD APIENTRY CAPI_INSTALLED (void); +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + return (unsigned)CAPI_INSTALLED () == 0; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + DWORD ApplID; + + *ErrorCode = (CAPI_REGISTER_ERROR) CAPI_REGISTER(MsgBufSize, MaxB3Connection, MaxB3Blks, MaxSizeB3, &ApplID); + + return (_cword)ApplID; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) { + + return (MESSAGE_EXCHANGE_ERROR) CAPI_RELEASE (Appl_Id); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) { + DWORD Error; + + Error = CAPI_PUT_MESSAGE(Appl_Id, (void *)Msg); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE __far *ReturnMessage) { + DWORD Error; + + Error = CAPI_GET_MESSAGE(Appl_Id, (PVOID *)ReturnMessage); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Error != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL (unsigned ApplId, HEV hEventSem) { + DWORD Error; + + Error = CAPI_SET_SIGNAL (ApplId, (DWORD) hEventSem); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_SET_SIGNAL error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) { + CAPI_GET_MANUFACTURER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) { + DWORD CMajor; + DWORD CMinor; + DWORD MMajor; + DWORD MMinor; + + CAPI_GET_VERSION(&CMajor, &CMinor, &MMajor, &MMinor); + + version[0] = (BYTE)CMajor; + version[1] = (BYTE)CMinor; + version[2] = (BYTE)MMajor; + version[3] = (BYTE)MMinor; + + return version; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) { + + CAPI_GET_SERIAL_NUMBER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + DWORD Error; + + Error = CAPI_GET_PROFILE (LpBuffer, Controller); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_GET_PROFILE error \n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ diff --git a/C20LIB/SOURCE/COS2.H b/C20LIB/SOURCE/COS2.H new file mode 100644 index 0000000..b57240a --- /dev/null +++ b/C20LIB/SOURCE/COS2.H @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------*\ + + COS2.H Version 1.0 1997 AVM + + Operation system specific CAPI 2.0 functions for OS/2 + +\*--------------------------------------------------------------------------*/ +#ifndef _cos2_h_ +#define _cos2_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include + +#include "capi20.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE __far * ReturnMessage); +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL (unsigned ApplId, HEV hEventSem); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif /*----- _cos2_h_ -----*/ diff --git a/C20LIB/SOURCE/CVXD.C b/C20LIB/SOURCE/CVXD.C new file mode 100644 index 0000000..8638f7f --- /dev/null +++ b/C20LIB/SOURCE/CVXD.C @@ -0,0 +1,271 @@ +/*---------------------------------------------------------------------------*\ + + CWIN.C Version 1.2 1997 AVM + + This file contains the source of the operating system specific + CAPI 2.0 functions, here for the Win95 VxD interface. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include + +#include "cvxd.h" + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static unsigned IsWin40 (void) { + + unsigned Major; + + VMMCall (Get_VMM_Version); + __asm { + movzx eax, ah + mov [Major], eax + } + return (Major >= 4); +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static unsigned CAPIVxDGetVersion (void) { + + unsigned uRet = 0; + + VxDCall(CAPI20_Get_Version); + __asm { + jc short VarSet + mov [uRet], 1 + VarSet: + } + return uRet; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static const void *GetDDB (unsigned DeviceId) { + + const void *DDB; + + __asm { + mov eax, [DeviceId] + xor edi, edi + } + VMMCall(Get_DDB); + __asm { + mov [DDB], ecx + } + + return DDB; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + + unsigned Installed; + + Installed = CAPIVxDGetVersion (); + + if (!Installed && IsWin40 ()) { + /*----- try GetDDB for dynamic loadable VxDs -----*/ + Installed = (GetDDB (CAPI20_DEVICE_ID) != 0); + } + return Installed; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + + unsigned ApplID; + + __asm { + sub ebx, ebx ; just use EBX compiler will save EBX + mov eax, (014h SHL 8) OR 01h + mov ecx, [MsgBufSize] + mov edx, [MaxB3Connection] + mov esi, [MaxB3Blks] + mov edi, [MaxSizeB3] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [ApplID], eax + mov eax, [ErrorCode] + mov [eax], bx + } + return (_cword)ApplID; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) { + + MESSAGE_EXCHANGE_ERROR Error; + + __asm { + mov eax, (014h SHL 8) OR 02h + mov edx, [Appl_Id] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [Error], eax + } + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) { + + MESSAGE_EXCHANGE_ERROR Error; + + __asm { + mov eax, (014h SHL 8) OR 03h + mov ebx, [Msg] + mov edx, [Appl_Id] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [Error], eax + } + +#if defined (CPROT) + if (Error == CapiNoError) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Error); +#endif + + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE *ReturnMessage) { + + MESSAGE_EXCHANGE_ERROR Error; + + __asm { + sub ebx, ebx ; just use EBX compiler will save EBX + mov eax, (014h SHL 8) OR 04h + mov edx, [Appl_Id] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [Error], eax + mov eax, [ReturnMessage] + mov [eax], ebx + } + +#if defined (CPROT) + if (Error == CapiNoError) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Error != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Error); +#endif + + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL(unsigned ApplId, void (*Callback) (void), unsigned Param) { + + MESSAGE_EXCHANGE_ERROR Error; + + __asm { + mov eax, (014h SHL 8) OR 05h + mov ebx, [Callback] + mov edx, [ApplId] + mov edi, [Param] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [Error], eax + } + +#if defined (CPROT) + if (Error != CapiNoError) + CAPI_PROTOCOL_TEXT("CAPI_SET_SIGNAL error \n", Error); +#endif + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (unsigned Controller, CAPI_MESSAGE LpBuffer) { + + __asm { + mov eax, (014h SHL 8) OR 0F0h + mov ecx, [Controller] + mov ebx, [LpBuffer] + } + VxDCall(CAPI20_MessageOperations); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (unsigned Controller, CAPI_MESSAGE version) { + + __asm { + mov eax, (014h SHL 8) OR 0F1h + mov ecx, [Controller] + } + VxDCall(CAPI20_MessageOperations); + __asm { + mov eax, [version] + mov [eax+0], ah + mov [eax+1], al + mov [eax+2], dh + mov [eax+3], dl + } + + return version; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (unsigned Controller, CAPI_MESSAGE LpBuffer) { + + __asm { + mov eax, (014h SHL 8) OR 0F2h + mov ecx, [Controller] + mov ebx, [LpBuffer] + } + VxDCall(CAPI20_MessageOperations) + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + MESSAGE_EXCHANGE_ERROR Error; + + __asm { + mov eax, (014h SHL 8) OR 0F3h + mov ecx, [Controller] + mov ebx, [LpBuffer] + } + VxDCall(CAPI20_MessageOperations); + __asm { + movzx eax, ax + mov [Error], eax + } + +#if defined (CPROT) + if (Error != CapiNoError) + CAPI_PROTOCOL_TEXT("CAPI_GET_PROFILE error \n", Error); +#endif + + return Error; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ diff --git a/C20LIB/SOURCE/CVXD.H b/C20LIB/SOURCE/CVXD.H new file mode 100644 index 0000000..70ba485 --- /dev/null +++ b/C20LIB/SOURCE/CVXD.H @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------*\ + + CVxD.H Version 1.2 1997 AVM + + Operation system specific CAPI 2.0 functions for the Win95 VxD interface + +\*--------------------------------------------------------------------------*/ +#ifndef _cvxd_h_ +#define _cvxd_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include /*----- Win95 DDK see %DDKROOT%\INC32 -----*/ +#include /*----- Win95 DDK see %DDKROOT%\INC32 -----*/ +#include "capi20.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#define CAPI20_DEVICE_ID 0x3215 +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +Begin_Service_Table (CAPI20, VxD) +Declare_Service (CAPI20_Get_Version, LOCAL) +Declare_Service (CAPI20_MessageOperations, LOCAL) +End_Service_Table (CAPI20, VxD) +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE *ReturnMessage); +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL (unsigned ApplId, void (*CallBack)(void), unsigned Param); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (unsigned Controller, CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_VERSION (unsigned Controller, CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (unsigned Controller, CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif /*----- _cvxd_h_ -----*/ diff --git a/C20LIB/SOURCE/CWIN16.C b/C20LIB/SOURCE/CWIN16.C new file mode 100644 index 0000000..a9e9feb --- /dev/null +++ b/C20LIB/SOURCE/CWIN16.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + + CWIN.C Version 1.1 1995 AVM + + This file contains the source of the operating system specific + CAPI functions, here for Windows 16 bit. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include +#include + +#include "capi20.h" + +/*---------------------------------------------------------------------------*\ + defined in capi20 Runtime DLL +\*---------------------------------------------------------------------------*/ +extern WORD FAR PASCAL CAPI_INSTALLED (void); +extern WORD FAR PASCAL CAPI_REGISTER (WORD MessageBufferSize, WORD maxLogicalConnection, WORD maxBDataBlocks, WORD maxBDataLen, LPWORD pApplID); +extern WORD FAR PASCAL CAPI_RELEASE (WORD ApplID); +extern WORD FAR PASCAL CAPI_PUT_MESSAGE (WORD ApplID, LPVOID pCAPIMessage); +extern WORD FAR PASCAL CAPI_GET_MESSAGE (WORD ApplID, LPVOID FAR *ppCAPIMessage); +extern WORD FAR PASCAL CAPI_SET_SIGNAL (WORD ApplID, VOID (FAR PASCAL *CAPI_Callback)(WORD ApplID, DWORD Param), DWORD Param); +extern WORD FAR PASCAL CAPI_GET_MANUFACTURER (LPBYTE SzBuffer); +extern WORD FAR PASCAL CAPI_GET_VERSION (LPWORD pCAPIMajor, LPWORD pCAPIMinor, LPWORD pManufacturerMajor, LPWORD pManufacturerMinor); +extern WORD FAR PASCAL CAPI_GET_SERIAL_NUMBER (LPBYTE SzBuffer); +extern WORD FAR PASCAL CAPI_GET_PROFILE (LPBYTE SzBuffer, WORD CtrlNr); +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + return (unsigned)CAPI_INSTALLED () == 0; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + WORD ApplID; + + *ErrorCode = (CAPI_REGISTER_ERROR) CAPI_REGISTER((WORD)MsgBufSize, (WORD)MaxB3Connection, (WORD)MaxB3Blks, (WORD)MaxSizeB3, &ApplID); + return (_cword)ApplID; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) { + + return (MESSAGE_EXCHANGE_ERROR) CAPI_RELEASE ((WORD)Appl_Id); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) { + WORD Error; + + Error = CAPI_PUT_MESSAGE((WORD)Appl_Id, (void __far *)Msg); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE __far *ReturnMessage) { + WORD Error; + + Error = CAPI_GET_MESSAGE((WORD)Appl_Id, (LPVOID FAR *)ReturnMessage); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Error != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL(unsigned ApplId, void (FAR PASCAL *CallBack)(WORD,DWORD), DWORD Param) { + WORD Error; + + Error = CAPI_SET_SIGNAL((WORD)ApplId, CallBack, Param); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_SET_SIGNAL error \n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) { + CAPI_GET_MANUFACTURER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) { + WORD CMajor; + WORD CMinor; + WORD MMajor; + WORD MMinor; + + CAPI_GET_VERSION((WORD __far *)&CMajor, (WORD __far *)&CMinor, + (WORD __far *)&MMajor, (WORD __far *)&MMinor); + + version[0] = (BYTE)CMajor; + version[1] = (BYTE)CMinor; + version[2] = (BYTE)MMajor; + version[3] = (BYTE)MMinor; + + return version; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) { + + CAPI_GET_SERIAL_NUMBER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + WORD Error; + + Error = CAPI_GET_PROFILE(LpBuffer, (WORD)Controller); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_GET_PROFILE error \n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} diff --git a/C20LIB/SOURCE/CWIN16.H b/C20LIB/SOURCE/CWIN16.H new file mode 100644 index 0000000..d68b829 --- /dev/null +++ b/C20LIB/SOURCE/CWIN16.H @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------*\ + + CWIN.H Version 1.2 1997 AVM + + Operation system specific CAPI 2.0 functions for Windows 16 Bit + +\*--------------------------------------------------------------------------*/ +#ifndef _cwin16_h_ +#define _cwin16_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include + +#include "capi20.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE __far * ReturnMessage); +MESSAGE_EXCHANGE_ERROR CAPI20_SET_SIGNAL(unsigned ApplId, void (__far __pascal *CallBack)(WORD,DWORD), DWORD Param); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif /*----- _cwin16_h_ -----*/ diff --git a/C20LIB/SOURCE/CWIN32.C b/C20LIB/SOURCE/CWIN32.C new file mode 100644 index 0000000..c65be09 --- /dev/null +++ b/C20LIB/SOURCE/CWIN32.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + + CWIN.C Version 1.1 1995 AVM + + This file contains the source of the operating system specific + CAPI functions, here for Windows 32 bit. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include +#include + +#include "capi20.h" +/*---------------------------------------------------------------------------*\ + defined in capi2032 runtime DLL +\*---------------------------------------------------------------------------*/ +extern DWORD APIENTRY CAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID); +extern DWORD APIENTRY CAPI_RELEASE (DWORD ApplID); +extern DWORD APIENTRY CAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage); +extern DWORD APIENTRY CAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage); +extern DWORD APIENTRY CAPI_WAIT_FOR_SIGNAL (DWORD ApplID); +extern DWORD APIENTRY CAPI_GET_MANUFACTURER (PVOID SzBuffer); +extern DWORD APIENTRY CAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor); +extern DWORD APIENTRY CAPI_GET_SERIAL_NUMBER (PVOID SzBuffer); +extern DWORD APIENTRY CAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtrlNr); +extern DWORD APIENTRY CAPI_INSTALLED (void); +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + return (unsigned)CAPI_INSTALLED () == 0; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + DWORD ApplID; + + *ErrorCode = (CAPI_REGISTER_ERROR) CAPI_REGISTER(MsgBufSize, MaxB3Connection, MaxB3Blks, MaxSizeB3, &ApplID); + + return (_cword)ApplID; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id) { + + return (MESSAGE_EXCHANGE_ERROR) CAPI_RELEASE (Appl_Id); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id) { + DWORD Error; + + Error = CAPI_PUT_MESSAGE(Appl_Id, (void *)Msg); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE __far *ReturnMessage) { + DWORD Error; + + Error = CAPI_GET_MESSAGE(Appl_Id, (LPVOID *)ReturnMessage); + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Error != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_WAIT_FOR_SIGNAL (unsigned ApplId) { + DWORD Error; + + Error = CAPI_WAIT_FOR_SIGNAL (ApplId); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_SET_SIGNAL error \n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) { + CAPI_GET_MANUFACTURER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) { + DWORD CMajor; + DWORD CMinor; + DWORD MMajor; + DWORD MMinor; + + CAPI_GET_VERSION(&CMajor, &CMinor, &MMajor, &MMinor); + + version[0] = (BYTE)CMajor; + version[1] = (BYTE)CMinor; + version[2] = (BYTE)MMajor; + version[3] = (BYTE)MMinor; + + return version; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) { + + CAPI_GET_SERIAL_NUMBER(LpBuffer); + + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + DWORD Error; + + Error = CAPI_GET_PROFILE (LpBuffer, Controller); + +#if defined (CPROT) + if (Error != 0x0000) + CAPI_PROTOCOL_TEXT("CAPI_GET_PROFILE error \n", Error); +#endif + + return (MESSAGE_EXCHANGE_ERROR) Error; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ diff --git a/C20LIB/SOURCE/CWIN32.H b/C20LIB/SOURCE/CWIN32.H new file mode 100644 index 0000000..70311da --- /dev/null +++ b/C20LIB/SOURCE/CWIN32.H @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------*\ + + CWIN.H Version 1.2 1997 AVM + + Operation system specific CAPI 2.0 functions for Windows 32 Bit + +\*--------------------------------------------------------------------------*/ +#ifndef _cwin32_h_ +#define _cwin32_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include + +#include "capi20.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE __far * ReturnMessage); +MESSAGE_EXCHANGE_ERROR CAPI20_WAIT_FOR_SIGNAL (unsigned ApplId); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif /*----- _cwin32_h_ -----*/ diff --git a/C20LIB/SOURCE/C_NW.C b/C20LIB/SOURCE/C_NW.C new file mode 100644 index 0000000..9a2088f --- /dev/null +++ b/C20LIB/SOURCE/C_NW.C @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + + C_NW.C Version 1.0 1998 AVM + + CAPI 2.0 Development Kit NetWare + + This file contains the source of the operating system specific + CAPI functions, here for Novell NetWare. See CAPI 2.0 spec. + +\*---------------------------------------------------------------------------*/ +#include +#include +#include + +#include "c_nw.h" +#include "c2imp_nw.h" +#include "c2mgr_nw.h" +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +static LONG GetMessageSemaphore = -1; +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void) { + return 1; // loader refuses to load if it can not find the symbols +} + +/*-----------------------------##########################*/ +static void APPL_ReceiveNotify (unsigned long signalContext) { + SignalLocalSemaphore (GetMessageSemaphore); // enables CAPI_GetMessage +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode) { + WORD ApplId; + + assert (GetMessageSemaphore == -1); + GetMessageSemaphore = OpenLocalSemaphore (0); + + *ErrorCode = (CAPI_REGISTER_ERROR)CAPI_Register( + (WORD)MsgBufSize, + (WORD)MaxB3Connection, + (WORD)MaxB3Blks, + (WORD)MaxSizeB3, + &ApplId, + SIGNAL_TYPE_CALLBACK, + (DWORD) APPL_ReceiveNotify, + 0 + ); + + if (*ErrorCode != CapiNoError) { + CloseLocalSemaphore (GetMessageSemaphore); + GetMessageSemaphore = -1; + ApplId = 0; + } + + return (_cword)ApplId; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned ApplId) { + MESSAGE_EXCHANGE_ERROR Error; + + assert (GetMessageSemaphore != -1); + + Error = (MESSAGE_EXCHANGE_ERROR)CAPI_Release ((WORD)ApplId); + + if (Error == CapiNoError) { + CloseLocalSemaphore (GetMessageSemaphore); + GetMessageSemaphore = -1; + } + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned ApplId) { + MESSAGE_EXCHANGE_ERROR Error; + + Error = (MESSAGE_EXCHANGE_ERROR)CAPI_PutMessage ((WORD)ApplId, (BYTE*)Msg); + +#if defined (CPROT) + if (Error == CapiNoError) + CAPI_PROTOCOL_MESSAGE (Msg); + else + CAPI_PROTOCOL_TEXT ("CAPI_PUT_MESSAGE error 0x%04x\n", Error); +#endif + + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned ApplId, CAPI_MESSAGE *ReturnMessage) { + MESSAGE_EXCHANGE_ERROR Error; + + assert (GetMessageSemaphore != -1); + + if (ExamineLocalSemaphore (GetMessageSemaphore) <= 0) { + Error = CapiReceiveQueueEmpty; + } else { + WaitOnLocalSemaphore (GetMessageSemaphore); + + Error = (MESSAGE_EXCHANGE_ERROR)CAPI_GetMessage((WORD)ApplId, (BYTE**)ReturnMessage); + } + +#if defined (CPROT) + if (Error == 0x0000) + CAPI_PROTOCOL_MESSAGE (*ReturnMessage); + else if (Error != CapiReceiveQueueEmpty) + CAPI_PROTOCOL_TEXT ("CAPI_GET_MESSAGE error 0x%04x\n", Error); +#endif + + return Error; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer) { + + CAPI_GetManufacturer (0, LpBuffer); + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version) { + WORD CMajor; + WORD CMinor; + WORD MMajor; + WORD MMinor; + WORD MgrMajor; + WORD MgrMinor; + + CAPI_GetVersion(0, (WORD *)&CMajor, (WORD *)&CMinor, + (WORD *)&MMajor, (WORD *)&MMinor, + (WORD *)&MgrMajor, (WORD *)&MgrMinor); + + version[0] = (BYTE)CMajor; + version[1] = (BYTE)CMinor; + version[2] = (BYTE)MMajor; + version[3] = (BYTE)MMinor; + return version; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer) { + + CAPI_GetSerialNumber (0, LpBuffer); + return LpBuffer; +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer) { + MESSAGE_EXCHANGE_ERROR Error; + + Error = (MESSAGE_EXCHANGE_ERROR)CAPI_GetProfile (LpBuffer, (DWORD)Controller); + +#if defined (CPROT) + if (Error != CapiNoError) + CAPI_PROTOCOL_TEXT("CAPI_GET_PROFILE error \n", Error); +#endif + + return Error; +} + +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ diff --git a/C20LIB/SOURCE/C_NW.H b/C20LIB/SOURCE/C_NW.H new file mode 100644 index 0000000..1203ed0 --- /dev/null +++ b/C20LIB/SOURCE/C_NW.H @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------*\ + + C_NW.H Version 1.0 1998 AVM + + CAPI 2.0 Development Kit internal functions for NetWare + +\*---------------------------------------------------------------------------*/ +#ifndef _c_nw_h +#define _c_nw_h +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#include "capi20.h" // NetWare independant +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +unsigned CAPI20_ISINSTALLED (void); +_cword CAPI20_REGISTER (unsigned MsgBufSize, unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, CAPI_REGISTER_ERROR *ErrorCode); +MESSAGE_EXCHANGE_ERROR CAPI20_RELEASE (unsigned Appl_Id); +MESSAGE_EXCHANGE_ERROR CAPI20_PUT_MESSAGE (CAPI_MESSAGE Msg, unsigned Appl_Id); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_MESSAGE (unsigned Appl_Id, CAPI_MESSAGE *ReturnMessage); +CAPI_MESSAGE CAPI20_GET_VERSION (CAPI_MESSAGE version); +CAPI_MESSAGE CAPI20_GET_MANUFACTURER (CAPI_MESSAGE LpBuffer); +CAPI_MESSAGE CAPI20_GET_SERIAL_NUMBER (CAPI_MESSAGE LpBuffer); +MESSAGE_EXCHANGE_ERROR CAPI20_GET_PROFILE (unsigned Controller, CAPI_MESSAGE LpBuffer); +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif diff --git a/C20LIB/SOURCE/FUNC.C b/C20LIB/SOURCE/FUNC.C new file mode 100644 index 0000000..216e94c --- /dev/null +++ b/C20LIB/SOURCE/FUNC.C @@ -0,0 +1,357 @@ +/*--------------------------------------------------------------------------*\ + + FUNC.C Version 1.2 1997 AVM + + This file contains the source of the CAPI functions that correspond + to the CAPI messages described in the CAPI 2.0 spec. + +\*--------------------------------------------------------------------------*/ +#include "capi20.h" + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned ALERT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x01,0x80,Messagenumber,adr); + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword CIPValue, + _cstruct CalledPartyNumber, + _cstruct CallingPartyNumber, + _cstruct CalledPartySubaddress, + _cstruct CallingPartySubaddress, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration, + _cstruct BC, + _cstruct LLC, + _cstruct HLC, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x02,0x80,Messagenumber,adr); + cmsg->CIPValue = CIPValue; + cmsg->CalledPartyNumber = CalledPartyNumber; + cmsg->CallingPartyNumber = CallingPartyNumber; + cmsg->CalledPartySubaddress = CalledPartySubaddress; + cmsg->CallingPartySubaddress = CallingPartySubaddress; + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; + cmsg->BC = BC; + cmsg->LLC = LLC; + cmsg->HLC = HLC; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x82,0x80,Messagenumber,adr); + cmsg->NCPI = NCPI; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DATA_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword Data, + _cword DataLength, + _cword DataHandle, + _cword Flags) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x86,0x80,Messagenumber,adr); + cmsg->Data = Data; + cmsg->DataLength = DataLength; + cmsg->DataHandle = DataHandle; + cmsg->Flags = Flags; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DISCONNECT_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x84,0x80,Messagenumber,adr); + cmsg->NCPI = NCPI; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DISCONNECT_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x04,0x80,Messagenumber,adr); + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned FACILITY_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword FacilitySelector, + _cstruct FacilityRequestParameter) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x80,0x80,Messagenumber,adr); + cmsg->FacilitySelector = FacilitySelector; + cmsg->FacilityRequestParameter = FacilityRequestParameter; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned INFO_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct CalledPartyNumber, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x08,0x80,Messagenumber,adr); + cmsg->CalledPartyNumber = CalledPartyNumber; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned LISTEN_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword InfoMask, + _cdword CIPmask, + _cdword CIPmask2, + _cstruct CallingPartyNumber, + _cstruct CallingPartySubaddress) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x05,0x80,Messagenumber,adr); + cmsg->InfoMask = InfoMask; + cmsg->CIPmask = CIPmask; + cmsg->CIPmask2 = CIPmask2; + cmsg->CallingPartyNumber = CallingPartyNumber; + cmsg->CallingPartySubaddress = CallingPartySubaddress; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned MANUFACTURER_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword ManuID, + _cdword Class, + _cdword Function, + _cstruct ManuData) { + CAPI_CMSG_HEADER (cmsg,ApplId,0xff,0x80,Messagenumber,adr); + cmsg->ManuID = ManuID; + cmsg->Class = Class; + cmsg->Function = Function; + cmsg->ManuData = ManuData; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned RESET_B3_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x87,0x80,Messagenumber,adr); + cmsg->NCPI = NCPI; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned SELECT_B_PROTOCOL_REQ (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x41,0x80,Messagenumber,adr); + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword Reject, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration, + _cstruct ConnectedNumber, + _cstruct ConnectedSubaddress, + _cstruct LLC, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x02,0x83,Messagenumber,adr); + cmsg->Reject = Reject; + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; + cmsg->ConnectedNumber = ConnectedNumber; + cmsg->ConnectedSubaddress = ConnectedSubaddress; + cmsg->LLC = LLC; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x03,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_B3_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x83,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword Reject, + _cstruct NCPI) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x82,0x83,Messagenumber,adr); + cmsg->Reject = Reject; + cmsg->NCPI = NCPI; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned CONNECT_B3_T90_ACTIVE_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x88,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DATA_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword DataHandle) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x86,0x83,Messagenumber,adr); + cmsg->DataHandle = DataHandle; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DISCONNECT_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x84,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned DISCONNECT_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x04,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned FACILITY_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword FacilitySelector, + _cstruct FacilityResponseParameters) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x80,0x83,Messagenumber,adr); + cmsg->FacilitySelector = FacilitySelector; + cmsg->FacilityResponseParameters = FacilityResponseParameters; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned INFO_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x08,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned MANUFACTURER_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword ManuID, + _cdword Class, + _cdword Function, + _cstruct ManuData) { + CAPI_CMSG_HEADER (cmsg,ApplId,0xff,0x83,Messagenumber,adr); + cmsg->ManuID = ManuID; + cmsg->Class = Class; + cmsg->Function = Function; + cmsg->ManuData = ManuData; + return CAPI_PUT_CMSG (cmsg); +} + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +unsigned RESET_B3_RESP (_cmsg __far *cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) { + CAPI_CMSG_HEADER (cmsg,ApplId,0x87,0x83,Messagenumber,adr); + return CAPI_PUT_CMSG (cmsg); +} diff --git a/C20LIB/SOURCE/GCMSGDOS.C b/C20LIB/SOURCE/GCMSGDOS.C new file mode 100644 index 0000000..4c87362 --- /dev/null +++ b/C20LIB/SOURCE/GCMSGDOS.C @@ -0,0 +1,29 @@ +/*---------------------------------------------------------------------------*\ + + GCMSGDOS.C Version 1.1 1995 AVM + + Operation system specific functions of the CAPI 2.0 Development Kit + for DOS + +\*---------------------------------------------------------------------------*/ +#include "capi20.h" +#include "cdos.h" + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) { + static unsigned char msg[2048]; + + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) { + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == 0x0000) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/GCMSGLIN.C b/C20LIB/SOURCE/GCMSGLIN.C new file mode 100644 index 0000000..e3dee78 --- /dev/null +++ b/C20LIB/SOURCE/GCMSGLIN.C @@ -0,0 +1,23 @@ +#include "capi20.h" +#include "clinux.h" + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) +{ + static unsigned char msg[2048]; + + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) +{ + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == 0x0000) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/GCMSGOS2.C b/C20LIB/SOURCE/GCMSGOS2.C new file mode 100644 index 0000000..4a18ccc --- /dev/null +++ b/C20LIB/SOURCE/GCMSGOS2.C @@ -0,0 +1,27 @@ +/*---------------------------------------------------------------------------*\ + + GCMSGOS2.C Version 1.1 1996 AVM + + Operation system specific functions of the CAPI 2.0 Development Kit + for OS/2 + +\*---------------------------------------------------------------------------*/ +#include "capi20.h" +#include "cos2.h" + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) { + static unsigned char msg[2048]; + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) { + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == 0x0000) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/GCMSGVXD.C b/C20LIB/SOURCE/GCMSGVXD.C new file mode 100644 index 0000000..c179192 --- /dev/null +++ b/C20LIB/SOURCE/GCMSGVXD.C @@ -0,0 +1,27 @@ +/*---------------------------------------------------------------------------*\ + + GCMSGWIN.C Version 1.1 1995 AVM + + Operation system specific functions of the CAPI 2.0 Development Kit + for the Win95 VxD interface + +\*---------------------------------------------------------------------------*/ +#include "capi20.h" +#include "cvxd.h" + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) { + static unsigned char msg[2048]; + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) { + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == CapiNoError) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/GCMSGWIN.C b/C20LIB/SOURCE/GCMSGWIN.C new file mode 100644 index 0000000..9b97136 --- /dev/null +++ b/C20LIB/SOURCE/GCMSGWIN.C @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------*\ + + GCMSGWIN.C Version 1.1 1995 AVM + + Operation system specific functions of the CAPI 2.0 Development Kit + for Windows 16/32 bit + +\*---------------------------------------------------------------------------*/ +#include "capi20.h" + +#if defined (TARGET_32BIT) +#include "cwin32.h" +#endif +#if defined (TARGET_16BIT) +#include "cwin16.h" +#endif + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) { + static unsigned char msg[2048]; + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) { + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == 0x0000) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/GCMSG_NW.C b/C20LIB/SOURCE/GCMSG_NW.C new file mode 100644 index 0000000..6ea9930 --- /dev/null +++ b/C20LIB/SOURCE/GCMSG_NW.C @@ -0,0 +1,29 @@ +/*---------------------------------------------------------------------------*\ + + GCMSG_NW.H Version 1.0 1998 AVM + + CAPI 2.0 Development Kit NetWare + + This file contains NetWare specific functions. +\*---------------------------------------------------------------------------*/ +#include "capi20.h" +#include "c_nw.h" + +/*-------------------------------------------------------*/ +unsigned __far CAPI_PUT_CMSG (_cmsg __far *cmsg) { + static unsigned char msg[2048]; + + CAPI_CMSG_2_MESSAGE (cmsg, (CAPI_MESSAGE)msg); + return CAPI20_PUT_MESSAGE ((CAPI_MESSAGE)msg, cmsg->ApplId); +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_GET_CMSG (_cmsg __far *cmsg, unsigned applid) { + MESSAGE_EXCHANGE_ERROR rtn; + CAPI_MESSAGE msg; + + rtn = CAPI20_GET_MESSAGE (applid, &msg); + if (rtn == 0x0000) + CAPI_MESSAGE_2_CMSG (cmsg, msg); + return rtn; +} diff --git a/C20LIB/SOURCE/MSG.C b/C20LIB/SOURCE/MSG.C new file mode 100644 index 0000000..e0187ec --- /dev/null +++ b/C20LIB/SOURCE/MSG.C @@ -0,0 +1,717 @@ +/*---------------------------------------------------------------------------*\ + + MSG.C Version 1.2 1997 AVM + + CAPI 2.0 Development Kit internal functions + +\*---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +#include "capi20.h" + +typedef struct { + int typ; + unsigned off; +} _cdef; + +#define _CBYTE 1 +#define _CWORD 2 +#define _CDWORD 3 +#define _CSTRUCT 4 +#define _CMSTRUCT 5 +#define _CEND 6 + +static _cdef cdef[] = { + /*00*/{_CEND}, + /*01*/{_CEND}, + /*02*/{_CEND}, + /*03*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->adr.adrController}, + /*04*/{_CMSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->AdditionalInfo}, + /*05*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->B1configuration}, + /*06*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->B1protocol}, + /*07*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->B2configuration}, + /*08*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->B2protocol}, + /*09*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->B3configuration}, + /*0a*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->B3protocol}, + /*0b*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->BC}, + /*0c*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->BChannelinformation}, + /*0d*/{_CMSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->BProtocol}, + /*0e*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->CalledPartyNumber}, + /*0f*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->CalledPartySubaddress}, + /*10*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->CallingPartyNumber}, + /*11*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->CallingPartySubaddress}, + /*12*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->CIPmask}, + /*13*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->CIPmask2}, + /*14*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->CIPValue}, + /*15*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Class}, + /*16*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->ConnectedNumber}, + /*17*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->ConnectedSubaddress}, + /*18*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Data}, + /*19*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->DataHandle}, + /*1a*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->DataLength}, + /*1b*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->FacilityConfirmationParameter}, + /*1c*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->Facilitydataarray}, + /*1d*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->FacilityIndicationParameter}, + /*1e*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->FacilityRequestParameter}, + /*1f*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->FacilityResponseParameters}, + /*20*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->FacilitySelector}, + /*21*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Flags}, + /*22*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Function}, + /*23*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->HLC}, + /*24*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Info}, + /*25*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->InfoElement}, + /*26*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->InfoMask}, + /*27*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->InfoNumber}, + /*28*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->Keypadfacility}, + /*29*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->LLC}, + /*2a*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->ManuData}, + /*2b*/{_CDWORD, (unsigned)(unsigned long)&((_cmsg *)0)->ManuID}, + /*2c*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->NCPI}, + /*2d*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Reason}, + /*2e*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Reason_B3}, + /*2f*/{_CWORD, (unsigned)(unsigned long)&((_cmsg *)0)->Reject}, + /*30*/{_CSTRUCT, (unsigned)(unsigned long)&((_cmsg *)0)->Useruserdata}, +}; + +static unsigned char *cpars[] = { + /*00*/ 0, + /*01 ALERT_REQ*/ (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", + /*02 CONNECT_REQ*/ (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", + /*03*/ 0, + /*04 DISCONNECT_REQ*/ (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", + /*05 LISTEN_REQ*/ (unsigned char*)"\x03\x26\x12\x13\x10\x11\x01", + /*06*/ 0, + /*07*/ 0, + /*08 INFO_REQ*/ (unsigned char*)"\x03\x0e\x04\x0c\x28\x30\x1c\x01\x01", + /*09 FACILITY_REQ*/ (unsigned char*)"\x03\x20\x1e\x01", + /*0a SELECT_B_PROTOCOL_REQ*/ (unsigned char*)"\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", + /*0b CONNECT_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", + /*0c*/ 0, + /*0d DISCONNECT_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", + /*0e*/ 0, + /*0f DATA_B3_REQ*/ (unsigned char*)"\x03\x18\x1a\x19\x21\x01", + /*10 RESET_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", + /*11*/ 0, + /*12*/ 0, + /*13 ALERT_CONF*/ (unsigned char*)"\x03\x24\x01", + /*14 CONNECT_CONF*/ (unsigned char*)"\x03\x24\x01", + /*15*/ 0, + /*16 DISCONNECT_CONF*/ (unsigned char*)"\x03\x24\x01", + /*17 LISTEN_CONF*/ (unsigned char*)"\x03\x24\x01", + /*18 MANUFACTURER_REQ*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*19*/ 0, + /*1a INFO_CONF*/ (unsigned char*)"\x03\x24\x01", + /*1b FACILITY_CONF*/ (unsigned char*)"\x03\x24\x20\x1b\x01", + /*1c SELECT_B_PROTOCOL_CONF*/ (unsigned char*)"\x03\x24\x01", + /*1d CONNECT_B3_CONF*/ (unsigned char*)"\x03\x24\x01", + /*1e*/ 0, + /*1f DISCONNECT_B3_CONF*/ (unsigned char*)"\x03\x24\x01", + /*20*/ 0, + /*21 DATA_B3_CONF*/ (unsigned char*)"\x03\x19\x24\x01", + /*22 RESET_B3_CONF*/ (unsigned char*)"\x03\x24\x01", + /*23*/ 0, + /*24*/ 0, + /*25*/ 0, + /*26 CONNECT_IND*/ (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", + /*27 CONNECT_ACTIVE_IND*/ (unsigned char*)"\x03\x16\x17\x29\x01", + /*28 DISCONNECT_IND*/ (unsigned char*)"\x03\x2d\x01", + /*29*/ 0, + /*2a MANUFACTURER_CONF*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*2b*/ 0, + /*2c INFO_IND*/ (unsigned char*)"\x03\x27\x25\x01", + /*2d FACILITY_IND*/ (unsigned char*)"\x03\x20\x1d\x01", + /*2e*/ 0, + /*2f CONNECT_B3_IND*/ (unsigned char*)"\x03\x2c\x01", + /*30 CONNECT_B3_ACTIVE_IND*/ (unsigned char*)"\x03\x2c\x01", + /*31 DISCONNECT_B3_IND*/ (unsigned char*)"\x03\x2e\x2c\x01", + /*32*/ 0, + /*33 DATA_B3_IND*/ (unsigned char*)"\x03\x18\x1a\x19\x21\x01", + /*34 RESET_B3_IND*/ (unsigned char*)"\x03\x2c\x01", + /*35 CONNECT_B3_T90_ACTIVE_IND*/ (unsigned char*)"\x03\x2c\x01", + /*36*/ 0, + /*37*/ 0, + /*38 CONNECT_RESP*/ (unsigned char*)"\x03\x2f\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x29\x04\x0c\x28\x30\x1c\x01\x01", + /*39 CONNECT_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", + /*3a DISCONNECT_RESP*/ (unsigned char*)"\x03\x01", + /*3b*/ 0, + /*3c MANUFACTURER_IND*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*3d*/ 0, + /*3e INFO_RESP*/ (unsigned char*)"\x03\x01", + /*3f FACILITY_RESP*/ (unsigned char*)"\x03\x20\x1f\x01", + /*40*/ 0, + /*41 CONNECT_B3_RESP*/ (unsigned char*)"\x03\x2f\x2c\x01", + /*42 CONNECT_B3_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", + /*43 DISCONNECT_B3_RESP*/ (unsigned char*)"\x03\x01", + /*44*/ 0, + /*45 DATA_B3_RESP*/ (unsigned char*)"\x03\x19\x01", + /*46 RESET_B3_RESP*/ (unsigned char*)"\x03\x01", + /*47 CONNECT_B3_T90_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", + /*48*/ 0, + /*49*/ 0, + /*4a*/ 0, + /*4b*/ 0, + /*4c*/ 0, + /*4d*/ 0, + /*4e MANUFACTURER_RESP*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", +}; + +/*-------------------------------------------------------*/ +#if defined (TARGET_16BIT) + +#undef memset +#define memset _fmemset + +#define byteTLcpy(x,y) *(_cbyte __far *)(x)=*(_cbyte __far *)(y); +#define wordTLcpy(x,y) *(_cword __far *)(x)=*(_cword __far *)(y); +#define dwordTLcpy(x,y) *(_cdword __far *)(x)=*(_cdword __far *)(y); +#define structTLcpy(x,y,l) _fmemcpy (x,y,l) +#define structTLcpyovl(x,y,l) _fmemmove (x,y,l) + +#define byteTRcpy(x,y) *(_cbyte __far *)(y)=*(_cbyte __far *)(x); +#define wordTRcpy(x,y) *(_cword __far *)(y)=*(_cword __far *)(x); +#define dwordTRcpy(x,y) *(_cdword __far *)(y)=*(_cdword __far *)(x); +#define structTRcpy(x,y,l) _fmemcpy (y,x,l) +#define structTRcpyovl(x,y,l) _fmemmove (y,x,l) + +#endif + + +/*-------------------------------------------------------*/ +#if defined (TARGET_32BIT) + +#define byteTLcpy(x,y) *(_cbyte *)(x)=*(_cbyte *)(y); +#define wordTLcpy(x,y) *(_cword *)(x)=*(_cword *)(y); +#define dwordTLcpy(x,y) memcpy(x,y,4); +#define structTLcpy(x,y,l) memcpy (x,y,l) +#define structTLcpyovl(x,y,l) memmove (x,y,l) + +#define byteTRcpy(x,y) *(_cbyte *)(y)=*(_cbyte *)(x); +#define wordTRcpy(x,y) *(_cword *)(y)=*(_cword *)(x); +#define dwordTRcpy(x,y) memcpy(y,x,4); +#define structTRcpy(x,y,l) memcpy (y,x,l) +#define structTRcpyovl(x,y,l) memmove (y,x,l) + +#endif + +/*-------------------------------------------------------*/ +static unsigned __far command_2_index (unsigned c, unsigned sc) { + if (c & 0x80) c = 0x9+(c&0x0f); + else if (c<=0x0f) ; + else if (c==0x41) c = 0x9+0x1; + else if (c==0xff) c = 0x00; + return (sc&3)*(0x9+0x9)+c; +} + +/*-------------------------------------------------------*/ +#define TYP (cdef[cmsg->par[cmsg->p]].typ) +#define OFF (((char __far *)cmsg)+cdef[cmsg->par[cmsg->p]].off) + +static void jumpcstruct (_cmsg __far *cmsg) { + unsigned layer; + for (cmsg->p++,layer=1; layer;) { + assert (cmsg->p); + cmsg->p++; + switch (TYP) { + case _CMSTRUCT: + layer++; + break; + case _CEND: + layer--; + break; + } + } +} +/*-------------------------------------------------------*/ +static void __far PARS_2_MESSAGE (_cmsg __far *cmsg) { + + for (;TYP != _CEND; cmsg->p++) { + switch (TYP) { + case _CBYTE: + byteTLcpy (cmsg->m+cmsg->l, OFF); + cmsg->l++; + break; + case _CWORD: + wordTLcpy (cmsg->m+cmsg->l, OFF); + cmsg->l+=2; + break; + case _CDWORD: + dwordTLcpy (cmsg->m+cmsg->l, OFF); + cmsg->l+=4; + break; + case _CSTRUCT: + if (*(CAPI_MESSAGE __far *) OFF == 0) { + *(cmsg->m+cmsg->l)='\0'; + cmsg->l++; + } + else if(**(_cstruct __far*)OFF != 0xff) { + structTLcpy (cmsg->m+cmsg->l, *(_cstruct __far*)OFF, 1+**(_cstruct __far*)OFF); + cmsg->l+=1+**(_cstruct __far*)OFF; + } + else { + _cstruct s = *(_cstruct __far*)OFF; + structTLcpy (cmsg->m+cmsg->l, s, 3+*(_cword __far*)(s+1)); + cmsg->l+= 3+*(_cword __far*)(s+1); + } + break; + case _CMSTRUCT: + /*----- Metastruktur 0 -----*/ + if (*(_cmstruct __far*)OFF == CAPI_DEFAULT) { + *(cmsg->m+cmsg->l)='\0'; + cmsg->l++; + jumpcstruct (cmsg); + } + /*----- Metastruktur wird composed -----*/ + else { + unsigned _l = cmsg->l; + unsigned _ls; + cmsg->l++; + cmsg->p++; + PARS_2_MESSAGE (cmsg); + _ls = cmsg->l-_l-1; + if (_ls < 255) + (cmsg->m+_l)[0] = (_cbyte)_ls; + else { + structTLcpyovl (cmsg->m+_l+3, cmsg->m+_l+1, _ls); + (cmsg->m+_l)[0] = 0xff; + wordTLcpy (cmsg->m+_l+1, &_ls); + cmsg->l+=2; + } + } + break; + } + } +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_CMSG_2_MESSAGE (_cmsg __far *cmsg, CAPI_MESSAGE msg) { + cmsg->m = msg; + cmsg->l = 8; + cmsg->p = 0; + cmsg->par = cpars [command_2_index (cmsg->Command,cmsg->Subcommand)]; + + PARS_2_MESSAGE (cmsg); + + wordTLcpy (msg+0, &cmsg->l); + byteTLcpy (cmsg->m+4, &cmsg->Command); + byteTLcpy (cmsg->m+5, &cmsg->Subcommand); + wordTLcpy (cmsg->m+2, &cmsg->ApplId); + wordTLcpy (cmsg->m+6, &cmsg->Messagenumber); + + return 0; +} + +/*-------------------------------------------------------*/ +static void __far MESSAGE_2_PARS (_cmsg __far *cmsg) { + for (;TYP != _CEND; cmsg->p++) { + + switch (TYP) { + case _CBYTE: + byteTRcpy (cmsg->m+cmsg->l, OFF); + cmsg->l++; + break; + case _CWORD: + wordTRcpy (cmsg->m+cmsg->l, OFF); + cmsg->l+=2; + break; + case _CDWORD: + dwordTRcpy (cmsg->m+cmsg->l, OFF); + cmsg->l+=4; + break; + case _CSTRUCT: + *(CAPI_MESSAGE __far *)OFF = cmsg->m+cmsg->l; + + if (cmsg->m[cmsg->l] != 0xff) + cmsg->l+= 1+ cmsg->m[cmsg->l]; + else + cmsg->l+= 3+ *(_cword __far *)(cmsg->m+cmsg->l+1); + break; + case _CMSTRUCT: + /*----- Metastruktur 0 -----*/ + if (cmsg->m[cmsg->l] == '\0') { + *(_cmstruct __far*)OFF = CAPI_DEFAULT; + cmsg->l++; + jumpcstruct (cmsg); + } + else { + unsigned _l = cmsg->l; + *(_cmstruct __far*)OFF = CAPI_COMPOSE; + cmsg->l = (cmsg->m+_l)[0] == 255 ? cmsg->l+3 : cmsg->l+1; + cmsg->p++; + MESSAGE_2_PARS (cmsg); + } + break; + } + } +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_MESSAGE_2_CMSG (_cmsg __far *cmsg, CAPI_MESSAGE msg) { + memset (cmsg, 0, sizeof(_cmsg)); + cmsg->m = msg; + cmsg->l = 8; + cmsg->p = 0; + byteTRcpy (cmsg->m+4, &cmsg->Command); + byteTRcpy (cmsg->m+5, &cmsg->Subcommand); + cmsg->par = cpars [command_2_index (cmsg->Command,cmsg->Subcommand)]; + + MESSAGE_2_PARS (cmsg); + + wordTRcpy (msg+0, &cmsg->l); + wordTRcpy (cmsg->m+2, &cmsg->ApplId); + wordTRcpy (cmsg->m+6, &cmsg->Messagenumber); + + return 0; +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_CMSG_ANSWER (_cmsg __far *cmsg) { + cmsg->Subcommand |= 0x01; + return 0; +} + +/*-------------------------------------------------------*/ +unsigned __far CAPI_CMSG_HEADER (_cmsg __far *cmsg, _cword _ApplId, + _cbyte _Command, _cbyte _Subcommand, + _cword _Messagenumber, _cdword _Controller) { + memset (cmsg, 0, sizeof(_cmsg)); + cmsg->ApplId = _ApplId ; + cmsg->Command = _Command ; + cmsg->Subcommand = _Subcommand ; + cmsg->Messagenumber = _Messagenumber; + cmsg->adr.adrController = _Controller ; + return 0; +} + +/*-------------------------------------------------------*/ +/*-------------------------------------------------------*/ +#if defined (CPROT) +static char *pnames[] = { + /*00*/0, + /*01*/0, + /*02*/0, + /*03*/"Controller/PLCI/NCCI", + /*04*/"AdditionalInfo", + /*05*/"B1configuration", + /*06*/"B1protocol", + /*07*/"B2configuration", + /*08*/"B2protocol", + /*09*/"B3configuration", + /*0a*/"B3protocol", + /*0b*/"BC", + /*0c*/"BChannelinformation", + /*0d*/"BProtocol", + /*0e*/"CalledPartyNumber", + /*0f*/"CalledPartySubaddress", + /*10*/"CallingPartyNumber", + /*11*/"CallingPartySubaddress", + /*12*/"CIPmask", + /*13*/"CIPmask2", + /*14*/"CIPValue", + /*15*/"Class", + /*16*/"ConnectedNumber", + /*17*/"ConnectedSubaddress", + /*18*/"Data", + /*19*/"DataHandle", + /*1a*/"DataLength", + /*1b*/"FacilityConfirmationParameter", + /*1c*/"Facilitydataarray", + /*1d*/"FacilityIndicationParameter", + /*1e*/"FacilityRequestParameter", + /*1f*/"FacilityResponseParameters", + /*20*/"FacilitySelector", + /*21*/"Flags", + /*22*/"Function", + /*23*/"HLC", + /*24*/"Info", + /*25*/"InfoElement", + /*26*/"InfoMask", + /*27*/"InfoNumber", + /*28*/"Keypadfacility", + /*29*/"LLC", + /*2a*/"ManuData", + /*2b*/"ManuID", + /*2c*/"NCPI", + /*2d*/"Reason", + /*2e*/"Reason_B3", + /*2f*/"Reject", + /*30*/"Useruserdata", +}; + +static char *mnames[] = { + 0, + "ALERT_REQ", + "CONNECT_REQ", + 0, + "DISCONNECT_REQ", + "LISTEN_REQ", + 0, + 0, + "INFO_REQ", + "FACILITY_REQ", + "SELECT_B_PROTOCOL_REQ", + "CONNECT_B3_REQ", + 0, + "DISCONNECT_B3_REQ", + 0, + "DATA_B3_REQ", + "RESET_B3_REQ", + 0, + 0, + "ALERT_CONF", + "CONNECT_CONF", + 0, + "DISCONNECT_CONF", + "LISTEN_CONF", + "MANUFACTURER_REQ", + 0, + "INFO_CONF", + "FACILITY_CONF", + "SELECT_B_PROTOCOL_CONF", + "CONNECT_B3_CONF", + 0, + "DISCONNECT_B3_CONF", + 0, + "DATA_B3_CONF", + "RESET_B3_CONF", + 0, + 0, + 0, + "CONNECT_IND", + "CONNECT_ACTIVE_IND", + "DISCONNECT_IND", + 0, + "MANUFACTURER_CONF", + 0, + "INFO_IND", + "FACILITY_IND", + 0, + "CONNECT_B3_IND", + "CONNECT_B3_ACTIVE_IND", + "DISCONNECT_B3_IND", + 0, + "DATA_B3_IND", + "RESET_B3_IND", + "CONNECT_B3_T90_ACTIVE_IND", + 0, + 0, + "CONNECT_RESP", + "CONNECT_ACTIVE_RESP", + "DISCONNECT_RESP", + 0, + "MANUFACTURER_IND", + 0, + "INFO_RESP", + "FACILITY_RESP", + 0, + "CONNECT_B3_RESP", + "CONNECT_B3_ACTIVE_RESP", + "DISCONNECT_B3_RESP", + 0, + "DATA_B3_RESP", + "RESET_B3_RESP", + "CONNECT_B3_T90_ACTIVE_RESP", + 0, + 0, + 0, + 0, + 0, + 0, + "MANUFACTURER_RESP" +}; + +static void (*signal)(char *, CAPI_PROTOCOL_TYP, CAPI_MESSAGE); +static char *buf=0, *p=0; +/*-------------------------------------------------------*/ +void bufprint (char *fmt, ...) { + va_list f; + va_start (f,fmt); + vsprintf (p,fmt,f); + va_end (f); + p+=strlen(p); +} + +static void printstructlen (_cbyte __far *m, unsigned len) { + unsigned hex = 0; + for (;len;len--,m++) + if (isalnum (*m) | *m == ' ') { + if (hex) + bufprint (">"); + bufprint ("%c", *m); + hex = 0; + } + else { + if (!hex) + bufprint ("<%02x", *m); + else + bufprint (" %02x", *m); + hex = 1; + } + if (hex) + bufprint (">"); +} + +static void printstruct (_cbyte __far *m) { + unsigned len; + if (m[0] != 0xff) { + len = m[0]; + m+=1; + } + else { + len = ((_cword __far *)(m+1))[0]; + m+=3; + } + printstructlen (m, len); +} + +/*-------------------------------------------------------*/ +#define NAME (pnames[cmsg->par[cmsg->p]]) + +static void __far PROTOCOL_MESSAGE_2_PARS (_cmsg __far *cmsg, int level) { + for (;TYP != _CEND; cmsg->p++) { + int slen = 29+3-level; + int i; + + bufprint (" "); + for (i=0; im+cmsg->l)); + cmsg->l++; + break; + case _CWORD: + bufprint ("%-*s = 0x%04x\n", slen, NAME, *(_cword __far *)(cmsg->m+cmsg->l)); + cmsg->l+=2; + break; + case _CDWORD: + if (strcmp(NAME,"Data")==0) { + bufprint ("%-*s = ", slen, NAME); + printstructlen ((_cbyte __far *)*(_cdword __far *)(cmsg->m+cmsg->l), + *(_cword __far *)(cmsg->m+cmsg->l+sizeof(_cdword))); + bufprint ("\n"); + } + else + bufprint ("%-*s = 0x%08lx\n", slen, NAME, *(_cdword __far *)(cmsg->m+cmsg->l)); + cmsg->l+=4; + break; + case _CSTRUCT: + bufprint ("%-*s = ", slen, NAME); + if (cmsg->m[cmsg->l]=='\0') + bufprint ("default"); + else + printstruct (cmsg->m+cmsg->l); + bufprint ("\n"); + if (cmsg->m[cmsg->l] != 0xff) + cmsg->l+= 1+ cmsg->m[cmsg->l]; + else + cmsg->l+= 3+ *(_cword __far *)(cmsg->m+cmsg->l+1); + + break; + + case _CMSTRUCT: + /*----- Metastruktur 0 -----*/ + if (cmsg->m[cmsg->l] == '\0') { + bufprint ("%-*s = default\n", slen, NAME); + cmsg->l++; + jumpcstruct (cmsg); + } + else { + char *name = NAME; + unsigned _l = cmsg->l; + bufprint ("%-*s\n", slen, name); + cmsg->l = (cmsg->m+_l)[0] == 255 ? cmsg->l+3 : cmsg->l+1; + cmsg->p++; + PROTOCOL_MESSAGE_2_PARS (cmsg, level+1); + } + break; + } + } +} +/*-------------------------------------------------------*/ +#ifndef NOCLOCK +#include +#endif +void __far CAPI_PROTOCOL_INIT (char *_buf, void (*_signal)(char *, CAPI_PROTOCOL_TYP, CAPI_MESSAGE)) { + +#ifndef NOCLOCK + time_t ltime; + char *date; +#endif + + buf = _buf; + signal = _signal; + p = buf; p[0]=0; + if (buf==NULL||signal==NULL) return; + + bufprint ("+---------------------------------------------------------------------\n"); + bufprint ("| COMMON-ISDN-API Development Kit AVM-Berlin Version 2.0\n"); + bufprint ("|\n"); +#ifndef NOCLOCK + time (<ime); + date = ctime (<ime); + date[24]='\0'; + bufprint ("|%*s\n", 69/2 + strlen(date)/2, date); +#endif + bufprint ("+---------------------------------------------------------------------\n"); + (*signal)(buf, CAPI_PROTOCOL_HEADER, NULL); + p = buf; + p[0]=0; +} + +/*-------------------------------------------------------*/ +void __far CAPI_PROTOCOL_TEXT (char *fmt, ...) { + va_list f; + if (buf==NULL||signal==NULL) return; + p = buf; p[0]=0; + va_start (f,fmt); + vsprintf (p,fmt,f); + va_end (f); + (*signal)(p, CAPI_PROTOCOL_TXT, NULL); +} + +/*-------------------------------------------------------*/ +void __far CAPI_PROTOCOL_MESSAGE (CAPI_MESSAGE msg) { + +#ifndef NOCLOCK + clock_t lclock; +#endif + _cmsg cmsg; + p = buf; + p[0]=0; + if (buf==NULL || signal==NULL) return; + + cmsg.m = msg; + cmsg.l = 8; + cmsg.p = 0; + byteTRcpy (cmsg.m+4, &cmsg.Command); + byteTRcpy (cmsg.m+5, &cmsg.Subcommand); + cmsg.par = cpars [command_2_index (cmsg.Command,cmsg.Subcommand)]; + +#ifndef NOCLOCK + lclock = clock(); + bufprint ("\n%-26s ID=%03d #0x%04x LEN=%04d %02ld:%02ld:%02ld:%02ld\n", + mnames[command_2_index (cmsg.Command,cmsg.Subcommand)], + ((unsigned short __far *)msg)[1], + ((unsigned short __far *)msg)[3], + ((unsigned short __far *)msg)[0], + (lclock / CLOCKS_PER_SEC / 60l / 60l), + (lclock / CLOCKS_PER_SEC / 60) % 60l, + (lclock / CLOCKS_PER_SEC) % 60l, + ((lclock) % CLOCKS_PER_SEC) / 10); +#else + bufprint ("\n%-26s ID=%03d #0x%04x LEN=%04d\n", + mnames[command_2_index (cmsg.Command,cmsg.Subcommand)], + ((unsigned short __far *)msg)[1], + ((unsigned short __far *)msg)[3], + ((unsigned short __far *)msg)[0]); +#endif + + PROTOCOL_MESSAGE_2_PARS (&cmsg, 1); + (*signal)(buf, CAPI_PROTOCOL_MSG, msg); +} + +#endif diff --git a/C20LIB/VXD/CAPI20.CLB b/C20LIB/VXD/CAPI20.CLB new file mode 100644 index 0000000..9ca18c4 Binary files /dev/null and b/C20LIB/VXD/CAPI20.CLB differ diff --git a/C20LIB/VXD/CAPI20D.CLB b/C20LIB/VXD/CAPI20D.CLB new file mode 100644 index 0000000..51e63a7 Binary files /dev/null and b/C20LIB/VXD/CAPI20D.CLB differ diff --git a/C20LIB/WIN16/CAPI20L.LIB b/C20LIB/WIN16/CAPI20L.LIB new file mode 100644 index 0000000..72e9738 Binary files /dev/null and b/C20LIB/WIN16/CAPI20L.LIB differ diff --git a/C20LIB/WIN16/CAPI20LD.LIB b/C20LIB/WIN16/CAPI20LD.LIB new file mode 100644 index 0000000..dc055f6 Binary files /dev/null and b/C20LIB/WIN16/CAPI20LD.LIB differ diff --git a/C20LIB/WIN16/CAPI20S.LIB b/C20LIB/WIN16/CAPI20S.LIB new file mode 100644 index 0000000..55bf6dc Binary files /dev/null and b/C20LIB/WIN16/CAPI20S.LIB differ diff --git a/C20LIB/WIN16/CAPI20SD.LIB b/C20LIB/WIN16/CAPI20SD.LIB new file mode 100644 index 0000000..059a14f Binary files /dev/null and b/C20LIB/WIN16/CAPI20SD.LIB differ diff --git a/C20LIB/WIN16/CAPI20W.LIB b/C20LIB/WIN16/CAPI20W.LIB new file mode 100644 index 0000000..b215b5a Binary files /dev/null and b/C20LIB/WIN16/CAPI20W.LIB differ diff --git a/C20LIB/WIN32/CAP2032.LIB b/C20LIB/WIN32/CAP2032.LIB new file mode 100644 index 0000000..9f633b7 Binary files /dev/null and b/C20LIB/WIN32/CAP2032.LIB differ diff --git a/C20LIB/WIN32/CAP2032D.LIB b/C20LIB/WIN32/CAP2032D.LIB new file mode 100644 index 0000000..9e9fd6a Binary files /dev/null and b/C20LIB/WIN32/CAP2032D.LIB differ diff --git a/C20LIB/WIN32/CAPI2032.LIB b/C20LIB/WIN32/CAPI2032.LIB new file mode 100644 index 0000000..8220274 Binary files /dev/null and b/C20LIB/WIN32/CAPI2032.LIB differ diff --git a/DEBUG.DLL/DEBUG.DOC b/DEBUG.DLL/DEBUG.DOC new file mode 100644 index 0000000..84f1afa Binary files /dev/null and b/DEBUG.DLL/DEBUG.DOC differ diff --git a/DEBUG.DLL/NC.MNU b/DEBUG.DLL/NC.MNU new file mode 100644 index 0000000..610b79e --- /dev/null +++ b/DEBUG.DLL/NC.MNU @@ -0,0 +1,53 @@ +---CAPI.DLL--- +Data B3 Messages aus + patch -fcapi.dll -sTraceData -h00 +Data B3 Messages kurz (default) + patch -fcapi.dll -sTraceData -h01 +Data B3 Messages lang + patch -fcapi.dll -sTraceData -h02 + +Kein GET_ & PUT_MESSAGE (default) + patch -fcapi.dll -sTraceAll -h00 +Auch GET_ & PUT_MESSAGE Protokollieren + patch -fcapi.dll -sTraceAll -h01 + +Protokoll nur einmal ”ffnen/schlieáen (default) + patch -fcapi.dll -sCloseProt -h00 +Protokoll bei jeder Message ”ffnen/schlieáen + patch -fcapi.dll -sCloseProt -h01 +- +---CAPI20.DLL--- +Data B3 Messages aus + patch -fcapi20.dll -sTraceData -h00 +Data B3 Messages kurz (default) + patch -fcapi20.dll -sTraceData -h01 +Data B3 Messages lang + patch -fcapi20.dll -sTraceData -h02 + +Kein GET_ & PUT_MESSAGE (default) + patch -fcapi20.dll -sTraceAll -h00 +Auch GET_ & PUT_MESSAGE Protokollieren + patch -fcapi20.dll -sTraceAll -h01 + +Protokoll nur einmal ”ffnen/schlieáen (default) + patch -fcapi20.dll -sCloseProt -h00 +Protokoll bei jeder Message ”ffnen/schlieáen + patch -fcapi20.dll -sCloseProt -h01 +- +---CAPI2032.DLL--- +Data B3 Messages aus + patch -fcapi2032.dll -sTraceData -h00 +Data B3 Messages kurz (default) + patch -fcapi2032.dll -sTraceData -h01 +Data B3 Messages lang + patch -fcapi2032.dll -sTraceData -h02 + +Kein GET_ & PUT_MESSAGE (default) + patch -fcapi2032.dll -sTraceAll -h00 +Auch GET_ & PUT_MESSAGE Protokollieren + patch -fcapi2032.dll -sTraceAll -h01 + +Protokoll nur einmal ”ffnen/schlieáen (default) + patch -fcapi2032.dll -sCloseProt -h00 +Protokoll bei jeder Message ”ffnen/schlieáen + patch -fcapi2032.dll -sCloseProt -h01 diff --git a/README.TXT b/README.TXT new file mode 100644 index 0000000..aa9eaad --- /dev/null +++ b/README.TXT @@ -0,0 +1,324 @@ + + + +The COMMON ISDN API 2.0 Application Development Kit V1.6 +--------------------------------------------------------- + +This COMMON ISDN API Application Development Kit is designed for programmers +and other people who are interested in the operation of the COMMON ISDN API. + +The COMMON ISDN API 2.0 Application Development Kit supports you in +developing ISDN-based applications. It offers a good introduction into +programming for COMMON ISDN API 2.0 and demonstrates how applications and +devices communicate through a uniform, standardized software interface. The +sample code is largely operating system independent, and should be easy to +port to other platforms. This time the SDK includes complete code for the +usage of the libraries for the operation systems Dos, Windows 16 bit, +Windows 32 bit and the Windows VxD interface. + + +The COMMON ISDN API (CAPI) enables applications to operate ISDN controller +boards in a simple, consistent manner. It is designed as a standard interface +allowing unrestricted use of all functions of ISDN boards. + +Applications using CAPI will not be affected by details specific to hardware +environments or network operators, such as different manufacturers' adapters +or national D-channel protocols. Furthermore, future technical developments +in ISDN hardware will be transparent to applications using the +COMMON ISDN API. The interface therefore provides a solid basis for all +ISDN-related techniques. + +Thus, ISDN-specific applications can be built or other protocols linked to +ISDN over a defined, structured interface, which has been supported in Europe +as an ETSI standard since 1994. + +The initial intention behind COMMON ISDN API was to create a uniform, open +software interface for using ISDN with the PC. This open interface is the +hardware-independent platform for ISDN applications. A second objective +was to design the interface at a high level of abstraction in order to allow +its unrestricted use at any BRI or PRI. + + +Functional Characteristics + +The COMMON ISDN API connects any number of applications to any number of +controllers. It supports layer 1 to 3 of the OSI protocol stack. The API +rests above layer 3 as the point of access for applications and higher-layer +protocols. + +Applications and COMMON ISDN API communicate with each other by exchanging +command and data messages in message queues. When an application issues a +command to an ISDN device (driver and/or controller), for example, the +command is posted to the COMMON ISDN API's corresponding message queue. In +the opposite direction, events from an ISDN device (driver and/or controller) +are posted to the message queue of the appropriate application. + +The COMMON ISDN API Application Developing Kit gives you support in +developing ISDN based applications. When you access CAPI direct from the +application, you have to assemble correct CAPI 2.0 messages yourself and +make your own trace functions. Or you can use the Development Kit Library, +which contains functions that build the CAPI 2.0 messages for you +(CAPI20_CMSG_2_MESSAGE) out of a C-structure (_cmsg) and protocol functions +with detailed output. + + + +----------------------------------------+ + | application | + +----------------------------------------+ + | | + | V + | +-----------------------+ + | | CAPI 2.0 Development |--------> Protocol function + | | Kit library | easier handling + | +-----------------------+ ... + | | + V V + +--------------------------------------+ + | CAPI 2.0 | + | operation system specific functions | + +--------------------------------------+ + + + +Contents + +The COMMON ISDN API 2.0 Application Development Kit provides all CAPI 2.0 +functions for MS-DOS as defined in the CAPI 2.0 specification of February, +1994. Access to all parameters in CAPI messages is facilitated through +C source, library and header files. + + +The COMMON ISDN API 2.0 Application Development Kit consists of the +following components: + +1. This description. +2. The COMMON ISDN API 2.0 specification and the addenda +3. A complete development environment, including the required libraries and + header files to support all COMMON ISDN API functions. +4. Sample source codes (C and header files) including explanations of the + COMMON ISDN API functions and their use, as well as a complete sample + application. +5. The compiled sample application. + +The kit includes the following files: + + \ + + README.TXT This text. + + WHATS.NEW New features of the CAPI 2.0 Development Kit V1.4 + +\CAPISPEC\ + + CAPI20.DOC Word document containing the CAPI 2.0 specification + + ADDENDUM.DOC Word document containing the addendum to the CAPI 2.0 + specification including specifications for Windows 95 + and Windows NT + +\DEBUG.DLL\ + + CAPI11.DLL 16-bit CAPI 1.1 protocol DLL + + CAPI20.DLL 16-bit CAPI 2.0 protocol DLL + + CAPI2032.DLL 32-bit CAPI 2.0 protocol DLL + + README.TXT Installation instructions for protocol DLLs + + +\SOURCE\ + + CAPI.C CAPI 2.0 state machine, which handles all incoming messages. + CAPI.H Header file. + + MAIN.C The sample program (DEMO.EXE) built using the development + kit. Allows you to connect and send data packets and + complete files to another B-channel: writes a log file to + disk. See the source file for further information on how to + use the sample program. + FAXMAIN.C The sample program for sending and receiving FAX. + + MAIN.H The callback-functions that are used by CAPI.C are defined + here. This file is used by both MAIN.C and FAXMAIN.C. + + C20MSG.C CAPI 2.0 error messages and message names + C20MSG.H Header file. + + CONNECT.C Functions to connect and disconnect. + CONNECT.H Header file. + + CONTR.C Functions concerning information about controllers. + CONTR.H Header file. + + DATA.C Functions to transfer data over B-channels. + DATA.H Header file. + + FAX.C Functions and constants used for sending and receiving FAX + FAX.H Header file. + + ID.C Functions handling connections. + ID.H Header file. + + INIT.C Functions to initialize CAPI. + INIT.H Header file. + + OS.H Header file for operating system dependent files. + + TESTFAX.SFF Sample FAX. + + LINUTI.C Funktions that are not available with Linux. + LINUTI.H Header file. + + LINUX.MAK Make routine for the sample Linux program. + + MAKEDEMO.BAT Make routine for the sample DOS program. + MAKEDEMO.LNK Linker input file for sample DOS program + + MAKEFAX.BAT Make routine for the sample DOS program. + MAKEFAX.LNK Linker input file for sample DOS program + + MKDEM32.BAT Make routine for the sample DOS program. + MKDEM32.LNK Linker input file for sample DOS program + + MKDEMO2.BAT Make routine for the sample DOS program. + MKFAX2.BAT Make routine for the sample DOS program. + + NW_MKDMO.BAT Make routine for the sample NetWare program. + NW_DMO.RSP Response file for sample NetWare program. + NW_MKFAX.BAT Make routine for the sample NetWare program. + NW_FAX.RSP Response file for sample NetWare program. + + +\SOURCE\DOS + + DEMO.EXE DOS executable of the demo program + FAX.EXE DOS executable of the Fax-demo program + +\SOURCE\LINUX + + DEMO Linux executable of the demo program + FAXMAIN Linux executable of the Fax-demo program + +\SOURCE\OS2 + + DEMO2.EXE OS/2 executable of the demo program + FAX2.EXE OS/2 executable of the Fax-demo program + +\SOURCE\WIN32 + + DEMO32.EXE Windows 32 bit executable of the demo program + +\SOURCE\NETWARE + + DEMO.NLM NetWare NLM executable of the demo program + FAXDEMO.NLM NetWare NLM executable of the demo fax program + + +\C20LIB + + MKDOS.BAT Make routine for DOS libraries (see description in the file). + MKWIN16.BAT Make routine for Windows 16 bit libraries (see description in + the file). + MKWIN32.BAT Make routine for Windows 32 bit libraries (see description in + the file). + MKVXD.BAT Make routine for Windows 32 bit VxD libraries (see description + in the file). + MKOS2.CMD Make routine for OS/2 libraries + LINUX.MAK Make routine for Linux libraries + + MKNW.BAT Make routine for NetWare libraries + + +\C20LIB\SOURCE + + CAPI20.H Header file for all CAPI20xx librarys. + + CDOS.C C file for building the CAPI20xx libraries for DOS. + CDOS.H Header file for the DOS-specific CAPI 2.0 functions. + + CWIN16.C C-file for building the CAPI20xx libraries for Windows 16 bit. + CWIN16.H Header file for the Windows(16)-specific CAPI 2.0 functions. + + CWIN32.C C-file for building the CAPI20xx libraries for Windows 32 bit. + CWIN32.H Header file for the Windows(32)-specific CAPI 2.0 functions. + + CVXD.C C-file for building the CAPI20xx libraries for Windows VxDs. + CVXD.H Header file for the VXD-specific CAPI 2.0 functions. + + COS2.C C file for building the CAPI20xx libraries for OS/2. + COS2.H Header file for the OS/2-specific CAPI 2.0 functions. + + CLINUX.C C file for building the CAPI20xx libraries for Linux. + CLINUX.H Header file for the Linux-specific CAPI 2.0 functions. + + C_NW.C C file for building the CAPI20xx libraries for NetWare. + C_NW.H Header files for the NetWare-specific CAPI 2.0 functions + C2IMP_NW.H + C2MGR_NW.H + + FUNC.C CAPI 2.0 functions. + GCMSGDOS.C Functions specific to DOS. + GCMSGWIN.C Functions specific to Windows 16 and 32 bit. + GCMSGVXD.C Functions specific to Windows VxDs. + GCMSGOS2.C Functions specific to OS/2. + GCMSGLIN.C Functions specific to Linux. + GCMSG_NW.C Functions specific to NetWare + MSG.C Internal CAPI 2.0 Application Development Kit functions. + + +\C20LIB\DOS + This directory contains the DOS-specific builds. + + CAPI20S.LIB CAPI 2.0 development kit library for the small memory model. + CAPI20L.LIB CAPI 2.0 development kit library for the large memory model. + CAPI20SD.LIB CAPI 2.0 development kit library for the small memory model, + including protocol functions. + CAPI20LD.LIB CAPI 2.0 development kit library for the large memory model, + including protocol functions. + +\C20LIB\WIN16 + This directory contains the Windows 16 bit-specific builds. + + CAPI20S.LIB CAPI 2.0 development kit library for the small memory model. + CAPI20L.LIB CAPI 2.0 development kit library for the large memory model. + CAPI20SD.LIB CAPI 2.0 development kit library for the small memory model, + including protocol functions. + CAPI20LD.LIB CAPI 2.0 development kit library for the large memory model, + including protocol functions. + CAPI20W.LIB Windows link library for dynamically linking a manufacturer- + specific CAPI20.DLL. + +\C20LIB\WIN32 + This directory contains the Windows 32 bit-specific builds. + + CAP2032.LIB CAPI 2.0 development kit library. + CAP2032D.LIB CAPI 2.0 development kit library including protocol functions. + CAPI2032.LIB Windows link library for dynamically linking a manufacturer- + specific CAPI2032.DLL. + +\C20LIB\VXD + This directory contains the Windows 32 bit VxD-specific builds. + + CAPI20.CLB CAPI 2.0 development kit library. + CAPI20D.CLB CAPI 2.0 development kit library including protocol functions. + +\C20LIB\OS2 + This directory contains the OS/2-specific builds. + + CAPI20.LIB CAPI 2.0 development kit library. + CAPI20D.LIB CAPI 2.0 development kit library including protocol functions. + CAPI20I.LIB OS/2 link library for dynamically linking a manufacturer- + specific CAPI2032.DLL. + +\C20LIB\LINUX + This directory contains the Linux-specific builds. + + LIBC20.a CAPI 2.0 development kit library. + + +\C20LIB\NETWARE + This directory contains the NetWare-specific builds. + + CAP2032.LIB CAPI 2.0 development kit library. + CAP2032D.LIB CAPI 2.0 development kit library including protocol functions. diff --git a/SOURCE/C20MSG.C b/SOURCE/C20MSG.C new file mode 100644 index 0000000..c32a20c --- /dev/null +++ b/SOURCE/C20MSG.C @@ -0,0 +1,184 @@ +/*--------------------------------------------------------------------------*\ + + C20MSG.C Version 1.1 1995 AVM + + CAPI 2.0 Messages + +\*--------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------*\ + * Decode_Info: Returns a string with an error description + * Note: infos with values of 0x00xx are only warnings and the corresponding + * messages have been processed. + * The description for all info values but 0x34xx is taken from the CAPI 2.0 + * specification february 1994. + * The description for the 0x34xx values is taken from ETS 300 102-1/Q.931 +\*--------------------------------------------------------------------------*/ +char *Decode_Info (unsigned int Info) { + switch (Info) { + +/*-- informative values (corresponding message was processed) -----*/ + case 0x0001: return "NCPI not supported by current protocol, NCPI ignored"; + case 0x0002: return "Flags not supported by current protocol, flags ignored"; + case 0x0003: return "Alert already sent by another application"; + +/*-- error information concerning CAPI_REGISTER -----*/ + case 0x1001: return "Too many applications"; + case 0x1002: return "Logical block size to small, must be at least 128 Bytes"; + case 0x1003: return "Buffer exceeds 64 kByte"; + case 0x1004: return "Message buffer size too small, must be at least 1024 Bytes"; + case 0x1005: return "Max. number of logical connections not supported"; + case 0x1006: return "Reserved"; + case 0x1007: return "The message could not be accepted because of an internal busy condition"; + case 0x1008: return "OS resource error (no memory ?)"; + case 0x1009: return "CAPI not installed"; + case 0x100A: return "Controller does not support external equipment"; + case 0x100B: return "Controller does only support external equipment"; + +/*-- error information concerning message exchange functions -----*/ + case 0x1101: return "Illegal application number"; + case 0x1102: return "Illegal command or subcommand or message length less than 12 bytes"; + case 0x1103: return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; + case 0x1104: return "Queue is empty"; + case 0x1105: return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; + case 0x1106: return "Unknown notification parameter"; + case 0x1107: return "The Message could not be accepted because of an internal busy condition"; + case 0x1108: return "OS Resource error (no memory ?)"; + case 0x1109: return "CAPI not installed"; + case 0x110A: return "Controller does not support external equipment"; + case 0x110B: return "Controller does only support external equipment"; + +/*-- error information concerning resource / coding problems -----*/ + case 0x2001: return "Message not supported in current state"; + case 0x2002: return "Illegal Controller / PLCI / NCCI"; + case 0x2003: return "Out of PLCI"; + case 0x2004: return "Out of NCCI"; + case 0x2005: return "Out of LISTEN"; + case 0x2006: return "Out of FAX resources (protocol T.30)"; + case 0x2007: return "Illegal message parameter coding"; + +/*-- error information concerning requested services -----*/ + case 0x3001: return "B1 protocol not supported"; + case 0x3002: return "B2 protocol not supported"; + case 0x3003: return "B3 protocol not supported"; + case 0x3004: return "B1 protocol parameter not supported"; + case 0x3005: return "B2 protocol parameter not supported"; + case 0x3006: return "B3 protocol parameter not supported"; + case 0x3007: return "B protocol combination not supported"; + case 0x3008: return "NCPI not supported"; + case 0x3009: return "CIP Value unknown"; + case 0x300A: return "Flags not supported (reserved bits)"; + case 0x300B: return "Facility not supported"; + case 0x300C: return "Data length not supported by current protocol"; + case 0x300D: return "Reset procedure not supported by current protocol"; + +/*-- informations about the clearing of a physical connection -----*/ + case 0x3301: return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; + case 0x3302: return "Protocol error layer 2"; + case 0x3303: return "Protocol error layer 3"; + case 0x3304: return "Another application got that call"; +/*-- T.30 specific reasons -----*/ + case 0x3311: return "Connecting not successful (remote station is no FAX G3 machine)"; + case 0x3312: return "Connecting not successful (training error)"; + case 0x3313: return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; + case 0x3314: return "Disconnected during transfer (remote abort)"; + case 0x3315: return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; + case 0x3316: return "Disconnected during transfer (local tx data underrun)"; + case 0x3317: return "Disconnected during transfer (local rx data overflow)"; + case 0x3318: return "Disconnected during transfer (local abort)"; + case 0x3319: return "Illegal parameter coding (e.g. SFF coding error)"; + +/*-- disconnect causes from the network according to ETS 300 102-1/Q.931 -----*/ + case 0x3481: return "Unallocated (unassigned) number"; + case 0x3482: return "No route to specified transit network"; + case 0x3483: return "No route to destination"; + case 0x3486: return "Channel unacceptable"; + case 0x3487: return "Call awarded and being delivered in an established channel"; + case 0x3490: return "Normal call clearing"; + case 0x3491: return "User busy"; + case 0x3492: return "No user responding"; + case 0x3493: return "No answer from user (user alerted)"; + case 0x3495: return "Call rejected"; + case 0x3496: return "Number changed"; + case 0x349A: return "Non-selected user clearing"; + case 0x349B: return "Destination out of order"; + case 0x349C: return "Invalid number format"; + case 0x349D: return "Facility rejected"; + case 0x349E: return "Response to STATUS ENQUIRY"; + case 0x349F: return "Normal, unspecified"; + case 0x34A2: return "No circuit / channel available"; + case 0x34A6: return "Network out of order"; + case 0x34A9: return "Temporary failure"; + case 0x34AA: return "Switching equipment congestion"; + case 0x34AB: return "Access information discarded"; + case 0x34AC: return "Requested circuit / channel not available"; + case 0x34AF: return "Resources unavailable, unspecified"; + case 0x34B1: return "Quality of service unavailable"; + case 0x34B2: return "Requested facility not subscribed"; + case 0x34B9: return "Bearer capability not authorized"; + case 0x34BA: return "Bearer capability not presently available"; + case 0x34BF: return "Service or option not available, unspecified"; + case 0x34C1: return "Bearer capability not implemented"; + case 0x34C2: return "Channel type not implemented"; + case 0x34C5: return "Requested facility not implemented"; + case 0x34C6: return "Only restricted digital information bearer capability is available"; + case 0x34CF: return "Service or option not implemented, unspecified"; + case 0x34D1: return "Invalid call reference value"; + case 0x34D2: return "Identified channel does not exist"; + case 0x34D3: return "A suspended call exists, but this call identity does not"; + case 0x34D4: return "Call identity in use"; + case 0x34D5: return "No call suspended"; + case 0x34D6: return "Call having the requested call identity has been cleared"; + case 0x34D8: return "Incompatible destination"; + case 0x34DB: return "Invalid transit network selection"; + case 0x34DF: return "Invalid message, unspecified"; + case 0x34E0: return "Mandatory information element is missing"; + case 0x34E1: return "Message type non-existent or not implemented"; + case 0x34E2: return "Message not compatible with call state or message type non-existent or not implemented"; + case 0x34E3: return "Information element non-existent or not implemented"; + case 0x34E4: return "Invalid information element contents"; + case 0x34E5: return "Message not compatible with call state"; + case 0x34E6: return "Recovery on timer expiry"; + case 0x34EF: return "Protocol error, unspecified"; + case 0x34FF: return "Interworking, unspecified"; + + default: return "No additional information"; + } +} + +/*---------------------------------------------------------------------------*\ + * Decode_Command: Returns a textstring with the CAPI-commandname +\*---------------------------------------------------------------------------*/ +char *Decode_Command (unsigned char Command) { + switch (Command) { + case 0x01: return "ALERT"; + case 0x02: return "CONNECT"; + case 0x03: return "CONNECT_ACTIVE"; + case 0x04: return "DISCONNECT"; + case 0x05: return "LISTEN"; + case 0x08: return "INFO"; + case 0x41: return "SELECT_B_PROTOCOL"; + case 0x80: return "FACILITY"; + case 0x82: return "CONNECT_B3"; + case 0x83: return "CONNECT_B3_ACTIVE"; + case 0x84: return "DISCONNECT_B3"; + case 0x86: return "DATA_B3"; + case 0x87: return "RESET_B3"; + case 0x88: return "CONNECT_B3_T90_ACTIVE"; + case 0xff: return "MANUFACTURER"; + } + return "Error: Command undefined in function Decode_Command"; +} + +/*--------------------------------------------------------------------------*\ + * Decode_Sub: Returns a textstring with the CAPI-subcommandname +\*--------------------------------------------------------------------------*/ +char *Decode_Sub (unsigned char Sub) { + switch (Sub) { + case 0x80: return "REQ"; /*----- Request -----*/ + case 0x81: return "CONF"; /*----- Confirmation -----*/ + case 0x82: return "IND"; /*----- Indication -----*/ + case 0x83: return "RESP"; /*----- Response -----*/ + } + return "Error: Subcommand undefined in function Decode_Sub"; +} diff --git a/SOURCE/C20MSG.H b/SOURCE/C20MSG.H new file mode 100644 index 0000000..8ea525f --- /dev/null +++ b/SOURCE/C20MSG.H @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------*\ + + C20MSG.H Version 1.1 1995 AVM + + CAPI 2.0 Messages + +\*--------------------------------------------------------------------------*/ +#ifndef _c20msg_h_ +#define _c20msg_h_ + + +/*--------------------------------------------------------------------------*\ + * Decode_Info: Returns a string with an error description + * Note: infos with values of 0x00xx are only warnings and the corresponding + * messages have been processed. + * The description for all info values but 0x34xx is taken from the CAPI 2.0 + * specification february 1994. + * The description for the 0x34xx values is taken from ETS 300 102-1/Q.931 +\*--------------------------------------------------------------------------*/ +char *Decode_Info (unsigned int Info); + +/*---------------------------------------------------------------------------*\ + * Decode_Command: Returns a textstring with the CAPI-commandname +\*---------------------------------------------------------------------------*/ +char *Decode_Command (unsigned char Command); + +/*--------------------------------------------------------------------------*\ + * Decode_Sub: Returns a textstring with the CAPI-subcommandname +\*--------------------------------------------------------------------------*/ +char *Decode_Sub (unsigned char Sub); + + +#endif /*----- _c20msg_h_ -----*/ diff --git a/SOURCE/CAPI.C b/SOURCE/CAPI.C new file mode 100644 index 0000000..dfb485c --- /dev/null +++ b/SOURCE/CAPI.C @@ -0,0 +1,300 @@ +/*--------------------------------------------------------------------------*\ + + CAPI.C Version 1.1 1995 AVM + + Implementation of CAPI state machine + +\*--------------------------------------------------------------------------*/ +#include + +#include "capi20.h" +#include "connect.h" +#include "data.h" +#include "init.h" +#include "capi.h" +#include "id.h" + +#define BC NULL +#define LLC NULL +#define HLC NULL +#define B1Protokoll 1 +#define B2Protokoll 1 +#define B3Protokoll 0 +#define B1Configuration NULL +#define B2Configuration NULL +#define B3Configuration NULL +#define Flags 0 +#define NCPI (_cstruct)NULL + +static _cmsg CMESSAGE; +static _cmsg __far *CMSG = &CMESSAGE; /*----- used in all requests and responses -----*/ + + +/*--------------------------------------------------------------------------*\ + * SetState: Set the state internal and informs the user +\*--------------------------------------------------------------------------*/ +static void ChangeState (ConnectionID Con, + ConnectionState State) { + + SetState (Con, State); + /*----- signal the status change to the user -----*/ + StateChange (Con, State); +} + +/*--------------------------------------------------------------------------*\ + * Handle_Indication: CAPI logic for all indications +\*--------------------------------------------------------------------------*/ +void Handle_Indication(void) { + ConnectionID Connection; + + switch (CMSG->Command) { + + case CAPI_CONNECT: + Connection = GetConnectionByPLCI (CONNECT_IND_PLCI(CMSG)); + if (Connection == INVALID_CONNECTION_ID) { + + /*----- incoming call -----*/ + Connection = AllocConnection(); + if (Connection == INVALID_CONNECTION_ID) { + + /*----- error no internal resources -----*/ + /*----- reject call -----*/ + CONNECT_RESP(CMSG, Appl_Id, CMSG->Messagenumber, CONNECT_IND_PLCI(CMSG), REJECT, + 0, 0, 0, NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, NULL); + return; + } + SetConnectionPLCI(Connection, CONNECT_IND_PLCI(CMSG)); + } + + SetCallingPartyNumberStruct (Connection, CONNECT_IND_CALLINGPARTYNUMBER(CMSG)); + + /*----- The ALERT_REQuest tells the caller that someone is listening -----*/ + /*----- for incoming calls on the line. A new timeout of 2 minutes is set -----*/ + /*----- Without the ALERT_REQuest a disconnect would be sent after -----*/ + /*----- 4 seconds with the cause "no user responding" on the caller side -----*/ + /*----- (Assumed that no CONNECT_RESPonse is sent in this time) -----*/ + /*----- If the application -----*/ + ALERT_REQ (CMSG, Appl_Id, 0, CONNECT_IND_PLCI(CMSG), + NULL, NULL, NULL, NULL); + + /*----- inform the user application -----*/ + SetState(Connection, D_ConnectPending); + IncomingCall(Connection, GetCallingPartyNumber (Connection)); + + ChangeState(Connection, D_ConnectPending); + /*----- signal incoming call to the user -----*/ + return; + + case CAPI_CONNECT_ACTIVE: + Connection = GetConnectionByPLCI (CONNECT_ACTIVE_IND_PLCI(CMSG)); + CONNECT_ACTIVE_RESP(CMSG, Appl_Id, CMSG->Messagenumber, CONNECT_ACTIVE_IND_PLCI(CMSG)); + ChangeState(Connection, D_Connected); + if (GetConnectionInitiator (Connection)) { + CONNECT_B3_REQ(CMSG, Appl_Id, 0, CONNECT_ACTIVE_IND_PLCI(CMSG), NCPI); + } + return; + + case CAPI_CONNECT_B3: + Connection = GetConnectionByPLCI (CONNECT_B3_IND_NCCI(CMSG) & 0x0000FFFF); + SetConnectionNCCI (Connection, CONNECT_B3_IND_NCCI(CMSG)); + CONNECT_B3_RESP(CMSG, Appl_Id, CMSG->Messagenumber, CONNECT_B3_IND_NCCI(CMSG), 0, NCPI); + ChangeState(Connection, B_ConnectPending); + return; + + case CAPI_CONNECT_B3_ACTIVE: + Connection = GetConnectionByNCCI (CONNECT_B3_ACTIVE_IND_NCCI(CMSG)); + SetConnectionInitiator (Connection, FALSE); + CONNECT_B3_ACTIVE_RESP(CMSG, Appl_Id, CMSG->Messagenumber, CONNECT_B3_ACTIVE_IND_NCCI(CMSG)); + ChangeState(Connection, Connected); + return; + + case CAPI_DISCONNECT_B3: + Connection = GetConnectionByNCCI(DISCONNECT_B3_IND_NCCI(CMSG)); + SetConnectionNCCI (Connection, INVAL_NCCI); + DISCONNECT_B3_RESP(CMSG, Appl_Id, CMSG->Messagenumber, DISCONNECT_B3_IND_NCCI(CMSG)); + ChangeState(Connection, D_Connected); + if (GetConnectionInitiator(Connection)) { + DISCONNECT_REQ(CMSG, Appl_Id, 0, GetConnectionPLCI(Connection), NULL, NULL, NULL, NULL); + } + return; + + case CAPI_DISCONNECT: + DISCONNECT_RESP(CMSG, Appl_Id, CMSG->Messagenumber, DISCONNECT_IND_PLCI(CMSG)); + Connection = GetConnectionByPLCI(DISCONNECT_IND_PLCI(CMSG)); + if (Connection != INVALID_CONNECTION_ID) { + ChangeState(Connection, Disconnected); + FreeConnection(Connection); + } + return; + + case CAPI_DATA_B3: + Connection = GetConnectionByNCCI(DATA_B3_IND_NCCI(CMSG)); + if (CMSG->DataLength > 0) { + int DiscardData = TRUE; + + DataAvailable(Connection, + (void __far *)DATA_B3_IND_DATA(CMSG), + DATA_B3_IND_DATALENGTH(CMSG), + DATA_B3_IND_DATAHANDLE(CMSG), + &DiscardData); + + if (DiscardData) + /*----- let CAPI free the data area immediately -----*/ + DATA_B3_RESP(CMSG, Appl_Id, CMSG->Messagenumber, DATA_B3_IND_NCCI(CMSG), DATA_B3_IND_DATAHANDLE(CMSG)); + } + return; + + case CAPI_INFO: + INFO_RESP(CMSG, Appl_Id, CMSG->Messagenumber, INFO_IND_PLCI(CMSG)); + return; + + default: + puts("Error: Indication not handled in function Handle_Indication"); + return; + } +} + +/*--------------------------------------------------------------------------*\ + * Handle_Confirmation: CAPI logic for all confirmations +\*--------------------------------------------------------------------------*/ +static void Handle_Confirmation(void) { + ConnectionID Connection; + + if (CMSG->Info > 0x00FF) { /*----- Info's with value 0x00xx are only -----*/ + /*----- warnings, the corresponding requests -----*/ + /*----- have been processed -----*/ + printf("Error: Info value 0x%x indicates error, function Handle_Confirmation\n", CMSG->Info); + + /*----- This branch is executed if an error has occurred -----*/ + + switch (CMSG->Command) { + case CAPI_CONNECT: + Connection = CMSG->Messagenumber; + ChangeState (Connection, D_ConnectPending); + ChangeState (Connection, Disconnected); + FreeConnection(Connection); + break; + + case CAPI_DATA_B3: + /*----- return the error value -----*/ + Connection = GetConnectionByNCCI(DATA_B3_CONF_NCCI(CMSG)); + DataConf(Connection, DATA_B3_CONF_DATAHANDLE(CMSG), + DATA_B3_CONF_INFO(CMSG)); + break; + + case CAPI_CONNECT_B3: + /*----- disconnect line -----*/ + Connection = GetConnectionByPLCI(CONNECT_B3_CONF_NCCI(CMSG) & 0x0000FFFF); + if (Connection == INVALID_CONNECTION_ID) + puts("Error: invalid PLCI in CONNECT_B3_CONF in function Handle_Confirmation"); + else + DISCONNECT_REQ(CMSG, Appl_Id, 0, GetConnectionPLCI(Connection), NULL, NULL, NULL, NULL); + break; + + case CAPI_DISCONNECT: + Connection = GetConnectionByPLCI(DISCONNECT_CONF_PLCI(CMSG)); + if (Connection == INVALID_CONNECTION_ID) + puts("Error: invalid PLCI in DISCONNECT_CONF in function Handle_Confirmation"); + break; + + case CAPI_DISCONNECT_B3: + Connection = GetConnectionByNCCI(DISCONNECT_B3_CONF_NCCI(CMSG)); + if (Connection == INVALID_CONNECTION_ID) + puts("Error: invalid NCCI in DISCONNECT_B3_CONF in function Handle_Confirmation"); + break; + case CAPI_LISTEN: + puts("Error: Info != 0 in LISTEN_CONF in function Handle_Confirmation"); + break; + case CAPI_INFO: + puts("Error: Info != 0 in INFO_CONF in function Handle_Confirmation"); + break; + case CAPI_ALERT: + puts("Error: Info != 0 in ALERT_CONF in function Handle_Confirmation"); + break; + } + + } else { /*----- no error -----*/ + + switch (CMSG->Command) { + case CAPI_CONNECT: + Connection = CMSG->Messagenumber; + SetConnectionPLCI(Connection, CONNECT_CONF_PLCI(CMSG)); + SetConnectionInitiator(Connection, TRUE); + ChangeState(Connection, D_ConnectPending); + return; + + case CAPI_CONNECT_B3: + Connection = GetConnectionByPLCI(CONNECT_B3_CONF_NCCI(CMSG) & 0x0000FFFF); + SetConnectionNCCI(Connection, CONNECT_B3_CONF_NCCI(CMSG)); + ChangeState(Connection, B_ConnectPending); + return; + + case CAPI_DISCONNECT: + Connection = GetConnectionByPLCI(DISCONNECT_CONF_PLCI(CMSG)); + if (Connection != INVALID_CONNECTION_ID) { + ChangeState(Connection, D_DisconnectPending); + } + return; + + case CAPI_DISCONNECT_B3: + Connection = GetConnectionByNCCI(DISCONNECT_B3_CONF_NCCI(CMSG)); + SetConnectionInitiator(Connection, TRUE); + ChangeState(Connection, B_DisconnectPending); + return; + + case CAPI_DATA_B3: + Connection = GetConnectionByNCCI(DATA_B3_CONF_NCCI(CMSG)); + DataConf(Connection, DATA_B3_CONF_DATAHANDLE(CMSG), + DATA_B3_CONF_INFO(CMSG)); + return; + case CAPI_LISTEN: + return; + case CAPI_INFO: + return; + case CAPI_ALERT: + return; + default: + puts("Error: Confirmation not handled in function Handle_Confirmation"); + return; + } + } +} + +/*--------------------------------------------------------------------------*\ + * Handle_CAPI_Msg: the main routine, checks for messages and handles them +\*--------------------------------------------------------------------------*/ +void Handle_CAPI_Msg(void) { + MESSAGE_EXCHANGE_ERROR Info; + int count; + + count=0; + do { + switch (Info = CAPI_GET_CMSG(CMSG, Appl_Id)) { + case 0x0000: /*----- a message has been read -----*/ + switch (CMSG->Subcommand) { + case CAPI_CONF: + Handle_Confirmation(); + break; + + case CAPI_IND: + Handle_Indication(); + break; + + default: /*----- neither indication nor confirmation ???? -----*/ + puts("Error: Unknown subcommand in function Handle_CAPI_Msg"); + return; + } + break; + + case 0x1104: + return; /*----- messagequeue is empty -----*/ + + default: + puts("Error: CAPI_GET_CMSG returns Info != 0 in function Handle_CAPI_Msg"); + return; + } + count++; + } while (count < 6); /*----- CAPI is checked maximal 5 times before returning -----*/ +} diff --git a/SOURCE/CAPI.H b/SOURCE/CAPI.H new file mode 100644 index 0000000..5fc4bc9 --- /dev/null +++ b/SOURCE/CAPI.H @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------*\ + + CAPI.H Version 1.1 1995 AVM + + Header file for CAPI.C + +\*--------------------------------------------------------------------------*/ +#ifndef _capi_h_ +#define _capi_h_ + + +/*--------------------------------------------------------------------------*\ + * Handle_CAPI_Msg: the main routine, checks for messages and handles them +\*--------------------------------------------------------------------------*/ +void Handle_CAPI_Msg(void); + + +#endif /*----- _capi_h_ -----*/ diff --git a/SOURCE/CONNECT.C b/SOURCE/CONNECT.C new file mode 100644 index 0000000..cf0d30d --- /dev/null +++ b/SOURCE/CONNECT.C @@ -0,0 +1,209 @@ +/*--------------------------------------------------------------------------*\ + + CONNECT.C Version 1.1 1995 AVM + + Functions concerning activation and deactivation of connections + +\*--------------------------------------------------------------------------*/ +#include +#include +#include + +#include "capi20.h" +#include "contr.h" +#include "init.h" +#include "connect.h" +#include "main.h" + +/*--------------------------------------------------------------------------*\ + * Listen: send a LISTEN_REQ + * parameters: CIPmask (which services shall be accepted) (see CAPI 2.0 spec.) + * Listen will be sent to the number of controllers specified in InitISDN. + * Listen with CIPmask = 0 results in getting no incoming calls signaled + * by CAPI. +\*--------------------------------------------------------------------------*/ +unsigned Listen(unsigned long CIPmask) { + MESSAGE_EXCHANGE_ERROR error; + _cmsg CMSG; + unsigned Controller; + unsigned numController; + + /*----- send listen to all controllers -----*/ + numController = GetNumController(); + for (Controller=1; Controller<=numController; Controller++) { + LISTEN_REQ_HEADER(&CMSG, Appl_Id, 0, Controller); + LISTEN_REQ_CIPMASK(&CMSG) = CIPmask; + if ((error = CAPI_PUT_CMSG(&CMSG)) != 0) + return error; + } + return 0; +} + +/*--------------------------------------------------------------------------*\ + * Connect: try's to connect to 'CalledPartyNumber' + * the return value of CAPI_PUT_CMSG is the same as CAPI_PUT_MESSAGE + * (defined in CAPI 2.0 spec. error class 0x11xx ) + * If CallingPartyNumber is not needed, set to NULL. + * CallingPartyNumber & CalledPartyNumber have to be zero terminated strings. + * For datatransmission set the protocols to zero, B3Configuration to NULL +\*--------------------------------------------------------------------------*/ +unsigned Connect(ConnectionID *Connection, + char *CalledPartyNumber, + char *CallingPartyNumber, + unsigned long Service, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration) { + + + _cmsg CMSG; + MESSAGE_EXCHANGE_ERROR error; + long Controller; + unsigned short CIPValue; + + assert (*Connection == INVALID_CONNECTION_ID); + + Controller = GetFreeController(); + if (Controller == INVAL_CONTROLLER) { + /*----- if no available controller use the first one for correct -----*/ + /*----- error signaling -----*/ + Controller = 1; + } + *Connection = AllocConnection(); + if (*Connection == INVALID_CONNECTION_ID) { + printf("Error: no available connection identifiers\n"); + /*----- no OS resources -----*/ + return 0x1108; + } + + /*----- use ConnectionIdentifier as Messagenumber -----*/ + CONNECT_REQ_HEADER(&CMSG, Appl_Id, (unsigned short)*Connection, Controller); + + /*----- build up service mask -----*/ + CIPValue = 0; + if (Service != 0) { + do { + if (Service & 1) break; + Service >>= 1; + CIPValue++; + } while (CIPValue<31); + } + CONNECT_REQ_CIPVALUE(&CMSG) = CIPValue; + + + SetCalledPartyNumber (*Connection, CalledPartyNumber); + SetCallingPartyNumber (*Connection, CallingPartyNumber); + + + CONNECT_REQ_CALLEDPARTYNUMBER(&CMSG) = GetCalledPartyNumberStruct(*Connection); + CONNECT_REQ_CALLINGPARTYNUMBER(&CMSG) = GetCallingPartyNumberStruct(*Connection); + CONNECT_REQ_B1PROTOCOL(&CMSG) = B1Protocol; + CONNECT_REQ_B2PROTOCOL(&CMSG) = B2Protocol; + CONNECT_REQ_B3PROTOCOL(&CMSG) = B3Protocol; + CONNECT_REQ_B3CONFIGURATION(&CMSG) = B3Configuration; + + error = CAPI_PUT_CMSG(&CMSG); + if (error != 0) { + FreeConnection (*Connection); + *Connection = INVALID_CONNECTION_ID; + printf("Connect: error in CAPI_PUT_MESSAGE\n"); + } + return error; + +/* + *all capi functions can also be called with all possible parameters specified + *direct in the function, e.g. + * + * error = CONNECT_REQ(&CMSG, Appl_Id, 0, + * Controller, CIPValue, + * CalledPartyNumber, CallingPartyNumber, + * CalledPartySubaddress, CallingPartySubaddress, + * B1Protokoll, B2Protokoll, B3Protokoll, + * B1Configuration, B2Configuration, B3Configuration, + * BC, LLC, HLC, + * NULL, NULL, NULL, NULL); + */ + +} + +/*--------------------------------------------------------------------------*\ + * Disconnect: disconnects one channel + * The ConnectionID must be valid +\*--------------------------------------------------------------------------*/ +unsigned Disconnect(ConnectionID Connection) { + _cmsg CMSG; + MESSAGE_EXCHANGE_ERROR error; + + assert (Connection != INVALID_CONNECTION_ID); + + switch (GetState(Connection)) { + case Connected: + case B_ConnectPending: + SetConnectionInitiator (Connection, TRUE); + DISCONNECT_B3_REQ_HEADER(&CMSG, Appl_Id, 0, GetConnectionNCCI (Connection)); + error = CAPI_PUT_CMSG(&CMSG); + break; + + case D_Connected: + case D_ConnectPending: + case B_DisconnectPending: + SetConnectionInitiator (Connection, TRUE); + DISCONNECT_REQ_HEADER(&CMSG, Appl_Id, 0, GetConnectionPLCI (Connection)); + error = CAPI_PUT_CMSG(&CMSG); + break; + + default: + error = 0; + break; + } + return error; +} + +/*--------------------------------------------------------------------------*\ + * IncomingCall: signals an incoming call + * This function will be executed if a CONNECT_INDication appears to + * inform the user. This function is implemented in the main program +\*--------------------------------------------------------------------------*/ +void IncomingCall(ConnectionID Connection, + char *CallingPartyNumber) { + + MainIncomingCall(Connection, CallingPartyNumber); +} + +/*--------------------------------------------------------------------------*\ + * AnswerCall: answers incoming call with the specified reject-value + * (some reject-values are defined in the req.h file) + * (for more see CAPI 2.0 spec.) +\*--------------------------------------------------------------------------*/ +unsigned AnswerCall(ConnectionID Connection, + RejectValue Reject, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration) { + + _cmsg CMSG; + + assert (Connection != INVALID_CONNECTION_ID); + + CONNECT_RESP_HEADER(&CMSG, Appl_Id, 0, GetConnectionPLCI (Connection)); + CONNECT_RESP_REJECT(&CMSG) = (unsigned short)Reject; + CONNECT_REQ_B1PROTOCOL(&CMSG) = B1Protocol; + CONNECT_REQ_B2PROTOCOL(&CMSG) = B2Protocol; + CONNECT_REQ_B3PROTOCOL(&CMSG) = B3Protocol; + CONNECT_REQ_B3CONFIGURATION(&CMSG) = B3Configuration; + + return CAPI_PUT_CMSG(&CMSG); +} + +/*--------------------------------------------------------------------------*\ + * StateChange: signals a state change on both B-channels (connected, disconnected) + * Whenever a channel changes his state this function is called + * This function is implemented in the main program +\*--------------------------------------------------------------------------*/ +void StateChange(ConnectionID Connection, + ConnectionState State) { + + MainStateChange(Connection, State); +} diff --git a/SOURCE/CONNECT.H b/SOURCE/CONNECT.H new file mode 100644 index 0000000..e0d3c98 --- /dev/null +++ b/SOURCE/CONNECT.H @@ -0,0 +1,88 @@ +/*--------------------------------------------------------------------------*\ + + CONNECT.H Version 1.1 1995 AVM + + Header file for CONNECT.C + +\*--------------------------------------------------------------------------*/ +#ifndef _connect_h_ +#define _connect_h_ + + +#include "id.h" + +/*--------------------------------------------------------------------------*\ + * Listen: send a LISTEN_REQ + * parameters: CIPmask (which services shall be accepted) (see CAPI 2.0 spec.) + * Listen will be sent to the number of controllers specified in InitISDN. + * Listen with CIPmask = 0 results in getting no incoming calls signaled + * by CAPI. +\*--------------------------------------------------------------------------*/ +#define NO_SERVICES 0x00000000 +#define ALL_SERVICES 0x1FFF03FF +#define SPEECH 0x00000002 +#define DATA_TRANSFER 0x00000004 +#define AUDIO3_1KHZ 0x00000010 +#define TELEPHONY 0x00010000 +#define FAX_GROUP2_3 0x00020000 + +unsigned Listen(unsigned long CIPmask); + +/*--------------------------------------------------------------------------*\ + * Connect: try's to connect to 'CalledPartyNumber' + * the return value of CAPI_PUT_CMSG is the same as CAPI_PUT_MESSAGE + * (defined in CAPI 2.0 spec. error class 0x11xx ) + * If CallingPartyNumber is not needed, set to NULL. + * CallingPartyNumber & CalledPartyNumber have to be zero terminated strings. + * For datatransmission set the protocols to zero, B3Configuration to NULL +\*--------------------------------------------------------------------------*/ +unsigned Connect(ConnectionID *Connection, + char *CalledPartyNumber, + char *CallingPartyNumber, + unsigned long Service, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration); + +/*--------------------------------------------------------------------------*\ + * Disconnect: disconnects one channel + * The ConnectionID must be valid +\*--------------------------------------------------------------------------*/ +unsigned Disconnect(ConnectionID Connection); + +/*--------------------------------------------------------------------------*\ + * IncomingCall: signals an incoming call + * This function will be executed if a CONNECT_INDication appears to + * inform the user. This function has to be implemented in the main program +\*--------------------------------------------------------------------------*/ +void IncomingCall(ConnectionID Connection, + char *CallingPartyNumber); + +/*--------------------------------------------------------------------------*\ + * AnswerCall: answers incoming call with the specified reject-value + * (for more see CAPI 2.0 spec.) +\*--------------------------------------------------------------------------*/ +typedef enum _RejectValue { + ACCEPT, + IGNORE, + REJECT +} RejectValue; + +unsigned AnswerCall(ConnectionID Connection, + RejectValue Reject, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration); + +/*--------------------------------------------------------------------------*\ + * StateChange: signals a state change on both B-channels (connected, disconnected) + * Whenever a channel changes his state this function is called + * This function has to be implemented in the main program +\*--------------------------------------------------------------------------*/ +void StateChange(ConnectionID Connection, + ConnectionState State); + + +#endif /*----- _connect_h_ -----*/ diff --git a/SOURCE/CONTR.C b/SOURCE/CONTR.C new file mode 100644 index 0000000..6aa1ef4 --- /dev/null +++ b/SOURCE/CONTR.C @@ -0,0 +1,58 @@ +/*--------------------------------------------------------------------------*\ + + CONTR.C Version 1.1 1995 AVM + + Functions concerning physical conntrollers + +\*--------------------------------------------------------------------------*/ +#include + +#include "contr.h" +#include "id.h" +#include "os.h" + +/*--------------------------------------------------------------------------*\ + * GetNumController: Returns the number of controllers detected by CAPI +\*--------------------------------------------------------------------------*/ +unsigned GetNumController(void) { + + unsigned short Buffer[64 / sizeof (unsigned short)]; + + /*----- retrieve the number of installed controllers -----*/ + CAPI20_GET_PROFILE (0, (unsigned char *)Buffer); + return (unsigned)Buffer[0]; +} + +/*--------------------------------------------------------------------------*\ + * GetNumOfSupportedBChannels: Returns the number of supported B-channels + * for the specified controller +\*--------------------------------------------------------------------------*/ +unsigned GetNumOfSupportedBChannels (long Controller) { + + unsigned short Buffer[64 / sizeof (unsigned short)]; + + assert (Controller != INVAL_CONTROLLER); + + /*----- retrieve controller specific information -----*/ + CAPI20_GET_PROFILE((unsigned)Controller, (unsigned char *)Buffer); + return (unsigned)Buffer[1]; +} + +/*--------------------------------------------------------------------------*\ + * GetFreeController: Returns the number of the first controller that has + * one free B-channel, or INVAL_CONTROLLER if none found. +\*--------------------------------------------------------------------------*/ +long GetFreeController(void) { + + long Controller; + int numController; + + numController = GetNumController (); + + for (Controller = 1; Controller <= numController; Controller++) { + if (GetNumOfSupportedBChannels (Controller) > GetNumberOfConnections (Controller)) { + return Controller; + } + } + return INVAL_CONTROLLER; +} diff --git a/SOURCE/CONTR.H b/SOURCE/CONTR.H new file mode 100644 index 0000000..a30b23d --- /dev/null +++ b/SOURCE/CONTR.H @@ -0,0 +1,29 @@ +/*--------------------------------------------------------------------------*\ + + CONTR.H Version 1.1 1995 AVM + + Header file for CONTR.C + +\*--------------------------------------------------------------------------*/ +#ifndef _contr_h_ +#define _contr_h_ + +/*--------------------------------------------------------------------------*\ + * GetNumController: Returns the number of controllers detected by CAPI +\*--------------------------------------------------------------------------*/ +unsigned GetNumController (void); + +/*--------------------------------------------------------------------------*\ + * GetNumOfSupportedBChannels: Returns the number of supported B-channels + * for the specified controller +\*--------------------------------------------------------------------------*/ +unsigned GetNumOfSupportedBChannels (long Controller); + +/*--------------------------------------------------------------------------*\ + * GetFreeController: Returns the number of the first controller that has + * one free B-channel, or INVAL_CONTROLLER if none found. +\*--------------------------------------------------------------------------*/ +long GetFreeController (void); + + +#endif /*----- _contr_h_ -----*/ diff --git a/SOURCE/DATA.C b/SOURCE/DATA.C new file mode 100644 index 0000000..064620b --- /dev/null +++ b/SOURCE/DATA.C @@ -0,0 +1,85 @@ +/*--------------------------------------------------------------------------*\ + + DATA.C Version 1.1 1995 AVM + + Functions concerning data transmission + +\*--------------------------------------------------------------------------*/ +#include + +#include "capi20.h" +#include "id.h" +#include "init.h" +#include "data.h" +#include "main.h" + +/*--------------------------------------------------------------------------*\ + * SendData: Sends one block with data over the specified channel +\*--------------------------------------------------------------------------*/ +unsigned SendData(ConnectionID Connection, + void __far *Data, + unsigned short DataLength, + unsigned short DataHandle) { + + _cmsg CMSG; + + assert (Connection != INVALID_CONNECTION_ID); + assert (GetState(Connection) == Connected); + + DATA_B3_REQ_HEADER(&CMSG, Appl_Id, 0, GetConnectionNCCI(Connection)); + DATA_B3_REQ_DATA(&CMSG) = (unsigned long)Data; + DATA_B3_REQ_DATALENGTH(&CMSG) = DataLength; + DATA_B3_REQ_DATAHANDLE(&CMSG) = DataHandle; + + return CAPI_PUT_CMSG(&CMSG); +} + +/*--------------------------------------------------------------------------*\ + * DataConf: signals the successful sending of a datablock + * This function is called after receiving a DATA_B3_CONFirmation. CAPI signals + * that the datablock identified by DataHandle has been sent and the memory + * area may be freed. The DataHandle is the same as specified in SendBlock. + * This function is implemented in the main program. +\*--------------------------------------------------------------------------*/ +void DataConf(ConnectionID Connection, + unsigned short DataHandle, + unsigned short Info) { + + MainDataConf(Connection, DataHandle, Info); +} + +/*--------------------------------------------------------------------------*\ + * DataAvailable: signals received data blocks + * This function is called after a DATA_B3_INDication is received. The flag + * DiscardData tells CAPI to free the memora area directly after the return + * of this function when set to TRUE (1) which is the preset. When the flag + * is set to FALSE (0) the data area MUST be freed later with ReleaseData. + * The datahandle identifies the memory area. When reaching 7 unconfirmed + * blocks, no more incoming data will be signaled until freeing at least + * one block. + * This function is implemented in the main program. +\*--------------------------------------------------------------------------*/ +void DataAvailable(ConnectionID Connection, + void __far *Data, + unsigned short DataLength, + unsigned short DataHandle, + int *DiscardData) { + + MainDataAvailable(Connection, Data, DataLength, DataHandle, DiscardData); +} + +/*--------------------------------------------------------------------------*\ + * ReleaseData: allows CAPI to reuse the memory area of the specified block. + * CAPI allows max. 7 unconfirmed Blocks. If the maximum of 7 is reached, + * no more DATA_B3_INDications will come up. +\*--------------------------------------------------------------------------*/ +unsigned ReleaseData(ConnectionID Connection, + unsigned short DataHandle) { + + _cmsg CMSG; + + assert (Connection != INVALID_CONNECTION_ID); + assert (GetState(Connection) == Connected); + + return DATA_B3_RESP(&CMSG, Appl_Id, 0, GetConnectionNCCI(Connection), DataHandle); +} diff --git a/SOURCE/DATA.H b/SOURCE/DATA.H new file mode 100644 index 0000000..6485af0 --- /dev/null +++ b/SOURCE/DATA.H @@ -0,0 +1,58 @@ +/*--------------------------------------------------------------------------*\ + + DATA.H Version 1.1 1995 AVM + + Functions concerning data transmission + +\*--------------------------------------------------------------------------*/ +#ifndef _data_h_ +#define _data_h_ + + +#define SendBlockSize 2048 /*----- must not be greater than MaxB3DataBlockSize in req.c-----*/ + +/*--------------------------------------------------------------------------*\ + * SendData: Sends one block with data over the specified channel +\*--------------------------------------------------------------------------*/ +unsigned SendData(ConnectionID Connection, + void __far *Data, + unsigned short DataLength, + unsigned short DataHandle); + +/*--------------------------------------------------------------------------*\ + * DataConf: signals the successful sending of a datablock + * This function is called after receiving a DATA_B3_CONFirmation. CAPI signals + * that the datablock identified by DataHandle has been sent and the memory + * area may be freed. The DataHandle is the same as specified in SendBlock. + * This function is implemented in the main program. +\*--------------------------------------------------------------------------*/ +void DataConf(ConnectionID Connection, + unsigned short DataHandle, + unsigned short Info); + +/*--------------------------------------------------------------------------*\ + * DataAvailable: signals received data blocks + * This function is called after a DATA_B3_INDication is received. The flag + * DiscardData tells CAPI to free the memora area directly after the return + * of this function when set to TRUE (1) which is the preset. When the flag + * is set to FALSE (0) the data area MUST be freed later with ReleaseData. + * The datahandle identifies the memory area. When reaching 7 unconfirmed + * blocks, no more incoming data will be signaled until freeing at least + * one block. + * This function is implemented in the main program. +\*--------------------------------------------------------------------------*/ +void DataAvailable(ConnectionID Connection, + void __far *Data, + unsigned short DataLength, + unsigned short DataHandle, + int *DiscardData); + +/*--------------------------------------------------------------------------*\ + * ReleaseData: allows CAPI to reuse the memory area of the specified block. + * CAPI allows max. 7 unconfirmed Blocks. If the maximum of 7 is reached, + * no more DATA_B3_INDications will come up. +\*--------------------------------------------------------------------------*/ +unsigned ReleaseData(ConnectionID Connection, + unsigned short DataHandle); + +#endif /*----- _data_h_ -----*/ diff --git a/SOURCE/DEMO.PRT b/SOURCE/DEMO.PRT new file mode 100644 index 0000000..95811c7 --- /dev/null +++ b/SOURCE/DEMO.PRT @@ -0,0 +1,42 @@ ++--------------------------------------------------------------------- +| COMMON-ISDN-API Development Kit AVM-Berlin Version 2.0 +| +| Wed Feb 11 16:58:21 1998 ++--------------------------------------------------------------------- + +CONNECT_REQ ID=001 #0x0000 LEN=0040 00:00:02:36 + Controller/PLCI/NCCI = 0x00000001 + CIPValue = 0x0002 + CalledPartyNumber = <80>803 + CallingPartyNumber = default + CalledPartySubaddress = default + CallingPartySubaddress = default + BProtocol + B1protocol = 0x0000 + B2protocol = 0x0000 + B3protocol = 0x0000 + B1configuration = default + B2configuration = default + B3configuration = default + BC = default + LLC = default + HLC = default + AdditionalInfo + BChannelinformation = default + Keypadfacility = default + Useruserdata = default + Facilitydataarray = default + +CONNECT_CONF ID=001 #0x0000 LEN=0014 00:00:02:42 + Controller/PLCI/NCCI = 0x00000101 + Info = 0x0000 +***** state change slot 0 ID 0: D_ConnectPending ***** + +DISCONNECT_IND ID=001 #0x0002 LEN=0014 00:00:07:36 + Controller/PLCI/NCCI = 0x00000101 + Reason = 0x3301 +Reason 0x3301: Protocol error layer 1 (broken line or B-channel removed by signalling protocol) + +DISCONNECT_RESP ID=001 #0x0002 LEN=0012 00:00:07:42 + Controller/PLCI/NCCI = 0x00000101 +***** state change slot 0 ID 0: Disconnected ***** diff --git a/SOURCE/DOS/DEMO.PRT b/SOURCE/DOS/DEMO.PRT new file mode 100644 index 0000000..2690e57 --- /dev/null +++ b/SOURCE/DOS/DEMO.PRT @@ -0,0 +1,5 @@ ++--------------------------------------------------------------------- +| COMMON-ISDN-API Development Kit AVM-Berlin Version 2.0 +| +| Wed Feb 11 16:56:29 1998 ++--------------------------------------------------------------------- diff --git a/SOURCE/FAX.C b/SOURCE/FAX.C new file mode 100644 index 0000000..edce88d --- /dev/null +++ b/SOURCE/FAX.C @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------*\ + + FAX.C Version 1.1 1995 AVM + + Functions and constants used to FAX + +\*--------------------------------------------------------------------------*/ +#include + +#include "fax.h" + +char stationID[30] = "123456789012"; +char headLine [30] = "FAX with CAPI 2.0"; + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +void SetupB3Config(B3_PROTO_FAXG3 *B3conf, + int FAX_Format ) { + + int len1, len2; + + B3conf->resolution = 0; + B3conf->format = (unsigned short)FAX_Format; + + len1 = strlen( stationID ); + B3conf->Infos[0] = (unsigned char)len1; + strcpy( (char *)&B3conf->Infos[1], stationID ); + + len2 = strlen( headLine ); + B3conf->Infos[len1 + 1] = (unsigned char)len2; + strcpy( (char *)&B3conf->Infos[len1 + 2], headLine ); + B3conf->len = (unsigned char)(2 * sizeof( unsigned short ) + len1 + len2 + 2); +} diff --git a/SOURCE/FAX.H b/SOURCE/FAX.H new file mode 100644 index 0000000..f7c138d --- /dev/null +++ b/SOURCE/FAX.H @@ -0,0 +1,54 @@ +/*--------------------------------------------------------------------------*\ + + FAX.H Version 1.1 1995 AVM + + Header file for FAX.C + +\*--------------------------------------------------------------------------*/ +#ifndef _fax_h_ +#define _fax_h_ + + +/*----- FAX Resolutions -----------------------------------------------*/ +#define FAX_STANDARD_RESOLUTION 0 +#define FAX_HIGH_RESOLUTION 1 + +/*----- FAX Formats ---------------------------------------------------*/ +#define FAX_SFF_FORMAT 0 +#define FAX_PLAIN_FORMAT 1 +#define FAX_PCX_FORMAT 2 +#define FAX_DCX_FORMAT 3 +#define FAX_TIFF_FORMAT 4 +#define FAX_ASCII_FORMAT 5 +#define FAX_EXTENDED_ASCII_FORMAT 6 +#define FAX_BINARY_FILE_TRANSFER_FORMAT 7 + + +/*----- the pragma pack (1) directive tells the compiler to pack the -----*/ +/*----- members of the structure on 1 byte boundaries. The default is 2 -----*/ +#ifdef __linux__ +typedef struct fax3proto3 +{ unsigned char len; + unsigned short resolution __attribute__ ((packed));; + unsigned short format __attribute__ ((packed));; + unsigned char Infos[100] __attribute__ ((packed));; +} B3_PROTO_FAXG3; +#else +#pragma pack (1) +typedef struct fax3proto3 +{ unsigned char len; + unsigned short resolution; + unsigned short format; + unsigned char Infos[100]; +} B3_PROTO_FAXG3; +#pragma pack () +#endif + + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +void SetupB3Config(B3_PROTO_FAXG3 *B3conf, + int FAX_Format); + + +#endif /*----- _fax_h_ -----*/ diff --git a/SOURCE/FAXMAIN.C b/SOURCE/FAXMAIN.C new file mode 100644 index 0000000..17465b3 --- /dev/null +++ b/SOURCE/FAXMAIN.C @@ -0,0 +1,748 @@ +/*--------------------------------------------------------------------------*\ + + FAXMAIN.C Version 1.1 1995 AVM + + 's'+'S' Send fax + 'r'+'R' Receive fax + +\*--------------------------------------------------------------------------*/ +#if !defined (NDEBUG) +#define DEBUG +#define CPROT +#endif + +#include "os.h" +#include +#include +#include +#include +#include + +#include "capi20.h" +#include "c20msg.h" +#include "capi.h" +#include "connect.h" +#include "contr.h" +#include "data.h" +#include "id.h" +#include "init.h" +#include "fax.h" + + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +/*----- note: you may enter your own number here, but if you -----*/ +/*----- supply a wrong number, some PBXs may reject the -----*/ +/*----- CAPI messages containing the wrong number -----*/ +/*----- e.g.: static char *CallingPartyNumber = "1234567"; -----*/ +static char *CallingPartyNumber = NULL; + +static char CalledPartyNumberArr[40]; + +#ifdef DEBUG +static char CAPI_PROT_BUF[CAPI_PROTOCOL_INIT_BUF_SIZE]; +static char ProtocolFileName[80]; +static FILE *ProtocolFile; +#endif + +#define INVALID_SLOT -1 +#define maxSlots 2 /*----- this demo program handles max. -----*/ + /*----- two connections -----*/ +static ConnectionID Slot[maxSlots]; + + +#define B1PROTOCOL 4 +#define B2PROTOCOL 4 +#define B3PROTOCOL 4 + + +#define QueueSize 8 + +typedef struct __DataElement { + char DATA[SendBlockSize]; + unsigned short DATA_LENGTH; + unsigned SENT; +} _DataElement; + +typedef struct __DataQueue { + _DataElement Element[QueueSize]; + unsigned Head; + unsigned Tail; + unsigned Fill; +} _DataQueue; + +_DataQueue Queue; + +static unsigned FileTransfer = FALSE; /*----- signals if filetransfer is in progress -----*/ +static unsigned FileReceive = FALSE; /*----- signals if filetransfer is in progress -----*/ +static FILE *File; + +/*--------------------------------------------------------------------------*\ + * Press_Key: +\*--------------------------------------------------------------------------*/ +int Press_Key(void) { + int c; + + if ((c = getch()) == 0) + c = getch()+256; + return c; +} + +/*--------------------------------------------------------------------------*\ + * GetSlot: returns the slotnumber of the ConnectionID or INVALID_SLOT +\*--------------------------------------------------------------------------*/ +int GetSlot(ConnectionID Con) { + int x; + + for (x=0; x= QueueSize) Queue.Tail = 0; + Queue.Fill--; + } +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** datablock slot %d ID %d handle %d has been sent *****\n", + GetSlot(Connection), Connection, DataHandle); +# endif +} + +/*--------------------------------------------------------------------------*\ + * MainStateChange: signals a state change on both B-channels (connected, + * disconnected). Whenever a channel changes his state this function is called +\*--------------------------------------------------------------------------*/ +void MainStateChange(ConnectionID Connection, + ConnectionState State) { + int index; + + assert (Connection != INVALID_CONNECTION_ID); + + + index = GetSlot(Connection); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** state change slot %d ID %d: %s *****\n", index, Connection, + ConnectionStateString[State]); +# endif + + if (State == Disconnected) { + FreeSlot(index); + } +} + +/*--------------------------------------------------------------------------*\ + * MainIncomingCall: signals an incoming call + * This function will be executed if a CONNECT_INDication appears to + * inform the user. +\*--------------------------------------------------------------------------*/ +void MainIncomingCall(ConnectionID Connection, + char *CallingPartyNumber) { + + int index; + B3_PROTO_FAXG3 B3conf; + + assert (Connection != INVALID_CONNECTION_ID); + + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** incoming call ,ID %d, caller: \"%s\" *****\n",Connection,CallingPartyNumber); +# endif + index = AllocSlot(Connection); + + SetupB3Config( &B3conf, FAX_SFF_FORMAT); + + if (index == INVALID_SLOT) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** no free slot available, rejecting call... *****\n"); +# endif + AnswerCall(Connection, REJECT, 4, 4, 4, (_cstruct)&B3conf); + return; + } +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** call assigned to slot %d *****\n", index); +# endif + + AnswerCall(Connection, ACCEPT, 4, 4, 4, (_cstruct)&B3conf); +} + + +#ifdef DEBUG + +/*--------------------------------------------------------------------------*\ + * CAPI_PROT_HANDLE: This is a callback-function that has been specified + * with CAPI_PROTOCOL_INIT. The first parameter is a pointer to the protocol- + * message which is plain ASCII-text. The parameter t contains the type of + * the message which can be CAPI_PROTOCOL_HEADER (appears only once when + * calling CAPI_PROTOCOL_INIT), CAPI_PROTOCOL_MSG (the text contains a + * decoded CAPI-message) and CAPI_PROTOCOL_TXT (the buffers contains a debug + * message or a message sent with the function CAPI_PROTOCOL_TEXT). + * If the type of the message is CAPI_PROTOCOL_MSG, the last parameter contains + * a pointer to the decoded CAPI-message. +\*--------------------------------------------------------------------------*/ +void CAPI_PROT_HANDLE(char *Message, + CAPI_PROTOCOL_TYP t, + CAPI_MESSAGE m) { + + fprintf(ProtocolFile,"%s",Message); + if (t != CAPI_PROTOCOL_MSG) + puts(Message); + + if (t == CAPI_PROTOCOL_MSG) { + _cmsg CMSG; + + CAPI_MESSAGE_2_CMSG(&CMSG, m); + if ((FileTransfer || FileReceive) && + (CMSG.Command == CAPI_DATA_B3) && (CMSG.Info == 0) && + (CMSG.Reason == 0) && (CMSG.Reason_B3 == 0)) { + + return; + } + puts(Message); + if (CMSG.Info != 0) { + printf("Info 0x%04X: %s\n",CMSG.Info,Decode_Info(CMSG.Info)); + fprintf(ProtocolFile,"Info 0x%04X: %s\n",CMSG.Info,Decode_Info(CMSG.Info)); + } + if (CMSG.Reason != 0) { + printf("Reason 0x%04X: %s\n",CMSG.Reason,Decode_Info(CMSG.Reason)); + fprintf(ProtocolFile,"Reason 0x%04X: %s\n",CMSG.Reason,Decode_Info(CMSG.Reason)); + } + if (CMSG.Reason_B3 != 0) { + printf("Reason_B3 0x%04X: %s\n",CMSG.Reason_B3,Decode_Info(CMSG.Reason_B3)); + fprintf(ProtocolFile,"Reason_B3 0x%04X: %s\n",CMSG.Reason_B3,Decode_Info(CMSG.Reason_B3)); + } + } + +} + +/*--------------------------------------------------------------------------*\ + * Prot_Init: Initialisation of the protocol +\*--------------------------------------------------------------------------*/ +int Prot_Init(char *Filename) { + char *p; + + strcpy(ProtocolFileName, Filename); + p = strrchr(ProtocolFileName, '.'); + if (p) *p = '\0'; + strcat(ProtocolFileName, ".prt"); + + if ((ProtocolFile=fopen(ProtocolFileName, "w"))==NULL) { + printf("Can't open protocol-file !!\n"); + return FALSE; + } + CAPI_PROTOCOL_INIT(CAPI_PROT_BUF, CAPI_PROT_HANDLE); + return TRUE; +} +#endif + +/*--------------------------------------------------------------------------*\ + * The following _h functions are 'h'igh level functions for the ones + * implemented in CONNECT.C . The _h functions perform some parameter tests + * that would cause an assert on the low-level functions. +\*--------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------*\ + * Connect_h: Asks for a number to call then executes 'Connect' +\*--------------------------------------------------------------------------*/ +unsigned Connect_h(ConnectionID *Connection, + char *CallingPartyNumber, + unsigned long Service, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration) { + + if (*Connection != INVALID_CONNECTION_ID) { + printf("Connect_h: Connection is already in use\n"); + return 0xFFFF; + } + + printf("Enter Number to call: "); + fflush (stdout); + gets(CalledPartyNumberArr); + + return Connect(Connection, + CalledPartyNumberArr, + CallingPartyNumber, + Service, + B1Protocol, + B2Protocol, + B3Protocol, + B3Configuration); +} + +/*--------------------------------------------------------------------------*\ + * Disconnect_h: high level Disconnect +\*--------------------------------------------------------------------------*/ +unsigned Disconnect_h(ConnectionID Connection) { + + int index; + ConnectionState State; + + if (Connection == INVALID_CONNECTION_ID) { + printf("Disconnect_h: ConnectionID is invalid\n"); + return 0xFFFF; + } + State = GetState(Connection); + if ((State == Disconnected) || (State == D_DisconnectPending)) { + index = GetSlot(Connection); + printf("Disconnect_h: slot %d ID %d is disconnected\n",index, Connection); + return 0xFFFF; + } + return Disconnect(Connection); +} + +/*--------------------------------------------------------------------------*\ + * SendData_h: high level SendData +\*--------------------------------------------------------------------------*/ +void InitQueue(void) { + unsigned x; + + for (x=0; x 0) { + t = Queue.Tail; + do { + if (Queue.Element[t].SENT == FALSE) { + error = SendData(index, + (void __far *)Queue.Element[t].DATA, + Queue.Element[t].DATA_LENGTH, + (unsigned short)t); + + if (error != 0) { + printf("Error transfering data: 0x%04X !!!\n",error); + break; + } + Queue.Element[t].SENT = TRUE; + } + if (++t >= QueueSize) t = 0; + } while (t != Queue.Head); + } +} + +/*--------------------------------------------------------------------------*\ + * SendFax: Asks for a filename and sends it as a fax +\*--------------------------------------------------------------------------*/ +unsigned SendFax(int SlotNr) { + + char Filename[80]; + unsigned count; + int FAX_Format; + B3_PROTO_FAXG3 B3conf; + + printf("This demo program can send ASCII and FAX-format files (.sff). Filenames\n"); + printf("with extensions other than .sff will be interpreted as ASCII-files.\n"); + printf("The name of the demo-fax-file is \"TESTFAX.SFF\".\n"); + printf("Enter Filename: "); + fflush (stdout); + gets(Filename); + FAX_Format = strstr( Filename, ".sff" ) ? FAX_SFF_FORMAT : FAX_ASCII_FORMAT; + + File = fopen(Filename, "rb"); + if (! File) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** could not open file: \"%s\" *****\n",Filename); +# endif + return 1; + } +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** opening file: \"%s\" *****\n",Filename); +# endif + + InitQueue(); + + SetupB3Config( &B3conf, FAX_Format); + Connect_h(&Slot[SlotNr], + CallingPartyNumber, + SPEECH, + B1PROTOCOL, + B2PROTOCOL, + B3PROTOCOL, + (_cstruct)&B3conf); + + do { + Handle_CAPI_Msg(); + if (Slot[SlotNr] == INVALID_CONNECTION_ID) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** disconnected, please try again *****\n\n"); +# endif + fclose(File); + return 2; + } + } while (GetState(Slot[SlotNr]) != Connected); + + + FileTransfer = TRUE; + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** Starting datatransfer, press any key to stop *****\n"); + CAPI_PROTOCOL_TEXT("***** there is no protocol output to the screen during transfer *****\n"); +# endif + do { + + if ((! feof(File)) && (Queue.Fill < 7)) { /*----- max. 7 outstanding blocks supported by CAPI -----*/ + count = fread(&(Queue.Element[Queue.Head].DATA[0]), 1, SendBlockSize, File); + if (count > 0) { + Queue.Element[Queue.Head].DATA_LENGTH = (unsigned short)count; + if (++Queue.Head >= QueueSize) Queue.Head = 0; + Queue.Fill++; + } + } + if (GetState(Slot[SlotNr]) != Connected) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** connection broken *****\n"); +# endif + break; + } + if (kbhit()) { + getch(); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** interrupted by user *****\n"); +# endif + break; + } + TransferData(SlotNr); + Handle_CAPI_Msg(); + + } while (!feof(File)); + + Disconnect_h(Slot[SlotNr]); + while ((Slot[SlotNr] != INVALID_CONNECTION_ID) && (GetState(Slot[SlotNr]) != Disconnected)) { + Handle_CAPI_Msg(); +# if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +# endif + if (kbhit()) { + getch(); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** interrupted by user *****\n"); +# endif + return 4; + } + + }; + + FileTransfer = FALSE; +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** End of transfer *****\n"); +# endif + fclose(File); + return 0; +} + +/*--------------------------------------------------------------------------*\ + * ReceiveFax: Waits for incoming data and stores it to disk +\*--------------------------------------------------------------------------*/ +unsigned ReceiveFax(int SlotNr) { + + char Filename[80]; + char *p; + + printf("The default extension for the FAX-data is .sff\n"); + printf("Enter Filename where incoming data shall be saved: "); + fflush (stdout); + gets(Filename); + + p = strchr(Filename, '.'); + if (p) *p = '\0'; + strcat(Filename, ".sff"); + + + File = fopen(Filename, "wb"); + if (! File) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** could not open file: \"%s\" *****\n",Filename); +# endif + return 3; + } + printf("opening file: \"%s\"\n\n",Filename); + + InitQueue(); + + FileReceive = TRUE; + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** Waiting for data , press any key to stop *****\n"); + CAPI_PROTOCOL_TEXT("***** there is no protocol output to the screen during transfer *****\n"); +# endif + + Listen(0x1FFF03FF); + + while (GetState(Slot[SlotNr]) != Connected) { + Handle_CAPI_Msg(); + if (kbhit()) { +# if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +# endif + getch(); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** interrupted by user *****\n"); +# endif + fclose(File); + FileReceive = FALSE; + return 0; + } + } + while (GetState(Slot[SlotNr]) != INVAL_STATE) { + Handle_CAPI_Msg(); + if (kbhit()) { +# if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +# endif + getch(); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** interrupted by user *****\n"); +# endif + FileReceive = FALSE; + fclose(File); + return 0; + } + } + + FileReceive = FALSE; + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** End of FAX-receive *****\n"); +# endif + + fclose(File); + return 0; +} + +/*--------------------------------------------------------------------------*\ + * HandleKeyStroke: Checks the keyboard +\*--------------------------------------------------------------------------*/ +int HandleKeyStroke(void) { + int i; + + if (kbhit()) { + i = Press_Key(); + switch (i) { + case 27: { /*----- ESCAPE -----*/ + printf("Exit program ? y/n "); + fflush (stdout); + i = Press_Key(); + if ((i == 'y') || (i =='Y')) { + puts("Y"); + return FALSE; + } + puts("N"); + return TRUE; + } + case 's': + case 'S': + SendFax(0); + break; + case 'r': + case 'R': + ReceiveFax(0); + break; + } + } + return TRUE; +} + +/*--------------------------------------------------------------------------*\ + * Interact: main loop, checks keystrokes and CAPI-messages +\*--------------------------------------------------------------------------*/ +void Interact(void) { + int numController; + int BChannels, Contr; + + + numController = GetNumController (); + BChannels = 0; + for (Contr=1; Contr<=numController; Contr++) + BChannels += GetNumOfSupportedBChannels(Contr); + + printf("Detected %i controllers with %i B-channels overall.\n\n", + numController, BChannels); + + puts("'s'+'S' Send fax"); + puts("'r'+'R' Receive fax"); + + do { +# if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +# endif + Handle_CAPI_Msg(); + } while (HandleKeyStroke()); + + puts("\nProgram terminated\n"); +} + +/*--------------------------------------------------------------------------*\ + * Hangup: Disconnect both channels +\*--------------------------------------------------------------------------*/ +void Hangup(void) { + int i; + + + if ((Slot[0] != INVALID_CONNECTION_ID) && + (GetState(Slot[0]) != Disconnected) && + (GetState(Slot[0]) != D_DisconnectPending)) + Disconnect(Slot[0]); + + if ((Slot[1] != INVALID_CONNECTION_ID) && + (GetState(Slot[1]) != Disconnected) && + (GetState(Slot[1]) != D_DisconnectPending)) + Disconnect(Slot[1]); + + do { + Handle_CAPI_Msg(); +# if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +# endif + if (kbhit()) { + while (kbhit()) { + getch(); + } + printf("Exit program ? y/n "); + fflush (stdout); + i = Press_Key(); + if ((i == 'y') || (i =='Y')) { + puts("Y"); + return; + } + puts("N"); + } + } + while ((Slot[0] != INVALID_CONNECTION_ID) || (Slot[1] != INVALID_CONNECTION_ID)); +} + +/*--------------------------------------------------------------------------*\ + * ctrlchandler: exits on CTRL-C and CTRL-BREAK +\*--------------------------------------------------------------------------*/ +void ctrlchandler(int sig) +{ + signal( SIGINT, ctrlchandler ); + exit(0); + sig = 0; /*----- suppress warning -----*/ +} + +/*--------------------------------------------------------------------------*\ + * main: Init & exit functions +\*--------------------------------------------------------------------------*/ +#ifdef DEBUG +int main(int ac, char *av[]) { +#else +int main(void) { +#endif + + Slot[0] = INVALID_CONNECTION_ID; + Slot[1] = INVALID_CONNECTION_ID; + + if (! RegisterCAPI ()) return 1; + atexit (ReleaseCAPI); + + signal(SIGINT, ctrlchandler); + + InitConnectionIDHandling (); + + +#ifdef DEBUG + if (! Prot_Init(av[ac-1])) return 2; +#endif + +#ifdef __linux__ + init_tty(); + atexit (restore_tty); +#endif + + Interact(); + + Hangup(); + +#ifdef DEBUG + fclose(ProtocolFile); +#endif + return 0; +} diff --git a/SOURCE/ID.C b/SOURCE/ID.C new file mode 100644 index 0000000..4030945 --- /dev/null +++ b/SOURCE/ID.C @@ -0,0 +1,420 @@ +/*--------------------------------------------------------------------------*\ + + ID.C Version 1.1 1995 AVM + + Functions for ConnectionID handling + +\*--------------------------------------------------------------------------*/ +#include +#include +#include + +#include "id.h" + +/*--------------------------------------------------------------------------*\ + * typedefinitions +\*--------------------------------------------------------------------------*/ +const char *ConnectionStateString[7] = {"Disconnected", + "D_ConnectPending", + "D_Connected", + "B_ConnectPending", + "Connected", + "B_DisconnectPending", + "D_DisconnectPending"}; + +typedef struct _ConnectionDesc { + unsigned InUse; + long PLCI; + long NCCI; + long Controller; + ConnectionState State; + int Initiator; + unsigned char *CalledPartyNumberStruct; /*----- CAPI struct -----*/ + unsigned char *CallingPartyNumberStruct; /*----- CAPI struct -----*/ +} ConnectionDesc; + +static ConnectionDesc C[maxConnections] = {0}; +static unsigned char * EmptyStruct = (unsigned char *)"\0"; + +/*--------------------------------------------------------------------------*\ + * InitConnectionIDHandling: Initialisation of internal structures. Must be + * executed before using the functions in this module. +\*--------------------------------------------------------------------------*/ +void InitConnectionIDHandling (void) { + unsigned Con; + + /*----- init local data -----*/ + for (Con=0; Con 1) + return (char *)(&(C[Con].CalledPartyNumberStruct[2])); + else + return (char *)EmptyStruct; +} + +/*--------------------------------------------------------------------------*\ + * GetCalledPartyNumberStruct: Returns the CalledPartyNumber belonging to the + * specified connection as a CAPI struct. +\*--------------------------------------------------------------------------*/ +unsigned char *GetCalledPartyNumberStruct (ConnectionID Con) { + + return C[Con].CalledPartyNumberStruct; +} + +/*--------------------------------------------------------------------------*\ + * SetCallingPartyNumber: Sets the CallingPartyNumber belonging to the + * specified connection. CalledPartyNumber has to be a zero terminated string + * containing only ASCII numbers. + * CallingPartyNumber contains always the number of the party that originated + * the call, if it is not needed you dont need to set it. +\*--------------------------------------------------------------------------*/ +void SetCallingPartyNumber (ConnectionID Con, + char *CallingNumber) { + + assert (Con != INVALID_CONNECTION_ID); + assert (C[Con].InUse); + + + FreeNumberStruct (&C[Con].CallingPartyNumberStruct); + if ((CallingNumber != NULL) && (*CallingNumber != 0)) { + int len; + + len = strlen(CallingNumber); + + /*----- \xLen\x00\x80 STRING '\0' -----*/ + + C[Con].CallingPartyNumberStruct = (unsigned char *)malloc(len + 3 + 1); + assert (C[Con].CallingPartyNumberStruct != NULL); + + C[Con].CallingPartyNumberStruct[0] = (unsigned char)(len + 2); + C[Con].CallingPartyNumberStruct[1] = 0x00; + C[Con].CallingPartyNumberStruct[2] = 0x80; + strcpy ((char *)&(C[Con].CallingPartyNumberStruct[3]), CallingNumber); + } +} + +/*--------------------------------------------------------------------------*\ + * SetCallingPartyNumberStruct: Sets the CallingPartyNumber belonging to the + * specified connection. CallingStruct has to be a valid CAPI struct. +\*--------------------------------------------------------------------------*/ +void SetCallingPartyNumberStruct (ConnectionID Con, + unsigned char *CallingStruct) { + + assert (Con != INVALID_CONNECTION_ID); + assert (C[Con].InUse); + + + FreeNumberStruct (&C[Con].CallingPartyNumberStruct); + if (CallingStruct != NULL) { + /*----- two more for the length byte and '\0' -----*/ + C[Con].CallingPartyNumberStruct = (unsigned char *)malloc((size_t)(CallingStruct[0] + 2)); + assert(C[Con].CallingPartyNumberStruct != NULL); + + memcpy(C[Con].CallingPartyNumberStruct, CallingStruct, (size_t)(CallingStruct[0] + 1)); + C[Con].CallingPartyNumberStruct[CallingStruct[0] + 1] = '\0'; + } +} + +/*--------------------------------------------------------------------------*\ + * GetCallingPartyNumber: Returns the CallingPartyNumber belonging to the + * specified connection as a zero terminated string. +\*--------------------------------------------------------------------------*/ +char *GetCallingPartyNumber (ConnectionID Con) { + + if (C[Con].CallingPartyNumberStruct[0] > 2) + return (char *)&(C[Con].CallingPartyNumberStruct[3]); + else + return (char *)EmptyStruct; +} + +/*--------------------------------------------------------------------------*\ + * GetCallingPartyNumberStruct: Returns the CallingPartyNumber belonging to the + * specified connection as a CAPI struct. +\*--------------------------------------------------------------------------*/ +unsigned char *GetCallingPartyNumberStruct (ConnectionID Con) { + + return C[Con].CallingPartyNumberStruct; +} diff --git a/SOURCE/ID.H b/SOURCE/ID.H new file mode 100644 index 0000000..1f72de6 --- /dev/null +++ b/SOURCE/ID.H @@ -0,0 +1,193 @@ +/*--------------------------------------------------------------------------*\ + + ID.H Version 1.1 1995 AVM + + Header file for ID.C + +\*--------------------------------------------------------------------------*/ +#ifndef _id_h_ +#define _id_h_ + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +typedef enum _ConnectionState { + Disconnected, + D_ConnectPending, + D_Connected, + B_ConnectPending, + Connected, + B_DisconnectPending, + D_DisconnectPending +} ConnectionState; + +extern const char *ConnectionStateString[7]; + + +typedef int ConnectionID; + +#define maxConnections 8 +#define INVALID_CONNECTION_ID (-1) +#define INVAL_STATE (-1) +#define INVAL_NCCI (-1) +#define INVAL_PLCI (-1) +#define INVAL_CONTROLLER (-1) +/*--------------------------------------------------------------------------*\ + * InitConnectionIDHandling: Initialisation of internal structures. Must be + * executed before using the functions in this module. +\*--------------------------------------------------------------------------*/ +void InitConnectionIDHandling (void); + +/*--------------------------------------------------------------------------*\ + * AllocConnection: allocates one connection structure. Returns + * INVALID_CONNECTION_ID if none free. All members are resetted. +\*--------------------------------------------------------------------------*/ +ConnectionID AllocConnection (void); + +/*--------------------------------------------------------------------------*\ + * FreeConnection: frees one connection, the ConnectionID is no longer valid +\*--------------------------------------------------------------------------*/ +void FreeConnection (ConnectionID Connection); + +/*--------------------------------------------------------------------------*\ + * SetConnectionPLCI: sets the PLCI (and controller) for one connection +\*--------------------------------------------------------------------------*/ +void SetConnectionPLCI (ConnectionID Con, + long PLCI); + +/*--------------------------------------------------------------------------*\ + * GetConnectionPLCI: returns the PLCI for one connection +\*--------------------------------------------------------------------------*/ +long GetConnectionPLCI (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * GetConnectionByPLCI: Searches the connection that uses the PLCI, if none + * found, returns INVALID_CONNECTION_ID. +\*--------------------------------------------------------------------------*/ +ConnectionID GetConnectionByPLCI (long PLCI); + +/*--------------------------------------------------------------------------*\ + * SetConnectionNCCI: Sets the NCCI for one connection. +\*--------------------------------------------------------------------------*/ +void SetConnectionNCCI (ConnectionID Con, + long NCCI); + +/*--------------------------------------------------------------------------*\ + * GetConnectionNCCI: Returns the NCCI for one connection. +\*--------------------------------------------------------------------------*/ +long GetConnectionNCCI (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * GetConnectionByNCCI: Searches the connection that uses the NCCI, if none + * found, returns INVALID_CONNECTION_ID. +\*--------------------------------------------------------------------------*/ +ConnectionID GetConnectionByNCCI (long NCCI); + +/*--------------------------------------------------------------------------*\ + * GetController: Returns the controller that is used by the specified + * connection. +\*--------------------------------------------------------------------------*/ +long GetController (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * GetNumberOfConnections: Returns the number of currently active connections + * on the specified controller. +\*--------------------------------------------------------------------------*/ +unsigned GetNumberOfConnections (long Controller); + +/*--------------------------------------------------------------------------*\ + * GetState: Returns the state of the specified connection. +\*--------------------------------------------------------------------------*/ +ConnectionState GetState (ConnectionID Connection); + +/*--------------------------------------------------------------------------*\ + * SetState: Sets the state of the specified connection. +\*--------------------------------------------------------------------------*/ +void SetState (ConnectionID Connection, + ConnectionState State); + +/*--------------------------------------------------------------------------*\ + * SetConnectionInitiator: Changes the Initiator flag to the specified value +\*--------------------------------------------------------------------------*/ +void SetConnectionInitiator (ConnectionID Con, + int Initiator); + +/*--------------------------------------------------------------------------*\ + * GetConnectionInitiator: Returns the Initiator flag for the specified + * connection +\*--------------------------------------------------------------------------*/ +int GetConnectionInitiator (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * SetCalledPartyNumber: Sets the CalledPartyNumber belonging to the specified + * connection. CalledPartyNumber has to be a zero terminated string containing + * only ASCII numbers. + * Note: CalledPartyNumber has to different meanings in incoming and outgoing + * call. For the outgoing call it contains the number of the party that will + * be called, in incoming calls it contains the number that has been dialed + * by the external party. On an ISDN access with multiple numbers this + * CalledPartyNumber must be used to determine which number has been called. + * Note, that this number may contain only the last one or two digits of + * the called number, but this is enough to uniquely identify the called port. +\*--------------------------------------------------------------------------*/ +void SetCalledPartyNumber (ConnectionID Con, + char *CalledPartyNumber); + +/*--------------------------------------------------------------------------*\ + * SetCalledPartyNumberStruct: Sets the CalledPartyNumber belonging to the + * specified connection. CalledStruct has to be a valid CAPI struct. +\*--------------------------------------------------------------------------*/ +void SetCalledPartyNumberStruct (ConnectionID Con, + unsigned char *CalledPartyNumber); + +/*--------------------------------------------------------------------------*\ + * GetCalledPartyNumber: Returns the CalledPartyNumber belonging to the + * specified connection as a zero terminated string. +\*--------------------------------------------------------------------------*/ +char *GetCalledPartyNumber (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * GetCalledPartyNumberStruct: Returns the CalledPartyNumber belonging to the + * specified connection as a CAPI struct. +\*--------------------------------------------------------------------------*/ +unsigned char *GetCalledPartyNumberStruct (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * SetCallingPartyNumber: Sets the CallingPartyNumber belonging to the + * specified connection. CalledPartyNumber has to be a zero terminated string + * containing only ASCII numbers. + * CallingPartyNumber contains always the number of the party that originated + * the call, if it is not needed you dont need to set it. +\*--------------------------------------------------------------------------*/ +void SetCallingPartyNumber (ConnectionID Con, + char *CallingPartyNumber); + +/*--------------------------------------------------------------------------*\ + * SetCallingPartyNumberStruct: Sets the CallingPartyNumber belonging to the + * specified connection. CallingStruct has to be a valid CAPI struct. +\*--------------------------------------------------------------------------*/ +void SetCallingPartyNumberStruct (ConnectionID Con, + unsigned char *CallingPartyNumber); + +/*--------------------------------------------------------------------------*\ + * GetCallingPartyNumber: Returns the CallingPartyNumber belonging to the + * specified connection as a zero terminated string. +\*--------------------------------------------------------------------------*/ +char *GetCallingPartyNumber (ConnectionID Con); + +/*--------------------------------------------------------------------------*\ + * GetCallingPartyNumberStruct: Returns the CallingPartyNumber belonging to the + * specified connection as a CAPI struct. +\*--------------------------------------------------------------------------*/ +unsigned char *GetCallingPartyNumberStruct (ConnectionID Con); + + +#endif /*----- _id_h_ -----*/ diff --git a/SOURCE/INIT.C b/SOURCE/INIT.C new file mode 100644 index 0000000..285e985 --- /dev/null +++ b/SOURCE/INIT.C @@ -0,0 +1,95 @@ +/*--------------------------------------------------------------------------*\ + + INIT.C Version 1.1 1995 AVM + + The init function must be called before any other function that uses + CAPI messages + +\*--------------------------------------------------------------------------*/ + +#include +#include + +#include "capi20.h" +#include "init.h" +#include "contr.h" +#include "capi.h" + +#include "os.h" + +/*--------------------------------------------------------------------------*\ + * defines needed by InitISDN +\*--------------------------------------------------------------------------*/ +unsigned short Appl_Id = 0; + + +#define MaxNumBChan 2 /*----- max. number of B-channels -----*/ +#define MaxNumB3DataBlocks 7 /*----- max. number of unconfirmed B3-datablocks -----*/ + /*----- 7 is the maximal number supported by CAPI -----*/ +#define MaxB3DataBlockSize 2048 /*- max. B3-Datablocksize -----*/ + /*- 2048 is the maximum supported by CAPI -----*/ +#define MsgBufSize (1024 + (1024 * MaxNumBChan)) /*-- size of messagebuffer -----*/ + +static CAPI_MESSAGE CAPI_BUFFER = NULL; + +/*--------------------------------------------------------------------------*\ + * RegisterCAPI: Check for CAPI, allocate memory for CAPI-buffer and + * register application. This function has to be called before using any + * other CAPI functions. +\*--------------------------------------------------------------------------*/ +unsigned RegisterCAPI (void) { + CAPI_REGISTER_ERROR ErrorCode; + unsigned numController; + + if (!CAPI20_ISINSTALLED()) { + printf ("\nError: ISDN-driver not installed\n"); + return 0; + } + numController = GetNumController(); + if (numController == 0) { + printf("\nError: No ISDN-controller installed\n"); + return 0; + } +#if defined (TARGET_16BIT) + CAPI_BUFFER = malloc(MsgBufSize + (MaxNumBChan * MaxNumB3DataBlocks * MaxB3DataBlockSize)); + if (!CAPI_BUFFER) { + printf ("\nError: not enough memory in function RegisterCAPI\n"); + return 0; + } + Appl_Id = CAPI20_REGISTER(CAPI_BUFFER, MsgBufSize, MaxNumBChan, + MaxNumB3DataBlocks, MaxB3DataBlockSize, &ErrorCode); +#endif +#if defined (TARGET_32BIT) +#ifdef __linux__ + Appl_Id = CAPI20_REGISTER(MaxNumBChan, + MaxNumB3DataBlocks, MaxB3DataBlockSize, &ErrorCode); +#else + Appl_Id = CAPI20_REGISTER(MsgBufSize, MaxNumBChan, + MaxNumB3DataBlocks, MaxB3DataBlockSize, &ErrorCode); +#endif +#endif + + if (Appl_Id == 0) { + printf ("\nError: registering the application in function RegisterCAPI, "); + printf ("code: %04X\n",ErrorCode); + return 0; + } + return numController; +} + +/*--------------------------------------------------------------------------*\ + * ReleaseCAPI: deregister application +\*--------------------------------------------------------------------------*/ +void ReleaseCAPI (void) { + MESSAGE_EXCHANGE_ERROR ErrorCode; + + ErrorCode = CAPI20_RELEASE(Appl_Id); + if (ErrorCode != 0) { + printf("Error: deregistering the application in function ReleaseCAPI, "); + printf("code: 0x%04X\n",ErrorCode); + } + if (CAPI_BUFFER != NULL) { + free (CAPI_BUFFER); + CAPI_BUFFER = NULL; + } +} diff --git a/SOURCE/INIT.H b/SOURCE/INIT.H new file mode 100644 index 0000000..704d4ee --- /dev/null +++ b/SOURCE/INIT.H @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------*\ + + INIT.H Version 1.1 1995 AVM + + Header file for INIT.C + +\*--------------------------------------------------------------------------*/ +#ifndef _init_h_ +#define _init_h_ + +extern unsigned short Appl_Id; + +/*--------------------------------------------------------------------------*\ + * RegisterCAPI: Check for CAPI, allocate memory for CAPI-buffer and + * register application. This function has to be called before using any + * other CAPI functions. +\*--------------------------------------------------------------------------*/ +unsigned RegisterCAPI (void); + +/*--------------------------------------------------------------------------*\ + * ReleaseCAPI: deregister application +\*--------------------------------------------------------------------------*/ +void ReleaseCAPI (void); + + +#endif /*----- _init_h_ -----*/ diff --git a/SOURCE/LINUTI.C b/SOURCE/LINUTI.C new file mode 100644 index 0000000..0af89b2 --- /dev/null +++ b/SOURCE/LINUTI.C @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include + +static struct termios sav; + +void restore_tty(void) +{ + (void)tcsetattr(0, TCSADRAIN, &sav); +} + +void init_tty(void) +{ + struct termios t; + + (void)tcgetattr(0, &t); + sav = t; + t.c_lflag &= ~(ICANON); + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; + (void)tcsetattr(0, TCSADRAIN, &t); +} + +int kbhit(void) +{ + struct timeval tv; + fd_set ifd; + + FD_ZERO(&ifd); + FD_SET(0, &ifd); + tv.tv_sec = 0; + tv.tv_usec = 0; + + return select(1, &ifd, 0, 0, &tv) == 1; +} + +int getch(void) +{ + char c; + + fflush(stdout); + if (read(0, &c, 1) == 1) + return c; + restore_tty(); + exit(1); +} diff --git a/SOURCE/LINUTI.H b/SOURCE/LINUTI.H new file mode 100644 index 0000000..8571081 --- /dev/null +++ b/SOURCE/LINUTI.H @@ -0,0 +1,4 @@ +void restore_tty(void); +void init_tty(void); +int kbhit(void); +int getch(void); diff --git a/SOURCE/LINUX.MAK b/SOURCE/LINUX.MAK new file mode 100644 index 0000000..c596e10 --- /dev/null +++ b/SOURCE/LINUX.MAK @@ -0,0 +1,24 @@ + +CFLAGS = -O2 -W -Wall -I ../c20lib/source -g + +CFLAGS := $(CFLAGS) -DTARGET_32BIT + +DEMOCFILES = main.c c20msg.c capi.c connect.c contr.c \ + data.c id.c init.c linuti.c + +FAXCFILES = faxmain.c c20msg.c capi.c connect.c contr.c \ + data.c id.c init.c fax.c linuti.c + +DEMOOFILES = $(patsubst %.c,linux/%.o,$(DEMOCFILES)) +FAXOFILES = $(patsubst %.c,linux/%.o,$(FAXCFILES)) + +all: linux/demo linux/faxmain + +linux/demo: $(DEMOOFILES) ../c20lib/linux/libc20.a + $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +linux/faxmain: $(FAXOFILES) ../c20lib/linux/libc20.a + $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +linux/%.o: %.c + $(CC) $(CFLAGS) -c $^ -o $@ diff --git a/SOURCE/LINUX/DEMO b/SOURCE/LINUX/DEMO new file mode 100644 index 0000000..341725f Binary files /dev/null and b/SOURCE/LINUX/DEMO differ diff --git a/SOURCE/LINUX/FAXMAIN b/SOURCE/LINUX/FAXMAIN new file mode 100644 index 0000000..83a275c Binary files /dev/null and b/SOURCE/LINUX/FAXMAIN differ diff --git a/SOURCE/MAIN.C b/SOURCE/MAIN.C new file mode 100644 index 0000000..60153e8 --- /dev/null +++ b/SOURCE/MAIN.C @@ -0,0 +1,849 @@ +/*--------------------------------------------------------------------------*\ + + MAIN.C 1995 AVM + + This demo program shows how to use the CAPI 2.0 Development Kit. + When the program is started, it prompts for a number which will be + called from the CONNECT routine. After that there is the main loop where + the program handles CAPI and keystrokes. + Following is a list of available keys: + 'l' Listen (CIP mask = 0x1FFF03FF) every service will be indicated + 'L' Listen (CIP mask = 0x00000000) no incoming call will be indicated + Listen is sent to all available controllers + 'c' Connect to specified number on slot 0 + 'C' Connect to specified number on slot 1 + 'd' Disconnect slot 0 + 'D' Disconnect slot 1 + 's' Send datablock with size "SendBlockSize" on slot 0 + 'S' Send datablock with size "SendBlockSize" on slot 1 + 'f' Transfer a file on slot 0 + 'F' Transfer a file on slot 1 + 'v' Receive a file on slot 0 + 'V' Receive a file on slot 1 + 'a' Accept incoming call on slot 0 + 'A' Accept incoming call on slot 1 + 'i' Ignore incoming call on slot 0 + 'I' Ignore incoming call on slot 1 + 'r' Reject incoming call on slot 0 + 'R' Reject incoming call on slot 1 + + Next is an example how to connect the local 2 B-channels: + !! This will cost the same as one telephone call !! + After the start press 'l' so that every incoming call will be indicated. + Press 'c' and the program asks for a number to call, then dials the number. + There should be an incoming call indication on slot 1. Press 'A' and the + program answers the call on the second slot. Now everytime you send data + with 's' or 'S' there must be an data indication on the opposite slot. + Disconnect the slot with 'd' or 'D' + +\*--------------------------------------------------------------------------*/ +#if !defined (NDEBUG) +#define DEBUG +#define CPROT +#endif + +#include "os.h" +#include +#include +#include +#include +#include + +#include "capi20.h" +#include "c20msg.h" +#include "capi.h" +#include "connect.h" +#include "contr.h" +#include "data.h" +#include "id.h" +#include "init.h" + +/*--------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------*/ +static char testblock[2048]; + +/*----- note: you may enter your own number here, but if you -----*/ +/*----- supply a wrong number, some PBXs may reject the -----*/ +/*----- CAPI messages containing the wrong number -----*/ +/*----- e.g.: static char *CallingPartyNumber = "1234567"; -----*/ +static char *CallingPartyNumber = NULL; + +static char CalledPartyNumberArr[40]; + +#ifdef DEBUG +static char CAPI_PROT_BUF[CAPI_PROTOCOL_INIT_BUF_SIZE]; +static char ProtocolFileName[80]; +static FILE *ProtocolFile; +#endif + +#define INVALID_SLOT -1 +#define maxSlots 2 /*----- this demo program handles max. -----*/ + /*----- two connections -----*/ +static ConnectionID Slot[maxSlots]; + + +#define B1PROTOCOL 0 +#define B2PROTOCOL 0 +#define B3PROTOCOL 0 +#define B3CONFIGURATION NULL + + +#define QueueSize 8 + +typedef struct __DataElement { + char DATA[SendBlockSize]; + unsigned short DATA_LENGTH; + unsigned SENT; +} _DataElement; + +typedef struct __DataQueue { + _DataElement Element[QueueSize]; + unsigned Head; + unsigned Tail; + unsigned Fill; +} _DataQueue; + +_DataQueue Queue; + +static unsigned FileTransfer = FALSE; /*----- signals if filetransfer is in progress -----*/ +static unsigned FileReceive = FALSE; /*----- signals if filetransfer is in progress -----*/ +static FILE *File; + +/*--------------------------------------------------------------------------*\ + * Press_Key: +\*--------------------------------------------------------------------------*/ +int Press_Key(void) { + int c; + + if ((c = getch()) == 0) + c = getch()+256; + return c; +} + +/*--------------------------------------------------------------------------*\ + * GetSlot: returns the slotnumber of the ConnectionID or INVALID_SLOT +\*--------------------------------------------------------------------------*/ +int GetSlot(ConnectionID Con) { + int x; + + for (x=0; x= QueueSize) Queue.Tail = 0; + Queue.Fill--; + } +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** datablock slot %d ID %d handle %d has been sent *****\n", + GetSlot(Connection), Connection, DataHandle); +# endif +} + +/*--------------------------------------------------------------------------*\ + * MainStateChange: signals a state change on both B-channels (connected, + * disconnected). Whenever a channel changes his state this function is called +\*--------------------------------------------------------------------------*/ +void MainStateChange(ConnectionID Connection, + ConnectionState State) { + int index; + + assert (Connection != INVALID_CONNECTION_ID); + + + index = GetSlot(Connection); +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** state change slot %d ID %d: %s *****\n", index, Connection, + ConnectionStateString[State]); +# endif + if (State == Disconnected) { + FreeSlot(index); + } +} + +/*--------------------------------------------------------------------------*\ + * MainIncomingCall: signals an incoming call + * This function will be executed if a CONNECT_INDication appears to + * inform the user. +\*--------------------------------------------------------------------------*/ +void MainIncomingCall(ConnectionID Connection, + char *CallingPartyNumber) { + int index; + + assert (Connection != INVALID_CONNECTION_ID); + + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** incoming call ,ID %d, caller: \"%s\" *****\n",Connection,CallingPartyNumber); +# endif + index = AllocSlot(Connection); + + if (index == INVALID_SLOT) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** no free slot available, rejecting call... *****\n"); +# endif + AnswerCall(Connection, REJECT,0,0,0,NULL); + return; + } +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** call assigned to slot %d *****\n", index); +# endif +} + + +#ifdef DEBUG + +/*--------------------------------------------------------------------------*\ + * CAPI_PROT_HANDLE: This is a callback-function that has been specified + * with CAPI_PROTOCOL_INIT. The first parameter is a pointer to the protocol- + * message which is plain ASCII-text. The parameter t contains the type of + * the message which can be CAPI_PROTOCOL_HEADER (appears only once when + * calling CAPI_PROTOCOL_INIT), CAPI_PROTOCOL_MSG (the text contains a + * decoded CAPI-message) and CAPI_PROTOCOL_TXT (the buffers contains a debug + * message or a message sent with the function CAPI_PROTOCOL_TEXT). + * If the type of the message is CAPI_PROTOCOL_MSG, the last parameter contains + * a pointer to the decoded CAPI-message. +\*--------------------------------------------------------------------------*/ +void CAPI_PROT_HANDLE(char *Message, + CAPI_PROTOCOL_TYP t, + CAPI_MESSAGE m) { + + fprintf(ProtocolFile,"%s",Message); + if (t != CAPI_PROTOCOL_MSG) + puts(Message); + + if (t == CAPI_PROTOCOL_MSG) { + _cmsg CMSG; + + CAPI_MESSAGE_2_CMSG(&CMSG, m); + if ((FileTransfer || FileReceive) && + (CMSG.Command == CAPI_DATA_B3) && (CMSG.Info == 0) && + (CMSG.Reason == 0) && (CMSG.Reason_B3 == 0)) { + + return; + } + puts(Message); + if (CMSG.Info != 0) { + printf("Info 0x%04X: %s\n",CMSG.Info,Decode_Info(CMSG.Info)); + fprintf(ProtocolFile,"Info 0x%04X: %s\n",CMSG.Info,Decode_Info(CMSG.Info)); + } + if (CMSG.Reason != 0) { + printf("Reason 0x%04X: %s\n",CMSG.Reason,Decode_Info(CMSG.Reason)); + fprintf(ProtocolFile,"Reason 0x%04X: %s\n",CMSG.Reason,Decode_Info(CMSG.Reason)); + } + if (CMSG.Reason_B3 != 0) { + printf("Reason_B3 0x%04X: %s\n",CMSG.Reason_B3,Decode_Info(CMSG.Reason_B3)); + fprintf(ProtocolFile,"Reason_B3 0x%04X: %s\n",CMSG.Reason_B3,Decode_Info(CMSG.Reason_B3)); + } + } + fflush(ProtocolFile); +} + +/*--------------------------------------------------------------------------*\ + * Prot_Init: Initialisation of the protocol +\*--------------------------------------------------------------------------*/ +int Prot_Init(char *Filename) { + char *p; + + strcpy(ProtocolFileName, Filename); + p = strrchr(ProtocolFileName, '.'); + if (p) *p = '\0'; + strcat(ProtocolFileName, ".prt"); + + if ((ProtocolFile=fopen(ProtocolFileName, "w"))==NULL) { + printf("Can't open protocol-file !!\n"); + return FALSE; + } + CAPI_PROTOCOL_INIT(CAPI_PROT_BUF, CAPI_PROT_HANDLE); + return TRUE; +} +#endif + +/*--------------------------------------------------------------------------*\ + * The following _h functions are 'h'igh level functions for the ones + * implemented in CONNECT.C . The _h functions perform some parameter tests + * that would cause an assert on the low-level functions. +\*--------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------*\ + * Connect_h: Asks for a number to call then executes 'Connect' +\*--------------------------------------------------------------------------*/ +unsigned Connect_h(ConnectionID *Connection, + char *CallingPartyNumber, + unsigned long Service, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration) { + + if (*Connection != INVALID_CONNECTION_ID) { + printf("Connect_h: Connection is already in use\n"); + return 0xFFFF; + } + + printf("Enter Number: "); + fflush (stdout); + gets(CalledPartyNumberArr); + + return Connect(Connection, + CalledPartyNumberArr, + CallingPartyNumber, + Service, + B1Protocol, + B2Protocol, + B3Protocol, + B3Configuration); +} + +/*--------------------------------------------------------------------------*\ + * Disconnect_h: high level Disconnect +\*--------------------------------------------------------------------------*/ +unsigned Disconnect_h(ConnectionID Connection) { + + int index; + ConnectionState State; + + if (Connection == INVALID_CONNECTION_ID) { + printf("Disconnect_h: ConnectionID is invalid\n"); + return 0xFFFF; + } + State = GetState(Connection); + if ((State == Disconnected) || (State == D_DisconnectPending)) { + index = GetSlot(Connection); + printf("Disconnect_h: slot %d ID %d is disconnected\n",index, Connection); + return 0xFFFF; + } + return Disconnect(Connection); +} + +/*--------------------------------------------------------------------------*\ + * SendData_h: high level SendData +\*--------------------------------------------------------------------------*/ +unsigned SendData_h(ConnectionID Connection, + void __far *Data, + unsigned short DataLength, + unsigned short DataHandle) { + + int index; + ConnectionState State; + + if (Connection == INVALID_CONNECTION_ID) { + printf("SendData_h: ConnectionID is invalid\n"); + return 0xFFFF; + } + State = GetState(Connection); + if (State != Connected) { + index = GetSlot(Connection); + printf("SendData_h: slot %d ID %d is not connected\n",index, Connection); + return 0xFFFF; + } + return SendData(Connection, Data, DataLength, DataHandle); +} + +/*--------------------------------------------------------------------------*\ + * AnswerCall_h: high level AnswerCall +\*--------------------------------------------------------------------------*/ +unsigned AnswerCall_h(ConnectionID Connection, + RejectValue Reject, + unsigned short B1Protocol, + unsigned short B2Protocol, + unsigned short B3Protocol, + unsigned char __far *B3Configuration) { + + int index; + ConnectionState State; + + if (Connection == INVALID_CONNECTION_ID) { + printf("AnswerCall_h: ConnectionID is invalid\n"); + return 0xFFFF; + } + State = GetState(Connection); + if (State != D_ConnectPending) { + index = GetSlot(Connection); + printf("AnswerCall_h: slot %d ID %d is the wrong state for answering\n",index, Connection); + return 0xFFFF; + } + return AnswerCall(Connection, + Reject, + B1Protocol, + B2Protocol, + B3Protocol, + B3Configuration); +} + +/*--------------------------------------------------------------------------*\ + * InitQueue: resets the data queue +\*--------------------------------------------------------------------------*/ +void InitQueue(void) { + unsigned x; + + for (x=0; x 0) { + t = Queue.Tail; + do { + if (Queue.Element[t].SENT == FALSE) { + error = SendData(index, + (void __far *)Queue.Element[t].DATA, + Queue.Element[t].DATA_LENGTH, + (unsigned short)t); + + if (error != 0) { + printf("Error transfering data: 0x%04X !!!",error); + break; + } + Queue.Element[t].SENT = TRUE; + } + if (++t >= QueueSize) t = 0; + } while (t != Queue.Head); + } +} + +/*--------------------------------------------------------------------------*\ + * SendFile: Sends a file +\*--------------------------------------------------------------------------*/ +unsigned SendFile(int index) { + + char Filename[80]; + unsigned count; + + if (Slot[index] == INVALID_CONNECTION_ID) { + printf("SendFile: ConnectionID is invalid\n"); + return 1; + } + if (GetState(Slot[index]) != Connected) { + printf("SendFile: slot %d ID %d is not connected\n",index, Slot[index]); + return 2; + } + printf("Enter Filename: "); + fflush (stdout); + gets(Filename); + + File = fopen(Filename, "rb"); + if (! File) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** file not found *****\n"); +# endif + return 3; + } + InitQueue(); + + FileTransfer = TRUE; + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** Starting datatransfer on slot %d, press any key to stop *****\n",index); + CAPI_PROTOCOL_TEXT("***** there is no protocol output to the screen during transfer *****\n\n"); +# endif + do { + + if ((! feof(File)) && (Queue.Fill < 7)) { /*----- max. 7 outstanding blocks supported by CAPI -----*/ + count = fread(&(Queue.Element[Queue.Head].DATA[0]), 1, SendBlockSize, File); + if (count > 0) { + Queue.Element[Queue.Head].DATA_LENGTH = (unsigned short)count; + if (++Queue.Head >= QueueSize) Queue.Head = 0; + Queue.Fill++; + } + } + if (GetState(Slot[index]) != Connected) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** connection broken *****\n"); +# endif + break; + } + if (kbhit()) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** interrupted by user *****\n"); +# endif + break; + } + TransferData(index); + Handle_CAPI_Msg(); + } while (Queue.Fill > 0); + + FileTransfer = FALSE; +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** End of filetransfer *****\n"); +# endif + fclose(File); + return 0; +} + +/*--------------------------------------------------------------------------*\ + * ReceiveFile: Receives a file and writes it to disk +\*--------------------------------------------------------------------------*/ +unsigned ReceiveFile(int index) { + + char Filename[80]; + + if (Slot[index] == INVALID_CONNECTION_ID) { + printf("ReceiveFile: ConnectionID is invalid\n"); + return 1; + } + if (GetState(Slot[index]) != Connected) { + printf("ReceiveFile: slot %d ID %d is not connected\n",index, Slot[index]); + return 2; + } + printf("Enter Filename where incoming data shall be saved: "); + fflush (stdout); + gets(Filename); + + File = fopen(Filename, "wb"); + if (! File) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** could not open file *****\n"); +# endif + return 3; + } + InitQueue(); + + FileReceive = TRUE; + +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** Waiting for data on slot %d, press any key to stop *****\n",index); + CAPI_PROTOCOL_TEXT("***** there is no protocol output to the screen during transfer *****\n"); +# endif + do { + if (GetState(Slot[index]) != Connected) { +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** connection broken *****\n"); +# endif + break; + } + Handle_CAPI_Msg(); + } while (! kbhit()); + + getch(); + FileReceive = FALSE; +# ifdef DEBUG + CAPI_PROTOCOL_TEXT("***** End of filetransfer *****\n"); +# endif + fclose(File); + return 0; +} + +/*---------------------------------------------------------------------------*\ + * PrintHelp: tell the user the options +\*---------------------------------------------------------------------------*/ +static void PrintHelp (void) { + + puts("\n\n"); + puts("'ESC' Exit program"); + puts("'l' Listen (CIP mask = 0x1FFF03FF) every service will be indicated"); + puts("'L' Listen (CIP mask = 0x00000000) no incoming call will be indicated"); + puts("'c'+'C' Connect, the specified number will be called"); + puts("'d' Disconnect slot 0"); + puts("'D' Disconnect slot 1"); + puts("'s' Send datablock with size \"SendBlockSize\" on slot 0"); + puts("'S' Send datablock with size \"SendBlockSize\" on slot 1"); + puts("'f' Transfer a file on slot 0"); + puts("'F' Transfer a file on slot 1"); + puts("'v' Receive a file on slot 0"); + puts("'V' Receive a file on slot 1"); + puts("'a' Accept incoming call on slot 0"); + puts("'A' Accept incoming call on slot 1"); + puts("'i' Ignore incoming call on slot 0"); + puts("'I' Ignore incoming call on slot 1"); + puts("'r' Reject incoming call on slot 0"); + puts("'R' Reject incoming call on slot 1"); + puts("'?' Print this help screen"); +} + +/*--------------------------------------------------------------------------*\ + * HandleKeyStroke: Checks the keyboard +\*--------------------------------------------------------------------------*/ +int HandleKeyStroke(void) { + int i; + +#if defined (TARGET_NW) + delay(50); // the netware NLM has to be cooperative +#endif + if (kbhit()) { + i = Press_Key(); + switch (i) { + case 'q': + case 27: { /*----- ESCAPE -----*/ + printf("Exit program ? y/n "); + fflush (stdout); + i = Press_Key(); + if ((i == 'y') || (i =='Y')) { + puts("Y"); + return FALSE; + } + puts("N"); + return TRUE; + } + case 'l': + Listen(ALL_SERVICES); + break; + case 'L': + Listen(NO_SERVICES); + break; + case 'c': + Connect_h(&Slot[0], + CallingPartyNumber, + DATA_TRANSFER, + B1PROTOCOL, + B2PROTOCOL, + B3PROTOCOL, + B3CONFIGURATION); + break; + case 'C': + Connect_h(&Slot[1], + CallingPartyNumber, + DATA_TRANSFER, + B1PROTOCOL, + B2PROTOCOL, + B3PROTOCOL, + B3CONFIGURATION); + break; + case 'd': + Disconnect_h(Slot[0]); + break; + case 'D': + Disconnect_h(Slot[1]); + break; + case 's': + SendData_h(Slot[0], (void __far *)&testblock, SendBlockSize, 1); + break; + case 'S': + SendData_h(Slot[1], (void __far *)&testblock, SendBlockSize, 1); + break; + case 'f': + SendFile(Slot[0]); + break; + case 'F': + SendFile(Slot[1]); + break; + case 'v': + ReceiveFile(Slot[0]); + break; + case 'V': + ReceiveFile(Slot[1]); + break; + case 'a': + AnswerCall_h(Slot[0],ACCEPT,B1PROTOCOL,B2PROTOCOL,B3PROTOCOL,NULL); + break; + case 'A': + AnswerCall_h(Slot[1],ACCEPT,B1PROTOCOL,B2PROTOCOL,B3PROTOCOL,NULL); + break; + case 'i': + AnswerCall_h(Slot[0],IGNORE,0,0,0,NULL); + break; + case 'I': + AnswerCall_h(Slot[1],IGNORE,0,0,0,NULL); + break; + case 'r': + AnswerCall_h(Slot[0],REJECT,0,0,0,NULL); + break; + case 'R': + AnswerCall_h(Slot[1],REJECT,0,0,0,NULL); + break; + case 'h': + case '?': + PrintHelp(); + break; + } + } + return TRUE; +} + +/*--------------------------------------------------------------------------*\ + * Interact: main loop, checks keystrokes and CAPI-messages +\*--------------------------------------------------------------------------*/ +void Interact(void) { + int numController; + int BChannels, Contr; + + + numController = GetNumController (); + BChannels = 0; + for (Contr=1; Contr<=numController; Contr++) + BChannels += GetNumOfSupportedBChannels(Contr); + + printf("Detected %i controllers with %i B-channels overall.\n", + numController, BChannels); + PrintHelp (); + + do { + Handle_CAPI_Msg(); + } while (HandleKeyStroke()); + + puts("\nProgram terminated\n"); +} + +/*--------------------------------------------------------------------------*\ + * Hangup: Disconnect both channels +\*--------------------------------------------------------------------------*/ +void Hangup(void) { + int i; + + + if ((Slot[0] != INVALID_CONNECTION_ID) && + (GetState(Slot[0]) != Disconnected) && + (GetState(Slot[0]) != D_DisconnectPending)) + Disconnect(Slot[0]); + + if ((Slot[1] != INVALID_CONNECTION_ID) && + (GetState(Slot[1]) != Disconnected) && + (GetState(Slot[1]) != D_DisconnectPending)) + Disconnect(Slot[1]); + + do { + Handle_CAPI_Msg(); + if (kbhit()) { + while (kbhit()) { + getch(); + } + printf("Exit program ? y/n "); + fflush (stdout); + i = Press_Key(); + if ((i == 'y') || (i =='Y')) { + puts("Y"); + return; + } + puts("N"); + } + } + while ((Slot[0] != INVALID_CONNECTION_ID) || (Slot[1] != INVALID_CONNECTION_ID)); +} + +/*--------------------------------------------------------------------------*\ + * ctrlchandler: exits on CTRL-C and CTRL-BREAK +\*--------------------------------------------------------------------------*/ +void ctrlchandler(int sig) +{ + signal( SIGINT, ctrlchandler ); + exit(0); + sig = 0; /*----- suppress warning -----*/ +} + +/*--------------------------------------------------------------------------*\ + * main: Init & exit functions +\*--------------------------------------------------------------------------*/ +#ifdef DEBUG +int main(int ac, char *av[]) { +#else +int main(void) { +#endif + + Slot[0] = INVALID_CONNECTION_ID; + Slot[1] = INVALID_CONNECTION_ID; + + if (! RegisterCAPI ()) return 1; + atexit (ReleaseCAPI); + + signal(SIGINT, ctrlchandler); + + InitConnectionIDHandling (); + + +#ifdef DEBUG + if (! Prot_Init(av[ac-1])) return 2; +#endif + +#ifdef __linux__ + init_tty(); + atexit (restore_tty); +#endif + + Interact(); + + Hangup(); + +#ifdef DEBUG + fclose(ProtocolFile); +#endif + + return 0; +} diff --git a/SOURCE/MAIN.H b/SOURCE/MAIN.H new file mode 100644 index 0000000..6b03926 --- /dev/null +++ b/SOURCE/MAIN.H @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------*\ + + MAIN.H 1995 AVM + + Header file for MAIN.C and FAXMAIN.C + +\*--------------------------------------------------------------------------*/ +#ifndef _main_h_ +#define _main_h_ + + +/*--------------------------------------------------------------------------*\ + * MainDataAvailable: signals received data blocks + * This function is called after a DATA_B3_INDication is received. After + * leaving this function, the data is invalid so it must be copied for + * further processing. + * Set DiscardData to FALSE (0) if you want to free the data area later + * with ReleaseData. DiscardData is preset with TRUE (1). +\*--------------------------------------------------------------------------*/ +void MainDataAvailable(ConnectionID Connection, + void __far *Data, + _cword DataLength, + _cword DataHandle, + int *DiscardData); + +/*--------------------------------------------------------------------------*\ + * MainDataConf: signals the successful sending of a datablock + * This function is called after receiving a DATA_B3_CONFirmation. CAPI signals + * that the datablock identified by DataHandle has been sent and the memory + * area may be freed. The DataHandle is the same as specified in SendBlock. +\*--------------------------------------------------------------------------*/ +void MainDataConf(ConnectionID Connection, + _cword DataHandle, + unsigned short Info); + +/*--------------------------------------------------------------------------*\ + * MainStateChange: signals a state change on both B-channels (connected, disconnected) + * Whenever a channel changes his state this function is called +\*--------------------------------------------------------------------------*/ +void MainStateChange(ConnectionID Connection, + ConnectionState State); + +/*--------------------------------------------------------------------------*\ + * MainIncomingCall: signals an incoming call + * This function will be executed if a CONNECT_INDication appears to + * inform the user. +\*--------------------------------------------------------------------------*/ +void MainIncomingCall(ConnectionID Connection, + char *CallingPartyNumber); + + +#endif /*----- _main_h_ -----*/ diff --git a/SOURCE/MAKEDEMO.BAT b/SOURCE/MAKEDEMO.BAT new file mode 100644 index 0000000..6da570b --- /dev/null +++ b/SOURCE/MAKEDEMO.BAT @@ -0,0 +1,13 @@ +@ +@rem Make utility for building the DOS based demo.exe example for connection +@rem handling and simple file transfer. This example has to be compiled +@rem with the Microsoft Visual C compiler for DOS. +@ +@ set CAPI20LIB=..\c20lib\dos +@ set CAPI20H=..\c20lib\source +@ +@ set cl=/c /AL /W4 /I%CAPI20H% /nologo /DTARGET_16BIT + cl main.c c20msg.c capi.c connect.c contr.c data.c id.c init.c + link @makedemo.lnk + del *.obj + del *.map diff --git a/SOURCE/MAKEDEMO.LNK b/SOURCE/MAKEDEMO.LNK new file mode 100644 index 0000000..1b62537 --- /dev/null +++ b/SOURCE/MAKEDEMO.LNK @@ -0,0 +1,12 @@ +c20msg.obj + +capi.obj + +connect.obj + +contr.obj + +data.obj + +id.obj + +init.obj + +main.obj + +, +DEMO.exe +DEMO + ..\c20lib\dos\capi20ld.lib; diff --git a/SOURCE/MAKEFAX.BAT b/SOURCE/MAKEFAX.BAT new file mode 100644 index 0000000..ba8c406 --- /dev/null +++ b/SOURCE/MAKEFAX.BAT @@ -0,0 +1,13 @@ +@ +@rem Make utility for building the DOS based faxdemo.exe example for simple +@rem fax handling. This example has to be compiled with the Microsoft Visual C +@rem compiler for a DOS. +@ +@ set CAPI20LIB=..\c20lib\dos +@ set CAPI20H=..\c20lib\source +@ +@ set cl=/c /AL /W4 /I%CAPI20H% /nologo /DTARGET_16BIT + cl faxmain.c c20msg.c capi.c connect.c contr.c data.c id.c init.c fax.c + link @makefax.lnk + del *.obj + del *.map diff --git a/SOURCE/MAKEFAX.LNK b/SOURCE/MAKEFAX.LNK new file mode 100644 index 0000000..97c1524 --- /dev/null +++ b/SOURCE/MAKEFAX.LNK @@ -0,0 +1,13 @@ +c20msg.obj + +capi.obj + +connect.obj + +contr.obj + +data.obj + +id.obj + +init.obj + +fax.obj + +faxmain.obj + +, +FAX.exe +FAX +/STACK:3072 ..\c20lib\dos\capi20ld.lib; diff --git a/SOURCE/MKDEM32.BAT b/SOURCE/MKDEM32.BAT new file mode 100644 index 0000000..d972e4f --- /dev/null +++ b/SOURCE/MKDEM32.BAT @@ -0,0 +1,15 @@ +@ +@rem Make utility for building the Win32 based demo32.exe example for +@rem connection handling and simple file transfer. This example has to be +@rem compiled with the Microsoft Visual C for Win32. +@ +@ set CAPI20LIB=..\c20lib\win32 +@ set CAPI20H=..\c20lib\source +@ +@ set cl=-DWIN32 -DCON -Di386 -D_X86_ -D_NTWIN -W3 -Gs -D_DEBUG -Zi +@ set cl=%cl% /c /I%CAPI20H% /nologo /DTARGET_32BIT + cl main.c c20msg.c capi.c connect.c contr.c data.c id.c init.c + link @mkdem32.lnk + del *.obj + del *.ilk + del *.pdb diff --git a/SOURCE/MKDEM32.LNK b/SOURCE/MKDEM32.LNK new file mode 100644 index 0000000..74137e6 --- /dev/null +++ b/SOURCE/MKDEM32.LNK @@ -0,0 +1,11 @@ +-machine:i386 -debug:notmapped,full -debugtype:cv -subsystem:console kernel32.lib +-OUT:demo32.exe +c20msg.obj +capi.obj +connect.obj +contr.obj +data.obj +id.obj +init.obj +main.obj +..\c20lib\win32\cap2032d.lib diff --git a/SOURCE/MKDEMO2.CMD b/SOURCE/MKDEMO2.CMD new file mode 100644 index 0000000..fa3ad3e --- /dev/null +++ b/SOURCE/MKDEMO2.CMD @@ -0,0 +1,11 @@ +@ +@rem Make utility for building the OS/2 based demo2.exe example for connection +@rem handling and simple file transfer. This example has to be compiled +@rem with the IBM VisualAge C++ compiler. +@ +@ set CAPI20LIB=..\c20lib\os2 +@ set CAPI20H=..\c20lib\source +@ +@ set icc=/I%CAPI20H% /DTARGET_32BIT /DTARGET_OS2 + icc /Fedemo2.exe main.c c20msg.c capi.c connect.c contr.c data.c id.c init.c %CAPI20LIB%\capi20d.lib + del *.obj diff --git a/SOURCE/MKFAX2.CMD b/SOURCE/MKFAX2.CMD new file mode 100644 index 0000000..b717388 --- /dev/null +++ b/SOURCE/MKFAX2.CMD @@ -0,0 +1,11 @@ +@ +@rem Make utility for building the OS/2 based fax2.exe example for simple +@rem fax handling. This example has to be compiled with the IBM VisualAge C++ +@rem compiler. +@ +@ set CAPI20LIB=..\c20lib\os2 +@ set CAPI20H=..\c20lib\source +@ +@ set icc=/I%CAPI20H% /DTARGET_32BIT /DTARGET_OS2 + icc /Fefax2.exe faxmain.c c20msg.c capi.c connect.c contr.c data.c id.c init.c fax.c %CAPI20LIB%\capi20d.lib + del *.obj diff --git a/SOURCE/NETWARE/DEMO.NLM b/SOURCE/NETWARE/DEMO.NLM new file mode 100644 index 0000000..c1146b3 Binary files /dev/null and b/SOURCE/NETWARE/DEMO.NLM differ diff --git a/SOURCE/NETWARE/FAXDEMO.NLM b/SOURCE/NETWARE/FAXDEMO.NLM new file mode 100644 index 0000000..8cba3ba Binary files /dev/null and b/SOURCE/NETWARE/FAXDEMO.NLM differ diff --git a/SOURCE/NW_DMO.RSP b/SOURCE/NW_DMO.RSP new file mode 100644 index 0000000..988dec0 --- /dev/null +++ b/SOURCE/NW_DMO.RSP @@ -0,0 +1,41 @@ +FORMAT NOVELL NLM 'AVM CAPI 2.0 DEMO' +Name NETWARE\DEMO.NLM +OPTION Copyright 'Copyright 1998, AVM GmbH Berlin. All rights reserved.' +OPTION Version=1.00 +OPTION ScreenName 'ADK_DEMO' +OPTION ThreadName 'AVM Demo' +OPTION Stack=8k +OPTION NODEFAULTLIBS +OPTION CaseExact +OPTION Verbose +OPTION Map +OPTION MULTILoad +DEBUG ALL DEBUG NOVELL + +File netware\c20msg.obj +File netware\capi.obj +File netware\connect.obj +File netware\contr.obj +File netware\data.obj +File netware\id.obj +File netware\init.obj +File netware\main.obj + +IMPORT CAPI_Register +IMPORT CAPI_Release +IMPORT CAPI_PutMessage +IMPORT CAPI_GetMessage +IMPORT CAPI_GetProfile +IMPORT CAPI_GetManufacturer +IMPORT CAPI_GetVersion +IMPORT CAPI_GetSerialNumber + +IMPORT @%WATCOM%\NOVI\clib.imp +IMPORT @%WATCOM%\NOVI\threads.imp +IMPORT @%WATCOM%\NOVI\nlmlib.imp + +LIBRARY %WATCOM%\LIB386\NETWARE\clib3s.lib +LIBRARY %WATCOM%\LIB386\plib3s.lib +LIBRARY ..\c20lib\netware\CAP2032.LIB + +MODULE CLIB diff --git a/SOURCE/NW_FAX.RSP b/SOURCE/NW_FAX.RSP new file mode 100644 index 0000000..5498eb0 --- /dev/null +++ b/SOURCE/NW_FAX.RSP @@ -0,0 +1,41 @@ +FORMAT NOVELL NLM 'AVM CAPI 2.0 FAXDEMO' +Name NETWARE\FAXDEMO.NLM +OPTION Copyright 'Copyright 1998, AVM GmbH Berlin. All rights reserved.' +OPTION Version=1.00 +OPTION ScreenName 'AVM_FAXDEMO' +OPTION ThreadName 'AVM FaxDemo' +OPTION Stack=8k +OPTION NODEFAULTLIBS +OPTION CaseExact +OPTION Verbose +OPTION Map +DEBUG ALL DEBUG NOVELL + +File netware\c20msg.obj +File netware\capi.obj +File netware\connect.obj +File netware\contr.obj +File netware\data.obj +File netware\id.obj +File netware\init.obj +File netware\fax.obj +File netware\faxmain.obj + +IMPORT CAPI_Register +IMPORT CAPI_Release +IMPORT CAPI_PutMessage +IMPORT CAPI_GetMessage +IMPORT CAPI_GetProfile +IMPORT CAPI_GetManufacturer +IMPORT CAPI_GetVersion +IMPORT CAPI_GetSerialNumber + +IMPORT @%WATCOM%\NOVI\clib.imp +IMPORT @%WATCOM%\NOVI\threads.imp +IMPORT @%WATCOM%\NOVI\nlmlib.imp + +LIBRARY %WATCOM%\LIB386\NETWARE\clib3s.lib +LIBRARY %WATCOM%\LIB386\plib3s.lib +LIBRARY ..\c20lib\netware\CAP2032.LIB + +MODULE CLIB diff --git a/SOURCE/NW_MKDMO.BAT b/SOURCE/NW_MKDMO.BAT new file mode 100644 index 0000000..3de63b4 --- /dev/null +++ b/SOURCE/NW_MKDMO.BAT @@ -0,0 +1,34 @@ +@ +@rem Make utility for building the NetWare based demo.nlm example for +@rem CAPI 2.0 calls. This example has been compiled with the 32Bit +@rem Watcom C 10.5 compiler. +@rem We assume that the Environment variable WATCOM contains the Install +@rem directory of your Watcom C Compiler (e.g. C:\wc105) +@ +@ +@ set CAPI20LIB=..\c20lib\netware +@ set CAPI20H=..\c20lib\source +@ set COMP=%WATCOM%\BINW\WCC386 +@ +@if "%1"=="rel" goto NODEBUG +@ set WCC386=/d2 /s /3s /ox /zq /wx /I%CAPI20H% /DB1 /DAVM /DTARGET_32BIT /DTARGET_NW +goto compile + +:NODEBUG +@ set WCC386=/d1 /s /3s /ox /zq /wx /I%CAPI20H% /DNDEBUG /DB1 /DAVM /DTARGET_32BIT /DTARGET_NW +goto compile + +:compile +%COMP% /bt=netware /fonetware\main.obj main.c > errors.nlm +%COMP% /bt=netware /fonetware\c20msg.obj c20msg.c >> errors.nlm +%COMP% /bt=netware /fonetware\capi.obj capi.c >> errors.nlm +%COMP% /bt=netware /fonetware\connect.obj connect.c >> errors.nlm +%COMP% /bt=netware /fonetware\contr.obj contr.c >> errors.nlm +%COMP% /bt=netware /fonetware\data.obj data.c >> errors.nlm +%COMP% /bt=netware /fonetware\id.obj id.c >> errors.nlm +%COMP% /bt=netware /fonetware\init.obj init.c >> errors.nlm + +%WATCOM%\BINW\wlink @nw_dmo.rsp >> errors.nlm +del netware\*.obj +del *.map + diff --git a/SOURCE/NW_MKFAX.BAT b/SOURCE/NW_MKFAX.BAT new file mode 100644 index 0000000..f356e18 --- /dev/null +++ b/SOURCE/NW_MKFAX.BAT @@ -0,0 +1,36 @@ +@ +@rem Make utility for building the NetWare based faxdemo.nlm example for +@rem simple fax handling. This example has been compiled with the 32Bit +@rem Watcom C 10.5 compiler. +@rem We assume that the Environment variable WATCOM contains the Install +@rem directory of your Watcom C Compiler (e.g. C:\wc105) +@ +@ +@ set CAPI20LIB=..\c20lib\netware +@ set CAPI20H=..\c20lib\source +@ set COMP=%WATCOM%\BINW\WCC386 +@ +@if "%1"=="rel" goto NODEBUG +@ set WCC386=/d2 /s /3s /ox /zq /wx /I%CAPI20H% /DB1 /DAVM /DTARGET_32BIT /DTARGET_NW +goto compile + +:NODEBUG +@ set WCC386=/d1 /s /3s /ox /zq /wx /I%CAPI20H% /DNDEBUG /DB1 /DAVM /DTARGET_32BIT /DTARGET_NW +goto compile + +:compile +%COMP% /bt=netware /fonetware\faxmain.obj faxmain.c > errors.nlm +%COMP% /bt=netware /fonetware\c20msg.obj c20msg.c >>errors.nlm +%COMP% /bt=netware /fonetware\capi.obj capi.c >>errors.nlm +%COMP% /bt=netware /fonetware\connect.obj connect.c >>errors.nlm +%COMP% /bt=netware /fonetware\contr.obj contr.c >>errors.nlm +%COMP% /bt=netware /fonetware\data.obj data.c >>errors.nlm +%COMP% /bt=netware /fonetware\id.obj id.c >>errors.nlm +%COMP% /bt=netware /fonetware\init.obj init.c >>errors.nlm +%COMP% /bt=netware /fonetware\fax.obj fax.c >>errors.nlm + +%WATCOM%\BINW\wlink @nw_fax.rsp >> errors.nlm +del netware\*.obj +del *.map + + diff --git a/SOURCE/OS.H b/SOURCE/OS.H new file mode 100644 index 0000000..f28681f --- /dev/null +++ b/SOURCE/OS.H @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------*\ + + OS.H Version 1.1 1997 AVM + + Header file for OS.H + +\*--------------------------------------------------------------------------*/ +#ifndef _os_h_ +#define _os_h_ +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#if defined (TARGET_32BIT) +# ifdef __linux__ +# include "clinux.h" +# include "linuti.h" +# elif defined (TARGET_OS2) +# include "cos2.h" +# include +# elif defined (TARGET_NW) +# include "c_nw.h" +# include +# include +# else +# include "cwin32.h" +# include +# endif +#else +# include "cdos.h" +# include +#endif +/*---------------------------------------------------------------------------*\ +\*---------------------------------------------------------------------------*/ +#endif diff --git a/SOURCE/TESTFAX.SFF b/SOURCE/TESTFAX.SFF new file mode 100644 index 0000000..7d24a2e Binary files /dev/null and b/SOURCE/TESTFAX.SFF differ diff --git a/WHATS.NEW b/WHATS.NEW new file mode 100644 index 0000000..f273080 --- /dev/null +++ b/WHATS.NEW @@ -0,0 +1,27 @@ + +The COMMON ISDN API 2.0 Application Development Kit V1.6 +--------------------------------------------------------- + - NetWare support + + +The COMMON ISDN API 2.0 Application Development Kit V1.5 +--------------------------------------------------------- + - VxD interface function CAPI20_ISINSTALLED improved + + +The COMMON ISDN API 2.0 Application Development Kit V1.4 +--------------------------------------------------------- + - OS/2 and Linux support + - improved ANSI-C conformity + - minor corrections und improvements + + +The COMMON ISDN API 2.0 Application Development Kit V1.3 +--------------------------------------------------------- + + - started providing "whats.new" + - added CAPI20.DLL and CAPI2032.DLL protocol DLLs, + check new DEBUG.DLL directory + - corrected CIPmask constants (connect.h) + - deleted sample CALLING_PARTY_NUMBER (main.c) due to problems + with some PBXs