コード例 #1
0
ファイル: captoinfo.c プロジェクト: allanjude/illumos-gate
static void
use_file(char *filename)
{
	FILE *termfile;
	char buffer[BUFSIZ];

	if (verbose)
		(void) fprintf(trace, "reading from %s.\n", filename);

	if ((termfile = fopen(filename, "r")) == NULL) {
		(void) fprintf(stderr, "%s: cannot open %s for reading.\n",
		    progname, filename);
		return;
	}

	copycomments++;
	setfilename(filename);

	while (fgets(buffer, BUFSIZ, termfile) != NULL) {
		if ((term_name = getterm_name(buffer)) != NULL) {
			setterm_name();
			captoinfo();
		}
	}
}
コード例 #2
0
ファイル: captoinfo.c プロジェクト: allanjude/illumos-gate
static void
use_etc_termcap(void)
{
	if (verbose)
#ifdef  SIGSTOP
		(void) fprintf(trace, "reading from /usr/share/lib/termcap\n");
#else   /* SIGSTOP */
		(void) fprintf(trace, "reading from /etc/termcap\n");
#endif  /* SIGSTOP */
		term_name = getenv("TERM");
		captoinfo();
}
コード例 #3
0
ファイル: term.c プロジェクト: sabotage-linux/netbsd-curses
static int
_ti_findterm(TERMINAL *term, const char *name, int flags)
{
    int r;
    char *c, *e, h[PATH_MAX];
    TIC *tic;
    uint8_t *f;
    ssize_t len;

    _DIAGASSERT(term != NULL);
    _DIAGASSERT(name != NULL);

    database[0] = '\0';
    _ti_database = NULL;
    r = 0;

    if ((e = getenv("TERMINFO")) != NULL && *e != '\0')
        if (e[0] == '/')
            return _ti_dbgetterm(term, e, name, flags);

    c = NULL;
#ifdef USE_TERMCAP
    if (e == NULL && (c = getenv("TERMCAP")) != NULL) {
        if (*c != '\0' && *c != '/') {
            c = strdup(c);
            if (c != NULL) {
                e = captoinfo(c);
                free(c);
            }
        }
    }
#endif
    if (e != NULL) {
        if (c == NULL)
            e = strdup(e); /* So we don't destroy env */
        if (e == NULL)
            tic = NULL;
        else {
            tic = _ti_compile(e, TIC_WARNING |
                              TIC_ALIAS | TIC_DESCRIPTION | TIC_EXTRA);
            free(e);
        }
        if (tic != NULL && ticcmp(tic, name) == 0) {
            len = _ti_flatten(&f, tic);
            if (len != -1) {
                r = _ti_readterm(term, (char *)f, (size_t)len,
                                 flags);
                free(f);
            }
        }
        _ti_freetic(tic);
        if (r == 1) {
            if (c == NULL)
                _ti_database = "$TERMINFO";
            else
                _ti_database = "$TERMCAP";
            return r;
        }
    }

    if ((e = getenv("TERMINFO_DIRS")) != NULL)
        return _ti_dbgettermp(term, e, name, flags);

    if ((e = getenv("HOME")) != NULL) {
        snprintf(h, sizeof(h), "%s/.terminfo", e);
        r = _ti_dbgetterm(term, h, name, flags);
    }
    if (r != 1)
        r = _ti_dbgettermp(term, _PATH_TERMINFO, name, flags);

    return r;

}