[BACK]Return to buffer.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/buffer.h, Revision 1.6

1.1       deraadt     1: /*
1.2       deraadt     2:  * Author: Tatu Ylonen <ylo@cs.hut.fi>
                      3:  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
                      4:  *                    All rights reserved
                      5:  * Code for manipulating FIFO buffers.
1.4       markus      6:  *
1.6     ! deraadt     7:  * 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".
1.2       deraadt    12:  */
1.1       deraadt    13:
1.6     ! deraadt    14: /* RCSID("$OpenBSD: buffer.h,v 1.5 2000/06/20 01:39:39 markus Exp $"); */
1.1       deraadt    15:
                     16: #ifndef BUFFER_H
                     17: #define BUFFER_H
                     18:
1.2       deraadt    19: typedef struct {
                     20:        char   *buf;            /* Buffer for data. */
                     21:        unsigned int alloc;     /* Number of bytes allocated for data. */
                     22:        unsigned int offset;    /* Offset of first byte containing data. */
                     23:        unsigned int end;       /* Offset of last byte containing data. */
                     24: }       Buffer;
1.1       deraadt    25: /* Initializes the buffer structure. */
1.2       deraadt    26: void    buffer_init(Buffer * buffer);
1.1       deraadt    27:
                     28: /* Frees any memory used for the buffer. */
1.2       deraadt    29: void    buffer_free(Buffer * buffer);
1.1       deraadt    30:
                     31: /* Clears any data from the buffer, making it empty.  This does not actually
                     32:    zero the memory. */
1.2       deraadt    33: void    buffer_clear(Buffer * buffer);
1.1       deraadt    34:
                     35: /* Appends data to the buffer, expanding it if necessary. */
1.2       deraadt    36: void    buffer_append(Buffer * buffer, const char *data, unsigned int len);
1.1       deraadt    37:
1.3       markus     38: /*
                     39:  * Appends space to the buffer, expanding the buffer if necessary. This does
                     40:  * not actually copy the data into the buffer, but instead returns a pointer
                     41:  * to the allocated region.
                     42:  */
1.2       deraadt    43: void    buffer_append_space(Buffer * buffer, char **datap, unsigned int len);
1.1       deraadt    44:
                     45: /* Returns the number of bytes of data in the buffer. */
1.2       deraadt    46: unsigned int buffer_len(Buffer * buffer);
1.1       deraadt    47:
                     48: /* Gets data from the beginning of the buffer. */
1.2       deraadt    49: void    buffer_get(Buffer * buffer, char *buf, unsigned int len);
1.1       deraadt    50:
                     51: /* Consumes the given number of bytes from the beginning of the buffer. */
1.2       deraadt    52: void    buffer_consume(Buffer * buffer, unsigned int bytes);
1.1       deraadt    53:
                     54: /* Consumes the given number of bytes from the end of the buffer. */
1.2       deraadt    55: void    buffer_consume_end(Buffer * buffer, unsigned int bytes);
1.1       deraadt    56:
                     57: /* Returns a pointer to the first used byte in the buffer. */
1.2       deraadt    58: char   *buffer_ptr(Buffer * buffer);
1.1       deraadt    59:
1.3       markus     60: /*
                     61:  * Dumps the contents of the buffer to stderr in hex.  This intended for
                     62:  * debugging purposes only.
                     63:  */
1.2       deraadt    64: void    buffer_dump(Buffer * buffer);
1.1       deraadt    65:
1.2       deraadt    66: #endif                         /* BUFFER_H */