/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
/*LINTLIBRARY*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "curses_inc.h"
#ifdef _VR2_COMPAT_CODE
extern char _endwin;
#endif /* _VR2_COMPAT_CODE */
/* 1200 is put at the 0th location since 0 is probably a mistake. */
static long baud_convert[] = {
1200, 50, 75, 110, 135, 150, 200, 300, 600, 1200,
1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,
115200, 153600, 230400, 307200, 460800, 921600
};
static char isfilter = 0;
static int _chk_trm(void);
static void _forget(void);
/*
* newscreen sets up a terminal and returns a pointer to the terminal
* structure or NULL in case of an error. The parameters are:
* type: terminal type
* lsize, csize, tabsize: physical sizes
* infptr, outfptr: input and output stdio stream file pointers
*/
SCREEN *
{
#ifndef _IOFBF
char *sobuf;
#endif /* _IOBUF */
#ifdef DEBUG
perror("trace");
exit(-1);
}
}
if (outf)
getenv("TERM"));
#endif /* DEBUG */
/* read in terminfo file */
goto err2;
/* the max length of a multi-byte character */
goto err2;
/* the max length of a multi-column character */
/* true multi-byte/multi-column case */
goto err2;
}
/* use calloc because almost everything needs to be zero */
goto err1;
/*
* The default is echo, for upward compatibility, but we do
* all echoing in curses to avoid problems with the tty driver
* echoing things during critical sections.
*/
/* set some fields for cur_term structure */
/*
* We use LINES instead of the SP variable and a local variable because
* slk_init and rip_init update the LINES value and application code
* may look at the value of LINES in the function called by rip_init.
*/
/* LINTED */
/* force the output to be buffered */
#ifdef _IOFBF
#else /* _IOFBF */
#ifdef DEBUG
#endif /* DEBUG */
}
#endif /* _IOFBF */
#ifdef SYSV
#else /* SYSV */
#endif /* SYSV */
/* figure out how much each terminal capability costs */
_init_costs();
/* initialize the array of alternate characters */
(void) init_acs();
/* set tty settings to something reasonable for us */
#ifdef SYSV
#else /* SYSV */
#endif /* SYSV */
(void) cbreak();
/* LINTED */
if (tabsize == 0)
/* LINTED */
#ifdef DEBUG
if (outf)
#endif /* DEBUG */
goto err;
#ifdef _VR2_COMPAT_CODE
#endif /* _VR2_COMPAT_CODE */
/*
* This will tell _quick_echo(if it's ever called), whether
* _quick_echo should let wrefresh handle everything.
*/
if (ceol_standout_glitch || (magic_cookie_glitch >= 0) ||
}
goto err;
/* video mark map for cookie terminals */
if (ceol_standout_glitch || (magic_cookie_glitch >= 0)) {
int i, nc;
char **marks;
sizeof (char *))) == NULL)
goto err;
sizeof (char))) == NULL)
goto err;
}
/* hash tables for lines */
sizeof (int))) == NULL)
goto err;
if (_slk_init)
(*_slk_init)();
if (_rip_init)
(*_rip_init)();
/* free all the storage allocated above and return NULL */
err:
curscr = old_curscr;
err1:
#ifdef DEBUG
#endif /* DEBUG */
err2:
return (NULL);
}
#ifdef DEBUG
if (outf)
#endif /* DEBUG */
}
return (SP);
}
/*
* check if terminal have capabilities to do basic cursor movements and
* screen clearing
*/
static int
_chk_trm(void)
{
#ifdef DEBUG
if (outf)
#endif /* DEBUG */
if (generic_type)
else {
if (isfilter) {
_forget();
/* Only need to move left or right on current line */
if (!(cursor_left || carriage_return ||
column_address || parm_left_cursor)) {
goto out_stupid;
}
} else {
if ((hard_copy || over_strike) ||
/* some way to move up, down, left */
(!(cursor_address) &&
(cursor_left || carriage_return)))) ||
(!clear_screen)) {
}
}
}
return (error_num);
}
int
filter(void)
{
isfilter = 1;
return (OK);
}
/*
* if (for some reason) user assumes that terminal has only one line,
* disable all capabilities that deal with non-horizontal cursor movement
*/
static void
_forget(void)
{
lines = 1;
}