xref: /titanic_50/usr/src/cmd/ssh/include/buffer.h (revision 26ba198477055398633f319757f934b7ce73784e)
17c478bd9Sstevel@tonic-gate /*	$OpenBSD: buffer.h,v 1.11 2002/03/04 17:27:39 stevesk Exp $	*/
27c478bd9Sstevel@tonic-gate 
37c478bd9Sstevel@tonic-gate #ifndef	_BUFFER_H
47c478bd9Sstevel@tonic-gate #define	_BUFFER_H
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
77c478bd9Sstevel@tonic-gate 
87c478bd9Sstevel@tonic-gate #ifdef __cplusplus
97c478bd9Sstevel@tonic-gate extern "C" {
107c478bd9Sstevel@tonic-gate #endif
117c478bd9Sstevel@tonic-gate 
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate /*
147c478bd9Sstevel@tonic-gate  * Author: Tatu Ylonen <ylo@cs.hut.fi>
157c478bd9Sstevel@tonic-gate  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
167c478bd9Sstevel@tonic-gate  *                    All rights reserved
177c478bd9Sstevel@tonic-gate  * Code for manipulating FIFO buffers.
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * As far as I am concerned, the code I have written for this software
207c478bd9Sstevel@tonic-gate  * can be used freely for any purpose.  Any derived versions of this
217c478bd9Sstevel@tonic-gate  * software must be clearly marked as such, and if the derived work is
227c478bd9Sstevel@tonic-gate  * incompatible with the protocol description in the RFC file, it must be
237c478bd9Sstevel@tonic-gate  * called by a name other than "ssh" or "Secure Shell".
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate typedef struct {
277c478bd9Sstevel@tonic-gate 	u_char	*buf;		/* Buffer for data. */
287c478bd9Sstevel@tonic-gate 	u_int	 alloc;		/* Number of bytes allocated for data. */
297c478bd9Sstevel@tonic-gate 	u_int	 offset;	/* Offset of first byte containing data. */
307c478bd9Sstevel@tonic-gate 	u_int	 end;		/* Offset of last byte containing data. */
317c478bd9Sstevel@tonic-gate }       Buffer;
327c478bd9Sstevel@tonic-gate 
33*26ba1984Sjp161948 #define	BUFFER_MAX_CHUNK	0x100000
34*26ba1984Sjp161948 #define	BUFFER_MAX_LEN		0xa00000
35*26ba1984Sjp161948 
367c478bd9Sstevel@tonic-gate void	 buffer_init(Buffer *);
377c478bd9Sstevel@tonic-gate void	 buffer_clear(Buffer *);
387c478bd9Sstevel@tonic-gate void	 buffer_free(Buffer *);
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate u_int	 buffer_len(Buffer *);
417c478bd9Sstevel@tonic-gate void	*buffer_ptr(Buffer *);
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate void	 buffer_append(Buffer *, const void *, u_int);
447c478bd9Sstevel@tonic-gate void	*buffer_append_space(Buffer *, u_int);
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate void	 buffer_get(Buffer *, void *, u_int);
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate void	 buffer_consume(Buffer *, u_int);
497c478bd9Sstevel@tonic-gate void	 buffer_consume_end(Buffer *, u_int);
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate void     buffer_dump(Buffer *);
527c478bd9Sstevel@tonic-gate 
53*26ba1984Sjp161948 int	 buffer_get_ret(Buffer *, void *, u_int);
54*26ba1984Sjp161948 int	 buffer_consume_ret(Buffer *, u_int);
55*26ba1984Sjp161948 int	 buffer_consume_end_ret(Buffer *, u_int);
56*26ba1984Sjp161948 
577c478bd9Sstevel@tonic-gate #ifdef __cplusplus
587c478bd9Sstevel@tonic-gate }
597c478bd9Sstevel@tonic-gate #endif
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #endif /* _BUFFER_H */
62