/*
 * Tentun - covert tunneling project
 *
 * Copyright (C) 2003 David Gordon
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 * The round buffer can be used to buffer a stream of bytes. It functions
 * essentially as a queue. The first data you write to the round
 * buffer is the first data you read. It is important that you check if enough
 * data/space is available in the buffer before you attempt a read/write.
 */


#ifndef __RBUF_H__
#define __RBUF_H__
/* #include "util.h" */


typedef struct {
    char *buf;
    int alloc_size;
    int read_index;
    int write_index;
} rbuf;


void set_size(rbuf*, int new_size);
void clean_up(rbuf* rb);
int is_empty(rbuf* rb);
int is_full(rbuf* rb);
int avail_size(rbuf* rb);
int used_size(rbuf* rb);
void seek(rbuf*, int pos);
void internal_read_buf(rbuf*, char *data_buf, int data_buf_size,
		       int *local_index_ptr);
void read_buf(rbuf*, char *data_buf, int data_buf_size);
void peek_buf(rbuf*, char *data_buf, int data_buf_size);
void write_buf(rbuf*, char *data_buf, int data_buf_size);



#endif
