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

Diff for /src/usr.bin/ssh/Attic/buffer.c between version 1.5 and 1.6

version 1.5, 2000/04/12 10:22:38 version 1.6, 2000/04/14 10:30:30
Line 1 
Line 1 
 /*  /*
  *   *
  * buffer.c   * buffer.c
  *   *
  * Author: Tatu Ylonen <ylo@cs.hut.fi>   * Author: Tatu Ylonen <ylo@cs.hut.fi>
  *   *
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland   * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved   *                    All rights reserved
  *   *
  * Created: Sat Mar 18 04:15:33 1995 ylo   * Created: Sat Mar 18 04:15:33 1995 ylo
  *   *
  * Functions for manipulating fifo buffers (that can grow if needed).   * Functions for manipulating fifo buffers (that can grow if needed).
  *   *
  */   */
   
 #include "includes.h"  #include "includes.h"
Line 22 
Line 22 
   
 /* Initializes the buffer structure. */  /* Initializes the buffer structure. */
   
 void  void
 buffer_init(Buffer *buffer)  buffer_init(Buffer *buffer)
 {  {
         buffer->alloc = 4096;          buffer->alloc = 4096;
Line 33 
Line 33 
   
 /* Frees any memory used for the buffer. */  /* Frees any memory used for the buffer. */
   
 void  void
 buffer_free(Buffer *buffer)  buffer_free(Buffer *buffer)
 {  {
         memset(buffer->buf, 0, buffer->alloc);          memset(buffer->buf, 0, buffer->alloc);
Line 45 
Line 45 
  * zero the memory.   * zero the memory.
  */   */
   
 void  void
 buffer_clear(Buffer *buffer)  buffer_clear(Buffer *buffer)
 {  {
         buffer->offset = 0;          buffer->offset = 0;
Line 54 
Line 54 
   
 /* Appends data to the buffer, expanding it if necessary. */  /* Appends data to the buffer, expanding it if necessary. */
   
 void  void
 buffer_append(Buffer *buffer, const char *data, unsigned int len)  buffer_append(Buffer *buffer, const char *data, unsigned int len)
 {  {
         char *cp;          char *cp;
Line 68 
Line 68 
  * to the allocated region.   * to the allocated region.
  */   */
   
 void  void
 buffer_append_space(Buffer *buffer, char **datap, unsigned int len)  buffer_append_space(Buffer *buffer, char **datap, unsigned int len)
 {  {
         /* If the buffer is empty, start using it from the beginning. */          /* If the buffer is empty, start using it from the beginning. */
Line 102 
Line 102 
   
 /* Returns the number of bytes of data in the buffer. */  /* Returns the number of bytes of data in the buffer. */
   
 unsigned int  unsigned int
 buffer_len(Buffer *buffer)  buffer_len(Buffer *buffer)
 {  {
         return buffer->end - buffer->offset;          return buffer->end - buffer->offset;
Line 110 
Line 110 
   
 /* Gets data from the beginning of the buffer. */  /* Gets data from the beginning of the buffer. */
   
 void  void
 buffer_get(Buffer *buffer, char *buf, unsigned int len)  buffer_get(Buffer *buffer, char *buf, unsigned int len)
 {  {
         if (len > buffer->end - buffer->offset)          if (len > buffer->end - buffer->offset)
Line 121 
Line 121 
   
 /* Consumes the given number of bytes from the beginning of the buffer. */  /* Consumes the given number of bytes from the beginning of the buffer. */
   
 void  void
 buffer_consume(Buffer *buffer, unsigned int bytes)  buffer_consume(Buffer *buffer, unsigned int bytes)
 {  {
         if (bytes > buffer->end - buffer->offset)          if (bytes > buffer->end - buffer->offset)
Line 131 
Line 131 
   
 /* Consumes the given number of bytes from the end of the buffer. */  /* Consumes the given number of bytes from the end of the buffer. */
   
 void  void
 buffer_consume_end(Buffer *buffer, unsigned int bytes)  buffer_consume_end(Buffer *buffer, unsigned int bytes)
 {  {
         if (bytes > buffer->end - buffer->offset)          if (bytes > buffer->end - buffer->offset)
Line 149 
Line 149 
   
 /* Dumps the contents of the buffer to stderr. */  /* Dumps the contents of the buffer to stderr. */
   
 void  void
 buffer_dump(Buffer *buffer)  buffer_dump(Buffer *buffer)
 {  {
         int i;          int i;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6