source: trunk/third/ssh/buffer.h @ 12646

Revision 12646, 2.2 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12645, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2
3buffer.h
4
5Author: Tatu Ylonen <ylo@cs.hut.fi>
6
7Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8                   All rights reserved
9
10Created: Sat Mar 18 04:12:25 1995 ylo
11
12Code for manipulating FIFO buffers.
13
14*/
15
16/*
17 * $Id: buffer.h,v 1.1.1.2 1999-03-08 17:43:42 danw Exp $
18 * $Log: not supported by cvs2svn $
19 * Revision 1.1.1.1  1996/02/18  21:38:11  ylo
20 *      Imported ssh-1.2.13.
21 *
22 * Revision 1.2  1995/07/13  01:18:55  ylo
23 *      Removed "Last modified" header.
24 *      Added cvs log.
25 *
26 * $Endlog$
27 */
28
29#ifndef BUFFER_H
30#define BUFFER_H
31
32typedef struct
33{
34  char *buf;                    /* Buffer for data. */
35  unsigned int alloc;           /* Number of bytes allocated for data. */
36  unsigned int offset;          /* Offset of first byte containing data. */
37  unsigned int end;             /* Offset of last byte containing data. */
38} Buffer;
39
40/* Initializes the buffer structure. */
41void buffer_init(Buffer *buffer);
42
43/* Frees any memory used for the buffer. */
44void buffer_free(Buffer *buffer);
45
46/* Clears any data from the buffer, making it empty.  This does not actually
47   zero the memory. */
48void buffer_clear(Buffer *buffer);
49
50/* Appends data to the buffer, expanding it if necessary. */
51void buffer_append(Buffer *buffer, const char *data, unsigned int len);
52
53/* Appends space to the buffer, expanding the buffer if necessary.
54   This does not actually copy the data into the buffer, but instead
55   returns a pointer to the allocated region. */
56void buffer_append_space(Buffer *buffer, char **datap, unsigned int len);
57
58/* Returns the number of bytes of data in the buffer. */
59unsigned int buffer_len(Buffer *buffer);
60
61/* Gets data from the beginning of the buffer. */
62void buffer_get(Buffer *buffer, char *buf, unsigned int len);
63
64/* Consumes the given number of bytes from the beginning of the buffer. */
65void buffer_consume(Buffer *buffer, unsigned int bytes);
66
67/* Consumes the given number of bytes from the end of the buffer. */
68void buffer_consume_end(Buffer *buffer, unsigned int bytes);
69
70/* Returns a pointer to the first used byte in the buffer. */
71char *buffer_ptr(Buffer *buffer);
72
73/* Dumps the contents of the buffer to stderr in hex.  This intended for
74   debugging purposes only. */
75void buffer_dump(Buffer *buffer);
76
77#endif /* BUFFER_H */
Note: See TracBrowser for help on using the repository browser.