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?
23 find -H -s * -name '*.h' |
25 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
26 awk '{printf("#include <%s>\\\\n", $1)}'
29 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
31 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
33 print "/* XXX obnoxious prerequisites. */"
34 print "#define COMPAT_43"
35 print "#include <sys/param.h>"
36 print "#include <sys/devicestat.h>"
37 print "#include <sys/disklabel.h>"
38 print "#include <sys/socket.h>"
39 print "#include <sys/time.h>"
40 print "#include <sys/tty.h>"
41 print "#include <bsm/audit.h>"
42 print "#include <net/ethernet.h>"
43 print "#include <net/if.h>"
44 print "#include <net/if_var.h>"
45 print "#include <net/pfvar.h>"
46 print "#include <net/route.h>"
47 print "#include <netinet/in.h>"
48 print "#include <netinet/ip_mroute.h>"
49 print "#include <netinet6/in6_var.h>"
50 print "#include <netinet6/nd6.h>"
51 print "#include <netinet6/ip6_mroute.h>"
52 print "#include <stdio.h>"
53 print "#include <cam/cam.h>"
55 print "const char *ioctlname(u_long val);"
60 print "ioctlname(u_long val)"
64 print "\tswitch(val) {"
67 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
69 # find where the name starts
70 for (i = 1; i <= NF; i++)
76 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
78 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
84 print "\n\treturn(NULL);"