* Copyright (c) 1991 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)print.c 5.4 (Berkeley) 6/10/91";
static void binit
__P((char *));
static void bput
__P((char *));
static char *ccval
__P((int));
print(tp
, wp
, ldisc
, fmt
)
register struct cchar
*p
;
char buf1
[100], buf2
[100];
cnt
+= printf("tablet disc; ");
cnt
+= printf("slip disc; ");
cnt
+= printf("#%d disc; ", ldisc
);
ispeed
= cfgetispeed(tp
);
ospeed
= cfgetospeed(tp
);
printf("ispeed %d baud; ospeed %d baud;", ispeed
, ospeed
);
cnt
+= printf("speed %d baud;", ispeed
);
cnt
+= printf(" %d rows; %d columns;", wp
->ws_row
, wp
->ws_col
);
#define on(f) ((tmp&f) != 0)
if (fmt >= BSD || on(f) != d) \
put("-icanon", ICANON
, 1);
put("-iexten", IEXTEN
, 1);
put("-echoke", ECHOKE
, 0);
put("-echonl", ECHONL
, 0);
put("-echoctl", ECHOCTL
, 0);
put("-echoprt", ECHOPRT
, 0);
put("-altwerase", ALTWERASE
, 0);
put("-noflsh", NOFLSH
, 0);
put("-tostop", TOSTOP
, 0);
put("-mdmbuf", MDMBUF
, 0);
put("-flusho", FLUSHO
, 0);
put("-pendin", PENDIN
, 0);
put("-nokerninfo", NOKERNINFO
, 0);
put("-extproc", EXTPROC
, 0);
put("-istrip", ISTRIP
, 0);
put("-imaxbel", IMAXBEL
, 1);
put("-ignbrk", IGNBRK
, 0);
put("-brkint", BRKINT
, 1);
put("-ignpar", IGNPAR
, 0);
put("-parmrk", PARMRK
, 0);
put("-oxtabs", OXTABS
, 1);
/* control flags (hardware state) */
bput("-parenb" + on(PARENB
));
put("-parodd", PARODD
, 0);
put("-clocal", CLOCAL
, 0);
put("-cstopb", CSTOPB
, 0);
put("-crtscts", CRTSCTS
, 0);
/* special control characters */
for (p
= cchars1
; p
->name
; ++p
) {
(void)snprintf(buf1
, sizeof(buf1
), "%s = %s;",
p
->name
, ccval(cc
[p
->sub
]));
for (p
= cchars1
, cnt
= 0; p
->name
; ++p
) {
if (fmt
!= BSD
&& cc
[p
->sub
] == p
->def
)
(void)sprintf(buf1
+ cnt
* 8, WD
, p
->name
);
(void)sprintf(buf2
+ cnt
* 8, WD
, ccval(cc
[p
->sub
]));
if (++cnt
== LINELENGTH
/ 8) {
(void)printf("%s\n", buf1
);
(void)printf("%s\n", buf2
);
(void)printf("%s\n", buf1
);
(void)printf("%s\n", buf2
);
col
= printf("%s: %s", label
, s
);
if ((col
+ strlen(s
)) > LINELENGTH
) {
col
= printf("%s", s
) + 8;
if (c
== _POSIX_VDISABLE
)