xref: /titanic_50/usr/src/cmd/sgs/tools/catalog.awk (revision 49f9b365248ee858ee91baa36eab27c5200f6dca)
1#
2# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3# Use is subject to license terms.
4#
5# CDDL HEADER START
6#
7# The contents of this file are subject to the terms of the
8# Common Development and Distribution License, Version 1.0 only
9# (the "License").  You may not use this file except in compliance
10# with the License.
11#
12# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13# or http://www.opensolaris.org/os/licensing.
14# See the License for the specific language governing permissions
15# and limitations under the License.
16#
17# When distributing Covered Code, include this CDDL HEADER in each
18# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19# If applicable, add the following below this CDDL HEADER, with the
20# fields enclosed by brackets "[]" replaced with your own identifying
21# information: Portions Copyright [yyyy] [name of copyright owner]
22#
23# CDDL HEADER END
24#
25#ident	"%Z%%M%	%I%	%E% SMI"
26
27#
28# Extract MACROs from .msg file
29# The MACROs which are referenced by MSG_INTL() go to CATA_MSG_INTL_LIST
30# The MACROs which are referenced by MSG_ORIG() go to CATA_MSG_ORIG_LIST
31#
32
33BEGIN {
34	# skip == 0
35	#	The MACRO will not be recorded
36	skip = 0
37
38	# which == 0
39	#	Collecting MACRO's in between _START_ and _END_
40	# which == 1
41	#	Collecting MACRO's in after _END_
42	which = 0
43}
44
45#
46# If the MACROs are surrounded by _CHKMSG_SKIP_BEGIN_ and
47# _CHKMSG_SKIP_END_, these MACRO will not be recorded for checking.
48# It is assumed that the use of MACRO are checked by developers.
49#
50/_CHKMSG_SKIP_BEGIN_/ {
51	if ($3 == mach)
52		skip = 1
53}
54/_CHKMSG_SKIP_END_/ {
55	if ($3 == mach)
56		skip = 0
57}
58
59/^@/ {
60	dontprint = 0
61
62	if ($2 == "_START_") {
63		which = 0
64		dontprint = 1
65	} else if ($2 == "_END_") {
66		which = 1
67		dontprint = 1
68	} else if (match($2, "MSG_ID_") != 0) {
69		dontprint = 1
70	}
71
72	if (skip == 1 || dontprint == 1)
73		next
74
75	if (which == 0)
76		print $2 >> "CATA_MSG_INTL_LIST"
77	else
78		print $2 >> "CATA_MSG_ORIG_LIST"
79}
80