9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander Pyhalov#!@PYTHON@
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# CDDL HEADER START
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# The contents of this file are subject to the terms of the
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# Common Development and Distribution License (the "License").
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# You may not use this file except in compliance with the License.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# or http://www.opensolaris.org/os/licensing.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# See the License for the specific language governing permissions
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# and limitations under the License.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# When distributing Covered Code, include this CDDL HEADER in each
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# If applicable, add the following below this CDDL HEADER, with the
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# fields enclosed by brackets "[]" replaced with your own identifying
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# information: Portions Copyright [yyyy] [name of copyright owner]
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# CDDL HEADER END
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# Check header files conform to ON standards.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson#
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonimport sys, os, getopt
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowesys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe "python%d.%d" % sys.version_info[:2]))
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# Allow running from the source tree, using the modules in the source tree
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowesys.path.insert(2, os.path.join(os.path.dirname(__file__), '..'))
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonfrom onbld.Checks.HdrChk import hdrchk
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsondef usage():
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson progname = os.path.split(sys.argv[0])[1]
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson msg = ['Usage: %s [-a] file [file...]\n' % progname,
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson ' -a\tApply (more lenient) application header rules\n']
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson sys.stderr.writelines(msg)
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsontry:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson opts, args = getopt.getopt(sys.argv[1:], 'a')
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonexcept getopt.GetoptError:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson usage()
e7aca7349385967a98ed221ad54db99998d477e8Richard Lowe sys.exit(2)
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonlenient = False
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonfor opt, arg in opts:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson if opt == '-a':
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson lenient = True
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonret = 0
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonfor filename in args:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson try:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson fh = open(filename, 'r')
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson except IOError, e:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson sys.stderr.write("failed to open '%s': %s\n" %
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson (e.filename, e.strerror))
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson else:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson ret |= hdrchk(fh, lenient=lenient, output=sys.stderr)
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson fh.close()
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelsonsys.exit(ret)