mkioctls revision 1.12
11.7Sjtc#!/bin/sh -
21.12Smjl#	$NetBSD: mkioctls,v 1.12 2003/06/24 11:27:50 mjl 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.11Scgd${CC:-cc} -E -nostdinc -idirafter $DESTDIR/usr/include -dM ${1+"$@"} | awk '
381.1ScgdBEGIN {
391.1Scgd	print "#include <sys/param.h>"
401.1Scgd	print "#include <sys/socket.h>"
411.12Smjl	print "#include <sys/sockio.h>"
421.1Scgd	print "#include <sys/socketvar.h>"
431.1Scgd	print "#include <net/route.h>"
441.1Scgd	print "#include <net/if.h>"
451.6Sthorpej	print "#include <netinet/in.h>"
461.6Sthorpej	print "#include <netinet/ip_mroute.h>"
471.1Scgd	print "#include <sys/termios.h>"
481.1Scgd	print "#define COMPAT_43"
491.1Scgd	print "#include <sys/ioctl.h>"
501.10Slukem	print ""
511.10Slukem	print "char *ioctlname __P((long));"
521.1Scgd	print ""
531.1Scgd	print "char *"
541.1Scgd	print "ioctlname(val)"
551.5Smycroft	print "\tlong val;"
561.1Scgd	print "{"
571.1Scgd	print ""
581.1Scgd}
591.1Scgd
601.1Scgd/^#[ 	]*define[ 	]*(TIO|FIO|SIO|OSIO)[A-Z]*[ 	]*_IO/ {
611.1Scgd	
621.1Scgd	# find where the name starts
631.1Scgd	for (i = 1; i <= NF; i++)
641.1Scgd		if ($i ~ /define/)
651.1Scgd			break;
661.1Scgd	++i;
671.1Scgd	# 
681.5Smycroft	printf("\tif (val == %s)\n\t\treturn (\"%s\");\n", $i, $i);
691.1Scgd
701.1Scgd}
711.1ScgdEND {
721.5Smycroft	print "\n\treturn (NULL);"
731.1Scgd	print "}"
741.1Scgd}
751.5Smycroft'
76