xref: /titanic_50/usr/src/cmd/ssh/include/buffer.h (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
1 /*	$OpenBSD: buffer.h,v 1.11 2002/03/04 17:27:39 stevesk Exp $	*/
2 
3 #ifndef	_BUFFER_H
4 #define	_BUFFER_H
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 /*
14  * Author: Tatu Ylonen <ylo@cs.hut.fi>
15  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
16  *                    All rights reserved
17  * Code for manipulating FIFO buffers.
18  *
19  * As far as I am concerned, the code I have written for this software
20  * can be used freely for any purpose.  Any derived versions of this
21  * software must be clearly marked as such, and if the derived work is
22  * incompatible with the protocol description in the RFC file, it must be
23  * called by a name other than "ssh" or "Secure Shell".
24  */
25 
26 typedef struct {
27 	u_char	*buf;		/* Buffer for data. */
28 	u_int	 alloc;		/* Number of bytes allocated for data. */
29 	u_int	 offset;	/* Offset of first byte containing data. */
30 	u_int	 end;		/* Offset of last byte containing data. */
31 }       Buffer;
32 
33 #define	BUFFER_MAX_CHUNK	0x100000
34 #define	BUFFER_MAX_LEN		0xa00000
35 
36 void	 buffer_init(Buffer *);
37 void	 buffer_clear(Buffer *);
38 void	 buffer_free(Buffer *);
39 
40 u_int	 buffer_len(Buffer *);
41 void	*buffer_ptr(Buffer *);
42 
43 void	 buffer_append(Buffer *, const void *, u_int);
44 void	*buffer_append_space(Buffer *, u_int);
45 
46 void	 buffer_get(Buffer *, void *, u_int);
47 
48 void	 buffer_consume(Buffer *, u_int);
49 void	 buffer_consume_end(Buffer *, u_int);
50 
51 void     buffer_dump(Buffer *);
52 
53 int	 buffer_get_ret(Buffer *, void *, u_int);
54 int	 buffer_consume_ret(Buffer *, u_int);
55 int	 buffer_consume_end_ret(Buffer *, u_int);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif /* _BUFFER_H */
62