xref: /titanic_51/usr/src/lib/libcurses/screen/print.c (revision 004388ebfdfe2ed7dfd2d153a876dfcc22d2c006)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*004388ebScasper  * Common Development and Distribution License (the "License").
6*004388ebScasper  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*004388ebScasper  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
317c478bd9Sstevel@tonic-gate  * The Regents of the University of California
327c478bd9Sstevel@tonic-gate  * All Rights Reserved
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
357c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
367c478bd9Sstevel@tonic-gate  * contributors.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <stdlib.h>
427c478bd9Sstevel@tonic-gate #include <string.h>
437c478bd9Sstevel@tonic-gate #include <sys/types.h>
447c478bd9Sstevel@tonic-gate #include "curses_inc.h"
457c478bd9Sstevel@tonic-gate #include "print.h"
467c478bd9Sstevel@tonic-gate #include <signal.h>   /* use this file to determine if this is SVR4.0 system */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef SIGSTOP	/* SVR4.0 and beyond */
497c478bd9Sstevel@tonic-gate #define	_ULIBTI	"/usr/share/lib/terminfo"
507c478bd9Sstevel@tonic-gate #else
517c478bd9Sstevel@tonic-gate #define	_ULIBTI	"/usr/lib/terminfo"
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate char *progname;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /* global variables */
577c478bd9Sstevel@tonic-gate static enum printtypes printing = pr_none;
587c478bd9Sstevel@tonic-gate static int onecolumn = 0;		/* print a single column */
597c478bd9Sstevel@tonic-gate static int width = 60;			/* width of multi-column printing */
607c478bd9Sstevel@tonic-gate static int restrictterm = 1;		/* restrict termcap names */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /* local variables */
637c478bd9Sstevel@tonic-gate static int printed = 0;
647c478bd9Sstevel@tonic-gate static size_t caplen = 0;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate void
677c478bd9Sstevel@tonic-gate pr_init(enum printtypes type)
687c478bd9Sstevel@tonic-gate {
697c478bd9Sstevel@tonic-gate 	printing = type;
707c478bd9Sstevel@tonic-gate }
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate void
737c478bd9Sstevel@tonic-gate pr_onecolumn(int onoff)
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate 	onecolumn = onoff;
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate void
797c478bd9Sstevel@tonic-gate pr_width(int nwidth)
807c478bd9Sstevel@tonic-gate {
817c478bd9Sstevel@tonic-gate 	if (nwidth > 0)
827c478bd9Sstevel@tonic-gate 		width = nwidth;
837c478bd9Sstevel@tonic-gate }
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate void
867c478bd9Sstevel@tonic-gate pr_caprestrict(int onoff)
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate 	restrictterm = onoff;
897c478bd9Sstevel@tonic-gate }
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate static char capbools[] =
927c478bd9Sstevel@tonic-gate 	"ambsbwdadbeoeshchshzinkmmimsncnsosptulxbxnxoxsxt";
937c478bd9Sstevel@tonic-gate static int ncapbools = sizeof (capbools) / sizeof (capbools[0]);
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate static char capnums[] =
967c478bd9Sstevel@tonic-gate 	"codBdCdFdNdTknlipbsgug";
977c478bd9Sstevel@tonic-gate static int ncapnums = sizeof (capnums) / sizeof (capnums[0]);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate static char capstrs[] =
1007c478bd9Sstevel@tonic-gate 	"ALDCDLDOICLERISFSRUPaealasbcbtcdcechclcmcsctcvdcdldmdsedeifshoi1i2i"
1017c478bd9Sstevel@tonic-gate 	    "cifimipisk0k1k2k3k4k5k6k7k8k9kbkdkekhklkokrkskul0l1l2l3l4l5l6l7l"
1027c478bd9Sstevel@tonic-gate 	    "8l9ndnlpcr1r2r3rcrfrpscsesosrsttetitsucueupusvbvevivs";
1037c478bd9Sstevel@tonic-gate static int ncapstrs = sizeof (capstrs) / sizeof (capstrs[0]);
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate static int
1067c478bd9Sstevel@tonic-gate findcapname(char *capname, char *caplist, int listsize)
1077c478bd9Sstevel@tonic-gate {
1087c478bd9Sstevel@tonic-gate 	int low = 0, mid, high = listsize - 2;
1097c478bd9Sstevel@tonic-gate 	while (low <= high) {
1107c478bd9Sstevel@tonic-gate 		mid = (low + high) / 4 * 2;
1117c478bd9Sstevel@tonic-gate 		if (capname[0] == caplist[mid]) {
1127c478bd9Sstevel@tonic-gate 			if (capname[1] == caplist[mid + 1])
1137c478bd9Sstevel@tonic-gate 				return (1);
1147c478bd9Sstevel@tonic-gate 			else if (capname[1] < caplist[mid + 1])
1157c478bd9Sstevel@tonic-gate 				high = mid - 2;
1167c478bd9Sstevel@tonic-gate 			else
1177c478bd9Sstevel@tonic-gate 				low = mid + 2;
1187c478bd9Sstevel@tonic-gate 		} else if (capname[0] < caplist[mid])
1197c478bd9Sstevel@tonic-gate 			high = mid - 2;
1207c478bd9Sstevel@tonic-gate 		else
1217c478bd9Sstevel@tonic-gate 			low = mid + 2;
1227c478bd9Sstevel@tonic-gate 	}
1237c478bd9Sstevel@tonic-gate 	return (0);
1247c478bd9Sstevel@tonic-gate /*
1257c478bd9Sstevel@tonic-gate  *	for (; *caplist; caplist += 2)
1267c478bd9Sstevel@tonic-gate  *		if (caplist[0] == capname[0] && caplist[1] == capname[1])
1277c478bd9Sstevel@tonic-gate  *			return (1);
1287c478bd9Sstevel@tonic-gate  *	return (0);
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  *  Print out the first line of an entry.
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate void
1367c478bd9Sstevel@tonic-gate pr_heading(char *term, char *synonyms)
1377c478bd9Sstevel@tonic-gate {
1387c478bd9Sstevel@tonic-gate 	int	do_print = 0;	/* Can we print the path of the file ? */
1397c478bd9Sstevel@tonic-gate 	char	buffer[512];	/* Holds search pathname */
1407c478bd9Sstevel@tonic-gate 	FILE	*work_fp;	/* Used to try and open the files */
1417c478bd9Sstevel@tonic-gate 	char	tail[4];	/* Used for terminfo pathname suffix */
1427c478bd9Sstevel@tonic-gate 	char	*terminfo;	/* The value of $TERMINFO */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	/*
1467c478bd9Sstevel@tonic-gate 	 *	Try to obtain $TERMINFO
1477c478bd9Sstevel@tonic-gate 	 */
1487c478bd9Sstevel@tonic-gate 	terminfo = getenv("TERMINFO");
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	if (term == (char *)0)
1517c478bd9Sstevel@tonic-gate 		term = "";
1527c478bd9Sstevel@tonic-gate 	/*
1537c478bd9Sstevel@tonic-gate 	 *	Build the suffix for this device
1547c478bd9Sstevel@tonic-gate 	 */
1557c478bd9Sstevel@tonic-gate 	tail[0] = '/';
1567c478bd9Sstevel@tonic-gate 	tail[1] = *term;
1577c478bd9Sstevel@tonic-gate 	tail[2] = '/';
1587c478bd9Sstevel@tonic-gate 	tail[3] = '\0';
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 	/*
1617c478bd9Sstevel@tonic-gate 	 *	If we have it - use it, otherwise use /usr/share/lib/terminfo
1627c478bd9Sstevel@tonic-gate 	 *	as base directory
1637c478bd9Sstevel@tonic-gate 	 */
1647c478bd9Sstevel@tonic-gate 	if (terminfo != NULL)
1657c478bd9Sstevel@tonic-gate 		(void) sprintf(buffer, "%s%s%s", terminfo, tail, term);
1667c478bd9Sstevel@tonic-gate 	else
1677c478bd9Sstevel@tonic-gate 		(void) sprintf(buffer, "%s%s%s", _ULIBTI, tail, term);
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 	/*
1707c478bd9Sstevel@tonic-gate 	 *	Attempt to open the file.
1717c478bd9Sstevel@tonic-gate 	 */
172*004388ebScasper 	if ((work_fp = fopen(buffer, "rF")) == NULL) {
1737c478bd9Sstevel@tonic-gate 		/*
1747c478bd9Sstevel@tonic-gate 		 * Open failed. If we were looking in /usr/share/lib/terminfo
1757c478bd9Sstevel@tonic-gate 		 *	we are done, otherwise look there next.
1767c478bd9Sstevel@tonic-gate 		 */
1777c478bd9Sstevel@tonic-gate 		if (strncmp(buffer, _ULIBTI, strlen(_ULIBTI)) == 0) {
1787c478bd9Sstevel@tonic-gate 				/*
1797c478bd9Sstevel@tonic-gate 				 * We are done. Not in /usr/share/lib/terminfo,
1807c478bd9Sstevel@tonic-gate 				 *	and $TERMINFO is not set.
1817c478bd9Sstevel@tonic-gate 				 */
1827c478bd9Sstevel@tonic-gate 				(void) fprintf(stderr, "Error: Term \"%s\" not "
1837c478bd9Sstevel@tonic-gate 				    "found in %s\n", term, _ULIBTI);
1847c478bd9Sstevel@tonic-gate 		} else {
1857c478bd9Sstevel@tonic-gate 			/*
1867c478bd9Sstevel@tonic-gate 			 * Check /usr/share/lib/terminfo last. If this fails,
1877c478bd9Sstevel@tonic-gate 			 * all hope is lost as we know it is not in $TERMINFO.
1887c478bd9Sstevel@tonic-gate 			 */
1897c478bd9Sstevel@tonic-gate 			(void) sprintf(buffer, "%s%s%s", _ULIBTI, tail, term);
1907c478bd9Sstevel@tonic-gate 
191*004388ebScasper 			if ((work_fp = fopen(buffer, "rF")) == NULL) {
1927c478bd9Sstevel@tonic-gate 				/*
1937c478bd9Sstevel@tonic-gate 				 *	All hope is lost
1947c478bd9Sstevel@tonic-gate 				 */
1957c478bd9Sstevel@tonic-gate 				(void) fprintf(stderr, "Error: Term \"%s\" not "
1967c478bd9Sstevel@tonic-gate 				    "found in %s or %s\n", term, _ULIBTI,
1977c478bd9Sstevel@tonic-gate 				    getenv("TERMINFO"));
1987c478bd9Sstevel@tonic-gate 			} else do_print = 1;
1997c478bd9Sstevel@tonic-gate 		}
2007c478bd9Sstevel@tonic-gate 	} else do_print = 1;
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	/*
2037c478bd9Sstevel@tonic-gate 	 *	If we found it - print the comment(after closing the file)
2047c478bd9Sstevel@tonic-gate 	 */
2057c478bd9Sstevel@tonic-gate 	if (do_print && *term) {
2067c478bd9Sstevel@tonic-gate 		(void) fclose(work_fp);
2077c478bd9Sstevel@tonic-gate 		(void) printf("#	Reconstructed via infocmp from file: "
2087c478bd9Sstevel@tonic-gate 		    "%s\n", buffer);
2097c478bd9Sstevel@tonic-gate 	}
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 	switch ((int)printing) {
2127c478bd9Sstevel@tonic-gate 		case (int)pr_terminfo:
2137c478bd9Sstevel@tonic-gate 			(void) printf("%s,\n", synonyms);
2147c478bd9Sstevel@tonic-gate 			break;
2157c478bd9Sstevel@tonic-gate 		case (int)pr_cap:
2167c478bd9Sstevel@tonic-gate 			(void) printf("%s:\\\n", synonyms);
2177c478bd9Sstevel@tonic-gate 			caplen = strlen(synonyms) + 1;
2187c478bd9Sstevel@tonic-gate 			break;
2197c478bd9Sstevel@tonic-gate 		case (int)pr_longnames:
2207c478bd9Sstevel@tonic-gate 			(void) printf("Terminal type %s\n", term);
2217c478bd9Sstevel@tonic-gate 			(void) printf("  %s\n", synonyms);
2227c478bd9Sstevel@tonic-gate 			break;
2237c478bd9Sstevel@tonic-gate 	}
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate void
2277c478bd9Sstevel@tonic-gate pr_bheading(void)
2287c478bd9Sstevel@tonic-gate {
2297c478bd9Sstevel@tonic-gate 	if (printing == pr_longnames)
2307c478bd9Sstevel@tonic-gate 		(void) printf("flags\n");
2317c478bd9Sstevel@tonic-gate 	printed = 0;
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate void
2357c478bd9Sstevel@tonic-gate pr_boolean(char *infoname, char *capname, char *fullname, int value)
2367c478bd9Sstevel@tonic-gate {
2377c478bd9Sstevel@tonic-gate 	int	vlen;
2387c478bd9Sstevel@tonic-gate 	size_t	nlen;
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate 	if (printing == pr_cap && restrictterm &&
2417c478bd9Sstevel@tonic-gate 	    !findcapname(capname, capbools, ncapbools))
2427c478bd9Sstevel@tonic-gate 		return;
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 	if (onecolumn) {
2457c478bd9Sstevel@tonic-gate 		if (value < 0)
2467c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
2477c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
2487c478bd9Sstevel@tonic-gate 					(void) printf("\t%s@,\n", infoname);
2497c478bd9Sstevel@tonic-gate 					break;
2507c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
2517c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s@:\\\n", capname);
2527c478bd9Sstevel@tonic-gate 					caplen += 4 + strlen(capname);
2537c478bd9Sstevel@tonic-gate 					break;
2547c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
2557c478bd9Sstevel@tonic-gate 					(void) printf("  %s@\n", fullname);
2567c478bd9Sstevel@tonic-gate 			}
2577c478bd9Sstevel@tonic-gate 		else
2587c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
2597c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
2607c478bd9Sstevel@tonic-gate 					(void) printf("\t%s,\n", infoname);
2617c478bd9Sstevel@tonic-gate 					break;
2627c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
2637c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s:\\\n", capname);
2647c478bd9Sstevel@tonic-gate 					caplen += 3 + strlen(capname);
2657c478bd9Sstevel@tonic-gate 					break;
2667c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
2677c478bd9Sstevel@tonic-gate 					(void) printf("  %s\n", fullname);
2687c478bd9Sstevel@tonic-gate 			}
2697c478bd9Sstevel@tonic-gate 	} else {
2707c478bd9Sstevel@tonic-gate 		switch ((int)printing) {
2717c478bd9Sstevel@tonic-gate 			case (int)pr_terminfo:	nlen = strlen(infoname);
2727c478bd9Sstevel@tonic-gate 						break;
2737c478bd9Sstevel@tonic-gate 			case (int)pr_cap:	nlen = strlen(capname);
2747c478bd9Sstevel@tonic-gate 						break;
2757c478bd9Sstevel@tonic-gate 			case (int)pr_longnames:
2767c478bd9Sstevel@tonic-gate 						nlen = strlen(fullname);
2777c478bd9Sstevel@tonic-gate 						break;
2787c478bd9Sstevel@tonic-gate 		}
2797c478bd9Sstevel@tonic-gate 		vlen = (value < 0) ? 1 : 0;
2807c478bd9Sstevel@tonic-gate 		if ((printed > 0) && (printed + nlen + vlen + 1 > width)) {
2817c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
2827c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
2837c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
2847c478bd9Sstevel@tonic-gate 						(void) printf("\n");
2857c478bd9Sstevel@tonic-gate 						break;
2867c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
2877c478bd9Sstevel@tonic-gate 						(void) printf(":\\\n");
2887c478bd9Sstevel@tonic-gate 						caplen += 1;
2897c478bd9Sstevel@tonic-gate 			}
2907c478bd9Sstevel@tonic-gate 			printed = 0;
2917c478bd9Sstevel@tonic-gate 		}
2927c478bd9Sstevel@tonic-gate 		if (printed == 0) {
2937c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
2947c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
2957c478bd9Sstevel@tonic-gate 					(void) printf("\t");
2967c478bd9Sstevel@tonic-gate 					printed = 8;
2977c478bd9Sstevel@tonic-gate 					break;
2987c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
2997c478bd9Sstevel@tonic-gate 					(void) printf("\t:");
3007c478bd9Sstevel@tonic-gate 					printed = 9;
3017c478bd9Sstevel@tonic-gate 					caplen += 2;
3027c478bd9Sstevel@tonic-gate 					break;
3037c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
3047c478bd9Sstevel@tonic-gate 					(void) printf("  ");
3057c478bd9Sstevel@tonic-gate 					printed = 2;
3067c478bd9Sstevel@tonic-gate 			}
3077c478bd9Sstevel@tonic-gate 		} else {
3087c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
3097c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
3107c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
3117c478bd9Sstevel@tonic-gate 					(void) printf(" ");
3127c478bd9Sstevel@tonic-gate 					break;
3137c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
3147c478bd9Sstevel@tonic-gate 					(void) printf(":");
3157c478bd9Sstevel@tonic-gate 					caplen += 1;
3167c478bd9Sstevel@tonic-gate 			}
3177c478bd9Sstevel@tonic-gate 			printed++;
3187c478bd9Sstevel@tonic-gate 		}
3197c478bd9Sstevel@tonic-gate 		if (value < 0)
3207c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
3217c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
3227c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", infoname);
3237c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
3247c478bd9Sstevel@tonic-gate 					break;
3257c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
3267c478bd9Sstevel@tonic-gate 					(void) printf("%s@", capname);
3277c478bd9Sstevel@tonic-gate 					printed += nlen + 1;
3287c478bd9Sstevel@tonic-gate 					caplen += nlen + 1;
3297c478bd9Sstevel@tonic-gate 					break;
3307c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
3317c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", fullname);
3327c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
3337c478bd9Sstevel@tonic-gate 			}
3347c478bd9Sstevel@tonic-gate 		else
3357c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
3367c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
3377c478bd9Sstevel@tonic-gate 					(void) printf("%s,", infoname);
3387c478bd9Sstevel@tonic-gate 					printed += nlen + 1;
3397c478bd9Sstevel@tonic-gate 					break;
3407c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
3417c478bd9Sstevel@tonic-gate 					(void) printf("%s", capname);
3427c478bd9Sstevel@tonic-gate 					printed += nlen;
3437c478bd9Sstevel@tonic-gate 					caplen += nlen;
3447c478bd9Sstevel@tonic-gate 					break;
3457c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
3467c478bd9Sstevel@tonic-gate 					(void) printf("%s,", fullname);
3477c478bd9Sstevel@tonic-gate 					printed += nlen + 1;
3487c478bd9Sstevel@tonic-gate 			}
3497c478bd9Sstevel@tonic-gate 	}
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate void
3537c478bd9Sstevel@tonic-gate pr_bfooting(void)
3547c478bd9Sstevel@tonic-gate {
3557c478bd9Sstevel@tonic-gate 	if (!onecolumn && (printed > 0))
3567c478bd9Sstevel@tonic-gate 		switch ((int)printing) {
3577c478bd9Sstevel@tonic-gate 			case (int)pr_terminfo:
3587c478bd9Sstevel@tonic-gate 			case (int)pr_longnames:
3597c478bd9Sstevel@tonic-gate 				(void) printf("\n");
3607c478bd9Sstevel@tonic-gate 				break;
3617c478bd9Sstevel@tonic-gate 			case (int)pr_cap:
3627c478bd9Sstevel@tonic-gate 				(void) printf(":\\\n");
3637c478bd9Sstevel@tonic-gate 			caplen += 1;
3647c478bd9Sstevel@tonic-gate 	    }
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate void
3687c478bd9Sstevel@tonic-gate pr_nheading(void)
3697c478bd9Sstevel@tonic-gate {
3707c478bd9Sstevel@tonic-gate 	if (printing == pr_longnames)
3717c478bd9Sstevel@tonic-gate 		(void) printf("\nnumbers\n");
3727c478bd9Sstevel@tonic-gate 	printed = 0;
3737c478bd9Sstevel@tonic-gate }
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /*
3767c478bd9Sstevel@tonic-gate  *  Return the length of the number if it were printed out
3777c478bd9Sstevel@tonic-gate  *  with %d. The number is guaranteed to be in the range
3787c478bd9Sstevel@tonic-gate  *  0..maxshort.
3797c478bd9Sstevel@tonic-gate  */
3807c478bd9Sstevel@tonic-gate static int
3817c478bd9Sstevel@tonic-gate digitlen(int value)
3827c478bd9Sstevel@tonic-gate {
3837c478bd9Sstevel@tonic-gate 	return (value >= 10000 ? 5 :
3847c478bd9Sstevel@tonic-gate 	    value >=  1000 ? 4 :
3857c478bd9Sstevel@tonic-gate 	    value >=   100 ? 3 :
3867c478bd9Sstevel@tonic-gate 	    value >=    10 ? 2 :
3877c478bd9Sstevel@tonic-gate 	    value >=	0 ? 1 : 0);
3887c478bd9Sstevel@tonic-gate }
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate void
3917c478bd9Sstevel@tonic-gate pr_number(char *infoname, char *capname, char *fullname, int value)
3927c478bd9Sstevel@tonic-gate {
3937c478bd9Sstevel@tonic-gate 	int	vlen;
3947c478bd9Sstevel@tonic-gate 	size_t	nlen;
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate 	if (printing == pr_cap && restrictterm &&
3977c478bd9Sstevel@tonic-gate 	    !findcapname(capname, capnums, ncapnums))
3987c478bd9Sstevel@tonic-gate 		return;
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate 	if (onecolumn) {
4017c478bd9Sstevel@tonic-gate 		if (value < 0)
4027c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4037c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4047c478bd9Sstevel@tonic-gate 					(void) printf("\t%s@,\n", infoname);
4057c478bd9Sstevel@tonic-gate 					break;
4067c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4077c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s@:\\\n", capname);
4087c478bd9Sstevel@tonic-gate 					caplen += 4 + strlen(capname);
4097c478bd9Sstevel@tonic-gate 					break;
4107c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4117c478bd9Sstevel@tonic-gate 					(void) printf("  %s @\n", fullname);
4127c478bd9Sstevel@tonic-gate 			}
4137c478bd9Sstevel@tonic-gate 		else
4147c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4157c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4167c478bd9Sstevel@tonic-gate 					(void) printf("\t%s#%d,\n", infoname,
4177c478bd9Sstevel@tonic-gate 					    value);
4187c478bd9Sstevel@tonic-gate 					break;
4197c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4207c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s#%d:\\\n",
4217c478bd9Sstevel@tonic-gate 					    capname, value);
4227c478bd9Sstevel@tonic-gate 					caplen += 4 + strlen(capname) +
4237c478bd9Sstevel@tonic-gate 					    digitlen(value);
4247c478bd9Sstevel@tonic-gate 					break;
4257c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4267c478bd9Sstevel@tonic-gate 					(void) printf("  %s = %d\n", fullname,
4277c478bd9Sstevel@tonic-gate 					    value);
4287c478bd9Sstevel@tonic-gate 			}
4297c478bd9Sstevel@tonic-gate 	} else {
4307c478bd9Sstevel@tonic-gate 		switch ((int)printing) {
4317c478bd9Sstevel@tonic-gate 			case (int)pr_terminfo:
4327c478bd9Sstevel@tonic-gate 					nlen = strlen(infoname);
4337c478bd9Sstevel@tonic-gate 					break;
4347c478bd9Sstevel@tonic-gate 			case (int)pr_cap:
4357c478bd9Sstevel@tonic-gate 					nlen = strlen(capname);
4367c478bd9Sstevel@tonic-gate 					break;
4377c478bd9Sstevel@tonic-gate 			case (int)pr_longnames:
4387c478bd9Sstevel@tonic-gate 					nlen = strlen(fullname);
4397c478bd9Sstevel@tonic-gate 					break;
4407c478bd9Sstevel@tonic-gate 		}
4417c478bd9Sstevel@tonic-gate 		vlen = digitlen(value);
4427c478bd9Sstevel@tonic-gate 		if ((printed > 0) && (printed + nlen + vlen + 2 > width)) {
4437c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4447c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4457c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4467c478bd9Sstevel@tonic-gate 					(void) printf("\n");
4477c478bd9Sstevel@tonic-gate 					break;
4487c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4497c478bd9Sstevel@tonic-gate 					(void) printf(":\\\n");
4507c478bd9Sstevel@tonic-gate 					caplen += 1;
4517c478bd9Sstevel@tonic-gate 			}
4527c478bd9Sstevel@tonic-gate 			printed = 0;
4537c478bd9Sstevel@tonic-gate 		}
4547c478bd9Sstevel@tonic-gate 		if (printed == 0) {
4557c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4567c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4577c478bd9Sstevel@tonic-gate 					(void) printf("\t");
4587c478bd9Sstevel@tonic-gate 					printed = 8;
4597c478bd9Sstevel@tonic-gate 					break;
4607c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4617c478bd9Sstevel@tonic-gate 					(void) printf("\t:");
4627c478bd9Sstevel@tonic-gate 					printed = 9;
4637c478bd9Sstevel@tonic-gate 					caplen += 2;
4647c478bd9Sstevel@tonic-gate 					break;
4657c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4667c478bd9Sstevel@tonic-gate 					(void) printf("  ");
4677c478bd9Sstevel@tonic-gate 					printed = 2;
4687c478bd9Sstevel@tonic-gate 			}
4697c478bd9Sstevel@tonic-gate 		} else {
4707c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4717c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4727c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4737c478bd9Sstevel@tonic-gate 					(void) printf(" ");
4747c478bd9Sstevel@tonic-gate 					break;
4757c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4767c478bd9Sstevel@tonic-gate 					(void) printf(":");
4777c478bd9Sstevel@tonic-gate 					caplen += 1;
4787c478bd9Sstevel@tonic-gate 			}
4797c478bd9Sstevel@tonic-gate 			printed++;
4807c478bd9Sstevel@tonic-gate 		}
4817c478bd9Sstevel@tonic-gate 		if (value < 0) {
4827c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4837c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4847c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", infoname);
4857c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
4867c478bd9Sstevel@tonic-gate 					break;
4877c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
4887c478bd9Sstevel@tonic-gate 					(void) printf("%s@", capname);
4897c478bd9Sstevel@tonic-gate 					printed += nlen + 1;
4907c478bd9Sstevel@tonic-gate 					caplen += nlen + 1;
4917c478bd9Sstevel@tonic-gate 					break;
4927c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
4937c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", fullname);
4947c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
4957c478bd9Sstevel@tonic-gate 			}
4967c478bd9Sstevel@tonic-gate 		} else
4977c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
4987c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
4997c478bd9Sstevel@tonic-gate 					(void) printf("%s#%d,", infoname,
5007c478bd9Sstevel@tonic-gate 					    value);
5017c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 2;
5027c478bd9Sstevel@tonic-gate 					break;
5037c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
5047c478bd9Sstevel@tonic-gate 					(void) printf("%s#%d", capname, value);
5057c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 1;
5067c478bd9Sstevel@tonic-gate 					caplen += nlen + vlen + 1;
5077c478bd9Sstevel@tonic-gate 					break;
5087c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
5097c478bd9Sstevel@tonic-gate 					(void) printf("%s = %d,", fullname,
5107c478bd9Sstevel@tonic-gate 					    value);
5117c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 4;
5127c478bd9Sstevel@tonic-gate 			}
5137c478bd9Sstevel@tonic-gate 	}
5147c478bd9Sstevel@tonic-gate }
5157c478bd9Sstevel@tonic-gate 
5167c478bd9Sstevel@tonic-gate void
5177c478bd9Sstevel@tonic-gate pr_nfooting(void)
5187c478bd9Sstevel@tonic-gate {
5197c478bd9Sstevel@tonic-gate 	if (!onecolumn && (printed > 0))
5207c478bd9Sstevel@tonic-gate 		switch ((int)printing) {
5217c478bd9Sstevel@tonic-gate 			case (int)pr_terminfo:
5227c478bd9Sstevel@tonic-gate 			case (int)pr_longnames:
5237c478bd9Sstevel@tonic-gate 				(void) printf("\n");
5247c478bd9Sstevel@tonic-gate 				break;
5257c478bd9Sstevel@tonic-gate 			case (int)pr_cap:
5267c478bd9Sstevel@tonic-gate 				(void) printf(":\\\n");
5277c478bd9Sstevel@tonic-gate 				caplen += 1;
5287c478bd9Sstevel@tonic-gate 		}
5297c478bd9Sstevel@tonic-gate }
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate void
5327c478bd9Sstevel@tonic-gate pr_sheading(void)
5337c478bd9Sstevel@tonic-gate {
5347c478bd9Sstevel@tonic-gate 	if (printing == pr_longnames)
5357c478bd9Sstevel@tonic-gate 		(void) printf("\nstrings\n");
5367c478bd9Sstevel@tonic-gate 	printed = 0;
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate void
5407c478bd9Sstevel@tonic-gate pr_string(char *infoname, char *capname, char *fullname, char *value)
5417c478bd9Sstevel@tonic-gate {
5427c478bd9Sstevel@tonic-gate 	char *evalue;
5437c478bd9Sstevel@tonic-gate 	int badcapvalue;
5447c478bd9Sstevel@tonic-gate 	size_t nlen, vlen;
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate 	if (printing == pr_cap) {
5477c478bd9Sstevel@tonic-gate 		if (restrictterm && !findcapname(capname, capstrs, ncapstrs))
5487c478bd9Sstevel@tonic-gate 			return;
5497c478bd9Sstevel@tonic-gate 		if (value)
5507c478bd9Sstevel@tonic-gate 			value = infotocap(value, &badcapvalue);
5517c478bd9Sstevel@tonic-gate 	}
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate 	if (onecolumn) {
5547c478bd9Sstevel@tonic-gate 		if (value == NULL)
5557c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
5567c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
5577c478bd9Sstevel@tonic-gate 					(void) printf("\t%s@,\n", infoname);
5587c478bd9Sstevel@tonic-gate 					break;
5597c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
5607c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s@:\\\n", capname);
5617c478bd9Sstevel@tonic-gate 					caplen += 4 + strlen(capname);
5627c478bd9Sstevel@tonic-gate 					break;
5637c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
5647c478bd9Sstevel@tonic-gate 					(void) printf("  %s@\n", fullname);
5657c478bd9Sstevel@tonic-gate 			}
5667c478bd9Sstevel@tonic-gate 		else
5677c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
5687c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
5697c478bd9Sstevel@tonic-gate 					(void) printf("\t%s=", infoname);
5707c478bd9Sstevel@tonic-gate 					tpr(stdout, value);
5717c478bd9Sstevel@tonic-gate 					(void) printf(",\n");
5727c478bd9Sstevel@tonic-gate 					break;
5737c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
5747c478bd9Sstevel@tonic-gate 					(void) printf("\t:%s%s=",
5757c478bd9Sstevel@tonic-gate 					    badcapvalue ? "." : "", capname);
5767c478bd9Sstevel@tonic-gate 					caplen += 3 + strlen(capname) +
5777c478bd9Sstevel@tonic-gate 					    (badcapvalue ? 1 : 0);
5787c478bd9Sstevel@tonic-gate 					caplen += cpr(stdout, value);
5797c478bd9Sstevel@tonic-gate 					(void) printf(":\\\n");
5807c478bd9Sstevel@tonic-gate 					caplen += 1;
5817c478bd9Sstevel@tonic-gate 					break;
5827c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
5837c478bd9Sstevel@tonic-gate 					(void) printf("  %s = '", fullname);
5847c478bd9Sstevel@tonic-gate 					tpr(stdout, value);
5857c478bd9Sstevel@tonic-gate 					(void) printf("'\n");
5867c478bd9Sstevel@tonic-gate 			}
5877c478bd9Sstevel@tonic-gate 	} else {
5887c478bd9Sstevel@tonic-gate 		switch ((int)printing) {
5897c478bd9Sstevel@tonic-gate 			case (int)pr_terminfo:
5907c478bd9Sstevel@tonic-gate 				nlen = strlen(infoname);
5917c478bd9Sstevel@tonic-gate 				break;
5927c478bd9Sstevel@tonic-gate 			case (int)pr_cap:
5937c478bd9Sstevel@tonic-gate 				nlen = strlen(capname);
5947c478bd9Sstevel@tonic-gate 				if (badcapvalue)
5957c478bd9Sstevel@tonic-gate 					nlen++;
5967c478bd9Sstevel@tonic-gate 				break;
5977c478bd9Sstevel@tonic-gate 			case (int)pr_longnames:
5987c478bd9Sstevel@tonic-gate 				nlen = strlen(fullname);
5997c478bd9Sstevel@tonic-gate 		}
6007c478bd9Sstevel@tonic-gate 		if (value == NULL)
6017c478bd9Sstevel@tonic-gate 			vlen = 1;
6027c478bd9Sstevel@tonic-gate 		else
6037c478bd9Sstevel@tonic-gate 			if (printing == pr_cap)
6047c478bd9Sstevel@tonic-gate 				vlen = strlen(evalue = cexpand(value));
6057c478bd9Sstevel@tonic-gate 			else
6067c478bd9Sstevel@tonic-gate 				vlen = strlen(evalue = iexpand(value));
6077c478bd9Sstevel@tonic-gate 		if ((printed > 0) && (printed + nlen + vlen + 1 > width)) {
6087c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6097c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6107c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6117c478bd9Sstevel@tonic-gate 					(void) printf("\n");
6127c478bd9Sstevel@tonic-gate 					break;
6137c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
6147c478bd9Sstevel@tonic-gate 					(void) printf(":\\\n");
6157c478bd9Sstevel@tonic-gate 					caplen += 1;
6167c478bd9Sstevel@tonic-gate 			}
6177c478bd9Sstevel@tonic-gate 			printed = 0;
6187c478bd9Sstevel@tonic-gate 		}
6197c478bd9Sstevel@tonic-gate 		if (printed == 0) {
6207c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6217c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6227c478bd9Sstevel@tonic-gate 					(void) printf("\t");
6237c478bd9Sstevel@tonic-gate 					printed = 8;
6247c478bd9Sstevel@tonic-gate 					break;
6257c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
6267c478bd9Sstevel@tonic-gate 					(void) printf("\t:");
6277c478bd9Sstevel@tonic-gate 					printed = 9;
6287c478bd9Sstevel@tonic-gate 					caplen += 2;
6297c478bd9Sstevel@tonic-gate 					break;
6307c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6317c478bd9Sstevel@tonic-gate 					(void) printf("  ");
6327c478bd9Sstevel@tonic-gate 					printed = 2;
6337c478bd9Sstevel@tonic-gate 			}
6347c478bd9Sstevel@tonic-gate 		} else {
6357c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6367c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6377c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6387c478bd9Sstevel@tonic-gate 					(void) printf(" ");
6397c478bd9Sstevel@tonic-gate 					break;
6407c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
6417c478bd9Sstevel@tonic-gate 					(void) printf(":");
6427c478bd9Sstevel@tonic-gate 					caplen += 1;
6437c478bd9Sstevel@tonic-gate 			}
6447c478bd9Sstevel@tonic-gate 			printed++;
6457c478bd9Sstevel@tonic-gate 		}
6467c478bd9Sstevel@tonic-gate 		if (value == NULL) {
6477c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6487c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6497c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", infoname);
6507c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
6517c478bd9Sstevel@tonic-gate 					break;
6527c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
6537c478bd9Sstevel@tonic-gate 					(void) printf("%s@", capname);
6547c478bd9Sstevel@tonic-gate 					printed += nlen + 1;
6557c478bd9Sstevel@tonic-gate 					caplen += nlen + 1;
6567c478bd9Sstevel@tonic-gate 					break;
6577c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6587c478bd9Sstevel@tonic-gate 					(void) printf("%s@,", fullname);
6597c478bd9Sstevel@tonic-gate 					printed += nlen + 2;
6607c478bd9Sstevel@tonic-gate 			}
6617c478bd9Sstevel@tonic-gate 		} else
6627c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6637c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6647c478bd9Sstevel@tonic-gate 					(void) printf("%s=%s,", infoname,
6657c478bd9Sstevel@tonic-gate 					    evalue);
6667c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 2;
6677c478bd9Sstevel@tonic-gate 					break;
6687c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
6697c478bd9Sstevel@tonic-gate 					if (badcapvalue) {
6707c478bd9Sstevel@tonic-gate 						(void) printf(".");
6717c478bd9Sstevel@tonic-gate 						caplen += 1;
6727c478bd9Sstevel@tonic-gate 					}
6737c478bd9Sstevel@tonic-gate 					(void) printf("%s=%s", capname,
6747c478bd9Sstevel@tonic-gate 					    evalue);
6757c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 1;
6767c478bd9Sstevel@tonic-gate 					caplen += nlen + vlen + 1;
6777c478bd9Sstevel@tonic-gate 					break;
6787c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6797c478bd9Sstevel@tonic-gate 					(void) printf("%s = '%s',", fullname,
6807c478bd9Sstevel@tonic-gate 					    evalue);
6817c478bd9Sstevel@tonic-gate 					printed += nlen + vlen + 6;
6827c478bd9Sstevel@tonic-gate 			}
6837c478bd9Sstevel@tonic-gate 	}
6847c478bd9Sstevel@tonic-gate }
6857c478bd9Sstevel@tonic-gate 
6867c478bd9Sstevel@tonic-gate void
6877c478bd9Sstevel@tonic-gate pr_sfooting(void)
6887c478bd9Sstevel@tonic-gate {
6897c478bd9Sstevel@tonic-gate 	if (onecolumn) {
6907c478bd9Sstevel@tonic-gate 		if (printing == pr_cap)
6917c478bd9Sstevel@tonic-gate 			(void) printf("\n");
6927c478bd9Sstevel@tonic-gate 	} else {
6937c478bd9Sstevel@tonic-gate 		if (printed > 0)
6947c478bd9Sstevel@tonic-gate 			switch ((int)printing) {
6957c478bd9Sstevel@tonic-gate 				case (int)pr_terminfo:
6967c478bd9Sstevel@tonic-gate 				case (int)pr_longnames:
6977c478bd9Sstevel@tonic-gate 					(void) printf("\n");
6987c478bd9Sstevel@tonic-gate 					break;
6997c478bd9Sstevel@tonic-gate 				case (int)pr_cap:
7007c478bd9Sstevel@tonic-gate 					(void) printf(":\n");
7017c478bd9Sstevel@tonic-gate 					caplen += 1;
7027c478bd9Sstevel@tonic-gate 			}
7037c478bd9Sstevel@tonic-gate 	}
7047c478bd9Sstevel@tonic-gate 	if (caplen >= 1024) {
7057c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "%s: WARNING: termcap entry is too "
7067c478bd9Sstevel@tonic-gate 		    "long!\n", progname);
7077c478bd9Sstevel@tonic-gate 	}
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate 	if (printing == pr_longnames)
7107c478bd9Sstevel@tonic-gate 		(void) printf("end of strings\n");
7117c478bd9Sstevel@tonic-gate }
712