1#!/bin/sh
2# $Id: MKcaptab.awk,v 1.11 1999/01/24 02:46:42 Jeffrey.C.Honig Exp $
3AWK=${1-awk}
4DATA=${2-../include/Caps}
5
6cat <<'EOF'
7/*
8 *	comp_captab.c -- The names of the capabilities indexed via a hash
9 *		         table for the compiler.
10 *
11 */
12
13#include <ncurses_cfg.h>
14#include <tic.h>
15#include <term.h>
16
17EOF
18
19./make_hash 1 info <$DATA
20./make_hash 3 cap  <$DATA
21
22cat <<'EOF'
23const struct alias _nc_capalias_table[] =
24{
25EOF
26
27$AWK <$DATA '
28$1 == "capalias"	{
29		    if ($3 == "IGNORE")
30			to = "(char *)NULL";
31		    else
32			to = "\"" $3 "\"";
33		    printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
34				$2, to, $4, $5
35		}
36'
37
38cat <<'EOF'
39	{(char *)NULL, (char *)NULL, (char *)NULL}
40};
41
42const struct alias _nc_infoalias_table[] =
43{
44EOF
45
46$AWK <$DATA '
47$1 == "infoalias"	{
48		    if ($3 == "IGNORE")
49			to = "(char *)NULL";
50		    else
51			to = "\"" $3 "\"";
52		    printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
53				$2, to, $4, $5
54		}
55'
56
57cat <<'EOF'
58	{(char *)NULL, (char *)NULL, (char *)NULL}
59};
60
61const struct name_table_entry *_nc_get_table(bool termcap)
62{
63	return termcap ? _nc_cap_table: _nc_info_table ;
64}
65
66const struct name_table_entry * const * _nc_get_hash_table(bool termcap)
67{
68	return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
69}
70EOF
71