10Sstevel@tonic-gate /* $OpenBSD: buffer.h,v 1.11 2002/03/04 17:27:39 stevesk Exp $ */ 20Sstevel@tonic-gate 30Sstevel@tonic-gate #ifndef _BUFFER_H 40Sstevel@tonic-gate #define _BUFFER_H 50Sstevel@tonic-gate 60Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 70Sstevel@tonic-gate 80Sstevel@tonic-gate #ifdef __cplusplus 90Sstevel@tonic-gate extern "C" { 100Sstevel@tonic-gate #endif 110Sstevel@tonic-gate 120Sstevel@tonic-gate 130Sstevel@tonic-gate /* 140Sstevel@tonic-gate * Author: Tatu Ylonen <ylo@cs.hut.fi> 150Sstevel@tonic-gate * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 160Sstevel@tonic-gate * All rights reserved 170Sstevel@tonic-gate * Code for manipulating FIFO buffers. 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * As far as I am concerned, the code I have written for this software 200Sstevel@tonic-gate * can be used freely for any purpose. Any derived versions of this 210Sstevel@tonic-gate * software must be clearly marked as such, and if the derived work is 220Sstevel@tonic-gate * incompatible with the protocol description in the RFC file, it must be 230Sstevel@tonic-gate * called by a name other than "ssh" or "Secure Shell". 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate typedef struct { 270Sstevel@tonic-gate u_char *buf; /* Buffer for data. */ 280Sstevel@tonic-gate u_int alloc; /* Number of bytes allocated for data. */ 290Sstevel@tonic-gate u_int offset; /* Offset of first byte containing data. */ 300Sstevel@tonic-gate u_int end; /* Offset of last byte containing data. */ 310Sstevel@tonic-gate } Buffer; 320Sstevel@tonic-gate 330Sstevel@tonic-gate void buffer_init(Buffer *); 340Sstevel@tonic-gate void buffer_clear(Buffer *); 350Sstevel@tonic-gate void buffer_free(Buffer *); 360Sstevel@tonic-gate 370Sstevel@tonic-gate u_int buffer_len(Buffer *); 380Sstevel@tonic-gate void *buffer_ptr(Buffer *); 390Sstevel@tonic-gate 400Sstevel@tonic-gate void buffer_append(Buffer *, const void *, u_int); 410Sstevel@tonic-gate void *buffer_append_space(Buffer *, u_int); 420Sstevel@tonic-gate 43*5087Sjp161948 int buffer_check_alloc(Buffer *, u_int); 44*5087Sjp161948 450Sstevel@tonic-gate void buffer_get(Buffer *, void *, u_int); 460Sstevel@tonic-gate 470Sstevel@tonic-gate void buffer_consume(Buffer *, u_int); 480Sstevel@tonic-gate void buffer_consume_end(Buffer *, u_int); 490Sstevel@tonic-gate 500Sstevel@tonic-gate void buffer_dump(Buffer *); 510Sstevel@tonic-gate 522757Sjp161948 int buffer_get_ret(Buffer *, void *, u_int); 532757Sjp161948 int buffer_consume_ret(Buffer *, u_int); 542757Sjp161948 int buffer_consume_end_ret(Buffer *, u_int); 552757Sjp161948 560Sstevel@tonic-gate #ifdef __cplusplus 570Sstevel@tonic-gate } 580Sstevel@tonic-gate #endif 590Sstevel@tonic-gate 600Sstevel@tonic-gate #endif /* _BUFFER_H */ 61