1#!/bin/sh
2# $Id: MKfallback.sh,v 1.9 1999/06/15 22:57:45 tom Exp $
3#
4# MKfallback.sh -- create fallback table for entry reads
5#
6# This script generates source code for a custom version of read_entry.c
7# that (instead of reading capabilities for an argument terminal type
8# from an on-disk terminfo tree) tries to match the type with one of a
9# specified list of types generated in.
10#
11cat <<EOF
12/*
13 * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
14 */
15
16#include <curses.priv.h>
17#include <term.h>
18
19EOF
20
21if [ "$*" ]
22then
23	cat <<EOF
24#include <tic.h>
25
26/* fallback entries for: $* */
27EOF
28	for x in $*
29	do
30		echo "/* $x */"
31		infocmp -E $x
32	done
33
34	cat <<EOF
35static const TERMTYPE fallbacks[$#] =
36{
37EOF
38	comma=""
39	for x in $*
40	do
41		echo "$comma /* $x */"
42		infocmp -e $x
43		comma=","
44	done
45
46	cat <<EOF
47};
48
49EOF
50fi
51
52cat <<EOF
53const TERMTYPE *_nc_fallback(const char *name GCC_UNUSED)
54{
55EOF
56
57if [ "$*" ]
58then
59	cat <<EOF
60    const TERMTYPE	*tp;
61
62    for (tp = fallbacks;
63	 	tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
64	 	tp++)
65	if (_nc_name_match(tp->term_names, name, "|"))
66	    return(tp);
67EOF
68else
69	echo "	/* the fallback list is empty */";
70fi
71
72cat <<EOF
73	return((TERMTYPE *)0);
74}
75EOF
76