This file is indexed.

/usr/share/perl5/XMLTV/Ask/Tk.pm is in libxmltv-perl 0.5.63-2.

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

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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# A few GUI routines for asking the user questions using the Tk library.

package XMLTV::Ask::Tk;
use strict;

# Use Log::TraceMessages if installed.
BEGIN {
    eval { require Log::TraceMessages };
    if ($@) {
	*t = sub {};
	*d = sub { '' };
    }
    else {
	*t = \&Log::TraceMessages::t;
	*d = \&Log::TraceMessages::d;
    }
}

use Tk;

my $main_window;
my $top_frame;
my $middle_frame; 
my $bottom_frame;
my $mid_bottom_frame;

# Ask a question with a free text answer.
# Parameters:
#   current module
#   question text
#   what character to show instead of the one typed
# Returns the text entered by the user.
sub ask( $$$ ) {
        shift;
        my $question = shift;
        my $show = shift;

        my $textbox;
        
        $main_window = MainWindow->new;
        
        $main_window->title("Question");
        $main_window->minsize(qw(400 250));
        $main_window->geometry('+250+150');

        $top_frame    = $main_window->Frame()->pack;
        $middle_frame = $main_window->Frame()->pack;
        $bottom_frame = $main_window->Frame()->pack(-side => 'bottom');
	
        $top_frame->Label(-height => 2)->pack;
	
        $top_frame->Label(-text => $question)->pack;

        my $ans;
        
        $bottom_frame->Button(-text    => "OK",
			  -command => sub {$ans = $textbox->get(); $main_window->destroy;},
			  -width    => 10
			 )->pack(-padx => 2, -pady => 4);
        
        if (defined $show) {
            $textbox = $middle_frame->Entry(-show => $show)->pack();
        }
        else {
            $textbox = $middle_frame->Entry()->pack();
        }
        MainLoop();
	
        return $ans;
}

# Ask a question with a password answer.
# Parameters:
#   current module
#   question text
# Returns the text entered by the user.
sub ask_password( $$ ) { ask($_[0], $_[1], "*") }


# Ask a question where the answer is one of a set of alternatives.
#
# Parameters:
#   current module
#   question text
#   default choice
#   Remaining arguments are the choices available.
#
# Returns one of the choices, or undef if input could not be read.
#
sub ask_choice( $$$@ ) {
        shift;
        my $question = shift; die if not defined $question;
        my $default = shift; die if not defined $default;
        my @options = @_; die if not @options;
        t "asking question $question, default $default";
        warn "default $default not in options"
        if not grep { $_ eq $default } @options;
        return _ask_choices( $question, $default, 0, @options );
}

# Ask a yes/no question.
#
# Parameters:
#   current module
#   question text
#   default (true or false)
#
# Returns true or false, or undef if input could not be read.
#
sub ask_boolean( $$$ ) {
        shift;
        my ($text, $default) = @_;	
        t "asking question $text, default $default";
	
        $main_window = MainWindow->new;

        $main_window->title('Question');
        $main_window->minsize(qw(400 250));
        $main_window->geometry('+250+150');

        $top_frame    = $main_window->Frame()->pack;
        $middle_frame = $main_window->Frame()->pack;
        $bottom_frame = $main_window->Frame()->pack(-side => 'bottom');
	
        $top_frame->Label(-height => 2)->pack;
        $top_frame->Label(-text => $text)->pack;
	
        my $ans = 0;
  
        $bottom_frame->Button(-text    => "Yes",
			  -command => sub { $ans = 1; $main_window->destroy; },
			  -width => 10,
			 )->pack(-side => 'left', -padx => 2, -pady => 4);
	
        $bottom_frame->Button(-text    => "No",
			  -command => sub { $ans = 0; $main_window->destroy; },
			  -width => 10
			 )->pack(-side => 'left', -padx => 2, -pady => 4);
	
        MainLoop();

        return $ans;
}

