home *** CD-ROM | disk | FTP | other *** search
- /******************************************
- * CCLOSE.C *
- * Copyright TimeSlice, Inc. 1985, 86, 87. *
- ******************************************/
-
- #include <ts.h>
- #include <stdio.h>
-
- /***
- * CCLOSBUF( CHAN *CN ) - This function decrements CN->OPENLEV. If C->OPENLEV == 0
- * and CN->Q->EMPTY == TRUE, then the channel is de-allocated.
- ***/
- int cclosbuf( cn )
- CHAN *cn ;
- {
- CHAN *cn2, *flag;
-
- critstart( DOS_CRCLASS ) ;
- for( cn2 = (CHAN *)&_chfrnt ; cn2->nxt && cn2->nxt != cn ;cn2 = cn2->nxt )
- ;
- if ( flag = cn2->nxt )
- { /* was cn found ? */
- if ( (!--cn->openlev) && (cn->q.empty ) )
- {
- cn2->nxt = cn->nxt ; /* remove cn from linked list */
- } else
- crel( cn ) ;
- }
- critend( DOS_CRCLASS ) ;
- return( flag != NULL );
- }
-