This file is indexed.

/usr/share/perl5/Net/XMPP/Debug.pm is in libnet-xmpp-perl 1.02-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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
##############################################################################
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Library General Public License for more details.
#
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the
#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA  02111-1307, USA.
#
#  Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/
#
##############################################################################

package Net::XMPP::Debug;

=head1 NAME

Net::XMPP::Debug - XMPP Debug Module

=head1 SYNOPSIS

  Net::XMPP::Debug is a module that provides a developer easy access
  to logging debug information.

=head1 DESCRIPTION

  Debug is a helper module for the Net::XMPP modules.  It provides
  the Net::XMPP modules with an object to control where, how, and
  what is logged.

=head2 Basic Functions

    $Debug = new Net::XMPP::Debug();

    $Debug->Init(level=>2,
	             file=>"stdout",
  	             header=>"MyScript");

    $Debug->Log0("Connection established");

=head1 METHODS

=head2 Basic Functions

    new(hash) - creates the Debug object.  The hash argument is passed
                to the Init function.  See that function description
                below for the valid settings.

    Init(level=>integer,  - initializes the debug object.  The level
         file=>string,      determines the maximum level of debug
         header=>string,    messages to log:
         setdefault=>0|1,     0 - Base level Output (default)
         usedefault=>0|1,     1 - High level API calls
         time=>0|1)           2 - Low level API calls
                              ...
                              N - Whatever you want....
                            The file determines where the debug log
                            goes.  You can either specify a path to
                            a file, or "stdout" (the default).  "stdout"
                            tells Debug to send all of the debug info
                            sent to this object to go to stdout.
                            header is a string that will preappended
                            to the beginning of all log entries.  This
                            makes it easier to see what generated the
                            log entry (default is "Debug").
                            setdefault saves the current filehandle
                            and makes it available for other Debug
                            objects to use.  To use the default set
                            usedefault to 1.  The time parameter
                            specifies whether or not to add a timestamp
                            to the beginning of each logged line.

    LogN(array) - Logs the elements of the array at the corresponding
                  debug level N.  If you pass in a reference to an
                  array or hash then they are printed in a readable
                  way.  (ie... Log0, Log2, Log100, etc...)

=head1 EXAMPLE

  $Debug = new Net::XMPP:Debug(level=>2,
                               header=>"Example");

    $Debug->Log0("test");

    $Debug->Log2("level 2 test");

    $hash{a} = "atest";
    $hash{b} = "btest";

    $Debug->Log1("hashtest",\%hash);

  You would get the following log:

    Example: test
    Example: level 2 test
    Example: hashtest { a=>"atest" b=>"btest" }

  If you had set the level to 1 instead of 2 you would get:

    Example: test
    Example: hashtest { a=>"atest" b=>"btest" }

=head1 AUTHOR

Ryan Eatmon

=head1 COPYRIGHT

This module is free software, you can redistribute it and/or modify it
under the LGPL.

=cut

require 5.003;
use strict;
use FileHandle;
use Carp;
use vars qw( %HANDLES $DEFAULT $DEFAULTLEVEL $DEFAULTTIME $AUTOLOAD );

$DEFAULTLEVEL = -1;

sub new
{
    my $proto = shift;
    my $self = { };
    bless($self, $proto);

    $self->Init(@_);

    return $self;
}


