mkioctls revision 53079
1set -e 2 3# $FreeBSD: head/usr.bin/kdump/mkioctls 53079 1999-11-10 08:41:08Z dfr $ 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_mroute.h>" 39 print "#include <cam/cam.h>" 40 print "#include <stdio.h>" 41 print "" 42 print ioctl_includes 43 print "" 44 print "char *" 45 print "ioctlname(register_t val)" 46 print "{" 47 print "" 48 generate_case_statement = 0 49 if (generate_case_statement) 50 print "\tswitch(val) {" 51} 52 53/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ { 54 55 # find where the name starts 56 for (i = 1; i <= NF; i++) 57 if ($i ~ /define/) 58 break; 59 ++i; 60 # 61 if (generate_case_statement) 62 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i); 63 else 64 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i); 65 66} 67END { 68 if (generate_case_statement) 69 print "\t}" 70 print "\n\treturn(NULL);" 71 print "}" 72} 73' 74