3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.3 2001/04/07 11:09:28 ru Exp $
5 if [ "x$1" = "x-s" ]; then
13 echo "usage: sh $0 [-s] include-dir"
17 LC_ALL=C; export LC_ALL
19 # Build a list of headers that have ioctls in them.
20 # XXX should we use an ANSI cpp?
21 # XXX netipx conflicts with netns (leave out netns).
25 egrep -v '^(netns)/' |
27 egrep -v 'disklabel' |
30 egrep -v '^(netiso)/' |
31 egrep -v '^(netccitt)/' |
33 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
34 sed -e 's/^/#include </' -e s'/$/>/'
37 echo "/* XXX obnoxious prerequisites. */"
38 echo "#define COMPAT_43 1"
39 echo "#include <sys/param.h>"
40 echo "#include <sys/socket.h>"
41 echo "#include <sys/time.h>"
42 echo "#include <sys/tty.h>"
43 echo "#include <net/ethernet.h>"
44 echo "#include <net/if.h>"
45 echo "#include <net/if_var.h>"
46 echo "#include <net/route.h>"
47 echo "#include <netinet/in.h>"
48 echo "#include <netinet/ip_compat.h>"
49 echo "#include <netinet/ip_mroute.h>"
50 echo "#include <netinet6/in6_var.h>"
51 echo "#include <netinet6/nd6.h>"
52 echo "#include <netinet6/ip6_mroute.h>"
53 echo "#include <netat/appletalk.h>"
54 echo "#include <stdio.h>"
56 echo "$ioctl_includes"
59 echo "$ioctl_includes" |
60 cc -no-cpp-precomp -E -I$1 -dM - |
61 awk -v use_switch="$use_switch" '
64 print "ioctlname(register_t val)"
68 print "\tswitch(val) {"
71 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
73 # find where the name starts
74 for (i = 1; i <= NF; i++)
80 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
82 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
88 print "\n\treturn(NULL);"