xref: /titanic_52/usr/src/tools/onbld/Checks/Cddl.py (revision bfed486ad8de8b8ebc6345a8e10accae08bf2f45)
1cdf0c1d5Smjnelson#! /usr/bin/python
2cdf0c1d5Smjnelson
3cdf0c1d5SmjnelsonCDDL = '''
4cdf0c1d5SmjnelsonCDDL HEADER START
5cdf0c1d5Smjnelson
6cdf0c1d5SmjnelsonThe contents of this file are subject to the terms of the
7cdf0c1d5SmjnelsonCommon Development and Distribution License (the "License").
8cdf0c1d5SmjnelsonYou may not use this file except in compliance with the License.
9cdf0c1d5Smjnelson
10cdf0c1d5SmjnelsonYou can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11cdf0c1d5Smjnelsonor http://www.opensolaris.org/os/licensing.
12cdf0c1d5SmjnelsonSee the License for the specific language governing permissions
13cdf0c1d5Smjnelsonand limitations under the License.
14cdf0c1d5Smjnelson
15cdf0c1d5SmjnelsonWhen distributing Covered Code, include this CDDL HEADER in each
16cdf0c1d5Smjnelsonfile and include the License file at usr/src/OPENSOLARIS.LICENSE.
17cdf0c1d5SmjnelsonIf applicable, add the following below this CDDL HEADER, with the
18cdf0c1d5Smjnelsonfields enclosed by brackets "[]" replaced with your own identifying
19cdf0c1d5Smjnelsoninformation: Portions Copyright [yyyy] [name of copyright owner]
20cdf0c1d5Smjnelson
21cdf0c1d5SmjnelsonCDDL HEADER END
22cdf0c1d5Smjnelson'''
23cdf0c1d5Smjnelson
24cdf0c1d5Smjnelson#
25*bfed486aSAli Bahrami# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
26cdf0c1d5Smjnelson# Use is subject to license terms.
27cdf0c1d5Smjnelson#
28cdf0c1d5Smjnelson
29cdf0c1d5Smjnelson#
30*bfed486aSAli Bahrami# Check that source files contain a valid CDDL block
31cdf0c1d5Smjnelson#
32cdf0c1d5Smjnelson
33*bfed486aSAli Bahramiimport sys, CmtBlk
34cdf0c1d5Smjnelson
35*bfed486aSAli Bahrami# scmtest has a test for cddlchk that depends on the variable
36*bfed486aSAli Bahrami# Cddl.CmntChrs. However, that variable has been refactored into
37*bfed486aSAli Bahrami# CmtBlk. The following line preserves the original interface
38*bfed486aSAli Bahrami# from the Cddl module, and allows existing programs that assume
39*bfed486aSAli Bahrami# Cddl.CmntChrs exists to continue working.
40*bfed486aSAli Bahrami#
41*bfed486aSAli BahramiCmntChrs = CmtBlk.CmntChrs
42cdf0c1d5Smjnelson
43*bfed486aSAli Bahrami# The CDDL string above contains the block guards so that the text will
44*bfed486aSAli Bahrami# be tested by cddlchk. However, we don't want to include the initial
45*bfed486aSAli Bahrami# \n or the block guards in the text passed in.
46*bfed486aSAli Bahrami#
47*bfed486aSAli BahramiCDDL = CDDL.splitlines()[3:-2]
48cdf0c1d5Smjnelson
49cdf0c1d5Smjnelsondef cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr):
50*bfed486aSAli Bahrami	return CmtBlk.cmtblkchk(fh, 'CDDL', CDDL, filename=filename,
51*bfed486aSAli Bahrami				lenient=lenient, verbose=verbose, output=output)
52