summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_initscr.c
blob: 1c2d9e37412388facc4bcd4a343e4a240f1ae619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for   *
*  details. If they are missing then this copy is in violation of    *
*  the copyright conditions.                                        */

/*
**	lib_initscr.c
**
**	The routine initscr().
**
*/

#include <stdlib.h>
#include "curses.priv.h"

WINDOW *initscr()
{
static	bool initialized = FALSE;
char *name;
#ifdef TRACE
	_init_trace();

	T(("initscr() called"));
#endif

	/* Portable applications must not call initscr() more than once */
	if (!initialized) {
		initialized = TRUE;

		if ((name = getenv("TERM")) == 0)
			name = "unknown";
		if (newterm(name, stdout, stdin) == 0) {
			fprintf(stderr, "Error opening terminal: %s.\n", name);
			exit(1);
		}
		/* def_shell_mode - done in newterm */
		def_prog_mode();
	}
	return(stdscr);
}
OpenPOWER on IntegriCloud