xref: /NextBSD/sys/sys/mach/device/cirbuf.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright 1991-1998 by Open Software Foundation, Inc.
3  *              All Rights Reserved
4  *
5  * Permission to use, copy, modify, and distribute this software and
6  * its documentation for any purpose and without fee is hereby granted,
7  * provided that the above copyright notice appears in all copies and
8  * that both the copyright notice and this permission notice appear in
9  * supporting documentation.
10  *
11  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
12  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
16  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
18  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
19  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 /*
22  * MkLinux
23  */
24 /* CMU_HIST */
25 /*
26  * Revision 2.4.3.1  92/03/28  10:04:31  jeffreyh
27  * 	04-Mar-92  emcmanus at gr.osf.org
28  * 		Declare new cb_space() function.
29  * 	[92/03/10  07:56:04  bernadat]
30  *
31  * Revision 2.4  91/05/14  15:39:43  mrt
32  * 	Correcting copyright
33  *
34  * Revision 2.3  91/02/05  17:08:06  mrt
35  * 	Changed to new Mach copyright
36  * 	[91/01/31  17:26:40  mrt]
37  *
38  * Revision 2.2  90/08/27  21:54:39  dbg
39  * 	Created.
40  * 	[90/07/09            dbg]
41  *
42  */
43 /* CMU_ENDHIST */
44 
45 /*
46  *(C)UNIX System Laboratories, Inc. all or some portions of this file are
47  *derived from material licensed to the University of California by
48  *American Telephone and Telegraph Co. or UNIX System Laboratories,
49  *Inc. and are reproduced herein with the permission of UNIX System
50  *Laboratories, Inc.
51  */
52 
53 /*
54  * Mach Operating System
55  * Copyright (c) 1991,1990 Carnegie Mellon University
56  * All Rights Reserved.
57  *
58  * Permission to use, copy, modify and distribute this software and its
59  * documentation is hereby granted, provided that both the copyright
60  * notice and this permission notice appear in all copies of the
61  * software, derivative works or modified versions, and any portions
62  * thereof, and that both notices appear in supporting documentation.
63  *
64  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
65  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
66  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
67  *
68  * Carnegie Mellon requests users of this software to return to
69  *
70  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
71  *  School of Computer Science
72  *  Carnegie Mellon University
73  *  Pittsburgh PA 15213-3890
74  *
75  * any improvements or extensions that they make and grant Carnegie Mellon
76  * the rights to redistribute these changes.
77  */
78 /*
79  */
80 /*
81  *	Author: David B. Golub, Carnegie Mellon University
82  *	Date: 	7/90
83  */
84 
85 #ifndef	_DEVICE_CIRBUF_H_
86 #define	_DEVICE_CIRBUF_H_
87 
88 /*
89  * Circular buffers for TTY
90  */
91 
92 struct cirbuf {
93 	char *	c_start;	/* start of buffer */
94 	char *	c_end;		/* end of buffer + 1*/
95 	char *	c_cf;		/* read pointer */
96 	char *	c_cl;		/* write pointer */
97 	short	c_cc;		/* current number of characters
98 				   (compatibility) */
99 	short	c_hog;		/* max ever */
100 };
101 
102 /*
103  * Exported routines
104  */
105 
106 extern int	putc(
107 			char			ch,
108 			struct cirbuf 		* cb);
109 extern int	getc(
110 			struct cirbuf		* cb);
111 extern int	q_to_b(
112 			struct cirbuf		* cb,
113 			char			* cp,
114 			int			count);
115 extern int	b_to_q(
116 			char			* cp,
117 			int			count,
118 			struct cirbuf		* cb);
119 extern void	ndflush(
120 			struct cirbuf		* cb,
121 			int			count);
122 extern void	cb_alloc(
123 			struct cirbuf		* cb,
124 			int			buf_size);
125 extern void	cb_free(
126 			struct cirbuf		* cb);
127 extern int	cb_space(
128 			struct cirbuf		* cb);
129 extern int	ndqb(
130 			struct cirbuf		*cb,
131 			int			mask);
132 
133 #endif	/* _DEVICE_CIRBUF_H_ */
134