hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
163 values
lang
stringclasses
53 values
max_stars_repo_path
stringlengths
3
945
max_stars_repo_name
stringlengths
4
112
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
945
max_issues_repo_name
stringlengths
4
113
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
945
max_forks_repo_name
stringlengths
4
113
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
3
1.05M
avg_line_length
float64
1
966k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
73e857644abe05d9bc36d823522be81ecd67338f
22,854
pm
Perl
perl/vendor/lib/Test/Output.pm
mnikolop/Thesis_project_CyberDoc
9a37fdd5a31de24cb902ee31ef19eb992faa1665
[ "Apache-2.0" ]
4
2018-04-20T07:27:13.000Z
2021-12-21T05:19:24.000Z
perl/vendor/lib/Test/Output.pm
mnikolop/Thesis_project_CyberDoc
9a37fdd5a31de24cb902ee31ef19eb992faa1665
[ "Apache-2.0" ]
4
2021-03-10T19:10:00.000Z
2021-05-11T14:58:19.000Z
perl/vendor/lib/Test/Output.pm
mnikolop/Thesis_project_CyberDoc
9a37fdd5a31de24cb902ee31ef19eb992faa1665
[ "Apache-2.0" ]
1
2019-11-12T02:29:26.000Z
2019-11-12T02:29:26.000Z
package Test::Output; use vars qw($VERSION); use warnings; use strict; use Test::Builder; use Test::Output::Tie; use Sub::Exporter -setup => { exports => [ qw(output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike output_from stderr_from stdout_from combined_from ) ], groups => { stdout => [ qw( stdout_is stdout_isnt stdout_like stdout_unlike ) ], stderr => [ qw( stderr_is stderr_isnt stderr_like stderr_unlike ) ], output => [ qw( output_is output_isnt output_like output_unlike ) ], combined => [ qw( combined_is combined_isnt combined_like combined_unlike ) ], functions => [ qw( output_from stderr_from stdout_from combined_from ) ], tests => [ qw( output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike ) ], default => [ '-tests' ], }, }; my $Test = Test::Builder->new; =head1 NAME Test::Output - Utilities to test STDOUT and STDERR messages. =head1 VERSION Version 0.16 =cut $VERSION = '1.01'; =head1 SYNOPSIS use Test::More tests => 4; use Test::Output; sub writer { print "Write out.\n"; print STDERR "Error out.\n"; } stdout_is(\&writer,"Write out.\n",'Test STDOUT'); stderr_isnt(\&writer,"No error out.\n",'Test STDERR'); combined_is( \&writer, "Write out.\nError out.\n", 'Test STDOUT & STDERR combined' ); output_is( \&writer, "Write out.\n", "Error out.\n", 'Test STDOUT & STDERR' ); # Use bare blocks. stdout_is { print "test" } "test", "Test STDOUT"; stderr_isnt { print "bad test" } "test", "Test STDERR"; output_is { print 'STDOUT'; print STDERR 'STDERR' } "STDOUT", "STDERR", "Test output"; =head1 DESCRIPTION Test::Output provides a simple interface for testing output sent to STDOUT or STDERR. A number of different utilities are included to try and be as flexible as possible to the tester. Originally this module was designed not to have external requirements, however, the features provided by L<Sub::Exporter> over what L<Exporter> provides is just to great to pass up. Test::Output ties STDOUT and STDERR using Test::Output::Tie. =cut =head1 TESTS =cut =head2 STDOUT =over 4 =item B<stdout_is> =item B<stdout_isnt> stdout_is ( $coderef, $expected, 'description' ); stdout_is { ... } $expected, 'description'; stdout_isnt( $coderef, $expected, 'description' ); stdout_isnt { ... } $expected, 'description'; stdout_is() captures output sent to STDOUT from $coderef and compares it against $expected. The test passes if equal. stdout_isnt() passes if STDOUT is not equal to $expected. =cut sub stdout_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT is:\n$stdout\nnot:\n$expected\nas expected"); return $ok; } sub stdout_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatching:\n$expected\nnot expected"); return $ok; } =item B<stdout_like> =item B<stdout_unlike> stdout_like ( $coderef, qr/$expected/, 'description' ); stdout_like { ... } qr/$expected/, 'description'; stdout_unlike( $coderef, qr/$expected/, 'description' ); stdout_unlike { ... } qr/$expected/, 'description'; stdout_like() captures the output sent to STDOUT from $coderef and compares it to the regex in $expected. The test passes if the regex matches. stdout_unlike() passes if STDOUT does not match the regex. =back =cut sub stdout_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_like' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stdout_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_unlike' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatches:\n$expected\nnot expected"); return $ok; } =head2 STDERR =over 4 =item B<stderr_is> =item B<stderr_isnt> stderr_is ( $coderef, $expected, 'description' ); stderr_is {... } $expected, 'description'; stderr_isnt( $coderef, $expected, 'description' ); stderr_isnt {... } $expected, 'description'; stderr_is() is similar to stdout_is, except that it captures STDERR. The test passes if STDERR from $coderef equals $expected. stderr_isnt() passes if STDERR is not equal to $expected. =cut sub stderr_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR is:\n$stderr\nnot:\n$expected\nas expected"); return $ok; } sub stderr_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =item B<stderr_like> =item B<stderr_unlike> stderr_like ( $coderef, qr/$expected/, 'description' ); stderr_like { ...} qr/$expected/, 'description'; stderr_unlike( $coderef, qr/$expected/, 'description' ); stderr_unlike { ...} qr/$expected/, 'description'; stderr_like() is similar to stdout_like() except that it compares the regex $expected to STDERR captured from $codref. The test passes if the regex matches. stderr_unlike() passes if STDERR does not match the regex. =back =cut sub stderr_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_like' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stderr_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_unlike' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =head2 COMBINED OUTPUT =over 4 =item B<combined_is> =item B<combined_isnt> combined_is ( $coderef, $expected, 'description' ); combined_is {... } $expected, 'description'; combined_isnt ( $coderef, $expected, 'description' ); combined_isnt {... } $expected, 'description'; combined_is() directs STDERR to STDOUT then captures STDOUT. This is equivalent to UNIXs 2>&1. The test passes if the combined STDOUT and STDERR from $coderef equals $expected. combined_isnt() passes if combined STDOUT and STDERR are not equal to $expected. =cut sub combined_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined eq $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR are:\n$combined\nnot:\n$expected\nas expected"); return $ok; } sub combined_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined ne $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =item B<combined_like> =item B<combined_unlike> combined_like ( $coderef, qr/$expected/, 'description' ); combined_like { ...} qr/$expected/, 'description'; combined_unlike ( $coderef, qr/$expected/, 'description' ); combined_unlike { ...} qr/$expected/, 'description'; combined_like() is similar to combined_is() except that it compares a regex ($expected) to STDOUT and STDERR captured from $codref. The test passes if the regex matches. combined_unlike() passes if the combined STDOUT and STDERR does not match the regex. =back =cut sub combined_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_like' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\ndon't match:\n$expected\nas expected"); return $ok; } sub combined_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_unlike' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =head2 OUTPUT =over 4 =item B<output_is> =item B<output_isnt> output_is ( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_is {... } $expected_stdout, $expected_stderr, 'description'; output_isnt( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_isnt {... } $expected_stdout, $expected_stderr, 'description'; The output_is() function is a combination of the stdout_is() and stderr_is() functions. For example: output_is(sub {print "foo"; print STDERR "bar";},'foo','bar'); is functionally equivalent to stdout_is(sub {print "foo";},'foo') && stderr_is(sub {print STDERR "bar";'bar'); except that $coderef is only executed once. Unlike, stdout_is() and stderr_is() which ignore STDERR and STDOUT repectively, output_is() requires both STDOUT and STDERR to match in order to pass. Setting either $expected_stdout or $expected_stderr to C<undef> ignores STDOUT or STDERR respectively. output_is(sub {print "foo"; print STDERR "bar";},'foo',undef); is the same as stdout_is(sub {print "foo";},'foo') output_isnt() provides the opposite function of output_is(). It is a combination of stdout_isnt() and stderr_isnt(). output_isnt(sub {print "foo"; print STDERR "bar";},'bar','foo'); is functionally equivalent to stdout_is(sub {print "foo";},'bar') && stderr_is(sub {print STDERR "bar";'foo'); As with output_is(), setting either $expected_stdout or $expected_stderr to C<undef> ignores the output to that facility. output_isnt(sub {print "foo"; print STDERR "bar";},undef,'foo'); is the same as stderr_is(sub {print STDERR "bar";},'foo') =cut sub output_is (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } unless ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout eq $expout ); $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr eq $experr ); $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_isnt (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } if ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout ne $expout ); $diag = "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr ne $experr ); $diag = "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } else { if ( $stdout eq '' ) { $ok = 0; $diag = "STDOUT:\n$stdout\nmatching:\n\nnot expected"; } if ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n\nnot expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =item B<output_like> =item B<output_unlike> output_like ( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_like { ... } $regex_stdout, $regex_stderr, 'description'; output_unlike( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_unlike { ... } $regex_stdout, $regex_stderr, 'description'; output_like() and output_unlike() follow the same principles as output_is() and output_isnt() except they use a regular expression for matching. output_like() attempts to match $regex_stdout and $regex_stderr against STDOUT and STDERR produced by $coderef. The test passes if both match. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,qr/bar/); The above test is successful. Like output_is(), setting either $regex_stdout or $regex_stderr to C<undef> ignores the output to that facility. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,undef); is the same as stdout_like(sub {print "foo"; print STDERR "bar";},qr/foo/); output_unlike() test pass if output from $coderef doesn't match $regex_stdout and $regex_stderr. =back =cut sub output_like (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_like_STDERR' => $experr, 'output_like_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } unless ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout =~ $expout ); $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr =~ $experr ); $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_unlike (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_unlike_STDERR' => $experr, 'output_unlike_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } if ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout !~ $expout ); $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr !~ $experr ); $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =head1 EXPORTS By default, all tests are exported, however with the switch to L<Sub::Exporter> export groups are now available to better limit imports. To import tests for STDOUT: use Test::Output qw(:stdout); To import tests STDERR: use Test::Output qw(:stderr); To import just the functions: use Test::Output qw(:functions); And to import all tests: use Test::Output; The following is a list of group names and which functions are exported: =over 4 =item stdout stdout_is stdout_isnt stdout_like stdout_unlike =item stderr stderr_is stderr_isnt stderr_like stderr_unlike =item output output_is output_isnt output_like output_unlike =item combined combined_is combined_isnt combined_like combined_unlike =item tests All of the above, this is the default when no options are given. =back L<Sub::Exporter> allows for many other options, I encourage reading its documentation. =cut =head1 FUNCTIONS =cut =head2 stdout_from my $stdout = stdout_from($coderef) my $stdout = stdout_from { ... }; stdout_from() executes $coderef and captures STDOUT. =cut sub stdout_from (&) { my $test = shift; select( ( select(STDOUT), $| = 1 )[0] ); my $out = tie *STDOUT, 'Test::Output::Tie'; &$test; my $stdout = $out->read; undef $out; untie *STDOUT; return $stdout; } =head2 stderr_from my $stderr = stderr_from($coderef) my $stderr = stderr_from { ... }; stderr_from() executes $coderef and captures STDERR. =cut sub stderr_from (&) { my $test = shift; local $SIG{__WARN__} = sub { print STDERR @_ } if $] < 5.008; select( ( select(STDERR), $| = 1 )[0] ); my $err = tie *STDERR, 'Test::Output::Tie'; &$test; my $stderr = $err->read; undef $err; untie *STDERR; return $stderr; } =head2 output_from my ($stdout, $stderr) = output_from($coderef) my ($stdout, $stderr) = output_from {...}; output_from() executes $coderef one time capturing both STDOUT and STDERR. =cut sub output_from (&) { my $test = shift; select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); my $out = tie *STDOUT, 'Test::Output::Tie'; my $err = tie *STDERR, 'Test::Output::Tie'; &$test; my $stdout = $out->read; my $stderr = $err->read; undef $out; undef $err; untie *STDOUT; untie *STDERR; return ( $stdout, $stderr ); } =head2 combined_from my $combined = combined_from($coderef); my $combined = combined_from {...}; combined_from() executes $coderef one time combines STDOUT and STDERR, and captures them. combined_from() is equivalent to using 2>&1 in UNIX. =cut sub combined_from (&) { my $test = shift; select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); open( STDERR, ">&STDOUT" ); my $out = tie *STDOUT, 'Test::Output::Tie'; tie *STDERR, 'Test::Output::Tie', $out; &$test; my $combined = $out->read; undef $out; { no warnings; untie *STDOUT; untie *STDERR; } return ($combined); } sub _chkregex { my %regexs = @_; foreach my $test ( keys(%regexs) ) { next unless ( defined( $regexs{$test} ) ); my $usable_regex = $Test->maybe_regex( $regexs{$test} ); unless ( defined($usable_regex) ) { my $ok = $Test->ok( 0, $test ); $Test->diag("'$regexs{$test}' doesn't look much like a regex to me."); # unless $ok; return $ok; } } return 1; } =head1 AUTHOR Currently maintained by brian d foy, C<bdfoy@cpan.org>. Shawn Sorichetti, C<< <ssoriche@cpan.org> >> =head1 SOURCE AVAILABILITY This module is in Github: http://github.com/briandfoy/test-output/tree/master =head1 BUGS Please report any bugs or feature requests to C<bug-test-output@rt.cpan.org>, or through the web interface at L<http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 ACKNOWLEDGEMENTS Thanks to chromatic whose TieOut.pm was the basis for capturing output. Also thanks to rjbs for his help cleaning the documention, and pushing me to L<Sub::Exporter>. Thanks to David Wheeler for providing code block support and tests. Thanks to Michael G Schwern for the solution to combining STDOUT and STDERR. =head1 COPYRIGHT & LICENSE Copyright 2005-2008 Shawn Sorichetti, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Test::Output
23.249237
79
0.620767
ed35c1d004576c6422e694198bd5e18a2b60a643
2,000
pl
Perl
corpus/sts2015-en-train/perl/find_pairs.pl
pasmod/paradox
29ae67c94145a5440423419ed953d8d980091889
[ "MIT" ]
3
2016-12-06T20:36:12.000Z
2020-07-05T19:29:23.000Z
corpus/sts2015-en-train/perl/find_pairs.pl
pasmod/paradox
29ae67c94145a5440423419ed953d8d980091889
[ "MIT" ]
2
2018-08-09T02:36:23.000Z
2018-08-20T16:15:11.000Z
corpus/sts2015-en-train/perl/find_pairs.pl
pasmod/paradox
29ae67c94145a5440423419ed953d8d980091889
[ "MIT" ]
3
2018-08-08T23:28:17.000Z
2019-01-23T12:40:01.000Z
#--------------------------------------------------- # find the pairs that are in sts2015 data set #--------------------------------------------------- use strict; use warnings; die "Usage: perl find_pairs.pl input_file sts_dir output_file\n" if (@ARGV != 3); #my $input_file = "../data/clean/text"; #my $input_dir = "../data/raw/test"; #my $output_file = "../data/clean/text.clean"; my $input_file = $ARGV[0]; my $input_dir = $ARGV[1]; my $output_file = $ARGV[2]; ### 1. read test files my %pair_hash; foreach my $input_file (<$input_dir/*>) { $input_file =~ /$input_dir\/.+\.(.+?)\.txt$/; my $set = $1; open(I, $input_file) || die "Cannot open $input_file\n"; while (my $str = <I>) { $str =~ s/\s+$//; $str = lc($str); $pair_hash{$str} = $set; } close(I); } ### 2. read mturk file my %pair_set; my %pair_score; my %pair_count; my %all_score; my $count = 0; open(I, $input_file) || die "Cannot open $input_file\n"; while (my $str = <I>) { $str =~ s/\s+$//; $str =~ s/^(\d+)\t//; $str = lc($str); my $score = $1; if (!exists $pair_hash{$str}) { #print "$score\t$str\n"; $count++; next; } $all_score{$str} .= "$score "; $pair_score{$str} += $score; $pair_count{$str}++; $pair_set{$str} = $pair_hash{$str}; } close(I); #print "$count\n"; ### 3. write into file my $count2 = 0; my $count3 = 0; open(O, ">$output_file") || die "Cannot create $output_file\n"; foreach my $pair (sort {$pair_set{$a} cmp $pair_set{$b}} keys %pair_set) { my $score = $pair_score{$pair} / $pair_count{$pair}; my $as = $all_score{$pair}; $as =~ s/\s+$//; my @ss = split(/\s+/, $as); if (@ss > 5) { $count2++; splice(@ss, 5); } if (@ss < 5) { #print "$pair_count{$pair}\t$pair\n"; $count3++; } my $as_str = join(" ", @ss); print O "$score\t$pair_count{$pair}\t$pair_set{$pair}\t$as_str\t$pair\n"; } close(O); #print "more than 5 annotations: $count2\n"; #print "less than 5 annotations: $count3\n";
24.096386
86
0.535
ed08f6841d81c94fae5200a5f916bb844dffead8
4,096
t
Perl
test/math.t
albfan/cli
e20bb3b1b043b6108228297a8283c99fccb1971d
[ "MIT" ]
1
2019-09-26T20:04:37.000Z
2019-09-26T20:04:37.000Z
test/math.t
albfan/cli
e20bb3b1b043b6108228297a8283c99fccb1971d
[ "MIT" ]
null
null
null
test/math.t
albfan/cli
e20bb3b1b043b6108228297a8283c99fccb1971d
[ "MIT" ]
1
2019-02-03T17:31:27.000Z
2019-02-03T17:31:27.000Z
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- ############################################################################### # # Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # # http://www.opensource.org/licenses/mit-license.php # ############################################################################### import sys import os import unittest from datetime import datetime # Ensure python finds the local simpletap module sys.path.append(os.path.dirname(os.path.abspath(__file__))) from basetest import Task, TestCase class TestMath(TestCase): @classmethod def setUpClass(cls): cls.t = Task() cls.t.config("verbose", "nothing") cls.t.config("dateformat", "YYYY-MM-DD") # YYYY-12-21. cls.when = "%d-12-21T23:59:59\n" % datetime.now().year # Different ways of specifying YYYY-12-21. cls.t("add one due:eoy-10days") cls.t("add two due:'eoy-10days'") cls.t("add three 'due:eoy-10days'") cls.t("add four due:'eoy - 10days'") cls.t("add five 'due:eoy - 10days'") cls.t("add six 'due:%d-12-31T23:59:59 - 10days'" % datetime.now().year) def test_compact_unquoted(self): """compact unquoted""" code, out, err = self.t('_get 1.due') self.assertEqual(out, self.when) def test_compact_value_quoted(self): """compact value quoted""" code, out, err = self.t('_get 2.due') self.assertEqual(out, self.when) def test_compact_arg_quoted(self): """compact arg quoted""" code, out, err = self.t('_get 3.due') self.assertEqual(out, self.when) def test_sparse_value_quoted(self): """sparse value quoted""" code, out, err = self.t('_get 4.due') self.assertEqual(out, self.when) def test_sparse_arg_quoted(self): """sparse arg quoted""" code, out, err = self.t('_get 5.due') self.assertEqual(out, self.when) def test_sparse_arg_quoted_literal(self): """sparse arg quoted literal""" code, out, err = self.t('_get 6.due') self.assertEqual(out, self.when) class TestBug851(TestCase): @classmethod def setUpClass(cls): """Executed once before any test in the class""" cls.t = Task() cls.t('add past due:-2days') cls.t('add future due:2days') def setUp(self): """Executed before each test in the class""" def test_attribute_before_with_math(self): """851: Test due.before:now+1d""" code, out, err = self.t('due.before:now+1day ls') self.assertIn("past", out) self.assertNotIn("future", out) def test_attribute_after_with_math(self): """851: Test due.after:now+1d""" code, out, err = self.t('due.after:now+1day ls') self.assertNotIn("past", out) self.assertIn("future", out) if __name__ == "__main__": from simpletap import TAPTestRunner unittest.main(testRunner=TAPTestRunner()) # vim: ai sts=4 et sw=4 ft=python
35.310345
81
0.633545
ed02a0c09cb22f0f15e175602dd2620aef0b8fca
247
t
Perl
webapp/t/002_index_route.t
6bb79df9/yjournal
b554caa4508438b75a11d070c660956728a95194
[ "MIT" ]
null
null
null
webapp/t/002_index_route.t
6bb79df9/yjournal
b554caa4508438b75a11d070c660956728a95194
[ "MIT" ]
null
null
null
webapp/t/002_index_route.t
6bb79df9/yjournal
b554caa4508438b75a11d070c660956728a95194
[ "MIT" ]
null
null
null
use Test::More tests => 2; use strict; use warnings; # the order is important use YJournal; use Dancer::Test; route_exists [GET => '/'], 'a route handler is defined for /'; response_status_is ['GET' => '/'], 200, 'response status is 200 for /';
22.454545
71
0.672065
ed53351984ed15cee94320bf40914ac35beb45af
549
pl
Perl
data/c/make_ip_del.pl
jeffreybozek/whois
aa16f66c9dca556b7db131b68b0b99d435bc43d8
[ "MIT" ]
null
null
null
data/c/make_ip_del.pl
jeffreybozek/whois
aa16f66c9dca556b7db131b68b0b99d435bc43d8
[ "MIT" ]
null
null
null
data/c/make_ip_del.pl
jeffreybozek/whois
aa16f66c9dca556b7db131b68b0b99d435bc43d8
[ "MIT" ]
null
null
null
#!/usr/bin/perl -w use strict; while (<>) { chomp; s/^\s*(.*)\s*$/$1/; s/\s*#.*$//; next if /^$/; die "format error: $_" if not /^([\d\.]+)\/(\d+)\s+([\w\.]+)$/; my $m = $2; my $s = $3; my ($i1, $i2, $i3, $i4) = split(/\./, $1); print '{ ' . (($i1 << 24) + ($i2 << 16) + ($i3 << 8) + $i4) . 'UL, '. ((~(0xffffffff >> $m)) & 0xffffffff) . 'UL, "'; if ($s =~ /\./) { print $s; } elsif ($s eq 'UNKNOWN') { print "\\005"; } elsif ($s eq 'UNALLOCATED') { print "\\006"; } else { print "whois.$s.net"; } print '" },' . "\n"; }
19.607143
70
0.393443
73e3b5c2e855db5fdfdce5130d4715a725a894c7
1,511
pm
Perl
network/freebox/restapi/plugin.pm
dalfo77/centreon-plugins
3cb2011c46a45b5e4a785ca6bab439142f882d45
[ "Apache-2.0" ]
null
null
null
network/freebox/restapi/plugin.pm
dalfo77/centreon-plugins
3cb2011c46a45b5e4a785ca6bab439142f882d45
[ "Apache-2.0" ]
null
null
null
network/freebox/restapi/plugin.pm
dalfo77/centreon-plugins
3cb2011c46a45b5e4a785ca6bab439142f882d45
[ "Apache-2.0" ]
null
null
null
# # Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package network::freebox::restapi::plugin; use strict; use warnings; use base qw(centreon::plugins::script_custom); sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; %{$self->{modes}} = ( 'dsl-usage' => 'network::freebox::restapi::mode::dslusage', 'net-usage' => 'network::freebox::restapi::mode::netusage', 'system' => 'network::freebox::restapi::mode::system', ); $self->{custom_modes}{api} = 'network::freebox::restapi::custom::api'; return $self; } 1; __END__ =head1 PLUGIN DESCRIPTION Check Freebox through HTTP/REST API. =cut
29.057692
75
0.671079
ed1f2eae06db26976010132f43bad58a3f6cb6d9
788
pl
Perl
scripts/ag-trimm-3p-end.pl
mortazavilab/polyAsite_workflow_GM12878
5e3a1854f9d3e569fbe2b0f6c94a2648b68d21c4
[ "Apache-2.0" ]
10
2019-11-05T03:22:32.000Z
2021-12-17T10:05:50.000Z
scripts/ag-trimm-3p-end.pl
mortazavilab/polyAsite_workflow_GM12878
5e3a1854f9d3e569fbe2b0f6c94a2648b68d21c4
[ "Apache-2.0" ]
null
null
null
scripts/ag-trimm-3p-end.pl
mortazavilab/polyAsite_workflow_GM12878
5e3a1854f9d3e569fbe2b0f6c94a2648b68d21c4
[ "Apache-2.0" ]
1
2021-06-03T14:17:55.000Z
2021-06-03T14:17:55.000Z
use strict; use warnings; use Getopt::Long; my $help; my $nucs; my $minLen; GetOptions( "nuc=s" => \$nucs, "help" => \$help, "h" => \$help, "minLen=i" => \$minLen ); my $nuc = '[' . $nucs . ']'; my $showhelp = 0; $showhelp = 1 if ( not defined $nuc ); $showhelp = 1 if ( defined $help ); $showhelp = 1 if ( not defined $minLen ); if ($showhelp) { print STDERR "Usage: cat sample.fa | perl $0 --nuc=C --minLen=x\n\n"; exit; } my $header = ''; while (<STDIN>) { chomp; if ( $_ =~ m/^>/ ) { $header = $_; } else { if ( $header eq '' ) { print STDERR "[ERROR] no header found.\n"; exit; } my $seq = $_; $seq =~ s/$nuc+$//g; if ( length($seq) >= $minLen ) { print "$header\n$seq\n"; } $header = ''; } }
17.130435
71
0.48731
ed4d94970685d5adca1251dd008bdf8dfd22b801
4,801
t
Perl
t/007_functions.t
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
t/007_functions.t
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
t/007_functions.t
lominorama/cfn-perl
d4aafdd58cc06fe749cd65f51ce5e08e67c30e3a
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env perl use Moose::Util::TypeConstraints; use strict; use warnings; use Cfn; use Test::More; coerce 'Cfn::Resource::Properties::Test1', from 'HashRef', via { Cfn::Resource::Properties::Test1->new( %$_ ) }; package Cfn::Resource::Test1 { use Moose; extends 'Cfn::Resource'; has Properties => (is => 'rw', isa => 'Cfn::Resource::Properties::Test1', required => 1, coerce => 1); } package Cfn::Resource::Properties::Test1 { use Moose; extends 'Cfn::Resource::Properties'; has Prop1 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop2 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop3 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop4 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop5 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop6 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop7 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop8 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop9 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop10 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop11 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop12 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop13 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop14 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop15 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop16 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop17 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop18 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop19 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); has Prop20 => (is => 'rw', isa => 'Cfn::Value', coerce => 1); } my $cfn = Cfn->new; $cfn->addResource('t1', 'Test1', Prop1 => { 'Fn::Base64' => 'Value' }, Prop2 => { 'Fn::FindInMap' => [ 'MapName', 'TopLevelKey', 'SecondLevelKey' ] }, Prop3 => { 'Fn::GetAtt' => [ 'LogicalId', 'Attribute' ] }, Prop4 => { 'Fn::GetAZs' => '' }, Prop5 => { 'Fn::GetAZs' => { Ref => 'AWS::Region' } }, Prop6 => { 'Fn::Join' => [ 'del', [ 'v1', 'v2', 'v3' ] ] }, Prop7 => { 'Fn::Select' => [ 0, [ 'v1', 'v2', 'v3' ] ] }, Prop8 => { 'Fn::Select' => [ 0, { 'Fn::GetAZs' => '' } ] }, Prop9 => { 'Ref' => 'LogicalId' }, Prop10 => { 'Fn::And' => [ { 'Fn::Equals' => [ 'sg-mysggroup', { 'Ref' => 'ASecurityGroup' } ] }, { 'Condition' => 'SomeOtherCondition' } ] }, Prop11 => { "Fn::Equals" => [ {"Ref" => "EnvironmentType"}, "prod" ] }, Prop12 => { "Fn::If" => [ "CreateNewSecurityGroup", {"Ref" => "NewSecurityGroup"}, {"Ref" => "ExistingSecurityGroup"} ]}, Prop13 => { "Fn::Not" => [{ "Fn::Equals" => [ {"Ref" => "EnvironmentType"}, "prod" ] } ] }, Prop14 => { "Fn::Or" => [{ "Fn::Equals" => ["sg-mysggroup", {"Ref" => "ASecurityGroup"}]}, {"Condition" => "SomeOtherCondition"} ] }, Prop15 => { 'Fn::ImportValue' => 'Value' }, Prop16 => { 'Fn::Split' => [ 'del', 'Value' ] }, Prop17 => { 'Fn::Sub' => [ 'String' ] }, Prop18 => { 'Fn::Sub' => [ 'String', [ 'v1', 'v2', 'v3' ] ] }, Prop19 => { 'Fn::Cidr' => [ "192.168.0.0/24", 6, 5] }, Prop20 => { 'Fn::Transform' => { Name => 'macro name', Parameters => {key1 => 'value1', key2 => 'value2' } } } ); isa_ok($cfn->Resource('t1')->Properties->Prop1, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop2, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop3, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop4, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop5, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop6, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop7, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop8, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop9, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop10, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop11, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop12, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop13, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop14, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop15, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop16, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop17, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop18, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop19, 'Cfn::Value::Function'); isa_ok($cfn->Resource('t1')->Properties->Prop20, 'Cfn::Value::Function'); done_testing;
48.989796
136
0.558425
ed6023bda881aef36cdcbefe36028ba9d97847f9
396
pm
Perl
auto-lib/Azure/MachineLearning/PatchWebServicesResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/MachineLearning/PatchWebServicesResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/MachineLearning/PatchWebServicesResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
1
2021-04-08T15:26:39.000Z
2021-04-08T15:26:39.000Z
package Azure::MachineLearning::PatchWebServicesResult; use Moose; has properties => (is => 'ro', isa => 'Azure::MachineLearning::WebServiceProperties' ); has id => (is => 'ro', isa => 'Str' ); has location => (is => 'ro', isa => 'Str' ); has name => (is => 'ro', isa => 'Str' ); has tags => (is => 'ro', isa => 'HashRef[Str]' ); has type => (is => 'ro', isa => 'Str' ); 1;
33
90
0.535354
73e651726512155f7fb4360ae288be20b3459a14
3,666
pm
Perl
auto-lib/Paws/MarketplaceCatalog/ListChangeSets.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/MarketplaceCatalog/ListChangeSets.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/MarketplaceCatalog/ListChangeSets.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
package Paws::MarketplaceCatalog::ListChangeSets; use Moose; has Catalog => (is => 'ro', isa => 'Str', required => 1); has FilterList => (is => 'ro', isa => 'ArrayRef[Paws::MarketplaceCatalog::Filter]'); has MaxResults => (is => 'ro', isa => 'Int'); has NextToken => (is => 'ro', isa => 'Str'); has Sort => (is => 'ro', isa => 'Paws::MarketplaceCatalog::Sort'); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'ListChangeSets'); class_has _api_uri => (isa => 'Str', is => 'ro', default => '/ListChangeSets'); class_has _api_method => (isa => 'Str', is => 'ro', default => 'POST'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::MarketplaceCatalog::ListChangeSetsResponse'); 1; ### main pod documentation begin ### =head1 NAME Paws::MarketplaceCatalog::ListChangeSets - Arguments for method ListChangeSets on L<Paws::MarketplaceCatalog> =head1 DESCRIPTION This class represents the parameters used for calling the method ListChangeSets on the L<AWS Marketplace Catalog Service|Paws::MarketplaceCatalog> service. Use the attributes of this class as arguments to method ListChangeSets. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to ListChangeSets. =head1 SYNOPSIS my $catalog.marketplace = Paws->service('MarketplaceCatalog'); my $ListChangeSetsResponse = $catalog . marketplace->ListChangeSets( Catalog => 'MyCatalog', FilterList => [ { Name => 'MyFilterName', # min: 1, max: 255; OPTIONAL ValueList => [ 'MyStringValue', ... ], # min: 1, max: 10; OPTIONAL }, ... ], # OPTIONAL MaxResults => 1, # OPTIONAL NextToken => 'MyNextToken', # OPTIONAL Sort => { SortBy => 'MySortBy', # min: 1, max: 255; OPTIONAL SortOrder => 'ASCENDING', # values: ASCENDING, DESCENDING; OPTIONAL }, # OPTIONAL ); # Results: my $ChangeSetSummaryList = $ListChangeSetsResponse->ChangeSetSummaryList; my $NextToken = $ListChangeSetsResponse->NextToken; # Returns a L<Paws::MarketplaceCatalog::ListChangeSetsResponse> object. Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/catalog.marketplace/ListChangeSets> =head1 ATTRIBUTES =head2 B<REQUIRED> Catalog => Str The catalog related to the request. Fixed value: C<AWSMarketplace> =head2 FilterList => ArrayRef[L<Paws::MarketplaceCatalog::Filter>] An array of filter objects. =head2 MaxResults => Int The maximum number of results returned by a single call. This value must be provided in the next call to retrieve the next set of results. By default, this value is 20. =head2 NextToken => Str The token value retrieved from a previous call to access the next page of results. =head2 Sort => L<Paws::MarketplaceCatalog::Sort> An object that contains two attributes, C<sortBy> and C<sortOrder>. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method ListChangeSets in L<Paws::MarketplaceCatalog> =head1 BUGS and CONTRIBUTIONS The source code is located here: L<https://github.com/pplu/aws-sdk-perl> Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> =cut
33.327273
249
0.669667
ed5fb8094a0d4b76122c6f84ea664aff8b03eedc
358
al
Perl
x64/Release/slic3r_130/lib/auto/Net/SSLeay/get_https.al
aacitelli/OASIS-Challenge-Baseline-Code-and-Models
f1847c4a5c3d33ad3d05a41a5c5caf0d383faac1
[ "BSD-2-Clause" ]
null
null
null
x64/Release/slic3r_130/lib/auto/Net/SSLeay/get_https.al
aacitelli/OASIS-Challenge-Baseline-Code-and-Models
f1847c4a5c3d33ad3d05a41a5c5caf0d383faac1
[ "BSD-2-Clause" ]
null
null
null
x64/Release/slic3r_130/lib/auto/Net/SSLeay/get_https.al
aacitelli/OASIS-Challenge-Baseline-Code-and-Models
f1847c4a5c3d33ad3d05a41a5c5caf0d383faac1
[ "BSD-2-Clause" ]
null
null
null
#line 1 "auto/Net/SSLeay/get_https.al" # NOTE: Derived from blib\lib\Net\SSLeay.pm. # Changes made here will be lost when autosplit is run again. # See AutoSplit.pm. package Net::SSLeay; #line 1364 "blib\lib\Net\SSLeay.pm (autosplit into blib\lib\auto\Net\SSLeay\get_https.al)" sub get_https { do_httpx2(GET => 1, @_) } # end of Net::SSLeay::get_https 1;
32.545455
90
0.726257
ed461dfe7d359304ecc46770e540ef7853e86095
193
pm
Perl
auto-lib/Azure/BatchAI/FileServerListResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/BatchAI/FileServerListResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/BatchAI/FileServerListResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
1
2021-04-08T15:26:39.000Z
2021-04-08T15:26:39.000Z
package Azure::BatchAI::FileServerListResult; use Moose; has 'nextLink' => (is => 'ro', isa => 'Str' ); has 'value' => (is => 'ro', isa => 'ArrayRef[Azure::BatchAI::FileServer]' ); 1;
27.571429
79
0.590674
73e4053ae8c2c8efdf8c3b6b40f78c26c14db1c1
48,679
pm
Perl
windows/cperl/lib/Unicode/Collate/CJK/Korean.pm
SCOTT-HAMILTON/Monetcours
66a2970218a31e9987a4e7eb37443c54f22e6825
[ "MIT" ]
1,318
2019-07-11T10:34:39.000Z
2022-03-29T15:05:19.000Z
windows/cperl/lib/Unicode/Collate/CJK/Korean.pm
SCOTT-HAMILTON/Monetcours
66a2970218a31e9987a4e7eb37443c54f22e6825
[ "MIT" ]
387
2019-09-05T16:33:09.000Z
2022-03-31T10:43:39.000Z
windows/cperl/lib/Unicode/Collate/CJK/Korean.pm
SCOTT-HAMILTON/Monetcours
66a2970218a31e9987a4e7eb37443c54f22e6825
[ "MIT" ]
66
2019-11-11T15:33:12.000Z
2022-03-01T07:55:55.000Z
package Unicode::Collate::CJK::Korean; use 5.006; use strict; use warnings; our $VERSION = '1.27'; my %jamo2prim = ( '1100', 0x3D0C, '1101', 0x3D0D, '1102', 0x3D0E, '1103', 0x3D0F, '1105', 0x3D11, '1106', 0x3D12, '1107', 0x3D13, '1109', 0x3D15, '110A', 0x3D16, '110B', 0x3D17, '110C', 0x3D18, '110E', 0x3D1A, '110F', 0x3D1B, '1110', 0x3D1C, '1111', 0x3D1D, '1112', 0x3D1E, '1161', 0x3D8A, '1162', 0x3D8B, '1163', 0x3D8C, '1165', 0x3D8E, '1166', 0x3D8F, '1167', 0x3D90, '1168', 0x3D91, '1169', 0x3D92, '116A', 0x3D93, '116B', 0x3D94, '116C', 0x3D95, '116D', 0x3D96, '116E', 0x3D97, '116F', 0x3D98, '1170', 0x3D99, '1171', 0x3D9A, '1172', 0x3D9B, '1173', 0x3D9C, '1174', 0x3D9D, '1175', 0x3D9E, '11A8', 0x3DE8, '11AB', 0x3DEB, '11AF', 0x3DEF, '11B7', 0x3DF7, '11B8', 0x3DF8, '11BC', 0x3DFC, '11BD', 0x3DFD, ); # for DUCET v10.0.0 my(%u2e, $prim, $wt); while (<DATA>) { last if /^__END__/; my @c = split; if (@c == 1 && $c[0] =~ /^[A-D]/) { # hangul $c[0] =~ s/^.*://; $prim = [ map $jamo2prim{$_}, split /-/, $c[0] ]; $wt = 0x20; } else { # ideographs for my $c (@c) { next if !$c; $wt++; $u2e{hex($c)} = [ $wt, @$prim ]; } } } sub weightKorean { my $u = shift; return undef if !exists $u2e{$u}; my @a = @{ $u2e{$u} }; my $s = shift @a; my $p = shift @a; return([ $p, $s, 0x2, $u ], @a); } 1; # DATA format # hangul syllable:jamo-jamo(-jamo) # equiv. ideographs __DATA__ AC00:1100-1161 4F3D 4F73 5047 50F9 52A0 53EF 5475 54E5 5609 5AC1 5BB6 6687 67B6 67B7 67EF 6B4C 73C2 75C2 7A3C 82DB 8304 8857 8888 8A36 8CC8 8DCF 8EFB 8FE6 99D5 4EEE 50A2 5496 54FF 5777 5B8A 659D 698E 6A9F 73C8 7B33 801E 8238 846D 8B0C AC01:1100-1161-11A8 523B 5374 5404 606A 6164 6BBC 73CF 811A 89BA 89D2 95A3 537B 54AF 57C6 6409 64F1 6877 AC04:1100-1161-11AB 4F83 520A 58BE 5978 59E6 5E72 5E79 61C7 63C0 6746 67EC 687F 6F97 764E 770B 78F5 7A08 7AFF 7C21 809D 826E 8271 8AEB 9593 5058 6173 681E 69A6 7395 79C6 831B 884E 8D76 8FC0 9F66 AC08:1100-1161-11AF 4E6B 559D 66F7 6E34 78A3 7AED 845B 8910 874E 97A8 5676 696C 79F8 7FAF 880D 9DA1 AC10:1100-1161-11B7 52D8 574E 582A 5D4C 611F 61BE 6221 6562 67D1 6A44 6E1B 7518 75B3 76E3 77B0 7D3A 90AF 9451 9452 9F95 5769 57F3 5D41 5F07 61A8 64BC 6B3F 6B5B 6CD4 6DE6 6F89 77D9 8F57 9163 9E7B AC11:1100-1161-11B8 5323 5CAC 7532 80DB 9240 9598 97D0 AC15:1100-1161-11BC 525B 5808 59DC 5CA1 5D17 5EB7 5F3A 5F4A 6177 6C5F 757A 7586 7CE0 7D73 7DB1 7F8C 8154 8221 8591 8941 8B1B 92FC 964D 9C47 508B 50F5 58C3 5FFC 625B 6760 6A7F 6BAD 77FC 7A45 7E48 7F61 7F97 7FAB 8333 8C47 97C1 AC1C:1100-1162 4ECB 4EF7 500B 51F1 584F 6137 613E 6168 6539 69EA 6F11 75A5 7686 76D6 7B87 82A5 84CB 93A7 958B 5274 5303 63E9 69E9 73A0 78D5 95D3 AC1D:1100-1162-11A8 5580 5BA2 AC31:1100-1162-11BC 5751 7CB3 7FB9 785C 8CE1 93D7 AC39:1100-1163-11A8 91B5 AC70:1100-1165 5028 53BB 5C45 5DE8 62D2 636E 64DA 64E7 6E20 70AC 795B 8DDD 8E1E 907D 9245 92F8 547F 661B 79EC 7B65 7C67 80E0 8152 82E3 8392 8556 8627 88AA 88FE 99CF AC74:1100-1165-11AB 4E7E 4EF6 5065 5DFE 5EFA 6106 6957 8171 8654 8E47 9375 9A2B 63F5 728D 7777 8930 8B07 97AC AC78:1100-1165-11AF 4E5E 5091 6770 6840 4E6C 6705 69A4 AC80:1100-1165-11B7 5109 528D 5292 6AA2 77BC 9210 9ED4 64BF 82A1 AC81:1100-1165-11B8 52AB 602F 8FF2 5226 5227 AC8C:1100-1166 5048 61A9 63ED ACA9:1100-1167-11A8 64CA 683C 6A84 6FC0 8188 89A1 9694 630C 6BC4 95C3 9ABC 9B32 9D03 ACAC:1100-1167-11AB 5805 727D 72AC 7504 7D79 7E6D 80A9 898B 8B74 9063 9D51 6A2B 72F7 754E 7B67 7E33 7E7E 7F82 8832 9C39 ACB0:1100-1167-11AF 6289 6C7A 6F54 7D50 7F3A 8A23 73A6 89D6 95CB ACB8:1100-1167-11B7 517C 614A 7B9D 8B19 9257 938C 5094 55DB 5C92 62D1 6B49 7E11 84B9 9EDA 9F38 ACBD:1100-1167-11BC 4EAC 4FD3 501E 50BE 5106 52C1 52CD 537F 5770 5883 5E9A 5F91 6176 61AC 64CE 656C 666F 66BB 66F4 6897 6D87 7085 70F1 749F 74A5 74CA 75D9 786C 78EC 7ADF 7AF6 7D45 7D93 8015 803F 811B 8396 8B66 8F15 9015 93E1 9803 9838 9A5A 9BE8 518F 5244 54FD 60F8 61BC 6243 6AA0 7162 712D 71B2 754A 7AF8 7D86 9848 7F44 8927 8B26 99C9 9BC1 9EE5 ACC4:1100-1168 4FC2 5553 583A 5951 5B63 5C46 60B8 6212 6842 68B0 68E8 6EAA 754C 7678 78CE 7A3D 7CFB 7E6B 7E7C 8A08 8AA1 8C3F 968E 9DC4 5826 70D3 7608 798A 7B53 7DAE 7E18 7F7D 846A 858A 96DE 9AFB ACE0:1100-1169 53E4 53E9 544A 5471 56FA 59D1 5B64 5C3B 5EAB 62F7 6537 6545 6572 66A0 67AF 69C1 6CBD 75FC 7690 777E 7A3F 7F94 8003 80A1 818F 82E6 82FD 83F0 85C1 8831 88B4 8AA5 8F9C 932E 96C7 9867 9AD8 9F13 4F30 51C5 5233 5859 6772 6832 69C0 69F9 6ADC 726F 768B 76EC 77BD 7A01 7B8D 7BD9 7CD5 7F5F 7F96 7FFA 80EF 89DA 8A41 90DC 9164 9237 9760 9D23 9DF1 ACE1:1100-1169-11A8 54ED 659B 66F2 688F 7A40 8C37 9D60 56B3 69F2 7E20 89F3 8F42 ACE4:1100-1169-11AB 56F0 5764 5D11 6606 68B1 68CD 6EFE 7428 889E 9BE4 5803 5D10 6083 6346 7DC4 886E 88CD 890C 9315 95AB 9AE1 9D7E 9DA4 9F6B ACE8:1100-1169-11AF 6C68 9AA8 6430 69BE 77FB 9DBB ACF5:1100-1169-11BC 4F9B 516C 5171 529F 5B54 5DE5 6050 606D 62F1 63A7 653B 73D9 7A7A 86A3 8CA2 978F 5025 5D06 60BE 6831 69D3 7B9C 86E9 86EC 8D1B 8DEB 91ED 9F94 ACF6:1100-1169-11BD 4E32 ACFC:1100-116A 5BE1 6208 679C 74DC 79D1 83D3 8A87 8AB2 8DE8 904E 934B 9846 4F89 581D 5925 5938 64BE 7313 7A1E 7AA0 874C 88F9 8E1D 9299 9A0D ACFD:1100-116A-11A8 5ED3 69E8 85FF 90ED 6901 7668 8EA9 970D 97B9 AD00:1100-116A-11AB 51A0 5B98 5BEC 6163 68FA 6B3E 704C 742F 74D8 7BA1 7F50 83C5 89C0 8CAB 95DC 9928 4E31 6DAB 721F 76E5 797C 7ABE 7B66 7DB0 8F28 9327 9475 96DA 9874 9AD6 9E1B AD04:1100-116A-11AF 522E 605D 62EC 9002 4F78 681D 7B48 8052 9AFA 9D30 AD11:1100-116A-11BC 4F8A 5149 5321 58D9 5EE3 66E0 6D38 709A 72C2 73D6 7B50 80F1 945B 6047 6844 6846 720C 7377 78FA 7D56 7E8A 832A 8A86 8A91 AD18:1100-116B 5366 639B 7F6B 54BC 6302 7F63 8A7F AD34:1100-116C 4E56 5080 584A 58DE 602A 6127 62D0 69D0 9B41 5ABF 5EE5 6060 7470 749D 84AF 8958 AD35:1100-116C-11A8 9998 AD49:1100-116C-11BC 5B8F 7D18 80B1 8F5F 6D64 89E5 8A07 958E AD50:1100-116D 4EA4 50D1 54AC 55AC 5B0C 5DA0 5DE7 652A 654E 6821 6A4B 72E1 768E 77EF 7D5E 7FF9 81A0 854E 86DF 8F03 8F4E 90CA 9903 9A55 9BAB 4F7C 5604 5610 566D 5699 59E3 618D 649F 6648 669E 69B7 78FD 7A96 8DAB 8E7B 9278 9AB9 9D41 9F69 AD6C:1100-116E 4E18 4E45 4E5D 4EC7 4FF1 5177 52FE 5340 53E3 53E5 548E 5614 5775 57A2 5BC7 5D87 5ED0 61FC 62D8 6551 67B8 67E9 69CB 6B50 6BC6 6BEC 6C42 6E9D 7078 72D7 7396 7403 77BF 77E9 7A76 7D7F 8009 81FC 8205 820A 82DF 8862 8B33 8CFC 8EC0 9011 90B1 9264 92B6 99D2 9A45 9CE9 9DD7 9F9C 4F49 4F5D 4FC5 50B4 5193 52AC 5336 53B9 53F4 5778 59E4 5ABE 5AD7 5C68 5CA3 5F40 6235 6263 6344 6406 6473 662B 6998 6F1A 7486 750C 759A 75C0 766F 7A9B 7AB6 7BDD 7CD7 80CA 849F 86AF 88D8 89AF 8A6C 9058 91E6 97DD 97ED 97EE 98B6 99C8 9B2E 9DC7 9E1C AD6D:1100-116E-11A8 570B 5C40 83CA 97A0 97AB 9EB4 530A 63AC 8DFC 9EAF AD70:1100-116E-11AB 541B 7A98 7FA4 88D9 8ECD 90E1 6343 687E 76B8 AD74:1100-116E-11AF 5800 5C48 6398 7A9F 5014 5D1B 6DC8 8A58 AD81:1100-116E-11BC 5BAE 5F13 7A79 7AAE 828E 8EAC 8EB3 AD8C:1100-116F-11AB 5026 5238 52F8 5377 5708 62F3 6372 6B0A 6DC3 7737 52CC 60D3 68EC 7760 7DA3 8737 AD90:1100-116F-11AF 53A5 7357 8568 8E76 95D5 ADA4:1100-1170 673A 6AC3 6F70 8A6D 8ECC 994B 4F79 51E0 5282 5331 6192 6485 6A3B 6C3F 7C0B 7E62 8DEA 95E0 993D 9E82 ADC0:1100-1171 6677 6B78 8CB4 9B3C ADDC:1100-1172 53EB 572D 594E 63C6 69FB 73EA 7845 7ABA 7AC5 7CFE 8475 898F 8D73 9035 95A8 5232 5AE2 5B00 5DCB 668C 694F 6A1B 6F59 777D 7CFA 866C 866F 8DEC 90BD 95DA 980D 9997 ADE0:1100-1172-11AB 52FB 5747 7547 7B60 83CC 921E 56F7 9E8F ADE4:1100-1172-11AF 6A58 ADF9:1100-1173-11A8 514B 524B 5287 621F 68D8 6975 9699 4E9F 5C05 5C50 90C4 ADFC:1100-1173-11AB 50C5 52A4 52E4 61C3 65A4 6839 69FF 747E 7B4B 82B9 83EB 89B2 8B39 8FD1 9949 537A 53AA 5890 5DF9 5ED1 6F0C 89D4 8DDF 91FF 9773 AE08:1100-1173-11B7 4ECA 5997 64D2 6611 6A8E 7434 7981 79BD 82A9 887E 887F 895F 9326 552B 5664 5D94 7B12 9EC5 AE09:1100-1173-11B8 4F0B 53CA 6025 6271 6C72 7D1A 7D66 573E 5C8C 7680 790F 7B08 82A8 AE0D:1100-1173-11BC 4E98 5162 77DC 80AF 4E99 6B91 AE30:1100-1175 4F01 4F0E 5176 5180 55DC 5668 573B 57FA 57FC 5914 5947 5993 5BC4 5C90 5D0E 5DF1 5E7E 5FCC 6280 65D7 65E3 671E 671F 675E 68CB 68C4 6A5F 6B3A 6C23 6C7D 6C82 6DC7 7398 7426 742A 7482 74A3 7578 757F 7881 78EF 7941 7947 7948 797A 7B95 7D00 7DBA 7F88 8006 802D 808C 8A18 8B4F 8C48 8D77 9321 9324 98E2 9951 9A0E 9A0F 9A65 9E92 50DB 525E 588D 5C7A 5E8B 5F03 5FEE 612D 638E 6532 65C2 66A3 66C1 68CA 6B67 7081 7309 79A8 7DA5 7DA6 7F87 80B5 82AA 82B0 8604 8641 871D 87E3 8989 89AC 8DC2 9691 980E 9B10 9C2D 9ED6 AE34:1100-1175-11AB 7DCA AE38:1100-1175-11AF 4F76 5409 62EE 6854 59DE 86E3 AE40:1100-1175-11B7 91D1 B07D:1101-1175-11A8 55AB B098:1102-1161 513A 5A1C 61E6 62CF 62FF 90A3 6310 632A 689B 7CE5 7CEF B099:1102-1161-11A8 8AFE B09C:1102-1161-11AB 6696 7156 96E3 5044 7157 8D67 992A B0A0:1102-1161-11AF 634F 637A B0A8:1102-1161-11B7 5357 678F 6960 6E73 7537 5583 67DF B0A9:1102-1161-11B8 7D0D 8872 B0AD:1102-1161-11BC 56CA 5A18 66E9 B0B4:1102-1162 4E43 5167 5948 67F0 8010 5302 5976 5B2D 8FFA 9F10 B140:1102-1167 5973 B141:1102-1167-11A8 60C4 B144:1102-1167-11AB 5E74 649A 79CA 78BE B150:1102-1167-11B7 5FF5 606C 62C8 637B B155:1102-1167-11BC 5BE7 5BD7 4F5E 511C 5680 6FD8 B178:1102-1169 52AA 5974 5F29 6012 7459 99D1 5476 5B65 5CF1 7331 7B2F 81D1 B18D:1102-1169-11BC 6FC3 81BF 8FB2 5102 5665 7A60 91B2 B1CC:1102-116C 60F1 8166 9912 B1E8:1102-116D 5C3F 5ACB 5B32 6DD6 78E0 88CA 9403 B204:1102-116E 5542 8028 B208:1102-116E-11AB 5AE9 B20C:1102-116E-11AF 8A25 5436 80AD B274:1102-1172 677B 7D10 5FF8 9775 B275:1102-1172-11A8 8844 B2A5:1102-1173-11BC 80FD B2C8:1102-1175 5C3C 6CE5 5462 6029 67C5 7962 79B0 81A9 B2C9:1102-1175-11A8 533F 6EBA 6635 66B1 B2E4:1103-1161 591A 8336 7239 B2E8:1103-1161-11AB 4E39 4EB6 4F46 55AE 5718 58C7 5F56 65B7 65E6 6A80 6BB5 6E4D 77ED 7AEF 7C1E 7DDE 86CB 8892 9132 935B 6171 62C5 6934 6F19 7649 8011 80C6 8176 8711 B2EC:1103-1161-11AF 64BB 6FBE 737A 75B8 9054 59B2 601B 95E5 977C 97C3 B2F4:1103-1161-11B7 5556 574D 61BA 64D4 66C7 6DE1 6E5B 6F6D 6FB9 75F0 8043 81BD 8541 8983 8AC7 8B5A 931F 510B 5557 5649 58B0 58DC 6BEF 79AB 7F4E 859D 90EF 9EEE 9EF5 B2F5:1103-1161-11B8 6C93 7553 7B54 8E0F 905D B2F9:1103-1161-11BC 5510 5802 5858 5E62 6207 649E 68E0 7576 7CD6 87B3 9EE8 5018 513B 515A 642A 6A94 6E8F 746D 74AB 77A0 7911 87F7 8960 8B9C 93DC 943A 9933 9939 B300:1103-1162 4EE3 5788 576E 5927 5C0D 5CB1 5E36 5F85 6234 64E1 73B3 81FA 888B 8CB8 968A 9EDB 5113 61DF 65F2 6C4F 7893 9413 B301:1103-1162-11A8 5B85 B355:1103-1165-11A8 5FB7 60B3 B3C4:1103-1169 5012 5200 5230 5716 5835 5857 5C0E 5C60 5CF6 5D8B 5EA6 5F92 60BC 6311 6389 6417 6843 68F9 6AC2 6DD8 6E21 6ED4 6FE4 71FE 76DC 7779 79B1 7A3B 8404 89A9 8CED 8DF3 8E48 9003 9014 9053 90FD 934D 9676 97DC 53E8 58D4 5F22 5FC9 6146 638F 642F 64E3 6AAE 6D2E 6D82 7A0C 83DF 9174 95CD 9780 97B1 9955 9F17 B3C5:1103-1169-11A8 6BD2 7006 7258 72A2 7368 7763 79BF 7BE4 7E9B 8B80 6ADD 9EF7 B3C8:1103-1169-11AB 58A9 60C7 6566 65FD 66BE 6C8C 711E 71C9 8C5A 9813 5F34 6F61 8E89 B3CC:1103-1169-11AF 4E6D 7A81 5484 5817 B3D9:1103-1169-11BC 4EDD 51AC 51CD 52D5 540C 61A7 6771 6850 68DF 6D1E 6F7C 75BC 77B3 7AE5 80F4 8463 9285 4F97 50EE 54C3 578C 5CD2 5F64 6723 6A66 6DB7 825F 82F3 833C 856B 8740 932C 9B97 B450:1103-116E 515C 6597 675C 6793 75D8 7AC7 8373 8C46 9017 982D 6296 6581 809A 8130 86AA 8839 9661 B454:1103-116E-11AB 5C6F 81C0 829A 9041 906F 920D 7A80 8FCD B458:1103-116E-11AF 4E67 B4DD:1103-1173-11A8 5F97 B4F1:1103-1173-11BC 5D9D 6A59 71C8 767B 7B49 85E4 8B04 9127 9A30 51F3 58B1 6ED5 78F4 7C50 7E22 87A3 9419 B77C:1105-1161 5587 61F6 7669 7F85 863F 87BA 88F8 908F 502E 56C9 66EA 7630 7822 81DD 947C 9A3E 9A58 B77D:1105-1161-11A8 6D1B 70D9 73DE 7D61 843D 916A 99F1 55E0 7296 B780:1105-1161-11AB 4E82 5375 6B04 6B12 703E 721B 862D 9E1E 5B3E 5E71 6514 7053 8974 947E 95CC B784:1105-1161-11AF 524C 8FA3 57D2 8FA2 B78C:1105-1161-11B7 5D50 64E5 652C 6B16 6FEB 7C43 7E9C 85CD 8964 89BD 5A6A 60CF B78D:1105-1161-11B8 62C9 81D8 881F 945E B791:1105-1161-11BC 5ECA 6717 6D6A 72FC 7405 746F 8782 90DE 6994 7860 7A02 83A8 870B 95AC B798:1105-1162 4F86 5D0D 5FA0 840A 6DF6 9A0B B7AD:1105-1162-11BC 51B7 B7B5:1105-1163-11A8 63A0 7565 7567 B7C9:1105-1163-11BC 4EAE 5006 5169 51C9 6881 6A11 7CAE 7CB1 7CE7 826F 8AD2 8F1B 91CF 55A8 60A2 690B 6DBC 8E09 9B4E B824:1105-1167 4FB6 5137 52F5 5442 5EEC 616E 623E 65C5 6ADA 6FFE 792A 85DC 8823 95AD 9A62 9A6A 9E97 9ECE 5122 53B2 5533 68A0 7658 7CF2 8182 81DA 8821 908C 9462 B825:1105-1167-11A8 529B 66C6 6B77 701D 792B 8F62 9742 650A 6ADF 6AEA 7667 8F63 9148 B828:1105-1167-11AB 6190 6200 6523 6F23 7149 7489 7DF4 806F 84EE 8F26 9023 934A 5B4C 695D 6E45 81E0 93C8 9C0A 9C31 B82C:1105-1167-11AF 51BD 5217 52A3 6D0C 70C8 88C2 6312 6369 98B2 B834:1105-1167-11B7 5EC9 6582 6BAE 6FC2 7C3E 5969 7032 78CF B835:1105-1167-11B8 7375 8E90 9B23 B839:1105-1167-11BC 4EE4 4F36 56F9 5CBA 5DBA 601C 73B2 7B2D 7F9A 7FCE 8046 901E 9234 96F6 9748 9818 9F61 53E6 5464 59C8 5CAD 6624 6B1E 6CE0 79E2 82D3 86C9 8EE8 9D12 9E77 B840:1105-1168 4F8B 6FA7 79AE 91B4 96B7 96B8 9C67 B85C:1105-1169 52DE 6488 64C4 6AD3 6F5E 7018 7210 76E7 8001 8606 865C 8DEF 8F05 9732 9B6F 9DFA 9E75 58DA 6EF7 7388 7646 7A82 826A 826B 8F64 942A 946A 9871 9AD7 9C78 9E15 B85D:1105-1169-11A8 788C 797F 7DA0 83C9 9304 9E7F 9E93 5725 5F54 6DE5 6F09 7C0F 8F46 9A04 B860:1105-1169-11AB 8AD6 B871:1105-1169-11BC 58DF 5F04 6727 7027 74CF 7C60 807E 5131 650F 66E8 7931 8622 96B4 9F8E B8B0:1105-116C 5121 7028 7262 78CA 8CC2 8CDA 8CF4 96F7 6502 790C 7927 7C5F 7E87 7F4D 8012 857E 8A84 9179 9842 B8CC:1105-116D 4E86 50DA 5BEE 5ED6 6599 71CE 7642 77AD 804A 84FC 907C 9B27 5639 5AFD 64A9 66B8 6F66 7360 7E5A 818B 91AA 9410 98C2 98C9 B8E1:1105-116D-11BC 9F8D 9F92 B8E8:1105-116E 58D8 5A41 5C62 6A13 6DDA 6F0F 763B 7D2F 7E37 851E 8938 93E4 964B 50C2 560D 5D81 617A 802C 87BB 9ACF B958:1105-1172 5289 65D2 67F3 69B4 6D41 6E9C 700F 7409 7460 7559 7624 786B 8B2C 985E 6A4A 7E32 7E8D 905B 9DB9 B959:1105-1172-11A8 516D 622E 9678 52E0 B95C:1105-1172-11AB 4F96 502B 5D19 6DEA 7DB8 8F2A 6384 B960:1105-1172-11AF 5F8B 6144 6817 5D42 6EA7 B96D:1105-1172-11BC 9686 7643 7ABF B975:1105-1173-11A8 52D2 808B 6CD0 B984:1105-1173-11B7 51DC 51DB 5EE9 6F9F B989:1105-1173-11BC 51CC 695E 7A1C 7DBE 83F1 9675 5030 8506 B9AC:1105-1175 4FDA 5229 5398 540F 550E 5C65 60A7 674E 68A8 6D6C 7281 72F8 7406 7483 75E2 7C6C 7F79 7FB8 8389 88CF 88E1 91CC 91D0 96E2 9BC9 4FD0 527A 54E9 5AE0 6D96 6F13 79BB 8385 870A 87AD 8C8D 9090 9B51 9ED0 B9B0:1105-1175-11AB 541D 6F7E 71D0 7498 85FA 8EAA 96A3 9C57 9E9F 5D99 608B 735C 78F7 7CA6 7CBC 7E57 8E99 8F54 9130 93FB 9A4E B9BC:1105-1175-11B7 6797 6DCB 7433 81E8 9716 75F3 B9BD:1105-1175-11B8 782C 7ACB 7B20 7C92 5CA6 B9C8:1106-1161 6469 746A 75F2 78BC 78E8 99AC 9B54 9EBB 5298 5ABD 879E 87C7 9EBD 9EBF B9C9:1106-1161-11A8 5BDE 5E55 6F20 819C 83AB 9088 7799 93CC B9CC:1106-1161-11AB 4E07 534D 5A29 5DD2 5F4E 6162 633D 6669 66FC 6EFF 6F2B 7063 779E 842C 8513 883B 8F13 9945 9C3B 5881 5ADA 5E54 7E35 8B3E 8E63 93CB 93DD 9B18 B9D0:1106-1161-11AF 551C 62B9 672B 6CAB 8309 896A 977A 5E15 79E3 B9DD:1106-1161-11BC 4EA1 5984 5FD8 5FD9 671B 7DB2 7F54 8292 832B 83BD 8F1E 9099 60D8 6C52 6F2D 83BE 87D2 9B4D B9E4:1106-1162 57CB 59B9 5A92 5BD0 6627 679A 6885 6BCF 7164 7F75 8CB7 8CE3 9081 9B45 5446 6973 6CAC 73AB 771B 82FA 8393 9176 9709 B9E5:1106-1162-11A8 8108 8C8A 964C 9A40 9EA5 8109 8C83 8C98 B9F9:1106-1162-11BC 5B5F 6C13 731B 76F2 76DF 840C 511A 750D 753F 867B BA71:1106-1167-11A8 51AA 8993 5E4E 7CF8 BA74:1106-1167-11AB 514D 5195 52C9 68C9 6C94 7704 7720 7DBF 7DEC 9762 9EB5 4FDB 6E4E 7CC6 7DDC 9EAA BA78:1106-1167-11AF 6EC5 8511 7BFE 884A BA85:1106-1167-11BC 51A5 540D 547D 660E 669D 6927 6E9F 76BF 7791 8317 84C2 879F 9169 9298 9CF4 6D3A BA8C:1106-1168 8882 BAA8:1106-1169 4FAE 5192 52DF 59C6 5E3D 6155 6478 6479 66AE 67D0 6A21 6BCD 6BDB 725F 7261 7441 7738 77DB 8017 82BC 8305 8B00 8B28 8C8C 4F94 59E5 5AA2 5AEB 6048 65C4 7683 770A 7C8D 7CE2 8004 8765 87CA 927E 9AE6 BAA9:1106-1169-11A8 6728 6C90 7267 76EE 7766 7A46 9DA9 51E9 82DC BAB0:1106-1169-11AF 6B7F 6C92 BABD:1106-1169-11BC 5922 6726 8499 5E6A 61DE 66DA 6E95 6FDB 77A2 77C7 8268 96FA 9E0F BB18:1106-116D 536F 5893 5999 5EDF 63CF 6634 6773 6E3A 732B 7AD7 82D7 9328 6DFC 7707 85D0 8C93 BB34:1106-116E 52D9 5DEB 61AE 61CB 620A 62C7 64AB 65E0 6959 6B66 6BCB 7121 73F7 755D 7E46 821E 8302 856A 8AA3 8CBF 9727 9D61 511B 5638 5EE1 81B4 9A16 BB35:1106-116E-11A8 58A8 9ED8 563F BB38:1106-116E-11AB 5011 520E 543B 554F 6587 6C76 7D0A 7D0B 805E 868A 9580 96EF 5301 6097 61E3 6286 636B 7086 748A BB3C:1106-116E-11AF 52FF 6C95 7269 BBF8:1106-1175 5473 5A9A 5C3E 5D4B 5F4C 5FAE 672A 68B6 6963 6E3C 6E44 7709 7C73 7F8E 8587 8B0E 8FF7 9761 9EF4 4EB9 5A13 5A84 5ABA 5F25 5F2D 6549 7030 737C 7CDC 7E3B 82FF 863C 9E8B BBFC:1106-1175-11AB 5CB7 60B6 610D 61AB 654F 65FB 65FC 6C11 6CEF 739F 73C9 7DE1 9594 5FDE 5FDF 668B 6E63 7DCD 7F60 82E0 95A9 9C35 9EFD BC00:1106-1175-11AF 5BC6 871C 8B10 6A12 6EF5 BC15:1107-1161-11A8 525D 535A 62CD 640F 64B2 6734 6A38 6CCA 73C0 749E 7B94 7C95 7E1B 818A 8236 8584 8FEB 96F9 99C1 4EB3 6B02 7254 939B 99EE 9AC6 BC18:1107-1161-11AB 4F34 534A 53CD 53DB 62CC 642C 6500 6591 69C3 6CEE 6F58 73ED 7554 7622 76E4 76FC 78D0 78FB 792C 7D46 822C 87E0 8FD4 9812 98EF 5ABB 6273 642B 653D 670C 80D6 878C 9816 BC1C:1107-1161-11AF 52C3 62D4 64A5 6E24 6F51 767C 8DCB 91B1 9262 9AEE 9B43 54F1 6D61 8116 9238 9D53 BC29:1107-1161-11BC 5023 508D 574A 59A8 5C28 5E47 5F77 623F 653E 65B9 65C1 6609 678B 699C 6EC2 78C5 7D21 80AA 8180 822B 82B3 84A1 868C 8A2A 8B17 90A6 9632 9F90 4EFF 5396 5E6B 5FAC 6412 65CA 6886 7253 823D 8783 938A 9AE3 9B74 BC30:1107-1162 500D 4FF3 57F9 5F98 62DC 6392 676F 6E43 7119 76C3 80CC 80DA 88F4 88F5 8919 8CE0 8F29 914D 966A 574F 576F 6252 7432 84D3 BC31:1107-1162-11A8 4F2F 4F70 5E1B 67CF 6822 767D 767E 9B44 7CA8 BC88:1107-1165-11AB 5E61 6A0A 7169 71D4 756A 7E41 8543 85E9 98DC 7E59 7FFB 81B0 8629 88A2 BC8C:1107-1165-11AF 4F10 7B4F 7F70 95A5 6A43 7F78 BC94:1107-1165-11B7 51E1 5E06 68B5 6C3E 6C4E 6CDB 72AF 7BC4 8303 7B35 8A09 98BF BC95:1107-1165-11B8 6CD5 743A BCBD:1107-1167-11A8 50FB 5288 58C1 64D8 6A97 74A7 7656 78A7 8617 95E2 9739 64D7 7513 7588 895E 9DFF 9F0A BCC0:1107-1167-11AB 535E 5F01 8B8A 8FA8 8FAF 908A 5FED 6283 7C69 8FAE 8141 8CC6 99E2 9ABF 9D18 BCC4:1107-1167-11AF 5225 77A5 9C49 9F08 5F46 9DE9 BCD1:1107-1167-11BC 4E19 5002 5175 5C5B 5E77 661E 663A 67C4 68C5 70B3 7501 75C5 79C9 7ADD 8F27 9920 9A08 4E26 5840 7D63 7F3E 8FF8 9235 92F2 927C BCF4:1107-1169 4FDD 5821 5831 5BF6 666E 6B65 6D11 6E7A 6F7D 73E4 752B 83E9 88DC 8913 8B5C 8F14 4FCC 76D9 7C20 8446 974C 9D07 9EFC BCF5:1107-1169-11A8 4F0F 50D5 5310 535C 5B93 5FA9 670D 798F 8179 832F 8514 8907 8986 8F39 8F3B 99A5 9C12 58A3 5E5E 6251 6FEE 7B99 83D4 8760 876E 9D69 BCF8:1107-1169-11AB 672C BCFC:1107-1169-11AF 4E76 BD09:1107-1169-11BC 4FF8 5949 5C01 5CEF 5CF0 6367 68D2 70FD 71A2 742B 7E2B 84EC 8702 9022 92D2 9CF3 4E30 5906 7BF7 7D98 83F6 9D0C BD80:1107-116E 4E0D 4ED8 4FEF 5085 5256 526F 5426 5490 57E0 592B 5A66 5B5A 5B75 5BCC 5E9C 6276 6577 65A7 6D6E 6EA5 7236 7B26 7C3F 7F36 8150 8151 819A 8240 8299 83A9 8A03 8CA0 8CE6 8CFB 8D74 8DBA 90E8 91DC 961C 9644 99D9 9CE7 4EC6 4FD8 5A8D 6294 62CA 638A 6874 6991 6DAA 739E 7954 7B5F 7F58 7F66 80D5 82A3 82FB 8500 86A8 8709 889D 88D2 8DD7 9207 982B 9B92 9EA9 BD81:1107-116E-11A8 5317 BD84:1107-116E-11AB 5206 5429 5674 58B3 5954 596E 5FFF 61A4 626E 6610 6C7E 711A 76C6 7C89 7CDE 7D1B 82AC 8CC1 96F0 4F53 574C 5E09 678C 68FB 68FC 6C1B 6E53 6FC6 7287 755A 780F 7B28 80A6 81B9 8561 8F52 9EFA 9F22 BD88:1107-116E-11AF 4F5B 5F17 5F7F 62C2 5CAA 7953 7D31 8274 8300 97CD 9AF4 9EFB BD95:1107-116E-11BC 5D29 670B 68DA 787C 7E43 9D6C 580B 6F30 9B05 BE44:1107-1175 4E15 5099 5315 532A 5351 5983 5A62 5E87 60B2 618A 6249 6279 6590 6787 69A7 6BD4 6BD6 6BD7 6BD8 6CB8 7435 75FA 7812 7891 79D5 79D8 7C83 7DCB 7FE1 80A5 813E 81C2 83F2 871A 88E8 8AB9 8B6C 8CBB 9119 975E 98DB 9F3B 4EF3 4FFE 5255 572E 57E4 59A3 5C41 5EB3 60B1 68D0 6911 6C98 6DDD 6DE0 6FDE 72C9 72D2 75DE 75F9 7765 7955 7BE6 7D15 7F86 8153 8298 82BE 8406 84D6 868D 8C94 8D14 8F61 90B3 90EB 959F 9674 970F 97B4 9A11 9A1B 9AC0 9F19 BE48:1107-1175-11AB 56AC 5B2A 5F6C 658C 6AB3 6BAF 6D5C 6FF1 7015 725D 73AD 8CA7 8CD3 983B 5110 64EF 77C9 7E7D 81CF 860B 8C73 90A0 944C 9726 9870 9B02 9B22 BE59:1107-1175-11BC 6191 6C37 8058 9A01 51B0 51ED 51F4 5A09 C0AC:1109-1161 4E4D 4E8B 4E9B 4ED5 4F3A 4F3C 4F7F 4FDF 50FF 53F2 53F8 5506 55E3 56DB 58EB 5962 5A11 5BEB 5BFA 5C04 5DF3 5E2B 5F99 601D 6368 659C 65AF 67F6 67FB 68AD 6B7B 6C99 6CD7 6E23 7009 7345 7802 793E 7940 7960 79C1 7BE9 7D17 7D72 8086 820D 838E 84D1 86C7 88DF 8A50 8A5E 8B1D 8CDC 8D66 8FAD 90AA 98FC 99DF 9E9D 509E 525A 5378 548B 59D2 6942 69AD 6C5C 75E7 76B6 7AE2 7B25 7F37 8721 8997 99DB 9B66 9BCA 9C24 C0AD:1109-1161-11A8 524A 6714 69CA 720D 84B4 9460 C0B0:1109-1161-11AB 5098 522A 5C71 6563 6C55 73CA 7523 759D 7B97 849C 9178 9730 5277 59CD 5B7F 6A75 6F78 6F98 72FB 7E56 8A15 93DF 958A 6BFF C0B4:1109-1161-11AF 4E77 6492 6BBA 715E 85A9 C0BC:1109-1161-11B7 4E09 6749 68EE 6E17 829F 8518 886B 7CDD 91E4 9B16 C0BD:1109-1161-11B8 63F7 6F81 9212 98AF 5345 553C 6B43 7FE3 9364 9705 970E C0C1:1109-1161-11BC 4E0A 50B7 50CF 511F 5546 55AA 5617 5B40 5C19 5CE0 5E38 5E8A 5EA0 5EC2 60F3 6851 6A61 6E58 723D 7240 72C0 76F8 7965 7BB1 7FD4 88F3 89F4 8A73 8C61 8CDE 971C 587D 5F9C 664C 6BA4 751E 7DD7 939F 9859 9B3A C0C8:1109-1162 585E 74BD 8CFD 9C13 C0C9:1109-1162-11A8 55C7 7A61 7D22 8272 69ED 6FC7 7012 C0DD:1109-1162-11BC 7272 751F 7525 7B19 771A 924E C11C:1109-1165 5885 58FB 5DBC 5E8F 5EB6 5F90 6055 6292 637F 654D 6691 66D9 66F8 6816 68F2 7280 745E 7B6E 7D6E 7DD6 7F72 80E5 8212 85AF 897F 8A93 901D 92E4 9ECD 9F20 566C 5A7F 63DF 6495 6E51 6FA8 7D13 8021 82A7 924F C11D:1109-1165-11A8 5915 596D 5E2D 60DC 6614 6673 6790 6C50 6DC5 6F5F 77F3 78A9 84C6 91CB 932B 6670 77FD 814A 8203 8725 9250 9F2B C120:1109-1165-11AB 4ED9 50CA 5148 5584 5B0B 5BA3 6247 657E 65CB 6E32 717D 7401 7444 7487 74BF 766C 79AA 7DDA 7E55 7FA8 817A 81B3 8239 861A 87EC 8A75 8DE3 9078 9291 9425 994D 9BAE 58A1 5AD9 5C1F 5C20 5C73 6103 6B5A 71AF 7B45 7DAB 8B54 8B71 93C7 9A38 9C53 9C7B C124:1109-1165-11AF 5368 5C51 6954 6CC4 6D29 6E2B 820C 859B 893B 8A2D 8AAA 96EA 9F67 5070 5A9F 63F2 66AC 7207 789F 7A27 7D32 C12C:1109-1165-11B7 5261 66B9 6BB2 7E96 87FE 8D0D 9583 965D 5B45 61B8 647B 7752 8B6B 929B 97F1 C12D:1109-1165-11B8 651D 6D89 71EE 56C1 61FE 7044 8076 8EA1 9477 9873 C131:1109-1165-11BC 57CE 59D3 5BAC 6027 60FA 6210 661F 665F 7329 73F9 76DB 7701 7B6C 8056 8072 8165 8AA0 9192 7446 9A02 C138:1109-1166 4E16 52E2 6B72 6D17 7A05 7B39 7D30 8CB0 5E28 6D12 7E50 86FB C18C:1109-1169 53EC 562F 5851 5BB5 5C0F 5C11 5DE2 6240 6383 6414 662D 68B3 6CBC 6D88 6EAF 701F 70A4 71D2 7526 758F 758E 7619 7B11 7BE0 7C2B 7D20 7D39 852C 856D 8607 8A34 900D 9061 90B5 92B7 97F6 9A37 4F4B 4FCF 5372 55C9 57FD 5850 612C 634E 6A14 6CDD 7B71 7BBE 7E45 7FDB 8186 8258 86F8 8E08 9165 9704 9B48 9BB9 9C3A C18D:1109-1169-11A8 4FD7 5C6C 675F 6D91 7C9F 7E8C 8B16 8D16 901F 6D2C 906C C190:1109-1169-11AB 5B6B 5DFD 640D 84C0 905C 98E1 98E7 98F1 C194:1109-1169-11AF 7387 7AA3 87C0 C1A1:1109-1169-11BC 5B8B 609A 677E 6DDE 8A1F 8AA6 9001 980C 67D7 7AE6 9B06 C1C4:1109-116B 5237 7051 788E 9396 60E2 66EC 7463 C1E0:1109-116C 8870 91D7 C218:1109-116E 4FEE 53D7 55FD 56DA 5782 58FD 5AC2 5B88 5CAB 5CC0 5E25 6101 620D 624B 6388 641C 6536 6578 6A39 6B8A 6C34 6D19 6F31 71E7 72E9 7378 7407 74B2 7626 7761 79C0 7A57 7AEA 7CB9 7D8F 7DAC 7E61 7F9E 8129 8331 8490 84DA 85EA 8896 8AB0 8B90 8F38 9042 9083 916C 9296 92B9 968B 96A7 96A8 96D6 9700 9808 9996 9AD3 9B1A 53DF 552E 5ECB 666C 6BB3 6CC5 6EB2 6FC9 775F 7762 778D 795F 7C54 813A 8184 81B8 8B8E 8C4E 9672 98BC 9948 C219:1109-116E-11A8 53D4 587E 5919 5B70 5BBF 6DD1 6F5A 719F 7421 74B9 8085 83FD 4FF6 500F 5135 5A4C 6A5A 9A4C 9DEB C21C:1109-116E-11AB 5DE1 5F87 5FAA 6042 65EC 6812 696F 6A53 6B89 6D35 6DF3 73E3 76FE 77AC 7B4D 7D14 8123 821C 8340 84F4 8563 8A62 8AC4 9187 931E 9806 99B4 4F9A 72E5 76F9 7734 7D03 80AB 99E8 9B0A 9D89 C220:1109-116E-11AF 620C 8853 8FF0 9265 7D49 C22D:1109-116E-11BC 5D07 5D27 5D69 83D8 C26C:1109-1171 5005 6DEC 7120 C2AC:1109-1173-11AF 745F 819D 8768 8671 C2B5:1109-1173-11B8 6FD5 62FE 7FD2 8936 8972 6174 71A0 96B0 C2B9:1109-1173-11BC 4E1E 4E58 50E7 52DD 5347 627F 6607 7E69 8805 965E 584D 9B19 C2DC:1109-1175 4F8D 5319 5636 59CB 5AA4 5C38 5C4E 5C4D 5E02 5F11 6043 65BD 662F 6642 67BE 67F4 731C 77E2 793A 7FC5 8494 84CD 8996 8A66 8A69 8AE1 8C55 8C7A 5072 5155 53AE 557B 5852 5EDD 67B2 67F9 6F8C 7DE6 7FE4 8ADF 8AF0 8C49 91C3 9349 984B C2DD:1109-1175-11A8 57F4 5BD4 5F0F 606F 62ED 690D 6B96 6E5C 7184 7BD2 8755 8B58 8EFE 98DF 98FE 55B0 5AB3 683B C2E0:1109-1175-11AB 4F38 4F81 4FE1 547B 5A20 5BB8 613C 65B0 6668 71FC 7533 795E 7D33 814E 81E3 8398 85AA 85CE 8703 8A0A 8EAB 8F9B 8FC5 54C2 567A 56DF 59FA 6C5B 77E7 8124 8D10 9823 99EA C2E4:1109-1175-11AF 5931 5BA4 5BE6 6089 87CB 98CB C2EC:1109-1175-11B7 5BE9 5C0B 5FC3 6C81 6DF1 700B 751A 82AF 8AF6 68A3 6F6F 71D6 845A 9414 9C4F C2ED:1109-1175-11B8 4EC0 5341 8FBB C30D:110A-1161-11BC 96D9 C528:110A-1175 6C0F C544:110B-1161 4E9E 4FC4 5152 555E 5A25 5CE8 6211 7259 82BD 83AA 86FE 8859 8A1D 963F 96C5 9913 9D09 9D5D 4E2B 54E6 5A3F 5A40 5CE9 75B4 7811 7B0C 8FD3 930F 9D5E C545:110B-1161-11A8 580A 5CB3 5DBD 5E44 60E1 6115 63E1 6A02 6E25 9102 9354 984E 9C10 9F77 5053 537E 54A2 5594 5669 816D 843C 89A8 8AE4 9D9A 9F76 C548:110B-1161-11AB 5B89 5CB8 6309 664F 6848 773C 96C1 978D 9854 9B9F 6849 72B4 8D0B 9D08 C54C:110B-1161-11AF 65A1 8B01 8ECB 95BC 560E 621E 63E0 7A75 8A10 904F 981E 9D36 C554:110B-1161-11B7 5535 5CA9 5DD6 5EB5 6697 764C 83F4 95C7 557D 5A95 5D53 667B 8164 844A 84ED 8AF3 9837 99A3 9EEF C555:110B-1161-11B8 58D3 62BC 72CE 9D28 C559:110B-1161-11BC 4EF0 592E 600F 663B 6B83 79E7 9D26 536C 5771 6CF1 76CE 9785 C560:110B-1162 5393 54C0 57C3 5D16 611B 66D6 6DAF 788D 827E 9698 9744 50FE 5509 5540 566F 5A2D 5D15 6328 6371 6B38 6F04 7343 769A 775A 77B9 78D1 7919 8586 85F9 9749 9A03 C561:110B-1162-11A8 5384 627C 6396 6DB2 7E0A 814B 984D 545D 6239 6424 9628 C575:110B-1162-11BC 6AFB 7F4C 9DAF 9E1A 56B6 5AC8 7F43 9DEA C57C:110B-1163 4E5F 503B 51B6 591C 60F9 63F6 6930 723A 8036 91CE 57DC C57D:110B-1163-11A8 5F31 7D04 82E5 846F 84BB 85E5 8E8D 721A 79B4 7BDB 7C65 9470 9C2F 9DB8 9FA0 C591:110B-1163-11BC 4F6F 58E4 5B43 6059 63DA 6518 656D 6698 694A 6A23 6D0B 7001 716C 75D2 760D 79B3 7A70 7F8A 8944 8B93 91C0 967D 990A 5F89 6F3E 703C 70CA 7662 773B 8618 8F30 9472 98BA 9A64 C5B4:110B-1165 5704 5FA1 65BC 6F01 7600 79A6 8A9E 99AD 9B5A 9F6C 5709 6554 6DE4 98EB C5B5:110B-1165-11A8 5104 61B6 6291 6A8D 81C6 7E76 C5B8:110B-1165-11AB 5043 5830 5F66 7109 8A00 8AFA 50BF 533D 5AE3 8B9E 9122 9F34 9F39 C5BC:110B-1165-11AF 5B7C 8616 81EC C5C4:110B-1165-11B7 4FFA 513C 56B4 5944 63A9 6DF9 5D26 5E7F 66EE 7F68 9183 95B9 C5C5:110B-1165-11B8 5DAA 696D 5DAB 9134 C5D0:110B-1166 605A 66C0 C5D4:110B-1166-11AB 5186 C5EC:110B-1167 4E88 4F59 5982 6B5F 6C5D 74B5 7916 8207 8245 8339 8F3F 8F5D 9918 8201 C5ED:110B-1167-11A8 4EA6 57DF 5F79 6613 75AB 7E79 8B6F 9006 9A5B 5DA7 61CC 6DE2 95BE C5F0:110B-1167-11AB 56A5 5827 59F8 5A1F 5BB4 5EF6 6350 633B 693D 6C87 6CBF 6D8E 6D93 6DF5 6F14 70DF 7136 7159 71C3 71D5 784F 786F 7B75 7DE3 7E2F 884D 8EDF 925B 9CF6 5157 56E6 57CF 5B3F 6081 63BE 66E3 6ADE 6E37 81D9 839A 8735 8815 8B8C 9DF0 C5F4:110B-1167-11AF 6085 6D85 71B1 95B1 564E C5FC:110B-1167-11B7 53AD 67D3 708E 7130 7430 8276 82D2 95BB 9AE5 9E7D 5189 5869 61D5 624A 6ABF 6AB6 704E 7069 91C5 995C 9B58 9EF6 C5FD:110B-1167-11B8 66C4 71C1 8449 66C5 7180 7217 9768 C601:110B-1167-11BC 584B 5DB8 5F71 6620 668E 6979 69AE 6C38 6CF3 6E36 6F41 6FDA 701B 702F 7150 71DF 7370 745B 74D4 76C8 7A4E 7E93 82F1 8A60 8FCE 9348 9719 548F 5B34 5B30 6D67 6FF4 766D 78A4 7E08 8811 8D0F 90E2 97FA C608:110B-1168 4E42 502A 5208 53E1 66F3 6C6D 6FCA 730A 777F 7A62 82AE 85DD 8602 88D4 8A63 8B7D 8C6B 92B3 9713 9810 56C8 5ADB 62FD 639C 6798 7369 7768 7796 7E44 7FF3 82C5 854A 854B 8589 868B 873A 9BE2 9DD6 9E91 C624:110B-1169 4E94 4F0D 4FC9 50B2 5348 543E 5433 55DA 5862 58BA 5967 5A1B 5BE4 609F 61CA 6556 65FF 6664 68A7 6C5A 6FB3 70CF 71AC 7352 7B7D 8708 8AA4 9C32 9F07 4EF5 4FE3 5514 55F7 5641 572C 5AAA 5AEF 5FE4 6160 6342 6C59 7AB9 8071 8323 8956 8B37 8FC3 8FD5 9068 93CA 93D6 96A9 9A41 9F2F C625:110B-1169-11A8 5C4B 6C83 7344 7389 923A C628:110B-1169-11AB 6EAB 7465 761F 7A69 7E15 860A 5ABC 614D 6637 6C33 7185 8580 8F40 919E 97DE 9942 9C2E C62C:110B-1169-11AF 5140 55E2 8183 C639:110B-1169-11BC 58C5 64C1 74EE 7515 7670 7FC1 9095 96CD 9954 5581 5EF1 6EC3 7655 79BA 7F4B 84CA 96DD 9852 C640:110B-116A 6E26 74E6 7AA9 7AAA 81E5 86D9 8778 8A1B 54C7 56EE 5A50 6799 6D3C 7327 7A8A 8435 8B4C C644:110B-116A-11AB 5A49 5B8C 5B9B 68A1 6900 6D63 73A9 7413 742C 7897 7DE9 7FEB 8118 8155 839E 8C4C 962E 9811 5213 57B8 59A7 5C8F 5FE8 60CB 6DB4 76CC C648:110B-116A-11AF 66F0 C655:110B-116A-11BC 5F80 65FA 6789 6C6A 738B 5C2B 7007 8FEC C65C:110B-116B 502D 5A03 6B6A 77EE 5AA7 C678:110B-116C 5916 5D6C 5DCD 7325 754F 504E 5D34 5D54 6E28 7168 78A8 78C8 8075 9697 C694:110B-116D 50E5 51F9 582F 592D 5996 59DA 5BE5 5DA2 62D7 6416 6493 64FE 66DC 6A48 71FF 7464 7A88 7AAF 7E47 7E5E 8000 8170 87EF 8981 8B20 9059 9080 9952 5060 5593 5773 589D 5B08 5E7A 5FAD 5FBC 6B80 6F86 7945 7A7E 7A85 8558 9076 9DC2 C695:110B-116D-11A8 617E 6B32 6D74 7E1F 8925 8FB1 6EBD 84D0 C6A9:110B-116D-11BC 4FD1 50AD 5197 52C7 57C7 5889 5BB9 5EB8 6142 6995 6D8C 6E67 6EB6 7194 7462 7528 752C 8073 8338 84C9 8E0A 9394 93DE 509B 5B82 5D71 6175 6183 69E6 7867 8202 86F9 8E34 C6B0:110B-116E 4E8E 4F51 5076 512A 53C8 53CB 53F3 5B87 5BD3 5C24 611A 6182 65F4 725B 7397 7440 76C2 7950 7991 79B9 7D06 7FBD 828B 85D5 865E 8FC2 9047 90F5 91EA 9685 96E8 96E9 4E8F 4EB4 4FC1 504A 5401 5823 5D4E 5EBD 6745 75A3 76F1 7AFD 8026 8030 8B23 8E3D 935D 9E80 9E8C 9F72 C6B1:110B-116E-11A8 52D6 5F67 65ED 6631 682F 715C 7A36 90C1 980A 71E0 C6B4:110B-116E-11AB 4E91 6A52 6B9E 6F90 7189 8018 82B8 8553 904B 9695 96F2 97FB 60F2 6C84 7BD4 7D1C 9723 97F5 C6B8:110B-116E-11AF 851A 9B31 4E90 C6C5:110B-116E-11BC 718A 96C4 C6D0:110B-116F-11AB 5143 539F 54E1 5713 5712 57A3 5A9B 5AC4 5BC3 6028 613F 63F4 6C85 6D39 6E72 6E90 7230 733F 7457 82D1 8881 8F45 9060 9662 9858 9D1B 51A4 571C 676C 6965 7328 7DA9 82AB 8597 873F 8B1C 92FA 9A35 9D77 9EFF C6D4:110B-116F-11AF 6708 8D8A 925E 5216 7CA4 C704:110B-1171 4F4D 5049 50DE 5371 570D 59D4 5A01 5C09 6170 6690 6E2D 7232 744B 7DEF 80C3 840E 8466 853F 875F 885B 8918 8B02 9055 97CB 9B4F 559F 5E43 7152 71A8 75FF 8473 885E 8AC9 9036 95C8 97D9 97E1 9927 9AAA C720:110B-1172 4E73 4F91 5112 516A 552F 55A9 5B7A 5BA5 5E7C 5E7D 5EBE 60A0 60DF 6108 6109 63C4 6538 6709 67D4 67DA 6961 6962 6CB9 6D27 6E38 6FE1 7336 7337 745C 7531 7652 7DAD 81FE 8438 88D5 8A98 8ADB 8AED 8E30 8E42 904A 903E 907A 9149 91C9 936E 5198 5466 56FF 58DD 5E37 63C9 65BF 6CD1 7256 7609 7610 7AAC 7AB3 7C72 7CC5 7DCC 8174 83A0 8555 8564 86B0 86B4 8764 8915 8B89 900C 97A3 9BAA 9EDD 9F2C 9FA5 C721:110B-1172-11A8 5809 6BD3 8089 80B2 5125 C724:110B-1172-11AB 5141 596B 5C39 6F64 73A7 80E4 8D07 9217 958F 6600 92C6 C728:110B-1172-11AF 807F 6F4F 77DE C735:110B-1172-11BC 620E 701C 7D68 878D 72E8 C740:110B-1173-11AB 57A0 6069 6147 6BB7 8ABE 9280 96B1 542C 569A 5701 57BD 6196 6ABC 6EB5 72FA 73E2 766E 8A14 911E 9F57 C744:110B-1173-11AF 4E59 9CE6 C74C:110B-1173-11B7 541F 6DEB 852D 9670 97F3 98EE 5591 5D1F 5ED5 6114 972A C74D:110B-1173-11B8 63D6 6CE3 9091 6092 6339 6D65 C751:110B-1173-11BC 51DD 61C9 81BA 9DF9 C758:110B-1174 4F9D 501A 5100 5B9C 610F 61FF 64EC 6905 6BC5 7591 77E3 7FA9 8264 858F 87FB 8863 8ABC 8B70 91AB 5117 51D2 5293 5DB7 6B39 6F2A 7317 7912 8798 9950 C774:110B-1175 4E8C 4EE5 4F0A 5937 59E8 5DF2 5F1B 5F5B 6021 723E 73E5 7570 75CD 79FB 800C 8033 8084 82E1 8351 8CBD 8CB3 9087 98F4 990C 54BF 5768 5C14 5F5D 682E 6D1F 73C6 8A11 8A51 8FE4 96B6 C775:110B-1175-11A8 7037 76CA 7FCA 7FCC 7FFC 8B1A 5F0B 71A4 9DC1 C778:110B-1175-11AB 4EBA 4EC1 5203 5370 54BD 56E0 59FB 5BC5 5F15 5FCD 6E6E 7D6A 8335 8693 8A8D 976D 9777 4EDE 5819 5924 5A63 6268 6C24 6D07 798B 7C7E 82A2 88C0 C77C:110B-1175-11AF 4E00 4F5A 4F7E 58F9 65E5 6EA2 9038 93B0 99B9 6CC6 8EFC C784:110B-1175-11B7 4EFB 58EC 598A 59D9 6041 7A14 834F 8CC3 7D4D 887D 928B 98EA C785:110B-1175-11B8 5165 5344 5EFF C789:110B-1175-11BC 4ECD 5269 5B55 82BF 5AB5 C790:110C-1161 4ED4 523A 54A8 59C9 59FF 5B50 5B57 5B5C 6063 6148 6ECB 7099 716E 7386 74F7 75B5 78C1 7D2B 8005 81EA 8328 8517 85C9 8AEE 8CC7 96CC 5470 5B28 5B56 5B76 67D8 6CDA 7278 7725 7726 7CA2 8014 80FE 8308 8332 83BF 8678 89DC 8A3E 8CB2 8D6D 93A1 983F 9AED 9B93 9DBF 9DD3 C791:110C-1161-11A8 4F5C 52FA 56BC 65AB 6628 707C 70B8 7235 7DBD 828D 914C 96C0 9D72 5C9D 600D 65B1 67DE 6C4B 712F 72B3 788F C794:110C-1161-11AB 5B71 68E7 6B98 6F7A 76DE 5257 6214 9A4F C7A0:110C-1161-11B7 5C91 66AB 6F5B 7BB4 7C2A 8836 6D94 6F5C 6FF3 C7A1:110C-1161-11B8 96DC 5361 56C3 7728 78FC 894D C7A5:110C-1161-11BC 4E08 4ED7 5320 5834 58BB 58EF 596C 5C07 5E33 5E84 5F35 638C 66B2 6756 6A1F 6AA3 6B0C 6F3F 7246 7350 748B 7AE0 7CA7 8178 81DF 81E7 838A 846C 8523 8594 85CF 88DD 8D13 91AC 9577 969C 50BD 5958 599D 5B19 5D82 5EE7 6215 6F33 7242 7634 7CDA 7F98 8407 88C5 8CEC 9123 93D8 9926 9E9E C7AC:110C-1162 518D 54C9 5728 5BB0 624D 6750 683D 6893 6E3D 6ED3 707D 7E21 88C1 8CA1 8F09 9F4B 9F4E 5908 5D3D 6257 699F 707E 7E94 C7C1:110C-1162-11BC 722D 7B8F 8ACD 931A 5D22 7319 7424 9397 C800:110C-1165 4F47 4F4E 5132 5480 59D0 5E95 62B5 6775 696E 6A17 6CAE 6E1A 72D9 732A 75BD 7BB8 7D35 82E7 83F9 8457 85F7 8A5B 8CAF 8E87 9019 90B8 96CE 9F5F 5B81 5CA8 677C 67E2 6C10 6F74 7026 7274 7F5D 7F9D 82F4 86C6 889B 891A 89DD 8A46 8C6C 967C C801:110C-1165-11A8 52E3 540A 5AE1 5BC2 6458 6575 6EF4 72C4 7684 7A4D 7B1B 7C4D 7E3E 7FDF 837B 8B2B 8CCA 8D64 8DE1 8E5F 8FEA 8FF9 9069 93D1 6A00 78E7 7CF4 83C2 89BF 9016 99B0 C804:110C-1165-11AB 4F43 4F7A 50B3 5168 5178 524D 526A 5861 587C 5960 5C08 5C55 5EDB 609B 6230 6813 6BBF 6C08 6FB1 714E 7420 7530 7538 7551 7672 7B4C 7B8B 7BAD 7BC6 7E8F 8A6E 8F3E 8F49 923F 9293 9322 942B 96FB 985A 986B 991E 542E 56C0 5AE5 5C47 5DD3 6229 63C3 65C3 6834 69C7 6E54 6FB6 724B 7471 750E 754B 7560 75CA 765C 78DA 7C5B 7FB6 7FE6 8146 819E 8343 8E94 8F07 9085 913D 92D1 932A 975B 9766 9853 98E6 9930 9B0B 9C63 9E07 C808:110C-1165-11AF 5207 622A 6298 6D59 7664 7ACA 7BC0 7D76 5C8A 6662 7A83 C810:110C-1165-11B7 5360 5CBE 5E97 6F38 70B9 7C98 9711 9B8E 9EDE 4F54 588A 73B7 7B18 7C1F 82EB 852A 86C5 8998 98AD 9ECF C811:110C-1165-11B8 63A5 647A 8776 6904 696A 8728 8DD5 8E40 9C08 C815:110C-1165-11BC 4E01 4E95 4EAD 505C 5075 5448 59C3 5B9A 5E40 5EAD 5EF7 5F81 60C5 633A 653F 6574 65CC 6676 6678 67FE 6968 6A89 6B63 6C40 6DC0 6DE8 6E1F 6E5E 701E 70A1 738E 73FD 753A 775B 7887 798E 7A0B 7A7D 7CBE 7D8E 8247 8A02 8AEA 8C9E 912D 914A 91D8 9266 92CC 9320 9706 9756 975C 9802 9F0E 4F42 53EE 5A67 5A77 6014 639F 686F 6883 68D6 706F 73F5 7594 7B73 839B 8A3C 9049 9172 92E5 975A C81C:110C-1166 5236 5291 557C 5824 5E1D 5F1F 608C 63D0 68AF 6FDF 796D 7B2C 81CD 85BA 88FD 8AF8 8E44 918D 9664 969B 973D 984C 9F4A 5115 5A23 64E0 7318 7445 7747 7994 7A0A 7DF9 8E36 8E4F 8E8B 9357 9684 97F2 9BA7 9BF7 C870:110C-1169 4FCE 5146 51CB 52A9 5632 5F14 5F6B 63AA 64CD 65E9 6641 66FA 66F9 671D 689D 68D7 69FD 6F15 6F6E 7167 71E5 722A 74AA 773A 7956 795A 79DF 7A20 7A95 7C97 7CDF 7D44 7E70 8087 85FB 86A4 8A54 8ABF 8D99 8E81 9020 906D 91E3 963B 96D5 9CE5 4F7B 50AE 5201 539D 5608 566A 5B25 5F82 61C6 627E 6B82 6FA1 7431 7681 7967 7AC8 7B0A 7CD9 7CF6 7D69 7D5B 80D9 81CA 825A 8526 8729 8A82 8B5F 921F 929A 92FD 9BDB 9D70 9F02 C871:110C-1169-11A8 65CF 7C07 8DB3 93C3 762F C874:110C-1169-11AB 5B58 5C0A 62F5 C878:110C-1169-11AF 5352 62D9 731D C885:110C-1169-11BC 5027 5B97 5F9E 60B0 616B 68D5 6DD9 742E 7A2E 7D42 7D9C 7E31 816B 8E2A 8E35 937E 9418 4F00 6152 67CA 6936 6A05 747D 7607 7CBD 87BD 8E64 C88C:110C-116A 4F50 5750 5DE6 5EA7 632B 5249 75E4 839D 9AFD C8C4:110C-116C 7F6A C8FC:110C-116E 4E3B 4F4F 4F8F 505A 59DD 80C4 546A 5468 55FE 594F 5B99 5DDE 5EDA 665D 6731 67F1 682A 6CE8 6D32 6E4A 6F8D 70B7 73E0 7587 7C4C 7D02 7D2C 7DA2 821F 86DB 8A3B 8A85 8D70 8E8A 8F33 9031 914E 9152 9444 99D0 4E1F 4F9C 5114 5C0C 5E6C 62C4 7843 7C52 8098 8160 851F 86C0 88EF 8A4B 8CD9 8D8E 8F08 9052 9252 970C 9714 9F04 C8FD:110C-116E-11A8 7AF9 7CA5 C900:110C-116E-11AB 4FCA 5101 51C6 57C8 5BEF 5CFB 6659 6A3D 6D5A 6E96 6FEC 710C 756F 7AE3 8822 9021 9075 96CB 99FF 5642 57FB 58AB 60F7 6499 76B4 7DA7 7F47 8E06 8E72 940F 96BC 9915 9C52 9D54 C904:110C-116E-11AF 8301 4E7C C911:110C-116E-11BC 4E2D 4EF2 8846 91CD 773E C989:110C-1173-11A8 537D 5373 559E C990:110C-1173-11AF 6ADB 9A2D C999:110C-1173-11B8 696B 6C41 847A 6A9D 857A C99D:110C-1173-11BC 589E 618E 66FE 62EF 70DD 7511 75C7 7E52 84B8 8B49 8D08 5D92 77F0 7F7E C9C0:110C-1175 4E4B 53EA 54AB 5730 5740 5FD7 6301 6307 646F 652F 65E8 667A 679D 67B3 6B62 6C60 6C9A 6F2C 77E5 7825 7949 7957 7D19 80A2 8102 81F3 829D 82B7 8718 8A8C 8D04 8DBE 9072 577B 5880 627A 69B0 6CDC 75E3 79EA 7BEA 8210 8E1F 8E93 8EF9 962F 9BA8 9DD9 C9C1:110C-1175-11A8 76F4 7A19 7A37 7E54 8077 799D C9C4:110C-1175-11AB 5507 55D4 5875 632F 6422 6649 664B 686D 699B 6B84 6D25 6EB1 73CD 7468 74A1 755B 75B9 76E1 771E 778B 79E6 7E09 7E1D 81FB 852F 8897 8A3A 8CD1 8EEB 8FB0 9032 93AD 9663 9673 9707 4FB2 5118 73D2 7A39 84C1 87B4 8D81 9241 9B12 C9C8:110C-1175-11AF 4F84 53F1 59EA 5AC9 5E19 684E 74C6 75BE 79E9 7A92 81A3 86ED 8CEA 8DCC 8FED 57A4 7D70 84BA 90C5 9455 C9D0:110C-1175-11B7 659F 6715 9D06 C9D1:110C-1175-11B8 57F7 6F57 7DDD 8F2F 93F6 96C6 54A0 6222 C9D5:110C-1175-11BC 5FB5 61F2 6F84 6F82 7013 7665 77AA CC28:110E-1161 4E14 4F98 501F 53C9 55DF 5D6F 5DEE 6B21 6B64 78CB 7B9A 8E49 8ECA 906E 4F7D 5056 5953 5C94 5FA3 69CE 7473 7868 CC29:110E-1161-11A8 6349 643E 7740 7A84 932F 947F 9F6A 6233 64C9 65B2 CC2C:110E-1161-11AB 64B0 6FAF 71E6 74A8 74DA 7AC4 7C12 7E82 7CB2 7E98 8B9A 8D0A 947D 9910 994C 5127 5139 5297 5DD1 6522 6B11 7228 8DB2 CC30:110E-1161-11AF 5239 5BDF 64E6 672D 7D2E 624E 62F6 CC38:110E-1161-11B7 50ED 53C3 5879 6158 6159 61FA 65AC 7AD9 8B92 8B96 5133 53C5 5D84 5DC9 615A 61AF 6519 69E7 6B03 6BDA 8B56 93E8 9471 995E 9A42 9EF2 CC3D:110E-1161-11BC 5009 5021 5275 5531 5A3C 5EE0 5F70 6134 655E 660C 6636 66A2 69CD 6EC4 6F32 7316 7621 7A93 8139 8259 83D6 84BC 5000 5096 51D4 5231 60B5 60DD 6227 6436 6919 6C05 7472 7A97 7ABB 8E4C 92F9 9306 95B6 9B2F 9DAC CC44:110E-1162 50B5 57F0 5BC0 5BE8 5F69 63A1 7826 7DB5 83DC 8521 91C7 91F5 68CC 831D CC45:110E-1162-11A8 518A 67F5 7B56 8CAC 5616 5E58 78D4 7B27 7C00 86B1 CC98:110E-1165 51C4 59BB 60BD 8655 6DD2 840B 8904 89B7 90EA CC99:110E-1165-11A8 501C 5254 5C3A 617D 621A 62D3 64F2 65A5 6ECC 7620 810A 8E60 965F 96BB 544E 5767 5849 60D5 6357 646D 8734 8DD6 8E91 CC9C:110E-1165-11AB 4EDF 5343 5598 5929 5DDD 64C5 6CC9 6DFA 7394 7A7F 821B 85A6 8CE4 8E10 9077 91E7 95E1 9621 97C6 4FF4 5029 50E2 5103 6D0A 6FFA 74E9 7946 7C81 81F6 828A 831C 8350 84A8 8546 8695 8FBF 975D CCA0:110E-1165-11AF 51F8 54F2 5586 5FB9 64A4 6F88 7DB4 8F1F 8F4D 9435 525F 555C 57D1 60D9 6387 6B60 9295 9323 98FB 992E CCA8:110E-1165-11B7 50C9 5C16 6CBE 6DFB 751B 77BB 7C3D 7C64 8A79 8AC2 5E68 5FDD 60C9 6A90 6AFC 7038 7C37 895C CCA9:110E-1165-11B8 581E 59BE 5E16 6377 7252 758A 776B 8ADC 8CBC 8F12 5022 546B 558B 6017 893A CCAD:110E-1165-11BC 5EF3 6674 6DF8 807D 83C1 8ACB 9751 9BD6 51CA 570A 873B 9D84 CCB4:110E-1166 5243 66FF 6D95 6EEF 7DE0 8AE6 902E 905E 9AD4 568F 5F58 68E3 6BA2 780C 8482 8515 855E 8EC6 9746 9AF0 CD08:110E-1169 521D 527F 54E8 6194 6284 62DB 68A2 6912 695A 6A35 7092 7126 785D 7901 790E 79D2 7A0D 8096 8278 82D5 8349 8549 8C82 8D85 9162 918B 91AE 5062 50EC 52AD 52E6 564D 5AF6 5CA7 5CED 5D95 600A 6084 6100 676A 71CB 7D83 8016 8A9A 8B59 8DA0 8EFA 8FE2 9214 936B 936C 9798 9866 9AEB 9DE6 9F60 CD09:110E-1169-11A8 4FC3 56D1 71ED 77D7 8700 89F8 66EF 7225 77DA 85A5 8E85 9AD1 CD0C:110E-1169-11AB 5BF8 5FD6 6751 90A8 540B CD1D:110E-1169-11BC 53E2 585A 5BF5 60A4 6181 6460 7E3D 8070 8525 9283 8471 84EF 93E6 9A18 9A44 CD2C:110E-116A-11AF 64AE CD5C:110E-116C 50AC 5D14 6700 562C 6467 69B1 6F3C 7480 78EA 7E17 8127 CD94:110E-116E 589C 62BD 63A8 690E 6978 6A1E 6E6B 76BA 79CB 82BB 8429 8ACF 8DA8 8FFD 9112 914B 919C 9310 9318 939A 96DB 9A36 9C0D 50E6 557E 5A35 5E1A 60C6 6376 63EB 6425 7503 7633 9F9D 7B92 7BA0 7C09 7E0B 7E10 84AD 966C 96B9 97A6 9A05 9B4B 9C0C 9D7B 9D96 9DB5 9E84 9EA4 CD95:110E-116E-11A8 4E11 755C 795D 7AFA 7B51 7BC9 7E2E 84C4 8E59 8E74 8EF8 9010 59AF 8233 8C56 8E5C 9F00 CD98:110E-116E-11AB 6625 693F 7443 CD9C:110E-116E-11AF 51FA 672E 9EDC 79EB CDA9:110E-116E-11BC 5145 5FE0 6C96 87F2 885D 8877 51B2 5FE1 73EB CDCC:110E-1170 60B4 81B5 8403 8D05 60F4 63E3 75A9 7601 9847 CDE8:110E-1171 53D6 5439 5634 5A36 5C31 708A 7FE0 805A 8106 81ED 8DA3 9189 9A5F 9DF2 51A3 6A47 6BF3 CE21:110E-1173-11A8 5074 4EC4 53A0 60FB 6E2C 5EC1 6603 CE35:110E-1173-11BC 5C64 CE58:110E-1175 4F88 5024 55E4 5CD9 5E5F 6065 6894 6CBB 6DC4 71BE 75D4 75F4 7661 7A1A 7A49 7DC7 7DFB 7F6E 81F4 86A9 8F1C 96C9 99B3 9F52 536E 54C6 5BD8 5DF5 7564 75D3 7D7A 83D1 8599 892B 8C78 8DF1 9319 9624 9BD4 9D19 9D1F 9D44 CE59:110E-1175-11A8 5247 52C5 98ED 6555 CE5C:110E-1175-11AB 89AA 6AEC 85FD 896F 9F54 CE60:110E-1175-11AF 4E03 67D2 6F06 CE68:110E-1175-11B7 4FB5 5BE2 6795 6C88 6D78 741B 7827 91DD 937C 5BD6 5FF1 6939 6C89 90F4 92DF 99F8 CE69:110E-1175-11B8 87C4 CE6D:110E-1175-11BC 79E4 7A31 CF8C:110F-116B 5FEB 5672 592C D0C0:1110-1161 4ED6 54A4 553E 58AE 59A5 60F0 6253 62D6 6736 6955 8235 9640 99B1 99DD 4F57 579E 62D5 67C1 6A62 6CB1 8A6B 8DCE 8EB1 99DE 9B80 9D15 9F09 D0C1:1110-1161-11A8 502C 5353 5544 577C 6258 64E2 666B 67DD 6FC1 6FEF 7422 7438 8A17 9438 62C6 6A50 6CB0 6DBF 77FA 7C5C 8600 8E14 9034 D0C4:1110-1161-11AB 5451 5606 5766 5F48 619A 6B4E 7058 70AD 7DBB 8A95 61BB 6524 6BAB 7671 9A52 D0C8:1110-1161-11AF 596A 812B 4FBB D0D0:1110-1161-11B7 63A2 7708 803D 8CAA 55FF 5FD0 9156 D0D1:1110-1161-11B8 5854 642D 69BB 509D 584C 6428 D0D5:1110-1161-11BC 5B95 5E11 6E6F 8569 71D9 76EA 78AD 862F D0DC:1110-1162 514C 53F0 592A 6020 614B 6B86 6C70 6CF0 7B1E 80CE 82D4 8DC6 90B0 98B1 57ED 5A27 5B61 62AC 8FE8 99C4 99D8 D0DD:1110-1162-11A8 64C7 6FA4 D0F1:1110-1162-11BC 6491 6490 725A D130:1110-1165 6504 D1A0:1110-1169 514E 5410 571F 8A0E D1A4:1110-1169-11AB 564B 5678 74F2 D1B5:1110-1169-11BC 615F 6876 75DB 7B52 7D71 901A 606B 6A0B 7B69 D1F4:1110-116C 5806 69CC 817F 892A 9000 9839 96A4 D22C:1110-116E 5078 5957 59AC 6295 900F 9B2A 5992 6E1D 9AB0 D241:1110-116E-11BC 4F5F D2B9:1110-1173-11A8 615D 7279 5FD2 D2C8:1110-1173-11B7 95D6 D30C:1111-1161 5761 5A46 5DF4 628A 64AD 64FA 6777 6CE2 6D3E 722C 7436 7834 7F77 82AD 8DDB 9817 53F5 5991 5CA5 6015 705E 7238 73BB 76A4 7B06 7C38 8019 83E0 8469 9131 D310:1111-1161-11AB 5224 5742 677F 7248 74E3 8CA9 8FA6 9211 962A 6C74 D314:1111-1161-11AF 516B 53ED 634C 6733 6C43 D328:1111-1162 4F69 5504 6096 6557 6C9B 6D7F 724C 72FD 7A17 8987 8C9D 5B5B 65C6 73EE 9708 9738 D33D:1111-1162-11BC 5F6D 6F8E 70F9 81A8 7830 794A 87DA 87DB D345:1111-1163-11A8 610E D3B8:1111-1167-11AB 4FBF 504F 6241 7247 7BC7 7DE8 7FE9 904D 97AD 9A19 533E 5FA7 60FC 7DF6 8251 8439 8759 890A 8ADE D3C4:1111-1167-11B7 8CB6 782D 7A86 D3C9:1111-1167-11BC 576A 5E73 67B0 840D 8A55 6026 62A8 6CD9 82F9 84F1 9B83 D3D0:1111-1168 5420 5B16 5E63 5EE2 5F0A 6583 80BA 853D 9589 965B 655D 72F4 7358 7648 D3EC:1111-1169 4F48 5305 530D 530F 5486 54FA 5703 5E03 6016 629B 62B1 6355 6CE1 6D66 75B1 7832 80DE 812F 82DE 8461 84B2 888D 8912 900B 92EA 98FD 9B91 5124 5E96 6661 66D3 70AE 70B0 8216 8AA7 924B 9784 9914 9BC6 D3ED:1111-1169-11A8 5E45 66B4 66DD 7011 7206 D45C:1111-116D 4FF5 527D 5F6A 6153 6753 6A19 6F02 74E2 7968 8868 8C79 98C7 98C4 9A43 50C4 52E1 560C 5AD6 647D 6B8D 719B 7E39 88F1 93E2 9463 9ADF 9C3E D488:1111-116E-11B7 54C1 7A1F 7980 D48D:1111-116E-11BC 6953 8AF7 8C4A 98A8 99AE 760B 8451 D53C:1111-1175 5F7C 62AB 75B2 76AE 88AB 907F 9642 8A56 8F9F 9781 9AF2 D53D:1111-1175-11A8 8177 D544:1111-1175-11AF 5339 5F3C 5FC5 6CCC 73CC 7562 758B 7B46 82FE 999D 4F56 5487 6EED 7BF3 7F7C 84FD 89F1 8E55 97B8 97E0 99DC 9D6F D54D:1111-1175-11B8 4E4F 903C 506A D558:1112-1161 4E0B 4F55 53A6 590F 5EC8 6630 6CB3 7455 8377 8766 8CC0 9050 971E 9C15 5440 5687 5C88 61D7 7146 7615 7F45 935C D559:1112-1161-11A8 58D1 5B78 8650 8B14 9DB4 72E2 7627 76AC 786E 90DD 9DFD D55C:1112-1161-11AB 5BD2 6068 608D 65F1 6C57 6F22 6FA3 701A 7F55 7FF0 9591 9592 9650 97D3 50E9 5AFA 5AFB 634D 66B5 9588 99FB 9DF3 9F3E D560:1112-1161-11AF 5272 8F44 778E D568:1112-1161-11B7 51FD 542B 54B8 5563 558A 6ABB 6DB5 7DD8 8266 929C 9677 9E79 839F 83E1 8AF4 8F5E 95DE D569:1112-1161-11B8 5408 54C8 76D2 86E4 95A4 95D4 965C 530C 55D1 67D9 69BC 6E98 76CD 90C3 D56D:1112-1161-11BC 4EA2 4F09 59EE 5AE6 5DF7 6052 6297 676D 6841 6C86 6E2F 7F38 809B 822A 9805 592F 6046 7095 7F3F 980F D574:1112-1162 4EA5 5055 54B3 5793 595A 5B69 5BB3 61C8 6977 6D77 7023 87F9 89E3 8A72 8AE7 9082 99ED 9AB8 548D 5DB0 5EE8 6B2C 736C 744E 75CE 85A4 91A2 9826 9BAD D575:1112-1162-11A8 52BE 6838 7FEE 8988 D589:1112-1162-11BC 5016 5E78 674F 8347 884C 60BB D5A5:1112-1163-11BC 4EAB 5411 56AE 73E6 9115 97FF 9909 9957 9999 858C D5C8:1112-1165 5653 589F 865B 8A31 6B54 D5CC:1112-1165-11AB 61B2 6AF6 737B 8ED2 5DDA 5E70 6507 D5D0:1112-1165-11AF 6B47 D5D8:1112-1165-11B7 96AA 9A57 5DAE 736B 7381 D601:1112-1167-11A8 5955 7200 8D6B 9769 5F08 6D2B 7131 9B29 D604:1112-1167-11AB 4FD4 5CF4 5F26 61F8 665B 6CEB 70AB 7384 73B9 73FE 7729 774D 7D43 7D62 7E23 8237 8852 8CE2 9249 986F 5107 5B1B 6621 7404 75C3 770C 7E6F 7FFE 8706 8AA2 92D7 99FD D608:1112-1167-11AF 5B51 7A74 8840 9801 7D5C 8D90 D610:1112-1167-11B7 5ACC D611:1112-1167-11B8 4FE0 5354 593E 5CFD 633E 6D79 72F9 8105 8107 83A2 92CF 9830 5327 53F6 57C9 604A 608F 611C 7BCB D615:1112-1167-11BC 4EA8 5144 5211 578B 5F62 6CC2 6ECE 7005 7050 70AF 7192 73E9 7469 834A 87A2 8861 9008 90A2 93A3 99A8 5910 5A19 8A57 8FE5 9658 D61C:1112-1168 516E 5F57 60E0 6167 66B3 8559 8E4A 91AF 978B 5092 5612 5BED 5FAF 69E5 76FB 8B11 8B7F D638:1112-1169 4E4E 4E92 547C 58D5 58FA 597D 5CB5 5F27 6236 6248 660A 6667 6BEB 6D69 6DCF 6E56 6EF8 6F94 6FE0 6FE9 705D 72D0 7425 745A 74E0 7693 795C 7CCA 7E1E 80E1 82A6 846B 84BF 864E 865F 8774 8B77 8C6A 93AC 9800 9865 512B 51B1 5637 5AED 5AEE 6019 6C8D 6EC8 6EEC 7292 7322 769C 769E 7B8E 8055 9190 992C 9B0D D639:1112-1169-11A8 60D1 6216 9177 D63C:1112-1169-11AB 5A5A 660F 6DF7 6E3E 743F 9B42 5702 60DB 6EB7 711C 95BD D640:1112-1169-11AF 5FFD 60DA 7B0F 56EB D64D:1112-1169-11BC 54C4 5F18 6C5E 6CD3 6D2A 70D8 7D05 8679 8A0C 9D3B 664E 6F92 7BCA 9277 9B28 D654:1112-116A 5316 548C 5B05 6A3A 706B 7575 798D 79BE 82B1 83EF 8A71 8B41 8CA8 9774 4FF0 5629 5A72 64ED 756B 9A4A 9FA2 D655:1112-116A-11A8 64F4 652B 78BA 78BB 7A6B 77CD 77E1 792D 944A D658:1112-116A-11AB 4E38 559A 5950 5BA6 5E7B 60A3 63DB 6B61 6665 6853 6E19 7165 74B0 7D08 9084 9A69 9C25 5BF0 61FD 64D0 74DB 7696 7746 7D59 8C62 8F58 9370 9436 9B1F D65C:1112-116A-11AF 6D3B 6ED1 733E 8C41 95CA 86DE D669:1112-116A-11BC 51F0 5E4C 5FA8 604D 60F6 6130 614C 6643 6644 69A5 6CC1 6E5F 6EC9 6F62 714C 749C 7687 7BC1 7C27 8352 8757 9051 968D 9EC3 55A4 5A93 6033 745D 8093 8CBA 93A4 D68C:1112-116C 532F 56DE 5EFB 5F8A 6062 6094 61F7 6666 6703 6A9C 6DEE 6FAE 7070 736A 7E6A 81BE 8334 86D4 8AA8 8CC4 4F6A 6803 6D04 6ED9 76D4 8A7C 8FF4 982E 9C60 D68D:1112-116C-11A8 5283 7372 5684 D6A1:1112-116C-11BC 5B96 6A6B 9404 6F8B 921C 9ECC D6A8:1112-116D 54EE 5686 5B5D 6548 6585 66C9 689F 6D8D 6DC6 723B 80B4 9175 9A4D 509A 56C2 5D24 6BBD 7187 769B 8653 991A D6C4:1112-116E 4FAF 5019 539A 540E 543C 5589 55C5 5E3F 5F8C 673D 7166 73DD 9005 543D 55A3 5795 5820 6DB8 7334 7BCC 8A61 8B43 9157 9931 D6C8:1112-116E-11AB 52DB 52F3 5864 58CE 7104 718F 71FB 85B0 8A13 6688 66DB 720B 736F 7E81 8477 9442 D6CC:1112-116E-11AF 6B3B D6D9:1112-116E-11BC 85A8 D6E4:1112-116F-11AB 55A7 6684 714A 8431 70DC 8AE0 8AFC D6FC:1112-1170 5349 5599 6BC1 71EC 8294 866B 867A D718:1112-1171 5F59 5FBD 63EE 6689 7147 8AF1 8F1D 9EBE 649D 7FEC D734:1112-1172 4F11 643A 70CB 7566 8667 54BB 64D5 96B3 9AF9 9D42 D73C:1112-1172-11AF 6064 8B4E 9DF8 5379 D749:1112-1172-11BC 5147 51F6 5308 6D36 80F8 605F 80F7 D751:1112-1173-11A8 9ED1 D754:1112-1173-11AB 6615 6B23 7098 75D5 5F88 5FFB 6380 712E 8A22 91C1 D758:1112-1173-11AF 5403 5C79 7D07 8A16 4EE1 6C54 7599 8FC4 9F55 D760:1112-1173-11B7 6B20 6B3D 6B46 5EDE D761:1112-1173-11B8 5438 6070 6D3D 7FD5 564F 6B59 6F5D 7FD6 D765:1112-1173-11BC 8208 D76C:1112-1174 50D6 51DE 559C 566B 56CD 59EC 5B09 5E0C 6199 6198 6231 665E 66E6 7199 71B9 71BA 72A7 79A7 7A00 7FB2 54A5 550F 563B 6095 6232 66BF 6B37 71F9 7214 8C68 993C D790:1112-1175-11AF 8A70 72B5 7E88 896D 9821 9EE0 __END__ =head1 NAME Unicode::Collate::CJK::Korean - weighting CJK Unified Ideographs for Unicode::Collate =head1 SYNOPSIS use Unicode::Collate; use Unicode::Collate::CJK::Korean; my $collator = Unicode::Collate->new( overrideCJK => \&Unicode::Collate::CJK::Korean::weightKorean ); =head1 DESCRIPTION C<Unicode::Collate::CJK::Korean> provides C<weightKorean()>, that is adequate for C<overrideCJK> of C<Unicode::Collate> and makes tailoring of CJK Unified Ideographs in the order of CLDR's Korean ordering. =head1 SEE ALSO =over 4 =item CLDR - Unicode Common Locale Data Repository L<http://cldr.unicode.org/> =item Unicode Locale Data Markup Language (LDML) - UTS #35 L<http://www.unicode.org/reports/tr35/> =item L<Unicode::Collate> =item L<Unicode::Collate::Locale> =back =cut
31.184497
73
0.789642
ed662ddb3b9c6631eac7692832f7f71a88b94802
290,447
pm
Perl
KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/lib/Image/ExifTool/QuickTime.pm
rebplu/KOST-VAL
1537125425068d5faec3bc4f5263df715956ae76
[ "BSD-3-Clause-No-Nuclear-Warranty" ]
52
2016-01-19T11:04:42.000Z
2022-02-19T18:37:30.000Z
KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/lib/Image/ExifTool/QuickTime.pm
rebplu/KOST-VAL
1537125425068d5faec3bc4f5263df715956ae76
[ "BSD-3-Clause-No-Nuclear-Warranty" ]
126
2016-01-18T12:21:11.000Z
2022-03-24T22:10:26.000Z
KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/lib/Image/ExifTool/QuickTime.pm
rebplu/KOST-VAL
1537125425068d5faec3bc4f5263df715956ae76
[ "BSD-3-Clause-No-Nuclear-Warranty" ]
27
2016-01-30T10:50:58.000Z
2022-01-05T01:57:19.000Z
#------------------------------------------------------------------------------ # File: QuickTime.pm # # Description: Read QuickTime, MP4 and M4A meta information # # Revisions: 10/04/2005 - P. Harvey Created # 12/19/2005 - P. Harvey Added MP4 support # 09/22/2006 - P. Harvey Added M4A support # 07/27/2010 - P. Harvey Updated to 2010-05-03 QuickTime spec # # References: # # 1) http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html # 2) http://search.cpan.org/dist/MP4-Info-1.04/ # 3) http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt # 4) http://wiki.multimedia.cx/index.php?title=Apple_QuickTime # 5) ISO 14496-12 (http://read.pudn.com/downloads64/ebook/226547/ISO_base_media_file_format.pdf) # 6) ISO 14496-16 (http://www.iec-normen.de/previewpdf/info_isoiec14496-16%7Bed2.0%7Den.pdf) # 7) http://atomicparsley.sourceforge.net/mpeg-4files.html # 8) http://wiki.multimedia.cx/index.php?title=QuickTime_container # 9) http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart3.pdf (Oct 2008) # 10) http://code.google.com/p/mp4v2/wiki/iTunesMetadata # 11) http://www.canieti.com.mx/assets/files/1011/IEC_100_1384_DC.pdf # 12) QuickTime file format specification 2010-05-03 # 13) http://www.adobe.com/devnet/flv/pdf/video_file_format_spec_v10.pdf # 14) http://standards.iso.org/ittf/PubliclyAvailableStandards/c051533_ISO_IEC_14496-12_2008.zip # 15) http://getid3.sourceforge.net/source/module.audio-video.quicktime.phps # 16) http://qtra.apple.com/atoms.html # 17) http://www.etsi.org/deliver/etsi_ts/126200_126299/126244/10.01.00_60/ts_126244v100100p.pdf # 18) https://github.com/appsec-labs/iNalyzer/blob/master/scinfo.m # 19) http://nah6.com/~itsme/cvs-xdadevtools/iphone/tools/decodesinf.pl # 20) https://developer.apple.com/legacy/library/documentation/quicktime/reference/QT7-1_Update_Reference/QT7-1_Update_Reference.pdf # 21) Francois Bonzon private communication # 22) https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html #------------------------------------------------------------------------------ package Image::ExifTool::QuickTime; use strict; use vars qw($VERSION $AUTOLOAD); use Image::ExifTool qw(:DataAccess :Utils); use Image::ExifTool::Exif; use Image::ExifTool::GPS; $VERSION = '1.96'; sub FixWrongFormat($); sub ProcessMOV($$;$); sub ProcessKeys($$$); sub ProcessMetaData($$$); sub ProcessEncodingParams($$$); sub ProcessHybrid($$$); sub ProcessRights($$$); sub ConvertISO6709($); sub ConvertChapterList($); sub PrintChapter($); sub PrintGPSCoordinates($); sub UnpackLang($); sub WriteQuickTime($$$); sub WriteMOV($$); # MIME types for all entries in the ftypLookup with file extensions # (defaults to 'video/mp4' if not found in this lookup) my %mimeLookup = ( '3G2' => 'video/3gpp2', '3GP' => 'video/3gpp', AAX => 'audio/vnd.audible.aax', DVB => 'video/vnd.dvb.file', F4A => 'audio/mp4', F4B => 'audio/mp4', JP2 => 'image/jp2', JPM => 'image/jpm', JPX => 'image/jpx', M4A => 'audio/mp4', M4B => 'audio/mp4', M4P => 'audio/mp4', M4V => 'video/x-m4v', MOV => 'video/quicktime', MQV => 'video/quicktime', ); # look up file type from ftyp atom type, with MIME type in comment if known # (ref http://www.ftyps.com/) my %ftypLookup = ( '3g2a' => '3GPP2 Media (.3G2) compliant with 3GPP2 C.S0050-0 V1.0', # video/3gpp2 '3g2b' => '3GPP2 Media (.3G2) compliant with 3GPP2 C.S0050-A V1.0.0', # video/3gpp2 '3g2c' => '3GPP2 Media (.3G2) compliant with 3GPP2 C.S0050-B v1.0', # video/3gpp2 '3ge6' => '3GPP (.3GP) Release 6 MBMS Extended Presentations', # video/3gpp '3ge7' => '3GPP (.3GP) Release 7 MBMS Extended Presentations', # video/3gpp '3gg6' => '3GPP Release 6 General Profile', # video/3gpp '3gp1' => '3GPP Media (.3GP) Release 1 (probably non-existent)', # video/3gpp '3gp2' => '3GPP Media (.3GP) Release 2 (probably non-existent)', # video/3gpp '3gp3' => '3GPP Media (.3GP) Release 3 (probably non-existent)', # video/3gpp '3gp4' => '3GPP Media (.3GP) Release 4', # video/3gpp '3gp5' => '3GPP Media (.3GP) Release 5', # video/3gpp '3gp6' => '3GPP Media (.3GP) Release 6 Basic Profile', # video/3gpp '3gp6' => '3GPP Media (.3GP) Release 6 Progressive Download', # video/3gpp '3gp6' => '3GPP Media (.3GP) Release 6 Streaming Servers', # video/3gpp '3gs7' => '3GPP Media (.3GP) Release 7 Streaming Servers', # video/3gpp 'aax ' => 'Audible Enhanced Audiobook (.AAX)', #PH 'avc1' => 'MP4 Base w/ AVC ext [ISO 14496-12:2005]', # video/mp4 'CAEP' => 'Canon Digital Camera', 'caqv' => 'Casio Digital Camera', 'CDes' => 'Convergent Design', 'da0a' => 'DMB MAF w/ MPEG Layer II aud, MOT slides, DLS, JPG/PNG/MNG images', 'da0b' => 'DMB MAF, extending DA0A, with 3GPP timed text, DID, TVA, REL, IPMP', 'da1a' => 'DMB MAF audio with ER-BSAC audio, JPG/PNG/MNG images', 'da1b' => 'DMB MAF, extending da1a, with 3GPP timed text, DID, TVA, REL, IPMP', 'da2a' => 'DMB MAF aud w/ HE-AAC v2 aud, MOT slides, DLS, JPG/PNG/MNG images', 'da2b' => 'DMB MAF, extending da2a, with 3GPP timed text, DID, TVA, REL, IPMP', 'da3a' => 'DMB MAF aud with HE-AAC aud, JPG/PNG/MNG images', 'da3b' => 'DMB MAF, extending da3a w/ BIFS, 3GPP timed text, DID, TVA, REL, IPMP', 'dmb1' => 'DMB MAF supporting all the components defined in the specification', 'dmpf' => 'Digital Media Project', # various 'drc1' => 'Dirac (wavelet compression), encapsulated in ISO base media (MP4)', 'dv1a' => 'DMB MAF vid w/ AVC vid, ER-BSAC aud, BIFS, JPG/PNG/MNG images, TS', 'dv1b' => 'DMB MAF, extending dv1a, with 3GPP timed text, DID, TVA, REL, IPMP', 'dv2a' => 'DMB MAF vid w/ AVC vid, HE-AAC v2 aud, BIFS, JPG/PNG/MNG images, TS', 'dv2b' => 'DMB MAF, extending dv2a, with 3GPP timed text, DID, TVA, REL, IPMP', 'dv3a' => 'DMB MAF vid w/ AVC vid, HE-AAC aud, BIFS, JPG/PNG/MNG images, TS', 'dv3b' => 'DMB MAF, extending dv3a, with 3GPP timed text, DID, TVA, REL, IPMP', 'dvr1' => 'DVB (.DVB) over RTP', # video/vnd.dvb.file 'dvt1' => 'DVB (.DVB) over MPEG-2 Transport Stream', # video/vnd.dvb.file 'F4A ' => 'Audio for Adobe Flash Player 9+ (.F4A)', # audio/mp4 'F4B ' => 'Audio Book for Adobe Flash Player 9+ (.F4B)', # audio/mp4 'F4P ' => 'Protected Video for Adobe Flash Player 9+ (.F4P)', # video/mp4 'F4V ' => 'Video for Adobe Flash Player 9+ (.F4V)', # video/mp4 'isc2' => 'ISMACryp 2.0 Encrypted File', # ?/enc-isoff-generic 'iso2' => 'MP4 Base Media v2 [ISO 14496-12:2005]', # video/mp4 'isom' => 'MP4 Base Media v1 [IS0 14496-12:2003]', # video/mp4 'JP2 ' => 'JPEG 2000 Image (.JP2) [ISO 15444-1 ?]', # image/jp2 'JP20' => 'Unknown, from GPAC samples (prob non-existent)', 'jpm ' => 'JPEG 2000 Compound Image (.JPM) [ISO 15444-6]', # image/jpm 'jpx ' => 'JPEG 2000 with extensions (.JPX) [ISO 15444-2]', # image/jpx 'KDDI' => '3GPP2 EZmovie for KDDI 3G cellphones', # video/3gpp2 #LCAG => (found in CompatibleBrands of Leica MOV videos) 'M4A ' => 'Apple iTunes AAC-LC (.M4A) Audio', # audio/x-m4a 'M4B ' => 'Apple iTunes AAC-LC (.M4B) Audio Book', # audio/mp4 'M4P ' => 'Apple iTunes AAC-LC (.M4P) AES Protected Audio', # audio/mp4 'M4V ' => 'Apple iTunes Video (.M4V) Video', # video/x-m4v 'M4VH' => 'Apple TV (.M4V)', # video/x-m4v 'M4VP' => 'Apple iPhone (.M4V)', # video/x-m4v 'mj2s' => 'Motion JPEG 2000 [ISO 15444-3] Simple Profile', # video/mj2 'mjp2' => 'Motion JPEG 2000 [ISO 15444-3] General Profile', # video/mj2 'mmp4' => 'MPEG-4/3GPP Mobile Profile (.MP4/3GP) (for NTT)', # video/mp4 'mp21' => 'MPEG-21 [ISO/IEC 21000-9]', # various 'mp41' => 'MP4 v1 [ISO 14496-1:ch13]', # video/mp4 'mp42' => 'MP4 v2 [ISO 14496-14]', # video/mp4 'mp71' => 'MP4 w/ MPEG-7 Metadata [per ISO 14496-12]', # various 'MPPI' => 'Photo Player, MAF [ISO/IEC 23000-3]', # various 'mqt ' => 'Sony / Mobile QuickTime (.MQV) US Patent 7,477,830 (Sony Corp)', # video/quicktime 'MSNV' => 'MPEG-4 (.MP4) for SonyPSP', # audio/mp4 'NDAS' => 'MP4 v2 [ISO 14496-14] Nero Digital AAC Audio', # audio/mp4 'NDSC' => 'MPEG-4 (.MP4) Nero Cinema Profile', # video/mp4 'NDSH' => 'MPEG-4 (.MP4) Nero HDTV Profile', # video/mp4 'NDSM' => 'MPEG-4 (.MP4) Nero Mobile Profile', # video/mp4 'NDSP' => 'MPEG-4 (.MP4) Nero Portable Profile', # video/mp4 'NDSS' => 'MPEG-4 (.MP4) Nero Standard Profile', # video/mp4 'NDXC' => 'H.264/MPEG-4 AVC (.MP4) Nero Cinema Profile', # video/mp4 'NDXH' => 'H.264/MPEG-4 AVC (.MP4) Nero HDTV Profile', # video/mp4 'NDXM' => 'H.264/MPEG-4 AVC (.MP4) Nero Mobile Profile', # video/mp4 'NDXP' => 'H.264/MPEG-4 AVC (.MP4) Nero Portable Profile', # video/mp4 'NDXS' => 'H.264/MPEG-4 AVC (.MP4) Nero Standard Profile', # video/mp4 'odcf' => 'OMA DCF DRM Format 2.0 (OMA-TS-DRM-DCF-V2_0-20060303-A)', # various 'opf2' => 'OMA PDCF DRM Format 2.1 (OMA-TS-DRM-DCF-V2_1-20070724-C)', 'opx2' => 'OMA PDCF DRM + XBS extensions (OMA-TS-DRM_XBS-V1_0-20070529-C)', 'pana' => 'Panasonic Digital Camera', 'qt ' => 'Apple QuickTime (.MOV/QT)', # video/quicktime 'ROSS' => 'Ross Video', 'sdv ' => 'SD Memory Card Video', # various? 'ssc1' => 'Samsung stereoscopic, single stream', 'ssc2' => 'Samsung stereoscopic, dual stream', 'XAVC' => 'Sony XAVC', #PH ); # information for time/date-based tags (time zero is Jan 1, 1904) my %timeInfo = ( Notes => 'converted from UTC to local time if the QuickTimeUTC option is set', # It is not uncommon for brain-dead software to use the wrong time zero, # so assume a time zero of Jan 1, 1970 if the date is before this RawConv => q{ my $offset = (66 * 365 + 17) * 24 * 3600; return $val - $offset if $val >= $offset or $$self{OPTIONS}{QuickTimeUTC}; $self->WarnOnce('Patched incorrect time zero for QuickTime date/time tag',1) if $val; return $val; }, Shift => 'Time', Writable => 1, Permanent => 1, DelValue => 0, # Note: This value will be in UTC if generated by a system that is aware of the time zone ValueConv => 'ConvertUnixTime($val, $self->Options("QuickTimeUTC"))', ValueConvInv => 'GetUnixTime($val, $self->Options("QuickTimeUTC")) + (66 * 365 + 17) * 24 * 3600', PrintConv => '$self->ConvertDateTime($val)', PrintConvInv => '$self->InverseDateTime($val)', # (can't put Groups here because they aren't constant!) ); # information for duration tags my %durationInfo = ( ValueConv => '$$self{TimeScale} ? $val / $$self{TimeScale} : $val', PrintConv => '$$self{TimeScale} ? ConvertDuration($val) : $val', ); # handle unknown tags my %unknownInfo = ( Unknown => 1, ValueConv => '$val =~ /^([\x20-\x7e]*)\0*$/ ? $1 : \$val', ); # parsing for most of the 3gp udta language text boxes my %langText = ( RawConv => sub { my ($val, $self) = @_; return '<err>' unless length $val >= 6; my $lang = UnpackLang(Get16u(\$val, 4)); $lang = $lang ? "($lang) " : ''; $val = substr($val, 6); # isolate string $val = $self->Decode($val, 'UCS2') if $val =~ /^\xfe\xff/; return $lang . $val; }, ); # 4-character Vendor ID codes (ref PH) my %vendorID = ( appl => 'Apple', fe20 => 'Olympus (fe20)', # (FE200) FFMP => 'FFmpeg', 'GIC '=> 'General Imaging Co.', kdak => 'Kodak', KMPI => 'Konica-Minolta', leic => 'Leica', mino => 'Minolta', niko => 'Nikon', NIKO => 'Nikon', olym => 'Olympus', pana => 'Panasonic', pent => 'Pentax', pr01 => 'Olympus (pr01)', # (FE100,FE110,FE115) sany => 'Sanyo', 'SMI '=> 'Sorenson Media Inc.', ZORA => 'Zoran Corporation', 'AR.D'=> 'Parrot AR.Drone', ' KD '=> 'Kodak', # (FZ201) ); # QuickTime data atom encodings for string types (ref 12) my %stringEncoding = ( 1 => 'UTF8', 2 => 'UTF16', 3 => 'ShiftJIS', 4 => 'UTF8', 5 => 'UTF16', ); my %graphicsMode = ( # (ref http://homepage.mac.com/vanhoek/MovieGuts%20docs/64.html) 0x00 => 'srcCopy', 0x01 => 'srcOr', 0x02 => 'srcXor', 0x03 => 'srcBic', 0x04 => 'notSrcCopy', 0x05 => 'notSrcOr', 0x06 => 'notSrcXor', 0x07 => 'notSrcBic', 0x08 => 'patCopy', 0x09 => 'patOr', 0x0a => 'patXor', 0x0b => 'patBic', 0x0c => 'notPatCopy', 0x0d => 'notPatOr', 0x0e => 'notPatXor', 0x0f => 'notPatBic', 0x20 => 'blend', 0x21 => 'addPin', 0x22 => 'addOver', 0x23 => 'subPin', 0x24 => 'transparent', 0x25 => 'addMax', 0x26 => 'subOver', 0x27 => 'addMin', 0x31 => 'grayishTextOr', 0x32 => 'hilite', 0x40 => 'ditherCopy', # the following ref ISO/IEC 15444-3 0x100 => 'Alpha', 0x101 => 'White Alpha', 0x102 => 'Pre-multiplied Black Alpha', 0x110 => 'Component Alpha', ); # QuickTime atoms %Image::ExifTool::QuickTime::Main = ( PROCESS_PROC => \&ProcessMOV, WRITE_PROC => \&WriteQuickTime, GROUPS => { 2 => 'Video' }, NOTES => q{ The QuickTime format is used for many different types of audio, video and image files (most commonly, MOV and MP4 videos). Exiftool extracts standard meta information a variety of audio, video and image parameters, as well as proprietary information written by many camera models. Tags with a question mark after their name are not extracted unless the Unknown option is set. ExifTool has the ability to write/create XMP, and edit some date/time tags in QuickTime-format files. According to the specification, many QuickTime date/time tags should be stored as UTC. Unfortunately, digital cameras often store local time values instead (presumably because they don't know the time zone). For this reason, by default ExifTool does not assume a time zone for these values. However, if the QuickTimeUTC API option is set, then ExifTool will assume these values are properly stored as UTC, and will convert them to local time when extracting. See L<http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html> for the official specification. }, meta => { # 'meta' is found here in my Sony ILCE-7S MP4 sample - PH Name => 'Meta', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Meta', Start => 4, # skip 4-byte version number header }, }, free => [ { Name => 'KodakFree', # (found in Kodak M5370 MP4 videos) Condition => '$$valPt =~ /^\0\0\0.Seri/s', SubDirectory => { TagTable => 'Image::ExifTool::Kodak::Free' }, },{ Unknown => 1, Binary => 1, }, # (also Samsung WB750 uncompressed thumbnail data starting with "SDIC\0") ], # fre1 - 4 bytes: "june" (Kodak PixPro SP360) frea => { Name => 'Kodak_frea', SubDirectory => { TagTable => 'Image::ExifTool::Kodak::frea' }, }, skip => [ { Name => 'CanonSkip', Condition => '$$valPt =~ /^\0.{3}(CNDB|CNCV|CNMN|CNFV|CNTH|CNDM)/s', SubDirectory => { TagTable => 'Image::ExifTool::Canon::Skip' }, }, { Name => 'Skip', Unknown => 1, Binary => 1 }, ], wide => { Unknown => 1, Binary => 1 }, ftyp => { #MP4 Name => 'FileType', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::FileType' }, }, pnot => { Name => 'Preview', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Preview' }, }, PICT => { Name => 'PreviewPICT', Groups => { 2 => 'Preview' }, Binary => 1, }, pict => { #8 Name => 'PreviewPICT', Groups => { 2 => 'Preview' }, Binary => 1, }, moov => { Name => 'Movie', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Movie' }, }, mdat => { Name => 'MovieData', Unknown => 1, Binary => 1 }, 'mdat-size' => { Name => 'MovieDataSize', Notes => q{ not a real tag ID, this tag represents the size of the 'mdat' data in bytes and is used in the AvgBitrate calculation }, }, 'mdat-offset' => 'MovieDataOffset', junk => { Unknown => 1, Binary => 1 }, #8 uuid => [ { #9 (MP4 files) Name => 'XMP', # *** this is where ExifTool writes XMP in MP4 videos (as per XMP spec) *** Condition => '$$valPt=~/^\xbe\x7a\xcf\xcb\x97\xa9\x42\xe8\x9c\x71\x99\x94\x91\xe3\xaf\xac/', SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main', Start => 16, }, }, { #11 (MP4 files) Name => 'UUID-PROF', Condition => '$$valPt=~/^PROF!\xd2\x4f\xce\xbb\x88\x69\x5c\xfa\xc9\xc7\x40/', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Profile', Start => 24, # uid(16) + version(1) + flags(3) + count(4) }, }, { #PH (Flip MP4 files) Name => 'UUID-Flip', Condition => '$$valPt=~/^\x4a\xb0\x3b\x0f\x61\x8d\x40\x75\x82\xb2\xd9\xfa\xce\xd3\x5f\xf5/', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Flip', Start => 16, }, }, # "\x98\x7f\xa3\xdf\x2a\x85\x43\xc0\x8f\x8f\xd9\x7c\x47\x1e\x8e\xea" - unknown data in Flip videos { #8 Name => 'UUID-Unknown', %unknownInfo, }, ], _htc => { Name => 'HTCInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HTCInfo' }, }, udta => { Name => 'UserData', SubDirectory => { TagTable => 'Image::ExifTool::FLIR::UserData' }, }, thum => { #PH Name => 'ThumbnailImage', Groups => { 2 => 'Preview' }, Binary => 1, }, ardt => { #PH Name => 'ARDroneFile', ValueConv => 'length($val) > 4 ? substr($val,4) : $val', # remove length }, prrt => { #PH Name => 'ARDroneTelemetry', Notes => q{ telemetry information for each video frame: status1, status2, time, pitch, roll, yaw, speed, altitude }, ValueConv => q{ my $size = length $val; return \$val if $size < 12 or not $$self{OPTIONS}{Binary}; my $len = Get16u(\$val, 2); my $str = ''; SetByteOrder('II'); my $pos = 12; while ($pos + $len <= $size) { my $s1 = Get16u(\$val, $pos); # s2: 7=take-off?, 3=moving, 4=hovering, 9=landing?, 2=landed my $s2 = Get16u(\$val, $pos + 2); $str .= "$s1 $s2"; my $num = int(($len-4)/4); my ($i, $v); for ($i=0; $i<$num; ++$i) { my $pt = $pos + 4 + $i * 4; if ($i > 0 && $i < 4) { $v = GetFloat(\$val, $pt); # pitch/roll/yaw } else { $v = Get32u(\$val, $pt); # convert time to sec, and speed(NC)/altitude to metres $v /= 1000 if $i <= 5; } $str .= " $v"; } $str .= "\n"; $pos += $len; } SetByteOrder('MM'); return \$str; }, }, # meta - proprietary XML information written by some Flip cameras - PH ); # MPEG-4 'ftyp' atom # (ref http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html) %Image::ExifTool::QuickTime::FileType = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'int32u', 0 => { Name => 'MajorBrand', Format => 'undef[4]', PrintConv => \%ftypLookup, }, 1 => { Name => 'MinorVersion', Format => 'undef[4]', ValueConv => 'sprintf("%x.%x.%x", unpack("nCC", $val))', }, 2 => { Name => 'CompatibleBrands', Format => 'undef[$size-8]', # ignore any entry with a null, and return others as a list ValueConv => 'my @a=($val=~/.{4}/sg); @a=grep(!/\0/,@a); \@a', }, ); # proprietary HTC atom (HTC One MP4 video) %Image::ExifTool::QuickTime::HTCInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, NOTES => 'Tags written by some HTC camera phones.', slmt => { Name => 'Unknown_slmt', Unknown => 1, Format => 'int32u', # (observed values: 4) }, ); # atoms used in QTIF files %Image::ExifTool::QuickTime::ImageFile = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Image' }, NOTES => 'Tags used in QTIF QuickTime Image Files.', idsc => { Name => 'ImageDescription', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::ImageDesc' }, }, idat => { Name => 'ImageData', Binary => 1, }, iicc => { Name => 'ICC_Profile', SubDirectory => { TagTable => 'Image::ExifTool::ICC_Profile::Main' }, }, ); # image description data block %Image::ExifTool::QuickTime::ImageDesc = ( PROCESS_PROC => \&ProcessHybrid, VARS => { ID_LABEL => 'ID/Index' }, GROUPS => { 2 => 'Image' }, FORMAT => 'int16u', 2 => { Name => 'CompressorID', Format => 'string[4]', # not very useful since this isn't a complete list and name is given below # # ref http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html # PrintConv => { # cvid => 'Cinepak', # jpeg => 'JPEG', # 'smc '=> 'Graphics', # 'rle '=> 'Animation', # rpza => 'Apple Video', # kpcd => 'Kodak Photo CD', # 'png '=> 'Portable Network Graphics', # mjpa => 'Motion-JPEG (format A)', # mjpb => 'Motion-JPEG (format B)', # SVQ1 => 'Sorenson video, version 1', # SVQ3 => 'Sorenson video, version 3', # mp4v => 'MPEG-4 video', # 'dvc '=> 'NTSC DV-25 video', # dvcp => 'PAL DV-25 video', # 'gif '=> 'Compuserve Graphics Interchange Format', # h263 => 'H.263 video', # tiff => 'Tagged Image File Format', # 'raw '=> 'Uncompressed RGB', # '2vuY'=> "Uncompressed Y'CbCr, 3x8-bit 4:2:2 (2vuY)", # 'yuv2'=> "Uncompressed Y'CbCr, 3x8-bit 4:2:2 (yuv2)", # v308 => "Uncompressed Y'CbCr, 8-bit 4:4:4", # v408 => "Uncompressed Y'CbCr, 8-bit 4:4:4:4", # v216 => "Uncompressed Y'CbCr, 10, 12, 14, or 16-bit 4:2:2", # v410 => "Uncompressed Y'CbCr, 10-bit 4:4:4", # v210 => "Uncompressed Y'CbCr, 10-bit 4:2:2", # }, }, 10 => { Name => 'VendorID', Format => 'string[4]', RawConv => 'length $val ? $val : undef', PrintConv => \%vendorID, SeparateTable => 'VendorID', }, # 14 - ("Quality" in QuickTime docs) ?? 16 => 'SourceImageWidth', 17 => 'SourceImageHeight', 18 => { Name => 'XResolution', Format => 'fixed32u' }, 20 => { Name => 'YResolution', Format => 'fixed32u' }, # 24 => 'FrameCount', # always 1 (what good is this?) 25 => { Name => 'CompressorName', Format => 'string[32]', # (sometimes this is a Pascal string, and sometimes it is a C string) RawConv => q{ $val=substr($val,1,ord($1)) if $val=~/^([\0-\x1f])/ and ord($1)<length($val); length $val ? $val : undef; }, }, 41 => 'BitDepth', # # Observed offsets for child atoms of various CompressorID types: # # CompressorID Offset Child atoms # ----------- ------ ---------------- # avc1 86 avcC, btrt, colr, pasp, fiel, clap, svcC # mp4v 86 esds, pasp # s263 86 d263 # btrt => { Name => 'BitrateInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Bitrate' }, }, # Reference for fiel, colr, pasp, clap: # https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG9 fiel => { Name => 'VideoFieldOrder', ValueConv => 'join(" ", unpack("C*",$val))', PrintConv => [{ 1 => 'Progressive', 2 => '2:1 Interlaced', }], }, colr => { Name => 'ColorRepresentation', ValueConv => 'join(" ", substr($val,0,4), unpack("x4n*",$val))', }, pasp => { Name => 'PixelAspectRatio', ValueConv => 'join(":", unpack("N*",$val))', }, clap => { Name => 'CleanAperture', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::CleanAperture' }, }, # avcC - AVC configuration (ref http://thompsonng.blogspot.ca/2010/11/mp4-file-format-part-2.html) # hvcC - HEVC configuration # svcC - 7 bytes: 00 00 00 00 ff e0 00 # esds - elementary stream descriptor # d263 gama => { Name => 'Gamma', Format => 'fixed32u' }, # mjqt - default quantization table for MJPEG # mjht - default Huffman table for MJPEG ); # 'btrt' atom information (ref http://lists.freedesktop.org/archives/gstreamer-commits/2011-October/054459.html) %Image::ExifTool::QuickTime::Bitrate = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'int32u', PRIORITY => 0, # often filled with zeros 0 => 'BufferSize', 1 => 'MaxBitrate', 2 => 'AverageBitrate', ); # 'clap' atom information (ref https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG9) %Image::ExifTool::QuickTime::CleanAperture = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'rational64u', 0 => 'CleanApertureWidth', 1 => 'CleanApertureHeight', 2 => 'CleanApertureOffsetX', 3 => 'CleanApertureOffsetY', ); # preview data block %Image::ExifTool::QuickTime::Preview = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, GROUPS => { 2 => 'Image' }, FORMAT => 'int16u', 0 => { Name => 'PreviewDate', Format => 'int32u', Groups => { 2 => 'Time' }, %timeInfo, }, 2 => 'PreviewVersion', 3 => { Name => 'PreviewAtomType', Format => 'string[4]', }, 5 => 'PreviewAtomIndex', ); # movie atoms %Image::ExifTool::QuickTime::Movie = ( PROCESS_PROC => \&ProcessMOV, WRITE_PROC => \&WriteQuickTime, GROUPS => { 2 => 'Video' }, mvhd => { Name => 'MovieHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::MovieHeader' }, }, trak => { Name => 'Track', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Track' }, }, udta => { Name => 'UserData', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::UserData' }, }, meta => { # 'meta' is found here in my EX-F1 MOV sample - PH Name => 'Meta', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Meta' }, }, iods => { Name => 'InitialObjectDescriptor', Flags => ['Binary','Unknown'], }, uuid => [ { #11 (MP4 files) (also found in QuickTime::Track) Name => 'UUID-USMT', Condition => '$$valPt=~/^USMT!\xd2\x4f\xce\xbb\x88\x69\x5c\xfa\xc9\xc7\x40/', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::UserMedia', Start => 16, }, }, { #PH (Canon SX280) Name => 'UUID-Canon', Condition => '$$valPt=~/^\x85\xc0\xb6\x87\x82\x0f\x11\xe0\x81\x11\xf4\xce\x46\x2b\x6a\x48/', SubDirectory => { TagTable => 'Image::ExifTool::Canon::uuid', Start => 16, }, }, { Name => 'UUID-Unknown', %unknownInfo, }, ], cmov => { Name => 'CompressedMovie', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::CMovie' }, }, htka => { # (written by HTC One M8 in slow-motion 1280x720 video - PH) Name => 'HTCTrack', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Track' }, }, # prfl - Profile (ref 12) # clip - clipping --> contains crgn (clip region) (ref 12) # mvex - movie extends --> contains mehd (movie extends header), trex (track extends) (ref 14) # ICAT - 4 bytes: "6350" (Nikon CoolPix S6900) ); # movie header data block %Image::ExifTool::QuickTime::MovieHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'int32u', DATAMEMBER => [ 0, 1, 2, 3, 4 ], 0 => { Name => 'MovieHeaderVersion', Format => 'int8u', RawConv => '$$self{MovieHeaderVersion} = $val', }, 1 => { Name => 'CreateDate', Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if MovieHeaderVersion == 1 (ref 13) Hook => '$$self{MovieHeaderVersion} and $format = "int64u", $varSize += 4', }, 2 => { Name => 'ModifyDate', Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if MovieHeaderVersion == 1 (ref 13) Hook => '$$self{MovieHeaderVersion} and $format = "int64u", $varSize += 4', }, 3 => { Name => 'TimeScale', RawConv => '$$self{TimeScale} = $val', }, 4 => { Name => 'Duration', %durationInfo, # this is int64u if MovieHeaderVersion == 1 (ref 13) Hook => '$$self{MovieHeaderVersion} and $format = "int64u", $varSize += 4', }, 5 => { Name => 'PreferredRate', ValueConv => '$val / 0x10000', }, 6 => { Name => 'PreferredVolume', Format => 'int16u', ValueConv => '$val / 256', PrintConv => 'sprintf("%.2f%%", $val * 100)', }, 9 => { Name => 'MatrixStructure', Format => 'fixed32s[9]', # (the right column is fixed 2.30 instead of 16.16) ValueConv => q{ my @a = split ' ',$val; $_ /= 0x4000 foreach @a[2,5,8]; return "@a"; }, }, 18 => { Name => 'PreviewTime', %durationInfo }, 19 => { Name => 'PreviewDuration', %durationInfo }, 20 => { Name => 'PosterTime', %durationInfo }, 21 => { Name => 'SelectionTime', %durationInfo }, 22 => { Name => 'SelectionDuration',%durationInfo }, 23 => { Name => 'CurrentTime', %durationInfo }, 24 => 'NextTrackID', ); # track atoms %Image::ExifTool::QuickTime::Track = ( PROCESS_PROC => \&ProcessMOV, WRITE_PROC => \&WriteQuickTime, GROUPS => { 1 => 'Track#', 2 => 'Video' }, tkhd => { Name => 'TrackHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::TrackHeader' }, }, udta => { Name => 'UserData', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::UserData' }, }, mdia => { #MP4 Name => 'Media', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Media' }, }, meta => { #PH (MOV) Name => 'Meta', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Meta' }, }, tref => { Name => 'TrackRef', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::TrackRef' }, }, tapt => { Name => 'TrackAperture', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::TrackAperture' }, }, uuid => [ { #11 (MP4 files) (also found in QuickTime::Movie) Name => 'UUID-USMT', Condition => '$$valPt=~/^USMT!\xd2\x4f\xce\xbb\x88\x69\x5c\xfa\xc9\xc7\x40/', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::UserMedia', Start => 16, }, }, { Name => 'UUID-Unknown', %unknownInfo, }, ], # edts - edits --> contains elst (edit list) # clip - clipping --> contains crgn (clip region) # matt - track matt --> contains kmat (compressed matt) # load - track loading settings # imap - track input map --> contains ' in' --> contains ' ty', obid # prfl - Profile (ref 12) ); # track header data block %Image::ExifTool::QuickTime::TrackHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, GROUPS => { 1 => 'Track#', 2 => 'Video' }, FORMAT => 'int32u', DATAMEMBER => [ 0, 1, 2, 5 ], 0 => { Name => 'TrackHeaderVersion', Format => 'int8u', Priority => 0, RawConv => '$$self{TrackHeaderVersion} = $val', }, 1 => { Name => 'TrackCreateDate', Priority => 0, Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if TrackHeaderVersion == 1 (ref 13) Hook => '$$self{TrackHeaderVersion} and $format = "int64u", $varSize += 4', }, 2 => { Name => 'TrackModifyDate', Priority => 0, Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if TrackHeaderVersion == 1 (ref 13) Hook => '$$self{TrackHeaderVersion} and $format = "int64u", $varSize += 4', }, 3 => { Name => 'TrackID', Priority => 0, }, 5 => { Name => 'TrackDuration', Priority => 0, %durationInfo, # this is int64u if TrackHeaderVersion == 1 (ref 13) Hook => '$$self{TrackHeaderVersion} and $format = "int64u", $varSize += 4', }, 8 => { Name => 'TrackLayer', Format => 'int16u', Priority => 0, }, 9 => { Name => 'TrackVolume', Format => 'int16u', Priority => 0, ValueConv => '$val / 256', PrintConv => 'sprintf("%.2f%%", $val * 100)', }, 10 => { Name => 'MatrixStructure', Format => 'fixed32s[9]', # (the right column is fixed 2.30 instead of 16.16) ValueConv => q{ my @a = split ' ',$val; $_ /= 0x4000 foreach @a[2,5,8]; return "@a"; }, }, 19 => { Name => 'ImageWidth', Priority => 0, RawConv => \&FixWrongFormat, }, 20 => { Name => 'ImageHeight', Priority => 0, RawConv => \&FixWrongFormat, }, ); # user data atoms %Image::ExifTool::QuickTime::UserData = ( PROCESS_PROC => \&ProcessMOV, WRITE_PROC => \&WriteQuickTime, GROUPS => { 2 => 'Video' }, NOTES => q{ Tag ID's beginning with the copyright symbol (hex 0xa9) are multi-language text. Alternate language tags are accessed by adding a dash followed by the language/country code to the tag name. ExifTool will extract any multi-language user data tags found, even if they don't exist in this table. }, "\xa9cpy" => { Name => 'Copyright', Groups => { 2 => 'Author' } }, "\xa9day" => { Name => 'ContentCreateDate', Groups => { 2 => 'Time' }, # handle values in the form "2010-02-12T13:27:14-0800" (written by Apple iPhone) ValueConv => q{ require Image::ExifTool::XMP; $val = Image::ExifTool::XMP::ConvertXMPDate($val); $val =~ s/([-+]\d{2})(\d{2})$/$1:$2/; # add colon to timezone if necessary return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, "\xa9ART" => 'Artist', #PH (iTunes 8.0.2) "\xa9alb" => 'Album', #PH (iTunes 8.0.2) "\xa9arg" => 'Arranger', #12 "\xa9ark" => 'ArrangerKeywords', #12 "\xa9cmt" => 'Comment', #PH (iTunes 8.0.2) "\xa9cok" => 'ComposerKeywords', #12 "\xa9com" => 'Composer', #12 "\xa9dir" => 'Director', #12 "\xa9ed1" => 'Edit1', "\xa9ed2" => 'Edit2', "\xa9ed3" => 'Edit3', "\xa9ed4" => 'Edit4', "\xa9ed5" => 'Edit5', "\xa9ed6" => 'Edit6', "\xa9ed7" => 'Edit7', "\xa9ed8" => 'Edit8', "\xa9ed9" => 'Edit9', "\xa9fmt" => 'Format', "\xa9gen" => 'Genre', #PH (iTunes 8.0.2) "\xa9grp" => 'Grouping', #PH (NC) "\xa9inf" => 'Information', "\xa9isr" => 'ISRCCode', #12 "\xa9lab" => 'RecordLabelName', #12 "\xa9lal" => 'RecordLabelURL', #12 "\xa9lyr" => 'Lyrics', #PH (NC) "\xa9mak" => 'Make', #12 "\xa9mal" => 'MakerURL', #12 "\xa9mod" => 'Model', #PH "\xa9nam" => 'Title', #12 "\xa9pdk" => 'ProducerKeywords', #12 "\xa9phg" => 'RecordingCopyright', #12 "\xa9prd" => 'Producer', "\xa9prf" => 'Performers', "\xa9prk" => 'PerformerKeywords', #12 "\xa9prl" => 'PerformerURL', "\xa9dir" => 'Director', #12 "\xa9req" => 'Requirements', "\xa9snk" => 'SubtitleKeywords', #12 "\xa9snm" => 'Subtitle', #12 "\xa9src" => 'SourceCredits', #12 "\xa9swf" => 'SongWriter', #12 "\xa9swk" => 'SongWriterKeywords', #12 "\xa9swr" => 'SoftwareVersion', #12 "\xa9too" => 'Encoder', #PH (NC) "\xa9trk" => 'Track', #PH (NC) "\xa9wrt" => 'Composer', "\xa9xyz" => { #PH (iPhone 3GS) Name => 'GPSCoordinates', Groups => { 2 => 'Location' }, ValueConv => \&ConvertISO6709, PrintConv => \&PrintGPSCoordinates, }, # \xa9 tags written by DJI Phantom 3: (ref PH) # \xa9xsp - +0.00 # \xa9ysp - +0.00 # \xa9zsp - +0.00,+0.40 # \xa9fpt - -2.80,-0.80,-0.20,+0.20,+0.70,+6.50 # \xa9fyw - -160.70,-83.60,-4.30,+87.20,+125.90,+158.80, # \xa9frl - +1.60,-0.30,+0.40,+0.60,+2.50,+7.20 # \xa9gpt - -49.90,-17.50,+0.00 # \xa9gyw - -160.60,-83.40,-3.80,+87.60,+126.20,+158.00 (similar values to fyw) # \xa9grl - +0.00 # and the following entries don't have the proper 4-byte header for \xa9 tags: "\xa9dji" => { Name => 'UserData_dji', Format => 'undef', Binary => 1, Unknown => 1, Hidden => 1 }, "\xa9res" => { Name => 'UserData_res', Format => 'undef', Binary => 1, Unknown => 1, Hidden => 1 }, "\xa9uid" => { Name => 'UserData_uid', Format => 'undef', Binary => 1, Unknown => 1, Hidden => 1 }, "\xa9mdl" => { Name => 'Model', Format => 'string', Notes => 'non-standard-format DJI tag' }, # end DJI tags name => 'Name', WLOC => { Name => 'WindowLocation', Format => 'int16u', }, LOOP => { Name => 'LoopStyle', Format => 'int32u', PrintConv => { 1 => 'Normal', 2 => 'Palindromic', }, }, SelO => { Name => 'PlaySelection', Format => 'int8u', }, AllF => { Name => 'PlayAllFrames', Format => 'int8u', }, meta => { Name => 'Meta', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Meta', Start => 4, # must skip 4-byte version number header }, }, 'ptv '=> { Name => 'PrintToVideo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Video' }, }, hnti => { Name => 'HintInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HintInfo' }, }, hinf => { Name => 'HintTrackInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HintTrackInfo' }, }, hinv => 'HintVersion', #PH (guess) XMP_ => { #PH (Adobe CS3 Bridge) Name => 'XMP', # *** this is where ExifTool writes XMP in MOV videos (as per XMP spec) *** SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' }, }, # the following are 3gp tags, references: # http://atomicparsley.sourceforge.net # http://www.3gpp.org/ftp/tsg_sa/WG4_CODEC/TSGS4_25/Docs/ cprt => { Name => 'Copyright', %langText, Groups => { 2 => 'Author' } }, auth => { Name => 'Author', %langText, Groups => { 2 => 'Author' } }, titl => { Name => 'Title', %langText }, dscp => { Name => 'Description',%langText }, perf => { Name => 'Performer', %langText }, gnre => { Name => 'Genre', %langText }, albm => { Name => 'Album', %langText }, coll => { Name => 'CollectionName', %langText }, #17 rtng => { Name => 'Rating', # (4-byte flags, 4-char entity, 4-char criteria, 2-byte lang, string) RawConv => q{ return '<err>' unless length $val >= 14; my $str = 'Entity=' . substr($val,4,4) . ' Criteria=' . substr($val,8,4); $str =~ tr/\0-\x1f\x7f-\xff//d; # remove unprintable characters my $lang = Image::ExifTool::QuickTime::UnpackLang(Get16u(\$val, 12)); $lang = $lang ? "($lang) " : ''; $val = substr($val, 14); $val = $self->Decode($val, 'UCS2') if $val =~ /^\xfe\xff/; return $lang . $str . ' ' . $val; }, }, clsf => { Name => 'Classification', # (4-byte flags, 4-char entity, 2-byte index, 2-byte lang, string) RawConv => q{ return '<err>' unless length $val >= 12; my $str = 'Entity=' . substr($val,4,4) . ' Index=' . Get16u(\$val,8); $str =~ tr/\0-\x1f\x7f-\xff//d; # remove unprintable characters my $lang = Image::ExifTool::QuickTime::UnpackLang(Get16u(\$val, 10)); $lang = $lang ? "($lang) " : ''; $val = substr($val, 12); $val = $self->Decode($val, 'UCS2') if $val =~ /^\xfe\xff/; return $lang . $str . ' ' . $val; }, }, kywd => { Name => 'Keywords', # (4 byte flags, 2-byte lang, 1-byte count, count x pascal strings) RawConv => q{ return '<err>' unless length $val >= 7; my $lang = Image::ExifTool::QuickTime::UnpackLang(Get16u(\$val, 4)); $lang = $lang ? "($lang) " : ''; my $num = Get8u(\$val, 6); my ($i, @vals); my $pos = 7; for ($i=0; $i<$num; ++$i) { last if $pos >= length $val; my $len = Get8u(\$val, $pos++); last if $pos + $len > length $val; my $v = substr($val, $pos, $len); $v = $self->Decode($v, 'UCS2') if $v =~ /^\xfe\xff/; push @vals, $v; $pos += $len; } my $sep = $self->Options('ListSep'); return $lang . join($sep, @vals); }, }, loci => { Name => 'LocationInformation', Groups => { 2 => 'Location' }, # (4-byte flags, 2-byte lang, location string, 1-byte role, 4-byte fixed longitude, # 4-byte fixed latitude, 4-byte fixed altitude, body string, notes string) RawConv => q{ return '<err>' unless length $val >= 6; my $lang = Image::ExifTool::QuickTime::UnpackLang(Get16u(\$val, 4)); $lang = $lang ? "($lang) " : ''; $val = substr($val, 6); my $str; if ($val =~ /^\xfe\xff/) { $val =~ s/^(\xfe\xff(.{2})*?)\0\0//s or return '<err>'; $str = $self->Decode($1, 'UCS2'); } else { $val =~ s/^(.*?)\0//s or return '<err>'; $str = $1; } $str = '(none)' unless length $str; return '<err>' if length $val < 13; my $role = Get8u(\$val, 0); my $lon = GetFixed32s(\$val, 1); my $lat = GetFixed32s(\$val, 5); my $alt = GetFixed32s(\$val, 9); my $roleStr = {0=>'shooting',1=>'real',2=>'fictional',3=>'reserved'}->{$role}; $str .= ' Role=' . ($roleStr || "unknown($role)"); $str .= sprintf(' Lat=%.5f Lon=%.5f Alt=%.2f', $lat, $lon, $alt); $val = substr($val, 13); if ($val =~ s/^(\xfe\xff(.{2})*?)\0\0//s) { $str .= ' Body=' . $self->Decode($1, 'UCS2'); } elsif ($val =~ s/^(.*?)\0//s) { $str .= " Body=$1"; } if ($val =~ s/^(\xfe\xff(.{2})*?)\0\0//s) { $str .= ' Notes=' . $self->Decode($1, 'UCS2'); } elsif ($val =~ s/^(.*?)\0//s) { $str .= " Notes=$1"; } return $lang . $str; }, }, yrrc => { Name => 'Year', Groups => { 2 => 'Time' }, RawConv => 'length($val) >= 6 ? Get16u(\$val,4) : "<err>"', }, urat => { #17 Name => 'UserRating', RawConv => q{ return '<err>' unless length $val >= 8; return Get8u(\$val, 7); }, }, # tsel - TrackSelection (ref 17) # Apple tags (ref 16) angl => { Name => 'CameraAngle', Format => 'string' }, # (NC) clfn => { Name => 'ClipFileName', Format => 'string' }, # (NC) clid => { Name => 'ClipID', Format => 'string' }, # (NC) cmid => { Name => 'CameraID', Format => 'string' }, # (NC) cmnm => { # (NC) Name => 'Model', Description => 'Camera Model Name', Format => 'string', # (necessary to remove the trailing NULL) }, date => { # (NC) Name => 'DateTimeOriginal', Groups => { 2 => 'Time' }, ValueConv => q{ require Image::ExifTool::XMP; $val = Image::ExifTool::XMP::ConvertXMPDate($val); $val =~ s/([-+]\d{2})(\d{2})$/$1:$2/; # add colon to timezone if necessary return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, manu => { # (SX280) Name => 'Make', # (with Canon there are 6 unknown bytes before the model: "\0\0\0\0\x15\xc7") RawConv => '$val=~s/^\0{4}..//s; $val=~s/\0.*//; $val', }, modl => { # (Samsung GT-S8530, Canon SX280) Name => 'Model', Description => 'Camera Model Name', # (with Canon there are 6 unknown bytes before the model: "\0\0\0\0\x15\xc7") RawConv => '$val=~s/^\0{4}..//s; $val=~s/\0.*//; $val', }, reel => { Name => 'ReelName', Format => 'string' }, # (NC) scen => { Name => 'Scene', Format => 'string' }, # (NC) shot => { Name => 'ShotName', Format => 'string' }, # (NC) slno => { Name => 'SerialNumber', Format => 'string' }, # (NC) apmd => { Name => 'ApertureMode', Format => 'undef' }, #20 kgtt => { #http://lists.ffmpeg.org/pipermail/ffmpeg-devel-irc/2012-June/000707.html # 'TrackType' will expand to 'Track#Type' when found inside a track Name => 'TrackType', # set flag to process this as international text # even though the tag ID doesn't start with 0xa9 IText => 1, }, chpl => { # (Nero chapter list) Name => 'ChapterList', ValueConv => \&ConvertChapterList, PrintConv => \&PrintChapter, }, # ndrm - 7 bytes (0 0 0 1 0 0 0) Nero Digital Rights Management? (PH) # other non-Apple tags (ref 16) # hpix - HipixRichPicture (ref 16, HIPIX) # strk - sub-track information (ref 16, ISO) # # Manufacturer-specific metadata # TAGS => [ #PH # these tags were initially discovered in a Pentax movie, # but similar information is found in videos from other manufacturers { Name => 'FujiFilmTags', Condition => '$$valPt =~ /^FUJIFILM DIGITAL CAMERA\0/', SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::MOV', ByteOrder => 'LittleEndian', }, }, { Name => 'KodakTags', Condition => '$$valPt =~ /^EASTMAN KODAK COMPANY/', SubDirectory => { TagTable => 'Image::ExifTool::Kodak::MOV', ByteOrder => 'LittleEndian', }, }, { Name => 'KonicaMinoltaTags', Condition => '$$valPt =~ /^KONICA MINOLTA DIGITAL CAMERA/', SubDirectory => { TagTable => 'Image::ExifTool::Minolta::MOV1', ByteOrder => 'LittleEndian', }, }, { Name => 'MinoltaTags', Condition => '$$valPt =~ /^MINOLTA DIGITAL CAMERA/', SubDirectory => { TagTable => 'Image::ExifTool::Minolta::MOV2', ByteOrder => 'LittleEndian', }, }, { Name => 'NikonTags', Condition => '$$valPt =~ /^NIKON DIGITAL CAMERA\0/', SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MOV', ByteOrder => 'LittleEndian', }, }, { Name => 'OlympusTags1', Condition => '$$valPt =~ /^OLYMPUS DIGITAL CAMERA\0.{9}\x01\0/s', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::MOV1', ByteOrder => 'LittleEndian', }, }, { Name => 'OlympusTags2', Condition => '$$valPt =~ /^OLYMPUS DIGITAL CAMERA(?!\0.{21}\x0a\0{3})/s', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::MOV2', ByteOrder => 'LittleEndian', }, }, { Name => 'OlympusTags3', Condition => '$$valPt =~ /^OLYMPUS DIGITAL CAMERA\0/', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::MP4', ByteOrder => 'LittleEndian', }, }, { Name => 'OlympusTags4', Condition => '$$valPt =~ /^.{16}OLYM\0/s', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::MOV3', Start => 12, }, }, { Name => 'PentaxTags', Condition => '$$valPt =~ /^PENTAX DIGITAL CAMERA\0/', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::MOV', ByteOrder => 'LittleEndian', }, }, { Name => 'SamsungTags', Condition => '$$valPt =~ /^SAMSUNG DIGITAL CAMERA\0/', SubDirectory => { TagTable => 'Image::ExifTool::Samsung::MP4', ByteOrder => 'LittleEndian', }, }, { Name => 'SanyoMOV', Condition => q{ $$valPt =~ /^SANYO DIGITAL CAMERA\0/ and $self->{VALUE}->{FileType} eq "MOV" }, SubDirectory => { TagTable => 'Image::ExifTool::Sanyo::MOV', ByteOrder => 'LittleEndian', }, }, { Name => 'SanyoMP4', Condition => q{ $$valPt =~ /^SANYO DIGITAL CAMERA\0/ and $self->{VALUE}->{FileType} eq "MP4" }, SubDirectory => { TagTable => 'Image::ExifTool::Sanyo::MP4', ByteOrder => 'LittleEndian', }, }, { Name => 'UnknownTags', Unknown => 1, Binary => 1 }, ], # ---- Canon ---- CNCV => { Name => 'CompressorVersion', Format => 'string' }, #PH (5D Mark II) CNMN => { Name => 'Model', #PH (EOS 550D) Description => 'Camera Model Name', Format => 'string', # (necessary to remove the trailing NULL) }, CNFV => { Name => 'FirmwareVersion', Format => 'string' }, #PH (EOS 550D) CNTH => { #PH (PowerShot S95) Name => 'CanonCNTH', SubDirectory => { TagTable => 'Image::ExifTool::Canon::CNTH' }, }, CNOP => { #PH (7DmkII) Name => 'CanonCNOP', SubDirectory => { TagTable => 'Image::ExifTool::Canon::CNOP' }, }, # CNDB - 2112 bytes (550D) # CNDM - 4 bytes - 0xff,0xd8,0xff,0xd9 (S95) # CNDG - 10232 bytes, mostly zeros (N100) # ---- Casio ---- QVMI => { #PH Name => 'CasioQVMI', # Casio stores standard EXIF-format information in MOV videos (eg. EX-S880) SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main', ProcessProc => \&Image::ExifTool::Exif::ProcessExif, # (because ProcessMOV is default) DirName => 'IFD0', Multi => 0, # (no NextIFD pointer) Start => 10, ByteOrder => 'BigEndian', }, }, # ---- FujiFilm ---- FFMV => { #PH (FinePix HS20EXR) Name => 'FujiFilmFFMV', SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::FFMV' }, }, MVTG => { #PH (FinePix HS20EXR) Name => 'FujiFilmMVTG', SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main', ProcessProc => \&Image::ExifTool::Exif::ProcessExif, # (because ProcessMOV is default) DirName => 'IFD0', Start => 16, Base => '$start', ByteOrder => 'LittleEndian', }, }, # ---- GoPro ---- (ref PH) GoPr => 'GoProType', # (Hero3+) FIRM => 'FirmwareVersion', # (Hero4) LENS => 'LensSerialNumber', # (Hero4) CAME => { # (Hero4) Name => 'SerialNumberHash', Description => 'Camera Serial Number Hash', ValueConv => 'unpack("H*",$val)', }, # SETT? 12 bytes (Hero4) # MUID? 32 bytes (Hero4, starts with serial number hash) # HMMT? 404 bytes (Hero4, all zero) # free (all zero) # --- HTC ---- htcb => { Name => 'HTCBinary', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HTCBinary' }, }, # ---- Kodak ---- DcMD => { Name => 'KodakDcMD', SubDirectory => { TagTable => 'Image::ExifTool::Kodak::DcMD' }, }, # AMBA => Ambarella AVC atom (unknown data written by Kodak Playsport video cam) # tmlp - 1 byte: 0 (PixPro SP360) # pivi - 72 bytes (PixPro SP360) # pive - 12 bytes (PixPro SP360) # m ev - 2 bytes: 0 0 (PixPro SP360) # m wb - 4 bytes: 0 0 0 0 (PixPro SP360) # mclr - 4 bytes: 0 0 0 0 (PixPro SP360) # mmtr - 4 bytes: 6 0 0 0 (PixPro SP360) # mflr - 4 bytes: 0 0 0 0 (PixPro SP360) # lvlm - 24 bytes (PixPro SP360) # ufdm - 4 bytes: 0 0 0 1 (PixPro SP360) # mtdt - 1 byte: 0 (PixPro SP360) # gdta - 75240 bytes (PixPro SP360) # ---- LG ---- adzc => { Name => 'Unknown_adzc', Unknown => 1, Hidden => 1, %langText }, # "false\0/","true\0/" adze => { Name => 'Unknown_adze', Unknown => 1, Hidden => 1, %langText }, # "false\0/" adzm => { Name => 'Unknown_adzm', Unknown => 1, Hidden => 1, %langText }, # "\x0e\x04/","\x10\x06" # ---- Microsoft ---- Xtra => { #PH (microsoft) Name => 'MicrosoftXtra', SubDirectory => { TagTable => 'Image::ExifTool::Microsoft::Xtra' }, }, # ---- Minolta ---- MMA0 => { #PH (DiMage 7Hi) Name => 'MinoltaMMA0', SubDirectory => { TagTable => 'Image::ExifTool::Minolta::MMA' }, }, MMA1 => { #PH (Dimage A2) Name => 'MinoltaMMA1', SubDirectory => { TagTable => 'Image::ExifTool::Minolta::MMA' }, }, # ---- Nikon ---- NCDT => { #PH Name => 'NikonNCDT', SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDT' }, }, # ---- Olympus ---- scrn => { #PH (TG-810) Name => 'OlympusPreview', Condition => '$$valPt =~ /^.{4}\xff\xd8\xff\xdb/s', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::scrn' }, }, # ---- Panasonic/Leica ---- PANA => { #PH Name => 'PanasonicPANA', SubDirectory => { TagTable => 'Image::ExifTool::Panasonic::PANA' }, }, LEIC => { #PH Name => 'LeicaLEIC', SubDirectory => { TagTable => 'Image::ExifTool::Panasonic::PANA' }, }, # ---- Pentax ---- thmb => [ # (apparently defined by 3gpp, ref 16) { #PH (Pentax Q) Name => 'MakerNotePentax5a', Condition => '$$valPt =~ /^PENTAX \0II/', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::Main', ProcessProc => \&Image::ExifTool::Exif::ProcessExif, # (because ProcessMOV is default) Start => 10, Base => '$start - 10', ByteOrder => 'LittleEndian', }, },{ #PH (TG-810) Name => 'OlympusThumbnail', Condition => '$$valPt =~ /^.{4}\xff\xd8\xff\xdb/s', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::thmb' }, },{ #17 (format is in bytes 3-7) Name => 'ThumbnailImage', Condition => '$$valPt =~ /^.{8}\xff\xd8\xff\xdb/s', Groups => { 2 => 'Preview' }, ValueConv => 'substr($val, 8)', },{ #17 (format is in bytes 3-7) Name => 'ThumbnailPNG', Condition => '$$valPt =~ /^.{8}\x89PNG\r\n\x1a\n/s', Groups => { 2 => 'Preview' }, ValueConv => 'substr($val, 8)', },{ Name => 'UnknownThumbnail', Groups => { 2 => 'Preview' }, Binary => 1, }, ], PENT => { #PH Name => 'PentaxPENT', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::PENT', ByteOrder => 'LittleEndian', }, }, PXTH => { #PH (Pentax K-01) Name => 'PentaxPreview', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::PXTH' }, }, PXMN => [{ #PH (Pentax K-01) Name => 'MakerNotePentax5b', Condition => '$$valPt =~ /^PENTAX \0MM/', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::Main', ProcessProc => \&Image::ExifTool::Exif::ProcessExif, # (because ProcessMOV is default) Start => 10, Base => '$start - 10', ByteOrder => 'BigEndian', }, },{ #PH (Pentax 645Z) Name => 'MakerNotePentax5c', Condition => '$$valPt =~ /^PENTAX \0II/', SubDirectory => { TagTable => 'Image::ExifTool::Pentax::Main', ProcessProc => \&Image::ExifTool::Exif::ProcessExif, # (because ProcessMOV is default) Start => 10, Base => '$start - 10', ByteOrder => 'LittleEndian', }, },{ Name => 'MakerNotePentaxUnknown', Binary => 1, }], # ---- Ricoh ---- RTHU => { #PH (GR) Name => 'PreviewImage', Groups => { 2 => 'Preview' }, RawConv => '$self->ValidateImage(\$val, $tag)', }, RMKN => { #PH (GR) Name => 'RicohRMKN', SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main', ProcessProc => \&Image::ExifTool::ProcessTIFF, # (because ProcessMOV is default) }, }, # ---- Samsung ---- vndr => 'Vendor', #PH (Samsung PL70) SDLN => 'PlayMode', #PH (NC, Samsung ST80 "SEQ_PLAY") INFO => { Name => 'SamsungINFO', SubDirectory => { TagTable => 'Image::ExifTool::Samsung::INFO' }, }, '@sec' => { #PH (Samsung WB30F) Name => 'SamsungSec', SubDirectory => { TagTable => 'Image::ExifTool::Samsung::sec' }, }, 'smta' => { #PH (Samsung SM-C101) Name => 'SamsungSmta', SubDirectory => { TagTable => 'Image::ExifTool::Samsung::smta', Start => 4, }, }, cver => 'CodeVersion', #PH (guess, Samsung MV900F) # ducp - 4 bytes all zero (Samsung ST96,WB750), 52 bytes all zero (Samsung WB30F) # edli - 52 bytes all zero (Samsung WB30F) # @etc - 4 bytes all zero (Samsung WB30F) # saut - 4 bytes all zero (Samsung SM-N900T) # smrd - string "TRUEBLUE" (Samsung SM-C101) # ---- Unknown ---- # CDET - 128 bytes (unknown origin) # # other 3rd-party tags # (ref http://code.google.com/p/mp4parser/source/browse/trunk/isoparser/src/main/resources/isoparser-default.properties?r=814) # ccid => 'ContentID', icnu => 'IconURI', infu => 'InfoURL', cdis => 'ContentDistributorID', albr => { Name => 'AlbumArtist', Groups => { 2 => 'Author' } }, cvru => 'CoverURI', lrcu => 'LyricsURI', tags => { # found in Audible .m4b audio books (ref PH) Name => 'Audible_tags', SubDirectory => { TagTable => 'Image::ExifTool::Audible::tags' }, }, ); # Unknown information stored in HTC One (M8) videos - PH %Image::ExifTool::QuickTime::HTCBinary = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 0 => 'MakerNotes', 1 => 'HTC', 2 => 'Video' }, TAG_PREFIX => 'HTCBinary', FORMAT => 'int32u', FIRST_ENTRY => 0, # 0 - values: 1 # 1 - values: 0 # 2 - values: 0 # 3 - values: FileSize minus 12 (why?) # 4 - values: 12 ); # User-specific media data atoms (ref 11) %Image::ExifTool::QuickTime::UserMedia = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, MTDT => { Name => 'MetaData', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::MetaData' }, }, ); # User-specific media data atoms (ref 11) %Image::ExifTool::QuickTime::MetaData = ( PROCESS_PROC => \&Image::ExifTool::QuickTime::ProcessMetaData, GROUPS => { 2 => 'Video' }, TAG_PREFIX => 'MetaData', 0x01 => 'Title', 0x03 => { Name => 'ProductionDate', Groups => { 2 => 'Time' }, # translate from format "YYYY/mm/dd HH:MM:SS" ValueConv => '$val=~tr{/}{:}; $val', PrintConv => '$self->ConvertDateTime($val)', }, 0x04 => 'Software', 0x05 => 'Product', 0x0a => { Name => 'TrackProperty', RawConv => 'my @a=unpack("Nnn",$val); "@a"', PrintConv => [ { 0 => 'No presentation', BITMASK => { 0 => 'Main track' } }, { 0 => 'No attributes', BITMASK => { 15 => 'Read only' } }, '"Priority $val"', ], }, 0x0b => { Name => 'TimeZone', Groups => { 2 => 'Time' }, RawConv => 'Get16s(\$val,0)', PrintConv => 'TimeZoneString($val)', }, 0x0c => { Name => 'ModifyDate', Groups => { 2 => 'Time' }, # translate from format "YYYY/mm/dd HH:MM:SS" ValueConv => '$val=~tr{/}{:}; $val', PrintConv => '$self->ConvertDateTime($val)', }, ); # compressed movie atoms (ref http://wiki.multimedia.cx/index.php?title=QuickTime_container#cmov) %Image::ExifTool::QuickTime::CMovie = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, dcom => 'Compression', # cmvd - compressed movie data ); # Profile atoms (ref 11) %Image::ExifTool::QuickTime::Profile = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, FPRF => { Name => 'FileGlobalProfile', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::FileProf' }, }, APRF => { Name => 'AudioProfile', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::AudioProf' }, }, VPRF => { Name => 'VideoProfile', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::VideoProf' }, }, OLYM => { #PH Name => 'OlympusOLYM', SubDirectory => { TagTable => 'Image::ExifTool::Olympus::OLYM', ByteOrder => 'BigEndian', }, }, ); # FPRF atom information (ref 11) %Image::ExifTool::QuickTime::FileProf = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'int32u', 0 => { Name => 'FileProfileVersion', Unknown => 1 }, # unknown = uninteresting 1 => { Name => 'FileFunctionFlags', PrintConv => { BITMASK => { 28 => 'Fragmented', 29 => 'Additional tracks', 30 => 'Edited', # (main AV track is edited) }}, }, # 2 - reserved ); # APRF atom information (ref 11) %Image::ExifTool::QuickTime::AudioProf = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Audio' }, FORMAT => 'int32u', 0 => { Name => 'AudioProfileVersion', Unknown => 1 }, 1 => 'AudioTrackID', 2 => { Name => 'AudioCodec', Format => 'undef[4]', }, 3 => { Name => 'AudioCodecInfo', Unknown => 1, PrintConv => 'sprintf("0x%.4x", $val)', }, 4 => { Name => 'AudioAttributes', PrintConv => { BITMASK => { 0 => 'Encrypted', 1 => 'Variable bitrate', 2 => 'Dual mono', }}, }, 5 => { Name => 'AudioAvgBitrate', ValueConv => '$val * 1000', PrintConv => 'ConvertBitrate($val)', }, 6 => { Name => 'AudioMaxBitrate', ValueConv => '$val * 1000', PrintConv => 'ConvertBitrate($val)', }, 7 => 'AudioSampleRate', 8 => 'AudioChannels', ); # VPRF atom information (ref 11) %Image::ExifTool::QuickTime::VideoProf = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, FORMAT => 'int32u', 0 => { Name => 'VideoProfileVersion', Unknown => 1 }, 1 => 'VideoTrackID', 2 => { Name => 'VideoCodec', Format => 'undef[4]', }, 3 => { Name => 'VideoCodecInfo', Unknown => 1, PrintConv => 'sprintf("0x%.4x", $val)', }, 4 => { Name => 'VideoAttributes', PrintConv => { BITMASK => { 0 => 'Encrypted', 1 => 'Variable bitrate', 2 => 'Variable frame rate', 3 => 'Interlaced', }}, }, 5 => { Name => 'VideoAvgBitrate', ValueConv => '$val * 1000', PrintConv => 'ConvertBitrate($val)', }, 6 => { Name => 'VideoMaxBitrate', ValueConv => '$val * 1000', PrintConv => 'ConvertBitrate($val)', }, 7 => { Name => 'VideoAvgFrameRate', Format => 'fixed32u', PrintConv => 'int($val * 1000 + 0.5) / 1000', }, 8 => { Name => 'VideoMaxFrameRate', Format => 'fixed32u', PrintConv => 'int($val * 1000 + 0.5) / 1000', }, 9 => { Name => 'VideoSize', Format => 'int16u[2]', PrintConv => '$val=~tr/ /x/; $val', }, 10 => { Name => 'PixelAspectRatio', Format => 'int16u[2]', PrintConv => '$val=~tr/ /:/; $val', }, ); # meta atoms %Image::ExifTool::QuickTime::Meta = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, ilst => { Name => 'ItemList', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::ItemList', HasData => 1, # process atoms as containers with 'data' elements }, }, # MP4 tags (ref 5) hdlr => { Name => 'Handler', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Handler' }, }, dinf => { Name => 'DataInformation', Flags => ['Binary','Unknown'], }, ipmc => { Name => 'IPMPControl', Flags => ['Binary','Unknown'], }, iloc => { Name => 'ItemLocation', Flags => ['Binary','Unknown'], }, ipro => { Name => 'ItemProtection', Flags => ['Binary','Unknown'], }, iinf => { Name => 'ItemInformation', Flags => ['Binary','Unknown'], }, 'xml ' => { Name => 'XML', Flags => [ 'Binary', 'Protected', 'BlockExtract' ], SubDirectory => { TagTable => 'Image::ExifTool::XMP::XML', IgnoreProp => { NonRealTimeMeta => 1 }, # ignore container for Sony 'nrtm' }, }, 'keys' => { Name => 'Keys', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Keys' }, }, bxml => { Name => 'BinaryXML', Flags => ['Binary','Unknown'], }, pitm => { Name => 'PrimaryItemReference', Flags => ['Binary','Unknown'], }, free => { #PH Name => 'Free', Flags => ['Binary','Unknown'], }, ); # track reference atoms %Image::ExifTool::QuickTime::TrackRef = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 1 => 'Track#', 2 => 'Video' }, chap => { Name => 'ChapterListTrackID', Format => 'int32u' }, tmcd => { Name => 'TimeCode', Format => 'int32u' }, mpod => { #PH (FLIR MP4) Name => 'ElementaryStreamTrack', Format => 'int32u', ValueConv => '$val =~ s/^1 //; $val', # (why 2 numbers? -- ignore the first if "1") }, # also: sync, scpt, ssrc, iTunesInfo ); # track aperture mode dimensions atoms # (ref https://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap2/qtff2.html) %Image::ExifTool::QuickTime::TrackAperture = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 1 => 'Track#', 2 => 'Video' }, clef => { Name => 'CleanApertureDimensions', Format => 'fixed32u', Count => 3, ValueConv => '$val =~ s/^.*? //; $val', # remove flags word PrintConv => '$val =~ tr/ /x/; $val', }, prof => { Name => 'ProductionApertureDimensions', Format => 'fixed32u', Count => 3, ValueConv => '$val =~ s/^.*? //; $val', PrintConv => '$val =~ tr/ /x/; $val', }, enof => { Name => 'EncodedPixelsDimensions', Format => 'fixed32u', Count => 3, ValueConv => '$val =~ s/^.*? //; $val', PrintConv => '$val =~ tr/ /x/; $val', }, ); # item list atoms # -> these atoms are unique, and contain one or more 'data' atoms %Image::ExifTool::QuickTime::ItemList = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Audio' }, NOTES => q{ As well as these tags, the 'mdta' handler uses numerical tag ID's which are added dynamically to this table after processing the Meta Keys information. }, # in this table, binary 1 and 2-byte "data"-type tags are interpreted as # int8u and int16u. Multi-byte binary "data" tags are extracted as binary data "\xa9ART" => 'Artist', "\xa9alb" => 'Album', "\xa9cmt" => 'Comment', "\xa9com" => 'Composer', "\xa9day" => { Name => 'ContentCreateDate', Groups => { 2 => 'Time' }, # handle values in the form "2010-02-12T13:27:14-0800" ValueConv => q{ require Image::ExifTool::XMP; $val = Image::ExifTool::XMP::ConvertXMPDate($val); $val =~ s/([-+]\d{2})(\d{2})$/$1:$2/; # add colon to timezone if necessary return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, "\xa9des" => 'Description', #4 "\xa9enc" => 'EncodedBy', #10 "\xa9gen" => 'Genre', "\xa9grp" => 'Grouping', "\xa9lyr" => 'Lyrics', "\xa9nam" => 'Title', # "\xa9st3" ? #10 "\xa9too" => 'Encoder', "\xa9trk" => 'Track', "\xa9wrt" => 'Composer', '----' => { Name => 'iTunesInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::iTunesInfo' }, }, aART => { Name => 'AlbumArtist', Groups => { 2 => 'Author' } }, covr => { Name => 'CoverArt', Groups => { 2 => 'Preview' } }, cpil => { #10 Name => 'Compilation', PrintConv => { 0 => 'No', 1 => 'Yes' }, }, disk => { Name => 'DiskNumber', Format => 'undef', # (necessary to prevent decoding as string!) ValueConv => 'length($val) >= 6 ? join(" of ",unpack("x2nn",$val)) : \$val', }, pgap => { #10 Name => 'PlayGap', PrintConv => { 0 => 'Insert Gap', 1 => 'No Gap', }, }, tmpo => { Name => 'BeatsPerMinute', Format => 'int16u', # marked as boolean but really int16u in my sample }, trkn => { Name => 'TrackNumber', Format => 'undef', # (necessary to prevent decoding as string!) ValueConv => 'length($val) >= 6 ? join(" of ",unpack("x2nn",$val)) : \$val', }, # # Note: it is possible that the tags below are not being decoded properly # because I don't have samples to verify many of these - PH # akID => { #10 Name => 'AppleStoreAccountType', PrintConv => { 0 => 'iTunes', 1 => 'AOL', }, }, albm => 'Album', #(ffmpeg source) apID => 'AppleStoreAccount', atID => { #10 (or TV series) Name => 'AlbumTitleID', Format => 'int32u', }, auth => { Name => 'Author', Groups => { 2 => 'Author' } }, catg => 'Category', #7 cnID => { #10 Name => 'AppleStoreCatalogID', Format => 'int32u', }, cprt => { Name => 'Copyright', Groups => { 2 => 'Author' } }, dscp => 'Description', desc => 'Description', #7 gnre => { #10 Name => 'Genre', PrintConv => q{ return $val unless $val =~ /^\d+$/; require Image::ExifTool::ID3; Image::ExifTool::ID3::PrintGenre($val - 1); # note the "- 1" }, }, egid => 'EpisodeGlobalUniqueID', #7 geID => { #10 Name => 'GenreID', Format => 'int32u', SeparateTable => 1, PrintConv => { #21 (based on http://www.apple.com/itunes/affiliates/resources/documentation/genre-mapping.html) 2 => 'Music|Blues', 3 => 'Music|Comedy', 4 => "Music|Children's Music", 5 => 'Music|Classical', 6 => 'Music|Country', 7 => 'Music|Electronic', 8 => 'Music|Holiday', 9 => 'Music|Classical|Opera', 10 => 'Music|Singer/Songwriter', 11 => 'Music|Jazz', 12 => 'Music|Latino', 13 => 'Music|New Age', 14 => 'Music|Pop', 15 => 'Music|R&B/Soul', 16 => 'Music|Soundtrack', 17 => 'Music|Dance', 18 => 'Music|Hip-Hop/Rap', 19 => 'Music|World', 20 => 'Music|Alternative', 21 => 'Music|Rock', 22 => 'Music|Christian & Gospel', 23 => 'Music|Vocal', 24 => 'Music|Reggae', 25 => 'Music|Easy Listening', 26 => 'Podcasts', 27 => 'Music|J-Pop', 28 => 'Music|Enka', 29 => 'Music|Anime', 30 => 'Music|Kayokyoku', 31 => 'Music Videos', 32 => 'TV Shows', 33 => 'Movies', 34 => 'Music', 35 => 'iPod Games', 36 => 'App Store', 37 => 'Tones', 38 => 'Books', 39 => 'Mac App Store', 40 => 'Textbooks', 50 => 'Music|Fitness & Workout', 51 => 'Music|Pop|K-Pop', 52 => 'Music|Karaoke', 53 => 'Music|Instrumental', 74 => 'Audiobooks|News', 75 => 'Audiobooks|Programs & Performances', 1001 => 'Music|Alternative|College Rock', 1002 => 'Music|Alternative|Goth Rock', 1003 => 'Music|Alternative|Grunge', 1004 => 'Music|Alternative|Indie Rock', 1005 => 'Music|Alternative|New Wave', 1006 => 'Music|Alternative|Punk', 1007 => 'Music|Blues|Chicago Blues', 1009 => 'Music|Blues|Classic Blues', 1010 => 'Music|Blues|Contemporary Blues', 1011 => 'Music|Blues|Country Blues', 1012 => 'Music|Blues|Delta Blues', 1013 => 'Music|Blues|Electric Blues', 1014 => "Music|Children's Music|Lullabies", 1015 => "Music|Children's Music|Sing-Along", 1016 => "Music|Children's Music|Stories", 1017 => 'Music|Classical|Avant-Garde', 1018 => 'Music|Classical|Baroque Era', 1019 => 'Music|Classical|Chamber Music', 1020 => 'Music|Classical|Chant', 1021 => 'Music|Classical|Choral', 1022 => 'Music|Classical|Classical Crossover', 1023 => 'Music|Classical|Early Music', 1024 => 'Music|Classical|Impressionist', 1025 => 'Music|Classical|Medieval Era', 1026 => 'Music|Classical|Minimalism', 1027 => 'Music|Classical|Modern Era', 1028 => 'Music|Classical|Opera', 1029 => 'Music|Classical|Orchestral', 1030 => 'Music|Classical|Renaissance', 1031 => 'Music|Classical|Romantic Era', 1032 => 'Music|Classical|Wedding Music', 1033 => 'Music|Country|Alternative Country', 1034 => 'Music|Country|Americana', 1035 => 'Music|Country|Bluegrass', 1036 => 'Music|Country|Contemporary Bluegrass', 1037 => 'Music|Country|Contemporary Country', 1038 => 'Music|Country|Country Gospel', 1039 => 'Music|Country|Honky Tonk', 1040 => 'Music|Country|Outlaw Country', 1041 => 'Music|Country|Traditional Bluegrass', 1042 => 'Music|Country|Traditional Country', 1043 => 'Music|Country|Urban Cowboy', 1044 => 'Music|Dance|Breakbeat', 1045 => 'Music|Dance|Exercise', 1046 => 'Music|Dance|Garage', 1047 => 'Music|Dance|Hardcore', 1048 => 'Music|Dance|House', 1049 => "Music|Dance|Jungle/Drum'n'bass", 1050 => 'Music|Dance|Techno', 1051 => 'Music|Dance|Trance', 1052 => 'Music|Jazz|Big Band', 1053 => 'Music|Jazz|Bop', 1054 => 'Music|Easy Listening|Lounge', 1055 => 'Music|Easy Listening|Swing', 1056 => 'Music|Electronic|Ambient', 1057 => 'Music|Electronic|Downtempo', 1058 => 'Music|Electronic|Electronica', 1060 => 'Music|Electronic|IDM/Experimental', 1061 => 'Music|Electronic|Industrial', 1062 => 'Music|Singer/Songwriter|Alternative Folk', 1063 => 'Music|Singer/Songwriter|Contemporary Folk', 1064 => 'Music|Singer/Songwriter|Contemporary Singer/Songwriter', 1065 => 'Music|Singer/Songwriter|Folk-Rock', 1066 => 'Music|Singer/Songwriter|New Acoustic', 1067 => 'Music|Singer/Songwriter|Traditional Folk', 1068 => 'Music|Hip-Hop/Rap|Alternative Rap', 1069 => 'Music|Hip-Hop/Rap|Dirty South', 1070 => 'Music|Hip-Hop/Rap|East Coast Rap', 1071 => 'Music|Hip-Hop/Rap|Gangsta Rap', 1072 => 'Music|Hip-Hop/Rap|Hardcore Rap', 1073 => 'Music|Hip-Hop/Rap|Hip-Hop', 1074 => 'Music|Hip-Hop/Rap|Latin Rap', 1075 => 'Music|Hip-Hop/Rap|Old School Rap', 1076 => 'Music|Hip-Hop/Rap|Rap', 1077 => 'Music|Hip-Hop/Rap|Underground Rap', 1078 => 'Music|Hip-Hop/Rap|West Coast Rap', 1079 => 'Music|Holiday|Chanukah', 1080 => 'Music|Holiday|Christmas', 1081 => "Music|Holiday|Christmas: Children's", 1082 => 'Music|Holiday|Christmas: Classic', 1083 => 'Music|Holiday|Christmas: Classical', 1084 => 'Music|Holiday|Christmas: Jazz', 1085 => 'Music|Holiday|Christmas: Modern', 1086 => 'Music|Holiday|Christmas: Pop', 1087 => 'Music|Holiday|Christmas: R&B', 1088 => 'Music|Holiday|Christmas: Religious', 1089 => 'Music|Holiday|Christmas: Rock', 1090 => 'Music|Holiday|Easter', 1091 => 'Music|Holiday|Halloween', 1092 => 'Music|Holiday|Holiday: Other', 1093 => 'Music|Holiday|Thanksgiving', 1094 => 'Music|Christian & Gospel|CCM', 1095 => 'Music|Christian & Gospel|Christian Metal', 1096 => 'Music|Christian & Gospel|Christian Pop', 1097 => 'Music|Christian & Gospel|Christian Rap', 1098 => 'Music|Christian & Gospel|Christian Rock', 1099 => 'Music|Christian & Gospel|Classic Christian', 1100 => 'Music|Christian & Gospel|Contemporary Gospel', 1101 => 'Music|Christian & Gospel|Gospel', 1103 => 'Music|Christian & Gospel|Praise & Worship', 1104 => 'Music|Christian & Gospel|Southern Gospel', 1105 => 'Music|Christian & Gospel|Traditional Gospel', 1106 => 'Music|Jazz|Avant-Garde Jazz', 1107 => 'Music|Jazz|Contemporary Jazz', 1108 => 'Music|Jazz|Crossover Jazz', 1109 => 'Music|Jazz|Dixieland', 1110 => 'Music|Jazz|Fusion', 1111 => 'Music|Jazz|Latin Jazz', 1112 => 'Music|Jazz|Mainstream Jazz', 1113 => 'Music|Jazz|Ragtime', 1114 => 'Music|Jazz|Smooth Jazz', 1115 => 'Music|Latino|Latin Jazz', 1116 => 'Music|Latino|Contemporary Latin', 1117 => 'Music|Latino|Latin Pop', 1118 => 'Music|Latino|Raices', # (Ra&iacute;ces) 1119 => 'Music|Latino|Latin Urban', 1120 => 'Music|Latino|Baladas y Boleros', 1121 => 'Music|Latino|Latin Alternative & Rock', 1122 => 'Music|Brazilian', 1123 => 'Music|Latino|Regional Mexicano', 1124 => 'Music|Latino|Salsa y Tropical', 1125 => 'Music|New Age|Environmental', 1126 => 'Music|New Age|Healing', 1127 => 'Music|New Age|Meditation', 1128 => 'Music|New Age|Nature', 1129 => 'Music|New Age|Relaxation', 1130 => 'Music|New Age|Travel', 1131 => 'Music|Pop|Adult Contemporary', 1132 => 'Music|Pop|Britpop', 1133 => 'Music|Pop|Pop/Rock', 1134 => 'Music|Pop|Soft Rock', 1135 => 'Music|Pop|Teen Pop', 1136 => 'Music|R&B/Soul|Contemporary R&B', 1137 => 'Music|R&B/Soul|Disco', 1138 => 'Music|R&B/Soul|Doo Wop', 1139 => 'Music|R&B/Soul|Funk', 1140 => 'Music|R&B/Soul|Motown', 1141 => 'Music|R&B/Soul|Neo-Soul', 1142 => 'Music|R&B/Soul|Quiet Storm', 1143 => 'Music|R&B/Soul|Soul', 1144 => 'Music|Rock|Adult Alternative', 1145 => 'Music|Rock|American Trad Rock', 1146 => 'Music|Rock|Arena Rock', 1147 => 'Music|Rock|Blues-Rock', 1148 => 'Music|Rock|British Invasion', 1149 => 'Music|Rock|Death Metal/Black Metal', 1150 => 'Music|Rock|Glam Rock', 1151 => 'Music|Rock|Hair Metal', 1152 => 'Music|Rock|Hard Rock', 1153 => 'Music|Rock|Metal', 1154 => 'Music|Rock|Jam Bands', 1155 => 'Music|Rock|Prog-Rock/Art Rock', 1156 => 'Music|Rock|Psychedelic', 1157 => 'Music|Rock|Rock & Roll', 1158 => 'Music|Rock|Rockabilly', 1159 => 'Music|Rock|Roots Rock', 1160 => 'Music|Rock|Singer/Songwriter', 1161 => 'Music|Rock|Southern Rock', 1162 => 'Music|Rock|Surf', 1163 => 'Music|Rock|Tex-Mex', 1165 => 'Music|Soundtrack|Foreign Cinema', 1166 => 'Music|Soundtrack|Musicals', 1167 => 'Music|Comedy|Novelty', 1168 => 'Music|Soundtrack|Original Score', 1169 => 'Music|Soundtrack|Soundtrack', 1171 => 'Music|Comedy|Standup Comedy', 1172 => 'Music|Soundtrack|TV Soundtrack', 1173 => 'Music|Vocal|Standards', 1174 => 'Music|Vocal|Traditional Pop', 1175 => 'Music|Jazz|Vocal Jazz', 1176 => 'Music|Vocal|Vocal Pop', 1177 => 'Music|World|Afro-Beat', 1178 => 'Music|World|Afro-Pop', 1179 => 'Music|World|Cajun', 1180 => 'Music|World|Celtic', 1181 => 'Music|World|Celtic Folk', 1182 => 'Music|World|Contemporary Celtic', 1183 => 'Music|Reggae|Modern Dancehall', 1184 => 'Music|World|Drinking Songs', 1185 => 'Music|Indian|Indian Pop', 1186 => 'Music|World|Japanese Pop', 1187 => 'Music|World|Klezmer', 1188 => 'Music|World|Polka', 1189 => 'Music|World|Traditional Celtic', 1190 => 'Music|World|Worldbeat', 1191 => 'Music|World|Zydeco', 1192 => 'Music|Reggae|Roots Reggae', 1193 => 'Music|Reggae|Dub', 1194 => 'Music|Reggae|Ska', 1195 => 'Music|World|Caribbean', 1196 => 'Music|World|South America', 1197 => 'Music|Arabic', 1198 => 'Music|World|North America', 1199 => 'Music|World|Hawaii', 1200 => 'Music|World|Australia', 1201 => 'Music|World|Japan', 1202 => 'Music|World|France', 1203 => 'Music|World|Africa', 1204 => 'Music|World|Asia', 1205 => 'Music|World|Europe', 1206 => 'Music|World|South Africa', 1207 => 'Music|Jazz|Hard Bop', 1208 => 'Music|Jazz|Trad Jazz', 1209 => 'Music|Jazz|Cool', 1210 => 'Music|Blues|Acoustic Blues', 1211 => 'Music|Classical|High Classical', 1220 => 'Music|Brazilian|Axe', # (Ax&eacute;) 1221 => 'Music|Brazilian|Bossa Nova', 1222 => 'Music|Brazilian|Choro', 1223 => 'Music|Brazilian|Forro', # (Forr&oacute;) 1224 => 'Music|Brazilian|Frevo', 1225 => 'Music|Brazilian|MPB', 1226 => 'Music|Brazilian|Pagode', 1227 => 'Music|Brazilian|Samba', 1228 => 'Music|Brazilian|Sertanejo', 1229 => 'Music|Brazilian|Baile Funk', 1230 => 'Music|Alternative|Chinese Alt', 1231 => 'Music|Alternative|Korean Indie', 1232 => 'Music|Chinese', 1233 => 'Music|Chinese|Chinese Classical', 1234 => 'Music|Chinese|Chinese Flute', 1235 => 'Music|Chinese|Chinese Opera', 1236 => 'Music|Chinese|Chinese Orchestral', 1237 => 'Music|Chinese|Chinese Regional Folk', 1238 => 'Music|Chinese|Chinese Strings', 1239 => 'Music|Chinese|Taiwanese Folk', 1240 => 'Music|Chinese|Tibetan Native Music', 1241 => 'Music|Hip-Hop/Rap|Chinese Hip-Hop', 1242 => 'Music|Hip-Hop/Rap|Korean Hip-Hop', 1243 => 'Music|Korean', 1244 => 'Music|Korean|Korean Classical', 1245 => 'Music|Korean|Korean Trad Song', 1246 => 'Music|Korean|Korean Trad Instrumental', 1247 => 'Music|Korean|Korean Trad Theater', 1248 => 'Music|Rock|Chinese Rock', 1249 => 'Music|Rock|Korean Rock', 1250 => 'Music|Pop|C-Pop', 1251 => 'Music|Pop|Cantopop/HK-Pop', 1252 => 'Music|Pop|Korean Folk-Pop', 1253 => 'Music|Pop|Mandopop', 1254 => 'Music|Pop|Tai-Pop', 1255 => 'Music|Pop|Malaysian Pop', 1256 => 'Music|Pop|Pinoy Pop', 1257 => 'Music|Pop|Original Pilipino Music', 1258 => 'Music|Pop|Manilla Sound', 1259 => 'Music|Pop|Indo Pop', 1260 => 'Music|Pop|Thai Pop', 1261 => 'Music|Vocal|Trot', 1262 => 'Music|Indian', 1263 => 'Music|Indian|Bollywood', 1264 => 'Music|Indian|Tamil', 1265 => 'Music|Indian|Telugu', 1266 => 'Music|Indian|Regional Indian', 1267 => 'Music|Indian|Devotional & Spiritual', 1268 => 'Music|Indian|Sufi', 1269 => 'Music|Indian|Indian Classical', 1270 => 'Music|World|Russian Chanson', 1271 => 'Music|World|Dini', 1272 => 'Music|World|Halk', 1273 => 'Music|World|Sanat', 1274 => 'Music|World|Dangdut', 1275 => 'Music|World|Indonesian Religious', 1276 => 'Music|World|Calypso', 1277 => 'Music|World|Soca', 1278 => 'Music|Indian|Ghazals', 1279 => 'Music|Indian|Indian Folk', 1280 => 'Music|World|Arabesque', 1281 => 'Music|World|Afrikaans', 1282 => 'Music|World|Farsi', 1283 => 'Music|World|Israeli', 1284 => 'Music|Arabic|Khaleeji', 1285 => 'Music|Arabic|North African', 1286 => 'Music|Arabic|Arabic Pop', 1287 => 'Music|Arabic|Islamic', 1288 => 'Music|Soundtrack|Sound Effects', 1289 => 'Music|Folk', 1290 => 'Music|Orchestral', 1291 => 'Music|Marching', 1293 => 'Music|Pop|Oldies', 1294 => 'Music|Country|Thai Country', 1295 => 'Music|World|Flamenco', 1296 => 'Music|World|Tango', 1297 => 'Music|World|Fado', 1298 => 'Music|World|Iberia', 1299 => 'Music|World|Russian', 1300 => 'Music|World|Turkish', 1301 => 'Podcasts|Arts', 1302 => 'Podcasts|Society & Culture|Personal Journals', 1303 => 'Podcasts|Comedy', 1304 => 'Podcasts|Education', 1305 => 'Podcasts|Kids & Family', 1306 => 'Podcasts|Arts|Food', 1307 => 'Podcasts|Health', 1309 => 'Podcasts|TV & Film', 1310 => 'Podcasts|Music', 1311 => 'Podcasts|News & Politics', 1314 => 'Podcasts|Religion & Spirituality', 1315 => 'Podcasts|Science & Medicine', 1316 => 'Podcasts|Sports & Recreation', 1318 => 'Podcasts|Technology', 1320 => 'Podcasts|Society & Culture|Places & Travel', 1321 => 'Podcasts|Business', 1323 => 'Podcasts|Games & Hobbies', 1324 => 'Podcasts|Society & Culture', 1325 => 'Podcasts|Government & Organizations', 1337 => 'Music Videos|Classical|Piano', 1401 => 'Podcasts|Arts|Literature', 1402 => 'Podcasts|Arts|Design', 1404 => 'Podcasts|Games & Hobbies|Video Games', 1405 => 'Podcasts|Arts|Performing Arts', 1406 => 'Podcasts|Arts|Visual Arts', 1410 => 'Podcasts|Business|Careers', 1412 => 'Podcasts|Business|Investing', 1413 => 'Podcasts|Business|Management & Marketing', 1415 => 'Podcasts|Education|K-12', 1416 => 'Podcasts|Education|Higher Education', 1417 => 'Podcasts|Health|Fitness & Nutrition', 1420 => 'Podcasts|Health|Self-Help', 1421 => 'Podcasts|Health|Sexuality', 1438 => 'Podcasts|Religion & Spirituality|Buddhism', 1439 => 'Podcasts|Religion & Spirituality|Christianity', 1440 => 'Podcasts|Religion & Spirituality|Islam', 1441 => 'Podcasts|Religion & Spirituality|Judaism', 1443 => 'Podcasts|Society & Culture|Philosophy', 1444 => 'Podcasts|Religion & Spirituality|Spirituality', 1446 => 'Podcasts|Technology|Gadgets', 1448 => 'Podcasts|Technology|Tech News', 1450 => 'Podcasts|Technology|Podcasting', 1454 => 'Podcasts|Games & Hobbies|Automotive', 1455 => 'Podcasts|Games & Hobbies|Aviation', 1456 => 'Podcasts|Sports & Recreation|Outdoor', 1459 => 'Podcasts|Arts|Fashion & Beauty', 1460 => 'Podcasts|Games & Hobbies|Hobbies', 1461 => 'Podcasts|Games & Hobbies|Other Games', 1462 => 'Podcasts|Society & Culture|History', 1463 => 'Podcasts|Religion & Spirituality|Hinduism', 1464 => 'Podcasts|Religion & Spirituality|Other', 1465 => 'Podcasts|Sports & Recreation|Professional', 1466 => 'Podcasts|Sports & Recreation|College & High School', 1467 => 'Podcasts|Sports & Recreation|Amateur', 1468 => 'Podcasts|Education|Educational Technology', 1469 => 'Podcasts|Education|Language Courses', 1470 => 'Podcasts|Education|Training', 1471 => 'Podcasts|Business|Business News', 1472 => 'Podcasts|Business|Shopping', 1473 => 'Podcasts|Government & Organizations|National', 1474 => 'Podcasts|Government & Organizations|Regional', 1475 => 'Podcasts|Government & Organizations|Local', 1476 => 'Podcasts|Government & Organizations|Non-Profit', 1477 => 'Podcasts|Science & Medicine|Natural Sciences', 1478 => 'Podcasts|Science & Medicine|Medicine', 1479 => 'Podcasts|Science & Medicine|Social Sciences', 1480 => 'Podcasts|Technology|Software How-To', 1481 => 'Podcasts|Health|Alternative Health', 1602 => 'Music Videos|Blues', 1603 => 'Music Videos|Comedy', 1604 => "Music Videos|Children's Music", 1605 => 'Music Videos|Classical', 1606 => 'Music Videos|Country', 1607 => 'Music Videos|Electronic', 1608 => 'Music Videos|Holiday', 1609 => 'Music Videos|Classical|Opera', 1610 => 'Music Videos|Singer/Songwriter', 1611 => 'Music Videos|Jazz', 1612 => 'Music Videos|Latin', 1613 => 'Music Videos|New Age', 1614 => 'Music Videos|Pop', 1615 => 'Music Videos|R&B/Soul', 1616 => 'Music Videos|Soundtrack', 1617 => 'Music Videos|Dance', 1618 => 'Music Videos|Hip-Hop/Rap', 1619 => 'Music Videos|World', 1620 => 'Music Videos|Alternative', 1621 => 'Music Videos|Rock', 1622 => 'Music Videos|Christian & Gospel', 1623 => 'Music Videos|Vocal', 1624 => 'Music Videos|Reggae', 1625 => 'Music Videos|Easy Listening', 1626 => 'Music Videos|Podcasts', 1627 => 'Music Videos|J-Pop', 1628 => 'Music Videos|Enka', 1629 => 'Music Videos|Anime', 1630 => 'Music Videos|Kayokyoku', 1631 => 'Music Videos|Disney', 1632 => 'Music Videos|French Pop', 1633 => 'Music Videos|German Pop', 1634 => 'Music Videos|German Folk', 1635 => 'Music Videos|Alternative|Chinese Alt', 1636 => 'Music Videos|Alternative|Korean Indie', 1637 => 'Music Videos|Chinese', 1638 => 'Music Videos|Chinese|Chinese Classical', 1639 => 'Music Videos|Chinese|Chinese Flute', 1640 => 'Music Videos|Chinese|Chinese Opera', 1641 => 'Music Videos|Chinese|Chinese Orchestral', 1642 => 'Music Videos|Chinese|Chinese Regional Folk', 1643 => 'Music Videos|Chinese|Chinese Strings', 1644 => 'Music Videos|Chinese|Taiwanese Folk', 1645 => 'Music Videos|Chinese|Tibetan Native Music', 1646 => 'Music Videos|Hip-Hop/Rap|Chinese Hip-Hop', 1647 => 'Music Videos|Hip-Hop/Rap|Korean Hip-Hop', 1648 => 'Music Videos|Korean', 1649 => 'Music Videos|Korean|Korean Classical', 1650 => 'Music Videos|Korean|Korean Trad Song', 1651 => 'Music Videos|Korean|Korean Trad Instrumental', 1652 => 'Music Videos|Korean|Korean Trad Theater', 1653 => 'Music Videos|Rock|Chinese Rock', 1654 => 'Music Videos|Rock|Korean Rock', 1655 => 'Music Videos|Pop|C-Pop', 1656 => 'Music Videos|Pop|Cantopop/HK-Pop', 1657 => 'Music Videos|Pop|Korean Folk-Pop', 1658 => 'Music Videos|Pop|Mandopop', 1659 => 'Music Videos|Pop|Tai-Pop', 1660 => 'Music Videos|Pop|Malaysian Pop', 1661 => 'Music Videos|Pop|Pinoy Pop', 1662 => 'Music Videos|Pop|Original Pilipino Music', 1663 => 'Music Videos|Pop|Manilla Sound', 1664 => 'Music Videos|Pop|Indo Pop', 1665 => 'Music Videos|Pop|Thai Pop', 1666 => 'Music Videos|Vocal|Trot', 1671 => 'Music Videos|Brazilian', 1672 => 'Music Videos|Brazilian|Axe', # (Ax&eacute;) 1673 => 'Music Videos|Brazilian|Baile Funk', 1674 => 'Music Videos|Brazilian|Bossa Nova', 1675 => 'Music Videos|Brazilian|Choro', 1676 => 'Music Videos|Brazilian|Forro', 1677 => 'Music Videos|Brazilian|Frevo', 1678 => 'Music Videos|Brazilian|MPB', 1679 => 'Music Videos|Brazilian|Pagode', 1680 => 'Music Videos|Brazilian|Samba', 1681 => 'Music Videos|Brazilian|Sertanejo', 1682 => 'Music Videos|Classical|High Classical', 1683 => 'Music Videos|Fitness & Workout', 1684 => 'Music Videos|Instrumental', 1685 => 'Music Videos|Jazz|Big Band', 1686 => 'Music Videos|Pop|K-Pop', 1687 => 'Music Videos|Karaoke', 1688 => 'Music Videos|Rock|Heavy Metal', 1689 => 'Music Videos|Spoken Word', 1690 => 'Music Videos|Indian', 1691 => 'Music Videos|Indian|Bollywood', 1692 => 'Music Videos|Indian|Tamil', 1693 => 'Music Videos|Indian|Telugu', 1694 => 'Music Videos|Indian|Regional Indian', 1695 => 'Music Videos|Indian|Devotional & Spiritual', 1696 => 'Music Videos|Indian|Sufi', 1697 => 'Music Videos|Indian|Indian Classical', 1698 => 'Music Videos|World|Russian Chanson', 1699 => 'Music Videos|World|Dini', 1700 => 'Music Videos|World|Halk', 1701 => 'Music Videos|World|Sanat', 1702 => 'Music Videos|World|Dangdut', 1703 => 'Music Videos|World|Indonesian Religious', 1704 => 'Music Videos|Indian|Indian Pop', 1705 => 'Music Videos|World|Calypso', 1706 => 'Music Videos|World|Soca', 1707 => 'Music Videos|Indian|Ghazals', 1708 => 'Music Videos|Indian|Indian Folk', 1709 => 'Music Videos|World|Arabesque', 1710 => 'Music Videos|World|Afrikaans', 1711 => 'Music Videos|World|Farsi', 1712 => 'Music Videos|World|Israeli', 1713 => 'Music Videos|Arabic', 1714 => 'Music Videos|Arabic|Khaleeji', 1715 => 'Music Videos|Arabic|North African', 1716 => 'Music Videos|Arabic|Arabic Pop', 1717 => 'Music Videos|Arabic|Islamic', 1718 => 'Music Videos|Soundtrack|Sound Effects', 1719 => 'Music Videos|Folk', 1720 => 'Music Videos|Orchestral', 1721 => 'Music Videos|Marching', 1723 => 'Music Videos|Pop|Oldies', 1724 => 'Music Videos|Country|Thai Country', 1725 => 'Music Videos|World|Flamenco', 1726 => 'Music Videos|World|Tango', 1727 => 'Music Videos|World|Fado', 1728 => 'Music Videos|World|Iberia', 1729 => 'Music Videos|World|Russian', 1730 => 'Music Videos|World|Turkish', 1731 => 'Music Videos|Alternative|College Rock', 1732 => 'Music Videos|Alternative|Goth Rock', 1733 => 'Music Videos|Alternative|Grunge', 1734 => 'Music Videos|Alternative|Indie Rock', 1735 => 'Music Videos|Alternative|New Wave', 1736 => 'Music Videos|Alternative|Punk', 1737 => 'Music Videos|Blues|Acoustic Blues', 1738 => 'Music Videos|Blues|Chicago Blues', 1739 => 'Music Videos|Blues|Classic Blues', 1740 => 'Music Videos|Blues|Contemporary Blues', 1741 => 'Music Videos|Blues|Country Blues', 1742 => 'Music Videos|Blues|Delta Blues', 1743 => 'Music Videos|Blues|Electric Blues', 1744 => "Music Videos|Children's Music|Lullabies", 1745 => "Music Videos|Children's Music|Sing-Along", 1746 => "Music Videos|Children's Music|Stories", 1747 => 'Music Videos|Christian & Gospel|CCM', 1748 => 'Music Videos|Christian & Gospel|Christian Metal', 1749 => 'Music Videos|Christian & Gospel|Christian Pop', 1750 => 'Music Videos|Christian & Gospel|Christian Rap', 1751 => 'Music Videos|Christian & Gospel|Christian Rock', 1752 => 'Music Videos|Christian & Gospel|Classic Christian', 1753 => 'Music Videos|Christian & Gospel|Contemporary Gospel', 1754 => 'Music Videos|Christian & Gospel|Gospel', 1755 => 'Music Videos|Christian & Gospel|Praise & Worship', 1756 => 'Music Videos|Christian & Gospel|Southern Gospel', 1757 => 'Music Videos|Christian & Gospel|Traditional Gospel', 1758 => 'Music Videos|Classical|Avant-Garde', 1759 => 'Music Videos|Classical|Baroque Era', 1760 => 'Music Videos|Classical|Chamber Music', 1761 => 'Music Videos|Classical|Chant', 1762 => 'Music Videos|Classical|Choral', 1763 => 'Music Videos|Classical|Classical Crossover', 1764 => 'Music Videos|Classical|Early Music', 1765 => 'Music Videos|Classical|Impressionist', 1766 => 'Music Videos|Classical|Medieval Era', 1767 => 'Music Videos|Classical|Minimalism', 1768 => 'Music Videos|Classical|Modern Era', 1769 => 'Music Videos|Classical|Orchestral', 1770 => 'Music Videos|Classical|Renaissance', 1771 => 'Music Videos|Classical|Romantic Era', 1772 => 'Music Videos|Classical|Wedding Music', 1773 => 'Music Videos|Comedy|Novelty', 1774 => 'Music Videos|Comedy|Standup Comedy', 1775 => 'Music Videos|Country|Alternative Country', 1776 => 'Music Videos|Country|Americana', 1777 => 'Music Videos|Country|Bluegrass', 1778 => 'Music Videos|Country|Contemporary Bluegrass', 1779 => 'Music Videos|Country|Contemporary Country', 1780 => 'Music Videos|Country|Country Gospel', 1781 => 'Music Videos|Country|Honky Tonk', 1782 => 'Music Videos|Country|Outlaw Country', 1783 => 'Music Videos|Country|Traditional Bluegrass', 1784 => 'Music Videos|Country|Traditional Country', 1785 => 'Music Videos|Country|Urban Cowboy', 1786 => 'Music Videos|Dance|Breakbeat', 1787 => 'Music Videos|Dance|Exercise', 1788 => 'Music Videos|Dance|Garage', 1789 => 'Music Videos|Dance|Hardcore', 1790 => 'Music Videos|Dance|House', 1791 => "Music Videos|Dance|Jungle/Drum'n'bass", 1792 => 'Music Videos|Dance|Techno', 1793 => 'Music Videos|Dance|Trance', 1794 => 'Music Videos|Easy Listening|Lounge', 1795 => 'Music Videos|Easy Listening|Swing', 1796 => 'Music Videos|Electronic|Ambient', 1797 => 'Music Videos|Electronic|Downtempo', 1798 => 'Music Videos|Electronic|Electronica', 1799 => 'Music Videos|Electronic|IDM/Experimental', 1800 => 'Music Videos|Electronic|Industrial', 1801 => 'Music Videos|Hip-Hop/Rap|Alternative Rap', 1802 => 'Music Videos|Hip-Hop/Rap|Dirty South', 1803 => 'Music Videos|Hip-Hop/Rap|East Coast Rap', 1804 => 'Music Videos|Hip-Hop/Rap|Gangsta Rap', 1805 => 'Music Videos|Hip-Hop/Rap|Hardcore Rap', 1806 => 'Music Videos|Hip-Hop/Rap|Hip-Hop', 1807 => 'Music Videos|Hip-Hop/Rap|Latin Rap', 1808 => 'Music Videos|Hip-Hop/Rap|Old School Rap', 1809 => 'Music Videos|Hip-Hop/Rap|Rap', 1810 => 'Music Videos|Hip-Hop/Rap|Underground Rap', 1811 => 'Music Videos|Hip-Hop/Rap|West Coast Rap', 1812 => 'Music Videos|Holiday|Chanukah', 1813 => 'Music Videos|Holiday|Christmas', 1814 => "Music Videos|Holiday|Christmas: Children's", 1815 => 'Music Videos|Holiday|Christmas: Classic', 1816 => 'Music Videos|Holiday|Christmas: Classical', 1817 => 'Music Videos|Holiday|Christmas: Jazz', 1818 => 'Music Videos|Holiday|Christmas: Modern', 1819 => 'Music Videos|Holiday|Christmas: Pop', 1820 => 'Music Videos|Holiday|Christmas: R&B', 1821 => 'Music Videos|Holiday|Christmas: Religious', 1822 => 'Music Videos|Holiday|Christmas: Rock', 1823 => 'Music Videos|Holiday|Easter', 1824 => 'Music Videos|Holiday|Halloween', 1825 => 'Music Videos|Holiday|Thanksgiving', 1826 => 'Music Videos|Jazz|Avant-Garde Jazz', 1828 => 'Music Videos|Jazz|Bop', 1829 => 'Music Videos|Jazz|Contemporary Jazz', 1830 => 'Music Videos|Jazz|Cool', 1831 => 'Music Videos|Jazz|Crossover Jazz', 1832 => 'Music Videos|Jazz|Dixieland', 1833 => 'Music Videos|Jazz|Fusion', 1834 => 'Music Videos|Jazz|Hard Bop', 1835 => 'Music Videos|Jazz|Latin Jazz', 1836 => 'Music Videos|Jazz|Mainstream Jazz', 1837 => 'Music Videos|Jazz|Ragtime', 1838 => 'Music Videos|Jazz|Smooth Jazz', 1839 => 'Music Videos|Jazz|Trad Jazz', 1840 => 'Music Videos|Latin|Alternative & Rock in Spanish', 1841 => 'Music Videos|Latin|Baladas y Boleros', 1842 => 'Music Videos|Latin|Contemporary Latin', 1843 => 'Music Videos|Latin|Latin Jazz', 1844 => 'Music Videos|Latin|Latin Urban', 1845 => 'Music Videos|Latin|Pop in Spanish', 1846 => 'Music Videos|Latin|Raices', 1847 => 'Music Videos|Latin|Regional Mexicano', 1848 => 'Music Videos|Latin|Salsa y Tropical', 1849 => 'Music Videos|New Age|Healing', 1850 => 'Music Videos|New Age|Meditation', 1851 => 'Music Videos|New Age|Nature', 1852 => 'Music Videos|New Age|Relaxation', 1853 => 'Music Videos|New Age|Travel', 1854 => 'Music Videos|Pop|Adult Contemporary', 1855 => 'Music Videos|Pop|Britpop', 1856 => 'Music Videos|Pop|Pop/Rock', 1857 => 'Music Videos|Pop|Soft Rock', 1858 => 'Music Videos|Pop|Teen Pop', 1859 => 'Music Videos|R&B/Soul|Contemporary R&B', 1860 => 'Music Videos|R&B/Soul|Disco', 1861 => 'Music Videos|R&B/Soul|Doo Wop', 1862 => 'Music Videos|R&B/Soul|Funk', 1863 => 'Music Videos|R&B/Soul|Motown', 1864 => 'Music Videos|R&B/Soul|Neo-Soul', 1865 => 'Music Videos|R&B/Soul|Soul', 1866 => 'Music Videos|Reggae|Modern Dancehall', 1867 => 'Music Videos|Reggae|Dub', 1868 => 'Music Videos|Reggae|Roots Reggae', 1869 => 'Music Videos|Reggae|Ska', 1870 => 'Music Videos|Rock|Adult Alternative', 1871 => 'Music Videos|Rock|American Trad Rock', 1872 => 'Music Videos|Rock|Arena Rock', 1873 => 'Music Videos|Rock|Blues-Rock', 1874 => 'Music Videos|Rock|British Invasion', 1875 => 'Music Videos|Rock|Death Metal/Black Metal', 1876 => 'Music Videos|Rock|Glam Rock', 1877 => 'Music Videos|Rock|Hair Metal', 1878 => 'Music Videos|Rock|Hard Rock', 1879 => 'Music Videos|Rock|Jam Bands', 1880 => 'Music Videos|Rock|Prog-Rock/Art Rock', 1881 => 'Music Videos|Rock|Psychedelic', 1882 => 'Music Videos|Rock|Rock & Roll', 1883 => 'Music Videos|Rock|Rockabilly', 1884 => 'Music Videos|Rock|Roots Rock', 1885 => 'Music Videos|Rock|Singer/Songwriter', 1886 => 'Music Videos|Rock|Southern Rock', 1887 => 'Music Videos|Rock|Surf', 1888 => 'Music Videos|Rock|Tex-Mex', 1889 => 'Music Videos|Singer/Songwriter|Alternative Folk', 1890 => 'Music Videos|Singer/Songwriter|Contemporary Folk', 1891 => 'Music Videos|Singer/Songwriter|Contemporary Singer/Songwriter', 1892 => 'Music Videos|Singer/Songwriter|Folk-Rock', 1893 => 'Music Videos|Singer/Songwriter|New Acoustic', 1894 => 'Music Videos|Singer/Songwriter|Traditional Folk', 1895 => 'Music Videos|Soundtrack|Foreign Cinema', 1896 => 'Music Videos|Soundtrack|Musicals', 1897 => 'Music Videos|Soundtrack|Original Score', 1898 => 'Music Videos|Soundtrack|Soundtrack', 1899 => 'Music Videos|Soundtrack|TV Soundtrack', 1900 => 'Music Videos|Vocal|Standards', 1901 => 'Music Videos|Vocal|Traditional Pop', 1902 => 'Music Videos|Jazz|Vocal Jazz', 1903 => 'Music Videos|Vocal|Vocal Pop', 1904 => 'Music Videos|World|Africa', 1905 => 'Music Videos|World|Afro-Beat', 1906 => 'Music Videos|World|Afro-Pop', 1907 => 'Music Videos|World|Asia', 1908 => 'Music Videos|World|Australia', 1909 => 'Music Videos|World|Cajun', 1910 => 'Music Videos|World|Caribbean', 1911 => 'Music Videos|World|Celtic', 1912 => 'Music Videos|World|Celtic Folk', 1913 => 'Music Videos|World|Contemporary Celtic', 1914 => 'Music Videos|World|Europe', 1915 => 'Music Videos|World|France', 1916 => 'Music Videos|World|Hawaii', 1917 => 'Music Videos|World|Japan', 1918 => 'Music Videos|World|Klezmer', 1919 => 'Music Videos|World|North America', 1920 => 'Music Videos|World|Polka', 1921 => 'Music Videos|World|South Africa', 1922 => 'Music Videos|World|South America', 1923 => 'Music Videos|World|Traditional Celtic', 1924 => 'Music Videos|World|Worldbeat', 1925 => 'Music Videos|World|Zydeco', 1926 => 'Music Videos|Christian & Gospel', 1928 => 'Music Videos|Classical|Art Song', 1929 => 'Music Videos|Classical|Brass & Woodwinds', 1930 => 'Music Videos|Classical|Solo Instrumental', 1931 => 'Music Videos|Classical|Contemporary Era', 1932 => 'Music Videos|Classical|Oratorio', 1933 => 'Music Videos|Classical|Cantata', 1934 => 'Music Videos|Classical|Electronic', 1935 => 'Music Videos|Classical|Sacred', 1936 => 'Music Videos|Classical|Guitar', 1938 => 'Music Videos|Classical|Violin', 1939 => 'Music Videos|Classical|Cello', 1940 => 'Music Videos|Classical|Percussion', 1941 => 'Music Videos|Electronic|Dubstep', 1942 => 'Music Videos|Electronic|Bass', 1943 => 'Music Videos|Hip-Hop/Rap|UK Hip-Hop', 1944 => 'Music Videos|Reggae|Lovers Rock', 1945 => 'Music Videos|Alternative|EMO', 1946 => 'Music Videos|Alternative|Pop Punk', 1947 => 'Music Videos|Alternative|Indie Pop', 1948 => 'Music Videos|New Age|Yoga', 1949 => 'Music Videos|Pop|Tribute', 4000 => 'TV Shows|Comedy', 4001 => 'TV Shows|Drama', 4002 => 'TV Shows|Animation', 4003 => 'TV Shows|Action & Adventure', 4004 => 'TV Shows|Classic', 4005 => 'TV Shows|Kids', 4006 => 'TV Shows|Nonfiction', 4007 => 'TV Shows|Reality TV', 4008 => 'TV Shows|Sci-Fi & Fantasy', 4009 => 'TV Shows|Sports', 4010 => 'TV Shows|Teens', 4011 => 'TV Shows|Latino TV', 4401 => 'Movies|Action & Adventure', 4402 => 'Movies|Anime', 4403 => 'Movies|Classics', 4404 => 'Movies|Comedy', 4405 => 'Movies|Documentary', 4406 => 'Movies|Drama', 4407 => 'Movies|Foreign', 4408 => 'Movies|Horror', 4409 => 'Movies|Independent', 4410 => 'Movies|Kids & Family', 4411 => 'Movies|Musicals', 4412 => 'Movies|Romance', 4413 => 'Movies|Sci-Fi & Fantasy', 4414 => 'Movies|Short Films', 4415 => 'Movies|Special Interest', 4416 => 'Movies|Thriller', 4417 => 'Movies|Sports', 4418 => 'Movies|Western', 4419 => 'Movies|Urban', 4420 => 'Movies|Holiday', 4421 => 'Movies|Made for TV', 4422 => 'Movies|Concert Films', 4423 => 'Movies|Music Documentaries', 4424 => 'Movies|Music Feature Films', 4425 => 'Movies|Japanese Cinema', 4426 => 'Movies|Jidaigeki', 4427 => 'Movies|Tokusatsu', 4428 => 'Movies|Korean Cinema', 4429 => 'Movies|Russian', 4430 => 'Movies|Turkish', 4431 => 'Movies|Bollywood', 4432 => 'Movies|Regional Indian', 4433 => 'Movies|Middle Eastern', 4434 => 'Movies|African', 6000 => 'App Store|Business', 6001 => 'App Store|Weather', 6002 => 'App Store|Utilities', 6003 => 'App Store|Travel', 6004 => 'App Store|Sports', 6005 => 'App Store|Social Networking', 6006 => 'App Store|Reference', 6007 => 'App Store|Productivity', 6008 => 'App Store|Photo & Video', 6009 => 'App Store|News', 6010 => 'App Store|Navigation', 6011 => 'App Store|Music', 6012 => 'App Store|Lifestyle', 6013 => 'App Store|Health & Fitness', 6014 => 'App Store|Games', 6015 => 'App Store|Finance', 6016 => 'App Store|Entertainment', 6017 => 'App Store|Education', 6018 => 'App Store|Books', 6020 => 'App Store|Medical', 6021 => 'App Store|Newsstand', 6022 => 'App Store|Catalogs', 6023 => 'App Store|Food & Drink', 7001 => 'App Store|Games|Action', 7002 => 'App Store|Games|Adventure', 7003 => 'App Store|Games|Arcade', 7004 => 'App Store|Games|Board', 7005 => 'App Store|Games|Card', 7006 => 'App Store|Games|Casino', 7007 => 'App Store|Games|Dice', 7008 => 'App Store|Games|Educational', 7009 => 'App Store|Games|Family', 7011 => 'App Store|Games|Music', 7012 => 'App Store|Games|Puzzle', 7013 => 'App Store|Games|Racing', 7014 => 'App Store|Games|Role Playing', 7015 => 'App Store|Games|Simulation', 7016 => 'App Store|Games|Sports', 7017 => 'App Store|Games|Strategy', 7018 => 'App Store|Games|Trivia', 7019 => 'App Store|Games|Word', 8001 => 'Tones|Ringtones|Alternative', 8002 => 'Tones|Ringtones|Blues', 8003 => "Tones|Ringtones|Children's Music", 8004 => 'Tones|Ringtones|Classical', 8005 => 'Tones|Ringtones|Comedy', 8006 => 'Tones|Ringtones|Country', 8007 => 'Tones|Ringtones|Dance', 8008 => 'Tones|Ringtones|Electronic', 8009 => 'Tones|Ringtones|Enka', 8010 => 'Tones|Ringtones|French Pop', 8011 => 'Tones|Ringtones|German Folk', 8012 => 'Tones|Ringtones|German Pop', 8013 => 'Tones|Ringtones|Hip-Hop/Rap', 8014 => 'Tones|Ringtones|Holiday', 8015 => 'Tones|Ringtones|Inspirational', 8016 => 'Tones|Ringtones|J-Pop', 8017 => 'Tones|Ringtones|Jazz', 8018 => 'Tones|Ringtones|Kayokyoku', 8019 => 'Tones|Ringtones|Latin', 8020 => 'Tones|Ringtones|New Age', 8021 => 'Tones|Ringtones|Classical|Opera', 8022 => 'Tones|Ringtones|Pop', 8023 => 'Tones|Ringtones|R&B/Soul', 8024 => 'Tones|Ringtones|Reggae', 8025 => 'Tones|Ringtones|Rock', 8026 => 'Tones|Ringtones|Singer/Songwriter', 8027 => 'Tones|Ringtones|Soundtrack', 8028 => 'Tones|Ringtones|Spoken Word', 8029 => 'Tones|Ringtones|Vocal', 8030 => 'Tones|Ringtones|World', 8050 => 'Tones|Alert Tones|Sound Effects', 8051 => 'Tones|Alert Tones|Dialogue', 8052 => 'Tones|Alert Tones|Music', 8053 => 'Tones|Ringtones', 8054 => 'Tones|Alert Tones', 8055 => 'Tones|Ringtones|Alternative|Chinese Alt', 8056 => 'Tones|Ringtones|Alternative|College Rock', 8057 => 'Tones|Ringtones|Alternative|Goth Rock', 8058 => 'Tones|Ringtones|Alternative|Grunge', 8059 => 'Tones|Ringtones|Alternative|Indie Rock', 8060 => 'Tones|Ringtones|Alternative|Korean Indie', 8061 => 'Tones|Ringtones|Alternative|New Wave', 8062 => 'Tones|Ringtones|Alternative|Punk', 8063 => 'Tones|Ringtones|Anime', 8064 => 'Tones|Ringtones|Arabic', 8065 => 'Tones|Ringtones|Arabic|Arabic Pop', 8066 => 'Tones|Ringtones|Arabic|Islamic', 8067 => 'Tones|Ringtones|Arabic|Khaleeji', 8068 => 'Tones|Ringtones|Arabic|North African', 8069 => 'Tones|Ringtones|Blues|Acoustic Blues', 8070 => 'Tones|Ringtones|Blues|Chicago Blues', 8071 => 'Tones|Ringtones|Blues|Classic Blues', 8072 => 'Tones|Ringtones|Blues|Contemporary Blues', 8073 => 'Tones|Ringtones|Blues|Country Blues', 8074 => 'Tones|Ringtones|Blues|Delta Blues', 8075 => 'Tones|Ringtones|Blues|Electric Blues', 8076 => 'Tones|Ringtones|Brazilian', 8077 => 'Tones|Ringtones|Brazilian|Axe', # (Ax&eacute;) 8078 => 'Tones|Ringtones|Brazilian|Baile Funk', 8079 => 'Tones|Ringtones|Brazilian|Bossa Nova', 8080 => 'Tones|Ringtones|Brazilian|Choro', 8081 => 'Tones|Ringtones|Brazilian|Forro', # (Forr&oacute;) 8082 => 'Tones|Ringtones|Brazilian|Frevo', 8083 => 'Tones|Ringtones|Brazilian|MPB', 8084 => 'Tones|Ringtones|Brazilian|Pagode', 8085 => 'Tones|Ringtones|Brazilian|Samba', 8086 => 'Tones|Ringtones|Brazilian|Sertanejo', 8087 => "Tones|Ringtones|Children's Music|Lullabies", 8088 => "Tones|Ringtones|Children's Music|Sing-Along", 8089 => "Tones|Ringtones|Children's Music|Stories", 8090 => 'Tones|Ringtones|Chinese', 8091 => 'Tones|Ringtones|Chinese|Chinese Classical', 8092 => 'Tones|Ringtones|Chinese|Chinese Flute', 8093 => 'Tones|Ringtones|Chinese|Chinese Opera', 8094 => 'Tones|Ringtones|Chinese|Chinese Orchestral', 8095 => 'Tones|Ringtones|Chinese|Chinese Regional Folk', 8096 => 'Tones|Ringtones|Chinese|Chinese Strings', 8097 => 'Tones|Ringtones|Chinese|Taiwanese Folk', 8098 => 'Tones|Ringtones|Chinese|Tibetan Native Music', 8099 => 'Tones|Ringtones|Christian & Gospel', 8100 => 'Tones|Ringtones|Christian & Gospel|CCM', 8101 => 'Tones|Ringtones|Christian & Gospel|Christian Metal', 8102 => 'Tones|Ringtones|Christian & Gospel|Christian Pop', 8103 => 'Tones|Ringtones|Christian & Gospel|Christian Rap', 8104 => 'Tones|Ringtones|Christian & Gospel|Christian Rock', 8105 => 'Tones|Ringtones|Christian & Gospel|Classic Christian', 8106 => 'Tones|Ringtones|Christian & Gospel|Contemporary Gospel', 8107 => 'Tones|Ringtones|Christian & Gospel|Gospel', 8108 => 'Tones|Ringtones|Christian & Gospel|Praise & Worship', 8109 => 'Tones|Ringtones|Christian & Gospel|Southern Gospel', 8110 => 'Tones|Ringtones|Christian & Gospel|Traditional Gospel', 8111 => 'Tones|Ringtones|Classical|Avant-Garde', 8112 => 'Tones|Ringtones|Classical|Baroque Era', 8113 => 'Tones|Ringtones|Classical|Chamber Music', 8114 => 'Tones|Ringtones|Classical|Chant', 8115 => 'Tones|Ringtones|Classical|Choral', 8116 => 'Tones|Ringtones|Classical|Classical Crossover', 8117 => 'Tones|Ringtones|Classical|Early Music', 8118 => 'Tones|Ringtones|Classical|High Classical', 8119 => 'Tones|Ringtones|Classical|Impressionist', 8120 => 'Tones|Ringtones|Classical|Medieval Era', 8121 => 'Tones|Ringtones|Classical|Minimalism', 8122 => 'Tones|Ringtones|Classical|Modern Era', 8123 => 'Tones|Ringtones|Classical|Orchestral', 8124 => 'Tones|Ringtones|Classical|Renaissance', 8125 => 'Tones|Ringtones|Classical|Romantic Era', 8126 => 'Tones|Ringtones|Classical|Wedding Music', 8127 => 'Tones|Ringtones|Comedy|Novelty', 8128 => 'Tones|Ringtones|Comedy|Standup Comedy', 8129 => 'Tones|Ringtones|Country|Alternative Country', 8130 => 'Tones|Ringtones|Country|Americana', 8131 => 'Tones|Ringtones|Country|Bluegrass', 8132 => 'Tones|Ringtones|Country|Contemporary Bluegrass', 8133 => 'Tones|Ringtones|Country|Contemporary Country', 8134 => 'Tones|Ringtones|Country|Country Gospel', 8135 => 'Tones|Ringtones|Country|Honky Tonk', 8136 => 'Tones|Ringtones|Country|Outlaw Country', 8137 => 'Tones|Ringtones|Country|Thai Country', 8138 => 'Tones|Ringtones|Country|Traditional Bluegrass', 8139 => 'Tones|Ringtones|Country|Traditional Country', 8140 => 'Tones|Ringtones|Country|Urban Cowboy', 8141 => 'Tones|Ringtones|Dance|Breakbeat', 8142 => 'Tones|Ringtones|Dance|Exercise', 8143 => 'Tones|Ringtones|Dance|Garage', 8144 => 'Tones|Ringtones|Dance|Hardcore', 8145 => 'Tones|Ringtones|Dance|House', 8146 => "Tones|Ringtones|Dance|Jungle/Drum'n'bass", 8147 => 'Tones|Ringtones|Dance|Techno', 8148 => 'Tones|Ringtones|Dance|Trance', 8149 => 'Tones|Ringtones|Disney', 8150 => 'Tones|Ringtones|Easy Listening', 8151 => 'Tones|Ringtones|Easy Listening|Lounge', 8152 => 'Tones|Ringtones|Easy Listening|Swing', 8153 => 'Tones|Ringtones|Electronic|Ambient', 8154 => 'Tones|Ringtones|Electronic|Downtempo', 8155 => 'Tones|Ringtones|Electronic|Electronica', 8156 => 'Tones|Ringtones|Electronic|IDM/Experimental', 8157 => 'Tones|Ringtones|Electronic|Industrial', 8158 => 'Tones|Ringtones|Fitness & Workout', 8159 => 'Tones|Ringtones|Folk', 8160 => 'Tones|Ringtones|Hip-Hop/Rap|Alternative Rap', 8161 => 'Tones|Ringtones|Hip-Hop/Rap|Chinese Hip-Hop', 8162 => 'Tones|Ringtones|Hip-Hop/Rap|Dirty South', 8163 => 'Tones|Ringtones|Hip-Hop/Rap|East Coast Rap', 8164 => 'Tones|Ringtones|Hip-Hop/Rap|Gangsta Rap', 8165 => 'Tones|Ringtones|Hip-Hop/Rap|Hardcore Rap', 8166 => 'Tones|Ringtones|Hip-Hop/Rap|Hip-Hop', 8167 => 'Tones|Ringtones|Hip-Hop/Rap|Korean Hip-Hop', 8168 => 'Tones|Ringtones|Hip-Hop/Rap|Latin Rap', 8169 => 'Tones|Ringtones|Hip-Hop/Rap|Old School Rap', 8170 => 'Tones|Ringtones|Hip-Hop/Rap|Rap', 8171 => 'Tones|Ringtones|Hip-Hop/Rap|Underground Rap', 8172 => 'Tones|Ringtones|Hip-Hop/Rap|West Coast Rap', 8173 => 'Tones|Ringtones|Holiday|Chanukah', 8174 => 'Tones|Ringtones|Holiday|Christmas', 8175 => "Tones|Ringtones|Holiday|Christmas: Children's", 8176 => 'Tones|Ringtones|Holiday|Christmas: Classic', 8177 => 'Tones|Ringtones|Holiday|Christmas: Classical', 8178 => 'Tones|Ringtones|Holiday|Christmas: Jazz', 8179 => 'Tones|Ringtones|Holiday|Christmas: Modern', 8180 => 'Tones|Ringtones|Holiday|Christmas: Pop', 8181 => 'Tones|Ringtones|Holiday|Christmas: R&B', 8182 => 'Tones|Ringtones|Holiday|Christmas: Religious', 8183 => 'Tones|Ringtones|Holiday|Christmas: Rock', 8184 => 'Tones|Ringtones|Holiday|Easter', 8185 => 'Tones|Ringtones|Holiday|Halloween', 8186 => 'Tones|Ringtones|Holiday|Thanksgiving', 8187 => 'Tones|Ringtones|Indian', 8188 => 'Tones|Ringtones|Indian|Bollywood', 8189 => 'Tones|Ringtones|Indian|Devotional & Spiritual', 8190 => 'Tones|Ringtones|Indian|Ghazals', 8191 => 'Tones|Ringtones|Indian|Indian Classical', 8192 => 'Tones|Ringtones|Indian|Indian Folk', 8193 => 'Tones|Ringtones|Indian|Indian Pop', 8194 => 'Tones|Ringtones|Indian|Regional Indian', 8195 => 'Tones|Ringtones|Indian|Sufi', 8196 => 'Tones|Ringtones|Indian|Tamil', 8197 => 'Tones|Ringtones|Indian|Telugu', 8198 => 'Tones|Ringtones|Instrumental', 8199 => 'Tones|Ringtones|Jazz|Avant-Garde Jazz', 8201 => 'Tones|Ringtones|Jazz|Big Band', 8202 => 'Tones|Ringtones|Jazz|Bop', 8203 => 'Tones|Ringtones|Jazz|Contemporary Jazz', 8204 => 'Tones|Ringtones|Jazz|Cool', 8205 => 'Tones|Ringtones|Jazz|Crossover Jazz', 8206 => 'Tones|Ringtones|Jazz|Dixieland', 8207 => 'Tones|Ringtones|Jazz|Fusion', 8208 => 'Tones|Ringtones|Jazz|Hard Bop', 8209 => 'Tones|Ringtones|Jazz|Latin Jazz', 8210 => 'Tones|Ringtones|Jazz|Mainstream Jazz', 8211 => 'Tones|Ringtones|Jazz|Ragtime', 8212 => 'Tones|Ringtones|Jazz|Smooth Jazz', 8213 => 'Tones|Ringtones|Jazz|Trad Jazz', 8214 => 'Tones|Ringtones|Pop|K-Pop', 8215 => 'Tones|Ringtones|Karaoke', 8216 => 'Tones|Ringtones|Korean', 8217 => 'Tones|Ringtones|Korean|Korean Classical', 8218 => 'Tones|Ringtones|Korean|Korean Trad Instrumental', 8219 => 'Tones|Ringtones|Korean|Korean Trad Song', 8220 => 'Tones|Ringtones|Korean|Korean Trad Theater', 8221 => 'Tones|Ringtones|Latin|Alternative & Rock in Spanish', 8222 => 'Tones|Ringtones|Latin|Baladas y Boleros', 8223 => 'Tones|Ringtones|Latin|Contemporary Latin', 8224 => 'Tones|Ringtones|Latin|Latin Jazz', 8225 => 'Tones|Ringtones|Latin|Latin Urban', 8226 => 'Tones|Ringtones|Latin|Pop in Spanish', 8227 => 'Tones|Ringtones|Latin|Raices', 8228 => 'Tones|Ringtones|Latin|Regional Mexicano', 8229 => 'Tones|Ringtones|Latin|Salsa y Tropical', 8230 => 'Tones|Ringtones|Marching Bands', 8231 => 'Tones|Ringtones|New Age|Healing', 8232 => 'Tones|Ringtones|New Age|Meditation', 8233 => 'Tones|Ringtones|New Age|Nature', 8234 => 'Tones|Ringtones|New Age|Relaxation', 8235 => 'Tones|Ringtones|New Age|Travel', 8236 => 'Tones|Ringtones|Orchestral', 8237 => 'Tones|Ringtones|Pop|Adult Contemporary', 8238 => 'Tones|Ringtones|Pop|Britpop', 8239 => 'Tones|Ringtones|Pop|C-Pop', 8240 => 'Tones|Ringtones|Pop|Cantopop/HK-Pop', 8241 => 'Tones|Ringtones|Pop|Indo Pop', 8242 => 'Tones|Ringtones|Pop|Korean Folk-Pop', 8243 => 'Tones|Ringtones|Pop|Malaysian Pop', 8244 => 'Tones|Ringtones|Pop|Mandopop', 8245 => 'Tones|Ringtones|Pop|Manilla Sound', 8246 => 'Tones|Ringtones|Pop|Oldies', 8247 => 'Tones|Ringtones|Pop|Original Pilipino Music', 8248 => 'Tones|Ringtones|Pop|Pinoy Pop', 8249 => 'Tones|Ringtones|Pop|Pop/Rock', 8250 => 'Tones|Ringtones|Pop|Soft Rock', 8251 => 'Tones|Ringtones|Pop|Tai-Pop', 8252 => 'Tones|Ringtones|Pop|Teen Pop', 8253 => 'Tones|Ringtones|Pop|Thai Pop', 8254 => 'Tones|Ringtones|R&B/Soul|Contemporary R&B', 8255 => 'Tones|Ringtones|R&B/Soul|Disco', 8256 => 'Tones|Ringtones|R&B/Soul|Doo Wop', 8257 => 'Tones|Ringtones|R&B/Soul|Funk', 8258 => 'Tones|Ringtones|R&B/Soul|Motown', 8259 => 'Tones|Ringtones|R&B/Soul|Neo-Soul', 8260 => 'Tones|Ringtones|R&B/Soul|Soul', 8261 => 'Tones|Ringtones|Reggae|Modern Dancehall', 8262 => 'Tones|Ringtones|Reggae|Dub', 8263 => 'Tones|Ringtones|Reggae|Roots Reggae', 8264 => 'Tones|Ringtones|Reggae|Ska', 8265 => 'Tones|Ringtones|Rock|Adult Alternative', 8266 => 'Tones|Ringtones|Rock|American Trad Rock', 8267 => 'Tones|Ringtones|Rock|Arena Rock', 8268 => 'Tones|Ringtones|Rock|Blues-Rock', 8269 => 'Tones|Ringtones|Rock|British Invasion', 8270 => 'Tones|Ringtones|Rock|Chinese Rock', 8271 => 'Tones|Ringtones|Rock|Death Metal/Black Metal', 8272 => 'Tones|Ringtones|Rock|Glam Rock', 8273 => 'Tones|Ringtones|Rock|Hair Metal', 8274 => 'Tones|Ringtones|Rock|Hard Rock', 8275 => 'Tones|Ringtones|Rock|Metal', 8276 => 'Tones|Ringtones|Rock|Jam Bands', 8277 => 'Tones|Ringtones|Rock|Korean Rock', 8278 => 'Tones|Ringtones|Rock|Prog-Rock/Art Rock', 8279 => 'Tones|Ringtones|Rock|Psychedelic', 8280 => 'Tones|Ringtones|Rock|Rock & Roll', 8281 => 'Tones|Ringtones|Rock|Rockabilly', 8282 => 'Tones|Ringtones|Rock|Roots Rock', 8283 => 'Tones|Ringtones|Rock|Singer/Songwriter', 8284 => 'Tones|Ringtones|Rock|Southern Rock', 8285 => 'Tones|Ringtones|Rock|Surf', 8286 => 'Tones|Ringtones|Rock|Tex-Mex', 8287 => 'Tones|Ringtones|Singer/Songwriter|Alternative Folk', 8288 => 'Tones|Ringtones|Singer/Songwriter|Contemporary Folk', 8289 => 'Tones|Ringtones|Singer/Songwriter|Contemporary Singer/Songwriter', 8290 => 'Tones|Ringtones|Singer/Songwriter|Folk-Rock', 8291 => 'Tones|Ringtones|Singer/Songwriter|New Acoustic', 8292 => 'Tones|Ringtones|Singer/Songwriter|Traditional Folk', 8293 => 'Tones|Ringtones|Soundtrack|Foreign Cinema', 8294 => 'Tones|Ringtones|Soundtrack|Musicals', 8295 => 'Tones|Ringtones|Soundtrack|Original Score', 8296 => 'Tones|Ringtones|Soundtrack|Sound Effects', 8297 => 'Tones|Ringtones|Soundtrack|Soundtrack', 8298 => 'Tones|Ringtones|Soundtrack|TV Soundtrack', 8299 => 'Tones|Ringtones|Vocal|Standards', 8300 => 'Tones|Ringtones|Vocal|Traditional Pop', 8301 => 'Tones|Ringtones|Vocal|Trot', 8302 => 'Tones|Ringtones|Jazz|Vocal Jazz', 8303 => 'Tones|Ringtones|Vocal|Vocal Pop', 8304 => 'Tones|Ringtones|World|Africa', 8305 => 'Tones|Ringtones|World|Afrikaans', 8306 => 'Tones|Ringtones|World|Afro-Beat', 8307 => 'Tones|Ringtones|World|Afro-Pop', 8308 => 'Tones|Ringtones|World|Arabesque', 8309 => 'Tones|Ringtones|World|Asia', 8310 => 'Tones|Ringtones|World|Australia', 8311 => 'Tones|Ringtones|World|Cajun', 8312 => 'Tones|Ringtones|World|Calypso', 8313 => 'Tones|Ringtones|World|Caribbean', 8314 => 'Tones|Ringtones|World|Celtic', 8315 => 'Tones|Ringtones|World|Celtic Folk', 8316 => 'Tones|Ringtones|World|Contemporary Celtic', 8317 => 'Tones|Ringtones|World|Dangdut', 8318 => 'Tones|Ringtones|World|Dini', 8319 => 'Tones|Ringtones|World|Europe', 8320 => 'Tones|Ringtones|World|Fado', 8321 => 'Tones|Ringtones|World|Farsi', 8322 => 'Tones|Ringtones|World|Flamenco', 8323 => 'Tones|Ringtones|World|France', 8324 => 'Tones|Ringtones|World|Halk', 8325 => 'Tones|Ringtones|World|Hawaii', 8326 => 'Tones|Ringtones|World|Iberia', 8327 => 'Tones|Ringtones|World|Indonesian Religious', 8328 => 'Tones|Ringtones|World|Israeli', 8329 => 'Tones|Ringtones|World|Japan', 8330 => 'Tones|Ringtones|World|Klezmer', 8331 => 'Tones|Ringtones|World|North America', 8332 => 'Tones|Ringtones|World|Polka', 8333 => 'Tones|Ringtones|World|Russian', 8334 => 'Tones|Ringtones|World|Russian Chanson', 8335 => 'Tones|Ringtones|World|Sanat', 8336 => 'Tones|Ringtones|World|Soca', 8337 => 'Tones|Ringtones|World|South Africa', 8338 => 'Tones|Ringtones|World|South America', 8339 => 'Tones|Ringtones|World|Tango', 8340 => 'Tones|Ringtones|World|Traditional Celtic', 8341 => 'Tones|Ringtones|World|Turkish', 8342 => 'Tones|Ringtones|World|Worldbeat', 8343 => 'Tones|Ringtones|World|Zydeco', 8345 => 'Tones|Ringtones|Classical|Art Song', 8346 => 'Tones|Ringtones|Classical|Brass & Woodwinds', 8347 => 'Tones|Ringtones|Classical|Solo Instrumental', 8348 => 'Tones|Ringtones|Classical|Contemporary Era', 8349 => 'Tones|Ringtones|Classical|Oratorio', 8350 => 'Tones|Ringtones|Classical|Cantata', 8351 => 'Tones|Ringtones|Classical|Electronic', 8352 => 'Tones|Ringtones|Classical|Sacred', 8353 => 'Tones|Ringtones|Classical|Guitar', 8354 => 'Tones|Ringtones|Classical|Piano', 8355 => 'Tones|Ringtones|Classical|Violin', 8356 => 'Tones|Ringtones|Classical|Cello', 8357 => 'Tones|Ringtones|Classical|Percussion', 8358 => 'Tones|Ringtones|Electronic|Dubstep', 8359 => 'Tones|Ringtones|Electronic|Bass', 8360 => 'Tones|Ringtones|Hip-Hop/Rap|UK Hip Hop', 8361 => 'Tones|Ringtones|Reggae|Lovers Rock', 8362 => 'Tones|Ringtones|Alternative|EMO', 8363 => 'Tones|Ringtones|Alternative|Pop Punk', 8364 => 'Tones|Ringtones|Alternative|Indie Pop', 8365 => 'Tones|Ringtones|New Age|Yoga', 8366 => 'Tones|Ringtones|Pop|Tribute', 9002 => 'Books|Nonfiction', 9003 => 'Books|Romance', 9004 => 'Books|Travel & Adventure', 9007 => 'Books|Arts & Entertainment', 9008 => 'Books|Biographies & Memoirs', 9009 => 'Books|Business & Personal Finance', 9010 => 'Books|Children & Teens', 9012 => 'Books|Humor', 9015 => 'Books|History', 9018 => 'Books|Religion & Spirituality', 9019 => 'Books|Science & Nature', 9020 => 'Books|Sci-Fi & Fantasy', 9024 => 'Books|Lifestyle & Home', 9025 => 'Books|Health, Mind & Body', 9026 => 'Books|Comics & Graphic Novels', 9027 => 'Books|Computers & Internet', 9028 => 'Books|Cookbooks, Food & Wine', 9029 => 'Books|Professional & Technical', 9030 => 'Books|Parenting', 9031 => 'Books|Fiction & Literature', 9032 => 'Books|Mysteries & Thrillers', 9033 => 'Books|Reference', 9034 => 'Books|Politics & Current Events', 9035 => 'Books|Sports & Outdoors', 10001 => 'Books|Lifestyle & Home|Antiques & Collectibles', 10002 => 'Books|Arts & Entertainment|Art & Architecture', 10003 => 'Books|Religion & Spirituality|Bibles', 10004 => 'Books|Health, Mind & Body|Spirituality', 10005 => 'Books|Business & Personal Finance|Industries & Professions', 10006 => 'Books|Business & Personal Finance|Marketing & Sales', 10007 => 'Books|Business & Personal Finance|Small Business & Entrepreneurship', 10008 => 'Books|Business & Personal Finance|Personal Finance', 10009 => 'Books|Business & Personal Finance|Reference', 10010 => 'Books|Business & Personal Finance|Careers', 10011 => 'Books|Business & Personal Finance|Economics', 10012 => 'Books|Business & Personal Finance|Investing', 10013 => 'Books|Business & Personal Finance|Finance', 10014 => 'Books|Business & Personal Finance|Management & Leadership', 10015 => 'Books|Comics & Graphic Novels|Graphic Novels', 10016 => 'Books|Comics & Graphic Novels|Manga', 10017 => 'Books|Computers & Internet|Computers', 10018 => 'Books|Computers & Internet|Databases', 10019 => 'Books|Computers & Internet|Digital Media', 10020 => 'Books|Computers & Internet|Internet', 10021 => 'Books|Computers & Internet|Network', 10022 => 'Books|Computers & Internet|Operating Systems', 10023 => 'Books|Computers & Internet|Programming', 10024 => 'Books|Computers & Internet|Software', 10025 => 'Books|Computers & Internet|System Administration', 10026 => 'Books|Cookbooks, Food & Wine|Beverages', 10027 => 'Books|Cookbooks, Food & Wine|Courses & Dishes', 10028 => 'Books|Cookbooks, Food & Wine|Special Diet', 10029 => 'Books|Cookbooks, Food & Wine|Special Occasions', 10030 => 'Books|Cookbooks, Food & Wine|Methods', 10031 => 'Books|Cookbooks, Food & Wine|Reference', 10032 => 'Books|Cookbooks, Food & Wine|Regional & Ethnic', 10033 => 'Books|Cookbooks, Food & Wine|Specific Ingredients', 10034 => 'Books|Lifestyle & Home|Crafts & Hobbies', 10035 => 'Books|Professional & Technical|Design', 10036 => 'Books|Arts & Entertainment|Theater', 10037 => 'Books|Professional & Technical|Education', 10038 => 'Books|Nonfiction|Family & Relationships', 10039 => 'Books|Fiction & Literature|Action & Adventure', 10040 => 'Books|Fiction & Literature|African American', 10041 => 'Books|Fiction & Literature|Religious', 10042 => 'Books|Fiction & Literature|Classics', 10043 => 'Books|Fiction & Literature|Erotica', 10044 => 'Books|Sci-Fi & Fantasy|Fantasy', 10045 => 'Books|Fiction & Literature|Gay', 10046 => 'Books|Fiction & Literature|Ghost', 10047 => 'Books|Fiction & Literature|Historical', 10048 => 'Books|Fiction & Literature|Horror', 10049 => 'Books|Fiction & Literature|Literary', 10050 => 'Books|Mysteries & Thrillers|Hard-Boiled', 10051 => 'Books|Mysteries & Thrillers|Historical', 10052 => 'Books|Mysteries & Thrillers|Police Procedural', 10053 => 'Books|Mysteries & Thrillers|Short Stories', 10054 => 'Books|Mysteries & Thrillers|British Detectives', 10055 => 'Books|Mysteries & Thrillers|Women Sleuths', 10056 => 'Books|Romance|Erotic Romance', 10057 => 'Books|Romance|Contemporary', 10058 => 'Books|Romance|Paranormal', 10059 => 'Books|Romance|Historical', 10060 => 'Books|Romance|Short Stories', 10061 => 'Books|Romance|Suspense', 10062 => 'Books|Romance|Western', 10063 => 'Books|Sci-Fi & Fantasy|Science Fiction', 10064 => 'Books|Sci-Fi & Fantasy|Science Fiction & Literature', 10065 => 'Books|Fiction & Literature|Short Stories', 10066 => 'Books|Reference|Foreign Languages', 10067 => 'Books|Arts & Entertainment|Games', 10068 => 'Books|Lifestyle & Home|Gardening', 10069 => 'Books|Health, Mind & Body|Health & Fitness', 10070 => 'Books|History|Africa', 10071 => 'Books|History|Americas', 10072 => 'Books|History|Ancient', 10073 => 'Books|History|Asia', 10074 => 'Books|History|Australia & Oceania', 10075 => 'Books|History|Europe', 10076 => 'Books|History|Latin America', 10077 => 'Books|History|Middle East', 10078 => 'Books|History|Military', 10079 => 'Books|History|United States', 10080 => 'Books|History|World', 10081 => "Books|Children & Teens|Children's Fiction", 10082 => "Books|Children & Teens|Children's Nonfiction", 10083 => 'Books|Professional & Technical|Law', 10084 => 'Books|Fiction & Literature|Literary Criticism', 10085 => 'Books|Science & Nature|Mathematics', 10086 => 'Books|Professional & Technical|Medical', 10087 => 'Books|Arts & Entertainment|Music', 10088 => 'Books|Science & Nature|Nature', 10089 => 'Books|Arts & Entertainment|Performing Arts', 10090 => 'Books|Lifestyle & Home|Pets', 10091 => 'Books|Nonfiction|Philosophy', 10092 => 'Books|Arts & Entertainment|Photography', 10093 => 'Books|Fiction & Literature|Poetry', 10094 => 'Books|Health, Mind & Body|Psychology', 10095 => 'Books|Reference|Almanacs & Yearbooks', 10096 => 'Books|Reference|Atlases & Maps', 10097 => 'Books|Reference|Catalogs & Directories', 10098 => 'Books|Reference|Consumer Guides', 10099 => 'Books|Reference|Dictionaries & Thesauruses', 10100 => 'Books|Reference|Encyclopedias', 10101 => 'Books|Reference|Etiquette', 10102 => 'Books|Reference|Quotations', 10103 => 'Books|Reference|Words & Language', 10104 => 'Books|Reference|Writing', 10105 => 'Books|Religion & Spirituality|Bible Studies', 10106 => 'Books|Religion & Spirituality|Buddhism', 10107 => 'Books|Religion & Spirituality|Christianity', 10108 => 'Books|Religion & Spirituality|Hinduism', 10109 => 'Books|Religion & Spirituality|Islam', 10110 => 'Books|Religion & Spirituality|Judaism', 10111 => 'Books|Science & Nature|Astronomy', 10112 => 'Books|Science & Nature|Chemistry', 10113 => 'Books|Science & Nature|Earth Sciences', 10114 => 'Books|Science & Nature|Essays', 10115 => 'Books|Science & Nature|History', 10116 => 'Books|Science & Nature|Life Sciences', 10117 => 'Books|Science & Nature|Physics', 10118 => 'Books|Science & Nature|Reference', 10119 => 'Books|Health, Mind & Body|Self-Improvement', 10120 => 'Books|Nonfiction|Social Science', 10121 => 'Books|Sports & Outdoors|Baseball', 10122 => 'Books|Sports & Outdoors|Basketball', 10123 => 'Books|Sports & Outdoors|Coaching', 10124 => 'Books|Sports & Outdoors|Extreme Sports', 10125 => 'Books|Sports & Outdoors|Football', 10126 => 'Books|Sports & Outdoors|Golf', 10127 => 'Books|Sports & Outdoors|Hockey', 10128 => 'Books|Sports & Outdoors|Mountaineering', 10129 => 'Books|Sports & Outdoors|Outdoors', 10130 => 'Books|Sports & Outdoors|Racket Sports', 10131 => 'Books|Sports & Outdoors|Reference', 10132 => 'Books|Sports & Outdoors|Soccer', 10133 => 'Books|Sports & Outdoors|Training', 10134 => 'Books|Sports & Outdoors|Water Sports', 10135 => 'Books|Sports & Outdoors|Winter Sports', 10136 => 'Books|Reference|Study Aids', 10137 => 'Books|Professional & Technical|Engineering', 10138 => 'Books|Nonfiction|Transportation', 10139 => 'Books|Travel & Adventure|Africa', 10140 => 'Books|Travel & Adventure|Asia', 10141 => 'Books|Travel & Adventure|Specialty Travel', 10142 => 'Books|Travel & Adventure|Canada', 10143 => 'Books|Travel & Adventure|Caribbean', 10144 => 'Books|Travel & Adventure|Latin America', 10145 => 'Books|Travel & Adventure|Essays & Memoirs', 10146 => 'Books|Travel & Adventure|Europe', 10147 => 'Books|Travel & Adventure|Middle East', 10148 => 'Books|Travel & Adventure|United States', 10149 => 'Books|Nonfiction|True Crime', 11001 => 'Books|Sci-Fi & Fantasy|Fantasy|Contemporary', 11002 => 'Books|Sci-Fi & Fantasy|Fantasy|Epic', 11003 => 'Books|Sci-Fi & Fantasy|Fantasy|Historical', 11004 => 'Books|Sci-Fi & Fantasy|Fantasy|Paranormal', 11005 => 'Books|Sci-Fi & Fantasy|Fantasy|Short Stories', 11006 => 'Books|Sci-Fi & Fantasy|Science Fiction & Literature|Adventure', 11007 => 'Books|Sci-Fi & Fantasy|Science Fiction & Literature|High Tech', 11008 => 'Books|Sci-Fi & Fantasy|Science Fiction & Literature|Short Stories', 11009 => 'Books|Professional & Technical|Education|Language Arts & Disciplines', 11010 => 'Books|Communications & Media', 11011 => 'Books|Communications & Media|Broadcasting', 11012 => 'Books|Communications & Media|Digital Media', 11013 => 'Books|Communications & Media|Journalism', 11014 => 'Books|Communications & Media|Photojournalism', 11015 => 'Books|Communications & Media|Print', 11016 => 'Books|Communications & Media|Speech', 11017 => 'Books|Communications & Media|Writing', 11018 => 'Books|Arts & Entertainment|Art & Architecture|Urban Planning', 11019 => 'Books|Arts & Entertainment|Dance', 11020 => 'Books|Arts & Entertainment|Fashion', 11021 => 'Books|Arts & Entertainment|Film', 11022 => 'Books|Arts & Entertainment|Interior Design', 11023 => 'Books|Arts & Entertainment|Media Arts', 11024 => 'Books|Arts & Entertainment|Radio', 11025 => 'Books|Arts & Entertainment|TV', 11026 => 'Books|Arts & Entertainment|Visual Arts', 11027 => 'Books|Biographies & Memoirs|Arts & Entertainment', 11028 => 'Books|Biographies & Memoirs|Business', 11029 => 'Books|Biographies & Memoirs|Culinary', 11030 => 'Books|Biographies & Memoirs|Gay & Lesbian', 11031 => 'Books|Biographies & Memoirs|Historical', 11032 => 'Books|Biographies & Memoirs|Literary', 11033 => 'Books|Biographies & Memoirs|Media & Journalism', 11034 => 'Books|Biographies & Memoirs|Military', 11035 => 'Books|Biographies & Memoirs|Politics', 11036 => 'Books|Biographies & Memoirs|Religious', 11037 => 'Books|Biographies & Memoirs|Science & Technology', 11038 => 'Books|Biographies & Memoirs|Sports', 11039 => 'Books|Biographies & Memoirs|Women', 11040 => 'Books|Romance|New Adult', 11042 => 'Books|Romance|Romantic Comedy', 11043 => 'Books|Romance|Gay & Lesbian', 11044 => 'Books|Fiction & Literature|Essays', 11045 => 'Books|Fiction & Literature|Anthologies', 11046 => 'Books|Fiction & Literature|Comparative Literature', 11047 => 'Books|Fiction & Literature|Drama', 11049 => 'Books|Fiction & Literature|Fairy Tales, Myths & Fables', 11050 => 'Books|Fiction & Literature|Family', 11051 => 'Books|Comics & Graphic Novels|Manga|School Drama', 11052 => 'Books|Comics & Graphic Novels|Manga|Human Drama', 11053 => 'Books|Comics & Graphic Novels|Manga|Family Drama', 11054 => 'Books|Sports & Outdoors|Boxing', 11055 => 'Books|Sports & Outdoors|Cricket', 11056 => 'Books|Sports & Outdoors|Cycling', 11057 => 'Books|Sports & Outdoors|Equestrian', 11058 => 'Books|Sports & Outdoors|Martial Arts & Self Defense', 11059 => 'Books|Sports & Outdoors|Motor Sports', 11060 => 'Books|Sports & Outdoors|Rugby', 11061 => 'Books|Sports & Outdoors|Running', 11062 => 'Books|Health, Mind & Body|Diet & Nutrition', 11063 => 'Books|Science & Nature|Agriculture', 11064 => 'Books|Science & Nature|Atmosphere', 11065 => 'Books|Science & Nature|Biology', 11066 => 'Books|Science & Nature|Ecology', 11067 => 'Books|Science & Nature|Environment', 11068 => 'Books|Science & Nature|Geography', 11069 => 'Books|Science & Nature|Geology', 11070 => 'Books|Nonfiction|Social Science|Anthropology', 11071 => 'Books|Nonfiction|Social Science|Archaeology', 11072 => 'Books|Nonfiction|Social Science|Civics', 11073 => 'Books|Nonfiction|Social Science|Government', 11074 => 'Books|Nonfiction|Social Science|Social Studies', 11075 => 'Books|Nonfiction|Social Science|Social Welfare', 11076 => 'Books|Nonfiction|Social Science|Society', 11077 => 'Books|Nonfiction|Philosophy|Aesthetics', 11078 => 'Books|Nonfiction|Philosophy|Epistemology', 11079 => 'Books|Nonfiction|Philosophy|Ethics', 11080 => 'Books|Nonfiction|Philosophy|Language', 11081 => 'Books|Nonfiction|Philosophy|Logic', 11082 => 'Books|Nonfiction|Philosophy|Metaphysics', 11083 => 'Books|Nonfiction|Philosophy|Political', 11084 => 'Books|Nonfiction|Philosophy|Religion', 11085 => 'Books|Reference|Manuals', 11086 => 'Books|Kids', 11087 => 'Books|Kids|Animals', 11088 => 'Books|Kids|Basic Concepts', 11089 => 'Books|Kids|Basic Concepts|Alphabet', 11090 => 'Books|Kids|Basic Concepts|Body', 11091 => 'Books|Kids|Basic Concepts|Colors', 11092 => 'Books|Kids|Basic Concepts|Counting & Numbers', 11093 => 'Books|Kids|Basic Concepts|Date & Time', 11094 => 'Books|Kids|Basic Concepts|General', 11095 => 'Books|Kids|Basic Concepts|Money', 11096 => 'Books|Kids|Basic Concepts|Opposites', 11097 => 'Books|Kids|Basic Concepts|Seasons', 11098 => 'Books|Kids|Basic Concepts|Senses & Sensation', 11099 => 'Books|Kids|Basic Concepts|Size & Shape', 11100 => 'Books|Kids|Basic Concepts|Sounds', 11101 => 'Books|Kids|Basic Concepts|Words', 11102 => 'Books|Kids|Biography', 11103 => 'Books|Kids|Careers & Occupations', 11104 => 'Books|Kids|Computers & Technology', 11105 => 'Books|Kids|Cooking & Food', 11106 => 'Books|Kids|Arts & Entertainment', 11107 => 'Books|Kids|Arts & Entertainment|Art', 11108 => 'Books|Kids|Arts & Entertainment|Crafts', 11109 => 'Books|Kids|Arts & Entertainment|Music', 11110 => 'Books|Kids|Arts & Entertainment|Performing Arts', 11111 => 'Books|Kids|Family', 11112 => 'Books|Kids|Fiction', 11113 => 'Books|Kids|Fiction|Action & Adventure', 11114 => 'Books|Kids|Fiction|Animals', 11115 => 'Books|Kids|Fiction|Classics', 11116 => 'Books|Kids|Fiction|Comics & Graphic Novels', 11117 => 'Books|Kids|Fiction|Culture, Places & People', 11118 => 'Books|Kids|Fiction|Family & Relationships', 11119 => 'Books|Kids|Fiction|Fantasy', 11120 => 'Books|Kids|Fiction|Fairy Tales, Myths & Fables', 11121 => 'Books|Kids|Fiction|Favorite Characters', 11122 => 'Books|Kids|Fiction|Historical', 11123 => 'Books|Kids|Fiction|Holidays & Celebrations', 11124 => 'Books|Kids|Fiction|Monsters & Ghosts', 11125 => 'Books|Kids|Fiction|Mysteries', 11126 => 'Books|Kids|Fiction|Nature', 11127 => 'Books|Kids|Fiction|Religion', 11128 => 'Books|Kids|Fiction|Sci-Fi', 11129 => 'Books|Kids|Fiction|Social Issues', 11130 => 'Books|Kids|Fiction|Sports & Recreation', 11131 => 'Books|Kids|Fiction|Transportation', 11132 => 'Books|Kids|Games & Activities', 11133 => 'Books|Kids|General Nonfiction', 11134 => 'Books|Kids|Health', 11135 => 'Books|Kids|History', 11136 => 'Books|Kids|Holidays & Celebrations', 11137 => 'Books|Kids|Holidays & Celebrations|Birthdays', 11138 => 'Books|Kids|Holidays & Celebrations|Christmas & Advent', 11139 => 'Books|Kids|Holidays & Celebrations|Easter & Lent', 11140 => 'Books|Kids|Holidays & Celebrations|General', 11141 => 'Books|Kids|Holidays & Celebrations|Halloween', 11142 => 'Books|Kids|Holidays & Celebrations|Hanukkah', 11143 => 'Books|Kids|Holidays & Celebrations|Other', 11144 => 'Books|Kids|Holidays & Celebrations|Passover', 11145 => 'Books|Kids|Holidays & Celebrations|Patriotic Holidays', 11146 => 'Books|Kids|Holidays & Celebrations|Ramadan', 11147 => 'Books|Kids|Holidays & Celebrations|Thanksgiving', 11148 => "Books|Kids|Holidays & Celebrations|Valentine's Day", 11149 => 'Books|Kids|Humor', 11150 => 'Books|Kids|Humor|Jokes & Riddles', 11151 => 'Books|Kids|Poetry', 11152 => 'Books|Kids|Learning to Read', 11153 => 'Books|Kids|Learning to Read|Chapter Books', 11154 => 'Books|Kids|Learning to Read|Early Readers', 11155 => 'Books|Kids|Learning to Read|Intermediate Readers', 11156 => 'Books|Kids|Nursery Rhymes', 11157 => 'Books|Kids|Government', 11158 => 'Books|Kids|Reference', 11159 => 'Books|Kids|Religion', 11160 => 'Books|Kids|Science & Nature', 11161 => 'Books|Kids|Social Issues', 11162 => 'Books|Kids|Social Studies', 11163 => 'Books|Kids|Sports & Recreation', 11164 => 'Books|Kids|Transportation', 11165 => 'Books|Young Adult', 11166 => 'Books|Young Adult|Animals', 11167 => 'Books|Young Adult|Biography', 11168 => 'Books|Young Adult|Careers & Occupations', 11169 => 'Books|Young Adult|Computers & Technology', 11170 => 'Books|Young Adult|Cooking & Food', 11171 => 'Books|Young Adult|Arts & Entertainment', 11172 => 'Books|Young Adult|Arts & Entertainment|Art', 11173 => 'Books|Young Adult|Arts & Entertainment|Crafts', 11174 => 'Books|Young Adult|Arts & Entertainment|Music', 11175 => 'Books|Young Adult|Arts & Entertainment|Performing Arts', 11176 => 'Books|Young Adult|Family', 11177 => 'Books|Young Adult|Fiction', 11178 => 'Books|Young Adult|Fiction|Action & Adventure', 11179 => 'Books|Young Adult|Fiction|Animals', 11180 => 'Books|Young Adult|Fiction|Classics', 11181 => 'Books|Young Adult|Fiction|Comics & Graphic Novels', 11182 => 'Books|Young Adult|Fiction|Culture, Places & People', 11183 => 'Books|Young Adult|Fiction|Dystopian', 11184 => 'Books|Young Adult|Fiction|Family & Relationships', 11185 => 'Books|Young Adult|Fiction|Fantasy', 11186 => 'Books|Young Adult|Fiction|Fairy Tales, Myths & Fables', 11187 => 'Books|Young Adult|Fiction|Favorite Characters', 11188 => 'Books|Young Adult|Fiction|Historical', 11189 => 'Books|Young Adult|Fiction|Holidays & Celebrations', 11190 => 'Books|Young Adult|Fiction|Horror, Monsters & Ghosts', 11191 => 'Books|Young Adult|Fiction|Crime & Mystery', 11192 => 'Books|Young Adult|Fiction|Nature', 11193 => 'Books|Young Adult|Fiction|Religion', 11194 => 'Books|Young Adult|Fiction|Romance', 11195 => 'Books|Young Adult|Fiction|Sci-Fi', 11196 => 'Books|Young Adult|Fiction|Coming of Age', 11197 => 'Books|Young Adult|Fiction|Sports & Recreation', 11198 => 'Books|Young Adult|Fiction|Transportation', 11199 => 'Books|Young Adult|Games & Activities', 11200 => 'Books|Young Adult|General Nonfiction', 11201 => 'Books|Young Adult|Health', 11202 => 'Books|Young Adult|History', 11203 => 'Books|Young Adult|Holidays & Celebrations', 11204 => 'Books|Young Adult|Holidays & Celebrations|Birthdays', 11205 => 'Books|Young Adult|Holidays & Celebrations|Christmas & Advent', 11206 => 'Books|Young Adult|Holidays & Celebrations|Easter & Lent', 11207 => 'Books|Young Adult|Holidays & Celebrations|General', 11208 => 'Books|Young Adult|Holidays & Celebrations|Halloween', 11209 => 'Books|Young Adult|Holidays & Celebrations|Hanukkah', 11210 => 'Books|Young Adult|Holidays & Celebrations|Other', 11211 => 'Books|Young Adult|Holidays & Celebrations|Passover', 11212 => 'Books|Young Adult|Holidays & Celebrations|Patriotic Holidays', 11213 => 'Books|Young Adult|Holidays & Celebrations|Ramadan', 11214 => 'Books|Young Adult|Holidays & Celebrations|Thanksgiving', 11215 => "Books|Young Adult|Holidays & Celebrations|Valentine's Day", 11216 => 'Books|Young Adult|Humor', 11217 => 'Books|Young Adult|Humor|Jokes & Riddles', 11218 => 'Books|Young Adult|Poetry', 11219 => 'Books|Young Adult|Politics & Government', 11220 => 'Books|Young Adult|Reference', 11221 => 'Books|Young Adult|Religion', 11222 => 'Books|Young Adult|Science & Nature', 11223 => 'Books|Young Adult|Coming of Age', 11224 => 'Books|Young Adult|Social Studies', 11225 => 'Books|Young Adult|Sports & Recreation', 11226 => 'Books|Young Adult|Transportation', 11227 => 'Books|Communications & Media', 11228 => 'Books|Military & Warfare', 11229 => 'Books|Romance|Inspirational', 11231 => 'Books|Romance|Holiday', 11232 => 'Books|Romance|Wholesome', 11233 => 'Books|Romance|Military', 11234 => 'Books|Arts & Entertainment|Art History', 11236 => 'Books|Arts & Entertainment|Design', 11243 => 'Books|Business & Personal Finance|Accounting', 11244 => 'Books|Business & Personal Finance|Hospitality', 11245 => 'Books|Business & Personal Finance|Real Estate', 11246 => 'Books|Humor|Jokes & Riddles', 11247 => 'Books|Religion & Spirituality|Comparative Religion', 11255 => 'Books|Cookbooks, Food & Wine|Culinary Arts', 11259 => 'Books|Mysteries & Thrillers|Cozy', 11260 => 'Books|Politics & Current Events|Current Events', 11261 => 'Books|Politics & Current Events|Foreign Policy & International Relations', 11262 => 'Books|Politics & Current Events|Local Government', 11263 => 'Books|Politics & Current Events|National Government', 11264 => 'Books|Politics & Current Events|Political Science', 11265 => 'Books|Politics & Current Events|Public Administration', 11266 => 'Books|Politics & Current Events|World Affairs', 11273 => 'Books|Nonfiction|Family & Relationships|Family & Childcare', 11274 => 'Books|Nonfiction|Family & Relationships|Love & Romance', 11275 => 'Books|Sci-Fi & Fantasy|Fantasy|Urban', 11276 => 'Books|Reference|Foreign Languages|Arabic', 11277 => 'Books|Reference|Foreign Languages|Bilingual Editions', 11278 => 'Books|Reference|Foreign Languages|African Languages', 11279 => 'Books|Reference|Foreign Languages|Ancient Languages', 11280 => 'Books|Reference|Foreign Languages|Chinese', 11281 => 'Books|Reference|Foreign Languages|English', 11282 => 'Books|Reference|Foreign Languages|French', 11283 => 'Books|Reference|Foreign Languages|German', 11284 => 'Books|Reference|Foreign Languages|Hebrew', 11285 => 'Books|Reference|Foreign Languages|Hindi', 11286 => 'Books|Reference|Foreign Languages|Italian', 11287 => 'Books|Reference|Foreign Languages|Japanese', 11288 => 'Books|Reference|Foreign Languages|Korean', 11289 => 'Books|Reference|Foreign Languages|Linguistics', 11290 => 'Books|Reference|Foreign Languages|Other Languages', 11291 => 'Books|Reference|Foreign Languages|Portuguese', 11292 => 'Books|Reference|Foreign Languages|Russian', 11293 => 'Books|Reference|Foreign Languages|Spanish', 11294 => 'Books|Reference|Foreign Languages|Speech Pathology', 11295 => 'Books|Science & Nature|Mathematics|Advanced Mathematics', 11296 => 'Books|Science & Nature|Mathematics|Algebra', 11297 => 'Books|Science & Nature|Mathematics|Arithmetic', 11298 => 'Books|Science & Nature|Mathematics|Calculus', 11299 => 'Books|Science & Nature|Mathematics|Geometry', 11300 => 'Books|Science & Nature|Mathematics|Statistics', 11301 => 'Books|Professional & Technical|Medical|Veterinary', 11302 => 'Books|Professional & Technical|Medical|Neuroscience', 11303 => 'Books|Professional & Technical|Medical|Immunology', 11304 => 'Books|Professional & Technical|Medical|Nursing', 11305 => 'Books|Professional & Technical|Medical|Pharmacology & Toxicology', 11306 => 'Books|Professional & Technical|Medical|Anatomy & Physiology', 11307 => 'Books|Professional & Technical|Medical|Dentistry', 11308 => 'Books|Professional & Technical|Medical|Emergency Medicine', 11309 => 'Books|Professional & Technical|Medical|Genetics', 11310 => 'Books|Professional & Technical|Medical|Psychiatry', 11311 => 'Books|Professional & Technical|Medical|Radiology', 11312 => 'Books|Professional & Technical|Medical|Alternative Medicine', 11317 => 'Books|Nonfiction|Philosophy|Political Philosophy', 11319 => 'Books|Nonfiction|Philosophy|Philosophy of Language', 11320 => 'Books|Nonfiction|Philosophy|Philosophy of Religion', 11327 => 'Books|Nonfiction|Social Science|Sociology', 11329 => 'Books|Professional & Technical|Engineering|Aeronautics', 11330 => 'Books|Professional & Technical|Engineering|Chemical & Petroleum Engineering', 11331 => 'Books|Professional & Technical|Engineering|Civil Engineering', 11332 => 'Books|Professional & Technical|Engineering|Computer Science', 11333 => 'Books|Professional & Technical|Engineering|Electrical Engineering', 11334 => 'Books|Professional & Technical|Engineering|Environmental Engineering', 11335 => 'Books|Professional & Technical|Engineering|Mechanical Engineering', 11336 => 'Books|Professional & Technical|Engineering|Power Resources', 11337 => 'Books|Comics & Graphic Novels|Manga|Boys', 11338 => 'Books|Comics & Graphic Novels|Manga|Men', 11339 => 'Books|Comics & Graphic Novels|Manga|Girls', 11340 => 'Books|Comics & Graphic Novels|Manga|Women', 11341 => 'Books|Comics & Graphic Novels|Manga|Other', 12001 => 'Mac App Store|Business', 12002 => 'Mac App Store|Developer Tools', 12003 => 'Mac App Store|Education', 12004 => 'Mac App Store|Entertainment', 12005 => 'Mac App Store|Finance', 12006 => 'Mac App Store|Games', 12007 => 'Mac App Store|Health & Fitness', 12008 => 'Mac App Store|Lifestyle', 12010 => 'Mac App Store|Medical', 12011 => 'Mac App Store|Music', 12012 => 'Mac App Store|News', 12013 => 'Mac App Store|Photography', 12014 => 'Mac App Store|Productivity', 12015 => 'Mac App Store|Reference', 12016 => 'Mac App Store|Social Networking', 12017 => 'Mac App Store|Sports', 12018 => 'Mac App Store|Travel', 12019 => 'Mac App Store|Utilities', 12020 => 'Mac App Store|Video', 12021 => 'Mac App Store|Weather', 12022 => 'Mac App Store|Graphics & Design', 12201 => 'Mac App Store|Games|Action', 12202 => 'Mac App Store|Games|Adventure', 12203 => 'Mac App Store|Games|Arcade', 12204 => 'Mac App Store|Games|Board', 12205 => 'Mac App Store|Games|Card', 12206 => 'Mac App Store|Games|Casino', 12207 => 'Mac App Store|Games|Dice', 12208 => 'Mac App Store|Games|Educational', 12209 => 'Mac App Store|Games|Family', 12210 => 'Mac App Store|Games|Kids', 12211 => 'Mac App Store|Games|Music', 12212 => 'Mac App Store|Games|Puzzle', 12213 => 'Mac App Store|Games|Racing', 12214 => 'Mac App Store|Games|Role Playing', 12215 => 'Mac App Store|Games|Simulation', 12216 => 'Mac App Store|Games|Sports', 12217 => 'Mac App Store|Games|Strategy', 12218 => 'Mac App Store|Games|Trivia', 12219 => 'Mac App Store|Games|Word', 13001 => 'App Store|Newsstand|News & Politics', 13002 => 'App Store|Newsstand|Fashion & Style', 13003 => 'App Store|Newsstand|Home & Garden', 13004 => 'App Store|Newsstand|Outdoors & Nature', 13005 => 'App Store|Newsstand|Sports & Leisure', 13006 => 'App Store|Newsstand|Automotive', 13007 => 'App Store|Newsstand|Arts & Photography', 13008 => 'App Store|Newsstand|Brides & Weddings', 13009 => 'App Store|Newsstand|Business & Investing', 13010 => "App Store|Newsstand|Children's Magazines", 13011 => 'App Store|Newsstand|Computers & Internet', 13012 => 'App Store|Newsstand|Cooking, Food & Drink', 13013 => 'App Store|Newsstand|Crafts & Hobbies', 13014 => 'App Store|Newsstand|Electronics & Audio', 13015 => 'App Store|Newsstand|Entertainment', 13017 => 'App Store|Newsstand|Health, Mind & Body', 13018 => 'App Store|Newsstand|History', 13019 => 'App Store|Newsstand|Literary Magazines & Journals', 13020 => "App Store|Newsstand|Men's Interest", 13021 => 'App Store|Newsstand|Movies & Music', 13023 => 'App Store|Newsstand|Parenting & Family', 13024 => 'App Store|Newsstand|Pets', 13025 => 'App Store|Newsstand|Professional & Trade', 13026 => 'App Store|Newsstand|Regional News', 13027 => 'App Store|Newsstand|Science', 13028 => 'App Store|Newsstand|Teens', 13029 => 'App Store|Newsstand|Travel & Regional', 13030 => "App Store|Newsstand|Women's Interest", 15000 => 'Textbooks|Arts & Entertainment', 15001 => 'Textbooks|Arts & Entertainment|Art & Architecture', 15002 => 'Textbooks|Arts & Entertainment|Art & Architecture|Urban Planning', 15003 => 'Textbooks|Arts & Entertainment|Art History', 15004 => 'Textbooks|Arts & Entertainment|Dance', 15005 => 'Textbooks|Arts & Entertainment|Design', 15006 => 'Textbooks|Arts & Entertainment|Fashion', 15007 => 'Textbooks|Arts & Entertainment|Film', 15008 => 'Textbooks|Arts & Entertainment|Games', 15009 => 'Textbooks|Arts & Entertainment|Interior Design', 15010 => 'Textbooks|Arts & Entertainment|Media Arts', 15011 => 'Textbooks|Arts & Entertainment|Music', 15012 => 'Textbooks|Arts & Entertainment|Performing Arts', 15013 => 'Textbooks|Arts & Entertainment|Photography', 15014 => 'Textbooks|Arts & Entertainment|Theater', 15015 => 'Textbooks|Arts & Entertainment|TV', 15016 => 'Textbooks|Arts & Entertainment|Visual Arts', 15017 => 'Textbooks|Biographies & Memoirs', 15018 => 'Textbooks|Business & Personal Finance', 15019 => 'Textbooks|Business & Personal Finance|Accounting', 15020 => 'Textbooks|Business & Personal Finance|Careers', 15021 => 'Textbooks|Business & Personal Finance|Economics', 15022 => 'Textbooks|Business & Personal Finance|Finance', 15023 => 'Textbooks|Business & Personal Finance|Hospitality', 15024 => 'Textbooks|Business & Personal Finance|Industries & Professions', 15025 => 'Textbooks|Business & Personal Finance|Investing', 15026 => 'Textbooks|Business & Personal Finance|Management & Leadership', 15027 => 'Textbooks|Business & Personal Finance|Marketing & Sales', 15028 => 'Textbooks|Business & Personal Finance|Personal Finance', 15029 => 'Textbooks|Business & Personal Finance|Real Estate', 15030 => 'Textbooks|Business & Personal Finance|Reference', 15031 => 'Textbooks|Business & Personal Finance|Small Business & Entrepreneurship', 15032 => 'Textbooks|Children & Teens', 15033 => 'Textbooks|Children & Teens|Fiction', 15034 => 'Textbooks|Children & Teens|Nonfiction', 15035 => 'Textbooks|Comics & Graphic Novels', 15036 => 'Textbooks|Comics & Graphic Novels|Graphic Novels', 15037 => 'Textbooks|Comics & Graphic Novels|Manga', 15038 => 'Textbooks|Communications & Media', 15039 => 'Textbooks|Communications & Media|Broadcasting', 15040 => 'Textbooks|Communications & Media|Digital Media', 15041 => 'Textbooks|Communications & Media|Journalism', 15042 => 'Textbooks|Communications & Media|Photojournalism', 15043 => 'Textbooks|Communications & Media|Print', 15044 => 'Textbooks|Communications & Media|Speech', 15045 => 'Textbooks|Communications & Media|Writing', 15046 => 'Textbooks|Computers & Internet', 15047 => 'Textbooks|Computers & Internet|Computers', 15048 => 'Textbooks|Computers & Internet|Databases', 15049 => 'Textbooks|Computers & Internet|Digital Media', 15050 => 'Textbooks|Computers & Internet|Internet', 15051 => 'Textbooks|Computers & Internet|Network', 15052 => 'Textbooks|Computers & Internet|Operating Systems', 15053 => 'Textbooks|Computers & Internet|Programming', 15054 => 'Textbooks|Computers & Internet|Software', 15055 => 'Textbooks|Computers & Internet|System Administration', 15056 => 'Textbooks|Cookbooks, Food & Wine', 15057 => 'Textbooks|Cookbooks, Food & Wine|Beverages', 15058 => 'Textbooks|Cookbooks, Food & Wine|Courses & Dishes', 15059 => 'Textbooks|Cookbooks, Food & Wine|Culinary Arts', 15060 => 'Textbooks|Cookbooks, Food & Wine|Methods', 15061 => 'Textbooks|Cookbooks, Food & Wine|Reference', 15062 => 'Textbooks|Cookbooks, Food & Wine|Regional & Ethnic', 15063 => 'Textbooks|Cookbooks, Food & Wine|Special Diet', 15064 => 'Textbooks|Cookbooks, Food & Wine|Special Occasions', 15065 => 'Textbooks|Cookbooks, Food & Wine|Specific Ingredients', 15066 => 'Textbooks|Engineering', 15067 => 'Textbooks|Engineering|Aeronautics', 15068 => 'Textbooks|Engineering|Chemical & Petroleum Engineering', 15069 => 'Textbooks|Engineering|Civil Engineering', 15070 => 'Textbooks|Engineering|Computer Science', 15071 => 'Textbooks|Engineering|Electrical Engineering', 15072 => 'Textbooks|Engineering|Environmental Engineering', 15073 => 'Textbooks|Engineering|Mechanical Engineering', 15074 => 'Textbooks|Engineering|Power Resources', 15075 => 'Textbooks|Fiction & Literature', 15076 => 'Textbooks|Fiction & Literature|Latino', 15077 => 'Textbooks|Fiction & Literature|Action & Adventure', 15078 => 'Textbooks|Fiction & Literature|African American', 15079 => 'Textbooks|Fiction & Literature|Anthologies', 15080 => 'Textbooks|Fiction & Literature|Classics', 15081 => 'Textbooks|Fiction & Literature|Comparative Literature', 15082 => 'Textbooks|Fiction & Literature|Erotica', 15083 => 'Textbooks|Fiction & Literature|Gay', 15084 => 'Textbooks|Fiction & Literature|Ghost', 15085 => 'Textbooks|Fiction & Literature|Historical', 15086 => 'Textbooks|Fiction & Literature|Horror', 15087 => 'Textbooks|Fiction & Literature|Literary', 15088 => 'Textbooks|Fiction & Literature|Literary Criticism', 15089 => 'Textbooks|Fiction & Literature|Poetry', 15090 => 'Textbooks|Fiction & Literature|Religious', 15091 => 'Textbooks|Fiction & Literature|Short Stories', 15092 => 'Textbooks|Health, Mind & Body', 15093 => 'Textbooks|Health, Mind & Body|Fitness', 15094 => 'Textbooks|Health, Mind & Body|Self-Improvement', 15095 => 'Textbooks|History', 15096 => 'Textbooks|History|Africa', 15097 => 'Textbooks|History|Americas', 15098 => 'Textbooks|History|Americas|Canada', 15099 => 'Textbooks|History|Americas|Latin America', 15100 => 'Textbooks|History|Americas|United States', 15101 => 'Textbooks|History|Ancient', 15102 => 'Textbooks|History|Asia', 15103 => 'Textbooks|History|Australia & Oceania', 15104 => 'Textbooks|History|Europe', 15105 => 'Textbooks|History|Middle East', 15106 => 'Textbooks|History|Military', 15107 => 'Textbooks|History|World', 15108 => 'Textbooks|Humor', 15109 => 'Textbooks|Language Studies', 15110 => 'Textbooks|Language Studies|African Languages', 15111 => 'Textbooks|Language Studies|Ancient Languages', 15112 => 'Textbooks|Language Studies|Arabic', 15113 => 'Textbooks|Language Studies|Bilingual Editions', 15114 => 'Textbooks|Language Studies|Chinese', 15115 => 'Textbooks|Language Studies|English', 15116 => 'Textbooks|Language Studies|French', 15117 => 'Textbooks|Language Studies|German', 15118 => 'Textbooks|Language Studies|Hebrew', 15119 => 'Textbooks|Language Studies|Hindi', 15120 => 'Textbooks|Language Studies|Indigenous Languages', 15121 => 'Textbooks|Language Studies|Italian', 15122 => 'Textbooks|Language Studies|Japanese', 15123 => 'Textbooks|Language Studies|Korean', 15124 => 'Textbooks|Language Studies|Linguistics', 15125 => 'Textbooks|Language Studies|Other Language', 15126 => 'Textbooks|Language Studies|Portuguese', 15127 => 'Textbooks|Language Studies|Russian', 15128 => 'Textbooks|Language Studies|Spanish', 15129 => 'Textbooks|Language Studies|Speech Pathology', 15130 => 'Textbooks|Lifestyle & Home', 15131 => 'Textbooks|Lifestyle & Home|Antiques & Collectibles', 15132 => 'Textbooks|Lifestyle & Home|Crafts & Hobbies', 15133 => 'Textbooks|Lifestyle & Home|Gardening', 15134 => 'Textbooks|Lifestyle & Home|Pets', 15135 => 'Textbooks|Mathematics', 15136 => 'Textbooks|Mathematics|Advanced Mathematics', 15137 => 'Textbooks|Mathematics|Algebra', 15138 => 'Textbooks|Mathematics|Arithmetic', 15139 => 'Textbooks|Mathematics|Calculus', 15140 => 'Textbooks|Mathematics|Geometry', 15141 => 'Textbooks|Mathematics|Statistics', 15142 => 'Textbooks|Medicine', 15143 => 'Textbooks|Medicine|Anatomy & Physiology', 15144 => 'Textbooks|Medicine|Dentistry', 15145 => 'Textbooks|Medicine|Emergency Medicine', 15146 => 'Textbooks|Medicine|Genetics', 15147 => 'Textbooks|Medicine|Immunology', 15148 => 'Textbooks|Medicine|Neuroscience', 15149 => 'Textbooks|Medicine|Nursing', 15150 => 'Textbooks|Medicine|Pharmacology & Toxicology', 15151 => 'Textbooks|Medicine|Psychiatry', 15152 => 'Textbooks|Medicine|Psychology', 15153 => 'Textbooks|Medicine|Radiology', 15154 => 'Textbooks|Medicine|Veterinary', 15155 => 'Textbooks|Mysteries & Thrillers', 15156 => 'Textbooks|Mysteries & Thrillers|British Detectives', 15157 => 'Textbooks|Mysteries & Thrillers|Hard-Boiled', 15158 => 'Textbooks|Mysteries & Thrillers|Historical', 15159 => 'Textbooks|Mysteries & Thrillers|Police Procedural', 15160 => 'Textbooks|Mysteries & Thrillers|Short Stories', 15161 => 'Textbooks|Mysteries & Thrillers|Women Sleuths', 15162 => 'Textbooks|Nonfiction', 15163 => 'Textbooks|Nonfiction|Family & Relationships', 15164 => 'Textbooks|Nonfiction|Transportation', 15165 => 'Textbooks|Nonfiction|True Crime', 15166 => 'Textbooks|Parenting', 15167 => 'Textbooks|Philosophy', 15168 => 'Textbooks|Philosophy|Aesthetics', 15169 => 'Textbooks|Philosophy|Epistemology', 15170 => 'Textbooks|Philosophy|Ethics', 15171 => 'Textbooks|Philosophy|Philosophy of Language', 15172 => 'Textbooks|Philosophy|Logic', 15173 => 'Textbooks|Philosophy|Metaphysics', 15174 => 'Textbooks|Philosophy|Political Philosophy', 15175 => 'Textbooks|Philosophy|Philosophy of Religion', 15176 => 'Textbooks|Politics & Current Events', 15177 => 'Textbooks|Politics & Current Events|Current Events', 15178 => 'Textbooks|Politics & Current Events|Foreign Policy & International Relations', 15179 => 'Textbooks|Politics & Current Events|Local Governments', 15180 => 'Textbooks|Politics & Current Events|National Governments', 15181 => 'Textbooks|Politics & Current Events|Political Science', 15182 => 'Textbooks|Politics & Current Events|Public Administration', 15183 => 'Textbooks|Politics & Current Events|World Affairs', 15184 => 'Textbooks|Professional & Technical', 15185 => 'Textbooks|Professional & Technical|Design', 15186 => 'Textbooks|Professional & Technical|Language Arts & Disciplines', 15187 => 'Textbooks|Professional & Technical|Engineering', 15188 => 'Textbooks|Professional & Technical|Law', 15189 => 'Textbooks|Professional & Technical|Medical', 15190 => 'Textbooks|Reference', 15191 => 'Textbooks|Reference|Almanacs & Yearbooks', 15192 => 'Textbooks|Reference|Atlases & Maps', 15193 => 'Textbooks|Reference|Catalogs & Directories', 15194 => 'Textbooks|Reference|Consumer Guides', 15195 => 'Textbooks|Reference|Dictionaries & Thesauruses', 15196 => 'Textbooks|Reference|Encyclopedias', 15197 => 'Textbooks|Reference|Etiquette', 15198 => 'Textbooks|Reference|Quotations', 15199 => 'Textbooks|Reference|Study Aids', 15200 => 'Textbooks|Reference|Words & Language', 15201 => 'Textbooks|Reference|Writing', 15202 => 'Textbooks|Religion & Spirituality', 15203 => 'Textbooks|Religion & Spirituality|Bible Studies', 15204 => 'Textbooks|Religion & Spirituality|Bibles', 15205 => 'Textbooks|Religion & Spirituality|Buddhism', 15206 => 'Textbooks|Religion & Spirituality|Christianity', 15207 => 'Textbooks|Religion & Spirituality|Comparative Religion', 15208 => 'Textbooks|Religion & Spirituality|Hinduism', 15209 => 'Textbooks|Religion & Spirituality|Islam', 15210 => 'Textbooks|Religion & Spirituality|Judaism', 15211 => 'Textbooks|Religion & Spirituality|Spirituality', 15212 => 'Textbooks|Romance', 15213 => 'Textbooks|Romance|Contemporary', 15214 => 'Textbooks|Romance|Erotic Romance', 15215 => 'Textbooks|Romance|Paranormal', 15216 => 'Textbooks|Romance|Historical', 15217 => 'Textbooks|Romance|Short Stories', 15218 => 'Textbooks|Romance|Suspense', 15219 => 'Textbooks|Romance|Western', 15220 => 'Textbooks|Sci-Fi & Fantasy', 15221 => 'Textbooks|Sci-Fi & Fantasy|Fantasy', 15222 => 'Textbooks|Sci-Fi & Fantasy|Fantasy|Contemporary', 15223 => 'Textbooks|Sci-Fi & Fantasy|Fantasy|Epic', 15224 => 'Textbooks|Sci-Fi & Fantasy|Fantasy|Historical', 15225 => 'Textbooks|Sci-Fi & Fantasy|Fantasy|Paranormal', 15226 => 'Textbooks|Sci-Fi & Fantasy|Fantasy|Short Stories', 15227 => 'Textbooks|Sci-Fi & Fantasy|Science Fiction', 15228 => 'Textbooks|Sci-Fi & Fantasy|Science Fiction & Literature', 15229 => 'Textbooks|Sci-Fi & Fantasy|Science Fiction & Literature|Adventure', 15230 => 'Textbooks|Sci-Fi & Fantasy|Science Fiction & Literature|High Tech', 15231 => 'Textbooks|Sci-Fi & Fantasy|Science Fiction & Literature|Short Stories', 15232 => 'Textbooks|Science & Nature', 15233 => 'Textbooks|Science & Nature|Agriculture', 15234 => 'Textbooks|Science & Nature|Astronomy', 15235 => 'Textbooks|Science & Nature|Atmosphere', 15236 => 'Textbooks|Science & Nature|Biology', 15237 => 'Textbooks|Science & Nature|Chemistry', 15238 => 'Textbooks|Science & Nature|Earth Sciences', 15239 => 'Textbooks|Science & Nature|Ecology', 15240 => 'Textbooks|Science & Nature|Environment', 15241 => 'Textbooks|Science & Nature|Essays', 15242 => 'Textbooks|Science & Nature|Geography', 15243 => 'Textbooks|Science & Nature|Geology', 15244 => 'Textbooks|Science & Nature|History', 15245 => 'Textbooks|Science & Nature|Life Sciences', 15246 => 'Textbooks|Science & Nature|Nature', 15247 => 'Textbooks|Science & Nature|Physics', 15248 => 'Textbooks|Science & Nature|Reference', 15249 => 'Textbooks|Social Science', 15250 => 'Textbooks|Social Science|Anthropology', 15251 => 'Textbooks|Social Science|Archaeology', 15252 => 'Textbooks|Social Science|Civics', 15253 => 'Textbooks|Social Science|Government', 15254 => 'Textbooks|Social Science|Social Studies', 15255 => 'Textbooks|Social Science|Social Welfare', 15256 => 'Textbooks|Social Science|Society', 15257 => 'Textbooks|Social Science|Society|African Studies', 15258 => 'Textbooks|Social Science|Society|American Studies', 15259 => 'Textbooks|Social Science|Society|Asia Pacific Studies', 15260 => 'Textbooks|Social Science|Society|Cross-Cultural Studies', 15261 => 'Textbooks|Social Science|Society|European Studies', 15262 => 'Textbooks|Social Science|Society|Immigration & Emigration', 15263 => 'Textbooks|Social Science|Society|Indigenous Studies', 15264 => 'Textbooks|Social Science|Society|Latin & Caribbean Studies', 15265 => 'Textbooks|Social Science|Society|Middle Eastern Studies', 15266 => 'Textbooks|Social Science|Society|Race & Ethnicity Studies', 15267 => 'Textbooks|Social Science|Society|Sexuality Studies', 15268 => "Textbooks|Social Science|Society|Women's Studies", 15269 => 'Textbooks|Social Science|Sociology', 15270 => 'Textbooks|Sports & Outdoors', 15271 => 'Textbooks|Sports & Outdoors|Baseball', 15272 => 'Textbooks|Sports & Outdoors|Basketball', 15273 => 'Textbooks|Sports & Outdoors|Coaching', 15274 => 'Textbooks|Sports & Outdoors|Equestrian', 15275 => 'Textbooks|Sports & Outdoors|Extreme Sports', 15276 => 'Textbooks|Sports & Outdoors|Football', 15277 => 'Textbooks|Sports & Outdoors|Golf', 15278 => 'Textbooks|Sports & Outdoors|Hockey', 15279 => 'Textbooks|Sports & Outdoors|Motor Sports', 15280 => 'Textbooks|Sports & Outdoors|Mountaineering', 15281 => 'Textbooks|Sports & Outdoors|Outdoors', 15282 => 'Textbooks|Sports & Outdoors|Racket Sports', 15283 => 'Textbooks|Sports & Outdoors|Reference', 15284 => 'Textbooks|Sports & Outdoors|Soccer', 15285 => 'Textbooks|Sports & Outdoors|Training', 15286 => 'Textbooks|Sports & Outdoors|Water Sports', 15287 => 'Textbooks|Sports & Outdoors|Winter Sports', 15288 => 'Textbooks|Teaching & Learning', 15289 => 'Textbooks|Teaching & Learning|Adult Education', 15290 => 'Textbooks|Teaching & Learning|Curriculum & Teaching', 15291 => 'Textbooks|Teaching & Learning|Educational Leadership', 15292 => 'Textbooks|Teaching & Learning|Educational Technology', 15293 => 'Textbooks|Teaching & Learning|Family & Childcare', 15294 => 'Textbooks|Teaching & Learning|Information & Library Science', 15295 => 'Textbooks|Teaching & Learning|Learning Resources', 15296 => 'Textbooks|Teaching & Learning|Psychology & Research', 15297 => 'Textbooks|Teaching & Learning|Special Education', 15298 => 'Textbooks|Travel & Adventure', 15299 => 'Textbooks|Travel & Adventure|Africa', 15300 => 'Textbooks|Travel & Adventure|Americas', 15301 => 'Textbooks|Travel & Adventure|Americas|Canada', 15302 => 'Textbooks|Travel & Adventure|Americas|Latin America', 15303 => 'Textbooks|Travel & Adventure|Americas|United States', 15304 => 'Textbooks|Travel & Adventure|Asia', 15305 => 'Textbooks|Travel & Adventure|Caribbean', 15306 => 'Textbooks|Travel & Adventure|Essays & Memoirs', 15307 => 'Textbooks|Travel & Adventure|Europe', 15308 => 'Textbooks|Travel & Adventure|Middle East', 15309 => 'Textbooks|Travel & Adventure|Oceania', 15310 => 'Textbooks|Travel & Adventure|Specialty Travel', 15311 => 'Textbooks|Comics & Graphic Novels|Comics', 15312 => 'Textbooks|Reference|Manuals', 100000 => 'Music|Christian & Gospel', 100001 => 'Music|Classical|Art Song', 100002 => 'Music|Classical|Brass & Woodwinds', 100003 => 'Music|Classical|Solo Instrumental', 100004 => 'Music|Classical|Contemporary Era', 100005 => 'Music|Classical|Oratorio', 100006 => 'Music|Classical|Cantata', 100007 => 'Music|Classical|Electronic', 100008 => 'Music|Classical|Sacred', 100009 => 'Music|Classical|Guitar', 100010 => 'Music|Classical|Piano', 100011 => 'Music|Classical|Violin', 100012 => 'Music|Classical|Cello', 100013 => 'Music|Classical|Percussion', 100014 => 'Music|Electronic|Dubstep', 100015 => 'Music|Electronic|Bass', 100016 => 'Music|Hip-Hop/Rap|UK Hip-Hop', 100017 => 'Music|Reggae|Lovers Rock', 100018 => 'Music|Alternative|EMO', 100019 => 'Music|Alternative|Pop Punk', 100020 => 'Music|Alternative|Indie Pop', 100021 => 'Music|New Age|Yoga', 100022 => 'Music|Pop|Tribute', 40000000 => 'iTunes U', 40000001 => 'iTunes U|Business', 40000002 => 'iTunes U|Business|Economics', 40000003 => 'iTunes U|Business|Finance', 40000004 => 'iTunes U|Business|Hospitality', 40000005 => 'iTunes U|Business|Management', 40000006 => 'iTunes U|Business|Marketing', 40000007 => 'iTunes U|Business|Personal Finance', 40000008 => 'iTunes U|Business|Real Estate', 40000009 => 'iTunes U|Engineering', 40000010 => 'iTunes U|Engineering|Chemical & Petroleum Engineering', 40000011 => 'iTunes U|Engineering|Civil Engineering', 40000012 => 'iTunes U|Engineering|Computer Science', 40000013 => 'iTunes U|Engineering|Electrical Engineering', 40000014 => 'iTunes U|Engineering|Environmental Engineering', 40000015 => 'iTunes U|Engineering|Mechanical Engineering', 40000016 => 'iTunes U|Art & Architecture', 40000017 => 'iTunes U|Art & Architecture|Architecture', 40000019 => 'iTunes U|Art & Architecture|Art History', 40000020 => 'iTunes U|Art & Architecture|Dance', 40000021 => 'iTunes U|Art & Architecture|Film', 40000022 => 'iTunes U|Art & Architecture|Design', 40000023 => 'iTunes U|Art & Architecture|Interior Design', 40000024 => 'iTunes U|Art & Architecture|Music', 40000025 => 'iTunes U|Art & Architecture|Theater', 40000026 => 'iTunes U|Health & Medicine', 40000027 => 'iTunes U|Health & Medicine|Anatomy & Physiology', 40000028 => 'iTunes U|Health & Medicine|Behavioral Science', 40000029 => 'iTunes U|Health & Medicine|Dentistry', 40000030 => 'iTunes U|Health & Medicine|Diet & Nutrition', 40000031 => 'iTunes U|Health & Medicine|Emergency Medicine', 40000032 => 'iTunes U|Health & Medicine|Genetics', 40000033 => 'iTunes U|Health & Medicine|Gerontology', 40000034 => 'iTunes U|Health & Medicine|Health & Exercise Science', 40000035 => 'iTunes U|Health & Medicine|Immunology', 40000036 => 'iTunes U|Health & Medicine|Neuroscience', 40000037 => 'iTunes U|Health & Medicine|Pharmacology & Toxicology', 40000038 => 'iTunes U|Health & Medicine|Psychiatry', 40000039 => 'iTunes U|Health & Medicine|Global Health', 40000040 => 'iTunes U|Health & Medicine|Radiology', 40000041 => 'iTunes U|History', 40000042 => 'iTunes U|History|Ancient History', 40000043 => 'iTunes U|History|Medieval History', 40000044 => 'iTunes U|History|Military History', 40000045 => 'iTunes U|History|Modern History', 40000046 => 'iTunes U|History|African History', 40000047 => 'iTunes U|History|Asia-Pacific History', 40000048 => 'iTunes U|History|European History', 40000049 => 'iTunes U|History|Middle Eastern History', 40000050 => 'iTunes U|History|North American History', 40000051 => 'iTunes U|History|South American History', 40000053 => 'iTunes U|Communications & Media', 40000054 => 'iTunes U|Philosophy', 40000055 => 'iTunes U|Religion & Spirituality', 40000056 => 'iTunes U|Language', 40000057 => 'iTunes U|Language|African Languages', 40000058 => 'iTunes U|Language|Ancient Languages', 40000061 => 'iTunes U|Language|English', 40000063 => 'iTunes U|Language|French', 40000064 => 'iTunes U|Language|German', 40000065 => 'iTunes U|Language|Italian', 40000066 => 'iTunes U|Language|Linguistics', 40000068 => 'iTunes U|Language|Spanish', 40000069 => 'iTunes U|Language|Speech Pathology', 40000070 => 'iTunes U|Literature', 40000071 => 'iTunes U|Literature|Anthologies', 40000072 => 'iTunes U|Literature|Biography', 40000073 => 'iTunes U|Literature|Classics', 40000074 => 'iTunes U|Literature|Literary Criticism', 40000075 => 'iTunes U|Literature|Fiction', 40000076 => 'iTunes U|Literature|Poetry', 40000077 => 'iTunes U|Mathematics', 40000078 => 'iTunes U|Mathematics|Advanced Mathematics', 40000079 => 'iTunes U|Mathematics|Algebra', 40000080 => 'iTunes U|Mathematics|Arithmetic', 40000081 => 'iTunes U|Mathematics|Calculus', 40000082 => 'iTunes U|Mathematics|Geometry', 40000083 => 'iTunes U|Mathematics|Statistics', 40000084 => 'iTunes U|Science', 40000085 => 'iTunes U|Science|Agricultural', 40000086 => 'iTunes U|Science|Astronomy', 40000087 => 'iTunes U|Science|Atmosphere', 40000088 => 'iTunes U|Science|Biology', 40000089 => 'iTunes U|Science|Chemistry', 40000090 => 'iTunes U|Science|Ecology', 40000091 => 'iTunes U|Science|Geography', 40000092 => 'iTunes U|Science|Geology', 40000093 => 'iTunes U|Science|Physics', 40000094 => 'iTunes U|Psychology & Social Science', 40000095 => 'iTunes U|Law & Politics|Law', 40000096 => 'iTunes U|Law & Politics|Political Science', 40000097 => 'iTunes U|Law & Politics|Public Administration', 40000098 => 'iTunes U|Psychology & Social Science|Psychology', 40000099 => 'iTunes U|Psychology & Social Science|Social Welfare', 40000100 => 'iTunes U|Psychology & Social Science|Sociology', 40000101 => 'iTunes U|Society', 40000103 => 'iTunes U|Society|Asia Pacific Studies', 40000104 => 'iTunes U|Society|European Studies', 40000105 => 'iTunes U|Society|Indigenous Studies', 40000106 => 'iTunes U|Society|Latin & Caribbean Studies', 40000107 => 'iTunes U|Society|Middle Eastern Studies', 40000108 => "iTunes U|Society|Women's Studies", 40000109 => 'iTunes U|Teaching & Learning', 40000110 => 'iTunes U|Teaching & Learning|Curriculum & Teaching', 40000111 => 'iTunes U|Teaching & Learning|Educational Leadership', 40000112 => 'iTunes U|Teaching & Learning|Family & Childcare', 40000113 => 'iTunes U|Teaching & Learning|Learning Resources', 40000114 => 'iTunes U|Teaching & Learning|Psychology & Research', 40000115 => 'iTunes U|Teaching & Learning|Special Education', 40000116 => 'iTunes U|Art & Architecture|Culinary Arts', 40000117 => 'iTunes U|Art & Architecture|Fashion', 40000118 => 'iTunes U|Art & Architecture|Media Arts', 40000119 => 'iTunes U|Art & Architecture|Photography', 40000120 => 'iTunes U|Art & Architecture|Visual Art', 40000121 => 'iTunes U|Business|Entrepreneurship', 40000122 => 'iTunes U|Communications & Media|Broadcasting', 40000123 => 'iTunes U|Communications & Media|Digital Media', 40000124 => 'iTunes U|Communications & Media|Journalism', 40000125 => 'iTunes U|Communications & Media|Photojournalism', 40000126 => 'iTunes U|Communications & Media|Print', 40000127 => 'iTunes U|Communications & Media|Speech', 40000128 => 'iTunes U|Communications & Media|Writing', 40000129 => 'iTunes U|Health & Medicine|Nursing', 40000130 => 'iTunes U|Language|Arabic', 40000131 => 'iTunes U|Language|Chinese', 40000132 => 'iTunes U|Language|Hebrew', 40000133 => 'iTunes U|Language|Hindi', 40000134 => 'iTunes U|Language|Indigenous Languages', 40000135 => 'iTunes U|Language|Japanese', 40000136 => 'iTunes U|Language|Korean', 40000137 => 'iTunes U|Language|Other Languages', 40000138 => 'iTunes U|Language|Portuguese', 40000139 => 'iTunes U|Language|Russian', 40000140 => 'iTunes U|Law & Politics', 40000141 => 'iTunes U|Law & Politics|Foreign Policy & International Relations', 40000142 => 'iTunes U|Law & Politics|Local Governments', 40000143 => 'iTunes U|Law & Politics|National Governments', 40000144 => 'iTunes U|Law & Politics|World Affairs', 40000145 => 'iTunes U|Literature|Comparative Literature', 40000146 => 'iTunes U|Philosophy|Aesthetics', 40000147 => 'iTunes U|Philosophy|Epistemology', 40000148 => 'iTunes U|Philosophy|Ethics', 40000149 => 'iTunes U|Philosophy|Metaphysics', 40000150 => 'iTunes U|Philosophy|Political Philosophy', 40000151 => 'iTunes U|Philosophy|Logic', 40000152 => 'iTunes U|Philosophy|Philosophy of Language', 40000153 => 'iTunes U|Philosophy|Philosophy of Religion', 40000154 => 'iTunes U|Psychology & Social Science|Archaeology', 40000155 => 'iTunes U|Psychology & Social Science|Anthropology', 40000156 => 'iTunes U|Religion & Spirituality|Buddhism', 40000157 => 'iTunes U|Religion & Spirituality|Christianity', 40000158 => 'iTunes U|Religion & Spirituality|Comparative Religion', 40000159 => 'iTunes U|Religion & Spirituality|Hinduism', 40000160 => 'iTunes U|Religion & Spirituality|Islam', 40000161 => 'iTunes U|Religion & Spirituality|Judaism', 40000162 => 'iTunes U|Religion & Spirituality|Other Religions', 40000163 => 'iTunes U|Religion & Spirituality|Spirituality', 40000164 => 'iTunes U|Science|Environment', 40000165 => 'iTunes U|Society|African Studies', 40000166 => 'iTunes U|Society|American Studies', 40000167 => 'iTunes U|Society|Cross-cultural Studies', 40000168 => 'iTunes U|Society|Immigration & Emigration', 40000169 => 'iTunes U|Society|Race & Ethnicity Studies', 40000170 => 'iTunes U|Society|Sexuality Studies', 40000171 => 'iTunes U|Teaching & Learning|Educational Technology', 40000172 => 'iTunes U|Teaching & Learning|Information/Library Science', 40000173 => 'iTunes U|Language|Dutch', 40000174 => 'iTunes U|Language|Luxembourgish', 40000175 => 'iTunes U|Language|Swedish', 40000176 => 'iTunes U|Language|Norwegian', 40000177 => 'iTunes U|Language|Finnish', 40000178 => 'iTunes U|Language|Danish', 40000179 => 'iTunes U|Language|Polish', 40000180 => 'iTunes U|Language|Turkish', 40000181 => 'iTunes U|Language|Flemish', 50000024 => 'Audiobooks', 50000040 => 'Audiobooks|Fiction', 50000041 => 'Audiobooks|Arts & Entertainment', 50000042 => 'Audiobooks|Biography & Memoir', 50000043 => 'Audiobooks|Business', 50000044 => 'Audiobooks|Kids & Young Adults', 50000045 => 'Audiobooks|Classics', 50000046 => 'Audiobooks|Comedy', 50000047 => 'Audiobooks|Drama & Poetry', 50000048 => 'Audiobooks|Speakers & Storytellers', 50000049 => 'Audiobooks|History', 50000050 => 'Audiobooks|Languages', 50000051 => 'Audiobooks|Mystery', 50000052 => 'Audiobooks|Nonfiction', 50000053 => 'Audiobooks|Religion & Spirituality', 50000054 => 'Audiobooks|Science', 50000055 => 'Audiobooks|Sci Fi & Fantasy', 50000056 => 'Audiobooks|Self Development', 50000057 => 'Audiobooks|Sports', 50000058 => 'Audiobooks|Technology', 50000059 => 'Audiobooks|Travel & Adventure', 50000061 => 'Music|Spoken Word', 50000063 => 'Music|Disney', 50000064 => 'Music|French Pop', 50000066 => 'Music|German Pop', 50000068 => 'Music|German Folk', 50000069 => 'Audiobooks|Romance', 50000070 => 'Audiobooks|Audiobooks Latino', 50000071 => 'Books|Comics & Graphic Novels|Manga|Action', 50000072 => 'Books|Comics & Graphic Novels|Manga|Comedy', 50000073 => 'Books|Comics & Graphic Novels|Manga|Erotica', 50000074 => 'Books|Comics & Graphic Novels|Manga|Fantasy', 50000075 => 'Books|Comics & Graphic Novels|Manga|Four Cell Manga', 50000076 => 'Books|Comics & Graphic Novels|Manga|Gay & Lesbian', 50000077 => 'Books|Comics & Graphic Novels|Manga|Hard-Boiled', 50000078 => 'Books|Comics & Graphic Novels|Manga|Heroes', 50000079 => 'Books|Comics & Graphic Novels|Manga|Historical Fiction', 50000080 => 'Books|Comics & Graphic Novels|Manga|Mecha', 50000081 => 'Books|Comics & Graphic Novels|Manga|Mystery', 50000082 => 'Books|Comics & Graphic Novels|Manga|Nonfiction', 50000083 => 'Books|Comics & Graphic Novels|Manga|Religious', 50000084 => 'Books|Comics & Graphic Novels|Manga|Romance', 50000085 => 'Books|Comics & Graphic Novels|Manga|Romantic Comedy', 50000086 => 'Books|Comics & Graphic Novels|Manga|Science Fiction', 50000087 => 'Books|Comics & Graphic Novels|Manga|Sports', 50000088 => 'Books|Fiction & Literature|Light Novels', 50000089 => 'Books|Comics & Graphic Novels|Manga|Horror', 50000090 => 'Books|Comics & Graphic Novels|Comics', }, }, grup => 'Grouping', #10 hdvd => { #10 Name => 'HDVideo', PrintConv => { 0 => 'No', 1 => 'Yes' }, }, keyw => 'Keyword', #7 ldes => 'LongDescription', #10 pcst => { #7 Name => 'Podcast', PrintConv => { 0 => 'No', 1 => 'Yes' }, }, perf => 'Performer', plID => { #10 (or TV season) Name => 'PlayListID', Format => 'int8u', # actually int64u, but split it up }, purd => 'PurchaseDate', #7 purl => 'PodcastURL', #7 rtng => { #10 Name => 'Rating', PrintConv => { 0 => 'none', 1 => 'Explicit', 2 => 'Clean', 4 => 'Explicit (old)', }, }, sfID => { #10 Name => 'AppleStoreCountry', Format => 'int32u', SeparateTable => 1, PrintConv => { #21 143441 => 'United States', # USA 143442 => 'France', # FRA 143443 => 'Germany', # DEU 143444 => 'United Kingdom', # GBR 143445 => 'Austria', # AUT 143446 => 'Belgium', # BEL 143447 => 'Finland', # FIN 143448 => 'Greece', # GRC 143449 => 'Ireland', # IRL 143450 => 'Italy', # ITA 143451 => 'Luxembourg', # LUX 143452 => 'Netherlands', # NLD 143453 => 'Portugal', # PRT 143454 => 'Spain', # ESP 143455 => 'Canada', # CAN 143456 => 'Sweden', # SWE 143457 => 'Norway', # NOR 143458 => 'Denmark', # DNK 143459 => 'Switzerland', # CHE 143460 => 'Australia', # AUS 143461 => 'New Zealand', # NZL 143462 => 'Japan', # JPN 143463 => 'Hong Kong', # HKG 143464 => 'Singapore', # SGP 143465 => 'China', # CHN 143466 => 'Republic of Korea', # KOR 143467 => 'India', # IND 143468 => 'Mexico', # MEX 143469 => 'Russia', # RUS 143470 => 'Taiwan', # TWN 143471 => 'Vietnam', # VNM 143472 => 'South Africa', # ZAF 143473 => 'Malaysia', # MYS 143474 => 'Philippines', # PHL 143475 => 'Thailand', # THA 143476 => 'Indonesia', # IDN 143477 => 'Pakistan', # PAK 143478 => 'Poland', # POL 143479 => 'Saudi Arabia', # SAU 143480 => 'Turkey', # TUR 143481 => 'United Arab Emirates', # ARE 143482 => 'Hungary', # HUN 143483 => 'Chile', # CHL 143484 => 'Nepal', # NPL 143485 => 'Panama', # PAN 143486 => 'Sri Lanka', # LKA 143487 => 'Romania', # ROU 143489 => 'Czech Republic', # CZE 143491 => 'Israel', # ISR 143492 => 'Ukraine', # UKR 143493 => 'Kuwait', # KWT 143494 => 'Croatia', # HRV 143495 => 'Costa Rica', # CRI 143496 => 'Slovakia', # SVK 143497 => 'Lebanon', # LBN 143498 => 'Qatar', # QAT 143499 => 'Slovenia', # SVN 143501 => 'Colombia', # COL 143502 => 'Venezuela', # VEN 143503 => 'Brazil', # BRA 143504 => 'Guatemala', # GTM 143505 => 'Argentina', # ARG 143506 => 'El Salvador', # SLV 143507 => 'Peru', # PER 143508 => 'Dominican Republic', # DOM 143509 => 'Ecuador', # ECU 143510 => 'Honduras', # HND 143511 => 'Jamaica', # JAM 143512 => 'Nicaragua', # NIC 143513 => 'Paraguay', # PRY 143514 => 'Uruguay', # URY 143515 => 'Macau', # MAC 143516 => 'Egypt', # EGY 143517 => 'Kazakhstan', # KAZ 143518 => 'Estonia', # EST 143519 => 'Latvia', # LVA 143520 => 'Lithuania', # LTU 143521 => 'Malta', # MLT 143523 => 'Moldova', # MDA 143524 => 'Armenia', # ARM 143525 => 'Botswana', # BWA 143526 => 'Bulgaria', # BGR 143528 => 'Jordan', # JOR 143529 => 'Kenya', # KEN 143530 => 'Macedonia', # MKD 143531 => 'Madagascar', # MDG 143532 => 'Mali', # MLI 143533 => 'Mauritius', # MUS 143534 => 'Niger', # NER 143535 => 'Senegal', # SEN 143536 => 'Tunisia', # TUN 143537 => 'Uganda', # UGA 143538 => 'Anguilla', # AIA 143539 => 'Bahamas', # BHS 143540 => 'Antigua and Barbuda', # ATG 143541 => 'Barbados', # BRB 143542 => 'Bermuda', # BMU 143543 => 'British Virgin Islands', # VGB 143544 => 'Cayman Islands', # CYM 143545 => 'Dominica', # DMA 143546 => 'Grenada', # GRD 143547 => 'Montserrat', # MSR 143548 => 'St. Kitts and Nevis', # KNA 143549 => 'St. Lucia', # LCA 143550 => 'St. Vincent and The Grenadines', # VCT 143551 => 'Trinidad and Tobago', # TTO 143552 => 'Turks and Caicos', # TCA 143553 => 'Guyana', # GUY 143554 => 'Suriname', # SUR 143555 => 'Belize', # BLZ 143556 => 'Bolivia', # BOL 143557 => 'Cyprus', # CYP 143558 => 'Iceland', # ISL 143559 => 'Bahrain', # BHR 143560 => 'Brunei Darussalam', # BRN 143561 => 'Nigeria', # NGA 143562 => 'Oman', # OMN 143563 => 'Algeria', # DZA 143564 => 'Angola', # AGO 143565 => 'Belarus', # BLR 143566 => 'Uzbekistan', # UZB 143568 => 'Azerbaijan', # AZE 143571 => 'Yemen', # YEM 143572 => 'Tanzania', # TZA 143573 => 'Ghana', # GHA 143575 => 'Albania', # ALB 143576 => 'Benin', # BEN 143577 => 'Bhutan', # BTN 143578 => 'Burkina Faso', # BFA 143579 => 'Cambodia', # KHM 143580 => 'Cape Verde', # CPV 143581 => 'Chad', # TCD 143582 => 'Republic of the Congo', # COG 143583 => 'Fiji', # FJI 143584 => 'Gambia', # GMB 143585 => 'Guinea-Bissau', # GNB 143586 => 'Kyrgyzstan', # KGZ 143587 => "Lao People's Democratic Republic", # LAO 143588 => 'Liberia', # LBR 143589 => 'Malawi', # MWI 143590 => 'Mauritania', # MRT 143591 => 'Federated States of Micronesia', # FSM 143592 => 'Mongolia', # MNG 143593 => 'Mozambique', # MOZ 143594 => 'Namibia', # NAM 143595 => 'Palau', # PLW 143597 => 'Papua New Guinea', # PNG 143598 => 'Sao Tome and Principe', # STP (S&atilde;o Tom&eacute; and Pr&iacute;ncipe) 143599 => 'Seychelles', # SYC 143600 => 'Sierra Leone', # SLE 143601 => 'Solomon Islands', # SLB 143602 => 'Swaziland', # SWZ 143603 => 'Tajikistan', # TJK 143604 => 'Turkmenistan', # TKM 143605 => 'Zimbabwe', # ZWE }, }, soaa => 'SortAlbumArtist', #10 soal => 'SortAlbum', #10 soar => 'SortArtist', #10 soco => 'SortComposer', #10 sonm => 'SortName', #10 sosn => 'SortShow', #10 stik => { #10 Name => 'MediaType', PrintConvColumns => 2, PrintConv => { #(http://weblog.xanga.com/gryphondwb/615474010/iphone-ringtones---what-did-itunes-741-really-do.html) 0 => 'Movie', 1 => 'Normal (Music)', 2 => 'Audiobook', 5 => 'Whacked Bookmark', 6 => 'Music Video', 9 => 'Short Film', 10 => 'TV Show', 11 => 'Booklet', 14 => 'Ringtone', 21 => 'Podcast', #15 }, }, rate => 'RatingPercent', #PH titl => 'Title', tven => 'TVEpisodeID', #7 tves => { #7/10 Name => 'TVEpisode', Format => 'int32u', }, tvnn => 'TVNetworkName', #7 tvsh => 'TVShow', #10 tvsn => { #7/10 Name => 'TVSeason', Format => 'int32u', }, yrrc => 'Year', #(ffmpeg source) itnu => { #PH (iTunes 10.5) Name => 'iTunesU', Description => 'iTunes U', PrintConv => { 0 => 'No', 1 => 'Yes' }, }, #https://github.com/communitymedia/mediautilities/blob/master/src/net/sourceforge/jaad/mp4/boxes/BoxTypes.java gshh => { Name => 'GoogleHostHeader', Format => 'string' }, gspm => { Name => 'GooglePingMessage', Format => 'string' }, gspu => { Name => 'GooglePingURL', Format => 'string' }, gssd => { Name => 'GoogleSourceData', Format => 'string' }, gsst => { Name => 'GoogleStartTime', Format => 'string' }, gstd => { Name => 'GoogleTrackDuration',Format => 'string', ValueConv => '$val / 1000', PrintConv => 'ConvertDuration($val)' }, # atoms observed in AAX audiobooks (ref PH) "\xa9cpy" => { Name => 'Copyright', Groups => { 2 => 'Author' } }, "\xa9pub" => 'Publisher', "\xa9nrt" => 'Narrator', '@pti' => 'ParentTitle', # (guess -- same as "\xa9nam") '@PST' => 'ParentShortTitle', # (guess -- same as "\xa9nam") '@ppi' => 'ParentProductID', # (guess -- same as 'prID') '@sti' => 'ShortTitle', # (guess -- same as "\xa9nam") prID => 'ProductID', rldt => { Name => 'ReleaseDate', Groups => { 2 => 'Time' }}, CDEK => { Name => 'Unknown_CDEK', Unknown => 1 }, # eg: "B004ZMTFEG" - used in URL's ("asin=") CDET => { Name => 'Unknown_CDET', Unknown => 1 }, # eg: "ADBL" VERS => 'ProductVersion', GUID => 'GUID', AACR => { Name => 'Unknown_AACR', Unknown => 1 }, # eg: "CR!1T1H1QH6WX7T714G2BMFX3E9MC4S" # ausr - 30 bytes (User Alias?) ); # item list keys (ref PH) %Image::ExifTool::QuickTime::Keys = ( PROCESS_PROC => \&Image::ExifTool::QuickTime::ProcessKeys, VARS => { LONG_TAGS => 1 }, NOTES => q{ This directory contains a list of key names which are used to decode ItemList tags written by the "mdta" handler. The prefix of "com.apple.quicktime." has been removed from all TagID's below. }, version => 'Version', album => 'Album', artist => { }, artwork => { }, author => { Name => 'Author', Groups => { 2 => 'Author' } }, comment => { }, copyright => { Name => 'Copyright', Groups => { 2 => 'Author' } }, creationdate=> { Name => 'CreationDate', Groups => { 2 => 'Time' }, ValueConv => q{ require Image::ExifTool::XMP; $val = Image::ExifTool::XMP::ConvertXMPDate($val,1); $val =~ s/([-+]\d{2})(\d{2})$/$1:$2/; # add colon to timezone if necessary return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, description => { }, director => { }, title => { }, #22 genre => { }, information => { }, keywords => { }, producer => { }, #22 make => { Name => 'Make', Groups => { 2 => 'Camera' } }, model => { Name => 'Model', Groups => { 2 => 'Camera' } }, publisher => { }, software => { }, year => { Groups => { 2 => 'Time' } }, 'camera.identifier' => 'CameraIdentifier', # (iPhone 4) 'camera.framereadouttimeinmicroseconds' => { # (iPhone 4) Name => 'FrameReadoutTime', ValueConv => '$val * 1e-6', PrintConv => '$val * 1e6 . " microseconds"', }, 'location.ISO6709' => { Name => 'GPSCoordinates', Groups => { 2 => 'Location' }, ValueConv => \&ConvertISO6709, PrintConv => \&PrintGPSCoordinates, }, 'location.name' => { Name => 'LocationName', Groups => { 2 => 'Location' } }, 'location.body' => { Name => 'LocationBody', Groups => { 2 => 'Location' } }, 'location.note' => { Name => 'LocationNote', Groups => { 2 => 'Location' } }, 'location.role' => { Name => 'LocationRole', Groups => { 2 => 'Location' }, PrintConv => { 0 => 'Shooting Location', 1 => 'Real Location', 2 => 'Fictional Location', }, }, 'location.date' => { Name => 'LocationDate', Groups => { 2 => 'Time' }, ValueConv => q{ require Image::ExifTool::XMP; $val = Image::ExifTool::XMP::ConvertXMPDate($val); $val =~ s/([-+]\d{2})(\d{2})$/$1:$2/; # add colon to timezone if necessary return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, 'direction.facing' => { Name => 'CameraDirection', Groups => { 2 => 'Location' } }, 'direction.motion' => { Name => 'CameraMotion', Groups => { 2 => 'Location' } }, 'location.body' => { Name => 'LocationBody', Groups => { 2 => 'Location' } }, 'player.version' => 'PlayerVersion', 'player.movie.visual.brightness'=> 'Brightness', 'player.movie.visual.color' => 'Color', 'player.movie.visual.tint' => 'Tint', 'player.movie.visual.contrast' => 'Contrast', 'player.movie.audio.gain' => 'AudioGain', 'player.movie.audio.treble' => 'Trebel', 'player.movie.audio.bass' => 'Bass', 'player.movie.audio.balance' => 'Balance', 'player.movie.audio.pitchshift' => 'PitchShift', 'player.movie.audio.mute' => { Name => 'Mute', Format => 'int8u', PrintConv => { 0 => 'Off', 1 => 'On' }, }, 'rating.user' => 'UserRating', # (Canon ELPH 510 HS) 'collection.user' => 'UserCollection', #22 'Encoded_With' => 'EncodedWith', ); # iTunes info ('----') atoms %Image::ExifTool::QuickTime::iTunesInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Audio' }, NOTES => q{ ExifTool will extract any iTunesInfo tags that exist, even if they are not defined in this table. }, # 'mean'/'name'/'data' atoms form a triplet, but unfortunately # I haven't been able to find any documentation on this. # 'mean' is normally 'com.apple.iTunes' mean => { Name => 'Mean', # the 'Triplet' flag tells ProcessMOV() to generate # a single tag from the mean/name/data triplet Triplet => 1, Hidden => 1, }, name => { Name => 'Name', Triplet => 1, Hidden => 1, }, data => { Name => 'Data', Triplet => 1, Hidden => 1, }, # the tag ID's below are composed from "mean/name", # but "mean/" is omitted if it is "com.apple.iTunes/": 'iTunMOVI' => { Name => 'iTunMOVI', SubDirectory => { TagTable => 'Image::ExifTool::PLIST::Main' }, }, 'tool' => { Name => 'iTunTool', Description => 'iTunTool', Format => 'int32u', PrintConv => 'sprintf("0x%.8x",$val)', }, 'iTunEXTC' => { Name => 'ContentRating', Notes => 'standard | rating | score | reasons', # eg. 'us-tv|TV-14|500|V', 'mpaa|PG-13|300|For violence and sexuality' # (see http://shadowofged.blogspot.ca/2008/06/itunes-content-ratings.html) }, 'iTunNORM' => { Name => 'VolumeNormalization', PrintConv => '$val=~s/ 0+(\w)/ $1/g; $val=~s/^\s+//; $val', }, 'iTunSMPB' => { Name => 'iTunSMPB', Description => 'iTunSMPB', # hex format, similar to iTunNORM, but 12 words instead of 10, # and 4th word is 16 hex digits (all others are 8) # (gives AAC encoder delay, ref http://code.google.com/p/l-smash/issues/detail?id=1) PrintConv => '$val=~s/ 0+(\w)/ $1/g; $val=~s/^\s+//; $val', }, # (CDDB = Compact Disc DataBase) # iTunes_CDDB_1 = <CDDB1 disk ID>+<# tracks>+<logical block address for each track>... 'iTunes_CDDB_1' => 'CDDB1Info', 'iTunes_CDDB_TrackNumber' => 'CDDBTrackNumber', 'Encoding Params' => { Name => 'EncodingParams', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::EncodingParams' }, }, # also heard about 'iTunPGAP', but I haven't seen a sample DISCNUMBER => 'DiscNumber', #PH TRACKNUMBER => 'TrackNumber', #PH popularimeter => 'Popularimeter', #PH ); # iTunes audio encoding parameters # ref https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/AudioCodecServicesRef/Reference/reference.html %Image::ExifTool::QuickTime::EncodingParams = ( PROCESS_PROC => \&ProcessEncodingParams, GROUPS => { 2 => 'Audio' }, # (I have commented out the ones that don't have integer values because they # probably don't appear, and definitly wouldn't work with current decoding - PH) # global codec properties #'lnam' => 'AudioCodecName', #'lmak' => 'AudioCodecManufacturer', #'lfor' => 'AudioCodecFormat', 'vpk?' => 'AudioHasVariablePacketByteSizes', #'ifm#' => 'AudioSupportedInputFormats', #'ofm#' => 'AudioSupportedOutputFormats', #'aisr' => 'AudioAvailableInputSampleRates', #'aosr' => 'AudioAvailableOutputSampleRates', 'abrt' => 'AudioAvailableBitRateRange', 'mnip' => 'AudioMinimumNumberInputPackets', 'mnop' => 'AudioMinimumNumberOutputPackets', 'cmnc' => 'AudioAvailableNumberChannels', 'lmrc' => 'AudioDoesSampleRateConversion', #'aicl' => 'AudioAvailableInputChannelLayoutTags', #'aocl' => 'AudioAvailableOutputChannelLayoutTags', #'if4o' => 'AudioInputFormatsForOutputFormat', #'of4i' => 'AudioOutputFormatsForInputFormat', #'acfi' => 'AudioFormatInfo', # instance codec properties 'tbuf' => 'AudioInputBufferSize', 'pakf' => 'AudioPacketFrameSize', 'pakb' => 'AudioMaximumPacketByteSize', #'ifmt' => 'AudioCurrentInputFormat', #'ofmt' => 'AudioCurrentOutputFormat', #'kuki' => 'AudioMagicCookie', 'ubuf' => 'AudioUsedInputBufferSize', 'init' => 'AudioIsInitialized', 'brat' => 'AudioCurrentTargetBitRate', #'cisr' => 'AudioCurrentInputSampleRate', #'cosr' => 'AudioCurrentOutputSampleRate', 'srcq' => 'AudioQualitySetting', #'brta' => 'AudioApplicableBitRateRange', #'isra' => 'AudioApplicableInputSampleRates', #'osra' => 'AudioApplicableOutputSampleRates', 'pad0' => 'AudioZeroFramesPadded', 'prmm' => 'AudioCodecPrimeMethod', #'prim' => 'AudioCodecPrimeInfo', #'icl ' => 'AudioInputChannelLayout', #'ocl ' => 'AudioOutputChannelLayout', #'acs ' => 'AudioCodecSettings', #'acfl' => 'AudioCodecFormatList', 'acbf' => 'AudioBitRateControlMode', 'vbrq' => 'AudioVBRQuality', 'mdel' => 'AudioMinimumDelayMode', # deprecated 'pakd' => 'AudioRequiresPacketDescription', #'brt#' => 'AudioAvailableBitRates', 'acef' => 'AudioExtendFrequencies', 'ursr' => 'AudioUseRecommendedSampleRate', 'oppr' => 'AudioOutputPrecedence', #'loud' => 'AudioCurrentLoudnessStatistics', # others 'vers' => 'AudioEncodingParamsVersion', #PH 'cdcv' => { #PH Name => 'AudioComponentVersion', ValueConv => 'join ".", unpack("ncc", pack("N",$val))', }, ); # print to video data block %Image::ExifTool::QuickTime::Video = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, 0 => { Name => 'DisplaySize', PrintConv => { 0 => 'Normal', 1 => 'Double Size', 2 => 'Half Size', 3 => 'Full Screen', 4 => 'Current Size', }, }, 6 => { Name => 'SlideShow', PrintConv => { 0 => 'No', 1 => 'Yes', }, }, ); # 'hnti' atoms %Image::ExifTool::QuickTime::HintInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, 'rtp ' => { Name => 'RealtimeStreamingProtocol', PrintConv => '$val=~s/^sdp /(SDP) /; $val', }, 'sdp ' => 'StreamingDataProtocol', ); # 'hinf' atoms %Image::ExifTool::QuickTime::HintTrackInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, trpY => { Name => 'TotalBytes', Format => 'int64u' }, #(documented) trpy => { Name => 'TotalBytes', Format => 'int64u' }, #(observed) totl => { Name => 'TotalBytes', Format => 'int32u' }, nump => { Name => 'NumPackets', Format => 'int64u' }, npck => { Name => 'NumPackets', Format => 'int32u' }, tpyl => { Name => 'TotalBytesNoRTPHeaders', Format => 'int64u' }, tpaY => { Name => 'TotalBytesNoRTPHeaders', Format => 'int32u' }, #(documented) tpay => { Name => 'TotalBytesNoRTPHeaders', Format => 'int32u' }, #(observed) maxr => { Name => 'MaxDataRate', Format => 'int32u', Count => 2, PrintConv => 'my @a=split(" ",$val);sprintf("%d bytes in %.3f s",$a[1],$a[0]/1000)', }, dmed => { Name => 'MediaTrackBytes', Format => 'int64u' }, dimm => { Name => 'ImmediateDataBytes', Format => 'int64u' }, drep => { Name => 'RepeatedDataBytes', Format => 'int64u' }, tmin => { Name => 'MinTransmissionTime', Format => 'int32u', PrintConv => 'sprintf("%.3f s",$val/1000)', }, tmax => { Name => 'MaxTransmissionTime', Format => 'int32u', PrintConv => 'sprintf("%.3f s",$val/1000)', }, pmax => { Name => 'LargestPacketSize', Format => 'int32u' }, dmax => { Name => 'LargestPacketDuration', Format => 'int32u', PrintConv => 'sprintf("%.3f s",$val/1000)', }, payt => { Name => 'PayloadType', Format => 'undef', # (necessary to prevent decoding as string!) ValueConv => 'unpack("N",$val) . " " . substr($val, 5)', PrintConv => '$val=~s/ /, /;$val', }, ); # MP4 media box (ref 5) %Image::ExifTool::QuickTime::Media = ( PROCESS_PROC => \&ProcessMOV, WRITE_PROC => \&WriteQuickTime, GROUPS => { 1 => 'Track#', 2 => 'Video' }, NOTES => 'MP4 media box.', mdhd => { Name => 'MediaHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::MediaHeader' }, }, hdlr => { Name => 'Handler', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Handler' }, }, minf => { Name => 'MediaInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::MediaInfo' }, }, ); # MP4 media header box (ref 5) %Image::ExifTool::QuickTime::MediaHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, WRITE_PROC => \&Image::ExifTool::WriteBinaryData, GROUPS => { 1 => 'Track#', 2 => 'Video' }, FORMAT => 'int32u', DATAMEMBER => [ 0, 1, 2, 3, 4 ], 0 => { Name => 'MediaHeaderVersion', RawConv => '$$self{MediaHeaderVersion} = $val', }, 1 => { Name => 'MediaCreateDate', Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if MediaHeaderVersion == 1 (ref 5/13) Hook => '$$self{MediaHeaderVersion} and $format = "int64u", $varSize += 4', }, 2 => { Name => 'MediaModifyDate', Groups => { 2 => 'Time' }, %timeInfo, # this is int64u if MediaHeaderVersion == 1 (ref 5/13) Hook => '$$self{MediaHeaderVersion} and $format = "int64u", $varSize += 4', }, 3 => { Name => 'MediaTimeScale', RawConv => '$$self{MediaTS} = $val', }, 4 => { Name => 'MediaDuration', RawConv => '$$self{MediaTS} ? $val / $$self{MediaTS} : $val', PrintConv => '$$self{MediaTS} ? ConvertDuration($val) : $val', # this is int64u if MediaHeaderVersion == 1 (ref 5/13) Hook => '$$self{MediaHeaderVersion} and $format = "int64u", $varSize += 4', }, 5 => { Name => 'MediaLanguageCode', Format => 'int16u', RawConv => '$val ? $val : undef', # allow both Macintosh (for MOV files) and ISO (for MP4 files) language codes ValueConv => '$val < 0x400 ? $val : pack "C*", map { (($val>>$_)&0x1f)+0x60 } 10, 5, 0', PrintConv => q{ return $val unless $val =~ /^\d+$/; require Image::ExifTool::Font; return $Image::ExifTool::Font::ttLang{Macintosh}{$val} || "Unknown ($val)"; }, }, ); # MP4 media information box (ref 5) %Image::ExifTool::QuickTime::MediaInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 1 => 'Track#', 2 => 'Video' }, NOTES => 'MP4 media info box.', vmhd => { Name => 'VideoHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::VideoHeader' }, }, smhd => { Name => 'AudioHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::AudioHeader' }, }, hmhd => { Name => 'HintHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HintHeader' }, }, nmhd => { Name => 'NullMediaHeader', Flags => ['Binary','Unknown'], }, dinf => { Name => 'DataInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::DataInfo' }, }, gmhd => { Name => 'GenMediaHeader', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::GenMediaHeader' }, }, hdlr => { #PH Name => 'Handler', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Handler' }, }, stbl => { Name => 'SampleTable', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::SampleTable' }, }, ); # MP4 video media header (ref 5) %Image::ExifTool::QuickTime::VideoHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, NOTES => 'MP4 video media header.', FORMAT => 'int16u', 2 => { Name => 'GraphicsMode', PrintHex => 1, SeparateTable => 'GraphicsMode', PrintConv => \%graphicsMode, }, 3 => { Name => 'OpColor', Format => 'int16u[3]' }, ); # MP4 audio media header (ref 5) %Image::ExifTool::QuickTime::AudioHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Audio' }, NOTES => 'MP4 audio media header.', FORMAT => 'int16u', 2 => { Name => 'Balance', Format => 'fixed16s' }, ); # MP4 hint media header (ref 5) %Image::ExifTool::QuickTime::HintHeader = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, NOTES => 'MP4 hint media header.', FORMAT => 'int16u', 2 => 'MaxPDUSize', 3 => 'AvgPDUSize', 4 => { Name => 'MaxBitrate', Format => 'int32u', PrintConv => 'ConvertBitrate($val)' }, 6 => { Name => 'AvgBitrate', Format => 'int32u', PrintConv => 'ConvertBitrate($val)' }, ); # MP4 sample table box (ref 5) %Image::ExifTool::QuickTime::SampleTable = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Video' }, NOTES => 'MP4 sample table box.', stsd => [ { Name => 'AudioSampleDesc', Condition => '$$self{HandlerType} and $$self{HandlerType} eq "soun"', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::AudioSampleDesc', Start => 8, # skip version number and count }, },{ Name => 'VideoSampleDesc', Condition => '$$self{HandlerType} and $$self{HandlerType} eq "vide"', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::ImageDesc', Start => 8, # skip version number and count }, },{ Name => 'HintSampleDesc', Condition => '$$self{HandlerType} and $$self{HandlerType} eq "hint"', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::HintSampleDesc', Start => 8, # skip version number and count }, },{ Name => 'OtherSampleDesc', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::OtherSampleDesc', Start => 8, # skip version number and count }, }, # (Note: "alis" HandlerType handled by the parent audio or video handler) ], stts => [ # decoding time-to-sample table { Name => 'VideoFrameRate', Notes => 'average rate calculated from time-to-sample table for video media', Condition => '$$self{HandlerType} and $$self{HandlerType} eq "vide"', Format => 'undef', # (necessary to prevent decoding as string!) # (must be RawConv so appropriate MediaTS is used in calculation) RawConv => 'Image::ExifTool::QuickTime::CalcSampleRate($self, \$val)', PrintConv => 'int($val * 1000 + 0.5) / 1000', }, { Name => 'TimeToSampleTable', Flags => ['Binary','Unknown'], }, ], ctts => { Name => 'CompositionTimeToSample', Flags => ['Binary','Unknown'], }, stsc => { Name => 'SampleToChunk', Flags => ['Binary','Unknown'], }, stsz => { Name => 'SampleSizes', Flags => ['Binary','Unknown'], }, stz2 => { Name => 'CompactSampleSizes', Flags => ['Binary','Unknown'], }, stco => { Name => 'ChunkOffset', Flags => ['Binary','Unknown'], }, co64 => { Name => 'ChunkOffset64', Flags => ['Binary','Unknown'], }, stss => { Name => 'SyncSampleTable', Flags => ['Binary','Unknown'], }, stsh => { Name => 'ShadowSyncSampleTable', Flags => ['Binary','Unknown'], }, padb => { Name => 'SamplePaddingBits', Flags => ['Binary','Unknown'], }, stdp => { Name => 'SampleDegradationPriority', Flags => ['Binary','Unknown'], }, sdtp => { Name => 'IdependentAndDisposableSamples', Flags => ['Binary','Unknown'], }, sbgp => { Name => 'SampleToGroup', Flags => ['Binary','Unknown'], }, sgpd => { Name => 'SampleGroupDescription', Flags => ['Binary','Unknown'], }, subs => { Name => 'Sub-sampleInformation', Flags => ['Binary','Unknown'], }, cslg => { Name => 'CompositionToDecodeTimelineMapping', Flags => ['Binary','Unknown'], }, stps => { Name => 'PartialSyncSamples', ValueConv => 'join " ",unpack("x8N*",$val)', }, ); # MP4 audio sample description box (ref 5/AtomicParsley 0.9.4 parsley.cpp) %Image::ExifTool::QuickTime::AudioSampleDesc = ( PROCESS_PROC => \&ProcessHybrid, VARS => { ID_LABEL => 'ID/Index' }, GROUPS => { 2 => 'Audio' }, NOTES => q{ MP4 audio sample description. This hybrid atom contains both data and child atoms. }, 4 => { Name => 'AudioFormat', Format => 'undef[4]', RawConv => q{ $$self{AudioFormat} = $val; return undef unless $val =~ /^[\w ]{4}$/i; # check for protected audio format $self->OverrideFileType('M4P') if $val eq 'drms' and $$self{VALUE}{FileType} eq 'M4A'; return $val; }, }, 20 => { #PH Name => 'AudioVendorID', Condition => '$$self{AudioFormat} ne "mp4s"', Format => 'undef[4]', RawConv => '$val eq "\0\0\0\0" ? undef : $val', PrintConv => \%vendorID, SeparateTable => 'VendorID', }, 24 => { Name => 'AudioChannels', Format => 'int16u' }, 26 => { Name => 'AudioBitsPerSample', Format => 'int16u' }, 32 => { Name => 'AudioSampleRate', Format => 'fixed32u' }, # # Observed offsets for child atoms of various AudioFormat types: # # AudioFormat Offset Child atoms # ----------- ------ ---------------- # mp4a 52 * wave, chan, esds # in24 52 wave, chan # "ms\0\x11" 52 wave # sowt 52 chan # mp4a 36 * esds, pinf # drms 36 esds, sinf # samr 36 damr # alac 36 alac # ac-3 36 dac3 # # (* child atoms found at different offsets in mp4a) # pinf => { Name => 'PurchaseInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::ProtectionInfo' }, }, sinf => { # "protection scheme information" Name => 'ProtectionInfo', #3 SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::ProtectionInfo' }, }, # chan - 16/36 bytes # esds - 31/40/42/43 bytes - ES descriptor (ref 3) damr => { #3 Name => 'DecodeConfig', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::DecodeConfig' }, }, wave => { Name => 'Wave', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Wave' }, }, # alac - 28 bytes # adrm - AAX DRM atom? 148 bytes # aabd - AAX unknown 17kB (contains 'aavd' strings) ); # AMR decode config box (ref 3) %Image::ExifTool::QuickTime::DecodeConfig = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Audio' }, 0 => { Name => 'EncoderVendor', Format => 'undef[4]', }, 4 => 'EncoderVersion', # 5 - int16u - packet modes # 7 - int8u - number of packet mode changes # 8 - int8u - bytes per packet ); %Image::ExifTool::QuickTime::ProtectionInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Audio' }, NOTES => 'Child atoms found in "sinf" and/or "pinf" atoms.', frma => 'OriginalFormat', # imif - IPMP information schm => { Name => 'SchemeType', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::SchemeType' }, }, schi => { Name => 'SchemeInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::SchemeInfo' }, }, # skcr # enda ); %Image::ExifTool::QuickTime::Wave = ( PROCESS_PROC => \&ProcessMOV, frma => 'PurchaseFileFormat', # "ms\0\x11" - 20 bytes ); # scheme type atom # ref http://xhelmboyx.tripod.com/formats/mp4-layout.txt %Image::ExifTool::QuickTime::SchemeType = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Audio' }, # 0 - 4 bytes version 4 => { Name => 'SchemeType', Format => 'undef[4]' }, 8 => { Name => 'SchemeVersion', Format => 'int16u' }, 10 => { Name => 'SchemeURL', Format => 'string[$size-10]' }, ); %Image::ExifTool::QuickTime::SchemeInfo = ( PROCESS_PROC => \&ProcessMOV, GROUPS => { 2 => 'Audio' }, user => { Name => 'UserID', Groups => { 2 => 'Author' }, ValueConv => '"0x" . unpack("H*",$val)', }, cert => { # ref http://www.onvif.org/specs/stream/ONVIF-ExportFileFormat-Spec-v100.pdf Name => 'Certificate', ValueConv => '"0x" . unpack("H*",$val)', }, 'key ' => { Name => 'KeyID', ValueConv => '"0x" . unpack("H*",$val)', }, iviv => { Name => 'InitializationVector', ValueConv => 'unpack("H*",$val)', }, righ => { Name => 'Rights', Groups => { 2 => 'Author' }, SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::Rights' }, }, name => { Name => 'UserName', Groups => { 2 => 'Author' } }, # chtb # priv - private data # sign # adkm - Adobe DRM key management system (ref http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf) # iKMS # iSFM # iSLT ); %Image::ExifTool::QuickTime::Rights = ( PROCESS_PROC => \&ProcessRights, GROUPS => { 2 => 'Audio' }, veID => 'ItemVendorID', #PH ("VendorID" ref 19) plat => 'Platform', #18? aver => 'VersionRestrictions', #19 ("appversion?" ref 18) tran => 'TransactionID', #18 song => 'ItemID', #19 ("appid" ref 18) tool => { Name => 'ItemTool', #PH (guess) ("itunes build?" ref 18) Format => 'string', }, medi => 'MediaFlags', #PH (?) mode => 'ModeFlags', #PH (?) 0x04 is HD flag (https://compilr.com/heksesang/requiem-mac/UnDrm.java) ); # MP4 hint sample description box (ref 5) # (ref https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-SW1) %Image::ExifTool::QuickTime::HintSampleDesc = ( PROCESS_PROC => \&ProcessHybrid, VARS => { ID_LABEL => 'ID/Index' }, NOTES => 'MP4 hint sample description.', 4 => { Name => 'HintFormat', Format => 'undef[4]' }, # 14 - int16u DataReferenceIndex 16 => { Name => 'HintTrackVersion', Format => 'int16u' }, # 18 - int16u LastCompatibleHintTrackVersion 20 => { Name => 'MaxPacketSize', Format => 'int32u' }, # # Observed offsets for child atoms of various HintFormat types: # # HintFormat Offset Child atoms # ----------- ------ ---------------- # "rtp " 24 tims # tims => { Name => 'RTPTimeScale', Format => 'int32u' }, tsro => { Name => 'TimestampRandomOffset', Format => 'int32u' }, snro => { Name => 'SequenceNumberRandomOffset', Format => 'int32u' }, ); # MP4 generic sample description box %Image::ExifTool::QuickTime::OtherSampleDesc = ( PROCESS_PROC => \&ProcessHybrid, 4 => { Name => 'OtherFormat', Format => 'undef[4]' }, # # Observed offsets for child atoms of various OtherFormat types: # # OtherFormat Offset Child atoms # ----------- ------ ---------------- # avc1 86 avcC # mp4a 36 esds # mp4s 16 esds # tmcd 34 name # ftab => { Name => 'FontTable', Format => 'undef', ValueConv => 'substr($val, 5)' }, ); # MP4 data information box (ref 5) %Image::ExifTool::QuickTime::DataInfo = ( PROCESS_PROC => \&ProcessMOV, NOTES => 'MP4 data information box.', dref => { Name => 'DataRef', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::DataRef', Start => 8, }, }, ); # Generic media header %Image::ExifTool::QuickTime::GenMediaHeader = ( PROCESS_PROC => \&ProcessMOV, gmin => { Name => 'GenMediaInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::GenMediaInfo' }, }, text => { Name => 'Text', Flags => ['Binary','Unknown'], }, tmcd => { Name => 'TimeCode', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::TimeCode' }, }, ); # TimeCode header %Image::ExifTool::QuickTime::TimeCode = ( PROCESS_PROC => \&ProcessMOV, tcmi => { Name => 'TCMediaInfo', SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::TCMediaInfo' }, }, ); # TimeCode media info (ref 12) %Image::ExifTool::QuickTime::TCMediaInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, 4 => { Name => 'TextFont', Format => 'int16u', PrintConv => { 0 => 'System' }, }, 6 => { Name => 'TextFace', Format => 'int16u', PrintConv => { 0 => 'Plain', BITMASK => { 0 => 'Bold', 1 => 'Italic', 2 => 'Underline', 3 => 'Outline', 4 => 'Shadow', 5 => 'Condense', 6 => 'Extend', }, }, }, 8 => { Name => 'TextSize', Format => 'int16u', }, # 10 - reserved 12 => { Name => 'TextColor', Format => 'int16u[3]', }, 18 => { Name => 'BackgroundColor', Format => 'int16u[3]', }, 24 => { Name => 'FontName', Format => 'pstring', ValueConv => '$self->Decode($val, $self->Options("CharsetQuickTime"))', }, ); # Generic media info (ref http://sourceforge.jp/cvs/view/ntvrec/ntvrec/libqtime/gmin.h?view=co) %Image::ExifTool::QuickTime::GenMediaInfo = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, 0 => 'GenMediaVersion', 1 => { Name => 'GenFlags', Format => 'int8u[3]' }, 4 => { Name => 'GenGraphicsMode', Format => 'int16u', PrintHex => 1, SeparateTable => 'GraphicsMode', PrintConv => \%graphicsMode, }, 6 => { Name => 'GenOpColor', Format => 'int16u[3]' }, 12 => { Name => 'GenBalance', Format => 'fixed16s' }, ); # MP4 data reference box (ref 5) %Image::ExifTool::QuickTime::DataRef = ( PROCESS_PROC => \&ProcessMOV, NOTES => 'MP4 data reference box.', 'url ' => { Name => 'URL', Format => 'undef', # (necessary to prevent decoding as string!) RawConv => q{ # ignore if self-contained (flags bit 0 set) return undef if unpack("N",$val) & 0x01; $_ = substr($val,4); s/\0.*//s; $_; }, }, 'urn ' => { Name => 'URN', Format => 'undef', # (necessary to prevent decoding as string!) RawConv => q{ return undef if unpack("N",$val) & 0x01; $_ = substr($val,4); s/\0.*//s; $_; }, }, ); # MP4 handler box (ref 5) %Image::ExifTool::QuickTime::Handler = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, GROUPS => { 2 => 'Video' }, 4 => { #PH Name => 'HandlerClass', Format => 'undef[4]', RawConv => '$val eq "\0\0\0\0" ? undef : $val', PrintConv => { mhlr => 'Media Handler', dhlr => 'Data Handler', }, }, 8 => { Name => 'HandlerType', Format => 'undef[4]', RawConv => '$$self{HandlerType} = $val unless $val eq "alis" or $val eq "url "; $val', PrintConvColumns => 2, PrintConv => { alis => 'Alias Data', #PH crsm => 'Clock Reference', #3 hint => 'Hint Track', ipsm => 'IPMP', #3 m7sm => 'MPEG-7 Stream', #3 meta => 'NRT Metadata', #PH mdir => 'Metadata', #3 mdta => 'Metadata Tags', #PH mjsm => 'MPEG-J', #3 ocsm => 'Object Content', #3 odsm => 'Object Descriptor', #3 priv => 'Private', #PH sdsm => 'Scene Description', #3 soun => 'Audio Track', text => 'Text', #PH (but what type? subtitle?) tmcd => 'Time Code', #PH 'url '=> 'URL', #3 vide => 'Video Track', subp => 'Subpicture', #http://www.google.nl/patents/US7778526 nrtm => 'Non-Real Time Metadata', #PH (Sony ILCE-7S) [how is this different from "meta"?] }, }, 12 => { #PH Name => 'HandlerVendorID', Format => 'undef[4]', RawConv => '$val eq "\0\0\0\0" ? undef : $val', PrintConv => \%vendorID, SeparateTable => 'VendorID', }, 24 => { Name => 'HandlerDescription', Format => 'string', # (sometimes this is a Pascal string, and sometimes it is a C string) RawConv => q{ $val=substr($val,1,ord($1)) if $val=~/^([\0-\x1f])/ and ord($1)<length($val); length $val ? $val : undef; }, }, ); # Flip uuid data (ref PH) %Image::ExifTool::QuickTime::Flip = ( PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, FORMAT => 'int32u', FIRST_ENTRY => 0, NOTES => 'Found in MP4 files from Flip Video cameras.', GROUPS => { 1 => 'MakerNotes', 2 => 'Image' }, 1 => 'PreviewImageWidth', 2 => 'PreviewImageHeight', 13 => 'PreviewImageLength', 14 => { # (confirmed for FlipVideoMinoHD) Name => 'SerialNumber', Groups => { 2 => 'Camera' }, Format => 'string[16]', }, 28 => { Name => 'PreviewImage', Groups => { 2 => 'Preview' }, Format => 'undef[$val{13}]', RawConv => '$self->ValidateImage(\$val, $tag)', }, ); # QuickTime composite tags %Image::ExifTool::QuickTime::Composite = ( GROUPS => { 2 => 'Video' }, Rotation => { Require => { 0 => 'QuickTime:MatrixStructure', 1 => 'QuickTime:HandlerType', }, ValueConv => 'Image::ExifTool::QuickTime::CalcRotation($self)', }, AvgBitrate => { Priority => 0, # let QuickTime::AvgBitrate take priority Require => { 0 => 'QuickTime::MovieDataSize', 1 => 'QuickTime::Duration', }, RawConv => q{ return undef unless $val[1]; $val[1] /= $$self{TimeScale} if $$self{TimeScale}; my $key = 'MovieDataSize'; my $size = $val[0]; for (;;) { $key = $self->NextTagKey($key) or last; $size += $self->GetValue($key, 'ValueConv'); } return int($size * 8 / $val[1] + 0.5); }, PrintConv => 'ConvertBitrate($val)', }, GPSLatitude => { Require => 'QuickTime:GPSCoordinates', Groups => { 2 => 'Location' }, ValueConv => 'my @c = split " ", $val; $c[0]', PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")', }, GPSLongitude => { Require => 'QuickTime:GPSCoordinates', Groups => { 2 => 'Location' }, ValueConv => 'my @c = split " ", $val; $c[1]', PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")', }, # split altitude into GPSAltitude/GPSAltitudeRef like EXIF and XMP GPSAltitude => { Require => 'QuickTime:GPSCoordinates', Groups => { 2 => 'Location' }, Priority => 0, # (because it may not exist) ValueConv => 'my @c = split " ", $val; defined $c[2] ? abs($c[2]) : undef', PrintConv => '"$val m"', }, GPSAltitudeRef => { Require => 'QuickTime:GPSCoordinates', Groups => { 2 => 'Location' }, Priority => 0, # (because altitude information may not exist) ValueConv => 'my @c = split " ", $val; defined $c[2] ? ($c[2] < 0 ? 1 : 0) : undef', PrintConv => { 0 => 'Above Sea Level', 1 => 'Below Sea Level', }, }, GPSLatitude2 => { Name => 'GPSLatitude', Require => 'QuickTime:LocationInformation', Groups => { 2 => 'Location' }, ValueConv => '$val =~ /Lat=([-+.\d]+)/; $1', PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")', }, GPSLongitude2 => { Name => 'GPSLongitude', Require => 'QuickTime:LocationInformation', Groups => { 2 => 'Location' }, ValueConv => '$val =~ /Lon=([-+.\d]+)/; $1', PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")', }, GPSAltitude2 => { Name => 'GPSAltitude', Require => 'QuickTime:LocationInformation', Groups => { 2 => 'Location' }, ValueConv => '$val =~ /Alt=([-+.\d]+)/; abs($1)', PrintConv => '"$val m"', }, GPSAltitudeRef2 => { Name => 'GPSAltitudeRef', Require => 'QuickTime:LocationInformation', Groups => { 2 => 'Location' }, ValueConv => '$val =~ /Alt=([-+.\d]+)/; $1 < 0 ? 1 : 0', PrintConv => { 0 => 'Above Sea Level', 1 => 'Below Sea Level', }, }, CDDBDiscPlayTime => { Require => 'CDDB1Info', Groups => { 2 => 'Audio' }, ValueConv => '$val =~ /^..([a-z0-9]{4})/i ? hex($1) : undef', PrintConv => 'ConvertDuration($val)', }, CDDBDiscTracks => { Require => 'CDDB1Info', Groups => { 2 => 'Audio' }, ValueConv => '$val =~ /^.{6}([a-z0-9]{2})/i ? hex($1) : undef', }, ); # add our composite tags Image::ExifTool::AddCompositeTags('Image::ExifTool::QuickTime'); #------------------------------------------------------------------------------ # AutoLoad our writer routines when necessary # sub AUTOLOAD { return Image::ExifTool::DoAutoLoad($AUTOLOAD, @_); } #------------------------------------------------------------------------------ # Calculate rotation of video track # Inputs: 0) ExifTool object ref # Returns: rotation angle or undef sub CalcRotation($) { my $et = shift; my $value = $$et{VALUE}; my ($i, $track); # get the video track family 1 group (eg. "Track1"); for ($i=0; ; ++$i) { my $idx = $i ? " ($i)" : ''; my $tag = "HandlerType$idx"; last unless $$value{$tag}; next unless $$value{$tag} eq 'vide'; $track = $et->GetGroup($tag, 1); last; } return undef unless $track; # get the video track matrix for ($i=0; ; ++$i) { my $idx = $i ? " ($i)" : ''; my $tag = "MatrixStructure$idx"; last unless $$value{$tag}; next unless $et->GetGroup($tag, 1) eq $track; my @a = split ' ', $$value{$tag}; return undef unless $a[0] or $a[1]; # calculate the rotation angle (assume uniform rotation) my $angle = atan2($a[1], $a[0]) * 180 / 3.14159; $angle += 360 if $angle < 0; return int($angle * 1000 + 0.5) / 1000; } return undef; } #------------------------------------------------------------------------------ # Determine the average sample rate from a time-to-sample table # Inputs: 0) ExifTool object ref, 1) time-to-sample table data ref # Returns: average sample rate (in Hz) sub CalcSampleRate($$) { my ($et, $valPt) = @_; my @dat = unpack('N*', $$valPt); my ($num, $dur) = (0, 0); my $i; for ($i=2; $i<@dat-1; $i+=2) { $num += $dat[$i]; # total number of samples $dur += $dat[$i] * $dat[$i+1]; # total sample duration } return undef unless $num and $dur and $$et{MediaTS}; return $num * $$et{MediaTS} / $dur; } #------------------------------------------------------------------------------ # Fix incorrect format for ImageWidth/Height as written by Pentax sub FixWrongFormat($) { my $val = shift; return undef unless $val; if ($val & 0xffff0000) { $val = unpack('n',pack('N',$val)); } return $val; } #------------------------------------------------------------------------------ # Convert ISO 6709 string to standard lag/lon format # Inputs: 0) ISO 6709 string (lat, lon, and optional alt) # Returns: position in decimal degress with altitude if available # Notes: Wikipedia indicates altitude may be in feet -- how is this specified? sub ConvertISO6709($) { my $val = shift; if ($val =~ /^([-+]\d{1,2}(?:\.\d*)?)([-+]\d{1,3}(?:\.\d*)?)([-+]\d+(?:\.\d*)?)?/) { # +DD.DDD+DDD.DDD+AA.AAA $val = ($1 + 0) . ' ' . ($2 + 0); $val .= ' ' . ($3 + 0) if $3; } elsif ($val =~ /^([-+])(\d{2})(\d{2}(?:\.\d*)?)([-+])(\d{3})(\d{2}(?:\.\d*)?)([-+]\d+(?:\.\d*)?)?/) { # +DDMM.MMM+DDDMM.MMM+AA.AAA my $lat = $2 + $3 / 60; $lat = -$lat if $1 eq '-'; my $lon = $5 + $6 / 60; $lon = -$lon if $4 eq '-'; $val = "$lat $lon"; $val .= ' ' . ($7 + 0) if $7; } elsif ($val =~ /^([-+])(\d{2})(\d{2})(\d{2}(?:\.\d*)?)([-+])(\d{3})(\d{2})(\d{2}(?:\.\d*)?)([-+]\d+(?:\.\d*)?)?/) { # +DDMMSS.SSS+DDDMMSS.SSS+AA.AAA my $lat = $2 + $3 / 60 + $4 / 3600; $lat = -$lat if $1 eq '-'; my $lon = $6 + $7 / 60 + $8 / 3600; $lon = -$lon if $5 eq '-'; $val = "$lat $lon"; $val .= ' ' . ($9 + 0) if $9; } return $val; } #------------------------------------------------------------------------------ # Convert Nero chapter list (ref ffmpeg libavformat/movenc.c) # Inputs: 0) binary chpl data # Returns: chapter list sub ConvertChapterList($) { my $val = shift; my $size = length $val; return '<invalid>' if $size < 9; my $num = Get8u(\$val, 8); my ($i, @chapters); my $pos = 9; for ($i=0; $i<$num; ++$i) { last if $pos + 9 > $size; my $dur = Get64u(\$val, $pos) / 10000000; my $len = Get8u(\$val, $pos + 8); last if $pos + 9 + $len > $size; my $title = substr($val, $pos + 9, $len); $pos += 9 + $len; push @chapters, "$dur $title"; } return \@chapters; # return as a list } #------------------------------------------------------------------------------ # Print conversion for a Nero chapter list item # Inputs: 0) ValueConv chapter string # Returns: formatted chapter string sub PrintChapter($) { my $val = shift; $val =~ /^(\S+) (.*)/ or return $val; my ($dur, $title) = ($1, $2); my $h = int($dur / 3600); $dur -= $h * 3600; my $m = int($dur / 60); my $s = $dur - $m * 60; return sprintf("[%d:%.2d:%06.3f] %s",$h,$m,$s,$title); } #------------------------------------------------------------------------------ # Format GPSCoordinates for printing # Inputs: 0) string with numerical lat, lon and optional alt, separated by spaces # 1) ExifTool object reference # Returns: PrintConv value sub PrintGPSCoordinates($) { my ($val, $et) = @_; my @v = split ' ', $val; my $prt = Image::ExifTool::GPS::ToDMS($et, $v[0], 1, "N") . ', ' . Image::ExifTool::GPS::ToDMS($et, $v[1], 1, "E"); if (defined $v[2]) { $prt .= ', ' . ($v[2] < 0 ? -$v[2] . ' m Below' : $v[2] . ' m Above') . ' Sea Level'; } return $prt; } #------------------------------------------------------------------------------ # Unpack packed ISO 639/T language code # Inputs: 0) packed language code (or undef) # Returns: language code, or undef for default language, or 'err' for format error sub UnpackLang($) { my $lang = shift; if ($lang) { # language code is packed in 5-bit characters $lang = pack "C*", map { (($lang>>$_)&0x1f)+0x60 } 10, 5, 0; # validate language code if ($lang =~ /^[a-z]+$/) { # treat 'eng' or 'und' as the default language undef $lang if $lang eq 'und' or $lang eq 'eng'; } else { $lang = 'err'; # invalid language code } } return $lang; } #------------------------------------------------------------------------------ # Get langInfo hash and save details about alt-lang tags # Inputs: 0) ExifTool ref, 1) tagInfo hash ref, 2) locale code # Returns: new tagInfo hash ref, or undef if invalid sub GetLangInfoQT($$$) { my ($et, $tagInfo, $langCode) = @_; my $langInfo = Image::ExifTool::GetLangInfo($tagInfo, $langCode); if ($langInfo) { $$et{QTLang} or $$et{QTLang} = [ ]; push @{$$et{QTLang}}, $$langInfo{Name}; } return $langInfo; } #------------------------------------------------------------------------------ # Process MPEG-4 MTDT atom (ref 11) # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success sub ProcessMetaData($$$) { my ($et, $dirInfo, $tagTablePtr) = @_; my $dataPt = $$dirInfo{DataPt}; my $dirLen = length $$dataPt; my $verbose = $et->Options('Verbose'); return 0 unless $dirLen >= 2; my $count = Get16u($dataPt, 0); $verbose and $et->VerboseDir('MetaData', $count); my $i; my $pos = 2; for ($i=0; $i<$count; ++$i) { last if $pos + 10 > $dirLen; my $size = Get16u($dataPt, $pos); last if $size < 10 or $size + $pos > $dirLen; my $tag = Get32u($dataPt, $pos + 2); my $lang = Get16u($dataPt, $pos + 6); my $enc = Get16u($dataPt, $pos + 8); my $val = substr($$dataPt, $pos + 10, $size); my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); if ($tagInfo) { # convert language code to ASCII (ignore read-only bit) $lang = UnpackLang($lang); # handle alternate languages if ($lang) { my $langInfo = GetLangInfoQT($et, $tagInfo, $lang); $tagInfo = $langInfo if $langInfo; } $verbose and $et->VerboseInfo($tag, $tagInfo, Value => $val, DataPt => $dataPt, Start => $pos + 10, Size => $size - 10, ); # convert from UTF-16 BE if necessary $val = $et->Decode($val, 'UCS2') if $enc == 1; if ($enc == 0 and $$tagInfo{Unknown}) { # binary data $et->FoundTag($tagInfo, \$val); } else { $et->FoundTag($tagInfo, $val); } } $pos += $size; } return 1; } #------------------------------------------------------------------------------ # Process hybrid binary data + QuickTime container (ref PH) # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success sub ProcessHybrid($$$) { my ($et, $dirInfo, $tagTablePtr) = @_; # brute-force search for child atoms after first 8 bytes of binary data my $dataPt = $$dirInfo{DataPt}; my $pos = ($$dirInfo{DirStart} || 0) + 8; my $len = length($$dataPt); my $try = $pos; my $childPos; while ($pos <= $len - 8) { my $tag = substr($$dataPt, $try+4, 4); # look only for well-behaved tag ID's $tag =~ /[^\w ]/ and $try = ++$pos, next; my $size = Get32u($dataPt, $try); if ($size + $try == $len) { # the atom ends exactly at the end of the parent -- this must be it $childPos = $pos; $$dirInfo{DirLen} = $pos; # the binary data ends at the first child atom last; } if ($size < 8 or $size + $try > $len - 8) { $try = ++$pos; # fail. try next position } else { $try += $size; # could be another atom following this } } # process binary data $$dirInfo{MixedTags} = 1; # ignore non-integer tag ID's $et->ProcessBinaryData($dirInfo, $tagTablePtr); # process child atoms if found if ($childPos) { $$dirInfo{DirStart} = $childPos; $$dirInfo{DirLen} = $len - $childPos; ProcessMOV($et, $dirInfo, $tagTablePtr); } return 1; } #------------------------------------------------------------------------------ # Process iTunes 'righ' atom (ref PH) # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success sub ProcessRights($$$) { my ($et, $dirInfo, $tagTablePtr) = @_; my $dataPt = $$dirInfo{DataPt}; my $dataPos = $$dirInfo{Base}; my $dirLen = length $$dataPt; my $unknown = $$et{OPTIONS}{Unkown} || $$et{OPTIONS}{Verbose}; my $pos; $et->VerboseDir('righ', $dirLen / 8); for ($pos = 0; $pos + 8 <= $dirLen; $pos += 8) { my $tag = substr($$dataPt, $pos, 4); last if $tag eq "\0\0\0\0"; my $val = substr($$dataPt, $pos + 4, 4); my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); unless ($tagInfo) { next unless $unknown; my $name = $tag; $name =~ s/([\x00-\x1f\x7f-\xff])/'x'.unpack('H*',$1)/eg; $tagInfo = { Name => "Unknown_$name", Description => "Unknown $name", Unknown => 1, }, AddTagToTable($tagTablePtr, $tag, $tagInfo); } $val = '0x' . unpack('H*', $val) unless $$tagInfo{Format}; $et->HandleTag($tagTablePtr, $tag, $val, DataPt => $dataPt, DataPos => $dataPos, Start => $pos + 4, Size => 4, ); } return 1; } #------------------------------------------------------------------------------ # Process iTunes Encoding Params (ref PH) # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success sub ProcessEncodingParams($$$) { my ($et, $dirInfo, $tagTablePtr) = @_; my $dataPt = $$dirInfo{DataPt}; my $dirLen = length $$dataPt; my $pos; $et->VerboseDir('Encoding Params', $dirLen / 8); for ($pos = 0; $pos + 8 <= $dirLen; $pos += 8) { my ($tag, $val) = unpack("x${pos}a4N", $$dataPt); $et->HandleTag($tagTablePtr, $tag, $val); } return 1; } #------------------------------------------------------------------------------ # Process Meta keys and add tags to the ItemList table ('mdta' handler) (ref PH) # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref # Returns: 1 on success sub ProcessKeys($$$) { local $_; my ($et, $dirInfo, $tagTablePtr) = @_; my $dataPt = $$dirInfo{DataPt}; my $dirLen = length $$dataPt; my $out; if ($et->Options('Verbose')) { $et->VerboseDir('Keys'); $out = $et->Options('TextOut'); } my $pos = 8; my $index = 1; ++$$et{KeyCount}; # increment key count for this directory my $infoTable = GetTagTable('Image::ExifTool::QuickTime::ItemList'); my $userTable = GetTagTable('Image::ExifTool::QuickTime::UserData'); while ($pos < $dirLen - 4) { my $len = unpack("x${pos}N", $$dataPt); last if $len < 8 or $pos + $len > $dirLen; delete $$tagTablePtr{$index}; my $ns = substr($$dataPt, $pos + 4, 4); my $tag = substr($$dataPt, $pos + 8, $len - 8); $tag =~ s/\0.*//s; # truncate at null if ($ns eq 'mdta') { $tag =~ s/^com\.apple\.quicktime\.//; # remove common apple quicktime domain } next unless $tag; # (I have some samples where the tag is a reversed ItemList or UserData tag ID) my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); unless ($tagInfo) { $tagInfo = $et->GetTagInfo($infoTable, $tag); unless ($tagInfo) { $tagInfo = $et->GetTagInfo($userTable, $tag); if (not $tagInfo and $tag =~ /^\w{3}\xa9$/) { $tag = pack('N', unpack('V', $tag)); $tagInfo = $et->GetTagInfo($infoTable, $tag); $tagInfo or $tagInfo = $et->GetTagInfo($userTable, $tag); } } } my ($newInfo, $msg); if ($tagInfo) { $newInfo = { Name => $$tagInfo{Name}, Format => $$tagInfo{Format}, ValueConv => $$tagInfo{ValueConv}, PrintConv => $$tagInfo{PrintConv}, }; my $groups = $$tagInfo{Groups}; $$newInfo{Groups} = { %$groups } if $groups; } elsif ($tag =~ /^[-\w.]+$/) { # create info for tags with reasonable id's my $name = $tag; $name =~ s/\.(.)/\U$1/g; $newInfo = { Name => ucfirst($name) }; $msg = ' (Unknown)'; } # substitute this tag in the ItemList table with the given index my $id = $$et{KeyCount} . '.' . $index; if (ref $$infoTable{$id} eq 'HASH') { # delete other languages too if they exist my $oldInfo = $$infoTable{$id}; if ($$oldInfo{OtherLang}) { delete $$infoTable{$_} foreach @{$$oldInfo{OtherLang}}; } delete $$infoTable{$id}; } if ($newInfo) { $msg or $msg = ''; AddTagToTable($infoTable, $id, $newInfo); $out and print $out "$$et{INDENT}Added ItemList Tag $id = $tag$msg\n"; } $pos += $len; ++$index; } return 1; } #------------------------------------------------------------------------------ # Process a QuickTime atom # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) optional tag table ref # Returns: 1 on success sub ProcessMOV($$;$) { my ($et, $dirInfo, $tagTablePtr) = @_; my $raf = $$dirInfo{RAF}; my $dataPt = $$dirInfo{DataPt}; my $verbose = $et->Options('Verbose'); my $dataPos = $$dirInfo{Base} || 0; my $charsetQuickTime = $et->Options('CharsetQuickTime'); my ($buff, $tag, $size, $track, $isUserData, %triplet, $doDefaultLang); unless (defined $$et{KeyCount}) { $$et{KeyCount} = 0; # initialize ItemList key directory count $doDefaultLang = 1; # flag to generate default language tags } # more convenient to package data as a RandomAccess file $raf or $raf = new File::RandomAccess($dataPt); # skip leading bytes if necessary if ($$dirInfo{DirStart}) { $raf->Seek($$dirInfo{DirStart}, 1) or return 0; $dataPos += $$dirInfo{DirStart}; } # read size/tag name atom header $raf->Read($buff,8) == 8 or return 0; $dataPos += 8; if ($tagTablePtr) { $isUserData = ($tagTablePtr eq \%Image::ExifTool::QuickTime::UserData); } else { $tagTablePtr = GetTagTable('Image::ExifTool::QuickTime::Main'); } ($size, $tag) = unpack('Na4', $buff); if ($dataPt) { $verbose and $et->VerboseDir($$dirInfo{DirName}); } else { # check on file type if called with a RAF $$tagTablePtr{$tag} or return 0; if ($tag eq 'ftyp' and $size >= 12) { # read ftyp atom to see what type of file this is my $fileType; if ($raf->Read($buff, $size-8) == $size-8) { $raf->Seek(-($size-8), 1); my $type = substr($buff, 0, 4); # see if we know the extension for this file type if ($ftypLookup{$type} and $ftypLookup{$type} =~ /\(\.(\w+)/) { $fileType = $1; # check compatible brands } elsif ($buff =~ /^.{8}(.{4})+(mp41|mp42|avc1)/s) { $fileType = 'MP4'; } elsif ($buff =~ /^.{8}(.{4})+(f4v )/s) { $fileType = 'F4V'; } elsif ($buff =~ /^.{8}(.{4})+(qt )/s) { $fileType = 'MOV'; } } $fileType or $fileType = 'MP4'; # default to MP4 $et->SetFileType($fileType, $mimeLookup{$fileType} || 'video/mp4'); } else { $et->SetFileType(); # MOV } SetByteOrder('MM'); $$et{PRIORITY_DIR} = 'XMP'; # have XMP take priority } for (;;) { if ($size < 8) { if ($size == 0) { if ($dataPt) { # a zero size isn't legal for contained atoms, but Canon uses it to # terminate the CNTH atom (eg. CanonEOS100D.mov), so tolerate it here my $pos = $raf->Tell() - 4; $raf->Seek(0,2); my $str = $$dirInfo{DirName} . ' with ' . ($raf->Tell() - $pos) . ' bytes'; $et->VPrint(0,"$$et{INDENT}\[Terminator found in $str remaining]"); } else { $tag = sprintf("0x%.8x",Get32u(\$tag,0)) if $tag =~ /[\x00-\x1f\x7f-\xff]/; $et->VPrint(0,"$$et{INDENT}Tag '$tag' extends to end of file"); } last; } $size == 1 or $et->Warn('Invalid atom size'), last; # read extended atom size $raf->Read($buff, 8) == 8 or last; $dataPos += 8; my ($hi, $lo) = unpack('NN', $buff); if ($hi or $lo > 0x7fffffff) { if ($hi > 0x7fffffff) { $et->Warn('Invalid atom size'); last; } elsif (not $et->Options('LargeFileSupport')) { $et->Warn('End of processing at large atom (LargeFileSupport not enabled)'); last; } } $size = $hi * 4294967296 + $lo - 16; $size < 0 and $et->Warn('Invalid extended size'), last; } else { $size -= 8; } if ($isUserData and $$et{SET_GROUP1}) { my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); # add track name to UserData tags inside tracks $tag = $$et{SET_GROUP1} . $tag; if (not $$tagTablePtr{$tag} and $tagInfo) { my %newInfo = %$tagInfo; foreach ('Name', 'Description') { next unless $$tagInfo{$_}; $newInfo{$_} = $$et{SET_GROUP1} . $$tagInfo{$_}; $newInfo{$_} =~ s/^(Track\d+)Track/$1/; # remove duplicate "Track" in name } AddTagToTable($tagTablePtr, $tag, \%newInfo); } } my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); # allow numerical tag ID's unless ($tagInfo) { my $id = $$et{KeyCount} . '.' . unpack('N', $tag); if ($$tagTablePtr{$id}) { $tagInfo = $et->GetTagInfo($tagTablePtr, $id); $tag = $id; } } # generate tagInfo if Unknown option set if (not defined $tagInfo and ($$et{OPTIONS}{Unknown} or $verbose or $tag =~ /^\xa9/)) { my $name = $tag; my $n = ($name =~ s/([\x00-\x1f\x7f-\xff])/'x'.unpack('H*',$1)/eg); # print in hex if tag is numerical $name = sprintf('0x%.4x',unpack('N',$tag)) if $n > 2; if ($name =~ /^xa9(.*)/) { $tagInfo = { Name => "UserData_$1", Description => "User Data $1", }; } else { $tagInfo = { Name => "Unknown_$name", Description => "Unknown $name", %unknownInfo, }; } AddTagToTable($tagTablePtr, $tag, $tagInfo); } # save required tag sizes if ($$tagTablePtr{"$tag-size"}) { $et->HandleTag($tagTablePtr, "$tag-size", $size); $et->HandleTag($tagTablePtr, "$tag-offset", $raf->Tell()) if $$tagTablePtr{"$tag-offset"}; } # load values only if associated with a tag (or verbose) and not too big my $ignore; if ($size > 0x2000000) { # start to get worried above 32 MB $ignore = 1; if ($tagInfo and not $$tagInfo{Unknown}) { my $t = $tag; $t =~ s/([\x00-\x1f\x7f-\xff])/'x'.unpack('H*',$1)/eg; if ($size > 0x8000000) { $et->Warn("Skipping '$t' atom > 128 MB", 1); } else { $et->Warn("Skipping '$t' atom > 32 MB", 2) or $ignore = 0; } } } if (defined $tagInfo and not $ignore) { my $val; my $missing = $size - $raf->Read($val, $size); if ($missing) { $et->Warn("Truncated '$tag' data (missing $missing bytes)"); last; } # use value to get tag info if necessary $tagInfo or $tagInfo = $et->GetTagInfo($tagTablePtr, $tag, \$val); my $hasData = ($$dirInfo{HasData} and $val =~ /\0...data\0/s); if ($verbose and not $hasData) { my $tval; if ($tagInfo and $$tagInfo{Format}) { $tval = ReadValue(\$val, 0, $$tagInfo{Format}, $$tagInfo{Count}, length($val)); } $et->VerboseInfo($tag, $tagInfo, Value => $tval, DataPt => \$val, DataPos => $dataPos, Size => $size, Format => $tagInfo ? $$tagInfo{Format} : undef, ); } # handle iTunesInfo mean/name/data triplets if ($tagInfo and $$tagInfo{Triplet}) { if ($tag eq 'data' and $triplet{mean} and $triplet{name}) { $tag = $triplet{name}; # add 'mean' to name unless it is 'com.apple.iTunes' $tag = $triplet{mean} . '/' . $tag unless $triplet{mean} eq 'com.apple.iTunes'; $tagInfo = $et->GetTagInfo($tagTablePtr, $tag, \$val); unless ($tagInfo) { my $name = $triplet{name}; my $desc = $name; $name =~ tr/-_a-zA-Z0-9//dc; $desc =~ tr/_/ /; $tagInfo = { Name => $name, Description => $desc, }; AddTagToTable($tagTablePtr, $tag, $tagInfo); } # ignore 8-byte header $val = substr($val, 8) if length($val) >= 8; unless ($$tagInfo{Format} or $$tagInfo{SubDirectory}) { # extract as binary if it contains any non-ASCII or control characters if ($val =~ /[^\x20-\x7e]/) { my $buff = $val; $val = \$buff; } } undef %triplet; } else { undef %triplet if $tag eq 'mean'; $triplet{$tag} = substr($val,4) if length($val) > 4; undef $tagInfo; # don't store this tag } } if ($tagInfo) { my $subdir = $$tagInfo{SubDirectory}; if ($subdir) { my $start = $$subdir{Start} || 0; my ($base, $dPos) = ($dataPos, 0); if ($$subdir{Base}) { $dPos -= eval $$subdir{Base}; $base -= $dPos; } my %dirInfo = ( DataPt => \$val, DataLen => $size, DirStart => $start, DirLen => $size - $start, DirName => $$subdir{DirName} || $$tagInfo{Name}, HasData => $$subdir{HasData}, Multi => $$subdir{Multi}, IgnoreProp => $$subdir{IgnoreProp}, # (XML hack) DataPos => $dPos, Base => $base, # (needed for IsOffset tags in binary data) ); $dirInfo{BlockInfo} = $tagInfo if $$tagInfo{BlockExtract}; if ($$subdir{ByteOrder} and $$subdir{ByteOrder} =~ /^Little/) { SetByteOrder('II'); } my $oldGroup1 = $$et{SET_GROUP1}; if ($$tagInfo{Name} eq 'Track') { $track or $track = 0; $$et{SET_GROUP1} = 'Track' . (++$track); } my $subTable = GetTagTable($$subdir{TagTable}); my $proc = $$subdir{ProcessProc}; # make ProcessMOV() the default processing procedure for subdirectories $proc = \&ProcessMOV unless $proc or $$subTable{PROCESS_PROC}; $et->ProcessDirectory(\%dirInfo, $subTable, $proc) if $size > $start; $$et{SET_GROUP1} = $oldGroup1; SetByteOrder('MM'); } elsif ($hasData) { # handle atoms containing 'data' tags # (currently ignore contained atoms: 'itif', 'name', etc.) my $pos = 0; for (;;) { last if $pos + 16 > $size; my ($len, $type, $flags, $ctry, $lang) = unpack("x${pos}Na4Nnn", $val); last if $pos + $len > $size; my $value; my $format = $$tagInfo{Format}; if ($type eq 'data' and $len >= 16) { $pos += 16; $len -= 16; $value = substr($val, $pos, $len); # format flags (ref 12): # 0x0=binary, 0x1=UTF-8, 0x2=UTF-16, 0x3=ShiftJIS, # 0x4=UTF-8 0x5=UTF-16, 0xd=JPEG, 0xe=PNG, # 0x15=signed int, 0x16=unsigned int, 0x17=float, # 0x18=double, 0x1b=BMP, 0x1c='meta' atom if ($stringEncoding{$flags}) { # handle all string formats $value = $et->Decode($value, $stringEncoding{$flags}); # (shouldn't be null terminated, but some software writes it anyway) $value =~ s/\0$// unless $$tagInfo{Binary}; } else { if (not $format) { if ($flags == 0x15 or $flags == 0x16) { $format = { 1=>'int8', 2=>'int16', 4=>'int32' }->{$len}; $format .= $flags == 0x15 ? 's' : 'u' if $format; } elsif ($flags == 0x17) { $format = 'float'; } elsif ($flags == 0x18) { $format = 'double'; } elsif ($flags == 0x00) { # read 1 and 2-byte binary as integers if ($len == 1) { $format = 'int8u', } elsif ($len == 2) { $format = 'int16u', } } } if ($format) { $value = ReadValue(\$value, 0, $format, $$tagInfo{Count}, $len); } elsif (not $$tagInfo{ValueConv}) { # make binary data a scalar reference unless a ValueConv exists my $buf = $value; $value = \$buf; } } } my $langInfo; if ($ctry or $lang) { # ignore country ('ctry') and language lists ('lang') for now undef $ctry if $ctry and $ctry <= 255; undef $lang if $lang and $lang <= 255; $lang = UnpackLang($lang); # add country code if specified if ($ctry) { $ctry = unpack('a2',pack('n',$ctry)); # unpack as ISO 3166-1 # treat 'ZZ' like a default country (see ref 12) undef $ctry if $ctry eq 'ZZ'; if ($ctry and $ctry =~ /^[A-Z]{2}$/) { $lang or $lang = 'und'; $lang .= "-$ctry"; } } if ($lang) { # get tagInfo for other language $langInfo = GetLangInfoQT($et, $tagInfo, $lang); # save other language tag ID's so we can delete later if necessary if ($langInfo) { $$tagInfo{OtherLang} or $$tagInfo{OtherLang} = [ ]; push @{$$tagInfo{OtherLang}}, $$langInfo{TagID}; } } } $langInfo or $langInfo = $tagInfo; $et->VerboseInfo($tag, $langInfo, Value => ref $value ? $$value : $value, DataPt => \$val, DataPos => $dataPos, Start => $pos, Size => $len, Format => $format, Extra => sprintf(", Type='$type', Flags=0x%x",$flags) ) if $verbose; $et->FoundTag($langInfo, $value) if defined $value; $pos += $len; } } elsif ($tag =~ /^\xa9/ or $$tagInfo{IText}) { # parse international text to extract all languages my $pos = 0; if ($$tagInfo{Format}) { $et->FoundTag($tagInfo, ReadValue(\$val, 0, $$tagInfo{Format}, undef, length($val))); $pos = $size; } for (;;) { last if $pos + 4 > $size; my ($len, $lang) = unpack("x${pos}nn", $val); $pos += 4; # according to the QuickTime spec (ref 12), $len should include # 4 bytes for length and type words, but nobody (including # Apple, Pentax and Kodak) seems to add these in, so try # to allow for either if ($pos + $len > $size) { $len -= 4; last if $pos + $len > $size or $len < 0; } # ignore any empty entries (or null padding) after the first next if not $len and $pos; my $str = substr($val, $pos, $len); my $langInfo; if ($lang < 0x400) { # this is a Macintosh language code # a language code of 0 is Macintosh english, so treat as default if ($lang) { # use Font.pm to look up language string require Image::ExifTool::Font; $lang = $Image::ExifTool::Font::ttLang{Macintosh}{$lang}; } # the spec says only "Macintosh text encoding", but # allow this to be configured by the user $str = $et->Decode($str, $charsetQuickTime); } else { # convert language code to ASCII (ignore read-only bit) $lang = UnpackLang($lang); # may be either UTF-8 or UTF-16BE my $enc = $str=~s/^\xfe\xff// ? 'UTF16' : 'UTF8'; $str = $et->Decode($str, $enc); } $langInfo = GetLangInfoQT($et, $tagInfo, $lang) if $lang; $et->FoundTag($langInfo || $tagInfo, $str); $pos += $len; } } else { my $format = $$tagInfo{Format}; if ($format) { $val = ReadValue(\$val, 0, $format, $$tagInfo{Count}, length($val)); } my $oldBase; if ($$tagInfo{SetBase}) { $oldBase = $$et{BASE}; $$et{BASE} = $dataPos; } my $key = $et->FoundTag($tagInfo, $val); $$et{BASE} = $oldBase if defined $oldBase; # decode if necessary (NOTE: must be done after RawConv) if (defined $key and (not $format or $format =~ /^string/) and not $$tagInfo{Unknown} and not $$tagInfo{ValueConv} and not $$tagInfo{Binary} and defined $$et{VALUE}{$key} and not ref $val) { my $vp = \$$et{VALUE}{$key}; if (not ref $$vp and length($$vp) <= 65536 and $$vp =~ /[\x80-\xff]/) { # the encoding of this is not specified, so use CharsetQuickTime # unless the string is valid UTF-8 require Image::ExifTool::XMP; my $enc = Image::ExifTool::XMP::IsUTF8($vp) > 0 ? 'UTF8' : $charsetQuickTime; $$vp = $et->Decode($$vp, $enc); } } } } } else { $et->VerboseInfo($tag, $tagInfo, Size => $size, Extra => sprintf(' at offset 0x%.4x', $raf->Tell()), ) if $verbose; $raf->Seek($size, 1) or $et->Warn("Truncated '$tag' data"), last; } $raf->Read($buff, 8) == 8 or last; $dataPos += $size + 8; ($size, $tag) = unpack('Na4', $buff); } # fill in missing defaults for alternate language tags # (the first language is taken as the default) if ($doDefaultLang and $$et{QTLang}) { foreach $tag (@{$$et{QTLang}}) { next unless defined $$et{VALUE}{$tag}; my $langInfo = $$et{TAG_INFO}{$tag} or next; my $tagInfo = $$langInfo{SrcTagInfo} or next; next if defined $$et{VALUE}{$$tagInfo{Name}}; $et->FoundTag($tagInfo, $$et{VALUE}{$tag}); } delete $$et{QTLang}; } return 1; } #------------------------------------------------------------------------------ # Process a QuickTime Image File # Inputs: 0) ExifTool object reference, 1) directory information reference # Returns: 1 on success sub ProcessQTIF($$) { my ($et, $dirInfo) = @_; my $table = GetTagTable('Image::ExifTool::QuickTime::ImageFile'); return ProcessMOV($et, $dirInfo, $table); } 1; # end __END__ =head1 NAME Image::ExifTool::QuickTime - Read QuickTime and MP4 meta information =head1 SYNOPSIS This module is used by Image::ExifTool =head1 DESCRIPTION This module contains routines required by Image::ExifTool to extract information from QuickTime and MP4 video, and M4A audio files. =head1 AUTHOR Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 REFERENCES =over 4 =item L<http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html> =item L<http://search.cpan.org/dist/MP4-Info-1.04/> =item L<http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt> =item L<http://wiki.multimedia.cx/index.php?title=Apple_QuickTime> =item L<http://atomicparsley.sourceforge.net/mpeg-4files.html> =item L<http://wiki.multimedia.cx/index.php?title=QuickTime_container> =item L<http://code.google.com/p/mp4v2/wiki/iTunesMetadata> =item L<http://www.canieti.com.mx/assets/files/1011/IEC_100_1384_DC.pdf> =item L<http://www.adobe.com/devnet/flv/pdf/video_file_format_spec_v10.pdf> =back =head1 SEE ALSO L<Image::ExifTool::TagNames/QuickTime Tags>, L<Image::ExifTool(3pm)|Image::ExifTool> =cut
43.99379
143
0.529911
ed573628f0bc7912809badc26fae76c440fcbf5e
1,437
pm
Perl
cloud/aws/sqs/plugin.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
cloud/aws/sqs/plugin.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
cloud/aws/sqs/plugin.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package cloud::aws::sqs::plugin; use strict; use warnings; use base qw(centreon::plugins::script_custom); sub new { my ( $class, %options ) = @_; my $self = $class->SUPER::new( package => __PACKAGE__, %options ); bless $self, $class; $self->{version} = '1.0'; %{ $self->{modes} } = ( 'queues' => 'cloud::aws::sqs::mode::queues', 'list-queues' => 'cloud::aws::sqs::mode::listqueues' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; $self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli'; return $self; } 1; __END__ =head1 PLUGIN DESCRIPTION Check Amazon Simple Queue Service (Amazon SQS). =cut
27.634615
74
0.686152
ed58ef284e235a31ac7e4731418ec34eb9cba4d0
2,687
pl
Perl
src/linux/tools/perf/scripts/perl/wakeup-latency.pl
wangyan98/linux-lib
f98bbaec0d696b948935939b2d613cd15cd6105f
[ "MIT" ]
21
2021-01-22T06:47:38.000Z
2022-03-20T14:24:29.000Z
src/linux/tools/perf/scripts/perl/wakeup-latency.pl
wangyan98/linux-lib
f98bbaec0d696b948935939b2d613cd15cd6105f
[ "MIT" ]
1
2021-08-07T07:14:45.000Z
2021-08-07T08:24:23.000Z
src/linux/tools/perf/scripts/perl/wakeup-latency.pl
wangyan98/linux-lib
f98bbaec0d696b948935939b2d613cd15cd6105f
[ "MIT" ]
12
2021-01-22T14:59:28.000Z
2022-02-22T04:03:31.000Z
#!/usr/bin/perl -w # (c) 2009, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # Display avg/min/max wakeup latency # The common_* event handler fields are the most useful fields common to # all events. They don't necessarily correspond to the 'common_*' fields # in the status files. Those fields not available as handler params can # be retrieved via script functions of the form get_common_*(). use 5.010000; use strict; use warnings; use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; use lib "./Perf-Trace-Util/lib"; use Perf::Trace::Core; use Perf::Trace::Util; my %last_wakeup; my $max_wakeup_latency; my $min_wakeup_latency; my $total_wakeup_latency; my $total_wakeups; sub sched::sched_switch { my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, $common_pid, $common_comm, $prev_comm, $prev_pid, $prev_prio, $prev_state, $next_comm, $next_pid, $next_prio) = @_; my $wakeup_ts = $last_wakeup{$common_cpu}{ts}; if ($wakeup_ts) { my $switch_ts = nsecs($common_secs, $common_nsecs); my $wakeup_latency = $switch_ts - $wakeup_ts; if ($wakeup_latency > $max_wakeup_latency) { $max_wakeup_latency = $wakeup_latency; } if ($wakeup_latency < $min_wakeup_latency) { $min_wakeup_latency = $wakeup_latency; } $total_wakeup_latency += $wakeup_latency; $total_wakeups++; } $last_wakeup{$common_cpu}{ts} = 0; } sub sched::sched_wakeup { my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, $common_pid, $common_comm, $comm, $pid, $prio, $success, $target_cpu) = @_; $last_wakeup{$target_cpu}{ts} = nsecs($common_secs, $common_nsecs); } sub trace_begin { $min_wakeup_latency = 1000000000; $max_wakeup_latency = 0; } sub trace_end { printf("wakeup_latency stats:\n\n"); print "total_wakeups: $total_wakeups\n"; printf("avg_wakeup_latency (ns): %u\n", avg($total_wakeup_latency, $total_wakeups)); printf("min_wakeup_latency (ns): %u\n", $min_wakeup_latency); printf("max_wakeup_latency (ns): %u\n", $max_wakeup_latency); print_unhandled(); } my %unhandled; sub print_unhandled { if ((scalar keys %unhandled) == 0) { return; } print "\nunhandled events:\n\n"; printf("%-40s %10s\n", "event", "count"); printf("%-40s %10s\n", "----------------------------------------", "-----------"); foreach my $event_name (keys %unhandled) { printf("%-40s %10d\n", $event_name, $unhandled{$event_name}); } } sub trace_unhandled { my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, $common_pid, $common_comm) = @_; $unhandled{$event_name}++; }
25.836538
73
0.675847
ed54f20a3df03b186e81ea755ba2030d95312afb
261
pm
Perl
ISA/lib/perl/StudyAssayEntity/Performer.pm
EuPathDB-Infra/CBIL
412e748211eaff7c138ad4e7bcdf1c6233d2012e
[ "Apache-2.0" ]
null
null
null
ISA/lib/perl/StudyAssayEntity/Performer.pm
EuPathDB-Infra/CBIL
412e748211eaff7c138ad4e7bcdf1c6233d2012e
[ "Apache-2.0" ]
1
2020-02-13T16:00:10.000Z
2020-02-13T16:00:10.000Z
ISA/lib/perl/StudyAssayEntity/Performer.pm
VEuPathDB/CBIL
92269a7d9f1df07f39eb5eb5d76a9e866c6b0c82
[ "Apache-2.0" ]
null
null
null
package CBIL::ISA::StudyAssayEntity::Performer; use base qw(CBIL::ISA::StudyAssayEntity); use strict; sub isNode { return 0; } # subclasses must consider these sub getAttributeNames { return []; } sub getParents { return ["ProtocolApplication"]; } 1;
13.736842
47
0.720307
ed5640592a7b50531fd617903a73c70a9866a6df
993
pm
Perl
lib/App/llffp/Schema/Result/Performer.pm
mmcclimon/app-llffp
140a0e8d109da8ab356b72e344934744eadec0ad
[ "MIT", "X11", "Unlicense" ]
null
null
null
lib/App/llffp/Schema/Result/Performer.pm
mmcclimon/app-llffp
140a0e8d109da8ab356b72e344934744eadec0ad
[ "MIT", "X11", "Unlicense" ]
null
null
null
lib/App/llffp/Schema/Result/Performer.pm
mmcclimon/app-llffp
140a0e8d109da8ab356b72e344934744eadec0ad
[ "MIT", "X11", "Unlicense" ]
null
null
null
package App::llffp::Schema::Result::Performer; use base qw{DBIx::Class::Core}; use warnings; use strict; # This class uses the "performer" table __PACKAGE__->table('performer'); # A performer has either an ensemble name or a person's last name (not both). # XXX figure out a way to enforce this __PACKAGE__->add_columns( id => { accessor => 'id', data_type => 'integer', is_nullable => 0, is_auto_increment => 1, }, last_name => { data_type => 'varchar', size => 256, is_nullable => 1, }, first_name => { data_type => 'varchar', size => 256, is_nullable => 1, }, ensemble_name => { data_type => 'varchar', size => 256, is_nullable => 1, }, birth_date => { data_type => 'integer', is_nullable => 1, }, death_date => { data_type => 'integer', is_nullable => 1, }, ); __PACKAGE__->set_primary_key('id'); 1;
21.12766
77
0.545821
73f21560c14c35027922897be5bd72d1c2ad6415
29,347
t
Perl
t/sets12345.t
BrotherBuford/tantocuore-randomizer
4b4ba49a059949b4d96d223a79df643a96fcae41
[ "MIT" ]
6
2019-09-25T17:47:15.000Z
2021-06-02T09:01:23.000Z
t/sets12345.t
BrotherBuford/tantocuore-randomizer
4b4ba49a059949b4d96d223a79df643a96fcae41
[ "MIT" ]
null
null
null
t/sets12345.t
BrotherBuford/tantocuore-randomizer
4b4ba49a059949b4d96d223a79df643a96fcae41
[ "MIT" ]
null
null
null
## no critic (Modules::RequireExplicitPackage, Modules::RequireVersionVar, Modules::RequireEndWithOne) use warnings; use strict; use Local::TantoCuore::Test qw(:all); my @sets = qw(1 2 3 4 5); my @testcases = ( [ [qw(beer=1)], [qw()], ], [ [qw(private=1 beer=1)], [qw()], ], [ [qw(events=1 beer=1)], [qw(20 21 PR43)], ], [ [qw(private=1 events=1 beer=1)], [qw()], ], [ [qw(buildings=1 beer=1)], [qw(20-IV 20-V 27-II)], ], [ [qw(buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(buildings=1 events=1 beer=1)], [qw(20 21 27-II)], ], [ [qw(buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(reminiscences=2 beer=1)], [qw()], ], [ [qw(reminiscences=2 private=1 beer=1)], [qw()], ], [ [qw(reminiscences=2 events=1 beer=1)], [qw(20 21 PR43)], ], [ [qw(reminiscences=2 private=1 events=1 beer=1)], [qw()], ], [ [qw(reminiscences=2 buildings=1 beer=1)], [qw(20-IV 20-V 27-II)], ], [ [qw(reminiscences=2 buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(reminiscences=2 buildings=1 events=1 beer=1)], [qw(20 21 27-II)], ], [ [qw(reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(reminiscences=1 beer=1)], [qw(PR14)], ], [ [qw(reminiscences=1 private=1 beer=1)], [qw()], ], [ [qw(reminiscences=1 events=1 beer=1)], [qw(20 21 PR14 PR43)], ], [ [qw(reminiscences=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(reminiscences=1 buildings=1 beer=1)], [qw(20-IV 20-V 27-II PR14)], ], [ [qw(reminiscences=1 buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(reminiscences=1 buildings=1 events=1 beer=1)], [qw(20 21 27-II PR14)], ], [ [qw(reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 beer=1)], [qw()], ], [ [qw(couples=1 private=1 beer=1)], [qw()], ], [ [qw(couples=1 events=1 beer=1)], [qw(20 21)], ], [ [qw(couples=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 buildings=1 beer=1)], [qw(20-IV 20-V 27-II)], ], [ [qw(couples=1 buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(couples=1 buildings=1 events=1 beer=1)], [qw(20 21 27-II)], ], [ [qw(couples=1 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=2 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=2 private=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=2 events=1 beer=1)], [qw(20 21)], ], [ [qw(couples=1 reminiscences=2 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=2 buildings=1 beer=1)], [qw(20-IV 20-V 27-II)], ], [ [qw(couples=1 reminiscences=2 buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(couples=1 reminiscences=2 buildings=1 events=1 beer=1)], [qw(20 21 27-II)], ], [ [qw(couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=1 beer=1)], [qw(PR14)], ], [ [qw(couples=1 reminiscences=1 private=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=1 events=1 beer=1)], [qw(20 21 PR14)], ], [ [qw(couples=1 reminiscences=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(couples=1 reminiscences=1 buildings=1 beer=1)], [qw(20-IV 20-V 27-II PR14)], ], [ [qw(couples=1 reminiscences=1 buildings=1 private=1 beer=1)], [qw(20-IV 20-V)], ], [ [qw(couples=1 reminiscences=1 buildings=1 events=1 beer=1)], [qw(20 21 27-II PR14)], ], [ [qw(couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(attack=1 beer=1)], [qw(19 20 20-II 21 25 30-III PR43)], ], [ [qw(attack=1 private=1 beer=1)], [qw(30-III PR43)], ], [ [qw(attack=1 events=1 beer=1)], [qw(19 20 20-II 21 25 30-III PR43)], ], [ [qw(attack=1 private=1 events=1 beer=1)], [qw(30-III PR43)], ], [ [qw(attack=1 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 buildings=1 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 buildings=1 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=2 beer=1)], [qw(19 20 20-II 21 25 30-III PR43)], ], [ [qw(attack=1 reminiscences=2 private=1 beer=1)], [qw(30-III PR43)], ], [ [qw(attack=1 reminiscences=2 events=1 beer=1)], [qw(19 20 20-II 21 25 30-III PR43)], ], [ [qw(attack=1 reminiscences=2 private=1 events=1 beer=1)], [qw(30-III PR43)], ], [ [qw(attack=1 reminiscences=2 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 reminiscences=2 buildings=1 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=2 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=1 beer=1)], [qw(19 20 20-II 21 25 PR14 PR43)], ], [ [qw(attack=1 reminiscences=1 private=1 beer=1)], [qw()], ], [ [qw(attack=1 reminiscences=1 events=1 beer=1)], [qw(19 20 20-II 21 25 PR14 PR43)], ], [ [qw(attack=1 reminiscences=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(attack=1 reminiscences=1 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II PR14)], ], [ [qw(attack=1 reminiscences=1 buildings=1 private=1 beer=1)], [qw()], ], [ [qw(attack=1 reminiscences=1 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II PR14)], ], [ [qw(attack=1 reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(attack=1 couples=1 beer=1)], [qw(19 20 20-II 21 25 30-III)], ], [ [qw(attack=1 couples=1 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 events=1 beer=1)], [qw(19 20 20-II 21 25 30-III)], ], [ [qw(attack=1 couples=1 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 couples=1 buildings=1 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 couples=1 buildings=1 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 beer=1)], [qw(19 20 20-II 21 25 30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 events=1 beer=1)], [qw(19 20 20-II 21 25 30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 private=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II 30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=1 beer=1)], [qw(19 20 20-II 21 25 PR14)], ], [ [qw(attack=1 couples=1 reminiscences=1 private=1 beer=1)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 events=1 beer=1)], [qw(19 20 20-II 21 25 PR14)], ], [ [qw(attack=1 couples=1 reminiscences=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 beer=1)], [qw(19 20 20-II 21 25 27-II PR14)], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 private=1 beer=1)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 events=1 beer=1)], [qw(19 20 20-II 21 25 27-II PR14)], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw()], ], [ [qw(attack=2 beer=1)], [qw(Error)], ], [ [qw(attack=2 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 private=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 events=1 beer=1)], [qw(Error)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=1)], [qw(Error)], ], [ [qw(beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(private=1 beer=2)], [qw(21-IV)], ], [ [qw(events=1 beer=2)], [qw(20 21 PR19 PR34 PR43)], ], [ [qw(private=1 events=1 beer=2)], [qw()], ], [ [qw(buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(reminiscences=2 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(reminiscences=2 private=1 beer=2)], [qw(21-IV)], ], [ [qw(reminiscences=2 events=1 beer=2)], [qw(20 21 PR19 PR34 PR43)], ], [ [qw(reminiscences=2 private=1 events=1 beer=2)], [qw()], ], [ [qw(reminiscences=2 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(reminiscences=2 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(reminiscences=2 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(reminiscences=1 beer=2)], [qw(21-IV PR14 PR19 PR34)], ], [ [qw(reminiscences=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(reminiscences=1 events=1 beer=2)], [qw(20 21 PR14 PR19 PR34 PR43)], ], [ [qw(reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(reminiscences=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR14 PR19 PR34)], ], [ [qw(reminiscences=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(reminiscences=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR14 PR19 PR34)], ], [ [qw(reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(couples=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(couples=1 events=1 beer=2)], [qw(20 21 PR19 PR34)], ], [ [qw(couples=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(couples=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(couples=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(couples=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 reminiscences=2 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(couples=1 reminiscences=2 private=1 beer=2)], [qw(21-IV)], ], [ [qw(couples=1 reminiscences=2 events=1 beer=2)], [qw(20 21 PR19 PR34)], ], [ [qw(couples=1 reminiscences=2 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 reminiscences=2 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(couples=1 reminiscences=2 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(couples=1 reminiscences=2 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 reminiscences=1 beer=2)], [qw(21-IV PR14 PR19 PR34)], ], [ [qw(couples=1 reminiscences=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(couples=1 reminiscences=1 events=1 beer=2)], [qw(20 21 PR14 PR19 PR34)], ], [ [qw(couples=1 reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(couples=1 reminiscences=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR14 PR19 PR34)], ], [ [qw(couples=1 reminiscences=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(couples=1 reminiscences=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR14 PR19 PR34)], ], [ [qw(couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34 PR43)], ], [ [qw(attack=1 private=1 beer=2)], [qw(30-III PR43)], ], [ [qw(attack=1 events=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34 PR43)], ], [ [qw(attack=1 private=1 events=1 beer=2)], [qw(30-III PR43)], ], [ [qw(attack=1 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 buildings=1 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 buildings=1 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=2 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34 PR43)], ], [ [qw(attack=1 reminiscences=2 private=1 beer=2)], [qw(30-III PR43)], ], [ [qw(attack=1 reminiscences=2 events=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34 PR43)], ], [ [qw(attack=1 reminiscences=2 private=1 events=1 beer=2)], [qw(30-III PR43)], ], [ [qw(attack=1 reminiscences=2 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 reminiscences=2 buildings=1 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=2 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 reminiscences=1 beer=2)], [qw(19 20 20-II 21 25 PR14 PR19 PR34 PR43)], ], [ [qw(attack=1 reminiscences=1 private=1 beer=2)], [qw()], ], [ [qw(attack=1 reminiscences=1 events=1 beer=2)], [qw(19 20 20-II 21 25 PR14 PR19 PR34 PR43)], ], [ [qw(attack=1 reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=1 reminiscences=1 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II PR14 PR19 PR34)], ], [ [qw(attack=1 reminiscences=1 buildings=1 private=1 beer=2)], [qw()], ], [ [qw(attack=1 reminiscences=1 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II PR14 PR19 PR34)], ], [ [qw(attack=1 reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=1 couples=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 events=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 buildings=1 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 buildings=1 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=2 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 events=1 beer=2)], [qw(19 20 20-II 21 25 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=2 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 private=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II 30-III PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw(30-III)], ], [ [qw(attack=1 couples=1 reminiscences=1 beer=2)], [qw(19 20 20-II 21 25 PR14 PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=1 private=1 beer=2)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 events=1 beer=2)], [qw(19 20 20-II 21 25 PR14 PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 beer=2)], [qw(19 20 20-II 21 25 27-II PR14 PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 private=1 beer=2)], [qw()], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 events=1 beer=2)], [qw(19 20 20-II 21 25 27-II PR14 PR19 PR34)], ], [ [qw(attack=1 couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(attack=2 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 events=1 beer=2)], [qw(20 21 PR19 PR34 PR43)], ], [ [qw(attack=2 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(attack=2 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(attack=2 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 reminiscences=2 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(attack=2 reminiscences=2 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 reminiscences=2 events=1 beer=2)], [qw(20 21 PR19 PR34 PR43)], ], [ [qw(attack=2 reminiscences=2 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 reminiscences=2 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(attack=2 reminiscences=2 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 reminiscences=2 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(attack=2 reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 reminiscences=1 beer=2)], [qw(21-IV PR14 PR19 PR34)], ], [ [qw(attack=2 reminiscences=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 reminiscences=1 events=1 beer=2)], [qw(20 21 PR14 PR19 PR34 PR43)], ], [ [qw(attack=2 reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 reminiscences=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR14 PR19 PR34)], ], [ [qw(attack=2 reminiscences=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 reminiscences=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR14 PR19 PR34)], ], [ [qw(attack=2 reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(attack=2 couples=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 couples=1 events=1 beer=2)], [qw(20 21 PR19 PR34)], ], [ [qw(attack=2 couples=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(attack=2 couples=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 couples=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(attack=2 couples=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 reminiscences=2 beer=2)], [qw(21-IV PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=2 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 couples=1 reminiscences=2 events=1 beer=2)], [qw(20 21 PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=2 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=2 buildings=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 reminiscences=1 beer=2)], [qw(21-IV PR14 PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=1 private=1 beer=2)], [qw(21-IV)], ], [ [qw(attack=2 couples=1 reminiscences=1 events=1 beer=2)], [qw(20 21 PR14 PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=1 private=1 events=1 beer=2)], [qw()], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 beer=2)], [qw(20-IV 20-V 21-IV 27-II PR14 PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 private=1 beer=2)], [qw(20-IV 20-V 21-IV)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 events=1 beer=2)], [qw(20 21 27-II PR14 PR19 PR34)], ], [ [qw(attack=2 couples=1 reminiscences=1 buildings=1 private=1 events=1 beer=2)], [qw()], ], ); run_tests( \@sets, \@testcases );
25.212199
102
0.489658
73f3a3a01c12680e54a958b696983dc875fdadf4
5,935
pm
Perl
lib/Mojolicious/Plugin/RoutesConfig.pm
kberov/Mojolicious-Plugin-RoutesConfig
2e69b3c4a7cffa756509f15e71265f97ec77092d
[ "Artistic-2.0" ]
1
2019-04-15T10:48:50.000Z
2019-04-15T10:48:50.000Z
lib/Mojolicious/Plugin/RoutesConfig.pm
kberov/Mojolicious-Plugin-RoutesConfig
2e69b3c4a7cffa756509f15e71265f97ec77092d
[ "Artistic-2.0" ]
2
2019-02-04T21:13:02.000Z
2021-06-06T21:01:55.000Z
lib/Mojolicious/Plugin/RoutesConfig.pm
kberov/Mojolicious-Plugin-RoutesConfig
2e69b3c4a7cffa756509f15e71265f97ec77092d
[ "Artistic-2.0" ]
null
null
null
package Mojolicious::Plugin::RoutesConfig; use Mojo::Base 'Mojolicious::Plugin::Config', -signatures; use List::Util qw(first); our $VERSION = 0.07; our $AUTHORITY = 'cpan:BEROV'; sub register { my ($self, $app, $conf) = @_; my $file = $conf->{file}; my $file_msg = ($file ? ' in file ' . $file : ''); $conf = $self->SUPER::register($app, $conf); $app->log->warn('No routes definitions found' . $file_msg . '...') && return $conf unless exists $conf->{routes}; $app->log->warn( '"routes" key must point to an ARRAY reference ' . 'of routes descriptions' . $file_msg . '...') && return $conf unless ref $conf->{routes} eq 'ARRAY'; $self->_generate_routes($app, $app->routes, $conf->{routes}, $file_msg); return $conf; } # generates routes (recursively for under) sub _generate_routes { my ($self, $app, $routes, $routes_conf, $file_msg) = @_; my $init_rx = '^(?:any|get|post|patch|put|delete|options|under)$'; for my $rconf (@$routes_conf) { my $init_method = first(sub { $_ =~ /$init_rx/; }, keys %$rconf); unless ($init_method) { $app->log->warn( "Malformed route description$file_msg!!!$/" . " Could not find route initialisation method, matching$/" . " /$init_rx/$/" . " in definition$/" . $app->dumper($rconf) . ". Skipping..."); next; } my $init_params = $rconf->{$init_method}; my $route = _call_method($routes, $init_method, $init_params); if ($init_method eq 'under') { # recourse $self->_generate_routes($app, $route, $rconf->{routes}, $file_msg); } for my $method (keys %$rconf) { next if $method =~ /^(?:$init_method|routes)$/; my $params = $rconf->{$method}; $route->can($method) || do { $app->log->warn("Malformed route description$file_msg!!!$/" . " for route definition$/" . $app->dumper($rconf) . qq|Can't locate object method "$method" via package "${\ ref $route}"!$/| . ' Removing route ' . (ref $init_params eq 'ARRAY' ? $init_params->[0] : $init_params)); $route->remove(); last; }; _call_method($route, $method, $params); } } return; } # Returns a new or existing route sub _call_method ($caller, $method, $params) { if (ref $params eq 'ARRAY') { return $caller->$method(@$params); } elsif (ref $params eq 'HASH') { return $caller->$method(%$params); } elsif (ref $params eq 'CODE') { return $caller->$method($params->()); } else { return $caller->$method($params); } Carp::confess("Paramether to $method " . "must be one of ARRAY, HASH, CODE reference or scalar in the form controller#action. " . "Now it is " . Mojo::Util::dumper($params)); } =encoding utf8 =head1 NAME Mojolicious::Plugin::RoutesConfig - Describe routes in configuration =head1 SYNOPSIS # Create $MOJO_HOME/etc/routes.conf and describe your routes # or do it directly in $MOJO_HOME/${\ $app->moniker }.conf { routes => [ {get => '/groups', to => 'groups#list', name => 'list_groups'}, {post => '/groups', to => 'groups#create'}, {any => {[qw(GET POST)] => '/users'}, to => 'users#list_or_create'}, {under => '/управление', to => 'auth#under_management', routes => [ {any => '/', to => 'upravlenie#index', name => 'home_upravlenie'}, {get => '/groups', to => 'groups#index', name => 'home_groups'}, #... ], }, ], } # in YourApp::startup() my $config = $app->plugin('Config'); # or even my $config = $app->plugin('RoutesConfig'); # or $app->plugin('RoutesConfig', $config); $app->plugin('RoutesConfig', {file => $app->home->child('etc/routes_admin.conf')}); $app->plugin('RoutesConfig', {file => $app->home->child('etc/routes_site.conf')}); # in YourLiteApp my $config = plugin 'Config'; plugin 'RoutesConfig', $config; plugin 'RoutesConfig', {file => app->home->child('etc/routes_admin.conf')}; plugin 'RoutesConfig', {file => app->home->child('etc/routes_site.conf')}; =head1 DESCRIPTION L<Mojolicious::Plugin::RoutesConfig> allows you to define your routes in configuration file or in a separate file, for example C<$MOJO_HOME/etc/plugins/routes.conf>. This way you can quickly enable and disable parts of your application without editing its source code. The routes are described the same way as you would generate them imperatively, just instead of methods you use method names as keys and suitable references as values which will be dereferenced and passed as arguments to the respective method. If C<$parameters> is a reference to CODE it will be executed and whatever it returns will be the parameters for the respective method.For allowed keys look at L<Mojolicious::Routes::Route/METHODS>. Look at C<t/blog/etc/complex_routes.conf> for inspiration. You can have all your routes defined in the configuration file as it is Perl and you have the C<app> object available. =head1 METHODS L<Mojolicious::Plugin::RoutesConfig> inherits all methods from L<Mojolicious::Plugin::Config> and implements the following new ones. =head2 register my $config = $plugin->register(Mojolicious->new, $config); my $config = $plugin->register($app, {file => '/etc/app_routes.conf'}); Register the plugin in L<Mojolicious> application and generate routes. =head1 AUTHOR Красимир Беров CPAN ID: BEROV berov ат cpan точка org http://i-can.eu =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of Artistic License 2.0. The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L<Mojolicious::Routes>, L<Mojolicious::Routes::Route>, L<Mojolicious::Plugin::Config> =cut 1;
33.342697
132
0.627801
ed59007f2b411362203d6cb077b5d4fa17571ac0
112
pl
Perl
HelloWorld/ProgrammingPerl/ch03/ch03.059.pl
grtlinux/KieaPerl
ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e
[ "Apache-2.0" ]
null
null
null
HelloWorld/ProgrammingPerl/ch03/ch03.059.pl
grtlinux/KieaPerl
ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e
[ "Apache-2.0" ]
null
null
null
HelloWorld/ProgrammingPerl/ch03/ch03.059.pl
grtlinux/KieaPerl
ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e
[ "Apache-2.0" ]
null
null
null
my $home = $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($<))[7] || die "You're homeless!\n";
22.4
36
0.428571
ed48d6d5d00e3360b485e37900c7653197b31cda
1,175
t
Perl
t/01basic.t
git-the-cpan/MooseX-AttributeTags
585e2244e85dee47c96461309639b387cce78178
[ "Artistic-1.0" ]
null
null
null
t/01basic.t
git-the-cpan/MooseX-AttributeTags
585e2244e85dee47c96461309639b387cce78178
[ "Artistic-1.0" ]
null
null
null
t/01basic.t
git-the-cpan/MooseX-AttributeTags
585e2244e85dee47c96461309639b387cce78178
[ "Artistic-1.0" ]
null
null
null
=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::AttributeTags compiles and works. =head1 AUTHOR Toby Inkster E<lt>tobyink@cpan.orgE<gt>. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::More; use Test::Fatal; { package Foo; use Moose; use MooseX::AttributeTags ( 'Foo', 'Bar' => [ quux => [ is => 'ro', default => 666 ], quuux => [ is => 'ro', default => 999 ], xyzzy => sub { 42 }, ], 'Baz' => [ barry => [ is => 'ro', required => 1 ], ], ); has munchkin1 => ( traits => [ Foo, Bar ], is => 'ro', quux => 777, ); ::like( ::exception { has munchkin2 => ( traits => [ Baz ], is => 'ro', ); }, qr{\AAttribute .?barry.? is required}, ); } my $m1 = 'Foo'->meta->get_attribute('munchkin1'); ok $m1->does(Foo::Foo); ok $m1->does(Foo::Bar); can_ok($m1, qw/quux quuux xyzzy/); is($m1->quux, 777); is($m1->quuux, 999); is($m1->xyzzy, 42); done_testing;
16.319444
69
0.57617
ed5b1a154a58915b87954f2d0ad7545881817efb
294
pm
Perl
auto-lib/Paws/RedShift/DeleteClusterResult.pm
cah-rfelsburg/paws
de9ffb8d49627635a2da588066df26f852af37e4
[ "Apache-2.0" ]
2
2016-09-22T09:18:33.000Z
2017-06-20T01:36:58.000Z
auto-lib/Paws/RedShift/DeleteClusterResult.pm
cah-rfelsburg/paws
de9ffb8d49627635a2da588066df26f852af37e4
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/RedShift/DeleteClusterResult.pm
cah-rfelsburg/paws
de9ffb8d49627635a2da588066df26f852af37e4
[ "Apache-2.0" ]
null
null
null
package Paws::RedShift::DeleteClusterResult; use Moose; has Cluster => (is => 'ro', isa => 'Paws::RedShift::Cluster'); 1; ### main pod documentation begin ### =head1 NAME Paws::RedShift::DeleteClusterResult =head1 ATTRIBUTES =head2 Cluster => L<Paws::RedShift::Cluster> =cut
11.307692
64
0.673469
ed5a721d230177d4caa091bcbfdf1937e469d36d
436
t
Perl
tests/glu/dispatch/hello.t
Gaia-Interactive/gaia_core_php
c6ef27682e4ed96cd8d55ae4649e9ed59d18e02a
[ "BSD-3-Clause" ]
3
2015-02-23T19:57:07.000Z
2020-07-13T16:02:01.000Z
tests/glu/dispatch/hello.t
Gaia-Interactive/gaia_core_php
c6ef27682e4ed96cd8d55ae4649e9ed59d18e02a
[ "BSD-3-Clause" ]
null
null
null
tests/glu/dispatch/hello.t
Gaia-Interactive/gaia_core_php
c6ef27682e4ed96cd8d55ae4649e9ed59d18e02a
[ "BSD-3-Clause" ]
4
2015-03-03T08:14:12.000Z
2019-01-09T04:46:43.000Z
#!/usr/bin/env php <?php use Gaia\Test\Tap; $path = __DIR__ . '/lib/hello.php'; include __DIR__ . '/base.php'; Tap::plan(4); Tap::is( $result_dispatch, 'hi there', 'return from dispatch gives correct response'); Tap::is( $result_export_before_dispatch, array(), 'export before dispatch is empty'); Tap::is( $result_export_after_dispatch, array(), 'export after dispatch is empty'); Tap::is( $exception, NULL, 'no exception thrown' );
33.538462
86
0.711009
ed6526640cc14b579b06ce15d711b6d84b2eeba9
1,053
pm
Perl
lib/Google/Ads/GoogleAds/V6/Services/GenderViewService/GetGenderViewRequest.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
lib/Google/Ads/GoogleAds/V6/Services/GenderViewService/GetGenderViewRequest.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
lib/Google/Ads/GoogleAds/V6/Services/GenderViewService/GetGenderViewRequest.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
# Copyright 2020, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. package Google::Ads::GoogleAds::V6::Services::GenderViewService::GetGenderViewRequest; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = {resourceName => $args->{resourceName}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
30.085714
86
0.740741
ed2af4f17de1015e1771324191474cb97e7f3edc
17,224
pl
Perl
phage_tree/combineprotdists.by.length.nomysql.noolds.pl
linsalrob/bioinformatics
da250531fdc3b0e5d6be0ac44d7874fa201f92b0
[ "MIT" ]
3
2018-06-16T20:58:55.000Z
2021-11-25T10:37:29.000Z
combineprotdists.pl
linsalrob/PhageProteomicTree
0a949b0fbfa42bf8eed97d8ce80d512edc530092
[ "MIT" ]
null
null
null
combineprotdists.pl
linsalrob/PhageProteomicTree
0a949b0fbfa42bf8eed97d8ce80d512edc530092
[ "MIT" ]
1
2020-03-07T07:15:51.000Z
2020-03-07T07:15:51.000Z
#!/usr/bin/perl -w # Copyright 2001, 20002 Rob Edwards # For updates, more information, or to discuss the scripts # please contact Rob Edwards at redwards@utmem.edu or via http://www.salmonella.org/ # # This file is part of The Phage Proteome Scripts developed by Rob Edwards. # # Tnese scripts are free software; you can redistribute and/or modify # them under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # They are distributed in the hope that they will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # in the file (COPYING) along with these scripts; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # combinprotdists.pl # a trimmed down version that doesn't complain if the old data and new data don't match. it works fine, but uses less memory # This version doesn't rely on mysql - you need to provide some text files for the mapping. # new version. This will assign a distance of $penalty to any sequence that does not match, and to all empty # spaces. There is a good rationale for this. The The Dayhoff PAM matrix scoring system returns a percent of # the amino acids that are likely to have changed. Therefore a 100% score means that they have all changed. # We will make an average, and include the number of scores used to calculate the average. Then we can fitch # it with the subreplicas option. # the subreplicate number will be added if the protein appears, but is not similar. (i.e. an average score of 100 2 # means that two proteins were found to be similar but were to distant for a score. But an average score of # 100 0 means that no proteins were found! # in this version you can select -n for no padding of missing proteins. Padding runs through the genome and if # no match to another genome is found it increments the score by 100 for each protein in the query (line) genome use strict; my $usage = "combineprotdists.pl <dir of prot dists> <matrix filename> <number of genomes used> <options>\nOPTIONS\n"; $usage .= "\t-d data file : must be in the context [genome, protein id, protein length]\n"; $usage .= "\t-n DON'T pad missing proteins with worst score (supplied with the -p option)\n\t-m print out all protein matches"; $usage .= "\n\t-p # penalty for being bad Rob. Default is 100\n\t-l factor lengths of proteins into the scores\n"; $usage .= "\t-lp penalize based on protein lengths (otherwise it will be whatever the penalty is)\n"; $usage .= "\t-s # skip proteins with match >= this value (treat as if there is no match)\n"; $usage .= "\t-c report progress (will be put on STDERR, but you may want to redirect this\n"; $usage .= "\t-a don't average the protein scores (only works with -l)\n"; my $dir= shift || &niceexit($usage); my $matrixfilename = shift || &niceexit($usage); my $nogenomes = shift || &niceexit($usage); my $args= join (" ", @ARGV); my $pad=1; my $penalty =100; my $skip=100000000; # start with skip unreasonably high. Nothing will be bigger than this. Reset if called on command line my $genomedatafile; if ($args =~ /-n/) {$pad=0} if ($args =~ /-p\s+(\d+)/) {$penalty=$1} if ($args =~ /-s\s+(\d+)/) {$skip=$1; print STDERR "Using skip of $skip\n"} if ($args =~ /-d\s+(\S+)/) {$genomedatafile=$1} &niceexit($usage) unless (defined $genomedatafile); print STDERR "Using PENALTY of $penalty and PAD of $pad\n"; my %noorfs; &getnoorfs; my %proteinlength; if ($args =~ /-l/) { my $length = &getprotlengths; %proteinlength = %$length; } my @matrix; my @newmatch; my @newmatchcount; my @newmismatch; my @newmismatchcount; my $genomedata; # the replacement for dbh my @count; my @proteinmatches; my @genematches; my $minmatch = 100; my $maxmatch=1; my %linegenomecount; # read each file one at a time, and add the data to an array opendir(DIR, $dir) || &niceexit("Can't open $dir"); print STDERR "Reading the files\n"; while (my $file=readdir(DIR)) { next if ($file =~ /^\./); open (IN, "$dir/$file") || &niceexit("Can't open $dir/$file"); my @genomes = ('0'); my @genes = ('0'); my @dists; my %genomeshash; my %checkdupgenomes; # we need to know all the genomes before we can store the data. Therefore # read and store each line in @dists # then get all the genome numbers and store them in an array while (my $line = <IN>) { chomp($line); my @line = split (/\s+/, $line); next unless ($#line); next if ($line =~ /^\s+/); unless ($line[0] =~ /_/) { $line[0] .= "_" . &maponegene($line[0]); $line = join (" ", @line); # this just corrects $line if we change it } push (@dists, $line); my ($gene, $genome) = split (/_/, $line[0]); unless ($gene && $genome) {&niceexit("Can't parse $line in $file\n")} push (@genes, $gene); push (@genomes, $genome); $checkdupgenomes{$genome}++; } # now we loop through all the lines, and split them on white space. # then we add each value to the pre-existing value in the matrix # note that because the genomes are represented as numbers we can just # use these numbers for the position in the matrix. # we are going to also count the number of times that we save each data # point for the final average. # Finally, we only do this in one direction because the input # matrices are complete (and identical) on both halves. # note that column zero of the matrix is empty (there is no genome 0) foreach my $z (0 .. $#dists) { my @line = split (/\s+/, $dists[$z]); unless ($#line == $#genomes) { my $x; foreach my $y (0 .. $#dists) {if ($dists[$y] eq $dists[$z]) {$x = $y}} &niceexit("PROBLEM WITH \n@line AND \n@genomes\n\nIN FILE: $file\n\nBECAUSE $#line AND $#genomes AT LINE $x\n"); } my ($gene, $linegenome) = split (/_/, $line[0]); unless ($gene && $linegenome) {&niceexit("CAN'T PARSE @line SECOND TIME AROUND\n")} $linegenomecount{$linegenome}++; my @seengenome; foreach my $x (1 .. $#genomes) { #do this for all the genomes. next if ($x <= $z+1); # If we are padding the table with 100s where there is no match, we # need to convert the -1's to 100. Otherwise we will ignore it. if ($line[$x] == -1) {if ($pad) {$line[$x] = $penalty} else {next}} next if ($line[$x] > $skip); if ($args =~ /-l/) { if ($args =~ /-c/) {print STDERR "For $x, $line[$x] has protein lengths $proteinlength{$genes[$x]} and $proteinlength{$gene} and becomes "} $line[$x] = $line[$x] * ($proteinlength{$genes[$x]}+$proteinlength{$gene}); unless ($args =~ /-a/) {$line[$x] = $line[$x]/2} if ($args =~ /-c/) {print STDERR " $line[$x]\n"} if ($line[$x] > $maxmatch) {$maxmatch=$line[$x]} if ($line[$x] < $minmatch) {$minmatch=$line[$x]} } #if it is itself, we want to make it zero. Otherwise, we'll save the protein numbers that match if ($genomes[$x] == $linegenome) {$line[$x] = '0.000'} else { my $genematch; # save the protein matches, but I only want to save them one way around # to make it easier if ($gene <$genes[$x]) {$genematch = $gene.",".$genes[$x].";".$line[$x]} else {$genematch = $genes[$x].",".$gene.";".$line[$x]} # protein match is a two dimensional array where each element is an array. # but it is called with an array! 4 dimensions? ${$proteinmatches[$linegenome][$genomes[$x]]}{$genematch} =1; # gene matches is all the genes from $linegenome that match genome. This will # be used to calculate the penalty for ORFs that are missed. ${$genematches[$linegenome][$genomes[$x]]}{$gene} =1; } # add the length if we need to. ####### if ($args =~ /-l/ && $line[$x] > 0) if ($args =~ /-l/) { #now save the data because the count is really the length not the number $matrix[$linegenome][$genomes[$x]] += $line[$x]; $newmatch[$linegenome][$genomes[$x]] += $line[$x]; { my $countadj; if ($args =~ /-a/) {$countadj = ($proteinlength{$genes[$x]}+$proteinlength{$gene})} else {$countadj = ($proteinlength{$genes[$x]}+$proteinlength{$gene})/2} $count[$linegenome][$genomes[$x]] += $countadj; $newmatchcount[$linegenome][$genomes[$x]] += $countadj; } } else { $matrix[$linegenome][$genomes[$x]] += $line[$x]; $count[$linegenome][$genomes[$x]] ++; } $seengenome[$linegenome][$genomes[$x]] ++; } # now we need to pad out all the missing genomes with 100's if ($pad) { foreach my $x (1 .. $nogenomes) { next if ($checkdupgenomes{$x}); next if ($seengenome[$linegenome][$x]); if ($args =~ /-lp/) { $matrix[$linegenome][$x] += $penalty*$proteinlength{$gene}; $count[$linegenome][$x] += $proteinlength{$gene}; $newmismatch[$linegenome][$x] += $penalty*$proteinlength{$gene}; $newmismatchcount[$linegenome][$x] += $proteinlength{$gene}; } else { $matrix[$linegenome][$x] += $penalty; $count[$linegenome][$x] ++; } } } } } print STDERR "\tDone\nSorting and calculating\n"; print STDERR "Minimum match was $minmatch and maximum match was $maxmatch\n"; my $genomeproteins; { # now we need to penalize genomes that have only a few macthes. # we will go through gene matches for each pair in the matrix, and # add a penalty based on the number of missing orfs. if ($pad) { if ($args =~ /-lp/) {$genomeproteins = &getallprots()} else { open (MISS, ">missing.seqs.txt") || &niceexit("Can't open missing.seqs.txt\n"); print MISS "Original\t#ORFs\tCompared to\t# similar\t# different\n"; } foreach my $y (0 .. $#genematches) { next unless (exists $noorfs{$y}); # this just checks we have orfs for genome $y foreach my $x (1 .. $#{$matrix[$y]}) { next unless (exists $noorfs{$x}); next if ($y == $x); my @similar = keys %{$proteinmatches[$y][$x]}; if ($y + $x ==19) {print "xxsimilar $y, $x -> ", $#similar+1, ":\n|", join ("|\n|", @similar), "|\n"} # need to add a loop to get all proteins per genome, and then remove the ones we've seen if ($args =~ /-lp/) { my %found; foreach my $similar (@similar) { my ($genes, $trash) = split /;/, $similar; my ($gene1, $gene2) = split /,/, $genes; $found{$gene1}=$found{$gene2}=1; } foreach my $missedprot (@{${$genomeproteins}{$y}}) { next if (exists $found{$missedprot}); $matrix[$y][$x] += $proteinlength{$missedprot}*$penalty; $count[$y][$x] += $proteinlength{$missedprot}; $newmismatch[$y][$x] += $proteinlength{$missedprot}*$penalty; $newmismatchcount[$y][$x] += $proteinlength{$missedprot}; } } else { my $difference = $noorfs{$y} - ($#similar+1); print MISS "$y\t$noorfs{$y}\t$x\t",$#similar+1, "\t$difference\n"; next unless ($difference); $matrix[$y][$x] += ($penalty * $difference); $count[$y][$x] += $difference; } } } } } my %difference; my %genomedifference; { my %seen; # now we will average the matrix based on the count. foreach my $y (0 .. $#matrix) { next unless ($matrix[$y]); foreach my $x (1 .. $#{$matrix[$y]}) { next unless ($count[$y][$x] && $matrix[$y][$x]); my $temp = $x."+".$y; my $temp1 = $y."+".$x; next if ($seen{$temp} || $seen{$temp1}); $seen{$temp} = $seen{$temp1} =1; # because we are only looking at one half of the matrix (see above) # we need to be sure that both halves are the same. # this loop will take care of that. $matrix[$y][$x] = $matrix[$x][$y] = $matrix[$y][$x] + $matrix[$x][$y]; $count[$y][$x] = $count[$x][$y] = $count[$y][$x] + $count[$x][$y]; $matrix[$x][$y] = $matrix[$y][$x] = $matrix[$y][$x]/$count[$y][$x]; } } } { # we are going to output the matrix twice. This first loop will output the matrix with # the replicates number, and the second loop will output the matrix alone with no replicates # number. This is to test whether FITCH is breaking on the number of replicates. my $minmatch=100; my $maxmatch=1; # now we have all the data, lets just print out the matrix open (OUT, ">$matrixfilename"); print OUT $#matrix, "\n"; #foreach my $y (1 .. $#matrix) {print STDERR "\t$y"} #print STDERR "\n"; foreach my $y (1 .. $#matrix) { my $tempstring = "gnm".$y; if (length($tempstring) > 10) {print STDERR "$tempstring is too long\n"} my $spacestoadd = " " x (10 - length($tempstring)); print OUT $tempstring,$spacestoadd; foreach my $x (1 .. $#matrix) { if ($y == $x) { if ($args=~ /-l/) { my $total; foreach my $protein (@{${$genomeproteins}{$y}}) {$total+=$proteinlength{$protein}} print OUT "0 $total "; } else {print OUT "0 $noorfs{$x} "} next; } unless (defined $matrix[$y][$x]) {print OUT "$penalty 0 "; next} unless ($matrix[$y][$x]) { print OUT "0 "; if ($count[$y][$x]) {print OUT int($count[$y][$x])," "} else {print OUT "0 "} next; } if ($matrix[$y][$x] > $maxmatch) {$maxmatch=$matrix[$y][$x]} if ($matrix[$y][$x] < $minmatch) {$minmatch=$matrix[$y][$x]} print OUT $matrix[$y][$x], " ", int($count[$y][$x]), " "; } print OUT "\n"; } print STDERR "MATRIX: Minimum = $minmatch and MAXIMUM = $maxmatch\n"; close OUT; } { # output the matrix again, this time do not put out the replicates number open (OUT, ">$matrixfilename.nosubreplicates"); print OUT $#matrix, "\n"; #foreach my $y (1 .. $#matrix) {print STDERR "\t$y"} #print STDERR "\n"; foreach my $y (1 .. $#matrix) { my $tempstring = "gnm".$y; if (length($tempstring) > 10) {print STDERR "$tempstring is too long\n"} my $spacestoadd = " " x (10 - length($tempstring)); print OUT $tempstring,$spacestoadd; foreach my $x (1 .. $#matrix) { if ($y == $x) {print OUT "0 "; next} unless (defined $matrix[$y][$x]) {print OUT "$penalty "; next} unless ($matrix[$y][$x]) {print OUT "0 "; next} print OUT $matrix[$y][$x], " "; } print OUT "\n"; } close OUT; } if ($args =~ /-c/) { foreach my $key (sort {$difference{$a} <=> $difference{$b}} keys %difference) {print "$key difference: $difference{$key}\n"} foreach my $key (sort {$genomedifference{$b} <=> $genomedifference{$a}} keys %genomedifference) {print "genome$key difference: $genomedifference{$key}\n"} } if ($args=~ /-m/) { open (PROT, ">$dir.protein.matches") || &niceexit("Can't open $dir.protein.matches for writing\n"); #print out all the protein matches foreach my $y (1 .. $nogenomes) { my $tempstring = "gnm".$y; if (length($tempstring) > 10) {print STDERR "$tempstring is too long\n"} my $spacestoadd = " " x (10 - length($tempstring)); print PROT $tempstring,$spacestoadd, "\t"; foreach my $x (1 .. $nogenomes) { unless (defined $proteinmatches[$y][$x]) {print PROT "\t"; next} unless ($proteinmatches[$y][$x]) {print PROT "\t"; next} my @allmatches = (keys %{$proteinmatches[$y][$x]}, keys %{$proteinmatches[$x][$y]}); my %allmatches; @allmatches{@allmatches}=1; @allmatches = sort keys %allmatches; print PROT join (" ", sort @allmatches), "\t"; } print PROT "\n"; } } &niceexit(0); sub readfile { open(IN, $genomedatafile) || die "can't open genomedatafile"; while (<IN>) { next if (/^\#/); chomp; my @a=split /\t/; push @{$genomedata->{$a[0]}}, [$a[1], $a[2]]; } close IN; } sub maponegene { &readfile() unless (defined $genomedata); my $gene=shift; foreach my $g (keys %$genomedata) { foreach my $tuple (@{$genomedata->{$g}}) { return $g if ($tuple->[0] eq $gene); } } return ""; } sub getnoorfs { &readfile() unless (defined $genomedata); foreach my $g (keys %$genomedata) { $noorfs{$g}=scalar(@{$genomedata->{$g}}); } } sub getprotlengths { &readfile() unless (defined $genomedata); local $| =1; my %length; my $total; my $count; print STDERR "Getting protein lengths "; foreach my $g (keys %$genomedata) { foreach my $tuple (@{$genomedata->{$g}}) { $length{$tuple->[0]}=$tuple->[1]; $total += $tuple->[1]; $count++; } } print STDERR "Done\n"; print STDERR "Total length found is $total for $count proteins, average is ", $total/$count, "\n"; return \%length; } sub getallprots { my %genomeproteins; &readfile() unless (defined $genomedata); foreach my $g (keys %$genomedata) { foreach my $tuple (@{$genomedata->{$g}}) { push @{$genomeproteins{$g}}, $tuple->[0]; } } return \%genomeproteins; } sub niceexit { my $reason = shift; if ($reason) {print STDERR $reason; exit(-1)} else {exit(0)} }
35.808732
155
0.605086
ed446c25d22d416d7902aaeb4d14c52f701106f7
9,919
pm
Perl
miRNAFinderApp/app/features/microPred/progs/miPred/bioperl-1.4/blib/lib/Bio/Coordinate/Collection.pm
shyaman/miRNAFinder-web-server
4e21ea9b77a321ae87a3e0f93abe66eda0013f62
[ "MIT" ]
1
2021-04-27T18:17:33.000Z
2021-04-27T18:17:33.000Z
miRNAFinderApp/app/features/microPred/progs/miPred/bioperl-1.4/Bio/Coordinate/Collection.pm
shyaman/miRNAFinder-web-server
4e21ea9b77a321ae87a3e0f93abe66eda0013f62
[ "MIT" ]
2
2020-06-20T15:59:50.000Z
2021-04-25T17:50:35.000Z
miRNAFinderApp/app/features/microPred/progs/miPred/bioperl-1.4/blib/lib/Bio/Coordinate/Collection.pm
shyaman/miRNAFinder-web-server
4e21ea9b77a321ae87a3e0f93abe66eda0013f62
[ "MIT" ]
null
null
null
# $Id: Collection.pm,v 1.18 2003/12/19 03:02:11 jason Exp $ # # bioperl module for Bio::Coordinate::Collection # # Cared for by Heikki Lehvaslaiho <heikki@ebi.ac.uk> # # Copyright Heikki Lehvaslaiho # # You may distribute this module under the same terms as perl itself # POD documentation - main docs before the code =head1 NAME Bio::Coordinate::Collection - Noncontinuous match between two coordinate sets =head1 SYNOPSIS # create Bio::Coordinate::Pairs or other Bio::Coordinate::MapperIs somehow $pair1; $pair2; # add them into a Collection $collection = Bio::Coordinate::Collection->new; $collection->add_mapper($pair1); $collection->add_mapper($pair2); # create a position and map it $pos = Bio::Location::Simple->new (-start => 5, -end => 9 ); $res = $collection->map($pos); $res->match->start == 1; $res->match->end == 5; # if mapping is many to one (*>1) or many-to-many (*>*) # you have to give seq_id not get unrelevant entries $pos = Bio::Location::Simple->new (-start => 5, -end => 9 -seq_id=>'clone1'); =head1 DESCRIPTION Generic, context neutral mapper to provide coordinate transforms between two B<disjoint> coordinate systems. It brings into Bioperl the functionality from Ewan Birney's Bio::EnsEMBL::Mapper ported into current bioperl. This class is aimed for representing mapping between whole chromosomes and contigs, or between contigs and clones, or between sequencing reads and assembly. The submaps are automatically sorted, so they can be added in any order. To map coordinates to the other direction, you have to swap() the collection. Keeping track of the direction and ID restrictions are left to the calling code. =head1 FEEDBACK =head2 Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing lists Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bio.perl.org/MailList.html - About the mailing lists =head2 Reporting Bugs report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web: bioperl-bugs@bio.perl.org http://bugzilla.bioperl.org/ =head1 AUTHOR - Heikki Lehvaslaiho Email: heikki@ebi.ac.uk Address: EMBL Outstation, European Bioinformatics Institute Wellcome Trust Genome Campus, Hinxton Cambs. CB10 1SD, United Kingdom =head1 CONTRIBUTORS Ewan Birney, birney@ebi.ac.uk =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut # Let the code begin... package Bio::Coordinate::Collection; use vars qw(@ISA ); use strict; # Object preamble - inherits from Bio::Root::Root use Bio::Root::Root; use Bio::Coordinate::MapperI; use Bio::Coordinate::Result; use Bio::Coordinate::Result::Gap; @ISA = qw(Bio::Root::Root Bio::Coordinate::MapperI); sub new { my($class,@args) = @_; my $self = $class->SUPER::new(@args); $self->{'_mappers'} = []; my($in, $out, $strict, $mappers, $return_match) = $self->_rearrange([qw(IN OUT STRICT MAPPERS RETURN_MATCH )], @args); $in && $self->in($in); $out && $self->out($out); $mappers && $self->mappers($mappers); $return_match && $self->return_match('return_match'); return $self; # success - we hope! } =head2 add_mapper Title : add_mapper Usage : $obj->add_mapper($mapper) Function: Pushes one Bio::Coodinate::MapperI into the list of mappers. Sets _is_sorted() to false. Example : Returns : 1 when succeeds, 0 for failure. Args : mapper object =cut sub add_mapper { my ($self,$value) = @_; $self->throw("Is not a Bio::Coordinate::MapperI but a [$self]") unless defined $value && $value->isa('Bio::Coordinate::MapperI'); # test pair range lengths $self->warn("Coodinates in pair [". $value . ":" . $value->in->seq_id . "/". $value->out->seq_id . "] are not right.") unless $value->test; $self->_is_sorted(0); push(@{$self->{'_mappers'}},$value); } =head2 mappers Title : mappers Usage : $obj->mappers(); Function: Returns or sets a list of mappers. Example : Returns : array of mappers Args : array of mappers =cut sub mappers{ my ($self,@args) = @_; if (@args) { $self->throw("Is not a Bio::Coordinate::MapperI but a [$self]") unless defined $args[0] && $args[0]->isa('Bio::Coordinate::MapperI'); push(@{$self->{'_mappers'}}, @args); } return @{$self->{'_mappers'}}; } =head2 each_mapper Title : each_mapper Usage : $obj->each_mapper(); Function: Returns a list of mappers. Example : Returns : list of mappers Args : none =cut sub each_mapper{ my ($self) = @_; return @{$self->{'_mappers'}}; } =head2 mapper_count Title : mapper_count Usage : my $count = $collection->mapper_count; Function: Get the count of the number of mappers stored in this collection Example : Returns : integer Args : none =cut sub mapper_count{ my $self = shift; return scalar @{$self->{'_mappers'} || []}; } =head2 swap Title : swap Usage : $obj->swap; Function: Swap the direction of mapping;input <-> output Example : Returns : 1 Args : =cut sub swap { my ($self) = @_; use Data::Dumper; $self->sort unless $self->_is_sorted; map {$_->swap;} @{$self->{'_mappers'}}; ($self->{'_in_ids'}, $self->{'_out_ids'}) = ($self->{'_out_ids'}, $self->{'_in_ids'}); 1; } =head2 test Title : test Usage : $obj->test; Function: test that both components of all pairs are of the same length. Ran automatically. Example : Returns : boolean Args : =cut sub test { my ($self) = @_; my $res = 1; foreach my $mapper ($self->each_mapper) { $self->warn("Coodinates in pair [". $mapper . ":" . $mapper->in->seq_id . "/". $mapper->out->seq_id . "] are not right.") && ($res = 0) unless $mapper->test; } $res; } =head2 map Title : map Usage : $newpos = $obj->map($pos); Function: Map the location from the input coordinate system to a new value in the output coordinate system. Example : Returns : new value in the output coordinate system Args : integer =cut sub map { my ($self,$value) = @_; $self->throw("Need to pass me a value.") unless defined $value; $self->throw("I need a Bio::Location, not [$value]") unless $value->isa('Bio::LocationI'); $self->throw("No coordinate mappers!") unless $self->each_mapper; $self->sort unless $self->_is_sorted; if ($value->isa("Bio::Location::SplitLocationI")) { my $result = new Bio::Coordinate::Result; foreach my $loc ( $value->sub_Location(1) ) { my $res = $self->_map($loc); map { $result->add_sub_Location($_) } $res->each_Location; } return $result; } else { return $self->_map($value); } } =head2 _map Title : _map Usage : $newpos = $obj->_map($simpleloc); Function: Internal method that does the actual mapping. Called multiple times by map() if the location to be mapped is a split location Example : Returns : new location in the output coordinate system or undef Args : Bio::Location::Simple =cut sub _map { my ($self,$value) = @_; my $result = Bio::Coordinate::Result->new(-is_remote=>1); IDMATCH: { # bail out now we if are forcing the use of an ID # and it is not in this collection last IDMATCH if defined $value->seq_id && ! $self->{'_in_ids'}->{$value->seq_id}; foreach my $pair ($self->each_mapper) { # if we are limiting input to a certain ID next if defined $value->seq_id && $value->seq_id ne $pair->in->seq_id; # if we haven't even reached the start, move on next if $pair->in->end < $value->start; # if we have over run, break last if $pair->in->start > $value->end; my $subres = $pair->map($value); $result->add_result($subres); } } $result->seq_id($result->match->seq_id) if $result->match; unless ($result->each_Location) { #build one gap; my $gap = Bio::Location::Simple->new(-start => $value->start, -end => $value->end, -strand => $value->strand, -location_type => $value->location_type ); $gap->seq_id($value->seq_id) if defined $value->seq_id; bless $gap, 'Bio::Coordinate::Result::Gap'; $result->seq_id($value->seq_id) if defined $value->seq_id; $result->add_sub_Location($gap); } return $result; } =head2 sort Title : sort Usage : $obj->sort; Function: Sort function so that all mappings are sorted by input coordinate start Example : Returns : 1 Args : =cut sub sort{ my ($self) = @_; @{$self->{'_mappers'}} = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, $_->in->start] } @{$self->{'_mappers'}}; #create hashes for sequence ids $self->{'_in_ids'} = (); $self->{'_out_ids'} = (); foreach ($self->each_mapper) { $self->{'_in_ids'}->{$_->in->seq_id} = 1; $self->{'_out_ids'}->{$_->out->seq_id} = 1; } $self->_is_sorted(1); } =head2 _is_sorted Title : _is_sorted Usage : $newpos = $obj->_is_sorted; Function: toggle for whether the (internal) coodinate mapper data are sorted Example : Returns : boolean Args : boolean =cut sub _is_sorted{ my ($self,$value) = @_; $self->{'_is_sorted'} = 1 if defined $value && $value; return $self->{'_is_sorted'}; } 1;
23.393868
78
0.621938
ed6fd2f8fc1045cda036e4c8b01f835e0e987732
217
pm
Perl
auto-lib/Azure/Logic/ListBySubscriptionIntegrationAccountsResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/Logic/ListBySubscriptionIntegrationAccountsResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
null
null
null
auto-lib/Azure/Logic/ListBySubscriptionIntegrationAccountsResult.pm
pplu/azure-sdk-perl
26cbef2d926f571bc1617c26338c106856f95568
[ "Apache-2.0" ]
1
2021-04-08T15:26:39.000Z
2021-04-08T15:26:39.000Z
package Azure::Logic::ListBySubscriptionIntegrationAccountsResult; use Moose; has nextLink => (is => 'ro', isa => 'Str' ); has value => (is => 'ro', isa => 'ArrayRef[Azure::Logic::IntegrationAccount]' ); 1;
27.125
83
0.64977
ed26c5437f68a3fd16dcb1eecec7f03bd1bd7356
5,276
t
Perl
perl/src/t/op/sprintf2.t
nokibsarkar/sl4a
d3c17dca978cbeee545e12ea240a9dbf2a6999e9
[ "Apache-2.0" ]
2,293
2015-01-02T12:46:10.000Z
2022-03-29T09:45:43.000Z
perl/src/t/op/sprintf2.t
nokibsarkar/sl4a
d3c17dca978cbeee545e12ea240a9dbf2a6999e9
[ "Apache-2.0" ]
315
2015-05-31T11:55:46.000Z
2022-01-12T08:36:37.000Z
perl/src/t/op/sprintf2.t
nokibsarkar/sl4a
d3c17dca978cbeee545e12ea240a9dbf2a6999e9
[ "Apache-2.0" ]
1,033
2015-01-04T07:48:40.000Z
2022-03-24T09:34:37.000Z
#!./perl -w BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; } plan tests => 1368; use strict; use Config; is( sprintf("%.40g ",0.01), sprintf("%.40g", 0.01)." ", q(the sprintf "%.<number>g" optimization) ); is( sprintf("%.40f ",0.01), sprintf("%.40f", 0.01)." ", q(the sprintf "%.<number>f" optimization) ); # cases of $i > 1 are against [perl #39126] for my $i (1, 5, 10, 20, 50, 100) { chop(my $utf8_format = "%-*s\x{100}"); my $string = "\xB4"x$i; # latin1 ACUTE or ebcdic COPYRIGHT my $expect = $string." "x$i; # followed by 2*$i spaces is(sprintf($utf8_format, 3*$i, $string), $expect, "width calculation under utf8 upgrade, length=$i"); } # check simultaneous width & precision with wide characters for my $i (1, 3, 5, 10) { my $string = "\x{0410}"x($i+10); # cyrillic capital A my $expect = "\x{0410}"x$i; # cut down to exactly $i characters my $format = "%$i.${i}s"; is(sprintf($format, $string), $expect, "width & precision interplay with utf8 strings, length=$i"); } # Used to mangle PL_sv_undef fresh_perl_is( 'print sprintf "xxx%n\n"; print undef', 'Modification of a read-only value attempted at - line 1.', { switches => [ '-w' ] }, q(%n should not be able to modify read-only constants), ); # check overflows for (int(~0/2+1), ~0, "9999999999999999999") { is(eval {sprintf "%${_}d", 0}, undef, "no sprintf result expected %${_}d"); like($@, qr/^Integer overflow in format string for sprintf /, "overflow in sprintf"); is(eval {printf "%${_}d\n", 0}, undef, "no printf result expected %${_}d"); like($@, qr/^Integer overflow in format string for prtf /, "overflow in printf"); } # check %NNN$ for range bounds { my ($warn, $bad) = (0,0); local $SIG{__WARN__} = sub { if ($_[0] =~ /uninitialized/) { $warn++ } else { $bad++ } }; my $fmt = join('', map("%$_\$s%" . ((1 << 31)-$_) . '$s', 1..20)); my $result = sprintf $fmt, qw(a b c d); is($result, "abcd", "only four valid values in $fmt"); is($warn, 36, "expected warnings"); is($bad, 0, "unexpected warnings"); } { foreach my $ord (0 .. 255) { my $bad = 0; local $SIG{__WARN__} = sub { if ($_[0] !~ /^Invalid conversion in sprintf/) { warn $_[0]; $bad++; } }; my $r = eval {sprintf '%v' . chr $ord}; is ($bad, 0, "pattern '%v' . chr $ord"); } } sub mysprintf_int_flags { my ($fmt, $num) = @_; die "wrong format $fmt" if $fmt !~ /^%([-+ 0]+)([1-9][0-9]*)d\z/; my $flag = $1; my $width = $2; my $sign = $num < 0 ? '-' : $flag =~ /\+/ ? '+' : $flag =~ /\ / ? ' ' : ''; my $abs = abs($num); my $padlen = $width - length($sign.$abs); return $flag =~ /0/ && $flag !~ /-/ # do zero padding ? $sign . '0' x $padlen . $abs : $flag =~ /-/ # left or right ? $sign . $abs . ' ' x $padlen : ' ' x $padlen . $sign . $abs; } # Whole tests for "%4d" with 2 to 4 flags; # total counts: 3 * (4**2 + 4**3 + 4**4) == 1008 my @flags = ("-", "+", " ", "0"); for my $num (0, -1, 1) { for my $f1 (@flags) { for my $f2 (@flags) { for my $f3 ('', @flags) { # '' for doubled flags my $flag = $f1.$f2.$f3; my $width = 4; my $fmt = '%'."${flag}${width}d"; my $result = sprintf($fmt, $num); my $expect = mysprintf_int_flags($fmt, $num); is($result, $expect, qq/sprintf("$fmt",$num)/); next if $f3 eq ''; for my $f4 (@flags) { # quadrupled flags my $flag = $f1.$f2.$f3.$f4; my $fmt = '%'."${flag}${width}d"; my $result = sprintf($fmt, $num); my $expect = mysprintf_int_flags($fmt, $num); is($result, $expect, qq/sprintf("$fmt",$num)/); } } } } } # test that %f doesn't panic with +Inf, -Inf, NaN [perl #45383] foreach my $n (2**1e100, -2**1e100, 2**1e100/2**1e100) { # +Inf, -Inf, NaN eval { my $f = sprintf("%f", $n); }; is $@, "", "sprintf(\"%f\", $n)"; } # test %ll formats with and without HAS_QUAD eval { my $q = pack "q", 0 }; my $Q = $@ eq ''; my @tests = ( [ '%lld' => [qw( 4294967296 -100000000000000 )] ], [ '%lli' => [qw( 4294967296 -100000000000000 )] ], [ '%llu' => [qw( 4294967296 100000000000000 )] ], [ '%Ld' => [qw( 4294967296 -100000000000000 )] ], [ '%Li' => [qw( 4294967296 -100000000000000 )] ], [ '%Lu' => [qw( 4294967296 100000000000000 )] ], ); for my $t (@tests) { my($fmt, $nums) = @$t; for my $num (@$nums) { my $w; local $SIG{__WARN__} = sub { $w = shift }; is(sprintf($fmt, $num), $Q ? $num : $fmt, "quad: $fmt -> $num"); like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$fmt"/, "warning: $fmt"); } } # Check unicode vs byte length for my $width (1,2,3,4,5,6,7) { for my $precis (1,2,3,4,5,6,7) { my $v = "\x{20ac}\x{20ac}"; my $format = "%" . $width . "." . $precis . "s"; my $chars = ($precis > 2 ? 2 : $precis); my $space = ($width < 2 ? 0 : $width - $chars); fresh_perl_is( 'my $v = "\x{20ac}\x{20ac}"; my $x = sprintf "'.$format.'", $v; $x =~ /^(\s*)(\S*)$/; print "$_" for map {length} $1, $2', "$space$chars", {}, q(sprintf ").$format.q(", "\x{20ac}\x{20ac}"), ); } }
28.830601
134
0.510235
ed273cedce9c4b25a776adc1391337d37473a85b
34,330
t
Perl
t/integration/transaction.t
braintree/braintree_perl
55d1ee47b239500210eac712311d44642b0240a6
[ "MIT" ]
12
2015-01-22T04:47:07.000Z
2019-05-24T19:35:14.000Z
t/integration/transaction.t
braintree/braintree_perl
55d1ee47b239500210eac712311d44642b0240a6
[ "MIT" ]
14
2015-03-04T01:36:19.000Z
2018-01-14T02:54:35.000Z
t/integration/transaction.t
braintree/braintree_perl
55d1ee47b239500210eac712311d44642b0240a6
[ "MIT" ]
15
2015-01-22T04:47:16.000Z
2020-11-27T11:06:14.000Z
use lib qw(lib t/lib); use Test::More; use Net::Braintree; use Net::Braintree::TestHelper; use Net::Braintree::CreditCardNumbers::CardTypeIndicators; use Net::Braintree::ErrorCodes::Transaction; use Net::Braintree::ErrorCodes::Descriptor; use Net::Braintree::CreditCardDefaults; use Net::Braintree::Nonce; use Net::Braintree::SandboxValues::CreditCardNumber; use Net::Braintree::SandboxValues::TransactionAmount; use Net::Braintree::Test; use Net::Braintree::Transaction::Status; use Net::Braintree::Transaction::PaymentInstrumentType; my $transaction_params = { amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, descriptor => { name => "abc*def", phone => "1234567890", url => "ebay.com" } }; subtest "Successful Transactions" => sub { @examples = ("credit", "sale"); foreach (@examples) { my ($method) = $_; my $result = Net::Braintree::Transaction->$method($transaction_params); ok $result->is_success; is($result->message, "", "$method result has errors: " . $result->message); is($result->transaction->credit_card->last_4, "1111"); is($result->transaction->voice_referral_number, undef); is($result->transaction->descriptor->name, "abc*def"); is($result->transaction->descriptor->phone, "1234567890"); is($result->transaction->descriptor->url, "ebay.com"); } }; subtest "descriptor validations" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "5.00", credit_card => { number => "4000111111111511", expiration_date => "05/16" }, descriptor => { name => "abcdef", phone => "12345678", url => "12345678901234" } }); not_ok $result->is_success; is($result->errors->for("transaction")->for("descriptor")->on("name")->[0]->code, Net::Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid); is($result->errors->for("transaction")->for("descriptor")->on("phone")->[0]->code, Net::Braintree::ErrorCodes::Descriptor::PhoneFormatIsInvalid); is($result->errors->for("transaction")->for("descriptor")->on("url")->[0]->code, Net::Braintree::ErrorCodes::Descriptor::UrlFormatIsInvalid); }; subtest "Fraud rejections" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "5.00", credit_card => { number => "4000111111111511", expiration_date => "05/16" } }); not_ok $result->is_success; is($result->message, "Gateway Rejected: fraud"); is($result->transaction->gateway_rejection_reason, "fraud"); }; subtest "Processor declined rejection" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "2001.00", credit_card => { number => "4111111111111111", expiration_date => "05/16" } }); not_ok $result->is_success; is($result->message, "Insufficient Funds"); is($result->transaction->processor_response_code, "2001"); is($result->transaction->processor_response_text, "Insufficient Funds"); is($result->transaction->additional_processor_response, "2001 : Insufficient Funds"); }; subtest "Custom Fields" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, custom_fields => { store_me => "please!" } }); ok $result->is_success; is $result->transaction->custom_fields->store_me, "please!", "stores custom field value"; }; subtest "billing_address_id" => sub { my $customer_result = Net::Braintree::Customer->create(); my $address_result = Net::Braintree::Address->create({ customer_id => $customer_result->customer->id, first_name => 'Jenna', }); my $result = Net::Braintree::Transaction->sale({ amount => "50.00", customer_id => $customer_result->customer->id, billing_address_id => $address_result->address->id, credit_card => { number => "5431111111111111", expiration_date => "05/12" }, }); ok $result->is_success; is $result->transaction->billing_details->first_name, "Jenna"; }; subtest "with payment method nonce" => sub { subtest "it can create a transaction" => sub { my $nonce = Net::Braintree::TestHelper::get_nonce_for_new_card("4111111111111111", ''); my $result = Net::Braintree::Transaction->sale({ amount => "50.00", payment_method_nonce => $nonce }); ok $result->is_success; is($result->transaction->credit_card_details->bin, "411111"); }; }; subtest "apple pay" => sub { subtest "it can create a transaction with a fake apple pay nonce" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", payment_method_nonce => Net::Braintree::Nonce::apple_pay_visa }); ok $result->is_success; my $apple_pay_detail = $result->transaction->apple_pay; is($apple_pay_detail->card_type, Net::Braintree::ApplePayCard::CardType::Visa); ok $apple_pay_detail->expiration_month + 0 > 0; ok $apple_pay_detail->expiration_year + 0 > 0; isnt($apple_pay_detail->cardholder_name, undef); }; }; subtest "three_d_secure" => sub { subtest "can create a transaction with a three_d_secure_token" => sub { my $merchant_account_id = Net::Braintree::TestHelper::three_d_secure_merchant_account_id; my $three_d_secure_token = Net::Braintree::TestHelper::create_3ds_verification( $merchant_account_id, { number => "4111111111111111", expiration_month => "05", expiration_year => "2009", }); my $result = Net::Braintree::Transaction->sale({ amount => "100.00", credit_card => { number => "4111111111111111", expiration_date => "05/09", }, merchant_account_id => $merchant_account_id, three_d_secure_token => $three_d_secure_token }); ok $result->is_success; }; subtest "returns an error if three_d_secure_token is not a real one" => sub { my $merchant_account_id = Net::Braintree::TestHelper::three_d_secure_merchant_account_id; my $result = Net::Braintree::Transaction->sale({ amount => "100.00", credit_card => { number => "4111111111111111", expiration_date => "05/09", }, merchant_account_id => $merchant_account_id, three_d_secure_token => "nonexistent_three_d_secure_token" }); not_ok $result->is_success; my $expected_error_code = Net::Braintree::ErrorCodes::Transaction::ThreeDSecureTokenIsInvalid; is($result->errors->for("transaction")->on("three_d_secure_token")->[0]->code, $expected_error_code); }; subtest "returns an error if 3ds lookup data does not match transaction" => sub { my $merchant_account_id = Net::Braintree::TestHelper::three_d_secure_merchant_account_id; my $three_d_secure_token = Net::Braintree::TestHelper::create_3ds_verification( $merchant_account_id, { number => "4111111111111111", expiration_month => "05", expiration_year => "2009", }); my $result = Net::Braintree::Transaction->sale({ amount => "100.00", credit_card => { number => "4111111111111111", expiration_date => "05/20", }, merchant_account_id => $merchant_account_id, three_d_secure_token => $three_d_secure_token }); not_ok $result->is_success; my $expected_error_code = Net::Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionDataDoesntMatchVerify; is($result->errors->for("transaction")->on("three_d_secure_token")->[0]->code, $expected_error_code); }; }; subtest "Service Fee" => sub { subtest "can create a transaction" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_sub_merchant_account", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00" }); ok $result->is_success; is($result->transaction->service_fee_amount, "10.00"); }; subtest "master merchant account does not support service fee" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_credit_card", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00" }); not_ok $result->is_success; my $expected_error_code = Net::Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount; is($result->errors->for("transaction")->on("service_fee_amount")->[0]->code, $expected_error_code); }; subtest "sub merchant account requires service fee" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_sub_merchant_account", credit_card => { number => "5431111111111111", expiration_date => "05/12" } }); not_ok $result->is_success; my $expected_error_code = Net::Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount; is($result->errors->for("transaction")->on("merchant_account_id")->[0]->code, $expected_error_code); }; subtest "not allowed on credits" => sub { my $result = Net::Braintree::Transaction->credit({ amount => "50.00", merchant_account_id => "sandbox_sub_merchant_account", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00" }); not_ok $result->is_success; my $expected_error_code = Net::Braintree::ErrorCodes::Transaction::ServiceFeeIsNotAllowedOnCredits; is($result->errors->for("transaction")->on("base")->[0]->code, $expected_error_code); }; }; subtest "create with hold in escrow" => sub { subtest "can successfully create new transcation with hold in escrow option" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_sub_merchant_account", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00", options => { hold_in_escrow => 'true' } }); ok $result->is_success; is($result->transaction->escrow_status, Net::Braintree::Transaction::EscrowStatus::HoldPending); }; subtest "fails to create new transaction with hold in escrow if merchant account is not submerchant" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_credit_card", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00", options => { hold_in_escrow => 'true' } }); not_ok $result->is_success; is($result->errors->for("transaction")->on("base")->[0]->code, Net::Braintree::ErrorCodes::Transaction::CannotHoldInEscrow ); } }; subtest "Hold for escrow" => sub { subtest "can hold a submerchant's authorized transaction for escrow" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_sub_merchant_account", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, service_fee_amount => "10.00" }); my $hold_result = Net::Braintree::Transaction->hold_in_escrow($result->transaction->id); ok $hold_result->is_success; is($hold_result->transaction->escrow_status, Net::Braintree::Transaction::EscrowStatus::HoldPending); }; subtest "fails with an error when holding non submerchant account transactions for error" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_credit_card", credit_card => { number => "5431111111111111", expiration_date => "05/12" } }); my $hold_result = Net::Braintree::Transaction->hold_in_escrow($result->transaction->id); not_ok $hold_result->is_success; is($hold_result->errors->for("transaction")->on("base")->[0]->code, Net::Braintree::ErrorCodes::Transaction::CannotHoldInEscrow ); }; }; subtest "Submit For Release" => sub { subtest "can submit a escrowed transaction for release" => sub { my $response = create_escrowed_transaction(); my $result = Net::Braintree::Transaction->release_from_escrow($response->transaction->id); ok $result->is_success; is($result->transaction->escrow_status, Net::Braintree::Transaction::EscrowStatus::ReleasePending ); }; subtest "cannot submit non-escrowed transaction for release" => sub { my $sale = Net::Braintree::Transaction->sale({ amount => "50.00", merchant_account_id => "sandbox_credit_card", credit_card => { number => "5431111111111111", expiration_date => "05/12" } }); my $result = Net::Braintree::Transaction->release_from_escrow($sale->transaction->id); not_ok $result->is_success; is($result->errors->for("transaction")->on("base")->[0]->code, Net::Braintree::ErrorCodes::Transaction::CannotReleaseFromEscrow ); }; }; subtest "Cancel Release" => sub { subtest "can cancel release for a transaction which has been submitted" => sub { my $escrow = create_escrowed_transaction(); my $submit = Net::Braintree::Transaction->release_from_escrow($escrow->transaction->id); my $result = Net::Braintree::Transaction->cancel_release($submit->transaction->id); ok $result->is_success; is($result->transaction->escrow_status, Net::Braintree::Transaction::EscrowStatus::Held); }; subtest "cannot cancel release of already released transactions" => sub { my $escrowed = create_escrowed_transaction(); my $result = Net::Braintree::Transaction->cancel_release($escrowed->transaction->id); not_ok $result->is_success; is($result->errors->for("transaction")->on("base")->[0]->code, Net::Braintree::ErrorCodes::Transaction::CannotCancelRelease ); }; }; subtest "Security parameters" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", device_session_id => "abc123", fraud_merchant_id => "456", credit_card => { number => "5431111111111111", expiration_date => "05/12" }, }); ok $result->is_success; }; subtest "Sale" => sub { subtest "returns payment instrument type" => sub { my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, credit_card => { number => Net::Braintree::SandboxValues::CreditCardNumber::VISA, expiration_date => "05/2009" } }); ok $result->is_success; my $transaction = $result->transaction; ok($transaction->payment_instrument_type eq Net::Braintree::Transaction::PaymentInstrumentType::CREDIT_CARD); }; subtest "returns payment instrument type for paypal" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce }); ok $result->is_success; my $transaction = $result->transaction; ok($transaction->payment_instrument_type eq Net::Braintree::Transaction::PaymentInstrumentType::PAYPAL_ACCOUNT); }; subtest "returns debug ID for paypal" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce }); ok $result->is_success; my $transaction = $result->transaction; isnt($transaction->paypal_details->debug_id, undef); }; }; subtest "Disbursement Details" => sub { subtest "disbursement_details for disbursed transactions" => sub { my $result = Net::Braintree::Transaction->find("deposittransaction"); is $result->transaction->is_disbursed, 1; my $disbursement_details = $result->transaction->disbursement_details; is $disbursement_details->funds_held, 0; is $disbursement_details->disbursement_date, "2013-04-10T00:00:00Z"; is $disbursement_details->success, 1; is $disbursement_details->settlement_amount, "100.00"; is $disbursement_details->settlement_currency_iso_code, "USD"; is $disbursement_details->settlement_currency_exchange_rate, "1"; }; subtest "is_disbursed false for non-disbursed transactions" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", } }); is $result->transaction->is_disbursed, 0; }; }; subtest "Disputes" => sub { subtest "exposes disputes for disputed transactions" => sub { my $result = Net::Braintree::Transaction->find("disputedtransaction"); ok $result->is_success; my $disputes = $result->transaction->disputes; my $dispute = shift(@$disputes); is $dispute->amount, '250.00'; is $dispute->received_date, "2014-03-01T00:00:00Z"; is $dispute->reply_by_date, "2014-03-21T00:00:00Z"; is $dispute->reason, Net::Braintree::Dispute::Reason::Fraud; is $dispute->status, Net::Braintree::Dispute::Status::Won; is $dispute->currency_iso_code, "USD"; is $dispute->transaction_details->id, "disputedtransaction"; is $dispute->transaction_details->amount, "1000.00"; }; }; subtest "Submit for Settlement" => sub { subtest "submit the full amount for settlement" => sub { my $sale = Net::Braintree::Transaction->sale($transaction_params); my $result = Net::Braintree::Transaction->submit_for_settlement($sale->transaction->id); ok $result->is_success; is($result->transaction->amount, "50.00", "settlement amount"); is($result->transaction->status, "submitted_for_settlement", "transaction submitted for settlement"); }; subtest "submit a lesser amount for settlement" => sub { my $sale = Net::Braintree::Transaction->sale($transaction_params); my $result = Net::Braintree::Transaction->submit_for_settlement($sale->transaction->id, "10.00"); ok $result->is_success; is($result->transaction->amount, "10.00", "settlement amount"); is($result->transaction->status, "submitted_for_settlement", "transaction submitted for settlement"); }; subtest "can't submit a greater amount for settlement" => sub { my $sale = Net::Braintree::Transaction->sale($transaction_params); my $result = Net::Braintree::Transaction->submit_for_settlement($sale->transaction->id, "100.00"); not_ok $result->is_success; is($result->message, "Settlement amount is too large."); }; }; subtest "Refund" => sub { subtest "successful w/ partial refund amount" => sub { my $settled = create_settled_transaction($transaction_params); my $result = Net::Braintree::Transaction->refund($settled->transaction->id, "20.00"); ok $result->is_success; is($result->transaction->type, 'credit', 'Refund result type is credit'); is($result->transaction->amount, "20.00", "refund amount responds correctly"); }; subtest "unsuccessful if transaction has not been settled" => sub { my $sale = Net::Braintree::Transaction->sale($transaction_params); my $result = Net::Braintree::Transaction->refund($sale->transaction->id); not_ok $result->is_success; is($result->message, "Cannot refund a transaction unless it is settled.", "Errors on unsettled transaction"); }; }; subtest "Void" => sub { subtest "successful" => sub { my $sale = Net::Braintree::Transaction->sale($transaction_params); my $void = Net::Braintree::Transaction->void($sale->transaction->id); ok $void->is_success; is($void->transaction->id, $sale->transaction->id, "Void tied to sale"); }; subtest "unsuccessful" => sub { my $settled = create_settled_transaction($transaction_params); my $void = Net::Braintree::Transaction->void($settled->transaction->id); not_ok $void->is_success; is($void->message, "Transaction can only be voided if status is authorized or submitted_for_settlement."); }; }; subtest "Find" => sub { subtest "successful" => sub { my $sale_result = Net::Braintree::Transaction->sale($transaction_params); $find_result = Net::Braintree::Transaction->find($sale_result->transaction->id); is $find_result->transaction->id, $sale_result->transaction->id, "should find existing transaction"; is $find_result->transaction->amount, "50.00", "should find correct amount"; }; subtest "unsuccessful" => sub { should_throw("NotFoundError", sub { Net::Braintree::Transaction->find('foo') }, "Not Foound"); }; }; subtest "Options" => sub { subtest "submit for settlement" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", }, options => { submit_for_settlement => 'true'} }); is $result->transaction->status, "submitted_for_settlement", "should have correct status"; }; subtest "store_in_vault" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", }, customer => {first_name => "Dan", last_name => "Smith"}, billing => { street_address => "123 45 6" }, shipping => { street_address => "789 10 11" }, options => { store_in_vault => 'true', add_billing_address_to_payment_method => 'true', store_shipping_address_in_vault => 'true' } }); my $customer_result = Net::Braintree::Customer->find($result->transaction->customer->id); like $result->transaction->credit_card->token, qr/[\d\w]{4,}/, "it sets the token"; }; }; subtest "Create from payment method token" => sub { my $sale_result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", }, customer => {first_name => "Dan", last_name => "Smith"}, options => { store_in_vault => 'true' } }); my $create_from_token = Net::Braintree::Transaction->sale({customer_id => $sale_result->transaction->customer->id, payment_method_token => $sale_result->transaction->credit_card->token, amount => "10.00"}); ok $create_from_token->is_success; is $create_from_token->transaction->customer->id, $sale_result->transaction->customer->id, "ties sale to existing customer"; is $create_from_token->transaction->credit_card->token, $sale_result->transaction->credit_card->token, "ties sale to existing customer card"; }; subtest "Clone transaction" => sub { my $sale_result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", }, customer => {first_name => "Dan"}, billing => {first_name => "Jim"}, shipping => {first_name => "John"} }); my $clone_result = Net::Braintree::Transaction->clone_transaction($sale_result->transaction->id, { amount => "123.45", channel => "MyShoppingCartProvider", options => { submit_for_settlement => "false" } }); ok $clone_result->is_success; my $clone_transaction = $clone_result->transaction; isnt $clone_transaction->id, $sale_result->transaction->id; is $clone_transaction->amount, "123.45"; is $clone_transaction->channel, "MyShoppingCartProvider"; is $clone_transaction->credit_card->bin, "543111"; is $clone_transaction->credit_card->expiration_year, "2012"; is $clone_transaction->credit_card->expiration_month, "05"; is $clone_transaction->customer->first_name, "Dan"; is $clone_transaction->billing->first_name, "Jim"; is $clone_transaction->shipping->first_name, "John"; is $clone_transaction->status, "authorized"; }; subtest "Clone transaction and submit for settlement" => sub { my $sale_result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12" } }); my $clone_result = Net::Braintree::Transaction->clone_transaction($sale_result->transaction->id, { amount => "123.45", options => { submit_for_settlement => "true" } }); ok $clone_result->is_success; my $clone_transaction = $clone_result->transaction; is $clone_transaction->status, "submitted_for_settlement"; }; subtest "Clone transaction with validation error" => sub { my $credit_result = Net::Braintree::Transaction->credit({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "05/12", } }); my $clone_result = Net::Braintree::Transaction->clone_transaction($credit_result->transaction->id, {amount => "123.45"}); my $expected_error_code = 91543; not_ok $clone_result->is_success; is($clone_result->errors->for("transaction")->on("base")->[0]->code, $expected_error_code); }; subtest "Recurring" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", recurring => "true", credit_card => { number => "5431111111111111", expiration_date => "05/12" } }); ok $result->is_success; is($result->transaction->recurring, 1); }; subtest "Card Type Indicators" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => Net::Braintree::CreditCardNumbers::CardTypeIndicators::Unknown, expiration_date => "05/12", } }); ok $result->is_success; is($result->transaction->credit_card->prepaid, Net::Braintree::CreditCard::Prepaid::Unknown); is($result->transaction->credit_card->commercial, Net::Braintree::CreditCard::Commercial::Unknown); is($result->transaction->credit_card->debit, Net::Braintree::CreditCard::Debit::Unknown); is($result->transaction->credit_card->payroll, Net::Braintree::CreditCard::Payroll::Unknown); is($result->transaction->credit_card->healthcare, Net::Braintree::CreditCard::Healthcare::Unknown); is($result->transaction->credit_card->durbin_regulated, Net::Braintree::CreditCard::DurbinRegulated::Unknown); is($result->transaction->credit_card->issuing_bank, Net::Braintree::CreditCard::IssuingBank::Unknown); is($result->transaction->credit_card->country_of_issuance, Net::Braintree::CreditCard::CountryOfIssuance::Unknown); }; subtest "Venmo Sdk Payment Method Code" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", venmo_sdk_payment_method_code => Net::Braintree::Test::VenmoSdk::VisaPaymentMethodCode }); ok $result->is_success; is($result->transaction->credit_card->bin, "411111"); is($result->transaction->credit_card->last_4, "1111"); }; subtest "Venmo Sdk Session" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "50.00", credit_card => { number => "5431111111111111", expiration_date => "08/2012" }, options => { venmo_sdk_session => Net::Braintree::Test::VenmoSdk::Session } }); ok $result->is_success; ok $result->transaction->credit_card->venmo_sdk; }; subtest "paypal" => sub { subtest "create a transaction with a one-time paypal nonce" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => "10.00", payment_method_nonce => $nonce }); ok $result->is_success; isnt($result->transaction->paypal_details, undef); isnt($result->transaction->paypal_details->payer_email, undef); isnt($result->transaction->paypal_details->payment_id, undef); isnt($result->transaction->paypal_details->authorization_id, undef); isnt($result->transaction->paypal_details->image_url, undef); isnt($result->transaction->paypal_details->debug_id, undef); }; subtest "create a transaction with a payee email" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => "10.00", payment_method_nonce => $nonce, paypal_account => { payee_email => "payee\@example.com" } }); ok $result->is_success; isnt($result->transaction->paypal_details, undef); isnt($result->transaction->paypal_details->payer_email, undef); isnt($result->transaction->paypal_details->payment_id, undef); isnt($result->transaction->paypal_details->authorization_id, undef); isnt($result->transaction->paypal_details->image_url, undef); isnt($result->transaction->paypal_details->debug_id, undef); is($result->transaction->paypal_details->payee_email, "payee\@example.com"); }; subtest "create a transaction with a payee email in the options params" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => "10.00", payment_method_nonce => $nonce, paypal_account => { }, options => { payee_email => "payee\@example.com", } }); ok $result->is_success; isnt($result->transaction->paypal_details, undef); isnt($result->transaction->paypal_details->payer_email, undef); isnt($result->transaction->paypal_details->payment_id, undef); isnt($result->transaction->paypal_details->authorization_id, undef); isnt($result->transaction->paypal_details->image_url, undef); isnt($result->transaction->paypal_details->debug_id, undef); is($result->transaction->paypal_details->payee_email, "payee\@example.com"); }; subtest "create a transaction with a one-time paypal nonce and vault" => sub { my $nonce = Net::Braintree::TestHelper::generate_one_time_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce, options => { store_in_vault => "true" } }); ok $result->is_success; my $transaction = $result->transaction; isnt($transaction->paypal_details, undef); isnt($transaction->paypal_details->payer_email, undef); isnt($transaction->paypal_details->payment_id, undef); isnt($transaction->paypal_details->authorization_id, undef); is($transaction->paypal_details->token, undef); isnt($transaction->paypal_details->debug_id, undef); }; subtest "create a transaction with a future payment paypal nonce and vault" => sub { my $nonce = Net::Braintree::TestHelper::generate_future_payment_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce, options => { store_in_vault => "true" } }); ok $result->is_success; my $transaction = $result->transaction; isnt($transaction->paypal_details, undef); isnt($transaction->paypal_details->payer_email, undef); isnt($transaction->paypal_details->payment_id, undef); isnt($transaction->paypal_details->authorization_id, undef); isnt($transaction->paypal_details->token, undef); isnt($transaction->paypal_details->debug_id, undef); }; subtest "void paypal transaction" => sub { my $nonce = Net::Braintree::TestHelper::generate_future_payment_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce, }); ok $result->is_success; my $void_result = Net::Braintree::Transaction->void($result->transaction->id); ok $void_result->is_success; }; subtest "submit paypal transaction for settlement" => sub { my $nonce = Net::Braintree::TestHelper::generate_future_payment_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce, }); ok $result->is_success; my $settlement_result = Net::Braintree::Transaction->submit_for_settlement($result->transaction->id); ok $settlement_result->is_success; ok $settlement_result->transaction->status eq Net::Braintree::Transaction::Status::Settling }; subtest "refund a paypal transaction" => sub { my $nonce = Net::Braintree::TestHelper::generate_future_payment_paypal_nonce(''); isnt($nonce, undef); my $result = Net::Braintree::Transaction->sale({ amount => Net::Braintree::SandboxValues::TransactionAmount::AUTHORIZE, payment_method_nonce => $nonce, options => { submit_for_settlement => "true" } }); ok $result->is_success; my $id = $result->transaction->id; my $refund_result = Net::Braintree::Transaction->refund($id); ok $refund_result->is_success; }; subtest "paypal transaction returns settlement response code" => sub { my $result = Net::Braintree::Transaction->sale({ amount => "10.00", payment_method_nonce => Net::Braintree::Nonce::paypal_future_payment, options => { submit_for_settlement => "true" } }); ok $result->is_success; Net::Braintree::TestHelper::settlement_decline($result->transaction->id); $result = Net::Braintree::Transaction->find($result->transaction->id); my $transaction = $result->transaction; is($transaction->status, Net::Braintree::Transaction::Status::SettlementDeclined); is($transaction->processor_settlement_response_code, "4001"); is($transaction->processor_settlement_response_text, "Settlement Declined"); }; }; done_testing();
36.795284
208
0.666706
ed48399c2132b662d47368d6c82ae17dc3db4bd7
220,207
pl
Perl
db/db.pl
touilleio/arkime
5f1ed2c168ee379bbdedcd252e2845867d18130f
[ "Apache-2.0" ]
1
2021-09-25T06:29:49.000Z
2021-09-25T06:29:49.000Z
db/db.pl
touilleio/arkime
5f1ed2c168ee379bbdedcd252e2845867d18130f
[ "Apache-2.0" ]
1
2022-02-28T01:36:10.000Z
2022-02-28T01:36:10.000Z
db/db.pl
touilleio/arkime
5f1ed2c168ee379bbdedcd252e2845867d18130f
[ "Apache-2.0" ]
2
2021-09-08T10:43:33.000Z
2022-02-28T00:35:43.000Z
#!/usr/bin/perl # This script can initialize, upgrade or provide simple maintenance for the # Arkime elastic search db # # Schema Versions # 0 - Before this script existed # 1 - First version of script; turned on strict schema; added lpms, fpms; added # many missing items that were dynamically created by mistake # 2 - Added email items # 3 - Added email md5 # 4 - Added email host and ip; added help, usersimport, usersexport, wipe commands # 5 - No schema change, new rotate command, encoding of file pos is different. # Negative is file num, positive is file pos # 6 - Multi fields for spi view, added xffcnt, 0.90 fixes, need to type INIT/UPGRADE # instead of YES # 7 - files_v3 # 8 - fileSize, memory to stats/dstats and -v flag # 9 - http body hash, rawus # 10 - dynamic fields for http and email headers # 11 - Require 0.90.1, switch from soft to node, new fpd field, removed fpms field # 12 - Added hsver, hdver fields, diskQueue, user settings, scrub* fields, user removeEnabled # 13 - Rename rotate to expire, added smb, socks, rir fields # 14 - New http fields, user.views # 15 - New first byte fields, socks user # 16 - New dynamic plugin section # 17 - email hasheader, db,pa,by src and dst # 18 - fields db # 19 - users_v3 # 20 - queries # 21 - doc_values, new tls fields, starttime/stoptime/view # 22 - cpu to stats/dstats # 23 - packet lengths # 24 - field category # 25 - cert hash # 26 - dynamic stats, ES 2.0 # 27 - table states # 28 - timestamp, firstPacket, lastPacket, ipSrc, ipDst, portSrc, portSrc # 29 - stats/dstats uses dynamic_templates # 30 - change file to dynamic # 31 - Require ES >= 2.4, dstats_v2, stats_v1 # 32 - Require ES >= 2.4 or ES >= 5.1.2, tags_v3, queries_v1, fields_v1, users_v4, files_v4, sequence_v1 # 33 - user columnConfigs # 34 - stats_v2 # 35 - user spiviewFieldConfigs # 36 - user action history # 37 - add request body to history # 50 - Moloch 1.0 # 51 - Upgrade for ES 6.x: sequence_v2, fields_v2, queries_v2, files_v5, users_v5, dstats_v3, stats_v3 # 52 - Hunt (packet search) # 53 - add forcedExpression to history # 54 - users_v6 # 55 - user hideStats, hideFiles, hidePcap, and disablePcapDownload # 56 - notifiers # 57 - hunt notifiers # 58 - users message count and last used date # 59 - tokens # 60 - users time query limit # 61 - shortcuts # 62 - hunt error timestamp and node # 63 - Upgrade for ES 7.x: sequence_v3, fields_v3, queries_v3, files_v6, users_v7, dstats_v4, stats_v4, hunts_v2 # 64 - lock shortcuts # 65 - hunt unrunnable and failedSessionIds # 66 - share hunts # 67 - remove hunt info from matched sessions # 68 - cron query enhancements # 70 - reindex everything, ecs, sessions3 use HTTP::Request::Common; use LWP::UserAgent; use JSON; use Data::Dumper; use POSIX; use IO::Compress::Gzip qw(gzip $GzipError); use IO::Uncompress::Gunzip qw(gunzip $GunzipError); use strict; my $VERSION = 70; my $verbose = 0; my $PREFIX = undef; my $OLDPREFIX = ""; my $SECURE = 1; my $CLIENTCERT = ""; my $CLIENTKEY = ""; my $NOCHANGES = 0; my $SHARDS = -1; my $REPLICAS = -1; my $HISTORY = 13; my $SEGMENTS = 1; my $SEGMENTSMIN = -1; my $NOOPTIMIZE = 0; my $FULL = 0; my $REVERSE = 0; my $SHARDSPERNODE = 1; my $ESTIMEOUT=60; my $UPGRADEALLSESSIONS = 1; my $DOHOTWARM = 0; my $DOILM = 0; my $WARMAFTER = -1; my $WARMKIND = "daily"; my $OPTIMIZEWARM = 0; my $TYPE = "string"; my $SHARED = 0; my $DESCRIPTION = ""; my $LOCKED = 0; my $GZ = 0; my $REFRESH = 60; my $ESAPIKEY = ""; #use LWP::ConsoleLogger::Everywhere (); ################################################################################ sub MIN ($$) { $_[$_[0] > $_[1]] } sub MAX ($$) { $_[$_[0] < $_[1]] } sub commify { scalar reverse join ',', unpack '(A3)*', scalar reverse shift } ################################################################################ sub logmsg { local $| = 1; print (scalar localtime() . " ") if ($verbose > 0); print ("@_"); } ################################################################################ sub showHelp($) { my ($str) = @_; print "\n", $str,"\n\n"; print "$0 [Global Options] <ESHOST:ESPORT> <command> [<command arguments>]\n"; print "\n"; print "Global Options:\n"; print " -v - Verbose, multiple increases level\n"; print " --prefix <prefix> - Prefix for table names\n"; print " --clientkey <keypath> - Path to key for client authentication. Must not have a passphrase.\n"; print " --clientcert <certpath> - Path to cert for client authentication\n"; print " --insecure - Disable certificate verification for https calls\n"; print " -n - Make no db changes\n"; print " --timeout <timeout> - Timeout in seconds for ES, default 60\n"; print " --esapikey <key> - Same key as elasticsearchAPIKey in your Arkime config file\n"; print "\n"; print "General Commands:\n"; print " info - Information about the database\n"; print " init [<opts>] - Clear ALL elasticsearch Arkime data and create schema\n"; print " --shards <shards> - Number of shards for sessions, default number of nodes\n"; print " --replicas <num> - Number of replicas for sessions, default 0\n"; print " --refresh <num> - Number of seconds for ES refresh interval for sessions indices, default 60\n"; print " --shardsPerNode <shards> - Number of shards per node or use \"null\" to let ES decide, default shards*replicas/nodes\n"; print " --hotwarm - Set 'hot' for 'node.attr.molochtype' on new indices, warm on non sessions indices\n"; print " --ilm - Use ilm to manage\n"; print " wipe - Same as init, but leaves user database untouched\n"; print " upgrade [<opts>] - Upgrade Arkime's schema in elasticsearch from previous versions\n"; print " --shards <shards> - Number of shards for sessions, default number of nodes\n"; print " --replicas <num> - Number of replicas for sessions, default 0\n"; print " --refresh <num> - Number of seconds for ES refresh interval for sessions indices, default 60\n"; print " --shardsPerNode <shards> - Number of shards per node or use \"null\" to let ES decide, default shards*replicas/nodes\n"; print " --hotwarm - Set 'hot' for 'node.attr.molochtype' on new indices, warm on non sessions indices\n"; print " --ilm - Use ilm to manage\n"; print " expire <type> <num> [<opts>] - Perform daily ES maintenance and optimize all indices in ES\n"; print " type - Same as rotateIndex in ini file = hourly,hourlyN,daily,weekly,monthly\n"; print " num - Number of indexes to keep\n"; print " --replicas <num> - Number of replicas for older sessions indices, default 0\n"; print " --nooptimize - Do not optimize session indexes during this operation\n"; print " --history <num> - Number of weeks of history to keep, default 13\n"; print " --segments <num> - Number of segments to optimize sessions to, default 1\n"; print " --segmentsmin <num> - Only optimize indices with at least <num> segments, default is <segments> \n"; print " --reverse - Optimize from most recent to oldest\n"; print " --shardsPerNode <shards> - Number of shards per node or use \"null\" to let ES decide, default shards*replicas/nodes\n"; print " --warmafter <wafter> - Set molochwarm on indices after <wafter> <type>\n"; print " --optmizewarm - Only optimize warm green indices\n"; print " optimize - Optimize all Arkime indices in ES\n"; print " --segments <num> - Number of segments to optimize sessions to, default 1\n"; print " optimize-admin - Optimize only admin indices in ES, use with ILM\n"; print " disable-users <days> - Disable user accounts that have not been active\n"; print " days - Number of days of inactivity (integer)\n"; print " set-shortcut <name> <userid> <file> [<opts>]\n"; print " name - Name of the shortcut (no special characters except '_')\n"; print " userid - UserId of the user to add the shortcut for\n"; print " file - File that includes a comma or newline separated list of values\n"; print " --type <type> - Type of shortcut = string, ip, number, default is string\n"; print " --shared - Whether the shortcut is shared to all users\n"; print " --description <description>- Description of the shortcut\n"; print " --locked - Whether the shortcut is locked and cannot be modified by the web interface\n"; print " shrink <index> <node> <num> - Shrink a session index\n"; print " index - The session index to shrink\n"; print " node - The node to temporarily use for shrinking\n"; print " num - Number of shards to shrink to\n"; print " --shardsPerNode <shards> - Number of shards per node or use \"null\" to let ES decide, default 1\n"; print " ilm <force> <delete> - Create ILM profile\n"; print " force - Time in hours/days before (moving to warm) and force merge (number followed by h or d)\n"; print " delete - Time in hours/days before deleting index (number followed by h or d)\n"; print " --hotwarm - Set 'hot' for 'node.attr.molochtype' on new indices, warm on non sessions indices\n"; print " --segments <num> - Number of segments to optimize sessions to, default 1\n"; print " --replicas <num> - Number of replicas for older sessions indices, default 0\n"; print " --history <num> - Number of weeks of history to keep, default 13\n"; print " reindex <src> [<dst>] - Reindex ES indices\n"; print " --nopcap - Remove fields having to do with pcap files\n"; print "\n"; print "Backup and Restore Commands:\n"; print " backup <basename> <opts> - Backup everything but sessions/history; filenames created start with <basename>\n"; print " --gz - GZip the files\n"; print " restore <basename> [<opts>] - Restore everything but sessions/history; filenames restored from start with <basename>\n"; print " --skipupgradeall - Do not upgrade Sessions\n"; print " export <index> <basename> - Save a single index into a file, filename starts with <basename>\n"; print " import <filename> - Import single index from <filename>\n"; print " users-export <filename> - Save the users info to <filename>\n"; print " users-import <filename> - Load the users info from <filename>\n"; print "\n"; print "File Commands:\n"; print " mv <old fn> <new fn> - Move a pcap file in the database (doesn't change disk)\n"; print " rm <fn> - Remove a pcap file in the database (doesn't change disk)\n"; print " rm-missing <node> - Remove from db any MISSING files on THIS machine for the named node\n"; print " add-missing <node> <dir> - Add to db any MISSING files on THIS machine for named node and directory\n"; print " sync-files <nodes> <dirs> - Add/Remove in db any MISSING files on THIS machine for named node(s) and directory(s), both comma separated\n"; print "\n"; print "Field Commands:\n"; print " field disable <exp> - Disable a field from being indexed\n"; print " field enable <exp> - Enable a field from being indexed\n"; print "\n"; print "Node Commands:\n"; print " rm-node <node> - Remove from db all data for node (doesn't change disk)\n"; print " add-alias <node> <hostname> - Adds a hidden node that points to hostname\n"; print " hide-node <node> - Hide node in stats display\n"; print " unhide-node <node> - Unhide node in stats display\n"; print "\n"; print "ES maintenance\n"; print " set-replicas <pat> <num> - Set the number of replicas for index pattern\n"; print " set-shards-per-node <pat> <num> - Set the number of shards per node for index pattern\n"; print " set-allocation-enable <mode> - Set the allocation mode (all, primaries, new_primaries, none, null)\n"; print " allocate-empty <node> <index> <shard> - Allocate a empty shard on a node, DATA LOSS!\n"; print " unflood-stage <pat> - Mark index pattern as no longer flooded\n"; exit 1; } ################################################################################ sub waitFor { my ($str, $help) = @_; print "Type \"$str\" to continue - $help?\n"; while (1) { my $answer = <STDIN>; chomp $answer; last if ($answer eq $str); print "You didn't type \"$str\", for some reason you typed \"$answer\"\n"; } } ################################################################################ sub waitForRE { my ($re, $help) = @_; print "$help\n"; while (1) { my $answer = <STDIN>; chomp $answer; return $answer if ($answer =~ $re); print "$help\n"; } } ################################################################################ sub esIndexExists { my ($index) = @_; logmsg "HEAD ${main::elasticsearch}/$index\n" if ($verbose > 2); my $response = $main::userAgent->head("${main::elasticsearch}/$index"); logmsg "HEAD RESULT:", $response->code, "\n" if ($verbose > 3); return $response->code == 200; } ################################################################################ sub esCheckAlias { my ($alias, $index) = @_; my $result = esGet("/_alias/$alias", 1); return (exists $result->{$index} && exists $result->{$index}->{aliases}->{$alias}); } ################################################################################ sub esGet { my ($url, $dontcheck) = @_; logmsg "GET ${main::elasticsearch}$url\n" if ($verbose > 2); my $response = $main::userAgent->get("${main::elasticsearch}$url"); if (($response->code == 500 && $ARGV[1] ne "init" && $ARGV[1] ne "shrink") || ($response->code != 200 && !$dontcheck)) { die "Couldn't GET ${main::elasticsearch}$url the http status code is " . $response->code . " are you sure elasticsearch is running/reachable?"; } my $json = from_json($response->content); logmsg "GET RESULT:", Dumper($json), "\n" if ($verbose > 3); return $json } ################################################################################ sub esPost { my ($url, $content, $dontcheck) = @_; if ($NOCHANGES && $url !~ /_search/) { logmsg "NOCHANGE: POST ${main::elasticsearch}$url\n"; return; } logmsg "POST ${main::elasticsearch}$url\n" if ($verbose > 2); logmsg "POST DATA:", Dumper($content), "\n" if ($verbose > 3); my $response = $main::userAgent->post("${main::elasticsearch}$url", Content => $content, Content_Type => "application/json"); if ($response->code == 500 || ($response->code != 200 && $response->code != 201 && !$dontcheck)) { return from_json("{}") if ($dontcheck == 2); logmsg "POST RESULT:", $response->content, "\n" if ($verbose > 3); die "Couldn't POST ${main::elasticsearch}$url the http status code is " . $response->code . " are you sure elasticsearch is running/reachable?"; } my $json = from_json($response->content); logmsg "POST RESULT:", Dumper($json), "\n" if ($verbose > 3); return $json } ################################################################################ sub esPut { my ($url, $content, $dontcheck) = @_; if ($NOCHANGES) { logmsg "NOCHANGE: PUT ${main::elasticsearch}$url\n"; return; } logmsg "PUT ${main::elasticsearch}$url\n" if ($verbose > 2); logmsg "PUT DATA:", Dumper($content), "\n" if ($verbose > 3); my $response = $main::userAgent->request(HTTP::Request::Common::PUT("${main::elasticsearch}$url", Content => $content, Content_Type => "application/json")); if ($response->code != 200 && !$dontcheck) { logmsg Dumper($response); die "Couldn't PUT ${main::elasticsearch}$url the http status code is " . $response->code . " are you sure elasticsearch is running/reachable?\n" . $response->content; } elsif ($response->code == 500 && $dontcheck) { print "Ignoring following error\n"; logmsg Dumper($response); } my $json = from_json($response->content); logmsg "PUT RESULT:", Dumper($json), "\n" if ($verbose > 3); return $json } ################################################################################ sub esDelete { my ($url, $dontcheck) = @_; if ($NOCHANGES) { logmsg "NOCHANGE: DELETE ${main::elasticsearch}$url\n"; return; } logmsg "DELETE ${main::elasticsearch}$url\n" if ($verbose > 2); my $response = $main::userAgent->request(HTTP::Request::Common::_simple_req("DELETE", "${main::elasticsearch}$url")); if ($response->code == 500 || ($response->code != 200 && !$dontcheck)) { die "Couldn't DELETE ${main::elasticsearch}$url the http status code is " . $response->code . " are you sure elasticsearch is running/reachable?"; } my $json = from_json($response->content); return $json } ################################################################################ sub esCopy { my ($srci, $dsti) = @_; $main::userAgent->timeout(7200); my $status = esGet("/_stats/docs", 1); logmsg "Copying " . $status->{indices}->{$srci}->{primaries}->{docs}->{count} . " elements from $srci to $dsti\n"; esPost("/_reindex?timeout=7200s", to_json({"source" => {"index" => $srci}, "dest" => {"index" => $dsti, "version_type" => "external"}, "conflicts" => "proceed"})); my $status = esGet("/${dsti}/_refresh", 1); my $status = esGet("/_stats/docs", 1); if ($status->{indices}->{$srci}->{primaries}->{docs}->{count} > $status->{indices}->{$dsti}->{primaries}->{docs}->{count}) { logmsg $status->{indices}->{$srci}->{primaries}->{docs}->{count}, " > ", $status->{indices}->{$dsti}->{primaries}->{docs}->{count}, "\n"; die "\nERROR - Copy failed from $srci to $dsti, you will probably need to delete $dsti and run upgrade again. Make sure to not change the index while upgrading.\n\n"; } logmsg "\n"; $main::userAgent->timeout($ESTIMEOUT + 5); } ################################################################################ sub esScroll { my ($index, $type, $query) = @_; my @hits = (); my $id = ""; while (1) { if ($verbose > 0) { local $| = 1; print "."; } my $url; if ($id eq "") { if ($type eq "") { $url = "/${PREFIX}$index/_search?scroll=10m&size=500"; } else { $url = "/${PREFIX}$index/$type/_search?scroll=10m&size=500"; } } else { $url = "/_search/scroll?scroll=10m&scroll_id=$id"; $query = ""; } my $incoming = esPost($url, $query, 1); die Dumper($incoming) if ($incoming->{status} == 404); last if (@{$incoming->{hits}->{hits}} == 0); push(@hits, @{$incoming->{hits}->{hits}}); $id = $incoming->{_scroll_id}; } return \@hits; } ################################################################################ sub esAlias { my ($cmd, $index, $alias, $dontaddprefix) = @_; logmsg "Alias cmd $cmd from $index to alias $alias\n" if ($verbose > 0); if (!$dontaddprefix){ # append PREFIX esPost("/_aliases?master_timeout=${ESTIMEOUT}s", '{ "actions": [ { "' . $cmd . '": { "index": "' . $PREFIX . $index . '", "alias" : "'. $PREFIX . $alias .'" } } ] }', 1); } else { # do not append PREFIX esPost("/_aliases?master_timeout=${ESTIMEOUT}s", '{ "actions": [ { "' . $cmd . '": { "index": "' . $index . '", "alias" : "'. $alias .'" } } ] }', 1); } } ################################################################################ sub esWaitForNoTask { my ($str) = @_; while (1) { logmsg "GET ${main::elasticsearch}/_cat/tasks\n" if ($verbose > 1); my $response = $main::userAgent->get("${main::elasticsearch}/_cat/tasks"); if ($response->code != 200) { sleep(30); } return 1 if (index ($response->content, $str) == -1); sleep 20; } } ################################################################################ sub esForceMerge { my ($index, $segments, $dowait) = @_; esWaitForNoTask("forcemerge") if ($dowait); esPost("/$index/_forcemerge?max_num_segments=$segments", "", 2); esWaitForNoTask("forcemerge") if ($dowait); } ################################################################################ sub sequenceCreate { my $settings = ' { "settings": { "index.priority": 100, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating sequence_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}sequence_v30?master_timeout=${ESTIMEOUT}s", $settings, 1); esAlias("add", "sequence_v30", "sequence"); sequenceUpdate(); } ################################################################################ sub sequenceUpdate { my $mapping = ' { "_source" : { "enabled": "false" }, "enabled" : "false" }'; logmsg "Setting sequence_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}sequence_v30/_mapping?master_timeout=${ESTIMEOUT}s", $mapping); } ################################################################################ sub sequenceUpgrade { if (esCheckAlias("${PREFIX}sequence", "${PREFIX}sequence_v30") && esIndexExists("${PREFIX}sequence_v30")) { logmsg ("SKIPPING - ${PREFIX}sequence already points to ${PREFIX}sequence_v30\n"); return; } $main::userAgent->timeout(7200); sequenceCreate(); esAlias("remove", "sequence_v3", "sequence"); my $results = esGet("/${OLDPREFIX}sequence_v3/_search?version=true&size=10000&rest_total_hits_as_int=true", 0); logmsg "Copying " . $results->{hits}->{total} . " elements from ${OLDPREFIX}sequence_v3 to ${PREFIX}sequence_v30\n"; return if ($results->{hits}->{total} == 0); foreach my $hit (@{$results->{hits}->{hits}}) { if ($hit->{_id} =~ /^fn-/) { esPost("/${PREFIX}sequence_v30/_doc/$hit->{_id}?timeout=${ESTIMEOUT}s&version_type=external&version=$hit->{_version}", "{}", 1); } } esDelete("/${OLDPREFIX}sequence_v3"); $main::userAgent->timeout($ESTIMEOUT + 5); } ################################################################################ sub filesCreate { my $settings = ' { "settings": { "index.priority": 80, "number_of_shards": 2, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating files_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}files_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "files_v30", "files"); filesUpdate(); } ################################################################################ sub filesUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "true", "dynamic_templates": [ { "any": { "match": "*", "mapping": { "index": false } } } ], "properties": { "num": { "type": "long" }, "node": { "type": "keyword" }, "first": { "type": "long" }, "name": { "type": "keyword" }, "filesize": { "type": "long" }, "locked": { "type": "short" }, "last": { "type": "long" } } }'; logmsg "Setting files_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}files_v30/_mapping?master_timeout=${ESTIMEOUT}s", $mapping); } ################################################################################ sub statsCreate { my $settings = ' { "settings": { "index.priority": 70, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating stats index\n" if ($verbose > 0); esPut("/${PREFIX}stats_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "stats_v30", "stats"); statsUpdate(); } ################################################################################ sub statsUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "true", "dynamic_templates": [ { "numeric": { "match_mapping_type": "long", "mapping": { "type": "long" } } } ], "properties": { "hostname": { "type": "keyword" }, "nodeName": { "type": "keyword" }, "currentTime": { "type": "date", "format": "epoch_second" } } }'; logmsg "Setting stats mapping\n" if ($verbose > 0); esPut("/${PREFIX}stats_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping, 1); } ################################################################################ sub dstatsCreate { my $settings = ' { "settings": { "index.priority": 50, "number_of_shards": 2, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating dstats_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}dstats_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "dstats_v30", "dstats"); dstatsUpdate(); } ################################################################################ sub dstatsUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "true", "dynamic_templates": [ { "numeric": { "match_mapping_type": "long", "mapping": { "type": "long", "index": false } } }, { "noindex": { "match": "*", "mapping": { "index": false } } } ], "properties": { "nodeName": { "type": "keyword" }, "interval": { "type": "short" }, "currentTime": { "type": "date", "format": "epoch_second" } } }'; logmsg "Setting dstats_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}dstats_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping, 1); } ################################################################################ sub fieldsCreate { my $settings = ' { "settings": { "index.priority": 90, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating fields index\n" if ($verbose > 0); esPut("/${PREFIX}fields_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "fields_v30", "fields"); fieldsUpdate(); ecsFieldsUpdate(); } ################################################################################ sub newField { my ($field, $json) = @_; esPost("/${PREFIX}fields_v30/_doc/$field?timeout=${ESTIMEOUT}s", $json); } ################################################################################ sub fieldsUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic_templates": [ { "string_template": { "match_mapping_type": "string", "mapping": { "type": "keyword" } } } ] }'; logmsg "Setting fields_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}fields_v30/_mapping?master_timeout=${ESTIMEOUT}s", $mapping); esPost("/${PREFIX}fields_v30/_doc/ip?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All IP fields", "group": "general", "help": "Search all ip fields", "type": "ip", "dbField2": "ipall", "portField": "portall", "noFacet": "true" }'); esPost("/${PREFIX}fields_v30/_doc/port?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All port fields", "group": "general", "help": "Search all port fields", "type": "integer", "dbField2": "portall", "regex": "(^port\\\\.(?:(?!\\\\.cnt$).)*$|\\\\.port$)" }'); esPost("/${PREFIX}fields_v30/_doc/rir?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All rir fields", "group": "general", "help": "Search all rir fields", "type": "uptermfield", "dbField2": "rirall", "regex": "(^rir\\\\.(?:(?!\\\\.cnt$).)*$|\\\\.rir$)" }'); esPost("/${PREFIX}fields_v30/_doc/country?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All country fields", "group": "general", "help": "Search all country fields", "type": "uptermfield", "dbField2": "geoall", "regex": "(^country\\\\.(?:(?!\\\\.cnt$).)*$|\\\\.country$)" }'); esPost("/${PREFIX}fields_v30/_doc/asn?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All ASN fields", "group": "general", "help": "Search all ASN fields", "type": "termfield", "dbField2": "asnall", "regex": "(^asn\\\\.(?:(?!\\\\.cnt$).)*$|\\\\.asn$)" }'); esPost("/${PREFIX}fields_v30/_doc/host?timeout=${ESTIMEOUT}s", '{ "friendlyName": "All Host fields", "group": "general", "help": "Search all Host fields", "type": "lotermfield", "dbField2": "hostall", "regex": "(^host\\\\.(?:(?!\\\\.(cnt|tokens)$).)*$|\\\\.host$)" }'); esPost("/${PREFIX}fields_v30/_doc/ip.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src IP", "group": "general", "help": "Source IP", "type": "ip", "dbField2": "srcIp", "portField": "p1", "portField2": "srcPort", "portFieldECS": "source.port", "category": "ip" }'); esPost("/${PREFIX}fields_v30/_doc/port.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src Port", "group": "general", "help": "Source Port", "type": "integer", "dbField2": "srcPort", "category": "port" }'); esPost("/${PREFIX}fields_v30/_doc/asn.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src ASN", "group": "general", "help": "GeoIP ASN string calculated from the source IP", "type": "termfield", "dbField2": "srcASN", "category": "asn" }'); esPost("/${PREFIX}fields_v30/_doc/asn.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src ASN", "group": "general", "help": "GeoIP ASN string calculated from the source IP", "type": "termfield", "dbField2": "srcASN", "category": "asn" }'); newField("source.as.number", '{ "friendlyName": "Src ASN Number", "group": "general", "help": "GeoIP ASN Number calculated from the source IP", "type": "integer", "fieldECS": "source.as.number" }'); newField("source.as.organization.name", '{ "friendlyName": "Src ASN Name", "group": "general", "help": "GeoIP ASN Name calculated from the source IP", "type": "termfield", "fieldECS": "source.as.organization.name" }'); esPost("/${PREFIX}fields_v30/_doc/country.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src Country", "group": "general", "help": "Source Country", "type": "uptermfield", "dbField2": "srcGEO", "category": "country" }'); esPost("/${PREFIX}fields_v30/_doc/rir.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src RIR", "group": "general", "help": "Source RIR", "type": "uptermfield", "dbField2": "srcRIR", "category": "rir" }'); esPost("/${PREFIX}fields_v30/_doc/ip.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst IP", "group": "general", "help": "Destination IP", "type": "ip", "dbField2": "dstIp", "portField2": "dstPort", "portFieldECS": "destination.port", "category": "ip", "aliases": ["ip.dst:port"] }'); esPost("/${PREFIX}fields_v30/_doc/port.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst Port", "group": "general", "help": "Source Port", "type": "integer", "dbField2": "dstPort", "category": "port" }'); esPost("/${PREFIX}fields_v30/_doc/asn.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst ASN", "group": "general", "help": "GeoIP ASN string calculated from the destination IP", "type": "termfield", "dbField2": "dstASN", "category": "asn" }'); newField("destination.as.number", '{ "friendlyName": "Dst ASN Number", "group": "general", "help": "GeoIP ASN Number calculated from the destination IP", "type": "integer", "fieldECS": "destination.as.number" }'); newField("destination.as.organization.name", '{ "friendlyName": "Dst ASN Name", "group": "general", "help": "GeoIP ASN Name calculated from the destination IP", "type": "termfield", "fieldECS": "destination.as.organization.name" }'); esPost("/${PREFIX}fields_v30/_doc/country.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst Country", "group": "general", "help": "Destination Country", "type": "uptermfield", "dbField2": "dstGEO", "category": "country" }'); esPost("/${PREFIX}fields_v30/_doc/rir.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst RIR", "group": "general", "help": "Destination RIR", "type": "uptermfield", "dbField2": "dstRIR", "category": "rir" }'); esPost("/${PREFIX}fields_v30/_doc/bytes?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Bytes", "group": "general", "help": "Total number of raw bytes sent AND received in a session", "type": "integer", "dbField2": "totBytes" }'); esPost("/${PREFIX}fields_v30/_doc/bytes.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src Bytes", "group": "general", "help": "Total number of raw bytes sent by source in a session", "type": "integer", "dbField2": "srcBytes" }'); esPost("/${PREFIX}fields_v30/_doc/bytes.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst Bytes", "group": "general", "help": "Total number of raw bytes sent by destination in a session", "type": "integer", "dbField2": "dstBytes" }'); esPost("/${PREFIX}fields_v30/_doc/databytes?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Data bytes", "group": "general", "help": "Total number of data bytes sent AND received in a session", "type": "integer", "dbField2": "totDataBytes" }'); esPost("/${PREFIX}fields_v30/_doc/databytes.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src data bytes", "group": "general", "help": "Total number of data bytes sent by source in a session", "type": "integer", "dbField2": "srcDataBytes" }'); esPost("/${PREFIX}fields_v30/_doc/databytes.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst data bytes", "group": "general", "help": "Total number of data bytes sent by destination in a session", "type": "integer", "dbField2": "dstDataBytes" }'); esPost("/${PREFIX}fields_v30/_doc/packets?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Packets", "group": "general", "help": "Total number of packets sent AND received in a session", "type": "integer", "dbField2": "totPackets" }'); esPost("/${PREFIX}fields_v30/_doc/packets.src?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Src Packets", "group": "general", "help": "Total number of packets sent by source in a session", "type": "integer", "dbField2": "srcPackets" }'); esPost("/${PREFIX}fields_v30/_doc/packets.dst?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Dst Packets", "group": "general", "help": "Total number of packets sent by destination in a session", "type": "integer", "dbField2": "dstPackets" }'); esPost("/${PREFIX}fields_v30/_doc/ip.protocol?timeout=${ESTIMEOUT}s", '{ "friendlyName": "IP Protocol", "group": "general", "help": "IP protocol number or friendly name", "type": "lotermfield", "dbField2": "ipProtocol", "transform": "ipProtocolLookup" }'); esPost("/${PREFIX}fields_v30/_doc/id?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Arkime ID", "group": "general", "help": "Arkime ID for the session", "type": "termfield", "dbField2": "_id", "noFacet": "true" }'); esPost("/${PREFIX}fields_v30/_doc/rootId?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Arkime Root ID", "group": "general", "help": "Arkime ID of the first session in a multi session stream", "type": "termfield", "dbField2": "rootId" }'); esPost("/${PREFIX}fields_v30/_doc/node?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Arkime Node", "group": "general", "help": "Arkime node name the session was recorded on", "type": "termfield", "dbField2": "node" }'); esPost("/${PREFIX}fields_v30/_doc/file?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Filename", "group": "general", "help": "Arkime offline pcap filename", "type": "fileand", "dbField2": "fileand" }'); esPost("/${PREFIX}fields_v30/_doc/payload8.src.hex?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload Src Hex", "group": "general", "help": "First 8 bytes of source payload in hex", "type": "lotermfield", "dbField2": "srcPayload8", "aliases": ["payload.src"] }'); esPost("/${PREFIX}fields_v30/_doc/payload8.src.utf8?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload Src UTF8", "group": "general", "help": "First 8 bytes of source payload in utf8", "type": "termfield", "dbField2": "srcPayload8", "transform": "utf8ToHex", "noFacet": "true" }'); esPost("/${PREFIX}fields_v30/_doc/payload8.dst.hex?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload Dst Hex", "group": "general", "help": "First 8 bytes of destination payload in hex", "type": "lotermfield", "dbField2": "dstPayload8", "aliases": ["payload.dst"] }'); esPost("/${PREFIX}fields_v30/_doc/payload8.dst.utf8?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload Dst UTF8", "group": "general", "help": "First 8 bytes of destination payload in utf8", "type": "termfield", "dbField2": "dstPayload8", "transform": "utf8ToHex", "noFacet": "true" }'); esPost("/${PREFIX}fields_v30/_doc/payload8.hex?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload Hex", "group": "general", "help": "First 8 bytes of payload in hex", "type": "lotermfield", "dbField2": "fballhex", "regex": "^payload8.(src|dst).hex$" }'); esPost("/${PREFIX}fields_v30/_doc/payload8.utf8?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Payload UTF8", "group": "general", "help": "First 8 bytes of payload in hex", "type": "lotermfield", "dbField2": "fballutf8", "regex": "^payload8.(src|dst).utf8$" }'); esPost("/${PREFIX}fields_v30/_doc/scrubbed.by?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Scrubbed By", "group": "general", "help": "SPI data was scrubbed by", "type": "lotermfield", "dbField2": "scrubby" }'); esPost("/${PREFIX}fields_v30/_doc/view?timeout=${ESTIMEOUT}s", '{ "friendlyName": "View Name", "group": "general", "help": "Arkime view name", "type": "viewand", "dbField2": "viewand", "noFacet": "true" }'); esPost("/${PREFIX}fields_v30/_doc/starttime?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Start Time", "group": "general", "help": "Session Start Time", "type": "seconds", "type2": "date", "dbField2": "firstPacket" }'); esPost("/${PREFIX}fields_v30/_doc/stoptime?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Stop Time", "group": "general", "help": "Session Stop Time", "type": "seconds", "type2": "date", "dbField2": "lastPacket" }'); esPost("/${PREFIX}fields_v30/_doc/huntId?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Hunt ID", "group": "general", "help": "The ID of the packet search job that matched this session", "type": "termfield", "dbField2": "huntId" }'); esPost("/${PREFIX}fields_v30/_doc/huntName?timeout=${ESTIMEOUT}s", '{ "friendlyName": "Hunt Name", "group": "general", "help": "The name of the packet search job that matched this session", "type": "termfield", "dbField2": "huntName" }'); } ################################################################################ sub queriesCreate { my $settings = ' { "settings": { "index.priority": 40, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating queries index\n" if ($verbose > 0); esPut("/${PREFIX}queries_v30?master_timeout=${ESTIMEOUT}s", $settings); queriesUpdate(); } ################################################################################ sub queriesUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "strict", "properties": { "name": { "type": "keyword" }, "enabled": { "type": "boolean" }, "lpValue": { "type": "long" }, "lastRun": { "type": "date" }, "count": { "type": "long" }, "lastCount": { "type": "long" }, "query": { "type": "keyword" }, "action": { "type": "keyword" }, "creator": { "type": "keyword" }, "tags": { "type": "keyword" }, "notifier": { "type": "keyword" }, "lastNotified": { "type": "date" }, "lastNotifiedCount": { "type": "long" }, "description": { "type": "keyword" }, "created": { "type": "date" }, "lastToggled": { "type": "date" }, "lastToggledBy": { "type": "keyword" } } }'; logmsg "Setting queries mapping\n" if ($verbose > 0); esPut("/${PREFIX}queries_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping); esAlias("add", "queries_v30", "queries"); } ################################################################################ my %ECSMAP; my %ECSPROP; sub addECSMap { my ($exp, $db, $fieldECS) = @_; $ECSMAP{$exp}->{fieldECS} = $fieldECS if ($exp ne 'null'); $ECSPROP{$fieldECS}->{path} = $db; $ECSPROP{$fieldECS}->{type} = "alias"; } addECSMap("country.dst", "dstGEO", "destination.geo.country_iso_code"); addECSMap("asn.dst", "dstASN", "destination.as.full"); addECSMap("bytes.dst", "dstBytes", "destination.bytes"); addECSMap("databytes.dst", "dstDataBytes", "server.bytes"); addECSMap("packets.dst", "dstPackets", "destination.packets"); addECSMap("ip.dst", "dstIp", "destination.ip"); addECSMap("port.dst", "dstPort", "destination.port"); addECSMap("mac.dst", "dstMac", "destination.mac"); addECSMap("null", "dstMacCnt", "destination.mac-cnt"); addECSMap("country.src", "srcGEO", "source.geo.country_iso_code"); addECSMap("asn.src", "srcASN", "source.as.full"); addECSMap("bytes.src", "srcBytes", "source.bytes"); addECSMap("databytes.src", "srcDataBytes", "client.bytes"); addECSMap("packets.src", "srcPackets", "source.packets"); addECSMap("ip.src", "srcIp", "source.ip"); addECSMap("port.src", "srcPort", "source.port"); addECSMap("mac.src", "srcMac", "source.mac"); addECSMap("null", "srcMacCnt", "source.mac-cnt"); addECSMap("communityId", "communityId", "network.community_id"); addECSMap("bytes", "totBytes", "network.bytes"); addECSMap("packets", "totPackets", "network.packets"); addECSMap("vlan", "vlan", "network.vlan.id"); addECSMap('null', "vlanCnt", "network.vlan.id-cnt"); addECSMap('null', "timestamp", "\@timestamp"); ################################################################################ sub ecsFieldsUpdate { foreach my $key (keys (%ECSMAP)) { esPost("/${PREFIX}fields/_update/$key", qq({"doc":{"fieldECS": "$ECSMAP{$key}->{fieldECS}"}}), 1); } #print '{"properties":' . to_json(\%ECSPROP) . "}\n"; esPut("/${OLDPREFIX}sessions2-*/_mapping", '{"properties":' . to_json(\%ECSPROP) . "}", 1); } ################################################################################ sub sessions3ECSTemplate { # Modfified version of https://raw.githubusercontent.com/elastic/ecs/1.10/generated/elasticsearch/7/template.json # 1) change index_patterns # 2) Delete cloud,dns,http,tls,user,data_stream # 3) Add source.as.full, destination.as.full, source.mac-cnt, destination.mac-cnt, network.vlan.id-cnt my $template = ' { "index_patterns": "' . $PREFIX . 'sessions3-*", "mappings": { "_meta": { "version": "1.10.0" }, "date_detection": false, "dynamic_templates": [ { "strings_as_keyword": { "mapping": { "ignore_above": 1024, "type": "keyword" }, "match_mapping_type": "string" } } ], "properties": { "@timestamp": { "type": "date" }, "agent": { "properties": { "build": { "properties": { "original": { "ignore_above": 1024, "type": "keyword" } } }, "ephemeral_id": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "client": { "properties": { "address": { "ignore_above": 1024, "type": "keyword" }, "as": { "properties": { "number": { "type": "long" }, "organization": { "properties": { "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } } } }, "bytes": { "type": "long" }, "domain": { "ignore_above": 1024, "type": "keyword" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "nat": { "properties": { "ip": { "type": "ip" }, "port": { "type": "long" } } }, "packets": { "type": "long" }, "port": { "type": "long" }, "registered_domain": { "ignore_above": 1024, "type": "keyword" }, "subdomain": { "ignore_above": 1024, "type": "keyword" }, "top_level_domain": { "ignore_above": 1024, "type": "keyword" }, "user": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "email": { "ignore_above": 1024, "type": "keyword" }, "full_name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "roles": { "ignore_above": 1024, "type": "keyword" } } } } }, "container": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "image": { "properties": { "name": { "ignore_above": 1024, "type": "keyword" }, "tag": { "ignore_above": 1024, "type": "keyword" } } }, "labels": { "type": "object" }, "name": { "ignore_above": 1024, "type": "keyword" }, "runtime": { "ignore_above": 1024, "type": "keyword" } } }, "destination": { "properties": { "address": { "ignore_above": 1024, "type": "keyword" }, "as": { "properties": { "full" : { "type" : "keyword" }, "number": { "type": "long" }, "organization": { "properties": { "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } } } }, "bytes": { "type": "long" }, "domain": { "ignore_above": 1024, "type": "keyword" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "mac-cnt" : { "type" : "long" }, "nat": { "properties": { "ip": { "type": "ip" }, "port": { "type": "long" } } }, "packets": { "type": "long" }, "port": { "type": "long" }, "registered_domain": { "ignore_above": 1024, "type": "keyword" }, "subdomain": { "ignore_above": 1024, "type": "keyword" }, "top_level_domain": { "ignore_above": 1024, "type": "keyword" }, "user": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "email": { "ignore_above": 1024, "type": "keyword" }, "full_name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "roles": { "ignore_above": 1024, "type": "keyword" } } } } }, "dll": { "properties": { "code_signature": { "properties": { "exists": { "type": "boolean" }, "signing_id": { "ignore_above": 1024, "type": "keyword" }, "status": { "ignore_above": 1024, "type": "keyword" }, "subject_name": { "ignore_above": 1024, "type": "keyword" }, "team_id": { "ignore_above": 1024, "type": "keyword" }, "trusted": { "type": "boolean" }, "valid": { "type": "boolean" } } }, "hash": { "properties": { "md5": { "ignore_above": 1024, "type": "keyword" }, "sha1": { "ignore_above": 1024, "type": "keyword" }, "sha256": { "ignore_above": 1024, "type": "keyword" }, "sha512": { "ignore_above": 1024, "type": "keyword" }, "ssdeep": { "ignore_above": 1024, "type": "keyword" } } }, "name": { "ignore_above": 1024, "type": "keyword" }, "path": { "ignore_above": 1024, "type": "keyword" }, "pe": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "company": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "file_version": { "ignore_above": 1024, "type": "keyword" }, "imphash": { "ignore_above": 1024, "type": "keyword" }, "original_file_name": { "ignore_above": 1024, "type": "keyword" }, "product": { "ignore_above": 1024, "type": "keyword" } } } } }, "ecs": { "properties": { "version": { "ignore_above": 1024, "type": "keyword" } } }, "error": { "properties": { "code": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "message": { "norms": false, "type": "text" }, "stack_trace": { "doc_values": false, "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "index": false, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" } } }, "event": { "properties": { "action": { "ignore_above": 1024, "type": "keyword" }, "category": { "ignore_above": 1024, "type": "keyword" }, "code": { "ignore_above": 1024, "type": "keyword" }, "created": { "type": "date" }, "dataset": { "ignore_above": 1024, "type": "keyword" }, "duration": { "type": "long" }, "end": { "type": "date" }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "ingested": { "type": "date" }, "kind": { "ignore_above": 1024, "type": "keyword" }, "module": { "ignore_above": 1024, "type": "keyword" }, "original": { "doc_values": false, "ignore_above": 1024, "index": false, "type": "keyword" }, "outcome": { "ignore_above": 1024, "type": "keyword" }, "provider": { "ignore_above": 1024, "type": "keyword" }, "reason": { "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" }, "risk_score": { "type": "float" }, "risk_score_norm": { "type": "float" }, "sequence": { "type": "long" }, "severity": { "type": "long" }, "start": { "type": "date" }, "timezone": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "url": { "ignore_above": 1024, "type": "keyword" } } }, "file": { "properties": { "accessed": { "type": "date" }, "attributes": { "ignore_above": 1024, "type": "keyword" }, "code_signature": { "properties": { "exists": { "type": "boolean" }, "signing_id": { "ignore_above": 1024, "type": "keyword" }, "status": { "ignore_above": 1024, "type": "keyword" }, "subject_name": { "ignore_above": 1024, "type": "keyword" }, "team_id": { "ignore_above": 1024, "type": "keyword" }, "trusted": { "type": "boolean" }, "valid": { "type": "boolean" } } }, "created": { "type": "date" }, "ctime": { "type": "date" }, "device": { "ignore_above": 1024, "type": "keyword" }, "directory": { "ignore_above": 1024, "type": "keyword" }, "drive_letter": { "ignore_above": 1, "type": "keyword" }, "extension": { "ignore_above": 1024, "type": "keyword" }, "gid": { "ignore_above": 1024, "type": "keyword" }, "group": { "ignore_above": 1024, "type": "keyword" }, "hash": { "properties": { "md5": { "ignore_above": 1024, "type": "keyword" }, "sha1": { "ignore_above": 1024, "type": "keyword" }, "sha256": { "ignore_above": 1024, "type": "keyword" }, "sha512": { "ignore_above": 1024, "type": "keyword" }, "ssdeep": { "ignore_above": 1024, "type": "keyword" } } }, "inode": { "ignore_above": 1024, "type": "keyword" }, "mime_type": { "ignore_above": 1024, "type": "keyword" }, "mode": { "ignore_above": 1024, "type": "keyword" }, "mtime": { "type": "date" }, "name": { "ignore_above": 1024, "type": "keyword" }, "owner": { "ignore_above": 1024, "type": "keyword" }, "path": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "pe": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "company": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "file_version": { "ignore_above": 1024, "type": "keyword" }, "imphash": { "ignore_above": 1024, "type": "keyword" }, "original_file_name": { "ignore_above": 1024, "type": "keyword" }, "product": { "ignore_above": 1024, "type": "keyword" } } }, "size": { "type": "long" }, "target_path": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "uid": { "ignore_above": 1024, "type": "keyword" }, "x509": { "properties": { "alternative_names": { "ignore_above": 1024, "type": "keyword" }, "issuer": { "properties": { "common_name": { "ignore_above": 1024, "type": "keyword" }, "country": { "ignore_above": 1024, "type": "keyword" }, "distinguished_name": { "ignore_above": 1024, "type": "keyword" }, "locality": { "ignore_above": 1024, "type": "keyword" }, "organization": { "ignore_above": 1024, "type": "keyword" }, "organizational_unit": { "ignore_above": 1024, "type": "keyword" }, "state_or_province": { "ignore_above": 1024, "type": "keyword" } } }, "not_after": { "type": "date" }, "not_before": { "type": "date" }, "public_key_algorithm": { "ignore_above": 1024, "type": "keyword" }, "public_key_curve": { "ignore_above": 1024, "type": "keyword" }, "public_key_exponent": { "doc_values": false, "index": false, "type": "long" }, "public_key_size": { "type": "long" }, "serial_number": { "ignore_above": 1024, "type": "keyword" }, "signature_algorithm": { "ignore_above": 1024, "type": "keyword" }, "subject": { "properties": { "common_name": { "ignore_above": 1024, "type": "keyword" }, "country": { "ignore_above": 1024, "type": "keyword" }, "distinguished_name": { "ignore_above": 1024, "type": "keyword" }, "locality": { "ignore_above": 1024, "type": "keyword" }, "organization": { "ignore_above": 1024, "type": "keyword" }, "organizational_unit": { "ignore_above": 1024, "type": "keyword" }, "state_or_province": { "ignore_above": 1024, "type": "keyword" } } }, "version_number": { "ignore_above": 1024, "type": "keyword" } } } } }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "host": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "cpu": { "properties": { "usage": { "scaling_factor": 1000, "type": "scaled_float" } } }, "disk": { "properties": { "read": { "properties": { "bytes": { "type": "long" } } }, "write": { "properties": { "bytes": { "type": "long" } } } } }, "domain": { "ignore_above": 1024, "type": "keyword" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "hostname": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "network": { "properties": { "egress": { "properties": { "bytes": { "type": "long" }, "packets": { "type": "long" } } }, "ingress": { "properties": { "bytes": { "type": "long" }, "packets": { "type": "long" } } } } }, "os": { "properties": { "family": { "ignore_above": 1024, "type": "keyword" }, "full": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "kernel": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "platform": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "type": { "ignore_above": 1024, "type": "keyword" }, "uptime": { "type": "long" }, "user": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "email": { "ignore_above": 1024, "type": "keyword" }, "full_name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "roles": { "ignore_above": 1024, "type": "keyword" } } } } }, "labels": { "type": "object" }, "log": { "properties": { "file": { "properties": { "path": { "ignore_above": 1024, "type": "keyword" } } }, "level": { "ignore_above": 1024, "type": "keyword" }, "logger": { "ignore_above": 1024, "type": "keyword" }, "origin": { "properties": { "file": { "properties": { "line": { "type": "integer" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "function": { "ignore_above": 1024, "type": "keyword" } } }, "original": { "doc_values": false, "ignore_above": 1024, "index": false, "type": "keyword" }, "syslog": { "properties": { "facility": { "properties": { "code": { "type": "long" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "priority": { "type": "long" }, "severity": { "properties": { "code": { "type": "long" }, "name": { "ignore_above": 1024, "type": "keyword" } } } }, "type": "object" } } }, "message": { "norms": false, "type": "text" }, "network": { "properties": { "application": { "ignore_above": 1024, "type": "keyword" }, "bytes": { "type": "long" }, "community_id": { "ignore_above": 1024, "type": "keyword" }, "direction": { "ignore_above": 1024, "type": "keyword" }, "forwarded_ip": { "type": "ip" }, "iana_number": { "ignore_above": 1024, "type": "keyword" }, "inner": { "properties": { "vlan": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } } }, "type": "object" }, "name": { "ignore_above": 1024, "type": "keyword" }, "packets": { "type": "long" }, "protocol": { "ignore_above": 1024, "type": "keyword" }, "transport": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "vlan": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "id-cnt" : { "type" : "long" }, "name": { "ignore_above": 1024, "type": "keyword" } } } } }, "observer": { "properties": { "egress": { "properties": { "interface": { "properties": { "alias": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "vlan": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "zone": { "ignore_above": 1024, "type": "keyword" } }, "type": "object" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "hostname": { "ignore_above": 1024, "type": "keyword" }, "ingress": { "properties": { "interface": { "properties": { "alias": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "vlan": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "zone": { "ignore_above": 1024, "type": "keyword" } }, "type": "object" }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "os": { "properties": { "family": { "ignore_above": 1024, "type": "keyword" }, "full": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "kernel": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "platform": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "product": { "ignore_above": 1024, "type": "keyword" }, "serial_number": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "vendor": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "orchestrator": { "properties": { "api_version": { "ignore_above": 1024, "type": "keyword" }, "cluster": { "properties": { "name": { "ignore_above": 1024, "type": "keyword" }, "url": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "namespace": { "ignore_above": 1024, "type": "keyword" }, "organization": { "ignore_above": 1024, "type": "keyword" }, "resource": { "properties": { "name": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" } } }, "type": { "ignore_above": 1024, "type": "keyword" } } }, "organization": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } }, "package": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "build_version": { "ignore_above": 1024, "type": "keyword" }, "checksum": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "install_scope": { "ignore_above": 1024, "type": "keyword" }, "installed": { "type": "date" }, "license": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "path": { "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" }, "size": { "type": "long" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "process": { "properties": { "args": { "ignore_above": 1024, "type": "keyword" }, "args_count": { "type": "long" }, "code_signature": { "properties": { "exists": { "type": "boolean" }, "signing_id": { "ignore_above": 1024, "type": "keyword" }, "status": { "ignore_above": 1024, "type": "keyword" }, "subject_name": { "ignore_above": 1024, "type": "keyword" }, "team_id": { "ignore_above": 1024, "type": "keyword" }, "trusted": { "type": "boolean" }, "valid": { "type": "boolean" } } }, "command_line": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "entity_id": { "ignore_above": 1024, "type": "keyword" }, "executable": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "exit_code": { "type": "long" }, "hash": { "properties": { "md5": { "ignore_above": 1024, "type": "keyword" }, "sha1": { "ignore_above": 1024, "type": "keyword" }, "sha256": { "ignore_above": 1024, "type": "keyword" }, "sha512": { "ignore_above": 1024, "type": "keyword" }, "ssdeep": { "ignore_above": 1024, "type": "keyword" } } }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "parent": { "properties": { "args": { "ignore_above": 1024, "type": "keyword" }, "args_count": { "type": "long" }, "code_signature": { "properties": { "exists": { "type": "boolean" }, "signing_id": { "ignore_above": 1024, "type": "keyword" }, "status": { "ignore_above": 1024, "type": "keyword" }, "subject_name": { "ignore_above": 1024, "type": "keyword" }, "team_id": { "ignore_above": 1024, "type": "keyword" }, "trusted": { "type": "boolean" }, "valid": { "type": "boolean" } } }, "command_line": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "entity_id": { "ignore_above": 1024, "type": "keyword" }, "executable": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "exit_code": { "type": "long" }, "hash": { "properties": { "md5": { "ignore_above": 1024, "type": "keyword" }, "sha1": { "ignore_above": 1024, "type": "keyword" }, "sha256": { "ignore_above": 1024, "type": "keyword" }, "sha512": { "ignore_above": 1024, "type": "keyword" }, "ssdeep": { "ignore_above": 1024, "type": "keyword" } } }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "pe": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "company": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "file_version": { "ignore_above": 1024, "type": "keyword" }, "imphash": { "ignore_above": 1024, "type": "keyword" }, "original_file_name": { "ignore_above": 1024, "type": "keyword" }, "product": { "ignore_above": 1024, "type": "keyword" } } }, "pgid": { "type": "long" }, "pid": { "type": "long" }, "ppid": { "type": "long" }, "start": { "type": "date" }, "thread": { "properties": { "id": { "type": "long" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "title": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "uptime": { "type": "long" }, "working_directory": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } }, "pe": { "properties": { "architecture": { "ignore_above": 1024, "type": "keyword" }, "company": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "file_version": { "ignore_above": 1024, "type": "keyword" }, "imphash": { "ignore_above": 1024, "type": "keyword" }, "original_file_name": { "ignore_above": 1024, "type": "keyword" }, "product": { "ignore_above": 1024, "type": "keyword" } } }, "pgid": { "type": "long" }, "pid": { "type": "long" }, "ppid": { "type": "long" }, "start": { "type": "date" }, "thread": { "properties": { "id": { "type": "long" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "title": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "uptime": { "type": "long" }, "working_directory": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } }, "registry": { "properties": { "data": { "properties": { "bytes": { "ignore_above": 1024, "type": "keyword" }, "strings": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" } } }, "hive": { "ignore_above": 1024, "type": "keyword" }, "key": { "ignore_above": 1024, "type": "keyword" }, "path": { "ignore_above": 1024, "type": "keyword" }, "value": { "ignore_above": 1024, "type": "keyword" } } }, "related": { "properties": { "hash": { "ignore_above": 1024, "type": "keyword" }, "hosts": { "ignore_above": 1024, "type": "keyword" }, "ip": { "type": "ip" }, "user": { "ignore_above": 1024, "type": "keyword" } } }, "rule": { "properties": { "author": { "ignore_above": 1024, "type": "keyword" }, "category": { "ignore_above": 1024, "type": "keyword" }, "description": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "license": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" }, "ruleset": { "ignore_above": 1024, "type": "keyword" }, "uuid": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "server": { "properties": { "address": { "ignore_above": 1024, "type": "keyword" }, "as": { "properties": { "number": { "type": "long" }, "organization": { "properties": { "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } } } }, "bytes": { "type": "long" }, "domain": { "ignore_above": 1024, "type": "keyword" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "nat": { "properties": { "ip": { "type": "ip" }, "port": { "type": "long" } } }, "packets": { "type": "long" }, "port": { "type": "long" }, "registered_domain": { "ignore_above": 1024, "type": "keyword" }, "subdomain": { "ignore_above": 1024, "type": "keyword" }, "top_level_domain": { "ignore_above": 1024, "type": "keyword" }, "user": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "email": { "ignore_above": 1024, "type": "keyword" }, "full_name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "roles": { "ignore_above": 1024, "type": "keyword" } } } } }, "service": { "properties": { "ephemeral_id": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "node": { "properties": { "name": { "ignore_above": 1024, "type": "keyword" } } }, "state": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "source": { "properties": { "address": { "ignore_above": 1024, "type": "keyword" }, "as": { "properties": { "full" : { "type" : "keyword" }, "number": { "type": "long" }, "organization": { "properties": { "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" } } } } }, "bytes": { "type": "long" }, "domain": { "ignore_above": 1024, "type": "keyword" }, "geo": { "properties": { "city_name": { "ignore_above": 1024, "type": "keyword" }, "continent_code": { "ignore_above": 1024, "type": "keyword" }, "continent_name": { "ignore_above": 1024, "type": "keyword" }, "country_iso_code": { "ignore_above": 1024, "type": "keyword" }, "country_name": { "ignore_above": 1024, "type": "keyword" }, "location": { "type": "geo_point" }, "name": { "ignore_above": 1024, "type": "keyword" }, "postal_code": { "ignore_above": 1024, "type": "keyword" }, "region_iso_code": { "ignore_above": 1024, "type": "keyword" }, "region_name": { "ignore_above": 1024, "type": "keyword" }, "timezone": { "ignore_above": 1024, "type": "keyword" } } }, "ip": { "type": "ip" }, "mac": { "ignore_above": 1024, "type": "keyword" }, "mac-cnt" : { "type" : "long" }, "nat": { "properties": { "ip": { "type": "ip" }, "port": { "type": "long" } } }, "packets": { "type": "long" }, "port": { "type": "long" }, "registered_domain": { "ignore_above": 1024, "type": "keyword" }, "subdomain": { "ignore_above": 1024, "type": "keyword" }, "top_level_domain": { "ignore_above": 1024, "type": "keyword" }, "user": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "email": { "ignore_above": 1024, "type": "keyword" }, "full_name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "group": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" } } }, "hash": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "roles": { "ignore_above": 1024, "type": "keyword" } } } } }, "span": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" } } }, "tags": { "ignore_above": 1024, "type": "keyword" }, "threat": { "properties": { "framework": { "ignore_above": 1024, "type": "keyword" }, "tactic": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" } } }, "technique": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" }, "subtechnique": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" } } } } } } }, "trace": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" } } }, "transaction": { "properties": { "id": { "ignore_above": 1024, "type": "keyword" } } }, "url": { "properties": { "domain": { "ignore_above": 1024, "type": "keyword" }, "extension": { "ignore_above": 1024, "type": "keyword" }, "fragment": { "ignore_above": 1024, "type": "keyword" }, "full": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "original": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "password": { "ignore_above": 1024, "type": "keyword" }, "path": { "ignore_above": 1024, "type": "keyword" }, "port": { "type": "long" }, "query": { "ignore_above": 1024, "type": "keyword" }, "registered_domain": { "ignore_above": 1024, "type": "keyword" }, "scheme": { "ignore_above": 1024, "type": "keyword" }, "subdomain": { "ignore_above": 1024, "type": "keyword" }, "top_level_domain": { "ignore_above": 1024, "type": "keyword" }, "username": { "ignore_above": 1024, "type": "keyword" } } }, "user_agent": { "properties": { "device": { "properties": { "name": { "ignore_above": 1024, "type": "keyword" } } }, "name": { "ignore_above": 1024, "type": "keyword" }, "original": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "os": { "properties": { "family": { "ignore_above": 1024, "type": "keyword" }, "full": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "kernel": { "ignore_above": 1024, "type": "keyword" }, "name": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "platform": { "ignore_above": 1024, "type": "keyword" }, "type": { "ignore_above": 1024, "type": "keyword" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "vulnerability": { "properties": { "category": { "ignore_above": 1024, "type": "keyword" }, "classification": { "ignore_above": 1024, "type": "keyword" }, "description": { "fields": { "text": { "norms": false, "type": "text" } }, "ignore_above": 1024, "type": "keyword" }, "enumeration": { "ignore_above": 1024, "type": "keyword" }, "id": { "ignore_above": 1024, "type": "keyword" }, "reference": { "ignore_above": 1024, "type": "keyword" }, "report_id": { "ignore_above": 1024, "type": "keyword" }, "scanner": { "properties": { "vendor": { "ignore_above": 1024, "type": "keyword" } } }, "score": { "properties": { "base": { "type": "float" }, "environmental": { "type": "float" }, "temporal": { "type": "float" }, "version": { "ignore_above": 1024, "type": "keyword" } } }, "severity": { "ignore_above": 1024, "type": "keyword" } } } } }, "order": 1, "settings": { "index": { "mapping": { "total_fields": { "limit": 10000 } }, "refresh_interval": "5s" } } } '; logmsg "Creating sessions ecs template\n" if ($verbose > 0); esPut("/_template/${PREFIX}sessions3_ecs_template?master_timeout=${ESTIMEOUT}s&pretty", $template); } ################################################################################ # Create the template sessions use and update mapping of current sessions. # Not all fields need to be here, but the index will be created quicker if more are. sub sessions3Update { my $mapping = ' { "_meta": { "molochDbVersion": ' . $VERSION . ' }, "dynamic": "true", "dynamic_templates": [ { "template_ip_end": { "match": "*Ip", "mapping": { "type": "ip" } } }, { "template_ip_alone": { "match": "ip", "mapping": { "type": "ip" } } }, { "template_word_split": { "match": "*Tokens", "mapping": { "analyzer": "wordSplit", "type": "text", "norms": false } } }, { "template_string": { "match_mapping_type": "string", "mapping": { "type": "keyword" } } } ], "properties" : { "asset" : { "type" : "keyword" }, "assetCnt" : { "type" : "long" }, "bgp" : { "properties" : { "type" : { "type" : "keyword" } } }, "cert" : { "properties" : { "alt" : { "type" : "keyword" }, "altCnt" : { "type" : "long" }, "curve" : { "type" : "keyword" }, "hash" : { "type" : "keyword" }, "issuerCN" : { "type" : "keyword" }, "issuerON" : { "type" : "keyword" }, "notAfter" : { "type" : "date" }, "notBefore" : { "type" : "date" }, "publicAlgorithm" : { "type" : "keyword" }, "remainingDays" : { "type" : "long" }, "serial" : { "type" : "keyword" }, "subjectCN" : { "type" : "keyword" }, "subjectON" : { "type" : "keyword" }, "validDays" : { "type" : "long" } } }, "certCnt" : { "type" : "long" }, "dhcp" : { "properties" : { "host" : { "type" : "keyword", "copy_to" : [ "dhcp.hostTokens" ] }, "hostCnt" : { "type" : "long" }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "id" : { "type" : "keyword" }, "idCnt" : { "type" : "long" }, "mac" : { "type" : "keyword" }, "macCnt" : { "type" : "long" }, "oui" : { "type" : "keyword" }, "ouiCnt" : { "type" : "long" }, "type" : { "type" : "keyword" }, "typeCnt" : { "type" : "long" } } }, "dns" : { "properties" : { "ASN" : { "type" : "keyword" }, "GEO" : { "type" : "keyword" }, "RIR" : { "type" : "keyword" }, "host" : { "type" : "keyword", "copy_to" : [ "dns.hostTokens" ] }, "hostCnt" : { "type" : "long" }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "ip" : { "type" : "ip" }, "ipCnt" : { "type" : "long" }, "opcode" : { "type" : "keyword" }, "opcodeCnt" : { "type" : "long" }, "puny" : { "type" : "keyword" }, "punyCnt" : { "type" : "long" }, "qc" : { "type" : "keyword" }, "qcCnt" : { "type" : "long" }, "qt" : { "type" : "keyword" }, "qtCnt" : { "type" : "long" }, "status" : { "type" : "keyword" }, "statusCnt" : { "type" : "long" } } }, "dstOui" : { "type" : "keyword" }, "dstOuiCnt" : { "type" : "long" }, "dstPayload8" : { "type" : "keyword" }, "dstRIR" : { "type" : "keyword" }, "email" : { "properties" : { "ASN" : { "type" : "keyword" }, "GEO" : { "type" : "keyword" }, "RIR" : { "type" : "keyword" }, "bodyMagic" : { "type" : "keyword" }, "bodyMagicCnt" : { "type" : "long" }, "contentType" : { "type" : "keyword" }, "contentTypeCnt" : { "type" : "long" }, "dst" : { "type" : "keyword" }, "dstCnt" : { "type" : "long" }, "filename" : { "type" : "keyword" }, "filenameCnt" : { "type" : "long" }, "header" : { "type" : "keyword" }, "header-chad" : { "type" : "keyword" }, "header-chadCnt" : { "type" : "long" }, "headerCnt" : { "type" : "long" }, "host" : { "type" : "keyword", "copy_to" : [ "email.hostTokens" ] }, "hostCnt" : { "type" : "long" }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "id" : { "type" : "keyword" }, "idCnt" : { "type" : "long" }, "ip" : { "type" : "ip" }, "ipCnt" : { "type" : "long" }, "md5" : { "type" : "keyword" }, "md5Cnt" : { "type" : "long" }, "mimeVersion" : { "type" : "keyword" }, "mimeVersionCnt" : { "type" : "long" }, "smtpHello" : { "type" : "keyword" }, "smtpHelloCnt" : { "type" : "long" }, "src" : { "type" : "keyword" }, "srcCnt" : { "type" : "long" }, "subject" : { "type" : "keyword" }, "subjectCnt" : { "type" : "long" }, "useragent" : { "type" : "keyword" }, "useragentCnt" : { "type" : "long" } } }, "fileId" : { "type" : "long" }, "firstPacket" : { "type" : "date" }, "greASN" : { "type" : "keyword" }, "greGEO" : { "type" : "keyword" }, "greIp" : { "type" : "ip" }, "greIpCnt" : { "type" : "long" }, "greRIR" : { "type" : "keyword" }, "http" : { "properties" : { "authType" : { "type" : "keyword" }, "authTypeCnt" : { "type" : "long" }, "bodyMagic" : { "type" : "keyword" }, "bodyMagicCnt" : { "type" : "long" }, "clientVersion" : { "type" : "keyword" }, "clientVersionCnt" : { "type" : "long" }, "cookieKey" : { "type" : "keyword" }, "cookieKeyCnt" : { "type" : "long" }, "cookieValue" : { "type" : "keyword" }, "cookieValueCnt" : { "type" : "long" }, "host" : { "type" : "keyword", "copy_to" : [ "http.hostTokens" ] }, "hostCnt" : { "type" : "long" }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "key" : { "type" : "keyword" }, "keyCnt" : { "type" : "long" }, "md5" : { "type" : "keyword" }, "md5Cnt" : { "type" : "long" }, "method" : { "type" : "keyword" }, "methodCnt" : { "type" : "long" }, "path" : { "type" : "keyword" }, "pathCnt" : { "type" : "long" }, "request-authorization" : { "type" : "keyword" }, "request-authorizationCnt" : { "type" : "long" }, "request-chad" : { "type" : "keyword" }, "request-chadCnt" : { "type" : "long" }, "request-content-type" : { "type" : "keyword" }, "request-content-typeCnt" : { "type" : "long" }, "request-origin" : { "type" : "keyword" }, "request-referer" : { "type" : "keyword" }, "request-refererCnt" : { "type" : "long" }, "requestBody" : { "type" : "keyword" }, "requestHeader" : { "type" : "keyword" }, "requestHeaderCnt" : { "type" : "long" }, "response-content-type" : { "type" : "keyword" }, "response-content-typeCnt" : { "type" : "long" }, "response-location" : { "type" : "keyword" }, "response-server" : { "type" : "keyword" }, "responseHeader" : { "type" : "keyword" }, "responseHeaderCnt" : { "type" : "long" }, "serverVersion" : { "type" : "keyword" }, "serverVersionCnt" : { "type" : "long" }, "statuscode" : { "type" : "long" }, "statuscodeCnt" : { "type" : "long" }, "uri" : { "type" : "keyword", "copy_to" : [ "http.uriTokens" ] }, "uriCnt" : { "type" : "long" }, "uriTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "user" : { "type" : "keyword" }, "userCnt" : { "type" : "long" }, "useragent" : { "type" : "keyword", "copy_to" : [ "http.useragentTokens" ] }, "useragentCnt" : { "type" : "long" }, "useragentTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "value" : { "type" : "keyword" }, "valueCnt" : { "type" : "long" }, "xffASN" : { "type" : "keyword" }, "xffGEO" : { "type" : "keyword" }, "xffIp" : { "type" : "ip" }, "xffIpCnt" : { "type" : "long" }, "xffRIR" : { "type" : "keyword" } } }, "icmp" : { "properties" : { "code" : { "type" : "long" }, "type" : { "type" : "long" } } }, "initRTT" : { "type" : "long" }, "ipProtocol" : { "type" : "long" }, "irc" : { "properties" : { "channel" : { "type" : "keyword" }, "channelCnt" : { "type" : "long" }, "nick" : { "type" : "keyword" }, "nickCnt" : { "type" : "long" } } }, "krb5" : { "properties" : { "cname" : { "type" : "keyword" }, "cnameCnt" : { "type" : "long" }, "realm" : { "type" : "keyword" }, "realmCnt" : { "type" : "long" }, "sname" : { "type" : "keyword" }, "snameCnt" : { "type" : "long" } } }, "lastPacket" : { "type" : "date" }, "ldap" : { "properties" : { "authtype" : { "type" : "keyword" }, "authtypeCnt" : { "type" : "long" }, "bindname" : { "type" : "keyword" }, "bindnameCnt" : { "type" : "long" } } }, "length" : { "type" : "long" }, "mysql" : { "properties" : { "user" : { "type" : "keyword" }, "version" : { "type" : "keyword" } } }, "node" : { "type" : "keyword" }, "oracle" : { "properties" : { "host" : { "type" : "keyword", "copy_to" : [ "oracle.hostTokens" ] }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "service" : { "type" : "keyword" }, "user" : { "type" : "keyword" } } }, "packetLen" : { "type" : "integer", "index" : false }, "packetPos" : { "type" : "long", "index" : false }, "postgresql" : { "properties" : { "app" : { "type" : "keyword" }, "db" : { "type" : "keyword" }, "user" : { "type" : "keyword" } } }, "protocol" : { "type" : "keyword" }, "protocolCnt" : { "type" : "long" }, "quic" : { "properties" : { "host" : { "type" : "keyword", "copy_to" : [ "quic.hostTokens" ] }, "hostCnt" : { "type" : "long" }, "hostTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "useragent" : { "type" : "keyword", "copy_to" : [ "quic.useragentTokens" ] }, "useragentCnt" : { "type" : "long" }, "useragentTokens" : { "type" : "text", "norms" : false, "analyzer" : "wordSplit" }, "version" : { "type" : "keyword" }, "versionCnt" : { "type" : "long" } } }, "radius" : { "properties" : { "framedASN" : { "type" : "keyword" }, "framedGEO" : { "type" : "keyword" }, "framedIp" : { "type" : "ip" }, "framedIpCnt" : { "type" : "long" }, "framedRIR" : { "type" : "keyword" }, "mac" : { "type" : "keyword" }, "macCnt" : { "type" : "long" }, "user" : { "type" : "keyword" } } }, "rootId" : { "type" : "keyword" }, "segmentCnt" : { "type" : "long" }, "smb" : { "properties" : { "filename" : { "type" : "keyword" }, "filenameCnt" : { "type" : "long" }, "host" : { "type" : "keyword", "copy_to" : [ "smb.hostTokens" ] } } }, "socks" : { "properties" : { "ASN" : { "type" : "keyword" }, "GEO" : { "type" : "keyword" }, "RIR" : { "type" : "keyword" }, "host" : { "type" : "keyword", "copy_to" : [ "socks.hostTokens" ] }, "ip" : { "type" : "ip" }, "port" : { "type" : "long" }, "user" : { "type" : "keyword" } } }, "srcOui" : { "type" : "keyword" }, "srcOuiCnt" : { "type" : "long" }, "srcPayload8" : { "type" : "keyword" }, "srcRIR" : { "type" : "keyword" }, "ssh" : { "properties" : { "hassh" : { "type" : "keyword" }, "hasshCnt" : { "type" : "long" }, "hasshServer" : { "type" : "keyword" }, "hasshServerCnt" : { "type" : "long" }, "key" : { "type" : "keyword" }, "keyCnt" : { "type" : "long" }, "version" : { "type" : "keyword" }, "versionCnt" : { "type" : "long" } } }, "suricata" : { "properties" : { "action" : { "type" : "keyword" }, "actionCnt" : { "type" : "long" }, "category" : { "type" : "keyword" }, "categoryCnt" : { "type" : "long" }, "flowId" : { "type" : "keyword" }, "flowIdCnt" : { "type" : "long" }, "gid" : { "type" : "long" }, "gidCnt" : { "type" : "long" }, "severity" : { "type" : "long" }, "severityCnt" : { "type" : "long" }, "signature" : { "type" : "keyword" }, "signatureCnt" : { "type" : "long" }, "signatureId" : { "type" : "long" }, "signatureIdCnt" : { "type" : "long" } } }, "tags" : { "type" : "keyword" }, "tagsCnt" : { "type" : "long" }, "tcpflags" : { "properties" : { "ack" : { "type" : "long" }, "dstZero" : { "type" : "long" }, "fin" : { "type" : "long" }, "psh" : { "type" : "long" }, "rst" : { "type" : "long" }, "srcZero" : { "type" : "long" }, "syn" : { "type" : "long" }, "syn-ack" : { "type" : "long" }, "urg" : { "type" : "long" } } }, "tls" : { "properties" : { "cipher" : { "type" : "keyword" }, "cipherCnt" : { "type" : "long" }, "dstSessionId" : { "type" : "keyword" }, "ja3" : { "type" : "keyword" }, "ja3Cnt" : { "type" : "long" }, "ja3s" : { "type" : "keyword" }, "ja3sCnt" : { "type" : "long" }, "srcSessionId" : { "type" : "keyword" }, "version" : { "type" : "keyword" }, "versionCnt" : { "type" : "long" } } }, "totDataBytes" : { "type" : "long" }, "user" : { "type" : "keyword" }, "userCnt" : { "type" : "long" } } } '; $REPLICAS = 0 if ($REPLICAS < 0); my $shardsPerNode = ceil($SHARDS * ($REPLICAS+1) / $main::numberOfNodes); $shardsPerNode = $SHARDSPERNODE if ($SHARDSPERNODE eq "null" || $SHARDSPERNODE > $shardsPerNode); my $settings = ''; if ($DOHOTWARM) { $settings .= ', "routing.allocation.require.molochtype": "hot"'; } if ($DOILM) { $settings .= qq/, "lifecycle.name": "${PREFIX}molochsessions"/; } my $template = ' { "index_patterns": "' . $PREFIX . 'sessions3-*", "settings": { "index": { "routing.allocation.total_shards_per_node": ' . $shardsPerNode . $settings . ', "refresh_interval": "' . $REFRESH . 's", "number_of_shards": ' . $SHARDS . ', "number_of_replicas": ' . $REPLICAS . ', "analysis": { "analyzer": { "wordSplit": { "type": "custom", "tokenizer": "pattern", "filter": ["lowercase"] } } } } }, "mappings":' . $mapping . ', "order": 99 }'; logmsg "Creating sessions template\n" if ($verbose > 0); esPut("/_template/${PREFIX}sessions3_template?master_timeout=${ESTIMEOUT}s&pretty", $template); my $indices = esGet("/${PREFIX}sessions3-*/_alias", 1); if ($UPGRADEALLSESSIONS) { logmsg "Updating sessions3 mapping for ", scalar(keys %{$indices}), " indices\n" if (scalar(keys %{$indices}) != 0); foreach my $i (keys %{$indices}) { progress("$i "); esPut("/$i/_mapping?master_timeout=${ESTIMEOUT}s", $mapping, 1); } logmsg "\n" if (scalar(keys %{$indices}) != 0); } sessions3ECSTemplate(); } ################################################################################ sub historyUpdate { my $mapping = ' { "history": { "_source": {"enabled": "true"}, "dynamic": "strict", "properties": { "uiPage": { "type": "keyword" }, "userId": { "type": "keyword" }, "method": { "type": "keyword" }, "api": { "type": "keyword" }, "expression": { "type": "keyword" }, "view": { "type": "object", "dynamic": "true" }, "timestamp": { "type": "date", "format": "epoch_second" }, "range": { "type": "integer" }, "query": { "type": "keyword" }, "queryTime": { "type": "integer" }, "recordsReturned": { "type": "integer" }, "recordsFiltered": { "type": "long" }, "recordsTotal": { "type": "long" }, "body": { "type": "object", "dynamic": "true", "enabled": "false" }, "forcedExpression": { "type": "keyword" } } } }'; my $settings = ''; if ($DOILM) { $settings .= qq/"lifecycle.name": "${PREFIX}molochhistory", /; } my $template = qq/ { "index_patterns": "${PREFIX}history_v1-*", "settings": { ${settings} "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-1" }, "mappings": ${mapping} }/; logmsg "Creating history template\n" if ($verbose > 0); esPut("/_template/${PREFIX}history_v1_template?master_timeout=${ESTIMEOUT}s&pretty&include_type_name=true", $template); my $indices = esGet("/${PREFIX}history_v1-*/_alias", 1); if ($UPGRADEALLSESSIONS) { logmsg "Updating history mapping for ", scalar(keys %{$indices}), " indices\n" if (scalar(keys %{$indices}) != 0); foreach my $i (keys %{$indices}) { progress("$i "); esPut("/$i/history/_mapping?master_timeout=${ESTIMEOUT}s&include_type_name=true", $mapping, 1); } logmsg "\n" if (scalar(keys %{$indices}) != 0); } } ################################################################################ ################################################################################ sub huntsCreate { my $settings = ' { "settings": { "index.priority": 30, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating hunts_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}hunts_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "hunts_v30", "hunts"); huntsUpdate(); } sub huntsUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "strict", "properties": { "userId": { "type": "keyword" }, "status": { "type": "keyword" }, "name": { "type": "keyword" }, "size": { "type": "integer" }, "search": { "type": "keyword" }, "searchType": { "type": "keyword" }, "src": { "type": "boolean" }, "dst": { "type": "boolean" }, "type": { "type": "keyword" }, "matchedSessions": { "type": "integer" }, "searchedSessions": { "type": "integer" }, "totalSessions": { "type": "integer" }, "lastPacketTime": { "type": "date" }, "created": { "type": "date" }, "lastUpdated": { "type": "date" }, "started": { "type": "date" }, "query": { "type": "object", "dynamic": "true" }, "errors": { "properties": { "value": { "type": "keyword" }, "time": { "type": "date" }, "node": { "type": "keyword" } } }, "notifier": { "type": "keyword" }, "unrunnable": { "type": "boolean" }, "failedSessionIds": { "type": "keyword" }, "users": { "type": "keyword" }, "removed": { "type": "boolean" } } }'; logmsg "Setting hunts_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}hunts_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping); } ################################################################################ ################################################################################ sub lookupsCreate { my $settings = ' { "settings": { "index.priority": 30, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating lookups_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}lookups_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "lookups_v30", "lookups"); lookupsUpdate(); } sub lookupsUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "strict", "properties": { "userId": { "type": "keyword" }, "name": { "type": "keyword" }, "shared": { "type": "boolean" }, "description": { "type": "keyword" }, "number": { "type": "integer" }, "ip": { "type": "keyword" }, "string": { "type": "keyword" }, "locked": { "type": "boolean" } } }'; logmsg "Setting lookups_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}lookups_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping); } ################################################################################ ################################################################################ sub usersCreate { my $settings = ' { "settings": { "index.priority": 60, "number_of_shards": 1, "number_of_replicas": 0, "auto_expand_replicas": "0-3" } }'; logmsg "Creating users_v30 index\n" if ($verbose > 0); esPut("/${PREFIX}users_v30?master_timeout=${ESTIMEOUT}s", $settings); esAlias("add", "users_v30", "users"); usersUpdate(); } ################################################################################ sub usersUpdate { my $mapping = ' { "_source": {"enabled": "true"}, "dynamic": "strict", "properties": { "userId": { "type": "keyword" }, "userName": { "type": "keyword" }, "enabled": { "type": "boolean" }, "createEnabled": { "type": "boolean" }, "webEnabled": { "type": "boolean" }, "headerAuthEnabled": { "type": "boolean" }, "emailSearch": { "type": "boolean" }, "removeEnabled": { "type": "boolean" }, "packetSearch": { "type": "boolean" }, "hideStats": { "type": "boolean" }, "hideFiles": { "type": "boolean" }, "hidePcap": { "type": "boolean" }, "disablePcapDownload": { "type": "boolean" }, "passStore": { "type": "keyword" }, "expression": { "type": "keyword" }, "settings": { "type": "object", "dynamic": "true" }, "views": { "type": "object", "dynamic": "true", "enabled": "false" }, "notifiers": { "type": "object", "dynamic": "true", "enabled": "false" }, "columnConfigs": { "type": "object", "dynamic": "true", "enabled": "false" }, "spiviewFieldConfigs": { "type": "object", "dynamic": "true", "enabled": "false" }, "tableStates": { "type": "object", "dynamic": "true", "enabled": "false" }, "welcomeMsgNum": { "type": "integer" }, "lastUsed": { "type": "date" }, "timeLimit": { "type": "integer" } } }'; logmsg "Setting users_v30 mapping\n" if ($verbose > 0); esPut("/${PREFIX}users_v30/_mapping?master_timeout=${ESTIMEOUT}s&pretty", $mapping); } ################################################################################ sub setPriority { esPut("/${PREFIX}sequence/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 100}}', 1); esPut("/${PREFIX}fields/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 90}}', 1); esPut("/${PREFIX}files/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 80}}', 1); esPut("/${PREFIX}stats/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 70}}', 1); esPut("/${PREFIX}users/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 60}}', 1); esPut("/${PREFIX}dstats/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 50}}', 1); esPut("/${PREFIX}queries/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 40}}', 1); esPut("/${PREFIX}hunts/_settings?master_timeout=${ESTIMEOUT}s", '{"settings": {"index.priority": 30}}', 1); } ################################################################################ sub createNewAliasesFromOld { my ($alias, $newName, $oldName, $createFunction) = @_; if (esCheckAlias($alias, $newName) && esIndexExists($newName)) { logmsg ("SKIPPING - $alias already points to $newName\n"); return; } if (!esIndexExists($oldName)) { die "ERROR - $oldName doesn't exist!"; } $createFunction->(); esAlias("remove", $oldName, $alias, 1); esCopy($oldName, $newName); esDelete("/${oldName}", 1); } ################################################################################ sub kind2time { my ($kind, $num) = @_; my @theTime = gmtime; if ($kind eq "hourly") { $theTime[2] -= $num; } elsif ($kind =~ /^hourly([23468])$/) { $theTime[2] -= $num * int($1); } elsif ($kind eq "hourly12") { $theTime[2] -= $num * 12; } elsif ($kind eq "daily") { $theTime[3] -= $num; } elsif ($kind eq "weekly") { $theTime[3] -= 7*$num; } elsif ($kind eq "monthly") { $theTime[4] -= $num; } return @theTime; } ################################################################################ sub mktimegm { local $ENV{TZ} = 'UTC'; return mktime(@_); } ################################################################################ sub index2time { my($index) = @_; return 0 if ($index !~ /sessions[23]-(.*)$/); $index = $1; my @t; $t[0] = 59; $t[1] = 59; $t[5] = int (substr($index, 0, 2)); $t[5] += 100 if ($t[5] < 50); if ($index =~ /m/) { $t[2] = 23; $t[3] = 28; $t[4] = int(substr($index, 3, 2)) - 1; } elsif ($index =~ /w/) { $t[2] = 23; $t[3] = int(substr($index, 3, 2)) * 7 + 3; } elsif ($index =~ /h/) { $t[4] = int(substr($index, 2, 2)) - 1; $t[3] = int(substr($index, 4, 2)); $t[2] = int(substr($index, 7, 2)); } else { $t[2] = 23; $t[3] = int(substr($index, 4, 2)); $t[4] = int(substr($index, 2, 2)) - 1; } return mktimegm(@t); } ################################################################################ sub time2index { my($type, $prefix, $t) = @_; my @t = gmtime($t); if ($type eq "hourly") { return sprintf("${prefix}%02d%02d%02dh%02d", $t[5] % 100, $t[4]+1, $t[3], $t[2]); } if ($type =~ /^hourly([23468])$/) { my $n = int($1); return sprintf("${prefix}%02d%02d%02dh%02d", $t[5] % 100, $t[4]+1, $t[3], int($t[2]/$n)*$n); } if ($type eq "hourly12") { return sprintf("${prefix}%02d%02d%02dh%02d", $t[5] % 100, $t[4]+1, $t[3], int($t[2]/12)*12); } if ($type eq "daily") { return sprintf("${prefix}%02d%02d%02d", $t[5] % 100, $t[4]+1, $t[3]); } if ($type eq "weekly") { return sprintf("${prefix}%02dw%02d", $t[5] % 100, int($t[7]/7)); } if ($type eq "monthly") { return sprintf("${prefix}%02dm%02d", $t[5] % 100, $t[4]+1); } } ################################################################################ sub dbESVersion { my $esversion = esGet("/"); my @parts = split(/\./, $esversion->{version}->{number}); $main::esVersion = int($parts[0]*100*100) + int($parts[1]*100) + int($parts[2]); return $esversion; } ################################################################################ sub dbVersion { my ($loud) = @_; my $version; $version = esGet("/_template/${OLDPREFIX}sessions2_template,${PREFIX}sessions3_template?filter_path=**._meta", 1); if (defined $version && exists $version->{"${PREFIX}sessions3_template"} && exists $version->{"${PREFIX}sessions3_template"}->{mappings}->{_meta} && exists $version->{"${PREFIX}sessions3_template"}->{mappings}->{_meta}->{molochDbVersion} ) { $main::versionNumber = $version->{"${PREFIX}sessions3_template"}->{mappings}->{_meta}->{molochDbVersion}; return; } if (defined $version && exists $version->{"${OLDPREFIX}sessions2_template"} && exists $version->{"${OLDPREFIX}sessions2_template"}->{mappings}->{_meta} && exists $version->{"${OLDPREFIX}sessions2_template"}->{mappings}->{_meta}->{molochDbVersion} ) { $main::versionNumber = $version->{"${OLDPREFIX}sessions2_template"}->{mappings}->{_meta}->{molochDbVersion}; return; } logmsg "This is a fresh Arkime install\n" if ($loud); $main::versionNumber = -1; if ($loud && $ARGV[1] !~ "init") { die "Looks like Arkime wasn't installed, must do init" } } ################################################################################ sub dbCheckForActivity { my ($prefix) = @_; logmsg "This upgrade requires all capture nodes to be stopped. Checking\n"; my $json1 = esGet("/${prefix}stats/stat/_search?size=1000&rest_total_hits_as_int=true"); sleep(6); my $json2 = esGet("/${prefix}stats/stat/_search?size=1000&rest_total_hits_as_int=true"); die "Some capture nodes still active" if ($json1->{hits}->{total} != $json2->{hits}->{total}); return if ($json1->{hits}->{total} == 0); my @hits1 = sort {$a->{_source}->{nodeName} cmp $b->{_source}->{nodeName}} @{$json1->{hits}->{hits}}; my @hits2 = sort {$a->{_source}->{nodeName} cmp $b->{_source}->{nodeName}} @{$json2->{hits}->{hits}}; for (my $i = 0; $i < $json1->{hits}->{total}; $i++) { if ($hits1[$i]->{_source}->{nodeName} ne $hits2[$i]->{_source}->{nodeName}) { die "Capture node '" . $hits1[$i]->{_source}->{nodeName} . "' or '" . $hits2[$i]->{_source}->{nodeName} . "' still active"; } if ($hits1[$i]->{_source}->{currentTime} != $hits2[$i]->{_source}->{currentTime}) { die "Capture node '" . $hits1[$i]->{_source}->{nodeName} . "' still active"; } } } ################################################################################ sub dbCheckHealth { my $health = esGet("/_cluster/health"); if ($health->{status} ne "green") { logmsg("WARNING elasticsearch health is '$health->{status}' instead of 'green', things may be broken\n\n"); } return $health; } ################################################################################ sub dbCheck { my $esversion = dbESVersion(); my @parts = split(/[-.]/, $esversion->{version}->{number}); $main::esVersion = int($parts[0]*100*100) + int($parts[1]*100) + int($parts[2]); if ($esversion->{version}->{distribution} eq "opensearch") { if ($main::esVersion < 1000) { logmsg("Currently using Opensearch version ", $esversion->{version}->{number}, " which isn't supported\n", "* < 1.0.0 is not supported\n" ); exit (1) } } else { if ($main::esVersion < 71000) { logmsg("Currently using Elasticsearch version ", $esversion->{version}->{number}, " which isn't supported\n", "* < 7.10.0 is not supported\n", "\n", "Instructions: https://molo.ch/faq#how-do-i-upgrade-elasticsearch\n", "Make sure to restart any viewer or capture after upgrading!\n" ); exit (1) } if ($main::esVersion < 71002) { logmsg("Currently using Elasticsearch version ", $esversion->{version}->{number}, " 7.10.2 or newer is recommended\n"); } } my $error = 0; my $nodes = esGet("/_nodes?flat_settings"); my $nodeStats = esGet("/_nodes/stats"); foreach my $key (sort {$nodes->{nodes}->{$a}->{name} cmp $nodes->{nodes}->{$b}->{name}} keys %{$nodes->{nodes}}) { next if (exists $nodes->{$key}->{attributes} && exists $nodes->{$key}->{attributes}->{data} && $nodes->{$key}->{attributes}->{data} eq "false"); my $node = $nodes->{nodes}->{$key}; my $nodeStat = $nodeStats->{nodes}->{$key}; my $errstr; my $warnstr; if (exists $node->{settings}->{"index.cache.field.type"}) { $errstr .= sprintf (" REMOVE 'index.cache.field.type'\n"); } if (!(exists $nodeStat->{process}->{max_file_descriptors}) || int($nodeStat->{process}->{max_file_descriptors}) < 4000) { $errstr .= sprintf (" INCREASE max file descriptors in /etc/security/limits.conf and restart all ES node\n"); $errstr .= sprintf (" (change root to the user that runs ES)\n"); $errstr .= sprintf (" root hard nofile 128000\n"); $errstr .= sprintf (" root soft nofile 128000\n"); } if ($errstr) { $error = 1; logmsg ("\nERROR: On node ", $node->{name}, " machine ", ($node->{hostname} || $node->{host}), " in file ", $node->{settings}->{config}, "\n"); logmsg($errstr); } if ($warnstr) { logmsg ("\nWARNING: On node ", $node->{name}, " machine ", ($node->{hostname} || $node->{host}), " in file ", $node->{settings}->{config}, "\n"); logmsg($warnstr); } } if ($error) { logmsg "\nFix above errors before proceeding\n"; exit (1); } } ################################################################################ sub checkForOld6Indices { my $result = esGet("/_all/_settings/index.version.created?pretty"); my $found = 0; while ( my ($key, $value) = each (%{$result})) { if ($value->{settings}->{index}->{version}->{created} < 6000000) { logmsg "WARNING: You must delete index '$key' before upgrading to ES 7\n"; $found = 1; } } if ($found) { logmsg "\nYou MUST delete (and optionally re-add) the indices above while still on ES 6.x otherwise ES 7.x will NOT start.\n\n"; } } ################################################################################ sub progress { my ($msg) = @_; if ($verbose == 1) { local $| = 1; logmsg "."; } elsif ($verbose == 2) { local $| = 1; logmsg "$msg"; } } ################################################################################ sub optimizeOther { logmsg "Optimizing Admin Indices\n"; esForceMerge("${PREFIX}stats_v30,${PREFIX}dstats_v30,${PREFIX}fields_v30,${PREFIX}files_v30,${PREFIX}sequence_v30,${PREFIX}users_v30,${PREFIX}queries_v30,${PREFIX}hunts_v30,${PREFIX}lookups_v30", 1, 0); logmsg "\n" if ($verbose > 0); } ################################################################################ sub parseArgs { my ($pos) = @_; for (;$pos <= $#ARGV; $pos++) { if ($ARGV[$pos] eq "--shards") { $pos++; $SHARDS = $ARGV[$pos]; } elsif ($ARGV[$pos] eq "--replicas") { $pos++; $REPLICAS = int($ARGV[$pos]); } elsif ($ARGV[$pos] eq "--refresh") { $pos++; $REFRESH = int($ARGV[$pos]); } elsif ($ARGV[$pos] eq "--history") { $pos++; $HISTORY = int($ARGV[$pos]); } elsif ($ARGV[$pos] eq "--segments") { $pos++; $SEGMENTS = int($ARGV[$pos]); } elsif ($ARGV[$pos] eq "--segmentsmin") { $pos++; $SEGMENTSMIN = int($ARGV[$pos]); } elsif ($ARGV[$pos] eq "--nooptimize") { $NOOPTIMIZE = 1; } elsif ($ARGV[$pos] eq "--full") { $FULL = 1; } elsif ($ARGV[$pos] eq "--reverse") { $REVERSE = 1; } elsif ($ARGV[$pos] eq "--skipupgradeall") { $UPGRADEALLSESSIONS = 0; } elsif ($ARGV[$pos] eq "--shardsPerNode") { $pos++; if ($ARGV[$pos] eq "null") { $SHARDSPERNODE = "null"; } else { $SHARDSPERNODE = int($ARGV[$pos]); } } elsif ($ARGV[$pos] eq "--hotwarm") { $DOHOTWARM = 1; } elsif ($ARGV[$pos] eq "--ilm") { $DOILM = 1; } elsif ($ARGV[$pos] eq "--warmafter") { $pos++; $WARMAFTER = int($ARGV[$pos]); $WARMKIND = $ARGV[2]; if (substr($ARGV[$pos], -6) eq "hourly") { $WARMKIND = "hourly"; } elsif (substr($ARGV[$pos], -5) eq "daily") { $WARMKIND = "daily"; } } elsif ($ARGV[$pos] eq "--optimizewarm") { $OPTIMIZEWARM = 1; } elsif ($ARGV[$pos] eq "--shared") { $SHARED = 1; } elsif ($ARGV[$pos] eq "--locked") { $LOCKED = 1; } elsif ($ARGV[$pos] eq "--gz") { $GZ = 1; } elsif ($ARGV[$pos] eq "--type") { $pos++; $TYPE = $ARGV[$pos]; } elsif ($ARGV[$pos] eq "--description") { $pos++; $DESCRIPTION = $ARGV[$pos]; } else { logmsg "Unknown option '$ARGV[$pos]'\n"; } } } ################################################################################ while (@ARGV > 0 && substr($ARGV[0], 0, 1) eq "-") { if ($ARGV[0] =~ /(-v+|--verbose)$/) { $verbose += ($ARGV[0] =~ tr/v//); } elsif ($ARGV[0] =~ /--prefix$/) { $PREFIX = $ARGV[1]; shift @ARGV; $PREFIX .= "_" if ($PREFIX ne "" && $PREFIX !~ /_$/); $OLDPREFIX = $PREFIX; } elsif ($ARGV[0] =~ /-n$/) { $NOCHANGES = 1; } elsif ($ARGV[0] =~ /--insecure$/) { $SECURE = 0; } elsif ($ARGV[0] =~ /--clientcert$/) { $CLIENTCERT = $ARGV[1]; shift @ARGV; } elsif ($ARGV[0] =~ /--clientkey$/) { $CLIENTKEY = $ARGV[1]; shift @ARGV; } elsif ($ARGV[0] =~ /--timeout$/) { $ESTIMEOUT = int($ARGV[1]); shift @ARGV; } elsif ($ARGV[0] =~ /(--esapikey|--elasticsearchAPIKey)$/) { $ESAPIKEY = $ARGV[1]; shift @ARGV; } else { showHelp("Unknkown global option $ARGV[0]") } shift @ARGV; } $PREFIX = "arkime_" if (! defined $PREFIX); showHelp("Help:") if ($ARGV[1] =~ /^help$/); showHelp("Missing arguments") if (@ARGV < 2); showHelp("Unknown command '$ARGV[1]'") if ($ARGV[1] !~ /^(init|initnoprompt|clean|info|wipe|upgrade|upgradenoprompt|disable-?users|set-?shortcut|users-?import|import|restore|users-?export|export|backup|expire|rotate|optimize|optimize-admin|mv|rm|rm-?missing|rm-?node|add-?missing|field|force-?put-?version|sync-?files|hide-?node|unhide-?node|add-?alias|set-?replicas|set-?shards-?per-?node|set-?allocation-?enable|allocate-?empty|unflood-?stage|shrink|ilm|recreate-users|recreate-stats|recreate-dstats|recreate-fields|reindex|force-sessions3-update)$/); showHelp("Missing arguments") if (@ARGV < 3 && $ARGV[1] =~ /^(users-?import|import|users-?export|backup|restore|rm|rm-?missing|rm-?node|hide-?node|unhide-?node|set-?allocation-?enable|unflood-?stage|reindex)$/); showHelp("Missing arguments") if (@ARGV < 4 && $ARGV[1] =~ /^(field|export|add-?missing|sync-?files|add-?alias|set-?replicas|set-?shards-?per-?node|set-?shortcut|ilm)$/); showHelp("Missing arguments") if (@ARGV < 5 && $ARGV[1] =~ /^(allocate-?empty|set-?shortcut|shrink)$/); showHelp("Must have both <old fn> and <new fn>") if (@ARGV < 4 && $ARGV[1] =~ /^(mv)$/); showHelp("Must have both <type> and <num> arguments") if (@ARGV < 4 && $ARGV[1] =~ /^(rotate|expire)$/); parseArgs(2) if ($ARGV[1] =~ /^(init|initnoprompt|upgrade|upgradenoprompt|clean|wipe|optimize)$/); parseArgs(3) if ($ARGV[1] =~ /^(restore|backup)$/); $ESTIMEOUT = 240 if ($ESTIMEOUT < 240 && $ARGV[1] =~ /^(init|initnoprompt|upgrade|upgradenoprompt|clean|shrink|ilm)$/); $main::userAgent = LWP::UserAgent->new(timeout => $ESTIMEOUT + 5, keep_alive => 5); if ($ESAPIKEY ne "") { $main::userAgent->default_header('Authorization' => "ApiKey $ESAPIKEY"); } if ($CLIENTCERT ne "") { $main::userAgent->ssl_opts( SSL_verify_mode => $SECURE, verify_hostname=> $SECURE, SSL_cert_file => $CLIENTCERT, SSL_key_file => $CLIENTKEY ) } else { $main::userAgent->ssl_opts( SSL_verify_mode => $SECURE, verify_hostname=> $SECURE ) } if ($ARGV[0] =~ /^urlinfile:\/\//) { open( my $file, substr($ARGV[0], 12)) or die "Couldn't open file ", substr($ARGV[0], 12); $main::elasticsearch = <$file>; chomp $main::elasticsearch; close ($file); } elsif ($ARGV[0] =~ /^http/) { $main::elasticsearch = $ARGV[0]; } else { $main::elasticsearch = "http://$ARGV[0]"; } if ($ARGV[1] =~ /^(users-?import|import)$/) { my $fh; if ($ARGV[2] =~ /\.gz$/) { $fh = new IO::Uncompress::Gunzip $ARGV[2] or die "gunzip failed: $GunzipError\n"; } else { open($fh, "<", $ARGV[2]) or die "cannot open < $ARGV[2]: $!"; } my $data = do { local $/; <$fh> }; # Use version/version_type instead of _version/_version_type $data =~ s/, "_version": (\d+), "_version_type"/, "version": \1, "version_type"/g; # Remove type from older backups $data =~ s/, "_type": .*, "_id":/, "_id":/g; esPost("/_bulk", $data); close($fh); exit 0; } elsif ($ARGV[1] =~ /^export$/) { my $index = $ARGV[2]; my $data = esScroll($index, "", '{"version": true}'); if (scalar(@{$data}) == 0){ logmsg "The index is empty\n"; exit 0; } open(my $fh, ">", "$ARGV[3].${PREFIX}${index}.json") or die "cannot open > $ARGV[3].${PREFIX}${index}.json: $!"; foreach my $hit (@{$data}) { print $fh "{\"index\": {\"_index\": \"${PREFIX}${index}\", \"_id\": \"$hit->{_id}\", \"version\": $hit->{_version}, \"version_type\": \"external\"}}\n"; if (exists $hit->{_source}) { print $fh to_json($hit->{_source}) . "\n"; } else { print $fh "{}\n"; } } close($fh); exit 0; } elsif ($ARGV[1] =~ /^backup$/) { sub bopen { my ($index) = @_; if ($GZ) { return new IO::Compress::Gzip "$ARGV[2].${PREFIX}${index}.json.gz" or die "cannot open $ARGV[2].${PREFIX}${index}.json.gz: $GzipError\n"; } else { open(my $fh, ">", "$ARGV[2].${PREFIX}${index}.json") or die "cannot open > $ARGV[2].${PREFIX}${index}.json: $!"; return $fh; } } my @indexes = ("users", "sequence", "stats", "queries", "files", "fields", "dstats", "hunts", "lookups"); logmsg "Exporting documents...\n"; foreach my $index (@indexes) { my $data = esScroll($index, "", '{"version": true}'); next if (scalar(@{$data}) == 0); my $fh = bopen($index); foreach my $hit (@{$data}) { print $fh "{\"index\": {\"_index\": \"${PREFIX}${index}\", \"_id\": \"$hit->{_id}\", \"version\": $hit->{_version}, \"version_type\": \"external\"}}\n"; if (exists $hit->{_source}) { print $fh to_json($hit->{_source}) . "\n"; } else { print $fh "{}\n"; } } close($fh); } logmsg "Exporting templates...\n"; my @templates = ("sessions3_template", "history_v1_template"); foreach my $template (@templates) { my $data = esGet("/_template/${PREFIX}${template}?include_type_name=true"); my @name = split(/_/, $template); my $fh = bopen("template"); print $fh to_json($data); close($fh); } logmsg "Exporting settings...\n"; foreach my $index (@indexes) { my $data = esGet("/${PREFIX}${index}/_settings"); my $fh = bopen("${index}.settings"); print $fh to_json($data); close($fh); } logmsg "Exporting mappings...\n"; foreach my $index (@indexes) { my $data = esGet("/${PREFIX}${index}/_mappings"); my $fh = bopen("${index}.mappings"); print $fh to_json($data); close($fh); } logmsg "Exporting aliaes...\n"; my @indexes_prefixed = (); foreach my $index (@indexes) { push(@indexes_prefixed, $PREFIX . $index); } my $aliases = join(',', @indexes_prefixed); $aliases = "/_cat/aliases/${aliases}?format=json"; my $data = esGet($aliases), "\n"; my $fh = bopen("aliases"); print $fh to_json($data); close($fh); logmsg "Finished\n"; exit 0; } elsif ($ARGV[1] =~ /^users-?export$/) { open(my $fh, ">", $ARGV[2]) or die "cannot open > $ARGV[2]: $!"; my $users = esGet("/${PREFIX}users/_search?size=1000"); foreach my $hit (@{$users->{hits}->{hits}}) { print $fh "{\"index\": {\"_index\": \"users\", \"_type\": \"user\", \"_id\": \"" . $hit->{_id} . "\"}}\n"; print $fh to_json($hit->{_source}) . "\n"; } close($fh); exit 0; } elsif ($ARGV[1] =~ /^(rotate|expire)$/) { showHelp("Invalid expire <type>") if ($ARGV[2] !~ /^(hourly|hourly[23468]|hourly12|daily|weekly|monthly)$/); $SEGMENTSMIN = $SEGMENTS if ($SEGMENTSMIN == -1); # First handle sessions expire my $indicesa = esGet("/_cat/indices/${OLDPREFIX}sessions2-*,${PREFIX}sessions3-*?format=json", 1); my %indices = map { $_->{index} => $_ } @{$indicesa}; my $endTime = time(); my $endTimeIndex2 = time2index($ARGV[2], "${OLDPREFIX}sessions2-", $endTime, ""); delete $indices{$endTimeIndex2}; # Don't optimize current index my $endTimeIndex3 = time2index($ARGV[2], "${PREFIX}sessions3-", $endTime); delete $indices{$endTimeIndex3}; # Don't optimize current index my @startTime = kind2time($ARGV[2], int($ARGV[3])); parseArgs(4); my $startTime = mktimegm(@startTime); my @warmTime = kind2time($WARMKIND, $WARMAFTER); my $warmTime = mktimegm(@warmTime); my $optimizecnt = 0; my $warmcnt = 0; my @indiceskeys = sort (keys %indices); foreach my $i (@indiceskeys) { my $t = index2time($i); if ($t >= $startTime) { $indices{$i}->{OPTIMIZEIT} = 1; $optimizecnt++; } if ($WARMAFTER != -1 && $t < $warmTime) { $indices{$i}->{WARMIT} = 1; $warmcnt++; } } my $nodes = esGet("/_nodes"); $main::numberOfNodes = dataNodes($nodes->{nodes}); my $shardsPerNode = ceil($SHARDS * ($REPLICAS+1) / $main::numberOfNodes); $shardsPerNode = $SHARDSPERNODE if ($SHARDSPERNODE eq "null" || $SHARDSPERNODE > $shardsPerNode); dbESVersion(); optimizeOther() unless $NOOPTIMIZE ; logmsg sprintf ("Expiring %s sessions indices, %s optimizing %s, warming %s\n", commify(scalar(keys %indices) - $optimizecnt), $NOOPTIMIZE?"Not":"", commify($optimizecnt), commify($warmcnt)); esPost("/_flush/synced", "", 1); @indiceskeys = reverse(@indiceskeys) if ($REVERSE); # Get all the settings at once, we use below to see if we need to change them my $settings = esGet("/_settings?flat_settings&master_timeout=${ESTIMEOUT}s", 1); # Find all the shards that have too many segments and increment the OPTIMIZEIT count or not warm my $shards = esGet("/_cat/shards/${OLDPREFIX}sessions2*,${PREFIX}sessions3*?h=i,sc&format=json"); for my $i (@{$shards}) { # Not expiring and too many segments if (exists $indices{$i->{i}}->{OPTIMIZEIT} && defined $i->{sc} && int($i->{sc}) > $SEGMENTSMIN) { # Either not only optimizing warm or make sure we are green warm if (!$OPTIMIZEWARM || ($settings->{$i->{i}}->{settings}->{"index.routing.allocation.require.molochtype"} eq "warm" && $indices{$i->{i}}->{health} eq "green")) { $indices{$i->{i}}->{OPTIMIZEIT}++; } } if (exists $indices{$i->{i}}->{WARMIT} && $settings->{$i->{i}}->{settings}->{"index.routing.allocation.require.molochtype"} ne "warm") { $indices{$i->{i}}->{WARMIT}++; } } foreach my $i (@indiceskeys) { progress("$i "); if (exists $indices{$i}->{OPTIMIZEIT}) { # 1 is set if it shouldn't be expired, > 1 means it needs to be optimized if ($indices{$i}->{OPTIMIZEIT} > 1) { esForceMerge($i, $SEGMENTS, 1) unless $NOOPTIMIZE; } if ($REPLICAS != -1) { if (!exists $settings->{$i} || $settings->{$i}->{settings}->{"index.number_of_replicas"} ne "$REPLICAS" || ("$shardsPerNode" eq "null" && exists $settings->{$i}->{settings}->{"index.routing.allocation.total_shards_per_node"}) || ("$shardsPerNode" ne "null" && $settings->{$i}->{settings}->{"index.routing.allocation.total_shards_per_node"} ne "$shardsPerNode")) { esPut("/$i/_settings?master_timeout=${ESTIMEOUT}s", '{"index": {"number_of_replicas":' . $REPLICAS . ', "routing.allocation.total_shards_per_node": ' . $shardsPerNode . '}}', 1); } } } else { esDelete("/$i", 1); } if ($indices{$i}->{WARMIT} > 1) { esPut("/$i/_settings?master_timeout=${ESTIMEOUT}s", '{"index": {"routing.allocation.require.molochtype": "warm"}}', 1); } } esPost("/_flush/synced", "", 1); # Now figure out history expire my $hindices = esGet("/${PREFIX}history_v1-*,${OLDPREFIX}history_v1-*/_alias", 1); my $endTimeIndex = time2index("weekly", "${OLDPREFIX}history_v1-", $endTime); delete $hindices->{$endTimeIndex}; $endTimeIndex = time2index("weekly", "${PREFIX}history_v1-", $endTime); delete $hindices->{$endTimeIndex}; @startTime = gmtime; $startTime[3] -= 7 * $HISTORY; $optimizecnt = 0; $startTime = mktimegm(@startTime); while ($startTime <= $endTime + 2*24*60*60) { my $iname = time2index("weekly", "${PREFIX}history_v1-", $startTime); my $inameold = time2index("weekly", "${OLDPREFIX}history_v1-", $startTime); if (exists $hindices->{$iname} && $hindices->{$iname}->{OPTIMIZEIT} != 1) { $hindices->{$iname}->{OPTIMIZEIT} = 1; $optimizecnt++; } elsif (exists $hindices->{"$iname-shrink"} && $hindices->{"$iname-shrink"}->{OPTIMIZEIT} != 1) { $hindices->{"$iname-shrink"}->{OPTIMIZEIT} = 1; $optimizecnt++; } elsif (exists $hindices->{$inameold} && $hindices->{$inameold}->{OPTIMIZEIT} != 1) { $hindices->{$inameold}->{OPTIMIZEIT} = 1; $optimizecnt++; } elsif (exists $hindices->{"$inameold-shrink"} && $hindices->{"$inameold-shrink"}->{OPTIMIZEIT} != 1) { $hindices->{"$inameold-shrink"}->{OPTIMIZEIT} = 1; $optimizecnt++; } $startTime += 24*60*60; } logmsg sprintf ("Expiring %s history indices, %s optimizing %s\n", commify(scalar(keys %{$hindices}) - $optimizecnt), $NOOPTIMIZE?"Not":"", commify($optimizecnt)); foreach my $i (sort (keys %{$hindices})) { progress("$i "); if (! exists $hindices->{$i}->{OPTIMIZEIT}) { esDelete("/$i", 1); } } esForceMerge("${OLDPREFIX}history_*,${PREFIX}history_*", 1, 1) unless $NOOPTIMIZE; esPost("/_flush/synced", "", 1); # Give the cluster a kick to rebalance esPost("/_cluster/reroute?master_timeout=${ESTIMEOUT}s&retry_failed"); exit 0; } elsif ($ARGV[1] eq "optimize") { my $indices = esGet("/${OLDPREFIX}sessions2-*,${PREFIX}sessions3*/_alias", 1); dbESVersion(); $main::userAgent->timeout(7200); esPost("/_flush/synced", "", 1); optimizeOther(); logmsg sprintf "Optimizing %s Session Indices\n", commify(scalar(keys %{$indices})); foreach my $i (sort (keys %{$indices})) { progress("$i "); esForceMerge($i, $SEGMENTS, 1); } esPost("/_flush/synced", "", 1); logmsg "Optimizing History\n"; esForceMerge("${PREFIX}history_v1-*", 1, 1); logmsg "\n"; exit 0; } elsif ($ARGV[1] eq "optimize-admin") { $main::userAgent->timeout(7200); esPost("/_flush/synced", "", 1); optimizeOther(); esForceMerge("${PREFIX}history_*", 1, 0); exit 0; } elsif ($ARGV[1] =~ /^(disable-?users)$/) { showHelp("Invalid number of <days>") if (!defined $ARGV[2] || $ARGV[2] !~ /^[+-]?\d+$/); my $users = esGet("/${PREFIX}users/_search?size=1000&q=enabled:true+AND+createEnabled:false+AND+_exists_:lastUsed"); my $rmcount = 0; foreach my $hit (@{$users->{hits}->{hits}}) { my $epoc = time(); my $lastUsed = $hit->{_source}->{lastUsed}; $lastUsed = $lastUsed / 1000; # convert to seconds $lastUsed = $epoc - $lastUsed; # in seconds $lastUsed = $lastUsed / 86400; # days since last used if ($lastUsed > $ARGV[2]) { my $userId = $hit->{_source}->{userId}; print "Disabling user: $userId\n"; esPost("/${PREFIX}users/user/$userId/_update", '{"doc": {"enabled": false}}'); $rmcount++; } } if ($rmcount == 0) { print "No users disabled\n"; } else { print "$rmcount user(s) disabled\n"; } exit 0; } elsif ($ARGV[1] =~ /^(set-?shortcut)$/) { showHelp("Invalid name $ARGV[2], names cannot have special characters except '_'") if ($ARGV[2] =~ /[^-a-zA-Z0-9_]$/); showHelp("file '$ARGV[4]' not found") if (! -e $ARGV[4]); showHelp("file '$ARGV[4]' empty") if (-z $ARGV[4]); parseArgs(5); showHelp("Type must be ip, string, or number instead of $TYPE") if ($TYPE !~ /^(string|ip|number)$/); # read shortcuts file my $shortcutValues; open(my $fh, '<', $ARGV[4]); { local $/; $shortcutValues = <$fh>; } close($fh); my $shortcutsArray = [split /[\n,]/, $shortcutValues]; my $shortcutName = $ARGV[2]; my $shortcutUserId = $ARGV[3]; my $shortcuts = esGet("/${PREFIX}lookups/_search?q=name:${shortcutName}"); my $existingShortcut; foreach my $shortcut (@{$shortcuts->{hits}->{hits}}) { if ($shortcut->{_source}->{name} == $shortcutName) { $existingShortcut = $shortcut; last; } } # create shortcut object my $newShortcut; $newShortcut->{name} = $shortcutName; $newShortcut->{userId} = $shortcutUserId; $newShortcut->{$TYPE} = $shortcutsArray; if ($existingShortcut) { # use existing optional fields if ($existingShortcut->{_source}->{description}) { $newShortcut->{description} = $existingShortcut->{_source}->{description}; } if ($existingShortcut->{_source}->{shared}) { $newShortcut->{shared} = $existingShortcut->{_source}->{shared}; } } if ($DESCRIPTION) { $newShortcut->{description} = $DESCRIPTION; } if ($SHARED) { $newShortcut->{shared} = \1; } if ($LOCKED) { $newShortcut->{locked} = \1; } my $verb = "Created"; if ($existingShortcut) { # update the shortcut $verb = "Updated"; my $id = $existingShortcut->{_id}; esPost("/${PREFIX}lookups/lookup/${id}", to_json($newShortcut)); } else { # create the shortcut esPost("/${PREFIX}lookups/lookup", to_json($newShortcut)); } # increment the _meta version by 1 my $mapping = esGet("/${PREFIX}lookups/_mapping"); my @indexes = keys %{$mapping}; my $index = @indexes[0]; my $meta = $mapping->{$index}->{mappings}->{_meta}; $meta->{version}++; esPut("/${PREFIX}lookups/_mapping", to_json({"_meta" => $meta})); print "${verb} shortcut ${shortcutName}\n"; exit 0; } elsif ($ARGV[1] =~ /^(shrink)$/) { parseArgs(5); die "Only shrink history and sessions2 indices" if ($ARGV[2] !~ /(sessions2|sessions3|history)/); logmsg("Moving all shards for ${PREFIX}$ARGV[2] to $ARGV[3]\n"); my $json = esPut("/${PREFIX}$ARGV[2]/_settings?master_timeout=${ESTIMEOUT}s", "{\"settings\": {\"index.routing.allocation.total_shards_per_node\": null, \"index.routing.allocation.require._name\" : \"$ARGV[3]\", \"index.blocks.write\": true}}"); while (1) { $json = esGet("/_cluster/health?wait_for_no_relocating_shards=true&timeout=30s", 1); last if ($json->{relocating_shards} == 0); progress("Waiting for relocation to finish\n"); } logmsg("Shrinking ${PREFIX}$ARGV[2] to ${PREFIX}$ARGV[2]-shrink\n"); $json = esPut("/${PREFIX}$ARGV[2]/_shrink/${PREFIX}$ARGV[2]-shrink?master_timeout=${ESTIMEOUT}s&copy_settings=true", '{"settings": {"index.routing.allocation.require._name": null, "index.blocks.write": null, "index.codec": "best_compression", "index.number_of_shards": ' . $ARGV[4] . '}}'); logmsg("Checking for completion\n"); my $status = esGet("/${PREFIX}$ARGV[2]-shrink/_refresh", 0); my $status = esGet("/${PREFIX}$ARGV[2]-shrink/_flush", 0); my $status = esGet("/_stats/docs", 0); if ($status->{indices}->{"${PREFIX}$ARGV[2]-shrink"}->{primaries}->{docs}->{count} == $status->{indices}->{"${PREFIX}$ARGV[2]"}->{primaries}->{docs}->{count}) { logmsg("Deleting old index\n"); esDelete("/${PREFIX}$ARGV[2]", 1); esPut("/${PREFIX}$ARGV[2]-shrink/_settings?master_timeout=${ESTIMEOUT}s", "{\"index.routing.allocation.total_shards_per_node\" : $SHARDSPERNODE}") if ($SHARDSPERNODE ne "null"); } else { logmsg("Doc counts don't match, not deleting old index\n"); } exit 0; } elsif ($ARGV[1] eq "recreate-users") { waitFor("USERS", "This will delete and recreate the users index"); esDelete("/${PREFIX}users_*", 1); esDelete("/${PREFIX}users", 1); usersCreate(); exit 0; } elsif ($ARGV[1] eq "recreate-stats") { waitFor("STATS", "This will delete and recreate the stats index, make sure no captures are running"); esDelete("/${PREFIX}stats_*", 1); esDelete("/${PREFIX}stats", 1); statsCreate(); exit 0; } elsif ($ARGV[1] eq "recreate-dstats") { waitFor("DSTATS", "This will delete and recreate the dstats index, make sure no captures are running"); esDelete("/${PREFIX}dstats_*", 1); esDelete("/${PREFIX}dstats", 1); dstatsCreate(); exit 0; } elsif ($ARGV[1] eq "recreate-fields") { waitFor("FIELDS", "This will delete and recreate the fields index, make sure no captures are running"); esDelete("/${PREFIX}fields_*", 1); esDelete("/${PREFIX}fields", 1); fieldsCreate(); exit 0; } elsif ($ARGV[1] eq "force-sessions3-update") { my $nodes = esGet("/_nodes"); $main::numberOfNodes = dataNodes($nodes->{nodes}); if (int($SHARDS) > $main::numberOfNodes) { die "Can't set shards ($SHARDS) greater then the number of nodes ($main::numberOfNodes)"; } elsif ($SHARDS == -1) { $SHARDS = $main::numberOfNodes; if ($SHARDS > 24) { logmsg "Setting # of shards to 24, use --shards for a different number\n"; $SHARDS = 24; } } waitFor("SESSIONS3UPDATE", "This will update the sessions3 template and all sessions3 indices"); sessions3Update(); exit 0; } elsif ($ARGV[1] eq "info") { dbVersion(0); my $esversion = dbESVersion(); my $catNodes = esGet("/_cat/nodes?format=json&bytes=b&h=name,diskTotal,role"); my $status = esGet("/_stats/docs,store", 1); my $minMax = esPost("/${OLDPREFIX}sessions2-*,${PREFIX}sessions3-*/_search?size=0", '{"aggs":{ "min" : { "min" : { "field" : "lastPacket" } }, "max" : { "max" : { "field" : "lastPacket" } } } }', 1); my $ilm = esGet("/_ilm/policy/${PREFIX}molochsessions", 1); my $sessions = 0; my $sessionsBytes = 0; my $sessionsTotalBytes = 0; my @sessions = grep /^${PREFIX}sessions[23]-/, keys %{$status->{indices}}; foreach my $index (@sessions) { $sessions += $status->{indices}->{$index}->{primaries}->{docs}->{count}; $sessionsBytes += int($status->{indices}->{$index}->{primaries}->{store}->{size_in_bytes}); $sessionsTotalBytes += int($status->{indices}->{$index}->{total}->{store}->{size_in_bytes}); } my $diskTotal = 0; my $dataNodes = 0; my $totalNodes = 0; foreach my $node (@{$catNodes}) { $totalNodes++; if ($node->{role} =~ /d/) { $diskTotal += $node->{diskTotal}; $dataNodes++; } } my $historys = 0; my $historysBytes = 0; my @historys = grep /^${PREFIX}history_v1-/, keys %{$status->{indices}}; foreach my $index (@historys) { next if ($index !~ /^${PREFIX}history_v1-/); $historys += $status->{indices}->{$index}->{primaries}->{docs}->{count}; $historysBytes += $status->{indices}->{$index}->{primaries}->{store}->{size_in_bytes}; } sub printIndex { my ($status, $name) = @_; my $index = $status->{indices}->{$PREFIX.$name} || $status->{indices}->{$OLDPREFIX.$name}; return if (!$index); printf "%-20s %17s (%s bytes)\n", $name . ":", commify($index->{primaries}->{docs}->{count}), commify($index->{primaries}->{store}->{size_in_bytes}); } printf "Cluster Name: %17s\n", $esversion->{cluster_name}; printf "ES Version: %17s\n", $esversion->{version}->{number}; printf "DB Version: %17s\n", $main::versionNumber; printf "ES Data Nodes: %17s/%s\n", commify($dataNodes), commify($totalNodes); printf "Sessions2 Indices: %17s\n", commify(scalar(@sessions)); printf "Sessions: %17s (%s bytes)\n", commify($sessions), commify($sessionsBytes); if (scalar(@sessions) > 0 && $dataNodes > 0) { printf "Sessions Density: %17s (%s bytes)\n", commify(int($sessions/($dataNodes*scalar(@sessions)))), commify(int($sessionsBytes/($dataNodes*scalar(@sessions)))); my $days = (int($minMax->{aggregations}->{max}->{value}) - int($minMax->{aggregations}->{min}->{value}))/(24*60*60*1000); printf "MB per Day: %17s\n", commify(int($sessionsTotalBytes/($days*1000*1000))) if ($days > 0); printf "Sessions Days: %17.2f (%s - %s)\n", $days, $minMax->{aggregations}->{min}->{value_as_string}, $minMax->{aggregations}->{max}->{value_as_string}; printf "Possible Sessions Days: %13.2f\n", (0.95*$diskTotal)/($sessionsTotalBytes/$days) if ($days > 0); if (exists $ilm->{molochsessions} && exists $ilm->{molochsessions}->{policy}->{phases}->{delete}) { printf "ILM Delete Age: %17s\n", $ilm->{molochsessions}->{policy}->{phases}->{delete}->{min_age}; } } printf "History Indices: %17s\n", commify(scalar(@historys)); printf "Histories: %17s (%s bytes)\n", commify($historys), commify($historysBytes); if (scalar(@historys) > 0 && $dataNodes > 0) { printf "History Density: %17s (%s bytes)\n", commify(int($historys/($dataNodes*scalar(@historys)))), commify(int($historysBytes/($dataNodes*scalar(@historys)))); } printIndex($status, "stats_v30"); printIndex($status, "stats_v4"); printIndex($status, "stats_v3"); printIndex($status, "fields_v30"); printIndex($status, "fields_v3"); printIndex($status, "fields_v2"); printIndex($status, "files_v30"); printIndex($status, "files_v6"); printIndex($status, "files_v5"); printIndex($status, "users_v30"); printIndex($status, "users_v7"); printIndex($status, "users_v6"); printIndex($status, "users_v5"); printIndex($status, "users_v4"); printIndex($status, "hunts_v30"); printIndex($status, "hunts_v2"); printIndex($status, "hunts_v1"); printIndex($status, "dstats_v30"); printIndex($status, "dstats_v4"); printIndex($status, "dstats_v3"); printIndex($status, "sequence_v30"); printIndex($status, "sequence_v3"); printIndex($status, "sequence_v2"); exit 0; } elsif ($ARGV[1] eq "mv") { (my $fn = $ARGV[2]) =~ s/\//\\\//g; my $results = esGet("/${PREFIX}files/_search?q=name:$fn"); die "Couldn't find '$ARGV[2]' in db\n" if (@{$results->{hits}->{hits}} == 0); foreach my $hit (@{$results->{hits}->{hits}}) { my $script = '{"script" : "ctx._source.name = \"' . $ARGV[3] . '\"; ctx._source.locked = 1;"}'; esPost("/${PREFIX}files/file/" . $hit->{_id} . "/_update", $script); } logmsg "Moved " . scalar (@{$results->{hits}->{hits}}) . " file(s) in database\n"; exit 0; } elsif ($ARGV[1] eq "rm") { (my $fn = $ARGV[2]) =~ s/\//\\\//g; my $results = esGet("/${PREFIX}files/_search?q=name:$fn"); die "Couldn't find '$ARGV[2]' in db\n" if (@{$results->{hits}->{hits}} == 0); foreach my $hit (@{$results->{hits}->{hits}}) { esDelete("/${PREFIX}files/_doc/" . $hit->{_id}, 0); } logmsg "Removed " . scalar (@{$results->{hits}->{hits}}) . " file(s) in database\n"; exit 0; } elsif ($ARGV[1] =~ /^rm-?missing$/) { my $results = esGet("/${PREFIX}files/_search?size=10000&q=node:$ARGV[2]"); die "Couldn't find '$ARGV[2]' in db\n" if (@{$results->{hits}->{hits}} == 0); logmsg "Need to remove references to these files from database:\n"; my $cnt = 0; foreach my $hit (@{$results->{hits}->{hits}}) { if (! -f $hit->{_source}->{name}) { logmsg $hit->{_source}->{name}, "\n"; $cnt++; } } die "Nothing found to remove." if ($cnt == 0); logmsg "\n"; waitFor("YES", "Do you want to remove file references from database?"); foreach my $hit (@{$results->{hits}->{hits}}) { if (! -f $hit->{_source}->{name}) { esDelete("/${PREFIX}files/_doc/" . $hit->{_id}, 0); } } exit 0; } elsif ($ARGV[1] =~ /^rm-?node$/) { esGet("/${PREFIX}files,${PREFIX}dstats,${PREFIX}stats/_refresh", 1); my $results; $results = esGet("/${PREFIX}files/_search?size=1000&q=node:$ARGV[2]&rest_total_hits_as_int=true"); logmsg "Deleting ", $results->{hits}->{total}, " files\n"; while ($results->{hits}->{total} > 0) { foreach my $hit (@{$results->{hits}->{hits}}) { esDelete("/${PREFIX}files/_doc/" . $hit->{_id}, 0); } esPost("/_flush/synced", "", 1); esGet("/${PREFIX}files/_refresh", 1); $results = esGet("/${PREFIX}files/_search?size=1000&q=node:$ARGV[2]&rest_total_hits_as_int=true"); } esDelete("/${PREFIX}stats/_doc/" . $ARGV[2], 1); $results = esGet("/${PREFIX}dstats/_search?size=1000&q=nodeName:$ARGV[2]&rest_total_hits_as_int=true"); logmsg "Deleting ", $results->{hits}->{total}, " stats\n"; while ($results->{hits}->{total} > 0) { foreach my $hit (@{$results->{hits}->{hits}}) { esDelete("/${PREFIX}dstats/_doc/" . $hit->{_id}, 0); } esPost("/_flush/synced", "", 1); esGet("/${PREFIX}dstats/_refresh", 1); $results = esGet("/${PREFIX}dstats/_search?size=1000&q=nodeName:$ARGV[2]&rest_total_hits_as_int=true"); } exit 0; } elsif ($ARGV[1] =~ /^hide-?node$/) { my $results = esGet("/${PREFIX}stats/stat/$ARGV[2]", 1); die "Node $ARGV[2] not found" if (!$results->{found}); esPost("/${PREFIX}stats/stat/$ARGV[2]/_update", '{"doc": {"hide": true}}'); exit 0; } elsif ($ARGV[1] =~ /^unhide-?node$/) { my $results = esGet("/${PREFIX}stats/stat/$ARGV[2]", 1); die "Node $ARGV[2] not found" if (!$results->{found}); esPost("/${PREFIX}stats/stat/$ARGV[2]/_update", '{"script" : "ctx._source.remove(\"hide\")"}'); exit 0; } elsif ($ARGV[1] =~ /^add-?alias$/) { my $results = esGet("/${PREFIX}stats/stat/$ARGV[2]", 1); die "Node $ARGV[2] already exists, must remove first" if ($results->{found}); esPost("/${PREFIX}stats/stat/$ARGV[2]", '{"nodeName": "' . $ARGV[2] . '", "hostname": "' . $ARGV[3] . '", "hide": true}'); exit 0; } elsif ($ARGV[1] =~ /^add-?missing$/) { my $dir = $ARGV[3]; chop $dir if (substr($dir, -1) eq "/"); opendir(my $dh, $dir) || die "Can't opendir $dir: $!"; my @files = grep { m/^$ARGV[2]-/ && -f "$dir/$_" } readdir($dh); closedir $dh; logmsg "Checking ", scalar @files, " files, this may take a while.\n"; foreach my $file (@files) { $file =~ /(\d+)-(\d+).pcap/; my $filenum = int($2); my $ctime = (stat("$dir/$file"))[10]; my $info = esGet("/${PREFIX}files/_doc/$ARGV[2]-$filenum", 1); if (!$info->{found}) { logmsg "Adding $dir/$file $filenum $ctime\n"; esPost("/${PREFIX}files/file/$ARGV[2]-$filenum", to_json({ 'locked' => 0, 'first' => $ctime, 'num' => $filenum, 'name' => "$dir/$file", 'node' => $ARGV[2]}), 1); } elsif ($verbose > 0) { logmsg "Ok $dir/$file\n"; } } exit 0; } elsif ($ARGV[1] =~ /^sync-?files$/) { my @nodes = split(",", $ARGV[2]); my @dirs = split(",", $ARGV[3]); # find all local files, do this first also to make sure we can access dirs my @localfiles = (); foreach my $dir (@dirs) { chop $dir if (substr($dir, -1) eq "/"); opendir(my $dh, $dir) || die "Can't opendir $dir: $!"; foreach my $node (@nodes) { my @files = grep { m/^$ARGV[2]-/ && -f "$dir/$_" } readdir($dh); @files = map "$dir/$_", @files; push (@localfiles, @files); } closedir $dh; } # See what files are in db my $remotefiles = esScroll("files", "", to_json({'query' => {'terms' => {'node' => \@nodes}}})); logmsg("\n") if ($verbose > 0); my %remotefileshash; foreach my $hit (@{$remotefiles}) { if (! -f $hit->{_source}->{name}) { progress("Removing " . $hit->{_source}->{name} . " id: " . $hit->{_id} . "\n"); esDelete("/${PREFIX}files/_doc/" . $hit->{_id}, 1); } else { $remotefileshash{$hit->{_source}->{name}} = $hit->{_source}; } } # Now see which local are missing foreach my $file (@localfiles) { my @stat = stat("$file"); if (!exists $remotefileshash{$file}) { $file =~ /\/([^\/]*)-(\d+)-(\d+).pcap/; my $node = $1; my $filenum = int($3); progress("Adding $file $node $filenum $stat[7]\n"); esPost("/${PREFIX}files/file/$node-$filenum", to_json({ 'locked' => 0, 'first' => $stat[10], 'num' => $filenum, 'name' => "$file", 'node' => $node, 'filesize' => $stat[7]}), 1); } elsif ($stat[7] != $remotefileshash{$file}->{filesize}) { progress("Updating filesize $file $stat[7]\n"); $file =~ /\/([^\/]*)-(\d+)-(\d+).pcap/; my $node = $1; my $filenum = int($3); $remotefileshash{$file}->{filesize} = $stat[7]; esPost("/${PREFIX}files/file/$node-$filenum", to_json($remotefileshash{$file}), 1); } } logmsg("\n") if ($verbose > 0); exit 0; } elsif ($ARGV[1] =~ /^(field)$/) { my $result = esGet("/${PREFIX}fields/_doc/$ARGV[3]", 1); my $found = $result->{found}; die "Field $ARGV[3] isn't found" if (!$found); esPost("/${PREFIX}fields/field/$ARGV[3]/_update", "{\"doc\":{\"disabled\":" . ($ARGV[2] eq "disable"?"true":"false"). "}}"); exit 0; } elsif ($ARGV[1] =~ /^force-?put-?version$/) { die "This command doesn't work anymore, use force-sessions3-update"; exit 0; } elsif ($ARGV[1] =~ /^set-?replicas$/) { esPost("/_flush/synced", "", 1); esPut("/${PREFIX}$ARGV[2]/_settings?master_timeout=${ESTIMEOUT}s", "{\"index.number_of_replicas\" : $ARGV[3]}"); exit 0; } elsif ($ARGV[1] =~ /^set-?shards-?per-?node$/) { esPost("/_flush/synced", "", 1); esPut("/${PREFIX}$ARGV[2]/_settings?master_timeout=${ESTIMEOUT}s", "{\"index.routing.allocation.total_shards_per_node\" : $ARGV[3]}"); exit 0; } elsif ($ARGV[1] =~ /^set-?allocation-?enable$/) { esPost("/_flush/synced", "", 1); if ($ARGV[2] eq "null") { esPut("/_cluster/settings?master_timeout=${ESTIMEOUT}s", "{ \"persistent\": { \"cluster.routing.allocation.enable\": null}}"); } else { esPut("/_cluster/settings?master_timeout=${ESTIMEOUT}s", "{ \"persistent\": { \"cluster.routing.allocation.enable\": \"$ARGV[2]\"}}"); } exit 0; } elsif ($ARGV[1] =~ /^allocate-?empty$/) { my $result = esPost("/_cluster/reroute?master_timeout=${ESTIMEOUT}s", "{ \"commands\": [{\"allocate_empty_primary\": {\"index\": \"$ARGV[3]\", \"shard\": \"$ARGV[4]\", \"node\": \"$ARGV[2]\", \"accept_data_loss\": true}}]}"); exit 0; } elsif ($ARGV[1] =~ /^unflood-?stage$/) { esPut("/${PREFIX}$ARGV[2]/_settings?master_timeout=${ESTIMEOUT}s", "{\"index.blocks.read_only_allow_delete\" : null}"); exit 0; } elsif ($ARGV[1] =~ /^ilm$/) { parseArgs(4); my $forceTime = $ARGV[2]; die "force time must be num followed by h or d" if ($forceTime !~ /^\d+[hd]/); my $deleteTime = $ARGV[3]; die "delete time must be num followed by h or d" if ($deleteTime !~ /^\d+[hd]/); $REPLICAS = 0 if ($REPLICAS == -1); $HISTORY = $HISTORY * 7; print "Creating history ilm policy '${PREFIX}molochhistory' with: deleteTime ${HISTORY}d\n"; print "Creating sessions ilm policy '${PREFIX}molochsessions' with: forceTime: $forceTime deleteTime: $deleteTime segments: $SEGMENTS replicas: $REPLICAS\n"; print "You will need to run db.pl upgrade with --ilm to update the templates the first time you turn ilm on.\n"; sleep 5; my $hpolicy = qq/ { "policy": { "phases": { "delete": { "min_age": "${HISTORY}d", "actions": { "delete": {} } } } } }/; esPut("/_ilm/policy/${PREFIX}molochhistory?master_timeout=${ESTIMEOUT}s", $hpolicy); esPut("/${PREFIX}history_v*/_settings?master_timeout=${ESTIMEOUT}s", qq/{"settings": {"index.lifecycle.name": "${PREFIX}molochhistory"}}/, 1); print "History Policy:\n$hpolicy\n" if ($verbose > 1); sleep 5; my $policy; if ($DOHOTWARM) { $policy = qq/ { "policy": { "phases": { "hot": { "min_age": "0ms", "actions": { "set_priority": { "priority": 95 } } }, "warm": { "min_age": "$forceTime", "actions": { "allocate": { "number_of_replicas": $REPLICAS, "require": { "molochtype": "warm" } }, "forcemerge": { "max_num_segments": $SEGMENTS }, "set_priority": { "priority": 10 } } }, "delete": { "min_age": "$deleteTime", "actions": { "delete": {} } } } } }/; } else { $policy = qq/ { "policy": { "phases": { "warm": { "min_age": "$forceTime", "actions": { "allocate": { "number_of_replicas": $REPLICAS }, "forcemerge": { "max_num_segments": $SEGMENTS }, "set_priority": { "priority": 10 } } }, "delete": { "min_age": "$deleteTime", "actions": { "delete": {} } } } } }/; } esPut("/_ilm/policy/${PREFIX}molochsessions?master_timeout=${ESTIMEOUT}s", $policy); esPut("/${OLDPREFIX}sessions2-*,${PREFIX}sessions3-*/_settings?master_timeout=${ESTIMEOUT}s", qq/{"settings": {"index.lifecycle.name": "${PREFIX}molochsessions"}}/, 1); print "Policy:\n$policy\n" if ($verbose > 1); exit 0; } elsif ($ARGV[1] =~ /^reindex$/) { my ($src, $dst); my $MODE = 0; if ($ARGV[-1] eq "--nopcap") { $MODE = 1; pop @ARGV; } elsif ($ARGV[-1] eq "--nopacketlen") { $MODE = 2; pop @ARGV; } if (scalar @ARGV == 3) { $src = $ARGV[2]; if ($src =~ /\*/) { showHelp("Can not have an * in src index name without supplying a dst index name"); } if ($src =~ /-shrink/) { $dst = $src =~ s/-shrink//rg } elsif ($src =~ /-reindex/) { $dst = $src =~ s/-reindex//rg } else { $dst = "$src-reindex"; } print "src: $src dst: $dst\n"; } elsif (scalar @ARGV == 4) { $src = $ARGV[2]; $dst = $ARGV[3]; } else { showHelp("Invalid arguments"); } my $query = {"source" => {"index" => $src}, "dest" => {"index" => $dst}, "conflicts" => "proceed"}; if ($MODE == 1) { $query->{script} = {"source" => 'ctx._source.remove("packetPos");ctx._source.remove("packetLen");ctx._source.remove("fileId");'}; } elsif ($MODE == 2) { $query->{script} = {"source" => 'ctx._source.remove("packetLen");'}; } my $result = esPost("/_reindex?wait_for_completion=false&slices=auto", to_json($query)); die Dumper($result) if (! exists $result->{task}); my $task = $result->{task}; print "task: $task\n"; sleep 10; my $srcCount = esGet("/$src/_count")->{count}; my $dstCount = esGet("/$dst/_count")->{count}; my $lastp = -1; while (1) { $result = esGet("/_tasks/$task"); $dstCount = esGet("/$dst/_count")->{count}; die Dumper($result->{error}) if (exists $result->{error}); my $p = int($dstCount * 100 / $srcCount); if ($lastp != $p) { print (scalar localtime() . " $p% ($dstCount/$srcCount)\n"); $lastp = $p; } last if ($result->{completed}); sleep 30; } esGet("/${dst}/_flush", 1); esGet("/${dst}/_refresh", 1); $srcCount = esGet("/$src/_count")->{count}; $dstCount = esGet("/$dst/_count")->{count}; die "Mismatch counts $srcCount != $dstCount" if ($srcCount != $dstCount); die "Not deleting src since would delete dst too" if ("${dst}*" eq "$src"); esDelete("/$src", 1); print "Deleted $src\n"; exit 0; } sub dataNodes { my ($nodes) = @_; my $total = 0; foreach my $key (keys %{$nodes}) { next if (exists $nodes->{$key}->{attributes} && exists $nodes->{$key}->{attributes}->{data} && $nodes->{$key}->{attributes}->{data} eq "false"); next if (exists $nodes->{$key}->{settings} && exists $nodes->{$key}->{settings}->{node} && $nodes->{$key}->{settings}->{node}->{data} eq "false"); $total++; } return $total; } my $health = dbCheckHealth(); my $nodes = esGet("/_nodes"); $main::numberOfNodes = dataNodes($nodes->{nodes}); logmsg "It is STRONGLY recommended that you stop ALL Arkime captures and viewers before proceeding. Use 'db.pl ${main::elasticsearch} backup' to backup db first.\n\n"; if ($main::numberOfNodes == 1) { logmsg "There is $main::numberOfNodes elastic search data node, if you expect more please fix first before proceeding.\n\n"; } else { logmsg "There are $main::numberOfNodes elastic search data nodes, if you expect more please fix first before proceeding.\n\n"; } if (int($SHARDS) > $main::numberOfNodes) { die "Can't set shards ($SHARDS) greater then the number of nodes ($main::numberOfNodes)"; } elsif ($SHARDS == -1) { $SHARDS = $main::numberOfNodes; if ($SHARDS > 24) { logmsg "Setting # of shards to 24, use --shards for a different number\n"; $SHARDS = 24; } } dbCheck(); dbVersion(1); if ($ARGV[1] eq "wipe" && $main::versionNumber != $VERSION) { die "Can only use wipe if schema is up to date. Use upgrade first."; } if ($ARGV[1] =~ /^(init|wipe|clean)/) { if ($ARGV[1] eq "init" && $main::versionNumber >= 0) { logmsg "It appears this elastic search cluster already has Arkime installed (version $main::versionNumber), this will delete ALL data in elastic search! (It does not delete the pcap files on disk.)\n\n"; waitFor("INIT", "do you want to erase everything?"); } elsif ($ARGV[1] eq "wipe") { logmsg "This will delete ALL session data in elastic search! (It does not delete the pcap files on disk or user info.)\n\n"; waitFor("WIPE", "do you want to wipe everything?"); } elsif ($ARGV[1] eq "clean") { waitFor("CLEAN", "do you want to clean everything?"); } logmsg "Erasing\n"; esDelete("/${PREFIX}sequence_v30,${OLDPREFIX}sequence_v3,${OLDPREFIX}sequence_v2,${OLDPREFIX}sequence_v1,${OLDPREFIX}sequence?ignore_unavailable=true", 1); esDelete("/${PREFIX}files_v30,${OLDPREFIX}files_v6,${OLDPREFIX}files_v5,${OLDPREFIX}files_v4,${OLDPREFIX}files_v3,${OLDPREFIX}files?ignore_unavailable=true", 1); esDelete("/${PREFIX}stats_v30,${OLDPREFIX}stats_v4,${OLDPREFIX}stats_v3,${OLDPREFIX}stats_v2,${OLDPREFIX}stats_v1,${OLDPREFIX}stats?ignore_unavailable=true", 1); esDelete("/${PREFIX}dstats_v30,${OLDPREFIX}dstats_v4,${OLDPREFIX}dstats_v3,${OLDPREFIX}dstats_v2,${OLDPREFIX}dstats_v1,${OLDPREFIX}dstats?ignore_unavailable=true", 1); esDelete("/${PREFIX}fields_v30,${OLDPREFIX}fields_v3,${OLDPREFIX}fields_v2,${OLDPREFIX}fields_v1,${OLDPREFIX}fields?ignore_unavailable=true", 1); esDelete("/${PREFIX}hunts_v30,${OLDPREFIX}hunts_v2,${OLDPREFIX}hunts_v1,${OLDPREFIX}hunts?ignore_unavailable=true", 1); esDelete("/${PREFIX}lookups_v30,${OLDPREFIX}lookups_v1,${OLDPREFIX}lookups?ignore_unavailable=true", 1); esDelete("/${OLDPREFIX}sessions-*", 1); esDelete("/${OLDPREFIX}sessions2-*", 1); esDelete("/${PREFIX}sessions3-*", 1); esDelete("/${OLDPREFIX}history_v1-*", 1); esDelete("/${PREFIX}history_v1-*", 1); esDelete("/_template/${OLDPREFIX}template_1", 1); esDelete("/_template/${OLDPREFIX}sessions_template", 1); esDelete("/_template/${OLDPREFIX}sessions2_template", 1); esDelete("/_template/${PREFIX}sessions3_template", 1); esDelete("/_template/${PREFIX}sessions3_ecs_template", 1); esDelete("/_template/${OLDPREFIX}history_v1_template", 1); esDelete("/_template/${PREFIX}history_v1_template", 1); if ($ARGV[1] =~ /^(init|clean)/) { esDelete("/${PREFIX}users_v30,${OLDPREFIX}users_v7,${OLDPREFIX}users_v6,${OLDPREFIX}users_v5,${OLDPREFIX}users?ignore_unavailable=true", 1); esDelete("/${PREFIX}queries_v30,${OLDPREFIX}queries_v3,${OLDPREFIX}queries_v2,${OLDPREFIX}queries_v1,${OLDPREFIX}queries?ignore_unavailable=true", 1); } esDelete("/tagger", 1); sleep(1); exit 0 if ($ARGV[1] =~ "clean"); logmsg "Creating\n"; sequenceCreate(); filesCreate(); statsCreate(); dstatsCreate(); sessions3Update(); fieldsCreate(); historyUpdate(); huntsCreate(); lookupsCreate(); if ($ARGV[1] =~ "init") { usersCreate(); queriesCreate(); } } elsif ($ARGV[1] =~ /^restore$/) { logmsg "It is STRONGLY recommended that you stop ALL Arkime captures and viewers before proceeding.\n"; dbCheckForActivity($PREFIX); my @indexes = ("users", "sequence", "stats", "queries", "hunts", "files", "fields", "dstats", "lookups"); my @filelist = (); foreach my $index (@indexes) { # list of data, settings, and mappings files push(@filelist, "$ARGV[2].${PREFIX}${index}.json\n") if (-e "$ARGV[2].${PREFIX}${index}.json"); push(@filelist, "$ARGV[2].${PREFIX}${index}.settings.json\n") if (-e "$ARGV[2].${PREFIX}${index}.settings.json"); push(@filelist, "$ARGV[2].${PREFIX}${index}.mappings.json\n") if (-e "$ARGV[2].${PREFIX}${index}.mappings.json"); } foreach my $index ("sessions2", "sessions3", "history") { # list of templates @filelist = (@filelist, "$ARGV[2].${PREFIX}${index}.template.json\n") if (-e "$ARGV[2].${PREFIX}${index}.template.json"); } push(@filelist, "$ARGV[2].${PREFIX}aliases.json\n") if (-e "$ARGV[2].${PREFIX}aliases.json"); my @directory = split(/\//,$ARGV[2]); my $basename = $directory[scalar(@directory)-1]; splice(@directory, scalar(@directory)-1, 1); my $path = join("/", @directory); die "Cannot find files start with ${basename}.${PREFIX} in $path" if (scalar(@filelist) == 0); logmsg "\nFollowing files will be used for restore\n\n@filelist\n\n"; waitFor("RESTORE", "do you want to restore? This will delete ALL data [@indexes] but sessions and history and restore from backups: files start with $basename in $path"); logmsg "\nStarting Restore...\n\n"; logmsg "Erasing data ...\n\n"; esDelete("/${OLDPREFIX}tags_v3", 1); esDelete("/${OLDPREFIX}tags_v2", 1); esDelete("/${OLDPREFIX}tags", 1); esDelete("/${OLDPREFIX}sequence", 1); esDelete("/${OLDPREFIX}sequence_v1", 1); esDelete("/${OLDPREFIX}sequence_v2", 1); esDelete("/${OLDPREFIX}sequence_v3", 1); esDelete("/${OLDPREFIX}files_v6", 1); esDelete("/${OLDPREFIX}files_v5", 1); esDelete("/${OLDPREFIX}files_v4", 1); esDelete("/${OLDPREFIX}files_v3", 1); esDelete("/${OLDPREFIX}files", 1); esDelete("/${OLDPREFIX}stats", 1); esDelete("/${OLDPREFIX}stats_v1", 1); esDelete("/${OLDPREFIX}stats_v2", 1); esDelete("/${OLDPREFIX}stats_v3", 1); esDelete("/${OLDPREFIX}stats_v4", 1); esDelete("/${OLDPREFIX}dstats", 1); esDelete("/${OLDPREFIX}dstats_v1", 1); esDelete("/${OLDPREFIX}dstats_v2", 1); esDelete("/${OLDPREFIX}dstats_v3", 1); esDelete("/${OLDPREFIX}dstats_v4", 1); esDelete("/${OLDPREFIX}fields", 1); esDelete("/${OLDPREFIX}fields_v1", 1); esDelete("/${OLDPREFIX}fields_v2", 1); esDelete("/${OLDPREFIX}fields_v3", 1); esDelete("/${OLDPREFIX}hunts_v2", 1); esDelete("/${OLDPREFIX}hunts_v1", 1); esDelete("/${OLDPREFIX}hunts", 1); esDelete("/${OLDPREFIX}users_v3", 1); esDelete("/${OLDPREFIX}users_v4", 1); esDelete("/${OLDPREFIX}users_v5", 1); esDelete("/${OLDPREFIX}users_v6", 1); esDelete("/${OLDPREFIX}users_v7", 1); esDelete("/${OLDPREFIX}users", 1); esDelete("/${OLDPREFIX}queries", 1); esDelete("/${OLDPREFIX}queries_v1", 1); esDelete("/${OLDPREFIX}queries_v2", 1); esDelete("/${OLDPREFIX}queries_v3", 1); esDelete("/${OLDPREFIX}lookups_v1", 1); esDelete("/_template/${OLDPREFIX}template_1", 1); esDelete("/_template/${OLDPREFIX}sessions_template", 1); esDelete("/_template/${OLDPREFIX}sessions2_template", 1); esDelete("/_template/${OLDPREFIX}history_v1_template", 1); esDelete("/${PREFIX}sequence_v3", 1); # should be 30 esDelete("/${PREFIX}fields_v30", 1); esDelete("/${PREFIX}queries_v30", 1); esDelete("/${PREFIX}files_v30", 1); esDelete("/${PREFIX}users_v30", 1); esDelete("/${PREFIX}dstats_v30", 1); esDelete("/${PREFIX}stats_v30", 1); esDelete("/${PREFIX}hunts_v30", 1); esDelete("/${PREFIX}lookups_v30", 1); esDelete("/_template/${PREFIX}sessions3_ecs_template", 1); esDelete("/_template/${PREFIX}sessions3_template", 1); esDelete("/_template/${PREFIX}history_v1_template", 1); logmsg "Importing settings...\n\n"; foreach my $index (@indexes) { # import settings if (-e "$ARGV[2].${PREFIX}${index}.settings.json") { open(my $fh, "<", "$ARGV[2].${PREFIX}${index}.settings.json"); my $data = do { local $/; <$fh> }; $data = from_json($data); my @index = keys %{$data}; delete $data->{$index[0]}->{settings}->{index}->{creation_date}; delete $data->{$index[0]}->{settings}->{index}->{provided_name}; delete $data->{$index[0]}->{settings}->{index}->{uuid}; delete $data->{$index[0]}->{settings}->{index}->{version}; my $settings = to_json($data->{$index[0]}); esPut("/$index[0]?master_timeout=${ESTIMEOUT}s", $settings); close($fh); } } logmsg "Importing aliases...\n\n"; if (-e "$ARGV[2].${PREFIX}aliases.json") { # import alias open(my $fh, "<", "$ARGV[2].${PREFIX}aliases.json"); my $data = do { local $/; <$fh> }; $data = from_json($data); foreach my $alias (@{$data}) { esAlias("add", $alias->{index}, $alias->{alias}, 1); } } logmsg "Importing mappings...\n\n"; foreach my $index (@indexes) { # import mappings if (-e "$ARGV[2].${PREFIX}${index}.mappings.json") { open(my $fh, "<", "$ARGV[2].${PREFIX}${index}.mappings.json"); my $data = do { local $/; <$fh> }; $data = from_json($data); my @index = keys %{$data}; my $mappings = $data->{$index[0]}->{mappings}; my @type = keys %{$mappings}; esPut("/$index[0]/$type[0]/_mapping?master_timeout=${ESTIMEOUT}s&pretty", to_json($mappings)); close($fh); } } logmsg "Importing documents...\n\n"; foreach my $index (@indexes) { # import documents if (-e "$ARGV[2].${PREFIX}${index}.json") { open(my $fh, "<", "$ARGV[2].${PREFIX}${index}.json"); my $data = do { local $/; <$fh> }; esPost("/_bulk", $data); close($fh); } } logmsg "Importing templates for Sessions and History...\n\n"; my @templates = ("sessions2", "sessions3", "history"); foreach my $template (@templates) { # import templates if (-e "$ARGV[2].${PREFIX}${template}.template.json") { open(my $fh, "<", "$ARGV[2].${PREFIX}${template}.template.json"); my $data = do { local $/; <$fh> }; $data = from_json($data); my @template_name = keys %{$data}; esPut("/_template/$template_name[0]?master_timeout=${ESTIMEOUT}s&include_type_name=true", to_json($data->{$template_name[0]})); close($fh); } } foreach my $template (@templates) { # update mappings if (-e "$ARGV[2].${PREFIX}${template}.template.json") { open(my $fh, "<", "$ARGV[2].${PREFIX}${template}.template.json"); my $data = do { local $/; <$fh> }; $data = from_json($data); my @template_name = keys %{$data}; my $mapping = $data->{$template_name[0]}->{mappings}; if (($template cmp "sessions2") == 0 && $UPGRADEALLSESSIONS) { my $indices = esGet("/${OLDPREFIX}sessions2-*/_alias", 1); logmsg "Updating sessions2 mapping for ", scalar(keys %{$indices}), " indices\n" if (scalar(keys %{$indices}) != 0); foreach my $i (keys %{$indices}) { progress("$i "); esPut("/$i/session/_mapping?master_timeout=${ESTIMEOUT}s&include_type_name=true", to_json($mapping), 1); } logmsg "\n"; } elsif (($template cmp "sessions3") == 0 && $UPGRADEALLSESSIONS) { my $indices = esGet("/${PREFIX}sessions3-*/_alias", 1); logmsg "Updating sessions3 mapping for ", scalar(keys %{$indices}), " indices\n" if (scalar(keys %{$indices}) != 0); foreach my $i (keys %{$indices}) { progress("$i "); esPut("/$i/_mapping?master_timeout=${ESTIMEOUT}s", to_json($mapping), 1); } logmsg "\n"; } elsif (($template cmp "history") == 0) { my $indices = esGet("/${PREFIX}history_v1-*/_alias", 1); logmsg "Updating history mapping for ", scalar(keys %{$indices}), " indices\n" if (scalar(keys %{$indices}) != 0); foreach my $i (keys %{$indices}) { progress("$i "); esPut("/$i/history/_mapping?master_timeout=${ESTIMEOUT}s&include_type_name=true", to_json($mapping), 1); } logmsg "\n"; } close($fh); } } logmsg "Finished Restore.\n"; } else { # Remaing is upgrade or upgradenoprompt # For really old versions don't support upgradenoprompt if ($main::versionNumber < 64) { logmsg "Can not upgrade directly, please upgrade to Moloch 2.4.x or 2.7.x first. (Db version $main::versionNumber)\n\n"; exit 1; } if ($health->{status} eq "red") { logmsg "Not auto upgrading when elasticsearch status is red.\n\n"; waitFor("RED", "do you want to really want to upgrade?"); } elsif ($ARGV[1] ne "upgradenoprompt") { logmsg "Trying to upgrade from version $main::versionNumber to version $VERSION.\n\n"; waitFor("UPGRADE", "do you want to upgrade?"); } logmsg "Starting Upgrade\n"; if ($main::versionNumber < 70) { checkForOld6Indices(); dbCheckForActivity($OLDPREFIX); esPost("/_flush/synced", "", 1); sequenceUpgrade(); createNewAliasesFromOld("${OLDPREFIX}fields", "${PREFIX}fields_v30", "${OLDPREFIX}fields_v3", \&fieldsCreate); createNewAliasesFromOld("${OLDPREFIX}queries", "${PREFIX}queries_v30", "${OLDPREFIX}queries_v3", \&queriesCreate); createNewAliasesFromOld("${OLDPREFIX}files", "${PREFIX}files_v30", "${OLDPREFIX}files_v6", \&filesCreate); createNewAliasesFromOld("${OLDPREFIX}users", "${PREFIX}users_v30", "${OLDPREFIX}users_v7", \&usersCreate); createNewAliasesFromOld("${OLDPREFIX}dstats", "${PREFIX}dstats_v30", "${OLDPREFIX}dstats_v4", \&dstatsCreate); createNewAliasesFromOld("${OLDPREFIX}stats", "${PREFIX}stats_v30", "${OLDPREFIX}stats_v4", \&statsCreate); createNewAliasesFromOld("${OLDPREFIX}hunts", "${PREFIX}hunts_v30", "${OLDPREFIX}hunts_v2", \&huntsCreate); createNewAliasesFromOld("${OLDPREFIX}lookups", "${PREFIX}lookups_v30", "${OLDPREFIX}lookups_v1", \&lookupsCreate); sessions3Update(); historyUpdate(); ecsFieldsUpdate(); esDelete("/_template/${OLDPREFIX}sessions2_template", 1); esDelete("/_template/${OLDPREFIX}history_v1_template", 1); } elsif ($main::versionNumber <= 70) { sessions3Update(); historyUpdate(); ecsFieldsUpdate(); } else { logmsg "db.pl is hosed\n"; } } if ($DOHOTWARM) { esPut("/${PREFIX}stats_v30,${PREFIX}dstats_v30,${PREFIX}fields_v30,${PREFIX}files_v30,${PREFIX}sequence_v30,${PREFIX}users_v30,${PREFIX}queries_v30,${PREFIX}hunts_v30,${PREFIX}history*,${PREFIX}lookups_v30/_settings?master_timeout=${ESTIMEOUT}s&allow_no_indices=true&ignore_unavailable=true", "{\"index.routing.allocation.require.molochtype\": \"warm\"}"); } else { esPut("/${PREFIX}stats_v30,${PREFIX}dstats_v30,${PREFIX}fields_v30,${PREFIX}files_v30,${PREFIX}sequence_v30,${PREFIX}users_v30,${PREFIX}queries_v30,${PREFIX}hunts_v30,${PREFIX}history*,${PREFIX}lookups_v30/_settings?master_timeout=${ESTIMEOUT}s&allow_no_indices=true&ignore_unavailable=true", "{\"index.routing.allocation.require.molochtype\": null}"); } logmsg "Finished\n"; sleep 1;
30.289821
553
0.428783
ed54ef8a339609717d3e8c4da9ee9dd3ba116045
10,841
pm
Perl
lib/Sam/Parser.pm
smyang2018/proovread
6f5a6b43e4a78b1c23fd80fc876e477feb377470
[ "MIT" ]
64
2015-02-23T10:33:01.000Z
2022-03-15T02:08:27.000Z
lib/Sam/Parser.pm
smyang2018/proovread
6f5a6b43e4a78b1c23fd80fc876e477feb377470
[ "MIT" ]
152
2015-03-30T19:47:32.000Z
2021-08-16T04:34:07.000Z
lib/Sam/Parser.pm
BioInf-Wuerzburg/proovread
6f5a6b43e4a78b1c23fd80fc876e477feb377470
[ "MIT" ]
22
2015-05-16T01:07:43.000Z
2021-08-29T15:48:42.000Z
package Sam::Parser; use warnings; use strict; use Sam::Alignment qw(:flags); our $VERSION = '1.3.3'; =head1 NAME Sam::Parser.pm =head1 DESCRIPTION Parser module for SAM format files. =cut =head1 SYNOPSIS use Sam::Parser; use Sam::Alignment ':flags'; my $sp = Sam::Parser->new( file => "file.bam" ); # parser for file handle and with customized is routine read starts with 'C' my $sp = Sam::Parser->new( fh => \*SAM, is => sub{ substr($_[0]->seq, 0, 1) eq 'C' } ); # header print $sp->header; # print read ids of all reads with bad quality while( my $aln = $sp->next_aln() ){ print $aln->qname() if $aln->is_bad_quality(); } # reset the 'is' routine $sp->is(MAPPED_BOTH); =cut =head1 Constructor METHOD =head2 new Initialize a sam parser object. Takes parameters in key => value format. my $sp = Sam::Parser->new(file => .sam/.bam); # lazy SAM from STDIN with samtools filter my $sp = Sam::Parser->new( samtools_opt => '-f 16 -q 20' # reverse only and mapping qual >20 ); # something a tad more fancy open(my $fh, 'samtools view file.bam | filter-bam |'); my $sp = Sam::Parser->new(fh => $fh); # write (only bam) my $sp = Sam::Parser->new( file => new.bam mode => '>', ); =cut my @ATTR_SCALAR = qw(file fh is mode samtools_path samtools_exe samtools_opt samtools region _header_fh _is_bai _idxstats_fh _idxstats ); my %SELF; @SELF{@ATTR_SCALAR} = (undef) x scalar @ATTR_SCALAR; sub new{ my $class = shift; my $self = { %SELF, # defaults mode => '<', samtools_exe => 'samtools', # overwrite defaults @_, # protected _is => undef, _is_bai => undef, _idxstats_fh => undef, }; bless $self, $class; # open file in read/write mode die "Either file or fh required\n" if ($self->file && $self->fh); $self->fh(\*STDIN) if (!$self->file && !$self->fh); $self->samtools_exe(join("/", grep{$_}($self->samtools_path, $self->samtools_exe))); $self->file2fh if $self->file; $self->cache_header unless $self->_is_bai; # prepare _is test routine $self->is($self->{is}) if $self->{is}; return $self; } sub DESTROY{ my $self = shift; foreach my $fh (qw(fh _header_fh _idxstats_fh)) { close $self->$fh if $self->$fh; } } ############################################################################ =head1 Object METHODS =cut =head2 region Get/set region. Only works with indexed BAM files. =cut sub region{ my ($self, $region) = @_; if (@_>1) { $self->{region} = $region; $self->file2fh; # update fh } return $self->{region}; } =head2 is Get/Set conditions that determine which alignments are returned by the next methods. Takes either a reference to a list of property bitmasks or a code reference to a customized test which returns 1 and 0 respectively. To explicitly deactivate testing, provide a value that evaluates to FALSE. For details on bitmasks see L<Sam::Alignment>. The test routine is executed with the parameters C<$parser_obj, $aln_obj> and for C<next_pair()> additionally with C< $aln_obj2 >. # parser returning only BAD_QUALITY alns my $sp = Sam::Parser->new( is => [Sam::Alignment->BAD_QUALITY] ); # customized parser that only returns reads with a GC content > 70%. my $sp = Sam::Parser->new( is => sub{ my ($self, $aln) = @_; return ($aln->seq =~ tr/GC//) / length($aln->seq) > .7 ? 1 : 0; }) # deactivate testing my $sp->is(0); =cut sub is{ my ($self, $is) = @_; if(@_== 2){ unless($is){ $self->{_is} = undef; }elsif(ref($is) eq 'ARRAY'){ $self->{_is} = eval 'sub{$_[0]->is('.join(', ', @$is).')}'; }elsif(ref($is) eq 'CODE'){ $self->{_is} = $is; }else{ die (((caller 0)[3])." neither ARRAY nor CODE reference given!\n"); } } return $self->{_is}; } =head2 header Get header as string. =cut sub header{ my ($self) = @_; return $self->{_header} if defined($self->{_header}); # cached my $cmd = $self->samtools("view -H", $self->file); return qx($cmd); } =head2 next_header Parse header, returns line as string in SCALAR context. In LIST context returns tag => value list, with @CO lines as CO => comment and raw => raw_line. Returns FALSE if no (more) matching header lines are in the file. Limit method to a subset of header lines by providing a specific tag: # print names of all reference sequences from header while(%h = $sp->next_header('@SQ')){ print $h{'SN'}."\n"; } =cut { # backward comp no warnings 'once'; *next_header_line = \&next_header; } sub next_header{ my ($self, $search_tag) = (@_, '@'); my $fh = $self->{_header_fh}; # loop if line buffer was empty or did not return # get next header line while ( my $sam = <$fh> ) { if (my ($tag, $content) = $sam =~ /^(\@?(?:$search_tag)\w{0,2})\s(.*)/) { if (wantarray) { return $tag eq '@CO' ? (CO => $content, raw => $sam, tag => $tag) : ($content =~ /(\w\w):(\S+)/g, raw => $sam, tag => $tag); } else { return $sam; } } next; } return; } =head2 next_aln Loop through sam file and return next 'Sam::Alignment' object (meeting the 'is' criteria if specified). =cut sub next_aln{ my ($self) = @_; my $sam = readline($self->{fh}); return unless defined $sam; # eof my $aln = Sam::Alignment->new($sam); return $aln if !$self->{_is} or &{$self->{_is}}($aln); return; } =head2 next_seq Return next Sam::Seq object. Only works with BAM. =cut sub next_seq{ my ($self) = @_; die (((caller 0)[3]).": only works on indexed BAM files\n") unless $self->_is_bai; my ($id, $len); if ($self->region){ ($id = $self->region) =~ s/(:([0-9,]+)|:([0-9,]+-[0-9,]+))$//; $len = ($self->idxstat($id))[1]; }else { ($id, $len) = $self->next_idxstat; ($id, $len) = $self->next_idxstat if $id eq "*"; # dont look at unmapped } return unless defined($id); my $ss = Sam::Seq->new(id => $id, len => $len); my $sp = Sam::Parser->new(file => $self->file, region => $id); while ( my $aln = $sp->next_aln ) { $ss->add_aln_by_score($aln); } return $ss; } =head2 next_idxstat Read idxstats. Returns LIST (id, len, #reads mapped, #reads unmapped). =cut sub next_idxstat{ my ($self) = @_; die (((caller 0)[3]).": only works on indexed BAM files\n") unless $self->_is_bai; my $s = readline($self->_idxstats_fh); return unless defined $s; chomp($s); return split("\t", $s) } =head2 append_aln Append an alignment to the file, provided as object or string. Returns the byte offset position in the file. NOTE: In case a string is provided, make sure it contains trailing newline since no further test is performed. =cut sub append_aln{ my ($self, $aln) = @_; my $pos = tell($self->{fh}); print {$self->{fh}} ref $aln ? $aln->raw : $aln; return $pos; } =head2 tell Return the byte offset of the current append filehandle position =cut { # backward no warnings 'once'; *append_tell = \&tell; } sub tell{ my ($self) = @_; return tell($self->{fh}); } =head2 fh, mode, samtools_exe, samtools_path Get/set ... =cut sub _init_accessors{ no strict 'refs'; # generate simple accessors closure style foreach my $attr ( @ATTR_SCALAR ) { next if $_[0]->can($attr); # don't overwrite explicitly created subs *{__PACKAGE__ . "::$attr"} = sub { $_[0]->{$attr} = $_[1] if @_ == 2; return $_[0]->{$attr}; } } } =head2 file Get/set SAM/BAM file. =cut sub file{ my ($self, $file) = @_; if (defined $file) { $self->{file} = $file; $self->file2fh(); # update filehandle } return $self->{file}; } =head2 file2fh Check file (sam/bam/bai) and open file handles accordingly. =cut sub file2fh{ my ($self) = @_; die (((caller 0)[3]).": only read '<' and write '>' mode supported\n") unless $self->mode eq '<' or $self->mode eq '>'; # write if ( $self->mode eq '>' ) { my $cmd = $self->samtools("view", $self->file); open($self->{fh}, "|-", $cmd) or die (((caller 0)[3]).": $!\n$cmd\n"); return $self->{fh}; } -e $self->file.'.bai' ? $self->_is_bai(1) : $self->_is_bai(0); # read die $self->file." doesn't exist\n" unless -e $self->file; if ( $self->_is_bai ){ my $cmd = $self->samtools("view", $self->samtools_opt, $self->file, $self->region); open($self->{fh}, "-|", $cmd) or die (((caller 0)[3]).": $!\n$cmd\n"); my $idxstats_cmd = $self->samtools("idxstats", $self->file); open($self->{_idxstats_fh}, "-|", $idxstats_cmd) or die (((caller 0)[3]).": $!\n$idxstats_cmd\n"); my $header_cmd = $self->samtools("view -H", $self->file); open($self->{_header_fh}, "-|", $header_cmd) or die (((caller 0)[3]).": $!\n$header_cmd\n"); }else{ # only one chance to cache header my $cmd = $self->samtools("view -h", $self->samtools_opt, $self->file, $self->region); open($self->{fh}, "-|", $cmd) or die (((caller 0)[3]).": $!\n$cmd\n"); } return $self->fh; } =head2 cache_header Read and cache header from stream. Automatically done if no .bai. =cut sub cache_header{ my ($self) = @_; my $fh = $self->fh; my $h = ''; my $c; while (1) { $c = $fh->getc(); last if ! defined($c) or $c ne '@'; $h.= $c.<$fh>; } $fh->ungetc(ord($c)) if defined $c; # push back peek $self->{_header} = $h; open($self->{_header_fh}, '<', \$self->{_header}) or die $!; } =head2 idxstat Get idxstat for specific ID. Parses and caches idxstats. =cut sub idxstat{ my ($self, $id) = @_; unless ( $self->_idxstats ) { my $idxstats_cmd = $self->samtools("idxstats", $self->file); open(IDX, '-|', $idxstats_cmd) or die (((caller 0)[3]).": $!\n$idxstats_cmd\n"); $self->{_idxstats} = {}; while (<IDX>) { chomp; my (@s) = split("\t", $_); $self->{_idxstats}{$s[0]} = \@s; } close IDX; } die "ID \"$id\" doesn't exists in bam index" unless exists $self->_idxstats->{$id}; return @{$self->_idxstats->{$id}}; } =head2 samtools Get samtools command. =cut sub samtools{ my ($self, @opt) = @_; my $cmd = join(" ", $self->samtools_exe, grep{defined $_}@opt); return $cmd; } # init closure accessors __PACKAGE__->_init_accessors(); =head1 AUTHOR Thomas Hackl S<thackl@lim4.de> =cut 1;
22.07943
123
0.561941
ed25a9becb4ccc9acbdfc448075ff9e48212f19e
104
pm
Perl
t/lib/MooX/C.pm
git-the-cpan/MooX
6c5403b7855e218d9d8df2255040011f325996a7
[ "Artistic-1.0" ]
null
null
null
t/lib/MooX/C.pm
git-the-cpan/MooX
6c5403b7855e218d9d8df2255040011f325996a7
[ "Artistic-1.0" ]
null
null
null
t/lib/MooX/C.pm
git-the-cpan/MooX
6c5403b7855e218d9d8df2255040011f325996a7
[ "Artistic-1.0" ]
null
null
null
package MooX::C; use strict; use warnings; sub import { $main::COUNT += 4 if $main::COUNT == 3; } 1;
10.4
40
0.615385
73ed5bd56056a1fc8911ddf980ac61807bf44986
1,145
pm
Perl
lib/Google/Ads/GoogleAds/V6/Services/AccountBudgetProposalService/AccountBudgetProposalOperation.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
lib/Google/Ads/GoogleAds/V6/Services/AccountBudgetProposalService/AccountBudgetProposalOperation.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
lib/Google/Ads/GoogleAds/V6/Services/AccountBudgetProposalService/AccountBudgetProposalOperation.pm
PierrickVoulet/google-ads-perl
bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4
[ "Apache-2.0" ]
null
null
null
# Copyright 2020, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. package Google::Ads::GoogleAds::V6::Services::AccountBudgetProposalService::AccountBudgetProposalOperation; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { create => $args->{create}, remove => $args->{remove}, updateMask => $args->{updateMask}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
30.131579
107
0.724017
ed0920a85f5352dad547ace7703a0bb663edadf8
198
pl
Perl
silk-src/src/rwtotal/tests/rwtotal-help.pl
mjschultz/netsa-pkg
07bf4ff29a73ebc0f58e4aa27d3ad6b1dee7fc83
[ "Apache-2.0" ]
3
2018-06-01T06:55:14.000Z
2021-11-14T22:51:04.000Z
silk-src/src/rwtotal/tests/rwtotal-help.pl
mjschultz/netsa-pkg
07bf4ff29a73ebc0f58e4aa27d3ad6b1dee7fc83
[ "Apache-2.0" ]
3
2017-07-02T17:03:34.000Z
2021-09-09T17:05:31.000Z
silk-src/src/rwtotal/tests/rwtotal-help.pl
mjschultz/netsa-pkg
07bf4ff29a73ebc0f58e4aa27d3ad6b1dee7fc83
[ "Apache-2.0" ]
4
2017-08-14T15:42:31.000Z
2022-01-24T16:24:27.000Z
#! /usr/bin/perl -w # STATUS: OK # TEST: ./rwtotal --help use strict; use SiLKTests; my $rwtotal = check_silk_app('rwtotal'); my $cmd = "$rwtotal --help"; exit (check_exit_status($cmd) ? 0 : 1);
16.5
40
0.641414
ed1ea19af5cafda455ab809350851696aff82b50
967
pl
Perl
demo_real/hypoDD/selectphase.pl
miguelj-neves/REAL
50b67f8392633c03027d013720059c6d97f4d9b0
[ "MIT" ]
57
2019-07-05T03:42:50.000Z
2022-03-20T09:36:29.000Z
demo_real/hypoDD/selectphase.pl
miguelj-neves/REAL
50b67f8392633c03027d013720059c6d97f4d9b0
[ "MIT" ]
2
2019-10-02T19:10:27.000Z
2021-09-30T08:01:43.000Z
demo_real/hypoDD/selectphase.pl
miguelj-neves/REAL
50b67f8392633c03027d013720059c6d97f4d9b0
[ "MIT" ]
22
2019-06-27T02:51:54.000Z
2021-11-16T02:46:00.000Z
#!/usr/bin/perl -w $phasein = "../VELEST/phase_allday.txt"; $event = "../VELEST/new.cat"; $phaseout = "italy.pha"; #phase format for hypoDD open(JK,"<$phasein"); @par = <JK>; close(JK); open(EV,"<$event"); @eves = <EV>; close(EV); open(EV,">$phaseout"); foreach $file(@par){ chomp($file); ($test,$jk) = split(' ',$file); if($test eq "#"){ ($jk,$year,$month,$day,$hour,$min,$sec,$lat,$lon,$dep,$jk,$jk,$jk,$jk,$num) = split(' ',,$file); $out = 0; foreach $eve(@eves){ chomp($eve); ($date,$hh,$mm,$ss,$lat1,$lon1,$dep1,$num0,$gap,$res) = split(" ",$eve); $num1 = $num0*100; #combine original picks & improved initial locations that obtained with VELEST if(abs($num-$num1)<1 && abs($hour*3600 + $min*60 + $sec - $hh*3600 - $mm*60 - $ss) < 1.5){ print EV "# $year $month $day $hour $min $sec $lat1 $lon1 $dep1 0 0 0 0 $num\n"; $out = 1; } } }else{ if($out>0){ printf EV "$file\n"; } } } close(EV);
24.794872
98
0.54395
73da789d2b7f9d94f585c4042dfa7fa8bbaf3ca2
821
t
Perl
t/30-Application/16-set_maximum_instances.t
guillaumeaubert/IPC-Concurrency-DBI
e4c272b3064e4360a3bb7621608c820851073c30
[ "Artistic-1.0" ]
null
null
null
t/30-Application/16-set_maximum_instances.t
guillaumeaubert/IPC-Concurrency-DBI
e4c272b3064e4360a3bb7621608c820851073c30
[ "Artistic-1.0" ]
1
2015-06-10T01:57:36.000Z
2015-06-10T01:57:36.000Z
t/30-Application/16-set_maximum_instances.t
guillaumeaubert/IPC-Concurrency-DBI
e4c272b3064e4360a3bb7621608c820851073c30
[ "Artistic-1.0" ]
null
null
null
#!perl use strict; use warnings; use IPC::Concurrency::DBI::Application; use Test::Exception; use Test::FailWarnings -allow_deps => 1; use Test::More tests => 6; use lib 't/'; use LocalTest; can_ok( 'IPC::Concurrency::DBI::Application', 'set_maximum_instances', ); my $dbh = LocalTest::ok_database_handle(); my $application; lives_ok( sub { $application = IPC::Concurrency::DBI::Application->new( database_handle => $dbh, name => 'cron_script.pl', ); }, 'Instantiate application.', ); is( $application->get_maximum_instances(), 10, 'Check the maximum instances allowed.', ); lives_ok( sub { $application->set_maximum_instances( 5 ); }, 'Set a new maximum instances number.', ); is( $application->get_maximum_instances(), 5, 'Check the maximum instances allowed.', );
15.203704
57
0.673569
ed2e2f021839b1d30d401c5d473f1761a8680a43
3,169
pm
Perl
auto-lib/Paws/CloudWatchLogs/ExportTask.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/CloudWatchLogs/ExportTask.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/CloudWatchLogs/ExportTask.pm
galenhuntington/aws-sdk-perl
13b775dcb5f0b3764f0a82f3679ed5c7721e67d3
[ "Apache-2.0" ]
null
null
null
package Paws::CloudWatchLogs::ExportTask; use Moose; has Destination => (is => 'ro', isa => 'Str', request_name => 'destination', traits => ['NameInRequest']); has DestinationPrefix => (is => 'ro', isa => 'Str', request_name => 'destinationPrefix', traits => ['NameInRequest']); has ExecutionInfo => (is => 'ro', isa => 'Paws::CloudWatchLogs::ExportTaskExecutionInfo', request_name => 'executionInfo', traits => ['NameInRequest']); has From => (is => 'ro', isa => 'Int', request_name => 'from', traits => ['NameInRequest']); has LogGroupName => (is => 'ro', isa => 'Str', request_name => 'logGroupName', traits => ['NameInRequest']); has Status => (is => 'ro', isa => 'Paws::CloudWatchLogs::ExportTaskStatus', request_name => 'status', traits => ['NameInRequest']); has TaskId => (is => 'ro', isa => 'Str', request_name => 'taskId', traits => ['NameInRequest']); has TaskName => (is => 'ro', isa => 'Str', request_name => 'taskName', traits => ['NameInRequest']); has To => (is => 'ro', isa => 'Int', request_name => 'to', traits => ['NameInRequest']); 1; ### main pod documentation begin ### =head1 NAME Paws::CloudWatchLogs::ExportTask =head1 USAGE This class represents one of two things: =head3 Arguments in a call to a service Use the attributes of this class as arguments to methods. You shouldn't make instances of this class. Each attribute should be used as a named argument in the calls that expect this type of object. As an example, if Att1 is expected to be a Paws::CloudWatchLogs::ExportTask object: $service_obj->Method(Att1 => { Destination => $value, ..., To => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::CloudWatchLogs::ExportTask object: $result = $service_obj->Method(...); $result->Att1->Destination =head1 DESCRIPTION Represents an export task. =head1 ATTRIBUTES =head2 Destination => Str The name of Amazon S3 bucket to which the log data was exported. =head2 DestinationPrefix => Str The prefix that was used as the start of Amazon S3 key for every object exported. =head2 ExecutionInfo => L<Paws::CloudWatchLogs::ExportTaskExecutionInfo> Execution info about the export task. =head2 From => Int The start time, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a time stamp before this time are not exported. =head2 LogGroupName => Str The name of the log group from which logs data was exported. =head2 Status => L<Paws::CloudWatchLogs::ExportTaskStatus> The status of the export task. =head2 TaskId => Str The ID of the export task. =head2 TaskName => Str The name of the export task. =head2 To => Int The end time, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a time stamp later than this time are not exported. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::CloudWatchLogs> =head1 BUGS and CONTRIBUTIONS The source code is located here: L<https://github.com/pplu/aws-sdk-perl> Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> =cut
28.809091
154
0.699905
ed52a6199d0c088bd7e4fef86813350748026799
591
pm
Perl
auto-lib/Paws/ServerlessRepo/PutApplicationPolicyResponse.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
164
2015-01-08T14:58:53.000Z
2022-02-20T19:16:24.000Z
auto-lib/Paws/ServerlessRepo/PutApplicationPolicyResponse.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
348
2015-01-07T22:08:38.000Z
2022-01-27T14:34:44.000Z
auto-lib/Paws/ServerlessRepo/PutApplicationPolicyResponse.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
87
2015-04-22T06:29:47.000Z
2021-09-29T14:45:55.000Z
package Paws::ServerlessRepo::PutApplicationPolicyResponse; use Moose; has Statements => (is => 'ro', isa => 'ArrayRef[Paws::ServerlessRepo::ApplicationPolicyStatement]', traits => ['NameInRequest'], request_name => 'statements'); has _request_id => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::ServerlessRepo::PutApplicationPolicyResponse =head1 ATTRIBUTES =head2 Statements => ArrayRef[L<Paws::ServerlessRepo::ApplicationPolicyStatement>] An array of policy statements applied to the application. =head2 _request_id => Str =cut
21.107143
161
0.730964
ed5dcb91e372174ca8cdc115c8339614043a52b1
575
t
Perl
t/0.90/use/Data_Object_Number_Func_Log.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
t/0.90/use/Data_Object_Number_Func_Log.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
t/0.90/use/Data_Object_Number_Func_Log.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
use 5.014; use strict; use warnings; use Test::More; # POD =name Data::Object::Number::Func::Log =abstract Data-Object Number Function (Log) Class =synopsis use Data::Object::Number::Func::Log; my $func = Data::Object::Number::Func::Log->new(@args); $func->execute; =inherits Data::Object::Number::Func =attributes arg1(NumberLike, req, ro) =libraries Data::Object::Library =description Data::Object::Number::Func::Log is a function object for Data::Object::Number. =cut # TESTING use_ok 'Data::Object::Number::Func::Log'; ok 1 and done_testing;
11.734694
78
0.693913
ed09d45f9a21a927a6424d0dfb473a0d22a2f826
1,052
pm
Perl
masses/plugins/Dumpmem.pm
mikiec84/spamassassin
45e3655120174b28f1081dcee7bf15f85437ab50
[ "Apache-2.0" ]
196
2015-01-13T03:55:31.000Z
2022-03-29T23:56:13.000Z
masses/plugins/Dumpmem.pm
mikiec84/spamassassin
45e3655120174b28f1081dcee7bf15f85437ab50
[ "Apache-2.0" ]
14
2015-04-08T09:44:37.000Z
2015-05-19T12:20:44.000Z
masses/plugins/Dumpmem.pm
isabella232/spamassassin
53b6bbc7f382be89e9e05f90d6564cd933015ea8
[ "Apache-2.0" ]
77
2015-01-13T04:35:30.000Z
2022-03-15T14:49:08.000Z
# Dumpmem - dump SpamAssassin memory structures to disk after each message # # use as follows: # # MEMDEBUG=1 ./mass-check --cf='loadplugin Dumpmem plugins/Dumpmem.pm' \ # [normal mass-check arguments] # # e.g. # # MEMDEBUG=1 ./mass-check --cf='loadplugin Dumpmem plugins/Dumpmem.pm' \ # --net -n -o spam:dir:/local/cor/recent/spam/high.2007010* package Dumpmem; use strict; use Mail::SpamAssassin; use Mail::SpamAssassin::Plugin; our @ISA = qw(Mail::SpamAssassin::Plugin); use Mail::SpamAssassin::Util::MemoryDump; sub new { my ($class, $mailsa) = @_; $class = ref($class) || $class; my $self = $class->SUPER::new($mailsa); warn "Dumpmem plugin loaded"; if (!$ENV{'MEMDEBUG'}) { warn "you forgot to set MEMDEBUG=1! are you sure you want that?"; } bless ($self, $class); return $self; } sub per_msg_finish { my ($self, $opts) = @_; Mail::SpamAssassin::Util::MemoryDump::MEMDEBUG(); Mail::SpamAssassin::Util::MemoryDump::MEMDEBUG_dump_obj( $opts->{permsgstatus}->{main}); } 1;
25.658537
74
0.647338
ed5a612efee1f7d5c2a926a3743258034d2c4d6b
12,185
pm
Perl
nfsroot/usr/share/perl/5.20.2/autodie.pm
simontakite/FAI
077f94c83700cdd29433d09372f916f9e277497b
[ "Apache-2.0" ]
1
2019-02-16T13:29:23.000Z
2019-02-16T13:29:23.000Z
nfsroot/usr/share/perl/5.20.2/autodie.pm
simontakite/FAI
077f94c83700cdd29433d09372f916f9e277497b
[ "Apache-2.0" ]
1
2018-08-21T03:56:33.000Z
2018-08-21T03:56:33.000Z
nfsroot/usr/share/perl/5.20.2/autodie.pm
simontakite/FAI
077f94c83700cdd29433d09372f916f9e277497b
[ "Apache-2.0" ]
null
null
null
package autodie; use 5.008; use strict; use warnings; use Fatal (); our @ISA = qw(Fatal); our $VERSION; # ABSTRACT: Replace functions with ones that succeed or die with lexical scope BEGIN { our $VERSION = '2.23'; # VERSION: Generated by DZP::OurPkg::Version } use constant ERROR_WRONG_FATAL => q{ Incorrect version of Fatal.pm loaded by autodie. The autodie pragma uses an updated version of Fatal to do its heavy lifting. We seem to have loaded Fatal version %s, which is probably the version that came with your version of Perl. However autodie needs version %s, which would have come bundled with autodie. You may be able to solve this problem by adding the following line of code to your main program, before any use of Fatal or autodie. use lib "%s"; }; # We have to check we've got the right version of Fatal before we # try to compile the rest of our code, lest we use a constant # that doesn't exist. BEGIN { # If we have the wrong Fatal, then we've probably loaded the system # one, not our own. Complain, and give a useful hint. ;) if ($Fatal::VERSION ne $VERSION) { my $autodie_path = $INC{'autodie.pm'}; $autodie_path =~ s/autodie\.pm//; require Carp; Carp::croak sprintf( ERROR_WRONG_FATAL, $Fatal::VERSION, $VERSION, $autodie_path ); } } # When passing args to Fatal we want to keep the first arg # (our package) in place. Hence the splice. sub import { splice(@_,1,0,Fatal::LEXICAL_TAG); goto &Fatal::import; } sub unimport { splice(@_,1,0,Fatal::LEXICAL_TAG); goto &Fatal::unimport; } 1; __END__ =head1 NAME autodie - Replace functions with ones that succeed or die with lexical scope =head1 SYNOPSIS use autodie; # Recommended: implies 'use autodie qw(:default)' use autodie qw(:all); # Recommended more: defaults and system/exec. use autodie qw(open close); # open/close succeed or die open(my $fh, "<", $filename); # No need to check! { no autodie qw(open); # open failures won't die open(my $fh, "<", $filename); # Could fail silently! no autodie; # disable all autodies } =head1 DESCRIPTION bIlujDI' yIchegh()Qo'; yIHegh()! It is better to die() than to return() in failure. -- Klingon programming proverb. The C<autodie> pragma provides a convenient way to replace functions that normally return false on failure with equivalents that throw an exception on failure. The C<autodie> pragma has I<lexical scope>, meaning that functions and subroutines altered with C<autodie> will only change their behaviour until the end of the enclosing block, file, or C<eval>. If C<system> is specified as an argument to C<autodie>, then it uses L<IPC::System::Simple> to do the heavy lifting. See the description of that module for more information. =head1 EXCEPTIONS Exceptions produced by the C<autodie> pragma are members of the L<autodie::exception> class. The preferred way to work with these exceptions under Perl 5.10 is as follows: use feature qw(switch); eval { use autodie; open(my $fh, '<', $some_file); my @records = <$fh>; # Do things with @records... close($fh); }; given ($@) { when (undef) { say "No error"; } when ('open') { say "Error from open"; } when (':io') { say "Non-open, IO error."; } when (':all') { say "All other autodie errors." } default { say "Not an autodie error at all." } } Under Perl 5.8, the C<given/when> structure is not available, so the following structure may be used: eval { use autodie; open(my $fh, '<', $some_file); my @records = <$fh>; # Do things with @records... close($fh); }; if ($@ and $@->isa('autodie::exception')) { if ($@->matches('open')) { print "Error from open\n"; } if ($@->matches(':io' )) { print "Non-open, IO error."; } } elsif ($@) { # A non-autodie exception. } See L<autodie::exception> for further information on interrogating exceptions. =head1 CATEGORIES Autodie uses a simple set of categories to group together similar built-ins. Requesting a category type (starting with a colon) will enable autodie for all built-ins beneath that category. For example, requesting C<:file> will enable autodie for C<close>, C<fcntl>, C<fileno>, C<open> and C<sysopen>. The categories are currently: :all :default :io read seek sysread sysseek syswrite :dbm dbmclose dbmopen :file binmode close chmod chown fcntl fileno flock ioctl open sysopen truncate :filesys chdir closedir opendir link mkdir readlink rename rmdir symlink unlink :ipc pipe :msg msgctl msgget msgrcv msgsnd :semaphore semctl semget semop :shm shmctl shmget shmread :socket accept bind connect getsockopt listen recv send setsockopt shutdown socketpair :threads fork :system system exec Note that while the above category system is presently a strict hierarchy, this should not be assumed. A plain C<use autodie> implies C<use autodie qw(:default)>. Note that C<system> and C<exec> are not enabled by default. C<system> requires the optional L<IPC::System::Simple> module to be installed, and enabling C<system> or C<exec> will invalidate their exotic forms. See L</BUGS> below for more details. The syntax: use autodie qw(:1.994); allows the C<:default> list from a particular version to be used. This provides the convenience of using the default methods, but the surety that no behavioral changes will occur if the C<autodie> module is upgraded. C<autodie> can be enabled for all of Perl's built-ins, including C<system> and C<exec> with: use autodie qw(:all); =head1 FUNCTION SPECIFIC NOTES =head2 print The autodie pragma B<<does not check calls to C<print>>>. =head2 flock It is not considered an error for C<flock> to return false if it fails due to an C<EWOULDBLOCK> (or equivalent) condition. This means one can still use the common convention of testing the return value of C<flock> when called with the C<LOCK_NB> option: use autodie; if ( flock($fh, LOCK_EX | LOCK_NB) ) { # We have a lock } Autodying C<flock> will generate an exception if C<flock> returns false with any other error. =head2 system/exec The C<system> built-in is considered to have failed in the following circumstances: =over 4 =item * The command does not start. =item * The command is killed by a signal. =item * The command returns a non-zero exit value (but see below). =back On success, the autodying form of C<system> returns the I<exit value> rather than the contents of C<$?>. Additional allowable exit values can be supplied as an optional first argument to autodying C<system>: system( [ 0, 1, 2 ], $cmd, @args); # 0,1,2 are good exit values C<autodie> uses the L<IPC::System::Simple> module to change C<system>. See its documentation for further information. Applying C<autodie> to C<system> or C<exec> causes the exotic forms C<system { $cmd } @args > or C<exec { $cmd } @args> to be considered a syntax error until the end of the lexical scope. If you really need to use the exotic form, you can call C<CORE::system> or C<CORE::exec> instead, or use C<no autodie qw(system exec)> before calling the exotic form. =head1 GOTCHAS Functions called in list context are assumed to have failed if they return an empty list, or a list consisting only of a single undef element. =head1 DIAGNOSTICS =over 4 =item :void cannot be used with lexical scope The C<:void> option is supported in L<Fatal>, but not C<autodie>. To workaround this, C<autodie> may be explicitly disabled until the end of the current block with C<no autodie>. To disable autodie for only a single function (eg, open) use C<no autodie qw(open)>. C<autodie> performs no checking of called context to determine whether to throw an exception; the explicitness of error handling with C<autodie> is a deliberate feature. =item No user hints defined for %s You've insisted on hints for user-subroutines, either by pre-pending a C<!> to the subroutine name itself, or earlier in the list of arguments to C<autodie>. However the subroutine in question does not have any hints available. =back See also L<Fatal/DIAGNOSTICS>. =head1 BUGS "Used only once" warnings can be generated when C<autodie> or C<Fatal> is used with package filehandles (eg, C<FILE>). Scalar filehandles are strongly recommended instead. When using C<autodie> or C<Fatal> with user subroutines, the declaration of those subroutines must appear before the first use of C<Fatal> or C<autodie>, or have been exported from a module. Attempting to use C<Fatal> or C<autodie> on other user subroutines will result in a compile-time error. Due to a bug in Perl, C<autodie> may "lose" any format which has the same name as an autodying built-in or function. C<autodie> may not work correctly if used inside a file with a name that looks like a string eval, such as F<eval (3)>. =head2 autodie and string eval Due to the current implementation of C<autodie>, unexpected results may be seen when used near or with the string version of eval. I<None of these bugs exist when using block eval>. Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval> statements, although it can be explicitly enabled inside a string C<eval>. Under Perl 5.10 only, using a string eval when C<autodie> is in effect can cause the autodie behaviour to leak into the surrounding scope. This can be worked around by using a C<no autodie> at the end of the scope to explicitly remove autodie's effects, or by avoiding the use of string eval. I<None of these bugs exist when using block eval>. The use of C<autodie> with block eval is considered good practice. =head2 REPORTING BUGS Please report bugs via the CPAN Request Tracker at L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=autodie>. =head1 FEEDBACK If you find this module useful, please consider rating it on the CPAN Ratings service at L<http://cpanratings.perl.org/rate?distribution=autodie> . The module author loves to hear how C<autodie> has made your life better (or worse). Feedback can be sent to E<lt>pjf@perltraining.com.auE<gt>. =head1 AUTHOR Copyright 2008-2009, Paul Fenwick E<lt>pjf@perltraining.com.auE<gt> =head1 LICENSE This module is free software. You may distribute it under the same terms as Perl itself. =head1 SEE ALSO L<Fatal>, L<autodie::exception>, L<autodie::hints>, L<IPC::System::Simple> I<Perl tips, autodie> at L<http://perltraining.com.au/tips/2008-08-20.html> =head1 ACKNOWLEDGEMENTS Mark Reed and Roland Giersig -- Klingon translators. See the F<AUTHORS> file for full credits. The latest version of this file can be found at L<https://github.com/pjf/autodie/tree/master/AUTHORS> . =cut
27.883295
80
0.639146
73fc9594368d2ac30e25139a7b0318bbf0eb66e2
380
pm
Perl
lib/Data/Object/Array/Func/Empty.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
lib/Data/Object/Array/Func/Empty.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
lib/Data/Object/Array/Func/Empty.pm
jjatria/do
57d98377cb76af78a9f1d07648e32e62271b326a
[ "Artistic-1.0" ]
null
null
null
package Data::Object::Array::Func::Empty; use 5.014; use strict; use warnings; use Data::Object 'Class'; extends 'Data::Object::Array::Func'; # VERSION # BUILD has arg1 => ( is => 'ro', isa => 'Object', req => 1 ); # METHODS sub execute { my ($self) = @_; my ($data) = $self->unpack; $#$data = -1; return $data; } sub mapping { return ('arg1'); } 1;
9.74359
41
0.563158
ed1f0b53a3f494a636a17de8120f7c6441857f70
10,577
pm
Perl
modules/EnsEMBL/Web/Document/Element/Configurator.pm
nakib103/ensembl-webcode
4814ccb25ff9925d80b71514c72793917614c614
[ "Apache-2.0" ]
16
2015-01-14T14:12:30.000Z
2021-01-27T15:28:52.000Z
modules/EnsEMBL/Web/Document/Element/Configurator.pm
nakib103/ensembl-webcode
4814ccb25ff9925d80b71514c72793917614c614
[ "Apache-2.0" ]
250
2015-01-05T13:03:19.000Z
2022-03-30T09:07:12.000Z
modules/EnsEMBL/Web/Document/Element/Configurator.pm
nakib103/ensembl-webcode
4814ccb25ff9925d80b71514c72793917614c614
[ "Apache-2.0" ]
98
2015-01-05T14:58:48.000Z
2022-02-15T17:11:32.000Z
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2021] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package EnsEMBL::Web::Document::Element::Configurator; # Generates the modal context navigation menu, used in dynamic pages use strict; use EnsEMBL::Web::Attributes; use base qw(EnsEMBL::Web::Document::Element::Content); sub tree :AccessorMutator; sub active :AccessorMutator; sub caption :AccessorMutator; sub content { my $self = shift; my $content = $self->{'form'}; $content .= $_->component_content for @{$self->{'panels'}}; $content .= '</form>' if $self->{'form'}; return $content; } sub get_json { my $self = shift; return { wrapper => qq{<div class="modal_wrapper config_wrapper"></div>}, content => $self->content, params => $self->{'json'}, panelType => $self->{'panel_type'} }; } sub init { my $self = shift; my $controller = shift; my $navigation = $controller->page->navigation; $self->init_config($controller); $navigation->tree($self->tree); $navigation->active($self->active); $navigation->caption($self->caption); $navigation->configuration(1); } sub init_config { my ($self, $controller, $url) = @_; my $hub = $controller->hub; my $action = $hub->action; my $view_config = $hub->get_viewconfig($action); my $img_url = $self->img_url; return unless $view_config; my $panel = $self->new_panel('Configurator', $controller, code => 'configurator'); my $image_config = $view_config->image_config_type ? $hub->get_imageconfig({type => $view_config->image_config_type, cache_code => 'configurator', species => $hub->species}) : undef; my $top_form = EnsEMBL::Web::Form->new({'class' => [qw(bgcolour _config_settings)], 'action' => '#'}); my $search_box; $view_config->build_form($controller->object, $image_config); if ($image_config) { if ($image_config->get_parameter('multi_species')) { my @sp = @{$image_config->species_list}; if (@sp) { my $species_select = $top_form->add_field({ 'field_class' => 'species_select', 'label' => 'Species to configure', 'inline' => 1, 'elements' => [{ 'element_class' => 'species_select_select', 'type' => 'dropdown', 'name' => 'species', 'class' => '_stt', 'values' => [ map { 'caption' => $_->[1], 'value' => $hub->url('Config', { 'species' => $_->[0], '__clear' => 1 }), 'class' => "_stt__$_->[0]", 'selected' => $hub->species eq $_->[0] ? 1 : 0 }, @sp ] }, { 'type' => 'noedit', 'is_html' => 1, 'no_input' => 1, 'value' => join('', map sprintf('<span class="_stt_%s"><img class="nosprite" src="%sspecies/48/%1$s.png" alt="" /></span>', $_->[0], $img_url), @sp) }] }); } } $search_box = qq{<div class="configuration_search"><input class="configuration_search_text" value="Find a track" name="configuration_search_text" /></div>}; $self->active($image_config->get_parameter('active_menu') || 'active_tracks'); } # Add config selector dropdown at the top $top_form->add_field({ 'field_class' => '_config_dropdown config_dropdown hidden', 'label' => 'Select from available configurations', 'elements' => [{ 'type' => 'dropdown', 'name' => 'config_selector', }, { 'type' => 'string', 'value' => 'Enter configuration name' }, { 'type' => 'submit', 'value' => 'Save', }] }); $top_form->add_hidden([{ 'name' => 'config_selector_url', 'value' => $hub->url('Config', {function => 'list_configs', '__clear' => 1}), 'class' => 'js_param' }, { 'name' => 'config_save_url', 'value' => $hub->url('Config', {function => 'save_config', '__clear' => 1}), 'class' => 'js_param' }, { 'name' => 'config_apply_url', 'value' => $hub->url('Config', {function => 'apply_config', '__clear' => 1}), 'class' => 'js_param' }]); if (!$self->active || !$view_config->tree->get_node($self->active)) { my @nodes = @{$view_config->tree->root->child_nodes}; $self->active(undef); while (!$self->active && scalar @nodes) { my $node = shift @nodes; $self->active($node->id) if $node->data->{'class'}; } } my $form = $view_config->form; if ($hub->param('matrix')) { $panel->{'content'} = $form->render; } else { $form->add_hidden({ name => 'component', value => $action, class => 'component' }); $panel->set_content($top_form->render . $search_box . $form->render . $self->save_as($hub->user, $view_config, $view_config->image_config_type)); } $self->{'panel_type'} = $form->js_panel; $self->add_panel($panel); $self->tree($view_config->tree); $self->caption('Configure view'); $self->{'json'} = $view_config->form->{'json'} || {}; #TODO - respect encapsulation $self->add_image_config_notes($controller) if ($image_config && !$hub->param('matrix')); } sub add_image_config_notes { my ($self, $controller) = @_; my $panel = $self->new_panel('Configurator', $controller, code => 'x', class => 'image_config_notes' ); my $img_url = $self->img_url; my $trackhub_link = $self->hub->url({'type' => 'UserData', 'action' => 'TrackHubSearch'}); $panel->set_content(qq( <div class="info-box"> <p>Looking for more data? Search the <a href="${trackhub_link}" class="modal_link">Trackhub Registry</a> for external sources of annotation</p> </div> <h2 class="clear">Key</h2> <div> <ul class="configuration_key"> <li><img src="${img_url}render/normal.gif" /><span>Track style</span></li> <li><img src="${img_url}strand-f.png" /><span>Forward strand</span></li> <li><img src="${img_url}strand-r.png" /><span>Reverse strand</span></li> <li><img src="${img_url}star-on.png" /><span>Favourite track</span></li> <li><img src="${img_url}16/info.png" /><span>Track information</span></li> </ul> </div> <div> <ul class="configuration_key"> <li><img src="${img_url}track-external.gif" /><span>External data</span></li> <li><img src="${img_url}track-user.gif" /><span>User-added track</span></li> </ul> </div> <p class="space-below">Please note that the content of external tracks is not the responsibility of the Ensembl project.</p> <p>URL-based tracks may either slow down your ensembl browsing experience OR may be unavailable as these are served and stored from other servers elsewhere on the Internet.</p> )); $self->add_panel($panel); } sub save_as { return ''; my ($self, $user, $view_config, $image_config) = @_; my $hub = $self->hub; my $data = $hub->config_adaptor->filtered_configs({ code => $image_config ? [ $view_config->code, $image_config ] : $view_config->code, active => '' }); my %groups = $user ? map { $_->group_id => $_ } $user->find_admin_groups : (); my ($configs, %seen, $save_to); foreach (sort { $a->{'name'} cmp $b->{'name'} } values %$data) { next if $seen{$_->{'config_key'}}; $seen{$_} = 1 for $_->{'config_key'}, $_->{'link_key'}; next if $_->{'record_type'} eq 'group' && !$groups{$_->{'record_type_id'}}; $configs .= sprintf( '<option value="%s" class="%1$s">%s%s</option>', $_->{'config_key'}, $_->{'name'}, $user ? sprintf(' (%s%s)', $_->{'record_type'} eq 'user' ? 'Account' : ucfirst $_->{'record_type'}, $_->{'record_type'} eq 'group' ? ': ' . $groups{$_->{'record_type_id'}}->name : '') : '' ); } my $existing = sprintf(' <div%s> <label>Existing configuration:</label> <select name="overwrite" class="existing%s"> <option value="">----------</option> %s </select> <h2>Or</h2> </div>', $configs ? '' : ' style="display:none"', $configs ? '' : ' disabled', $configs ); if ($user) { $save_to = sprintf(' <p> <label>Save to:</label> <span>Account <input type="radio" name="record_type" value="user" class="default save_to" checked /></span> <span>Session <input type="radio" name="record_type" value="session" class="save_to" /></span> %s </p>', scalar keys %groups ? '<span>Groups you administer <input type="radio" name="record_type" value="group" class="save_to" /></span>' : '' ); if (scalar keys %groups) { my %default_groups = map { $_ => 1 } @{$hub->species_defs->ENSEMBL_DEFAULT_USER_GROUPS || []}; $save_to .= '<div class="groups"><h4>Groups:</h4>'; foreach (sort { ($a->[0] <=> $b->[0]) || ($a->[1] cmp $b->[1]) } map [ $default_groups{$_->group_id}, lc $_->name, $_ ], values %groups) { $save_to .= sprintf(' <div class="form-field"> <label class="group ff-label">%s:</label> <div class="ff-right"><input type="checkbox" value="%s" name="group" class="group" /></div> </div>', $_->[2]->name, $_->[2]->group_id ); } $save_to .= '</div>'; } } else { $save_to = '<input type="hidden" name="record_type" value="session" />'; } return qq{ <div class="config_save_as"> <h1>Save configuration</h1> <form> $existing $save_to <p><label>Name:</label><input class="name" type="text" name="name" maxlength="255" /></p> <p><label>Description:</label><textarea class="desc" name="description" rows="5"></textarea></p> <input class="fbutton disabled" type="button" value="Save" /> </form> </div> }; } 1;
35.733108
194
0.571429
ed1788ce4e7b47c8c0ed356696b312bd26b1a89c
464
pm
Perl
lib/Krawfish/Koral/Compile/Enrich/Snippet/Hit.pm
KorAP/Krawfish-prototype
1ec0229d15c23c5ca2e1734425d5fdd5212a1e30
[ "BSD-2-Clause" ]
null
null
null
lib/Krawfish/Koral/Compile/Enrich/Snippet/Hit.pm
KorAP/Krawfish-prototype
1ec0229d15c23c5ca2e1734425d5fdd5212a1e30
[ "BSD-2-Clause" ]
null
null
null
lib/Krawfish/Koral/Compile/Enrich/Snippet/Hit.pm
KorAP/Krawfish-prototype
1ec0229d15c23c5ca2e1734425d5fdd5212a1e30
[ "BSD-2-Clause" ]
null
null
null
package Krawfish::Koral::Compile::Enrich::Snippet::Hit; use Krawfish::Compile::Segment::Enrich::Snippet::Hit; use strict; use warnings; # Define the hit object # (e.g. which annotations should occur) sub new { my $class = shift; warn 'DEPRECATED!'; bless { @_ }, $class; }; sub identify { $_[0]; }; sub optimize { my $self = shift; Krawfish::Compile::Segment::Enrich::Snippet::Hit->new( %$self ); }; sub to_string { return 'hit'; }; 1;
14.060606
56
0.637931
ed4ba1f4a277cf0a926f0841c9e2da8eefe1b950
2,281
pl
Perl
data/processed/0.4_0.5_150/survey_80_769949150_True.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/0.4_0.5_150/survey_80_769949150_True.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
data/processed/0.4_0.5_150/survey_80_769949150_True.pl
VincentDerk/Paper-AC-Decisions-Learning
abd1dc8893fbb11b43ebb49a25e26c0183bdba62
[ "Apache-2.0" ]
null
null
null
body_1(0,multi) :- true. body_20(19,multi) :- true. body_36(33,multi) :- a("young"), s("M"). body_52(49,multi) :- a("young"), s("F"). body_67(64,multi) :- a("adult"), s("M"). body_82(79,multi) :- a("adult"), s("F"). body_97(94,multi) :- a("old"), s("M"). body_112(109,multi) :- a("old"), s("F"). body_125(124,multi) :- e("high"). body_139(138,multi) :- e("uni"). body_152(151,multi) :- e("high"). body_166(165,multi) :- e("uni"). body_181(178,multi) :- o("emp"), r("small"). body_202(199,multi) :- o("emp"), r("big"). body_222(219,multi) :- o("self"), r("small"). body_242(239,multi) :- o("self"), r("big"). query(o("self")). query(a("young")). query(t("car")). query(a("adult")). query(t("other")). query(r("small")). query(o("emp")). query(e("high")). query(t("train")). query(e("uni")). query(a("old")). query(s("F")). query(s("M")). query(r("big")). utility(\+(o("self")),-31). utility(a("young"),17). utility(\+(t("car")),48). utility(t("other"),-49). utility(\+(t("other")),36). utility(r("small"),-8). utility(\+(r("small")),3). utility(o("emp"),-17). utility(e("high"),-8). utility(\+(e("high")),29). utility(t("train"),33). utility(\+(t("train")),-37). utility(e("uni"),-23). utility(a("old"),-10). utility(\+(a("old")),-9). utility(s("F"),-34). utility(\+(s("F")),50). utility(s("M"),-8). utility(r("big"),-19). 0.3::a("young"); 0.5::a("adult"); 0.2::a("old") :- body_1(0,multi). 0.75::e("high"); 0.25::e("uni") :- body_36(33,multi). 0.2::r("small"); 0.8::r("big") :- body_166(165,multi). 0.58::t("car"); 0.24::t("train"); 0.18::t("other") :- body_202(199,multi). 0.72::e("high"); 0.28::e("uni") :- body_67(64,multi). 0.92::o("emp"); 0.08::o("self") :- body_139(138,multi). 0.7::t("car"); 0.21::t("train"); 0.09::t("other") :- body_242(239,multi). 0.9::e("high"); 0.1::e("uni") :- body_112(109,multi). 0.7::e("high"); 0.3::e("uni") :- body_82(79,multi). 0.64::e("high"); 0.36::e("uni") :- body_52(49,multi). 0.48::t("car"); 0.42::t("train"); 0.1::t("other") :- body_181(178,multi). 0.6::s("M"); 0.4::s("F") :- body_20(19,multi). 0.25::r("small"); 0.75::r("big") :- body_152(151,multi). 0.56::t("car"); 0.36::t("train"); 0.08::t("other") :- body_222(219,multi). 0.96::o("emp"); 0.04::o("self") :- body_125(124,multi). 0.88::e("high"); 0.12::e("uni") :- body_97(94,multi).
34.560606
74
0.547567
ed40233cf5750eee6534f926fddefb66b1cbcf5b
742
pm
Perl
t/Class/Declare/Attributes/Multi/Three.pm
denormal/perl-Class-Declare-Attributes
07ec56eefa794c3d8412362a965531b7b9e88875
[ "Artistic-2.0" ]
null
null
null
t/Class/Declare/Attributes/Multi/Three.pm
denormal/perl-Class-Declare-Attributes
07ec56eefa794c3d8412362a965531b7b9e88875
[ "Artistic-2.0" ]
null
null
null
t/Class/Declare/Attributes/Multi/Three.pm
denormal/perl-Class-Declare-Attributes
07ec56eefa794c3d8412362a965531b7b9e88875
[ "Artistic-2.0" ]
null
null
null
#!/usr/bin/perl -Tw # $Id: Three.pm 1515 2010-08-22 14:41:53Z ian $ # Helper class for multiple inheritance test # - unlike Class::Declare, Class::Declare::Attributes doesn't support # on-the-fly generation of modules (Attributes::Handlers is unable to # return a meaningful glob for a method generated through a string # eval()), so we must explicitly generate modules for testing, rather # than have the test script generate them for us. package Class::Declare::Attributes::Multi::Three; use strict; use warnings; use base qw( Class::Declare::Attributes ); # define a public method sub c : public { 3 }; ################################################################################ 1; # end of module __END__
32.26087
80
0.636119
ed6e39a7f4f1e6ab4b807b70b3a96778a52fb516
8,514
pl
Perl
config_d05.pl
codesshaman/moulinette
1f641e5441803f3881eb9cf540c2c08f4640da5e
[ "MIT" ]
23
2021-03-06T17:10:36.000Z
2022-03-30T12:10:13.000Z
config_d05.pl
mrv8x/42-moulinette-auto-test1
08b985220cb3228eae59bf080af01ad6484cf72e
[ "MIT" ]
null
null
null
config_d05.pl
mrv8x/42-moulinette-auto-test1
08b985220cb3228eae59bf080af01ad6484cf72e
[ "MIT" ]
9
2021-01-14T08:37:40.000Z
2022-03-27T04:33:10.000Z
ex00 ft_putstr(char *str) main -m ==== ft_putstr("asdf"); ft_putstr(" qwerty\n"); ft_putstr("zxcv"); ==== check -e ==== $expected = "asdf qwerty\nzxcv"; ==== ex01 ft_putnbr(int nb) main_basic -m ==== ft_putnbr(123456); ==== check_basic -e ==== $expected = '123456'; ==== main_negative -m ==== ft_putnbr(-987654321); ==== check_negative -e ==== $expected = '-987654321'; ==== main_zero -m ==== ft_putnbr(0); ==== check_zero -e ==== $expected = '0'; ==== main_intmax -m ==== ft_putnbr(2147483647); ==== check_intmax -e ==== $expected = '2147483647'; ==== main_intnmax -m ==== ft_putnbr(-2147483648); ==== check_intnmax -e ==== $expected = '-2147483648'; ==== ex02 int ft_atoi(char *str) main_basic -p -m ==== $code = 'int res; int exp;'; my @tests = qw/ 0 15 -25 12345 987654321 -34567 2147483647 -2147483648 /; foreach (@tests) { $code .= "res = ft_atoi(\"$_\"), exp = $_;\n"; $code .= "printf(\"ft_atoi('$_') ($_ vs %d) -> %d\\n\", res, res == exp);\n"; } ==== check_basic -l=6 ==== ==== main_junk -m ==== TEST(ft_atoi("\t\n\v\f\r +256"), 256); TEST(ft_atoi("256a99999"), 256); ==== check_jump -l=2 ==== ==== ex03 char* ft_strcpy(char* dest, char* src) main -m ==== char test1[256] = "asdf"; printf("%s", ft_strcpy(test1, "qwerty\n")); printf("%s", ft_strcpy(test1, "")); printf("%s", ft_strcpy(test1, "hell0\n")); ==== check -e ==== $expected = "qwerty\nhell0\n"; ==== ex04 char* ft_strncpy(char* dest, unsigned int n) main -m ==== char test1[256] = "asdf"; char test2[256] = "asdf"; char test3[256] = "asdf"; printf("%s\n", ft_strncpy(test1, "uiop", 5)); printf("%s\n", ft_strncpy(test2, "qwerty", 4)); printf("%s\n", ft_strncpy(test3, "z", 1)); ==== check -e ==== $expected = "uiop\nqwer\nzsdf\n"; ==== ex05 char* ft_strstr(char* str, char* to_find) main -m ==== printf("%s\n", ft_strstr("asdf qwerty", "wer")); printf("%s\n", ft_strstr("asdf qwerty qwerty", "wer")); printf("%s\n", ft_strstr("asdf qwerty", "qwerty1")); printf("%s\n", ft_strstr("", "wer")); printf("%s\n", ft_strstr("asdf qwerty", "zxcv")); printf("%s\n", ft_strstr("asdf qwerty", "")); ==== check -e ==== $expected = "werty\nwerty qwerty\n(null)\n(null)\n(null)\nasdf qwerty\n"; ==== ex06 int ft_strcmp(char* s1, char* s2) main -p -m ==== my %tests = ( asdf_asdf => 0, asde_asdf => -1, asdg_asdf => 1, _ => 0, A_ => 0x41, _A => -0x41, ); $code = 'int exp, res;'; foreach (sort keys %tests) { my ($left, $right) = split '_', $_; $code .= "res = ft_strcmp(\"$left\", \"$right\"), exp = $tests{$_};\n"; $code .= "printf(\"ft_strcmp('$left', '$right') (%d vs %d) -> %d\\n\", exp, res, res == exp);\n"; } ==== check -l=6 ==== ==== ex07 int ft_strncmp(char* s1, char* s2, unsigned int n) main -p -m ==== my %tests = ( asdf_asdf_4 => 0, asde_asdf_4 => -1, asdg_asdf_4 => 1, asdf_asdf_3 => 0, asde_asdf_3 => 0, __0 => 0, ); $code = 'int res, exp;'; foreach (sort keys %tests) { my ($left, $right, $len) = split _ => $_; $code .= "res = ft_strncmp(\"$left\", \"$right\", $len), exp = $tests{$_};\n"; $code .= "printf(\"ft_strncmp('$left', '$right', $len) (%d vs %d) -> %d\\n\", exp, res, res == exp);\n"; } ==== check -l=6 ==== ==== ex08 char* ft_strupcase(char* str) main -m ==== char str[] = "asdf qWeRtY ZXCV"; printf("%s", ft_strupcase(str)); ==== check -e ==== $expected = 'ASDF QWERTY ZXCV'; ==== ex09 char* ft_strlowcase(char* str) main -m ==== char str[] = "asdf qWeRtY ZXCV"; printf("%s", ft_strlowcase(str)); ==== check -e ==== $expected = 'asdf qwerty zxcv'; ==== ex10 char* ft_strcapitalize(char* str) main -m ==== char str[] = "asdf qWeRtY ZXCV 100TIS\n"; printf("%s", ft_strcapitalize(str)); char str2[] = "asdf-qWeRtY ZXCV 100TIS"; printf("%s", ft_strcapitalize(str2)); ==== check -e ==== $expected = "Asdf Qwerty Zxcv 100tis\nAsdf-Qwerty Zxcv 100tis"; ==== ex11 int ft_str_is_alpha(char* str) main -p -m ==== my %tests = ( asdf => 1, QWERTY => 1, asdf1234 => 0, '999' => 0, '' => 1, ); $code = join '', map "TEST(ft_str_is_alpha(\"$_\"), $tests{$_});\n", sort keys %tests; ==== check -l=5 ==== ==== ex12 int ft_str_is_numeric(char* str) main -p -m ==== my %tests = ( 123456 => 1, asdf1234 => 0, 0 => 1, '' => 1, '12345asdf' => 0, ); $code = join '', map "TEST(ft_str_is_numeric(\"$_\"), $tests{$_});\n", sort keys %tests; ==== check -l=5 ==== ==== ex13 int ft_str_is_lowercase(char* str) main -p -m ==== my %tests = ( asdf => 1, asdF => 0, ASDF => 0, 1234 => 0, '' => 1, ); $code = join '', map "TEST(ft_str_is_lowercase(\"$_\"), $tests{$_});\n", sort keys %tests; ==== check -l=5 ==== ==== ex14 int ft_str_is_uppercase(char* str) main -p -m ==== my %tests = ( ASDF => 1, ASDf => 0, asdf => 0, 1234 => 0, '' => 1, ); $code = join '', map "TEST(ft_str_is_uppercase(\"$_\"), $tests{$_});\n", sort keys %tests; ==== check -l=5 ==== ==== ex15 int ft_str_is_printable(char* str) main -p -m ==== my %tests = ( asdf => 1, 1234 => 1, ASDF => 1, '!@#$^&*()_+-=[]{}:;,./<>?' => 1, "\\xf0" => 0, "\\x7f" => 0, "\\n" => 0, '' => 1, ); $code = join '', map "TEST(ft_str_is_printable(\"$_\"), $tests{$_});\n", sort keys %tests; ==== check -l=8 ==== ==== ex16 char* ft_strcat(char* dest, char* src) main -m ==== char test[256] = ""; printf("%s\n", ft_strcat(test, "asdf")); printf("%s\n", ft_strcat(test, "")); printf("%s\n", ft_strcat(test, "zxcv")); ==== check -e ==== $expected = "asdf\nasdf\nasdfzxcv\n"; ==== ex17 char* ft_strncat(char* dest, char* src, int nb) main -m ==== char test[256] = "zxcvzxcvzxcvxzcvzxcvzxcv"; char test1[256] = "zxcvzxcvzxcvxzcvzxcvzxcv"; char test2[256] = "zxcvzxcvzxcvxzcvzxcvzxcv"; char test3[256] = "zxcvzxcvzxcvxzcvzxcvzxcv"; printf("%s\n", ft_strncat(test, "asdf", 16)); printf("%s\n", ft_strncat(test1, "", 16)); printf("%s\n", ft_strncat(test2, "qwerty", 0)); printf("%s\n", ft_strncat(test3, "asdf", 3)); ==== check -e ==== $expected = "zxcvzxcvzxcvxzcvzxcvzxcvasdf\nzxcvzxcvzxcvxzcvzxcvzxcv\nqwerty\nqwertyasd\n"; ==== ex18 unsigned int ft_strlcat(char* dest, char* src, unsigned int size) main -m ==== char test[256] = "\0zxcvzxcvzxcvxzcvzxcv"; printf("%d-", ft_strlcat(test, "asdf", 16)); printf("%s\n", test); printf("%d-", ft_strlcat(test, "asdf", 6)); printf("%s\n", test); printf("%d-", ft_strlcat(test, "asdf", 4)); printf("%s\n", test); printf("%d-", ft_strlcat(test, "", 16)); printf("%s\n", test); printf("%d-", ft_strlcat(test, "asdf", 0)); printf("%s\n", test); ==== check -e ==== $expected = "4-asdf\n8-asdfa\n8-asdfa\n5-asdfa\n4-asdfa\n"; ==== ex19 unsigned int ft_strlcpy(char* dest, char* src, unsigned int size) main -m ==== char test[256] = "\0zxcvzxcvzxcvxzcvzxcv"; printf("%d-", ft_strlcpy(test, "asdf", 16)); printf("%s\n", test); printf("%d-", ft_strlcpy(test, "uiop", 0)); printf("%s\n", test); printf("%d-", ft_strlcpy(test, "qwerty", 4)); printf("%s\n", test); printf("%d-", ft_strlcpy(test, "", 4)); printf("%s\n", test); ==== check -e ==== $expected = "4-asdf\n4-asdf\n6-qwe\n0-\n"; ==== ex20 ft_putnbr_base(int nbr, char* base) main_basic -m ==== ft_putnbr_base(40, "0123456789abcdef"); ==== check_basic -e ==== $expected = "28"; ==== main_basic2 -m ==== ft_putnbr_base(31, "0123456789abcdef"); ==== check_basic2 -e ==== $expected = "1f"; ==== main_binary -m ==== ft_putnbr_base(15, "01"); ==== check_binary -e ==== $expected = '1111'; ==== main_negative -m ==== ft_putnbr_base(-15, "0123456789"); ft_putnbr_base(-16, "01"); ==== check_negative -e ==== $expected = '-15-10000'; ==== main_intmax -m ==== ft_putnbr_base(2147483647, "0123456789abcdef"); ft_putnbr_base(-2147483648, "0123456789abcdef"); ==== check_intmax -e ==== $expected = '7fffffff-80000000'; ==== ex21 int ft_atoi_base(char* str, char* base) main -p -m ==== my %tests = ( _15_0123456789 => 15, _3f_0123456789abcdef => 63, _a_0a => 1, '_-15_0123456789' => -15, '_-111_01' => -7, _a_0 => 0, _1_012341234 => 0, '_1_01234+' => 0, _5_01234 => 0, __01234 => 0, ); foreach (sort keys %tests) { my (undef, $str, $base) = split '_'; $code .= "TEST(ft_atoi_base(\"$str\", \"$base\"), $tests{$_});\n"; } ==== check -l=10 ==== ==== ex22 ft_putstr_non_printable(char* str) main -m ==== ft_putstr_non_printable("asdf\x7f\x1fhi\x01\xfflol"); ==== check -e ==== $expected = 'asdf\\7f\\1fhi\\01\\fflol'; ==== ex23 void* ft_print_memory(void* addr, unsigned int size) main -m ==== ft_print_memory("asdfasdfqwertytyzxcvzxcv\0\0\xff\x7f\x01", 29); ==== check -e ==== $expected = '00000000: 6173 6466 6173 6466 7177 6572 7479 7479 asdfasdfqwertyty 00000010: 7a78 6376 7a78 6376 0000 ff7f 01 zxcvzxcv..... '; ====
22.056995
105
0.584684
ed5616b64e60d107f9adb3dfd1ebda0b3dbe30d3
1,866
pl
Perl
geneidsgenenames.pl
bzhanglab/glad4u
132718f54590bc3bd7f13616de000ac3dd31acdf
[ "Apache-2.0" ]
2
2019-06-28T13:33:38.000Z
2020-10-06T13:23:32.000Z
geneidsgenenames.pl
bzhanglab/glad4u
132718f54590bc3bd7f13616de000ac3dd31acdf
[ "Apache-2.0" ]
null
null
null
geneidsgenenames.pl
bzhanglab/glad4u
132718f54590bc3bd7f13616de000ac3dd31acdf
[ "Apache-2.0" ]
null
null
null
#!/usr/local/bin/perl # #/****************************************************************************************** # * This code will go through the NCBI All_Data.gene_info file and create a new file where * # * each line contains a gene ID with all the MIM IDs describing this gene. * # ******************************************************************************************/ my (@buf, %gene, $temp); open(INPUT, "<../resources/All_Data.gene_info"); open(INPUT2, "<../resources/names.dmp"); open(OUTPUT1, ">../geneidsgenenames.txt"); open(OUTPUT2, ">../genenamesgeneids.txt"); open(OUTPUT3, ">../geneidsgenenames-homo.txt"); open(OUTPUT4, ">../genenamesgeneids-homo.txt"); open(OUTPUT5, ">../taxidstaxnames.txt"); while (<INPUT>) { if (/\t/) { @buf = split(/\t/); $buf[0] =~ s/\n//g; $buf[1] =~ s/\n//g; $buf[2] =~ s/\n//g; if (@buf>3) { $gene{$buf[0]}{$buf[1]}{$buf[2]} = 1; } } } while (<INPUT2>) { if (/scientific name/) { @buf = split(/\t/); $buf[0] =~ s/\n//g; $buf[2] =~ s/\n//g; if (@buf>3) { # $taxid{$buf[0]} = $buf[2]; print OUTPUT5 "$buf[0]\t$buf[2]\n"; } } } foreach my $key (keys %gene) { foreach my $key2 (keys %{$gene{$key}}) { $temp = 0; print(OUTPUT1 "$key2\t"); if ($key=~/9606/) { print(OUTPUT3 "$key2\t"); } foreach my $key3 (keys %{$gene{$key}{$key2}}) { if ($temp!=0) { print(OUTPUT1 ","); if ($key=~/9606/) { print(OUTPUT3 ","); } } print(OUTPUT1 "$key3"); if ($key=~/9606/) { print(OUTPUT3 "$key3"); } print(OUTPUT2 "$key3\t$key2"); if ($key=~/9606/) { print(OUTPUT4 "$key3\t$key2"); } $temp++; } print(OUTPUT1 "\t$key\n"); if ($key=~/9606/) { print(OUTPUT3 "\n"); } print(OUTPUT2 "\t$key\n"); if ($key=~/9606/) { print(OUTPUT4 "\n"); } } } close(INPUT); close(OUTPUT1); close(OUTPUT2); close(OUTPUT3); close(OUTPUT4);
27.441176
93
0.494641
73e552ab2ff13f91e3bf1ca3206a1ab28da38c17
10,766
pm
Perl
ImageDocker/ExifTool/lib/Image/ExifTool/InDesign.pm
kelvinjjwong/ImageDocker
aa5a5ea08881d11acc15846a6b650755d54457dd
[ "MIT" ]
5
2019-03-09T02:26:18.000Z
2020-04-06T17:35:39.000Z
ImageDocker/ExifTool/lib/Image/ExifTool/InDesign.pm
kelvinjjwong/ImageDocker
aa5a5ea08881d11acc15846a6b650755d54457dd
[ "MIT" ]
1
2019-07-21T06:50:54.000Z
2019-07-21T06:53:20.000Z
ImageDocker/ExifTool/lib/Image/ExifTool/InDesign.pm
kelvinjjwong/ImageDocker
aa5a5ea08881d11acc15846a6b650755d54457dd
[ "MIT" ]
2
2019-05-10T09:58:25.000Z
2020-01-03T05:56:42.000Z
#------------------------------------------------------------------------------ # File: InDesign.pm # # Description: Read/write meta information in Adobe InDesign files # # Revisions: 2009-06-17 - P. Harvey Created # # References: 1) http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart3.pdf #------------------------------------------------------------------------------ package Image::ExifTool::InDesign; use strict; use vars qw($VERSION); use Image::ExifTool qw(:DataAccess :Utils); $VERSION = '1.05'; # map for writing metadata to InDesign files (currently only write XMP) my %indMap = ( XMP => 'IND', ); # GUID's used in InDesign files my $masterPageGUID = "\x06\x06\xed\xf5\xd8\x1d\x46\xe5\xbd\x31\xef\xe7\xfe\x74\xb7\x1d"; my $objectHeaderGUID = "\xde\x39\x39\x79\x51\x88\x4b\x6c\x8E\x63\xee\xf8\xae\xe0\xdd\x38"; my $objectTrailerGUID = "\xfd\xce\xdb\x70\xf7\x86\x4b\x4f\xa4\xd3\xc7\x28\xb3\x41\x71\x06"; #------------------------------------------------------------------------------ # Read or write meta information in an InDesign file # Inputs: 0) ExifTool object reference, 1) dirInfo reference # Returns: 1 on success, 0 if this wasn't a valid InDesign file, or -1 on write error sub ProcessIND($$) { my ($et, $dirInfo) = @_; my $raf = $$dirInfo{RAF}; my $outfile = $$dirInfo{OutFile}; my ($hdr, $buff, $buf2, $err, $writeLen, $foundXMP); # validate the InDesign file return 0 unless $raf->Read($hdr, 16) == 16; return 0 unless $hdr eq $masterPageGUID; return 0 unless $raf->Read($buff, 8) == 8; $et->SetFileType($buff eq 'DOCUMENT' ? 'INDD' : 'IND'); # set the FileType tag # read the master pages $raf->Seek(0, 0) or $err = 'Seek error', goto DONE; unless ($raf->Read($buff, 4096) == 4096 and $raf->Read($buf2, 4096) == 4096) { $err = 'Unexpected end of file'; goto DONE; # (goto's can be our friend) } SetByteOrder('II'); unless ($buf2 =~ /^\Q$masterPageGUID/) { $err = 'Second master page is invalid'; goto DONE; } my $seq1 = Get64u(\$buff, 264); my $seq2 = Get64u(\$buf2, 264); # take the most current master page my $curPage = $seq2 > $seq1 ? \$buf2 : \$buff; # byte order of stream data may be different than headers my $streamInt32u = Get8u($curPage, 24); if ($streamInt32u == 1) { $streamInt32u = 'V'; # little-endian int32u } elsif ($streamInt32u == 2) { $streamInt32u = 'N'; # big-endian int32u } else { $err = 'Invalid stream byte order'; goto DONE; } my $pages = Get32u($curPage, 280); $pages < 2 and $err = 'Invalid page count', goto DONE; my $pos = $pages * 4096; if ($pos > 0x7fffffff and not $et->Options('LargeFileSupport')) { $err = 'InDesign files larger than 2 GB not supported (LargeFileSupport not set)'; goto DONE; } if ($outfile) { # make XMP the preferred group for writing $et->InitWriteDirs(\%indMap, 'XMP'); Write($outfile, $buff, $buf2) or $err = 1, goto DONE; my $result = Image::ExifTool::CopyBlock($raf, $outfile, $pos - 8192); unless ($result) { $err = defined $result ? 'Error reading InDesign database' : 1; goto DONE; } $writeLen = 0; } else { $raf->Seek($pos, 0) or $err = 'Seek error', goto DONE; } # scan through the contiguous objects for XMP my $verbose = $et->Options('Verbose'); my $out = $et->Options('TextOut'); for (;;) { $raf->Read($hdr, 32) or last; unless (length($hdr) == 32 and $hdr =~ /^\Q$objectHeaderGUID/) { # this must be null padding or we have an error $hdr =~ /^\0+$/ or $err = 'Corrupt file or unsupported InDesign version'; last; } my $len = Get32u(\$hdr, 24); if ($verbose) { printf $out "Contiguous object at offset 0x%x (%d bytes):\n", $raf->Tell(), $len; if ($verbose > 2) { my $len2 = $len < 1024000 ? $len : 1024000; my %parms = (Addr => $raf->Tell()); $parms{MaxLen} = $verbose > 3 ? 1024 : 96 if $verbose < 5; $raf->Seek(-$raf->Read($buff, $len2), 1) or $err = 1; HexDump(\$buff, undef, %parms); } } # check for XMP if stream data is long enough # (56 bytes is just enough for XMP header) if ($len > 56) { $raf->Read($buff, 56) == 56 or $err = 'Unexpected end of file', last; if ($buff =~ /^(....)<\?xpacket begin=(['"])\xef\xbb\xbf\2 id=(['"])W5M0MpCehiHzreSzNTczkc9d\3/s) { my $lenWord = $1; # save length word for writing later $len -= 4; # get length of XMP only $foundXMP = 1; # I have a sample where the XMP is 107 MB, and ActivePerl may run into # memory troubles (with its apparent 1 GB limit) if the XMP is larger # than about 400 MB, so guard against this if ($len > 300 * 1024 * 1024) { my $msg = sprintf('Insanely large XMP (%.0f MB)', $len / (1024 * 1024)); if ($outfile) { $et->Error($msg, 2) and $err = 1, last; } elsif ($et->Options('IgnoreMinorErrors')) { $et->Warn($msg); } else { $et->Warn("$msg. Ignored.", 1); $err = 1; last; } } # load and parse the XMP data unless ($raf->Seek(-52, 1) and $raf->Read($buff, $len) == $len) { $err = 'Error reading XMP stream'; last; } my %dirInfo = ( DataPt => \$buff, Parent => 'IND', NoDelete => 1, # do not allow this to be deleted when writing ); # validate xmp data length (should be same as length in header - 4) my $xmpLen = unpack($streamInt32u, $lenWord); unless ($xmpLen == $len) { if ($xmpLen < $len) { $dirInfo{DirLen} = $xmpLen; } else { $err = 'Truncated XMP stream (missing ' . ($xmpLen - $len) . ' bytes)'; } } my $tagTablePtr = GetTagTable('Image::ExifTool::XMP::Main'); if ($outfile) { last if $err; # make sure that XMP is writable my $classID = Get32u(\$hdr, 20); $classID & 0x40000000 or $err = 'XMP stream is not writable', last; my $xmp = $et->WriteDirectory(\%dirInfo, $tagTablePtr); if ($xmp and length $xmp) { # write new xmp with leading length word $buff = pack($streamInt32u, length $xmp) . $xmp; # update header with new length and invalid checksum Set32u(length($buff), \$hdr, 24); Set32u(0xffffffff, \$hdr, 28); } else { $$et{CHANGED} = 0; # didn't change anything $et->Warn("Can't delete XMP as a block from InDesign file") if defined $xmp; # put length word back at start of stream $buff = $lenWord . $buff; } } else { $et->ProcessDirectory(\%dirInfo, $tagTablePtr); } $len = 0; # we got the full stream (nothing left to read) } else { $len -= 56; # we got 56 bytes of the stream } } else { $buff = ''; # must reset this for writing later } if ($outfile) { # write object header and data Write($outfile, $hdr, $buff) or $err = 1, last; my $result = Image::ExifTool::CopyBlock($raf, $outfile, $len); unless ($result) { $err = defined $result ? 'Truncated stream data' : 1; last; } $writeLen += 32 + length($buff) + $len; } elsif ($len) { # skip over remaining stream data $raf->Seek($len, 1) or $err = 'Seek error', last; } $raf->Read($buff, 32) == 32 or $err = 'Unexpected end of file', last; unless ($buff =~ /^\Q$objectTrailerGUID/) { $err = 'Invalid object trailer'; last; } if ($outfile) { # make sure object UID and ClassID are the same in the trailer substr($hdr,16,8) eq substr($buff,16,8) or $err = 'Non-matching object trailer', last; # write object trailer Write($outfile, $objectTrailerGUID, substr($hdr,16)) or $err = 1, last; $writeLen += 32; } } if ($outfile) { # write null padding if necessary # (InDesign files must be an even number of 4096-byte blocks) my $part = $writeLen % 4096; Write($outfile, "\0" x (4096 - $part)) or $err = 1 if $part; } DONE: if (not $err) { $et->Warn('No XMP stream to edit') if $outfile and not $foundXMP; return 1; # success! } elsif (not $outfile) { # issue warning on read error $et->Warn($err) unless $err eq '1'; } elsif ($err ne '1') { # set error and return success code $et->Error($err); } else { return -1; # write error } return 1; } 1; # end __END__ =head1 NAME Image::ExifTool::InDesign - Read/write meta information in Adobe InDesign files =head1 SYNOPSIS This module is used by Image::ExifTool =head1 DESCRIPTION This module contains routines required by Image::ExifTool to read XMP meta information from Adobe InDesign (.IND, .INDD and .INDT) files. =head1 LIMITATIONS 1) Only XMP meta information is processed. 2) A new XMP stream may not be created, so XMP tags may only be written to InDesign files which previously contained XMP. 3) File sizes of greater than 2 GB are supported only if the system supports them and the LargeFileSupport option is enabled. =head1 AUTHOR Copyright 2003-2018, Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 REFERENCES =over 4 =item L<http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart3.pdf> =back =head1 SEE ALSO L<Image::ExifTool(3pm)|Image::ExifTool> =cut
38.177305
111
0.514304
ed3f01f9fd9c0a2cadd5c76ec809e869433d23e8
10,498
t
Perl
t/20_is.t
wollmers/Text-Guess-Language
e2c0eeefccf5c11108a942515198ee17fa5abb29
[ "Artistic-1.0" ]
null
null
null
t/20_is.t
wollmers/Text-Guess-Language
e2c0eeefccf5c11108a942515198ee17fa5abb29
[ "Artistic-1.0" ]
3
2016-03-06T23:15:42.000Z
2017-10-27T17:58:51.000Z
t/20_is.t
wollmers/Text-Guess-Language
e2c0eeefccf5c11108a942515198ee17fa5abb29
[ "Artistic-1.0" ]
null
null
null
#!perl use 5.008; use strict; use warnings; use utf8; use lib qw(../lib/); use Test::More; my $class = 'Text::Guess::Language'; use_ok($class); my $text =<<TEXT; Mannréttindayfirlýsing Sameinuðo Þjóðanna. Inngangsorð Það ber að viðurkenna, að hver maður sé jafnborinn til virðingar og réttinda, er eigi verði af honum tekin, og er þetta undirstaða frelsis, réttlætis og friðar i heiminum. Hafi mannréttindi verið fyrir borð borin og lítilsvirt, hefur slíkt haft í för með sér siðlausar athafnir, er ofboðið hafa samvizku mannkynsins, enda hefur því verið yfir lýst, að æðsta markmið almennings um heim allan sé að skapa veröld, þar sem menn fái notið málfrelsis , trúfrelsis og óttaleysis um einkalíf afkomu. Mannréttindi á að vernda með lögum. Að öðrum kosti hljóta menn að grípa til þess örþrifaráðs að rísa upp gegn kúgun og ofbeldi. Það er mikilsvert að efla vinsamleg samskipti þjóða í milli. Í stofnskrá sinni hafa Sameinuðu þjóðdirnar lýst yfir trú sinni á grundvallaratriði mannréttinda, á göfgi og gildi mannsins og jafnrétti karla og kvernna, enda munu þær beita sér fyrir félagslegum framförum og betri lífsafkomu með auknu frelsi manna. Aðildarríkin hafa bundizt samtökum um að efla almenna virðingu fyrir og gæzlu hinna mikilsverðustu mannréttinda í samráði við Sameinuðu þjóðirnar. Til þess að slík samtök megi sem best takast, er það ákaflega mikilvægt, að almennur skilningur verði vakinn á eðli slíkra réttinda og frjálsræðis. Fyrir því hefur allsherjarþing Sameinuðu þjóðanna fallizt á mannréttindayfirlýsingu þá, sem hér með er birt öllum þjóðum og ríkjum til fyrirmyndar. Skulu einstaklingar og yfirvöld jafnan hafa yfirlýsingu þessa í huga og kappkosta með fræðslu og uppeldi að efla virðingu fyrir réttindum Þeim og frjálstræÞi, sem hér er að stefnt. Ber og hverjum einum að stuðla Þeim framförum, innan ríkis og ríkja í milli, er að markmiðum yfirlýsingarinnar stefna, tryggja almenna og virka viðurkenningu á grundvallaratriðum hennar og sjá um, að Þau verði í heiðri höfó, bæði meðal Þjóða aðildarríkjanna sjálfra og meðal Þjóða á landsvæðum Þeim, er hlita lögsögu aðildarríkja. 1. grein. Hver maður er borinn frjáls og jafn öðrum að virðingu og réttindum. Menn eru gæddir vitsmunum og samvizku, og ber þeim að breyta bróðurlega hverjum við annan. 2. grein. Hver maður skal eiga kröfu á réttindum þeim og því frjálsræði, sem fólgin eru í yfirlýsingu þessari, og skal þar engan greinarmun gera vegna kynþáttar, litarháttar, kynferðis, tungu, trúar, stjórnmálaskoðana eða annarra skoðana, þjóðernis, uppruna, eigna, ætternis eða annarra aðstæðna. Eigi má heldur gera greinarmun á mönnum fyrir sakir stjórnskipulags lands þeirra eða landsvæðis, þjóðréttarstöðu þess eða lögsögu yfir því, hvort sem landið er sjálfstætt ríki, umráðasvæði, sjálfstjórnarlaust eða á annan hátt háð takmörkunum á fullveldi sínu. 3. grein. Allir menn eiga rétt til lífs, frelsis og mannhelgi. 4. grein. Engan mann skal hneppa í þrældóm né nauðungarvinnu. Þrælahald og þrælaverzlun, hverju nafni sem nefnist, skulu bönnuð. 5. grein. Enginn maður skal sæta pyndingum, grimmilegri, ómannlegri eða vanvirðandi meðferð eða refsingu. 6. grein. Allir menn skulu, hvar í heimi sem er, eiga kröfu á að vera viðurkenndir aðilar að lögum. 7. grein. Allir menn skulu jafnir fyrir lögunum og eiga rétt á jafnri vernd þeirra, án manngreinarálits. Ber öllum mönnum réttur til verndar gegn hvers konar misrétti, sem í bága brýtur við yfirlýsingu þessa, svo og gagnvart hvers konar áróðri til þess að skapa slíkt misrétti. 8. grein. Nú sætir einhver maður meðferð, er brýtur í bága við grundvallarréttindi þau, sem tryggð eru í stjórnarskrá og lögum, og skal hann þá eiga athvarf hjá dómstólum landsins til þess að fa hlut sinn réttan. 9. grein. Ekki má eftir geðþótta taka menn fasta, hneppa þá i fangelsi eða varðhald né gera útlæga. 10. grein. Nú leikur vafi á um réttindi þegns og skyldur, eða hann er borinn sökum um glæpsamlegt athæfi, og skal hann þá njóta fulls jafnréttis við aðra menn um réttláta opinbera rannsókn fÞrir óháðum og óhlutdrægum dómstóli. 11. grein. Hvern þann mann, sem borinn er sökum fyrir refsivert athæfi, skal telja saklausan, unz sök hans her sönnuð lögfullri sönnun fÞrir opinberum dómstóli, enda hafi tryggilega verið búið um vörn sakbornings. Engan skal telja sekan til refsingar, nema verknaður sá eða aðgerðaleysi, sem hann er borinn, varði refsingu að landslögum eða þjóðarétti á þeim tíma, er máli skiptir. Eigi má heldur dæma hann til þyngri refsingar en þeirrar, sem að lögum var leyfð, þegar verknaðurinn var framinn. 12. grein. Eigi má eftir geðþótta raska heimilisfriði nokkurs manns, hnýsast í einkamál hans eða bréf, vanvirða hann eða spilla mannorði hans. Ber hverjum manni lagavernd gagnvart slíkum afskiptum eða árásum. 13. grein. Frjálsir skulu menn vera ferða sinna og dvalar innan landamæra hvers ríkis. Rétt skal mönnum vera að fara af landi burt, hvort sem er af sínu landi eða öðru, og eiga afturkvæmt til heimalands síns. 14. grein. Rétt skal mönnum vera að leita og njóta griðlands erlendis gegn ofsóknum. Enginn má þó skírskota til slíkra réttinda, sem lögsóttur er með réttu fyrir ópólitísk afbrot eða atferli, er brýtur í bága við markmið og grundvallarreglur Sameinuðu þjóðanna. 15. grein. Allir menn hafa rétt til ríkisfangs. Engan mann má eftir geðþótta svipta ríkisfangi né rétti til þess að skipta um ríkisfang. 16. grein. Konum og körlum, sem hafa aldur til þess að lögum, skal heimilt að stofna til hjúskapar og fjölskyldu, án tillits til kynþáttar, þjóðernis eða trúarbragða. Þau skulu njóta jafnréttis um stofnun og slit hjúskapar, svo og í hjónabandinu. Eigi má hjúskap binda, nema bæði hjónæfni samþykki fúsum vilja. Fjölskyldan er í eðli sínu frumeining þjóðfélagsins, og ber þjóðfélagi og ríki að vernda hana. 17. grein. Hverjum manni skal heimilt að eiga eignir, einum sér eða í félagi við aðra. Engan má eftir geðþótta svipta eign sinni. 18. grein. Allir menn skulu frjálsir hugsana sinna, sanfæringar og trúar. Í þessu felst frjálsræði til að skipta um trú eða játningu og enn fremur til að láta í ljós trú sína eða játningu, einir sér eða í félagi við aðra, opinberlega eða einslega, með kennslu, tilbeiðslu, guðsþjónustum og helgihaldi. 19. grein. Hver maður skal frjáls skoðana sinna og að því að láta þær í ljós. Felur slíkt frjálsræði í sér réttindi til þess að leita, taka við og dreifa vitneskju og hugmyndum með hverjum hætti sem vera skal og án tillits til landamæra. 20. grein. Hverjum manni skal frjálst að eiga þátt í friðsamlegum fundahöldum og félagsskap. Engan mann má neyða til að vera í félagi. 21. grein. Hverjum manni er heimilt að taka þátt í stjórn lands síns, beinlínis eða með því að kjósa til þess fulltrúa frjálsum kosningum. Hver maður á jafnan rétt til þess að gegna opinberum störfum í landi sínu. Vilji þjóðarinnar skal vera grundvöllur að valdi ríkisstjórnar. Skal hann látinn í ljós með reglubundnum, óháðum og almennum kosningum, enda sé kosningarréttur jafn og leynileg atkvæðagreiðsla viðhöfð eða jafngildi hennar að frjálsræði. 22. grein. Hver þjóðfélagsþegn skal fyrir atbeina hins opinbera eða alþjóðasamtaka og í samræmi við skipulag og efnahag hvers ríkis eiga kröfu á félagslegu öryggi og þeim efnahagslegum, félagslegum og menningarlegum réttindum, sem honum eru nauðsynleg til þess að virðing hans og þroski fái notið sin. 23. grein. Hver maður á rétt á atvinnu að frjálsu vali, á réttlátum og hagkvænum vinnuskilyrðum og á vernd gegn atvinnuleysi. Hverjum manni ber sama greiðsla fyrir sama verk, án manngreinarálits. Allir menn, sem vinnu stunda, skulu bera úr býtum réttlátt og hagstætt endurgjald, er tryggi þeim og fjölskyldum þeirra mannsæm lífskjör. Þeim ber og önnur félagsleg vernd, ef þörf krefur. Hver maður má stofna til stéttarsamtaka og ganga í þau til verndar hagsmunum sínum. 24. grein. Hverjum manni ber réttur til hvíldar og tómstunda, og telst þar til hæfileg takmörkun vinnutíma og reglubundið orlof að óskertum launum. 25. grein. Hver maður á kröfu til lífskjara, sem nauðsynleg eru til verndar heilsu og vellíðan hans sjálfs og fjölskyldu hans. Telst þar til matur, klæðnaður, húsnæði, læknishjálp og nauðsynleg félagshjálp, svo og réttindi til öryggis gegn atvinnuleysi, veikindum, örorku, fyrirvinnumissi, elli eða öðrum áföllum, sem skorti valda og hann getur ekki við gert. Mæðrum og börnum ber sérstök vernd og aðstoð. Öll börn, skilgetin sem óskilgetin, skulu njóta sömu félagsverndar. 26. grein. Hver maður á rétt til menntunar. Skal hún veitt ókeypis, að minnsta kosti barnafræðsla og undirstöðummentu. Börn skulu vera skólaskyld. Iðnaðar- og verknám skal öllum standa til boða og æðri menntu vera öllum jafnfrjáls, þeim er hæfileika hafa til að njóta hennar. Menntun skal beina í þá átt að þroska persónuleika einstaklinganna og innræta þeim virðingu fyrir mannréttindum og mannhelgi. Hún skal miða að því að efla skilning, umburðarlyndi og vináttu meðal allra þjóða, kynþátta og trúarflokka og að efla starf Sameinuðu þjóðanna í þágu friðarins. Foreldrar skulu fremur öðrum ráða, hverrar menntunar börn þeirra skuli njóta. 27. grein Hverjum manni ber réttur til þess að taka frjálsan þátt í menningarlífi þjóðfélagsins, njóta lista, eiga þátt í framförum á sviði vísinda og verða aðnjótandi þeirra gæða, er af þeim leiðir. Hver maður skal njóta lögverndar þeirra hagsmuna, í andlegum og efnalegum skilningi, er leiðir af vísindaverki, ritverki eða listaverki, sem hann er höfundur að, hverju nafni sem nefnist. 28. grein Hverjum manni ber réttur til þess þjóðfélags- og milliþjóðaskipulags, er virði og framkvæmi að fullu mannréttindi þau, sem í yfirlýsingu þessari eru upp talin. 29. grein. Hver maður hefur skyldur við þióðfélagið, enda getur það eitt tryggt fullan og frjálsan persónuþroska einstaklingsins. Þjóðfélagsþegnar skulu um réttindi og frjálsræði háðir þeim takmörkunum einum, sem settar eru með lögum i því skyni að tryggja viðurkenningu á og virðingu fyrir frelsi og réttindum annarra og til þess að fullnægja réttlátum kröfum um siðgæði, reglu og velferð almennings í lýðfrjálsu þjóðfélagi. Þessi mannréttindi má aldrei framkvæma svo, að í bága fari við markmið og grundvallarreglur Sameinuðu þjóðanna. 30. grein. Ekkert atriði þessarar yfirlýsingar má túlka á þann veg, að nokkru ríki, flokki manna eða einstaklingi sé heimilt að aðhafast nokkuð það, er stefni að því að gera að engu nokkur þeirra mannréttinda, sem hér hafa verið upp talin. TEXT is(Text::Guess::Language->guess($text),'is','is is'); done_testing;
76.072464
659
0.809297
ed63704db79fcc0ad1d810b7e966f95ec7b65284
5,224
pm
Perl
tools/modules/EnsEMBL/Web/JSONServer/Tools.pm
nicklangridge/public-plugins
4c64d2b1d79c02d24972165f79479b3836f67fc9
[ "Apache-2.0" ]
null
null
null
tools/modules/EnsEMBL/Web/JSONServer/Tools.pm
nicklangridge/public-plugins
4c64d2b1d79c02d24972165f79479b3836f67fc9
[ "Apache-2.0" ]
null
null
null
tools/modules/EnsEMBL/Web/JSONServer/Tools.pm
nicklangridge/public-plugins
4c64d2b1d79c02d24972165f79479b3836f67fc9
[ "Apache-2.0" ]
null
null
null
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2017] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package EnsEMBL::Web::JSONServer::Tools; use strict; use warnings; use EnsEMBL::Web::File::Utils::URL; use EnsEMBL::Web::Utils::DynamicLoader qw(dynamic_require); use parent qw(EnsEMBL::Web::JSONServer); sub object_type { 'Tools' } sub call_js_panel_method { # TODO - get rid of this - Let frontend decide what methods to call my ($self, $method_name, $method_args) = @_; return {'panelMethod' => [ $method_name, @{$method_args || []} ]}; } sub json_form_submit { my $self = shift; my $hub = $self->hub; my $object = $self->object; my $ticket = $object->ticket_class->new($object); if (!$hub->param('species') || $hub->param('species') eq '') { my $sp_err = { 'heading' => "No species selected", 'message' => "Please select a species to run BLAST/BLAT against.", 'stage' => "validation" }; return $self->call_js_panel_method('ticketNotSubmitted', [ $sp_err ]); } $ticket->process; if (my $error = $ticket->error) { return $self->call_js_panel_method('ticketNotSubmitted', [ $error ]); } return $self->call_js_panel_method('ticketSubmitted'); } sub json_save { my $self = shift; $self->object->save_ticket_to_account; return $self->call_js_panel_method('refresh', [ 1 ]); } sub json_delete { my $self = shift; $self->object->delete_ticket_or_job; return $self->call_js_panel_method('refresh', [ 1 ]); } sub json_refresh_tickets { my $self = shift; my $tickets_old = $self->hub->param('tickets'); my ($tickets_new, $auto_refresh) = $self->object->get_tickets_data_for_sync; return $self->call_js_panel_method('updateTicketList', [ $tickets_old eq $tickets_new ? undef : $tickets_new, $auto_refresh ]); } sub json_share { my $self = shift; my $object = $self->object; my $visibility = $object->change_ticket_visibility($self->hub->param('share') ? 'public' : 'private'); return { 'shared' => $visibility eq 'public' ? 1 : 0 }; } sub json_load_ticket { my $self = shift; return $self->call_js_panel_method('populateForm', [ $self->object->get_edit_jobs_data ]); } #Ajax request used by all 1000genomes tools to retrieve content for sample population url and return sub json_read_sample_file { my ($self) = @_; my $hub = $self->hub; my $url = $hub->param('population_url') or return; my $pop_value = $hub->param('pop_value') ? 1 : 0; my $pops = []; my $args = { 'no_exception' => 1 }; my $proxy = $hub->web_proxy; $args->{proxy} = $proxy ? $proxy : ""; my $html = EnsEMBL::Web::File::Utils::URL::read_file($url, $args); return { 'error' => 'cannot retrieve file' } unless $html; my $sample_pop; if ( $html ){ foreach (split("\n",$html)){ next if(!$_ || $_ =~ /sample/gi); #skip if empty or skip header if there is one my ($sam, $pop, $plat) = split(/\t/, $_); $sample_pop->{$pop} ||= []; push @{$sample_pop->{$pop}}, $sam; } } #push @$pops, { caption =>'ALL', value=>'ALL', 'selected' => 'selected'}; #They might already have all in the sample file or it might not be needed. If thats not the case, uncomment for my $population (sort {$a cmp $b} keys %{$sample_pop}) { my $ind_list = join(',' , @{$sample_pop->{$population}}) if($pop_value); push @{$pops}, { value => $ind_list ? $ind_list : $population, caption => $population }; } return { 'populations' => $pops }; } #Ajax request used by all 1000genomes tools (data slicer) to retrieve individuals inside a vcf file sub json_get_individuals { my ($self) = @_; my $hub = $self->hub; my $pops = []; my $url = $hub->param('file_url') or return; my $region = $hub->param('region') or return; my ($vcf, $error); eval { $vcf = dynamic_require('Vcf')->new(file=>$url, region=>$region, print_header=>1, silent=>1, tabix=>$SiteDefs::TABIX, tmp_dir=>$SiteDefs::ENSEMBL_TMP_TMP); #print_header allows print sample name rather than column index }; $error = "Error reading VCF file" unless ($vcf); if ($vcf) { $vcf->parse_header(); my $x=$vcf->next_data_hash(); for my $individual (keys %{$$x{gtypes}}) { push @{$pops}, { value => $individual, name => $individual }; } $error = "No data found in the uploaded VCF file within the region $region. Please choose another region or another file" unless (scalar @{$pops}); } return $error ? {'vcf_error' => $error } : { 'individuals' => $pops }; } 1;
31.853659
226
0.644525
ed43010e3b2e6bd7cbf04566dcf19708c10c1e5a
128,550
pl
Perl
vp9/common/vp9_rtcd_defs.pl
kim42083/webm.libvpx
9b99eb2e123c8e30288de73d6722c88672e4e434
[ "BSD-3-Clause" ]
null
null
null
vp9/common/vp9_rtcd_defs.pl
kim42083/webm.libvpx
9b99eb2e123c8e30288de73d6722c88672e4e434
[ "BSD-3-Clause" ]
null
null
null
vp9/common/vp9_rtcd_defs.pl
kim42083/webm.libvpx
9b99eb2e123c8e30288de73d6722c88672e4e434
[ "BSD-3-Clause" ]
null
null
null
sub vp9_common_forward_decls() { print <<EOF /* * VP9 */ #include "vpx/vpx_integer.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_enums.h" struct macroblockd; /* Encoder forward decls */ struct macroblock; struct vp9_variance_vtable; struct search_site_config; struct mv; union int_mv; struct yv12_buffer_config; EOF } forward_decls qw/vp9_common_forward_decls/; # x86inc.asm doesn't work if pic is enabled on 32 bit platforms so no assembly. if (vpx_config("CONFIG_USE_X86INC") eq "yes") { $mmx_x86inc = 'mmx'; $sse_x86inc = 'sse'; $sse2_x86inc = 'sse2'; $ssse3_x86inc = 'ssse3'; $avx_x86inc = 'avx'; $avx2_x86inc = 'avx2'; } else { $mmx_x86inc = $sse_x86inc = $sse2_x86inc = $ssse3_x86inc = $avx_x86inc = $avx2_x86inc = ''; } # this variable is for functions that are 64 bit only. if ($opts{arch} eq "x86_64") { $mmx_x86_64 = 'mmx'; $sse2_x86_64 = 'sse2'; $ssse3_x86_64 = 'ssse3'; $avx_x86_64 = 'avx'; $avx2_x86_64 = 'avx2'; } else { $mmx_x86_64 = $sse2_x86_64 = $ssse3_x86_64 = $avx_x86_64 = $avx2_x86_64 = ''; } # optimizations which depend on multiple features if ((vpx_config("HAVE_AVX2") eq "yes") && (vpx_config("HAVE_SSSE3") eq "yes")) { $avx2_ssse3 = 'avx2'; } else { $avx2_ssse3 = ''; } # # RECON # add_proto qw/void vp9_d207_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d207_predictor_4x4/, "$ssse3_x86inc"; add_proto qw/void vp9_d45_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d45_predictor_4x4/, "$ssse3_x86inc"; add_proto qw/void vp9_d63_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d63_predictor_4x4/, "$ssse3_x86inc"; add_proto qw/void vp9_h_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_h_predictor_4x4 neon dspr2/, "$ssse3_x86inc"; add_proto qw/void vp9_d117_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d117_predictor_4x4/; add_proto qw/void vp9_d135_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d135_predictor_4x4/; add_proto qw/void vp9_d153_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d153_predictor_4x4/, "$ssse3_x86inc"; add_proto qw/void vp9_v_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_v_predictor_4x4 neon/, "$sse_x86inc"; add_proto qw/void vp9_tm_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_tm_predictor_4x4 neon dspr2/, "$sse_x86inc"; add_proto qw/void vp9_dc_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_predictor_4x4 dspr2/, "$sse_x86inc"; add_proto qw/void vp9_dc_top_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_top_predictor_4x4/; add_proto qw/void vp9_dc_left_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_left_predictor_4x4/; add_proto qw/void vp9_dc_128_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_128_predictor_4x4/; add_proto qw/void vp9_d207_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d207_predictor_8x8/, "$ssse3_x86inc"; add_proto qw/void vp9_d45_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d45_predictor_8x8/, "$ssse3_x86inc"; add_proto qw/void vp9_d63_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d63_predictor_8x8/, "$ssse3_x86inc"; add_proto qw/void vp9_h_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_h_predictor_8x8 neon dspr2/, "$ssse3_x86inc"; add_proto qw/void vp9_d117_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d117_predictor_8x8/; add_proto qw/void vp9_d135_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d135_predictor_8x8/; add_proto qw/void vp9_d153_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d153_predictor_8x8/, "$ssse3_x86inc"; add_proto qw/void vp9_v_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_v_predictor_8x8 neon/, "$sse_x86inc"; add_proto qw/void vp9_tm_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_tm_predictor_8x8 neon dspr2/, "$sse2_x86inc"; add_proto qw/void vp9_dc_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_predictor_8x8 dspr2/, "$sse_x86inc"; add_proto qw/void vp9_dc_top_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_top_predictor_8x8/; add_proto qw/void vp9_dc_left_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_left_predictor_8x8/; add_proto qw/void vp9_dc_128_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_128_predictor_8x8/; add_proto qw/void vp9_d207_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d207_predictor_16x16/, "$ssse3_x86inc"; add_proto qw/void vp9_d45_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d45_predictor_16x16/, "$ssse3_x86inc"; add_proto qw/void vp9_d63_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d63_predictor_16x16/, "$ssse3_x86inc"; add_proto qw/void vp9_h_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_h_predictor_16x16 neon dspr2/, "$ssse3_x86inc"; add_proto qw/void vp9_d117_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d117_predictor_16x16/; add_proto qw/void vp9_d135_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d135_predictor_16x16/; add_proto qw/void vp9_d153_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d153_predictor_16x16/, "$ssse3_x86inc"; add_proto qw/void vp9_v_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_v_predictor_16x16 neon/, "$sse2_x86inc"; add_proto qw/void vp9_tm_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_tm_predictor_16x16 neon/, "$sse2_x86inc"; add_proto qw/void vp9_dc_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_predictor_16x16 dspr2/, "$sse2_x86inc"; add_proto qw/void vp9_dc_top_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_top_predictor_16x16/; add_proto qw/void vp9_dc_left_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_left_predictor_16x16/; add_proto qw/void vp9_dc_128_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_128_predictor_16x16/; add_proto qw/void vp9_d207_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d207_predictor_32x32/, "$ssse3_x86inc"; add_proto qw/void vp9_d45_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d45_predictor_32x32/, "$ssse3_x86inc"; add_proto qw/void vp9_d63_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d63_predictor_32x32/, "$ssse3_x86inc"; add_proto qw/void vp9_h_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_h_predictor_32x32 neon/, "$ssse3_x86inc"; add_proto qw/void vp9_d117_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d117_predictor_32x32/; add_proto qw/void vp9_d135_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d135_predictor_32x32/; add_proto qw/void vp9_d153_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_d153_predictor_32x32/; add_proto qw/void vp9_v_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_v_predictor_32x32 neon/, "$sse2_x86inc"; add_proto qw/void vp9_tm_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_tm_predictor_32x32 neon/, "$sse2_x86_64"; add_proto qw/void vp9_dc_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_predictor_32x32/, "$sse2_x86inc"; add_proto qw/void vp9_dc_top_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_top_predictor_32x32/; add_proto qw/void vp9_dc_left_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_left_predictor_32x32/; add_proto qw/void vp9_dc_128_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left"; specialize qw/vp9_dc_128_predictor_32x32/; # # Loopfilter # add_proto qw/void vp9_lpf_vertical_16/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh"; specialize qw/vp9_lpf_vertical_16 sse2 neon_asm dspr2/; $vp9_lpf_vertical_16_neon_asm=vp9_lpf_vertical_16_neon; add_proto qw/void vp9_lpf_vertical_16_dual/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh"; specialize qw/vp9_lpf_vertical_16_dual sse2 neon_asm dspr2/; $vp9_lpf_vertical_16_dual_neon_asm=vp9_lpf_vertical_16_dual_neon; add_proto qw/void vp9_lpf_vertical_8/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count"; specialize qw/vp9_lpf_vertical_8 sse2 neon_asm dspr2/; $vp9_lpf_vertical_8_neon_asm=vp9_lpf_vertical_8_neon; add_proto qw/void vp9_lpf_vertical_8_dual/, "uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1"; specialize qw/vp9_lpf_vertical_8_dual sse2 neon_asm dspr2/; $vp9_lpf_vertical_8_dual_neon_asm=vp9_lpf_vertical_8_dual_neon; add_proto qw/void vp9_lpf_vertical_4/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count"; specialize qw/vp9_lpf_vertical_4 mmx neon dspr2/; add_proto qw/void vp9_lpf_vertical_4_dual/, "uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1"; specialize qw/vp9_lpf_vertical_4_dual sse2 neon dspr2/; add_proto qw/void vp9_lpf_horizontal_16/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count"; specialize qw/vp9_lpf_horizontal_16 sse2 avx2 neon_asm dspr2/; $vp9_lpf_horizontal_16_neon_asm=vp9_lpf_horizontal_16_neon; add_proto qw/void vp9_lpf_horizontal_8/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count"; specialize qw/vp9_lpf_horizontal_8 sse2 neon_asm dspr2/; $vp9_lpf_horizontal_8_neon_asm=vp9_lpf_horizontal_8_neon; add_proto qw/void vp9_lpf_horizontal_8_dual/, "uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1"; specialize qw/vp9_lpf_horizontal_8_dual sse2 neon_asm dspr2/; $vp9_lpf_horizontal_8_dual_neon_asm=vp9_lpf_horizontal_8_dual_neon; add_proto qw/void vp9_lpf_horizontal_4/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count"; specialize qw/vp9_lpf_horizontal_4 mmx neon dspr2/; add_proto qw/void vp9_lpf_horizontal_4_dual/, "uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1"; specialize qw/vp9_lpf_horizontal_4_dual sse2 neon dspr2/; # # post proc # if (vpx_config("CONFIG_VP9_POSTPROC") eq "yes") { add_proto qw/void vp9_mbpost_proc_down/, "uint8_t *dst, int pitch, int rows, int cols, int flimit"; specialize qw/vp9_mbpost_proc_down sse2/; $vp9_mbpost_proc_down_sse2=vp9_mbpost_proc_down_xmm; add_proto qw/void vp9_mbpost_proc_across_ip/, "uint8_t *src, int pitch, int rows, int cols, int flimit"; specialize qw/vp9_mbpost_proc_across_ip sse2/; $vp9_mbpost_proc_across_ip_sse2=vp9_mbpost_proc_across_ip_xmm; add_proto qw/void vp9_post_proc_down_and_across/, "const uint8_t *src_ptr, uint8_t *dst_ptr, int src_pixels_per_line, int dst_pixels_per_line, int rows, int cols, int flimit"; specialize qw/vp9_post_proc_down_and_across sse2/; $vp9_post_proc_down_and_across_sse2=vp9_post_proc_down_and_across_xmm; add_proto qw/void vp9_plane_add_noise/, "uint8_t *Start, char *noise, char blackclamp[16], char whiteclamp[16], char bothclamp[16], unsigned int Width, unsigned int Height, int Pitch"; specialize qw/vp9_plane_add_noise sse2/; $vp9_plane_add_noise_sse2=vp9_plane_add_noise_wmt; add_proto qw/void vp9_filter_by_weight16x16/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int src_weight"; specialize qw/vp9_filter_by_weight16x16 sse2/; add_proto qw/void vp9_filter_by_weight8x8/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int src_weight"; specialize qw/vp9_filter_by_weight8x8 sse2/; } # # Sub Pixel Filters # add_proto qw/void vp9_convolve_copy/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve_copy neon dspr2/, "$sse2_x86inc"; add_proto qw/void vp9_convolve_avg/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve_avg neon dspr2/, "$sse2_x86inc"; add_proto qw/void vp9_convolve8/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8 sse2 ssse3 neon dspr2/, "$avx2_ssse3"; add_proto qw/void vp9_convolve8_horiz/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8_horiz sse2 ssse3 neon dspr2/, "$avx2_ssse3"; add_proto qw/void vp9_convolve8_vert/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8_vert sse2 ssse3 neon dspr2/, "$avx2_ssse3"; add_proto qw/void vp9_convolve8_avg/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8_avg sse2 ssse3 neon dspr2/; add_proto qw/void vp9_convolve8_avg_horiz/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8_avg_horiz sse2 ssse3 neon dspr2/; add_proto qw/void vp9_convolve8_avg_vert/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h"; specialize qw/vp9_convolve8_avg_vert sse2 ssse3 neon dspr2/; # # dct # if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { # Note as optimized versions of these functions are added we need to add a check to ensure # that when CONFIG_EMULATE_HARDWARE is on, it defaults to the C versions only. add_proto qw/void vp9_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_1_add/; add_proto qw/void vp9_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_16_add/; add_proto qw/void vp9_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_1_add/; add_proto qw/void vp9_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_64_add/; add_proto qw/void vp9_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_12_add/; add_proto qw/void vp9_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_1_add/; add_proto qw/void vp9_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_256_add/; add_proto qw/void vp9_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_10_add/; add_proto qw/void vp9_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1024_add/; add_proto qw/void vp9_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_34_add/; add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1_add/; add_proto qw/void vp9_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht4x4_16_add/; add_proto qw/void vp9_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht8x8_64_add/; add_proto qw/void vp9_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type"; specialize qw/vp9_iht16x16_256_add/; # dct and add add_proto qw/void vp9_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_1_add/; add_proto qw/void vp9_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_16_add/; } else { # Force C versions if CONFIG_EMULATE_HARDWARE is 1 if (vpx_config("CONFIG_EMULATE_HARDWARE") eq "yes") { add_proto qw/void vp9_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_1_add/; add_proto qw/void vp9_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_16_add/; add_proto qw/void vp9_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_1_add/; add_proto qw/void vp9_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_64_add/; add_proto qw/void vp9_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_12_add/; add_proto qw/void vp9_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_1_add/; add_proto qw/void vp9_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_256_add/; add_proto qw/void vp9_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_10_add/; add_proto qw/void vp9_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1024_add/; add_proto qw/void vp9_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_34_add/; add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1_add/; add_proto qw/void vp9_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht4x4_16_add/; add_proto qw/void vp9_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht8x8_64_add/; add_proto qw/void vp9_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type"; specialize qw/vp9_iht16x16_256_add/; # dct and add add_proto qw/void vp9_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_1_add/; add_proto qw/void vp9_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_16_add/; } else { add_proto qw/void vp9_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_1_add sse2 neon dspr2/; add_proto qw/void vp9_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct4x4_16_add sse2 neon dspr2/; add_proto qw/void vp9_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_1_add sse2 neon dspr2/; add_proto qw/void vp9_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_64_add sse2 neon dspr2/, "$ssse3_x86_64"; add_proto qw/void vp9_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct8x8_12_add sse2 neon dspr2/, "$ssse3_x86_64"; add_proto qw/void vp9_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_1_add sse2 neon dspr2/; add_proto qw/void vp9_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_256_add sse2 ssse3 neon dspr2/; add_proto qw/void vp9_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct16x16_10_add sse2 ssse3 neon dspr2/; add_proto qw/void vp9_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1024_add sse2 neon dspr2/; add_proto qw/void vp9_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_34_add sse2 neon_asm dspr2/; #is this a typo? $vp9_idct32x32_34_add_neon_asm=vp9_idct32x32_1024_add_neon; add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_idct32x32_1_add sse2 neon dspr2/; add_proto qw/void vp9_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht4x4_16_add sse2 neon dspr2/; add_proto qw/void vp9_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type"; specialize qw/vp9_iht8x8_64_add sse2 neon dspr2/; add_proto qw/void vp9_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type"; specialize qw/vp9_iht16x16_256_add sse2 dspr2/; # dct and add add_proto qw/void vp9_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_1_add/; add_proto qw/void vp9_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride"; specialize qw/vp9_iwht4x4_16_add/; } } # High bitdepth functions if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { # # Intra prediction # add_proto qw/void vp9_highbd_d207_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d207_predictor_4x4/; add_proto qw/void vp9_highbd_d45_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d45_predictor_4x4/; add_proto qw/void vp9_highbd_d63_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d63_predictor_4x4/; add_proto qw/void vp9_highbd_h_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_h_predictor_4x4/; add_proto qw/void vp9_highbd_d117_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d117_predictor_4x4/; add_proto qw/void vp9_highbd_d135_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d135_predictor_4x4/; add_proto qw/void vp9_highbd_d153_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d153_predictor_4x4/; add_proto qw/void vp9_highbd_v_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_v_predictor_4x4 neon/, "$sse_x86inc"; add_proto qw/void vp9_highbd_tm_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_tm_predictor_4x4/, "$sse_x86inc"; add_proto qw/void vp9_highbd_dc_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_predictor_4x4/, "$sse_x86inc"; add_proto qw/void vp9_highbd_dc_top_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_top_predictor_4x4/; add_proto qw/void vp9_highbd_dc_left_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_left_predictor_4x4/; add_proto qw/void vp9_highbd_dc_128_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_128_predictor_4x4/; add_proto qw/void vp9_highbd_d207_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d207_predictor_8x8/; add_proto qw/void vp9_highbd_d45_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d45_predictor_8x8/; add_proto qw/void vp9_highbd_d63_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d63_predictor_8x8/; add_proto qw/void vp9_highbd_h_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_h_predictor_8x8/; add_proto qw/void vp9_highbd_d117_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d117_predictor_8x8/; add_proto qw/void vp9_highbd_d135_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d135_predictor_8x8/; add_proto qw/void vp9_highbd_d153_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d153_predictor_8x8/; add_proto qw/void vp9_highbd_v_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_v_predictor_8x8/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_tm_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_tm_predictor_8x8/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_dc_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_predictor_8x8/, "$sse2_x86inc";; add_proto qw/void vp9_highbd_dc_top_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_top_predictor_8x8/; add_proto qw/void vp9_highbd_dc_left_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_left_predictor_8x8/; add_proto qw/void vp9_highbd_dc_128_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_128_predictor_8x8/; add_proto qw/void vp9_highbd_d207_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d207_predictor_16x16/; add_proto qw/void vp9_highbd_d45_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d45_predictor_16x16/; add_proto qw/void vp9_highbd_d63_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d63_predictor_16x16/; add_proto qw/void vp9_highbd_h_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_h_predictor_16x16/; add_proto qw/void vp9_highbd_d117_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d117_predictor_16x16/; add_proto qw/void vp9_highbd_d135_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d135_predictor_16x16/; add_proto qw/void vp9_highbd_d153_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d153_predictor_16x16/; add_proto qw/void vp9_highbd_v_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_v_predictor_16x16 neon/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_tm_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_tm_predictor_16x16/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_dc_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_predictor_16x16/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_dc_top_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_top_predictor_16x16/; add_proto qw/void vp9_highbd_dc_left_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_left_predictor_16x16/; add_proto qw/void vp9_highbd_dc_128_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_128_predictor_16x16/; add_proto qw/void vp9_highbd_d207_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d207_predictor_32x32/; add_proto qw/void vp9_highbd_d45_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d45_predictor_32x32/; add_proto qw/void vp9_highbd_d63_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d63_predictor_32x32/; add_proto qw/void vp9_highbd_h_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_h_predictor_32x32/; add_proto qw/void vp9_highbd_d117_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d117_predictor_32x32/; add_proto qw/void vp9_highbd_d135_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d135_predictor_32x32/; add_proto qw/void vp9_highbd_d153_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_d153_predictor_32x32/; add_proto qw/void vp9_highbd_v_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_v_predictor_32x32/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_tm_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_tm_predictor_32x32/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_dc_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_predictor_32x32/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_dc_top_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_top_predictor_32x32/; add_proto qw/void vp9_highbd_dc_left_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_left_predictor_32x32/; add_proto qw/void vp9_highbd_dc_128_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd"; specialize qw/vp9_highbd_dc_128_predictor_32x32/; # # Sub Pixel Filters # add_proto qw/void vp9_highbd_convolve_copy/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve_copy/; add_proto qw/void vp9_highbd_convolve_avg/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve_avg/; add_proto qw/void vp9_highbd_convolve8/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_convolve8_horiz/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8_horiz/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_convolve8_vert/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8_vert/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_convolve8_avg/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8_avg/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_convolve8_avg_horiz/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8_avg_horiz/, "$sse2_x86_64"; add_proto qw/void vp9_highbd_convolve8_avg_vert/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps"; specialize qw/vp9_highbd_convolve8_avg_vert/, "$sse2_x86_64"; # # Loopfilter # add_proto qw/void vp9_highbd_lpf_vertical_16/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd"; specialize qw/vp9_highbd_lpf_vertical_16 sse2/; add_proto qw/void vp9_highbd_lpf_vertical_16_dual/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd"; specialize qw/vp9_highbd_lpf_vertical_16_dual sse2/; add_proto qw/void vp9_highbd_lpf_vertical_8/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count, int bd"; specialize qw/vp9_highbd_lpf_vertical_8 sse2/; add_proto qw/void vp9_highbd_lpf_vertical_8_dual/, "uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd"; specialize qw/vp9_highbd_lpf_vertical_8_dual sse2/; add_proto qw/void vp9_highbd_lpf_vertical_4/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count, int bd"; specialize qw/vp9_highbd_lpf_vertical_4 sse2/; add_proto qw/void vp9_highbd_lpf_vertical_4_dual/, "uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd"; specialize qw/vp9_highbd_lpf_vertical_4_dual sse2/; add_proto qw/void vp9_highbd_lpf_horizontal_16/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count, int bd"; specialize qw/vp9_highbd_lpf_horizontal_16 sse2/; add_proto qw/void vp9_highbd_lpf_horizontal_8/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count, int bd"; specialize qw/vp9_highbd_lpf_horizontal_8 sse2/; add_proto qw/void vp9_highbd_lpf_horizontal_8_dual/, "uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd"; specialize qw/vp9_highbd_lpf_horizontal_8_dual sse2/; add_proto qw/void vp9_highbd_lpf_horizontal_4/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int count, int bd"; specialize qw/vp9_highbd_lpf_horizontal_4 sse2/; add_proto qw/void vp9_highbd_lpf_horizontal_4_dual/, "uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd"; specialize qw/vp9_highbd_lpf_horizontal_4_dual sse2/; # # post proc # if (vpx_config("CONFIG_VP9_POSTPROC") eq "yes") { add_proto qw/void vp9_highbd_mbpost_proc_down/, "uint16_t *dst, int pitch, int rows, int cols, int flimit"; specialize qw/vp9_highbd_mbpost_proc_down/; add_proto qw/void vp9_highbd_mbpost_proc_across_ip/, "uint16_t *src, int pitch, int rows, int cols, int flimit"; specialize qw/vp9_highbd_mbpost_proc_across_ip/; add_proto qw/void vp9_highbd_post_proc_down_and_across/, "const uint16_t *src_ptr, uint16_t *dst_ptr, int src_pixels_per_line, int dst_pixels_per_line, int rows, int cols, int flimit"; specialize qw/vp9_highbd_post_proc_down_and_across/; add_proto qw/void vp9_highbd_plane_add_noise/, "uint8_t *Start, char *noise, char blackclamp[16], char whiteclamp[16], char bothclamp[16], unsigned int Width, unsigned int Height, int Pitch"; specialize qw/vp9_highbd_plane_add_noise/; } # # dct # # Note as optimized versions of these functions are added we need to add a check to ensure # that when CONFIG_EMULATE_HARDWARE is on, it defaults to the C versions only. add_proto qw/void vp9_highbd_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct4x4_1_add/; add_proto qw/void vp9_highbd_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct8x8_1_add/; add_proto qw/void vp9_highbd_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct16x16_1_add/; add_proto qw/void vp9_highbd_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct32x32_1024_add/; add_proto qw/void vp9_highbd_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct32x32_34_add/; add_proto qw/void vp9_highbd_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct32x32_1_add/; add_proto qw/void vp9_highbd_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd"; specialize qw/vp9_highbd_iht4x4_16_add/; add_proto qw/void vp9_highbd_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd"; specialize qw/vp9_highbd_iht8x8_64_add/; add_proto qw/void vp9_highbd_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd"; specialize qw/vp9_highbd_iht16x16_256_add/; # dct and add add_proto qw/void vp9_highbd_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_iwht4x4_1_add/; add_proto qw/void vp9_highbd_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_iwht4x4_16_add/; # Force C versions if CONFIG_EMULATE_HARDWARE is 1 if (vpx_config("CONFIG_EMULATE_HARDWARE") eq "yes") { add_proto qw/void vp9_highbd_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct4x4_16_add/; add_proto qw/void vp9_highbd_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct8x8_64_add/; add_proto qw/void vp9_highbd_idct8x8_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct8x8_10_add/; add_proto qw/void vp9_highbd_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct16x16_256_add/; add_proto qw/void vp9_highbd_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct16x16_10_add/; } else { add_proto qw/void vp9_highbd_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct4x4_16_add sse2/; add_proto qw/void vp9_highbd_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct8x8_64_add sse2/; add_proto qw/void vp9_highbd_idct8x8_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct8x8_10_add sse2/; add_proto qw/void vp9_highbd_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct16x16_256_add sse2/; add_proto qw/void vp9_highbd_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd"; specialize qw/vp9_highbd_idct16x16_10_add sse2/; } } # # Encoder functions below this point. # if (vpx_config("CONFIG_VP9_ENCODER") eq "yes") { # variance add_proto qw/unsigned int vp9_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance32x16 avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance64x32 avx2 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance32x64 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance32x32 avx2 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance64x64 avx2 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance16x16 avx2 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance8x8 neon/, "$sse2_x86inc"; add_proto qw/void vp9_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_get8x8var neon/, "$sse2_x86inc"; add_proto qw/void vp9_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_get16x16var avx2 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance4x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance4x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance64x64 avx2 neon/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance64x64 avx2/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance32x64/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance32x64/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance64x32/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance64x32/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance32x16/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance32x16/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance16x32/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance16x32/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance32x32 avx2 neon/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance32x32 avx2/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance16x16 neon/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance16x16/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance8x16/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance8x16/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance16x8/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance16x8/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance8x8 neon/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance8x8/, "$sse2_x86inc", "$ssse3_x86inc"; # TODO(jingning): need to convert 8x4/4x8 functions into mmx/sse form add_proto qw/unsigned int vp9_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance8x4/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance8x4/, "$sse2_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance4x8/, "$sse_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance4x8/, "$sse_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_sub_pixel_variance4x4/, "$sse_x86inc", "$ssse3_x86inc"; #vp9_sub_pixel_variance4x4_sse2=vp9_sub_pixel_variance4x4_wmt add_proto qw/unsigned int vp9_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_sub_pixel_avg_variance4x4/, "$sse_x86inc", "$ssse3_x86inc"; add_proto qw/unsigned int vp9_sad64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad64x64 neon avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad32x64 avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad64x32 avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad32x16 avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad32x32 neon avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad16x16 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad8x8 neon/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad4x8/, "$sse_x86inc"; add_proto qw/unsigned int vp9_sad4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_sad4x4/, "$sse_x86inc"; add_proto qw/unsigned int vp9_sad64x64_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad64x64_avg avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x64_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad32x64_avg avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad64x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad64x32_avg avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad32x16_avg avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad16x32_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad32x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad32x32_avg avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad16x16_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad16x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad16x8_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad8x16_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad8x8_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad8x4_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad8x4_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_sad4x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad4x8_avg/, "$sse_x86inc"; add_proto qw/unsigned int vp9_sad4x4_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_sad4x4_avg/, "$sse_x86inc"; add_proto qw/void vp9_sad64x64x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad64x64x3/; add_proto qw/void vp9_sad32x32x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad32x32x3/; add_proto qw/void vp9_sad16x16x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x16x3 sse3 ssse3/; add_proto qw/void vp9_sad16x8x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x8x3 sse3 ssse3/; add_proto qw/void vp9_sad8x16x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad8x16x3 sse3/; add_proto qw/void vp9_sad8x8x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad8x8x3 sse3/; add_proto qw/void vp9_sad4x4x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad4x4x3 sse3/; add_proto qw/void vp9_sad64x64x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad64x64x8/; add_proto qw/void vp9_sad32x32x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad32x32x8/; add_proto qw/void vp9_sad16x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad16x16x8 sse4/; add_proto qw/void vp9_sad16x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad16x8x8 sse4/; add_proto qw/void vp9_sad8x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad8x16x8 sse4/; add_proto qw/void vp9_sad8x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad8x8x8 sse4/; add_proto qw/void vp9_sad8x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad8x4x8/; add_proto qw/void vp9_sad4x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad4x8x8/; add_proto qw/void vp9_sad4x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_sad4x4x8 sse4/; add_proto qw/void vp9_sad64x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad64x64x4d sse2 avx2 neon/; add_proto qw/void vp9_sad32x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad32x64x4d sse2/; add_proto qw/void vp9_sad64x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad64x32x4d sse2/; add_proto qw/void vp9_sad32x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad32x16x4d sse2/; add_proto qw/void vp9_sad16x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x32x4d sse2/; add_proto qw/void vp9_sad32x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad32x32x4d sse2 avx2 neon/; add_proto qw/void vp9_sad16x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x16x4d sse2 neon/; add_proto qw/void vp9_sad16x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x8x4d sse2/; add_proto qw/void vp9_sad8x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad8x16x4d sse2/; add_proto qw/void vp9_sad8x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad8x8x4d sse2/; # TODO(jingning): need to convert these 4x8/8x4 functions into sse2 form add_proto qw/void vp9_sad8x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad8x4x4d sse2/; add_proto qw/void vp9_sad4x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad4x8x4d sse/; add_proto qw/void vp9_sad4x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad4x4x4d sse/; add_proto qw/unsigned int vp9_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_mse16x16 avx2/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_mse8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_mse16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_mse8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_get_mb_ss/, "const int16_t *"; specialize qw/vp9_get_mb_ss/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_avg_8x8/, "const uint8_t *, int p"; specialize qw/vp9_avg_8x8 sse2 neon/; add_proto qw/unsigned int vp9_avg_4x4/, "const uint8_t *, int p"; specialize qw/vp9_avg_4x4 sse2/; add_proto qw/void vp9_hadamard_8x8/, "int16_t const *src_diff, int src_stride, int16_t *coeff"; specialize qw/vp9_hadamard_8x8 sse2/; add_proto qw/void vp9_hadamard_16x16/, "int16_t *coeff"; specialize qw/vp9_hadamard_16x16/; add_proto qw/int16_t vp9_satd/, "const int16_t *coeff, int length"; specialize qw/vp9_satd sse2/; add_proto qw/void vp9_int_pro_row/, "int16_t *hbuf, uint8_t const *ref, const int ref_stride, const int height"; specialize qw/vp9_int_pro_row sse2/; add_proto qw/int16_t vp9_int_pro_col/, "uint8_t const *ref, const int width"; specialize qw/vp9_int_pro_col sse2/; add_proto qw/int vp9_vector_var/, "int16_t const *ref, int16_t const *src, const int bwl"; specialize qw/vp9_vector_var sse2/; if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { add_proto qw/unsigned int vp9_highbd_avg_8x8/, "const uint8_t *, int p"; specialize qw/vp9_highbd_avg_8x8/; add_proto qw/unsigned int vp9_highbd_avg_4x4/, "const uint8_t *, int p"; specialize qw/vp9_highbd_avg_4x4/; } # ENCODEMB INVOKE add_proto qw/void vp9_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride"; specialize qw/vp9_subtract_block neon/, "$sse2_x86inc"; # # Denoiser # if (vpx_config("CONFIG_VP9_TEMPORAL_DENOISING") eq "yes") { add_proto qw/int vp9_denoiser_filter/, "const uint8_t *sig, int sig_stride, const uint8_t *mc_avg, int mc_avg_stride, uint8_t *avg, int avg_stride, int increase_denoising, BLOCK_SIZE bs, int motion_magnitude"; specialize qw/vp9_denoiser_filter sse2/; } if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { # the transform coefficients are held in 32-bit # values, so the assembler code for vp9_block_error can no longer be used. add_proto qw/int64_t vp9_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz"; specialize qw/vp9_block_error/; add_proto qw/void vp9_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_fp/; add_proto qw/void vp9_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_fp_32x32/; add_proto qw/void vp9_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_b/; add_proto qw/void vp9_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_b_32x32/; add_proto qw/void vp9_fdct8x8_quant/, "const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_fdct8x8_quant/; } else { add_proto qw/int64_t vp9_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz"; specialize qw/vp9_block_error avx2/, "$sse2_x86inc"; add_proto qw/void vp9_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_fp neon sse2/, "$ssse3_x86_64"; add_proto qw/void vp9_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_fp_32x32/, "$ssse3_x86_64"; add_proto qw/void vp9_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_b sse2/, "$ssse3_x86_64"; add_proto qw/void vp9_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_quantize_b_32x32/, "$ssse3_x86_64"; add_proto qw/void vp9_fdct8x8_quant/, "const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_fdct8x8_quant sse2 ssse3 neon/; } # # Structured Similarity (SSIM) # if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") { add_proto qw/void vp9_ssim_parms_8x8/, "uint8_t *s, int sp, uint8_t *r, int rp, unsigned long *sum_s, unsigned long *sum_r, unsigned long *sum_sq_s, unsigned long *sum_sq_r, unsigned long *sum_sxr"; specialize qw/vp9_ssim_parms_8x8/, "$sse2_x86_64"; add_proto qw/void vp9_ssim_parms_16x16/, "uint8_t *s, int sp, uint8_t *r, int rp, unsigned long *sum_s, unsigned long *sum_r, unsigned long *sum_sq_s, unsigned long *sum_sq_r, unsigned long *sum_sxr"; specialize qw/vp9_ssim_parms_16x16/, "$sse2_x86_64"; } # fdct functions if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { add_proto qw/void vp9_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht4x4 sse2/; add_proto qw/void vp9_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht8x8 sse2/; add_proto qw/void vp9_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht16x16 sse2/; add_proto qw/void vp9_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fwht4x4/, "$mmx_x86inc"; add_proto qw/void vp9_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct4x4_1 sse2/; add_proto qw/void vp9_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct4x4 sse2/; add_proto qw/void vp9_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct8x8_1 sse2/; add_proto qw/void vp9_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct8x8 sse2/; add_proto qw/void vp9_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct16x16_1 sse2/; add_proto qw/void vp9_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct16x16 sse2/; add_proto qw/void vp9_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32_1 sse2/; add_proto qw/void vp9_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32 sse2/; add_proto qw/void vp9_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32_rd sse2/; } else { add_proto qw/void vp9_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht4x4 sse2/; add_proto qw/void vp9_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht8x8 sse2/; add_proto qw/void vp9_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_fht16x16 sse2/; add_proto qw/void vp9_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fwht4x4/, "$mmx_x86inc"; add_proto qw/void vp9_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct4x4_1 sse2/; add_proto qw/void vp9_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct4x4 sse2/; add_proto qw/void vp9_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct8x8_1 sse2 neon/; add_proto qw/void vp9_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct8x8 sse2 neon/, "$ssse3_x86_64"; add_proto qw/void vp9_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct16x16_1 sse2/; add_proto qw/void vp9_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct16x16 sse2/; add_proto qw/void vp9_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32_1 sse2/; add_proto qw/void vp9_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32 sse2 avx2/; add_proto qw/void vp9_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_fdct32x32_rd sse2 avx2/; } # # Motion search # add_proto qw/int vp9_full_search_sad/, "const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct vp9_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv"; specialize qw/vp9_full_search_sad sse3 sse4_1/; $vp9_full_search_sad_sse3=vp9_full_search_sadx3; $vp9_full_search_sad_sse4_1=vp9_full_search_sadx8; add_proto qw/int vp9_diamond_search_sad/, "const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct vp9_variance_vtable *fn_ptr, const struct mv *center_mv"; specialize qw/vp9_diamond_search_sad/; add_proto qw/int vp9_full_range_search/, "const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct vp9_variance_vtable *fn_ptr, const struct mv *center_mv"; specialize qw/vp9_full_range_search/; add_proto qw/void vp9_temporal_filter_apply/, "uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count"; specialize qw/vp9_temporal_filter_apply sse2/; if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { # variance add_proto qw/unsigned int vp9_highbd_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance8x4/; add_proto qw/unsigned int vp9_highbd_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance4x8/; add_proto qw/unsigned int vp9_highbd_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_variance4x4/; add_proto qw/void vp9_highbd_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_get8x8var/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_get16x16var/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance8x4/; add_proto qw/unsigned int vp9_highbd_10_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance4x8/; add_proto qw/unsigned int vp9_highbd_10_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_variance4x4/; add_proto qw/void vp9_highbd_10_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_10_get8x8var/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_10_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_10_get16x16var/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance8x4/; add_proto qw/unsigned int vp9_highbd_12_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance4x8/; add_proto qw/unsigned int vp9_highbd_12_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_variance4x4/; add_proto qw/void vp9_highbd_12_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_12_get8x8var/, "$sse2_x86inc"; add_proto qw/void vp9_highbd_12_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; specialize qw/vp9_highbd_12_get16x16var/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance4x8/; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance4x8/; add_proto qw/unsigned int vp9_highbd_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_sub_pixel_variance4x4/; add_proto qw/unsigned int vp9_highbd_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_sub_pixel_avg_variance4x4/; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance4x8/; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance4x8/; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_sub_pixel_variance4x4/; add_proto qw/unsigned int vp9_highbd_10_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_10_sub_pixel_avg_variance4x4/; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance4x8/; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance4x8/; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_sub_pixel_variance4x4/; add_proto qw/unsigned int vp9_highbd_12_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, const uint8_t *second_pred"; specialize qw/vp9_highbd_12_sub_pixel_avg_variance4x4/; add_proto qw/unsigned int vp9_highbd_sad64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad64x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad32x64/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad64x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad32x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad16x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad32x32/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad16x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad8x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad8x4/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad4x8/; add_proto qw/unsigned int vp9_highbd_sad4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vp9_highbd_sad4x4/; add_proto qw/unsigned int vp9_highbd_sad64x64_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad64x64_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x64_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad32x64_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad64x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad64x32_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad32x16_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad16x32_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad32x32_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad32x32_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad16x16_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad16x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad16x8_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x16_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad8x16_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad8x8_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad8x4_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad8x4_avg/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_sad4x8_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad4x8_avg/; add_proto qw/unsigned int vp9_highbd_sad4x4_avg/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred"; specialize qw/vp9_highbd_sad4x4_avg/; add_proto qw/void vp9_highbd_sad64x64x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad64x64x3/; add_proto qw/void vp9_highbd_sad32x32x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad32x32x3/; add_proto qw/void vp9_highbd_sad16x16x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad16x16x3/; add_proto qw/void vp9_highbd_sad16x8x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad16x8x3/; add_proto qw/void vp9_highbd_sad8x16x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad8x16x3/; add_proto qw/void vp9_highbd_sad8x8x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad8x8x3/; add_proto qw/void vp9_highbd_sad4x4x3/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad4x4x3/; add_proto qw/void vp9_highbd_sad64x64x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad64x64x8/; add_proto qw/void vp9_highbd_sad32x32x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad32x32x8/; add_proto qw/void vp9_highbd_sad16x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad16x16x8/; add_proto qw/void vp9_highbd_sad16x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad16x8x8/; add_proto qw/void vp9_highbd_sad8x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad8x16x8/; add_proto qw/void vp9_highbd_sad8x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad8x8x8/; add_proto qw/void vp9_highbd_sad8x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad8x4x8/; add_proto qw/void vp9_highbd_sad4x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad4x8x8/; add_proto qw/void vp9_highbd_sad4x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array"; specialize qw/vp9_highbd_sad4x4x8/; add_proto qw/void vp9_highbd_sad64x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad64x64x4d sse2/; add_proto qw/void vp9_highbd_sad32x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad32x64x4d sse2/; add_proto qw/void vp9_highbd_sad64x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad64x32x4d sse2/; add_proto qw/void vp9_highbd_sad32x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad32x16x4d sse2/; add_proto qw/void vp9_highbd_sad16x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad16x32x4d sse2/; add_proto qw/void vp9_highbd_sad32x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad32x32x4d sse2/; add_proto qw/void vp9_highbd_sad16x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad16x16x4d sse2/; add_proto qw/void vp9_highbd_sad16x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad16x8x4d sse2/; add_proto qw/void vp9_highbd_sad8x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad8x16x4d sse2/; add_proto qw/void vp9_highbd_sad8x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad8x8x4d sse2/; add_proto qw/void vp9_highbd_sad8x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad8x4x4d sse2/; add_proto qw/void vp9_highbd_sad4x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad4x8x4d sse2/; add_proto qw/void vp9_highbd_sad4x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_highbd_sad4x4x4d sse2/; add_proto qw/unsigned int vp9_highbd_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_mse16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_mse8x16/; add_proto qw/unsigned int vp9_highbd_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_mse16x8/; add_proto qw/unsigned int vp9_highbd_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_mse8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_mse16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_10_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_mse8x16/; add_proto qw/unsigned int vp9_highbd_10_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_mse16x8/; add_proto qw/unsigned int vp9_highbd_10_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_10_mse8x8/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_mse16x16/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_highbd_12_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_mse8x16/; add_proto qw/unsigned int vp9_highbd_12_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_mse16x8/; add_proto qw/unsigned int vp9_highbd_12_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; specialize qw/vp9_highbd_12_mse8x8/, "$sse2_x86inc"; # ENCODEMB INVOKE add_proto qw/int64_t vp9_highbd_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd"; specialize qw/vp9_highbd_block_error sse2/; add_proto qw/void vp9_highbd_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd"; specialize qw/vp9_highbd_subtract_block/; add_proto qw/void vp9_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_highbd_quantize_fp/; add_proto qw/void vp9_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_highbd_quantize_fp_32x32/; add_proto qw/void vp9_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_highbd_quantize_b sse2/; add_proto qw/void vp9_highbd_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; specialize qw/vp9_highbd_quantize_b_32x32 sse2/; # # Structured Similarity (SSIM) # if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") { add_proto qw/void vp9_highbd_ssim_parms_8x8/, "uint16_t *s, int sp, uint16_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr"; specialize qw/vp9_highbd_ssim_parms_8x8/; } # fdct functions add_proto qw/void vp9_highbd_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_highbd_fht4x4 sse2/; add_proto qw/void vp9_highbd_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_highbd_fht8x8 sse2/; add_proto qw/void vp9_highbd_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; specialize qw/vp9_highbd_fht16x16 sse2/; add_proto qw/void vp9_highbd_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fwht4x4/; add_proto qw/void vp9_highbd_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct4x4 sse2/; add_proto qw/void vp9_highbd_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct8x8_1/; add_proto qw/void vp9_highbd_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct8x8 sse2/; add_proto qw/void vp9_highbd_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct16x16_1/; add_proto qw/void vp9_highbd_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct16x16 sse2/; add_proto qw/void vp9_highbd_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct32x32_1/; add_proto qw/void vp9_highbd_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct32x32 sse2/; add_proto qw/void vp9_highbd_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride"; specialize qw/vp9_highbd_fdct32x32_rd sse2/; add_proto qw/void vp9_highbd_temporal_filter_apply/, "uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count"; specialize qw/vp9_highbd_temporal_filter_apply/; } # End vp9_high encoder functions } # end encoder functions 1;
66.024653
381
0.793551
73da6441aaca978286841cce4b78bf9253cb9fa3
3,979
pm
Perl
modules/EnsEMBL/Draw/GlyphSet/_clone.pm
at7/backup-ensembl-webcode
4c8c30f2ba9e0eebc3dd07e068fb6e02c388d086
[ "Apache-2.0", "MIT" ]
null
null
null
modules/EnsEMBL/Draw/GlyphSet/_clone.pm
at7/backup-ensembl-webcode
4c8c30f2ba9e0eebc3dd07e068fb6e02c388d086
[ "Apache-2.0", "MIT" ]
null
null
null
modules/EnsEMBL/Draw/GlyphSet/_clone.pm
at7/backup-ensembl-webcode
4c8c30f2ba9e0eebc3dd07e068fb6e02c388d086
[ "Apache-2.0", "MIT" ]
null
null
null
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2017] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package EnsEMBL::Draw::GlyphSet::_clone; ### Retrieve all BAC map clones - these are the clones in the ### subset "bac_map" - if we are looking at a long segment then we only ### retrieve accessioned clones ("acc_bac_map") use strict; use base qw(EnsEMBL::Draw::GlyphSet_simple); sub label_overlay { return 1; } sub features { my $self = shift; my $db = $self->my_config('db'); my @sorted = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map {[ $_->seq_region_start - 1e9 * $_->get_scalar_attribute('state'), $_ ]} map { @{$self->{'container'}->get_all_MiscFeatures($_, $db) || []} } $self->my_config('set'); return \@sorted; } ## If bac map clones are very long then we draw them as "outlines" as ## we aren't convinced on their quality... However draw ENCODE filled sub get_colours { my ($self, $f) = @_; my $colours = $self->SUPER::get_colours($f); if (!$self->my_colour($colours->{'key'}, 'solid')) { $colours->{'part'} = 'border' if $f->get_scalar_attribute('inner_start'); $colours->{'part'} = 'border' if $self->my_config('outline_threshold') && $f->length > $self->my_config('outline_threshold'); } return $colours; } sub colour_key { my ($self, $f) = @_; (my $state = $f->get_scalar_attribute('state')) =~ s/^\d\d://; return $state ? lc $state : $self->my_config('set'); } sub feature_label { my ($self, $f) = @_; return $f->get_first_scalar_attribute(qw(name well_name clone_name sanger_project synonym embl_acc)); } ## Link back to this page centred on the map fragment sub href { my ($self, $f) = @_; return $self->_url({ type => 'Location', action => 'MiscFeature', r => $f->seq_region_name . ':' . $f->seq_region_start . '-' . $f->seq_region_end, misc_feature => $f->get_first_scalar_attribute(qw(name well_name clone_name sanger_project synonym embl_acc)), mfid => $f->dbID, db => $self->my_config('db'), }); } sub tag { my ($self, $f) = @_; my ($s, $e) = ($f->get_scalar_attribute('inner_start'), $f->get_scalar_attribute('inner_end')); my @result; if ($s && $e) { (my $state = $f->get_scalar_attribute('state')) =~ s/^\d\d://; ($s, $e) = $self->sr2slice($s, $e); push @result, { style => 'rect', start => $s, end => $e, colour => $self->my_colour($state) }; } push @result, { style => 'left-triangle', start => $f->start, end => $f->end, colour => $self->my_colour('fish_tag') } if $f->get_scalar_attribute('fish'); return @result; } sub render_tag { my ($self, $tag, $composite, $slice_length, $height, $start, $end) = @_; my @glyph; if ($tag->{'style'} eq 'left-triangle') { my $triangle_end = $start - 1 + 3/$self->scalex; $triangle_end = $end if $triangle_end > $end; push @glyph, $self->Poly({ colour => $tag->{'colour'}, absolutey => 1, points => [ $start - 1, 0, $start - 1, 3, $triangle_end, 0 ], }); } return @glyph; } sub export_feature { my $self = shift; my ($feature, $feature_type) = @_; return $self->_render_text($feature, $feature_type, { headers => [ 'id' ], values => [ [$self->feature_label($feature)]->[0] ] }); } 1;
29.69403
157
0.618748
ed32f4b85e7fe2b8273d5433c19bcff1de77c401
1,119
t
Perl
t/regression/read_error00.t
xlat/excel-reader-xlsx
412632febfde68bd31ebeff0caa2e0b7c9f2c710
[ "Artistic-1.0" ]
null
null
null
t/regression/read_error00.t
xlat/excel-reader-xlsx
412632febfde68bd31ebeff0caa2e0b7c9f2c710
[ "Artistic-1.0" ]
null
null
null
t/regression/read_error00.t
xlat/excel-reader-xlsx
412632febfde68bd31ebeff0caa2e0b7c9f2c710
[ "Artistic-1.0" ]
3
2017-02-21T10:13:01.000Z
2019-10-16T08:02:29.000Z
############################################################################### # # Tests for Excel::Writer::XLSX. # # reverse('(c)'), February 2012, John McNamara, jmcnamara@cpan.org # use lib 't/lib'; use TestFunctions qw(_is_deep_diff _read_json); use strict; use warnings; use Excel::Reader::XLSX; use Test::More tests => 1; ############################################################################### # # Test setup. # my $json_filename = 't/regression/json_files/read_error00.json'; my $json = _read_json( $json_filename ); my $caption = $json->{caption}; my $expected = $json->{expected}; my $xlsx_file = 't/regression/xlsx_files/' . $json->{xlsx_file}; my $got; ############################################################################### # # Test error handling when reading data from an Excel file. # use Excel::Reader::XLSX; my $reader = Excel::Reader::XLSX->new(); my $workbook = $reader->read_file( $xlsx_file ); $got = { error_code => $reader->error_code(), error_text => $reader->error(), }; # Test the results. _is_deep_diff( $got, $expected, $caption );
25.431818
79
0.517426
73fa67e8ffb09e23632aa98fbde1fd1c922bc38d
33,385
pm
Perl
lib/susedistribution.pm
rwx788/os-autoinst-distri-opensuse
9239a796a1cb96e13581715a1fa47698cf0f852b
[ "FSFAP" ]
null
null
null
lib/susedistribution.pm
rwx788/os-autoinst-distri-opensuse
9239a796a1cb96e13581715a1fa47698cf0f852b
[ "FSFAP" ]
null
null
null
lib/susedistribution.pm
rwx788/os-autoinst-distri-opensuse
9239a796a1cb96e13581715a1fa47698cf0f852b
[ "FSFAP" ]
null
null
null
package susedistribution; use base 'distribution'; use serial_terminal (); use strict; use warnings; use utils qw( disable_serial_getty ensure_serialdev_permissions get_root_console_tty get_x11_console_tty quit_packagekit save_svirt_pty type_string_slow type_string_very_slow zypper_call ); use version_utils qw(is_hyperv_in_gui is_sle is_leap is_svirt_except_s390x is_tumbleweed is_opensuse); use x11utils qw(desktop_runner_hotkey ensure_unlocked_desktop); use Utils::Backends qw(has_serial_over_ssh set_sshserial_dev use_ssh_serial_console is_remote_backend); use backend::svirt qw(SERIAL_TERMINAL_DEFAULT_DEVICE SERIAL_TERMINAL_DEFAULT_PORT); use Cwd; use autotest 'query_isotovideo'; =head1 SUSEDISTRIBUTION =head1 SYNOPSIS Base class implementation of distribution class necessary for testapi =cut # don't import script_run - it will overwrite script_run from distribution and create a recursion use testapi qw(send_key %cmd assert_screen check_screen check_var click_lastmatch get_var save_screenshot match_has_tag set_var type_password type_string enter_cmd wait_serial $serialdev mouse_hide send_key_until_needlematch record_info record_soft_failure wait_still_screen wait_screen_change get_required_var diag); =head2 handle_password_prompt Types the password in a password prompt =cut sub handle_password_prompt { my ($console) = @_; $console //= ''; return if get_var("LIVETEST") || get_var('LIVECD'); assert_screen("password-prompt", 60); if ($console eq 'hyperv-intermediary') { type_string get_required_var('VIRSH_GUEST_PASSWORD'); } elsif ($console eq 'svirt') { type_string(get_required_var(check_var('VIRSH_VMM_FAMILY', 'hyperv') ? 'HYPERV_PASSWORD' : 'VIRSH_PASSWORD')); } else { type_password; } send_key('ret'); } =head2 init TODO needs to be documented =cut sub init { my ($self) = @_; $self->SUPER::init(); $self->init_cmd(); $self->init_consoles(); } =head2 init_cmd TODO needs to be documented =cut sub init_cmd { my ($self) = @_; ## keyboard cmd vars %testapi::cmd = qw( next alt-n xnext alt-n install alt-i update alt-u finish alt-f accept alt-a ok alt-o cancel alt-c continue alt-o createpartsetup alt-c custompart alt-c addpart alt-d donotformat alt-d addraid alt-i add alt-a raid0 alt-0 raid1 alt-1 raid5 alt-5 raid6 alt-6 raid10 alt-i mountpoint alt-m filesystem alt-s expertpartitioner alt-e encrypt alt-e encryptdisk alt-a enablelvm alt-e resize alt-i customsize alt-c acceptlicense alt-a instdetails alt-d rebootnow alt-n otherrootpw alt-s noautologin alt-a change alt-c software s package p bootloader b entiredisk alt-e guidedsetup alt-d rescandevices alt-e exp_part_finish alt-f size_hotkey alt-s sync_interval alt-n sync_without_daemon alt-y toggle_home alt-p raw_volume alt-a enable_snapshots alt-n system_view alt-s ); if (check_var('INSTLANG', "de_DE")) { $testapi::cmd{next} = "alt-w"; $testapi::cmd{createpartsetup} = "alt-e"; $testapi::cmd{custompart} = "alt-b"; $testapi::cmd{addpart} = "alt-h"; $testapi::cmd{finish} = "alt-b"; $testapi::cmd{accept} = "alt-r"; $testapi::cmd{donotformat} = "alt-n"; $testapi::cmd{add} = "alt-h"; # $testapi::cmd{raid6}="alt-d"; 11.2 only $testapi::cmd{raid10} = "alt-r"; $testapi::cmd{mountpoint} = "alt-e"; $testapi::cmd{rebootnow} = "alt-j"; $testapi::cmd{otherrootpw} = "alt-e"; $testapi::cmd{change} = "alt-n"; $testapi::cmd{software} = "w"; } if (check_var('INSTLANG', "es_ES")) { $testapi::cmd{next} = "alt-i"; } if (check_var('INSTLANG', "fr_FR")) { $testapi::cmd{next} = "alt-s"; } if (!is_sle('<15') && !is_leap('<15.0')) { # SLE15/Leap15 use Chrony instead of ntp $testapi::cmd{sync_interval} = "alt-i"; $testapi::cmd{sync_without_daemon} = "alt-s"; } ## keyboard cmd vars end if (check_var('VIDEOMODE', 'text') && check_var('SCC_REGISTER', 'installation')) { $testapi::cmd{expertpartitioner} = "alt-x"; } } =head2 init_desktop_runner Starts the desktop runner for C<x11_start_program> =cut sub init_desktop_runner { my ($program, $timeout) = @_; $timeout //= 30; my $hotkey = desktop_runner_hotkey; send_key($hotkey); mouse_hide(200); if (!check_screen('desktop-runner', $timeout)) { record_info('workaround', "desktop-runner does not show up on $hotkey, retrying up to three times (see bsc#978027)"); send_key 'esc'; # To avoid failing needle on missing 'alt' key - poo#20608 send_key_until_needlematch 'desktop-runner', $hotkey, 3, 10; } wait_still_screen(2); for (my $retries = 10; $retries > 0; $retries--) { # krunner may use auto-completion which sometimes gets confused by # too fast typing or looses characters because of the load caused (also # see below), especially in wayland. # See https://progress.opensuse.org/issues/18200 as well as # https://progress.opensuse.org/issues/35589 if (check_var('DESKTOP', 'kde')) { if (get_var('WAYLAND')) { type_string_very_slow substr $program, 0, 2; wait_still_screen(3); type_string_very_slow substr $program, 2; } else { type_string_slow $program; } } else { type_string $program; } # Do multiple attempts only on plasma last unless (check_var('DESKTOP', 'kde')); # Make sure we have plasma suggestions as it may take time, especially on boot or under load. Otherwise, try again if ($retries == 1) { assert_screen('desktop-runner-plasma-suggestions', $timeout); } elsif (!check_screen('desktop-runner-plasma-suggestions', $timeout)) { # Prepare for next attempt send_key 'esc'; # Escape from desktop-runner sleep(5); # Leave some time for the system to recover send_key_until_needlematch 'desktop-runner', $hotkey, 3, 10; } else { last; } } } =head2 x11_start_program x11_start_program($program [, timeout => $timeout ] [, no_wait => 0|1 ] [, valid => 0|1 [, target_match => $target_match ] [, match_timeout => $match_timeout ] [, match_no_wait => 0|1 ] [, match_typed => 0|1 ]]); Start the program C<$program> in an X11 session using the I<desktop-runner> and looking for a target screen to match. The timeout for C<check_screen> for I<desktop-runner> can be configured with optional C<$timeout>. Specify C<no_wait> to skip the C<wait_still_screen> after the typing of C<$program>. Overwrite C<valid> with a false value to exit after I<desktop-runner> executed without checking for the result. C<valid=1> is especially useful when the used I<desktop-runner> has an auto-completion feature which can cause high load while typing potentially causing the subsequent C<ret> to fail. By default C<x11_start_program> looks for a screen tagged with the value of C<$program> with C<assert_screen> after executing the command to launch C<$program>. The tag(s) can be customized with the parameter C<$target_match>. C<$match_timeout> can be specified to configure the timeout on that internal C<assert_screen>. Specify C<match_no_wait> to forward the C<no_wait> option to the internal C<assert_screen>. If user wants to assert that command was typed correctly in the I<desktop-runner> she can pass needle tag using C<match_typed> parameter. This will check typed text and retry once in case of typos or unexpected results (see poo#25972). The combination of C<no_wait> with C<valid> and C<target_match> is the preferred solution for the most efficient approach by saving time within tests. In case of KDE plasma krunner provides a suggestion list which can take a bit of time to be computed therefore the logic is slightly different there, for example longer waiting time, looking for the computed suggestions list before accepting and a default timeout for the target match of 90 seconds versus just using the default of C<assert_screen> itself. For other desktop environments we keep the old check for the runner border. This method is overwriting the base method in os-autoinst. =cut sub x11_start_program { my ($self, $program, %args) = @_; my $timeout = $args{timeout}; # enable valid option as default $args{valid} //= 1; $args{target_match} //= $program; $args{match_no_wait} //= 0; $args{match_timeout} //= 90 if check_var('DESKTOP', 'kde'); # Start desktop runner and type command there init_desktop_runner($program, $timeout); # With match_typed we check typed text and if doesn't match - retrying # Is required by firefox test on kde, as typing fails on KDE desktop runnner sometimes if ($args{match_typed} && !check_screen($args{match_typed}, 30)) { send_key 'esc'; init_desktop_runner($program, $timeout); } wait_still_screen(3); save_screenshot; send_key 'ret'; # As above especially krunner seems to take some time before disappearing # after 'ret' press we should wait in this case nevertheless wait_still_screen(3, similarity_level => 45) unless ($args{no_wait} || ($args{valid} && $args{target_match} && !check_var('DESKTOP', 'kde'))); return unless $args{valid}; set_var('IN_X11_START_PROGRAM', $program); my @target = ref $args{target_match} eq 'ARRAY' ? @{$args{target_match}} : $args{target_match}; for (1 .. 3) { push @target, check_var('DESKTOP', 'kde') ? 'desktop-runner-plasma-suggestions' : 'desktop-runner-border'; assert_screen([@target], $args{match_timeout}, no_wait => $args{match_no_wait}); last unless match_has_tag('desktop-runner-border') || match_has_tag('desktop-runner-plasma-suggestions'); wait_screen_change { send_key 'ret'; }; } set_var('IN_X11_START_PROGRAM', undef); # asserting program came up properly die "Did not find target needle for tag(s) '@target'" if match_has_tag('desktop-runner-border') || match_has_tag('desktop-runner-plasma-suggestions'); } sub _ensure_installed_zypper_fallback { my ($self, $pkglist) = @_; $self->become_root; quit_packagekit; zypper_call "in $pkglist"; enter_cmd "exit"; } =head2 ensure_installed Ensure that a package is installed =cut sub ensure_installed { my ($self, $pkgs, %args) = @_; my $pkglist = ref $pkgs eq 'ARRAY' ? join ' ', @$pkgs : $pkgs; $args{timeout} //= 90; testapi::x11_start_program('xterm'); $self->become_root; ensure_serialdev_permissions; quit_packagekit; zypper_call "in $pkglist"; wait_still_screen 1; send_key("alt-f4"); # close xterm assert_screen 'generic-desktop' if is_opensuse; } =head2 script_sudo Execute the given command as sudo =cut sub script_sudo { my ($self, $prog, $wait) = @_; my $str = time; if ($wait > 0) { $prog = "$prog; echo $str-\$?- > /dev/$testapi::serialdev" unless $prog eq 'bash'; } enter_cmd "clear"; # poo#13710 enter_cmd "su -c \'$prog\'", max_interval => 125; handle_password_prompt unless ($testapi::username eq 'root'); if ($wait > 0) { if ($prog eq 'bash') { return wait_still_screen(4, 8); } else { return wait_serial("$str-\\d+-"); } } return; } =head2 set_standard_prompt set_standard_prompt([$user] [[, os_type] [, skip_set_standard_prompt]]) C<$user> and C<os_type> affect prompt sign. C<skip_set_standard_prompt> options skip the entire routine. =cut sub set_standard_prompt { my ($self, $user, %args) = @_; return if $args{skip_set_standard_prompt} || !get_var('SET_CUSTOM_PROMPT'); $user ||= $testapi::username; my $os_type = $args{os_type} // 'linux'; my $prompt_sign = $user eq 'root' ? '#' : '$'; if ($os_type eq 'windows') { $prompt_sign = $user eq 'root' ? '# ' : '$$ '; enter_cmd "prompt $prompt_sign"; enter_cmd "cls"; # clear the screen } elsif ($os_type eq 'linux') { enter_cmd "which tput 2>&1 && PS1=\"\\\[\$(tput bold 2; tput setaf 1)\\\]$prompt_sign\\\[\$(tput sgr0)\\\] \""; } } =head2 become_root Log in as root in the current console =cut sub become_root { my ($self) = @_; $self->script_sudo('bash', 1); # No need to apply on more recent kernels if (is_sle('<=15-SP2') || is_leap('<=15.2')) { disable_serial_getty() unless $self->script_run("systemctl is-enabled serial-getty\@$testapi::serialdev"); } enter_cmd "cd /tmp"; $self->set_standard_prompt('root'); enter_cmd "clear"; } =head2 init_consoles Initialize the consoles needed during our tests =cut sub init_consoles { my ($self) = @_; # avoid complex boolean logic by setting interim variables if (check_var('BACKEND', 'svirt') && check_var('ARCH', 's390x')) { set_var('S390_ZKVM', 1); set_var('SVIRT_VNC_CONSOLE', 'x11'); } if (check_var('BACKEND', 'qemu')) { $self->add_console('root-virtio-terminal', 'virtio-terminal', {}); for (my $num = 1; $num < get_var('VIRTIO_CONSOLE_NUM', 1); $num++) { $self->add_console('root-virtio-terminal' . $num, 'virtio-terminal', {socked_path => cwd() . '/virtio_console' . $num}); } } if (get_var('SUT_IP') || get_var('VIRSH_GUEST')) { my $hostname = get_var('SUT_IP', get_var('VIRSH_GUEST')); $self->add_console( 'root-serial-ssh', 'ssh-serial', { hostname => $hostname, password => $testapi::password, user => 'root' }); $self->add_console( 'user-serial-ssh', 'ssh-serial', { hostname => $hostname, password => $testapi::password, user => $testapi::username }); } # svirt backend, except s390x ARCH if (is_svirt_except_s390x) { my $hostname = get_var('VIRSH_GUEST'); my $port = get_var('VIRSH_INSTANCE', 1) + 5900; $self->add_console( 'sut', 'vnc-base', { hostname => $hostname, port => $port, password => $testapi::password }); set_var('SVIRT_VNC_CONSOLE', 'sut'); } else { # sut-serial (serial terminal: emulation of QEMU's virtio console for svirt) $self->add_console('root-sut-serial', 'ssh-virtsh-serial', { pty_dev => SERIAL_TERMINAL_DEFAULT_DEVICE, target_port => SERIAL_TERMINAL_DEFAULT_PORT}); } if ((get_var('BACKEND', '') =~ /qemu|ikvm/ || (get_var('BACKEND', '') =~ /generalhw/ && get_var('GENERAL_HW_VNC_IP')) || is_svirt_except_s390x)) { $self->add_console('install-shell', 'tty-console', {tty => 2}); $self->add_console('installation', 'tty-console', {tty => check_var('VIDEOMODE', 'text') ? 1 : 7}); $self->add_console('install-shell2', 'tty-console', {tty => 9}); # On SLE15 X is running on tty2 see bsc#1054782 $self->add_console('root-console', 'tty-console', {tty => get_root_console_tty}); $self->add_console('user-console', 'tty-console', {tty => 4}); $self->add_console('log-console', 'tty-console', {tty => 5}); $self->add_console('displaymanager', 'tty-console', {tty => 7}); $self->add_console('x11', 'tty-console', {tty => get_x11_console_tty}); $self->add_console('tunnel-console', 'tty-console', {tty => 3}) if get_var('TUNNELED'); } if (check_var('VIRSH_VMM_FAMILY', 'hyperv')) { $self->add_console( 'hyperv-intermediary', 'ssh-virtsh', { hostname => get_required_var('VIRSH_GUEST'), password => get_var('VIRSH_GUEST_PASSWORD')}); } if (get_var('BACKEND', '') =~ /ikvm|ipmi|spvm|pvm_hmc/) { $self->add_console( 'root-ssh', 'ssh-xterm', { hostname => get_required_var('SUT_IP'), password => $testapi::password, user => 'root', serial => 'rm -f /dev/sshserial; mkfifo /dev/sshserial; chmod 666 /dev/sshserial; while true; do cat /dev/sshserial; done', gui => 1 }); } # Use ssh consoles on generalhw, without VNC connection if (get_var('BACKEND', '') =~ /generalhw/ && !defined(get_var('GENERAL_HW_VNC_IP'))) { my $hostname = get_required_var('SUT_IP'); # 'root-ssh' is only needed to set a serial over ssh $self->add_console( 'root-ssh', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root', serial => 'rm -f /dev/sshserial; mkfifo /dev/sshserial; chmod 666 /dev/sshserial; tail -fn +1 /dev/sshserial' }) if (has_serial_over_ssh); $self->add_console( 'root-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root', }); $self->add_console( 'log-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root', }); $self->add_console( 'user-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => $testapi::username }); } if (get_var('BACKEND', '') =~ /ipmi|s390x|spvm|pvm_hmc/ || get_var('S390_ZKVM')) { my $hostname; $hostname = get_var('VIRSH_GUEST') if get_var('S390_ZKVM'); $hostname = get_required_var('SUT_IP') if get_var('BACKEND', '') =~ /ipmi|spvm|pvm_hmc/; if (check_var('BACKEND', 's390x')) { # expand the S390 params my $s390_params = get_var("S390_NETWORK_PARAMS"); my $s390_host = get_required_var('S390_HOST'); $s390_params =~ s,\@S390_HOST\@,$s390_host,g; set_var("S390_NETWORK_PARAMS", $s390_params); ($hostname) = $s390_params =~ /Hostname=(\S+)/; } if (check_var("VIDEOMODE", "text")) { # adds console for text-based installation on s390x $self->add_console( 'installation', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root' }); } elsif (check_var("VIDEOMODE", "ssh-x")) { $self->add_console( 'installation', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root', gui => 1 }); } else { $self->add_console( 'installation', 'vnc-base', { hostname => $hostname, port => 5901, password => $testapi::password }); } $self->add_console( 'x11', 'vnc-base', { hostname => $hostname, port => 5901, password => $testapi::password }); $self->add_console( 'iucvconn', 'ssh-iucvconn', { hostname => $hostname, password => $testapi::password }); $self->add_console( 'install-shell', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root' }); $self->add_console( 'root-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root' }); $self->add_console( 'user-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => $testapi::username }); $self->add_console( 'log-console', 'ssh-xterm', { hostname => $hostname, password => $testapi::password, user => 'root' }); } return; } =head2 ensure_user Make sure the right user is logged in, e.g. when using remote shells =cut sub ensure_user { my ($user) = @_; enter_cmd("su - $user") if $user ne 'root'; } =head2 hyperv_console_switch hyperv_console_switch($console, $nr) On Hyper-V console switch from one console to another is not possible with the general 'Ctrl-Alt-Fx' binding as the combination is lost somewhere in VNC-to-RDP translation. For VT-to-VT switch we use 'Alt-Fx' binding, however this is not enough for X11-to-VT switch, which requires the missing 'Ctrl'. However, in X11 we can use `chvt` command to do the switch for us. This is expected to be executed either from activate_console(), or from console_selected(), test variable C<CONSOLE_JUST_ACTIVATED> works as a mutually exclusive lock. Requires C<console> name, an actual VT number C<nr> is optional. =cut sub hyperv_console_switch { my ($self, $console, $nr) = @_; return unless check_var('VIRSH_VMM_FAMILY', 'hyperv'); # If CONSOLE_JUST_ACTIVATED is set, this sub was already executed for current console. # If we switch to 'x11', we are already there because, if we switch from VT then 'Alt-Fx' # works, if we switch from 'x11' to 'x11' then we don't have to do anything. if (get_var('CONSOLE_JUST_ACTIVATED') || $console eq 'x11' || $console eq 'displaymanager') { set_var('CONSOLE_JUST_ACTIVATED', 0); return; } die 'hyperv_console_switch: Console was not provided' unless $console; diag 'hyperv_console_switch: Console number was not provided' unless $nr; # If we are in VT, 'Alt-Fx' switch already worked return if check_screen('any-console', 10); # We are in X11 and wan't to switch to VT if (check_var('DESKTOP', 'textmode') && check_var('VIDEOMODE', 'text')) { testapi::assert_still_screen { enter_cmd "xinit /usr/bin/xterm -- :1 &" }; testapi::mouse_set(10, 10); } else { testapi::x11_start_program('xterm'); } self->distribution::script_sudo("exec chvt $nr; exit", 0); } =head2 console_nr console_nr($console) Return console VT number with regards to it's name. =cut sub console_nr { my ($console) = @_; $console =~ m/^(\w+)-(console|virtio-terminal|sut-serial|ssh|shell)/; my ($name) = ($1) || return; my $nr = 4; $nr = get_root_console_tty if ($name eq 'root'); $nr = 5 if ($name eq 'log'); $nr = 3 if ($name eq 'tunnel'); return $nr; } =head2 activate_console activate_console($console [, [ensure_tty_selected => 0|1] [, skip_set_standard_prompt => 0|1] [, skip_setterm => 0|1] [, timeout => $timeout]]) Callback whenever a console is selected for the first time. Accepts arguments provided to select_console(). C<skip_set_standard_prompt> and C<skip_setterm> arguments skip respective routines, e.g. if you want select_console() without addition console setup. Then, at some point, you should set it on your own. Option C<ensure_tty_selected> ensures TTY is selected. C<timeout> is set on the internal C<assert_screen> call and can be set to configure a timeout value different than default. =cut sub activate_console { my ($self, $console, %args) = @_; # Select configure serial and redirect to root-ssh instead return use_ssh_serial_console if (get_var('BACKEND', '') =~ /ikvm|ipmi|spvm|pvm_hmc/ && $console =~ m/^(root-console|install-shell|log-console)$/); if ($console eq 'install-shell') { if (get_var("LIVECD")) { # LIVE CDa do not run inst-consoles as started by inst-linux (it's regular live run, auto-starting yast live installer) assert_screen "tty2-selected", 10; # login as root, who does not have a password on Live-CDs wait_screen_change { enter_cmd "root" }; } else { # on s390x we need to login here by providing a password handle_password_prompt if check_var('ARCH', 's390x'); assert_screen "inst-console"; } } $console =~ m/^(\w+)-(console|virtio-terminal|sut-serial|ssh|shell)/; my ($name, $user, $type) = ($1, $1, $2); $name = $user //= ''; $type //= ''; if ($name eq 'user') { $user = $testapi::username; } elsif ($name =~ /log|tunnel/) { $user = 'root'; } # Use ssh for generalhw(ssh/no VNC) for given consoles $type = 'ssh' if (get_var('BACKEND', '') =~ /generalhw/ && !defined(get_var('GENERAL_HW_VNC_IP')) && $console =~ /root-console|install-shell|user-console|log-console/); diag "activate_console, console: $console, type: $type"; if ($type eq 'console') { # different handling for ssh consoles on s390x zVM if (get_var('BACKEND', '') =~ /ipmi|s390x|spvm|pvm_hmc/ || get_var('S390_ZKVM')) { diag 'backend ipmi || spvm || pvm_hmc || s390x || zkvm'; $user ||= 'root'; handle_password_prompt; ensure_user($user); } else { my $nr = console_nr($console); $self->hyperv_console_switch($console, $nr); my @tags = ("tty$nr-selected", "text-logged-in-$user"); # s390 zkvm uses a remote ssh session which is root by default so # search for that and su to user later if necessary push(@tags, 'text-logged-in-root') if get_var('S390_ZKVM'); push(@tags, 'wsl-linux-prompt') if (get_var('FLAVOR') eq 'WSL'); # Wait a bit to avoid false match on 'text-logged-in-$user', if tty has not switched yet, # or premature typing of credentials on sle15+ my $stilltime = is_sle('15+') ? 6 : 1; wait_still_screen $stilltime; # we need to wait more than five seconds here to pass the idle timeout in # case the system is still booting (https://bugzilla.novell.com/show_bug.cgi?id=895602) # or when using remote consoles which can take some seconds, e.g. # just after ssh login assert_screen \@tags, $args{timeout} // 60; if (match_has_tag("tty$nr-selected")) { enter_cmd "$user"; handle_password_prompt; } elsif (match_has_tag('text-logged-in-root')) { ensure_user($user); } elsif (match_has_tag('wsl-linux-prompt')) { return; } } # For poo#81016, need enlarge wait time for aarch64. my $waittime = check_var('ARCH', 'aarch64') ? 120 : 60; assert_screen "text-logged-in-$user", $waittime; unless ($args{skip_set_standard_prompt}) { $self->set_standard_prompt($user, skip_set_standard_prompt => $args{skip_set_standard_prompt}); assert_screen $console; } } elsif ($type =~ /^(virtio-terminal|sut-serial)$/) { serial_terminal::login($user, $self->{serial_term_prompt}); } elsif ($console eq 'novalink-ssh') { assert_screen "password-prompt-novalink"; type_password get_required_var('NOVALINK_PASSWORD'); send_key('ret'); my $user = get_var('NOVALINK_USERNAME', 'root'); assert_screen("text-logged-in-$user", 60); $self->set_standard_prompt($user); } elsif ($console eq 'powerhmc-ssh') { assert_screen "password-prompt-hmc"; type_password get_required_var('HMC_PASSWORD'); send_key('ret'); my $user = get_var('HMC_USERNAME', 'hscroot'); assert_screen("text-logged-in-$user", 60); } elsif ($type eq 'ssh') { $user ||= 'root'; handle_password_prompt; ensure_user($user); assert_screen(["text-logged-in-$user", "text-login"], 60); $self->set_standard_prompt($user, skip_set_standard_prompt => $args{skip_set_standard_prompt}); set_sshserial_dev if has_serial_over_ssh; # We can use ssh console with a real serial already grabbed } elsif ($console eq 'svirt' || $console eq 'hyperv-intermediary') { my $os_type = (check_var('VIRSH_VMM_FAMILY', 'hyperv') && $console eq 'svirt') ? 'windows' : 'linux'; handle_password_prompt($console); $self->set_standard_prompt('root', os_type => $os_type, skip_set_standard_prompt => $args{skip_set_standard_prompt}); save_svirt_pty; } elsif ( $console eq 'installation' && ((get_var('BACKEND', '') =~ /ipmi|s390x|spvm|pvm_hmc/) || get_var('S390_ZKVM')) && (get_var('VIDEOMODE', '') =~ /text|ssh-x/)) { diag 'activate_console called with installation for ssh based consoles'; $user ||= 'root'; handle_password_prompt; ensure_user($user); assert_screen "text-logged-in-$user", 60; } else { diag 'activate_console called with generic type, no action'; } # Both consoles and shells should be prevented from blanking if ((($type eq 'console') or ($type =~ /shell/)) and (get_var('BACKEND', '') =~ /qemu|svirt/)) { # On s390x 'setterm' binary is not present as there's no linux console unless (check_var('ARCH', 's390x') || get_var('PUBLIC_CLOUD')) { # Disable console screensaver $self->script_run('setterm -blank 0') unless $args{skip_setterm}; } } if (get_var('TUNNELED') && $name !~ /tunnel/) { die "Console '$console' activated in TUNNEL mode activated but tunnel(s) are not yet initialized, use the 'tunnel' console and call 'setup_ssh_tunnels' first" unless get_var('_SSH_TUNNELS_INITIALIZED'); $self->script_run('ssh -t sut', 0); ensure_user($user) unless (get_var('PUBLIC_CLOUD')); } set_var('CONSOLE_JUST_ACTIVATED', 1); } =head2 console_selected console_selected($console [, await_console => $await_console] [, tags => $tags ] [, ignore => $ignore ] [, timeout => $timeout ]); Overrides C<select_console> callback from C<testapi>. Waits for console by calling assert_screen on C<tags>, by default the name of the selected console. C<await_console> is set to 1 by default. Can be set to 0 to skip the check for the console. Call for example C<select_console('root-console', await_console => 0)> if there should be no checking for the console to be shown. Useful when the check should or must be test module specific. C<ignore> can be overridden to not check on certain consoles. By default the known uncheckable consoles are already ignored. C<timeout> is set on the internal C<assert_screen> call and can be set to configure a timeout value different than default. =cut sub console_selected { my ($self, $console, %args) = @_; if ((exists $testapi::testapi_console_proxies{'root-ssh'}) && $console =~ m/^(root-console|install-shell|log-console)$/) { $console = 'root-ssh'; my $ret = query_isotovideo('backend_select_console', {testapi_console => $console}); die $ret->{error} if $ret->{error}; $autotest::selected_console = $console; } $args{await_console} //= 1; $args{tags} //= $console; $args{ignore} //= qr{sut|root-virtio-terminal|root-sut-serial|iucvconn|svirt|root-ssh|hyperv-intermediary|serial-ssh}; $args{timeout} //= 30; if ($args{tags} =~ $args{ignore} || !$args{await_console} || (get_var('FLAVOR') eq 'WSL')) { set_var('CONSOLE_JUST_ACTIVATED', 0); return; } $self->hyperv_console_switch($console, console_nr($console)); set_var('CONSOLE_JUST_ACTIVATED', 0); # x11 needs special handling because we can not easily know if screen is # locked, display manager is waiting for login, etc. return ensure_unlocked_desktop if $args{tags} =~ /x11/; assert_screen($args{tags}, no_wait => 1, timeout => $args{timeout}); if (match_has_tag('workqueue_lockup')) { record_soft_failure 'bsc#1126782'; send_key 'ret'; } } 1;
37.218506
214
0.598832
ed5f9b5bc44aa0c87fb289b74cbdf909466f68f5
5,595
pm
Perl
lib/Google/Ads/AdWords/v201809/BasicUserList.pm
googleads/googleads-perl-lib
69e66d7e46fbd8ad901581b108ea6c14212701cf
[ "Apache-2.0" ]
4
2015-04-23T01:59:40.000Z
2021-10-12T23:14:36.000Z
lib/Google/Ads/AdWords/v201809/BasicUserList.pm
googleads/googleads-perl-lib
69e66d7e46fbd8ad901581b108ea6c14212701cf
[ "Apache-2.0" ]
23
2015-02-19T17:03:58.000Z
2019-07-01T10:15:46.000Z
lib/Google/Ads/AdWords/v201809/BasicUserList.pm
googleads/googleads-perl-lib
69e66d7e46fbd8ad901581b108ea6c14212701cf
[ "Apache-2.0" ]
10
2015-08-03T07:51:58.000Z
2020-09-26T16:17:46.000Z
package Google::Ads::AdWords::v201809::BasicUserList; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/rm/v201809' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use base qw(Google::Ads::AdWords::v201809::UserList); # Variety: sequence use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %id_of :ATTR(:get<id>); my %isReadOnly_of :ATTR(:get<isReadOnly>); my %name_of :ATTR(:get<name>); my %description_of :ATTR(:get<description>); my %status_of :ATTR(:get<status>); my %integrationCode_of :ATTR(:get<integrationCode>); my %accessReason_of :ATTR(:get<accessReason>); my %accountUserListStatus_of :ATTR(:get<accountUserListStatus>); my %membershipLifeSpan_of :ATTR(:get<membershipLifeSpan>); my %size_of :ATTR(:get<size>); my %sizeRange_of :ATTR(:get<sizeRange>); my %sizeForSearch_of :ATTR(:get<sizeForSearch>); my %sizeRangeForSearch_of :ATTR(:get<sizeRangeForSearch>); my %listType_of :ATTR(:get<listType>); my %isEligibleForSearch_of :ATTR(:get<isEligibleForSearch>); my %isEligibleForDisplay_of :ATTR(:get<isEligibleForDisplay>); my %closingReason_of :ATTR(:get<closingReason>); my %UserList__Type_of :ATTR(:get<UserList__Type>); my %conversionTypes_of :ATTR(:get<conversionTypes>); __PACKAGE__->_factory( [ qw( id isReadOnly name description status integrationCode accessReason accountUserListStatus membershipLifeSpan size sizeRange sizeForSearch sizeRangeForSearch listType isEligibleForSearch isEligibleForDisplay closingReason UserList__Type conversionTypes ) ], { 'id' => \%id_of, 'isReadOnly' => \%isReadOnly_of, 'name' => \%name_of, 'description' => \%description_of, 'status' => \%status_of, 'integrationCode' => \%integrationCode_of, 'accessReason' => \%accessReason_of, 'accountUserListStatus' => \%accountUserListStatus_of, 'membershipLifeSpan' => \%membershipLifeSpan_of, 'size' => \%size_of, 'sizeRange' => \%sizeRange_of, 'sizeForSearch' => \%sizeForSearch_of, 'sizeRangeForSearch' => \%sizeRangeForSearch_of, 'listType' => \%listType_of, 'isEligibleForSearch' => \%isEligibleForSearch_of, 'isEligibleForDisplay' => \%isEligibleForDisplay_of, 'closingReason' => \%closingReason_of, 'UserList__Type' => \%UserList__Type_of, 'conversionTypes' => \%conversionTypes_of, }, { 'id' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'isReadOnly' => 'SOAP::WSDL::XSD::Typelib::Builtin::boolean', 'name' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'description' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'status' => 'Google::Ads::AdWords::v201809::UserListMembershipStatus', 'integrationCode' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'accessReason' => 'Google::Ads::AdWords::v201809::AccessReason', 'accountUserListStatus' => 'Google::Ads::AdWords::v201809::AccountUserListStatus', 'membershipLifeSpan' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'size' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'sizeRange' => 'Google::Ads::AdWords::v201809::SizeRange', 'sizeForSearch' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'sizeRangeForSearch' => 'Google::Ads::AdWords::v201809::SizeRange', 'listType' => 'Google::Ads::AdWords::v201809::UserListType', 'isEligibleForSearch' => 'SOAP::WSDL::XSD::Typelib::Builtin::boolean', 'isEligibleForDisplay' => 'SOAP::WSDL::XSD::Typelib::Builtin::boolean', 'closingReason' => 'Google::Ads::AdWords::v201809::UserListClosingReason', 'UserList__Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'conversionTypes' => 'Google::Ads::AdWords::v201809::UserListConversionType', }, { 'id' => 'id', 'isReadOnly' => 'isReadOnly', 'name' => 'name', 'description' => 'description', 'status' => 'status', 'integrationCode' => 'integrationCode', 'accessReason' => 'accessReason', 'accountUserListStatus' => 'accountUserListStatus', 'membershipLifeSpan' => 'membershipLifeSpan', 'size' => 'size', 'sizeRange' => 'sizeRange', 'sizeForSearch' => 'sizeForSearch', 'sizeRangeForSearch' => 'sizeRangeForSearch', 'listType' => 'listType', 'isEligibleForSearch' => 'isEligibleForSearch', 'isEligibleForDisplay' => 'isEligibleForDisplay', 'closingReason' => 'closingReason', 'UserList__Type' => 'UserList.Type', 'conversionTypes' => 'conversionTypes', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201809::BasicUserList =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType BasicUserList from the namespace https://adwords.google.com/api/adwords/rm/v201809. User list targeting as a collection of conversion types. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * conversionTypes =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
29.140625
90
0.655049
ed6cca57d6d1d19f0d6e9105af4e81f90a20cec6
1,436
t
Perl
test/thread_test.t
glhrmfrts/terrasync
626a2f264950f54ed9f3eb33d07ac10546569997
[ "MIT" ]
1
2021-11-13T14:59:04.000Z
2021-11-13T14:59:04.000Z
test/thread_test.t
glhrmfrts/terrasync
626a2f264950f54ed9f3eb33d07ac10546569997
[ "MIT" ]
null
null
null
test/thread_test.t
glhrmfrts/terrasync
626a2f264950f54ed9f3eb33d07ac10546569997
[ "MIT" ]
null
null
null
terralib.includepath = terralib.includepath .. ";C:\\code\\terra\\terrasync\\include\\pthreads4w" package.terrapath = package.terrapath .. ";C:\\code\\terra\\?.t" local C = terralib.includecstring [[ #include <stdio.h> #include <string.h> #include <windows.h> ]] local M = require 'terrasync.mutex' local T = require 'terrasync.thread' local struct State { mutex: M.Mutex okay: bool } local terra printstuff(arg: &State) C.Sleep(5000) C.printf("Hello world from thread!\n") [ M.withlock(`arg.mutex, quote arg.okay=true end) ] end terra main(argc: int, argv: &rawstring) var mutex, merr = M.makemutex() if merr:iserror() then C.printf("Error creating mutex: %s\n", merr:getstring()) return end defer mutex:destroy() var state = State{ mutex, false } var t, terr = T.makethread(printstuff, &state) if terr:iserror() then C.printf("Error creating thread: %s\n", terr:getstring()) return end defer t:join() C.printf("%d\n", state.okay) var i: int = 0 while true do [ M.withlock(`state.mutex, quote if state.okay then break end end) ] C.printf("Hello world from main: %d!\n", i) C.Sleep(1000) i = i + 1 end C.printf("%d\n", state.okay) end terralib.saveobj("build/thread_test.exe", { main = main }, { "/link", "C:\\code\\terra\\terrasync\\libs\\x64\\pthreads4w.lib" })
24.758621
128
0.617688
ed52cf83d2a16d47923245ac368d15ef4d30a331
299
al
Perl
Apps/CZ/CashDeskLocalization/app/Src/TableExtensions/BankAccount.TableExt.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
337
2019-05-07T06:04:40.000Z
2022-03-31T10:07:42.000Z
Apps/CZ/CashDeskLocalization/app/Src/TableExtensions/BankAccount.TableExt.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
14,850
2019-05-07T06:04:27.000Z
2022-03-31T19:53:28.000Z
Apps/CZ/CashDeskLocalization/app/Src/TableExtensions/BankAccount.TableExt.al
MiguelMercadoActual/ALAppExtensions
97ee3823053eb32fa7e38dc3d1e7a89bdcca8d7b
[ "MIT" ]
374
2019-05-09T10:08:14.000Z
2022-03-31T17:48:32.000Z
tableextension 11778 "Bank Account CZP" extends "Bank Account" { fields { field(11750; "Account Type CZP"; Enum "Bank Account Type CZP") { Caption = 'Account Type'; DataClassification = CustomerContent; Editable = false; } } }
23
70
0.558528
ed5ade1bac55f0fb5b4e9769207b65ecee7b4c56
1,205
pm
Perl
lib/Test/Cukes/Feature.pm
gugod/Test-Cukes
29ce08557c012bf86909f61940b3151ed9c932a8
[ "MIT" ]
3
2015-01-10T00:48:22.000Z
2015-11-09T01:36:10.000Z
lib/Test/Cukes/Feature.pm
gugod/Test-Cukes
29ce08557c012bf86909f61940b3151ed9c932a8
[ "MIT" ]
1
2020-05-19T05:23:10.000Z
2020-05-19T05:23:10.000Z
lib/Test/Cukes/Feature.pm
gugod/Test-Cukes
29ce08557c012bf86909f61940b3151ed9c932a8
[ "MIT" ]
null
null
null
package Test::Cukes::Feature; use Moose; use Test::Cukes::Scenario; has name => ( is => "rw", required => 1, isa => "Str" ); has body => ( is => "rw", isa => "Str" ); has scenarios => ( is => "rw", isa => "ArrayRef[Test::Cukes::Scenario]" ); sub BUILDARGS { my $class = shift; if (@_ == 1 && ! ref $_[0]) { my $text = shift; my $args = { name => "", body => "", scenarios => [] }; my @blocks = split /\n\n/, $text; my $meta = shift @blocks; unless ($meta =~ m/^Feature:\s([^\n]+x?)$(.+)\z/sm) { die "Cannot extra feature name and body from text:\n----\n$meta\n----\n\n"; } $args->{name} = $1; $args->{body} = $2; for my $scenario_text (@blocks) { unless ($scenario_text =~ s/^ (.+?)$/$1/mg) { die "Scenario text is not properly indented:\n----\n${scenario_text}\n----\n\n"; } push @{$args->{scenarios}}, Test::Cukes::Scenario->new($scenario_text) } return $args; } return $class->SUPER::BUILDARGS(@_); } __PACKAGE__->meta->make_immutable; no Moose; 1;
21.140351
96
0.461411
ed66bd9d5e6efc67de02d0c06eb95f17fb48e5e1
4,762
pm
Perl
scr/pm/IO/All/Base.pm
AmeerAbdelhadi/Timing-Driven-Variation-Aware-Clock-Mesh-Synthesis
755ae558be1a64bc0d41774f5d8b386700d64f4f
[ "BSD-3-Clause" ]
5
2019-07-04T16:41:27.000Z
2021-12-20T20:21:24.000Z
scr/pm/IO/All/Base.pm
AmeerAbdelhadi/Timing-Driven-Variation-Aware-Clock-Mesh-Synthesis
755ae558be1a64bc0d41774f5d8b386700d64f4f
[ "BSD-3-Clause" ]
null
null
null
scr/pm/IO/All/Base.pm
AmeerAbdelhadi/Timing-Driven-Variation-Aware-Clock-Mesh-Synthesis
755ae558be1a64bc0d41774f5d8b386700d64f4f
[ "BSD-3-Clause" ]
4
2017-12-01T08:17:28.000Z
2019-07-07T23:47:44.000Z
package IO::All::Base; use strict; use warnings; use Fcntl; sub import { my $class = shift; my $flag = $_[0] || ''; my $package = caller; no strict 'refs'; if ($flag eq '-base') { push @{$package . "::ISA"}, $class; *{$package . "::$_"} = \&$_ for qw'field const option chain proxy proxy_open'; } elsif ($flag eq -mixin) { mixin_import(scalar(caller(0)), $class, @_); } else { my @flags = @_; for my $export (@{$class . '::EXPORT'}) { *{$package . "::$export"} = $export eq 'io' ? $class->generate_constructor(@flags) : \&{$class . "::$export"}; } } } sub generate_constructor { my $class = shift; my (@flags, %flags, $key); for (@_) { if (s/^-//) { push @flags, $_; $flags{$_} = 1; $key = $_; } else { $flags{$key} = $_ if $key; } } my $constructor; $constructor = sub { my $self = $class->new(@_); for (@flags) { $self->$_($flags{$_}); } $self->constructor($constructor); return $self; } } sub _init { my $self = shift; $self->io_handle(undef); $self->is_open(0); return $self; } #=============================================================================== # Closure generating functions #=============================================================================== sub option { my $package = caller; my ($field, $default) = @_; $default ||= 0; field("_$field", $default); no strict 'refs'; *{"${package}::$field"} = sub { my $self = shift; *$self->{"_$field"} = @_ ? shift(@_) : 1; return $self; }; } sub chain { my $package = caller; my ($field, $default) = @_; no strict 'refs'; *{"${package}::$field"} = sub { my $self = shift; if (@_) { *$self->{$field} = shift; return $self; } return $default unless exists *$self->{$field}; return *$self->{$field}; }; } sub field { my $package = caller; my ($field, $default) = @_; no strict 'refs'; return if defined &{"${package}::$field"}; *{"${package}::$field"} = sub { my $self = shift; unless (exists *$self->{$field}) { *$self->{$field} = ref($default) eq 'ARRAY' ? [] : ref($default) eq 'HASH' ? {} : $default; } return *$self->{$field} unless @_; *$self->{$field} = shift; }; } sub const { my $package = caller; my ($field, $default) = @_; no strict 'refs'; return if defined &{"${package}::$field"}; *{"${package}::$field"} = sub { $default }; } sub proxy { my $package = caller; my ($proxy) = @_; no strict 'refs'; return if defined &{"${package}::$proxy"}; *{"${package}::$proxy"} = sub { my $self = shift; my @return = $self->io_handle->$proxy(@_); $self->error_check; wantarray ? @return : $return[0]; }; } sub proxy_open { my $package = caller; my ($proxy, @args) = @_; no strict 'refs'; return if defined &{"${package}::$proxy"}; my $method = sub { my $self = shift; $self->assert_open(@args); my @return = $self->io_handle->$proxy(@_); $self->error_check; wantarray ? @return : $return[0]; }; *{"$package\::$proxy"} = (@args and $args[0] eq '>') ? sub { my $self = shift; $self->$method(@_); return $self; } : $method; } sub mixin_import { my $target_class = shift; $target_class = caller(0) if $target_class eq 'mixin'; my $mixin_class = shift or die "Nothing to mixin"; eval "require $mixin_class"; my $pseudo_class = CORE::join '-', $target_class, $mixin_class; my %methods = mixin_methods($mixin_class); no strict 'refs'; no warnings; @{"$pseudo_class\::ISA"} = @{"$target_class\::ISA"}; @{"$target_class\::ISA"} = ($pseudo_class); for (keys %methods) { *{"$pseudo_class\::$_"} = $methods{$_}; } } sub mixin_methods { my $mixin_class = shift; no strict 'refs'; my %methods = all_methods($mixin_class); map { $methods{$_} ? ($_, \ &{"$methods{$_}\::$_"}) : ($_, \ &{"$mixin_class\::$_"}) } (keys %methods); } sub all_methods { no strict 'refs'; my $class = shift; my %methods = map { ($_, $class) } grep { defined &{"$class\::$_"} and not /^_/ } keys %{"$class\::"}; return (%methods); } 1;
24.172589
80
0.452751
ed6dd3af784e3aaa1d4910c8d4f80d294539212d
386
pm
Perl
lib/Viroverse/Model/pcr_pool_pcr_product.pm
MullinsLab/viroverse
fca0c5f81ce9d5fdcef96d661def0699ba4209cb
[ "MIT" ]
7
2019-02-04T20:37:19.000Z
2020-10-07T18:23:09.000Z
lib/Viroverse/Model/pcr_pool_pcr_product.pm
MullinsLab/viroverse
fca0c5f81ce9d5fdcef96d661def0699ba4209cb
[ "MIT" ]
75
2019-03-07T20:44:04.000Z
2020-01-22T11:27:03.000Z
lib/Viroverse/Model/pcr_pool_pcr_product.pm
MullinsLab/viroverse
fca0c5f81ce9d5fdcef96d661def0699ba4209cb
[ "MIT" ]
null
null
null
package Viroverse::Model::pcr_pool_pcr_product; use base 'Viroverse::CDBI'; use strict; use warnings; __PACKAGE__->table('viroserve.pcr_pool_pcr_product'); __PACKAGE__->columns(Primary => qw[ pcr_pool_id pcr_product_id ] ); __PACKAGE__->has_a(pcr_product_id => 'Viroverse::Model::pcr'); __PACKAGE__->has_a(pcr_pool_id => 'Viroverse::Model::pcr_pool'); 1;
21.444444
64
0.712435
ed44f3e9e038fafc839aaa401be96997cda7884d
26,782
t
Perl
parts/k8s/kubernetesparams.t
oivindoh/acs-engine
9eaa1c2dfa582c021481a4caed88e41e7f3a70ed
[ "MIT" ]
null
null
null
parts/k8s/kubernetesparams.t
oivindoh/acs-engine
9eaa1c2dfa582c021481a4caed88e41e7f3a70ed
[ "MIT" ]
null
null
null
parts/k8s/kubernetesparams.t
oivindoh/acs-engine
9eaa1c2dfa582c021481a4caed88e41e7f3a70ed
[ "MIT" ]
null
null
null
{{if .HasAadProfile}} "aadTenantId": { "defaultValue": "", "metadata": { "description": "The AAD tenant ID to use for authentication. If not specified, will use the tenant of the deployment subscription." }, "type": "string" }, "aadAdminGroupId": { "defaultValue": "", "metadata": { "description": "The AAD default Admin group Object ID used to create a cluster-admin RBAC role." }, "type": "string" }, {{end}} {{if IsHostedMaster}} "kubernetesEndpoint": { "metadata": { "description": "The Kubernetes API endpoint https://<kubernetesEndpoint>:443" }, "type": "string" }, {{else}} {{if not IsOpenShift}} "etcdServerCertificate": { "metadata": { "description": "The base 64 server certificate used on the master" }, "type": "string" }, "etcdServerPrivateKey": { "metadata": { "description": "The base 64 server private key used on the master." }, "type": "securestring" }, "etcdClientCertificate": { "metadata": { "description": "The base 64 server certificate used on the master" }, "type": "string" }, "etcdClientPrivateKey": { "metadata": { "description": "The base 64 server private key used on the master." }, "type": "securestring" }, "etcdPeerCertificate0": { "metadata": { "description": "The base 64 server certificates used on the master" }, "type": "string" }, "etcdPeerPrivateKey0": { "metadata": { "description": "The base 64 server private keys used on the master." }, "type": "securestring" }, {{if ge .MasterProfile.Count 3}} "etcdPeerCertificate1": { "metadata": { "description": "The base 64 server certificates used on the master" }, "type": "string" }, "etcdPeerCertificate2": { "metadata": { "description": "The base 64 server certificates used on the master" }, "type": "string" }, "etcdPeerPrivateKey1": { "metadata": { "description": "The base 64 server private keys used on the master." }, "type": "securestring" }, "etcdPeerPrivateKey2": { "metadata": { "description": "The base 64 server private keys used on the master." }, "type": "securestring" }, {{if ge .MasterProfile.Count 5}} "etcdPeerCertificate3": { "metadata": { "description": "The base 64 server certificates used on the master" }, "type": "string" }, "etcdPeerCertificate4": { "metadata": { "description": "The base 64 server certificates used on the master" }, "type": "string" }, "etcdPeerPrivateKey3": { "metadata": { "description": "The base 64 server private keys used on the master." }, "type": "securestring" }, "etcdPeerPrivateKey4": { "metadata": { "description": "The base 64 server private keys used on the master." }, "type": "securestring" }, {{end}} {{end}} {{end}} {{end}} {{if not IsOpenShift}} "apiServerCertificate": { "metadata": { "description": "The base 64 server certificate used on the master" }, "type": "string" }, "apiServerPrivateKey": { "metadata": { "description": "The base 64 server private key used on the master." }, "type": "securestring" }, "caCertificate": { "metadata": { "description": "The base 64 certificate authority certificate" }, "type": "string" }, "caPrivateKey": { "metadata": { "description": "The base 64 CA private key used on the master." }, "type": "securestring" }, "clientCertificate": { "metadata": { "description": "The base 64 client certificate used to communicate with the master" }, "type": "string" }, "clientPrivateKey": { "metadata": { "description": "The base 64 client private key used to communicate with the master" }, "type": "securestring" }, "kubeConfigCertificate": { "metadata": { "description": "The base 64 certificate used by cli to communicate with the master" }, "type": "string" }, "kubeConfigPrivateKey": { "metadata": { "description": "The base 64 private key used by cli to communicate with the master" }, "type": "securestring" }, {{end}} "generatorCode": { "metadata": { "description": "The generator code used to identify the generator" }, "type": "string" }, "orchestratorName": { "metadata": { "description": "The orchestrator name used to identify the orchestrator. This must be no more than 3 digits in length, otherwise it will exceed Windows Naming" }, "minLength": 3, "maxLength": 3, "type": "string" }, "dockerBridgeCidr": { "metadata": { "description": "Docker bridge network IP address and subnet" }, "type": "string" }, "kubeClusterCidr": { "metadata": { "description": "Kubernetes cluster subnet" }, "type": "string" }, "kubeDNSServiceIP": { "metadata": { "description": "Kubernetes DNS IP" }, "type": "string" }, "kubeServiceCidr": { "metadata": { "description": "Kubernetes service address space" }, "type": "string" }, {{if not IsHostedMaster}} "kubernetesNonMasqueradeCidr": { "metadata": { "description": "kubernetesNonMasqueradeCidr cluster subnet" }, "defaultValue": "{{GetDefaultVNETCIDR}}", "type": "string" }, {{end}} "kubernetesKubeletClusterDomain": { "metadata": { "description": "--cluster-domain Kubelet config" }, "type": "string" }, "kubernetesHyperkubeSpec": { "metadata": { "description": "The container spec for hyperkube." }, "type": "string" }, "kubernetesCcmImageSpec": { "defaultValue": "", "metadata": { "description": "The container spec for cloud-controller-manager." }, "type": "string" }, "kubernetesAddonManagerSpec": { "metadata": { "description": "The container spec for hyperkube." }, "type": "string" }, "kubernetesAddonResizerSpec": { "metadata": { "description": "The container spec for addon-resizer." }, "type": "string" }, {{if .OrchestratorProfile.KubernetesConfig.IsDashboardEnabled}} "kubernetesDashboardSpec": { "metadata": { "description": "The container spec for kubernetes-dashboard-amd64." }, "type": "string" }, "kubernetesDashboardCPURequests": { "metadata": { "description": "Dashboard CPU Requests." }, "type": "string" }, "kubernetesDashboardMemoryRequests": { "metadata": { "description": "Dashboard Memory Requests." }, "type": "string" }, "kubernetesDashboardCPULimit": { "metadata": { "description": "Dashboard CPU Limit." }, "type": "string" }, "kubernetesDashboardMemoryLimit": { "metadata": { "description": "Dashboard Memory Limit." }, "type": "string" }, {{end}} "enableAggregatedAPIs": { "metadata": { "description": "Enable aggregated API on master nodes" }, "defaultValue": false, "type": "bool" }, "kubernetesExecHealthzSpec": { "metadata": { "description": "The container spec for exechealthz-amd64." }, "type": "string" }, "kubernetesDNSSidecarSpec": { "metadata": { "description": "The container spec for k8s-dns-sidecar-amd64." }, "type": "string" }, "kubernetesHeapsterSpec": { "metadata": { "description": "The container spec for heapster." }, "type": "string" }, {{if .OrchestratorProfile.IsMetricsServerEnabled}} "kubernetesMetricsServerSpec": { "metadata": { "description": "The container spec for Metrics Server." }, "type": "string" }, {{end}} {{if .IsNVIDIADevicePluginEnabled}} "kubernetesNVIDIADevicePluginSpec": { "metadata": { "description": "The container spec for NVIDIA Device Plugin." }, "type": "string" }, "kubernetesNVIDIADevicePluginCPURequests": { "metadata": { "description": "NVIDIA Device Plugin CPU Requests" }, "type": "string" }, "kubernetesNVIDIADevicePluginMemoryRequests": { "metadata": { "description": "NVIDIA Device Plugin Memory Requests" }, "type": "string" }, "kubernetesNVIDIADevicePluginCPULimit": { "metadata": { "description": "NVIDIA Device Plugin CPU Limit" }, "type": "string" }, "kubernetesNVIDIADevicePluginMemoryLimit": { "metadata": { "description": "NVIDIA Device Plugin Memory Limit" }, "type": "string" }, {{end}} {{if .OrchestratorProfile.KubernetesConfig.IsTillerEnabled}} "kubernetesTillerSpec": { "metadata": { "description": "The container spec for Helm Tiller." }, "type": "string" }, "kubernetesTillerCPURequests": { "metadata": { "description": "Helm Tiller CPU Requests." }, "type": "string" }, "kubernetesTillerMemoryRequests": { "metadata": { "description": "Helm Tiller Memory Requests." }, "type": "string" }, "kubernetesTillerCPULimit": { "metadata": { "description": "Helm Tiller CPU Limit." }, "type": "string" }, "kubernetesTillerMemoryLimit": { "metadata": { "description": "Helm Tiller Memory Limit." }, "type": "string" }, "kubernetesTillerMaxHistory": { "metadata": { "description": "Helm Tiller Max History to Store. '0' for no limit." }, "type": "string" }, {{end}} {{if .OrchestratorProfile.KubernetesConfig.IsAADPodIdentityEnabled}} "kubernetesAADPodIdentityEnabled": { "defaultValue": false, "metadata": { "description": "AAD Pod Identity status" }, "type": "bool" }, {{end}} "kubernetesACIConnectorEnabled": { "metadata": { "description": "ACI Connector Status" }, "type": "bool" }, {{if .OrchestratorProfile.KubernetesConfig.IsACIConnectorEnabled}} "kubernetesACIConnectorSpec": { "metadata": { "description": "The container spec for ACI Connector." }, "type": "string" }, "kubernetesACIConnectorNodeName": { "metadata": { "description": "Node name for ACI Connector." }, "type": "string" }, "kubernetesACIConnectorOS": { "metadata": { "description": "OS for ACI Connector." }, "type": "string" }, "kubernetesACIConnectorTaint": { "metadata": { "description": "Taint for ACI Connector." }, "type": "string" }, "kubernetesACIConnectorRegion": { "metadata": { "description": "Region for ACI Connector." }, "type": "string" }, "kubernetesACIConnectorCPURequests": { "metadata": { "description": "ACI Connector CPU Requests" }, "type": "string" }, "kubernetesACIConnectorMemoryRequests": { "metadata": { "description": "ACI Connector Memory Requests" }, "type": "string" }, "kubernetesACIConnectorCPULimit": { "metadata": { "description": "ACI Connector CPU Limit" }, "type": "string" }, "kubernetesACIConnectorMemoryLimit": { "metadata": { "description": "ACI Connector Memory Limit" }, "type": "string" }, {{end}} "kubernetesClusterAutoscalerEnabled": { "metadata": { "description": "Cluster autoscaler status" }, "type": "bool" }, {{if .OrchestratorProfile.KubernetesConfig.IsClusterAutoscalerEnabled}} "kubernetesClusterAutoscalerSpec": { "metadata": { "description": "The container spec for the cluster autoscaler." }, "type": "string" }, "kubernetesClusterAutoscalerAzureCloud": { "metadata": { "description": "Name of the Azure cloud for the cluster autoscaler." }, "type": "string" }, "kubernetesClusterAutoscalerCPULimit": { "metadata": { "description": "Cluster autoscaler cpu limit" }, "type": "string" }, "kubernetesClusterAutoscalerMemoryLimit": { "metadata": { "description": "Cluster autoscaler memory limit" }, "type": "string" }, "kubernetesClusterAutoscalerCPURequests": { "metadata": { "description": "Cluster autoscaler cpu requests" }, "type": "string" }, "kubernetesClusterAutoscalerMemoryRequests": { "metadata": { "description": "Cluster autoscaler memory requests" }, "type": "string" }, "kubernetesClusterAutoscalerMinNodes": { "metadata": { "description": "Cluster autoscaler min nodes" }, "type": "string" }, "kubernetesClusterAutoscalerMaxNodes": { "metadata": { "description": "Cluster autoscaler max nodes" }, "type": "string" }, "kubernetesClusterAutoscalerUseManagedIdentity": { "metadata": { "description": "Managed identity for the cluster autoscaler addon" }, "type": "string" }, {{end}} "flexVolumeDriverConfig": { "type": "object", "defaultValue": { "kubernetesBlobfuseFlexVolumeInstallerCPURequests": "50m", "kubernetesBlobfuseFlexVolumeInstallerMemoryRequests": "10Mi", "kubernetesBlobfuseFlexVolumeInstallerCPULimit": "50m", "kubernetesBlobfuseFlexVolumeInstallerMemoryLimit": "10Mi", "kubernetesSMBFlexVolumeInstallerCPURequests": "50m", "kubernetesSMBFlexVolumeInstallerMemoryRequests": "10Mi", "kubernetesSMBFlexVolumeInstallerCPULimit": "50m", "kubernetesSMBFlexVolumeInstallerMemoryLimit": "10Mi" } }, {{if .OrchestratorProfile.KubernetesConfig.IsKeyVaultFlexVolumeEnabled}} "kubernetesKeyVaultFlexVolumeInstallerCPURequests": { "metadata": { "description": "Key Vault FlexVolume Installer CPU Requests" }, "type": "string" }, "kubernetesKeyVaultFlexVolumeInstallerMemoryRequests": { "metadata": { "description": "Key Vault FlexVolume Installer Memory Requests" }, "type": "string" }, "kubernetesKeyVaultFlexVolumeInstallerCPULimit": { "metadata": { "description": "Key Vault FlexVolume Installer CPU Limit" }, "type": "string" }, "kubernetesKeyVaultFlexVolumeInstallerMemoryLimit": { "metadata": { "description": "Key Vault FlexVolume Installer Memory Limit" }, "type": "string" }, {{end}} {{if .OrchestratorProfile.KubernetesConfig.IsReschedulerEnabled}} "kubernetesReschedulerSpec": { "metadata": { "description": "The container spec for rescheduler." }, "type": "string" }, "kubernetesReschedulerCPURequests": { "metadata": { "description": "Rescheduler CPU Requests." }, "type": "string" }, "kubernetesReschedulerMemoryRequests": { "metadata": { "description": "Rescheduler Memory Requests." }, "type": "string" }, "kubernetesReschedulerCPULimit": { "metadata": { "description": "Rescheduler CPU Limit." }, "type": "string" }, "kubernetesReschedulerMemoryLimit": { "metadata": { "description": "Rescheduler Memory Limit." }, "type": "string" }, {{end}} {{if .OrchestratorProfile.KubernetesConfig.IsIPMasqAgentEnabled}} "kubernetesIPMasqAgentCPURequests": { "metadata": { "description": "IP Masq Agent CPU Requests" }, "type": "string" }, "kubernetesIPMasqAgentMemoryRequests": { "metadata": { "description": "IP Masq Agent Memory Requests" }, "type": "string" }, "kubernetesIPMasqAgentCPULimit": { "metadata": { "description": "IP Masq Agent CPU Limit" }, "type": "string" }, "kubernetesIPMasqAgentMemoryLimit": { "metadata": { "description": "IP Masq Agent Memory Limit" }, "type": "string" }, {{end}} "kubernetesPodInfraContainerSpec": { "metadata": { "description": "The container spec for pod infra." }, "type": "string" }, "cloudproviderConfig": { "type": "object", "defaultValue": { "cloudProviderBackoff": true, "cloudProviderBackoffRetries": 10, "cloudProviderBackoffJitter": "0", "cloudProviderBackoffDuration": 0, "cloudProviderBackoffExponent": "0", "cloudProviderRateLimit": false, "cloudProviderRateLimitQPS": "0", "cloudProviderRateLimitBucket": 0 } }, "kubernetesKubeDNSSpec": { "metadata": { "description": "The container spec for kubedns-amd64." }, "type": "string" }, "kubernetesCoreDNSSpec": { "metadata": { "description": "The container spec for coredns" }, "type": "string" }, "kubernetesDNSMasqSpec": { "metadata": { "description": "The container spec for kube-dnsmasq-amd64." }, "type": "string" }, {{if not IsOpenShift}} "dockerEngineDownloadRepo": { "defaultValue": "https://aptdocker.azureedge.net/repo", "metadata": { "description": "The docker engine download url for kubernetes." }, "type": "string" }, "dockerEngineVersion": { "metadata": { "description": "The docker engine version to install." }, "allowedValues": [ "17.05.*", "17.04.*", "17.03.*", "1.13.*", "1.12.*", "1.11.*" ], "type": "string" }, {{end}} "networkPolicy": { "defaultValue": "{{.OrchestratorProfile.KubernetesConfig.NetworkPolicy}}", "metadata": { "description": "The network policy enforcement to use (calico|cilium); 'none' and 'azure' here for backwards compatibility" }, "allowedValues": [ "", "none", "azure", "calico", "cilium" ], "type": "string" }, "networkPlugin": { "defaultValue": "{{.OrchestratorProfile.KubernetesConfig.NetworkPlugin}}", "metadata": { "description": "The network plugin to use for Kubernetes (kubenet|azure|flannel|cilium)" }, "allowedValues": [ "kubenet", "azure", "flannel", "cilium" ], "type": "string" }, "containerRuntime": { "defaultValue": "{{.OrchestratorProfile.KubernetesConfig.ContainerRuntime}}", "metadata": { "description": "The container runtime to use (docker|clear-containers|kata-containers|containerd)" }, "allowedValues": [ "docker", "clear-containers", "kata-containers", "containerd" ], "type": "string" }, "containerdDownloadURLBase": { "defaultValue": "https://storage.googleapis.com/cri-containerd-release/", "type": "string" }, "cniPluginsURL": { "defaultValue": "https://acs-mirror.azureedge.net/cni/cni-plugins-amd64-latest.tgz", "type": "string" }, "vnetCniLinuxPluginsURL": { "defaultValue": "https://acs-mirror.azureedge.net/cni/azure-vnet-cni-linux-amd64-latest.tgz", "type": "string" }, "vnetCniWindowsPluginsURL": { "defaultValue": "https://acs-mirror.azureedge.net/cni/azure-vnet-cni-windows-amd64-latest.zip", "type": "string" }, "maxPods": { "defaultValue": 30, "metadata": { "description": "This param has been deprecated." }, "type": "int" }, "vnetCidr": { "defaultValue": "{{GetDefaultVNETCIDR}}", "metadata": { "description": "Cluster vnet cidr" }, "type": "string" }, "gcHighThreshold": { "defaultValue": 85, "metadata": { "description": "High Threshold for Image Garbage collection on each node" }, "type": "int" }, "gcLowThreshold": { "defaultValue": 80, "metadata": { "description": "Low Threshold for Image Garbage collection on each node." }, "type": "int" }, "kuberneteselbsvcname": { "defaultValue": "", "metadata": { "description": "elb service for standard lb" }, "type": "string" }, {{if .OrchestratorProfile.KubernetesConfig.IsContainerMonitoringEnabled}} "omsAgentVersion": { "defaultValue": "", "metadata": { "description": "OMS agent version for Container Monitoring." }, "type": "string" }, "omsAgentDockerProviderVersion": { "defaultValue": "", "metadata": { "description": "Docker provider version for Container Monitoring." }, "type": "string" }, "omsAgentImage": { "defaultValue": "", "metadata": { "description": "OMS agent image for Container Monitoring." }, "type": "string" }, "omsAgentWorkspaceGuid": { "defaultValue": "", "metadata": { "description": "OMS workspace guid" }, "type": "string" }, "omsAgentWorkspaceKey": { "defaultValue": "", "metadata": { "description": "OMS workspace key" }, "type": "string" }, "kubernetesOMSAgentCPURequests": { "defaultValue": "", "metadata": { "description": "OMS Agent CPU requests resource limit" }, "type": "string" }, "kubernetesOMSAgentMemoryRequests": { "defaultValue": "", "metadata": { "description": "OMS Agent memory requests resource limit" }, "type": "string" }, "kubernetesOMSAgentCPULimit": { "defaultValue": "", "metadata": { "description": "OMS Agent CPU limit resource limit" }, "type": "string" }, "kubernetesOMSAgentMemoryLimit": { "defaultValue": "", "metadata": { "description": "OMS Agent memory limit resource limit" }, "type": "string" }, {{end}} {{ if not UseManagedIdentity }} "servicePrincipalClientId": { "metadata": { "description": "Client ID (used by cloudprovider)" }, "type": "securestring" }, "servicePrincipalClientSecret": { "metadata": { "description": "The Service Principal Client Secret." }, "type": "securestring" }, {{ end }} "masterOffset": { "defaultValue": 0, "allowedValues": [ 0, 1, 2, 3, 4 ], "metadata": { "description": "The offset into the master pool where to start creating master VMs. This value can be from 0 to 4, but must be less than masterCount." }, "type": "int" }, "etcdDiskSizeGB": { "metadata": { "description": "Size in GB to allocate for etcd volume" }, "type": "string" }, "etcdDownloadURLBase": { "metadata": { "description": "etcd image base URL" }, "type": "string" }, "etcdVersion": { "metadata": { "description": "etcd version" }, "type": "string" }, "etcdEncryptionKey": { "metadata": { "description": "Encryption at rest key for etcd" }, "type": "string" } {{if ProvisionJumpbox}} ,"jumpboxVMName": { "metadata": { "description": "jumpbox VM Name" }, "type": "string" }, "jumpboxVMSize": { {{GetMasterAllowedSizes}} "metadata": { "description": "The size of the Virtual Machine. Required" }, "type": "string" }, "jumpboxOSDiskSizeGB": { "metadata": { "description": "Size in GB to allocate to the private cluster jumpbox VM OS." }, "type": "int" }, "jumpboxPublicKey": { "metadata": { "description": "SSH public key used for auth to the private cluster jumpbox" }, "type": "string" }, "jumpboxUsername": { "metadata": { "description": "Username for the private cluster jumpbox" }, "type": "string" }, "jumpboxStorageProfile": { "metadata": { "description": "Storage Profile for the private cluster jumpbox" }, "type": "string" } {{end}} {{if HasCustomSearchDomain}} ,"searchDomainName": { "defaultValue": "", "metadata": { "description": "Custom Search Domain name." }, "type": "string" }, "searchDomainRealmUser": { "defaultValue": "", "metadata": { "description": "Windows server AD user name to join the Linux Machines with active directory and be able to change dns registries." }, "type": "string" }, "searchDomainRealmPassword": { "defaultValue": "", "metadata": { "description": "Windows server AD user password to join the Linux Machines with active directory and be able to change dns registries." }, "type": "securestring" } {{end}} {{if HasCustomNodesDNS}} ,"dnsServer": { "defaultValue": "", "metadata": { "description": "DNS Server IP" }, "type": "string" } {{end}} {{if EnableEncryptionWithExternalKms}} , {{if not UseManagedIdentity}} "servicePrincipalObjectId": { "metadata": { "description": "Object ID (used by cloudprovider)" }, "type": "securestring" }, {{end}} "clusterKeyVaultSku": { "type": "string", "defaultValue": "Standard", "allowedValues": [ "Standard", "Premium" ], "metadata": { "description": "SKU for the key vault used by the cluster" } } {{end}} {{if IsAzureCNI}} ,"AzureCNINetworkMonitorImageURL": { "defaultValue": "", "metadata": { "description": "Azure CNI networkmonitor Image URL" }, "type": "string" } {{end}}
27.328571
168
0.557987
ed27437c7a22ba6186184bb60e9060c6e7faf479
284,442
pm
Perl
src/fhem/trunk/fhem/contrib/HMCCU/FHEM/88_HMCCU.pm
nastymorbol/fhem-docker
c88d13e6fb098a487486b448806048eab1222b81
[ "MIT" ]
null
null
null
src/fhem/trunk/fhem/contrib/HMCCU/FHEM/88_HMCCU.pm
nastymorbol/fhem-docker
c88d13e6fb098a487486b448806048eab1222b81
[ "MIT" ]
null
null
null
src/fhem/trunk/fhem/contrib/HMCCU/FHEM/88_HMCCU.pm
nastymorbol/fhem-docker
c88d13e6fb098a487486b448806048eab1222b81
[ "MIT" ]
null
null
null
############################################################################## # # 88_HMCCU.pm # # $Id: 88_HMCCU.pm 18745 2019-02-26 17:33:23Z zap $ # # Version 4.4.019 # # Module for communication between FHEM and Homematic CCU2/3. # # Supports BidCos-RF, BidCos-Wired, HmIP-RF, virtual CCU channels, # CCU group devices, HomeGear, CUxD, Osram Lightify, Homematic Virtual Layer # and Philips Hue (not tested) # # (c) 2020 by zap (zap01 <at> t-online <dot> de) # ############################################################################## # # Verbose levels: # # 0 = Log start/stop and initialization messages # 1 = Log errors # 2 = Log counters and warnings # 3 = Log events and runtime information # ############################################################################## package main; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; use strict; use warnings; # use Data::Dumper; use IO::File; use Fcntl 'SEEK_END', 'SEEK_SET', 'O_CREAT', 'O_RDWR'; use Encode qw(decode encode); use RPC::XML::Client; use RPC::XML::Server; use HttpUtils; use SetExtensions; use HMCCUConf; # Import configuration data my $HMCCU_STATECONTROL = \%HMCCUConf::HMCCU_STATECONTROL; my $HMCCU_ROLECMDS = \%HMCCUConf::HMCCU_ROLECMDS; my $HMCCU_ATTR = \%HMCCUConf::HMCCU_ATTR; my $HMCCU_CONVERSIONS = \%HMCCUConf::HMCCU_CONVERSIONS; my $HMCCU_CHN_DEFAULTS = \%HMCCUConf::HMCCU_CHN_DEFAULTS; my $HMCCU_DEV_DEFAULTS = \%HMCCUConf::HMCCU_DEV_DEFAULTS; my $HMCCU_SCRIPTS = \%HMCCUConf::HMCCU_SCRIPTS; # Custom configuration data my %HMCCU_CUST_CHN_DEFAULTS; my %HMCCU_CUST_DEV_DEFAULTS; # HMCCU version my $HMCCU_VERSION = '4.4.019'; # Constants and default values my $HMCCU_MAX_IOERRORS = 100; my $HMCCU_MAX_QUEUESIZE = 500; my $HMCCU_TIME_WAIT = 100000; my $HMCCU_TIME_TRIGGER = 10; # RPC ping interval for default interface, should be smaller than HMCCU_TIMEOUT_EVENT my $HMCCU_TIME_PING = 300; my $HMCCU_TIMEOUT_CONNECTION = 10; my $HMCCU_TIMEOUT_WRITE = 0.001; my $HMCCU_TIMEOUT_ACCEPT = 1; my $HMCCU_TIMEOUT_EVENT = 600; my $HMCCU_STATISTICS = 500; my $HMCCU_TIMEOUT_REQUEST = 4; # ReGa Ports my %HMCCU_REGA_PORT = ( 'http' => 8181, 'https' => '48181' ); # RPC interface priority my @HMCCU_RPC_PRIORITY = ('BidCos-RF', 'HmIP-RF', 'BidCos-Wired'); # RPC port name by port number my %HMCCU_RPC_NUMPORT = ( 2000 => 'BidCos-Wired', 2001 => 'BidCos-RF', 2010 => 'HmIP-RF', 9292 => 'VirtualDevices', 2003 => 'Homegear', 8701 => 'CUxD', 7000 => 'HVL' ); # RPC port number by port name my %HMCCU_RPC_PORT = ( 'BidCos-Wired', 2000, 'BidCos-RF', 2001, 'HmIP-RF', 2010, 'VirtualDevices', 9292, 'Homegear', 2003, 'CUxD', 8701, 'HVL', 7000 ); # RPC flags my %HMCCU_RPC_FLAG = ( 2000 => 'forceASCII', 2001 => 'forceASCII', 2003 => '_', 2010 => 'forceASCII', 7000 => 'forceInit', 8701 => 'forceInit', 9292 => '_' ); my %HMCCU_RPC_SSL = ( 2000 => 1, 2001 => 1, 2010 => 1, 9292 => 1, 'BidCos-Wired' => 1, 'BidCos-RF' => 1, 'HmIP-RF' => 1, 'VirtualDevices' => 1 ); # Default values for delayed initialization during FHEM startup my $HMCCU_INIT_INTERVAL0 = 12; my $HMCCU_CCU_PING_TIMEOUT = 1; my $HMCCU_CCU_BOOT_DELAY = 180; my $HMCCU_CCU_DELAYED_INIT = 59; my $HMCCU_CCU_RPC_OFFSET = 20; # Datapoint operations my $HMCCU_OPER_READ = 1; my $HMCCU_OPER_WRITE = 2; my $HMCCU_OPER_EVENT = 4; # Datapoint types my $HMCCU_TYPE_BINARY = 2; my $HMCCU_TYPE_FLOAT = 4; my $HMCCU_TYPE_INTEGER = 16; my $HMCCU_TYPE_STRING = 20; # Flags for CCU object specification my $HMCCU_FLAG_NAME = 1; my $HMCCU_FLAG_CHANNEL = 2; my $HMCCU_FLAG_DATAPOINT = 4; my $HMCCU_FLAG_ADDRESS = 8; my $HMCCU_FLAG_INTERFACE = 16; my $HMCCU_FLAG_FULLADDR = 32; # Valid flag combinations my $HMCCU_FLAGS_IACD = $HMCCU_FLAG_INTERFACE | $HMCCU_FLAG_ADDRESS | $HMCCU_FLAG_CHANNEL | $HMCCU_FLAG_DATAPOINT; my $HMCCU_FLAGS_IAC = $HMCCU_FLAG_INTERFACE | $HMCCU_FLAG_ADDRESS | $HMCCU_FLAG_CHANNEL; my $HMCCU_FLAGS_ACD = $HMCCU_FLAG_ADDRESS | $HMCCU_FLAG_CHANNEL | $HMCCU_FLAG_DATAPOINT; my $HMCCU_FLAGS_AC = $HMCCU_FLAG_ADDRESS | $HMCCU_FLAG_CHANNEL; my $HMCCU_FLAGS_ND = $HMCCU_FLAG_NAME | $HMCCU_FLAG_DATAPOINT; my $HMCCU_FLAGS_NC = $HMCCU_FLAG_NAME | $HMCCU_FLAG_CHANNEL; my $HMCCU_FLAGS_NCD = $HMCCU_FLAG_NAME | $HMCCU_FLAG_CHANNEL | $HMCCU_FLAG_DATAPOINT; # Flags for address/name checks my $HMCCU_FL_STADDRESS = 1; my $HMCCU_FL_NAME = 2; my $HMCCU_FL_EXADDRESS = 4; my $HMCCU_FL_ADDRESS = 5; my $HMCCU_FL_ALL = 7; # Default values my $HMCCU_DEF_HMSTATE = '^0\.UNREACH!(1|true):unreachable;^[0-9]\.LOW_?BAT!(1|true):warn_battery'; # Placeholder for external addresses (i.e. HVL) my $HMCCU_EXT_ADDR = 'ZZZ0000000'; # Declare functions # FHEM standard functions sub HMCCU_Initialize ($); sub HMCCU_Define ($$); sub HMCCU_InitDevice ($); sub HMCCU_Undef ($$); sub HMCCU_DelayedShutdown ($); sub HMCCU_Shutdown ($); sub HMCCU_Set ($@); sub HMCCU_Get ($@); sub HMCCU_Attr ($@); sub HMCCU_AttrInterfacesPorts ($$$); sub HMCCU_Notify ($$); sub HMCCU_Detail ($$$$); sub HMCCU_PostInit ($); # Aggregation sub HMCCU_AggregateReadings ($$); sub HMCCU_AggregationRules ($$); # Handling of default attributes sub HMCCU_ExportDefaults ($$); sub HMCCU_ImportDefaults ($); sub HMCCU_FindDefaults ($$); sub HMCCU_GetDefaults ($$); sub HMCCU_SetDefaults ($); # Status and logging functions sub HMCCU_Trace ($$$$); sub HMCCU_Log ($$$;$); sub HMCCU_LogError ($$$); sub HMCCU_SetError ($@); sub HMCCU_SetState ($@); sub HMCCU_SetRPCState ($@); # Filter and modify readings sub HMCCU_CalculateScaleValue ($$$$;$$$); sub HMCCU_FilterReading ($$$;$); sub HMCCU_FormatReadingValue ($$$); sub HMCCU_GetReadingName ($$$$$$$;$); sub HMCCU_ScaleValue ($$$$$); sub HMCCU_StripNumber ($$;$); sub HMCCU_Substitute ($$$$$;$$); sub HMCCU_SubstRule ($$$); sub HMCCU_SubstVariables ($$$); # Update client device readings sub HMCCU_BulkUpdate ($$$$); sub HMCCU_GetUpdate ($$$); sub HMCCU_RefreshReadings ($); sub HMCCU_UpdateCB ($$$); sub HMCCU_UpdateClients ($$$$$$); sub HMCCU_UpdateInternalValues ($$$$$); sub HMCCU_UpdateMultipleDevices ($$); sub HMCCU_UpdatePeers ($$$$); sub HMCCU_UpdateParamsetReadings ($$$;$); sub HMCCU_UpdateSingleDatapoint ($$$$); # sub HMCCU_UpdateSingleDevice ($$$$); # RPC functions sub HMCCU_EventsTimedOut ($); sub HMCCU_GetRPCCallbackURL ($$$$$); sub HMCCU_GetRPCDevice ($$$); sub HMCCU_GetRPCInterfaceList ($); sub HMCCU_GetRPCPortList ($); sub HMCCU_GetRPCServerInfo ($$$); sub HMCCU_IsRPCServerRunning ($$$); sub HMCCU_IsRPCType ($$$); sub HMCCU_IsRPCStateBlocking ($); sub HMCCU_ResetCounters ($); sub HMCCU_RPCRequest ($$$$$;$); sub HMCCU_StartExtRPCServer ($); sub HMCCU_StopExtRPCServer ($;$); # Parse and validate names and addresses sub HMCCU_ParseObject ($$$); sub HMCCU_IsDevAddr ($$); sub HMCCU_IsChnAddr ($$); sub HMCCU_SplitChnAddr ($); sub HMCCU_SplitDatapoint ($;$); # FHEM device handling functions sub HMCCU_AssignIODevice ($$$); sub HMCCU_ExistsClientDevice ($$); sub HMCCU_FindClientDevices ($$$$); sub HMCCU_FindIODevice ($); sub HMCCU_GetHash ($@); sub HMCCU_GetAttribute ($$$$); sub HMCCU_GetFlags ($); sub HMCCU_GetAttrReadingFormat ($$); sub HMCCU_GetAttrStripNumber ($); sub HMCCU_GetAttrSubstitute ($$); sub HMCCU_IODeviceStates (); sub HMCCU_IsFlag ($$); # Handle interfaces, devices and channels sub HMCCU_AddDevice ($$$;$); sub HMCCU_AddDeviceDesc ($$$$); sub HMCCU_AddDeviceModel ($$$$$$); sub HMCCU_AddPeers ($$$); sub HMCCU_CreateDevice ($$$$$); sub HMCCU_DeleteDevice ($); sub HMCCU_DeviceDescToStr ($$); sub HMCCU_ExistsDeviceModel ($$$;$); sub HMCCU_FindParamDef ($$$); sub HMCCU_FormatDeviceInfo ($); sub HMCCU_GetAddress ($$$$); sub HMCCU_GetAffectedAddresses ($); sub HMCCU_GetCCUDeviceParam ($$); sub HMCCU_GetChannelName ($$$); sub HMCCU_GetChannelRole ($;$); sub HMCCU_GetClientDeviceModel ($;$); sub HMCCU_GetDefaultInterface ($); sub HMCCU_GetDeviceAddresses ($;$$); sub HMCCU_GetDeviceChannels ($$$); sub HMCCU_GetDeviceConfig ($); sub HMCCU_GetDeviceDesc ($$;$); sub HMCCU_GetDeviceIdentifier ($$;$$); sub HMCCU_GetDeviceInfo ($$;$); sub HMCCU_GetDeviceInterface ($$$); sub HMCCU_GetDeviceList ($); sub HMCCU_GetDeviceModel ($$$;$); sub HMCCU_GetDeviceName ($$$); sub HMCCU_GetDeviceType ($$$); sub HMCCU_GetFirmwareVersions ($$); sub HMCCU_GetGroupMembers ($$); sub HMCCU_GetMatchingDevices ($$$$); sub HMCCU_GetParamDef ($$$;$); sub HMCCU_GetParamValue ($$$$$); sub HMCCU_GetReceivers ($$$); sub HMCCU_IsValidChannel ($$$); sub HMCCU_IsValidDevice ($$$); sub HMCCU_IsValidDeviceOrChannel ($$$); sub HMCCU_IsValidParameter ($$$$); sub HMCCU_IsValidReceiver ($$$$); sub HMCCU_ParamsetDescToStr ($$); sub HMCCU_RemoveDevice ($$$;$); sub HMCCU_RenameDevice ($$$); sub HMCCU_ResetDeviceTables ($;$$); sub HMCCU_UpdateDevice ($$); sub HMCCU_UpdateDeviceRoles ($$;$$); sub HMCCU_UpdateDeviceTable ($$); # Handle datapoints sub HMCCU_FindDatapoint ($$$$$); sub HMCCU_GetDatapoint ($@); sub HMCCU_GetDatapointAttr ($$$$$); sub HMCCU_GetDatapointList ($$$); sub HMCCU_GetSpecialCommands ($$); sub HMCCU_GetSpecialDatapoints ($); sub HMCCU_GetStateValues ($$;$); sub HMCCU_GetValidDatapoints ($$$$$); sub HMCCU_IsValidDatapoint ($$$$$); sub HMCCU_SetDefaultAttributes ($;$); sub HMCCU_SetMultipleDatapoints ($$); sub HMCCU_SetMultipleParameters ($$$;$); # Homematic script and variable functions sub HMCCU_GetVariables ($$); sub HMCCU_HMCommand ($$$); sub HMCCU_HMCommandCB ($$$); sub HMCCU_HMCommandNB ($$$); sub HMCCU_HMScriptExt ($$$$$); sub HMCCU_SetVariable ($$$$$); sub HMCCU_UpdateVariables ($); # Helper functions sub HMCCU_BitsToStr ($$); sub HMCCU_BuildURL ($$); sub HMCCU_CalculateReading ($$); sub HMCCU_CorrectName ($); sub HMCCU_Encrypt ($); sub HMCCU_Decrypt ($); sub HMCCU_DefStr ($;$$); sub HMCCU_DeleteReadings ($$); sub HMCCU_EncodeEPDisplay ($); sub HMCCU_ExprMatch ($$$); sub HMCCU_ExprNotMatch ($$$); sub HMCCU_FlagsToStr ($$$;$$); sub HMCCU_GetDeviceStates ($); sub HMCCU_GetDutyCycle ($); sub HMCCU_GetHMState ($$$); sub HMCCU_GetIdFromIP ($$); sub HMCCU_GetTimeSpec ($); sub HMCCU_IsFltNum ($); sub HMCCU_IsIntNum ($); sub HMCCU_ISO2UTF ($); sub HMCCU_Max ($$); sub HMCCU_MaxHashEntries ($$); sub HMCCU_Min ($$); sub HMCCU_RefToString ($); sub HMCCU_ResolveName ($$); sub HMCCU_TCPConnect ($$); sub HMCCU_TCPPing ($$$); sub HMCCU_UpdateReadings ($$); ################################################## # Initialize module ################################################## sub HMCCU_Initialize ($) { my ($hash) = @_; $hash->{DefFn} = "HMCCU_Define"; $hash->{UndefFn} = "HMCCU_Undef"; $hash->{SetFn} = "HMCCU_Set"; $hash->{GetFn} = "HMCCU_Get"; $hash->{ReadFn} = "HMCCU_Read"; $hash->{AttrFn} = "HMCCU_Attr"; $hash->{NotifyFn} = "HMCCU_Notify"; $hash->{ShutdownFn} = "HMCCU_Shutdown"; $hash->{DelayedShutdownFn} = "HMCCU_DelayedShutdown"; $hash->{FW_detailFn} = "HMCCU_Detail"; $hash->{parseParams} = 1; $hash->{AttrList} = "stripchar stripnumber ccuaggregate:textField-long". " ccudefaults rpcinterfaces:multiple-strict,".join(',',sort keys %HMCCU_RPC_PORT). " ccudef-hmstatevals:textField-long ccudef-substitute:textField-long". " ccudef-readingfilter:textField-long". " ccudef-readingformat:name,namelc,address,addresslc,datapoint,datapointlc". " ccudef-stripnumber ccuReadingPrefix". " ccuflags:multiple-strict,procrpc,dptnocheck,logCommand,noagg,nohmstate,updGroupMembers,". "logEvents,noEvents,noInitialUpdate,noReadings,nonBlocking,reconnect,logPong,trace". " ccuReqTimeout ccuGetVars rpcinterval:2,3,5,7,10 rpcqueue rpcPingCCU". " rpcport:multiple-strict,".join(',',sort keys %HMCCU_RPC_NUMPORT). " rpcserver:on,off rpcserveraddr rpcserverport rpctimeout rpcevtimeout substitute". " ccuget:Value,State ". $readingFnAttributes; } ###################################################################### # Define device ###################################################################### sub HMCCU_Define ($$) { my ($hash, $a, $h) = @_; my $name = $hash->{NAME}; return 'Specify CCU hostname or IP address as a parameter' if (scalar(@$a) < 3); # Setup http or ssl connection if ($$a[2] =~ /^(https?):\/\/(.+)/) { $hash->{prot} = $1; $hash->{host} = $2; } else { $hash->{prot} = 'http'; $hash->{host} = $$a[2]; } $hash->{Clients} = ':HMCCUDEV:HMCCUCHN:HMCCURPC:HMCCURPCPROC:'; $hash->{hmccu}{ccu}{delay} = exists($h->{ccudelay}) ? $h->{ccudelay} : $HMCCU_CCU_BOOT_DELAY; $hash->{hmccu}{ccu}{timeout} = exists($h->{waitforccu}) ? $h->{waitforccu} : $HMCCU_CCU_PING_TIMEOUT; $hash->{hmccu}{ccu}{delayed} = 0; # Check if TCL-Rega process is running on CCU (CCU is reachable) if (exists($h->{delayedinit}) && $h->{delayedinit} > 0) { return "Value for delayed initialization must be greater than $HMCCU_CCU_DELAYED_INIT" if ($h->{delayedinit} <= $HMCCU_CCU_DELAYED_INIT); $hash->{hmccu}{ccu}{delay} = $h->{delayedinit}; $hash->{ccustate} = 'unreachable'; HMCCU_Log ($hash, 1, 'Forced delayed initialization'); } else { if (HMCCU_TCPPing ($hash->{host}, $HMCCU_REGA_PORT{$hash->{prot}}, $hash->{hmccu}{ccu}{timeout})) { $hash->{ccustate} = 'active'; } else { $hash->{ccustate} = 'unreachable'; HMCCU_Log ($hash, 1, "CCU port ".$HMCCU_REGA_PORT{$hash->{prot}}." is not reachable"); } } # Get CCU IP address $hash->{ccuip} = HMCCU_ResolveName ($hash->{host}, 'N/A'); # Get CCU number (if more than one) if (scalar(@$a) >= 4) { return 'CCU number must be in range 1-9' if ($$a[3] < 1 || $$a[3] > 9); $hash->{CCUNum} = $$a[3]; } else { # Count CCU devices my $ccucount = 0; foreach my $d (keys %defs) { my $ch = $defs{$d}; $ccucount++ if (exists($ch->{TYPE}) && $ch->{TYPE} eq 'HMCCU' && $ch != $hash); } $hash->{CCUNum} = $ccucount+1; } $hash->{version} = $HMCCU_VERSION; $hash->{ccutype} = 'CCU2/3'; $hash->{RPCState} = 'inactive'; $hash->{NOTIFYDEV} = 'global,TYPE=(HMCCU|HMCCUDEV|HMCCUCHN)'; $hash->{hmccu}{defInterface} = $HMCCU_RPC_PRIORITY[0]; $hash->{hmccu}{defPort} = $HMCCU_RPC_PORT{$hash->{hmccu}{defInterface}}; $hash->{hmccu}{rpcports} = undef; HMCCU_Log ($hash, 1, "Initialized version $HMCCU_VERSION"); my $rc = 0; if ($hash->{ccustate} eq 'active') { # If CCU is alive read devices, channels, interfaces and groups HMCCU_Log ($hash, 1, "HMCCU: Initializing device"); $rc = HMCCU_InitDevice ($hash); } if ($hash->{ccustate} ne 'active' || $rc > 0) { # Schedule update of CCU assets if CCU is not active during FHEM startup if (!$init_done) { $hash->{hmccu}{ccu}{delayed} = 1; HMCCU_Log ($hash, 1, "Scheduling delayed initialization in ".$hash->{hmccu}{ccu}{delay}." seconds"); InternalTimer (gettimeofday()+$hash->{hmccu}{ccu}{delay}, "HMCCU_InitDevice", $hash); } } $hash->{hmccu}{evtime} = 0; $hash->{hmccu}{evtimeout} = 0; $hash->{hmccu}{updatetime} = 0; $hash->{hmccu}{rpccount} = 0; HMCCU_UpdateReadings ($hash, { 'state' => 'Initialized', 'rpcstate' => 'inactive' }); # readingsBeginUpdate ($hash); # readingsBulkUpdate ($hash, "state", "Initialized"); # readingsBulkUpdate ($hash, "rpcstate", "inactive"); # readingsEndUpdate ($hash, 1); $attr{$name}{stateFormat} = "rpcstate/state"; return undef; } ###################################################################### # Initialization of FHEM device. # Called during Define() or by HMCCU after CCU ready. # Return 0 on successful initialization or >0 on error: # 1 = CCU port 8181 or 48181 is not reachable. # 2 = Error while reading device list from CCU. ###################################################################### sub HMCCU_InitDevice ($) { my ($hash) = @_; my $name = $hash->{NAME}; if ($hash->{hmccu}{ccu}{delayed} == 1) { HMCCU_Log ($hash, 1, 'Initializing devices'); if (!HMCCU_TCPPing ($hash->{host}, $HMCCU_REGA_PORT{$hash->{prot}}, $hash->{hmccu}{ccu}{timeout})) { $hash->{ccustate} = 'unreachable'; HMCCU_Log ($hash, 1, "HMCCU: CCU port ".$HMCCU_REGA_PORT{$hash->{prot}}." is not reachable"); return 1; } } my ($devcnt, $chncnt, $ifcount, $prgcount, $gcount) = HMCCU_GetDeviceList ($hash); if ($devcnt >= 0) { HMCCU_Log ($hash, 1, "Read $devcnt devices with $chncnt channels from CCU ".$hash->{host}); HMCCU_Log ($hash, 1, "Read $ifcount interfaces from CCU ".$hash->{host}); HMCCU_Log ($hash, 1, "Read $prgcount programs from CCU ".$hash->{host}); HMCCU_Log ($hash, 1, "Read $gcount virtual groups from CCU ".$hash->{host}); return 0; } else { HMCCU_Log ($hash, 1, "Error while reading device list from CCU ".$hash->{host}); return 2; } } ###################################################################### # Tasks to be executed after all devices have been defined. Executed # as timer function. # Read device configuration from CCU # Start RPC servers ###################################################################### sub HMCCU_PostInit ($) { my ($hash) = @_; my $name = $hash->{NAME}; if ($hash->{ccustate} eq 'active') { my $rpcServer = AttrVal ($name, 'rpcserver', 'off'); HMCCU_Log ($hash, 1, 'Reading device config from CCU. This may take a couple of seconds ...'); my ($cDev, $cPar, $cLnk) = HMCCU_GetDeviceConfig ($hash); HMCCU_Log ($hash, 2, "Read device configuration: devices/channels=$cDev parametersets=$cPar links=$cLnk"); HMCCU_StartExtRPCServer ($hash) if ($rpcServer eq 'on'); } else { HMCCU_Log ($hash, 1, 'CCU not active. Post FHEM start initialization failed'); } } ###################################################################### # Set or delete attribute ###################################################################### sub HMCCU_Attr ($@) { my ($cmd, $name, $attrname, $attrval) = @_; my $hash = $defs{$name}; my $rc = 0; if ($cmd eq 'set') { if ($attrname eq 'ccudefaults') { $rc = HMCCU_ImportDefaults ($attrval); return HMCCU_SetError ($hash, -16) if ($rc == 0); if ($rc < 0) { $rc = -$rc; return HMCCU_SetError ($hash, "Syntax error in default attribute file $attrval line $rc"); } } elsif ($attrname eq 'ccuaggregate') { $rc = HMCCU_AggregationRules ($hash, $attrval); return HMCCU_SetError ($hash, 'Syntax error in attribute ccuaggregate') if ($rc == 0); } elsif ($attrname eq 'ccuackstate') { return "HMCCU: Attribute ccuackstate is depricated. Use ccuflags with 'ackState' instead"; } elsif ($attrname eq 'ccureadings') { return "HMCCU: Attribute ccureadings is depricated. Use ccuflags with 'noReadings' instead"; } elsif ($attrname eq 'ccuflags') { my $ccuflags = AttrVal ($name, 'ccuflags', 'null'); my @flags = ($attrval =~ /(intrpc|extrpc|procrpc)/g); return "Flags extrpc, procrpc and intrpc cannot be combined" if (scalar (@flags) > 1); if ($attrval =~ /(intrpc|extrpc)/) { HMCCU_Log ($hash, 1, "RPC server mode $1 no longer supported. Using procrpc instead"); $attrval =~ s/(extrpc|intrpc)/procrpc/; $_[3] = $attrval; } } elsif ($attrname eq 'ccuGetVars') { my ($interval, $pattern) = split /:/, $attrval; $pattern = '.*' if (!defined ($pattern)); $hash->{hmccu}{ccuvarspat} = $pattern; $hash->{hmccu}{ccuvarsint} = $interval; RemoveInternalTimer ($hash, "HMCCU_UpdateVariables"); if ($interval > 0) { HMCCU_Log ($hash, 2, "Updating CCU system variables every $interval seconds"); InternalTimer (gettimeofday()+$interval, "HMCCU_UpdateVariables", $hash); } } elsif ($attrname eq 'rpcdevice') { return "HMCCU: Attribute rpcdevice is depricated. Please remove it"; } elsif ($attrname eq 'rpcinterfaces' || $attrname eq 'rpcport') { if ($hash->{hmccu}{ccu}{delayed} == 0) { my $msg = HMCCU_AttrInterfacesPorts ($hash, $attrname, $attrval); return $msg if ($msg ne ''); } } } elsif ($cmd eq 'del') { if ($attrname eq 'ccuaggregate') { HMCCU_AggregationRules ($hash, ''); } elsif ($attrname eq 'ccuGetVars') { RemoveInternalTimer ($hash, "HMCCU_UpdateVariables"); } elsif ($attrname eq 'rpcdevice') { delete $hash->{RPCDEV} if (exists ($hash->{RPCDEV})); } elsif ($attrname eq 'rpcport' || $attrname eq 'rpcinterfaces') { my ($defInterface, $defPort) = HMCCU_GetDefaultInterface ($hash); $hash->{hmccu}{rpcports} = undef; delete $attr{$name}{'rpcinterfaces'} if ($attrname eq 'rpcport'); delete $attr{$name}{'rpcport'} if ($attrname eq 'rpcinterfaces'); } } return undef; } ###################################################################### # Set attributes rpcinterfaces and rpcport. # Return empty string on success or error message on error. ###################################################################### sub HMCCU_AttrInterfacesPorts ($$$) { my ($hash, $attr, $attrval) = @_; my $name = $hash->{NAME}; if ($attr eq 'rpcinterfaces') { my @ilist = split (',', $attrval); my @plist = (); foreach my $p (@ilist) { my ($pn, $dc) = HMCCU_GetRPCServerInfo ($hash, $p, 'port,devcount'); return "Illegal RPC interface $p" if (!defined ($pn)); return "No devices assigned to interface $p" if ($dc == 0); push (@plist, $pn); } return "No RPC interface specified" if (scalar (@plist) == 0); $hash->{hmccu}{rpcports} = join (',', @plist); $attr{$name}{"rpcport"} = $hash->{hmccu}{rpcports}; } elsif ($attr eq 'rpcport') { my @plist = split (',', $attrval); my @ilist = (); foreach my $p (@plist) { my ($in, $dc) = HMCCU_GetRPCServerInfo ($hash, $p, 'name,devcount'); return "Illegal RPC port $p" if (!defined($in)); return "No devices assigned to interface $in" if ($dc == 0); push (@ilist, $in); } return "No RPC port specified" if (scalar (@ilist) == 0); $hash->{hmccu}{rpcports} = $attrval; $attr{$name}{"rpcinterfaces"} = join (',', @ilist); } return ''; } ###################################################################### # Parse aggregation rules for readings. # Syntax of aggregation rule is: # FilterSpec[;...] # FilterSpec := {Name|Filt|Read|Cond|Else|Pref|Coll|Html}[,...] # Name := name:Name # Filt := filter:{name|type|group|room|alias}=Regexp[!Regexp] # Read := read:Regexp # Cond := if:{any|all|min|max|sum|avg|gt|lt|ge|le}=Value # Else := else:Value # Pref := prefix:{RULE|Prefix} # Coll := coll:{NAME|Attribute} # Html := html:Template ###################################################################### sub HMCCU_AggregationRules ($$) { my ($hash, $rulestr) = @_; my $name = $hash->{NAME}; # Delete existing aggregation rules if (exists ($hash->{hmccu}{agg})) { delete $hash->{hmccu}{agg}; } return if ($rulestr eq ''); my @pars = ('name', 'filter', 'if', 'else'); # Extract aggregation rules my $cnt = 0; my @rules = split (/[;\n]+/, $rulestr); foreach my $r (@rules) { $cnt++; # Set default rule parameters. Can be modified later my %opt = ('read' => 'state', 'prefix' => 'RULE', 'coll' => 'NAME'); # Parse aggregation rule my @specs = split (',', $r); foreach my $spec (@specs) { if ($spec =~ /^(name|filter|read|if|else|prefix|coll|html):(.+)$/) { $opt{$1} = $2; } } # Check if mandatory parameters are specified foreach my $p (@pars) { return HMCCU_Log ($hash, 1, "Parameter $p is missing in aggregation rule $cnt.") if (!exists ($opt{$p})); } my $fname = $opt{name}; my ($fincl, $fexcl) = split ('!', $opt{filter}); my ($ftype, $fexpr) = split ('=', $fincl); return 0 if (!defined ($fexpr)); my ($fcond, $fval) = split ('=', $opt{if}); return 0 if (!defined ($fval)); my ($fcoll, $fdflt) = split ('!', $opt{coll}); $fdflt = 'no match' if (!defined ($fdflt)); my $fhtml = exists ($opt{'html'}) ? $opt{'html'} : ''; # Read HTML template (optional) if ($fhtml ne '') { my %tdef; my @html; # Read template file if (open (TEMPLATE, "<$fhtml")) { @html = <TEMPLATE>; close (TEMPLATE); } else { return HMCCU_Log ($hash, 1, "Can't open file $fhtml."); } # Parse template foreach my $line (@html) { chomp $line; my ($key, $h) = split /:/, $line, 2; next if (!defined ($h) || $key =~ /^#/); $tdef{$key} = $h; } # Some syntax checks return HMCCU_Log ($hash, 1, "Missing definition row-odd in template file.") if (!exists ($tdef{'row-odd'})); # Set default values $tdef{'begin-html'} = '' if (!exists ($tdef{'begin-html'})); $tdef{'end-html'} = '' if (!exists ($tdef{'end-html'})); $tdef{'begin-table'} = "<table>" if (!exists ($tdef{'begin-table'})); $tdef{'end-table'} = "</table>" if (!exists ($tdef{'end-table'})); $tdef{'default'} = 'no data' if (!exists ($tdef{'default'}));; $tdef{'row-even'} = $tdef{'row-odd'} if (!exists ($tdef{'row-even'})); foreach my $t (keys %tdef) { $hash->{hmccu}{agg}{$fname}{fhtml}{$t} = $tdef{$t}; } } $hash->{hmccu}{agg}{$fname}{ftype} = $ftype; $hash->{hmccu}{agg}{$fname}{fexpr} = $fexpr; $hash->{hmccu}{agg}{$fname}{fexcl} = (defined ($fexcl) ? $fexcl : ''); $hash->{hmccu}{agg}{$fname}{fread} = $opt{'read'}; $hash->{hmccu}{agg}{$fname}{fcond} = $fcond; $hash->{hmccu}{agg}{$fname}{ftrue} = $fval; $hash->{hmccu}{agg}{$fname}{felse} = $opt{'else'}; $hash->{hmccu}{agg}{$fname}{fpref} = $opt{prefix} eq 'RULE' ? $fname : $opt{prefix}; $hash->{hmccu}{agg}{$fname}{fcoll} = $fcoll; $hash->{hmccu}{agg}{$fname}{fdflt} = $fdflt; } return 1; } ###################################################################### # Export default attributes. ###################################################################### sub HMCCU_ExportDefaults ($$) { my ($filename, $all) = @_; return 0 if (!open (DEFFILE, ">$filename")); print DEFFILE "# HMCCU default attributes for channels\n"; foreach my $t (keys %{$HMCCU_CHN_DEFAULTS}) { print DEFFILE "\nchannel:$t\n"; foreach my $a (sort keys %{$HMCCU_CHN_DEFAULTS->{$t}}) { print DEFFILE "$a=".$HMCCU_CHN_DEFAULTS->{$t}{$a}."\n"; } } print DEFFILE "\n# HMCCU default attributes for devices\n"; foreach my $t (keys %{$HMCCU_DEV_DEFAULTS}) { print DEFFILE "\ndevice:$t\n"; foreach my $a (sort keys %{$HMCCU_DEV_DEFAULTS->{$t}}) { print DEFFILE "$a=".$HMCCU_DEV_DEFAULTS->{$t}{$a}."\n"; } } if ($all) { print DEFFILE "# HMCCU custom default attributes for channels\n"; foreach my $t (keys %HMCCU_CUST_CHN_DEFAULTS) { print DEFFILE "\nchannel:$t\n"; foreach my $a (sort keys %{$HMCCU_CUST_CHN_DEFAULTS{$t}}) { print DEFFILE "$a=".$HMCCU_CUST_CHN_DEFAULTS{$t}{$a}."\n"; } } print DEFFILE "\n# HMCCU custom default attributes for devices\n"; foreach my $t (keys %HMCCU_CUST_DEV_DEFAULTS) { print DEFFILE "\ndevice:$t\n"; foreach my $a (sort keys %{$HMCCU_CUST_DEV_DEFAULTS{$t}}) { print DEFFILE "$a=".$HMCCU_CUST_DEV_DEFAULTS{$t}{$a}."\n"; } } } close (DEFFILE); return 1; } ###################################################################### # Import customer default attributes # Returns 1 on success. Returns negative line number on syntax errors. # Returns 0 on file open error. ###################################################################### sub HMCCU_ImportDefaults ($) { my ($filename) = @_; my $modtype = ''; my $ccutype = ''; my $line = 0; return 0 if (!open (DEFFILE, "<$filename")); my @defaults = <DEFFILE>; close (DEFFILE); chomp (@defaults); %HMCCU_CUST_CHN_DEFAULTS = (); %HMCCU_CUST_DEV_DEFAULTS = (); foreach my $d (@defaults) { $line++; next if ($d eq '' || $d =~ /^#/); if ($d =~ /^(channel|device):/) { my @t = split (':', $d, 2); if (scalar (@t) != 2) { close (DEFFILE); return -$line; } $modtype = $t[0]; $ccutype = $t[1]; next; } if ($ccutype eq '' || $modtype eq '') { close (DEFFILE); return -$line; } my @av = split ('=', $d, 2); if (scalar (@av) != 2) { close (DEFFILE); return -$line; } if ($modtype eq 'channel') { $HMCCU_CUST_CHN_DEFAULTS{$ccutype}{$av[0]} = $av[1]; } else { $HMCCU_CUST_DEV_DEFAULTS{$ccutype}{$av[0]} = $av[1]; } } return 1; } ###################################################################### # Find default attributes # Return template reference. ###################################################################### sub HMCCU_FindDefaults ($$) { my ($hash, $common) = @_; my $type = $hash->{TYPE}; my $ccutype = $hash->{ccutype}; if ($type eq 'HMCCUCHN') { my ($adr, $chn) = split (':', $hash->{ccuaddr}); foreach my $deftype (keys %HMCCU_CUST_CHN_DEFAULTS) { my @chnlst = split (',', $HMCCU_CUST_CHN_DEFAULTS{$deftype}{_channels}); return \%{$HMCCU_CUST_CHN_DEFAULTS{$deftype}} if ($ccutype =~ /^($deftype)$/i && grep { $_ eq $chn} @chnlst); } foreach my $deftype (keys %{$HMCCU_CHN_DEFAULTS}) { my @chnlst = split (',', $HMCCU_CHN_DEFAULTS->{$deftype}{_channels}); return \%{$HMCCU_CHN_DEFAULTS->{$deftype}} if ($ccutype =~ /^($deftype)$/i && grep { $_ eq $chn} @chnlst); } } elsif ($type eq 'HMCCUDEV' || $type eq 'HMCCU') { foreach my $deftype (keys %HMCCU_CUST_DEV_DEFAULTS) { return \%{$HMCCU_CUST_DEV_DEFAULTS{$deftype}} if ($ccutype =~ /^($deftype)$/i); } foreach my $deftype (keys %{$HMCCU_DEV_DEFAULTS}) { return \%{$HMCCU_DEV_DEFAULTS->{$deftype}} if ($ccutype =~ /^($deftype)$/i); } } return undef; } ###################################################################### # Set default attributes from template ###################################################################### sub HMCCU_SetDefaultsTemplate ($$) { my ($hash, $template) = @_; my $name = $hash->{NAME}; foreach my $a (keys %{$template}) { next if ($a =~ /^_/); my $v = $template->{$a}; CommandAttr (undef, "$name $a $v"); } } ###################################################################### # Set default attributes ###################################################################### sub HMCCU_SetDefaults ($) { my ($hash) = @_; my $name = $hash->{NAME}; # Set type specific attributes my $template = HMCCU_FindDefaults ($hash, 0); return 0 if (!defined ($template)); HMCCU_SetDefaultsTemplate ($hash, $template); return 1; } ###################################################################### # List default attributes for device type (mode = 0) or all # device types (mode = 1) with default attributes available. ###################################################################### sub HMCCU_GetDefaults ($$) { my ($hash, $mode) = @_; my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my $ccutype = $hash->{ccutype}; my $result = ''; my $deffile = ''; if ($mode == 0) { my $template = HMCCU_FindDefaults ($hash, 0); return ($result eq '' ? "No default attributes defined" : $result) if (!defined ($template)); foreach my $a (keys %{$template}) { next if ($a =~ /^_/); my $v = $template->{$a}; $result .= $a." = ".$v."\n"; } } else { $result = "HMCCU Channels:\n------------------------------\n"; foreach my $deftype (sort keys %{$HMCCU_CHN_DEFAULTS}) { my $tlist = $deftype; $tlist =~ s/\|/,/g; $result .= $HMCCU_CHN_DEFAULTS->{$deftype}{_description}." ($tlist), channels ". $HMCCU_CHN_DEFAULTS->{$deftype}{_channels}."\n"; } $result .= "\nHMCCU Devices:\n------------------------------\n"; foreach my $deftype (sort keys %{$HMCCU_DEV_DEFAULTS}) { my $tlist = $deftype; $tlist =~ s/\|/,/g; $result .= $HMCCU_DEV_DEFAULTS->{$deftype}{_description}." ($tlist)\n"; } $result .= "\nCustom Channels:\n-----------------------------\n"; foreach my $deftype (sort keys %HMCCU_CUST_CHN_DEFAULTS) { my $tlist = $deftype; $tlist =~ s/\|/,/g; $result .= $HMCCU_CUST_CHN_DEFAULTS{$deftype}{_description}." ($tlist), channels ". $HMCCU_CUST_CHN_DEFAULTS{$deftype}{_channels}."\n"; } $result .= "\nCustom Devices:\n-----------------------------\n"; foreach my $deftype (sort keys %HMCCU_CUST_DEV_DEFAULTS) { my $tlist = $deftype; $tlist =~ s/\|/,/g; $result .= $HMCCU_CUST_DEV_DEFAULTS{$deftype}{_description}." ($tlist)\n"; } } return $result; } ###################################################################### # Handle FHEM events ###################################################################### sub HMCCU_Notify ($$) { my ($hash, $devhash) = @_; my $name = $hash->{NAME}; my $devname = $devhash->{NAME}; my $devtype = $devhash->{TYPE}; my $disable = AttrVal ($name, 'disable', 0); my $ccuflags = HMCCU_GetFlags ($name); return if ($disable); my $events = deviceEvents ($devhash, 1); return if (!$events); # Process events foreach my $event (@{$events}) { if ($devname eq 'global') { if ($event eq 'INITIALIZED') { my $delay = $hash->{ccustate} eq 'active' && $hash->{hmccu}{ccu}{delayed} == 0 ? $HMCCU_INIT_INTERVAL0 : $hash->{hmccu}{ccu}{delay}+$HMCCU_CCU_RPC_OFFSET; HMCCU_Log ($hash, 0, "Scheduling post FHEM initialization tasks in $delay seconds"); InternalTimer (gettimeofday()+$delay, "HMCCU_PostInit", $hash, 0); } elsif ($event =~ /^(ATTR|DELETEATTR)/) { my $refreshAttrList = "ccucalculate|ccuflags|ccureadingfilter|ccureadingformat|". "ccureadingname|ccuReadingPrefix|ccuscaleval|controldatapoint|hmstatevals|". "statedatapoint|statevals|substitute:textField-long|substexcl|stripnumber"; my ($aCmd, $aDev, $aAtt, $aVal) = split (/\s+/, $event); if (defined($aAtt)) { my $clHash = $defs{$aDev}; if (defined($clHash->{TYPE}) && ($clHash->{TYPE} eq 'HMCCUCHN' || $clHash->{TYPE} eq 'HMCCUDEV') && $aAtt =~ /^($refreshAttrList)$/) { HMCCU_RefreshReadings ($clHash); } } } } else { return if ($devtype ne 'HMCCUDEV' && $devtype ne 'HMCCUCHN'); my ($r, $v) = split (": ", $event); return if (!defined($v) || $ccuflags =~ /noagg/); foreach my $rule (keys %{$hash->{hmccu}{agg}}) { my $ftype = $hash->{hmccu}{agg}{$rule}{ftype}; my $fexpr = $hash->{hmccu}{agg}{$rule}{fexpr}; my $fread = $hash->{hmccu}{agg}{$rule}{fread}; next if ($r !~ $fread); next if ($ftype eq 'name' && $devname !~ /$fexpr/); next if ($ftype eq 'type' && $devhash->{ccutype} !~ /$fexpr/); next if ($ftype eq 'group' && AttrVal ($devname, 'group', 'null') !~ /$fexpr/); next if ($ftype eq 'room' && AttrVal ($devname, 'room', 'null') !~ /$fexpr/); next if ($ftype eq 'alias' && AttrVal ($devname, 'alias', 'null') !~ /$fexpr/); HMCCU_AggregateReadings ($hash, $rule); } } } return; } ###################################################################### # Enhance device details in FHEM WEB ###################################################################### sub HMCCU_Detail ($$$$) { my ($FW_Name, $Device, $Room, $pageHash) = @_; my $hash = $defs{$Device}; return defined ($hash->{host}) ? qq( <span class='mkTitle'>CCU Administration</span> <table class="block wide"> <tr class="odd"> <td><div class="col1"> &gt; <a target="_blank" href="$hash->{prot}://$hash->{host}">CCU WebUI</a> </div></td> </tr> <tr class="odd"> <td><div class="col1"> &gt; <a target="_blank" href="$hash->{prot}://$hash->{host}/addons/cuxd/index.ccc">CUxD Config</a> </div></td> </tr> </table> ) : ''; } ###################################################################### # Calculate reading aggregations. # Called by Notify or via command get aggregation. ###################################################################### sub HMCCU_AggregateReadings ($$) { my ($hash, $rule) = @_; my $dc = 0; my $mc = 0; my $result = ''; my $rl = ''; my $table = ''; # Get rule parameters my $ftype = $hash->{hmccu}{agg}{$rule}{ftype}; my $fexpr = $hash->{hmccu}{agg}{$rule}{fexpr}; my $fexcl = $hash->{hmccu}{agg}{$rule}{fexcl}; my $fread = $hash->{hmccu}{agg}{$rule}{fread}; my $fcond = $hash->{hmccu}{agg}{$rule}{fcond}; my $ftrue = $hash->{hmccu}{agg}{$rule}{ftrue}; my $felse = $hash->{hmccu}{agg}{$rule}{felse}; my $fpref = $hash->{hmccu}{agg}{$rule}{fpref}; my $fhtml = exists ($hash->{hmccu}{agg}{$rule}{fhtml}) ? 1 : 0; my $resval; $resval = $ftrue if ($fcond =~ /^(max|min|sum|avg)$/); my @devlist = HMCCU_FindClientDevices ($hash, "(HMCCUDEV|HMCCUCHN)", undef, undef); foreach my $d (@devlist) { my $ch = $defs{$d}; my $cn = $ch->{NAME}; my $ct = $ch->{TYPE}; my $fmatch = ''; $fmatch = $cn if ($ftype eq 'name'); $fmatch = $ch->{ccutype} if ($ftype eq 'type'); $fmatch = AttrVal ($cn, 'group', '') if ($ftype eq 'group'); $fmatch = AttrVal ($cn, 'room', '') if ($ftype eq 'room'); $fmatch = AttrVal ($cn, 'alias', '') if ($ftype eq 'alias'); next if (!defined ($fmatch) || $fmatch eq '' || $fmatch !~ /$fexpr/ || ($fexcl ne '' && $fmatch =~ /$fexcl/)); my $fcoll = $hash->{hmccu}{agg}{$rule}{fcoll} eq 'NAME' ? $cn : AttrVal ($cn, $hash->{hmccu}{agg}{$rule}{fcoll}, $cn); # Compare readings foreach my $r (keys %{$ch->{READINGS}}) { next if ($r =~ /^\./ || $r !~ /$fread/); my $rv = $ch->{READINGS}{$r}{VAL}; my $f = 0; if (($fcond eq 'any' || $fcond eq 'all') && $rv =~ /$ftrue/) { $mc++; $f = 1; } if ($fcond eq 'max' && $rv > $resval) { $resval = $rv; $mc = 1; $f = 1; } if ($fcond eq 'min' && $rv < $resval) { $resval = $rv; $mc = 1; $f = 1; } if ($fcond eq 'sum' || $fcond eq 'avg') { $resval += $rv; $mc++; $f = 1; } if ($fcond =~ /^(gt|lt|ge|le)$/ && !HMCCU_IsFltNum ($rv)) { HMCCU_Log ($hash, 4, "Aggregation value $rv of reading $cn.$r is not numeric"); next; } if (($fcond eq 'gt' && $rv > $ftrue) || ($fcond eq 'lt' && $rv < $ftrue) || ($fcond eq 'ge' && $rv >= $ftrue) || ($fcond eq 'le' && $rv <= $ftrue)) { $mc++; $f = 1; } if ($f) { $rl .= ($mc > 1 ? ",$fcoll" : $fcoll); last; } } $dc++; } $rl = $hash->{hmccu}{agg}{$rule}{fdflt} if ($rl eq ''); # HTML code generation if ($fhtml) { if ($rl ne '') { $table = $hash->{hmccu}{agg}{$rule}{fhtml}{'begin-html'}. $hash->{hmccu}{agg}{$rule}{fhtml}{'begin-table'}; $table .= $hash->{hmccu}{agg}{$rule}{fhtml}{'header'} if (exists ($hash->{hmccu}{agg}{$rule}{fhtml}{'header'})); my $row = 1; foreach my $v (split (",", $rl)) { my $t_row = ($row % 2) ? $hash->{hmccu}{agg}{$rule}{fhtml}{'row-odd'} : $hash->{hmccu}{agg}{$rule}{fhtml}{'row-even'}; $t_row =~ s/\<reading\/\>/$v/; $table .= $t_row; $row++; } $table .= $hash->{hmccu}{agg}{$rule}{fhtml}{'end-table'}. $hash->{hmccu}{agg}{$rule}{fhtml}{'end-html'}; } else { $table = $hash->{hmccu}{agg}{$rule}{fhtml}{'begin-html'}. $hash->{hmccu}{agg}{$rule}{fhtml}{'default'}. $hash->{hmccu}{agg}{$rule}{fhtml}{'end-html'}; } } if ($fcond eq 'any') { $result = $mc > 0 ? $ftrue : $felse; } elsif ($fcond eq 'all') { $result = $mc == $dc ? $ftrue : $felse; } elsif ($fcond eq 'min' || $fcond eq 'max' || $fcond eq 'sum') { $result = $mc > 0 ? $resval : $felse; } elsif ($fcond eq 'avg') { $result = $mc > 0 ? $resval/$mc : $felse; } elsif ($fcond =~ /^(gt|lt|ge|le)$/) { $result = $mc; } HMCCU_UpdateReadings ($hash, { $fpref.'state' => $result, $fpref.'match' => $mc, $fpref.'count' => $dc, $fpref.'list' => $rl }); readingsSingleUpdate ($hash, $fpref.'table', $table, 1) if ($fhtml); # Set readings # readingsBeginUpdate ($hash); # readingsBulkUpdate ($hash, $fpref.'state', $result); # readingsBulkUpdate ($hash, $fpref.'match', $mc); # readingsBulkUpdate ($hash, $fpref.'count', $dc); # readingsBulkUpdate ($hash, $fpref.'list', $rl); # readingsBulkUpdate ($hash, $fpref.'table', $table) if ($fhtml); # readingsEndUpdate ($hash, 1); return $result; } ###################################################################### # Delete device ###################################################################### sub HMCCU_Undef ($$) { my ($hash, $arg) = @_; # Shutdown RPC server HMCCU_Shutdown ($hash); # Delete reference to IO module in client devices my @keylist = keys %defs; foreach my $d (@keylist) { if (exists ($defs{$d}) && exists($defs{$d}{IODev}) && $defs{$d}{IODev} == $hash) { delete $defs{$d}{IODev}; } } return undef; } ###################################################################### # Delayed shutdown FHEM ###################################################################### sub HMCCU_DelayedShutdown ($) { my ($hash) = @_; my $name = $hash->{NAME}; my $delay = HMCCU_Max (AttrVal ("global", "maxShutdownDelay", 10)-2, 0); # Shutdown RPC server if (!exists ($hash->{hmccu}{delayedShutdown})) { $hash->{hmccu}{delayedShutdown} = $delay; HMCCU_Log ($hash, 1, "Graceful shutdown in $delay seconds"); HMCCU_StopExtRPCServer ($hash, 0); } else { HMCCU_Log ($hash, 1, "Graceful shutdown already in progress"); } return 1; } ###################################################################### # Shutdown FHEM ###################################################################### sub HMCCU_Shutdown ($) { my ($hash) = @_; my $name = $hash->{NAME}; # Shutdown RPC server if (!exists ($hash->{hmccu}{delayedShutdown})) { HMCCU_Log ($hash, 1, "Immediate shutdown"); HMCCU_StopExtRPCServer ($hash, 0); } else { HMCCU_Log ($hash, 1, "Graceful shutdown"); } # Remove existing timer functions RemoveInternalTimer ($hash); return undef; } ###################################################################### # Set commands ###################################################################### sub HMCCU_Set ($@) { my ($hash, $a, $h) = @_; my $name = shift @$a; my $opt = shift @$a; my $options = "var clear delete execute hmscript cleardefaults:noArg datapoint defaults:noArg ". "importdefaults rpcregister:all rpcserver:on,off,restart ackmessages:noArg authentication ". "prgActivate prgDeactivate"; return "No set command specified" if (!defined ($opt)); my @ifList = HMCCU_GetRPCInterfaceList ($hash); if (scalar (@ifList) > 0) { my $ifStr = join (',', @ifList); $options =~ s/rpcregister:all/rpcregister:all,$ifStr/; } my $host = $hash->{host}; $options = "initialize:noArg" if (exists ($hash->{hmccu}{ccu}{delayed}) && $hash->{hmccu}{ccu}{delayed} == 1 && $hash->{ccustate} eq 'unreachable'); # return undef if ($hash->{ccustate} ne 'active'); return "HMCCU: CCU busy, choose one of rpcserver:off" if ($opt ne 'rpcserver' && HMCCU_IsRPCStateBlocking ($hash)); my $usage = "HMCCU: Unknown argument $opt, choose one of $options"; my $ccuflags = HMCCU_GetFlags ($name); my $stripchar = AttrVal ($name, "stripchar", ''); my $ccureadings = AttrVal ($name, "ccureadings", $ccuflags =~ /noReadings/ ? 0 : 1); my $ccureqtimeout = AttrVal ($name, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); my $readingformat = HMCCU_GetAttrReadingFormat ($hash, $hash); my $substitute = HMCCU_GetAttrSubstitute ($hash, $hash); my $result; # Add program names to command execute if (exists ($hash->{hmccu}{prg})) { my @progs = (); my @aprogs = (); my @iprogs = (); foreach my $p (keys %{$hash->{hmccu}{prg}}) { if ($hash->{hmccu}{prg}{$p}{internal} eq 'false' && $p !~ /^\$/) { push (@progs, $p); push (@aprogs, $p) if ($hash->{hmccu}{prg}{$p}{active} eq 'true'); push (@iprogs, $p) if ($hash->{hmccu}{prg}{$p}{active} eq 'false'); } } if (scalar (@progs) > 0) { my $prgopt = "execute:".join(',', @progs); my $prgact = "prgActivate:".join(',', @iprogs); my $prgdac = "prgDeactivate:".join(',', @aprogs); $options =~ s/execute/$prgopt/; $options =~ s/prgActivate/$prgact/; $options =~ s/prgDeactivate/$prgdac/; $usage =~ s/execute/$prgopt/; $usage =~ s/prgActivate/$prgact/; $usage =~ s/prgDeactivate/$prgdac/; } } if ($opt eq 'var') { my $vartype; $vartype = shift @$a if (scalar (@$a) == 3); my $objname = shift @$a; my $objvalue = shift @$a; $usage = "set $name $opt [{'bool'|'list'|'number'|'text'}] variable value [param=value [...]]"; return HMCCU_SetError ($hash, $usage) if (!defined ($objvalue)); $objname =~ s/$stripchar$// if ($stripchar ne ''); $objvalue =~ s/\\_/%20/g; $h->{name} = $objname if (!defined ($h) && defined ($vartype)); $result = HMCCU_SetVariable ($hash, $objname, $objvalue, $vartype, $h); return HMCCU_SetError ($hash, $result) if ($result < 0); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'initialize') { return HMCCU_SetError ($hash, "State of CCU must be unreachable") if ($hash->{ccustate} ne 'unreachable'); my $err = HMCCU_InitDevice ($hash); return HMCCU_SetError ($hash, "CCU not reachable") if ($err == 1); return HMCCU_SetError ($hash, "Can't read device list from CCU") if ($err == 2); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'authentication') { my $username = shift @$a; my $password = shift @$a; $usage = "set $name $opt username password"; if (!defined ($username)) { setKeyValue ($name."_username", undef); setKeyValue ($name."_password", undef); return "Credentials for CCU authentication deleted"; } return HMCCU_SetError ($hash, $usage) if (!defined ($password)); my $encuser = HMCCU_Encrypt ($username); my $encpass = HMCCU_Encrypt ($password); return HMCCU_SetError ($hash, "Encryption of credentials failed") if ($encuser eq '' || $encpass eq ''); my $err = setKeyValue ($name."_username", $encuser); return HMCCU_SetError ($hash, "Can't store credentials. $err") if (defined ($err)); $err = setKeyValue ($name."_password", $encpass); return HMCCU_SetError ($hash, "Can't store credentials. $err") if (defined ($err)); return "Credentials for CCU authentication stored"; } elsif ($opt eq 'clear') { my $rnexp = shift @$a; HMCCU_DeleteReadings ($hash, $rnexp); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'datapoint') { $usage = "set $name $opt [DevSpec] [Device[,...]].[Channel].Datapoint=Value [...]\n"; my $devSpec = shift @$a; return HMCCU_SetError ($hash, $usage) if (scalar(keys %$h) < 1); my $cmd = 1; my %dpValues; my @devSpecList = (); if (defined($devSpec)) { @devSpecList = devspec2array ($devSpec); return HMCCU_SetError ($hash, "No FHEM device matching $devSpec in command set datapoint") if (scalar (@devSpecList) == 0); } foreach my $dptSpec (keys %$h) { my $adr; my $chn; my $dpt; my $value = $h->{$dptSpec}; my @t = split (/\./, $dptSpec); my @devList = (); if (scalar(@t) == 3 || (scalar(@t) == 2 && $dptSpec !~ /^[0-9]{1,2}\.(.+)$/)) { $devSpec = shift @t; @devList = split (',', $devSpec); } else { @devList = @devSpecList; } my ($t1, $t2) = @t; foreach my $devName (@devList) { my $dh = $defs{$devName}; my $ccuif = $dh->{ccuif}; my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($dh); my $stateVals = HMCCU_GetStateValues ($dh, $cd, $cc); if ($dh->{TYPE} eq 'HMCCUCHN') { if (defined ($t2)) { HMCCU_Log ($hash, 3, "Ignored channel in set datapoint for device $devName"); $dpt = $t2; } else { $dpt = $t1; } ($adr, $chn) = HMCCU_SplitChnAddr ($dh->{ccuaddr}); } elsif ($dh->{TYPE} eq 'HMCCUDEV') { return HMCCU_SetError ($hash, "Missing channel number for device $devName") if (!defined ($t2)); return HMCCU_SetError ($hash, "Invalid channel number specified for device $devName") if ($t1 !~ /^[0-9]+$/ || $t1 > $dh->{channels}); $adr = $dh->{ccuaddr}; $chn = $t1; $dpt = $t2; } else { return HMCCU_SetError ($hash, "FHEM device $devName has illegal type"); } return HMCCU_SetError ($hash, "Invalid datapoint $dpt specified for device $devName") if (!HMCCU_IsValidDatapoint ($dh, $dh->{ccutype}, $chn, $dpt, 2)); $value = HMCCU_Substitute ($value, $stateVals, 1, undef, '') if ($stateVals ne '' && "$chn" eq "$cc" && $dpt eq $cd); my $no = sprintf ("%03d", $cmd); $dpValues{"$no.$ccuif.$devName:$chn.$dpt"} = $value; $cmd++; } } my $rc = HMCCU_SetMultipleDatapoints ($hash, \%dpValues); return HMCCU_SetError ($hash, $rc) if ($rc < 0); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'delete') { my $objname = shift @$a; my $objtype = shift @$a; $objtype = "OT_VARDP" if (!defined ($objtype)); $usage = "Usage: set $name $opt ccuobject ['OT_VARDP'|'OT_DEVICE']"; return HMCCU_SetError ($hash, $usage) if (!defined ($objname) || $objtype !~ /^(OT_VARDP|OT_DEVICE)$/); $result = HMCCU_HMScriptExt ($hash, "!DeleteObject", { name => $objname, type => $objtype }, undef, undef); return HMCCU_SetError ($hash, -2) if ($result =~ /^ERROR:.*/); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'execute') { my $program = shift @$a; $program .= ' '.join(' ', @$a) if (scalar (@$a) > 0); my $response; $usage = "Usage: set $name $opt program-name"; return HMCCU_SetError ($hash, $usage) if (!defined ($program)); my $cmd = qq(dom.GetObject("$program").ProgramExecute()); my $value = HMCCU_HMCommand ($hash, $cmd, 1); return HMCCU_SetState ($hash, 'OK') if (defined($value)); return HMCCU_SetError ($hash, 'Program execution error'); } elsif ($opt eq 'prgActivate' || $opt eq 'prgDeactivate') { my $program = shift @$a; my $mode = $opt eq 'prgActivate' ? 'true' : 'false'; $usage = "Usage: set $name $opt program-name"; return HMCCU_SetError ($hash, $usage) if (!defined ($program)); $result = HMCCU_HMScriptExt ($hash, '!ActivateProgram', { name => $program, mode => $mode }, undef, undef); return HMCCU_SetError ($hash, -2) if ($result =~ /^ERROR:.*/); return HMCCU_SetState ($hash, 'OK'); } elsif ($opt eq 'hmscript') { my $script = shift @$a; my $dump = shift @$a; my $response = ''; my %objects = (); my $objcount = 0; $usage = "Usage: set $name $opt {file|!function|'['code']'} ['dump'] [parname=value [...]]"; # If no parameter is specified list available script functions if (!defined ($script)) { $response = "Available HomeMatic script functions:\n". "-------------------------------------\n"; foreach my $scr (keys %{$HMCCU_SCRIPTS}) { $response .= "$scr ".$HMCCU_SCRIPTS->{$scr}{syntax}."\n". $HMCCU_SCRIPTS->{$scr}{description}."\n\n"; } $response .= $usage; return $response; } return HMCCU_SetError ($hash, $usage) if (defined ($dump) && $dump ne 'dump'); # Execute script $response = HMCCU_HMScriptExt ($hash, $script, $h, undef, undef); return HMCCU_SetError ($hash, -2, $response) if ($response =~ /^ERROR:/); HMCCU_SetState ($hash, 'OK'); return $response if (! $ccureadings || defined ($dump)); foreach my $line (split /[\n\r]+/, $response) { my @tokens = split /=/, $line; next if (@tokens != 2); my $reading; my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($hash, $tokens[0], $HMCCU_FLAG_INTERFACE); ($add, $chn) = HMCCU_GetAddress ($hash, $nam, '', '') if ($flags == $HMCCU_FLAGS_NCD); if ($flags == $HMCCU_FLAGS_IACD || $flags == $HMCCU_FLAGS_NCD) { $objects{$add}{$chn}{VALUES}{$dpt} = $tokens[1]; $objcount++; } else { # If output is not related to a channel store reading in I/O device my $Value = HMCCU_Substitute ($tokens[1], $substitute, 0, undef, $tokens[0]); my $rn = HMCCU_CorrectName ($tokens[0]); readingsSingleUpdate ($hash, $rn, $Value, 1); } } HMCCU_UpdateMultipleDevices ($hash, \%objects) if ($objcount > 0); return defined ($dump) ? $response : undef; } elsif ($opt eq 'rpcregister') { my $ifName = shift @$a; $result = ''; @ifList = (defined ($ifName) && $ifName ne 'all') ? ($ifName) : HMCCU_GetRPCInterfaceList ($hash); foreach my $i (@ifList) { my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 0, $i); if ($rpcdev eq '') { HMCCU_Log ($hash, 2, "Can't find HMCCURPCPROC device for interface $i"); next; } my $res = AnalyzeCommandChain (undef, "set $rpcdev register"); $result .= $res if (defined ($res)); } return HMCCU_SetState ($hash, "OK", $result); } elsif ($opt eq 'rpcserver') { my $action = shift @$a; $action = shift @$a if ($action eq $opt); $usage = "Usage: set $name $opt {'on'|'off'|'restart'}"; return HMCCU_SetError ($hash, $usage) if (!defined ($action) || $action !~ /^(on|off|restart)$/); if ($action eq 'on') { return HMCCU_SetError ($hash, "Start of RPC server failed") if (!HMCCU_StartExtRPCServer ($hash)); } elsif ($action eq 'off') { return HMCCU_SetError ($hash, "Stop of RPC server failed") if (!HMCCU_StopExtRPCServer ($hash)); } elsif ($action eq 'restart') { return "HMCCU: No RPC server running" if (!HMCCU_IsRPCServerRunning ($hash, undef, undef)); return HMCCU_SetError ($hash, "HMCCU: restart of RPC server not supported"); } return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'ackmessages') { my $response = HMCCU_HMScriptExt ($hash, "!ClearUnreachable", undef, undef, undef); return HMCCU_SetError ($hash, -2, $response) if ($response =~ /^ERROR:/); return HMCCU_SetState ($hash, "OK", "Unreach errors in CCU cleared"); } elsif ($opt eq 'defaults') { my $rc = HMCCU_SetDefaults ($hash); return HMCCU_SetError ($hash, "HMCCU: No default attributes found") if ($rc == 0); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'cleardefaults') { %HMCCU_CUST_CHN_DEFAULTS = (); %HMCCU_CUST_DEV_DEFAULTS = (); return HMCCU_SetState ($hash, "OK", "Default attributes deleted"); } elsif ($opt eq 'importdefaults') { my $filename = shift @$a; $usage = "Usage: set $name $opt filename"; return HMCCU_SetError ($hash, $usage) if (!defined ($filename)); my $rc = HMCCU_ImportDefaults ($filename); return HMCCU_SetError ($hash, -16) if ($rc == 0); if ($rc < 0) { $rc = -$rc; return HMCCU_SetError ($hash, "Syntax error in default attribute file $filename line $rc"); } return HMCCU_SetState ($hash, "OK", "Default attributes read from file $filename"); } else { return $usage; } } ###################################################################### # Get commands ###################################################################### sub HMCCU_Get ($@) { my ($hash, $a, $h) = @_; my $name = shift @$a; my $opt = shift @$a; return "No get command specified" if (!defined($opt)); $opt = lc($opt); my $options = "ccuconfig create defaults:noArg exportDefaults dump dutycycle:noArg vars update". " updateccu deviceDesc paramsetDesc firmware rpcEvents:noArg rpcState:noArg deviceInfo". " ccuMsg:alarm,service ccuConfig:noArg"; my $usage = "HMCCU: Unknown argument $opt, choose one of $options"; my $host = $hash->{host}; return undef if ($hash->{hmccu}{ccu}{delayed} || $hash->{ccustate} ne 'active'); return "HMCCU: CCU busy, choose one of rpcstate:noArg" if ($opt ne 'rpcstate' && HMCCU_IsRPCStateBlocking ($hash)); my $ccuflags = HMCCU_GetFlags ($name); my $ccureadings = AttrVal ($name, "ccureadings", $ccuflags =~ /noReadings/ ? 0 : 1); my $readname; my $readaddr; my $result = ''; my $rc; if ($opt eq 'dump') { my $content = shift @$a; my $filter = shift @$a; $filter = '.*' if (!defined ($filter)); $usage = "Usage: get $name dump {'datapoints'|'devtypes'} [filter]"; my %foper = (1, "R", 2, "W", 4, "E", 3, "RW", 5, "RE", 6, "WE", 7, "RWE"); my %ftype = (2, "B", 4, "F", 16, "I", 20, "S"); return HMCCU_SetError ($hash, $usage) if (!defined ($content)); if ($content eq 'devtypes') { foreach my $devtype (sort keys %{$hash->{hmccu}{dp}}) { $result .= $devtype."\n" if ($devtype =~ /$filter/); } } elsif ($content eq 'datapoints') { foreach my $devtype (sort keys %{$hash->{hmccu}{dp}}) { next if ($devtype !~ /$filter/); foreach my $chn (sort keys %{$hash->{hmccu}{dp}{$devtype}{ch}}) { foreach my $dpt (sort keys %{$hash->{hmccu}{dp}{$devtype}{ch}{$chn}}) { my $t = $hash->{hmccu}{dp}{$devtype}{ch}{$chn}{$dpt}{type}; my $o = $hash->{hmccu}{dp}{$devtype}{ch}{$chn}{$dpt}{oper}; $result .= $devtype.".".$chn.".".$dpt." [". (exists($ftype{$t}) ? $ftype{$t} : $t)."] [". (exists($foper{$o}) ? $foper{$o} : $o)."]\n"; } } } } else { return HMCCU_SetError ($hash, $usage); } return HMCCU_SetState ($hash, 'OK', ($result eq '') ? 'No data found' : $result); } elsif ($opt eq 'vars') { my $varname = shift @$a; $usage = "Usage: get $name vars {regexp}[,...]"; return HMCCU_SetError ($hash, $usage) if (!defined ($varname)); ($rc, $result) = HMCCU_GetVariables ($hash, $varname); return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0); return HMCCU_SetState ($hash, "OK", $ccureadings ? undef : $result); } elsif ($opt eq 'update' || $opt eq 'updateccu') { my $devexp = shift @$a; $devexp = '.*' if (!defined ($devexp)); $usage = "Usage: get $name $opt [device-expr [{'State'|'Value'}]]"; my $ccuget = shift @$a; $ccuget = 'Attr' if (!defined ($ccuget)); return HMCCU_SetError ($hash, $usage) if ($ccuget !~ /^(Attr|State|Value)$/); my $nonBlocking = HMCCU_IsFlag ($name, 'nonBlocking') ? 1 : 0; HMCCU_UpdateClients ($hash, $devexp, $ccuget, ($opt eq 'updateccu') ? 1 : 0, undef, 0); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'deviceinfo') { my $device = shift @$a; $usage = "Usage: get $name $opt device [{'State'|'Value'}]"; return HMCCU_SetError ($hash, $usage) if (!defined ($device)); my $ccuget = shift @$a; $ccuget = 'Attr' if (!defined ($ccuget)); return HMCCU_SetError ($hash, $usage) if ($ccuget !~ /^(Attr|State|Value)$/); return HMCCU_SetError ($hash, -1) if (!HMCCU_IsValidDeviceOrChannel ($hash, $device, $HMCCU_FL_ALL)); $result = HMCCU_GetDeviceInfo ($hash, $device, $ccuget); return HMCCU_SetError ($hash, -2) if ($result eq '' || $result =~ /^ERROR:.*/); HMCCU_SetState ($hash, "OK"); return HMCCU_FormatDeviceInfo ($result); } elsif ($opt eq 'rpcevents') { $result = ''; my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $ifname (@iflist) { my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 0, $ifname); if ($rpcdev eq '') { HMCCU_Log ($hash, 2, "Can't find HMCCURPCPROC device for interface $ifname"); next; } my $res = AnalyzeCommandChain (undef, "get $rpcdev rpcevents"); $result .= $res if (defined ($result)); } return HMCCU_SetState ($hash, "OK", $result) if ($result ne ''); return HMCCU_SetError ($hash, "No event statistics available"); } elsif ($opt eq 'rpcstate') { my @hm_pids = (); my @hm_tids = (); $result = "No RPC processes or threads are running"; if (HMCCU_IsRPCServerRunning ($hash, \@hm_pids, \@hm_tids)) { $result = "RPC process(es) running with pid(s) ". join (',', @hm_pids) if (scalar (@hm_pids) > 0); $result = "RPC thread(s) running with tid(s) ". join (',', @hm_tids) if (scalar (@hm_tids) > 0); } return HMCCU_SetState ($hash, "OK", $result); } elsif ($opt eq 'ccuconfig') { my ($devcount, $chncount, $ifcount, $prgcount, $gcount) = HMCCU_GetDeviceList ($hash); return HMCCU_SetError ($hash, -2) if ($devcount < 0); return HMCCU_SetError ($hash, "No devices received from CCU") if ($devcount == 0); HMCCU_ResetDeviceTables ($hash); my ($cDev, $cPar, $cLnk) = HMCCU_GetDeviceConfig ($hash); return "Devices: $devcount, Channels: $chncount\nDevice descriptions: $cDev\n". "Paramset descriptions: $cPar\nLinks/Peerings: $cLnk"; } elsif ($opt eq 'create') { $usage = "Usage: get $name create {devexp|chnexp} [t={'chn'|'dev'|'all'}] [s=suffix] ". "[p=prefix] [f=format] ['defaults'|'noDefaults'] [save] [attr=val [...]]"; my $devdefaults = 1; my $savedef = 0; my $newcount = 0; # Process command line parameters my $devspec = shift @$a; my $devprefix = exists ($h->{p}) ? $h->{p} : ''; my $devsuffix = exists ($h->{'s'}) ? $h->{'s'} : ''; my $devtype = exists ($h->{t}) ? $h->{t} : 'dev'; my $devformat = exists ($h->{f}) ? $h->{f} : '%n'; return HMCCU_SetError ($hash, $usage) if ($devtype !~ /^(dev|chn|all)$/ || !defined ($devspec)); foreach my $defopt (@$a) { if ($defopt eq 'defaults') { $devdefaults = 1; } elsif (lc($defopt) eq 'nodefaults') { $devdefaults = 0; } elsif ($defopt eq 'save') { $savedef = 1; } else { return HMCCU_SetError ($hash, $usage); } } # Get list of existing client devices my @devlist = HMCCU_FindClientDevices ($hash, "(HMCCUDEV|HMCCUCHN)", undef, undef); foreach my $add (sort keys %{$hash->{hmccu}{dev}}) { my $defmod = $hash->{hmccu}{dev}{$add}{addtype} eq 'dev' ? 'HMCCUDEV' : 'HMCCUCHN'; my $ccuname = $hash->{hmccu}{dev}{$add}{name}; my $ccudevname = HMCCU_GetDeviceName ($hash, $add, $ccuname); next if ($devtype ne 'all' && $devtype ne $hash->{hmccu}{dev}{$add}{addtype}); next if (HMCCU_ExprNotMatch ($ccuname, $devspec, 1)); # Build FHEM device name my $devname = $devformat; $devname = $devprefix.$devname.$devsuffix; $devname =~ s/%n/$ccuname/g; $devname =~ s/%d/$ccudevname/g; $devname =~ s/%a/$add/g; $devname =~ s/[^A-Za-z\d_\.]+/_/g; # Check for duplicate device definitions next if (exists ($defs{$devname})); my $devexists = 0; foreach my $exdev (@devlist) { if ($defs{$exdev}->{ccuaddr} eq $add) { $devexists = 1; last; } } next if ($devexists); # Define new client device my $ret = CommandDefine (undef, $devname." $defmod ".$add); if ($ret) { HMCCU_Log ($hash, 2, "Define command failed $devname $defmod $ccuname. $ret"); $result .= "\nCan't create device $devname. $ret"; next; } # Set device attributes HMCCU_SetDefaults ($defs{$devname}) if ($devdefaults); foreach my $da (keys %$h) { next if ($da =~ /^[pstf]$/); $ret = CommandAttr (undef, "$devname $da ".$h->{$da}); HMCCU_Log ($hash, 2, "Attr command failed $devname $da ".$h->{$da}.". $ret") if ($ret); } HMCCU_Log ($hash, 2, "Created device $devname"); $result .= "\nCreated device $devname"; $newcount++; } CommandSave (undef, undef) if ($newcount > 0 && $savedef); $result .= "\nCreated $newcount client devices"; return HMCCU_SetState ($hash, "OK", $result); } elsif ($opt eq 'dutycycle') { my $dc = HMCCU_GetDutyCycle ($hash); return HMCCU_SetState ($hash, "OK"); } elsif ($opt eq 'firmware') { my $devtype = shift @$a; $devtype = '.*' if (!defined ($devtype)); my $dtexp = $devtype; $dtexp = '.*' if ($devtype eq 'full'); my $dc = HMCCU_GetFirmwareVersions ($hash, $dtexp); return "Found no firmware downloads" if ($dc == 0); $result = "Found $dc firmware downloads. Click on the new version number for download\n\n"; if ($devtype eq 'full') { $result .= "Type Available Date\n". "-----------------------------------------\n"; foreach my $ct (keys %{$hash->{hmccu}{type}}) { $result .= sprintf "%-20s <a href=\"http://www.eq-3.de/%s\">%-9s</a> %-10s\n", $ct, $hash->{hmccu}{type}{$ct}{download}, $hash->{hmccu}{type}{$ct}{firmware}, $hash->{hmccu}{type}{$ct}{date}; } } else { my @devlist = HMCCU_FindClientDevices ($hash, "(HMCCUDEV|HMCCUCHN)", undef, undef); return $result if (scalar (@devlist) == 0); $result .= "Device Type Current Available Date\n". "---------------------------------------------------------------------------\n"; foreach my $dev (@devlist) { my $ch = $defs{$dev}; my $ct = uc($ch->{ccutype}); my $fw = defined ($ch->{firmware}) ? $ch->{firmware} : 'N/A'; next if (!exists ($hash->{hmccu}{type}{$ct}) || $ct !~ /$dtexp/); $result .= sprintf "%-25s %-20s %-7s <a href=\"http://www.eq-3.de/%s\">%-9s</a> %-10s\n", $ch->{NAME}, $ct, $fw, $hash->{hmccu}{type}{$ct}{download}, $hash->{hmccu}{type}{$ct}{firmware}, $hash->{hmccu}{type}{$ct}{date}; } } return HMCCU_SetState ($hash, "OK", $result); } elsif ($opt eq 'defaults') { $result = HMCCU_GetDefaults ($hash, 1); return HMCCU_SetState ($hash, "OK", $result); } elsif ($opt eq 'exportdefaults') { my $filename = shift @$a; $usage = "Usage: get $name $opt filename ['all']"; my $all = 0; my $defopt = shift @$a; $all = 1 if (defined($defopt) && $defopt eq 'all'); return HMCCU_SetError ($hash, $usage) if (!defined ($filename)); my $rc = HMCCU_ExportDefaults ($filename, $all); return HMCCU_SetError ($hash, -16) if ($rc == 0); return HMCCU_SetState ($hash, "OK", "Default attributes written to $filename"); } elsif ($opt eq 'aggregation') { my $rule = shift @$a; $usage = "Usage: get $name $opt {'all'|'rule'}"; return HMCCU_SetError ($hash, $usage) if (!defined ($rule)); if ($rule eq 'all') { foreach my $r (keys %{$hash->{hmccu}{agg}}) { my $rc = HMCCU_AggregateReadings ($hash, $r); $result .= "$r = $rc\n"; } } else { return HMCCU_SetError ($hash, "HMCCU: Aggregation rule does not exist") if (!exists ($hash->{hmccu}{agg}{$rule})); $result = HMCCU_AggregateReadings ($hash, $rule); $result = "$rule = $result"; } return HMCCU_SetState ($hash, "OK", $ccureadings ? undef : $result); } elsif ($opt eq 'devicedesc') { my $ccuobj = shift @$a; return HMCCU_SetError ($hash, "Usage: get $name $opt {device|channel}") if (!defined ($ccuobj)); my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($hash, $ccuobj, $HMCCU_FLAG_FULLADDR); return HMCCU_SetError ($hash, "Invalid device or address") if (!($flags & $HMCCU_FLAG_ADDRESS)); $result = HMCCU_DeviceDescToStr ($hash, $add); return defined($result) ? $result : HMCCU_SetError ($hash, "Can't get device description"); } elsif ($opt eq 'paramsetdesc') { my $ccuobj = shift @$a; return HMCCU_SetError ($hash, "Usage: get $name $opt {device|channel}") if (!defined ($ccuobj)); my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($hash, $ccuobj, $HMCCU_FLAG_FULLADDR); return HMCCU_SetError ($hash, "Invalid device or address") if (!($flags & $HMCCU_FLAG_ADDRESS)); $result = HMCCU_ParamsetDescToStr ($hash, $add); return defined($result) ? $result : HMCCU_SetError ($hash, "Can't get device description"); } elsif ($opt eq 'ccumsg') { my $msgtype = shift @$a; $usage = "Usage: get $name $opt {service|alarm}"; return HMCCU_SetError ($hash, $usage) if (!defined ($msgtype)); my $script = ($msgtype eq 'service') ? "!GetServiceMessages" : "!GetAlarms"; my $res = HMCCU_HMScriptExt ($hash, $script, undef, undef, undef); return HMCCU_SetError ($hash, "Error") if ($res eq '' || $res =~ /^ERROR:.*/); # Generate event for each message foreach my $msg (split /[\n\r]+/, $res) { next if ($msg =~ /^[0-9]+$/); DoTrigger ($name, $msg); } return HMCCU_SetState ($hash, "OK", $res); } else { if (exists ($hash->{hmccu}{agg})) { my @rules = keys %{$hash->{hmccu}{agg}}; $usage .= " aggregation:all,".join (',', @rules) if (scalar (@rules) > 0); } return $usage; } } ###################################################################### # Parse CCU object specification. # # Supported address types: # Classic Homematic and Homematic-IP addresses. # Team addresses with leading * for BidCos-RF. # CCU virtual remote addresses (BidCoS:ChnNo) # OSRAM lightify addresses (OL-...) # Homematic virtual layer addresses (if known by HMCCU) # # Possible syntax for datapoints: # Interface.Address:Channel.Datapoint # Address:Channel.Datapoint # Channelname.Datapoint # # Possible syntax for channels: # Interface.Address:Channel # Address:Channel # Channelname # # If object name doesn't match the rules above it's treated as name. # With parameter flags one can specify if result is filled up with # default values for interface or datapoint. # # Return list of detected attributes (empty string if attribute is # not detected): # (Interface, Address, Channel, Datapoint, Name, Flags) # Flags is a bitmask of detected attributes. ###################################################################### sub HMCCU_ParseObject ($$$) { my ($hash, $object, $flags) = @_; my ($i, $a, $c, $d, $n, $f) = ('', '', '', '', '', '', 0); my $extaddr; my ($defInterface, $defPort) = HMCCU_GetDefaultInterface ($hash); # "ccu:" is default. Remove it. $object =~ s/^ccu://g; # Check for FHEM device if ($object =~ /^hmccu:/) { my ($hmccu, $fhdev, $fhcdp) = split(':', $object); return ($i, $a, $c, $d, $n, $f) if (!defined ($fhdev)); my $cl_hash = $defs{$fhdev}; return ($i, $a, $c, $d, $n, $f) if (!defined ($cl_hash) || ($cl_hash->{TYPE} ne 'HMCCUDEV' && $cl_hash->{TYPE} ne 'HMCCUCHN')); $object = $cl_hash->{ccuaddr}; $object .= ":$fhcdp" if (defined ($fhcdp)); } # Check if address is already known by HMCCU. Substitute device address by ZZZ0000000 # to allow external addresses like HVL if ($object =~ /^.+\.(.+):[0-9]{1,2}\..+$/ || $object =~ /^.+\.(.+):[0-9]{1,2}$/ || $object =~ /^(.+):[0-9]{1,2}\..+$/ || $object =~ /^(.+):[0-9]{1,2}$/ || $object =~ /^(.+)$/) { $extaddr = $1; if (!HMCCU_IsDevAddr ($extaddr, 0) && exists ($hash->{hmccu}{dev}{$extaddr}) && $hash->{hmccu}{dev}{$extaddr}{valid}) { $object =~ s/$extaddr/$HMCCU_EXT_ADDR/; } } if ($object =~ /^(.+?)\.([\*]*[A-Z]{3}[0-9]{7}):([0-9]{1,2})\.(.+)$/ || $object =~ /^(.+?)\.([0-9A-F]{12,14}):([0-9]{1,2})\.(.+)$/ || $object =~ /^(.+?)\.(OL-.+):([0-9]{1,2})\.(.+)$/ || $object =~ /^(.+?)\.(BidCoS-RF):([0-9]{1,2})\.(.+)$/) { # # Interface.Address:Channel.Datapoint [30=11110] # $f = $HMCCU_FLAGS_IACD; ($i, $a, $c, $d) = ($1, $2, $3, $4); } elsif ($object =~ /^(.+)\.([\*]*[A-Z]{3}[0-9]{7}):([0-9]{1,2})$/ || $object =~ /^(.+)\.([0-9A-F]{12,14}):([0-9]{1,2})$/ || $object =~ /^(.+)\.(OL-.+):([0-9]{1,2})$/ || $object =~ /^(.+)\.(BidCoS-RF):([0-9]{1,2})$/) { # # Interface.Address:Channel [26=11010] # $f = $HMCCU_FLAGS_IAC | ($flags & $HMCCU_FLAG_DATAPOINT); ($i, $a, $c, $d) = ($1, $2, $3, $flags & $HMCCU_FLAG_DATAPOINT ? '.*' : ''); } elsif ($object =~ /^([\*]*[A-Z]{3}[0-9]{7}):([0-9]{1,2})\.(.+)$/ || $object =~ /^([0-9A-F]{12,14}):([0-9]{1,2})\.(.+)$/ || $object =~ /^(OL-.+):([0-9]{1,2})\.(.+)$/ || $object =~ /^(BidCoS-RF):([0-9]{1,2})\.(.+)$/) { # # Address:Channel.Datapoint [14=01110] # $f = $HMCCU_FLAGS_ACD; ($a, $c, $d) = ($1, $2, $3); } elsif ($object =~ /^([\*]*[A-Z]{3}[0-9]{7}):([0-9]{1,2})$/ || $object =~ /^([0-9A-Z]{12,14}):([0-9]{1,2})$/ || $object =~ /^(OL-.+):([0-9]{1,2})$/ || $object =~ /^(BidCoS-RF):([0-9]{1,2})$/) { # # Address:Channel [10=01010] # $f = $HMCCU_FLAGS_AC | ($flags & $HMCCU_FLAG_DATAPOINT); ($a, $c, $d) = ($1, $2, $flags & $HMCCU_FLAG_DATAPOINT ? '.*' : ''); } elsif ($object =~ /^([\*]*[A-Z]{3}[0-9]{7})$/ || $object =~ /^([0-9A-Z]{12,14})$/ || $object =~ /^(OL-.+)$/ || $object eq 'BidCoS') { # # Address # $f = $HMCCU_FLAG_ADDRESS; $a = $1; } elsif ($object =~ /^(.+?)\.([A-Z_]+)$/) { # # Name.Datapoint # $f = $HMCCU_FLAGS_ND; ($n, $d) = ($1, $2); } elsif ($object =~ /^.+$/) { # # Name [1=00001] # $f = $HMCCU_FLAG_NAME | ($flags & $HMCCU_FLAG_DATAPOINT); ($n, $d) = ($object, $flags & $HMCCU_FLAG_DATAPOINT ? '.*' : ''); } else { $f = 0; } # Restore external address (i.e. HVL device address) $a = $extaddr if ($a eq $HMCCU_EXT_ADDR); # Check if name is a valid channel name if ($f & $HMCCU_FLAG_NAME) { my ($add, $chn) = HMCCU_GetAddress ($hash, $n, '', ''); if ($chn ne '') { $f = $f | $HMCCU_FLAG_CHANNEL; } if ($flags & $HMCCU_FLAG_FULLADDR) { ($i, $a, $c) = (HMCCU_GetDeviceInterface ($hash, $add, $defInterface), $add, $chn); $f |= $HMCCU_FLAG_INTERFACE; $f |= $HMCCU_FLAG_ADDRESS if ($add ne ''); $f |= $HMCCU_FLAG_CHANNEL if ($chn ne ''); } } elsif ($f & $HMCCU_FLAG_ADDRESS && $i eq '' && ($flags & $HMCCU_FLAG_FULLADDR || $flags & $HMCCU_FLAG_INTERFACE)) { $i = HMCCU_GetDeviceInterface ($hash, $a, $defInterface); $f |= $HMCCU_FLAG_INTERFACE; } return ($i, $a, $c, $d, $n, $f); } ###################################################################### # Filter reading by datapoint and optionally by channel name or # channel address. # Parameter channel can be a channel name or a channel address without # interface specification. # Filter rule syntax is either: # [N:]{Channel-Number|Channel-Name-Expr}!Datapoint-Expr # or # [N:][Channel-Number.]Datapoint-Expr # Multiple filter rules must be separated by ; ###################################################################### sub HMCCU_FilterReading ($$$;$) { my ($hash, $chn, $dpt, $ps) = @_; my $name = $hash->{NAME}; my $fnc = "FilterReading"; my $ioHash = HMCCU_GetHash ($hash); return 1 if (!defined($ioHash)); if (defined($ps)) { $ps = 'LINK' if ($ps =~ /^LINK\..+$/); } else { $ps = 'VALUES'; } my $flags = HMCCU_GetFlags ($name); my @flagList = $flags =~ /show(Master|Link|Device)Readings/g; push (@flagList, 'VALUES'); my $dispFlags = uc(join(',', @flagList)); my $rf = AttrVal ($name, 'ccureadingfilter', '.*'); my $chnnam = ''; my ($devadd, $chnnum) = HMCCU_SplitChnAddr ($chn); if ($chnnum ne 'd') { # Get channel name and channel number $chnnam = HMCCU_GetChannelName ($ioHash, $chn, ''); if ($chnnam eq '') { ($devadd, $chnnum) = HMCCU_GetAddress ($hash, $chn, '', ''); $chnnam = $chn; } } HMCCU_Trace ($hash, 2, $fnc, "chn=$chn, chnnam=$chnnam chnnum=$chnnum dpt=$dpt, rules=$rf dispFlags=$dispFlags ps=$ps"); return 0 if ($dispFlags !~ /DEVICE/ && ($chnnum eq 'd' || $chnnum eq '0')); return 0 if ($dispFlags !~ /$ps/); foreach my $r (split (';', $rf)) { my $rm = 1; my $cn = ''; # Negative filter if ($r =~ /^N:/) { $rm = 0; $r =~ s/^N://; } # Get filter criteria my ($c, $f) = split ("!", $r); if (defined ($f)) { next if ($c eq '' || $chnnam eq '' || $chnnum eq ''); $cn = $c if ($c =~ /^([0-9]{1,2})$/); } else { $c = ''; if ($r =~ /^([0-9]{1,2})\.(.+)$/) { $cn = $1; $f = $2; } else { $cn = ''; $f = $r; } } HMCCU_Trace ($hash, 2, undef, " check rm=$rm f=$f cn=$cn c=$c"); # Positive filter return 1 if ( $rm && ( ( ($cn ne '' && "$chnnum" eq "$cn") || ($c ne '' && $chnnam =~ /$c/) || ($cn eq '' && $c eq '') || ($chnnum eq 'd') ) && $dpt =~ /$f/ ) ); # Negative filter return 1 if ( !$rm && ( ($cn ne '' && "$chnnum" ne "$cn") || ($c ne '' && $chnnam !~ /$c/) || $dpt !~ /$f/ ) ); HMCCU_Trace ($hash, 2, undef, " check result false"); } return 0; } ###################################################################### # Build reading name # # Parameters: # # Interface,Address,ChannelNo,Datapoint,ChannelNam,Format,Paramset # Format := { name[lc] | datapoint[lc] | address[lc] | formatStr } # formatStr := Any text containing at least one format pattern # pattern := { %a, %c, %n, %d, %A, %C, %N, %D } # # Valid combinations: # # ChannelName,Datapoint # Address,Datapoint # Address,ChannelNo,Datapoint # # Reading names can be modified or new readings can be added by # setting attribut ccureadingname. # Returns list of readings names. Return empty list on error. ###################################################################### sub HMCCU_GetReadingName ($$$$$$$;$) { my ($hash, $i, $a, $c, $d, $n, $rf, $ps) = @_; my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my %prefix = ( 'MASTER' => 'R-', 'LINK' => 'L-', 'VALUES' => '', 'SERVICE' => 'S-', 'PEER' => 'P-', 'DEVICE' => 'D-' ); my $ioHash = HMCCU_GetHash ($hash); return () if (!defined($ioHash) || !defined($d) || $d eq ''); $c = '' if (!defined ($c)); $i = '' if (!defined ($i)); my @rcv = (); if (defined($ps)) { if ($ps =~ /^LINK\.(.+)$/) { @rcv = HMCCU_GetDeviceIdentifier ($ioHash, $1, undef); $ps = 'LINK'; } } else { $ps = 'VALUES'; } my $rn = ''; my @rnlist; # Log3 $name, 1, "HMCCU: ChannelNo undefined: Addr=".$a if (!defined ($c)); $rf = HMCCU_GetAttrReadingFormat ($hash, $ioHash) if (!defined ($rf)); my $sr = 'LEVEL$:pct;SET_TEMPERATURE$:desired-temp;ACTUAL_TEMPERATURE$measured-temp;'. 'SET_POINT_TEMPERATURE$:desired-temp'; my $asr = AttrVal ($name, 'ccureadingname', ''); $sr .= ';'.$asr if ($asr ne ''); # Complete missing values if ($n eq '' && $a ne '') { $n = ($c ne '') ? HMCCU_GetChannelName ($ioHash, $a.':'.$c, '') : HMCCU_GetDeviceName ($ioHash, $a, ''); } elsif ($n ne '' && $a eq '') { ($a, $c) = HMCCU_GetAddress ($ioHash, $n, '', ''); } if ($i eq '' && $a ne '') { $i = HMCCU_GetDeviceInterface ($ioHash, $a, ''); } # Get reading prefix definitions $ps = 'DEVICE' if ($c eq '0' || $c eq 'd'); my $readingPrefix = HMCCU_GetAttribute ($ioHash, $hash, 'ccuReadingPrefix', ''); foreach my $pd (split (',', $readingPrefix)) { my ($rSet, $rPre) = split (':', $pd); $prefix{$rSet} = $rPre if (defined($rPre) && exists($prefix{$rSet})); } my $rpf = exists($prefix{$ps}) ? $prefix{$ps} : ''; if ($rf eq 'datapoint' || $rf =~ /^datapoint(lc|uc)$/) { $rn = $c ne '' && $type ne 'HMCCUCHN' ? $c.'.'.$d : $d; } elsif ($rf eq 'name' || $rf =~ /^name(lc|uc)$/) { return () if ($n eq ''); $rn = $n.'.'.$d; } elsif ($rf eq 'address' || $rf =~ /^address(lc|uc)$/) { return () if ($a eq ''); my $t = $a; $t = $i.'.'.$t if ($i ne ''); $t = $t.'.'.$c if ($c ne ''); $rn = $t.'.'.$d; } elsif ($rf =~ /\%/) { $rn = $1; if ($a ne '') { $rn =~ s/\%a/lc($a)/ge; $rn =~ s/\%A/uc($a)/ge; } if ($n ne '') { $rn =~ s/\%n/lc($n)/ge; $rn =~ s/\%N/uc($n)/ge; } if ($c ne '') { $rn =~ s/\%c/lc($c)/ge; $rn =~ s/\%C/uc($c)/ge; } $rn =~ s/\%d/lc($d)/ge; $rn =~ s/\%D/uc($d)/ge; } if (scalar (@rcv) > 0) { push (@rnlist, map { $rpf.$_.'-'.$rn } @rcv); } else { push (@rnlist, $rpf.$rn); } # Rename and/or add reading names my @rules = split (';', $sr); foreach my $rr (@rules) { my ($rold, $rnew) = split (':', $rr); next if (!defined ($rnew)); my @rnewList = split (',', $rnew); next if (scalar (@rnewList) < 1); if ($rnlist[0] =~ /$rold/) { foreach my $rnew (@rnewList) { if ($rnew =~ /^\+(.+)$/) { my $radd = $1; $radd =~ s/$rold/$radd/; push (@rnlist, $radd); } else { $rnlist[0] =~ s/$rold/$rnew/; last; } } } } # Convert to lower or upper case $rnlist[0] = lc($rnlist[0]) if ($rf =~ /^(datapoint|name|address)lc$/); $rnlist[0] = uc($rnlist[0]) if ($rf =~ /^(datapoint|name|address)uc$/); # Return array of corrected reading names return map { HMCCU_CorrectName ($_) } @rnlist; } ###################################################################### # Format reading value depending on attribute stripnumber. # Syntax of attribute stripnumber: # [datapoint-expr!]format[;...] # Valid formats: # 0 = Remove all digits # 1 = Preserve 1 digit # 2 = Remove trailing zeroes # -n = Round value to specified number of digits (-0 is allowed) # %f = Format for numbers. String suffix is allowed. ###################################################################### sub HMCCU_FormatReadingValue ($$$) { my ($hash, $value, $dpt) = @_; my $name = $hash->{NAME}; my $fnc = "FormatReadingValue"; if (!defined($value)) { HMCCU_Trace ($hash, 2, $fnc, "Value undefined for datapoint $dpt"); return $value; } my $stripnumber = HMCCU_GetAttrStripNumber ($hash); if ($stripnumber ne 'null' && HMCCU_IsFltNum ($value)) { my $isint = HMCCU_IsIntNum ($value) ? 2 : 0; foreach my $sr (split (';', $stripnumber)) { my ($d, $s) = split ('!', $sr); if (defined ($s)) { next if ($d eq '' || $dpt !~ /$d/); } else { $s = $sr; } return HMCCU_StripNumber ($value, $s, $isint | 1); } HMCCU_Trace ($hash, 2, $fnc, "sn = $stripnumber, dpt=$dpt, isint=$isint, value $value not changed"); } else { my $h = uc(unpack "H*", $value); HMCCU_Trace ($hash, 2, $fnc, "sn = $stripnumber, Value $value 0x$h not changed"); } return $value; } ###################################################################### # Format number # Parameter: # $value - Any value (non numeric values will be ignored) # $strip - # $number - 0=detect, 1=number, 2=integer ###################################################################### sub HMCCU_StripNumber ($$;$) { my ($value, $strip, $number) = @_; $number //= 0; if ($number & 1 || $value =~ /^[+-]?\d*\.?\d+(?:(?:e|E)\d+)?$/) { my $isint = ($number & 2 || $value =~ /^[+-]?[0-9]+$/) ? 1 : 0; if ($strip eq '0' && !$isint) { return sprintf ("%d", $value); } elsif ($strip eq '1' && !$isint) { return sprintf ("%.1f", $value); } elsif ($strip eq '2' && !$isint) { return sprintf ("%g", $value); } elsif ($strip =~ /^-([0-9])$/ && !$isint) { my $f = '%.'.$1.'f'; return sprintf ($f, $value); } elsif ($strip =~ /^%.+$/) { return sprintf ($strip, $value); } } return $value; } ###################################################################### # Log message if trace flag is set. # Will output multiple log file entries if parameter msg is separated # by <br> ###################################################################### sub HMCCU_Trace ($$$$) { my ($hash, $level, $fnc, $msg) = @_; my $name = $hash->{NAME}; my $type = $hash->{TYPE}; return if (!HMCCU_IsFlag ($name, "trace")); foreach my $m (split ("<br>", $msg)) { $m = "[$name] $fnc: $m" if (defined ($fnc) && $fnc ne ''); Log3 $name, $level, "$type: $m"; } } ###################################################################### # Log message with module type, device name and process id. # Return parameter rc or 0. # Parameter source can be a device hash reference, a string reference # or a string. ###################################################################### sub HMCCU_Log ($$$;$) { my ($source, $level, $msg, $rc) = @_; $rc //= 0; my $r = ref($source); my $pid = $$; my $name = "n/a"; my $type = "n/a"; if ($r eq 'HASH') { $name = $source->{NAME} if (exists ($source->{NAME})); $type = $source->{TYPE} if (exists ($source->{TYPE})); } elsif ($r eq 'SCALAR') { $name = $$source; $type = $defs{$name}->{TYPE} if (exists ($defs{$name})); } else { $name = $source; $type = $defs{$name}->{TYPE} if (exists ($defs{$name})); } Log3 $name, $level, "$type: [$name : $pid] $msg"; return $rc; } ###################################################################### # Log message and return message preceded by string "ERROR: ". ###################################################################### sub HMCCU_LogError ($$$) { my ($hash, $level, $msg) = @_; HMCCU_Log ($hash, $level, $msg, undef); return "ERROR: $msg"; } ###################################################################### # Set error state and write log file message # Parameter text can be an error code (integer <= 0) or an error text. # If text is 0 or 'OK' call HMCCU_SetState which returns undef. # Otherwise error message is returned. # Parameter addinfo is optional. ###################################################################### sub HMCCU_SetError ($@) { my ($hash, $text, $addinfo) = @_; my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my $msg; my %errlist = ( -1 => 'Invalid device/channel name or address', -2 => 'Execution of CCU script or command failed', -3 => 'Cannot detect IO device', -4 => 'Device deleted in CCU', -5 => 'No response from CCU', -6 => 'Update of readings disabled. Remove ccuflag noReadings', -7 => 'Invalid channel number', -8 => 'Invalid datapoint', -9 => 'Interface does not support RPC calls', -10 => 'No readable datapoints found', -11 => 'No state channel defined', -12 => 'No control channel defined', -13 => 'No state datapoint defined', -14 => 'No control datapoint defined', -15 => 'No state values defined', -16 => 'Cannot open file', -17 => 'Cannot detect or create external RPC device', -18 => 'Type of system variable not supported', -19 => 'Device not initialized', -20 => 'Invalid or unknown device interface', -21 => 'Device disabled' ); if ($text ne 'OK' && $text ne '0') { $msg = exists ($errlist{$text}) ? $errlist{$text} : $text; $msg = $type.": ".$name." ". $msg; if (defined ($addinfo) && $addinfo ne '') { $msg .= ". $addinfo"; } HMCCU_Log ($hash, 1, $msg); return HMCCU_SetState ($hash, "Error", $msg); } else { return HMCCU_SetState ($hash, "OK"); } } ###################################################################### # Set state of device if attribute ccuflags = ackState # Return undef or $retval ###################################################################### sub HMCCU_SetState ($@) { my ($hash, $text, $retval) = @_; my $name = $hash->{NAME}; my $ccuflags = HMCCU_GetFlags ($name); $ccuflags .= ',ackState' if ($hash->{TYPE} eq 'HMCCU' && $ccuflags !~ /ackState/); if (defined ($hash) && defined ($text) && $ccuflags =~ /ackState/) { readingsSingleUpdate ($hash, 'state', $text, 1) if (ReadingsVal ($name, 'state', '') ne $text); } return $retval; } ###################################################################### # Set state of RPC server. Update all client devices if overall state # is 'running'. # Parameters iface and msg are optional. If iface is set function # was called by HMCCURPCPROC device. ###################################################################### sub HMCCU_SetRPCState ($@) { my ($hash, $state, $iface, $msg) = @_; my $name = $hash->{NAME}; my $ccuflags = HMCCU_GetFlags ($name); my $filter; my $rpcstate = $state; if (defined ($iface)) { # Set interface state my ($ifname) = HMCCU_GetRPCServerInfo ($hash, $iface, 'name'); $hash->{hmccu}{interfaces}{$ifname}{state} = $state if (defined ($ifname)); # Count number of processes in state running, error or inactive # Prepare filter for updating client devices my %stc = ('running' => 0, 'error' => 0, 'inactive' => 0); my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $i (@iflist) { my $st = $hash->{hmccu}{interfaces}{$i}{state}; $stc{$st}++ if (exists ($stc{$st})); if ($hash->{hmccu}{interfaces}{$i}{manager} eq 'HMCCU' && $ccuflags !~ /noInitialUpdate/) { my $rpcFlags = AttrVal ($hash->{hmccu}{interfaces}{$i}{device}, 'ccuflags', 'null'); if ($rpcFlags !~ /noInitialUpdate/) { $filter = defined ($filter) ? "$filter|$i" : $i; } } } # Determine overall process state my $rpcstate = 'null'; $rpcstate = 'running' if ($stc{"running"} == scalar (@iflist)); $rpcstate = 'inactive' if ($stc{"inactive"} == scalar (@iflist)); $rpcstate = 'error' if ($stc{"error"} == scalar (@iflist)); if ($rpcstate =~ /^(running|inactive|error)$/) { if ($rpcstate ne $hash->{RPCState}) { $hash->{RPCState} = $rpcstate; readingsSingleUpdate ($hash, "rpcstate", $rpcstate, 1); HMCCU_Log ($hash, 4, "Set rpcstate to $rpcstate"); HMCCU_Log ($hash, 1, $msg, undef) if (defined ($msg)); HMCCU_Log ($hash, 1, "All RPC servers $rpcstate"); DoTrigger ($name, "RPC server $rpcstate"); if ($rpcstate eq 'running' && defined ($filter)) { HMCCU_UpdateClients ($hash, '.*', 'Value', 0, $filter, 1); } } } } # Set I/O device state if ($rpcstate eq 'running' || $rpcstate eq 'inactive') { HMCCU_SetState ($hash, 'OK'); } elsif ($rpcstate eq 'error') { HMCCU_SetState ($hash, 'error'); } else { HMCCU_SetState ($hash, 'busy'); } return undef; } ###################################################################### # Substitute first occurrence of regular expression or fixed string. # Floating point values are ignored without datapoint specification. # Integer values are compared with complete value. # $hashOrRule - # $mode - 0=Substitute regular expression, 1=Substitute text # $chn - A channel number. Ignored if $dpt contains a Channel # number. # $dpt - Datapoint name. If it contains a channel number, it # overrides parameter $chn # $type - Role of a channel, i.e. SHUTTER_CONTACT (optional). # $devDesc - Device description reference (optional). ###################################################################### sub HMCCU_Substitute ($$$$$;$$) { my ($value, $hashOrRule, $mode, $chn, $dpt, $type, $devDesc) = @_; my $substrule = ''; my $ioHash; if (defined($hashOrRule)) { if (ref($hashOrRule) eq 'HASH') { $ioHash = HMCCU_GetHash ($hashOrRule); my $substitute = HMCCU_GetAttrSubstitute ($hashOrRule, $ioHash) if (defined($ioHash)); } else { $substrule = $hashOrRule; } } my $rc = 0; my $newvalue; # return $value if (!defined ($substrule) || $substrule eq ''); # Remove channel number from datapoint if specified if ($dpt =~ /^([0-9]{1,2})\.(.+)$/) { ($chn, $dpt) = ($1, $2); } my @rulelist = split (';', $substrule); foreach my $rule (@rulelist) { my @ruletoks = split ('!', $rule); if (scalar(@ruletoks) == 2 && $dpt ne '' && $mode == 0) { my ($r, $f) = split (':', $ruletoks[0], 2); if (!defined($f)) { $f = $r; $r = undef; } if (!defined($r) || (defined($type) && $r eq $type)) { my @dptlist = split (',', $f); foreach my $d (@dptlist) { my $c = -1; if ($d =~ /^([0-9]{1,2})\.(.+)$/) { ($c, $d) = ($1, $2); } if ($d eq $dpt && ($c == -1 || !defined($chn) || $c == $chn)) { ($rc, $newvalue) = HMCCU_SubstRule ($value, $ruletoks[1], $mode); return $newvalue; } } } } elsif (scalar(@ruletoks) == 1) { return $value if ($value !~ /^[+-]?\d+$/ && $value =~ /^[+-]?\d*\.?\d+(?:(?:e|E)\d+)?$/); ($rc, $newvalue) = HMCCU_SubstRule ($value, $ruletoks[0], $mode); return $newvalue if ($rc == 1); } } # Original value not modified by rules. Use default conversion depending on type/role # Default conversion can be overriden by attribute ccudef-substitute in I/O device # Substitute enumerations if (defined($devDesc) && defined($ioHash)) { my $paramDef = HMCCU_GetParamDef ($ioHash, $devDesc, 'VALUES', $dpt); if (!defined($paramDef) && defined($paramDef->{TYPE}) && $paramDef->{TYPE} eq 'ENUM' && defined($paramDef->{VALUE_LIST})) { my $i = defined($paramDef->{MIN}) ? $paramDef->{MIN} : 0; if ($mode) { my %enumVals = map { $_ => $i++ } split(',', $paramDef->{VALUE_LIST}); return $enumVals{$value} if (exists($enumVals{$value})); } else { my @enumList = split(',', $paramDef->{VALUE_LIST}); my $idx = $value-$i; return $enumList[$idx] if ($idx >= 0 && $idx < scalar(@enumList)); } } } if ((!defined($type) || $type eq '') && defined($devDesc) && defined($devDesc->{INDEX})) { $type = $devDesc->{TYPE}; } $type = 'DEFAULT' if (!defined($type) || $type eq ''); if (exists($HMCCU_CONVERSIONS->{$type}{$dpt}{$value})) { return $HMCCU_CONVERSIONS->{$type}{$dpt}{$value}; } elsif (exists($HMCCU_CONVERSIONS->{DEFAULT}{$dpt}{$value})) { return $HMCCU_CONVERSIONS->{DEFAULT}{$dpt}{$value}; } return $value; } ###################################################################### # Execute substitution list. # Syntax for single substitution: {#n-n|regexp|text}:newtext # mode=0: Substitute regular expression # mode=1: Substitute text (for setting statevals) # newtext can contain ':'. Parameter ${value} in newtext is # substituted by original value. # Return (status, value) # status=1: value = substituted value # status=0: value = original value ###################################################################### sub HMCCU_SubstRule ($$$) { my ($value, $substitutes, $mode) = @_; my $rc = 0; $substitutes =~ s/\$\{value\}/$value/g; my @sub_list = split /[, ]/,$substitutes; foreach my $s (@sub_list) { my ($regexp, $text) = split /:/,$s,2; next if (!defined ($regexp) || !defined($text)); if ($regexp =~ /^#([+-]?\d*\.?\d+?)\-([+-]?\d*\.?\d+?)$/) { my ($mi, $ma) = ($1, $2); if ($value =~ /^\d*\.?\d+?$/ && $value >= $mi && $value <= $ma) { $value = $text; $rc = 1; } } elsif ($mode == 0 && $value =~ /$regexp/ && $value !~ /^[+-]?\d+$/) { my $x = eval { $value =~ s/$regexp/$text/ }; $rc = 1 if (defined ($x)); last; } elsif (($mode == 1 || $value =~ /^[+-]?\d+$/) && $value =~ /^$regexp$/) { my $x = eval { $value =~ s/^$regexp$/$text/ }; $rc = 1 if (defined ($x)); last; } } return ($rc, $value); } ###################################################################### # Substitute datapoint variables in string by datapoint value. The # value depends on the character preceding the variable name. Syntax # of variable names is: # {$|$$|%|%%}{[cn.]Name} # {$|$$|%|%%}[cn.]Name # % = Original / raw value # %% = Previous original / raw value # $ = Converted / formatted value # $$ = Previous converted / formatted value # Parameter dplist is a comma separated list of value keys in format # [address:]Channel.Datapoint. ###################################################################### sub HMCCU_SubstVariables ($$$) { my ($clhash, $text, $dplist) = @_; my $fnc = 'HMCCU_SubstVariables'; my @varlist = defined($dplist) ? split (',', $dplist) : keys %{$clhash->{hmccu}{dp}}; HMCCU_Trace ($clhash, 2, $fnc, "text=$text"); # Substitute datapoint variables by value foreach my $dp (@varlist) { my ($chn, $dpt) = split (/\./, $dp); HMCCU_Trace ($clhash, 2, $fnc, "var=$dp"); if (defined ($clhash->{hmccu}{dp}{$dp}{VALUES}{OSVAL})) { $text =~ s/\$\$\{?$dp\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{OSVAL}/g; $text =~ s/\$\$\{?$dpt\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{OSVAL}/g; } if (defined ($clhash->{hmccu}{dp}{$dp}{VALUES}{SVAL})) { $text =~ s/\$\{?$dp\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{SVAL}/g; $text =~ s/\$\{?$dpt\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{SVAL}/g; } if (defined ($clhash->{hmccu}{dp}{$dp}{VALUES}{OVAL})) { $text =~ s/\%\%\{?$dp\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{OVAL}/g; $text =~ s/\%\%\{?$dpt\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{OVAL}/g; } if (defined ($clhash->{hmccu}{dp}{$dp}{VALUES}{VAL})) { $text =~ s/\%\{?$dp\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{VAL}/g; $text =~ s/\%\{?$dpt\}?/$clhash->{hmccu}{dp}{$dp}{VALUES}{VAL}/g; $text =~ s/$dp/$clhash->{hmccu}{dp}{$dp}{VALUES}{VAL}/g; } } HMCCU_Trace ($clhash, 2, $fnc, "text=$text"); return $text; } ###################################################################### # Update all datapoint/readings of all client devices matching # specified regular expression. Update will fail if device is deleted # or disabled or if ccuflag noReadings is set. # If fromccu is 1 regular expression is compared to CCU device name. # Otherwise it's compared to FHEM device name. If ifname is specified # only devices belonging to interface ifname are updated. ###################################################################### sub HMCCU_UpdateClients ($$$$$$) { my ($hash, $devexp, $ccuget, $fromccu, $ifname, $nonBlock) = @_; my $fhname = $hash->{NAME}; my $c = 0; my $dc = 0; my $filter = "ccudevstate=active"; $filter .= ",ccuif=$ifname" if (defined ($ifname)); $ccuget = AttrVal ($fhname, 'ccuget', 'Value') if ($ccuget eq 'Attr'); my $list = ''; if ($fromccu) { foreach my $name (sort keys %{$hash->{hmccu}{adr}}) { next if ($name !~ /$devexp/ || !($hash->{hmccu}{adr}{$name}{valid})); my @devlist = HMCCU_FindClientDevices ($hash, '(HMCCUDEV|HMCCUCHN)', undef, $filter); $dc += scalar(@devlist); foreach my $d (@devlist) { my $ch = $defs{$d}; next if ( !defined ($ch->{IODev}) || !defined ($ch->{ccuaddr}) || $ch->{ccuaddr} ne $hash->{hmccu}{adr}{$name}{address} || $ch->{ccuif} eq 'fhem' || !HMCCU_IsValidDeviceOrChannel ($hash, $ch->{ccuaddr}, $HMCCU_FL_ADDRESS)); $list .= ($list eq '') ? $name : ",$name"; $c++; } } } else { my @devlist = HMCCU_FindClientDevices ($hash, "(HMCCUDEV|HMCCUCHN)", $devexp, $filter); $dc = scalar(@devlist); foreach my $d (@devlist) { my $ch = $defs{$d}; next if ( !defined ($ch->{IODev}) || !defined ($ch->{ccuaddr}) || $ch->{ccuif} eq 'fhem' || !HMCCU_IsValidDeviceOrChannel ($hash, $ch->{ccuaddr}, $HMCCU_FL_ADDRESS)); my $name = HMCCU_GetDeviceName ($hash, $ch->{ccuaddr}, ''); next if ($name eq ''); $list .= ($list eq '') ? $name : ",$name"; $c++; } } return HMCCU_Log ($hash, 2, "HMCCU: Found no devices to update") if ($c == 0); HMCCU_Log ($hash, 2, "Updating $c of $dc client devices matching devexp=$devexp filter=$filter"); if (HMCCU_IsFlag ($fhname, 'nonBlocking') || $nonBlock) { HMCCU_HMScriptExt ($hash, '!GetDatapointsByDevice', { list => $list, ccuget => $ccuget }, \&HMCCU_UpdateCB, { logCount => 1, devCount => $c }); return 1; } else { my $response = HMCCU_HMScriptExt ($hash, '!GetDatapointsByDevice', { list => $list, ccuget => $ccuget }, undef, undef); return -2 if ($response eq '' || $response =~ /^ERROR:.*/); HMCCU_UpdateCB ({ ioHash => $hash, logCount => 1, devCount => $c }, undef, $response); return 1; } } ########################################################################## # Create virtual device in internal device tables. # If sourceAddr is specified, parameter newType will be ignored. # Return 0 on success or error code: # 1 = newType not defined # 2 = Device with newType not found in internal tables ########################################################################## sub HMCCU_CreateDevice ($$$$$) { my ($hash, $newAddr, $newName, $newType, $sourceAddr) = @_; my %object; if (!defined ($sourceAddr)) { # Search for type in device table return 1 if (!defined ($newType)); foreach my $da (keys %{$hash->{hmccu}{dev}}) { if ($hash->{hmccu}{dev}{$da}{type} eq $newType) { $sourceAddr = $da; last; } } return 2 if (!defined ($sourceAddr)); } else { $newType = $hash->{hmccu}{dev}{$sourceAddr}{type}; } # Device attributes $object{$newAddr}{flag} = 'N'; $object{$newAddr}{addtype} = 'dev'; $object{$newAddr}{channels} = $hash->{hmccu}{dev}{$sourceAddr}{channels}; $object{$newAddr}{name} = $newName; $object{$newAddr}{type} = $newType; $object{$newAddr}{interface} = 'fhem'; $object{$newAddr}{direction} = 0; # Channel attributes for (my $chn=0; $chn<$object{$newAddr}{channels}; $chn++) { my $ca = "$newAddr:$chn"; $object{$ca}{flag} = 'N'; $object{$ca}{addtype} = 'chn'; $object{$ca}{channels} = 1; $object{$ca}{name} = "$newName:$chn"; $object{$ca}{direction} = $hash->{hmccu}{dev}{"$sourceAddr:$chn"}{direction}; $object{$ca}{rxmode} = $hash->{hmccu}{dev}{"$sourceAddr:$chn"}{rxmode}; $object{$ca}{usetype} = $hash->{hmccu}{dev}{"$sourceAddr:$chn"}{usetype}; } HMCCU_UpdateDeviceTable ($hash, \%object); return 0; } ########################################################################## # Remove virtual device from internal device tables. ########################################################################## sub HMCCU_DeleteDevice ($) { my ($clthash) = @_; my $name = $clthash->{NAME}; return if (!exists ($clthash->{IODev}) || !exists ($clthash->{ccuif}) || !exists ($clthash->{ccuaddr})); return if ($clthash->{ccuif} ne 'fhem'); my $hmccu_hash = $clthash->{IODev}; my $devaddr = $clthash->{ccuaddr}; my $channels = exists ($clthash->{hmccu}{channels}) ? $clthash->{hmccu}{channels} : 0; # Delete device address entries if (exists ($hmccu_hash->{hmccu}{dev}{$devaddr})) { delete $hmccu_hash->{hmccu}{dev}{$devaddr}; } # Delete channel address and name entries for (my $chn=0; $chn<=$channels; $chn++) { if (exists ($hmccu_hash->{hmccu}{dev}{"$devaddr:$chn"})) { delete $hmccu_hash->{hmccu}{dev}{"$devaddr:$chn"}; } if (exists ($hmccu_hash->{hmccu}{adr}{"$name:$chn"})) { delete $hmccu_hash->{hmccu}{adr}{"$name:$chn"}; } } # Delete device name entries if (exists ($hmccu_hash->{hmccu}{adr}{$name})) { delete $hmccu_hash->{hmccu}{adr}{$name}; } } ########################################################################## # Update parameters in internal device tables and client devices. # Parameter devices is a hash reference with following keys: # {address} # {address}{flag} := [N, D, R] (N=New, D=Deleted, R=Renamed) # {address}{addtype} := [chn, dev] for channel or device # {address}{channels} := Number of channels # {address}{name} := Device or channel name # {address}{type} := Homematic device type # {address}{usetype} := Usage type # {address}{interface} := Device interface ID # {address}{firmware} := Firmware version of device # {address}{version} := Version of RPC device description # {address}{rxmode} := Transmit mode # {address}{direction} := Channel direction: 0=none, 1=sensor, 2=actor # {address}{paramsets} := Comma separated list of supported paramsets # {address}{sourceroles} := Link sender roles # {address}{targetroles} := Link receiver roles # {address}{children} := Comma separated list of channels # {address}{parent} := Parent device # {address}{aes} := AES flag # If flag is 'D' the hash must contain an entry for the device address # and for each channel address. ########################################################################## sub HMCCU_UpdateDeviceTable ($$) { my ($hash, $devices) = @_; my $name = $hash->{NAME}; my $devcount = 0; my $chncount = 0; # Update internal device table foreach my $da (keys %{$devices}) { my $nm = $hash->{hmccu}{dev}{$da}{name} if (defined ($hash->{hmccu}{dev}{$da}{name})); $nm = $devices->{$da}{name} if (defined ($devices->{$da}{name})); if ($devices->{$da}{flag} eq 'N' && defined ($nm)) { my $at = ''; if (defined ($devices->{$da}{addtype})) { $at = $devices->{$da}{addtype}; } else { $at = 'chn' if (HMCCU_IsChnAddr ($da, 0)); $at = 'dev' if (HMCCU_IsDevAddr ($da, 0)); } if ($at eq '') { HMCCU_Log ($hash, 2, "Cannot detect type of address $da. Ignored."); next; } HMCCU_Log ($hash, 2, "Duplicate name for device/channel $nm address=$da in CCU.") if (exists ($hash->{hmccu}{adr}{$nm}) && $at ne $hash->{hmccu}{adr}{$nm}{addtype}); # Updated or new device/channel $hash->{hmccu}{dev}{$da}{addtype} = $at; $hash->{hmccu}{dev}{$da}{valid} = 1; foreach my $k ('channels', 'type', 'usetype', 'interface', 'version', 'firmware', 'rxmode', 'direction', 'paramsets', 'sourceroles', 'targetroles', 'children', 'parent', 'aes') { $hash->{hmccu}{dev}{$da}{$k} = $devices->{$da}{$k} if (defined ($devices->{$da}{$k})); } if (defined ($nm)) { $hash->{hmccu}{dev}{$da}{name} = $nm; $hash->{hmccu}{adr}{$nm}{address} = $da; $hash->{hmccu}{adr}{$nm}{addtype} = $hash->{hmccu}{dev}{$da}{addtype}; $hash->{hmccu}{adr}{$nm}{valid} = 1; } } elsif ($devices->{$da}{flag} eq 'D' && exists ($hash->{hmccu}{dev}{$da})) { # Device deleted, mark as invalid $hash->{hmccu}{dev}{$da}{valid} = 0; $hash->{hmccu}{adr}{$nm}{valid} = 0 if (defined ($nm)); } elsif ($devices->{$da}{flag} eq 'R' && exists ($hash->{hmccu}{dev}{$da})) { # Device replaced, change address my $na = $devices->{hmccu}{newaddr}; # Copy device entries and delete old device entries foreach my $k (keys %{$hash->{hmccu}{dev}{$da}}) { $hash->{hmccu}{dev}{$na}{$k} = $hash->{hmccu}{dev}{$da}{$k}; } $hash->{hmccu}{adr}{$nm}{address} = $na; delete $hash->{hmccu}{dev}{$da}; } } # Delayed initialization if CCU was not ready during FHEM start if ($hash->{hmccu}{ccu}{delayed} == 1) { # Initialize interface and port lists HMCCU_AttrInterfacesPorts ($hash, 'rpcinterfaces', $attr{$name}{rpcinterfaces}) if (exists ($attr{$name}{rpcinterfaces})); HMCCU_AttrInterfacesPorts ($hash, 'rpcport', $attr{$name}{rpcport}) if (exists ($attr{$name}{rpcport})); # Initialize pending client devices my @cdev = HMCCU_FindClientDevices ($hash, '(HMCCUDEV|HMCCUCHN|HMCCURPCPROC)', undef, 'ccudevstate=pending'); if (scalar (@cdev) > 0) { HMCCU_Log ($hash, 2, "Initializing ".scalar(@cdev)." client devices in state 'pending'"); foreach my $cd (@cdev) { my $ch = $defs{$cd}; my $ct = $ch->{TYPE}; my $rc = 0; if ($ct eq 'HMCCUDEV') { $rc = HMCCUDEV_InitDevice ($hash, $ch); } elsif ($ct eq 'HMCCUCHN') { $rc = HMCCUCHN_InitDevice ($hash, $ch); } elsif ($ct eq 'HMCCURPCPROC') { $rc = HMCCURPCPROC_InitDevice ($hash, $ch); } HMCCU_Log ($hash, 3, "Can't initialize client device ".$ch->{NAME}) if ($rc > 0); } } $hash->{hmccu}{ccu}{delayed} = 0; } # Update client devices my @devlist = HMCCU_FindClientDevices ($hash, "(HMCCUDEV|HMCCUCHN)", undef, undef); foreach my $d (@devlist) { my $ch = $defs{$d}; my $ct = $ch->{TYPE}; next if (!exists ($ch->{ccuaddr})); my $ca = $ch->{ccuaddr}; next if (!exists ($devices->{$ca})); if ($devices->{$ca}{flag} eq 'N') { # New device or new device information $ch->{ccudevstate} = 'active'; if ($ct eq 'HMCCUDEV') { $ch->{ccutype} = $hash->{hmccu}{dev}{$ca}{type} if (defined ($hash->{hmccu}{dev}{$ca}{type})); $ch->{firmware} = $devices->{$ca}{firmware} if (defined ($devices->{$ca}{firmware})); } else { $ch->{chntype} = $devices->{$ca}{usetype} if (defined ($devices->{$ca}{usetype})); my ($add, $chn) = HMCCU_SplitChnAddr ($ca); $ch->{ccutype} = $devices->{$add}{type} if (defined ($devices->{$add}{type})); $ch->{firmware} = $devices->{$add}{firmware} if (defined ($devices->{$add}{firmware})); } $ch->{ccuname} = $hash->{hmccu}{dev}{$ca}{name} if (defined ($hash->{hmccu}{dev}{$ca}{name})); $ch->{ccuif} = $hash->{hmccu}{dev}{$ca}{interface} if (defined ($devices->{$ca}{interface})); $ch->{hmccu}{channels} = $hash->{hmccu}{dev}{$ca}{channels} if (defined ($hash->{hmccu}{dev}{$ca}{channels})); } elsif ($devices->{$ca}{flag} eq 'D') { # Deleted device $ch->{ccudevstate} = 'deleted'; } elsif ($devices->{$ca}{flag} eq 'R') { # Replaced device $ch->{ccuaddr} = $devices->{$ca}{newaddr}; } } # Update internals of I/O device foreach my $adr (keys %{$hash->{hmccu}{dev}}) { if (exists ($hash->{hmccu}{dev}{$adr}{addtype})) { $devcount++ if ($hash->{hmccu}{dev}{$adr}{addtype} eq 'dev'); $chncount++ if ($hash->{hmccu}{dev}{$adr}{addtype} eq 'chn'); } } $hash->{ccudevices} = $devcount; $hash->{ccuchannels} = $chncount; return ($devcount, $chncount); } ###################################################################### # Delete device table entries ###################################################################### sub HMCCU_ResetDeviceTables ($;$$) { my ($hash, $iface, $address) = @_; if (defined($iface)) { if (defined($address)) { $hash->{hmccu}{device}{$iface}{$address} = (); } else { $hash->{hmccu}{device}{$iface} = (); } } else { $hash->{hmccu}{device} = (); $hash->{hmccu}{model} = (); $hash->{hmccu}{snd} = (); $hash->{hmccu}{rcv} = (); } } ###################################################################### # Add new CCU or FHEM device or channel # If $devName is undef, a new device or channel will be added to IO # device if it doesn't exist. ###################################################################### sub HMCCU_AddDevice ($$$;$) { my ($ioHash, $iface, $address, $devName) = @_; if (defined($devName)) { # Device description must exist return if (!exists($ioHash->{hmccu}{device}{$iface}{$address})); my @devList = (); if (defined($ioHash->{hmccu}{device}{$iface}{$address}{_fhem})) { @devList = split (',', $ioHash->{hmccu}{device}{$iface}{$address}{_fhem}); # Prevent duplicate device names foreach my $d (@devList) { return if ($d eq $devName); } } push @devList, $devName; $ioHash->{hmccu}{device}{$iface}{$address}{_fhem} = join(',', @devList); } elsif (!exists($ioHash->{hmccu}{device}{$iface}{$address})) { my ($rpcDevice, undef) = HMCCU_GetRPCDevice ($ioHash, 0, $iface); if ($rpcDevice ne '') { my $rpcHash = $defs{$rpcDevice}; HMCCURPCPROC_GetDeviceDesc ($rpcHash, $address); HMCCURPCPROC_GetParamsetDesc ($rpcHash, $address); } } } ###################################################################### # Delete CCU or FHEM device or Channel # If $devName is undef, a device or a channel will be removed from # IO device. ###################################################################### sub HMCCU_RemoveDevice ($$$;$) { my ($ioHash, $iface, $address, $devName) = @_; return if (!exists($ioHash->{hmccu}{device}{$iface}{$address})); if (defined($devName)) { if (defined($ioHash->{hmccu}{device}{$iface}{$address}{_fhem})) { my @devList = grep { $_ ne $devName } split(',', $ioHash->{hmccu}{device}{$iface}{$address}{_fhem}); $ioHash->{hmccu}{device}{$iface}{$address}{_fhem} = scalar(@devList) > 0 ? join(',', @devList) : undef; } } elsif (exists($ioHash->{hmccu}{device}{$iface}{$address})) { delete $ioHash->{hmccu}{device}{$iface}{$address}; } } ###################################################################### # Update client device or channel # Store receiver, sender ###################################################################### sub HMCCU_UpdateDevice ($$) { my ($ioHash, $clHash) = @_; return if (!exists($clHash->{ccuif}) || !exists($clHash->{ccuaddr})); my $clType = $clHash->{TYPE}; my $address = $clHash->{ccuaddr}; my $iface = $clHash->{ccuif}; my ($da, $dc) = HMCCU_SplitChnAddr ($address); # Update the links if (exists($ioHash->{hmccu}{snd}{$iface}{$da})) { delete $clHash->{sender} if (exists($clHash->{sender})); delete $clHash->{receiver} if (exists($clHash->{receiver})); my @rcvList = (); my @sndList = (); foreach my $c (sort keys %{$ioHash->{hmccu}{snd}{$iface}{$da}}) { next if ($clType eq 'HMCCUCHN' && "$c" ne "$dc"); foreach my $r (keys %{$ioHash->{hmccu}{snd}{$iface}{$da}{$c}}) { my @rcvNames = HMCCU_GetDeviceIdentifier ($ioHash, $r, $iface); my $rcvFlags = HMCCU_FlagsToStr ('peer', 'FLAGS', $ioHash->{hmccu}{snd}{$iface}{$da}{$c}{$r}{FLAGS}, ','); push @rcvList, map { $_.($rcvFlags ne 'OK' ? " [".$rcvFlags."]" : '') } @rcvNames; } } foreach my $c (sort keys %{$ioHash->{hmccu}{rcv}{$iface}{$da}}) { next if ($clType eq 'HMCCUCHN' && "$c" ne "$dc"); foreach my $s (keys %{$ioHash->{hmccu}{rcv}{$iface}{$da}{$c}}) { my @sndNames = HMCCU_GetDeviceIdentifier ($ioHash, $s, $iface); my $sndFlags = HMCCU_FlagsToStr ('peer', 'FLAGS', $ioHash->{hmccu}{snd}{$iface}{$da}{$c}{$s}{FLAGS}, ','); push @sndList, map { $_.($sndFlags ne 'OK' ? " [".$sndFlags."]" : '') } @sndNames; } } $clHash->{sender} = join (',', @sndList) if (scalar(@sndList) > 0); $clHash->{receiver} = join (',', @rcvList) if (scalar(@rcvList) > 0); } } ###################################################################### # Update device roles ###################################################################### sub HMCCU_UpdateDeviceRoles ($$;$$) { my ($ioHash, $clHash, $iface, $address) = @_; my $clType = $clHash->{TYPE}; $iface = $clHash->{ccuif} if (!defined($iface)); $address = $clHash->{ccuaddr} if (!defined($address)); return if (!defined($address)); my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $address, $iface); if (defined($devDesc)) { if ($clType eq 'HMCCUCHN' && defined($devDesc->{TYPE})) { $clHash->{hmccu}{role} = $devDesc->{TYPE}; } elsif ($clType eq 'HMCCUDEV' && defined($devDesc->{CHILDREN})) { my @roles = (); foreach my $c (split(',', $devDesc->{CHILDREN})) { my $childDevDesc = HMCCU_GetDeviceDesc ($ioHash, $c, $iface); if (defined($childDevDesc) && defined($childDevDesc->{TYPE})) { push @roles, $childDevDesc->{INDEX}.':'.$childDevDesc->{TYPE}; } } $clHash->{hmccu}{role} = join(',', @roles) if (scalar(@roles) > 0); } } } ###################################################################### # Rename a client device ###################################################################### sub HMCCU_RenameDevice ($$$) { my ($ioHash, $clHash, $oldName) = @_; return 0 if (!defined($ioHash) || !defined($clHash) || !exists($clHash->{ccuif}) || !exists($clHash->{ccuaddr})); my $name = $clHash->{NAME}; my $iface = $clHash->{ccuif}; my $address = $clHash->{ccuaddr}; return 0 if (!exists($ioHash->{hmccu}{device}{$iface}{$address})); if (exists($ioHash->{hmccu}{device}{$iface}{$address}{_fhem})) { my @devList = grep { $_ ne $oldName } split(',', $ioHash->{hmccu}{device}{$iface}{$address}{_fhem}); push @devList, $name; $ioHash->{hmccu}{device}{$iface}{$address}{_fhem} = join(',', @devList); } else { $ioHash->{hmccu}{device}{$iface}{$address}{_fhem} = $name; } # Update links, but not the roles HMCCU_UpdateDevice ($ioHash, $clHash); return 1; } ###################################################################### # Return role of a channel as stored in device hash ###################################################################### sub HMCCU_GetChannelRole ($;$) { my ($clHash, $chnNo) = @_; return '' if (!defined($clHash->{hmccu}{role})); if ($clHash->{TYPE} eq 'HMCCUCHN') { return $clHash->{hmccu}{role}; } elsif ($clHash->{TYPE} eq 'HMCCUDEV') { if (!defined($chnNo)) { my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($clHash); $chnNo = $cc; } if ($chnNo ne '') { foreach my $role (split(',', $clHash->{hmccu}{role})) { my ($c, $r) = split(':', $role); return $r if (defined($r) && "$c" eq "$chnNo"); } } } return ''; } ###################################################################### # Get device configuration for all interfaces from CCU # Currently binary interfaces like CUxD are not supported ###################################################################### sub HMCCU_GetDeviceConfig ($) { my ($ioHash) = @_; my ($cDev, $cPar, $cLnk) = (0, 0, 0); foreach my $iface (keys %{$ioHash->{hmccu}{interfaces}}) { next if ($ioHash->{hmccu}{interfaces}{$iface}{type} eq 'B'); if (exists($ioHash->{hmccu}{interfaces}{$iface}{device})) { my $rpcHash = $defs{$ioHash->{hmccu}{interfaces}{$iface}{device}}; $cDev += HMCCURPCPROC_GetDeviceDesc ($rpcHash); $cPar += HMCCURPCPROC_GetParamsetDesc ($rpcHash); $cLnk += HMCCURPCPROC_GetPeers ($rpcHash); } } # Get defined FHEM devices my @devList = HMCCU_FindClientDevices ($ioHash, "(HMCCUDEV|HMCCUCHN)", undef, undef); foreach my $d (@devList) { my $ch = $defs{$d}; if (exists($ch->{ccuaddr}) && exists($ch->{ccuif})) { my $i = $ch->{ccuif}; my $a = $ch->{ccuaddr}; HMCCU_AddDevice ($ioHash, $i, $a, $d); } } # Update FHEM devices foreach my $d (@devList) { HMCCU_UpdateDevice ($ioHash, $defs{$d}); HMCCU_UpdateDeviceRoles ($ioHash, $defs{$d}); } return ($cDev, $cPar, $cLnk); } ###################################################################### # Add new device. # Arrays are converted to a comma separated string. Device description # is stored in $hash->{hmccu}{device}. # Address type and name of interface will be added to standard device # description in hash elements "_addtype" and "_interface". # Parameters: # $desc - Hash reference with RPC device description. # $key - Key of device description hash (i.e. "ADDRESS"). # $iface - RPC interface name (i.e. "BidCos-RF"). ###################################################################### sub HMCCU_AddDeviceDesc ($$$$) { my ($hash, $desc, $key, $iface) = @_; return 0 if (!exists ($desc->{$key})); my $k = $desc->{$key}; foreach my $p (keys %$desc) { if (ref($desc->{$p}) eq 'ARRAY') { $hash->{hmccu}{device}{$iface}{$k}{$p} = join(',', @{$desc->{$p}}); } else { my $d = $desc->{$p}; $d =~ s/ /,/g; $hash->{hmccu}{device}{$iface}{$k}{$p} = $d; } } $hash->{hmccu}{device}{$iface}{$k}{_interface} = $iface; if (defined($desc->{PARENT}) && $desc->{PARENT} ne '') { $hash->{hmccu}{device}{$iface}{$k}{_addtype} = 'chn'; $hash->{hmccu}{device}{$iface}{$k}{_fw_ver} = $hash->{hmccu}{device}{$iface}{$desc->{PARENT}}{_fw_ver}; $hash->{hmccu}{device}{$iface}{$k}{_model} = $hash->{hmccu}{device}{$iface}{$desc->{PARENT}}{_model}; $hash->{hmccu}{device}{$iface}{$k}{_name} = HMCCU_GetChannelName ($hash, $k, ''); } else { $hash->{hmccu}{device}{$iface}{$k}{_addtype} = 'dev'; my $fw_ver = $desc->{FIRMWARE}; $fw_ver =~ s/[-\.]/_/g; $hash->{hmccu}{device}{$iface}{$k}{_fw_ver} = $fw_ver."-".$desc->{VERSION}; $hash->{hmccu}{device}{$iface}{$k}{_model} = $desc->{TYPE}; $hash->{hmccu}{device}{$iface}{$k}{_name} = HMCCU_GetDeviceName ($hash, $k, ''); } return 1; } ###################################################################### # Get device description. # Parameters: # $hash - Hash reference of IO device. # $address - Address of device or channel. Accepts a channel address # with channel number 'd' as an alias for device address. # $iface - Interface name (optional). # Return hash reference for device description or undef on error. ###################################################################### sub HMCCU_GetDeviceDesc ($$;$) { my ($hash, $address, $iface) = @_; return undef if (!exists($hash->{hmccu}{device})); if (!defined($address)) { HMCCU_Log ($hash, 2, "Address not defined for device\n".stacktraceAsString(undef)); return undef; } my @ifaceList = (); if (defined($iface)) { push (@ifaceList, $iface); } else { push (@ifaceList, keys %{$hash->{hmccu}{device}}); } $address =~ s/:d//; foreach my $i (@ifaceList) { return $hash->{hmccu}{device}{$i}{$address} if (exists($hash->{hmccu}{device}{$i}{$address})); } return undef; } ###################################################################### # Get list of device identifiers # CCU device names are preceeded by "ccu:". # If no names were found, the address is returned. ###################################################################### sub HMCCU_GetDeviceIdentifier ($$;$$) { my ($ioHash, $address, $iface, $chnNo) = @_; my @idList = (); my ($da, $dc) = HMCCU_SplitChnAddr ($address); # my $c = defined($chnNo) ? ' #'.$chnNo : ''; my $c = ''; my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $address, $iface); if (defined($devDesc)) { if (defined($devDesc->{_fhem})) { push @idList, map { $_.$c } split(',', $devDesc->{_fhem}); } elsif (defined($devDesc->{PARENT}) && $devDesc->{PARENT} ne '') { push @idList, HMCCU_GetDeviceIdentifier ($ioHash, $devDesc->{PARENT}, $iface, $dc); } elsif (defined($devDesc->{_name})) { push @idList, "ccu:".$devDesc->{_name}; } } return scalar(@idList) > 0 ? @idList : ($address); } ###################################################################### # Convert device description to string # Parameter $object can be a device or channel address or a client # device hash reference. ###################################################################### sub HMCCU_DeviceDescToStr ($$) { my ($ioHash, $object) = @_; my $result = ''; my $address; my $iface; if (ref($object) eq 'HASH') { $address = $object->{ccuaddr}; $iface = $object->{ccuif}; } else { $address = $object; } my ($devAddr, $chnNo) = HMCCU_SplitChnAddr ($address); my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $devAddr, $iface); return undef if (!defined($devDesc)); my @addList = ($devAddr); push (@addList, split (',', $devDesc->{CHILDREN})) if (defined($devDesc->{CHILDREN}) && $devDesc->{CHILDREN} ne ''); foreach my $a (@addList) { my ($d, $c) = HMCCU_SplitChnAddr ($a); next if ($chnNo ne '' && "$c" ne '0' && "$c" ne "$chnNo" && $c ne ''); $devDesc = HMCCU_GetDeviceDesc ($ioHash, $a, $iface); return undef if (!defined($devDesc)); $result .= $a eq $devAddr ? "Device $a" : "Channel $a"; $result .= " $devDesc->{_name} [$devDesc->{TYPE}]\n"; foreach my $n (sort keys %{$devDesc}) { next if ($n =~ /^_/ || $n =~ /^(ADDRESS|TYPE|INDEX|VERSION)$/ || !defined($devDesc->{$n}) || $devDesc->{$n} eq ''); $result .= " $n: ".HMCCU_FlagsToStr ('device', $n, $devDesc->{$n}, ',', '')."\n"; } } return $result; } ###################################################################### # Convert parameter set description to string # Parameter $object can be an address or a reference to a client hash. ###################################################################### sub HMCCU_ParamsetDescToStr ($$) { my ($ioHash, $object) = @_; my $result = ''; my $address; my $iface; if (ref($object) eq 'HASH') { $address = $object->{ccuaddr}; $iface = $object->{ccuif}; } else { $address = $object; } my ($devAddr, $chnNo) = HMCCU_SplitChnAddr ($address); # BUG? # my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $address, $iface); my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $devAddr, $iface); return undef if (!defined($devDesc)); my $model = HMCCU_GetDeviceModel ($ioHash, $devDesc->{_model}, $devDesc->{_fw_ver}); return undef if (!defined($model)); my @chnList = (); if ($chnNo eq '') { push @chnList, sort keys %{$model}; unshift (@chnList, pop(@chnList)) if (exists($model->{'d'})); } else { push @chnList, 'd', 0, $chnNo; } foreach my $c (@chnList) { $result .= $c eq 'd' ? "Device\n" : "Channel $c\n"; foreach my $ps (sort keys %{$model->{$c}}) { $result .= " Paramset $ps\n"; $result .= join ("\n", map { " ".$_.": ". $model->{$c}{$ps}{$_}{TYPE}. " [".HMCCU_FlagsToStr ('model', 'OPERATIONS', $model->{$c}{$ps}{$_}{OPERATIONS}, ',', '')."]". " [".HMCCU_FlagsToStr ('model', 'FLAGS', $model->{$c}{$ps}{$_}{FLAGS}, ',', '')."]". " RANGE=".HMCCU_StripNumber ($model->{$c}{$ps}{$_}{MIN}, 2). "...".HMCCU_StripNumber ($model->{$c}{$ps}{$_}{MAX}, 2). " DFLT=".HMCCU_StripNumber ($model->{$c}{$ps}{$_}{DEFAULT}, 2). HMCCU_ISO2UTF (HMCCU_DefStr ($model->{$c}{$ps}{$_}{UNIT}, " UNIT=")). HMCCU_DefStr ($model->{$c}{$ps}{$_}{VALUE_LIST}, " VALUES=") } sort keys %{$model->{$c}{$ps}})."\n"; } } return $result; } ###################################################################### # Get device addresses. # Parameters: # $iface - Interface name. If set to undef, all devices are # returned. # $filter - Filter expression in format Attribute=RegExp[,...]. # Attribute is a valid device description parameter name or # "_addtype" or "_interface". # Return array with addresses. ###################################################################### sub HMCCU_GetDeviceAddresses ($;$$) { my ($hash, $iface, $filter) = @_; my @addList = (); my @ifaceList = (); return @addList if (!exists($hash->{hmccu}{device})); if (defined($iface)) { push (@ifaceList, $iface); } else { push (@ifaceList, keys %{$hash->{hmccu}{device}}); } if (defined($filter)) { my %f = (); foreach my $fd (split (',', $filter)) { my ($fa, $fv) = split ('=', $fd); $f{$fa} = $fv if (defined($fv)); } return undef if (scalar(keys(%f)) == 0); foreach my $i (@ifaceList) { foreach my $a (keys %{$hash->{hmccu}{device}{$i}}) { my $n = 0; foreach my $fr (keys(%f)) { if (HMCCU_ExprNotMatch ($hash->{hmccu}{device}{$i}{$a}{$fr}, $f{$fr}, 1)) { $n = 1; last; } } push (@addList, $a) if ($n == 0); } } } else { foreach my $i (@ifaceList) { push (@addList, keys %{$hash->{hmccu}{device}{$i}}); } } return @addList; } ###################################################################### # Check if device model is already known by HMCCU # $type - The device model # $fw_ver - combined key of firmware and description version # $chnNo - Channel number or 'd' for device ###################################################################### sub HMCCU_ExistsDeviceModel ($$$;$) { my ($hash, $type, $fw_ver, $chnNo) = @_; return 0 if (!exists($hash->{hmccu}{model})); if (defined($chnNo)) { return (exists($hash->{hmccu}{model}{$type}) && exists($hash->{hmccu}{model}{$type}{$fw_ver}) && exists($hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}) ? 1 : 0); } else { return (exists($hash->{hmccu}{model}{$type}) && exists($hash->{hmccu}{model}{$type}{$fw_ver}) ? 1 : 0); } } ###################################################################### # Add new device model # Parameters: # $desc - Hash reference with paramset description # $type - The device model # $fw_ver - combined key of firmware and description version # $paramset - Name of parameter set # $chnNo - Channel number or 'd' for device ###################################################################### sub HMCCU_AddDeviceModel ($$$$$$) { my ($hash, $desc, $type, $fw_ver, $paramset, $chnNo) = @_; # Process list of parameter names foreach my $p (keys %$desc) { # Process parameter attributes foreach my $a (keys %{$desc->{$p}}) { if (ref($desc->{$p}{$a}) eq 'HASH') { # Process sub attributes foreach my $s (keys %{$desc->{$p}{$a}}) { if (ref($desc->{$p}{$a}{$s}) eq 'ARRAY') { $hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}{$paramset}{$p}{$a}{$s} = join(',', @{$desc->{$p}{$a}{$s}}); } else { $hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}{$paramset}{$p}{$a}{$s} = $desc->{$p}{$a}{$s}; } } } elsif (ref($desc->{$p}{$a}) eq 'ARRAY') { $hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}{$paramset}{$p}{$a} = join(',', @{$desc->{$p}{$a}}); } else { $hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}{$paramset}{$p}{$a} = $desc->{$p}{$a}; } } } } ###################################################################### # Get device model # Parameters: # $chnNo - Channel number. Use 'd' for device entry. If not defined # a reference to the master entry is returned. ###################################################################### sub HMCCU_GetDeviceModel ($$$;$) { my ($hash, $type, $fw_ver, $chnNo) = @_; return undef if (!exists($hash->{hmccu}{model})); if (defined($chnNo)) { return (exists($hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo}) ? $hash->{hmccu}{model}{$type}{$fw_ver}{$chnNo} : undef); } else { return (exists($hash->{hmccu}{model}{$type}{$fw_ver}) ? $hash->{hmccu}{model}{$type}{$fw_ver} : undef); } } ###################################################################### # Get device model for client device # Parameters: # $hash - Hash reference for device of type HMCCUCHN or HMCCUDEV. # $chnNo - Channel number. Use 'd' for device entry. If not defined # a reference to the master entry is returned. ###################################################################### sub HMCCU_GetClientDeviceModel ($;$) { my ($clHash, $chnNo) = @_; return undef if ( ($clHash->{TYPE} ne 'HMCCUCHN' && $clHash->{TYPE} ne 'HMCCUDEV') || (!defined($clHash->{ccuaddr}))); my $ioHash = HMCCU_GetHash ($clHash); my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $clHash->{ccuaddr}, $clHash->{ccuif}); return defined($devDesc) ? HMCCU_GetDeviceModel ($ioHash, $devDesc->{_model}, $devDesc->{_fw_ver}, $chnNo) : undef; } ###################################################################### # Get parameter defintion of device model # Parameters: # $hash - Hash reference of IO device. # $object - Device or channel address or device description # reference. # $paramset - Valid paramset for device or channel. # $parameter - Parameter name. # Returns undef on error. On success return a reference to the # parameter or parameter set definition (if $parameter is not specified). ###################################################################### sub HMCCU_GetParamDef ($$$;$) { my ($hash, $object, $paramset, $parameter) = @_; return undef if (!defined($object)); my $devDesc = ref($object) eq 'HASH' ? $object : HMCCU_GetDeviceDesc ($hash, $object); if (defined($devDesc)) { # Build device address and channel number my $a = $devDesc->{ADDRESS}; my ($devAddr, $chnNo) = ($a =~ /:[0-9]{1,2}$/) ? HMCCU_SplitChnAddr ($a) : ($a, 'd'); my $model = HMCCU_GetDeviceModel ($hash, $devDesc->{_model}, $devDesc->{_fw_ver}, $chnNo); if (defined($model) && exists($model->{$paramset})) { if (defined($parameter) && exists($model->{$paramset}{$parameter})) { return $model->{$paramset}{$parameter}; } else { return $model->{$paramset} } } } return undef; } ###################################################################### # Find parameter defintion of device model # Parameters: # $hash - Hash reference of IO device. # $object - Device or channel address or device description # reference. # $parameter - Parameter name. # Returns (undef,undef) on error. Otherwise parameter set name and # reference to the parameter definition. ###################################################################### sub HMCCU_FindParamDef ($$$) { my ($hash, $object, $parameter) = @_; my $devDesc = ref($object) eq 'HASH' ? $object : HMCCU_GetDeviceDesc ($hash, $object); if (defined($devDesc)) { # Build device address and channel number my $a = $devDesc->{ADDRESS}; my ($devAddr, $chnNo) = ($a =~ /:[0-9]{1,2}$/) ? HMCCU_SplitChnAddr ($a) : ($a, 'd'); my $model = HMCCU_GetDeviceModel ($hash, $devDesc->{_model}, $devDesc->{_fw_ver}, $chnNo); if (defined($model)) { foreach my $ps (keys %$model) { return ($ps, $model->{$ps}{$parameter}) if (exists($model->{$ps}{$parameter})); } } } return (undef, undef); } ###################################################################### # Check if parameter exists # Parameters: # $clHash - Hash reference of client device. # $object - Device or channel address or device description # reference. # $ps - Parameter set name. # $parameter - Parameter name. # Returns 0 or 1 ###################################################################### sub HMCCU_IsValidParameter ($$$$) { my ($clHash, $object, $ps, $parameter) = @_; my $ioHash = HMCCU_GetHash ($clHash); return 0 if (!defined ($ioHash)); my $devDesc = ref($object) eq 'HASH' ? $object : HMCCU_GetDeviceDesc ($ioHash, $object); if (defined($devDesc)) { # Build device address and channel number my $a = $devDesc->{ADDRESS}; my ($devAddr, $chnNo) = ($a =~ /:[0-9]{1,2}$/) ? HMCCU_SplitChnAddr ($a) : ($a, 'd'); my $model = HMCCU_GetDeviceModel ($ioHash, $devDesc->{_model}, $devDesc->{_fw_ver}, $chnNo); if (defined($model)) { my @parList = ref($parameter) eq 'HASH' ? keys %$parameter : ($parameter); foreach my $p (@parList) { return 0 if (!exists($model->{$ps}) || !exists($model->{$ps}{$p})); } return 1; } } return 0; } ###################################################################### # Convert parameter value # Parameters: # $hash - Hash reference of IO device. # $object - Device/channel address or device description reference. # $paramset - Parameter set. # $parameter - Parameter name. # $value - Parameter value. # Return converted or original value. ###################################################################### sub HMCCU_GetParamValue ($$$$$) { my ($hash, $object, $paramset, $parameter, $value) = @_; # Conversion table my %ct = ( 'BOOL' => { 0 => 'false', 1 => 'true' } ); return $value if (!defined($object)); $paramset = 'LINK' if ($paramset =~ /^LINK\..+$/); my $paramDef = HMCCU_GetParamDef ($hash, $object, $paramset, $parameter); if (defined($paramDef)) { my $type = $paramDef->{TYPE}; return $ct{$type}{$value} if (exists($ct{$type}) && exists($ct{$type}{$value})); if ($type eq 'ENUM' && exists($paramDef->{VALUE_LIST})) { my @vl = split(',', $paramDef->{VALUE_LIST}); return $vl[$value] if ($value =~ /^[0-9]+$/ && $value < scalar(@vl)); } } return $value; } ###################################################################### # Update client devices with peering information # In addition peering information is stored in hash of IO device. ###################################################################### sub HMCCU_AddPeers ($$$) { my ($ioHash, $peerList, $iface) = @_; foreach my $p (@$peerList) { my ($sd, $sc) = HMCCU_SplitChnAddr ($p->{SENDER}); my ($rd, $rc) = HMCCU_SplitChnAddr ($p->{RECEIVER}); $ioHash->{hmccu}{snd}{$iface}{$sd}{$sc}{$p->{RECEIVER}}{NAME} = $p->{NAME}; $ioHash->{hmccu}{snd}{$iface}{$sd}{$sc}{$p->{RECEIVER}}{DESCRIPTION} = $p->{DESCRIPTION}; $ioHash->{hmccu}{snd}{$iface}{$sd}{$sc}{$p->{RECEIVER}}{FLAGS} = $p->{FLAGS}; $ioHash->{hmccu}{rcv}{$iface}{$rd}{$rc}{$p->{SENDER}}{NAME} = $p->{NAME}; $ioHash->{hmccu}{rcv}{$iface}{$rd}{$rc}{$p->{SENDER}}{DESCRIPTION} = $p->{DESCRIPTION}; $ioHash->{hmccu}{rcv}{$iface}{$rd}{$rc}{$p->{SENDER}}{FLAGS} = $p->{FLAGS}; } return scalar(@$peerList); } ###################################################################### # Get list of receivers for a source address ###################################################################### sub HMCCU_GetReceivers ($$$) { my ($ioHash, $address, $iface) = @_; my ($sd, $sc) = HMCCU_SplitChnAddr ($address); if (exists($ioHash->{hmccu}{snd}{$iface}{$sd}{$sc})) { return keys %{$ioHash->{hmccu}{snd}{$iface}{$sd}{$sc}}; } return (); } ###################################################################### # Check if receiver exists for a source address ###################################################################### sub HMCCU_IsValidReceiver ($$$$) { my ($ioHash, $address, $iface, $receiver) = @_; my ($sd, $sc) = HMCCU_SplitChnAddr ($address); return exists($ioHash->{hmccu}{snd}{$iface}{$sd}{$sc}{$receiver}) ? 1 : 0; } ####################################################################### # Convert bitmask to text # Parameters: # $set - 'device', 'model' or 'peer'. # $flag - Name of parameter. # $value - Value of parameter. # $sep - String separator. Default = ''. # $default - Default value is returned if no bit is set. # Return empty string on error. Return $default if no bit set. # Return $value if $flag is not a bitmask. ###################################################################### sub HMCCU_FlagsToStr ($$$;$$) { my ($set, $flag, $value, $sep, $default) = @_; $value = 0 if (!defined($value)); $default = '' if (!defined($default)); $sep = '' if (!defined($sep)); my %bitmasks = ( 'device' => { 'DIRECTION' => { 1 => "SENDER", 2 => "RECEIVER" }, 'FLAGS' => { 1 => "Visible", 2 => "Internal", 8 => "DontDelete" }, 'RX_MODE' => { 1 => "ALWAYS", 2 => "BURST", 4 => "CONFIG", 8 => "WAKEUP", 16 => "LAZY_CONFIG" } }, 'model' => { 'FLAGS' => { 1 => "Visible", 2 => "Internal", 4 => "Transform", 8 => "Service", 16 => "Sticky" }, 'OPERATIONS' => { 1 => 'R', 2 => 'W', 4 => 'E' } }, 'peer' => { 'FLAGS' => { 1 => "SENDER_BROKEN", 2 => "RECEIVER_BROKEN" } } ); my %mappings = ( 'device' => { 'DIRECTION' => { 0 => "NONE" } }, 'peer' => { 'FLAGS' => { 0 => "OK" } } ); return $value if (!exists($bitmasks{$set}{$flag}) && !exists($mappings{$set}{$flag})); return $mappings{$set}{$flag}{$value} if (exists($mappings{$set}{$flag}) && exists($mappings{$set}{$flag}{$value})); if (exists($bitmasks{$set}{$flag})) { my @list = (); foreach my $b (sort keys %{$bitmasks{$set}{$flag}}) { push (@list, $bitmasks{$set}{$flag}{$b}) if ($value & $b); } return scalar(@list) == 0 ? $default : join($sep, @list); } return $value; } ###################################################################### # Update a single client device datapoint considering scaling, reading # format and value substitution. # Return stored value. ###################################################################### sub HMCCU_UpdateSingleDatapoint ($$$$) { my ($clHash, $chn, $dpt, $value) = @_; my $ioHash = HMCCU_GetHash ($clHash); return $value if (!defined($ioHash)); my %objects; my $ccuaddr = $clHash->{ccuaddr}; my ($devaddr, $chnnum) = HMCCU_SplitChnAddr ($ccuaddr); $objects{$devaddr}{$chn}{VALUES}{$dpt} = $value; my $rc = HMCCU_UpdateParamsetReadings ($ioHash, $clHash, \%objects); return (ref($rc)) ? $rc->{$devaddr}{$chn}{VALUES}{$dpt} : $value; } ###################################################################### # Update readings of client device. # Parameter objects is a hash reference which contains updated data # for devices: # {devaddr}{channelno}{paramset}{parameter} = value # For links format of paramset is "LINK.receiver". # channelno = 'd' for device parameters. # Return hash reference for results or undef on error. ###################################################################### sub HMCCU_UpdateParamsetReadings ($$$;$) { my ($ioHash, $clHash, $objects, $addListRef) = @_; my $ioName = $ioHash->{NAME}; my $clName = $clHash->{NAME}; my $clType = $clHash->{TYPE}; return undef if (!defined($clHash->{IODev}) || !defined($clHash->{ccuaddr}) || $clHash->{IODev} != $ioHash); # Resulting readings my %results; # Updated internal values my @chKeys = (); # Check if update of device allowed my $ccuflags = HMCCU_GetFlags ($ioName); my $disable = AttrVal ($clName, 'disable', 0); my $update = AttrVal ($clName, 'ccureadings', HMCCU_IsFlag ($clName, 'noReadings') ? 0 : 1); return undef if ($update == 0 || $disable == 1 || $clHash->{ccudevstate} ne 'active'); # Build list of affected addresses my ($devAddr, $chnNo) = HMCCU_SplitChnAddr ($clHash->{ccuaddr}); my @addList = defined ($addListRef) ? @$addListRef : ($devAddr); # Determine virtual device flag my $vg = (($clHash->{ccuif} eq 'VirtualDevices' || $clHash->{ccuif} eq 'fhem') && exists($clHash->{ccugroup})) ? 1 : 0; # Get client device attributes my $clFlags = HMCCU_GetFlags ($clName); my $clRF = HMCCU_GetAttrReadingFormat ($clHash, $ioHash); my $peer = AttrVal ($clName, 'peer', 'null'); my $clInt = $clHash->{ccuif}; my ($sc, $sd, $cc, $cd, $ss, $cs) = HMCCU_GetSpecialDatapoints ($clHash); readingsBeginUpdate ($clHash); # Loop over all addresses foreach my $a (@addList) { next if (!exists($objects->{$a})); # Loop over all channels of device, including channel 'd' foreach my $c (keys %{$objects->{$a}}) { next if (($clType eq 'HMCCUCHN' && "$c" ne "$chnNo" && "$c" ne "0" && "$c" ne "d")); if (ref($objects->{$a}{$c}) ne 'HASH') { HMCCU_Log ($ioHash, 2, "object $a $c is not a hash reference\n".stacktraceAsString(undef)); next; } my $chnAddr = "$a:$c"; my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $chnAddr, $clHash->{ccuif}); my $chnType = defined($devDesc) ? $devDesc->{TYPE} : HMCCU_GetChannelRole ($clHash, $c); # Loop over all parameter sets foreach my $ps (keys %{$objects->{$a}{$c}}) { if (ref($objects->{$a}{$c}{$ps}) ne 'HASH') { HMCCU_Log ($ioHash, 2, "object $a $c $ps is not a hash reference\n".stacktraceAsString(undef)); next; } # Loop over all parameters foreach my $p (keys %{$objects->{$a}{$c}{$ps}}) { my $v = $objects->{$a}{$c}{$ps}{$p}; next if (!defined($v)); my $fv = $v; my $cv = $v; my $sv; # Key for storing values in client device hash. Indirect updates of virtual # devices are stored with device address in key. my $chKey = $devAddr ne $a ? "$chnAddr.$p" : "$c.$p"; # Store raw value in client device hash HMCCU_UpdateInternalValues ($clHash, $chKey, $ps, 'VAL', $v); # Modify value: scale, format, substitute $sv = HMCCU_ScaleValue ($clHash, $c, $p, $v, 0); $fv = HMCCU_FormatReadingValue ($clHash, $sv, $p); $cv = HMCCU_Substitute ($fv, $clHash, 0, $c, $p, $chnType, $devDesc); $cv = HMCCU_GetParamValue ($ioHash, $devDesc, $ps, $p, $fv) if (defined($devDesc) && "$fv" eq "$cv"); HMCCU_UpdateInternalValues ($clHash, $chKey, $ps, 'SVAL', $cv); push @chKeys, $chKey; # Update 'state' and 'control' HMCCU_BulkUpdate ($clHash, 'control', $fv, $cv) if ($cd ne '' && $p eq $cd && $c eq $cc); HMCCU_BulkUpdate ($clHash, 'state', $fv, $cv) if ($p eq $sd && ($sc eq '' || $sc eq $c)); # Update peers HMCCU_UpdatePeers ($clHash, "$c.$p", $cv, $peer) if (!$vg && $peer ne 'null'); # Store result, but not for indirect updates of virtual devices $results{$devAddr}{$c}{$ps}{$p} = $cv if ($devAddr eq $a); my @rnList = HMCCU_GetReadingName ($clHash, $clInt, $a, $c, $p, '', $clRF, $ps); my $dispFlag = HMCCU_FilterReading ($clHash, $chnAddr, $p, $ps) ? '' : '.'; foreach my $rn (@rnList) { HMCCU_BulkUpdate ($clHash, $dispFlag.$rn, $fv, $cv); } } } } } # Calculate additional readings if (scalar (@chKeys) > 0) { my %calc = HMCCU_CalculateReading ($clHash, \@chKeys); foreach my $cr (keys %calc) { HMCCU_BulkUpdate ($clHash, $cr, $calc{$cr}, $calc{$cr}); } } # Update device states my ($devState, $battery, $activity) = HMCCU_GetDeviceStates ($clHash); HMCCU_BulkUpdate ($clHash, 'battery', $battery, $battery) if ($battery ne 'unknown'); HMCCU_BulkUpdate ($clHash, 'activity', $activity, $activity); HMCCU_BulkUpdate ($clHash, 'devstate', $devState, $devState); # Calculate and update HomeMatic state if ($ccuflags !~ /nohmstate/) { my ($hms_read, $hms_chn, $hms_dpt, $hms_val) = HMCCU_GetHMState ($clName, $ioName, undef); HMCCU_BulkUpdate ($clHash, $hms_read, $hms_val, $hms_val) if (defined ($hms_val)); } readingsEndUpdate ($clHash, 1); return \%results; } ###################################################################### # Refresh readings of a client device ###################################################################### sub HMCCU_RefreshReadings ($) { my ($clHash) = @_; my $ioHash = HMCCU_GetHash ($clHash); return if (!defined($ioHash)); HMCCU_DeleteReadings ($clHash, '.*'); my %objects; my ($devAddr, undef) = HMCCU_SplitChnAddr ($clHash->{ccuaddr}); for my $dp (keys %{$clHash->{hmccu}{dp}}) { foreach my $ps (keys %{$clHash->{hmccu}{dp}{$dp}}) { my ($chnNo, $par) = split (/\./, $dp); if (defined($par) && defined($clHash->{hmccu}{dp}{$dp}{$ps}{VAL})) { $objects{$devAddr}{$chnNo}{$ps}{$par} = $clHash->{hmccu}{dp}{$dp}{$ps}{VAL}; } } } if (scalar(keys %objects) > 0) { HMCCU_UpdateParamsetReadings ($ioHash, $clHash, \%objects); } } ###################################################################### # Store datapoint values in device hash. # Parameter type is VAL or SVAL. # Structure: # {hmccu}{dp}{channel.datapoint}{paramset}{VAL|OVAL|SVAL|OSVAL} # {hmccu}{tt}{} ###################################################################### sub HMCCU_UpdateInternalValues ($$$$$) { my ($ch, $chkey, $paramset, $type, $value) = @_; my $otype = "O".$type; my %weekDay = ('SUNDAY', 0, 'MONDAY', 1, 'TUESDAY', 2, 'WEDNESDAY', 3, 'THURSDAY', 4, 'FRIDAY', 5, 'SATURDAY', 6); # Store time/value tables if ($type eq 'SVAL' && $chkey =~ /^[0-9d]+\.P([0-9])_([A-Z]+)_([A-Z]+)_([0-9]+)$/) { my ($prog, $valName, $day, $time) = ($1, $2, $3, $4); if (exists($weekDay{$day})) { $ch->{hmccu}{tt}{$prog}{$valName}{$day}{$time} = $value; } } # Save old value if (exists ($ch->{hmccu}{dp}{$chkey}{$paramset}{$type})) { $ch->{hmccu}{dp}{$chkey}{$paramset}{$otype} = $ch->{hmccu}{dp}{$chkey}{$paramset}{$type}; } else { $ch->{hmccu}{dp}{$chkey}{$paramset}{$otype} = $value; } # Store new value $ch->{hmccu}{dp}{$chkey}{$paramset}{$type} = $value; } ###################################################################### # Update readings of multiple client devices. # Parameter objects is a hash reference: # {devaddr} # {devaddr}{channelno} # {devaddr}{channelno}{datapoint} = value # Return number of updated devices. ###################################################################### sub HMCCU_UpdateMultipleDevices ($$) { my ($hash, $objects) = @_; my $name = $hash->{NAME}; my $c = 0; # Check syntax return 0 if (!defined ($hash) || !defined ($objects)); # Update reading in matching client devices my @devlist = HMCCU_FindClientDevices ($hash, '(HMCCUDEV|HMCCUCHN)', undef, 'ccudevstate=active'); foreach my $d (@devlist) { my $clHash = $defs{$d}; if (!defined ($clHash)) { HMCCU_Log ($name, 2, "Can't find hash for device $d"); next; } my @addrlist = HMCCU_GetAffectedAddresses ($clHash); next if (scalar (@addrlist) == 0); foreach my $addr (@addrlist) { if (exists ($objects->{$addr})) { my $rc = HMCCU_UpdateParamsetReadings ($hash, $clHash, $objects, \@addrlist); $c++ if (ref($rc)); last; } } } return $c; } ###################################################################### # Get list of device addresses including group device members. # For virtual devices group members are only returned if ccuflag # updGroupMembers is set. ###################################################################### sub HMCCU_GetAffectedAddresses ($) { my ($clHash) = @_; my @addlist = (); if ($clHash->{TYPE} eq 'HMCCUDEV' || $clHash->{TYPE} eq 'HMCCUCHN') { my $ioHash = HMCCU_GetHash ($clHash); my $ccuFlags = defined($ioHash) ? HMCCU_GetFlags ($ioHash) : 'null'; if (exists($clHash->{ccuaddr})) { my ($devaddr, $cnum) = HMCCU_SplitChnAddr ($clHash->{ccuaddr}); push @addlist, $devaddr; } if ((($clHash->{ccuif} eq 'VirtualDevices' && $ccuFlags =~ /updGroupMembers/) || $clHash->{ccuif} eq 'fhem') && exists($clHash->{ccugroup})) { push @addlist, split (',', $clHash->{ccugroup}); } } return @addlist; } ###################################################################### # Update peer devices. # Syntax of peer definitions is: # channel.datapoint[,...]:condition:type:action # condition := valid perl expression. Any channel.datapoint # combination is substituted by the corresponding value. If channel # is preceded by a % it's substituted by the raw value. If it's # preceded by a $ it's substituted by the formated/converted value. # If % or $ is doubled the old values are used. # type := type of action. Valid types are ccu, hmccu and fhem. # action := Action to be performed if result of condition is true. # Depending on type action type this could be an assignment or a # FHEM command. If action contains $value this parameter is # substituted by the original value of the datapoint which has # triggered the action. # assignment := channel.datapoint=expression ###################################################################### sub HMCCU_UpdatePeers ($$$$) { my ($clt_hash, $chndpt, $val, $peerattr) = @_; my $fnc = "UpdatePeers"; my $io_hash = HMCCU_GetHash ($clt_hash); HMCCU_Trace ($clt_hash, 2, $fnc, "chndpt=$chndpt val=$val peer=$peerattr"); my @rules = split (/[;\n]+/, $peerattr); foreach my $r (@rules) { HMCCU_Trace ($clt_hash, 2, $fnc, "rule=$r"); my ($vars, $cond, $type, $act) = split (/:/, $r, 4); next if (!defined ($act)); HMCCU_Trace ($clt_hash, 2, $fnc, "vars=$vars, cond=$cond, type=$type, act=$act"); next if ($cond !~ /$chndpt/); # Check if rule is affected by datapoint update my $ex = 0; foreach my $dpt (split (",", $vars)) { HMCCU_Trace ($clt_hash, 2, $fnc, "dpt=$dpt"); $ex = 1 if ($ex == 0 && $dpt eq $chndpt); if (!exists ($clt_hash->{hmccu}{dp}{$dpt})) { HMCCU_Trace ($clt_hash, 2, $fnc, "Datapoint $dpt does not exist on hash"); } last if ($ex == 1); } next if (! $ex); # Substitute variables and evaluate condition $cond = HMCCU_SubstVariables ($clt_hash, $cond, $vars); my $e = eval "$cond"; HMCCU_Trace ($clt_hash, 2, $fnc, "eval $cond = $e") if (defined ($e)); HMCCU_Trace ($clt_hash, 2, $fnc, "Error in eval $cond") if (!defined ($e)); HMCCU_Trace ($clt_hash, 2, $fnc, "NoMatch in eval $cond") if (defined ($e) && $e eq ''); next if (!defined ($e) || $e eq ''); # Substitute variables and execute action if ($type eq 'ccu' || $type eq 'hmccu') { my ($aobj, $aexp) = split (/=/, $act); $aexp =~ s/\$value/$val/g; $aexp = HMCCU_SubstVariables ($clt_hash, $aexp, $vars); HMCCU_Trace ($clt_hash, 2, $fnc, "set $aobj to $aexp"); my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($io_hash, "$type:$aobj", $HMCCU_FLAG_INTERFACE); next if ($flags != $HMCCU_FLAGS_IACD && $flags != $HMCCU_FLAGS_NCD); HMCCU_SetMultipleDatapoints ($clt_hash, { "001.$int.$add:$chn.$dpt" => $aexp }); } elsif ($type eq 'fhem') { $act =~ s/\$value/$val/g; $act = HMCCU_SubstVariables ($clt_hash, $act, $vars); HMCCU_Trace ($clt_hash, 2, $fnc, "Execute command $act"); AnalyzeCommandChain (undef, $act); } } } ###################################################################### # Get list of valid RPC interfaces. # Binary interfaces are ignored if internal RPC server is used. ###################################################################### sub HMCCU_GetRPCInterfaceList ($) { my ($hash) = @_; my $name = $hash->{NAME}; my ($defInterface, $defPort) = HMCCU_GetDefaultInterface ($hash); my $ccuflags = HMCCU_GetFlags ($name); my @interfaces = (); if (defined($hash->{hmccu}{rpcports})) { foreach my $p (split (',', $hash->{hmccu}{rpcports})) { my ($ifname, $iftype) = HMCCU_GetRPCServerInfo ($hash, $p, 'name,type'); push (@interfaces, $ifname) if (defined($ifname) && defined($iftype)); } } else { @interfaces = ($defInterface); } return @interfaces; } ###################################################################### # Get list of valid RPC ports. # Binary interfaces are ignored if internal RPC server is used. ###################################################################### sub HMCCU_GetRPCPortList ($) { my ($hash) = @_; my $name = $hash->{NAME}; my ($defInterface, $defPort) = HMCCU_GetDefaultInterface ($hash); my $ccuflags = HMCCU_GetFlags ($name); my @ports = (); if (defined($hash->{hmccu}{rpcports})) { foreach my $p (split (',', $hash->{hmccu}{rpcports})) { my ($ifname, $iftype) = HMCCU_GetRPCServerInfo ($hash, $p, 'name,type'); push (@ports, $p) if (defined($ifname) && defined($iftype)); } } else { @ports = ($defPort); } return @ports; } ###################################################################### # Called by HMCCURPCPROC device of default interface # when no events from CCU were received for a specified time span. # Return 1 if all RPC servers have been registered successfully. # Return 0 if at least one RPC server failed to register or the # corresponding HMCCURPCPROC device was not found. ###################################################################### sub HMCCU_EventsTimedOut ($) { my ($hash) = @_; my $name = $hash->{NAME}; return 1 if (!HMCCU_IsFlag ($name, 'reconnect')); HMCCU_Log ($hash, 2, 'Reconnecting to CCU'); # Register callback for each interface my $rc = 1; my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $ifname (@iflist) { my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 0, $ifname); if ($rpcdev eq '') { HMCCU_Log ($hash, 0, "Can't find RPC device for interface $ifname"); $rc = 0; next; } my $clHash = $defs{$rpcdev}; # Check if CCU interface is reachable before registering callback my ($nrc, $msg) = HMCCURPCPROC_RegisterCallback ($clHash, 2); $rc &= $nrc; if ($nrc) { $clHash->{ccustate} = 'active'; } else { HMCCU_Log ($clHash, 1, $msg); } } return $rc; } ###################################################################### # Build RPC callback URL # Parameter hash might be a HMCCU or a HMCCURPCPROC hash. ###################################################################### sub HMCCU_GetRPCCallbackURL ($$$$$) { my ($hash, $localaddr, $cbport, $clkey, $iface) = @_; return undef if (!defined($hash)); my $ioHash = $hash->{TYPE} eq 'HMCCURPCPROC' ? $hash->{IODev} : $hash; return undef if (!exists($ioHash->{hmccu}{interfaces}{$iface}) && !exists ($ioHash->{hmccu}{ifports}{$iface})); my $ifname = $iface =~ /^[0-9]+$/ ? $ioHash->{hmccu}{ifports}{$iface} : $iface; return undef if (!exists($ioHash->{hmccu}{interfaces}{$ifname})); my $url = $ioHash->{hmccu}{interfaces}{$ifname}{prot}."://$localaddr:$cbport/fh". $ioHash->{hmccu}{interfaces}{$ifname}{port}; $url =~ s/^https/http/; return $url; } ###################################################################### # Get RPC server information. # Parameter iface can be a port number or an interface name. # Parameter info is a comma separated list of info tokens. # Valid values for info are: # url, port, prot, host, type, name, flags, device, devcount. # Return undef for invalid interface or info token. ###################################################################### sub HMCCU_GetRPCServerInfo ($$$) { my ($hash, $iface, $info) = @_; my @result = (); return @result if (!defined($hash) || (!exists($hash->{hmccu}{interfaces}{$iface}) && !exists($hash->{hmccu}{ifports}{$iface}))); my $ifname = $iface =~ /^[0-9]+$/ ? $hash->{hmccu}{ifports}{$iface} : $iface; return @result if (!exists($hash->{hmccu}{interfaces}{$ifname})); foreach my $i (split (',', $info)) { if ($i eq 'name') { push (@result, $ifname); } else { my $v = exists ($hash->{hmccu}{interfaces}{$ifname}{$i}) ? $hash->{hmccu}{interfaces}{$ifname}{$i} : undef; push @result, $v; } } return @result; } ###################################################################### # Check if RPC interface is of specified type. # Parameter type is A for XML or B for binary. ###################################################################### sub HMCCU_IsRPCType ($$$) { my ($hash, $iface, $type) = @_; my ($rpctype) = HMCCU_GetRPCServerInfo ($hash, $iface, 'type'); return 0 if (!defined($rpctype)); return $rpctype eq $type ? 1 : 0; } ###################################################################### # Initialize statistic counters ###################################################################### sub HMCCU_ResetCounters ($) { my ($hash) = @_; my @counters = ('total', 'EV', 'ND', 'IN', 'DD', 'RA', 'RD', 'UD', 'EX', 'SL', 'ST'); foreach my $cnt (@counters) { $hash->{hmccu}{ev}{$cnt} = 0; } delete $hash->{hmccu}{evs}; delete $hash->{hmccu}{evr}; $hash->{hmccu}{evtimeout} = 0; $hash->{hmccu}{evtime} = 0; } ###################################################################### # Start external RPC server via RPC device. # Return number of RPC servers or 0 on error. ###################################################################### sub HMCCU_StartExtRPCServer ($) { my ($hash) = @_; my $name = $hash->{NAME}; my $ccuflags = AttrVal ($name, 'ccuflags', 'null'); my $attrset = 0; # Change RPC type to procrpc if ($ccuflags =~ /(extrpc|intrpc)/) { $ccuflags =~ s/(extrpc|intrpc)/procrpc/g; CommandAttr (undef, "$name ccuflags $ccuflags"); $attrset = 1; # Disable existing devices of type HMCCURPC foreach my $d (keys %defs) { my $ch = $defs{$d}; next if (!exists ($ch->{TYPE}) || !exists ($ch->{NAME})); next if ($ch->{TYPE} ne 'HMCCURPC'); CommandAttr (undef, $ch->{NAME}." disable 1") if (IsDisabled ($ch->{NAME}) != 1); } } my $c = 0; my $d = 0; my $s = 0; my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $ifname1 (@iflist) { HMCCU_Log ($hash, 2, "Get RPC device for interface $ifname1"); my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 1, $ifname1); next if ($rpcdev eq '' || !defined ($hash->{hmccu}{interfaces}{$ifname1}{device})); $d++; $s++ if ($save); } # Save FHEM config if new RPC devices were defined or attribute has changed if ($s > 0 || $attrset) { HMCCU_Log ($hash, 1, "Saving FHEM config"); CommandSave (undef, undef); } if ($d == scalar (@iflist)) { foreach my $ifname2 (@iflist) { my $dh = $defs{$hash->{hmccu}{interfaces}{$ifname2}{device}}; $hash->{hmccu}{interfaces}{$ifname2}{manager} = 'HMCCU'; my ($rc, $msg) = HMCCURPCPROC_StartRPCServer ($dh); if (!$rc) { HMCCU_SetRPCState ($hash, 'error', $ifname2, $msg); } else { $c++; } } HMCCU_SetRPCState ($hash, 'starting') if ($c > 0); return $c; } else { HMCCU_Log ($hash, 0, "Definition of some RPC devices failed"); } return 0; } ###################################################################### # Stop external RPC server via RPC device. ###################################################################### sub HMCCU_StopExtRPCServer ($;$) { my ($hash, $wait) = @_; my $name = $hash->{NAME}; return HMCCU_Log ($hash, 0, "Module HMCCURPCPROC not loaded") if (!exists ($modules{'HMCCURPCPROC'})); HMCCU_SetRPCState ($hash, 'stopping'); my $rc = 1; my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $ifname (@iflist) { my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 0, $ifname); if ($rpcdev eq '') { HMCCU_Log ($hash, 0, "HMCCU: Can't find RPC device"); next; } $hash->{hmccu}{interfaces}{$ifname}{manager} = 'HMCCU'; $rc &= HMCCURPCPROC_StopRPCServer ($defs{$rpcdev}, $wait); } return $rc; } ###################################################################### # Check status of RPC server depending on internal RPCState. # Return 1 if RPC server is stopping, starting or restarting. During # this phases CCU reacts very slowly so any get or set command from # HMCCU devices are disabled. ###################################################################### sub HMCCU_IsRPCStateBlocking ($) { my ($hash) = @_; return ($hash->{RPCState} eq "starting" || $hash->{RPCState} eq "restarting" || $hash->{RPCState} eq "stopping" ) ? 1 : 0; } ###################################################################### # Check if RPC servers are running. # Return number of running RPC servers. If paramters pids or tids are # defined also return process or thread IDs. ###################################################################### sub HMCCU_IsRPCServerRunning ($$$) { my ($hash, $pids, $tids) = @_; my $name = $hash->{NAME}; my $c = 0; my $ccuflags = HMCCU_GetFlags ($name); @$pids = () if (defined ($pids)); my @iflist = HMCCU_GetRPCInterfaceList ($hash); foreach my $ifname (@iflist) { my ($rpcdev, $save) = HMCCU_GetRPCDevice ($hash, 0, $ifname); next if ($rpcdev eq ''); my $rc = HMCCURPCPROC_CheckProcessState ($defs{$rpcdev}, 'running'); if ($rc < 0 || $rc > 1) { push (@$pids, $rc); $c++; } } return $c; } ###################################################################### # Get channels and datapoints of CCU device ###################################################################### sub HMCCU_GetDeviceInfo ($$;$) { my ($hash, $device, $ccuget) = @_; $ccuget //= 'Value'; my $name = $hash->{NAME}; my $devname = ''; my $response = ''; my $ioHash = HMCCU_GetHash ($hash); return '' if (!defined($ioHash)); my @devlist; if ($hash->{ccuif} eq 'fhem' && exists ($hash->{ccugroup})) { push @devlist, split (",", $hash->{ccugroup}); } else { push @devlist, $device; } return '' if (scalar(@devlist) == 0); $ccuget = HMCCU_GetAttribute ($ioHash, $hash, 'ccuget', 'Value') if ($ccuget eq 'Attr'); foreach my $dev (@devlist) { my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($ioHash, $dev, 0); if ($flags == $HMCCU_FLAG_ADDRESS) { $devname = HMCCU_GetDeviceName ($ioHash, $add, ''); return '' if ($devname eq ''); } else { $devname = $nam; } $response .= HMCCU_HMScriptExt ($ioHash, "!GetDeviceInfo", { devname => $devname, ccuget => $ccuget }, undef, undef); HMCCU_Trace ($hash, 2, undef, "Device=$devname Devname=$devname<br>". "Script response = \n".$response."<br>". "Script = GetDeviceInfo"); } return $response; } ###################################################################### # Make device info readable # n=number, b=bool, f=float, i=integer, s=string, a=alarm, p=presence # e=enumeration ###################################################################### sub HMCCU_FormatDeviceInfo ($) { my ($devinfo) = @_; my %vtypes = (0, "n", 2, "b", 4, "f", 6, "a", 8, "n", 11, "s", 16, "i", 20, "s", 23, "p", 29, "e"); my $result = ''; my $c_oaddr = ''; foreach my $dpspec (split ("\n", $devinfo)) { my ($c, $c_addr, $c_name, $d_name, $d_type, $d_value, $d_flags) = split (";", $dpspec); if ($c_addr ne $c_oaddr) { $result .= "CHN $c_addr $c_name\n"; $c_oaddr = $c_addr; } my $t = exists ($vtypes{$d_type}) ? $vtypes{$d_type} : $d_type; $result .= " DPT {$t} $d_name = $d_value [$d_flags]\n"; } return $result; } ###################################################################### # Get available firmware versions from EQ-3 server. # Firmware version, date and download link are stored in hash # {hmccu}{type}{$type} in elements {firmware}, {date} and {download}. # Parameter type can be a regular expression matching valid Homematic # device types in upper case letters. Default is '.*'. # Return number of available firmware downloads. ###################################################################### sub HMCCU_GetFirmwareVersions ($$) { my ($hash, $type) = @_; my $name = $hash->{NAME}; my $ccureqtimeout = AttrVal ($name, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); my $url = "http://www.eq-3.de/service/downloads.html"; my $response = GetFileFromURL ($url, $ccureqtimeout, "suchtext=&suche_in=&downloadart=11"); my @download = $response =~ m/<a.href="(Downloads\/Software\/Firmware\/[^"]+)/g; my $dc = 0; my @ts = localtime (time); $ts[4] += 1; $ts[5] += 1900; foreach my $dl (@download) { my $dd = $ts[3]; my $mm = $ts[4]; my $yy = $ts[5]; my $fw; my $date = "$dd.$mm.$yy"; my @path = split (/\//, $dl); my $file = pop @path; next if ($file !~ /(\.tgz|\.tar\.gz)/); $file =~ s/_update_V?/\|/; my ($dt, $rest) = split (/\|/, $file); next if (!defined ($rest)); $dt =~ s/_/-/g; $dt = uc($dt); next if ($dt !~ /$type/); if ($rest =~ /^([\d_]+)([0-9]{2})([0-9]{2})([0-9]{2})\./) { # Filename with version and date ($fw, $yy, $mm, $dd) = ($1, $2, $3, $4); $yy += 2000 if ($yy < 100); $date = "$dd.$mm.$yy"; $fw =~ s/_$//; } elsif ($rest =~ /^([\d_]+)\./) { # Filename with version $fw = $1; } else { $fw = $rest; } $fw =~ s/_/\./g; # Compare firmware dates if (exists ($hash->{hmccu}{type}{$dt}{date})) { my ($dd1, $mm1, $yy1) = split (/\./, $hash->{hmccu}{type}{$dt}{date}); my $v1 = $yy1*10000+$mm1*100+$dd1; my $v2 = $yy*10000+$mm*100+$dd; next if ($v1 > $v2); } $dc++; $hash->{hmccu}{type}{$dt}{firmware} = $fw; $hash->{hmccu}{type}{$dt}{date} = $date; $hash->{hmccu}{type}{$dt}{download} = $dl; } return $dc; } ###################################################################### # Read CCU device identified by device or channel name via Homematic # Script. # Return (device count, channel count) or (-1, -1) on error. ###################################################################### sub HMCCU_GetDevice ($$) { my ($hash, $name) = @_; my $devcount = 0; my $chncount = 0; my $devname; my $devtype; my %objects = (); my $response = HMCCU_HMScriptExt ($hash, '!GetDevice', { name => $name }, undef, undef); return (-1, -1) if ($response eq '' || $response =~ /^ERROR:.*/); my @scrlines = split /[\n\r]+/,$response; foreach my $hmdef (@scrlines) { my @hmdata = split /;/,$hmdef; next if (scalar(@hmdata) == 0); if ($hmdata[0] eq 'D') { next if (scalar (@hmdata) != 6); # 1=Interface 2=Device-Address 3=Device-Name 4=Device-Type 5=Channel-Count my $typeprefix = $hmdata[2] =~ /^CUX/ ? 'CUX-' : $hmdata[1] eq 'HVL' ? 'HVL-' : ''; $objects{$hmdata[2]}{addtype} = 'dev'; $objects{$hmdata[2]}{channels} = $hmdata[5]; $objects{$hmdata[2]}{flag} = 'N'; $objects{$hmdata[2]}{interface} = $hmdata[1]; $objects{$hmdata[2]}{name} = $hmdata[3]; $objects{$hmdata[2]}{type} = $typeprefix . $hmdata[4]; $objects{$hmdata[2]}{direction} = 0; $devname = $hmdata[3]; $devtype = $typeprefix . $hmdata[4]; } elsif ($hmdata[0] eq 'C') { next if (scalar (@hmdata) != 4); # 1=Channel-Address 2=Channel-Name 3=Direction $objects{$hmdata[1]}{addtype} = 'chn'; $objects{$hmdata[1]}{channels} = 1; $objects{$hmdata[1]}{flag} = 'N'; $objects{$hmdata[1]}{name} = $hmdata[2]; $objects{$hmdata[1]}{valid} = 1; $objects{$hmdata[1]}{direction} = $hmdata[3]; } } if (scalar (keys %objects) > 0) { # Update HMCCU device tables ($devcount, $chncount) = HMCCU_UpdateDeviceTable ($hash, \%objects); # Read available datapoints for device type HMCCU_GetDatapointList ($hash, $devname, $devtype) if (defined ($devname) && defined ($devtype)); } return ($devcount, $chncount); } ###################################################################### # Read list of CCU devices, channels, interfaces, programs and groups # via Homematic Script. # Update data of client devices if not current. # Return counters (devices, channels, interfaces, programs, groups) # or (-1, -1, -1, -1, -1) on error. ###################################################################### sub HMCCU_GetDeviceList ($) { my ($hash) = @_; my $name = $hash->{NAME}; my $devcount = 0; my $chncount = 0; my $ifcount = 0; my $prgcount = 0; my $gcount = 0; my %objects = (); # Read devices, channels, interfaces and groups from CCU my $response = HMCCU_HMScriptExt ($hash, "!GetDeviceList", undef, undef, undef); return (-1, -1, -1, -1, -1) if ($response eq '' || $response =~ /^ERROR:.*/); my $groups = HMCCU_HMScriptExt ($hash, "!GetGroupDevices", undef, undef, undef); # CCU is reachable $hash->{ccustate} = 'active'; # Delete old entries %{$hash->{hmccu}{dev}} = (); %{$hash->{hmccu}{adr}} = (); %{$hash->{hmccu}{interfaces}} = (); %{$hash->{hmccu}{grp}} = (); %{$hash->{hmccu}{prg}} = (); $hash->{hmccu}{updatetime} = time (); # Device hash elements for HMCCU_UpdateDeviceTable(): # # {address}{flag} := [N, D, R] # {address}{addtype} := [chn, dev] # {address}{channels} := Number of channels # {address}{name} := Device or channel name # {address}{type} := Homematic device type # {address}{usetype} := Usage type # {address}{interface} := Device interface ID # {address}{firmware} := Firmware version of device # {address}{version} := Version of RPC device description # {address}{rxmode} := Transmit mode # {address}{direction} := Channel direction: 1=sensor 2=actor 0=none my @scrlines = split /[\n\r]+/,$response; foreach my $hmdef (@scrlines) { my @hmdata = split /;/,$hmdef; next if (scalar (@hmdata) == 0); my $typeprefix = ''; if ($hmdata[0] eq 'D') { # Device next if (scalar (@hmdata) != 6); # @hmdata: 1=Interface 2=Device-Address 3=Device-Name 4=Device-Type 5=Channel-Count $objects{$hmdata[2]}{addtype} = 'dev'; $objects{$hmdata[2]}{channels} = $hmdata[5]; $objects{$hmdata[2]}{flag} = 'N'; $objects{$hmdata[2]}{interface} = $hmdata[1]; $objects{$hmdata[2]}{name} = $hmdata[3]; $typeprefix = "CUX-" if ($hmdata[2] =~ /^CUX/); $typeprefix = "HVL-" if ($hmdata[1] eq 'HVL'); $objects{$hmdata[2]}{type} = $typeprefix . $hmdata[4]; $objects{$hmdata[2]}{direction} = 0; # CCU information (address = BidCoS-RF) if ($hmdata[2] eq 'BidCoS-RF') { $hash->{ccuname} = $hmdata[3]; $hash->{ccuaddr} = $hmdata[2]; $hash->{ccuif} = $hmdata[1]; } # Count devices per interface if (exists ($hash->{hmccu}{interfaces}{$hmdata[1]}) && exists ($hash->{hmccu}{interfaces}{$hmdata[1]}{devcount})) { $hash->{hmccu}{interfaces}{$hmdata[1]}{devcount}++; } else { $hash->{hmccu}{interfaces}{$hmdata[1]}{devcount} = 1; } } elsif ($hmdata[0] eq 'C') { # Channel next if (scalar (@hmdata) != 4); # @hmdata: 1=Channel-Address 2=Channel-Name 3=Direction $objects{$hmdata[1]}{addtype} = 'chn'; $objects{$hmdata[1]}{channels} = 1; $objects{$hmdata[1]}{flag} = 'N'; $objects{$hmdata[1]}{name} = $hmdata[2]; $objects{$hmdata[1]}{valid} = 1; $objects{$hmdata[1]}{direction} = $hmdata[3]; } elsif ($hmdata[0] eq 'I') { # Interface next if (scalar (@hmdata) != 4); # 1=Interface-Name 2=Interface Info 3=URL my $ifurl = $hmdata[3]; if ($ifurl =~ /^([^:]+):\/\/([^:]+):([0-9]+)/) { my ($prot, $ipaddr, $port) = ($1, $2, $3); next if (!defined ($port) || $port eq ''); if ($port >= 10000) { $port -= 30000; $ifurl =~ s/:3$port/:$port/; } if ($hash->{ccuip} ne 'N/A') { $ifurl =~ s/127\.0\.0\.1/$hash->{ccuip}/; $ipaddr =~ s/127\.0\.0\.1/$hash->{ccuip}/; } else { $ifurl =~ s/127\.0\.0\.1/$hash->{host}/; $ipaddr =~ s/127\.0\.0\.1/$hash->{host}/; } if ($HMCCU_RPC_FLAG{$port} =~ /forceASCII/) { $ifurl =~ s/xmlrpc_bin/xmlrpc/; $prot = "xmlrpc"; } # Perl module RPC::XML::Client.pm does not support URLs starting with xmlrpc:// $ifurl =~ s/xmlrpc:/http:/; $prot =~ s/^xmlrpc$/http/; $hash->{hmccu}{interfaces}{$hmdata[1]}{url} = $ifurl; $hash->{hmccu}{interfaces}{$hmdata[1]}{prot} = $prot; $hash->{hmccu}{interfaces}{$hmdata[1]}{type} = $prot eq 'http' ? 'A' : 'B'; $hash->{hmccu}{interfaces}{$hmdata[1]}{port} = $port; $hash->{hmccu}{interfaces}{$hmdata[1]}{host} = $ipaddr; $hash->{hmccu}{interfaces}{$hmdata[1]}{state} = 'inactive'; $hash->{hmccu}{interfaces}{$hmdata[1]}{manager} = 'null'; $hash->{hmccu}{interfaces}{$hmdata[1]}{flags} = $HMCCU_RPC_FLAG{$port}; if (!exists ($hash->{hmccu}{interfaces}{$hmdata[1]}{devcount})) { $hash->{hmccu}{interfaces}{$hmdata[1]}{devcount} = 0; } $hash->{hmccu}{ifports}{$port} = $hmdata[1]; $ifcount++; } } elsif ($hmdata[0] eq 'P') { # Program next if (scalar (@hmdata) != 4); # 1=Program-Name 2=Active-Flag 3=Internal-Flag $hash->{hmccu}{prg}{$hmdata[1]}{active} = $hmdata[2]; $hash->{hmccu}{prg}{$hmdata[1]}{internal} = $hmdata[3]; $prgcount++; } } if (scalar (keys %objects) > 0) { if ($ifcount > 0) { # Configure interfaces and RPC ports my $defInterface = $hash->{hmccu}{defInterface}; my $f = 0; $hash->{ccuinterfaces} = join (',', keys %{$hash->{hmccu}{interfaces}}); if (!exists ($hash->{hmccu}{interfaces}{$defInterface}) || $hash->{hmccu}{interfaces}{$defInterface}{devcount} == 0) { HMCCU_Log ($hash, 1, "Default interface $defInterface does not exist or has no devices assigned. Changing default interface."); foreach my $i (@HMCCU_RPC_PRIORITY) { if ("$i" ne "$defInterface" && exists ($hash->{hmccu}{interfaces}{$i}) && $hash->{hmccu}{interfaces}{$i}{devcount} > 0) { $hash->{hmccu}{defInterface} = $i; $hash->{hmccu}{defPort} = $HMCCU_RPC_PORT{$i}; $f = 1; HMCCU_Log ($hash, 1, "Changed default interface from $defInterface to $i"); last; } } if ($f == 0) { HMCCU_Log ($hash, 1, "None of interfaces ".join(',', @HMCCU_RPC_PRIORITY)." exist on CCU"); return (-1, -1, -1, -1, -1); } } # Remove invalid RPC ports if (defined ($hash->{hmccu}{rpcports})) { my @plist = (); foreach my $p (split (',', $hash->{hmccu}{rpcports})) { push (@plist, $p) if (exists ($hash->{hmccu}{interfaces}{$HMCCU_RPC_NUMPORT{$p}})); } $hash->{hmccu}{rpcports} = join (',', @plist); } } else { HMCCU_Log ($hash, 1, "Found no interfaces on CCU"); return (-1, -1, -1, -1, -1); } # Update HMCCU device tables ($devcount, $chncount) = HMCCU_UpdateDeviceTable ($hash, \%objects); # Read available datapoints for each device type # This will lead to problems if some devices have different firmware versions # or links to system variables ! HMCCU_GetDatapointList ($hash, undef, undef); } # Store group configurations if ($groups !~ /^ERROR:.*/ && $groups ne '') { my @gnames = ($groups =~ m/"NAME":"([^"]+)"/g); my @gmembers = ($groups =~ m/"groupMembers":\[[^\]]+\]/g); my @gtypes = ($groups =~ m/"groupType":\{"id":"([^"]+)"/g); foreach my $gm (@gmembers) { my $gn = shift @gnames; my $gt = shift @gtypes; my @ml = ($gm =~ m/,"id":"([^"]+)"/g); $hash->{hmccu}{grp}{$gn}{type} = $gt; $hash->{hmccu}{grp}{$gn}{devs} = join (',', @ml); $gcount++; } } # Store asset counters $hash->{hmccu}{ccu}{devcount} = $devcount; $hash->{hmccu}{ccu}{chncount} = $chncount; $hash->{hmccu}{ccu}{ifcount} = $ifcount; $hash->{hmccu}{ccu}{prgcount} = $prgcount; $hash->{hmccu}{ccu}{gcount} = $gcount; HMCCU_UpdateReadings ($hash, { "count_devices" => $devcount, "count_channels" => $chncount, "count_interfaces" => $ifcount, "count_programs" => $prgcount, "count_groups" => $gcount }); # readingsBeginUpdate ($hash); # readingsBulkUpdate ($hash, "count_devices", $devcount); # readingsBulkUpdate ($hash, "count_channels", $chncount); # readingsBulkUpdate ($hash, "count_interfaces", $ifcount); # readingsBulkUpdate ($hash, "count_programs", $prgcount); # readingsBulkUpdate ($hash, "count_groups", $gcount); # readingsEndUpdate ($hash, 1); return ($devcount, $chncount, $ifcount, $prgcount, $gcount); } ###################################################################### # Read list of datapoints for all or one CCU device type(s). # Function must not be called before GetDeviceList. # Return number of datapoints read. ###################################################################### sub HMCCU_GetDatapointList ($$$) { my ($hash, $devname, $devtype) = @_; my $name = $hash->{NAME}; my @devunique; if (defined($devname) && defined($devtype)) { return 0 if (exists($hash->{hmccu}{dp}{$devtype})); push @devunique, $devname; } else { if (exists($hash->{hmccu}{dp})) { delete $hash->{hmccu}{dp}; } # Select one device for each device type my %alltypes; foreach my $add (sort keys %{$hash->{hmccu}{dev}}) { next if ($hash->{hmccu}{dev}{$add}{addtype} ne 'dev'); my $dt = $hash->{hmccu}{dev}{$add}{type}; if (defined($dt)) { if ($dt ne '' && !exists ($alltypes{$dt})) { $alltypes{$dt} = 1; push @devunique, $hash->{hmccu}{dev}{$add}{name}; } } else { HMCCU_Log ($hash, 2, "Corrupt or invalid entry in device table for device $add"); } } } return HMCCU_Log ($hash, 2, "No device types found in device table. Cannot read datapoints.", 0) if (scalar(@devunique) == 0); my $devlist = join (',', @devunique); my $response = HMCCU_HMScriptExt ($hash, '!GetDatapointList', { list => $devlist }, undef, undef); return HMCCU_Log ($hash, 2, "Cannot get datapoint list", 0) if ($response eq '' || $response =~ /^ERROR:.*/); my $c = 0; foreach my $dpspec (split /[\n\r]+/,$response) { my ($iface, $chna, $devt, $devc, $dptn, $dptt, $dpto) = split (";", $dpspec); my $dcdp = "$devc.$dptn"; $devt = "CUX-".$devt if ($iface eq 'CUxD'); $devt = "HVL-".$devt if ($iface eq 'HVL'); $hash->{hmccu}{dp}{$devt}{spc}{ontime} = $dcdp if ($dptn eq 'ON_TIME'); $hash->{hmccu}{dp}{$devt}{spc}{ramptime} = $dcdp if ($dptn eq 'RAMP_TIME'); $hash->{hmccu}{dp}{$devt}{spc}{submit} = $dcdp if ($dptn eq 'SUBMIT'); $hash->{hmccu}{dp}{$devt}{spc}{level} = $dcdp if ($dptn eq 'LEVEL'); $hash->{hmccu}{dp}{$devt}{ch}{$devc}{$dptn}{type} = $dptt; $hash->{hmccu}{dp}{$devt}{ch}{$devc}{$dptn}{oper} = $dpto; if (exists($hash->{hmccu}{dp}{$devt}{cnt}{$dptn})) { $hash->{hmccu}{dp}{$devt}{cnt}{$dptn}++; } else { $hash->{hmccu}{dp}{$devt}{cnt}{$dptn} = 1; } $c++; } return $c; } ###################################################################### # Check if device/channel name or address is valid and refers to an # existing device or channel. # mode: Bit combination: 1=Address 2=Name 4=Special address ###################################################################### sub HMCCU_IsValidDeviceOrChannel ($$$) { my ($hash, $param, $mode) = @_; return HMCCU_IsValidDevice ($hash, $param, $mode) || HMCCU_IsValidChannel ($hash, $param, $mode) ? 1 : 0; } ###################################################################### # Check if device name or address is valid and refers to an existing # device. # mode: Bit combination: 1=Address 2=Name 4=Special address ###################################################################### sub HMCCU_IsValidDevice ($$$) { my ($hash, $param, $mode) = @_; # Address if ($mode & $HMCCU_FL_STADDRESS) { my $i; my $a = 'null'; # Address with interface if (HMCCU_IsDevAddr ($param, 1)) { ($i, $a) = split (/\./, $param); } elsif (HMCCU_IsDevAddr ($param, 0)) { $a = $param; } # else { # HMCCU_Log ($hash, 3, "$param is not a valid address", 0); # } if (exists ($hash->{hmccu}{dev}{$a})) { return $hash->{hmccu}{dev}{$a}{valid}; } # else { # HMCCU_Log ($hash, 3, "Address $param not found", 0); # } # Special address for Non-Homematic devices if (($mode & $HMCCU_FL_EXADDRESS) && exists ($hash->{hmccu}{dev}{$param})) { return $hash->{hmccu}{dev}{$param}{valid} && $hash->{hmccu}{dev}{$param}{addtype} eq 'dev' ? 1 : 0; } # HMCCU_Log ($hash, 3, "Invalid address $param", 0); } # Name if (($mode & $HMCCU_FL_NAME)) { if (exists ($hash->{hmccu}{adr}{$param})) { return $hash->{hmccu}{adr}{$param}{valid} && $hash->{hmccu}{adr}{$param}{addtype} eq 'dev' ? 1 : 0; } # else { # HMCCU_Log ($hash, 3, "Device $param not found", 0); # } } return 0; } ###################################################################### # Check if channel name or address is valid and refers to an existing # channel. # mode: Bit combination: 1=Address 2=Name 4=Special address ###################################################################### sub HMCCU_IsValidChannel ($$$) { my ($hash, $param, $mode) = @_; # Standard address for Homematic devices if ($mode & $HMCCU_FL_STADDRESS) { # Address with interface if (($mode & $HMCCU_FL_STADDRESS) && HMCCU_IsChnAddr ($param, 1)) { my ($i, $a) = split (/\./, $param); return 0 if (! exists ($hash->{hmccu}{dev}{$a})); return $hash->{hmccu}{dev}{$a}{valid}; } # Address without interface if (HMCCU_IsChnAddr ($param, 0)) { return 0 if (! exists ($hash->{hmccu}{dev}{$param})); return $hash->{hmccu}{dev}{$param}{valid}; } } # Special address for Non-Homematic devices if (($mode & $HMCCU_FL_EXADDRESS) && exists ($hash->{hmccu}{dev}{$param})) { return $hash->{hmccu}{dev}{$param}{valid} && $hash->{hmccu}{dev}{$param}{addtype} eq 'chn' ? 1 : 0; } # Name if (($mode & $HMCCU_FL_NAME) && exists ($hash->{hmccu}{adr}{$param})) { return $hash->{hmccu}{adr}{$param}{valid} && $hash->{hmccu}{adr}{$param}{addtype} eq 'chn' ? 1 : 0; } return 0; } ###################################################################### # Get CCU parameters of device or channel. # Returns list containing interface, deviceaddress, name, type and # channels. ###################################################################### sub HMCCU_GetCCUDeviceParam ($$) { my ($hash, $param) = @_; my $name = $hash->{NAME}; my $devadd; my $add = undef; my $chn = undef; if (HMCCU_IsDevAddr ($param, 1) || HMCCU_IsChnAddr ($param, 1)) { my $i; ($i, $add) = split (/\./, $param); } else { if (HMCCU_IsDevAddr ($param, 0) || HMCCU_IsChnAddr ($param, 0)) { $add = $param; } else { if (exists ($hash->{hmccu}{adr}{$param})) { # param is a device name $add = $hash->{hmccu}{adr}{$param}{address}; } elsif (exists ($hash->{hmccu}{dev}{$param})) { # param is a non standard device or channel address $add = $param; } } } return (undef, undef, undef, undef) if (!defined ($add)); ($devadd, $chn) = split (':', $add); return (undef, undef, undef, undef) if (!defined ($devadd) || !exists ($hash->{hmccu}{dev}{$devadd}) || $hash->{hmccu}{dev}{$devadd}{valid} == 0); return ($hash->{hmccu}{dev}{$devadd}{interface}, $add, $hash->{hmccu}{dev}{$add}{name}, $hash->{hmccu}{dev}{$devadd}{type}, $hash->{hmccu}{dev}{$add}{channels}); } ###################################################################### # Get list of valid datapoints for device type. # hash = hash of client or IO device # devtype = Homematic device type # chn = Channel number, -1=all channels # oper = Valid operation: 1=Read, 2=Write, 4=Event # dplistref = Reference for array with datapoints. # Return number of datapoints. ###################################################################### sub HMCCU_GetValidDatapoints ($$$$$) { my ($hash, $devtype, $chn, $oper, $dplistref) = @_; my $ioHash = HMCCU_GetHash ($hash); return 0 if (HMCCU_IsFlag ($ioHash->{NAME}, 'dptnocheck') || !exists($ioHash->{hmccu}{dp})); return HMCCU_Log ($hash, 2, 'Parameter chn undefined') if (!defined($chn)); if ($chn >= 0) { if (exists($ioHash->{hmccu}{dp}{$devtype}{ch}{$chn})) { foreach my $dp (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}{$chn}}) { if ($ioHash->{hmccu}{dp}{$devtype}{ch}{$chn}{$dp}{oper} & $oper) { push @$dplistref, $dp; } } } } else { if (exists ($ioHash->{hmccu}{dp}{$devtype})) { foreach my $ch (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}}) { foreach my $dp (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}{$ch}}) { if ($ioHash->{hmccu}{dp}{$devtype}{ch}{$ch}{$dp}{oper} & $oper) { push @$dplistref, $ch.".".$dp; } } } } } return scalar(@$dplistref); } ###################################################################### # Get datapoint attribute. # Valid attributes are 'oper' or 'type'. # Return undef on error ###################################################################### sub HMCCU_GetDatapointAttr ($$$$$) { my ($hash, $devtype, $chnno, $dpt, $attr) = @_; return ( ($attr ne 'oper' && $attr ne 'type') || (!exists($hash->{hmccu}{dp}{$devtype})) || (!exists($hash->{hmccu}{dp}{$devtype}{ch}{$chnno})) || (!exists($hash->{hmccu}{dp}{$devtype}{ch}{$chnno}{$dpt})) ) ? undef : $hash->{hmccu}{dp}{$devtype}{ch}{$chnno}{$dpt}{$attr}; } ###################################################################### # Find a datapoint for device type. # hash = hash of client or IO device # devtype = Homematic device type # chn = Channel number, -1=all channels # oper = Valid operation: 1=Read, 2=Write, 4=Event # Return channel of first match or -1. ###################################################################### sub HMCCU_FindDatapoint ($$$$$) { my ($hash, $devtype, $chn, $dpt, $oper) = @_; my $ioHash = HMCCU_GetHash ($hash); return -1 if (!exists($ioHash->{hmccu}{dp})); if ($chn >= 0) { if (exists($ioHash->{hmccu}{dp}{$devtype}{ch}{$chn})) { foreach my $dp (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}{$chn}}) { return $chn if ($dp eq $dpt && $ioHash->{hmccu}{dp}{$devtype}{ch}{$chn}{$dp}{oper} & $oper); } } } else { if (exists($ioHash->{hmccu}{dp}{$devtype})) { foreach my $ch (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}}) { foreach my $dp (sort keys %{$ioHash->{hmccu}{dp}{$devtype}{ch}{$ch}}) { return $ch if ($dp eq $dpt && $ioHash->{hmccu}{dp}{$devtype}{ch}{$ch}{$dp}{oper} & $oper); } } } } return -1; } ###################################################################### # Check if datapoint is valid. # Parameter chn can be a channel address or a channel number. If dpt # contains a channel number parameter chn should be set to undef. # Parameter dpt can contain a channel number. # Parameter oper specifies access flag: # 1 = datapoint readable # 2 = datapoint writeable # Return 1 if ccuflags is set to dptnocheck or datapoint is valid. # Otherwise 0. ###################################################################### sub HMCCU_IsValidDatapoint ($$$$$) { my ($hash, $devtype, $chn, $dpt, $oper) = @_; my $fnc = 'IsValidDatapoint'; my $ioHash = HMCCU_GetHash ($hash); return 0 if (!defined($ioHash)); if ($hash->{TYPE} eq 'HMCCU' && !defined($devtype)) { $devtype = HMCCU_GetDeviceType ($ioHash, $chn, 'null'); } return 1 if (HMCCU_IsFlag ($ioHash->{NAME}, "dptnocheck") || !exists($ioHash->{hmccu}{dp})); my $chnno; if (defined ($chn) && $chn ne '') { if ($chn =~ /^[0-9]{1,2}$/) { $chnno = $chn; } elsif (HMCCU_IsValidChannel ($ioHash, $chn, $HMCCU_FL_ADDRESS)) { my ($a, $c) = split(":",$chn); $chnno = $c; } else { HMCCU_Trace ($hash, 2, $fnc, "$chn is not a valid channel address or number"); HMCCU_Trace ($hash, 2, $fnc, stacktraceAsString(undef)); return 0; } } elsif ($dpt =~ /^([0-9]{1,2})\.(.+)$/) { $chnno = $1; $dpt = $2; } else { HMCCU_Trace ($hash, 2, $fnc, "channel number missing in datapoint $dpt"); return 0; } my $v = (exists($ioHash->{hmccu}{dp}{$devtype}{ch}{$chnno}{$dpt}) && ($ioHash->{hmccu}{dp}{$devtype}{ch}{$chnno}{$dpt}{oper} & $oper)) ? 1 : 0; HMCCU_Trace ($hash, 2, $fnc, "devtype=$devtype, chnno=$chnno, dpt=$dpt, valid=$v"); return $v; } ###################################################################### # Get list of device or channel addresses for which device or channel # name matches regular expression. # Parameter mode can be 'dev' or 'chn'. # Return number of matching entries. ###################################################################### sub HMCCU_GetMatchingDevices ($$$$) { my ($hash, $regexp, $mode, $listref) = @_; my $c = 0; foreach my $name (sort keys %{$hash->{hmccu}{adr}}) { next if ( $name !~/$regexp/ || $hash->{hmccu}{adr}{$name}{addtype} ne $mode || $hash->{hmccu}{adr}{$name}{valid} == 0); push (@$listref, $hash->{hmccu}{adr}{$name}{address}); $c++; } return $c; } ###################################################################### # Get name of a CCU device by address. # Channel number will be removed if specified. ###################################################################### sub HMCCU_GetDeviceName ($$$) { my ($hash, $addr, $default) = @_; if (HMCCU_IsValidDeviceOrChannel ($hash, $addr, $HMCCU_FL_ADDRESS)) { $addr =~ s/:[0-9]+$//; return $hash->{hmccu}{dev}{$addr}{name}; } return $default; } ###################################################################### # Get name of a CCU device channel by address. ###################################################################### sub HMCCU_GetChannelName ($$$) { my ($hash, $addr, $default) = @_; if (HMCCU_IsValidChannel ($hash, $addr, $HMCCU_FL_ADDRESS)) { return $hash->{hmccu}{dev}{$addr}{name}; } return $default; } ###################################################################### # Get type of a CCU device by address. # Channel number will be removed if specified. ###################################################################### sub HMCCU_GetDeviceType ($$$) { my ($hash, $addr, $default) = @_; if (HMCCU_IsValidDeviceOrChannel ($hash, $addr, $HMCCU_FL_ADDRESS)) { $addr =~ s/:[0-9]+$//; return $hash->{hmccu}{dev}{$addr}{type}; } return $default; } ###################################################################### # Get number of channels of a CCU device. # Channel number will be removed if specified. ###################################################################### sub HMCCU_GetDeviceChannels ($$$) { my ($hash, $addr, $default) = @_; if (HMCCU_IsValidDeviceOrChannel ($hash, $addr, $HMCCU_FL_ADDRESS)) { $addr =~ s/:[0-9]+$//; return $hash->{hmccu}{dev}{$addr}{channels}; } return 0; } ###################################################################### # Get default RPC interface and port ###################################################################### sub HMCCU_GetDefaultInterface ($) { my ($hash) = @_; my $ifname = exists ($hash->{hmccu}{defInterface}) ? $hash->{hmccu}{defInterface} : $HMCCU_RPC_PRIORITY[0]; my $ifport = $HMCCU_RPC_PORT{$ifname}; return ($ifname, $ifport); } ###################################################################### # Get interface of a CCU device by address. # Channel number will be removed if specified. ###################################################################### sub HMCCU_GetDeviceInterface ($$$) { my ($hash, $addr, $default) = @_; if (HMCCU_IsValidDeviceOrChannel ($hash, $addr, $HMCCU_FL_ADDRESS)) { $addr =~ s/:[0-9]+$//; return $hash->{hmccu}{dev}{$addr}{interface}; } return $default; } ###################################################################### # Get address of a CCU device or channel by CCU name or FHEM device # name defined via HMCCUCHN or HMCCUDEV. FHEM device names must be # preceded by "hmccu:". CCU names can be preceded by "ccu:". # Return array with device address and channel no. If name is not # found or refers to a device the specified default values will be # returned. ###################################################################### sub HMCCU_GetAddress ($$$$) { my ($hash, $name, $defadd, $defchn) = @_; my $add = $defadd; my $chn = $defchn; my $chnno = $defchn; my $addr = ''; my $type = ''; if ($name =~ /^hmccu:.+$/) { # Name is a FHEM device name $name =~ s/^hmccu://; if ($name =~ /^([^:]+):([0-9]{1,2})$/) { $name = $1; $chnno = $2; } return ($defadd, $defchn) if (!exists($defs{$name})); my $dh = $defs{$name}; return ($defadd, $defchn) if ($dh->{TYPE} ne 'HMCCUCHN' && $dh->{TYPE} ne 'HMCCUDEV'); ($add, $chn) = HMCCU_SplitChnAddr ($dh->{ccuaddr}); $chn = $chnno if ($chn eq ''); return ($add, $chn); } elsif ($name =~ /^ccu:.+$/) { # Name is a CCU device or channel name $name =~ s/^ccu://; } if (exists ($hash->{hmccu}{adr}{$name})) { # Name known by HMCCU $addr = $hash->{hmccu}{adr}{$name}{address}; $type = $hash->{hmccu}{adr}{$name}{addtype}; } elsif (exists ($hash->{hmccu}{dev}{$name})) { # Address known by HMCCU $addr = $name; $type = $hash->{hmccu}{dev}{$name}{addtype}; } else { # Address not known. Query CCU my ($dc, $cc) = HMCCU_GetDevice ($hash, $name); if ($dc > 0 && $cc > 0 && exists ($hash->{hmccu}{adr}{$name})) { $addr = $hash->{hmccu}{adr}{$name}{address}; $type = $hash->{hmccu}{adr}{$name}{addtype}; } } if ($addr ne '') { if ($type eq 'chn') { ($add, $chn) = split (":", $addr); } else { $add = $addr; } } return ($add, $chn); } ###################################################################### # Get addresses of group member devices. # Group 'virtual' is ignored. # Return list of device addresses or empty list on error. ###################################################################### sub HMCCU_GetGroupMembers ($$) { my ($hash, $group) = @_; return $group ne 'virtual' && exists ($hash->{hmccu}{grp}{$group}) ? split (',', $hash->{hmccu}{grp}{$group}{devs}) : (); } ###################################################################### # Check if parameter is a channel address (syntax) # f=1: Interface required. ###################################################################### sub HMCCU_IsChnAddr ($$) { my ($id, $f) = @_; if ($f) { return ($id =~ /^.+\.[\*]*[A-Z]{3}[0-9]{7}:[0-9]{1,2}$/ || $id =~ /^.+\.[0-9A-F]{12,14}:[0-9]{1,2}$/ || $id =~ /^.+\.OL-.+:[0-9]{1,2}$/ || $id =~ /^.+\.BidCoS-RF:[0-9]{1,2}$/) ? 1 : 0; } else { return ($id =~ /^[\*]*[A-Z]{3}[0-9]{7}:[0-9]{1,2}$/ || $id =~ /^[0-9A-F]{12,14}:[0-9]{1,2}$/ || $id =~ /^OL-.+:[0-9]{1,2}$/ || $id =~ /^BidCoS-RF:[0-9]{1,2}$/) ? 1 : 0; } } ###################################################################### # Check if parameter is a device address (syntax) # f=1: Interface required. ###################################################################### sub HMCCU_IsDevAddr ($$) { my ($id, $f) = @_; if ($f) { return ($id =~ /^.+\.[\*]*[A-Z]{3}[0-9]{7}$/ || $id =~ /^.+\.[0-9A-F]{12,14}$/ || $id =~ /^.+\.OL-.+$/ || $id =~ /^.+\.BidCoS-RF$/) ? 1 : 0; } else { return ($id =~ /^[\*]*[A-Z]{3}[0-9]{7}$/ || $id =~ /^[0-9A-F]{12,14}$/ || $id =~ /^OL-.+$/ || $id eq 'BidCoS-RF') ? 1 : 0; } } ###################################################################### # Split channel address into device address and channel number. # Returns device address only if parameter is already a device address. ###################################################################### sub HMCCU_SplitChnAddr ($) { my ($addr) = @_; my ($dev, $chn) = split (':', $addr); $chn = '' if (!defined ($chn)); return ($dev, $chn); } sub HMCCU_SplitDatapoint ($;$) { my ($dpt, $defchn) = @_; my @t = split ('.', $dpt); return (scalar(@t) > 1) ? @t : ($defchn, $t[0]); } ###################################################################### # Get list of client devices matching the specified criteria. # If no criteria is specified all device names will be returned. # Parameters modexp and namexp are regular expressions for module # name and device name. Parameter internal contains a comma separated # list of expressions like internal=valueexp. # All parameters can be undefined. In this case all devices will be # returned. ###################################################################### sub HMCCU_FindClientDevices ($$$$) { my ($hash, $modexp, $namexp, $internal) = @_; my @devlist = (); foreach my $d (keys %defs) { my $ch = $defs{$d}; my $m = 1; next if ( (!defined($ch->{TYPE}) || !defined($ch->{NAME})) || (defined ($modexp) && $ch->{TYPE} !~ /$modexp/) || (defined ($namexp) && $ch->{NAME} !~ /$namexp/) || (defined ($hash) && exists ($ch->{IODev}) && $ch->{IODev} != $hash)); if (defined($internal)) { foreach my $intspec (split (',', $internal)) { my ($i, $v) = split ('=', $intspec); if (!exists($ch->{$i}) || (defined ($v) && exists ($ch->{$i}) && $ch->{$i} !~ /$v/)) { $m = 0; last; } } } push @devlist, $ch->{NAME} if ($m == 1); } return @devlist; } ###################################################################### # Check if client device already exists # Return name of existing device or empty string. ###################################################################### sub HMCCU_ExistsClientDevice ($$) { my ($devSpec, $type) = @_; foreach my $d (keys %defs) { my $clHash = $defs{$d}; return $clHash->{NAME} if (defined($clHash->{TYPE}) && $clHash->{TYPE} eq $type && (defined($clHash->{ccuaddr}) && $clHash->{ccuaddr} eq $devSpec || defined($clHash->{ccuname}) && $clHash->{ccuname} eq $devSpec) ); } return ''; } ###################################################################### # Get name of assigned client device of type HMCCURPCPROC. # Create a RPC device of type HMCCURPCPROC if none is found and # parameter create is set to 1. # Return (devname, create). # Return empty string for devname if RPC device cannot be identified # or created. Return (devname,1) if device has been created and # configuration should be saved. ###################################################################### sub HMCCU_GetRPCDevice ($$$) { my ($hash, $create, $ifname) = @_; my $name = $hash->{NAME}; my $rpcdevname; my $rpchost = $hash->{host}; my $rpcprot = $hash->{prot}; my $ccuflags = HMCCU_GetFlags ($name); return (HMCCU_Log ($hash, 1, 'Interface not defined for RPC server of type HMCCURPCPROC', '')) if (!defined($ifname)); ($rpcdevname, $rpchost) = HMCCU_GetRPCServerInfo ($hash, $ifname, 'device,host'); return ($rpcdevname, 0) if (defined ($rpcdevname)); return ('', 0) if (!defined ($rpchost)); # Search for RPC devices associated with I/O device my @devlist; foreach my $dev (keys %defs) { my $devhash = $defs{$dev}; next if ($devhash->{TYPE} ne 'HMCCURPCPROC'); my $ip = !exists($devhash->{rpcip}) ? HMCCU_Resolve ($devhash->{host}, 'null') : $devhash->{rpcip}; next if (($devhash->{host} ne $rpchost && $ip ne $rpchost) || $devhash->{rpcinterface} ne $ifname); push @devlist, $devhash->{NAME}; } my $devcnt = scalar(@devlist); if ($devcnt == 1) { $hash->{hmccu}{interfaces}{$ifname}{device} = $devlist[0]; return ($devlist[0], 0); } elsif ($devcnt > 1) { return (HMCCU_Log ($hash, 2, "Found more than one RPC device for interface $ifname", '')); } HMCCU_Log ($hash, 1, "No RPC device defined for interface $ifname"); # Create RPC device if ($create) { my $alias = "CCU RPC $ifname"; my $rpccreate = ''; $rpcdevname = 'd_rpc'; # Ensure unique device name by appending last 2 digits of CCU IP address $rpcdevname .= HMCCU_GetIdFromIP ($hash->{ccuip}, '') if (exists($hash->{ccuip})); # Build device name and define command $rpcdevname = makeDeviceName ($rpcdevname.$ifname); $rpccreate = "$rpcdevname HMCCURPCPROC $rpcprot://$rpchost $ifname"; return (HMCCU_Log ($hash, 2, "Device $rpcdevname already exists. Please delete or rename it.", '')) if (exists($defs{"$rpcdevname"})); # Create RPC device HMCCU_Log ($hash, 1, "Creating new RPC device $rpcdevname"); my $ret = CommandDefine (undef, $rpccreate); if (!defined($ret)) { # RPC device created. Set/copy some attributes from HMCCU device my %rpcdevattr = ('room' => 'copy', 'group' => 'copy', 'icon' => 'copy', 'stateFormat' => 'rpcstate/state', 'eventMap' => '/rpcserver on:on/rpcserver off:off/', 'verbose' => 2, 'alias' => $alias ); foreach my $a (keys %rpcdevattr) { my $v = $rpcdevattr{$a} eq 'copy' ? AttrVal ($name, $a, '') : $rpcdevattr{$a}; CommandAttr (undef, "$rpcdevname $a $v") if ($v ne ''); } return ($rpcdevname, 1); } else { HMCCU_Log ($hash, 1, "Definition of RPC device failed. $ret"); } } return ('', 0); } ###################################################################### # Assign IO device to client device. # Wrapper function for AssignIOPort() # Parameter $hash refers to a client device of type HMCCURPCPROC, # HMCCUDEV or HMCCUCHN. # Parameters ioname and ifname are optional. # Return 1 on success or 0 on error. ###################################################################### sub HMCCU_AssignIODevice ($$$) { my ($hash, $ioName, $ifName) = @_; my $type = $hash->{TYPE}; my $name = $hash->{NAME}; my $ioHash; AssignIoPort ($hash, $ioName); $ioHash = $hash->{IODev} if (exists ($hash->{IODev})); return HMCCU_Log ($hash, 1, "Can't assign I/O device", 0) if (!defined($ioHash) || !exists($ioHash->{TYPE}) || $ioHash->{TYPE} ne 'HMCCU'); if ($type eq 'HMCCURPCPROC' && defined ($ifName) && exists($ioHash->{hmccu}{interfaces}{$ifName})) { # Register RPC device $ioHash->{hmccu}{interfaces}{$ifName}{device} = $name; } return 1; } ###################################################################### # Get hash of HMCCU IO device which is responsible for device or # channel specified by parameter. If param is undef the first device # of type HMCCU will be returned. ###################################################################### sub HMCCU_FindIODevice ($) { my ($param) = @_; foreach my $dn (sort keys %defs) { my $ch = $defs{$dn}; next if (!exists ($ch->{TYPE})); next if ($ch->{TYPE} ne 'HMCCU'); my $disabled = AttrVal ($ch->{NAME}, 'disable', 0); next if ($disabled); return $ch if (!defined ($param)); return $ch if (HMCCU_IsValidDeviceOrChannel ($ch, $param, $HMCCU_FL_ALL)); } return undef; } ###################################################################### # Get states of IO devices ###################################################################### sub HMCCU_IODeviceStates () { my $active = 0; my $inactive = 0; # Search for first HMCCU device foreach my $dn (sort keys %defs) { my $ch = $defs{$dn}; next if (!exists ($ch->{TYPE})); next if ($ch->{TYPE} ne 'HMCCU'); if (exists ($ch->{ccustate}) && $ch->{ccustate} eq 'active') { $active++; } else { $inactive++; } } return ($active, $inactive); } ###################################################################### # Get hash of HMCCU IO device. Useful for client devices. Accepts hash # of HMCCU, HMCCUDEV or HMCCUCHN device as parameter. # If hash is 0 or undefined the hash of the first device of type HMCCU # will be returned. ###################################################################### sub HMCCU_GetHash ($@) { my ($hash) = @_; if (defined($hash) && $hash != 0) { if ($hash->{TYPE} eq 'HMCCUDEV' || $hash->{TYPE} eq 'HMCCUCHN') { return $hash->{IODev} if (exists ($hash->{IODev})); return HMCCU_FindIODevice ($hash->{ccuaddr}) if (exists($hash->{ccuaddr})); } elsif ($hash->{TYPE} eq 'HMCCU') { return $hash; } } # Search for first HMCCU device foreach my $dn (sort keys %defs) { my $ch = $defs{$dn}; next if (!exists ($ch->{TYPE})); return $ch if ($ch->{TYPE} eq 'HMCCU'); } return undef; } ###################################################################### # Get attribute of client device. Fallback to attribute of IO device. ###################################################################### sub HMCCU_GetAttribute ($$$$) { my ($ioHash, $clHash, $attrName, $attrDefault) = @_; my $value = AttrVal ($clHash->{NAME}, $attrName, ''); $value = AttrVal ($ioHash->{NAME}, $attrName, $attrDefault) if ($value eq ''); return $value; } ###################################################################### # Set default attributes for client device. ###################################################################### sub HMCCU_SetDefaultAttributes ($;$) { my ($clHash, $ctrlChn) = @_; my $clName = $clHash->{NAME}; my $role = HMCCU_GetChannelRole ($clHash, $ctrlChn); HMCCU_Log ($clHash, 2, "SetDefaultAttributes: role=$role"); if ($role ne '' && exists($HMCCU_ATTR->{$role})) { HMCCU_Log ($clHash, 2, "SetDefaultAttributes: attributes found"); foreach my $a (keys %{$HMCCU_ATTR->{$role}}) { CommandAttr (undef, "$clName $a ".$HMCCU_ATTR->{$role}{$a}); } return 1; } else { return 0; } } ###################################################################### # Get state values of client device # Return '' if no state values available ###################################################################### sub HMCCU_GetStateValues ($$;$) { my ($clHash, $dpt, $ctrlChn) = @_; my $sv = AttrVal ($clHash->{NAME}, 'statevals', ''); if ($sv eq '') { my $role = HMCCU_GetChannelRole ($clHash, $ctrlChn); if ($role ne '' && exists($HMCCU_STATECONTROL->{$role}) && $HMCCU_STATECONTROL->{$role}{C} eq $dpt) { return $HMCCU_STATECONTROL->{$role}{V}; } } return $sv; } ###################################################################### # Return additional commands depending on the channel role. ###################################################################### sub HMCCU_GetSpecialCommands ($$) { my ($clHash, $ctrlChn) = @_; my $role = HMCCU_GetChannelRole ($clHash, $ctrlChn); return $HMCCU_ROLECMDS->{$role} if ($role ne '' && exists($HMCCU_ROLECMDS->{$role})); return undef; } ###################################################################### # Get channels and datapoints from attributes statechannel, # statedatapoint and controldatapoint. # Return attribute values. Attribute controldatapoint is splitted into # controlchannel and datapoint name. If attribute statedatapoint # contains channel number it is splitted into statechannel and # datapoint name. # If controldatapoint is not specified it will synchronized with # statedatapoint. # Return (sc, sd, cc, cd) ###################################################################### sub HMCCU_GetSpecialDatapoints ($) { my ($hash) = @_; my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my $ccutype = $hash->{ccutype}; my ($sc, $sd, $cc, $cd) = ('', '', '', ''); my $statedatapoint = AttrVal ($name, 'statedatapoint', ''); my $controldatapoint = AttrVal ($name, 'controldatapoint', ''); my ($da, $dc) = HMCCU_SplitChnAddr ($hash->{ccuaddr}); # Attributes controlchannel and statechannel are only valid for HMCCUDEV devices if ($type eq 'HMCCUDEV') { $sc = AttrVal ($name, 'statechannel', ''); $cc = AttrVal ($name, 'controlchannel', ''); } else { $sc = $dc; $cc = $dc; } # If attribute statedatapoint is specified, use it. Attribute statechannel overrides # channel specification in statedatapoint if ($statedatapoint ne '') { if ($statedatapoint =~ /^([0-9]+)\.(.+)$/) { ($sc, $sd) = $sc eq '' ? ($1, $2) : ($sc, $2); } else { $sd = $statedatapoint; if ($sc eq '') { # Try to find state channel my $c = HMCCU_FindDatapoint ($hash, $type, -1, $sd, 3); $sc = $c if ($c >= 0); } } } # If attribute controldatapoint is specified, use it. Attribute controlchannel overrides # channel specification in controldatapoint if ($controldatapoint ne '') { if ($controldatapoint =~ /^([0-9]+)\.(.+)$/) { ($cc, $cd) = ($1, $2); } else { $cd = $controldatapoint; if ($cc eq '') { # Try to find control channel my $c = HMCCU_FindDatapoint ($hash, $type, -1, $cd, 3); $cc = $c if ($c >= 0); } } } # Detect by role, but do not override values defined as attributes if (exists($hash->{hmccu}{role})) { my $ccuRole = $hash->{hmccu}{role}; if ($type eq 'HMCCUCHN') { if (exists($HMCCU_STATECONTROL->{$ccuRole}) && $HMCCU_STATECONTROL->{$ccuRole}{F} & 1) { $sd = $HMCCU_STATECONTROL->{$ccuRole}{S} if ($HMCCU_STATECONTROL->{$ccuRole}{S} ne '' && $sd eq ''); $cd = $HMCCU_STATECONTROL->{$ccuRole}{C} if ($HMCCU_STATECONTROL->{$ccuRole}{C} ne '' && $cd eq ''); } } elsif ($type eq 'HMCCUDEV') { my ($rsdCnt, $rcdCnt) = (0, 0); my ($rsc, $rsd, $rcc, $rcd) = ('', '', '', ''); foreach my $roleDef (split(',', $ccuRole)) { my ($rc, $role) = split(':', $roleDef); if (defined($role) && exists($HMCCU_STATECONTROL->{$role}) && $HMCCU_STATECONTROL->{$role}{F} & 2) { if ($sd eq '' && $HMCCU_STATECONTROL->{$role}{S} ne '') { if ($sc ne '' && $rc eq $sc) { $sd = $HMCCU_STATECONTROL->{$role}{S}; } else { $rsc = $rc; $rsd = $HMCCU_STATECONTROL->{$role}{S}; $rsdCnt++; } } if ($cd eq '' && $HMCCU_STATECONTROL->{$role}{C} ne '') { if ($cc ne '' && $rc eq $cc) { $cd = $HMCCU_STATECONTROL->{$role}{C}; } else { $rcc = $rc; $rcd = $HMCCU_STATECONTROL->{$role}{C}; $rcdCnt++; } } } } ($sc, $sd) = ($rsc, $rsd) if ($rsdCnt == 1 && $sd eq ''); ($cc, $cd) = ($rcc, $rcd) if ($rcdCnt == 1 && $cd eq ''); } } $cc = $sc if ($cc eq '' && $sc ne ''); $sc = $cc if ($sc eq '' && $cc ne ''); $cd = $sd if ($cd eq '' && $sd ne ''); $sd = $cd if ($sd eq '' && $cd ne ''); $hash->{hmccu}{state}{dpt} = $sd; $hash->{hmccu}{state}{chn} = $sc; $hash->{hmccu}{control}{dpt} = $cd; $hash->{hmccu}{control}{chn} = $cc; return ($sc, $sd, $cc, $cd); } ###################################################################### # Get attribute ccuflags. # Default value is 'null'. With version 4.4 flags intrpc and extrpc # are substituted by procrpc. ###################################################################### sub HMCCU_GetFlags ($) { my ($name) = @_; my $ccuflags = AttrVal ($name, 'ccuflags', 'null'); $ccuflags =~ s/(extrpc|intrpc)/procrpc/g; return $ccuflags; } ###################################################################### # Check if specific CCU flag is set. ###################################################################### sub HMCCU_IsFlag ($$) { my ($name, $flag) = @_; my $ccuflags = AttrVal ($name, 'ccuflags', 'null'); return $ccuflags =~ /$flag/ ? 1 : 0; } ###################################################################### # Get reading format considering default attribute # ccudef-readingformat defined in I/O device. # Default reading format for virtual groups is always 'name'. ###################################################################### sub HMCCU_GetAttrReadingFormat ($$) { my ($clhash, $iohash) = @_; my $clname = $clhash->{NAME}; my $ioname = $iohash->{NAME}; my $rfdef = ''; if (exists($clhash->{ccutype}) && $clhash->{ccutype} =~ /^HM-CC-VG/) { $rfdef = 'name'; } else { $rfdef = AttrVal ($ioname, 'ccudef-readingformat', 'datapoint'); } return AttrVal ($clname, 'ccureadingformat', $rfdef); } ###################################################################### # Get number format considering default attribute ccudef-stripnumber, # Default is null ###################################################################### sub HMCCU_GetAttrStripNumber ($) { my ($hash) = @_; my $fnc = "GetAttrStripNumber"; my $type = $hash->{TYPE}; my %strip = ( 'BLIND' => '0', 'DIMMER' => '0' ); my $snDef = '1'; my $ioHash = HMCCU_GetHash ($hash); if (defined($ioHash)) { $snDef = AttrVal ($ioHash->{NAME}, 'ccudef-stripnumber', $snDef); } if (exists($hash->{hmccu}{role})) { if ($type eq 'HMCCUDEV') { foreach my $cr (split(',', $hash->{hmccu}{role})) { my ($c, $r) = split(':', $cr); if (exists($strip{$r})) { $snDef = $strip{$r}; last; } } } elsif ($type eq 'HMCCUCHN') { $snDef = $strip{$hash->{hmccu}{role}} if (exists($strip{$hash->{hmccu}{role}})); } } my $stripnumber = AttrVal ($hash->{NAME}, 'stripnumber', $snDef); HMCCU_Trace ($hash, 2, $fnc, "stripnumber = $stripnumber"); return $stripnumber; } ###################################################################### # Get attributes substitute and substexcl considering default # attribute ccudef-substitute defined in I/O device. # Substitute ${xxx} by datapoint value. ###################################################################### sub HMCCU_GetAttrSubstitute ($$) { my ($clhash, $iohash) = @_; my $fnc = 'GetAttrSubstitute'; my $clname = $clhash->{NAME}; my $ioname = $iohash->{NAME}; my $substdef = AttrVal ($ioname, 'ccudef-substitute', ''); my $subst = AttrVal ($clname, 'substitute', $substdef); $subst .= ";$substdef" if ($subst ne $substdef && $substdef ne ''); HMCCU_Trace ($clhash, 2, $fnc, "subst = $subst"); return $subst if ($subst !~ /\$\{.+\}/); $subst = HMCCU_SubstVariables ($clhash, $subst, undef); HMCCU_Trace ($clhash, 2, $fnc, "subst_vars = $subst"); return $subst; } ###################################################################### # Execute Homematic command on CCU (blocking). # If parameter mode is 1 an empty string is a valid result. # Return undef on error. ###################################################################### sub HMCCU_HMCommand ($$$) { my ($cl_hash, $cmd, $mode) = @_; my $cl_name = $cl_hash->{NAME}; my $fnc = 'HMCommand'; my $io_hash = HMCCU_GetHash ($cl_hash); my $ccureqtimeout = AttrVal ($io_hash->{NAME}, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); my $url = HMCCU_BuildURL ($io_hash, 'rega'); my $value; HMCCU_Trace ($cl_hash, 2, $fnc, "URL=$url, cmd=$cmd"); my $param = { url => $url, timeout => $ccureqtimeout, data => $cmd, method => "POST" }; $param->{sslargs} = { SSL_verify_mode => 0 }; my ($err, $response) = HttpUtils_BlockingGet ($param); if ($err eq '') { $value = $response; $value =~ s/<xml>(.*)<\/xml>//; $value =~ s/\r//g; HMCCU_Trace ($cl_hash, 2, $fnc, "Response=$response, Value=".(defined ($value) ? $value : "undef")); } else { HMCCU_Log ($io_hash, 2, "Error during HTTP request: $err"); HMCCU_Trace ($cl_hash, 2, $fnc, "Response=".(defined($response) ? $response : 'undef')); return undef; } if ($mode == 1) { return (defined($value) && $value ne 'null') ? $value : undef; } else { return (defined($value) && $value ne '' && $value ne 'null') ? $value : undef; } } ###################################################################### # Execute Homematic command on CCU (non blocking). ###################################################################### sub HMCCU_HMCommandNB ($$$) { my ($clHash, $cmd, $cbFunc) = @_; my $clName = $clHash->{NAME}; my $fnc = 'HMCommandNB'; my $ioHash = HMCCU_GetHash ($clHash); my $ccureqtimeout = AttrVal ($ioHash->{NAME}, 'ccuReqTimeout', $HMCCU_TIMEOUT_REQUEST); my $url = HMCCU_BuildURL ($ioHash, 'rega'); HMCCU_Trace ($clHash, 2, $fnc, "URL=$url"); if (defined($cbFunc)) { my $param = { url => $url, timeout => $ccureqtimeout, data => $cmd, method => "POST", callback => $cbFunc, devhash => $clHash }; $param->{sslargs} = { SSL_verify_mode => 0 }; HttpUtils_NonblockingGet ($param); } else { my $param = { url => $url, timeout => $ccureqtimeout, data => $cmd, method => "POST", callback => \&HMCCU_HMCommandCB, devhash => $clHash }; $param->{sslargs} = { SSL_verify_mode => 0 }; HttpUtils_NonblockingGet ($param); } } ###################################################################### # Default callback function for non blocking CCU request. ###################################################################### sub HMCCU_HMCommandCB ($$$) { my ($param, $err, $data) = @_; my $hash = $param->{devhash}; my $fnc = 'HMCommandCB'; HMCCU_Log ($hash, 2, "Error during CCU request. $err") if ($err ne ''); HMCCU_Trace ($hash, 2, $fnc, "URL=".$param->{url}."<br>Response=$data"); } ###################################################################### # Execute Homematic script on CCU. # Parameters: device-hash, script-code or script-name, parameter-hash # If content of hmscript starts with a ! the following text is treated # as name of an internal HomeMatic script function defined in # HMCCUConf.pm. # If content of hmscript is enclosed in [] the content is treated as # HomeMatic script code. Characters [] will be removed. # Otherwise hmscript is the name of a file containing Homematic script # code. # Return script output or error message starting with "ERROR:". ###################################################################### sub HMCCU_HMScriptExt ($$$$$) { my ($hash, $hmscript, $params, $cbFunc, $cbParam) = @_; my $name = $hash->{NAME}; my $code = $hmscript; my $scrname = ''; if ($hash->{TYPE} ne 'HMCCU') { HMCCU_Log ($hash, 2, stacktraceAsString(undef)); } return HMCCU_LogError ($hash, 2, "CCU host name not defined") if (!exists ($hash->{host})); my $host = $hash->{host}; my $ccureqtimeout = AttrVal ($hash->{NAME}, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); if ($hmscript =~ /^!(.*)$/) { # Internal script $scrname = $1; return "ERROR: Can't find internal script $scrname" if (!exists ($HMCCU_SCRIPTS->{$scrname})); $code = $HMCCU_SCRIPTS->{$scrname}{code}; } elsif ($hmscript =~ /^\[(.*)\]$/) { # Script code $code = $1; } else { # Script file if (open (SCRFILE, "<$hmscript")) { my @lines = <SCRFILE>; $code = join ("\n", @lines); close (SCRFILE); } else { return "ERROR: Can't open script file"; } } # Check and replace variables if (defined($params)) { my @parnames = keys %{$params}; if ($scrname ne '') { if (scalar (@parnames) != $HMCCU_SCRIPTS->{$scrname}{parameters}) { return "ERROR: Wrong number of parameters. Usage: $scrname ". $HMCCU_SCRIPTS->{$scrname}{syntax}; } foreach my $p (split (/[, ]+/, $HMCCU_SCRIPTS->{$scrname}{syntax})) { return "ERROR: Missing definition of parameter $p" if (!exists ($params->{$p})); } } foreach my $svar (keys %{$params}) { next if ($code !~ /\$$svar/); $code =~ s/\$$svar/$params->{$svar}/g; } } else { if ($scrname ne '' && $HMCCU_SCRIPTS->{$scrname}{parameters} > 0) { return "ERROR: Wrong number of parameters. Usage: $scrname ". $HMCCU_SCRIPTS->{$scrname}{syntax}; } } HMCCU_Trace ($hash, 2, "HMScriptEx", $code); # Execute script on CCU my $url = HMCCU_BuildURL ($hash, 'rega'); if (defined ($cbFunc)) { # Non blocking my $param = { url => $url, timeout => $ccureqtimeout, data => $code, method => "POST", callback => $cbFunc, ioHash => $hash }; if (defined ($cbParam)) { foreach my $p (keys %{$cbParam}) { $param->{$p} = $cbParam->{$p}; } } $param->{sslargs} = { SSL_verify_mode => 0 }; HttpUtils_NonblockingGet ($param); return '' } # Blocking my $param = { url => $url, timeout => $ccureqtimeout, data => $code, method => "POST" }; $param->{sslargs} = { SSL_verify_mode => 0 }; my ($err, $response) = HttpUtils_BlockingGet ($param); if ($err eq '') { my $output = $response; $output =~ s/<xml>.*<\/xml>//; $output =~ s/\r//g; return $output; } else { HMCCU_Log ($hash, 2, "HMScript failed. $err"); return "ERROR: HMScript failed. $err"; } } ###################################################################### # Bulk update of reading considering attribute substexcl. ###################################################################### sub HMCCU_BulkUpdate ($$$$) { my ($hash, $reading, $orgval, $subval) = @_; my $name = $hash->{NAME}; my $excl = AttrVal ($name, 'substexcl', ''); readingsBulkUpdate ($hash, $reading, ($excl ne '' && $reading =~ /$excl/ ? $orgval : $subval)); } ###################################################################### # Get datapoint value from CCU and optionally update reading. # If parameter noupd is defined and > 0 no readings will be updated. ###################################################################### sub HMCCU_GetDatapoint ($@) { my ($cl_hash, $param, $noupd) = @_; my $cl_name = $cl_hash->{NAME}; my $fnc = 'GetDatapoint'; my $value = ''; my $io_hash = HMCCU_GetHash ($cl_hash); return (-3, $value) if (!defined ($io_hash)); return (-4, $value) if ($cl_hash->{TYPE} ne 'HMCCU' && $cl_hash->{ccudevstate} eq 'deleted'); my $readingformat = HMCCU_GetAttrReadingFormat ($cl_hash, $io_hash); my $substitute = HMCCU_GetAttrSubstitute ($cl_hash, $io_hash); my ($statechn, $statedpt, $controlchn, $controldpt) = HMCCU_GetSpecialDatapoints ($cl_hash); my $ccuget = HMCCU_GetAttribute ($io_hash, $cl_hash, 'ccuget', 'Value'); my $ccureqtimeout = AttrVal ($io_hash->{NAME}, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); my $cmd = ''; my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($io_hash, $param, $HMCCU_FLAG_INTERFACE); return (-1, $value) if ($flags != $HMCCU_FLAGS_IACD && $flags != $HMCCU_FLAGS_NCD); if ($flags == $HMCCU_FLAGS_IACD) { $cmd = 'Write((datapoints.Get("'.$int.'.'.$add.':'.$chn.'.'.$dpt.'")).'.$ccuget.'())'; } elsif ($flags == $HMCCU_FLAGS_NCD) { $cmd = 'Write((dom.GetObject(ID_CHANNELS)).Get("'.$nam.'").DPByHssDP("'.$dpt.'").'.$ccuget.'())'; ($add, $chn) = HMCCU_GetAddress ($io_hash, $nam, '', ''); } HMCCU_Trace ($cl_hash, 2, $fnc, "CMD=$cmd, param=$param, ccuget=$ccuget"); $value = HMCCU_HMCommand ($cl_hash, $cmd, 1); if (defined ($value) && $value ne '' && $value ne 'null') { if (!defined ($noupd) || $noupd == 0) { $value = HMCCU_UpdateSingleDatapoint ($cl_hash, $chn, $dpt, $value); } else { my $svalue = HMCCU_ScaleValue ($cl_hash, $chn, $dpt, $value, 0); $value = HMCCU_Substitute ($svalue, $substitute, 0, $chn, $dpt); } HMCCU_Trace ($cl_hash, 2, $fnc, "Value of $chn.$dpt = $value"); return (1, $value); } else { HMCCU_Log ($cl_hash, 1, "Error CMD = $cmd"); return (-2, ''); } } ###################################################################### # Set multiple values of parameter set. # Parameter params is a hash reference. Keys are parameter names. # Parameter address must be a device or a channel address. # If no paramSet is specified, VALUES is used by default. ###################################################################### sub HMCCU_SetMultipleParameters ($$$;$) { my ($clHash, $address, $params, $paramSet) = @_; $paramSet //= 'VALUES'; my ($add, $chn) = HMCCU_SplitChnAddr ($address); return -1 if ($paramSet eq 'VALUES' && !defined($chn)); foreach my $p (sort keys %$params) { return -8 if ( ($paramSet eq 'VALUES' && !HMCCU_IsValidDatapoint ($clHash, $clHash->{ccutype}, $chn, $p, 2)) || ($paramSet eq 'MASTER' && !HMCCU_IsValidParameter ($clHash, $address, $paramSet, $p)) ); $params->{$p} = HMCCU_ScaleValue ($clHash, $chn, $p, $params->{$p}, 1); } return HMCCU_RPCRequest ($clHash, 'putParamset', $address, $paramSet, $params); } ###################################################################### # Set multiple datapoints on CCU in a single request. # Parameter params is a hash reference. Keys are full qualified CCU # datapoint specifications in format: # no.interface.{address|fhemdev}:channelno.datapoint # Parameter no defines the command order. ###################################################################### sub HMCCU_SetMultipleDatapoints ($$) { my ($clHash, $params) = @_; my $fnc = "SetMultipleDatapoints"; my $mdFlag = $clHash->{TYPE} eq 'HMCCU' ? 1 : 0; my $ioHash; if ($mdFlag) { $ioHash = $clHash; } else { $ioHash = HMCCU_GetHash ($clHash); return -3 if (!defined($ioHash)); } my $ioName = $ioHash->{NAME}; my $clName = $clHash->{NAME}; my $ccuFlags = HMCCU_GetFlags ($ioName); # Build Homematic script my $cmd = ''; foreach my $p (sort keys %$params) { my $v = $params->{$p}; # Check address. dev is either a device address or a FHEM device name my ($no, $int, $addchn, $dpt) = split (/\./, $p); return -1 if (!defined ($dpt)); my ($dev, $chn) = split (':', $addchn); return -1 if (!defined ($chn)); my $add = $dev; # Get hash of FHEM device if ($mdFlag) { return -1 if (!exists ($defs{$dev})); $clHash = $defs{$dev}; ($add, undef) = HMCCU_SplitChnAddr ($clHash->{ccuaddr}); } # Device has been deleted or is disabled return -4 if (exists ($clHash->{ccudevstate}) && $clHash->{ccudevstate} eq 'deleted'); return -21 if (IsDisabled ($clHash->{NAME})); HMCCU_Trace ($clHash, 2, $fnc, "dpt=$p, value=$v"); # Check client device type and datapoint my $clType = $clHash->{TYPE}; my $ccuType = $clHash->{ccutype}; return -1 if ($clType ne 'HMCCUCHN' && $clType ne 'HMCCUDEV'); if (!HMCCU_IsValidDatapoint ($clHash, $ccuType, $chn, $dpt, 2)) { HMCCU_Trace ($clHash, 2, $fnc, "Invalid datapoint $chn $dpt"); return -8; } my $ccuVerify = AttrVal ($clName, 'ccuverify', 0); my $ccuChange = AttrVal ($clName, 'ccuSetOnChange', 'null'); # Build device address list considering group devices my @addrList = $clHash->{ccuif} eq 'fhem' ? split (',', $clHash->{ccugroup}) : ($add); return -1 if (scalar (@addrList) < 1); foreach my $a (@addrList) { # Override address and interface of group device with address of group members if ($clHash->{ccuif} eq 'fhem') { ($add, undef) = HMCCU_SplitChnAddr ($a); $int = HMCCU_GetDeviceInterface ($ioHash, $a, ''); return -20 if ($int eq ''); } if ($ccuType eq 'HM-Dis-EP-WM55' && $dpt eq 'SUBMIT') { $v = HMCCU_EncodeEPDisplay ($v); } else { if ($v =~ /^[\$\%]{1,2}([0-9]{1,2}\.[A-Z0-9_]+)$/ && exists($clHash->{hmccu}{dp}{"$1"})) { $v = HMCCU_SubstVariables ($clHash, $v, undef); } else { $v = HMCCU_ScaleValue ($clHash, $chn, $dpt, $v, 1); } } my $dptType = HMCCU_GetDatapointAttr ($ioHash, $ccuType, $chn, $dpt, 'type'); $v = "'".$v."'" if (defined ($dptType) && $dptType == $HMCCU_TYPE_STRING); my $c = '(datapoints.Get("'.$int.'.'.$add.':'.$chn.'.'.$dpt.'")).State('.$v.");\n"; if ($dpt =~ /$ccuChange/) { $cmd .= 'if((datapoints.Get("'.$int.'.'.$add.':'.$chn.'.'.$dpt.'")).Value() != '.$v.") {\n$c}\n"; } else { $cmd .= $c; } } } if ($ccuFlags =~ /nonBlocking/) { # Execute command (non blocking) HMCCU_HMCommandNB ($clHash, $cmd, undef); return 0; } # Execute command (blocking) my $response = HMCCU_HMCommand ($clHash, $cmd, 1); return defined($response) ? 0 : -2; # Datapoint verification ??? } ###################################################################### # Scale, spread and/or shift datapoint value. # Mode: 0 = Get/Divide, 1 = Set/Multiply # Supports reversing of value if value range is specified. Syntax for # Rule is: # [ChannelNo.]Datapoint:Factor # [!][ChannelNo.]Datapoint:Min:Max:Range1:Range2 # If Datapoint name starts with a ! the value is reversed. In case of # an error original value is returned. ###################################################################### sub HMCCU_ScaleValue ($$$$$) { my ($hash, $chnno, $dpt, $value, $mode) = @_; my $name = $hash->{NAME}; my $ioHash = HMCCU_GetHash ($hash); my $ccuscaleval = AttrVal ($name, 'ccuscaleval', ''); if ($ccuscaleval ne '') { my @sl = split (',', $ccuscaleval); foreach my $sr (@sl) { my $f = 1.0; my @a = split (':', $sr); my $n = scalar (@a); next if ($n != 2 && $n != 5); my $rev = 0; my $dn = $a[0]; my $cn = $chnno; if ($dn =~ /^\!(.+)$/) { # Invert $dn = $1; $rev = 1; } if ($dn =~ /^([0-9]{1,2})\.(.+)$/) { # Compare channel number $cn = $1; $dn = $2; } next if ($dpt ne $dn || ($chnno ne '' && $cn ne $chnno)); if ($n == 2) { $f = ($a[1] == 0.0) ? 1.0 : $a[1]; return ($mode == 0) ? $value/$f : $value*$f; } else { # Do not scale if value out of range or interval wrong return $value if ($a[1] > $a[2] || $a[3] > $a[4]); return $value if ($mode == 0 && ($value < $a[1] || $value > $a[2])); return $value if ($mode == 1 && ($value < $a[3] || $value > $a[4])); # Reverse value if ($rev) { my $dr = ($mode == 0) ? $a[1]+$a[2] : $a[3]+$a[4]; $value = $dr-$value; } my $d1 = $a[2]-$a[1]; my $d2 = $a[4]-$a[3]; return $value if ($d1 == 0.0 || $d2 == 0.0); $f = $d1/$d2; return ($mode == 0) ? $value/$f+$a[3] : ($value-$a[3])*$f; } } } if ($dpt eq 'LEVEL') { return ($mode == 0) ? HMCCU_Min($value,100.0)/100.0 : HMCCU_Min($value,1.0)*100.0; } elsif ($dpt =~ /^P[0-9]_ENDTIME/) { if ($mode == 0) { my $hh = sprintf ("%02d", int($value/60)); my $mm = sprintf ("%02d", $value%60); return "$hh:$mm"; } else { my ($hh, $mm) = split (':', $value); $mm = 0 if (!defined($mm)); return $hh*60+$mm; } } # my $address = $hash->{TYPE} eq 'HMCCUDEV' ? $hash->{ccuaddr}.":$chnno" : $hash->{ccuaddr}; # my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $address, $hash->{ccuif}); # if (defined($devDesc)) { # my $devModel = HMCCU_GetDeviceModel ($ioHash, $devDesc->{_model}, $devDesc->{_fw_ver}, $chnno); # if (defined($devModel)) { # if ($devDesc->{TYPE} eq 'BLIND' || $devDesc->{TYPE} eq 'DIMMER' && $dpt eq 'LEVEL') { # my $f = $devModel->{VALUES}{LEVEL}{MAX}-$devModel->{VALUES}{LEVEL}{MIN}; # $f = 1.0 if (!defined($f) || $f == 0.0); # return ($mode == 0) ? $value/$f : $value*$f; # } # } # } return $value; } ###################################################################### # Get CCU system variables and update readings. # System variable readings are stored in I/O device. Unsupported # characters in variable names are substituted. ###################################################################### sub HMCCU_GetVariables ($$) { my ($hash, $pattern) = @_; my $name = $hash->{NAME}; my $count = 0; my $result = ''; my $ccureadings = AttrVal ($name, 'ccureadings', HMCCU_IsFlag ($name, 'noReadings') ? 0 : 1); my $response = HMCCU_HMScriptExt ($hash, "!GetVariables", undef, undef, undef); return (-2, $response) if ($response eq '' || $response =~ /^ERROR:.*/); readingsBeginUpdate ($hash) if ($ccureadings); foreach my $vardef (split /[\n\r]+/, $response) { my @vardata = split /=/, $vardef; next if (@vardata != 3 || $vardata[0] !~ /$pattern/); my $rn = HMCCU_CorrectName ($vardata[0]); my $value = HMCCU_FormatReadingValue ($hash, $vardata[2], $vardata[0]); readingsBulkUpdate ($hash, $rn, $value) if ($ccureadings); $result .= $vardata[0].'='.$vardata[2]."\n"; $count++; } readingsEndUpdate ($hash, 1) if ($ccureadings); return ($count, $result); } ###################################################################### # Timer function for periodic update of CCU system variables. ###################################################################### sub HMCCU_UpdateVariables ($) { my ($hash) = @_; if (exists($hash->{hmccu}{ccuvarspat})) { HMCCU_GetVariables ($hash, $hash->{hmccu}{ccuvarspat}); InternalTimer (gettimeofday ()+$hash->{hmccu}{ccuvarsint}, 'HMCCU_UpdateVariables', $hash); } } ###################################################################### # Set CCU system variable. If parameter vartype is undefined system # variable must exist in CCU. Following variable types are supported: # bool, list, number, text. Parameter params is a hash reference of # script parameters. # Return 0 on success, error code on error. ###################################################################### sub HMCCU_SetVariable ($$$$$) { my ($hash, $varname, $value, $vartype, $params) = @_; my $name = $hash->{NAME}; my $ccureqtimeout = AttrVal ($name, "ccuReqTimeout", $HMCCU_TIMEOUT_REQUEST); my %varfnc = ( 'bool' => '!CreateBoolVariable', 'list', '!CreateListVariable', 'number' => '!CreateNumericVariable', 'text', '!CreateStringVariable' ); if (!defined($vartype)) { my $cmd = qq(dom.GetObject("$varname").State("$value")); my $response = HMCCU_HMCommand ($hash, $cmd, 1); return HMCCU_Log ($hash, 1, "CMD=$cmd", -2) if (!defined($response)); } else { return -18 if (!exists($varfnc{$vartype})); # Set default values for variable attributes $params->{name} = $varname if (!exists ($params->{name})); $params->{init} = $value if (!exists ($params->{init})); $params->{unit} = '' if (!exists ($params->{unit})); $params->{desc} = '' if (!exists ($params->{desc})); $params->{min} = '0' if ($vartype eq 'number' && !exists ($params->{min})); $params->{max} = '65000' if ($vartype eq 'number' && !exists ($params->{max})); $params->{list} = $value if ($vartype eq 'list' && !exists ($params->{list})); $params->{valtrue} = 'ist wahr' if ($vartype eq 'bool' && !exists ($params->{valtrue})); $params->{valfalse} = 'ist falsch' if ($vartype eq 'bool' && !exists ($params->{valfalse})); my $rc = HMCCU_HMScriptExt ($hash, $varfnc{$vartype}, $params, undef, undef); return HMCCU_Log ($hash, 1, $rc, -2) if ($rc =~ /^ERROR:.*/); } return 0; } ###################################################################### # Update all datapoints / readings of device or channel considering # attribute ccureadingfilter. # Parameter $ccuget can be 'State', 'Value' or 'Attr'. # Return 1 on success, <= 0 on error ###################################################################### sub HMCCU_GetUpdate ($$$) { my ($clHash, $addr, $ccuget) = @_; my $name = $clHash->{NAME}; my $type = $clHash->{TYPE}; my $fnc = 'GetUpdate'; return 1 if (AttrVal ($name, 'disable', 0) == 1); my $ioHash = HMCCU_GetHash ($clHash); return -3 if (!defined($ioHash)); return -4 if ($type ne 'HMCCU' && $clHash->{ccudevstate} eq 'deleted'); my $nam = ''; my $list = ''; my $script = ''; $ccuget = HMCCU_GetAttribute ($ioHash, $clHash, 'ccuget', 'Value') if ($ccuget eq 'Attr'); if (HMCCU_IsValidChannel ($ioHash, $addr, $HMCCU_FL_ADDRESS)) { $nam = HMCCU_GetChannelName ($ioHash, $addr, ''); return -1 if ($nam eq ''); my ($stadd, $stchn) = split (':', $addr); my $stnam = HMCCU_GetChannelName ($ioHash, "$stadd:0", ''); $list = $stnam eq '' ? $nam : $stnam . "," . $nam; $script = "!GetDatapointsByChannel"; } elsif (HMCCU_IsValidDevice ($ioHash, $addr, $HMCCU_FL_ADDRESS)) { $nam = HMCCU_GetDeviceName ($ioHash, $addr, ''); return -1 if ($nam eq ''); $list = $nam if ($clHash->{ccuif} ne 'fhem'); $script = "!GetDatapointsByDevice"; # Consider members of group device if ($type eq 'HMCCUDEV' && (($clHash->{ccuif} eq 'VirtualDevices' && HMCCU_IsFlag ($ioHash, 'updGroupMembers'))|| $clHash->{ccuif} eq 'fhem') && exists($clHash->{ccugroup})) { foreach my $gd (split (",", $clHash->{ccugroup})) { $nam = HMCCU_GetDeviceName ($ioHash, $gd, ''); $list .= ','.$nam if ($nam ne ''); } } } else { return -1; } if (HMCCU_IsFlag ($ioHash->{NAME}, 'nonBlocking')) { # Non blocking request HMCCU_HMScriptExt ($ioHash, $script, { list => $list, ccuget => $ccuget }, \&HMCCU_UpdateCB, undef); return 1; } # Blocking request my $response = HMCCU_HMScriptExt ($ioHash, $script, { list => $list, ccuget => $ccuget }, undef, undef); HMCCU_Trace ($clHash, 2, $fnc, "Addr=$addr Name=$nam Script=$script<br>". "Script response = \n".$response); return -2 if ($response eq '' || $response =~ /^ERROR:.*/); HMCCU_UpdateCB ({ ioHash => $ioHash }, undef, $response); return 1; } ###################################################################### # Generic reading update callback function for non blocking HTTP # requests. # Format of $data: Newline separated list of datapoint values. # ChannelName=Interface.ChannelAddress.Datapoint=Value # Optionally last line can contain the number of datapoint lines. ###################################################################### sub HMCCU_UpdateCB ($$$) { my ($param, $err, $data) = @_; if (!exists ($param->{ioHash})) { Log3 1, undef, "HMCCU: Missing parameter ioHash in update callback"; return; } my $hash = $param->{ioHash}; my $logcount = 0; $logcount = 1 if (exists ($param->{logCount}) && $param->{logCount} == 1); my $count = 0; my @dpdef = split /[\n\r]+/, $data; my $lines = scalar (@dpdef); $count = ($lines > 0 && $dpdef[$lines-1] =~ /^[0-9]+$/) ? pop (@dpdef) : $lines; return if ($count == 0); my %events = (); foreach my $dp (@dpdef) { my ($chnname, $dpspec, $value) = split /=/, $dp; next if (!defined($value)); my ($iface, $chnadd, $dpt) = split /\./, $dpspec; next if (!defined($dpt)); my ($add, $chn) = ('', ''); if ($iface eq 'sysvar' && $chnadd eq 'link') { ($add, $chn) = HMCCU_GetAddress ($hash, $chnname, '', ''); } else { ($add, $chn) = HMCCU_SplitChnAddr ($chnadd); } next if ($chn eq ''); $events{$add}{$chn}{VALUES}{$dpt} = $value; } my $c_ok = HMCCU_UpdateMultipleDevices ($hash, \%events); my $c_err = 0; $c_err = HMCCU_Max($param->{devCount}-$c_ok, 0) if (exists ($param->{devCount})); HMCCU_Log ($hash, 2, "Update success=$c_ok failed=$c_err") if ($logcount); } ###################################################################### # Execute RPC request # Parameters: # $method - RPC request method. Use listParamset or listRawParamset # as an alias for getParamset if readings should not be updated. # $address - Device address. # $paramset - paramset name: VALUE, MASTER, LINK, ... If not defined # request does not affect a parameter set # $parref - Hash reference with parameter/value pairs or array # reference with parameter values (optional). # $filter - Regular expression for filtering response (default = .*). # Return (retCode, result). # retCode = 0 - Success # retCode < 0 - Error, result contains error message ###################################################################### sub HMCCU_RPCRequest ($$$$$;$) { my ($clHash, $method, $address, $paramset, $parref, $filter) = @_; $filter //= '.*'; my $name = $clHash->{NAME}; my $type = $clHash->{TYPE}; my $fnc = "RPCRequest"; my $reqMethod = $method eq 'listParamset' || $method eq 'listRawParamset' || $method eq 'getRawParamset' ? 'getParamset' : $method; my $addr = ''; my $result = ''; my $ioHash = HMCCU_GetHash ($clHash); return (-3, $result) if (!defined($ioHash)); return (-4, $result) if ($type ne 'HMCCU' && $clHash->{ccudevstate} eq 'deleted'); # Get flags and attributes my $ioFlags = HMCCU_GetFlags ($ioHash->{NAME}); my $clFlags = HMCCU_GetFlags ($name); my $ccureadings = AttrVal ($name, 'ccureadings', $clFlags =~ /noReadings/ ? 0 : 1); my $readingformat = HMCCU_GetAttrReadingFormat ($clHash, $ioHash); my $substitute = HMCCU_GetAttrSubstitute ($clHash, $ioHash); # Parse address, complete address information my ($int, $add, $chn, $dpt, $nam, $flags) = HMCCU_ParseObject ($ioHash, $address, $HMCCU_FLAG_FULLADDR); return (-1, $result) if (!($flags & $HMCCU_FLAG_ADDRESS)); $addr = $flags & $HMCCU_FLAG_CHANNEL ? "$add:$chn" : $add; # Get RPC type and port for interface of device address my ($rpcType, $rpcPort) = HMCCU_GetRPCServerInfo ($ioHash, $int, 'type,port'); return (-9, '') if (!defined($rpcType) || !defined($rpcPort)); # Search RPC device, do not create one my ($rpcDevice, $save) = HMCCU_GetRPCDevice ($ioHash, 0, $int); return (-17, $result) if ($rpcDevice eq ''); my $rpcHash = $defs{$rpcDevice}; # Build parameter array: (Address, Paramset [, Parameter ...]) # Paramset := VALUE | MASTER | LINK or any paramset supported by device # Parameter := Name=Value[:Type] my @parArray = ($addr); push (@parArray, $paramset) if (defined($paramset)); if (defined($parref)) { if (ref($parref) eq 'HASH') { foreach my $k (keys %{$parref}) { my ($pv, $pt) = split (':', $parref->{$k}); if (!defined($pt)) { my $paramDef = HMCCU_GetParamDef ($ioHash, $addr, $paramset, $k); $pt = defined($paramDef) && defined($paramDef->{TYPE}) && $paramDef->{TYPE} ne '' ? $paramDef->{TYPE} : "STRING"; } $pv .= ":$pt"; push @parArray, "$k=$pv"; } } elsif (ref($parref) eq 'ARRAY') { push @parArray, @$parref; } } # Submit RPC request my $reqResult = HMCCURPCPROC_SendRequest ($rpcHash, $reqMethod, @parArray); return (-5, 'RPC function not available') if (!defined($reqResult)); HMCCU_Trace ($clHash, 2, $fnc, "Dump of RPC request $method $addr. Result type=".ref($reqResult)."<br>". HMCCU_RefToString ($reqResult)); my $parCount = 0; if (ref($reqResult) eq 'HASH') { if (exists($reqResult->{faultString})) { HMCCU_Log ($rpcHash, 1, $reqResult->{faultString}); return (-2, $reqResult->{faultString}); } else { $parCount = keys %{$reqResult}; } } # else { # return (-2, defined ($RPC::XML::ERROR) ? $RPC::XML::ERROR : 'RPC request failed'); # } if ($method eq 'listParamset') { $result = join ("\n", map { $_ =~ /$filter/ ? $_.'='.$reqResult->{$_} : () } keys %$reqResult); } elsif ($method eq 'listRawParamset' || $method eq 'getRawParamset') { $result = $reqResult; } elsif ($method eq 'getDeviceDescription') { $result = ''; foreach my $k (sort keys %$reqResult) { if (ref($reqResult->{$k}) eq 'ARRAY') { $result .= "$k=".join(',', @{$reqResult->{$k}})."\n"; } else { $result .= "$k=".$reqResult->{$k}."\n"; } } } elsif ($method eq 'getParamsetDescription') { my %operFlags = ( 1 => 'R', 2 => 'W', 4 => 'E' ); $result = join ("\n", map { $_.': '. $reqResult->{$_}->{TYPE}. " [".HMCCU_BitsToStr(\%operFlags,$reqResult->{$_}->{OPERATIONS})."]". " FLAGS=".sprintf("%#b", $reqResult->{$_}->{FLAGS}). " RANGE=".$reqResult->{$_}->{MIN}."-".$reqResult->{$_}->{MAX}. " DFLT=".$reqResult->{$_}->{DEFAULT}. " UNIT=".$reqResult->{$_}->{UNIT} } sort keys %$reqResult); } elsif ($method eq 'getParamset') { readingsBeginUpdate ($clHash) if ($ccureadings); foreach my $k (sort keys %$reqResult) { next if ($k !~ /$filter/); my $value = $reqResult->{$k}; $result .= "$k=$value\n"; if ($ccureadings) { $value = HMCCU_FormatReadingValue ($clHash, $value, $k); $value = HMCCU_Substitute ($value, $substitute, 0, $chn, $k); my @readings = HMCCU_GetReadingName ($clHash, $int, $add, $chn, $k, $nam, $readingformat); foreach my $rn (@readings) { next if ($rn eq ''); $rn = "R-".$rn; readingsBulkUpdate ($clHash, $rn, $value); } } } readingsEndUpdate ($clHash, 1) if ($ccureadings); } else { $result = $reqResult; } return (0, $result); } ###################################################################### # *** HELPER FUNCTIONS *** ###################################################################### ###################################################################### # Return Prefix.Value if value is defined. Otherwise default. ###################################################################### sub HMCCU_DefStr ($;$$) { my ($v, $p, $d) = @_; $p = '' if (!defined($p)); $d = '' if (!defined($d)); return defined($v) && $v ne '' ? $p.$v : $d; } ###################################################################### # Convert string from ISO-8859-1 to UTF-8 ###################################################################### sub HMCCU_ISO2UTF ($) { my ($t) = @_; return encode("UTF-8", decode("iso-8859-1", $t)); } ###################################################################### # Check for floating point number ###################################################################### sub HMCCU_IsFltNum ($) { my ($value) = @_; return defined($value) && $value =~ /^[+-]?\d*\.?\d+(?:(?:e|E)\d+)?$/ ? 1 : 0; } ###################################################################### # Check for integer number ###################################################################### sub HMCCU_IsIntNum ($) { my ($value) = @_; return defined($value) && $value =~ /^[+-]?[0-9]+$/ ? 1 : 0; } ###################################################################### # Get device state from maintenance channel 0 # Return values for readings (devState, battery, alive) # Default is unknown for each reading ###################################################################### sub HMCCU_GetDeviceStates ($) { my ($clHash) = @_; my %stName = ( '0.AES_KEY' => 'sign', '0.CONFIG_PENDING' => 'cfgPending', '0.DEVICE_IN_BOOTLOADER' => 'boot', '0.STICKY_UNREACH' => 'stickyUnreach', '0.UPDATE_PENDING' => 'updPending' ); my @batName = ('0.LOWBAT', '0.LOW_BAT'); my @values = ('unknown', 'unknown', 'unknown'); if (exists($clHash->{hmccu}{dp})) { # Get device state my @state = (); foreach my $dp (keys %stName) { push @state, $stName{$dp} if (exists($clHash->{hmccu}{dp}{$dp}) && exists($clHash->{hmccu}{dp}{$dp}{VALUES}) && defined($clHash->{hmccu}{dp}{$dp}{VALUES}{VAL}) && $clHash->{hmccu}{dp}{$dp}{VALUES}{VAL} =~ /^(1|true)$/); } $values[0] = scalar(@state) > 0 ? join(',', @state) : 'ok'; # Get battery foreach my $bs (@batName) { if (exists($clHash->{hmccu}{dp}{$bs})) { $values[1] = $clHash->{hmccu}{dp}{$bs}{VALUES}{VAL} =~ /1|true/ ? 'low' : 'ok'; last; } } # Get connectivity state if (exists($clHash->{hmccu}{dp}{'0.UNREACH'})) { $values[2] = $clHash->{hmccu}{dp}{'0.UNREACH'}{VALUES}{VAL} =~ /1|true/ ? 'dead' : 'alive'; } } return @values; } ###################################################################### # Determine HomeMatic state considering datapoint values specified # in attributes ccudef-hmstatevals and hmstatevals. # Return (reading, channel, datapoint, value) ###################################################################### sub HMCCU_GetHMState ($$$) { my ($name, $ioname, $defval) = @_; my @hmstate = ('hmstate', undef, undef, $defval); my $fnc = "GetHMState"; my $clhash = $defs{$name}; my $cltype = $clhash->{TYPE}; return @hmstate if ($cltype ne 'HMCCUDEV' && $cltype ne 'HMCCUCHN'); my $ghmstatevals = AttrVal ($ioname, 'ccudef-hmstatevals', $HMCCU_DEF_HMSTATE); my $hmstatevals = AttrVal ($name, 'hmstatevals', $ghmstatevals); $hmstatevals .= ";".$ghmstatevals if ($hmstatevals ne $ghmstatevals); # Get reading name if ($hmstatevals =~ /^=([^;]*);/) { $hmstate[0] = $1; $hmstatevals =~ s/^=[^;]*;//; } # Default hmstate is equal to state $hmstate[3] = ReadingsVal ($name, 'state', undef) if (!defined ($defval)); # Substitute variables $hmstatevals = HMCCU_SubstVariables ($clhash, $hmstatevals, undef); foreach my $rule (split (';', $hmstatevals)) { my ($dptexpr, $subst) = split ('!', $rule, 2); my $dp = ''; next if (!defined ($dptexpr) || !defined ($subst)); foreach my $d (keys %{$clhash->{hmccu}{dp}}) { if ($d =~ /$dptexpr/) { $dp = $d; last; } } next if ($dp eq ''); my ($chn, $dpt) = split (/\./, $dp); if (exists($clhash->{hmccu}{dp}{$dp}) && exists($clhash->{hmccu}{dp}{$dp}{VALUES}{VAL})) { my $value = HMCCU_FormatReadingValue ($clhash, $clhash->{hmccu}{dp}{$dp}{VALUES}{VAL}, $hmstate[0]); my ($rc, $newvalue) = HMCCU_SubstRule ($value, $subst, 0); return ($hmstate[0], $chn, $dpt, $newvalue) if ($rc); } } return @hmstate; } ###################################################################### # Calculate time difference in seconds between current time and # specified timestamp ###################################################################### sub HMCCU_GetTimeSpec ($) { my ($ts) = @_; return -1 if ($ts !~ /^[0-9]{2}:[0-9]{2}$/ && $ts !~ /^[0-9]{2}:[0-9]{2}:[0-9]{2}$/); my (undef, $h, $m, $s) = GetTimeSpec ($ts); return -1 if (!defined($h)); $s += $h*3600+$m*60; my @lt = localtime; my $cs = $lt[2]*3600+$lt[1]*60+$lt[0]; $s += 86400 if ($cs > $s); return ($s-$cs); } ###################################################################### # Get minimum of 2 values ###################################################################### sub HMCCU_Min ($$) { my ($a, $b) = @_; return $a < $b ? $a : $b; } ###################################################################### # Get maximum of 2 values ###################################################################### sub HMCCU_Max ($$) { my ($a, $b) = @_; return $a > $b ? $a : $b; } ###################################################################### # Build ReGa or RPC client URL # Parameter backend specifies type of URL, 'rega' or name or port of # RPC interface. # Return empty string on error. ###################################################################### sub HMCCU_BuildURL ($$) { my ($hash, $backend) = @_; my $name = $hash->{NAME}; my $url = ''; my $username = ''; my $password = ''; my ($erruser, $encuser) = getKeyValue ($name."_username"); my ($errpass, $encpass) = getKeyValue ($name."_password"); if (!defined ($erruser) && !defined ($errpass) && defined ($encuser) && defined ($encpass)) { $username = HMCCU_Decrypt ($encuser); $password = HMCCU_Decrypt ($encpass); } my $auth = ($username ne '' && $password ne '') ? "$username:$password".'@' : ''; if ($backend eq 'rega') { $url = $hash->{prot}."://$auth".$hash->{host}.":". $HMCCU_REGA_PORT{$hash->{prot}}."/tclrega.exe"; } else { ($url) = HMCCU_GetRPCServerInfo ($hash, $backend, 'url'); if (defined ($url)) { if (exists ($HMCCU_RPC_SSL{$backend})) { my $p = $hash->{prot} eq 'https' ? '4' : ''; $url =~ s/^http:\/\//$hash->{prot}:\/\/$auth/; $url =~ s/:([0-9]+)/:$p$1/; } } else { $url = ''; } } HMCCU_Log ($hash, 4, "Build URL = $url"); return $url; } ###################################################################### # Calculate special readings. Requires hash of client device, channel # number and datapoint. Supported functions: # dewpoint, absolute humidity, increasing/decreasing counters, # minimum/maximum, average, sum, set. # Return readings array with reading/value pairs. ###################################################################### sub HMCCU_CalculateReading ($$) { my ($cl_hash, $chkeys) = @_; my $name = $cl_hash->{NAME}; my $fnc = "HMCCU_CalculateReading"; my @result = (); my $ccucalculate = AttrVal ($name, 'ccucalculate', ''); return @result if ($ccucalculate eq ''); my @calclist = split (/[;\n]+/, $ccucalculate); foreach my $calculation (@calclist) { my ($vt, $rn, $dpts) = split (':', $calculation, 3); next if (!defined ($dpts)); my $tmpdpts = ",$dpts,"; $tmpdpts =~ s/[\$\%\{\}]+//g; HMCCU_Trace ($cl_hash, 2, $fnc, "vt=$vt, rn=$rn, dpts=$dpts, tmpdpts=$tmpdpts"); my $f = 0; foreach my $chkey (@$chkeys) { if ($tmpdpts =~ /,$chkey,/) { $f = 1; last; } } next if ($f == 0); my @dplist = split (',', $dpts); # Get parameters values stored in device hash my $newdpts = HMCCU_SubstVariables ($cl_hash, $dpts, undef); my @pars = split (',', $newdpts); my $pc = scalar (@pars); next if ($pc != scalar(@dplist)); $f = 0; for (my $i=0; $i<$pc; $i++) { $pars[$i] =~ s/^#//; if ($pars[$i] eq $dplist[$i]) { $f = 1; last; } } next if ($f); if ($vt eq 'dewpoint' || $vt eq 'abshumidity') { # Dewpoint and absolute humidity next if ($pc < 2); my ($tmp, $hum) = @pars; if ($tmp >= 0.0) { $a = 7.5; $b = 237.3; } else { $a = 7.6; $b = 240.7; } my $sdd = 6.1078*(10.0**(($a*$tmp)/($b+$tmp))); my $dd = $hum/100.0*$sdd; if ($dd != 0.0) { if ($vt eq 'dewpoint') { my $v = log($dd/6.1078)/log(10.0); my $td = $b*$v/($a-$v); push (@result, $rn, (sprintf "%.1f", $td)); } else { my $af = 100000.0*18.016/8314.3*$dd/($tmp+273.15); push (@result, $rn, (sprintf "%.1f", $af)); } } } elsif ($vt eq 'equ') { # Set reading to value if all variables have the same value next if ($pc < 1); my $curval = shift @pars; my $f = 1; foreach my $newval (@pars) { $f = 0 if ("$newval" ne "$curval"); } push (@result, $rn, $f ? $curval : "n/a"); } elsif ($vt eq 'min' || $vt eq 'max') { # Minimum or maximum values next if ($pc < 1); my $curval = $pc > 1 ? shift @pars : ReadingsVal ($name, $rn, 0); foreach my $newval (@pars) { $curval = $newval if ($vt eq 'min' && $newval < $curval); $curval = $newval if ($vt eq 'max' && $newval > $curval); } push (@result, $rn, $curval); } elsif ($vt eq 'inc' || $vt eq 'dec') { # Increasing or decreasing values without reset next if ($pc < 1); my $newval = shift @pars; my $oldval = ReadingsVal ($name, $rn."_old", 0); my $curval = ReadingsVal ($name, $rn, 0); if (($vt eq 'inc' && $newval < $curval) || ($vt eq 'dec' && $newval > $curval)) { $oldval = $curval; push (@result, $rn."_old", $oldval); } $curval = $newval+$oldval; push (@result, $rn, $curval); } elsif ($vt eq 'avg') { # Average value next if ($pc < 1); if ($pc == 1) { my $newval = shift @pars; my $cnt = ReadingsVal ($name, $rn."_cnt", 0); my $sum = ReadingsVal ($name, $rn."_sum", 0); $cnt++; $sum += $newval; my $curval = $sum/$cnt; push (@result, $rn."_cnt", $cnt, $rn."_sum", $sum, $rn, $curval); } else { my $sum = 0; foreach my $p (@pars) { $sum += $p; } push (@result, $rn, $sum/scalar(@pars)); } } elsif ($vt eq 'sum') { # Sum of values next if ($pc < 1); my $curval = $pc > 1 ? 0 : ReadingsVal ($name, $rn, 0); foreach my $newval (@pars) { $curval += $newval; } push (@result, $rn, $curval); } elsif ($vt eq 'or') { # Logical OR next if ($pc < 1); my $curval = $pc > 1 ? 0 : ReadingsVal ($name, $rn, 0); foreach my $newval (@pars) { $curval |= $newval; } push (@result, $rn, $curval); } elsif ($vt eq 'and') { # Logical AND next if ($pc < 1); my $curval = $pc > 1 ? 1 : ReadingsVal ($name, $rn, 1); foreach my $newval (@pars) { $curval &= $newval; } push (@result, $rn, $curval); } elsif ($vt eq 'set') { # Set reading to value next if ($pc < 1); push (@result, $rn, join('', @pars)); } } return @result; } ###################################################################### # Encrypt string with FHEM unique ID ###################################################################### sub HMCCU_Encrypt ($) { my ($istr) = @_; my $ostr = ''; my $id = getUniqueId(); return '' if (!defined($id) || $id eq ''); my $key = $id; foreach my $c (split //, $istr) { my $k = chop($key); if ($k eq '') { $key = $id; $k = chop($key); } $ostr .= sprintf ("%.2x",ord($c)^ord($k)); } return $ostr; } ###################################################################### # Decrypt string with FHEM unique ID ###################################################################### sub HMCCU_Decrypt ($) { my ($istr) = @_; my $ostr = ''; my $id = getUniqueId(); return '' if (!defined($id) || $id eq ''); my $key = $id; for my $c (map { pack('C', hex($_)) } ($istr =~ /(..)/g)) { my $k = chop($key); if ($k eq '') { $key = $id; $k = chop($key); } $ostr .= chr(ord($c)^ord($k)); } return $ostr; } ###################################################################### # Delete readings matching regular expression. # Default for rnexp is .* # Readings 'state' and 'control' are ignored. ###################################################################### sub HMCCU_DeleteReadings ($$) { my ($hash, $rnexp) = @_; $rnexp = '.*' if (!defined ($rnexp)); my @readlist = keys %{$hash->{READINGS}}; foreach my $rd (@readlist) { readingsDelete ($hash, $rd) if ($rd ne 'state' && $rd ne 'control' && $rd =~ /$rnexp/); } } ###################################################################### # Update readings from hash ###################################################################### sub HMCCU_UpdateReadings ($$) { my ($hash, $readings) = @_; readingsBeginUpdate ($hash); foreach my $rn (keys %{$readings}) { readingsBulkUpdate ($hash, $rn, $readings->{$rn}); } readingsEndUpdate ($hash, 1); } ###################################################################### # Encode command string for e-paper display # # Parameters: # # msg := parameter=value[,...] # # text1-3=Text # icon1-3=IconName # sound=SoundName # signal=SignalName # pause=1-160 # repeat=0-15 # # Returns undef on error or encoded string on success ###################################################################### sub HMCCU_EncodeEPDisplay ($) { my ($msg) = @_; $msg //= ''; my %disp_icons = ( ico_off => '0x80', ico_on => '0x81', ico_open => '0x82', ico_closed => '0x83', ico_error => '0x84', ico_ok => '0x85', ico_info => '0x86', ico_newmsg => '0x87', ico_svcmsg => '0x88' ); my %disp_sounds = ( snd_off => '0xC0', snd_longlong => '0xC1', snd_longshort => '0xC2', snd_long2short => '0xC3', snd_short => '0xC4', snd_shortshort => '0xC5', snd_long => '0xC6' ); my %disp_signals = ( sig_off => '0xF0', sig_red => '0xF1', sig_green => '0xF2', sig_orange => '0xF3' ); # Parse command string my @text = ('', '', ''); my @icon = ('', '', ''); my %conf = (sound => 'snd_off', signal => 'sig_off', repeat => 1, pause => 10); foreach my $tok (split (',', $msg)) { my ($par, $val) = split ('=', $tok); next if (!defined($val)); if ($par =~ /^text([1-3])$/) { $text[$1-1] = substr ($val, 0, 12); } elsif ($par =~ /^icon([1-3])$/) { $icon[$1-1] = $val; } elsif ($par =~ /^(sound|pause|repeat|signal)$/) { $conf{$1} = $val; } } my $cmd = '0x02,0x0A'; for (my $c=0; $c<3; $c++) { if ($text[$c] ne '' || $icon[$c] ne '') { $cmd .= ',0x12'; # Hex code if ($text[$c] =~ /^0x[0-9A-F]{2}$/) { $cmd .= ','.$text[$c]; } # Predefined text code #0-9 elsif ($text[$c] =~ /^#([0-9])$/) { $cmd .= sprintf (",0x8%1X", $1); } # Convert string to hex codes else { $text[$c] =~ s/\\_/ /g; foreach my $ch (split ('', $text[$c])) { $cmd .= sprintf (",0x%02X", ord ($ch)); } } # Icon if ($icon[$c] ne '' && exists ($disp_icons{$icon[$c]})) { $cmd .= ',0x13,'.$disp_icons{$icon[$c]}; } } $cmd .= ',0x0A'; } # Sound my $snd = $disp_sounds{snd_off}; $snd = $disp_sounds{$conf{sound}} if (exists ($disp_sounds{$conf{sound}})); $cmd .= ',0x14,'.$snd.',0x1C'; # Repeat my $rep = $conf{repeat} if ($conf{repeat} >= 0 && $conf{repeat} <= 15); $rep = 1 if ($rep < 0); $rep = 15 if ($rep > 15); if ($rep == 0) { $cmd .= ',0xDF'; } else { $cmd .= sprintf (",0x%02X", 0xD0+$rep-1); } $cmd .= ',0x1D'; # Pause my $pause = $conf{pause}; $pause = 1 if ($pause < 1); $pause = 160 if ($pause > 160); $cmd .= sprintf (",0xE%1X,0x16", int(($pause-1)/10)); # Signal my $sig = $disp_signals{sig_off}; $sig = $disp_signals{$conf{signal}} if(exists ($disp_signals{$conf{signal}})); $cmd .= ','.$sig.',0x03'; return $cmd; } ###################################################################### # Convert reference to string recursively # Supports reference to ARRAY, HASH and SCALAR and scalar values. ###################################################################### sub HMCCU_RefToString ($) { my ($r) = @_; my $result = ''; if (ref($r) eq 'ARRAY') { $result .= "[\n"; foreach my $e (@$r) { $result .= "," if ($result ne '['); $result .= HMCCU_RefToString ($e); } $result .= "\n]"; } elsif (ref($r) eq 'HASH') { $result .= "{\n"; foreach my $k (sort keys %$r) { $result .= "," if ($result ne '{'); $result .= "$k=".HMCCU_RefToString ($r->{$k}); } $result .= "\n}"; } elsif (ref($r) eq 'SCALAR') { $result .= $$r; } else { $result .= $r; } return $result; } sub HMCCU_BitsToStr ($$) { my ($chrMap, $bMask) = @_; my $r = ''; foreach my $bVal (sort keys %$chrMap) { $r .= $chrMap->{$bVal} if ($bMask & $bVal); } return $r; } ###################################################################### # Match string with regular expression considering illegal regular # expressions. # Return parameter e if regular expression is incorrect. ###################################################################### sub HMCCU_ExprMatch ($$$) { my ($t, $r, $e) = @_; my $x = eval { $t =~ /$r/ }; return $e if (!defined($x)); return "$x" eq '' ? 0 : 1; } sub HMCCU_ExprNotMatch ($$$) { my ($t, $r, $e) = @_; my $x = eval { $t !~ /$r/ }; return $e if (!defined($x)); return "$x" eq '' ? 0 : 1; } ###################################################################### # Read duty cycles of interfaces 2001 and 2010 and update readings. ###################################################################### sub HMCCU_GetDutyCycle ($) { my ($hash) = @_; my $dc = 0; my @rpcports = HMCCU_GetRPCPortList ($hash); readingsBeginUpdate ($hash); foreach my $port (@rpcports) { next if ($port != 2001 && $port != 2010); my $url = HMCCU_BuildURL ($hash, $port); next if (!defined($url)); my $rpcclient = RPC::XML::Client->new ($url); my $response = $rpcclient->simple_request ("listBidcosInterfaces"); next if (!defined ($response) || ref($response) ne 'ARRAY'); foreach my $iface (@$response) { next if (ref($iface) ne 'HASH' || !exists ($iface->{DUTY_CYCLE})); $dc++; my $type; if (exists($iface->{TYPE})) { $type = $iface->{TYPE} } else { ($type) = HMCCU_GetRPCServerInfo ($hash, $port, 'name'); } readingsBulkUpdate ($hash, "iface_addr_$dc", $iface->{ADDRESS}); readingsBulkUpdate ($hash, "iface_conn_$dc", $iface->{CONNECTED}); readingsBulkUpdate ($hash, "iface_type_$dc", $type); readingsBulkUpdate ($hash, "iface_ducy_$dc", $iface->{DUTY_CYCLE}); } } readingsEndUpdate ($hash, 1); return $dc; } ###################################################################### # Check if TCP port is reachable. # Parameter timeout should be a multiple of 20 plus 5. ###################################################################### sub HMCCU_TCPPing ($$$) { my ($addr, $port, $timeout) = @_; if ($timeout > 0) { my $t = time (); while (time () < $t+$timeout) { return 1 if (HMCCU_TCPConnect ($addr, $port) ne ''); sleep (20); } return 0; } else { return HMCCU_TCPConnect ($addr, $port) eq '' ? 0 : 1; } } ###################################################################### # Check if TCP connection to specified host and port is possible. # Return empty string on error or local IP address on success. ###################################################################### sub HMCCU_TCPConnect ($$) { my ($addr, $port) = @_; my $socket = IO::Socket::INET->new (PeerAddr => $addr, PeerPort => $port); if ($socket) { my $ipaddr = $socket->sockhost (); close ($socket); return $ipaddr if (defined ($ipaddr)); } return ''; } ###################################################################### # Generate a 6 digit Id from last 2 segments of IP address ###################################################################### sub HMCCU_GetIdFromIP ($$) { my ($ip, $default) = @_; my @ipseg = split (/\./, $ip); return scalar(@ipseg) == 4 ? sprintf ("%03d%03d", $ipseg[2], $ipseg[3]) : $default; } ###################################################################### # Resolve hostname. # Return value defIP if hostname can't be resolved. ###################################################################### sub HMCCU_ResolveName ($$) { my ($host, $defIP) = @_; my $addrNum = inet_aton ($host); return defined($addrNum) ? inet_ntoa ($addrNum) : $defIP; } ###################################################################### # Substitute invalid characters in reading name. # Substitution rules: ':' => '.', any other illegal character => '_' ###################################################################### sub HMCCU_CorrectName ($) { my ($rn) = @_; $rn =~ s/\:/\./g; $rn =~ s/[^A-Za-z\d_\.-]+/_/g; return $rn; } ###################################################################### # Get N biggest hash entries # Format of returned hash is # {0..entries-1}{k} = Key of hash entry # {0..entries-1}{v} = Value of hash entry ###################################################################### sub HMCCU_MaxHashEntries ($$) { my ($hash, $entries) = @_; my %result; while (my ($key, $value) = each %$hash) { for (my $i=0; $i<$entries; $i++) { if (!exists ($result{$i}) || $value > $result{$i}{v}) { for (my $j=$entries-1; $j>$i; $j--) { if (exists ($result{$j-1})) { $result{$j}{k} = $result{$j-1}{k}; $result{$j}{v} = $result{$j-1}{v}; } } $result{$i}{v} = $value; $result{$i}{k} = $key; last; } } } return \%result; } 1; =pod =item device =item summary provides interface between FHEM and Homematic CCU2 =begin html <a name="HMCCU"></a> <h3>HMCCU</h3> <ul> The module provides an interface between FHEM and a Homematic CCU2. HMCCU is the I/O device for the client devices HMCCUDEV and HMCCUCHN. The module requires the additional Perl modules IO::File, RPC::XML::Client, RPC::XML::Server. </br></br> <a name="HMCCUdefine"></a> <b>Define</b><br/><br/> <ul> <code>define &lt;name&gt; HMCCU [&lt;Protocol&gt;://]&lt;HostOrIP&gt; [&lt;ccu-number&gt;] [waitforccu=&lt;timeout&gt;] [ccudelay=&lt;delay&gt;] [delayedinit=&lt;delay&gt;]</code> <br/><br/> Example:<br/> <code>define myccu HMCCU https://192.168.1.10 ccudelay=180</code> <br/><br/> The parameter <i>HostOrIP</i> is the hostname or IP address of a Homematic CCU2 or CCU3. Optionally the <i>protocol</i> 'http' or 'https' can be specified. Default protocol is 'http'.<br/> If you have more than one CCU you can specifiy a unique CCU number with parameter <i>ccu-number</i>. With option <i>waitforccu</i> HMCCU will wait for the specified time if CCU is not reachable. Parameter <i>timeout</i> should be a multiple of 20 in seconds. Warning: This option will block the start of FHEM for <i>timeout</i> seconds.<br/> The option <i>ccudelay</i> specifies the time for delayed initialization of CCU environment if the CCU is not reachable during FHEM startup (i.e. in case of a power failure). The default value for <i>delay</i> is 180 seconds. Increase this value if your CCU needs more time to start up after a power failure. This option will not block the start of FHEM.<br/> With option <i>delayedinit</i> the CCU ennvironment will be initialized after the specified time, no matter if CCU is reachable or not. As long as CCU environment is not initialized all client devices of type HMCCUCHN or HMCCUDEV are in state 'pending' and all commands are disabled.<br/><br/> For automatic update of Homematic device datapoints and FHEM readings one have to: <br/><br/> <ul> <li>Define used RPC interfaces with attribute 'rpcinterfaces'</li> <li>Start RPC servers with command 'set rpcserver on'</li> <li>Optionally enable automatic start of RPC servers with attribute 'rpcserver'</li> </ul><br/> Then start with the definition of client devices using modules HMCCUDEV (CCU devices) and HMCCUCHN (CCU channels) or with command 'get devicelist create'.<br/> Maybe it's helpful to set the following FHEM standard attributes for the HMCCU I/O device:<br/><br/> <ul> <li>Shortcut for RPC server control: eventMap /rpcserver on:on/rpcserver off:off/</li> </ul> </ul> <br/> <a name="HMCCUset"></a> <b>Set</b><br/><br/> <ul> <li><b>set &lt;name&gt; ackmessages</b><br/> Acknowledge device was unreachable messages in CCU. </li><br/> <li><b>set &lt;name&gt; authentication [&lt;username&gt; &lt;password&gt;]</b><br/> Set credentials for CCU authentication. Authentication must be activated by setting attribute ccuflags to 'authenticate'.<br/> When executing this command without arguments credentials are deleted. </li><br/> <li><b>set &lt;name&gt; clear [&lt;reading-exp&gt;]</b><br/> Delete readings matching specified reading name expression. Default expression is '.*'. Readings 'state' and 'control' are not deleted. </li><br/> <li><b>set &lt;name&gt; cleardefaults</b><br/> Clear default attributes imported from file. </li><br/> <li><b>set &lt;name&gt; datapoint &lt;FHEM-DevSpec&gt; [&lt;channel-number&gt;].&lt;datapoint&gt;=&ltvalue&gt;</b><br/> Set datapoint values on multiple devices. If <i>FHEM-Device</i> is of type HMCCUDEV a <i>channel-number</i> must be specified. The channel number is ignored for devices of type HMCCUCHN. </li><br/> <li><b>set &lt;name&gt; defaults</b><br/> Set default attributes for I/O device. </li><br/> <li><b>set &lt;name&gt; delete &lt;ccuobject&gt; [&lt;objecttype&gt;]</b><br/> Delete object in CCU. Default object type is OT_VARDP. Valid object types are<br/> OT_DEVICE=device, OT_VARDP=variable. </li><br/> <li><b>set &lt;name&gt; execute &lt;program&gt;</b><br/> Execute a CCU program. <br/><br/> Example:<br/> <code>set d_ccu execute PR-TEST</code> </li><br/> <li><b>set &lt;name&gt; hmscript {&lt;script-file&gt;|'!'&lt;function&gt;|'['&lt;code&gt;']'} [dump] [&lt;parname&gt;=&lt;value&gt; [...]]</b><br/> Execute Homematic script on CCU. If script code contains parameter in format $parname they are substituted by corresponding command line parameters <i>parname</i>.<br/> If output of script contains lines in format Object=Value readings in existing corresponding FHEM devices will be set. <i>Object</i> can be the name of a CCU system variable or a valid channel and datapoint specification. Readings for system variables are set in the I/O device. Datapoint related readings are set in client devices. If option 'dump' is specified the result of script execution is displayed in FHEM web interface. Execute command without parameters will list available script functions. </li><br/> <li><b>set &lt;name&gt; importdefaults &lt;filename&gt;</b><br/> Import default attributes from file. </li><br/> <li><b>set &lt;name&gt; initialize</b><br/> Initialize I/O device if state of CCU is unreachable. </li><br/> <li><b>set &lt;name&gt; prgActivate &lt;program&gt;</b><br/> Activate a CCU program. </li><br/> <li><b>set &lt;name&gt; prgDeactivate &lt;program&gt;</b><br/> Deactivate a CCU program. </li><br/> <li><b>set &lt;name&gt; rpcregister [{all | &lt;interface&gt;}]</b><br/> Register RPC servers at CCU. </li><br/> <li><b>set &lt;name&gt; rpcserver {on | off | restart}</b><br/> Start, stop or restart RPC server(s). This command executed with option 'on' will fork a RPC server process for each RPC interface defined in attribute 'rpcinterfaces'. Until operation is completed only a few set/get commands are available and you may get the error message 'CCU busy'. </li><br/> <li><b>set &lt;name&gt; var &lt;variable&gt; &lt;Value&gt;</b><br/> Set CCU system variable value. Special characters \_ in <i>value</i> are substituted by blanks. </li> </ul> <br/> <a name="HMCCUget"></a> <b>Get</b><br/><br/> <ul> <li><b>get &lt;name&gt; aggregation {&lt;rule&gt;|all}</b><br/> Process aggregation rule defined with attribute ccuaggregate. </li><br/> <li><b>get &lt;name&gt; ccuconfig</b><br/> Read configuration of CCU (devices, channels, programs). This command is executed automatically after the definition of an I/O device. It must be executed manually after module HMCCU is reloaded or after devices have changed in CCU (added, removed or renamed). If a RPC server is running HMCCU will raise events "<i>count</i> devices added in CCU" or "<i>count</i> devices deleted in CCU". It's recommended to set up a notification which reacts with execution of command 'get devicelist' on these events. </li><br/> <li><b>get &lt;name&gt; ccumsg {service|alarm}</b><br/> Query active service or alarm messages from CCU. Generate FHEM event for each message. </li><br/> <li><b>get &lt;name&gt; defaults</b><br/> List device types and channels with default attributes available. </li><br/> <li><b>get &lt;name&gt; deviceDesc {&lt;device&gt;|&lt;channel&gt;}</b><br/> Get description of CCU device or channel. </li><br/> <li><b>get &lt;name&gt; deviceinfo &lt;device-name&gt; [{State | <u>Value</u>}]</b><br/> List device channels and datapoints. If option 'State' is specified the device is queried directly. Otherwise device information from CCU is listed. </li><br/> <li><b>get &lt;name&gt; create &lt;devexp&gt; [t={chn|<u>dev</u>|all}] [p=&lt;prefix&gt;] [s=&lt;suffix&gt;] [f=&lt;format&gt;] [defattr] [save] [&lt;attr&gt;=&lt;value&gt; [...]]</b><br/> Create client devices for all CCU devices and channels matching specified regular expression. With option t=chn or t=dev (default) the creation of devices is limited to CCU channels or devices.<br/> Optionally a <i>prefix</i> and/or a <i>suffix</i> for the FHEM device name can be specified. The parameter <i>format</i> defines a template for the FHEM device names. Prefix, suffix and format can contain format identifiers which are substituted by corresponding values of the CCU device or channel: %n = CCU object name (channel or device), %d = CCU device name, %a = CCU address. In addition a list of default attributes for the created client devices can be specified. If option 'defattr' is specified HMCCU tries to set default attributes for device. With option 'duplicates' HMCCU will overwrite existing devices and/or create devices for existing device addresses. Option 'save' will save FHEM config after device definition. </li><br/> <li><b>get &lt;name&gt; dump {datapoints|devtypes} [&lt;filter&gt;]</b><br/> Dump all Homematic devicetypes or all devices including datapoints currently defined in FHEM. </li><br/> <li><b>get &lt;name&gt; dutycycle</b><br/> Read CCU interface and gateway information. For each interface/gateway the following information is stored in readings:<br/> iface_addr_n = interface address<br/> iface_type_n = interface type<br/> iface_conn_n = interface connection state (1=connected, 0=disconnected)<br/> iface_ducy_n = duty cycle of interface (0-100) </li><br/> <li><b>get &lt;name&gt; exportdefaults &lt;filename&gt; [all]</b><br/> Export default attributes into file. If option <i>all</i> is specified, also defaults imported by customer will be exported. </li><br/> <li><b>get &lt;name&gt; firmware [{&lt;type-expr&gt; | full}]</b><br/> Get available firmware downloads from eq-3.de. List FHEM devices with current and available firmware version. By default only firmware version of defined HMCCUDEV or HMCCUCHN devices are listet. With option 'full' all available firmware versions are listed. With parameter <i>type-expr</i> one can filter displayed firmware versions by Homematic device type. </li><br/> <li><b>get &lt;name&gt; paramsetDesc {&lt;device&gt;|&lt;channel&gt;}</b><br/> Get parameter set description of CCU device or channel. </li><br/> <li><b>get &lt;name&gt; rpcstate</b><br/> Check if RPC server process is running. </li><br/> <li><b>get &lt;name&gt; update [&lt;devexp&gt; [{State | <u>Value</u>}]]</b><br/> Update all datapoints / readings of client devices with <u>FHEM device name</u>(!) matching <i>devexp</i>. With option 'State' all CCU devices are queried directly. This can be time consuming. </li><br/> <li><b>get &lt;name&gt; updateccu [&lt;devexp&gt; [{State | <u>Value</u>}]]</b><br/> Update all datapoints / readings of client devices with <u>CCU device name</u>(!) matching <i>devexp</i>. With option 'State' all CCU devices are queried directly. This can be time consuming. </li><br/> <li><b>get &lt;name&gt; vars &lt;regexp&gt;</b><br/> Get CCU system variables matching <i>regexp</i> and store them as readings. </li> </ul> <br/> <a name="HMCCUattr"></a> <b>Attributes</b><br/> <br/> <ul> <li><b>ccuaggregate &lt;rule&gt;[;...]</b><br/> Define aggregation rules for client device readings. With an aggregation rule it's easy to detect if some or all client device readings are set to a specific value, i.e. detect all devices with low battery or detect all open windows.<br/> Aggregation rules are automatically executed as a reaction on reading events of HMCCU client devices. An aggregation rule consists of several parameters separated by comma:<br/><br/> <ul> <li><b>name:&lt;rule-name&gt;</b><br/> Name of aggregation rule</li> <li><b>filter:{name|alias|group|room|type}=&lt;incl-expr&gt;[!&lt;excl-expr&gt;]</b><br/> Filter criteria, i.e. "type=^HM-Sec-SC.*"</li> <li><b>read:&lt;read-expr&gt;</b><br/> Expression for reading names, i.e. "STATE"</li> <li><b>if:{any|all|min|max|sum|avg|lt|gt|le|ge}=&lt;value&gt;</b><br/> Condition, i.e. "any=open" or initial value, i.e. max=0</li> <li><b>else:&lt;value&gt;</b><br/> Complementary value, i.e. "closed"</li> <li><b>prefix:{&lt;text&gt;|RULE}</b><br/> Prefix for reading names with aggregation results</li> <li><b>coll:{&lt;attribute&gt;|NAME}[!&lt;default-text&gt;]</b><br/> Attribute of matching devices stored in aggregation results. Default text in case of no matching devices found is optional.</li> <li><b>html:&lt;template-file&gt;</b><br/> Create HTML code with matching devices.</li> </ul><br/> Aggregation results will be stored in readings <i>prefix</i>count, <i>prefix</i>list, <i>prefix</i>match, <i>prefix</i>state and <i>prefix</i>table.<br/><br/> Format of a line in <i>template-file</i> is &lt;keyword&gt;:&lt;html-code&gt;. See FHEM Wiki for an example. Valid keywords are:<br/><br/> <ul> <li><b>begin-html</b>: Start of html code.</li> <li><b>begin-table</b>: Start of table (i.e. the table header)</li> <li><b>row-odd</b>: HTML code for odd lines. A tag &lt;reading/&gt is replaced by a matching device.</li> <li><b>row-even</b>: HTML code for event lines.</li> <li><b>end-table</b>: End of table.</li> <li><b>default</b>: HTML code for no matches.</li> <li><b>end-html</b>: End of html code.</li> </ul><br/> Example: Find open windows<br/> name=lock,filter:type=^HM-Sec-SC.*,read:STATE,if:any=open,else:closed,prefix:lock_,coll:NAME!All windows closed<br/><br/> Example: Find devices with low batteries. Generate reading in HTML format.<br/> name=battery,filter:name=.*,read:(LOWBAT|LOW_BAT),if:any=yes,else:no,prefix:batt_,coll:NAME!All batteries OK,html:/home/battery.cfg<br/> </li><br/> <li><b>ccudef-hmstatevals &lt;subst-rule[;...]&gt;</b><br/> Set global rules for calculation of reading hmstate. </li><br/> <li><b>ccudef-readingfilter &lt;filter-rule[;...]&gt;</b><br/> Set global reading/datapoint filter. This filter is added to the filter specified by client device attribute 'ccureadingfilter'. </li><br/> <li><b>ccudef-readingformat {name | address | <u>datapoint</u> | namelc | addresslc | datapointlc}</b><br/> Set global reading format. This format is the default for all readings except readings of virtual device groups. </li><br/> <li><b>ccudef-stripnumber [&lt;datapoint-expr&gt;!]{0|1|2|-n|%fmt}[;...]</b><br/> Set global formatting rules for numeric datapoint or config parameter values. Default value is 2 (strip trailing zeroes).<br/> For details see description of attribute stripnumber in <a href="#HMCCUCHNattr">HMCCUCHN</a>. </li> <li><b>ccudef-substitute &lt;subst-rule&gt;[;...]</b><br/> Set global substitution rules for datapoint value. These rules are added to the rules specified by client device attribute 'substitute'. </li><br/> <li><b>ccudefaults &lt;filename&gt;</b><br/> Load default attributes for HMCCUCHN and HMCCUDEV devices from specified file. Best practice for creating a custom default attribute file is by exporting predefined default attributes from HMCCU with command 'get exportdefaults'. </li><br/> <li><b>ccuflags {&lt;flags&gt;}</b><br/> Control behaviour of several HMCCU functions. Parameter <i>flags</i> is a comma seperated list of the following strings:<br/> ackState - Acknowledge command execution by setting STATE to error or success.<br/> dptnocheck - Do not check within set or get commands if datapoint is valid<br/> intrpc - No longer supported.<br/> extrpc - No longer supported.<br/> logCommand - Write all set and get commands of all devices to log file with verbose level 3.<br/> logEvents - Write events from CCU into FHEM logfile<br/> logPong - Write log message when receiving pong event if verbose level is at least 3.<br/> noEvents - Ignore events / device updates sent by CCU. No readings will be updated!<br/> noInitialUpdate - Do not update datapoints of devices after RPC server start. Overrides settings in RPC devices. nonBlocking - Use non blocking (asynchronous) CCU requests<br/> noReadings - Do not create or update readings<br/> procrpc - Use external RPC server provided by module HMCCPRPCPROC. During first RPC server start HMCCU will create a HMCCURPCPROC device for each interface confiugured in attribute 'rpcinterface'<br/> reconnect - Automatically reconnect to CCU when events timeout occurred.<br/> updGroupMembers - Update readings of group members in virtual devices. </li><br/> <li><b>ccuget {State | <u>Value</u>}</b><br/> Set read access method for CCU channel datapoints. Method 'State' is slower than 'Value' because each request is sent to the device. With method 'Value' only CCU is queried. Default is 'Value'. Method for write access to datapoints is always 'State'. </li><br/> <li><b>ccuGetVars &lt;interval&gt;[&lt;pattern&gt;]</b><br/> Read CCU system variables periodically and update readings. If pattern is specified only variables matching this expression are stored as readings. </li><br/> <li><b>ccuReqTimeout &lt;Seconds&gt;</b><br/> Set timeout for CCU request. Default is 4 seconds. This timeout affects several set and get commands, i.e. "set datapoint" or "set var". If a command runs into a timeout FHEM will block for <i>Seconds</i>. To prevent blocking set flag 'nonBlocking' in attribute <i>ccuflags</i>. </li><br/> <li><b>ccureadings {0 | <u>1</u>}</b><br/> Deprecated. Readings are written by default. To deactivate readings set flag noReadings in attribute ccuflags. </li><br/> <li><b>rpcinterfaces &lt;interface&gt;[,...]</b><br/> Specify list of CCU RPC interfaces. HMCCU will register a RPC server for each interface. Either interface BidCos-RF or HmIP-RF (HmIP only) is default. Valid interfaces are:<br/><br/> <ul> <li>BidCos-Wired (Port 2000)</li> <li>BidCos-RF (Port 2001)</li> <li>Homegear (Port 2003)</li> <li>HmIP-RF (Port 2010)</li> <li>HVL (Port 7000)</li> <li>CUxD (Port 8701)</li> <li>VirtualDevice (Port 9292)</li> </ul> </li><br/> <li><b>rpcinterval &lt;Seconds&gt;</b><br/> Specifiy how often RPC queue is read. Default is 5 seconds. Only relevant if internal RPC server is used (deprecated). </li><br/> <li><b>rpcPingCCU &lt;interval&gt;</b><br/> Send RPC ping request to CCU every <i>interval</i> seconds. If <i>interval</i> is 0 ping requests are disabled. Default value is 300 seconds. If attribut ccuflags is set to logPong a log message with level 3 is created when receiving a pong event. </li><br/> <li><b>rpcport &lt;value[,...]&gt;</b><br/> Deprecated, use attribute 'rpcinterfaces' instead. Specify list of RPC ports on CCU. Either port 2001 or 2010 (HmIP only) is default. Valid RPC ports are:<br/><br/> <ul> <li>2000 = Wired components</li> <li>2001 = BidCos-RF (wireless 868 MHz components with BidCos protocol)</li> <li>2003 = Homegear (experimental)</li> <li>2010 = HM-IP (wireless 868 MHz components with IPv6 protocol)</li> <li>7000 = HVL (Homematic Virtual Layer devices)</li> <li>8701 = CUxD (only supported with external RPC server HMCCURPC)</li> <li>9292 = CCU group devices (especially heating groups)</li> </ul> </li><br/> <li><b>rpcqueue &lt;queue-file&gt;</b><br/> Specify name of RPC queue file. This parameter is only a prefix (including the pathname) for the queue files with extension .idx and .dat. Default is /tmp/ccuqueue. If FHEM is running on a SD card it's recommended that the queue files are placed on a RAM disk. </li><br/> <li><b>rpcserver {on | <u>off</u>}</b><br/> Specify if RPC server is automatically started on FHEM startup. </li><br/> <li><b>rpcserveraddr &lt;ip-or-name&gt;</b><br/> Specify network interface by IP address or DNS name where RPC server should listen on. By default HMCCU automatically detects the IP address. This attribute should be used if the FHEM server has more than one network interface. </li><br/> <li><b>rpcserverport &lt;base-port&gt;</b><br/> Specify base port for RPC server. The real listening port of an RPC server is calculated by the formula: base-port + rpc-port + (10 * ccu-number). Default value for <i>base-port</i> is 5400.<br/> The value ccu-number is only relevant if more than one CCU is connected to FHEM. Example: If <i>base-port</i> is 5000, protocol is BidCos (rpc-port 2001) and only one CCU is connected the resulting RPC server port is 5000+2001+(10*0) = 7001. </li><br/> <li><b>substitute &lt;subst-rule&gt;:&lt;substext&gt;[,...]</b><br/> Define substitions for datapoint values. Syntax of <i>subst-rule</i> is<br/><br/> [[&lt;channelno.&gt;]&lt;datapoint&gt;[,...]!]&lt;{#n1-m1|regexp1}&gt;:&lt;text1&gt;[,...] </li><br/> <li><b>stripchar &lt;character&gt;</b><br/> Strip the specified character from variable or device name in set commands. This is useful if a variable should be set in CCU using the reading with trailing colon. </li> </ul> </ul> =end html =cut
32.690725
143
0.547932
ed75bcfde12c7e21e9c188f98f0f44bea73921f4
15,080
pm
Perl
lib/Mail/SpamAssassin/Plugin/AuthRes.pm
isabella232/spamassassin
53b6bbc7f382be89e9e05f90d6564cd933015ea8
[ "Apache-2.0" ]
196
2015-01-13T03:55:31.000Z
2022-03-29T23:56:13.000Z
lib/Mail/SpamAssassin/Plugin/AuthRes.pm
apache/spamassassin
6a28fdf568f16b39c049e45014e082a34a9e4be9
[ "Apache-2.0" ]
2
2015-03-23T21:32:14.000Z
2018-10-18T15:37:36.000Z
lib/Mail/SpamAssassin/Plugin/AuthRes.pm
isabella232/spamassassin
53b6bbc7f382be89e9e05f90d6564cd933015ea8
[ "Apache-2.0" ]
77
2015-01-13T04:35:30.000Z
2022-03-15T14:49:08.000Z
# <@LICENSE> # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to you under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # </@LICENSE> =head1 NAME Mail::SpamAssassin::Plugin::AuthRes - use Authentication-Results header fields =head1 SYNOPSIS =head2 SpamAssassin configuration: loadplugin Mail::SpamAssassin::Plugin::AuthRes authres_trusted_authserv myserv.example.com authres_networks all =head1 DESCRIPTION This plugin parses Authentication-Results header fields and can supply the results obtained to other plugins, so as to avoid repeating checks that have been performed already. =cut package Mail::SpamAssassin::Plugin::AuthRes; use Mail::SpamAssassin::Plugin; use Mail::SpamAssassin::Logger; use strict; use warnings; # use bytes; use re 'taint'; our @ISA = qw(Mail::SpamAssassin::Plugin); # list of valid methods and values # https://www.iana.org/assignments/email-auth/email-auth.xhtml # some others not in that list: # dkim-atps=neutral my %method_result = ( 'auth' => {'fail'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1}, 'dkim' => {'fail'=>1,'neutral'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'policy'=>1,'temperror'=>1}, 'dkim-adsp' => {'discard'=>1,'fail'=>1,'none'=>1,'nxdomain'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1,'unknown'=>1}, 'dkim-atps' => {'fail'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1,'neutral'=>1}, 'dmarc' => {'fail'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1}, 'domainkeys' => {'fail'=>1,'neutral'=>1,'none'=>1,'permerror'=>1,'policy'=>1,'pass'=>1,'temperror'=>1}, 'iprev' => {'fail'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1}, 'rrvs' => {'fail'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1,'unknown'=>1}, 'sender-id' => {'fail'=>1,'hardfail'=>1,'neutral'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'policy'=>1,'softfail'=>1,'temperror'=>1}, 'smime' => {'fail'=>1,'neutral'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'policy'=>1,'temperror'=>1}, 'spf' => {'fail'=>1,'hardfail'=>1,'neutral'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'policy'=>1,'softfail'=>1,'temperror'=>1}, 'vbr' => {'fail'=>1,'none'=>1,'pass'=>1,'permerror'=>1,'temperror'=>1}, ); my %method_ptype_prop = ( 'auth' => {'smtp' => {'auth'=>1,'mailfrom'=>1}}, 'dkim' => {'header' => {'d'=>1,'i'=>1,'b'=>1}}, 'dkim-adsp' => {'header' => {'from'=>1}}, 'dkim-atps' => {'header' => {'from'=>1}}, 'dmarc' => {'header' => {'from'=>1}}, 'domainkeys' => {'header' => {'d'=>1,'from'=>1,'sender'=>1}}, 'iprev' => {'policy' => {'iprev'=>1}}, 'rrvs' => {'smtp' => {'rcptto'=>1}}, 'sender-id' => {'header' => {'*'=>1}}, 'smime' => {'body' => {'smime-part'=>1,'smime-identifer'=>1,'smime-serial'=>1,'smime-issuer'=>1}}, 'spf' => {'smtp' => {'mailfrom'=>1,'helo'=>1}}, 'vbr' => {'header' => {'md'=>1,'mv'=>1}}, ); # Some MIME helpers my $QUOTED_STRING = qr/"((?:[^"\\]++|\\.)*+)"?/; my $TOKEN = qr/[^\s\x00-\x1f\x80-\xff\(\)\<\>\@\,\;\:\/\[\]\?\=\"]+/; my $ATOM = qr/[a-zA-Z0-9\@\!\#\$\%\&\\\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+/; sub new { my ($class, $mailsa) = @_; # the usual perlobj boilerplate to create a subclass object $class = ref($class) || $class; my $self = $class->SUPER::new($mailsa); bless ($self, $class); $self->set_config($mailsa->{conf}); # process first as other plugins might depend on us $self->register_method_priority("parsed_metadata", -10); $self->register_eval_rule("check_authres_result", $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS); return $self; } sub set_config { my ($self, $conf) = @_; my @cmds; =head1 ADMINISTRATOR OPTIONS =over =item authres_networks internal/trusted/all (default: internal) Process Authenticated-Results headers set by servers from these networks (refers to SpamAssassin *_networks zones). Any header outside this is completely ignored (affects all module settings). internal = internal_networks trusted = internal_networks + trusted_networks all = all above + all external Setting "all" is safe only if your MX servers filter properly all incoming A-R headers, and you use authres_trusted_authserv to match your authserv-id. This is suitable for default OpenDKIM for example. These settings might also be required if your filters do not insert A-R header to correct position above the internal Received header (some known offenders: OpenDKIM, OpenDMARC, amavisd-milter). =back =cut push (@cmds, { setting => 'authres_networks', is_admin => 1, default => 'internal', type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING, code => sub { my ($self, $key, $value, $line) = @_; if (!defined $value || $value =~ /^$/) { return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE; } $value = lc($value); if ($value =~ /^(?:internal|trusted|all)$/) { $self->{authres_networks} = $value; } else { return $Mail::SpamAssassin::Conf::INVALID_VALUE; } } }); =over =item authres_trusted_authserv authservid1 id2 ... (default: none) Trusted authentication server IDs (the domain-name-like first word of Authentication-Results field, also known as C<authserv-id>). Note that if set, ALL A-R headers are ignored unless a match is found. Use strongly recommended, possibly along with authres_networks all. =back =cut push (@cmds, { setting => 'authres_trusted_authserv', is_admin => 1, default => {}, type => $Mail::SpamAssassin::Conf::CONF_TYPE_HASH_KEY_VALUE, code => sub { my ($self, $key, $value, $line) = @_; if (!defined $value || $value =~ /^$/) { return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE; } foreach my $id (split(/\s+/, lc $value)) { $self->{authres_trusted_authserv}->{$id} = 1; } } }); =over =item authres_ignored_authserv authservid1 id2 ... (default: none) Ignored authentication server IDs (the domain-name-like first word of Authentication-Results field, also known as C<authserv-id>). Any A-R header is ignored if match is found. =back =cut push (@cmds, { setting => 'authres_ignored_authserv', is_admin => 1, default => {}, type => $Mail::SpamAssassin::Conf::CONF_TYPE_HASH_KEY_VALUE, code => sub { my ($self, $key, $value, $line) = @_; if (!defined $value || $value =~ /^$/) { return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE; } foreach my $id (split(/\s+/, lc $value)) { $self->{authres_ignored_authserv}->{$id} = 1; } } }); $conf->{parser}->register_commands(\@cmds); } =head1 METADATA Parsed headers are stored in $pms-E<gt>{authres_parsed}, as a hash of array of hashes where results are collected by method. For example, the header field: Authentication-Results: server.example.com; spf=pass smtp.mailfrom=bounce.example.org; dkim=pass header.i=@example.org; dkim=fail header.i=@another.signing.domain.example Produces the following structure: $pms->{authres_parsed} = { 'dkim' => [ { 'properties' => { 'header' => { 'i' => '@example.org' } }, 'authserv' => 'server.example.com', 'result' => 'pass', 'version' => 1, 'reason' => '' }, { 'properties' => { 'header' => { 'i' => '@another.signing.domain.example' } }, 'result' => 'fail', 'authserv' => 'server.example.com', 'version' => 1, 'reason' => '' }, ], } Within each array, the order of results is the original, which should be most recent results first. For checking result of methods, $pms-E<gt>{authres_result} is available: $pms->{authres_result} = { 'dkim' => 'pass', 'spf' => 'fail', } =head1 EVAL FUNCTIONS =over 4 =item header RULENAME eval:check_authres_result(method, result) Can be used to check results. ifplugin Mail::SpamAssassin::Plugin::AuthRes ifplugin !(Mail::SpamAssassin::Plugin::SPF) header SPF_PASS eval:check_authres_result('spf', 'pass') header SPF_FAIL eval:check_authres_result('spf', 'fail') header SPF_SOFTFAIL eval:check_authres_result('spf', 'softfail') header SPF_TEMPFAIL eval:check_authres_result('spf', 'tempfail') endif ifplugin !(Mail::SpamAssassin::Plugin::DKIM) header DKIM_VERIFIED eval:check_authres_result('dkim', 'pass') header DKIM_INVALID eval:check_authres_result('dkim', 'fail') endif endif =back =cut sub check_authres_result { my ($self, $pms, $method, $wanted_result) = @_; my $result = $pms->{authres_result}->{$method}; $wanted_result = lc($wanted_result); if ($wanted_result eq 'missing') { return !defined($result) ? 1 : 0; } return ($wanted_result eq $result); } sub parsed_metadata { my ($self, $opts) = @_; my $pms = $opts->{permsgstatus}; my @authres; my $nethdr; if ($pms->{conf}->{authres_networks} eq 'internal') { $nethdr = 'ALL-INTERNAL'; } elsif ($pms->{conf}->{authres_networks} eq 'trusted') { $nethdr = 'ALL-TRUSTED'; } else { $nethdr = 'ALL'; } foreach my $hdr (split(/^/m, $pms->get($nethdr))) { if ($hdr =~ /^Authentication-Results:\s*(.+)/i) { push @authres, $1; } } if (!@authres) { dbg("authres: no Authentication-Results headers found from %s", $pms->{conf}->{authres_networks}); return 0; } foreach (@authres) { eval { $self->parse_authres($pms, $_); } or do { dbg("authres: skipping header, $@"); } } $pms->{authres_result} = {}; # Set $pms->{authres_result} info for all found methods # 'pass' will always win if multiple results foreach my $method (keys %method_result) { my $parsed = $pms->{authres_parsed}->{$method}; next if !$parsed; foreach my $pref (@$parsed) { if (!$pms->{authres_result}->{$method} || $pref->{result} eq 'pass') { $pms->{authres_result}->{$method} = $pref->{result}; } } } if (%{$pms->{authres_result}}) { dbg("authres: results: %s", join(' ', map { $_.'='.$pms->{authres_result}->{$_} } sort keys %{$pms->{authres_result}})); } else { dbg("authres: no results"); } } sub parse_authres { my ($self, $pms, $hdr) = @_; dbg("authres: parsing Authentication-Results: $hdr"); my $authserv; my $version = 1; my @methods; local $_ = $hdr; # authserv-id if (!/\G($TOKEN)/gcs) { die("invalid authserv\n"); } $authserv = lc($1); if (%{$pms->{conf}->{authres_trusted_authserv}}) { if (!$pms->{conf}->{authres_trusted_authserv}->{$authserv}) { die("authserv not trusted: $authserv\n"); } } if ($pms->{conf}->{authres_ignored_authserv}->{$authserv}) { die("ignored authserv: $authserv\n"); } skip_cfws(); if (/\G\d+/gcs) { # skip authserv version skip_cfws(); } if (!/\G;/gcs) { die("missing delimiter\n"); } skip_cfws(); while (pos() < length()) { my ($method, $result); my $reason = ''; my $props = {}; # skip none method if (/\Gnone\b/igcs) { die("method none\n"); } # method / version = result if (!/\G([\w-]+)/gcs) { die("invalid method\n"); } $method = lc($1); if (!exists $method_result{$method}) { die("unknown method: $method\n"); } skip_cfws(); if (/\G\//gcs) { skip_cfws(); if (!/\G\d+/gcs) { die("invalid $method version\n"); } $version = $1; skip_cfws(); } if (!/\G=/gcs) { die("missing result for $method: ".substr($_, pos())."\n"); } skip_cfws(); if (!/\G(\w+)/gcs) { die("invalid result for $method\n"); } $result = $1; if (!exists $method_result{$method}{$result}) { die("unknown result for $method: $result\n"); } skip_cfws(); # reason = value if (/\Greason\b/igcs) { skip_cfws(); if (!/\G=/gcs) { die("invalid reason\n"); } skip_cfws(); if (!/\G$QUOTED_STRING|($TOKEN)/gcs) { die("invalid reason\n"); } $reason = defined $1 ? $1 : $2; skip_cfws(); } # ptype.property = value while (pos() < length()) { my ($ptype, $property, $value); # ptype if (!/\G(\w+)/gcs) { die("invalid ptype: ".substr($_,pos())."\n"); } $ptype = lc($1); if (!exists $method_ptype_prop{$method}{$ptype}) { die("unknown ptype: $ptype\n"); } skip_cfws(); # dot if (!/\G\./gcs) { die("missing property\n"); } skip_cfws(); # property if (!/\G(\w+)/gcs) { die("invalid property\n"); } $property = lc($1); if (!exists $method_ptype_prop{$method}{$ptype}{$property} && !exists $method_ptype_prop{$method}{$ptype}{'*'}) { die("unknown property for $ptype: $property\n"); } skip_cfws(); # = if (!/\G=/gcs) { die("missing property value\n"); } skip_cfws(); # value: # The grammar is ( value / [ [ local-part ] "@" ] domain-name ) # where value := token / quoted-string # and local-part := dot-atom / quoted-string / obs-local-part if (!/\G$QUOTED_STRING|($ATOM(?:\.$ATOM)*|$TOKEN)(?=(?:[\s;]|$))/gcs) { die("invalid $ptype.$property value\n"); } $value = defined $1 ? $1 : $2; skip_cfws(); $props->{$ptype}->{$property} = $value; if (/\G(?:;|$)/gcs) { skip_cfws(); last; } } push @methods, [$method, { 'authserv' => $authserv, 'version' => $version, 'result' => $result, 'reason' => $reason, 'properties' => $props, }]; } # paranoid check.. if (pos() < length()) { die("parse ended prematurely?\n"); } # Pushed to pms only if header parsed completely foreach my $marr (@methods) { push @{$pms->{authres_parsed}->{$marr->[0]}}, $marr->[1]; } return 1; } # skip whitespace and comments sub skip_cfws { /\G\s*/gcs; if (/\G\(/gcs) { my $i = 1; while (/\G.*?([()]|\z)/gcs) { $1 eq ')' ? $i-- : $i++; last if !$i; } die("comment not ended\n") if $i; /\G\s*/gcs; } } #sub check_cleanup { # my ($self, $opts) = @_; # my $pms = $opts->{permsgstatus}; # use Data::Dumper; # print STDERR Dumper($pms->{authres_parsed}); # print STDERR Dumper($pms->{authres_result}); #} 1;
27.220217
132
0.584682
ed7084ad60598a0950698ac95cf7736d9ce19980
703
t
Perl
t/0.01/data/object/float/eq.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
t/0.01/data/object/float/eq.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
t/0.01/data/object/float/eq.t
srchulo/do
d3c4ccecf33d1cf83d64b1c15666d0282a89e4f3
[ "Apache-2.0" ]
null
null
null
use strict; use warnings; use Test::More; use_ok 'Data::Object::Float'; # deprecated # can_ok 'Data::Object::Float', 'eq'; use Scalar::Util 'refaddr'; subtest 'test the eq method' => sub { my $float = Data::Object::Float->new(98765.98765); my $eq = $float->eq(98765.98765); isnt refaddr($float), refaddr($eq); is $eq, 1; $eq = $float->eq('98765.98765'); isnt refaddr($float), refaddr($eq); is $eq, 1; $eq = $float->eq(987650); isnt refaddr($float), refaddr($eq); is $eq, 0; $eq = $float->eq('098765.98765'); isnt refaddr($float), refaddr($eq); is $eq, 1; isa_ok $float, 'Data::Object::Float'; isa_ok $eq, 'Data::Object::Number'; }; ok 1 and done_testing;
18.5
52
0.608819
ed3c3a4985ce245b063246cdbb9ae217ade7530a
521
pm
Perl
auto-lib/Paws/ManagedBlockchain/CreateNetworkOutput.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
164
2015-01-08T14:58:53.000Z
2022-02-20T19:16:24.000Z
auto-lib/Paws/ManagedBlockchain/CreateNetworkOutput.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
348
2015-01-07T22:08:38.000Z
2022-01-27T14:34:44.000Z
auto-lib/Paws/ManagedBlockchain/CreateNetworkOutput.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
87
2015-04-22T06:29:47.000Z
2021-09-29T14:45:55.000Z
package Paws::ManagedBlockchain::CreateNetworkOutput; use Moose; has MemberId => (is => 'ro', isa => 'Str'); has NetworkId => (is => 'ro', isa => 'Str'); has _request_id => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::ManagedBlockchain::CreateNetworkOutput =head1 ATTRIBUTES =head2 MemberId => Str The unique identifier for the first member within the network. =head2 NetworkId => Str The unique identifier for the network. =head2 _request_id => Str =cut
15.323529
62
0.673704
ed77dc70df27a89e4ee96f2a901e2edb59ecd702
6,873
pm
Perl
web2py-appliances-master/ServerStats/software/server/orca/lib/perl/Math/IntervalSearch.pm
wantsomechocolate/WantsomeBeanstalk
8c8a0a80490d04ea52661a3114fd3db8de65a01e
[ "BSD-3-Clause" ]
null
null
null
web2py-appliances-master/ServerStats/software/server/orca/lib/perl/Math/IntervalSearch.pm
wantsomechocolate/WantsomeBeanstalk
8c8a0a80490d04ea52661a3114fd3db8de65a01e
[ "BSD-3-Clause" ]
null
null
null
web2py-appliances-master/ServerStats/software/server/orca/lib/perl/Math/IntervalSearch.pm
wantsomechocolate/WantsomeBeanstalk
8c8a0a80490d04ea52661a3114fd3db8de65a01e
[ "BSD-3-Clause" ]
null
null
null
package Math::IntervalSearch; require 5.004_01; use strict; use vars qw(@EXPORT_OK @ISA $VERSION); use Exporter; use Carp; @EXPORT_OK = qw(interval_search); @ISA = qw(Exporter); $VERSION = substr q$Revision: 1.05 $, 10; sub cluck { warn Carp::longmess @_ } sub LessThan { $_[0] < $_[1]; } sub LessThanEqualTo { $_[0] <= $_[1]; } # This holds the result from the last interval search. my $last_interval_result = undef; sub interval_search { if ( @_ > 4 ) { cluck "interval called with too many parameters"; return; } # Get the input arguments. my $x = shift; my $sequenceRef = shift; return unless defined($x); return unless defined($sequenceRef); return unless ref($sequenceRef); # Check the input arguments for any code references and use them. my $LessThan = \&LessThan; my $LessThanEqualTo = \&LessThanEqualTo; @_ and defined(ref($_[0])) and ref($_[0]) eq 'CODE' and $LessThan = shift; @_ and defined(ref($_[0])) and ref($_[0]) eq 'CODE' and $LessThanEqualTo = shift; # Get the number of points in the data. my $num = @$sequenceRef; # Return -1 if there's no data. if ( $num <= 0 ) { $last_interval_result = 0; return -1; } # Use the result from the last time through the subroutine, if it # exists. Force the result into the range required by the array # size. $last_interval_result = 0 unless defined($last_interval_result); # Which side of the data point is x on if there's only one point? if ( $num == 1 ) { $last_interval_result = 0; if ( &$LessThan($x, $sequenceRef->[0]) ) { return -1; } else { return 0; } } # Is the point less than the smallest point in the sequence? if ( &$LessThan($x, $sequenceRef->[0]) ) { $last_interval_result = 0; return -1; } # Is the point greater than the largest point in the sequence? if ( &$LessThanEqualTo($sequenceRef->[$num-1], $x) ) { return $last_interval_result = $num - 1; } # Use the result from the last run as a start for this run. if ( $last_interval_result > $num-1 ) { $last_interval_result = $num - 2; } my $ilo = $last_interval_result; my $ihi = $ilo + 1; # Is the new upper ihi beyond the extent of the sequence? if ( $ihi >= $num ) { $ihi = $num - 1; $ilo = $ihi - 1; } # If x < sequence(ilo), then decrease ilo to capture x. if ( &$LessThan($x, $sequenceRef->[$ilo]) ) { my $istep = 1; for (;;) { $ihi = $ilo; $ilo = $ihi - $istep; if ( $ilo <= 0 ) { $ilo = 0; last; } if ( &$LessThanEqualTo($sequenceRef->[$ilo], $x) ) { last; } $istep *= 2; } } # If x >= sequence(ihi), then increase ihi to capture x. if ( &$LessThanEqualTo($sequenceRef->[$ihi], $x) ) { my $istep = 1; for (;;) { $ilo = $ihi; $ihi = $ilo + $istep; if ( $ihi >= $num-1 ) { $ihi = $num - 1; last; } if ( &$LessThan($x, $sequenceRef->[$ihi]) ) { last; } $istep *= 2; } } # Now sequence(ilo) <= x < sequence(ihi). Narrow the interval. for (;;) { # Find the middle point of the sequence. my $middle = int(($ilo + $ihi)/2); # The division above was integer, so if ihi = ilo+1, then # middle=ilo, which tests if x has been trapped. if ( $middle == $ilo ) { $last_interval_result = $ilo; return $ilo; } if ( &$LessThan($x, $sequenceRef->[$middle]) ) { $ihi = $middle; } else { $ilo = $middle; } } } 1; __END__ =pod =head1 NAME Math::IntervalSearch - Search where an element lies in a list of sorted elements =head1 SYNOPSIS use Math::IntervalSearch qw(interval_search); my @array = (1..5); my $location = interval_search(2.4, \@array); # Use your own comparison operators. sub ReverseLessThan { $_[0] < $_[1]; } sub ReverseLessThanEqualTo { $_[0] <= $_[1]; } $location = interval_search(2.4, \@array, \&ReverseLessThan, \&ReverseLessThanEqualTo); =head1 DESCRIPTION This subroutine is used to locate a position in an array of values where a given value would fit. It has been designed to be efficient in the common situation that it is called repeatedly. The user can supply a different set of comparison operators to replace the standard < and <=. =head1 SUBROUTINES =over 4 =item B<interval_search> I<value> I<sequence> [I<less_than> [I<less_than_equal_to>]] Given a I<value> I<interval_search> returns the location in the reference to an array I<sequence> where the value would fit. The default < operator to compare the elements in I<sequence> can be replaced by the subroutine I<less_than> which should return 1 if the first element passed to I<less_than> is less than the second. The default <= operator to compare the elements in I<sequence> can be replaced by the subroutine I<less_than> which should return 1 if the first element passed to I<less_than> is less than the second. The values in I<sequence> should already be sorted in numerically increasing order or in the order that would be produced by using the I<less_than> subroutine. Let N be the number of elements in referenced array I<sequence>, then I<interval_search> returns these values: -1 if I<value> < I<sequence>->[0] i if I<sequence>->[i] <= I<value> < I<sequence>->[i+1] N-1 if I<sequence>->[N-1] <= I<value> If a reference is made to an empty array, then -1 is always returned. If there is illegal input to I<interval_search>, such as an improper number of arguments, then an empty list in list context, an undefined value in scalar context, or nothing in a void context is returned. This subroutine is designed to be efficient in the common situation that it is called repeatedly, with I<value> taken from an increasing or decreasing list of values. This will happen, e.g., when an irregular waveform is interpolated to create a sequence with constant separation. The first guess for the output is therefore taken to be the value returned at the previous call and stored in the variable ilo. A first check ascertains that ilo is less than the number of data points in I<sequence>. This is necessary since the present call may have nothing to do with the previous call. Then, if I<sequence>->[ilo] <= I<value> < I<sequence>->[ilo+1], we set left = ilo and are done after just three comparisons. Otherwise, we repeatedly double the difference istep = ihi - ilo while also moving ilo and ihi in the direction of x, until I<sequence>->[ilo] <= x < I<sequence>->[ihi], after which bisection is used to get, in addition, ilo+1 = ihi. Then left = ilo is returned. =back 4 =head1 AUTHOR Blair Zajac <bzajac@geostaff.com>. =head1 COPYRIGHT Copyright (c) 1998 by Blair Zajac. =cut
27.059055
84
0.645133
ed1708a6f7d6f091099562a0f201dbf072a5822f
2,487
pl
Perl
lib/attvar.pl
bflagg/swish
d357234613182abcc2953d5b827d367616be8502
[ "BSD-2-Clause" ]
464
2015-01-01T13:56:55.000Z
2022-03-08T01:44:04.000Z
lib/attvar.pl
bflagg/swish
d357234613182abcc2953d5b827d367616be8502
[ "BSD-2-Clause" ]
129
2015-01-20T00:19:46.000Z
2022-02-14T19:49:17.000Z
lib/attvar.pl
bflagg/swish
d357234613182abcc2953d5b827d367616be8502
[ "BSD-2-Clause" ]
132
2015-01-02T10:02:47.000Z
2022-03-29T10:34:51.000Z
/* Part of SWISH Author: Jan Wielemaker E-mail: J.Wielemaker@cs.vu.nl WWW: http://www.swi-prolog.org Copyright (C): 2017, VU University Amsterdam CWI Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ :- module(swish_attvar, [ put_attr/2 % +Var, :Attr. ]). :- meta_predicate put_attr(-, :). %! put_attr(+Var, :Value) is det. % % Put an attribute on the current module. This is the same as % put_attr(Var, Module, Value), where Module is the calling context. put_attr(Var, M:Value) :- put_attr(Var, M, Value). :- multifile sandbox:safe_meta/3. sandbox:safe_meta(swish_attvar:put_attr(Var,Value), Context, Called) :- Value \= _:_, !, attr_hook_predicates([ attr_unify_hook(Value, _), attribute_goals(Var,_,_), project_attributes(_,_) ], Context, Called). attr_hook_predicates([], _, []). attr_hook_predicates([H|T], M, Called) :- ( predicate_property(M:H, defined) -> Called = [M:H|Rest] ; Called = Rest ), attr_hook_predicates(T, M, Rest).
36.043478
72
0.670688
ed56ee0baa219e60e00212870a001733ca0263dd
10,437
pl
Perl
examples/ppa_1998/ppa_perl/abcache.pl
gitathrun/pdq-qnm-pkg
410e6ff6def503bc579e50ea471b83061e99a0fe
[ "MIT" ]
1
2018-03-12T12:27:18.000Z
2018-03-12T12:27:18.000Z
examples/ppa_1998/ppa_perl/abcache.pl
gitathrun/pdq-qnm-pkg
410e6ff6def503bc579e50ea471b83061e99a0fe
[ "MIT" ]
null
null
null
examples/ppa_1998/ppa_perl/abcache.pl
gitathrun/pdq-qnm-pkg
410e6ff6def503bc579e50ea471b83061e99a0fe
[ "MIT" ]
null
null
null
#!/usr/bin/perl ############################################################################### # Copyright (C) 1994 - 1996, Performance Dynamics Company # # # # This software is licensed as described in the file COPYING, which # # you should have received as part of this distribution. The terms # # are also available at http://www.perfdynamics.com/Tools/copyright.html. # # # # You may opt to use, copy, modify, merge, publish, distribute and/or sell # # copies of the Software, and permit persons to whom the Software is # # furnished to do so, under the terms of the COPYING file. # # # # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # # KIND, either express or implied. # ############################################################################### # # abcache.pl - Cache protocol scaling # # Created by NJG: 13:03:53 07-19-96 Revised by NJG: 18:58:44 04-02-99 # # $Id$ # #--------------------------------------------------------------------- use pdq; #--------------------------------------------------------------------- $DEBUG = 0; #--------------------------------------------------------------------- sub itoa { my ($n, $s) = @_; if (($sign = $n) < 0) { $n = -$n; } $i = 0; do { # generate digits in reverse order $s[$i++] = '0' + ($n % 10); } while (($n /= 10) > 0); if ($sign < 0) { $s[$i++] = '-'; } $s[$i] = '\0'; # reverse order of bytes for ($i = 0, $j = strlen($s) - 1; $i < $j; $i++, $j--) { $c = $s[$i]; $s[$i] = $s[$j]; $s[$j] = $c; } } # itoa # #--------------------------------------------------------------------- sub intwt { my ($N, $W) = @_; my($i); if ($N < 1.0) { $i = 1; $$W = $N; } if ($N >= 1.0) { $i = $N; $$W = 1.0; } return int($i); } # intwt # #--------------------------------------------------------------------- $model = "ABC Model"; # Main memory update policy $WBACK = 1; # Globals $MAXCPU = 15; $ZX = 2.5; # Cache parameters $RD = 0.85; $WR = (1 - $RD); $HT = 0.95; $WUMD = 0.0526; $MD = 0.35; # Bus and L2 cache ids $L2C = "L2C"; $BUS = "MBus"; # Aggregate cache traffic $RWHT = "RWhit"; $gen = 1.0; # Bus Ops $RDOP = "Read"; $WROP = "Write"; $INVL = "Inval"; # per CPU intruction stream intensity $Prhit = ($RD * $HT); $Pwhit = ($WR * $HT * (1 - $WUMD)) + ($WR * (1 - $HT) * (1 - $MD)); $Prdop = $RD * (1 - $HT); $Pwbop = $WR * (1 - $HT) * $MD; $Pwthr = $WR; $Pinvl = $WR * $HT * $WUMD; $Nrwht = 0.8075 * $MAXCPU; $Nrdop = 0.0850 * $MAXCPU; $Nwthr = 0.15 * $MAXCPU; $Nwbop = 0.0003 * $MAXCPU * 100; $Ninvl = 0.015 * $MAXCPU; $Srdop = (20.0); $Swthr = (25.0); $Swbop = (20.0); $Wrwht = 0.0; $Wrdop = 0.0; $Wwthr = 0.0; $Wwbop = 0.0; $Winvl = 0.0; $Zrwht = $ZX; $Zrdop = $ZX; $Zwbop = $ZX; $Zinvl = $ZX; $Zwthr = $ZX; $Xcpu = 0.0; $Pcpu = 0.0; $Ubrd = 0.0; $Ubwr = 0.0; $Ubin = 0.0; $Ucht = 0.0; $Ucrd = 0.0; $Ucwr = 0.0; $Ucin = 0.0; #--------------------------------------------------------------------- pdq::Init($model); #----- Create single bus queueing center ----------------------------- $noNodes = pdq::CreateNode($BUS, $pdq::CEN, $pdq::FCFS); #----- Create per CPU cache queueing centers ------------------------- for ($i = 0; $i < $MAXCPU; $i++) { $cname = sprintf "%s%d", $L2C, $i; $noNodes = pdq::CreateNode($cname, $pdq::CEN, $pdq::FCFS); #$DEBUG && printf "i %2d cname %10s noNodes %d\n", $i, $cname, $noNodes; } #----- Create CPU nodes, workloads, and demands ---------------------- $DEBUG && printf " Nrwht %s, Zrwht %s\n", $Nrwht, $Zrwht; $no = intwt($Nrwht, \$Wrwht); $DEBUG && printf "no %d %f Nrwht %d, Zrwht %d\n", $no, $no, $Nrwht, $Zrwht; for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $RWHT, $i; #$DEBUG && printf "wname %s Nrwht %d, Zrwht %d\n", $wname, $Nrwht, $Zrwht; $noStreams = pdq::CreateClosed($wname, $pdq::TERM, $Nrwht, $Zrwht); $cname = sprintf "%s%d", $L2C, $i; #$DEBUG && printf "cname %s\n", $cname; pdq::SetDemand($cname, $wname, 1.0); pdq::SetDemand($BUS, $wname, 0.0); # no bus activity $DEBUG && printf "i %2d cname %10s noNodes %2d noStreams %d\n", $i, $cname, $noNodes, $noStreams; } #--------------------------------------------------------------------- $no = intwt($Nrdop, \$Wrdop); $DEBUG && printf "no %d Nrdop %d, Zrdop %d\n", $no, $Nrdop, $Zrdop; for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $RDOP, $i; $noStreams = pdq::CreateClosed($wname, $pdq::TERM, $Nrdop, $Zrdop); $cname = sprintf "%s%d", $L2C, $i; pdq::SetDemand($cname, $wname, $gen); # generate bus request pdq::SetDemand($BUS, $wname, $Srdop); # req + async data return $DEBUG && printf "i %2d cname %10s noNodes %2d noStreams %d\n", $i, $cname, $noNodes, $noStreams; } #--------------------------------------------------------------------- if (WBACK) { $no = intwt($Nwbop, \$Wwbop); printf "no %d Nwbop %d, Zwbop %d\n", $no, $Nwbop, $Zwbop; for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $WROP, $i; $noStreams = pdq::CreateClosed($wname, $pdq::TERM, $Nwbop, $Zwbop); $cname = sprintf "%s%d", $L2C, $i; pdq::SetDemand($cname, $wname, $gen); pdq::SetDemand($BUS, $wname, $Swbop); # asych write to memory ? $DEBUG && printf "w %2d cname %10s noNodes %2d noStreams %d\n", $i, $cname, $noNodes, $noStreams; } } else { # write-thru $no = intwt($Nwthr, \$Wwthr); printf "no %d Nwthr %d, Zwthr %d\n", $no, $Nwthr, $Zwthr; for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $WROP, $i; $noStreams = pdq::CreateClosed($wname, $pdq::TERM, $Nwthr, $Zwthr); $cname = sprintf "%s%d", $L2C, $i; pdq::SetDemand($cname, $wname, $gen); pdq::SetDemand($BUS, $wname, $Swthr); $DEBUG && printf "i %2d cname %10s noNodes %2d noStreams %d\n", $i, $cname, $noNodes, $noStreams; } } #--------------------------------------------------------------------- if (WBACK) { $no = intwt($Ninvl, \$Winvl); printf "no %d Ninvl %d, Zinvl %d\n", $no, $Ninvl, $Zinvl; for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $INVL, $i; $noStreams = pdq::CreateClosed($wname, $pdq::TERM, $Ninvl, $Zinvl); $cname = sprintf "%s%d", $L2C, $i; pdq::SetDemand($cname, $wname, $gen); # gen + intervene pdq::SetDemand($BUS, $wname, 1.0); $DEBUG && printf "w %2d cname %10s noNodes %2d noStreams %d\n", $i, $cname, $noNodes, $noStreams; } } pdq::Solve($pdq::APPROX); #----- Bus utilizations ---------------------------------------------- $no = intwt($Nrdop, \$Wrdop); for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $RDOP, $i; $Ubrd += pdq::GetUtilization($BUS, $wname, $pdq::TERM); } $Ubrd *= $Wrdop; if (WBACK) { $no = intwt($Nwbop, \$Wwbop); for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $WROP, $i; $Ubwr += pdq::GetUtilization($BUS, $wname, $pdq::TERM); } $Ubwr *= $Wwbop; $no = intwt($Ninvl, \$Winvl); for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $INVL, $i; $Ubin += pdq::GetUtilization($BUS, $wname, $pdq::TERM); } $Ubin *= $Winvl; } else { # write-thru $no = intwt($Nwthr, \$Wwthr); for ($i = 0; $i < $no; $i++) { $wname = sprintf "%s%d", $WROP, $i; $Ubwr += pdq::GetUtilization($BUS, $wname, $pdq::TERM); } $Ubwr *= $Wwthr; } #---- Cache measures at CPU[0] only ---------------------------------- $i = 0; $cname = sprintf "%s%d", $L2C, $i; $wname = sprintf "%s%d", $RWHT, $i; $Xcpu = pdq::GetThruput($pdq::TERM, $wname) * $Wrwht; $Pcpu += $Xcpu * $Zrwht; $Ucht = pdq::GetUtilization($cname, $wname, $pdq::TERM) * $Wrwht; $wname = sprintf "%s%d", $RDOP, $i; $Xcpu = pdq::GetThruput($pdq::TERM, $wname) * Wrdop; $Pcpu += $Xcpu * $Zrdop; $Ucrd = pdq::GetUtilization($cname, $wname, $pdq::TERM) * $Wrdop; $Pcpu *= 1.88; if ($WBACK) { $wname = sprintf "%s%d", $WROP, $i; $Ucwr = pdq::GetUtilization($cname, $wname, $pdq::TERM) * $Wwbop; $wname = sprintf "%s%d", $INVL, $i; $Ucin = pdq::GetUtilization($cname, $wname, $pdq::TERM) * $Winvl; } else { # write-thru $wname = sprintf "%s%d", $WROP, $i; $Ucwr = pdq::GetUtilization($cname, $wname, $pdq::TERM) * $Wwthr; } printf "\n**** %s Results ****\n", $model; printf "PDQ nodes: %d PDQ streams: %d\n", $noNodes, $noStreams; printf "Memory Mode: %s\n", $WBACK ? "WriteBack" : "WriteThru"; printf "Ncpu: %2d\n", $MAXCPU; $no = intwt($Nrwht, \$Wrwht); printf "Nrwht: %5.2f (N:%2d W:%5.2f)\n", $Nrwht, $no, $Wrwht; $no = intwt($Nrdop, \$Wrdop); printf "Nrdop: %5.2f (N:%2d W:%5.2f)\n", $Nrdop, $no, $Wrdop; if (WBACK) { $no = intwt($Nwbop, \$Wwbop); printf "Nwbop: %5.2f (N:%2d W:%5.2f)\n", $Nwbop, $no, $Wwbop; $no = intwt($Ninvl, \$Winvl); printf "Ninvl: %5.2f (N:%2d W:%5.2f)\n", $Ninvl, $no, $Winvl; } else { $no = intwt($Nwthr, \$Wwthr); printf "Nwthr: %5.2f (N:%2d W:%5.2f)\n", $Nwthr, $no, $Wwthr; } printf "\n"; printf "Hit Ratio: %5.2f %%\n", $HT * 100.0; printf "Read Miss: %5.2f %%\n", $RD * (1 - $HT) * 100.0; printf "WriteMiss: %5.2f %%\n", $WR * (1 - $HT) * 100.0; printf "Ucpu: %5.2f %%\n", ($Pcpu * 100.0) / $MAXCPU; printf "Pcpu: %5.2f\n", $Pcpu; printf "\n"; printf "Ubus[reads]: %5.2f %%\n", $Ubrd * 100.0; printf "Ubus[write]: %5.2f %%\n", $Ubwr * 100.0; printf "Ubus[inval]: %5.2f %%\n", $Ubin * 100.0; printf "Ubus[total]: %5.2f %%\n", ($Ubrd + $Ubwr + $Ubin) * 100.0; printf "\n"; printf "Uca%d[hits]: %5.2f %%\n", $i, $Ucht * 100.0; printf "Uca%d[reads]: %5.2f %%\n", $i, $Ucrd * 100.0; printf "Uca%d[write]: %5.2f %%\n", $i, $Ucwr * 100.0; printf "Uca%d[inval]: %5.2f %%\n", $i, $Ucin * 100.0; printf "Uca%d[total]: %5.2f %%\n", $i, ($Ucht + $Ucrd + $Ucwr + $Ucin) * 100.0; #---------------------------------------------------------------------
26.027431
106
0.450704
73dbb2293d821a758b88623887365a0df61ff349
10,014
pm
Perl
JBrowse/extlib/lib/perl5/Bio/Search/Hit/HmmpfamHit.pm
joelchaconcastillo/srnalightnxtg
a14d50d08a90ce7b3b2d0ea200046ad7a719cdc0
[ "Apache-2.0" ]
null
null
null
JBrowse/extlib/lib/perl5/Bio/Search/Hit/HmmpfamHit.pm
joelchaconcastillo/srnalightnxtg
a14d50d08a90ce7b3b2d0ea200046ad7a719cdc0
[ "Apache-2.0" ]
null
null
null
JBrowse/extlib/lib/perl5/Bio/Search/Hit/HmmpfamHit.pm
joelchaconcastillo/srnalightnxtg
a14d50d08a90ce7b3b2d0ea200046ad7a719cdc0
[ "Apache-2.0" ]
null
null
null
# # BioPerl module for Bio::Search::Hit::HmmpfamHit # # Please direct questions and support issues to <bioperl-l@bioperl.org> # # Cared for by Sendu Bala <bix@sendu.me.uk> # # Copyright Sendu Bala # # You may distribute this module under the same terms as perl itself # POD documentation - main docs before the code =head1 NAME Bio::Search::Hit::HmmpfamHit - A parser and hit object for hmmpfam hits =head1 SYNOPSIS # generally we use Bio::SearchIO to build these objects use Bio::SearchIO; my $in = Bio::SearchIO->new(-format => 'hmmer_pull', -file => 'result.hmmer'); while (my $result = $in->next_result) { while (my $hit = $result->next_hit) { print $hit->name, "\n"; print $hit->score, "\n"; print $hit->significance, "\n"; while (my $hsp = $hit->next_hsp) { # process HSPI objects } } } =head1 DESCRIPTION This object implements a parser for hmmpfam hit output, a program in the HMMER package. =head1 FEEDBACK =head2 Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists =head2 Support Please direct usage questions or support issues to the mailing list: I<bioperl-l@bioperl.org> rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. =head2 Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ =head1 AUTHOR - Sendu Bala Email bix@sendu.me.uk =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut # Let the code begin... package Bio::Search::Hit::HmmpfamHit; use strict; use Bio::Search::HSP::HmmpfamHSP; use base qw(Bio::Root::Root Bio::Search::Hit::PullHitI); =head2 new Title : new Usage : my $obj = Bio::Search::Hit::HmmpfamHit->new(); Function: Builds a new Bio::Search::Hit::HmmpfamHit object. Returns : Bio::Search::Hit::HmmpfamHit Args : -chunk => [Bio::Root::IO, $start, $end] (required if no -parent) -parent => Bio::PullParserI object (required if no -chunk) -hit_data => array ref with [name description score significance num_hsps rank] where the array ref provided to -chunk contains an IO object for a filehandle to something representing the raw data of the hit, and $start and $end define the tell() position within the filehandle that the hit data starts and ends (optional; defaults to start and end of the entire thing described by the filehandle) =cut sub new { my ($class, @args) = @_; my $self = $class->SUPER::new(@args); $self->_setup(@args); my $fields = $self->_fields; foreach my $field (qw( next_domain domains hsp_data )) { $fields->{$field} = undef; } my $hit_data = $self->_raw_hit_data; if ($hit_data && ref($hit_data) eq 'ARRAY') { foreach my $field (qw(name description score significance num_hsps rank)) { $fields->{$field} = shift(@{$hit_data}); } } $fields->{hit_start} = 1; delete $self->_fields->{accession}; $self->_dependencies( { ( length => 'hsp_data' ) } ); return $self; } # # PullParserI discovery methods so we can answer all HitI questions # sub _discover_description { # this should be set when this object is created, but if it was undef as is # possible, this _discover method will be called: just return and keep the # return value undef return; } sub _discover_hsp_data { my $self = shift; my $hsp_table = $self->get_field('hsp_table'); my $hsp_data = $hsp_table->{$self->get_field('name')} || undef; if ($hsp_data) { if (defined $hsp_data->{hit_length}) { $self->_fields->{length} = $hsp_data->{hit_length}; } # rank query_start query_end hit_start hit_end score evalue $self->_fields->{hsp_data} = $hsp_data->{hsp_data}; } } sub _discover_query_start { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; my ($this_hsp) = sort { $a->[1] <=> $b->[1] } @{$hsp_data}; $self->_fields->{query_start} = $this_hsp->[1]; } sub _discover_query_end { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; my ($this_hsp) = sort { $b->[2] <=> $a->[2] } @{$hsp_data}; $self->_fields->{query_end} = $this_hsp->[2]; } sub _discover_hit_start { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; my ($this_hsp) = sort { $a->[3] <=> $b->[3] } @{$hsp_data}; $self->_fields->{hit_start} = $this_hsp->[3]; } sub _discover_hit_end { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; my ($this_hsp) = sort { $b->[4] <=> $a->[4] } @{$hsp_data}; $self->_fields->{hit_end} = $this_hsp->[4]; } sub _discover_next_hsp { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; unless (defined $self->{_next_hsp_index}) { $self->{_next_hsp_index} = 0; } return if $self->{_next_hsp_index} == -1; $self->_fields->{next_hsp} = Bio::Search::HSP::HmmpfamHSP->new(-parent => $self, -hsp_data => $hsp_data->[$self->{_next_hsp_index}++]); if ($self->{_next_hsp_index} > $#{$hsp_data}) { $self->{_next_hsp_index} = -1; } } =head2 next_hsp Title : next_hsp Usage : while( $hsp = $obj->next_hsp()) { ... } Function : Returns the next available High Scoring Pair Example : Returns : L<Bio::Search::HSP::HSPI> object or null if finished Args : none =cut sub next_hsp { my $self = shift; my $hsp = $self->get_field('next_hsp'); undef $self->_fields->{next_hsp}; return $hsp; } =head2 next_domain Title : next_domain Usage : my $domain = $hit->next_domain(); Function: An alias for L<next_hsp()>, this will return the next HSP Returns : L<Bio::Search::HSP::HSPI> object Args : none =cut *next_domain = \&next_hsp; =head2 hsps Usage : $hit_object->hsps(); Purpose : Get a list containing all HSP objects. Example : @hsps = $hit_object->hsps(); Returns : list of L<Bio::Search::HSP::BlastHSP> objects. Argument : none =cut sub hsps { my $self = shift; my $old = $self->{_next_hsp_index} || 0; $self->rewind; my @hsps; while (defined(my $hsp = $self->next_hsp)) { push(@hsps, $hsp); } $self->{_next_hsp_index} = @hsps > 0 ? $old : -1; return @hsps; } =head2 domains Title : domains Usage : my @domains = $hit->domains(); Function: An alias for L<hsps()>, this will return the full list of hsps Returns : array of L<Bio::Search::HSP::HSPI> objects Args : none =cut *domains = \&hsps; =head2 hsp Usage : $hit_object->hsp( [string] ); Purpose : Get a single HSPI object for the present HitI object. Example : $hspObj = $hit_object->hsp; # same as 'best' : $hspObj = $hit_object->hsp('best'); : $hspObj = $hit_object->hsp('worst'); Returns : Object reference for a L<Bio::Search::HSP::HSPI> object. Argument : String (or no argument). : No argument (default) = highest scoring HSP (same as 'best'). : 'best' = highest scoring HSP. : 'worst' = lowest scoring HSP. Throws : Exception if an unrecognized argument is used. See Also : L<hsps()|hsps>, L<num_hsps>() =cut sub hsp { my ($self, $type) = @_; $type ||= 'best'; my $hsp_data = $self->get_field('hsp_data') || return; my $sort; if ($type eq 'best') { $sort = sub { $a->[6] <=> $b->[6] }; } elsif ($type eq 'worst') { $sort = sub { $b->[6] <=> $a->[6] }; } else { $self->throw("Unknown arg '$type' given to hsp()"); } my ($this_hsp) = sort $sort @{$hsp_data}; return Bio::Search::HSP::HmmpfamHSP->new(-parent => $self, -hsp_data => $this_hsp); } =head2 rewind Title : rewind Usage : $result->rewind; Function: Allow one to reset the Hit iterator to the beginning, so that next_hit() will subsequently return the first hit and so on. Returns : n/a Args : none =cut sub rewind { my $self = shift; my $hsp_data = $self->get_field('hsp_data') || return; $self->{_next_hsp_index} = @{$hsp_data} > 0 ? 0 : -1; } # have p() a synonym of significance() sub p { return shift->significance; } =head2 strand Usage : $sbjct->strand( [seq_type] ); Purpose : Gets the strand(s) for the query, sbjct, or both sequences. : For hmmpfam, the answers are always 1 (forward strand). Example : $qstrand = $sbjct->strand('query'); : $sstrand = $sbjct->strand('hit'); : ($qstrand, $sstrand) = $sbjct->strand(); Returns : scalar context: integer '1' : array context without args: list of two strings (1, 1) : Array context can be "induced" by providing an argument of 'list' : or 'array'. Argument : In scalar context: seq_type = 'query' or 'hit' or 'sbjct' (default : = 'query') ('sbjct' is synonymous with 'hit') =cut sub strand { my ($self, $type) = @_; $type ||= (wantarray ? 'list' : 'query'); $type = lc($type); if ($type eq 'list' || $type eq 'array') { return (1, 1); } return 1; } =head2 frac_aligned_query Usage : $hit_object->frac_aligned_query(); Purpose : Get the fraction of the query sequence which has been aligned : across all HSPs (not including intervals between non-overlapping : HSPs). Example : $frac_alnq = $hit_object->frac_aligned_query(); Returns : undef (the length of query sequences is unknown in Hmmpfam reports) Argument : none =cut # noop sub frac_aligned_query { } 1;
26.492063
84
0.6428
ed2de671c49e3f83794a2238970f6eb7c42d44fe
1,601
t
Perl
admin/admin/DARPA/BAA.security/V2B.t
weiss/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
114
2015-01-18T22:55:52.000Z
2022-02-17T10:45:02.000Z
admin/admin/DARPA/BAA.security/V2B.t
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
null
null
null
admin/admin/DARPA/BAA.security/V2B.t
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
29
2015-11-03T22:05:22.000Z
2022-02-08T15:36:37.000Z
.\" @(#)V2B.t 1.3 89/03/09 .nr PS 10 .nr VS 12 .LP \fB\s+4B. Budget\fP\s-4 .LP .ce April 1, 1989 - March 31, 1990 .sp2 .TS center, expand; ln. A. SALARIES AND WAGES 1. Technical (Programmer II @ 100% & Programmer III @ 100%) $ 85,361 2. Clerical Assistance (Assistant III @ 10%, Secretary @ 50%) $ 14,769 3. Administrative Services $ 10,227 TOTAL SALARIES AND WAGES $ 110,357 B. EMPLOYEE BENEFITS $ 33,383 TOTAL SALARIES AND EMPLOYEE BENEFITS $ 143,740 C. EQUIPMENT 1. 2 ea. DEC/Sun 8MB Workstations $ 19,390 2. 3 ea. SMD Disk Drives $ 33,000 3. 4 ea. Ethernet Interfaces $ 12,000 4. 4 ea. 9600 Baud Telebit Modems $ 6,400 5. 3 ea. 4 Mb Upgrades for Sun Workstations $ 9,000 6. 3 ea. 16 Mb Upgrades for VAX $ 24,000 7. 1 ea. SCSI Disks $3,200 8. 3 ea. Interphase 4400 Disk Controllers $ 15,000 9. 4 ea. High-speed Network Interfaces $ 30,000 10. 1 ea. X.25 Network Interfaces $ 5,000 11. 2 ea. Exabyte 8mm Tape Backup Systems $ 15,000 12. 1 ea. MicroVAX Gateway $ 15,000 TOTAL EQUIPMENT $ 186,990 D. TRAVEL 1. 10 R/Ts to the East Coast @ $700/trip 2. 2 R/Ts to Europe (IEEE 1003 - POSIX) @ $1,760/trip TOTAL TRAVEL $ 10,520 E. SUPPLIES AND EXPENSES 1. Computer Maintenance $ 42,908 2. Network Access $ 1,080 3. Mailing, Telephone, Xeroxing & Expendable Supplies $ 5,370 TOTAL SUPPLIES AND EXPENSES $ 49,358 F. TOTAL DIRECT COSTS $ 390,690 G. INDIRECT COSTS (48.5% of $203,619 Modified Total Direct Costs) $ 98,755 H. TOTAL COST OF PROJECT $ 489,364 .TE
25.412698
75
0.638351
ed324156551b345d757a0d9d22c817d98fa87bcb
23,340
pm
Perl
code-orig/SourceDiscovery/jmatlab/MATLAB Component Runtime/v70/sys/perl/win32/site/lib/Win32/ODBC.pm
usc-isi-i2/eidos
a40dd1b012bfa6e62756b289a1f955a877e5de3f
[ "MIT" ]
1
2021-01-21T15:42:58.000Z
2021-01-21T15:42:58.000Z
code-orig/SourceDiscovery/jmatlab/MATLAB Component Runtime/v70/sys/perl/win32/site/lib/Win32/ODBC.pm
usc-isi-i2/eidos
a40dd1b012bfa6e62756b289a1f955a877e5de3f
[ "MIT" ]
null
null
null
code-orig/SourceDiscovery/jmatlab/MATLAB Component Runtime/v70/sys/perl/win32/site/lib/Win32/ODBC.pm
usc-isi-i2/eidos
a40dd1b012bfa6e62756b289a1f955a877e5de3f
[ "MIT" ]
null
null
null
package Win32::ODBC; $VERSION = '0.03'; # Win32::ODBC.pm # +==========================================================+ # | | # | ODBC.PM package | # | --------------- | # | | # | Copyright (c) 1996, 1997 Dave Roth. All rights reserved. | # | This program is free software; you can redistribute | # | it and/or modify it under the same terms as Perl itself. | # | | # +==========================================================+ # # # based on original code by Dan DeMaggio (dmag@umich.edu) # # Use under GNU General Public License or Larry Wall's "Artistic License" # # Check the README.TXT file that comes with this package for details about # it's history. # require Exporter; require DynaLoader; $ODBCPackage = "Win32::ODBC"; $ODBCPackage::Version = 970208; $::ODBC = $ODBCPackage; $CacheConnection = 0; # Reserve ODBC in the main namespace for US! *ODBC::=\%Win32::ODBC::; @ISA= qw( Exporter DynaLoader ); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw( ODBC_ADD_DSN ODBC_REMOVE_DSN ODBC_CONFIG_DSN SQL_DONT_CLOSE SQL_DROP SQL_CLOSE SQL_UNBIND SQL_RESET_PARAMS SQL_FETCH_NEXT SQL_FETCH_FIRST SQL_FETCH_LAST SQL_FETCH_PRIOR SQL_FETCH_ABSOLUTE SQL_FETCH_RELATIVE SQL_FETCH_BOOKMARK SQL_COLUMN_COUNT SQL_COLUMN_NAME SQL_COLUMN_TYPE SQL_COLUMN_LENGTH SQL_COLUMN_PRECISION SQL_COLUMN_SCALE SQL_COLUMN_DISPLAY_SIZE SQL_COLUMN_NULLABLE SQL_COLUMN_UNSIGNED SQL_COLUMN_MONEY SQL_COLUMN_UPDATABLE SQL_COLUMN_AUTO_INCREMENT SQL_COLUMN_CASE_SENSITIVE SQL_COLUMN_SEARCHABLE SQL_COLUMN_TYPE_NAME SQL_COLUMN_TABLE_NAME SQL_COLUMN_OWNER_NAME SQL_COLUMN_QUALIFIER_NAME SQL_COLUMN_LABEL SQL_COLATT_OPT_MAX SQL_COLUMN_DRIVER_START SQL_COLATT_OPT_MIN SQL_ATTR_READONLY SQL_ATTR_WRITE SQL_ATTR_READWRITE_UNKNOWN SQL_UNSEARCHABLE SQL_LIKE_ONLY SQL_ALL_EXCEPT_LIKE SQL_SEARCHABLE ); #The above are included for backward compatibility sub new { my ($n, $self); my ($type) = shift; my ($DSN) = shift; my (@Results) = @_; if (ref $DSN){ @Results = ODBCClone($DSN->{'connection'}); }else{ @Results = ODBCConnect($DSN, @Results); } @Results = processError(-1, @Results); if (! scalar(@Results)){ return undef; } $self = bless {}; $self->{'connection'} = $Results[0]; $ErrConn = $Results[0]; $ErrText = $Results[1]; $ErrNum = 0; $self->{'DSN'} = $DSN; $self; } #### # Close this ODBC session (or all sessions) #### sub Close { my ($self, $Result) = shift; $Result = DESTROY($self); $self->{'connection'} = -1; return $Result; } #### # Auto-Kill an instance of this module #### sub DESTROY { my ($self) = shift; my (@Results) = (0); if($self->{'connection'} > -1){ @Results = ODBCDisconnect($self->{'connection'}); @Results = processError($self, @Results); if ($Results[0]){ undef $self->{'DSN'}; undef @{$self->{'fnames'}}; undef %{$self->{'field'}}; undef %{$self->{'connection'}}; } } return $Results[0]; } sub sql{ return (Sql(@_)); } #### # Submit an SQL Execute statement for processing #### sub Sql{ my ($self, $Sql, @Results) = @_; @Results = ODBCExecute($self->{'connection'}, $Sql); return updateResults($self, @Results); } #### # Retrieve data from a particular field #### sub Data{ # Change by JOC 06-APR-96 # Altered by Dave Roth <dave@roth.net> 96.05.07 my($self) = shift; my(@Fields) = @_; my(@Results, $Results, $Field); if ($self->{'Dirty'}){ GetData($self); $self->{'Dirty'} = 0; } @Fields = @{$self->{'fnames'}} if (! scalar(@Fields)); foreach $Field (@Fields) { if (wantarray) { push(@Results, data($self, $Field)); } else { $Results .= data($self, $Field); } } return wantarray ? @Results : $Results; } sub DataHash{ my($self, @Results) = @_; my(%Results, $Element); if ($self->{'Dirty'}){ GetData($self); $self->{'Dirty'} = 0; } @Results = @{$self->{'fnames'}} if (! scalar(@Results)); foreach $Element (@Results) { $Results{$Element} = data($self, $Element); } return %Results; } #### # Retrieve data from the data buffer #### sub data { $_[0]->{'data'}->{$_[1]}; } sub fetchrow{ return (FetchRow(@_)); } #### # Put a row from an ODBC data set into data buffer #### sub FetchRow{ my ($self, @Results) = @_; my ($item, $num, $sqlcode); # Added by JOC 06-APR-96 # $num = 0; $num = 0; undef $self->{'data'}; @Results = ODBCFetch($self->{'connection'}, @Results); if (! (@Results = processError($self, @Results))){ #### # There should be an innocuous error "No records remain" # This indicates no more records in the dataset #### return undef; } # Set the Dirty bit so we will go and extract data via the # ODBCGetData function. Otherwise use the cache. $self->{'Dirty'} = 1; # Return the array of field Results. return @Results; } sub GetData{ my($self) = @_; my(@Results, $num); @Results = ODBCGetData($self->{'connection'}); if (!(@Results = processError($self, @Results))){ return undef; } #### # This is a special case. Do not call processResults #### ClearError(); foreach (@Results){ s/ +$//; # HACK $self->{'data'}->{ ${$self->{'fnames'}}[$num] } = $_; $num++; } # return is a hack to interface with a assoc array. return wantarray? (1, 1): 1; } #### # See if any more ODBC Results Sets # Added by Brian Dunfordshore <Brian_Dunfordshore@bridge.com> # 96.07.10 #### sub MoreResults{ my ($self) = @_; my(@Results) = ODBCMoreResults($self->{'connection'}); return (processError($self, @Results))[0]; } #### # Retrieve the catalog from the current DSN # NOTE: All Field names are uppercase!!! #### sub Catalog{ my ($self) = shift; my ($Qualifier, $Owner, $Name, $Type) = @_; my (@Results) = ODBCTableList($self->{'connection'}, $Qualifier, $Owner, $Name, $Type); # If there was an error return 0 else 1 return (updateResults($self, @Results) != 1); } #### # Return an array of names from the catalog for the current DSN # TableList($Qualifier, $Owner, $Name, $Type) # Return: (array of names of tables) # NOTE: All Field names are uppercase!!! #### sub TableList{ my ($self) = shift; my (@Results) = @_; if (! scalar(@Results)){ @Results = ("", "", "%", "TABLE"); } if (! Catalog($self, @Results)){ return undef; } undef @Results; while (FetchRow($self)){ push(@Results, Data($self, "TABLE_NAME")); } return sort(@Results); } sub fieldnames{ return (FieldNames(@_)); } #### # Return an array of fieldnames extracted from the current dataset #### sub FieldNames { $self = shift; return @{$self->{'fnames'}}; } #### # Closes this connection. This is used mostly for testing. You should # probably use Close(). #### sub ShutDown{ my($self) = @_; print "\nClosing connection $self->{'connection'}..."; $self->Close(); print "\nDone\n"; } #### # Return this connection number #### sub Connection{ my($self) = @_; return $self->{'connection'}; } #### # Returns the current connections that are in use. #### sub GetConnections{ return ODBCGetConnections(); } #### # Set the Max Buffer Size for this connection. This determines just how much # ram can be allocated when a fetch() is performed that requires a HUGE amount # of memory. The default max is 10k and the absolute max is 100k. # This will probably never be used but I put it in because I noticed a fetch() # of a MEMO field in an Access table was something like 4Gig. Maybe I did # something wrong, but after checking several times I decided to impliment # this limit thingie. #### sub SetMaxBufSize{ my($self, $Size) = @_; my(@Results) = ODBCSetMaxBufSize($self->{'connection'}, $Size); return (processError($self, @Results))[0]; } #### # Returns the Max Buffer Size for this connection. See SetMaxBufSize(). #### sub GetMaxBufSize{ my($self) = @_; my(@Results) = ODBCGetMaxBufSize($self->{'connection'}); return (processError($self, @Results))[0]; } #### # Returns the DSN for this connection as an associative array. #### sub GetDSN{ my($self, $DSN) = @_; if(! ref($self)){ $DSN = $self; $self = 0; } if (! $DSN){ $self = $self->{'connection'}; } my(@Results) = ODBCGetDSN($self, $DSN); return (processError($self, @Results)); } #### # Returns an associative array of $XXX{'DSN'}=Description #### sub DataSources{ my($self, $DSN) = @_; if(! ref $self){ $DSN = $self; $self = 0; } my(@Results) = ODBCDataSources($DSN); return (processError($self, @Results)); } #### # Returns an associative array of $XXX{'Driver Name'}=Driver Attributes #### sub Drivers{ my($self) = @_; if(! ref $self){ $self = 0; } my(@Results) = ODBCDrivers(); return (processError($self, @Results)); } #### # Returns the number of Rows that were affected by the previous SQL command. #### sub RowCount{ my($self, $Connection) = @_; if (! ref($self)){ $Connection = $self; $self = 0; } if (! $Connection){$Connection = $self->{'connection'};} my(@Results) = ODBCRowCount($Connection); return (processError($self, @Results))[0]; } #### # Returns the Statement Close Type -- how does ODBC Close a statment. # Types: # SQL_DROP # SQL_CLOSE # SQL_UNBIND # SQL_RESET_PARAMS #### sub GetStmtCloseType{ my($self, $Connection) = @_; if (! ref($self)){ $Connection = $self; $self = 0; } if (! $Connection){$Connection = $self->{'connection'};} my(@Results) = ODBCGetStmtCloseType($Connection); return (processError($self, @Results)); } #### # Sets the Statement Close Type -- how does ODBC Close a statment. # Types: # SQL_DROP # SQL_CLOSE # SQL_UNBIND # SQL_RESET_PARAMS # Returns the newly set value. #### sub SetStmtCloseType{ my($self, $Type, $Connection) = @_; if (! ref($self)){ $Connection = $Type; $Type = $self; $self = 0; } if (! $Connection){$Connection = $self->{'connection'};} my(@Results) = ODBCSetStmtCloseType($Connection, $Type); return (processError($self, @Results))[0]; } sub ColAttributes{ my($self, $Type, @Field) = @_; my(%Results, @Results, $Results, $Attrib, $Connection, $Temp); if (! ref($self)){ $Type = $Field; $Field = $self; $self = 0; } $Connection = $self->{'connection'}; if (! scalar(@Field)){ @Field = $self->fieldnames;} foreach $Temp (@Field){ @Results = ODBCColAttributes($Connection, $Temp, $Type); ($Attrib) = processError($self, @Results); if (wantarray){ $Results{$Temp} = $Attrib; }else{ $Results .= "$Temp"; } } return wantarray? %Results:$Results; } sub GetInfo{ my($self, $Type) = @_; my($Connection, @Results); if(! ref $self){ $Type = $self; $self = 0; $Connection = 0; }else{ $Connection = $self->{'connection'}; } @Results = ODBCGetInfo($Connection, $Type); return (processError($self, @Results))[0]; } sub GetConnectOption{ my($self, $Type) = @_; my(@Results); if(! ref $self){ $Type = $self; $self = 0; } @Results = ODBCGetConnectOption($self->{'connection'}, $Type); return (processError($self, @Results))[0]; } sub SetConnectOption{ my($self, $Type, $Value) = @_; if(! ref $self){ $Value = $Type; $Type = $self; $self = 0; } my(@Results) = ODBCSetConnectOption($self->{'connection'}, $Type, $Value); return (processError($self, @Results))[0]; } sub Transact{ my($self, $Type) = @_; my(@Results); if(! ref $self){ $Type = $self; $self = 0; } @Results = ODBCTransact($self->{'connection'}, $Type); return (processError($self, @Results))[0]; } sub SetPos{ my($self, @Results) = @_; @Results = ODBCSetPos($self->{'connection'}, @Results); $self->{'Dirty'} = 1; return (processError($self, @Results))[0]; } sub ConfigDSN{ my($self) = shift @_; my($Type, $Connection); if(! ref $self){ $Type = $self; $Connection = 0; $self = 0; }else{ $Type = shift @_; $Connection = $self->{'connection'}; } my($Driver, @Attributes) = @_; @Results = ODBCConfigDSN($Connection, $Type, $Driver, @Attributes); return (processError($self, @Results))[0]; } sub Version{ my($self, @Packages) = @_; my($Temp, @Results); if (! ref($self)){ push(@Packages, $self); } my($ExtName, $ExtVersion) = Info(); if (! scalar(@Packages)){ @Packages = ("ODBC.PM", "ODBC.PLL"); } foreach $Temp (@Packages){ if ($Temp =~ /pll/i){ push(@Results, "ODBC.PM:$Win32::ODBC::Version"); }elsif ($Temp =~ /pm/i){ push(@Results, "ODBC.PLL:$ExtVersion"); } } return @Results; } sub SetStmtOption{ my($self, $Option, $Value) = @_; if(! ref $self){ $Value = $Option; $Option = $self; $self = 0; } my(@Results) = ODBCSetStmtOption($self->{'connection'}, $Option, $Value); return (processError($self, @Results))[0]; } sub GetStmtOption{ my($self, $Type) = @_; if(! ref $self){ $Type = $self; $self = 0; } my(@Results) = ODBCGetStmtOption($self->{'connection'}, $Type); return (processError($self, @Results))[0]; } sub GetFunctions{ my($self, @Results)=@_; @Results = ODBCGetFunctions($self->{'connection'}, @Results); return (processError($self, @Results)); } sub DropCursor{ my($self) = @_; my(@Results) = ODBCDropCursor($self->{'connection'}); return (processError($self, @Results))[0]; } sub SetCursorName{ my($self, $Name) = @_; my(@Results) = ODBCSetCursorName($self->{'connection'}, $Name); return (processError($self, @Results))[0]; } sub GetCursorName{ my($self) = @_; my(@Results) = ODBCGetCursorName($self->{'connection'}); return (processError($self, @Results))[0]; } sub GetSQLState{ my($self) = @_; my(@Results) = ODBCGetSQLState($self->{'connection'}); return (processError($self, @Results))[0]; } # ----------- R e s u l t P r o c e s s i n g F u n c t i o n s ---------- #### # Generic processing of data into associative arrays #### sub updateResults{ my ($self, $Error, @Results) = @_; undef %{$self->{'field'}}; ClearError($self); if ($Error){ SetError($self, $Results[0], $Results[1]); return ($Error); } @{$self->{'fnames'}} = @Results; foreach (0..$#{$self->{'fnames'}}){ s/ +$//; $self->{'field'}->{${$self->{'fnames'}}[$_]} = $_; } return undef; } # ---------------------------------------------------------------------------- # ----------------- D e b u g g i n g F u n c t i o n s -------------------- sub Debug{ my($self, $iDebug, $File) = @_; my(@Results); if (! ref($self)){ if (defined $self){ $File = $iDebug; $iDebug = $self; } $Connection = 0; $self = 0; }else{ $Connection = $self->{'connection'}; } push(@Results, ($Connection, $iDebug)); push(@Results, $File) if ($File ne ""); @Results = ODBCDebug(@Results); return (processError($self, @Results))[0]; } #### # Prints out the current dataset (used mostly for testing) #### sub DumpData { my($self) = @_; my($f, $goo); # Changed by JOC 06-Apr-96 # print "\nDumping Data for connection: $conn->{'connection'}\n"; print "\nDumping Data for connection: $self->{'connection'}\n"; print "Error: \""; print $self->Error(); print "\"\n"; if (! $self->Error()){ foreach $f ($self->FieldNames){ print $f . " "; $goo .= "-" x length($f); $goo .= " "; } print "\n$goo\n"; while ($self->FetchRow()){ foreach $f ($self->FieldNames){ print $self->Data($f) . " "; } print "\n"; } } } sub DumpError{ my($self) = @_; my($ErrNum, $ErrText, $ErrConn); my($Temp); print "\n---------- Error Report: ----------\n"; if (ref $self){ ($ErrNum, $ErrText, $ErrConn) = $self->Error(); ($Temp = $self->GetDSN()) =~ s/.*DSN=(.*?);.*/$1/i; print "Errors for \"$Temp\" on connection " . $self->{'connection'} . ":\n"; }else{ ($ErrNum, $ErrText, $ErrConn) = Error(); print "Errors for the package:\n"; } print "Connection Number: $ErrConn\nError number: $ErrNum\nError message: \"$ErrText\"\n"; print "-----------------------------------\n"; } #### # Submit an SQL statement and print data about it (used mostly for testing) #### sub Run{ my($self, $Sql) = @_; print "\nExcecuting connection $self->{'connection'}\nsql statement: \"$Sql\"\n"; $self->Sql($Sql); print "Error: \""; print $self->error; print "\"\n"; print "--------------------\n\n"; } # ---------------------------------------------------------------------------- # ----------- E r r o r P r o c e s s i n g F u n c t i o n s ------------ #### # Process Errors returned from a call to ODBCxxxx(). # It is assumed that the Win32::ODBC function returned the following structure: # ($ErrorNumber, $ResultsText, ...) # $ErrorNumber....0 = No Error # >0 = Error Number # $ResultsText.....if no error then this is the first Results element. # if error then this is the error text. #### sub processError{ my($self, $Error, @Results) = @_; if ($Error){ SetError($self, $Results[0], $Results[1]); undef @Results; } return @Results; } #### # Return the last recorded error message #### sub error{ return (Error(@_)); } sub Error{ my($self) = @_; if(ref($self)){ if($self->{'ErrNum'}){ my($State) = ODBCGetSQLState($self->{'connection'}); return (wantarray)? ($self->{'ErrNum'}, $self->{'ErrText'}, $self->{'connection'}, $State) :"[$self->{'ErrNum'}] [$self->{'connection'}] [$State] \"$self->{'ErrText'}\""; } }elsif ($ErrNum){ return (wantarray)? ($ErrNum, $ErrText, $ErrConn):"[$ErrNum] [$ErrConn] \"$ErrText\""; } return undef } #### # SetError: # Assume that if $self is not a reference then it is just a placeholder # and should be ignored. #### sub SetError{ my($self, $Num, $Text, $Conn) = @_; if (ref $self){ $self->{'ErrNum'} = $Num; $self->{'ErrText'} = $Text; $Conn = $self->{'connection'} if ! $Conn; } $ErrNum = $Num; $ErrText = $Text; #### # Test Section Begin #### # $! = ($Num, $Text); #### # Test Section End #### $ErrConn = $Conn; } sub ClearError{ my($self, $Num, $Text) = @_; if (ref $self){ undef $self->{'ErrNum'}; undef $self->{'ErrText'}; }else{ undef $ErrConn; undef $ErrNum; undef $ErrText; } ODBCCleanError(); return 1; } sub GetError{ my($self, $Connection) = @_; my(@Results); if (! ref($self)){ $Connection = $self; $self = 0; }else{ if (! defined($Connection)){ $Connection = $self->{'connection'}; } } @Results = ODBCGetError($Connection); return @Results; } # ---------------------------------------------------------------------------- # ------------------ A U T O L O A D F U N C T I O N ----------------------- sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; #reset $! to zero to reset any current errors. $!=0; $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { # Added by JOC 06-APR-96 # $pack = 0; $pack = 0; ($pack,$file,$line) = caller; print "Your vendor has not defined Win32::ODBC macro $constname, used in $file at line $line."; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; } # -------------------------------------------------------------- # # # Make sure that we shutdown ODBC and free memory even if we are # using perlis.dll on Win32 platform! END{ # ODBCShutDown() unless $CacheConnection; } bootstrap Win32::ODBC; # Preloaded methods go here. # Autoload methods go after __END__, and are processed by the autosplit program. 1; __END__
25.933333
183
0.502656
ed36d4ce72107a7345bc11ff6e386c21ea0b85f1
1,458
pm
Perl
modules/Bio/EnsEMBL/Production/Pipeline/Release/DivisionFactory.pm
lairdm/ensembl-production
c2b9ef27fb715a518e48eb729f975c688932eb67
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Production/Pipeline/Release/DivisionFactory.pm
lairdm/ensembl-production
c2b9ef27fb715a518e48eb729f975c688932eb67
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Production/Pipeline/Release/DivisionFactory.pm
lairdm/ensembl-production
c2b9ef27fb715a518e48eb729f975c688932eb67
[ "Apache-2.0" ]
null
null
null
=head1 LICENSE Copyright [2009-2016] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 NAME Bio::EnsEMBL::Production::Pipeline::Release::DivisionFactory; =head1 DESCRIPTION =head1 AUTHOR ckong@ebi.ac.uk =cut package Bio::EnsEMBL::Production::Pipeline::Release::DivisionFactory; use strict; use Data::Dumper; use Bio::EnsEMBL::Registry; use base('Bio::EnsEMBL::Production::Pipeline::Common::Base'); sub fetch_input { my ($self) = @_; return 0; } sub run { my ($self) = @_; return 0; } sub write_output { my ($self) = @_; my $division = $self->param_required('division'); if ( ref($division) ne 'ARRAY' ) { $division = [$division]; } foreach my $div (@$division) { $self->dataflow_output_id( { 'division' => $div, 'prod_db' => $self->param_required('prod_db'), }, 2 ); } return 0; } 1;
20.25
72
0.659808
73d8d383924588d58837373c650e1bbfe86f8540
9,187
t
Perl
t/02-valdiff.t
bgeels/GLPlugin
e157e89015796f45699f6936cc694798e2b95299
[ "Artistic-2.0", "Unlicense" ]
13
2016-07-26T12:07:04.000Z
2021-11-08T08:18:35.000Z
t/02-valdiff.t
bgeels/GLPlugin
e157e89015796f45699f6936cc694798e2b95299
[ "Artistic-2.0", "Unlicense" ]
13
2016-04-04T21:10:41.000Z
2022-03-03T10:44:26.000Z
t/02-valdiff.t
bgeels/GLPlugin
e157e89015796f45699f6936cc694798e2b95299
[ "Artistic-2.0", "Unlicense" ]
38
2015-08-27T08:39:15.000Z
2021-11-08T08:33:01.000Z
#!perl use 5.006; use strict; use warnings; use Test::More; plan tests => 54; push(@INC, '/home/lausser/git/GLPlugin/blib/lib', '/home/lausser/git/GLPlugin/blib/arch' ); require Monitoring::GLPlugin; @ARGV = ( '--mode', 'uptime', '--statefilesdir', '/tmp', '--timeout', '1000', #'-vvvvvvvvvvvvvvvvvvvvvvvv', ); my $plugin = Monitoring::GLPlugin->new( shortname => '', usage => 'Usage: %s [ -v|--verbose ] [ -t <timeout> ] '. ' ...]', version => '$Revision: #PACKAGE_VERSION# $', blurb => 'This plugin checks nothing ', url => 'http://labs.consol.de/nagios/', timeout => 60, ); $plugin->add_mode( internal => 'device::uptime', spec => 'uptime', alias => undef, help => 'Check the uptime of the device', ); $plugin->add_default_args(); $plugin->getopts(); $plugin->override_opt("mode", "uptime"); $plugin->validate_args(); sub clean_plugin { my @elements = @_; map { delete $plugin->{'delta_'.$_}; delete $plugin->{$_.'_per_sec'}; delete $plugin->{'delta_found_'.$_}; delete $plugin->{'delta_lost_'.$_}; } @elements; delete $plugin->{delta_timestamp}; } diag("statefile is ".$plugin->create_statefile(name => 'test')); diag("now test ever growing metrics. shrinking means overrun"); unlink $plugin->create_statefile(name => 'test') if -f $plugin->create_statefile(name => 'test'); $plugin->{metric} = 0; $plugin->valdiff({name => 'test'}, qw(metric)); ok(exists $plugin->{delta_metric}, 'delta_metric was created'); ok($plugin->{delta_metric} == 0, 'delta_metric is 0'); $plugin->{metric} = 10; $plugin->valdiff({name => 'test'}, qw(metric)); ok($plugin->{delta_metric} == 10, 'delta_metric is 10'); $plugin->{metric} = 5; $plugin->valdiff({name => 'test'}, qw(metric)); ok($plugin->{delta_metric} == 5, 'delta_metric is 5, overrun'); clean_plugin(qw(metric)); diag("now test growing and shrinking metrics"); unlink $plugin->create_statefile(name => 'test', lastarray => 1) if -f $plugin->create_statefile(name => 'test', lastarray => 1); $plugin->{metric} = 0; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok(exists $plugin->{delta_metric}, 'delta_metric was created'); ok($plugin->{delta_metric} == 0, 'delta_metric is 0'); sleep 1; $plugin->{metric} = 10; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok($plugin->{delta_metric} == 10, 'delta_metric is 10'); sleep 1; $plugin->{metric} = 5; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); diag("delta ". $plugin->{delta_metric}); ok($plugin->{delta_metric} == -5, 'delta_metric is -5'); clean_plugin(qw(metric)); diag("now test growing and shrinking metrics, compare to a value in the past"); # # example: check the number of wlan access points managed by a controller # 5 APs disappear (stolen?) and you don't want to use a volatile check # keep the critical state for a certain time # $plugin->override_opt("lookback", "10"); unlink $plugin->create_statefile(name => 'test', lastarray => 1) if -f $plugin->create_statefile(name => 'test', lastarray => 1); $plugin->{metric} = 10; my $tentime = time; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok(exists $plugin->{delta_metric}, 'delta_metric was created'); ok($plugin->{delta_metric} == 10, 'delta_metric is 10'); sleep 1; diag("suddenly count is only 5"); $plugin->{metric} = 5; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok($plugin->{delta_metric} == -5, 'delta_metric is -5'); diag("delta -5 must be the result for the next 10 seconds"); sleep 5; $plugin->{metric} = 5; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok($plugin->{delta_metric} == -5, 'delta_metric is still -5'); sleep 2; $plugin->{metric} = 5; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); ok($plugin->{delta_metric} == -5, 'delta_metric is still -5'); foreach (1..12) { last if (time > $tentime+10); sleep 1; } sleep 1; $plugin->{metric} = 5; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric)); diag(sprintf "after %ds delta is %d", time - $tentime, $plugin->{delta_metric}); ok($plugin->{delta_metric} == 0, 'delta_metric is 0'); $plugin->override_opt("lookback", undef); clean_plugin(qw(metric)); diag("now test growing and shrinking metrics"); diag("now test growing and shrinking lists"); unlink $plugin->create_statefile(name => 'test', lastarray => 1) if -f $plugin->create_statefile(name => 'test', lastarray => 1); $plugin->{metric} = 5; $plugin->{list} = ["ELEM1", "ELEM2", "ELEM3", "ELEM4", "ELEM5"]; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok(exists $plugin->{delta_metric}, 'delta_metric was created'); ok($plugin->{delta_metric} == 5, 'delta_metric is 5'); ok(scalar(@{$plugin->{delta_found_list}}) == 5, 'delta_found_list is 5'); ok(scalar(@{$plugin->{delta_lost_list}}) == 0, 'delta_lost_list is 0'); sleep 1; $plugin->{metric} = 3; $plugin->{list} = ["ELEM1", "ELEM3", "ELEM5"]; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); diag("delta ". $plugin->{delta_metric}); ok($plugin->{delta_metric} == -2, 'delta_metric is -2'); ok(scalar(grep /ELEM1/, @{$plugin->{list}}) != 0); ok(scalar(grep /ELEM1/, @{$plugin->{delta_found_list}}) == 0); ok(scalar(grep /ELEM1/, @{$plugin->{delta_lost_list}}) == 0); ok(scalar(grep /ELEM2/, @{$plugin->{list}}) == 0); ok(scalar(grep /ELEM2/, @{$plugin->{delta_found_list}}) == 0); ok(scalar(grep /ELEM2/, @{$plugin->{delta_lost_list}}) != 0); sleep 1; $plugin->{metric} = 3; $plugin->{list} = ["ELEM1", "ELEM2", "ELEM3"]; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); diag("delta ". $plugin->{delta_metric}); ok($plugin->{delta_metric} == 0, 'delta_metric is 0'); ok(scalar(grep /ELEM1/, @{$plugin->{list}}) != 0); ok(scalar(grep /ELEM1/, @{$plugin->{delta_found_list}}) == 0); ok(scalar(grep /ELEM1/, @{$plugin->{delta_lost_list}}) == 0); ok(scalar(grep /ELEM2/, @{$plugin->{list}}) != 0); ok(scalar(grep /ELEM2/, @{$plugin->{delta_found_list}}) != 0); ok(scalar(grep /ELEM2/, @{$plugin->{delta_lost_list}}) == 0); ok(scalar(grep /ELEM5/, @{$plugin->{list}}) == 0); ok(scalar(grep /ELEM5/, @{$plugin->{delta_found_list}}) == 0); ok(scalar(grep /ELEM5/, @{$plugin->{delta_lost_list}}) != 0); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok($plugin->{delta_metric} == 0, 'delta_metric is unchanged'); ok(scalar(@{$plugin->{delta_found_list}}) == 0, 'delta_found_list is empty'); ok(scalar(@{$plugin->{delta_lost_list}}) == 0, 'delta_lost_list is empty'); clean_plugin(qw(metric list)); diag("now test growing and shrinking metrics, compare to a value in the past"); diag("now test growing and shrinking lists, compare to a list in the past"); $plugin->override_opt("lookback", "10"); unlink $plugin->create_statefile(name => 'test', lastarray => 1) if -f $plugin->create_statefile(name => 'test', lastarray => 1); $plugin->{metric} = 5; $plugin->{list} = ["ELEM1", "ELEM2", "ELEM3", "ELEM4", "ELEM5"]; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok(exists $plugin->{delta_metric}, 'delta_metric was created'); ok($plugin->{delta_metric} == 5, 'delta_metric is 5'); ok(scalar(@{$plugin->{delta_found_list}}) == 5, 'delta_found_list is 5'); ok(scalar(@{$plugin->{delta_lost_list}}) == 0, 'delta_lost_list is 0'); clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); sleep 11; clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); sleep 1; $tentime = time; $plugin->{metric} = 3; $plugin->{list} = ["ELEM1", "ELEM2", "ELEM3"]; diag("state change, ELEM4 and ELEM5 lost"); clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok($plugin->{delta_metric} == -2, 'delta_metric is -2'); ok(scalar(@{$plugin->{delta_found_list}}) == 0, 'delta_found_list is 0'); ok(scalar(@{$plugin->{delta_lost_list}}) == 2, 'delta_lost_list is 2'); sleep 1; diag("should still be the same"); clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok($plugin->{delta_metric} == -2, 'delta_metric is -2'); ok(scalar(@{$plugin->{delta_found_list}}) == 0, 'delta_found_list is 0'); ok(scalar(@{$plugin->{delta_lost_list}}) == 2, 'delta_lost_list is 2'); sleep 1; clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok($plugin->{delta_metric} == -2, 'delta_metric is -2'); ok(scalar(@{$plugin->{delta_found_list}}) == 0, 'delta_found_list is 0'); ok(scalar(@{$plugin->{delta_lost_list}}) == 2, 'delta_lost_list is 2'); foreach (1..12) { last if (time > $tentime+10); sleep 1; $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); } sleep 1; clean_plugin(qw(metric list)); $plugin->valdiff({name => 'test', lastarray => 1}, qw(metric list)); ok($plugin->{delta_metric} == 0, 'delta_metric is 0'); ok(scalar(@{$plugin->{delta_found_list}}) == 0, 'delta_found_list is 0'); ok(scalar(@{$plugin->{delta_lost_list}}) == 0, 'delta_lost_list is 0'); diag(sprintf "after %ds delta is %d", time - $tentime, $plugin->{delta_metric});
40.650442
80
0.645804
ed1e1bc6ff998fdeb2ff1db62d88edc1b950dac6
7,863
pm
Perl
lib/Data/Feed.pm
ThisUsedToBeAnEmail/Data-Feed
c4eb40c276b5ee8de14f5fd353563405f26168a7
[ "Artistic-2.0", "Unlicense" ]
2
2016-05-17T01:46:30.000Z
2016-06-08T14:33:49.000Z
lib/Data/Feed.pm
ThisUsedToBeAnEmail/Data-Feed
c4eb40c276b5ee8de14f5fd353563405f26168a7
[ "Artistic-2.0", "Unlicense" ]
null
null
null
lib/Data/Feed.pm
ThisUsedToBeAnEmail/Data-Feed
c4eb40c276b5ee8de14f5fd353563405f26168a7
[ "Artistic-2.0", "Unlicense" ]
null
null
null
package Data::Feed; use Moose; use Carp qw(carp croak); use Data::Feed::Parser; use Data::Feed::Stream; use Data::Feed::Object; use Data::Dumper; use Scalar::Util; use JSON; use 5.006; our $VERSION = '0.01'; has 'feed' => ( is => 'rw', isa => 'ArrayRef[Data::Feed::Object]', lazy => 1, traits => ['Array'], default => sub { [ ] }, handles => { all => 'elements', count => 'count', get => 'get', pop => 'pop', delete => 'delete', insert => 'unshift', is_empty => 'is_empty', } ); sub parse { my ($self, $stream) = @_; if (!$stream) { croak "No stream was provided to parse()."; } my $parser = Data::Feed::Parser->new( stream => Data::Feed::Stream->new(stream => $stream)->open_stream )->parse; my $parsed = $parser->parse; my $feed = $parser->feed; $feed ? carp 'parse success' : return carp 'parse failed'; if ($self->count >= 1) { $self->insert(@{ $parsed }); } else { $self->feed($parsed); } return 1; } sub write { my ($self, $stream, $type) = @_; if (!$stream || $stream =~ m{^http}) { croak "No valid stream was provided to write"; } Data::Feed::Stream->new(stream => $stream)->write_file($self->render); return 1; } sub render { my ( $self, $format ) = @_; $format ||= 'text'; $format = '_' . $format; return $self->$format('render'); } sub generate { my ( $self, $format ) = @_; $format ||= 'text'; $format = '_' . $format; return $self->$format('generate'); } sub _raw { my ( $self, $type ) = @_; my @render = $self->_convert_feed($type, 'raw'); if ($type eq q{render}) { return join "\n", @render; } else { return \@render; } } sub _text { my ( $self, $type ) = @_; my @render = $self->_convert_feed($type, 'text'); if ($type eq q{render}) { return join "\n", @render; } else { return \@render; } } sub _json { my ( $self ) = @_; my @render = $self->_convert_feed('generate', 'json'); my $json = JSON->new->allow_nonref; return $json->pretty->encode( \@render ); } sub _convert_feed { my ( $self, $type, $format ) = @_; my @render; foreach my $object ( $self->all ) { push @render, $object->$type($format); } return @render; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME Data::Feed =head1 VERSION Version 0.5 =head1 SYNOPSIS use Data::Feed; my $feed = Data::Feed->new(); $feed->parse( '***' ); $feed->all; $feed->count; $feed->delete(Index1, Index2..); $feed->get(Index1, Index2..); $feed->write( 'path/to/empty.xml' ); my $feed_text = $feed->render('text'); # TODO make Object an array of hash refs foreach my $object ( $feed->all ) { $object->render('text'); # text, html, xml.. $object->hash('text'); # text, html, xml... $object->fields('title', 'description'); # returns title and description object $object->edit(title => 'WoW', description => 'something amazing'); # sets # missing fields $object->title->raw; $object->link->raw; $object->description->raw; $object->image->raw; $object->date->raw; # missing lots $entry->title->as_text; } =head1 DESCRIPTION Data::Feed is a frontend for building dynamic data feeds. =over =back =head1 Methods =over =back =head2 parse Populates the feed Attribute, this is an Array of Data::Feed::Object 's You can currently build Feeds by parsing xml (RSS, ATOM) and static HTML via Meta Tags (twitter, opengraph); =over =item URI # any rss/atom feed or a web page that contains og or twitter markup $feed->parse( 'http://examples.com/feed.xml' ); =cut =item File $feed->parse( 'path/to/feed.xml' ); =cut =item Raw $feed->parse( 'qq{<?xml version="1.0"><feed> .... </feed>} ); =cut =back =head2 all returns all elements in the current feed =over =back =head2 count returns the count of the current data feed =over =back =head2 get accepts an integer and returns an Data::Feed::Object from feed by its Array index =over =back =head2 pop pop the first Data::Feed::Object from the current feed =over =back =head2 delete accepts an integer and deletes the relevant Data::Feed::Object based on its Array index =over =back =head2 insert insert an 'Data::Feed::Object' into the feed =over =back =head2 is_empty returns true if Data::Feed is empty. =over =back =head2 render render the feed using the passed in format, defaults to text. # raw - as taken from the feed # text - stripped to plain text # json $feed->render('raw'); =over =back =head2 generate returns the feed object as a Array of hashes but with the values rendered, key being the field. You can also pass in a format. $feed->hash('text'); =over =back =head1 AUTHOR =head1 BUGS Please report any bugs or feature requests to C<bug-data-feed at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Feed>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. You can also look for information at: =over 4 =item * RT: CPAN's request tracker (report bugs here) L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Feed> =item * AnnoCPAN: Annotated CPAN documentation L<http://annocpan.org/dist/Data-Feed> =item * CPAN Ratings L<http://cpanratings.perl.org/d/Data-Feed> =item * Search CPAN L<http://search.cpan.org/dist/Data-Feed/> =back =head1 ACKNOWLEDGEMENTS =head1 LICENSE AND COPYRIGHT Copyright 2016 LNATION. This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: L<http://www.perlfoundation.org/artistic_license_2_0> Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =cut 1; # End of Data::Feed
20.746702
126
0.652168
73d58b8c8a280b68578f431b8fd335a553989ec0
2,203
pm
Perl
auto-lib/Paws/WorkSpaces/CreateTags.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/WorkSpaces/CreateTags.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/WorkSpaces/CreateTags.pm
meis/aws-sdk-perl
6d61ffcf351e446f06d7e84e53caa08d98573959
[ "Apache-2.0" ]
null
null
null
package Paws::WorkSpaces::CreateTags; use Moose; has ResourceId => (is => 'ro', isa => 'Str', required => 1); has Tags => (is => 'ro', isa => 'ArrayRef[Paws::WorkSpaces::Tag]', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'CreateTags'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::WorkSpaces::CreateTagsResult'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::WorkSpaces::CreateTags - Arguments for method CreateTags on L<Paws::WorkSpaces> =head1 DESCRIPTION This class represents the parameters used for calling the method CreateTags on the L<Amazon WorkSpaces|Paws::WorkSpaces> service. Use the attributes of this class as arguments to method CreateTags. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to CreateTags. =head1 SYNOPSIS my $workspaces = Paws->service('WorkSpaces'); my $CreateTagsResult = $workspaces->CreateTags( ResourceId => 'MyNonEmptyString', Tags => [ { Key => 'MyTagKey', # min: 1, max: 127 Value => 'MyTagValue', # max: 255; OPTIONAL }, ... ], ); Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/workspaces/CreateTags> =head1 ATTRIBUTES =head2 B<REQUIRED> ResourceId => Str The identifier of the WorkSpace. To find this ID, use DescribeWorkspaces. =head2 B<REQUIRED> Tags => ArrayRef[L<Paws::WorkSpaces::Tag>] The tags. Each WorkSpace can have a maximum of 50 tags. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method CreateTags in L<Paws::WorkSpaces> =head1 BUGS and CONTRIBUTIONS The source code is located here: L<https://github.com/pplu/aws-sdk-perl> Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> =cut
29.373333
249
0.689514
ed5add72b65f0c2ad132f578a839583bf931b0b7
8,916
pl
Perl
data/ip-country.pl
pbiering/IP2Location-C-Library
7a3198a8222cf6dce2270a8f639f54771b0f0594
[ "MIT" ]
null
null
null
data/ip-country.pl
pbiering/IP2Location-C-Library
7a3198a8222cf6dce2270a8f639f54771b0f0594
[ "MIT" ]
null
null
null
data/ip-country.pl
pbiering/IP2Location-C-Library
7a3198a8222cf6dce2270a8f639f54771b0f0594
[ "MIT" ]
null
null
null
#!/usr/bin/perl use strict; use Math::BigInt; &csv2bin_ipv4; &csv2bin_ipv6; sub csv2bin_ipv4 { my $dbtype = 1; my $ipv4_infilename = "IP-COUNTRY.CSV"; my $ipv4_outfilename = "IP-COUNTRY.BIN"; my $ipv6_index_base = 0; my $ipv6_count = 0; my $ipv6_base = 0; my $ipv4_index_base = 64; my %ipv4_index_row_min; my %ipv4_index_row_max; my $ipv4_count = 0; my $ipv4_base = $ipv4_index_base + 256**2*8; my $longsize = 4; my $columnsize = 2; my %country; my @sorted_country; print STDOUT "$ipv4_infilename to $ipv4_outfilename conversion started (can take some time).\n"; open IN, "<$ipv4_infilename" or die "Error open $ipv4_infilename"; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($ipv4_infilename); while (<IN>) { chomp($_); $_ =~ s/^\"//; $_ =~ s/\"$//; my @array = split (/\",\"/, $_); $country{$array[2]}{"LONG"} = $array[3]; my $no2from = &ipv4_first2octet($array[0]); my $no2to = &ipv4_first2octet($array[1]); foreach my $no2 ($no2from .. $no2to) { if (!defined($ipv4_index_row_min{$no2})) { $ipv4_index_row_min{$no2} = $ipv4_count; } $ipv4_index_row_max{$no2} = $ipv4_count; } $ipv4_count++; } close IN; $country{"-"}{"-"}++; $ipv4_count++; my $addr = $ipv4_base + $ipv4_count * $longsize * $columnsize; @sorted_country = sort keys(%country); foreach my $co (@sorted_country) { $country{$co}{"ADDR"} = $addr; $addr = $addr + 1 + 2 + 1 + length($country{$co}{"LONG"}); } my ($second, $minute, $hour, $day, $month, $year, $weekday, $dayofyear, $isdst) = gmtime($mtime); open OUT, ">$ipv4_outfilename" or die "Error writing $ipv4_outfilename"; binmode(OUT); print OUT pack("C", $dbtype); print OUT pack("C", $columnsize); print OUT pack("C", $year - 100); print OUT pack("C", $month + 1); print OUT pack("C", $day); print OUT pack("V", $ipv4_count); print OUT pack("V", $ipv4_base + 1); print OUT pack("V", $ipv6_count); print OUT pack("V", $ipv6_base + 1); print OUT pack("V", $ipv4_index_base + 1); print OUT pack("V", $ipv6_index_base + 1); foreach my $i (29 .. 63) { print OUT pack("C", 0); } foreach my $c (sort {$a <=> $b} keys(%ipv4_index_row_min)) { print OUT pack("V", $ipv4_index_row_min{$c}); print OUT pack("V", $ipv4_index_row_max{$c}); } my $p = tell(OUT); if ($p != 524352) { print STDERR "$ipv4_outfilename Index Out of Range\b"; die; } open IN, "<$ipv4_infilename" or die; while (<IN>) { chomp($_); $_ =~ s/^\"//; $_ =~ s/\"$//; my @array = split (/\",\"/, $_); print OUT pack("V", $array[0]); print OUT pack("V", $country{$array[2]}{"ADDR"}); } close IN; print OUT pack("V", 4294967295); print OUT pack("V", $country{"-"}{"ADDR"}); foreach my $co (@sorted_country) { print OUT pack("C", length($co)); print OUT $co; if ($co eq "-") { print OUT " "; } if ($co eq "UK") { print STDERR "ERROR: UK should not be in the database!\n"; die; } print OUT pack("C", length($country{$co}{"LONG"})); print OUT $country{$co}{"LONG"}; } close OUT; print STDOUT "$ipv4_infilename to $ipv4_outfilename conversion done.\n"; } sub csv2bin_ipv6 { my $dbtype = 1; my $ipv4_infilename = "IP-COUNTRY.CSV"; my $ipv6_infilename = "IP-COUNTRY.6.CSV"; my $ipv6_outfilename = "IPV6-COUNTRY.BIN"; my $ipv4_index_base = 64; my $ipv6_index_base = $ipv4_index_base + 256**2*8; my %ipv4_index_row_min; my %ipv4_index_row_max; my %ipv6_index_row_min; my %ipv6_index_row_max; my $ipv4_count = 0; my $ipv4_base = $ipv6_index_base + 256**2*8; my $longsize = 4; my $columnsize = 2; my $ipv6_longsize = 16; my $ipv6_count = 0; my $ipv6_base = 0; my %country; my @sorted_country; print STDOUT "$ipv6_infilename + $ipv4_infilename to $ipv6_outfilename conversion started (can take some time).\n"; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); open IN, "<$ipv4_infilename" or die "Error open $ipv4_infilename"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($ipv4_infilename); my $ip2location_mtime = $mtime; while (<IN>) { chomp($_); $_ =~ s/^\"//; $_ =~ s/\"$//; my @array = split (/\",\"/, $_); if ($array[2] eq "UK") { $array[2] = "GB"; } $country{$array[2]}{"LONG"} = $array[3]; my $no2from = &ipv4_first2octet($array[0]); my $no2to = &ipv4_first2octet($array[1]); foreach my $no2 ($no2from .. $no2to) { if (!defined($ipv4_index_row_min{$no2})) { $ipv4_index_row_min{$no2} = $ipv4_count; } $ipv4_index_row_max{$no2} = $ipv4_count; } $ipv4_count++; } close IN; open IN, "<$ipv6_infilename" or die "Error open $ipv6_infilename"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($ipv4_infilename); $ip2location_mtime = $mtime if ($mtime > $ip2location_mtime); # select newest while (<IN>) { chomp($_); $_ =~ s/^\"//; $_ =~ s/\"$//; my @array = split (/\",\"/, $_); $country{$array[2]}{"LONG"} = $array[3]; my $no2from = new Math::BigInt(&ipv6_first2octet($array[0])); my $no2to = new Math::BigInt(&ipv6_first2octet($array[1])); foreach my $no2 ($no2from .. $no2to) { if (!defined($ipv6_index_row_min{$no2})) { $ipv6_index_row_min{$no2} = $ipv6_count; } $ipv6_index_row_max{$no2} = $ipv6_count; } $ipv6_count++; } close IN; $country{"-"}{"-"}++; $ipv4_count++; $ipv6_count++; $ipv6_base = $ipv4_base + $ipv4_count * $longsize * $columnsize; my $addr = $ipv6_base + $ipv6_count * $longsize * ($columnsize + 3); #IPv6 address range is 4 bytes vs 1 byte in IPv4 @sorted_country = sort keys(%country); foreach my $co (@sorted_country) { $country{$co}{"ADDR"} = $addr; $addr = $addr + 1 + 2 + 1 + length($country{$co}{"LONG"}); } my ($second, $minute, $hour, $day, $month, $year, $weekday, $dayofyear, $isdst) = gmtime($ip2location_mtime); open OUT, ">$ipv6_outfilename" or die "Error writing $ipv6_outfilename"; binmode(OUT); #binary mode print OUT pack("C", $dbtype); print OUT pack("C", $columnsize); print OUT pack("C", $year - 100); print OUT pack("C", $month + 1); print OUT pack("C", $day); print OUT pack("V", $ipv4_count); print OUT pack("V", $ipv4_base + 1); print OUT pack("V", $ipv6_count); print OUT pack("V", $ipv6_base + 1); print OUT pack("V", $ipv4_index_base + 1); print OUT pack("V", $ipv6_index_base + 1); foreach my $i (29 .. 63) { print OUT pack("C", 0); } foreach my $c (sort {$a <=> $b} keys(%ipv4_index_row_min)) { print OUT pack("V", $ipv4_index_row_min{$c}); print OUT pack("V", $ipv4_index_row_max{$c}); } foreach my $c (sort {$a <=> $b} keys(%ipv6_index_row_min)) { print OUT pack("V", $ipv6_index_row_min{$c}); print OUT pack("V", $ipv6_index_row_max{$c}); } my $p = tell(OUT); if ($p != 1048640) { print STDERR "$ipv6_outfilename $p Index Out of Range\b"; die; } open IN, "<$ipv4_infilename" or die; while (<IN>) { chomp($_); $_ =~ s/^\"//; $_ =~ s/\"$//; my @array = split (/\",\"/, $_); if ($array[2] eq "UK") { $array[2] = "GB"; } print OUT pack("V", $array[0]); print OUT pack("V", $country{$array[2]}{"ADDR"}); } close IN; print OUT pack("V", 4294967295); print OUT pack("V", $country{"-"}{"ADDR"}); # export IPv6 range open IN, "<$ipv6_infilename" or die; while (<IN>) { my @array = &splitcsv($_); print OUT &int2bytes($array[0]); print OUT pack("V", $country{$array[2]}{"ADDR"}); } close IN; print OUT &int2bytes("340282366920938463463374607431768211455"); print OUT pack("V", $country{"-"}{"ADDR"}); foreach my $co (@sorted_country) { print OUT pack("C", length($co)); print OUT $co; if ($co eq "-") { print OUT " "; } if ($co eq "UK") { print STDERR "ERROR: UK should not be in the database!\n"; $co = "GB"; } print OUT pack("C", length($country{$co}{"LONG"})); print OUT $country{$co}{"LONG"}; } close OUT; print STDOUT "$ipv6_infilename + $ipv4_infilename to $ipv6_outfilename conversion done.\n"; } sub int2bytes { my $ip = new Math::BigInt(shift(@_)); my $binip1_31 = 0; my $binip32_63 = 0; my $binip64_95 = 0; my $binip96_127 = 0; ($ip, $binip1_31) = $ip->bdiv(4294967296); ($ip, $binip32_63) = $ip->bdiv(4294967296); ($ip, $binip64_95) = $ip->bdiv(4294967296); ($ip, $binip96_127) = $ip->bdiv(4294967296); return pack("V", $binip1_31) . pack("V", $binip32_63) .pack("V", $binip64_95) .pack("V", $binip96_127); } sub splitcsv { my $line = shift (@_); return () unless $line; my @cells; chomp($line); while($line =~ /(?:^|,)(?:\"([^\"]*)\"|([^,]*))/g) { my $value = defined $1 ? $1 : $2; push @cells, (defined $value ? $value : ''); } return @cells; } sub ipv4_first2octet { my $no = shift(@_); $no = $no >> 16; return $no; } sub ipv6_first2octet { my $ip = new Math::BigInt(shift(@_)); my $remainder = 0; ($ip, $remainder) = $ip->bdiv(2**112); }
26.456973
118
0.608345
73fa3170108da721f6eaf4fc654eacad39f4e8f8
12,940
pm
Perl
modules/Bio/EnsEMBL/Compara/RunnableDB/EpoLowCoverage/ImportAlignment.pm
dbolser-ebi/ensembl-compara
9a98ca2dc2cd4e09ff1861789d96da0c9477921e
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Compara/RunnableDB/EpoLowCoverage/ImportAlignment.pm
dbolser-ebi/ensembl-compara
9a98ca2dc2cd4e09ff1861789d96da0c9477921e
[ "Apache-2.0" ]
null
null
null
modules/Bio/EnsEMBL/Compara/RunnableDB/EpoLowCoverage/ImportAlignment.pm
dbolser-ebi/ensembl-compara
9a98ca2dc2cd4e09ff1861789d96da0c9477921e
[ "Apache-2.0" ]
null
null
null
=head1 LICENSE Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =head1 NAME Bio::EnsEMBL::Compara::RunnableDB::EpoLowCoverage::ImportAlignment =head1 SYNOPSIS =head1 DESCRIPTION This module imports a specified alignment. This is used in the low coverage genome alignment pipeline for importing the high coverage alignment which is used to build the low coverage genomes on. =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut package Bio::EnsEMBL::Compara::RunnableDB::EpoLowCoverage::ImportAlignment; use strict; use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::Utils::Exception qw(throw); use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable'); =head2 fetch_input Title : fetch_input Usage : $self->fetch_input Function: Fetches input data for gerp from the database Returns : none Args : none =cut sub fetch_input { my( $self) = @_; #create a Compara::DBAdaptor which shares the same DBI handle #with $self->db (Hive DBAdaptor) $self->compara_dba->dbc->disconnect_when_inactive(0); } =head2 run Title : run Usage : $self->run Function: Run gerp Returns : none Args : none =cut sub run { my $self = shift; #Quick and dirty import, assuming the 2 databases are on the same server. Useful for debugging if ($self->param('quick')) { $self->importAlignment_quick(); } else { $self->importAlignment(); } } =head2 write_output Title : write_output Usage : $self->write_output Function: Write results to the database Returns : 1 Args : none =cut sub write_output { my ($self) = @_; return 1; } #Uses copy_data method from copy_data.pl script sub importAlignment { my $self = shift; #if the database name is defined in the url, then open that if ($self->param('from_db_url') =~ /mysql:\/\/.*@.*\/.+/) { $self->param('from_comparaDBA', new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor(-url=>$self->param('from_db_url'))); } else { #open the most recent compara database $self->param('from_comparaDBA', Bio::EnsEMBL::Registry->get_DBAdaptor("Multi", "compara")); } my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name("import_alignment"); my $dbname = $self->param('from_comparaDBA')->dbc->dbname; my $analysis_id = $analysis->dbID; my $mlss_id = $self->param('method_link_species_set_id'); my $step = $self->param('step'); ##Find min and max of the relevant internal IDs in the FROM database my $sth = $self->param('from_comparaDBA')->dbc->prepare("SELECT MIN(gab.genomic_align_block_id), MAX(gab.genomic_align_block_id), MIN(ga.genomic_align_id), MAX(ga.genomic_align_id), MIN(gat.node_id), MAX(gat.node_id), MIN(gat.root_id), MAX(gat.root_id) FROM genomic_align_block gab LEFT JOIN genomic_align ga using (genomic_align_block_id) LEFT JOIN genomic_align_tree gat ON gat.node_id = ga.node_id WHERE gab.method_link_species_set_id = ?"); $sth->execute($mlss_id); my ($min_gab, $max_gab, $min_ga, $max_ga, $min_node_id, $max_node_id, $min_root_id, $max_root_id) = $sth->fetchrow_array(); $sth->finish(); #HACK to just copy over one chr (22) for testing purposes #my $dnafrag_id = 905407; my $dnafrag_id; if ($self->param('dnafrag_id')) { $dnafrag_id = $self->param('dnafrag_id'); } #Copy the method_link_species_set copy_data($self->param('from_comparaDBA'), $self->compara_dba, "method_link_species_set", undef, undef, undef, "SELECT * FROM method_link_species_set WHERE method_link_species_set_id = $mlss_id"); #Copy the species_set copy_data($self->param('from_comparaDBA'), $self->compara_dba, "species_set", undef, undef, undef, "SELECT species_set.* FROM species_set JOIN method_link_species_set USING (species_set_id) WHERE method_link_species_set_id = $mlss_id"); #copy genomic_align_block table if ($dnafrag_id) { copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align_block", "genomic_align_block_id", $min_gab, $max_gab, "SELECT gab.* FROM genomic_align_block gab LEFT JOIN genomic_align ga USING (genomic_align_block_id) WHERE ga.method_link_species_set_id = $mlss_id AND dnafrag_id=$dnafrag_id", $step); } else { copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align_block", "genomic_align_block_id", $min_gab, $max_gab, "SELECT * FROM genomic_align_block WHERE method_link_species_set_id = $mlss_id", $step); } #copy genomic_align_tree table if ($dnafrag_id) { copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align_tree", "root_id", $min_root_id, $max_root_id, "SELECT gat.*". " FROM genomic_align_tree gat LEFT JOIN genomic_align USING (node_id)". " WHERE node_id IS NOT NULL AND method_link_species_set_id = $mlss_id AND dnafrag_id=$dnafrag_id", $step); } else { copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align_tree", "root_id", $min_root_id, $max_root_id, "SELECT gat.*". " FROM genomic_align ga". " JOIN dnafrag USING (dnafrag_id)". " LEFT JOIN genomic_align_tree gat USING (node_id) WHERE ga.node_id IS NOT NULL AND ga.method_link_species_set_id = $mlss_id AND genome_db_id != 63", $step); } #copy genomic_align table if ($dnafrag_id) { copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align", "genomic_align_id", $min_ga, $max_ga, "SELECT ga.*". " FROM genomic_align ga ". " WHERE method_link_species_set_id = $mlss_id AND dnafrag_id=$dnafrag_id", $step); } else { # copy_data($self->{'from_comparaDBA'}, $self->compara_dba, # "genomic_align", # "genomic_align_id", # $min_ga, $max_ga, # "SELECT *". # " FROM genomic_align". # " WHERE method_link_species_set_id = $mlss_id"); #Don't copy over ancestral genomic_aligns copy_data($self->param('from_comparaDBA'), $self->compara_dba, "genomic_align", "genomic_align_id", $min_ga, $max_ga, "SELECT genomic_align.*". " FROM genomic_align JOIN dnafrag USING (dnafrag_id)". " WHERE method_link_species_set_id = $mlss_id AND genome_db_id != 63", $step); } } =head2 copy_data Arg[1] : Bio::EnsEMBL::Compara::DBSQL::DBAdaptor $from_dba Arg[2] : Bio::EnsEMBL::Compara::DBSQL::DBAdaptor $to_dba Arg[3] : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $this_mlss Arg[4] : string $table Arg[5] : string $sql_query Description : copy data in this table using this SQL query. Returns : Exceptions : throw if argument test fails =cut sub copy_data { my ($from_dba, $to_dba, $table_name, $index_name, $min_id, $max_id, $query, $step) = @_; print "Copying data in table $table_name\n"; my $sth = $from_dba->dbc->db_handle->column_info($from_dba->dbc->dbname, undef, $table_name, '%'); $sth->execute; my $all_rows = $sth->fetchall_arrayref; my $binary_mode = 0; foreach my $this_col (@$all_rows) { if (($this_col->[5] eq "BINARY") or ($this_col->[5] eq "VARBINARY") or ($this_col->[5] eq "BLOB") or ($this_col->[5] eq "BIT")) { $binary_mode = 1; last; } } #speed up writing of data by disabling keys, write the data, then enable $to_dba->dbc->do("ALTER TABLE `$table_name` DISABLE KEYS"); if ($binary_mode) { #copy_data_in_binary_mode($from_dba, $to_dba, $table_name, $query); } else { copy_data_in_text_mode($from_dba, $to_dba, $table_name, $index_name, $min_id, $max_id, $query, $step); } $to_dba->dbc->do("ALTER TABLE `$table_name` ENABLE KEYS"); } =head2 copy_data_in_text_mode Arg[1] : Bio::EnsEMBL::Compara::DBSQL::DBAdaptor $from_dba Arg[2] : Bio::EnsEMBL::Compara::DBSQL::DBAdaptor $to_dba Arg[3] : Bio::EnsEMBL::Compara::MethodLinkSpeciesSet $this_mlss Arg[4] : string $table Arg[5] : string $sql_query Description : copy data in this table using this SQL query. Returns : Exceptions : throw if argument test fails =cut sub copy_data_in_text_mode { my ($from_dba, $to_dba, $table_name, $index_name, $min_id, $max_id, $query, $step) = @_; my $user = $to_dba->dbc->username; my $pass = $to_dba->dbc->password; my $host = $to_dba->dbc->host; my $port = $to_dba->dbc->port; my $dbname = $to_dba->dbc->dbname; my $use_limit = 0; my $start = $min_id; #my $step = 100000; #my $step = 10000; #Default step size. if (!defined $step) { $step = 10000; } #If not using BETWEEN, revert back to LIMIT if (!defined $index_name && !defined $min_id && !defined $max_id) { $use_limit = 1; $start = 0; } while (1) { my $end = $start + $step - 1; my $sth; if (!$use_limit) { $sth = $from_dba->dbc->prepare($query." AND $index_name BETWEEN $start AND $end"); } else { $sth = $from_dba->dbc->prepare($query." LIMIT $start, $step"); } $start += $step; $sth->execute(); my $all_rows = $sth->fetchall_arrayref; ## EXIT CONDITION return if (!@$all_rows); my $filename = "/tmp/$table_name.copy_data.$$.txt"; open(TEMP, ">$filename") or die; foreach my $this_row (@$all_rows) { print TEMP join("\t", map {defined($_)?$_:'\N'} @$this_row), "\n"; } close(TEMP); if ($pass) { unless (system("mysqlimport", "-u$user", "-p$pass", "-h$host", "-P$port", "-L", "-l", "-i", $dbname, $filename) == 0) { throw("Failed mysqlimport -u$user -p$pass -h$host -P$port -L -l -i $dbname $filename"); } } else { unless (system("mysqlimport", "-u$user", "-h$host", "-P$port", "-L", "-l", "-i", $dbname, $filename) ==0) { throw("Failed mysqlimport -u$user -h$host -P$port -L -l -i $dbname $filename"); } } unlink("$filename"); } } #Assumes the from and to databases are on the same server and downloads all entries from genomic_align_block, genomic_align #and genomic_align_tree sub importAlignment_quick { my $self = shift; #if the database name is defined in the url, then open that if ($self->param('from_db_url') =~ /mysql:\/\/.*@.*\/.+/) { $self->param('from_comparaDBA', new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor(-url=>$self->param('from_db_url'))); } else { #open the most recent compara database $self->param('from_comparaDBA', Bio::EnsEMBL::Registry->get_DBAdaptor("Multi", "compara")); } my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name("import_alignment"); my $dbname = $self->param('from_comparaDBA')->dbc->dbname; my $analysis_id = $analysis->dbID; my $mlss_id = $self->param('method_link_species_set_id'); #my $sql = "INSERT INTO genomic_align_block SELECT * FROM ?.genomic_align_block WHERE method_link_species_set_id = ?\n"; my $sql = "INSERT INTO genomic_align_block SELECT * FROM $dbname.genomic_align_block\n"; my $sth = $self->compara_dba->dbc->prepare($sql); $sth->execute(); #$sth->execute($dbname, $mlss_id); $sth->finish(); #$sql = "INSERT INTO genomic_align SELECT genomic_align.* FROM ?.genomic_align LEFT JOIN WHERE method_link_species_set_id = ?\n"; $sql = "INSERT INTO genomic_align SELECT * FROM $dbname.genomic_align\n"; my $sth = $self->compara_dba->dbc->prepare($sql); $sth->execute(); #$sth->execute($dbname, $mlss_id); $sth->finish(); #$sql = "INSERT INTO genomic_align_tree SELECT genomic_align_tree.* FROM ?.genomic_align_tree LEFT JOIN ?.genomic_align_group USING (node_id) LEFT JOIN ?.genomic_align USING (genomic_align_id) LEFT JOIN ?.genomic_align_block WHERE genomic_align_block.method_link_species_set_id = ?\n"; $sql = "INSERT INTO genomic_align_tree SELECT * FROM $dbname.genomic_align_tree\n"; my $sth = $self->compara_dba->dbc->prepare($sql); #$sth->execute($dbname, $dbname, $dbname, $dbname, $mlss_id); $sth->execute(); $sth->finish(); } 1;
32.926209
289
0.671175
ed66ebb6281bec30958428dd54c4657a0f30ca84
2,943
pm
Perl
centreon/common/powershell/hyperv/2012/scvmmintegrationservice.pm
seliger111/centreon-plugins
0a4fa66817a106a0523842da95bf782190746f62
[ "Apache-2.0" ]
null
null
null
centreon/common/powershell/hyperv/2012/scvmmintegrationservice.pm
seliger111/centreon-plugins
0a4fa66817a106a0523842da95bf782190746f62
[ "Apache-2.0" ]
null
null
null
centreon/common/powershell/hyperv/2012/scvmmintegrationservice.pm
seliger111/centreon-plugins
0a4fa66817a106a0523842da95bf782190746f62
[ "Apache-2.0" ]
null
null
null
# # Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package centreon::common::powershell::hyperv::2012::scvmmintegrationservice; use strict; use warnings; use centreon::plugins::misc; sub get_powershell { my (%options) = @_; my $no_ps = (defined($options{no_ps})) ? 1 : 0; return '' if ($no_ps == 1); my $ps = ' $culture = new-object "System.Globalization.CultureInfo" "en-us" [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture $ProgressPreference = "SilentlyContinue" Try { $ErrorActionPreference = "Stop" Import-Module -Name "virtualmachinemanager" $username = "' . $options{scvmm_username} . '" $password = ConvertTo-SecureString "' . $options{scvmm_password} . '" -AsPlainText -Force $UserCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password $connection = Get-VMMServer -ComputerName "' . $options{scvmm_hostname} . '" -TCPPort ' . $options{scvmm_port} . ' -Credential $UserCredential $vms = Get-SCVirtualMachine -VMMServer $connection Foreach ($vm in $vms) { $desc = $vm.description -replace "\r","" $desc = $desc -replace "\n"," - " Write-Host ("[VM={0}]" -f $vm.Name) -NoNewline Write-Host ("[Description={0}]" -f $desc) -NoNewline Write-Host ("[Status={0}]" -f $vm.Status) -NoNewline Write-Host ("[Cloud={0}]" -f $vm.Cloud) -NoNewline Write-Host ("[HostGroup={0}]" -f $vm.HostGroupPath) -NoNewline Write-Host ("[VMAddition={0}]" -f $vm.VMAddition) -NoNewline Write-Host ("[OperatingSystemShutdownEnabled={0}]" -f $vm.OperatingSystemShutdownEnabled) -NoNewline Write-Host ("[TimeSynchronizationEnabled={0}]" -f $vm.TimeSynchronizationEnabled) -NoNewline Write-Host ("[DataExchangeEnabled={0}]" -f $vm.DataExchangeEnabled) -NoNewline Write-Host ("[HeartbeatEnabled={0}]" -f $vm.HeartbeatEnabled) -NoNewline Write-Host ("[BackupEnabled={0}]" -f $vm.BackupEnabled) } } Catch { Write-Host $Error[0].Exception exit 1 } exit 0 '; return centreon::plugins::misc::powershell_encoded($ps); } 1; __END__ =head1 DESCRIPTION Method to get hyper-v informations. =cut
35.457831
146
0.686714
73db4d456d273e65a02427c64ac0eea3e802d62b
740
t
Perl
examples/external_module/complex_deps.t
f0rmiga/rules_perl
0deb110fbb652081fe4f6a9bd4ccf89022112f96
[ "Apache-2.0" ]
null
null
null
examples/external_module/complex_deps.t
f0rmiga/rules_perl
0deb110fbb652081fe4f6a9bd4ccf89022112f96
[ "Apache-2.0" ]
null
null
null
examples/external_module/complex_deps.t
f0rmiga/rules_perl
0deb110fbb652081fe4f6a9bd4ccf89022112f96
[ "Apache-2.0" ]
null
null
null
# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Include a module that is pure perl - no need to compile it use strict; use warnings; use Test::More tests => 1; use_ok("IO::Tty");
32.173913
74
0.75
73d99ef6002676f06955a0b45efce47aa684dac6
2,711
pl
Perl
posda/posdatools/Posda/bin/BackgroundStructLinkageCheck.pl
UAMS-DBMI/PosdaTools
7d33605da1b88e4787a1368dbecaffda1df95e5b
[ "Apache-2.0" ]
6
2019-01-17T15:47:44.000Z
2022-02-02T16:47:25.000Z
posda/posdatools/Posda/bin/BackgroundStructLinkageCheck.pl
UAMS-DBMI/PosdaTools
7d33605da1b88e4787a1368dbecaffda1df95e5b
[ "Apache-2.0" ]
23
2016-06-08T21:51:36.000Z
2022-03-02T08:11:44.000Z
posda/posdatools/Posda/bin/BackgroundStructLinkageCheck.pl
UAMS-DBMI/PosdaTools
7d33605da1b88e4787a1368dbecaffda1df95e5b
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/perl -w use strict; use File::Temp qw/ tempfile /; use Posda::BackgroundProcess; use Posda::DownloadableFile; use Posda::DB::PosdaFilesQueries; my $usage = <<EOF; BackgroundStructLinkageCheck.pl <bkgrnd_id> <notify_email> or BackgroundStructLinkageCheck.pl -h Generates a csv report file Sends email when done, which includes a link to the report Expect input lines in following format: <file_id>&<collection>&<site>&<patient_id>&<series_instance_uid> EOF $|=1; unless($#ARGV == 1 ){ die $usage } my ($invoc_id, $notify) = @ARGV; my $background = Posda::BackgroundProcess->new($invoc_id, $notify); my %Files; my $num_lines; while(my $line = <STDIN>){ chomp $line; $num_lines += 1; $background->LogInputLine($line); my($file_id, $collection, $site, $pat_id, $series_instance_uid) = split(/&/, $line); if(exists $Files{$file_id}){ print "File id: $file_id has multiple rows\n"; } $Files{$file_id} = { collection => $collection, site => $site, patient_id => $pat_id, series => $series_instance_uid }; } my $num_files = keys %Files; print "$num_files files identified\n"; $background->ForkAndExit; close STDOUT; close STDIN; $background->LogInputCount($num_lines); ############################################# print STDERR "In child\n"; my $get_sop_ref = PosdaDB::Queries->GetQueryInstance( "GetSopOfPlanReferenceByDose"); my $get_ref_info = PosdaDB::Queries->GetQueryInstance( "GetExistenceClassModalityUniquenessOfReferencedFile"); $background->WriteToReport("\"Collection\"," . "\"Site\",\"Patient Id\",\"Series\"," . "\"FileId\",\"Summary\"" . "\r\n"); my @Files = sort keys %Files; { print STDERR "$num_files files to process in child\n"; my $date = `date`; $background->WriteToEmail("At: $date\nEntering background:\n" . "Script: Starting BackgroundStructLinkageCheck.pl\n"); $background->WriteToEmail("Files to process:$num_files\n"); } File: for my $i (0 .. $#Files){ my $file_id = $Files[$i]; my $file_info = $Files{$file_id}; { # Until implemented... $background->WriteToReport("\"$file_info->{collection}\"," . "\"$file_info->{site}\"," . "\"$file_info->{patient_id}\"," . "\"$file_info->{series}\"," . "\"$file_id\"," . "\"Checking Not currently implemented\"," . "\r\n"); next File; } } ############################################# $background->LogCompletionTime; my $link = $background->GetReportDownloadableURL; my $report_file_id = $background->GetReportFileID; { my $date = `date`; $background->WriteToEmail("$date\nFinished\n"); $background->WriteToEmail("Report url: $link\n"); $background->WriteToEmail("Report file_id: $report_file_id\n"); }
27.11
68
0.649945
ed10dbba76527d4c7ec928fdc7e86d888a082227
500
pl
Perl
t/request_tests/cluster_settings.pl
krux/ElasticSearch.pm
655f9d4fe6dacc4a1962cb389b9216ae38ff4fbc
[ "BSD-3-Clause" ]
2
2015-11-20T17:08:51.000Z
2021-11-08T01:09:16.000Z
t/request_tests/cluster_settings.pl
krux/ElasticSearch.pm
655f9d4fe6dacc4a1962cb389b9216ae38ff4fbc
[ "BSD-3-Clause" ]
null
null
null
t/request_tests/cluster_settings.pl
krux/ElasticSearch.pm
655f9d4fe6dacc4a1962cb389b9216ae38ff4fbc
[ "BSD-3-Clause" ]
3
2016-10-12T09:33:27.000Z
2021-11-10T01:58:36.000Z
#!perl use Test::More; use strict; use warnings; our $es; my $r; ok $es->update_cluster_settings( transient => { "discovery.zen.minimum_master_nodes" => 2 }, persistent => { "discovery.zen.minimum_master_nodes" => 3 } ), 'Update cluster settings'; ok $r= $es->cluster_settings(), 'Get cluster settings'; is $r->{transient}{"discovery.zen.minimum_master_nodes"}, 2, ' - transient set'; is $r->{persistent}{"discovery.zen.minimum_master_nodes"}, 3, ' - persistent set'; 1;
22.727273
64
0.664
73e3439dda7208858851089579033b69daa6feff
2,065
pm
Perl
auto-lib/Paws/MediaPackage/DeleteOriginEndpoint.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
164
2015-01-08T14:58:53.000Z
2022-02-20T19:16:24.000Z
auto-lib/Paws/MediaPackage/DeleteOriginEndpoint.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
348
2015-01-07T22:08:38.000Z
2022-01-27T14:34:44.000Z
auto-lib/Paws/MediaPackage/DeleteOriginEndpoint.pm
0leksii/aws-sdk-perl
b2132fe3c79a06fd15b6137e8a0eb628de722e0f
[ "Apache-2.0" ]
87
2015-04-22T06:29:47.000Z
2021-09-29T14:45:55.000Z
package Paws::MediaPackage::DeleteOriginEndpoint; use Moose; has Id => (is => 'ro', isa => 'Str', traits => ['ParamInURI'], uri_name => 'id', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'DeleteOriginEndpoint'); class_has _api_uri => (isa => 'Str', is => 'ro', default => '/origin_endpoints/{id}'); class_has _api_method => (isa => 'Str', is => 'ro', default => 'DELETE'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::MediaPackage::DeleteOriginEndpointResponse'); 1; ### main pod documentation begin ### =head1 NAME Paws::MediaPackage::DeleteOriginEndpoint - Arguments for method DeleteOriginEndpoint on L<Paws::MediaPackage> =head1 DESCRIPTION This class represents the parameters used for calling the method DeleteOriginEndpoint on the L<AWS Elemental MediaPackage|Paws::MediaPackage> service. Use the attributes of this class as arguments to method DeleteOriginEndpoint. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DeleteOriginEndpoint. =head1 SYNOPSIS my $mediapackage = Paws->service('MediaPackage'); my $DeleteOriginEndpointResponse = $mediapackage->DeleteOriginEndpoint( Id => 'My__string', ); Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/mediapackage/DeleteOriginEndpoint> =head1 ATTRIBUTES =head2 B<REQUIRED> Id => Str The ID of the OriginEndpoint to delete. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method DeleteOriginEndpoint in L<Paws::MediaPackage> =head1 BUGS and CONTRIBUTIONS The source code is located here: L<https://github.com/pplu/aws-sdk-perl> Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> =cut
33.852459
249
0.733656
ed217cde5687771e284e3a89b1896c903054b8cc
935
pm
Perl
lib/HiveWeb/Schema/Result/PurchaseSoda.pm
rexxar-tc/HiveWeb
1c2305cf7b0b5d635573a042555799347659dc9a
[ "BSD-3-Clause" ]
5
2017-12-18T21:33:38.000Z
2019-10-02T02:42:07.000Z
lib/HiveWeb/Schema/Result/PurchaseSoda.pm
rexxar-tc/HiveWeb
1c2305cf7b0b5d635573a042555799347659dc9a
[ "BSD-3-Clause" ]
150
2017-12-09T14:42:38.000Z
2021-03-19T15:40:20.000Z
lib/HiveWeb/Schema/Result/PurchaseSoda.pm
rexxar-tc/HiveWeb
1c2305cf7b0b5d635573a042555799347659dc9a
[ "BSD-3-Clause" ]
4
2019-11-13T22:38:15.000Z
2021-07-08T17:01:39.000Z
use utf8; package HiveWeb::Schema::Result::PurchaseSoda; use strict; use warnings; use Moose; use MooseX::NonMoose; use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::Core'; __PACKAGE__->table('purchase_soda'); __PACKAGE__->add_columns( 'purchase_id', { data_type => 'uuid', is_foreign_key => 1, is_nullable => 0, size => 16 }, 'soda_id', { data_type => 'uuid', is_foreign_key => 1, is_nullable => 0, size => 16 }, 'soda_quantity', { data_type => 'integer', is_nullable => 0 }, ); __PACKAGE__->set_primary_key('purchase_id', 'soda_id'); __PACKAGE__->belongs_to( 'purchase', 'HiveWeb::Schema::Result::Purchase', { purchase_id => 'purchase_id' }, { is_deferrable => 0, on_delete => 'RESTRICT', on_update => 'RESTRICT' }, ); __PACKAGE__->belongs_to( 'soda', 'HiveWeb::Schema::Result::SodaStatus', { soda_id => 'soda_id' }, { is_deferrable => 0, on_delete => 'RESTRICT', on_update => 'RESTRICT' }, ); 1;
23.375
76
0.674866
ed6a1646abd0c2529ab082cb4d9e8ed8d8d0a2c2
12,056
pl
Perl
board/config.pl
f2d/bakareha
d4db4281148ac26179f81c37c3ce78b4d44282aa
[ "MIT" ]
null
null
null
board/config.pl
f2d/bakareha
d4db4281148ac26179f81c37c3ce78b4d44282aa
[ "MIT" ]
null
null
null
board/config.pl
f2d/bakareha
d4db4281148ac26179f81c37c3ce78b4d44282aa
[ "MIT" ]
null
null
null
# # Example config file. # # Uncomment and edit the options you want to specifically change from the # default values. You must specify ADMIN_PASS and SECRET. # # System config use constant ADMIN_PASS => 'CHANGE_ME'; # Admin password. CHANGE THIS to something you will remember. #use constant NUKE_PASS => 'CHANGE_ME'; # Optional password to discard all board content. Leave out to disable. use constant SECRET => 'CHANGE_ME'; # Cryptographic secret. CHANGE THIS to something totally random, and long. #use constant CAPPED_TRIPS => ('!!example1'=>' capcode','!!example2'=>' <span class="cap">Cap-tan</span>'); # Usage: posterName!!tripCodePassword # Admin tripcode hash, for startng threads when locked down, and similar. # Format is '!trip'=>'capcode', where 'capcode' is what is shown instead of the trip. # This can contain HTML, but keep it valid XHTML! # Page look use constant TITLE => 'Feedback and help'; # Name of this image board #use constant SHOWTITLETXT => 1; # Show TITLE at top (1: yes 0: no) #use constant SHOWTITLEIMG => 0; # Show image at top (0: no, 1: single, 2: rotating) #use constant TITLEIMG => 'title.jpg'; # Title image (point to a script file if rotating) #use constant THREADS_DISPLAYED => 10; # Number of threads on the front page #use constant THREADS_LISTED => 40; # Number of threads in the thread list #use constant REPLIES_PER_THREAD => 10; # Replies shown #use constant S_ADMIN_CONTACT_LINK => 'admin@'.$ENV{HTTP_HOST}; #use constant S_ANONAME => 'Anonymous'; # Defines what to print if there is no text entered in the name field use constant S_HOME_PATH => '/'; use constant S_BOARD_PATH => '/board/'; use constant DEFAULT_STYLE => 'Ace'; # Default CSS style title # Limitations #use constant ALLOW_TEXT_THREADS => 1; # Allow users to create text threads #use constant ALLOW_TEXT_REPLIES => 1; # Allow users to make text replies #use constant AUTOCLOSE_POSTS => 0; # Maximum number of posts before a thread closes. 0 to disable. #use constant AUTOCLOSE_DAYS => 0; # Maximum number of days with no activity before a thread closes. 0 to disable. #use constant AUTOCLOSE_SIZE => 0; # Maximum size of the thread HTML file in kilobytes before a thread closes. 0 to disable. use constant MAX_RES => 200; # Maximum topic bumps #use constant MAX_THREADS => 0; # Maximum number of threads - set to 0 to disable #use constant MAX_POSTS => 0; # Maximum number of posts - set to 0 to disable #use constant MAX_MEGABYTES => 0; # Maximum size to use for all images in megabytes - set to 0 to disable #use constant MAX_FIELD_LENGTH => 100; # Maximum number of characters in subject, name, and email #use constant MAX_COMMENT_LENGTH => 8192; # Maximum number of characters in a comment #use constant MAX_LINES_SHOWN => 15; # Max lines of a comment shown on the main page (0 = no limit) #use constant ALLOW_ADMIN_EDIT => 0; # Allow editing of include files and spam.txt from admin.pl. # Warning! This is a security risk, since include templates can run code! # Only enable if you completely trust your moderators! # Image posts #use constant ALLOW_IMAGE_THREADS => 1; # Allow users to create image threads #use constant ALLOW_IMAGE_REPLIES => 1; # Allow users to make image replies #use constant IMAGE_REPLIES_PER_THREAD => 0; # Number of image replies per thread to show, set to 0 for no limit. use constant MAX_KB => 9999; # Maximum upload size in KB #use constant MAX_W => 200; # Images exceeding this width will be thumbnailed #use constant MAX_H => 200; # Images exceeding this height will be thumbnailed #use constant THUMBNAIL_SMALL => 1; # Thumbnail small images (1: yes, 0: no) #use constant THUMBNAIL_QUALITY => 70; # Thumbnail JPEG quality #use constant ALLOW_UNKNOWN => 0; # Allow unknown filetypes (1: yes, 0: no) #use constant MUNGE_UNKNOWN => '.unknown'; # Munge unknown file type extensions with this. If you remove this, make sure your web server is locked down properly. #use constant FORBIDDEN_EXTENSIONS => ('php','php3','php4','phtml','shtml','cgi','pl','pm','py','r','exe','dll','scr','pif','asp','cfm','jsp','vbs'); # file extensions which are forbidden #use constant STUPID_THUMBNAILING => 0; # Bypass thumbnailing code and just use HTML to resize the image. STUPID, wastes bandwidth. (1: enable, 0: disable) #use constant MAX_IMAGE_WIDTH => 16384; # Maximum width of image before rejecting #use constant MAX_IMAGE_HEIGHT => 16384; # Maximum height of image before rejecting #use constant MAX_IMAGE_PIXELS => 50000000; # Maximum width*height of image before rejecting #use constant CONVERT_COMMAND => 'w:\\usr\\local\\im\\convert.exe'; # location of the ImageMagick convert command (usually just 'convert', but sometime a full path is needed) # Captcha #use constant ENABLE_CAPTCHA => 0; # Enable verification codes (0: disabled, 1: enabled) #use constant CAPTCHA_HEIGHT => 18; # Approximate height of captcha image #use constant CAPTCHA_SCRIBBLE => 0.2; # Scribbling factor #use constant CAPTCHA_SCALING => 0.15; # Randomized scaling factor #use constant CAPTCHA_ROTATION => 0.3; # Randomized rotation factor #use constant CAPTCHA_SPACING => 2.5; # Letter spacing # Tweaks #use constant CHARSET => 'utf-8'; # Character set to use, typically "utf-8" or "shift_jis". Remember to set Apache to use the same character set for .html files! (AddCharset shift_jis html) #use constant PROXY_CHECK => (); # Ports to scan for proxies - NOT IMPLEMENTED. #use constant TRIM_METHOD => 0; # Which threads to trim (0: oldest - like futaba 1: least active - furthest back) #use constant REQUIRE_THREAD_TITLE => 0; # Require a title for threads (0: no, 1: yes) use constant DATE_STYLE => 'ymdhms'; # Date style ('2ch', 'futaba', 'localtime, 'http') #use constant DISPLAY_ID => ''; # How to display user IDs # 0 or '': don't display, # 'day', 'thread', 'board' in any combination: make IDs change for each day, thread or board, # 'mask': display masked IP address (similar IPs look similar, but are still encrypted) # 'sage': don't display ID when user sages, 'link': don't display ID when the user fills out the link field, # 'ip': display user's IP, 'host': display user's host #use constant EMAIL_ID => 'Heaven'; # Replace the ID with this string when the user uses an email. Set to '' to disable. #use constant SILLY_ANONYMOUS => ''; # Make up silly names for anonymous people (same syntax as DISPLAY_ID) #use constant FORCED_ANON => 0; # Force anonymous posting (0: no, 1: yes) #use constant TRIPKEY => '!'; # This character is displayed before tripcodes #use constant ALTERNATE_REDIRECT => 0; # Use alternate redirect method. (Javascript/meta-refresh instead of HTTP forwards.) #use constant APPROX_LINE_LENGTH => 150; # Approximate line length used by reply abbreviation code to guess at the length of a reply. use constant COOKIE_PATH => 'current'; # Path argument for cookies ('root': cookies apply to all boards on the site, 'current': cookies apply only to this board, 'parent': cookies apply to all boards in the parent directory) - does NOT apply to the style cookie! #use constant STYLE_COOKIE => 'wakabastyle'; # Cookie name for the style selector. #use constant ENABLE_DELETION => 1; # Enable user deletion of posts. (0: no, 1: yes) #use constant PAGE_GENERATION => 'paged'; # Page generation method ('single': just one page, 'paged': split into several pages like futaba, 'monthly': separate pages for each month) #use constant DELETE_FIRST => 'remove'; # What to do when the first post is deleted ('keep': keep the thread, 'single': delete the thread if there is only one post, 'remove': delete the whole thread) #use constant DEFAULT_MARKUP => 'waka'; # Default markup format ('none', 'waka', 'html', 'aa') #use constant FUDGE_BLOCKQUOTES => 1; # Modify formatting for old stylesheets #use constant USE_XHTML => 1; # Send pages as application/xhtml+xml to browsers that support this (0:no, 1:yes) #use constant KEEP_MAINPAGE_NEWLINES => 0; # Don't strip whitespace from main page (needed for Google ads to work, 0:no, 1:yes) #use constant SPAM_TRAP => 1; # Enable the spam trap (empty, hidden form fields that spam bots usually fill out) (0:no, 1:yes) # Internal paths and files - might as well leave this alone. #use constant RES_DIR => 'res/'; # Reply cache directory (needs to be writeable by the script) #use constant CSS_DIR => 'css/'; # CSS file directory #use constant IMG_DIR => 'src/'; # Image directory (needs to be writeable by the script) #use constant THUMB_DIR => 'thumb/'; # Thumbnail directory (needs to be writeable by the script) #use constant INCLUDE_DIR => 'include/'; # Include file directory #use constant LOG_FILE => 'log.txt'; # Log file (stores delete passwords and IP addresses in encrypted form) #use constant PAGE_EXT => '.html'; # Extension used for board pages after first #use constant HTML_SELF => 'index.html'; # Name of main html file #use constant HTML_BACKLOG => ''; # Name of backlog html file #use constant RSS_FILE => ''; # RSS file. Set to '' to disable RSS support. #use constant JS_FILE => 'kareha.js'; # Location of the js file #use constant CSS_FILE => 'kareha.css'; # Location of the css file use constant FAVICON => 'icon.png'; # Path to the favicon for the board #use constant SPAM_FILES => ('spam.txt'); # Spam definition files, as a Perl list. # Hints: # * Set all boards to use the same file for easy updating. # * Set up two files, one being the official list from # http://wakaba.c3.cx/antispam/spam.txt, and one your own additions. # Admin script options #use constant ADMIN_SHOWN_LINES => 5; # Number of post lines the admin script shows. #use constant ADMIN_SHOWN_POSTS => 10; # Number of posts per thread the admin script shows. #use constant ADMIN_MASK_IPS => 0; # Mask poster IP addresses in the admin script (0: no, 1: yes) #use constant ADMIN_EDITABLE_FILES => (SPAM_FILES); # A Perl list of all files that can be edited from the admin script. # Hints: # * If you don't trust your moderators, don't let them edit templates! Templates can execute code on your server! # * If you still want to allow editing of templates, use (SPAM_FILES,glob("include/*")) as a convenient shorthand. #use constant ADMIN_BAN_FILE => '.htaccess'; # Name of the file to write bans to #use constant ADMIN_BAN_TEMPLATE => "\n# Banned at <var scalar localtime> (<var \$reason>)\nDeny from <var \$ip>\n"; # Format of the ban entries, using the template syntax. # Icons for filetypes - file extensions specified here will get icons and keep original filenames # (except for the built-in image formats). use constant FILETYPES => ( # # Audio files # mp3 => 'icons/audio-mp3.png', # ogg => 'icons/audio-ogg.png', # aac => 'icons/audio-aac.png', # m4a => 'icons/audio-aac.png', # mpc => 'icons/audio-mpc.png', # mpp => 'icons/audio-mpp.png', # mod => 'icons/audio-mod.png', # it => 'icons/audio-it.png', # xm => 'icons/audio-xm.png', # fla => 'icons/audio-flac.png', # flac => 'icons/audio-flac.png', # sid => 'icons/audio-sid.png', # mo3 => 'icons/audio-mo3.png', # spc => 'icons/audio-spc.png', # nsf => 'icons/audio-nsf.png', # # Archive files zip => 'icons/archive-zip.png', rar => 'icons/archive-rar.png', # lzh => 'icons/archive-lzh.png', # lha => 'icons/archive-lzh.png', gz => 'icons/archive-gz.png', bz2 => 'icons/archive-bz2.png', '7z' => 'icons/archive-7z.png', # # Other files # swf => 'icons/flash.png', # torrent => 'icons/torrent.png', # # To stop Wakaba from renaming image files, put their names in here like this: # gif => '.', # jpg => '.', # png => '.', ); # Allowed HTML tags and attributes. Sort of undocumented for now, but feel free to # learn by example. #use constant ALLOWED_HTML => ( # 'a'=>{args=>{'href'=>'url'},forced=>{'rel'=>'nofollow'}}, # 'b'=>{},'i'=>{},'u'=>{},'sub'=>{},'sup'=>{}, # 'em'=>{},'strong'=>{}, # 'ul'=>{},'ol'=>{},'li'=>{},'dl'=>{},'dt'=>{},'dd'=>{}, # 'p'=>{},'br'=>{empty=>1},'blockquote'=>{}, #); 1;
65.167568
263
0.706951
73ece4e87981c48cf553d81cf50546b3be6e9f30
1,800
t
Perl
t/markup/standard/preformatted.t
racke/Markdent
5b6e6c4f88b8a46674f1728d2c46c29c16bf138b
[ "Artistic-1.0" ]
null
null
null
t/markup/standard/preformatted.t
racke/Markdent
5b6e6c4f88b8a46674f1728d2c46c29c16bf138b
[ "Artistic-1.0" ]
null
null
null
t/markup/standard/preformatted.t
racke/Markdent
5b6e6c4f88b8a46674f1728d2c46c29c16bf138b
[ "Artistic-1.0" ]
null
null
null
use strict; use warnings; use Test2::V0; use lib 't/lib'; use Test::Markdent; { my $text = <<'EOF'; preformatted line EOF my $expect = [ { type => 'preformatted', text => "preformatted line\n", } ]; parse_ok( $text, $expect, 'one-line preformatted' ); } { my $tab = "\t"; my $text = <<"EOF"; ${tab}preformatted line EOF my $expect = [ { type => 'preformatted', text => "preformatted line\n", } ]; parse_ok( $text, $expect, 'one-line preformatted with leading tab' ); } { my $text = <<'EOF'; pre 1 pre 2 EOF ( my $expect_text = $text ) =~ s/^[ ]{4}//gm; my $expect = [ { type => 'preformatted', text => $expect_text, }, ]; parse_ok( $text, $expect, 'two pre lines, second has 2-space indentation' ); } { my $text = <<'EOF'; pre 1 pre 2 EOF ( my $expect_text = $text ) =~ s/^[ ]{4}//gm; my $expect = [ { type => 'preformatted', text => $expect_text, }, ]; parse_ok( $text, $expect, 'preformatted text includes empty lines' ); } { my $pre = <<'EOF'; pre 1 pre 2 EOF my $text = <<"EOF"; $pre regular text EOF ( my $expect_text = $pre ) =~ s/^[ ]{4}//gm; my $expect = [ { type => 'preformatted', text => $expect_text, }, { type => 'paragraph', }, [ { type => 'text', text => "regular text\n", }, ], ]; parse_ok( $text, $expect, 'preformatted text with empty lines followed by regular paragraph' ); } done_testing();
15.12605
74
0.44
ed607176bead661b03721c281f29753886e9e245
957
pm
Perl
auto-lib/Paws/ServiceCatalog/SearchProductsOutput.pm
agimenez/aws-sdk-perl
9c4dff7d1af2ff0210c28ca44fb9e92bc625712b
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/ServiceCatalog/SearchProductsOutput.pm
agimenez/aws-sdk-perl
9c4dff7d1af2ff0210c28ca44fb9e92bc625712b
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/ServiceCatalog/SearchProductsOutput.pm
agimenez/aws-sdk-perl
9c4dff7d1af2ff0210c28ca44fb9e92bc625712b
[ "Apache-2.0" ]
null
null
null
package Paws::ServiceCatalog::SearchProductsOutput; use Moose; has NextPageToken => (is => 'ro', isa => 'Str'); has ProductViewAggregations => (is => 'ro', isa => 'Paws::ServiceCatalog::ProductViewAggregations'); has ProductViewSummaries => (is => 'ro', isa => 'ArrayRef[Paws::ServiceCatalog::ProductViewSummary]'); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::ServiceCatalog::SearchProductsOutput =head1 ATTRIBUTES =head2 NextPageToken => Str The page token to use to retrieve the next page of results for this operation. If there are no more pages, this value is null. =head2 ProductViewAggregations => L<Paws::ServiceCatalog::ProductViewAggregations> A list of the product view aggregation value objects. =head2 ProductViewSummaries => ArrayRef[L<Paws::ServiceCatalog::ProductViewSummary>] A list of the product view summary objects. =head2 _request_id => Str =cut 1;
23.925
104
0.731452
73f59b547e015199052961a8140f4e93b749c9f5
1,968
pm
Perl
archive/frontend/twiki/lib/TWiki/Configure/Checkers/UpperNational.pm
rec/wik
2be7f75339feab318bac858ca1c882ffe97df7cd
[ "MIT" ]
1
2020-02-01T19:20:24.000Z
2020-02-01T19:20:24.000Z
archive/frontend/twiki/lib/TWiki/Configure/Checkers/UpperNational.pm
rec/wik
2be7f75339feab318bac858ca1c882ffe97df7cd
[ "MIT" ]
3
2019-12-19T12:37:05.000Z
2020-01-13T18:28:44.000Z
archive/frontend/twiki/lib/TWiki/Configure/Checkers/UpperNational.pm
rec/wik
2be7f75339feab318bac858ca1c882ffe97df7cd
[ "MIT" ]
null
null
null
# Module of TWiki Enterprise Collaboration Platform, http://TWiki.org/ # # Copyright (C) 2000-2018 Peter Thoeny, peter[at]thoeny.org # and TWiki Contributors. All Rights Reserved. TWiki Contributors # are listed in the AUTHORS file in the root of this distribution. # NOTE: Please extend that file, not this notice. # # Additional copyrights apply to some or all of the code in this # file as follows: # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. For # more details read LICENSE in the root of this distribution. # # This program 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. # # As per the GPL, removal of this notice is prohibited. package TWiki::Configure::Checkers::UpperNational; use strict; use TWiki::Configure::Checker; use base 'TWiki::Configure::Checker'; sub check { my $this = shift; # support upgrade from old configuration, where LowerNational and # UpperNational were stored as REGEX'es (now they are STRING's): if ($TWiki::cfg{UpperNational} =~ /^\(\?-xism:(.*)\)$/) { $TWiki::cfg{UpperNational} = $1; } if( $] < 5.006 || !$TWiki::cfg{UseLocale} ) { # Locales are off/broken, or using pre-5.6 Perl, so have to # explicitly list the accented characters (but not if using UTF-8) my $forUpperNat = join '', grep { uc($_) ne $_ and m/[^a-z]/ } map { chr($_) } 1..255; if ($forUpperNat) { return $this->WARN( <<HERE The following upper case accented characters have been found in this locale and should be considered for use in this parameter: <strong>$forUpperNat</strong> HERE ); } } return ''; } 1;
33.931034
94
0.685976
ed47e54c98c35d929c507d0cb9804b2fbdc27988
150
pl
Perl
quote.pl
wizzat/shell
059c97fd73bb2327526e6c659a7a4a55f73f16e0
[ "MIT" ]
null
null
null
quote.pl
wizzat/shell
059c97fd73bb2327526e6c659a7a4a55f73f16e0
[ "MIT" ]
null
null
null
quote.pl
wizzat/shell
059c97fd73bb2327526e6c659a7a4a55f73f16e0
[ "MIT" ]
null
null
null
#!/usr/bin/perl -w use strict; while (<STDIN>) { $_ =~ s/^(\s*)(.*)(\s*)$/$1'$2'/; $_ =~ s/,'$/',/; $_ =~ s/'$/',/; print("$_\n"); }
15
37
0.313333
ed6ce49ee71ad2486e7f1757c7e7a8c3105eb8d8
3,940
pm
Perl
Model/lib/perl/CannedQuery/NodeMetadataSampleInfo.pm
EuPathDB-Infra/ClinEpiWebsite
73388e992230d40644ca4abb478e1f280e239525
[ "Apache-2.0" ]
1
2019-09-19T14:36:08.000Z
2019-09-19T14:36:08.000Z
Model/lib/perl/CannedQuery/NodeMetadataSampleInfo.pm
EuPathDB/ClinEpiWebsite
73388e992230d40644ca4abb478e1f280e239525
[ "Apache-2.0" ]
9
2020-12-06T03:11:18.000Z
2022-03-29T16:36:33.000Z
Model/lib/perl/CannedQuery/NodeMetadataSampleInfo.pm
EuPathDB/ClinEpiWebsite
73388e992230d40644ca4abb478e1f280e239525
[ "Apache-2.0" ]
null
null
null
package ClinEpiWebsite::Model::CannedQuery::NodeMetadataSampleInfo; @ISA = qw( EbrcWebsiteCommon::Model::CannedQuery ); =pod =head1 Purpose This canned query selects various characteristics from the sample table for a given participant. =head1 Macros The following macros must be available to execute this query. =over =item Id - source id for the participant =back =cut # ======================================================================== # ----------------------------- Declarations ----------------------------- # ======================================================================== use strict; use FileHandle; use EbrcWebsiteCommon::Model::CannedQuery; use Data::Dumper; # ======================================================================== # ----------------------- Create, Init, and Access ----------------------- # ======================================================================== # --------------------------------- init --------------------------------- sub init { my $Self = shift; my $Args = ref $_[0] ? shift : {@_}; $Self->SUPER::init($Args); $Self->setName ( $Args->{Name }); $Self->setId ( $Args->{Id }); $Self->setContXAxis ( $Args->{ContXAxis }); $Self->setSampleInfo ( $Args->{SampleInfo }); $Self->setTblPrefix ( $Args->{TblPrefix }); my $contXAxis = $Self->getContXAxis(); my $sampleInfo = $Self->getSampleInfo(); my $tblPrefix = $Self->getTblPrefix(); my $prtcpntTable = $tblPrefix . "Participants"; my $ioTable = $tblPrefix . "PANIO"; my $sampleTable = $tblPrefix . "Samples"; my $ontologyTable = $tblPrefix . "Ontology"; my $obsTable = $tblPrefix . "Observations"; $Self->setSql(<<Sql); select m.ONTOLOGY_TERM_NAME as LEGEND , m.ONTOLOGY_TERM_NAME as ID , sa.$sampleInfo as STATUS , ea.$contXAxis as NAME from apidbtuning.$sampleTable sa , apidbtuning.$prtcpntTable pa , apidbtuning.$obsTable ea , apidbtuning.$ioTable io , apidbtuning.$ioTable pio , apidbtuning.$ontologyTable m where pa.NAME = \'<<Id>>\' and pa.PAN_ID = io.INPUT_PAN_ID and io.OUTPUT_PAN_ID = ea.PAN_ID and ea.PAN_ID = pio.INPUT_PAN_ID and pio.OUTPUT_PAN_ID = sa.PAN_ID and sa.$sampleInfo is not null and m.ONTOLOGY_TERM_SOURCE_ID = \'$sampleInfo\' order by ea.$contXAxis Sql return $Self; } # -------------------------------- access -------------------------------- sub getId { $_[0]->{'Id' } } sub setId { $_[0]->{'Id' } = $_[1]; $_[0] } sub getName { $_[0]->{'Name' } } sub setName { $_[0]->{'Name' } = $_[1]; $_[0] } sub getSampleInfo { $_[0]->{'SampleInfo' } } sub setSampleInfo { $_[0]->{'SampleInfo' } = $_[1]; $_[0] } sub getContXAxis { $_[0]->{'ContXAxis' } } sub setContXAxis { $_[0]->{'ContXAxis' } = $_[1]; $_[0] } sub getTblPrefix { $_[0]->{'TblPrefix' } } sub setTblPrefix { $_[0]->{'TblPrefix' } = $_[1]; $_[0] } # ======================================================================== # --------------------------- Support Methods ---------------------------- # ======================================================================== sub prepareDictionary { my $Self = shift; my $Dict = shift || {}; $Dict->{Id} = $Self->getId(); my $Rv = $Dict; return $Rv; } # ======================================================================== # ---------------------------- End of Package ---------------------------- # ======================================================================== 1;
30.78125
96
0.408376
ed3a99b3d1b3eeb6d5b1e6156f72a9782fadfe68
13,007
pm
Perl
lib/WebService/Mattermost/V4/API/Resource/Team.pm
OkayDave/WebService-Mattermost
6982449840d8ae3a75e68f740195f64a46ee6cbc
[ "MIT" ]
null
null
null
lib/WebService/Mattermost/V4/API/Resource/Team.pm
OkayDave/WebService-Mattermost
6982449840d8ae3a75e68f740195f64a46ee6cbc
[ "MIT" ]
null
null
null
lib/WebService/Mattermost/V4/API/Resource/Team.pm
OkayDave/WebService-Mattermost
6982449840d8ae3a75e68f740195f64a46ee6cbc
[ "MIT" ]
null
null
null
package WebService::Mattermost::V4::API::Resource::Team; # ABSTRACT: Wrapped API methods for the team API endpoints. use Moo; use Types::Standard 'InstanceOf'; use WebService::Mattermost::V4::API::Resource::Team::Channels; use WebService::Mattermost::Helper::Alias 'v4'; extends 'WebService::Mattermost::V4::API::Resource'; with qw( WebService::Mattermost::V4::API::Resource::Role::Single WebService::Mattermost::V4::API::Resource::Role::View::Team ); ################################################################################ has channels => (is => 'ro', isa => InstanceOf[v4 'Team::Channels'], lazy => 1, builder => 1); ################################################################################ around [ qw( delete get patch update add_member add_members members members_by_ids invite_by_emails stats get_icon set_icon remove_icon set_scheme search_posts ) ] => sub { my $orig = shift; my $self = shift; my $id = shift || $self->id; return $self->validate_id($orig, $id, @_); }; around [ qw(get_by_name exists_by_name) ] => sub { my $orig = shift; my $self = shift; my $name = shift; unless ($name) { return $self->error_return('The first parameter must be a name.'); } return $self->$orig($name, @_); }; around [ qw(get_member remove_member) ] => sub { my $orig = shift; my $self = shift; my $team_id = shift; my $user_id = shift; unless ($team_id && $user_id) { return $self->error_return('The first parameter should be a team ID and the second a user ID.'); } return $self->$orig($team_id, $user_id, @_); }; sub get { my $self = shift; my $id = shift; return $self->_single_view_get({ endpoint => '%s', ids => [ $id ], }); } sub get_by_name { my $self = shift; my $name = shift; return $self->_single_view_get({ endpoint => 'name/%s', ids => [ $name ], }); } sub update { my $self = shift; my $id = shift; my $args = shift; return $self->_single_view_put({ endpoint => '%s', ids => [ $id ], parameters => $args, required => [ qw( display_name description company_name allowed_domains invite_id allow_open_invite ) ], }); } sub delete { my $self = shift; my $id = shift; return $self->_delete({ endpoint => '%s', ids => [ $id ], view => 'Status', }); } sub patch { my $self = shift; my $id = shift; my $args = shift; return $self->_single_view_put({ endpoint => '%s/patch', parameters => $args, ids => [ $id ], }); } sub exists_by_name { my $self = shift; my $name = shift; return $self->_get({ endpoint => 'name/%s/exists', ids => [ $name ], }); } sub members { my $self = shift; my $id = shift; return $self->_get({ endpoint => '%s/members', ids => [ $id ], view => 'TeamMember', }); } sub members_by_ids { my $self = shift; my $team_id = shift; my $user_ids = shift; return $self->_get({ endpoint => '%s/members/ids', ids => [ $team_id ], parameters => $user_ids, view => 'TeamMember', }); } sub add_member { my $self = shift; my $team_id = shift; my $user_id = shift; return $self->_single_view_post({ endpoint => '%s/members', ids => [ $team_id ], view => 'TeamMember', parameters => { team_id => $team_id, user_id => $user_id, }, }); } sub add_members { my $self = shift; my $team_id = shift; my $users = shift; return $self->_post({ endpoint => '%s/members/batch', ids => [ $team_id ], view => 'TeamMember', parameters => [ map { { user_id => $_->{id}, team_id => $team_id, roles => $_->{roles}, } } grep { defined($_->{id}) && defined($_->{roles}) } @{$users} ], }); } sub get_member { my $self = shift; my $team_id = shift; my $user_id = shift; unless ($user_id) { return $self->error_return('The second parameter should be a user ID'); } return $self->_single_view_get({ endpoint => '%s/members/%s', ids => [ $team_id, $user_id ], view => 'TeamMember', }); } sub remove_member { my $self = shift; my $team_id = shift; my $user_id = shift; return $self->_single_view_delete({ endpoint => '%s/members/%s', ids => [ $team_id, $user_id ], view => 'Status', }); } sub stats { my $self = shift; my $id = shift; return $self->_single_view_get({ endpoint => '%s/stats', ids => [ $id ], view => 'TeamStats', }); } sub get_icon { my $self = shift; my $id = shift; return $self->_single_view_get({ endpoint => '%s/image', ids => [ $id ], view => 'Icon', }); } sub set_icon { my $self = shift; my $id = shift; my $filename = shift; return $self->_single_view_post({ endpoint => '%s/image', ids => [ $id ], override_data_type => 'form', parameters => { image => { file => $filename }, }, }); } sub remove_icon { my $self = shift; my $id = shift; return $self->_single_view_delete({ endpoint => '%s/image', ids => [ $id ], view => 'Status', }); } sub invite_by_emails { my $self = shift; my $id = shift; my $emails = shift; return $self->_single_view_post({ endpoint => '%s/invite/email', ids => [ $id ], parameters => $emails, view => 'Status', }); } sub import_from_existing { my $self = shift; my $id = shift; my $args = shift; my $filename = $args->{filename}; unless ($args->{file}) { return $self->error_return('A filename argument is required'); } $args->{file} = { file => { file => $args->{filename} } }; return $self->_single_view_post({ endpoint => '%s/import', ids => [ $id ], override_data_type => 'form', parameters => $args, required => [ qw(file filesize importFrom) ], view => 'Results', }); } sub set_scheme { my $self = shift; my $id = shift; my $scheme = shift; return $self->_single_view_put({ endpoint => '%s/scheme', ids => [ $id ], parameters => { scheme_id => $scheme }, required => [ 'scheme_id' ], view => 'Status', }); } sub search_posts { my $self = shift; my $id = shift; my $args = shift; $args->{is_or_search} ||= \0; return $self->_single_view_post({ endpoint => '%s/posts/search', ids => [ $id ], parameters => $args, required => [ qw(terms is_or_search) ], view => 'Thread', }); } ################################################################################ sub _build_channels { my $self = shift; return $self->_new_related_resource('teams', 'Team::Channels'); } ################################################################################ 1; __END__ =head1 DESCRIPTION API methods relating to a single team by ID or name. =head2 USAGE use WebService::Mattermost; my $mm = WebService::Mattermost->new({ authenticate => 1, username => 'me@somewhere.com', password => 'hunter2', base_url => 'https://my.mattermost.server.com/api/v4/', }); my $resource = $mm->api->team; =head2 METHODS =over 4 =item C<get()> L<Get a team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D%2Fget> my $response = $resource->get('TEAM-ID-HERE'); =item C<get_by_name()> L<Get a team by name|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1name~1%7Bname%7D%2Fget> my $response = $resource->get_by_name('TEAM-NAME-HERE'); =item C<update()> L<Update a team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D%2Fput> my $response = $resource->update('TEAM-ID-HERE', { # Required parameters: display_name => '...', description => '...', company_name => '...', allowed_domains => '...', invite_id => '...', }); =item C<delete()> L<Delete a team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D%2Fdelete> my $response = $resource->delete('TEAM-ID-HERE'); =item C<patch()> L<Patch a team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1patch%2Fput> my $response = $resource->patch('TEAM-ID-HERE', { # Optional parameters: display_name => '...', description => '...', company_name => '...', allowed_domains => '...', invite_id => '...', }); =item C<exists_by_name()> L<Check if team exists|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1name~1%7Bname%7D~1exists%2Fget> my $response = $resource->exists_by_name('TEAM-NAME-HERE'); =item C<members()> L<Get team members|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1members%2Fget> my $response = $resource->members('TEAM-ID-HERE'); =item C<members_by_ids()> L<Get team members by IDs|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1members~1ids%2Fpost> my $response = $resource->members_by_ids('TEAM-ID-HERE', [ qw( USER-ID-HERE USER-ID-HERE USER-ID-HERE ) ]); =item C<add_member()> L<Add user to team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1members%2Fpost> my $response = $resource->add_member('TEAM-ID-HERE', 'USER-ID-HERE'); =item C<add_members()> L<Add multiple users to team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1members~1batch%2Fpost> my $response = $resource->add_members('TEAM-ID-HERE', [ { user_id => 'USER-ID-HERE', roles => 'ROLES-HERE' }, { user_id => 'USER-ID-HERE', roles => 'ROLES-HERE' }, { user_id => 'USER-ID-HERE', roles => 'ROLES-HERE' }, ]); =item C<remove_member()> L<Remove user from team|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1members~1%7Buser_id%7D%2Fdelete> my $response = $resource->remove_member('TEAM-ID-HERE', 'USER-ID-HERE'); =item C<stats()> L<Get a team stats|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1stats%2Fget> my $response = $resource->stats('TEAM-ID-HERE'); =item C<get_icon()> L<Get the team icon|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1image%2Fget> my $response = $resource->get_icon('TEAM-ID-HERE'); =item C<set_icon()> L<Sets the team icon|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1image%2Fpost> my $response = $resource->set_icon('TEAM-ID-HERE', '/path/to/icon/here.png'); =item C<remove_icon()> L<Remove the team icon|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1image%2Fdelete> my $response = $resource->remove_icon('TEAM-ID-HERE'); =item C<invite_by_emails()> L<Invite users to the team by email|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1invite~1email%2Fpost> my $response = $resource->invite_by_emails('TEAM-ID-HERE', [ EMAIL-HERE EMAIL-HERE EMAIL-HERE ]); =item C<import_from_existing()> L<Import a Team from other application|https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1%7Bteam_id%7D~1import%2Fpost> my $response = $resource->import_from_existing('TEAM-ID-HERE', { filename => 'IMPORT-FILENAME', filesize => 'filesize', importFrom => '...', }); =item C<search_posts()> L<Search for team posts|https://api.mattermost.com/#tag/posts%2Fpaths%2F~1teams~1%7Bteam_id%7D~1posts~1search%2Fpost> my $response = $resource->search_posts('TEAM-ID-HERE', { # Required parameters: terms => '...', # Optional parameters is_or_search => \1, # or \0 for false time_zone_offset => 0, include_deleted_channels => \1, # or \0 for false page => 0, per_page => 60, }); =back
24.17658
129
0.532252
ed6bb70183277220ff996e04d360f6034dafedfb
8,096
pm
Perl
modules/Bio/EnsEMBL/Compara/RunnableDB/MercatorPecan/DumpMercatorFiles.pm
nds/ensembl-compara
32b7cf0f0f00e51c3b2eb24961a2a2286a8bf685
[ "Apache-2.0" ]
40
2015-06-25T19:17:03.000Z
2022-03-22T17:57:35.000Z
modules/Bio/EnsEMBL/Compara/RunnableDB/MercatorPecan/DumpMercatorFiles.pm
nds/ensembl-compara
32b7cf0f0f00e51c3b2eb24961a2a2286a8bf685
[ "Apache-2.0" ]
343
2015-01-14T10:45:48.000Z
2022-03-31T11:04:58.000Z
modules/Bio/EnsEMBL/Compara/RunnableDB/MercatorPecan/DumpMercatorFiles.pm
nds/ensembl-compara
32b7cf0f0f00e51c3b2eb24961a2a2286a8bf685
[ "Apache-2.0" ]
102
2015-01-14T10:40:39.000Z
2022-02-20T23:57:34.000Z
=head1 LICENSE See the NOTICE file distributed with this work for additional information regarding copyright ownership. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =head1 NAME Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::DumpMercatorFiles =head1 DESCRIPTION Create Chromosome, Anchor and Hit files needed by Mercator. Supported keys: 'genome_db_id' => <number> The id of the query genome 'genome_db_ids' => < list_of_genome_db_ids > eg genome_db_ids => [61,108,111,112,38,60,101,43,31] List of genome ids to match against 'all_hits' => <0|1> Whether to perform all best hits (1) or best reciprocal hits only (0) 'input_dir' => < directory_path > Location to write files required by Mercator 'maximum_gap' => <number> eg 50000 'cutoff_score' => <number> Filter by score. Not normally used 'cutoff_evalue' => <number> Filter by evalue. Not normally used =cut package Bio::EnsEMBL::Compara::RunnableDB::MercatorPecan::DumpMercatorFiles; use strict; use warnings; use Time::HiRes qw(time gettimeofday tv_interval); use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable'); sub param_defaults { my $self = shift; return { %{ $self->SUPER::param_defaults }, 'cutoff_score' => undef, 'cutoff_evalue' => undef, } } sub run { my $self = shift; $self->dumpMercatorFiles; } sub dumpMercatorFiles { my $self = shift; my $starttime = time(); unless (defined $self->param('input_dir')) { my $input_dir = $self->worker_temp_directory . "/input_dir"; $self->param('input_dir', $input_dir); } if (! -e $self->param('input_dir')) { mkdir($self->param('input_dir')); } my $dfa = $self->compara_dba->get_DnaFragAdaptor; my $gdba = $self->compara_dba->get_GenomeDBAdaptor; my $ma = $self->compara_dba->get_SeqMemberAdaptor; my $max_gap = $self->param('maximum_gap'); my $gdb_id = $self->param_required('genome_db_id'); my $dnafrags; ## Create the Chromosome file for Mercator my $gdb = $gdba->fetch_by_dbID($gdb_id); my $file = $self->param('input_dir') . "/$gdb_id.chroms"; open(my $fh, '>', $file); my $core_dba = $gdb->db_adaptor; $core_dba->dbc->prevent_disconnect( sub { my $coord_system_adaptor = $core_dba->get_CoordSystemAdaptor(); my $assembly_mapper_adaptor = $core_dba->get_AssemblyMapperAdaptor(); my $seq_level_coord_system = $coord_system_adaptor->fetch_sequence_level; my $coord_systems = $coord_system_adaptor->fetch_all_by_attrib('default_version');; my %coord_systems_by_name = map {$_->name => $_} @$coord_systems; my %assembly_mappers = map {$_->name => $assembly_mapper_adaptor->fetch_by_CoordSystems($_, $seq_level_coord_system)} grep {$_->name ne $seq_level_coord_system->name} @$coord_systems; foreach my $df (@{$dfa->fetch_all_by_GenomeDB($gdb)}) { print $fh $df->name . "\t" . $df->length,"\n"; if ($max_gap and $df->length > $max_gap and $assembly_mappers{$df->coord_system_name}) { # Avoid large assembly gaps: when a gap larger than "maximum_gap" is # found, break the region as if they were several chromosomes in order # to ensure Mercator won't link cliques on both sides of the gap. my @mappings = $assembly_mappers{$df->coord_system_name}->map($df->name, 1, $df->length, 1, $coord_systems_by_name{$df->coord_system_name}); my $part = 1; foreach my $this_mapping (@mappings) { next if ($this_mapping->isa("Bio::EnsEMBL::Mapper::Coordinate")); next if ($this_mapping->length < $max_gap); # print join(" :: ", $df->name, $this_mapping->length, $this_mapping->start, $this_mapping->end), "\n"; # This method currently assumes that no original chromosome name # end with --X where X is any number. print $fh $df->name . "--$part\t" . $df->length,"\n"; $dnafrags->{$df->dbID}->{$this_mapping->start} = $df->name."--".$part; $part++; } } } } ); close $fh; ## Create the anchor file for Mercator $file = $self->param('input_dir') . "/$gdb_id.anchors"; open($fh, '>', $file); foreach my $member (@{$ma->fetch_all_by_GenomeDB($gdb_id)}) { my $strand = "+"; $strand = "-" if ($member->dnafrag_strand == -1); my $dnafrag_name = $member->dnafrag->name; if (defined($dnafrags->{$member->dnafrag_id})) { foreach my $this_start (sort {$a <=> $b} keys %{$dnafrags->{$member->dnafrag_id}}) { if ($this_start > $member->dnafrag_start - 1) { last; } else { $dnafrag_name = ($dnafrags->{$member->dnafrag_id}->{$this_start} or $member->dnafrag->name); } } } print $fh $member->dbID . "\t" . $dnafrag_name ."\t" . $strand . "\t" . ($member->dnafrag_start - 1) ."\t" . $member->dnafrag_end ."\t1\n"; } close $fh; my $genome_db_ids = $self->param('genome_db_ids'); my $gdb_id1 = $self->param('genome_db_id'); my $cutoff_score = $self->param('cutoff_score'); my $cutoff_evalue = $self->param('cutoff_evalue'); foreach my $gdb_id2 (@$genome_db_ids) { my $file = $self->param('input_dir') . "/$gdb_id1" . "-$gdb_id2.hits"; open($fh, '>', $file); my $sql = $self->get_sql_for_peptide_hits($gdb_id1, $gdb_id2); my $sth = $self->compara_dba->dbc->prepare($sql); my ($qmember_id,$hmember_id,$score1,$evalue1,$score2,$evalue2); $sth->execute($gdb_id1, $gdb_id2); $sth->bind_columns( \$qmember_id,\$hmember_id,\$score1,\$evalue1,\$score2,\$evalue2); my %pair_seen = (); while ($sth->fetch()) { next if ($pair_seen{$qmember_id . "_" . $hmember_id}); my $score = ($score1>$score2)?$score2:$score1; ## Use smallest score my $evalue = ($evalue1>$evalue2)?$evalue1:$evalue2; ## Use largest e-value next if (defined $cutoff_score && $score < $cutoff_score); next if (defined $cutoff_evalue && $evalue > $cutoff_evalue); print $fh "$qmember_id\t$hmember_id\t" . int($score). "\t$evalue\n"; $pair_seen{$qmember_id . "_" . $hmember_id} = 1; } close $fh; $sth->finish(); } if($self->debug){printf("%1.3f secs to dump mercator files for \"%s\"\n", (time()-$starttime), $gdb->name);} return 1; } sub get_sql_for_peptide_hits { my ($self, $gdb_id1, $gdb_id2) = @_; my $sql; my $table_name1 = "peptide_align_feature_$gdb_id1"; my $table_name2 = "peptide_align_feature_$gdb_id2"; if ($self->param('all_hits')) { ## Use all best hits $sql = "SELECT paf1.qmember_id, paf1.hmember_id, paf1.score, paf1.evalue, paf2.score, paf2.evalue FROM $table_name1 paf1, $table_name2 paf2 WHERE paf2.hgenome_db_id = ? AND paf1.hgenome_db_id = ? AND paf1.qmember_id = paf2.hmember_id AND paf1.hmember_id = paf2.qmember_id AND (paf1.hit_rank = 1 OR paf2.hit_rank = 1)"; } else { ## Use best reciprocal hits only $sql = "SELECT paf1.qmember_id, paf1.hmember_id, paf1.score, paf1.evalue, paf2.score, paf2.evalue FROM $table_name1 paf1, $table_name2 paf2 WHERE paf2.hgenome_db_id = ? AND paf1.hgenome_db_id = ? AND paf1.qmember_id = paf2.hmember_id AND paf1.hmember_id = paf2.qmember_id AND paf1.hit_rank = 1 AND paf2.hit_rank = 1"; } return $sql; } 1;
34.598291
185
0.648839
ed6d86438137955af4bdaee079891fba5193d656
80,952
pm
Perl
git/usr/share/perl5/core_perl/Math/BigInt/Calc.pm
BrianShin/Drupal---Example
2d49bfeeed97cc19fc59c60d1caca51aa664fb0e
[ "Apache-2.0" ]
9
2018-04-19T05:08:30.000Z
2021-11-23T07:36:58.000Z
git/usr/share/perl5/core_perl/Math/BigInt/Calc.pm
BrianShin/Drupal---Example
2d49bfeeed97cc19fc59c60d1caca51aa664fb0e
[ "Apache-2.0" ]
98
2017-11-02T19:00:44.000Z
2022-03-22T16:15:39.000Z
git/usr/share/perl5/core_perl/Math/BigInt/Calc.pm
BrianShin/Drupal---Example
2d49bfeeed97cc19fc59c60d1caca51aa664fb0e
[ "Apache-2.0" ]
9
2017-10-24T21:53:36.000Z
2021-11-23T07:36:59.000Z
package Math::BigInt::Calc; use 5.006001; use strict; use warnings; our $VERSION = '1.999715'; $VERSION = eval $VERSION; # Package to store unsigned big integers in decimal and do math with them # Internally the numbers are stored in an array with at least 1 element, no # leading zero parts (except the first) and in base 1eX where X is determined # automatically at loading time to be the maximum possible value # todo: # - fully remove funky $# stuff in div() (maybe - that code scares me...) # USE_MUL: due to problems on certain os (os390, posix-bc) "* 1e-5" is used # instead of "/ 1e5" at some places, (marked with USE_MUL). Other platforms # BS2000, some Crays need USE_DIV instead. # The BEGIN block is used to determine which of the two variants gives the # correct result. # Beware of things like: # $i = $i * $y + $car; $car = int($i / $BASE); $i = $i % $BASE; # This works on x86, but fails on ARM (SA1100, iPAQ) due to who knows what # reasons. So, use this instead (slower, but correct): # $i = $i * $y + $car; $car = int($i / $BASE); $i -= $BASE * $car; ############################################################################## # global constants, flags and accessory # announce that we are compatible with MBI v1.83 and up sub api_version () { 2; } # constants for easier life my ($BASE,$BASE_LEN,$RBASE,$MAX_VAL); my ($AND_BITS,$XOR_BITS,$OR_BITS); my ($AND_MASK,$XOR_MASK,$OR_MASK); sub _base_len { # Set/get the BASE_LEN and assorted other, connected values. # Used only by the testsuite, the set variant is used only by the BEGIN # block below: shift; my ($b, $int) = @_; if (defined $b) { # avoid redefinitions undef &_mul; undef &_div; if ($] >= 5.008 && $int && $b > 7) { $BASE_LEN = $b; *_mul = \&_mul_use_div_64; *_div = \&_div_use_div_64; $BASE = int("1e".$BASE_LEN); $MAX_VAL = $BASE-1; return $BASE_LEN unless wantarray; return ($BASE_LEN, $BASE, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL,); } # find whether we can use mul or div in mul()/div() $BASE_LEN = $b+1; my $caught = 0; while (--$BASE_LEN > 5) { $BASE = int("1e".$BASE_LEN); $RBASE = abs('1e-'.$BASE_LEN); # see USE_MUL $caught = 0; $caught += 1 if (int($BASE * $RBASE) != 1); # should be 1 $caught += 2 if (int($BASE / $BASE) != 1); # should be 1 last if $caught != 3; } $BASE = int("1e".$BASE_LEN); $RBASE = abs('1e-'.$BASE_LEN); # see USE_MUL $MAX_VAL = $BASE-1; # ($caught & 1) != 0 => cannot use MUL # ($caught & 2) != 0 => cannot use DIV if ($caught == 2) # 2 { # must USE_MUL since we cannot use DIV *_mul = \&_mul_use_mul; *_div = \&_div_use_mul; } else # 0 or 1 { # can USE_DIV instead *_mul = \&_mul_use_div; *_div = \&_div_use_div; } } return $BASE_LEN unless wantarray; return ($BASE_LEN, $BASE, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL); } sub _new { # Given a string representing an integer, returns a reference to an array # of integers, where each integer represents a chunk of the original input # integer. Assumes normalized value as input. my ($proto, $str) = @_; my $input_len = length($str) - 1; # Shortcut for small numbers. return [ int($str) ] if $input_len < $BASE_LEN; my $format = "a" . (($input_len % $BASE_LEN) + 1); $format .= $] < 5.008 ? "a$BASE_LEN" x int($input_len / $BASE_LEN) : "(a$BASE_LEN)*"; [ reverse(map { 0 + $_ } unpack($format, $str)) ]; } BEGIN { # from Daniel Pfeiffer: determine largest group of digits that is precisely # multipliable with itself plus carry # Test now changed to expect the proper pattern, not a result off by 1 or 2 my ($e, $num) = 3; # lowest value we will use is 3+1-1 = 3 do { $num = '9' x ++$e; $num *= $num + 1; } while $num =~ /9{$e}0{$e}/; # must be a certain pattern $e--; # last test failed, so retract one step # the limits below brush the problems with the test above under the rug: # the test should be able to find the proper $e automatically $e = 5 if $^O =~ /^uts/; # UTS get's some special treatment $e = 5 if $^O =~ /^unicos/; # unicos is also problematic (6 seems to work # there, but we play safe) my $int = 0; if ($e > 7) { use integer; my $e1 = 7; $num = 7; do { $num = ('9' x ++$e1) + 0; $num *= $num + 1; } while ("$num" =~ /9{$e1}0{$e1}/); # must be a certain pattern $e1--; # last test failed, so retract one step if ($e1 > 7) { $int = 1; $e = $e1; } } __PACKAGE__->_base_len($e,$int); # set and store use integer; # find out how many bits _and, _or and _xor can take (old default = 16) # I don't think anybody has yet 128 bit scalars, so let's play safe. local $^W = 0; # don't warn about 'nonportable number' $AND_BITS = 15; $XOR_BITS = 15; $OR_BITS = 15; # find max bits, we will not go higher than numberofbits that fit into $BASE # to make _and etc simpler (and faster for smaller, slower for large numbers) my $max = 16; while (2 ** $max < $BASE) { $max++; } { no integer; $max = 16 if $] < 5.006; # older Perls might not take >16 too well } my ($x,$y,$z); do { $AND_BITS++; $x = CORE::oct('0b' . '1' x $AND_BITS); $y = $x & $x; $z = (2 ** $AND_BITS) - 1; } while ($AND_BITS < $max && $x == $z && $y == $x); $AND_BITS --; # retreat one step do { $XOR_BITS++; $x = CORE::oct('0b' . '1' x $XOR_BITS); $y = $x ^ 0; $z = (2 ** $XOR_BITS) - 1; } while ($XOR_BITS < $max && $x == $z && $y == $x); $XOR_BITS --; # retreat one step do { $OR_BITS++; $x = CORE::oct('0b' . '1' x $OR_BITS); $y = $x | $x; $z = (2 ** $OR_BITS) - 1; } while ($OR_BITS < $max && $x == $z && $y == $x); $OR_BITS --; # retreat one step $AND_MASK = __PACKAGE__->_new( ( 2 ** $AND_BITS )); $XOR_MASK = __PACKAGE__->_new( ( 2 ** $XOR_BITS )); $OR_MASK = __PACKAGE__->_new( ( 2 ** $OR_BITS )); # We can compute the approximate length no faster than the real length: *_alen = \&_len; } ############################################################################### sub _zero { # create a zero [ 0 ]; } sub _one { # create a one [ 1 ]; } sub _two { # create a two (used internally for shifting) [ 2 ]; } sub _ten { # create a 10 (used internally for shifting) [ 10 ]; } sub _1ex { # create a 1Ex my $rem = $_[1] % $BASE_LEN; # remainder my $parts = $_[1] / $BASE_LEN; # parts # 000000, 000000, 100 [ (0) x $parts, '1' . ('0' x $rem) ]; } sub _copy { # make a true copy [ @{$_[1]} ]; } # catch and throw away sub import { } ############################################################################## # convert back to string and number sub _str { # Convert number from internal base 1eN format to string format. Internal # format is always normalized, i.e., no leading zeros. my $ary = $_[1]; my $idx = $#$ary; # index of last element if ($idx < 0) { # should not happen require Carp; Carp::croak("$_[1] has no elements"); } # Handle first one differently, since it should not have any leading zeros. my $ret = int($ary->[$idx]); if ($idx > 0) { $idx--; # Interestingly, the pre-padd method uses more time # the old grep variant takes longer (14 vs. 10 sec) my $z = '0' x ($BASE_LEN - 1); while ($idx >= 0) { $ret .= substr($z . $ary->[$idx], -$BASE_LEN); $idx--; } } $ret; } sub _num { # Make a Perl scalar number (int/float) from a BigInt object. my $x = $_[1]; return 0 + $x->[0] if scalar @$x == 1; # below $BASE # Start with the most significant element and work towards the least # significant element. Avoid multiplying "inf" (which happens if the number # overflows) with "0" (if there are zero elements in $x) since this gives # "nan" which propagates to the output. my $num = 0; for (my $i = $#$x ; $i >= 0 ; --$i) { $num *= $BASE; $num += $x -> [$i]; } return $num; } ############################################################################## # actual math code sub _add { # (ref to int_num_array, ref to int_num_array) # # Routine to add two base 1eX numbers stolen from Knuth Vol 2 Algorithm A # pg 231. There are separate routines to add and sub as per Knuth pg 233. # This routine modifies array x, but not y. my ($c, $x, $y) = @_; return $x if @$y == 1 && $y->[0] == 0; # $x + 0 => $x if (@$x == 1 && $x->[0] == 0) { # 0 + $y => $y->copy # Twice as slow as $x = [ @$y ], but necessary to modify $x in-place. @$x = @$y; return $x; } # For each in Y, add Y to X and carry. If after that, something is left in # X, foreach in X add carry to X and then return X, carry. Trades one # "$j++" for having to shift arrays. my $i; my $car = 0; my $j = 0; for $i (@$y) { $x->[$j] -= $BASE if $car = (($x->[$j] += $i + $car) >= $BASE) ? 1 : 0; $j++; } while ($car != 0) { $x->[$j] -= $BASE if $car = (($x->[$j] += $car) >= $BASE) ? 1 : 0; $j++; } $x; } sub _inc { # (ref to int_num_array, ref to int_num_array) # Add 1 to $x, modify $x in place my ($c, $x) = @_; for my $i (@$x) { return $x if ($i += 1) < $BASE; # early out $i = 0; # overflow, next } push @$x, 1 if $x->[-1] == 0; # last overflowed, so extend $x; } sub _dec { # (ref to int_num_array, ref to int_num_array) # Sub 1 from $x, modify $x in place my ($c, $x) = @_; my $MAX = $BASE - 1; # since MAX_VAL based on BASE for my $i (@$x) { last if ($i -= 1) >= 0; # early out $i = $MAX; # underflow, next } pop @$x if $x->[-1] == 0 && @$x > 1; # last underflowed (but leave 0) $x; } sub _sub { # (ref to int_num_array, ref to int_num_array, swap) # # Subtract base 1eX numbers -- stolen from Knuth Vol 2 pg 232, $x > $y # subtract Y from X by modifying x in place my ($c, $sx, $sy, $s) = @_; my $car = 0; my $i; my $j = 0; if (!$s) { for $i (@$sx) { last unless defined $sy->[$j] || $car; $i += $BASE if $car = (($i -= ($sy->[$j] || 0) + $car) < 0); $j++; } # might leave leading zeros, so fix that return __strip_zeros($sx); } for $i (@$sx) { # We can't do an early out if $x < $y, since we need to copy the high # chunks from $y. Found by Bob Mathews. #last unless defined $sy->[$j] || $car; $sy->[$j] += $BASE if $car = ($sy->[$j] = $i - ($sy->[$j] || 0) - $car) < 0; $j++; } # might leave leading zeros, so fix that __strip_zeros($sy); } sub _mul_use_mul { # (ref to int_num_array, ref to int_num_array) # multiply two numbers in internal representation # modifies first arg, second need not be different from first my ($c,$xv,$yv) = @_; if (@$yv == 1) { # shortcut for two very short numbers (improved by Nathan Zook) # works also if xv and yv are the same reference, and handles also $x == 0 if (@$xv == 1) { if (($xv->[0] *= $yv->[0]) >= $BASE) { $xv->[0] = $xv->[0] - ($xv->[1] = int($xv->[0] * $RBASE)) * $BASE; }; return $xv; } # $x * 0 => 0 if ($yv->[0] == 0) { @$xv = (0); return $xv; } # multiply a large number a by a single element one, so speed up my $y = $yv->[0]; my $car = 0; foreach my $i (@$xv) { $i = $i * $y + $car; $car = int($i * $RBASE); $i -= $car * $BASE; } push @$xv, $car if $car != 0; return $xv; } # shortcut for result $x == 0 => result = 0 return $xv if ( ((@$xv == 1) && ($xv->[0] == 0)) ); # since multiplying $x with $x fails, make copy in this case $yv = [@$xv] if $xv == $yv; # same references? my @prod = (); my ($prod,$car,$cty,$xi,$yi); for $xi (@$xv) { $car = 0; $cty = 0; # slow variant # for $yi (@$yv) # { # $prod = $xi * $yi + ($prod[$cty] || 0) + $car; # $prod[$cty++] = # $prod - ($car = int($prod * RBASE)) * $BASE; # see USE_MUL # } # $prod[$cty] += $car if $car; # need really to check for 0? # $xi = shift @prod; # faster variant # looping through this if $xi == 0 is silly - so optimize it away! $xi = (shift @prod || 0), next if $xi == 0; for $yi (@$yv) { $prod = $xi * $yi + ($prod[$cty] || 0) + $car; ## this is actually a tad slower ## $prod = $prod[$cty]; $prod += ($car + $xi * $yi); # no ||0 here $prod[$cty++] = $prod - ($car = int($prod * $RBASE)) * $BASE; # see USE_MUL } $prod[$cty] += $car if $car; # need really to check for 0? $xi = shift @prod || 0; # || 0 makes v5.005_3 happy } push @$xv, @prod; # can't have leading zeros # __strip_zeros($xv); $xv; } sub _mul_use_div_64 { # (ref to int_num_array, ref to int_num_array) # multiply two numbers in internal representation # modifies first arg, second need not be different from first # works for 64 bit integer with "use integer" my ($c,$xv,$yv) = @_; use integer; if (@$yv == 1) { # shortcut for two small numbers, also handles $x == 0 if (@$xv == 1) { # shortcut for two very short numbers (improved by Nathan Zook) # works also if xv and yv are the same reference, and handles also $x == 0 if (($xv->[0] *= $yv->[0]) >= $BASE) { $xv->[0] = $xv->[0] - ($xv->[1] = $xv->[0] / $BASE) * $BASE; }; return $xv; } # $x * 0 => 0 if ($yv->[0] == 0) { @$xv = (0); return $xv; } # multiply a large number a by a single element one, so speed up my $y = $yv->[0]; my $car = 0; foreach my $i (@$xv) { #$i = $i * $y + $car; $car = $i / $BASE; $i -= $car * $BASE; $i = $i * $y + $car; $i -= ($car = $i / $BASE) * $BASE; } push @$xv, $car if $car != 0; return $xv; } # shortcut for result $x == 0 => result = 0 return $xv if ( ((@$xv == 1) && ($xv->[0] == 0)) ); # since multiplying $x with $x fails, make copy in this case $yv = [@$xv] if $xv == $yv; # same references? my @prod = (); my ($prod,$car,$cty,$xi,$yi); for $xi (@$xv) { $car = 0; $cty = 0; # looping through this if $xi == 0 is silly - so optimize it away! $xi = (shift @prod || 0), next if $xi == 0; for $yi (@$yv) { $prod = $xi * $yi + ($prod[$cty] || 0) + $car; $prod[$cty++] = $prod - ($car = $prod / $BASE) * $BASE; } $prod[$cty] += $car if $car; # need really to check for 0? $xi = shift @prod || 0; # || 0 makes v5.005_3 happy } push @$xv, @prod; $xv; } sub _mul_use_div { # (ref to int_num_array, ref to int_num_array) # multiply two numbers in internal representation # modifies first arg, second need not be different from first my ($c,$xv,$yv) = @_; if (@$yv == 1) { # shortcut for two small numbers, also handles $x == 0 if (@$xv == 1) { # shortcut for two very short numbers (improved by Nathan Zook) # works also if xv and yv are the same reference, and handles also $x == 0 if (($xv->[0] *= $yv->[0]) >= $BASE) { $xv->[0] = $xv->[0] - ($xv->[1] = int($xv->[0] / $BASE)) * $BASE; }; return $xv; } # $x * 0 => 0 if ($yv->[0] == 0) { @$xv = (0); return $xv; } # multiply a large number a by a single element one, so speed up my $y = $yv->[0]; my $car = 0; foreach my $i (@$xv) { $i = $i * $y + $car; $car = int($i / $BASE); $i -= $car * $BASE; # This (together with use integer;) does not work on 32-bit Perls #$i = $i * $y + $car; $i -= ($car = $i / $BASE) * $BASE; } push @$xv, $car if $car != 0; return $xv; } # shortcut for result $x == 0 => result = 0 return $xv if ( ((@$xv == 1) && ($xv->[0] == 0)) ); # since multiplying $x with $x fails, make copy in this case $yv = [@$xv] if $xv == $yv; # same references? my @prod = (); my ($prod,$car,$cty,$xi,$yi); for $xi (@$xv) { $car = 0; $cty = 0; # looping through this if $xi == 0 is silly - so optimize it away! $xi = (shift @prod || 0), next if $xi == 0; for $yi (@$yv) { $prod = $xi * $yi + ($prod[$cty] || 0) + $car; $prod[$cty++] = $prod - ($car = int($prod / $BASE)) * $BASE; } $prod[$cty] += $car if $car; # need really to check for 0? $xi = shift @prod || 0; # || 0 makes v5.005_3 happy } push @$xv, @prod; # can't have leading zeros # __strip_zeros($xv); $xv; } sub _div_use_mul { # ref to array, ref to array, modify first array and return remainder if # in list context # see comments in _div_use_div() for more explanations my ($c,$x,$yorg) = @_; # the general div algorithm here is about O(N*N) and thus quite slow, so # we first check for some special cases and use shortcuts to handle them. # This works, because we store the numbers in a chunked format where each # element contains 5..7 digits (depending on system). # if both numbers have only one element: if (@$x == 1 && @$yorg == 1) { # shortcut, $yorg and $x are two small numbers if (wantarray) { my $r = [ $x->[0] % $yorg->[0] ]; $x->[0] = int($x->[0] / $yorg->[0]); return ($x,$r); } else { $x->[0] = int($x->[0] / $yorg->[0]); return $x; } } # if x has more than one, but y has only one element: if (@$yorg == 1) { my $rem; $rem = _mod($c,[ @$x ],$yorg) if wantarray; # shortcut, $y is < $BASE my $j = scalar @$x; my $r = 0; my $y = $yorg->[0]; my $b; while ($j-- > 0) { $b = $r * $BASE + $x->[$j]; $x->[$j] = int($b/$y); $r = $b % $y; } pop @$x if @$x > 1 && $x->[-1] == 0; # splice up a leading zero return ($x,$rem) if wantarray; return $x; } # now x and y have more than one element # check whether y has more elements than x, if yet, the result will be 0 if (@$yorg > @$x) { my $rem; $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to original array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; # only x, which is [0] now } # check whether the numbers have the same number of elements, in that case # the result will fit into one element and can be computed efficiently if (@$yorg == @$x) { my $rem; # if $yorg has more digits than $x (it's leading element is longer than # the one from $x), the result will also be 0: if (length(int($yorg->[-1])) > length(int($x->[-1]))) { $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to org array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; } # now calculate $x / $yorg if (length(int($yorg->[-1])) == length(int($x->[-1]))) { # same length, so make full compare my $a = 0; my $j = scalar @$x - 1; # manual way (abort if unequal, good for early ne) while ($j >= 0) { last if ($a = $x->[$j] - $yorg->[$j]); $j--; } # $a contains the result of the compare between X and Y # a < 0: x < y, a == 0: x == y, a > 0: x > y if ($a <= 0) { $rem = [ 0 ]; # a = 0 => x == y => rem 0 $rem = [@$x] if $a != 0; # a < 0 => x < y => rem = x splice(@$x,1); # keep single element $x->[0] = 0; # if $a < 0 $x->[0] = 1 if $a == 0; # $x == $y return ($x,$rem) if wantarray; return $x; } # $x >= $y, so proceed normally } } # all other cases: my $y = [ @$yorg ]; # always make copy to preserve my ($car,$bar,$prd,$dd,$xi,$yi,@q,$v2,$v1,@d,$tmp,$q,$u2,$u1,$u0); $car = $bar = $prd = 0; if (($dd = int($BASE/($y->[-1]+1))) != 1) { for $xi (@$x) { $xi = $xi * $dd + $car; $xi -= ($car = int($xi * $RBASE)) * $BASE; # see USE_MUL } push(@$x, $car); $car = 0; for $yi (@$y) { $yi = $yi * $dd + $car; $yi -= ($car = int($yi * $RBASE)) * $BASE; # see USE_MUL } } else { push(@$x, 0); } @q = (); ($v2,$v1) = @$y[-2,-1]; $v2 = 0 unless $v2; while ($#$x > $#$y) { ($u2,$u1,$u0) = @$x[-3..-1]; $u2 = 0 unless $u2; #warn "oups v1 is 0, u0: $u0 $y->[-2] $y->[-1] l ",scalar @$y,"\n" # if $v1 == 0; $q = (($u0 == $v1) ? $MAX_VAL : int(($u0*$BASE+$u1)/$v1)); --$q while ($v2*$q > ($u0*$BASE+$u1-$q*$v1)*$BASE+$u2); if ($q) { ($car, $bar) = (0,0); for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $prd = $q * $y->[$yi] + $car; $prd -= ($car = int($prd * $RBASE)) * $BASE; # see USE_MUL $x->[$xi] += $BASE if ($bar = (($x->[$xi] -= $prd + $bar) < 0)); } if ($x->[-1] < $car + $bar) { $car = 0; --$q; for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $x->[$xi] -= $BASE if ($car = (($x->[$xi] += $y->[$yi] + $car) >= $BASE)); } } } pop(@$x); unshift(@q, $q); } if (wantarray) { @d = (); if ($dd != 1) { $car = 0; for $xi (reverse @$x) { $prd = $car * $BASE + $xi; $car = $prd - ($tmp = int($prd / $dd)) * $dd; # see USE_MUL unshift(@d, $tmp); } } else { @d = @$x; } @$x = @q; my $d = \@d; __strip_zeros($x); __strip_zeros($d); return ($x,$d); } @$x = @q; __strip_zeros($x); $x; } sub _div_use_div_64 { # ref to array, ref to array, modify first array and return remainder if # in list context # This version works on 64 bit integers my ($c,$x,$yorg) = @_; use integer; # the general div algorithm here is about O(N*N) and thus quite slow, so # we first check for some special cases and use shortcuts to handle them. # This works, because we store the numbers in a chunked format where each # element contains 5..7 digits (depending on system). # if both numbers have only one element: if (@$x == 1 && @$yorg == 1) { # shortcut, $yorg and $x are two small numbers if (wantarray) { my $r = [ $x->[0] % $yorg->[0] ]; $x->[0] = int($x->[0] / $yorg->[0]); return ($x,$r); } else { $x->[0] = int($x->[0] / $yorg->[0]); return $x; } } # if x has more than one, but y has only one element: if (@$yorg == 1) { my $rem; $rem = _mod($c,[ @$x ],$yorg) if wantarray; # shortcut, $y is < $BASE my $j = scalar @$x; my $r = 0; my $y = $yorg->[0]; my $b; while ($j-- > 0) { $b = $r * $BASE + $x->[$j]; $x->[$j] = int($b/$y); $r = $b % $y; } pop @$x if @$x > 1 && $x->[-1] == 0; # splice up a leading zero return ($x,$rem) if wantarray; return $x; } # now x and y have more than one element # check whether y has more elements than x, if yet, the result will be 0 if (@$yorg > @$x) { my $rem; $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to original array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; # only x, which is [0] now } # check whether the numbers have the same number of elements, in that case # the result will fit into one element and can be computed efficiently if (@$yorg == @$x) { my $rem; # if $yorg has more digits than $x (it's leading element is longer than # the one from $x), the result will also be 0: if (length(int($yorg->[-1])) > length(int($x->[-1]))) { $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to org array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; } # now calculate $x / $yorg if (length(int($yorg->[-1])) == length(int($x->[-1]))) { # same length, so make full compare my $a = 0; my $j = scalar @$x - 1; # manual way (abort if unequal, good for early ne) while ($j >= 0) { last if ($a = $x->[$j] - $yorg->[$j]); $j--; } # $a contains the result of the compare between X and Y # a < 0: x < y, a == 0: x == y, a > 0: x > y if ($a <= 0) { $rem = [ 0 ]; # a = 0 => x == y => rem 0 $rem = [@$x] if $a != 0; # a < 0 => x < y => rem = x splice(@$x,1); # keep single element $x->[0] = 0; # if $a < 0 $x->[0] = 1 if $a == 0; # $x == $y return ($x,$rem) if wantarray; # including remainder? return $x; } # $x >= $y, so proceed normally } } # all other cases: my $y = [ @$yorg ]; # always make copy to preserve my ($car,$bar,$prd,$dd,$xi,$yi,@q,$v2,$v1,@d,$tmp,$q,$u2,$u1,$u0); $car = $bar = $prd = 0; if (($dd = int($BASE/($y->[-1]+1))) != 1) { for $xi (@$x) { $xi = $xi * $dd + $car; $xi -= ($car = int($xi / $BASE)) * $BASE; } push(@$x, $car); $car = 0; for $yi (@$y) { $yi = $yi * $dd + $car; $yi -= ($car = int($yi / $BASE)) * $BASE; } } else { push(@$x, 0); } # @q will accumulate the final result, $q contains the current computed # part of the final result @q = (); ($v2,$v1) = @$y[-2,-1]; $v2 = 0 unless $v2; while ($#$x > $#$y) { ($u2,$u1,$u0) = @$x[-3..-1]; $u2 = 0 unless $u2; #warn "oups v1 is 0, u0: $u0 $y->[-2] $y->[-1] l ",scalar @$y,"\n" # if $v1 == 0; $q = (($u0 == $v1) ? $MAX_VAL : int(($u0*$BASE+$u1)/$v1)); --$q while ($v2*$q > ($u0*$BASE+$u1-$q*$v1)*$BASE+$u2); if ($q) { ($car, $bar) = (0,0); for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $prd = $q * $y->[$yi] + $car; $prd -= ($car = int($prd / $BASE)) * $BASE; $x->[$xi] += $BASE if ($bar = (($x->[$xi] -= $prd + $bar) < 0)); } if ($x->[-1] < $car + $bar) { $car = 0; --$q; for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $x->[$xi] -= $BASE if ($car = (($x->[$xi] += $y->[$yi] + $car) >= $BASE)); } } } pop(@$x); unshift(@q, $q); } if (wantarray) { @d = (); if ($dd != 1) { $car = 0; for $xi (reverse @$x) { $prd = $car * $BASE + $xi; $car = $prd - ($tmp = int($prd / $dd)) * $dd; unshift(@d, $tmp); } } else { @d = @$x; } @$x = @q; my $d = \@d; __strip_zeros($x); __strip_zeros($d); return ($x,$d); } @$x = @q; __strip_zeros($x); $x; } sub _div_use_div { # ref to array, ref to array, modify first array and return remainder if # in list context my ($c,$x,$yorg) = @_; # the general div algorithm here is about O(N*N) and thus quite slow, so # we first check for some special cases and use shortcuts to handle them. # This works, because we store the numbers in a chunked format where each # element contains 5..7 digits (depending on system). # if both numbers have only one element: if (@$x == 1 && @$yorg == 1) { # shortcut, $yorg and $x are two small numbers if (wantarray) { my $r = [ $x->[0] % $yorg->[0] ]; $x->[0] = int($x->[0] / $yorg->[0]); return ($x,$r); } else { $x->[0] = int($x->[0] / $yorg->[0]); return $x; } } # if x has more than one, but y has only one element: if (@$yorg == 1) { my $rem; $rem = _mod($c,[ @$x ],$yorg) if wantarray; # shortcut, $y is < $BASE my $j = scalar @$x; my $r = 0; my $y = $yorg->[0]; my $b; while ($j-- > 0) { $b = $r * $BASE + $x->[$j]; $x->[$j] = int($b/$y); $r = $b % $y; } pop @$x if @$x > 1 && $x->[-1] == 0; # splice up a leading zero return ($x,$rem) if wantarray; return $x; } # now x and y have more than one element # check whether y has more elements than x, if yet, the result will be 0 if (@$yorg > @$x) { my $rem; $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to original array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; # only x, which is [0] now } # check whether the numbers have the same number of elements, in that case # the result will fit into one element and can be computed efficiently if (@$yorg == @$x) { my $rem; # if $yorg has more digits than $x (it's leading element is longer than # the one from $x), the result will also be 0: if (length(int($yorg->[-1])) > length(int($x->[-1]))) { $rem = [@$x] if wantarray; # make copy splice (@$x,1); # keep ref to org array $x->[0] = 0; # set to 0 return ($x,$rem) if wantarray; # including remainder? return $x; } # now calculate $x / $yorg if (length(int($yorg->[-1])) == length(int($x->[-1]))) { # same length, so make full compare my $a = 0; my $j = scalar @$x - 1; # manual way (abort if unequal, good for early ne) while ($j >= 0) { last if ($a = $x->[$j] - $yorg->[$j]); $j--; } # $a contains the result of the compare between X and Y # a < 0: x < y, a == 0: x == y, a > 0: x > y if ($a <= 0) { $rem = [ 0 ]; # a = 0 => x == y => rem 0 $rem = [@$x] if $a != 0; # a < 0 => x < y => rem = x splice(@$x,1); # keep single element $x->[0] = 0; # if $a < 0 $x->[0] = 1 if $a == 0; # $x == $y return ($x,$rem) if wantarray; # including remainder? return $x; } # $x >= $y, so proceed normally } } # all other cases: my $y = [ @$yorg ]; # always make copy to preserve my ($car,$bar,$prd,$dd,$xi,$yi,@q,$v2,$v1,@d,$tmp,$q,$u2,$u1,$u0); $car = $bar = $prd = 0; if (($dd = int($BASE/($y->[-1]+1))) != 1) { for $xi (@$x) { $xi = $xi * $dd + $car; $xi -= ($car = int($xi / $BASE)) * $BASE; } push(@$x, $car); $car = 0; for $yi (@$y) { $yi = $yi * $dd + $car; $yi -= ($car = int($yi / $BASE)) * $BASE; } } else { push(@$x, 0); } # @q will accumulate the final result, $q contains the current computed # part of the final result @q = (); ($v2,$v1) = @$y[-2,-1]; $v2 = 0 unless $v2; while ($#$x > $#$y) { ($u2,$u1,$u0) = @$x[-3..-1]; $u2 = 0 unless $u2; #warn "oups v1 is 0, u0: $u0 $y->[-2] $y->[-1] l ",scalar @$y,"\n" # if $v1 == 0; $q = (($u0 == $v1) ? $MAX_VAL : int(($u0*$BASE+$u1)/$v1)); --$q while ($v2*$q > ($u0*$BASE+$u1-$q*$v1)*$BASE+$u2); if ($q) { ($car, $bar) = (0,0); for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $prd = $q * $y->[$yi] + $car; $prd -= ($car = int($prd / $BASE)) * $BASE; $x->[$xi] += $BASE if ($bar = (($x->[$xi] -= $prd + $bar) < 0)); } if ($x->[-1] < $car + $bar) { $car = 0; --$q; for ($yi = 0, $xi = $#$x-$#$y-1; $yi <= $#$y; ++$yi,++$xi) { $x->[$xi] -= $BASE if ($car = (($x->[$xi] += $y->[$yi] + $car) >= $BASE)); } } } pop(@$x); unshift(@q, $q); } if (wantarray) { @d = (); if ($dd != 1) { $car = 0; for $xi (reverse @$x) { $prd = $car * $BASE + $xi; $car = $prd - ($tmp = int($prd / $dd)) * $dd; unshift(@d, $tmp); } } else { @d = @$x; } @$x = @q; my $d = \@d; __strip_zeros($x); __strip_zeros($d); return ($x,$d); } @$x = @q; __strip_zeros($x); $x; } ############################################################################## # testing sub _acmp { # Internal absolute post-normalized compare (ignore signs) # ref to array, ref to array, return <0, 0, >0 # Arrays must have at least one entry; this is not checked for. my ($c, $cx, $cy) = @_; # shortcut for short numbers return (($cx->[0] <=> $cy->[0]) <=> 0) if @$cx == @$cy && @$cx == 1; # fast comp based on number of array elements (aka pseudo-length) my $lxy = (@$cx - @$cy) # or length of first element if same number of elements (aka difference 0) || # need int() here because sometimes the last element is '00018' vs '18' (length(int($cx->[-1])) - length(int($cy->[-1]))); return -1 if $lxy < 0; # already differs, ret return 1 if $lxy > 0; # ditto # manual way (abort if unequal, good for early ne) my $a; my $j = @$cx; while (--$j >= 0) { last if $a = $cx->[$j] - $cy->[$j]; } $a <=> 0; } sub _len { # compute number of digits in base 10 # int() because add/sub sometimes leaves strings (like '00005') instead of # '5' in this place, thus causing length() to report wrong length my $cx = $_[1]; (@$cx - 1) * $BASE_LEN + length(int($cx->[-1])); } sub _digit { # Return the nth digit. Zero is rightmost, so _digit(123,0) gives 3. # Negative values count from the left, so _digit(123, -1) gives 1. my ($c, $x, $n) = @_; my $len = _len('', $x); $n += $len if $n < 0; # -1 last, -2 second-to-last return "0" if $n < 0 || $n >= $len; # return 0 for digits out of range my $elem = int($n / $BASE_LEN); # which array element my $digit = $n % $BASE_LEN; # which digit in this element substr("$x->[$elem]", -$digit - 1, 1); } sub _zeros { # Return number of trailing zeros in decimal. # Check each array element for having 0 at end as long as elem == 0 # Upon finding a elem != 0, stop. my $x = $_[1]; return 0 if @$x == 1 && $x->[0] == 0; my $zeros = 0; my $elem; foreach my $e (@$x) { if ($e != 0) { $elem = "$e"; # preserve x $elem =~ s/.*?(0*$)/$1/; # strip anything not zero $zeros *= $BASE_LEN; # elems * 5 $zeros += length($elem); # count trailing zeros last; # early out } $zeros ++; # real else branch: 50% slower! } $zeros; } ############################################################################## # _is_* routines sub _is_zero { # return true if arg is zero @{$_[1]} == 1 && $_[1]->[0] == 0 ? 1 : 0; } sub _is_even { # return true if arg is even $_[1]->[0] & 1 ? 0 : 1; } sub _is_odd { # return true if arg is odd $_[1]->[0] & 1 ? 1 : 0; } sub _is_one { # return true if arg is one @{$_[1]} == 1 && $_[1]->[0] == 1 ? 1 : 0; } sub _is_two { # return true if arg is two @{$_[1]} == 1 && $_[1]->[0] == 2 ? 1 : 0; } sub _is_ten { # return true if arg is ten @{$_[1]} == 1 && $_[1]->[0] == 10 ? 1 : 0; } sub __strip_zeros { # Internal normalization function that strips leading zeros from the array. # Args: ref to array my $s = shift; my $cnt = @$s; # get count of parts my $i = $cnt - 1; push @$s, 0 if $i < 0; # div might return empty results, so fix it return $s if @$s == 1; # early out #print "strip: cnt $cnt i $i\n"; # '0', '3', '4', '0', '0', # 0 1 2 3 4 # cnt = 5, i = 4 # i = 4 # i = 3 # => fcnt = cnt - i (5-2 => 3, cnt => 5-1 = 4, throw away from 4th pos) # >= 1: skip first part (this can be zero) while ($i > 0) { last if $s->[$i] != 0; $i--; } $i++; splice @$s, $i if $i < $cnt; # $i cant be 0 $s; } ############################################################################### # check routine to test internal state for corruptions sub _check { # used by the test suite my $x = $_[1]; return "$x is not a reference" if !ref($x); # are all parts are valid? my $i = 0; my $j = @$x; my ($e, $try); while ($i < $j) { $e = $x->[$i]; $e = 'undef' unless defined $e; $try = '=~ /^[\+]?[0-9]+\$/; '."($x, $e)"; last if $e !~ /^[+]?[0-9]+$/; $try = '=~ /^[\+]?[0-9]+\$/; '."($x, $e) (stringify)"; last if "$e" !~ /^[+]?[0-9]+$/; $try = '=~ /^[\+]?[0-9]+\$/; '."($x, $e) (cat-stringify)"; last if '' . "$e" !~ /^[+]?[0-9]+$/; $try = ' < 0 || >= $BASE; '."($x, $e)"; last if $e <0 || $e >= $BASE; # This test is disabled, since new/bnorm and certain ops (like early out # in add/sub) are allowed/expected to leave '00000' in some elements. #$try = '=~ /^00+/; '."($x, $e)"; #last if $e =~ /^00+/; $i++; } return "Illegal part '$e' at pos $i (tested: $try)" if $i < $j; 0; } ############################################################################### sub _mod { # if possible, use mod shortcut my ($c, $x, $yo) = @_; # slow way since $y too big if (@$yo > 1) { my ($xo, $rem) = _div($c, $x, $yo); @$x = @$rem; return $x; } my $y = $yo->[0]; # if both are single element arrays if (scalar @$x == 1) { $x->[0] %= $y; return $x; } # if @$x has more than one element, but @$y is a single element my $b = $BASE % $y; if ($b == 0) { # when BASE % Y == 0 then (B * BASE) % Y == 0 # (B * BASE) % $y + A % Y => A % Y # so need to consider only last element: O(1) $x->[0] %= $y; } elsif ($b == 1) { # else need to go through all elements in @$x: O(N), but loop is a bit # simplified my $r = 0; foreach (@$x) { $r = ($r + $_) % $y; # not much faster, but heh... #$r += $_ % $y; $r %= $y; } $r = 0 if $r == $y; $x->[0] = $r; } else { # else need to go through all elements in @$x: O(N) my $r = 0; my $bm = 1; foreach (@$x) { $r = ($_ * $bm + $r) % $y; $bm = ($bm * $b) % $y; #$r += ($_ % $y) * $bm; #$bm *= $b; #$bm %= $y; #$r %= $y; } $r = 0 if $r == $y; $x->[0] = $r; } @$x = $x->[0]; # keep one element of @$x return $x; } ############################################################################## # shifts sub _rsft { my ($c, $x, $y, $n) = @_; if ($n != 10) { $n = _new($c, $n); return _div($c, $x, _pow($c, $n, $y)); } # shortcut (faster) for shifting by 10) # multiples of $BASE_LEN my $dst = 0; # destination my $src = _num($c, $y); # as normal int my $xlen = (@$x - 1) * $BASE_LEN + length(int($x->[-1])); if ($src >= $xlen or ($src == $xlen and !defined $x->[1])) { # 12345 67890 shifted right by more than 10 digits => 0 splice(@$x, 1); # leave only one element $x->[0] = 0; # set to zero return $x; } my $rem = $src % $BASE_LEN; # remainder to shift $src = int($src / $BASE_LEN); # source if ($rem == 0) { splice(@$x, 0, $src); # even faster, 38.4 => 39.3 } else { my $len = @$x - $src; # elems to go my $vd; my $z = '0' x $BASE_LEN; $x->[@$x] = 0; # avoid || 0 test inside loop while ($dst < $len) { $vd = $z . $x->[$src]; $vd = substr($vd, -$BASE_LEN, $BASE_LEN - $rem); $src++; $vd = substr($z . $x->[$src], -$rem, $rem) . $vd; $vd = substr($vd, -$BASE_LEN, $BASE_LEN) if length($vd) > $BASE_LEN; $x->[$dst] = int($vd); $dst++; } splice(@$x, $dst) if $dst > 0; # kill left-over array elems pop @$x if $x->[-1] == 0 && @$x > 1; # kill last element if 0 } # else rem == 0 $x; } sub _lsft { my ($c, $x, $y, $n) = @_; if ($n != 10) { $n = _new($c, $n); return _mul($c, $x, _pow($c, $n, $y)); } # shortcut (faster) for shifting by 10) since we are in base 10eX # multiples of $BASE_LEN: my $src = @$x; # source my $len = _num($c, $y); # shift-len as normal int my $rem = $len % $BASE_LEN; # remainder to shift my $dst = $src + int($len / $BASE_LEN); # destination my $vd; # further speedup $x->[$src] = 0; # avoid first ||0 for speed my $z = '0' x $BASE_LEN; while ($src >= 0) { $vd = $x->[$src]; $vd = $z . $vd; $vd = substr($vd, -$BASE_LEN + $rem, $BASE_LEN - $rem); $vd .= $src > 0 ? substr($z . $x->[$src - 1], -$BASE_LEN, $rem) : '0' x $rem; $vd = substr($vd, -$BASE_LEN, $BASE_LEN) if length($vd) > $BASE_LEN; $x->[$dst] = int($vd); $dst--; $src--; } # set lowest parts to 0 while ($dst >= 0) { $x->[$dst--] = 0; } # fix spurious last zero element splice @$x, -1 if $x->[-1] == 0; $x; } sub _pow { # power of $x to $y # ref to array, ref to array, return ref to array my ($c, $cx, $cy) = @_; if (@$cy == 1 && $cy->[0] == 0) { splice(@$cx, 1); $cx->[0] = 1; # y == 0 => x => 1 return $cx; } if ((@$cx == 1 && $cx->[0] == 1) || # x == 1 (@$cy == 1 && $cy->[0] == 1)) # or y == 1 { return $cx; } if (@$cx == 1 && $cx->[0] == 0) { splice (@$cx, 1); $cx->[0] = 0; # 0 ** y => 0 (if not y <= 0) return $cx; } my $pow2 = _one(); my $y_bin = _as_bin($c, $cy); $y_bin =~ s/^0b//; my $len = length($y_bin); while (--$len > 0) { _mul($c, $pow2, $cx) if substr($y_bin, $len, 1) eq '1'; # is odd? _mul($c, $cx, $cx); } _mul($c, $cx, $pow2); $cx; } sub _nok { # Return binomial coefficient (n over k). # Given refs to arrays, return ref to array. # First input argument is modified. my ($c, $n, $k) = @_; # If k > n/2, or, equivalently, 2*k > n, compute nok(n, k) as # nok(n, n-k), to minimize the number if iterations in the loop. { my $twok = _mul($c, _two($c), _copy($c, $k)); # 2 * k if (_acmp($c, $twok, $n) > 0) { # if 2*k > n $k = _sub($c, _copy($c, $n), $k); # k = n - k } } # Example: # # / 7 \ 7! 1*2*3*4 * 5*6*7 5 * 6 * 7 6 7 # | | = --------- = --------------- = --------- = 5 * - * - # \ 3 / (7-3)! 3! 1*2*3*4 * 1*2*3 1 * 2 * 3 2 3 if (_is_zero($c, $k)) { @$n = 1; } else { # Make a copy of the original n, since we'll be modifying n in-place. my $n_orig = _copy($c, $n); # n = 5, f = 6, d = 2 (cf. example above) _sub($c, $n, $k); _inc($c, $n); my $f = _copy($c, $n); _inc($c, $f); my $d = _two($c); # while f <= n (the original n, that is) ... while (_acmp($c, $f, $n_orig) <= 0) { # n = (n * f / d) == 5 * 6 / 2 (cf. example above) _mul($c, $n, $f); _div($c, $n, $d); # f = 7, d = 3 (cf. example above) _inc($c, $f); _inc($c, $d); } } return $n; } my @factorials = ( 1, 1, 2, 2*3, 2*3*4, 2*3*4*5, 2*3*4*5*6, 2*3*4*5*6*7, ); sub _fac { # factorial of $x # ref to array, return ref to array my ($c,$cx) = @_; if ((@$cx == 1) && ($cx->[0] <= 7)) { $cx->[0] = $factorials[$cx->[0]]; # 0 => 1, 1 => 1, 2 => 2 etc. return $cx; } if ((@$cx == 1) && # we do this only if $x >= 12 and $x <= 7000 ($cx->[0] >= 12 && $cx->[0] < 7000)) { # Calculate (k-j) * (k-j+1) ... k .. (k+j-1) * (k + j) # See http://blogten.blogspot.com/2007/01/calculating-n.html # The above series can be expressed as factors: # k * k - (j - i) * 2 # We cache k*k, and calculate (j * j) as the sum of the first j odd integers # This will not work when N exceeds the storage of a Perl scalar, however, # in this case the algorithm would be way to slow to terminate, anyway. # As soon as the last element of $cx is 0, we split it up and remember # how many zeors we got so far. The reason is that n! will accumulate # zeros at the end rather fast. my $zero_elements = 0; # If n is even, set n = n -1 my $k = _num($c,$cx); my $even = 1; if (($k & 1) == 0) { $even = $k; $k --; } # set k to the center point $k = ($k + 1) / 2; # print "k $k even: $even\n"; # now calculate k * k my $k2 = $k * $k; my $odd = 1; my $sum = 1; my $i = $k - 1; # keep reference to x my $new_x = _new($c, $k * $even); @$cx = @$new_x; if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } # print STDERR "x = ", _str($c,$cx),"\n"; my $BASE2 = int(sqrt($BASE))-1; my $j = 1; while ($j <= $i) { my $m = ($k2 - $sum); $odd += 2; $sum += $odd; $j++; while ($j <= $i && ($m < $BASE2) && (($k2 - $sum) < $BASE2)) { $m *= ($k2 - $sum); $odd += 2; $sum += $odd; $j++; # print STDERR "\n k2 $k2 m $m sum $sum odd $odd\n"; sleep(1); } if ($m < $BASE) { _mul($c,$cx,[$m]); } else { _mul($c,$cx,$c->_new($m)); } if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } # print STDERR "Calculate $k2 - $sum = $m (x = ", _str($c,$cx),")\n"; } # multiply in the zeros again unshift @$cx, (0) x $zero_elements; return $cx; } # go forward until $base is exceeded # limit is either $x steps (steps == 100 means a result always too high) or # $base. my $steps = 100; $steps = $cx->[0] if @$cx == 1; my $r = 2; my $cf = 3; my $step = 2; my $last = $r; while ($r*$cf < $BASE && $step < $steps) { $last = $r; $r *= $cf++; $step++; } if ((@$cx == 1) && $step == $cx->[0]) { # completely done, so keep reference to $x and return $cx->[0] = $r; return $cx; } # now we must do the left over steps my $n; # steps still to do if (scalar @$cx == 1) { $n = $cx->[0]; } else { $n = _copy($c,$cx); } # Set $cx to the last result below $BASE (but keep ref to $x) $cx->[0] = $last; splice (@$cx,1); # As soon as the last element of $cx is 0, we split it up and remember # how many zeors we got so far. The reason is that n! will accumulate # zeros at the end rather fast. my $zero_elements = 0; # do left-over steps fit into a scalar? if (ref $n eq 'ARRAY') { # No, so use slower inc() & cmp() # ($n is at least $BASE here) my $base_2 = int(sqrt($BASE)) - 1; #print STDERR "base_2: $base_2\n"; while ($step < $base_2) { if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } my $b = $step * ($step + 1); $step += 2; _mul($c,$cx,[$b]); } $step = [$step]; while (_acmp($c,$step,$n) <= 0) { if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } _mul($c,$cx,$step); _inc($c,$step); } } else { # Yes, so we can speed it up slightly # print "# left over steps $n\n"; my $base_4 = int(sqrt(sqrt($BASE))) - 2; #print STDERR "base_4: $base_4\n"; my $n4 = $n - 4; while ($step < $n4 && $step < $base_4) { if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } my $b = $step * ($step + 1); $step += 2; $b *= $step * ($step + 1); $step += 2; _mul($c,$cx,[$b]); } my $base_2 = int(sqrt($BASE)) - 1; my $n2 = $n - 2; #print STDERR "base_2: $base_2\n"; while ($step < $n2 && $step < $base_2) { if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } my $b = $step * ($step + 1); $step += 2; _mul($c,$cx,[$b]); } # do what's left over while ($step <= $n) { _mul($c,$cx,[$step]); $step++; if ($cx->[0] == 0) { $zero_elements ++; shift @$cx; } } } # multiply in the zeros again unshift @$cx, (0) x $zero_elements; $cx; # return result } ############################################################################# sub _log_int { # calculate integer log of $x to base $base # ref to array, ref to array - return ref to array my ($c,$x,$base) = @_; # X == 0 => NaN return if (scalar @$x == 1 && $x->[0] == 0); # BASE 0 or 1 => NaN return if (scalar @$base == 1 && $base->[0] < 2); my $cmp = _acmp($c,$x,$base); # X == BASE => 1 if ($cmp == 0) { splice (@$x,1); $x->[0] = 1; return ($x,1) } # X < BASE if ($cmp < 0) { splice (@$x,1); $x->[0] = 0; return ($x,undef); } my $x_org = _copy($c,$x); # preserve x splice(@$x,1); $x->[0] = 1; # keep ref to $x # Compute a guess for the result based on: # $guess = int ( length_in_base_10(X) / ( log(base) / log(10) ) ) my $len = _len($c,$x_org); my $log = log($base->[-1]) / log(10); # for each additional element in $base, we add $BASE_LEN to the result, # based on the observation that log($BASE,10) is BASE_LEN and # log(x*y) == log(x) + log(y): $log += ((scalar @$base)-1) * $BASE_LEN; # calculate now a guess based on the values obtained above: my $res = int($len / $log); $x->[0] = $res; my $trial = _pow ($c, _copy($c, $base), $x); my $a = _acmp($c,$trial,$x_org); # print STDERR "# trial ", _str($c,$x)," was: $a (0 = exact, -1 too small, +1 too big)\n"; # found an exact result? return ($x,1) if $a == 0; if ($a > 0) { # or too big _div($c,$trial,$base); _dec($c, $x); while (($a = _acmp($c,$trial,$x_org)) > 0) { # print STDERR "# big _log_int at ", _str($c,$x), "\n"; _div($c,$trial,$base); _dec($c, $x); } # result is now exact (a == 0), or too small (a < 0) return ($x, $a == 0 ? 1 : 0); } # else: result was to small _mul($c,$trial,$base); # did we now get the right result? $a = _acmp($c,$trial,$x_org); if ($a == 0) # yes, exactly { _inc($c, $x); return ($x,1); } return ($x,0) if $a > 0; # Result still too small (we should come here only if the estimate above # was very off base): # Now let the normal trial run obtain the real result # Simple loop that increments $x by 2 in each step, possible overstepping # the real result my $base_mul = _mul($c, _copy($c,$base), $base); # $base * $base while (($a = _acmp($c,$trial,$x_org)) < 0) { # print STDERR "# small _log_int at ", _str($c,$x), "\n"; _mul($c,$trial,$base_mul); _add($c, $x, [2]); } my $exact = 1; if ($a > 0) { # overstepped the result _dec($c, $x); _div($c,$trial,$base); $a = _acmp($c,$trial,$x_org); if ($a > 0) { _dec($c, $x); } $exact = 0 if $a != 0; # a = -1 => not exact result, a = 0 => exact } ($x,$exact); # return result } # for debugging: use constant DEBUG => 0; my $steps = 0; sub steps { $steps }; sub _sqrt { # square-root of $x in place # Compute a guess of the result (by rule of thumb), then improve it via # Newton's method. my ($c,$x) = @_; if (scalar @$x == 1) { # fits into one Perl scalar, so result can be computed directly $x->[0] = int(sqrt($x->[0])); return $x; } my $y = _copy($c,$x); # hopefully _len/2 is < $BASE, the -1 is to always undershot the guess # since our guess will "grow" my $l = int((_len($c,$x)-1) / 2); my $lastelem = $x->[-1]; # for guess my $elems = scalar @$x - 1; # not enough digits, but could have more? if ((length($lastelem) <= 3) && ($elems > 1)) { # right-align with zero pad my $len = length($lastelem) & 1; print "$lastelem => " if DEBUG; $lastelem .= substr($x->[-2] . '0' x $BASE_LEN,0,$BASE_LEN); # former odd => make odd again, or former even to even again $lastelem = $lastelem / 10 if (length($lastelem) & 1) != $len; print "$lastelem\n" if DEBUG; } # construct $x (instead of _lsft($c,$x,$l,10) my $r = $l % $BASE_LEN; # 10000 00000 00000 00000 ($BASE_LEN=5) $l = int($l / $BASE_LEN); print "l = $l " if DEBUG; splice @$x,$l; # keep ref($x), but modify it # we make the first part of the guess not '1000...0' but int(sqrt($lastelem)) # that gives us: # 14400 00000 => sqrt(14400) => guess first digits to be 120 # 144000 000000 => sqrt(144000) => guess 379 print "$lastelem (elems $elems) => " if DEBUG; $lastelem = $lastelem / 10 if ($elems & 1 == 1); # odd or even? my $g = sqrt($lastelem); $g =~ s/\.//; # 2.345 => 2345 $r -= 1 if $elems & 1 == 0; # 70 => 7 # padd with zeros if result is too short $x->[$l--] = int(substr($g . '0' x $r,0,$r+1)); print "now ",$x->[-1] if DEBUG; print " would have been ", int('1' . '0' x $r),"\n" if DEBUG; # If @$x > 1, we could compute the second elem of the guess, too, to create # an even better guess. Not implemented yet. Does it improve performance? $x->[$l--] = 0 while ($l >= 0); # all other digits of guess are zero print "start x= ",_str($c,$x),"\n" if DEBUG; my $two = _two(); my $last = _zero(); my $lastlast = _zero(); $steps = 0 if DEBUG; while (_acmp($c,$last,$x) != 0 && _acmp($c,$lastlast,$x) != 0) { $steps++ if DEBUG; $lastlast = _copy($c,$last); $last = _copy($c,$x); _add($c,$x, _div($c,_copy($c,$y),$x)); _div($c,$x, $two ); print " x= ",_str($c,$x),"\n" if DEBUG; } print "\nsteps in sqrt: $steps, " if DEBUG; _dec($c,$x) if _acmp($c,$y,_mul($c,_copy($c,$x),$x)) < 0; # overshot? print " final ",$x->[-1],"\n" if DEBUG; $x; } sub _root { # take n'th root of $x in place (n >= 3) my ($c,$x,$n) = @_; if (scalar @$x == 1) { if (scalar @$n > 1) { # result will always be smaller than 2 so trunc to 1 at once $x->[0] = 1; } else { # fits into one Perl scalar, so result can be computed directly # cannot use int() here, because it rounds wrongly (try # (81 ** 3) ** (1/3) to see what I mean) #$x->[0] = int( $x->[0] ** (1 / $n->[0]) ); # round to 8 digits, then truncate result to integer $x->[0] = int ( sprintf ("%.8f", $x->[0] ** (1 / $n->[0]) ) ); } return $x; } # we know now that X is more than one element long # if $n is a power of two, we can repeatedly take sqrt($X) and find the # proper result, because sqrt(sqrt($x)) == root($x,4) my $b = _as_bin($c,$n); if ($b =~ /0b1(0+)$/) { my $count = CORE::length($1); # 0b100 => len('00') => 2 my $cnt = $count; # counter for loop unshift (@$x, 0); # add one element, together with one # more below in the loop this makes 2 while ($cnt-- > 0) { # 'inflate' $X by adding one element, basically computing # $x * $BASE * $BASE. This gives us more $BASE_LEN digits for result # since len(sqrt($X)) approx == len($x) / 2. unshift (@$x, 0); # calculate sqrt($x), $x is now one element to big, again. In the next # round we make that two, again. _sqrt($c,$x); } # $x is now one element to big, so truncate result by removing it splice (@$x,0,1); } else { # trial computation by starting with 2,4,8,16 etc until we overstep my $step; my $trial = _two(); # while still to do more than X steps do { $step = _two(); while (_acmp($c, _pow($c, _copy($c, $trial), $n), $x) < 0) { _mul ($c, $step, [2]); _add ($c, $trial, $step); } # hit exactly? if (_acmp($c, _pow($c, _copy($c, $trial), $n), $x) == 0) { @$x = @$trial; # make copy while preserving ref to $x return $x; } # overstepped, so go back on step _sub($c, $trial, $step); } while (scalar @$step > 1 || $step->[0] > 128); # reset step to 2 $step = _two(); # add two, because $trial cannot be exactly the result (otherwise we would # already have found it) _add($c, $trial, $step); # and now add more and more (2,4,6,8,10 etc) while (_acmp($c, _pow($c, _copy($c, $trial), $n), $x) < 0) { _add ($c, $trial, $step); } # hit not exactly? (overstepped) if (_acmp($c, _pow($c, _copy($c, $trial), $n), $x) > 0) { _dec($c,$trial); } # hit not exactly? (overstepped) # 80 too small, 81 slightly too big, 82 too big if (_acmp($c, _pow($c, _copy($c, $trial), $n), $x) > 0) { _dec ($c, $trial); } @$x = @$trial; # make copy while preserving ref to $x return $x; } $x; } ############################################################################## # binary stuff sub _and { my ($c,$x,$y) = @_; # the shortcut makes equal, large numbers _really_ fast, and makes only a # very small performance drop for small numbers (e.g. something with less # than 32 bit) Since we optimize for large numbers, this is enabled. return $x if _acmp($c,$x,$y) == 0; # shortcut my $m = _one(); my ($xr,$yr); my $mask = $AND_MASK; my $x1 = $x; my $y1 = _copy($c,$y); # make copy $x = _zero(); my ($b,$xrr,$yrr); use integer; while (!_is_zero($c,$x1) && !_is_zero($c,$y1)) { ($x1, $xr) = _div($c,$x1,$mask); ($y1, $yr) = _div($c,$y1,$mask); # make ints() from $xr, $yr # this is when the AND_BITS are greater than $BASE and is slower for # small (<256 bits) numbers, but faster for large numbers. Disabled # due to KISS principle # $b = 1; $xrr = 0; foreach (@$xr) { $xrr += $_ * $b; $b *= $BASE; } # $b = 1; $yrr = 0; foreach (@$yr) { $yrr += $_ * $b; $b *= $BASE; } # _add($c,$x, _mul($c, _new( $c, ($xrr & $yrr) ), $m) ); # 0+ due to '&' doesn't work in strings _add($c,$x, _mul($c, [ 0+$xr->[0] & 0+$yr->[0] ], $m) ); _mul($c,$m,$mask); } $x; } sub _xor { my ($c,$x,$y) = @_; return _zero() if _acmp($c,$x,$y) == 0; # shortcut (see -and) my $m = _one(); my ($xr,$yr); my $mask = $XOR_MASK; my $x1 = $x; my $y1 = _copy($c,$y); # make copy $x = _zero(); my ($b,$xrr,$yrr); use integer; while (!_is_zero($c,$x1) && !_is_zero($c,$y1)) { ($x1, $xr) = _div($c,$x1,$mask); ($y1, $yr) = _div($c,$y1,$mask); # make ints() from $xr, $yr (see _and()) #$b = 1; $xrr = 0; foreach (@$xr) { $xrr += $_ * $b; $b *= $BASE; } #$b = 1; $yrr = 0; foreach (@$yr) { $yrr += $_ * $b; $b *= $BASE; } #_add($c,$x, _mul($c, _new( $c, ($xrr ^ $yrr) ), $m) ); # 0+ due to '^' doesn't work in strings _add($c,$x, _mul($c, [ 0+$xr->[0] ^ 0+$yr->[0] ], $m) ); _mul($c,$m,$mask); } # the loop stops when the shorter of the two numbers is exhausted # the remainder of the longer one will survive bit-by-bit, so we simple # multiply-add it in _add($c,$x, _mul($c, $x1, $m) ) if !_is_zero($c,$x1); _add($c,$x, _mul($c, $y1, $m) ) if !_is_zero($c,$y1); $x; } sub _or { my ($c,$x,$y) = @_; return $x if _acmp($c,$x,$y) == 0; # shortcut (see _and) my $m = _one(); my ($xr,$yr); my $mask = $OR_MASK; my $x1 = $x; my $y1 = _copy($c,$y); # make copy $x = _zero(); my ($b,$xrr,$yrr); use integer; while (!_is_zero($c,$x1) && !_is_zero($c,$y1)) { ($x1, $xr) = _div($c,$x1,$mask); ($y1, $yr) = _div($c,$y1,$mask); # make ints() from $xr, $yr (see _and()) # $b = 1; $xrr = 0; foreach (@$xr) { $xrr += $_ * $b; $b *= $BASE; } # $b = 1; $yrr = 0; foreach (@$yr) { $yrr += $_ * $b; $b *= $BASE; } # _add($c,$x, _mul($c, _new( $c, ($xrr | $yrr) ), $m) ); # 0+ due to '|' doesn't work in strings _add($c,$x, _mul($c, [ 0+$xr->[0] | 0+$yr->[0] ], $m) ); _mul($c,$m,$mask); } # the loop stops when the shorter of the two numbers is exhausted # the remainder of the longer one will survive bit-by-bit, so we simple # multiply-add it in _add($c,$x, _mul($c, $x1, $m) ) if !_is_zero($c,$x1); _add($c,$x, _mul($c, $y1, $m) ) if !_is_zero($c,$y1); $x; } sub _as_hex { # convert a decimal number to hex (ref to array, return ref to string) my ($c,$x) = @_; # fits into one element (handle also 0x0 case) return sprintf("0x%x",$x->[0]) if @$x == 1; my $x1 = _copy($c,$x); my $es = ''; my ($xr, $h, $x10000); if ($] >= 5.006) { $x10000 = [ 0x10000 ]; $h = 'h4'; } else { $x10000 = [ 0x1000 ]; $h = 'h3'; } while (@$x1 != 1 || $x1->[0] != 0) # _is_zero() { ($x1, $xr) = _div($c,$x1,$x10000); $es .= unpack($h,pack('V',$xr->[0])); } $es = reverse $es; $es =~ s/^[0]+//; # strip leading zeros '0x' . $es; # return result prepended with 0x } sub _as_bin { # convert a decimal number to bin (ref to array, return ref to string) my ($c,$x) = @_; # fits into one element (and Perl recent enough), handle also 0b0 case # handle zero case for older Perls if ($] <= 5.005 && @$x == 1 && $x->[0] == 0) { my $t = '0b0'; return $t; } if (@$x == 1 && $] >= 5.006) { my $t = sprintf("0b%b",$x->[0]); return $t; } my $x1 = _copy($c,$x); my $es = ''; my ($xr, $b, $x10000); if ($] >= 5.006) { $x10000 = [ 0x10000 ]; $b = 'b16'; } else { $x10000 = [ 0x1000 ]; $b = 'b12'; } while (!(@$x1 == 1 && $x1->[0] == 0)) # _is_zero() { ($x1, $xr) = _div($c,$x1,$x10000); $es .= unpack($b,pack('v',$xr->[0])); } $es = reverse $es; $es =~ s/^[0]+//; # strip leading zeros '0b' . $es; # return result prepended with 0b } sub _as_oct { # convert a decimal number to octal (ref to array, return ref to string) my ($c,$x) = @_; # fits into one element (handle also 0 case) return sprintf("0%o",$x->[0]) if @$x == 1; my $x1 = _copy($c,$x); my $es = ''; my $xr; my $x1000 = [ 0100000 ]; while (@$x1 != 1 || $x1->[0] != 0) # _is_zero() { ($x1, $xr) = _div($c,$x1,$x1000); $es .= reverse sprintf("%05o", $xr->[0]); } $es = reverse $es; $es =~ s/^0+//; # strip leading zeros '0' . $es; # return result prepended with 0 } sub _from_oct { # convert a octal number to decimal (string, return ref to array) my ($c,$os) = @_; # for older Perls, play safe my $m = [ 0100000 ]; my $d = 5; # 5 digits at a time my $mul = _one(); my $x = _zero(); my $len = int( (length($os)-1)/$d ); # $d digit parts, w/o the '0' my $val; my $i = -$d; while ($len >= 0) { $val = substr($os,$i,$d); # get oct digits $val = CORE::oct($val); $i -= $d; $len --; my $adder = [ $val ]; _add ($c, $x, _mul ($c, $adder, $mul ) ) if $val != 0; _mul ($c, $mul, $m ) if $len >= 0; # skip last mul } $x; } sub _from_hex { # convert a hex number to decimal (string, return ref to array) my ($c,$hs) = @_; my $m = _new($c, 0x10000000); # 28 bit at a time (<32 bit!) my $d = 7; # 7 digits at a time if ($] <= 5.006) { # for older Perls, play safe $m = [ 0x10000 ]; # 16 bit at a time (<32 bit!) $d = 4; # 4 digits at a time } my $mul = _one(); my $x = _zero(); my $len = int( (length($hs)-2)/$d ); # $d digit parts, w/o the '0x' my $val; my $i = -$d; while ($len >= 0) { $val = substr($hs,$i,$d); # get hex digits $val =~ s/^0x// if $len == 0; # for last part only because $val = CORE::hex($val); # hex does not like wrong chars $i -= $d; $len --; my $adder = [ $val ]; # if the resulting number was to big to fit into one element, create a # two-element version (bug found by Mark Lakata - Thanx!) if (CORE::length($val) > $BASE_LEN) { $adder = _new($c,$val); } _add ($c, $x, _mul ($c, $adder, $mul ) ) if $val != 0; _mul ($c, $mul, $m ) if $len >= 0; # skip last mul } $x; } sub _from_bin { # convert a hex number to decimal (string, return ref to array) my ($c,$bs) = @_; # instead of converting X (8) bit at a time, it is faster to "convert" the # number to hex, and then call _from_hex. my $hs = $bs; $hs =~ s/^[+-]?0b//; # remove sign and 0b my $l = length($hs); # bits $hs = '0' x (8-($l % 8)) . $hs if ($l % 8) != 0; # padd left side w/ 0 my $h = '0x' . unpack('H*', pack ('B*', $hs)); # repack as hex $c->_from_hex($h); } ############################################################################## # special modulus functions sub _modinv { # modular multiplicative inverse my ($c,$x,$y) = @_; # modulo zero if (_is_zero($c, $y)) { return (undef, undef); } # modulo one if (_is_one($c, $y)) { return (_zero($c), '+'); } my $u = _zero($c); my $v = _one($c); my $a = _copy($c,$y); my $b = _copy($c,$x); # Euclid's Algorithm for bgcd(), only that we calc bgcd() ($a) and the result # ($u) at the same time. See comments in BigInt for why this works. my $q; my $sign = 1; { ($a, $q, $b) = ($b, _div($c, $a, $b)); # step 1 last if _is_zero($c, $b); my $t = _add($c, # step 2: _mul($c, _copy($c, $v), $q) , # t = v * q $u ); # + u $u = $v; # u = v $v = $t; # v = t $sign = -$sign; redo; } # if the gcd is not 1, then return NaN return (undef, undef) unless _is_one($c, $a); ($v, $sign == 1 ? '+' : '-'); } sub _modpow { # modulus of power ($x ** $y) % $z my ($c,$num,$exp,$mod) = @_; # a^b (mod 1) = 0 for all a and b if (_is_one($c,$mod)) { @$num = 0; return $num; } # 0^a (mod m) = 0 if m != 0, a != 0 # 0^0 (mod m) = 1 if m != 0 if (_is_zero($c, $num)) { if (_is_zero($c, $exp)) { @$num = 1; } else { @$num = 0; } return $num; } # $num = _mod($c,$num,$mod); # this does not make it faster my $acc = _copy($c,$num); my $t = _one(); my $expbin = _as_bin($c,$exp); $expbin =~ s/^0b//; my $len = length($expbin); while (--$len >= 0) { if ( substr($expbin,$len,1) eq '1') # is_odd { _mul($c,$t,$acc); $t = _mod($c,$t,$mod); } _mul($c,$acc,$acc); $acc = _mod($c,$acc,$mod); } @$num = @$t; $num; } sub _gcd { # Greatest common divisor. my ($c, $x, $y) = @_; # gcd(0,0) = 0 # gcd(0,a) = a, if a != 0 if (@$x == 1 && $x->[0] == 0) { if (@$y == 1 && $y->[0] == 0) { @$x = 0; } else { @$x = @$y; } return $x; } # Until $y is zero ... until (@$y == 1 && $y->[0] == 0) { # Compute remainder. _mod($c, $x, $y); # Swap $x and $y. my $tmp = [ @$x ]; @$x = @$y; $y = $tmp; # no deref here; that would modify input $y } return $x; } ############################################################################## ############################################################################## 1; __END__ =pod =head1 NAME Math::BigInt::Calc - Pure Perl module to support Math::BigInt =head1 SYNOPSIS This library provides support for big integer calculations. It is not intended to be used by other modules. Other modules which support the same API (see below) can also be used to support Math::BigInt, like Math::BigInt::GMP and Math::BigInt::Pari. =head1 DESCRIPTION In this library, the numbers are represented in base B = 10**N, where N is the largest possible value that does not cause overflow in the intermediate computations. The base B elements are stored in an array, with the least significant element stored in array element zero. There are no leading zero elements, except a single zero element when the number is zero. For instance, if B = 10000, the number 1234567890 is represented internally as [3456, 7890, 12]. =head1 THE Math::BigInt API In order to allow for multiple big integer libraries, Math::BigInt was rewritten to use a plug-in library for core math routines. Any module which conforms to the API can be used by Math::BigInt by using this in your program: use Math::BigInt lib => 'libname'; 'libname' is either the long name, like 'Math::BigInt::Pari', or only the short version, like 'Pari'. =head2 General Notes A library only needs to deal with unsigned big integers. Testing of input parameter validity is done by the caller, so there is no need to worry about underflow (e.g., in C<_sub()> and C<_dec()>) nor about division by zero (e.g., in C<_div()>) or similar cases. For some methods, the first parameter can be modified. That includes the possibility that you return a reference to a completely different object instead. Although keeping the reference and just changing its contents is preferred over creating and returning a different reference. Return values are always objects, strings, Perl scalars, or true/false for comparison routines. =head2 API version 1 The following methods must be defined in order to support the use by Math::BigInt v1.70 or later. =head3 API version =over 4 =item I<api_version()> Return API version as a Perl scalar, 1 for Math::BigInt v1.70, 2 for Math::BigInt v1.83. =back =head3 Constructors =over 4 =item I<_new(STR)> Convert a string representing an unsigned decimal number to an object representing the same number. The input is normalize, i.e., it matches C<^(0|[1-9]\d*)$>. =item I<_zero()> Return an object representing the number zero. =item I<_one()> Return an object representing the number one. =item I<_two()> Return an object representing the number two. =item I<_ten()> Return an object representing the number ten. =item I<_from_bin(STR)> Return an object given a string representing a binary number. The input has a '0b' prefix and matches the regular expression C<^0[bB](0|1[01]*)$>. =item I<_from_oct(STR)> Return an object given a string representing an octal number. The input has a '0' prefix and matches the regular expression C<^0[1-7]*$>. =item I<_from_hex(STR)> Return an object given a string representing a hexadecimal number. The input has a '0x' prefix and matches the regular expression C<^0x(0|[1-9a-fA-F][\da-fA-F]*)$>. =back =head3 Mathematical functions Each of these methods may modify the first input argument, except I<_bgcd()>, which shall not modify any input argument, and I<_sub()> which may modify the second input argument. =over 4 =item I<_add(OBJ1, OBJ2)> Returns the result of adding OBJ2 to OBJ1. =item I<_mul(OBJ1, OBJ2)> Returns the result of multiplying OBJ2 and OBJ1. =item I<_div(OBJ1, OBJ2)> Returns the result of dividing OBJ1 by OBJ2 and truncating the result to an integer. =item I<_sub(OBJ1, OBJ2, FLAG)> =item I<_sub(OBJ1, OBJ2)> Returns the result of subtracting OBJ2 by OBJ1. If C<flag> is false or omitted, OBJ1 might be modified. If C<flag> is true, OBJ2 might be modified. =item I<_dec(OBJ)> Decrement OBJ by one. =item I<_inc(OBJ)> Increment OBJ by one. =item I<_mod(OBJ1, OBJ2)> Return OBJ1 modulo OBJ2, i.e., the remainder after dividing OBJ1 by OBJ2. =item I<_sqrt(OBJ)> Return the square root of the object, truncated to integer. =item I<_root(OBJ, N)> Return Nth root of the object, truncated to int. N is E<gt>= 3. =item I<_fac(OBJ)> Return factorial of object (1*2*3*4*...). =item I<_pow(OBJ1, OBJ2)> Return OBJ1 to the power of OBJ2. By convention, 0**0 = 1. =item I<_modinv(OBJ1, OBJ2)> Return modular multiplicative inverse, i.e., return OBJ3 so that (OBJ3 * OBJ1) % OBJ2 = 1 % OBJ2 The result is returned as two arguments. If the modular multiplicative inverse does not exist, both arguments are undefined. Otherwise, the arguments are a number (object) and its sign ("+" or "-"). The output value, with its sign, must either be a positive value in the range 1,2,...,OBJ2-1 or the same value subtracted OBJ2. For instance, if the input arguments are objects representing the numbers 7 and 5, the method must either return an object representing the number 3 and a "+" sign, since (3*7) % 5 = 1 % 5, or an object representing the number 2 and "-" sign, since (-2*7) % 5 = 1 % 5. =item I<_modpow(OBJ1, OBJ2, OBJ3)> Return modular exponentiation, (OBJ1 ** OBJ2) % OBJ3. =item I<_rsft(OBJ, N, B)> Shift object N digits right in base B and return the resulting object. This is equivalent to performing integer division by B**N and discarding the remainder, except that it might be much faster, depending on how the number is represented internally. For instance, if the object $obj represents the hexadecimal number 0xabcde, then C<_rsft($obj, 2, 16)> returns an object representing the number 0xabc. The "remainer", 0xde, is discarded and not returned. =item I<_lsft(OBJ, N, B)> Shift the object N digits left in base B. This is equivalent to multiplying by B**N, except that it might be much faster, depending on how the number is represented internally. =item I<_log_int(OBJ, B)> Return integer log of OBJ to base BASE. This method has two output arguments, the OBJECT and a STATUS. The STATUS is Perl scalar; it is 1 if OBJ is the exact result, 0 if the result was truncted to give OBJ, and undef if it is unknown whether OBJ is the exact result. =item I<_gcd(OBJ1, OBJ2)> Return the greatest common divisor of OBJ1 and OBJ2. =back =head3 Bitwise operators Each of these methods may modify the first input argument. =over 4 =item I<_and(OBJ1, OBJ2)> Return bitwise and. If necessary, the smallest number is padded with leading zeros. =item I<_or(OBJ1, OBJ2)> Return bitwise or. If necessary, the smallest number is padded with leading zeros. =item I<_xor(OBJ1, OBJ2)> Return bitwise exclusive or. If necessary, the smallest number is padded with leading zeros. =back =head3 Boolean operators =over 4 =item I<_is_zero(OBJ)> Returns a true value if OBJ is zero, and false value otherwise. =item I<_is_one(OBJ)> Returns a true value if OBJ is one, and false value otherwise. =item I<_is_two(OBJ)> Returns a true value if OBJ is two, and false value otherwise. =item I<_is_ten(OBJ)> Returns a true value if OBJ is ten, and false value otherwise. =item I<_is_even(OBJ)> Return a true value if OBJ is an even integer, and a false value otherwise. =item I<_is_odd(OBJ)> Return a true value if OBJ is an even integer, and a false value otherwise. =item I<_acmp(OBJ1, OBJ2)> Compare OBJ1 and OBJ2 and return -1, 0, or 1, if OBJ1 is less than, equal to, or larger than OBJ2, respectively. =back =head3 String conversion =over 4 =item I<_str(OBJ)> Return a string representing the object. The returned string should have no leading zeros, i.e., it should match C<^(0|[1-9]\d*)$>. =item I<_as_bin(OBJ)> Return the binary string representation of the number. The string must have a '0b' prefix. =item I<_as_oct(OBJ)> Return the octal string representation of the number. The string must have a '0x' prefix. Note: This method was required from Math::BigInt version 1.78, but the required API version number was not incremented, so there are older libraries that support API version 1, but do not support C<_as_oct()>. =item I<_as_hex(OBJ)> Return the hexadecimal string representation of the number. The string must have a '0x' prefix. =back =head3 Numeric conversion =over 4 =item I<_num(OBJ)> Given an object, return a Perl scalar number (int/float) representing this number. =back =head3 Miscellaneous =over 4 =item I<_copy(OBJ)> Return a true copy of the object. =item I<_len(OBJ)> Returns the number of the decimal digits in the number. The output is a Perl scalar. =item I<_zeros(OBJ)> Return the number of trailing decimal zeros. The output is a Perl scalar. =item I<_digit(OBJ, N)> Return the Nth digit as a Perl scalar. N is a Perl scalar, where zero refers to the rightmost (least significant) digit, and negative values count from the left (most significant digit). If $obj represents the number 123, then I<_digit($obj, 0)> is 3 and I<_digit(123, -1)> is 1. =item I<_check(OBJ)> Return a true value if the object is OK, and a false value otherwise. This is a check routine to test the internal state of the object for corruption. =back =head2 API version 2 The following methods are required for an API version of 2 or greater. =head3 Constructors =over 4 =item I<_1ex(N)> Return an object representing the number 10**N where N E<gt>= 0 is a Perl scalar. =back =head3 Mathematical functions =over 4 =item I<_nok(OBJ1, OBJ2)> Return the binomial coefficient OBJ1 over OBJ1. =back =head3 Miscellaneous =over 4 =item I<_alen(OBJ)> Return the approximate number of decimal digits of the object. The output is one Perl scalar. This estimate must be greater than or equal to what C<_len()> returns. =back =head2 API optional methods The following methods are optional, and can be defined if the underlying lib has a fast way to do them. If undefined, Math::BigInt will use pure Perl (hence slow) fallback routines to emulate these: =head3 Signed bitwise operators. Each of these methods may modify the first input argument. =over 4 =item I<_signed_or(OBJ1, OBJ2, SIGN1, SIGN2)> Return the signed bitwise or. =item I<_signed_and(OBJ1, OBJ2, SIGN1, SIGN2)> Return the signed bitwise and. =item I<_signed_xor(OBJ1, OBJ2, SIGN1, SIGN2)> Return the signed bitwise exclusive or. =back =head1 WRAP YOUR OWN If you want to port your own favourite c-lib for big numbers to the Math::BigInt interface, you can take any of the already existing modules as a rough guideline. You should really wrap up the latest BigInt and BigFloat testsuites with your module, and replace in them any of the following: use Math::BigInt; by this: use Math::BigInt lib => 'yourlib'; This way you ensure that your library really works 100% within Math::BigInt. =head1 BUGS Please report any bugs or feature requests to C<bug-math-bigint at rt.cpan.org>, or through the web interface at L<https://rt.cpan.org/Ticket/Create.html?Queue=Math-BigInt> (requires login). We will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Math::BigInt::Calc You can also look for information at: =over 4 =item * RT: CPAN's request tracker L<https://rt.cpan.org/Public/Dist/Display.html?Name=Math-BigInt> =item * AnnoCPAN: Annotated CPAN documentation L<http://annocpan.org/dist/Math-BigInt> =item * CPAN Ratings L<http://cpanratings.perl.org/dist/Math-BigInt> =item * Search CPAN L<http://search.cpan.org/dist/Math-BigInt/> =item * CPAN Testers Matrix L<http://matrix.cpantesters.org/?dist=Math-BigInt> =item * The Bignum mailing list =over 4 =item * Post to mailing list C<bignum at lists.scsys.co.uk> =item * View mailing list L<http://lists.scsys.co.uk/pipermail/bignum/> =item * Subscribe/Unsubscribe L<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/bignum> =back =back =head1 LICENSE This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHORS =over 4 =item * Original math code by Mark Biggar, rewritten by Tels L<http://bloodgate.com/> in late 2000. =item * Separated from BigInt and shaped API with the help of John Peacock. =item * Fixed, speed-up, streamlined and enhanced by Tels 2001 - 2007. =item * API documentation corrected and extended by Peter John Acklam, E<lt>pjacklam@online.noE<gt> =back =head1 SEE ALSO L<Math::BigInt>, L<Math::BigFloat>, L<Math::BigInt::GMP>, L<Math::BigInt::FastCalc> and L<Math::BigInt::Pari>. =cut
26.894352
91
0.504805
ed55b5651f13afd861244fbd657f59835623eaa3
3,383
pm
Perl
lib/Perlbal/Plugin/ForwardedFor.pm
git-the-cpan/Perlbal-Plugin-ForwardedFor
d22b931cb4a1f87a2e135a41cd5e4799bf6c9a37
[ "Artistic-1.0" ]
null
null
null
lib/Perlbal/Plugin/ForwardedFor.pm
git-the-cpan/Perlbal-Plugin-ForwardedFor
d22b931cb4a1f87a2e135a41cd5e4799bf6c9a37
[ "Artistic-1.0" ]
null
null
null
lib/Perlbal/Plugin/ForwardedFor.pm
git-the-cpan/Perlbal-Plugin-ForwardedFor
d22b931cb4a1f87a2e135a41cd5e4799bf6c9a37
[ "Artistic-1.0" ]
null
null
null
package Perlbal::Plugin::ForwardedFor; use strict; use warnings; use Perlbal; our $VERSION = '0.02'; my $target_header; sub load { Perlbal::register_global_hook( 'manage_command.forwarded_for', sub { my $mc = shift->parse(qr/^forwarded_for\s+=\s+(.+)\s*$/, "usage: FORWARDED_FOR = <new_name>"); ($target_header) = $mc->args; return $mc->ok; } ); return 1; } sub register { my ( $self, $svc ) = @_; $svc->register_hook( 'ForwardedFor', 'backend_client_assigned', sub { rewrite_header( @_, $target_header ) }, ); return 1; } sub rewrite_header { my ( $svc, $target_header ) = @_; my $headers = $svc->{'req_headers'}; my $header_name = 'X-Forwarded-For'; my $forwarded = $headers->header($header_name); my $DELIMITER = q{, }; my $EMPTY = q{}; my @ips = split /$DELIMITER/, $forwarded; my $ip = pop @ips; $headers->header( $target_header, $ip ); if (@ips) { $headers->header( $header_name, join $DELIMITER, @ips ); } else { # actually, i wish we could delete it $headers->header( $header_name, $EMPTY ); } return 0; } 1; __END__ =head1 NAME Perlbal::Plugin::ForwardedFor - Rename the X-Forwarded-For header in Perlbal =head1 VERSION Version 0.02 =head1 SYNOPSIS This plugin changes the header Perlbal will use to delcare itself as a proxy. Usually Perlbal will - perl RFC - add itself to X-Forwarded-For, but this plugins allows you to change that to any header you want, so you could differ Perlbal from other possible proxies the user might have. In your Perlbal configuration: LOAD ForwardedFor CREATE SERVICE http_balancer SET role = reverse_proxy SET pool = machines SET plugins = ForwardedFor FORWARDED_FOR = X-Perlbal-Forwarded-For =head1 SUBROUTINES/METHODS =head2 load Register a global hook and check for configuration problems. =head2 register Register a service hook to run a callback to rewrite the header. =head2 rewrite_header The function that is called as the callback. Rewrites the I<X-Forwarded-For> to whatever header name you specified in the configuration file. =head1 AUTHOR Sawyer X, C<< <xsawyerx at cpan.org> >> =head1 BUGS This plugin is on Github and you can file issues on: L<http://github.com/xsawyerx/perlbal-plugin-forwardedfor/issues> =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Perlbal::Plugin::ForwardedFor You can also look for information at: =over 4 =item * Github issue tracker: L<http://github.com/xsawyerx/perlbal-plugin-forwardedfor/issues> =item * Github page: L<http://github.com/xsawyerx/perlbal-plugin-forwardedfor> =item * AnnoCPAN: Annotated CPAN documentation L<http://annocpan.org/dist/Perlbal-Plugin-ForwardedFor> =item * CPAN Ratings L<http://cpanratings.perl.org/d/Perlbal-Plugin-ForwardedFor> =item * Search CPAN L<http://search.cpan.org/dist/Perlbal-Plugin-ForwardedFor/> =back =head1 LICENSE AND COPYRIGHT Copyright 2010 Sawyer X. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.
21.411392
77
0.689329
ed6a77b3c3c5629a6021a074f0f612ebcd8625af
79
t
Perl
t/00_compile.t
manish364824/LWP-Protocol-PSGI
f6d5440cabb4f0d7d5d05a2c35d9df66632bc6b1
[ "Artistic-1.0" ]
2
2016-04-05T18:37:21.000Z
2017-03-22T10:52:09.000Z
t/00_compile.t
manish364824/LWP-Protocol-PSGI
f6d5440cabb4f0d7d5d05a2c35d9df66632bc6b1
[ "Artistic-1.0" ]
3
2016-02-07T05:44:46.000Z
2019-10-25T13:54:56.000Z
t/00_compile.t
manish364824/LWP-Protocol-PSGI
f6d5440cabb4f0d7d5d05a2c35d9df66632bc6b1
[ "Artistic-1.0" ]
4
2016-09-29T16:34:59.000Z
2020-11-09T16:57:55.000Z
use strict; use Test::More tests => 1; BEGIN { use_ok 'LWP::Protocol::PSGI' }
15.8
38
0.658228
ed2cc66d202cf51f44127401b886515791493ec6
2,887
t
Perl
t/boilerplate.t
srvance/p4-objects
e682b2c55d36dc36ea51277180ec12eb5b68c4d7
[ "Artistic-1.0-Perl" ]
1
2019-10-16T09:20:26.000Z
2019-10-16T09:20:26.000Z
t/boilerplate.t
srvance/p4-objects
e682b2c55d36dc36ea51277180ec12eb5b68c4d7
[ "Artistic-1.0-Perl" ]
null
null
null
t/boilerplate.t
srvance/p4-objects
e682b2c55d36dc36ea51277180ec12eb5b68c4d7
[ "Artistic-1.0-Perl" ]
null
null
null
#!perl -T use strict; use warnings; use Test::More tests => 31; sub not_in_file_ok { my ($filename, %regex) = @_; open my $fh, "<", $filename or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } not_in_file_ok(README => "The README is used..." => qr/The README is used/, "'version information here'" => qr/to provide version information/, ); not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } module_boilerplate_ok('lib/P4/Objects.pm'); module_boilerplate_ok('lib/P4/Objects/BasicConnection.pm'); module_boilerplate_ok('lib/P4/Objects/Changelist.pm'); module_boilerplate_ok('lib/P4/Objects/ChangelistRevision.pm'); module_boilerplate_ok('lib/P4/Objects/Common/AccessUpdateForm.pm'); module_boilerplate_ok('lib/P4/Objects/Common/Base.pm'); module_boilerplate_ok('lib/P4/Objects/Common/BinaryOptions.pm'); module_boilerplate_ok('lib/P4/Objects/Common/Form.pm'); module_boilerplate_ok('lib/P4/Objects/Connection.pm'); module_boilerplate_ok('lib/P4/Objects/Exception.pm'); module_boilerplate_ok('lib/P4/Objects/FileType.pm'); module_boilerplate_ok('lib/P4/Objects/FstatResult.pm'); module_boilerplate_ok('lib/P4/Objects/IntegrationRecord.pm'); module_boilerplate_ok('lib/P4/Objects/Label.pm'); module_boilerplate_ok('lib/P4/Objects/OpenRevision.pm'); module_boilerplate_ok('lib/P4/Objects/PendingChangelist.pm'); module_boilerplate_ok('lib/P4/Objects/PendingResolve.pm'); module_boilerplate_ok('lib/P4/Objects/RawConnection.pm'); module_boilerplate_ok('lib/P4/Objects/Repository.pm'); module_boilerplate_ok('lib/P4/Objects/Revision.pm'); module_boilerplate_ok('lib/P4/Objects/Session.pm'); module_boilerplate_ok('lib/P4/Objects/SubmittedChangelist.pm'); module_boilerplate_ok('lib/P4/Objects/SyncResults.pm'); module_boilerplate_ok('lib/P4/Objects/Workspace.pm'); module_boilerplate_ok('lib/P4/Objects/WorkspaceRevision.pm'); module_boilerplate_ok('lib/P4/Objects/IntegrateResults.pm'); module_boilerplate_ok('lib/P4/Objects/IntegrateResult.pm'); module_boilerplate_ok('lib/P4/Objects/Extensions/MergeResolveData.pm'); module_boilerplate_ok('lib/P4/Objects/Extensions/MergeResolveTracker.pm');
37.493506
78
0.712504
73f2d8ae53e3e8e49f69cf34ac351857014e07e7
2,729
pm
Perl
auto-lib/Paws/Comprehend/BatchDetectEntities.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/Comprehend/BatchDetectEntities.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
auto-lib/Paws/Comprehend/BatchDetectEntities.pm
shogo82148/aws-sdk-perl
a87555a9d30dd1415235ebacd2715b2f7e5163c7
[ "Apache-2.0" ]
null
null
null
package Paws::Comprehend::BatchDetectEntities; use Moose; has LanguageCode => (is => 'ro', isa => 'Str', required => 1); has TextList => (is => 'ro', isa => 'ArrayRef[Str|Undef]', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'BatchDetectEntities'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::Comprehend::BatchDetectEntitiesResponse'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::Comprehend::BatchDetectEntities - Arguments for method BatchDetectEntities on L<Paws::Comprehend> =head1 DESCRIPTION This class represents the parameters used for calling the method BatchDetectEntities on the L<Amazon Comprehend|Paws::Comprehend> service. Use the attributes of this class as arguments to method BatchDetectEntities. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to BatchDetectEntities. =head1 SYNOPSIS my $comprehend = Paws->service('Comprehend'); my $BatchDetectEntitiesResponse = $comprehend->BatchDetectEntities( LanguageCode => 'en', TextList => [ 'MyString', ... # min: 1 ], ); # Results: my $ErrorList = $BatchDetectEntitiesResponse->ErrorList; my $ResultList = $BatchDetectEntitiesResponse->ResultList; # Returns a L<Paws::Comprehend::BatchDetectEntitiesResponse> object. Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. For the AWS API documentation, see L<https://docs.aws.amazon.com/goto/WebAPI/comprehend/BatchDetectEntities> =head1 ATTRIBUTES =head2 B<REQUIRED> LanguageCode => Str The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. All documents must be in the same language. Valid values are: C<"en">, C<"es">, C<"fr">, C<"de">, C<"it">, C<"pt">, C<"ar">, C<"hi">, C<"ja">, C<"ko">, C<"zh">, C<"zh-TW"> =head2 B<REQUIRED> TextList => ArrayRef[Str|Undef] A list containing the text of the input documents. The list can contain a maximum of 25 documents. Each document must contain fewer than 5,000 bytes of UTF-8 encoded characters. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method BatchDetectEntities in L<Paws::Comprehend> =head1 BUGS and CONTRIBUTIONS The source code is located here: L<https://github.com/pplu/aws-sdk-perl> Please report bugs to: L<https://github.com/pplu/aws-sdk-perl/issues> =cut
34.1125
249
0.717479
ed6ef6473eb03c9ff2dbadc7fa8287ab74586127
6,463
pm
Perl
cloud/aws/fsx/mode/datausage.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
cloud/aws/fsx/mode/datausage.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
cloud/aws/fsx/mode/datausage.pm
centreon-lab/centreon-plugins
68096c697a9e1baf89a712674a193d9a9321503c
[ "Apache-2.0" ]
null
null
null
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package cloud::aws::fsx::mode::datausage; use base qw(cloud::aws::custom::mode); use strict; use warnings; sub get_metrics_mapping { my ($self, %options) = @_; my $metrics_mapping = { extra_params => { message_multiple => 'All FSx metrics are ok' }, metrics => { DataReadBytes => { output => 'Data Read Bytes', label => 'data-read-bytes', nlabel => { absolute => 'fsx.data.read.bytes', per_second => 'fsx.data.read.bytespersecond' }, unit => 'B' }, DataWriteBytes => { output => 'Data Write Bytes', label => 'data-write-ops', nlabel => { absolute => 'fsx.data.write.bytes', per_second => 'fsx.data.write.bytespersecond' }, unit => 'B' }, DataReadOperations => { output => 'Data Read Ops', label => 'data-read-ops', nlabel => { absolute => 'fsx.data.io.read.count', per_second => 'fsx.data.io.read.persecond' }, unit => 'count' }, DataWriteOperations => { output => 'Data Write Ops', label => 'data-write-ops', nlabel => { absolute => 'fsx.data.io.write.count', per_second => 'fsx.data.io.write.persecond' }, unit => 'count' }, MetadataOperations => { output => 'MetaData Operations Bytes', label => 'metadata-ops-bytes', nlabel => { absolute => 'fsx.metadata.ops.bytes', per_second => 'fsx.metadata.ops.bytespersecond' }, unit => 'B' } } }; return $metrics_mapping; } sub long_output { my ($self, %options) = @_; return "FSx FileSystemId '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { 'name:s@' => { name => 'name' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --name option."); $self->{output}->option_exit(); } foreach my $instance (@{$self->{option_results}->{name}}) { if ($instance ne '') { push @{$self->{aws_instance}}, $instance; } } } sub manage_selection { my ($self, %options) = @_; my %metric_results; foreach my $instance (@{$self->{aws_instance}}) { $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( namespace => 'AWS/FSx', dimensions => [ { Name => "FileSystemId", Value => $instance } ], metrics => $self->{aws_metrics}, statistics => $self->{aws_statistics}, timeframe => $self->{aws_timeframe}, period => $self->{aws_period} ); foreach my $metric (@{$self->{aws_metrics}}) { foreach my $statistic (@{$self->{aws_statistics}}) { next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && !defined($self->{option_results}->{zeroed})); $self->{metrics}->{$instance}->{display} = $instance; $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; } } } if (scalar(keys %{$self->{metrics}}) <= 0) { $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); $self->{output}->option_exit(); } } 1; __END__ =head1 MODE Check FSx FileSystem Data consumption metrics. Example: perl centreon_plugins.pl --plugin=cloud::aws::fsx::plugin --custommode=awscli --mode=datausage --region='eu-west-1' --name='fs-1234abcd' --filter-metric='DataReadIOBytes' --statistic='sum' --warning-data-read-bytes='5' --verbose See 'https://docs.aws.amazon.com/efs/latest/ug/efs-metrics.html' for more information. =over 8 =item B<--name> Set the instance name (Required) (Can be multiple). =item B<--filter-metric> Filter on a specific metric Can be: DataReadBytes, DataWriteBytes, DataReadOperations, DataWriteOperations, MetaDataOperations =item B<--statistic> Set the metric calculation method (Only Sum is relevant). =item B<--warning-$metric$> Thresholds warning ($metric$ can be: 'data-write-ops', 'data-write-ops', 'data-read-ops', 'data-read-bytes', 'metadata-ops-bytes'). =item B<--critical-$metric$> Thresholds critical ($metric$ can be: 'data-write-ops', 'data-write-ops', 'data-read-ops', 'data-read-bytes', 'metadata-ops-bytes'). =back =cut
32.97449
139
0.551601
ed5136fbe6619ba6febefc971a376f7163f624aa
7,751
pm
Perl
apps/backup/tsm/local/mode/sessions.pm
nribault/centreon-plugins
e99276ba80ba202392791e78d72b00f1306d1a99
[ "Apache-2.0" ]
null
null
null
apps/backup/tsm/local/mode/sessions.pm
nribault/centreon-plugins
e99276ba80ba202392791e78d72b00f1306d1a99
[ "Apache-2.0" ]
null
null
null
apps/backup/tsm/local/mode/sessions.pm
nribault/centreon-plugins
e99276ba80ba202392791e78d72b00f1306d1a99
[ "Apache-2.0" ]
null
null
null
# # Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package apps::backup::tsm::local::mode::sessions; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::misc; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); sub custom_status_output { my ($self, %options) = @_; my $msg = sprintf("[client name: %s] [state: %s] [session type: %s] started since", $self->{result_values}->{client_name}, $self->{result_values}->{state}, $self->{result_values}->{session_type}, $self->{result_values}->{generation_time}); return $msg; } sub custom_status_calc { my ($self, %options) = @_; $self->{result_values}->{session_id} = $options{new_datas}->{$self->{instance} . '_session_id'}; $self->{result_values}->{client_name} = $options{new_datas}->{$self->{instance} . '_client_name'}; $self->{result_values}->{session_type} = $options{new_datas}->{$self->{instance} . '_session_type'}; $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; $self->{result_values}->{generation_time} = $options{new_datas}->{$self->{instance} . '_generation_time'}; return 0; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0 }, { name => 'sessions', type => 1, cb_prefix_output => 'prefix_sessions_output', message_multiple => 'All sessions are ok' }, ]; $self->{maps_counters}->{global} = [ { label => 'total', set => { key_values => [ { name => 'total' } ], output_template => 'Total Sessions : %s', perfdatas => [ { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, ]; $self->{maps_counters}->{sessions} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'session_id' }, { name => 'client_name' }, { name => 'session_type' }, { name => 'state' }, { name => 'since' }, { name => 'generation_time' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, } }, ]; } sub prefix_sessions_output { my ($self, %options) = @_; return "Session '" . $options{instance_value}->{session_id} . "' "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { "filter-clientname:s" => { name => 'filter_clientname' }, "filter-sessiontype:s" => { name => 'filter_sessiontype' }, "filter-state:s" => { name => 'filter_state' }, "warning-status:s" => { name => 'warning_status', default => '' }, "critical-status:s" => { name => 'critical_status', default => '' }, "timezone:s" => { name => 'timezone' }, }); centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', error_msg => "Cannot load module 'DateTime'."); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->change_macros(macros => ['warning_status', 'critical_status']); $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); } sub manage_selection { my ($self, %options) = @_; my $response = $options{custom}->execute_command( query => "SELECT session_id, client_name, start_time, state, session_type FROM sessions" ); $self->{sessions} = {}; $self->{global} = { total => 0 }; my $tz = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone}); while ($response =~ /^(.*?),(.*?),(.*?),(.*?),(.*?)$/mg) { my ($session_id, $client_name, $start_time, $state, $session_type) = ($1, $2, $3, $4, $5); $start_time =~ /^(\d+)-(\d+)-(\d+)\s+(\d+)[:\/](\d+)[:\/](\d+)/; my $dt = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6, %$tz); if (defined($self->{option_results}->{filter_clientname}) && $self->{option_results}->{filter_clientname} ne '' && $client_name !~ /$self->{option_results}->{filter_clientname}/) { $self->{output}->output_add(long_msg => "skipping '" . $client_name . "': no matching client name filter.", debug => 1); next; } if (defined($self->{option_results}->{filter_sessiontype}) && $self->{option_results}->{filter_sessiontype} ne '' && $session_type !~ /$self->{option_results}->{filter_sessiontype}/) { $self->{output}->output_add(long_msg => "skipping '" . $session_type . "': no matching session type filter.", debug => 1); next; } if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' && $state !~ /$self->{option_results}->{filter_state}/) { $self->{output}->output_add(long_msg => "skipping '" . $session_type . "': no matching state filter.", debug => 1); next; } my $diff_time = time() - $dt->epoch; $self->{global}->{total}++; $self->{sessions}->{$session_id} = { session_id => $session_id, client_name => $client_name, state => $state, session_type => $session_type, since => $diff_time, generation_time => centreon::plugins::misc::change_seconds(value => $diff_time) }; } } 1; __END__ =head1 MODE Check sessions. =over 8 =item B<--filter-clientname> Filter by client name. =item B<--filter-state> Filter by state. =item B<--filter-sessiontype> Filter by session type. =item B<--warning-status> Set warning threshold for status (Default: '') Can used special variables like: %{client_name}, %{state}, %{session_type}, %{since} =item B<--critical-status> Set critical threshold for status (Default: ''). Can used special variables like: %{client_name}, %{state}, %{session_type}, %{since} =item B<--warning-*> Set warning threshold. Can be : 'total'. =item B<--critical-*> Set critical threshold. Can be : 'total'. =item B<--timezone> Timezone of time options. Default is 'GMT'. =back =cut
36.734597
144
0.571281