home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / SRC / CFILRATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-28  |  1.2 KB  |  56 lines

  1.                 /******************************************
  2.            *            CFILRATE             *
  3.            * Copyright InfoTeSys, Inc. 1990         *
  4.                ******************************************/
  5.  
  6. #include <ts.h>
  7.  
  8. /**********
  9. * CNCOUNT( CHAN *CN, short mode )
  10. * This function returns the number of BYTES in the channel to read from
  11. * cn->bot (CW_BOT) or cn->ahead (CW_AHEAD)
  12. *
  13. * MODIFICATION
  14. *
  15. * 90-01-08 Bonné J.    Creation date
  16. * 90-03-28 Bonné J.
  17. *
  18. **********/
  19.  
  20. short cncount( cn, mode )
  21. CHAN    *cn ;
  22. short    mode;
  23. {
  24.     register short b;
  25.  
  26.     b = (mode == CW_AHEAD) ? cn->q.ahead : cn->q.bot;
  27.  
  28.     if ( cn->q.top < b ) return( cn->q.size - b + cn->q.top);
  29.        else         return( cn->q.top - b           );
  30. }
  31.  
  32.  
  33. /**********
  34. * CNFILL( CHAN *CN, short mode )
  35. * This function returns a value from 0 to 100 to indicate the filling
  36. * rate of the channel.      0  = empty
  37. *             50  = half full
  38. *            100  = full
  39. *
  40. * MODIFICATION
  41. *
  42. * 90-01-08 Bonné J.    Creation date
  43. * 90-03-28 Bonné J.
  44. *
  45. **********/
  46.  
  47. short cnfill( cn, mode )
  48. CHAN    *cn ;
  49. short    mode;
  50. {
  51.     if (cn->q.size)
  52.        return ( (short)( (long)cncount(cn, mode) * 100 ) / cn->q.size);
  53.     else
  54.        return 100;                  /* no size is full */
  55. }
  56.