termcap.ed revision 2
2N/AH
2N/A!rm -f termcap.c
2N/A0a
2N/A/*
2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/*
2N/A * University Copyright- Copyright (c) 1982, 1986, 1988
2N/A * The Regents of the University of California
2N/A * All Rights Reserved
2N/A *
2N/A * University Acknowledgment- Portions of this document are derived from
2N/A * software developed by the University of California, Berkeley, and its
2N/A * contributors.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * Simulation of termcap using terminfo.
2N/A * This file is created from termcap.ed. DO NOT EDIT ME!
2N/A */
2N/A
2N/A/*
2N/A * These are declared so people won't get undefineds if they use
2N/A * old documentation. We don't do anything with them.
2N/A */
2N/A
2N/A#include <sys/types.h>
2N/A#include <string.h>
2N/A#include "curses_inc.h"
2N/A
2N/Achar *UP;
2N/Achar *BC;
2N/Achar PC;
2N/Ashort ospeed;
2N/A
2N/A/* ARGSUSED */
2N/Aint
2N/Atgetent(char *bp, char *name)
2N/A{
2N/A int rv;
2N/A
2N/A if (setupterm(name, 1, &rv) >= 0)
2N/A /* Leave things as they were (for compatibility) */
2N/A (void) reset_shell_mode();
2N/A return (rv);
2N/A}
2N/A
2N/A/* Make a 2 letter code into an integer we can switch on easily */
2N/A#define _TWO(s1, s2) (s1 + 256*s2)
2N/A#define _TWOSTR(str) _TWO(*str, str[1])
2N/A
2N/Astatic char *
2N/A_stripdelays(char *inbuf, char *outbuf, int size)
2N/A{
2N/A char *saveoutbuf = outbuf;
2N/A
2N/A if (inbuf == NULL)
2N/A return (0);
2N/A else
2N/A while (size && *inbuf)
2N/A if (*inbuf == '$' && *(inbuf+1) == '<')
2N/A /* LINTED */
2N/A while (*inbuf && *inbuf++ != '>');
2N/A else {
2N/A size--;
2N/A *outbuf++ = *inbuf++;
2N/A *outbuf = 0;
2N/A }
2N/A return (saveoutbuf);
2N/A}
2N/A
2N/A/* generated by sort on caps */
2N/Astatic short booloffsets[] =
2N/A { /* generated by sort on caps */
2N/A.
2N/A!sed -e '1,/^--- begin bool/d' -e '/^--- end bool/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
2N/A.r !cat ./tmp/termcap.tmp
2N/A.a
2N/A };
2N/A
2N/A/* generated by sort on caps */
2N/Astatic short numoffsets[] =
2N/A {
2N/A.
2N/A!sed -e '1,/^--- begin num/d' -e '/^--- end num/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
2N/A.r !cat ./tmp/termcap.tmp
2N/A.a
2N/A };
2N/A
2N/A/* generated by sort on caps */
2N/Astatic short stroffsets[] =
2N/A {
2N/A.
2N/A!sed -e '1,/^--- begin str/d' -e '/^--- end str/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
2N/A.r !cat ./tmp/termcap.tmp
2N/A!rm ./tmp/termcap.tmp
2N/A.a
2N/A };
2N/A
2N/A/*
2N/A * Return the value of the boolean capability tcstr.
2N/A * Return 0 if the capability is not found.
2N/A */
2N/A
2N/Aint
2N/Atgetflag(char *tcstr)
2N/A{
2N/A char *p;
2N/A char stripped[16];
2N/A
2N/A switch (_TWOSTR(tcstr)) {
2N/A /* Special cases that do not have exact terminfo equivalents */
2N/A case _TWO('b','s'):
2N/A /* bs: true if ^H moves the cursor left */
2N/A p = _stripdelays(cursor_left, stripped, 16);
2N/A return (p && *p == 8 && p[1] == 0);
2N/A case _TWO('p','t'):
2N/A /* pt: true if terminal has ^I tabs every 8 spaces */
2N/A p = _stripdelays(tab, stripped, 16);
2N/A return (p && *p == 9 && p[1] == 0);
2N/A case _TWO('n','c'):
2N/A /* cr: true if ^M does not return the cursor */
2N/A p = _stripdelays(carriage_return, stripped, 16);
2N/A return (! (p && *p == 13 && p[1] == 0));
2N/A case _TWO('n','s'):
2N/A /* ns: true if no way to scroll the terminal */
2N/A return (scroll_forward == NULL);
2N/A }
2N/A {
2N/A int n = _NUMELEMENTS(booloffsets);
2N/A int offset = _tcsearch(tcstr, booloffsets, boolcodes, n, 2);
2N/A char *bool_array = (char *) cur_bools;
2N/A
2N/A if (offset == -1)
2N/A return (0);
2N/A else
2N/A return (bool_array[offset]);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * Return the value of the numeric capability tcstr.
2N/A * Return -1 if the capability is not found.
2N/A */
2N/A
2N/Aint
2N/Atgetnum(char *tcstr)
2N/A{
2N/A int n = _NUMELEMENTS(numoffsets);
2N/A int offset = _tcsearch(tcstr, numoffsets, numcodes, n, 2);
2N/A short *num_array = (short *) cur_nums;
2N/A
2N/A if (offset == -1)
2N/A return (-1);
2N/A else
2N/A return (num_array[offset]);
2N/A}
2N/A
2N/A/*
2N/A * Return the string capability for capability "id". We also copy
2N/A * it into *area for upward compatibility with a few programs that
2N/A * actually expect it to be copied, at a slight cost in speed.
2N/A */
2N/A
2N/Achar *
2N/Atgetstr(char *tcstr, char **area)
2N/A{
2N/A int n = _NUMELEMENTS(stroffsets);
2N/A int offset = _tcsearch(tcstr, stroffsets, strcodes, n, 2);
2N/A char **str_array = (char **) cur_strs;
2N/A char *rv;
2N/A
2N/A if (offset == -1)
2N/A return (0);
2N/A rv = str_array[offset];
2N/A if (area && *area && rv) {
2N/A (void) strcpy(*area, rv);
2N/A *area += strlen(rv) + 1;
2N/A }
2N/A return (rv);
2N/A}
2N/A.
2N/Aw termcap.c
2N/Aq