mkioctls revision 53669
1set -e 2 3# $FreeBSD: head/usr.bin/kdump/mkioctls 53669 1999-11-24 15:38:35Z guido $ 4 5# Build a list of headers that have ioctls in them. 6# XXX should we use an ANSI cpp? 7# XXX netipx conflicts with netns (leave out netns). 8ioctl_includes=` 9 cd $DESTDIR/usr/include 10 find * -name '*.h' -follow | 11 egrep -v '^(netns)/' | 12 xargs egrep -l \ 13'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-0_]*[ ]+_IO[^a-z0-9_]' | 14 sed -e 's/^/#include </' -e s'/$/>/' 15` 16 17echo "$ioctl_includes" | 18 cpp -I$DESTDIR/usr/include -dM | 19 awk -v ioctl_includes="$ioctl_includes" ' 20BEGIN { 21 print "/* XXX obnoxious prerequisites. */" 22 print "#define COMPAT_43" 23 print "#include <sys/param.h>" 24 print "#include <sys/devicestat.h>" 25 print "#include <sys/disklabel.h>" 26 print "#include <sys/dkbad.h>" 27 print "#include <sys/socket.h>" 28 print "#include <sys/time.h>" 29 print "#include <sys/tty.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>" 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>" 43 print "#include <netinet/ip_state.h>" 44 print "#include <netinet/ip_mroute.h>" 45 print "#include <cam/cam.h>" 46 print "#include <stdio.h>" 47 print "" 48 print ioctl_includes 49 print "" 50 print "char *" 51 print "ioctlname(register_t val)" 52 print "{" 53 print "" 54 generate_case_statement = 0 55 if (generate_case_statement) 56 print "\tswitch(val) {" 57} 58 59/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ { 60 61 # find where the name starts 62 for (i = 1; i <= NF; i++) 63 if ($i ~ /define/) 64 break; 65 ++i; 66 # 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); 71 72} 73END { 74 if (generate_case_statement) 75 print "\t}" 76 print "\n\treturn(NULL);" 77 print "}" 78} 79' 80