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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ed0560f946f784d87d344b1f828851c2275ea512 | 3,448 | t | Perl | examples/builtin/TestHashMap.t | rewriting/tom | 2918e95c78006f08a2a0919ef440413fa5c2342a | [
"BSD-3-Clause"
]
| 36 | 2016-02-19T12:09:49.000Z | 2022-02-03T13:13:21.000Z | examples/builtin/TestHashMap.t | rewriting/tom | 2918e95c78006f08a2a0919ef440413fa5c2342a | [
"BSD-3-Clause"
]
| null | null | null | examples/builtin/TestHashMap.t | rewriting/tom | 2918e95c78006f08a2a0919ef440413fa5c2342a | [
"BSD-3-Clause"
]
| 6 | 2017-11-30T17:07:10.000Z | 2022-03-12T14:46:21.000Z | /*
* Copyright (c) 2006-2015, Universite de Lorraine, Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - Neither the name of the Inria nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* 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.
*/
package builtin;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestHashMap {
public final static void main(String[] args) {
org.junit.runner.JUnitCore.main(TestHashMap.class.getName());
}
%include { java/util/HashMap.tom }
/* we have to do this to match a string as an object */
%include { string.tom }
%op Object string(s:String) {
is_fsym(s) { ($s != null) && ( $s instanceof String ) }
make(s) { $s }
get_slot(s,o) { ((String) $o) }
}
@Test
public void testMake() {
java.util.HashMap map = `concHashMap(mapEntry("one","1"),
mapEntry("two","2"),
mapEntry("three","3"));
assertEquals(map.get("one"),"1");
assertEquals(map.get("two"),"2");
assertEquals(map.get("three"),"3");
}
@Test
public void testGetValue() {
java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
m.put("one","1");
m.put("two","2");
m.put("three","3");
/* finding a value by key */
%match(HashMap m) {
concHashMap(_*, mapEntry(string("two"),y), _*) -> {
assertEquals(`y,"2");;
}
}
}
@Test
public void testAddingRemoving() {
java.util.HashMap m = `concHashMap(mapEntry("one","1"),
mapEntry("two","2"));
java.util.HashMap m2 = `concHashMap(m*, mapEntry("hello","world"));
assertEquals(m2.get("one"),"1");
assertEquals(m2.get("two"),"2");
assertEquals(m2.get("hello"),"world");
java.util.HashMap m3 = null;
%match(HashMap m2) {
concHashMap(X*, mapEntry(_,string("world")), Y* ) -> {
m3 = `concHashMap(X*,Y*);
}
}
assertEquals(m3.get("one"),"1");
assertEquals(m3.get("two"),"2");
assertEquals(m3.get("hello"), null);
}
}
| 34.828283 | 80 | 0.649362 |
ed25ff24f94a1cc87f2ac978c610206db87ba6ec | 10,192 | pm | Perl | omd/versions/1.2.8p15.cre/lib/perl5/lib/perl5/Config/Tiny.pm | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
]
| null | null | null | omd/versions/1.2.8p15.cre/lib/perl5/lib/perl5/Config/Tiny.pm | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
]
| null | null | null | omd/versions/1.2.8p15.cre/lib/perl5/lib/perl5/Config/Tiny.pm | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
]
| null | null | null | package Config::Tiny;
# If you thought Config::Simple was small...
use strict;
our $VERSION = '2.20'; # Also change version # in t/02.main.t.
BEGIN {
require 5.008001;
$Config::Tiny::errstr = '';
}
# Create an empty object
sub new { bless {}, shift }
# Create an object from a file
sub read {
my $class = ref $_[0] ? ref shift : shift;
my $file = shift or return $class->_error('No file name provided');
# Slurp in the file.
my $encoding = shift;
$encoding = $encoding ? "<:$encoding" : '<';
local $/ = undef;
open( CFG, $encoding, $file ) or return $class->_error( "Failed to open file '$file' for reading: $!" );
my $contents = <CFG>;
close( CFG );
return $class -> _error("Reading from '$file' returned undef") if (! defined $contents);
return $class->read_string( $contents );
}
# Create an object from a string
sub read_string {
my $class = ref $_[0] ? ref shift : shift;
my $self = bless {}, $class;
return undef unless defined $_[0];
# Parse the file
my $ns = '_';
my $counter = 0;
foreach ( split /(?:\015{1,2}\012|\015|\012)/, shift ) {
$counter++;
# Skip comments and empty lines
next if /^\s*(?:\#|\;|$)/;
# Remove inline comments
s/\s\;\s.+$//g;
# Handle section headers
if ( /^\s*\[\s*(.+?)\s*\]\s*$/ ) {
# Create the sub-hash if it doesn't exist.
# Without this sections without keys will not
# appear at all in the completed struct.
$self->{$ns = $1} ||= {};
next;
}
# Handle properties
if ( /^\s*([^=]+?)\s*=\s*(.*?)\s*$/ ) {
$self->{$ns}->{$1} = $2;
next;
}
return $self->_error( "Syntax error at line $counter: '$_'" );
}
$self;
}
# Save an object to a file
sub write {
my $self = shift;
my $file = shift or return $self->_error('No file name provided');
my $encoding = shift;
$encoding = $encoding ? ">:$encoding" : '>';
# Write it to the file
my $string = $self->write_string;
return undef unless defined $string;
open( CFG, $encoding, $file ) or return $self->_error(
"Failed to open file '$file' for writing: $!"
);
print CFG $string;
close CFG;
return 1;
}
# Save an object to a string
sub write_string {
my $self = shift;
my $contents = '';
foreach my $section ( sort { (($b eq '_') <=> ($a eq '_')) || ($a cmp $b) } keys %$self ) {
# Check for several known-bad situations with the section
# 1. Leading whitespace
# 2. Trailing whitespace
# 3. Newlines in section name
return $self->_error(
"Illegal whitespace in section name '$section'"
) if $section =~ /(?:^\s|\n|\s$)/s;
my $block = $self->{$section};
$contents .= "\n" if length $contents;
$contents .= "[$section]\n" unless $section eq '_';
foreach my $property ( sort keys %$block ) {
return $self->_error(
"Illegal newlines in property '$section.$property'"
) if $block->{$property} =~ /(?:\012|\015)/s;
$contents .= "$property=$block->{$property}\n";
}
}
$contents;
}
# Error handling
sub errstr { $Config::Tiny::errstr }
sub _error { $Config::Tiny::errstr = $_[1]; undef }
1;
__END__
=pod
=head1 NAME
Config::Tiny - Read/Write .ini style files with as little code as possible
=head1 SYNOPSIS
# In your configuration file
rootproperty=blah
[section]
one=twp
three= four
Foo =Bar
empty=
# In your program
use Config::Tiny;
# Create a config
my $Config = Config::Tiny->new;
# Open the config
$Config = Config::Tiny->read( 'file.conf' );
$Config = Config::Tiny->read( 'file.conf', 'utf8' ); # Neither ':' nor '<:' prefix!
$Config = Config::Tiny->read( 'file.conf', 'encoding(iso-8859-1)');
# Reading properties
my $rootproperty = $Config->{_}->{rootproperty};
my $one = $Config->{section}->{one};
my $Foo = $Config->{section}->{Foo};
# Changing data
$Config->{newsection} = { this => 'that' }; # Add a section
$Config->{section}->{Foo} = 'Not Bar!'; # Change a value
delete $Config->{_}; # Delete a value or section
# Save a config
$Config->write( 'file.conf' );
$Config->write( 'file.conf', 'utf8' ); # Neither ':' nor '>:' prefix!
# Shortcuts
my($rootproperty) = $$Config{_}{rootproperty};
my($config) = Config::Tiny -> read_string('alpha=bet');
my($value) = $$config{_}{alpha}; # $value is 'bet'.
my($config) = Config::Tiny -> read_string("[init]\nalpha=bet");
my($value) = $$config{init}{alpha}; # $value is 'bet'.
=head1 DESCRIPTION
C<Config::Tiny> is a Perl class to read and write .ini style configuration
files with as little code as possible, reducing load time and memory
overhead.
Most of the time it is accepted that Perl applications use a lot
of memory and modules.
The C<*::Tiny> family of modules is specifically intended to provide an ultralight alternative to the
standard modules.
This module is primarily for reading human written files, and anything we write shouldn't need to have
documentation/comments. If you need something with more power move up to L<Config::Simple>, L<Config::General>
or one of the many other C<Config::*> modules.
Lastly, L<Config::Tiny> does B<not> preserve your comments, whitespace, or the order of your config file.
See L<Config::Tiny::Ordered> (and possibly others) for the preservation of the order of the entries in the file.
=head1 CONFIGURATION FILE SYNTAX
Files are the same format as for MS Windows C<*.ini> files. For example:
[section]
var1=value1
var2=value2
If a property is outside of a section at the beginning of a file, it will
be assigned to the C<"root section">, available at C<$Config-E<gt>{_}>.
Lines starting with C<'#'> or C<';'> are considered comments and ignored,
as are blank lines.
When writing back to the config file, all comments, custom whitespace,
and the ordering of your config file elements is discarded. If you need
to keep the human elements of a config when writing back, upgrade to
something better, this module is not for you.
=head1 METHODS
=head2 errstr()
Returns a string representing the most recent error, or the empty string.
You can also retrieve the error message from the C<$Config::Tiny::errstr> variable.
=head2 new()
The constructor C<new> creates and returns an empty C<Config::Tiny> object.
=head2 read($filename, [$encoding])
Here, the [] indicate an optional parameter.
The C<read> constructor reads a config file, $filename, and returns a new
C<Config::Tiny> object containing the properties in the file.
$encoding may be used to indicate the encoding of the file, e.g. 'utf8' or 'encoding(iso-8859-1)'.
Do not add a prefix to $encoding, such as '<' or '<:'.
Returns the object on success, or C<undef> on error.
When C<read> fails, C<Config::Tiny> sets an error message internally
you can recover via C<Config::Tiny-E<gt>errstr>. Although in B<some>
cases a failed C<read> will also set the operating system error
variable C<$!>, not all errors do and you should not rely on using
the C<$!> variable.
See t/04.utf8.t and t/04.utf8.txt.
=head2 read_string($string)
The C<read_string> method takes as argument the contents of a config file
as a string and returns the C<Config::Tiny> object for it.
=head2 write($filename, [$encoding])
Here, the [] indicate an optional parameter.
The C<write> method generates the file content for the properties, and
writes it to disk to the filename specified.
$encoding may be used to indicate the encoding of the file, e.g. 'utf8' or 'encoding(iso-8859-1)'.
Do not add a prefix to $encoding, such as '>' or '>:'.
Returns true on success or C<undef> on error.
See t/04.utf8.t and t/04.utf8.txt.
=head2 write_string()
Generates the file content for the object and returns it as a string.
=head1 FAQ
=head2 Why can't I put comments at the ends of lines?
Because a line like:
key=value # A comment
Sets key to 'value # A comment' :-(.
This conforms to the syntax discussed in L</CONFIGURATION FILE SYNTAX>.
=head2 Why can't I omit the '=' signs?
E.g.:
[Things]
my =
list =
of =
things =
Instead of:
[Things]
my
list
of
things
Because the use of '=' signs is a type of mandatory documentation. It indicates that that section contains 4 items,
and not 1 odd item split over 4 lines.
=head2 Why do I have to assign the result of a method call to a variable?
This question comes from RT#85386.
Yes, the syntax may seem odd, but you don't have to call both new() and read_string().
Try:
perl -MData::Dumper -MConfig::Tiny -E 'my $c=Config::Tiny->read_string("one=s"); say Dumper $c'
Or:
my($config) = Config::Tiny -> read_string('alpha=bet');
my($value) = $$config{_}{alpha}; # $value is 'bet'.
Or even, a bit ridiculously:
my($value) = ${Config::Tiny -> read_string('alpha=bet')}{_}{alpha}; # $value is 'bet'.
=head1 CAVEATS
=head2 Unsupported Section Headers
Some edge cases in section headers are not supported, and additionally may not
be detected when writing the config file.
Specifically, section headers with leading whitespace, trailing whitespace,
or newlines anywhere in the section header, will not be written correctly
to the file and may cause file corruption.
=head2 Setting an option more than once
C<Config::Tiny> will only recognize the first time an option is set in a
config file. Any further attempts to set the same option later in the config
file are ignored.
=head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-Tiny>
For other issues, or commercial enhancement or support, contact the author.
=head1 AUTHOR
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
Maintanence from V 2.15: Ron Savage L<http://savage.net.au/>.
=head1 ACKNOWLEGEMENTS
Thanks to Sherzod Ruzmetov E<lt>sherzodr@cpan.orgE<gt> for
L<Config::Simple>, which inspired this module by being not quite
"simple" enough for me :).
=head1 SEE ALSO
See, amongst many: L<Config::Simple> and L<Config::General>.
See L<Config::Tiny::Ordered> (and possibly others) for the preservation of the order of the entries in the file.
=head1 COPYRIGHT
Copyright 2002 - 2011 Adam Kennedy.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
| 26.750656 | 115 | 0.684164 |
ed4a35909816cbbdd201cc179014ff247a6857a4 | 1,832 | pm | Perl | auto-lib/Paws/SSM/MaintenanceWindowIdentity.pm | agimenez/aws-sdk-perl | 9c4dff7d1af2ff0210c28ca44fb9e92bc625712b | [
"Apache-2.0"
]
| null | null | null | auto-lib/Paws/SSM/MaintenanceWindowIdentity.pm | agimenez/aws-sdk-perl | 9c4dff7d1af2ff0210c28ca44fb9e92bc625712b | [
"Apache-2.0"
]
| null | null | null | auto-lib/Paws/SSM/MaintenanceWindowIdentity.pm | agimenez/aws-sdk-perl | 9c4dff7d1af2ff0210c28ca44fb9e92bc625712b | [
"Apache-2.0"
]
| null | null | null | package Paws::SSM::MaintenanceWindowIdentity;
use Moose;
has Cutoff => (is => 'ro', isa => 'Int');
has Duration => (is => 'ro', isa => 'Int');
has Enabled => (is => 'ro', isa => 'Bool');
has Name => (is => 'ro', isa => 'Str');
has WindowId => (is => 'ro', isa => 'Str');
1;
### main pod documentation begin ###
=head1 NAME
Paws::SSM::MaintenanceWindowIdentity
=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::SSM::MaintenanceWindowIdentity object:
$service_obj->Method(Att1 => { Cutoff => $value, ..., WindowId => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::SSM::MaintenanceWindowIdentity object:
$result = $service_obj->Method(...);
$result->Att1->Cutoff
=head1 DESCRIPTION
Information about the Maintenance Window.
=head1 ATTRIBUTES
=head2 Cutoff => Int
The number of hours before the end of the Maintenance Window that
Systems Manager stops scheduling new tasks for execution.
=head2 Duration => Int
The duration of the Maintenance Window in hours.
=head2 Enabled => Bool
Whether the Maintenance Window is enabled.
=head2 Name => Str
The name of the Maintenance Window.
=head2 WindowId => Str
The ID of the Maintenance Window.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::SSM>
=head1 BUGS and CONTRIBUTIONS
The source code is located here: https://github.com/pplu/aws-sdk-perl
Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues
=cut
| 22.341463 | 107 | 0.709607 |
ed4eea514737e6a03906e5032331716eefa543c8 | 1,962 | pm | Perl | lib/WWW/CPANTS/Bin/Task/PostProcess/UpdateRanking.pm | haukex/www-cpants | eae6618924b057f504cb9e93aa69384d0c5705ab | [
"Artistic-1.0"
]
| 13 | 2015-05-06T19:10:54.000Z | 2021-11-14T19:50:10.000Z | lib/WWW/CPANTS/Bin/Task/PostProcess/UpdateRanking.pm | haukex/www-cpants | eae6618924b057f504cb9e93aa69384d0c5705ab | [
"Artistic-1.0"
]
| 74 | 2015-01-16T01:38:36.000Z | 2021-01-25T09:27:48.000Z | lib/WWW/CPANTS/Bin/Task/PostProcess/UpdateRanking.pm | haukex/www-cpants | eae6618924b057f504cb9e93aa69384d0c5705ab | [
"Artistic-1.0"
]
| 8 | 2015-03-10T11:43:50.000Z | 2020-04-10T06:27:39.000Z | package WWW::CPANTS::Bin::Task::PostProcess::UpdateRanking;
use Mojo::Base 'WWW::CPANTS::Bin::Task', -signatures;
our @READ = qw/Authors Kwalitee/;
our @WRITE = qw/Authors/;
sub run ($self, @args) {
my $db = $self->db;
my $authors = $db->table('Authors');
my @methods = qw(
select_all_pause_ids_with_many_cpan_dists
select_all_pause_ids_with_few_cpan_dists
);
for my $method (@methods) {
$self->_update_ranking($authors->$method);
}
}
sub _update_ranking ($self, $pause_ids) {
my $authors = $self->db->table('Authors');
my $averages = $self->_calc_averages($pause_ids);
my ($rank, $ct, $current) = (0, 0, undef);
for my $row (@$averages) {
my ($pause_id, $core_average, $average) = @$row;
$ct++;
if (!defined $current or $current > $core_average) {
$rank = $ct;
$current = $core_average;
}
$authors->update_ranking($pause_id, $rank, $core_average, $average);
}
}
sub _calc_averages ($self, $pause_ids) {
my $kwalitee = $self->db->table('Kwalitee');
# TODO: benchmark this against the one-query version
my @averages;
for my $pause_id (@$pause_ids) {
my ($kwalitee_sum, $core_kwalitee_sum, $total) = (0, 0, 0);
my $rows = $kwalitee->select_all_scores_for_author($pause_id);
for my $row (@{ $rows // [] }) {
next if !$row->{kwalitee} && !$row->{core_kwalitee};
$kwalitee_sum += $row->{kwalitee};
$core_kwalitee_sum += $row->{core_kwalitee};
$total++;
}
my $average = $total ? $kwalitee_sum / $total : 0;
my $core_average = $total ? $core_kwalitee_sum / $total : 0;
push @averages, [
$pause_id,
sprintf("%.2f", $core_average),
sprintf("%.2f", $average),
];
}
[sort { $b->[1] <=> $a->[1] or $a->[0] cmp $b->[0] } @averages];
}
1;
| 31.645161 | 76 | 0.550459 |
73e8c3eec96eabe14cbf6ff124011005d3de3121 | 5,874 | t | Perl | openresty-win32-build/thirdparty/perl5-5.29.6/cpan/CPAN-Meta/t/merge.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
]
| 2 | 2018-06-15T08:32:44.000Z | 2019-01-12T03:20:41.000Z | openresty-win32-build/thirdparty/perl5-5.29.6/cpan/CPAN-Meta/t/merge.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
]
| null | null | null | openresty-win32-build/thirdparty/perl5-5.29.6/cpan/CPAN-Meta/t/merge.t | nneesshh/openresty-win32-build | bfbb9d7526020eda1788a0ed24f2be3c8be5c1c3 | [
"MIT"
]
| null | null | null | use strict;
use warnings;
use Test::More;
use CPAN::Meta;
use CPAN::Meta::Merge;
delete $ENV{PERL_YAML_BACKEND};
delete $ENV{PERL_JSON_BACKEND};
delete $ENV{CPAN_META_JSON_BACKEND};
delete $ENV{CPAN_META_JSON_DECODER};
my %base = (
abstract => 'This is a test',
author => ['A.U. Thor'],
generated_by => 'Myself',
license => [ 'perl_5' ],
resources => {
license => [ 'http://dev.perl.org/licenses/' ],
bugtracker => { web => 'https://rt.cpan.org/Dist/Display.html?Foo-Bar' },
},
prereqs => {
runtime => {
requires => {
Foo => '0',
},
},
},
dynamic_config => 0,
provides => {
Baz => {
file => 'lib/Baz.pm',
},
},
'meta-spec' => {
url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
version => 2,
},
);
my %first = (
author => [ 'I.M. Poster' ],
generated_by => 'Some other guy',
license => [ 'bsd' ],
resources => {
license => [ 'http://opensource.org/licenses/bsd-license.php' ],
},
prereqs => {
runtime => {
requires => {
Foo => '< 1',
},
recommends => {
Bar => '3.14',
},
},
test => {
requires => {
'Test::Bar' => 0,
},
},
},
dynamic_config => 1,
provides => {
Quz => {
file => 'lib/Quz.pm',
},
},
);
my %first_expected = (
abstract => 'This is a test',
author => [ 'A.U. Thor', 'I.M. Poster' ],
generated_by => 'Myself, Some other guy',
license => [ 'perl_5', 'bsd' ],
resources => {
license => [ 'http://dev.perl.org/licenses/', 'http://opensource.org/licenses/bsd-license.php' ],
bugtracker => { web => 'https://rt.cpan.org/Dist/Display.html?Foo-Bar' },
},
prereqs => {
runtime => {
requires => {
Foo => '>= 0, < 1',
},
recommends => {
Bar => '3.14',
},
},
test => {
requires => {
'Test::Bar' => 0,
},
},
},
provides => {
Baz => {
file => 'lib/Baz.pm',
},
Quz => {
file => 'lib/Quz.pm',
},
},
dynamic_config => 1,
'meta-spec' => {
url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
version => 2,
},
);
my %provides_merge_expected = (
abstract => 'This is a test',
author => ['A.U. Thor'],
generated_by => 'Myself',
license => [ 'perl_5' ],
resources => {
license => [ 'http://dev.perl.org/licenses/' ],
bugtracker => { web => 'https://rt.cpan.org/Dist/Display.html?Foo-Bar' },
},
prereqs => {
runtime => {
requires => {
Foo => '0',
},
},
},
dynamic_config => 0,
provides => {
Baz => {
file => 'lib/Baz.pm',
version => '0.001', # same as %base, but for this extra key
},
},
'meta-spec' => {
url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
version => 2,
},
);
my $merger = CPAN::Meta::Merge->new(default_version => '2');
my $first_result = $merger->merge(\%base, \%first);
is_deeply($first_result, \%first_expected, 'First result is as expected');
is_deeply($merger->merge(\%base, { abstract => 'This is a test' }), \%base, 'Can merge in identical abstract');
is(
eval { $merger->merge(\%base, { abstract => 'And now for something else' }) },
undef,
'Trying to merge different abstract gives an exception',
);
like $@, qr/^Can't merge attribute abstract/, 'Exception looks right';
is(
eval { $merger->merge(\%base, { resources => { bugtracker => { web => 'http://foo.com' } } } ) },
undef,
'Trying to merge a different bugtracker URL gives an exception',
);
like $@, qr/^Duplication of element resources\.bugtracker\.web /, 'Exception looks right';
is(
eval { $merger->merge(\%base, { provides => { Baz => { file => 'Baz.pm' } } }) },
undef,
'Trying to merge different provides.$module.file gives an exception',
);
like $@, qr/^Duplication of element provides\.Baz\.file /, 'Exception looks right';
my $provides_result = $merger->merge(\%base, { provides => { Baz => { file => 'lib/Baz.pm', version => '0.001' } } });
is_deeply(
$provides_result,
\%provides_merge_expected,
'Trying to merge a new key for provides.$module is permitted; identical values are preserved',
);
my $extra_merger = CPAN::Meta::Merge->new(
default_version => '2',
extra_mappings => {
'x_toolkit' => 'set_addition',
'x_meta_meta' => {
name => 'identical',
tags => 'set_addition',
}
}
);
my $extra_results = $extra_merger->merge(\%base, {
x_toolkit => [ 'marble' ],
x_meta_meta => {
name => 'Test',
tags => [ 'Testing' ],
}
},
{ x_toolkit => [ 'trike'],
x_meta_meta => {
name => 'Test',
tags => [ 'TDD' ],
}
}
);
my $expected_nested_extra = {
name => 'Test',
tags => [ 'Testing', 'TDD' ],
};
is_deeply($extra_results->{x_toolkit}, [ 'marble', 'trike' ], 'Extra mapping fields are merged');
is_deeply($extra_results->{x_meta_meta}, $expected_nested_extra, 'Nested extra mapping fields are merged' );
my $adds_to = sub {
my ($left, $right, $path) = @_;
if ($right !~ /^\Q$left\E/) {
die sprintf "Can't merge attribute %s: '%s' does not start with '%s'", join('.', @{$path}), $right, $left;
}
return $right;
};
$extra_merger = CPAN::Meta::Merge->new(default_version => '2', extra_mappings => { 'abstract' => \&$adds_to } );
my $extra_results2 = $extra_merger->merge({ abstract => 'This is a test.'}, { abstract => 'This is a test. Includes more detail..' } );
is($extra_results2->{abstract}, 'This is a test. Includes more detail..', 'Extra mapping fields overwrite existing mappings');
my $extra_failure = eval { $extra_merger->merge({ abstract => 'This is a test.'}, { abstract => 'This is a better test.' } ) };
is($extra_failure, undef, 'Extra mapping produces a failure');
like $@, qr/does not start with/, 'Exception looks right';
# issue 67
@base{qw/name version release_status/} = qw/Foo-Bar 0.01 testing/;
my $base_obj = CPAN::Meta->create(\%base);
ok my $first_result_obj = $merger->merge($base_obj, \%first), 'merging CPAN::Meta objects succeeds';
done_testing();
# vim: ts=4 sts=4 sw=4 tw=78 noet :
| 25.650655 | 136 | 0.586313 |
ed00d16aff216b38749cd23055f5a654ba4ca5b3 | 941 | t | Perl | S03-operators/brainos.t | SirBogman/roast | 0a0835a20951c93fea57a39dec1b2b8789d81fc5 | [
"Artistic-2.0"
]
| 1 | 2019-11-06T05:07:10.000Z | 2019-11-06T05:07:10.000Z | S03-operators/brainos.t | SirBogman/roast | 0a0835a20951c93fea57a39dec1b2b8789d81fc5 | [
"Artistic-2.0"
]
| null | null | null | S03-operators/brainos.t | SirBogman/roast | 0a0835a20951c93fea57a39dec1b2b8789d81fc5 | [
"Artistic-2.0"
]
| null | null | null | use v6;
use Test;
plan 9;
=begin pod
Raku has an explicitly declared C<=~> which should die at compile time
and is intended to catch user "brainos"; it recommends C<~~> to the user
instead. Similar for C<!~>.
=end pod
#L<S03/Chaining binary precedence/"To catch">
my $str = 'foo';
try { EVAL '$str =~ m/bar/;' };
ok $! ~~ Exception, 'caught "=~" braino';
ok "$!" ~~ /'~~'/, 'error for "=~" usage mentions "~~"';
try { EVAL '$str !~ m/bar/;' };
ok $! ~~ Exception, 'caught "!~" braino';
ok "$!" ~~ /'!~~'/, 'error for "!~" usage mentions "!~~"';
# RT #76878
{
my $x = 2;
is EVAL('"$x =~ b"'), '2 =~ b', '=~ allowed in double quotes';
is EVAL('"$x !~ b"'), '2 !~ b', '!~ allowed in double quotes';
is EVAL('"$x << b"'), '2 << b', '<< allowed in double quotes';
is EVAL('"$x >> b"'), '2 >> b', '>> allowed in double quotes';
is EVAL('"$x . b"'), '2 . b', '. allowed in double quotes';
}
# vim: ft=perl6
| 25.432432 | 72 | 0.527099 |
ed391ecca810e232202d5d303da85ace148af69c | 1,620 | pm | Perl | auto-lib/Paws/S3/SourceSelectionCriteria.pm | meis/aws-sdk-perl | 6d61ffcf351e446f06d7e84e53caa08d98573959 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Paws/S3/SourceSelectionCriteria.pm | meis/aws-sdk-perl | 6d61ffcf351e446f06d7e84e53caa08d98573959 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Paws/S3/SourceSelectionCriteria.pm | meis/aws-sdk-perl | 6d61ffcf351e446f06d7e84e53caa08d98573959 | [
"Apache-2.0"
]
| null | null | null | package Paws::S3::SourceSelectionCriteria;
use Moose;
has SseKmsEncryptedObjects => (is => 'ro', isa => 'Paws::S3::SseKmsEncryptedObjects');
1;
### main pod documentation begin ###
=head1 NAME
Paws::S3::SourceSelectionCriteria
=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::S3::SourceSelectionCriteria object:
$service_obj->Method(Att1 => { SseKmsEncryptedObjects => $value, ..., SseKmsEncryptedObjects => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::S3::SourceSelectionCriteria object:
$result = $service_obj->Method(...);
$result->Att1->SseKmsEncryptedObjects
=head1 DESCRIPTION
A container for filters that define which source objects should be
replicated.
=head1 ATTRIBUTES
=head2 SseKmsEncryptedObjects => L<Paws::S3::SseKmsEncryptedObjects>
A container for filter information for the selection of S3 objects
encrypted with AWS KMS. If you include C<SourceSelectionCriteria> in
the replication configuration, this element is required.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::S3>
=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
| 27 | 109 | 0.761728 |
ed3814cdbc6576727cd0e500448b39d97411677f | 38,546 | t | Perl | t/01-tree.t | raydiak/perl6-Pod-To-HTMLBody | b0bfff8cd53e8b81ebdb62cc5b7629e727054276 | [
"ClArtistic"
]
| 1 | 2018-03-06T06:32:50.000Z | 2018-03-06T06:32:50.000Z | t/01-tree.t | raydiak/perl6-Pod-To-HTMLBody | b0bfff8cd53e8b81ebdb62cc5b7629e727054276 | [
"ClArtistic"
]
| null | null | null | t/01-tree.t | raydiak/perl6-Pod-To-HTMLBody | b0bfff8cd53e8b81ebdb62cc5b7629e727054276 | [
"ClArtistic"
]
| 2 | 2020-06-07T18:10:14.000Z | 2021-07-21T08:32:10.000Z | use v6;
use Pod::To::Tree;
use Pod::To::HTMLBody;
use Test;
subtest 'tree manipulation', {
my $item = Node::Item.new;
my $new-list = Node::List.new;
$new-list.add-below( $item );
subtest 'links from new-list', {
nok $new-list.parent;
nok $new-list.previous-sibling;
nok $new-list.next-sibling;
is $new-list.first-child, $item;
};
subtest 'links from item', {
is $item.parent, $new-list;
nok $item.previous-sibling;
nok $item.next-sibling;
nok $item.first-child;
};
my $new-item = Node::Item.new;
$item.replace-with( $new-item );
subtest 'new-list after replacing item', {
nok $new-list.parent;
nok $new-list.previous-sibling;
nok $new-list.next-sibling;
is $new-list.first-child, $new-item;
};
subtest 'new-item after being emplaced', {
is $new-item.parent, $new-list;
nok $new-item.previous-sibling;
nok $new-item.next-sibling;
nok $new-item.first-child;
};
my $item2 = Node::Item.new;
$new-list.add-below( $item2 );
subtest 'new-list after adding $item2', {
nok $new-list.parent;
nok $new-list.previous-sibling;
nok $new-list.next-sibling;
is $new-list.first-child, $new-item;
};
# Root <-
# | | \
# V V /
# List - <-
# | | \
# V V /
# Item
# | |
# V V
# X X
my $the-root = Node::Document.new;
my $the-item = Node::Item.new;
my $the-list = Node::List.new;
$the-root.add-below( $the-list );
$the-list.add-below( $the-item );
subtest 'root', {
nok $the-root.parent;
nok $the-root.previous-sibling;
nok $the-root.next-sibling;
is $the-root.first-child, $the-list;
};
subtest 'list', {
is $the-list.parent, $the-root;
nok $the-list.previous-sibling;
nok $the-list.next-sibling;
is $the-list.first-child, $the-item;
};
subtest 'item', {
is $the-item.parent, $the-list;
nok $the-item.previous-sibling;
nok $the-item.next-sibling;
nok $the-item.first-child;
};
};
my $pod-counter = 0;
my $root;
my $r;
subtest 'paragraphs', {
=begin pod
Lorem ipsum
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>' 'Lorem ipsum' '</p>'
'</div>'
/, 'simple paragraph';
=begin pod
someone accidentally left a space
between these two paragraphs
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<p>' 'someone accidentally left a space' '</p>'
'<p>' 'between these two paragraphs' '</p>'
/, 'paragraph break';
=for foo
some text
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'some text' '</p>'
'</section>'
/, 'paragraph with body';
=for foo
some
spaced text
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'some spaced text' '</p>'
'</section>'
/, 'spacing';
};
subtest 'section', {
=begin foo
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'</section>'
/, 'section';
=begin foo
Some content
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'Some content' '</p>'
'</section>'
/, 'section wih content';
=begin foo
Some content
over two lines
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'Some content over two lines' '</p>'
'</section>'
/, 'section wih content over two lines';
=begin foo
paragraph one
paragraph
two
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'paragraph one' '</p>'
'<p>' 'paragraph two' '</p>'
'</section>'
/, 'two paragraphs';
=begin something
=begin somethingelse
toot tooot!
=end somethingelse
=end something
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<section>'
'<h1>' 'something' '</h1>'
'<section>'
'<h1>' 'somethingelse' '</h1>'
'<p>' 'toot tooot!' '</p>'
'</section>'
'</section>'
/, 'nested section';
=begin foo
and so, all of the villages chased
Albi, The Racist Dragon, into the
very cold and very scary cave
and it was so cold and so scary in
there, that Albi began to cry
=begin bar
Dragon Tears!
=end bar
Which, as we all know...
=begin bar
Turn into Jelly Beans!
=end bar
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
'<section>'
'<h1>' 'bar' '</h1>'
'<p>' 'Dragon Tears!' '</p>'
'</section>'
'<p>' 'Which, as we all know...' '</p>'
'<section>'
'<h1>' 'bar' '</h1>'
'<p>' 'Turn into Jelly Beans!' '</p>'
'</section>'
'</section>'
/, 'Mixed sections and paragraphs';
=begin something
=begin somethingelse
toot tooot!
=end somethingelse
=end something
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'something' '</h1>'
'<section>'
'<h1>' 'somethingelse' '</h1>'
'<p>' 'toot tooot!' '</p>'
'</section>'
'</section>'
/, 'regression test';
=begin kwid
= DESCRIPTION
bla bla
foo
=end kwid
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'kwid' '</h1>'
'<p>' '= DESCRIPTION bla bla' '</p>'
'<p>' 'foo' '</p>'
'</section>'
/, 'broken meta tag';
=begin more-discussion-needed
XXX: chop(@array) should return an array of chopped strings?
XXX: chop(%has) should return a hash of chopped strings?
=end more-discussion-needed
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'more-discussion-needed' '</h1>'
'<p>' 'XXX: chop(@array) should return an array of chopped strings? XXX: chop(%has) should return a hash of chopped strings?' '</p>'
'</section>'
/, 'playing with line breaks';
=for foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'</section>'
/, 'hanging section';
# tests without Albi would still be tests, but definitely very, very sad
# also, Albi without paragraph blocks wouldn't be the happiest dragon
# either
=begin foo
and so, all of the villages chased
Albi, The Racist Dragon, into the
very cold and very scary cave
and it was so cold and so scary in
there, that Albi began to cry
=for bar
Dragon Tears!
Which, as we all know...
=for bar
Turn into Jelly Beans!
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
'<section>'
'<h1>' 'bar' '</h1>'
'<p>' 'Dragon Tears!' '</p>'
'</section>'
'<p>' 'Which, as we all know...' '</p>'
'<section>'
'<h1>' 'bar' '</h1>'
'<p>' 'Turn into Jelly Beans!' '</p>'
'</section>'
'</section>'
/, 'nested blocks';
=foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'</section>'
/, 'hanging block';
=foo some text
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'some text' '</p>'
'</section>'
/, 'hanging block with paragraph';
=foo some text
and some more
# Yes, 'some text' and 'and some more' are in the same paragraph block, no
# way to know if they've been broken up.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'some text and some more' '</p>'
'</section>'
/, 'hanging block with multi-line paragraph';
=begin foo
and so, all of the villages chased
Albi, The Racist Dragon, into the
very cold and very scary cave
and it was so cold and so scary in
there, that Albi began to cry
=bold Dragon Tears!
Which, as we all know...
=bold Turn
into
Jelly
Beans!
=end foo
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'foo' '</h1>'
'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
'<section>'
'<h1>' 'bold' '</h1>'
'<p>' 'Dragon Tears!' '</p>'
'</section>'
'<p>' 'Which, as we all know...' '</p>'
'<section>'
'<h1>' 'bold' '</h1>'
'<p>' 'Turn into Jelly Beans!' '</p>'
'</section>'
'</section>'
/, 'nested paragraphs';
=table_not
Constants 1
Variables 10
Subroutines 33
Everything else 57
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<section>'
'<h1>' 'table_not' '</h1>'
'<p>' 'Constants 1 Variables 10 Subroutines 33 Everything else 57' '</p>'
'</section>'
/, 'S26 counterexample - not a table';
};
subtest 'table', {
#`(
=table
+-----+----+---+
| a | b | c |
+-----+----+---+
| foo | 52 | Y |
| bar | 17 | N |
| dz | 9 | Y |
+-----+----+---+
# Check out the raw pod if you don't believe me, this is a set of single
# rows.
#
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
'<tr>' '<td>' '| a | b | c |' '</td>' '</tr>'
'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
'<tr>' '<td>' '| foo | 52 | Y |' '</td>' '</tr>'
'<tr>' '<td>' '| bar | 17 | N |' '</td>' '</tr>'
'<tr>' '<td>' '| dz | 9 | Y |' '</td>' '</tr>'
'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
'</table>'
/, 'RT #124403 - incorrect table parse';
)
#`(
=begin table
a | b | c
l | m | n
x | y
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'a' '</td>'
'<td>' 'b' '</td>'
'<td>' 'c' '</td>'
'</tr>'
'<tr>'
'<td>' 'l' '</td>'
'<td>' 'm' '</td>'
'<td>' 'n' '</td>'
'</tr>'
'<tr>'
'<td>' 'x' '</td>'
'<td>' 'y' '</td>'
'</tr>'
'</table>'
/, 'RT #129862 short row';
)
#`(
=table
X O
===========
X O
===========
X
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'X' '</td>'
'<td>' 'O' '</td>'
'</tr>'
'<tr>'
'<td>' '</td>'
'<td>' 'X' '</td>'
'<td>' 'O' '</td>'
'</tr>'
'<tr>'
'<td>' '</td>'
'<td>' '</td>'
'<td>' 'X' '</td>'
'</tr>'
'</table>'
/, 'RT #132341 rows, also #129862';
)
#`(
# XXX The 'Z<..>' aren't being parsed by Perl...
# also tests fix for RT #129862
=begin table
a | b | c
l | m | n
x | y Z<a comment> Z<another comment>
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'a' '</td>'
'<td>' 'b' '</td>'
'<td>' 'c' '</td>'
'</tr>'
'<tr>'
'<td>' 'l' '</td>'
'<td>' 'm' '</td>'
'<td>' 'n' '</td>'
'</tr>'
'<tr>'
'<td>' 'x' '</td>'
'<td>' 'y Z<a comment> Z<another comment>' '</td>'
'</tr>'
'</table>'
/, 'RT #132348 allow inline Z<> comments';
)
=begin table
a
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'a' '</td>'
'</tr>'
'</table>'
/, 'single-column table';
=begin table
b
-
a
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'b' '</td>'
'</th>'
'<tr>'
'<td>' 'a' '</td>'
'</tr>'
'</table>'
/, 'single-column table with header';
#`(
# need to handle table cells with char column separators as data
# example table from <https://docs.perl6.org/language/regexes>
# WITHOUT the escaped characters (results in an extra, unwanted, incorrect column)
=begin table
Operator | Meaning
==========+=========
+ | set union
| | set union
& | set intersection
- | set difference (first minus second)
^ | symmetric set intersection / XOR
=end table
# XXX '&' needs to be escaped, among others probably.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Operator' '</td>'
'<td>' 'Meaning' '</td>'
'</th>'
'<tr>'
'<td>' '+' '</td>'
'<td>' 'set union' '</td>'
'</tr>'
'<tr>'
'<td>' '</td>'
'<td>' '</td>'
'<td>' 'set union' '</td>'
'</tr>'
'<tr>'
'<td>' '&' '</td>'
'<td>' 'set intersection' '</td>'
'</tr>'
'<tr>'
'<td>' '-' '</td>'
'<td>' 'set difference (first minus second)' '</td>'
'</tr>'
'<tr>'
'<td>' '^' '</td>'
'<td>' 'symmetric set intersection / XOR' '</td>'
'</tr>'
'</table>'
/, '#1282 header, entities and gaps';
)
#`(
# WITHOUT the escaped characters and without the non-breaking spaces
# (results in the desired table)
=begin table
Operator | Meaning
==========+=========
+ | set union
| | set union
& | set intersection
- | set difference (first minus second)
^ | symmetric set intersection / XOR
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Operator' '</td>'
'<td>' 'Meaning' '</td>'
'</th>'
'<tr>'
'<td>' '+ &' '</td>'
'<td>' 'set union set intersection' '</td>'
'<td>' 'set union' '</td>'
'</tr>'
'<tr>'
'<td>' '^' '</td>'
'<td>' 'symmetric set intersection / XOR' '</td>'
'</tr>'
'</table>'
/, 'escaped characters';
)
#`(
# WITH the escaped characters (results in the desired table)
=begin table
Operator | Meaning
==========+=========
\+ | set union
\| | set union
& | set intersection
- | set difference (first minus second)
^ | symmetric set intersection / XOR
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Operator' '</td>'
'<td>' 'Meaning' '</td>'
'</th>'
'<tr>'
'<td>' '\\+' '</td>'
'<td>' 'set union' '</td>'
'</tr>'
'<tr>'
'<td>' '\\|' '</td>'
'<td>' 'set union' '</td>'
'</tr>'
'<tr>'
'<td>' '&' '</td>'
'<td>' 'set intersection' '</td>'
'</tr>'
'<tr>'
'<td>' '-' '</td>'
'<td>' 'set difference (first minus second)' '</td>'
'</tr>'
'<tr>'
'<td>' '^' '</td>'
'<td>' 'symmetric set intersection / XOR' '</td>'
'</tr>'
'</table>'
/, 'escaped, and some non-breaking spaces';
)
#`(
# WITH the escaped characters but without the non-breaking spaces
# (results in the desired table)
=begin table
Operator | Meaning
==========+=========
\+ | set union
\| | set union
& | set intersection
- | set difference (first minus second)
^ | symmetric set intersection / XOR
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Operator' '</td>'
'<td>' 'Meaning' '</td>'
'</th>'
'<tr>'
'<td>' '\\+ \\| &' '</td>'
'<td>' 'set union set union set intersection' '</td>'
'</tr>'
'<tr>'
'<td>' '^' '</td>'
'<td>' 'symmetric set intersection / XOR' '</td>'
'</tr>'
'</table>'
/, 'escaped, no non-breaking spaces';
)
=begin table
The Shoveller Eddie Stevens King Arthur's singing shovel
Blue Raja Geoffrey Smith Master of cutlery
Mr Furious Roy Orson Ticking time bomb of fury
The Bowler Carol Pinnsler Haunted bowling ball
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'The Shoveller' '</td>'
'<td>' 'Eddie Stevens' '</td>'
'<td>' 'King Arthur\'s singing shovel' '</td>'
'</tr>'
'<tr>'
'<td>' 'Blue Raja' '</td>'
'<td>' 'Geoffrey Smith' '</td>'
'<td>' 'Master of cutlery' '</td>'
'</tr>'
'<tr>'
'<td>' 'Mr Furious' '</td>'
'<td>' 'Roy Orson' '</td>'
'<td>' 'Ticking time bomb of fury' '</td>'
'</tr>'
'<tr>'
'<td>' 'The Bowler' '</td>'
'<td>' 'Carol Pinnsler' '</td>'
'<td>' 'Haunted bowling ball' '</td>'
'</tr>'
'</table>'
/, 'simple table';
=table
Constants 1
Variables 10
Subroutines 33
Everything else 57
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'Constants' '</td>'
'<td>' '1' '</td>'
'</tr>'
'<tr>'
'<td>' 'Variables' '</td>'
'<td>' '10' '</td>'
'</tr>'
'<tr>'
'<td>' 'Subroutines' '</td>'
'<td>' '33' '</td>'
'</tr>'
'<tr>'
'<td>' 'Everything else' '</td>'
'<td>' '57' '</td>'
'</tr>'
'</table>'
/, 'simple two-column table';
=for table
mouse | mice
horse | horses
elephant | elephants
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'mouse' '</td>'
'<td>' 'mice' '</td>'
'</tr>'
'<tr>'
'<td>' 'horse' '</td>'
'<td>' 'horses' '</td>'
'</tr>'
'<tr>'
'<td>' 'elephant' '</td>'
'<td>' 'elephants' '</td>'
'</tr>'
'</table>'
/, 'two-column table, no header';
=table
Animal | Legs | Eats
=======================
Zebra + 4 + Cookies
Human + 2 + Pizza
Shark + 0 + Fish
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Animal' '</td>'
'<td>' 'Legs' '</td>'
'<td>' 'Eats' '</td>'
'</th>'
'<tr>'
'<td>' 'Zebra' '</td>'
'<td>' '4' '</td>'
'<td>' 'Cookies' '</td>'
'</tr>'
'<tr>'
'<td>' 'Human' '</td>'
'<td>' '2' '</td>'
'<td>' 'Pizza' '</td>'
'</tr>'
'<tr>'
'<td>' 'Shark' '</td>'
'<td>' '0' '</td>'
'<td>' 'Fish' '</td>'
'</tr>'
'</table>'
/, 'hanging table';
=table
Superhero | Secret |
| Identity | Superpower
==============|=================|================================
The Shoveller | Eddie Stevens | King Arthur's singing shovel
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Superhero' '</td>'
'<td>' 'Secret Identity' '</td>'
'<td>' 'Superpower' '</td>'
'</th>'
'<tr>'
'<td>' 'The Shoveller' '</td>'
'<td>' 'Eddie Stevens' '</td>'
'<td>' "King Arthur's singing shovel" '</td>'
'</tr>'
'</table>'
/, 'hanging table with multiline header';
=begin table
Secret
Superhero Identity Superpower
============= =============== ===================
The Shoveller Eddie Stevens King Arthur's
singing shovel
Blue Raja Geoffrey Smith Master of cutlery
Mr Furious Roy Orson Ticking time bomb
of fury
The Bowler Carol Pinnsler Haunted bowling ball
=end table
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<th>'
'<td>' 'Superhero' '</td>'
'<td>' 'Secret Identity' '</td>'
'<td>' 'Superpower' '</td>'
'</th>'
'<tr>'
'<td>' 'The Shoveller' '</td>'
'<td>' 'Eddie Stevens' '</td>'
'<td>' "King Arthur's singing shovel" '</td>'
'</tr>'
'<tr>'
'<td>' 'Blue Raja' '</td>'
'<td>' 'Geoffrey Smith' '</td>'
'<td>' 'Master of cutlery' '</td>'
'</tr>'
'<tr>'
'<td>' 'Mr Furious' '</td>'
'<td>' 'Roy Orson' '</td>'
'<td>' 'Ticking time bomb of fury' '</td>'
'</tr>'
'<tr>'
'<td>' 'The Bowler' '</td>'
'<td>' 'Carol Pinnsler' '</td>'
'<td>' 'Haunted bowling ball' '</td>'
'</tr>'
'</table>'
/, 'table with == separators';
=table
X | O |
---+---+---
| X | O
---+---+---
| | X
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'X' '</td>'
'<td>' 'O' '</td>'
'<td>' '</td>'
'</tr>'
'<tr>'
'<td>' '</td>'
'<td>' 'X' '</td>'
'<td>' 'O' '</td>'
'</tr>'
'<tr>'
'<td>' '</td>'
'<td>' '</td>'
'<td>' 'X' '</td>'
'</tr>'
'</table>'
/, 'tic-tac-toe with empty squares';
# test for:
# RT #126740 - Pod::Block::Table node caption property is not populated properly
# Note that the caption property is just one of the table's %config key/value
# pairs so any tests for other config keys in a single table are usually the same as testing
# multiple tables, each for one caption test.
=begin table :caption<foo> :bar(0)
foo
bar
=end table
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
isa-ok $root, Node::Table;
is $root.config.<bar>, 0;
# XXX This is wrong. There's a .caption available, it should be used.
is $root.config.<caption>, 'foo';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<table>'
'<tr>'
'<td>' 'foo' '</td>'
'</tr>'
'<tr>'
'<td>' 'bar' '</td>'
'</tr>'
'</table>'
/, 'RT #126740 caption propery';
};
subtest 'item', {
=item foo
# Isn't part of the Roast suite, but I need it to check some edge cases.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<li>' 'foo' '</li>'
/, 'standalone item';
=begin pod
=item foo
=item bar
=end pod
# Isn't part of the Roast suite, but I need it to check some edge cases.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<li>' 'foo' '</li>'
'<li>' 'bar' '</li>'
'</div>'
/, 'items';
=begin pod
The seven suspects are:
=item Happy
=item Dopey
=item Sleepy
=item Bashful
=item Sneezy
=item Grumpy
=item Keyser Soze
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>' 'The seven suspects are:' '</p>'
'<li>' 'Happy' '</li>'
'<li>' 'Dopey' '</li>'
'<li>' 'Sleepy' '</li>'
'<li>' 'Bashful' '</li>'
'<li>' 'Sneezy' '</li>'
'<li>' 'Grumpy' '</li>'
'<li>' 'Keyser Soze' '</li>'
'</div>'
/, 'one-level list';
#`(
=begin pod
=item1 Animal
=item2 Vertebrate
=item2 Invertebrate
=item1 Phase
=item2 Solid
=item2 Liquid
=item2 Gas
=item2 Chocolate
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<li>' 'Animal' '</li>'
'<ul>'
'<li>' 'Vertebrate' '</li>'
'<li>' 'Invertebrate' '</li>'
'</ul>'
'<li>' 'Phase' '</li>'
'<ul>'
'<li>' 'Solid' '</li>'
'<li>' 'Liquid' '</li>'
'<li>' 'Gas' '</li>'
'<li>' 'Chocolate' '</li>'
'</ul>'
/, 'nested lists';
)
#`(
=begin pod
=comment CORRECT...
=begin item1
The choices are:
=end item1
=item2 Liberty
=item2 Death
=item2 Beer
=item2 Cake
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
1
/;
)
};
=begin pod
sample paragraph
=begin table
Secret
Superhero Identity Superpower
============= =============== ===================
The Shoveller Eddie Stevens King Arthur's
singing shovel
Blue Raja Geoffrey Smith Master of cutlery
Mr Furious Roy Orson Ticking time bomb
of fury
The Bowler Carol Pinnsler Haunted bowling ball
=end table
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>' 'sample paragraph' '</p>'
'<table>'
'<th>'
'<td>' 'Superhero' '</td>'
'<td>' 'Secret Identity' '</td>'
'<td>' 'Superpower' '</td>'
'</th>'
'<tr>'
'<td>' 'The Shoveller' '</td>'
'<td>' 'Eddie Stevens' '</td>'
'<td>' "King Arthur's singing shovel" '</td>'
'</tr>'
'<tr>'
'<td>' 'Blue Raja' '</td>'
'<td>' 'Geoffrey Smith' '</td>'
'<td>' 'Master of cutlery' '</td>'
'</tr>'
'<tr>'
'<td>' 'Mr Furious' '</td>'
'<td>' 'Roy Orson' '</td>'
'<td>' 'Ticking time bomb of fury' '</td>'
'</tr>'
'<tr>'
'<td>' 'The Bowler' '</td>'
'<td>' 'Carol Pinnsler' '</td>'
'<td>' 'Haunted bowling ball' '</td>'
'</tr>'
'</table>'
'</div>'
/, 'paragraph and complex table';
# various things which caused the spectest to fail at some point
=begin pod
=head1 This is a heading block
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled. It is terminated by
the first blank line.
This is another ordinary paragraph.
Its text will also be squeezed and
short lines filled. It is terminated by
the trailing directive on the next line.
=head2 This is another heading block
This is yet another ordinary paragraph,
at the first virtual column set by the
previous directive
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<h1>'
'<p>' 'This is a heading block' '</p>'
'</h1>'
'<p>' 'This is an ordinary paragraph. Its text will be squeezed and short lines filled. It is terminated by the first blank line.' '</p>'
'<p>' 'This is another ordinary paragraph. Its text will also be squeezed and short lines filled. It is terminated by the trailing directive on the next line.' '</p>'
'<h2>'
'<p>' 'This is another heading block' '</p>'
'</h2>'
'<p>' 'This is yet another ordinary paragraph, at the first virtual column set by the previous directive' '</p>'
'</div>'
/, 'headings with indentations';
=begin pod
=for got
Inside got
=for bidden
Inside bidden
Outside blocks
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<section>'
'<h1>' 'got' '</h1>'
'<p>' 'Inside got' '</p>'
'</section>'
'<section>'
'<h1>' 'bidden' '</h1>'
'<p>' 'Inside bidden' '</p>'
'</section>'
'<p>' 'Outside blocks' '</p>'
'</div>'
/, 'nested blocks';
# mixed blocks
=begin pod
=begin one
one, delimited block
=end one
=for two
two, paragraph block
=for three
three, still a parablock
=begin four
four, another delimited one
=end four
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<section>'
'<h1>' 'one' '</h1>'
'<p>' 'one, delimited block' '</p>'
'</section>'
'<section>'
'<h1>' 'two' '</h1>'
'<p>' 'two, paragraph block' '</p>'
'</section>'
'<section>'
'<h1>' 'three' '</h1>'
'<p>' 'three, still a parablock' '</p>'
'</section>'
'<section>'
'<h1>' 'four' '</h1>'
'<p>' 'four, another delimited one' '</p>'
'</section>'
'</div>'
/, 'multiple blocks';
# Without the =begin..=end directives here, each =for is its own directive.
# It might not quite be in the spirit of the test, XXX
#
=begin pod
=for pod
=for nested
=for para :nested(1)
E<a;b>E<a;b;c>
♥♥♥
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<div>' '</div>'
'<section>'
'<h1>' 'nested' '</h1>'
'</section>'
'<section>'
'<h1>' 'para' '</h1>'
'<p>' 'a ba b c ♥♥♥' '</p>'
'</section>'
'</div>'
/, 'RT #131400';
=begin pod
=got Inside
got
=bidden Inside
bidden
Outside blocks
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<section>'
'<h1>' 'got' '</h1>'
'<p>' 'Inside got' '</p>'
'</section>'
'<section>'
'<h1>' 'bidden' '</h1>'
'<p>' 'Inside bidden' '</p>'
'</section>'
'<p>' 'Outside blocks' '</p>'
'</div>'
/, 'multiple blocks';
# mixed blocks
=begin pod
=begin one
one, delimited block
=end one
=two two,
paragraph block
=for three
three, still a parablock
=begin four
four, another delimited one
=end four
=head1 And just for the sake of having a working =head1 :)
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<section>'
'<h1>' 'one' '</h1>'
'<p>' 'one, delimited block' '</p>'
'</section>'
'<section>'
'<h1>' 'two' '</h1>'
'<p>' 'two, paragraph block' '</p>'
'</section>'
'<section>'
'<h1>' 'three' '</h1>'
'<p>' 'three, still a parablock' '</p>'
'</section>'
'<section>'
'<h1>' 'four' '</h1>'
'<p>' 'four, another delimited one' '</p>'
'</section>'
'<h1>'
'<p>' 'And just for the sake of having a working =head1 :)' '</p>'
'</h1>'
'</div>'
/, 'mixed contents';
=head3
Heading level 3
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<h3>'
'<p>' 'Heading level 3' '</p>'
'</h3>'
/, 'heading';
=begin pod
This ordinary paragraph introduces a code block:
$this = 1 * code('block');
$which.is_specified(:by<indenting>);
$which.spans(:newlines);
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<p>' 'This ordinary paragraph introduces a code block:' '</p>'
'<code>' "\$this = 1 * code('block');
\$which.is_specified(:by<indenting>);
\$which.spans(:newlines);" '</code>'
/, 'indented code';
# more fancy code blocks
=begin pod
This is an ordinary paragraph
While this is not
This is a code block
=head1 Mumble mumble
Suprisingly, this is not a code block
(with fancy indentation too)
But this is just a text. Again
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<div>'
'<p>' 'This is an ordinary paragraph' '</p>'
'<code>' 'While' .+ 'block' '</code>' # XXX look into this
'<h1>'
'<p>' 'Mumble mumble' '</p>'
'</h1>'
'<p>' 'Suprisingly, this is not a code block (with fancy indentation too)' '</p>'
'<p>' 'But this is just a text. Again' '</p>'
'</div>'
/, 'mixed block types';
=begin pod
Tests for the feed operators
==> and <==
=end pod
# XXX Check to see if entities need to be decoded here.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<p>' 'Tests for the feed operators' '</p>'
'<code>' '==> and <==' '</code>'
/, 'entities';
=begin pod
Fun comes
This is code
Ha, what now?
one more block of code
just to make sure it works
or better: maybe it'll break!
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<p>' 'Fun comes' '</p>'
'<code>' 'This is code' '</code>'
'<code>' 'Ha, what now?' '</code>'
'<code>' 'one more block of code
just to make sure it works
or better: maybe it\'ll break!' '</code>'
/, 'multi-line code block';
=begin pod
=head1 A heading
This is Pod too. Specifically, this is a simple C<para> block
$this = pod('also'); # Specifically, a code block
=end pod
# XXX The code with '$this...' needs to be fixed.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<h1>'
'<p>' 'A heading' '</p>'
'</h1>'
'<p>' 'This is Pod too. Specifically, this is a simple '
'<code>' 'para' '</code>'
# ' block'
# '</p>'
# '<code>'
# '\$this = pod(\'also\'); # Specifically, a code block'
# '</code>'
# '</div>'
/, 'complex code block';
=begin pod
this is code
=for podcast
this is not
this is not code either
=begin itemization
this is not
=end itemization
=begin quitem
and this is not
=end quitem
=begin item
and this is!
=end item
=end pod
# Note that <li> <code/> </li> is intentional here because of the indent.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<code>' 'this is code' '</code>'
'<section>'
'<h1>' 'podcast' '</h1>'
'<p>' 'this is not' '</p>'
'</section>'
'<p>' 'this is not code either' '</p>'
'<section>'
'<h1>' 'itemization' '</h1>'
'<p>' 'this is not' '</p>'
'</section>'
'<section>'
'<h1>' 'quitem' '</h1>'
'<p>' 'and this is not' '</p>'
'</section>'
'<li>' '<code>' 'and this is!' '</code>' '</li>'
'</div>'
/, 'mixed code and one hidden in an item';
=begin code
foo foo
=begin code
=end code
=end code
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<code>'
'foo foo
=begin code
=end code'
'</code>'
/, 'embedded pseudo-pod';
=begin pod
=for comment
foo foo
bla bla bla
This isn't a comment
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<div>'
'<!--' 'foo foo' 'bla bla bla' '-->'
'<p>' 'This isn\'t a comment' '</p>'
'</div>'
/, 'paragraph comment';
=comment
This file is deliberately specified in Perl 6 Pod format
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<!--'
'This file is deliberately specified in Perl 6 Pod format'
'-->'
/, 'S26 counterexample - hanging comment';
# this happens to break hilighting in some editors,
# so I put it at the end
=begin comment
foo foo
=begin invalid pod
=as many invalid pod as we want
===yay!
=end comment
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'<!--'
'foo foo'
'=begin invalid pod'
'=as many invalid pod as we want'
'===yay!'
'-->'
/, 'delimited comment';
# XXX Those items are :numbered in S26, but we're waiting with block
# configuration until we're inside Rakudo, otherwise we'll have to
# pretty much implement Pair parsing in gsocmess only to get rid of
# it later.
=begin pod
Let's consider two common proverbs:
=begin item
I<The rain in Spain falls mainly on the plain.>
This is a common myth and an unconscionable slur on the Spanish
people, the majority of whom are extremely attractive.
=end item
=begin item
I<The early bird gets the worm.>
In deciding whether to become an early riser, it is worth
considering whether you would actually enjoy annelids
for breakfast.
=end item
As you can see, folk wisdom is often of dubious value.
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>' "Let's consider two common proverbs:" '</p>'
'<li>'
'<i>' 'The rain in Spain falls mainly on the plain.' '</i>'
'This is a common myth and an unconscionable slur on the Spanish people, the majority of whom are extremely attractive.'
'</li>'
'<li>'
'<i>' 'The early bird gets the worm.' '</i>'
'In deciding whether to become an early riser, it is worth considering whether you would actually enjoy annelids for breakfast.'
'</li>'
'<p>' 'As you can see, folk wisdom is often of dubious value.' '</p>'
'</div>'
/, 'compound mixed content';
# includes tests for fixes for RT bugs:
# 124403 - incorrect table parse:
# 129862 - uneven rows
# 132341 - pad rows to add empty cells to ensure all rows have same number of cells
=pod
B<I am a formatting code>
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<b>' 'I am a formatting code' '</b>'
/, 'inline bold';
=pod
I<Render unto Caesar in italic>
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<i>' 'Render unto Caesar in italic' '</i>'
/, 'inline italic';
=pod
U<Ignore this!>
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<u>' 'Ignore this!' '</u>'
/, 'inline underline';
=pod
The basic C<ln> command is: C<ln> B<R<source_file> R<target_file>>
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
'The basic'
'<code>' 'ln' '</code>'
'command is:'
'<code>' 'ln' '</code>'
'<b>'
'<var>' 'source_file' '</var>'
'<var>' 'target_file' '</var>'
'</b>'
/, 'inline code and references';
=pod
L<C<b>|a>
L<C<b>|a>
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>'
'<a href="a">' '<code>' 'b' '</code>' '</a>'
' '
'<a href="a">' '<code>' 'b' '</code>' '</a>'
'</p>'
'</div>'
/, 'links';
=begin pod
=head1 A heading
This is Pod too. Specifically, this is a simple C<para> block
$this = pod('also'); # Specifically, a code block
=end pod
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<h1>'
'<p>' 'A heading' '</p>'
'</h1>'
'<p>'
'This is Pod too. Specifically, this is a simple '
'<code>' 'para' '</code>'
' block'
'</p>'
'<code>'
'$this = pod(\'also\'); # Specifically, a code block'
'</code>'
'</div>'
/, 'mixture';
=pod V<C<boo> B<bar> asd>
# Note that V<> doesn't generate its own POD node.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>' 'C<boo> B<bar> asd' '</p>'
'</div>'
/, 'invisible verbatim';
=pod C< infix:<+> >
=pod C<< infix:<+> >>
# XXX Needs to be translated.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>'
'<code>' 'infix:<+> ' '</code>'
'</p>'
'</div>'
/, 'inline <>';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<p>'
'<code>' 'infix:<+> ' '</code>'
'</p>'
'</div>'
/, 'RT #114510 inline <<>>';
=begin pod
=begin code :allow<B>
=end code
=end pod
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
isa-ok $root, 'Node::Document';
isa-ok $root.first-child, 'Node::Code';
is $root.first-child.config.<allow>, 'B';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<code>' '</code>'
'</div>'
/, 'code with configuration';
=begin pod
=config head2 :like<head1> :formatted<I>
=end pod
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
isa-ok $root.first-child, 'Node::Config';
is $root.first-child.type, 'head2';
todo 'need to test config properly', 2;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'</div>'
/, 'bare config node';
=begin pod
=for pod :number(42) :zebras :!sheep :feist<1 2 3 4>
=end pod
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 2;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<div>'
'</div>'
'</div>'
/, 'RT #127005';
=begin pod
=for DESCRIPTION :title<presentation template>
= :author<John Brown> :pubdate(2011)
=end pod
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 1;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<section>'
'<h1>' 'DESCRIPTION' '</h1>'
'</section>'
'</div>'
/, 'RT #127005';
=begin pod
=for table :caption<Table of contents>
foo bar
=end pod
$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 1;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<table>'
'<tr>'
'<td>' 'foo bar' '</td>'
'</tr>'
'</table>'
'</div>'
/, 'captioned table';
=begin pod
=begin code :allow<B>
These words have some B<importance>.
=end code
=end pod
#die $=pod[$pod-counter].perl;
$r = $=pod[$pod-counter];
#die $r;
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
'<div>'
'<code>'
'These words have some '
'<b>' 'importance' '</b>'
'.' "\n"
'</code>'
'</div>'
/, 'Adjective';
done-testing;
# vim: ft=perl6
| 22.114745 | 168 | 0.534245 |
ed4b5c60a819a388be378fe5dc184407c1adc631 | 3,371 | pm | Perl | tests/network/snmp.pm | skriesch/os-autoinst-distri-opensuse | 64271513af053c2ad6abb83234e8151064e389bd | [
"FSFAP"
]
| null | null | null | tests/network/snmp.pm | skriesch/os-autoinst-distri-opensuse | 64271513af053c2ad6abb83234e8151064e389bd | [
"FSFAP"
]
| null | null | null | tests/network/snmp.pm | skriesch/os-autoinst-distri-opensuse | 64271513af053c2ad6abb83234e8151064e389bd | [
"FSFAP"
]
| null | null | null | # SUSE's openQA tests
#
# Copyright 2021 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Package: net-snmp
# Summary: Test smtp server and client tools.
# Maintainer: QE Core <qe-core@suse.de>
use base 'opensusebasetest';
use warnings;
use strict;
use testapi;
use utils;
sub run {
my $self = shift;
$self->select_serial_terminal;
zypper_call 'in net-snmp';
assert_script_run 'cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.back';
assert_script_run 'echo "createUser bootstrap MD5 temp_password DES" >> /etc/snmp/snmpd.conf';
assert_script_run 'echo "createUser bootstrap2 SHA temp_password AES" >> /etc/snmp/snmpd.conf';
assert_script_run 'echo "rwuser bootstrap priv" >> /etc/snmp/snmpd.conf';
assert_script_run 'echo "rwuser bootstrap2 priv" >> /etc/snmp/snmpd.conf';
assert_script_run 'echo "rwuser demo priv" >> /etc/snmp/snmpd.conf';
# remove syslocaton from config to allow overwriting via snmp
assert_script_run 'sed -i -e "/^syslocation /d" /etc/snmp/snmpd.conf';
systemctl 'start snmpd';
record_info 'snmp get';
record_info 'V1';
assert_script_run 'snmpget -v 1 -c public localhost SNMPv2-MIB::sysDescr.0 | grep Linux';
record_info 'V2c';
assert_script_run 'snmpget -v 2c -c public localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
validate_script_output 'snmpget -v2c -c badcommunity localhost sysLocation.0 || true', qr/Timeout: No Response from localhost/;
record_info 'V3';
assert_script_run 'snmpget -v 3 -u bootstrap -l authPriv -a MD5 -x DES -A temp_password -X temp_password localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
assert_script_run 'snmpget -v 3 -u bootstrap2 -l authPriv -a SHA -x AES -A temp_password -X temp_password localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
validate_script_output 'snmpget -v 3 -u bootstrap -l authPriv -a SHA -x AES -A wrong_password -X temp_password localhost sysLocation.0 || true', qr/Authentication failure/;
record_info 'user create';
assert_script_run 'snmpusm -u bootstrap -l authPriv -a MD5 -x DES -A temp_password -X temp_password localhost create demo bootstrap';
assert_script_run 'snmpget -v 3 -u demo -l authPriv -a MD5 -x DES -A temp_password -X temp_password localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
record_info 'pass change';
assert_script_run 'snmpusm -u demo -l authPriv -a MD5 -x DES -A temp_password -X temp_password localhost passwd temp_password new_password';
assert_script_run 'snmpget -v 3 -u demo -l authPriv -a MD5 -x DES -A new_password -X new_password localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
record_info 'user config';
assert_script_run 'mkdir ~/.snmp';
assert_script_run 'echo "defSecurityName demo" > ~/.snmp/snmp.conf';
assert_script_run 'echo "defSecurityLevel authPriv" >> ~/.snmp/snmp.conf';
assert_script_run 'echo "defAuthType MD5" >> ~/.snmp/snmp.conf';
assert_script_run 'echo "defPrivType DES" >> ~/.snmp/snmp.conf';
assert_script_run 'echo "defAuthPassphrase new_password" >> ~/.snmp/snmp.conf';
assert_script_run 'echo "defPrivPassphrase new_password" >> ~/.snmp/snmp.conf';
assert_script_run 'snmpget localhost 1.3.6.1.2.1.1.1.0 | grep Linux';
record_info 'snmp set';
assert_script_run 'snmpset localhost sysLocation.0 s Earth';
assert_script_run 'snmpget -v2c -c public localhost sysLocation.0 | grep Earth';
}
1;
| 47.478873 | 176 | 0.718185 |
73e58b64f91f94f80e4e07840efc282af7e3c141 | 4,303 | pl | Perl | afd2solexa_data/genes_tags_counts.pl | SchwarzEM/ems_perl | 0c20b1fe1d215689ee8db3677b23175bd968841f | [
"BSD-3-Clause"
]
| 2 | 2021-07-19T09:00:17.000Z | 2021-08-30T02:45:18.000Z | afd2solexa_data/genes_tags_counts.pl | Superboy666/ems_perl | ce78eb5c2120566e6e55a786ebd15382cb38736f | [
"BSD-3-Clause"
]
| null | null | null | afd2solexa_data/genes_tags_counts.pl | Superboy666/ems_perl | ce78eb5c2120566e6e55a786ebd15382cb38736f | [
"BSD-3-Clause"
]
| 1 | 2021-07-19T09:00:18.000Z | 2021-07-19T09:00:18.000Z | #!/usr/bin/perl
# genes_tags_counts.pl -- Erich Schwarz <emsch@its.caltech.edu>, 2/28/2008.
# Purpose: get useful gene/tag counts from Solexa splice/uniqs.
use strict;
use warnings;
# Enforce superficially correct inputs.
my $splice_file = $ARGV[0];
my $uniqs_file = $ARGV[1];
unless ( $#ARGV == 1 ) {
die 'Format: ./genes_tags_counts.pl [splice file] [uniqs file]', "\n";
}
# These hashes both record a sighting and count tags.
my %genes_spliced = ();
my %genes_tagged = ();
my %ambivs_tagged = ();
# Input lines of uniqs vs. splices are ~same, so ~same parsing:
sub parse_input_line {
my ($_input, $_splice);
($_input, $_splice) = @_;
# Typical input lines:
# WBGene00019904|WBGene00020894 42956 -- never in splices, though.
# WBGene00020894 13716
# WBGene00007790 1
if ( $_input =~ / \A ( WBGene\d+ (?: \| WBGene\d+ )* )
\s+
( \d+ )
\z /xms ) {
my $gNtag = $1;
my $count = $2;
# Splices are stronger evidence, so track them specifically:
if ($_splice eq "splice") {
$genes_spliced{$gNtag} += $count;
}
# Genes can be ambiguous, because tags can touch 2 exons:
if ( $gNtag =~ / \| /xms ) {
$ambivs_tagged{$gNtag} += $count;
}
if ( $gNtag !~ / \| /xms ) {
$genes_tagged{$gNtag} += $count;
}
}
}
# Import data from the splices and uniqs files.
open my $SPLICES, "<", "$splice_file"
or die "Can't open splice file $splice_file\n";
while (my $input = <$SPLICES>) {
chomp $input;
parse_input_line($input, "splice");
}
close $SPLICES;
open my $UNIQS, "<", "$uniqs_file"
or die "Can't open uniqs. file $uniqs_file\n";
while (my $input = <$UNIQS>) {
chomp $input;
parse_input_line($input, q{});
}
# Export a summary of uniqs/splices data.
# A note on sorting genes in the summary:
#
# Bare "sort" (or 'cmp') is used to give clean ASCIIbetical order.
# $b <=> $a is then used to give genes in descending count order.
# And int($b <=> $a) comparisons are used to avoid floating-point nonsense.
# So a cohort of equal-counted genes will be listed reliably ASCIIbetically.
my @Ntagged_genes
= sort { int($genes_tagged{$b}) <=> int($genes_tagged{$a}) }
sort
grep { int($genes_tagged{$_}) != 1 }
keys %genes_tagged;
my $tagged_count = @Ntagged_genes;
my @Ntagged_ambivs
= sort { int($ambivs_tagged{$b}) <=> int($ambivs_tagged{$a}) }
sort
grep { int($ambivs_tagged{$_}) != 1 }
keys %ambivs_tagged;
my $ambiv_count = @Ntagged_ambivs;
my @unitagged_splices
= sort
grep { int($genes_tagged{$_}) == 1 }
grep { int($genes_spliced{$_}) == 1 }
keys %genes_spliced;
my $uni_splic_count = @unitagged_splices;
my @unitagged_genes
= sort
grep {! $genes_spliced{$_} }
grep { int($genes_tagged{$_}) == 1 }
keys %genes_tagged;
my $unitagged_count = @unitagged_genes;
my @unitagged_ambivs
= sort
grep { int($ambivs_tagged{$_}) == 1 }
keys %ambivs_tagged;
my $uni_ambiv_count = @unitagged_ambivs;
print "Genes with >= 2 tags: $tagged_count\n";
print "Ambiv. id. genes with >= 2 tags: $ambiv_count\n";
print "Genes with 1 splice tag: $uni_splic_count\n";
print "Genes with 1 non-splice tag: $unitagged_count\n";
print "Ambiv. genes w/ 1 non-splice tag: $uni_ambiv_count\n";
print "\n";
# There are a number of ways one might list the genes.
# One reasonable way, though is to have a straight list
# of both unambig. and ambig. genes with >= 2 tags,
# sorted by tag count.
my @Ntagged_all_refs
= map { [ $_, $genes_tagged{$_} ] } @Ntagged_genes;
# N.B.: 'push' alters its first argument!
push ( @Ntagged_all_refs,
( map { [ $_, $ambivs_tagged{$_} ] } @Ntagged_ambivs ), );
push ( @Ntagged_all_refs,
( map { [ $_, $genes_spliced{$_} ] } @unitagged_splices ), );
# See "Note on sorting" above.
my @Ntagged_all_sorted_refs
= sort { int($b->[1]) <=> int($a->[1]); }
sort { $a->[0] cmp $b->[0]; }
@Ntagged_all_refs;
foreach my $generef ( @Ntagged_all_sorted_refs ) {
print $generef->[0], "\t", $generef->[1], "\n";
}
| 28.496689 | 76 | 0.595166 |
ed32670987307b1fea2559bcb657cd8f668fcf54 | 11,514 | pm | Perl | lib/AmuseWikiFarm/View/HTML.pm | rojenzaman/amusewiki | df5585bc97ffc9eab069bdc4d9aedd5bad7a0d98 | [
"Artistic-1.0"
]
| null | null | null | lib/AmuseWikiFarm/View/HTML.pm | rojenzaman/amusewiki | df5585bc97ffc9eab069bdc4d9aedd5bad7a0d98 | [
"Artistic-1.0"
]
| null | null | null | lib/AmuseWikiFarm/View/HTML.pm | rojenzaman/amusewiki | df5585bc97ffc9eab069bdc4d9aedd5bad7a0d98 | [
"Artistic-1.0"
]
| null | null | null | package AmuseWikiFarm::View::HTML;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::TT';
use AmuseWikiFarm::Log::Contextual;
use Template::Filters;
use AmuseWikiFarm::Utils::Amuse qw/amw_meta_stripper to_json/;
use URI;
$Template::Filters::FILTERS->{escape_invisible_chars} = \&escape_invisible_chars;
$Template::Filters::FILTERS->{escape_js} = \&escape_js_string;
sub escape_invisible_chars {
my $s = shift;
$s =~ s/([\x{ad}\x{a0}])/sprintf('<U+%04X>', ord($1))/ge;
return $s;
}
sub escape_js_string {
my $s = shift;
$s =~ s/(\\|'|"|\/)/\\$1/g;
return $s;
};
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
ENCODING => 'utf8',
WRAPPER => 'wrapper.tt',
PRE_PROCESS => 'macros.tt',
render_die => 1,
);
before process => sub {
my ($self, $c) = @_;
my $site = $c->stash->{site};
return unless $site;
if ($c->request->query_params->{bare}) {
$c->stash(no_wrapper => 1);
}
unless ($c->stash->{no_wrapper}) {
log_debug { "Doing the layout fixes" };
$self->add_navigation_menus($c, $site);
# display number of pending revisions in the user menu
if ($c->user_exists) {
$c->stash->{site_pending_revisions} = $site->revisions->pending->count;
}
# warn about failed jobs in the user menu
if ($c->user_exists and $c->check_any_user_role(qw/admin root/)) {
$c->stash->{site_failed_jobs} = $site->jobs->failed_jobs->count;
}
# layout adjustments
my $theme = $site->bootstrap_theme;
if (my $alt_theme = $site->bootstrap_alt_theme) {
$c->stash(site_has_alt_theme => 1);
if ($c->stash->{use_alternate_theme}) {
$theme = $alt_theme;
}
}
my $columns = 12;
if ($c->stash->{full_page_no_side_columns}) {
$c->stash(layout_always_fluid => 1);
}
else {
$c->stash(layout_always_fluid => $site->layout_always_fluid);
my $left_column = $site->left_layout_html;
my $right_column = $site->right_layout_html;
if ($left_column || $right_column) {
my $wide = 4;
# enlarge the column if we have only one sidebar
if ($left_column && $right_column) {
$wide = 2;
}
$c->stash(left_layout_html => $left_column,
right_layout_html => $right_column,
left_layout_cols => ($left_column ? $wide : 0),
right_layout_cols => ($right_column ? $wide : 0),
);
$columns = 8;
}
}
if (my $meta_desc = $c->stash->{meta_description}) {
$c->stash(meta_description => amw_meta_stripper($meta_desc));
}
$self->add_open_graph($c);
my $sitelink = {
'@context' => 'http://schema.org',
'@type' => "WebSite",
'url' => $c->uri_for('/')->as_string,
'potentialAction' => {
'@type' => "SearchAction",
'target' => $c->uri_for_action('/search/index') . '?query={search_term_string}',
'query-input' => "required name=search_term_string"
},
};
$c->stash(
bootstrap_css => "/static/css/bootstrap.$theme.css",
main_body_cols => $columns,
top_layout_html => $site->top_layout_html,
bottom_layout_html => $site->bottom_layout_html,
footer_layout_html => $site->footer_layout_html,
sitelinks_searchbox => to_json($sitelink, pretty => 1, canonical => 1),
category_types_navbar_display => $site->category_types_navbar_display($c->user_exists),
);
}
};
=head2 add_open_graph
From the specs (L<http://ogp.me>)
=over 4
=item og:title
The title of your object as it should appear within the graph, e.g., "The Rock".
We look into page_title, which should already set. Otherwise we fall
back to the site description.
=item og:type
The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
If a text object is stashed, we can set it to C<book> or C<article> +
C<$type:author> + C<$type:tag> with topics, otherwise it's C<website>
=item og:image
An image URL which should represent your object within the graph. If
it's a text object, we could have a cover attached. Otherwise default
to the site logo. Skip the whole thing if we don't have that, as it's
mandatory.
=item og:url
The canonical URL of your object that will be used as its permanent ID
in the graph, e.g., "http://www.imdb.com/title/tt0117500/".
If C<page_title> is not set, default to the root. Otherwise parse
$c->request->uri, stripping reserved params (prefixed by C<__>). If
I'm not mistaken, we don't have different access urls for the same
resources, so it's always the canonical.
=item og:description
This is optional, use the meta_description if set.
=item og:site_name
This is optional, but we should have it.
=item og:locale and og:locale:alternate (string).
Optional, but we should have it. We need the language_TERRITORY, though.
=back
=cut
sub add_open_graph {
my ($self, $c) = @_;
if (my $site = $c->stash->{site}) {
my $image;
SEARCHIMAGE:
foreach my $i (qw/opengraph.png pagelogo.png navlogo.png/) {
if (my $found = $site->site_files->min_dimensions(200, 200)->single({ file_name => $i })) {
$image = $found;
log_debug { "Found $i, stashing apple_touch_icon " . $image->file_name . ' ' . $image->mime_type };
$c->stash(apple_touch_icon => $c->uri_for_action('/sitefiles/local_files',
[ $site->id, $image->file_name ]));
$c->stash(apple_touch_icon_mime_type => $image->mime_type);
last SEARCHIMAGE;
}
}
if ($image) {
# ok, we have an image, we can proceed
my @opengraph;
my $title = $c->stash->{page_title} || $site->sitename;
if ($title) {
push @opengraph, { p => 'og:title', c => $title };
}
else {
# cannot proceed, this is a broken setup and shouldn't happen
return;
}
my $text = $c->stash->{text};
if ($text and ref($text) and $text->can('text_qualification')) {
my $type = $text->text_qualification || 'article';
push @opengraph, { p => 'og:type', c => $type };
if (my $author = $text->author) {
push @opengraph, { p => "og:$type:author", c => $author };
}
if (my $categories = $c->stash->{text_display_categories}) {
my $lh = $c->stash->{lh};
my ($topics) = grep { $_->{code} eq 'topic' } @$categories;
if ($topics && @{$topics->{entries}}) {
foreach my $topic (@{$topics->{entries}}) {
if (my $t = $topic->{name}) {
push @opengraph, { p => "og:$type:tag", c => $lh->site_loc($t) };
}
}
}
}
if (my $cover = $text->cover_file) {
# this return an attachment object
if (my $thumb = $cover->thumbnails->min_dimensions(200, 200)->first) {
$image = $thumb;
}
}
}
else {
push @opengraph, { p => 'og:type', c => 'website' };
}
my $image_url = $image->is_site_file ?
$c->uri_for_action('/sitefiles/local_files',
[ $site->id, $image->file_name ])
:
$c->uri_for_action('/uploads/thumbnail',
[ $site->id, $image->file_name ]);
push @opengraph, ({
p => 'og:image',
c => $image_url,
},
{
p => 'og:image:width',
c => $image->image_width,
},
{
p => 'og:image:height',
c => $image->image_height,
});
# if we're here, we are already serving the canonical or an allowed alias.
my $uri = $c->request->uri->clone;
my %query = $uri->query_form; # don't mind if the param is repeated twice.
foreach my $k (keys %query) {
delete $query{$k} if $k =~ m/^__/;
}
# unclear what happens if the app is mounted, but in this
# case I think that's the last of our problems.
push @opengraph, { p => 'og:url', c => "$uri" };
if (my $site_name = $site->sitename) {
push @opengraph, { p => 'og:site_name', c => $site_name };
}
if (my $desc = $c->stash->{meta_description} || $title) {
push @opengraph, { p => 'og:description', c => $desc };
}
$c->stash(open_graph => \@opengraph) if @opengraph;
}
}
}
sub add_navigation_menus {
my ($self, $c, $site) = @_;
my @related = map {
+{ uri => $_->canonical_url, name => $_->sitename || $_->canonical }
} $site->other_sites;
my @specials = map {
+{ uri => $_->full_uri, name => $_->title || $_->rui }
} $site->titles->published_specials->without_index_uri->no_uid_or_localized($c->stash->{current_locale_code});
my %out = (
projects => \@related,
specials => \@specials,
archive => [],
);
foreach my $link ($site->site_links->search(undef, { order_by => [qw/sorting_pos url/] })) {
if ($out{$link->menu}) {
push @{$out{$link->menu}}, {
uri => $link->url,
name => $link->label || $link->url
};
}
}
foreach my $menu (keys %out) {
if (@{$out{$menu}}) {
foreach my $link (@{$out{$menu}}) {
unless ($link->{uri} =~ m{https?://}) {
$link->{uri} = $c->uri_for($link->{uri});
}
$link->{active} = $link->{uri} eq $c->request->uri;
}
}
else {
delete $out{$menu}; # nothing to show
}
}
$c->stash(navigation => \%out);
}
=head1 NAME
AmuseWikiFarm::View::HTML - TT View for AmuseWikiFarm
=head1 DESCRIPTION
TT View for AmuseWikiFarm.
=head1 SEE ALSO
L<AmuseWikiFarm>
=head1 AUTHOR
Marco Pessotto <melmothx@gmail.com>
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;
| 35.319018 | 126 | 0.493486 |
ed41939525e3fa6f908f5b09f51534601b73276d | 11,493 | t | Perl | t/unit/configuration.t | FROGGS/mongo-perl-driver | 965807e8a1c99db3cd2430d2a9598028872939ad | [
"Apache-2.0"
]
| 1 | 2018-10-25T15:16:11.000Z | 2018-10-25T15:16:11.000Z | t/unit/configuration.t | FROGGS/mongo-perl-driver | 965807e8a1c99db3cd2430d2a9598028872939ad | [
"Apache-2.0"
]
| 2 | 2019-07-24T19:05:40.000Z | 2019-07-24T19:05:51.000Z | t/unit/configuration.t | shadow-dot-cat/mongo-perl-driver | 905d422393572dd812a73b836b227cf9e0d27c39 | [
"Apache-2.0"
]
| null | null | null | # Copyright 2015 - present MongoDB, Inc.
#
# 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.
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use MongoDB;
use MongoDB::MongoClient;
sub _mc {
return MongoDB::MongoClient->new(@_);
}
subtest "host and port" => sub {
my $mc = _mc();
is( $mc->host, "mongodb://localhost:27017", "default host is URI" );
is( $mc->port, 27017, "port" );
is( $mc->_uri->uri, $mc->host, "uri matches host" );
$mc = _mc( host => "example.com" );
is( $mc->host, "example.com", "host as hostname is preserved" );
is( $mc->_uri->uri, "mongodb://example.com:27017", "uri gets host" );
$mc = _mc( host => "example.com", port => 99 );
is( $mc->host, "example.com", "host as hostname is preserved" );
is( $mc->port, 99, "default port changed" );
is( $mc->_uri->uri, "mongodb://example.com:99", "uri gets both host and port" );
$mc = _mc( host => "localhost:27018" );
is( $mc->_uri->uri, "mongodb://localhost:27018", "host as localhost:27018" );
$mc = _mc( host => "mongodb://example.com", port => 99 );
is( $mc->host, "mongodb://example.com", "host as URI is preserved" );
is( $mc->port, 99, "port changed" );
is( $mc->_uri->uri, $mc->host, "uri matches host" );
is_deeply( $mc->_uri->hostids, ["example.com:27017"],
"host pairs ignores changed port" );
};
subtest "app name" => sub {
my $mc = _mc();
is( $mc->app_name, "", "default app name" );
$mc = _mc( app_name => "foo" );
is( $mc->app_name, "foo", "app_name" );
$mc = _mc( host => 'mongodb://localhost/?appName=foo', );
is( $mc->app_name, "foo", "appName" );
$mc = _mc(
host => 'mongodb://localhost/?appName=foo',
app_name => "bar",
);
is( $mc->app_name, "foo", "appName supersedes app_name" );
like(
exception { _mc( app_name => 'x' x 129 ) },
qr/app name must be at most 128 bytes/,
"long app names are rejected"
);
};
subtest "auth mechanism and properties" => sub {
my @up = qw/username johndoe password trustno1/;
my $mc = _mc();
is( $mc->auth_mechanism, 'NONE', "default auth_mechanism" );
is_deeply( $mc->auth_mechanism_properties, {}, "default auth_mechanism_properties" );
$mc = _mc(
@up,
auth_mechanism => 'GSSAPI',
auth_mechanism_properties => { foo => 1 }
);
is( $mc->auth_mechanism, 'GSSAPI', "custom auth_mechanism" );
is_deeply(
$mc->auth_mechanism_properties,
{ foo => 1, SERVICE_NAME => 'mongodb' },
"custom auth_mechanism_properties"
);
$mc = _mc(
@up,
host => 'mongodb://localhost/?authMechanism=GSSAPI&authMechanismProperties=bar:2',
auth_mechanism => 'MONGODB-CR',
auth_mechanism_properties => { foo => 1 },
);
is( $mc->auth_mechanism, 'GSSAPI', "authMechanism supersedes auth_mechanism" );
is_deeply(
$mc->auth_mechanism_properties,
{ bar => 2, SERVICE_NAME => 'mongodb' },
"authMechanismProperties supersedes auth_mechanism_properties"
);
};
subtest bson_codec => sub {
my $codec = BSON->new( op_char => '-' );
my $mc = _mc();
ok( !$mc->bson_codec->prefer_numeric, "default bson_codec object" );
$mc = _mc( bson_codec => $codec );
is( $mc->bson_codec->op_char, '-', "bson_codec object" );
$mc = _mc( bson_codec => { prefer_numeric => 1 } );
isa_ok( $mc->bson_codec, 'BSON' );
ok( $mc->bson_codec->prefer_numeric, "bson_codec coerced from hashref" );
};
subtest connect_timeout_ms => sub {
my $mc = _mc();
is( $mc->connect_timeout_ms, 10000, "default connect_timeout_ms" );
$mc = _mc(
connect_timeout_ms => 30000,
);
is( $mc->connect_timeout_ms, 30000, "connect_timeout_ms" );
$mc = _mc(
host => 'mongodb://localhost/?connectTimeoutMS=20000',
connect_timeout_ms => 30000,
);
is( $mc->connect_timeout_ms, 20000, "connectTimeoutMS" );
};
subtest db_name => sub {
my $mc = _mc();
is( $mc->db_name, "", "default db_name" );
$mc = _mc( db_name => "testdb", );
is( $mc->db_name, "testdb", "db_name" );
$mc = _mc(
host => 'mongodb://localhost/admin',
db_name => "testdb",
);
is( $mc->db_name, "admin", "database in URI" );
};
my %simple_time_options = (
heartbeat_frequency_ms => 60000,
local_threshold_ms => 15,
max_staleness_seconds => -1,
max_time_ms => 0,
server_selection_timeout_ms => 30000,
socket_check_interval_ms => 5000,
);
for my $key ( sort keys %simple_time_options ) {
subtest $key => sub {
my $mc = _mc( read_pref_mode => 'nearest' );
is( $mc->$key, $simple_time_options{$key}, "default $key" );
$mc = _mc( $key => 99999, read_pref_mode => 'nearest' );
is( $mc->$key, 99999, "$key" );
( my $cs_key = $key ) =~ s/_//g;
$mc = _mc(
host => "mongodb://localhost/?$cs_key=88888",
$key => 99999,
read_pref_mode => 'nearest'
);
is( $mc->$key, 88888, "$cs_key" );
};
}
subtest journal => sub {
my $mc = _mc();
ok( !$mc->j, "default j (false)" );
$mc = _mc( j => 1 );
ok( $mc->j, "j (true)" );
$mc = _mc(
host => 'mongodb://localhost/?journal=false',
j => 1,
);
ok( !$mc->j, "journal supersedes j" );
};
subtest "heartbeat frequency minimum" => sub {
like(
exception { _mc( heartbeat_frequency_ms => 10 ) },
qr/must be at least 500/,
"heartbeat_frequency_ms < 500 throws"
);
is(
exception { _mc( heartbeat_frequency_ms => 500 ) },
undef,
"heartbeat_frequency_ms == 500"
);
};
subtest "read_pref_mode and read_pref_tag_sets" => sub {
my $mc = _mc();
is( $mc->read_pref_mode, 'primary', "default read_pref_mode" );
is_deeply( $mc->read_pref_tag_sets, [ {} ], "default read_pref_tag_sets" );
my $tag_set_list = [ { dc => 'nyc', rack => 1 }, { dc => 'nyc' } ];
$mc = _mc(
read_pref_mode => 'secondary',
read_pref_tag_sets => $tag_set_list,
);
is( $mc->read_pref_mode, 'secondary', "read_pref_mode" );
is_deeply( $mc->read_pref_tag_sets, $tag_set_list, "read_pref_tag_sets" );
$mc = _mc(
host => 'mongodb://localhost/?readPreference=nearest&readPreferenceTags=dc:sf',
read_pref_mode => 'secondary',
read_pref_tag_sets => $tag_set_list,
);
is( $mc->read_pref_mode, 'nearest', "readPreference" );
is_deeply( $mc->read_pref_tag_sets, [ { dc => 'sf' } ], "readPreferenceTags" );
};
subtest replica_set_name => sub {
my $mc = _mc();
is( $mc->replica_set_name, "", "default replica_set_name" );
is( $mc->_topology->replica_set_name, '', "topology object matches" );
$mc = _mc( replica_set_name => "repl1" );
is( $mc->replica_set_name, "repl1", "replica_set_name" );
is( $mc->_topology->replica_set_name, "repl1", "topology object matches" );
$mc = _mc(
host => 'mongodb://localhost/?replicaSet=repl2',
replica_set_name => "repl1",
);
is( $mc->replica_set_name, "repl2", "replicaSet" );
is( $mc->_topology->replica_set_name, "repl2", "topology object matches" );
};
subtest server_selection_try_once => sub {
my $mc = _mc();
ok( $mc->server_selection_try_once, "default server_selection_try_once true" );
$mc = _mc( server_selection_try_once => 0 );
ok( !$mc->server_selection_try_once, "server_selection_try_once (false)" );
$mc = _mc(
host => 'mongodb://localhost/?serverSelectionTryOnce=false',
server_selection_try_once => 1,
);
ok( !$mc->server_selection_try_once, "URI supersedes argument" )
or diag explain $mc->_uri;
};
subtest socket_timeout_ms => sub {
my $mc = _mc();
is( $mc->socket_timeout_ms, 30000, "default socket_timeout_ms" );
$mc = _mc(
socket_timeout_ms => 40000,
);
is( $mc->socket_timeout_ms, 40000, "socket_timeout_ms" );
$mc = _mc(
host => 'mongodb://localhost/?socketTimeoutMS=10000',
socket_timeout_ms => 40000,
);
is( $mc->socket_timeout_ms, 10000, "socketTimeoutMS" );
};
subtest ssl => sub {
my $mc = _mc();
ok( !$mc->ssl, "default ssl (false)" );
$mc = _mc( ssl => 1 );
ok( $mc->ssl, "ssl (true)" );
$mc = _mc( ssl => {} );
ok( $mc->ssl, "ssl (hashref)" );
$mc = _mc(
host => 'mongodb://localhost/?ssl=false',
ssl => 1,
);
ok( !$mc->ssl, "connection string supersedes" );
};
subtest "username and password" => sub {
my $mc = _mc();
is( $mc->username, "", "default username" );
is( $mc->password, "", "default password" );
$mc = _mc(
username => "mulder",
password => "trustno1"
);
is( $mc->username, "mulder", "username" );
is( $mc->password, "trustno1", "password" );
$mc = _mc(
host => 'mongodb://scully:skeptic@localhost/',
username => "mulder",
password => "trustno1"
);
is( $mc->username, "scully", "username from URI" );
is( $mc->password, "skeptic", "password from URI" );
$mc = _mc(
host => 'mongodb://:@localhost/',
username => "mulder",
password => "trustno1"
);
is( $mc->username, "", "username from URI" );
is( $mc->password, "", "password from URI" );
};
subtest w => sub {
my $mc = _mc();
is( $mc->w, undef, "default w" );
$mc = _mc( w => 2 );
is( $mc->w, 2, "w:2" );
$mc = _mc( w => 'majority' );
is( $mc->w, 'majority', "w:majority" );
$mc = _mc(
host => 'mongodb://localhost/?w=0',
w => 'majority',
);
is( $mc->w, 0, "w from connection string" );
isnt( exception { _mc( w => {} ) },
undef, "Setting w to anything but a string or int dies." );
};
subtest wtimeout => sub {
my $mc = _mc();
is( $mc->wtimeout, 1000, "default wtimeout" );
$mc = _mc( wtimeout => 40000, );
is( $mc->wtimeout, 40000, "wtimeout" );
$mc = _mc(
host => 'mongodb://localhost/?wtimeoutMS=10000',
wtimeout => 40000,
);
is( $mc->wtimeout, 10000, "wtimeoutMS" );
};
subtest "warnings and exceptions" => sub {
my $warning;
local $SIG{__WARN__} = sub { $warning = shift };
my $mc = _mc( host => "mongodb://localhost/?notArealOption=42" );
like(
$warning,
qr/Unsupported option 'notArealOption' in URI/,
"unknown option warns with original case"
);
like(
exception { _mc( host => "mongodb://localhost/?ssl=" ) },
qr/expected boolean/,
'ssl key with invalid value'
);
};
done_testing;
| 30.648 | 90 | 0.560602 |
ed45997ebf0005ede8bfec54cbe079543aaa515e | 1,821 | t | Perl | t/50_Cxn_Pool/17_static_runaway_nodes.t | szabosteve/elasticsearch-perl | 1ff926c47baed00afcde09326ae5f4b8269dd225 | [
"Apache-2.0"
]
| 70 | 2015-03-19T09:19:39.000Z | 2022-03-01T20:06:00.000Z | t/50_Cxn_Pool/17_static_runaway_nodes.t | szabosteve/elasticsearch-perl | 1ff926c47baed00afcde09326ae5f4b8269dd225 | [
"Apache-2.0"
]
| 149 | 2015-03-10T20:51:53.000Z | 2022-03-14T19:15:27.000Z | t/50_Cxn_Pool/17_static_runaway_nodes.t | szabosteve/elasticsearch-perl | 1ff926c47baed00afcde09326ae5f4b8269dd225 | [
"Apache-2.0"
]
| 51 | 2015-04-23T18:54:18.000Z | 2022-03-10T19:50:16.000Z | # Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. 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.
use Test::More;
use Test::Exception;
use Search::Elasticsearch;
use lib 't/lib';
use MockCxn qw(mock_static_client);
## Runaway nodes (ie wrong HTTP response codes signal node failure, instead of
## request failure)
my $t = mock_static_client(
{ nodes => 'one' },
{ node => 1, ping => 1 },
{ node => 1, code => 200, content => 1 },
{ node => 1, code => 503, error => 'Unavailable' },
{ node => 1, ping => 1 },
{ node => 1, code => 503, error => 'Unavailable' },
# throw Unavailable: too many retries
{ node => 1, ping => 1 },
{ node => 1, code => 503, error => 'Unavailable' },
{ node => 1, ping => 1 },
{ node => 1, code => 503, error => 'Unavailable' },
# throw Unavailable: too many retries
{ node => 1, ping => 1 },
{ node => 1, code => 200, content => 1 },
);
ok $t->perform_request
&& !eval { $t->perform_request }
&& $@ =~ /Unavailable/
&& !eval { $t->perform_request }
&& $@ =~ /Unavailable/
&& $t->perform_request,
"Runaway nodes";
done_testing;
| 30.864407 | 78 | 0.646348 |
ed02d3b8723f812cde410fbd57fe585e42206995 | 103 | pl | Perl | tp02/ex01.pl | bernas670/PLOG | 238751b43615b18729c09f167ec20190c461ab80 | [
"MIT"
]
| null | null | null | tp02/ex01.pl | bernas670/PLOG | 238751b43615b18729c09f167ec20190c461ab80 | [
"MIT"
]
| null | null | null | tp02/ex01.pl | bernas670/PLOG | 238751b43615b18729c09f167ec20190c461ab80 | [
"MIT"
]
| 1 | 2020-01-27T20:52:13.000Z | 2020-01-27T20:52:13.000Z | r(a,b).
r(a,c).
r(b,a).
r(a,d).
s(b,c).
s(b,d).
s(c,c).
s(d,e). | 12.875 | 17 | 0.23301 |
ed44daf1bebc315ce6385afbea068357da56b1f5 | 2,512 | pl | Perl | examples/ppdq_2005/pdq_models/mm1.pl | evelynmitchell/pdq | 242e8a5ef15ee4c9bd67189861451eb5f34e3bf9 | [
"MIT"
]
| null | null | null | examples/ppdq_2005/pdq_models/mm1.pl | evelynmitchell/pdq | 242e8a5ef15ee4c9bd67189861451eb5f34e3bf9 | [
"MIT"
]
| null | null | null | examples/ppdq_2005/pdq_models/mm1.pl | evelynmitchell/pdq | 242e8a5ef15ee4c9bd67189861451eb5f34e3bf9 | [
"MIT"
]
| null | null | null | #! /usr/bin/perl
###############################################################################
# Copyright (C) 1994 - 2013, 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. #
###############################################################################
#
# $Id: mm1.pl,v 4.8 2013/02/19 05:12:10 earl-lang Exp $
# mm1-book.pl
# Updated by NJG on Sat, Apr 8, 2006 per erratum for p. 220
# Updated by NJG on Monday, February 18, 2013 Correct p.269 PPDQ 2nd edn.
use pdq;
## PDQ INPUTS ##
# Measured parameters
$MeasurePeriod = 3600; # seconds
$ArrivalCount = 1800;
$ServiceVisits = 10;
# Derived parameters
$ArrivalRate = $ArrivalCount / $MeasurePeriod;
$ServiceTime = 0.10; # seconds
$ServiceDemand = $ServiceVisits * $ServiceTime; # seconds
# Check the queue meets stability condition
$ServiceCap = 1 / $ServiceDemand;
if($ArrivalRate >= $ServiceCap) {
print "Error: Arrival rate $ArrivalRate ";
print "exceeds service capacity ServiceCap !!\n";
exit;
}
$NodeName = "FIFO";
$WorkName = "Work";
# Initialize PDQ internal variables
pdq::Init("M/M/1 on p.269 PDQ Book");
# Define the queueing circuit type and workload
pdq::CreateOpen($WorkName, $ArrivalRate);
# Define the FIFO queue
pdq::CreateNode($NodeName, $pdq::CEN, $pdq::FCFS);
# Define service demand due to the workload at FIFO
pdq::SetDemand($NodeName, $WorkName, $ServiceDemand);
# Change the units used by PDQ::Report()
pdq::SetWUnit("Requests");
pdq::SetTUnit("Seconds");
# Solve the PDQ model
# NOTE: Must use CANON-ical method since this is an open circuit
pdq::Solve($pdq::CANON);
## PDQ OUTPUTS ##
# Generate a report
pdq::Report();
| 36.405797 | 79 | 0.566879 |
ed2a6502acf568f215ac383bac27ba30ff0e4a62 | 1,267 | pm | Perl | auto-lib/Azure/Batch/UpdateBatchAccount.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Azure/Batch/UpdateBatchAccount.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Azure/Batch/UpdateBatchAccount.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| 1 | 2021-04-08T15:26:39.000Z | 2021-04-08T15:26:39.000Z | package Azure::Batch::UpdateBatchAccount;
use Moose;
use MooseX::ClassAttribute;
has 'accountName' => (is => 'ro', required => 1, isa => 'Str',
traits => [ 'Azure::ParamInPath' ],
);
has 'api_version' => (is => 'ro', required => 1, isa => 'Str', default => '2017-09-01',
traits => [ 'Azure::ParamInQuery', 'Azure::LocationInResponse' ], location => 'api-version',
);
has 'parameters' => (is => 'ro', required => 1, isa => 'Azure::Batch::BatchAccountUpdateParameters',
traits => [ 'Azure::ParamInBody' ],
);
has 'resourceGroupName' => (is => 'ro', required => 1, isa => 'Str',
traits => [ 'Azure::ParamInPath' ],
);
has 'subscriptionId' => (is => 'ro', required => 1, isa => 'Str',
traits => [ 'Azure::ParamInPath' ],
);
class_has _api_uri => (is => 'ro', default => '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}');
class_has _returns => (is => 'ro', isa => 'HashRef', default => sub { {
200 => 'Azure::Batch::UpdateBatchAccountResult',
default => 'Azure::Batch::UpdateBatchAccountResult',
} });
class_has _is_async => (is => 'ro', default => 0);
class_has _api_method => (is => 'ro', default => 'PATCH');
1;
| 39.59375 | 172 | 0.599842 |
ed1635298809625b890f97e1976fccf6ace2f2d5 | 32,150 | pl | Perl | tools/gen_funcs.pl | svandecappelle/go-testdeep | 716933871b2e396554bd8c35ebd1f2c700b77b0c | [
"BSD-2-Clause"
]
| null | null | null | tools/gen_funcs.pl | svandecappelle/go-testdeep | 716933871b2e396554bd8c35ebd1f2c700b77b0c | [
"BSD-2-Clause"
]
| null | null | null | tools/gen_funcs.pl | svandecappelle/go-testdeep | 716933871b2e396554bd8c35ebd1f2c700b77b0c | [
"BSD-2-Clause"
]
| null | null | null | #!/usr/bin/env perl
# Copyright (c) 2018, Maxime Soulé
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
use strict;
use warnings;
use autodie;
use 5.010;
use IPC::Open2;
die "usage $0 [-h]\n" if @ARGV != 0;
(my $REPO_DIR = $0) =~ s,/[^/]+\z,/..,;
-d $REPO_DIR or die "Cannot find repository directory ($REPO_DIR)\n";
my $SITE_REPO_DIR = "$REPO_DIR/../go-testdeep-site";
unless (-d $SITE_REPO_DIR)
{
if ($ENV{PROD_SITE})
{
die "*** Cannot PROD_SITE as $SITE_REPO_DIR not found!\n";
}
warn "*** WARNING: cannot find $SITE_REPO_DIR. Disabling site upgrade.\n";
undef $SITE_REPO_DIR;
}
my $DIR = "$REPO_DIR/td";
-d $DIR or die "Cannot find td/ directory ($DIR)\n";
my $HEADER = <<'EOH';
// Copyright (c) 2018-2021, Maxime Soulé
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
// DO NOT EDIT!!! AUTOMATICALLY GENERATED!!!
EOH
my $args_comment_src = <<'EOC';
%arg{args...} are optional and allow to name the test. This name is
used in case of failure to qualify the test. If %code{len(args) > 1} and
the first item of %arg{args} is a string and contains a '%' rune then
%godoc{fmt.Fprintf} is used to compose the name, else %arg{args} are passed to
%godoc{fmt.Fprint}. Do not forget it is the name of the test, not the
reason of a potential failure.
EOC
my $ARGS_COMMENT_GD = doc2godoc($args_comment_src);
my $ARGS_COMMENT_MD = doc2md($args_comment_src);
# These functions are variadics, but only with one possible param. In
# this case, discard the variadic property and use a default value for
# this optional parameter.
my %IGNORE_VARIADIC = (Between => 'td.BoundsInIn',
N => 0,
Re => 'nil',
TruncTime => 0);
# Smuggler operators (automatically filled)
my %SMUGGLER_OPERATORS;
# These operators should be renamed when used as *T method
my %RENAME_METHOD = (Lax => 'CmpLax');
# These operators do not have *T method nor Cmp shortcut
my %ONLY_OPERATORS = map { $_ => 1 } qw(Catch Delay Ignore Tag);
my @INPUT_LABELS = qw(nil bool str int float cplx
array slice map struct ptr if chan func);
my %INPUTS;
@INPUTS{@INPUT_LABELS} = ();
opendir(my $dh, $DIR);
my(%funcs, %operators, %consts, %forbiddenOpsInJSON);
while (readdir $dh)
{
if (/^td_.*\.go\z/ and not /_test.go\z/)
{
my $contents = do { local $/; open(my $fh, '<', "$DIR/$_"); <$fh> };
# Load the operators forbidden inside JSON()
if ($_ eq 'td_json.go')
{
$contents =~ /^var forbiddenOpsInJSON = map\[string\]string\{(.*?)^\}/ms
or die "$_: forbiddenOpsInJSON map not found\n";
@forbiddenOpsInJSON{$1 =~ /"([^"]+)":/g} = ();
}
while ($contents =~ /^const \(\n(.+)^\)\n/gms)
{
@consts{$1 =~ /^\t([A-Z]\w+)/mg} = ();
}
my %ops;
while ($contents =~ m,^// summary\((\w+)\): (.*\n(?://.*\n)*),gm)
{
my($op, $summary) = ($1, $2);
$summary =~ s,^// input\(.*,,sm;
$ops{$op} = process_summary($summary =~ s,\n(?://|\z),,gr);
}
my %inputs;
while ($contents =~ m,^// input\((\w+)\): (.*\n(?://.*\n)*),gm)
{
my $op = $1;
foreach my $in (split(/\s*,\s*/, $2 =~ s,\n(?://|\z),,gr))
{
if ($in eq 'all')
{
@{$inputs{$op}}{keys %INPUTS} = ('✓') x keys %INPUTS;
next;
}
if ($in =~ /^(\w+)\((.*)\)\z/)
{
$inputs{$op}{$1} = process_summary($2);
$in = $1;
}
else
{
$inputs{$op}{$in} = '✓';
}
exists $INPUTS{$in} or die "$_: input($op) unknow input '$in'\n";
$inputs{$op}{if} //= '✓'; # interface
}
}
my $num_smugglers = keys %SMUGGLER_OPERATORS;
while ($contents =~ m,^(// ([A-Z]\w*) .*\n(?://.*\n)*)func \2\((.*?)\) TestDeep \{\n,gm)
{
exists $ops{$2} or die "$_: no summary($2) found\n";
exists $inputs{$2} or die "$_: no input($2) found\n";
my($doc, $func, $params) = ($1, $2, $3);
if ($doc =~ /is a smuggler operator/)
{
$SMUGGLER_OPERATORS{$func} = 1;
}
my @args;
foreach my $arg (split(/, /, $params))
{
my %arg;
@arg{qw(name type)} = split(/ /, $arg, 2);
if (defined $arg{type}
and $arg{variadic} = $arg{type} =~ s/^\.{3}//)
{
if (exists $IGNORE_VARIADIC{$func})
{
$arg{default} = $IGNORE_VARIADIC{$func};
delete $arg{variadic};
}
}
push(@args, \%arg);
}
my $last_type;
foreach my $arg (reverse @args)
{
if (defined(my $arg_type = $arg->{type}) and not $arg->{variadic})
{
if (defined $last_type and $arg_type eq $last_type)
{
delete $arg->{type};
}
$last_type = $arg_type;
}
}
$funcs{$func}{args} = \@args unless $ONLY_OPERATORS{$func};
die "TAB detected in $func operator documentation" if $doc =~ /\t/;
$operators{$func} = {
name => $func,
summary => delete $ops{$func},
input => delete $inputs{$func},
doc => $doc,
signature => "func $func($params) TestDeep",
args => \@args,
};
}
if (%ops)
{
die "$_: summary found without operator definition: "
. join(', ', keys %ops) . "\n";
}
if (%inputs)
{
die "$_: input found without operator definition: "
. join(', ', keys %inputs) . "\n";
}
if ($contents =~ /^\ttdSmugglerBase/m
and $num_smugglers == keys %SMUGGLER_OPERATORS)
{
die "$_: this file should contain at least one smuggler operator\n";
}
}
}
closedir($dh);
%funcs or die "No TestDeep golang source file found!\n";
my $funcs_contents = my $t_contents = <<EOH;
$HEADER
package td
import (
\t"time"
)
EOH
$funcs_contents .= <<EOV;
// allOperators lists the ${\scalar(keys(%funcs) + keys %ONLY_OPERATORS)} operators.
// nil means not usable in JSON().
var allOperators = map[string]interface{}{
${\join('', map
{ qq("$_": ) . (exists $forbiddenOpsInJSON{$_} ? 'nil' : $_) . ",\n" }
sort keys(%funcs), keys %ONLY_OPERATORS)}
}
EOV
my @sorted_funcs = sort { lc($a) cmp lc($b) } keys %funcs;
foreach my $func (@sorted_funcs)
{
my $func_name = "Cmp$func";
my $method_name = $RENAME_METHOD{$func} // $func;
my $cmp_args = 'got';
if (@{$funcs{$func}{args}})
{
foreach my $arg (@{$funcs{$func}{args}})
{
if (defined $arg->{type})
{
if ($arg->{type} ne 'interface{}' or $arg->{variadic})
{
$cmp_args .= ' interface{}';
}
last
}
}
}
else
{
$cmp_args .= ' interface{}';
}
my $call_args = '';
my @cmpt_args;
foreach my $arg (@{$funcs{$func}{args}})
{
$call_args .= ', ' unless $call_args eq '';
$call_args .= $arg->{name};
push(@cmpt_args, { name => $arg->{name} });
$cmp_args .= ", $arg->{name} ";
if ($arg->{variadic})
{
$call_args .= '...';
$cmp_args .= '[]';
}
$cmp_args .= $arg->{type} if defined $arg->{type};
}
my $cmp_doc = <<EOF;
Cmp$func is a shortcut for:
td.Cmp(t, got, td.$func($call_args), args...)
EOF
$funcs_contents .= "\n" . go_comment($cmp_doc) . <<EOF;
// See https://pkg.go.dev/github.com/maxatome/go-testdeep/td#$func for details.
EOF
$cmp_doc .= <<EOF; # operator doc
See above for details.
EOF
my $t_doc = <<EOF;
$method_name is a shortcut for:
t.Cmp(got, td.$func($call_args), args...)
EOF
$t_contents .= "\n" . go_comment($t_doc) . <<EOF;
// See https://pkg.go.dev/github.com/maxatome/go-testdeep/td#$func for details.
EOF
$t_doc .= <<EOF; # operator doc
See above for details.
EOF
my $func_comment;
my $last_arg = $funcs{$func}{args}[-1];
if (exists $last_arg->{default})
{
$func_comment .= <<EOF;
$func() optional parameter "$last_arg->{name}" is here mandatory.
$last_arg->{default} value should be passed to mimic its absence in
original $func() call.
EOF
}
$func_comment .= <<EOF;
Returns true if the test is OK, false if it fails.
EOF
$operators{$func}{cmp}{name} = "Cmp$func";
$operators{$func}{cmp}{doc} = $cmp_doc . $func_comment . $ARGS_COMMENT_MD;
$operators{$func}{cmp}{signature} = my $cmp_sig =
"func Cmp$func(t TestingT, $cmp_args, args ...interface{}) bool";
$operators{$func}{cmp}{args} = \@cmpt_args;
$funcs_contents .= go_comment($func_comment . $ARGS_COMMENT_GD) . <<EOF;
$cmp_sig {
\tt.Helper()
\treturn Cmp(t, got, $func($call_args), args...)
}
EOF
$operators{$func}{t}{name} = $method_name;
$operators{$func}{t}{doc} = $t_doc . $func_comment . $ARGS_COMMENT_MD;
$operators{$func}{t}{signature} = my $t_sig =
"func (t *T) $method_name($cmp_args, args ...interface{}) bool";
$operators{$func}{t}{args} = \@cmpt_args;
$t_contents .= go_comment($func_comment . $ARGS_COMMENT_GD) . <<EOF;
$t_sig {
\tt.Helper()
\treturn t.Cmp(got, $func($call_args), args...)
}
EOF
}
my $examples = do { open(my $efh, '<', "$DIR/example_test.go"); local $/; <$efh> };
my $funcs_reg = join('|', @sorted_funcs);
my($imports) = ($examples =~ /^(import \(.+?^\))$/ms);
while ($examples =~ /^func Example($funcs_reg)(_\w+)?\(\) \{\n(.*?)^\}$/gms)
{
push(@{$funcs{$1}{examples}}, { name => $2 // '', code => $3 });
}
{
open(my $fh, "| gofmt -s > '$DIR/cmp_funcs.go'");
print $fh $funcs_contents;
close $fh;
say "$DIR/cmp_funcs.go generated";
}
{
open(my $fh, "| gofmt -s > '$DIR/t.go'");
print $fh $t_contents;
close $fh;
say "$DIR/t.go generated";
}
my $funcs_test_contents = <<EOH;
$HEADER
package td_test
$imports
EOH
my $t_test_contents = $funcs_test_contents;
my($rep, $reb, $rec);
$rep = qr/\( [^()]* (?:(??{ $rep }) [^()]* )* \)/x; # recursively matches (...)
$reb = qr/\[ [^][]* (?:(??{ $reb }) [^][]* )* \]/x; # recursively matches [...]
$rec = qr/\{ [^{}]* (?:(??{ $rec }) [^{}]* )* \}/x; # recursively matches {...}
my $rparam =qr/"(?:\\.|[^"]+)*" # "string"
|'(?:\\.|[^']+)*' # 'char'
|`[^`]*` # `string`
|&[a-zA-Z_]\w*(?:\.\w+)?(?:$rec)? # &Struct{...}, &variable
|\[[^][]*\](?:interface\{\}|\w+)$rec # []Array{...}
|\[\]byte\("[^"]+"\) # []byte("...")
|map${reb}\w+$rec # map[...]Type{...}
|func\([^)]*\)[^{]+$rec # func fn (...) ... { ... }
|[a-zA-Z_]\w*(?:\.\w+)?(?:$rec|$rep)? # Str{...}, Fn(...), pkg.var
|[\w.*+-\/]+ # 123*pkg.var...
|$rep$rep # (type)(value)
/x;
sub extract_params
{
my($func, $params_str) = @_;
my $str = substr($params_str, 1, -1);
$str ne '' or return;
my @params;
for (;;)
{
if ($str =~ /\G\s*($rparam)\s*(,|\z)/omsgx)
{
push(@params, $1);
$2 or return @params;
}
else
{
die "Cannot extract params from $func: $params_str\n"
}
}
}
foreach my $func (@sorted_funcs)
{
my $args = $funcs{$func}{args};
my $method = $RENAME_METHOD{$func} // $func;
foreach my $example (@{$funcs{$func}{examples}})
{
my $name = $example->{name};
foreach my $info ([ "td.Cmp$func(t, ", "Cmp$func", \$funcs_test_contents ],
[ "t.$method(", "T_$method",\$t_test_contents ])
{
(my $code = $example->{code}) =~
s%td\.Cmp\(t,\s+($rparam),\s+td\.$func($rep)%
my @params = extract_params("$func$name", $2);
my $repl = $info->[0] . $1;
for (my $i = 0; $i < @$args; $i++)
{
$repl .= ', ';
if ($args->[$i]{variadic})
{
if (defined $params[$i])
{
$repl .= '[]' . $args->[$i]{type} . '{'
. join(', ', @params[$i .. $#params])
. '}';
}
else
{
$repl .= 'nil';
}
last
}
$repl .= $params[$i]
// $args->[$i]{default}
// die("Internal error, no param: "
. "$func$name -> #$i/$args->[$i]{name}!\n");
}
$repl
%egs;
${$info->[2]} .= <<EOF;
func Example$info->[1]$name() {
$code}
EOF
}
}
}
{
# Cmp* examples
open(my $fh, "| gofmt -s > '$DIR/example_cmp_test.go'");
print $fh $funcs_test_contents;
close $fh;
say "$DIR/example_cmp_test.go generated";
}
{
# T.* examples
$t_test_contents =~ s/t := &testing\.T\{\}/t := td.NewT(&testing\.T\{\})/g;
$t_test_contents =~ s/td\.Cmp\(t,/t.Cmp(/g;
open(my $fh, "| gofmt -s > '$DIR/example_t_test.go'");
print $fh $t_test_contents;
close $fh;
say "$DIR/example_t_test.go generated";
}
#
# Check "args..." comment is the same everywhere it needs to be
my @args_errors;
$ARGS_COMMENT_GD = go_comment($ARGS_COMMENT_GD);
foreach my $go_file (do { opendir(my $dh, $DIR);
grep /(?<!_test)\.go\z/, readdir $dh })
{
my $contents = do { local $/; open(my $fh, '<', "$DIR/$go_file"); <$fh> };
while ($contents =~ m,\n((?://[^\n]*\n)*)
func\ ([A-Z]\w+|\(t\ \*T\)\ [A-Z]\w+)($rep),xg)
{
my($comment, $func, $params) = ($1, $2, $3);
next if $func eq '(t *T) CmpDeeply' or $func eq 'CmpDeeply';
if ($params =~ /\Qargs ...interface{})\E\z/)
{
#chomp $comment;
if (substr($comment, - length($ARGS_COMMENT_GD)) ne $ARGS_COMMENT_GD)
{
push(@args_errors, "$go_file: $func");
}
}
}
}
if (@args_errors)
{
die "*** At least one args comment is missing or not conform:\n- "
. join("\n- ", @args_errors)
. "\n";
}
my $common_links = do
{
my $base_url = 'https://pkg.go.dev/github.com/maxatome/go-testdeep';
my $td_url = "$base_url/td";
# Specific types and functions
join("\n", map "[`$_`]: $td_url#$_", qw(T TestDeep Cmp))
. "\n\n"
# Helpers
. join("\n", map "[`$_`]: $base_url/helpers/$_",
qw(tdhttp tdsuite tdutil))
. "\n\n"
# Specific links
. "[`BeLax` config flag]: $td_url#ContextConfig\n"
. "[`error`]: https://pkg.go.dev/builtin/#error\n"
. "\n\n"
# Foreign types
. join("\n", map "[`$_->[0]`]: https://pkg.go.dev/$_->[1]",
[ 'fmt.Stringer' => 'fmt/#Stringer' ],
[ 'time.Time' => 'time/#Time' ],
[ 'math.NaN' => 'math/#NaN' ])
. "\n";
};
my @sorted_operators = sort { lc($a) cmp lc($b) } keys %operators;
my $md_links = do
{
$common_links
. join("\n", map qq([`$_`]: {{< ref "$_" >}}), @sorted_operators)
. "\n\n"
# Cmp* functions
. join("\n", map qq([`Cmp$_`]: {{< ref "$_#cmp\L$_\E-shortcut" >}}),
@sorted_funcs)
. "\n\n"
# T.Cmp* methods
. join("\n", map
{
my $m = $RENAME_METHOD{$_} // $_;
qq([`T.$m`]: {{< ref "$_#t\L$m\E-shortcut" >}})
}
@sorted_funcs);
};
my $gh_links = do
{
my $td_url = 'https://go-testdeep.zetta.rocks/operators/';
$common_links
. join("\n", map qq([`$_`]: $td_url\L$_/), @sorted_operators)
. "\n\n"
# Cmp* functions
. join("\n", map qq([`Cmp$_`]: $td_url\L$_/#cmp$_-shortcut), @sorted_funcs)
. "\n\n"
# T.Cmp* methods
. join("\n", map
{
my $m = $RENAME_METHOD{$_} // $_;
qq([`T.$m`]: $td_url\L$_/#t$m-shortcut)
}
@sorted_funcs);
};
# README.md
{
my $readme = do { local $/; open(my $fh, '<', "$REPO_DIR/README.md"); <$fh> };
# Links
$readme =~ s{(<!-- links:begin -->).*(<!-- links:end -->)}
{$1\n$gh_links\n$2}s;
open(my $fh, '>', "$REPO_DIR/README.md.new");
print $fh $readme;
close $fh;
rename "$REPO_DIR/README.md.new", "$REPO_DIR/README.md";
say "$REPO_DIR/README.md modified";
}
# Hugo
if (defined $SITE_REPO_DIR)
{
my $op_examples = do { local $/;
open(my $fh, '<', "$DIR/example_test.go");
<$fh> };
# Reload generated examples so they are properly gofmt'ed
my $cmp_examples = do { local $/;
open(my $fh, '<', "$DIR/example_cmp_test.go");
<$fh> };
my $t_examples = do { local $/;
open(my $fh, '<', "$DIR/example_t_test.go");
<$fh> };
foreach my $operator (@sorted_operators)
{
# Rework each operator doc
my $doc = process_doc($operators{$operator});
open(my $fh, '>', "$SITE_REPO_DIR/docs_src/content/operators/$operator.md");
print $fh <<EOM;
---
title: "$operator"
weight: 10
---
```go
$operators{$operator}{signature}
```
$doc
> See also [<i class='fas fa-book'></i> $operator godoc](https://pkg.go.dev/github.com/maxatome/go-testdeep/td#$operator).
EOM
my @examples;
my $re = qr/^func Example${operator}(?:_(\w+))?\(\) \{\n(.+?)^\}$/ms;
while ($op_examples =~ /$re/g)
{
my $name = ucfirst($1 // 'Base');
push(@examples, <<EOE);
{{%expand "$name example" %}}```go
${2}
```{{% /expand%}}
EOE
}
if (@examples)
{
printf $fh "### Example%s\n\n", @examples > 1 ? 's' : '';
print $fh @examples;
}
if (my $cmp = $operators{$operator}{cmp})
{
my $doc = process_doc($cmp);
print $fh <<EOM;
## $cmp->{name} shortcut
```go
$cmp->{signature}
```
$doc
> See also [<i class='fas fa-book'></i> $cmp->{name} godoc](https://pkg.go.dev/github.com/maxatome/go-testdeep/td#$cmp->{name}).
EOM
@examples = ();
my $re = qr/func ExampleCmp${operator}(?:_(\w+))?\(\) \{\n(.+?)^\}$/ms;
while ($cmp_examples =~ /$re/g)
{
my $name = ucfirst($1 // 'Base');
push(@examples, <<EOE);
{{%expand "$name example" %}}```go
${2}
```{{% /expand%}}
EOE
}
if (@examples)
{
printf $fh "### Example%s\n\n", @examples > 1 ? 's' : '';
print $fh @examples;
}
}
if (my $t = $operators{$operator}{t})
{
my $doc = process_doc($t);
print $fh <<EOM;
## T.$t->{name} shortcut
```go
$t->{signature}
```
$doc
> See also [<i class='fas fa-book'></i> T.$t->{name} godoc](https://pkg.go.dev/github.com/maxatome/go-testdeep/td#T.$t->{name}).
EOM
@examples = ();
my $re = qr/func ExampleT_$t->{name}(?:_(\w+))?\(\) \{\n(.+?)^\}$/ms;
while ($t_examples =~ /$re/g)
{
my $name = ucfirst($1 // 'Base');
push(@examples, <<EOE);
{{%expand "$name example" %}}```go
${2}
```{{% /expand%}}
EOE
}
if (@examples)
{
printf $fh "### Example%s\n\n", @examples > 1 ? 's' : '';
print $fh @examples;
}
}
close $fh;
}
# Dump operators
{
my $op_list_file = "$SITE_REPO_DIR/docs_src/content/operators/_index.md";
my $op_list = do { local $/; open(my $fh, '<', $op_list_file); <$fh> };
$op_list =~ s{(<!-- operators:begin -->).*(<!-- operators:end -->)}
{
"$1\n"
. join('',
map qq\n: $operators{$_}{summary}\n\n!,
@sorted_operators)
. $2
}se or die "operators tags not found in $op_list_file\n";
$op_list =~ s{(<!-- smugglers:begin -->).*(<!-- smugglers:end -->)}
{
"$1\n"
. join('',
map qq\n: $operators{$_}{summary}\n\n!,
sort { lc($a) cmp lc($b) }
keys %SMUGGLER_OPERATORS)
. "$md_links\n$2"
}se or die "smugglers tags not found in $op_list_file\n";
open(my $fh, '>', "$op_list_file.new");
print $fh $op_list;
close $fh;
rename "$op_list_file.new", $op_list_file;
}
# Dump matrices
{
my $matrix_file = "$SITE_REPO_DIR/docs_src/content/operators/matrix.md";
my $matrix = do { local $/; open(my $fh, '<', $matrix_file); <$fh> };
my $header = <<'EOH';
| Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
| ------------------- | --- | ---- | ------ | -------- | ------ | -------- | ----- | ----- | --- | ------ | ------- | ---------- | ---- | ---- | -------- |
EOH
$matrix =~ s{(<!-- op-go-matrix:begin -->).*(<!-- op-go-matrix:end -->)}
{
my $repl = "$1\n";
my $num = 0;
foreach my $op (@sorted_operators)
{
$repl .= $header if $num++ % 10 == 0;
$repl .= "| [`$op`]";
for my $label (@INPUT_LABELS)
{
$repl .= " | "
. ($operators{$op}{input}{$label} // '✗');
}
$repl .= " | [`$op`] |\n";
}
"$repl\n$md_links\n$2"
}se or die "op-go-matrix tags not found in $matrix_file\n";
my %by_input;
while (my($op, $info) = each %operators)
{
while (my($label, $comment) = each %{$operators{$op}{input}})
{
$by_input{$label}{$op} = $comment;
}
}
$matrix =~ s{(<!-- go-(\w+)-matrix:begin -->).*(<!-- go-\2-matrix:end -->)}
{
my $repl = "$1\n";
foreach my $op (sort keys %{$by_input{$2}})
{
my $comment = $by_input{$2}{$op};
next if $comment eq 'todo';
if ($comment eq '✓')
{
next if $2 eq 'if';
$comment = '';
}
elsif ($2 eq 'if')
{
$comment =~ s/^✓ \+/ →/;
}
else
{
substr($comment, 0, 0, ' only ');
}
$repl .= "- [`$op`]$comment\n";
}
$repl . $3
}gse or die "go-op-matrix tags not found in $matrix_file\n";
open(my $fh, '>', "$matrix_file.new");
print $fh $matrix;
close $fh;
rename "$matrix_file.new", $matrix_file;
}
# tdhttp example
{
my $example = do
{
open(my $fh, '<', "$REPO_DIR/helpers/tdhttp/example_test.go");
local $/;
<$fh>
};
my($import) = $example =~ /^(import \(.*?^\))$/ms;
$import or die "tdhttp example, import not found!\n";
$example =~ s/.*^func Example\(\) \{\n\tt := &testing.T\{\}\n\n//ms
or die "tdhttp example, func Example() not found!\n";
$example =~ s/fmt\.Printf/t.Logf/g
or die "tdhttp example, fmt.Printf not found\n";
$example =~ s/fmt\.Println/t.Log/g
or die "tdhttp example, fmt.Println not found\n";
$example =~ s,\n\t// Output:\n.*,},s
or die "tdhttp example, Output: not found\n";
my $md_file = "$SITE_REPO_DIR/docs_src/content/helpers/_index.md";
my $final = do { open(my $fh, '<', $md_file); local $/; <$fh> } =~
s{(<!-- tdhttp:begin -->).*(<!-- tdhttp:end -->)}
<$1
{{%expand "Main example" %}}```go
package myapi
$import
func TestMyAPI(t *testing.T) {
$example
```{{% /expand%}}
$2>rs or die "tdhttp example not found in $md_file!";
open(my $out, '>', "$md_file.new");
print $out $final;
close $out;
rename "$md_file.new", $md_file;
}
# Final publish
if ($ENV{PROD_SITE})
{
# Delegate to go-testdeep-site repository
chdir $SITE_REPO_DIR;
exec './publish.sh';
}
}
sub go_comment
{
shift =~ s,^(.?),$1 ne '' ? "// $1" : '//',egmr
}
sub doc2godoc
{
my $doc = shift;
state $repl = { arg => sub { qq("$_[0]") },
code => sub { $_[0] },
godoc => sub { $_[0] } };
$doc =~ s/%([a-z]+)\{([^}]+)\}/($repl->{$1} or die $1)->($2)/egr;
}
sub doc2md
{
my $doc = shift;
state $repl = { arg => sub { "*$_[0]*" },
code => sub { "`$_[0]`" },
godoc => sub
{
my($pkg, $fn) = split('\.', $_[0], 2);
"[`$_[0]`](https://pkg.go.dev/$pkg/#$fn)"
} };
$doc =~ s/%([a-z]+)\{([^}]+)\}/($repl->{$1} or die $1)->($2)/egr;
}
sub process_summary
{
my $text = shift;
$text =~ s/(time\.Time|fmt.Stringer|error)/[`$1`]/g;
$text =~ s/BeLax config flag/[`BeLax` config flag]/;
$text =~ s/(\[\]byte|\bnil\b)/`$1`/g;
return $text;
}
sub process_doc
{
my $op = shift;
my $doc = $op->{doc};
$doc =~ s,^// ?,,mg if $doc =~ m,^//,;
$doc =~ s/\n{3,}/\n\n/g;
my($inEx, $inBul);
$doc =~ s{^(?:(\n?\S)
|(\n?)(\s+)(\S?))}
<
if (defined $1)
{
if ($inEx) { $inEx = ''; "```\n$1" }
elsif ($inBul) { $inBul = ''; "\n$1" }
else { $1 }
}
else
{
if ($inEx) { $2 . substr($3, length($inEx)) . $4 }
elsif ($inBul) { $2 . substr($3, length($inBul)) . $4 }
elsif ($4 eq '-') { $inBul = $3; "\n-" }
else { $inEx = $3; "$2```go\n$4" }
}
>gemx;
$doc .= "```\n" if $inEx;
my @codes;
$doc =~ s/^(```go\n.*?^```\n)/push(@codes, $1); "CODE<$#codes>"/gems;
$doc =~ s<
(\$\^[A-Za-z]+) # $1
| (\b(${\join('|', grep !/^JSON/, keys %operators)}
|JSON(?!\s+(?:value|data|filename|object|representation|specification)))
(?:\([^)]*\)|\b)) # $2 $3
| ((?:(?:\[\])+|\*+|\b)(?:bool\b
|u?int(?:\*|(?:8|16|32|64)?\b)
|float(?:\*|(?:32|64)\b)
|complex(?:\*|(?:64|128)\b)
|string\b
|rune\b
|byte\b
|interface\{\})
|\(\*byte\)\(nil\)
|\bmap\[string\]interface\{\}
|\b(?:len|cap)\(\)
|\bnil\b
|\$(?:\d+|[a-zA-Z_]\w*)) # $4
| ((?:\b|\*)fmt\.Stringer
|\breflect\.Type
|\bregexp\.MustCompile
|\*regexp\.Regexp
|\btime\.[A-Z][a-zA-Z]+
|\bjson\.(?:Unm|M)arshal
|\bio\.Reader
|\bioutil\.Read(?:All|File))\b # $5
| (\berror\b) # $6
| (\bTypeBehind(?:\(\)|\b)) # $7
| \b(${\join('|', keys %consts)})\b # $8
| \b(smuggler\s+operator)\b # $9
| \b(TestDeep\s+operators?)\b # $10
| (?|\*?(SmuggledGot)|(Flatten))\b # $11
>{
if ($1)
{
"`$1`"
}
elsif ($2)
{
qq!
}
elsif ($4)
{
"`$4`"
}
elsif ($5)
{
my $all = $5;
my($pkg, $fn) = split('\.', $all, 2);
$pkg =~ s/^\*//;
"[`$all`](https://pkg.go.dev/$pkg/#$fn)"
}
elsif ($6)
{
"[`$6`](https://pkg.go.dev/builtin/#error)"
}
elsif ($7)
{
qq!
}
elsif ($8)
{
"[`$8`](https://pkg.go.dev/github.com/maxatome/go-testdeep/td#BoundsKind)"
}
elsif ($9)
{
qq!
}
elsif ($10)
{
qq!
}
elsif ($11)
{
qq!
}
}geox;
if ($op->{args} and @{$op->{args}})
{
$doc =~ s/"(${\join('|', map quotemeta($_->{name}),
@{$op->{args}})})"/*$1*/g;
}
return $doc =~ s/^CODE<(\d+)>/go_format($op, $codes[$1])/egmr;
}
sub go_format
{
my($operator, $code) = @_;
$code =~ s/^```go\n// or return $code;
$code =~ s/\n```\n\z//;
my $pid = open2(my $fmt_out, my $fmt_in, 'gofmt', '-s');
print $fmt_in <<EOM;
package x
//line $operator->{name}.go:1
func x() {
$code
}
EOM
close $fmt_in;
(my $new_code = do { local $/; <$fmt_out> }) =~ s/[^\t]+//;
$new_code =~ s/\n\}\n\z//;
$new_code =~ s/^\t//gm;
waitpid $pid, 0;
if ($? != 0)
{
die <<EOD
gofmt of following example for function $operator->{name} failed:
$code
EOD
}
$new_code =~ s/^(\t+)/" " x length $1/gme;
if ($new_code ne $code)
{
die <<EOD;
Code example function $operator->{name} is not correctly indented:
$code
------------------ should be ------------------
$new_code
EOD
}
return "```go\n$new_code\n```\n";
}
| 29.360731 | 155 | 0.420933 |
73ddfadc2a2c4140fa9f32ab09f82526fa8c55ba | 59,210 | pm | Perl | lib/Mail/SpamAssassin/BayesStore/SQL.pm | ToToL/spamassassin | fa5a88c0c3fac815e2a2b69b1bb795f2fffa3684 | [
"Apache-2.0"
]
| 196 | 2015-01-13T03:55:31.000Z | 2022-03-29T23:56:13.000Z | lib/Mail/SpamAssassin/BayesStore/SQL.pm | ToToL/spamassassin | fa5a88c0c3fac815e2a2b69b1bb795f2fffa3684 | [
"Apache-2.0"
]
| 2 | 2015-03-23T21:32:14.000Z | 2018-10-18T15:37:36.000Z | lib/Mail/SpamAssassin/BayesStore/SQL.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::BayesStore::SQL - SQL Bayesian Storage Module Implementation
=head1 DESCRIPTION
This module implements a SQL based bayesian storage module.
=cut
package Mail::SpamAssassin::BayesStore::SQL;
use strict;
use warnings;
# use bytes;
use re 'taint';
use Errno qw(EBADF);
use Digest::SHA qw(sha1);
use Mail::SpamAssassin::BayesStore;
use Mail::SpamAssassin::Logger;
our @ISA = qw( Mail::SpamAssassin::BayesStore );
use constant HAS_DBI => eval { require DBI; };
=head1 METHODS
=head2 new
public class (Mail::SpamAssassin::BayesStore::SQL) new (Mail::Spamassassin::Plugin::Bayes $bayes)
Description:
This methods creates a new instance of the Mail::SpamAssassin::BayesStore::SQL
object. It expects to be passed an instance of the Mail::SpamAssassin:Bayes
object which is passed into the Mail::SpamAssassin::BayesStore parent object.
This method sets up the database connection and determines the username to
use in queries.
=cut
sub new {
my $class = shift;
$class = ref($class) || $class;
my $self = $class->SUPER::new(@_);
$self->{supported_db_version} = 3;
$self->{db_writable_p} = 0;
if (!$self->{bayes}->{conf}->{bayes_sql_dsn}) {
dbg("bayes: invalid config, must set bayes_sql_dsn config variable\n");
return;
}
$self->{_dsn} = $self->{bayes}->{conf}->{bayes_sql_dsn};
$self->{_dbuser} = $self->{bayes}->{conf}->{bayes_sql_username};
$self->{_dbpass} = $self->{bayes}->{conf}->{bayes_sql_password};
$self->{_dbh} = undef;
unless (HAS_DBI) {
dbg("bayes: unable to connect to database: DBI module not available: $!");
}
if ($self->{bayes}->{conf}->{bayes_sql_override_username}) {
$self->{_username} = $self->{bayes}->{conf}->{bayes_sql_override_username};
}
else {
$self->{_username} = $self->{bayes}->{main}->{username};
# Need to make sure that a username is set, so just in case there is
# no username set in main, set one here.
if (!defined $self->{_username} || $self->{_username} eq '') {
$self->{_username} = "GLOBALBAYES";
}
}
dbg("bayes: using username: ".$self->{_username});
return $self;
}
=head2 tie_db_readonly
public instance (Boolean) tie_db_readonly ();
Description:
This method ensures that the database connection is properly setup
and working. If necessary it will initialize a user's bayes variables
so that they can begin using the database immediately.
=cut
sub tie_db_readonly {
my ($self) = @_;
return 0 unless (HAS_DBI);
if ($self->{_dbh}) {
# already connected, but connection has now become readonly
$self->{db_writable_p} = 0;
return 1;
}
my $main = $self->{bayes}->{main};
my $timer_tie_ro = $main->time_method('b_tie_ro');
$self->read_db_configs();
return 0 unless ($self->_connect_db());
my $db_ver = $self->_get_db_version();
$self->{db_version} = $db_ver;
dbg("bayes: found bayes db version ".$self->{db_version});
if ( $db_ver != $self->DB_VERSION ) {
warn("bayes: database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
$self->untie_db();
return 0;
}
unless ($self->_initialize_db(0)) {
dbg("bayes: unable to initialize database for ".$self->{_username}." user, aborting!");
$self->untie_db();
return 0;
}
return 1;
}
=head2 tie_db_writable
public instance (Boolean) tie_db_writable ()
Description:
This method ensures that the database connection is properly setup
and working. If necessary it will initialize a users bayes variables
so that they can begin using the database immediately.
=cut
sub tie_db_writable {
my ($self) = @_;
return 0 unless (HAS_DBI);
if ($self->{_dbh}) {
# already connected, but now it will be writable
$self->{db_writable_p} = 1;
return 1;
}
my $main = $self->{bayes}->{main};
my $timer_tie_rw = $main->time_method('b_tie_rw');
$self->read_db_configs();
return 0 unless ($self->_connect_db());
my $db_ver = $self->_get_db_version();
$self->{db_version} = $db_ver;
dbg("bayes: found bayes db version ".$self->{db_version});
if ( $db_ver != $self->DB_VERSION ) {
warn("bayes: database version $db_ver is different than we understand (".$self->DB_VERSION."), aborting!");
$self->untie_db();
return 0;
}
unless ($self->_initialize_db(1)) {
dbg("bayes: unable to initialize database for ".$self->{_username}." user, aborting!");
$self->untie_db();
return 0;
}
$self->{db_writable_p} = 1;
return 1;
}
=head2 untie_db
public instance () untie_db ()
Description:
Disconnects from an SQL server.
=cut
sub untie_db {
my ($self) = @_;
return unless (defined($self->{_dbh}));
$self->{db_writable_p} = 0;
$self->{_dbh}->disconnect();
$self->{_dbh} = undef;
}
=head2 calculate_expire_delta
public instance (%) calculate_expire_delta (Integer $newest_atime,
Integer $start,
Integer $max_expire_mult)
Description:
This method performs a calculation on the data to determine the optimum
atime for token expiration.
=cut
sub calculate_expire_delta {
my ($self, $newest_atime, $start, $max_expire_mult) = @_;
my %delta; # use a hash since an array is going to be very sparse
return %delta unless (defined($self->{_dbh}));
my $sql = "SELECT count(*)
FROM bayes_token
WHERE id = ?
AND atime < ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: calculate_expire_delta: SQL Error: ".$self->{_dbh}->errstr());
return %delta;
}
for (my $i = 1; $i <= $max_expire_mult; $i<<=1) {
my $rc = $sth->execute($self->{_userid}, $newest_atime - $start * $i);
unless ($rc) {
dbg("bayes: calculate_expire_delta: SQL error: ".$self->{_dbh}->errstr());
return;
}
my ($count) = $sth->fetchrow_array();
$delta{$i} = $count;
}
$sth->finish();
return %delta;
}
=head2 token_expiration
public instance (Integer, Integer,
Integer, Integer) token_expiration(\% $opts,
Integer $newdelta,
@ @vars)
Description:
This method performs the database specific expiration of tokens based on
the passed in C<$newdelta> and C<@vars>.
=cut
sub token_expiration {
my ($self, $opts, $newdelta, @vars) = @_;
my $num_hapaxes;
my $num_lowfreq;
my $deleted;
# Figure out how old is too old...
my $too_old = $vars[10] - $newdelta; # tooold = newest - delta
# if token atime > newest, reset to newest ...
my $sql = "UPDATE bayes_token SET atime = ?
WHERE id = ?
AND atime > ?";
my $rows = $self->{_dbh}->do($sql, undef, $vars[10], $self->{_userid}, $vars[10]);
unless (defined($rows)) {
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
# Check to make sure the expire won't remove too many tokens
$sql = "SELECT count(token) FROM bayes_token
WHERE id = ?
AND atime < ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
my $rc = $sth->execute($self->{_userid}, $too_old);
unless ($rc) {
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
my ($count) = $sth->fetchrow_array();
$sth->finish();
# Sanity check: if we expired too many tokens, abort!
if ($vars[3] - $count < 100000) {
dbg("bayes: token expiration would expire too many tokens, aborting");
# set these appropriately so the next expire pass does the first pass
$deleted = 0;
$newdelta = 0;
}
else {
# Do the expire
$sql = "DELETE from bayes_token
WHERE id = ?
AND atime < ?";
$rows = $self->{_dbh}->do($sql, undef, $self->{_userid}, $too_old);
unless (defined($rows)) {
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
$deleted = 0;
goto token_expiration_final;
}
$deleted = ($rows eq '0E0') ? 0 : $rows;
}
# Update the magic tokens as appropriate
$sql = "UPDATE bayes_vars SET token_count = token_count - ?,
last_expire = ?,
last_atime_delta = ?,
last_expire_reduce = ?
WHERE id = ?";
$rows = $self->{_dbh}->do($sql, undef, $deleted, time(), $newdelta, $deleted, $self->{_userid});
unless (defined($rows)) {
# Very bad, we actually deleted the tokens, but were unable to update
# bayes_vars with the new data.
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
dbg("bayes: bayes database now in inconsistent state, suggest a backup/restore");
goto token_expiration_final;
}
# If we didn't remove any tokens, the oldest token age wouldn't have changed
if ($deleted) {
# Now let's update the oldest_token_age value, shouldn't need to worry
# about newest_token_age. There is a slight race condition here, but the
# chance is small that we'll insert a new token with such an old atime
my $oldest_token_age = $self->_get_oldest_token_age();
$sql = "UPDATE bayes_vars SET oldest_token_age = ? WHERE id = ?";
$rows = $self->{_dbh}->do($sql, undef, $oldest_token_age, $self->{_userid});
unless (defined($rows)) {
# not much more we can do here, so just warn the user and bail out
dbg("bayes: token_expiration: SQL error: ".$self->{_dbh}->errstr());
# yeah I know it's the next thing anyway, but here in case someone adds
# additional code below this block
goto token_expiration_final;
}
}
token_expiration_final:
my $kept = $vars[3] - $deleted;
$num_hapaxes = $self->_get_num_hapaxes() if ($opts->{verbose});
$num_lowfreq = $self->_get_num_lowfreq() if ($opts->{verbose});
# Call untie_db() first so we unlock correctly etc. first
$self->untie_db();
return ($kept, $deleted, $num_hapaxes, $num_lowfreq);
}
=head2 sync_due
public instance (Boolean) sync_due ()
Description:
This method determines if a database sync is currently required.
Unused for SQL based implementation.
=cut
sub sync_due {
my ($self) = @_;
return 0;
}
=head2 seen_get
public instance (String) seen_get (string $msgid)
Description:
This method retrieves the stored value, if any, for C<$msgid>. The return value
is the stored string ('s' for spam and 'h' for ham) or undef if C<$msgid> is not
found.
=cut
sub seen_get {
my ($self, $msgid) = @_;
return unless defined($self->{_dbh});
my $sql = "SELECT flag FROM bayes_seen
WHERE id = ?
AND msgid = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: seen_get: SQL Error: ".$self->{_dbh}->errstr());
return;
}
my $rc = $sth->execute($self->{_userid}, $msgid);
unless ($rc) {
dbg("bayes: seen_get: SQL error: ".$self->{_dbh}->errstr());
return;
}
my ($flag) = $sth->fetchrow_array();
$sth->finish();
return $flag;
}
=head2 seen_put
public (Boolean) seen_put (string $msgid, char $flag)
Description:
This method records C<$msgid> as the type given by C<$flag>. C<$flag> is one of
two values 's' for spam and 'h' for ham.
=cut
sub seen_put {
my ($self, $msgid, $flag) = @_;
return 0 if (!$msgid);
return 0 if (!$flag);
return 0 unless (defined($self->{_dbh}));
my $sql = "INSERT INTO bayes_seen (id, msgid, flag)
VALUES (?,?,?)";
my $rows = $self->{_dbh}->do($sql,
undef,
$self->{_userid}, $msgid, $flag);
unless (defined($rows)) {
dbg("bayes: seen_put: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
dbg("bayes: seen ($msgid) put");
return 1;
}
=head2 seen_delete
public instance (Boolean) seen_delete (string $msgid)
Description:
This method removes C<$msgid> from the database.
=cut
sub seen_delete {
my ($self, $msgid) = @_;
return 0 if (!$msgid);
return 0 unless (defined($self->{_dbh}));
my $sql = "DELETE FROM bayes_seen
WHERE id = ?
AND msgid = ?";
my $rows = $self->{_dbh}->do($sql,
undef,
$self->{_userid}, $msgid);
unless (defined($rows)) {
dbg("bayes: seen_delete: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 get_storage_variables
public instance (@) get_storage_variables ()
Description:
This method retrieves the various administrative variables used by
the Bayes process and database.
The values returned in the array are in the following order:
0: scan count base
1: number of spam
2: number of ham
3: number of tokens in db
4: last expire atime
5: oldest token in db atime
6: db version value
7: last journal sync
8: last atime delta
9: last expire reduction count
10: newest token in db atime
=cut
sub get_storage_variables {
my ($self) = @_;
my @values;
return (0,0,0,0,0,0,0,0,0,0,0) unless (defined($self->{_dbh}));
my $sql = "SELECT spam_count, ham_count, token_count, last_expire,
last_atime_delta, last_expire_reduce, oldest_token_age,
newest_token_age
FROM bayes_vars
WHERE id = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: get_storage_variables: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0,0,0,0,0,0,0,0,0);
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: get_storage_variables: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0,0,0,0,0,0,0,0,0);
}
my ($spam_count, $ham_count, $token_count,
$last_expire, $last_atime_delta, $last_expire_reduce,
$oldest_token_age, $newest_token_age) = $sth->fetchrow_array();
$sth->finish();
my $db_ver = $self->DB_VERSION;
@values = (
0,
$spam_count,
$ham_count,
$token_count,
$last_expire,
$oldest_token_age,
$db_ver,
0, # we do not do journal syncs
$last_atime_delta,
$last_expire_reduce,
$newest_token_age
);
return @values;
}
=head2 dump_db_toks
public instance () dump_db_toks (String $template, String $regex, Array @vars)
Description:
This method loops over all tokens, computing the probability for the token and then
printing it out according to the passed in token.
=cut
sub dump_db_toks {
my ($self, $template, $regex, @vars) = @_;
return unless (defined($self->{_dbh}));
# 0/0 tokens don't count, but in theory we shouldn't have any
my $token_select = $self->_token_select_string();
my $sql = "SELECT $token_select, spam_count, ham_count, atime
FROM bayes_token
WHERE id = ?
AND (spam_count > 0 OR ham_count > 0)";
my $sth = $self->{_dbh}->prepare($sql);
unless (defined($sth)) {
dbg("bayes: dump_db_toks: SQL error: ".$self->{_dbh}->errstr());
return;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: dump_db_toks: SQL error: ".$self->{_dbh}->errstr());
return;
}
while (my ($token, $spam_count, $ham_count, $atime) = $sth->fetchrow_array()) {
my $prob = $self->{bayes}->_compute_prob_for_token($token, $vars[1], $vars[2],
$spam_count, $ham_count);
$prob ||= 0.5;
my $encoded_token = unpack("H*", $token);
printf $template,$prob,$spam_count,$ham_count,$atime,$encoded_token
or die "Error writing tokens: $!";
}
$sth->finish();
return;
}
=head2 set_last_expire
public instance (Boolean) set_last_expire (Integer $time)
Description:
This method sets the last expire time.
=cut
sub set_last_expire {
my ($self, $time) = @_;
return 0 unless (defined($time));
return 0 unless (defined($self->{_dbh}));
my $sql = "UPDATE bayes_vars SET last_expire = ? WHERE id = ?";
my $rows = $self->{_dbh}->do($sql,
undef,
$time,
$self->{_userid});
unless (defined($rows)) {
dbg("bayes: set_last_expire: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 get_running_expire_tok
public instance (String $time) get_running_expire_tok ()
Description:
This method determines if an expire is currently running and returns
the last time set.
There can be multiple times, so we just pull the greatest (most recent)
value.
=cut
sub get_running_expire_tok {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "SELECT max(runtime) from bayes_expire WHERE id = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: get_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: get_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($runtime) = $sth->fetchrow_array();
$sth->finish();
return $runtime;
}
=head2 set_running_expire_tok
public instance (String $time) set_running_expire_tok ()
Description:
This method sets the time that an expire starts running.
=cut
sub set_running_expire_tok {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "INSERT INTO bayes_expire (id,runtime) VALUES (?,?)";
my $time = time();
my $rows = $self->{_dbh}->do($sql,
undef,
$self->{_userid}, $time);
unless (defined($rows)) {
dbg("bayes: set_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return;
}
return $time;
}
=head2 remove_running_expire_tok
public instance (Boolean) remove_running_expire_tok ()
Description:
This method removes the row in the database that indicates that
and expire is currently running.
=cut
sub remove_running_expire_tok {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "DELETE from bayes_expire
WHERE id = ?";
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
dbg("bayes: remove_running_expire_tok: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 tok_get
public instance (Integer, Integer, Integer) tok_get (String $token)
Description:
This method retrieves a specified token (C<$token>) from the database
and returns it's spam_count, ham_count and last access time.
=cut
sub tok_get {
my ($self, $token) = @_;
return (0,0,0) unless (defined($self->{_dbh}));
my $sql = "SELECT spam_count, ham_count, atime
FROM bayes_token
WHERE id = ?
AND token = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: tok_get: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0);
}
my $rc = $sth->execute($self->{_userid}, $token);
unless ($rc) {
dbg("bayes: tok_get: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0);
}
my ($spam_count, $ham_count, $atime) = $sth->fetchrow_array();
$sth->finish();
$spam_count = 0 if (!$spam_count || $spam_count < 0);
$ham_count = 0 if (!$ham_count || $ham_count < 0);
$atime = 0 if (!$atime);
return ($spam_count, $ham_count, $atime)
}
=head2 tok_get_all
public instance (\@) tok_get (@ $tokens)
Description:
This method retrieves the specified tokens (C<$tokens>) from storage and returns
an array ref of arrays spam count, ham count and last access time.
=cut
sub tok_get_all {
my ($self, @tokens) = @_;
return [] unless (defined($self->{_dbh}));
my $token_list_size = scalar(@tokens);
dbg("bayes: tok_get_all: token count: $token_list_size");
my @tok_results;
my $search_index = 0;
my $results_index = 0;
my $bunch_end;
my $token_select = $self->_token_select_string();
my $multi_sql = "SELECT $token_select, spam_count, ham_count, atime
FROM bayes_token
WHERE id = ?
AND token IN ";
# fetch tokens in bunches of 100 until there are <= 100 left, then just fetch the rest
while ($token_list_size > $search_index) {
my $bunch_size;
if ($token_list_size - $search_index > 100) {
$bunch_size = 100;
}
else {
$bunch_size = $token_list_size - $search_index;
}
while ($token_list_size - $search_index >= $bunch_size) {
my @bindings;
my $bindcount;
my $in_str = '(';
$bunch_end = $search_index + $bunch_size;
for ( ; $search_index < $bunch_end; $search_index++) {
$in_str .= '?,';
push(@bindings, $tokens[$search_index]);
}
chop $in_str;
$in_str .= ')';
my $dynamic_sql = $multi_sql . $in_str;
my $sth = $self->{_dbh}->prepare($dynamic_sql);
unless (defined($sth)) {
dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
my $rc = $sth->execute($self->{_userid}, @bindings);
unless ($rc) {
dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
return [];
}
my $results = $sth->fetchall_arrayref();
$sth->finish();
foreach my $result (@{$results}) {
# Make sure that spam_count and ham_count are not negative
$result->[1] = 0 if (!$result->[1] || $result->[1] < 0);
$result->[2] = 0 if (!$result->[2] || $result->[2] < 0);
# Make sure that atime has a value
$result->[3] = 0 if (!$result->[3]);
$tok_results[$results_index++] = $result;
}
}
}
return \@tok_results;
}
=head2 tok_count_change
public instance (Boolean) tok_count_change (Integer $spam_count,
Integer $ham_count,
String $token,
String $atime)
Description:
This method takes a C<$spam_count> and C<$ham_count> and adds it to
C<$tok> along with updating C<$tok>s atime with C<$atime>.
=cut
sub tok_count_change {
my ($self, $spam_count, $ham_count, $token, $atime) = @_;
$atime = 0 unless defined $atime;
$self->_put_token($token, $spam_count, $ham_count, $atime);
}
=head2 multi_tok_count_change
public instance (Boolean) multi_tok_count_change (Integer $spam_count,
Integer $ham_count,
\% $tokens,
String $atime)
Description:
This method takes a C<$spam_count> and C<$ham_count> and adds it to all
of the tokens in the C<$tokens> hash ref along with updating each token's
atime with C<$atime>.
=cut
sub multi_tok_count_change {
my ($self, $spam_count, $ham_count, $tokens, $atime) = @_;
$atime = 0 unless defined $atime;
$self->_put_tokens($tokens, $spam_count, $ham_count, $atime);
}
=head2 nspam_nham_get
public instance ($spam_count, $ham_count) nspam_nham_get ()
Description:
This method retrieves the total number of spam and the total number of
ham learned.
=cut
sub nspam_nham_get {
my ($self) = @_;
return (0,0) unless (defined($self->{_dbh}));
my @vars = $self->get_storage_variables();
return ($vars[1] || 0, $vars[2] || 0);
}
=head2 nspam_nham_change
public instance (Boolean) nspam_nham_change (Integer $num_spam,
Integer $num_ham)
Description:
This method updates the number of spam and the number of ham in the database.
=cut
sub nspam_nham_change {
my ($self, $num_spam, $num_ham) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql;
my @bindings;
if ($num_spam != 0 && $num_ham != 0) {
$sql = "UPDATE bayes_vars
SET spam_count = spam_count + ?,
ham_count = ham_count + ?
WHERE id = ?";
@bindings = ($num_spam, $num_ham, $self->{_userid});
}
elsif ($num_spam != 0) {
$sql = "UPDATE bayes_vars
SET spam_count = spam_count + ?
WHERE id = ?";
@bindings = ($num_spam, $self->{_userid});
}
elsif ($num_ham != 0) {
$sql = "UPDATE bayes_vars
SET ham_count = ham_count + ?
WHERE id = ?";
@bindings = ($num_ham, $self->{_userid});
}
else {
# For some reason called with no delta, it's ok though so just return
dbg("bayes: nspam_nham_change: Called with no delta on spam or ham");
return 1;
}
my $rows = $self->{_dbh}->do($sql,
undef,
@bindings);
unless (defined($rows)) {
dbg("bayes: nspam_nham_change: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 tok_touch
public instance (Boolean) tok_touch (String $token,
String $atime)
Description:
This method updates the given tokens (C<$token>) atime.
The assumption is that the token already exists in the database.
=cut
sub tok_touch {
my ($self, $token, $atime) = @_;
return 0 unless (defined($self->{_dbh}));
# shortcut, will only update atime for the token if the atime is less than
# what we are updating to
my $sql = "UPDATE bayes_token
SET atime = ?
WHERE id = ?
AND token = ?
AND atime < ?";
my $rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid},
$token, $atime);
unless (defined($rows)) {
dbg("bayes: tok_touch: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
# if we didn't update a row then no need to update newest_token_age
return 1 if ($rows eq '0E0');
# need to check newest_token_age
# no need to check oldest_token_age since we would only update if the
# atime was newer than what is in the database
$sql = "UPDATE bayes_vars
SET newest_token_age = ?
WHERE id = ?
AND newest_token_age < ?";
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: tok_touch: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 tok_touch_all
public instance (Boolean) tok_touch (\@ $tokens
String $atime)
Description:
This method does a mass update of the given list of tokens C<$tokens>, if the existing token
atime is < C<$atime>.
The assumption is that the tokens already exist in the database.
We should never be touching more than N_SIGNIFICANT_TOKENS, so we can make
some assumptions about how to handle the data (ie no need to batch like we
do in tok_get_all)
=cut
sub tok_touch_all {
my ($self, $tokens, $atime) = @_;
return 0 unless (defined($self->{_dbh}));
return 1 unless (scalar(@{$tokens}));
my $sql = "UPDATE bayes_token SET atime = ? WHERE id = ? AND token IN (";
my @bindings = ($atime, $self->{_userid});
foreach my $token (@{$tokens}) {
$sql .= "?,";
push(@bindings, $token);
}
chop($sql); # get rid of trailing ,
$sql .= ") AND atime < ?";
push(@bindings, $atime);
my $rows = $self->{_dbh}->do($sql, undef, @bindings);
unless (defined($rows)) {
dbg("bayes: tok_touch_all: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
# if we didn't update a row then no need to update newest_token_age
return 1 if ($rows eq '0E0');
# need to check newest_token_age
# no need to check oldest_token_age since we would only update if the
# atime was newer than what is in the database
$sql = "UPDATE bayes_vars
SET newest_token_age = ?
WHERE id = ?
AND newest_token_age < ?";
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: tok_touch_all: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 cleanup
public instance (Boolean) cleanup ()
Description:
This method performs any cleanup necessary before moving onto the next
operation.
=cut
sub cleanup {
my ($self) = @_;
return 1 unless ($self->{needs_cleanup});
# cleanup was needed, go ahead and clear the cleanup flag
$self->{needs_cleanup} = 0;
my $sql = "DELETE from bayes_token
WHERE id = ?
AND spam_count = 0
AND ham_count = 0";
my $toks_deleted = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($toks_deleted)) {
dbg("bayes: cleanup: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
# check to see if any tokens where deleted
return 1 if ($toks_deleted eq '0E0');
$sql = "UPDATE bayes_vars SET token_count = token_count - $toks_deleted
WHERE id = ?";
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
dbg("bayes: cleanup: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 get_magic_re
public instance get_magic_re (String)
Description:
This method returns a regexp which indicates a magic token.
Unused in SQL implementation.
=cut
sub get_magic_re {
my ($self) = @_;
undef;
}
=head2 sync
public instance (Boolean) sync (\% $opts)
Description:
This method performs a sync of the database
=cut
sub sync {
my ($self, $opts) = @_;
# Not used for this implementation
return 1;
}
=head2 perform_upgrade
public instance (Boolean) perform_upgrade (\% $opts);
Description:
Performs an upgrade of the database from one version to another, not
currently used in this implementation.
=cut
sub perform_upgrade {
my ($self) = @_;
return 1;
}
=head2 clear_database
public instance (Boolean) clear_database ()
Description:
This method deletes all records for a particular user.
Callers should be aware that any errors returned by this method
could cause the database to be inconsistent for the given user.
=cut
sub clear_database {
my ($self) = @_;
# We want to open readonly first, because if they don't already have
# a db entry, we want to avoid creating one, just to delete it in a few secs
if ($self->tie_db_readonly()) {
# Ok, they must have had a db entry, so now make the connection writable
$self->tie_db_writable();
}
else {
# If we were unable to create a readonly connection then they must
# not have a db entry, so no need to clear.
# But it should be considered a success.
return 1;
}
return 0 unless (defined($self->{_dbh}));
my $rows = $self->{_dbh}->do("DELETE FROM bayes_vars WHERE id = ?",
undef,
$self->{_userid});
unless (defined($rows)) {
dbg("bayes: SQL error removing user (bayes_vars) data: ".$self->{_dbh}->errstr());
return 0;
}
$rows = $self->{_dbh}->do("DELETE FROM bayes_seen WHERE id = ?",
undef,
$self->{_userid});
unless (defined($rows)) {
dbg("bayes: SQL error removing seen data: ".$self->{_dbh}->errstr());
return 0;
}
$rows = $self->{_dbh}->do("DELETE FROM bayes_token WHERE id = ?",
undef,
$self->{_userid});
unless (defined($rows)) {
dbg("bayes: SQL error removing token data: ".$self->{_dbh}->errstr());
return 0;
}
return 1;
}
=head2 backup_database
public instance (Boolean) backup_database ()
Description:
This method will dump the users database in a machine readable format.
=cut
sub backup_database {
my ($self) = @_;
return 0 unless ($self->tie_db_readonly());
return 0 unless (defined($self->{_dbh}));
my @vars = $self->get_storage_variables();
my $num_spam = $vars[1] || 0;
my $num_ham = $vars[2] || 0;
print "v\t$vars[6]\tdb_version # this must be the first line!!!\n"
or die "Error writing: $!";
print "v\t$num_spam\tnum_spam\n" or die "Error writing: $!";
print "v\t$num_ham\tnum_nonspam\n" or die "Error writing: $!";
my $token_select = $self->_token_select_string();
my $token_sql = "SELECT spam_count, ham_count, atime, $token_select
FROM bayes_token
WHERE id = ?
AND (spam_count > 0 OR ham_count > 0)";
my $seen_sql = "SELECT flag, msgid
FROM bayes_seen
WHERE id = ?";
my $sth = $self->{_dbh}->prepare_cached($token_sql);
unless (defined ($sth)) {
dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
while (my @values = $sth->fetchrow_array()) {
$values[3] = unpack("H*", $values[3]);
print "t\t" . join("\t", @values) . "\n"
or die "Error writing: $!";
}
$sth->finish();
$sth = $self->{_dbh}->prepare_cached($seen_sql);
unless (defined ($sth)) {
dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
$rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: backup_database: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
while (my @values = $sth->fetchrow_array()) {
print "s\t" . join("\t",@values) . "\n" or die "Error writing: $!";
}
$sth->finish();
$self->untie_db();
return 1;
}
=head2 restore_database
public instance (Boolean) restore_database (String $filename, Boolean $showdots)
Description:
This method restores a database from the given filename, C<$filename>.
Callers should be aware that any errors returned by this method
could causes the database to be inconsistent for the given user.
=cut
sub restore_database {
my ($self, $filename, $showdots) = @_;
local *DUMPFILE;
if (!open(DUMPFILE, '<', $filename)) {
dbg("bayes: unable to open backup file $filename: $!");
return 0;
}
# This is the critical phase (moving sql around), so don't allow it
# to be interrupted.
local $SIG{'INT'} = 'IGNORE';
local $SIG{'HUP'} = 'IGNORE' if (!Mail::SpamAssassin::Util::am_running_on_windows());
local $SIG{'TERM'} = 'IGNORE';
unless ($self->clear_database()) {
return 0;
}
# we need to go ahead close the db connection so we can then open it up
# in a fresh state after clearing
$self->untie_db();
unless ($self->tie_db_writable()) {
return 0;
}
my $token_count = 0;
my $db_version;
my $num_spam;
my $num_ham;
my $error_p = 0;
my $line_count = 0;
my $line = <DUMPFILE>;
defined $line or die "Error reading dump file: $!";
$line_count++;
# We require the database version line to be the first in the file so we can
# figure out how to properly deal with the file. If it is not the first
# line then fail
if ($line =~ m/^v\s+(\d+)\s+db_version/) {
$db_version = $1;
}
else {
dbg("bayes: database version must be the first line in the backup file, correct and re-run");
return 0;
}
unless ($db_version == 2 || $db_version == 3) {
warn("bayes: database version $db_version is unsupported, must be version 2 or 3");
return 0;
}
my $token_error_count = 0;
my $seen_error_count = 0;
for ($!=0; defined($line=<DUMPFILE>); $!=0) {
chomp($line);
$line_count++;
if ($line_count % 1000 == 0) {
print STDERR "." if ($showdots);
}
if ($line =~ /^v\s+/) { # variable line
my @parsed_line = split(/\s+/, $line, 3);
my $value = $parsed_line[1] + 0;
if ($parsed_line[2] eq 'num_spam') {
$num_spam = $value;
}
elsif ($parsed_line[2] eq 'num_nonspam') {
$num_ham = $value;
}
else {
dbg("bayes: restore_database: skipping unknown line: $line");
}
}
elsif ($line =~ /^t\s+/) { # token line
my @parsed_line = split(/\s+/, $line, 5);
my $spam_count = $parsed_line[1] + 0;
my $ham_count = $parsed_line[2] + 0;
my $atime = $parsed_line[3] + 0;
my $token = $parsed_line[4];
my $token_warn_p = 0;
my @warnings;
if ($spam_count < 0) {
$spam_count = 0;
push(@warnings, 'spam count < 0, resetting');
$token_warn_p = 1;
}
if ($ham_count < 0) {
$ham_count = 0;
push(@warnings, 'ham count < 0, resetting');
$token_warn_p = 1;
}
if ($spam_count == 0 && $ham_count == 0) {
dbg("bayes: token has zero spam and ham count, skipping");
next;
}
if ($atime > time()) {
$atime = time();
push(@warnings, 'atime > current time, resetting');
$token_warn_p = 1;
}
if ($token_warn_p) {
dbg("bayes: token ($token) has the following warnings:\n".join("\n",@warnings));
}
if ($db_version < 3) {
# versions < 3 use plain text tokens, so we need to convert to hash
$token = substr(sha1($token), -5);
}
else {
# turn unpacked binary token back into binary value
$token = pack("H*",$token);
}
unless ($self->_put_token($token, $spam_count, $ham_count, $atime)) {
dbg("bayes: error inserting token for line: $line");
$token_error_count++;
}
$token_count++;
}
elsif ($line =~ /^s\s+/) { # seen line
my @parsed_line = split(/\s+/, $line, 3);
my $flag = $parsed_line[1];
my $msgid = $parsed_line[2];
unless ($flag eq 'h' || $flag eq 's') {
dbg("bayes: unknown seen flag ($flag) for line: $line, skipping");
next;
}
unless ($msgid) {
dbg("bayes: blank msgid for line: $line, skipping");
next;
}
unless ($self->seen_put($msgid, $flag)) {
dbg("bayes: error inserting msgid in seen table for line: $line");
$seen_error_count++;
}
}
else {
dbg("bayes: skipping unknown line: $line");
next;
}
if ($token_error_count >= 20) {
warn "bayes: encountered too many errors (20) while parsing token line, reverting to empty database and exiting\n";
$self->clear_database();
return 0;
}
if ($seen_error_count >= 20) {
warn "bayes: encountered too many errors (20) while parsing seen lines, reverting to empty database and exiting\n";
$self->clear_database();
return 0;
}
}
defined $line || $!==0 or
$!==EBADF ? dbg("bayes: error reading dump file: $!")
: die "error reading dump file: $!";
close(DUMPFILE) or die "Can't close dump file: $!";
print STDERR "\n" if ($showdots);
unless (defined($num_spam)) {
dbg("bayes: unable to find num spam, please check file");
$error_p = 1;
}
unless (defined($num_ham)) {
dbg("bayes: unable to find num ham, please check file");
$error_p = 1;
}
if ($error_p) {
dbg("bayes: error(s) while attempting to load $filename, clearing database, correct and re-run");
$self->clear_database();
return 0;
}
if ($num_spam || $num_ham) {
unless ($self->nspam_nham_change($num_spam, $num_ham)) {
dbg("bayes: error updating num spam and num ham, clearing database");
$self->clear_database();
return 0;
}
}
dbg("bayes: parsed $line_count lines");
dbg("bayes: created database with $token_count tokens based on $num_spam spam messages and $num_ham ham messages");
$self->untie_db();
return 1;
}
=head2 db_readable
public instance (Boolean) db_readable()
Description:
This method returns a boolean value indicating if the database is in a
readable state.
=cut
sub db_readable {
my ($self) = @_;
# if there's a database handle, we can read...
return defined $self->{_dbh};
}
=head2 db_writable
public instance (Boolean) db_writeable()
Description:
This method returns a boolean value indicating if the database is in a
writable state.
=cut
sub db_writable {
my ($self) = @_;
return (defined $self->{_dbh} && $self->{db_writable_p})
}
=head1 Private Methods
=head2 _connect_db
private instance (Boolean) _connect_db ()
Description:
This method connects to the SQL database.
=cut
sub _connect_db {
my ($self) = @_;
$self->{_dbh} = undef;
# Turn off PrintError and explicitly set AutoCommit to off
my $dbh = DBI->connect($self->{_dsn}, $self->{_dbuser}, $self->{_dbpass},
{'PrintError' => 0, 'AutoCommit' => 1});
if (!$dbh) {
dbg("bayes: unable to connect to database: ".DBI->errstr());
return 0;
}
else {
dbg("bayes: database connection established");
}
$self->{_dbh} = $dbh;
return 1;
}
=head2 _get_db_version
private instance (Integer) _get_db_version ()
Description:
Gets the current version of the database from the special global vars
tables.
=cut
sub _get_db_version {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
return ($self->{_db_version_cache}) if (defined($self->{_db_version_cache}));
my $sql = "SELECT value FROM bayes_global_vars WHERE variable = 'VERSION'";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: _get_db_version: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute();
unless ($rc) {
dbg("bayes: _get_db_version: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($version) = $sth->fetchrow_array();
$sth->finish();
$self->{_db_version_cache} = $version;
return $version;
}
=head2 _initialize_db
private instance (Boolean) _initialize_db ()
Description:
This method will check to see if a user has had their bayes variables
initialized. If not then it will perform this initialization.
=cut
sub _initialize_db {
my ($self, $create_entry_p) = @_;
return 0 if !defined $self->{_dbh};
return 0 if !defined $self->{_username} || $self->{_username} eq '';
# Check to see if we should call the services_authorized_for_username plugin
# hook to see if this user is allowed/able to use bayes. If not, do nothing
# and return 0.
if ($self->{bayes}->{conf}->{bayes_sql_username_authorized}) {
my $services = { 'bayessql' => 0 };
$self->{bayes}->{main}->call_plugins("services_allowed_for_username",
{ services => $services,
username => $self->{_username},
conf => $self->{bayes}->{conf},
});
unless ($services->{bayessql}) {
dbg("bayes: username not allowed by services_allowed_for_username plugin call");
return 0;
}
}
my $sqlselect = "SELECT id FROM bayes_vars WHERE username = ?";
my $sthselect = $self->{_dbh}->prepare_cached($sqlselect);
unless (defined($sthselect)) {
dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sthselect->execute($self->{_username});
unless ($rc) {
dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($id) = $sthselect->fetchrow_array();
if ($id) {
$self->{_userid} = $id;
dbg("bayes: Using userid: ".$self->{_userid});
$sthselect->finish();
return 1;
}
# Do not create an entry for this user unless we were specifically asked to
return 0 unless ($create_entry_p);
# For now let the database setup the other variables as defaults
my $sqlinsert = "INSERT INTO bayes_vars (username) VALUES (?)";
my $rows = $self->{_dbh}->do($sqlinsert,
undef,
$self->{_username});
unless (defined($rows)) {
dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
# Now we need to figure out what id we inserted them at, in a perfect
# world the database driver would handle this for us (ie mysql_insert_id)
# but this is far from a perfect world, however since in theory we only
# ever do this once it's ok to take the hit
$rc = $sthselect->execute($self->{_username});
unless ($rc) {
dbg("bayes: _initialize_db: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
($id) = $sthselect->fetchrow_array();
$sthselect->finish();
if ($id) {
$self->{_userid} = $id;
dbg("bayes: using userid: ".$self->{_userid});
return 1;
}
return 1;
}
=head2 _put_token
private instance (Boolean) _put_token (string $token,
integer $spam_count,
integer $ham_count,
string $atime)
Description:
This method performs the work of either inserting or updating a token in
the database.
=cut
sub _put_token {
my ($self, $token, $spam_count, $ham_count, $atime) = @_;
return 0 unless (defined($self->{_dbh}));
$spam_count ||= 0;
$ham_count ||= 0;
if ($spam_count == 0 && $ham_count == 0) {
return 1;
}
my ($existing_spam_count,
$existing_ham_count,
$existing_atime) = $self->tok_get($token);
if (!$existing_atime) {
# You can't create a new entry for a token with a negative count, so just return
# if we are unable to find an entry.
return 1 if ($spam_count < 0 || $ham_count < 0);
my $sql = "INSERT INTO bayes_token
(id, token, spam_count, ham_count, atime)
VALUES (?,?,?,?,?)";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid},
$token,
$spam_count,
$ham_count,
$atime);
unless ($rc) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
$sth->finish();
$sql = "UPDATE bayes_vars SET token_count = token_count + 1
WHERE id = ?";
my $rows = $self->{_dbh}->do($sql, undef, $self->{_userid});
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
$sql = "UPDATE bayes_vars SET newest_token_age = ?
WHERE id = ? AND newest_token_age < ?";
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
if ($rows eq '0E0') {
# no need to update oldest_token_age if we updated newest_token_age
$sql = "UPDATE bayes_vars SET oldest_token_age = ?
WHERE id = ? AND oldest_token_age > ?";
$rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
}
else {
if ($spam_count < 0 || $ham_count < 0) {
# we only need to cleanup when we subtract counts for a token and the
# counts may have both reached 0
# XXX - future optimization, since we have the existing spam/ham counts
# we can make an educated guess on if the count would reach 0, for
# instance, if we are decreasing spam_count but spam_count is currently
# > 1000, then there is no possible way this update or any others that
# might currently be happening could reduce that value to 0, so there
# would be no need to set the needs_cleanup flag
$self->{needs_cleanup} = 1;
}
my $update_atime_p = 1;
my $updated_atime_p = 0;
# if the existing atime is already >= the one we are going to set, then
# don't bother
$update_atime_p = 0 if ($existing_atime >= $atime);
# These SQL statements include as part of the WHERE clause something like
# "AND spam_count + ? >= 0" or "AND ham_count + ? >= 0". This is to keep
# the count from going negative.
if ($spam_count) {
my $sql;
my @args;
if ($update_atime_p) {
$sql = "UPDATE bayes_token
SET spam_count = spam_count + ?,
atime = ?
WHERE id = ?
AND token = ?
AND spam_count + ? >= 0";
@args = ($spam_count, $atime, $self->{_userid}, $token, $spam_count);
$updated_atime_p = 1; # note the fact that we did do it
}
else {
$sql = "UPDATE bayes_token
SET spam_count = spam_count + ?
WHERE id = ?
AND token = ?
AND spam_count + ? >= 0";
@args = ($spam_count, $self->{_userid}, $token, $spam_count);
}
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
if ($ham_count) {
my $sql;
my @args;
if ($update_atime_p && !$updated_atime_p) {
$sql = "UPDATE bayes_token
SET ham_count = ham_count + ?,
atime = ?
WHERE id = ?
AND token = ?
AND ham_count + ? >= 0";
@args = ($ham_count, $atime, $self->{_userid}, $token, $ham_count);
$updated_atime_p = 1; # note the fact that we did do it
}
else {
$sql = "UPDATE bayes_token
SET ham_count = ham_count + ?
WHERE id = ?
AND token = ?
AND ham_count + ? >= 0";
@args = ($ham_count, $self->{_userid}, $token, $ham_count);
}
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
if ($updated_atime_p) {
# we updated the atime, so we need to check and update bayes_vars
# we only need to worry about newest_token_age since we would have
# only updated the atime if it was > the previous value
my $sql = "UPDATE bayes_vars SET newest_token_age = ?
WHERE id = ? AND newest_token_age < ?";
my $rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
}
}
return 1;
}
=head2 _put_tokens
private instance (Boolean) _put_tokens (\% $tokens,
integer $spam_count,
integer $ham_count,
string $atime)
Description:
This method performs the work of either inserting or updating tokens in
the database.
=cut
sub _put_tokens {
my ($self, $tokens, $spam_count, $ham_count, $atime) = @_;
return 0 unless (defined($self->{_dbh}));
$spam_count ||= 0;
$ham_count ||= 0;
if ($spam_count == 0 && $ham_count == 0) {
return 1;
}
my $atime_updated_p = 0;
my $atime_inserted_p = 0;
my $new_tokens = 0;
my $insertsql = "INSERT INTO bayes_token
(id, token, spam_count, ham_count, atime)
VALUES (?,?,?,?,?)";
my $insertsth = $self->{_dbh}->prepare_cached($insertsql);
unless (defined($insertsth)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
foreach my $token (keys %{$tokens}) {
my ($existing_spam_count,
$existing_ham_count,
$existing_atime) = $self->tok_get($token);
if (!$existing_atime) {
# You can't create a new entry for a token with a negative count, so
# just skip to the next one if we are unable to find an entry.
next if ($spam_count < 0 || $ham_count < 0);
my $rc = $insertsth->execute($self->{_userid},
$token,
$spam_count,
$ham_count,
$atime);
unless ($rc) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
next;
}
$insertsth->finish();
$atime_inserted_p = 1;
$new_tokens++;
}
else {
if ($spam_count < 0 || $ham_count < 0) {
# we only need to cleanup when we subtract counts for a token and the
# counts may have both reached 0
# XXX - future optimization, since we have the existing spam/ham counts
# we can make an educated guess on if the count would reach 0, for
# instance, if we are decreasing spam_count but spam_count is currently
# > 1000, then there is no possible way this update or any others that
# might currently be happening could reduce that value to 0, so there
# would be no need to set the needs_cleanup flag
$self->{needs_cleanup} = 1;
}
my $update_atime_p = 1;
# if the existing atime is already >= the one we are going to set, then
# don't bother
$update_atime_p = 0 if ($existing_atime >= $atime);
# These SQL statements include as part of the WHERE clause something like
# "AND spam_count + ? >= 0" or "AND ham_count + ? >= 0". This is to keep
# the count from going negative.
if ($spam_count) {
my $sql;
my @args;
if ($update_atime_p) {
$sql = "UPDATE bayes_token
SET spam_count = spam_count + ?,
atime = ?
WHERE id = ?
AND token = ?
AND spam_count + ? >= 0";
@args = ($spam_count, $atime, $self->{_userid}, $token, $spam_count);
$atime_updated_p = 1;
}
else {
$sql = "UPDATE bayes_token
SET spam_count = spam_count + ?
WHERE id = ?
AND token = ?
AND spam_count + ? >= 0";
@args = ($spam_count, $self->{_userid}, $token, $spam_count);
}
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
}
}
if ($ham_count) {
my $sql;
my @args;
# if $spam_count then we already updated the atime
if ($update_atime_p && !$spam_count) {
$sql = "UPDATE bayes_token
SET ham_count = ham_count + ?,
atime = ?
WHERE id = ?
AND token = ?
AND ham_count + ? >= 0";
@args = ($ham_count, $atime, $self->{_userid}, $token, $ham_count);
$atime_updated_p = 1;
}
else {
$sql = "UPDATE bayes_token
SET ham_count = ham_count + ?
WHERE id = ?
AND token = ?
AND ham_count + ? >= 0";
@args = ($ham_count, $self->{_userid}, $token, $ham_count);
}
my $rows = $self->{_dbh}->do($sql, undef, @args);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
}
}
}
}
if ($new_tokens) {
my $sql = "UPDATE bayes_vars SET token_count = token_count + ?
WHERE id = ?";
my $rows = $self->{_dbh}->do($sql, undef, $new_tokens, $self->{_userid});
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
}
}
if ($atime_updated_p || $atime_inserted_p) {
# we updated the atime, so we need to check and update bayes_vars
# we only need to worry about newest_token_age since we would have
# only updated the atime if it was > the previous value
my $sql = "UPDATE bayes_vars SET newest_token_age = ?
WHERE id = ? AND newest_token_age < ?";
my $rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
}
}
# If we inserted then we might need to update oldest_token_age
# but if we already updated newest_token_age then there is no need
if ($atime_inserted_p) {
my $sql = "UPDATE bayes_vars SET oldest_token_age = ?
WHERE id = ? AND oldest_token_age > ?";
my $rows = $self->{_dbh}->do($sql, undef, $atime, $self->{_userid}, $atime);
unless (defined($rows)) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
}
}
return 1;
}
=head2 _get_oldest_token_age
private instance (Integer) _get_oldest_token_age ()
Description:
This method finds the atime of the oldest token in the database.
The use of min(atime) in the SQL is ugly and but really the most efficient
way of getting the oldest_token_age after we've done a mass expire. It should
only be called at expire time.
=cut
sub _get_oldest_token_age {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "SELECT min(atime) FROM bayes_token
WHERE id = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: _get_oldest_token_age: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: _get_oldest_token_age: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($atime) = $sth->fetchrow_array();
$sth->finish();
return $atime;
}
=head2 _get_num_hapaxes
private instance (Integer) _get_num_hapaxes ()
Description:
This method gets the total number of hapaxes (spam_count + ham_count == 1) in
the token database for a user.
=cut
sub _get_num_hapaxes {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "SELECT count(*)
FROM bayes_token
WHERE id = ?
AND spam_count + ham_count = 1";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: _get_num_hapaxes: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: _get_num_hapaxes: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($num_hapaxes) = $sth->fetchrow_array();
$sth->finish();
return $num_hapaxes;
}
=head2 _get_num_lowfreq
private instance (Integer) _get_num_lowfreq ()
Description:
This method gets the total number of lowfreq tokens (spam_count < 8 and
ham_count < 8) in the token database for a user
=cut
sub _get_num_lowfreq {
my ($self) = @_;
return 0 unless (defined($self->{_dbh}));
my $sql = "SELECT count(*)
FROM bayes_token
WHERE id = ?
AND (spam_count >= 0 AND spam_count < 8)
AND (ham_count >= 0 AND ham_count < 8)
AND spam_count + ham_count != 1";
my $sth = $self->{_dbh}->prepare_cached($sql);
unless (defined($sth)) {
dbg("bayes: _get_num_lowfreq: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my $rc = $sth->execute($self->{_userid});
unless ($rc) {
dbg("bayes: _get_num_lowfreq: SQL error: ".$self->{_dbh}->errstr());
return 0;
}
my ($num_lowfreq) = $sth->fetchrow_array();
$sth->finish();
return $num_lowfreq;
}
=head2 _token_select_string
private instance (String) _token_select_string
Description:
This method returns the string to be used in SELECT statements to represent
the token column.
The default is to use the RPAD function to pad the token out to 5 characters.
=cut
sub _token_select_string {
return "RPAD(token, 5, ' ')";
}
sub sa_die { Mail::SpamAssassin::sa_die(@_); }
1;
| 25.110263 | 121 | 0.608968 |
ed498ab1660de63169d53c580fe1decc68ea75f3 | 21,658 | pm | Perl | lib/PerlPoint/Constants.pm | git-the-cpan/PerlPoint-Package | a251aa46f8b197732260b973e805e481f739b1a7 | [
"Unlicense"
]
| null | null | null | lib/PerlPoint/Constants.pm | git-the-cpan/PerlPoint-Package | a251aa46f8b197732260b973e805e481f739b1a7 | [
"Unlicense"
]
| null | null | null | lib/PerlPoint/Constants.pm | git-the-cpan/PerlPoint-Package | a251aa46f8b197732260b973e805e481f739b1a7 | [
"Unlicense"
]
| null | null | null |
# = HISTORY SECTION =====================================================================
# ---------------------------------------------------------------------------------------
# version | date | author | changes
# ---------------------------------------------------------------------------------------
# 0.19 |07.03.2006| JSTENZEL | added DUMMY_TOKEN;
# 0.18 |15.12.2005| JSTENZEL | internal helper routine name now begins with underscore;
# 0.17 |15.06.2003| JSTENZEL | added DIRECTIVE_EVERY constant;
# |10.09.2003| JSTENZEL | added DIRECTIVE_DPOINT_TEXT constant;
# |08.07.2004| JSTENZEL | added TEMPLATE_ACTION_... constants;
# 0.16 |< 02.03.02| JSTENZEL | added DIRECTIVE_DSTREAM_ENTRYPOINT constant;
# |02.03.2002| JSTENZEL | added DSTREAM_... constants;
# |29.09.2002| JSTENZEL | added STREAM_DOCSTREAMS;
# |02.01.2003| JSTENZEL | added TRACE_TMPFILES;
# 0.15 |10.08.2001| JSTENZEL | added STREAM_... constants;
# | | JSTENZEL | reorganized POD slightly;
# |14.08.2001| JSTENZEL | added missed doc of TAG_... constants;
# |29.09.2001| JSTENZEL | removed STREAM_CONTROL;
# |13.11.2001| JSTENZEL | added PARSING_IGNORE and PARSING_ERASE;
# |14.11.2001| JSTENZEL | added STREAM_DIR_ index constants;
# 0.14 |28.05.2001| JSTENZEL | added DIRECTIVE_VARRESET;
# |12.06.2001| JSTENZEL | added PARSING_... constants;
# 0.13 |18.03.2001| JSTENZEL | added tag constants;
# 0.12 |14.03.2001| JSTENZEL | added mailing list hint to POD;
# 0.11 |20.01.2001| JSTENZEL | added new constant DIRECTIVE_VARSET;
# 0.10 |07.12.2000| JSTENZEL | new namespace PerlPoint;
# 0.09 |18.11.2000| JSTENZEL | added new CACHE constants;
# 0.08 |28.10.2000| JSTENZEL | added new constant TRACE_ACTIVE;
# 0.07 |07.10.2000| JSTENZEL | added new constant DIRECTIVE_NEW_LINE;
# | | JSTENZEL | sligthly improved POD;
# 0.06 |27.05.2000| JSTENZEL | updated POD;
# 0.05 |11.04.2000| JSTENZEL | added new paragraph constants: xxx_DPOINT;
# 0.04 |07.04.2000| JSTENZEL | added new paragraph constants: xxx_UPOINT, xxx_OPOINT;
# |08.04.2000| JSTENZEL | added new paragraph constants: xxx_xSHIFT;
# |09.04.2000| JSTENZEL | START/STOP constants are now in the same range as
# | | | directives to avoid comparison trouble in tests;
# |14.04.2000| JSTENZEL | new directives: list envelopes;
# 0.03 |13.10.1999| JSTENZEL | updated POD;
# 0.02 |11.10.1999| JSTENZEL | renamed into PP::Constants;
# | | JSTENZEL | adapted POD to pod2text (needs more blank lines);
# | | JSTENZEL | added backend constants;
# 0.01 |09.10.1999| JSTENZEL | derived from the PP::Parser draft.
# ---------------------------------------------------------------------------------------
# = POD SECTION =========================================================================
=head1 NAME
B<PerlPoint::Constants> - public PerlPoint module constants
=head1 VERSION
This manual describes version B<0.19>.
=head1 DESCRIPTION
The module declares a number of constants shared between other
B<PerlPoint::...> modules.
=head1 SYNOPSIS
The I<usage> of the provided constants is described in the manuals
of the using modules B<PerlPoint::Parser> and B<PerlPoint::Backend>.
=head1 CONSTANTS
=cut
# declare package
package PerlPoint::Constants;
# declare version
$VERSION=$VERSION=0.19;
# startup actions
BEGIN
{
# declare startup helper function
sub _startupGenerateConstants
{
# init counter
my $c=0;
# and generate constants
foreach my $constant (@_)
{eval "use constant $constant => $c"; $c++;}
}
=pod
=head2 Stream directive constants
These constants are built into I<directives> which the parser produces
in its output (that is, the representation format it translates an ASCII
text in to be subsequently processed by a backend).
=over 4
=item DIRECTIVE_BLOCK
flags a block paragraph;
=item DIRECTIVE_COMMENT
flags a comment;
=item DIRECTIVE_COMPLETE
a format entity is completed;
=item DIRECTIVE_DOCUMENT
flags a complete document (made from one ASCII file);
=item DIRECTIVE_DLIST
flags a "definition list";
=item DIRECTIVE_DPOINT
flags a "definition point" paragraph;
=item DIRECTIVE_DPOINT_ITEM
flags a "definition point" item (the stuff to be defined);
=item DIRECTIVE_DPOINT_TEXT
flags a "definition point" text (the definition part);
=item DIRECTIVE_DSTREAM_ENTRYPOINT
flags the switch into another document stream;
=item DIRECTIVE_HEADLINE
flags a headline;
=item DIRECTIVE_LIST_LSHIFT
control directive, shift a list left;
=item DIRECTIVE_LIST_RSHIFT
control directive, shift a list right;
=item DIRECTIVE_NEW_LINE
a backend hint to inform about a new source line;
=item DIRECTIVE_OLIST
flags an "ordered list";
=item DIRECTIVE_OPOINT
flags an "ordered point" paragraph;
=item DIRECTIVE_SIMLPE
a pseudo directive, used to flag simple strings in backends;
=item DIRECTIVE_START
a format entity starts;
=item DIRECTIVE_TAG
flags a tag;
=item DIRECTIVE_TEXT
flags a text paragraph;
=item DIRECTIVE_ULIST
flags an "unordered list";
=item DIRECTIVE_UPOINT
flags an "unordered point" paragraph;
=item DIRECTIVE_VARRESET
a backend hint flagging that I<all> variables are deleted;
=item DIRECTIVE_VARSET
a backend hint propagating a variable setting;
=item DIRECTIVE_VERBATIM
flags a verbatim block paragraph;
=back
=cut
# directive constants
_startupGenerateConstants(
'DIRECTIVE_EVERY', # pseudo_directive used in backend;
'DIRECTIVE_START', # entity start;
'DIRECTIVE_COMPLETE', # entity complete;
'DIRECTIVE_BLOCK', # block;
'DIRECTIVE_COMMENT', # comment;
'DIRECTIVE_DLIST', # definition list;
'DIRECTIVE_DOCUMENT', # document;
'DIRECTIVE_DPOINT', # definition list point;
'DIRECTIVE_DPOINT_ITEM', # defined item;
'DIRECTIVE_DPOINT_TEXT', # definition text;
'DIRECTIVE_HEADLINE', # headline;
'DIRECTIVE_LIST_LSHIFT', # shift list left;
'DIRECTIVE_LIST_RSHIFT', # shift list right;
'DIRECTIVE_NEW_LINE', # backend line hint;
'DIRECTIVE_OLIST', # ordered list;
'DIRECTIVE_OPOINT', # ordered list point;
'DIRECTIVE_TAG', # tag;
'DIRECTIVE_TEXT', # text;
'DIRECTIVE_ULIST', # unordered list;
'DIRECTIVE_UPOINT', # unordered list point;
'DIRECTIVE_VARSET', # backend hint: variable setting;
'DIRECTIVE_VARRESET', # backend hint: reset *all* variables;
'DIRECTIVE_VERBATIM', # verbatim;
'DIRECTIVE_DSTREAM_ENTRYPOINT', # document stream entry point;
'DIRECTIVE_SIMPLE', # a pseudo directive (never used directly - MUST be the last here!);
);
=pod
=head2 Parser constants
control how the parser continues processing, usually used by tag hooks.
=over 4
=item PARSING_COMPLETED
We read all we need. Stop parsing successfully.
=item PARSING_ERASE
Ignore the tag I<and all its contents> (which means its body).
=item PARSING_ERROR
A semantic error occurred. Parsing will usually be continued
to possibly detect even more errors.
=item PARSING_FAILED
A syntactic error occured. Parsing will be stopped immediately.
=item PARSING_IGNORE
Ignore the tag as if it was not written.
=item PARSING_OK
Input ok, parsing can be continued.
=back
=cut
# parser constants
_startupGenerateConstants(
'PARSING_OK', # all right, proceed;
'PARSING_COMPLETED', # we know without further parsing that the input was perfect;
'PARSING_ERROR', # a semantic error occured;
'PARSING_FAILED', # a syntactical error occured;
'PARSING_IGNORE', # ignore the tag;
'PARSING_ERASE', # ignore the tag *and all its content*;
);
=pod
=head2 Tag definition constants
flagging mode of tag components.
=over 4
=item TAGS_OPTIONAL
the item can be used but is not required.
=item TAGS_MANDATORY
the item is an essential tag part.
=item TAGS_DISABLED
the item must not be used.
=back
=cut
# tag constants
_startupGenerateConstants(
'TAGS_OPTIONAL', # something is optional;
'TAGS_MANDATORY', # something is mandatory;
'TAGS_DISABLED', # something is disabled (not necessary);
);
=pod
=head2 Stream data structure part constants
index constants to access parts of the intermediate data structure produced
by the parser and processed by backends. Intended to be used by C<PerlPoint::Parser>
and C<PerlPoint::Backend>.
=over 4
=item STREAM_IDENT
stream data identifier - a string identifying the data structure as a PerlPoint stream.
=item STREAM_DOCSTREAMS
a list of all detected document stream identifiers.
=item STREAM_TOKENS
token stream.
=item STREAM_HEADLINES
headline stream.
=back
=cut
# stream data structure part constants
_startupGenerateConstants(
'STREAM_IDENT', # stream data identifier;
'STREAM_DOCSTREAMS', # list of document streams (hash);
'STREAM_TOKENS', # token stream;
'STREAM_HEADLINES', # headline stream;
);
=pod
=head2 Stream directive data structure index constants
index constants to access parts of a stream directive.
=over 4
=item STREAM_DIR_HINTS
a hash filled by the parser to control backend behaviour.
=item STREAM_DIR_TYPE
directive type constant (C<DIRECTIVE_HEADLINE>, C<DIRECTIVE_TAG> etc.)
=item STREAM_DIR_STATE
start/completion flag (C<DIRECTIVE_START>, C<DIRECTIVE_COMPLETE>).
=item STREAM_DIR_DATA
beginning of the data part, depends on directive type.
=back
=cut
# stream directive data structure index constants
_startupGenerateConstants(
'STREAM_DIR_HINTS', # backend hints stored by the parser;
'STREAM_DIR_TYPE', # directive type;
'STREAM_DIR_STATE', # directive state (starting, complete);
'STREAM_DIR_DATA', # data part (index of first element);
);
=pod
=head2 Document stream handling constants
declare how document streams should be handled by the parser.
=over 4
=item DSTREAM_DEFAULT
Document stream entry points are streamed directly - so the backend
can handle them.
=item DSTREAM_IGNORE
Document streams (except of the main stream) are completely ignored.
=item DSTREAM_HEADLINES
Document stream entry points are streamed as headlines.
=back
=cut
# declare display constants
_startupGenerateConstants(
'DSTREAM_DEFAULT', # just stream them;
'DSTREAM_IGNORE', # ignore all streams except of "main";
'DSTREAM_HEADLINES', # stream entry points as headlines;
);
}
=pod
=head2 Trace constants
They activate trace code.
=over 4
=item TRACE_ACTIVE
activates the traces of active contents evaluation.
=item TRACE_BACKEND
activates backend traces;
=item TRACE_LEXER
activates the traces of the lexical analysis.
=item TRACE_NOTHING
deactivates all trace codes. (In fact, it I<does not activate> any trace.
If you decide to combine it with other trace constants, it will cause nothing.)
=item TRACE_PARAGRAPHS
activates traces which show the paragraphs recognized when they are entered
or completed.
=item TRACE_PARSER
activates the traces of the syntactical analysis.
=item TRACE_SEMANTIC
activates the traces of the semantic analysis.
=item TRACE_TMPFILES
deactivates the removal of temporary files.
=back
=cut
# declare trace constants (take care of correct values)
use constant 'TRACE_NOTHING' => 0; # MUST be 0!
use constant 'TRACE_PARAGRAPHS' => 1;
use constant 'TRACE_LEXER' => 2;
use constant 'TRACE_PARSER' => 4;
use constant 'TRACE_SEMANTIC' => 8;
use constant 'TRACE_ACTIVE' => 16;
use constant 'TRACE_BACKEND' => 32;
use constant 'TRACE_TMPFILES' => 64;
=pod
=head2 Display constants
determine if information messages should be suppressed.
=over 4
=item DISPLAY_ALL
all messages are displayed. (More correctly, no message is suppressed.
If you combine this constant with other display constants, it will take
no effect.)
=item DISPLAY_NOINFO
suppresses information messages;
=item DISPLAY_NOWARN
suppresses warnings;
=back
=cut
# declare display constants
use constant 'DISPLAY_ALL' => 0; # MUST be 0!
use constant 'DISPLAY_NOINFO' => 1; # suppress informations;
use constant 'DISPLAY_NOWARN' => 2; # suppress warnings;
=pod
=head2 Cache constants
specify how presentation files shall be cached.
=over 4
=item CACHE_OFF
Files are reparsed completely regardless of cache data. Existing cache data
remain untouched.
=item CACHE_ON
While reading the presentation descriptions, cached and unchanged paragraphs
are reloaded from the cache if possible. New or modified paragraphs are stored
to accelerate repeated reading.
Please note that this will not overwrite or remove previously stored cache data for modified
or deleted paragraphs. Old cache data remains in the cache, while new data is added - the
cache size continously grows.
=item CACHE_CLEANUP
Cleans up an existing cache before the parser starts (and possibly rebuilds it).
=back
=cut
# declare cache constants
use constant 'CACHE_OFF' => 0; # MUST be 0! Deactivates the cache.
use constant 'CACHE_ON' => 1; # activates the cache;
use constant 'CACHE_CLEANUP' => 2; # cache cleanup;
=pod
=head2 Template action constants
flag which way a template engine should perform an action.
=over 4
=item TEMPLATE_ACTION_DOC
Produce files which are needed I<once> (per document).
=item TEMPLATE_ACTION_INDEX
Processes the index page.
=item TEMPLATE_ACTION_PAGE
Produce a page.
=item TEMPLATE_ACTION_PAGE_SUPPLEMENTS
Produce additional files belonging to a page.
=item TEMPLATE_ACTION_TOC
Processes the table of contents page.
=back
=cut
# template action constants
_startupGenerateConstants(
'TEMPLATE_ACTION_DOC', # process doc data;
'TEMPLATE_ACTION_INDEX', # process index;
'TEMPLATE_ACTION_PAGE', # process page data;
'TEMPLATE_ACTION_PAGE_SUPPLEMENTS', # process page supplement files;
'TEMPLATE_ACTION_TOC', # process TOC template;
);
=pod
=head2 String constants
used for various purposes.
=over 4
=item DUMMY_TOKEN
a pseudo token added for reasons of parsing, which the backend can delete from the stream.
=back
=cut
use constant DUMMY_TOKEN => '__DUMMY__TOKEN__';
# release memory
undef &_startupGenerateConstants;
# modules
use Exporter;
@ISA=qw(Exporter);
# declare exports
@EXPORT=qw(
DIRECTIVE_START
DIRECTIVE_COMPLETE
DIRECTIVE_BLOCK
DIRECTIVE_COMMENT
DIRECTIVE_DLIST
DIRECTIVE_DOCUMENT
DIRECTIVE_DPOINT
DIRECTIVE_DPOINT_ITEM
DIRECTIVE_DPOINT_TEXT
DIRECTIVE_DSTREAM_ENTRYPOINT
DIRECTIVE_HEADLINE
DIRECTIVE_LIST_LSHIFT
DIRECTIVE_LIST_RSHIFT
DIRECTIVE_NEW_LINE
DIRECTIVE_OLIST
DIRECTIVE_OPOINT
DIRECTIVE_VARRESET
DIRECTIVE_TAG
DIRECTIVE_TEXT
DIRECTIVE_ULIST
DIRECTIVE_UPOINT
DIRECTIVE_VARSET
DIRECTIVE_VERBATIM
DIRECTIVE_SIMPLE
DIRECTIVE_EVERY
TRACE_ACTIVE
TRACE_BACKEND
TRACE_LEXER
TRACE_NOTHING
TRACE_PARAGRAPHS
TRACE_PARSER
TRACE_SEMANTIC
TRACE_TMPFILES
DISPLAY_ALL
DISPLAY_NOINFO
DISPLAY_NOWARN
CACHE_OFF
CACHE_ON
CACHE_CLEANUP
DSTREAM_DEFAULT
DSTREAM_IGNORE
DSTREAM_HEADLINES
DUMMY_TOKEN
);
%EXPORT_TAGS=(
parsing => [qw(PARSING_OK PARSING_COMPLETED PARSING_ERROR PARSING_FAILED PARSING_IGNORE PARSING_ERASE)],
stream => [qw(
STREAM_IDENT STREAM_DOCSTREAMS STREAM_TOKENS STREAM_HEADLINES
STREAM_DIR_HINTS STREAM_DIR_TYPE STREAM_DIR_STATE STREAM_DIR_DATA
)],
tags => [qw(TAGS_OPTIONAL TAGS_MANDATORY TAGS_DISABLED)],
templates => [qw(
TEMPLATE_ACTION_DOC
TEMPLATE_ACTION_INDEX
TEMPLATE_ACTION_PAGE
TEMPLATE_ACTION_PAGE_SUPPLEMENTS
TEMPLATE_ACTION_TOC
)],
);
Exporter::export_ok_tags(
qw(
parsing
stream
tags
templates
)
);
1;
# = POD TRAILER SECTION =================================================================
=pod
=head1 SEE ALSO
=over 4
=item B<PerlPoint::Parser>
A parser for Perl Point ASCII texts.
=item B<PerlPoint::Backend>
A frame class to write Perl Point backends.
=back
=head1 SUPPORT
A PerlPoint mailing list is set up to discuss usage, ideas,
bugs, suggestions and translator development. To subscribe,
please send an empty message to perlpoint-subscribe@perl.org.
If you prefer, you can contact me via perl@jochen-stenzel.de
as well.
=head1 AUTHOR
Copyright (c) Jochen Stenzel (perl@jochen-stenzel.de), 1999-2004.
All rights reserved.
This module is free software, you can redistribute it and/or modify it
under the terms of the Artistic License distributed with Perl version
5.003 or (at your option) any later version. Please refer to the
Artistic License that came with your Perl distribution for more
details.
The Artistic License should have been included in your distribution of
Perl. It resides in the file named "Artistic" at the top-level of the
Perl source tree (where Perl was downloaded/unpacked - ask your
system administrator if you dont know where this is). Alternatively,
the current version of the Artistic License distributed with Perl can
be viewed on-line on the World-Wide Web (WWW) from the following URL:
http://www.perl.com/perl/misc/Artistic.html
=head1 DISCLAIMER
This software is distributed in the hope that it will be useful, but
is provided "AS IS" WITHOUT WARRANTY OF ANY KIND, either expressed or
implied, INCLUDING, without limitation, the implied warranties of
MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE.
The ENTIRE RISK as to the quality and performance of the software
IS WITH YOU (the holder of the software). Should the software prove
defective, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
IN NO EVENT WILL ANY COPYRIGHT HOLDER OR ANY OTHER PARTY WHO MAY CREATE,
MODIFY, OR DISTRIBUTE THE SOFTWARE BE LIABLE OR RESPONSIBLE TO YOU OR TO
ANY OTHER ENTITY FOR ANY KIND OF DAMAGES (no matter how awful - not even
if they arise from known or unknown flaws in the software).
Please refer to the Artistic License that came with your Perl
distribution for more details.
=cut
| 27.909794 | 132 | 0.603195 |
73d28cae7b1195c1eb547a81a21e74958680a74c | 974 | pm | Perl | tools/test_modules/m11750.pm | arjunm8/hashcat | 61e8368592e7ba0db1fe2ce4b0ac58d876b8c071 | [
"MIT"
]
| 1 | 2021-05-05T11:29:07.000Z | 2021-05-05T11:29:07.000Z | tools/test_modules/m11750.pm | snowphantom/hashcat | dc9a246893d8bec9a5b2412f372617a165ad9bcf | [
"MIT"
]
| null | null | null | tools/test_modules/m11750.pm | snowphantom/hashcat | dc9a246893d8bec9a5b2412f372617a165ad9bcf | [
"MIT"
]
| null | null | null | #!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
sub module_constraints { [[0, 256], [0, 256], [-1, -1], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $python_code = <<"END_CODE";
import binascii
import hmac
import sys
from pygost import gost34112012256
key = b"$word"
msg = b"$salt"
digest = hmac.new (key, msg, gost34112012256).digest ()
sys.stdout.write (binascii.hexlify (digest[::-1]))
END_CODE
my $digest = `python2 -c '$python_code'`;
my $hash = sprintf ("%s:%s", $digest, $salt);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $salt, $word) = split (':', $line);
return unless defined $hash;
return unless defined $salt;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt);
return ($new_hash, $word);
}
1;
| 17.709091 | 77 | 0.634497 |
73fb85967d0c095a4803610cfb0018894bce4f49 | 57 | pl | Perl | Arithmetic/08.pl | dvberkel/99-prolog-problems | a69926cef25d271804312dec49ffcb100862f0ac | [
"MIT"
]
| 2 | 2021-03-29T13:48:24.000Z | 2021-10-31T10:52:24.000Z | Arithmetic/08.pl | dvberkel/99-prolog-problems | a69926cef25d271804312dec49ffcb100862f0ac | [
"MIT"
]
| null | null | null | Arithmetic/08.pl | dvberkel/99-prolog-problems | a69926cef25d271804312dec49ffcb100862f0ac | [
"MIT"
]
| 1 | 2021-08-07T19:06:45.000Z | 2021-08-07T19:06:45.000Z | :- ['07'].
co_prime(P, Q) :- gcd(P, Q, Gcd), Gcd =:= 1.
| 14.25 | 44 | 0.421053 |
ed3bd53f799f1136a4c41cc53dc6a18e2bd8f534 | 14,811 | pl | Perl | phylogenomics/ens_single-copy_core_genes.pl | ammarabdalrahem/plant-scripts | 4a209f1bcfbbd09efb88931a5bc7dde7b798685a | [
"Apache-2.0"
]
| 9 | 2021-01-27T15:37:57.000Z | 2022-02-15T08:05:50.000Z | phylogenomics/ens_single-copy_core_genes.pl | ammarabdalrahem/plant-scripts | 4a209f1bcfbbd09efb88931a5bc7dde7b798685a | [
"Apache-2.0"
]
| 2 | 2021-12-01T13:02:43.000Z | 2022-01-24T07:53:37.000Z | phylogenomics/ens_single-copy_core_genes.pl | ammarabdalrahem/plant-scripts | 4a209f1bcfbbd09efb88931a5bc7dde7b798685a | [
"Apache-2.0"
]
| 8 | 2020-10-22T11:30:53.000Z | 2022-03-19T07:51:46.000Z | #!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Benchmark;
use Data::Dumper;
use HTTP::Tiny;
use JSON qw(decode_json);
use FindBin '$Bin';
use lib $Bin;
use PlantCompUtils qw(
download_compara_TSV_file perform_rest_action transverse_tree_json
minimize_MSA $REQUEST_COUNT $COMPARADIR @DIVISIONS
);
# Retrieves single-copy orthologous genes/proteins shared by (plant) species in clade
# by querying pre-computed Compara data from Ensembl Genomes with a reference genome.
# Multiple copies are optionally allowed for selected or all species.
#
# Copyright [2019-2021] EMBL-European Bioinformatics Institute
# Ensembl Genomes
my $RESTURL = 'http://rest.ensembl.org';
my $INFOPOINT = $RESTURL . '/info/genomes/division/';
my $TAXOPOINT = $RESTURL . '/info/genomes/taxonomy/';
my $TREEPOINT = $RESTURL . '/genetree/member/id/';
my $downloadir = $Bin . '/downloads';
my $verbose = 0;
my $division = 'Plants';
my $taxonid = ''; # NCBI Taxonomy id, Brassicaceae=3700
# Asterids=71274, Poaceae=4479
my $ref_genome =
'arabidopsis_thaliana'; # should be diploid and contained in $taxonid;
my $seqtype = 'protein';
my $comparadir = '';
my $outfolder = '';
my $out_genome = '';
my ( $help, $sp, $show_supported, $request, $response );
my ( $GOC, $WGA, $one2many, $LOWCONF ) = ( 0, 0, 0, 0 );
my ( @multi_species, @ignore_species, %ignore, %polyploid,
%division_supported );
GetOptions(
"help|?" => \$help,
"verbose|v" => \$verbose,
"supported|l" => \$show_supported,
"division|d=s" => \$division,
"clade|c=s" => \$taxonid,
"reference|r=s" => \$ref_genome,
"outgroup|o=s" => \$out_genome,
"multicopy|m=s" => \@multi_species,
"ignore|i=s" => \@ignore_species,
"type|t=s" => \$seqtype,
"GOC|G=i" => \$GOC,
"WGA|W=i" => \$WGA,
"LC|L" => \$LOWCONF,
"folder|f=s" => \$outfolder
) || help_message();
sub help_message {
print "\nusage: $0 [options]\n\n"
. "-c NCBI Taxonomy clade of interest (required, example: -c Brassicaceae or -c 3700)\n"
. "-l list supported species_names (optional, example: -l)\n"
. "-d Ensembl division (optional, default: -d $division)\n"
. "-r reference species_name (optional, default: -r $ref_genome)\n"
. "-o outgroup species_name (optional, example: -o brachypodium_distachyon)\n"
. "-m multi-copy species_name(s) (optional, example: -m brassica_napus -m ... -m all)\n"
. "-i ignore species_name(s) (optional, example: -i selaginella_moellendorffii -i ...)\n"
. "-f folder to output FASTA files (optional, example: -f myfolder)\n"
. "-t sequence type [protein|cdna] (optional, requires -f, default: -t protein)\n"
. "-L allow low-confidence orthologues (optional, by default these are skipped)\n"
. "-v verbose (optional, example: -v\n";
print "\nThe following options are only available for some clades:\n\n"
. "-G min Gene Order Conservation [0:100] (optional, example: -G 75)\n"
. " see modules/Bio/EnsEMBL/Compara/PipeConfig/EBI/Plants/ProteinTrees_conf.pm\n"
. " at https://github.com/Ensembl/ensembl-compara\n\n"
. "-W min Whole Genome Align score [0:100] (optional, example: -W 75)\n"
. " see ensembl-compara/scripts/pipeline/compara_plants.xml\n"
. " at https://github.com/Ensembl/ensembl-compara\n\n";
print "Read about GOC and WGA at:\n"
. "https://www.ensembl.org/info/genome/compara/Ortholog_qc_manual.html\n\n";
print "Example calls:\n\n"
. " perl $0 -c Brassicaceae -f Brassicaceae\n"
. " perl $0 -c Brassicaceae -f Brassicaceae -t cdna -o beta_vulgaris\n"
. " perl $0 -f poaceae -c 4479 -r oryza_sativa -WGA 75\n"
. " perl $0 -f all -c 33090 -m all -r physcomitrella_patens\n";
exit(0);
}
if ($help) { help_message() }
if ($division) {
if ( !grep( /^$division$/, @PlantCompUtils::DIVISIONS ) ) {
die "# ERROR: accepted values for division are: "
. join( ',', @PlantCompUtils::DIVISIONS ) . "\n";
}
else {
$comparadir = $PlantCompUtils::COMPARADIR;
my $lcdiv = lc($division);
$comparadir =~ s/xxx/$lcdiv/;
}
}
if ($show_supported) {
print "# $0 -d $division -l \n\n";
}
else {
if ( $taxonid eq '' ) {
print "# ERROR: need a valid NCBI Taxonomy clade, ".
"such as -c Brassicaceae or -c 3700\n\n";
print "# Check https://www.ncbi.nlm.nih.gov/taxonomy\n";
exit;
}
else {
$taxonid =~ s/\s+/%20/g;
}
if (@ignore_species) {
foreach my $sp (@ignore_species) {
$ignore{$sp} = 1;
}
printf( "\n# ignored species : %d\n\n", scalar( keys(%ignore) ) );
}
# species for which one2many orths are allowed, such as polyploid species
# with scaffold level assemblies or species with ancestral genome duplications
if (@multi_species) {
foreach my $sp (@multi_species) {
if ( $sp eq 'all' ) {
$one2many = 1;
%polyploid = ();
$polyploid{$sp} = 1;
last;
}
else { $polyploid{$sp} = 1 }
}
if ($one2many) { print "\n# multi-copy species : all\n\n" }
else {
printf( "\n# multi-copy species : %d\n\n",
scalar( keys(%polyploid) ) );
}
}
if ($outfolder) {
if ( -e $outfolder ) {
print "\n# WARNING : folder '$outfolder' exists, files might be overwritten\n\n";
}
else {
if ( !mkdir($outfolder) ) {
die "# ERROR: cannot create $outfolder\n";
}
}
if ( $seqtype ne 'protein' && $seqtype ne 'cdna' ) {
die "# ERROR: accepted values for seqtype are: protein|cdna\n";
}
}
print "# $0 -d $division -c $taxonid -r $ref_genome -o $out_genome "
. "-f $outfolder -t $seqtype -G $GOC -W $WGA -L $LOWCONF\n\n";
}
my $start_time = new Benchmark();
# new object and params for REST requests
my $http = HTTP::Tiny->new();
my $global_headers = { 'Content-Type' => 'application/json' };
$PlantCompUtils::REQUEST_COUNT = 0;
## 0) check supported species in division
$request = $INFOPOINT . "Ensembl$division?";
$response = perform_rest_action( $http, $request, $global_headers );
my $infodump = decode_json($response);
foreach $sp ( @{$infodump} ) {
if ( $sp->{'has_peptide_compara'} ) {
$division_supported{ $sp->{'name'} } = 1;
}
}
# list supported species and exit
if ($show_supported) {
foreach $sp ( sort( keys(%division_supported) ) ) {
print "$sp\n";
}
exit;
}
# check outgroup is supported
if ( $out_genome && !$division_supported{$out_genome} ) {
die "# ERROR: genome $out_genome is not supported\n";
}
## 1) check species in clade
my $n_of_species = 0;
my ( @supported_species, %supported, %core, %present );
$request = $TAXOPOINT . "$taxonid?";
$response = perform_rest_action( $http, $request, $global_headers );
$infodump = decode_json($response);
foreach $sp ( @{$infodump} ) {
if ( $sp->{'name'} && $division_supported{ $sp->{'name'} } ) {
next if ( $ignore{ $sp->{'name'} } );
push( @supported_species, $sp->{'name'} );
$supported{ $sp->{'name'} } = 1;
print "# " . $sp->{'name'} . "\n" if ($verbose);
}
}
printf( "# supported species in NCBI taxon %s : %d\n\n",
$taxonid, scalar(@supported_species) );
# check reference genome is supported and is not polyploid
if ( !grep( /$ref_genome/, @supported_species ) ) {
die "# ERROR: cannot find $ref_genome within NCBI taxon $taxonid\n";
}
elsif ( $polyploid{$ref_genome} ) {
die "# ERROR: $ref_genome is polyploid; reference genome must be diploid\n";
}
# add outgroup if required
if ($out_genome) {
push( @supported_species, $out_genome );
$supported{$out_genome} = 1;
print "# outgenome: $out_genome\n";
}
$n_of_species = scalar(@supported_species);
print "# total selected species : $n_of_species\n\n";
## 2) get orthologous (plant) genes shared by $ref_genome and other species
# columns of TSV file
my (
$gene_stable_id, $prot_stable_id, $species,
$identity, $homology_type, $hom_gene_stable_id,
$hom_prot_stable_id, $hom_species, $hom_identity,
$dn, $ds, $goc_score,
$wga_coverage, $high_confidence
);
# get TSV file
my $stored_compara_file =
download_compara_TSV_file( $comparadir, $ref_genome, $downloadir );
# uncompress on the fly and parse
my (@sorted_ids);
open( TSV, "gzip -dc $stored_compara_file |" )
|| die "# ERROR: cannot open $stored_compara_file\n";
while (<TSV>) {
(
$gene_stable_id, $prot_stable_id, $species,
$identity, $homology_type, $hom_gene_stable_id,
$hom_prot_stable_id, $hom_species, $hom_identity,
$dn, $ds, $goc_score,
$wga_coverage, $high_confidence
) = split(/\t/);
if ( $species ne $ref_genome ) {
if ( keys(%present) == $n_of_species ) {
last;
} # in case all-vs-all file is used
else { next }
}
next if ( !$supported{$hom_species} || $hom_species eq $ref_genome );
if ( defined($high_confidence) ) {
next
if ( $LOWCONF == 0
&& ( $high_confidence eq 'NULL' || $high_confidence == 0 ) );
}
next if ( $WGA && ( $wga_coverage eq 'NULL' || $wga_coverage < $WGA ) );
next if ( $GOC && ( $goc_score eq 'NULL' || $goc_score < $GOC ) );
if (
$homology_type eq 'ortholog_one2one'
|| ( ( $one2many || $polyploid{$hom_species} )
&& $homology_type eq 'ortholog_one2many' )
)
{
# add $ref_genome protein
if ( !$core{$gene_stable_id} ) {
push( @{ $core{$gene_stable_id}{$ref_genome} }, $prot_stable_id );
$present{$ref_genome}++;
push( @sorted_ids, $gene_stable_id ); # save cluster order
}
push( @{ $core{$gene_stable_id}{$hom_species} }, $hom_prot_stable_id );
$present{$hom_species}++;
}
}
close(TSV);
# check GOC / WGA availability
foreach $hom_species (@supported_species) {
if ( !defined( $present{$hom_species} ) && $WGA ) {
print "# WGA not available: $hom_species\n";
}
elsif ( !defined( $present{$hom_species} ) && $GOC ) {
print "# GOC not available: $hom_species\n";
}
}
## 3) print summary matrix of single-copy / core genes and compile sequence clusters
my $total_core_clusters = 0;
my ( $pruned_species, $treedump, $acc, $seq, $line, $filename );
# prepare param to prune species in REST requests
if ($outfolder) {
foreach $hom_species (@supported_species) {
$pruned_species .= "prune_species=$hom_species;";
}
}
foreach $gene_stable_id (@sorted_ids) {
next if ( scalar( keys( %{ $core{$gene_stable_id} } ) ) < $n_of_species );
my ( %valid_prots, %align );
$filename = $gene_stable_id;
if ($outfolder) {
if ( $seqtype eq 'protein' ) { $filename .= '.faa' }
else { $filename .= '.fna' }
}
# print matrix header
if ( $total_core_clusters == 0 ) {
print "cluster";
foreach $hom_species (@supported_species) {
print "\t$hom_species";
}
print "\n";
}
# print a matrix row in TSV format
print $filename;
foreach $hom_species (@supported_species) {
printf( "\t%s",
join( ',', @{ $core{$gene_stable_id}{$hom_species} } ) );
# store which prots come from each species
foreach $hom_prot_stable_id (
@{ $core{$gene_stable_id}{$hom_species} } )
{
$valid_prots{$hom_prot_stable_id} = $hom_species;
}
}
print "\n";
# retrieve cluster sequences
if ($outfolder) {
# check whether this cluster already exists
if ( -s "$outfolder/$filename" ) {
$total_core_clusters++;
next;
}
# make REST request and parse dumped JSON
$request = "$TREEPOINT$gene_stable_id?compara=$division;".
"aligned=1;sequence=$seqtype;$pruned_species";
$response = perform_rest_action( $http, $request, $global_headers );
$treedump = decode_json($response);
# parse sequences in that tree
my %tree_seqs;
transverse_tree_json( $treedump->{'tree'}, \%tree_seqs );
foreach $acc ( keys(%tree_seqs) ) {
if ( $valid_prots{$acc} ) {
$align{ $valid_prots{$acc} }{$acc} = $tree_seqs{$acc};
$valid_prots{$acc} .= " found";
}
}
# minimize alignment and save cluster to file
if ( scalar( keys(%align) ) == $n_of_species ) {
my $min_align = minimize_MSA( \%align );
open( FASTA, ">", "$outfolder/$filename" )
|| die "# ERROR: cannot create $outfolder/$filename\n";
foreach $hom_species (@supported_species) {
foreach $hom_prot_stable_id (
@{ $core{$gene_stable_id}{$hom_species} } )
{
print FASTA ">$hom_species $hom_prot_stable_id\n".
"$min_align->{ $hom_species }{ $hom_prot_stable_id }\n";
}
}
close(FASTA);
}
else
{ # might occur with low-confidence orths in split trees and same supertree
if ($verbose) {
print "# WARNING: cannot retrieve aligned sequences for $gene_stable_id : ";
foreach $acc ( keys(%valid_prots) ) {
next if ( $valid_prots{$acc} =~ m/ found/ );
print "# $acc $valid_prots{$acc},";
}
print "\n";
}
}
}
$total_core_clusters++; #last if($total_core_clusters == 1); # debug
}
print "\n# total single-copy core clusters : $total_core_clusters\n\n";
# print diagnostics
if ( $total_core_clusters == 0 ) {
print "# diagnostic stats (species\tclusters)\n\n";
foreach $hom_species (@supported_species) {
$present{$hom_species} = 0 unless ( $present{$hom_species} );
}
foreach $hom_species ( sort { $present{$a} <=> $present{$b} }
(@supported_species) )
{
printf( "%s %d\n", $hom_species, $present{$hom_species} );
}
}
my $end_time = new Benchmark();
print "\n# runtime: "
. timestr( timediff( $end_time, $start_time ), 'all' ) . "\n";
| 32.127983 | 106 | 0.57383 |
73e12c4966a4454a25d0e4947b1fd54bf3b1afab | 1,234 | t | Perl | t/opt_suffix.t | ntnl/Fed | f7be1c4d9d4be559fc99e7eb28e729d4423cca8f | [
"Artistic-1.0"
]
| 2 | 2016-02-06T14:12:35.000Z | 2021-12-28T06:55:59.000Z | t/opt_suffix.t | ntnl/Fed | f7be1c4d9d4be559fc99e7eb28e729d4423cca8f | [
"Artistic-1.0"
]
| null | null | null | t/opt_suffix.t | ntnl/Fed | f7be1c4d9d4be559fc99e7eb28e729d4423cca8f | [
"Artistic-1.0"
]
| null | null | null | #!/usr/bin/perl
################################################################################
#
# fed - File editor.
#
# Copyright (C) 2011 Bartłomiej /Natanael/ Syguła
#
# This is free software.
# It is licensed, and can be distributed under the same terms as Perl itself.
#
################################################################################
use strict; use warnings; # {{{
use FindBin qw( $Bin );
use English qw( -no_match_vars );
use File::Slurp qw( read_file );
use File::Temp qw( tempfile );
use Test::More;
# }}}
# Debug:
use lib $Bin . q{/../lib};
plan tests => 3;
use App::Fed;
my ($t_fh, $t_path, $t_new_path);
($t_fh, $t_path) = tempfile();
print $t_fh read_file($Bin . q{/../t_data/text_H.txt}); close $t_fh;
$t_new_path = $t_path .q{.new}; # FIXME: This is SO lame, but I'm not aiming at supporting Windows at the moment (this will change, hence this note exists)
is(
App::Fed::main(q{-S}, q{.new}, q{s/world/universe/}, $t_path),
0,
'Save to file with suffix added to the name.'
);
is(
read_file($t_path),
qq{Hello world!\n},
q{Siffix - check original},
);
is(
read_file($t_new_path),
qq{Hello universe!\n},
q{Suffix - check result},
);
# vim: fdm=marker
| 22.436364 | 155 | 0.552674 |
ed489af1c91acce7a9c178d7c0353caa13fa4e2a | 74,832 | pl | Perl | node_modules/grpc/third_party/boringssl/crypto/aes/asm/aes-x86_64.pl | bharathappali/carousel-makeover | dd905a12ab6bda280fa79df289827e5f210722d7 | [
"Apache-2.0"
]
| 91 | 2018-11-24T05:33:58.000Z | 2022-03-16T05:58:05.000Z | node_modules/grpc/third_party/boringssl/crypto/aes/asm/aes-x86_64.pl | bharathappali/carousel-makeover | dd905a12ab6bda280fa79df289827e5f210722d7 | [
"Apache-2.0"
]
| 11 | 2019-06-02T23:50:17.000Z | 2022-02-04T23:58:56.000Z | node_modules/grpc/third_party/boringssl/crypto/aes/asm/aes-x86_64.pl | bharathappali/carousel-makeover | dd905a12ab6bda280fa79df289827e5f210722d7 | [
"Apache-2.0"
]
| 18 | 2018-11-24T10:35:29.000Z | 2021-04-22T07:22:10.000Z | #!/usr/bin/env perl
#
# ====================================================================
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/.
# ====================================================================
#
# Version 2.1.
#
# aes-*-cbc benchmarks are improved by >70% [compared to gcc 3.3.2 on
# Opteron 240 CPU] plus all the bells-n-whistles from 32-bit version
# [you'll notice a lot of resemblance], such as compressed S-boxes
# in little-endian byte order, prefetch of these tables in CBC mode,
# as well as avoiding L1 cache aliasing between stack frame and key
# schedule and already mentioned tables, compressed Td4...
#
# Performance in number of cycles per processed byte for 128-bit key:
#
# ECB encrypt ECB decrypt CBC large chunk
# AMD64 33 43 13.0
# EM64T 38 56 18.6(*)
# Core 2 30 42 14.5(*)
# Atom 65 86 32.1(*)
#
# (*) with hyper-threading off
$flavour = shift;
$output = shift;
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl";
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
*STDOUT=*OUT;
$verticalspin=1; # unlike 32-bit version $verticalspin performs
# ~15% better on both AMD and Intel cores
$speed_limit=512; # see aes-586.pl for details
$code=".text\n";
$s0="%eax";
$s1="%ebx";
$s2="%ecx";
$s3="%edx";
$acc0="%esi"; $mask80="%rsi";
$acc1="%edi"; $maskfe="%rdi";
$acc2="%ebp"; $mask1b="%rbp";
$inp="%r8";
$out="%r9";
$t0="%r10d";
$t1="%r11d";
$t2="%r12d";
$rnds="%r13d";
$sbox="%r14";
$key="%r15";
sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/; $r; }
sub lo() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1l/;
$r =~ s/%[er]([sd]i)/%\1l/;
$r =~ s/%(r[0-9]+)[d]?/%\1b/; $r; }
sub LO() { my $r=shift; $r =~ s/%r([a-z]+)/%e\1/;
$r =~ s/%r([0-9]+)/%r\1d/; $r; }
sub _data_word()
{ my $i;
while(defined($i=shift)) { $code.=sprintf".long\t0x%08x,0x%08x\n",$i,$i; }
}
sub data_word()
{ my $i;
my $last=pop(@_);
$code.=".long\t";
while(defined($i=shift)) { $code.=sprintf"0x%08x,",$i; }
$code.=sprintf"0x%08x\n",$last;
}
sub data_byte()
{ my $i;
my $last=pop(@_);
$code.=".byte\t";
while(defined($i=shift)) { $code.=sprintf"0x%02x,",$i&0xff; }
$code.=sprintf"0x%02x\n",$last&0xff;
}
sub encvert()
{ my $t3="%r8d"; # zaps $inp!
$code.=<<___;
# favor 3-way issue Opteron pipeline...
movzb `&lo("$s0")`,$acc0
movzb `&lo("$s1")`,$acc1
movzb `&lo("$s2")`,$acc2
mov 0($sbox,$acc0,8),$t0
mov 0($sbox,$acc1,8),$t1
mov 0($sbox,$acc2,8),$t2
movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1
movzb `&lo("$s3")`,$acc2
xor 3($sbox,$acc0,8),$t0
xor 3($sbox,$acc1,8),$t1
mov 0($sbox,$acc2,8),$t3
movzb `&hi("$s3")`,$acc0
shr \$16,$s2
movzb `&hi("$s0")`,$acc2
xor 3($sbox,$acc0,8),$t2
shr \$16,$s3
xor 3($sbox,$acc2,8),$t3
shr \$16,$s1
lea 16($key),$key
shr \$16,$s0
movzb `&lo("$s2")`,$acc0
movzb `&lo("$s3")`,$acc1
movzb `&lo("$s0")`,$acc2
xor 2($sbox,$acc0,8),$t0
xor 2($sbox,$acc1,8),$t1
xor 2($sbox,$acc2,8),$t2
movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1
movzb `&lo("$s1")`,$acc2
xor 1($sbox,$acc0,8),$t0
xor 1($sbox,$acc1,8),$t1
xor 2($sbox,$acc2,8),$t3
mov 12($key),$s3
movzb `&hi("$s1")`,$acc1
movzb `&hi("$s2")`,$acc2
mov 0($key),$s0
xor 1($sbox,$acc1,8),$t2
xor 1($sbox,$acc2,8),$t3
mov 4($key),$s1
mov 8($key),$s2
xor $t0,$s0
xor $t1,$s1
xor $t2,$s2
xor $t3,$s3
___
}
sub enclastvert()
{ my $t3="%r8d"; # zaps $inp!
$code.=<<___;
movzb `&lo("$s0")`,$acc0
movzb `&lo("$s1")`,$acc1
movzb `&lo("$s2")`,$acc2
movzb 2($sbox,$acc0,8),$t0
movzb 2($sbox,$acc1,8),$t1
movzb 2($sbox,$acc2,8),$t2
movzb `&lo("$s3")`,$acc0
movzb `&hi("$s1")`,$acc1
movzb `&hi("$s2")`,$acc2
movzb 2($sbox,$acc0,8),$t3
mov 0($sbox,$acc1,8),$acc1 #$t0
mov 0($sbox,$acc2,8),$acc2 #$t1
and \$0x0000ff00,$acc1
and \$0x0000ff00,$acc2
xor $acc1,$t0
xor $acc2,$t1
shr \$16,$s2
movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1
shr \$16,$s3
mov 0($sbox,$acc0,8),$acc0 #$t2
mov 0($sbox,$acc1,8),$acc1 #$t3
and \$0x0000ff00,$acc0
and \$0x0000ff00,$acc1
shr \$16,$s1
xor $acc0,$t2
xor $acc1,$t3
shr \$16,$s0
movzb `&lo("$s2")`,$acc0
movzb `&lo("$s3")`,$acc1
movzb `&lo("$s0")`,$acc2
mov 0($sbox,$acc0,8),$acc0 #$t0
mov 0($sbox,$acc1,8),$acc1 #$t1
mov 0($sbox,$acc2,8),$acc2 #$t2
and \$0x00ff0000,$acc0
and \$0x00ff0000,$acc1
and \$0x00ff0000,$acc2
xor $acc0,$t0
xor $acc1,$t1
xor $acc2,$t2
movzb `&lo("$s1")`,$acc0
movzb `&hi("$s3")`,$acc1
movzb `&hi("$s0")`,$acc2
mov 0($sbox,$acc0,8),$acc0 #$t3
mov 2($sbox,$acc1,8),$acc1 #$t0
mov 2($sbox,$acc2,8),$acc2 #$t1
and \$0x00ff0000,$acc0
and \$0xff000000,$acc1
and \$0xff000000,$acc2
xor $acc0,$t3
xor $acc1,$t0
xor $acc2,$t1
movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1
mov 16+12($key),$s3
mov 2($sbox,$acc0,8),$acc0 #$t2
mov 2($sbox,$acc1,8),$acc1 #$t3
mov 16+0($key),$s0
and \$0xff000000,$acc0
and \$0xff000000,$acc1
xor $acc0,$t2
xor $acc1,$t3
mov 16+4($key),$s1
mov 16+8($key),$s2
xor $t0,$s0
xor $t1,$s1
xor $t2,$s2
xor $t3,$s3
___
}
sub encstep()
{ my ($i,@s) = @_;
my $tmp0=$acc0;
my $tmp1=$acc1;
my $tmp2=$acc2;
my $out=($t0,$t1,$t2,$s[0])[$i];
if ($i==3) {
$tmp0=$s[1];
$tmp1=$s[2];
$tmp2=$s[3];
}
$code.=" movzb ".&lo($s[0]).",$out\n";
$code.=" mov $s[2],$tmp1\n" if ($i!=3);
$code.=" lea 16($key),$key\n" if ($i==0);
$code.=" movzb ".&hi($s[1]).",$tmp0\n";
$code.=" mov 0($sbox,$out,8),$out\n";
$code.=" shr \$16,$tmp1\n";
$code.=" mov $s[3],$tmp2\n" if ($i!=3);
$code.=" xor 3($sbox,$tmp0,8),$out\n";
$code.=" movzb ".&lo($tmp1).",$tmp1\n";
$code.=" shr \$24,$tmp2\n";
$code.=" xor 4*$i($key),$out\n";
$code.=" xor 2($sbox,$tmp1,8),$out\n";
$code.=" xor 1($sbox,$tmp2,8),$out\n";
$code.=" mov $t0,$s[1]\n" if ($i==3);
$code.=" mov $t1,$s[2]\n" if ($i==3);
$code.=" mov $t2,$s[3]\n" if ($i==3);
$code.="\n";
}
sub enclast()
{ my ($i,@s)=@_;
my $tmp0=$acc0;
my $tmp1=$acc1;
my $tmp2=$acc2;
my $out=($t0,$t1,$t2,$s[0])[$i];
if ($i==3) {
$tmp0=$s[1];
$tmp1=$s[2];
$tmp2=$s[3];
}
$code.=" movzb ".&lo($s[0]).",$out\n";
$code.=" mov $s[2],$tmp1\n" if ($i!=3);
$code.=" mov 2($sbox,$out,8),$out\n";
$code.=" shr \$16,$tmp1\n";
$code.=" mov $s[3],$tmp2\n" if ($i!=3);
$code.=" and \$0x000000ff,$out\n";
$code.=" movzb ".&hi($s[1]).",$tmp0\n";
$code.=" movzb ".&lo($tmp1).",$tmp1\n";
$code.=" shr \$24,$tmp2\n";
$code.=" mov 0($sbox,$tmp0,8),$tmp0\n";
$code.=" mov 0($sbox,$tmp1,8),$tmp1\n";
$code.=" mov 2($sbox,$tmp2,8),$tmp2\n";
$code.=" and \$0x0000ff00,$tmp0\n";
$code.=" and \$0x00ff0000,$tmp1\n";
$code.=" and \$0xff000000,$tmp2\n";
$code.=" xor $tmp0,$out\n";
$code.=" mov $t0,$s[1]\n" if ($i==3);
$code.=" xor $tmp1,$out\n";
$code.=" mov $t1,$s[2]\n" if ($i==3);
$code.=" xor $tmp2,$out\n";
$code.=" mov $t2,$s[3]\n" if ($i==3);
$code.="\n";
}
$code.=<<___;
.type _x86_64_AES_encrypt,\@abi-omnipotent
.align 16
_x86_64_AES_encrypt:
xor 0($key),$s0 # xor with key
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
mov 240($key),$rnds # load key->rounds
sub \$1,$rnds
jmp .Lenc_loop
.align 16
.Lenc_loop:
___
if ($verticalspin) { &encvert(); }
else { &encstep(0,$s0,$s1,$s2,$s3);
&encstep(1,$s1,$s2,$s3,$s0);
&encstep(2,$s2,$s3,$s0,$s1);
&encstep(3,$s3,$s0,$s1,$s2);
}
$code.=<<___;
sub \$1,$rnds
jnz .Lenc_loop
___
if ($verticalspin) { &enclastvert(); }
else { &enclast(0,$s0,$s1,$s2,$s3);
&enclast(1,$s1,$s2,$s3,$s0);
&enclast(2,$s2,$s3,$s0,$s1);
&enclast(3,$s3,$s0,$s1,$s2);
$code.=<<___;
xor 16+0($key),$s0 # xor with key
xor 16+4($key),$s1
xor 16+8($key),$s2
xor 16+12($key),$s3
___
}
$code.=<<___;
.byte 0xf3,0xc3 # rep ret
.size _x86_64_AES_encrypt,.-_x86_64_AES_encrypt
___
# it's possible to implement this by shifting tN by 8, filling least
# significant byte with byte load and finally bswap-ing at the end,
# but such partial register load kills Core 2...
sub enccompactvert()
{ my ($t3,$t4,$t5)=("%r8d","%r9d","%r13d");
$code.=<<___;
movzb `&lo("$s0")`,$t0
movzb `&lo("$s1")`,$t1
movzb `&lo("$s2")`,$t2
movzb `&lo("$s3")`,$t3
movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1
shr \$16,$s2
movzb `&hi("$s3")`,$acc2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb ($sbox,$t3,1),$t3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb `&hi("$s0")`,$acc0
movzb ($sbox,$acc1,1),$t5 #$t1
movzb `&lo("$s2")`,$acc1
movzb ($sbox,$acc2,1),$acc2 #$t2
movzb ($sbox,$acc0,1),$acc0 #$t3
shl \$8,$t4
shr \$16,$s3
shl \$8,$t5
xor $t4,$t0
shr \$16,$s0
movzb `&lo("$s3")`,$t4
shr \$16,$s1
xor $t5,$t1
shl \$8,$acc2
movzb `&lo("$s0")`,$t5
movzb ($sbox,$acc1,1),$acc1 #$t0
xor $acc2,$t2
shl \$8,$acc0
movzb `&lo("$s1")`,$acc2
shl \$16,$acc1
xor $acc0,$t3
movzb ($sbox,$t4,1),$t4 #$t1
movzb `&hi("$s3")`,$acc0
movzb ($sbox,$t5,1),$t5 #$t2
xor $acc1,$t0
shr \$8,$s2
movzb `&hi("$s0")`,$acc1
shl \$16,$t4
shr \$8,$s1
shl \$16,$t5
xor $t4,$t1
movzb ($sbox,$acc2,1),$acc2 #$t3
movzb ($sbox,$acc0,1),$acc0 #$t0
movzb ($sbox,$acc1,1),$acc1 #$t1
movzb ($sbox,$s2,1),$s3 #$t3
movzb ($sbox,$s1,1),$s2 #$t2
shl \$16,$acc2
xor $t5,$t2
shl \$24,$acc0
xor $acc2,$t3
shl \$24,$acc1
xor $acc0,$t0
shl \$24,$s3
xor $acc1,$t1
shl \$24,$s2
mov $t0,$s0
mov $t1,$s1
xor $t2,$s2
xor $t3,$s3
___
}
sub enctransform_ref()
{ my $sn = shift;
my ($acc,$r2,$tmp)=("%r8d","%r9d","%r13d");
$code.=<<___;
mov $sn,$acc
and \$0x80808080,$acc
mov $acc,$tmp
shr \$7,$tmp
lea ($sn,$sn),$r2
sub $tmp,$acc
and \$0xfefefefe,$r2
and \$0x1b1b1b1b,$acc
mov $sn,$tmp
xor $acc,$r2
xor $r2,$sn
rol \$24,$sn
xor $r2,$sn
ror \$16,$tmp
xor $tmp,$sn
ror \$8,$tmp
xor $tmp,$sn
___
}
# unlike decrypt case it does not pay off to parallelize enctransform
sub enctransform()
{ my ($t3,$r20,$r21)=($acc2,"%r8d","%r9d");
$code.=<<___;
mov \$0x80808080,$t0
mov \$0x80808080,$t1
and $s0,$t0
and $s1,$t1
mov $t0,$acc0
mov $t1,$acc1
shr \$7,$t0
lea ($s0,$s0),$r20
shr \$7,$t1
lea ($s1,$s1),$r21
sub $t0,$acc0
sub $t1,$acc1
and \$0xfefefefe,$r20
and \$0xfefefefe,$r21
and \$0x1b1b1b1b,$acc0
and \$0x1b1b1b1b,$acc1
mov $s0,$t0
mov $s1,$t1
xor $acc0,$r20
xor $acc1,$r21
xor $r20,$s0
xor $r21,$s1
mov \$0x80808080,$t2
rol \$24,$s0
mov \$0x80808080,$t3
rol \$24,$s1
and $s2,$t2
and $s3,$t3
xor $r20,$s0
xor $r21,$s1
mov $t2,$acc0
ror \$16,$t0
mov $t3,$acc1
ror \$16,$t1
lea ($s2,$s2),$r20
shr \$7,$t2
xor $t0,$s0
shr \$7,$t3
xor $t1,$s1
ror \$8,$t0
lea ($s3,$s3),$r21
ror \$8,$t1
sub $t2,$acc0
sub $t3,$acc1
xor $t0,$s0
xor $t1,$s1
and \$0xfefefefe,$r20
and \$0xfefefefe,$r21
and \$0x1b1b1b1b,$acc0
and \$0x1b1b1b1b,$acc1
mov $s2,$t2
mov $s3,$t3
xor $acc0,$r20
xor $acc1,$r21
ror \$16,$t2
xor $r20,$s2
ror \$16,$t3
xor $r21,$s3
rol \$24,$s2
mov 0($sbox),$acc0 # prefetch Te4
rol \$24,$s3
xor $r20,$s2
mov 64($sbox),$acc1
xor $r21,$s3
mov 128($sbox),$r20
xor $t2,$s2
ror \$8,$t2
xor $t3,$s3
ror \$8,$t3
xor $t2,$s2
mov 192($sbox),$r21
xor $t3,$s3
___
}
$code.=<<___;
.type _x86_64_AES_encrypt_compact,\@abi-omnipotent
.align 16
_x86_64_AES_encrypt_compact:
lea 128($sbox),$inp # size optimization
mov 0-128($inp),$acc1 # prefetch Te4
mov 32-128($inp),$acc2
mov 64-128($inp),$t0
mov 96-128($inp),$t1
mov 128-128($inp),$acc1
mov 160-128($inp),$acc2
mov 192-128($inp),$t0
mov 224-128($inp),$t1
jmp .Lenc_loop_compact
.align 16
.Lenc_loop_compact:
xor 0($key),$s0 # xor with key
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
lea 16($key),$key
___
&enccompactvert();
$code.=<<___;
cmp 16(%rsp),$key
je .Lenc_compact_done
___
&enctransform();
$code.=<<___;
jmp .Lenc_loop_compact
.align 16
.Lenc_compact_done:
xor 0($key),$s0
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
.byte 0xf3,0xc3 # rep ret
.size _x86_64_AES_encrypt_compact,.-_x86_64_AES_encrypt_compact
___
# void asm_AES_encrypt (const void *inp,void *out,const AES_KEY *key);
$code.=<<___;
.align 16
.globl asm_AES_encrypt
.type asm_AES_encrypt,\@function,3
.hidden asm_AES_encrypt
asm_AES_encrypt:
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
# allocate frame "above" key schedule
mov %rsp,%r10
lea -63(%rdx),%rcx # %rdx is key argument
and \$-64,%rsp
sub %rsp,%rcx
neg %rcx
and \$0x3c0,%rcx
sub %rcx,%rsp
sub \$32,%rsp
mov %rsi,16(%rsp) # save out
mov %r10,24(%rsp) # save real stack pointer
.Lenc_prologue:
mov %rdx,$key
mov 240($key),$rnds # load rounds
mov 0(%rdi),$s0 # load input vector
mov 4(%rdi),$s1
mov 8(%rdi),$s2
mov 12(%rdi),$s3
shl \$4,$rnds
lea ($key,$rnds),%rbp
mov $key,(%rsp) # key schedule
mov %rbp,8(%rsp) # end of key schedule
# pick Te4 copy which can't "overlap" with stack frame or key schedule
lea .LAES_Te+2048(%rip),$sbox
lea 768(%rsp),%rbp
sub $sbox,%rbp
and \$0x300,%rbp
lea ($sbox,%rbp),$sbox
call _x86_64_AES_encrypt_compact
mov 16(%rsp),$out # restore out
mov 24(%rsp),%rsi # restore saved stack pointer
mov $s0,0($out) # write output vector
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
mov (%rsi),%r15
mov 8(%rsi),%r14
mov 16(%rsi),%r13
mov 24(%rsi),%r12
mov 32(%rsi),%rbp
mov 40(%rsi),%rbx
lea 48(%rsi),%rsp
.Lenc_epilogue:
ret
.size asm_AES_encrypt,.-asm_AES_encrypt
___
#------------------------------------------------------------------#
sub decvert()
{ my $t3="%r8d"; # zaps $inp!
$code.=<<___;
# favor 3-way issue Opteron pipeline...
movzb `&lo("$s0")`,$acc0
movzb `&lo("$s1")`,$acc1
movzb `&lo("$s2")`,$acc2
mov 0($sbox,$acc0,8),$t0
mov 0($sbox,$acc1,8),$t1
mov 0($sbox,$acc2,8),$t2
movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1
movzb `&lo("$s3")`,$acc2
xor 3($sbox,$acc0,8),$t0
xor 3($sbox,$acc1,8),$t1
mov 0($sbox,$acc2,8),$t3
movzb `&hi("$s1")`,$acc0
shr \$16,$s0
movzb `&hi("$s2")`,$acc2
xor 3($sbox,$acc0,8),$t2
shr \$16,$s3
xor 3($sbox,$acc2,8),$t3
shr \$16,$s1
lea 16($key),$key
shr \$16,$s2
movzb `&lo("$s2")`,$acc0
movzb `&lo("$s3")`,$acc1
movzb `&lo("$s0")`,$acc2
xor 2($sbox,$acc0,8),$t0
xor 2($sbox,$acc1,8),$t1
xor 2($sbox,$acc2,8),$t2
movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1
movzb `&lo("$s1")`,$acc2
xor 1($sbox,$acc0,8),$t0
xor 1($sbox,$acc1,8),$t1
xor 2($sbox,$acc2,8),$t3
movzb `&hi("$s3")`,$acc0
mov 12($key),$s3
movzb `&hi("$s0")`,$acc2
xor 1($sbox,$acc0,8),$t2
mov 0($key),$s0
xor 1($sbox,$acc2,8),$t3
xor $t0,$s0
mov 4($key),$s1
mov 8($key),$s2
xor $t2,$s2
xor $t1,$s1
xor $t3,$s3
___
}
sub declastvert()
{ my $t3="%r8d"; # zaps $inp!
$code.=<<___;
lea 2048($sbox),$sbox # size optimization
movzb `&lo("$s0")`,$acc0
movzb `&lo("$s1")`,$acc1
movzb `&lo("$s2")`,$acc2
movzb ($sbox,$acc0,1),$t0
movzb ($sbox,$acc1,1),$t1
movzb ($sbox,$acc2,1),$t2
movzb `&lo("$s3")`,$acc0
movzb `&hi("$s3")`,$acc1
movzb `&hi("$s0")`,$acc2
movzb ($sbox,$acc0,1),$t3
movzb ($sbox,$acc1,1),$acc1 #$t0
movzb ($sbox,$acc2,1),$acc2 #$t1
shl \$8,$acc1
shl \$8,$acc2
xor $acc1,$t0
xor $acc2,$t1
shr \$16,$s3
movzb `&hi("$s1")`,$acc0
movzb `&hi("$s2")`,$acc1
shr \$16,$s0
movzb ($sbox,$acc0,1),$acc0 #$t2
movzb ($sbox,$acc1,1),$acc1 #$t3
shl \$8,$acc0
shl \$8,$acc1
shr \$16,$s1
xor $acc0,$t2
xor $acc1,$t3
shr \$16,$s2
movzb `&lo("$s2")`,$acc0
movzb `&lo("$s3")`,$acc1
movzb `&lo("$s0")`,$acc2
movzb ($sbox,$acc0,1),$acc0 #$t0
movzb ($sbox,$acc1,1),$acc1 #$t1
movzb ($sbox,$acc2,1),$acc2 #$t2
shl \$16,$acc0
shl \$16,$acc1
shl \$16,$acc2
xor $acc0,$t0
xor $acc1,$t1
xor $acc2,$t2
movzb `&lo("$s1")`,$acc0
movzb `&hi("$s1")`,$acc1
movzb `&hi("$s2")`,$acc2
movzb ($sbox,$acc0,1),$acc0 #$t3
movzb ($sbox,$acc1,1),$acc1 #$t0
movzb ($sbox,$acc2,1),$acc2 #$t1
shl \$16,$acc0
shl \$24,$acc1
shl \$24,$acc2
xor $acc0,$t3
xor $acc1,$t0
xor $acc2,$t1
movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1
mov 16+12($key),$s3
movzb ($sbox,$acc0,1),$acc0 #$t2
movzb ($sbox,$acc1,1),$acc1 #$t3
mov 16+0($key),$s0
shl \$24,$acc0
shl \$24,$acc1
xor $acc0,$t2
xor $acc1,$t3
mov 16+4($key),$s1
mov 16+8($key),$s2
lea -2048($sbox),$sbox
xor $t0,$s0
xor $t1,$s1
xor $t2,$s2
xor $t3,$s3
___
}
sub decstep()
{ my ($i,@s) = @_;
my $tmp0=$acc0;
my $tmp1=$acc1;
my $tmp2=$acc2;
my $out=($t0,$t1,$t2,$s[0])[$i];
$code.=" mov $s[0],$out\n" if ($i!=3);
$tmp1=$s[2] if ($i==3);
$code.=" mov $s[2],$tmp1\n" if ($i!=3);
$code.=" and \$0xFF,$out\n";
$code.=" mov 0($sbox,$out,8),$out\n";
$code.=" shr \$16,$tmp1\n";
$tmp2=$s[3] if ($i==3);
$code.=" mov $s[3],$tmp2\n" if ($i!=3);
$tmp0=$s[1] if ($i==3);
$code.=" movzb ".&hi($s[1]).",$tmp0\n";
$code.=" and \$0xFF,$tmp1\n";
$code.=" shr \$24,$tmp2\n";
$code.=" xor 3($sbox,$tmp0,8),$out\n";
$code.=" xor 2($sbox,$tmp1,8),$out\n";
$code.=" xor 1($sbox,$tmp2,8),$out\n";
$code.=" mov $t2,$s[1]\n" if ($i==3);
$code.=" mov $t1,$s[2]\n" if ($i==3);
$code.=" mov $t0,$s[3]\n" if ($i==3);
$code.="\n";
}
sub declast()
{ my ($i,@s)=@_;
my $tmp0=$acc0;
my $tmp1=$acc1;
my $tmp2=$acc2;
my $out=($t0,$t1,$t2,$s[0])[$i];
$code.=" mov $s[0],$out\n" if ($i!=3);
$tmp1=$s[2] if ($i==3);
$code.=" mov $s[2],$tmp1\n" if ($i!=3);
$code.=" and \$0xFF,$out\n";
$code.=" movzb 2048($sbox,$out,1),$out\n";
$code.=" shr \$16,$tmp1\n";
$tmp2=$s[3] if ($i==3);
$code.=" mov $s[3],$tmp2\n" if ($i!=3);
$tmp0=$s[1] if ($i==3);
$code.=" movzb ".&hi($s[1]).",$tmp0\n";
$code.=" and \$0xFF,$tmp1\n";
$code.=" shr \$24,$tmp2\n";
$code.=" movzb 2048($sbox,$tmp0,1),$tmp0\n";
$code.=" movzb 2048($sbox,$tmp1,1),$tmp1\n";
$code.=" movzb 2048($sbox,$tmp2,1),$tmp2\n";
$code.=" shl \$8,$tmp0\n";
$code.=" shl \$16,$tmp1\n";
$code.=" shl \$24,$tmp2\n";
$code.=" xor $tmp0,$out\n";
$code.=" mov $t2,$s[1]\n" if ($i==3);
$code.=" xor $tmp1,$out\n";
$code.=" mov $t1,$s[2]\n" if ($i==3);
$code.=" xor $tmp2,$out\n";
$code.=" mov $t0,$s[3]\n" if ($i==3);
$code.="\n";
}
$code.=<<___;
.type _x86_64_AES_decrypt,\@abi-omnipotent
.align 16
_x86_64_AES_decrypt:
xor 0($key),$s0 # xor with key
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
mov 240($key),$rnds # load key->rounds
sub \$1,$rnds
jmp .Ldec_loop
.align 16
.Ldec_loop:
___
if ($verticalspin) { &decvert(); }
else { &decstep(0,$s0,$s3,$s2,$s1);
&decstep(1,$s1,$s0,$s3,$s2);
&decstep(2,$s2,$s1,$s0,$s3);
&decstep(3,$s3,$s2,$s1,$s0);
$code.=<<___;
lea 16($key),$key
xor 0($key),$s0 # xor with key
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
___
}
$code.=<<___;
sub \$1,$rnds
jnz .Ldec_loop
___
if ($verticalspin) { &declastvert(); }
else { &declast(0,$s0,$s3,$s2,$s1);
&declast(1,$s1,$s0,$s3,$s2);
&declast(2,$s2,$s1,$s0,$s3);
&declast(3,$s3,$s2,$s1,$s0);
$code.=<<___;
xor 16+0($key),$s0 # xor with key
xor 16+4($key),$s1
xor 16+8($key),$s2
xor 16+12($key),$s3
___
}
$code.=<<___;
.byte 0xf3,0xc3 # rep ret
.size _x86_64_AES_decrypt,.-_x86_64_AES_decrypt
___
sub deccompactvert()
{ my ($t3,$t4,$t5)=("%r8d","%r9d","%r13d");
$code.=<<___;
movzb `&lo("$s0")`,$t0
movzb `&lo("$s1")`,$t1
movzb `&lo("$s2")`,$t2
movzb `&lo("$s3")`,$t3
movzb `&hi("$s3")`,$acc0
movzb `&hi("$s0")`,$acc1
shr \$16,$s3
movzb `&hi("$s1")`,$acc2
movzb ($sbox,$t0,1),$t0
movzb ($sbox,$t1,1),$t1
movzb ($sbox,$t2,1),$t2
movzb ($sbox,$t3,1),$t3
movzb ($sbox,$acc0,1),$t4 #$t0
movzb `&hi("$s2")`,$acc0
movzb ($sbox,$acc1,1),$t5 #$t1
movzb ($sbox,$acc2,1),$acc2 #$t2
movzb ($sbox,$acc0,1),$acc0 #$t3
shr \$16,$s2
shl \$8,$t5
shl \$8,$t4
movzb `&lo("$s2")`,$acc1
shr \$16,$s0
xor $t4,$t0
shr \$16,$s1
movzb `&lo("$s3")`,$t4
shl \$8,$acc2
xor $t5,$t1
shl \$8,$acc0
movzb `&lo("$s0")`,$t5
movzb ($sbox,$acc1,1),$acc1 #$t0
xor $acc2,$t2
movzb `&lo("$s1")`,$acc2
shl \$16,$acc1
xor $acc0,$t3
movzb ($sbox,$t4,1),$t4 #$t1
movzb `&hi("$s1")`,$acc0
movzb ($sbox,$acc2,1),$acc2 #$t3
xor $acc1,$t0
movzb ($sbox,$t5,1),$t5 #$t2
movzb `&hi("$s2")`,$acc1
shl \$16,$acc2
shl \$16,$t4
shl \$16,$t5
xor $acc2,$t3
movzb `&hi("$s3")`,$acc2
xor $t4,$t1
shr \$8,$s0
xor $t5,$t2
movzb ($sbox,$acc0,1),$acc0 #$t0
movzb ($sbox,$acc1,1),$s1 #$t1
movzb ($sbox,$acc2,1),$s2 #$t2
movzb ($sbox,$s0,1),$s3 #$t3
mov $t0,$s0
shl \$24,$acc0
shl \$24,$s1
shl \$24,$s2
xor $acc0,$s0
shl \$24,$s3
xor $t1,$s1
xor $t2,$s2
xor $t3,$s3
___
}
# parallelized version! input is pair of 64-bit values: %rax=s1.s0
# and %rcx=s3.s2, output is four 32-bit values in %eax=s0, %ebx=s1,
# %ecx=s2 and %edx=s3.
sub dectransform()
{ my ($tp10,$tp20,$tp40,$tp80,$acc0)=("%rax","%r8", "%r9", "%r10","%rbx");
my ($tp18,$tp28,$tp48,$tp88,$acc8)=("%rcx","%r11","%r12","%r13","%rdx");
my $prefetch = shift;
$code.=<<___;
mov $mask80,$tp40
mov $mask80,$tp48
and $tp10,$tp40
and $tp18,$tp48
mov $tp40,$acc0
mov $tp48,$acc8
shr \$7,$tp40
lea ($tp10,$tp10),$tp20
shr \$7,$tp48
lea ($tp18,$tp18),$tp28
sub $tp40,$acc0
sub $tp48,$acc8
and $maskfe,$tp20
and $maskfe,$tp28
and $mask1b,$acc0
and $mask1b,$acc8
xor $acc0,$tp20
xor $acc8,$tp28
mov $mask80,$tp80
mov $mask80,$tp88
and $tp20,$tp80
and $tp28,$tp88
mov $tp80,$acc0
mov $tp88,$acc8
shr \$7,$tp80
lea ($tp20,$tp20),$tp40
shr \$7,$tp88
lea ($tp28,$tp28),$tp48
sub $tp80,$acc0
sub $tp88,$acc8
and $maskfe,$tp40
and $maskfe,$tp48
and $mask1b,$acc0
and $mask1b,$acc8
xor $acc0,$tp40
xor $acc8,$tp48
mov $mask80,$tp80
mov $mask80,$tp88
and $tp40,$tp80
and $tp48,$tp88
mov $tp80,$acc0
mov $tp88,$acc8
shr \$7,$tp80
xor $tp10,$tp20 # tp2^=tp1
shr \$7,$tp88
xor $tp18,$tp28 # tp2^=tp1
sub $tp80,$acc0
sub $tp88,$acc8
lea ($tp40,$tp40),$tp80
lea ($tp48,$tp48),$tp88
xor $tp10,$tp40 # tp4^=tp1
xor $tp18,$tp48 # tp4^=tp1
and $maskfe,$tp80
and $maskfe,$tp88
and $mask1b,$acc0
and $mask1b,$acc8
xor $acc0,$tp80
xor $acc8,$tp88
xor $tp80,$tp10 # tp1^=tp8
xor $tp88,$tp18 # tp1^=tp8
xor $tp80,$tp20 # tp2^tp1^=tp8
xor $tp88,$tp28 # tp2^tp1^=tp8
mov $tp10,$acc0
mov $tp18,$acc8
xor $tp80,$tp40 # tp4^tp1^=tp8
shr \$32,$acc0
xor $tp88,$tp48 # tp4^tp1^=tp8
shr \$32,$acc8
xor $tp20,$tp80 # tp8^=tp8^tp2^tp1=tp2^tp1
rol \$8,`&LO("$tp10")` # ROTATE(tp1^tp8,8)
xor $tp28,$tp88 # tp8^=tp8^tp2^tp1=tp2^tp1
rol \$8,`&LO("$tp18")` # ROTATE(tp1^tp8,8)
xor $tp40,$tp80 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
rol \$8,`&LO("$acc0")` # ROTATE(tp1^tp8,8)
xor $tp48,$tp88 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
rol \$8,`&LO("$acc8")` # ROTATE(tp1^tp8,8)
xor `&LO("$tp80")`,`&LO("$tp10")`
shr \$32,$tp80
xor `&LO("$tp88")`,`&LO("$tp18")`
shr \$32,$tp88
xor `&LO("$tp80")`,`&LO("$acc0")`
xor `&LO("$tp88")`,`&LO("$acc8")`
mov $tp20,$tp80
rol \$24,`&LO("$tp20")` # ROTATE(tp2^tp1^tp8,24)
mov $tp28,$tp88
rol \$24,`&LO("$tp28")` # ROTATE(tp2^tp1^tp8,24)
shr \$32,$tp80
xor `&LO("$tp20")`,`&LO("$tp10")`
shr \$32,$tp88
xor `&LO("$tp28")`,`&LO("$tp18")`
rol \$24,`&LO("$tp80")` # ROTATE(tp2^tp1^tp8,24)
mov $tp40,$tp20
rol \$24,`&LO("$tp88")` # ROTATE(tp2^tp1^tp8,24)
mov $tp48,$tp28
shr \$32,$tp20
xor `&LO("$tp80")`,`&LO("$acc0")`
shr \$32,$tp28
xor `&LO("$tp88")`,`&LO("$acc8")`
`"mov 0($sbox),$mask80" if ($prefetch)`
rol \$16,`&LO("$tp40")` # ROTATE(tp4^tp1^tp8,16)
`"mov 64($sbox),$maskfe" if ($prefetch)`
rol \$16,`&LO("$tp48")` # ROTATE(tp4^tp1^tp8,16)
`"mov 128($sbox),$mask1b" if ($prefetch)`
rol \$16,`&LO("$tp20")` # ROTATE(tp4^tp1^tp8,16)
`"mov 192($sbox),$tp80" if ($prefetch)`
xor `&LO("$tp40")`,`&LO("$tp10")`
rol \$16,`&LO("$tp28")` # ROTATE(tp4^tp1^tp8,16)
xor `&LO("$tp48")`,`&LO("$tp18")`
`"mov 256($sbox),$tp88" if ($prefetch)`
xor `&LO("$tp20")`,`&LO("$acc0")`
xor `&LO("$tp28")`,`&LO("$acc8")`
___
}
$code.=<<___;
.type _x86_64_AES_decrypt_compact,\@abi-omnipotent
.align 16
_x86_64_AES_decrypt_compact:
lea 128($sbox),$inp # size optimization
mov 0-128($inp),$acc1 # prefetch Td4
mov 32-128($inp),$acc2
mov 64-128($inp),$t0
mov 96-128($inp),$t1
mov 128-128($inp),$acc1
mov 160-128($inp),$acc2
mov 192-128($inp),$t0
mov 224-128($inp),$t1
jmp .Ldec_loop_compact
.align 16
.Ldec_loop_compact:
xor 0($key),$s0 # xor with key
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
lea 16($key),$key
___
&deccompactvert();
$code.=<<___;
cmp 16(%rsp),$key
je .Ldec_compact_done
mov 256+0($sbox),$mask80
shl \$32,%rbx
shl \$32,%rdx
mov 256+8($sbox),$maskfe
or %rbx,%rax
or %rdx,%rcx
mov 256+16($sbox),$mask1b
___
&dectransform(1);
$code.=<<___;
jmp .Ldec_loop_compact
.align 16
.Ldec_compact_done:
xor 0($key),$s0
xor 4($key),$s1
xor 8($key),$s2
xor 12($key),$s3
.byte 0xf3,0xc3 # rep ret
.size _x86_64_AES_decrypt_compact,.-_x86_64_AES_decrypt_compact
___
# void asm_AES_decrypt (const void *inp,void *out,const AES_KEY *key);
$code.=<<___;
.align 16
.globl asm_AES_decrypt
.type asm_AES_decrypt,\@function,3
.hidden asm_AES_decrypt
asm_AES_decrypt:
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
# allocate frame "above" key schedule
mov %rsp,%r10
lea -63(%rdx),%rcx # %rdx is key argument
and \$-64,%rsp
sub %rsp,%rcx
neg %rcx
and \$0x3c0,%rcx
sub %rcx,%rsp
sub \$32,%rsp
mov %rsi,16(%rsp) # save out
mov %r10,24(%rsp) # save real stack pointer
.Ldec_prologue:
mov %rdx,$key
mov 240($key),$rnds # load rounds
mov 0(%rdi),$s0 # load input vector
mov 4(%rdi),$s1
mov 8(%rdi),$s2
mov 12(%rdi),$s3
shl \$4,$rnds
lea ($key,$rnds),%rbp
mov $key,(%rsp) # key schedule
mov %rbp,8(%rsp) # end of key schedule
# pick Td4 copy which can't "overlap" with stack frame or key schedule
lea .LAES_Td+2048(%rip),$sbox
lea 768(%rsp),%rbp
sub $sbox,%rbp
and \$0x300,%rbp
lea ($sbox,%rbp),$sbox
shr \$3,%rbp # recall "magic" constants!
add %rbp,$sbox
call _x86_64_AES_decrypt_compact
mov 16(%rsp),$out # restore out
mov 24(%rsp),%rsi # restore saved stack pointer
mov $s0,0($out) # write output vector
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
mov (%rsi),%r15
mov 8(%rsi),%r14
mov 16(%rsi),%r13
mov 24(%rsi),%r12
mov 32(%rsi),%rbp
mov 40(%rsi),%rbx
lea 48(%rsi),%rsp
.Ldec_epilogue:
ret
.size asm_AES_decrypt,.-asm_AES_decrypt
___
#------------------------------------------------------------------#
sub enckey()
{
$code.=<<___;
movz %dl,%esi # rk[i]>>0
movzb -128(%rbp,%rsi),%ebx
movz %dh,%esi # rk[i]>>8
shl \$24,%ebx
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
shr \$16,%edx
movz %dl,%esi # rk[i]>>16
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
movz %dh,%esi # rk[i]>>24
shl \$8,%ebx
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
shl \$16,%ebx
xor %ebx,%eax
xor 1024-128(%rbp,%rcx,4),%eax # rcon
___
}
# int asm_AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
$code.=<<___;
.align 16
.globl asm_AES_set_encrypt_key
.type asm_AES_set_encrypt_key,\@function,3
asm_AES_set_encrypt_key:
push %rbx
push %rbp
push %r12 # redundant, but allows to share
push %r13 # exception handler...
push %r14
push %r15
sub \$8,%rsp
.Lenc_key_prologue:
call _x86_64_AES_set_encrypt_key
mov 40(%rsp),%rbp
mov 48(%rsp),%rbx
add \$56,%rsp
.Lenc_key_epilogue:
ret
.size asm_AES_set_encrypt_key,.-asm_AES_set_encrypt_key
.type _x86_64_AES_set_encrypt_key,\@abi-omnipotent
.align 16
_x86_64_AES_set_encrypt_key:
mov %esi,%ecx # %ecx=bits
mov %rdi,%rsi # %rsi=userKey
mov %rdx,%rdi # %rdi=key
test \$-1,%rsi
jz .Lbadpointer
test \$-1,%rdi
jz .Lbadpointer
lea .LAES_Te(%rip),%rbp
lea 2048+128(%rbp),%rbp
# prefetch Te4
mov 0-128(%rbp),%eax
mov 32-128(%rbp),%ebx
mov 64-128(%rbp),%r8d
mov 96-128(%rbp),%edx
mov 128-128(%rbp),%eax
mov 160-128(%rbp),%ebx
mov 192-128(%rbp),%r8d
mov 224-128(%rbp),%edx
cmp \$128,%ecx
je .L10rounds
cmp \$192,%ecx
je .L12rounds
cmp \$256,%ecx
je .L14rounds
mov \$-2,%rax # invalid number of bits
jmp .Lexit
.L10rounds:
mov 0(%rsi),%rax # copy first 4 dwords
mov 8(%rsi),%rdx
mov %rax,0(%rdi)
mov %rdx,8(%rdi)
shr \$32,%rdx
xor %ecx,%ecx
jmp .L10shortcut
.align 4
.L10loop:
mov 0(%rdi),%eax # rk[0]
mov 12(%rdi),%edx # rk[3]
.L10shortcut:
___
&enckey ();
$code.=<<___;
mov %eax,16(%rdi) # rk[4]
xor 4(%rdi),%eax
mov %eax,20(%rdi) # rk[5]
xor 8(%rdi),%eax
mov %eax,24(%rdi) # rk[6]
xor 12(%rdi),%eax
mov %eax,28(%rdi) # rk[7]
add \$1,%ecx
lea 16(%rdi),%rdi
cmp \$10,%ecx
jl .L10loop
movl \$10,80(%rdi) # setup number of rounds
xor %rax,%rax
jmp .Lexit
.L12rounds:
mov 0(%rsi),%rax # copy first 6 dwords
mov 8(%rsi),%rbx
mov 16(%rsi),%rdx
mov %rax,0(%rdi)
mov %rbx,8(%rdi)
mov %rdx,16(%rdi)
shr \$32,%rdx
xor %ecx,%ecx
jmp .L12shortcut
.align 4
.L12loop:
mov 0(%rdi),%eax # rk[0]
mov 20(%rdi),%edx # rk[5]
.L12shortcut:
___
&enckey ();
$code.=<<___;
mov %eax,24(%rdi) # rk[6]
xor 4(%rdi),%eax
mov %eax,28(%rdi) # rk[7]
xor 8(%rdi),%eax
mov %eax,32(%rdi) # rk[8]
xor 12(%rdi),%eax
mov %eax,36(%rdi) # rk[9]
cmp \$7,%ecx
je .L12break
add \$1,%ecx
xor 16(%rdi),%eax
mov %eax,40(%rdi) # rk[10]
xor 20(%rdi),%eax
mov %eax,44(%rdi) # rk[11]
lea 24(%rdi),%rdi
jmp .L12loop
.L12break:
movl \$12,72(%rdi) # setup number of rounds
xor %rax,%rax
jmp .Lexit
.L14rounds:
mov 0(%rsi),%rax # copy first 8 dwords
mov 8(%rsi),%rbx
mov 16(%rsi),%rcx
mov 24(%rsi),%rdx
mov %rax,0(%rdi)
mov %rbx,8(%rdi)
mov %rcx,16(%rdi)
mov %rdx,24(%rdi)
shr \$32,%rdx
xor %ecx,%ecx
jmp .L14shortcut
.align 4
.L14loop:
mov 0(%rdi),%eax # rk[0]
mov 28(%rdi),%edx # rk[4]
.L14shortcut:
___
&enckey ();
$code.=<<___;
mov %eax,32(%rdi) # rk[8]
xor 4(%rdi),%eax
mov %eax,36(%rdi) # rk[9]
xor 8(%rdi),%eax
mov %eax,40(%rdi) # rk[10]
xor 12(%rdi),%eax
mov %eax,44(%rdi) # rk[11]
cmp \$6,%ecx
je .L14break
add \$1,%ecx
mov %eax,%edx
mov 16(%rdi),%eax # rk[4]
movz %dl,%esi # rk[11]>>0
movzb -128(%rbp,%rsi),%ebx
movz %dh,%esi # rk[11]>>8
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
shr \$16,%edx
shl \$8,%ebx
movz %dl,%esi # rk[11]>>16
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
movz %dh,%esi # rk[11]>>24
shl \$16,%ebx
xor %ebx,%eax
movzb -128(%rbp,%rsi),%ebx
shl \$24,%ebx
xor %ebx,%eax
mov %eax,48(%rdi) # rk[12]
xor 20(%rdi),%eax
mov %eax,52(%rdi) # rk[13]
xor 24(%rdi),%eax
mov %eax,56(%rdi) # rk[14]
xor 28(%rdi),%eax
mov %eax,60(%rdi) # rk[15]
lea 32(%rdi),%rdi
jmp .L14loop
.L14break:
movl \$14,48(%rdi) # setup number of rounds
xor %rax,%rax
jmp .Lexit
.Lbadpointer:
mov \$-1,%rax
.Lexit:
.byte 0xf3,0xc3 # rep ret
.size _x86_64_AES_set_encrypt_key,.-_x86_64_AES_set_encrypt_key
___
sub deckey_ref()
{ my ($i,$ptr,$te,$td) = @_;
my ($tp1,$tp2,$tp4,$tp8,$acc)=("%eax","%ebx","%edi","%edx","%r8d");
$code.=<<___;
mov $i($ptr),$tp1
mov $tp1,$acc
and \$0x80808080,$acc
mov $acc,$tp4
shr \$7,$tp4
lea 0($tp1,$tp1),$tp2
sub $tp4,$acc
and \$0xfefefefe,$tp2
and \$0x1b1b1b1b,$acc
xor $tp2,$acc
mov $acc,$tp2
and \$0x80808080,$acc
mov $acc,$tp8
shr \$7,$tp8
lea 0($tp2,$tp2),$tp4
sub $tp8,$acc
and \$0xfefefefe,$tp4
and \$0x1b1b1b1b,$acc
xor $tp1,$tp2 # tp2^tp1
xor $tp4,$acc
mov $acc,$tp4
and \$0x80808080,$acc
mov $acc,$tp8
shr \$7,$tp8
sub $tp8,$acc
lea 0($tp4,$tp4),$tp8
xor $tp1,$tp4 # tp4^tp1
and \$0xfefefefe,$tp8
and \$0x1b1b1b1b,$acc
xor $acc,$tp8
xor $tp8,$tp1 # tp1^tp8
rol \$8,$tp1 # ROTATE(tp1^tp8,8)
xor $tp8,$tp2 # tp2^tp1^tp8
xor $tp8,$tp4 # tp4^tp1^tp8
xor $tp2,$tp8
xor $tp4,$tp8 # tp8^(tp8^tp4^tp1)^(tp8^tp2^tp1)=tp8^tp4^tp2
xor $tp8,$tp1
rol \$24,$tp2 # ROTATE(tp2^tp1^tp8,24)
xor $tp2,$tp1
rol \$16,$tp4 # ROTATE(tp4^tp1^tp8,16)
xor $tp4,$tp1
mov $tp1,$i($ptr)
___
}
# int asm_AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
$code.=<<___;
.align 16
.globl asm_AES_set_decrypt_key
.type asm_AES_set_decrypt_key,\@function,3
asm_AES_set_decrypt_key:
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
push %rdx # save key schedule
.Ldec_key_prologue:
call _x86_64_AES_set_encrypt_key
mov (%rsp),%r8 # restore key schedule
cmp \$0,%eax
jne .Labort
mov 240(%r8),%r14d # pull number of rounds
xor %rdi,%rdi
lea (%rdi,%r14d,4),%rcx
mov %r8,%rsi
lea (%r8,%rcx,4),%rdi # pointer to last chunk
.align 4
.Linvert:
mov 0(%rsi),%rax
mov 8(%rsi),%rbx
mov 0(%rdi),%rcx
mov 8(%rdi),%rdx
mov %rax,0(%rdi)
mov %rbx,8(%rdi)
mov %rcx,0(%rsi)
mov %rdx,8(%rsi)
lea 16(%rsi),%rsi
lea -16(%rdi),%rdi
cmp %rsi,%rdi
jne .Linvert
lea .LAES_Te+2048+1024(%rip),%rax # rcon
mov 40(%rax),$mask80
mov 48(%rax),$maskfe
mov 56(%rax),$mask1b
mov %r8,$key
sub \$1,%r14d
.align 4
.Lpermute:
lea 16($key),$key
mov 0($key),%rax
mov 8($key),%rcx
___
&dectransform ();
$code.=<<___;
mov %eax,0($key)
mov %ebx,4($key)
mov %ecx,8($key)
mov %edx,12($key)
sub \$1,%r14d
jnz .Lpermute
xor %rax,%rax
.Labort:
mov 8(%rsp),%r15
mov 16(%rsp),%r14
mov 24(%rsp),%r13
mov 32(%rsp),%r12
mov 40(%rsp),%rbp
mov 48(%rsp),%rbx
add \$56,%rsp
.Ldec_key_epilogue:
ret
.size asm_AES_set_decrypt_key,.-asm_AES_set_decrypt_key
___
# void asm_AES_cbc_encrypt (const void char *inp, unsigned char *out,
# size_t length, const AES_KEY *key,
# unsigned char *ivp,const int enc);
{
# stack frame layout
# -8(%rsp) return address
my $keyp="0(%rsp)"; # one to pass as $key
my $keyend="8(%rsp)"; # &(keyp->rd_key[4*keyp->rounds])
my $_rsp="16(%rsp)"; # saved %rsp
my $_inp="24(%rsp)"; # copy of 1st parameter, inp
my $_out="32(%rsp)"; # copy of 2nd parameter, out
my $_len="40(%rsp)"; # copy of 3rd parameter, length
my $_key="48(%rsp)"; # copy of 4th parameter, key
my $_ivp="56(%rsp)"; # copy of 5th parameter, ivp
my $ivec="64(%rsp)"; # ivec[16]
my $aes_key="80(%rsp)"; # copy of aes_key
my $mark="80+240(%rsp)"; # copy of aes_key->rounds
$code.=<<___;
.align 16
.globl asm_AES_cbc_encrypt
.type asm_AES_cbc_encrypt,\@function,6
.extern OPENSSL_ia32cap_P
.hidden asm_AES_cbc_encrypt
asm_AES_cbc_encrypt:
cmp \$0,%rdx # check length
je .Lcbc_epilogue
pushfq
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
.Lcbc_prologue:
cld
mov %r9d,%r9d # clear upper half of enc
lea .LAES_Te(%rip),$sbox
cmp \$0,%r9
jne .Lcbc_picked_te
lea .LAES_Td(%rip),$sbox
.Lcbc_picked_te:
mov OPENSSL_ia32cap_P(%rip),%r10d
cmp \$$speed_limit,%rdx
jb .Lcbc_slow_prologue
test \$15,%rdx
jnz .Lcbc_slow_prologue
bt \$28,%r10d
jc .Lcbc_slow_prologue
# allocate aligned stack frame...
lea -88-248(%rsp),$key
and \$-64,$key
# ... and make sure it doesn't alias with AES_T[ed] modulo 4096
mov $sbox,%r10
lea 2304($sbox),%r11
mov $key,%r12
and \$0xFFF,%r10 # s = $sbox&0xfff
and \$0xFFF,%r11 # e = ($sbox+2048)&0xfff
and \$0xFFF,%r12 # p = %rsp&0xfff
cmp %r11,%r12 # if (p=>e) %rsp =- (p-e);
jb .Lcbc_te_break_out
sub %r11,%r12
sub %r12,$key
jmp .Lcbc_te_ok
.Lcbc_te_break_out: # else %rsp -= (p-s)&0xfff + framesz
sub %r10,%r12
and \$0xFFF,%r12
add \$320,%r12
sub %r12,$key
.align 4
.Lcbc_te_ok:
xchg %rsp,$key
#add \$8,%rsp # reserve for return address!
mov $key,$_rsp # save %rsp
.Lcbc_fast_body:
mov %rdi,$_inp # save copy of inp
mov %rsi,$_out # save copy of out
mov %rdx,$_len # save copy of len
mov %rcx,$_key # save copy of key
mov %r8,$_ivp # save copy of ivp
movl \$0,$mark # copy of aes_key->rounds = 0;
mov %r8,%rbp # rearrange input arguments
mov %r9,%rbx
mov %rsi,$out
mov %rdi,$inp
mov %rcx,$key
mov 240($key),%eax # key->rounds
# do we copy key schedule to stack?
mov $key,%r10
sub $sbox,%r10
and \$0xfff,%r10
cmp \$2304,%r10
jb .Lcbc_do_ecopy
cmp \$4096-248,%r10
jb .Lcbc_skip_ecopy
.align 4
.Lcbc_do_ecopy:
mov $key,%rsi
lea $aes_key,%rdi
lea $aes_key,$key
mov \$240/8,%ecx
.long 0x90A548F3 # rep movsq
mov %eax,(%rdi) # copy aes_key->rounds
.Lcbc_skip_ecopy:
mov $key,$keyp # save key pointer
mov \$18,%ecx
.align 4
.Lcbc_prefetch_te:
mov 0($sbox),%r10
mov 32($sbox),%r11
mov 64($sbox),%r12
mov 96($sbox),%r13
lea 128($sbox),$sbox
sub \$1,%ecx
jnz .Lcbc_prefetch_te
lea -2304($sbox),$sbox
cmp \$0,%rbx
je .LFAST_DECRYPT
#----------------------------- ENCRYPT -----------------------------#
mov 0(%rbp),$s0 # load iv
mov 4(%rbp),$s1
mov 8(%rbp),$s2
mov 12(%rbp),$s3
.align 4
.Lcbc_fast_enc_loop:
xor 0($inp),$s0
xor 4($inp),$s1
xor 8($inp),$s2
xor 12($inp),$s3
mov $keyp,$key # restore key
mov $inp,$_inp # if ($verticalspin) save inp
call _x86_64_AES_encrypt
mov $_inp,$inp # if ($verticalspin) restore inp
mov $_len,%r10
mov $s0,0($out)
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
lea 16($inp),$inp
lea 16($out),$out
sub \$16,%r10
test \$-16,%r10
mov %r10,$_len
jnz .Lcbc_fast_enc_loop
mov $_ivp,%rbp # restore ivp
mov $s0,0(%rbp) # save ivec
mov $s1,4(%rbp)
mov $s2,8(%rbp)
mov $s3,12(%rbp)
jmp .Lcbc_fast_cleanup
#----------------------------- DECRYPT -----------------------------#
.align 16
.LFAST_DECRYPT:
cmp $inp,$out
je .Lcbc_fast_dec_in_place
mov %rbp,$ivec
.align 4
.Lcbc_fast_dec_loop:
mov 0($inp),$s0 # read input
mov 4($inp),$s1
mov 8($inp),$s2
mov 12($inp),$s3
mov $keyp,$key # restore key
mov $inp,$_inp # if ($verticalspin) save inp
call _x86_64_AES_decrypt
mov $ivec,%rbp # load ivp
mov $_inp,$inp # if ($verticalspin) restore inp
mov $_len,%r10 # load len
xor 0(%rbp),$s0 # xor iv
xor 4(%rbp),$s1
xor 8(%rbp),$s2
xor 12(%rbp),$s3
mov $inp,%rbp # current input, next iv
sub \$16,%r10
mov %r10,$_len # update len
mov %rbp,$ivec # update ivp
mov $s0,0($out) # write output
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
lea 16($inp),$inp
lea 16($out),$out
jnz .Lcbc_fast_dec_loop
mov $_ivp,%r12 # load user ivp
mov 0(%rbp),%r10 # load iv
mov 8(%rbp),%r11
mov %r10,0(%r12) # copy back to user
mov %r11,8(%r12)
jmp .Lcbc_fast_cleanup
.align 16
.Lcbc_fast_dec_in_place:
mov 0(%rbp),%r10 # copy iv to stack
mov 8(%rbp),%r11
mov %r10,0+$ivec
mov %r11,8+$ivec
.align 4
.Lcbc_fast_dec_in_place_loop:
mov 0($inp),$s0 # load input
mov 4($inp),$s1
mov 8($inp),$s2
mov 12($inp),$s3
mov $keyp,$key # restore key
mov $inp,$_inp # if ($verticalspin) save inp
call _x86_64_AES_decrypt
mov $_inp,$inp # if ($verticalspin) restore inp
mov $_len,%r10
xor 0+$ivec,$s0
xor 4+$ivec,$s1
xor 8+$ivec,$s2
xor 12+$ivec,$s3
mov 0($inp),%r11 # load input
mov 8($inp),%r12
sub \$16,%r10
jz .Lcbc_fast_dec_in_place_done
mov %r11,0+$ivec # copy input to iv
mov %r12,8+$ivec
mov $s0,0($out) # save output [zaps input]
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
lea 16($inp),$inp
lea 16($out),$out
mov %r10,$_len
jmp .Lcbc_fast_dec_in_place_loop
.Lcbc_fast_dec_in_place_done:
mov $_ivp,%rdi
mov %r11,0(%rdi) # copy iv back to user
mov %r12,8(%rdi)
mov $s0,0($out) # save output [zaps input]
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
.align 4
.Lcbc_fast_cleanup:
cmpl \$0,$mark # was the key schedule copied?
lea $aes_key,%rdi
je .Lcbc_exit
mov \$240/8,%ecx
xor %rax,%rax
.long 0x90AB48F3 # rep stosq
jmp .Lcbc_exit
#--------------------------- SLOW ROUTINE ---------------------------#
.align 16
.Lcbc_slow_prologue:
# allocate aligned stack frame...
lea -88(%rsp),%rbp
and \$-64,%rbp
# ... just "above" key schedule
lea -88-63(%rcx),%r10
sub %rbp,%r10
neg %r10
and \$0x3c0,%r10
sub %r10,%rbp
xchg %rsp,%rbp
#add \$8,%rsp # reserve for return address!
mov %rbp,$_rsp # save %rsp
.Lcbc_slow_body:
#mov %rdi,$_inp # save copy of inp
#mov %rsi,$_out # save copy of out
#mov %rdx,$_len # save copy of len
#mov %rcx,$_key # save copy of key
mov %r8,$_ivp # save copy of ivp
mov %r8,%rbp # rearrange input arguments
mov %r9,%rbx
mov %rsi,$out
mov %rdi,$inp
mov %rcx,$key
mov %rdx,%r10
mov 240($key),%eax
mov $key,$keyp # save key pointer
shl \$4,%eax
lea ($key,%rax),%rax
mov %rax,$keyend
# pick Te4 copy which can't "overlap" with stack frame or key scdedule
lea 2048($sbox),$sbox
lea 768-8(%rsp),%rax
sub $sbox,%rax
and \$0x300,%rax
lea ($sbox,%rax),$sbox
cmp \$0,%rbx
je .LSLOW_DECRYPT
#--------------------------- SLOW ENCRYPT ---------------------------#
test \$-16,%r10 # check upon length
mov 0(%rbp),$s0 # load iv
mov 4(%rbp),$s1
mov 8(%rbp),$s2
mov 12(%rbp),$s3
jz .Lcbc_slow_enc_tail # short input...
.align 4
.Lcbc_slow_enc_loop:
xor 0($inp),$s0
xor 4($inp),$s1
xor 8($inp),$s2
xor 12($inp),$s3
mov $keyp,$key # restore key
mov $inp,$_inp # save inp
mov $out,$_out # save out
mov %r10,$_len # save len
call _x86_64_AES_encrypt_compact
mov $_inp,$inp # restore inp
mov $_out,$out # restore out
mov $_len,%r10 # restore len
mov $s0,0($out)
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
lea 16($inp),$inp
lea 16($out),$out
sub \$16,%r10
test \$-16,%r10
jnz .Lcbc_slow_enc_loop
test \$15,%r10
jnz .Lcbc_slow_enc_tail
mov $_ivp,%rbp # restore ivp
mov $s0,0(%rbp) # save ivec
mov $s1,4(%rbp)
mov $s2,8(%rbp)
mov $s3,12(%rbp)
jmp .Lcbc_exit
.align 4
.Lcbc_slow_enc_tail:
mov %rax,%r11
mov %rcx,%r12
mov %r10,%rcx
mov $inp,%rsi
mov $out,%rdi
.long 0x9066A4F3 # rep movsb
mov \$16,%rcx # zero tail
sub %r10,%rcx
xor %rax,%rax
.long 0x9066AAF3 # rep stosb
mov $out,$inp # this is not a mistake!
mov \$16,%r10 # len=16
mov %r11,%rax
mov %r12,%rcx
jmp .Lcbc_slow_enc_loop # one more spin...
#--------------------------- SLOW DECRYPT ---------------------------#
.align 16
.LSLOW_DECRYPT:
shr \$3,%rax
add %rax,$sbox # recall "magic" constants!
mov 0(%rbp),%r11 # copy iv to stack
mov 8(%rbp),%r12
mov %r11,0+$ivec
mov %r12,8+$ivec
.align 4
.Lcbc_slow_dec_loop:
mov 0($inp),$s0 # load input
mov 4($inp),$s1
mov 8($inp),$s2
mov 12($inp),$s3
mov $keyp,$key # restore key
mov $inp,$_inp # save inp
mov $out,$_out # save out
mov %r10,$_len # save len
call _x86_64_AES_decrypt_compact
mov $_inp,$inp # restore inp
mov $_out,$out # restore out
mov $_len,%r10
xor 0+$ivec,$s0
xor 4+$ivec,$s1
xor 8+$ivec,$s2
xor 12+$ivec,$s3
mov 0($inp),%r11 # load input
mov 8($inp),%r12
sub \$16,%r10
jc .Lcbc_slow_dec_partial
jz .Lcbc_slow_dec_done
mov %r11,0+$ivec # copy input to iv
mov %r12,8+$ivec
mov $s0,0($out) # save output [can zap input]
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
lea 16($inp),$inp
lea 16($out),$out
jmp .Lcbc_slow_dec_loop
.Lcbc_slow_dec_done:
mov $_ivp,%rdi
mov %r11,0(%rdi) # copy iv back to user
mov %r12,8(%rdi)
mov $s0,0($out) # save output [can zap input]
mov $s1,4($out)
mov $s2,8($out)
mov $s3,12($out)
jmp .Lcbc_exit
.align 4
.Lcbc_slow_dec_partial:
mov $_ivp,%rdi
mov %r11,0(%rdi) # copy iv back to user
mov %r12,8(%rdi)
mov $s0,0+$ivec # save output to stack
mov $s1,4+$ivec
mov $s2,8+$ivec
mov $s3,12+$ivec
mov $out,%rdi
lea $ivec,%rsi
lea 16(%r10),%rcx
.long 0x9066A4F3 # rep movsb
jmp .Lcbc_exit
.align 16
.Lcbc_exit:
mov $_rsp,%rsi
mov (%rsi),%r15
mov 8(%rsi),%r14
mov 16(%rsi),%r13
mov 24(%rsi),%r12
mov 32(%rsi),%rbp
mov 40(%rsi),%rbx
lea 48(%rsi),%rsp
.Lcbc_popfq:
popfq
.Lcbc_epilogue:
ret
.size asm_AES_cbc_encrypt,.-asm_AES_cbc_encrypt
___
}
$code.=<<___;
.align 64
.LAES_Te:
___
&_data_word(0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6);
&_data_word(0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591);
&_data_word(0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56);
&_data_word(0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec);
&_data_word(0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa);
&_data_word(0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb);
&_data_word(0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45);
&_data_word(0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b);
&_data_word(0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c);
&_data_word(0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83);
&_data_word(0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9);
&_data_word(0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a);
&_data_word(0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d);
&_data_word(0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f);
&_data_word(0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df);
&_data_word(0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea);
&_data_word(0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34);
&_data_word(0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b);
&_data_word(0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d);
&_data_word(0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413);
&_data_word(0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1);
&_data_word(0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6);
&_data_word(0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972);
&_data_word(0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85);
&_data_word(0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed);
&_data_word(0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511);
&_data_word(0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe);
&_data_word(0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b);
&_data_word(0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05);
&_data_word(0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1);
&_data_word(0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142);
&_data_word(0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf);
&_data_word(0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3);
&_data_word(0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e);
&_data_word(0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a);
&_data_word(0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6);
&_data_word(0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3);
&_data_word(0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b);
&_data_word(0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428);
&_data_word(0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad);
&_data_word(0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14);
&_data_word(0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8);
&_data_word(0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4);
&_data_word(0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2);
&_data_word(0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda);
&_data_word(0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949);
&_data_word(0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf);
&_data_word(0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810);
&_data_word(0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c);
&_data_word(0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697);
&_data_word(0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e);
&_data_word(0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f);
&_data_word(0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc);
&_data_word(0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c);
&_data_word(0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969);
&_data_word(0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27);
&_data_word(0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122);
&_data_word(0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433);
&_data_word(0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9);
&_data_word(0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5);
&_data_word(0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a);
&_data_word(0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0);
&_data_word(0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e);
&_data_word(0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c);
#Te4 # four copies of Te4 to choose from to avoid L1 aliasing
&data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
&data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
&data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
&data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
&data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
&data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
&data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
&data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
&data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
&data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
&data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
&data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
&data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
&data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
&data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
&data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
&data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
&data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
&data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
&data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
&data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
&data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
&data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
&data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
&data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
&data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
&data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
&data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
&data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
&data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
&data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
&data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
&data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
&data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
&data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
&data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
&data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
&data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
&data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
&data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
&data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
&data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
&data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
&data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
&data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
&data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
&data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
&data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
&data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
&data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
&data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
&data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
&data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
&data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
&data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
&data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
&data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
&data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
&data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
&data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
&data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
&data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
&data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
&data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
&data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
&data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
&data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
&data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
&data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
&data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
&data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
&data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
&data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
&data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
&data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
&data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
&data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
&data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
&data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
&data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
&data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
&data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
&data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
&data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
&data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
&data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
&data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
&data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
&data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
&data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
&data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
&data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
&data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
&data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
&data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
&data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
&data_byte(0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5);
&data_byte(0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76);
&data_byte(0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0);
&data_byte(0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0);
&data_byte(0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc);
&data_byte(0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15);
&data_byte(0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a);
&data_byte(0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75);
&data_byte(0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0);
&data_byte(0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84);
&data_byte(0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b);
&data_byte(0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf);
&data_byte(0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85);
&data_byte(0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8);
&data_byte(0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5);
&data_byte(0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2);
&data_byte(0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17);
&data_byte(0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73);
&data_byte(0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88);
&data_byte(0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb);
&data_byte(0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c);
&data_byte(0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79);
&data_byte(0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9);
&data_byte(0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08);
&data_byte(0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6);
&data_byte(0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a);
&data_byte(0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e);
&data_byte(0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e);
&data_byte(0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94);
&data_byte(0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf);
&data_byte(0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68);
&data_byte(0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
#rcon:
$code.=<<___;
.long 0x00000001, 0x00000002, 0x00000004, 0x00000008
.long 0x00000010, 0x00000020, 0x00000040, 0x00000080
.long 0x0000001b, 0x00000036, 0x80808080, 0x80808080
.long 0xfefefefe, 0xfefefefe, 0x1b1b1b1b, 0x1b1b1b1b
___
$code.=<<___;
.align 64
.LAES_Td:
___
&_data_word(0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a);
&_data_word(0xcb6bab3b, 0xf1459d1f, 0xab58faac, 0x9303e34b);
&_data_word(0x55fa3020, 0xf66d76ad, 0x9176cc88, 0x254c02f5);
&_data_word(0xfcd7e54f, 0xd7cb2ac5, 0x80443526, 0x8fa362b5);
&_data_word(0x495ab1de, 0x671bba25, 0x980eea45, 0xe1c0fe5d);
&_data_word(0x02752fc3, 0x12f04c81, 0xa397468d, 0xc6f9d36b);
&_data_word(0xe75f8f03, 0x959c9215, 0xeb7a6dbf, 0xda595295);
&_data_word(0x2d83bed4, 0xd3217458, 0x2969e049, 0x44c8c98e);
&_data_word(0x6a89c275, 0x78798ef4, 0x6b3e5899, 0xdd71b927);
&_data_word(0xb64fe1be, 0x17ad88f0, 0x66ac20c9, 0xb43ace7d);
&_data_word(0x184adf63, 0x82311ae5, 0x60335197, 0x457f5362);
&_data_word(0xe07764b1, 0x84ae6bbb, 0x1ca081fe, 0x942b08f9);
&_data_word(0x58684870, 0x19fd458f, 0x876cde94, 0xb7f87b52);
&_data_word(0x23d373ab, 0xe2024b72, 0x578f1fe3, 0x2aab5566);
&_data_word(0x0728ebb2, 0x03c2b52f, 0x9a7bc586, 0xa50837d3);
&_data_word(0xf2872830, 0xb2a5bf23, 0xba6a0302, 0x5c8216ed);
&_data_word(0x2b1ccf8a, 0x92b479a7, 0xf0f207f3, 0xa1e2694e);
&_data_word(0xcdf4da65, 0xd5be0506, 0x1f6234d1, 0x8afea6c4);
&_data_word(0x9d532e34, 0xa055f3a2, 0x32e18a05, 0x75ebf6a4);
&_data_word(0x39ec830b, 0xaaef6040, 0x069f715e, 0x51106ebd);
&_data_word(0xf98a213e, 0x3d06dd96, 0xae053edd, 0x46bde64d);
&_data_word(0xb58d5491, 0x055dc471, 0x6fd40604, 0xff155060);
&_data_word(0x24fb9819, 0x97e9bdd6, 0xcc434089, 0x779ed967);
&_data_word(0xbd42e8b0, 0x888b8907, 0x385b19e7, 0xdbeec879);
&_data_word(0x470a7ca1, 0xe90f427c, 0xc91e84f8, 0x00000000);
&_data_word(0x83868009, 0x48ed2b32, 0xac70111e, 0x4e725a6c);
&_data_word(0xfbff0efd, 0x5638850f, 0x1ed5ae3d, 0x27392d36);
&_data_word(0x64d90f0a, 0x21a65c68, 0xd1545b9b, 0x3a2e3624);
&_data_word(0xb1670a0c, 0x0fe75793, 0xd296eeb4, 0x9e919b1b);
&_data_word(0x4fc5c080, 0xa220dc61, 0x694b775a, 0x161a121c);
&_data_word(0x0aba93e2, 0xe52aa0c0, 0x43e0223c, 0x1d171b12);
&_data_word(0x0b0d090e, 0xadc78bf2, 0xb9a8b62d, 0xc8a91e14);
&_data_word(0x8519f157, 0x4c0775af, 0xbbdd99ee, 0xfd607fa3);
&_data_word(0x9f2601f7, 0xbcf5725c, 0xc53b6644, 0x347efb5b);
&_data_word(0x7629438b, 0xdcc623cb, 0x68fcedb6, 0x63f1e4b8);
&_data_word(0xcadc31d7, 0x10856342, 0x40229713, 0x2011c684);
&_data_word(0x7d244a85, 0xf83dbbd2, 0x1132f9ae, 0x6da129c7);
&_data_word(0x4b2f9e1d, 0xf330b2dc, 0xec52860d, 0xd0e3c177);
&_data_word(0x6c16b32b, 0x99b970a9, 0xfa489411, 0x2264e947);
&_data_word(0xc48cfca8, 0x1a3ff0a0, 0xd82c7d56, 0xef903322);
&_data_word(0xc74e4987, 0xc1d138d9, 0xfea2ca8c, 0x360bd498);
&_data_word(0xcf81f5a6, 0x28de7aa5, 0x268eb7da, 0xa4bfad3f);
&_data_word(0xe49d3a2c, 0x0d927850, 0x9bcc5f6a, 0x62467e54);
&_data_word(0xc2138df6, 0xe8b8d890, 0x5ef7392e, 0xf5afc382);
&_data_word(0xbe805d9f, 0x7c93d069, 0xa92dd56f, 0xb31225cf);
&_data_word(0x3b99acc8, 0xa77d1810, 0x6e639ce8, 0x7bbb3bdb);
&_data_word(0x097826cd, 0xf418596e, 0x01b79aec, 0xa89a4f83);
&_data_word(0x656e95e6, 0x7ee6ffaa, 0x08cfbc21, 0xe6e815ef);
&_data_word(0xd99be7ba, 0xce366f4a, 0xd4099fea, 0xd67cb029);
&_data_word(0xafb2a431, 0x31233f2a, 0x3094a5c6, 0xc066a235);
&_data_word(0x37bc4e74, 0xa6ca82fc, 0xb0d090e0, 0x15d8a733);
&_data_word(0x4a9804f1, 0xf7daec41, 0x0e50cd7f, 0x2ff69117);
&_data_word(0x8dd64d76, 0x4db0ef43, 0x544daacc, 0xdf0496e4);
&_data_word(0xe3b5d19e, 0x1b886a4c, 0xb81f2cc1, 0x7f516546);
&_data_word(0x04ea5e9d, 0x5d358c01, 0x737487fa, 0x2e410bfb);
&_data_word(0x5a1d67b3, 0x52d2db92, 0x335610e9, 0x1347d66d);
&_data_word(0x8c61d79a, 0x7a0ca137, 0x8e14f859, 0x893c13eb);
&_data_word(0xee27a9ce, 0x35c961b7, 0xede51ce1, 0x3cb1477a);
&_data_word(0x59dfd29c, 0x3f73f255, 0x79ce1418, 0xbf37c773);
&_data_word(0xeacdf753, 0x5baafd5f, 0x146f3ddf, 0x86db4478);
&_data_word(0x81f3afca, 0x3ec468b9, 0x2c342438, 0x5f40a3c2);
&_data_word(0x72c31d16, 0x0c25e2bc, 0x8b493c28, 0x41950dff);
&_data_word(0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664);
&_data_word(0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0);
#Td4: # four copies of Td4 to choose from to avoid L1 aliasing
&data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
&data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
&data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
&data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
&data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
&data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
&data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
&data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
&data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
&data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
&data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
&data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
&data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
&data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
&data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
&data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
&data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
&data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
&data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
&data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
&data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
&data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
&data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
&data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
&data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
&data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
&data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
&data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
&data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
&data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
&data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
&data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
$code.=<<___;
.long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe
.long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0
___
&data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
&data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
&data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
&data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
&data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
&data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
&data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
&data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
&data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
&data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
&data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
&data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
&data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
&data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
&data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
&data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
&data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
&data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
&data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
&data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
&data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
&data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
&data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
&data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
&data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
&data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
&data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
&data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
&data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
&data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
&data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
&data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
$code.=<<___;
.long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe
.long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0
___
&data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
&data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
&data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
&data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
&data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
&data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
&data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
&data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
&data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
&data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
&data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
&data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
&data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
&data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
&data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
&data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
&data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
&data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
&data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
&data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
&data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
&data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
&data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
&data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
&data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
&data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
&data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
&data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
&data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
&data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
&data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
&data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
$code.=<<___;
.long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe
.long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0
___
&data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
&data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
&data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
&data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
&data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
&data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
&data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
&data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
&data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
&data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
&data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
&data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
&data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
&data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
&data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
&data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
&data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
&data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
&data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
&data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
&data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
&data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
&data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
&data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
&data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
&data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
&data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
&data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
&data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
&data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
&data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
&data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
$code.=<<___;
.long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe
.long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0
.asciz "AES for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
.align 64
___
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
# CONTEXT *context,DISPATCHER_CONTEXT *disp)
if ($win64) {
$rec="%rcx";
$frame="%rdx";
$context="%r8";
$disp="%r9";
$code.=<<___;
.extern __imp_RtlVirtualUnwind
.type block_se_handler,\@abi-omnipotent
.align 16
block_se_handler:
push %rsi
push %rdi
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
pushfq
sub \$64,%rsp
mov 120($context),%rax # pull context->Rax
mov 248($context),%rbx # pull context->Rip
mov 8($disp),%rsi # disp->ImageBase
mov 56($disp),%r11 # disp->HandlerData
mov 0(%r11),%r10d # HandlerData[0]
lea (%rsi,%r10),%r10 # prologue label
cmp %r10,%rbx # context->Rip<prologue label
jb .Lin_block_prologue
mov 152($context),%rax # pull context->Rsp
mov 4(%r11),%r10d # HandlerData[1]
lea (%rsi,%r10),%r10 # epilogue label
cmp %r10,%rbx # context->Rip>=epilogue label
jae .Lin_block_prologue
mov 24(%rax),%rax # pull saved real stack pointer
lea 48(%rax),%rax # adjust...
mov -8(%rax),%rbx
mov -16(%rax),%rbp
mov -24(%rax),%r12
mov -32(%rax),%r13
mov -40(%rax),%r14
mov -48(%rax),%r15
mov %rbx,144($context) # restore context->Rbx
mov %rbp,160($context) # restore context->Rbp
mov %r12,216($context) # restore context->R12
mov %r13,224($context) # restore context->R13
mov %r14,232($context) # restore context->R14
mov %r15,240($context) # restore context->R15
.Lin_block_prologue:
mov 8(%rax),%rdi
mov 16(%rax),%rsi
mov %rax,152($context) # restore context->Rsp
mov %rsi,168($context) # restore context->Rsi
mov %rdi,176($context) # restore context->Rdi
jmp .Lcommon_seh_exit
.size block_se_handler,.-block_se_handler
.type key_se_handler,\@abi-omnipotent
.align 16
key_se_handler:
push %rsi
push %rdi
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
pushfq
sub \$64,%rsp
mov 120($context),%rax # pull context->Rax
mov 248($context),%rbx # pull context->Rip
mov 8($disp),%rsi # disp->ImageBase
mov 56($disp),%r11 # disp->HandlerData
mov 0(%r11),%r10d # HandlerData[0]
lea (%rsi,%r10),%r10 # prologue label
cmp %r10,%rbx # context->Rip<prologue label
jb .Lin_key_prologue
mov 152($context),%rax # pull context->Rsp
mov 4(%r11),%r10d # HandlerData[1]
lea (%rsi,%r10),%r10 # epilogue label
cmp %r10,%rbx # context->Rip>=epilogue label
jae .Lin_key_prologue
lea 56(%rax),%rax
mov -8(%rax),%rbx
mov -16(%rax),%rbp
mov -24(%rax),%r12
mov -32(%rax),%r13
mov -40(%rax),%r14
mov -48(%rax),%r15
mov %rbx,144($context) # restore context->Rbx
mov %rbp,160($context) # restore context->Rbp
mov %r12,216($context) # restore context->R12
mov %r13,224($context) # restore context->R13
mov %r14,232($context) # restore context->R14
mov %r15,240($context) # restore context->R15
.Lin_key_prologue:
mov 8(%rax),%rdi
mov 16(%rax),%rsi
mov %rax,152($context) # restore context->Rsp
mov %rsi,168($context) # restore context->Rsi
mov %rdi,176($context) # restore context->Rdi
jmp .Lcommon_seh_exit
.size key_se_handler,.-key_se_handler
.type cbc_se_handler,\@abi-omnipotent
.align 16
cbc_se_handler:
push %rsi
push %rdi
push %rbx
push %rbp
push %r12
push %r13
push %r14
push %r15
pushfq
sub \$64,%rsp
mov 120($context),%rax # pull context->Rax
mov 248($context),%rbx # pull context->Rip
lea .Lcbc_prologue(%rip),%r10
cmp %r10,%rbx # context->Rip<.Lcbc_prologue
jb .Lin_cbc_prologue
lea .Lcbc_fast_body(%rip),%r10
cmp %r10,%rbx # context->Rip<.Lcbc_fast_body
jb .Lin_cbc_frame_setup
lea .Lcbc_slow_prologue(%rip),%r10
cmp %r10,%rbx # context->Rip<.Lcbc_slow_prologue
jb .Lin_cbc_body
lea .Lcbc_slow_body(%rip),%r10
cmp %r10,%rbx # context->Rip<.Lcbc_slow_body
jb .Lin_cbc_frame_setup
.Lin_cbc_body:
mov 152($context),%rax # pull context->Rsp
lea .Lcbc_epilogue(%rip),%r10
cmp %r10,%rbx # context->Rip>=.Lcbc_epilogue
jae .Lin_cbc_prologue
lea 8(%rax),%rax
lea .Lcbc_popfq(%rip),%r10
cmp %r10,%rbx # context->Rip>=.Lcbc_popfq
jae .Lin_cbc_prologue
mov `16-8`(%rax),%rax # biased $_rsp
lea 56(%rax),%rax
.Lin_cbc_frame_setup:
mov -16(%rax),%rbx
mov -24(%rax),%rbp
mov -32(%rax),%r12
mov -40(%rax),%r13
mov -48(%rax),%r14
mov -56(%rax),%r15
mov %rbx,144($context) # restore context->Rbx
mov %rbp,160($context) # restore context->Rbp
mov %r12,216($context) # restore context->R12
mov %r13,224($context) # restore context->R13
mov %r14,232($context) # restore context->R14
mov %r15,240($context) # restore context->R15
.Lin_cbc_prologue:
mov 8(%rax),%rdi
mov 16(%rax),%rsi
mov %rax,152($context) # restore context->Rsp
mov %rsi,168($context) # restore context->Rsi
mov %rdi,176($context) # restore context->Rdi
.Lcommon_seh_exit:
mov 40($disp),%rdi # disp->ContextRecord
mov $context,%rsi # context
mov \$`1232/8`,%ecx # sizeof(CONTEXT)
.long 0xa548f3fc # cld; rep movsq
mov $disp,%rsi
xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
mov 8(%rsi),%rdx # arg2, disp->ImageBase
mov 0(%rsi),%r8 # arg3, disp->ControlPc
mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
mov 40(%rsi),%r10 # disp->ContextRecord
lea 56(%rsi),%r11 # &disp->HandlerData
lea 24(%rsi),%r12 # &disp->EstablisherFrame
mov %r10,32(%rsp) # arg5
mov %r11,40(%rsp) # arg6
mov %r12,48(%rsp) # arg7
mov %rcx,56(%rsp) # arg8, (NULL)
call *__imp_RtlVirtualUnwind(%rip)
mov \$1,%eax # ExceptionContinueSearch
add \$64,%rsp
popfq
pop %r15
pop %r14
pop %r13
pop %r12
pop %rbp
pop %rbx
pop %rdi
pop %rsi
ret
.size cbc_se_handler,.-cbc_se_handler
.section .pdata
.align 4
.rva .LSEH_begin_asm_AES_encrypt
.rva .LSEH_end_asm_AES_encrypt
.rva .LSEH_info_asm_AES_encrypt
.rva .LSEH_begin_asm_AES_decrypt
.rva .LSEH_end_asm_AES_decrypt
.rva .LSEH_info_asm_AES_decrypt
.rva .LSEH_begin_asm_AES_set_encrypt_key
.rva .LSEH_end_asm_AES_set_encrypt_key
.rva .LSEH_info_asm_AES_set_encrypt_key
.rva .LSEH_begin_asm_AES_set_decrypt_key
.rva .LSEH_end_asm_AES_set_decrypt_key
.rva .LSEH_info_asm_AES_set_decrypt_key
.rva .LSEH_begin_asm_AES_cbc_encrypt
.rva .LSEH_end_asm_AES_cbc_encrypt
.rva .LSEH_info_asm_AES_cbc_encrypt
.section .xdata
.align 8
.LSEH_info_asm_AES_encrypt:
.byte 9,0,0,0
.rva block_se_handler
.rva .Lenc_prologue,.Lenc_epilogue # HandlerData[]
.LSEH_info_asm_AES_decrypt:
.byte 9,0,0,0
.rva block_se_handler
.rva .Ldec_prologue,.Ldec_epilogue # HandlerData[]
.LSEH_info_asm_AES_set_encrypt_key:
.byte 9,0,0,0
.rva key_se_handler
.rva .Lenc_key_prologue,.Lenc_key_epilogue # HandlerData[]
.LSEH_info_asm_AES_set_decrypt_key:
.byte 9,0,0,0
.rva key_se_handler
.rva .Ldec_key_prologue,.Ldec_key_epilogue # HandlerData[]
.LSEH_info_asm_AES_cbc_encrypt:
.byte 9,0,0,0
.rva cbc_se_handler
___
}
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
| 26.668567 | 89 | 0.638965 |
73fb8b6ccf5f6b75815a07f234867bac95d5e9dd | 25,410 | pm | Perl | lib/SemanticWeb/Schema/Vehicle.pm | robrwo/LDF-JSON-LD | 2745fa73562625ab217b7094a812bfc1f4be8cbc | [
"ClArtistic"
]
| null | null | null | lib/SemanticWeb/Schema/Vehicle.pm | robrwo/LDF-JSON-LD | 2745fa73562625ab217b7094a812bfc1f4be8cbc | [
"ClArtistic"
]
| null | null | null | lib/SemanticWeb/Schema/Vehicle.pm | robrwo/LDF-JSON-LD | 2745fa73562625ab217b7094a812bfc1f4be8cbc | [
"ClArtistic"
]
| null | null | null | use utf8;
package SemanticWeb::Schema::Vehicle;
# ABSTRACT: A vehicle is a device that is designed or used to transport people or cargo over land
use Moo;
extends qw/ SemanticWeb::Schema::Product /;
use MooX::JSON_LD 'Vehicle';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
use namespace::autoclean;
our $VERSION = 'v14.0.1';
=encoding utf8
=head1 DESCRIPTION
A vehicle is a device that is designed or used to transport people or cargo
over land, water, air, or through space.
=head1 ATTRIBUTES
=head2 C<acceleration_time>
C<accelerationTime>
The time needed to accelerate the vehicle from a given start velocity to a given target velocity.
Typical unit code(s): SEC for seconds
=over
=item *
Note: There are unfortunately no standard unit codes for seconds/0..100 km/h or seconds/0..60 mph. Simply use "SEC" for seconds and indicate the velocities in the [[name]] of the L<SemanticWeb::Schema::QuantitativeValue>, or use [[valueReference]] with a L<SemanticWeb::Schema::QuantitativeValue> of 0..60 mph or 0..100 km/h to specify the reference speeds.
=back
A acceleration_time should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_acceleration_time>
A predicate for the L</acceleration_time> attribute.
=cut
has acceleration_time => (
is => 'rw',
predicate => '_has_acceleration_time',
json_ld => 'accelerationTime',
);
=head2 C<body_type>
C<bodyType>
Indicates the design and body style of the vehicle (e.g. station wagon,
hatchback, etc.).
A body_type should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QualitativeValue']>
=item C<Str>
=back
=head2 C<_has_body_type>
A predicate for the L</body_type> attribute.
=cut
has body_type => (
is => 'rw',
predicate => '_has_body_type',
json_ld => 'bodyType',
);
=head2 C<call_sign>
C<callSign>
A [callsign](https://en.wikipedia.org/wiki/Call_sign), as used in
broadcasting and radio communications to identify people, radio and TV
stations, or vehicles.
A call_sign should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_call_sign>
A predicate for the L</call_sign> attribute.
=cut
has call_sign => (
is => 'rw',
predicate => '_has_call_sign',
json_ld => 'callSign',
);
=head2 C<cargo_volume>
C<cargoVolume>
The available volume for cargo or luggage. For automobiles, this is usually the trunk volume.
Typical unit code(s): LTR for liters, FTQ for cubic foot/feet
Note: You can use [[minValue]] and [[maxValue]] to indicate ranges.
A cargo_volume should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_cargo_volume>
A predicate for the L</cargo_volume> attribute.
=cut
has cargo_volume => (
is => 'rw',
predicate => '_has_cargo_volume',
json_ld => 'cargoVolume',
);
=head2 C<date_vehicle_first_registered>
C<dateVehicleFirstRegistered>
The date of the first registration of the vehicle with the respective
public authorities.
A date_vehicle_first_registered should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_date_vehicle_first_registered>
A predicate for the L</date_vehicle_first_registered> attribute.
=cut
has date_vehicle_first_registered => (
is => 'rw',
predicate => '_has_date_vehicle_first_registered',
json_ld => 'dateVehicleFirstRegistered',
);
=head2 C<drive_wheel_configuration>
C<driveWheelConfiguration>
The drive wheel configuration, i.e. which roadwheels will receive torque
from the vehicle's engine via the drivetrain.
A drive_wheel_configuration should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::DriveWheelConfigurationValue']>
=item C<Str>
=back
=head2 C<_has_drive_wheel_configuration>
A predicate for the L</drive_wheel_configuration> attribute.
=cut
has drive_wheel_configuration => (
is => 'rw',
predicate => '_has_drive_wheel_configuration',
json_ld => 'driveWheelConfiguration',
);
=head2 C<emissions_co2>
C<emissionsCO2>
The CO2 emissions in g/km. When used in combination with a
QuantitativeValue, put "g/km" into the unitText property of that value,
since there is no UN/CEFACT Common Code for "g/km".
A emissions_co2 should be one of the following types:
=over
=item C<Num>
=back
=head2 C<_has_emissions_co2>
A predicate for the L</emissions_co2> attribute.
=cut
has emissions_co2 => (
is => 'rw',
predicate => '_has_emissions_co2',
json_ld => 'emissionsCO2',
);
=head2 C<fuel_capacity>
C<fuelCapacity>
The capacity of the fuel tank or in the case of electric cars, the battery.
If there are multiple components for storage, this should indicate the
total of all storage of the same type. Typical unit code(s): LTR for
liters, GLL of US gallons, GLI for UK / imperial gallons, AMH for
ampere-hours (for electrical vehicles).
A fuel_capacity should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_fuel_capacity>
A predicate for the L</fuel_capacity> attribute.
=cut
has fuel_capacity => (
is => 'rw',
predicate => '_has_fuel_capacity',
json_ld => 'fuelCapacity',
);
=head2 C<fuel_consumption>
C<fuelConsumption>
The amount of fuel consumed for traveling a particular distance or temporal duration with the given vehicle (e.g. liters per 100 km).
=over
=item *
Note 1: There are unfortunately no standard unit codes for liters per 100 km. Use [[unitText]] to indicate the unit of measurement, e.g. L/100 km.
=item *
Note 2: There are two ways of indicating the fuel consumption, [[fuelConsumption]] (e.g. 8 liters per 100 km) and [[fuelEfficiency]] (e.g. 30 miles per gallon). They are reciprocal.
=item *
Note 3: Often, the absolute value is useful only when related to driving speed ("at 80 km/h") or usage pattern ("city traffic"). You can use [[valueReference]] to link the value for the fuel consumption to another value.
=back
A fuel_consumption should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_fuel_consumption>
A predicate for the L</fuel_consumption> attribute.
=cut
has fuel_consumption => (
is => 'rw',
predicate => '_has_fuel_consumption',
json_ld => 'fuelConsumption',
);
=head2 C<fuel_efficiency>
C<fuelEfficiency>
The distance traveled per unit of fuel used; most commonly miles per gallon (mpg) or kilometers per liter (km/L).
=over
=item *
Note 1: There are unfortunately no standard unit codes for miles per gallon or kilometers per liter. Use [[unitText]] to indicate the unit of measurement, e.g. mpg or km/L.
=item *
Note 2: There are two ways of indicating the fuel consumption, [[fuelConsumption]] (e.g. 8 liters per 100 km) and [[fuelEfficiency]] (e.g. 30 miles per gallon). They are reciprocal.
=item *
Note 3: Often, the absolute value is useful only when related to driving speed ("at 80 km/h") or usage pattern ("city traffic"). You can use [[valueReference]] to link the value for the fuel economy to another value.
=back
A fuel_efficiency should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_fuel_efficiency>
A predicate for the L</fuel_efficiency> attribute.
=cut
has fuel_efficiency => (
is => 'rw',
predicate => '_has_fuel_efficiency',
json_ld => 'fuelEfficiency',
);
=head2 C<fuel_type>
C<fuelType>
The type of fuel suitable for the engine or engines of the vehicle. If the
vehicle has only one engine, this property can be attached directly to the
vehicle.
A fuel_type should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QualitativeValue']>
=item C<Str>
=back
=head2 C<_has_fuel_type>
A predicate for the L</fuel_type> attribute.
=cut
has fuel_type => (
is => 'rw',
predicate => '_has_fuel_type',
json_ld => 'fuelType',
);
=head2 C<known_vehicle_damages>
C<knownVehicleDamages>
A textual description of known damages, both repaired and unrepaired.
A known_vehicle_damages should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_known_vehicle_damages>
A predicate for the L</known_vehicle_damages> attribute.
=cut
has known_vehicle_damages => (
is => 'rw',
predicate => '_has_known_vehicle_damages',
json_ld => 'knownVehicleDamages',
);
=head2 C<meets_emission_standard>
C<meetsEmissionStandard>
Indicates that the vehicle meets the respective emission standard.
A meets_emission_standard should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QualitativeValue']>
=item C<Str>
=back
=head2 C<_has_meets_emission_standard>
A predicate for the L</meets_emission_standard> attribute.
=cut
has meets_emission_standard => (
is => 'rw',
predicate => '_has_meets_emission_standard',
json_ld => 'meetsEmissionStandard',
);
=head2 C<mileage_from_odometer>
C<mileageFromOdometer>
The total distance travelled by the particular vehicle since its initial
production, as read from its odometer. Typical unit code(s): KMT for
kilometers, SMI for statute miles
A mileage_from_odometer should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_mileage_from_odometer>
A predicate for the L</mileage_from_odometer> attribute.
=cut
has mileage_from_odometer => (
is => 'rw',
predicate => '_has_mileage_from_odometer',
json_ld => 'mileageFromOdometer',
);
=head2 C<model_date>
C<modelDate>
The release date of a vehicle model (often used to differentiate versions
of the same make and model).
A model_date should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_model_date>
A predicate for the L</model_date> attribute.
=cut
has model_date => (
is => 'rw',
predicate => '_has_model_date',
json_ld => 'modelDate',
);
=head2 C<number_of_airbags>
C<numberOfAirbags>
The number or type of airbags in the vehicle.
A number_of_airbags should be one of the following types:
=over
=item C<Num>
=item C<Str>
=back
=head2 C<_has_number_of_airbags>
A predicate for the L</number_of_airbags> attribute.
=cut
has number_of_airbags => (
is => 'rw',
predicate => '_has_number_of_airbags',
json_ld => 'numberOfAirbags',
);
=head2 C<number_of_axles>
C<numberOfAxles>
The number of axles. Typical unit code(s): C62
A number_of_axles should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_number_of_axles>
A predicate for the L</number_of_axles> attribute.
=cut
has number_of_axles => (
is => 'rw',
predicate => '_has_number_of_axles',
json_ld => 'numberOfAxles',
);
=head2 C<number_of_doors>
C<numberOfDoors>
The number of doors. Typical unit code(s): C62
A number_of_doors should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_number_of_doors>
A predicate for the L</number_of_doors> attribute.
=cut
has number_of_doors => (
is => 'rw',
predicate => '_has_number_of_doors',
json_ld => 'numberOfDoors',
);
=head2 C<number_of_forward_gears>
C<numberOfForwardGears>
The total number of forward gears available for the transmission system of
the vehicle. Typical unit code(s): C62
A number_of_forward_gears should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_number_of_forward_gears>
A predicate for the L</number_of_forward_gears> attribute.
=cut
has number_of_forward_gears => (
is => 'rw',
predicate => '_has_number_of_forward_gears',
json_ld => 'numberOfForwardGears',
);
=head2 C<number_of_previous_owners>
C<numberOfPreviousOwners>
The number of owners of the vehicle, including the current one. Typical
unit code(s): C62
A number_of_previous_owners should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_number_of_previous_owners>
A predicate for the L</number_of_previous_owners> attribute.
=cut
has number_of_previous_owners => (
is => 'rw',
predicate => '_has_number_of_previous_owners',
json_ld => 'numberOfPreviousOwners',
);
=head2 C<payload>
The permitted weight of passengers and cargo, EXCLUDING the weight of the empty vehicle.
Typical unit code(s): KGM for kilogram, LBR for pound
=over
=item *
Note 1: Many databases specify the permitted TOTAL weight instead, which is the sum of [[weight]] and [[payload]]
=item *
Note 2: You can indicate additional information in the [[name]] of the L<SemanticWeb::Schema::QuantitativeValue> node.
=item *
Note 3: You may also link to a L<SemanticWeb::Schema::QualitativeValue> node that provides additional information using [[valueReference]].
=item *
Note 4: Note that you can use [[minValue]] and [[maxValue]] to indicate ranges.
=back
A payload should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_payload>
A predicate for the L</payload> attribute.
=cut
has payload => (
is => 'rw',
predicate => '_has_payload',
json_ld => 'payload',
);
=head2 C<production_date>
C<productionDate>
The date of production of the item, e.g. vehicle.
A production_date should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_production_date>
A predicate for the L</production_date> attribute.
=cut
has production_date => (
is => 'rw',
predicate => '_has_production_date',
json_ld => 'productionDate',
);
=head2 C<purchase_date>
C<purchaseDate>
The date the item e.g. vehicle was purchased by the current owner.
A purchase_date should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_purchase_date>
A predicate for the L</purchase_date> attribute.
=cut
has purchase_date => (
is => 'rw',
predicate => '_has_purchase_date',
json_ld => 'purchaseDate',
);
=head2 C<seating_capacity>
C<seatingCapacity>
The number of persons that can be seated (e.g. in a vehicle), both in terms
of the physical space available, and in terms of limitations set by law.
Typical unit code(s): C62 for persons
A seating_capacity should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_seating_capacity>
A predicate for the L</seating_capacity> attribute.
=cut
has seating_capacity => (
is => 'rw',
predicate => '_has_seating_capacity',
json_ld => 'seatingCapacity',
);
=head2 C<speed>
The speed range of the vehicle. If the vehicle is powered by an engine, the upper limit of the speed range (indicated by [[maxValue]] should be the maximum speed achievable under regular conditions.
Typical unit code(s): KMH for km/h, HM for mile per hour (0.447 04 m/s), KNT for knot
I<Note 1: Use [[minValue]] and [[maxValue]] to indicate the range. Typically, the minimal value is zero.
> Note 2: There are many different ways of measuring the speed range. You can link to information about how the given value has been determined using the [[valueReference]] property.
A speed should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_speed>
A predicate for the L</speed> attribute.
=cut
has speed => (
is => 'rw',
predicate => '_has_speed',
json_ld => 'speed',
);
=head2 C<steering_position>
C<steeringPosition>
The position of the steering wheel or similar device (mostly for cars).
A steering_position should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::SteeringPositionValue']>
=back
=head2 C<_has_steering_position>
A predicate for the L</steering_position> attribute.
=cut
has steering_position => (
is => 'rw',
predicate => '_has_steering_position',
json_ld => 'steeringPosition',
);
=head2 C<stupid_property>
C<stupidProperty>
This is a StupidProperty! - for testing only
A stupid_property should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_stupid_property>
A predicate for the L</stupid_property> attribute.
=cut
has stupid_property => (
is => 'rw',
predicate => '_has_stupid_property',
json_ld => 'stupidProperty',
);
=head2 C<tongue_weight>
C<tongueWeight>
The permitted vertical load (TWR) of a trailer attached to the vehicle. Also referred to as Tongue Load Rating (TLR) or Vertical Load Rating (VLR)
Typical unit code(s): KGM for kilogram, LBR for pound
=over
=item *
Note 1: You can indicate additional information in the [[name]] of the L<SemanticWeb::Schema::QuantitativeValue> node.
=item *
Note 2: You may also link to a L<SemanticWeb::Schema::QualitativeValue> node that provides additional information using [[valueReference]].
=item *
Note 3: Note that you can use [[minValue]] and [[maxValue]] to indicate ranges.
=back
A tongue_weight should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_tongue_weight>
A predicate for the L</tongue_weight> attribute.
=cut
has tongue_weight => (
is => 'rw',
predicate => '_has_tongue_weight',
json_ld => 'tongueWeight',
);
=head2 C<trailer_weight>
C<trailerWeight>
The permitted weight of a trailer attached to the vehicle.
Typical unit code(s): KGM for kilogram, LBR for pound
I< Note 1: You can indicate additional information in the [[name]] of the L<SemanticWeb::Schema::QuantitativeValue> node.
> Note 2: You may also link to a L<SemanticWeb::Schema::QualitativeValue> node that provides additional information using [[valueReference]].
* Note 3: Note that you can use [[minValue]] and [[maxValue]] to indicate ranges.
A trailer_weight should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_trailer_weight>
A predicate for the L</trailer_weight> attribute.
=cut
has trailer_weight => (
is => 'rw',
predicate => '_has_trailer_weight',
json_ld => 'trailerWeight',
);
=head2 C<vehicle_configuration>
C<vehicleConfiguration>
A short text indicating the configuration of the vehicle, e.g. '5dr
hatchback ST 2.5 MT 225 hp' or 'limited edition'.
A vehicle_configuration should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_vehicle_configuration>
A predicate for the L</vehicle_configuration> attribute.
=cut
has vehicle_configuration => (
is => 'rw',
predicate => '_has_vehicle_configuration',
json_ld => 'vehicleConfiguration',
);
=head2 C<vehicle_engine>
C<vehicleEngine>
Information about the engine or engines of the vehicle.
A vehicle_engine should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::EngineSpecification']>
=back
=head2 C<_has_vehicle_engine>
A predicate for the L</vehicle_engine> attribute.
=cut
has vehicle_engine => (
is => 'rw',
predicate => '_has_vehicle_engine',
json_ld => 'vehicleEngine',
);
=head2 C<vehicle_identification_number>
C<vehicleIdentificationNumber>
The Vehicle Identification Number (VIN) is a unique serial number used by
the automotive industry to identify individual motor vehicles.
A vehicle_identification_number should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_vehicle_identification_number>
A predicate for the L</vehicle_identification_number> attribute.
=cut
has vehicle_identification_number => (
is => 'rw',
predicate => '_has_vehicle_identification_number',
json_ld => 'vehicleIdentificationNumber',
);
=head2 C<vehicle_interior_color>
C<vehicleInteriorColor>
The color or color combination of the interior of the vehicle.
A vehicle_interior_color should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_vehicle_interior_color>
A predicate for the L</vehicle_interior_color> attribute.
=cut
has vehicle_interior_color => (
is => 'rw',
predicate => '_has_vehicle_interior_color',
json_ld => 'vehicleInteriorColor',
);
=head2 C<vehicle_interior_type>
C<vehicleInteriorType>
The type or material of the interior of the vehicle (e.g. synthetic fabric,
leather, wood, etc.). While most interior types are characterized by the
material used, an interior type can also be based on vehicle usage or
target audience.
A vehicle_interior_type should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_vehicle_interior_type>
A predicate for the L</vehicle_interior_type> attribute.
=cut
has vehicle_interior_type => (
is => 'rw',
predicate => '_has_vehicle_interior_type',
json_ld => 'vehicleInteriorType',
);
=head2 C<vehicle_model_date>
C<vehicleModelDate>
The release date of a vehicle model (often used to differentiate versions
of the same make and model).
A vehicle_model_date should be one of the following types:
=over
=item C<Str>
=back
=head2 C<_has_vehicle_model_date>
A predicate for the L</vehicle_model_date> attribute.
=cut
has vehicle_model_date => (
is => 'rw',
predicate => '_has_vehicle_model_date',
json_ld => 'vehicleModelDate',
);
=head2 C<vehicle_seating_capacity>
C<vehicleSeatingCapacity>
The number of passengers that can be seated in the vehicle, both in terms
of the physical space available, and in terms of limitations set by law.
Typical unit code(s): C62 for persons.
A vehicle_seating_capacity should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=item C<Num>
=back
=head2 C<_has_vehicle_seating_capacity>
A predicate for the L</vehicle_seating_capacity> attribute.
=cut
has vehicle_seating_capacity => (
is => 'rw',
predicate => '_has_vehicle_seating_capacity',
json_ld => 'vehicleSeatingCapacity',
);
=head2 C<vehicle_special_usage>
C<vehicleSpecialUsage>
Indicates whether the vehicle has been used for special purposes, like
commercial rental, driving school, or as a taxi. The legislation in many
countries requires this information to be revealed when offering a car for
sale.
A vehicle_special_usage should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::CarUsageType']>
=item C<Str>
=back
=head2 C<_has_vehicle_special_usage>
A predicate for the L</vehicle_special_usage> attribute.
=cut
has vehicle_special_usage => (
is => 'rw',
predicate => '_has_vehicle_special_usage',
json_ld => 'vehicleSpecialUsage',
);
=head2 C<vehicle_transmission>
C<vehicleTransmission>
The type of component used for transmitting the power from a rotating power
source to the wheels or other relevant component(s) ("gearbox" for cars).
A vehicle_transmission should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QualitativeValue']>
=item C<Str>
=back
=head2 C<_has_vehicle_transmission>
A predicate for the L</vehicle_transmission> attribute.
=cut
has vehicle_transmission => (
is => 'rw',
predicate => '_has_vehicle_transmission',
json_ld => 'vehicleTransmission',
);
=head2 C<weight_total>
C<weightTotal>
The permitted total weight of the loaded vehicle, including passengers and cargo and the weight of the empty vehicle.
Typical unit code(s): KGM for kilogram, LBR for pound
=over
=item *
Note 1: You can indicate additional information in the [[name]] of the L<SemanticWeb::Schema::QuantitativeValue> node.
=item *
Note 2: You may also link to a L<SemanticWeb::Schema::QualitativeValue> node that provides additional information using [[valueReference]].
=item *
Note 3: Note that you can use [[minValue]] and [[maxValue]] to indicate ranges.
=back
A weight_total should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_weight_total>
A predicate for the L</weight_total> attribute.
=cut
has weight_total => (
is => 'rw',
predicate => '_has_weight_total',
json_ld => 'weightTotal',
);
=head2 C<wheelbase>
The distance between the centers of the front and rear wheels. Typical unit
code(s): CMT for centimeters, MTR for meters, INH for inches, FOT for
foot/feet
A wheelbase should be one of the following types:
=over
=item C<InstanceOf['SemanticWeb::Schema::QuantitativeValue']>
=back
=head2 C<_has_wheelbase>
A predicate for the L</wheelbase> attribute.
=cut
has wheelbase => (
is => 'rw',
predicate => '_has_wheelbase',
json_ld => 'wheelbase',
);
=head1 SEE ALSO
L<SemanticWeb::Schema::Product>
=cut
1;
| 18.878158 | 357 | 0.725659 |
ed4a4f7e2bf553db0536085a921c81ebcaa991a9 | 5,681 | t | Perl | S02-types/mixed_multi_dimensional.t | lathropd/roast | 85a3ffb9eda173337ea98bb857327916237ce87c | [
"Artistic-2.0"
]
| null | null | null | S02-types/mixed_multi_dimensional.t | lathropd/roast | 85a3ffb9eda173337ea98bb857327916237ce87c | [
"Artistic-2.0"
]
| null | null | null | S02-types/mixed_multi_dimensional.t | lathropd/roast | 85a3ffb9eda173337ea98bb857327916237ce87c | [
"Artistic-2.0"
]
| null | null | null | use v6;
use Test;
plan 80;
=begin description
This tests some mixed multi-dimensional structures.
NOTE:
These tests don't go any more than two levels deep
(AoH, AoP) in most cases.
When we have this support, then
this test should be added too more.
Some deeper tests were already added.
=end description
# UNSPECCED
{ # Array of Pairs
my @array;
isa-ok(@array, Array);
my $pair = ('key' => 'value');
isa-ok($pair, Pair);
@array[0] = $pair; # assign a variable
is(+@array, 1, 'the array has one value in it');
isa-ok(@array[0], Pair);
is(@array[0]<key>, 'value', 'got the right pair value');
@array[1] = ('key1' => 'value1'); # assign it inline
is(+@array, 2, 'the array has two values in it');
isa-ok(@array[1], Pair);
is(@array[1]<key1>, 'value1', 'got the right pair value');
}
# UNSPECCED
{ # Array of Hashes
my @array;
isa-ok(@array, Array);
my %hash = ('key', 'value', 'key1', 'value1');
isa-ok(%hash, Hash);
is(+%hash.keys, 2, 'our hash has two keys');
@array[0] = %hash;
is(+@array, 1, 'the array has one value in it');
isa-ok(@array[0], Hash);
is(@array[0]{"key"}, 'value', 'got the right value for key');
is(@array[0]<key1>, 'value1', 'got the right value1 for key1');
}
{ # Array of Arrays
# L<S09/Multidimensional arrays>
my @array = (1, [2, 3], [4, 5], 6);
isa-ok(@array, Array);
is(+@array, 4, 'got 4 elements in the Array of Arrays');
is(@array[0], 1, 'got the right first element');
isa-ok(@array[1], Array);
is(@array[1][0], 2, 'got the right second/first element');
is(@array[1][1], 3, 'got the right second/second element');
isa-ok(@array[2], Array);
is(@array[2][0], 4, 'got the right third/first element');
is(@array[2][1], 5, 'got the right third/second element');
is(@array[3], 6, 'got the right fourth element');
}
# UNSPECCED
{ # Array of Subs
my @array;
isa-ok(@array, Array);
@array[0] = sub { 1 };
@array[1] = { 2 };
@array[2] = -> { 3 };
is(+@array, 3, 'got three elements in the Array');
isa-ok(@array[0], Sub);
isa-ok(@array[1], Block);
isa-ok(@array[2], Block);
is(@array[0](), 1, 'the first element (when executed) is 1');
is(@array[1](), 2, 'the second element (when executed) is 2');
is(@array[2](), 3, 'the third element (when executed) is 3');
}
# UNSPECCED
{ # Hash of Arrays
my %hash;
isa-ok(%hash, Hash);
%hash<key> = [ 1, 2, 3 ];
isa-ok(%hash<key>, Array);
is(+%hash<key>, 3, 'it should have 3 values in it');
is(%hash<key>[0], 1, 'got the right value');
is(%hash<key>[1], 2, 'got the right value');
is(%hash<key>[2], 3, 'got the right value');
{
my $array = %hash<key>;
is(+$array, 3, 'it should have 3 values in it');
is($array[0], 1, 'got the right value (when I pull the array out)');
is($array[1], 2, 'got the right value (when I pull the array out)');
is($array[2], 3, 'got the right value (when I pull the array out)');
}
{
%hash<key>.push(4);
is(+%hash<key>, 4, 'it should now have 4 values in it');
is(%hash<key>[3], 4, 'got the right value (which we just pushed onto the list)');
}
}
{ # Hash of Array-refs
# UNSPECCED
my %hash;
isa-ok(%hash, Hash);
my @array = ( 1, 2, 3 );
isa-ok(@array, Array);
%hash<key> = @array;
isa-ok(%hash<key>, Array);
is(+%hash<key>, 3, 'it should have 3 values in it');
is(%hash<key>[0], 1, 'got the right value');
is(%hash<key>[1], 2, 'got the right value');
is(%hash<key>[2], 3, 'got the right value');
{
my @array = @( %hash<key> );
is(+@array, 3, 'it should have 3 values in it');
is(@array[0], 1, 'got the right value (when I pull the array out)');
is(@array[1], 2, 'got the right value (when I pull the array out)');
is(@array[2], 3, 'got the right value (when I pull the array out)');
}
{
%hash<key>.push(4);
is(+%hash<key>, 4, 'it should now have 4 values in it');
is(%hash<key>[3], 4, 'got the right value (which we just pushed onto the array)');
}
}
{ # Itemized hash survives addition to an array.
my %h = <a 5 b 6>;
my $hr = %h;
my $a0 = [ $%h ,'extra' ];
my $a1 = [ $%h ];
my $a2 = [ $hr ];
is($a0.elems,2,'itemized hash should not get decomposed');
is($a1.elems,1,'itemized hash should not get decomposed');
is($a2.elems,1,'itemized hash should not get decomposed');
}
{ # nested, declared in one statement
my $h = { a => [ 1,2,3 ] };
isa-ok($h<a>.WHAT, Array, "array nested in hashref in one declaration");
}
{ # structures deeper than 2 levels
my @array;
@array[0][0][0][0][0] = 5;
isa-ok(@array, Array);
isa-ok(@array[0], Array);
isa-ok(@array[0][0], Array);
isa-ok(@array[0][0][0], Array);
isa-ok(@array[0][0][0][0], Array);
is(@array[0][0][0][0][0], 5, "5 level deep arrays only structure");
@array[1]<two>[0]<four>[0]<six> = 6;
isa-ok(@array, Array);
isa-ok(@array[1], Hash);
isa-ok(@array[1]<two>, Array);
isa-ok(@array[1]<two>[0], Hash);
is(+@array[1]<two>[0], 1, "one key at level 4");
isa-ok(@array[1]<two>[0]<four>, Array);
isa-ok(@array[1]<two>[0]<four>[0], Hash);
is(@array[1]<two>[0]<four>[0]<six>, 6, "6 level deep mixed structure");
@array[2]<two>[0]<f><other> = 5;
isa-ok(@array[1]<two>[0], Hash);
#?rakudo todo 'isa hash'
isa-ok(@array[1]<two>[0]<f>, Hash);
#?rakudo 2 todo 'unknown'
is(+@array[1]<two>[0], 2, "two keys at level 4");
is(@array[1]<two>[0]<f><other>, 5, "more keys at level 4");
}
# vim: expandtab shiftwidth=4
| 27.712195 | 86 | 0.563281 |
73d146ce655e388acbb9de7cc41077633a7e1d5f | 2,353 | t | Perl | t/regression/chart_format11.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
]
| 61 | 2015-02-03T02:49:53.000Z | 2022-02-13T09:17:53.000Z | t/regression/chart_format11.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
]
| 167 | 2015-01-02T09:25:11.000Z | 2022-02-16T22:04:20.000Z | t/regression/chart_format11.t | f20/excel-writer-xlsx | b08a865c6972f935b7d72e64e5580cca8e6cc299 | [
"Artistic-1.0-Perl"
]
| 31 | 2015-02-16T12:06:45.000Z | 2021-10-14T13:03:22.000Z | ###############################################################################
#
# Tests the output of Excel::Writer::XLSX against Excel generated files.
#
# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org
#
use lib 't/lib';
use TestFunctions qw(_compare_xlsx_files _is_deep_diff);
use strict;
use warnings;
use Test::More tests => 1;
###############################################################################
#
# Tests setup.
#
my $filename = 'chart_format11.xlsx';
my $dir = 't/regression/';
my $got_filename = $dir . "ewx_$filename";
my $exp_filename = $dir . 'xlsx_files/' . $filename;
my $ignore_members = [];
my $ignore_elements = { 'xl/charts/chart1.xml' => ['<c:pageMargins'] };
###############################################################################
#
# Test the creation of an Excel::Writer::XLSX file with chart formatting.
#
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet = $workbook->add_worksheet();
my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
# For testing, copy the randomly generated axis ids in the target xlsx file.
$chart->{_axis_ids} = [ 50664576, 50666496 ];
my $data = [
[ 1, 2, 3, 4, 5 ],
[ 2, 4, 6, 8, 10 ],
[ 3, 6, 9, 12, 15 ],
];
$worksheet->write( 'A1', $data );
$chart->add_series(
categories => '=Sheet1!$A$1:$A$5',
values => '=Sheet1!$B$1:$B$5',
trendline => {
type => 'polynomial',
name => 'My trend name',
order => 2,
forward => 0.5,
backward => 0.5,
line => {
color => 'red',
width => 1,
dash_type => 'long_dash',
}
},
);
$chart->add_series(
categories => '=Sheet1!$A$1:$A$5',
values => '=Sheet1!$C$1:$C$5',
);
$worksheet->insert_chart( 'E9', $chart );
$workbook->close();
###############################################################################
#
# Compare the generated and existing Excel files.
#
my ( $got, $expected, $caption ) = _compare_xlsx_files(
$got_filename,
$exp_filename,
$ignore_members,
$ignore_elements,
);
_is_deep_diff( $got, $expected, $caption );
###############################################################################
#
# Cleanup.
#
unlink $got_filename;
__END__
| 22.625 | 79 | 0.483638 |
73d9b7a59134773ccb35d868aefe7fe4115c7508 | 4,684 | pl | Perl | webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/uz-Latn-UZ.pl | tomoyanp/isucon9-qualify-20210912 | f84b5d1c82f9d41bbba02422c1a6acd358d9c41a | [
"MIT"
]
| null | null | null | webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/uz-Latn-UZ.pl | tomoyanp/isucon9-qualify-20210912 | f84b5d1c82f9d41bbba02422c1a6acd358d9c41a | [
"MIT"
]
| 5 | 2021-05-20T04:16:14.000Z | 2022-02-12T01:40:02.000Z | webapp/perl/local/lib/perl5/auto/share/dist/DateTime-Locale/uz-Latn-UZ.pl | matsubara0507/isucon9-kansousen | 77b19085d76add98a3ce7370063a8636cde62499 | [
"MIT"
]
| null | null | null | {
am_pm_abbreviated => [
"TO",
"TK",
],
available_formats => {
Bh => "B h",
Bhm => "B h:mm",
Bhms => "B h:mm:ss",
E => "ccc",
EBhm => "E, B h:mm",
EBhms => "E, B h:mm:ss",
EHm => "E, HH:mm",
EHms => "E, HH:mm:ss",
Ed => "d, E",
Ehm => "E, h:mm a",
Ehms => "E, h:mm:ss a",
Gy => "G y",
GyMMM => "MMM, G y",
GyMMMEd => "E, d-MMM, G y",
GyMMMd => "d-MMM, G y",
H => "HH",
Hm => "HH:mm",
Hms => "HH:mm:ss",
Hmsv => "HH:mm:ss (v)",
Hmv => "HH:mm (v)",
M => "LL",
MEd => "E, dd/MM",
MMM => "LLL",
MMMEd => "E, d-MMM",
"MMMMW-count-one" => "MMMM, W-'hafta'",
"MMMMW-count-other" => "MMMM, W-'hafta'",
MMMMd => "d-MMMM",
MMMd => "d-MMM",
Md => "dd/MM",
d => "d",
h => "h a",
hm => "h:mm a",
hms => "h:mm:ss a",
hmsv => "h:mm:ss a (v)",
hmv => "h:mm a (v)",
ms => "mm:ss",
y => "y",
yM => "MM.y",
yMEd => "E, dd/MM/y",
yMMM => "MMM, y",
yMMMEd => "E, d-MMM, y",
yMMMM => "MMMM, y",
yMMMd => "d-MMM, y",
yMd => "dd/MM/y",
yQQQ => "y, QQQ",
yQQQQ => "y, QQQQ",
"yw-count-one" => "Y, w-'hafta'",
"yw-count-other" => "Y, w-'hafta'",
},
code => "uz-Latn-UZ",
date_format_full => "EEEE, d-MMMM, y",
date_format_long => "d-MMMM, y",
date_format_medium => "d-MMM, y",
date_format_short => "dd/MM/yy",
datetime_format_full => "{1}, {0}",
datetime_format_long => "{1}, {0}",
datetime_format_medium => "{1}, {0}",
datetime_format_short => "{1}, {0}",
day_format_abbreviated => [
"Dush",
"Sesh",
"Chor",
"Pay",
"Jum",
"Shan",
"Yak",
],
day_format_narrow => [
"D",
"S",
"C",
"P",
"J",
"S",
"Y",
],
day_format_wide => [
"dushanba",
"seshanba",
"chorshanba",
"payshanba",
"juma",
"shanba",
"yakshanba",
],
day_stand_alone_abbreviated => [
"Dush",
"Sesh",
"Chor",
"Pay",
"Jum",
"Shan",
"Yak",
],
day_stand_alone_narrow => [
"D",
"S",
"C",
"P",
"J",
"S",
"Y",
],
day_stand_alone_wide => [
"dushanba",
"seshanba",
"chorshanba",
"payshanba",
"juma",
"shanba",
"yakshanba",
],
era_abbreviated => [
"m.a.",
"milodiy",
],
era_narrow => [
"m.a.",
"milodiy",
],
era_wide => [
"miloddan avvalgi",
"milodiy",
],
first_day_of_week => 1,
glibc_date_1_format => "%a %b %e %H:%M:%S %Z %Y",
glibc_date_format => "%m/%d/%y",
glibc_datetime_format => "%a %b %e %H:%M:%S %Y",
glibc_time_12_format => "%I:%M:%S %p",
glibc_time_format => "%H:%M:%S",
language => "Uzbek",
month_format_abbreviated => [
"yan",
"fev",
"mar",
"apr",
"may",
"iyn",
"iyl",
"avg",
"sen",
"okt",
"noy",
"dek",
],
month_format_narrow => [
"Y",
"F",
"M",
"A",
"M",
"I",
"I",
"A",
"S",
"O",
"N",
"D",
],
month_format_wide => [
"yanvar",
"fevral",
"mart",
"aprel",
"may",
"iyun",
"iyul",
"avgust",
"sentabr",
"oktabr",
"noyabr",
"dekabr",
],
month_stand_alone_abbreviated => [
"Yan",
"Fev",
"Mar",
"Apr",
"May",
"Iyn",
"Iyl",
"Avg",
"Sen",
"Okt",
"Noy",
"Dek",
],
month_stand_alone_narrow => [
"Y",
"F",
"M",
"A",
"M",
"I",
"I",
"A",
"S",
"O",
"N",
"D",
],
month_stand_alone_wide => [
"Yanvar",
"Fevral",
"Mart",
"Aprel",
"May",
"Iyun",
"Iyul",
"Avgust",
"Sentabr",
"Oktabr",
"Noyabr",
"Dekabr",
],
name => "Uzbek Uzbekistan Latin",
native_language => "o\N{U+2018}zbek",
native_name => "o\N{U+2018}zbek O\N{U+02bb}zbekiston lotin",
native_script => "lotin",
native_territory => "O\N{U+02bb}zbekiston",
native_variant => undef,
quarter_format_abbreviated => [
"1-ch",
"2-ch",
"3-ch",
"4-ch",
],
quarter_format_narrow => [
1,
2,
3,
4,
],
quarter_format_wide => [
"1-chorak",
"2-chorak",
"3-chorak",
"4-chorak",
],
quarter_stand_alone_abbreviated => [
"1-ch",
"2-ch",
"3-ch",
"4-ch",
],
quarter_stand_alone_narrow => [
1,
2,
3,
4,
],
quarter_stand_alone_wide => [
"1-chorak",
"2-chorak",
"3-chorak",
"4-chorak",
],
script => "Latin",
territory => "Uzbekistan",
time_format_full => "H:mm:ss (zzzz)",
time_format_long => "H:mm:ss (z)",
time_format_medium => "HH:mm:ss",
time_format_short => "HH:mm",
variant => undef,
version => 35,
}
| 17.157509 | 62 | 0.443638 |
ed089cdad2d52ff485fb06becf9cf17df57acb15 | 5,782 | pm | Perl | modules/Bio/EnsEMBL/GlyphSet/contig.pm | amonida/ensembl-webcode | 284a8c633fdcf72575f18c11ac0657ee0919e270 | [
"Apache-2.0",
"MIT"
]
| null | null | null | modules/Bio/EnsEMBL/GlyphSet/contig.pm | amonida/ensembl-webcode | 284a8c633fdcf72575f18c11ac0657ee0919e270 | [
"Apache-2.0",
"MIT"
]
| null | null | null | modules/Bio/EnsEMBL/GlyphSet/contig.pm | amonida/ensembl-webcode | 284a8c633fdcf72575f18c11ac0657ee0919e270 | [
"Apache-2.0",
"MIT"
]
| 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
package Bio::EnsEMBL::GlyphSet::contig;
use strict;
use base qw(Bio::EnsEMBL::GlyphSet);
sub _init {
my $self = shift;
return $self->render_text if $self->{'text_export'};
# only draw contigs once - on one strand
if ($self->species_defs->NO_SEQUENCE) {
$self->errorTrack('Clone map - no sequence to display');
return;
}
my ($fontname, $fontsize) = $self->get_font_details('innertext');
my $container = $self->{'container'};
my $length = $container->length;
my $h = [ $self->get_text_width(0, 'X', '', font => $fontname, ptsize => $fontsize) ]->[3];
my $box_h = $self->my_config('h');
my $pix_per_bp = $self->scalex;
my $features = $self->features;
if (!$box_h) {
$box_h = $h + 4;
} elsif ($box_h < $h + 4) {
$h = 0;
}
foreach (0, $box_h) {
$self->push($self->Rect({
x => 0,
y => $_,
width => $length,
height => 0,
colour => 'grey50',
absolutey => 1,
}));
}
if (scalar @$features) {
$self->init_contigs($h, $box_h, $fontname, $fontsize, $features);
} else {
$self->errorTrack($container->isa('Bio::EnsEMBL::Compara::AlignSlice::Slice') && $self->get_parameter('compara') ne 'primary' ? 'Alignment gap - no contigs to display' : 'Golden path gap - no contigs to display');
}
}
sub init_contigs {
my ($self, $h, $box_h, $fontname, $fontsize, $contig_tiling_path) = @_;
my $length = $self->{'container'}->length;
my $pix_per_bp = $self->scalex;
my $threshold_navigation = ($self->my_config('threshold_navigation') || 2e6) * 1001;
my $navigation = $self->my_config('navigation') || 'on';
my $show_navigation = $length < $threshold_navigation && $navigation eq 'on';
my $species = $self->species;
my @colours = ([ 'contigblue1', 'contigblue2' ], [ 'lightgoldenrod1', 'lightgoldenrod3' ]);
my @label_colours = qw(white black);
# Draw the Contig Tiling Path
foreach (sort { $a->{'start'} <=> $b->{'start'} } @$contig_tiling_path) {
my $strand = $_->strand;
my $end = $_->{'end'};
my $start = $_->{'start'};
my $region = $_->{'name'};
my $i = $_->get_all_Attributes('hap_contig')->[0]{'value'} ? 1 : 0; # if this is a haplotype contig then need a different pair of colours for the contigs
# AlignSlice segments can be on different strands - hence need to check if start & end need a swap
($start, $end) = ($end, $start) if $start > $end;
$start = 1 if $start < 1;
$end = $length if $end > $length;
$self->push($self->Rect({
x => $start - 1,
y => 0,
width => $end - $start + 1,
height => $box_h,
colour => $colours[$i]->[0],
absolutey => 1,
title => $region,
href => $show_navigation && $species ne 'ancestral_sequences' ? $self->href($_) : ''
}));
push @{$colours[$i]}, shift @{@colours[$i]};
if ($h) {
my @res = $self->get_text_width(($end - $start) * $pix_per_bp, $self->feature_label($_), $strand > 0 ? '>' : '<', font => $fontname, ptsize => $fontsize);
if ($res[0]) {
$self->push($self->Text({
x => ($end + $start - $res[2] / $pix_per_bp) / 2,
height => $res[3],
width => $res[2] / $pix_per_bp,
textwidth => $res[2],
y => ($h - $res[3]) / 2,
font => $fontname,
ptsize => $fontsize,
colour => $label_colours[$i],
text => $res[0],
absolutey => 1
}));
}
}
}
}
sub render_text {
my $self = shift;
return if $self->species_defs->NO_SEQUENCE;
my $export;
foreach (@{$self->features}) {
$export .= $self->_render_text($_, 'Contig', { headers => [ 'id' ], values => [ $_->{'name'} ] }, {
seqname => $_->seq_region_name,
start => $_->start,
end => $_->end,
strand => $_->strand
});
}
return $export;
}
sub features {
my $self = shift;
my $container = $self->{'container'};
my $adaptor = $container->adaptor;
my @features;
foreach (@{$container->project('seqlevel') || []}) {
my $slice = Bio::EnsEMBL::Slice->new_fast({%{$_->to_Slice}});
$slice->{'name'} = $slice->coord_system->name eq 'ancestralsegment' ? $slice->{'_tree'} : $slice->seq_region_name; # This is a Slice of Ancestral sequences: display the tree instead of the ID;
$slice->{'start'} = $_->from_start;
$slice->{'end'} = $_->from_end;
push @features, $slice;
}
return \@features;
}
sub href {
my ($self, $f) = @_;
my $offset = $self->{'container'}->start - 1;
return $self->_url({
species => $self->species,
type => 'Location',
action => 'Contig',
region => $f->{'name'},
r => sprintf('%s:%s-%s', $self->{'container'}->seq_region_name, $f->start + $offset, $f->end + $offset)
});
}
sub feature_label {
my ($self, $f) = @_;
return $f->strand == 1 ? "$f->{'name'} >" : "< $f->{'name'}";
}
1;
| 31.769231 | 217 | 0.554825 |
ed4ac9c2445cd5826bb1e16ac6dccc92088d93ff | 2,985 | pl | Perl | src/libYARP_sig_logpolar/configure.pl | robotology-legacy/yarp1 | 21434f5b776edea201b39a9644552dca59339dbc | [
"Artistic-1.0-Perl"
]
| null | null | null | src/libYARP_sig_logpolar/configure.pl | robotology-legacy/yarp1 | 21434f5b776edea201b39a9644552dca59339dbc | [
"Artistic-1.0-Perl"
]
| null | null | null | src/libYARP_sig_logpolar/configure.pl | robotology-legacy/yarp1 | 21434f5b776edea201b39a9644552dca59339dbc | [
"Artistic-1.0-Perl"
]
| null | null | null | #! /usr/bin/perl
#
# --file <config_file>
# where <config_file> is the filename of the context config file.
#
use Getopt::Long;
use File::Copy;
print "Entering configure process of YARP log-polar library...\n";
$yarp_root = $ENV{'YARP_ROOT'};
if (!defined($yarp_root))
{
die "YARP_ROOT environment variable must be defined!\nto point to the path of the yarp source distribution\n";
}
require "$yarp_root/conf/configure.template.pl" or die "Can't find template file $yarp_root/conf/configure.template.pl\n";
my $exp_os = check_os();
print "Ready to start...\n";
my $config_file = "$yarp_root/conf/context.conf";
my %options = ();
GetOptions ('file=s' => \$config_file );
if (-e $config_file)
{
copy ($config_file, "$config_file.old") or warn "Can't copy $config_file, old file might be overwritten\n";
load_config_file (\%options, $config_file);
}
#
#
#
my $os = $options{"Architecture<-OS"};
print "Now I'm going to ask a few questions to help building the configuration. ";
print "For pathnames you can use (type) the pre-defined value \$YARP_ROOT ";
print "that I've verified as: \"$yarp_root\"\n\n";
print "Please, use always the forward slash as a separator!\n";
print "I determined already that you're running on a supported OS: $exp_os\n";
die "Cross-compile is not supported, the auto-detected OS must be also selected\n" if ($os ne $exp_os);
print "Would you like to set a default for library compilation?\n";
get_option_hash ("Compile_Sig_Logpolar<-Lib_Clean", "FALSE", "Clean first: i.e. rebuild libraries?", 1, \%options);
get_option_hash ("Compile_Sig_Logpolar<-Lib_Debug", "FALSE", "Debug mode?", 1, \%options);
get_option_hash ("Compile_Sig_Logpolar<-Lib_Release", "FALSE", "Release mode (optimization on)?", 1, \%options);
get_option_hash ("Compile_Sig_Logpolar<-Lib_Install", "FALSE", "Install after compile?", 1, \%options);
# consistency check.
if ($options{"Compile_Sig_Logpolar<-Lib_Debug"} ne "TRUE" &&
$options{"Compile_Sig_Logpolar<-Lib_Release"} ne "TRUE" &&
$options{"Compile_Sig_Logpolar<-Lib_Clean"} eq "TRUE")
{
print "Since you're rebuilding, you should at least select between debug and release\n";
print "I'm assuming you wanted to compile debug\n";
$options{"Compile_Sig_Logpolar<-Lib_Debug"} = "TRUE";
}
get_option_hash ("Compile_Sig_Logpolar<-Tools_Rebuild", "NO", "Would you like to recompile the tools?", 1, \%options);
if ($options{"Compile_Sig_Logpolar<-Tools_Rebuild"} eq "NO" &&
$options{"Compile_Sig_Logpolar<-Lib_Clean"} eq "TRUE")
{
print "You're rebuilding, you need to compile the tools too. ";
print "I'm doing it for you.\n";
$options{"Compile_Sig_Logpolar<-Tools_Rebuild"} = "YES";
}
get_option_hash ("Compile_Sig_Logpolar<-Tools_Debug", "FALSE", "Would you like to compile the tools with debug enabled?", 1, \%options);
print "We're done for now, the context file is being updated: \"$config_file\"\n";
#
# creating a new config file.
#
save_config_file (\%options, $config_file);
print "Done!\n";
| 34.709302 | 136 | 0.720268 |
ed08ef594938511a2944935d4b4adf06889b2aca | 1,699 | pm | Perl | cloud/aws/elb/application/plugin.pm | xdrive05/centreon-plugins | 8227ba680fdfd2bb0d8a806ea61ec1611c2779dc | [
"Apache-2.0"
]
| 1 | 2021-03-16T22:20:32.000Z | 2021-03-16T22:20:32.000Z | cloud/aws/elb/application/plugin.pm | xdrive05/centreon-plugins | 8227ba680fdfd2bb0d8a806ea61ec1611c2779dc | [
"Apache-2.0"
]
| null | null | null | cloud/aws/elb/application/plugin.pm | xdrive05/centreon-plugins | 8227ba680fdfd2bb0d8a806ea61ec1611c2779dc | [
"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 cloud::aws::elb::application::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} = '0.1';
%{ $self->{modes} } = (
'connections' => 'cloud::aws::elb::application::mode::connections',
'discovery' => 'cloud::aws::elb::application::mode::discovery',
'http-codes' => 'cloud::aws::elb::application::mode::httpcodes',
'targets-health' => 'cloud::aws::elb::application::mode::targetshealth',
);
$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 Application Elastic Load Balancing (Amazon Application ELB).
=cut
| 31.462963 | 87 | 0.675103 |
ed3c2f593ddb60fa1dd860a2c753ee0da3caaa7f | 3,824 | pm | Perl | auto-lib/Paws/SSM/OpsItemSummary.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/SSM/OpsItemSummary.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/SSM/OpsItemSummary.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
]
| 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z | # Generated by default/object.tt
package Paws::SSM::OpsItemSummary;
use Moose;
has ActualEndTime => (is => 'ro', isa => 'Str');
has ActualStartTime => (is => 'ro', isa => 'Str');
has Category => (is => 'ro', isa => 'Str');
has CreatedBy => (is => 'ro', isa => 'Str');
has CreatedTime => (is => 'ro', isa => 'Str');
has LastModifiedBy => (is => 'ro', isa => 'Str');
has LastModifiedTime => (is => 'ro', isa => 'Str');
has OperationalData => (is => 'ro', isa => 'Paws::SSM::OpsItemOperationalData');
has OpsItemId => (is => 'ro', isa => 'Str');
has OpsItemType => (is => 'ro', isa => 'Str');
has PlannedEndTime => (is => 'ro', isa => 'Str');
has PlannedStartTime => (is => 'ro', isa => 'Str');
has Priority => (is => 'ro', isa => 'Int');
has Severity => (is => 'ro', isa => 'Str');
has Source => (is => 'ro', isa => 'Str');
has Status => (is => 'ro', isa => 'Str');
has Title => (is => 'ro', isa => 'Str');
1;
### main pod documentation begin ###
=head1 NAME
Paws::SSM::OpsItemSummary
=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::SSM::OpsItemSummary object:
$service_obj->Method(Att1 => { ActualEndTime => $value, ..., Title => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::SSM::OpsItemSummary object:
$result = $service_obj->Method(...);
$result->Att1->ActualEndTime
=head1 DESCRIPTION
A count of OpsItems.
=head1 ATTRIBUTES
=head2 ActualEndTime => Str
The time a runbook workflow ended. Currently reported only for the
OpsItem type C</aws/changerequest>.
=head2 ActualStartTime => Str
The time a runbook workflow started. Currently reported only for the
OpsItem type C</aws/changerequest>.
=head2 Category => Str
A list of OpsItems by category.
=head2 CreatedBy => Str
The Amazon Resource Name (ARN) of the IAM entity that created the
OpsItem.
=head2 CreatedTime => Str
The date and time the OpsItem was created.
=head2 LastModifiedBy => Str
The Amazon Resource Name (ARN) of the IAM entity that created the
OpsItem.
=head2 LastModifiedTime => Str
The date and time the OpsItem was last updated.
=head2 OperationalData => L<Paws::SSM::OpsItemOperationalData>
Operational data is custom data that provides useful reference details
about the OpsItem.
=head2 OpsItemId => Str
The ID of the OpsItem.
=head2 OpsItemType => Str
The type of OpsItem. Currently, the only valid values are
C</aws/changerequest> and C</aws/issue>.
=head2 PlannedEndTime => Str
The time specified in a change request for a runbook workflow to end.
Currently supported only for the OpsItem type C</aws/changerequest>.
=head2 PlannedStartTime => Str
The time specified in a change request for a runbook workflow to start.
Currently supported only for the OpsItem type C</aws/changerequest>.
=head2 Priority => Int
The importance of this OpsItem in relation to other OpsItems in the
system.
=head2 Severity => Str
A list of OpsItems by severity.
=head2 Source => Str
The impacted AWS resource.
=head2 Status => Str
The OpsItem status. Status can be C<Open>, C<In Progress>, or
C<Resolved>.
=head2 Title => Str
A short heading that describes the nature of the OpsItem and the
impacted resource.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::SSM>
=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
| 23.036145 | 102 | 0.694038 |
ed0339cbe1352c4b78774620fddb8e2238b43d71 | 116,642 | pl | Perl | vpx_dsp/vpx_dsp_rtcd_defs.pl | phoenixstar7/VP9-GE | c530208ae3cc0cb6835aeaa8e9ceb7edb37f40f0 | [
"BSD-3-Clause"
]
| null | null | null | vpx_dsp/vpx_dsp_rtcd_defs.pl | phoenixstar7/VP9-GE | c530208ae3cc0cb6835aeaa8e9ceb7edb37f40f0 | [
"BSD-3-Clause"
]
| null | null | null | vpx_dsp/vpx_dsp_rtcd_defs.pl | phoenixstar7/VP9-GE | c530208ae3cc0cb6835aeaa8e9ceb7edb37f40f0 | [
"BSD-3-Clause"
]
| null | null | null | sub vpx_dsp_forward_decls() {
print <<EOF
/*
* DSP
*/
#include "vpx/vpx_integer.h"
#include "vpx_dsp/vpx_dsp_common.h"
EOF
}
forward_decls qw/vpx_dsp_forward_decls/;
# functions that are 64 bit only.
$mmx_x86_64 = $sse2_x86_64 = $ssse3_x86_64 = $avx_x86_64 = $avx2_x86_64 = '';
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';
}
#
# Intra prediction
#
add_proto qw/void vpx_d207_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d207_predictor_4x4 sse2/;
add_proto qw/void vpx_d45_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d45_predictor_4x4 neon sse2/;
add_proto qw/void vpx_d45e_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d63_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d63_predictor_4x4 ssse3/;
add_proto qw/void vpx_d63e_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_h_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_h_predictor_4x4 neon dspr2 msa sse2 vsx/;
add_proto qw/void vpx_he_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d117_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d135_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d135_predictor_4x4 neon/;
add_proto qw/void vpx_d153_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d153_predictor_4x4 ssse3/;
add_proto qw/void vpx_v_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_v_predictor_4x4 neon msa sse2/;
add_proto qw/void vpx_ve_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_tm_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_tm_predictor_4x4 neon dspr2 msa sse2 vsx/;
add_proto qw/void vpx_dc_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_predictor_4x4 dspr2 msa neon sse2/;
add_proto qw/void vpx_dc_top_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_top_predictor_4x4 msa neon sse2/;
add_proto qw/void vpx_dc_left_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_left_predictor_4x4 msa neon sse2/;
add_proto qw/void vpx_dc_128_predictor_4x4/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_128_predictor_4x4 msa neon sse2/;
add_proto qw/void vpx_d207_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d207_predictor_8x8 ssse3/;
add_proto qw/void vpx_d45_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d45_predictor_8x8 neon sse2 vsx/;
add_proto qw/void vpx_d63_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d63_predictor_8x8 ssse3 vsx/;
add_proto qw/void vpx_h_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_h_predictor_8x8 neon dspr2 msa sse2 vsx/;
add_proto qw/void vpx_d117_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d135_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d135_predictor_8x8 neon/;
add_proto qw/void vpx_d153_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d153_predictor_8x8 ssse3/;
add_proto qw/void vpx_v_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_v_predictor_8x8 neon msa sse2/;
add_proto qw/void vpx_tm_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_tm_predictor_8x8 neon dspr2 msa sse2 vsx/;
add_proto qw/void vpx_dc_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_predictor_8x8 dspr2 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_top_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_top_predictor_8x8 neon msa sse2/;
add_proto qw/void vpx_dc_left_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_left_predictor_8x8 neon msa sse2/;
add_proto qw/void vpx_dc_128_predictor_8x8/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_128_predictor_8x8 neon msa sse2/;
add_proto qw/void vpx_d207_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d207_predictor_16x16 ssse3/;
add_proto qw/void vpx_d45_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d45_predictor_16x16 neon ssse3 vsx/;
add_proto qw/void vpx_d63_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d63_predictor_16x16 ssse3 vsx/;
add_proto qw/void vpx_h_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_h_predictor_16x16 neon dspr2 msa sse2 vsx/;
add_proto qw/void vpx_d117_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d135_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d135_predictor_16x16 neon/;
add_proto qw/void vpx_d153_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d153_predictor_16x16 ssse3/;
add_proto qw/void vpx_v_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_v_predictor_16x16 neon msa sse2 vsx/;
add_proto qw/void vpx_tm_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_tm_predictor_16x16 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_predictor_16x16 dspr2 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_top_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_top_predictor_16x16 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_left_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_left_predictor_16x16 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_128_predictor_16x16/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_128_predictor_16x16 neon msa sse2 vsx/;
add_proto qw/void vpx_d207_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d207_predictor_32x32 ssse3/;
add_proto qw/void vpx_d45_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d45_predictor_32x32 neon ssse3 vsx/;
add_proto qw/void vpx_d63_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d63_predictor_32x32 ssse3 vsx/;
add_proto qw/void vpx_h_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_h_predictor_32x32 neon msa sse2 vsx/;
add_proto qw/void vpx_d117_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
add_proto qw/void vpx_d135_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d135_predictor_32x32 neon/;
add_proto qw/void vpx_d153_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_d153_predictor_32x32 ssse3/;
add_proto qw/void vpx_v_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_v_predictor_32x32 neon msa sse2 vsx/;
add_proto qw/void vpx_tm_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_tm_predictor_32x32 neon msa sse2 vsx/;
add_proto qw/void vpx_dc_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_predictor_32x32 msa neon sse2 vsx/;
add_proto qw/void vpx_dc_top_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_top_predictor_32x32 msa neon sse2 vsx/;
add_proto qw/void vpx_dc_left_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_left_predictor_32x32 msa neon sse2 vsx/;
add_proto qw/void vpx_dc_128_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
specialize qw/vpx_dc_128_predictor_32x32 msa neon sse2 vsx/;
# High bitdepth functions
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vpx_highbd_d207_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d45_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d45_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_d63_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_h_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_h_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_d117_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d135_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d135_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_d153_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_v_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_v_predictor_4x4 neon sse2/;
add_proto qw/void vpx_highbd_tm_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_tm_predictor_4x4 neon sse2/;
add_proto qw/void vpx_highbd_dc_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_predictor_4x4 neon sse2/;
add_proto qw/void vpx_highbd_dc_top_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_top_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_dc_left_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_left_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_dc_128_predictor_4x4/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_128_predictor_4x4 neon/;
add_proto qw/void vpx_highbd_d207_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d45_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d45_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_d63_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_h_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_h_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_d117_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d135_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d135_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_d153_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_v_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_v_predictor_8x8 neon sse2/;
add_proto qw/void vpx_highbd_tm_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_tm_predictor_8x8 neon sse2/;
add_proto qw/void vpx_highbd_dc_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_predictor_8x8 neon sse2/;
add_proto qw/void vpx_highbd_dc_top_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_top_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_dc_left_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_left_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_dc_128_predictor_8x8/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_128_predictor_8x8 neon/;
add_proto qw/void vpx_highbd_d207_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d45_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d45_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_d63_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_h_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_h_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_d117_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d135_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d135_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_d153_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_v_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_v_predictor_16x16 neon sse2/;
add_proto qw/void vpx_highbd_tm_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_tm_predictor_16x16 neon sse2/;
add_proto qw/void vpx_highbd_dc_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_predictor_16x16 neon sse2/;
add_proto qw/void vpx_highbd_dc_top_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_top_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_dc_left_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_left_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_dc_128_predictor_16x16/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_128_predictor_16x16 neon/;
add_proto qw/void vpx_highbd_d207_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d45_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d45_predictor_32x32 neon/;
add_proto qw/void vpx_highbd_d63_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_h_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_h_predictor_32x32 neon/;
add_proto qw/void vpx_highbd_d117_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_d135_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_d135_predictor_32x32 neon/;
add_proto qw/void vpx_highbd_d153_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
add_proto qw/void vpx_highbd_v_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_v_predictor_32x32 neon sse2/;
add_proto qw/void vpx_highbd_tm_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_tm_predictor_32x32 neon sse2/;
add_proto qw/void vpx_highbd_dc_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_predictor_32x32 neon sse2/;
add_proto qw/void vpx_highbd_dc_top_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_top_predictor_32x32 neon/;
add_proto qw/void vpx_highbd_dc_left_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_left_predictor_32x32 neon/;
add_proto qw/void vpx_highbd_dc_128_predictor_32x32/, "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
specialize qw/vpx_highbd_dc_128_predictor_32x32 neon/;
} # CONFIG_VP9_HIGHBITDEPTH
#
# Sub Pixel Filters
#
add_proto qw/void vpx_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/vpx_convolve_copy neon dspr2 msa sse2/;
add_proto qw/void vpx_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/vpx_convolve_avg neon dspr2 msa sse2/;
add_proto qw/void vpx_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/vpx_convolve8 sse2 ssse3 avx2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_convolve8_horiz sse2 ssse3 avx2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_convolve8_vert sse2 ssse3 avx2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_convolve8_avg sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_convolve8_avg_horiz sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_convolve8_avg_vert sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_scaled_2d/, "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/vpx_scaled_2d ssse3/;
add_proto qw/void vpx_scaled_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";
add_proto qw/void vpx_scaled_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";
add_proto qw/void vpx_scaled_avg_2d/, "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";
add_proto qw/void vpx_scaled_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";
add_proto qw/void vpx_scaled_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";
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
#
# Sub Pixel Filters
#
add_proto qw/void vpx_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/vpx_highbd_convolve_copy sse2 avx2 neon/;
add_proto qw/void vpx_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/vpx_highbd_convolve_avg sse2 avx2 neon/;
add_proto qw/void vpx_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/vpx_highbd_convolve8 neon/, "$sse2_x86_64";
add_proto qw/void vpx_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/vpx_highbd_convolve8_horiz neon/, "$sse2_x86_64";
add_proto qw/void vpx_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/vpx_highbd_convolve8_vert neon/, "$sse2_x86_64";
add_proto qw/void vpx_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/vpx_highbd_convolve8_avg neon/, "$sse2_x86_64";
add_proto qw/void vpx_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/vpx_highbd_convolve8_avg_horiz neon/, "$sse2_x86_64";
add_proto qw/void vpx_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/vpx_highbd_convolve8_avg_vert neon/, "$sse2_x86_64";
} # CONFIG_VP9_HIGHBITDEPTH
#
# Loopfilter
#
add_proto qw/void vpx_lpf_vertical_16/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_vertical_16 sse2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_vertical_16_dual/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_vertical_16_dual sse2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_vertical_8/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_vertical_8 sse2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_lpf_vertical_8_dual sse2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_vertical_4/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_vertical_4 sse2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_lpf_vertical_4_dual sse2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_horizontal_16/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_horizontal_16 sse2 avx2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_horizontal_16_dual/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_horizontal_16_dual sse2 avx2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_horizontal_8/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_horizontal_8 sse2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_lpf_horizontal_8_dual sse2 neon dspr2 msa/;
add_proto qw/void vpx_lpf_horizontal_4/, "uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh";
specialize qw/vpx_lpf_horizontal_4 sse2 neon dspr2 msa/;
add_proto qw/void vpx_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/vpx_lpf_horizontal_4_dual sse2 neon dspr2 msa/;
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vpx_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/vpx_highbd_lpf_vertical_16 sse2 neon/;
add_proto qw/void vpx_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/vpx_highbd_lpf_vertical_16_dual sse2 neon/;
add_proto qw/void vpx_highbd_lpf_vertical_8/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_vertical_8 sse2 neon/;
add_proto qw/void vpx_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/vpx_highbd_lpf_vertical_8_dual sse2 neon/;
add_proto qw/void vpx_highbd_lpf_vertical_4/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_vertical_4 sse2 neon/;
add_proto qw/void vpx_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/vpx_highbd_lpf_vertical_4_dual sse2 neon/;
add_proto qw/void vpx_highbd_lpf_horizontal_16/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_horizontal_16 sse2 neon/;
add_proto qw/void vpx_highbd_lpf_horizontal_16_dual/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_horizontal_16_dual sse2 neon/;
add_proto qw/void vpx_highbd_lpf_horizontal_8/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_horizontal_8 sse2 neon/;
add_proto qw/void vpx_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/vpx_highbd_lpf_horizontal_8_dual sse2 neon/;
add_proto qw/void vpx_highbd_lpf_horizontal_4/, "uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd";
specialize qw/vpx_highbd_lpf_horizontal_4 sse2 neon/;
add_proto qw/void vpx_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/vpx_highbd_lpf_horizontal_4_dual sse2 neon/;
} # CONFIG_VP9_HIGHBITDEPTH
#
# Encoder functions.
#
#
# Forward transform
#
if (vpx_config("CONFIG_VP9_ENCODER") eq "yes") {
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vpx_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct4x4 sse2/;
add_proto qw/void vpx_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct4x4_1 sse2/;
add_proto qw/void vpx_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct8x8 neon sse2/;
add_proto qw/void vpx_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct8x8_1 neon sse2/;
add_proto qw/void vpx_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct16x16 sse2/;
add_proto qw/void vpx_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct16x16_1 sse2/;
add_proto qw/void vpx_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32 sse2/;
add_proto qw/void vpx_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32_rd sse2/;
add_proto qw/void vpx_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32_1 sse2/;
add_proto qw/void vpx_highbd_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_highbd_fdct4x4 sse2/;
add_proto qw/void vpx_highbd_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_highbd_fdct8x8 sse2/;
add_proto qw/void vpx_highbd_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
add_proto qw/void vpx_highbd_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_highbd_fdct16x16 sse2/;
add_proto qw/void vpx_highbd_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
add_proto qw/void vpx_highbd_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_highbd_fdct32x32 sse2/;
add_proto qw/void vpx_highbd_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_highbd_fdct32x32_rd sse2/;
add_proto qw/void vpx_highbd_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
} else {
add_proto qw/void vpx_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct4x4 sse2 msa/;
add_proto qw/void vpx_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct4x4_1 sse2/;
add_proto qw/void vpx_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct8x8 sse2 neon msa/, "$ssse3_x86_64";
add_proto qw/void vpx_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct8x8_1 sse2 neon msa/;
add_proto qw/void vpx_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct16x16 sse2 msa/;
add_proto qw/void vpx_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct16x16_1 sse2 msa/;
add_proto qw/void vpx_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32 sse2 avx2 msa/;
add_proto qw/void vpx_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32_rd sse2 avx2 msa/;
add_proto qw/void vpx_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/vpx_fdct32x32_1 sse2 msa/;
} # CONFIG_VP9_HIGHBITDEPTH
} # CONFIG_VP9_ENCODER
#
# Inverse transform
if (vpx_config("CONFIG_VP9") eq "yes") {
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 vpx_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_iwht4x4_16_add sse2/;
add_proto qw/void vpx_highbd_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct4x4_1_add neon/;
add_proto qw/void vpx_highbd_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct8x8_1_add neon/;
add_proto qw/void vpx_highbd_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct16x16_1_add neon/;
add_proto qw/void vpx_highbd_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct32x32_1_add neon sse2/;
add_proto qw/void vpx_highbd_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
# Force C versions if CONFIG_EMULATE_HARDWARE is 1
if (vpx_config("CONFIG_EMULATE_HARDWARE") eq "yes") {
add_proto qw/void vpx_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_highbd_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
add_proto qw/void vpx_highbd_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
} else {
add_proto qw/void vpx_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct4x4_16_add neon sse2/;
add_proto qw/void vpx_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct4x4_1_add neon sse2/;
add_proto qw/void vpx_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_64_add neon sse2 ssse3/;
add_proto qw/void vpx_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_12_add neon sse2 ssse3/;
add_proto qw/void vpx_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_1_add neon sse2/;
add_proto qw/void vpx_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_256_add neon sse2/;
add_proto qw/void vpx_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_38_add neon sse2/;
$vpx_idct16x16_38_add_sse2=vpx_idct16x16_256_add_sse2;
add_proto qw/void vpx_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_10_add neon sse2/;
add_proto qw/void vpx_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_1_add neon sse2/;
add_proto qw/void vpx_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_1024_add neon sse2 ssse3/;
add_proto qw/void vpx_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_135_add neon sse2 ssse3/;
# Need to add 135 eob idct32x32 implementations.
$vpx_idct32x32_135_add_sse2=vpx_idct32x32_1024_add_sse2;
add_proto qw/void vpx_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_34_add neon sse2 ssse3/;
add_proto qw/void vpx_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_1_add neon sse2/;
add_proto qw/void vpx_highbd_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct4x4_16_add neon sse2/;
add_proto qw/void vpx_highbd_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct8x8_64_add neon sse2/;
add_proto qw/void vpx_highbd_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct8x8_12_add neon sse2/;
add_proto qw/void vpx_highbd_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct16x16_256_add neon sse2/;
add_proto qw/void vpx_highbd_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct16x16_38_add neon sse2/;
$vpx_highbd_idct16x16_38_add_sse2=vpx_highbd_idct16x16_256_add_sse2;
add_proto qw/void vpx_highbd_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct16x16_10_add neon sse2/;
add_proto qw/void vpx_highbd_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct32x32_1024_add neon/;
add_proto qw/void vpx_highbd_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct32x32_135_add neon/;
add_proto qw/void vpx_highbd_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride, int bd";
specialize qw/vpx_highbd_idct32x32_34_add neon/;
} # CONFIG_EMULATE_HARDWARE
} else {
# Force C versions if CONFIG_EMULATE_HARDWARE is 1
if (vpx_config("CONFIG_EMULATE_HARDWARE") eq "yes") {
add_proto qw/void vpx_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
add_proto qw/void vpx_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
} else {
add_proto qw/void vpx_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct4x4_1_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct4x4_16_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_1_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_64_add sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_idct8x8_12_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct8x8_12_add sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_1_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct16x16_256_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_256_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct16x16_38_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_38_add sse2 neon dspr2 msa/;
$vpx_idct16x16_38_add_sse2=vpx_idct16x16_256_add_sse2;
$vpx_idct16x16_38_add_dspr2=vpx_idct16x16_256_add_dspr2;
$vpx_idct16x16_38_add_msa=vpx_idct16x16_256_add_msa;
add_proto qw/void vpx_idct16x16_10_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct16x16_10_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_1024_add sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_idct32x32_135_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_135_add sse2 ssse3 neon dspr2 msa/;
$vpx_idct32x32_135_add_sse2=vpx_idct32x32_1024_add_sse2;
$vpx_idct32x32_135_add_dspr2=vpx_idct32x32_1024_add_dspr2;
$vpx_idct32x32_135_add_msa=vpx_idct32x32_1024_add_msa;
add_proto qw/void vpx_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_34_add sse2 ssse3 neon dspr2 msa/;
add_proto qw/void vpx_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_idct32x32_1_add sse2 neon dspr2 msa/;
add_proto qw/void vpx_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_iwht4x4_1_add msa/;
add_proto qw/void vpx_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int stride";
specialize qw/vpx_iwht4x4_16_add msa sse2/;
} # CONFIG_EMULATE_HARDWARE
} # CONFIG_VP9_HIGHBITDEPTH
} # CONFIG_VP9
#
# Quantization
#
if (vpx_config("CONFIG_VP9_ENCODER") eq "yes") {
add_proto qw/void vpx_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/vpx_quantize_b sse2/, "$ssse3_x86_64", "$avx_x86_64";
add_proto qw/void vpx_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/vpx_quantize_b_32x32/, "$ssse3_x86_64", "$avx_x86_64";
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vpx_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/vpx_highbd_quantize_b sse2/;
add_proto qw/void vpx_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/vpx_highbd_quantize_b_32x32 sse2/;
} # CONFIG_VP9_HIGHBITDEPTH
} # CONFIG_VP9_ENCODER
if (vpx_config("CONFIG_ENCODERS") eq "yes") {
#
# Block subtraction
#
add_proto qw/void vpx_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/vpx_subtract_block neon msa sse2/;
#
# Single block SAD
#
add_proto qw/unsigned int vpx_sad64x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad64x64 avx2 neon msa sse2/;
add_proto qw/unsigned int vpx_sad64x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad64x32 avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad32x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad32x64 avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad32x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad32x32 avx2 neon msa sse2/;
add_proto qw/unsigned int vpx_sad32x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad32x16 avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad16x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad16x32 msa sse2/;
add_proto qw/unsigned int vpx_sad16x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad16x16 neon msa sse2/;
add_proto qw/unsigned int vpx_sad16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad16x8 neon msa sse2/;
add_proto qw/unsigned int vpx_sad8x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad8x16 neon msa sse2/;
add_proto qw/unsigned int vpx_sad8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad8x8 neon msa sse2/;
add_proto qw/unsigned int vpx_sad8x4/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad8x4 msa sse2/;
add_proto qw/unsigned int vpx_sad4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad4x8 msa sse2/;
add_proto qw/unsigned int vpx_sad4x4/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_sad4x4 neon msa sse2/;
#
# Avg
#
if (vpx_config("CONFIG_VP9_ENCODER") eq "yes") {
add_proto qw/unsigned int vpx_avg_8x8/, "const uint8_t *, int p";
specialize qw/vpx_avg_8x8 sse2 neon msa/;
add_proto qw/unsigned int vpx_avg_4x4/, "const uint8_t *, int p";
specialize qw/vpx_avg_4x4 sse2 neon msa/;
add_proto qw/void vpx_minmax_8x8/, "const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max";
specialize qw/vpx_minmax_8x8 sse2 neon msa/;
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vpx_hadamard_8x8/, "const int16_t *src_diff, int src_stride, tran_low_t *coeff";
specialize qw/vpx_hadamard_8x8 sse2 neon vsx/, "$ssse3_x86_64";
add_proto qw/void vpx_hadamard_16x16/, "const int16_t *src_diff, int src_stride, tran_low_t *coeff";
specialize qw/vpx_hadamard_16x16 sse2 neon vsx/;
add_proto qw/int vpx_satd/, "const tran_low_t *coeff, int length";
specialize qw/vpx_satd sse2 neon/;
} else {
add_proto qw/void vpx_hadamard_8x8/, "const int16_t *src_diff, int src_stride, int16_t *coeff";
specialize qw/vpx_hadamard_8x8 sse2 neon msa vsx/, "$ssse3_x86_64";
add_proto qw/void vpx_hadamard_16x16/, "const int16_t *src_diff, int src_stride, int16_t *coeff";
specialize qw/vpx_hadamard_16x16 sse2 neon msa vsx/;
add_proto qw/int vpx_satd/, "const int16_t *coeff, int length";
specialize qw/vpx_satd sse2 neon msa/;
}
add_proto qw/void vpx_int_pro_row/, "int16_t *hbuf, const uint8_t *ref, const int ref_stride, const int height";
specialize qw/vpx_int_pro_row sse2 neon msa/;
add_proto qw/int16_t vpx_int_pro_col/, "const uint8_t *ref, const int width";
specialize qw/vpx_int_pro_col sse2 neon msa/;
add_proto qw/int vpx_vector_var/, "const int16_t *ref, const int16_t *src, const int bwl";
specialize qw/vpx_vector_var neon sse2 msa/;
} # CONFIG_VP9_ENCODER
add_proto qw/unsigned int vpx_sad64x64_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad64x64_avg avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad64x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad64x32_avg avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad32x64_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad32x64_avg avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad32x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad32x32_avg avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad32x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad32x16_avg avx2 msa sse2/;
add_proto qw/unsigned int vpx_sad16x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad16x32_avg msa sse2/;
add_proto qw/unsigned int vpx_sad16x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad16x16_avg msa sse2/;
add_proto qw/unsigned int vpx_sad16x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad16x8_avg msa sse2/;
add_proto qw/unsigned int vpx_sad8x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad8x16_avg msa sse2/;
add_proto qw/unsigned int vpx_sad8x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad8x8_avg msa sse2/;
add_proto qw/unsigned int vpx_sad8x4_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad8x4_avg msa sse2/;
add_proto qw/unsigned int vpx_sad4x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad4x8_avg msa sse2/;
add_proto qw/unsigned int vpx_sad4x4_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_sad4x4_avg msa sse2/;
#
# Multi-block SAD, comparing a reference to N blocks 1 pixel apart horizontally
#
# Blocks of 3
add_proto qw/void vpx_sad64x64x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad64x64x3 msa/;
add_proto qw/void vpx_sad32x32x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad32x32x3 msa/;
add_proto qw/void vpx_sad16x16x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x16x3 sse3 ssse3 msa/;
add_proto qw/void vpx_sad16x8x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x8x3 sse3 ssse3 msa/;
add_proto qw/void vpx_sad8x16x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x16x3 sse3 msa/;
add_proto qw/void vpx_sad8x8x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x8x3 sse3 msa/;
add_proto qw/void vpx_sad4x4x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad4x4x3 sse3 msa/;
# Blocks of 8
add_proto qw/void vpx_sad64x64x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad64x64x8 msa/;
add_proto qw/void vpx_sad32x32x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad32x32x8 msa/;
add_proto qw/void vpx_sad16x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x16x8 sse4_1 msa/;
add_proto qw/void vpx_sad16x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x8x8 sse4_1 msa/;
add_proto qw/void vpx_sad8x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x16x8 sse4_1 msa/;
add_proto qw/void vpx_sad8x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x8x8 sse4_1 msa/;
add_proto qw/void vpx_sad8x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x4x8 msa/;
add_proto qw/void vpx_sad4x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad4x8x8 msa/;
add_proto qw/void vpx_sad4x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad4x4x8 sse4_1 msa/;
#
# Multi-block SAD, comparing a reference to N independent blocks
#
add_proto qw/void vpx_sad64x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad64x64x4d avx2 neon msa sse2/;
add_proto qw/void vpx_sad64x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad64x32x4d msa sse2/;
add_proto qw/void vpx_sad32x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad32x64x4d msa sse2/;
add_proto qw/void vpx_sad32x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad32x32x4d avx2 neon msa sse2/;
add_proto qw/void vpx_sad32x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad32x16x4d msa sse2/;
add_proto qw/void vpx_sad16x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x32x4d msa sse2/;
add_proto qw/void vpx_sad16x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x16x4d neon msa sse2/;
add_proto qw/void vpx_sad16x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad16x8x4d msa sse2/;
add_proto qw/void vpx_sad8x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x16x4d msa sse2/;
add_proto qw/void vpx_sad8x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x8x4d msa sse2/;
add_proto qw/void vpx_sad8x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad8x4x4d msa sse2/;
add_proto qw/void vpx_sad4x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad4x8x4d msa sse2/;
add_proto qw/void vpx_sad4x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_sad4x4x4d msa sse2/;
add_proto qw/uint64_t vpx_sum_squares_2d_i16/, "const int16_t *src, int stride, int size";
specialize qw/vpx_sum_squares_2d_i16 sse2 msa/;
#
# Structured Similarity (SSIM)
#
if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") {
add_proto qw/void vpx_ssim_parms_8x8/, "const uint8_t *s, int sp, const uint8_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/vpx_ssim_parms_8x8/, "$sse2_x86_64";
add_proto qw/void vpx_ssim_parms_16x16/, "const uint8_t *s, int sp, const uint8_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/vpx_ssim_parms_16x16/, "$sse2_x86_64";
}
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
#
# Block subtraction
#
add_proto qw/void vpx_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";
#
# Single block SAD
#
add_proto qw/unsigned int vpx_highbd_sad64x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad64x64 sse2/;
add_proto qw/unsigned int vpx_highbd_sad64x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad64x32 sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad32x64 sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad32x32 sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad32x16 sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad16x32 sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad16x8 sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad8x16 sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x4/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
specialize qw/vpx_highbd_sad8x4 sse2/;
add_proto qw/unsigned int vpx_highbd_sad4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
add_proto qw/unsigned int vpx_highbd_sad4x4/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride";
#
# Avg
#
add_proto qw/unsigned int vpx_highbd_avg_8x8/, "const uint8_t *, int p";
add_proto qw/unsigned int vpx_highbd_avg_4x4/, "const uint8_t *, int p";
add_proto qw/void vpx_highbd_minmax_8x8/, "const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max";
add_proto qw/unsigned int vpx_highbd_sad64x64_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad64x64_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad64x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad64x32_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x64_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad32x64_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad32x32_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad32x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad32x16_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x32_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad16x32_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad16x16_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad16x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad16x8_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad8x16_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad8x8_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad8x4_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
specialize qw/vpx_highbd_sad8x4_avg sse2/;
add_proto qw/unsigned int vpx_highbd_sad4x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
add_proto qw/unsigned int vpx_highbd_sad4x4_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
#
# Multi-block SAD, comparing a reference to N blocks 1 pixel apart horizontally
#
# Blocks of 3
add_proto qw/void vpx_highbd_sad64x64x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad32x32x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad16x16x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad16x8x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad8x16x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad8x8x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad4x4x3/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
# Blocks of 8
add_proto qw/void vpx_highbd_sad64x64x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad32x32x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad16x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad16x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad8x16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad8x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad8x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad4x8x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
add_proto qw/void vpx_highbd_sad4x4x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array";
#
# Multi-block SAD, comparing a reference to N independent blocks
#
add_proto qw/void vpx_highbd_sad64x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad64x64x4d sse2/;
add_proto qw/void vpx_highbd_sad64x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad64x32x4d sse2/;
add_proto qw/void vpx_highbd_sad32x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad32x64x4d sse2/;
add_proto qw/void vpx_highbd_sad32x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad32x32x4d sse2/;
add_proto qw/void vpx_highbd_sad32x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad32x16x4d sse2/;
add_proto qw/void vpx_highbd_sad16x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad16x32x4d sse2/;
add_proto qw/void vpx_highbd_sad16x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad16x16x4d sse2/;
add_proto qw/void vpx_highbd_sad16x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad16x8x4d sse2/;
add_proto qw/void vpx_highbd_sad8x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad8x16x4d sse2/;
add_proto qw/void vpx_highbd_sad8x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad8x8x4d sse2/;
add_proto qw/void vpx_highbd_sad8x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad8x4x4d sse2/;
add_proto qw/void vpx_highbd_sad4x8x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad4x8x4d sse2/;
add_proto qw/void vpx_highbd_sad4x4x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, uint32_t *sad_array";
specialize qw/vpx_highbd_sad4x4x4d sse2/;
#
# Structured Similarity (SSIM)
#
if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") {
add_proto qw/void vpx_highbd_ssim_parms_8x8/, "const uint16_t *s, int sp, const 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";
}
} # CONFIG_VP9_HIGHBITDEPTH
} # CONFIG_ENCODERS
if (vpx_config("CONFIG_ENCODERS") eq "yes" || vpx_config("CONFIG_POSTPROC") eq "yes" || vpx_config("CONFIG_VP9_POSTPROC") eq "yes") {
#
# Variance
#
add_proto qw/unsigned int vpx_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance64x64 sse2 avx2 neon msa/;
add_proto qw/unsigned int vpx_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance64x32 sse2 avx2 neon msa/;
add_proto qw/unsigned int vpx_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance32x64 sse2 neon msa/;
add_proto qw/unsigned int vpx_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance32x32 sse2 avx2 neon msa/;
add_proto qw/unsigned int vpx_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance32x16 sse2 avx2 msa/;
add_proto qw/unsigned int vpx_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance16x32 sse2 msa/;
add_proto qw/unsigned int vpx_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance16x16 sse2 avx2 neon msa/;
add_proto qw/unsigned int vpx_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance16x8 sse2 neon msa/;
add_proto qw/unsigned int vpx_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance8x16 sse2 neon msa/;
add_proto qw/unsigned int vpx_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance8x8 sse2 neon msa/;
add_proto qw/unsigned int vpx_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance8x4 sse2 msa/;
add_proto qw/unsigned int vpx_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance4x8 sse2 msa/;
add_proto qw/unsigned int vpx_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_variance4x4 sse2 msa/;
#
# Specialty Variance
#
add_proto qw/void vpx_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
specialize qw/vpx_get16x16var sse2 avx2 neon msa/;
add_proto qw/void vpx_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
specialize qw/vpx_get8x8var sse2 neon msa/;
add_proto qw/unsigned int vpx_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_mse16x16 sse2 avx2 neon msa/;
add_proto qw/unsigned int vpx_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_mse16x8 sse2 msa/;
add_proto qw/unsigned int vpx_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_mse8x16 sse2 msa/;
add_proto qw/unsigned int vpx_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_mse8x8 sse2 msa/;
add_proto qw/unsigned int vpx_get_mb_ss/, "const int16_t *";
specialize qw/vpx_get_mb_ss sse2 msa/;
add_proto qw/unsigned int vpx_get4x4sse_cs/, "const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride";
specialize qw/vpx_get4x4sse_cs neon msa/;
add_proto qw/void vpx_comp_avg_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride";
specialize qw/vpx_comp_avg_pred sse2/;
#
# Subpixel Variance
#
add_proto qw/uint32_t vpx_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance64x64 avx2 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance64x32 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance32x64 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance32x32 avx2 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance32x16 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance16x32 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance16x16 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance16x8 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance8x16 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance8x8 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance8x4 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance4x8 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_sub_pixel_variance4x4 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance64x64 avx2 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance64x32 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance32x64 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance32x32 avx2 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance32x16 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance16x32 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance16x16 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance16x8 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance8x16 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance8x8 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance8x4 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance4x8 msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance4x4 msa sse2 ssse3/;
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/unsigned int vpx_highbd_12_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance64x64 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance64x32 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance32x64 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance32x32 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance32x16 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance16x32 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance16x8 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance8x16 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_variance8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_12_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_12_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_12_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_10_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance64x64 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance64x32 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance32x64 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance32x32 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance32x16 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance16x32 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance16x8 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance8x16 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_variance8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_10_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_10_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_10_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_8_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance64x64 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance64x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance64x32 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance32x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance32x64 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance32x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance32x32 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance32x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance32x16 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance16x32/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance16x32 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance16x8 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance8x16 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_variance8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_8_variance8x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_8_variance4x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_8_variance4x4/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";
add_proto qw/void vpx_highbd_8_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/void vpx_highbd_8_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/void vpx_highbd_10_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/void vpx_highbd_10_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/void vpx_highbd_12_get16x16var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/void vpx_highbd_12_get8x8var/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum";
add_proto qw/unsigned int vpx_highbd_8_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_mse16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_8_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_8_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_8_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_8_mse8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_10_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_mse16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_10_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_10_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_10_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_10_mse8x8 sse2/;
add_proto qw/unsigned int vpx_highbd_12_mse16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_mse16x16 sse2/;
add_proto qw/unsigned int vpx_highbd_12_mse16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_12_mse8x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
add_proto qw/unsigned int vpx_highbd_12_mse8x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse";
specialize qw/vpx_highbd_12_mse8x8 sse2/;
add_proto qw/void vpx_highbd_comp_avg_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride";
#
# Subpixel Variance
#
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance64x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance64x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance32x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance32x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance32x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance16x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance16x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance16x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance8x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance8x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_12_sub_pixel_variance8x4 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
add_proto qw/uint32_t vpx_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, uint32_t *sse";
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance64x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance64x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance32x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance32x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance32x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance16x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance16x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance16x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance8x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance8x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
specialize qw/vpx_highbd_10_sub_pixel_variance8x4 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse";
add_proto qw/uint32_t vpx_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, uint32_t *sse";
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance64x64 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance64x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance32x64 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance32x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance32x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance16x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance16x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance16x8 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance8x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance8x8 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
specialize qw/vpx_highbd_8_sub_pixel_variance8x4 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance64x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance64x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance32x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance32x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance32x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance16x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance16x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance16x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance8x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance8x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_12_sub_pixel_avg_variance8x4 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance64x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance64x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance32x64 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance32x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance32x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance16x32 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance16x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance16x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance8x16 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance8x8 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_10_sub_pixel_avg_variance8x4 sse2/;
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
add_proto qw/uint32_t vpx_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, uint32_t *sse, const uint8_t *second_pred";
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance64x64 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance64x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance64x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance32x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance32x64 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance32x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance32x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance32x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance32x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance16x32/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance16x32 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance16x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance16x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance16x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance16x8 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance8x16/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance8x16 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance8x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance8x8 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance8x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_highbd_8_sub_pixel_avg_variance8x4 sse2/;
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
add_proto qw/uint32_t vpx_highbd_8_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
} # CONFIG_VP9_HIGHBITDEPTH
#
# Post Processing
#
if (vpx_config("CONFIG_POSTPROC") eq "yes" || vpx_config("CONFIG_VP9_POSTPROC") eq "yes") {
add_proto qw/void vpx_plane_add_noise/, "uint8_t *start, const int8_t *noise, int blackclamp, int whiteclamp, int width, int height, int pitch";
specialize qw/vpx_plane_add_noise sse2 msa/;
add_proto qw/void vpx_mbpost_proc_down/, "unsigned char *dst, int pitch, int rows, int cols,int flimit";
specialize qw/vpx_mbpost_proc_down sse2 neon msa/;
add_proto qw/void vpx_mbpost_proc_across_ip/, "unsigned char *dst, int pitch, int rows, int cols,int flimit";
specialize qw/vpx_mbpost_proc_across_ip sse2 neon msa/;
add_proto qw/void vpx_post_proc_down_and_across_mb_row/, "unsigned char *src, unsigned char *dst, int src_pitch, int dst_pitch, int cols, unsigned char *flimits, int size";
specialize qw/vpx_post_proc_down_and_across_mb_row sse2 neon msa/;
}
} # CONFIG_ENCODERS || CONFIG_POSTPROC || CONFIG_VP9_POSTPROC
1;
| 65.936687 | 365 | 0.793385 |
ed40500d32da28dbe675bf903ccb33d675143dff | 1,598 | pm | Perl | auto-lib/Paws/CloudFront/CachePolicySummary.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/CloudFront/CachePolicySummary.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/CloudFront/CachePolicySummary.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
]
| 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z | # Generated by default/object.tt
package Paws::CloudFront::CachePolicySummary;
use Moose;
has CachePolicy => (is => 'ro', isa => 'Paws::CloudFront::CachePolicy', required => 1);
has Type => (is => 'ro', isa => 'Str', required => 1);
1;
### main pod documentation begin ###
=head1 NAME
Paws::CloudFront::CachePolicySummary
=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::CloudFront::CachePolicySummary object:
$service_obj->Method(Att1 => { CachePolicy => $value, ..., Type => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::CloudFront::CachePolicySummary object:
$result = $service_obj->Method(...);
$result->Att1->CachePolicy
=head1 DESCRIPTION
Contains a cache policy.
=head1 ATTRIBUTES
=head2 B<REQUIRED> CachePolicy => L<Paws::CloudFront::CachePolicy>
The cache policy.
=head2 B<REQUIRED> Type => Str
The type of cache policy, either C<managed> (created by AWS) or
C<custom> (created in this AWS account).
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::CloudFront>
=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
| 24.212121 | 107 | 0.727159 |
73fff19085317d9b5650caae812fa6f0732437f8 | 5,906 | pm | Perl | core/server/OpenXPKI/Server/Workflow/Activity/SCEPv2/PersistRequest.pm | mrscotty/openxpki | e02e08fba744e741eb31c733fbbe477dde2cca1d | [
"Apache-2.0"
]
| null | null | null | core/server/OpenXPKI/Server/Workflow/Activity/SCEPv2/PersistRequest.pm | mrscotty/openxpki | e02e08fba744e741eb31c733fbbe477dde2cca1d | [
"Apache-2.0"
]
| null | null | null | core/server/OpenXPKI/Server/Workflow/Activity/SCEPv2/PersistRequest.pm | mrscotty/openxpki | e02e08fba744e741eb31c733fbbe477dde2cca1d | [
"Apache-2.0"
]
| null | null | null | # OpenXPKI::Server::Workflow::Activity::CSR:PersistRequest:
# Written by Alexander Klink for the OpenXPKI project 2006
# Copyright (c) 2006 by The OpenXPKI Project
package OpenXPKI::Server::Workflow::Activity::SCEPv2::PersistRequest;
use strict;
use base qw( OpenXPKI::Server::Workflow::Activity );
use OpenXPKI::Server::Context qw( CTX );
use OpenXPKI::Exception;
use OpenXPKI::Debug;
use OpenXPKI::Serialization::Simple;
use Data::Dumper;
sub execute
{
my $self = shift;
my $workflow = shift;
my $context = $workflow->context();
my $pki_realm = CTX('session')->get_pki_realm();
my $serializer = OpenXPKI::Serialization::Simple->new();
my $dbi = CTX('dbi_backend');
my $csr_serial = $dbi->get_new_serial(
TABLE => 'CSR',
);
my $type = $context->param('csr_type');
if (! defined $type) {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_SERVER_WORKFLOW_ACTIVITY_CSR_PERSISTREQUEST_CSR_TYPE_UNDEFINED',
);
}
my $profile = $context->param('cert_profile');
if (! defined $profile) {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_SERVER_WORKFLOW_ACTIVITY_CSR_PERSISTREQUEST_CSR_PROFILE_UNDEFINED',
);
}
my $subject = $context->param('cert_subject');
if (! defined $subject) {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_SERVER_WORKFLOW_ACTIVITY_CSR_PERSISTREQUEST_CSR_SUBJECT_UNDEFINED',
);
}
my $data;
if ($type eq 'spkac') {
$data = $context->param('spkac');
}
elsif ($type eq 'pkcs10') {
$data = $context->param('pkcs10');
}
else {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_ACTIVITY_CSR_INSERTREQUEST_UNSUPPORTED_CSR_TYPE',
params => {
TYPE => $type,
},
);
}
# TODO: LOA (currently NULL)
$dbi->insert(
TABLE => 'CSR',
HASH => {
'PKI_REALM' => $pki_realm,
'CSR_SERIAL' => $csr_serial,
'TYPE' => $type,
'DATA' => $data,
'PROFILE' => $profile,
'SUBJECT' => $subject,
'ROLE' => '',
},
);
my $source_ref = $serializer->deserialize($context->param('sources'));
if (! defined $source_ref) {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_SERVER_WF_ACTIVITY_CSR_PERSISTREQUEST_SOURCES_UNDEFINED',
);
}
my $san_serialized = $context->param('cert_subject_alt_name');
if($san_serialized) {
my $subj_alt_names = $serializer->deserialize($san_serialized);
my @subj_alt_names = @{$subj_alt_names};
##! 16: '$subj_alt_names: ' . Dumper($subj_alt_names)
##! 16: '@subj_alt_names: ' . Dumper(\@subj_alt_names)
my $san_source = $source_ref->{'cert_subject_alt_name_parts'};
$san_source = $source_ref->{'cert_subject_alt_name'} unless($san_source);
if (! defined $san_source) {
OpenXPKI::Exception->throw(
message => 'I18N_OPENXPKI_SERVER_WF_ACTIVITY_CSR_PERSISTREQUEST_SUBJECT_ALT_NAME_SOURCE_UNDEFINED',
);
}
foreach my $san (@subj_alt_names) {
##! 64: 'san: ' . $san
my $attrib_serial = $dbi->get_new_serial(
TABLE => 'CSR_ATTRIBUTES',
);
$dbi->insert(
TABLE => 'CSR_ATTRIBUTES',
HASH => {
'ATTRIBUTE_SERIAL' => $attrib_serial,
'PKI_REALM' => $pki_realm,
'CSR_SERIAL' => $csr_serial,
'ATTRIBUTE_KEY' => 'subject_alt_name',
'ATTRIBUTE_VALUE' => $serializer->serialize($san),
'ATTRIBUTE_SOURCE' => $san_source,
},
);
}
} # end SAN
foreach my $validity_param (qw( notbefore notafter )) {
if (defined $context->param($validity_param)) {
my $source = $source_ref->{$validity_param};
my $attrib_serial = $dbi->get_new_serial(
TABLE => 'CSR_ATTRIBUTES',
);
$dbi->insert(
TABLE => 'CSR_ATTRIBUTES',
HASH => {
'ATTRIBUTE_SERIAL' => $attrib_serial,
'PKI_REALM' => $pki_realm,
'CSR_SERIAL' => $csr_serial,
'ATTRIBUTE_KEY' => $validity_param,
'ATTRIBUTE_VALUE' => $context->param($validity_param),
'ATTRIBUTE_SOURCE' => $source,
},
);
}
}
# process additional information (user configurable in profile)
if (defined $context->param('cert_info')) {
my $cert_info = $serializer->deserialize($context->param('cert_info'));
##! 16: 'additional certificate information: ' . Dumper $cert_info
foreach my $custom_key (keys %{$cert_info}) {
my $attrib_serial = $dbi->get_new_serial(
TABLE => 'CSR_ATTRIBUTES',
);
$dbi->insert(
TABLE => 'CSR_ATTRIBUTES',
HASH => {
'ATTRIBUTE_SERIAL' => $attrib_serial,
'PKI_REALM' => $pki_realm,
'CSR_SERIAL' => $csr_serial,
'ATTRIBUTE_KEY' => 'custom_' . $custom_key,
'ATTRIBUTE_VALUE' => $cert_info->{$custom_key},
'ATTRIBUTE_SOURCE' => $source_ref->{'cert_info'},
},
);
}
}
$dbi->commit();
$context->param('csr_serial' => $csr_serial);
}
1;
__END__
=head1 Name
OpenXPKI::Server::Workflow::Activity::CSR::PersistRequest
=head1 Description
persists the Certificate Signing Request into the database, so that
it can then be used by the certificate issuance workflow.
| 32.994413 | 115 | 0.550965 |
ed497f19981d69ba3cd5ce89a3f565962ef57d4a | 1,547 | pm | Perl | lib/VIC/PIC/P16F648A.pm | gitpan/VIC | e4129f70186638cc02956959e9446435b6000142 | [
"Artistic-1.0"
]
| null | null | null | lib/VIC/PIC/P16F648A.pm | gitpan/VIC | e4129f70186638cc02956959e9446435b6000142 | [
"Artistic-1.0"
]
| null | null | null | lib/VIC/PIC/P16F648A.pm | gitpan/VIC | e4129f70186638cc02956959e9446435b6000142 | [
"Artistic-1.0"
]
| null | null | null | package VIC::PIC::P16F648A;
use strict;
use warnings;
our $VERSION = '0.23';
$VERSION = eval $VERSION;
use Moo;
extends 'VIC::PIC::P16F627A';
# role CodeGen
has type => (is => 'ro', default => 'p16f648a');
has include => (is => 'ro', default => 'p16f648a.inc');
has memory => (is => 'ro', default => sub {
{
flash => 4096, # words
SRAM => 256,
EEPROM => 256,
}
});
has address => (is => 'ro', default => sub {
{
isr => [ 0x0004 ],
reset => [ 0x0000 ],
range => [ 0x0000, 0x0FFF ],
}
});
has banks => (is => 'ro', default => sub {
{
count => 4,
size => 0x80,
gpr => {
0 => [ 0x020, 0x07F],
1 => [ 0x0A0, 0x0EF],
2 => [ 0x120, 0x16F],
},
# remapping of these addresses automatically done by chip
common => [0x070, 0x07F],
remap => [
[0x0F0, 0x0FF],
[0x170, 0x17F],
[0x1F0, 0x1FF],
],
}
});
1;
__END__
=encoding utf8
=head1 NAME
VIC::PIC::P16F648A
=head1 SYNOPSIS
A class that describes the code to be generated for each specific
microcontroller that maps the VIC syntax back into assembly. This is the
back-end to VIC's front-end.
=head1 DESCRIPTION
INTERNAL CLASS.
=head1 AUTHOR
Vikas N Kumar <vikas@cpan.org>
=head1 COPYRIGHT
Copyright (c) 2014. Vikas N Kumar
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
=cut
| 19.582278 | 72 | 0.564318 |
ed4e9afdc39e0aa6650e57f044ff9f8f2d700f44 | 88 | t | Perl | t/basic.t | coppit/module-install-getprogramlocations | 58b66455d6bb2fc9d8409be812189fd1a41fd6c7 | [
"FSFAP"
]
| null | null | null | t/basic.t | coppit/module-install-getprogramlocations | 58b66455d6bb2fc9d8409be812189fd1a41fd6c7 | [
"FSFAP"
]
| null | null | null | t/basic.t | coppit/module-install-getprogramlocations | 58b66455d6bb2fc9d8409be812189fd1a41fd6c7 | [
"FSFAP"
]
| null | null | null | use Test::More tests => 1;
BEGIN { use_ok( 'Module::Install::GetProgramLocations' ); }
| 22 | 59 | 0.681818 |
ed0026433cbfa64021c2184150315d985643fd16 | 2,269 | t | Perl | t/regression/image49.t | lcorbasson/excel-writer-xlsx | c8f60933dffdffd8a4a65360a88a4e206310916a | [
"Artistic-1.0-Perl"
]
| 1 | 2020-08-18T17:23:15.000Z | 2020-08-18T17:23:15.000Z | t/regression/image49.t | lcorbasson/excel-writer-xlsx | c8f60933dffdffd8a4a65360a88a4e206310916a | [
"Artistic-1.0-Perl"
]
| null | null | null | t/regression/image49.t | lcorbasson/excel-writer-xlsx | c8f60933dffdffd8a4a65360a88a4e206310916a | [
"Artistic-1.0-Perl"
]
| null | null | null | ###############################################################################
#
# Tests the output of Excel::Writer::XLSX against Excel generated files.
#
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org
#
use lib 't/lib';
use TestFunctions qw(_compare_xlsx_files _is_deep_diff);
use strict;
use warnings;
use Test::More tests => 1;
###############################################################################
#
# Tests setup.
#
my $filename = 'image49.xlsx';
my $dir = 't/regression/';
my $got_filename = $dir . "ewx_$filename";
my $exp_filename = $dir . 'xlsx_files/' . $filename;
my $ignore_members = [];
my $ignore_elements = {};
###############################################################################
#
# Test the creation of a simple Excel::Writer::XLSX file with image(s).
#
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet1 = $workbook->add_worksheet();
my $worksheet2 = $workbook->add_worksheet();
my $worksheet3 = $workbook->add_worksheet();
$worksheet1->insert_image( 'A1', $dir . 'images/blue.png' );
$worksheet1->insert_image( 'B3', $dir . 'images/red.jpg' );
$worksheet1->insert_image( 'D5', $dir . 'images/yellow.jpg' );
$worksheet1->insert_image( 'F9', $dir . 'images/grey.png' );
$worksheet2->insert_image( 'A1', $dir . 'images/blue.png' );
$worksheet2->insert_image( 'B3', $dir . 'images/red.jpg' );
$worksheet2->insert_image( 'D5', $dir . 'images/yellow.jpg' );
$worksheet2->insert_image( 'F9', $dir . 'images/grey.png' );
$worksheet3->insert_image( 'A1', $dir . 'images/blue.png' );
$worksheet3->insert_image( 'B3', $dir . 'images/red.jpg' );
$worksheet3->insert_image( 'D5', $dir . 'images/yellow.jpg' );
$worksheet3->insert_image( 'F9', $dir . 'images/grey.png' );
$workbook->close();
###############################################################################
#
# Compare the generated and existing Excel files.
#
my ( $got, $expected, $caption ) = _compare_xlsx_files(
$got_filename,
$exp_filename,
$ignore_members,
$ignore_elements,
);
_is_deep_diff( $got, $expected, $caption );
###############################################################################
#
# Cleanup.
#
unlink $got_filename;
__END__
| 27.337349 | 79 | 0.548259 |
ed4d5696d84d01fc452b809254d63ea7b63420e4 | 64,621 | t | Perl | t/perl/lib/proxy_constant_subs.t | moznion/p5-Compiler-Lexer | 7ccc1b90b6b557ad12ceff947efdfdc050aa623c | [
"Artistic-1.0"
]
| null | null | null | t/perl/lib/proxy_constant_subs.t | moznion/p5-Compiler-Lexer | 7ccc1b90b6b557ad12ceff947efdfdc050aa623c | [
"Artistic-1.0"
]
| null | null | null | t/perl/lib/proxy_constant_subs.t | moznion/p5-Compiler-Lexer | 7ccc1b90b6b557ad12ceff947efdfdc050aa623c | [
"Artistic-1.0"
]
| null | null | null | use strict;
use warnings;
use Test::More;
BEGIN {
use_ok('Compiler::Lexer');
}
my $script =<<'__SCRIPT__';
my @symbols;
BEGIN {
require './test.pl';
skip_all_without_dynamic_extension($_) foreach qw(B Fcntl);
# S_IFMT is a real subroutine, and acts as control
# SEEK_SET is a proxy constant subroutine.
@symbols = qw(S_IFMT SEEK_SET);
}
use strict;
use warnings;
plan(4 * @symbols);
use B qw(svref_2object GVf_IMPORTED_CV);
use Fcntl @symbols;
# GVf_IMPORTED_CV should not be set on the original, but should be set on the
# imported GV.
foreach my $symbol (@symbols) {
my ($ps, $ms);
{
no strict 'refs';
$ps = svref_2object(\*{"Fcntl::$symbol"});
$ms = svref_2object(\*{"::$symbol"});
}
object_ok($ps, 'B::GV');
is($ps->GvFLAGS() & GVf_IMPORTED_CV, 0,
"GVf_IMPORTED_CV not set on original");
object_ok($ms, 'B::GV');
is($ms->GvFLAGS() & GVf_IMPORTED_CV, GVf_IMPORTED_CV,
"GVf_IMPORTED_CV set on imported GV");
}
__SCRIPT__
subtest 'tokenize' => sub {
my $tokens = Compiler::Lexer->new('')->tokenize($script);
is_deeply($tokens, [
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'VarDecl',
'data' => 'my',
'type' => Compiler::Lexer::TokenType::T_VarDecl,
'line' => 1
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LocalArrayVar',
'data' => '@symbols',
'type' => Compiler::Lexer::TokenType::T_LocalArrayVar,
'line' => 1
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 1
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_ModWord,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ModWord',
'data' => 'BEGIN',
'type' => Compiler::Lexer::TokenType::T_ModWord,
'line' => 2
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftBrace',
'data' => '{',
'type' => Compiler::Lexer::TokenType::T_LeftBrace,
'line' => 2
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RequireDecl',
'data' => 'require',
'type' => Compiler::Lexer::TokenType::T_RequireDecl,
'line' => 3
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RawString',
'data' => './test.pl',
'type' => Compiler::Lexer::TokenType::T_RawString,
'line' => 3
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 3
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'skip_all_without_dynamic_extension',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SpecificValue',
'data' => '$_',
'type' => Compiler::Lexer::TokenType::T_SpecificValue,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Stmt,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ForeachStmt',
'data' => 'foreach',
'type' => Compiler::Lexer::TokenType::T_ForeachStmt,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_RegPrefix,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegList',
'data' => 'qw',
'type' => Compiler::Lexer::TokenType::T_RegList,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegExp',
'data' => 'B Fcntl',
'type' => Compiler::Lexer::TokenType::T_RegExp,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 4
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ArrayVar',
'data' => '@symbols',
'type' => Compiler::Lexer::TokenType::T_ArrayVar,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Assign,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Assign',
'data' => '=',
'type' => Compiler::Lexer::TokenType::T_Assign,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_RegPrefix,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegList',
'data' => 'qw',
'type' => Compiler::Lexer::TokenType::T_RegList,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegExp',
'data' => 'S_IFMT SEEK_SET',
'type' => Compiler::Lexer::TokenType::T_RegExp,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 7
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightBrace',
'data' => '}',
'type' => Compiler::Lexer::TokenType::T_RightBrace,
'line' => 8
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UseDecl',
'data' => 'use',
'type' => Compiler::Lexer::TokenType::T_UseDecl,
'line' => 10
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Module,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UsedName',
'data' => 'strict',
'type' => Compiler::Lexer::TokenType::T_UsedName,
'line' => 10
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 10
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UseDecl',
'data' => 'use',
'type' => Compiler::Lexer::TokenType::T_UseDecl,
'line' => 11
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Module,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UsedName',
'data' => 'warnings',
'type' => Compiler::Lexer::TokenType::T_UsedName,
'line' => 11
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 11
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'plan',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Int',
'data' => '4',
'type' => Compiler::Lexer::TokenType::T_Int,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Mul',
'data' => '*',
'type' => Compiler::Lexer::TokenType::T_Mul,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ArrayVar',
'data' => '@symbols',
'type' => Compiler::Lexer::TokenType::T_ArrayVar,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 12
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UseDecl',
'data' => 'use',
'type' => Compiler::Lexer::TokenType::T_UseDecl,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Module,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UsedName',
'data' => 'B',
'type' => Compiler::Lexer::TokenType::T_UsedName,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_RegPrefix,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegList',
'data' => 'qw',
'type' => Compiler::Lexer::TokenType::T_RegList,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegExp',
'data' => 'svref_2object GVf_IMPORTED_CV',
'type' => Compiler::Lexer::TokenType::T_RegExp,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RegDelim',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RegDelim,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 13
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UseDecl',
'data' => 'use',
'type' => Compiler::Lexer::TokenType::T_UseDecl,
'line' => 14
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Module,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'UsedName',
'data' => 'Fcntl',
'type' => Compiler::Lexer::TokenType::T_UsedName,
'line' => 14
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ArrayVar',
'data' => '@symbols',
'type' => Compiler::Lexer::TokenType::T_ArrayVar,
'line' => 14
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 14
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Stmt,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ForeachStmt',
'data' => 'foreach',
'type' => Compiler::Lexer::TokenType::T_ForeachStmt,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'VarDecl',
'data' => 'my',
'type' => Compiler::Lexer::TokenType::T_VarDecl,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LocalVar',
'data' => '$symbol',
'type' => Compiler::Lexer::TokenType::T_LocalVar,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'ArrayVar',
'data' => '@symbols',
'type' => Compiler::Lexer::TokenType::T_ArrayVar,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftBrace',
'data' => '{',
'type' => Compiler::Lexer::TokenType::T_LeftBrace,
'line' => 19
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Decl,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'VarDecl',
'data' => 'my',
'type' => Compiler::Lexer::TokenType::T_VarDecl,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'GlobalVar',
'data' => '$ps',
'type' => Compiler::Lexer::TokenType::T_GlobalVar,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'GlobalVar',
'data' => '$ms',
'type' => Compiler::Lexer::TokenType::T_GlobalVar,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 20
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftBrace',
'data' => '{',
'type' => Compiler::Lexer::TokenType::T_LeftBrace,
'line' => 21
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Function,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'BuiltinFunc',
'data' => 'no',
'type' => Compiler::Lexer::TokenType::T_BuiltinFunc,
'line' => 22
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'strict',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 22
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RawString',
'data' => 'refs',
'type' => Compiler::Lexer::TokenType::T_RawString,
'line' => 22
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 22
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ps',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Assign,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Assign',
'data' => '=',
'type' => Compiler::Lexer::TokenType::T_Assign,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'svref_2object',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Ref',
'data' => '\\',
'type' => Compiler::Lexer::TokenType::T_Ref,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Glob',
'data' => '*',
'type' => Compiler::Lexer::TokenType::T_Glob,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftBrace',
'data' => '{',
'type' => Compiler::Lexer::TokenType::T_LeftBrace,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'String',
'data' => 'Fcntl::$symbol',
'type' => Compiler::Lexer::TokenType::T_String,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightBrace',
'data' => '}',
'type' => Compiler::Lexer::TokenType::T_RightBrace,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 23
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ms',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Assign,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Assign',
'data' => '=',
'type' => Compiler::Lexer::TokenType::T_Assign,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'svref_2object',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Ref',
'data' => '\\',
'type' => Compiler::Lexer::TokenType::T_Ref,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Glob',
'data' => '*',
'type' => Compiler::Lexer::TokenType::T_Glob,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftBrace',
'data' => '{',
'type' => Compiler::Lexer::TokenType::T_LeftBrace,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'String',
'data' => '::$symbol',
'type' => Compiler::Lexer::TokenType::T_String,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightBrace',
'data' => '}',
'type' => Compiler::Lexer::TokenType::T_RightBrace,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 24
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightBrace',
'data' => '}',
'type' => Compiler::Lexer::TokenType::T_RightBrace,
'line' => 25
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'object_ok',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ps',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RawString',
'data' => 'B::GV',
'type' => Compiler::Lexer::TokenType::T_RawString,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 26
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'is',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ps',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Pointer',
'data' => '->',
'type' => Compiler::Lexer::TokenType::T_Pointer,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Function,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Method',
'data' => 'GvFLAGS',
'type' => Compiler::Lexer::TokenType::T_Method,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'BitAnd',
'data' => '&',
'type' => Compiler::Lexer::TokenType::T_BitAnd,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'GVf_IMPORTED_CV',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Int',
'data' => '0',
'type' => Compiler::Lexer::TokenType::T_Int,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 27
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'String',
'data' => 'GVf_IMPORTED_CV not set on original',
'type' => Compiler::Lexer::TokenType::T_String,
'line' => 28
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 28
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 28
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'object_ok',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ms',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RawString',
'data' => 'B::GV',
'type' => Compiler::Lexer::TokenType::T_RawString,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 29
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'is',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Var',
'data' => '$ms',
'type' => Compiler::Lexer::TokenType::T_Var,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Pointer',
'data' => '->',
'type' => Compiler::Lexer::TokenType::T_Pointer,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Function,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Method',
'data' => 'GvFLAGS',
'type' => Compiler::Lexer::TokenType::T_Method,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'LeftParenthesis',
'data' => '(',
'type' => Compiler::Lexer::TokenType::T_LeftParenthesis,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Operator,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'BitAnd',
'data' => '&',
'type' => Compiler::Lexer::TokenType::T_BitAnd,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'GVf_IMPORTED_CV',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 1,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Key',
'data' => 'GVf_IMPORTED_CV',
'type' => Compiler::Lexer::TokenType::T_Key,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Comma,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'Comma',
'data' => ',',
'type' => Compiler::Lexer::TokenType::T_Comma,
'line' => 30
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Term,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'String',
'data' => 'GVf_IMPORTED_CV set on imported GV',
'type' => Compiler::Lexer::TokenType::T_String,
'line' => 31
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightParenthesis',
'data' => ')',
'type' => Compiler::Lexer::TokenType::T_RightParenthesis,
'line' => 31
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_StmtEnd,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'SemiColon',
'data' => ';',
'type' => Compiler::Lexer::TokenType::T_SemiColon,
'line' => 31
}, 'Compiler::Lexer::Token' ),
bless( {
'kind' => Compiler::Lexer::Kind::T_Symbol,
'has_warnings' => 0,
'stype' => Compiler::Lexer::SyntaxType::T_Value,
'name' => 'RightBrace',
'data' => '}',
'type' => Compiler::Lexer::TokenType::T_RightBrace,
'line' => 32
}, 'Compiler::Lexer::Token' )
]
, 'Compiler::Lexer::tokenize');
};
subtest 'get_groups_by_syntax_level' => sub {
my $lexer = Compiler::Lexer->new('');
my $tokens = $lexer->tokenize($script);
my $stmts = $lexer->get_groups_by_syntax_level($tokens, Compiler::Lexer::SyntaxType::T_Stmt);
is_deeply($stmts, [
{
'token_num' => 3,
'has_warnings' => 0,
'end_line' => 1,
'src' => ' my @symbols ;',
'start_line' => 1,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 3,
'has_warnings' => 0,
'end_line' => 3,
'src' => ' require \'./test.pl\' ;',
'start_line' => 3,
'indent' => 1,
'block_id' => 1
},
{
'token_num' => 10,
'has_warnings' => 1,
'end_line' => 4,
'src' => ' skip_all_without_dynamic_extension ( $_ ) foreach qw(B Fcntl) ;',
'start_line' => 4,
'indent' => 1,
'block_id' => 1
},
{
'token_num' => 7,
'has_warnings' => 0,
'end_line' => 7,
'src' => ' @symbols = qw(S_IFMT SEEK_SET) ;',
'start_line' => 7,
'indent' => 1,
'block_id' => 1
},
{
'token_num' => 3,
'has_warnings' => 0,
'end_line' => 10,
'src' => ' use strict ;',
'start_line' => 10,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 3,
'has_warnings' => 0,
'end_line' => 11,
'src' => ' use warnings ;',
'start_line' => 11,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 7,
'has_warnings' => 1,
'end_line' => 12,
'src' => ' plan ( 4 * @symbols ) ;',
'start_line' => 12,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 7,
'has_warnings' => 0,
'end_line' => 13,
'src' => ' use B qw(svref_2object GVf_IMPORTED_CV) ;',
'start_line' => 13,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 4,
'has_warnings' => 0,
'end_line' => 14,
'src' => ' use Fcntl @symbols ;',
'start_line' => 14,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 87,
'has_warnings' => 1,
'end_line' => 32,
'src' => ' foreach my $symbol ( @symbols ) { my ( $ps , $ms ) ; { no strict \'refs\' ; $ps = svref_2object ( \\ * { "Fcntl::$symbol" } ) ; $ms = svref_2object ( \\ * { "::$symbol" } ) ; } object_ok ( $ps , \'B::GV\' ) ; is ( $ps-> GvFLAGS ( ) & GVf_IMPORTED_CV , 0 , "GVf_IMPORTED_CV not set on original" ) ; object_ok ( $ms , \'B::GV\' ) ; is ( $ms-> GvFLAGS ( ) & GVf_IMPORTED_CV , GVf_IMPORTED_CV , "GVf_IMPORTED_CV set on imported GV" ) ; }',
'start_line' => 19,
'indent' => 0,
'block_id' => 0
},
{
'token_num' => 7,
'has_warnings' => 1,
'end_line' => 20,
'src' => ' my ( $ps , $ms ) ;',
'start_line' => 20,
'indent' => 1,
'block_id' => 2
},
{
'token_num' => 28,
'has_warnings' => 1,
'end_line' => 25,
'src' => ' { no strict \'refs\' ; $ps = svref_2object ( \\ * { "Fcntl::$symbol" } ) ; $ms = svref_2object ( \\ * { "::$symbol" } ) ; }',
'start_line' => 21,
'indent' => 1,
'block_id' => 2
},
{
'token_num' => 4,
'has_warnings' => 1,
'end_line' => 22,
'src' => ' no strict \'refs\' ;',
'start_line' => 22,
'indent' => 2,
'block_id' => 3
},
{
'token_num' => 11,
'has_warnings' => 1,
'end_line' => 23,
'src' => ' $ps = svref_2object ( \\ * { "Fcntl::$symbol" } ) ;',
'start_line' => 23,
'indent' => 2,
'block_id' => 3
},
{
'token_num' => 11,
'has_warnings' => 1,
'end_line' => 24,
'src' => ' $ms = svref_2object ( \\ * { "::$symbol" } ) ;',
'start_line' => 24,
'indent' => 2,
'block_id' => 3
},
{
'token_num' => 7,
'has_warnings' => 1,
'end_line' => 26,
'src' => ' object_ok ( $ps , \'B::GV\' ) ;',
'start_line' => 26,
'indent' => 1,
'block_id' => 2
},
{
'token_num' => 15,
'has_warnings' => 1,
'end_line' => 28,
'src' => ' is ( $ps-> GvFLAGS ( ) & GVf_IMPORTED_CV , 0 , "GVf_IMPORTED_CV not set on original" ) ;',
'start_line' => 27,
'indent' => 1,
'block_id' => 2
},
{
'token_num' => 7,
'has_warnings' => 1,
'end_line' => 29,
'src' => ' object_ok ( $ms , \'B::GV\' ) ;',
'start_line' => 29,
'indent' => 1,
'block_id' => 2
},
{
'token_num' => 15,
'has_warnings' => 1,
'end_line' => 31,
'src' => ' is ( $ms-> GvFLAGS ( ) & GVf_IMPORTED_CV , GVf_IMPORTED_CV , "GVf_IMPORTED_CV set on imported GV" ) ;',
'start_line' => 30,
'indent' => 1,
'block_id' => 2
}
]
, 'Compiler::Lexer::get_groups_by_syntax_level');
};
subtest 'get_used_modules' => sub {
my $modules = Compiler::Lexer->new('')->get_used_modules($script);
is_deeply($modules, [
{
'args' => '',
'name' => 'strict'
},
{
'args' => '',
'name' => 'warnings'
},
{
'args' => ' qw ( svref_2object GVf_IMPORTED_CV )',
'name' => 'B'
},
{
'args' => ' @symbols',
'name' => 'Fcntl'
}
]
, 'Compiler::Lexer::get_used_modules');
};
done_testing;
| 43.457297 | 458 | 0.389626 |
ed507b6e195ecce70457ce320017b33b3e0761fb | 32,713 | al | Perl | Apps/W1/EmailLogging/app/src/pages/EmailLoggingSetupWizard.Page.al | AndersLarsenMicrosoft/ALAppExtensions | 31000fa1bb6bedac17a8141e2ac1ab607e466ec5 | [
"MIT"
]
| 1 | 2022-03-28T01:20:39.000Z | 2022-03-28T01:20:39.000Z | Apps/W1/EmailLogging/app/src/pages/EmailLoggingSetupWizard.Page.al | snu-development/ALAppExtensions | 371a27fe48483be776642dde19483a87ae27289c | [
"MIT"
]
| null | null | null | Apps/W1/EmailLogging/app/src/pages/EmailLoggingSetupWizard.Page.al | snu-development/ALAppExtensions | 371a27fe48483be776642dde19483a87ae27289c | [
"MIT"
]
| null | null | null | page 1681 "Email Logging Setup Wizard"
{
Caption = 'Set Up Email Logging';
DeleteAllowed = false;
InsertAllowed = false;
LinksAllowed = false;
PageType = NavigatePage;
ShowFilter = false;
Permissions = tabledata "Email Logging Setup" = rimd;
layout
{
area(content)
{
group(NotDoneBanner)
{
Editable = false;
ShowCaption = false;
Visible = TopBannerVisible and (not DoneVisible);
field(NotDoneIcon; MediaResourcesStandard."Media Reference")
{
ApplicationArea = Basic, Suite, RelationshipMgmt;
Editable = false;
ShowCaption = false;
}
}
group(DoneBanner)
{
Editable = false;
ShowCaption = false;
Visible = TopBannerVisible and DoneVisible;
field(DoneIcon; MediaResourcesDone."Media Reference")
{
ApplicationArea = Basic, Suite, RelationshipMgmt;
Editable = false;
ShowCaption = false;
}
}
group(FeatureNotEnabled)
{
Caption = '';
Visible = not FeatureEnabled;
group(FeatureHeader)
{
ShowCaption = false;
InstructionalText = 'The Email Logging Using the Microsoft Graph API feature is not enabled. To continue, open the Feature Management page and enable the feature.';
}
field(EnableFeature; OpenFeatureManagementTxt)
{
ApplicationArea = All;
Editable = false;
ShowCaption = false;
ToolTip = 'Open the Feature Management page.';
Style = StandardAccent;
trigger OnDrillDown()
begin
Commit();
Page.RunModal(Page::"Feature Management");
FeatureEnabled := EmailLoggingManagement.IsEmailLoggingUsingGraphApiFeatureEnabled();
end;
}
}
group(Step1)
{
Caption = '';
Visible = IntroVisible;
group("Welcome to Email Logging Setup")
{
Caption = 'Welcome to Email Logging Setup';
group(Control3)
{
Caption = '';
InstructionalText = 'This guide will help you set up email logging using the Microsoft Graph API to connect to a shared mailbox.';
}
group(Control4)
{
Caption = '';
InstructionalText = 'To learn more about how to set up shared mailboxes and rules so that your organization can track email communication between sales people and external contacts, choose the link below.';
}
field(LearnHowToSetupMailboxForEmailLogging; LearnHowToSetupMailboxForEmailLoggingTxt)
{
ApplicationArea = RelationshipMgmt;
ShowCaption = false;
Editable = false;
Style = StandardAccent;
trigger OnDrillDown()
begin
Hyperlink(HowToSetupMailboxForEmailLoggingUrlTxt);
end;
}
field(ManualSetupDone; ManualSetupDone)
{
Caption = 'Manual setup done';
ToolTip = 'The settings in Exchange Online are complete.';
ApplicationArea = RelationshipMgmt;
trigger OnValidate()
begin
NextEnabled := ManualSetupDone;
end;
}
}
}
group(Step2)
{
Visible = (not IsSaaSInfrastructure) and ClientCredentialsVisible;
InstructionalText = 'Specify the ID and secret of the Azure Active Directory application that will be used to connect to the shared mailbox.';
ShowCaption = false;
field(ClientCredentialsLink; ClientCredentialsLinkTxt)
{
ShowCaption = false;
Editable = false;
ApplicationArea = RelationshipMgmt;
trigger OnDrillDown()
begin
CustomCredentialsSpecified := EmailLoggingManagement.PromptClientCredentials(ClientId, ClientSecret, RedirectUrl);
NextEnabled := CustomCredentialsSpecified;
end;
}
group(SpecifiedCustomClientCredentialsGroup)
{
Visible = CustomCredentialsSpecified;
ShowCaption = false;
field(SpecifiedCustomClientCredentials; SpecifiedCustomClientCredentialsTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Indicates that the client credentials are specified and will be used to connect to the shared mailbox.';
Caption = 'Client ID and secret are specified and will be used to connect to the shared mailbox';
Editable = false;
ShowCaption = false;
Style = Standard;
}
}
group(ClientCredentialsRequiredGroup)
{
Visible = not CustomCredentialsSpecified;
ShowCaption = false;
field(ClientCredentialsRequired; ClientCredentialsRequiredTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Indicates that the client ID and secret are required to connect to the shared mailbox.';
Editable = false;
ShowCaption = false;
Style = Standard;
}
}
}
group(Step3)
{
InstructionalText = 'Sign in with an administrator account for Exchange Online and give consent to the application that will be used to connect to the shared mailbox.';
Visible = UseThirdPartyApp and OAuth2Visible;
ShowCaption = false;
field(SignInAndGiveConsentLink; SignInAndGiveConsentLinkTxt)
{
ShowCaption = false;
Editable = false;
ApplicationArea = RelationshipMgmt;
trigger OnDrillDown()
begin
HasAdminSignedIn := true;
AreAdminCredentialsCorrect := SignInAndGiveAppConsent();
AppConsentGiven := AreAdminCredentialsCorrect;
NextEnabled := AppConsentGiven;
CurrPage.Update(false);
end;
}
group(AdminSignInSucceed)
{
Visible = HasAdminSignedIn and AreAdminCredentialsCorrect;
ShowCaption = false;
field(SuccesfullyLoggedIn; SuccesfullyLoggedInTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies if the Exchange administrator has logged in successfully.';
Editable = false;
ShowCaption = false;
Style = Favorable;
}
}
group(AdminSignInFailed)
{
Visible = HasAdminSignedIn and (not AreAdminCredentialsCorrect);
ShowCaption = false;
field(UnsuccesfullyLoggedIn; UnsuccesfullyLoggedInTxt)
{
ApplicationArea = RelationshipMgmt;
Tooltip = 'Indicates that the Exchange Online administrator is not signed in.';
Editable = false;
ShowCaption = false;
Style = Unfavorable;
}
}
field(AppConsentGiven; AppConsentGiven)
{
Caption = 'Consent given';
ToolTip = 'Consent given';
ApplicationArea = RelationshipMgmt;
Enabled = ConsentGiven and ((not HasAdminSignedIn) or (not AreAdminCredentialsCorrect));
trigger OnValidate()
begin
NextEnabled := AppConsentGiven;
end;
}
}
group(Step4)
{
Visible = EmailAddressVisible;
InstructionalText = 'Provide the email address of the shared mailbox that is configured for email logging. The shared mailbox must be in the same tenant as Business Central.';
ShowCaption = false;
field("Email Address"; EmailAddress)
{
ApplicationArea = RelationshipMgmt;
Tooltip = 'Specifies the email address of the shared mailbox. The shared mailbox must be in the same tenant as Business Central.';
Caption = 'Shared Mailbox Email';
ExtendedDatatype = EMail;
trigger OnValidate()
begin
ValidateMailboxLinkVisited := false;
IsMailboxValid := false;
NextEnabled := false;
end;
}
group(ValidateMailboxFirstPartyApp)
{
Visible = (not UseThirdPartyApp) and EmailAddressVisible;
InstructionalText = 'Click the link below to test the connection to the shared mailbox.';
ShowCaption = false;
}
group(ValidateMailboxThirdPartyApp)
{
Visible = UseThirdPartyApp and EmailAddressVisible;
InstructionalText = 'Click the link below to test the connection to the shared mailbox. You will need to sign in with an Exchange Online account that the scheduled job will use to connect to the shared mailbox and process emails.';
ShowCaption = false;
}
field(ValidateMailboxLink; ValidateMailboxLinkTxt)
{
ShowCaption = false;
Editable = false;
ApplicationArea = RelationshipMgmt;
trigger OnDrillDown()
var
EmailLoggingAPIHelper: Codeunit "Email Logging API Helper";
OAuthClient: Interface "Email Logging OAuth Client";
APIClient: Interface "Email Logging API Client";
[NonDebuggable]
AccessToken: Text;
begin
EmailLoggingManagement.InitializeOAuthClient(OAuthClient);
if CustomCredentialsSpecified then
OAuthClient.Initialize(ClientId, ClientSecret, RedirectUrl)
else
OAuthClient.Initialize();
if UseThirdPartyApp then begin
OAuthClient.GetAccessToken(Enum::"Prompt Interaction"::"Select Account", AccessToken);
if AccessToken = '' then
IsMailboxValid := false;
end;
if (not UseThirdPartyApp) or (AccessToken <> '') then begin
EmailLoggingManagement.InitializeAPIClient(APIClient);
EmailLoggingAPIHelper.Initialize(OAuthClient, APIClient);
IsMailboxValid := EmailLoggingAPIHelper.IsSharedMailboxAvailable(EmailAddress);
end;
ValidateMailboxLinkVisited := true;
NextEnabled := IsMailboxValid;
end;
}
group(ValidMailboxGroup)
{
Visible = ValidateMailboxLinkVisited and IsMailboxValid;
ShowCaption = false;
field(ValidMailbox; ValidMailboxTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'The connection test was successful.';
Editable = false;
ShowCaption = false;
Style = Favorable;
}
}
group(InvalidMailboxGroup)
{
Visible = ValidateMailboxLinkVisited and (not IsMailboxValid);
ShowCaption = false;
field(InvalidMailbox; InvalidMailboxTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'The connection test was not successful.';
Editable = false;
ShowCaption = false;
Style = Unfavorable;
}
}
group(AdvancedSection)
{
ShowCaption = false;
Visible = AdvancedSectionVisible;
group(AdvancedHeader)
{
ShowCaption = false;
InstructionalText = 'Enter the number of email messages that the job queue entry for email logging will get from Exchange Online in one run. By balancing this number with how often the job queue entry runs you can fine tune the process. If a message is not logged in the current run it will be in the next one.';
}
field(EmailBatchSize; EmailBatchSize)
{
ApplicationArea = RelationshipMgmt;
Caption = 'Email Batch Size';
ToolTip = 'Specifies the number of email messages that the job queue entry for email logging will get from Exchange Online in one run. By balancing this number with how often the job queue entry runs you can fine tune the process. If a message is not logged in the current run it will be in the next one.';
ShowMandatory = true;
NotBlank = true;
MinValue = 1;
MaxValue = 1000;
}
}
}
group(Step5)
{
Caption = '';
Visible = DoneVisible;
group(FinalStepDesc)
{
Caption = 'That''s it!';
InstructionalText = 'When you choose Finish, the following will be created:';
group(Control33)
{
ShowCaption = false;
field(CreateEmailLoggingJobQueue; CreateEmailLoggingJobQueue)
{
ApplicationArea = RelationshipMgmt;
Caption = 'Create Email Logging Job Queue';
ToolTip = 'Create Email Logging Job Queue';
}
group(InvalidInteractionTemplateSetupGroup)
{
Visible = CreateEmailLoggingJobQueue and (not ValidInteractionTemplateSetup);
ShowCaption = false;
InstructionalText = 'Email Logging requires correctly configured Interaction Template Setup.';
field(InteractionTemplateSetupLink; InteractionTemplateSetupLinkTxt)
{
ApplicationArea = RelationshipMgmt;
ShowCaption = false;
Editable = false;
Style = StandardAccent;
trigger OnDrillDown()
begin
Commit();
Page.RunModal(Page::"Interaction Template Setup");
ValidInteractionTemplateSetup := EmailLoggingManagement.CheckInteractionTemplateSetup();
end;
}
field(InvalidInteractionTemplateSetup; InvalidInteractionTemplateSetupTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Indicates that Interaction Template Setup needs to be configurred.';
Caption = 'Interaction Template Setup needs to be configurred.';
Editable = false;
ShowCaption = false;
Style = Unfavorable;
}
}
group(ValidInteractionTemplateSetupGroup)
{
Visible = CreateEmailLoggingJobQueue and ValidInteractionTemplateSetup;
ShowCaption = false;
field(ValidInteractionTemplateSetup; ValidInteractionTemplateSetupTxt)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Indicates that Interaction Template Setup is correctly configurred.';
Caption = 'Interaction Template Setup is correctly configurred.';
Editable = false;
ShowCaption = false;
Style = Favorable;
}
}
}
}
}
}
}
actions
{
area(Processing)
{
action(ActionSimple)
{
ApplicationArea = Basic, Suite;
Caption = 'Simple';
Image = Setup;
InFooterBar = true;
Visible = EmailAddressVisible and SimpleActionEnabled;
trigger OnAction()
begin
AdvancedActionEnabled := true;
SimpleActionEnabled := false;
AdvancedSectionVisible := false;
end;
}
action(ActionAdvanced)
{
ApplicationArea = Basic, Suite;
Caption = 'Advanced';
Image = Setup;
InFooterBar = true;
Visible = EmailAddressVisible and AdvancedActionEnabled;
trigger OnAction()
begin
AdvancedActionEnabled := false;
SimpleActionEnabled := true;
AdvancedSectionVisible := true;
end;
}
action(ActionBack)
{
ApplicationArea = RelationshipMgmt;
Caption = 'Back';
ToolTip = 'Back';
Enabled = BackEnabled;
Image = PreviousRecord;
InFooterBar = true;
trigger OnAction()
begin
NextStep(true);
end;
}
action(ActionNext)
{
ApplicationArea = RelationshipMgmt;
Caption = 'Next';
ToolTip = 'Next';
Enabled = NextEnabled;
Image = NextRecord;
InFooterBar = true;
trigger OnAction()
begin
NextStep(false);
end;
}
action(ActionFinish)
{
ApplicationArea = RelationshipMgmt;
Caption = 'Finish';
ToolTip = 'Finish';
Enabled = FinishEnabled;
Image = Approve;
InFooterBar = true;
trigger OnAction()
var
EmailLoggingSetup: Record "Email Logging Setup";
GuidedExperience: Codeunit "Guided Experience";
begin
if EmailLoggingSetup.Get() then
EmailLoggingManagement.ClearEmailLoggingSetup(EmailLoggingSetup);
EmailLoggingManagement.DeleteEmailLoggingJobQueueSetup();
UpdateEmailLoggingSetup(EmailLoggingSetup);
if CreateEmailLoggingJobQueue then begin
Session.LogMessage('0000G0T', CreateEmailLoggingJobTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok);
EmailLoggingManagement.CreateEmailLoggingJobQueueSetup();
end else
Session.LogMessage('0000G0U', SkipCreatingEmailLoggingJobTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok);
GuidedExperience.CompleteAssistedSetup(ObjectType::Page, PAGE::"Setup Email Logging");
Session.LogMessage('0000G0V', EmailLoggingSetupCompletedTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok);
CurrPage.Close();
end;
}
}
}
trigger OnInit()
var
EmailLoggingSetup: Record "Email Logging Setup";
EnvironmentInformation: Codeunit "Environment Information";
IsolatedStorageManagement: Codeunit "Isolated Storage Management";
OAuthClient: Interface "Email Logging OAuth Client";
ApplicationType: Enum "Email Logging App Type";
ClientSecretLocal: Text;
begin
LoadTopBanners();
FeatureEnabled := EmailLoggingManagement.IsEmailLoggingUsingGraphApiFeatureEnabled();
EmailBatchSize := EmailLoggingSetup.GetDefaultEmailBatchSize();
if not EmailLoggingSetup.Get() then begin
EmailLoggingSetup.Insert();
Commit();
end;
EmailAddress := EmailLoggingSetup."Email Address";
EmailLoggingManagement.InitializeOAuthClient(OAuthClient);
ApplicationType := OAuthClient.GetApplicationType();
UseThirdPartyApp := ApplicationType = ApplicationType::"Third Party";
IsSaaSInfrastructure := EnvironmentInformation.IsSaaSInfrastructure();
if not IsSaaSInfrastructure then begin
ClientId := EmailLoggingSetup."Client Id";
if not IsNullGuid(EmailLoggingSetup."Client Secret Key") then
if IsolatedStorageManagement.Get(EmailLoggingSetup."Client Secret Key", DataScope::Company, ClientSecretLocal) then
ClientSecret := CopyStr(ClientSecretLocal, 1, MaxStrLen(ClientSecret));
RedirectUrl := EmailLoggingSetup."Redirect URL";
if RedirectUrl = '' then
RedirectUrl := EmailLoggingSetup.GetDefaultRedirectUrl();
CustomCredentialsSpecified := (ClientId <> '') or (ClientSecret <> '') or (RedirectUrl <> '');
end;
ConsentGiven := EmailLoggingSetup."Consent Given";
AdvancedActionEnabled := true;
SimpleActionEnabled := false;
end;
trigger OnOpenPage()
begin
if FeatureEnabled then
ShowIntroStep();
end;
trigger OnQueryClosePage(CloseAction: Action): Boolean
var
GuidedExperience: Codeunit "Guided Experience";
begin
if CloseAction = Action::OK then
if GuidedExperience.AssistedSetupExistsAndIsNotComplete(ObjectType::Page, PAGE::"Setup Email Logging") then
if not Confirm(NotSetUpQst, false) then
Error('');
end;
var
MediaRepositoryStandard: Record "Media Repository";
MediaRepositoryDone: Record "Media Repository";
MediaResourcesStandard: Record "Media Resources";
MediaResourcesDone: Record "Media Resources";
EmailLoggingManagement: Codeunit "Email Logging Management";
ClientTypeManagement: Codeunit "Client Type Management";
Step: Option Intro,Client,OAuth2,Email,Done;
UseThirdPartyApp: Boolean;
IsSaaSInfrastructure: Boolean;
EmailBatchSize: Integer;
ClientId: Text[250];
[NonDebuggable]
ClientSecret: Text[250];
RedirectUrl: Text[2048];
FeatureEnabled: Boolean;
BackEnabled: Boolean;
NextEnabled: Boolean;
FinishEnabled: Boolean;
TopBannerVisible: Boolean;
IntroVisible: Boolean;
OAuth2Visible: Boolean;
EmailAddressVisible: Boolean;
ClientCredentialsVisible: Boolean;
ManualSetupDone: Boolean;
AppConsentGiven: Boolean;
DoneVisible: Boolean;
AdvancedActionEnabled: Boolean;
SimpleActionEnabled: Boolean;
AdvancedSectionVisible: Boolean;
EmailAddress: Text[250];
ConsentGiven: Boolean;
HasAdminSignedIn: Boolean;
AreAdminCredentialsCorrect: Boolean;
CustomCredentialsSpecified: Boolean;
ValidateMailboxLinkVisited: Boolean;
IsMailboxValid: Boolean;
ValidInteractionTemplateSetup: Boolean;
CategoryTok: Label 'Email Logging', Locked = true;
OpenFeatureManagementTxt: Label 'Open Feature Management';
NotSetUpQst: Label 'Email logging is not set up. \\Are you sure that you want to exit?';
CreateEmailLoggingJobQueue: Boolean;
UpdateSetupTxt: Label 'Update email logging setup record.', Locked = true;
LearnHowToSetupMailboxForEmailLoggingTxt: Label 'Learn how to set up a shared mailbox for email logging';
HowToSetupMailboxForEmailLoggingUrlTxt: Label 'https://go.microsoft.com/fwlink/?linkid=2115467', Locked = true;
SuccesfullyLoggedInTxt: Label 'The user is signed in.';
UnsuccesfullyLoggedInTxt: Label 'Could not sign in the user.';
SpecifiedCustomClientCredentialsTxt: Label 'Client ID and secret are specified and will be used to connect to the shared mailbox.';
ClientCredentialsRequiredTxt: Label 'Client ID and secret are required to connect to the shared mailbox.';
SignInAndGiveConsentLinkTxt: Label 'Sign in and give consent';
ClientCredentialsLinkTxt: Label 'Specify client ID and secret';
ValidateMailboxLinkTxt: Label 'Check connection to the specified mailbox';
ValidMailboxTxt: Label 'The connection test was successful.';
InvalidMailboxTxt: Label 'The connection test was not successful.';
InteractionTemplateSetupLinkTxt: Label 'Interaction Template Setup';
ValidInteractionTemplateSetupTxt: Label 'Interaction Template Setup is correctly configured.';
InvalidInteractionTemplateSetupTxt: Label 'Interaction Template Setup needs to be configured.';
EmailLoggingSetupCompletedTxt: Label 'Email Logging Setup completed.', Locked = true;
CreateEmailLoggingJobTxt: Label 'Create email logging job', Locked = true;
SkipCreatingEmailLoggingJobTxt: Label 'Skip creating email logging job', Locked = true;
local procedure NextStep(Backwards: Boolean)
begin
if Backwards then
Step := Step - 1
else
Step := Step + 1;
case Step of
Step::Client:
if IsSaaSInfrastructure then
NextStep(Backwards);
Step::OAuth2:
if not UseThirdPartyApp then
NextStep(Backwards);
end;
case Step of
Step::Intro:
ShowIntroStep();
Step::Client:
ShowClientStep();
Step::OAuth2:
ShowOAuth2Step();
Step::Email:
ShowEmailStep();
Step::Done:
ShowDoneStep();
end;
CurrPage.Update(true);
end;
local procedure ShowIntroStep()
begin
ResetWizardControls();
IntroVisible := true;
NextEnabled := ManualSetupDone;
BackEnabled := false;
end;
local procedure ShowClientStep()
begin
ResetWizardControls();
ClientCredentialsVisible := true;
end;
local procedure ShowOAuth2Step()
begin
ResetWizardControls();
OAuth2Visible := true;
if HasAdminSignedIn and (not AreAdminCredentialsCorrect) then
HasAdminSignedIn := false;
NextEnabled := AppConsentGiven;
end;
local procedure ShowEmailStep()
begin
ResetWizardControls();
EmailAddressVisible := true;
NextEnabled := IsMailboxValid;
end;
local procedure ShowDoneStep()
begin
ResetWizardControls();
DoneVisible := true;
NextEnabled := false;
ValidInteractionTemplateSetup := EmailLoggingManagement.CheckInteractionTemplateSetup();
FinishEnabled := ValidInteractionTemplateSetup;
CreateEmailLoggingJobQueue := true;
end;
local procedure ResetWizardControls()
begin
// Buttons
BackEnabled := true;
NextEnabled := true;
FinishEnabled := false;
// Tabs
IntroVisible := false;
ClientCredentialsVisible := false;
OAuth2Visible := false;
EmailAddressVisible := false;
AdvancedSectionVisible := false;
DoneVisible := false;
end;
[TryFunction]
[NonDebuggable]
local procedure SignInAndGiveAppConsent()
var
OAuthClient: Interface "Email Logging OAuth Client";
AccessToken: Text;
TenantId: Text;
begin
EmailLoggingManagement.InitializeOAuthClient(OAuthClient);
if CustomCredentialsSpecified then
OAuthClient.Initialize(ClientId, ClientSecret, RedirectUrl)
else
OAuthClient.Initialize();
OAuthClient.GetAccessToken(Enum::"Prompt Interaction"::"Admin Consent", AccessToken);
TenantId := EmailLoggingManagement.ExtractTenantIdFromAccessToken(AccessToken);
ConsentGiven := TenantId <> '';
end;
[NonDebuggable]
local procedure UpdateEmailLoggingSetup(var EmailLoggingSetup: Record "Email Logging Setup")
var
DummyEmailLoggingSetup: Record "Email Logging Setup";
begin
Session.LogMessage('0000G0W', UpdateSetupTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryTok);
EmailLoggingSetup.Validate("Email Address", EmailAddress);
EmailLoggingSetup.Validate("Email Batch Size", EmailBatchSize);
if CustomCredentialsSpecified then begin
EmailLoggingSetup.Validate("Client Id", ClientId);
EmailLoggingSetup.SetClientSecret(ClientSecret);
EmailLoggingSetup.Validate("Redirect URL", RedirectUrl);
end;
EmailLoggingSetup."Consent Given" := ConsentGiven;
EmailLoggingSetup.Validate(Enabled, true);
if DummyEmailLoggingSetup.Get() then
EmailLoggingSetup.Modify()
else
EmailLoggingSetup.Insert();
end;
local procedure LoadTopBanners()
begin
if MediaRepositoryStandard.Get('AssistedSetup-NoText-400px.png', Format(ClientTypeManagement.GetCurrentClientType())) and
MediaRepositoryDone.Get('AssistedSetupDone-NoText-400px.png', Format(ClientTypeManagement.GetCurrentClientType()))
then
if MediaResourcesStandard.Get(MediaRepositoryStandard."Media Resources Ref") and
MediaResourcesDone.Get(MediaRepositoryDone."Media Resources Ref")
then
TopBannerVisible := MediaResourcesDone."Media Reference".HasValue;
end;
}
| 43.50133 | 336 | 0.537493 |
ed3b4dd4f2cb31db433f8f009d8d5ae1f1aa3e6c | 4,276 | t | Perl | t/01-param-check.t | celeron1ghz/acceptessa2-mail | a74b8b69ea1a03009673252f620dd0303ede8c5b | [
"MIT"
]
| null | null | null | t/01-param-check.t | celeron1ghz/acceptessa2-mail | a74b8b69ea1a03009673252f620dd0303ede8c5b | [
"MIT"
]
| null | null | null | t/01-param-check.t | celeron1ghz/acceptessa2-mail | a74b8b69ea1a03009673252f620dd0303ede8c5b | [
"MIT"
]
| null | null | null | use strict;
use Test::More;
use Test::LongString;
use Acceptessa2::Mail;
use YAML;
sub cr2crlf {
my $val = shift;
return join("\r\n", split "\n", $val) . "\r\n";
}
my $data = YAML::Load(join "", <DATA>);
my @tests = (
{
template => $data->{tmpl1},
expected => cr2crlf($data->{result1}),
desc => 'basic template',
parameter => {
from => 'from@from',
to => 'to@to',
subject => 'subject subject',
template => "z",
data => {
hello => "mogemoge",
world => "fugafuga",
}
},
ret => { success => 1 },
},
{
template => $data->{tmpl2},
expected => cr2crlf($data->{result2}),
desc => 'with attachment',
parameter => {
from => 'from@from',
to => 'to@to',
subject => 'subject subject',
template => "z",
data => {
hello => "mogemoge",
world => "fugafuga",
},
attachment => {
a1 => 'moge/a1.png',
b1 => 'fuga/b1.png',
}
},
ret => { success => 1 },
},
{
template => '[% $test ',
expected => "",
desc => 'with error',
parameter => {
from => 'from@from',
to => 'to@to',
subject => 'subject subject',
template => "z",
data => {
hello => "mogemoge",
world => "fugafuga",
},
},
ret => { error => $data->{error1} },
},
);
plan tests => @tests * 2;
my $ATTACHMENT = {
"moge/a1.png" => "aaaaaaaaaa",
"fuga/b1.png" => "bbbbbbbbbb",
};
local *Email::Simple::Creator::_date_header = sub { 'ThisIsDateString' };
local *Acceptessa2::Mail::get_attachment = sub {
my ($class, $key) = @_;
return $ATTACHMENT->{$key};
};
foreach my $t (@tests) {
my $result;
local *Acceptessa2::Mail::get_template = sub { $t->{template} };
local *Acceptessa2::Mail::send_mail = sub { $result = $_[1] };
my $ret = Acceptessa2::Mail->run($t->{parameter});
my $mail_contents = $result ? $result->as_string : '';
is_deeply $ret, $t->{ret}, "$t->{desc}: return value ok";
if ($t->{parameter}->{attachment}) {
my $boundary = quotemeta $result->{ct}->{attributes}->{boundary};
$mail_contents =~ s/$boundary/wawawawawawawawawawa/g;
}
is_string $mail_contents, $t->{expected}, "$t->{desc}: template render ok";
}
__DATA__
tmpl1: |
<!-- subject subject -->
[% $hello %] [% $world %]
result1: |
From: from@from
To: to@to
Subject: subject subject
Date: ThisIsDateString
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: text/html; charset=utf-8
bW9nZW1vZ2UgZnVnYWZ1Z2EK
tmpl2: |
<!-- subject2 subject2 -->
[% $hello %] [% $world %]
result2: |
From: from@from
To: to@to
Subject: subject2 subject2
Date: ThisIsDateString
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed; boundary=wawawawawawawawawawa
--wawawawawawawawawawa
Date: ThisIsDateString
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
bW9nZW1vZ2UgZnVnYWZ1Z2EK
--wawawawawawawawawawa
Content-Id: <a1>
Date: ThisIsDateString
MIME-Version: 1.0
Content-Type: image/jpeg; name=a1.png
Content-Disposition: attachment; filename=a1.png
Content-Transfer-Encoding: base64
YWFhYWFhYWFhYQ==
--wawawawawawawawawawa
Content-Id: <b1>
Date: ThisIsDateString
MIME-Version: 1.0
Content-Type: image/jpeg; name=b1.png
Content-Disposition: attachment; filename=b1.png
Content-Transfer-Encoding: base64
YmJiYmJiYmJiYg==
--wawawawawawawawawawa--
error1: |
template syntax error: Text::Xslate::Syntax::Kolon: Malformed templates detected, near ' $test ', while parsing templates (<string>:1) at lib/Acceptessa2/Mail.pm line 68.
----------------------------------------------------------------------------
<: $test
----------------------------------------------------------------------------
| 26.893082 | 172 | 0.519177 |
73ffec5242e243a405ea149da9763da8197103a5 | 18,631 | t | Perl | t/plugin/kafka-logger2.t | hwy1782/apisix | 79601b820f15ddb98c85237e8a7b45f3263fb5a1 | [
"Apache-2.0"
]
| 1 | 2021-12-16T10:59:19.000Z | 2021-12-16T10:59:19.000Z | t/plugin/kafka-logger2.t | hwy1782/apisix | 79601b820f15ddb98c85237e8a7b45f3263fb5a1 | [
"Apache-2.0"
]
| 24 | 2021-05-12T06:10:45.000Z | 2022-03-30T12:11:18.000Z | t/plugin/kafka-logger2.t | zhangbao0325/apisix | b4fd8ad943e9b30f3641a823fe53ad9a836986ca | [
"Apache-2.0"
]
| null | null | null | #
# 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.
#
use t::APISIX 'no_plan';
repeat_each(1);
no_long_string();
no_root_location();
add_block_preprocessor(sub {
my ($block) = @_;
if (!$block->request) {
$block->set_value("request", "GET /t");
}
if ((!defined $block->error_log) && (!defined $block->no_error_log)) {
$block->set_value("no_error_log", "[error]");
}
});
run_tests;
__DATA__
=== TEST 1: required_acks, matches none of the enum values
--- config
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.kafka-logger")
local ok, err = plugin.check_schema({
broker_list = {
["127.0.0.1"] = 3000
},
required_acks = 10,
kafka_topic ="test",
key= "key1"
})
if not ok then
ngx.say(err)
end
ngx.say("done")
}
}
--- response_body
property "required_acks" validation failed: matches none of the enum values
done
=== TEST 2: report log to kafka, with required_acks(1, 0, -1)
--- config
location /t {
content_by_lua_block {
local data = {
{
input = {
plugins = {
["kafka-logger"] = {
broker_list = {
["127.0.0.1"] = 9092
},
kafka_topic = "test2",
producer_type = "sync",
timeout = 1,
batch_max_size = 1,
required_acks = 1,
meta_format = "origin",
}
},
upstream = {
nodes = {
["127.0.0.1:1980"] = 1
},
type = "roundrobin"
},
uri = "/hello",
},
},
{
input = {
plugins = {
["kafka-logger"] = {
broker_list = {
["127.0.0.1"] = 9092
},
kafka_topic = "test2",
producer_type = "sync",
timeout = 1,
batch_max_size = 1,
required_acks = -1,
meta_format = "origin",
}
},
upstream = {
nodes = {
["127.0.0.1:1980"] = 1
},
type = "roundrobin"
},
uri = "/hello",
},
},
{
input = {
plugins = {
["kafka-logger"] = {
broker_list = {
["127.0.0.1"] = 9092
},
kafka_topic = "test2",
producer_type = "sync",
timeout = 1,
batch_max_size = 1,
required_acks = 0,
meta_format = "origin",
}
},
upstream = {
nodes = {
["127.0.0.1:1980"] = 1
},
type = "roundrobin"
},
uri = "/hello",
},
},
}
local t = require("lib.test_admin").test
local err_count = 0
for i in ipairs(data) do
local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT, data[i].input)
if code >= 300 then
err_count = err_count + 1
end
ngx.print(body)
t('/hello', ngx.HTTP_GET)
end
assert(err_count == 0)
}
}
--- error_log
send data to kafka: GET /hello
send data to kafka: GET /hello
send data to kafka: GET /hello
=== TEST 3: update the broker_list and cluster_name, generate different kafka producers
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]]
)
ngx.sleep(0.5)
if code >= 300 then
ngx.status = code
ngx.say("fail")
return
end
code, body = t('/apisix/admin/global_rules/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"kafka-logger": {
"broker_list" : {
"127.0.0.1": 9092
},
"kafka_topic" : "test2",
"timeout" : 1,
"batch_max_size": 1,
"include_req_body": false,
"cluster_name": 1
}
}
}]]
)
if code >= 300 then
ngx.status = code
ngx.say("fail")
return
end
t('/hello',ngx.HTTP_GET)
ngx.sleep(0.5)
code, body = t('/apisix/admin/global_rules/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"kafka-logger": {
"broker_list" : {
"127.0.0.1": 19092
},
"kafka_topic" : "test4",
"timeout" : 1,
"batch_max_size": 1,
"include_req_body": false,
"cluster_name": 2
}
}
}]]
)
if code >= 300 then
ngx.status = code
ngx.say("fail")
return
end
t('/hello',ngx.HTTP_GET)
ngx.sleep(0.5)
ngx.sleep(2)
ngx.say("passed")
}
}
--- timeout: 10
--- response
passed
--- wait: 5
--- error_log
phase_func(): kafka cluster name 1, broker_list[1] port 9092
phase_func(): kafka cluster name 2, broker_list[1] port 19092
--- no_error_log eval
qr/not found topic/
=== TEST 4: use the topic that does not exist on kafka(even if kafka allows auto create topics, first time push messages to kafka would got this error)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/global_rules/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"kafka-logger": {
"broker_list" : {
"127.0.0.1": 9092
},
"kafka_topic" : "undefined_topic",
"timeout" : 1,
"batch_max_size": 1,
"include_req_body": false
}
}
}]]
)
if code >= 300 then
ngx.status = code
ngx.say("fail")
return
end
t('/hello',ngx.HTTP_GET)
ngx.sleep(0.5)
ngx.sleep(2)
ngx.say("passed")
}
}
--- timeout: 5
--- response
passed
--- error_log eval
qr/not found topic, retryable: true, topic: undefined_topic, partition_id: -1/
=== TEST 5: check broker_list via schema
--- config
location /t {
content_by_lua_block {
local data = {
{
input = {
broker_list = {},
kafka_topic = "test",
key= "key1",
},
},
{
input = {
broker_list = {
["127.0.0.1"] = "9092"
},
kafka_topic = "test",
key= "key1",
},
},
{
input = {
broker_list = {
["127.0.0.1"] = 0
},
kafka_topic = "test",
key= "key1",
},
},
{
input = {
broker_list = {
["127.0.0.1"] = 65536
},
kafka_topic = "test",
key= "key1",
},
},
}
local plugin = require("apisix.plugins.kafka-logger")
local err_count = 0
for i in ipairs(data) do
local ok, err = plugin.check_schema(data[i].input)
if not ok then
err_count = err_count + 1
ngx.say(err)
end
end
assert(err_count == #data)
}
}
--- response_body
property "broker_list" validation failed: expect object to have at least 1 properties
property "broker_list" validation failed: failed to validate 127.0.0.1 (matching ".*"): wrong type: expected integer, got string
property "broker_list" validation failed: failed to validate 127.0.0.1 (matching ".*"): expected 0 to be greater than 1
property "broker_list" validation failed: failed to validate 127.0.0.1 (matching ".*"): expected 65536 to be smaller than 65535
=== TEST 6: kafka brokers info in log
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"kafka-logger": {
"broker_list" :
{
"127.0.0.127":9092
},
"kafka_topic" : "test2",
"producer_type": "sync",
"key" : "key1",
"batch_max_size": 1,
"cluster_name": 10
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
local http = require "resty.http"
local httpc = http.new()
local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello"
local res, err = httpc:request_uri(uri, {method = "GET"})
}
}
--- error_log_like eval
qr/create new kafka producer instance, brokers: \[\{"port":9092,"host":"127.0.0.127"}]/
qr/failed to send data to Kafka topic: .*, brokers: \{"127.0.0.127":9092}/
=== TEST 7: set route(id: 1,include_req_body = true,include_req_body_expr = array)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[=[{
"plugins": {
"kafka-logger": {
"broker_list" :
{
"127.0.0.1":9092
},
"kafka_topic" : "test2",
"key" : "key1",
"timeout" : 1,
"include_req_body": true,
"include_req_body_expr": [
[
"arg_name",
"==",
"qwerty"
]
],
"batch_max_size": 1
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]=]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed
=== TEST 8: hit route, expr eval success
--- request
POST /hello?name=qwerty
abcdef
--- response_body
hello world
--- error_log eval
qr/send data to kafka: \{.*"body":"abcdef"/
--- wait: 2
=== TEST 9: hit route,expr eval fail
--- request
POST /hello?name=zcxv
abcdef
--- response_body
hello world
--- no_error_log eval
qr/send data to kafka: \{.*"body":"abcdef"/
--- wait: 2
=== TEST 10: check log schema(include_req_body)
--- config
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.kafka-logger")
local ok, err = plugin.check_schema({
kafka_topic = "test",
key = "key1",
broker_list = {
["127.0.0.1"] = 3
},
include_req_body = true,
include_req_body_expr = {
{"bar", "<>", "foo"}
}
})
if not ok then
ngx.say(err)
end
ngx.say("done")
}
}
--- response_body
failed to validate the 'include_req_body_expr' expression: invalid operator '<>'
done
=== TEST 11: check log schema(include_resp_body)
--- config
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.kafka-logger")
local ok, err = plugin.check_schema({
kafka_topic = "test",
key = "key1",
broker_list = {
["127.0.0.1"] = 3
},
include_resp_body = true,
include_resp_body_expr = {
{"bar", "<!>", "foo"}
}
})
if not ok then
ngx.say(err)
end
ngx.say("done")
}
}
--- response_body
failed to validate the 'include_resp_body_expr' expression: invalid operator '<!>'
done
=== TEST 12: set route(id: 1,include_resp_body = true,include_resp_body_expr = array)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[=[{
"plugins": {
"kafka-logger": {
"broker_list" :
{
"127.0.0.1":9092
},
"kafka_topic" : "test2",
"key" : "key1",
"timeout" : 1,
"include_resp_body": true,
"include_resp_body_expr": [
[
"arg_name",
"==",
"qwerty"
]
],
"batch_max_size": 1
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]=]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed
=== TEST 13: hit route, expr eval success
--- request
POST /hello?name=qwerty
abcdef
--- response_body
hello world
--- error_log eval
qr/send data to kafka: \{.*"body":"hello world\\n"/
--- wait: 2
=== TEST 14: hit route,expr eval fail
--- request
POST /hello?name=zcxv
abcdef
--- response_body
hello world
--- no_error_log eval
qr/send data to kafka: \{.*"body":"hello world\\n"/
--- wait: 2
| 30.44281 | 151 | 0.371209 |
ed2107f20062cd147c108168468990bd404577e6 | 5,148 | pm | Perl | lib/audit_test.pm | JoyceNa/os-autoinst-distri-opensuse | 91552318906538c92e71b4821bbff37a125545d3 | [
"FSFAP"
]
| null | null | null | lib/audit_test.pm | JoyceNa/os-autoinst-distri-opensuse | 91552318906538c92e71b4821bbff37a125545d3 | [
"FSFAP"
]
| 1 | 2018-11-06T03:12:09.000Z | 2018-11-06T03:12:09.000Z | lib/audit_test.pm | JoyceNa/os-autoinst-distri-opensuse | 91552318906538c92e71b4821bbff37a125545d3 | [
"FSFAP"
]
| null | null | null | # SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# Summary: Base module for audit-test test cases
# Maintainer: llzhao <llzhao@suse.com>
package audit_test;
use base Exporter;
use strict;
use warnings;
use testapi;
use utils;
use Mojo::File 'path';
use Mojo::Util 'trim';
our @EXPORT = qw(
$testdir
$testfile_tar
$baseline_file
$code_repo
$mode
get_testsuite_name
run_testcase
compare_run_log
parse_lines
);
our $testdir = '/tmp/';
our $code_repo = get_var('CODE_BASE', 'https://gitlab.suse.de/security/audit-test-sle15/-/archive/master/audit-test-sle15-master.tar');
our $testfile_tar = 'audit-test-sle15-master';
our $mode = get_var('MODE', 64);
# $current_file: current output file name; $baseline_file: baseline file name
our $current_file = 'run.log';
our $baseline_file = 'baseline_run.log';
# Run the specific test case
# input: $testcase - test case name (the actual test case name is in corresponding 'audit-test' test suite,
# e.g. "kvm", 'audit-tools', 'syscalls')
sub run_testcase {
my ($testcase, %args) = @_;
# Run test case
assert_script_run("cd ${testdir}${testfile_tar}/audit-test/");
assert_script_run('make') if ($args{make});
assert_script_run("cd ${testcase}/");
# Export MODE
assert_script_run("export MODE=$audit_test::mode");
# Test case 'audit-remote-libvirt' does not generate any logs
if ($testcase eq 'audit-remote-libvirt') {
# Note: the outputs of run.bash can not be saved to "./$file" so save to "../$file"
script_run("./run.bash 1>../$current_file 2>&1", timeout => $args{timeout});
assert_script_run("mv ../$current_file $current_file");
assert_script_run("cat $current_file");
assert_script_run("cp $current_file ./rollup.log");
}
else {
assert_script_run('./run.bash', timeout => $args{timeout});
}
# Upload logs
upload_logs("$current_file");
upload_logs("$baseline_file");
}
sub parse_lines {
my ($lines) = @_;
my @results;
foreach my $line (@$lines) {
if ($line =~ /(\[\d+\])\s+(.*)\s+(PASS|FAIL|ERROR)/) {
my $name = trim $2;
push @results, {id => $1, name => $name, result => $3};
}
}
return @results;
}
# Compare baseline testing result and current testing result
# input: $testcase - test case name (the test module name in openQA code,
# if test module is 'audit_tools.pm' then $testcase = audit_tools, etc)
sub compare_run_log {
my ($testcase) = @_;
# Read the current test result from rollup.log
my $output = script_output('cat ./rollup.log');
my @lines = split(/\n/, $output);
my @current_results = parse_lines(\@lines);
my %baseline_results;
my $baseline_file = "ulogs/$testcase-baseline_run.log";
if (!-e $baseline_file) {
diag "The file $baseline_file does not exist";
}
else {
my @lines = split(/\n/, path("$baseline_file")->slurp);
%baseline_results = map { $_->{name} => {id => $_->{id}, result => $_->{result}} } parse_lines(\@lines);
}
my $flag = 'ok';
foreach my $current_result (@current_results) {
my $c_id = $current_result->{id};
my $c_result = $current_result->{result};
my $key = $current_result->{name};
unless ($baseline_results{$key}) {
my $msg = "poo#93441\nNo baseline found(defined).\n$c_id $key $c_result";
$flag = _parse_results_with_diff_baseline($key, $c_result, $msg, $flag);
next;
}
my $b_id = $baseline_results{$key}->{id};
my $b_result = $baseline_results{$key}->{result};
if ($c_result ne $b_result) {
my $info = "poo#93441\nTest result is NOT same as baseline \nCurrent: $c_id $key $c_result\nBaseline: $b_id $key $b_result";
$flag = _parse_results_with_diff_baseline($key, $c_result, $info, $flag);
next;
}
record_info($key, "Test result is the same as baseline\n$c_id $key $c_result", result => 'ok');
}
return $flag;
}
# When the current result is different with baseline, according to current result
# the test result shown on openQA is different.
# Rules for test result
# No baseline:
# Current result test result shown on openQA
# PASS softfail
# ERROR fail
# FAIL fail
#
# different with baseline:
# Current result Baseline test result shown on openQA
# PASS FAIL/ERROR softfail
# FAIL PASS/ERROR fail
# ERROR PASS/FAIL fail
#
sub _parse_results_with_diff_baseline {
my ($name, $result, $msg, $flag) = @_;
if ($result eq 'PASS') {
record_soft_failure($msg);
$flag = 'softfail' if ($flag ne 'fail');
}
else {
record_info($name, $msg, result => 'fail');
$flag = 'fail';
}
return $flag;
}
1;
| 32.175 | 138 | 0.621795 |
ed556ecb05756632dc8a2a4913a9f786822d3a5d | 5,802 | pl | Perl | usr/libexec/emlog.pl | artful-addict/kh-squared-coming-soon | 10432cf26d76824eb527b63e3210fe1a31498473 | [
"MIT"
]
| null | null | null | usr/libexec/emlog.pl | artful-addict/kh-squared-coming-soon | 10432cf26d76824eb527b63e3210fe1a31498473 | [
"MIT"
]
| null | null | null | usr/libexec/emlog.pl | artful-addict/kh-squared-coming-soon | 10432cf26d76824eb527b63e3210fe1a31498473 | [
"MIT"
]
| null | null | null | #!/usr/bin/perl -T
#
# Copyright (c) 2013 Apple Inc. All Rights Reserved.
#
# IMPORTANT NOTE: This file is licensed only for use on Apple-branded
# computers and is subject to the terms and conditions of the Apple Software
# License Agreement accompanying the package this file is a part of.
# You may not port this file to another platform without Apple's written consent.
#
# Log scraper
# takes input from a local socket with the -p option or from stdin or with a -l to only process one line from stdin
#
# grabs errors from ssh & ftpd
#
use Socket;
use IO::Socket;
use strict;
use warnings;
use constant MAX_MSG_LEN => 5000;
my $OUTSTREAM;
$SIG{'INT'} = sub { exit 0 };
{
delete @ENV{qw(IFS CDPATH PATH ENV BASH_ENV)}; # clean up the path
open $OUTSTREAM, "|/usr/libexec/xssendevent" or die "Cannot launch /usr/libexec/xssendevent $!";
while (<STDIN>) {
processMessage($_);
if(($#ARGV > 1) && ($ARGV[0] eq '-l')) # have we been launched by launchd? if so we are only interested in one line (for now...)
{
exit 0;
}
} # end loop
}
# resolveAddress(string)
sub resolveAddress
{
my $hent;
#print "resolving " . $_[0] . "\n";
$hent = gethostbyname($_[0]);
if(defined $hent)
{
return inet_ntoa($hent);
} else {
return $_[0];
}
};
# processMessage(string)
# need to cope with the RFC5424 changes to the message line:
# they encode the Facility & Priority at the beginning in angle brackets, overwriting
# the day name. e.g. "<83>Feb 17" rather than "Wed Feb 17"
#
# if the log string begins with '<' one to three digits '>' letter*
# replace with the original contents with a space between the '>' and the next char
# e.g. insert a space
sub processMessage
{
my $username = "";
my $address = "";
my $eventString = "";
my $logLine = $_[0];
$logLine =~ s/^(<\d{1,3}>)(\S)/$1 $2/;
my @fields = split(' ',$logLine);
my $totalFields = @fields;
if($totalFields < 6)
{
return 0;
}
# Below are some examples of log scraping for sshd & ftp.
if($fields[4] =~ /sshd/) # process sshd messages
{
if(($fields[5] eq "Received") &&
($fields[6] eq "disconnect") &&
($fields[11] eq "Bye"))
{
$address = $fields[8];
#remove the trailing ':'
chop($address);
#print "address is " . $address . "\n";
$eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {clientIP = \"$address\"; protocolName = \"SSH\";};}";
}
elsif(($fields[5] eq "Invalid") && ($fields[6] eq "user"))
{
$address = $fields[$totalFields - 1];
#print "address is " . $address . "\n";
$eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {clientIP = \"$address\"; protocolName = \"SSH\";};}";
}
# old checks, subsumed by the BSM audit mechanism
#
# if(($fields[6] eq "error:") && ($fields[7] eq "PAM:"))
# {
# if(($fields[8] eq "Authentication") || ($fields[8] eq "authentication") )
# {
# $username = $fields[13];
# if($fields[$totalFields - 2] eq "via")
# {
# $address = resolveAddress($fields[$totalFields - 3]);
# } else {
# $address = resolveAddress($fields[$totalFields - 1]);
# }
# } else {
# $username = $fields[13];
# if($fields[$totalFields - 2] eq "via")
# {
# $address = resolveAddress($fields[$totalFields - 3]);
# } else {
# $address = resolveAddress($fields[$totalFields - 1]);
# }
# }
# $username =~ tr/A-Za-z0-9_-//cd;
# $address =~ tr/\[\]:%A-Za-z0-9.//cd;
# $eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {username = \"$username\"; clientIP = \"$address\"; protocolName = \"SSH\";};}";
#}
#elsif($fields[6] eq "Failed")
#{
# if($fields[7] eq "none")
# {
# $username = $fields[11];
# $address = resolveAddress($fields[$totalFields - 1]);
# } else {
# $username = $fields[11];
# $address = resolveAddress($fields[$totalFields - 4]);
# }
# $username =~ tr/A-Za-z0-9_-//cd;
# $address =~ tr/\[\]:%A-Za-z0-9.//cd;
# $eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {username = \"$username\"; clientIP = \"$address\"; protocolName = \"SSH\";};}";
#
#}
#elsif ($fields[6] eq "Invalid" && $fields[7] eq "user")
#{
# $username = $fields[8];
# $address = resolveAddress($fields[$totalFields - 1]);
# $username =~ tr/A-Za-z0-9_-//cd;
# $address =~ tr/\[\]:%A-Za-z0-9.//cd;
# $eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {username = \"$username\"; clientIP = \"$address\"; protocolName = \"SSH\";};}";
#}
#elsif($fields[6] eq "Accepted")
#{
# $username = $fields[9];
# $address = resolveAddress($fields[$totalFields - 4]);
# $username =~ tr/A-Za-z0-9_-//cd;
# $address =~ tr/\[\]:%A-Za-z0-9.//cd;
# $eventString = "{ eventType = auth.success; eventSource = emlog.pl; eventDetails = {username = \"$username\"; clientIP = \"$address\"; protocolName = \"SSH\";};}";
#}
#elsif(($fields[6] eq "Did") && ($fields[7] eq "not") && ($fields[9] eq "identification"))
#{
# $address = resolveAddress($fields[$totalFields - 1]);
# $address =~ tr/\[\]:%A-Za-z0-9.//cd;
# $eventString = "{ eventType = network.probe; eventSource = emlog.pl; eventDetails = #{sourceIP = \"$address\"; port = 22;};}";
#}
if(!$eventString eq "") {
print $OUTSTREAM $eventString;
print $OUTSTREAM "\n";
#print $eventString . "\n";
}
}
if(0)
#if($fields[5] =~ /ftpd/)
{
if(($fields[6] eq "Failed") && ($fields[7] eq "authentication"))
{
my $addr = $fields[10];
$addr =~ s/\[//;
$addr =~ s/\]//;
$eventString = "{ eventType = auth.failure; eventSource = emlog.pl; eventDetails = {clientIP = \"$addr\"; hostPort = 21; protocolName = \"ftp\";};}";
}
if(!$eventString eq "") {
print $OUTSTREAM $eventString;
print $OUTSTREAM "\n";
#print $eventString . "\n";
}
}
};
| 29.753846 | 165 | 0.604274 |
ed1f0a6c31524e704b505cec56df7753ef880faf | 1,157 | t | Perl | t/01-basic.t | dionys/path-tiny-archive-tar | fe6b1f223a11e0bee8753fdaae060a14e80ffba7 | [
"Artistic-1.0"
]
| null | null | null | t/01-basic.t | dionys/path-tiny-archive-tar | fe6b1f223a11e0bee8753fdaae060a14e80ffba7 | [
"Artistic-1.0"
]
| null | null | null | t/01-basic.t | dionys/path-tiny-archive-tar | fe6b1f223a11e0bee8753fdaae060a14e80ffba7 | [
"Artistic-1.0"
]
| null | null | null | #!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Path::Tiny qw( tempdir );
use Path::Tiny::Archive::Tar ();
my $s = tempdir();
my $d = tempdir();
can_ok $s, qw( tar tgz tbz2 untar );
$s->child('foo.txt')->spew('Foo');
$s->child('bar')->mkpath();
ok $s->child('foo.txt')->tar($d->child('foo1.tar'));
ok $s->tar($d->child('foo2.tar'));
is_deeply [ sort map { $_->basename } $d->children ], [ qw( foo1.tar foo2.tar ) ];
for ($d->children) {
ok $_->is_file;
ok $_->stat->size;
}
cleanup_dir($s);
ok $d->child('foo1.tar')->untar($s);
is_deeply [ sort map { $_->basename } $s->children ], [ qw( foo.txt ) ];
ok $s->child('foo.txt')->is_file;
is $s->child('foo.txt')->slurp(), 'Foo';
cleanup_dir($s);
ok $d->child('foo2.tar')->untar($s);
is_deeply [ sort map { $_->basename } $s->children ], [ qw( bar foo.txt ) ];
ok $s->child('foo.txt')->is_file;
is $s->child('foo.txt')->slurp(), 'Foo';
ok $s->child('bar')->is_dir;
done_testing;
sub cleanup_dir {
for ($_[0]->children) {
if ($_->is_file) {
$_->remove();
}
elsif ($_->is_dir) {
$_->remove_tree();
}
}
}
| 19.283333 | 82 | 0.545376 |
ed2960eaa90b26a567f968fa6e4550e3549c2168 | 2,807 | pl | Perl | build/zoneinfo2lua.pl | tluyou/openwrtbb-luci | d30f4865b0ee5fcc1456975843d2cd5501201f0a | [
"Apache-2.0"
]
| 1 | 2021-10-17T10:54:32.000Z | 2021-10-17T10:54:32.000Z | build/zoneinfo2lua.pl | tluyou/openwrtbb-luci | d30f4865b0ee5fcc1456975843d2cd5501201f0a | [
"Apache-2.0"
]
| null | null | null | build/zoneinfo2lua.pl | tluyou/openwrtbb-luci | d30f4865b0ee5fcc1456975843d2cd5501201f0a | [
"Apache-2.0"
]
| 2 | 2017-10-14T07:18:34.000Z | 2019-09-18T01:18:30.000Z | #!/usr/bin/perl
# zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo
# Execute from within root of Luci feed, usually feeds/luci
# $Id$
use strict;
my %TZ;
my $tzdin = $ARGV[0] || "/usr/share/zoneinfo";
my $tzdout = $ARGV[1] || "./modules/base/luasrc/sys/zoneinfo";
local $/ = "\012";
open( ZTAB, "< $tzdin/zone.tab" ) || die "open($tzdin/zone.tab): $!";
while( ! eof ZTAB ) {
chomp( my $line = readline ZTAB );
next if $line =~ /^#/ || $line =~ /^\s+$/;
my ( undef, undef, $zone, @comment ) = split /\s+/, $line;
printf STDERR "%-40s", $zone;
if( open ZONE, "< $tzdin/$zone" ) {
seek ZONE, -2, 2;
while( tell(ZONE) > 0 ) {
read ZONE, my $char, 1;
( $char eq "\012" ) ? last : seek ZONE, -2, 1;
}
chomp( my $tz = readline ZONE );
print STDERR ( $tz || "(no tzinfo found)" ), "\n";
close ZONE;
if( $tz ) {
$zone =~ s/_/ /g;
$TZ{$zone} = $tz;
}
}
else
{
print STDERR "open($tzdin/$zone): $!\n";
}
}
close ZTAB;
open(O, "> $tzdout/tzdata.lua") || die "open($tzdout/tzdata.lua): $!\n";
print STDERR "Writing time zones to $tzdout/tzdata.lua ... ";
print O <<HEAD;
-- Licensed to the public under the Apache License 2.0.
module "luci.sys.zoneinfo.tzdata"
TZ = {
HEAD
foreach my $zone ( sort keys %TZ ) {
printf O "\t{ '%s', '%s' },\n", $zone, $TZ{$zone}
}
print O "}\n";
close O;
print STDERR "done\n";
open (O, "> $tzdout/tzoffset.lua") || die "open($tzdout/tzoffset.lua): $!\n";
print STDERR "Writing time offsets to $tzdout/tzoffset.lua ... ";
print O <<HEAD;
-- Licensed to the public under the Apache License 2.0.
module "luci.sys.zoneinfo.tzoffset"
OFFSET = {
HEAD
my %seen;
foreach my $tz ( sort keys %TZ ) {
my $zone = $TZ{$tz};
if( $zone =~ /^
([A-Z]+)
(?:
( -? \d+ (?: : \d+ )? )
(?:
([A-Z]+)
( -? \d+ (?: : \d+ )? )?
)?
)?
\b /xo ) {
my ( $offset, $s, $h, $m ) = ( 0, 1, 0, 0 );
my ( $std, $soffset, $dst, $doffset ) = ( $1, $2, $3, $4 );
next if $seen{$std}; # and ( !$dst or $seen{$dst} );
if ( $soffset ) {
( $s, $h, $m ) = $soffset =~ /^(-)?(\d+)(?::(\d+))?$/;
$s = $s ? 1 : -1;
$h ||= 0;
$m ||= 0;
$offset = $s * $h * 60 * 60;
$offset += $s * $m * 60;
printf O "\t%-5s = %6d,\t-- %s\n",
lc($std), $offset, $std;
$seen{$std} = 1;
if( $dst ) {
if( $doffset ) {
( $s, $h, $m ) = $doffset =~ /^(-)?(\d+)(?::(\d+))?$/;
$s = $s ? 1 : -1;
$h ||= 0;
$m ||= 0;
$offset = $s * $h * 60 * 60;
$offset += $s * $m * 60;
} else {
$offset += 60 * 60;
}
printf O "\t%-5s = %6d,\t-- %s\n",
lc($dst), $offset, $dst;
$seen{$dst} = 1;
}
}
else {
printf O "\t%-5s = %6d,\t-- %s\n",
lc($std), $offset, $std;
$seen{$std} = 1;
}
}
}
print O "}\n";
close O;
print STDERR "done\n";
| 18.713333 | 77 | 0.481297 |
ed3023039109e20699791f6afb86153d94f7d423 | 5,293 | pl | Perl | lib/monitor.pl | rpaditya/trmon | 10b3e03f3087b7843d70098cecaef8640fec61a6 | [
"MIT"
]
| 1 | 2016-01-28T11:50:05.000Z | 2016-01-28T11:50:05.000Z | lib/monitor.pl | rpaditya/trmon | 10b3e03f3087b7843d70098cecaef8640fec61a6 | [
"MIT"
]
| null | null | null | lib/monitor.pl | rpaditya/trmon | 10b3e03f3087b7843d70098cecaef8640fec61a6 | [
"MIT"
]
| null | null | null | # Copyright (C) 2000-2005 by R.P. Aditya <aditya@grot.org>
# (See "License", below.)
#
# License:
# 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 2
# of the License, or (at your option) any later version.
#
# 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. See the
# GNU General Public License for more details.
#
# You may have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# An on-line copy of the GNU General Public License can be found
# http://www.fsf.org/copyleft/gpl.html.
use strict;
local $| = 1;
use vars qw($config);
use Digest::MD5 qw(md5 md5_hex md5_base64);
use Time::HiRes;
use LWP::UserAgent;
use Sys::Syslog;
#Sys::Syslog::setlogsock('unix');
use RRDs;
$config->{'STEP'} = 300;
$config->{'DEBUG'} = 0;
$config->{'timeout'} = 15;
if (! defined $main::config->{'logfacility'}){
$config->{'logfacility'} = 'user';
}
sub check_httpd {
my($url, $username, $pwd, $timeout) = @_;
my($rval) = 0;
my($ua) = new LWP::UserAgent;
$ua->timeout($timeout);
my($start) = Time::HiRes::time ();
my($request) = HTTP::Request->new(GET => $url);
my($tcp_end) = Time::HiRes::time ();
$request->authorization_basic($username, $pwd);
my($response) = $ua->request($request);
my($finish) = Time::HiRes::time ();
my($content) = $ua->request($request)->content;
$rval = $response->is_success - $response->is_error;
my($contentsize) = length($content);
my($md5) = md5_base64($content);
undef $ua;
return($rval, $response->code, $response->status_line, $start, $tcp_end, $finish, $contentsize, $content, $md5);
}
sub updateRRD {
my($RRD, $t, @vals) = @_;
if (! -e $RRD){
return(1, "could not find ${RRD}");
} else {
# my($lastUpdate) = RRDs::last($RRD);
# if (my $error = RRDs::error()){
# return(1, "RRDs::last failed on $RRD: $error");
# }
#
# #when the last update should have minimally happened
# my($difference) = (time - $config->{'STEP'} + $config->{'timeout'});
#
# #if the last update was more recent (>) when it should have happened, skip
# if ($lastUpdate > $difference){
# if ($config->{'DEBUG'} >= 10){
# notify('err', "skip $RRD lastUpdate $lastUpdate > $difference");
# }
# return (1, "skip $RRD lastUpdate $lastUpdate > $difference");
# }
my($vallist) = $t . ":" . join(':', @vals);
RRDs::update("$RRD", "$vallist");
if (my $error = RRDs::error()) {
return(1, "RRDs::update - $RRD [$error] (${vallist})");
} else {
return(0, "OK");
}
}
}
sub notify {
my($severity, $mesg, $who, $longmsg) = @_;
if (! $who){
$who = "";
}
if (! $longmsg){
$longmsg = $mesg;
}
my($useverity) = uc($severity);
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon += 1;
my($timestamp) = sprintf("%02d-%02d %02d:%02d:%02d", $mon, $mday, $hour, $min, $sec);
my($pid) = $$;
if ($severity eq "debug"){
if ($config->{'DEBUG'}){
print STDERR "${useverity}: ($timestamp): $mesg\n";
}
} else {
syslog($severity, "${useverity}: $mesg");
if ($severity eq "emerg" || $severity eq "crit"){
if ($who ne ""){
my($rv, $errmsg) = &sendmail($who, $who, "$mesg (${useverity})", $longmsg)
;
if ($rv){
syslog('crit', "CRIT: could not send email to ${who} (${errmsg})");
}
}
#
# send an snmp trap
#
# my($trapdest) = "$config->{'snmpTrapCommunity'}\@$config->{'snmpTrapHost'}";
# snmptrap($trapdest, enterpriseOID,
# agent, generalID, specificID, OID, type, value,
# [OID, type, value ...])
}
}
}
sub sendmail {
my($to, $from, $subject, $msg) = @_;
if (! $msg){
$msg = $subject;
}
open MAIL,"| /usr/sbin/sendmail -t -oi" or return (1, "Couldn't pipe to sendmail: $!");
print MAIL <<"MAIL";
To: ${to}
From: ${from}
Reply-To: ${from}
Subject: ${subject}
-------------8<----------cut here----------------8<-----------------
${msg}
-------------8<----------cut here----------------8<-----------------
MAIL
close MAIL or return(1, "Couldn't close sendmail pipe: $!");
return(0, "okay");
}
sub pgrep {
my($string) = @_;
my(@pid) = `/bin/ps auxwww | /usr/bin/egrep "${string}"`;
for my $l (@pid){
chomp($l);
my($u, $pid, $cpu, $mem, $vsz, $rss, $tt, $stat, $started, $time, @cmd) = split(/\s+/, $l);
my($cmdstring) = join(' ', @cmd);
next if ($cmdstring =~ /grep/);
return($pid, $u, $cmdstring);
}
}
1;
| 29.903955 | 116 | 0.527867 |
73d4c338c608959493523667a16f6e01d23846f0 | 7,281 | pm | Perl | users/modules/EnsEMBL/Users/Messages.pm | andrewyatz/public-plugins | c3c0c2d71a9ba4ffdc756553b5461a14eb9228f3 | [
"Apache-2.0"
]
| null | null | null | users/modules/EnsEMBL/Users/Messages.pm | andrewyatz/public-plugins | c3c0c2d71a9ba4ffdc756553b5461a14eb9228f3 | [
"Apache-2.0"
]
| null | null | null | users/modules/EnsEMBL/Users/Messages.pm | andrewyatz/public-plugins | c3c0c2d71a9ba4ffdc756553b5461a14eb9228f3 | [
"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
package EnsEMBL::Users::Messages;
### @usage
### use EnsEMBL::Users::Messages qw(ALL); # is same as use EnsEMBL::Users::Messages; # will include all the message constants, but not the get_message method
### use EnsEMBL::Users::Messages qw(get_message); # will only include the get_message method, no message constants
### use EnsEMBL::Users::Messages qw(ALL get_message); # will include all message constants and the get_message method
### use EnsEMBL::Users::Messages qw(MESSAGE_PASSWORD_WRONG); # will only include only the specified message constant - could be multiple
use strict;
use warnings;
use HTML::Entities qw(encode_entities);
use Digest::MD5 qw(md5_hex);
my %MESSAGES = (
MESSAGE_OPENID_CANCELLED => sub { sprintf('Your request to login via %s was cancelled', encode_entities($_[0]->param('provider') || 'OpenID')) },
MESSAGE_OPENID_INVALID => sub { '_message__OPENID_INVALID' },
MESSAGE_OPENID_SETUP_NEEDED => sub { '_message__OPENID_SETUP_NEEDED' },
MESSAGE_OPENID_ERROR => sub { 'OpenID error', sprintf('<p>An error happenned while making OpenID request.</p><p>Error summary: %s</p>', encode_entities($_[0]->param('oerr') || '')) },
MESSAGE_OPENID_EMAIL_MISSING => sub { '_message__OPENID_EMAIL_MISSING' },
MESSAGE_EMAIL_NOT_FOUND => sub { 'Email not found', sprintf('The email address provided is not recognised. Please try again with a different email or <a href="%s">register</a> here if you are a new user.', encode_entities($_[0]->url({'type' => 'Account', 'action' => 'Register', 'email' => $_[0]->param('email') || ''}))) },
MESSAGE_PASSWORD_WRONG => sub { 'Wrong password', 'The password provided is invalid. Please try again.' },
MESSAGE_PASSWORD_INVALID => sub { 'Invalid password', 'Password needs to be atleast 6 characters long.' },
MESSAGE_PASSWORD_MISMATCH => sub { 'Password mismatch', 'The passwords do not match. Please try again.' },
MESSAGE_PASSWORD_CHANGED => sub { 'Password saved', 'New password has been saved successfully. Please login with the new password.' },
MESSAGE_ALREADY_REGISTERED => sub { sprintf('The email address provided seems to be already registered. Please try to login with the email, or request to <a href="%s">retrieve your password</a> if you have lost one.', $_[0]->url({'action' => 'Password', 'function' => 'Lost', 'email' => $_[0]->param('email') || ''})) },
MESSAGE_VERIFICATION_FAILED => sub { 'Verification failed', 'The email address could not be verified.' },
MESSAGE_VERIFICATION_PENDING => sub { 'Verification pending', 'The email address has yet not been verified.' },
MESSAGE_EMAIL_INVALID => sub { 'Invalid email', 'Please enter a valid email address' },
MESSAGE_EMAILS_INVALID => sub { 'Invalid email address', sprintf('Following email address(es) are not valid: %s', encode_entities($_[0]->param('invalids') || '')) },
MESSAGE_NAME_MISSING => sub { 'Please provide a name' },
MESSAGE_ACCOUNT_BLOCKED => sub { 'Your account seems to be blocked. Please contact the helpdesk in case you need any help.' },
MESSAGE_VERIFICATION_SENT => sub { sprintf(q(A verification email has been sent to the email address '%s'. Please go to your inbox and click on the link provided in the email.), encode_entities($_[0]->param('email'))) },
MESSAGE_PASSWORD_EMAIL_SENT => sub { sprintf(q(An email has been sent to the email address '%s'. Please go to your inbox and follow the instructions to reset your password provided in the email.), encode_entities($_[0]->param('email'))) },
MESSAGE_EMAIL_CHANGED => sub { sprintf(q(You email address on our records has been successfully changed. Please <a href="%s">%s</a> to continue.), $_[0]->user ? ($_[0]->PREFERENCES_PAGE, 'click here') : ($_[0]->url({qw(type Account action Login)}), 'login')) },
MESSAGE_CANT_DELETE_LOGIN => sub { 'You can not delete the only login option you have to access your account.' },
MESSAGE_GROUP_NOT_FOUND => sub { 'Sorry, we could not find the specified group. Either the group does not exist or is inactive or is inaccessible to you for the action selected.' },
MESSAGE_GROUP_INACTIVE => sub { 'Group inactive', 'This group is inactive. To perform the action selected, please activate the group first.'},
MESSAGE_NO_GROUP_SELECTED => sub { 'No group selected', 'Please select a group.' },
MESSAGE_GROUP_INVITATION_SENT => sub { sprintf(q{Invitation for the group sent successfully to the following email(s): %s}, encode_entities($_[0]->param('emails'))) },
MESSAGE_NO_BOOKMARK_SELECTED => sub { 'No bookmark selected', 'Please select a bookmark.' },
MESSAGE_CANT_DEMOTE_ADMIN => sub { 'Not allowed', 'Sorry, you can not demote yourself as you seem to be the only administrator of this group.' },
MESSAGE_BOOKMARK_NOT_FOUND => sub { 'Bookmark not found', 'Sorry, we could not find the specified bookmark.' },
MESSAGE_CANT_DELETE_BOOKMARK => sub { 'Not allowed', 'You do not seem to have the right to delete this bookmark.' },
MESSAGE_NO_EXISTING_ACCOUNT => sub { sprintf(q(No existing account was found for the email address provided. Please verify the email address again, or to create a new account, please <a href="%s">click here</a>), $_[0]->url({'action' => 'OpenID', 'function' => 'Register', 'code' => $_[0]->param('code') || ''})) },
MESSAGE_LOGIN_ALREADY_TAKEN => sub { 'Could not add login', 'Sorry, this login option already exists for another user account.' },
MESSAGE_LOGIN_ALREADY_LINKED => sub { 'Login option already added', 'You already seem to have linked this login option to your account.' },
MESSAGE_URL_EXPIRED => sub { 'URL expired or invalid', 'The link you clicked to reach here has been expired or is invalid.' },
MESSAGE_UNKNOWN_ERROR => sub { 'Unknown error', 'An unknown error occurred. Please try again or contact the help desk.' }
);
my %CODES = map { $_ => substr(md5_hex($_), 0, 8) } keys %MESSAGES;
sub import {
my $class = shift;
my $caller = caller;
my %includes = map { $_ => 1 } @_;
{
no strict qw(refs);
if ($includes{'get_message'}) {
*{"${caller}::get_message"} = sub {
my ($code, $hub) = @_;
my $constant = { reverse %CODES }->{$code || ''};
return $MESSAGES{$constant || 'MESSAGE_UNKNOWN_ERROR'}->($hub);
};
}
foreach my $message_constant (grep { !@_ || $includes{'ALL'} || $includes{$_} } keys %MESSAGES) {
*{"${caller}::${message_constant}"} = sub { return $CODES{$message_constant}; };
}
}
}
1;
| 76.642105 | 332 | 0.692625 |
73dab7ed8c5b50037f1609ec7a1f2e606ec137e6 | 961 | pm | Perl | lib/Perl/Critic/TooMuchCode.pm | charsbar/Perl-Critic-TooMuchCode | ce9b5318723005d0b7487c8e9afec4cea58622d7 | [
"MIT"
]
| null | null | null | lib/Perl/Critic/TooMuchCode.pm | charsbar/Perl-Critic-TooMuchCode | ce9b5318723005d0b7487c8e9afec4cea58622d7 | [
"MIT"
]
| null | null | null | lib/Perl/Critic/TooMuchCode.pm | charsbar/Perl-Critic-TooMuchCode | ce9b5318723005d0b7487c8e9afec4cea58622d7 | [
"MIT"
]
| null | null | null | package Perl::Critic::TooMuchCode;
use strict;
our $VERSION='0.13';
# Well, we need a place for this monkey-patching business.
sub __get_terop_usage {
my ($used, $doc) = @_;
for my $question_mark (@{ $doc->find( sub { $_[1]->isa('PPI::Token::Operator') && $_[1]->content eq '?' }) ||[]}) {
my $el = $question_mark->snext_sibling;
next unless $el->isa('PPI::Token::Label');
my $tok = $el->content;
$tok =~ s/\s*:\z//;
$used->{$tok}++;
}
}
1;
__END__
=head1 NAME
Perl::Critic::TooMuchCode - perlcritic add-ons that generally check for dead code.
=head1 DESCRIPTION
This add-on for L<Perl::Critic> is aiming for identifying trivial dead
code. Either the ones that has no use, or the one that produce no
effect. Having dead code floating around causes maintenance burden. Some
might prefer not to generate them in the first place.
=head1 AUTHOR
Kang-min Liu <gugod@gugod.org>
=head1 LICENSE
MIT
=cut
| 22.880952 | 119 | 0.656608 |
73ebb700e195ba207811f576de89fd9f40f98271 | 4,883 | pl | Perl | nutmonitor-lib.pl | JRGTH/nut-monitor-webmin-module | 329b3391ec1cd1db9fcdce1d75d3a280ecb35962 | [
"BSD-3-Clause"
]
| null | null | null | nutmonitor-lib.pl | JRGTH/nut-monitor-webmin-module | 329b3391ec1cd1db9fcdce1d75d3a280ecb35962 | [
"BSD-3-Clause"
]
| null | null | null | nutmonitor-lib.pl | JRGTH/nut-monitor-webmin-module | 329b3391ec1cd1db9fcdce1d75d3a280ecb35962 | [
"BSD-3-Clause"
]
| null | null | null | #!/usr/local/bin/perl
# nutmonitor-lib.pl
BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
my $ups_stat_props="$config{'nut_monitor'}";
my $ups_cmd_props="$config{'nut_command'}";
# Get NUT version
sub get_nut_version
{
my $getversion = 'upsd -V | awk "{print \$5}"';
my $version = `$getversion`;
}
# Get pid file
# Returns the NUT PID file.
sub get_pid_file
{
$pidfile = $config{'pid_file'};
return $pidfile;
}
# Get NUT pid
# Returns the PID of the running NUT process.
sub get_nut_pid
{
local $file = &get_pid_file();
if ($file) {
return &check_pid_file($file);
}
else {
local ($rv) = &find_byname("upsd");
return $rv;
}
}
# Kill NUT related processes.
sub kill_nut_procs
{
my $killnutprocs = `pkill -U nut`;
}
sub list_nut
{
my %nut=();
my $list=`upsc $config{'ups_name'} | grep -E "$ups_stat_props"`;
open my $fh, "<", \$list;
while (my $line =<$fh>)
{
chomp ($line);
my @props = split(" ", $line, 2);
$ct = 1;
foreach $prop (split(",", "VALUE")) {
$nut{$props[0]}{$prop} = $props[$ct];
$ct++;
}
}
return %nut;
}
sub list_cmd
{
my %nut=();
my $list=`upscmd -l $config{'ups_name'} | sed '1d;2d' | grep -E "$ups_cmd_props"`;
open my $fh, "<", \$list;
while (my $line =<$fh>)
{
chomp ($line);
my @props = split(" ", $line, 2);
$ct = 1;
foreach $prop (split(",", "DESCRIPTION")) {
$nut{$props[0]}{$prop} = $props[$ct];
$ct++;
}
}
return %nut;
}
# NUT summary list.
sub ui_nut_list
{
my %nut = list_nut($nut);
@props = split(/,/, "VALUE");
print &ui_columns_start([ "PROPERTY", @props ]);
my $num = 0;
foreach $key (sort(keys %nut))
{
@vals = ();
foreach $prop (@props) { push (@vals, $nut{$key}{$prop}); }
# Disable start, stop and restart buttons.
print &ui_columns_row([ "<a href='index.cgi?nut=$key'>$key</a>", @vals ]);
$num ++;
}
print &ui_columns_end();
}
# NUT available command list.
sub ui_nut_advanced
{
my %nut = list_cmd($nut);
@props = split(/,/, "DESCRIPTION");
print &ui_columns_start([ "COMMAND", @props ]);
my $num = 0;
foreach $key (sort(keys %nut))
{
@vals = ();
foreach $prop (@props) { push (@vals, $nut{$key}{$prop}); }
# Execute ups command.
if ($config{'allow_cmdexec'}) {
print &ui_columns_row([ "<a href='exec.cgi?nut=$key'>$key</a>", @vals ]);
}
else {
print &ui_columns_row([ "<a href='index.cgi?nut=$key'>$key</a>", @vals ]);
}
$num ++;
}
print &ui_columns_end();
}
sub ui_nut_conf
{
# Display icons for options.
if ($config{'show_conf'}) {
push(@links, "edit_config.cgi");
push(@titles, $text{'manual_nutedit'});
push(@icons, "images/manual.gif");
}
&icons_table(\@links, \@titles, \@icons, 4);
}
# Restart NUT, and returns an error message on failure or
# undef on success.
sub restart_nut
{
if ($config{'restart_cmd'}) {
local $out = `$config{'restart_cmd'} 2>&1 </dev/null`;
return "<pre>$out</pre>" if ($?);
}
else {
# Just kill NUT related processes and start NUT.
kill_nut_procs;
if ($config{'start_cmd'}) {
$out = &backquote_logged("$config{'start_cmd'} 2>&1 </dev/null");
if ($?) { return "<pre>$out</pre>"; }
}
}
return undef;
}
# Always use stop command whenever possible, otherwise
# try to kill the NUT service, returns an error message on failure or
# undef on success.
sub stop_nut
{
if ($config{'stop_cmd'}) {
local $out = `$config{'stop_cmd'} 2>&1 </dev/null`;
return "<pre>$out</pre>" if ($?);
}
else {
# Just kill NUT related processes.
&kill_nut_procs;
}
return undef;
}
# Attempts to start NUT, returning undef on success or an error
# message on failure.
sub start_nut
{
# Remove PID file if invalid.
if (-f $config{'pid_file'} && !&check_pid_file($config{'pid_file'})) {
&unlink_file($config{'pid_file'});
}
if ($config{'start_cmd'}) {
$out = &backquote_logged("$config{'start_cmd'} 2>&1 </dev/null");
if ($?) { return "<pre>$out</pre>"; }
}
else {
$out = &backquote_logged("$config{'pid_file'} 2>&1 </dev/null");
if ($?) { return "<pre>$out</pre>"; }
}
return undef;
}
# Attempts to execute UPS command, returning undef on success or an error
# message always.
sub exec_nut
{
if ($config{'show_advanced'}) {
if ($config{'allow_cmdexec'}) {
if (($config{'ups_username'}) && ($config{'ups_password'})) {
my $upsname = $config{'ups_name'};
my $username = $config{'ups_username'};
my $userpass = $config{'ups_password'};
my $nutcmd = $in{'nut'};
local $out = &backquote_logged("upscmd -u $username -p $userpass $upsname $nutcmd 2>&1 </dev/null");
if ($?) {
return "<pre>$out</pre>";
} else {
&ui_print_header(undef, $text{'index_title'}, "");
@result = $out;
if (!$result[0]) {
print "$text{'exec_ok'} [$nutcmd]<br/>";
} else {
print "<b>$text{'exec_output'} [$nutcmd]<br><br></b>".$result[0]."<br/>";
foreach $key (@result[1..@result]) {
print $key."<br/>";
}
}
&ui_print_footer("", $text{'index_return'});
}
}
}
}
return undef;
}
1;
| 21.606195 | 103 | 0.610076 |
ed4068924940a07e2b7020a28b08d420d48ae190 | 16,729 | t | Perl | src/couch_set_view/test/08-deletes-cleanup.t | bryandmc/couchdb | b7df92caa359993bd7e785e49875e6c5c82d5eaf | [
"Apache-2.0"
]
| 93 | 2015-01-19T16:36:36.000Z | 2022-03-24T00:26:33.000Z | src/couch_set_view/test/08-deletes-cleanup.t | bryandmc/couchdb | b7df92caa359993bd7e785e49875e6c5c82d5eaf | [
"Apache-2.0"
]
| 4 | 2015-04-27T00:01:05.000Z | 2021-07-26T08:16:56.000Z | src/couch_set_view/test/08-deletes-cleanup.t | bryandmc/couchdb | b7df92caa359993bd7e785e49875e6c5c82d5eaf | [
"Apache-2.0"
]
| 62 | 2015-01-04T13:07:15.000Z | 2022-02-25T10:02:14.000Z | #!/usr/bin/env escript
%% -*- Mode: Erlang; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
%%! -smp enable
% 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.
-include("../../couchdb/couch_db.hrl").
-include_lib("couch_set_view/include/couch_set_view.hrl").
% Test motivated by MB-4518.
-define(MAX_WAIT_TIME, 900 * 1000).
test_set_name() -> <<"couch_test_set_index_deletes_cleanup">>.
num_set_partitions() -> 64.
ddoc_id() -> <<"_design/test">>.
initial_num_docs() -> 104192. % must be multiple of num_set_partitions()
main(_) ->
test_util:init_code_path(),
etap:plan(74),
case (catch test()) of
ok ->
etap:end_tests();
Other ->
etap:diag(io_lib:format("Test died abnormally: ~p", [Other])),
etap:bail(Other)
end,
ok.
test() ->
couch_set_view_test_util:start_server(test_set_name()),
create_set(),
add_documents(0, initial_num_docs()),
{QueryResult1, Group1} = query_reduce_view(false),
etap:is(
QueryResult1,
initial_num_docs(),
"Reduce view has value " ++ couch_util:to_list(initial_num_docs())),
verify_btrees_1(Group1),
compact_view_group(),
{QueryResult2, Group2} = query_reduce_view(false),
etap:is(
QueryResult2,
initial_num_docs(),
"Reduce view has value " ++ couch_util:to_list(initial_num_docs())),
verify_btrees_1(Group2),
etap:diag("Deleting all documents"),
delete_docs(0, initial_num_docs()),
etap:is(
couch_set_view_test_util:doc_count(test_set_name(), lists:seq(0, 63)),
0,
"All docs were deleted"),
etap:diag("Marking partitions [ 32 .. 63 ] for cleanup"),
ok = lists:foreach(
fun(I) ->
ok = couch_set_view:set_partition_states(
mapreduce_view, test_set_name(), ddoc_id(), [], [], [I])
end,
lists:seq(32, 63)),
etap:diag("Waiting for cleanup of partitions [ 32 .. 63 ]"),
MainGroupInfo = get_group_info(),
wait_for_cleanup(MainGroupInfo),
etap:diag("Cleanup finished"),
{QueryResult3, Group3} = query_reduce_view(false),
etap:is(
QueryResult3,
empty,
"Reduce view returned 0 rows"),
verify_btrees_2(Group3),
compact_view_group(),
{QueryResult4, Group4} = query_reduce_view(false),
etap:is(
QueryResult4,
empty,
"Reduce view returned 0 rows"),
verify_btrees_2(Group4),
etap:diag("Marking partitions [ 32 .. 63 ] as active"),
ok = lists:foreach(
fun(I) ->
ok = couch_set_view:set_partition_states(
mapreduce_view, test_set_name(), ddoc_id(), [I], [], [])
end,
lists:seq(32, 63)),
{QueryResult5, Group5} = query_reduce_view(false),
etap:is(
QueryResult5,
empty,
"Reduce view returned 0 rows"),
verify_btrees_3(Group5),
compact_view_group(),
{QueryResult6, Group6} = query_reduce_view(false),
etap:is(
QueryResult6,
empty,
"Reduce view returned 0 rows"),
verify_btrees_3(Group6),
etap:diag("Creating the same documents again"),
add_documents(0, initial_num_docs()),
{QueryResult7, Group7} = query_reduce_view(false),
etap:is(
QueryResult7,
initial_num_docs(),
"Reduce view has value " ++ couch_util:to_list(initial_num_docs())),
verify_btrees_1(Group7),
compact_view_group(),
{QueryResult8, Group8} = query_reduce_view(false),
etap:is(
QueryResult8,
initial_num_docs(),
"Reduce view has value " ++ couch_util:to_list(initial_num_docs())),
verify_btrees_1(Group8),
couch_set_view_test_util:delete_set_dbs(test_set_name(), num_set_partitions()),
couch_set_view_test_util:stop_server(),
ok.
query_reduce_view(Stale) ->
etap:diag("Querying reduce view with ?group=true"),
{ok, View, Group, _} = couch_set_view:get_reduce_view(
test_set_name(), ddoc_id(), <<"test">>,
#set_view_group_req{stale = Stale, debug = true}),
FoldFun = fun(Key, Red, Acc) -> {ok, [{Key, Red} | Acc]} end,
ViewArgs = #view_query_args{
run_reduce = true,
view_name = <<"test">>
},
{ok, Rows} = couch_set_view:fold_reduce(Group, View, FoldFun, [], ViewArgs),
couch_set_view:release_group(Group),
case Rows of
[{_Key, {json, RedValue}}] ->
{ejson:decode(RedValue), Group};
[] ->
{empty, Group}
end.
wait_for_cleanup(GroupInfo) ->
etap:diag("Waiting for main index cleanup to finish"),
Pid = spawn(fun() ->
wait_for_cleanup_loop(GroupInfo)
end),
Ref = erlang:monitor(process, Pid),
receive
{'DOWN', Ref, process, Pid, normal} ->
ok;
{'DOWN', Ref, process, Pid, Reason} ->
etap:bail("Failure waiting for main index cleanup: " ++ couch_util:to_list(Reason))
after ?MAX_WAIT_TIME ->
etap:bail("Timeout waiting for main index cleanup")
end.
wait_for_cleanup_loop(GroupInfo) ->
case couch_util:get_value(cleanup_partitions, GroupInfo) of
[] ->
{Stats} = couch_util:get_value(stats, GroupInfo),
Cleanups = couch_util:get_value(cleanups, Stats),
etap:is(
(is_integer(Cleanups) andalso (Cleanups > 0)),
true,
"Main group stats has at least 1 full cleanup");
_ ->
ok = timer:sleep(1000),
wait_for_cleanup_loop(get_group_info())
end.
get_group_info() ->
{ok, Info} = couch_set_view:get_group_info(
mapreduce_view, test_set_name(), ddoc_id(), prod),
Info.
delete_docs(StartId, NumDocs) ->
Dbs = dict:from_list(lists:map(
fun(I) ->
{ok, Db} = couch_set_view_test_util:open_set_db(test_set_name(), I),
{I, Db}
end,
lists:seq(0, 63))),
Docs = lists:foldl(
fun(I, Acc) ->
Doc = couch_doc:from_json_obj({[
{<<"meta">>, {[{<<"deleted">>, true}, {<<"id">>, doc_id(I)}]}},
{<<"json">>, {[]}}
]}),
DocList = case orddict:find(I rem 64, Acc) of
{ok, L} ->
L;
error ->
[]
end,
orddict:store(I rem 64, [Doc | DocList], Acc)
end,
orddict:new(), lists:seq(StartId, StartId + NumDocs - 1)),
[] = orddict:fold(
fun(I, DocList, Acc) ->
Db = dict:fetch(I, Dbs),
etap:diag("Deleting " ++ integer_to_list(length(DocList)) ++
" documents from partition " ++ integer_to_list(I)),
ok = couch_db:update_docs(Db, DocList, [sort_docs]),
Acc
end,
[], Docs),
ok = lists:foreach(fun({_, Db}) -> ok = couch_db:close(Db) end, dict:to_list(Dbs)).
create_set() ->
couch_set_view_test_util:delete_set_dbs(test_set_name(), num_set_partitions()),
couch_set_view_test_util:create_set_dbs(test_set_name(), num_set_partitions()),
couch_set_view:cleanup_index_files(mapreduce_view, test_set_name()),
etap:diag("Creating the set databases (# of partitions: " ++
integer_to_list(num_set_partitions()) ++ ")"),
DDoc = {[
{<<"meta">>, {[{<<"id">>, ddoc_id()}]}},
{<<"json">>, {[
{<<"language">>, <<"javascript">>},
{<<"views">>, {[
{<<"test">>, {[
{<<"map">>, <<"function(doc, meta) { emit(meta.id, doc.value); }">>},
{<<"reduce">>, <<"_count">>}
]}}
]}}
]}}
]},
ok = couch_set_view_test_util:update_ddoc(test_set_name(), DDoc),
etap:diag("Configuring set view with partitions [0 .. 63] as active"),
Params = #set_view_params{
max_partitions = num_set_partitions(),
active_partitions = lists:seq(0, 63),
passive_partitions = [],
use_replica_index = false
},
ok = couch_set_view:define_group(
mapreduce_view, test_set_name(), ddoc_id(), Params).
add_documents(StartId, Count) ->
etap:diag("Adding " ++ integer_to_list(Count) ++ " new documents"),
DocList0 = lists:map(
fun(I) ->
{I rem num_set_partitions(), {[
{<<"meta">>, {[{<<"id">>, doc_id(I)}]}},
{<<"json">>, {[
{<<"value">>, I}
]}}
]}}
end,
lists:seq(StartId, StartId + Count - 1)),
DocList = [Doc || {_, Doc} <- lists:keysort(1, DocList0)],
ok = couch_set_view_test_util:populate_set_sequentially(
test_set_name(),
lists:seq(0, num_set_partitions() - 1),
DocList).
doc_id(I) ->
iolist_to_binary(io_lib:format("doc_~8..0b", [I])).
compact_view_group() ->
{ok, CompactPid} = couch_set_view_compactor:start_compact(
mapreduce_view, test_set_name(), ddoc_id(), main),
Ref = erlang:monitor(process, CompactPid),
etap:diag("Waiting for view group compaction to finish"),
receive
{'DOWN', Ref, process, CompactPid, normal} ->
ok;
{'DOWN', Ref, process, CompactPid, noproc} ->
ok;
{'DOWN', Ref, process, CompactPid, Reason} ->
etap:bail("Failure compacting main group: " ++ couch_util:to_list(Reason))
after ?MAX_WAIT_TIME ->
etap:bail("Timeout waiting for main group compaction to finish")
end.
verify_btrees_1(Group) ->
#set_view_group{
id_btree = IdBtree,
views = [View0],
index_header = #set_view_index_header{
seqs = HeaderUpdateSeqs,
abitmask = Abitmask,
pbitmask = Pbitmask,
cbitmask = Cbitmask
}
} = Group,
#set_view{
id_num = 0,
indexer = #mapreduce_view{
btree = View0Btree
}
} = View0,
etap:diag("Verifying view group btrees"),
ExpectedBitmask = couch_set_view_util:build_bitmask(lists:seq(0, 63)),
DbSeqs = couch_set_view_test_util:get_db_seqs(test_set_name(), lists:seq(0, 63)),
etap:is(
couch_set_view_test_util:full_reduce_id_btree(Group, IdBtree),
{ok, {initial_num_docs(), ExpectedBitmask}},
"Id Btree has the right reduce value"),
etap:is(
couch_set_view_test_util:full_reduce_view_btree(Group, View0Btree),
{ok, {initial_num_docs(), [initial_num_docs()], ExpectedBitmask}},
"View0 Btree has the right reduce value"),
etap:is(HeaderUpdateSeqs, DbSeqs, "Header has right update seqs list"),
etap:is(Abitmask, ExpectedBitmask, "Header has right active bitmask"),
etap:is(Pbitmask, 0, "Header has right passive bitmask"),
etap:is(Cbitmask, 0, "Header has right cleanup bitmask"),
etap:diag("Verifying the Id Btree"),
MaxPerPart = initial_num_docs() div num_set_partitions(),
{ok, _, {_, _, _, IdBtreeFoldResult}} = couch_btree:fold(
IdBtree,
fun(Kv, _, {P0, I0, C0, It}) ->
case C0 >= MaxPerPart of
true ->
P = P0 + 1,
I = P,
C = 1;
false ->
P = P0,
I = I0,
C = C0 + 1
end,
true = (P < num_set_partitions()),
V = ?JSON_ENCODE(doc_id(I)),
[ExpectedKv] = mapreduce_view:convert_back_index_kvs_to_binary(
[{doc_id(I), {P, [{0, [V]}]}}], []),
case ExpectedKv =:= Kv of
true ->
ok;
false ->
etap:bail("Id Btree has an unexpected KV at iteration " ++ integer_to_list(It))
end,
{ok, {P, I + num_set_partitions(), C, It + 1}}
end,
{0, 0, 0, 0}, []),
etap:is(IdBtreeFoldResult, initial_num_docs(),
"Id Btree has " ++ integer_to_list(initial_num_docs()) ++ " entries"),
etap:diag("Verifying the View0 Btree"),
{ok, _, View0BtreeFoldResult} = couch_btree:fold(
View0Btree,
fun(Kv, _, Acc) ->
V = ?JSON_ENCODE(Acc),
ExpectedKeyDocId = mapreduce_view:encode_key_docid(
?JSON_ENCODE(doc_id(Acc)), doc_id(Acc)),
ExpectedKv = {ExpectedKeyDocId, <<(Acc rem 64):16, (size(V)):24, V/binary>>},
case ExpectedKv =:= Kv of
true ->
ok;
false ->
etap:bail("View0 Btree has an unexpected KV at iteration " ++ integer_to_list(Acc))
end,
{ok, Acc + 1}
end,
0, []),
etap:is(View0BtreeFoldResult, initial_num_docs(),
"View0 Btree has " ++ integer_to_list(initial_num_docs()) ++ " entries").
verify_btrees_2(Group) ->
#set_view_group{
id_btree = IdBtree,
views = [View0],
index_header = #set_view_index_header{
seqs = HeaderUpdateSeqs,
abitmask = Abitmask,
pbitmask = Pbitmask,
cbitmask = Cbitmask
}
} = Group,
#set_view{
id_num = 0,
indexer = #mapreduce_view{
btree = View0Btree
}
} = View0,
etap:diag("Verifying view group btrees"),
ExpectedABitmask = couch_set_view_util:build_bitmask(lists:seq(0, 31)),
DbSeqs = couch_set_view_test_util:get_db_seqs(test_set_name(), lists:seq(0, 31)),
etap:is(
couch_set_view_test_util:full_reduce_id_btree(Group, IdBtree),
{ok, {0, 0}},
"Id Btree has the right reduce value"),
etap:is(
couch_set_view_test_util:full_reduce_view_btree(Group, View0Btree),
{ok, {0, [0], 0}},
"View0 Btree has the right reduce value"),
etap:is(HeaderUpdateSeqs, DbSeqs, "Header has right update seqs list"),
etap:is(Abitmask, ExpectedABitmask, "Header has right active bitmask"),
etap:is(Pbitmask, 0, "Header has right passive bitmask"),
etap:is(Cbitmask, 0, "Header has right cleanup bitmask"),
etap:diag("Verifying the Id Btree"),
{ok, _, IdBtreeFoldResult} = couch_set_view_test_util:fold_id_btree(
Group,
IdBtree,
fun(_Kv, _, Acc) ->
{ok, Acc + 1}
end,
0, []),
etap:is(IdBtreeFoldResult, 0, "Id Btree is empty"),
etap:diag("Verifying the View0 Btree"),
{ok, _, View0BtreeFoldResult} = couch_set_view_test_util:fold_view_btree(
Group,
View0Btree,
fun(_Kv, _, Acc) ->
{ok, Acc + 1}
end,
0, []),
etap:is(View0BtreeFoldResult, 0, "View0 Btree is empty").
verify_btrees_3(Group) ->
#set_view_group{
id_btree = IdBtree,
views = [View0],
index_header = #set_view_index_header{
seqs = HeaderUpdateSeqs,
abitmask = Abitmask,
pbitmask = Pbitmask,
cbitmask = Cbitmask
}
} = Group,
#set_view{
id_num = 0,
indexer = #mapreduce_view{
btree = View0Btree
}
} = View0,
etap:diag("Verifying view group btrees"),
ExpectedABitmask = couch_set_view_util:build_bitmask(lists:seq(0, 63)),
DbSeqs = couch_set_view_test_util:get_db_seqs(test_set_name(), lists:seq(0, 63)),
etap:is(
couch_set_view_test_util:full_reduce_id_btree(Group, IdBtree),
{ok, {0, 0}},
"Id Btree has the right reduce value"),
etap:is(
couch_set_view_test_util:full_reduce_view_btree(Group, View0Btree),
{ok, {0, [0], 0}},
"View0 Btree has the right reduce value"),
etap:is(HeaderUpdateSeqs, DbSeqs, "Header has right update seqs list"),
etap:is(Abitmask, ExpectedABitmask, "Header has right active bitmask"),
etap:is(Pbitmask, 0, "Header has right passive bitmask"),
etap:is(Cbitmask, 0, "Header has right cleanup bitmask"),
etap:diag("Verifying the Id Btree"),
{ok, _, IdBtreeFoldResult} = couch_set_view_test_util:fold_id_btree(
Group,
IdBtree,
fun(_Kv, _, Acc) ->
{ok, Acc + 1}
end,
0, []),
etap:is(IdBtreeFoldResult, 0, "Id Btree is empty"),
etap:diag("Verifying the View0 Btree"),
{ok, _, View0BtreeFoldResult} = couch_set_view_test_util:fold_view_btree(
Group,
View0Btree,
fun(_Kv, _, Acc) ->
{ok, Acc + 1}
end,
0, []),
etap:is(View0BtreeFoldResult, 0, "View0 Btree is empty").
| 33.126733 | 99 | 0.587363 |
ed486b7f4e05d4a75cbe2677fbe35184ae390af8 | 397 | t | Perl | t/00-load.t | ivanwills/data-context-bem | 02afbaf94925c136daa126e67afc91cd7977acef | [
"Artistic-1.0"
]
| null | null | null | t/00-load.t | ivanwills/data-context-bem | 02afbaf94925c136daa126e67afc91cd7977acef | [
"Artistic-1.0"
]
| null | null | null | t/00-load.t | ivanwills/data-context-bem | 02afbaf94925c136daa126e67afc91cd7977acef | [
"Artistic-1.0"
]
| null | null | null | #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 5 + 1;
use Test::NoWarnings;
BEGIN {
use_ok('Data::Context::BEM');
use_ok('Data::Context::BEM::Instance');
use_ok('Data::Context::BEM::Block');
use_ok('Data::Context::BEM::Block::Page');
use_ok('Data::Context::BEM::Merge');
}
diag( "Testing Data::Context::BEM $Data::Context::BEM::VERSION, Perl $], $^X" );
| 22.055556 | 80 | 0.624685 |
ed53f18aec5b5cd5518675185fbabf951a8716b7 | 9,788 | pl | Perl | src/perl/predotar2bsml.pl | jonathancrabtree/ergatis | a587bfa0d30c58dec8855ba5ed45274e4f206ad7 | [
"Artistic-1.0"
]
| null | null | null | src/perl/predotar2bsml.pl | jonathancrabtree/ergatis | a587bfa0d30c58dec8855ba5ed45274e4f206ad7 | [
"Artistic-1.0"
]
| null | null | null | src/perl/predotar2bsml.pl | jonathancrabtree/ergatis | a587bfa0d30c58dec8855ba5ed45274e4f206ad7 | [
"Artistic-1.0"
]
| null | null | null | #!/usr/bin/perl
BEGIN{foreach (@INC) {s/\/usr\/local\/packages/\/local\/platform/}};
use lib (@INC,$ENV{"PERL_MOD_DIR"});
no lib "$ENV{PERL_MOD_DIR}/i686-linux";
no lib ".";
=head1 NAME
predotar2bsml.pl - convert predotar output to BSML
=head1 SYNOPSIS
USAGE: predotar2bsml.pl --input=/path/to/predotar_file --output=/path/to/output.bsml
=head1 OPTIONS
B<--input,-i>
Input file file from a predotar run.
B<--debug,-d>
Debug level. Use a large number to turn on verbose debugging.
B<--log,-l>
Log file
B<--output,-o>
Output BSML file (will be created, must not exist)
B<--help,-h>
This help message
=head1 DESCRIPTION
This script is used to convert the output from predotar into BSML.
=head1 INPUT
predotar can be run using multiple input sequences simultaneously, and this
script supports parsing single or multiple input result sets. predotar
output using 'p' option for plant sequence looks like:
Predotar v. 1.03 using plant predictors
initializing predictors...
initializing sequence formats...
reading temp_multi
format assumed to be FastA
Seq Mit Plast ER None Prediction
NCAPP1 0.01 0.01 0.98 0.02 ER
two 0.59 0.05 0.00 0.39 mitochondrial
three Discarding three: no terminal Met
finished reading temp_multi
predicted 2 sequences out of 3
or using 'a' for animal/fungi:
Predotar v. 1.03 using animal/fungal predictors
initializing predictors...
initializing sequence formats...
reading temp_multi
format assumed to be FastA
Seq Mit ER None Prediction
NCAPP1 0.02 0.99 0.01 ER
two 0.63 0.01 0.36 mitochondrial
three Discarding three: no terminal Met
finished reading temp_multi
predicted 2 sequences out of 3
Output from both analysis types are supported. Discarded sequences are ignored.
You define the input file using the --input option. This file does not need any
special file extension.
Weak predictions are qualified with the term 'possibly' (eg: 'possibly ER').
By default, weak predictions and strong predictions will be treated as equally
acceptable by the parser. To modify this behaviour and reject weak predictions,
use the option --strict.
=head1 OUTPUT
After parsing the input file, a file specified by the --output option is created. This script
will fail if it already exists.
=head1 CONTACT
Brett Whitty
bwhitty@tigr.org
=cut
use strict;
use Getopt::Long qw(:config no_ignore_case no_auto_abbrev);
use Pod::Usage;
BEGIN {
use Ergatis::Logger;
use BSML::BsmlRepository;
use Papyrus::TempIdCreator;
use BSML::BsmlBuilder;
use BSML::BsmlParserTwig;
}
my %options = ();
my $results = GetOptions (\%options,
'input|i=s',
'output|o=s',
'debug|d=s',
'command_id=s', ## passed by workflow
'logconf=s', ## passed by workflow (not used)
'project|p=s',
'log|l=s',
'help|h',
'strict',
) || pod2usage();
my $logfile = $options{'log'} || Ergatis::Logger::get_default_logfilename();
my $logger = new Ergatis::Logger('LOG_FILE'=>$logfile,
'LOG_LEVEL'=>$options{'debug'});
$logger = $logger->get_logger();
# display documentation
if( $options{'help'} ){
pod2usage( {-exitval=>0, -verbose => 2, -output => \*STDOUT} );
}
## make sure all passed options are peachy
&check_parameters(\%options);
## we want to create ids unique to this document, which will be replaced later. they must
## contain the prefix that will be used to look up a real id, such as ath1.gen.15
my $next_id = 1;
## we want a new doc
my $doc = new BSML::BsmlBuilder();
## we're going to generate ids
my $idcreator = new Papyrus::TempIdCreator();
## open the input file for parsing
open (my $ifh, $options{'input'}) || $logger->logdie("can't open input file for reading");
my @results;
my @result_fields;
my @field_ids;
my $finished_flag = 0;
while (<$ifh>) {
chomp;
#check whitespace, no warn
next if ( /^\s*$/ );
##recognize header fields
if (/^Seq\t/) {
##save the field ids for verifying data later
@field_ids = split("\t");
while (my $result_line = <$ifh>) {
chomp $result_line;
if ($result_line =~ /^finished reading/) {
$finished_flag = 1;
last;
} else {
my @result_fields = split("\t", $result_line);
if ($result_line =~ /Discarding/) {
$logger->error(
"input sequence ".$result_fields[0]." was discarded by predotar."
) if ($logger->is_error);
next;
}
push (@results, \@result_fields);
}
}
}
}
## if we reached EOF without hitting finished reading line
## we need to die because something's probably gone very wrong
if (! $finished_flag) {
$logger->logdie("Reached end of input file without seeing 'finished reading' line.\nRaw file is corrupted or in an unrecognized format.\n");
}
my @clean_results = @results; ## removed skipping of discarded sequences
#my @clean_results;
#foreach my $result_fields_ref(@results) {
## Check if any sequences were discarded
# if ((scalar @$result_fields_ref) == 2 && $result_fields_ref->[1] =~ /^Discarding ([^:]+): (.*)$/) {
# $logger->error("The sequence with id \"$1\" was discarded by predotar.\nThe reason given was: $2\n") if ($logger->is_error);
# } elsif (scalar @$result_fields_ref != scalar @field_ids) {
# $logger->error("The number of fields in the following line did not match the results header:\n".join("\t", @$result_fields_ref)."\n") if ($logger->is_error);
# } else {
# push (@clean_results, $result_fields_ref);
# }
#}
@results = ();
my $result_count = scalar @clean_results;
## GO mappings tables for output
my %go_term;
my %go_id;
if (defined($options{strict})) {
%go_term = (
'mitochondrial' => 'mitochondrion',
'possibly mitochondrial' => 'cellular component unknown',
'plastid' => 'plastid',
'possibly plastid' => 'cellular component unknown',
'ER' => 'endoplasmic reticulum',
'possibly ER' => 'cellular component unknown',
'none' => 'cellular component unknown',
);
%go_id = (
'mitochondrial' => 'GO:0005739',
'possibly mitochondrial' => 'GO:0008372',
'plastid' => 'GO:0009536',
'possibly plastid' => 'GO:0008372',
'ER' => 'GO:0005783',
'possibly ER' => 'GO:0008372',
'none' => 'GO:0008372',
);
} else {
%go_term = (
'mitochondrial' => 'mitochondrion',
'possibly mitochondrial' => 'mitochondrion',
'plastid' => 'plastid',
'possibly plastid' => 'plastid',
'ER' => 'endoplasmic reticulum',
'possibly ER' => 'endoplasmic reticulum',
'none' => 'cellular component unknown',
);
%go_id = (
'mitochondrial' => 'GO:0005739',
'possibly mitochondrial' => 'GO:0005739',
'plastid' => 'GO:0009536',
'possibly plastid' => 'GO:0009536',
'ER' => 'GO:0005783',
'possibly ER' => 'GO:0005783',
'none' => 'GO:0008372',
);
}
## loop through each of the matches that we found
for (my $i = 0; $i < $result_count; $i++) {
my @result_fields = @{$clean_results[$i]};
my @result_field_ids = @field_ids;
## pull the sequence id off the front of the array
my $sequence_id = shift @result_fields;
## and discard the label
shift @result_field_ids;
## pull the prediction off the end of the array
my $prediction = pop @result_fields;
## and again discard the label
pop @result_field_ids;
my $seq = $doc->createAndAddSequence($sequence_id, undef, '', 'aa', 'polypeptide');
$seq->addBsmlLink('analysis', '#predotar_analysis', 'input_of');
unless ($prediction =~ /^Discarding ([^:]+): (.*)$/) {
my $ft = $doc->createAndAddFeatureTable($seq);
my $new_id = $idcreator->new_id( db => $options{project},
so_type => 'transit_peptide', prefix => $options{command_id},
);
my $feature = $doc->createAndAddFeature($ft, $new_id, '', 'transit_peptide');
$feature->addBsmlLink('analysis', '#predotar_analysis', 'computed_by');
unless (defined($go_id{$prediction})) {
$logger->logdie("predotar prediction '$prediction' was not an expected result");
}
my $attribute_array_ref;
push( @{$attribute_array_ref}, { name => 'GO',
content => $go_id{$prediction}}
);
push( @{$attribute_array_ref}, { name => 'IEA',
content => 'predotar prediction'}
);
$feature->addBsmlAttributeList($attribute_array_ref);
my $attribute_count = scalar @result_field_ids;
for (my $j = 0; $j < $attribute_count; $j++) {
$doc->createAndAddBsmlAttribute($feature, $result_field_ids[$j], $result_fields[$j]);
}
}
}
## add the analysis element
my $analysis = $doc->createAndAddAnalysis(
id => 'predotar_analysis',
sourcename => $options{'output'},
);
$doc->createAndAddBsmlAttribute( $analysis, 'version', 'current' );
$doc->createAndAddBsmlAttribute( $analysis, 'algorithm', 'predotar' );
## now write the doc
$doc->write($options{'output'});
exit;
sub check_parameters {
## make sure input file exists
if (! -e $options{'input'}) { $logger->logdie("input file $options{'input'} does not exist") }
## make sure output file doesn't exist yet
if (-e $options{'output'}) { $logger->logdie("can't create $options{'output'} because it already exists") }
$options{'project'} = 'unknown' unless ($options{'project'});
$options{'command_id'} = '0' unless ($options{'command_id'});
return 1;
}
| 31.271565 | 167 | 0.629444 |
ed1819bd008de89f08204d2e50d63de8fc352673 | 278 | pl | Perl | benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/gc_sc/Zl.pl | YangZhou1997/DynamicCache_v2 | 60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2 | [
"BSD-3-Clause"
]
| 430 | 2015-01-05T19:21:10.000Z | 2022-03-29T07:19:18.000Z | benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/gc_sc/Zl.pl | YangZhou1997/DynamicCache_v2 | 60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2 | [
"BSD-3-Clause"
]
| 9 | 2015-01-20T17:42:30.000Z | 2022-03-04T22:05:43.000Z | benchmarks/spec2k6bin/specint/perl_depends/lib/unicore/lib/gc_sc/Zl.pl | YangZhou1997/DynamicCache_v2 | 60bc1e01e0eaf88f6c8e959cb6316e20ac910ed2 | [
"BSD-3-Clause"
]
| 41 | 2015-05-10T17:08:50.000Z | 2022-01-19T01:15:19.000Z | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is built by mktables from e.g. UnicodeData.txt.
# Any changes made here will be lost!
#
# This file supports:
# \p{Zl}
# \p{Zl} (and fuzzy permutations)
#
# Meaning: General Category 'Zl'
#
return <<'END';
2028
END
| 18.533333 | 59 | 0.618705 |
73d9eb89aa57700a0b16e9bbb19e206a2d497828 | 527 | ph | Perl | Polyline/Polyline14/HumanInterface/$SrcVersion/PolylineTextRu/PolylineTextRu.ph | PdcVipSolutions/SpbExamples | 70b9767910316720fc3adf04b640027e3391f2c0 | [
"MIT"
]
| null | null | null | Polyline/Polyline14/HumanInterface/$SrcVersion/PolylineTextRu/PolylineTextRu.ph | PdcVipSolutions/SpbExamples | 70b9767910316720fc3adf04b640027e3391f2c0 | [
"MIT"
]
| null | null | null | Polyline/Polyline14/HumanInterface/$SrcVersion/PolylineTextRu/PolylineTextRu.ph | PdcVipSolutions/SpbExamples | 70b9767910316720fc3adf04b640027e3391f2c0 | [
"MIT"
]
| null | null | null | /*****************************************************************************
Copyright (c) Victor Yukhtenko
SpbSolutions/Examples/Polyline
******************************************************************************/
#requires @"PolylineTextRu\PolylineTextRu.pack"
% publicly used packages
#include @"HumanInterface.ph"
#include @"pfc\core.ph"
#include @"Interfaces\PolyLineInterfaces.ph"
#include @"HumanInterface\polylineText.i"
% exported interfaces
% exported classes
#include @"PolylineTextRu\polylineTextRu.cl"
| 27.736842 | 79 | 0.555977 |
ed51b2095f96c58d8242e06b8c018ad7ddb45b58 | 63 | pm | Perl | auto-lib/Azure/Databricks/ProvisioningState.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Azure/Databricks/ProvisioningState.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| null | null | null | auto-lib/Azure/Databricks/ProvisioningState.pm | pplu/azure-sdk-perl | 26cbef2d926f571bc1617c26338c106856f95568 | [
"Apache-2.0"
]
| 1 | 2021-04-08T15:26:39.000Z | 2021-04-08T15:26:39.000Z | package Azure::Databricks::ProvisioningState;
use Moose;
1;
| 12.6 | 45 | 0.761905 |
73e799c9f3e337ddd6ffe1192d73fcf3d031628c | 6,450 | pm | Perl | App-Catable/lib/App/Catable/Schema/Result/Account.pm | shlomif/catable | 2f656d7d9296f42d3a9d68dec85ddebdd786ebd9 | [
"MIT"
]
| 6 | 2015-04-09T11:04:56.000Z | 2020-09-24T22:05:52.000Z | App-Catable/lib/App/Catable/Schema/Result/Account.pm | shlomif/catable | 2f656d7d9296f42d3a9d68dec85ddebdd786ebd9 | [
"MIT"
]
| null | null | null | App-Catable/lib/App/Catable/Schema/Result/Account.pm | shlomif/catable | 2f656d7d9296f42d3a9d68dec85ddebdd786ebd9 | [
"MIT"
]
| null | null | null | package App::Catable::Schema::Result::Account;
use strict;
use warnings;
use Digest;
=head1 NAME
App::Catable::Schema::Account - a schema class representing an account.
=head1 SYNOPSIS
my $schema = App::Catable->model("BlogDB");
my $account_rs = $schema->resultset('Account');
my $account = $account_rs->find({
id => 2_400,
});
print $account->display_name();
=head1 DESCRIPTION
This is the account schema class for L<App::Catable>. It represents a login
using OpenID or whatever.
=head1 FIELDS
This field list also comprises a method list, since DBIC
creates accessor methods for each field.
=head2 id
Auto-incremented user ID.
=head2 url
This is the 'username' for OpenID authentication. If set, the user is an
OpenID user, and the C<username> and C<password> fields will not be set.
=head2 username
This is the username for login using the local user system.
=head2 password
This is the password for login using the local user system.
=head2 homepage
=head2 real_name
=head2 nickname
=head2 age
=head2 gender
These are all optional fields for the user to fill in if they wish.
=head2 last_logon_ts
A timestamp for when the user last successfully logged on.
=head2 ctime
A timestamp for when the account was created.
=head2 mtime
A timestamp for when the account was last updated.
=head1 METHODS
=cut
use base qw( DBIx::Class );
__PACKAGE__->load_components( qw( TimeStamp InflateColumn::DateTime Core ) );
__PACKAGE__->table( 'account' );
__PACKAGE__->resultset_class('App::Catable::Schema::ResultSet::Account');
__PACKAGE__->add_columns(
id => {
data_type => 'bigint',
is_auto_increment => 1,
is_nullable => 0,
},
url => {
data_type => 'varchar',
size => 1024,
is_nullable => 1,
},
username => {
data_type => 'varchar',
size => 50,
is_nullable => 1,
},
password => {
data_type => 'char',
size => 40,
is_nullable => 1,
},
homepage => {
data_type => 'varchar',
size => 1024,
is_nullable => 1,
},
real_name => {
data_type => 'varchar',
size => 100,
is_nullable => 1,
},
nickname => {
data_type => 'varchar',
size => 100,
is_nullable => 1,
},
age => {
data_type => 'int',
size => 3,
is_nullable => 1,
},
gender => {
data_type => 'char',
size => 1,
is_nullable => 1,
},
last_logon_ts => {
data_type => 'datetime',
is_nullable => 0,
set_on_create => 1,
},
ctime => {
data_type => 'datetime',
is_nullable => 0,
set_on_create => 1,
},
mtime => {
data_type => 'datetime',
is_nullable => 0,
set_on_create => 1,
set_on_update => 1,
},
);
__PACKAGE__->set_primary_key( qw( id ) );
__PACKAGE__->add_unique_constraint ( [ 'url' ]);
__PACKAGE__->might_have(
blogs => 'App::Catable::Schema::Result::Blog',
'owner_id',
);
__PACKAGE__->might_have(
posts => 'App::Catable::Schema::Result::Entry',
'author_id',
{ where => { 'foreign.parent_id' => 0 }},
);
=head2 new
=head4 Parameters
Hashref containing C<username> and C<password>. You may also pass in a hashref under
the C<options> key. That hashref is used as follows.
The password will be hashed using the SHA-1 algorithm unless you pass in a type in
the C<password_type> hash key.
For convenience, and to make it easier to borrow code, the hashing types supported
are the same as those supported by the Catalyst Authentication plugin's Password
credential type (as of Authentication v0.10011) - C<clear>, C<crypted>,
C<salted_hash>, C<hashed>.
To support the C<salted_hash> and C<hashed> types you need to therefore pass
in either C<password_salt_len> or C<password_pre_salt> and C<password_post_salt>
as well.
To support the C<crypted> type you will have to also provide a C<password_salt>. This
is only used to create the password, and if you're using crypted then I assume you know
how it all works anyway.
Bright sparks will notice, then, that this means you can combine the
C<$c->config('Plugin::Authentication')->{$realm}->{credential}> config to the
Authentication plugin with a C<password_salt> if you are using C<crypted>, and pass
this whole hash as a reference under C<options>.
=cut
sub new {
my ($class, $args) = @_;
my $options = delete $args->{options} || {};
my $self = $class->next::method( $args );
$options->{password_type} ||= 'hashed';
$options->{password_hash_type} ||= 'SHA-1';
my $password = $self->password;
if ($options->{'password_type'} eq 'crypted') {
$password = crypt( $password, $options->{password_salt} );
}
elsif ($options->{'password_type'} eq 'salted_hash') {
require Crypt::SaltedHash;
my $salt_len = $options->{'password_salt_len'} ? $options->{'password_salt_len'} : 0;
my $shash = Crypt::SaltedHash->new( salt_len => $salt_len );
$shash->add( $args->{password} );
$password = $shash->generate;
}
elsif ($options->{'password_type'} eq 'hashed') {
my $d = Digest->new( $options->{'password_hash_type'} );
$d->add( $options->{'password_pre_salt'} || '' );
$d->add( $password );
$d->add( $options->{'password_post_salt'} || '' );
my $computed = $d->clone()->digest;
# me running tests shows that this is the one that gives us a 40-char string
$password = unpack( "H*", $computed );
}
$self->password( $password );
return $self;
}
=head2 $self->display()
The display name for the account - either the username or the OpenID URL.
=cut
sub display
{
my $self = shift;
return $self->username() || $self->url();
}
=head1 SEE ALSO
L<App::Catable::Schema>, L<App::Catable>, L<DBIx::Class>
L<App::Catable::Schema::Post>
=head1 AUTHOR
Shlomi Fish L<http://www.shlomifish.org/> .
=head1 LICENSE
This module is free software, available under the MIT X11 Licence:
L<http://www.opensource.org/licenses/mit-license.php>
Copyright by Shlomi Fish, 2009.
=cut
1;
| 24.157303 | 93 | 0.609302 |
ed3d2ba1877ef0c8fb0b0471b092f269a8afdbb2 | 754 | pl | Perl | adjust_line_number_HYPERGEOMETRIC_RATIO_TEST_INPUT_FILE.pl | AbhiRatnakumar/omnigenic_ppi_core_genes_plos_genetics_paper | f0c6b3ec71d9b6df385e9fc7ff3a0c675cdd74b8 | [
"MIT"
]
| 4 | 2020-08-21T07:06:15.000Z | 2021-11-16T15:05:26.000Z | adjust_line_number_HYPERGEOMETRIC_RATIO_TEST_INPUT_FILE.pl | AbhiRatnakumar/omnigenic_ppi_core_genes_plos_genetics_paper | f0c6b3ec71d9b6df385e9fc7ff3a0c675cdd74b8 | [
"MIT"
]
| 1 | 2021-11-15T17:01:33.000Z | 2021-11-15T17:01:33.000Z | adjust_line_number_HYPERGEOMETRIC_RATIO_TEST_INPUT_FILE.pl | AbhiRatnakumar/omnigenic_ppi_core_genes_plos_genetics_paper | f0c6b3ec71d9b6df385e9fc7ff3a0c675cdd74b8 | [
"MIT"
]
| null | null | null | #!/usr/bin/perl
&loop_though_all_the_lines;
sub loop_though_all_the_lines
{
foreach my $file (`ls HYPERGEOMETRIC_RATIO_TEST_INPUT_FILE_for_all_studies_[a-z][a-z]`)
{
chomp($file);
&adjust_line_number($file);
}
}
sub adjust_line_number
{
my $file_in = shift;
open(INFO, $file_in);
my $file_out = $file_in."_line_count_adjusted.txt";
open(OUT, ">$file_out");
print OUT "line_count\tstudy\tno_gwas_hits\tno_in_ppi_family\tintersection\tline\tloci_line\tcount_unique_loci\tcount_of_loci\n";
my $line_count = 1;
while(<INFO>)
{
chomp;
my ($old_line_count, $rest_of_the_line) = split(/\t/,$_,2);
if(!($_ =~ /line_count/))
{
print OUT "$line_count\t$rest_of_the_line\n";
$line_count++;
}
}
close(INFO);
close(OUT);
}
| 18.85 | 130 | 0.701592 |
ed08e858d8b1e222ae8efb12be1370d47b9f9f59 | 389 | t | Perl | t/CAD-Format-DWG-AC2_10/087-header-variables-snap_base_x.t | michal-josef-spacek/CAD-Format-DWG-AC2_10 | 29135430eed296083d5f804eda669b196a9afcbf | [
"BSD-2-Clause"
]
| null | null | null | t/CAD-Format-DWG-AC2_10/087-header-variables-snap_base_x.t | michal-josef-spacek/CAD-Format-DWG-AC2_10 | 29135430eed296083d5f804eda669b196a9afcbf | [
"BSD-2-Clause"
]
| null | null | null | t/CAD-Format-DWG-AC2_10/087-header-variables-snap_base_x.t | michal-josef-spacek/CAD-Format-DWG-AC2_10 | 29135430eed296083d5f804eda669b196a9afcbf | [
"BSD-2-Clause"
]
| null | null | null | use strict;
use warnings;
use CAD::Format::DWG::AC2_10;
use File::Object;
use Test::More 'tests' => 2;
use Test::NoWarnings;
# Data directory.
my $data_dir = File::Object->new->up->dir('data/header/snap_base_x')->set;
# Test.
my $obj = CAD::Format::DWG::AC2_10->from_file(
$data_dir->file('BLANK.DWG')->s,
);
is($obj->header->variables->snap_base->x, 0, 'Snap base x (0 - default).');
| 22.882353 | 75 | 0.663239 |
73f07ced079a0a7081ad3b4d884fd6299002df3c | 2,382 | pm | Perl | perl/vendor/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
]
| 2 | 2021-11-19T22:37:28.000Z | 2021-11-22T18:04:55.000Z | perl/vendor/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
]
| 6 | 2021-11-18T00:39:48.000Z | 2021-11-20T00:31:40.000Z | perl/vendor/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm | ifleeyo180/VspriteMoodleWebsite | 38baa924829c83808d2c87d44740ff365927a646 | [
"Apache-2.0"
]
| null | null | null | package Moose::Meta::Attribute::Native::Trait::Bool;
our $VERSION = '2.2014';
use Moose::Role;
with 'Moose::Meta::Attribute::Native::Trait';
sub _helper_type { 'Bool' }
no Moose::Role;
1;
# ABSTRACT: Helper trait for Bool attributes
__END__
=pod
=encoding UTF-8
=head1 NAME
Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
=head1 VERSION
version 2.2014
=head1 SYNOPSIS
package Room;
use Moose;
has 'is_lit' => (
traits => ['Bool'],
is => 'rw',
isa => 'Bool',
default => 0,
handles => {
illuminate => 'set',
darken => 'unset',
flip_switch => 'toggle',
is_dark => 'not',
},
);
my $room = Room->new();
$room->illuminate; # same as $room->is_lit(1);
$room->darken; # same as $room->is_lit(0);
$room->flip_switch; # same as $room->is_lit(not $room->is_lit);
return $room->is_dark; # same as !$room->is_lit
=head1 DESCRIPTION
This trait provides native delegation methods for boolean values. A boolean is
a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
=head1 DEFAULT TYPE
If you don't provide an C<isa> value for your attribute, it will default to
C<Bool>.
=head1 PROVIDED METHODS
None of these methods accept arguments.
=over 4
=item * B<set>
Sets the value to C<1> and returns C<1>.
=item * B<unset>
Set the value to C<0> and returns C<0>.
=item * B<toggle>
Toggles the value. If it's true, set to false, and vice versa.
Returns the new value.
=item * B<not>
Equivalent of 'not C<$value>'.
=back
=head1 BUGS
See L<Moose/BUGS> for details on reporting bugs.
=head1 AUTHORS
=over 4
=item *
Stevan Little <stevan@cpan.org>
=item *
Dave Rolsky <autarch@urth.org>
=item *
Jesse Luehrs <doy@cpan.org>
=item *
Shawn M Moore <sartak@cpan.org>
=item *
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
=item *
Karen Etheridge <ether@cpan.org>
=item *
Florian Ragwitz <rafl@debian.org>
=item *
Hans Dieter Pearcey <hdp@cpan.org>
=item *
Chris Prather <chris@prather.org>
=item *
Matt S Trout <mstrout@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Infinity Interactive, Inc.
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
| 16.204082 | 78 | 0.651553 |
ed17be2019646d3147e48774d460ba8b3dba0207 | 577 | pl | Perl | src/main/perl/uniqBed.pl | dnaase/QRF_spark | fb8982c9e7d468ba14d15ebe8db3b49e11d52431 | [
"MIT"
]
| null | null | null | src/main/perl/uniqBed.pl | dnaase/QRF_spark | fb8982c9e7d468ba14d15ebe8db3b49e11d52431 | [
"MIT"
]
| null | null | null | src/main/perl/uniqBed.pl | dnaase/QRF_spark | fb8982c9e7d468ba14d15ebe8db3b49e11d52431 | [
"MIT"
]
| null | null | null | ## get unique row of bed files, input bed file should be sorted already.
## author: Yaping Liu lyping1986@gmail.com
$bed_file=$ARGV[0];
my $use_age = "USAGE: perl uniqBed.pl input_sorted_bed > output_uniq_bed";
if($ARGV[0] eq ""){
print "$use_age\n";
exit(1);
}
open(FH,"<$bed_file") or die;
my $chr="";
my $start="";
my $end="";
while(<FH>){
chomp;
my $line=$_;
my @splitin = split "\t",$line;
if($splitin[0] ne $chr or $splitin[1] ne $start or $splitin[2] ne $end){
print "$line\n";
$chr=$splitin[0];
$start=$splitin[1];
$end=$splitin[2];
}
}
close(FH); | 20.607143 | 74 | 0.622184 |
73e555ab709719e78639bf2ff36b7c10bdda022e | 41,465 | pl | Perl | api/sesame.pl | Baytars/ClioPatria | be9a753a4a1a82e8b21c72dadeefd32100fbde6d | [
"BSD-2-Clause"
]
| 42 | 2015-03-07T08:00:39.000Z | 2022-03-07T18:21:03.000Z | api/sesame.pl | Baytars/ClioPatria | be9a753a4a1a82e8b21c72dadeefd32100fbde6d | [
"BSD-2-Clause"
]
| 58 | 2015-02-10T08:19:51.000Z | 2022-02-17T17:04:38.000Z | api/sesame.pl | Baytars/ClioPatria | be9a753a4a1a82e8b21c72dadeefd32100fbde6d | [
"BSD-2-Clause"
]
| 17 | 2015-01-16T15:30:10.000Z | 2022-02-17T03:18:24.000Z | /* Part of ClioPatria SeRQL and SPARQL server
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 2010-2018, University of Amsterdam,
VU University 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(api_sesame,
[ api_action/4 % +Request, +Goal, +Format, +Message
]).
:- use_module(rdfql(serql)).
:- use_module(rdfql(sparql)).
:- use_module(rdfql(rdf_io)).
:- use_module(rdfql(rdf_html)).
:- use_module(library(http/http_parameters)).
:- use_module(user(user_db)).
:- use_module(library(semweb/rdfs)).
:- use_module(library(semweb/rdf_db)).
:- use_module(library(semweb/rdf_http_plugin)).
:- use_module(library(semweb/rdf_file_type)).
:- use_module(library(semweb/rdf_persistency)).
:- use_module(library(http/html_write)).
:- use_module(library(http/http_request_value)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_client)).
:- use_module(library(http/http_open)).
:- use_module(library(http/json)).
:- use_module(library(memfile)).
:- use_module(library(debug)).
:- use_module(library(lists)).
:- use_module(library(option)).
:- use_module(library(apply)).
:- use_module(library(settings)).
:- use_module(components(query)).
:- use_module(components(basics)).
:- use_module(components(messages)).
:- meta_predicate(api_action2(+,0,+,+)).
:- http_handler(sesame('login'), http_login, []).
:- http_handler(sesame('logout'), http_logout, []).
:- http_handler(sesame('evaluateQuery'), evaluate_query,
[spawn(sparql_query)]).
:- http_handler(sesame('evaluateGraphQuery'), evaluate_graph_query,
[spawn(sparql_query)]).
:- http_handler(sesame('evaluateTableQuery'), evaluate_table_query,
[spawn(sparql_query)]).
:- http_handler(sesame('extractRDF'), extract_rdf, []).
:- http_handler(sesame('listRepositories'), list_repositories, []).
:- http_handler(sesame('clearRepository'), clear_repository, []).
:- http_handler(sesame('unloadSource'), unload_source,
[ time_limit(infinite) ]).
:- http_handler(sesame('unloadGraph'), unload_graph,
[ time_limit(infinite) ]).
:- http_handler(sesame('uploadData'), upload_data,
[ time_limit(infinite) ]).
:- http_handler(sesame('uploadURL'), upload_url,
[ time_limit(infinite) ]).
:- http_handler(sesame('removeStatements'), remove_statements,
[ time_limit(infinite) ]).
:- http_handler(sesame('flushJournal'), flush_journal,
[ time_limit(infinite) ]).
:- http_handler(sesame('modifyPersistency'), modify_persistency,
[ time_limit(infinite) ]).
:- http_handler(sesame('addPrefix'), add_prefix, []).
:- http_handler(sesame('defPrefix'), del_prefix, []).
:- html_meta
api_action(+, 0, +, html).
%! http_login(+Request)
%
% HTTP handler to associate the current session with a local user.
% If the login succeeds a 200 reply according to the resultFormat
% parameters is sent. If the result fails due to a wrong
% user/password, the server responds with a 403 (forbidden)
% message. Other failures result in a 500 (server error).
%
% @see help('howto/ClientAuth.txt') for additional information on
% authetication.
http_login(Request) :-
http_parameters(Request,
[ user(User),
password(Password),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
api_action(Request,
( validate_login(Request, User, Password),
login(User)
),
ResultFormat,
'Login ~w'-[User]).
validate_login(_, User, Password) :-
validate_password(User, Password),
!.
validate_login(Request, _, _) :-
memberchk(path(Path), Request),
throw(http_reply(forbidden(Path))).
%! http_logout(+Request)
%
% HTTP handler to logout current user.
http_logout(Request) :-
http_parameters(Request,
[ resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
api_action(Request,
logout_user(Message),
ResultFormat,
Message).
logout_user('Logout ~w'-[User]) :-
logged_on(User),
!,
logout(User).
logout_user('Not logged on'-[]).
%! evaluate_query(+Request) is det.
%
% HTTP handler for both SeRQL and SPARQL queries. This handler
% deals with _interactive_ queries. Machines typically access
% /sparql/ to submit queries and process result compliant to the
% SPARQL protocol.
evaluate_query(Request) :-
http_parameters(Request,
[ repository(Repository),
query(Query),
queryLanguage(QueryLanguage),
resultFormat(ResultFormat),
serialization(Serialization),
resourceFormat(ResourceFormat),
entailment(Entailment),
storeAs(SaveAs)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
statistics(cputime, CPU0),
downcase_atom(QueryLanguage, QLang),
compile(QLang, Query, Compiled,
[ entailment(Entailment),
type(Type)
]),
authorized_query(Type, Repository, ResultFormat),
findall(Reply, run(QLang, Compiled, Reply), Result),
statistics(cputime, CPU1),
CPU is CPU1 - CPU0,
store_query(construct, SaveAs, Query),
( graph_type(Type)
-> write_graph(Result,
[ result_format(ResultFormat),
serialization(Serialization),
resource_format(ResourceFormat),
cputime(CPU)
])
; Type = select(VarNames)
-> write_table(Result,
[ variables(VarNames),
result_format(ResultFormat),
serialization(Serialization),
resource_format(ResourceFormat),
cputime(CPU)
])
; Type == ask, Result = [Reply]
-> reply_html_page(cliopatria(default),
title('ASK Result'),
[ h4('ASK query completed'),
p(['Answer = ', Reply])
])
; Type == update, Result = [Reply]
-> reply_html_page(cliopatria(default),
title('Update Result'),
[ h4('Update query completed'),
p(['Answer = ', Reply])
])
).
authorized_query(update, Repository, ResultFormat) :-
!,
authorized_api(write(Repository, sparql(update)), ResultFormat).
authorized_query(_, Repository, ResultFormat) :-
authorized_api(read(Repository, query), ResultFormat).
%! evaluate_graph_query(+Request)
%
% Handle CONSTRUCT queries.
evaluate_graph_query(Request) :-
http_parameters(Request,
[ repository(Repository),
query(Query),
queryLanguage(QueryLanguage),
resultFormat(ResultFormat),
serialization(Serialization),
resourceFormat(ResourceFormat),
entailment(Entailment),
storeAs(SaveAs)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(read(Repository, query), ResultFormat),
statistics(cputime, CPU0),
downcase_atom(QueryLanguage, QLang),
compile(QLang, Query, Compiled,
[ entailment(Entailment),
type(Type)
]),
( graph_type(Type)
-> true
; throw(error(domain_error(query_type(graph), Type), _))
),
findall(T, run(QLang, Compiled, T), Triples),
statistics(cputime, CPU1),
store_query(construct, SaveAs, Query),
CPU is CPU1 - CPU0,
write_graph(Triples,
[ result_format(ResultFormat),
serialization(Serialization),
resource_format(ResourceFormat),
cputime(CPU)
]).
graph_type(construct).
graph_type(describe).
%! evaluate_table_query(+Request)
%
% Handle SELECT queries.
evaluate_table_query(Request) :-
http_parameters(Request,
[ repository(Repository),
query(Query),
queryLanguage(QueryLanguage),
resultFormat(ResultFormat),
serialization(Serialization),
resourceFormat(ResourceFormat),
entailment(Entailment),
storeAs(SaveAs)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(read(Repository, query), ResultFormat),
statistics(cputime, CPU0),
downcase_atom(QueryLanguage, QLang),
compile(QLang, Query, Compiled,
[ entailment(Entailment),
type(select(VarNames))
]),
findall(R, run(QLang, Compiled, R), Rows),
statistics(cputime, CPU1),
CPU is CPU1 - CPU0,
store_query(select, SaveAs, Query),
write_table(Rows,
[ variables(VarNames),
result_format(ResultFormat),
serialization(Serialization),
resource_format(ResourceFormat),
cputime(CPU)
]).
%! compile(+Language, +Query, -Compiled, +Options)
%
% Compile a query and validate the query-type
compile(serql, Query, Compiled, Options) :-
!,
serql_compile(Query, Compiled, Options).
compile(sparql, Query, Compiled, Options) :-
!,
sparql_compile(Query, Compiled, Options).
compile(Language, _, _, _) :-
throw(error(domain_error(query_language, Language), _)).
%! run(+Language, +Compiled, -Reply)
run(serql, Compiled, Reply) :-
serql_run(Compiled, Reply).
run(sparql, Compiled, Reply) :-
sparql_run(Compiled, Reply).
%! extract_rdf(+Request)
%
% HTTP handler to extract RDF from the database. This handler
% separates the data into schema data and non-schema data, where
% schema data are triples whose subject is an rdfs:Class or
% rdf:Property. By default both are =off=, so one needs to pass
% either or both of the =schema= and =data= options as =on=.
extract_rdf(Request) :-
http_parameters(Request,
[ repository(Repository),
schema(Schema),
data(Data),
explicitOnly(ExplicitOnly),
niceOutput(_NiceOutput),
serialization(Serialization)
],
[ attribute_declarations(attribute_decl)
]),
authorized(read(Repository, download)),
statistics(cputime, CPU0),
findall(T, export_triple(Schema, Data, ExplicitOnly, T), Triples),
statistics(cputime, CPU1),
CPU is CPU1 - CPU0,
write_graph(Triples,
[ serialization(Serialization),
cputime(CPU)
]).
%! export_triple(+Schema, +Data, +ExplicitOnly, -RDF).
export_triple(off, off, _, _) :-
!,
fail. % no data requested
export_triple(on, on, on, rdf(S,P,O)) :-
!,
rdf_db:rdf(S,P,O).
export_triple(on, on, off, rdf(S,P,O)) :-
!,
rdfs_entailment:rdf(S,P,O).
export_triple(off, on, Explicit, RDF) :-
export_triple(on, on, Explicit, RDF),
\+ schema_triple(RDF).
export_triple(on, off, Explicit, RDF) :-
export_triple(on, on, Explicit, RDF),
schema_triple(RDF).
schema_triple(rdf(S,_P,_O)) :-
rdfs_individual_of(S, rdf:'Property').
schema_triple(rdf(S,_P,_O)) :-
rdfs_individual_of(S, rdfs:'Class').
%! list_repositories(+Request)
%
% List the available repositories. This is only =default= for now
list_repositories(_Request) :-
Repository = default,
logged_on(User, anonymous),
( catch(check_permission(User, write(Repository, _)), _, fail)
-> Write = true
; Write = false
),
( catch(check_permission(User, read(Repository, _)), _, fail)
-> Read = true
; Read = false
),
format('Content-type: text/xml~n~n'),
format('<?xml version="1.0" encoding="ISO-8859-1"?>~n~n', []),
format('<repositorylist>~n'),
format(' <repository id="default" readable="~w" writeable="~w">~n',
[ Read, Write ]),
format(' <title>Default repository</title>~n'),
format(' </repository>~n'),
format('</repositorylist>~n').
%! clear_repository(+Request)
%
% Clear the repository.
clear_repository(Request) :-
http_parameters(Request,
[ repository(Repository),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, clear), ResultFormat),
api_action(Request,
rdf_reset_db,
ResultFormat,
'Clear database'-[]).
%! unload_source(+Request)
%
% Remove triples loaded from a specified source
unload_source(Request) :-
http_parameters(Request,
[ repository(Repository),
source(Source),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, unload(Source)), ResultFormat),
api_action(Request, rdf_unload(Source),
ResultFormat,
'Unload triples from ~w'-[Source]).
%! unload_graph(+Request)
%
% Remove a named graph.
unload_graph(Request) :-
http_parameters(Request,
[ repository(Repository),
graph(Graph, []),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, unload(Graph)), ResultFormat),
api_action(Request, rdf_unload_graph(Graph),
ResultFormat,
'Unload triples from ~w'-[Graph]).
%! flush_journal(+Request)
%
% Flush the journal of the requested graph
flush_journal(Request) :-
http_parameters(Request,
[ repository(Repository),
graph(Graph, []),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, unload(Graph)), ResultFormat),
api_action(Request, rdf_flush_journals([graph(Graph)]),
ResultFormat,
'Flushed journals for graph ~w'-[Graph]).
%! modify_persistency(+Request)
%
% Change the persistent properties for the requested graph
modify_persistency(Request) :-
http_parameters(Request,
[ repository(Repository),
graph(Graph, []),
resultFormat(ResultFormat),
persistent(Persistent)
],
[ attribute_declarations(attribute_decl)
]),
persistency(Persistent, PVal, Action),
result_format(Request, ResultFormat),
authorized_api(write(Repository, persistent(Graph)), ResultFormat),
api_action(Request, rdf_persistency(Graph, PVal),
ResultFormat,
'~w persistency for graph ~w'-[Action, Graph]).
persistency(on, true, 'Set').
persistency(off, false, 'Cleared').
%! upload_data(Request).
%
% Sesame compliant method to upload data to the repository,
% typically used to handle a POST-form from a web-browser (e.g.,
% _|Load local file|_ in the ClioPatria menu). If =dataFormat= is
% omitted, the format of the data is guessed from the data itself.
% Currently, this possitively identifies valid RDF/XML and assumes
% that anything else is Turtle.
:- if(current_predicate(http_convert_parameters/3)).
%! create_tmp_file(+Stream, -Out, +Options) is det.
%
% Called from library(http/http_multipart_plugin) to process
% uploaded file from a form.
%
% @arg Stream is the input stream. It signals EOF at the end of
% the part, but must *not* be closed.
% @arg Options provides information about the part. Typically,
% this contains filename(FileName) and optionally media(Type,
% MediaParams).
:- public create_tmp_file/3.
create_tmp_file(Stream, file(File, Options), Options) :-
setup_call_catcher_cleanup(
tmp_file_stream(binary, File, Out),
copy_stream_data(Stream, Out),
Why,
cleanup(Why, File, Out)).
cleanup(Why, File, Out) :-
close(Out),
( Why == exit
-> true
; catch(delete_file(File), _, true)
).
%! upload_data_file(+Request, +FormData, +TempFile, +FileOptions)
%
% Load RDF from TempFile with additional form data provided in
% FormData. Options are the options passed from the uploaded file
% and include filename(Name) and optionally media(Type, Params).
upload_data_file(Request, Data, TmpFile, FileOptions) :-
http_convert_parameters(Data,
[ repository(Repository),
dataFormat(DataFormat),
baseURI(BaseURI),
verifyData(_Verify),
resultFormat(ResultFormat)
],
attribute_decl),
result_format(Request, ResultFormat),
authorized_api(write(Repository, load(posted)), ResultFormat),
phrase(load_option(DataFormat, BaseURI), LoadOptions),
append(LoadOptions, FileOptions, Options),
api_action(Request,
setup_call_cleanup(
open(TmpFile, read, Stream),
rdf_guess_format_and_load(Stream, Options),
close(Stream)),
ResultFormat,
'Load data from POST'-[]).
upload_option(_=_) :- !.
upload_option(Term) :- functor(Term, _, 1).
upload_data(Request) :-
option(method(post), Request),
!,
http_read_data(Request, Data,
[ on_filename(create_tmp_file)
]),
( option(data(file(TmpFile, FileOptions)), Data)
-> true
; existence_error(attribute_declaration, data)
),
include(upload_option, FileOptions, Options),
call_cleanup(upload_data_file(Request, Data, TmpFile, Options),
catch(delete_file(TmpFile), _, true)).
:- endif.
upload_data(Request) :-
http_parameters(Request,
[ repository(Repository),
data(Data,
[ description('RDF data to be loaded')
]),
dataFormat(DataFormat),
baseURI(BaseURI),
verifyData(_Verify),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, load(posted)), ResultFormat),
phrase(load_option(DataFormat, BaseURI), Options),
atom_to_memory_file(Data, MemFile),
api_action(Request,
setup_call_cleanup(open_memory_file(MemFile, read, Stream),
rdf_guess_format_and_load(Stream, Options),
( close(Stream),
free_memory_file(MemFile)
)),
ResultFormat,
'Load data from POST'-[]).
%! upload_url(+Request)
%
% Load data from an HTTP server. This API is compatible to Sesame,
% although the =verifyData= option is not implemented (data is
% always checked for syntax). Unlike Sesame, the default format is
% not =rdfxml=, but derived from the Content-type reported by the
% server.
%
% @see Calls rdf_load/2 for the actual loading.
% @see load_url_form/1 a form to access this API
upload_url(Request) :-
http_parameters(Request,
[ url(URL, []),
dataFormat(DataFormat),
baseURI(BaseURI,
[ default(URL)
]),
resultFormat(ResultFormat),
verifyData(_Verify),
repository(Repository)
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
authorized_api(write(Repository, load(url(URL))), ResultFormat),
phrase(load_option(DataFormat, BaseURI), Options),
api_action(Request,
load_from_url(URL, Options),
ResultFormat,
'Load data from ~w'-[URL]).
load_from_url(URL, Options) :-
http_open(URL, In,
[ cert_verify_hook(ssl_verify)
]),
call_cleanup(rdf_guess_format_and_load(In, Options),
close(In)).
:- public ssl_verify/5.
%! ssl_verify(+SSL, +ProblemCert, +AllCerts, +FirstCert, +Error)
%
% Currently we accept all certificates. We organise our own
% security using SHA1 signatures, so we do not care about the
% source of the data.
ssl_verify(_SSL,
_ProblemCertificate, _AllCertificates, _FirstCertificate,
_Error).
load_option(DataFormat, BaseURI) -->
data_format_option(DataFormat),
base_uri_option(BaseURI).
data_format_option(Var) --> {var(Var)}, !.
data_format_option(rdfxml) --> [format(xml)].
data_format_option(ntriples) --> [format(turtle)].
data_format_option(turtle) --> [format(turtle)].
base_uri_option(Var) --> {var(Var)}, !.
base_uri_option(URI) --> [base_uri(URI)].
%! remove_statements(+Request)
%
% Remove statements from the database
remove_statements(Request) :-
http_parameters(Request,
[ repository(Repository, [optional(true)]),
resultFormat(ResultFormat),
% as documented
subject(Subject, [optional(true)]),
predicate(Predicate, [optional(true)]),
object(Object, [optional(true)]),
% remove (turtle) graph
baseURI(BaseURI),
dataFormat(DataFormat),
data(Data, [optional(true)])
],
[ attribute_declarations(attribute_decl)
]),
result_format(Request, ResultFormat),
instantiated(Subject, SI),
instantiated(Predicate, PI),
instantiated(Object, OI),
authorized_api(write(Repository, remove_statements(SI, PI, OI)),
ResultFormat),
( nonvar(Data)
-> setup_call_cleanup(( atom_to_memory_file(Data, MemFile),
open_memory_file(MemFile, read, Stream,
[ free_on_close(true)
])
),
( rdf_guess_data_format(Stream, DataFormat),
get_triples(stream(Stream),
Triples,
[ base_uri(BaseURI),
data_format(DataFormat)
])
),
close(Stream)),
length(Triples, NTriples),
debug(removeStatements, 'Removing ~D statements', [NTriples]),
api_action(Request,
remove_triples(Triples),
ResultFormat,
'Remove ~D triples'-[NTriples])
; debug(removeStatements, 'removeStatements = ~w',
[rdf(Subject, Predicate, Object)]),
ntriple_part(Subject, subject, S),
ntriple_part(Predicate, predicate, P),
ntriple_part(Object, object, O),
debug(removeStatements, 'Action = ~q', [rdf_retractall(S,P,O)]),
api_action(Request,
rdf_retractall(S,P,O),
ResultFormat,
'Remove statements from ~k'-[rdf(S,P,O)])
).
%! remove_triples(+List)
%
% Remove indicated triples from the database.
remove_triples([]).
remove_triples([rdf(S,P,O)|T]) :-
rdf_retractall(S,P,O),
remove_triples(T).
instantiated(X, I) :-
( var(X)
-> I = (-)
; I = (+)
).
ntriple_part(In, _, _) :-
var(In),
!.
ntriple_part('', _, _) :- !.
ntriple_part(In, Field, Out) :-
atom_codes(In, Codes),
phrase(rdf_ntriple_part(Field, Out), Codes),
!.
ntriple_part(Text, Field, _) :-
throw(error(type_error(ntriples(Field), Text),
context(_,
'Field must be in N-triples notation'))).
%! rdf_ntriple_part(+Type, -Value)//
%
% Parse one of the fields of an ntriple. This is used for the
% SWI-Prolog Sesame (rdf4j.org) implementation to realise
% /servlets/removeStatements. I do not think public use of this
% predicate should be stimulated.
rdf_ntriple_part(subject, Subject) -->
subject(Subject).
rdf_ntriple_part(predicate, Predicate) -->
predicate(Predicate).
rdf_ntriple_part(object, Object) -->
object(Object).
subject(Subject) -->
uniref(Subject),
!.
subject(Subject) -->
node_id(Subject).
predicate(Predicate) -->
uniref(Predicate).
object(Object) -->
uniref(Object),
!.
object(Object) -->
node_id(Object).
object(Object) -->
literal(Object).
uniref(URI) -->
"<",
escaped_uri_codes(Codes),
">",
!,
{ atom_codes(URI, Codes)
}.
node_id(node(Id)) --> % anonymous nodes
"_:",
name_start(C0),
name_codes(Codes),
{ atom_codes(Id, [C0|Codes])
}.
literal(Literal) -->
lang_string(Literal),
!.
literal(Literal) -->
xml_string(Literal).
% name_start(-Code)
% name_codes(-ListfCodes)
%
% Parse identifier names
name_start(C) -->
[C],
{ code_type(C, alpha)
}.
name_codes([C|T]) -->
[C],
{ code_type(C, alnum)
},
!,
name_codes(T).
name_codes([]) -->
[].
% escaped_uri_codes(-CodeList)
%
% Decode string holding %xx escaped characters.
escaped_uri_codes([]) -->
[].
escaped_uri_codes([C|T]) -->
"%", [D0,D1],
!,
{ code_type(D0, xdigit(V0)),
code_type(D1, xdigit(V1)),
C is V0<<4 + V1
},
escaped_uri_codes(T).
escaped_uri_codes([C|T]) -->
"\\u", [D0,D1,D2,D3],
!,
{ code_type(D0, xdigit(V0)),
code_type(D1, xdigit(V1)),
code_type(D2, xdigit(V2)),
code_type(D3, xdigit(V3)),
C is V0<<12 + V1<<8 + V2<<4 + V3
},
escaped_uri_codes(T).
escaped_uri_codes([C|T]) -->
"\\U", [D0,D1,D2,D3,D4,D5,D6,D7],
!,
{ code_type(D0, xdigit(V0)),
code_type(D1, xdigit(V1)),
code_type(D2, xdigit(V2)),
code_type(D3, xdigit(V3)),
code_type(D4, xdigit(V4)),
code_type(D5, xdigit(V5)),
code_type(D6, xdigit(V6)),
code_type(D7, xdigit(V7)),
C is V0<<28 + V1<<24 + V2<<20 + V3<<16 +
V4<<12 + V5<<8 + V6<<4 + V7
},
escaped_uri_codes(T).
escaped_uri_codes([C|T]) -->
[C],
escaped_uri_codes(T).
% lang_string()
%
% Process a language string
lang_string(String) -->
"\"",
string(Codes),
"\"",
!,
{ atom_codes(Atom, Codes)
},
( langsep
-> language(Lang),
{ String = literal(lang(Lang, Atom))
}
; "^^"
-> uniref(Type),
{ String = literal(type(Type, Atom))
}
; { String = literal(Atom)
}
).
langsep -->
"-".
langsep -->
"@".
% xml_string(String)
%
% Handle xml"..."
xml_string(xml(String)) -->
"xml\"", % really no whitespace?
string(Codes),
"\"",
{ atom_codes(String, Codes)
}.
string([]) -->
[].
string([C0|T]) -->
string_char(C0),
string(T).
string_char(0'\\) -->
"\\\\".
string_char(0'") -->
"\\\"".
string_char(10) -->
"\\n".
string_char(13) -->
"\\r".
string_char(9) -->
"\\t".
string_char(C) -->
"\\u",
'4xdigits'(C).
string_char(C) -->
"\\U",
'4xdigits'(C0),
'4xdigits'(C1),
{ C is C0<<16 + C1
}.
string_char(C) -->
[C].
'4xdigits'(C) -->
[C0,C1,C2,C3],
{ code_type(C0, xdigit(V0)),
code_type(C1, xdigit(V1)),
code_type(C2, xdigit(V2)),
code_type(C3, xdigit(V3)),
C is V0<<12 + V1<<8 + V2<<4 + V3
}.
% language(-Lang)
%
% Return xml:lang language identifier.
language(Lang) -->
lang_code(C0),
lang_codes(Codes),
{ atom_codes(Lang, [C0|Codes])
}.
lang_code(C) -->
[C],
{ C \== 0'.,
\+ code_type(C, white)
}.
lang_codes([C|T]) -->
lang_code(C),
!,
lang_codes(T).
lang_codes([]) -->
[].
%! add_prefix(+Request)
%
% Register a new prefix
add_prefix(Request) :-
http_parameters(Request,
[ prefix(Prefix),
uri(URI),
repository(Repository),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
authorized_api(write(Repository, add_prefix), ResultFormat),
check_prefix(Prefix),
api_action(Request,
rdf_register_prefix(Prefix, URI),
ResultFormat,
'Register prefix ~w --> ~w'-[Prefix, URI]).
del_prefix(Request) :-
http_parameters(Request,
[ prefix(Prefix),
repository(Repository),
resultFormat(ResultFormat)
],
[ attribute_declarations(attribute_decl)
]),
authorized_api(write(Repository, del_prefix), ResultFormat),
( rdf_current_prefix(Prefix, URI)
-> api_action(Request,
rdf_unregister_prefix(Prefix),
ResultFormat,
'Removed prefix ~w (was ~w)'-[Prefix, URI])
; api_action(Request,
true,
ResultFormat,
'Prefix ~w was unknown'-[Prefix])
).
:- if(\+current_predicate(rdf_unregister_prefix/1)).
rdf_unregister_prefix(Prefix) :-
retractall(rdf_db:ns(Prefix, _)).
:- endif.
check_prefix(Prefix) :-
xml_name(Prefix),
!.
check_prefix(Prefix) :-
domain_error(xml_name, Prefix).
/*******************************
* HTTP ATTRIBUTES *
*******************************/
%! attribute_decl(+OptionName, -Options)
%
% Default options for specified attribute names. See
% http_parameters/3.
attribute_decl(repository,
[ optional(true),
description('Name of the repository (ignored)')
]).
attribute_decl(query,
[ description('SPARQL or SeRQL quer-text')
]).
attribute_decl(queryLanguage,
[ default('SPARQL'),
oneof(['SeRQL', 'SPARQL']),
description('Query language used in query-text')
]).
attribute_decl(serialization,
[ default(rdfxml),
oneof([ rdfxml,
ntriples,
n3
]),
description('Serialization for graph-data')
]).
attribute_decl(resultFormat,
[ optional(true),
oneof([ xml,
html,
rdf,
json,
csv
]),
description('Serialization format of the result')
]).
attribute_decl(resourceFormat,
[ default(ns),
oneof([ plain,
ns,
nslabel
]),
description('How to format URIs in the table')
]).
attribute_decl(entailment, % cache?
[ default(Default),
oneof(Es),
description('Reasoning performed')
]) :-
setting(cliopatria:default_entailment, Default),
findall(E, cliopatria:entailment(E, _), Es).
attribute_decl(dataFormat,
[ optional(true),
oneof([rdfxml, ntriples, turtle]),
description('Serialization of the data')
]).
attribute_decl(baseURI,
[ default('http://example.org/'),
description('Base URI for relative resources')
]).
attribute_decl(source,
[ description('Name of the graph')
]).
attribute_decl(verifyData,
[ description('Verify the data (ignored)')
| Options
]) :-
bool(off, Options).
attribute_decl(schema,
[ description('Include schema RDF in downloaded graph')
| Options
]) :-
bool(off, Options).
attribute_decl(data,
[ description('Include non-schema RDF in downloaded graph')
| Options
]) :-
bool(off, Options).
attribute_decl(explicitOnly,
[ description('Do not include entailed triples')
| Options
]) :-
bool(off, Options).
attribute_decl(niceOutput,
[ description('Produce human-readable output (ignored; we always do that)')
| Options
]) :-
bool(off, Options).
attribute_decl(user,
[ description('User name')
]).
attribute_decl(password,
[ description('Clear-text password')
]).
% Our extensions
attribute_decl(storeAs,
[ default(''),
description('Store query under this name')
]).
attribute_decl(persistent,
[ description('Modify persistency of a graph'),
oneof([on, off])
]).
attribute_decl(uri,
[ description('URI')
]).
attribute_decl(prefix,
[ description('Prefix (abbreviation)')
]).
bool(Def,
[ default(Def),
oneof([on, off])
]).
%! result_format(+Request, ?Format) is det.
result_format(_Request, Format) :-
atom(Format),
!.
result_format(Request, _Format) :-
memberchk(accept(Accept), Request),
debug(sparql(result), 'Got accept = ~q', [Accept]),
fail.
result_format(_Request, xml).
accept_output_format(Request, Format) :-
memberchk(accept(Accept), Request),
( atom(Accept)
-> http_parse_header_value(accept, Accept, Media)
; Media = Accept
),
find_media(Media, Format),
!.
accept_output_format(_, xml).
find_media([media(Type, _, _, _)|T], Format) :-
( sparql_media(Type, Format)
-> true
; find_media(T, Format)
).
sparql_media(application/'sparql-results+xml', xml).
sparql_media(application/'sparql-results+json', json).
%! api_action(+Request, :Goal, +Format, +Message)
%
% Perform some -modifying- goal, reporting time, triples and
% subject statistics.
%
% @param Format specifies the result format and is one of =html=,
% =xml= or =rdf=.
% @param Message is passed to html_write//1.
api_action(Request, G, html, Message) :-
!,
call_showing_messages(
api_action2(Request, G, html, Message),
[ header(h4(Message)),
footer([])
]).
api_action(Request, G, Format, Message) :-
api_action2(Request, G, Format, Message).
api_action2(_Request, G, Format, Message) :-
logged_on(User, anonymous),
get_time(T0), T is integer(T0),
statistics(cputime, CPU0),
rdf_statistics(triples(Triples0)),
subjects(Subjects0),
run(G, sesame(User, T)),
subjects(Subjects1),
rdf_statistics(triples(Triples1)),
statistics(cputime, CPU1),
CPU is CPU1 - CPU0,
Triples is Triples1 - Triples0,
Subjects is Subjects1 - Subjects0,
done(Format, Message, CPU, Subjects, Triples).
:- if(rdf_statistics(subjects(_))). % RDF 2.x
subjects(Count) :- rdf_statistics(subjects(Count)).
subj_label --> html('Subjects').
:- else. % RDF 3.0
subjects(Count) :- rdf_statistics(resources(Count)).
subj_label --> html('Resources').
:- endif.
:- meta_predicate
run(0, +).
run(M:(A,B), Log) :-
!,
run(M:A, Log),
run(M:B, Log).
run(Goal, _) :-
no_transaction(Goal),
!,
call(Goal).
run(A, Log) :-
rdf_transaction(A, Log).
no_transaction(_:rdf_reset_db).
no_transaction(_:rdf_unload_graph(_)).
no_transaction(_:rdf_flush_journals(_)).
no_transaction(cpa_browse:multigraph_action(_,_)).
done(html, _Message, CPU, Subjects, Triples) :-
after_messages([ \result_table(CPU, Subjects, Triples)
]).
done(Format, _:Message, CPU, Subjects, Triples) :-
!,
done(Format, Message, CPU, Subjects, Triples).
done(json, Fmt-Args, _CPU, _Subjects, _Triples) :-
format(string(Message), Fmt, Args),
format('Content-type: application/json~n~n'),
json_write(current_output,
json([transaction=
json([status=
json([msg=Message])])])),
format('~n').
done(xml, Fmt-Args, _CPU, _Subjects, _Triples) :-
format(string(Message), Fmt, Args),
format('Content-type: text/xml~n~n'),
format('<transaction>~n'),
format(' <status>~n'),
format(' <msg>~w</msg>~n', [Message]),
format(' </status>~n'),
format('</transaction>~n').
done(Format, Fmt-Args, _CPU, _Subjects, _Triples) :-
format('Content-type: text/plain~n~n'),
format('resultFormat=~w not yet supported~n~n', Format),
format(Fmt, Args).
%! result_table(+CPU, +SubDiff, +TripleDiff)// is det.
%
% HTML component that summarises the result of an operation.
result_table(CPU, Subjects, Triples) -->
{ rdf_statistics(triples(TriplesNow)),
subjects(SubjectsNow)
},
html([ h4('Operation completed'),
table([ id('result'),
class(block)
],
[ tr([td(class(empty), ''), th('+/-'), th('now')]),
tr([th(class(p_name), 'CPU time'),
\nc('~3f', CPU), td('')]),
tr([th(class(p_name), \subj_label),
\nc('~D', Subjects), \nc('~D', SubjectsNow)]),
tr([th(class(p_name), 'Triples'),
\nc('~D', Triples), \nc('~D', TriplesNow)])
])
]).
%! authorized_api(+Action, +ResultFormat) is det.
%
% @error permission_error(http_location, access, Path)
authorized_api(Action, ResultFormat) :-
ResultFormat == html, % do not bind
!,
authorized(Action).
authorized_api(Action, _) :-
logged_on(User, anonymous),
check_permission(User, Action).
| 31.725325 | 90 | 0.559026 |
73e9b13720713373522be5a4723fc18641fd0871 | 4,691 | pm | Perl | PfamLib/Bio/SCOOP/Region.pm | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 6 | 2017-01-25T12:53:23.000Z | 2021-03-17T04:52:35.000Z | PfamLib/Bio/SCOOP/Region.pm | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 50 | 2015-11-06T10:31:46.000Z | 2021-12-03T16:17:28.000Z | PfamLib/Bio/SCOOP/Region.pm | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 2 | 2019-05-30T00:10:26.000Z | 2021-04-12T09:42:17.000Z | =head1 NAME
Region
=head1 DESCRIPTION
The Region object contains info dedicated to a protein region
=head1 AUTHOR
B<Alex Bateman> Email agb@sanger.ac.uk
#COPYRIGHT
#Copyright (c) 2007: Genome Research Ltd.
#Authors: Alex Bateman (agb at sanger.ac.uk)
# K.Cara Woodwark (cara at sanger.ac.uk)
#This 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 2 of the License, or (at your option) any later
#version.
#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. See the GNU General Public License for more
#details.
#You should have received a copy of the GNU General Public License along with
#this program. If not, see <http://www.gnu.org/licenses/>.
=cut
#
# Perl Module for Bio::SCOOP::Region
#
# Cared for by Alex Bateman <agb@sanger.ac.uk>
#
package Bio::SCOOP::Region;
use vars qw($AUTOLOAD @ISA @EXPORT_OK);
use Exporter;
use Carp;
use strict;
use warnings;
#
# Place functions/variables you want to *export*, ie be visible from the caller package into @EXPORT_OK
#
@EXPORT_OK = qw();
#
# @ISA has our inheritance.
#
@ISA = ( 'Exporter' );
#######
# new #
#######
=head2 new
Create new region object.
$region = new Region('id'=>$id,
'start'=>$$res[2],
'end'=>$$res[3],
'family'=>$$res[0],
'evalue'=>$$res[4],
'significant'=>$$res[5]);
=cut
sub new {
my ($class,%hash)=@_;
my $region = {
};
bless $region, $class;
$region->{'id'}=$hash{'id'};
$region->{'start'}=$hash{'start'};
$region->{'end'}=$hash{'end'};
$region->{'family'}=$hash{'family'};
$region->{'evalue'}=$hash{'evalue'};
$region->{'significant'}=$hash{'significant'};
$region->{'match'}={};
return $region;
}
#########
# write #
#########
=head2 write
Debugging method: prints region object data to STDERR
$region->write();
=cut
sub write {
my ($self)=@_;
print STDERR "Region: id:",$self->{'id'}," start:",$self->start()," end:",$self->end()," family:",$self->family()," score:",$self->{'evalue'},"\n";
}
###########
# overlap #
###########
=head2 overlap
Method to check if two regions overlap
$region1->overlap($region2);
Returns true if there is an overlap
=cut
sub overlap {
my ($region1,$region2)=@_;
my $start1=$region1->{'start'};
my $start2=$region2->{'start'};
my $end1 =$region1->{'end'};
my $end2 =$region2->{'end'};
# shortcircuits test
if ($end1<$start2 or $end2<$start1){
return 0;
}
# This method requires the midpoint of one region to lie within the other
my $mid1=($start1+$end1)/2;
my $mid2=($start2+$end2)/2;
if ($mid1>$start2 and $mid1<$end2){
return 1;
} elsif ($mid2>$start1 and $mid2<$end1){
return 1;
}
return 0;
}
#########
# id #
#########
sub id {
my $self = shift @_;
return $self->{'id'};
}
#########
# start #
#########
sub start {
my $self = shift @_;
return $self->{'start'};
}
#######
# end #
#######
sub end {
my $self = shift @_;
return $self->{'end'};
}
##########
# family #
##########
sub family {
my $self = shift @_;
return $self->{'family'};
}
###############
# significant #
###############
sub significant {
my $self = shift @_;
return $self->{'significant'};
}
#########
# match #
#########
# Test whether this region has matched to another output already
# This is used to stop multiple counting for repeated regions.
sub match {
my ($self,$match) = @_;
if ($self->{'match'}->{$match}){
return 1;
} else {
return 0;
}
}
#############
# add_match #
#############
# Add an element to the match hash
sub add_match {
my ($self,$match) = @_;
$self->{'match'}->{$match}=1;
}
#########
# score #
#########
# Test whether this score has matched to another output already This
# is used to stop multiple counting for redundant regions because they
# will have the same score. However, some matches will be lost
# because although they are different they still get the same score.
sub score {
my ($self,$score) = @_;
if ($self->{'score'}->{$score}){
return 1;
} else {
return 0;
}
}
#############
# add_score #
#############
# Add an element to the score hash
sub add_score {
my ($self,$score) = @_;
$self->{'score'}->{$score}=1;
}
##########
# evalue #
##########
sub evalue {
my $self = shift @_;
return $self->{'evalue'};
}
1; # says use was ok
__END__
| 16.402098 | 151 | 0.578981 |
ed2915be8870efa7dc5b2209551be60ac121280a | 7,857 | pm | Perl | lib/Search/Elasticsearch/Plugin/XPack/2_0/Role/API.pm | garykrige/elasticsearch-perl | 11932ea7a72361e77e9ee921114283a3a3e13e63 | [
"Apache-2.0"
]
| null | null | null | lib/Search/Elasticsearch/Plugin/XPack/2_0/Role/API.pm | garykrige/elasticsearch-perl | 11932ea7a72361e77e9ee921114283a3a3e13e63 | [
"Apache-2.0"
]
| null | null | null | lib/Search/Elasticsearch/Plugin/XPack/2_0/Role/API.pm | garykrige/elasticsearch-perl | 11932ea7a72361e77e9ee921114283a3a3e13e63 | [
"Apache-2.0"
]
| null | null | null | package Search::Elasticsearch::Plugin::XPack::2_0::Role::API;
use Moo::Role;
with 'Search::Elasticsearch::Role::API';
use Search::Elasticsearch::Util qw(throw);
use namespace::clean;
has 'api_version' => ( is => 'ro', default => '2_0' );
our %API;
#===================================
sub api {
#===================================
my $name = $_[1] || return \%API;
return $API{$name}
|| throw( 'Internal', "Unknown api name ($name)" );
}
#===================================
%API = (
#===================================
#=== AUTOGEN - START ===
'graph.explore' => {
body => {},
doc => "explore",
parts => { index => { multi => 1 }, type => { multi => 1 } },
paths => [
[ { index => 0, type => 1 }, "{index}",
"{type}", "_graph",
"explore",
],
[ { index => 0 }, "{index}", "_graph", "explore" ],
],
qs =>
{ filter_path => "list", routing => "string", timeout => "time" },
},
'license.get' => {
doc => "license-management",
parts => {},
paths => [ [ {}, "_license" ] ],
qs => { filter_path => "list", local => "boolean" },
},
'license.post' => {
body => {},
doc => "license-management",
method => "PUT",
parts => {},
paths => [ [ {}, "_license" ] ],
qs => { acknowledge => "boolean", filter_path => "list" },
},
'shield.authenticate' => {
doc => "",
parts => {},
paths => [ [ {}, "_shield", "authenticate" ] ],
qs => { filter_path => "list" },
},
'shield.clear_cached_realms' => {
doc => "",
method => "POST",
parts => { realms => { required => 1 } },
paths => [
[ { realms => 2 }, "_shield", "realm", "{realms}",
"_clear_cache"
],
],
qs => { filter_path => "list", usernames => "string" },
},
'shield.clear_cached_roles' => {
doc => "",
method => "PUT",
parts => { name => { required => 1 } },
paths => [
[ { name => 2 }, "_shield", "role", "{name}", "_clear_cache" ]
],
qs => { filter_path => "list" },
},
'shield.delete_role' => {
doc => "",
method => "DELETE",
parts => { name => { required => 1 } },
paths => [ [ { name => 2 }, "_shield", "role", "{name}" ] ],
qs => { filter_path => "list" },
},
'shield.delete_user' => {
doc => "",
method => "DELETE",
parts => { username => { required => 1 } },
paths => [ [ { username => 2 }, "_shield", "user", "{username}" ] ],
qs => { filter_path => "list" },
},
'shield.get_role' => {
doc => "",
parts => { name => {} },
paths => [
[ { name => 2 }, "_shield", "role", "{name}" ],
[ {}, "_shield", "role" ],
],
qs => { filter_path => "list" },
},
'shield.get_user' => {
doc => "",
parts => { username => { multi => 1 } },
paths => [
[ { username => 2 }, "_shield", "user", "{username}" ],
[ {}, "_shield", "user" ],
],
qs => { filter_path => "list" },
},
'shield.put_role' => {
body => { required => 1 },
doc => "",
method => "PUT",
parts => { name => { required => 1 } },
paths => [ [ { name => 2 }, "_shield", "role", "{name}" ] ],
qs => { filter_path => "list" },
},
'shield.put_user' => {
body => { required => 1 },
doc => "",
method => "PUT",
parts => { username => { required => 1 } },
paths => [ [ { username => 2 }, "_shield", "user", "{username}" ] ],
qs => { filter_path => "list" },
},
'watcher.ack_watch' => {
doc => "appendix-api-ack-watch",
method => "PUT",
parts =>
{ action_id => { multi => 1 }, watch_id => { required => 1 } },
paths => [
[ { action_id => 3, watch_id => 2 }, "_watcher",
"watch", "{watch_id}",
"{action_id}", "_ack",
],
[ { watch_id => 2 }, "_watcher", "watch", "{watch_id}", "_ack" ],
],
qs => { filter_path => "list", master_timeout => "time" },
},
'watcher.activate_watch' => {
doc => "",
method => "PUT",
parts => { watch_id => { required => 1 } },
paths => [
[ { watch_id => 2 }, "_watcher",
"watch", "{watch_id}",
"_activate",
],
],
qs => { filter_path => "list", master_timeout => "time" },
},
'watcher.deactivate_watch' => {
doc => "",
method => "PUT",
parts => { watch_id => { required => 1 } },
paths => [
[ { watch_id => 2 }, "_watcher",
"watch", "{watch_id}",
"_deactivate",
],
],
qs => { filter_path => "list", master_timeout => "time" },
},
'watcher.delete_watch' => {
doc => "appendix-api-delete-watch",
method => "DELETE",
parts => { id => { required => 1 } },
paths => [ [ { id => 2 }, "_watcher", "watch", "{id}" ] ],
qs => {
filter_path => "list",
force => "boolean",
master_timeout => "time"
},
},
'watcher.execute_watch' => {
body => {},
doc => "appendix-api-execute-watch",
method => "PUT",
parts => { id => {} },
paths => [
[ { id => 2 }, "_watcher", "watch", "{id}", "_execute" ],
[ {}, "_watcher", "watch", "_execute" ],
],
qs => { debug => "boolean", filter_path => "list" },
},
'watcher.get_watch' => {
doc => "appendix-api-get-watch",
parts => { id => { required => 1 } },
paths => [ [ { id => 2 }, "_watcher", "watch", "{id}" ] ],
qs => { filter_path => "list" },
},
'watcher.info' => {
doc => "appendix-api-info",
parts => {},
paths => [ [ {}, "_watcher" ] ],
qs => { filter_path => "list" },
},
'watcher.put_watch' => {
body => { required => 1 },
doc => "appendix-api-put-watch",
method => "PUT",
parts => { id => { required => 1 } },
paths => [ [ { id => 2 }, "_watcher", "watch", "{id}" ] ],
qs => {
active => "boolean",
filter_path => "list",
master_timeout => "time"
},
},
'watcher.restart' => {
doc => "appendix-api-service",
method => "PUT",
parts => {},
paths => [ [ {}, "_watcher", "_restart" ] ],
qs => { filter_path => "list" },
},
'watcher.start' => {
doc => "appendix-api-service",
method => "PUT",
parts => {},
paths => [ [ {}, "_watcher", "_start" ] ],
qs => { filter_path => "list" },
},
'watcher.stats' => {
doc => "appendix-api-stats",
parts => { metric => {} },
paths => [
[ { metric => 2 }, "_watcher", "stats", "{metric}" ],
[ {}, "_watcher", "stats" ],
],
qs => { filter_path => "list" },
},
'watcher.stop' => {
doc => "appendix-api-service",
method => "PUT",
parts => {},
paths => [ [ {}, "_watcher", "_stop" ] ],
qs => { filter_path => "list" },
},
#=== AUTOGEN - END ===
);
__PACKAGE__->_qs_init( \%API );
1;
__END__
# ABSTRACT: This class contains the spec for the Elasticsearch XPack APIs for 2.x
| 28.467391 | 81 | 0.382716 |
73e2f124a774d26efe4325eb1858746668b22ceb | 1,044 | pm | Perl | lib/Google/Ads/GoogleAds/V6/Errors/PolicyFindingDetails.pm | PierrickVoulet/google-ads-perl | bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4 | [
"Apache-2.0"
]
| null | null | null | lib/Google/Ads/GoogleAds/V6/Errors/PolicyFindingDetails.pm | PierrickVoulet/google-ads-perl | bc9fa2de22aa3e11b99dc22251d90a1723dd8cc4 | [
"Apache-2.0"
]
| null | null | null | lib/Google/Ads/GoogleAds/V6/Errors/PolicyFindingDetails.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::Errors::PolicyFindingDetails;
use strict;
use warnings;
use base qw(Google::Ads::GoogleAds::BaseEntity);
use Google::Ads::GoogleAds::Utils::GoogleAdsHelper;
sub new {
my ($class, $args) = @_;
my $self = {policyTopicEntries => $args->{policyTopicEntries}};
# Delete the unassigned fields in this object for a more concise JSON payload
remove_unassigned_fields($self, $args);
bless $self, $class;
return $self;
}
1;
| 29.828571 | 79 | 0.740421 |
ed23a6da4ca5386de4a4c486060bcbb33658dba2 | 20,430 | pm | Perl | perl/vendor/lib/DateTime/TimeZone/America/Mexico_City.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/DateTime/TimeZone/America/Mexico_City.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/DateTime/TimeZone/America/Mexico_City.pm | mnikolop/Thesis_project_CyberDoc | 9a37fdd5a31de24cb902ee31ef19eb992faa1665 | [
"Apache-2.0"
]
| 1 | 2019-11-12T02:29:26.000Z | 2019-11-12T02:29:26.000Z | # This file is auto-generated by the Perl DateTime Suite time zone
# code generator (0.07) This code generator comes with the
# DateTime::TimeZone module distribution in the tools/ directory
#
# Generated from /tmp/rnClxBLdxJ/northamerica. Olson data version 2013a
#
# Do not edit this file directly.
#
package DateTime::TimeZone::America::Mexico_City;
{
$DateTime::TimeZone::America::Mexico_City::VERSION = '1.57';
}
use strict;
use Class::Singleton 1.03;
use DateTime::TimeZone;
use DateTime::TimeZone::OlsonDB;
@DateTime::TimeZone::America::Mexico_City::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' );
my $spans =
[
[
DateTime::TimeZone::NEG_INFINITY, # utc_start
60620943600, # utc_end 1922-01-01 07:00:00 (Sun)
DateTime::TimeZone::NEG_INFINITY, # local_start
60620919804, # local_end 1922-01-01 00:23:24 (Sun)
-23796,
0,
'LMT',
],
[
60620943600, # utc_start 1922-01-01 07:00:00 (Sun)
60792616800, # utc_end 1927-06-11 06:00:00 (Sat)
60620918400, # local_start 1922-01-01 00:00:00 (Sun)
60792591600, # local_end 1927-06-10 23:00:00 (Fri)
-25200,
0,
'MST',
],
[
60792616800, # utc_start 1927-06-11 06:00:00 (Sat)
60900876000, # utc_end 1930-11-15 06:00:00 (Sat)
60792595200, # local_start 1927-06-11 00:00:00 (Sat)
60900854400, # local_end 1930-11-15 00:00:00 (Sat)
-21600,
0,
'CST',
],
[
60900876000, # utc_start 1930-11-15 06:00:00 (Sat)
60915391200, # utc_end 1931-05-02 06:00:00 (Sat)
60900850800, # local_start 1930-11-14 23:00:00 (Fri)
60915366000, # local_end 1931-05-01 23:00:00 (Fri)
-25200,
0,
'MST',
],
[
60915391200, # utc_start 1931-05-02 06:00:00 (Sat)
60928524000, # utc_end 1931-10-01 06:00:00 (Thu)
60915369600, # local_start 1931-05-02 00:00:00 (Sat)
60928502400, # local_end 1931-10-01 00:00:00 (Thu)
-21600,
0,
'CST',
],
[
60928524000, # utc_start 1931-10-01 06:00:00 (Thu)
60944338800, # utc_end 1932-04-01 07:00:00 (Fri)
60928498800, # local_start 1931-09-30 23:00:00 (Wed)
60944313600, # local_end 1932-04-01 00:00:00 (Fri)
-25200,
0,
'MST',
],
[
60944338800, # utc_start 1932-04-01 07:00:00 (Fri)
61160421600, # utc_end 1939-02-05 06:00:00 (Sun)
60944317200, # local_start 1932-04-01 01:00:00 (Fri)
61160400000, # local_end 1939-02-05 00:00:00 (Sun)
-21600,
0,
'CST',
],
[
61160421600, # utc_start 1939-02-05 06:00:00 (Sun)
61172514000, # utc_end 1939-06-25 05:00:00 (Sun)
61160403600, # local_start 1939-02-05 01:00:00 (Sun)
61172496000, # local_end 1939-06-25 00:00:00 (Sun)
-18000,
1,
'CDT',
],
[
61172514000, # utc_start 1939-06-25 05:00:00 (Sun)
61218568800, # utc_end 1940-12-09 06:00:00 (Mon)
61172492400, # local_start 1939-06-24 23:00:00 (Sat)
61218547200, # local_end 1940-12-09 00:00:00 (Mon)
-21600,
0,
'CST',
],
[
61218568800, # utc_start 1940-12-09 06:00:00 (Mon)
61228328400, # utc_end 1941-04-01 05:00:00 (Tue)
61218550800, # local_start 1940-12-09 01:00:00 (Mon)
61228310400, # local_end 1941-04-01 00:00:00 (Tue)
-18000,
1,
'CDT',
],
[
61228328400, # utc_start 1941-04-01 05:00:00 (Tue)
61313781600, # utc_end 1943-12-16 06:00:00 (Thu)
61228306800, # local_start 1941-03-31 23:00:00 (Mon)
61313760000, # local_end 1943-12-16 00:00:00 (Thu)
-21600,
0,
'CST',
],
[
61313781600, # utc_start 1943-12-16 06:00:00 (Thu)
61325614800, # utc_end 1944-05-01 05:00:00 (Mon)
61313763600, # local_start 1943-12-16 01:00:00 (Thu)
61325596800, # local_end 1944-05-01 00:00:00 (Mon)
-18000,
1,
'CWT',
],
[
61325614800, # utc_start 1944-05-01 05:00:00 (Mon)
61508181600, # utc_end 1950-02-12 06:00:00 (Sun)
61325593200, # local_start 1944-04-30 23:00:00 (Sun)
61508160000, # local_end 1950-02-12 00:00:00 (Sun)
-21600,
0,
'CST',
],
[
61508181600, # utc_start 1950-02-12 06:00:00 (Sun)
61522693200, # utc_end 1950-07-30 05:00:00 (Sun)
61508163600, # local_start 1950-02-12 01:00:00 (Sun)
61522675200, # local_end 1950-07-30 00:00:00 (Sun)
-18000,
1,
'CDT',
],
[
61522693200, # utc_start 1950-07-30 05:00:00 (Sun)
62964547200, # utc_end 1996-04-07 08:00:00 (Sun)
61522671600, # local_start 1950-07-29 23:00:00 (Sat)
62964525600, # local_end 1996-04-07 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
62964547200, # utc_start 1996-04-07 08:00:00 (Sun)
62982082800, # utc_end 1996-10-27 07:00:00 (Sun)
62964529200, # local_start 1996-04-07 03:00:00 (Sun)
62982064800, # local_end 1996-10-27 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
62982082800, # utc_start 1996-10-27 07:00:00 (Sun)
62995996800, # utc_end 1997-04-06 08:00:00 (Sun)
62982061200, # local_start 1996-10-27 01:00:00 (Sun)
62995975200, # local_end 1997-04-06 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
62995996800, # utc_start 1997-04-06 08:00:00 (Sun)
63013532400, # utc_end 1997-10-26 07:00:00 (Sun)
62995978800, # local_start 1997-04-06 03:00:00 (Sun)
63013514400, # local_end 1997-10-26 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63013532400, # utc_start 1997-10-26 07:00:00 (Sun)
63027446400, # utc_end 1998-04-05 08:00:00 (Sun)
63013510800, # local_start 1997-10-26 01:00:00 (Sun)
63027424800, # local_end 1998-04-05 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63027446400, # utc_start 1998-04-05 08:00:00 (Sun)
63044982000, # utc_end 1998-10-25 07:00:00 (Sun)
63027428400, # local_start 1998-04-05 03:00:00 (Sun)
63044964000, # local_end 1998-10-25 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63044982000, # utc_start 1998-10-25 07:00:00 (Sun)
63058896000, # utc_end 1999-04-04 08:00:00 (Sun)
63044960400, # local_start 1998-10-25 01:00:00 (Sun)
63058874400, # local_end 1999-04-04 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63058896000, # utc_start 1999-04-04 08:00:00 (Sun)
63077036400, # utc_end 1999-10-31 07:00:00 (Sun)
63058878000, # local_start 1999-04-04 03:00:00 (Sun)
63077018400, # local_end 1999-10-31 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63077036400, # utc_start 1999-10-31 07:00:00 (Sun)
63090345600, # utc_end 2000-04-02 08:00:00 (Sun)
63077014800, # local_start 1999-10-31 01:00:00 (Sun)
63090324000, # local_end 2000-04-02 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63090345600, # utc_start 2000-04-02 08:00:00 (Sun)
63108486000, # utc_end 2000-10-29 07:00:00 (Sun)
63090327600, # local_start 2000-04-02 03:00:00 (Sun)
63108468000, # local_end 2000-10-29 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63108486000, # utc_start 2000-10-29 07:00:00 (Sun)
63124819200, # utc_end 2001-05-06 08:00:00 (Sun)
63108464400, # local_start 2000-10-29 01:00:00 (Sun)
63124797600, # local_end 2001-05-06 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63124819200, # utc_start 2001-05-06 08:00:00 (Sun)
63137516400, # utc_end 2001-09-30 07:00:00 (Sun)
63124801200, # local_start 2001-05-06 03:00:00 (Sun)
63137498400, # local_end 2001-09-30 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63137516400, # utc_start 2001-09-30 07:00:00 (Sun)
63149868000, # utc_end 2002-02-20 06:00:00 (Wed)
63137494800, # local_start 2001-09-30 01:00:00 (Sun)
63149846400, # local_end 2002-02-20 00:00:00 (Wed)
-21600,
0,
'CST',
],
[
63149868000, # utc_start 2002-02-20 06:00:00 (Wed)
63153849600, # utc_end 2002-04-07 08:00:00 (Sun)
63149846400, # local_start 2002-02-20 00:00:00 (Wed)
63153828000, # local_end 2002-04-07 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63153849600, # utc_start 2002-04-07 08:00:00 (Sun)
63171385200, # utc_end 2002-10-27 07:00:00 (Sun)
63153831600, # local_start 2002-04-07 03:00:00 (Sun)
63171367200, # local_end 2002-10-27 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63171385200, # utc_start 2002-10-27 07:00:00 (Sun)
63185299200, # utc_end 2003-04-06 08:00:00 (Sun)
63171363600, # local_start 2002-10-27 01:00:00 (Sun)
63185277600, # local_end 2003-04-06 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63185299200, # utc_start 2003-04-06 08:00:00 (Sun)
63202834800, # utc_end 2003-10-26 07:00:00 (Sun)
63185281200, # local_start 2003-04-06 03:00:00 (Sun)
63202816800, # local_end 2003-10-26 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63202834800, # utc_start 2003-10-26 07:00:00 (Sun)
63216748800, # utc_end 2004-04-04 08:00:00 (Sun)
63202813200, # local_start 2003-10-26 01:00:00 (Sun)
63216727200, # local_end 2004-04-04 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63216748800, # utc_start 2004-04-04 08:00:00 (Sun)
63234889200, # utc_end 2004-10-31 07:00:00 (Sun)
63216730800, # local_start 2004-04-04 03:00:00 (Sun)
63234871200, # local_end 2004-10-31 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63234889200, # utc_start 2004-10-31 07:00:00 (Sun)
63248198400, # utc_end 2005-04-03 08:00:00 (Sun)
63234867600, # local_start 2004-10-31 01:00:00 (Sun)
63248176800, # local_end 2005-04-03 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63248198400, # utc_start 2005-04-03 08:00:00 (Sun)
63266338800, # utc_end 2005-10-30 07:00:00 (Sun)
63248180400, # local_start 2005-04-03 03:00:00 (Sun)
63266320800, # local_end 2005-10-30 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63266338800, # utc_start 2005-10-30 07:00:00 (Sun)
63279648000, # utc_end 2006-04-02 08:00:00 (Sun)
63266317200, # local_start 2005-10-30 01:00:00 (Sun)
63279626400, # local_end 2006-04-02 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63279648000, # utc_start 2006-04-02 08:00:00 (Sun)
63297788400, # utc_end 2006-10-29 07:00:00 (Sun)
63279630000, # local_start 2006-04-02 03:00:00 (Sun)
63297770400, # local_end 2006-10-29 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63297788400, # utc_start 2006-10-29 07:00:00 (Sun)
63311097600, # utc_end 2007-04-01 08:00:00 (Sun)
63297766800, # local_start 2006-10-29 01:00:00 (Sun)
63311076000, # local_end 2007-04-01 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63311097600, # utc_start 2007-04-01 08:00:00 (Sun)
63329238000, # utc_end 2007-10-28 07:00:00 (Sun)
63311079600, # local_start 2007-04-01 03:00:00 (Sun)
63329220000, # local_end 2007-10-28 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63329238000, # utc_start 2007-10-28 07:00:00 (Sun)
63343152000, # utc_end 2008-04-06 08:00:00 (Sun)
63329216400, # local_start 2007-10-28 01:00:00 (Sun)
63343130400, # local_end 2008-04-06 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63343152000, # utc_start 2008-04-06 08:00:00 (Sun)
63360687600, # utc_end 2008-10-26 07:00:00 (Sun)
63343134000, # local_start 2008-04-06 03:00:00 (Sun)
63360669600, # local_end 2008-10-26 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63360687600, # utc_start 2008-10-26 07:00:00 (Sun)
63374601600, # utc_end 2009-04-05 08:00:00 (Sun)
63360666000, # local_start 2008-10-26 01:00:00 (Sun)
63374580000, # local_end 2009-04-05 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63374601600, # utc_start 2009-04-05 08:00:00 (Sun)
63392137200, # utc_end 2009-10-25 07:00:00 (Sun)
63374583600, # local_start 2009-04-05 03:00:00 (Sun)
63392119200, # local_end 2009-10-25 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63392137200, # utc_start 2009-10-25 07:00:00 (Sun)
63406051200, # utc_end 2010-04-04 08:00:00 (Sun)
63392115600, # local_start 2009-10-25 01:00:00 (Sun)
63406029600, # local_end 2010-04-04 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63406051200, # utc_start 2010-04-04 08:00:00 (Sun)
63424191600, # utc_end 2010-10-31 07:00:00 (Sun)
63406033200, # local_start 2010-04-04 03:00:00 (Sun)
63424173600, # local_end 2010-10-31 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63424191600, # utc_start 2010-10-31 07:00:00 (Sun)
63437500800, # utc_end 2011-04-03 08:00:00 (Sun)
63424170000, # local_start 2010-10-31 01:00:00 (Sun)
63437479200, # local_end 2011-04-03 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63437500800, # utc_start 2011-04-03 08:00:00 (Sun)
63455641200, # utc_end 2011-10-30 07:00:00 (Sun)
63437482800, # local_start 2011-04-03 03:00:00 (Sun)
63455623200, # local_end 2011-10-30 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63455641200, # utc_start 2011-10-30 07:00:00 (Sun)
63468950400, # utc_end 2012-04-01 08:00:00 (Sun)
63455619600, # local_start 2011-10-30 01:00:00 (Sun)
63468928800, # local_end 2012-04-01 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63468950400, # utc_start 2012-04-01 08:00:00 (Sun)
63487090800, # utc_end 2012-10-28 07:00:00 (Sun)
63468932400, # local_start 2012-04-01 03:00:00 (Sun)
63487072800, # local_end 2012-10-28 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63487090800, # utc_start 2012-10-28 07:00:00 (Sun)
63501004800, # utc_end 2013-04-07 08:00:00 (Sun)
63487069200, # local_start 2012-10-28 01:00:00 (Sun)
63500983200, # local_end 2013-04-07 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63501004800, # utc_start 2013-04-07 08:00:00 (Sun)
63518540400, # utc_end 2013-10-27 07:00:00 (Sun)
63500986800, # local_start 2013-04-07 03:00:00 (Sun)
63518522400, # local_end 2013-10-27 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63518540400, # utc_start 2013-10-27 07:00:00 (Sun)
63532454400, # utc_end 2014-04-06 08:00:00 (Sun)
63518518800, # local_start 2013-10-27 01:00:00 (Sun)
63532432800, # local_end 2014-04-06 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63532454400, # utc_start 2014-04-06 08:00:00 (Sun)
63549990000, # utc_end 2014-10-26 07:00:00 (Sun)
63532436400, # local_start 2014-04-06 03:00:00 (Sun)
63549972000, # local_end 2014-10-26 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63549990000, # utc_start 2014-10-26 07:00:00 (Sun)
63563904000, # utc_end 2015-04-05 08:00:00 (Sun)
63549968400, # local_start 2014-10-26 01:00:00 (Sun)
63563882400, # local_end 2015-04-05 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63563904000, # utc_start 2015-04-05 08:00:00 (Sun)
63581439600, # utc_end 2015-10-25 07:00:00 (Sun)
63563886000, # local_start 2015-04-05 03:00:00 (Sun)
63581421600, # local_end 2015-10-25 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63581439600, # utc_start 2015-10-25 07:00:00 (Sun)
63595353600, # utc_end 2016-04-03 08:00:00 (Sun)
63581418000, # local_start 2015-10-25 01:00:00 (Sun)
63595332000, # local_end 2016-04-03 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63595353600, # utc_start 2016-04-03 08:00:00 (Sun)
63613494000, # utc_end 2016-10-30 07:00:00 (Sun)
63595335600, # local_start 2016-04-03 03:00:00 (Sun)
63613476000, # local_end 2016-10-30 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63613494000, # utc_start 2016-10-30 07:00:00 (Sun)
63626803200, # utc_end 2017-04-02 08:00:00 (Sun)
63613472400, # local_start 2016-10-30 01:00:00 (Sun)
63626781600, # local_end 2017-04-02 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63626803200, # utc_start 2017-04-02 08:00:00 (Sun)
63644943600, # utc_end 2017-10-29 07:00:00 (Sun)
63626785200, # local_start 2017-04-02 03:00:00 (Sun)
63644925600, # local_end 2017-10-29 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63644943600, # utc_start 2017-10-29 07:00:00 (Sun)
63658252800, # utc_end 2018-04-01 08:00:00 (Sun)
63644922000, # local_start 2017-10-29 01:00:00 (Sun)
63658231200, # local_end 2018-04-01 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63658252800, # utc_start 2018-04-01 08:00:00 (Sun)
63676393200, # utc_end 2018-10-28 07:00:00 (Sun)
63658234800, # local_start 2018-04-01 03:00:00 (Sun)
63676375200, # local_end 2018-10-28 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63676393200, # utc_start 2018-10-28 07:00:00 (Sun)
63690307200, # utc_end 2019-04-07 08:00:00 (Sun)
63676371600, # local_start 2018-10-28 01:00:00 (Sun)
63690285600, # local_end 2019-04-07 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63690307200, # utc_start 2019-04-07 08:00:00 (Sun)
63707842800, # utc_end 2019-10-27 07:00:00 (Sun)
63690289200, # local_start 2019-04-07 03:00:00 (Sun)
63707824800, # local_end 2019-10-27 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63707842800, # utc_start 2019-10-27 07:00:00 (Sun)
63721756800, # utc_end 2020-04-05 08:00:00 (Sun)
63707821200, # local_start 2019-10-27 01:00:00 (Sun)
63721735200, # local_end 2020-04-05 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63721756800, # utc_start 2020-04-05 08:00:00 (Sun)
63739292400, # utc_end 2020-10-25 07:00:00 (Sun)
63721738800, # local_start 2020-04-05 03:00:00 (Sun)
63739274400, # local_end 2020-10-25 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63739292400, # utc_start 2020-10-25 07:00:00 (Sun)
63753206400, # utc_end 2021-04-04 08:00:00 (Sun)
63739270800, # local_start 2020-10-25 01:00:00 (Sun)
63753184800, # local_end 2021-04-04 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63753206400, # utc_start 2021-04-04 08:00:00 (Sun)
63771346800, # utc_end 2021-10-31 07:00:00 (Sun)
63753188400, # local_start 2021-04-04 03:00:00 (Sun)
63771328800, # local_end 2021-10-31 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63771346800, # utc_start 2021-10-31 07:00:00 (Sun)
63784656000, # utc_end 2022-04-03 08:00:00 (Sun)
63771325200, # local_start 2021-10-31 01:00:00 (Sun)
63784634400, # local_end 2022-04-03 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63784656000, # utc_start 2022-04-03 08:00:00 (Sun)
63802796400, # utc_end 2022-10-30 07:00:00 (Sun)
63784638000, # local_start 2022-04-03 03:00:00 (Sun)
63802778400, # local_end 2022-10-30 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63802796400, # utc_start 2022-10-30 07:00:00 (Sun)
63816105600, # utc_end 2023-04-02 08:00:00 (Sun)
63802774800, # local_start 2022-10-30 01:00:00 (Sun)
63816084000, # local_end 2023-04-02 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63816105600, # utc_start 2023-04-02 08:00:00 (Sun)
63834246000, # utc_end 2023-10-29 07:00:00 (Sun)
63816087600, # local_start 2023-04-02 03:00:00 (Sun)
63834228000, # local_end 2023-10-29 02:00:00 (Sun)
-18000,
1,
'CDT',
],
[
63834246000, # utc_start 2023-10-29 07:00:00 (Sun)
63848160000, # utc_end 2024-04-07 08:00:00 (Sun)
63834224400, # local_start 2023-10-29 01:00:00 (Sun)
63848138400, # local_end 2024-04-07 02:00:00 (Sun)
-21600,
0,
'CST',
],
[
63848160000, # utc_start 2024-04-07 08:00:00 (Sun)
63865695600, # utc_end 2024-10-27 07:00:00 (Sun)
63848142000, # local_start 2024-04-07 03:00:00 (Sun)
63865677600, # local_end 2024-10-27 02:00:00 (Sun)
-18000,
1,
'CDT',
],
];
sub olson_version { '2013a' }
sub has_dst_changes { 33 }
sub _max_year { 2023 }
sub _new_instance
{
return shift->_init( @_, spans => $spans );
}
sub _last_offset { -21600 }
my $last_observance = bless( {
'format' => 'C%sT',
'gmtoff' => '-6:00',
'local_start_datetime' => bless( {
'formatter' => undef,
'local_rd_days' => 730901,
'local_rd_secs' => 0,
'offset_modifier' => 0,
'rd_nanosecs' => 0,
'tz' => bless( {
'name' => 'floating',
'offset' => 0
}, 'DateTime::TimeZone::Floating' ),
'utc_rd_days' => 730901,
'utc_rd_secs' => 0,
'utc_year' => 2003
}, 'DateTime' ),
'offset_from_std' => 0,
'offset_from_utc' => -21600,
'until' => [],
'utc_start_datetime' => bless( {
'formatter' => undef,
'local_rd_days' => 730901,
'local_rd_secs' => 21600,
'offset_modifier' => 0,
'rd_nanosecs' => 0,
'tz' => bless( {
'name' => 'floating',
'offset' => 0
}, 'DateTime::TimeZone::Floating' ),
'utc_rd_days' => 730901,
'utc_rd_secs' => 21600,
'utc_year' => 2003
}, 'DateTime' )
}, 'DateTime::TimeZone::OlsonDB::Observance' )
;
sub _last_observance { $last_observance }
my $rules = [
bless( {
'at' => '2:00',
'from' => '2002',
'in' => 'Apr',
'letter' => 'D',
'name' => 'Mexico',
'offset_from_std' => 3600,
'on' => 'Sun>=1',
'save' => '1:00',
'to' => 'max',
'type' => undef
}, 'DateTime::TimeZone::OlsonDB::Rule' ),
bless( {
'at' => '2:00',
'from' => '2002',
'in' => 'Oct',
'letter' => 'S',
'name' => 'Mexico',
'offset_from_std' => 0,
'on' => 'lastSun',
'save' => '0',
'to' => 'max',
'type' => undef
}, 'DateTime::TimeZone::OlsonDB::Rule' )
]
;
sub _rules { $rules }
1;
| 26.636245 | 94 | 0.62883 |
ed4b9a53fa6daf1fcb8c9769efa507ec739cad95 | 4,730 | pm | Perl | lib/Web/AssetLib/Util.pm | ryan-lang/Web-AssetLib | e7b9c9597e45f4522f799544e6fa4a020227ffb6 | [
"MIT"
]
| null | null | null | lib/Web/AssetLib/Util.pm | ryan-lang/Web-AssetLib | e7b9c9597e45f4522f799544e6fa4a020227ffb6 | [
"MIT"
]
| null | null | null | lib/Web/AssetLib/Util.pm | ryan-lang/Web-AssetLib | e7b9c9597e45f4522f799544e6fa4a020227ffb6 | [
"MIT"
]
| null | null | null | package Web::AssetLib::Util;
use Method::Signatures;
use Moose;
use Carp;
use HTML::Element;
use v5.14;
no if $] >= 5.018, warnings => "experimental";
use Exporter qw( import );
our %EXPORT_TAGS = ( 'all' => [ 'normalizeFileType', 'normalizeMimeType', 'getFileExtension' ], );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} }, );
my %FILE_TYPES = (
js => 'js',
javascript => 'js',
css => 'css',
stylesheet => 'css',
jpeg => 'jpg',
jpg => 'jpg',
woff => 'woff',
woff2 => 'woff',
svg => 'svg',
map => 'map'
);
my %MIME_TYPES = (
js => 'text/javascript',
javascript => 'text/javascript',
css => 'text/css',
stylesheet => 'text/css',
jpg => 'image/jpeg',
jpeg => 'image/jpeg',
woff => 'application/font-woff',
woff2 => 'application/font-woff',
svg => 'image/svg+xml',
map => 'application/json'
);
func normalizeFileType ($type!) {
if ( my $normalized = $FILE_TYPES{$type} ) {
return $normalized;
}
else {
croak "could not map type '$type'";
}
}
func normalizeMimeType ($type!) {
if ( my $normalized = $MIME_TYPES{$type} ) {
return $normalized;
}
else {
croak "could not map type '$type'";
}
}
func getFileExtension ($string!) {
$string =~ /\.([0-9a-z]+)$/g;
return $1;
}
func generateHtmlTag (:$output!, :$html_attrs = {}) {
my $mime = normalizeMimeType( $output->type );
my $el;
for ( ref($output) ) {
when (/Content/) {
for ($mime) {
when ('text/css') {
$el = HTML::Element->new(
'style',
type => $mime,
%$html_attrs
);
$el->push_content( $output->content );
}
when ('text/javascript') {
$el = HTML::Element->new(
'script',
type => $mime,
%$html_attrs
);
$el->push_content( $output->content );
}
when ('image/svg+xml') {
return $output->content;
}
default {
croak "$mime content output not supported";
}
}
}
when (/Link/) {
for ($mime) {
when ('text/css') {
$el = HTML::Element->new(
'link',
href => $output->src,
rel => 'stylesheet',
type => $mime,
%$html_attrs
);
}
when ('text/javascript') {
$el = HTML::Element->new(
'script',
src => $output->src,
type => $mime,
%$html_attrs
);
}
when ('image/jpeg') {
$el = HTML::Element->new(
'img',
src => $output->src,
%$html_attrs
);
}
when ('image/svg+xml') {
$el = HTML::Element->new(
'object',
type => $mime,
data => $output->src,
%$html_attrs
);
$el->push_content('Your browser does not support SVG');
}
default {
croak "$mime link output not supported";
}
}
}
}
return $el->as_HTML;
}
no Moose;
1;
=pod
=encoding UTF-8
=head1 NAME
Web::AssetLib::Util - core utilties for Web::AssetLib
=head1 FUNCTIONS
=head2 normalizeFileType
my $type = normalizeFileType( 'stylesheet' );
# $type = 'css'
Converts file type string to a normalized version of that string.
e.g. "javascript" maps to "js"
=head2 normalizeMimeType
my $mime = normalizeMimeType( 'stylesheet' );
# $mime = 'text/css'
Converts file type string to a mime type.
e.g. "javascript" maps to "text/javascript"
=head2 generateHtmlTag
my $output = ... # a Web::AssetLib::Output object
my $tag = generateHtmlTag(
output => $output,
html_attrs => { async => 'async' }
);
Generates an HTML tag for a L<Web::AssetLib::Output> object. Optionally,
C<html_attrs> can be provided.
=head1 AUTHOR
Ryan Lang <rlang@cpan.org>
=cut
| 25.430108 | 98 | 0.426004 |
73e6b17de9526414865ff7395d05a95d20949213 | 10,105 | pm | Perl | lib/App/Paws/Workspace/Conversations.pm | tomhrr/paws | f0e26942b08f5f8b6b8d3e342bff11e238a28e54 | [
"BSD-3-Clause"
]
| 2 | 2020-03-14T00:10:51.000Z | 2021-12-19T17:44:19.000Z | lib/App/Paws/Workspace/Conversations.pm | tomhrr/paws | f0e26942b08f5f8b6b8d3e342bff11e238a28e54 | [
"BSD-3-Clause"
]
| 13 | 2019-06-09T14:10:06.000Z | 2021-02-01T10:04:24.000Z | lib/App/Paws/Workspace/Conversations.pm | tomhrr/paws | f0e26942b08f5f8b6b8d3e342bff11e238a28e54 | [
"BSD-3-Clause"
]
| null | null | null | package App::Paws::Workspace::Conversations;
use warnings;
use strict;
use File::Slurp qw(read_file write_file);
use File::Spec::Functions qw(catfile);
use HTTP::Request;
use JSON::XS qw(decode_json encode_json);
use Time::HiRes qw(sleep);
use App::Paws::Utils qw(standard_get_request);
our $LIMIT = 100;
sub new
{
my $class = shift;
my %args = @_;
my $self = {
(map { $_ => $args{$_} }
qw(context workspace users)),
retrieving => 0,
retrieved => 0,
};
bless $self, $class;
$self->_init_conversations();
return $self;
}
sub _users
{
return $_[0]->{'users'};
}
sub _conversation_to_name
{
my ($self, $conversation) = @_;
my ($name, $type) = @{$conversation}{qw(name type)};
if (($type eq 'im') and not $name) {
my $user_id = $conversation->{'user'};
$name = $self->_users()->id_to_name($user_id);
if (not $name) {
warn "Unable to find name for user '$user_id'";
$name = 'unknown';
}
}
return "$type/$name";
}
sub _init_conversations
{
my ($self, $force_retrieve) = @_;
my $context = $self->{'context'};
my $runner = $context->runner();
my $ws = $self->{'workspace'};
my $db_dir = $context->db_directory();
my $path = catfile($db_dir, $ws->name().'-workspace-conversations-db');
if (not -e $path) {
write_file($path, '{}');
}
my $db = decode_json(read_file($path));
if ($db->{'conversations'}) {
$self->{'conversations'} = $db->{'conversations'};
}
if (not $force_retrieve) {
return 1;
}
if ($self->{'retrieving'} or $self->{'retrieved'}) {
return 1;
}
my $req = standard_get_request(
$context, $ws,
'/conversations.list',
{ types => 'public_channel,private_channel,mpim,im' }
);
$self->{'retrieving'} = 1;
my @conversations;
$runner->add('conversations.list', $req, sub {
my ($runner, $res, $fn) = @_;
if (not $res->is_success()) {
my $res_str = $res->as_string();
$res_str =~ s/(\r?\n)+$//g;
print STDERR "Unable to process response: $res_str\n";
return;
}
my $data = decode_json($res->content());
if ($data->{'error'}) {
my $res_str = $res->as_string();
$res_str =~ s/(\r?\n)+$//g;
print STDERR "Error in response: $res_str\n";
return;
}
for my $conversation (@{$data->{'channels'}}) {
my $type = ($conversation->{'is_im'} ? 'im'
: $conversation->{'is_mpim'} ? 'mpim'
: $conversation->{'is_group'} ? 'group'
: 'channel');
$conversation->{'type'} = $type;
$conversation->{'name'} =
$self->_conversation_to_name($conversation);
push @conversations,
{ map { $_ => $conversation->{$_} }
qw(id name is_member user type) };
}
if (my $cursor = $data->{'response_metadata'}->{'next_cursor'}) {
my $req = standard_get_request(
$context, $ws,
'/conversations.list',
{ cursor => $cursor,
types => 'public_channel,private_channel,mpim,im' }
);
$runner->add('conversations.list', $req, $fn);
} else {
$self->{'conversations'} = \@conversations;
$db->{'conversations'} = $self->{'conversations'};
write_file($path, encode_json($db));
$self->{'retrieving'} = 0;
$self->{'retrieved'} = 1;
delete $self->{'conversation_map'};
}
});
}
sub get_list
{
my ($self) = @_;
return $self->{'conversations'};
}
sub retrieve_nb
{
my ($self) = @_;
if ($self->{'retrieving'} or $self->{'retrieved'}) {
return 1;
}
my $context = $self->{'context'};
my $runner = $context->runner();
$self->_init_conversations(1);
return 1;
}
sub retrieve
{
my ($self) = @_;
if ($self->{'retrieved'}) {
return 1;
}
$self->retrieve_nb();
my $context = $self->{'context'};
my $runner = $context->runner();
while (not $runner->poke('conversations.list')) {
sleep(0.01);
}
return 1;
}
sub _get_conversation_map
{
my ($self) = @_;
if ($self->{'conversation_map'}) {
return $self->{'conversation_map'};
}
my %conversation_map =
map { $_->{'name'} => $_->{'id'} }
@{$self->{'conversations'}};
$self->{'conversation_map'} = \%conversation_map;
return \%conversation_map;
}
sub name_to_id
{
my ($self, $name) = @_;
my $conversation_map = $self->_get_conversation_map();
if (exists $conversation_map->{$name}) {
return $conversation_map->{$name};
}
if ($name !~ /\//) {
if (exists $conversation_map->{"im/$name"}) {
return $conversation_map->{"im/$name"};
}
}
if (not $self->{'retrieved'}) {
$self->retrieve();
return $self->name_to_id($name);
}
return;
}
sub id_to_name
{
my ($self, $id) = @_;
my $conversation_map = $self->_get_conversation_map();
my %conversation_map_by_id = reverse %{$conversation_map};
if (exists $conversation_map_by_id{$id}) {
return $conversation_map_by_id{$id};
}
if (not $self->{'retrieved'}) {
$self->retrieve();
return $self->id_to_name($id);
}
return;
}
sub reset
{
my ($self) = @_;
if ($self->{'retrieving'}) {
print STDERR "Unable to reset: retrieval in progress\n";
return;
}
$self->{'retrieving'} = 0;
$self->{'retrieved'} = 0;
return 1;
}
1;
__END__
=head1 NAME
App::Paws::Workspace::Conversations
=head1 DESCRIPTION
Provides for retrieving the available conversations from Slack.
Actually receiving messages from those conversations is handled by
L<App::Paws::Receiver>.
=head1 CONSTRUCTOR
=over 4
=item B<new>
Arguments (hash):
=over 8
=item context
The current L<App::Paws::Context> object.
=item workspace
The L<App::Paws::Workspace> object for the
workspace.
=item users
The L<App::Paws::Workspace::Users> object for the
workspace.
=back
Returns a new instance of L<App::Paws::Workspace::Conversations>. The
object is also initialised with conversations at this point. If this
workspace has been loaded and persisted to local storage before, then
conversations are loaded into the object from that storage.
Otherwise, the list of conversations for the workspace is retrieved
from Slack.
=back
=head1 PUBLIC METHODS
=over 4
=item B<get_list>
Returns the current conversation list, as an arrayref. Each entry is
a hashref containing the following members:
=over 8
=item id
The conversation ID from Slack.
=item name
The conversation name, which is the concatenation
of the conversation type and either its name from
Slack (for non-DM conversations), or the name of
the Slack user (for DM conversations).
=item is_member
A boolean indicating whether the current user is a
member of the conversation.
=item user
For DM conversations, the user ID of the other
user in the conversation.
=item type
The conversation type. One of 'im', 'mpim',
'group', or 'channel'.
=back
=item B<retrieve_nb>
Retrieve the list of conversations for this workspace from Slack,
without blocking. If this object has already been used to retrieve
that list, then do nothing.
=item B<retrieve>
Retrieve the list of conversations for this workspace from Slack,
blocking until that is finished. If this object has already been used
to retrieve that list, then do nothing.
=item B<name_to_id>
Takes a conversation name (per the return value of C<get_list>) and
returns a conversation ID. If the conversation name cannot be found,
and this object has not already been used to retrieve the list of
conversations for this workspace from Slack, then retrieve that list
(blocking) and re-check.
=item B<id_to_name>
Takes a conversation ID (per the Slack API) and returns a conversation
name. If the conversation ID cannot be found, and this object has not
already been used to retrieve the list of conversations for this
workspace from Slack, then retrieve that list (blocking) and re-check.
=item B<reset>
Resets the internal object state. This allows for re-fetching
conversations from Slack.
=back
=head1 AUTHOR
Tom Harrison (C<tomh5908@gmail.com>)
=head1 COPYRIGHT & LICENCE
Copyright (c) 2020, Tom Harrison
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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
HOLDER 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.
=cut
| 25.199501 | 75 | 0.625928 |
73fdf079068d0cd13d2c1ab43303a72704a96d72 | 1,149 | pm | Perl | webeve/WebEve/cLog.pm | cwh42/webeve | 29749cb2c15098f5f50ada4b24040d59192c9728 | [
"Artistic-1.0-Perl"
]
| null | null | null | webeve/WebEve/cLog.pm | cwh42/webeve | 29749cb2c15098f5f50ada4b24040d59192c9728 | [
"Artistic-1.0-Perl"
]
| null | null | null | webeve/WebEve/cLog.pm | cwh42/webeve | 29749cb2c15098f5f50ada4b24040d59192c9728 | [
"Artistic-1.0-Perl"
]
| null | null | null | package WebEve::cLog;
use strict;
use FileHandle;
use Date::Calc qw( Today_and_Now );
# --------------------------------------------------------------------------------
# The Constructor
# --------------------------------------------------------------------------------
sub new {
my $class = shift;
my $LogFile = shift;
die "Constructor has to be used as instance method!" if ref($class);
my $self = {};
bless( $self, $class );
$self->{LogFileHandle} = new FileHandle ">>$LogFile";
die("Could not open Logfile <$LogFile>") unless defined( $self->{LogFileHandle} );
return $self;
}
#-----------------------------------------------------------------------
sub logger {
my $self = shift;
my ($message) = @_;
my $fh = $self->{LogFileHandle};
my $UserName = $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'};
printf( $fh "%4d-%02d-%02d %02d:%02d:%02d %s: %s\n",
Today_and_Now(), $UserName, $message );
}
#-----------------------------------------------------------------------
sub DESTROY {
my $self = shift;
$self->{LogFileHandle}->close if defined( $self->{LogFileHandle} );
}
1;
| 24.446809 | 86 | 0.437772 |
ed15a1cb48e46b0b5c63630a1f37db8b0136c2ad | 1,938 | pl | Perl | library/unicode_data/unicode_prop_list/unicode_logical_order_exception.pl | sergio-castro/logtalk3 | 821cb1277cf144be36b52bef9d9f86c530f96fac | [
"Apache-2.0"
]
| null | null | null | library/unicode_data/unicode_prop_list/unicode_logical_order_exception.pl | sergio-castro/logtalk3 | 821cb1277cf144be36b52bef9d9f86c530f96fac | [
"Apache-2.0"
]
| null | null | null | library/unicode_data/unicode_prop_list/unicode_logical_order_exception.pl | sergio-castro/logtalk3 | 821cb1277cf144be36b52bef9d9f86c530f96fac | [
"Apache-2.0"
]
| null | null | null | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file is part of VivoMind Prolog Unicode Resources
%
% VivoMind Prolog Unicode Resources is free software distributed using the
% Creative Commons CC0 1.0 Universal (CC0 1.0) - Public Domain Dedication
% license
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Last modified: March 15, 2012
%
% Original Unicode file header comments follow
/*
# PropList-6.1.0.txt
# Date: 2011-11-30, 01:49:54 GMT [MD]
#
# Unicode Character Database
# Copyright (c) 1991-2011 Unicode, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html
# For documentation, see http://www.unicode.org/reports/tr44/
*/
unicode_logical_order_exception(CodePoint) :-
( var(CodePoint) ->
% generate code point pairs
unicode_logical_order_exception(CodePointStart, CodePointEnd),
between(CodePointStart, CodePointEnd, CodePoint)
; % try first-argument indexing first
unicode_logical_order_exception(CodePoint, _) ->
true
; % look for a code point range that includes the given code point
unicode_logical_order_exception(CodePointStart, CodePointEnd),
between(CodePointStart, CodePointEnd, CodePoint) ->
true
).
% ================================================
unicode_logical_order_exception(0x0E40, 0x0E44). % Logical_Order_Exception # Lo [5] THAI CHARACTER SARA E..THAI CHARACTER SARA AI MAIMALAI
unicode_logical_order_exception(0x0EC0, 0x0EC4). % Logical_Order_Exception # Lo [5] LAO VOWEL SIGN E..LAO VOWEL SIGN AI
unicode_logical_order_exception(0xAAB5, 0xAAB6). % Logical_Order_Exception # Lo [2] TAI VIET VOWEL E..TAI VIET VOWEL O
unicode_logical_order_exception(0xAAB9, 0xAAB9). % Logical_Order_Exception # Lo TAI VIET VOWEL UEA
unicode_logical_order_exception(0xAABB, 0xAABC). % Logical_Order_Exception # Lo [2] TAI VIET VOWEL AUE..TAI VIET VOWEL AY
% Total code points: 15
| 40.375 | 140 | 0.682663 |
ed4eb8378886b84938782645e1c8759d0acc3d0f | 20,817 | pm | Perl | dataserver/opt/swamp/perl5/SWAMP/SWAMPUtils.pm | OWASP/open-swamp | ed68a3c00220f7a1c177d1fcf9e28c5d2910c2c6 | [
"Apache-2.0"
]
| 8 | 2016-03-22T17:25:21.000Z | 2019-06-02T11:39:45.000Z | exec/opt/swamp/perl5/SWAMP/SWAMPUtils.pm | OWASP/open-swamp | ed68a3c00220f7a1c177d1fcf9e28c5d2910c2c6 | [
"Apache-2.0"
]
| null | null | null | exec/opt/swamp/perl5/SWAMP/SWAMPUtils.pm | OWASP/open-swamp | ed68a3c00220f7a1c177d1fcf9e28c5d2910c2c6 | [
"Apache-2.0"
]
| 9 | 2015-10-22T14:40:28.000Z | 2019-10-19T13:36:28.000Z | #** @file SWAMPUtils.pm
#
# @brief Utility methods for SWAMP applications
# @author Dave Boulineau (db), dboulineau@continuousassurance.org
# @copy Copyright (c) 2013 Software Assurance Marketplace, Morgridge Institute for Research
#*
package SWAMP::SWAMPUtils;
use 5.014;
use utf8;
use strict;
use warnings;
use parent qw(Exporter);
use FindBin qw($Bin);
BEGIN {
our $VERSION = '1.00';
}
our (@EXPORT_OK);
BEGIN {
require Exporter;
@EXPORT_OK = qw(
checksumFile
createBOGfileName
createDomainPIDFile
createhtaccess
diewithconfess
findConfig
getBuildNumber
getDomainStateFilename
getHostAndPort
getHostIP
getHostname
getJobDir
getJobFilename
getLoggingConfigString
getMethodName
getSWAMPDir
getSwampConfig
getUUID
loadProperties
makeoption
makezip
makePIDFilename
readDomainPIDFile
removehtaccess
removeDomainPIDFile
pid_extension
saveProperties
safecsvstring
start_process
stop_process
systemcall
trim
uname
condor_chirp
);
}
use English '-no_match_vars';
use Fcntl qw(LOCK_UN LOCK_NB LOCK_EX O_WRONLY O_CREAT O_EXCL);
use Carp qw(croak longmess carp);
use ConfigReader::Simple;
use Cwd qw(abs_path);
use Data::UUID;
use Digest::SHA;
use File::Spec qw(catfile);
use File::Basename qw(basename);
use File::Path qw(remove_tree make_path);
use Log::Log4perl;
use Socket qw(inet_ntoa inet_aton AF_INET);
use constant {
'DEFAULT_CONFIG' => abs_path("$FindBin::Bin/../etc/swamp.conf"),
'ALIVE' => q{alive}, # signal of a functional exec node
'DEAD' => q{dead}, # signal of a non-functional exec node
'AWOL' => q{awol}, # signal of a non-functional exec node that hasn't reported back
};
sub getSWAMPDir {
return abs_path("$FindBin::Bin/..");
}
#** @function diewithconfess( )
# @brief A replacement DIE handler that does not invoke fatal.
#
# @return does not return, but exits with value 3.
#*
sub diewithconfess {
if ($EXCEPTIONS_BEING_CAUGHT) {
# Don't exit within an eval. $EXCEPTIONS_BEING_CAUGHT is Perl interpreter state and 1 iff parsing an eval.
return;
}
Log::Log4perl->get_logger(q{})->error( Carp::longmess(@_) );
exit 3;
}
sub getBuildNumber {
my $config = getSwampConfig();
my $num = $config->get('buildnumber');
return defined($num) ? $num : '0';
}
sub getSwampConfig {
my $configfile = shift || findConfig();
if ( defined($configfile) ) {
return loadProperties($configfile);
}
else {
Log::Log4perl->get_logger(q{})->logcarp('Cannot find config file.');
}
return;
}
## Deprecated by CSA484, DomainMonitors now dynamically register themselves.
##** @function getHypervisorList( $configfile )
## @brief Get the list of hypervisor machines from the config file
##
## @param configfile the path to the config file or undef to use the default
## @return A list of hypervisors that can be used by this SWAMP instance
##*
#sub getHypervisorList0 {
# my $configfile = shift;
# my $config = getSwampConfig($configfile);
# return split( /\s+/sxm, $config->get('hypervisors') );
#}
#** @function getHostAndPort($token, $configfile )
# @brief Return the host and port associated with a pattern in the config file.
#
# @param token the prefix of the host/port pair in the config file. For example 'agentMonitor' would be the prefix for agentMonitorHost
# @param configfile the path to the config file or undef to use the default
# @return textual representations of (port, host)
# @see {@link getSwampConfig}
#*
sub getHostAndPort {
my $token = shift;
my $configfile = shift;
my $config = getSwampConfig($configfile);
return ( $config->get( $token . 'Port' ), $config->get( $token . 'Host' ) );
}
my %methodnames;
sub getMethodName {
my $key = shift;
# Only initialize map if we need to
if ( !%methodnames ) {
%methodnames = loadConfigMethodNames();
}
if ( !defined( $methodnames{$key} ) ) {
Log::Log4perl->get_logger(q{})->logcarp("Cannot find method named $key.");
}
return $methodnames{$key};
}
#** @function createBOGfileName( $execrunid )
# @brief given a execute run it, convert it into a BOG
# filename
#
# @param execrunid - the execrunid of the BOG of interest.
# @return the BOG file's name.
# @see
#*
sub createBOGfileName {
my $execrunid = shift;
return "${execrunid}.bog";
}
sub getJobDir {
my $execrunid = shift;
$execrunid =~ s/ //gxsm;
return "job.${execrunid}";
}
sub getJobFilename {
my $execrunid = shift;
$execrunid =~ s/ //gxsm;
return File::Spec->catfile( getJobDir($execrunid), "${execrunid}.sub" );
}
#** @function getDomainStateFilename( $basedir, $domain)
# @brief Build a filename for a domain's statefile
#
# @param basedir This SWAMP instance's top level directory (above {bin,run,log})
# @param domain The domain of interest.
# @return the absolute path to the `domain`'s state file name.
#*
sub getDomainStateFilename {
my $basedir = shift;
my $domain = shift;
return File::Spec->catfile( abs_path($basedir), 'run', "$domain.state" );
}
sub getLoggingConfigString {
# Load from the config file, if we
# can find it.
my $configfile = findConfig();
if ( defined($configfile) ) {
return abs_path($configfile);
}
# ToDo Move this into the config file
my $config = <<"LOGGING_CONFIG";
log4perl.logger = TRACE, Logfile, Screen
log4perl.appender.Logfile = Log::Log4perl::Appender::File
log4perl.appender.Logfile.filename = sub { logfilename(); };
log4perl.appender.Logfile.mode = append
log4perl.appender.Logfile.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Logfile.layout.ConversionPattern = %d: %p %P %F{1}-%L %m%n
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr = 0
log4perl.appender.Screen.Threshold = TRACE
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %r %p %P %F{1} %M %L> %m %n
LOGGING_CONFIG
# log4perl.appender.Screen = Log::Log4perl::Appender::ScreenColoredLevels
return \$config;
}
sub getUUID {
return Data::UUID->new()->create_str();
}
#** @method loadProperties( $file , \%hash)
# @brief Read a files of properties (key value pairs) into a hashmap
#
# @param file - the name of the property file to read
# @param hash - the hash reference to fill with properties from $file
# @return a ConfigReader::Simple object.
# @see {@link getSwampConfig}
#*
sub loadProperties {
my $file = shift;
my $hashref = shift;
my $config;
Log::Log4perl->get_logger(q{})->debug("loadProperties: reading $file");
$config = ConfigReader::Simple->new($file);
if ( defined($hashref) && ref($hashref) eq "HASH" ) {
my $nItems = 0;
foreach my $key ( $config->directives() ) {
$hashref->{$key} = $config->get($key);
$nItems++;
}
return $nItems;
}
else {
return $config;
}
}
#** @function saveProperties( $file, \%hash, $comment )
# @brief Write the provided hash out to a property file
#
# @param file - the name of the property file to save to
# @param hash - the hash reference with which to fill the properties file.
# @param comment - Optional comment to add to the property file (program version,purpose)
# @return 1 on success, 0 on failure
# @see
#*
sub _getPropString { my ($key, $value) = @_ ;
my $propstring = q{};
my $nlcount = ($value =~ tr/\n//);
if ($nlcount > 0) {
$nlcount += 1;
$propstring = "$key:${nlcount}L=$value";
}
elsif ($value =~ m/^\s+|\s+$/sxm) {
$propstring = "$key:=$value";
}
else {
$propstring = "$key=$value";
}
return $propstring;
}
sub saveProperties {
my $file = shift;
my $hashref = shift;
my $comment = shift;
my $ret = 0;
if ( open( my $fh, '>', abs_path($file) ) ) {
if ( defined($comment) ) {
print $fh "# $comment\n";
}
foreach my $key ( sort keys %{$hashref} ) {
my $propstring = _getPropString($key, $hashref->{$key});
print $fh "$propstring\n";
}
if ( !close($fh) ) {
Log::Log4perl->get_logger(q{})->warn("close failed on $file $OS_ERROR");
}
else {
$ret = 1;
}
}
else {
Log::Log4perl->get_logger(q{})->error("unable to open $file $OS_ERROR");
}
return $ret;
}
#** @function systemcall( $command )
# @brief Run an external process and wait for it to finish
#
# @param $command the entire command line of the process to run
# @return the output (STDOUT and STDERR) of the process and process exit status. 0 => success.
#*
sub systemcall {
my ($command) = @_;
my $handler = $SIG{'CHLD'};
local $SIG{'CHLD'} = 'DEFAULT';
my ( $output, $status ) = ( $_ = qx{$command 2>&1}, $CHILD_ERROR >> 8 );
local $SIG{'CHLD'} = $handler;
if ($status) {
my $msg = "$command failed with status $status";
if ( defined($output) ) {
$msg .= "($output)";
}
carp $msg;
}
return ( $output, $status );
}
sub condor_chirp { my ($prefix, $type, $title, $value) = @_ ;
my $key = 'SWAMP';
if (defined($prefix)) {
$key .= "_$prefix";
}
else {
$key .= "_ARUN";
}
if (defined($type)) {
$key .= "_$type";
}
if (defined($title)) {
$key .= "_$title";
}
if ($type eq 'ID') {
$value = "\\\"$value\\\"";
}
my $command = "/usr/libexec/condor/condor_chirp set_job_attr $key \"$value\"";
my ($output, $status) = systemcall($command);
return($output, $status);
}
#** @function trim( @out )
# @brief remove leading and trailing whitespace from input
#
# @param out The data to be trimmed, a LIST or scalar
# @return trimmed version of input
#*
sub trim {
my @out = @_;
for (@out) {
s/^\s+//sxm;
s/\s+$//sxm;
}
return wantarray ? @out : $out[0];
}
#** @function safecsvstring( )
# @brief Convert a list of values into a comma separated string, allowing for undefined values as well
#
# @return comma separated string of the input values in original order with '<?>' as a placeholder for undefined values
#*
sub safecsvstring {
return join q{,}, map { !defined $_ ? q{<?>} : $_ } @_;
}
#** @function uname( )
# @brief Get the current operating system's name.
#
# @return The name of the current operating system or `unknown` if the name cannot be obtained.
#*
sub uname {
my ( $output, $status ) = systemcall("uname -s");
if ($status) {
return "unknown";
}
else {
chomp $output;
return $output;
}
}
#** @function findConfig( )
# @brief Locate the SWAMP configuration file (swamp.conf)
#
# Search order:
# - location pointed to by the environment variable SWAMP_CONFIG
# - current directory
# - The etc/swamp.conf file relative to where this process is running
# - /opt/swamp/etc/conf the default install location in production environments
# - ../../deployment/swamp/config/swamp.conf subversion location relative to this package
#
# @return The location of the swamp.conf file or undef if the file cannot be found in one of the usual locations.
# @see
#*
sub findConfig {
if ( defined( $ENV{'SWAMP_CONFIG'} ) ) {
return $ENV{'SWAMP_CONFIG'};
}
elsif ( -r 'swamp.conf' ) {
return 'swamp.conf';
}
elsif ( SWAMP::SWAMPUtils->DEFAULT_CONFIG && -r SWAMP::SWAMPUtils->DEFAULT_CONFIG ) {
return SWAMP::SWAMPUtils->DEFAULT_CONFIG;
}
elsif ( -r '/opt/swamp/etc/swamp.conf' ) {
return '/opt/swamp/etc/swamp.conf';
}
elsif ( -r '../../deployment/swamp/config/swamp.conf' ) {
return '../../deployment/swamp/config/swamp.conf';
}
return;
}
sub loadConfigMethodNames {
my $config = getSwampConfig();
if ( !defined($config) ) {
Log::Log4perl->get_logger(q{})->logconfess("cannot get config ");
}
my %methods;
foreach my $key ( $config->directives() ) {
if ( $key =~ /^method\./sxm ) {
my $method = $config->get($key);
$key =~ s/^method\.//sxm;
$methods{$key} = $method;
}
}
return %methods;
}
#** @function checksumFile( $filename, $algorithm)
# @brief Compute the checksum (sha512 default) of a file.
#
# @param filename The path of a file on which to compute the checksum.
# @param algorithm The digest algorithm to use: 1, 224, 256, 384, 512, 512224, or 512256. 512 is the default.
# @return the digest value as a hexadecimal string -or- ERROR if the digest could not be computed.
#*
sub checksumFile {
my $filename = shift;
my $algorithm = shift || 512;
my $sha = Digest::SHA->new(512);
if ( defined( eval { $sha->addfile( $filename, "pb" ); } ) ) {
return $sha->hexdigest;
}
else {
return 'ERROR';
}
}
#** @function getHostname( $ipstr )
# @brief Wrapper for gethostbyaddr: from an ipaddress string resolve the name.
#
# @param ipstr - A string representing an IPv4 address (e.g. '127.0.0.1')
# @return the hostname on success, undef on failure
#*
sub getHostname {
my $ipstr = shift;
return scalar gethostbyaddr( inet_aton($ipstr), AF_INET );
}
sub getHostIP {
my $hostname = shift;
my $ip;
my $ok = eval { $ip = inet_ntoa( scalar gethostbyname( $hostname ) ); };
if (defined($ok)) {
return $ip;
}
return ;
}
# Fork and start the process in @_
sub start_process {
my $server = shift;
my $pid;
if ( $OSNAME eq "MSWin32" ) {
Log::Log4perl->get_logger(q{})->warn("About to call fork() on a Win32 system.");
}
if ( !defined( $pid = fork() ) ) {
Log::Log4perl->get_logger(q{})->warn("Unable to fork process $server: $OS_ERROR");
return;
}
elsif ($pid) {
return $pid;
}
else {
exec($server); # Need a better way to tell if this failed.
# If we return from the exec call, bad bad things have happened.
exit 6;
}
return;
}
# Stop process PID passed in @_
sub stop_process {
my $pid = shift;
# Per RT 27778, use 'KILL' instead of 'INT' as the stop-server signal for
# MSWin platforms:
my $SIGNAL = ( $OSNAME eq "MSWin32" ) ? 'KILL' : 'TERM';
my $ret = kill $SIGNAL, $pid;
sleep 1; # give any old sockets time to go away
if ($ret != 1) {
Log::Log4perl->get_logger(q{})->warn("kill of $pid failed, trying again");
$ret = kill $SIGNAL, $pid;
sleep 1; # give any old sockets time to go away
if ($ret != 1) {
Log::Log4perl->get_logger(q{})->warn("kill of $pid failed again, -9 time.");
$ret = kill -9, $pid;
}
}
return $ret;
}
sub createhtaccess {
my $webroot = shift;
my $projuuid = shift;
my $viewerip = shift;
my $authtoken = shift;
my $ret = 1;
my $errormsg;
my $htfolder = File::Spec->catfile( $webroot, $projuuid );
# Clean up any existing one
removehtaccess( $webroot, $projuuid );
make_path( $htfolder, { 'error' => \my $err } );
if ( @{$err} ) {
$ret = 0;
foreach my $item ( @{$err} ) {
my ( $file, $message ) = %{$item};
$errormsg .= "$file $message, ";
}
}
if ( sysopen my $fh, File::Spec->catfile( $htfolder, '.htaccess' ),
O_WRONLY | O_EXCL | O_CREAT )
{
print $fh qq{#<IfModule mod_rewrite.c>\n};
print $fh qq{# Ensure mod_rewrite engine is turned on\n};
print $fh qq{RewriteEngine on\n};
print $fh qq{# Set the custom header for allowing access to the project\n};
print $fh qq{RequestHeader set AUTHORIZATION "SWAMP $authtoken"\n};
print $fh qq{# Handle proxy rewrite of URL\n};
print $fh qq{RewriteRule ^/?(.*) https://$viewerip/$projuuid/\$1 [P]\n};
print $fh qq{#</IfModule>\n};
if ( !close($fh) ) {
}
}
else {
$ret = 0;
$errormsg .= "Cannot open $htfolder/.htaccess $OS_ERROR";
}
return ( $errormsg, $ret );
}
sub removehtaccess {
my $webroot = shift;
my $projuuid = shift;
my $ret = 1;
my $errormsg;
if (!defined($projuuid) || length($projuuid) < 3) {
return ('no subfolder', 0);
}
remove_tree( File::Spec->catfile( $webroot, $projuuid ), { 'error' => \my $err } );
if ( @{$err} ) {
$ret = 0;
foreach my $item ( @{$err} ) {
my ( $file, $message ) = %{$item};
$errormsg .= "$file $message, ";
}
}
return ( $errormsg, $ret );
}
sub makezip {
my $oldname = shift;
my $log = Log::Log4perl->get_logger(q{});
my $newname = basename($oldname);
my $output;
my $status;
my $tmpdir = "tmp$PID"; #original
mkdir $tmpdir;
chdir $tmpdir;
if ( $newname =~ /(\.tar)/isxm || $newname =~ /(\.tgz)/isxm ) {
$newname =~ s/$1.*$/.zip/sxm;
# This will extract normal and compressed tarballs
( $output, $status ) = systemcall("/bin/tar xf $oldname");
if ($status) {
$log->error(
"Unable to extract tarfile $oldname: ($status) " . defined($output)
? $output
: q{}
);
$newname = $oldname;
}
}
elsif ( $newname =~ /(\.jar$)/isxm ) {
$newname =~ s/$1.*$/.zip/sxm;
( $output, $status ) = system("jar xf $oldname");
if ($status) {
$log->error(
"Unable to extract jarfile $oldname: ($status) " . defined($output)
? $output
: q{}
);
$newname = $oldname;
}
}
else {
$log->error("Do not understand how to re-zip $oldname");
}
if ( $newname ne $oldname ) {
( $output, $status ) = systemcall("zip ../$newname -qr .");
if ($status) {
$log->error(
"Unable to create zipfile ../$newname ($status) " . defined($output)
? $output
: q{}
);
# revert
$newname = $oldname;
}
}
chdir q{..};
remove_tree($tmpdir);
return $newname;
}
sub pid_extension {
return 'did';
}
sub makePIDFilename {
my $pid = shift;
my $domain = shift;
return "${domain}_${pid}." . pid_extension();
}
sub readDomainPIDFile {
my $file = shift;
my $pid;
my $domain;
if (open (my $fh, '<', abs_path($file) ) ) {
while (<$fh>) {
next if (/^\#/sxm);
chomp;
($pid, $domain) = split(/=/sxm, $_);
}
if (!close($fh)) {
my $log = Log::Log4perl->get_logger(q{});
$log->warn("readDomainPIDFile: Cannot close <$file> $OS_ERROR");
}
}
else {
my $log = Log::Log4perl->get_logger(q{});
$log->error("readDomainPIDFile: Cannot open <$file> $OS_ERROR");
}
return ($pid, $domain);
}
sub createDomainPIDFile {
my $pid = shift;
my $domain = shift;
my $file = File::Spec->catfile( getSWAMPDir(), 'run', makePIDFilename($pid, $domain));
my $ret = 0;
if ( open (my $fh, '>', $file) ) {
print $fh "$pid=$domain\n";
if (!close($fh)) {
my $log = Log::Log4perl->get_logger(q{});
$log->warn("createDomainPIDFile: Cannot close <$file> $OS_ERROR");
}
$ret = 1;
}
else {
my $log = Log::Log4perl->get_logger(q{});
$log->error("createDomainPIDFile: Cannot open <$file> $OS_ERROR");
}
return $ret;
}
sub removeDomainPIDFile {
my $pid = shift;
my $domain = shift;
my $file = File::Spec->catfile( getSWAMPDir(), 'run', makePIDFilename($pid, $domain));
my $ret = 0;
if (unlink ($file)) {
$ret = 1;
}
return $ret;
}
#** @function makeoption( $param, $name)
# @brief Convert a parameter into an option or set to blank. This is useful when mapping one set of parameter to a program's options
#
# @param param The parameter to use as the option parameter or empty/undefined
# @param name The option name to build
# @return either '--$name $param' or empty string, either of which should be valid syntax.
#*
sub makeoption {
my $param = shift;
my $name = shift;
if (defined($param) && $param ne q{}) {
return "--$name $param";
}
return q{};
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
=head1 SYNOPSIS
Write the Manual page for this package
=head1 DESCRIPTION
=head1 OPTIONS
=over 8
=item
=back
=head1 EXAMPLES
=head1 SEE ALSO
=cut
| 27.682181 | 135 | 0.59192 |
ed291ac2d69beca904adf715bc7eb149db3eb5aa | 2,228 | pm | Perl | lib/Perl/Lexer.pm | Code-Hex/Perl-Lexer | c0d244896982a0476bdcf8ced03e4b3c932eee20 | [
"Artistic-1.0"
]
| 2 | 2019-01-07T23:00:37.000Z | 2019-01-08T12:03:11.000Z | lib/Perl/Lexer.pm | Code-Hex/Perl-Lexer | c0d244896982a0476bdcf8ced03e4b3c932eee20 | [
"Artistic-1.0"
]
| null | null | null | lib/Perl/Lexer.pm | Code-Hex/Perl-Lexer | c0d244896982a0476bdcf8ced03e4b3c932eee20 | [
"Artistic-1.0"
]
| null | null | null | package Perl::Lexer;
use 5.010000;
use strict;
use warnings;
use B;
our $VERSION = "0.29";
use parent qw(Exporter);
our @EXPORT = qw(
TOKENTYPE_NONE
TOKENTYPE_IVAL
TOKENTYPE_OPNUM
TOKENTYPE_PVAL
TOKENTYPE_OPVAL
);
use Perl::Lexer::Token;
use XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
sub new {
my $class = shift;
bless {}, $class;
}
sub scan_string {
my ($self, $str) = @_;
open my $fh, '<', \$str;
$self->scan_fh($fh);
}
4649;
__END__
=for stopwords hackish yylval tokenize
=encoding utf-8
=head1 NAME
Perl::Lexer - Use Perl5 lexer as a library.
=head1 SYNOPSIS
use v5.18.0;
use Perl::Lexer;
my $lexer = Perl::Lexer->new();
my @tokens = @{$lexer->scan_string('1+2')};
for (@tokens) {
say $_->inspect;
}
Output is:
<Token: THING opval 1>
<Token: ADDOP opnum 63>
<Token: THING opval 2>
=head1 DESCRIPTION
B<THIS LIBRARY IS WRITTEN FOR RESEARCHING PERL5 LEXER API. THIS MODULE USES PERL5 INTERNAL API. DO NOT USE THIS.>
Perl::Lexer is a really hackish library for using Perl5 lexer as a library.
=head1 MOTIVATION
The programming language provides lexer library for itself is pretty nice.
I want to tokenize perl5 code by perl5.
Of course, this module uses Perl5's private APIs. I hope these APIs turn into public.
If we can use lexer, we can write a source code analysis related things like Test::MinimumVersion, and other things.
=head1 WHAT API IS NEEDED FOR WRITING MODULES LIKE THIS.
=over 4
=item Open the token informations for XS hackers.
Now, token name, type, and arguments informations are hidden at toke.c and perly.h.
I need to define `PERL_CORE` for use it... It's too bad.
And, I take token_type and debug_tokens from toke.c.
=back
=head1 METHODS
=over 4
=item my $lexer = Perl::Lexer->new();
Create new Perl::Lexer object.
=item $lexer->scan_string($code: Str) : ArrayRef[Str]
Tokenize perl5 code. This method returns arrayref of Perl::Lexer::Token.
=back
=head1 LICENSE
Copyright (C) Tokuhiro Matsuno.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR
Tokuhiro Matsuno E<lt>tokuhirom@gmail.comE<gt>
=cut
| 18.722689 | 116 | 0.702873 |
73e3c8494cf2f6a3316c200a488f6f83646726d1 | 434 | pl | Perl | perl/lib/unicore/lib/Scx/Ogam.pl | JyothsnaMididoddi26/xampp | 8f34d7fa7c2e6cc37fe4ece5e6886dc4e5c0757b | [
"Apache-2.0"
]
| 1 | 2017-01-31T08:49:16.000Z | 2017-01-31T08:49:16.000Z | xampp/perl/lib/unicore/lib/Scx/Ogam.pl | silent88/Biographies-du-Fontenay | af4567cb6b78003daa72c37b5ac9f5611a360a9f | [
"MIT"
]
| 2 | 2020-07-17T00:13:41.000Z | 2021-05-08T17:01:54.000Z | perl/lib/unicore/lib/Scx/Ogam.pl | Zolhyp/Plan | 05dbf6a650cd54f855d1731dee70098c5c587339 | [
"Apache-2.0"
]
| null | null | null | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by mktables from the Unicode
# database, Version 6.1.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by core Perl only. The format and even the
# name or existence of this file are subject to change without notice. Don't
# use it directly.
return <<'END';
1680 169C
END
| 31 | 78 | 0.64977 |
ed4a015aa6feb2fdd9515c85b9a4a13c7fcaa5ae | 106 | pl | Perl | HelloWorld/ProgrammingPerl/ch09/ch09.020.pl | grtlinux/KieaPerl | ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e | [
"Apache-2.0"
]
| null | null | null | HelloWorld/ProgrammingPerl/ch09/ch09.020.pl | grtlinux/KieaPerl | ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e | [
"Apache-2.0"
]
| null | null | null | HelloWorld/ProgrammingPerl/ch09/ch09.020.pl | grtlinux/KieaPerl | ed8e1e3359ad0186d5cc4f7ed037e956d2f26c9e | [
"Apache-2.0"
]
| null | null | null | 0 0..3 "fred" "barney" "wilma" "betty"
1 0..2 "george" "jane" "elroy"
2 0..2 "homer" "marge" "bart"
| 26.5 | 40 | 0.54717 |
ed417efbcc2924b2e097f993b31c213d8ffef463 | 2,458 | pl | Perl | alphanum.pl | aiekick/alphanum | 1f9a72cc50543fc2b4a9e2aba8ab5b5fbb103f54 | [
"MIT"
]
| 3 | 2021-01-05T08:41:49.000Z | 2022-02-07T19:52:40.000Z | alphanum.pl | aiekick/alphanum | 1f9a72cc50543fc2b4a9e2aba8ab5b5fbb103f54 | [
"MIT"
]
| null | null | null | alphanum.pl | aiekick/alphanum | 1f9a72cc50543fc2b4a9e2aba8ab5b5fbb103f54 | [
"MIT"
]
| 2 | 2021-01-05T08:44:56.000Z | 2021-01-08T08:16:13.000Z | #
# The Alphanum Algorithm is an improved sorting algorithm for strings
# containing numbers. Instead of sorting numbers in ASCII order like
# a standard sort, this algorithm sorts numbers in numeric order.
#
# The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
#
# Released under the MIT License - https://opensource.org/licenses/MIT
#
# Copyright 2007-2017 David Koelle
#
# 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.
#
#
# TODO: Make decimal points be considered in the same class as digits
#
# usage:
#my @sorted = sort { alphanum($a,$b) } @strings;
sub alphanum {
# split strings into chunks
my @a = chunkify($_[0]);
my @b = chunkify($_[1]);
# while we have chunks to compare.
while (@a && @b) {
my $a_chunk = shift @a;
my $b_chunk = shift @b;
my $test =
(($a_chunk =~ /\d/) && ($b_chunk =~ /\d/)) ? # if both are numeric
$a_chunk <=> $b_chunk : # compare as numbers
$a_chunk cmp $b_chunk ; # else compare as strings
# return comparison if not equal.
return $test if $test != 0;
}
# return longer string.
return @a <=> @b;
}
# split on numeric/non-numeric transitions
sub chunkify {
my @chunks = split m{ # split on
(?= # zero width
(?<=\D)\d | # digit preceded by a non-digit OR
(?<=\d)\D # non-digit preceded by a digit
)
}x, $_[0];
return @chunks;
}
| 33.671233 | 79 | 0.674532 |
ed01d577d5100f787c2298f97a2281393c3fb00a | 3,571 | pm | Perl | modules/Bio/EnsEMBL/GlyphSet/coverage.pm | nerdstrike/ensembl-webcode | ab69513124329e1b2d686c7d2c9f1d7689996a0b | [
"Apache-2.0",
"MIT"
]
| null | null | null | modules/Bio/EnsEMBL/GlyphSet/coverage.pm | nerdstrike/ensembl-webcode | ab69513124329e1b2d686c7d2c9f1d7689996a0b | [
"Apache-2.0",
"MIT"
]
| null | null | null | modules/Bio/EnsEMBL/GlyphSet/coverage.pm | nerdstrike/ensembl-webcode | ab69513124329e1b2d686c7d2c9f1d7689996a0b | [
"Apache-2.0",
"MIT"
]
| 1 | 2020-12-31T10:16:10.000Z | 2020-12-31T10:16:10.000Z | =head1 LICENSE
Copyright [1999-2013] 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
package Bio::EnsEMBL::GlyphSet::coverage;
use strict;
use Sanger::Graphics::Bump;
use Bio::EnsEMBL::Variation::Utils::Sequence qw(ambiguity_code variation_class);
use base qw(Bio::EnsEMBL::GlyphSet);
sub _init {
my ($self) = @_;
my $type = $self->type;
my $Config = $self->{'config'};
my $transcript = $Config->{'transcript'}->{'transcript'};
my @coverage_levels = sort { $a <=> $b } @{$Config->{'transcript'}->{'coverage_level'}};
my $max_coverage = $coverage_levels[-1];
my $min_coverage = $coverage_levels[0] || $coverage_levels[1];
my $coverage_obj = $Config->{'transcript'}->{'coverage_obj'};
unless (@$coverage_obj && @coverage_levels) {
$self->push($self->Space({
'x' => 1,
'y' => 0,
'height' => 1,
'width' => 1,
'absolutey' => 1,
}) );
return;
}
my $sample = $Config->{'transcript'}->{'sample'};
my $A = $self->my_config('type') eq 'bottom' ? 0 : 1;
my %draw_coverage = (
$coverage_levels[0] => [0, "grey70"],
$coverage_levels[1] => [1, "grey40"],
);
# Drawing stuff
my $fontname = $Config->species_defs->ENSEMBL_STYLE->{'GRAPHIC_FONT'};
my($font_w_bp, $font_h_bp) = $Config->texthelper->px2bp($fontname);
foreach my $coverage ( sort { $a->[2]->level <=> $b->[2]->level } @$coverage_obj ) {
my $level = $coverage->[2]->level;
my $y = $draw_coverage{$level}[0];
my $z = 2+$y;# -19+$y;
$y = 1 - $y if $A;
$y *= 2;
my $h = 3 - $y;
$y = 0;
# Draw ------------------------------------------------
my $S = $coverage->[0];
my $E = $coverage->[1];
my $width = $font_w_bp * length( $level );
my $offset = $self->{'container'}->strand > 0 ? $self->{'container'}->start - 1 : $self->{'container'}->end + 1;
my $start = $coverage->[2]->start() + $offset;
my $end = $coverage->[2]->end() + $offset;
my $pos = "$start-$end";
my $display_level = $level == $max_coverage ? ">".($level-1) : $level;
my $bglyph = $self->Rect({
'x' => $S,
'y' => 8-$h,
'height' => $h, #$y,
'width' => $E-$S+1,
'colour' => $draw_coverage{$level}->[1],
'absolutey' => 1,
'href' => $self->_url({'action' => 'ReadCoverage', 'pos' => $pos, 'sp' => $sample, 'disp_level' => $display_level}),
'zmenu' => {
'caption' => 'Resequencing read coverage: '.$display_level,
"12:bp $pos" => '',
"14:$sample" => '',
"16:Source: Sanger",
},
'z' => $z
});
#$self->join_tag( $bglyph, "$S:$E:$level", $A,$A, $draw_coverage{$level}->[1], 'fill', $z );
#$self->join_tag( $bglyph, "$S:$E:$level", 1-$A,$A, $draw_coverage{$level}->[1], 'fill', $z );
$self->push( $bglyph );
}
}
sub error_track_name { return 'read coverage'; }
1;
| 33.688679 | 127 | 0.548586 |
73d17ea32a0cbfeece4488d3906afecd389e4322 | 493 | pm | Perl | src/core/IO.pm | bdw/rakudo | deac603914bd19b60afea9bdac92525b63f0665c | [
"Artistic-2.0"
]
| null | null | null | src/core/IO.pm | bdw/rakudo | deac603914bd19b60afea9bdac92525b63f0665c | [
"Artistic-2.0"
]
| null | null | null | src/core/IO.pm | bdw/rakudo | deac603914bd19b60afea9bdac92525b63f0665c | [
"Artistic-2.0"
]
| null | null | null | my role IO {
method umask { state $ = :8( qx/umask/.chomp ) }
}
enum SeekType (
:SeekFromBeginning(0),
:SeekFromCurrent(1),
:SeekFromEnd(2),
);
enum ProtocolFamily (
:PF_LOCAL(0),
:PF_UNIX(1),
:PF_INET(2),
:PF_INET6(3),
:PF_MAX(4),
);
enum SocketType (
:SOCK_PACKET(0),
:SOCK_STREAM(1),
:SOCK_DGRAM(2),
:SOCK_RAW(3),
:SOCK_RDM(4),
:SOCK_SEQPACKET(5),
:SOCK_MAX(6),
);
enum ProtocolType (
:PROTO_TCP(6),
:PROTO_UDP(17),
);
# vim: ft=perl6 expandtab sw=4
| 15.40625 | 52 | 0.616633 |
ed53d90eaf7db67b765940b6526fac3e639933ec | 25,043 | pm | Perl | lib/CXGN/BrAPI/v2/Images.pm | dwaring87/sgn | 1d7b7de9c4fdb1f3b22a1fcff070f2c3846e4fd0 | [
"MIT"
]
| null | null | null | lib/CXGN/BrAPI/v2/Images.pm | dwaring87/sgn | 1d7b7de9c4fdb1f3b22a1fcff070f2c3846e4fd0 | [
"MIT"
]
| null | null | null | lib/CXGN/BrAPI/v2/Images.pm | dwaring87/sgn | 1d7b7de9c4fdb1f3b22a1fcff070f2c3846e4fd0 | [
"MIT"
]
| null | null | null | package CXGN::BrAPI::v2::Images;
use Moose;
use Data::Dumper;
use File::Basename;
use File::Slurp qw | slurp |;
use Image::Size;
use SGN::Model::Cvterm;
use SGN::Image;
use CXGN::Image::Search;
use CXGN::Page;
use CXGN::Tag;
use CXGN::Phenotypes::StorePhenotypes;
use Scalar::Util qw(looks_like_number);
extends 'CXGN::BrAPI::v2::Common';
sub search {
my $self = shift;
my $params = shift;
my $page_size = $self->page_size;
my $page = $self->page;
my $status = $self->status;
my $page_obj = CXGN::Page->new();
my $hostname = $page_obj->get_hostname();
my @data_files;
my $image_ids_arrayref = $params->{imageDbId} || ($params->{imageDbIds} || ());
my $image_names_arrayref = $params->{imageName} || ($params->{imageNames} || ());
my $stock_ids_arrayref = $params->{observationUnitDbId} || ($params->{observationUnitDbIds} || ());
my $phenotype_ids_arrayref = $params->{observationDbId} || ($params->{observationDbIds} || ());
my $descriptors_arrayref = $params->{descriptiveOntologyTerm} || ($params->{descriptiveOntologyTerms} || ());
my $reference_ids_arrayref = $params->{externalReferenceID} || ($params->{externalReferenceIDs} || ());
my $reference_sources_arrayref = $params->{externalReferenceSource} || ($params->{externalReferenceSources} || ());
my $imagefile_names_arrayref = $params->{imageFileNames} || ($params->{imageFileNames} || ());
my $imagefile_size_max = $params->{imageFileSizeMax}->[0] || undef;
my $imagefile_size_min = $params->{imageFileSizeMin}->[0] || undef;
my $image_height_max = $params->{imageHeightMax}->[0] || undef;
my $image_height_min = $params->{imageHeightMin}->[0] || undef;
my $image_location_arrayref = $params->{imageLocation} || ($params->{imageLocation} || ());
my $image_timestamp_end = $params->{imageTimeStampRangeEnd}->[0] || undef;
my $image_timestamp_start = $params->{imageTimeStampRangeStart}->[0] || undef;
my $image_width_max = $params->{imageWidthMax}->[0] || undef;
my $image_width_min = $params->{imageWidthMin}->[0] || undef;
my $mimetypes_arrayref = $params->{mimeTypes } || ($params->{mimeTypes} || ());
if (($phenotype_ids_arrayref && scalar(@$phenotype_ids_arrayref)>0) || ($reference_ids_arrayref && scalar(@$reference_ids_arrayref)>0) || ($reference_sources_arrayref && scalar(@$reference_sources_arrayref)>0) || ($image_location_arrayref && scalar(@$image_location_arrayref)>0)){
push @$status, { 'error' => 'The following search parameters are not implemented: observationDbId, externalReferenceID, externalReferenceSources, imageLocation' };
}
my %imagefile_names_arrayref;
if ($imagefile_names_arrayref && scalar(@$imagefile_names_arrayref)>0){
%imagefile_names_arrayref = map { $_ => 1} @$imagefile_names_arrayref;
}
my %phenotype_ids_arrayref;
if ($phenotype_ids_arrayref && scalar(@$phenotype_ids_arrayref)>0){
%phenotype_ids_arrayref = map { $_ => 1} @$phenotype_ids_arrayref;
}
my %mimetypes_arrayref;
if ($mimetypes_arrayref && scalar(@$mimetypes_arrayref)>0){
%mimetypes_arrayref = map { $_ => 1} @$mimetypes_arrayref;
}
my $start_index = $page*$page_size;
my $end_index = $page*$page_size + $page_size;
my $limit = $end_index-$start_index;
my $offset = $start_index;
my $image_search = CXGN::Image::Search->new({
bcs_schema=>$self->bcs_schema(),
people_schema=>$self->people_schema(),
phenome_schema=>$self->phenome_schema(),
image_name_list=>$image_names_arrayref,
description_list=>$descriptors_arrayref,
stock_id_list=>$stock_ids_arrayref,
image_id_list=>$image_ids_arrayref,
# still need to implement in the search
# phenotype_id_list=>$phenotype_ids_arrayref,
# imagefile_names_list =>$imagefile_names_arrayref,
# image_location_list =>$image_location_arrayref,
# mimetypes_list =>$mimetypes_arrayref
limit=>$limit,
offset=>$offset
});
my ($result, $total_count) = $image_search->search();
my @data;
foreach (@$result) {
my $mimetype = _get_mimetype($_->{'image_file_ext'});
if ( (%mimetypes_arrayref && !exists($mimetypes_arrayref{$mimetype}))) { next; }
if ( (%imagefile_names_arrayref && !exists($imagefile_names_arrayref{$_->{'image_original_filename'}}))) { next; }
if ( $image_timestamp_start && _to_comparable($_->{'image_modified_date'}) lt _to_comparable($image_timestamp_start) ) { next; }
if ( $image_timestamp_end && _to_comparable($_->{'image_modified_date'}) gt _to_comparable($image_timestamp_end) ) { next; }
my $image = SGN::Image->new($self->bcs_schema()->storage->dbh(), $_->{'image_id'});
my @cvterms = $image->get_cvterms();
my $url = $hostname . $image->get_image_url('medium');
my $filename = $image->get_filename();
my $size = (stat($filename))[7];
my ($width, $height) = imgsize($filename);
if ( $imagefile_size_max && $size > $imagefile_size_max ) { next; }
if ( $imagefile_size_min && $size < $imagefile_size_min + 1 ) { next; }
if ( $image_height_max && $height > $image_height_max ) { next; }
if ( $image_height_min && $height < $image_height_min + 1 ) { next; }
if ( $image_width_max && $width > $image_width_max ) { next; }
if ( $image_width_min && $width < $image_width_min + 1 ) { next; }
# Process cvterms
my @cvterm_names;
foreach (@cvterms) {
push(@cvterm_names, $_->name);
}
# Get the observation db ids
my @observationDbIds;
my $observations_array = $_->{'observations_array'};
foreach (@$observations_array) {
my $observationDbId = $_->{'phenotype_id'};
push @observationDbIds, $observationDbId
}
my %unique_tags;
foreach (@{$_->{'tags_array'}}) {
$unique_tags{$_->{tag_id}} = $_;
}
my @sorted_tags;
foreach my $tag_id (sort keys %unique_tags) {
push @sorted_tags, $unique_tags{$tag_id};
}
push @data, {
additionalInfo => {
observationLevel => $_->{'stock_type_name'},
observationUnitName => $_->{'stock_uniquename'},
tags => \@sorted_tags,
},
copyright => $_->{'image_username'} . " " . substr($_->{'image_modified_date'},0,4),
description => $_->{'image_description'},
descriptiveOntologyTerms => \@cvterm_names,
externalReferences => [],
imageDbId => qq|$_->{'image_id'}|,
imageFileName => $_->{'image_original_filename'},
imageFileSize => $size,
imageHeight => $height,
imageWidth => $width,
imageName => $_->{'image_name'},
imageTimeStamp => $_->{'image_modified_date'},
imageURL => $url,
mimeType => _get_mimetype($_->{'image_file_ext'}),
observationUnitDbId => qq|$_->{'stock_id'}|,
# location and linked phenotypes are not yet available for images in the db
imageLocation => {
geometry => {
coordinates => [],
type=> '',
},
type => '',
},
observationDbIds => [@observationDbIds],
};
}
my %result = (data => \@data);
my $pagination = CXGN::BrAPI::Pagination->pagination_response($total_count,$page_size,$page);
return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, 'Image search result constructed');
}
sub detail {
my $self = shift;
my $inputs = shift;
my $page_size = $self->page_size;
my $page = $self->page;
my $status = $self->status;
my $page_obj = CXGN::Page->new();
my $hostname = $page_obj->get_hostname();
my @data_files;
my $image = SGN::Image->new($self->bcs_schema()->storage->dbh(), $inputs->{image_id});
my @cvterms = $image->get_cvterms();
my $url = $hostname . $image->get_image_url('medium');
my $filename = $image->get_filename();
my $size = (stat($filename))[7];
my ($width, $height) = imgsize($filename);
my @image_ids;
push @image_ids, $inputs->{image_id};
my $image_search = CXGN::Image::Search->new({
bcs_schema=>$self->bcs_schema(),
people_schema=>$self->people_schema(),
phenome_schema=>$self->phenome_schema(),
image_id_list=>\@image_ids
});
my ($search_result, $total_count) = $image_search->search();
my %result;
foreach (@$search_result) {
# Process cvterms
my @cvterm_names;
foreach (@cvterms) {
push(@cvterm_names, $_->name);
}
# Get the observation variable db ids
my @observationDbIds;
my $observations_array = $_->{'observations_array'};
foreach (@$observations_array) {
my $observationDbId = $_->{'phenotype_id'};
push @observationDbIds, $observationDbId
}
%result = (
additionalInfo => {
observationLevel => $_->{'stock_type_name'},
observationUnitName => $_->{'stock_uniquename'},
tags => $_->{'tags_array'},
},
copyright => $_->{'image_username'} . " " . substr($_->{'image_modified_date'},0,4),
description => $_->{'image_description'},
descriptiveOntologyTerms => \@cvterm_names,
externalReferences => [],
imageDbId => qq|$_->{'image_id'}|,
imageFileName => $_->{'image_original_filename'},
imageFileSize => $size,
imageHeight => $height,
imageWidth => $width,
imageName => $_->{'image_name'},
imageTimeStamp => $_->{'image_modified_date'},
imageURL => $url,
mimeType => _get_mimetype($_->{'image_file_ext'}),
observationUnitDbId => qq|$_->{'stock_id'}|,
# location and linked phenotypes are not yet available for images in the db
imageLocation => {
geometry => {
coordinates => [],
type=> '',
},
type => '',
},
observationDbIds => [@observationDbIds],
);
}
my $total_count = 1;
my $pagination = CXGN::BrAPI::Pagination->pagination_response($total_count,$page_size,$page);
return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, 'Image detail constructed');
}
sub image_metadata_store {
my $self = shift;
my $data = shift;
my $image_dir = shift;
my $user_id = shift;
my $user_type = shift;
my $image_id = shift;
my $page_size = $self->page_size;
my $page = $self->page;
my $status = $self->status;
my $dbh = $self->bcs_schema()->storage()->dbh();
my $page_obj = CXGN::Page->new();
my $hostname = $page_obj->get_hostname();
my @image_ids;
foreach my $params (@{$data}) {
my $image_id = $params->{imageDbId} ? $params->{imageDbId} : undef;
my $imageName = $params->{imageName} ? $params->{imageName} : "";
my $description = $params->{description} ? $params->{description} : "";
my $imageFileName = $params->{imageFileName} ? $params->{imageFileName} : "";
print STDERR "Image filename in metadata store is: $imageFileName\n";
my $mimeType = $params->{mimeType} ? $params->{mimeType} : undef;
my $observationUnitDbId = $params->{observationUnitDbId} ? $params->{observationUnitDbId} : undef;
my $descriptiveOntologyTerms_arrayref = $params->{descriptiveOntologyTerms} || ();
my $observationDbIds_arrayref = $params->{observationDbIds} || ();
# metadata store for the rest not yet implemented
my $imageFileSize = $params->{imageFileSize} ? $params->{imageFileSize} : undef;
my $imageHeight = $params->{imageHeight} ? $params->{imageHeight} : ();
my $imageWidth = $params->{imageWidth} ? $params->{imageWidth} : ();
my $copyright = $params->{copyright} || "";
my $imageTimeStamp = $params->{imageTimeStamp} || "";
my $imageLocation_hashref = $params->{imageLocation} || ();
my $additionalInfo_hashref = $params->{additionalInfo} || ();
# Prechecks before storing
# Check that our observation unit db id exists. If not return error.
if ($observationUnitDbId) {
my $stock = $self->bcs_schema()->resultset("Stock::Stock")->find({ stock_id => $observationUnitDbId });
if (! defined $stock) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, 'Stock id is not valid. Cannot generate image metadata');
}
}
# Check that the cvterms are valid before continuing
my @cvterm_ids;
foreach (@$descriptiveOntologyTerms_arrayref) {
my $cvterm_id;
# If is like number, search for id
if (looks_like_number($_)) {
# Check if the trait exists
$cvterm_id = SGN::Model::Cvterm->find_trait_by_id($self->bcs_schema(), $_);
}
else {
# else search for string
$cvterm_id = SGN::Model::Cvterm->find_trait_by_name($self->bcs_schema(), $_);
}
if (!defined $cvterm_id) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Descriptive ontology term %s not found. Cannot generate image metadata', $_));
}
push(@cvterm_ids, $cvterm_id);
}
# Check that the image type they want to pass in is supported.
# If it is not converted, and is the same after _get_extension, it is not supported.
my $extension_type = _get_extension($mimeType);
if ($extension_type eq $mimeType) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Mime type %s is not supported.', $mimeType));
}
# Check if an image id was passed in, and if that image exists
my $image_obj = CXGN::Image->new( dbh=>$dbh, image_dir => $image_dir, image_id => $image_id);
if ($image_id && ! defined $image_obj->get_create_date()) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Image with id of %s, does not exist', $image_id));
}
# Check that the observationDbIds they passed exists
foreach (@$observationDbIds_arrayref) {
my $phenotype = $self->bcs_schema()->resultset("Phenotype::Phenotype")->find({ phenotype_id => $_ });
if (! defined $phenotype) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Observation with id of %s, does not exist', $_));
}
}
# End of prechecks
# Assign image properties
unless ($image_id) { $image_obj->set_sp_person_id($user_id); }
$image_obj->set_name($imageName);
$image_obj->set_description($description);
$image_obj->set_original_filename($imageFileName);
$image_obj->set_file_ext($extension_type);
# Save the image to the db
$image_id = $image_obj->store();
my $image = SGN::Image->new($self->bcs_schema()->storage->dbh(), $image_id);
# Remove cvterms so we can reassign them later
my @prev_cvterms = $image->get_cvterms();
foreach (@prev_cvterms) {
$image->remove_associated_cvterm($_->cvterm_id);
}
# Store desceriptiveOntologyTerms in the cvterm after finding the cvterm here.
foreach (@cvterm_ids) {
$image->associate_cvterm($_);
}
# Clear previously associated stocks.
my @stocks = $image->get_stocks();
foreach(@stocks){
$image->remove_stock($_->stock_id);
}
# Associate our stock with the image, if a stock_id was provided.
if ($observationUnitDbId) {
my $person = CXGN::People::Person->new($dbh, $user_id);
my $user_name = $person->get_username;
$image->associate_stock($observationUnitDbId, $user_name);
}
# Clear previously associated phenotypes
$image->remove_associated_phenotypes();
# Associate the image with the observations specified
foreach (@$observationDbIds_arrayref) {
my $nd_experiment_phenotype = $self->bcs_schema()->resultset("NaturalDiversity::NdExperimentPhenotype")->find({ phenotype_id => $_ });
if ($nd_experiment_phenotype) {
my %image_hash = ($nd_experiment_phenotype->nd_experiment_id => $image_id);
$image->associate_phenotype(\%image_hash);
} else {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Cannot find experiment associated with observation with id of %s, does not exist', $_));
}
}
push @image_ids, $image_id;
}
my $image_search = CXGN::Image::Search->new({
bcs_schema=>$self->bcs_schema(),
people_schema=>$self->people_schema(),
phenome_schema=>$self->phenome_schema(),
image_id_list=>\@image_ids
});
my ($result, $total_count) = $image_search->search();
my @data;
my $counter = 0;
foreach (@$result) {
my $mimetype = _get_mimetype($_->{'image_file_ext'});
my $image = SGN::Image->new($self->bcs_schema()->storage->dbh(), $_->{'image_id'});
my @cvterms = $image->get_cvterms();
# my $url = $hostname . $image->get_image_url('medium');
# my $filename = $image->get_filename();
# my $size = (stat($filename))[7];
# my ($width, $height) = imgsize($filename);
# Process cvterms
my @cvterm_names;
foreach (@cvterms) {
push(@cvterm_names, $_->name);
}
# Get the observation db ids
my @observationDbIds;
my $observations_array = $_->{'observations_array'};
foreach (@$observations_array) {
my $observationDbId = $_->{'phenotype_id'};
push @observationDbIds, $observationDbId
}
push @data, {
additionalInfo => {
observationLevel => $_->{'stock_type_name'},
observationUnitName => $_->{'stock_uniquename'},
tags => $_->{'tags_array'},
},
copyright => $_->{'image_username'} . " " . substr($_->{'image_modified_date'},0,4),
description => $_->{'image_description'},
descriptiveOntologyTerms => \@cvterm_names,
externalReferences => [],
imageDbId => qq|$_->{'image_id'}|,
imageFileName => $_->{'image_original_filename'},
# imageFileSize => $size,
# imageHeight => $height,
# imageWidth => $width,
imageName => $_->{'image_name'},
imageTimeStamp => $_->{'image_modified_date'},
# imageURL => $url,
mimeType => _get_mimetype($_->{'image_file_ext'}),
observationUnitDbId => qq|$_->{'stock_id'}|,
# location and linked phenotypes are not yet available for images in the db
imageLocation => {
geometry => {
coordinates => [],
type=> '',
},
type => '',
},
observationDbIds => [@observationDbIds],
};
$counter++;
}
my %result = (data => \@data);
my $pagination = CXGN::BrAPI::Pagination->pagination_response($counter,$page_size,$page);
return CXGN::BrAPI::JSONResponse->return_success( \%result, $pagination, undef, $self->status(), 'Image metadata stored');
}
sub image_data_store {
my $self = shift;
my $image_dir = shift;
my $image_id = shift;
my $inputs = shift;
my $content_type = shift;
print STDERR "Image ID: $image_id. inputs to image metadata store: ".Dumper($inputs);
# Get our image file extension type from the database
my @image_ids;
push @image_ids, $image_id;
my $image_search = CXGN::Image::Search->new({
bcs_schema=>$self->bcs_schema(),
people_schema=>$self->people_schema(),
phenome_schema=>$self->phenome_schema(),
image_id_list=>\@image_ids
});
my ($search_result, $total_count) = $image_search->search();
my $file_extension = @$search_result[0]->{'image_file_ext'};
my $original_filename = @$search_result[0]->{'image_original_filename'};
if (! defined $file_extension) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Unsupported image type, %s', $file_extension));
}
my $tempfile = $inputs->filename();
my ($filename, $tempdir, $extension) = fileparse($tempfile);
my $updated_tempfile_name = $tempdir . $original_filename;
print STDERR "\n\n Updated tempfile name is $updated_tempfile_name\n";
rename($tempfile, $updated_tempfile_name);
# process image data through CXGN::Image...
#
my $cxgn_img = CXGN::Image->new(dbh=>$self->bcs_schema()->storage()->dbh(), image_dir => $image_dir, image_id => $image_id);
eval {
$cxgn_img->process_image($updated_tempfile_name);
};
if ($@) {
print STDERR "An error occurred during image processing... $@\n";
}
else {
print STDERR "Image processed successfully.\n";
}
my %result = ( image_id => $image_id);
foreach (@$search_result) {
my $sgn_image = SGN::Image->new($self->bcs_schema()->storage->dbh(), $_->{'image_id'});
my $page_obj = CXGN::Page->new();
my $hostname = $page_obj->get_hostname();
my $url = $hostname . $sgn_image->get_image_url('medium');
my $filename = $sgn_image->get_filename();
my $size = (stat($filename))[7];
my ($width, $height) = imgsize($filename);
# Get the observation variable db ids
my @observationDbIds;
my $observations_array = $_->{'observations_array'};
foreach (@$observations_array) {
my $observationDbId = $_->{'phenotype_id'};
push @observationDbIds, $observationDbId
}
%result = (
additionalInfo => {
observationLevel => $_->{'stock_type_name'},
observationUnitName => $_->{'stock_uniquename'},
},
copyright => $_->{'image_username'} . " " . substr($_->{'image_modified_date'},0,4),
description => $_->{'image_description'},
imageDbId => $_->{'image_id'},
imageFileName => $_->{'image_original_filename'},
imageFileSize => $size,
imageHeight => $height,
imageWidth => $width,
imageName => $_->{'image_name'},
imageTimeStamp => $_->{'image_modified_date'},
imageURL => $url,
mimeType => _get_mimetype($_->{'image_file_ext'}),
observationUnitDbId => $_->{'stock_id'},
# location and linked phenotypes are not yet available for images in the db
imageLocation => {
geometry => {
coordinates => [],
type=> '',
},
type => '',
},
observationDbIds => [@observationDbIds],
);
}
my $pagination = CXGN::BrAPI::Pagination->pagination_response(1, 10, 0);
return CXGN::BrAPI::JSONResponse->return_success( \%result, $pagination, [], $self->status(), 'Image data store successful');
}
sub _get_mimetype {
my $extension = shift || '';
my %mimetypes = (
'.jpg' => 'image/jpeg',
'.JPG' => 'image/jpeg',
'.jpeg' => 'image/jpeg',
'.png' => 'image/png',
'.gif' => 'image/gif',
'.svg' => 'image/svg+xml',
'.pdf' => 'application/pdf',
'.ps' => 'application/postscript',
);
if ( defined $mimetypes{$extension} ) {
return $mimetypes{$extension};
} else {
return $extension;
}
}
sub _get_extension {
my $mimetype = shift;
my %extensions = (
'image/jpeg' => '.jpg',
'image/png' => '.png',
'image/gif' => '.gif',
'image/svg+xml' => '.svg',
'application/pdf' => '.pdf',
'application/postscript' => '.ps'
);
if ( defined $extensions{$mimetype} ) {
return $extensions{$mimetype};
} else {
return $mimetype;
}
}
sub _to_comparable {
my $str_date = shift;
my $date;
if ($str_date) {
$str_date =~ s/\ /+/g; #clean_inputs delete +, adding it
my $formatted_time = Time::Piece->strptime($str_date,'%Y-%m-%dT%T %z');
$date = $formatted_time->epoch;
}
return $date;
}
1;
| 39.562401 | 284 | 0.58148 |
ed4a67ddd5e086b5f945c5adc802e19a04bae12d | 1,047 | t | Perl | t/05_insert_and_emulate_row.t | GeJ/Aniki | 7e2074eea74dc14757d9ef5b742dc419a30af697 | [
"Artistic-1.0"
]
| 32 | 2015-02-10T21:42:43.000Z | 2021-01-18T00:34:33.000Z | t/05_insert_and_emulate_row.t | GeJ/Aniki | 7e2074eea74dc14757d9ef5b742dc419a30af697 | [
"Artistic-1.0"
]
| 25 | 2015-01-13T04:24:24.000Z | 2019-12-07T11:35:38.000Z | t/05_insert_and_emulate_row.t | GeJ/Aniki | 7e2074eea74dc14757d9ef5b742dc419a30af697 | [
"Artistic-1.0"
]
| 14 | 2015-06-03T05:05:31.000Z | 2021-01-15T12:59:16.000Z | use strict;
use warnings;
use utf8;
use Test::More;
use File::Spec;
use lib File::Spec->catfile('t', 'lib');
use t::Util;
run_on_database {
my $row = db->insert_and_emulate_row(author => { name => 'MOZNION' });
ok defined $row, 'row is defined.';
ok $row->is_new, 'new row.';
is_deeply $row->get_columns, {
id => $row->id,
name => 'MOZNION',
message => 'hello',
inflate_message => 'hello',
deflate_message => 'hello',
}, 'Data is valid.';
subtest 'inflate deflate' => sub {
is $row->inflate_message, 'inflate hello';
is $row->deflate_message, 'hello';
my $new_row = db->insert_and_emulate_row(author => +{ name => 'KARUPA', inflate_message => 'hello Aniki', deflate_message => 'hello Aniki' });
isa_ok $new_row, 'Aniki::Row';
is $new_row->name, 'KARUPA';
is $new_row->inflate_message, 'inflate hello Aniki';
is $new_row->deflate_message, 'deflate hello Aniki';
};
};
done_testing();
| 27.552632 | 150 | 0.574976 |
ed2aa799e997dbf7ed4904fc67d58c7693be5cb6 | 354 | pl | Perl | tarantool/comparison/zabbix/aggregate_results.pl | maxim-komar/mail.ru | 6382f3c2c831dea5db229a0687f9d61eb85a47bc | [
"MIT"
]
| null | null | null | tarantool/comparison/zabbix/aggregate_results.pl | maxim-komar/mail.ru | 6382f3c2c831dea5db229a0687f9d61eb85a47bc | [
"MIT"
]
| 1 | 2017-07-22T21:26:03.000Z | 2017-07-22T21:26:03.000Z | tarantool/comparison/zabbix/aggregate_results.pl | maxim-komar/mail.ru | 6382f3c2c831dea5db229a0687f9d61eb85a47bc | [
"MIT"
]
| null | null | null | #!/usr/bin/perl -w
use strict;
my $pat = qr/^mytasks\.(\d+)\.(\d+)\.part\d+\t(\d+)\t(\S+)/;
my %h;
while(<>){
next unless $_ =~ $pat;
my ($from, $to, $count, $time) = ($1, $2, $3, $4);
$h{"$from - $to"}{count} += $count;
$h{"$from - $to"}{time} += $time;
}
foreach(keys %h){
printf "%s\t%.6f\n", $_, $h{$_}{time} / $h{$_}{count};
}
| 22.125 | 60 | 0.443503 |
ed4d0a528e558be1036d6488bfa3caad551466b9 | 599 | pm | Perl | t/lib/tests/TestsFor/Emitria/Schema/Result/Show/Tag.pm | jonathanstowe/Emitria | 4bb700de0c4dc931e2dae24d7fb177d83e5a4514 | [
"Artistic-2.0"
]
| null | null | null | t/lib/tests/TestsFor/Emitria/Schema/Result/Show/Tag.pm | jonathanstowe/Emitria | 4bb700de0c4dc931e2dae24d7fb177d83e5a4514 | [
"Artistic-2.0"
]
| null | null | null | t/lib/tests/TestsFor/Emitria/Schema/Result/Show/Tag.pm | jonathanstowe/Emitria | 4bb700de0c4dc931e2dae24d7fb177d83e5a4514 | [
"Artistic-2.0"
]
| null | null | null | package TestsFor::Emitria::Schema::Result::Show::Tag;
use strict;
use warnings;
use lib qw(t/lib);
use Test::Class::Moose;
with qw(
Emitria::Test::Role::Constructor
Emitria::Test::Role::Package
);
use Emitria::Schema::Result::Show::Tag;
sub test_startup
{
my ( $test ) = @_;
$test->package_name('Emitria::Schema::Result::Show::Tag');
$test->next::method();
}
sub test_setup
{
my ( $test ) = @_;
$test->next::method();
}
sub test_teardown
{
my ( $test ) = @_;
$test->next::method();
}
sub test_shutdown
{
my ( $test ) = @_;
$test->next::method();
}
1;
| 12.744681 | 59 | 0.601002 |
ed552d2879bb2a313aa8ae6f22be63010b1d19e6 | 4,698 | pm | Perl | lib/AsposeCellsCloud/Object/HorizontalPageBreak.pm | aspose-cells-cloud/aspose-cells-cloud-perl | 1753bfd2a79ef00ccaee7d88e55e87d33926754d | [
"MIT"
]
| null | null | null | lib/AsposeCellsCloud/Object/HorizontalPageBreak.pm | aspose-cells-cloud/aspose-cells-cloud-perl | 1753bfd2a79ef00ccaee7d88e55e87d33926754d | [
"MIT"
]
| null | null | null | lib/AsposeCellsCloud/Object/HorizontalPageBreak.pm | aspose-cells-cloud/aspose-cells-cloud-perl | 1753bfd2a79ef00ccaee7d88e55e87d33926754d | [
"MIT"
]
| null | null | null | =begin comment
Copyright (c) 2021 Aspose.Cells Cloud
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.
=end comment
=cut
package AsposeCellsCloud::Object::HorizontalPageBreak;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ("Class::Accessor", "Class::Data::Inheritable");
__PACKAGE__->mk_classdata('attribute_map' => {});
__PACKAGE__->mk_classdata('swagger_types' => {});
__PACKAGE__->mk_classdata('method_documentation' => {});
__PACKAGE__->mk_classdata('class_documentation' => {});
# new object
sub new {
my ($class, %args) = @_;
my $self = bless {}, $class;
foreach my $attribute (keys %{$class->attribute_map}) {
my $args_key = $class->attribute_map->{$attribute};
$self->$attribute( $args{ $args_key } );
}
return $self;
}
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
foreach my $_key (keys %{$self->attribute_map}) {
if (defined $self->{$_key}) {
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
}
}
return $_data;
}
# from Perl hashref
sub from_hash {
my ($self, $hash) = @_;
# loop through attributes and use swagger_types to deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
my $_subclass = substr($_type, 6, -1);
my @_array = ();
foreach my $_element (@{$hash->{$_json_attribute}}) {
push @_array, $self->_deserialize($_subclass, $_element);
}
$self->{$_key} = \@_array;
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
} else {
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
}
}
return $self;
}
# deserialize non-array data
sub _deserialize {
my ($self, $type, $data) = @_;
$log->debugf("deserializing %s with %s",Dumper($data), $type);
if ($type eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data));
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
return $data;
} else { # hash(model)
my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
class => 'HorizontalPageBreak',
required => [], # TODO
} );
__PACKAGE__->method_documentation({
'start_column' => {
datatype => 'int',
base_name => 'StartColumn',
description => '',
format => '',
read_only => '',
},
'end_column' => {
datatype => 'int',
base_name => 'EndColumn',
description => '',
format => '',
read_only => '',
},
'row' => {
datatype => 'int',
base_name => 'Row',
description => '',
format => '',
read_only => '',
},
});
__PACKAGE__->swagger_types( {
'start_column' => 'int',
'end_column' => 'int',
'row' => 'int'
} );
__PACKAGE__->attribute_map( {
'start_column' => 'StartColumn',
'end_column' => 'EndColumn',
'row' => 'Row'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
1;
| 28.131737 | 98 | 0.615794 |
ed1d6891d9e9ebc52c91a14c373d17218b19c748 | 184 | pl | Perl | PfamScripts/make/pfbuild_farm_post_search.pl | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 6 | 2017-01-25T12:53:23.000Z | 2021-03-17T04:52:35.000Z | PfamScripts/make/pfbuild_farm_post_search.pl | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 50 | 2015-11-06T10:31:46.000Z | 2021-12-03T16:17:28.000Z | PfamScripts/make/pfbuild_farm_post_search.pl | Rfam/Rfam-combined | 3e0494c80b0b5760dfe96fb7a817372e61d4df51 | [
"Apache-2.0"
]
| 2 | 2019-05-30T00:10:26.000Z | 2021-04-12T09:42:17.000Z | #!/usr/bin/env perl
use strict;
use warnings;
use Bio::Pfam::HMM::HMMResultsIO;
my $HMMResultsIO = Bio::Pfam::HMM::HMMResultsIO->new;
$HMMResultsIO->convertHMMSearch( "OUTPUT" );
| 18.4 | 55 | 0.711957 |
ed3a854b35bb4198e2b9470cab3b0b89406cdc7f | 4,023 | t | Perl | t/bin/yts.t | preaction/ETL-Yertl | 61b1f01b203a5a9f1bf4cc6885e368a169ecae48 | [
"Artistic-1.0"
]
| 26 | 2015-01-22T14:23:36.000Z | 2021-03-16T18:07:20.000Z | t/bin/yts.t | jkeenan/ETL-Yertl | de163f48b839de6728f91b205ad50ea7084381ed | [
"Artistic-1.0"
]
| 120 | 2015-01-01T12:31:34.000Z | 2020-07-28T02:29:10.000Z | t/bin/yts.t | jkeenan/ETL-Yertl | de163f48b839de6728f91b205ad50ea7084381ed | [
"Artistic-1.0"
]
| 7 | 2015-03-28T20:11:55.000Z | 2022-02-12T02:55:33.000Z |
use ETL::Yertl 'Test';
use Capture::Tiny qw( capture );
use Test::Lib;
use ETL::Yertl::Format::yaml;
use ETL::Yertl::Adapter::test;
my $SHARE_DIR = path( __DIR__, '..', 'share' );
my $script = "$FindBin::Bin/../../bin/yts";
require $script;
$0 = $script; # So pod2usage finds the right file
subtest 'error checking' => sub {
subtest 'no arguments' => sub {
my ( $stdout, $stderr, $exit ) = capture { yts->main() };
isnt $exit, 0, 'error status';
like $stderr, qr{ERROR: Must give a database}, 'contains error message';
};
};
subtest 'read' => sub {
local @ETL::Yertl::Adapter::test::READ_TS = my @ts = (
{
timestamp => '2017-01-01 00:00:00',
metric => 'cpu_load_1m',
value => 1.23,
},
{
timestamp => '2017-01-01 00:01:00',
metric => 'cpu_load_1m',
value => 1.26,
},
);
subtest 'read metric' => sub {
my ( $stdout, $stderr, $exit ) = capture {
yts->main( 'test://localhost', 'cpu_load_1m' );
};
is $exit, 0;
ok !$stderr, 'nothing on stderr' or diag $stderr;
cmp_deeply [ docs_from_string( $stdout ) ], \@ts;
};
subtest 'read metric -- short' => sub {
my ( $stdout, $stderr, $exit ) = capture {
yts->main( 'test://localhost', 'cpu_load_1m', '--short' );
};
is $exit, 0;
ok !$stderr, 'nothing on stderr' or diag $stderr;
cmp_deeply
[ docs_from_string( $stdout ) ],
[ { map {; $_->{timestamp}, $_->{value} } @ts } ];
};
subtest 'read metric -- start/end' => sub {
local @ETL::Yertl::Adapter::test::LAST_READ_TS_ARGS;
my ( $stdout, $stderr, $exit ) = capture {
yts->main( 'test://localhost', 'cpu_load_1m', '--start', '2017-01-01', '--end', '2017-01-02' );
};
is $exit, 0;
ok !$stderr, 'nothing on stderr' or diag $stderr;
cmp_deeply \@ETL::Yertl::Adapter::test::LAST_READ_TS_ARGS,
[ {
metric => 'cpu_load_1m',
start => '2017-01-01',
end => '2017-01-02',
tags => undef,
} ],
'read_ts args correct'
or diag explain \@ETL::Yertl::Adapter::test::LAST_READ_TS_ARGS;
cmp_deeply [ docs_from_string( $stdout ) ], \@ts;
};
subtest 'error: no metric' => sub {
my ( $stdout, $stderr, $exit ) = capture { yts->main( 'test://localhost' ) };
isnt $exit, 0, 'error status';
like $stderr, qr{ERROR: Must give a metric}, 'contains error message';
};
};
subtest 'write' => sub {
my @ts = (
{
timestamp => '2017-01-01T00:00:00',
metric => 'cpu_load_1m',
value => 1.23,
},
{
timestamp => '2017-01-01T00:01:00',
metric => 'cpu_load_1m',
value => 1.26,
},
);
subtest 'write metric' => sub {
local @ETL::Yertl::Adapter::test::WRITE_TS = ();
local *STDIN = $SHARE_DIR->child( 'command', 'yts', 'write.yml' )->openr;
my ( $stdout, $stderr, $exit ) = capture {
yts->main( 'test://localhost' );
};
is $exit, 0;
ok !$stderr, 'nothing on stderr' or diag $stderr;
ok !$stdout, 'nothing on stdout' or diag $stdout;
cmp_deeply \@ETL::Yertl::Adapter::test::WRITE_TS, \@ts
or diag explain \@ETL::Yertl::Adapter::test::WRITE_TS;
};
subtest 'write metric -- short' => sub {
local @ETL::Yertl::Adapter::test::WRITE_TS = ();
local *STDIN = $SHARE_DIR->child( 'command', 'yts', 'write-short.yml' )->openr;
my ( $stdout, $stderr, $exit ) = capture {
yts->main( 'test://localhost', '--short', 'cpu_load_1m' );
};
is $exit, 0;
ok !$stderr, 'nothing on stderr' or diag $stderr;
cmp_deeply \@ETL::Yertl::Adapter::test::WRITE_TS, \@ts;
};
};
done_testing;
| 31.186047 | 107 | 0.504101 |
73d7b6f6dc2982dc0c68248da823e0e435d343d1 | 2,215 | pl | Perl | tools/defsengine/section_pkgs.pl | j-forristal/tfs_lib | d9c8688eb99f5a5f39de091563827f311b4a6ba8 | [
"CC0-1.0"
]
| 1 | 2019-07-19T14:48:52.000Z | 2019-07-19T14:48:52.000Z | tools/defsengine/section_pkgs.pl | j-forristal/tfs_lib | d9c8688eb99f5a5f39de091563827f311b4a6ba8 | [
"CC0-1.0"
]
| null | null | null | tools/defsengine/section_pkgs.pl | j-forristal/tfs_lib | d9c8688eb99f5a5f39de091563827f311b4a6ba8 | [
"CC0-1.0"
]
| null | null | null | #!/usr/bin/perl
use Digest::MD5 qw(md5);
%FL = ();
$DATAFILE = shift;
$FLAGSFILE = shift;
sub shifter {
my $n = shift;
my $c = 0;
while( ($n & 1) == 0 ){
$n = $n >> 1;
$c++;
}
return $c;
}
open(INF,'<',$FLAGSFILE) || die("flagsfile");
while(<INF>){
tr/\r\n//d;
if( $_ =~ m/^([A-Z0-9_]+)\t(\d+)/ ){
$FL{$1} = $2;
# We have to reserve the top flag value
if( $2 == 0x8000 ){ die("Illegal flag value for $1"); }
}
}
close(INF);
sub h {
my $d = shift;
return md5("ADDSEC".$d);
}
%DATA = ();
open(IN, '<', $DATAFILE) || die("datafile");
while(<IN>){
# skip over the non-item stuff
tr/\r\n//d;
next if(m/^[ \t]*#/);
next if($_ eq '');
s/#.*$//;
# parse the line into pieces
@p = split(/\t/, $_);
if( ~~@p < 3 ){
die("BAD: $_");
}
$pkg = $p[2];
$fls = $p[0];
$id = $p[1];
#$nom = $p[3];
# split the flags and calc the int value
@f = split(/\|/, $fls);
$fl = 0;
if( (scalar @f) == 1 ){
# single flag, encode it as a shifter
die("Unknown flag $_") if(!defined $FL{$f[0]});
$fl = 0x8000 + shifter( $FL{$f[0]} );
} else {
# combinable flags, encode accordingly
foreach (@f){
die("Unknown flag $_") if(!defined $FL{$_});
die("Combining high-order flags '$fls'") if( $FL{$_} > 0x7FFF );
$fl += $FL{$_};
}
}
# hash the package name
$h = h($pkg);
die("Dupe of $pkg") if( defined $DATA{$h} );
# save the record data
$DATA{$h} = pack("SS", $fl, $id);
}
# sort the records by hash
@k = sort keys %DATA;
# create an empty offset table
@table = ();
for( $i=0; $i<256; $i++){
push @table, 0;
}
# create linear records array
$BIN = '';
$rec = 1;
foreach (@k){
$i = ord( substr($_, 0, 1) );
$table[$i] = $rec if( $table[$i] == 0 );
$BIN .= $_ . $DATA{$_};
$rec += 1;
}
# terminating empty record
$BIN .= "\x00" x 20;
# print the offset table
for( $i=0; $i<256; $i++){
print pack("S", $table[$i]);
}
# print the records
print $BIN;
| 19.954955 | 88 | 0.443341 |
ed51f961e53fa3947252899a7f821c422e481045 | 10,299 | pl | Perl | OriginalClinSeqScripts/converge/convergeSvs.pl | griffithlab/resources | 53038e3c2c2803cb6eb804776acab7c38f9d667c | [
"MIT"
]
| null | null | null | OriginalClinSeqScripts/converge/convergeSvs.pl | griffithlab/resources | 53038e3c2c2803cb6eb804776acab7c38f9d667c | [
"MIT"
]
| null | null | null | OriginalClinSeqScripts/converge/convergeSvs.pl | griffithlab/resources | 53038e3c2c2803cb6eb804776acab7c38f9d667c | [
"MIT"
]
| null | null | null | #!/usr/bin/env genome-perl
#Written by Malachi Griffith
#For a group of ClinSeq models, get SVs and create a master table that merges all cases together
#Merge at the level of SV positions and then separately at the level of genes
use strict;
use warnings;
use Getopt::Long;
use Term::ANSIColor qw(:constants);
use Data::Dumper;
use above 'Genome';
use Genome::Model::ClinSeq::Util qw(:all);
use Genome::Model::ClinSeq::OriginalScripts::Converge qw(:all);
my $build_ids = '';
my $model_ids = '';
my $model_group_id = '';
my $outdir = '';
my $label = '';
my $verbose = 0;
my $test = 0;
GetOptions ('build_ids=s'=>\$build_ids, 'model_ids=s'=>\$model_ids, 'model_group_id=s'=>\$model_group_id, 'outdir=s'=>\$outdir, 'label=s'=>\$label, 'verbose=i'=>\$verbose, 'test=i'=>\$test);
my $usage=<<INFO;
Example usage:
convergeSvs.pl --model_group_id='50714' --outdir=/tmp/converge_svs/ --label='BRAF' --verbose=1
Specify *one* of the following as input (each model/build should be a ClinSeq model)
--build_ids Comma separated list of specific build IDs
--model_ids Comma separated list of specific model IDs
--model_group_id A single genome model group ID
Combines INDEL results from a group of Clinseq models into a single report:
--outdir Path to directory for output files
--label Label to apply to output files as a prefix
--verbose More descriptive stdout messages
--test Use --test=1 to limit BAM read counting to a small number of positions
INFO
unless (($build_ids || $model_ids || $model_group_id) && $outdir && $label){
print RED, "\n\nRequired parameter missing", RESET;
print GREEN, "\n\n$usage", RESET;
exit(1);
}
unless ($outdir =~ /\/$/){
$outdir .= "/";
}
unless (-e $outdir && -d $outdir){
print RED, "\n\nOutput directory is not valid: $outdir\n\n", RESET;
exit(1);
}
#Define paths/names of final output files
my $positions_outfile = "$outdir"."$label"."_SVs_Merged_PositionLevel.tsv";
my $genes_outfile = "$outdir"."$label"."_SVs_Merged_GeneLevel.tsv";
my $positions_outfile_categorical = "$outdir"."$label"."_SVs_Merged_PositionLevel_Categorical.tsv";
my $genes_outfile_categorical = "$outdir"."$label"."_SVs_Merged_GeneLevel_Categorical.tsv";
#Get the models/builds
my $models_builds;
if ($build_ids){
my @build_ids = split(",", $build_ids);
unless(scalar(@build_ids) > 0){
print RED, "\n\nCould not parse build_ids list: $build_ids", RESET;
}
$models_builds = &getModelsBuilds('-builds'=>\@build_ids, '-verbose'=>$verbose);
}elsif($model_ids){
my @model_ids = split(",", $model_ids);
unless(scalar(@model_ids) > 0){
print RED, "\n\nCould not parse model_ids list: $model_ids", RESET;
}
$models_builds = &getModelsBuilds('-models'=>\@model_ids, '-verbose'=>$verbose);
}elsif($model_group_id){
$models_builds = &getModelsBuilds('-model_group_id'=>$model_group_id, '-verbose'=>$verbose);
}
my @models = @{$models_builds->{models}};
my @builds = @{$models_builds->{builds}};
my $model_count = scalar(@models);
my %svs;
my %genes;
#Cycle through the models and get their builds
my $header_line;
my %model_list;
foreach my $m (@models){
my $model_name = $m->name;
my $model_id = $m->genome_model_id;
my $b = $m->last_succeeded_build || "NONE_FINISHED";
unless ($b){
print RED, "\n\nCould not find a succeeded build to use... for $model_name\n\n", RESET;
next();
}
my $data_directory = $b->data_directory;
my $patient = $m->subject;
my $wgs_build = $b->wgs_build;
my $exome_build = $b->exome_build;
my ($wgs_common_name, $wgs_name, $exome_common_name, $exome_name);
if ($wgs_build){
$wgs_common_name = $wgs_build->subject->individual->common_name;
$wgs_name = $wgs_build->subject->individual->name;
}
if ($exome_build){
$exome_common_name = $exome_build->subject->individual->common_name;
$exome_name = $exome_build->subject->individual->name;
}
#Get the patient common name from one of the builds, if none can be found, use the individual name instead, if that can't be found either set the name to 'UnknownName'
my @names = ($wgs_common_name, $exome_common_name, $wgs_name, $exome_name);
my $final_name;
foreach my $name (@names){
if ($name){
$final_name = $name;
last();
}
}
unless ($final_name){
print RED, "\n\nCould not determine a common or subject name from model: $model_name ($model_id)\n\n", RESET;
exit();
}
#Store model objects and values for later
$model_list{$model_id}{model_name} = $model_name;
$model_list{$model_id}{data_directory} = $data_directory;
$model_list{$model_id}{patient} = $patient;
$model_list{$model_id}{final_name} = $final_name;
#Find the appropriate SV file
my $clinseq_sv_dir = $data_directory . "/" . $final_name . "/sv/";
print BLUE, "\n$final_name\t$model_id\t$model_name\t$clinseq_sv_dir", RESET;
my $sv_file = $clinseq_sv_dir . "CandidateSvCodingFusions.tsv";
unless (-e $sv_file){
print RED, "\n\nCould not find SV file: $sv_file\n\n", RESET;
exit(1);
}
#Parse the SV file
my $header = 1;
my %columns;
open (SV, "$sv_file") || die "\n\nCould not open SV file: $sv_file\n\n";
while(<SV>){
chomp($_);
my $line = $_;
my @line = split("\t", $line);
if ($header == 1){
$header_line = $line;
$header = 0;
my $p = 0;
foreach my $head (@line){
$columns{$head}{pos} = $p;
$p++;
}
next();
}
my $gene_pair = $line[$columns{'gene_pair'}{pos}];
my $gene1 = $line[$columns{'gene1'}{pos}];
my $gene2 = $line[$columns{'gene2'}{pos}];
my $coord1 = $line[$columns{'coord1'}{pos}];
my $coord2 = $line[$columns{'coord2'}{pos}];
my $coord = $coord1 . "_" . $coord2;
my $mapped_gene_name1 = $line[$columns{'mapped_gene_name1'}{pos}];
my $mapped_gene_name2 = $line[$columns{'mapped_gene_name2'}{pos}];
my $pairoscope_tumor_reads = $line[$columns{'pairoscope_tumor_reads'}{pos}];
my $pairoscope_normal_reads = $line[$columns{'pairoscope_normal_reads'}{pos}];
#Merge to the level of distinct CTX SV positions...
if ($svs{$coord}){
$svs{$coord}{recurrence}++;
my $cases_ref = $svs{$coord}{cases};
$cases_ref->{$final_name}=1;
$svs{$coord}{pairoscope_tumor_reads} += $pairoscope_tumor_reads;
$svs{$coord}{pairoscope_normal_reads} += $pairoscope_normal_reads;
}else{
$svs{$coord}{recurrence} = 1;
$svs{$coord}{gene_pair} = $gene_pair;
$svs{$coord}{gene1} = $gene1;
$svs{$coord}{gene2} = $gene2;
$svs{$coord}{coord1} = $coord1;
$svs{$coord}{coord2} = $coord2;
$svs{$coord}{mapped_gene_name1} = $mapped_gene_name1;
$svs{$coord}{mapped_gene_name2} = $mapped_gene_name2;
$svs{$coord}{pairoscope_tumor_reads} = $pairoscope_tumor_reads;
$svs{$coord}{pairoscope_normal_reads} = $pairoscope_normal_reads;
$svs{$coord}{line} = $line;
my %cases;
$cases{$final_name}=1;
$svs{$coord}{cases} = \%cases;
}
#Merge to the level of distinct gene name pairs
if ($genes{$gene_pair}){
$genes{$gene_pair}{total_mutation_count}++;
my $positions_ref = $genes{$gene_pair}{positions};
$positions_ref->{$coord}=1;
my $cases_ref = $genes{$gene_pair}{cases};
$cases_ref->{$final_name}=1;
}else{
$genes{$gene_pair}{mapped_gene_name1} = $mapped_gene_name1;
$genes{$gene_pair}{mapped_gene_name2} = $mapped_gene_name2;
$genes{$gene_pair}{total_mutation_count} = 1;
my %positions;
$positions{$coord} = 1;
$genes{$gene_pair}{positions} = \%positions;
my %cases;
$cases{$final_name} = 1;
$genes{$gene_pair}{cases} = \%cases;
}
}
close(SV);
}
my $new_model_count = keys %model_list;
unless ($model_count == $new_model_count){
print RED, "\n\nDiscrepancy between number of models in input model group and number of common/subject names found (redundant models?)\n\n", RESET;
exit(1);
}
#Print the position level recurrence summary
open (OUT1, ">$positions_outfile") || die "\n\nCould not open output file for writing: $positions_outfile\n\n";
open (OUT2, ">$positions_outfile_categorical") || die "\n\nCould not open output file for writing: $positions_outfile_categorical\n\n";
print OUT1 "coord\trecurrence_count\tmutated_samples\tsum_pairoscope_tumor_reads\tsum_pairoscope_normal_reads\t$header_line\n";
print OUT2 "coord\tsample\n";
foreach my $coord (sort keys %svs){
my $cases_ref = $svs{$coord}{cases};
my @cases = keys %{$cases_ref};
my @sort_cases = sort @cases;
my $sort_cases_string = join(",", @sort_cases);
print OUT1 "$coord\t$svs{$coord}{recurrence}\t$sort_cases_string\t$svs{$coord}{pairoscope_tumor_reads}\t$svs{$coord}{pairoscope_normal_reads}\t$svs{$coord}{line}\n";
foreach my $case (@sort_cases){
print OUT2 "$coord\t$case\n";
}
}
close(OUT1);
close(OUT2);
#Print the gene level recurrence summary
open (OUT1, ">$genes_outfile") || die "\n\nCould not open output file for writing: $genes_outfile\n\n";
open (OUT2, ">$genes_outfile_categorical") || die "\n\nCould not open output file for writing: $genes_outfile_categorical\n\n";
print OUT1 "gene_pair\tmapped_gene_name1\tmapped_gene_name2\ttotal_mutation_count\tmutated_sample_count\tmutated_position_count\tmutated_samples\tmutated_positions\n";
print OUT2 "gene_pair\tsample\n";
foreach my $gene_pair (sort keys %genes){
my $positions_ref = $genes{$gene_pair}{positions};
my @positions = keys %{$positions_ref};
my $positions_count = scalar(@positions);
my @sort_positions = sort @positions;
my $sort_positions_string = join (",", @sort_positions);
my $cases_ref = $genes{$gene_pair}{cases};
my @cases = keys %{$cases_ref};
my @sort_cases = sort @cases;
my $sort_cases_string = join(",", @sort_cases);
my $cases_count = scalar(@cases);
print OUT1 "$gene_pair\t$genes{$gene_pair}{mapped_gene_name1}\t$genes{$gene_pair}{mapped_gene_name2}\t$genes{$gene_pair}{total_mutation_count}\t$cases_count\t$positions_count\t$sort_cases_string\t$sort_positions_string\n";
foreach my $case (@sort_cases){
print OUT2 "$gene_pair\t$case\n";
}
}
close(OUT1);
close(OUT2);
print BLUE, "\n\nWrote results to: $outdir\n\n", RESET;
exit();
| 36.913978 | 224 | 0.673172 |
ed4e9dedb766c9fc6bc8f845e786090efc60de8e | 3,470 | pm | Perl | t/lib/TestLib.pm | git-the-cpan/PerlX-Assert | 4af57049408f6a8a2bec6d6a5f9ece6f07a6ae9e | [
"Artistic-1.0"
]
| null | null | null | t/lib/TestLib.pm | git-the-cpan/PerlX-Assert | 4af57049408f6a8a2bec6d6a5f9ece6f07a6ae9e | [
"Artistic-1.0"
]
| null | null | null | t/lib/TestLib.pm | git-the-cpan/PerlX-Assert | 4af57049408f6a8a2bec6d6a5f9ece6f07a6ae9e | [
"Artistic-1.0"
]
| null | null | null | require Test::More;
Test::More::plan( skip_all => "broken by PerlX::Assert's change to decision logic" );
package main;
no warnings qw(void);
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
};
#line 0 02kwapi.t
{
package Foo;
use PerlX::Assert;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
die("Could not compile class Foo: $@") if $@;
ok( 'Foo'->go(6), 'class compiled with no relevant environment variables; assertions are ignored' );
ok( 'Foo'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
{
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
$ENV{AUTHOR_TESTING} = 1;
};
#line 0 02kwapi.t
{
package Foo_AUTHOR;
use PerlX::Assert;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
like(
exception { 'Foo_AUTHOR'->go(6) },
qr{^Assertion failed at 02kwapi.t line 6},
"class compiled with \$ENV{AUTHOR_TESTING}; assertions are working",
);
ok( 'Foo_AUTHOR'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
}
{
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
$ENV{PERL_STRICT} = 1;
};
#line 0 02kwapi.t
{
package Foo_AUTOMATED;
use PerlX::Assert;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
like(
exception { 'Foo_AUTOMATED'->go(6) },
qr{^Assertion failed at 02kwapi.t line 6},
"class compiled with \$ENV{PERL_STRICT}; assertions are working",
);
ok( 'Foo_AUTOMATED'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
}
{
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
$ENV{EXTENDED_TESTING} = 1;
};
#line 0 02kwapi.t
{
package Foo_EXTENDED;
use PerlX::Assert;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
like(
exception { 'Foo_EXTENDED'->go(6) },
qr{^Assertion failed at 02kwapi.t line 6},
"class compiled with \$ENV{EXTENDED_TESTING}; assertions are working",
);
ok( 'Foo_EXTENDED'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
}
{
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
$ENV{RELEASE_TESTING} = 1;
};
#line 0 02kwapi.t
{
package Foo_RELEASE;
use PerlX::Assert;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
like(
exception { 'Foo_RELEASE'->go(6) },
qr{^Assertion failed at 02kwapi.t line 6},
"class compiled with \$ENV{RELEASE_TESTING}; assertions are working",
);
ok( 'Foo_RELEASE'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
}
{
BEGIN {
$ENV{AUTHOR_TESTING} = $ENV{PERL_STRICT} = $ENV{EXTENDED_TESTING} = $ENV{RELEASE_TESTING} = 0;
};
#line 0 02kwapi.t
{
package Foo_EXPLICIT;
use PerlX::Assert -check;
sub go {
my $self = shift;
my ($x) = @_;
assert { $x < 5 };
return 1;
}
}
like(
exception { 'Foo_EXPLICIT'->go(6) },
qr{^Assertion failed at 02kwapi.t line 6},
"class compiled with -check; assertions are working",
);
ok( 'Foo_EXPLICIT'->go(4), '... and a dummy value that should not cause assertion to fail anyway' );
}
done_testing;
1;
| 21.552795 | 102 | 0.628242 |
73f50b83ab826630a826371d245a89655e39e813 | 2,123 | pm | Perl | auto-lib/Paws/IoTEvents/TransitionEvent.pm | torrentalle/aws-sdk-perl | 70cc5c7b7a494e422f8412da619161a99de1f1ec | [
"Apache-2.0"
]
| null | null | null | auto-lib/Paws/IoTEvents/TransitionEvent.pm | torrentalle/aws-sdk-perl | 70cc5c7b7a494e422f8412da619161a99de1f1ec | [
"Apache-2.0"
]
| 1 | 2021-05-26T19:13:58.000Z | 2021-05-26T19:13:58.000Z | auto-lib/Paws/IoTEvents/TransitionEvent.pm | torrentalle/aws-sdk-perl | 70cc5c7b7a494e422f8412da619161a99de1f1ec | [
"Apache-2.0"
]
| null | null | null | package Paws::IoTEvents::TransitionEvent;
use Moose;
has Actions => (is => 'ro', isa => 'ArrayRef[Paws::IoTEvents::Action]', request_name => 'actions', traits => ['NameInRequest']);
has Condition => (is => 'ro', isa => 'Str', request_name => 'condition', traits => ['NameInRequest'], required => 1);
has EventName => (is => 'ro', isa => 'Str', request_name => 'eventName', traits => ['NameInRequest'], required => 1);
has NextState => (is => 'ro', isa => 'Str', request_name => 'nextState', traits => ['NameInRequest'], required => 1);
1;
### main pod documentation begin ###
=head1 NAME
Paws::IoTEvents::TransitionEvent
=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::IoTEvents::TransitionEvent object:
$service_obj->Method(Att1 => { Actions => $value, ..., NextState => $value });
=head3 Results returned from an API call
Use accessors for each attribute. If Att1 is expected to be an Paws::IoTEvents::TransitionEvent object:
$result = $service_obj->Method(...);
$result->Att1->Actions
=head1 DESCRIPTION
Specifies the actions performed and the next state entered when a
C<condition> evaluates to TRUE.
=head1 ATTRIBUTES
=head2 Actions => ArrayRef[L<Paws::IoTEvents::Action>]
The actions to be performed.
=head2 B<REQUIRED> Condition => Str
[Required] A Boolean expression that when TRUE causes the actions to be
performed and the C<nextState> to be entered.
=head2 B<REQUIRED> EventName => Str
The name of the transition event.
=head2 B<REQUIRED> NextState => Str
The next state to enter.
=head1 SEE ALSO
This class forms part of L<Paws>, describing an object used in L<Paws::IoTEvents>
=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
| 27.571429 | 130 | 0.709845 |
ed56d6397f3ced4fcbd9407f89a3341115d38ee2 | 250 | pl | Perl | 2019/PLP/L1/20.pl | LorhanSohaky/UFSCar | af0e84946cbb61b12dfa738610065bbb0f4887a2 | [
"MIT"
]
| 1 | 2021-04-24T05:33:26.000Z | 2021-04-24T05:33:26.000Z | 2019/PLP/L1/20.pl | LorhanSohaky/UFSCar | af0e84946cbb61b12dfa738610065bbb0f4887a2 | [
"MIT"
]
| 8 | 2020-11-21T05:22:13.000Z | 2021-09-22T13:42:22.000Z | 2019/PLP/L1/20.pl | LorhanSohaky/UFSCar | af0e84946cbb61b12dfa738610065bbb0f4887a2 | [
"MIT"
]
| 1 | 2018-11-18T15:50:55.000Z | 2018-11-18T15:50:55.000Z | minN(X,Y,X):-X=<Y,!.
minN(X,Y,Y):-!.
minL([X],X):-!.
minL([X|Y],M):-minL(Y,Z),minN(X,Z,M).
removeE(X,[],[]):-!.
removeE(X,[X|Y],Y):-!.
removeE(X,[Z|Y],[Z|L]):-removeE(X,Y,L).
ordena([],[]):-!.
ordena(X,[W|Z]):-minL(X,W),removeE(W,X,M),ordena(M,Z).
| 20.833333 | 54 | 0.488 |
ed12d771cb1d9923930b09fe81b91bab4648ed8f | 3,186 | pl | Perl | oqtans_tools/Trinity/r2013_08_14/util/nbkc_merge_left_right_stats.pl | vipints/oqtans | af8119a73f6023deca57aedb9b090f7378a1a6c6 | [
"BSD-3-Clause"
]
| 3 | 2015-11-20T19:40:29.000Z | 2019-07-25T15:34:24.000Z | oqtans_tools/Trinity/r2013_08_14/util/nbkc_merge_left_right_stats.pl | vipints/oqtans | af8119a73f6023deca57aedb9b090f7378a1a6c6 | [
"BSD-3-Clause"
]
| null | null | null | oqtans_tools/Trinity/r2013_08_14/util/nbkc_merge_left_right_stats.pl | vipints/oqtans | af8119a73f6023deca57aedb9b090f7378a1a6c6 | [
"BSD-3-Clause"
]
| 2 | 2018-09-20T08:28:36.000Z | 2019-03-06T06:26:52.000Z | #!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case bundling pass_through);
my $usage = <<__EOUSAGE__;
###############################################################################
#
# Required:
#
# --left <string> left.fq.stats
# --right <string> right.fq.stats
#
# Optional
#
# --sorted flag indicating that entries are lexically sorted
# (this can account for differences in representation by
# reads in either file)
# Unpaired entries are ignored.
#
################################################################################
__EOUSAGE__
;
my $left_stats_file;
my $right_stats_file;
my $sorted_flag = 0;
&GetOptions( 'left=s' => \$left_stats_file,
'right=s' => \$right_stats_file,
'sorted' => \$sorted_flag,
);
unless ($left_stats_file && $right_stats_file) {
die $usage;
}
main: {
open (my $left_fh, $left_stats_file) or die $!;
open (my $right_fh, $right_stats_file) or die $!;
my $left_text = <$left_fh>;
my $right_text = <$right_fh>;
while (1) {
if ( (! $left_text) || (! $right_text)) {
last;
}
chomp $left_text;
chomp $right_text;
my ($left_median, $left_avg, $left_stdev, $left_pct, $left_acc, $left_cov) = split(/\t/, $left_text);
my ($right_median, $right_avg, $right_stdev, $right_pct, $right_acc, $right_cov) = split(/\t/, $right_text);
my $core_acc = $left_acc;
if ($left_acc =~ /^(\S+)\/\d$/) {
$core_acc = $1;
}
my $right_core = $right_acc;
if ($right_acc =~ /^(\S+)\/\d$/) {
$right_core = $1;
}
#print STDERR "$core_acc\t$right_core";
#if ($core_acc eq $right_core) { print STDERR "\tYES\n";} else { print STDERR "\n"; }
unless ($right_core eq $core_acc) {
if ($sorted_flag) {
if ($left_acc lt $right_acc) {
$left_text = <$left_fh>; # advance left
}
else {
# advance right
$right_text = <$right_fh>;
}
next;
}
else {
die "Error, core accs are not equivalent: [$core_acc] vs. [$right_core] reads, and --sorted flag wasn't used here.";
}
}
my $median_pair_cov = int( ($left_median+$right_median)/2 + 0.5);
my $avg_pair_cov = int ( ($left_avg + $right_avg)/2 + 0.5);
my $avg_stdev = int( ($left_stdev + $right_stdev)/2 + 0.5);
if ($median_pair_cov != 0) {
## ignore bad reads.
my $avg_pair_pct = int( ($left_pct + $right_pct) / 2 + 0.5);
print join("\t", $median_pair_cov, $avg_pair_cov, $avg_stdev, $avg_pair_pct, $core_acc) . "\n";
}
## advance next entries.
$left_text = <$left_fh>;
$right_text = <$right_fh>;
}
exit(0);
}
| 26.773109 | 132 | 0.467043 |
ed2fddc15d44e28087ccf967682f4f5da8b73445 | 2,004 | pl | Perl | mysql-dst/mysql-cluster/mysql-test/lib/v1/mtr_gprof.pl | SJTU-IPADS/dst | 897b929a692642cbf295c105d9d6e64090abb673 | [
"Apache-2.0"
]
| 9 | 2020-12-17T01:59:13.000Z | 2022-03-30T16:25:08.000Z | mysql-dst/mysql-cluster/mysql-test/lib/v1/mtr_gprof.pl | SJTU-IPADS/dst | 897b929a692642cbf295c105d9d6e64090abb673 | [
"Apache-2.0"
]
| 1 | 2021-07-30T12:06:33.000Z | 2021-07-31T10:16:09.000Z | mysql-dst/mysql-cluster/mysql-test/lib/v1/mtr_gprof.pl | SJTU-IPADS/dst | 897b929a692642cbf295c105d9d6e64090abb673 | [
"Apache-2.0"
]
| 1 | 2021-08-01T13:47:07.000Z | 2021-08-01T13:47:07.000Z | # -*- cperl -*-
# Copyright (c) 2004 MySQL AB, 2008 Sun Microsystems, Inc.
# Use is subject to license terms.
#
# 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; version 2 of the License.
#
# 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This is a library file used by the Perl version of mysql-test-run,
# and is part of the translation of the Bourne shell script with the
# same name.
use strict;
# These are not to be prefixed with "mtr_"
sub gprof_prepare ();
sub gprof_collect ();
##############################################################################
#
#
#
##############################################################################
sub gprof_prepare () {
rmtree($::opt_gprof_dir);
mkdir($::opt_gprof_dir);
}
# FIXME what about master1 and slave1?!
sub gprof_collect () {
if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
{
# FIXME check result code?!
mtr_run("gprof",
[$::exe_master_mysqld,
"$::master->[0]->{'path_myddir'}/gmon.out"],
$::opt_gprof_master, "", "", "");
print "Master execution profile has been saved in $::opt_gprof_master\n";
}
if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
{
# FIXME check result code?!
mtr_run("gprof",
[$::exe_slave_mysqld,
"$::slave->[0]->{'path_myddir'}/gmon.out"],
$::opt_gprof_slave, "", "", "");
print "Slave execution profile has been saved in $::opt_gprof_slave\n";
}
}
1;
| 30.363636 | 78 | 0.603792 |
ed586ccb771f43cdad7b7aff0aebef7e54f3f158 | 692 | pm | Perl | auto-lib/Paws/SageMakerA2IRuntime/ListHumanLoopsResponse.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/SageMakerA2IRuntime/ListHumanLoopsResponse.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/SageMakerA2IRuntime/ListHumanLoopsResponse.pm | 0leksii/aws-sdk-perl | b2132fe3c79a06fd15b6137e8a0eb628de722e0f | [
"Apache-2.0"
]
| 87 | 2015-04-22T06:29:47.000Z | 2021-09-29T14:45:55.000Z |
package Paws::SageMakerA2IRuntime::ListHumanLoopsResponse;
use Moose;
has HumanLoopSummaries => (is => 'ro', isa => 'ArrayRef[Paws::SageMakerA2IRuntime::HumanLoopSummary]', required => 1);
has NextToken => (is => 'ro', isa => 'Str');
has _request_id => (is => 'ro', isa => 'Str');
1;
### main pod documentation begin ###
=head1 NAME
Paws::SageMakerA2IRuntime::ListHumanLoopsResponse
=head1 ATTRIBUTES
=head2 B<REQUIRED> HumanLoopSummaries => ArrayRef[L<Paws::SageMakerA2IRuntime::HumanLoopSummary>]
An array of objects that contain information about the human loops.
=head2 NextToken => Str
A token to display the next page of results.
=head2 _request_id => Str
=cut
| 20.352941 | 120 | 0.715318 |
ed3c3260f1c9a26667ad671fa7df7a7bac5bc46c | 1,953 | pm | Perl | lib/MusicBrainz/Server/Data/Role/ValueSet.pm | kellnerd/musicbrainz-server | 9e058e10219ea6b8942cfd64160ffe19769f747b | [
"BSD-2-Clause"
]
| 577 | 2015-01-15T12:18:50.000Z | 2022-03-16T20:41:57.000Z | lib/MusicBrainz/Server/Data/Role/ValueSet.pm | kellnerd/musicbrainz-server | 9e058e10219ea6b8942cfd64160ffe19769f747b | [
"BSD-2-Clause"
]
| 1,227 | 2015-04-16T01:00:29.000Z | 2022-03-30T15:08:46.000Z | lib/MusicBrainz/Server/Data/Role/ValueSet.pm | kellnerd/musicbrainz-server | 9e058e10219ea6b8942cfd64160ffe19769f747b | [
"BSD-2-Clause"
]
| 280 | 2015-01-04T08:39:41.000Z | 2022-03-10T17:09:59.000Z | package MusicBrainz::Server::Data::Role::ValueSet;
use MooseX::Role::Parameterized;
use Moose::Util qw( ensure_all_roles );
use MusicBrainz::Server::Data::ValueSet;
my @str_params = qw(
entity_type
plural_value_type
value_attribute
value_class
value_type
);
parameter \@str_params => (
is => 'ro',
isa => 'Str',
required => 1,
);
role {
my $params = shift;
requires qw( c );
my $entity_type = $params->entity_type;
my $plural_value_type = $params->plural_value_type;
my $value_attribute = $params->value_attribute;
my $value_class = $params->value_class;
my $value_type = $params->value_type;
has $value_type => (
is => 'ro',
builder => qq(_build_$value_type),
lazy => 1,
);
method qq(_build_$value_type) => sub {
my $self = shift;
my $cls = MusicBrainz::Server::Data::ValueSet->new(
c => $self->c,
entity_type => $entity_type,
plural_value_type => $plural_value_type,
value_attribute => $value_attribute,
value_class => $value_class,
value_type => $value_type,
);
ensure_all_roles(
$cls,
'MusicBrainz::Server::Data::Role::Editable' => {
table => qq(${entity_type}_$value_type),
},
);
};
after update => sub {
my ($self, $entity_id, $update) = @_;
my $values = $update->{$plural_value_type};
if (defined $values) {
$self->$value_type->set($entity_id, @$values);
}
};
};
1;
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012-2017 MetaBrainz Foundation
This file is part of MusicBrainz, the open internet music database,
and is licensed under the GPL version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl-2.0.txt
=cut
| 25.038462 | 67 | 0.565284 |
ed4c8cf45a37839f8c41e2c51e88adccbd96f48e | 471 | t | Perl | t/dbtest/04_subs.t | niccord/OTOBO-OPM-Maker | fa9b8595b02b0a34e82827f1b160d3b58bd66924 | [
"ClArtistic"
]
| null | null | null | t/dbtest/04_subs.t | niccord/OTOBO-OPM-Maker | fa9b8595b02b0a34e82827f1b160d3b58bd66924 | [
"ClArtistic"
]
| null | null | null | t/dbtest/04_subs.t | niccord/OTOBO-OPM-Maker | fa9b8595b02b0a34e82827f1b160d3b58bd66924 | [
"ClArtistic"
]
| null | null | null | #!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use OTOBO::OPM::Maker;
use OTOBO::OPM::Maker::Command::dbtest;
my $dbtest = OTOBO::OPM::Maker::Command::dbtest->new({
app => OTOBO::OPM::Maker->new,
});
{
my $return = $dbtest->abstract;
is $return, 'Check if DatabaseInstall and DatabaseUninstall sections in the .sopm are correct';
}
{
my $return = $dbtest->usage_desc;
is $return, 'opmbuild dbtest <path_to_sopm>';
}
done_testing;
| 18.84 | 99 | 0.666667 |
ed556454e662254cb3a8b147c3f3208c6bac6104 | 1,785 | pm | Perl | libs/Recs/OutputStream.pm | blixtor/RecordStream | ddf0170c40f27f4a0c76c2636a632ff55c54abf8 | [
"MIT"
]
| null | null | null | libs/Recs/OutputStream.pm | blixtor/RecordStream | ddf0170c40f27f4a0c76c2636a632ff55c54abf8 | [
"MIT"
]
| null | null | null | libs/Recs/OutputStream.pm | blixtor/RecordStream | ddf0170c40f27f4a0c76c2636a632ff55c54abf8 | [
"MIT"
]
| null | null | null | package Recs::OutputStream;
=head1 NAME
Recs::OutputStream
=head1 AUTHOR
Benjamin Bernard <perlhacker@benjaminbernard.com>
Keith Amling <keith.amling@gmail.com>
=head1 DESCRIPTION
An output stream for Recs::Record objects
=head1 SYNOPSIS
use Recs::OutputStream;
my $out = Recs::OutputStream->new();
my $record = Recs::Record->new("name" => "John Smith", "age" => 39);
$out->put_record($record);
my $hash = { foo => 'bar' };
$out->put_hashref($hashref);
=head1 CONSTRUCTOR
=over 4
=item my $out = Recs::OutputStream->new(FH);
Takes an optional output file handle to print records to. If none is
specified, will output to STDOUT
=back
=head1 PUBLIC METHODS
=over 4
=item $out->put_record(RECORD);
Takes a L<Recs::Record> object and puts it on the output file handle.
=item $out->put_hashref(HASH_REF);
Puts the HASH_REF on the output stream as a record.
=item $out->record_string(RECORD);
String representation of a record, what would be printed from put_record
=item $out->put_hashref(HASH_REF);
String representation of a hash ref, what would be printed from put_hashref
=back
=cut
use strict;
use lib;
use JSON::Syck;
our $AUTOLOAD;
sub new
{
my $class = shift;
my ($fh) = @_;
$fh ||= \*STDOUT;
my $this =
{
'fh' => $fh,
};
bless $this, $class;
return $this;
}
sub put_record
{
my ($this, $rec) = @_;
my $fh = $this->{'fh'};
print $fh JSON::Syck::Dump($rec->as_hashref()) . "\n";
}
sub put_hashref
{
my ($this, $hr) = @_;
my $fh = $this->{'fh'};
print $fh JSON::Syck::Dump($hr) . "\n";
}
sub record_string {
my ($this, $rec) = @_;
return JSON::Syck::Dump($rec->as_hashref());
}
sub hashref_string {
my ($this, $hr) = @_;
return JSON::Syck::Dump($hr);
}
1;
| 15.521739 | 75 | 0.639776 |
73d857be317fcf6d1f9f9d20f8974825e0b19c76 | 10,098 | pl | Perl | dataDownload/get_gfs.pl | AlbertEjiestein/Wind-Field-Cesium | 53fe12e6ee486056092a90e12b7b040756054355 | [
"MIT"
]
| 20 | 2020-03-15T14:16:42.000Z | 2022-03-27T04:44:21.000Z | dataDownload/get_gfs.pl | AlbertEjiestein/Wind-Field-Cesium | 53fe12e6ee486056092a90e12b7b040756054355 | [
"MIT"
]
| 10 | 2020-03-11T04:45:17.000Z | 2020-11-13T10:06:06.000Z | dataDownload/get_gfs.pl | AlbertEjiestein/Wind-Field-Cesium | 53fe12e6ee486056092a90e12b7b040756054355 | [
"MIT"
]
| 5 | 2020-03-10T16:21:00.000Z | 2021-07-10T06:58:54.000Z | #!/usr/bin/perl -w
# w. ebisuzaki CPC/NCEP/NWS/NOAA 10/2006
#
# simple script to download gfs files
# inspired by Dan Swank's get-narr.pl script
# this script uses the tecnique described in
# https://www.cpc.ncep.noaa.gov/products/wesley/fast_downloading_grib.html
#
# arguments: action YYYYMMDDHH HR0 HR1 DHR VAR_LIST LEV_LIST DIRECTORY
#
# action = inv (display inventory of 1st file)
# data (get data)
#
# HR0, HR1, DHR: forecast hour parameters
# do f_hour = HR0, HR1, DHR (fortran)
# for (f_hour = HR1; f_hour <= HR1; f_hour = f_hour + DHR) (C)
#
# VAR_LIST: list of variable separated by colons, blanks replaced by underscore
# ex. HGT:TMP:OZONE
# LEV_LIST: list of levesl separated by colons, blanks replaced by underscore
# ex. 500_mb:sfc
#
# DIRECTORY: name of the directory in which to place the files
#
# v1.0 10/2006 who is going to find the first bug?
# v1.0a 10/2006 better help page
# v2.0beta 10/2006 no need for egrep, get_inv.pl and get_grib.pl
# v2.0beta2 10/2006 no need for egrep, get_inv.pl and get_grib.pl
# v2.0beta3 10/2006 update messages, ignore case on matches
# v2.0 1/2009 J.M. Berg: no need for OUTDIR for inventory
# v2.0.1 1/2011 change URL to http://nomads.ncep.noaa.gov
# v2.0.2 10/2012 set check for bad year to > 2030
# v2.1 1/2015 NCO change gfs naming conventions: added $FHR3, updated URLs
# v2.1.2 5/2017 quote left brace, required by new versions of perl
# v2.1.3 12/2018 conversion to https
# v2.1.4 12/2018 changed URLs to https
# v2.1.5 6/2019 changed URLs, help page
#
#------------ user customization section -----------------------------------------
# location of curl
$curl="curl";
$inv='.idx';
$grb='';
# the URLs of the inventory and grib must be defined by $URL$inv and $URL$grb
# symbolic variables supported YYYY MM DD HH FHR (forecast hour), FHR3 (3 digit forecast hour)
#
# grib2 files from operational nomads server
#
# 1x1 degree GFS
$URL='https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.$YYYY$MM$DD/$HH/gfs.t${HH}z.pgrb2.1p00.f${FHR3}';
# 0.5x0.5 degree GFS
# $URL='https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.$YYYY$MM$DD/$HH/gfs.t${HH}z.pgrb2.0p50.f${FHR3}';
# 0.25 x 0.25 degree GFS
# $URL='https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.$YYYY$MM$DD/$HH/gfs.t${HH}z.pgrb2.0p25.f${FHR3}';
# if you want a 1/4 degree grid .. you should learn to use grib-filter
# grib-filter will give regional subset and save downloading time
# see www.cpc.ncep.noaa.gov/products/wesley/scripting_grib_filter.html
#
# grib2 files from www.ftp.ncep.noaa.gov (not operational)
# $URL='https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.$YYYY$MM$DD/$HH/gfs.t${HH}z.pgrb2.1p00.f${FHR3}';
#
# if insecure web server, $insecure='k';
$insecure='';
#$insecure='-k';
# the windows dos prompt often has problems with pipes, slower code code to avoid pipes
$windows='thankfully no';
# $windows='yes';
#------------- guts of script ---------------------------------------------------
$version="2.1.8";
if ($#ARGV != 7) {
print "get_gfs.pl $version get GFS forecasts from nomads.ncep.noaa.gov\n";
print "\nget_gfs.pl action YYYYMMDDHH HR0 HR1 DHR VAR_LIST LEV_LIST DIRECTORY\n\n";
print " action = inv (display inventory of first data file)\n";
print " data (get data)\n";
print " YYYYMMDDHH: starting time of the forecast in UTC (Coordinated Universal Time)\n";
print " HR0, HR1, DHR: forecast hour parameters\n";
print " fortran: do f_hour = HR0, HR1, DHR\n";
print " C: for (f_hour = HR0; f_hour <= HR1; f_hour += DHR)\n";
print " enumerate forecast hours from HR0 to HR1 by increments fo DHR\n";
print " VAR_LIST: list of variable separated by colons, blanks replaced by underscore or all\n";
print " ex. HGT:TMP:OZONE, all\n";
print " LEV_LIST: list of levels separated by colons, blanks replaced by underscore or all\n";
print " ex. 500_mb:sfc, all\n";
print " Note: APCP has both 0-M hour acc fcst and N-N hour acc fcst in the GFS,\n";
print " to get the 0-N hour acc fcst, set LEV_LIST to '0-'\n";
print " DIRECTORY: name of the directory in which to place the output files\n";
print " To see the available variables and levels in a particular file, display the inventory\n";
print "\n EXAMPLES\n\n Displaying an inventory\n\n";
print " get_gfs.pl inv 2018123100 0 0 0 all all .\n\n";
print " Downloading 500 hPa Height and Temp 0/3/6 hours forecasts to current directory\n\n";
print " get_gfs.pl data 2018123100 0 6 3 HGT:TMP 500_mb .\n\n";
print " Downloading APCP 6/18 hours forecasts to current directory\n\n";
print " get_gfs.pl data 2018123000 6 18 6 APCP all . *downloads 2 types of APCP\n";
print " get_gfs.pl data 2018123000 6 18 6 APCP 0- . *downloads 0-N hour APCP (1 or 2 time)\n\n";
print " Of course the date code will have to be current.\n";
print "\nDec 30, 2018: This script has the current https URLs for the 1.0, 0.5 and 0.25\n";
print " degree GFS forecasts. To change, to a different resolution GFS forecasts,\n";
print "select the desired \$URL definition.\n";
print " This program can be used for other forecasts on nomads.ncep.noaa.gov by\n";
print "changing the URL in this perl script. This program uses the partial\n";
print "downloading techinque.\n";
print " https://www.cpc.ncep.noaa.gov/products/wesley/fast_downloading_grib.html\n";
print "\nTo get user-defined regional subsets of the GFS forecast from the\n";
print "nomads.ncep.noaa.gov server, use the grib_filter facility. \n";
print "This is more useful for high-resolution grids.\n";
exit(8);
}
$action = $ARGV[0];
$time = $ARGV[1];
$hr0=$ARGV[2];
$hr1=$ARGV[3];
$dhr=$ARGV[4];
$VARS=$ARGV[5];
$LEVS=$ARGV[6];
$OUTDIR = $ARGV[7];
$YYYY = substr($time,0,4);
$MM = substr($time,4,2);
$DD = substr($time,6,2);
$HH = substr($time,8,2);
# check values
if ($action ne 'data' && $action ne 'inv') {
print "action must be inv or data, not $action\n";
exit(8);
}
if ($YYYY < 2006 || $YYYY > 2040) {
print "bad date (year) code $time\n";
exit(8);
}
if ($MM < 1 || $MM > 12) {
print "bad date (month) code $time\n";
exit(8);
}
if ($DD < 1 || $DD > 31) {
print "bad date (day) code $time\n";
exit(8);
}
if ($HH < 0 || $HH > 23) {
print "bad date (hour) code $time\n";
exit(8);
}
if ($hr0 == $hr1) {
$dhr = 3;
}
if ($dhr != 3 && $dhr != 6 && $dhr != 12 && $dhr != 24) {
print "dhr must be 3, 6, 12 or 24, not $dhr\n";
exit(8);
}
if ($hr0 > $hr1) {
print "hr0 needs to be <= hr1\n";
exit(8);
}
if ($dhr <= 0) {
print "dhr needs to be > 0\n";
exit(8);
}
if (! -d $OUTDIR && $action ne 'inv') {
print "Directory $OUTDIR does not exist\n";
exit(8);
}
$VARS =~ tr/:_/| /;
if( $VARS =~ m/ALL/ig ) { $VARS = "."; }
else { $VARS = ":($VARS):"; }
$LEVS =~ tr/:_/| /;
if( $LEVS =~ m/ALL/ig ) { $LEVS = "."; }
else { $LEVS = ":($LEVS)" ; }
$URL =~ s/\$YYYY/$YYYY/g;
$URL =~ s/\$\{YYYY\}/$YYYY/g;
$URL =~ s/\$MM/$MM/g;
$URL =~ s/\$\{MM\}/$MM/g;
$URL =~ s/\$DD/$DD/g;
$URL =~ s/\$\{DD\}/$DD/g;
$URL =~ s/\$HH/$HH/g;
$URL =~ s/\$\{HH\}/$HH/g;
$output = '';
$fhr=$hr0;
while ($fhr <= $hr1) {
if ($fhr <= 9) { $fhr="0$fhr"; }
$fhr3=$fhr;
if ($fhr <= 99) { $fhr3="0$fhr"; }
$url = $URL;
$url =~ s/\$FHR3/$fhr3/g;
$url =~ s/\$\{FHR3\}/$fhr3/g;
$url =~ s/\$FHR/$fhr/g;
$url =~ s/\$\{FHR\}/$fhr/g;
$file = $url;
$file =~ s/^.*\///;
#
# read the inventory
# $line[] = wgrib inventory, $start[] = start of record (column two of $line[])
#
if ($windows eq 'yes') {
$err = system("$curl $insecure -f -s $url$inv -o $OUTDIR/$file.tmp");
$err = $err >> 8;
if ($err) {
print STDERR "error code=$err, problem reading $url$inv\n";
sleep(10);
exit(8);
}
open (In, "$OUTDIR/$file.tmp");
}
else {
open (In, "$curl $insecure -f -s $url$inv |");
}
$n=0;
while (<In>) {
chomp;
$line[$n] = $_;
s/^[^:]*://;
s/:.*//;
$start[$n] = $_;
$n++;
}
close(In);
if ($n == 0) {
print STDERR "Problem reading file $url$inv\n";
sleep(10);
exit(8);
}
#
# find end of record: $last[]
#
$lastnum = $start[$n-1];
for ($i = 0; $i < $n; $i++) {
$num = $start[$i];
if ($num < $lastnum) {
$j = $i + 1;
while ($start[$j] == $num) { $j++; }
$last[$i] = $start[$j] - 1;
}
else {
$last[$i] = '';
}
}
if ($action eq 'inv') {
for ($i = 0; $i < $n; $i++) {
print "$line[$i]:range=$start[$i]-$last[$i]\n";
}
exit(0);
}
#
# make the range field for Curl
#
$range = '';
$lastfrom = '';
$lastto = '-100';
for ($i = 0; $i < $n; $i++) {
$_ = $line[$i];
if (/$LEVS/i && /$VARS/i) {
$from=$start[$i];
$to=$last[$i];
if ($lastto + 1 == $from) {
$lastto = $to;
}
elsif ($lastto ne $to) {
if ($lastfrom ne '') {
if ($range eq '') { $range = "$lastfrom-$lastto"; }
else { $range = "$range,$lastfrom-$lastto"; }
}
$lastfrom = $from;
$lastto = $to;
}
}
}
if ($lastfrom ne '') {
if ($range eq '') { $range="$lastfrom-$lastto"; }
else { $range="$range,$lastfrom-$lastto"; }
}
if ($range ne '') {
$err = system("$curl $insecure -f -v -s -r \"$range\" $url$grb -o $OUTDIR/$file.tmp");
$err = $err >> 8;
if ($err != 0) {
print STDERR "error in getting file $err $url$grb\n";
sleep(20);
exit $err;
}
rename "$OUTDIR/$file.tmp", "$OUTDIR/$file";
$output = "$output $OUTDIR/$file";
}
else {
print "no matches (no download) for $file\n";
}
$fhr += $dhr;
}
print "\n\nfinished download\n\n$output\n";
exit(0);
| 32.057143 | 117 | 0.569123 |
ed422261b21a36d17b8df5dd44a919386c5d1571 | 3,082 | pm | Perl | lib/Perl/Critic/Policy/Variables/ProhibitPerl4PackageNames.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
]
| null | null | null | lib/Perl/Critic/Policy/Variables/ProhibitPerl4PackageNames.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
]
| null | null | null | lib/Perl/Critic/Policy/Variables/ProhibitPerl4PackageNames.pm | atoomic/Perl-Critic | e3e5f8cf53517c9ba053585ae131216ae3a2de41 | [
"Artistic-1.0"
]
| null | null | null | package Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames;
use 5.006001;
use strict;
use warnings;
use Readonly;
use Perl::Critic::Utils qw{ :characters :severities :classification };
use base 'Perl::Critic::Policy';
our $VERSION = '1.134';
#-----------------------------------------------------------------------------
Readonly::Scalar my $EXPL =>
q{Use double colon (::) to separate package name components instead of single quotes (')};
#-----------------------------------------------------------------------------
sub supported_parameters { return () }
sub default_severity { return $SEVERITY_LOW }
sub default_themes { return qw(core maintenance certrec ) }
sub applies_to { return qw( PPI::Token::Word PPI::Token::Symbol ) }
#-----------------------------------------------------------------------------
sub violates {
my ( $self, $elem, undef ) = @_;
my $content = $elem->content();
if ( (index $content, $QUOTE) < 0 ) {
return;
}
if ( $content =~ m< \A [\$@%&*] ' \z >xms ) {
# We've found $POSTMATCH.
return;
}
if ( $elem->isa('PPI::Token::Word') && is_hash_key($elem) ) {
return;
}
return
$self->violation(
qq{"$content" uses the obsolete single quote package separator.},
$EXPL,
$elem
);
}
#-----------------------------------------------------------------------------
1;
__END__
#-----------------------------------------------------------------------------
=pod
=for stopwords perlmod
=head1 NAME
Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames - Use double colon (::) to separate package name components instead of single quotes (').
=head1 AFFILIATION
This Policy is part of the core L<Perl::Critic|Perl::Critic>
distribution.
=head1 DESCRIPTION
Perl 5 kept single quotes (C<'>) as package component separators in
order to remain backward compatible with prior C<perl>s, but advocated
using double colon (C<::>) instead. In the more than a decade since
Perl 5, double colons have been overwhelmingly adopted and most people
are not even aware that the single quote can be used in this manner.
So, unless you're trying to obfuscate your code, don't use them.
package Foo::Bar::Baz; #ok
package Foo'Bar'Baz; #not ok
=head1 CONFIGURATION
This Policy is not configurable except for the standard options.
=head1 SEE ALSO
L<perlmod|perlmod>
=head1 AUTHOR
Elliot Shank C<< <perl@galumph.com> >>
=head1 COPYRIGHT
Copyright (c) 2007-2014 Elliot Shank.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
| 25.471074 | 148 | 0.567813 |
73e72e61e73b19384c8cb12f01c769a440864e61 | 18,877 | pl | Perl | engines/asm/e_padlock-x86.pl | JemmyLoveJenny/openssl | f8922b5107d098c78f846c8c999f96111345de8d | [
"Apache-2.0"
]
| 27 | 2019-04-27T00:51:22.000Z | 2022-03-30T04:05:44.000Z | engines/asm/e_padlock-x86.pl | JemmyLoveJenny/openssl | f8922b5107d098c78f846c8c999f96111345de8d | [
"Apache-2.0"
]
| 9 | 2020-05-03T12:17:50.000Z | 2021-10-15T02:18:47.000Z | engines/asm/e_padlock-x86.pl | JemmyLoveJenny/openssl | f8922b5107d098c78f846c8c999f96111345de8d | [
"Apache-2.0"
]
| 1 | 2019-07-14T17:25:17.000Z | 2019-07-14T17:25:17.000Z | #! /usr/bin/env perl
# Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
# ====================================================================
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/.
# ====================================================================
# September 2011
#
# Assembler helpers for Padlock engine. Compared to original engine
# version relying on inline assembler and compiled with gcc 3.4.6 it
# was measured to provide ~100% improvement on misaligned data in ECB
# mode and ~75% in CBC mode. For aligned data improvement can be
# observed for short inputs only, e.g. 45% for 64-byte messages in
# ECB mode, 20% in CBC. Difference in performance for aligned vs.
# misaligned data depends on misalignment and is either ~1.8x or 2.9x.
# These are approximately same factors as for hardware support, so
# there is little reason to rely on the latter. On the contrary, it
# might actually hurt performance in mixture of aligned and misaligned
# buffers, because a) if you choose to flip 'align' flag in control
# word on per-buffer basis, then you'd have to reload key context,
# which incurs penalty; b) if you choose to set 'align' flag
# permanently, it limits performance even for aligned data to ~1/2.
# All above mentioned results were collected on 1.5GHz C7. Nano on the
# other hand handles unaligned data more gracefully. Depending on
# algorithm and how unaligned data is, hardware can be up to 70% more
# efficient than below software alignment procedures, nor does 'align'
# flag have affect on aligned performance [if has any meaning at all].
# Therefore suggestion is to unconditionally set 'align' flag on Nano
# for optimal performance.
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
push(@INC,"${dir}","${dir}../../crypto/perlasm");
require "x86asm.pl";
$output=pop;
open STDOUT,">$output";
&asm_init($ARGV[0]);
%PADLOCK_PREFETCH=(ecb=>128, cbc=>64); # prefetch errata
$PADLOCK_CHUNK=512; # Must be a power of 2 larger than 16
$ctx="edx";
$out="edi";
$inp="esi";
$len="ecx";
$chunk="ebx";
&function_begin_B("padlock_capability");
&push ("ebx");
&pushf ();
&pop ("eax");
&mov ("ecx","eax");
&xor ("eax",1<<21);
&push ("eax");
&popf ();
&pushf ();
&pop ("eax");
&xor ("ecx","eax");
&xor ("eax","eax");
&bt ("ecx",21);
&jnc (&label("noluck"));
&cpuid ();
&xor ("eax","eax");
&cmp ("ebx","0x".unpack("H*",'tneC'));
&jne (&label("zhaoxin"));
&cmp ("edx","0x".unpack("H*",'Hrua'));
&jne (&label("noluck"));
&cmp ("ecx","0x".unpack("H*",'slua'));
&jne (&label("noluck"));
&jmp (&label("zhaoxinEnd"));
&set_label("zhaoxin");
&cmp ("ebx","0x".unpack("H*",'hS '));
&jne (&label("noluck"));
&cmp ("edx","0x".unpack("H*",'hgna'));
&jne (&label("noluck"));
&cmp ("ecx","0x".unpack("H*",' ia'));
&jne (&label("noluck"));
&set_label("zhaoxinEnd");
&mov ("eax",0xC0000000);
&cpuid ();
&mov ("edx","eax");
&xor ("eax","eax");
&cmp ("edx",0xC0000001);
&jb (&label("noluck"));
&mov ("eax",1);
&cpuid ();
&or ("eax",0x0f);
&xor ("ebx","ebx");
&and ("eax",0x0fff);
&cmp ("eax",0x06ff); # check for Nano
&sete ("bl");
&mov ("eax",0xC0000001);
&push ("ebx");
&cpuid ();
&pop ("ebx");
&mov ("eax","edx");
&shl ("ebx",4); # bit#4 denotes Nano
&and ("eax",0xffffffef);
&or ("eax","ebx")
&set_label("noluck");
&pop ("ebx");
&ret ();
&function_end_B("padlock_capability")
&function_begin_B("padlock_key_bswap");
&mov ("edx",&wparam(0));
&mov ("ecx",&DWP(240,"edx"));
&set_label("bswap_loop");
&mov ("eax",&DWP(0,"edx"));
&bswap ("eax");
&mov (&DWP(0,"edx"),"eax");
&lea ("edx",&DWP(4,"edx"));
&sub ("ecx",1);
&jnz (&label("bswap_loop"));
&ret ();
&function_end_B("padlock_key_bswap");
# This is heuristic key context tracing. At first one
# believes that one should use atomic swap instructions,
# but it's not actually necessary. Point is that if
# padlock_saved_context was changed by another thread
# after we've read it and before we compare it with ctx,
# our key *shall* be reloaded upon thread context switch
# and we are therefore set in either case...
&static_label("padlock_saved_context");
&function_begin_B("padlock_verify_context");
&mov ($ctx,&wparam(0));
&lea ("eax",($::win32 or $::coff) ? &DWP(&label("padlock_saved_context")) :
&DWP(&label("padlock_saved_context")."-".&label("verify_pic_point")));
&pushf ();
&call ("_padlock_verify_ctx");
&set_label("verify_pic_point");
&lea ("esp",&DWP(4,"esp"));
&ret ();
&function_end_B("padlock_verify_context");
&function_begin_B("_padlock_verify_ctx");
&add ("eax",&DWP(0,"esp")) if(!($::win32 or $::coff));# &padlock_saved_context
&bt (&DWP(4,"esp"),30); # eflags
&jnc (&label("verified"));
&cmp ($ctx,&DWP(0,"eax"));
&je (&label("verified"));
&pushf ();
&popf ();
&set_label("verified");
&mov (&DWP(0,"eax"),$ctx);
&ret ();
&function_end_B("_padlock_verify_ctx");
&function_begin_B("padlock_reload_key");
&pushf ();
&popf ();
&ret ();
&function_end_B("padlock_reload_key");
&function_begin_B("padlock_aes_block");
&push ("edi");
&push ("esi");
&push ("ebx");
&mov ($out,&wparam(0)); # must be 16-byte aligned
&mov ($inp,&wparam(1)); # must be 16-byte aligned
&mov ($ctx,&wparam(2));
&mov ($len,1);
&lea ("ebx",&DWP(32,$ctx)); # key
&lea ($ctx,&DWP(16,$ctx)); # control word
&data_byte(0xf3,0x0f,0xa7,0xc8); # rep xcryptecb
&pop ("ebx");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_aes_block");
sub generate_mode {
my ($mode,$opcode) = @_;
# int padlock_$mode_encrypt(void *out, const void *inp,
# struct padlock_cipher_data *ctx, size_t len);
&function_begin("padlock_${mode}_encrypt");
&mov ($out,&wparam(0));
&mov ($inp,&wparam(1));
&mov ($ctx,&wparam(2));
&mov ($len,&wparam(3));
&test ($ctx,15);
&jnz (&label("${mode}_abort"));
&test ($len,15);
&jnz (&label("${mode}_abort"));
&lea ("eax",($::win32 or $::coff) ? &DWP(&label("padlock_saved_context")) :
&DWP(&label("padlock_saved_context")."-".&label("${mode}_pic_point")));
&pushf ();
&cld ();
&call ("_padlock_verify_ctx");
&set_label("${mode}_pic_point");
&lea ($ctx,&DWP(16,$ctx)); # control word
&xor ("eax","eax");
if ($mode eq "ctr32") {
&movq ("mm0",&QWP(-16,$ctx)); # load [upper part of] counter
} else {
&xor ("ebx","ebx");
&test (&DWP(0,$ctx),1<<5); # align bit in control word
&jnz (&label("${mode}_aligned"));
&test ($out,0x0f);
&setz ("al"); # !out_misaligned
&test ($inp,0x0f);
&setz ("bl"); # !inp_misaligned
&test ("eax","ebx");
&jnz (&label("${mode}_aligned"));
&neg ("eax");
}
&mov ($chunk,$PADLOCK_CHUNK);
¬ ("eax"); # out_misaligned?-1:0
&lea ("ebp",&DWP(-24,"esp"));
&cmp ($len,$chunk);
&cmovc ($chunk,$len); # chunk=len>PADLOCK_CHUNK?PADLOCK_CHUNK:len
&and ("eax",$chunk); # out_misaligned?chunk:0
&mov ($chunk,$len);
&neg ("eax");
&and ($chunk,$PADLOCK_CHUNK-1); # chunk=len%PADLOCK_CHUNK
&lea ("esp",&DWP(0,"eax","ebp")); # alloca
&mov ("eax",$PADLOCK_CHUNK);
&cmovz ($chunk,"eax"); # chunk=chunk?:PADLOCK_CHUNK
&mov ("eax","ebp");
&and ("ebp",-16);
&and ("esp",-16);
&mov (&DWP(16,"ebp"),"eax");
if ($PADLOCK_PREFETCH{$mode}) {
&cmp ($len,$chunk);
&ja (&label("${mode}_loop"));
&mov ("eax",$inp); # check if prefetch crosses page
&cmp ("ebp","esp");
&cmove ("eax",$out);
&add ("eax",$len);
&neg ("eax");
&and ("eax",0xfff); # distance to page boundary
&cmp ("eax",$PADLOCK_PREFETCH{$mode});
&mov ("eax",-$PADLOCK_PREFETCH{$mode});
&cmovae ("eax",$chunk); # mask=distance<prefetch?-prefetch:-1
&and ($chunk,"eax");
&jz (&label("${mode}_unaligned_tail"));
}
&jmp (&label("${mode}_loop"));
&set_label("${mode}_loop",16);
&mov (&DWP(0,"ebp"),$out); # save parameters
&mov (&DWP(4,"ebp"),$inp);
&mov (&DWP(8,"ebp"),$len);
&mov ($len,$chunk);
&mov (&DWP(12,"ebp"),$chunk); # chunk
if ($mode eq "ctr32") {
&mov ("ecx",&DWP(-4,$ctx));
&xor ($out,$out);
&mov ("eax",&DWP(-8,$ctx)); # borrow $len
&set_label("${mode}_prepare");
&mov (&DWP(12,"esp",$out),"ecx");
&bswap ("ecx");
&movq (&QWP(0,"esp",$out),"mm0");
&inc ("ecx");
&mov (&DWP(8,"esp",$out),"eax");
&bswap ("ecx");
&lea ($out,&DWP(16,$out));
&cmp ($out,$chunk);
&jb (&label("${mode}_prepare"));
&mov (&DWP(-4,$ctx),"ecx");
&lea ($inp,&DWP(0,"esp"));
&lea ($out,&DWP(0,"esp"));
&mov ($len,$chunk);
} else {
&test ($out,0x0f); # out_misaligned
&cmovnz ($out,"esp");
&test ($inp,0x0f); # inp_misaligned
&jz (&label("${mode}_inp_aligned"));
&shr ($len,2);
&data_byte(0xf3,0xa5); # rep movsl
&sub ($out,$chunk);
&mov ($len,$chunk);
&mov ($inp,$out);
&set_label("${mode}_inp_aligned");
}
&lea ("eax",&DWP(-16,$ctx)); # ivp
&lea ("ebx",&DWP(16,$ctx)); # key
&shr ($len,4); # len/=AES_BLOCK_SIZE
&data_byte(0xf3,0x0f,0xa7,$opcode); # rep xcrypt*
if ($mode !~ /ecb|ctr/) {
&movaps ("xmm0",&QWP(0,"eax"));
&movaps (&QWP(-16,$ctx),"xmm0"); # copy [or refresh] iv
}
&mov ($out,&DWP(0,"ebp")); # restore parameters
&mov ($chunk,&DWP(12,"ebp"));
if ($mode eq "ctr32") {
&mov ($inp,&DWP(4,"ebp"));
&xor ($len,$len);
&set_label("${mode}_xor");
&movups ("xmm1",&QWP(0,$inp,$len));
&lea ($len,&DWP(16,$len));
&pxor ("xmm1",&QWP(-16,"esp",$len));
&movups (&QWP(-16,$out,$len),"xmm1");
&cmp ($len,$chunk);
&jb (&label("${mode}_xor"));
} else {
&test ($out,0x0f);
&jz (&label("${mode}_out_aligned"));
&mov ($len,$chunk);
&lea ($inp,&DWP(0,"esp"));
&shr ($len,2);
&data_byte(0xf3,0xa5); # rep movsl
&sub ($out,$chunk);
&set_label("${mode}_out_aligned");
&mov ($inp,&DWP(4,"ebp"));
}
&mov ($len,&DWP(8,"ebp"));
&add ($out,$chunk);
&add ($inp,$chunk);
&sub ($len,$chunk);
&mov ($chunk,$PADLOCK_CHUNK);
if (!$PADLOCK_PREFETCH{$mode}) {
&jnz (&label("${mode}_loop"));
} else {
&jz (&label("${mode}_break"));
&cmp ($len,$chunk);
&jae (&label("${mode}_loop"));
&set_label("${mode}_unaligned_tail");
&xor ("eax","eax");
&cmp ("esp","ebp");
&cmove ("eax",$len);
&sub ("esp","eax"); # alloca
&mov ("eax", $out); # save parameters
&mov ($chunk,$len);
&shr ($len,2);
&lea ($out,&DWP(0,"esp"));
&data_byte(0xf3,0xa5); # rep movsl
&mov ($inp,"esp");
&mov ($out,"eax"); # restore parameters
&mov ($len,$chunk);
&jmp (&label("${mode}_loop"));
&set_label("${mode}_break",16);
}
if ($mode ne "ctr32") {
&cmp ("esp","ebp");
&je (&label("${mode}_done"));
}
&pxor ("xmm0","xmm0");
&lea ("eax",&DWP(0,"esp"));
&set_label("${mode}_bzero");
&movaps (&QWP(0,"eax"),"xmm0");
&lea ("eax",&DWP(16,"eax"));
&cmp ("ebp","eax");
&ja (&label("${mode}_bzero"));
&set_label("${mode}_done");
&mov ("ebp",&DWP(16,"ebp"));
&lea ("esp",&DWP(24,"ebp"));
if ($mode ne "ctr32") {
&jmp (&label("${mode}_exit"));
&set_label("${mode}_aligned",16);
if ($PADLOCK_PREFETCH{$mode}) {
&lea ("ebp",&DWP(0,$inp,$len));
&neg ("ebp");
&and ("ebp",0xfff); # distance to page boundary
&xor ("eax","eax");
&cmp ("ebp",$PADLOCK_PREFETCH{$mode});
&mov ("ebp",$PADLOCK_PREFETCH{$mode}-1);
&cmovae ("ebp","eax");
&and ("ebp",$len); # remainder
&sub ($len,"ebp");
&jz (&label("${mode}_aligned_tail"));
}
&lea ("eax",&DWP(-16,$ctx)); # ivp
&lea ("ebx",&DWP(16,$ctx)); # key
&shr ($len,4); # len/=AES_BLOCK_SIZE
&data_byte(0xf3,0x0f,0xa7,$opcode); # rep xcrypt*
if ($mode ne "ecb") {
&movaps ("xmm0",&QWP(0,"eax"));
&movaps (&QWP(-16,$ctx),"xmm0"); # copy [or refresh] iv
}
if ($PADLOCK_PREFETCH{$mode}) {
&test ("ebp","ebp");
&jz (&label("${mode}_exit"));
&set_label("${mode}_aligned_tail");
&mov ($len,"ebp");
&lea ("ebp",&DWP(-24,"esp"));
&mov ("esp","ebp");
&mov ("eax","ebp");
&sub ("esp",$len);
&and ("ebp",-16);
&and ("esp",-16);
&mov (&DWP(16,"ebp"),"eax");
&mov ("eax", $out); # save parameters
&mov ($chunk,$len);
&shr ($len,2);
&lea ($out,&DWP(0,"esp"));
&data_byte(0xf3,0xa5); # rep movsl
&mov ($inp,"esp");
&mov ($out,"eax"); # restore parameters
&mov ($len,$chunk);
&jmp (&label("${mode}_loop"));
}
&set_label("${mode}_exit"); }
&mov ("eax",1);
&lea ("esp",&DWP(4,"esp")); # popf
&emms () if ($mode eq "ctr32");
&set_label("${mode}_abort");
&function_end("padlock_${mode}_encrypt");
}
&generate_mode("ecb",0xc8);
&generate_mode("cbc",0xd0);
&generate_mode("cfb",0xe0);
&generate_mode("ofb",0xe8);
&generate_mode("ctr32",0xc8); # yes, it implements own CTR with ECB opcode,
# because hardware CTR was introduced later
# and even has errata on certain C7 stepping.
# own implementation *always* works, though
# ~15% slower than dedicated hardware...
&function_begin_B("padlock_xstore");
&push ("edi");
&mov ("edi",&wparam(0));
&mov ("edx",&wparam(1));
&data_byte(0x0f,0xa7,0xc0); # xstore
&pop ("edi");
&ret ();
&function_end_B("padlock_xstore");
&function_begin_B("_win32_segv_handler");
&mov ("eax",1); # ExceptionContinueSearch
&mov ("edx",&wparam(0)); # *ExceptionRecord
&mov ("ecx",&wparam(2)); # *ContextRecord
&cmp (&DWP(0,"edx"),0xC0000005) # ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION
&jne (&label("ret"));
&add (&DWP(184,"ecx"),4); # skip over rep sha*
&mov ("eax",0); # ExceptionContinueExecution
&set_label("ret");
&ret ();
&function_end_B("_win32_segv_handler");
&safeseh("_win32_segv_handler") if ($::win32);
&function_begin_B("padlock_sha1_oneshot");
&push ("edi");
&push ("esi");
&xor ("eax","eax");
&mov ("edi",&wparam(0));
&mov ("esi",&wparam(1));
&mov ("ecx",&wparam(2));
if ($::win32 or $::coff) {
&push (&::islabel("_win32_segv_handler"));
&data_byte(0x64,0xff,0x30); # push %fs:(%eax)
&data_byte(0x64,0x89,0x20); # mov %esp,%fs:(%eax)
}
&mov ("edx","esp"); # put aside %esp
&add ("esp",-128); # 32 is enough but spec says 128
&movups ("xmm0",&QWP(0,"edi")); # copy-in context
&and ("esp",-16);
&mov ("eax",&DWP(16,"edi"));
&movaps (&QWP(0,"esp"),"xmm0");
&mov ("edi","esp");
&mov (&DWP(16,"esp"),"eax");
&xor ("eax","eax");
&data_byte(0xf3,0x0f,0xa6,0xc8); # rep xsha1
&movaps ("xmm0",&QWP(0,"esp"));
&mov ("eax",&DWP(16,"esp"));
&mov ("esp","edx"); # restore %esp
if ($::win32 or $::coff) {
&data_byte(0x64,0x8f,0x05,0,0,0,0); # pop %fs:0
&lea ("esp",&DWP(4,"esp"));
}
&mov ("edi",&wparam(0));
&movups (&QWP(0,"edi"),"xmm0"); # copy-out context
&mov (&DWP(16,"edi"),"eax");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_sha1_oneshot");
&function_begin_B("padlock_sha1_blocks");
&push ("edi");
&push ("esi");
&mov ("edi",&wparam(0));
&mov ("esi",&wparam(1));
&mov ("edx","esp"); # put aside %esp
&mov ("ecx",&wparam(2));
&add ("esp",-128);
&movups ("xmm0",&QWP(0,"edi")); # copy-in context
&and ("esp",-16);
&mov ("eax",&DWP(16,"edi"));
&movaps (&QWP(0,"esp"),"xmm0");
&mov ("edi","esp");
&mov (&DWP(16,"esp"),"eax");
&mov ("eax",-1);
&data_byte(0xf3,0x0f,0xa6,0xc8); # rep xsha1
&movaps ("xmm0",&QWP(0,"esp"));
&mov ("eax",&DWP(16,"esp"));
&mov ("esp","edx"); # restore %esp
&mov ("edi",&wparam(0));
&movups (&QWP(0,"edi"),"xmm0"); # copy-out context
&mov (&DWP(16,"edi"),"eax");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_sha1_blocks");
&function_begin_B("padlock_sha256_oneshot");
&push ("edi");
&push ("esi");
&xor ("eax","eax");
&mov ("edi",&wparam(0));
&mov ("esi",&wparam(1));
&mov ("ecx",&wparam(2));
if ($::win32 or $::coff) {
&push (&::islabel("_win32_segv_handler"));
&data_byte(0x64,0xff,0x30); # push %fs:(%eax)
&data_byte(0x64,0x89,0x20); # mov %esp,%fs:(%eax)
}
&mov ("edx","esp"); # put aside %esp
&add ("esp",-128);
&movups ("xmm0",&QWP(0,"edi")); # copy-in context
&and ("esp",-16);
&movups ("xmm1",&QWP(16,"edi"));
&movaps (&QWP(0,"esp"),"xmm0");
&mov ("edi","esp");
&movaps (&QWP(16,"esp"),"xmm1");
&xor ("eax","eax");
&data_byte(0xf3,0x0f,0xa6,0xd0); # rep xsha256
&movaps ("xmm0",&QWP(0,"esp"));
&movaps ("xmm1",&QWP(16,"esp"));
&mov ("esp","edx"); # restore %esp
if ($::win32 or $::coff) {
&data_byte(0x64,0x8f,0x05,0,0,0,0); # pop %fs:0
&lea ("esp",&DWP(4,"esp"));
}
&mov ("edi",&wparam(0));
&movups (&QWP(0,"edi"),"xmm0"); # copy-out context
&movups (&QWP(16,"edi"),"xmm1");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_sha256_oneshot");
&function_begin_B("padlock_sha256_blocks");
&push ("edi");
&push ("esi");
&mov ("edi",&wparam(0));
&mov ("esi",&wparam(1));
&mov ("ecx",&wparam(2));
&mov ("edx","esp"); # put aside %esp
&add ("esp",-128);
&movups ("xmm0",&QWP(0,"edi")); # copy-in context
&and ("esp",-16);
&movups ("xmm1",&QWP(16,"edi"));
&movaps (&QWP(0,"esp"),"xmm0");
&mov ("edi","esp");
&movaps (&QWP(16,"esp"),"xmm1");
&mov ("eax",-1);
&data_byte(0xf3,0x0f,0xa6,0xd0); # rep xsha256
&movaps ("xmm0",&QWP(0,"esp"));
&movaps ("xmm1",&QWP(16,"esp"));
&mov ("esp","edx"); # restore %esp
&mov ("edi",&wparam(0));
&movups (&QWP(0,"edi"),"xmm0"); # copy-out context
&movups (&QWP(16,"edi"),"xmm1");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_sha256_blocks");
&function_begin_B("padlock_sha512_blocks");
&push ("edi");
&push ("esi");
&mov ("edi",&wparam(0));
&mov ("esi",&wparam(1));
&mov ("ecx",&wparam(2));
&mov ("edx","esp"); # put aside %esp
&add ("esp",-128);
&movups ("xmm0",&QWP(0,"edi")); # copy-in context
&and ("esp",-16);
&movups ("xmm1",&QWP(16,"edi"));
&movups ("xmm2",&QWP(32,"edi"));
&movups ("xmm3",&QWP(48,"edi"));
&movaps (&QWP(0,"esp"),"xmm0");
&mov ("edi","esp");
&movaps (&QWP(16,"esp"),"xmm1");
&movaps (&QWP(32,"esp"),"xmm2");
&movaps (&QWP(48,"esp"),"xmm3");
&data_byte(0xf3,0x0f,0xa6,0xe0); # rep xsha512
&movaps ("xmm0",&QWP(0,"esp"));
&movaps ("xmm1",&QWP(16,"esp"));
&movaps ("xmm2",&QWP(32,"esp"));
&movaps ("xmm3",&QWP(48,"esp"));
&mov ("esp","edx"); # restore %esp
&mov ("edi",&wparam(0));
&movups (&QWP(0,"edi"),"xmm0"); # copy-out context
&movups (&QWP(16,"edi"),"xmm1");
&movups (&QWP(32,"edi"),"xmm2");
&movups (&QWP(48,"edi"),"xmm3");
&pop ("esi");
&pop ("edi");
&ret ();
&function_end_B("padlock_sha512_blocks");
&asciz ("VIA Padlock x86 module, CRYPTOGAMS by <appro\@openssl.org>");
&align (16);
&dataseg();
# Essentially this variable belongs in thread local storage.
# Having this variable global on the other hand can only cause
# few bogus key reloads [if any at all on signle-CPU system],
# so we accept the penalty...
&set_label("padlock_saved_context",4);
&data_word(0);
&asm_finish();
close STDOUT;
| 30.058917 | 92 | 0.586375 |
ed361cb51446ea6e46dc60d917fbf199fba48407 | 1,774 | t | Perl | t/trace1.t | cboleary/perl-tk | 88dd549c36e1e615837c3dc185f553b5a9533792 | [
"TCL"
]
| 28 | 2015-01-02T00:31:12.000Z | 2021-12-21T09:03:05.000Z | t/trace1.t | cboleary/perl-tk | 88dd549c36e1e615837c3dc185f553b5a9533792 | [
"TCL"
]
| 44 | 2015-01-07T22:25:25.000Z | 2022-03-28T13:34:44.000Z | t/trace1.t | cboleary/perl-tk | 88dd549c36e1e615837c3dc185f553b5a9533792 | [
"TCL"
]
| 18 | 2015-01-02T00:32:47.000Z | 2022-03-24T12:57:40.000Z | BEGIN { $|=1; $^W=1; }
use Test;
use Tk;
use Tk::Trace;
use strict;
plan test => 18;
my $mw = MainWindow->new;
$mw->geometry("+10+10");
my $v = 0;
my $e = $mw->Entry(-textvariable => \$v)->pack;
my ($r, $w, $u ) = (0, 0, 0 );
$e->traceVariable( \$v, 'rwu', [ \&trace_v, $e, 123 ] );
foreach my $k ( 1 .. 5 ) {
$mw->after(100);
$v++;
$mw->update;
}
$e->traceVdelete( \$v );
ok( $v, 5, 'traced variable != 5' );
ok( $r, 5, 'read trace not called 5 times' );
ok( $w, 6, 'write trace not called 5 times' );
ok( $u, 1, 'undef trace not called once' );
my $read_only = $v;
$e->traceVariable( \$v, 'w', sub { $read_only } );
$v = 777;
$e->traceVdelete( \$v );
ok( $v, 5, 'read-only variable failed != 5' );
ok( $v, 5, 'final value != 5' );
if ($Tk::VERSION < 804.027501) {
warn "# This test segfaults in Tk804.027\n";
ok(1);
} else {
# Similar code is part of the CPAN module Tk::LCD
my $c = $mw->Canvas->pack;
my $foo;
my $vref = \$foo;
my $st = [sub {
my ($index, $new_val, $op, $lcd) = @_;
return unless $op eq 'w';
# Problem: $c is not alive (or half-alive only) here
# and internal data structures seem not to be valid
$c->move("foo", 20,30);
$new_val;
}, $c];
$c->traceVariable($vref, 'w' => $st);
$c->{watch} = $vref;
$c->createPolygon(10,10,20,10,20,20,10,20,-tags=>"foo");
$c->OnDestroy( [sub {$_[0]->traceVdelete($_[0]->{watch})}, $c] );
$c->update;
$c->destroy;
ok(1);
}
sub trace_v {
my( $index, $value, $op, $ent, $num ) = @_;
if ( $op eq 'r' ) {
ok( $e, $ent, 'arguments out of order' );
$r++;
} elsif ( $op eq 'w' ) {
ok( $num, 123, '$num != 123' );
$w++;
} elsif ( $op eq 'u' ) {
$u++;
}
$value;
}
| 21.901235 | 69 | 0.501127 |
ed582199b99cfa9896145ba3aa557f27273b66c9 | 3,292 | pm | Perl | tests/publiccloud/azure_cli.pm | jlausuch/os-autoinst-distri-opensuse | 78ad74b2d9c292d60660096bdad1fcee93dfe3e3 | [
"FSFAP"
]
| 2 | 2017-11-29T19:04:30.000Z | 2017-11-29T19:04:31.000Z | tests/publiccloud/azure_cli.pm | jlausuch/os-autoinst-distri-opensuse | 78ad74b2d9c292d60660096bdad1fcee93dfe3e3 | [
"FSFAP"
]
| 1 | 2018-12-10T21:10:46.000Z | 2018-12-10T21:10:46.000Z | tests/publiccloud/azure_cli.pm | jlausuch/os-autoinst-distri-opensuse | 78ad74b2d9c292d60660096bdad1fcee93dfe3e3 | [
"FSFAP"
]
| null | null | null | # SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# Summary: Create VM in Azure using azure-cli binary
# Maintainer: qa-c team <qa-c@suse.de>
use Mojo::Base 'publiccloud::basetest';
use registration;
use testapi;
use mmapi;
use utils;
use publiccloud::utils "select_host_console";
sub run {
my ($self, $args) = @_;
$self->select_serial_terminal;
my $job_id = get_current_job_id();
# If 'az' is preinstalled, we test that version
if (script_run("which az") != 0) {
add_suseconnect_product 'sle-module-public-cloud';
zypper_call('in azure-cli jq python3-susepubliccloudinfo');
}
record_soft_failure('bsc#1192671') if (script_run('az --version', die => 0) != 0);
record_soft_failure('bsc#1192671') if (script_run('az --help', die => 0) != 0);
set_var 'PUBLIC_CLOUD_PROVIDER' => 'AZURE';
my $provider = $self->provider_factory();
sleep 600;
my $resource_group = "openqa-cli-test-rg-$job_id";
my $machine_name = "openqa-cli-test-vm-$job_id";
my $openqa_ttl = get_var('MAX_JOB_TIME', 7200) + get_var('PUBLIC_CLOUD_TTL_OFFSET', 300);
my $created_by = get_var('PUBLIC_CLOUD_RESOURCE_NAME', 'openqa-vm');
my $tags = "openqa-cli-test-tag=$job_id openqa_created_by=$created_by openqa_ttl=$openqa_ttl";
# Configure default location and create Resource group
assert_script_run("az configure --defaults location=southeastasia");
assert_script_run("az group create -n $resource_group --tags '$tags'");
# Pint - command line tool to query pint.suse.com to get the current image name
my $image_name = script_output("pint microsoft images --active --json | jq -r '.images[] | select( (.urn | contains(\"sles-15-sp3:gen2\")) and (.state == \"active\") and (.environment == \"PublicAzure\")).urn'");
record_info("PINT", "Pint query: " . $image_name);
# VM creation
my $vm_create = "az vm create --resource-group $resource_group --name $machine_name --public-ip-sku Standard --tags '$tags'";
$vm_create .= " --image $image_name --size Standard_B1ms --admin-username azureuser --ssh-key-values ~/.ssh/id_rsa.pub";
assert_script_run($vm_create, 600);
assert_script_run("az vm get-instance-view -g $resource_group -n $machine_name");
assert_script_run("az vm list-ip-addresses -g $resource_group -n $machine_name");
# Check that the machine is reachable via ssh
my $ip_address = script_output("az vm list-ip-addresses -g $resource_group -n $machine_name --query '[].virtualMachine.network.publicIpAddresses[0].ipAddress' --output tsv", 90);
script_retry("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no azureuser\@$ip_address hostnamectl", 90, delay => 15, retry => 12);
}
sub cleanup {
my $job_id = get_current_job_id();
my $resource_group = "openqa-cli-test-rg-$job_id";
my $machine_name = "openqa-cli-test-vm-$job_id";
assert_script_run("az group delete --resource-group $resource_group --yes", 180);
}
sub test_flags {
return {fatal => 0, milestone => 0, always_rollback => 1};
}
1;
| 42.205128 | 216 | 0.697145 |
Subsets and Splits