|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1982, 1986, 1991 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms, with or without ! 6: * modification, are permitted provided that the following conditions ! 7: * are met: ! 8: * 1. Redistributions of source code must retain the above copyright ! 9: * notice, this list of conditions and the following disclaimer. ! 10: * 2. Redistributions in binary form must reproduce the above copyright ! 11: * notice, this list of conditions and the following disclaimer in the ! 12: * documentation and/or other materials provided with the distribution. ! 13: * 3. All advertising materials mentioning features or use of this software ! 14: * must display the following acknowledgement: ! 15: * This product includes software developed by the University of ! 16: * California, Berkeley and its contributors. ! 17: * 4. Neither the name of the University nor the names of its contributors ! 18: * may be used to endorse or promote products derived from this software ! 19: * without specific prior written permission. ! 20: * ! 21: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 22: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 23: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 24: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 25: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 26: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 27: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 28: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 29: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 30: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 31: * SUCH DAMAGE. ! 32: * ! 33: * from: @(#)tty_subr.c 7.7 (Berkeley) 5/9/91 ! 34: */ ! 35: ! 36: #include "param.h" ! 37: #include "systm.h" ! 38: #include "buf.h" ! 39: #include "ioctl.h" ! 40: #include "tty.h" ! 41: #include "clist.h" ! 42: ! 43: /* ! 44: * Initialize clists. ! 45: */ ! 46: cinit() ! 47: { ! 48: ! 49: /* ! 50: * Body deleted. ! 51: */ ! 52: } ! 53: ! 54: /* ! 55: * Get a character from a clist. ! 56: */ ! 57: getc(clp) ! 58: struct clist *clp; ! 59: { ! 60: char c; ! 61: ! 62: /* ! 63: * Body deleted. ! 64: */ ! 65: return (c); ! 66: } ! 67: ! 68: /* ! 69: * Copy clist to buffer. ! 70: * Return number of bytes moved. ! 71: */ ! 72: q_to_b(clp, cp, count) ! 73: struct clist *clp; ! 74: char *cp; ! 75: int count; ! 76: { ! 77: int s, moved = 0; ! 78: ! 79: if (count <= 0) ! 80: return (0); ! 81: s = spltty(); ! 82: /* ! 83: * Body deleted. ! 84: */ ! 85: splx(s); ! 86: return (moved); ! 87: } ! 88: ! 89: /* ! 90: * Return count of contiguous characters in clist. ! 91: * Stop counting if flag&character is non-null. ! 92: */ ! 93: ndqb(clp, flag) ! 94: struct clist *clp; ! 95: int flag; ! 96: { ! 97: int count = 0; ! 98: int s; ! 99: ! 100: s = spltty(); ! 101: /* ! 102: * Body deleted. ! 103: */ ! 104: splx(s); ! 105: return (count); ! 106: } ! 107: ! 108: /* ! 109: * Flush count bytes from clist. ! 110: */ ! 111: ndflush(clp, count) ! 112: struct clist *clp; ! 113: int count; ! 114: { ! 115: int s; ! 116: ! 117: s = spltty(); ! 118: /* ! 119: * Body deleted. ! 120: */ ! 121: splx(s); ! 122: } ! 123: ! 124: /* ! 125: * Put a character into the output queue. ! 126: */ ! 127: putc(c, clp) ! 128: char c; ! 129: struct clist *clp; ! 130: { ! 131: int s, error = 0; ! 132: ! 133: s = spltty(); ! 134: /* ! 135: * Body deleted. ! 136: */ ! 137: if (error) { ! 138: splx(s); ! 139: return (-1); ! 140: } ! 141: splx(s); ! 142: return (0); ! 143: } ! 144: ! 145: /* ! 146: * Copy buffer to clist. ! 147: * Return number of bytes not transfered. ! 148: */ ! 149: b_to_q(cp, count, clp) ! 150: char *cp; ! 151: int count; ! 152: struct clist *clp; ! 153: { ! 154: int s, resid; ! 155: ! 156: if (count <= 0) ! 157: return (0); ! 158: resid = count; ! 159: s = spltty(); ! 160: /* ! 161: * Body deleted. ! 162: */ ! 163: splx(s); ! 164: return (resid); ! 165: } ! 166: ! 167: /* ! 168: * Given a non-NULL pointer into the clist return the pointer ! 169: * to the next character in the list or return NULL if no more chars. ! 170: * ! 171: * Callers must not allow getc's to happen between nextc's so that the ! 172: * pointer becomes invalid. Note that interrupts are NOT masked. ! 173: */ ! 174: char * ! 175: nextc(clp, cp, count) ! 176: struct clist *clp; ! 177: char *cp; ! 178: int *count; ! 179: { ! 180: int empty = 0; ! 181: ! 182: /* ! 183: * Body deleted. ! 184: */ ! 185: if (!empty) ! 186: return (cp); ! 187: return (0); ! 188: } ! 189: ! 190: /* ! 191: * Remove the last character in the clist and return it. ! 192: */ ! 193: unputc(clp) ! 194: struct clist *clp; ! 195: { ! 196: char c; ! 197: int s; ! 198: ! 199: s = spltty(); ! 200: /* ! 201: * Body deleted. ! 202: */ ! 203: splx(s); ! 204: return (c); ! 205: } ! 206: ! 207: /* ! 208: * Put the chars in the from queue on the end of the to queue. ! 209: */ ! 210: catq(from, to) ! 211: struct clist *from, *to; ! 212: { ! 213: char c; ! 214: ! 215: while ((c = getc(from)) >= 0) ! 216: putc(c, to); ! 217: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.