# Ask yes/no questions with option 'default to all'.
#
# Parameters:
#   current module
#   default (true or false),
#   question texts (one per question).
#
# Returns: lots of booleans, one for each question.  If input cannot
# be read, then a partial list is returned.
#
sub ask_many_boolean( $$@ ) {
        shift;
        my $default=shift;
        my @options = @_;
        return _ask_choices('', $default, 1, @options);
}

# A helper routine used to create the listbox for both
# ask_choice and ask_many_boolean
sub _ask_choices( $$$@ ) {
        my $question=shift;
        my $default=shift;
        my $allowedMany=shift;
        my @options = @_;

        return if not @options;
	
        my $select_all_button;
        my $select_none_button;

        my $listbox;
        my $i;
	
        $main_window = MainWindow->new;

        $main_window->title('Question');
        $main_window->minsize(qw( 400 250 ));
        $main_window->geometry('+250+150');

        $top_frame    = $main_window->Frame()->pack;
        $middle_frame = $main_window->Frame()->pack(-fill => 'both');
	
        $top_frame->Label(-height => 2)->pack;

        $top_frame->Label(-text => $question)->pack;

        $listbox = $middle_frame->ScrlListbox();

        $listbox->insert(0, @options);
	
        if ($allowedMany) {
                $listbox->configure( -selectmode => 'multiple' );
		
                if ($default) {
                        $listbox->selectionSet( 0, 'end' );
                }
		
                $mid_bottom_frame = $main_window->Frame()->pack();
	
	        $select_all_button = $mid_bottom_frame->Button
                        (-text => 'Select All',
                        -command => sub { $listbox->selectionSet(0, 1000) },
                        -width => 10,
                        )->pack(-side => 'left');
	
	        $select_none_button = $mid_bottom_frame->Button
                        (-text => 'Select None',
                        -command => sub { $listbox->selectionClear(0, 1000) },
                        -width => 10,
                        )-> pack(-side => 'right');
        }
        else {
                $listbox->configure(-selectmode => 'single');
                $listbox->selectionSet(_index_array($default, @options));
        }
	
        $listbox->pack(-fill => 'x', -padx => '5', -pady => '2');
	
        $bottom_frame = $main_window->Frame()->pack(-side => 'bottom');
	
        my @cursel;
  
        $bottom_frame->Button(-text    => 'OK',
			  -command => sub { @cursel = $listbox->curselection; $main_window->destroy; },
			  -width    => 10,
			 )->pack(-padx => 2, -pady => 4);
        
        MainLoop();

        if ($allowedMany) {
                my @choices;
                my @choice_numbers = @cursel;

                $i=0;
                foreach (@options) {
                        push @choices, 0;
                        foreach( @choice_numbers ) {
                                if ($options[$_] eq $options[$i]) {
                                        $choices[$i] = 1;
                                }
                        }
                        $i++;
                }

                return @choices;	
        }
        else {
                my $ans = $options[$cursel[0]];
	              return $ans;
        }
}

# Give some information to the user
# Parameters:
#   current module
#   text to show to the user
sub say( $$ ) {
        shift;
        my $question = shift;
	
        $main_window = MainWindow->new;

        $main_window->title("Information");
        $main_window->minsize(qw(400 250));
        $main_window->geometry('+250+150');

        $top_frame    = $main_window->Frame()->pack;
        $middle_frame = $main_window->Frame()->pack;
        $bottom_frame = $main_window->Frame()->pack(-side => 'bottom');
	
        $top_frame->Label(-height => 2)->pack;
        $top_frame->Label(-text => $question)->pack;
	
        $bottom_frame->Button(-text    => "OK",
			  -command => sub { $main_window->destroy; },
			  -width    => 10,
			 )->pack(-padx => 2, -pady => 4);
	
        MainLoop();
}

# A hekper routine that returns the index in an array
# of the supplied argument
# Parameters:
#     the item to find
#     the array to find it in
# Returns the index of the item in the array, or -1 if not found
sub _index_array($@)
{
        my $s=shift;
        my @array = @_;
	
        for (my $i = 0; $i < $#array; $i++) {
                return $i if $array[$i] eq $s;
        }
	
        return -1;
}

1;