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