1f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/*
2f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * Dropbear SSH
3f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
4f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * Copyright (c) 2002-2004 Matt Johnston
5f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * All rights reserved.
6f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
7f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * Permission is hereby granted, free of charge, to any person obtaining a copy
8f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * of this software and associated documentation files (the "Software"), to deal
9f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * in the Software without restriction, including without limitation the rights
10f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * copies of the Software, and to permit persons to whom the Software is
12f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * furnished to do so, subject to the following conditions:
13f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
14f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * The above copyright notice and this permission notice shall be included in
15f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * all copies or substantial portions of the Software.
16f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
17f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * SOFTWARE. */
24f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
25f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project#ifndef _CIRCBUFFER_H_
26f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project#define _CIRCBUFFER_H_
27f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectstruct circbuf {
28f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
29f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project	unsigned int size;
30f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project	unsigned int readpos;
31f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project	unsigned int writepos;
32f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project	unsigned int used;
33f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project	unsigned char* data;
34f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project};
35f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
36f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projecttypedef struct circbuf circbuffer;
37f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
38f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectcircbuffer * cbuf_new(unsigned int size);
39f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectvoid cbuf_free(circbuffer * cbuf);
40f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
41f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned int cbuf_getused(circbuffer * cbuf); /* how much data stored */
42f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned int cbuf_getavail(circbuffer * cbuf); /* how much we can write */
43f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned int cbuf_readlen(circbuffer *cbuf); /* max linear read len */
44f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned int cbuf_writelen(circbuffer *cbuf); /* max linear write len */
45f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
46f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned char* cbuf_readptr(circbuffer *cbuf, unsigned int len);
47f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectunsigned char* cbuf_writeptr(circbuffer *cbuf, unsigned int len);
48f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectvoid cbuf_incrwrite(circbuffer *cbuf, unsigned int len);
49f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectvoid cbuf_incrread(circbuffer *cbuf, unsigned int len);
50f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project#endif
51