Server IP : 103.119.228.120 / Your IP : 3.148.106.49 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/share/perl5/Net/OSCAR/ |
Upload File : |
=pod =head1 NAME Net::OSCAR::TLV -- tied hash for OSCAR TLVs =head1 VERSION version 1.928 =head1 DESCRIPTION Keys in hashes tied to this class will be treated as numbers. This class also preserves the ordering of its keys. =cut package Net::OSCAR::TLV; BEGIN { $Net::OSCAR::TLV::VERSION = '1.928'; } $REVISION = '$Revision$'; use strict; use vars qw(@EXPORT @ISA); require Exporter; @ISA = qw(Exporter); @EXPORT = qw(tlv); # Extra arguments: an optional scalar which modifies the behavior of $self->{foo}->{bar} = "baz" # Iff foo doesn't exist, the scalar will be evaluated and assigned as the value of foo. # So, instead of having foo be {bar => "baz"} , it could be another TLV. # It will be given the key bar. sub new { my $pkg = shift; my $self = $pkg->TIEHASH(@_); } sub getorder { my $self = shift; return map { (unpack("n", $_))[0] } @{$self->{ORDER}}; } sub setorder { my $self = shift; # Anything not specified gets shoved at the end my @end = grep { my $inbud = $_; not grep { $_ eq $inbud } @_ } @{$self->{ORDER}}; @{$self->{ORDER}} = map { pack("n", 0+$_) } @_; push @{$self->{ORDER}}, @end; } sub TIEHASH { my $class = shift; my $self = { DATA => {}, ORDER => [], CURRKEY => -1, AUTOVIVIFY => shift}; return bless $self, $class; } sub FETCH { my($self, $key) = @_; $self->{DATA}->{pack("n", 0+$key)}; } sub STORE { my($self, $key, $value) = @_; my($normalkey) = pack("n", 0+$key); #print STDERR "Storing: ", Data::Dumper->Dump([$value], ["${self}->{$key}"]); if(!exists $self->{DATA}->{$normalkey}) { if( $self->{AUTOVIVIFY} and ref($value) eq "HASH" and !tied(%$value) and scalar keys %$value == 0 ) { #print STDERR "Autovivifying $key: $self->{AUTOVIVIFY}\n"; eval $self->{AUTOVIVIFY}; #print STDERR "New value: ", Data::Dumper->Dump([$self->{DATA}->{$normalkey}], ["${self}->{$key}"]); } else { #print STDERR "Not autovivifying $key.\n"; #print STDERR "No autovivify.\n" unless $self->{AUTOVIVIFY}; #printf STDERR "ref(\$value) eq %s\n", ref($value) unless ref($value) eq "HASH"; #print STDERR "tied(\%\$value)\n" unless !tied(%$value); #printf STDERR "scalar keys \%\$value == %d\n", scalar keys %$value unless scalar keys %$value == 0; } push @{$self->{ORDER}}, $normalkey; } else { #print STDERR "Not autovivifying $key: already exists\n"; } $self->{DATA}->{$normalkey} = $value; return $value; } sub DELETE { my($self, $key) = @_; my($packedkey) = pack("n", 0+$key); delete $self->{DATA}->{$packedkey}; for(my $i = 0; $i < scalar @{$self->{ORDER}}; $i++) { next unless $packedkey eq $self->{ORDER}->[$i]; splice(@{$self->{ORDER}}, $i, 1); # What if the user deletes a key while iterating? We need to correct for the new index. if($self->{CURRKEY} != -1 and $i <= $self->{CURRKEY}) { $self->{CURRKEY}--; } last; } } sub CLEAR { my $self = shift; $self->{DATA} = {}; $self->{ORDER} = []; $self->{CURRKEY} = -1; return $self; } sub EXISTS { my($self, $key) = @_; my($packedkey) = pack("n", 0+$key); return exists $self->{DATA}->{$packedkey}; } sub FIRSTKEY { $_[0]->{CURRKEY} = -1; goto &NEXTKEY; } sub NEXTKEY { my ($self) = @_; my $currkey = ++$self->{CURRKEY}; if($currkey >= scalar @{$self->{ORDER}}) { return wantarray ? () : undef; } my $packedkey = $self->{ORDER}->[$currkey]; my($key) = unpack("n", $packedkey); return wantarray ? ($key, $self->{DATA}->{$packedkey}) : $key; } sub tlv(;@) { my %tlv = (); tie %tlv, "Net::OSCAR::TLV"; while(@_) { my($key, $value) = (shift, shift); $tlv{$key} = $value; } return \%tlv; } 1;