summaryrefslogtreecommitdiff
path: root/kslog/circbuf.h
blob: a5a590a416c0e608962483bf2fbf9720032c8f63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * circbuf.h
 *
 * circular buffer interface
 *
 * mike@gravitino.net
 */
 
typedef struct circular_buffer
{
	int len ;
	int size;
	int next;
	int curr;
	int loop;

	unsigned char *buf;

} circular_buffer;

/*
 * initialize circular_buffer structure:
 * zero out structure & save buf & len args to structure members
 */
void	cb_init(circular_buffer *cb, unsigned char *buf, int len);

/*
 * place character into circular buffer
 */
void	cb_putc(circular_buffer *cb, char ch);

/*
 * remove character from circular buffer
 */
int	cb_getc(circular_buffer *cb, char *ch);