17c478bd9Sstevel@tonic-gateH 27c478bd9Sstevel@tonic-gate!rm -f termcap.c 37c478bd9Sstevel@tonic-gate0a 47c478bd9Sstevel@tonic-gate/* 57c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 67c478bd9Sstevel@tonic-gate * Use is subject to license terms. 77c478bd9Sstevel@tonic-gate */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate/* 107c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 117c478bd9Sstevel@tonic-gate * The Regents of the University of California 127c478bd9Sstevel@tonic-gate * All Rights Reserved 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 157c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 167c478bd9Sstevel@tonic-gate * contributors. 177c478bd9Sstevel@tonic-gate */ 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate/* 207c478bd9Sstevel@tonic-gate * Simulation of termcap using terminfo. 217c478bd9Sstevel@tonic-gate * This file is created from termcap.ed. DO NOT EDIT ME! 227c478bd9Sstevel@tonic-gate */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate/* 257c478bd9Sstevel@tonic-gate * These are declared so people won't get undefineds if they use 267c478bd9Sstevel@tonic-gate * old documentation. We don't do anything with them. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate#include <sys/types.h> 307c478bd9Sstevel@tonic-gate#include <string.h> 317c478bd9Sstevel@tonic-gate#include "curses_inc.h" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gatechar *UP; 347c478bd9Sstevel@tonic-gatechar *BC; 357c478bd9Sstevel@tonic-gatechar PC; 367c478bd9Sstevel@tonic-gateshort ospeed; 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate/* ARGSUSED */ 397c478bd9Sstevel@tonic-gateint 407c478bd9Sstevel@tonic-gatetgetent(char *bp, char *name) 417c478bd9Sstevel@tonic-gate{ 427c478bd9Sstevel@tonic-gate int rv; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate if (setupterm(name, 1, &rv) >= 0) 457c478bd9Sstevel@tonic-gate /* Leave things as they were (for compatibility) */ 467c478bd9Sstevel@tonic-gate (void) reset_shell_mode(); 477c478bd9Sstevel@tonic-gate return (rv); 487c478bd9Sstevel@tonic-gate} 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate/* Make a 2 letter code into an integer we can switch on easily */ 517c478bd9Sstevel@tonic-gate#define _TWO(s1, s2) (s1 + 256*s2) 527c478bd9Sstevel@tonic-gate#define _TWOSTR(str) _TWO(*str, str[1]) 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gatestatic char * 557c478bd9Sstevel@tonic-gate_stripdelays(char *inbuf, char *outbuf, int size) 567c478bd9Sstevel@tonic-gate{ 577c478bd9Sstevel@tonic-gate char *saveoutbuf = outbuf; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate if (inbuf == NULL) 607c478bd9Sstevel@tonic-gate return (0); 61*e07d85f8SToomas Soome 62*e07d85f8SToomas Soome while (size && *inbuf) { 63*e07d85f8SToomas Soome if (*inbuf == '$' && *(inbuf+1) == '<') { 64*e07d85f8SToomas Soome /* LINTED */ 65*e07d85f8SToomas Soome while (*inbuf && *inbuf++ != '>'); 66*e07d85f8SToomas Soome } else { 67*e07d85f8SToomas Soome size--; 68*e07d85f8SToomas Soome *outbuf++ = *inbuf++; 69*e07d85f8SToomas Soome *outbuf = 0; 70*e07d85f8SToomas Soome } 71*e07d85f8SToomas Soome } 72*e07d85f8SToomas Soome return (saveoutbuf); 737c478bd9Sstevel@tonic-gate} 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate/* generated by sort on caps */ 767c478bd9Sstevel@tonic-gatestatic short booloffsets[] = 777c478bd9Sstevel@tonic-gate { /* generated by sort on caps */ 787c478bd9Sstevel@tonic-gate. 797c478bd9Sstevel@tonic-gate!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 807c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp 817c478bd9Sstevel@tonic-gate.a 827c478bd9Sstevel@tonic-gate }; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate/* generated by sort on caps */ 857c478bd9Sstevel@tonic-gatestatic short numoffsets[] = 867c478bd9Sstevel@tonic-gate { 877c478bd9Sstevel@tonic-gate. 887c478bd9Sstevel@tonic-gate!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 897c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp 907c478bd9Sstevel@tonic-gate.a 917c478bd9Sstevel@tonic-gate }; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate/* generated by sort on caps */ 947c478bd9Sstevel@tonic-gatestatic short stroffsets[] = 957c478bd9Sstevel@tonic-gate { 967c478bd9Sstevel@tonic-gate. 977c478bd9Sstevel@tonic-gate!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 987c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp 997c478bd9Sstevel@tonic-gate!rm ./tmp/termcap.tmp 1007c478bd9Sstevel@tonic-gate.a 1017c478bd9Sstevel@tonic-gate }; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate/* 1047c478bd9Sstevel@tonic-gate * Return the value of the boolean capability tcstr. 1057c478bd9Sstevel@tonic-gate * Return 0 if the capability is not found. 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gateint 1097c478bd9Sstevel@tonic-gatetgetflag(char *tcstr) 1107c478bd9Sstevel@tonic-gate{ 1117c478bd9Sstevel@tonic-gate char *p; 1127c478bd9Sstevel@tonic-gate char stripped[16]; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate switch (_TWOSTR(tcstr)) { 1157c478bd9Sstevel@tonic-gate /* Special cases that do not have exact terminfo equivalents */ 1167c478bd9Sstevel@tonic-gate case _TWO('b','s'): 1177c478bd9Sstevel@tonic-gate /* bs: true if ^H moves the cursor left */ 1187c478bd9Sstevel@tonic-gate p = _stripdelays(cursor_left, stripped, 16); 1197c478bd9Sstevel@tonic-gate return (p && *p == 8 && p[1] == 0); 1207c478bd9Sstevel@tonic-gate case _TWO('p','t'): 1217c478bd9Sstevel@tonic-gate /* pt: true if terminal has ^I tabs every 8 spaces */ 1227c478bd9Sstevel@tonic-gate p = _stripdelays(tab, stripped, 16); 1237c478bd9Sstevel@tonic-gate return (p && *p == 9 && p[1] == 0); 1247c478bd9Sstevel@tonic-gate case _TWO('n','c'): 1257c478bd9Sstevel@tonic-gate /* cr: true if ^M does not return the cursor */ 1267c478bd9Sstevel@tonic-gate p = _stripdelays(carriage_return, stripped, 16); 1277c478bd9Sstevel@tonic-gate return (! (p && *p == 13 && p[1] == 0)); 1287c478bd9Sstevel@tonic-gate case _TWO('n','s'): 1297c478bd9Sstevel@tonic-gate /* ns: true if no way to scroll the terminal */ 1307c478bd9Sstevel@tonic-gate return (scroll_forward == NULL); 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate { 1337c478bd9Sstevel@tonic-gate int n = _NUMELEMENTS(booloffsets); 1347c478bd9Sstevel@tonic-gate int offset = _tcsearch(tcstr, booloffsets, boolcodes, n, 2); 1357c478bd9Sstevel@tonic-gate char *bool_array = (char *) cur_bools; 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate if (offset == -1) 1387c478bd9Sstevel@tonic-gate return (0); 1397c478bd9Sstevel@tonic-gate else 1407c478bd9Sstevel@tonic-gate return (bool_array[offset]); 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate} 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate/* 1457c478bd9Sstevel@tonic-gate * Return the value of the numeric capability tcstr. 1467c478bd9Sstevel@tonic-gate * Return -1 if the capability is not found. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gateint 1507c478bd9Sstevel@tonic-gatetgetnum(char *tcstr) 1517c478bd9Sstevel@tonic-gate{ 1527c478bd9Sstevel@tonic-gate int n = _NUMELEMENTS(numoffsets); 1537c478bd9Sstevel@tonic-gate int offset = _tcsearch(tcstr, numoffsets, numcodes, n, 2); 1547c478bd9Sstevel@tonic-gate short *num_array = (short *) cur_nums; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate if (offset == -1) 1577c478bd9Sstevel@tonic-gate return (-1); 1587c478bd9Sstevel@tonic-gate else 1597c478bd9Sstevel@tonic-gate return (num_array[offset]); 1607c478bd9Sstevel@tonic-gate} 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate/* 1637c478bd9Sstevel@tonic-gate * Return the string capability for capability "id". We also copy 1647c478bd9Sstevel@tonic-gate * it into *area for upward compatibility with a few programs that 1657c478bd9Sstevel@tonic-gate * actually expect it to be copied, at a slight cost in speed. 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gatechar * 1697c478bd9Sstevel@tonic-gatetgetstr(char *tcstr, char **area) 1707c478bd9Sstevel@tonic-gate{ 1717c478bd9Sstevel@tonic-gate int n = _NUMELEMENTS(stroffsets); 1727c478bd9Sstevel@tonic-gate int offset = _tcsearch(tcstr, stroffsets, strcodes, n, 2); 1737c478bd9Sstevel@tonic-gate char **str_array = (char **) cur_strs; 1747c478bd9Sstevel@tonic-gate char *rv; 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate if (offset == -1) 1777c478bd9Sstevel@tonic-gate return (0); 1787c478bd9Sstevel@tonic-gate rv = str_array[offset]; 1797c478bd9Sstevel@tonic-gate if (area && *area && rv) { 1807c478bd9Sstevel@tonic-gate (void) strcpy(*area, rv); 1817c478bd9Sstevel@tonic-gate *area += strlen(rv) + 1; 1827c478bd9Sstevel@tonic-gate } 1837c478bd9Sstevel@tonic-gate return (rv); 1847c478bd9Sstevel@tonic-gate} 1857c478bd9Sstevel@tonic-gate. 1867c478bd9Sstevel@tonic-gatew termcap.c 1877c478bd9Sstevel@tonic-gateq 188