summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
committerDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
commit4af51306d9a51459a5bef922df1037f876ae51fe (patch)
tree09ecfc215fce82345a3259f8a0f384b9a67906f0 /buffer.c
parent5d1705ecf9bd3216dc99a84242bcdf2e7297d307 (diff)
- OpenBSD CVS updates.
[ssh.1 ssh.c] - ssh -2 [auth.c channels.c clientloop.c packet.c packet.h serverloop.c] [session.c sshconnect.c] - check payload for (illegal) extra data [ALL] - whitespace cleanup
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/buffer.c b/buffer.c
index 48ae96a42..83a63e6f0 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1,20 +1,20 @@
1/* 1/*
2 * 2 *
3 * buffer.c 3 * buffer.c
4 * 4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * 6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved 8 * All rights reserved
9 * 9 *
10 * Created: Sat Mar 18 04:15:33 1995 ylo 10 * Created: Sat Mar 18 04:15:33 1995 ylo
11 * 11 *
12 * Functions for manipulating fifo buffers (that can grow if needed). 12 * Functions for manipulating fifo buffers (that can grow if needed).
13 * 13 *
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: buffer.c,v 1.4 2000/04/13 02:26:36 damien Exp $"); 17RCSID("$Id: buffer.c,v 1.5 2000/04/16 01:18:40 damien Exp $");
18 18
19#include "xmalloc.h" 19#include "xmalloc.h"
20#include "buffer.h" 20#include "buffer.h"
@@ -22,7 +22,7 @@ RCSID("$Id: buffer.c,v 1.4 2000/04/13 02:26:36 damien Exp $");
22 22
23/* Initializes the buffer structure. */ 23/* Initializes the buffer structure. */
24 24
25void 25void
26buffer_init(Buffer *buffer) 26buffer_init(Buffer *buffer)
27{ 27{
28 buffer->alloc = 4096; 28 buffer->alloc = 4096;
@@ -33,7 +33,7 @@ buffer_init(Buffer *buffer)
33 33
34/* Frees any memory used for the buffer. */ 34/* Frees any memory used for the buffer. */
35 35
36void 36void
37buffer_free(Buffer *buffer) 37buffer_free(Buffer *buffer)
38{ 38{
39 memset(buffer->buf, 0, buffer->alloc); 39 memset(buffer->buf, 0, buffer->alloc);
@@ -45,7 +45,7 @@ buffer_free(Buffer *buffer)
45 * zero the memory. 45 * zero the memory.
46 */ 46 */
47 47
48void 48void
49buffer_clear(Buffer *buffer) 49buffer_clear(Buffer *buffer)
50{ 50{
51 buffer->offset = 0; 51 buffer->offset = 0;
@@ -54,7 +54,7 @@ buffer_clear(Buffer *buffer)
54 54
55/* Appends data to the buffer, expanding it if necessary. */ 55/* Appends data to the buffer, expanding it if necessary. */
56 56
57void 57void
58buffer_append(Buffer *buffer, const char *data, unsigned int len) 58buffer_append(Buffer *buffer, const char *data, unsigned int len)
59{ 59{
60 char *cp; 60 char *cp;
@@ -68,7 +68,7 @@ buffer_append(Buffer *buffer, const char *data, unsigned int len)
68 * to the allocated region. 68 * to the allocated region.
69 */ 69 */
70 70
71void 71void
72buffer_append_space(Buffer *buffer, char **datap, unsigned int len) 72buffer_append_space(Buffer *buffer, char **datap, unsigned int len)
73{ 73{
74 /* If the buffer is empty, start using it from the beginning. */ 74 /* If the buffer is empty, start using it from the beginning. */
@@ -102,7 +102,7 @@ restart:
102 102
103/* Returns the number of bytes of data in the buffer. */ 103/* Returns the number of bytes of data in the buffer. */
104 104
105unsigned int 105unsigned int
106buffer_len(Buffer *buffer) 106buffer_len(Buffer *buffer)
107{ 107{
108 return buffer->end - buffer->offset; 108 return buffer->end - buffer->offset;
@@ -110,7 +110,7 @@ buffer_len(Buffer *buffer)
110 110
111/* Gets data from the beginning of the buffer. */ 111/* Gets data from the beginning of the buffer. */
112 112
113void 113void
114buffer_get(Buffer *buffer, char *buf, unsigned int len) 114buffer_get(Buffer *buffer, char *buf, unsigned int len)
115{ 115{
116 if (len > buffer->end - buffer->offset) 116 if (len > buffer->end - buffer->offset)
@@ -121,7 +121,7 @@ buffer_get(Buffer *buffer, char *buf, unsigned int len)
121 121
122/* Consumes the given number of bytes from the beginning of the buffer. */ 122/* Consumes the given number of bytes from the beginning of the buffer. */
123 123
124void 124void
125buffer_consume(Buffer *buffer, unsigned int bytes) 125buffer_consume(Buffer *buffer, unsigned int bytes)
126{ 126{
127 if (bytes > buffer->end - buffer->offset) 127 if (bytes > buffer->end - buffer->offset)
@@ -131,7 +131,7 @@ buffer_consume(Buffer *buffer, unsigned int bytes)
131 131
132/* Consumes the given number of bytes from the end of the buffer. */ 132/* Consumes the given number of bytes from the end of the buffer. */
133 133
134void 134void
135buffer_consume_end(Buffer *buffer, unsigned int bytes) 135buffer_consume_end(Buffer *buffer, unsigned int bytes)
136{ 136{
137 if (bytes > buffer->end - buffer->offset) 137 if (bytes > buffer->end - buffer->offset)
@@ -149,7 +149,7 @@ buffer_ptr(Buffer *buffer)
149 149
150/* Dumps the contents of the buffer to stderr. */ 150/* Dumps the contents of the buffer to stderr. */
151 151
152void 152void
153buffer_dump(Buffer *buffer) 153buffer_dump(Buffer *buffer)
154{ 154{
155 int i; 155 int i;