#!/usr/bin/env python # # regenerate ioctl_table.h # import sys import os result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines() try: tablehfile = file( sys.argv[1]+".h", "w" ) except: tablehfile = sys.stdout try: tablecfile = file( sys.argv[1]+".cpp", "w" ) except: tablecfile = sys.stdout print >>tablehfile,""" /* * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer */ #ifndef IOCTLMAP_H #define IOCTLMAP_H #include #include typedef QIntDict IntStringMap; IntStringMap* constructIoctlMap(); #endif """ print >>tablecfile,""" /* * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer */ #include "%s" IntStringMap* constructIoctlMap() { \tIntStringMap* map = new IntStringMap(); """ % (tablehfile.name) for line in result: l = line.split() if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): print >>sys.stderr, "can't parse line: %s" % l continue #print >>tablecfile, "\tqDebug( \"adding %s = %s\" );" % ( l[2], l[1] ) print >>tablecfile, "\tmap->insert( %s, new QString(\"%s\") );" % ( l[2], l[1] ) print >>tablecfile,""" \treturn map; }; """