xref: /aoo42x/main/sysui/desktop/macosx/list_icons.pl (revision 7e90fac2)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#**************************************************************
6#
7#  Licensed to the Apache Software Foundation (ASF) under one
8#  or more contributor license agreements.  See the NOTICE file
9#  distributed with this work for additional information
10#  regarding copyright ownership.  The ASF licenses this file
11#  to you under the Apache License, Version 2.0 (the
12#  "License"); you may not use this file except in compliance
13#  with the License.  You may obtain a copy of the License at
14#
15#    http://www.apache.org/licenses/LICENSE-2.0
16#
17#  Unless required by applicable law or agreed to in writing,
18#  software distributed under the License is distributed on an
19#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20#  KIND, either express or implied.  See the License for the
21#  specific language governing permissions and limitations
22#  under the License.
23#
24#**************************************************************
25
26
27
28use warnings;
29use strict 'vars';
30
31# package all .icns if XML::Parser module is not installed
32eval 'use XML::Parser;'; if ( $@ ) { print '*.icns'; exit 0; };
33
34my $valuetype = "none";
35my $key = "none";
36
37#
38# XML handlers
39#
40
41sub start_handler {
42  my ($parser,$element,%attributes) = @_;
43  $valuetype = "$element";
44}
45
46sub char_handler {
47  my ($parser,$string) = @_;
48  if ( $key eq "CFBundleTypeIconFile" || $key eq "CFBundleIconFile" ) {
49    $string =~ s/^\s+//;
50    $string =~ s/\s+$//;
51    print "$string " if length($string) > 0;
52  }
53  $key = "$string" if $valuetype eq "key";
54}
55
56sub default_handler {
57  my ($parser,$string) = @_;
58}
59
60sub end_handler {
61  my ($parser,$element) = @_;
62
63  $key = "none" if $valuetype ne "key";
64  $valuetype = "none";
65}
66
67#
68# main
69#
70
71my $parser = new XML::Parser(ErrorContext => 2,
72                             Namespaces => 1);
73
74$parser->setHandlers( Start => \&start_handler,
75                      End => \&end_handler,
76                      Char => \&char_handler,
77                      Default => \&default_handler);
78$parser->parse(STDIN);
79
80print "\n";
81