1#! /usr/bin/python2.4 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Check header files conform to ON standards. 30# 31 32import sys, os, getopt 33 34sys.path.append(os.path.join(os.path.dirname(__file__), '../lib/python')) 35sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 36 37from onbld.Checks.HdrChk import hdrchk 38 39def usage(): 40 progname = os.path.split(sys.argv[0])[1] 41 msg = ['Usage: %s [-a] file [file...]\n' % progname, 42 ' -a\tApply (more lenient) application header rules\n'] 43 sys.stderr.writelines(msg) 44 45 46try: 47 opts, args = getopt.getopt(sys.argv[1:], 'a') 48except getopt.GetoptError: 49 usage() 50 sys.exit(2) 51 52lenient = False 53for opt, arg in opts: 54 if opt == '-a': 55 lenient = True 56 57ret = 0 58for filename in args: 59 try: 60 fh = open(filename, 'r') 61 except IOError, e: 62 sys.stderr.write("failed to open '%s': %s\n" % 63 (e.filename, e.strerror)) 64 else: 65 ret |= hdrchk(fh, lenient=lenient, output=sys.stderr) 66 fh.close() 67sys.exit(ret) 68