xref: /titanic_50/usr/src/cmd/ssh/include/buffer.h (revision 90685d2c52744c6540828f16cdd2db815d467e37)
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 
337c478bd9Sstevel@tonic-gate void	 buffer_init(Buffer *);
347c478bd9Sstevel@tonic-gate void	 buffer_clear(Buffer *);
357c478bd9Sstevel@tonic-gate void	 buffer_free(Buffer *);
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate u_int	 buffer_len(Buffer *);
387c478bd9Sstevel@tonic-gate void	*buffer_ptr(Buffer *);
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate void	 buffer_append(Buffer *, const void *, u_int);
417c478bd9Sstevel@tonic-gate void	*buffer_append_space(Buffer *, u_int);
427c478bd9Sstevel@tonic-gate 
43*90685d2cSjp161948 int	 buffer_check_alloc(Buffer *, u_int);
44*90685d2cSjp161948 
457c478bd9Sstevel@tonic-gate void	 buffer_get(Buffer *, void *, u_int);
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate void	 buffer_consume(Buffer *, u_int);
487c478bd9Sstevel@tonic-gate void	 buffer_consume_end(Buffer *, u_int);
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate void     buffer_dump(Buffer *);
517c478bd9Sstevel@tonic-gate 
5226ba1984Sjp161948 int	 buffer_get_ret(Buffer *, void *, u_int);
5326ba1984Sjp161948 int	 buffer_consume_ret(Buffer *, u_int);
5426ba1984Sjp161948 int	 buffer_consume_end_ret(Buffer *, u_int);
5526ba1984Sjp161948 
567c478bd9Sstevel@tonic-gate #ifdef __cplusplus
577c478bd9Sstevel@tonic-gate }
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #endif /* _BUFFER_H */
61