Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 4 | * All rights reserved |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 5 | * Code for manipulating FIFO buffers. |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 6 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 7 | * As far as I am concerned, the code I have written for this software |
| 8 | * can be used freely for any purpose. Any derived versions of this |
| 9 | * software must be clearly marked as such, and if the derived work is |
| 10 | * incompatible with the protocol description in the RFC file, it must be |
| 11 | * called by a name other than "ssh" or "Secure Shell". |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 12 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 13 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 14 | /* RCSID("$OpenBSD: buffer.h,v 1.9 2001/06/26 17:27:23 markus Exp $"); */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 15 | |
| 16 | #ifndef BUFFER_H |
| 17 | #define BUFFER_H |
| 18 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 19 | typedef struct { |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 20 | char *buf; /* Buffer for data. */ |
| 21 | u_int alloc; /* Number of bytes allocated for data. */ |
| 22 | u_int offset; /* Offset of first byte containing data. */ |
| 23 | u_int end; /* Offset of last byte containing data. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 24 | } Buffer; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 25 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 26 | void buffer_init(Buffer *); |
| 27 | void buffer_clear(Buffer *); |
| 28 | void buffer_free(Buffer *); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 29 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 30 | u_int buffer_len(Buffer *); |
| 31 | char *buffer_ptr(Buffer *); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 32 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 33 | void buffer_append(Buffer *, const char *, u_int); |
| 34 | void buffer_append_space(Buffer *, char **, u_int); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 35 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 36 | void buffer_get(Buffer *, char *, u_int); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 37 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 38 | void buffer_consume(Buffer *, u_int); |
| 39 | void buffer_consume_end(Buffer *, u_int); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 40 | |
Ben Lindstrom | 4cc240d | 2001-07-04 04:46:56 +0000 | [diff] [blame] | 41 | void buffer_dump(Buffer *); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 42 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 43 | #endif /* BUFFER_H */ |