xref: /minix/sbin/route/keywords.sh (revision 483e5955)
1#!/bin/sh
2# $NetBSD: keywords.sh,v 1.11 2013/03/01 18:25:17 joerg 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
32link
33llinfo
34lock
35lockrest
36mask
37monitor
38mtu
39net
40netmask
41nostatic
42prefixlen
43proto1
44proto2
45recvpipe
46reject
47rtt
48rttvar
49sa
50sendpipe
51show
52ssthresh
53static
54x25
55xns
56xresolve
57flushall
58nocloned
59nocloning
60noblackhole
61noreject
62mpls
63tag
64proxy
65_EOF_
66
67
68################################################################
69# Setup
70################################################################
71
72# This creates a stream of:
73#	keyword KEYWORD
74# (lower case, upper case).
75tr a-z A-Z < _keywords.t1 |
76paste _keywords.t1 - > _keywords.t2
77
78
79################################################################
80# Generate the h file
81################################################################
82exec > keywords.h
83
84echo '/* $'NetBSD'$ */
85
86/* WARNING!  This file was generated by keywords.sh  */
87
88extern struct keytab {
89	const char *kt_cp;
90	int	kt_i;
91} keywords[];
92
93' # defines follow
94
95$awk '{
96	printf("#define\tK_%s\t%d\n", $2, NR);
97}' < _keywords.t2
98
99
100################################################################
101# Generate the c file
102################################################################
103exec > keywords.c
104
105echo '/* $'NetBSD'$ */
106
107/* WARNING!  This file was generated by keywords.sh  */
108
109#include "keywords.h"
110
111struct keytab keywords[] = {
112' # initializers follow
113
114$awk '{
115	printf("\t{\"%s\", K_%s},\n", $1, $2);
116}' < _keywords.t2
117
118echo '	{0, 0}
119};
120' # tail
121
122
123################################################################
124# Cleanup
125################################################################
126
127rm -f _keywords.t1 _keywords.t2
128exit 0
129