summaryrefslogtreecommitdiff
path: root/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.h')
-rw-r--r--buffer.h55
1 files changed, 16 insertions, 39 deletions
diff --git a/buffer.h b/buffer.h
index 5e9fc278d..845bfb697 100644
--- a/buffer.h
+++ b/buffer.h
@@ -11,56 +11,33 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: buffer.h,v 1.8 2001/06/26 06:32:48 itojun Exp $"); */ 14/* RCSID("$OpenBSD: buffer.h,v 1.9 2001/06/26 17:27:23 markus Exp $"); */
15 15
16#ifndef BUFFER_H 16#ifndef BUFFER_H
17#define BUFFER_H 17#define BUFFER_H
18 18
19typedef struct { 19typedef struct {
20 char *buf; /* Buffer for data. */ 20 char *buf; /* Buffer for data. */
21 u_int alloc; /* Number of bytes allocated for data. */ 21 u_int alloc; /* Number of bytes allocated for data. */
22 u_int offset; /* Offset of first byte containing data. */ 22 u_int offset; /* Offset of first byte containing data. */
23 u_int end; /* Offset of last byte containing data. */ 23 u_int end; /* Offset of last byte containing data. */
24} Buffer; 24} Buffer;
25/* Initializes the buffer structure. */
26void buffer_init(Buffer *);
27 25
28/* Frees any memory used for the buffer. */ 26void buffer_init(Buffer *);
29void buffer_free(Buffer *); 27void buffer_clear(Buffer *);
28void buffer_free(Buffer *);
30 29
31/* Clears any data from the buffer, making it empty. This does not actually 30u_int buffer_len(Buffer *);
32 zero the memory. */ 31char *buffer_ptr(Buffer *);
33void buffer_clear(Buffer *);
34 32
35/* Appends data to the buffer, expanding it if necessary. */ 33void buffer_append(Buffer *, const char *, u_int);
36void buffer_append(Buffer *, const char *, u_int); 34void buffer_append_space(Buffer *, char **, u_int);
37 35
38/* 36void buffer_get(Buffer *, char *, u_int);
39 * Appends space to the buffer, expanding the buffer if necessary. This does
40 * not actually copy the data into the buffer, but instead returns a pointer
41 * to the allocated region.
42 */
43void buffer_append_space(Buffer *, char **, u_int);
44
45/* Returns the number of bytes of data in the buffer. */
46u_int buffer_len(Buffer *);
47
48/* Gets data from the beginning of the buffer. */
49void buffer_get(Buffer *, char *, u_int);
50 37
51/* Consumes the given number of bytes from the beginning of the buffer. */ 38void buffer_consume(Buffer *, u_int);
52void buffer_consume(Buffer *, u_int); 39void buffer_consume_end(Buffer *, u_int);
53 40
54/* Consumes the given number of bytes from the end of the buffer. */ 41void buffer_dump(Buffer *);
55void buffer_consume_end(Buffer *, u_int);
56
57/* Returns a pointer to the first used byte in the buffer. */
58char *buffer_ptr(Buffer *);
59
60/*
61 * Dumps the contents of the buffer to stderr in hex. This intended for
62 * debugging purposes only.
63 */
64void buffer_dump(Buffer *);
65 42
66#endif /* BUFFER_H */ 43#endif /* BUFFER_H */