home *** CD-ROM | disk | FTP | other *** search
- /* Common ISDN API C-Library Functions Basic MS-DOS Functions
- Author: Dietmar Friede
- Copyright (c) 1992 D.Friede
- #include "copy"
- #include "copying.doc"
- */
-
- #define VERSION "0.18 21.09.1993"
-
- #include "stdio.h"
- #include <dos.h>
- #include <ctype.h>
- #include <mem.h>
- #include "types.h"
- #include "api.h"
- #include "head.h"
-
- union capi_ptr
- {
- InterruptPtr fptr;
- byte far * cptr;
- } capi_ptr;
-
- static byte check_vec[5] = { 'K','B',0x80,'I','A'};
-
- byte capi_int= CAPI_INT;
- unsigned application= 0;
- static unsigned save_es;
-
- int
- api_check(void)
- {
- int i;
- byte far *p;
- capi_ptr.fptr= getvect(capi_int);
- p=capi_ptr.cptr;
- p+= 6;
- for( i=0 ; i< 5; i++,p++)
- if( *p != check_vec[i] )
- {
- printf("no Common-ISDN-API installed\n");
- return 1;
- }
- return 0;
- }
-
- int
- api_register(byte far *buffer, int nmesg, int maxcon, int maxblock, int maxsize)
- {
- union REGS regs;
- struct SREGS sregs;
-
- if(application)
- {
- printf("only one application\n");
- return 0;
- }
- segread(&sregs);
- save_es=FP_SEG(buffer);
- sregs.es=save_es;
- regs.x.bx=FP_OFF(buffer);
- regs.x.cx=nmesg;
- regs.x.dx=maxcon;
- regs.x.si=maxblock;
- regs.x.di=maxsize;
- regs.h.ah= 1; /* API_REGISTER */
- int86x(capi_int,®s,®s,&sregs);
- application= regs.x.ax;
- return(regs.x.ax);
- }
-
- word
- api_release()
- {
- union REGS regs;
-
- regs.x.dx=application;
- regs.h.ah= 2; /* API_RELEASE */
- int86(capi_int,®s,®s);
- application= 0;
- return(regs.x.ax);
- }
-
- void freemsg(byte far *message);
-
- int
- api_put_message(byte far *message)
- {
- union REGS regs;
- struct SREGS sregs;
-
- if(message==null) return 1;
- segread(&sregs);
- sregs.es=FP_SEG(message);
- regs.x.bx=FP_OFF(message);
- regs.x.dx=application;
- regs.h.ah= 3; /* API_PUT_MESSAGE */
- int86x(capi_int,®s,®s,&sregs);
- freemsg(message);
-
- return(regs.x.ax);
- }
-
- int
- api_get_message(byte far **message)
- {
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
- sregs.es= save_es;
- regs.x.dx=application;
- regs.h.ah= 4; /* API_GET_MESSAGE */
- int86x(capi_int,®s,®s,&sregs);
- if(regs.x.ax) *message= null;
- else *message= MK_FP(sregs.es,regs.x.bx);
- return(regs.x.ax);
- }
-
- word
- api_set_signal(InterruptPtr function)
- {
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
- sregs.es=FP_SEG(function);
- regs.x.bx=FP_OFF(function);
- regs.x.dx=application;
- regs.h.ah= 5; /* API_SET_SIGNAL */
- int86x(capi_int,®s,®s,&sregs);
- return(regs.x.ax);
- }
-
- int
- api_deinstall(int force)
- {
- union REGS regs;
-
- regs.x.bx=force;
- regs.h.ah= 6; /* API_DEINSTALL */
- int86(capi_int,®s,®s);
- return(regs.x.ax);
- }
-
- void
- api_get_manufacturer(byte far *buffer)
- {
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
- sregs.es=FP_SEG(buffer);
- regs.x.bx=FP_OFF(buffer);
- regs.h.ah= 0xf0;
- int86x(capi_int,®s,®s,&sregs);
- }
-
- void
- api_get_version(byte far *buffer)
- {
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
- sregs.es=FP_SEG(buffer);
- regs.x.bx=FP_OFF(buffer);
- regs.h.ah= 0xf1;
- int86x(capi_int,®s,®s,&sregs);
- }
-
- void
- api_get_serial(byte far *buffer)
- {
- union REGS regs;
- struct SREGS sregs;
-
- segread(&sregs);
- sregs.es=FP_SEG(buffer);
- regs.x.bx=FP_OFF(buffer);
- regs.h.ah= 0xf2;
- int86x(capi_int,®s,®s,&sregs);
- }
-
-