buffer.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
* Functions for manipulating fifo buffers (that can grow if needed).
*
* As far as I am concerned, the code I have written for this software
* can be used freely for any purpose. Any derived versions of this
* software must be clearly marked as such, and if the derived work is
* incompatible with the protocol description in the RFC file, it must be
* called by a name other than "ssh" or "Secure Shell".
*/
#include "includes.h"
#pragma ident "%Z%%M% %I% %E% SMI"
#include "xmalloc.h"
#include "buffer.h"
#include "log.h"
/* Initializes the buffer structure. */
void
{
}
/* Frees any memory used for the buffer. */
void
{
}
}
/*
* Clears any data from the buffer, making it empty. This does not actually
* zero the memory.
*/
void
{
}
/* Appends data to the buffer, expanding it if necessary. */
void
{
void *p;
}
/*
* Appends space to the buffer, expanding the buffer if necessary. This does
* not actually copy the data into the buffer, but instead returns a pointer
* to the allocated region.
*/
void *
{
void *p;
if (len > 0x100000)
/* If the buffer is empty, start using it from the beginning. */
}
/* If there is enough space to store all data, store it now. */
return p;
}
/*
* If the buffer is quite empty, but all data is at the end, move the
* data to the beginning and retry.
*/
goto restart;
}
/* Increase the size of the buffer and retry. */
if (newlen > 0xa00000)
fatal("buffer_append_space: alloc %u not supported",
newlen);
goto restart;
/* NOTREACHED */
}
/* Returns the number of bytes of data in the buffer. */
{
}
/* Gets data from the beginning of the buffer. */
void
{
fatal("buffer_get: trying to get more bytes %d than in buffer %d",
}
/* Consumes the given number of bytes from the beginning of the buffer. */
void
{
fatal("buffer_consume: trying to get more bytes than in buffer");
}
/* Consumes the given number of bytes from the end of the buffer. */
void
{
fatal("buffer_consume_end: trying to get more bytes than in buffer");
}
/* Returns a pointer to the first used byte in the buffer. */
void *
{
}
/* Dumps the contents of the buffer to stderr. */
void
{
int i;
}
}