xref: /onnv-gate/usr/src/cmd/sgs/tools/chkmsg.sh (revision 1618:8c9a4f31d225)
10Sstevel@tonic-gate#!/bin/sh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*1618Srie# Common Development and Distribution License (the "License").
7*1618Srie# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
22*1618Srie
230Sstevel@tonic-gate#
24*1618Srie# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25*1618Srie# Use is subject to license terms.
260Sstevel@tonic-gate#
27*1618Srie# ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate
290Sstevel@tonic-gateTOOLDIR="${SRC}/cmd/sgs/tools/"
300Sstevel@tonic-gate
310Sstevel@tonic-gate#
320Sstevel@tonic-gate# remove the temporary files
330Sstevel@tonic-gate#
340Sstevel@tonic-gaterm -f CATA_MSG_INTL_LIST CATA_MSG_ORIG_LIST
350Sstevel@tonic-gaterm -f MSG_INTL_LIST MSG_ORIG_LIST
360Sstevel@tonic-gate
370Sstevel@tonic-gatewhile getopts "m:" Arg
380Sstevel@tonic-gatedo
390Sstevel@tonic-gate	case $Arg in
400Sstevel@tonic-gate	m)	nawk -f ${TOOLDIR}/catalog.awk $OPTARG ;;
410Sstevel@tonic-gate	\?)	echo "usage: chkmsg -m msgfile source-files" ; exit 1 ;;
420Sstevel@tonic-gate	esac
430Sstevel@tonic-gatedone
440Sstevel@tonic-gateshift `expr $OPTIND - 1`
450Sstevel@tonic-gate
460Sstevel@tonic-gateif [ $# -eq 0 ]; then
470Sstevel@tonic-gate	echo "usage: chkmsg -m msgfile source-files"
480Sstevel@tonic-gate	exit 1
490Sstevel@tonic-gatefi
500Sstevel@tonic-gate
510Sstevel@tonic-gate#
52*1618Srie# Sort the MSG_INTL() and MSG_ORIG() entries.  Note, messages can come in _32
53*1618Srie# and _64 flavors - if so strip the suffix and uniquify the output.
540Sstevel@tonic-gate#
550Sstevel@tonic-gateif [ -s CATA_MSG_INTL_LIST ] ; then
56*1618Srie	sed -e "s/_32$//" -e "s/_64$//" CATA_MSG_INTL_LIST | sort | uniq > _TMP
570Sstevel@tonic-gate	mv _TMP CATA_MSG_INTL_LIST
580Sstevel@tonic-gatefi
590Sstevel@tonic-gateif [ -s CATA_MSG_ORIG_LIST ] ; then
60*1618Srie	sed -e "s/_32$//" -e "s/_64$//" CATA_MSG_ORIG_LIST | sort | uniq > _TMP
610Sstevel@tonic-gate	mv _TMP CATA_MSG_ORIG_LIST
620Sstevel@tonic-gatefi
630Sstevel@tonic-gate
640Sstevel@tonic-gate#
650Sstevel@tonic-gate# Generate the lists for the source files and sort them
660Sstevel@tonic-gate#
670Sstevel@tonic-gatenawk -f  ${TOOLDIR}/getmessage.awk	$*
680Sstevel@tonic-gate
690Sstevel@tonic-gateif [ -s MSG_INTL_LIST ] ; then
70*1618Srie	sed -e "s/_32$//" -e "s/_64$//" MSG_INTL_LIST | sort | uniq > _TMP
710Sstevel@tonic-gate	mv _TMP MSG_INTL_LIST
720Sstevel@tonic-gatefi
730Sstevel@tonic-gateif [ -s MSG_ORIG_LIST ] ; then
74*1618Srie	sed -e "s/_32$//" -e "s/_64$//" MSG_ORIG_LIST | sort | uniq > _TMP
750Sstevel@tonic-gate	mv _TMP MSG_ORIG_LIST
760Sstevel@tonic-gatefi
770Sstevel@tonic-gate
780Sstevel@tonic-gate#
790Sstevel@tonic-gate# Start checking
800Sstevel@tonic-gate#
810Sstevel@tonic-gateError=0
820Sstevel@tonic-gate
830Sstevel@tonic-gate#
840Sstevel@tonic-gate# Check MESG_INTL message
850Sstevel@tonic-gate#
860Sstevel@tonic-gatecomm -23 CATA_MSG_INTL_LIST MSG_INTL_LIST > _TMP 2> /dev/null
870Sstevel@tonic-gateif [ -s _TMP ]; then
880Sstevel@tonic-gate    echo
890Sstevel@tonic-gate    echo "messages exist between _START_ and _END_ but do not use MSG_INTL()"
900Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
910Sstevel@tonic-gate    Error=1
920Sstevel@tonic-gatefi
930Sstevel@tonic-gaterm -f _TMP
940Sstevel@tonic-gate
950Sstevel@tonic-gatecomm -13 CATA_MSG_INTL_LIST MSG_INTL_LIST > _TMP 2> /dev/null
960Sstevel@tonic-gateif [ -s _TMP ]; then
970Sstevel@tonic-gate    echo
980Sstevel@tonic-gate    echo "use of MSG_INTL() but messages do not exist between _START_ and _END_"
990Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1000Sstevel@tonic-gate    Error=1
1010Sstevel@tonic-gatefi
1020Sstevel@tonic-gaterm -f _TMP
1030Sstevel@tonic-gate
1040Sstevel@tonic-gate#
1050Sstevel@tonic-gate# Check MESG_ORIG message
1060Sstevel@tonic-gate#
1070Sstevel@tonic-gatecomm -23 CATA_MSG_ORIG_LIST MSG_ORIG_LIST > _TMP 2> /dev/null
1080Sstevel@tonic-gateif [ -s _TMP ]; then
1090Sstevel@tonic-gate    echo
1100Sstevel@tonic-gate    echo "messages exist after _END_ but do not use MSG_ORIG()"
1110Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1120Sstevel@tonic-gate    Error=1
1130Sstevel@tonic-gatefi
1140Sstevel@tonic-gaterm -f _TMP
1150Sstevel@tonic-gate
1160Sstevel@tonic-gatecomm -13 CATA_MSG_ORIG_LIST MSG_ORIG_LIST > _TMP 2> /dev/null
1170Sstevel@tonic-gateif [ -s _TMP ]; then
1180Sstevel@tonic-gate    echo
1190Sstevel@tonic-gate    echo "use of MSG_ORIG() but messages do not exist after _END_"
1200Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1210Sstevel@tonic-gate    Error=1
1220Sstevel@tonic-gatefi
1230Sstevel@tonic-gaterm -f _TMP
1240Sstevel@tonic-gate
1250Sstevel@tonic-gate#
1260Sstevel@tonic-gate# remove the temporary files
1270Sstevel@tonic-gate#
1280Sstevel@tonic-gaterm -f CATA_MSG_INTL_LIST CATA_MSG_ORIG_LIST
1290Sstevel@tonic-gaterm -f MSG_INTL_LIST MSG_ORIG_LIST
1300Sstevel@tonic-gate
1310Sstevel@tonic-gateexit $Error
132