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# 25bfed486aSAli Bahrami# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 26cdf0c1d5Smjnelson# Use is subject to license terms. 27cdf0c1d5Smjnelson# 28cdf0c1d5Smjnelson 29*00ff2212SAndy Fiddaman# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 30*00ff2212SAndy Fiddaman 31cdf0c1d5Smjnelson# 32bfed486aSAli Bahrami# Check that source files contain a valid CDDL block 33cdf0c1d5Smjnelson# 34cdf0c1d5Smjnelson 35*00ff2212SAndy Fiddamanimport sys 36*00ff2212SAndy Fiddamanfrom onbld.Checks import CmtBlk 37cdf0c1d5Smjnelson 38bfed486aSAli Bahrami# scmtest has a test for cddlchk that depends on the variable 39bfed486aSAli Bahrami# Cddl.CmntChrs. However, that variable has been refactored into 40bfed486aSAli Bahrami# CmtBlk. The following line preserves the original interface 41bfed486aSAli Bahrami# from the Cddl module, and allows existing programs that assume 42bfed486aSAli Bahrami# Cddl.CmntChrs exists to continue working. 43bfed486aSAli Bahrami# 44bfed486aSAli BahramiCmntChrs = CmtBlk.CmntChrs 45cdf0c1d5Smjnelson 46bfed486aSAli Bahrami# The CDDL string above contains the block guards so that the text will 47bfed486aSAli Bahrami# be tested by cddlchk. However, we don't want to include the initial 48bfed486aSAli Bahrami# \n or the block guards in the text passed in. 49bfed486aSAli Bahrami# 50bfed486aSAli BahramiCDDL = CDDL.splitlines()[3:-2] 51cdf0c1d5Smjnelson 52cdf0c1d5Smjnelsondef cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr): 53bfed486aSAli Bahrami return CmtBlk.cmtblkchk(fh, 'CDDL', CDDL, filename=filename, 54bfed486aSAli Bahrami lenient=lenient, verbose=verbose, output=output) 55