xref: /netbsd/sbin/route/keywords.sh (revision 6550d01e)
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
66_EOF_
67
68
69################################################################
70# Setup
71################################################################
72
73# This creates a stream of:
74#	keyword KEYWORD
75# (lower case, upper case).
76tr a-z A-Z < _keywords.t1 |
77paste _keywords.t1 - > _keywords.t2
78
79
80################################################################
81# Generate the h file
82################################################################
83exec > keywords.h
84
85echo '/* $'NetBSD'$ */
86
87/* WARNING!  This file was generated by keywords.sh  */
88
89extern struct keytab {
90	const char *kt_cp;
91	int	kt_i;
92} keywords[];
93
94' # defines follow
95
96$awk '{
97	printf("#define\tK_%s\t%d\n", $2, NR);
98}' < _keywords.t2
99
100
101################################################################
102# Generate the c file
103################################################################
104exec > keywords.c
105
106echo '/* $'NetBSD'$ */
107
108/* WARNING!  This file was generated by keywords.sh  */
109
110#include "keywords.h"
111
112struct keytab keywords[] = {
113' # initializers follow
114
115$awk '{
116	printf("\t{\"%s\", K_%s},\n", $1, $2);
117}' < _keywords.t2
118
119echo '	{0, 0}
120};
121' # tail
122
123
124################################################################
125# Cleanup
126################################################################
127
128rm -f _keywords.t1 _keywords.t2
129exit 0
130