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