1998-10-16 15:33:17 +00:00
|
|
|
set -e
|
|
|
|
|
1999-10-06 07:45:30 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
1999-12-03 12:50:02 +00:00
|
|
|
if [ "x$1" = "x-s" ]; then
|
|
|
|
use_switch=1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
use_switch=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "usage: sh $0 [-s] include-dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1998-10-16 15:33:17 +00:00
|
|
|
# Build a list of headers that have ioctls in them.
|
1996-06-23 17:05:10 +00:00
|
|
|
# XXX should we use an ANSI cpp?
|
1998-10-16 15:33:17 +00:00
|
|
|
# XXX netipx conflicts with netns (leave out netns).
|
|
|
|
ioctl_includes=`
|
1999-12-03 12:50:02 +00:00
|
|
|
cd $1
|
1998-10-16 15:33:17 +00:00
|
|
|
find * -name '*.h' -follow |
|
|
|
|
egrep -v '^(netns)/' |
|
|
|
|
xargs egrep -l \
|
2000-08-01 08:15:06 +00:00
|
|
|
'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
|
1998-10-16 15:33:17 +00:00
|
|
|
sed -e 's/^/#include </' -e s'/$/>/'
|
|
|
|
`
|
|
|
|
|
|
|
|
echo "$ioctl_includes" |
|
1999-12-03 12:50:02 +00:00
|
|
|
gcc -E -I$1 -dM - |
|
|
|
|
awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
|
1994-05-27 12:33:43 +00:00
|
|
|
BEGIN {
|
1998-10-16 15:33:17 +00:00
|
|
|
print "/* XXX obnoxious prerequisites. */"
|
|
|
|
print "#define COMPAT_43"
|
1994-05-27 12:33:43 +00:00
|
|
|
print "#include <sys/param.h>"
|
1998-10-16 15:33:17 +00:00
|
|
|
print "#include <sys/devicestat.h>"
|
|
|
|
print "#include <sys/disklabel.h>"
|
1994-05-27 12:33:43 +00:00
|
|
|
print "#include <sys/socket.h>"
|
1996-12-10 17:11:53 +00:00
|
|
|
print "#include <sys/time.h>"
|
1998-10-16 15:33:17 +00:00
|
|
|
print "#include <sys/tty.h>"
|
1994-05-27 12:33:43 +00:00
|
|
|
print "#include <net/if.h>"
|
1998-10-16 15:33:17 +00:00
|
|
|
print "#include <net/if_var.h>"
|
|
|
|
print "#include <net/route.h>"
|
|
|
|
print "#include <netatm/atm.h>"
|
|
|
|
print "#include <netatm/atm_if.h>"
|
|
|
|
print "#include <netatm/atm_sap.h>"
|
|
|
|
print "#include <netatm/atm_sys.h>"
|
1996-06-23 17:05:10 +00:00
|
|
|
print "#include <netinet/in.h>"
|
1999-11-24 15:38:35 +00:00
|
|
|
print "#include <netinet/ip_compat.h>"
|
|
|
|
print "#include <netinet/ip_fil.h>"
|
|
|
|
print "#include <netinet/ip_auth.h>"
|
|
|
|
print "#include <netinet/ip_nat.h>"
|
|
|
|
print "#include <netinet/ip_frag.h>"
|
|
|
|
print "#include <netinet/ip_state.h>"
|
1999-10-11 16:14:22 +00:00
|
|
|
print "#include <netinet/ip_mroute.h>"
|
2000-07-04 16:26:47 +00:00
|
|
|
print "#include <netinet6/in6_var.h>"
|
|
|
|
print "#include <netinet6/nd6.h>"
|
|
|
|
print "#include <netinet6/ip6_mroute.h>"
|
1998-10-16 15:33:17 +00:00
|
|
|
print "#include <cam/cam.h>"
|
|
|
|
print "#include <stdio.h>"
|
|
|
|
print ""
|
|
|
|
print ioctl_includes
|
1994-05-27 12:33:43 +00:00
|
|
|
print ""
|
|
|
|
print "char *"
|
1999-11-10 08:41:08 +00:00
|
|
|
print "ioctlname(register_t val)"
|
1994-05-27 12:33:43 +00:00
|
|
|
print "{"
|
|
|
|
print ""
|
1999-12-03 12:50:02 +00:00
|
|
|
if (use_switch)
|
1998-10-16 15:33:17 +00:00
|
|
|
print "\tswitch(val) {"
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
1998-10-16 15:33:17 +00:00
|
|
|
/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
# find where the name starts
|
|
|
|
for (i = 1; i <= NF; i++)
|
|
|
|
if ($i ~ /define/)
|
|
|
|
break;
|
|
|
|
++i;
|
|
|
|
#
|
1999-12-03 12:50:02 +00:00
|
|
|
if (use_switch)
|
1998-10-16 15:33:17 +00:00
|
|
|
printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
|
|
|
|
else
|
|
|
|
printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
END {
|
1999-12-03 12:50:02 +00:00
|
|
|
if (use_switch)
|
1998-10-16 15:33:17 +00:00
|
|
|
print "\t}"
|
1994-05-27 12:33:43 +00:00
|
|
|
print "\n\treturn(NULL);"
|
|
|
|
print "}"
|
|
|
|
}
|
1996-06-23 17:05:10 +00:00
|
|
|
'
|