mkioctls revision 20287
116631Sbde# XXX should we use an ANSI cpp?
216631Sbde# XXX does -I$DESTDIR/usr/include actually work?
316631Sbde(echo "#include <sys/ioctl.h>"
416631Sbde echo "#include <sys/ioctl_compat.h>"
516631Sbde) | cpp -I$DESTDIR/usr/include -dM | awk '
61590SrgrimesBEGIN {
71590Srgrimes	print "#include <sys/param.h>"
814541Sdg	print "#include <sys/queue.h>"
91590Srgrimes	print "#include <sys/socket.h>"
101590Srgrimes	print "#include <sys/socketvar.h>"
1120287Swollman	print "#include <sys/time.h>"
121590Srgrimes	print "#include <net/route.h>"
131590Srgrimes	print "#include <net/if.h>"
1416631Sbde	print "#include <netinet/in.h>"
1516631Sbde	print "#include <netinet/ip_mroute.h>"
161590Srgrimes	print "#include <sys/termios.h>"
171590Srgrimes	print "#define COMPAT_43"
181590Srgrimes	print "#include <sys/ioctl.h>"
191590Srgrimes	print ""
201590Srgrimes	print "char *"
211590Srgrimes	print "ioctlname(val)"
221590Srgrimes	print "{"
231590Srgrimes	print ""
241590Srgrimes}
251590Srgrimes
261590Srgrimes/^#[ 	]*define[ 	]*(TIO|FIO|SIO|OSIO)[A-Z]*[ 	]*_IO/ {
271590Srgrimes	
281590Srgrimes	# find where the name starts
291590Srgrimes	for (i = 1; i <= NF; i++)
301590Srgrimes		if ($i ~ /define/)
311590Srgrimes			break;
321590Srgrimes	++i;
331590Srgrimes	# 
341590Srgrimes	printf("\tif (val ==  %s)\n\t\treturn(\"%s\");\n", $i, $i);
351590Srgrimes
361590Srgrimes}
371590SrgrimesEND {
381590Srgrimes	print "\n\treturn(NULL);"
391590Srgrimes	print "}"
401590Srgrimes}
4116631Sbde'
42