This file is indexed.

/usr/share/doc/libmp3-info-perl/examples/mp3tag is in libmp3-info-perl 1.24-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/perl -sw-
#-----------------------------------------------------------------#
#  mp3tag.plx
#  pudge
#  
#
#  Created:       Chris Nandor (pudge@pobox.com)       22 Sep 1998
#  Last Modified: Chris Nandor (pudge@pobox.com)       30 Apr 1999
#-----------------------------------------------------------------#
# For obvious reasons, this script works only under MacPerl.
#-----------------------------------------------------------------#
use strict;
use MP3::Info;
use Mac::GetFile;
use Mac::Events;
#-----------------------------------------------------------------#
unless (@ARGV) {
    unless ($ARGV[0] = Mac::GetFile::get_file(
      'Get MP3 Audio File', 0, [qw(MPEG MPG3 SwaT)])) {
        MacPerl::Answer('No file selected.');
        exit;
    }
}

foreach my $file (@ARGV) {
    my($sdlg, $dlg, $win, $tag);
    $sdlg = MyDialog->new();
    $sdlg->start();
    $win = $sdlg->{WIN} = MyWindow->new();
    $tag = $sdlg->{TAG} = get_mp3tag($file) || {};
    $dlg = $sdlg->{DLG} = $sdlg->set_dialog($file);
    $sdlg->dlg_setup();

    while ($dlg->window()) {
        if (defined($win->{WIN})) {
            $win->check_value($dlg);
        }
        WaitNextEvent();
    }

    $win->{WIN}->dispose() if defined($win->{WIN});

    if ($tag->{_dialog_finished}) {
        set_mp3tag($file, $tag);
    }
}
#=================================================================#
package MyWindow;
use Mac::Dialogs;
use Mac::Events;
use Mac::Fonts;
use Mac::Lists;
use Mac::QuickDraw;
use Mac::Windows;
#-----------------------------------------------------------------#
sub new {bless {}, __PACKAGE__}
#-----------------------------------------------------------------#
sub DESTROY {
    my($ref) = @_;
    $ref->{WIN}->dispose() if defined($ref->{WIN});
}
#-----------------------------------------------------------------#
sub set_genre_window {
    my($self, $ref, @genres, $win, $list) = @_;
    @genres = sort @MP3::Info::mp3_genres;

    $win = $self->{WIN};
    $list = $self->{LIST};

    if ($win && $win->window()) {
        SendBehind($ref->{DLG}->window());
        return;
    }

    $win = MacWindow->new(
        Rect->new(500, 50, 650, 350), 'Genres', 1, floatProc(), 1
    );
    $win->sethook(redraw => sub {});
    SetPort($win->window);
    TextFont(3);
    TextSize(9);
    $list = $win->new_list(
        Rect->new(0, 0, 134, 300),
        Rect->new(0, 0, 1, scalar @genres),
        Point->new(0, 0), 0, 1, 1
    );

    $list->sethook(hit=>sub{SendBehind($win->window())});
    $list->sethook(key=>sub{
        my($mod) = $Mac::Events::CurrentEvent->modifiers();
        if ($_[2] == ord("\n")) {
            SendBehind($win->window());
            return;
        } elsif ($_[2] == ord('w') && (($mod & cmdKey()) == cmdKey())) {
            $win->dispose();
            return 1;
        }
        return;
    });

    for (my $c = 0; $c <= $#genres; $c++) {
        $list->set(0, $c, $genres[$c]);
    }

    $self->{WIN} = $win;
    $self->{LIST} = $list;
}
#-----------------------------------------------------------------#
sub check_value {
    my($ref, $dlg, $win, $list, $x, $y) = @_;
    $win = $ref->{WIN};
    $list = $ref->{LIST};
    return if ! defined $list->{'list'};
    $y = LGetSelect(1, Point->new(0,1), $list->{'list'});
    $x = $list->get($y) if defined $y;
    return if ref($x);
    if (defined($x) &&
        (!exists($list->{'_selectdata'}) || $x ne $list->{'_selectdata'})) {
        SetDialogItemText($dlg->window, 15, $list->{'_selectdata'} = $x);
    }
}
#=================================================================#
package MyDialog;
use File::Basename;
use Mac::Dialogs;
use Mac::Events;
use Mac::Fonts;
use Mac::QuickDraw;
use Mac::Menus;
use Mac::Windows;
#-----------------------------------------------------------------#
sub new {bless {}, __PACKAGE__}
#-----------------------------------------------------------------#
sub start {
    my($ref) = @_;
    $ref->do_menus();
}
#-----------------------------------------------------------------#
sub do_menus {
    my($ref, $bar) = @_;
    $ref->{_oldmenu} = GetMenuBar();
    DeleteMenu(130);
    DrawMenuBar();
}
#-----------------------------------------------------------------#
sub DESTROY {
    my($ref) = @_;
    $ref->{DLG}->dispose() if $ref->{DLG};
    SetDialogFont(systemFont());
    $ref->{_editmenu}->dipose() if $ref->{_editmenu};
    SetMenuBar($ref->{_oldmenu}) if $ref->{_oldmenu};
}
#-----------------------------------------------------------------#
sub dlg_setup {
    my($ref, $self) = @_;
    $self = $ref->{DLG};
    $self->sethook(key => sub{_dlg_handle_keys($ref, @_)});
    SetDialogCancelItem ($self->window(), 1);
    SetDialogDefaultItem($self->window(), 2);
    $self->item_hit(1  => \&dlg_cancel);
    $self->item_hit(2  => sub{dlg_ok($self, $ref->{TAG})});
    $self->item_hit(16 => sub{$ref->{WIN}->set_genre_window($ref)});
}
#-----------------------------------------------------------------#
sub _dlg_handle_keys {
    my($ref, $self, $v) = @_;
    my($mod) = $Mac::Events::CurrentEvent->modifiers();
    _dlg_key_handlers($ref, $self, $v, $mod) ? 1 : $self->_dialogselect($v);
}
#-----------------------------------------------------------------#
sub _dlg_key_handlers {
    my($ref, $self, $v, $mod) = @_;

    if (($mod & cmdKey()) == cmdKey()) {
        if ($v == ord('.')) {
            exit;
        } elsif ($v == ord('w')) {
            $self->dispose();
            return 1;
        } elsif ($v == ord('c')) {
            DialogCopy($self->window);
            return 1;
        } elsif ($v == ord('v')) {
            DialogPaste($self->window);
            return 1;
        } elsif ($v == ord('x')) {
            DialogCut($self->window);
            return 1;
        } elsif ($v == ord('a')) {
            SelectDialogItemText($self->window, $self->window->editField() + 1);
            return 1;
        } elsif ($v == ord('g')) {
            $ref->{WIN}->set_genre_window($ref);
            return 1;
        }
    }
    return 0;
}
#-----------------------------------------------------------------#
sub dlg_ok {
    my($self, $tag) = @_;
    my(%dlgs) = (
        TITLE => 5, ARTIST => 7, ALBUM => 9,
        COMMENT => 11, YEAR => 13, GENRE => 17,
        TRACKNUM => 15
    );
    foreach (keys %dlgs) {
        $tag->{$_} = GetDialogItemText($self->window(), $dlgs{$_});
    }
    $tag->{_dialog_finished} = 1;
    $self->dispose();
}
#-----------------------------------------------------------------#
sub dlg_cancel {
    my($self) = @_;
    $self->dispose();
}
#-----------------------------------------------------------------#
sub r ($$$$) {Rect->new(@_)}
#-----------------------------------------------------------------#
sub set_dialog {
    my($ref, $file, $tag) = @_;
    $tag = $ref->{TAG};
    SetDialogFont(geneva());
    MacDialog->new(
      r(50, 50, 460, 300),
      'Set MP3 Values', 1, movableDBoxProc(), 0,

      [kButtonDialogItem,     r(220, 220, 300, 240), 'Cancel'           ],
      [kButtonDialogItem,     r(310, 220, 390, 240), 'OK'               ],

      [kStaticTextDialogItem, r( 10,  10, 390,  25), basename($file)    ],

      [kStaticTextDialogItem, r( 10,  40,  70,  55), 'Title'            ],
      [kEditTextDialogItem,   r( 80,  40, 390,  55), $$tag{TITLE}||''   ],

      [kStaticTextDialogItem, r( 10,  70,  70,  85), 'Artist'           ],
      [kEditTextDialogItem,   r( 80,  70, 390,  85), $$tag{ARTIST}||''  ],

      [kStaticTextDialogItem, r( 10, 100,  70, 115), 'Album'            ],
      [kEditTextDialogItem,   r( 80, 100, 390, 115), $$tag{ALBUM}||''   ],

      [kStaticTextDialogItem, r( 10, 130,  70, 145), 'Comment'          ],
      [kEditTextDialogItem,   r( 80, 130, 390, 145), $$tag{COMMENT}||'' ],

      [kStaticTextDialogItem, r( 10, 160,  70, 175), 'Year'             ],
      [kEditTextDialogItem,   r( 80, 160, 120, 175), $$tag{YEAR}||''    ],

      [kStaticTextDialogItem, r(130, 160, 190, 175), 'Track #'          ],
      [kEditTextDialogItem,   r(200, 160, 240, 175), $$tag{TRACKNUM}||''],

      [kStaticTextDialogItem, r( 10, 190,  70, 205), 'Genre'            ],
      [kEditTextDialogItem,   r( 80, 190, 390, 205), $$tag{GENRE}||''   ],

      [kButtonDialogItem,     r(130, 220, 210, 240), 'Genres'           ],
    );
}
#-----------------------------------------------------------------#
__END__