1 #!/usr/perl5/bin/perl -w
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 # mkmsg.pl -- generate message file content for strings that
28 # originate in audit_record_attr and audit_event
30 # mkmsg.pl domain po_file_name
38 %attr %event %class %skipClass %token %noteAlias);
41 use POSIX qw(locale_h);
42 use Sun
::Solaris
::Utils
qw(gettext textdomain);
43 use Sun
::Solaris
::BSM
::_BSMparse
;
45 unless ($#ARGV == 1) {
46 print STDERR
"usage: $0 domain_name file_name\n";
49 my $textDomain = $ARGV[0];
50 my $poFile = $ARGV[1];
53 setlocale
(LC_ALL
, "");
54 textdomain
($textDomain);
57 $options{'classFilter'} = ''; # don''t filter
58 $debug = 0; # debug mode on
59 $options{'eventFilter'} = ''; # don''t filter
60 $options{'idFilter'} = ''; # don''t filter
62 $parse = new Sun
::Solaris
::BSM
::_BSMparse
($debug, \
%options, './',
63 '../../lib/libbsm', '.txt');
65 my ($attr, $token, $skipClass, $noteAlias) = $parse->readAttr();
66 %class = %{$parse->readClass()};
67 %event = %{$parse->readEvent()};
71 %noteAlias = %$noteAlias;
72 %skipClass = %$skipClass;
78 foreach $label (sort keys %event) {
80 my ($id, $class, $eventDescription) = ('', '', '');
81 if (defined($event{$label})) {
82 ($id, $class, $eventDescription) = @
{$event{$label}};
83 $eventDescription =~ s/\(\w+\)//;
86 my ($name, $description, $title, $skip, @case) = ('', '', '', '', ());
87 if (defined($attr{$label})) {
88 ($name, $description, $title, $skip, @case) = @
{$attr{$label}};
89 $description = '' if ($description eq 'none');
90 $name = '' if ($name eq 'none');
91 $title = $name if (($title eq 'none') || (!defined($title)));
94 # in auditrecord.pl, _either_ $description _or_ $eventDescription
95 # is used. Both are put into the message file so that this script
96 # doesn't have logic dependent on auditrecord.pl
99 addToMsgFile
($eventDescription);
100 addToMsgFile
($description);
104 foreach $case (@case) {
105 addToMsgFile
(${$case}[0]); # description
106 # [1] # token id (a name list)
107 my @comment = split(/\s*:\s*/, ${$case}[2]);
108 my $note = ${$case}[3];
111 foreach $comment (@comment) {
112 addToMsgFile
($comment);
114 if ($noteAlias{$note}) {
115 addToMsgFile
($noteAlias{$note});
122 writeMsgFile
($textDomain, $poFile);
130 foreach $text (@text) {
131 next if ($text =~ /^$/);
132 $text =~ s/:/:/g;
133 $translateText{$text} = 1;
137 # ids in the .po file must be quoted; since the messages themselves
138 # contain quotes, quotes must be escaped
146 open(Message
, ">$file") or
147 die "Failed to open $file: $!\n";
149 print Message
"# File:audit_record_attr: textdomain(\"$domain\")\n";
150 foreach $text (sort keys %translateText) {
152 print Message
"msgid \"$text\"\nmsgstr\n";