home *** CD-ROM | disk | FTP | other *** search
- /******************************************
- * CFILRATE *
- * Copyright InfoTeSys, Inc. 1990 *
- ******************************************/
-
- #include <ts.h>
-
- /**********
- * CNCOUNT( CHAN *CN, short mode )
- * This function returns the number of BYTES in the channel to read from
- * cn->bot (CW_BOT) or cn->ahead (CW_AHEAD)
- *
- * MODIFICATION
- *
- * 90-01-08 Bonné J. Creation date
- * 90-03-28 Bonné J.
- *
- **********/
-
- short cncount( cn, mode )
- CHAN *cn ;
- short mode;
- {
- register short b;
-
- b = (mode == CW_AHEAD) ? cn->q.ahead : cn->q.bot;
-
- if ( cn->q.top < b ) return( cn->q.size - b + cn->q.top);
- else return( cn->q.top - b );
- }
-
-
- /**********
- * CNFILL( CHAN *CN, short mode )
- * This function returns a value from 0 to 100 to indicate the filling
- * rate of the channel. 0 = empty
- * 50 = half full
- * 100 = full
- *
- * MODIFICATION
- *
- * 90-01-08 Bonné J. Creation date
- * 90-03-28 Bonné J.
- *
- **********/
-
- short cnfill( cn, mode )
- CHAN *cn ;
- short mode;
- {
- if (cn->q.size)
- return ( (short)( (long)cncount(cn, mode) * 100 ) / cn->q.size);
- else
- return 100; /* no size is full */
- }
-