mkioctls revision 1.7
11.7Sjtc#!/bin/sh -
21.7Sjtc#
31.7Sjtc# Copyright (c) 1994
41.7Sjtc#	The Regents of the University of California.  All rights reserved.
51.7Sjtc#
61.7Sjtc# Redistribution and use in source and binary forms, with or without
71.7Sjtc# modification, are permitted provided that the following conditions
81.7Sjtc# are met:
91.7Sjtc# 1. Redistributions of source code must retain the above copyright
101.7Sjtc#    notice, this list of conditions and the following disclaimer.
111.7Sjtc# 2. Redistributions in binary form must reproduce the above copyright
121.7Sjtc#    notice, this list of conditions and the following disclaimer in the
131.7Sjtc#    documentation and/or other materials provided with the distribution.
141.7Sjtc# 3. All advertising materials mentioning features or use of this software
151.7Sjtc#    must display the following acknowledgement:
161.7Sjtc#	This product includes software developed by the University of
171.7Sjtc#	California, Berkeley and its contributors.
181.7Sjtc# 4. Neither the name of the University nor the names of its contributors
191.7Sjtc#    may be used to endorse or promote products derived from this software
201.7Sjtc#    without specific prior written permission.
211.7Sjtc#
221.7Sjtc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231.7Sjtc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241.7Sjtc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251.7Sjtc# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261.7Sjtc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271.7Sjtc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281.7Sjtc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291.7Sjtc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301.7Sjtc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311.7Sjtc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321.7Sjtc# SUCH DAMAGE.
331.7Sjtc#
341.7Sjtc#	@(#)mkioctls	8.2 (Berkeley) 4/28/95
351.3Smycroft#
361.5Smycroftcpp -dM ${1+"$@"} | awk '
371.1ScgdBEGIN {
381.1Scgd	print "#include <sys/param.h>"
391.1Scgd	print "#include <sys/socket.h>"
401.1Scgd	print "#include <sys/socketvar.h>"
411.1Scgd	print "#include <net/route.h>"
421.1Scgd	print "#include <net/if.h>"
431.6Sthorpej	print "#include <netinet/in.h>"
441.6Sthorpej	print "#include <netinet/ip_mroute.h>"
451.1Scgd	print "#include <sys/termios.h>"
461.1Scgd	print "#define COMPAT_43"
471.1Scgd	print "#include <sys/ioctl.h>"
481.1Scgd	print ""
491.1Scgd	print "char *"
501.1Scgd	print "ioctlname(val)"
511.5Smycroft	print "\tlong val;"
521.1Scgd	print "{"
531.1Scgd	print ""
541.1Scgd}
551.1Scgd
561.1Scgd/^#[ 	]*define[ 	]*(TIO|FIO|SIO|OSIO)[A-Z]*[ 	]*_IO/ {
571.1Scgd	
581.1Scgd	# find where the name starts
591.1Scgd	for (i = 1; i <= NF; i++)
601.1Scgd		if ($i ~ /define/)
611.1Scgd			break;
621.1Scgd	++i;
631.1Scgd	# 
641.5Smycroft	printf("\tif (val == %s)\n\t\treturn (\"%s\");\n", $i, $i);
651.1Scgd
661.1Scgd}
671.1ScgdEND {
681.5Smycroft	print "\n\treturn (NULL);"
691.1Scgd	print "}"
701.1Scgd}
711.5Smycroft'
72