mkioctls revision 1.19
11.14Schristos#!/bin/sh
21.19Schristos#	$NetBSD: mkioctls,v 1.19 2004/06/22 17:30:52 christos Exp $
31.7Sjtc#
41.7Sjtc# Copyright (c) 1994
51.7Sjtc#	The Regents of the University of California.  All rights reserved.
61.7Sjtc#
71.7Sjtc# Redistribution and use in source and binary forms, with or without
81.7Sjtc# modification, are permitted provided that the following conditions
91.7Sjtc# are met:
101.7Sjtc# 1. Redistributions of source code must retain the above copyright
111.7Sjtc#    notice, this list of conditions and the following disclaimer.
121.7Sjtc# 2. Redistributions in binary form must reproduce the above copyright
131.7Sjtc#    notice, this list of conditions and the following disclaimer in the
141.7Sjtc#    documentation and/or other materials provided with the distribution.
151.7Sjtc# 3. All advertising materials mentioning features or use of this software
161.7Sjtc#    must display the following acknowledgement:
171.7Sjtc#	This product includes software developed by the University of
181.7Sjtc#	California, Berkeley and its contributors.
191.7Sjtc# 4. Neither the name of the University nor the names of its contributors
201.7Sjtc#    may be used to endorse or promote products derived from this software
211.7Sjtc#    without specific prior written permission.
221.7Sjtc#
231.7Sjtc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.7Sjtc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.7Sjtc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.7Sjtc# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.7Sjtc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.7Sjtc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.7Sjtc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.7Sjtc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.7Sjtc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.7Sjtc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.7Sjtc# SUCH DAMAGE.
341.7Sjtc#
351.7Sjtc#	@(#)mkioctls	8.2 (Berkeley) 4/28/95
361.3Smycroft#
371.16Schristosecho "/* Automatically generated file, do not edit! */"
381.14Schristosecho "#define const" 	# XXX: timepps lossage
391.14Schristosecho "struct ap_control { int _xxx; };" # XXX: ip_nat.h lossage
401.14Schristosecho "#define COMPAT_43"
411.14Schristosecho "struct lwp;"
421.15Sjmcecho "struct videomemory_t { int _xxx; };" # XXX arm video lossage
431.15Sjmcecho "typedef struct videomemory_t videomemory_t;" # XXX arm video lossage
441.14Schristosecho "#include <sys/types.h>"
451.14Schristosecho "#include <sys/param.h>"
461.14Schristosecho "#include <sys/disk.h>"
471.17Shannkenecho "#include <sys/dkbad.h>"
481.14Schristosecho "#include <sys/mount.h>"
491.14Schristosecho "#include <sys/termios.h>"
501.16Schristosecho "#include <sys/disklabel.h>"
511.14Schristosecho "#include <net/if.h>"
521.14Schristosecho "#include <net/route.h>"
531.14Schristosecho "#include <net/ppp_defs.h>"
541.14Schristosecho "#include <netinet/in.h>"
551.14Schristosecho "#include <netinet/in_systm.h>"
561.14Schristosecho "#include <netinet/ip.h>"
571.14Schristosecho "#include <netinet/ip_mroute.h>"
581.14Schristosecho "#include <netinet/ip_compat.h>"
591.14Schristosecho "#include <net80211/ieee80211.h>"
601.14Schristosecho "#include <netiso/iso.h>"
611.14Schristosfor i
621.14Schristosdo
631.14Schristos	echo "#include <$i>"
641.14Schristosdone | sed -e "s,${DESTDIR}/usr/include/,,g"
651.14Schristos
661.18Sdrochner${CC:-cc} -E -nostdinc -idirafter $DESTDIR/usr/include -dM ${1+"$@"} | awk '
671.1ScgdBEGIN {
681.17Shannken	keep["SLIOCGUNIT"] = 1;	# Same as PPPIOCGASYNCMAP
691.19Schristos	keep["TUNSLMODE"] = 1;	# Same as PPPIOCGASYNCMAP
701.17Shannken	keep["SIOCRMNAT"] = 1;	# Same as SIOCRMAFR
711.17Shannken	keep["SIOCADNAT"] = 1;	# Same as SIOCADAFR
721.17Shannken	keep["SIOCDELST"] = 1;	# Same as SIOCRMNAT
731.17Shannken	keep["CHIOGPICKER"] = 1; # Same as CDIOREADTOCHEADER
741.16Schristos
751.10Slukem	print ""
761.10Slukem	print "char *ioctlname __P((long));"
771.1Scgd	print ""
781.1Scgd	print "char *"
791.1Scgd	print "ioctlname(val)"
801.5Smycroft	print "\tlong val;"
811.1Scgd	print "{"
821.1Scgd	print ""
831.16Schristos	print "\tswitch (val) {\n"
841.1Scgd}
851.1Scgd
861.19Schristos/^#[ 	]*define[ 	]*[A-Z]*[ 	]*_IO/ {
871.1Scgd	
881.1Scgd	# find where the name starts
891.1Scgd	for (i = 1; i <= NF; i++)
901.1Scgd		if ($i ~ /define/)
911.1Scgd			break;
921.1Scgd	++i;
931.19Schristos	printf("/* %s [%s] */\n", $0, $i);
941.1Scgd	# 
951.19Schristos	if ($i ~ /^[A-Z0-9a-z_]*$/) {
961.19Schristos		if (keep[$i] != 1) {
971.19Schristos			printf("\tcase %s:\n\t\treturn \"%s\";\n", $i, $i);
981.19Schristos			keep[$i] = 1;
991.19Schristos		}
1001.16Schristos	}
1011.1Scgd}
1021.1ScgdEND {
1031.16Schristos	print "\tdefault:\n\t\treturn NULL;\n"
1041.16Schristos	print "\t}\n"
1051.1Scgd	print "}"
1061.1Scgd}
1071.5Smycroft'
108