1#!/bin/sh
2# $Id: MKcaptab.awk,v 1.12 2000/12/10 00:14:12 tom 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 <curses.priv.h>
15#include <tic.h>
16#include <term.h>
17
18EOF
19
20./make_hash 1 info <$DATA
21./make_hash 3 cap  <$DATA
22
23cat <<'EOF'
24const struct alias _nc_capalias_table[] =
25{
26EOF
27
28$AWK <$DATA '
29$1 == "capalias"	{
30		    if ($3 == "IGNORE")
31			to = "(char *)NULL";
32		    else
33			to = "\"" $3 "\"";
34		    printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
35				$2, to, $4, $5
36		}
37'
38
39cat <<'EOF'
40	{(char *)NULL, (char *)NULL, (char *)NULL}
41};
42
43const struct alias _nc_infoalias_table[] =
44{
45EOF
46
47$AWK <$DATA '
48$1 == "infoalias"	{
49		    if ($3 == "IGNORE")
50			to = "(char *)NULL";
51		    else
52			to = "\"" $3 "\"";
53		    printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
54				$2, to, $4, $5
55		}
56'
57
58cat <<'EOF'
59	{(char *)NULL, (char *)NULL, (char *)NULL}
60};
61
62NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
63{
64	return termcap ? _nc_cap_table: _nc_info_table ;
65}
66
67NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool termcap)
68{
69	return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
70}
71EOF
72