[BACK]Return to ring.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Diff for /src/usr.bin/telnet/ring.c between version 1.10 and 1.11

version 1.10, 2014/07/20 10:32:23 version 1.11, 2014/07/22 07:30:24
Line 71 
Line 71 
                                 ((d)->supplytime > (d)->consumetime))                                  ((d)->supplytime > (d)->consumetime))
   
   
   
   
   
 /* Buffer state transition routines */  /* Buffer state transition routines */
   
 void  void
 ring_init(ring, buffer, count)  ring_init(Ring *ring, unsigned char *buffer, int count)
     Ring *ring;  
     unsigned char *buffer;  
     int count;  
 {  {
     memset(ring, 0, sizeof *ring);      memset(ring, 0, sizeof *ring);
   
Line 97 
Line 91 
  * Mark the most recently supplied byte.   * Mark the most recently supplied byte.
  */   */
   
     void  void
 ring_mark(ring)  ring_mark(Ring *ring)
     Ring *ring;  
 {  {
     ring->mark = ring_decrement(ring, ring->supply, 1);      ring->mark = ring_decrement(ring, ring->supply, 1);
 }  }
Line 108 
Line 101 
  * Is the ring pointing to the mark?   * Is the ring pointing to the mark?
  */   */
   
     int  int
 ring_at_mark(ring)  ring_at_mark(Ring *ring)
     Ring *ring;  
 {  {
     if (ring->mark == ring->consume) {      if (ring->mark == ring->consume) {
         return 1;          return 1;
Line 123 
Line 115 
  * Clear any mark set on the ring.   * Clear any mark set on the ring.
  */   */
   
     void  void
 ring_clear_mark(ring)  ring_clear_mark(Ring *ring)
     Ring *ring;  
 {  {
     ring->mark = NULL;      ring->mark = NULL;
 }  }
Line 133 
Line 124 
 /*  /*
  * Add characters from current segment to ring buffer.   * Add characters from current segment to ring buffer.
  */   */
     void  void
 ring_supplied(ring, count)  ring_supplied(Ring *ring, int count)
     Ring *ring;  
     int count;  
 {  {
     ring->supply = ring_increment(ring, ring->supply, count);      ring->supply = ring_increment(ring, ring->supply, count);
     ring->supplytime = ++ring_clock;      ring->supplytime = ++ring_clock;
Line 145 
Line 134 
 /*  /*
  * We have just consumed "c" bytes.   * We have just consumed "c" bytes.
  */   */
     void  void
 ring_consumed(ring, count)  ring_consumed(Ring *ring, int count)
     Ring *ring;  
     int count;  
 {  {
     if (count == 0)     /* don't update anything */      if (count == 0)     /* don't update anything */
         return;          return;
Line 168 
Line 155 
 }  }
   
   
   
 /* Buffer state query routines */  /* Buffer state query routines */
   
   
 /* Number of bytes that may be supplied */  /* Number of bytes that may be supplied */
     int  int
 ring_empty_count(ring)  ring_empty_count(Ring *ring)
     Ring *ring;  
 {  {
     if (ring_empty(ring)) {     /* if empty */      if (ring_empty(ring)) {     /* if empty */
             return ring->size;              return ring->size;
Line 185 
Line 170 
 }  }
   
 /* number of CONSECUTIVE bytes that may be supplied */  /* number of CONSECUTIVE bytes that may be supplied */
     int  int
 ring_empty_consecutive(ring)  ring_empty_consecutive(Ring *ring)
     Ring *ring;  
 {  {
     if ((ring->consume < ring->supply) || ring_empty(ring)) {      if ((ring->consume < ring->supply) || ring_empty(ring)) {
                             /*                              /*
Line 207 
Line 191 
  * (but don't give more than enough to get to cross over set mark)   * (but don't give more than enough to get to cross over set mark)
  */   */
   
     int  int
 ring_full_count(ring)  ring_full_count(Ring *ring)
     Ring *ring;  
 {  {
     if ((ring->mark == NULL) || (ring->mark == ring->consume)) {      if ((ring->mark == NULL) || (ring->mark == ring->consume)) {
         if (ring_full(ring)) {          if (ring_full(ring)) {
Line 226 
Line 209 
  * Return the number of CONSECUTIVE bytes available for consuming.   * Return the number of CONSECUTIVE bytes available for consuming.
  * However, don't return more than enough to cross over set mark.   * However, don't return more than enough to cross over set mark.
  */   */
     int  int
 ring_full_consecutive(ring)  ring_full_consecutive(Ring *ring)
     Ring *ring;  
 {  {
     if ((ring->mark == NULL) || (ring->mark == ring->consume)) {      if ((ring->mark == NULL) || (ring->mark == ring->consume)) {
         if ((ring->supply < ring->consume) || ring_full(ring)) {          if ((ring->supply < ring->consume) || ring_full(ring)) {
Line 248 
Line 230 
 /*  /*
  * Move data into the "supply" portion of of the ring buffer.   * Move data into the "supply" portion of of the ring buffer.
  */   */
     void  void
 ring_supply_data(ring, buffer, count)  ring_supply_data(Ring *ring, unsigned char *buffer, int count)
     Ring *ring;  
     unsigned char *buffer;  
     int count;  
 {  {
     int i;      int i;
   

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11