1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996, by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate /* 30*7c478bd9Sstevel@tonic-gate * tput.c 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate * Copyright 1990, 1994 by Mortice Kern Systems Inc. All rights reserved. 33*7c478bd9Sstevel@tonic-gate * 34*7c478bd9Sstevel@tonic-gate * PORTABILITY: 35*7c478bd9Sstevel@tonic-gate * SVID 3 - fully 36*7c478bd9Sstevel@tonic-gate * POSIX.2a UPE - needs clarification between SVID 3 exit statues. 37*7c478bd9Sstevel@tonic-gate * In particular exit 1 and 4 for string capnames. 38*7c478bd9Sstevel@tonic-gate * not in XPG 3 39*7c478bd9Sstevel@tonic-gate * 40*7c478bd9Sstevel@tonic-gate * SYNOPSIS: 41*7c478bd9Sstevel@tonic-gate * tput [-T<term>] capname [parm1..parm9] 42*7c478bd9Sstevel@tonic-gate * tput [-T<term>] -S 43*7c478bd9Sstevel@tonic-gate * 44*7c478bd9Sstevel@tonic-gate * DESCRIPTION: 45*7c478bd9Sstevel@tonic-gate * tput lets you change your terminal's characteristics. The capname 46*7c478bd9Sstevel@tonic-gate * argument indicates how you want to change the characteristics. 47*7c478bd9Sstevel@tonic-gate * Some special capnames are: 48*7c478bd9Sstevel@tonic-gate * 49*7c478bd9Sstevel@tonic-gate * clear clear the screen 50*7c478bd9Sstevel@tonic-gate * init initialize terminal in an implemenation-defined way 51*7c478bd9Sstevel@tonic-gate * reset reset terminal in an implemenation-defined way 52*7c478bd9Sstevel@tonic-gate * longname print the full name of the ternminal (SVID) 53*7c478bd9Sstevel@tonic-gate * 54*7c478bd9Sstevel@tonic-gate * Other capnames are supported and may take from 0 to 9 parameters. A 55*7c478bd9Sstevel@tonic-gate * list of them can be found in the SVID 3, vol 3. (SVID) 56*7c478bd9Sstevel@tonic-gate * 57*7c478bd9Sstevel@tonic-gate * tput does its work by outputting approriate character sequences to the 58*7c478bd9Sstevel@tonic-gate * standard output. These character sequences are terminal-specific. If 59*7c478bd9Sstevel@tonic-gate * you specify -T <type>, tput assumes that your terminal has the 60*7c478bd9Sstevel@tonic-gate * specified type and will issue sequences appropriate to that terminal. 61*7c478bd9Sstevel@tonic-gate * 62*7c478bd9Sstevel@tonic-gate * If you do not specify -T, tput looks for an environment variable 63*7c478bd9Sstevel@tonic-gate * named TERM. If TERM exists, its value is assumed to give the terminal 64*7c478bd9Sstevel@tonic-gate * type. If TERM does not exist, tput assumes a default terminal type. 65*7c478bd9Sstevel@tonic-gate * 66*7c478bd9Sstevel@tonic-gate * The -S option allows more than one capability per invocation of tput. 67*7c478bd9Sstevel@tonic-gate * The capabilities must be passed to tput from the standard input instead 68*7c478bd9Sstevel@tonic-gate * of the comamnd line. Only one capname is allowed per line. 69*7c478bd9Sstevel@tonic-gate * 70*7c478bd9Sstevel@tonic-gate * EXIT STATUS 71*7c478bd9Sstevel@tonic-gate * tput may return the following status values: 72*7c478bd9Sstevel@tonic-gate * 73*7c478bd9Sstevel@tonic-gate * 0 Either a boolean capname is set true or a string capname was 74*7c478bd9Sstevel@tonic-gate * successfully written to the terminal. 75*7c478bd9Sstevel@tonic-gate * 76*7c478bd9Sstevel@tonic-gate * 1 No error message is printed. Returned if a boolean capname is 77*7c478bd9Sstevel@tonic-gate * false or a string capname is not defined for the terminal.(SVID) 78*7c478bd9Sstevel@tonic-gate * 79*7c478bd9Sstevel@tonic-gate * 2 Usage error. 80*7c478bd9Sstevel@tonic-gate * 81*7c478bd9Sstevel@tonic-gate * 3 Unknown terminal <term> or no terminfo database. 82*7c478bd9Sstevel@tonic-gate * 83*7c478bd9Sstevel@tonic-gate * 4 Unknown terminfo capability <capname>. 84*7c478bd9Sstevel@tonic-gate * 85*7c478bd9Sstevel@tonic-gate * >4 An error occured. 86*7c478bd9Sstevel@tonic-gate * 87*7c478bd9Sstevel@tonic-gate * 88*7c478bd9Sstevel@tonic-gate * NOTE 1: If the Caps file that describes the terminfo database changes 89*7c478bd9Sstevel@tonic-gate * then a new term.h will be required. See CURSES/tic related tools. 90*7c478bd9Sstevel@tonic-gate * 91*7c478bd9Sstevel@tonic-gate * NOTE 2: tput has knowledge about the TERMINAL structure. 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate #ifdef M_RCSID 94*7c478bd9Sstevel@tonic-gate #ifndef lint 95*7c478bd9Sstevel@tonic-gate static char rcsID[] = "$Id: tput.c 1.28 1995/04/12 09:28:05 ross Exp $"; 96*7c478bd9Sstevel@tonic-gate #endif 97*7c478bd9Sstevel@tonic-gate #endif 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #include <mks.h> 100*7c478bd9Sstevel@tonic-gate #include <curses.h> 101*7c478bd9Sstevel@tonic-gate #include <term.h> 102*7c478bd9Sstevel@tonic-gate #include <ctype.h> 103*7c478bd9Sstevel@tonic-gate #include <limits.h> 104*7c478bd9Sstevel@tonic-gate #include <stdarg.h> 105*7c478bd9Sstevel@tonic-gate #include <stdio.h> 106*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 107*7c478bd9Sstevel@tonic-gate #include <string.h> 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate extern char *_cmdname; 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* Exit Status */ 113*7c478bd9Sstevel@tonic-gate #define SUCCESS 0 114*7c478bd9Sstevel@tonic-gate #define NOT_DEFINED 1 115*7c478bd9Sstevel@tonic-gate #define USAGE 2 116*7c478bd9Sstevel@tonic-gate #define BAD_TERMINAL 3 117*7c478bd9Sstevel@tonic-gate #define NOT_VALID 4 118*7c478bd9Sstevel@tonic-gate #define ERROR 5 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate static int S_flag = 0; 121*7c478bd9Sstevel@tonic-gate static char *term_name; 122*7c478bd9Sstevel@tonic-gate static char dumb_term[] = "dumb"; 123*7c478bd9Sstevel@tonic-gate static char usage_msg[] = m_textstr(4931, "\ 124*7c478bd9Sstevel@tonic-gate Usage: tput [-W] [-Tterm] capname [parm1..parm9]\n\ 125*7c478bd9Sstevel@tonic-gate tput [-W] [-Tterm] -S\n", "U"); 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate STATREF void build_argv ANSI((int *ac, char ***av)); 128*7c478bd9Sstevel@tonic-gate STATREF int do_tput ANSI((int _argc, char **_argv)); 129*7c478bd9Sstevel@tonic-gate STATREF void init ANSI((void)); 130*7c478bd9Sstevel@tonic-gate STATREF void reset ANSI((void)); 131*7c478bd9Sstevel@tonic-gate STATREF int usage ANSI((void)); 132*7c478bd9Sstevel@tonic-gate STATREF void err_msg ANSI((char *fmt, ...)); /* GENTEXT: err_msg */ 133*7c478bd9Sstevel@tonic-gate STATREF void cat ANSI((char *_Fn)); 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /*f 136*7c478bd9Sstevel@tonic-gate * mainline for tput 137*7c478bd9Sstevel@tonic-gate */ 138*7c478bd9Sstevel@tonic-gate int 139*7c478bd9Sstevel@tonic-gate main(argc, argv) 140*7c478bd9Sstevel@tonic-gate int argc; 141*7c478bd9Sstevel@tonic-gate char **argv; 142*7c478bd9Sstevel@tonic-gate { 143*7c478bd9Sstevel@tonic-gate int opt; 144*7c478bd9Sstevel@tonic-gate int err_code; 145*7c478bd9Sstevel@tonic-gate setlocale(LC_ALL, ""); 146*7c478bd9Sstevel@tonic-gate _cmdname = m_cmdname(*argv); 147*7c478bd9Sstevel@tonic-gate if ((term_name = getenv("TERM")) == NULL) { 148*7c478bd9Sstevel@tonic-gate term_name = dumb_term; 149*7c478bd9Sstevel@tonic-gate } else { 150*7c478bd9Sstevel@tonic-gate term_name = m_strdup(term_name); 151*7c478bd9Sstevel@tonic-gate } 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate /* Default uses the terminfo database without modification. */ 154*7c478bd9Sstevel@tonic-gate use_env(0); 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate while ((opt = getopt(argc, argv, "ST:W")) != -1) { 157*7c478bd9Sstevel@tonic-gate switch (opt) { 158*7c478bd9Sstevel@tonic-gate case 'W': 159*7c478bd9Sstevel@tonic-gate /* Environment/window size are consulted and may 160*7c478bd9Sstevel@tonic-gate * alter the database entries for lines and columns. 161*7c478bd9Sstevel@tonic-gate */ 162*7c478bd9Sstevel@tonic-gate use_env(1); 163*7c478bd9Sstevel@tonic-gate break; 164*7c478bd9Sstevel@tonic-gate case 'S': 165*7c478bd9Sstevel@tonic-gate S_flag = 1; 166*7c478bd9Sstevel@tonic-gate break; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate case 'T': 169*7c478bd9Sstevel@tonic-gate term_name = optarg; 170*7c478bd9Sstevel@tonic-gate break; 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate default: 173*7c478bd9Sstevel@tonic-gate return (usage()); 174*7c478bd9Sstevel@tonic-gate } 175*7c478bd9Sstevel@tonic-gate } 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate argc -= optind; 178*7c478bd9Sstevel@tonic-gate argv += optind; 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate if ((S_flag ^ (argc <= 0)) == 1) 181*7c478bd9Sstevel@tonic-gate return (usage()); 182*7c478bd9Sstevel@tonic-gate (void) setupterm(term_name, fileno(stdout), &err_code); 183*7c478bd9Sstevel@tonic-gate switch (err_code) { 184*7c478bd9Sstevel@tonic-gate case 1: 185*7c478bd9Sstevel@tonic-gate break; 186*7c478bd9Sstevel@tonic-gate case 0: 187*7c478bd9Sstevel@tonic-gate err_msg(m_textstr(202, "Unknown terminal \"%s\".\n", "E term"), term_name); 188*7c478bd9Sstevel@tonic-gate return (BAD_TERMINAL); 189*7c478bd9Sstevel@tonic-gate case -1: 190*7c478bd9Sstevel@tonic-gate err_msg(m_textstr(203, "No terminfo database.\n", "E")); 191*7c478bd9Sstevel@tonic-gate return (BAD_TERMINAL); 192*7c478bd9Sstevel@tonic-gate } 193*7c478bd9Sstevel@tonic-gate do { 194*7c478bd9Sstevel@tonic-gate if (S_flag) { 195*7c478bd9Sstevel@tonic-gate build_argv(&argc, &argv); 196*7c478bd9Sstevel@tonic-gate if (argc <= 0) 197*7c478bd9Sstevel@tonic-gate break; 198*7c478bd9Sstevel@tonic-gate } 199*7c478bd9Sstevel@tonic-gate err_code = do_tput(argc, argv); 200*7c478bd9Sstevel@tonic-gate } while (S_flag && err_code == SUCCESS); 201*7c478bd9Sstevel@tonic-gate return (err_code); 202*7c478bd9Sstevel@tonic-gate } 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate /*f 205*7c478bd9Sstevel@tonic-gate * Get an input line from stdin and then break it up into an argv array. 206*7c478bd9Sstevel@tonic-gate * If EOF is reached then S_flag is set to 0. Only the first 10 strings 207*7c478bd9Sstevel@tonic-gate * are of any interest. Any extra are ignored. 208*7c478bd9Sstevel@tonic-gate */ 209*7c478bd9Sstevel@tonic-gate STATIC void 210*7c478bd9Sstevel@tonic-gate build_argv(ac, av) 211*7c478bd9Sstevel@tonic-gate int *ac; 212*7c478bd9Sstevel@tonic-gate char ***av; 213*7c478bd9Sstevel@tonic-gate { 214*7c478bd9Sstevel@tonic-gate int i = 0; 215*7c478bd9Sstevel@tonic-gate char *p; 216*7c478bd9Sstevel@tonic-gate static char *v[10+1]; 217*7c478bd9Sstevel@tonic-gate static char buf[LINE_MAX]; 218*7c478bd9Sstevel@tonic-gate if ((*v = fgets(buf, LINE_MAX, stdin)) == NULL) { 219*7c478bd9Sstevel@tonic-gate /* End of file or input error */ 220*7c478bd9Sstevel@tonic-gate S_flag = 0; 221*7c478bd9Sstevel@tonic-gate } else { 222*7c478bd9Sstevel@tonic-gate if ((p = strchr(buf, '\n')) != NULL) 223*7c478bd9Sstevel@tonic-gate *p = '\0'; 224*7c478bd9Sstevel@tonic-gate for (p = buf; i < 10;) { 225*7c478bd9Sstevel@tonic-gate while (isspace(*(unsigned char*) p)) 226*7c478bd9Sstevel@tonic-gate ++p; 227*7c478bd9Sstevel@tonic-gate if (*p == '\0') 228*7c478bd9Sstevel@tonic-gate break; 229*7c478bd9Sstevel@tonic-gate v[i++] = p; 230*7c478bd9Sstevel@tonic-gate while (!isspace(*(unsigned char*) p) && *p != '\0') 231*7c478bd9Sstevel@tonic-gate ++p; 232*7c478bd9Sstevel@tonic-gate if (*p == '\0') 233*7c478bd9Sstevel@tonic-gate break; 234*7c478bd9Sstevel@tonic-gate *p++ = '\0'; 235*7c478bd9Sstevel@tonic-gate } 236*7c478bd9Sstevel@tonic-gate } 237*7c478bd9Sstevel@tonic-gate v[i] = NULL; 238*7c478bd9Sstevel@tonic-gate *ac = i; 239*7c478bd9Sstevel@tonic-gate *av = v; 240*7c478bd9Sstevel@tonic-gate } 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate /*f 243*7c478bd9Sstevel@tonic-gate * 244*7c478bd9Sstevel@tonic-gate */ 245*7c478bd9Sstevel@tonic-gate STATIC int 246*7c478bd9Sstevel@tonic-gate do_tput(_argc, _argv) 247*7c478bd9Sstevel@tonic-gate int _argc; 248*7c478bd9Sstevel@tonic-gate char **_argv; 249*7c478bd9Sstevel@tonic-gate { 250*7c478bd9Sstevel@tonic-gate int i; 251*7c478bd9Sstevel@tonic-gate long q[9]; 252*7c478bd9Sstevel@tonic-gate const char *p; 253*7c478bd9Sstevel@tonic-gate char *end_num; 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate if (strcmp(*_argv, "init") == 0) 256*7c478bd9Sstevel@tonic-gate init(); 257*7c478bd9Sstevel@tonic-gate else if (strcmp(*_argv, "reset") == 0) 258*7c478bd9Sstevel@tonic-gate reset(); 259*7c478bd9Sstevel@tonic-gate else if (strcmp(*_argv, "longname") == 0) 260*7c478bd9Sstevel@tonic-gate (void) printf("%s\n", longname()); 261*7c478bd9Sstevel@tonic-gate else if ((i = tigetflag(*_argv)) != -1) 262*7c478bd9Sstevel@tonic-gate return (!i); 263*7c478bd9Sstevel@tonic-gate else if ((i = tigetnum(*_argv)) != -2) 264*7c478bd9Sstevel@tonic-gate (void) printf("%d\n", i); 265*7c478bd9Sstevel@tonic-gate else if ((p = tigetstr(*_argv)) != (char*) -1) { 266*7c478bd9Sstevel@tonic-gate if (p == NULL) 267*7c478bd9Sstevel@tonic-gate return (NOT_DEFINED); 268*7c478bd9Sstevel@tonic-gate for (i = 0; i < 9; ++i) { 269*7c478bd9Sstevel@tonic-gate if (1 < _argc) { 270*7c478bd9Sstevel@tonic-gate --_argc; 271*7c478bd9Sstevel@tonic-gate q[i] = strtol(*++_argv, &end_num, 0); 272*7c478bd9Sstevel@tonic-gate if (*end_num != '\0') { 273*7c478bd9Sstevel@tonic-gate /* The parameter must be a string 274*7c478bd9Sstevel@tonic-gate * so we save the pointer instead. 275*7c478bd9Sstevel@tonic-gate */ 276*7c478bd9Sstevel@tonic-gate q[i] = (long) *_argv; 277*7c478bd9Sstevel@tonic-gate } 278*7c478bd9Sstevel@tonic-gate } else { 279*7c478bd9Sstevel@tonic-gate q[i] = 0L; 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate (void) putp(tparm(p, q[0], q[1], q[2], q[3], 283*7c478bd9Sstevel@tonic-gate q[4], q[5], q[6], q[7], q[8] 284*7c478bd9Sstevel@tonic-gate )); 285*7c478bd9Sstevel@tonic-gate fflush(stdout); 286*7c478bd9Sstevel@tonic-gate } else { 287*7c478bd9Sstevel@tonic-gate err_msg(m_textstr(1864, "Unknown terminfo capability \"%s\".\n", "E action"), *_argv); 288*7c478bd9Sstevel@tonic-gate return (NOT_VALID); 289*7c478bd9Sstevel@tonic-gate } 290*7c478bd9Sstevel@tonic-gate return (SUCCESS); 291*7c478bd9Sstevel@tonic-gate } 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate /*f 294*7c478bd9Sstevel@tonic-gate * 295*7c478bd9Sstevel@tonic-gate */ 296*7c478bd9Sstevel@tonic-gate STATIC void 297*7c478bd9Sstevel@tonic-gate init() 298*7c478bd9Sstevel@tonic-gate { 299*7c478bd9Sstevel@tonic-gate if (init_prog != NULL) 300*7c478bd9Sstevel@tonic-gate (void) system(init_prog); 301*7c478bd9Sstevel@tonic-gate if (init_1string != NULL) 302*7c478bd9Sstevel@tonic-gate putp(init_1string); 303*7c478bd9Sstevel@tonic-gate if (init_2string != NULL) 304*7c478bd9Sstevel@tonic-gate putp(init_2string); 305*7c478bd9Sstevel@tonic-gate #if 0 /* currently not supported by our terminfo database */ 306*7c478bd9Sstevel@tonic-gate if (clear_margins != NULL) 307*7c478bd9Sstevel@tonic-gate putp(clear_margins); 308*7c478bd9Sstevel@tonic-gate if (set_left_margin != NULL) 309*7c478bd9Sstevel@tonic-gate putp(set_left_margin); 310*7c478bd9Sstevel@tonic-gate if (set_right_margin != NULL) 311*7c478bd9Sstevel@tonic-gate putp(set_right_margin); 312*7c478bd9Sstevel@tonic-gate #endif 313*7c478bd9Sstevel@tonic-gate /* TODO: setting of tabs using clear_all_tabs & set_tab. */ 314*7c478bd9Sstevel@tonic-gate if (init_file != NULL) 315*7c478bd9Sstevel@tonic-gate cat(init_file); 316*7c478bd9Sstevel@tonic-gate if (init_3string != NULL) 317*7c478bd9Sstevel@tonic-gate putp(init_3string); 318*7c478bd9Sstevel@tonic-gate } 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate /*f 321*7c478bd9Sstevel@tonic-gate * 322*7c478bd9Sstevel@tonic-gate */ 323*7c478bd9Sstevel@tonic-gate STATIC void 324*7c478bd9Sstevel@tonic-gate reset() 325*7c478bd9Sstevel@tonic-gate { 326*7c478bd9Sstevel@tonic-gate if (reset_1string != NULL) 327*7c478bd9Sstevel@tonic-gate putp(reset_1string); 328*7c478bd9Sstevel@tonic-gate if (reset_2string != NULL) 329*7c478bd9Sstevel@tonic-gate putp(reset_2string); 330*7c478bd9Sstevel@tonic-gate if (reset_file != NULL) 331*7c478bd9Sstevel@tonic-gate cat(reset_file); 332*7c478bd9Sstevel@tonic-gate if (reset_3string != NULL) 333*7c478bd9Sstevel@tonic-gate putp(reset_3string); 334*7c478bd9Sstevel@tonic-gate } 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate /*f 337*7c478bd9Sstevel@tonic-gate * usage message for tput 338*7c478bd9Sstevel@tonic-gate */ 339*7c478bd9Sstevel@tonic-gate STATIC int 340*7c478bd9Sstevel@tonic-gate usage() 341*7c478bd9Sstevel@tonic-gate { 342*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, m_strmsg(usage_msg)); 343*7c478bd9Sstevel@tonic-gate return (USAGE); 344*7c478bd9Sstevel@tonic-gate } 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate /*f 347*7c478bd9Sstevel@tonic-gate * display error message 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate STATIC void 350*7c478bd9Sstevel@tonic-gate err_msg VARARG1(char*, fmt) 351*7c478bd9Sstevel@tonic-gate { 352*7c478bd9Sstevel@tonic-gate va_list ap; 353*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: ", _cmdname); 354*7c478bd9Sstevel@tonic-gate va_start(ap, fmt); 355*7c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, m_strmsg(fmt), ap); 356*7c478bd9Sstevel@tonic-gate va_end(ap); 357*7c478bd9Sstevel@tonic-gate } 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /* 360*7c478bd9Sstevel@tonic-gate * Print a file via putp(). 361*7c478bd9Sstevel@tonic-gate */ 362*7c478bd9Sstevel@tonic-gate STATIC void 363*7c478bd9Sstevel@tonic-gate cat(fn) 364*7c478bd9Sstevel@tonic-gate char *fn; 365*7c478bd9Sstevel@tonic-gate { 366*7c478bd9Sstevel@tonic-gate FILE *fp; 367*7c478bd9Sstevel@tonic-gate char buf[LINE_MAX+1]; 368*7c478bd9Sstevel@tonic-gate if ((fp = fopen(fn, "rb")) == NULL) 369*7c478bd9Sstevel@tonic-gate return; 370*7c478bd9Sstevel@tonic-gate while (fgets(buf, LINE_MAX, fp) != NULL) 371*7c478bd9Sstevel@tonic-gate putp(buf); 372*7c478bd9Sstevel@tonic-gate (void) fclose(fp); 373*7c478bd9Sstevel@tonic-gate } 374