]>
Commit | Line | Data |
---|---|---|
fa1d7d85 | 1 | /* $OpenBSD: buffer.h,v 1.13 2005/03/14 11:46:56 markus Exp $ */ |
93c3b6de | 2 | |
8efc0c15 | 3 | /* |
5260325f | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
5260325f | 5 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
6 | * All rights reserved | |
5260325f | 7 | * Code for manipulating FIFO buffers. |
35484284 | 8 | * |
bcbf86ec | 9 | * As far as I am concerned, the code I have written for this software |
10 | * can be used freely for any purpose. Any derived versions of this | |
11 | * software must be clearly marked as such, and if the derived work is | |
12 | * incompatible with the protocol description in the RFC file, it must be | |
13 | * called by a name other than "ssh" or "Secure Shell". | |
5260325f | 14 | */ |
8efc0c15 | 15 | |
8efc0c15 | 16 | #ifndef BUFFER_H |
17 | #define BUFFER_H | |
18 | ||
5260325f | 19 | typedef struct { |
6c0fa2b1 | 20 | u_char *buf; /* Buffer for data. */ |
255cabd9 | 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. */ | |
5260325f | 24 | } Buffer; |
8efc0c15 | 25 | |
fa1d7d85 | 26 | #define BUFFER_MAX_CHUNK 0x100000 |
27 | #define BUFFER_MAX_LEN 0xa00000 | |
28 | ||
255cabd9 | 29 | void buffer_init(Buffer *); |
30 | void buffer_clear(Buffer *); | |
31 | void buffer_free(Buffer *); | |
8efc0c15 | 32 | |
255cabd9 | 33 | u_int buffer_len(Buffer *); |
6c0fa2b1 | 34 | void *buffer_ptr(Buffer *); |
8efc0c15 | 35 | |
6c0fa2b1 | 36 | void buffer_append(Buffer *, const void *, u_int); |
37 | void *buffer_append_space(Buffer *, u_int); | |
8efc0c15 | 38 | |
6c0fa2b1 | 39 | void buffer_get(Buffer *, void *, u_int); |
8efc0c15 | 40 | |
255cabd9 | 41 | void buffer_consume(Buffer *, u_int); |
42 | void buffer_consume_end(Buffer *, u_int); | |
8efc0c15 | 43 | |
255cabd9 | 44 | void buffer_dump(Buffer *); |
8efc0c15 | 45 | |
b82a59f2 | 46 | int buffer_get_ret(Buffer *, void *, u_int); |
47 | int buffer_consume_ret(Buffer *, u_int); | |
48 | int buffer_consume_end_ret(Buffer *, u_int); | |
49 | ||
5260325f | 50 | #endif /* BUFFER_H */ |