]> andersk Git - openssh.git/blame - buffer.h
*** empty log message ***
[openssh.git] / buffer.h
CommitLineData
8efc0c15 1/*
5260325f 2 *
3 * buffer.h
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
10 * Created: Sat Mar 18 04:12:25 1995 ylo
11 *
12 * Code for manipulating FIFO buffers.
13 *
14 */
8efc0c15 15
16/* RCSID("$Id$"); */
17
18#ifndef BUFFER_H
19#define BUFFER_H
20
5260325f 21typedef struct {
22 char *buf; /* Buffer for data. */
23 unsigned int alloc; /* Number of bytes allocated for data. */
24 unsigned int offset; /* Offset of first byte containing data. */
25 unsigned int end; /* Offset of last byte containing data. */
26} Buffer;
8efc0c15 27/* Initializes the buffer structure. */
5260325f 28void buffer_init(Buffer * buffer);
8efc0c15 29
30/* Frees any memory used for the buffer. */
5260325f 31void buffer_free(Buffer * buffer);
8efc0c15 32
33/* Clears any data from the buffer, making it empty. This does not actually
34 zero the memory. */
5260325f 35void buffer_clear(Buffer * buffer);
8efc0c15 36
37/* Appends data to the buffer, expanding it if necessary. */
5260325f 38void buffer_append(Buffer * buffer, const char *data, unsigned int len);
8efc0c15 39
40/* Appends space to the buffer, expanding the buffer if necessary.
41 This does not actually copy the data into the buffer, but instead
42 returns a pointer to the allocated region. */
5260325f 43void buffer_append_space(Buffer * buffer, char **datap, unsigned int len);
8efc0c15 44
45/* Returns the number of bytes of data in the buffer. */
5260325f 46unsigned int buffer_len(Buffer * buffer);
8efc0c15 47
48/* Gets data from the beginning of the buffer. */
5260325f 49void buffer_get(Buffer * buffer, char *buf, unsigned int len);
8efc0c15 50
51/* Consumes the given number of bytes from the beginning of the buffer. */
5260325f 52void buffer_consume(Buffer * buffer, unsigned int bytes);
8efc0c15 53
54/* Consumes the given number of bytes from the end of the buffer. */
5260325f 55void buffer_consume_end(Buffer * buffer, unsigned int bytes);
8efc0c15 56
57/* Returns a pointer to the first used byte in the buffer. */
5260325f 58char *buffer_ptr(Buffer * buffer);
8efc0c15 59
60/* Dumps the contents of the buffer to stderr in hex. This intended for
61 debugging purposes only. */
5260325f 62void buffer_dump(Buffer * buffer);
8efc0c15 63
5260325f 64#endif /* BUFFER_H */
This page took 0.070509 seconds and 5 git commands to generate.