#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
#
# Terminal Info Generator
#
# This script generates a static terminfo database for use by mdb. For each
# of the terminal properties used by mdb_termio.c, this script uses tput(1)
# to determine the value of the given attribute for each specified terminal
# type. The script produces an ANSI-C source file which contains a static
# array for each terminal type storing the properties. An additional array
# is then declared containing a list of the terminal types and pointers to
# the previous arrays. Finally, source code for several terminfo routines
# are included that simply access the arrays and return the saved properties.
#
{
exit 2
}
{
typeset skel="$1"
typeset secname="$2"
/\/\* [^ ]* [^ ]* \*\// && $3 == name {
if ($2 == "BEGIN") {
printing = 1;
printf("# %d \"%s\"\n", NR + 1, skel);
} else {
printing = 0;
}
next;
}
printing != 0 { print; }
'
}
verbose=false
while getopts s:t:v name ; do
v)
verbose=true
;;
s)
;;
t)
;;
?)
;;
esac
done
termlist=$*
if [ $? -ne 0 ]; then
exit 1
fi
done
# Extract the prologue from the skeleton
#
# For each terminal in the terminal list, produce a property definition array
# listing each property we need in mdb_termio.c and its current value.
#
#
# We don't want the compiler to blame the skeleton if it doesn't like
# the array we generate here, so point the finger elsewhere
#
echo "# 1 \"dynamic $term data from tigen\""
echo "static const termio_attr_t ${cterm}_attrs[] = {"
sed -n \ 's/{ "\([a-z0-9]*\)", \([A-Z_]*\),.*/\1 \2/p' | \
while read attr type; do
;;
;;
;;
*)
exit 1
esac
done
echo "\t{ NULL, NULL, NULL }"
echo "};\n"
done
#
# For each terminal in the terminal list, produce an entry in the terminal
# database array linking this terminal to its terminfo property array.
#
echo "# 1 \"dynamic array from tigen\""
echo "static const termio_desc_t termio_db[] = {"
echo "\t{ \"$term\", ${cterm}_attrs },"
done
echo "\t{ NULL, NULL }\n};"
exit 0