xref: /illumos-gate/usr/src/tools/onbld/Checks/Cddl.py (revision 6e6545bfaed3bab9ce836ee82d1abd8f2edba89a)
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# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
30
31#
32# Check that source files contain a valid CDDL block
33#
34
35import sys
36from onbld.Checks import CmtBlk
37
38# scmtest has a test for cddlchk that depends on the variable
39# Cddl.CmntChrs. However, that variable has been refactored into
40# CmtBlk. The following line preserves the original interface
41# from the Cddl module, and allows existing programs that assume
42# Cddl.CmntChrs exists to continue working.
43#
44CmntChrs = CmtBlk.CmntChrs
45
46# The CDDL string above contains the block guards so that the text will
47# be tested by cddlchk. However, we don't want to include the initial
48# \n or the block guards in the text passed in.
49#
50CDDL = CDDL.splitlines()[3:-2]
51
52def cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr):
53	return CmtBlk.cmtblkchk(fh, 'CDDL', CDDL, filename=filename,
54				lenient=lenient, verbose=verbose, output=output)
55