/*
* 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) 1995, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* XCurses Library
*
* Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
*
*/
#ifdef M_RCSID
#ifndef lint
static char const rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/setup.c 1.9 1995/10/02 20:22:57 ant Exp $";
#endif
#endif
#include <private.h>
#ifdef M_USE_IOCTL_H
#endif
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/*
* Any version number should be placed in this file, since setupterm()
* must be called in order to initialize Curses or Terminfo.
*/
/* True if __m_setupterm() should use either the window settings from
* ioctl(), or the environment variables LINES and COLUMNS to override
* the terminfo database entries for 'lines' and 'columns'.
*
* Call use_env(flag) before either setupterm(), newterm(), or initscr().
*/
/*
* Take the real command character out of the CC environment variable
* and substitute it in for the prototype given in 'command_character'.
*/
static void
{
int i, j;
for (i=0; i < __COUNT_STR; i++)
}
#define min(a, b) ((a) < (b) ? (a) : (b))
/*
* Return a number from a terminfo file. Numbers in a terminfo
* file are stored as two bytes with low-high ordering.
*/
static short
int fd;
{
return SHRT_MIN;
}
/*f
* Read the compiled terminfo entry in the given file into the
* structure pointed to by ptr, allocating space for the string
* table and placing its address in ptr->str_table.
*/
int
const char *filename;
{
int fd;
short offset;
/* Get compiled terminfo file header. */
goto error_1;
goto error_2;
/* Allocate and fetch terminal names. */
goto error_2;
goto error_3;
/* Fetch booleans. */
goto error_3;
(void) lseek(
);
} else {
}
/* Eat padding byte. */
/* Fetch numbers. */
for (i = 0; i < len; ++i)
(void) lseek(
);
} else {
}
/* Allocate and fetch strings. */
goto error_3;
/* Read in string offset section setting pointers to strings. */
for (i = 0; i < len; ++i) {
goto error_4;
if (offset < 0)
else
}
(void) lseek(
);
} else {
for (; i < __COUNT_STR; ++i)
}
goto error_4;
return 0;
return -1;
}
void
{
#ifdef M_CURSES_TRACE
#endif
__m_return_void("use_env");
}
/*f
* Set up terminal.
*
* Reads in the terminfo database pointed to by $TERMINFO env. var.
* for the given terminal, but does not set up the output virtualization
* structues used by CURSES. If the terminal name pointer is NULL,
* the $TERM env. var. is used for the terminal. All output is to
* the given file descriptor which is initialized for output.
*
* On error, if errret != NULL then setupterm() returns OK
* or ERR and stores a status value in the integer pointed to by
* errret. A status of 1 is normal, 0 means the terminal could
* not be found, and -1 means the terminfo database could not be
* found. If errret == NULL then setupterm() prints an error
* message upon and exit().
*
* On success, cur_term set to a terminfo structure and OK returned.
*/
int
const char *termname;
int *err_return;
{
char const *err_msg;
/* It is possible to call setupterm() for multiple terminals,
* in which case we have to be able to restore cur_term in
* case of error.
*/
err_code = -1;
goto error;
}
(void) def_shell_mode();
(void) def_prog_mode();
#ifdef ONLCR
#else
#endif
switch (err_code) {
case -1:
break;
case 0:
break;
case 1:
break;
case 2:
err_code = -1;
break;
}
if (err_return != (int *) 0) {
#ifdef M_CURSES_TRACE
"__m_setupterm error code passed back in %p = %d.",
);
#endif
*err_return = err_code;
if (err_code == 1) {
} else {
}
} else if (err_code != 1) {
#ifdef M_CURSES_TRACE
__m_trace("__m_setupterm() failed with:");
#endif
exit(1);
}
}
int
const char *term;
{
int code;
#ifdef M_CURSES_TRACE
#endif
}
int
{
#ifdef M_CURSES_TRACE
#endif
if (tp->_str_table != (char *) 0)
}
}
TERMINAL *
{
#ifdef M_CURSES_TRACE
#endif
}
int
const char *tm;
int fd, *err_return;
{
#ifdef M_CURSES_TRACE
#endif
err_code = 1;
filename = (char *) 0;
} else {
if (terminfo == (char *) 0) {
/* Not really true... */
err_code = 2;
goto error;
}
}
tm = def_termname;
/* Remember the terminal name being loaded. */
/* Length of path we're going to construct. */
err_code = 2;
goto error;
}
/* Construct terminfo filename. */
/* Go looking for compiled terminal definition. */
/* Length of default terminfo path. */
err_code = 2;
goto error;
}
err_code = 0;
goto error;
}
}
if (use_environment) {
char *env;
#ifdef TIOCGWINSZ
/*l
* Use ioctl(TIOCGWINSZ) to get row and column values. These
* values may override the default terminfo settings.
*/
{
}
}
#endif /* TIOCGWINSZ */
/* Check to see is the user wants a particular size terminal. */
if (0 < nlines)
}
if (0 < ncolumns)
}
}
do_prototype();
/* If no_color_video is disabled, then assign it a value that
* permits all attributes in combination with colour.
*/
if (no_color_video == -1)
no_color_video = 0;
if (filename != (char *) 0)
if (terminfo != def_terminfo)
if (err_return != NULL) {
#ifdef M_CURSES_TRACE
"restartterm() error code passed back in %p = %d.",
);
#endif
*err_return = err_code;
if (err_code == 1) {
} else {
}
} else if (err_code != 1) {
#ifdef M_CURSES_TRACE
__m_trace("restartterm() failed with:");
#endif
exit(1);
}
if (old_names != (char *) 0)
if (old_strings != (char *) 0)
if (old_term != (char *) 0)
}
}
/*
* Get the termios setting for the terminal. Check the input
* file descriptor first, else the output file descriptor. If
* both input and output are both terminals, it is assumed that
* they refer to the same terminal.
*/
int
{
/* Input was not a terminal, possibly redirected.
* Check output instead.
*/
return ERR;
}
return OK;
}
/*
* Restore the termios settings.
*/
int
{
int fd;
else
return OK;
#ifdef NOT_NOW
#else
/* VSU testing bug does not read the master side properly so in order
* to drain the buffer. Must use TCSANOW.
*/
#endif
}
int
{
#ifdef M_CURSES_TRACE
__m_trace("def_shell_mode(void)");
#endif
return __m_return_code(
);
}
int
{
#ifdef M_CURSES_TRACE
__m_trace("def_prog_mode(void)");
#endif
}
int
{
#ifdef M_CURSES_TRACE
__m_trace("reset_shell_mode(void)");
#endif
return __m_return_code(
);
}
int
{
#ifdef M_CURSES_TRACE
__m_trace("reset_prog_mode(void)");
#endif
return __m_return_code(
);
}