blob: 845bfb69707c4445bbae5cd2e4fdb5846f7a217b [file] [log] [blame]
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001/*
Damien Miller95def091999-11-25 00:26:21 +11002 * Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller95def091999-11-25 00:26:21 +11003 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
Damien Miller95def091999-11-25 00:26:21 +11005 * Code for manipulating FIFO buffers.
Damien Miller5f056372000-04-16 12:31:48 +10006 *
Damien Millere4340be2000-09-16 13:29:08 +11007 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is
10 * incompatible with the protocol description in the RFC file, it must be
11 * called by a name other than "ssh" or "Secure Shell".
Damien Miller95def091999-11-25 00:26:21 +110012 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100013
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000014/* RCSID("$OpenBSD: buffer.h,v 1.9 2001/06/26 17:27:23 markus Exp $"); */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100015
16#ifndef BUFFER_H
17#define BUFFER_H
18
Damien Miller95def091999-11-25 00:26:21 +110019typedef struct {
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000020 char *buf; /* Buffer for data. */
21 u_int alloc; /* Number of bytes allocated for data. */
22 u_int offset; /* Offset of first byte containing data. */
23 u_int end; /* Offset of last byte containing data. */
Damien Miller95def091999-11-25 00:26:21 +110024} Buffer;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100025
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000026void buffer_init(Buffer *);
27void buffer_clear(Buffer *);
28void buffer_free(Buffer *);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100029
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000030u_int buffer_len(Buffer *);
31char *buffer_ptr(Buffer *);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100032
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000033void buffer_append(Buffer *, const char *, u_int);
34void buffer_append_space(Buffer *, char **, u_int);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100035
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000036void buffer_get(Buffer *, char *, u_int);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100037
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000038void buffer_consume(Buffer *, u_int);
39void buffer_consume_end(Buffer *, u_int);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100040
Ben Lindstrom4cc240d2001-07-04 04:46:56 +000041void buffer_dump(Buffer *);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100042
Damien Miller95def091999-11-25 00:26:21 +110043#endif /* BUFFER_H */