home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / SRC / CCLOSBUF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-16  |  855 b   |  32 lines

  1.                  /******************************************
  2.            *            CCLOSE.C             *
  3.                * Copyright TimeSlice, Inc. 1985, 86, 87. *
  4.                ******************************************/
  5.  
  6. #include <ts.h>
  7. #include <stdio.h>
  8.  
  9. /***
  10. * CCLOSBUF( CHAN *CN ) - This function decrements CN->OPENLEV. If C->OPENLEV == 0
  11. * and CN->Q->EMPTY == TRUE, then the channel is de-allocated. 
  12. ***/
  13. int    cclosbuf( cn )
  14. CHAN    *cn ;
  15. {
  16.     CHAN  *cn2, *flag;
  17.  
  18.     critstart( DOS_CRCLASS ) ;
  19.     for( cn2 = (CHAN *)&_chfrnt ; cn2->nxt && cn2->nxt != cn ;cn2 = cn2->nxt )
  20.         ;
  21.     if ( flag = cn2->nxt )
  22.     {                           /* was cn found ? */
  23.     if ( (!--cn->openlev) && (cn->q.empty ) )
  24.     {
  25.        cn2->nxt = cn->nxt ;    /* remove cn from linked list */    
  26.     } else
  27.        crel( cn ) ;
  28.     }         
  29.     critend( DOS_CRCLASS ) ;
  30.     return( flag != NULL );
  31. }
  32.