#ifdef M_RCSID
#ifndef lint
static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/initscr.c 1.5 1995/09/28 16:47:03 ant Exp $";
#endif
#endif
#include <private.h>
#include <errno.h>
#include <stdlib.h>
static char nomem_msg[] = m_textstr(
3139, "Failed to allocate required memory.\n", "E"
);
static char noterm_msg[] = m_textstr(
202, "Unknown terminal \"%s\".\n", "E term"
);
static char dumb_msg[] = m_textstr(
3140, "Terminal \"%s\" has insufficent capabilities for Curses.\n",
"E term"
);
WINDOW *
initscr()
{
WINDOW *w;
SCREEN *sp;
int i, n, begy;
char *term, *err;
#ifdef M_CURSES_TRACE
__m_trace("initscr(void)");
#endif
errno = 0;
sp = newterm((char *) 0, stdout, stdin);
if (sp == (SCREEN *) 0) {
err = errno == ENOMEM ? nomem_msg : noterm_msg;
goto error_1;
}
(void) set_term(sp);
if (1 < lines
&& cursor_address == (char *) 0
&& row_address == (char *) 0
&& (cursor_up == (char *) 0 || cursor_down == (char *) 0)
&& (parm_up_cursor == (char *) 0 || parm_down_cursor == (char *) 0)) {
err = dumb_msg;
goto error_3;
}
if ((1 < lines && cursor_address == (char *) 0)
&& column_address == (char *) 0
&& (cursor_left == (char *) 0 || cursor_right == (char *) 0)
&& (parm_left_cursor == (char *) 0 || parm_right_cursor == (char *)0)) {
err = dumb_msg;
goto error_3;
}
if (clr_eol == (char *) 0) {
err = dumb_msg;
goto error_3;
}
return __m_return_pointer("initscr", stdscr);
error_3:
(void) delwin(stdscr);
(void) endwin();
(void) delscreen(sp);
error_1:
if ((term = getenv("TERM")) == (char *) 0)
term = M_TERM_NAME;
(void) fprintf(stderr, m_strmsg(err), term);
exit(1);
return (0);
}