1#!/bin/sh 2# $OpenBSD: MKfallback.sh,v 1.4 2010/01/12 23:22:06 nicm Exp $ 3############################################################################## 4# Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. # 5# # 6# Permission is hereby granted, free of charge, to any person obtaining a # 7# copy of this software and associated documentation files (the "Software"), # 8# to deal in the Software without restriction, including without limitation # 9# the rights to use, copy, modify, merge, publish, distribute, distribute # 10# with modifications, sublicense, and/or sell copies of the Software, and to # 11# permit persons to whom the Software is furnished to do so, subject to the # 12# following conditions: # 13# # 14# The above copyright notice and this permission notice shall be included in # 15# all copies or substantial portions of the Software. # 16# # 17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 23# DEALINGS IN THE SOFTWARE. # 24# # 25# Except as contained in this notice, the name(s) of the above copyright # 26# holders shall not be used in advertising or otherwise to promote the sale, # 27# use or other dealings in this Software without prior written # 28# authorization. # 29############################################################################## 30# $Id: MKfallback.sh,v 1.4 2010/01/12 23:22:06 nicm Exp $ 31# 32# MKfallback.sh -- create fallback table for entry reads 33# 34# This script generates source code for a custom version of read_entry.c 35# that (instead of reading capabilities for an argument terminal type 36# from an on-disk terminfo tree) tries to match the type with one of a 37# specified list of types generated in. 38# 39 40cat <<EOF 41/* 42 * DO NOT EDIT THIS FILE BY HAND! It is generated by MKfallback.sh. 43 */ 44 45#include <curses.priv.h> 46#include <term.h> 47 48EOF 49 50if [ "$*" ] 51then 52 cat <<EOF 53#include <tic.h> 54 55/* fallback entries for: $* */ 56EOF 57 for x in $* 58 do 59 echo "/* $x */" 60 infocmp -E $x 61 done 62 63 cat <<EOF 64static const TERMTYPE fallbacks[$#] = 65{ 66EOF 67 comma="" 68 for x in $* 69 do 70 echo "$comma /* $x */" 71 infocmp -e $x 72 comma="," 73 done 74 75 cat <<EOF 76}; 77 78EOF 79fi 80 81cat <<EOF 82NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *name GCC_UNUSED) 83{ 84EOF 85 86if [ "$*" ] 87then 88 cat <<EOF 89 const TERMTYPE *tp; 90 91 for (tp = fallbacks; 92 tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE); 93 tp++) 94 if (_nc_name_match(tp->term_names, name, "|")) 95 return(tp); 96EOF 97else 98 echo " /* the fallback list is empty */"; 99fi 100 101cat <<EOF 102 return((TERMTYPE *)0); 103} 104EOF 105