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
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright (c) 1996, by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate * All rights reserved.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /*
28*1da57d55SToomas Soome * tput.c
297c478bd9Sstevel@tonic-gate *
307c478bd9Sstevel@tonic-gate * Copyright 1990, 1994 by Mortice Kern Systems Inc. All rights reserved.
317c478bd9Sstevel@tonic-gate *
327c478bd9Sstevel@tonic-gate * PORTABILITY:
337c478bd9Sstevel@tonic-gate * SVID 3 - fully
347c478bd9Sstevel@tonic-gate * POSIX.2a UPE - needs clarification between SVID 3 exit statues.
357c478bd9Sstevel@tonic-gate * In particular exit 1 and 4 for string capnames.
367c478bd9Sstevel@tonic-gate * not in XPG 3
377c478bd9Sstevel@tonic-gate *
387c478bd9Sstevel@tonic-gate * SYNOPSIS:
397c478bd9Sstevel@tonic-gate * tput [-T<term>] capname [parm1..parm9]
407c478bd9Sstevel@tonic-gate * tput [-T<term>] -S
41*1da57d55SToomas Soome *
427c478bd9Sstevel@tonic-gate * DESCRIPTION:
437c478bd9Sstevel@tonic-gate * tput lets you change your terminal's characteristics. The capname
447c478bd9Sstevel@tonic-gate * argument indicates how you want to change the characteristics.
457c478bd9Sstevel@tonic-gate * Some special capnames are:
467c478bd9Sstevel@tonic-gate *
47*1da57d55SToomas Soome * clear clear the screen
48*1da57d55SToomas Soome * init initialize terminal in an implemenation-defined way
49*1da57d55SToomas Soome * reset reset terminal in an implemenation-defined way
507c478bd9Sstevel@tonic-gate * longname print the full name of the ternminal (SVID)
517c478bd9Sstevel@tonic-gate *
527c478bd9Sstevel@tonic-gate * Other capnames are supported and may take from 0 to 9 parameters. A
537c478bd9Sstevel@tonic-gate * list of them can be found in the SVID 3, vol 3. (SVID)
547c478bd9Sstevel@tonic-gate *
557c478bd9Sstevel@tonic-gate * tput does its work by outputting approriate character sequences to the
567c478bd9Sstevel@tonic-gate * standard output. These character sequences are terminal-specific. If
577c478bd9Sstevel@tonic-gate * you specify -T <type>, tput assumes that your terminal has the
587c478bd9Sstevel@tonic-gate * specified type and will issue sequences appropriate to that terminal.
597c478bd9Sstevel@tonic-gate *
607c478bd9Sstevel@tonic-gate * If you do not specify -T, tput looks for an environment variable
617c478bd9Sstevel@tonic-gate * named TERM. If TERM exists, its value is assumed to give the terminal
627c478bd9Sstevel@tonic-gate * type. If TERM does not exist, tput assumes a default terminal type.
637c478bd9Sstevel@tonic-gate *
647c478bd9Sstevel@tonic-gate * The -S option allows more than one capability per invocation of tput.
657c478bd9Sstevel@tonic-gate * The capabilities must be passed to tput from the standard input instead
66*1da57d55SToomas Soome * of the comamnd line. Only one capname is allowed per line.
677c478bd9Sstevel@tonic-gate *
68*1da57d55SToomas Soome * EXIT STATUS
697c478bd9Sstevel@tonic-gate * tput may return the following status values:
707c478bd9Sstevel@tonic-gate *
717c478bd9Sstevel@tonic-gate * 0 Either a boolean capname is set true or a string capname was
727c478bd9Sstevel@tonic-gate * successfully written to the terminal.
737c478bd9Sstevel@tonic-gate *
74*1da57d55SToomas Soome * 1 No error message is printed. Returned if a boolean capname is
757c478bd9Sstevel@tonic-gate * false or a string capname is not defined for the terminal.(SVID)
767c478bd9Sstevel@tonic-gate *
777c478bd9Sstevel@tonic-gate * 2 Usage error.
787c478bd9Sstevel@tonic-gate *
797c478bd9Sstevel@tonic-gate * 3 Unknown terminal <term> or no terminfo database.
807c478bd9Sstevel@tonic-gate *
817c478bd9Sstevel@tonic-gate * 4 Unknown terminfo capability <capname>.
827c478bd9Sstevel@tonic-gate *
83*1da57d55SToomas Soome * >4 An error occured.
847c478bd9Sstevel@tonic-gate *
857c478bd9Sstevel@tonic-gate *
867c478bd9Sstevel@tonic-gate * NOTE 1: If the Caps file that describes the terminfo database changes
877c478bd9Sstevel@tonic-gate * then a new term.h will be required. See CURSES/tic related tools.
887c478bd9Sstevel@tonic-gate *
897c478bd9Sstevel@tonic-gate * NOTE 2: tput has knowledge about the TERMINAL structure.
907c478bd9Sstevel@tonic-gate */
917c478bd9Sstevel@tonic-gate #ifdef M_RCSID
927c478bd9Sstevel@tonic-gate #ifndef lint
937c478bd9Sstevel@tonic-gate static char rcsID[] = "$Id: tput.c 1.28 1995/04/12 09:28:05 ross Exp $";
947c478bd9Sstevel@tonic-gate #endif
957c478bd9Sstevel@tonic-gate #endif
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate #include <mks.h>
987c478bd9Sstevel@tonic-gate #include <curses.h>
997c478bd9Sstevel@tonic-gate #include <term.h>
1007c478bd9Sstevel@tonic-gate #include <ctype.h>
1017c478bd9Sstevel@tonic-gate #include <limits.h>
1027c478bd9Sstevel@tonic-gate #include <stdarg.h>
1037c478bd9Sstevel@tonic-gate #include <stdio.h>
1047c478bd9Sstevel@tonic-gate #include <stdlib.h>
1057c478bd9Sstevel@tonic-gate #include <string.h>
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate extern char *_cmdname;
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate /* Exit Status */
1117c478bd9Sstevel@tonic-gate #define SUCCESS 0
1127c478bd9Sstevel@tonic-gate #define NOT_DEFINED 1
1137c478bd9Sstevel@tonic-gate #define USAGE 2
1147c478bd9Sstevel@tonic-gate #define BAD_TERMINAL 3
1157c478bd9Sstevel@tonic-gate #define NOT_VALID 4
1167c478bd9Sstevel@tonic-gate #define ERROR 5
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate static int S_flag = 0;
1197c478bd9Sstevel@tonic-gate static char *term_name;
1207c478bd9Sstevel@tonic-gate static char dumb_term[] = "dumb";
1217c478bd9Sstevel@tonic-gate static char usage_msg[] = m_textstr(4931, "\
1227c478bd9Sstevel@tonic-gate Usage: tput [-W] [-Tterm] capname [parm1..parm9]\n\
1237c478bd9Sstevel@tonic-gate tput [-W] [-Tterm] -S\n", "U");
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate STATREF void build_argv ANSI((int *ac, char ***av));
1267c478bd9Sstevel@tonic-gate STATREF int do_tput ANSI((int _argc, char **_argv));
1277c478bd9Sstevel@tonic-gate STATREF void init ANSI((void));
1287c478bd9Sstevel@tonic-gate STATREF void reset ANSI((void));
1297c478bd9Sstevel@tonic-gate STATREF int usage ANSI((void));
1307c478bd9Sstevel@tonic-gate STATREF void err_msg ANSI((char *fmt, ...)); /* GENTEXT: err_msg */
1317c478bd9Sstevel@tonic-gate STATREF void cat ANSI((char *_Fn));
1327c478bd9Sstevel@tonic-gate
1337c478bd9Sstevel@tonic-gate /*f
1347c478bd9Sstevel@tonic-gate * mainline for tput
1357c478bd9Sstevel@tonic-gate */
136*1da57d55SToomas Soome int
main(argc,argv)1377c478bd9Sstevel@tonic-gate main(argc, argv)
1387c478bd9Sstevel@tonic-gate int argc;
1397c478bd9Sstevel@tonic-gate char **argv;
1407c478bd9Sstevel@tonic-gate {
1417c478bd9Sstevel@tonic-gate int opt;
1427c478bd9Sstevel@tonic-gate int err_code;
1437c478bd9Sstevel@tonic-gate setlocale(LC_ALL, "");
1447c478bd9Sstevel@tonic-gate _cmdname = m_cmdname(*argv);
1457c478bd9Sstevel@tonic-gate if ((term_name = getenv("TERM")) == NULL) {
1467c478bd9Sstevel@tonic-gate term_name = dumb_term;
1477c478bd9Sstevel@tonic-gate } else {
1487c478bd9Sstevel@tonic-gate term_name = m_strdup(term_name);
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gate /* Default uses the terminfo database without modification. */
1527c478bd9Sstevel@tonic-gate use_env(0);
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate while ((opt = getopt(argc, argv, "ST:W")) != -1) {
1557c478bd9Sstevel@tonic-gate switch (opt) {
1567c478bd9Sstevel@tonic-gate case 'W':
1577c478bd9Sstevel@tonic-gate /* Environment/window size are consulted and may
1587c478bd9Sstevel@tonic-gate * alter the database entries for lines and columns.
159*1da57d55SToomas Soome */
1607c478bd9Sstevel@tonic-gate use_env(1);
1617c478bd9Sstevel@tonic-gate break;
1627c478bd9Sstevel@tonic-gate case 'S':
1637c478bd9Sstevel@tonic-gate S_flag = 1;
1647c478bd9Sstevel@tonic-gate break;
1657c478bd9Sstevel@tonic-gate
1667c478bd9Sstevel@tonic-gate case 'T':
1677c478bd9Sstevel@tonic-gate term_name = optarg;
1687c478bd9Sstevel@tonic-gate break;
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate default:
1717c478bd9Sstevel@tonic-gate return (usage());
1727c478bd9Sstevel@tonic-gate }
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gate argc -= optind;
1767c478bd9Sstevel@tonic-gate argv += optind;
1777c478bd9Sstevel@tonic-gate
1787c478bd9Sstevel@tonic-gate if ((S_flag ^ (argc <= 0)) == 1)
1797c478bd9Sstevel@tonic-gate return (usage());
1807c478bd9Sstevel@tonic-gate (void) setupterm(term_name, fileno(stdout), &err_code);
1817c478bd9Sstevel@tonic-gate switch (err_code) {
1827c478bd9Sstevel@tonic-gate case 1:
1837c478bd9Sstevel@tonic-gate break;
1847c478bd9Sstevel@tonic-gate case 0:
185*1da57d55SToomas Soome err_msg(m_textstr(202, "Unknown terminal \"%s\".\n", "E term"), term_name);
1867c478bd9Sstevel@tonic-gate return (BAD_TERMINAL);
1877c478bd9Sstevel@tonic-gate case -1:
188*1da57d55SToomas Soome err_msg(m_textstr(203, "No terminfo database.\n", "E"));
1897c478bd9Sstevel@tonic-gate return (BAD_TERMINAL);
1907c478bd9Sstevel@tonic-gate }
1917c478bd9Sstevel@tonic-gate do {
1927c478bd9Sstevel@tonic-gate if (S_flag) {
1937c478bd9Sstevel@tonic-gate build_argv(&argc, &argv);
1947c478bd9Sstevel@tonic-gate if (argc <= 0)
1957c478bd9Sstevel@tonic-gate break;
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate err_code = do_tput(argc, argv);
1987c478bd9Sstevel@tonic-gate } while (S_flag && err_code == SUCCESS);
1997c478bd9Sstevel@tonic-gate return (err_code);
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate /*f
2037c478bd9Sstevel@tonic-gate * Get an input line from stdin and then break it up into an argv array.
2047c478bd9Sstevel@tonic-gate * If EOF is reached then S_flag is set to 0. Only the first 10 strings
205*1da57d55SToomas Soome * are of any interest. Any extra are ignored.
2067c478bd9Sstevel@tonic-gate */
207*1da57d55SToomas Soome STATIC void
build_argv(ac,av)2087c478bd9Sstevel@tonic-gate build_argv(ac, av)
2097c478bd9Sstevel@tonic-gate int *ac;
2107c478bd9Sstevel@tonic-gate char ***av;
2117c478bd9Sstevel@tonic-gate {
2127c478bd9Sstevel@tonic-gate int i = 0;
2137c478bd9Sstevel@tonic-gate char *p;
2147c478bd9Sstevel@tonic-gate static char *v[10+1];
2157c478bd9Sstevel@tonic-gate static char buf[LINE_MAX];
2167c478bd9Sstevel@tonic-gate if ((*v = fgets(buf, LINE_MAX, stdin)) == NULL) {
2177c478bd9Sstevel@tonic-gate /* End of file or input error */
2187c478bd9Sstevel@tonic-gate S_flag = 0;
2197c478bd9Sstevel@tonic-gate } else {
2207c478bd9Sstevel@tonic-gate if ((p = strchr(buf, '\n')) != NULL)
2217c478bd9Sstevel@tonic-gate *p = '\0';
2227c478bd9Sstevel@tonic-gate for (p = buf; i < 10;) {
2237c478bd9Sstevel@tonic-gate while (isspace(*(unsigned char*) p))
2247c478bd9Sstevel@tonic-gate ++p;
2257c478bd9Sstevel@tonic-gate if (*p == '\0')
2267c478bd9Sstevel@tonic-gate break;
2277c478bd9Sstevel@tonic-gate v[i++] = p;
2287c478bd9Sstevel@tonic-gate while (!isspace(*(unsigned char*) p) && *p != '\0')
2297c478bd9Sstevel@tonic-gate ++p;
2307c478bd9Sstevel@tonic-gate if (*p == '\0')
231*1da57d55SToomas Soome break;
2327c478bd9Sstevel@tonic-gate *p++ = '\0';
2337c478bd9Sstevel@tonic-gate }
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate v[i] = NULL;
2367c478bd9Sstevel@tonic-gate *ac = i;
2377c478bd9Sstevel@tonic-gate *av = v;
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate /*f
241*1da57d55SToomas Soome *
2427c478bd9Sstevel@tonic-gate */
2437c478bd9Sstevel@tonic-gate STATIC int
do_tput(_argc,_argv)2447c478bd9Sstevel@tonic-gate do_tput(_argc, _argv)
2457c478bd9Sstevel@tonic-gate int _argc;
2467c478bd9Sstevel@tonic-gate char **_argv;
2477c478bd9Sstevel@tonic-gate {
2487c478bd9Sstevel@tonic-gate int i;
2497c478bd9Sstevel@tonic-gate long q[9];
2507c478bd9Sstevel@tonic-gate const char *p;
2517c478bd9Sstevel@tonic-gate char *end_num;
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate if (strcmp(*_argv, "init") == 0)
2547c478bd9Sstevel@tonic-gate init();
2557c478bd9Sstevel@tonic-gate else if (strcmp(*_argv, "reset") == 0)
2567c478bd9Sstevel@tonic-gate reset();
2577c478bd9Sstevel@tonic-gate else if (strcmp(*_argv, "longname") == 0)
2587c478bd9Sstevel@tonic-gate (void) printf("%s\n", longname());
2597c478bd9Sstevel@tonic-gate else if ((i = tigetflag(*_argv)) != -1)
2607c478bd9Sstevel@tonic-gate return (!i);
2617c478bd9Sstevel@tonic-gate else if ((i = tigetnum(*_argv)) != -2)
2627c478bd9Sstevel@tonic-gate (void) printf("%d\n", i);
2637c478bd9Sstevel@tonic-gate else if ((p = tigetstr(*_argv)) != (char*) -1) {
2647c478bd9Sstevel@tonic-gate if (p == NULL)
2657c478bd9Sstevel@tonic-gate return (NOT_DEFINED);
2667c478bd9Sstevel@tonic-gate for (i = 0; i < 9; ++i) {
2677c478bd9Sstevel@tonic-gate if (1 < _argc) {
2687c478bd9Sstevel@tonic-gate --_argc;
2697c478bd9Sstevel@tonic-gate q[i] = strtol(*++_argv, &end_num, 0);
2707c478bd9Sstevel@tonic-gate if (*end_num != '\0') {
2717c478bd9Sstevel@tonic-gate /* The parameter must be a string
2727c478bd9Sstevel@tonic-gate * so we save the pointer instead.
2737c478bd9Sstevel@tonic-gate */
2747c478bd9Sstevel@tonic-gate q[i] = (long) *_argv;
2757c478bd9Sstevel@tonic-gate }
2767c478bd9Sstevel@tonic-gate } else {
2777c478bd9Sstevel@tonic-gate q[i] = 0L;
278*1da57d55SToomas Soome }
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate (void) putp(tparm(p, q[0], q[1], q[2], q[3],
2817c478bd9Sstevel@tonic-gate q[4], q[5], q[6], q[7], q[8]
2827c478bd9Sstevel@tonic-gate ));
2837c478bd9Sstevel@tonic-gate fflush(stdout);
2847c478bd9Sstevel@tonic-gate } else {
2857c478bd9Sstevel@tonic-gate err_msg(m_textstr(1864, "Unknown terminfo capability \"%s\".\n", "E action"), *_argv);
2867c478bd9Sstevel@tonic-gate return (NOT_VALID);
2877c478bd9Sstevel@tonic-gate }
2887c478bd9Sstevel@tonic-gate return (SUCCESS);
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate /*f
292*1da57d55SToomas Soome *
2937c478bd9Sstevel@tonic-gate */
2947c478bd9Sstevel@tonic-gate STATIC void
init()2957c478bd9Sstevel@tonic-gate init()
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate if (init_prog != NULL)
2987c478bd9Sstevel@tonic-gate (void) system(init_prog);
2997c478bd9Sstevel@tonic-gate if (init_1string != NULL)
3007c478bd9Sstevel@tonic-gate putp(init_1string);
3017c478bd9Sstevel@tonic-gate if (init_2string != NULL)
3027c478bd9Sstevel@tonic-gate putp(init_2string);
3037c478bd9Sstevel@tonic-gate #if 0 /* currently not supported by our terminfo database */
3047c478bd9Sstevel@tonic-gate if (clear_margins != NULL)
3057c478bd9Sstevel@tonic-gate putp(clear_margins);
3067c478bd9Sstevel@tonic-gate if (set_left_margin != NULL)
3077c478bd9Sstevel@tonic-gate putp(set_left_margin);
3087c478bd9Sstevel@tonic-gate if (set_right_margin != NULL)
3097c478bd9Sstevel@tonic-gate putp(set_right_margin);
3107c478bd9Sstevel@tonic-gate #endif
311*1da57d55SToomas Soome /* TODO: setting of tabs using clear_all_tabs & set_tab. */
3127c478bd9Sstevel@tonic-gate if (init_file != NULL)
3137c478bd9Sstevel@tonic-gate cat(init_file);
3147c478bd9Sstevel@tonic-gate if (init_3string != NULL)
3157c478bd9Sstevel@tonic-gate putp(init_3string);
3167c478bd9Sstevel@tonic-gate }
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate /*f
319*1da57d55SToomas Soome *
3207c478bd9Sstevel@tonic-gate */
3217c478bd9Sstevel@tonic-gate STATIC void
reset()3227c478bd9Sstevel@tonic-gate reset()
3237c478bd9Sstevel@tonic-gate {
3247c478bd9Sstevel@tonic-gate if (reset_1string != NULL)
3257c478bd9Sstevel@tonic-gate putp(reset_1string);
3267c478bd9Sstevel@tonic-gate if (reset_2string != NULL)
3277c478bd9Sstevel@tonic-gate putp(reset_2string);
3287c478bd9Sstevel@tonic-gate if (reset_file != NULL)
3297c478bd9Sstevel@tonic-gate cat(reset_file);
3307c478bd9Sstevel@tonic-gate if (reset_3string != NULL)
3317c478bd9Sstevel@tonic-gate putp(reset_3string);
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate /*f
3357c478bd9Sstevel@tonic-gate * usage message for tput
3367c478bd9Sstevel@tonic-gate */
337*1da57d55SToomas Soome STATIC int
usage()3387c478bd9Sstevel@tonic-gate usage()
3397c478bd9Sstevel@tonic-gate {
3407c478bd9Sstevel@tonic-gate (void) fprintf(stderr, m_strmsg(usage_msg));
3417c478bd9Sstevel@tonic-gate return (USAGE);
3427c478bd9Sstevel@tonic-gate }
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate /*f
3457c478bd9Sstevel@tonic-gate * display error message
3467c478bd9Sstevel@tonic-gate */
3477c478bd9Sstevel@tonic-gate STATIC void
VARARG1(char *,fmt)3487c478bd9Sstevel@tonic-gate err_msg VARARG1(char*, fmt)
3497c478bd9Sstevel@tonic-gate {
3507c478bd9Sstevel@tonic-gate va_list ap;
3517c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: ", _cmdname);
3527c478bd9Sstevel@tonic-gate va_start(ap, fmt);
3537c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, m_strmsg(fmt), ap);
3547c478bd9Sstevel@tonic-gate va_end(ap);
3557c478bd9Sstevel@tonic-gate }
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate * Print a file via putp().
3597c478bd9Sstevel@tonic-gate */
3607c478bd9Sstevel@tonic-gate STATIC void
cat(fn)3617c478bd9Sstevel@tonic-gate cat(fn)
3627c478bd9Sstevel@tonic-gate char *fn;
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate FILE *fp;
3657c478bd9Sstevel@tonic-gate char buf[LINE_MAX+1];
3667c478bd9Sstevel@tonic-gate if ((fp = fopen(fn, "rb")) == NULL)
3677c478bd9Sstevel@tonic-gate return;
3687c478bd9Sstevel@tonic-gate while (fgets(buf, LINE_MAX, fp) != NULL)
3697c478bd9Sstevel@tonic-gate putp(buf);
3707c478bd9Sstevel@tonic-gate (void) fclose(fp);
3717c478bd9Sstevel@tonic-gate }
372