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 33*2757Sjp161948 #define BUFFER_MAX_CHUNK 0x100000 34*2757Sjp161948 #define BUFFER_MAX_LEN 0xa00000 35*2757Sjp161948 360Sstevel@tonic-gate void buffer_init(Buffer *); 370Sstevel@tonic-gate void buffer_clear(Buffer *); 380Sstevel@tonic-gate void buffer_free(Buffer *); 390Sstevel@tonic-gate 400Sstevel@tonic-gate u_int buffer_len(Buffer *); 410Sstevel@tonic-gate void *buffer_ptr(Buffer *); 420Sstevel@tonic-gate 430Sstevel@tonic-gate void buffer_append(Buffer *, const void *, u_int); 440Sstevel@tonic-gate void *buffer_append_space(Buffer *, u_int); 450Sstevel@tonic-gate 460Sstevel@tonic-gate void buffer_get(Buffer *, void *, u_int); 470Sstevel@tonic-gate 480Sstevel@tonic-gate void buffer_consume(Buffer *, u_int); 490Sstevel@tonic-gate void buffer_consume_end(Buffer *, u_int); 500Sstevel@tonic-gate 510Sstevel@tonic-gate void buffer_dump(Buffer *); 520Sstevel@tonic-gate 53*2757Sjp161948 int buffer_get_ret(Buffer *, void *, u_int); 54*2757Sjp161948 int buffer_consume_ret(Buffer *, u_int); 55*2757Sjp161948 int buffer_consume_end_ret(Buffer *, u_int); 56*2757Sjp161948 570Sstevel@tonic-gate #ifdef __cplusplus 580Sstevel@tonic-gate } 590Sstevel@tonic-gate #endif 600Sstevel@tonic-gate 610Sstevel@tonic-gate #endif /* _BUFFER_H */ 62