/*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)tty_subr.c 6.10 (Berkeley) %G%
+ * @(#)tty_subr.c 7.3 (Berkeley) %G%
*/
#include "param.h"
c = *p->c_cf++ & 0377;
if (--p->c_cc<=0) {
bp = (struct cblock *)(p->c_cf-1);
- bp = (struct cblock *) ((int)bp & ~CROUND);
+ bp = (struct cblock *)((int)bp & ~CROUND);
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
}
}
splx(s);
- return(c);
+ return (c);
}
/*
char *acp;
if (cc <= 0)
- return(0);
+ return (0);
s = spltty();
if (q->c_cc <= 0) {
q->c_cc = 0;
q->c_cf = q->c_cl = NULL;
splx(s);
- return(0);
+ return (0);
}
acp = cp;
while (cc) {
- nc = sizeof(struct cblock) - ((int)q->c_cf & CROUND);
+ nc = sizeof (struct cblock) - ((int)q->c_cf & CROUND);
nc = MIN(nc, cc);
nc = MIN(nc, q->c_cc);
(void) bcopy(q->c_cf, cp, (unsigned)nc);
}
}
splx(s);
- return(cp-acp);
+ return (cp-acp);
}
/*
}
out:
splx(s);
- return(cc);
+ return (cc);
}
-
-
/*
* Flush cc bytes from q.
*/
int rem, s;
s = spltty();
- if (q->c_cc <= 0) {
+ if (q->c_cc <= 0)
goto out;
- }
while (cc>0 && q->c_cc) {
bp = (struct cblock *)((int)q->c_cf & ~CROUND);
if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) {
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
splx(s);
- return(-1);
+ return (-1);
}
cfreelist = bp->c_next;
cfreecount -= CBSIZE;
bp = (struct cblock *)cp - 1;
if ((bp->c_next = cfreelist) == NULL) {
splx(s);
- return(-1);
+ return (-1);
}
bp = bp->c_next;
cfreelist = bp->c_next;
p->c_cc++;
p->c_cl = cp;
splx(s);
- return(0);
+ return (0);
}
-
-
/*
* copy buffer to clist.
* return number of bytes not transfered.
int acc;
if (cc <= 0)
- return(0);
+ return (0);
acc = cc;
s = spltty();
if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
while (cc) {
if (((int)cq & CROUND) == 0) {
- bp = (struct cblock *) cq - 1;
+ bp = (struct cblock *)cq - 1;
if ((bp->c_next = cfreelist) == NULL)
goto out;
bp = bp->c_next;
bp->c_next = NULL;
cq = bp->c_info;
}
- nc = MIN(cc, sizeof(struct cblock) - ((int)cq & CROUND));
+ nc = MIN(cc, sizeof (struct cblock) - ((int)cq & CROUND));
(void) bcopy(cp, cq, (unsigned)nc);
cp += nc;
cq += nc;
#ifdef unneeded
/*
- * Integer (short) get/put
- * using clists
+ * Integer (short) get/put using clists.
*/
typedef u_short word_t;
return(-1);
if (p->c_cc & 01) {
c = getc(p);
- return(c | (getc(p)<<8));
+#if BYTE_ORDER == LITTLE_ENDIAN
+ return (c | (getc(p)<<8));
+#else
+ return (getc(p) | (c<<8));
+#endif
}
s = spltty();
- c = *((word_t *)p->c_cf);
- p->c_cf += sizeof(word_t);
- p->c_cc -= sizeof(word_t);
+#if BYTE_ORDER == LITTLE_ENDIAN
+ c = (((u_char *)p->c_cf)[0] << 8) | ((u_char *)p->c_cf)[1];
+#else
+ c = (((u_char *)p->c_cf)[1] << 8) | ((u_char *)p->c_cf)[0];
+#endif
+ p->c_cf += sizeof (word_t);
+ p->c_cc -= sizeof (word_t);
if (p->c_cc <= 0) {
bp = (struct cblock *)(p->c_cf-1);
- bp = (struct cblock *) ((int)bp & ~CROUND);
+ bp = (struct cblock *)((int)bp & ~CROUND);
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
return(-1);
}
if (p->c_cc & 01) {
+#if BYTE_ORDER == LITTLE_ENDIAN
(void) putc(c, p);
(void) putc(c>>8, p);
+#else
+ (void) putc(c>>8, p);
+ (void) putc(c, p);
+#endif
} else {
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
bp->c_next = NULL;
cp = bp->c_info;
}
+#if defined(vax)
*(word_t *)cp = c;
- p->c_cl = cp + sizeof(word_t);
- p->c_cc += sizeof(word_t);
+#else
+ ((u_char *)cp)[0] = c>>8;
+ ((u_char *)cp)[1] = c;
+#endif
+ p->c_cl = cp + sizeof (word_t);
+ p->c_cc += sizeof (word_t);
}
splx(s);
return (0);