xref: /original-bsd/usr.bin/telnet/ring.h (revision 1e395994)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)ring.h	5.1 (Berkeley) 09/14/90
8  */
9 
10 /*
11  * This defines a structure for a ring buffer.
12  *
13  * The circular buffer has two parts:
14  *(((
15  *	full:	[consume, supply)
16  *	empty:	[supply, consume)
17  *]]]
18  *
19  */
20 typedef struct {
21     char	*consume,	/* where data comes out of */
22     		*supply,	/* where data comes in to */
23 		*bottom,	/* lowest address in buffer */
24 		*top,		/* highest address+1 in buffer */
25 		*mark;		/* marker (user defined) */
26     int		size;		/* size in bytes of buffer */
27     u_long	consumetime,	/* help us keep straight full, empty, etc. */
28 		supplytime;
29 } Ring;
30 
31 /* Here are some functions and macros to deal with the ring buffer */
32 
33 
34 #if	defined(LINT_ARGS)
35 
36 /* Initialization routine */
37 extern int
38 	ring_init(Ring *ring, char *buffer, int count);
39 
40 /* Data movement routines */
41 extern void
42 	ring_supply_data(Ring *ring, char *buffer, int count);
43 #ifdef notdef
44 extern void
45 	ring_consume_data(Ring *ring, char *buffer, int count);
46 #endif
47 
48 /* Buffer state transition routines */
49 extern void
50 	ring_supplied(Ring *ring, int count),
51 	ring_consumed(Ring *ring, int count);
52 
53 /* Buffer state query routines */
54 extern int
55 	ring_empty_count(Ring *ring),
56 	ring_empty_consecutive(Ring *ring),
57 	ring_full_count(Ring *ring),
58 	ring_full_consecutive(Ring *ring);
59 
60 #else /* LINT_ARGS */
61 extern int
62 	ring_init();
63 
64 extern void
65     ring_supply_data();
66 #ifdef notdef
67 extern void
68     ring_consume_data();
69 #endif
70 
71 extern void
72     ring_supplied(),
73     ring_consumed();
74 
75 extern void
76     ring_clear_mark(),
77     ring_mark();
78 
79 extern int
80     ring_empty_count(),
81     ring_empty_consecutive(),
82     ring_full_count(),
83     ring_full_consecutive();
84 #endif	/* defined(LINT_ARGS) */
85