xref: /original-bsd/sys/kern/PROTO/44Lite/tty_subr.c (revision f8c91da1)
1 /*-
2  * Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	from: @(#)tty_subr.c	7.7 (Berkeley) 5/9/91
8  */
9 
10 #include "param.h"
11 #include "systm.h"
12 #include "buf.h"
13 #include "ioctl.h"
14 #include "tty.h"
15 #include "clist.h"
16 
17 /*
18  * Initialize clists.
19  */
20 cinit()
21 {
22 
23 	/*
24 	 * Body deleted.
25 	 */
26 }
27 
28 /*
29  * Get a character from a clist.
30  */
31 getc(clp)
32 	struct clist *clp;
33 {
34 	char c;
35 
36 	/*
37 	 * Body deleted.
38 	 */
39 	return (c);
40 }
41 
42 /*
43  * Copy clist to buffer.
44  * Return number of bytes moved.
45  */
46 q_to_b(clp, cp, count)
47 	struct clist *clp;
48 	char *cp;
49 	int count;
50 {
51 	int s, moved = 0;
52 
53 	if (count <= 0)
54 		return (0);
55 	s = spltty();
56 	/*
57 	 * Body deleted.
58 	 */
59 	splx(s);
60 	return (moved);
61 }
62 
63 /*
64  * Return count of contiguous characters in clist.
65  * Stop counting if flag&character is non-null.
66  */
67 ndqb(clp, flag)
68 	struct clist *clp;
69 	int flag;
70 {
71 	int count = 0;
72 	int s;
73 
74 	s = spltty();
75 	/*
76 	 * Body deleted.
77 	 */
78 	splx(s);
79 	return (count);
80 }
81 
82 /*
83  * Flush count bytes from clist.
84  */
85 ndflush(clp, count)
86 	struct clist *clp;
87 	int count;
88 {
89 	int s;
90 
91 	s = spltty();
92 	/*
93 	 * Body deleted.
94 	 */
95 	splx(s);
96 }
97 
98 /*
99  * Put a character into the output queue.
100  */
101 putc(c, clp)
102 	char c;
103 	struct clist *clp;
104 {
105 	int s, error = 0;
106 
107 	s = spltty();
108 	/*
109 	 * Body deleted.
110 	 */
111 	if (error) {
112 		splx(s);
113 		return (-1);
114 	}
115 	splx(s);
116 	return (0);
117 }
118 
119 /*
120  * Copy buffer to clist.
121  * Return number of bytes not transfered.
122  */
123 b_to_q(cp, count, clp)
124 	char *cp;
125 	int count;
126 	struct clist *clp;
127 {
128 	int s, resid;
129 
130 	if (count <= 0)
131 		return (0);
132 	resid = count;
133 	s = spltty();
134 	/*
135 	 * Body deleted.
136 	 */
137 	splx(s);
138 	return (resid);
139 }
140 
141 /*
142  * Given a non-NULL pointer into the clist return the pointer
143  * to the next character in the list or return NULL if no more chars.
144  *
145  * Callers must not allow getc's to happen between nextc's so that the
146  * pointer becomes invalid.  Note that interrupts are NOT masked.
147  */
148 char *
149 nextc(clp, cp, count)
150 	struct clist *clp;
151 	char *cp;
152 	int *count;
153 {
154 	int empty = 0;
155 
156 	/*
157 	 * Body deleted.
158 	 */
159 	if (!empty)
160 		return (cp);
161 	return (0);
162 }
163 
164 /*
165  * Remove the last character in the clist and return it.
166  */
167 unputc(clp)
168 	struct clist *clp;
169 {
170 	char c;
171 	int s;
172 
173 	s = spltty();
174 	/*
175 	 * Body deleted.
176 	 */
177 	splx(s);
178 	return (c);
179 }
180 
181 /*
182  * Put the chars in the from queue on the end of the to queue.
183  */
184 catq(from, to)
185 	struct clist *from, *to;
186 {
187 	char c;
188 
189 	while ((c = getc(from)) >= 0)
190 		putc(c, to);
191 }
192