xref: /titanic_41/usr/src/cmd/ssh/include/buffer.h (revision 8200fe25ffab8b2032d046c88710a949f361b700)
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 void	 buffer_init(Buffer *);
34 void	 buffer_clear(Buffer *);
35 void	 buffer_free(Buffer *);
36 
37 u_int	 buffer_len(Buffer *);
38 void	*buffer_ptr(Buffer *);
39 
40 void	 buffer_append(Buffer *, const void *, u_int);
41 void	*buffer_append_space(Buffer *, u_int);
42 
43 void	 buffer_get(Buffer *, void *, u_int);
44 
45 void	 buffer_consume(Buffer *, u_int);
46 void	 buffer_consume_end(Buffer *, u_int);
47 
48 void     buffer_dump(Buffer *);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* _BUFFER_H */
55