7 if [ "x$1" = "x-s" ]; then
15 echo "usage: sh $0 [-s] include-dir"
19 LC_ALL=C; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # XXX should we use an ANSI cpp?
25 find -H -s * -name '*.h' |
27 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
28 awk '{printf("#include <%s>\\\\n", $1)}'
31 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
32 gcc -E -I$1 -dM -DCOMPAT_43TTY - |
33 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
35 print "/* XXX obnoxious prerequisites. */"
36 print "#define COMPAT_43"
37 print "#define COMPAT_43TTY"
38 print "#include <sys/param.h>"
39 print "#include <sys/devicestat.h>"
40 print "#include <sys/disklabel.h>"
41 print "#include <sys/socket.h>"
42 print "#include <sys/time.h>"
43 print "#include <sys/tty.h>"
44 print "#include <bsm/audit.h>"
45 print "#include <net/ethernet.h>"
46 print "#include <net/if.h>"
47 print "#include <net/if_var.h>"
48 print "#include <net/pfvar.h>"
49 print "#include <net/route.h>"
50 print "#include <netinet/in.h>"
51 print "#include <netinet/ip_mroute.h>"
52 print "#include <netinet6/in6_var.h>"
53 print "#include <netinet6/nd6.h>"
54 print "#include <netinet6/ip6_mroute.h>"
55 print "#include <stdio.h>"
56 print "#include <cam/cam.h>"
58 print "const char *ioctlname(u_long val);"
63 print "ioctlname(u_long val)"
67 print "\tswitch(val) {"
70 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
72 # find where the name starts
73 for (i = 1; i <= NF; i++)
79 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
81 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
87 print "\n\treturn(NULL);"