| 1set -e 2 3# Build a list of headers that have ioctls in them.
|
1# XXX should we use an ANSI cpp?
| 4# XXX should we use an ANSI cpp?
|
2# XXX does -I$DESTDIR/usr/include actually work? 3(echo "#include <sys/ioctl.h>" 4 echo "#include <sys/ioctl_compat.h>" 5) | cpp -I$DESTDIR/usr/include -dM | awk '
| 5# XXX netipx conflicts with netns (leave out netns). 6ioctl_includes=` 7 cd $DESTDIR/usr/include 8 find * -name '*.h' -follow | 9 egrep -v '^(netns)/' | 10 xargs egrep -l \ 11'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-0_]*[ ]+_IO[^a-z0-9_]' | 12 sed -e 's/^/#include </' -e s'/$/>/' 13` 14 15echo "$ioctl_includes" | 16 cpp -I$DESTDIR/usr/include -dM | 17 awk -v ioctl_includes="$ioctl_includes" '
|
6BEGIN {
| 18BEGIN {
|
| 19 print "/* XXX obnoxious prerequisites. */" 20 print "#define COMPAT_43"
|
7 print "#include <sys/param.h>"
| 21 print "#include <sys/param.h>"
|
8 print "#include <sys/queue.h>"
| 22 print "#include <sys/device.h>" 23 print "#include <sys/devicestat.h>" 24 print "#include <sys/disklabel.h>" 25 print "#include <sys/disk.h>" 26 print "#include <sys/dkbad.h>"
|
9 print "#include <sys/socket.h>"
| 27 print "#include <sys/socket.h>"
|
10 print "#include <sys/socketvar.h>"
| |
11 print "#include <sys/time.h>"
| 28 print "#include <sys/time.h>"
|
12 print "#include <net/route.h>"
| 29 print "#include <sys/tty.h>"
|
13 print "#include <net/if.h>"
| 30 print "#include <net/if.h>"
|
| 31 print "#include <net/if_var.h>" 32 print "#include <net/route.h>" 33 print "#include <netatm/atm.h>" 34 print "#include <netatm/atm_if.h>" 35 print "#include <netatm/atm_sap.h>" 36 print "#include <netatm/atm_sys.h>"
|
14 print "#include <netinet/in.h>"
| 37 print "#include <netinet/in.h>"
|
| 38 print "#include <netinet/ip_compat.h>" 39 print "#include <netinet/ip_fil.h>" 40 print "#include <netinet/ip_auth.h>" 41 print "#include <netinet/ip_nat.h>" 42 print "#include <netinet/ip_frag.h>"
|
15 print "#include <netinet/ip_mroute.h>"
| 43 print "#include <netinet/ip_mroute.h>"
|
16 print "#include <sys/termios.h>" 17 print "#define COMPAT_43" 18 print "#include <sys/ioctl.h>"
| 44 print "#include <netinet/ip_state.h>" 45 print "#include <cam/cam.h>" 46 print "#include <stdio.h>"
|
19 print ""
| 47 print ""
|
| 48 print ioctl_includes 49 print ""
|
20 print "char *" 21 print "ioctlname(val)" 22 print "{" 23 print ""
| 50 print "char *" 51 print "ioctlname(val)" 52 print "{" 53 print ""
|
| 54 generate_case_statement = 0 55 if (generate_case_statement) 56 print "\tswitch(val) {"
|
24} 25
| 57} 58
|
26/^#[ ]*define[ ]*(TIO|FIO|SIO|OSIO)[A-Z]*[ ]*_IO/ {
| 59/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
|
27 28 # find where the name starts 29 for (i = 1; i <= NF; i++) 30 if ($i ~ /define/) 31 break; 32 ++i; 33 #
| 60 61 # find where the name starts 62 for (i = 1; i <= NF; i++) 63 if ($i ~ /define/) 64 break; 65 ++i; 66 #
|
34 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
| 67 if (generate_case_statement) 68 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i); 69 else 70 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
|
35 36} 37END {
| 71 72} 73END {
|
| 74 if (generate_case_statement) 75 print "\t}"
|
38 print "\n\treturn(NULL);" 39 print "}" 40} 41'
| 76 print "\n\treturn(NULL);" 77 print "}" 78} 79'
|