diff options
author | Damien Miller <djm@mindrot.org> | 2000-04-16 11:18:38 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-04-16 11:18:38 +1000 |
commit | 4af51306d9a51459a5bef922df1037f876ae51fe (patch) | |
tree | 09ecfc215fce82345a3259f8a0f384b9a67906f0 /buffer.c | |
parent | 5d1705ecf9bd3216dc99a84242bcdf2e7297d307 (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.c | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -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" |
17 | RCSID("$Id: buffer.c,v 1.4 2000/04/13 02:26:36 damien Exp $"); | 17 | RCSID("$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 | ||
25 | void | 25 | void |
26 | buffer_init(Buffer *buffer) | 26 | buffer_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 | ||
36 | void | 36 | void |
37 | buffer_free(Buffer *buffer) | 37 | buffer_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 | ||
48 | void | 48 | void |
49 | buffer_clear(Buffer *buffer) | 49 | buffer_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 | ||
57 | void | 57 | void |
58 | buffer_append(Buffer *buffer, const char *data, unsigned int len) | 58 | buffer_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 | ||
71 | void | 71 | void |
72 | buffer_append_space(Buffer *buffer, char **datap, unsigned int len) | 72 | buffer_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 | ||
105 | unsigned int | 105 | unsigned int |
106 | buffer_len(Buffer *buffer) | 106 | buffer_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 | ||
113 | void | 113 | void |
114 | buffer_get(Buffer *buffer, char *buf, unsigned int len) | 114 | buffer_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 | ||
124 | void | 124 | void |
125 | buffer_consume(Buffer *buffer, unsigned int bytes) | 125 | buffer_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 | ||
134 | void | 134 | void |
135 | buffer_consume_end(Buffer *buffer, unsigned int bytes) | 135 | buffer_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 | ||
152 | void | 152 | void |
153 | buffer_dump(Buffer *buffer) | 153 | buffer_dump(Buffer *buffer) |
154 | { | 154 | { |
155 | int i; | 155 | int i; |