910af94b7a48dfbc6b02e226a9dcf896da430995
[ncurses.git] / ncurses / tinfo / MKcaptab.awk
1 #!/bin/sh
2 # $Id: MKcaptab.awk,v 1.11 1999/01/24 02:46:42 Jeffrey.C.Honig Exp $
3 AWK=${1-awk}
4 DATA=${2-../include/Caps}
5
6 cat <<'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
17 EOF
18
19 ./make_hash 1 info <$DATA
20 ./make_hash 3 cap  <$DATA
21
22 cat <<'EOF'
23 const struct alias _nc_capalias_table[] =
24 {
25 EOF
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
38 cat <<'EOF'
39         {(char *)NULL, (char *)NULL, (char *)NULL}
40 };
41
42 const struct alias _nc_infoalias_table[] =
43 {
44 EOF
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
57 cat <<'EOF'
58         {(char *)NULL, (char *)NULL, (char *)NULL}
59 };
60
61 const struct name_table_entry *_nc_get_table(bool termcap)
62 {
63         return termcap ? _nc_cap_table: _nc_info_table ;
64 }
65
66 const struct name_table_entry * const * _nc_get_hash_table(bool termcap)
67 {
68         return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
69 }
70 EOF