/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1996, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* tput.c
*
* Copyright 1990, 1994 by Mortice Kern Systems Inc. All rights reserved.
*
* PORTABILITY:
* SVID 3 - fully
* POSIX.2a UPE - needs clarification between SVID 3 exit statues.
* In particular exit 1 and 4 for string capnames.
* not in XPG 3
*
* SYNOPSIS:
* tput [-T<term>] capname [parm1..parm9]
* tput [-T<term>] -S
*
* DESCRIPTION:
* tput lets you change your terminal's characteristics. The capname
* argument indicates how you want to change the characteristics.
* Some special capnames are:
*
* clear clear the screen
* init initialize terminal in an implemenation-defined way
* reset reset terminal in an implemenation-defined way
* longname print the full name of the ternminal (SVID)
*
* Other capnames are supported and may take from 0 to 9 parameters. A
* list of them can be found in the SVID 3, vol 3. (SVID)
*
* tput does its work by outputting approriate character sequences to the
* standard output. These character sequences are terminal-specific. If
* you specify -T <type>, tput assumes that your terminal has the
* specified type and will issue sequences appropriate to that terminal.
*
* If you do not specify -T, tput looks for an environment variable
* named TERM. If TERM exists, its value is assumed to give the terminal
* type. If TERM does not exist, tput assumes a default terminal type.
*
* The -S option allows more than one capability per invocation of tput.
* The capabilities must be passed to tput from the standard input instead
* of the comamnd line. Only one capname is allowed per line.
*
* EXIT STATUS
* tput may return the following status values:
*
* 0 Either a boolean capname is set true or a string capname was
* successfully written to the terminal.
*
* 1 No error message is printed. Returned if a boolean capname is
* false or a string capname is not defined for the terminal.(SVID)
*
* 2 Usage error.
*
* 3 Unknown terminal <term> or no terminfo database.
*
* 4 Unknown terminfo capability <capname>.
*
* >4 An error occured.
*
*
* NOTE 1: If the Caps file that describes the terminfo database changes
*
* NOTE 2: tput has knowledge about the TERMINAL structure.
*/
#ifdef M_RCSID
#ifndef lint
#endif
#endif
#include <mks.h>
#include <curses.h>
#include <term.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern char *_cmdname;
/* Exit Status */
#define SUCCESS 0
static int S_flag = 0;
static char *term_name;
Usage: tput [-W] [-Tterm] capname [parm1..parm9]\n\
tput [-W] [-Tterm] -S\n", "U");
/*f
* mainline for tput
*/
int
int argc;
char **argv;
{
int opt;
int err_code;
} else {
}
/* Default uses the terminfo database without modification. */
use_env(0);
switch (opt) {
case 'W':
/* Environment/window size are consulted and may
* alter the database entries for lines and columns.
*/
use_env(1);
break;
case 'S':
S_flag = 1;
break;
case 'T':
break;
default:
return (usage());
}
}
return (usage());
switch (err_code) {
case 1:
break;
case 0:
return (BAD_TERMINAL);
case -1:
return (BAD_TERMINAL);
}
do {
if (S_flag) {
if (argc <= 0)
break;
}
return (err_code);
}
/*f
* Get an input line from stdin and then break it up into an argv array.
* If EOF is reached then S_flag is set to 0. Only the first 10 strings
* are of any interest. Any extra are ignored.
*/
STATIC void
int *ac;
char ***av;
{
int i = 0;
char *p;
static char *v[10+1];
/* End of file or input error */
S_flag = 0;
} else {
*p = '\0';
for (p = buf; i < 10;) {
while (isspace(*(unsigned char*) p))
++p;
if (*p == '\0')
break;
v[i++] = p;
while (!isspace(*(unsigned char*) p) && *p != '\0')
++p;
if (*p == '\0')
break;
*p++ = '\0';
}
}
v[i] = NULL;
*ac = i;
*av = v;
}
/*f
*
*/
STATIC int
int _argc;
char **_argv;
{
int i;
long q[9];
const char *p;
char *end_num;
init();
reset();
return (!i);
(void) printf("%d\n", i);
if (p == NULL)
return (NOT_DEFINED);
for (i = 0; i < 9; ++i) {
if (1 < _argc) {
--_argc;
if (*end_num != '\0') {
/* The parameter must be a string
* so we save the pointer instead.
*/
q[i] = (long) *_argv;
}
} else {
q[i] = 0L;
}
}
q[4], q[5], q[6], q[7], q[8]
));
} else {
return (NOT_VALID);
}
return (SUCCESS);
}
/*f
*
*/
STATIC void
init()
{
if (init_1string != NULL)
if (init_2string != NULL)
#if 0 /* currently not supported by our terminfo database */
if (clear_margins != NULL)
if (set_left_margin != NULL)
if (set_right_margin != NULL)
#endif
/* TODO: setting of tabs using clear_all_tabs & set_tab. */
if (init_3string != NULL)
}
/*f
*
*/
STATIC void
reset()
{
if (reset_1string != NULL)
if (reset_2string != NULL)
if (reset_file != NULL)
if (reset_3string != NULL)
}
/*f
* usage message for tput
*/
STATIC int
usage()
{
return (USAGE);
}
/*f
* display error message
*/
STATIC void
{
}
/*
* Print a file via putp().
*/
STATIC void
char *fn;
{
return;
}