mkioctls revision 1.1
1awk ' 2BEGIN { 3 print "#include <sys/param.h>" 4 print "#include <sys/socket.h>" 5 print "#include <sys/socketvar.h>" 6 print "#include <net/route.h>" 7 print "#include <net/if.h>" 8 print "#include <sys/termios.h>" 9 print "#define COMPAT_43" 10 print "#include <sys/ioctl.h>" 11 print "" 12 print "char *" 13 print "ioctlname(val)" 14 print "{" 15 print "" 16} 17 18/^#[ ]*define[ ]*(TIO|FIO|SIO|OSIO)[A-Z]*[ ]*_IO/ { 19 20 # find where the name starts 21 for (i = 1; i <= NF; i++) 22 if ($i ~ /define/) 23 break; 24 ++i; 25 # 26 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i); 27 28} 29END { 30 print "\n\treturn(NULL);" 31 print "}" 32} 33' /usr/include/sys/ioctl.h /usr/include/sys/ioctl_compat.h 34