/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
Device interfaces
*/
#include <limits.h>
#include <ctype.h>
#ifdef EUC
#ifdef NROFF
#include <stdlib.h>
#endif /* NROFF */
#endif /* EUC */
#include "tdef.h"
#include "ext.h"
#include "tw.h"
struct t t; /* terminal characteristics */
int dtab;
int plotmode;
int esct;
char *codestr;
int nchtab = 0;
int Inch;
int Hor;
int Vert;
/* these characters are used as various signals or values
* in miscellaneous places.
* values are set in specnames in t10.c
*/
int c_hyphen;
int c_emdash;
int c_rule;
int c_minus;
int c_fi;
int c_fl;
int c_ff;
int c_ffi;
int c_ffl;
int c_acute;
int c_grave;
int c_under;
int c_rooten;
int c_boxrule;
int c_lefthand;
int c_dagger;
int c_isalnum;
int
ptinit()
{
int i, j;
char *p, *cp, *q;
extern char *setbrk();
exit(-1);
}
p = codestr;
p = skipstr(p); /* skip over type, could check */
exit(1);
}
for (i = 0; i < _SPECCHAR_ST; i++)
i = 0;
/* this ought to be a pointer array and in place in codestr */
while (*p == ' ' || *p == '\t' || *p == '\n')
p++;
if (i + _SPECCHAR_ST >= NROFFCHARS) {
termtab);
exit(1);
}
*cp++ = *p++; /* 2-char names */
*cp++ = *p++;
*cp++ = '\0';
while (*p == ' ' || *p == '\t')
p++;
while (*p == ' ' || *p == '\t')
p++;
t.codetab[i] = p;
p = getstr(p, p); /* compress string */
p++;
i++;
nchtab++;
}
for (i = 0; i < 16; i++)
specnames(); /* install names like "hyphen", etc. */
if (eqflg)
return (0);
}
char *s;
{
while (*s == ' ' || *s == '\t' || *s == '\n')
s++;
while (*s != ' ' && *s != '\t' && *s != '\n')
if (*s++ == '\\')
s++;
return s;
}
char *s, *t;
{
int quote = 0;
while (*s == ' ' || *s == '\t' || *s == '\n')
s++;
if (*s == '"') {
s++;
quote = 1;
}
for (;;) {
if (quote && *s == '"') {
s++;
break;
}
break;
if (*s != '\\')
*t++ = *s++;
else {
s++; /* skip \\ */
if (isdigit((unsigned char)s[0]) &&
isdigit((unsigned char)s[1]) &&
isdigit((unsigned char)s[2])) {
*t++ = (s[0]-'0')<<6 | (s[1]-'0')<<3 | s[2]-'0';
s += 2;
} else if (isdigit((unsigned char)s[0])) {
*t++ = *s - '0';
} else if (*s == 'b') {
*t++ = '\b';
} else if (*s == 'n') {
*t++ = '\n';
} else if (*s == 'r') {
*t++ = '\r';
} else if (*s == 't') {
*t++ = '\t';
} else {
*t++ = *s;
}
s++;
}
}
*t = '\0';
return s;
}
char *s;
int *pn;
{
int base;
while (*s == ' ' || *s == '\t' || *s == '\n')
s++;
*pn = 0;
while (isdigit((unsigned char)*s))
return s;
}
int
{
static struct {
int *n;
char *v;
} spnames[] = {
&c_hyphen, "hy",
&c_emdash, "em",
&c_rule, "ru",
&c_minus, "\\-",
&c_fi, "fi",
&c_fl, "fl",
&c_ff, "ff",
&c_ffi, "Fi",
&c_ffl, "Fl",
&c_acute, "aa",
&c_grave, "ga",
&c_under, "ul",
&c_rooten, "rn",
&c_boxrule, "br",
&c_lefthand, "lh",
&c_isalnum, "__",
0, 0
};
int i;
for (i = 0; spnames[i].n; i++)
if (c_isalnum == 0)
return (0);
}
int
char *s;
{
int i;
for (i = 0; chtab[i] != 0; i++)
return(i + _SPECCHAR_ST);
return(0);
}
int
twdone()
{
int waitf;
if (t.twrest) /* has ptinit() been done yet? */
flusho();
if (pipeflg) {
}
restore_tty();
return (0);
}
int
ptout(i)
tchar i;
{
*olinep++ = i;
olinep--;
if (cbits(i) != '\n')
return (0);
olinep--;
move();
ptout1();
} else {
move();
}
return (0);
}
int
ptout1()
{
int k;
char *codep;
#ifdef EUC
#ifdef NROFF
int cnt;
#endif /* NROFF */
#endif /* EUC */
extern char *plot();
int w, j, phyw;
#ifdef EUC
#ifdef NROFF
int jj;
#endif /* NROFF */
#endif /* EUC */
tchar * q, i;
i = *q;
if (ismot(i)) {
j = absmot(i);
if (isnmot(i))
j = -j;
if (isvmot(i))
lead += j;
else
esc += j;
continue;
}
if ((k = cbits(i)) <= 040) {
switch (k) {
case ' ': /*space*/
break;
case '\033':
case '\007':
case '\016':
case '\017':
oput(k);
break;
}
continue;
}
#ifdef EUC
#ifdef NROFF
cnt = 0;
cnt++;
q++;
}
q -= cnt;
cnt = 0;
*q &= ~0xfe00;
}
k = cbits(i = *q);
} else {
#endif /* NROFF */
#endif /* EUC */
if (iszbit(i))
w = 0;
#ifdef EUC
#ifdef NROFF
}
#endif /* NROFF */
#endif /* EUC */
move();
esct += w;
#ifndef EUC
#else
#ifndef NROFF
#else
#endif /* NROFF */
#endif /* EUC */
}
for (j = w / t.Char; j > 0; j--)
oput('_');
for (j = w / t.Char; j > 0; j--)
oput('\b');
}
j++;
else
j = 1; /* number of overstrikes for bold */
if (k < 128) { /* ordinary ascii */
oput(k);
while (--j > 0) {
oput('\b');
oput(k);
}
#ifdef EUC
#ifdef NROFF
} else if (multi_locale && (k & CSMASK)) {
while (--j > 0) {
oput('\b');
}
} else if (k < 256) {
/*
* Invalid character for C locale or
* non-printable 8-bit single byte
* character such as <no-break-sp>
* in ISO-8859-1
*/
oput(k);
while (--j > 0) {
oput('\b');
oput(k);
}
#endif /* NROFF */
#endif /* EUC */
} else if (k >= nchtab + _SPECCHAR_ST) {
} else {
int oj = j;
while (*codep != 0) {
if (*codep & 0200) {
oput(' ');
} else {
codep++;
if (*codep == '\033')
else if (*codep != '\b')
for (j = oj; --j > 0; ) {
oput('\b');
}
codep++;
}
}
}
if (!w)
oput('\b');
}
return (0);
}
char *plot(x)
char *x;
{
int i;
char *j, *k;
k = x;
if ((*k & 0377) == 0200)
k++;
for (; *k; k++) {
if (*k == '%') { /* quote char within plot mode */
oput(*++k);
} else if (*k & 0200) {
if (*k & 0100) {
if (*k & 040)
j = t.up;
else
j = t.down;
} else {
if (*k & 040)
j = t.left;
else
j = t.right;
}
if ((i = *k & 037) == 0) { /* 2nd 0200 turns it off */
++k;
break;
}
while (i--)
oputs(j);
} else
oput(*k);
}
return(k);
}
int
move()
{
int k;
char *i, *j;
char *p, *q;
i = "\0";
else
i = "\n\0";
j = t.hlf;
p = t.right;
q = t.down;
if (lead) {
if (lead < 0) {
i = t.flr;
/* if(!esct)i = t.flr; else i = "\0";*/
j = t.hlr;
q = t.up;
}
if (*i & 0377) {
while (k--)
oputs(i);
}
if (*j & 0377) {
while (k--)
oputs(j);
} else { /* no half-line forward, not at line begining */
if (k > 0)
i = "\n";
while (k--)
oputs(i);
}
}
if (esc) {
if (esc < 0) {
j = "\b";
p = t.left;
} else {
j = " ";
if (hflg)
break;
}
}
while (k--)
oputs(j);
}
while (esc--)
oputs(p);
while (lead--)
oputs(q);
}
return (0);
}
int
ptlead()
{
move();
return (0);
}
int
dostop()
{
char junk;
flusho();
return (0);
}
int
newpage()
{
return (0);
}
int
{
return (0);
}