/*
 * CopyRight 1995. Nicholas Poljakov all rights reserved.
 */
#include <malloc.h>
#include <stdio.h>
#include <dos.h>
#include <tps.h>
#include <state1.h>

tp_ended (tp_id,
	  rc)

unsigned char tp_id[8];
unsigned long *rc;

{
   /*    union REGS inregs,outregs;
        struct SREGS segregs;
    */
       char _near *dp1;
       char _near *dp2;
       struct tp_ended *ptr;

   if ((ptr = (char *)calloc(1, sizeof(struct tp_ended))) == NULL) {
        *rc = PORT_BUSY; /* нет доступной памяти */
        return(0);
   }

   ptr->verb_cd=TP_ENDED;

   memcpy(ptr->tp_id,tp_id,8);
/*
     inregs.x.dx = FP_OFF(ptr);
     segregs.ds = FP_SEG(ptr);
     inregs.x.ax = ptr->verb_cd;

 int86x(0x68,&inregs,&outregs,&segregs);
 */
     dp1 = FP_OFF( ptr );
     dp2 = FP_SEG( ptr );
     _asm
         {
            push  ds
            mov   dx, word ptr dp1[0]
            mov   ax, word ptr dp2[0]
            mov   ds, ax
            mov   ax, TP_ENDED
            int   68h
            pop   ds
         }

     *rc = ptr->rc;
     free(ptr);
     return(0);
}
