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