##############################################################################
#
# Init - opens the fielhandle and initializes the Debug object.
#
##############################################################################
sub Init
{
    my $self = shift;

    my %args;
    while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }

    delete($args{file}) if (lc($args{file}) eq "stdout");

    $args{time} = 0 if !exists($args{time});
    $args{setdefault} = 0 if !exists($args{setdefault});
    $args{usedefault} = 0 if !exists($args{usedefault});

    $self->{TIME} = $args{time};

    if ($args{usedefault} == 1)
    {
        $args{setdefault} = 0;
        $self->{USEDEFAULT} = 1;
    }
    else
    {
        $self->{LEVEL} = 0;
        $self->{LEVEL} = $args{level} if exists($args{level});

        $self->{HANDLE} = new FileHandle(">&STDERR");
        $self->{HANDLE}->autoflush(1);
        if (exists($args{file}))
        {
            if (exists($Net::XMPP::Debug::HANDLES{$args{file}}))
            {
                $self->{HANDLE} = $Net::XMPP::Debug::HANDLES{$args{file}};
                $self->{HANDLE}->autoflush(1);
            }
            else
            {
                if (-e $args{file})
                {
                    if (-w $args{file})
                    {
                        $self->{HANDLE} = new FileHandle(">$args{file}");
                        if (defined($self->{HANDLE}))
                        {
                            $self->{HANDLE}->autoflush(1);
                            $Net::XMPP::Debug::HANDLES{$args{file}} = $self->{HANDLE};
                        }
                        else
                        {
                            print STDERR "ERROR: Debug filehandle could not be opened.\n";
                            print STDERR"        Debugging disabled.\n";
                            print STDERR "       ($!)\n";
                            $self->{LEVEL} = -1;
                        }
                    }
                    else
                    {
                        print STDERR "ERROR: You do not have permission to write to $args{file}.\n";
                        print STDERR"        Debugging disabled.\n";
                        $self->{LEVEL} = -1;
                    }
                }
                else
                {
                    $self->{HANDLE} = new FileHandle(">$args{file}");
                    if (defined($self->{HANDLE}))
                    {
                        $self->{HANDLE}->autoflush(1);
                        $Net::XMPP::Debug::HANDLES{$args{file}} = $self->{HANDLE};
                    }
                    else
                    {
                        print STDERR "ERROR: Debug filehandle could not be opened.\n";
                        print STDERR"        Debugging disabled.\n";
                        print STDERR "       ($!)\n";
                        $self->{LEVEL} = -1;
                    }
                }
            }
        }
    }
    if ($args{setdefault} == 1)
    {
        $Net::XMPP::Debug::DEFAULT = $self->{HANDLE};
        $Net::XMPP::Debug::DEFAULTLEVEL = $self->{LEVEL};
        $Net::XMPP::Debug::DEFAULTTIME = $self->{TIME};
    }

    $self->{HEADER} = "Debug";
    $self->{HEADER} = $args{header} if exists($args{header});
}


##############################################################################
#
# Log - takes the limit and the array to log and logs them
#
##############################################################################
sub Log
{
    my $self = shift;
    my (@args) = @_;

    my $fh = $self->{HANDLE};
    $fh = $Net::XMPP::Debug::DEFAULT if exists($self->{USEDEFAULT});

    my $string = "";

    my $testTime = $self->{TIME};
    $testTime = $Net::XMPP::Debug::DEFAULTTIME if exists($self->{USEDEFAULT});

    $string .= "[".&Net::XMPP::GetTimeStamp("local",time,"short")."] "
        if ($testTime == 1);
    $string .= $self->{HEADER}.": ";

    my $arg;

    foreach $arg (@args)
    {
        if (ref($arg) eq "HASH")
        {
            $string .= " {";
            my $key;
            foreach $key (sort {$a cmp $b} keys(%{$arg}))
            {
                $string .= " ".$key."=>'".$arg->{$key}."'";
            }
            $string .= " }";
        }
        else
        {
            if (ref($arg) eq "ARRAY")
            {
                $string .= " [ ".join(" ",@{$arg})." ]";
            }  else {
                $string .= $arg;
            }
        }
    }
    print $fh "$string\n";
    return 1;
}


##############################################################################
#
# AUTOLOAD - if a function is called that is not defined then this function
#            will examine the function name and either give an error or call
#            the appropriate function.
#
##############################################################################
sub AUTOLOAD
{
    my $self = shift;
    return if ($AUTOLOAD =~ /::DESTROY$/);
    my ($function) = ($AUTOLOAD =~ /\:\:(.*)$/);
    croak("$function not defined") if !($function =~ /Log\d+/);
    my ($level) = ($function =~ /Log(\d+)/);
    return 0 if ($level > (exists($self->{USEDEFAULT}) ? $Net::XMPP::Debug::DEFAULTLEVEL : $self->{LEVEL}));
    $self->Log(@_);
}


##############################################################################
#
# GetHandle - returns the filehandle being used by this object.
#
##############################################################################
sub GetHandle
{
    my $self = shift;
    return $self->{HANDLE};
}


##############################################################################
#
# GetLevel - returns the debug level used by this object.
#
##############################################################################
sub GetLevel
{
    my $self = shift;
    return $self->{LEVEL};
}


##############################################################################
#
# GetTime - returns the debug time used by this object.
#
##############################################################################
sub GetTime
{
    my $self = shift;
    return $self->{TIME};
}


1;