xref: /titanic_44/usr/src/cmd/ssh/include/buffer.h (revision 275c9da86e89f8abf71135cf63d9fc23671b2e60)
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 int	 buffer_check_alloc(Buffer *, u_int);
44 
45 void	 buffer_get(Buffer *, void *, u_int);
46 
47 void	 buffer_consume(Buffer *, u_int);
48 void	 buffer_consume_end(Buffer *, u_int);
49 
50 void     buffer_dump(Buffer *);
51 
52 int	 buffer_get_ret(Buffer *, void *, u_int);
53 int	 buffer_consume_ret(Buffer *, u_int);
54 int	 buffer_consume_end_ret(Buffer *, u_int);
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif /* _BUFFER_H */
61