xref: /titanic_50/usr/src/cmd/sgs/tools/chkmsg.sh (revision 5aefb6555731130ca4fd295960123d71f2d21fe8)
17c478bd9Sstevel@tonic-gate#!/bin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*5aefb655Srie# Common Development and Distribution License (the "License").
7*5aefb655Srie# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
22*5aefb655Srie
237c478bd9Sstevel@tonic-gate#
24*5aefb655Srie# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25*5aefb655Srie# Use is subject to license terms.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gateTOOLDIR="${SRC}/cmd/sgs/tools/"
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate#
327c478bd9Sstevel@tonic-gate# remove the temporary files
337c478bd9Sstevel@tonic-gate#
347c478bd9Sstevel@tonic-gaterm -f CATA_MSG_INTL_LIST CATA_MSG_ORIG_LIST
357c478bd9Sstevel@tonic-gaterm -f MSG_INTL_LIST MSG_ORIG_LIST
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gatewhile getopts "m:" Arg
387c478bd9Sstevel@tonic-gatedo
397c478bd9Sstevel@tonic-gate	case $Arg in
407c478bd9Sstevel@tonic-gate	m)	nawk -f ${TOOLDIR}/catalog.awk $OPTARG ;;
417c478bd9Sstevel@tonic-gate	\?)	echo "usage: chkmsg -m msgfile source-files" ; exit 1 ;;
427c478bd9Sstevel@tonic-gate	esac
437c478bd9Sstevel@tonic-gatedone
447c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1`
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gateif [ $# -eq 0 ]; then
477c478bd9Sstevel@tonic-gate	echo "usage: chkmsg -m msgfile source-files"
487c478bd9Sstevel@tonic-gate	exit 1
497c478bd9Sstevel@tonic-gatefi
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate#
52*5aefb655Srie# Sort the MSG_INTL() and MSG_ORIG() entries.  Note, messages can come in _32
53*5aefb655Srie# and _64 flavors - if so strip the suffix and uniquify the output.
547c478bd9Sstevel@tonic-gate#
557c478bd9Sstevel@tonic-gateif [ -s CATA_MSG_INTL_LIST ] ; then
56*5aefb655Srie	sed -e "s/_32$//" -e "s/_64$//" CATA_MSG_INTL_LIST | sort | uniq > _TMP
577c478bd9Sstevel@tonic-gate	mv _TMP CATA_MSG_INTL_LIST
587c478bd9Sstevel@tonic-gatefi
597c478bd9Sstevel@tonic-gateif [ -s CATA_MSG_ORIG_LIST ] ; then
60*5aefb655Srie	sed -e "s/_32$//" -e "s/_64$//" CATA_MSG_ORIG_LIST | sort | uniq > _TMP
617c478bd9Sstevel@tonic-gate	mv _TMP CATA_MSG_ORIG_LIST
627c478bd9Sstevel@tonic-gatefi
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate#
657c478bd9Sstevel@tonic-gate# Generate the lists for the source files and sort them
667c478bd9Sstevel@tonic-gate#
677c478bd9Sstevel@tonic-gatenawk -f  ${TOOLDIR}/getmessage.awk	$*
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gateif [ -s MSG_INTL_LIST ] ; then
70*5aefb655Srie	sed -e "s/_32$//" -e "s/_64$//" MSG_INTL_LIST | sort | uniq > _TMP
717c478bd9Sstevel@tonic-gate	mv _TMP MSG_INTL_LIST
727c478bd9Sstevel@tonic-gatefi
737c478bd9Sstevel@tonic-gateif [ -s MSG_ORIG_LIST ] ; then
74*5aefb655Srie	sed -e "s/_32$//" -e "s/_64$//" MSG_ORIG_LIST | sort | uniq > _TMP
757c478bd9Sstevel@tonic-gate	mv _TMP MSG_ORIG_LIST
767c478bd9Sstevel@tonic-gatefi
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate#
797c478bd9Sstevel@tonic-gate# Start checking
807c478bd9Sstevel@tonic-gate#
817c478bd9Sstevel@tonic-gateError=0
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate#
847c478bd9Sstevel@tonic-gate# Check MESG_INTL message
857c478bd9Sstevel@tonic-gate#
867c478bd9Sstevel@tonic-gatecomm -23 CATA_MSG_INTL_LIST MSG_INTL_LIST > _TMP 2> /dev/null
877c478bd9Sstevel@tonic-gateif [ -s _TMP ]; then
887c478bd9Sstevel@tonic-gate    echo
897c478bd9Sstevel@tonic-gate    echo "messages exist between _START_ and _END_ but do not use MSG_INTL()"
907c478bd9Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
917c478bd9Sstevel@tonic-gate    Error=1
927c478bd9Sstevel@tonic-gatefi
937c478bd9Sstevel@tonic-gaterm -f _TMP
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gatecomm -13 CATA_MSG_INTL_LIST MSG_INTL_LIST > _TMP 2> /dev/null
967c478bd9Sstevel@tonic-gateif [ -s _TMP ]; then
977c478bd9Sstevel@tonic-gate    echo
987c478bd9Sstevel@tonic-gate    echo "use of MSG_INTL() but messages do not exist between _START_ and _END_"
997c478bd9Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1007c478bd9Sstevel@tonic-gate    Error=1
1017c478bd9Sstevel@tonic-gatefi
1027c478bd9Sstevel@tonic-gaterm -f _TMP
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate#
1057c478bd9Sstevel@tonic-gate# Check MESG_ORIG message
1067c478bd9Sstevel@tonic-gate#
1077c478bd9Sstevel@tonic-gatecomm -23 CATA_MSG_ORIG_LIST MSG_ORIG_LIST > _TMP 2> /dev/null
1087c478bd9Sstevel@tonic-gateif [ -s _TMP ]; then
1097c478bd9Sstevel@tonic-gate    echo
1107c478bd9Sstevel@tonic-gate    echo "messages exist after _END_ but do not use MSG_ORIG()"
1117c478bd9Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1127c478bd9Sstevel@tonic-gate    Error=1
1137c478bd9Sstevel@tonic-gatefi
1147c478bd9Sstevel@tonic-gaterm -f _TMP
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gatecomm -13 CATA_MSG_ORIG_LIST MSG_ORIG_LIST > _TMP 2> /dev/null
1177c478bd9Sstevel@tonic-gateif [ -s _TMP ]; then
1187c478bd9Sstevel@tonic-gate    echo
1197c478bd9Sstevel@tonic-gate    echo "use of MSG_ORIG() but messages do not exist after _END_"
1207c478bd9Sstevel@tonic-gate    cat _TMP | sed "s/^/	/"
1217c478bd9Sstevel@tonic-gate    Error=1
1227c478bd9Sstevel@tonic-gatefi
1237c478bd9Sstevel@tonic-gaterm -f _TMP
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate#
1267c478bd9Sstevel@tonic-gate# remove the temporary files
1277c478bd9Sstevel@tonic-gate#
1287c478bd9Sstevel@tonic-gaterm -f CATA_MSG_INTL_LIST CATA_MSG_ORIG_LIST
1297c478bd9Sstevel@tonic-gaterm -f MSG_INTL_LIST MSG_ORIG_LIST
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gateexit $Error
132