=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/buffer.c,v retrieving revision 1.8.2.6 retrieving revision 1.9 diff -u -r1.8.2.6 -r1.9 --- src/usr.bin/ssh/Attic/buffer.c 2002/03/08 17:04:42 1.8.2.6 +++ src/usr.bin/ssh/Attic/buffer.c 2000/12/19 23:17:55 1.9 @@ -12,11 +12,11 @@ */ #include "includes.h" -RCSID("$OpenBSD: buffer.c,v 1.8.2.6 2002/03/08 17:04:42 brad Exp $"); +RCSID("$OpenBSD: buffer.c,v 1.9 2000/12/19 23:17:55 markus Exp $"); #include "xmalloc.h" #include "buffer.h" -#include "log.h" +#include "ssh.h" /* Initializes the buffer structure. */ @@ -53,11 +53,11 @@ /* Appends data to the buffer, expanding it if necessary. */ void -buffer_append(Buffer *buffer, const void *data, u_int len) +buffer_append(Buffer *buffer, const char *data, u_int len) { - void *p; - p = buffer_append_space(buffer, len); - memcpy(p, data, len); + char *cp; + buffer_append_space(buffer, &cp, len); + memcpy(cp, data, len); } /* @@ -66,11 +66,9 @@ * to the allocated region. */ -void * -buffer_append_space(Buffer *buffer, u_int len) +void +buffer_append_space(Buffer *buffer, char **datap, u_int len) { - void *p; - /* If the buffer is empty, start using it from the beginning. */ if (buffer->offset == buffer->end) { buffer->offset = 0; @@ -79,9 +77,9 @@ restart: /* If there is enough space to store all data, store it now. */ if (buffer->end + len < buffer->alloc) { - p = buffer->buf + buffer->end; + *datap = buffer->buf + buffer->end; buffer->end += len; - return p; + return; } /* * If the buffer is quite empty, but all data is at the end, move the @@ -98,7 +96,6 @@ buffer->alloc += len + 32768; buffer->buf = xrealloc(buffer->buf, buffer->alloc); goto restart; - /* NOTREACHED */ } /* Returns the number of bytes of data in the buffer. */ @@ -112,11 +109,10 @@ /* Gets data from the beginning of the buffer. */ void -buffer_get(Buffer *buffer, void *buf, u_int len) +buffer_get(Buffer *buffer, char *buf, u_int len) { if (len > buffer->end - buffer->offset) - fatal("buffer_get: trying to get more bytes %d than in buffer %d", - len, buffer->end - buffer->offset); + fatal("buffer_get: trying to get more bytes than in buffer"); memcpy(buf, buffer->buf + buffer->offset, len); buffer->offset += len; } @@ -143,7 +139,7 @@ /* Returns a pointer to the first used byte in the buffer. */ -void * +char * buffer_ptr(Buffer *buffer) { return buffer->buf + buffer->offset; @@ -155,14 +151,9 @@ buffer_dump(Buffer *buffer) { int i; - u_char *ucp = buffer->buf; + u_char *ucp = (u_char *) buffer->buf; - for (i = buffer->offset; i < buffer->end; i++) { - fprintf(stderr, "%02x", ucp[i]); - if ((i-buffer->offset)%16==15) - fprintf(stderr, "\r\n"); - else if ((i-buffer->offset)%2==1) - fprintf(stderr, " "); - } - fprintf(stderr, "\r\n"); + for (i = buffer->offset; i < buffer->end; i++) + fprintf(stderr, " %02x", ucp[i]); + fprintf(stderr, "\n"); }