1#!/bin/sh
2# $NetBSD: keywords.sh,v 1.9 2010/06/26 14:29:36 kefren Exp $
3# @(#)keywords	8.2 (Berkeley) 3/19/94
4#
5# WARNING!  If you change this file, re-run it!
6
7# This program requires "new" awk (or GNU awk).
8awk=${AWK:-awk}
9
10cat << _EOF_ > _keywords.t1
11add
12atalk
13blackhole
14change
15cloned
16cloning
17delete
18dst
19expire
20flush
21gateway
22genmask
23get
24host
25hopcount
26iface
27interface
28ifa
29ifp
30inet
31inet6
32iso
33link
34llinfo
35lock
36lockrest
37mask
38monitor
39mtu
40net
41netmask
42nostatic
43osi
44prefixlen
45proto1
46proto2
47recvpipe
48reject
49rtt
50rttvar
51sa
52sendpipe
53show
54ssthresh
55static
56x25
57xns
58xresolve
59flushall
60nocloned
61nocloning
62noblackhole
63noreject
64mpls
65tag
66proxy
67_EOF_
68
69
70################################################################
71# Setup
72################################################################
73
74# This creates a stream of:
75#	keyword KEYWORD
76# (lower case, upper case).
77tr a-z A-Z < _keywords.t1 |
78paste _keywords.t1 - > _keywords.t2
79
80
81################################################################
82# Generate the h file
83################################################################
84exec > keywords.h
85
86echo '/* $'NetBSD'$ */
87
88/* WARNING!  This file was generated by keywords.sh  */
89
90extern struct keytab {
91	const char *kt_cp;
92	int	kt_i;
93} keywords[];
94
95' # defines follow
96
97$awk '{
98	printf("#define\tK_%s\t%d\n", $2, NR);
99}' < _keywords.t2
100
101
102################################################################
103# Generate the c file
104################################################################
105exec > keywords.c
106
107echo '/* $'NetBSD'$ */
108
109/* WARNING!  This file was generated by keywords.sh  */
110
111#include "keywords.h"
112
113struct keytab keywords[] = {
114' # initializers follow
115
116$awk '{
117	printf("\t{\"%s\", K_%s},\n", $1, $2);
118}' < _keywords.t2
119
120echo '	{0, 0}
121};
122' # tail
123
124
125################################################################
126# Cleanup
127################################################################
128
129rm -f _keywords.t1 _keywords.t2
130exit 0
131