code
stringlengths
2
1.05M
repo_name
stringlengths
5
101
path
stringlengths
4
991
language
stringclasses
3 values
license
stringclasses
5 values
size
int64
2
1.05M
:- use_package(assertions). :- comment(filetype, part). :- comment(title,"PART III - ISO-Prolog library (iso)"). :- comment(author, "The CLIP Group"). :- comment(module,"@include{IsoProlog.lpdoc}"). main.
leuschel/ecce
www/CiaoDE/ciao/doc/common/IsoProlog.pl
Perl
apache-2.0
210
# # $Id: Tcp.pm,v eff9afda3723 2015/01/04 12:34:23 gomor $ # # client::tcp Brik # package Metabrik::Client::Tcp; use strict; use warnings; use base qw(Metabrik); sub brik_properties { return { revision => '$Revision: eff9afda3723 $', tags => [ qw(unstable client tcp socket netcat) ], attributes => { host => [ qw(host) ], port => [ qw(port) ], protocol => [ qw(tcp) ], eof => [ qw(0|1) ], size => [ qw(size) ], rtimeout => [ qw(read_timeout) ], use_ipv6 => [ qw(0|1) ], _socket => [ qw(INTERNAL) ], _select => [ qw(INTERNAL) ], }, attributes_default => { port => 'tcp', eof => 0, size => 1024, use_ipv6 => 0, }, commands => { connect => [ ], read => [ qw(size) ], readall => [ ], write => [ qw($data) ], disconnect => [ ], is_connected => [ ], chomp => [ qw($data) ], }, require_modules => { 'IO::Socket::INET' => [ ], 'IO::Socket::INET6' => [ ], 'IO::Select' => [ ], }, }; } sub brik_use_properties { my $self = shift; return { attributes_default => { rtimeout => $self->global->rtimeout, }, }; } sub connect { my $self = shift; my ($host, $port) = @_; $host ||= $self->host; $port ||= $self->port; if (! defined($host)) { return $self->log->error($self->brik_help_set('host')); } if (! defined($port)) { return $self->log->error($self->brik_help_set('port')); } my $context = $self->context; my $mod = $self->use_ipv6 ? 'IO::Socket::INET6' : 'IO::Socket::INET'; my $socket = $mod->new( PeerHost => $host, PeerPort => $port, Proto => $self->protocol, Timeout => $self->rtimeout, ReuseAddr => 1, ); if (! defined($socket)) { return $self->log->error("connect: failed connecting to target [$host:$port]: $!"); } $socket->blocking(0); $socket->autoflush(1); my $select = IO::Select->new or return $self->log->error("connect: IO::Select failed: $!"); $select->add($socket); $self->_socket($socket); $self->_select($select); $self->log->verbose("connect: successfully connected to [$host:$port]"); my $conn = { ip => $socket->peerhost, port => $socket->peerport, my_ip => $socket->sockhost, my_port => $socket->sockport, }; return $conn; } sub disconnect { my $self = shift; if ($self->_socket) { $self->_socket->close; $self->_socket(undef); $self->_select(undef); $self->log->verbose("disconnect: successfully disconnected"); } else { $self->log->verbose("disconnect: nothing to disconnect"); } return 1; } sub is_connected { my $self = shift; if ($self->_socket && $self->_socket->connected) { return 1; } return 0; } sub write { my $self = shift; my ($data) = @_; if (! defined($data)) { return $self->log->error($self->brik_help_run('write')); } if (! $self->is_connected) { return $self->log->error("write: not connected"); } my $socket = $self->_socket; my $ret = $socket->syswrite($data, length($data)); if (! $ret) { return $self->log->error("write: syswrite failed with error [$!]"); } return $ret; } sub read { my $self = shift; my ($size) = @_; $size ||= $self->size; if (! $self->is_connected) { return $self->log->error("read: not connected"); } my $socket = $self->_socket; my $select = $self->_select; my $read = 0; my $eof = 0; my $data = ''; while (my @read = $select->can_read($self->rtimeout)) { my $ret = $socket->sysread($data, $size); if (! defined($ret)) { return $self->log->error("read: sysread failed with error [$!]"); } elsif ($ret == 0) { # EOF $self->eof(1); $eof++; last; } elsif ($ret > 0) { # Read stuff $read++; last; } else { return $self->log->fatal("read: What?!?"); } } if (! $eof && ! $read) { $self->log->debug("read: timeout occured"); return 0; } return $data; } sub chomp { my $self = shift; my ($data) = @_; $data =~ s/\r\n$//; $data =~ s/\r$//; $data =~ s/\n$//; $data =~ s/\r/\\x0d/g; $data =~ s/\n/\\x0a/g; return $data; } 1; __END__ =head1 NAME Metabrik::Client::Tcp - client::tcp Brik =head1 COPYRIGHT AND LICENSE Copyright (c) 2014-2015, Patrice E<lt>GomoRE<gt> Auffret You may distribute this module under the terms of The BSD 3-Clause License. See LICENSE file in the source distribution archive. =head1 AUTHOR Patrice E<lt>GomoRE<gt> Auffret =cut
gitpan/Metabrik-Repository
lib/Metabrik/Client/Tcp.pm
Perl
bsd-3-clause
4,824
/* Part of XPCE --- The SWI-Prolog GUI toolkit Author: Jan Wielemaker and Anjo Anjewierden E-mail: jan@swi.psy.uva.nl WWW: http://www.swi.psy.uva.nl/projects/xpce/ Copyright (c) 2000-2011, University of 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(doc_load, []). :- use_module(library(pce)). /******************************* * PATHS * *******************************/ :- multifile user:file_search_path/2. user:file_search_path(doc, pce('prolog/lib/doc')). /******************************* * OBLIGATORY PARTS * *******************************/ :- use_module(doc(util)). % generic stuff :- use_module(doc(objects)). % global reusable objects :- use_module(doc(emit)). % basic conversion library /******************************* * CLASSES * *******************************/ :- pce_autoload(doc_table, doc(table)). :- pce_autoload(doc_mode, doc(layout)). :- pce_autoload(pbox, doc(layout)). :- pce_autoload(bullet_list, doc(layout)). :- pce_autoload(enum_list, doc(layout)). :- pce_autoload(definition_list, doc(layout)). :- pce_autoload(button_box, doc(layout)). :- pce_autoload(anchor_box, doc(layout)). :- pce_autoload(doc_window, doc(window)). :- pce_autoload(doc_browser, doc(browser)).
TeamSPoon/logicmoo_workspace
docker/rootfs/usr/local/lib/swipl/xpce/prolog/lib/doc/load.pl
Perl
mit
2,884
package Games::Lacuna::Client::Buildings::OperaHouse; use 5.0080000; use strict; use warnings; use Carp 'croak'; use Games::Lacuna::Client; use Games::Lacuna::Client::Buildings; our @ISA = qw(Games::Lacuna::Client::Buildings); __PACKAGE__->init(); 1; __END__ =head1 NAME Games::Lacuna::Client::Buildings::Warehouse - OperaHouse =head1 SYNOPSIS use Games::Lacuna::Client; =head1 DESCRIPTION =head1 AUTHOR Carl Franks, E<lt>cfranks@cpan.orgE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2011 by Carl Franks This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =cut
RedOrion/Vasari-TLEUtil
lib/Games/Lacuna/Client/Buildings/OperaHouse.pm
Perl
mit
737
package Venn::CLI::Role::API; =head1 NAME Venn::CLI::Role::API - Role to support API submission operations =head1 DESCRIPTION This class has been extracted from Venn::CLI::Command to allow creation of a standalone client library for Venn without duplicating code. =head1 AUTHOR Venn Engineering Josh Arenberg, Norbert Csongradi, Ryan Kupfer, Hai-Long Nguyen =head1 LICENSE Copyright 2013,2014,2015 Morgan Stanley 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 use v5.14; use Mouse::Role; use Mouse::Util::TypeConstraints; use MouseX::Getopt qw( NoGetopt ); use Venn::CLI::Types qw( NoEmptyStr ); use YAML::XS; use Data::Dumper; has 'debug' => ( is => 'ro', isa => 'Bool', metaclass => 'NoGetopt', documentation => 'Display diagnostic information', ); has 'ua' => ( is => 'rw', isa => 'LWP::UserAgent', metaclass => 'NoGetopt', lazy => 1, builder => '_build_ua', documentation => 'LWP::UserAgent instance for API interaction', ); =head1 COMMON ATTRIBUTES These attributes options are common to (and inherited by) all subcommands =cut has 'api_environment' => ( is => 'rw', isa => NoEmptyStr, metaclass => 'NoGetopt', builder => '_build_api_environment', documentation => 'Environment of execution (derived from, and not to be confused with, global option <env>)', ); has 'api_broker' => ( is => 'rw', isa => NoEmptyStr, metaclass => 'NoGetopt', lazy => 1, # needed because other attributes are used in the creation of this attribute builder => '_build_api_broker', documentation => 'Base path for the Venn REST API', ); has 'rest_timeout' => ( is => 'rw', isa => 'Int', metaclass => 'NoGetopt', documentation => 'Timeout for the REST connection', ); has 'api_version' => ( is => 'rw', isa => NoEmptyStr, metaclass => 'NoGetopt', default => 'v1', documentation => 'Stores the version of the REST API', ); has 'last_response' => ( is => 'rw', metaclass => 'NoGetopt', documentation => 'UA response object', ); =head2 _build_ua() Builds the UserAgent object =cut sub _build_ua { my ( $self ) = @_; my $ua = LWP::UserAgent->new(); $ua->timeout($self->rest_timeout); $ua->env_proxy; return $ua; } =head2 _build_api_environment() Builds the environment/scope of execution based on CWD and is overrideable with user args. =cut sub _build_api_environment { my ( $self ) = @_; # this allows us to create env mappings. e.g. if you only have # dev and prod, you could map qa -> dev here. my $final_environment; my $env = $self->can('app') ? ($self->app->global_options->env // '') : ''; given ($env) { when (/^(?:dev|qa|uat|prod)$/) { # environment must have been valid if ($self->app->global_options->env eq 'uat') { # overridden for the time being that we do not have qa infra $self->debug_message("UAT is currently mapped to QA, changing environment..."); $final_environment = 'qa'; } else { $final_environment = $self->app->global_options->env; } } default { $self->debug_message("Defaulting to dev based on execution path"); $final_environment = 'dev'; } } return $final_environment; } =head2 _build_api_broker() Generates the URI for the API endpoint =cut sub _build_api_broker { my ( $self ) = @_; # TODO: move to config return sprintf("%s/api", $ENV{VENN_SERVER}) if $ENV{VENN_SERVER}; my ($host, $port, $prefix); my $virtual = $0 =~ /venn_farm/ ? 'venn-farm' : 'virtual'; given ($self->api_environment // '') { when (/prod/) { $host = $ENV{VENN_HOST} // "$virtual.webfarm.ms.com"; $port = $ENV{VENN_PORT} // 80; $prefix = $ENV{VENN_PREFIX} // $self->webapp_prefix; } when (/qa/) { $host = $ENV{VENN_HOST} // "$virtual.webfarm-qa.ms.com"; $port = $ENV{VENN_PORT} // 80; $prefix = $ENV{VENN_PREFIX} // $self->webapp_prefix; } default { # Default to dev conditions (always override-able by the the env variables) $host = $ENV{VENN_HOST} // qx( /bin/hostname --fqdn ) // 'localhost'; ## no critic (ProhibitBacktickOperators) chomp $host; $port = $ENV{VENN_PORT} // $self->_find_dev_port // 3000; $prefix = $ENV{VENN_PREFIX} // undef; } } my $broker = "http://$host"; $broker .= ":$port" if $port; $broker .= "/$prefix" if $prefix; $self->debug_message("Using %s broker: %s", $self->api_environment, $broker); return $broker . '/api'; } =head2 _find_dev_port Finds the port the dev server is running on. =cut sub _find_dev_port { my ($self) = @_; my $ps = qx( ps uxww ); ## no critic (ProhibitBacktickOperators) if ($ps =~ /venn_server\.pl.*-p (\d+)/) { return $1 if $1 >= 1024 && $1 <= 65535; } return; } =head2 submit_to_api($path, $http_method, $payload) Submits a payload to the API path using the given http_method. This will set the Content-Type HTTP header, requesting a certain output format (ascii, json, yaml, etc.) =cut sub submit_to_api { my ($self, $path, $http_method, $payload) = @_; my $content_type = 'application/json'; # Ensure that we don't pass undefined arguments as 'undef' to the API my $simplified_payload_json; if ($payload) { my %simplified_payload = map { defined $payload->{$_} ? ( $_ => $payload->{$_} ) : () } keys %$payload; $simplified_payload_json = $self->hash2json(\%simplified_payload); $self->debug_message("JSON-Encoded Payload: %s", $simplified_payload_json); } $self->verbose_message("%s => %s", $http_method, $path); exit 0 if $self->can('app') && $self->app->global_options->dryrun; # Don't execute the request if we're doing a dryrun # API does not support POST requests (PUT is used for both insert and update) my $response; given ($http_method) { when (/^GET$/i) { $response = $self->ua->get($path, 'Content-Type' => $content_type); } when (/^POST$/i) { $response = $self->ua->post($path, 'Content-Type' => $content_type, 'Content' => $simplified_payload_json); } when (/^PUT$/i) { $response = $self->ua->put($path, 'Content-Type' => $content_type, 'Content' => $simplified_payload_json); } when (/^DELETE$/i) { $response = $self->ua->delete($path, 'Content-Type' => $content_type); } default { die "Invalid http request type passed to submit_to_api()"; } } $self->debug_message("Code: %s\nContent: %s", $response->code, $response->decoded_content); return $self->last_response($response); } =head2 parse_response($response) Parses the response from the server. We always expect JSON back now. =cut sub parse_response { my ($self, $response) = @_; if (blessed $response && $response->isa('HTTP::Response')) { $response = $response->decoded_content; } my $parsed_data = eval { JSON::XS::decode_json($response) }; if ($@) { $self->debug_message("Unexpected response: %s", $response); die "Unable to parse response from the server $@\n"; } return $parsed_data; } =head2 print_response($response, $dataroot) Outputs the response from the API based on the requested output formatting. Optionally, takes a second argument (string) that is is the root of the data being extracted for printing. Requested format: $self->output_format =cut sub print_response { my ($self, $response, $dataroot) = @_; # The request has failed for some reason, but we're expecting a failure payload if (! $response->is_success) { warn $response->status_line . "\n" if $self->debug; } my $raw_content = $response->decoded_content; die "No failure data payload was returned from the API\n" unless $raw_content; $self->debug_message("Results: %s", Dumper($raw_content)); my $data = $self->parse_response($response); given ($self->output_format // '') { when (/^yaml$/) { print YAML::XS::Dump($data); } when (/^json$/) { print JSON::XS::encode_json($data); } when (/^dumper$/) { say Dumper($data); } default { die 'Invalid output format specified'; } } return; } =head2 hash2json(\%hash) Converts a hash to json. =cut sub hash2json { my ($self, $hash) = @_; my $coder = JSON::XS->new->ascii->allow_nonref; my $encoded_data = $coder->encode($hash); return $encoded_data; } =head2 debug_message($message_format, @args) Print a debug message. =cut sub debug_message { my ($self, $message_format, @args) = @_; say sprintf("+++ " . $message_format, @args) if $self->debug; return; } =head2 verbose_message($message_format, @args) Print a verbose message. =cut sub verbose_message { my ($self, $message_format, @args) = @_; say STDERR sprintf($message_format, @args); # if $self->verbose; return; } =head2 error_message($message_format, @args) Prints an error message to STDERR =cut sub error_message { my ($self, $message_format, @args) = @_; say STDERR sprintf($message_format, @args); return; } 1;
hlnguyen21/venn-cli
lib/Venn/CLI/Role/API.pm
Perl
apache-2.0
10,281
package Paws::DMS::DeleteReplicationTaskResponse; use Moose; has ReplicationTask => (is => 'ro', isa => 'Paws::DMS::ReplicationTask'); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::DMS::DeleteReplicationTaskResponse =head1 ATTRIBUTES =head2 ReplicationTask => L<Paws::DMS::ReplicationTask> The deleted replication task. =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/DMS/DeleteReplicationTaskResponse.pm
Perl
apache-2.0
429
# # Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package apps::jive::sql::mode::etljobstatus; use base qw(centreon::plugins::mode); use strict; use warnings; my $thresholds = { status => [ ['^1$', 'OK'], ['^3$', 'CRITICAL'], ], }; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "retention:s" => { name => 'retention', default => 1 }, "threshold-overload:s@" => { name => 'threshold_overload' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); $self->{overload_th} = {}; foreach my $val (@{$self->{option_results}->{threshold_overload}}) { if ($val !~ /^(.*?),(.*)$/) { $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } my ($section, $status, $filter) = ('status', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); $self->{output}->option_exit(); } $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } } sub run { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); my $retention = $self->{option_results}->{retention}; # CURRENT_TIMESTAMP should be compatible with the jive databases: Oracle, MS SQL, MySQL, Postgres. # INTERVAL also. my $query = q{SELECT etl_job_id, state, start_ts, end_ts FROM jivedw_etl_job WHERE start_ts > CURRENT_TIMESTAMP - INTERVAL '} . $retention . q{' DAY}; $self->{sql}->query(query => $query); my $job_etl_problems = {}; my $total_problems = 0; while ((my $row = $self->{sql}->fetchrow_hashref())) { my $exit = $self->get_severity(section => 'status', value => $row->{state}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(long_msg => sprintf("%s: job '%i' state is %s [start_time: %s]", $exit, $row->{etl_job_id}, $row->{state}, $row->{start_ts})); $job_etl_problems->{$exit} = 0 if (!defined($job_etl_problems->{$exit})); $job_etl_problems->{$exit}++; $total_problems++; } } $self->{output}->output_add(severity => 'OK', short_msg => 'no job etl problems'); foreach (keys %{$job_etl_problems}) { $self->{output}->output_add(severity => $_, short_msg => sprintf("job etl had %i problems during the last %i days", $job_etl_problems->{$_}, $self->{option_results}->{retention})); } $self->{output}->perfdata_add(label => 'job_etl_problems', value => $total_problems, min => 0); $self->{output}->display(); $self->{output}->exit(); } sub get_severity { my ($self, %options) = @_; my $status = 'UNKNOWN'; # default if (defined($self->{overload_th}->{$options{section}})) { foreach (@{$self->{overload_th}->{$options{section}}}) { if ($options{value} =~ /$_->{filter}/i) { $status = $_->{status}; return $status; } } } foreach (@{$thresholds->{$options{section}}}) { if ($options{value} =~ /$$_[0]/i) { $status = $$_[1]; return $status; } } return $status; } 1; __END__ =head1 MODE Check jive ETL job status. Please use with dyn-mode option. =over 8 =item B<--retention> Retention in days (default : 1). =item B<--threshold-overload> Set to overload default threshold values (syntax: status,regexp) It used before default thresholds (order stays). Example: --threshold-overload='CRITICAL,^(?!(1)$)' =back =cut
bcournaud/centreon-plugins
apps/jive/sql/mode/etljobstatus.pm
Perl
apache-2.0
5,119
# # Copyright 2016 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 storage::dell::equallogic::snmp::mode::components::health; use strict; use warnings; my %map_health_status = ( 0 => 'unknown', 1 => 'normal', 2 => 'warning', 3 => 'critical', ); # In MIB 'eqlcontroller.mib' my $mapping = { eqlMemberHealthStatus => { oid => '.1.3.6.1.4.1.12740.2.1.5.1.1', map => \%map_health_status }, }; my $oid_eqlMemberHealthStatus = '.1.3.6.1.4.1.12740.2.1.5.1.1'; sub load { my (%options) = @_; push @{$options{request}}, { oid => $oid_eqlMemberHealthStatus }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking health"); $self->{components}->{health} = {name => 'health', total => 0, skip => 0}; return if ($self->check_exclude(section => 'health')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthStatus}})) { next if ($oid !~ /^$mapping->{eqlMemberHealthStatus}->{oid}\.(\d+\.\d+)$/); my ($member_instance) = ($1); my $member_name = $self->get_member_name(instance => $member_instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthStatus}, instance => $member_instance); next if ($self->check_exclude(section => 'health', instance => $member_instance)); $self->{components}->{health}->{total}++; $self->{output}->output_add(long_msg => sprintf("Health '%s' status is %s [instance: %s].", $member_name, $result->{eqlMemberHealthStatus}, $member_name )); my $exit = $self->get_severity(section => 'health', value => $result->{eqlMemberHealthStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Health '%s' status is %s", $member_name, $result->{eqlMemberHealthStatus})); } } } 1;
bcournaud/centreon-plugins
storage/dell/equallogic/snmp/mode/components/health.pm
Perl
apache-2.0
2,897
package VSAP::Server::Modules::vsap::sys::ssh; use 5.008004; use strict; use warnings; use VSAP::Server::Modules::vsap::backup; our $VERSION = '0.01'; our $SSHD_CONFIG = "/etc/ssh/sshd_config"; ############################################################################## # supporting functions ############################################################################## sub _disable_protocol_1 { REWT: { local $> = $) = 0; ## regain privileges for a moment # read it in open(CONFIG, $SSHD_CONFIG); my @config = <CONFIG>; close(CONFIG); # back it up VSAP::Server::Modules::vsap::backup::backup_system_file($SSHD_CONFIG); # write it out open(NEWCFG, ">/tmp/sshd_config.$$") || return; for (my $i=0; $i<=$#config; $i++) { if ($config[$i] =~ /^(#?)Protocol/) { $config[$i] =~ s/^\#(Protocol\s+2\s)/$1/; $config[$i] =~ s/^(Protocol\s+2,1\s)/\#$1/; } print NEWCFG $config[$i] || return; } close(NEWCFG); # rename rename("/tmp/sshd_config.$$", $SSHD_CONFIG); } } sub _enable_protocol_1 { REWT: { local $> = $) = 0; ## regain privileges for a moment # read it in open(CONFIG, $SSHD_CONFIG); my @config = <CONFIG>; close(CONFIG); # back it up VSAP::Server::Modules::vsap::backup::backup_system_file($SSHD_CONFIG); # write it out open(NEWCFG, ">/tmp/sshd_config.$$") || return; for (my $i=0; $i<=$#config; $i++) { if ($config[$i] =~ /^(#?)Protocol/) { $config[$i] =~ s/^(Protocol\s+2\s)/\#$1/; $config[$i] =~ s/^\#(Protocol\s+2,1\s)/$1/; } print NEWCFG $config[$i] || return; } close(NEWCFG); # rename rename("/tmp/sshd_config.$$", $SSHD_CONFIG); } } sub _is_enabled_protocol_1 { my $enabled = 0; REWT: { local $> = $) = 0; ## regain privileges for a moment # read it in open(CONFIG, $SSHD_CONFIG); my @config = <CONFIG>; close(CONFIG); $enabled = grep(/^Protocol.*1/i, @config); } return($enabled) } sub _num_connections { my @netstat = `netstat -tunv`; my @ssh_connections = grep(/:22\s/, @netstat); my $num_connections = $#ssh_connections + 1; return($num_connections); } ############################################################################## package VSAP::Server::Modules::vsap::sys::ssh::audit; sub handler { my $vsap = shift; my $xmlobj = shift; my $dom = $vsap->dom; my $status = "ok"; # disable Protocol version 1 (if no connections found) my $nc = VSAP::Server::Modules::vsap::sys::ssh::_num_connections(); VSAP::Server::Modules::vsap::sys::ssh::_disable_protocol_1 unless ($nc); my $root_node = $dom->createElement('vsap'); $root_node->setAttribute(type => 'sys:ssh:audit'); $root_node->appendTextChild(status => $status); $dom->documentElement->appendChild($root_node); return; } ############################################################################## package VSAP::Server::Modules::vsap::sys::ssh::init; sub handler { my $vsap = shift; my $xmlobj = shift; my $dom = $vsap->dom; my $status = "ok"; # enable Protocol version 1 VSAP::Server::Modules::vsap::sys::ssh::_enable_protocol_1(); my $root_node = $dom->createElement('vsap'); $root_node->setAttribute(type => 'sys:ssh:init'); $root_node->appendTextChild(status => $status); $dom->documentElement->appendChild($root_node); return; } ############################################################################## package VSAP::Server::Modules::vsap::sys::ssh::status; sub handler { my $vsap = shift; my $xmlobj = shift; my $dom = $vsap->dom; # is SSH Protocol version 1 enabled? my $ssh1_status; $ssh1_status = VSAP::Server::Modules::vsap::sys::ssh::_is_enabled_protocol_1(); $ssh1_status = $ssh1_status ? "enabled" : "disabled"; my $root_node = $dom->createElement('vsap'); $root_node->setAttribute(type => 'sys:ssh:status'); $root_node->appendTextChild(ssh1_status => $ssh1_status); $dom->documentElement->appendChild($root_node); return; } ############################################################################## 1; __END__ =head1 NAME VSAP::Server::Modules::vsap::sys::ssh - VSAP module to support CPX embedded java terminal access =head1 SYNOPSIS use VSAP::Server::Modules::vsap::sys::ssh; =head1 DESCRIPTION This module is used for the benefit of CPX embedded java terminal access. =head1 SEE ALSO sshd_config(5) =head1 AUTHOR Rus Berrett, E<lt>rus@surfutah.com<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2011 by MYNAMESERVER, LLC No part of this module may be duplicated in any form without written consent of the copyright holder. =cut
opencpx/opencpx
modules/VSAP-Server-Modules-vsap-sys-ssh/lib/VSAP/Server/Modules/vsap/sys/ssh.pm
Perl
apache-2.0
4,968
package Google::Ads::AdWords::v201409::ConversionOptimizerEligibility::RejectionReason; use strict; use warnings; sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201409'}; # derivation by restriction use base qw( SOAP::WSDL::XSD::Typelib::Builtin::string); 1; __END__ =pod =head1 NAME =head1 DESCRIPTION Perl data type class for the XML Schema defined simpleType ConversionOptimizerEligibility.RejectionReason from the namespace https://adwords.google.com/api/adwords/cm/v201409. This clase is derived from SOAP::WSDL::XSD::Typelib::Builtin::string . SOAP::WSDL's schema implementation does not validate data, so you can use it exactly like it's base type. # Description of restrictions not implemented yet. =head1 METHODS =head2 new Constructor. =head2 get_value / set_value Getter and setter for the simpleType's value. =head1 OVERLOADING Depending on the simple type's base type, the following operations are overloaded Stringification Numerification Boolification Check L<SOAP::WSDL::XSD::Typelib::Builtin> for more information. =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201409/ConversionOptimizerEligibility/RejectionReason.pm
Perl
apache-2.0
1,131
package # Date::Manip::TZ::patara00; # Copyright (c) 2008-2014 Sullivan Beck. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # This file was automatically generated. Any changes to this file will # be lost the next time 'tzdata' is run. # Generated on: Fri Nov 21 10:41:41 EST 2014 # Data version: tzdata2014j # Code version: tzcode2014j # This module contains data from the zoneinfo time zone database. The original # data was obtained from the URL: # ftp://ftp.iana.org/tz use strict; use warnings; require 5.010000; our (%Dates,%LastRule); END { undef %Dates; undef %LastRule; } our ($VERSION); $VERSION='6.48'; END { undef $VERSION; } %Dates = ( 1 => [ [ [1,1,2,0,0,0],[1,1,2,11,32,4],'+11:32:04',[11,32,4], 'LMT',0,[1900,12,31,12,27,55],[1900,12,31,23,59,59], '0001010200:00:00','0001010211:32:04','1900123112:27:55','1900123123:59:59' ], ], 1900 => [ [ [1900,12,31,12,27,56],[1901,1,1,0,27,56],'+12:00:00',[12,0,0], 'GILT',0,[9999,12,31,0,0,0],[9999,12,31,12,0,0], '1900123112:27:56','1901010100:27:56','9999123100:00:00','9999123112:00:00' ], ], ); %LastRule = ( ); 1;
nriley/Pester
Source/Manip/TZ/patara00.pm
Perl
bsd-2-clause
1,290
# # Copyright 2017 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 os::solaris::local::mode::analyzedisks; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "remote" => { name => 'remote' }, "ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 }, "sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'format' }, "command-path:s" => { name => 'command_path', default => '/usr/sbin' }, "command-options:s" => { name => 'command_options', default => '2>&1 << EOF 0 quit EOF' }, "warning:s" => { name => 'warning', }, "critical:s" => { name => 'critical', }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; my $stdout = centreon::plugins::misc::execute(output => $self->{output}, options => $self->{option_results}, sudo => $self->{option_results}->{sudo}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}); my $long_msg = $stdout; $long_msg =~ s/\|/~/mg; $self->{output}->output_add(long_msg => $long_msg); my $num_errors = 0; my $disks_name = ''; foreach (split /\n/, $stdout) { if (/\s+([^\s]+)\s+<(drive type unknown|drive not available)/i ) { $num_errors++; $disks_name .= ' [' . $1 . ']'; } } my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); if ($num_errors > 0) { $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("Disks$disks_name are on errors.")); } else { $self->{output}->output_add(severity => 'OK', short_msg => "No problems on disks."); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check disk status (need 'format' command). =over 8 =item B<--warning> Threshold warning. =item B<--critical> Threshold critical. =item B<--remote> Execute command remotely in 'ssh'. =item B<--hostname> Hostname to query (need --remote). =item B<--ssh-option> Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52"). =item B<--ssh-path> Specify ssh command path (default: none) =item B<--ssh-command> Specify ssh command (default: 'ssh'). Useful to use 'plink'. =item B<--timeout> Timeout in seconds for the command (Default: 30). =item B<--sudo> Use 'sudo' to execute the command. =item B<--command> Command to get information (Default: 'format'). Can be changed if you have output in a file. =item B<--command-path> Command path (Default: '/usr/sbin'). =item B<--command-options> Command options (Default: '2>&1 << EOF 0 quit EOF'). =back =cut
nichols-356/centreon-plugins
os/solaris/local/mode/analyzedisks.pm
Perl
apache-2.0
5,581
#! /usr/bin/perl # This script extracts trajectory data from EFPMD output use 5.008; use strict; use warnings; die "usage: trajectory.pl <input>\n" if scalar(@ARGV) != 1; open(FH, "<", $ARGV[0]) || die "$!"; while (<FH>) { next unless /GEOMETRY/; <FH>; my @lines; while (<FH>) { last if /^$/; push @lines, $_; } print scalar(@lines), "\n"; print "xyz", "\n"; foreach (@lines) { $_ =~ s/A[0-9]+([a-zA-Z]+)[0-9]*/$1/; print $_; } }
libefp/libefp
efpmd/tools/trajectory.pl
Perl
bsd-2-clause
456
#!/usr/bin/perl open FIN, $ARGV[0] or die "Unable to open $ARGV[0]! $!\n"; my $in_func = 0; my $leaf = 1; my $buffer = []; while (<FIN>) { if (/#Function (\w+)/) { $in_func = 1; push @$buffer, $_; } elsif (/#EndFunction/) { push @$buffer, $_; if ( $leaf ) { print @$buffer; print "\n"; } $in_func = 0; $leaf = 1; $buffer = (); } elsif ( $in_func and $leaf ) { my ($ts, $op, @args) = split / /; $leaf = 0 if ( $op !~ /^(?:GateName|PrepZ|MeasX|MeasZ|CNOT|H|S|Sdag|T|Tdag|X|Y|Z|Fredkin)$/ ); push @$buffer, $_ if ( $leaf ); } }
epiqc/ScaffCC
scripts/leaves.pl
Perl
bsd-2-clause
668
package Perun::beans::AttributeRights; use strict; use warnings; use Perun::Common; sub new { bless({}); } sub fromHash { return Perun::Common::fromHash(@_); } sub TO_JSON { my $self = shift; my $attributeId; if (defined($self->{_attributeId})) { $attributeId = $self->{_attributeId} * 1; } else { $attributeId = 0; } my $role; if (defined($self->{_role})) { $role = "$self->{_role}"; } else { $role = undef; } my @rights; if (defined($self->{_rights})) { @rights = @{$self->{_rights}}; } else { @rights = undef; } return { attributeId => $attributeId, role => $role, rights => \@rights }; } sub getAttributeId { my $self = shift; return $self->{_attributeId}; } sub setAttributeId { my $self = shift; $self->{_attributeId} = shift; return; } sub getRole { my $self = shift; return $self->{_role}; } sub setRole { my $self = shift; $self->{_role} = shift; return; } sub getRights { my $self = shift; return @{$self->{_rights}}; } sub setRights { my $self = shift; $self->{_rights} = shift; return; } 1;
stavamichal/perun
perun-cli/Perun/beans/AttributeRights.pm
Perl
bsd-2-clause
1,067
#!/usr/local/bin/perl # A bit of an evil hack but it post processes the file ../MINFO which # is generated by `make files` in the top directory. # This script outputs one mega makefile that has no shell stuff or any # funny stuff # $INSTALLTOP="/usr/local/ssl"; $OPTIONS=""; $ssl_version=""; $banner="\t\@echo Building OpenSSL"; my $no_static_engine = 0; my $engines = ""; local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic local $zlib_lib = ""; local $fips_canister_path = ""; my $fips_premain_dso_exe_path = ""; my $fips_premain_c_path = ""; my $fips_sha1_exe_path = ""; local $fipscanisterbuild = 0; local $fipsdso = 0; my $fipslibdir = ""; my $baseaddr = ""; my $ex_l_libs = ""; open(IN,"<Makefile") || die "unable to open Makefile!\n"; while(<IN>) { $ssl_version=$1 if (/^VERSION=(.*)$/); $OPTIONS=$1 if (/^OPTIONS=(.*)$/); $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); } close(IN); die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; $infile="MINFO"; %ops=( "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", "VC-WIN64A", "Microsoft C/C++ - Win64/x64", "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", "Mingw32", "GNU C++ - Windows NT or 9x", "Mingw32-files", "Create files with DOS copy ...", "BC-NT", "Borland C++ 4.5 - Windows NT", "linux-elf","Linux elf", "ultrix-mips","DEC mips ultrix", "FreeBSD","FreeBSD distribution", "OS2-EMX", "EMX GCC OS/2", "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets", "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", "default","cc under unix", ); $platform=""; my $xcflags=""; foreach (@ARGV) { if (!&read_options && !defined($ops{$_})) { print STDERR "unknown option - $_\n"; print STDERR "usage: perl mk1mf.pl [options] [system]\n"; print STDERR "\nwhere [system] can be one of the following\n"; foreach $i (sort keys %ops) { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } print STDERR <<"EOF"; and [options] can be one of no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest no-ripemd no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher no-bf no-cast no-aes no-camellia no-seed no-rsa no-dsa no-dh - Skip this public key cipher no-ssl2 no-ssl3 - Skip this version of SSL just-ssl - remove all non-ssl keys/digest no-asm - No x86 asm no-krb5 - No KRB5 no-ec - No EC no-ecdsa - No ECDSA no-ecdh - No ECDH no-engine - No engine no-hw - No hw nasm - Use NASM for x86 asm nw-nasm - Use NASM x86 asm for NetWare nw-mwasm - Use Metrowerks x86 asm for NetWare gaswin - Use GNU as with Mingw32 no-socks - No socket code no-err - No error strings dll/shlib - Build shared libraries (MS) debug - Debug build profile - Profiling build gcc - Use Gcc (unix) Values that can be set TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler -L<ex_lib_path> -l<ex_lib> - extra library flags (unix) -<ex_cc_flags> - extra 'cc' flags, added (MS), or replace (unix) EOF exit(1); } $platform=$_; } foreach (grep(!/^$/, split(/ /, $OPTIONS))) { print STDERR "unknown option - $_\n" if !&read_options; } $no_static_engine = 0 if (!$shlib); $no_mdc2=1 if ($no_des); $no_ssl3=1 if ($no_md5 || $no_sha); $no_ssl3=1 if ($no_rsa && $no_dh); $no_ssl2=1 if ($no_md5); $no_ssl2=1 if ($no_rsa); $out_def="out"; $inc_def="outinc"; $tmp_def="tmp"; $perl="perl" unless defined $perl; $mkdir="-mkdir" unless defined $mkdir; ($ssl,$crypto)=("ssl","crypto"); $ranlib="echo ranlib"; $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; # $bin_dir.=$o causes a core dump on my sparc :-( $NT=0; push(@INC,"util/pl","pl"); if (($platform =~ /VC-(.+)/)) { $FLAVOR=$1; $NT = 1 if $1 eq "NT"; require 'VC-32.pl'; } elsif ($platform eq "Mingw32") { require 'Mingw32.pl'; } elsif ($platform eq "Mingw32-files") { require 'Mingw32f.pl'; } elsif ($platform eq "BC-NT") { $bc=1; require 'BC-32.pl'; } elsif ($platform eq "FreeBSD") { require 'unix.pl'; $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; } elsif ($platform eq "linux-elf") { require "unix.pl"; require "linux.pl"; $unix=1; } elsif ($platform eq "ultrix-mips") { require "unix.pl"; require "ultrix.pl"; $unix=1; } elsif ($platform eq "OS2-EMX") { $wc=1; require 'OS2-EMX.pl'; } elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock")) { $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock"); require 'netware.pl'; } else { require "unix.pl"; $unix=1; $cflags.=' -DTERMIO'; } $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); $cflags= "$xcflags$cflags" if $xcflags ne ""; $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; $cflags.=" -DOPENSSL_NO_AES" if $no_aes; $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; $cflags.=" -DOPENSSL_NO_SEED" if $no_seed; $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; $cflags.=" -DOPENSSL_NO_MD2" if $no_md2; $cflags.=" -DOPENSSL_NO_MD4" if $no_md4; $cflags.=" -DOPENSSL_NO_MD5" if $no_md5; $cflags.=" -DOPENSSL_NO_SHA" if $no_sha; $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; $cflags.=" -DOPENSSL_NO_BF" if $no_bf; $cflags.=" -DOPENSSL_NO_CAST" if $no_cast; $cflags.=" -DOPENSSL_NO_DES" if $no_des; $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; $cflags.=" -DOPENSSL_NO_DH" if $no_dh; $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; $cflags.=" -DOPENSSL_NO_CMS" if $no_cms; $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake; $cflags.=" -DOPENSSL_NO_CAPIENG" if $no_capieng; $cflags.=" -DOPENSSL_NO_ERR" if $no_err; $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; $cflags.=" -DOPENSSL_NO_EC" if $no_ec; $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; $cflags.=" -DOPENSSL_NO_HW" if $no_hw; $cflags.=" -DOPENSSL_FIPS" if $fips; $cflags.= " -DZLIB" if $zlib_opt; $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; if ($no_static_engine) { $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; } else { $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; } #$cflags.=" -DRSAref" if $rsaref ne ""; ## if ($unix) ## { $cflags="$c_flags" if ($c_flags ne ""); } ##else { $cflags="$c_flags$cflags" if ($c_flags ne ""); } $ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO", "FIPS" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); if ($msdos) { $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; $banner.="\t\@echo documentation for details.\n"; } # have to do this to allow $(CC) under unix $link="$bin_dir$link" if ($link !~ /^\$/); $INSTALLTOP =~ s|/|$o|g; ############################################# # We parse in input file and 'store' info for later printing. open(IN,"<$infile") || die "unable to open $infile:$!\n"; $_=<IN>; for (;;) { chop; ($key,$val)=/^([^=]+)=(.*)/; if ($key eq "RELATIVE_DIRECTORY") { if ($lib ne "") { if ($fips && $dir =~ /^fips/) { $uc = "FIPS"; } else { $uc=$lib; $uc =~ s/^lib(.*)\.a/$1/; $uc =~ tr/a-z/A-Z/; } if (($uc ne "FIPS") || $fipscanisterbuild) { $lib_nam{$uc}=$uc; $lib_obj{$uc}.=$libobj." "; } } last if ($val eq "FINISHED"); $lib=""; $libobj=""; $dir=$val; } if ($key eq "KRB5_INCLUDES") { $cflags .= " $val";} if ($key eq "ZLIB_INCLUDE") { $cflags .= " $val" if $val ne "";} if ($key eq "LIBZLIB") { $zlib_lib = "$val" if $val ne "";} if ($key eq "LIBKRB5") { $ex_libs .= " $val" if $val ne "";} if ($key eq "TEST") { $test.=&var_add($dir,$val, 0); } if (($key eq "PROGS") || ($key eq "E_OBJ")) { $e_exe.=&var_add($dir,$val, 0); } if ($key eq "LIB") { $lib=$val; $lib =~ s/^.*\/([^\/]+)$/$1/; } if ($key eq "EXHEADER") { $exheader.=&var_add($dir,$val, 1); } if ($key eq "HEADER") { $header.=&var_add($dir,$val, 1); } if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) { $libobj=&var_add($dir,$val, 0); } if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) { $engines.=$val } if ($key eq "FIPS_EX_OBJ") { $fips_ex_obj=&var_add("crypto",$val,0); } if ($key eq "FIPSLIBDIR") { $fipslibdir=$val; $fipslibdir =~ s/\/$//; $fipslibdir =~ s/\//$o/g; } if ($key eq "BASEADDR") { $baseaddr=$val;} if (!($_=<IN>)) { $_="RELATIVE_DIRECTORY=FINISHED\n"; } } close(IN); if ($fips) { foreach (split " ", $fips_ex_obj) { $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/); } $fips_exclude_obj{"cpu_win32"} = 1; $fips_exclude_obj{"bn_asm"} = 1; $fips_exclude_obj{"des_enc"} = 1; $fips_exclude_obj{"fcrypt_b"} = 1; $fips_exclude_obj{"aes_core"} = 1; $fips_exclude_obj{"aes_cbc"} = 1; my @ltmp = split " ", $lib_obj{"CRYPTO"}; $lib_obj{"CRYPTO"} = ""; foreach(@ltmp) { if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1}) { if ($fipscanisterbuild) { $lib_obj{"FIPS"} .= "$_ "; } } else { $lib_obj{"CRYPTO"} .= "$_ "; } } } if ($fipscanisterbuild) { $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq ""; $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c"; } else { if ($fips_canister_path eq "") { $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib"; } if ($fips_premain_c_path eq "") { $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c"; } } if ($fips) { if ($fips_sha1_exe_path eq "") { $fips_sha1_exe_path = "\$(BIN_D)${o}fips_standalone_sha1$exep"; } } else { $fips_sha1_exe_path = ""; } if ($fips_premain_dso_exe_path eq "") { $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep"; } # $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips); #$ex_l_libs .= " \$(L_FIPS)" if $fipsdso; if ($fips) { if (!$shlib) { $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)"; $ex_l_libs .= " \$(O_FIPSCANISTER)"; $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild; } if ($fipscanisterbuild) { $fipslibdir = "\$(LIB_D)"; } else { if ($fipslibdir eq "") { open (IN, "util/fipslib_path.txt") || fipslib_error(); $fipslibdir = <IN>; chomp $fipslibdir; close IN; } fips_check_files($fipslibdir, "fipscanister.lib", "fipscanister.lib.sha1", "fips_premain.c", "fips_premain.c.sha1"); } } if ($shlib) { $extra_install= <<"EOF"; \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\" \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\" \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\" \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" EOF if ($no_static_engine) { $extra_install .= <<"EOF" \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" EOF } } else { $extra_install= <<"EOF"; \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\" \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" EOF $ex_libs .= " $zlib_lib" if $zlib_opt == 1; } $defs= <<"EOF"; # This makefile has been automatically generated from the OpenSSL distribution. # This single makefile will build the complete OpenSSL distribution and # by default leave the 'intertesting' output files in .${o}out and the stuff # that needs deleting in .${o}tmp. # The file was generated by running 'make makefile.one', which # does a 'make files', which writes all the environment variables from all # the makefiles to the file call MINFO. This file is used by # util${o}mk1mf.pl to generate makefile.one. # The 'makefile per directory' system suites me when developing this # library and also so I can 'distribute' indervidual library sections. # The one monster makefile better suits building in non-unix # environments. EOF $defs .= $preamble if defined $preamble; $defs.= <<"EOF"; INSTALLTOP=$INSTALLTOP # Set your compiler options PLATFORM=$platform CC=$bin_dir${cc} CFLAG=$cflags APP_CFLAG=$app_cflag LIB_CFLAG=$lib_cflag SHLIB_CFLAG=$shl_cflag APP_EX_OBJ=$app_ex_obj SHLIB_EX_OBJ=$shlib_ex_obj # add extra libraries to this define, for solaris -lsocket -lnsl would # be added EX_LIBS=$ex_libs # The OpenSSL directory SRC_D=$src_dir LINK=$link LFLAGS=$lflags RSC=$rsc FIPSLINK=\$(PERL) util${o}fipslink.pl AES_ASM_OBJ=$aes_asm_obj AES_ASM_SRC=$aes_asm_src BN_ASM_OBJ=$bn_asm_obj BN_ASM_SRC=$bn_asm_src BNCO_ASM_OBJ=$bnco_asm_obj BNCO_ASM_SRC=$bnco_asm_src DES_ENC_OBJ=$des_enc_obj DES_ENC_SRC=$des_enc_src BF_ENC_OBJ=$bf_enc_obj BF_ENC_SRC=$bf_enc_src CAST_ENC_OBJ=$cast_enc_obj CAST_ENC_SRC=$cast_enc_src RC4_ENC_OBJ=$rc4_enc_obj RC4_ENC_SRC=$rc4_enc_src RC5_ENC_OBJ=$rc5_enc_obj RC5_ENC_SRC=$rc5_enc_src MD5_ASM_OBJ=$md5_asm_obj MD5_ASM_SRC=$md5_asm_src SHA1_ASM_OBJ=$sha1_asm_obj SHA1_ASM_SRC=$sha1_asm_src RMD160_ASM_OBJ=$rmd160_asm_obj RMD160_ASM_SRC=$rmd160_asm_src CPUID_ASM_OBJ=$cpuid_asm_obj CPUID_ASM_SRC=$cpuid_asm_src # The output directory for everything intersting OUT_D=$out_dir # The output directory for all the temporary muck TMP_D=$tmp_dir # The output directory for the header files INC_D=$inc_dir INCO_D=$inc_dir${o}openssl PERL=$perl CP=$cp RM=$rm RANLIB=$ranlib MKDIR=$mkdir MKLIB=$bin_dir$mklib MLFLAGS=$mlflags ASM=$bin_dir$asm # FIPS validated module and support file locations E_PREMAIN_DSO=fips_premain_dso FIPSLIB_D=$fipslibdir BASEADDR=$baseaddr FIPS_PREMAIN_SRC=$fips_premain_c_path O_FIPSCANISTER=$fips_canister_path FIPS_SHA1_EXE=$fips_sha1_exe_path PREMAIN_DSO_EXE=$fips_premain_dso_exe_path ###################################################### # You should not need to touch anything below this point ###################################################### E_EXE=openssl SSL=$ssl CRYPTO=$crypto LIBFIPS=libosslfips # BIN_D - Binary output directory # TEST_D - Binary test file output directory # LIB_D - library output directory # ENG_D - dynamic engine output directory # Note: if you change these point to different directories then uncomment out # the lines around the 'NB' comment below. # BIN_D=\$(OUT_D) TEST_D=\$(OUT_D) LIB_D=\$(OUT_D) ENG_D=\$(OUT_D) # INCL_D - local library directory # OBJ_D - temp object file directory OBJ_D=\$(TMP_D) INCL_D=\$(TMP_D) O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp O_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$shlibp SO_SSL= $plib\$(SSL)$so_shlibp SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp L_FIPS= \$(LIB_D)$o$plib\$(LIBFIPS)$libp L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs ###################################################### # Don't touch anything below this point ###################################################### INC=-I\$(INC_D) -I\$(INCL_D) APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) $ex_libs_dep ############################################# EOF $rules=<<"EOF"; all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) lib exe $ex_build_targets banner: $banner \$(TMP_D): \$(MKDIR) \"\$(TMP_D)\" # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different #\$(BIN_D): # \$(MKDIR) \$(BIN_D) # #\$(TEST_D): # \$(MKDIR) \$(TEST_D) \$(LIB_D): \$(MKDIR) \"\$(LIB_D)\" \$(INCO_D): \$(INC_D) \$(MKDIR) \"\$(INCO_D)\" \$(INC_D): \$(MKDIR) \"\$(INC_D)\" headers: \$(HEADER) \$(EXHEADER) @ lib: \$(LIBS_DEP) \$(E_SHLIB) exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep install: all \$(MKDIR) \"\$(INSTALLTOP)\" \$(MKDIR) \"\$(INSTALLTOP)${o}bin\" \$(MKDIR) \"\$(INSTALLTOP)${o}include\" \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep\" \"\$(INSTALLTOP)${o}bin\" \$(CP) \"apps${o}openssl.cnf\" \"\$(INSTALLTOP)\" $extra_install test: \$(T_EXE) cd \$(BIN_D) ..${o}ms${o}test clean: \$(RM) \$(TMP_D)$o*.* vclean: \$(RM) \$(TMP_D)$o*.* \$(RM) \$(OUT_D)$o*.* EOF my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; $platform_cpp_symbol =~ s/-/_/g; if (open(IN,"crypto/buildinf.h")) { # Remove entry for this platform in existing file buildinf.h. my $old_buildinf_h = ""; while (<IN>) { if (/^\#ifdef $platform_cpp_symbol$/) { while (<IN>) { last if (/^\#endif/); } } else { $old_buildinf_h .= $_; } } close(IN); open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; print OUT $old_buildinf_h; close(OUT); } open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; printf OUT <<EOF; #ifdef $platform_cpp_symbol /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ #define CFLAGS "$cc $cflags" #define PLATFORM "$platform" EOF printf OUT " #define DATE \"%s\"\n", scalar gmtime(); printf OUT "#endif\n"; close(OUT); # Strip of trailing ' ' foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } $test=&clean_up_ws($test); $e_exe=&clean_up_ws($e_exe); $exheader=&clean_up_ws($exheader); $header=&clean_up_ws($header); # First we strip the exheaders from the headers list foreach (split(/\s+/,$exheader)){ $h{$_}=1; } foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } chop($h); $header=$h; $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); $rules.=&do_copy_rule("\$(INCL_D)",$header,""); $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); $rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); # Special case rules for fips_start and fips_end fips_premain_dso if ($fips) { if ($fipscanisterbuild) { $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj", "fips${o}fips_canister.c", "-DFIPS_START \$(SHLIB_CFLAGS)"); $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj", "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)"); } $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj", "fips${o}sha${o}fips_standalone_sha1.c", "\$(SHLIB_CFLAGS)"); $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj", "fips${o}fips_premain.c", "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)"); } foreach (values %lib_nam) { $lib_obj=$lib_obj{$_}; local($slib)=$shlib; if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) { $rules.="\$(O_SSL):\n\n"; next; } if ((!$fips && ($_ eq "CRYPTO")) || ($fips && ($_ eq "FIPS"))) { if ($cpuid_asm_obj ne "") { $lib_obj =~ s/(\S*\/cryptlib\S*)/$1 \$(CPUID_ASM_OBJ)/; $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src); } if ($aes_asm_obj ne "") { $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/; $lib_obj =~ s/\s\S*\/aes_cbc\S*//; $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src); } if ($sha1_asm_obj ne "") { $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/; $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src); } if ($bn_asm_obj ne "") { $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src); } if ($bnco_asm_obj ne "") { $lib_obj .= "\$(BNCO_ASM_OBJ)"; $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src); } if ($des_enc_obj ne "") { $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); } } if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/; $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src); } if (($cast_enc_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/; $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src); } if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/; $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src); } if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/; $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src); } if (($md5_asm_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); } if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) { $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); } $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); } # hack to add version info on MSVC if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) { $rules.= <<"EOF"; \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc \$(OBJ_D)\\\$(LIBFIPS).res: ms\\version32.rc \$(RSC) /fo"\$(OBJ_D)\\\$(LIBFIPS).res" /d FIPS ms\\version32.rc EOF } $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); foreach (split(/\s+/,$test)) { my $t_libs; $t=&bname($_); my $ltype; # Check to see if test program is FIPS if ($fips && /fips/) { # If fipsdso link to libosslfips.dll # otherwise perform static link to # $(O_FIPSCANISTER) if ($fipsdso) { $t_libs = "\$(L_FIPS)"; $ltype = 0; } else { $t_libs = "\$(O_FIPSCANISTER)"; $ltype = 2; } } else { $t_libs = "\$(L_LIBS)"; $ltype = 0; } $tt="\$(OBJ_D)${o}$t${obj}"; $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype); } $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp); foreach (split(/\s+/,$engines)) { $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); } $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); if ($fips) { if ($shlib) { if ($fipsdso) { $rules.= &do_lib_rule("\$(CRYPTOOBJ)", "\$(O_CRYPTO)", "$crypto", $shlib, "", ""); $rules.= &do_lib_rule( "\$(O_FIPSCANISTER)", "\$(O_FIPS)", "\$(LIBFIPS)", $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)"); $rules.= &do_sdef_rule(); } else { $rules.= &do_lib_rule( "\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", "\$(O_CRYPTO)", "$crypto", $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)"); } } else { $rules.= &do_lib_rule("\$(CRYPTOOBJ)", "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", ""); $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(FIPSOBJ)", "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", ""); } } else { $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib, "\$(SO_CRYPTO)"); } if ($fips) { if ($fipscanisterbuild) { $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)", "\$(OBJ_D)${o}fips_start$obj", "\$(FIPSOBJ)", "\$(OBJ_D)${o}fips_end$obj", "\$(FIPS_SHA1_EXE)", ""); $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)", "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj \$(SHA1_ASM_OBJ)", "","\$(EX_LIBS)", 1); } else { $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)", "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)", "","", 1); } $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1); } $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); print $defs; if ($platform eq "linux-elf") { print <<"EOF"; # Generate perlasm output files %.cpp: (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) EOF } print "###################################################################\n"; print $rules; ############################################### # strip off any trailing .[och] and append the relative directory # also remembering to do nothing if we are in one of the dropped # directories sub var_add { local($dir,$val,$keepext)=@_; local(@a,$_,$ret); return("") if $no_engine && $dir =~ /\/engine/; return("") if $no_hw && $dir =~ /\/hw/; return("") if $no_idea && $dir =~ /\/idea/; return("") if $no_aes && $dir =~ /\/aes/; return("") if $no_camellia && $dir =~ /\/camellia/; return("") if $no_seed && $dir =~ /\/seed/; return("") if $no_rc2 && $dir =~ /\/rc2/; return("") if $no_rc4 && $dir =~ /\/rc4/; return("") if $no_rc5 && $dir =~ /\/rc5/; return("") if $no_rsa && $dir =~ /\/rsa/; return("") if $no_rsa && $dir =~ /^rsaref/; return("") if $no_dsa && $dir =~ /\/dsa/; return("") if $no_dh && $dir =~ /\/dh/; return("") if $no_ec && $dir =~ /\/ec/; return("") if $no_cms && $dir =~ /\/cms/; return("") if $no_jpake && $dir =~ /\/jpake/; return("") if !$fips && $dir =~ /^fips/; if ($no_des && $dir =~ /\/des/) { if ($val =~ /read_pwd/) { return("$dir/read_pwd "); } else { return(""); } } return("") if $no_mdc2 && $dir =~ /\/mdc2/; return("") if $no_sock && $dir =~ /\/proxy/; return("") if $no_bf && $dir =~ /\/bf/; return("") if $no_cast && $dir =~ /\/cast/; $val =~ s/^\s*(.*)\s*$/$1/; @a=split(/\s+/,$val); grep(s/\.[och]$//,@a) unless $keepext; @a=grep(!/^e_.*_3d$/,@a) if $no_des; @a=grep(!/^e_.*_d$/,@a) if $no_des; @a=grep(!/^e_.*_ae$/,@a) if $no_idea; @a=grep(!/^e_.*_i$/,@a) if $no_aes; @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; @a=grep(!/^e_.*_bf$/,@a) if $no_bf; @a=grep(!/^e_.*_c$/,@a) if $no_cast; @a=grep(!/^e_rc4$/,@a) if $no_rc4; @a=grep(!/^e_camellia$/,@a) if $no_camellia; @a=grep(!/^e_seed$/,@a) if $no_seed; @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; @a=grep(!/_dhp$/,@a) if $no_dh; @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; @a=grep(!/_mdc2$/,@a) if $no_mdc2; @a=grep(!/^engine$/,@a) if $no_engine; @a=grep(!/^hw$/,@a) if $no_hw; @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; @a=grep(!/^gendsa$/,@a) if $no_sha1; @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; grep($_="$dir/$_",@a); @a=grep(!/(^|\/)s_/,@a) if $no_sock; @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; $ret=join(' ',@a)." "; return($ret); } # change things so that each 'token' is only separated by one space sub clean_up_ws { local($w)=@_; $w =~ s/^\s*(.*)\s*$/$1/; $w =~ s/\s+/ /g; return($w); } sub do_defs { local($var,$files,$location,$postfix)=@_; local($_,$ret,$pf); local(*OUT,$tmp,$t); $files =~ s/\//$o/g if $o ne '/'; $ret="$var="; $n=1; $Vars{$var}.=""; foreach (split(/ /,$files)) { $orig=$_; $_=&bname($_) unless /^\$/; if ($n++ == 2) { $n=0; $ret.="\\\n\t"; } if (($_ =~ /bss_file/) && ($postfix eq ".h")) { $pf=".c"; } else { $pf=$postfix; } if ($_ =~ /BN_ASM/) { $t="$_ "; } elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } elsif ($_ =~ /DES_ENC/) { $t="$_ "; } elsif ($_ =~ /BF_ENC/) { $t="$_ "; } elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } elsif ($_ =~ /AES_ASM/){ $t="$_ "; } elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } else { $t="$location${o}$_$pf "; } $Vars{$var}.="$t "; $ret.=$t; } # hack to add version info on MSVC if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))) { if ($var eq "CRYPTOOBJ") { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } elsif ($var eq "SSLOBJ") { $ret.="\$(OBJ_D)\\\$(SSL).res "; } } chomp($ret); $ret.="\n\n"; return($ret); } # return the name with the leading path removed sub bname { local($ret)=@_; $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; return($ret); } ############################################################## # do a rule for each file that says 'compile' to new direcory # compile the files in '$files' into $to sub do_compile_rule { local($to,$files,$ex)=@_; local($ret,$_,$n); $files =~ s/\//$o/g if $o ne '/'; foreach (split(/\s+/,$files)) { $n=&bname($_); $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) } return($ret); } ############################################################## # do a rule for each file that says 'compile' to new direcory sub cc_compile_target { local($target,$source,$ex_flags)=@_; local($ret); $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); $target =~ s/\//$o/g if $o ne "/"; $source =~ s/\//$o/g if $o ne "/"; $ret ="$target: \$(SRC_D)$o$source\n\t"; $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; return($ret); } ############################################################## sub do_asm_rule { local($target,$src)=@_; local($ret,@s,@t,$i); $target =~ s/\//$o/g if $o ne "/"; $src =~ s/\//$o/g if $o ne "/"; @s=split(/\s+/,$src); @t=split(/\s+/,$target); for ($i=0; $i<=$#s; $i++) { $ret.="$t[$i]: $s[$i]\n"; $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; } return($ret); } sub do_shlib_rule { local($n,$def)=@_; local($ret,$nn); local($t); ($nn=$n) =~ tr/a-z/A-Z/; $ret.="$n.dll: \$(${nn}OBJ)\n"; if ($vc && $w32) { $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; } $ret.="\n"; return($ret); } # do a rule for each file that says 'copy' to new direcory on change sub do_copy_rule { local($to,$files,$p)=@_; local($ret,$_,$n,$pp); $files =~ s/\//$o/g if $o ne '/'; foreach (split(/\s+/,$files)) { $n=&bname($_); if ($n =~ /bss_file/) { $pp=".c"; } else { $pp=$p; } $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; } return($ret); } sub read_options { # Many options are handled in a similar way. In particular # no-xxx sets zero or more scalars to 1. # Process these using a hash containing the option name and # reference to the scalars to set. my %valid_options = ( "no-rc2" => \$no_rc2, "no-rc4" => \$no_rc4, "no-rc5" => \$no_rc5, "no-idea" => \$no_idea, "no-aes" => \$no_aes, "no-camellia" => \$no_camellia, "no-seed" => \$no_seed, "no-des" => \$no_des, "no-bf" => \$no_bf, "no-cast" => \$no_cast, "no-md2" => \$no_md2, "no-md4" => \$no_md4, "no-md5" => \$no_md5, "no-sha" => \$no_sha, "no-sha1" => \$no_sha1, "no-ripemd" => \$no_ripemd, "no-mdc2" => \$no_mdc2, "no-patents" => [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], "no-rsa" => \$no_rsa, "no-dsa" => \$no_dsa, "no-dh" => \$no_dh, "no-hmac" => \$no_hmac, "no-asm" => \$no_asm, "nasm" => \$nasm, "ml64" => \$ml64, "nw-nasm" => \$nw_nasm, "nw-mwasm" => \$nw_mwasm, "gaswin" => \$gaswin, "no-ssl2" => \$no_ssl2, "no-ssl3" => \$no_ssl3, "no-tlsext" => \$no_tlsext, "no-cms" => \$no_cms, "no-jpake" => \$no_jpake, "no-capieng" => \$no_capieng, "no-err" => \$no_err, "no-sock" => \$no_sock, "no-krb5" => \$no_krb5, "no-ec" => \$no_ec, "no-ecdsa" => \$no_ecdsa, "no-ecdh" => \$no_ecdh, "no-engine" => \$no_engine, "no-hw" => \$no_hw, "just-ssl" => [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, \$no_aes, \$no_camellia, \$no_seed], "rsaref" => 0, "gcc" => \$gcc, "debug" => \$debug, "profile" => \$profile, "shlib" => \$shlib, "dll" => \$shlib, "shared" => 0, "no-gmp" => 0, "no-rfc3779" => 0, "no-montasm" => 0, "no-shared" => 0, "no-zlib" => 0, "no-zlib-dynamic" => 0, "fips" => \$fips, "fipscanisterbuild" => [\$fips, \$fipscanisterbuild], "fipsdso" => [\$fips, \$fipscanisterbuild, \$fipsdso], ); if (exists $valid_options{$_}) { my $r = $valid_options{$_}; if ( ref $r eq "SCALAR") { $$r = 1;} elsif ( ref $r eq "ARRAY") { my $r2; foreach $r2 (@$r) { $$r2 = 1; } } } elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } elsif (/^enable-zlib-dynamic$/) { $zlib_opt = 2; } elsif (/^no-static-engine/) { $no_static_engine = 1; } elsif (/^enable-static-engine/) { $no_static_engine = 0; } # There are also enable-xxx options which correspond to # the no-xxx. Since the scalars are enabled by default # these can be ignored. elsif (/^enable-/) { my $t = $_; $t =~ s/^enable/no/; if (exists $valid_options{$t}) {return 1;} return 0; } # experimental-xxx is mostly like enable-xxx, but opensslconf.v # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx. # (No need to fail if we don't know the algorithm -- this is for adventurous users only.) elsif (/^experimental-/) { my $algo, $ALGO; ($algo = $_) =~ s/^experimental-//; ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/; $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags"; } elsif (/^--with-krb5-flavor=(.*)$/) { my $krb5_flavor = $1; if ($krb5_flavor =~ /^force-[Hh]eimdal$/) { $xcflags="-DKRB5_HEIMDAL $xcflags"; } elsif ($krb5_flavor =~ /^MIT/i) { $xcflags="-DKRB5_MIT $xcflags"; if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) { $xcflags="-DKRB5_MIT_OLD11 $xcflags" } } } elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } elsif (/^-[lL].*$/) { $l_flags.="$_ "; } elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) { $c_flags.="$_ "; } else { return(0); } return(1); } sub fipslib_error { print STDERR "***FIPS module directory sanity check failed***\n"; print STDERR "FIPS module build failed, or was deleted\n"; print STDERR "Please rebuild FIPS module.\n"; exit 1; } sub fips_check_files { my $dir = shift @_; my $ret = 1; if (!-d $dir) { print STDERR "FIPS module directory $dir does not exist\n"; fipslib_error(); } foreach (@_) { if (!-f "$dir${o}$_") { print STDERR "FIPS module file $_ does not exist!\n"; $ret = 0; } } fipslib_error() if ($ret == 0); }
relokin/parsec
pkgs/libs/ssl/src/util/mk1mf.pl
Perl
bsd-3-clause
36,232
=head1 NAME SGN::Controller::AJAX::Search::Genotype - a REST controller class to provide search over markerprofiles =head1 DESCRIPTION =head1 AUTHOR =cut package SGN::Controller::AJAX::Search::Genotype; use Moose; use Data::Dumper; use JSON; use CXGN::People::Login; use CXGN::Genotype::Search; use JSON; use utf8; use File::Slurp qw | read_file |; use File::Temp 'tempfile'; use File::Copy; use File::Spec::Functions; use File::Basename qw | basename dirname|; use Digest::MD5; use DateTime; BEGIN { extends 'Catalyst::Controller::REST' } __PACKAGE__->config( default => 'application/json', stash_key => 'rest', map => { 'application/json' => 'JSON' }, ); sub genotyping_data_search : Path('/ajax/genotyping_data/search') : ActionClass('REST') { } sub genotyping_data_search_GET : Args(0) { my $self = shift; my $c = shift; my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $people_schema = $c->dbic_schema("CXGN::People::Schema"); my $clean_inputs = _clean_inputs($c->req->params); my $limit = $c->req->param('length'); my $offset = $c->req->param('start'); my $genotypes_search = CXGN::Genotype::Search->new({ bcs_schema=>$bcs_schema, people_schema=>$people_schema, cache_root=>$c->config->{cache_file_path}, accession_list=>$clean_inputs->{accession_id_list}, tissue_sample_list=>$clean_inputs->{tissue_sample_id_list}, trial_list=>$clean_inputs->{genotyping_data_project_id_list}, protocol_id_list=>$clean_inputs->{protocol_id_list}, #marker_name_list=>['S80_265728', 'S80_265723'] #marker_search_hash_list=>[{'S80_265728' => {'pos' => '265728', 'chrom' => '1'}}], #marker_score_search_hash_list=>[{'S80_265728' => {'GT' => '0/0', 'GQ' => '99'}}], genotypeprop_hash_select=>['DS'], protocolprop_marker_hash_select=>[], protocolprop_top_key_select=>[], forbid_cache=>$clean_inputs->{forbid_cache}->[0] }); my $file_handle = $genotypes_search->get_cached_file_search_json($c->config->{cluster_shared_tempdir}, 1); #only gets metadata and not all genotype data! my @result; my $counter = 0; open my $fh, "<&", $file_handle or die "Can't open output file: $!"; my $header_line = <$fh>; if ($header_line) { my $marker_objects = decode_json $header_line; my $start_index = $offset; my $end_index = $offset + $limit; # print STDERR Dumper [$start_index, $end_index]; while (my $gt_line = <$fh>) { if ($counter >= $start_index && $counter < $end_index) { my $g = decode_json $gt_line; print STDERR "PROTOCOL GENOTYPING DATA =".Dumper($g)."\n"; my $synonym_string = scalar(@{$g->{synonyms}})>0 ? join ',', @{$g->{synonyms}} : ''; push @result, [ "<a href=\"/breeders_toolbox/protocol/$g->{analysisMethodDbId}\">$g->{analysisMethod}</a>", "<a href=\"/stock/$g->{stock_id}/view\">$g->{stock_name}</a>", $g->{stock_type_name}, "<a href=\"/stock/$g->{germplasmDbId}/view\">$g->{germplasmName}</a>", $synonym_string, $g->{genotypeDescription}, $g->{resultCount}, $g->{igd_number}, "<a href=\"/stock/$g->{stock_id}/genotypes?genotype_id=$g->{markerProfileDbId}\">Download</a>" ]; } $counter++; } } #print STDERR Dumper \@result; my $draw = $c->req->param('draw'); if ($draw){ $draw =~ s/\D//g; # cast to int } $c->stash->{rest} = { data => \@result, draw => $draw, recordsTotal => $counter, recordsFiltered => $counter }; } sub _clean_inputs { no warnings 'uninitialized'; my $params = shift; foreach (keys %$params){ my $values = $params->{$_}; my $ret_val; if (ref \$values eq 'SCALAR'){ push @$ret_val, $values; } elsif (ref $values eq 'ARRAY'){ $ret_val = $values; } else { die "Input is not a scalar or an arrayref\n"; } @$ret_val = grep {$_ ne undef} @$ret_val; @$ret_val = grep {$_ ne ''} @$ret_val; $_ =~ s/\[\]$//; #ajax POST with arrays adds [] to the end of the name e.g. germplasmName[]. since all inputs are arrays now we can remove the []. $params->{$_} = $ret_val; } return $params; } sub pcr_genotyping_data_search : Path('/ajax/pcr_genotyping_data/search') : ActionClass('REST') { } sub pcr_genotyping_data_search_GET : Args(0) { my $self = shift; my $c = shift; my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $people_schema = $c->dbic_schema("CXGN::People::Schema"); my $clean_inputs = _clean_inputs($c->req->params); my $protocol_id = $clean_inputs->{protocol_id_list}; my $genotypes_search = CXGN::Genotype::Search->new({ bcs_schema=>$bcs_schema, people_schema=>$people_schema, protocol_id_list=>$protocol_id, }); my $result = $genotypes_search->get_pcr_genotype_info(); # print STDERR "PCR RESULTS =".Dumper($result)."\n"; my $protocol_marker_names = $result->{'marker_names'}; my $protocol_genotype_data = $result->{'protocol_genotype_data'}; my $protocol_marker_names_ref = decode_json $protocol_marker_names; my @marker_name_arrays = sort @$protocol_marker_names_ref; my @protocol_genotype_data_array = @$protocol_genotype_data; my @results; foreach my $genotype_data (@protocol_genotype_data_array) { my @each_genotype = (); my $stock_id = $genotype_data->[0]; my $stock_name = $genotype_data->[1]; my $stock_type = $genotype_data->[2]; my $ploidy_level = $genotype_data->[3]; push @each_genotype, qq{<a href="/stock/$stock_id/view">$stock_name</a>}; push @each_genotype, ($stock_type, $ploidy_level); my $marker_genotype_json = $genotype_data->[6]; my $marker_genotype_ref = decode_json $marker_genotype_json; my %marker_genotype_hash = %$marker_genotype_ref; foreach my $marker (@marker_name_arrays) { my @positive_bands = (); my $product_sizes_ref = $marker_genotype_hash{$marker}; if (!$product_sizes_ref) { push @each_genotype, 'NA'; } else { my %product_sizes_hash = %$product_sizes_ref; foreach my $product_size (keys %product_sizes_hash) { my $pcr_result = $product_sizes_hash{$product_size}; if ($pcr_result eq '1') { push @positive_bands, $product_size; } } if (scalar @positive_bands == 0) { push @positive_bands, '-'; } my $pcr_result = join(",", sort @positive_bands); push @each_genotype, $pcr_result ; } } push @results, [@each_genotype]; } # print STDERR "RESULTS =".Dumper(\@results)."\n"; $c->stash->{rest} = { data => \@results}; } sub pcr_genotyping_data_summary_search : Path('/ajax/pcr_genotyping_data_summary/search') : ActionClass('REST') { } sub pcr_genotyping_data_summary_search_GET : Args(0) { my $self = shift; my $c = shift; my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $people_schema = $c->dbic_schema("CXGN::People::Schema"); my $clean_inputs = _clean_inputs($c->req->params); my $protocol_id = $clean_inputs->{protocol_id_list}; my $genotypes_search = CXGN::Genotype::Search->new({ bcs_schema=>$bcs_schema, people_schema=>$people_schema, protocol_id_list=>$protocol_id, }); my $result = $genotypes_search->get_pcr_genotype_info(); # print STDERR "PCR RESULTS =".Dumper($result)."\n"; my $protocol_marker_names = $result->{'marker_names'}; my $protocol_genotype_data = $result->{'protocol_genotype_data'}; my $protocol_marker_names_ref = decode_json $protocol_marker_names; my @marker_name_arrays = @$protocol_marker_names_ref; my $number_of_markers = scalar @marker_name_arrays; my @protocol_genotype_data_array = @$protocol_genotype_data; my @results; foreach my $genotype_info (@protocol_genotype_data_array) { push @results, { stock_id => $genotype_info->[0], stock_name => $genotype_info->[1], stock_type => $genotype_info->[2], genotype_description => $genotype_info->[3], genotype_id => $genotype_info->[4], number_of_markers => $number_of_markers, }; } # print STDERR "RESULTS =".Dumper(\@results)."\n"; $c->stash->{rest} = { data => \@results}; } sub pcr_genotyping_data_download : Path('/ajax/pcr_genotyping_data/download') : ActionClass('REST') { } sub pcr_genotyping_data_download_POST : Args(0) { my $self = shift; my $c = shift; my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $people_schema = $c->dbic_schema("CXGN::People::Schema"); my $clean_inputs = _clean_inputs($c->req->params); my $ssr_protocol_id = $clean_inputs->{ssr_protocol_id}; my $downloaded_protocol_id = $ssr_protocol_id->[0]; print STDERR "PROTOCOL ID = $downloaded_protocol_id\n"; my $dir = $c->tempfiles_subdir('download'); my $temp_file_name = $downloaded_protocol_id . "_" . "genotype_data" . "XXXX"; my $rel_file = $c->tempfile( TEMPLATE => "download/$temp_file_name"); $rel_file = $rel_file . ".csv"; my $tempfile = $c->config->{basepath}."/".$rel_file; print STDERR "TEMPFILE : $tempfile\n"; if (!$c->user()) { $c->stash->{rest} = {error => "You need to be logged in to download genotype data" }; return; } my $metadata_schema = $c->dbic_schema('CXGN::Metadata::Schema'); my $user_id = $c->user()->get_object()->get_sp_person_id(); my $user_name = $c->user()->get_object()->get_username(); my $time = DateTime->now(); my $timestamp = $time->ymd()."_".$time->hms(); my $subdirectory_name = "ssr_download"; my $archived_file_name = catfile($user_id, $subdirectory_name,$timestamp."_".'genotype_data'.".csv"); my $archive_path = $c->config->{archive_path}; my $file_destination = catfile($archive_path, $archived_file_name); my $dbh = $c->dbc->dbh(); my $genotypes = CXGN::Genotype::DownloadFactory->instantiate( 'SSR', { bcs_schema=>$schema, people_schema=>$people_schema, protocol_id_list=>$ssr_protocol_id, filename => $tempfile, } ); my $file_handle = $genotypes->download(); print STDERR "FILE HANDLE =".Dumper($file_handle)."\n"; open(my $F, "<", $tempfile) || die "Can't open file ".$self->tempfile(); binmode $F; my $md5 = Digest::MD5->new(); $md5->addfile($F); close($F); if (!-d $archive_path) { mkdir $archive_path; } if (! -d catfile($archive_path, $user_id)) { mkdir (catfile($archive_path, $user_id)); } if (! -d catfile($archive_path, $user_id,$subdirectory_name)) { mkdir (catfile($archive_path, $user_id, $subdirectory_name)); } my $md_row = $metadata_schema->resultset("MdMetadata")->create({ create_person_id => $user_id, }); $md_row->insert(); my $file_row = $metadata_schema->resultset("MdFiles")->create({ basename => basename($file_destination), dirname => dirname($file_destination), filetype => 'ssr_genotype_data_csv', md5checksum => $md5->hexdigest(), metadata_id => $md_row->metadata_id(), }); $file_row->insert(); my $file_id = $file_row->file_id(); print STDERR "FILE ID =".Dumper($file_id)."\n"; print STDERR "FILE DESTINATION =".Dumper($file_destination)."\n"; move($tempfile,$file_destination); unlink $tempfile; my $result = $file_row->file_id; # print STDERR "FILE =".Dumper($file_destination)."\n"; # print STDERR "FILE ID =".Dumper($file_id)."\n"; $c->stash->{rest} = { success => 1, result => $result, file => $file_destination, file_id => $file_id, }; } 1;
solgenomics/sgn
lib/SGN/Controller/AJAX/Search/Genotype.pm
Perl
mit
12,306
/** * last(+L, ?X) */ last([X], X) :- !. last([_|XS], X) :- last(XS, X). :- begin_tests(last). test('empty list', [fail]) :- last([],_). test('simple list') :- last([a,b,c], X), X == c. test('instantiated failure', [fail]) :- last([a,b,c], a). test('instantiated success') :- last([a,b,c], c). :- end_tests(last).
danielchatfield/prolog-99-problems
p1_01.pl
Perl
mit
338
=pod =head1 NAME openssl-x509, x509 - Certificate display and signing utility =head1 SYNOPSIS B<openssl> B<x509> [B<-help>] [B<-inform DER|PEM>] [B<-outform DER|PEM>] [B<-keyform DER|PEM|ENGINE>] [B<-CAform DER|PEM>] [B<-CAkeyform DER|PEM>] [B<-in filename>] [B<-out filename>] [B<-serial>] [B<-hash>] [B<-subject_hash>] [B<-issuer_hash>] [B<-ocspid>] [B<-subject>] [B<-issuer>] [B<-nameopt option>] [B<-email>] [B<-ocsp_uri>] [B<-startdate>] [B<-enddate>] [B<-purpose>] [B<-dates>] [B<-checkend num>] [B<-modulus>] [B<-pubkey>] [B<-fingerprint>] [B<-alias>] [B<-noout>] [B<-trustout>] [B<-clrtrust>] [B<-clrreject>] [B<-addtrust arg>] [B<-addreject arg>] [B<-setalias arg>] [B<-days arg>] [B<-set_serial n>] [B<-signkey arg>] [B<-passin arg>] [B<-x509toreq>] [B<-req>] [B<-CA filename>] [B<-CAkey filename>] [B<-CAcreateserial>] [B<-CAserial filename>] [B<-force_pubkey key>] [B<-text>] [B<-ext extensions>] [B<-certopt option>] [B<-C>] [B<-I<digest>>] [B<-clrext>] [B<-extfile filename>] [B<-extensions section>] [B<-sigopt nm:v>] [B<-rand file...>] [B<-writerand file>] [B<-engine id>] [B<-preserve_dates>] =head1 DESCRIPTION The B<x509> command is a multi purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a "mini CA" or edit certificate trust settings. Since there are a large number of options they will split up into various sections. =head1 OPTIONS =head2 Input, Output, and General Purpose Options =over 4 =item B<-help> Print out a usage message. =item B<-inform DER|PEM> This specifies the input format normally the command will expect an X509 certificate but this can change if other options such as B<-req> are present. The DER format is the DER encoding of the certificate and PEM is the base64 encoding of the DER encoding with header and footer lines added. The default format is PEM. =item B<-outform DER|PEM> This specifies the output format, the options have the same meaning and default as the B<-inform> option. =item B<-in filename> This specifies the input filename to read a certificate from or standard input if this option is not specified. =item B<-out filename> This specifies the output filename to write to or standard output by default. =item B<-I<digest>> The digest to use. This affects any signing or display option that uses a message digest, such as the B<-fingerprint>, B<-signkey> and B<-CA> options. Any digest supported by the OpenSSL B<dgst> command can be used. If not specified then SHA1 is used with B<-fingerprint> or the default digest for the signing algorithm is used, typically SHA256. =item B<-rand file...> A file or files containing random data used to seed the random number generator. Multiple files can be specified separated by an OS-dependent character. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for all others. =item [B<-writerand file>] Writes random data to the specified I<file> upon exit. This can be used with a subsequent B<-rand> flag. =item B<-engine id> Specifying an engine (by its unique B<id> string) will cause B<x509> to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. =item B<-preserve_dates> When signing a certificate, preserve the "notBefore" and "notAfter" dates instead of adjusting them to current time and duration. Cannot be used with the B<-days> option. =back =head2 Display Options Note: the B<-alias> and B<-purpose> options are also display options but are described in the B<TRUST SETTINGS> section. =over 4 =item B<-text> Prints out the certificate in text form. Full details are output including the public key, signature algorithms, issuer and subject names, serial number any extensions present and any trust settings. =item B<-ext extensions> Prints out the certificate extensions in text form. Extensions are specified with a comma separated string, e.g., "subjectAltName,subjectKeyIdentifier". See the L<x509v3_config(5)> manual page for the extension names. =item B<-certopt option> Customise the output format used with B<-text>. The B<option> argument can be a single option or multiple options separated by commas. The B<-certopt> switch may be also be used more than once to set multiple options. See the B<TEXT OPTIONS> section for more information. =item B<-noout> This option prevents output of the encoded version of the certificate. =item B<-pubkey> Outputs the certificate's SubjectPublicKeyInfo block in PEM format. =item B<-modulus> This option prints out the value of the modulus of the public key contained in the certificate. =item B<-serial> Outputs the certificate serial number. =item B<-subject_hash> Outputs the "hash" of the certificate subject name. This is used in OpenSSL to form an index to allow certificates in a directory to be looked up by subject name. =item B<-issuer_hash> Outputs the "hash" of the certificate issuer name. =item B<-ocspid> Outputs the OCSP hash values for the subject name and public key. =item B<-hash> Synonym for "-subject_hash" for backward compatibility reasons. =item B<-subject_hash_old> Outputs the "hash" of the certificate subject name using the older algorithm as used by OpenSSL before version 1.0.0. =item B<-issuer_hash_old> Outputs the "hash" of the certificate issuer name using the older algorithm as used by OpenSSL before version 1.0.0. =item B<-subject> Outputs the subject name. =item B<-issuer> Outputs the issuer name. =item B<-nameopt option> Option which determines how the subject or issuer names are displayed. The B<option> argument can be a single option or multiple options separated by commas. Alternatively the B<-nameopt> switch may be used more than once to set multiple options. See the B<NAME OPTIONS> section for more information. =item B<-email> Outputs the email address(es) if any. =item B<-ocsp_uri> Outputs the OCSP responder address(es) if any. =item B<-startdate> Prints out the start date of the certificate, that is the notBefore date. =item B<-enddate> Prints out the expiry date of the certificate, that is the notAfter date. =item B<-dates> Prints out the start and expiry dates of a certificate. =item B<-checkend arg> Checks if the certificate expires within the next B<arg> seconds and exits non-zero if yes it will expire or zero if not. =item B<-fingerprint> Calculates and outputs the digest of the DER encoded version of the entire certificate (see digest options). This is commonly called a "fingerprint". Because of the nature of message digests, the fingerprint of a certificate is unique to that certificate and two certificates with the same fingerprint can be considered to be the same. =item B<-C> This outputs the certificate in the form of a C source file. =back =head2 Trust Settings A B<trusted certificate> is an ordinary certificate which has several additional pieces of information attached to it such as the permitted and prohibited uses of the certificate and an "alias". Normally when a certificate is being verified at least one certificate must be "trusted". By default a trusted certificate must be stored locally and must be a root CA: any certificate chain ending in this CA is then usable for any purpose. Trust settings currently are only used with a root CA. They allow a finer control over the purposes the root CA can be used for. For example a CA may be trusted for SSL client but not SSL server use. See the description of the B<verify> utility for more information on the meaning of trust settings. Future versions of OpenSSL will recognize trust settings on any certificate: not just root CAs. =over 4 =item B<-trustout> This causes B<x509> to output a B<trusted> certificate. An ordinary or trusted certificate can be input but by default an ordinary certificate is output and any trust settings are discarded. With the B<-trustout> option a trusted certificate is output. A trusted certificate is automatically output if any trust settings are modified. =item B<-setalias arg> Sets the alias of the certificate. This will allow the certificate to be referred to using a nickname for example "Steve's Certificate". =item B<-alias> Outputs the certificate alias, if any. =item B<-clrtrust> Clears all the permitted or trusted uses of the certificate. =item B<-clrreject> Clears all the prohibited or rejected uses of the certificate. =item B<-addtrust arg> Adds a trusted certificate use. Any object name can be used here but currently only B<clientAuth> (SSL client use), B<serverAuth> (SSL server use), B<emailProtection> (S/MIME email) and B<anyExtendedKeyUsage> are used. As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or enables all purposes when trusted. Other OpenSSL applications may define additional uses. =item B<-addreject arg> Adds a prohibited use. It accepts the same values as the B<-addtrust> option. =item B<-purpose> This option performs tests on the certificate extensions and outputs the results. For a more complete description see the B<CERTIFICATE EXTENSIONS> section. =back =head2 Signing Options The B<x509> utility can be used to sign certificates and requests: it can thus behave like a "mini CA". =over 4 =item B<-signkey arg> This option causes the input file to be self signed using the supplied private key or engine. The private key's format is specified with the B<-keyform> option. If the input file is a certificate it sets the issuer name to the subject name (i.e. makes it self signed) changes the public key to the supplied value and changes the start and end dates. The start date is set to the current time and the end date is set to a value determined by the B<-days> option. Any certificate extensions are retained unless the B<-clrext> option is supplied; this includes, for example, any existing key identifier extensions. If the input is a certificate request then a self signed certificate is created using the supplied private key using the subject name in the request. =item B<-sigopt nm:v> Pass options to the signature algorithm during sign or verify operations. Names and values of these options are algorithm-specific. =item B<-passin arg> The key password source. For more information about the format of B<arg> see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>. =item B<-clrext> Delete any extensions from a certificate. This option is used when a certificate is being created from another certificate (for example with the B<-signkey> or the B<-CA> options). Normally all extensions are retained. =item B<-keyform PEM|DER|ENGINE> Specifies the format (DER or PEM) of the private key file used in the B<-signkey> option. =item B<-days arg> Specifies the number of days to make a certificate valid for. The default is 30 days. Cannot be used with the B<-preserve_dates> option. =item B<-x509toreq> Converts a certificate into a certificate request. The B<-signkey> option is used to pass the required private key. =item B<-req> By default a certificate is expected on input. With this option a certificate request is expected instead. =item B<-set_serial n> Specifies the serial number to use. This option can be used with either the B<-signkey> or B<-CA> options. If used in conjunction with the B<-CA> option the serial number file (as specified by the B<-CAserial> or B<-CAcreateserial> options) is not used. The serial number can be decimal or hex (if preceded by B<0x>). =item B<-CA filename> Specifies the CA certificate to be used for signing. When this option is present B<x509> behaves like a "mini CA". The input file is signed by this CA using this option: that is its issuer name is set to the subject name of the CA and it is digitally signed using the CAs private key. This option is normally combined with the B<-req> option. Without the B<-req> option the input is a certificate which must be self signed. =item B<-CAkey filename> Sets the CA private key to sign a certificate with. If this option is not specified then it is assumed that the CA private key is present in the CA certificate file. =item B<-CAserial filename> Sets the CA serial number file to use. When the B<-CA> option is used to sign a certificate it uses a serial number specified in a file. This file consists of one line containing an even number of hex digits with the serial number to use. After each use the serial number is incremented and written out to the file again. The default filename consists of the CA certificate file base name with ".srl" appended. For example if the CA certificate file is called "mycacert.pem" it expects to find a serial number file called "mycacert.srl". =item B<-CAcreateserial> With this option the CA serial number file is created if it does not exist: it will contain the serial number "02" and the certificate being signed will have the 1 as its serial number. If the B<-CA> option is specified and the serial number file does not exist a random number is generated; this is the recommended practice. =item B<-extfile filename> File containing certificate extensions to use. If not specified then no extensions are added to the certificate. =item B<-extensions section> The section to add certificate extensions from. If this option is not specified then the extensions should either be contained in the unnamed (default) section or the default section should contain a variable called "extensions" which contains the section to use. See the L<x509v3_config(5)> manual page for details of the extension section format. =item B<-force_pubkey key> When a certificate is created set its public key to B<key> instead of the key in the certificate or certificate request. This option is useful for creating certificates where the algorithm can't normally sign requests, for example DH. The format or B<key> can be specified using the B<-keyform> option. =back =head2 Name Options The B<nameopt> command line switch determines how the subject and issuer names are displayed. If no B<nameopt> switch is present the default "oneline" format is used which is compatible with previous versions of OpenSSL. Each option is described in detail below, all options can be preceded by a B<-> to turn the option off. Only the first four will normally be used. =over 4 =item B<compat> Use the old format. =item B<RFC2253> Displays names compatible with RFC2253 equivalent to B<esc_2253>, B<esc_ctrl>, B<esc_msb>, B<utf8>, B<dump_nostr>, B<dump_unknown>, B<dump_der>, B<sep_comma_plus>, B<dn_rev> and B<sname>. =item B<oneline> A oneline format which is more readable than RFC2253. It is equivalent to specifying the B<esc_2253>, B<esc_ctrl>, B<esc_msb>, B<utf8>, B<dump_nostr>, B<dump_der>, B<use_quote>, B<sep_comma_plus_space>, B<space_eq> and B<sname> options. This is the I<default> of no name options are given explicitly. =item B<multiline> A multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>, B<space_eq>, B<lname> and B<align>. =item B<esc_2253> Escape the "special" characters required by RFC2253 in a field. That is B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginning of a string and a space character at the beginning or end of a string. =item B<esc_2254> Escape the "special" characters required by RFC2254 in a field. That is the B<NUL> character as well as and B<()*>. =item B<esc_ctrl> Escape control characters. That is those with ASCII values less than 0x20 (space) and the delete (0x7f) character. They are escaped using the RFC2253 \XX notation (where XX are two hex digits representing the character value). =item B<esc_msb> Escape characters with the MSB set, that is with ASCII values larger than 127. =item B<use_quote> Escapes some characters by surrounding the whole string with B<"> characters, without the option all escaping is done with the B<\> character. =item B<utf8> Convert all strings to UTF8 format first. This is required by RFC2253. If you are lucky enough to have a UTF8 compatible terminal then the use of this option (and B<not> setting B<esc_msb>) may result in the correct display of multibyte (international) characters. Is this option is not present then multibyte characters larger than 0xff will be represented using the format \UXXXX for 16 bits and \WXXXXXXXX for 32 bits. Also if this option is off any UTF8Strings will be converted to their character form first. =item B<ignore_type> This option does not attempt to interpret multibyte characters in any way. That is their content octets are merely dumped as though one octet represents each character. This is useful for diagnostic purposes but will result in rather odd looking output. =item B<show_type> Show the type of the ASN1 character string. The type precedes the field contents. For example "BMPSTRING: Hello World". =item B<dump_der> When this option is set any fields that need to be hexdumped will be dumped using the DER encoding of the field. Otherwise just the content octets will be displayed. Both options use the RFC2253 B<#XXXX...> format. =item B<dump_nostr> Dump non character string types (for example OCTET STRING) if this option is not set then non character string types will be displayed as though each content octet represents a single character. =item B<dump_all> Dump all fields. This option when used with B<dump_der> allows the DER encoding of the structure to be unambiguously determined. =item B<dump_unknown> Dump any field whose OID is not recognised by OpenSSL. =item B<sep_comma_plus>, B<sep_comma_plus_space>, B<sep_semi_plus_space>, B<sep_multiline> These options determine the field separators. The first character is between RDNs and the second between multiple AVAs (multiple AVAs are very rare and their use is discouraged). The options ending in "space" additionally place a space after the separator to make it more readable. The B<sep_multiline> uses a linefeed character for the RDN separator and a spaced B<+> for the AVA separator. It also indents the fields by four characters. If no field separator is specified then B<sep_comma_plus_space> is used by default. =item B<dn_rev> Reverse the fields of the DN. This is required by RFC2253. As a side effect this also reverses the order of multiple AVAs but this is permissible. =item B<nofname>, B<sname>, B<lname>, B<oid> These options alter how the field name is displayed. B<nofname> does not display the field at all. B<sname> uses the "short name" form (CN for commonName for example). B<lname> uses the long form. B<oid> represents the OID in numerical form and is useful for diagnostic purpose. =item B<align> Align field values for a more readable output. Only usable with B<sep_multiline>. =item B<space_eq> Places spaces round the B<=> character which follows the field name. =back =head2 Text Options As well as customising the name output format, it is also possible to customise the actual fields printed using the B<certopt> options when the B<text> option is present. The default behaviour is to print all fields. =over 4 =item B<compatible> Use the old format. This is equivalent to specifying no output options at all. =item B<no_header> Don't print header information: that is the lines saying "Certificate" and "Data". =item B<no_version> Don't print out the version number. =item B<no_serial> Don't print out the serial number. =item B<no_signame> Don't print out the signature algorithm used. =item B<no_validity> Don't print the validity, that is the B<notBefore> and B<notAfter> fields. =item B<no_subject> Don't print out the subject name. =item B<no_issuer> Don't print out the issuer name. =item B<no_pubkey> Don't print out the public key. =item B<no_sigdump> Don't give a hexadecimal dump of the certificate signature. =item B<no_aux> Don't print out certificate trust information. =item B<no_extensions> Don't print out any X509V3 extensions. =item B<ext_default> Retain default extension behaviour: attempt to print out unsupported certificate extensions. =item B<ext_error> Print an error message for unsupported certificate extensions. =item B<ext_parse> ASN1 parse unsupported extensions. =item B<ext_dump> Hex dump unsupported extensions. =item B<ca_default> The value used by the B<ca> utility, equivalent to B<no_issuer>, B<no_pubkey>, B<no_header>, and B<no_version>. =back =head1 EXAMPLES Note: in these examples the '\' means the example should be all on one line. Display the contents of a certificate: openssl x509 -in cert.pem -noout -text Display the "Subject Alternative Name" extension of a certificate: openssl x509 -in cert.pem -noout -ext subjectAltName Display more extensions of a certificate: openssl x509 -in cert.pem -noout -ext subjectAltName,nsCertType Display the certificate serial number: openssl x509 -in cert.pem -noout -serial Display the certificate subject name: openssl x509 -in cert.pem -noout -subject Display the certificate subject name in RFC2253 form: openssl x509 -in cert.pem -noout -subject -nameopt RFC2253 Display the certificate subject name in oneline form on a terminal supporting UTF8: openssl x509 -in cert.pem -noout -subject -nameopt oneline,-esc_msb Display the certificate SHA1 fingerprint: openssl x509 -sha1 -in cert.pem -noout -fingerprint Convert a certificate from PEM to DER format: openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER Convert a certificate to a certificate request: openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem Convert a certificate request into a self signed certificate using extensions for a CA: openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \ -signkey key.pem -out cacert.pem Sign a certificate request using the CA certificate above and add user certificate extensions: openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \ -CA cacert.pem -CAkey key.pem -CAcreateserial Set a certificate to be trusted for SSL client use and change set its alias to "Steve's Class 1 CA" openssl x509 -in cert.pem -addtrust clientAuth \ -setalias "Steve's Class 1 CA" -out trust.pem =head1 NOTES The PEM format uses the header and footer lines: -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- it will also handle files containing: -----BEGIN X509 CERTIFICATE----- -----END X509 CERTIFICATE----- Trusted certificates have the lines -----BEGIN TRUSTED CERTIFICATE----- -----END TRUSTED CERTIFICATE----- The conversion to UTF8 format used with the name options assumes that T61Strings use the ISO8859-1 character set. This is wrong but Netscape and MSIE do this as do many certificates. So although this is incorrect it is more likely to display the majority of certificates correctly. The B<-email> option searches the subject name and the subject alternative name extension. Only unique email addresses will be printed out: it will not print the same address more than once. =head1 CERTIFICATE EXTENSIONS The B<-purpose> option checks the certificate extensions and determines what the certificate can be used for. The actual checks done are rather complex and include various hacks and workarounds to handle broken certificates and software. The same code is used when verifying untrusted certificates in chains so this section is useful if a chain is rejected by the verify code. The basicConstraints extension CA flag is used to determine whether the certificate can be used as a CA. If the CA flag is true then it is a CA, if the CA flag is false then it is not a CA. B<All> CAs should have the CA flag set to true. If the basicConstraints extension is absent then the certificate is considered to be a "possible CA" other extensions are checked according to the intended use of the certificate. A warning is given in this case because the certificate should really not be regarded as a CA: however it is allowed to be a CA to work around some broken software. If the certificate is a V1 certificate (and thus has no extensions) and it is self signed it is also assumed to be a CA but a warning is again given: this is to work around the problem of Verisign roots which are V1 self signed certificates. If the keyUsage extension is present then additional restraints are made on the uses of the certificate. A CA certificate B<must> have the keyCertSign bit set if the keyUsage extension is present. The extended key usage extension places additional restrictions on the certificate uses. If this extension is present (whether critical or not) the key can only be used for the purposes specified. A complete description of each test is given below. The comments about basicConstraints and keyUsage and V1 certificates above apply to B<all> CA certificates. =over 4 =item B<SSL Client> The extended key usage extension must be absent or include the "web client authentication" OID. keyUsage must be absent or it must have the digitalSignature bit set. Netscape certificate type must be absent or it must have the SSL client bit set. =item B<SSL Client CA> The extended key usage extension must be absent or include the "web client authentication" OID. Netscape certificate type must be absent or it must have the SSL CA bit set: this is used as a work around if the basicConstraints extension is absent. =item B<SSL Server> The extended key usage extension must be absent or include the "web server authentication" and/or one of the SGC OIDs. keyUsage must be absent or it must have the digitalSignature, the keyEncipherment set or both bits set. Netscape certificate type must be absent or have the SSL server bit set. =item B<SSL Server CA> The extended key usage extension must be absent or include the "web server authentication" and/or one of the SGC OIDs. Netscape certificate type must be absent or the SSL CA bit must be set: this is used as a work around if the basicConstraints extension is absent. =item B<Netscape SSL Server> For Netscape SSL clients to connect to an SSL server it must have the keyEncipherment bit set if the keyUsage extension is present. This isn't always valid because some cipher suites use the key for digital signing. Otherwise it is the same as a normal SSL server. =item B<Common S/MIME Client Tests> The extended key usage extension must be absent or include the "email protection" OID. Netscape certificate type must be absent or should have the S/MIME bit set. If the S/MIME bit is not set in Netscape certificate type then the SSL client bit is tolerated as an alternative but a warning is shown: this is because some Verisign certificates don't set the S/MIME bit. =item B<S/MIME Signing> In addition to the common S/MIME client tests the digitalSignature bit or the nonRepudiation bit must be set if the keyUsage extension is present. =item B<S/MIME Encryption> In addition to the common S/MIME tests the keyEncipherment bit must be set if the keyUsage extension is present. =item B<S/MIME CA> The extended key usage extension must be absent or include the "email protection" OID. Netscape certificate type must be absent or must have the S/MIME CA bit set: this is used as a work around if the basicConstraints extension is absent. =item B<CRL Signing> The keyUsage extension must be absent or it must have the CRL signing bit set. =item B<CRL Signing CA> The normal CA tests apply. Except in this case the basicConstraints extension must be present. =back =head1 BUGS Extensions in certificates are not transferred to certificate requests and vice versa. It is possible to produce invalid certificates or requests by specifying the wrong private key or using inconsistent options in some cases: these should be checked. There should be options to explicitly set such things as start and end dates rather than an offset from the current time. =head1 SEE ALSO L<req(1)>, L<ca(1)>, L<genrsa(1)>, L<gendsa(1)>, L<verify(1)>, L<x509v3_config(5)> =head1 HISTORY The hash algorithm used in the B<-subject_hash> and B<-issuer_hash> options before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical version of the DN using SHA1. This means that any directories using the old form must have their links rebuilt using B<c_rehash> or similar. =head1 COPYRIGHT Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (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 L<https://www.openssl.org/source/license.html>. =cut
pmq20/ruby-compiler
vendor/openssl/doc/man1/x509.pod
Perl
mit
28,780
#!/usr/bin/perl use strict; use warnings; use WWW::Shopify; package WWW::Shopify::Model::Shop; use parent 'WWW::Shopify::Model::Item'; my $fields; sub fields { return $fields; } BEGIN { $fields = { "id" => new WWW::Shopify::Field::Identifier(), "address1" => new WWW::Shopify::Field::String::Address(), "city" => new WWW::Shopify::Field::String::City(), "country" => new WWW::Shopify::Field::String("[A-Z]{3}"), "country_name" => new WWW::Shopify::Field::String::Country(), "country_code" => new WWW::Shopify::Field::String("[A-Z]{3}"), "created_at" => new WWW::Shopify::Field::Date(min => '2010-01-01 00:00:00', max => 'now'), "customer_email" => new WWW::Shopify::Field::String::Email(), "domain" => new WWW::Shopify::Field::String::Hostname(), "email" => new WWW::Shopify::Field::String::Email(), "google_apps_domain" => new WWW::Shopify::Field::String::Hostname::Shopify(), "google_apps_login_enabled" => new WWW::Shopify::Field::Boolean(), "name" => new WWW::Shopify::Field::String::Words(1, 3), "phone" => new WWW::Shopify::Field::String::Phone(), "province" => new WWW::Shopify::Field::String::Words(1), "province_code" => new WWW::Shopify::Field::String("[A-Z]{3}"), "public" => new WWW::Shopify::Field::String(), "source" => new WWW::Shopify::Field::String(), "display_plan_name" => new WWW::Shopify::Field::String(), "zip" => new WWW::Shopify::Field::String("[A-Z][0-9][A-Z] [0-9][A-Z][0-9]"), "currency" => new WWW::Shopify::Field::Currency(), "timezone" => new WWW::Shopify::Field::Timezone(), "latitude" => new WWW::Shopify::Field::Float(), "longitude" => new WWW::Shopify::Field::Float(), "shop_owner" => new WWW::Shopify::Field::String::Name(), "money_format" => new WWW::Shopify::Field::String("\$ \{\{amount\}\}"), "money_with_currency_format" => new WWW::Shopify::Field::String("\$ \{\{amount\}\} USD"), "taxes_included" => new WWW::Shopify::Field::String(), "tax_shipping" => new WWW::Shopify::Field::String(), "plan_name" => new WWW::Shopify::Field::String::Words(1), "myshopify_domain" => new WWW::Shopify::Field::String::Hostname::Shopify(), "metafields" => new WWW::Shopify::Field::Relation::Many("WWW::Shopify::Model::Metafield") }; } sub creatable($) { return undef; } sub updatable($) { return undef; } sub deletable($) { return undef; } sub countable { return undef; } sub is_shop { return 1; } eval(__PACKAGE__->generate_accessors); die $@ if $@; 1
gitpan/WWW-Shopify
lib/WWW/Shopify/Model/Shop.pm
Perl
mit
2,418
#!/usr/bin/perl -w # # searcher_test.pl # # use strict; use warnings; use Cwd 'abs_path'; use File::Basename; my $lib_path; BEGIN { $lib_path = dirname(dirname(abs_path($0))) . '/lib'; # print "lib_path: $lib_path\n"; unshift @INC, $lib_path; } use Test::Simple tests => 89; use plsearch::config; use plsearch::FileUtil; use plsearch::SearchSettings; use plsearch::Searcher; sub get_settings { my $settings = new plsearch::SearchSettings(); $settings->{startpath} = '.'; push(@{$settings->{searchpatterns}}, "Searcher"); return $settings; } sub get_test_file { return "$SHAREDPATH/testFiles/testFile2.txt"; } sub test_validate_settings { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); } ################################################################################ # is_search_dir tests ################################################################################ sub test_is_search_dir_no_patterns { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = 'plsearch'; ok($searcher->is_search_dir($dir), "$dir is search dir with no patterns"); } sub test_is_search_dir_matches_in_pattern { my $settings = get_settings(); push(@{$settings->{in_dirpatterns}}, 'plsearch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = 'plsearch'; ok($searcher->is_search_dir($dir), "$dir matches in_dirpatterns"); } sub test_is_search_dir_no_match_in_pattern { my $settings = get_settings(); push(@{$settings->{in_dirpatterns}}, 'plsearch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = 'pysearch'; ok(!$searcher->is_search_dir($dir), "$dir does not match in_dirpatterns"); } sub test_is_search_dir_matches_out_pattern { my $settings = get_settings(); push(@{$settings->{out_dirpatterns}}, 'pysearch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = 'pysearch'; ok(!$searcher->is_search_dir($dir), "$dir matches out_dirpatterns"); } sub test_is_search_dir_no_match_out_pattern { my $settings = get_settings(); push(@{$settings->{out_dirpatterns}}, 'pysearch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = 'plsearch'; ok($searcher->is_search_dir($dir), "$dir does not match out_dirpatterns"); } sub test_is_search_dir_single_dot { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = '.'; ok($searcher->is_search_dir($dir), "$dir is search dir"); } sub test_is_search_dir_double_dot { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = '..'; ok($searcher->is_search_dir($dir), "$dir is search dir"); } sub test_is_search_dir_hidden_dir { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = '.git'; ok(!$searcher->is_search_dir($dir), "Hidden dir $dir is not search dir by default"); } sub test_is_search_dir_hidden_dir_include_hidden { my $settings = get_settings(); $settings->{excludehidden} = 0; my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $dir = '.git'; ok($searcher->is_search_dir($dir), "Hidden dir $dir is search dir with excludehidden set to false"); } ################################################################################ # is_search_file tests ################################################################################ sub test_is_search_file_matches_by_default { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->is_search_file($file), "$file is search file by default"); } sub test_is_search_file_matches_in_extension { my $settings = get_settings(); push(@{$settings->{in_extensions}}, 'pm'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->is_search_file($file), "$file matches in_extensions"); } sub test_is_search_file_no_match_in_extension { my $settings = get_settings(); push(@{$settings->{in_extensions}}, 'pl'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok(!$searcher->is_search_file($file), "$file does not match in_extensions"); } sub test_is_search_file_matches_out_extension { my $settings = get_settings(); push(@{$settings->{out_extensions}}, 'pm'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok(!$searcher->is_search_file($file), "$file matches out_extensions"); } sub test_is_search_file_no_match_out_extension { my $settings = get_settings(); push(@{$settings->{out_extensions}}, 'py'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->is_search_file($file), "$file does not match out_extensions"); } sub test_is_search_file_matches_in_pattern { my $settings = get_settings(); push(@{$settings->{in_filepatterns}}, 'Search'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'Searcher.pm'; ok($searcher->is_search_file($file), "$file matches in_filepatterns"); } sub test_is_search_file_no_match_in_pattern { my $settings = get_settings(); push(@{$settings->{in_filepatterns}}, 'Search'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok(!$searcher->is_search_file($file), "$file does not match in_filepatterns"); } sub test_is_search_file_matches_out_pattern { my $settings = get_settings(); push(@{$settings->{out_filepatterns}}, 'Search'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'Searcher.pm'; ok(!$searcher->is_search_file($file), "$file matches out_filepatterns"); } sub test_is_search_file_no_match_out_pattern { my $settings = get_settings(); push(@{$settings->{out_filepatterns}}, 'Search'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->is_search_file($file), "$file does not match out_filepatterns"); } ################################################################################ # is__archive_search_file tests ################################################################################ sub test_is_archive_search_file_matches_by_default { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok($searcher->is_archive_search_file($file), "$file is archive search file by default"); } sub test_is_archive_search_file_matches_in_extension { my $settings = get_settings(); push(@{$settings->{in_archiveextensions}}, 'zip'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok($searcher->is_archive_search_file($file), "$file matches in_archiveextensions"); } sub test_is_archive_search_file_no_match_in_extension { my $settings = get_settings(); push(@{$settings->{in_archiveextensions}}, 'gz'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok(!$searcher->is_archive_search_file($file), "$file does not match in_archiveextensions"); } sub test_is_archive_search_file_matches_out_extension { my $settings = get_settings(); push(@{$settings->{out_archiveextensions}}, 'zip'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok(!$searcher->is_archive_search_file($file), "$file matches out_archiveextensions"); } sub test_is_archive_search_file_no_match_out_extension { my $settings = get_settings(); push(@{$settings->{out_archiveextensions}}, 'gz'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok($searcher->is_archive_search_file($file), "$file does not match out_archiveextensions"); } sub test_is_archive_search_file_matches_in_pattern { my $settings = get_settings(); push(@{$settings->{in_archivefilepatterns}}, 'arch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok($searcher->is_archive_search_file($file), "$file matches in_archivefilepatterns"); } sub test_is_archive_search_file_no_match_in_pattern { my $settings = get_settings(); push(@{$settings->{in_archivefilepatterns}}, 'archives'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok(!$searcher->is_archive_search_file($file), "$file does not match in_archivefilepatterns"); } sub test_is_archive_search_file_matches_out_pattern { my $settings = get_settings(); push(@{$settings->{out_archivefilepatterns}}, 'arch'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok(!$searcher->is_archive_search_file($file), "$file matches out_archivefilepatterns"); } sub test_is_archive_search_file_no_match_out_pattern { my $settings = get_settings(); push(@{$settings->{out_archivefilepatterns}}, 'archives'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; ok($searcher->is_archive_search_file($file), "$file does not match out_archivefilepatterns"); } ################################################################################ # filter_file tests ################################################################################ sub test_filter_file_matches_by_default { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->filter_file($file), "$file passes filter_file by default"); } sub test_filter_file_is_search_file { my $settings = get_settings(); push(@{$settings->{in_extensions}}, 'pm'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok($searcher->filter_file($file), "$file passes filter_file when is_search_file"); } sub test_filter_file_not_is_search_file { my $settings = get_settings(); push(@{$settings->{in_extensions}}, 'pl'); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; ok(!$searcher->filter_file($file), "$file does not pass filter_file when !is_search_file"); } sub test_filter_file_is_hidden_file { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = '.gitignore'; ok(!$searcher->filter_file($file), "$file does not pass filter_file when excludehidden=1"); } sub test_filter_file_hidden_includehidden { my $settings = get_settings(); $settings->{excludehidden} = 0; my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = '.gitignore'; ok($searcher->filter_file($file), "$file passes filter_file when hidden and excludehidden=0"); } sub test_filter_file_archive_no_searcharchives { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; #print "searcher->is_archive_search_file(archive.zip): " . $searcher->is_archive_search_file('archive.zip') . "\n"; ok(!$searcher->filter_file($file), "$file does not pass filter_file when searcharchives=0"); } sub test_filter_file_archive_searcharchives { my $settings = get_settings(); $settings->{searcharchives} = 1; my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; #print "searcher->is_archive_search_file(archive.zip): " . $searcher->is_archive_search_file('archive.zip') . "\n"; ok($searcher->filter_file($file), "$file passes filter_file when searcharchives=1"); } sub test_filter_file_archive_archivesonly { my $settings = get_settings(); $settings->{archivesonly} = 1; $settings->{searcharchives} = 1; my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'archive.zip'; #print "searcher->is_archive_search_file(archive.zip): " . $searcher->is_archive_search_file('archive.zip') . "\n"; ok($searcher->filter_file($file), "$file passes filter_file when archivesonly=1"); } sub test_filter_file_nonarchive_archivesonly { my $settings = get_settings(); $settings->{archivesonly} = 1; $settings->{searcharchives} = 1; my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $file = 'FileUtil.pm'; #print "searcher->is_archive_search_file(archive.zip): " . $searcher->is_archive_search_file('archive.zip') . "\n"; ok(!$searcher->filter_file($file), "$file does not pass filter_file when archivesonly=1"); } ################################################################################ # search_lines tests ################################################################################ sub test_search_lines { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $testfile = get_test_file(); my $contents = plsearch::FileUtil::get_file_contents($testfile); my $results = $searcher->search_multiline_string($contents); ok(scalar @{$results} == 2, 'Two search results'); my $firstResult = $results->[0]; ok($firstResult->{linenum} == 29, "First result on line 23"); ok($firstResult->{match_start_index} == 3, "First result match_start_index == 3"); ok($firstResult->{match_end_index} == 11, "First result match_start_index == 11"); my $secondResult = $results->[1]; ok($secondResult->{linenum} == 35, "Second result on line 29"); ok($secondResult->{match_start_index} == 24, "Second result match_start_index == 24"); ok($secondResult->{match_end_index} == 32, "Second result match_start_index == 32"); } ################################################################################ # search_multiline_string tests ################################################################################ sub test_search_multiline_string { my $settings = get_settings(); my ($searcher, $errs) = new plsearch::Searcher($settings); ok(scalar @{$errs} == 0, 'No errors from valid settings'); my $testfile = get_test_file(); my $lines = plsearch::FileUtil::get_file_lines($testfile); my $results = $searcher->search_lines($lines); ok(scalar @{$results} == 2, 'Two search results'); my $firstResult = $results->[0]; ok($firstResult->{linenum} == 29, "First result on line 23"); ok($firstResult->{match_start_index} == 3, "First result match_start_index == 3"); ok($firstResult->{match_end_index} == 11, "First result match_start_index == 11"); my $secondResult = $results->[1]; ok($secondResult->{linenum} == 35, "Second result on line 29"); ok($secondResult->{match_start_index} == 24, "Second result match_start_index == 24"); ok($secondResult->{match_end_index} == 32, "Second result match_start_index == 32"); } ################################################################################ # main ################################################################################ sub main { test_validate_settings(); # 1 test # is_search_dir tests test_is_search_dir_no_patterns(); # 2 tests test_is_search_dir_matches_in_pattern(); # 2 tests test_is_search_dir_no_match_in_pattern(); # 2 tests test_is_search_dir_matches_out_pattern(); # 2 tests test_is_search_dir_no_match_out_pattern(); # 2 tests test_is_search_dir_single_dot(); # 2 tests test_is_search_dir_double_dot(); # 2 tests test_is_search_dir_hidden_dir(); # 2 tests test_is_search_dir_hidden_dir_include_hidden(); # 2 tests # is_search_file tests test_is_search_file_matches_by_default(); # 2 tests test_is_search_file_matches_in_extension(); # 2 tests test_is_search_file_no_match_in_extension(); # 2 tests test_is_search_file_matches_out_extension(); # 2 tests test_is_search_file_no_match_out_extension(); # 2 tests test_is_search_file_matches_in_pattern(); # 2 tests test_is_search_file_no_match_in_pattern(); # 2 tests test_is_search_file_matches_out_pattern(); # 2 tests test_is_search_file_no_match_out_pattern(); # 2 tests # is_archive_search_file tests test_is_archive_search_file_matches_by_default(); # 2 tests test_is_archive_search_file_matches_in_extension(); # 2 tests test_is_archive_search_file_no_match_in_extension(); # 2 tests test_is_archive_search_file_matches_out_extension(); # 2 tests test_is_archive_search_file_no_match_out_extension(); # 2 tests test_is_archive_search_file_matches_in_pattern(); # 2 tests test_is_archive_search_file_no_match_in_pattern(); # 2 tests test_is_archive_search_file_matches_out_pattern(); # 2 tests test_is_archive_search_file_no_match_out_pattern(); # 2 tests # filter_file tests test_filter_file_matches_by_default(); # 2 tests test_filter_file_is_search_file(); # 2 tests test_filter_file_not_is_search_file(); # 2 tests test_filter_file_is_hidden_file(); # 2 tests test_filter_file_hidden_includehidden(); # 2 tests test_filter_file_archive_no_searcharchives(); # 2 tests test_filter_file_archive_searcharchives(); # 2 tests test_filter_file_archive_archivesonly(); # 2 tests test_filter_file_nonarchive_archivesonly(); # 2 tests # search_lines tests test_search_lines(); # 8 tests # search_multiline_string tests test_search_multiline_string(); # 8 tests } main();
clarkcb/xsearch
perl/plsearch/t/searcher_test.pl
Perl
mit
20,523
# 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 debian/tzdata/northamerica. Olson data version 2008c # # Do not edit this file directly. # package DateTime::TimeZone::America::Havana; use strict; use Class::Singleton; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::America::Havana::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, 59611181368, DateTime::TimeZone::NEG_INFINITY, 59611161600, -19768, 0, 'LMT' ], [ 59611181368, 60732869376, 59611161592, 60732849600, -19776, 0, 'HMT' ], [ 60732869376, 60824149200, 60732851376, 60824131200, -18000, 0, 'CT' ], [ 60824149200, 60834686400, 60824134800, 60834672000, -14400, 1, 'CDT' ], [ 60834686400, 61202149200, 60834668400, 61202131200, -18000, 0, 'CST' ], [ 61202149200, 61210008000, 61202134800, 61209993600, -14400, 1, 'CDT' ], [ 61210008000, 61233598800, 61209990000, 61233580800, -18000, 0, 'CST' ], [ 61233598800, 61242062400, 61233584400, 61242048000, -14400, 1, 'CDT' ], [ 61242062400, 61265653200, 61242044400, 61265635200, -18000, 0, 'CST' ], [ 61265653200, 61273512000, 61265638800, 61273497600, -14400, 1, 'CDT' ], [ 61273512000, 61360002000, 61273494000, 61359984000, -18000, 0, 'CST' ], [ 61360002000, 61367860800, 61359987600, 61367846400, -14400, 1, 'CDT' ], [ 61367860800, 61391451600, 61367842800, 61391433600, -18000, 0, 'CST' ], [ 61391451600, 61399310400, 61391437200, 61399296000, -14400, 1, 'CDT' ], [ 61399310400, 61990981200, 61399292400, 61990963200, -18000, 0, 'CST' ], [ 61990981200, 62001432000, 61990966800, 62001417600, -14400, 1, 'CDT' ], [ 62001432000, 62022258000, 62001414000, 62022240000, -18000, 0, 'CST' ], [ 62022258000, 62033140800, 62022243600, 62033126400, -14400, 1, 'CDT' ], [ 62033140800, 62049387600, 62033122800, 62049369600, -18000, 0, 'CST' ], [ 62049387600, 62062776000, 62049373200, 62062761600, -14400, 1, 'CDT' ], [ 62062776000, 62081528400, 62062758000, 62081510400, -18000, 0, 'CST' ], [ 62081528400, 62094225600, 62081514000, 62094211200, -14400, 1, 'CDT' ], [ 62094225600, 62114187600, 62094207600, 62114169600, -18000, 0, 'CST' ], [ 62114187600, 62129908800, 62114173200, 62129894400, -14400, 1, 'CDT' ], [ 62129908800, 62145637200, 62129890800, 62145619200, -18000, 0, 'CST' ], [ 62145637200, 62161358400, 62145622800, 62161344000, -14400, 1, 'CDT' ], [ 62161358400, 62177086800, 62161340400, 62177068800, -18000, 0, 'CST' ], [ 62177086800, 62193412800, 62177072400, 62193398400, -14400, 1, 'CDT' ], [ 62193412800, 62209141200, 62193394800, 62209123200, -18000, 0, 'CST' ], [ 62209141200, 62223048000, 62209126800, 62223033600, -14400, 1, 'CDT' ], [ 62223048000, 62240590800, 62223030000, 62240572800, -18000, 0, 'CST' ], [ 62240590800, 62254584000, 62240576400, 62254569600, -14400, 1, 'CDT' ], [ 62254584000, 62272040400, 62254566000, 62272022400, -18000, 0, 'CST' ], [ 62272040400, 62286120000, 62272026000, 62286105600, -14400, 1, 'CDT' ], [ 62286120000, 62303490000, 62286102000, 62303472000, -18000, 0, 'CST' ], [ 62303490000, 62319211200, 62303475600, 62319196800, -14400, 1, 'CDT' ], [ 62319211200, 62334939600, 62319193200, 62334921600, -18000, 0, 'CST' ], [ 62334939600, 62351265600, 62334925200, 62351251200, -14400, 1, 'CDT' ], [ 62351265600, 62366389200, 62351247600, 62366371200, -18000, 0, 'CST' ], [ 62366389200, 62382715200, 62366374800, 62382700800, -14400, 1, 'CDT' ], [ 62382715200, 62399048400, 62382697200, 62399030400, -18000, 0, 'CST' ], [ 62399048400, 62412350400, 62399034000, 62412336000, -14400, 1, 'CDT' ], [ 62412350400, 62426264400, 62412332400, 62426246400, -18000, 0, 'CST' ], [ 62426264400, 62444404800, 62426250000, 62444390400, -14400, 1, 'CDT' ], [ 62444404800, 62457714000, 62444386800, 62457696000, -18000, 0, 'CST' ], [ 62457714000, 62475854400, 62457699600, 62475840000, -14400, 1, 'CDT' ], [ 62475854400, 62494002000, 62475836400, 62493984000, -18000, 0, 'CST' ], [ 62494002000, 62507304000, 62493987600, 62507289600, -14400, 1, 'CDT' ], [ 62507304000, 62525451600, 62507286000, 62525433600, -18000, 0, 'CST' ], [ 62525451600, 62538753600, 62525437200, 62538739200, -14400, 1, 'CDT' ], [ 62538753600, 62556901200, 62538735600, 62556883200, -18000, 0, 'CST' ], [ 62556901200, 62570203200, 62556886800, 62570188800, -14400, 1, 'CDT' ], [ 62570203200, 62588350800, 62570185200, 62588332800, -18000, 0, 'CST' ], [ 62588350800, 62602257600, 62588336400, 62602243200, -14400, 1, 'CDT' ], [ 62602257600, 62619800400, 62602239600, 62619782400, -18000, 0, 'CST' ], [ 62619800400, 62633707200, 62619786000, 62633692800, -14400, 1, 'CDT' ], [ 62633707200, 62647016400, 62633689200, 62646998400, -18000, 0, 'CST' ], [ 62647016400, 62665156800, 62647002000, 62665142400, -14400, 1, 'CDT' ], [ 62665156800, 62678466000, 62665138800, 62678448000, -18000, 0, 'CST' ], [ 62678466000, 62696606400, 62678451600, 62696592000, -14400, 1, 'CDT' ], [ 62696606400, 62710520400, 62696588400, 62710502400, -18000, 0, 'CST' ], [ 62710520400, 62728056000, 62710506000, 62728041600, -14400, 1, 'CDT' ], [ 62728056000, 62741970000, 62728038000, 62741952000, -18000, 0, 'CST' ], [ 62741970000, 62759505600, 62741955600, 62759491200, -14400, 1, 'CDT' ], [ 62759505600, 62774629200, 62759487600, 62774611200, -18000, 0, 'CST' ], [ 62774629200, 62791560000, 62774614800, 62791545600, -14400, 1, 'CDT' ], [ 62791560000, 62806683600, 62791542000, 62806665600, -18000, 0, 'CST' ], [ 62806683600, 62823013200, 62806669200, 62822998800, -14400, 1, 'CDT' ], [ 62823013200, 62838133200, 62822995200, 62838115200, -18000, 0, 'CST' ], [ 62838133200, 62854462800, 62838118800, 62854448400, -14400, 1, 'CDT' ], [ 62854462800, 62869582800, 62854444800, 62869564800, -18000, 0, 'CST' ], [ 62869582800, 62885912400, 62869568400, 62885898000, -14400, 1, 'CDT' ], [ 62885912400, 62901032400, 62885894400, 62901014400, -18000, 0, 'CST' ], [ 62901032400, 62917362000, 62901018000, 62917347600, -14400, 1, 'CDT' ], [ 62917362000, 62932482000, 62917344000, 62932464000, -18000, 0, 'CST' ], [ 62932482000, 62948811600, 62932467600, 62948797200, -14400, 1, 'CDT' ], [ 62948811600, 62964536400, 62948793600, 62964518400, -18000, 0, 'CST' ], [ 62964536400, 62980261200, 62964522000, 62980246800, -14400, 1, 'CDT' ], [ 62980261200, 62995986000, 62980243200, 62995968000, -18000, 0, 'CST' ], [ 62995986000, 63012315600, 62995971600, 63012301200, -14400, 1, 'CDT' ], [ 63012315600, 63026830800, 63012297600, 63026812800, -18000, 0, 'CST' ], [ 63026830800, 63044974800, 63026816400, 63044960400, -14400, 1, 'CDT' ], [ 63044974800, 63058280400, 63044956800, 63058262400, -18000, 0, 'CST' ], [ 63058280400, 63077029200, 63058266000, 63077014800, -14400, 1, 'CDT' ], [ 63077029200, 63090334800, 63077011200, 63090316800, -18000, 0, 'CST' ], [ 63090334800, 63108478800, 63090320400, 63108464400, -14400, 1, 'CDT' ], [ 63108478800, 63121784400, 63108460800, 63121766400, -18000, 0, 'CST' ], [ 63121784400, 63139928400, 63121770000, 63139914000, -14400, 1, 'CDT' ], [ 63139928400, 63153838800, 63139910400, 63153820800, -18000, 0, 'CST' ], [ 63153838800, 63171378000, 63153824400, 63171363600, -14400, 1, 'CDT' ], [ 63171378000, 63185288400, 63171360000, 63185270400, -18000, 0, 'CST' ], [ 63185288400, 63202827600, 63185274000, 63202813200, -14400, 1, 'CDT' ], [ 63202827600, 63216738000, 63202809600, 63216720000, -18000, 0, 'CST' ], [ 63216738000, 63297781200, 63216723600, 63297766800, -14400, 1, 'CDT' ], [ 63297781200, 63309272400, 63297763200, 63309254400, -18000, 0, 'CST' ], [ 63309272400, 63329230800, 63309258000, 63329216400, -14400, 1, 'CDT' ], [ 63329230800, 63341326800, 63329212800, 63341308800, -18000, 0, 'CST' ], [ 63341326800, 63360680400, 63341312400, 63360666000, -14400, 1, 'CDT' ], [ 63360680400, 63372776400, 63360662400, 63372758400, -18000, 0, 'CST' ], [ 63372776400, 63392130000, 63372762000, 63392115600, -14400, 1, 'CDT' ], [ 63392130000, 63404830800, 63392112000, 63404812800, -18000, 0, 'CST' ], [ 63404830800, 63424184400, 63404816400, 63424170000, -14400, 1, 'CDT' ], [ 63424184400, 63436280400, 63424166400, 63436262400, -18000, 0, 'CST' ], [ 63436280400, 63455634000, 63436266000, 63455619600, -14400, 1, 'CDT' ], [ 63455634000, 63467730000, 63455616000, 63467712000, -18000, 0, 'CST' ], [ 63467730000, 63487083600, 63467715600, 63487069200, -14400, 1, 'CDT' ], [ 63487083600, 63499179600, 63487065600, 63499161600, -18000, 0, 'CST' ], [ 63499179600, 63518533200, 63499165200, 63518518800, -14400, 1, 'CDT' ], [ 63518533200, 63530629200, 63518515200, 63530611200, -18000, 0, 'CST' ], [ 63530629200, 63549982800, 63530614800, 63549968400, -14400, 1, 'CDT' ], [ 63549982800, 63562078800, 63549964800, 63562060800, -18000, 0, 'CST' ], [ 63562078800, 63581432400, 63562064400, 63581418000, -14400, 1, 'CDT' ], [ 63581432400, 63594133200, 63581414400, 63594115200, -18000, 0, 'CST' ], [ 63594133200, 63613486800, 63594118800, 63613472400, -14400, 1, 'CDT' ], [ 63613486800, 63625582800, 63613468800, 63625564800, -18000, 0, 'CST' ], [ 63625582800, 63644936400, 63625568400, 63644922000, -14400, 1, 'CDT' ], [ 63644936400, 63657032400, 63644918400, 63657014400, -18000, 0, 'CST' ], [ 63657032400, 63676386000, 63657018000, 63676371600, -14400, 1, 'CDT' ], [ 63676386000, 63688482000, 63676368000, 63688464000, -18000, 0, 'CST' ], [ 63688482000, 63707835600, 63688467600, 63707821200, -14400, 1, 'CDT' ], ]; sub olson_version { '2008c' } sub has_dst_changes { 59 } sub _max_year { 2018 } sub _new_instance { return shift->_init( @_, spans => $spans ); } sub _last_offset { -18000 } my $last_observance = bless( { 'format' => 'C%sT', 'gmtoff' => '-5:00', 'local_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 702926, 'local_rd_secs' => 44976, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 702926, 'utc_rd_secs' => 44976, 'utc_year' => 1926 }, 'DateTime' ), 'offset_from_std' => 0, 'offset_from_utc' => -18000, 'until' => [], 'utc_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 702926, 'local_rd_secs' => 62976, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 702926, 'utc_rd_secs' => 62976, 'utc_year' => 1926 }, 'DateTime' ) }, 'DateTime::TimeZone::OlsonDB::Observance' ) ; sub _last_observance { $last_observance } my $rules = [ bless( { 'at' => '0:00s', 'from' => '2008', 'in' => 'Mar', 'letter' => 'D', 'name' => 'Cuba', 'offset_from_std' => 3600, 'on' => 'Sun>=15', 'save' => '1:00', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ), bless( { 'at' => '0:00s', 'from' => '2006', 'in' => 'Oct', 'letter' => 'S', 'name' => 'Cuba', 'offset_from_std' => 0, 'on' => 'lastSun', 'save' => '0', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ) ] ; sub _rules { $rules } 1;
carlgao/lenga
images/lenny64-peon/usr/share/perl5/DateTime/TimeZone/America/Havana.pm
Perl
mit
12,213
#!/usr/bin/perl use strict; use Data::Dumper; # This script expects MNIST data in CSV format # as downloaded from https://www.kaggle.com/c/digit-recognizer/data. # It outputs three datasets in Lua format: # - train - training data containing all except $NewClasses classes/labels # - test - test data containing the same classes and $testratio of the available data # - new - the remaining $NewClasses classes for evaluating the model on unseen classes my $infilename = 'data/mnist/train.csv'; # input file, the MNIST data in CSV format my $TestRatio = 0.3; # The ratio of items to add to the test set my $Classes = [0,1,2,4,5,6,8,9,3,7]; # The MNIST classes reordered so that new classes would be at the end my $NewClasses = 2; # Number of classes at the end of $Classes to include in the new set my $NewRatio = 0.1; # Only add this ratio of items to the "new" set my $NewFromTestRatio = 0.01; # Add this many elements from the test set to the "new" set my $TrainFile = 'data/train.lua'; # Output file my $TestFile = 'data/test.lua'; # Output file my $NewFile = 'data/new.lua'; # Output file my @trainset; my @testset; my @newset; # Used to reorder classes/labels my %Classmap; for (my $i=0; $i<@$Classes; $i++) { $Classmap{$Classes->[$i]} = $i; } # writefile($filename, $contents) sub writefile { my $filename = shift; my $contents = shift; open(my $fh, '>', $filename) or die "Cannot open $filename: $!"; print $fh $contents; close($fh); } # Write Lua code that initialises a Torch tensor with the dataset sub write_lua { my $data = shift; # [ [LABEL,[PIXELS]], ... ] my $filename = shift; # output file my $is_new = shift; # bool; whether we are writing the new dataset my $numclass = $is_new ? ($NewFromTestRatio == 0 ? $NewClasses : 10) : (10 - $NewClasses); my $datasize = scalar(@$data); my $numpixel = scalar(@{$data->[0]->[1]}); my $o = <<THEEND; require 'torch' local x = torch.Tensor($datasize, $numpixel):fill(0) local targetlabels = torch.Tensor($datasize, 1) THEEND # If $is_new, y is unused $o .= $is_new ? "local y = torch.Tensor(1)\n" : "local y = torch.Tensor($datasize, $numclass):fill(-1)\n"; for(my $i=0; $i<$datasize; $i++) { my $ii = $i+1; $o .= "function __mnist${ii}()\n"; for(my $j=0; $j<$numpixel; $j++) { $o .= 'x['.$ii.']['.($j+1).']='.$data->[$i]->[1]->[$j]."\n" if $data->[$i]->[1]->[$j]; } $o .= 'y['.$ii.']['.($data->[$i]->[0]+1)."]=1\n" unless $is_new; $o .= 'targetlabels['.$ii.'][1] = '.($data->[$i]->[0]+1)."\n"; $o .= "end\n__mnist${ii}()\n"; } $o .= "return {numclusters=$numclass,x=x,y=y,targetlabels=targetlabels}\n"; writefile($filename, $o); } # Main code my $header = 1; open(my $fh, '<', $infilename) or die "Cannot open $infilename: $!"; while(<$fh>) { if($header) { $header = 0; next; } s/\s+|\s+$//g; my @line = split(/,/, $_); my $label = $Classmap{shift(@line)}; my $outline = [$label, \@line]; if ($label >= 10 - $NewClasses) { if (rand() < $NewRatio) { push @newset, $outline; } } elsif (rand() < $TestRatio) { if (rand() < $NewFromTestRatio) { push @newset, $outline; } push @testset, $outline; } else { push @trainset, $outline; } } close($fh); print "Train set size " . scalar(@trainset) . "\n"; print "Test set size " . scalar(@testset) . "\n"; print "New set size " . scalar(@newset) . "\n"; write_lua(\@trainset, $TrainFile, 0); write_lua(\@testset, $TestFile, 0); write_lua(\@newset, $NewFile, 1);
csirmaz/TrainableOnlineClustering
mnist-data-convert.pl
Perl
mit
3,578
package # Date::Manip::Offset::off416; # Copyright (c) 2008-2015 Sullivan Beck. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # This file was automatically generated. Any changes to this file will # be lost the next time 'tzdata' is run. # Generated on: Wed Nov 25 11:44:44 EST 2015 # Data version: tzdata2015g # Code version: tzcode2015g # This module contains data from the zoneinfo time zone database. The original # data was obtained from the URL: # ftp://ftp.iana.org/tz use strict; use warnings; require 5.010000; our ($VERSION); $VERSION='6.52'; END { undef $VERSION; } our ($Offset,%Offset); END { undef $Offset; undef %Offset; } $Offset = '-11:01:38'; %Offset = ( 0 => [ 'america/nome', ], ); 1;
jkb78/extrajnm
local/lib/perl5/Date/Manip/Offset/off416.pm
Perl
mit
851
use strict; use utf8; package Dorq::code::block::builtin; use base 'Dorq::code::block'; sub exec { return shift -> val() -> ( @_ ); } -1;
kainwinterheart/dorq-dsl
Dorq/code/block/builtin.pm
Perl
mit
144
# 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::V9::Resources::CurrencyConstant; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { billableUnitMicros => $args->{billableUnitMicros}, code => $args->{code}, name => $args->{name}, resourceName => $args->{resourceName}, symbol => $args->{symbol}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V9/Resources/CurrencyConstant.pm
Perl
apache-2.0
1,222
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package network::aruba::instant::snmp::mode::apusage; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_status_output { my ($self, %options) = @_; my $msg = "Status is '" . $self->{result_values}->{status} . "'"; return $msg; } sub custom_memory_output { my ($self, %options) = @_; my $msg = sprintf("Memory Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), $self->{result_values}->{prct_used}, $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), $self->{result_values}->{prct_free}); return $msg; } sub prefix_ap_output { my ($self, %options) = @_; return "Access Point '" . $options{instance_value}->{display} . "' "; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0 }, { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are ok', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{global} = [ { label => 'total-ap', nlabel => 'accesspoints.total.count', set => { key_values => [ { name => 'total' } ], output_template => 'total access points: %s', perfdatas => [ { template => '%s', min => 0 } ] } } ]; $self->{maps_counters}->{ap} = [ { label => 'status', type => 2, critical_default => '%{status} !~ /up/i', set => { key_values => [ { name => 'status' }, { name => 'display' } ], closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold_ng } }, { label => 'clients', nlabel => 'clients.current.count', set => { key_values => [ { name => 'clients' }, { name => 'display' } ], output_template => 'Current Clients: %s', perfdatas => [ { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cpu', nlabel => 'cpu.utilization.percentage', set => { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'Cpu: %.2f%%', perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'mem-usage', nlabel => 'memory.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'mem-usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'mem-usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Memory Used: %.2f %%', perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } } ]; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { 'filter-name:s' => { name => 'filter_name' } }); return $self; } my $map_ap_status = { 1 => 'up', 2 => 'down' }; my $mapping = { aiAPName => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.2' }, aiAPIPAddress => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.3' }, aiAPCPUUtilization => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.7' }, aiAPMemoryFree => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.8' }, aiAPTotalMemory => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.10' }, aiAPStatus => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1.11', map => $map_ap_status } }; my $oid_aiAccessPointEntry = '.1.3.6.1.4.1.14823.2.3.3.1.2.1.1'; my $oid_aiClientAPIPAddress = '.1.3.6.1.4.1.14823.2.3.3.1.2.4.1.4'; sub manage_selection { my ($self, %options) = @_; my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $oid_aiAccessPointEntry, start => $mapping->{aiAPName}->{oid}, end => $mapping->{aiAPStatus}->{oid} }, { oid => $oid_aiClientAPIPAddress } ] ); my $link_ap = {}; $self->{global} = { total => 0 }; $self->{ap} = {}; foreach my $oid (keys %{$snmp_result->{$oid_aiAccessPointEntry}}) { next if ($oid !~ /^$mapping->{aiAPName}->{oid}\.(.*)$/); my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_aiAccessPointEntry}, instance => $instance); if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $result->{aiAPName} !~ /$self->{option_results}->{filter_name}/) { $self->{output}->output_add(long_msg => "skipping access point '" . $result->{aiAPName} . "'.", debug => 1); next; } $self->{global}->{total}++; $self->{ap}->{ $result->{aiAPName} } = { display => $result->{aiAPName}, status => $result->{aiAPStatus}, cpu => $result->{aiAPCPUUtilization}, clients => 0 }; if (defined($result->{aiAPTotalMemory}) && $result->{aiAPTotalMemory} > 0) { $self->{ap}->{ $result->{aiAPName} }->{free} = $result->{aiAPMemoryFree}; $self->{ap}->{ $result->{aiAPName} }->{total} = $result->{aiAPTotalMemory}; $self->{ap}->{ $result->{aiAPName} }->{used} = $result->{aiAPTotalMemory} - $result->{aiAPMemoryFree}; $self->{ap}->{ $result->{aiAPName} }->{prct_free} = $result->{aiAPMemoryFree} * 100 / $result->{aiAPTotalMemory}; $self->{ap}->{ $result->{aiAPName} }->{prct_used} = 100 - ($result->{aiAPMemoryFree} * 100 / $result->{aiAPTotalMemory}); } $link_ap->{ $result->{aiAPIPAddress} } = $self->{ap}->{$result->{aiAPName}}; } if (scalar(keys %{$snmp_result->{$oid_aiAccessPointEntry}}) == 0 && scalar(keys %{$snmp_result->{$oid_aiClientAPIPAddress}}) > 0) { $self->{ap}->{default} = { display => 'default', clients => 0 }; } foreach my $oid (keys %{$snmp_result->{$oid_aiClientAPIPAddress}}) { my $ap_ipaddress = $snmp_result->{$oid_aiClientAPIPAddress}->{$oid}; if (defined($link_ap->{$ap_ipaddress})) { $link_ap->{$ap_ipaddress}->{clients}++; } else { $self->{ap}->{default}->{clients}++; } } } 1; __END__ =head1 MODE Check access point usage. =over 8 =item B<--filter-counters> Only display some counters (regexp can be used). Example: --filter-counters='^cpu$' =item B<--filter-name> Filter access point name (can be a regexp). =item B<--warning-status> Set warning threshold for status (Default: ''). Can used special variables like: %{status}, %{display} =item B<--critical-status> Set critical threshold for status (Default: '%{status} !~ /up/i'). Can used special variables like: %{status}, %{display} =item B<--warning-*> B<--critical-*> Thresholds. Can be: 'total-ap', 'cpu', 'clients', 'mem-usage' (B), 'mem-usage-free' (B), 'mem-usage-prct' (%). =back =cut
centreon/centreon-plugins
network/aruba/instant/snmp/mode/apusage.pm
Perl
apache-2.0
9,605
#!/usr/bin/perl -w # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/build/trace/tracehash_hb.pl $ # # OpenPOWER HostBoot Project # # COPYRIGHT International Business Machines Corp. 2011,2014 # # 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. # # IBM_PROLOG_END_TAG # File tracehash.pl created by B J Zander. # 05/08/2011 - Update by andrewg to work in host boot environment use strict; sub determine_args(); sub launch_cpp_and_parse($$); sub cpp_dir($); sub read_string_file(); sub collect_files($); sub assimilate_file($); sub hash_strings(); sub write_string_file(); sub help(); select (STDERR); $| = 1; # Make all prints to STDERR flush the buffer immediately select (STDOUT); $| = 1; # Make all prints to STDOUT flush the buffer immediately # Constants my $HEAD_SEP = "|||"; my $HEAD_EYE_CATCHER = "#FSP_TRACE_v"; my $HEAD_BUILD_FLAG = "BUILD:"; my $HEAD_VER_FLAG = 2; my $BB_STRING_FILE = "/opt/fsp/etc/BB_StringFile"; # Global Variables my $debug = 0; my $seperator = "&&&&"; my $file_name = "trexStringFile"; my $in_sand; my ($backing) = $ENV{'bb'}; my $hash_prog = "trexhash"; #default to in path my $build = ""; my ($sandbox) = $ENV{'SANDBOX'} || ""; my ($context) = $ENV{'CONTEXT'} || ""; my ($sandboxbase) = $ENV{'SANDBOXBASE'} || ""; my ($bb); my ($sourcebase) = "$sandboxbase/src"; my ($version) = $HEAD_VER_FLAG; # default to oldest version my ($collect) = 0; my ($INCLUDE, $Arg, $file, $dir, $string_file); my $args = ""; my $fail_on_collision = 0; # 1 = exit with error if hash collision occurs my $hash_filename_too = 0; # 1 = hash is calculated over format string + filename print "sourcebase = $sourcebase\n" if $debug; print "sandbox = $sandbox\n" if $debug; print "backing = $backing\n" if $debug; print "context = $context\n" if $debug; if ($context =~ /x86/) { $bb = "i586-pc-linux-gnu"; } else { $bb = "powerpc-linux"; } if(($sourcebase =~ /\w+/) && ($sandbox =~ /\w+/)) { $INCLUDE = "-I $sandboxbase/export/$context/fips/include -I $backing/export/$context/fips/include -I /opt/fsp/$bb/include/fsp -I/opt/fsp/$bb/include/ -include /opt/fsp/$bb/include/fsp/tracinterface.H"; } else { print "Not in Sandbox so guessing Include Paths...\n" if $debug; $INCLUDE = "-I/opt/fsp/i586-pc-linux-gnu/include/fsp -I/opt/fsp/i586-pc-linux-gnu/include/ -include /opt/fsp/i586-pc-linux-gnu/include/fsp/tracinterface.H"; } # I/P Series work in ODE sandbox env. if ($sandboxbase =~ /\w+/) { $in_sand = 1; print "backing = $backing\n" if $debug; } else { $in_sand = 0; } # Parse the input parameters. while (@ARGV) { $Arg = shift; if ($Arg eq "-h" || $Arg eq "-H") { help(); exit(127); } if ($Arg eq "-f") { $file = shift; next; } if ($Arg eq "-d") { $dir = shift; next; } if ($Arg eq "-s") { $string_file = shift; next; } if ($Arg eq "-c") { $collect = 1; next; } if ($Arg eq "-v") { $debug = 1; print "debug on\n" if $debug; next; } if ($Arg eq "-C") { # fail if a hash collision is detected $fail_on_collision = 1; next; } if ($Arg eq "-F") { # hash is calculated over format string + file name $hash_filename_too = 1; next; } if ($Arg eq "-S") { $BB_STRING_FILE = ""; next; } #just pass it onto compiler $args = $args . " " . $Arg; } print "args = $args\n" if $debug; if (!$file && !$dir && !$in_sand) { help(); exit(127); } ################################# # M A I N # ################################# my $clock = `date`; $build = $HEAD_EYE_CATCHER . "$HEAD_VER_FLAG" . $HEAD_SEP . $clock . $HEAD_SEP . $HEAD_BUILD_FLAG; $build =~ s/\n//g; # Global array to hold the parsed TRAC macro calls. my @strings = (); # Assoc. arrays to hold hash|string values. my %string_file_array = (); my %hash_strings_array = (); # Check all provided arguments and look for defaults if not provided by user determine_args(); # Scan the appropriate files or directories for TRAC macro calls. if (defined $dir) { $build = $build . $dir; # default to put at top of string file if($collect) { collect_files($dir); } else { cpp_dir($dir); # Hash the string that have been scanned. %hash_strings_array = hash_strings(); } } else { $build = $build . $file; # default to put at top of string file if($collect) { assimilate_file($file); } else { # make sure include path includes directory that file is in if($file =~ /^(.+)\/[^\/]+\.C$/) { launch_cpp_and_parse($file,$1); } else { # No path in front of file so it has to be local dir launch_cpp_and_parse($file,"./"); } # Hash the string that have been scanned. %hash_strings_array = hash_strings(); } } # Read the existing string file into memory. %string_file_array = read_string_file(); # Write out the new string file. check for collisions of new/old string here write_string_file(); print "Hashing Started at $clock\n"; $clock = `date`; print "Hashing Finished at $clock\n"; exit 0; ################################# # S U B R O U T I N E S # ################################# #============================================================================= # Enhance usability by figuring out which build env. we are in #============================================================================= sub determine_args() { # Find trexhash program # but only if needed (i.e. not in collect mode) if (!$collect) { my $tmp = `which $hash_prog`; chomp $tmp; if ($tmp eq '') { print STDOUT "\nWarning: Program trexhash does not exist in path.\n" if $debug; $hash_prog = "./trexhash"; $tmp = `which $hash_prog`; chomp $tmp; if ($tmp eq '') { print STDOUT "\nError: Unable to find trexhash \n"; exit(127); } } } # Verify input values. if ((!defined $file) && (!defined $dir)) { if(!($in_sand)) { print STDOUT "\nError: No input directory or file provided as input to scan\n"; exit(127); } # Assume they want sandbox scanned if($collect) { # collect all string files generated by tracepp and merge $dir = "$sandboxbase/obj/"; } else { # generate our own string file by pre-compiling all source code $dir = "$sandboxbase/src/"; } print STDOUT "\n-f <file> or -d <dir> not found...scanning $dir by default\n\n"; } if (!defined $string_file) { if ($in_sand) { # Copy the current string file from backing build into our sandbox system ("cp $backing/obj/$file_name $sandboxbase/obj/$file_name") if !(-e "$sandboxbase/obj/$file_name"); $string_file = "$sandboxbase/obj/$file_name"; } else { $string_file = "./$file_name"; } print STDOUT "-sf <string_file> not specified, using $string_file instead...\n\n" if $debug; } # Try Creating the string file `touch $string_file`; if (! -f $string_file) { print STDOUT "\nError: File $string_file does not exist. Current directory may not be writable.\n\n"; help(); exit(127); } # Make sure trexStringFile is readable/writeable system("chmod ugo+rw $string_file"); } #============================================================================= # Launch cpp script and grab input from it looking for trace calls. #============================================================================= sub launch_cpp_and_parse($$) { my ($l_loc, $l_dir) = @_; print "Processing file $l_loc\n" if $debug; my $cmd = "/usr/bin/cpp $INCLUDE -I $l_dir $args $l_loc|"; print "$cmd\n" if $debug; open(FH,"$cmd") or die ("Cannot open $_:$!,stopped"); # Read through all lines in the file.. my $line = <FH>; while (defined $line) { chop $line; # remove EOL $line =~ s/^\s*//; # remove unneccesary beginning white space. $line =~ s/\s*$//; # remove unneccesary ending white space. # Look for lines that are trace macro calls. #if (/(trace_adal_hash)(\()( *)(".+")(,)(\d)/) #if ($line =~ /(.*?)(trace_adal_hash)(\()( *)(".+")(,)(\d)\)+(.*\d.*)/) while($line =~ m/^(.*?)trace_adal_hash\s*\(\s*(("[^"]*"\s*)+),\s*(\d+)\s*\)(.*)$/) { my ($prefix, $strings, $salt, $suffix) = ($1, $2, $4, $5); print STDOUT "$strings $salt\n" if $debug; $strings =~ s/"\s*$//; # remove trailing " and space $strings =~ s/^"//; # remove leading " $strings =~ s/"\s*"//g; # Check to see if it's contained on a single line, or if we # have to combine lines to get a complete trace call. # Save the macro call so it can be hashed later.. push (@strings, [$l_loc, $strings, $salt]); $line = $suffix; # check rest of line for a second trace call } my $nextline = <FH>; last if !defined $nextline; # if a trace call is spread over multiple lines we have to add the next # line from the source. the only problem is the definition/declaration # of trace_adal_hash: we have to ignore that. we catch that by requiring # a " after the function name. hopefully nobody writes a comment with # a " after the function declaration ... if ($line =~ /trace_adal_hash.*"/) { $line .= $nextline; } else { $line = $nextline; } } close(FH); } #============================================================================= # run cpp on all files in this directory and return the output #============================================================================= sub cpp_dir($) { my ($l_dir) = @_; my @dir_entry; my $l_entry; # Open the directory and read all entry names. opendir ( DH , "$l_dir") or die ("Cannot open $l_dir: $!, stopped"); print STDOUT "Processing directory $l_dir\n" if $debug; @dir_entry = readdir(DH); closedir(DH); while (@dir_entry) { $l_entry = shift(@dir_entry); if ($l_dir =~ m"/$") { $l_entry = "$l_dir$l_entry"; } else { $l_entry = "$l_dir/$l_entry"; } # Is the entry a directory? if (-d $l_entry) { if($l_entry =~ m"/?([^/]+)$") { # check dir we are going into print "dir = $1\n" if $debug; # should we recurse into this directory. if ($1 =~ m/^(\.\.?|sim[ou]|bldv)$/) { next; # skip '.', '..' and some fips dirs } cpp_dir($l_entry); } else { # unable to determine name of dir (no / in filename) # should we recurse into this directory. if ($l_entry =~ m/^(\.\.?|sim[ou]|bldv)$/) { next; # skip '.', '..' and some fips dirs } cpp_dir($l_entry); } } # Is the entry a file? elsif ((-f $l_entry) && ($l_entry =~ m/\.C$/)) { # it's a file so launch_cpp_and_parse($l_entry,$l_dir); } else { # Not a file or directory so ignore it... } } } #============================================================================= # Read in strings from the existing trace string file.... #============================================================================= sub read_string_file() { my %o_strings; my ($line) = ""; my ($l_hash) = ""; my ($l_str) = ""; my ($cur_build) = ""; my ($l_file) = ""; # Make sure we can open each file. open ( FH , "<$string_file") or die ("Cannot open $_: $!, stopped"); $line = <FH>; print "first line in trexStringFile= $line\n" if $debug; if((defined $line) && ($line =~ /^$HEAD_EYE_CATCHER(\d)/)) { $version = $1; print "version = $version\n" if $debug; #Always put latest version in file $line =~ s/^$HEAD_EYE_CATCHER\d/${HEAD_EYE_CATCHER}${HEAD_VER_FLAG}/; # Take previous version in file and use it. $build = $line; chomp($build); $line = <FH>; while (defined $line) { chomp $line; # remove EOL if($version eq "1") { ($l_hash, $l_file ,$l_str) = split(/\|\|/, $line); } elsif($version eq "2") { ($l_hash, $l_str ,$l_file) = split(/\|\|/, $line); } else { print "Unknown version of stringfile $version\n"; exit(127); } $o_strings{$l_hash} = $l_str . "||" . $l_file; $line = <FH>; } } else { # If there is a file then we are dealing with the first # version of trexStringFile so don't look for file name. if ($debug) { print "version 0 stringfile detected: $string_file\n"; } # there is a file and it doesn't have a header $version = 0; while (defined $line) { chomp $line; # remove EOL ($l_hash,$l_str) = split(/\|\|/, $line); $o_strings{$l_hash} =$l_str . "||" . "NO FILE"; $line = <FH>; } } close(FH); #Time to look for a building block string file if($BB_STRING_FILE ne "" and $string_file ne $BB_STRING_FILE and -f $BB_STRING_FILE) { # Make sure we can open the file. open ( FH , "<$BB_STRING_FILE") or die ("Cannot open $_: $!, stopped"); $line = <FH>; print "first line in BB_StringFile = $line\n" if $debug; if((defined $line) && ($line =~ /^$HEAD_EYE_CATCHER(\d)/)) { $version = $1; $line = <FH>; while (defined $line) { chop $line; # remove EOL if($version eq "1") { ($l_hash, $l_file ,$l_str) = split(/\|\|/, $line); } elsif($version eq "2") { ($l_hash, $l_str ,$l_file) = split(/\|\|/, $line); } #($l_hash, $l_file ,$l_str) = split(/\|\|/, $line); $o_strings{$l_hash} = $l_str . "||" . $l_file ; $line = <FH>; } } else { print "*** ERROR: BB_StringFile '$BB_STRING_FILE' should always have version!!!\n" } } else { print "$BB_STRING_FILE is not available\n" if $debug; } #All files are latest version now. $version = $HEAD_VER_FLAG; return %o_strings; } #============================================================================= # Read in strings from the existing trace string file.... #============================================================================= sub collect_files($) { my ($l_dir) = @_; my (@dir_entry); my ($l_entry) = ""; # Open the directory and read all entry names. opendir ( DH , "$l_dir") or die ("Cannot open $l_dir: $!, stopped"); print STDOUT "Processing directory $l_dir\n" if $debug; @dir_entry = readdir(DH); closedir(DH); while (@dir_entry) { $l_entry = shift(@dir_entry); if ($l_dir =~ m"/$") { $l_entry = "$l_dir$l_entry"; } else { $l_entry = "$l_dir/$l_entry"; } # Is the entry a directory? if (-d $l_entry) { # should we recurse into this directory. if ($l_entry =~ m/\/(\.\.?|sim[ou]|bldv)$/) { next; # skip '.', '..' and some fips dirs } collect_files($l_entry); } # Is the entry a file? elsif ((-f $l_entry) && ($l_entry =~ m"\.hash$")) { # it's a file so assimilate_file($l_entry); } else { # Not a file or directory so ignore it... } } } #============================================================================= # Read in data from file and add to master one #============================================================================= sub assimilate_file($) { my ($l_loc) = @_; my (%o_strings); my ($line) = ""; my ($l_hash) = ""; my ($l_str) = ""; my ($l_file) = ""; # Make sure we can open each file. open ( FH , "<$l_loc") or die ("Cannot open $_: $!, stopped"); $line = <FH>; print "Assimilate: first line in $l_loc = $line" if $debug; if((defined $line) && ($line =~ /^$HEAD_EYE_CATCHER(\d)/)) { $version = $1; if ($version eq "1") { if ($hash_filename_too) { print "*** ERROR: hash_filename_too (-F) isn't possible with trace version 1\n"; print " please rebuild all .hash files and global trexStringFile\n"; print " version 1 file is '$l_loc'\n"; exit(127); } } elsif ($version ne "2") { print "Unknown version of stringfile $version\n"; exit(127); } $line = <FH>; while (defined $line) { chop $line; # remove EOL # 64 bit support $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)d\b/\%$1$2$3lld/g; $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)i\b/\%$1$2$3lld/g; $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)u\b/\%$1$2$3llu/g; $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)x\b/\%$1$2$3llx/g; $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)X\b/\%$1$2$3llX/g; $line =~ s/\%p/0x\%llX/g; # Replace pointer format with hex value #print "line: $line\n"; if($version eq "1") { ($l_hash, $l_file ,$l_str) = split(/\|\|/, $line); } elsif($version eq "2") { ($l_hash, $l_str ,$l_file) = split(/\|\|/, $line); } my $newstring = $l_str . "||" . $l_file; if (exists $hash_strings_array{$l_hash}) { my $hashstr1 = $hash_strings_array{$l_hash}; my $hashstr2 = $newstring; if (!$hash_filename_too) { # hash was made over format string only, remove file name $hashstr1 =~ s/\|\|.*$//; $hashstr2 = $l_str; } if ($debug) { print "a_f: compare $hashstr1\n", " vs. $hashstr2\n"; } if ($hashstr1 ne $hashstr2) { print "*** ERROR: HASH Collision! (a_f)\n", " Two different strings have the same hash value ($l_hash)\n", " String 1: $hash_strings_array{$l_hash}\n", " String 2: $newstring\n"; if ($fail_on_collision) { exit(1); } } } $hash_strings_array{$l_hash} = $newstring; $line = <FH>; } } else { # If there is a file then we are dealing with the first # version of trexStringFile so don't look for file name. # these files shouldn't be there anymore. we don't check for collisions here if ($debug) { print "version 0 stringfile detected: $string_file\n"; } if(defined $line) { # there is a file and it doesn't have a header $version = 0; } while (defined $line) { chop $line; # remove EOL ($l_hash,$l_str) = split(/\|\|/, $line); $hash_strings_array{$l_hash} = $l_str . "||" . "NO FILE"; $line = <FH>; } } $version = $HEAD_VER_FLAG; close(FH); } #============================================================================= #============================================================================= sub hash_strings() { my ($hash_val, $l_key, $l_hash, %l_hash_strings); my ($line_feed) = chr(10); my ($l_file_name) = "NO FILENAME"; print "\nHashing printf strings.\n\n"; foreach my $str (@strings) { my $printf_string; $l_file_name = $str->[0]; $printf_string = $str->[1]; $l_key = $str->[2]; print "printf_string = $printf_string\n" if $debug; $printf_string =~ s/"\s?"//g; #multi line traces will have extra " in them $printf_string =~ s/`/\\`/g; # excape ' $printf_string =~ s/\\n/$line_feed/g; # escape \n if ($hash_filename_too) { $printf_string .= "||" . $l_file_name; } # call the hasher. print "$hash_prog \"$printf_string\" $l_key\n" if $debug; $hash_val = `$hash_prog \"$printf_string\" $l_key`; if ($?) { my ($hp_ret, $hp_sig) = ($? >> 8, $? & 127); if ($hp_sig) { print "*** ERROR: $hash_prog died with signal $hp_sig\n"; } elsif ($hp_ret) { print "*** ERROR: $hash_prog returned the error $hp_ret\n"; if ($hash_val) { print " error from $hash_prog:\n$hash_val"; } } exit(1); } print "printf_string = $printf_string l_key = $l_key hash val = $hash_val\n" if $debug; # undo escaping $printf_string =~ s/$line_feed/\\n/g; $printf_string =~ s/\\`/`/g; if (exists $l_hash_strings{$hash_val}) { # hash val was found before. check if it's the same string # else we have a hash collision my $l_tmp = $l_hash_strings{$hash_val}; if (!$hash_filename_too) { $l_tmp =~ s/\|\|.*$//; } if ($l_tmp ne $printf_string) { print "*** ERROR: HASH Collision! (h_s)\n", " Two different strings have the same hash value ($hash_val)\n", " String 1: $l_hash_strings{$hash_val}\n", " String 2: $printf_string (file $l_file_name)\n"; if ($fail_on_collision) { exit(1); } } } # this will overwrite an old string with a new one if a collision occurred # but we might want to bail out in this case anyway $printf_string = $printf_string . "||" . $l_file_name; $l_hash_strings{$hash_val} = $printf_string; } return %l_hash_strings; } #============================================================================= #============================================================================= sub write_string_file() { my (@keys) = (); my ($l_key) = ""; # Combine the contents of the existing string file with the trace calls # that we have just hashed. print STDOUT "\nCombining Hash strings...\n\n"; @keys = keys(%hash_strings_array); foreach $l_key (@keys) { my $l_tmp = $hash_strings_array{$l_key}; # freshly collected strings if (exists $string_file_array{$l_key}) { # hash exists in list from trexStringFile my $l_tmp2 = $string_file_array{$l_key}; if (!$hash_filename_too) { $l_tmp =~ s/\|\|.*$//; $l_tmp2 =~ s/\|\|.*$//; } # Check for hash collisions. if ($l_tmp ne $l_tmp2) { print "*** ERROR: HASH Collision! (w_s_f)\n", " Two different strings have the same hash value ($l_key)\n", " String 1: $hash_strings_array{$l_key}\n", " String 2: $string_file_array{$l_key}\n"; if ($fail_on_collision) { exit(1); } # don't fail, write new one } } if($version > 0) { # add/replace the new string to the string_file_array. $string_file_array{$l_key} = $hash_strings_array{$l_key} } else { # old version so only write out format string (not file name to) $string_file_array{$l_key} = $l_tmp; } } # Write out the updated string file. print STDOUT "\nWriting updated hash||string file ($string_file)...\n\n"; @keys = sort(keys(%string_file_array)); open ( FH , ">$string_file") or die ("Cannot open $_: $!, stopped"); if($version > 0) { print FH "$build\n"; # only print version if newer then version 0 } foreach $l_key (@keys) { print FH "$l_key||$string_file_array{$l_key}\n"; } close FH; } #============================================================================= #============================================================================= # Display command invokation help for this program... #============================================================================= sub help() { print << "EOF"; tracehash.pl - create a trace string file from sources or collect tracepp files Usage: tracehash.pl [options] General options: -h - Print this help text. -v - Be verbose, tell what's going on (debug output) Operation modes -c - Collect StringFiles created by tracepp and merge. default - Scan source files for trace calls. Collect mode: tracehash.pl -c [-vFCS] [-d <dir>] [-s <string_file>] tracehash.pl -c [-vFCS] [-f <file>] [-s <string_file>] Collect string files created by tracepp (.hash) from directory tree at <dir> or read them from string file <file> and write to file <string_file>, adding entries already in this file. -f - String file to read and write/add to <string_file>. -d - Start of directory tree to scan for .hash files. Default = . -s - File with trace strings (and hashes) to read from and write to default = ./trexStringFile -F - hash is calculated over trace string and source file name, otherwise without source file name -C - report an error if a hash collisions occurs -S - don't read global FLD-2.2 string file ($BB_STRING_FILE) If tracehash.pl is called in a FipS build sandbox without -d and -f defaults for the sandbox will be used. Scan mode: tracehash.pl [-vFCS] [-d <dir>] [-s <string_file>] [ccpopts] tracehash.pl [-vFCS] [-f <file>] [-s <string_file>] [cppopts] Scan all files in directory tree <dir> or scan file <file> and write strings to file <string_file>. Strings already in this file will be merged. -f - Source file to scan for trace entries. -d - Source directory to scan for trace entries. -s - File with trace strings (and hashes) to read from and write to. default = ./trexStringFile -F - hash for string was build from format string + source file name -C - report an error if hash collisions occur -S - don't read global FLD-2.2 string file ($BB_STRING_FILE) All other arguments will be passed verbatim to cpp EOF } #=============================================================================
shenki/hostboot
src/build/trace/tracehash_hb.pl
Perl
apache-2.0
25,552
package Paws::GameLift::AttributeValue; use Moose; has N => (is => 'ro', isa => 'Num'); has S => (is => 'ro', isa => 'Str'); has SDM => (is => 'ro', isa => 'Paws::GameLift::StringDoubleMap'); has SL => (is => 'ro', isa => 'ArrayRef[Str|Undef]'); 1; ### main pod documentation begin ### =head1 NAME Paws::GameLift::AttributeValue =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::GameLift::AttributeValue object: $service_obj->Method(Att1 => { N => $value, ..., SL => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::GameLift::AttributeValue object: $result = $service_obj->Method(...); $result->Att1->N =head1 DESCRIPTION Values for use in Player attribute type:value pairs. This object lets you specify an attribute value using any of the valid data types: string, number, string array or data map. Each C<AttributeValue> object can use only one of the available properties. =head1 ATTRIBUTES =head2 N => Num For number values, expressed as double. =head2 S => Str For single string values. Maximum string length is 100 characters. =head2 SDM => L<Paws::GameLift::StringDoubleMap> For a map of up to 10 type:value pairs. Maximum length for each string value is 100 characters. =head2 SL => ArrayRef[Str|Undef] For a list of up to 10 strings. Maximum length for each string is 100 characters. Duplicate values are not recognized; all occurrences of the repeated value after the first of a repeated value are ignored. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::GameLift> =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
ioanrogers/aws-sdk-perl
auto-lib/Paws/GameLift/AttributeValue.pm
Perl
apache-2.0
2,111
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2017] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut # POD documentation - main docs before the code =head1 NAME Bio::EnsEMBL::Compara::Production::EPOanchors::HMMerAnchors =head1 SYNOPSIS $exonate_anchors->fetch_input(); $exonate_anchors->run(); $exonate_anchors->write_output(); writes to database =head1 DESCRIPTION Given a database with anchor sequences and a target genome. This modules exonerates the anchors against the target genome. The required information (anchor batch size, target genome file, exonerate parameters are provided by the analysis, analysis_job and analysis_data tables =head1 AUTHOR Stephen Fitzgerald =head1 CONTACT This modules is part of the EnsEMBL project (http://www.ensembl.org) Questions can be posted to the ensembl-dev mailing list: http://lists.ensembl.org/mailman/listinfo/dev =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut package Bio::EnsEMBL::Compara::Production::EPOanchors::HMMerAnchors; use strict; use warnings; use Bio::AlignIO; use Bio::EnsEMBL::Utils::Exception qw(throw); use base('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable'); sub param_defaults { return { 'nhmmer' => '/software/ensembl/compara/hmmer-3.1b1/binaries/nhmmer', 'hmmbuild' => '/software/ensembl/compara/hmmer-3.1b1/binaries/hmmbuild', }; } sub fetch_input { my ($self) = @_; $self->compara_dba->dbc->disconnect_if_idle(); my $genomic_align_block_adaptor = $self->compara_dba->get_GenomicAlignBlockAdaptor(); my $align_slice_adaptor = $self->compara_dba->get_AlignSliceAdaptor(); my $analysis_data_adaptor = $self->db->get_AnalysisDataAdaptor(); my $target_genome_files = eval $analysis_data_adaptor->fetch_by_dbID($self->param('analysis_data_id') ); $self->param('target_file', $target_genome_files->{target_genomes}->{ $self->param('target_genome_db_id') } ); my $genomic_align_block_id = $self->param('genomic_align_block_id'); my $genomic_align_block = $genomic_align_block_adaptor->fetch_by_dbID($genomic_align_block_id); $self->param('anchor_id', $genomic_align_block_id ); my $align_slice = $align_slice_adaptor->fetch_by_GenomicAlignBlock($genomic_align_block, 1, 0); my $simple_align = $align_slice->get_SimpleAlign(); my $stockholm_file = $self->worker_temp_directory . "stockholm." . $genomic_align_block_id; #print genomic_align_block in stockholm format open F, ">$stockholm_file" || throw("Couldn't open $stockholm_file"); print F "# STOCKHOLM 1.0\n"; foreach my $seq( $simple_align->each_seq) { print F $genomic_align_block->dbID . "/" . $seq->display_id . "\t" . $seq->seq . "\n"; } print F "//\n"; close(F); #build the hmm from the stockholm format file my $hmmbuild_outfile = $self->worker_temp_directory . "$genomic_align_block_id.hmm"; my $hmmbuild = $self->param('hmmbuild'); my $hmmbuild_command = "$hmmbuild --dna $hmmbuild_outfile $stockholm_file"; system($hmmbuild_command); $self->param('query_file', $hmmbuild_outfile); } sub run { my ($self) = @_; my $nhmmer_command = join(" ", $self->param('nhmmer'), "--noali", $self->param('query_file'), $self->param('target_file') ); my $exo_fh; open( $exo_fh, "$nhmmer_command |" ) or throw("Error opening nhmmer command: $? $!"); #run nhmmer $self->param('exo_file', $exo_fh); } sub write_output { my ($self) = @_; my $anchor_align_adaptor = $self->compara_dba->get_AnchorAlignAdaptor(); my $exo_fh = $self->param('exo_file'); my (@hits, %hits); { local $/ = ">>"; while(my $mapping = <$exo_fh>){ next unless $mapping=~/!/; push(@hits, $mapping); } } foreach my $hit( @hits ){ my($target_info, $mapping_info) = (split("\n", $hit))[0,3]; my($coor_sys, $species, $seq_region_name) = (split(":", $target_info))[0,1,2]; my($score, $evalue, $alifrom, $alito) = (split(/ +/, $mapping_info))[2,4,8,9]; my $strand = $alifrom > $alito ? "-1" : "1"; ($alifrom, $alito) = ($alito, $alifrom) if $strand eq "-1"; my $dnafrag_adaptor = $self->compara_dba->get_DnaFragAdaptor(); my $dnafrag_id = $dnafrag_adaptor->fetch_by_GenomeDB_and_name($self->param('target_genome_db_id'), $seq_region_name)->dbID; push(@{ $hits{$self->param('anchor_id')} }, [ $dnafrag_id, $alifrom, $alito, $strand, $score, $evalue ]); } # $anchor_align_adaptor->store_exonerate_hits($records); } 1;
danstaines/ensembl-compara
modules/Bio/EnsEMBL/Compara/Production/EPOanchors/HMMerAnchors.pm
Perl
apache-2.0
5,004
#!/usr/bin/perl use strict; use warnings; use File::Basename; use WebService::TVDB; require File::HomeDir; require File::Spec; use File::Copy; use Getopt::Long; my $script = basename($0); my $HMT = '/usr/local/bin/hmt-linux'; my $SYNTAX = "$script [-n] <filename>\n\n\t-n\tDon't rename files, just print the changes\n"; my $VERBOSE = 0; my ($no,$title); GetOptions ( "series=s" => \$title, # string "verbose" => \$VERBOSE, "n" => \$no); # flag my @files = @ARGV; scalar @files || die $SYNTAX; my $keyfile = File::Spec->catfile(File::HomeDir->my_home, '.tvdb'); -f $keyfile || die "No TVDB API key file exists: $keyfile\n"; my $tvdb = WebService::TVDB->new(language => 'English', max_retries => 3); my $langob = $WebService::TVDB::Languages::languages->{$tvdb->language} || die "Unknown language: $tvdb->language. Your TVDB API may not be installed correctly.\n"; my $series_cache = {}; for my $fn (@files) { process_file($fn); } sub process_file { my ($fn) = @_; (undef, my $filedir, undef) = File::Spec->splitpath($fn); my $filebase = $fn; $filebase =~ s/(hmt|nts|thm|ts)$//; $filebase =~ s/\.$//; my $tabs = `$HMT -p "$filebase.hmt"` || die "Unable to run $HMT\n"; my @fields = split /\t/, $tabs; # Title, Synopsis, HD/SD, LCN, Channel Name, Start time, End time, Flags, Guidance, Number of bookmarks, Scheduled start, Scheduled duration, Genre code my $eptitle; if (!$title) { $title = $fields[0]; } else { $eptitle = $fields[0]; } my $synopsis = $fields[1]; my $guidance = $fields[8]; my $desc = $synopsis; # Clean tags from end of synopsis $desc =~ s/\[HD\]//; $desc =~ s/\[S\]//; $desc =~ s/\s+$//; if ($guidance) { $desc =~ s/ $guidance//; } my ($ep, $eptotal, ) = $desc =~ m/^(\d+)\/(\d+)\.\s+/; if ($ep && $eptotal) { $desc =~ s/^\d+\/\d+\.\s+//; } my ($tmp) = $desc =~ m/^([^:]+)\:\s+\w+/; if ($tmp) { $eptitle = $tmp; $desc =~ s/^$eptitle\:\s+//; } if ($VERBOSE) { my $s = "Using series '$title' episode"; if ($ep) { $s .= " $ep"; if ($eptotal) { $s .= " of $eptotal"; } } $s .= " '$eptitle'\n"; print $s; } my $lang = $langob->{name}; my $langabb = $langob->{abbreviation}; my $series = $series_cache->{$title}; if (!$series) { $VERBOSE && print "Searching TVDB ($lang/$langabb)\n"; my $series_list = $tvdb->search($title); $series = $series_list->[0]; if (!$series) { $series_cache->{$title} = $series = 'FAIL'; } else { $VERBOSE && print "Series ID: $series->{id}\n"; # Get all the data $series->fetch(); $series_cache->{$title} = $series; } } if ($series eq 'FAIL') { print "Unable to find series with name \"$title\"\n"; return 1; } my @episodes = grep { $_->{EpisodeNumber} } @{ $series->episodes() || [] }; my $episode; for my $tmp_episode (@episodes) { my $eptA = transform_eptitle($eptitle); my $eptB = transform_eptitle($tmp_episode->{EpisodeName}); if ( ($ep && $tmp_episode->{EpisodeNumber} == $ep) || ($eptA && $eptB && $eptA eq $eptB) ) { $episode = $tmp_episode; last; } } if ($episode) { my $newbase; if (!$episode->{EpisodeName}) { $VERBOSE && printf "Found episode %d (%d)\n", $episode->{EpisodeNumber}, $episode->{id}; $newbase = $filedir . sprintf '%s.S%02dE%02d', $title, $episode->{SeasonNumber}, $episode->{EpisodeNumber}; } else { $VERBOSE && printf "Found episode %d - %s (%d)\n", $episode->{EpisodeNumber}, $episode->{EpisodeName}, $episode->{id}; $newbase = $filedir . sprintf '%s.S%02dE%02d.%s', $title, $episode->{SeasonNumber}, $episode->{EpisodeNumber}, $episode->{EpisodeName}; } print "$filebase will be renamed: $newbase\n"; for my $ext (qw(hmt thm nts ts)) { my $oldfile = "$filebase.$ext"; my $newfile = "$newbase.$ext"; if (!$no) { move($oldfile, $newfile) || die "Unable to rename $oldfile to $newfile\n"; } } } else { print "$filebase will not be renamed\n"; } } # end process_file sub transform_eptitle { my $eptitle = shift; $eptitle || return q[]; $eptitle = lc $eptitle; $eptitle =~ s/\s+and\s+/ \& /g; $eptitle =~ s/\s+the\s+//g; $eptitle =~ s/^the\s+//g; $eptitle =~ s/[^a-z0-9\s\&]//g; $eptitle =~ s/\s//g; # $VERBOSE && print "Comparing title: $eptitle\n"; return $eptitle; }
andyjenkinson/hmt-rename
hmt-rename.pl
Perl
apache-2.0
4,335
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2021] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package XrefMapper::Methods::ExonerateGappedBest5_55_perc_id; use XrefMapper::Methods::ExonerateBasic; use vars '@ISA'; @ISA = qw{XrefMapper::Methods::ExonerateBasic}; sub options { return ('--gappedextension FALSE', '--model', 'affine:local', '--subopt', 'no', '--bestn', '5'); } sub query_identity_threshold { return 55; } sub target_identity_threshold { return 55; } 1;
Ensembl/ensembl
misc-scripts/xref_mapping/XrefMapper/Methods/ExonerateGappedBest5_55_perc_id.pm
Perl
apache-2.0
1,101
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2021] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut =pod =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =head1 NAME Bio::EnsEMBL::Production::Pipeline::Flatfile::ValidatorFactoryMethod - FlatFile validator factory =head1 SYNOPSIS my $factory = Bio::EnsEMBL::Production::Pipeline::FlatFile::ValidatorFactoryMethod->new(); my $embl_validator = $factory->create_instance('embl'); =head1 DESCRIPTION Implementation of the factory method pattern to create instances of Validator subclasses. At the moment, the only supported types of validator are embl/genbank. =back =cut package Bio::EnsEMBL::Production::Pipeline::Flatfile::ValidatorFactoryMethod; use Bio::EnsEMBL::Production::Pipeline::Flatfile::EMBLValidator; use Bio::EnsEMBL::Production::Pipeline::Flatfile::GenbankValidator; use Bio::EnsEMBL::Utils::Exception qw/throw/; =head2 new Arg [...] : None Description: Creates a new ValidatorFactoryMethod object. Returntype : Bio::EnsEMBL::Production::Pipeline::Flatfile::ValidatorFactoryMethod Exceptions : None Caller : general Status : Stable =cut sub new { my ($class, @args) = @_; my $self = bless {}, $class; return $self; } =head2 create_instance Arg [1] : String; validator type Description: Build a validator for the file type specified as argument. Supported file types are: - embl Exceptions : If type not specified or unsupported file format Returntype : Subclass of Bio::EnsEMBL::Production::Pipeline::FlatFile::Validator Caller : general Status : Stable =cut sub create_instance { my ($self, $type) = @_; throw "Parser type not specified" unless $type; my $validator; SWITCH: { $validator = Bio::EnsEMBL::Production::Pipeline::Flatfile::EMBLValidator->new(), last SWITCH if $type =~ /embl/i; $validator = Bio::EnsEMBL::Production::Pipeline::Flatfile::GenbankValidator->new(), last SWITCH if $type =~ /genbank/i; throw "Unknown type $type for Validator"; } return $validator; } 1;
Ensembl/ensembl-production
modules/Bio/EnsEMBL/Production/Pipeline/Flatfile/ValidatorFactoryMethod.pm
Perl
apache-2.0
2,907
package Paws::DAX::SecurityGroupMembership; use Moose; has SecurityGroupIdentifier => (is => 'ro', isa => 'Str'); has Status => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::DAX::SecurityGroupMembership =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::DAX::SecurityGroupMembership object: $service_obj->Method(Att1 => { SecurityGroupIdentifier => $value, ..., Status => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::DAX::SecurityGroupMembership object: $result = $service_obj->Method(...); $result->Att1->SecurityGroupIdentifier =head1 DESCRIPTION An individual VPC security group and its status. =head1 ATTRIBUTES =head2 SecurityGroupIdentifier => Str The unique ID for this security group. =head2 Status => Str The status of this security group. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::DAX> =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
ioanrogers/aws-sdk-perl
auto-lib/Paws/DAX/SecurityGroupMembership.pm
Perl
apache-2.0
1,467
package Bio::EnsEMBL::Analysis::RunnableDB; # Ensembl module for Bio::EnsEMBL::Analysis::RunnableDB # Copyright [1999-2015] 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. =head1 NAME Bio::EnsEMBL::Analysis::RunnableDB =head1 SYNOPSIS my $repeat_masker = Bio::EnsEMBL::Analysis::RunnableDB::RepeatMasker-> new( -input_id => 'contig::AL805961.22.1.166258:1:166258:1', -db => $db, -analysis => $analysis, ); $repeat_masker->fetch_input; $repeat_masker->run; $repeat_masker->write_output; =head1 DESCRIPTION This module acts as a base class for our RunnableDBs who act as an interface between the core database and our Runnables both fetching input data and writing data back to the databases The module provides some base functionality some of which must be used The constructor fits the model the pipeline which runs most of our analyses expects. If a child runnabledb expects more arguments to the constructor than this one it wont be directly runnable by the pipeline Most of the other methods provided are containers of some description but there are some methods with specific functionality parameters_hash is there to parse a string from the parameters varible in the analysis object. This string should have the format key => value, key => value where the key would be the Runnables constructor argument and the value the variable. This is to allow some flexibility in the arguments expected by and the way we run Runnables. fetch_sequence fetched a sequence using the fetch_by_name method of the slice adaptor from the given database. The name, database and an array of logic_names to determine masking can be given. If no name or database is provided the method defaults to input_id and db validate, this is a method which does some basic validation of the feature before storage. This checks if slice and analysis object are defined and if start, end and strand are defined then that the start is smaller than the end and both the start and end are > 0 All runnableDBs need to implement 3 methods to run within the pipeline fetch_input, this always must be implemented by individual child RunnableDBs as the input required for different analyses can vary so widely that it is impossible to write a generic method run, there is a run method implemented. To use this child runnabledbs need to have added the runnables they want run to the runnable method which holds an array of runnables which are each called and the output stored in this method write_output, there is also a generic implementation of this. To use this method the child runnabledb must implement a get_adaptor method which returns the appropriate adaptor to be used in storage. =head1 CONTACT Post questions to the Ensembl development list: http://lists.ensembl.org/mailman/listinfo/dev =cut use strict; use warnings; use Bio::EnsEMBL::Utils::Exception qw(verbose throw warning info ); use Bio::EnsEMBL::Utils::Argument qw( rearrange ); use Bio::EnsEMBL::Analysis::Tools::FeatureFactory; use Bio::EnsEMBL::Analysis::Tools::Utilities qw(parse_config parse_config_mini parse_config_value); use Bio::EnsEMBL::Analysis::Tools::Logger qw(logger_info logger_verbosity); use Bio::EnsEMBL::Analysis::Config::General qw(CORE_VERBOSITY LOGGER_VERBOSITY); use vars qw (@ISA); @ISA = qw(); =head2 new Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor Arg [3] : Bio::EnsEMBL::Analysis Function : create a Bio::EnsEMBL::Analysis::RunnableDB object Returntype: Bio::EnsEMBL::Analysis::RunnableDB Exceptions: throws if not passed either a dbadaptor, input id or an analysis object Example : $rdb = $perl_path->new( -analysis => $self->analysis, -input_id => $self->input_id, -db => $self->adaptor->db ); =cut sub new{ my ($class,@args) = @_; my $self = bless {},$class; my ($db, $input_id, $analysis,$ignore_config_file,$no_config_exception, $verbosity) = rearrange (['DB', 'INPUT_ID', 'ANALYSIS','IGNORE_CONFIG_FILE','NO_CONFIG_EXCEPTION', 'VERBOSITY'], @args); if(!$db || !$analysis || !$input_id){ throw("Can't create a RunnableDB without a dbadaptor ". $db." an analysis object ".$analysis. " or an input_id ".$input_id); } #Clone analysis to prevent analysis reference problem when #using separate pipeline and output DBs #Do not use adaptor here as caching returns same reference my $cloned_analysis; %{$cloned_analysis} = %{$analysis}; $analysis = bless $cloned_analysis, ref ($analysis); $self->db($db); $self->analysis($analysis); $self->input_id($input_id); $self->ignore_config_file($ignore_config_file) ; $self->no_config_exception($no_config_exception) ; verbose($CORE_VERBOSITY); logger_verbosity($LOGGER_VERBOSITY) unless ($verbosity); return $self; } =head2 db Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Pipeline::DBAdaptor Function : container for dbadaptor Returntype: Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor Exceptions: throws if not passed a Bio::EnsEMBL::DBSQL::DBConnection object Example : =cut sub db{ my $self = shift; my $db = shift; if($db){ throw("Must pass RunnableDB:db a Bio::EnsEMBL::DBSQL::DBAdaptor ". "not a ".$db) unless($db->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')); $self->{'db'} = $db; } return $self->{'db'}; } =head2 analysis Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Analysis Function : container for analysis object Returntype: Bio::EnsEMBL::Analysis Exceptions: throws passed incorrect object type Example : =cut sub analysis{ my $self = shift; my $analysis = shift; if($analysis){ throw("Must pass RunnableDB:analysis a Bio::EnsEMBL::Analysis". "not a ".$analysis) unless($analysis->isa ('Bio::EnsEMBL::Analysis')); $self->{'analysis'} = $analysis; } return $self->{'analysis'}; } =head2 query Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Slice Function : container for slice object Returntype: Bio::EnsEMBL::Slice Exceptions: throws if passed the incorrect object type Example : =cut sub query{ my $self = shift; my $slice = shift; if($slice){ throw("Must pass RunnableDB:query a Bio::EnsEMBL::Slice". "not a ".$slice) unless($slice->isa ('Bio::EnsEMBL::Slice')); $self->{'slice'} = $slice; } return $self->{'slice'}; } =head2 runnable Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Analysis::Runnable Function : container for an array of runnables Returntype: arrayref Exceptions: throws if passed the wrong object type Example : =cut sub runnable{ my ($self, $runnable) = @_; if(!$self->{'runnable'}){ $self->{'runnable'} = []; } if($runnable){ throw("Must pass RunnableDB:runnable a ". "Bio::EnsEMBL::Analysis::Runnable not a ".$runnable) unless($runnable->isa('Bio::EnsEMBL::Analysis::Runnable')); push(@{$self->{'runnable'}}, $runnable); } return $self->{'runnable'}; } =head2 input_id Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : string/int Function : container for specified variable. This pod refers to the three methods below, input_id, input_is_void, failing_job_status. This are simple containers which dont do more than hold and return an given value Returntype: string/int Exceptions: none Example : =cut sub input_id{ my $self = shift; $self->{'input_id'} = shift if(@_); return $self->{'input_id'}; } sub input_is_void{ my $self = shift; $self->{'input_is_void'} = shift if(@_); return $self->{'input_is_void'}; } sub failing_job_status{ my $self = shift; $self->{'failing_status'} = shift if(@_); return $self->{'failing_status'}; } =head2 output Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : arrayref of output Function : push array passed into onto output array Returntype: arrayref Exceptions: throws if not passed correct type Example : $self->output(\@output); =cut sub output{ my ($self, $output) = @_; if(!$self->{'output'}){ $self->{'output'} = []; } if($output){ if(ref($output) ne 'ARRAY'){ throw('Must pass RunnableDB:output an array ref not a '.$output); } push(@{$self->{'output'}}, @$output); } return $self->{'output'}; } =head2 feature_factory Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : Bio::EnsEMBL::Analysis::Tools::FeatureFactory Function : container for a feature factory object. If none is defined when one is requested a new one is created. Returntype: Bio::EnsEMBL::Analysis::Tools::FeatureFactory Exceptions: none Example : =cut sub feature_factory{ my ($self, $feature_factory) = @_; if($feature_factory){ $self->{'feature_factory'} = $feature_factory; } if(!$self->{'feature_factory'}){ $self->{'feature_factory'} = Bio::EnsEMBL::Analysis::Tools::FeatureFactory ->new(); } return $self->{'feature_factory'}; } #utility methods =head2 fetch_sequence Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : string, name Arg [3] : Bio::EnsEMBL::DBAdaptor Arg [4] : arrayref of logic_name if sequence is to be masked Arg [5] : Boolean for softmasking if sequence is to be softmasked Function : gets sequence from specifed database Returntype: Bio::EnsEMBL::Slice Exceptions: none Example : =cut sub fetch_sequence{ my ($self, $name, $db, $repeat_masking, $soft_masking) = @_; if(!$db){ $db = $self->db; } if(!$name){ $name = $self->input_id; } my $sa = $db->get_SliceAdaptor; my $slice = $sa->fetch_by_name($name); $repeat_masking = [] unless($repeat_masking); if(!$slice){ throw("Failed to fetch slice ".$name); } if(@$repeat_masking){ my $sequence = $slice->get_repeatmasked_seq($repeat_masking, $soft_masking); $slice = $sequence } return $slice; } =head2 parameters_hash Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : string, parameters string Function : parses the parameters string into a hash for the Runnables constructor. If neither of the delimiters are found in the string the string is given the key of options Returntype: hashref Exceptions: Example : =cut sub parameters_hash{ my ($self, $string) = @_; if(!$string){ $string = $self->analysis->parameters; } my %parameters_hash; if ($string) { if($string =~ /,/ || $string =~ /=>/){ my @pairs = split (/,/, $string); foreach my $pair(@pairs){ my ($key, $value) = split (/=>/, $pair); if ($key && ($value || $value eq '0')) { $key =~ s/^\s+//g; $key =~ s/\s+$//g; $value =~ s/^\s+//g; $value =~ s/\s+$//g; $parameters_hash{$key} = $value; } else { $parameters_hash{$key} = 1; } } }else{ $parameters_hash{'-options'} = $string; } } return \%parameters_hash; } =head2 run Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Function : cycles through all the runnables, calls run and pushes their output into the RunnableDBs output array Returntype: array ref Exceptions: none Example : =cut sub run{ my ($self) = @_; foreach my $runnable(@{$self->runnable}){ $runnable->run; $self->output($runnable->output); } return $self->{'output'}; } =head2 write_output Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Function : set analysis and slice on each feature Returntype: 1 Exceptions: none Example : =cut sub write_output { my ($self) = @_; my $adaptor = $self->get_adaptor(); my $analysis = $self->analysis(); # Keep track of the analysis_id we have here, because the store() # method might change it if the analysis does not already exist in # the output database, which will make running the next job difficult # or impossible (because the analysis tables weren't in sync). If we # find that the analysis ID changes, throw() so that the genebuilder # realizes that she has to sync thhe analysis tables. my $analysis_id = $analysis->dbID(); foreach my $feature ( @{ $self->output() } ) { $feature->analysis($analysis); if ( !defined( $feature->slice() ) ) { $feature->slice( $self->query() ); } $self->feature_factory->validate($feature); eval { $adaptor->store($feature); }; if ($@) { throw( sprintf( "RunnableDB::write_output() failed: " . "failed to store '%s' into database '%s': %s", $feature, $adaptor->dbc()->dbname(), $@ ) ); } } # Determine if the analysis ID changed, and throw() if it did. if ( $analysis->dbID() != $analysis_id ) { throw( sprintf( "The analysis ID for '%s' changed from %d to %d. " . "Are the analysis tables in sync?\n", $analysis->logic_name(), $analysis_id, $analysis->dbID() ) ); } return 1; } ## end sub write_output =head2 fetch_input Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Function : throw as it means child hasnt implement an essential method Returntype: none Exceptions: see function Example : =cut sub fetch_input{ my ($self) = @_; throw("Must implement fetch input in ".$self." RunnableDB will ". "not provide this"); } =head2 read_and_check_config Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : hashref, should be the hashref from which ever config file you are reading Arg [3] : label - the name of the config varible you're reading - useful for debugging Arg [4] : flag (1/0 ) to throw or not throw if logic_name is missing from config. ( useful for auto-setup in cloud ) Function : to on the basis of the entries of the hash in your specific config file set up instance variables first for the default values then for any values specific to you logic name Returntype: none Exceptions: none Example : =cut sub read_and_check_config{ my ($self, $var_hash, $label ) = @_; if ( defined $label ) { print "READING CONFIG : $label\n" ; } parse_config($self, $var_hash, $self->analysis->logic_name,$self->no_config_exception); } sub read_and_check_config_value{ my ($self, $var_hash, $label, $values_to_get ) = @_; if ( defined $label ) { print "READING CONFIG : $label\n" ; } parse_config_value($self, $var_hash, $self->analysis->logic_name, $values_to_get); } sub read_and_check_config_mini{ my ($self, $var_hash, $label ) = @_; if ( defined $label ) { print "READING CONFIG : $label\n" ; } parse_config_mini($self, $var_hash); } =head2 require_module Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB::Blast Arg [2] : string, module path Function : uses perls require to use the past in module Returntype: returns module name with / replaced by :: Exceptions: throws if require fails Example : my $parser = $self->require('Bio/EnsEMBL/Analysis/Tools/BPliteWrapper'); =cut sub require_module{ my ($self, $module) = @_; my $class; ($class = $module) =~ s/::/\//g; eval{ require "$class.pm"; }; throw("Couldn't require ".$class." Blast:require_module $@") if($@); return $module; } =head2 ignore_config_file Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : string ( 1 or 0 ) Function : Getter/Setter for value if the configuration file for the module should be ignored or not. Default is to not ignore ( =read / use ) the config file. Returntype: 1 or 0 =cut sub ignore_config_file { my $self = shift; $self->{'ignore_config'} = shift if(@_); return $self->{'ignore_config'}; } =head2 no_config_exception Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : string ( 1 or 0 ) Function : Returntype: 1 or 0 =cut sub no_config_exception{ my $self = shift; $self->{'no_config_exception'} = shift if(@_); return $self->{'no_config_exception'}; } 1;
mn1/ensembl-analysis
modules/Bio/EnsEMBL/Analysis/RunnableDB.pm
Perl
apache-2.0
16,903
=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::_simple; use strict; use base qw(Bio::EnsEMBL::GlyphSet_simple); sub features { my $self = shift; my $call = 'get_all_' . ($self->my_config('type') || 'SimpleFeatures'); my $db_type = $self->my_config('db'); my @features = map @{$self->{'container'}->$call($_, undef, $db_type)||[]}, @{$self->my_config('logic_names')||[]}; return \@features; } sub colour_key { return lc $_[1]->analysis->logic_name; } sub _das_type { return 'simple'; } sub title { my ($self, $f) = @_; my ($start, $end) = $self->slice2sr($f->start, $f->end); my $score = length($f->score) ? sprintf('score: %s;', $f->score) : ''; return sprintf '%s: %s; %s bp: %s', $f->analysis->logic_name, $f->display_label, $score, "$start-$end"; } sub href { my ($self, $f) = @_; my $ext_url = $self->my_config('ext_url'); return undef unless $ext_url; my ($start, $end) = $self->slice2sr($f->start, $f->end); return $self->_url({ action => 'SimpleFeature', logic_name => $f->analysis->logic_name, display_label => $f->display_label, score => $f->score, bp => "$start-$end", ext_url => $ext_url }); } sub export_feature { my ($self, $feature, $feature_type) = @_; my @label = $feature->can('display_label') ? split /\s*=\s*/, $feature->display_label : (); return $self->_render_text($feature, $feature_type, { 'headers' => [ $label[0] ], 'values' => [ $label[1] ] }); } 1;
Ensembl/ensembl-draw
modules/Bio/EnsEMBL/GlyphSet/_simple.pm
Perl
apache-2.0
2,154
use strict; package main; print("<form action=\"index.pl\" method=\"post\">\n"); print("<input type=\"hidden\" name=\"action\" value=\"insertTextComment\">\n"); my $formula0=$reportNameID;print("<input type=\"hidden\" name=\"reportNameID\" value=\"$formula0\">\n"); print(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"); if ($sessionObj->param("userMessage1") ne "") { print(" <tr>\n"); my $formula1=$sessionObj->param("userMessage1");print(" <td class=\"liteGray\" valign=\"top\" align=\"left\"><span class=\"userMessage\">$formula1</span></td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <td class=\"liteGray\" valign=\"top\" align=\"left\"><img name=\"xallHosts_host1\" src=\"../../../appRez/images/common/spacer.gif\" border=\"0\" width=\"9\" height=\"9\"></td>\n"); print(" </tr>\n"); $sessionObj->param("userMessage1", ""); } print(" <tr>\n"); print(" <td>\n"); print(" <fieldset> \n"); print(" <legend align=\"top\">Add Text Comment</legend>\n"); print(" <textarea name=\"textComment\" cols=\"65\" rows=\"7\"></textarea>\n"); print(" </fieldset>\n"); print(" </td>\n"); print(" </tr>\n"); print(" <td class=\"liteGray\" valign=\"top\" align=\"center\"><input class=\"liteButton\" type=\"submit\" name=\"Update\" value=\"ADD\"></td>\n"); print(" </table>\n"); print("</form>\n");
ktenzer/perfstat
ui/reportMonitor/content/layoutReport/dsp_selectTextComment.pl
Perl
apache-2.0
1,343
package Paws::SQS::SendMessageBatchResultEntry; use Moose; has Id => (is => 'ro', isa => 'Str', required => 1); has MD5OfMessageAttributes => (is => 'ro', isa => 'Str'); has MD5OfMessageBody => (is => 'ro', isa => 'Str', required => 1); has MessageId => (is => 'ro', isa => 'Str', required => 1); has SequenceNumber => (is => 'ro', isa => 'Str'); 1; ### main pod documentation begin ### =head1 NAME Paws::SQS::SendMessageBatchResultEntry =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::SQS::SendMessageBatchResultEntry object: $service_obj->Method(Att1 => { Id => $value, ..., SequenceNumber => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::SQS::SendMessageBatchResultEntry object: $result = $service_obj->Method(...); $result->Att1->Id =head1 DESCRIPTION Encloses a C<MessageId> for a successfully-enqueued message in a C< SendMessageBatch.> =head1 ATTRIBUTES =head2 B<REQUIRED> Id => Str An identifier for the message in this batch. =head2 MD5OfMessageAttributes => Str An MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see RFC1321. =head2 B<REQUIRED> MD5OfMessageBody => Str An MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see RFC1321. =head2 B<REQUIRED> MessageId => Str An identifier for the message. =head2 SequenceNumber => Str This parameter applies only to FIFO (first-in-first-out) queues. The large, non-consecutive number that Amazon SQS assigns to each message. The length of C<SequenceNumber> is 128 bits. As C<SequenceNumber> continues to increase for a particular C<MessageGroupId>. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::SQS> =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
ioanrogers/aws-sdk-perl
auto-lib/Paws/SQS/SendMessageBatchResultEntry.pm
Perl
apache-2.0
2,588
false :- main_verifier_error. verifier_error(A,B,C) :- A=0, B=0, C=0. verifier_error(A,B,C) :- A=0, B=1, C=1. verifier_error(A,B,C) :- A=1, B=0, C=1. verifier_error(A,B,C) :- A=1, B=1, C=1. main_entry :- true. main__un(A) :- main_entry, A=268435440. main_orig_main_exit :- main__un(A), A=0. main__un1(A) :- main__un(A), A<0. main__un1(A) :- main__un(A), A>0. main__un(A) :- main__un1(B), A=B+ -2. main_precall :- main_orig_main_exit, A=0. main___VERIFIER_assert :- main_precall. main__un2 :- main___VERIFIER_assert, 1=0. main_verifier_error :- main__un2.
bishoksan/RAHFT
benchmarks_scp/SVCOMP15/svcomp15-clp/simple_true-unreach-call4.i.pl
Perl
apache-2.0
646
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This file is part of Logtalk <https://logtalk.org/> % Copyright 1998-2022 Paulo Moura <pmoura@logtalk.org> % % 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. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- if(current_logtalk_flag(prolog_dialect, eclipse)). :- module(module). :- export((p/1, q/1, r/1, s/2, t/2)). p(1). q(2). r(3). s(1, one). s(2, two). t(1, a). t(1, b). t(1, c). t(2, x). t(2, y). t(2, z). :- else. :- module(module, [p/1, q/1, r/1, s/2, t/2]). p(1). q(2). r(3). s(1, one). s(2, two). t(1, a). t(1, b). t(1, c). t(2, x). t(2, y). t(2, z). :- endif.
LogtalkDotOrg/logtalk3
tests/logtalk/directives/use_module_2/module.pl
Perl
apache-2.0
1,220
package VMOMI::OvfConsumerOstNode; use parent 'VMOMI::DynamicData'; use strict; use warnings; our @class_ancestors = ( 'DynamicData', ); our @class_members = ( ['id', undef, 0, ], ['type', undef, 0, ], ['section', 'OvfConsumerOvfSection', 1, 1], ['child', 'OvfConsumerOstNode', 1, 1], ['entity', 'ManagedObjectReference', 0, 1], ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/OvfConsumerOstNode.pm
Perl
apache-2.0
578
package VMOMI::HostInternetScsiHbaIscsiIpv6Address; use parent 'VMOMI::DynamicData'; use strict; use warnings; our @class_ancestors = ( 'DynamicData', ); our @class_members = ( ['address', undef, 0, ], ['prefixLength', undef, 0, ], ['origin', undef, 0, ], ['operation', undef, 0, 1], ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/HostInternetScsiHbaIscsiIpv6Address.pm
Perl
apache-2.0
529
package VMOMI::InvalidLicense; use parent 'VMOMI::VimFault'; use strict; use warnings; our @class_ancestors = ( 'VimFault', 'MethodFault', ); our @class_members = ( ['licenseContent', undef, 0, ], ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/InvalidLicense.pm
Perl
apache-2.0
434
package Rabbid::Controller::Document; use Mojo::Base 'Mojolicious::Controller'; use Mojo::ByteStream 'b'; use IO::File; require Rabbid::Analyzer; # This action will render a template sub overview { my $c = shift; # Show all docs sorted my $corpus = $c->stash('corpus'); my $cache_handle = 'default'; # corpus environment if ($corpus && ($corpus = $c->config('Corpora')->{$corpus})) { $cache_handle = $corpus->{cache_handle}; }; # Display doc_id field my @display = ( '#' => { col => 'doc_id', filter => 1 } ); my $schema = $c->rabbid->corpus; # Schema not loaded unless ($schema) { $c->notify(error => 'Corpus not loadable'); return $c->reply->exception; }; # Render document view with oro table my $fields = $schema->fields(1); # TODO: May be cacheable foreach my $field (@$fields) { my $field_name = $field->[0]; my $field_type = lc($field->[1]); push @display, ( $c->loc('Rabbid_' . $field_name) => { col => $field_name, cell => sub { return b($_[-1]->{$field_name} // '')->decode, $field_type }, filter => 1 } ); }; # TODO: Make this based on schema my $oro_table = { table => 'Doc', cache => { chi => $c->chi($cache_handle), expires_in => '60min' }, display => \@display }; # Render document view with oro table $c->render( template => 'documents', oro_view => $oro_table ); }; 1; __END__
KorAP/Rabbid
lib/Rabbid/Controller/Document.pm
Perl
bsd-2-clause
1,497
package Grids::Peer; use Moose; use Carp qw/croak/; use Grids::UUID; has connection => ( is => 'rw', isa => 'Grids::Protocol::Connection', required => 1, ); has session_token => ( is => 'rw', isa => 'Str', lazy => 1, builder => 'build_session_token', ); has name => ( is => 'rw', isa => 'Str', required => 1, ); # this should be pubkey in the future sub id { my ($self) = @_; return $self->name; } sub build_session_token { my $self = shift; return Grids::UUID->new_id; } no Moose; __PACKAGE__->meta->make_immutable;
revmischa/grids
lib/Grids/Peer.pm
Perl
bsd-3-clause
581
%% this example demonstrates a more normal setting with extra/redundant metarules and BK predicates. %% the example is from the papers: %% A. Cropper and S.H. Muggleton. Learning higher-order logic programs through abstraction and invention. IJCAI 2016. %% R. Morel, A. Cropper, and L. Ong. Typed meta-interpretive learning of logic programs. JELIA 2019. %% target theory is: %% f(A,B):-map(A,B,f_1). %% f_1(A,B):-my_reverse(A,C),f_2(C,B). %% f_2(A,B):-my_tail(A,C),my_reverse(C,B). :- use_module('../metagol'). metagol:functional. func_test(Atom1,Atom2,Condition):- Atom1 = [P,A,B], Atom2 = [P,A,Z], Condition = (Z = B). even(X):- number(X), 0 is X mod 2. odd(X):- number(X), 1 is X mod 2. my_double(A,B):- integer(A), B is A*2. my_succ(A,B):- integer(A), (ground(B)->integer(B);true), succ(A,B). my_prec(A,B):- integer(A), (ground(B)->integer(B);true), succ(B,A). my_length(A,B):- is_list(A), (nonvar(B)->integer(B);true), length(A,B). my_last(A,B):- last(A,B). my_head([H|_],H). my_tail([_|T],T). my_reverse(A,B):- reverse(A,B). my_droplast([_],[]). my_droplast([H|T1],[H|T2]):- my_droplast(T1,T2). my_msort(A,B):- (nonvar(A) -> is_list(A)), (nonvar(B) -> is_list(B)), msort(A,B). empty([]). not_empty([_|_]). body_pred(my_succ/2). body_pred(my_prec/2). body_pred(my_double/2). body_pred(my_length/2). body_pred(my_last/2). body_pred(my_head/2). body_pred(my_tail/2). body_pred(my_reverse/2). body_pred(my_msort/2). body_pred(empty/1). body_pred(not_empty/1). body_pred(even/1). body_pred(odd/1). %% metarules metarule([P,Q], [P,A], [[Q,A]]). metarule([P,Q,R], [P,A], [[Q,A],[R,A]]). metarule([P,Q], [P,A,B], [[Q,A,B]]). metarule([P,Q,F], [P,A,B], [[Q,A,B,F]]). metarule([P,Q,R], [P,A,B], [[Q,A,C],[R,C,B]]). metarule([P,Q,R], [P,A,B], [[Q,A,B],[R,A,B]]). metarule([P,Q,R], [P,A,B], [[Q,A,B],[R,A]]). metarule([P,Q,R], [P,A,B], [[Q,A,B],[R,B]]). %% interpreted BK ibk([map,[],[],_],[]). ibk([map,[H1|T1],[H2|T2],F],[[F,H1,H2],[map,T1,T2,F]]). ibk([filter,[],[],_],[]). ibk([filter,[A|T1],[A|T2],F],[[F,A],[filter,T1,T2,F]]). ibk([filter,[_|T1],T2,F],[[filter,T1,T2,F]]). gen_ex(A,B):- random(2,30,NumRows), findall(SubList,(between(1,NumRows,_),random(2,30,NumColumns),randseq(NumColumns,NumColumns,SubList)),A), maplist(my_droplast,A,B). a :- set_random(seed(111)), findall(f(A,B),(between(1,5,_),gen_ex(A,B)), Pos), learn(Pos,[]). :- time(a).
metagol/metagol
examples/droplasts.pl
Perl
bsd-3-clause
2,468
package Data::Serializer::Data::Denter; BEGIN { @Data::Serializer::Data::Denter::ISA = qw(Data::Serializer) } use warnings; use strict; use Carp; use Data::Denter; use vars qw($VERSION @ISA); $VERSION = '0.02'; # # Create a Data::Denter serializer object. # sub serialize { my $self = shift; my ($val) = @_; return undef unless defined $val; return $val unless ref($val); return Data::Denter::Indent($val); } sub deserialize { my $self = shift; my ($val) = @_; return undef unless defined $val; return Data::Denter::Undent($val); } 1; __END__ # =head1 NAME Data::Serializer::Data::Denter - Creates bridge between Data::Serializer and Data::Denter =head1 SYNOPSIS use Data::Serializer::Data::Denter; =head1 DESCRIPTION Module is used internally to Data::Serializer =over 4 =item B<serialize> - Wrapper to normalize serializer method name =item B<deserialize> - Wrapper to normalize deserializer method name =back =head1 AUTHOR Neil Neely <neil@neely.cx> =head1 COPYRIGHT Copyright 2002 by Neil Neely. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), Data::Serializer(3), Data::Denter(3). =cut
cyanglee/chinese_segmentor
modules/Data/Serializer/Data/Denter.pm
Perl
mit
1,257
#!/usr/bin/env perl ### modules use strict; use warnings; use Pod::Usage; use Data::Dumper; use Getopt::Long; use File::Spec; use Bio::TreeIO; ### args/flags pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN)); my ($verbose, $species_in); GetOptions( "species=s" => \$species_in, "verbose" => \$verbose, "help|?" => \&pod2usage # Help ); ### I/O error & defaults map{ die " ERROR: $_ not found!\n" unless -e $_ } @ARGV; ### MAIN my $lca_r = load_species_tree($species_in); foreach my $parse_in (@ARGV){ parse_notung_reconcile($parse_in, $lca_r); } ### Subroutines sub parse_notung_reconcile{ # parsing notung reconcile # my ($parse_in, $lca_r) = @_; open my $in_fh, $parse_in or die $!; while(<$in_fh>){ chomp; next if /^\s*$/; if(/^#D/){ parse_duplication_block($parse_in, $in_fh, $lca_r); } elsif(/^#CD/){ parse_codivergence_block($parse_in, $in_fh, $lca_r); } elsif(/^#T/){ parse_transfer_block($parse_in, $in_fh, $lca_r); } elsif(/^#L/){ parse_loss_block($parse_in, $in_fh, $lca_r); } } close $in_fh or die $!; } sub parse_loss_block{ my ($parse_in, $in_fh, $lca_r) = @_; while(<$in_fh>){ chomp; last if /^\s*$/; my @line = split /\t/; next unless $line[2]; # if no losses $line[1] = $lca_r->{$line[1]} if exists $lca_r->{$line[1]}; print join("\t", $parse_in, "NA", $line[1], "Loss", "NA"), "\n"; } } sub parse_transfer_block{ my ($parse_in, $in_fh, $lca_r) = @_; while(<$in_fh>){ chomp; last if /^\s*$/; my @line = split /\t/; $line[3] = $lca_r->{$line[3]} if exists $lca_r->{$line[3]}; $line[4] = $lca_r->{$line[4]} if exists $lca_r->{$line[4]}; print join("\t", $parse_in, $line[1], $line[3], "Transfer", $line[4]), "\n"; } } sub parse_codivergence_block{ # parsing codivergences # my ($parse_in, $in_fh, $lca_r) = @_; my $last_blank = 1; while(<$in_fh>){ chomp; # end of block = 2 blank lines in a row # if(/^\s*$/){ last if $last_blank; $last_blank = 1; } else{ $last_blank = 0; } next if /^\s*$/; # writing out line # my @line = split /\t/; $line[1] = $lca_r->{$line[1]} if exists $lca_r->{$line[1]}; print join("\t", $parse_in, "NA", $line[1], "Co-Divergence", "NA"), "\n"; } } sub parse_duplication_block{ # parsing duplications # my ($parse_in, $in_fh, $lca_r) = @_; my $last_blank = 1; while(<$in_fh>){ chomp; # end of block = 2 blank lines in a row # if(/^\s*$/){ last if $last_blank; $last_blank = 1; } else{ $last_blank = 0; } next if /^\s*$/; # writing out line # my @line = split /\t/; $line[1] = $lca_r->{$line[1]} if exists $lca_r->{$line[1]}; print join("\t", $parse_in, "NA", $line[1], "Duplication", "NA"), "\n"; } } sub load_species_tree{ # loading species tree; getting node LCA for each node ID # my ($species_in) = @_; my $treeio = Bio::TreeIO->new( -file => $species_in, -format => "newick"); # getting LCA # my %lca; my $node_cnt; while (my $tree = $treeio->next_tree){ for my $node ($tree->get_nodes){ next if $node->is_Leaf; my $node_id = $node->id; $node_cnt++; # getting all leaves of node # my @children; for my $child ($node->get_all_Descendents){ push @children, $child if $child->is_Leaf; } # finding a pair of leaves where LCA is node # for (my $i=0; $i<=$#children; $i++){ last if exists $lca{$node_id}; for (my $ii=$#children; $i>=0; $i--){ # working backward last if exists $lca{$node_id}; my $lca_id = $tree->get_lca( @children[($i, $ii)] )->id; if($lca_id =~ /[A-Za-z]/ && $lca_id eq $node_id){ $lca{$node_id} = join("|", $children[$i]->id, $children[$ii]->id); } elsif( $lca_id == $node_id){ $lca{$node_id} = join("|", $children[$i]->id, $children[$ii]->id); } } } $lca{$node_id} = "NA" unless exists $lca{$node_id}; } } #print Dumper %lca; exit; return \%lca; } __END__ =pod =head1 NAME Notung_reconcile_parse.pl -- parse Notung '--reconcile' output into a *txt table =head1 SYNOPSIS Notung_reconcile_parse.pl [flags] *parsable.txt > reconcile.txt =head2 Required flags =over =item -s Species tree produced by Notung '-stpruned --treeoutput newick' =back =head2 Optional flags =over =item -h This help message =back =head2 For more information: perldoc Notung_reconcile_parse.pl =head1 DESCRIPTION The output is a tab-delimited table. Blank value = not applicable. =head2 Columns of output =over =item * Tree ID (file name) =item * Gene tree node name =item * Species tree node name =item * Category (Duplication, Transfer, Speciation, or Leaf) =item * Recipient (species tree node name) =back =head1 EXAMPLES =head2 Usage: Notung_reconcile_parse.pl -s species.nwk genetree1.parsable.txt > reconcile.txt =head1 AUTHOR Nick Youngblut <nyoungb2@illinois.edu> =head1 AVAILABILITY sharchaea.life.uiuc.edu:/home/git/NY_misc_perl/ =head1 COPYRIGHT Copyright 2010, 2011 This software is licensed under the terms of the GPLv3 =cut
nyoungb2/misc_perl
blib/script/Notung_reconcile_parse.pl
Perl
mit
5,127
package Paws::CodeStar::UpdateProjectResult; use Moose; has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::CodeStar::UpdateProjectResult =head1 ATTRIBUTES =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/CodeStar/UpdateProjectResult.pm
Perl
apache-2.0
254
package RSP::Datastore::Namespace; use strict; use warnings; use RSP::Error; use Scalar::Util::Numeric qw( isnum isint isfloat ); use Carp qw( cluck ); use base 'Class::Accessor::Chained'; __PACKAGE__->mk_accessors(qw(namespace conn tables sa cache)); sub new { my $class = shift; my $self = { tables => {}, sa => SQL::Abstract->new( quote_char => '`' ) }; bless $self, $class; } sub exception_name { return "datastore"; } sub fetch_types { die "abstract method fetch_types called"; } sub has_type_table { my $self = shift; my $type = lc(shift); if (!$type) { RSP::Error->throw("no type"); } if (!keys %{$self->tables}) { $self->fetch_types; } return $self->tables->{$type} } sub types { my $self = shift; if (!keys %{$self->tables}) { $self->fetch_types } return keys %{$self->tables}; } sub tables_for_type { my $self = shift; my $type = lc(shift); if (!$type) { RSP::Error->throw("no type"); } my @suffixes = qw( f s o i ); my @tables = (); foreach my $suffix (@suffixes) { push @tables, sprintf("%s_prop_%s", $type, $suffix ); } return @tables; } sub remove { my $self = shift; my $type = lc(shift); my $id = shift; if (!$type) { RSP::Error->throw("no type"); } if (!$id) { RSP::Error->throw("no id"); } $self->conn->begin_work; eval { $self->_remove_in_transaction( $type, $id ); if ( !$self->cache->remove( "${type}:${id}" ) ) { cluck "Could not remove from cache!"; } }; if ($@) { $self->conn->rollback; RSP::Error->throw($@); } $self->conn->commit; return 1; } sub _remove_in_transaction { my $self = shift; my $type = lc(shift); my $id = shift; my $where = { id => $id }; foreach my $table ($self->tables_for_type( $type )) { my ($stmt, @bind) = $self->sa->delete($table, $where); my $sth = $self->conn->prepare_cached( $stmt ); $sth->execute( @bind ); $sth->finish; } my ($stmt, @bind) = $self->sa->delete("${type}_ids", $where); my $sth = $self->conn->prepare_cached( $stmt ); $sth->execute(@bind); $sth->finish; } sub read { my $self = shift; my $type = lc(shift); my $id = shift; if (!$type) { RSP::Error->throw("no type"); } if (!$id) { RSP::Error->throw("no id"); } my $cache = $self->cache->get( "${type}:${id}" ); if ( $cache ) { my $cached = eval { JSON::XS::decode_json( $cache ); }; if ( keys %$cached ) { return $cached; } } if (!$self->has_type_table( $type )) { $self->create_type_table( $type ); return $self->read( $type, $id ); } else { my $obj = $self->read_one_object( $type, $id ); if (!$obj) { RSP::Error->throw("no such object"); } return $obj; } } sub encode_output_val { my $self = shift; my $table = shift; my $val = shift; my $chr = substr($table, -1, 1 ); # print "CHR FOR $val is $chr\n"; if ( $chr eq 'o' ) { return JSON::XS::decode_json( $val ); } elsif ( $chr eq 'i' ) { return 0 + $val; } elsif ( $chr eq 'f' ) { return 0.00 + $val; } elsif ( $chr eq 's' ) { return "".$val; } else { return $val; } } sub read_one_object { my $self = shift; my $type = lc(shift); my $id = shift; my $fields = ['propname', 'propval']; my $where = { id => $id }; #my ($stmt, @bind) = $self->sa->select("${type}_ids", ['count(id)'], $where); #my $sth = $self->conn->prepare($stmt); #$sth->execute(@bind); #if ( $sth->fetchrow_arrayref()->[0] < 1 ) { # confess "no such object"; #} else { # print "we have ids!"; #} my $obj; foreach my $table ($self->tables_for_type( $type )) { my ($stmt, @bind) = $self->sa->select($table, $fields, $where); my $sth = $self->conn->prepare_cached( $stmt ); $sth->execute( @bind ); while( my $row = $sth->fetchrow_hashref() ) { if (!$obj) { $obj = { id => $id }; } my $val = $row->{propval}; $obj->{ $row->{ propname } } = $self->encode_output_val( $table, $val ); } $sth->finish; } if (!$obj) { RSP::Error->throw("no such object $type:$id"); } my $json = JSON::XS::encode_json( $obj ); if (!$self->cache->set( "${type}:${id}", $json )) { cluck("could not write $type object $id to cache"); } return $obj; } sub write { my $self = shift; my $type = shift; my $obj = shift; my $trans = shift; if (!$type) { RSP::Error->throw("no type"); } if (!$obj) { RSP::Error->throw("no object"); } if ( $trans ) { my $id = $obj->{id}; if ( $self->cache->set( "${type}:${id}", JSON::XS::encode_json( $obj ) ) ) { return 1; } else { cluck("could not write transient $type object $id to cache, falling back to persistent store"); } } if (!$self->has_type_table( $type )) { $self->create_type_table( $type ); $self->write_one_object( $type, $obj ); } else { $self->write_one_object( $type, $obj ); } return 1; } sub write_one_object { my $self = shift; my $type = lc(shift); my $obj = shift; my $id = $obj->{id}; if (!$id) { RSP::Error->throw("object has no id"); } $self->conn->begin_work; eval { my $fields = [ 'id', 'propame', 'propval' ]; $self->_remove_in_transaction( $type, $id ); foreach my $key (keys %$obj) { next if $key eq 'id'; my $val = $obj->{$key}; my $svals = { id => $id, propname => $key, propval => $val }; my $table = $self->table_for( $type, value => $val ); if ( $self->valtype( $val ) eq 'ref' ) { $svals->{propval} = JSON::XS::encode_json( $val ); } my ($stmt, @bind) = $self->sa->insert($table, $svals); my $sth = $self->conn->prepare_cached($stmt); # print "NAMESPACE IS ", $self->namespace, "\n"; # print "SQL is $stmt\n"; # print "BIND VARS ARE ", join(", ", @bind), "\n"; $sth->execute(@bind); $sth->finish; } my ($stmt, @bind) = $self->sa->insert("${type}_ids", { id => $id }); my $sth = $self->conn->prepare_cached($stmt); $sth->execute(@bind); $sth->finish; if (!$self->cache->set( "${type}:${id}", JSON::XS::encode_json( $obj ) )) { cluck "could not write $type object $id to cache"; } }; if ($@) { # print "THERE WAS AN ERROR WRITING THE DATA: $@\n"; $self->conn->rollback; RSP::Error->throw($@); } $self->conn->commit; return 1; } sub query { my $self = shift; my $type = shift; my $query = shift; my $opts = shift || {}; if (!$type) { RSP::Error->throw("no type"); } if (!$query) { RSP::Error->throw("no query"); } my @objects; if (ref($query) eq 'HASH') { if (keys %$query == 0) { my $set = $self->all_ids_for( $type ); foreach my $id (@$set) { push @objects, $self->read($type, $id); } } else { my $set = $self->query_set_and( $type, $query ); foreach my $id (@$set) { push @objects, $self->read( $type, $id ); } } } elsif (ref($query) eq 'ARRAY') { my $set = $self->query_set_or( $type, $query ); foreach my $id (@$set) { push @objects, $self->read( $type, $id ); } } if ( $opts->{sort} ) { ## okay, time to get sorting... @objects = sort { my $ra = $a->{$opts->{sort}}; my $rb = $b->{$opts->{sort}}; my $result; if (isnum( $ra )) { $result = $ra <=> $rb; } else { $result = $ra cmp $rb; } return $result; } @objects; } if ( $opts->{reverse} ) { @objects = reverse @objects; } if ( $opts->{limit}) { my $offset = 0; if ($opts->{offset}) { $offset = $opts->{offset}; } @objects = splice(@objects, $offset, $opts->{limit} ); } return \@objects; } sub all_ids_for { my $self = shift; my $type = lc(shift); my $set = Set::Object->new; if ( !$self->has_type_table( $type ) ) { return $set; } my ($stmt, @bind) = $self->sa->select("${type}_ids", ['id']); my $sth = $self->conn->prepare_cached($stmt); $sth->execute( @bind ); while( my $row = $sth->fetchrow_arrayref() ) { $set->insert( $row->[0] ); } $sth->finish; return $set; } sub query_set_or { my $self = shift; my $type = lc(shift); my $query = shift; my @sets; foreach my $val (@$query) { my @qsets = $self->query_set_and( $type, $val ); if (@qsets) { push @sets, @qsets; } } if (!@sets) { return Set::Object->new; } else { my $set = shift @sets; while( my $nset = shift @sets ) { $set = $set->union( $nset ); } return $set; } } sub query_set_and { my $self = shift; my $type = lc(shift); my $query = shift; my @sets; foreach my $key (keys %$query) { my @qsets = $self->query_one_set( $type, $key, $query->{$key} ); if (@qsets) { push @sets, @qsets; } } if (!@sets) { return Set::Object->new; } else { my $set = shift @sets; while( my $nset = shift @sets ) { $set = $set->intersection( $nset ); } return $set; } } sub table_for { my $self = shift; my $type = shift; my $args = { @_ }; if (!exists $args->{value}) { RSP::Error->throw("no value"); } my $dt = $self->valtype( $args->{value} ); my $lookup = { 'int' => 'i', 'float' => 'f', 'ref' => 'o', 'string' => 's' }; return "${type}_prop_$lookup->{$dt}"; } sub valtype { my $self = shift; my $val = shift; if ( ref( $val ) ) { return 'ref'; } elsif (isnum($val)) { if ( isint( $val ) ) { return 'int'; } else { return 'float'; } } else { return 'string'; } } sub query_one_set { my $self = shift; my $type = lc(shift); my $key = shift; my $val = shift; my $table; my $set = Set::Object->new; ## ## this is hairy. we have to figure out what datatype we are querying. ## if ( !ref( $val ) ) { $table = $self->table_for( $type, value => $val ); } else { if ( ref($val) eq 'HASH' && keys %$val == 1) { my ($hval) = values (%$val); $table = $self->table_for( $type, value => $hval ); } elsif( ref($val) eq 'ARRAY' ) { ## at this point it's easier to duck and recursively query... my @csets = (); foreach my $elem (@$val) { push @csets, $self->query_set_and( $type, { $key => $elem } ); } return @csets; } } my ($stmt, @bind) = $self->sa->select($table, ['id'], { propname => $key, propval => $val }); my $sth = $self->conn->prepare_cached( $stmt ); $sth->execute(@bind); while( my $row = $sth->fetchrow_arrayref() ) { $set->insert($row->[0]); } $sth->finish; # print "SET FROM QUERY $stmt (@bind) IS ", join(", ", @$set), "\n"; return $set; } 1;
konobi/smart-platform
lib/RSP/Datastore/Namespace.pm
Perl
mit
10,674
/* Part of SWI-Prolog Author: Jan Wielemaker E-mail: J.Wielemaker@vu.nl WWW: http://www.swi-prolog.org Copyright (c) 2008-2016, 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(thread_pool, [ thread_pool_create/3, % +Pool, +Size, +Options thread_pool_destroy/1, % +Pool thread_create_in_pool/4, % +Pool, :Goal, -Id, +Options current_thread_pool/1, % ?Pool thread_pool_property/2 % ?Pool, ?Property ]). :- autoload(library(debug),[debug/3]). :- autoload(library(error),[must_be/2,type_error/2]). :- autoload(library(lists),[member/2,delete/3]). :- autoload(library(option), [meta_options/3,select_option/4,merge_options/3,option/3]). :- autoload(library(rbtrees), [ rb_new/1, rb_insert_new/4, rb_delete/3, rb_keys/2, rb_lookup/3, rb_update/4 ]). /** <module> Resource bounded thread management The module library(thread_pool) manages threads in pools. A pool defines properties of its member threads and the maximum number of threads that can coexist in the pool. The call thread_create_in_pool/4 allocates a thread in the pool, just like thread_create/3. If the pool is fully allocated it can be asked to wait or raise an error. The library has been designed to deal with server applications that receive a variety of requests, such as HTTP servers. Simply starting a thread for each request is a bit too simple minded for such servers: * Creating many CPU intensive threads often leads to a slow-down rather than a speedup. * Creating many memory intensive threads may exhaust resources * Tasks that require little CPU and memory but take long waiting for external resources can run many threads. Using this library, one can define a pool for each set of tasks with comparable characteristics and create threads in this pool. Unlike the worker-pool model, threads are not started immediately. Depending on the design, both approaches can be attractive. The library is implemented by means of a manager thread with the fixed thread id =|__thread_pool_manager|=. All state is maintained in this manager thread, which receives and processes requests to create and destroy pools, create threads in a pool and handle messages from terminated threads. Thread pools are _not_ saved in a saved state and must therefore be recreated using the initialization/1 directive or otherwise during startup of the application. @see http_handler/3 and http_spawn/2. */ :- meta_predicate thread_create_in_pool(+, 0, -, :). :- predicate_options(thread_create_in_pool/4, 4, [ wait(boolean), pass_to(system:thread_create/3, 3) ]). :- multifile create_pool/1. %! thread_pool_create(+Pool, +Size, +Options) is det. % % Create a pool of threads. A pool of threads is a declaration for % creating threads with shared properties (stack sizes) and a % limited number of threads. Threads are created using % thread_create_in_pool/4. If all threads in the pool are in use, % the behaviour depends on the =wait= option of % thread_create_in_pool/4 and the =backlog= option described % below. Options are passed to thread_create/3, except for % % * backlog(+MaxBackLog) % Maximum number of requests that can be suspended. Default % is =infinite=. Otherwise it must be a non-negative integer. % Using backlog(0) will never delay thread creation for this % pool. % % The pooling mechanism does _not_ interact with the =detached= % state of a thread. Threads can be created both =detached= and % normal and must be joined using thread_join/2 if they are not % detached. thread_pool_create(Name, Size, Options) :- must_be(list, Options), pool_manager(Manager), thread_self(Me), thread_send_message(Manager, create_pool(Name, Size, Options, Me)), wait_reply. %! thread_pool_destroy(+Name) is det. % % Destroy the thread pool named Name. % % @error existence_error(thread_pool, Name). thread_pool_destroy(Name) :- pool_manager(Manager), thread_self(Me), thread_send_message(Manager, destroy_pool(Name, Me)), wait_reply. %! current_thread_pool(?Name) is nondet. % % True if Name refers to a defined thread pool. current_thread_pool(Name) :- pool_manager(Manager), thread_self(Me), thread_send_message(Manager, current_pools(Me)), wait_reply(Pools), ( atom(Name) -> memberchk(Name, Pools) ; member(Name, Pools) ). %! thread_pool_property(?Name, ?Property) is nondet. % % True if Property is a property of thread pool Name. Defined % properties are: % % * options(Options) % Thread creation options for this pool % * free(Size) % Number of free slots on this pool % * size(Size) % Total number of slots on this pool % * members(ListOfIDs) % ListOfIDs is the list or threads running in this pool % * running(Running) % Number of running threads in this pool % * backlog(Size) % Number of delayed thread creations on this pool thread_pool_property(Name, Property) :- current_thread_pool(Name), pool_manager(Manager), thread_self(Me), thread_send_message(Manager, pool_properties(Me, Name, Property)), wait_reply(Props), ( nonvar(Property) -> memberchk(Property, Props) ; member(Property, Props) ). %! thread_create_in_pool(+Pool, :Goal, -Id, +Options) is det. % % Create a thread in Pool. Options overrule default thread % creation options associated to the pool. In addition, the % following option is defined: % % * wait(+Boolean) % If =true= (default) and the pool is full, wait until a % member of the pool completes. If =false=, throw a % resource_error. % % @error resource_error(threads_in_pool(Pool)) is raised if wait % is =false= or the backlog limit has been reached. % @error existence_error(thread_pool, Pool) if Pool does not % exist. thread_create_in_pool(Pool, Goal, Id, QOptions) :- meta_options(is_meta, QOptions, Options), catch(thread_create_in_pool_(Pool, Goal, Id, Options), Error, true), ( var(Error) -> true ; Error = error(existence_error(thread_pool, Pool), _), create_pool_lazily(Pool) -> thread_create_in_pool_(Pool, Goal, Id, Options) ; throw(Error) ). thread_create_in_pool_(Pool, Goal, Id, Options) :- select_option(wait(Wait), Options, ThreadOptions, true), pool_manager(Manager), thread_self(Me), thread_send_message(Manager, create(Pool, Goal, Me, Wait, Id, ThreadOptions)), wait_reply(Id). is_meta(at_exit). %! create_pool_lazily(+Pool) is semidet. % % Call the hook create_pool/1 to create the pool lazily. create_pool_lazily(Pool) :- with_mutex(Pool, ( mutex_destroy(Pool), create_pool_sync(Pool) )). create_pool_sync(Pool) :- current_thread_pool(Pool), !. create_pool_sync(Pool) :- create_pool(Pool). /******************************* * START MANAGER * *******************************/ %! pool_manager(-ThreadID) is det. % % ThreadID is the thread (alias) identifier of the manager. Starts % the manager if it is not running. pool_manager(TID) :- TID = '__thread_pool_manager', ( thread_running(TID) -> true ; with_mutex('__thread_pool', create_pool_manager(TID)) ). thread_running(Thread) :- catch(thread_property(Thread, status(Status)), E, true), ( var(E) -> ( Status == running -> true ; thread_join(Thread, _), print_message(warning, thread_pool(manager_died(Status))), fail ) ; E = error(existence_error(thread, Thread), _) -> fail ; throw(E) ). create_pool_manager(Thread) :- thread_running(Thread), !. create_pool_manager(Thread) :- thread_create(pool_manager_main, _, [ alias(Thread), inherit_from(main) ]). pool_manager_main :- rb_new(State0), manage_thread_pool(State0). /******************************* * MANAGER LOGIC * *******************************/ %! manage_thread_pool(+State) manage_thread_pool(State0) :- thread_get_message(Message), ( update_thread_pool(Message, State0, State) -> debug(thread_pool(state), 'Message ~p --> ~p', [Message, State]), manage_thread_pool(State) ; format(user_error, 'Update failed: ~p~n', [Message]) ). update_thread_pool(create_pool(Name, Size, Options, For), State0, State) :- !, ( rb_insert_new(State0, Name, tpool(Options, Size, Size, WP, WP, []), State) -> thread_send_message(For, thread_pool(true)) ; reply_error(For, permission_error(create, thread_pool, Name)), State = State0 ). update_thread_pool(destroy_pool(Name, For), State0, State) :- !, ( rb_delete(State0, Name, State) -> thread_send_message(For, thread_pool(true)) ; reply_error(For, existence_error(thread_pool, Name)), State = State0 ). update_thread_pool(current_pools(For), State, State) :- !, rb_keys(State, Keys), debug(thread_pool(current), 'Reply to ~w: ~p', [For, Keys]), reply(For, Keys). update_thread_pool(pool_properties(For, Name, P), State, State) :- !, ( rb_lookup(Name, Pool, State) -> findall(P, pool_property(P, Pool), List), reply(For, List) ; reply_error(For, existence_error(thread_pool, Name)) ). update_thread_pool(Message, State0, State) :- arg(1, Message, Name), ( rb_lookup(Name, Pool0, State0) -> update_pool(Message, Pool0, Pool), rb_update(State0, Name, Pool, State) ; State = State0, ( Message = create(Name, _, For, _, _, _) -> reply_error(For, existence_error(thread_pool, Name)) ; true ) ). pool_property(options(Options), tpool(Options, _Free, _Size, _WP, _WPT, _Members)). pool_property(backlog(Size), tpool(_, _Free, _Size, WP, WPT, _Members)) :- diff_list_length(WP, WPT, Size). pool_property(free(Free), tpool(_, Free, _Size, _, _, _)). pool_property(size(Size), tpool(_, _Free, Size, _, _, _)). pool_property(running(Count), tpool(_, Free, Size, _, _, _)) :- Count is Size - Free. pool_property(members(IDList), tpool(_, _, _, _, _, IDList)). diff_list_length(List, Tail, Size) :- '$skip_list'(Length, List, Rest), ( Rest == Tail -> Size = Length ; type_error(difference_list, List/Tail) ). %! update_pool(+Message, +Pool0, -Pool) is det. % % Deal with create requests and completion messages on a given % pool. There are two messages: % % * create(PoolName, Goal, ForThread, Wait, Id, Options) % Create a new thread on behalf of ForThread. There are % two cases: % * Free slots: create the thread % * No free slots: error or add to waiting % * exitted(PoolName, Thread) % A thread completed. If there is a request waiting, % create a new one. update_pool(create(Name, Goal, For, _, Id, MyOptions), tpool(Options, Free0, Size, WP, WPT, Members0), tpool(Options, Free, Size, WP, WPT, Members)) :- succ(Free, Free0), !, merge_options(MyOptions, Options, ThreadOptions), select_option(at_exit(AtExit), ThreadOptions, ThreadOptions1, true), catch(thread_create(Goal, Id, [ at_exit(worker_exitted(Name, Id, AtExit)) | ThreadOptions1 ]), E, true), ( var(E) -> Members = [Id|Members0], reply(For, Id) ; reply_error(For, E), Members = Members0 ). update_pool(Create, tpool(Options, 0, Size, WP, WPT0, Members), tpool(Options, 0, Size, WP, WPT, Members)) :- Create = create(Name, _Goal, For, Wait, _, _Options), !, option(backlog(BackLog), Options, infinite), ( can_delay(Wait, BackLog, WP, WPT0) -> WPT0 = [Create|WPT], debug(thread_pool, 'Delaying ~p', [Create]) ; WPT = WPT0, reply_error(For, resource_error(threads_in_pool(Name))) ). update_pool(exitted(_Name, Id), tpool(Options, Free0, Size, WP0, WPT, Members0), Pool) :- succ(Free0, Free), delete(Members0, Id, Members1), Pool1 = tpool(Options, Free, Size, WP, WPT, Members1), ( WP0 == WPT -> WP = WP0, Pool = Pool1 ; WP0 = [Waiting|WP], debug(thread_pool, 'Start delayed ~p', [Waiting]), update_pool(Waiting, Pool1, Pool) ). can_delay(true, infinite, _, _) :- !. can_delay(true, BackLog, WP, WPT) :- diff_list_length(WP, WPT, Size), BackLog > Size. %! worker_exitted(+PoolName, +WorkerId, :AtExit) % % It is possible that '__thread_pool_manager' no longer exists % while closing down the process because the manager was killed % before the worker. % % @tbd Find a way to discover that we are terminating Prolog. :- public worker_exitted/3. worker_exitted(Name, Id, AtExit) :- catch(thread_send_message('__thread_pool_manager', exitted(Name, Id)), _, true), call(AtExit). /******************************* * UTIL * *******************************/ reply(To, Term) :- thread_send_message(To, thread_pool(true(Term))). reply_error(To, Error) :- thread_send_message(To, thread_pool(error(Error, _))). wait_reply :- thread_get_message(thread_pool(Result)), ( Result == true -> true ; Result == fail -> fail ; throw(Result) ). wait_reply(Value) :- thread_get_message(thread_pool(Reply)), ( Reply = true(Value0) -> Value = Value0 ; Reply == fail -> fail ; throw(Reply) ). /******************************* * HOOKS * *******************************/ %! create_pool(+PoolName) is semidet. % % Hook to create a thread pool lazily. The hook is called if % thread_create_in_pool/4 discovers that the thread pool does not % exist. If the hook succeeds, thread_create_in_pool/4 retries % creating the thread. For example, we can use the following % declaration to create threads in the pool =media=, which holds a % maximum of 20 threads. % % == % :- multifile thread_pool:create_pool/1. % % thread_pool:create_pool(media) :- % thread_pool_create(media, 20, []). % == /******************************* * MESSAGES * *******************************/ :- multifile prolog:message/3. prolog:message(thread_pool(Message)) --> message(Message). message(manager_died(Status)) --> [ 'Thread-pool: manager died on status ~p; restarting'-[Status] ].
josd/eye
eye-wasm/swipl-wasm/home/library/thread_pool.pl
Perl
mit
16,881
#! /usr/bin/env perl # Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (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@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/. # ==================================================================== # AES for s390x. # April 2007. # # Software performance improvement over gcc-generated code is ~70% and # in absolute terms is ~73 cycles per byte processed with 128-bit key. # You're likely to exclaim "why so slow?" Keep in mind that z-CPUs are # *strictly* in-order execution and issued instruction [in this case # load value from memory is critical] has to complete before execution # flow proceeds. S-boxes are compressed to 2KB[+256B]. # # As for hardware acceleration support. It's basically a "teaser," as # it can and should be improved in several ways. Most notably support # for CBC is not utilized, nor multiple blocks are ever processed. # Then software key schedule can be postponed till hardware support # detection... Performance improvement over assembler is reportedly # ~2.5x, but can reach >8x [naturally on larger chunks] if proper # support is implemented. # May 2007. # # Implement AES_set_[en|de]crypt_key. Key schedule setup is avoided # for 128-bit keys, if hardware support is detected. # Januray 2009. # # Add support for hardware AES192/256 and reschedule instructions to # minimize/avoid Address Generation Interlock hazard and to favour # dual-issue z10 pipeline. This gave ~25% improvement on z10 and # almost 50% on z9. The gain is smaller on z10, because being dual- # issue z10 makes it improssible to eliminate the interlock condition: # critial path is not long enough. Yet it spends ~24 cycles per byte # processed with 128-bit key. # # Unlike previous version hardware support detection takes place only # at the moment of key schedule setup, which is denoted in key->rounds. # This is done, because deferred key setup can't be made MT-safe, not # for keys longer than 128 bits. # # Add AES_cbc_encrypt, which gives incredible performance improvement, # it was measured to be ~6.6x. It's less than previously mentioned 8x, # because software implementation was optimized. # May 2010. # # Add AES_ctr32_encrypt. If hardware-assisted, it provides up to 4.3x # performance improvement over "generic" counter mode routine relying # on single-block, also hardware-assisted, AES_encrypt. "Up to" refers # to the fact that exact throughput value depends on current stack # frame alignment within 4KB page. In worst case you get ~75% of the # maximum, but *on average* it would be as much as ~98%. Meaning that # worst case is unlike, it's like hitting ravine on plateau. # November 2010. # # Adapt for -m31 build. If kernel supports what's called "highgprs" # feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit # instructions and achieve "64-bit" performance even in 31-bit legacy # application context. The feature is not specific to any particular # processor, as long as it's "z-CPU". Latter implies that the code # remains z/Architecture specific. On z990 it was measured to perform # 2x better than code generated by gcc 4.3. # December 2010. # # Add support for z196 "cipher message with counter" instruction. # Note however that it's disengaged, because it was measured to # perform ~12% worse than vanilla km-based code... # February 2011. # # Add AES_xts_[en|de]crypt. This includes support for z196 km-xts-aes # instructions, which deliver ~70% improvement at 8KB block size over # vanilla km-based code, 37% - at most like 512-bytes block size. $flavour = shift; if ($flavour =~ /3[12]/) { $SIZE_T=4; $g=""; } else { $SIZE_T=8; $g="g"; } while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} open STDOUT,">$output"; $softonly=0; # allow hardware support $t0="%r0"; $mask="%r0"; $t1="%r1"; $t2="%r2"; $inp="%r2"; $t3="%r3"; $out="%r3"; $bits="%r3"; $key="%r4"; $i1="%r5"; $i2="%r6"; $i3="%r7"; $s0="%r8"; $s1="%r9"; $s2="%r10"; $s3="%r11"; $tbl="%r12"; $rounds="%r13"; $ra="%r14"; $sp="%r15"; $stdframe=16*$SIZE_T+4*8; sub _data_word() { my $i; while(defined($i=shift)) { $code.=sprintf".long\t0x%08x,0x%08x\n",$i,$i; } } $code=<<___; .text .type AES_Te,\@object .align 256 AES_Te: ___ &_data_word( 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a); $code.=<<___; # Te4[256] .byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 .byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 .byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 .byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 .byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc .byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 .byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a .byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 .byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 .byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 .byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b .byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf .byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 .byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 .byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 .byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 .byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 .byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 .byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 .byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb .byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c .byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 .byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 .byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 .byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 .byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a .byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e .byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e .byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 .byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf .byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 .byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 # rcon[] .long 0x01000000, 0x02000000, 0x04000000, 0x08000000 .long 0x10000000, 0x20000000, 0x40000000, 0x80000000 .long 0x1B000000, 0x36000000, 0, 0, 0, 0, 0, 0 .align 256 .size AES_Te,.-AES_Te # void AES_encrypt(const unsigned char *inp, unsigned char *out, # const AES_KEY *key) { .globl AES_encrypt .type AES_encrypt,\@function AES_encrypt: ___ $code.=<<___ if (!$softonly); l %r0,240($key) lhi %r1,16 clr %r0,%r1 jl .Lesoft la %r1,0($key) #la %r2,0($inp) la %r4,0($out) lghi %r3,16 # single block length .long 0xb92e0042 # km %r4,%r2 brc 1,.-4 # can this happen? br %r14 .align 64 .Lesoft: ___ $code.=<<___; stm${g} %r3,$ra,3*$SIZE_T($sp) llgf $s0,0($inp) llgf $s1,4($inp) llgf $s2,8($inp) llgf $s3,12($inp) larl $tbl,AES_Te bras $ra,_s390x_AES_encrypt l${g} $out,3*$SIZE_T($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) lm${g} %r6,$ra,6*$SIZE_T($sp) br $ra .size AES_encrypt,.-AES_encrypt .type _s390x_AES_encrypt,\@function .align 16 _s390x_AES_encrypt: st${g} $ra,15*$SIZE_T($sp) x $s0,0($key) x $s1,4($key) x $s2,8($key) x $s3,12($key) l $rounds,240($key) llill $mask,`0xff<<3` aghi $rounds,-1 j .Lenc_loop .align 16 .Lenc_loop: sllg $t1,$s0,`0+3` srlg $t2,$s0,`8-3` srlg $t3,$s0,`16-3` srl $s0,`24-3` nr $s0,$mask ngr $t1,$mask nr $t2,$mask nr $t3,$mask srlg $i1,$s1,`16-3` # i0 sllg $i2,$s1,`0+3` srlg $i3,$s1,`8-3` srl $s1,`24-3` nr $i1,$mask nr $s1,$mask ngr $i2,$mask nr $i3,$mask l $s0,0($s0,$tbl) # Te0[s0>>24] l $t1,1($t1,$tbl) # Te3[s0>>0] l $t2,2($t2,$tbl) # Te2[s0>>8] l $t3,3($t3,$tbl) # Te1[s0>>16] x $s0,3($i1,$tbl) # Te1[s1>>16] l $s1,0($s1,$tbl) # Te0[s1>>24] x $t2,1($i2,$tbl) # Te3[s1>>0] x $t3,2($i3,$tbl) # Te2[s1>>8] srlg $i1,$s2,`8-3` # i0 srlg $i2,$s2,`16-3` # i1 nr $i1,$mask nr $i2,$mask sllg $i3,$s2,`0+3` srl $s2,`24-3` nr $s2,$mask ngr $i3,$mask xr $s1,$t1 srlg $ra,$s3,`8-3` # i1 sllg $t1,$s3,`0+3` # i0 nr $ra,$mask la $key,16($key) ngr $t1,$mask x $s0,2($i1,$tbl) # Te2[s2>>8] x $s1,3($i2,$tbl) # Te1[s2>>16] l $s2,0($s2,$tbl) # Te0[s2>>24] x $t3,1($i3,$tbl) # Te3[s2>>0] srlg $i3,$s3,`16-3` # i2 xr $s2,$t2 srl $s3,`24-3` nr $i3,$mask nr $s3,$mask x $s0,0($key) x $s1,4($key) x $s2,8($key) x $t3,12($key) x $s0,1($t1,$tbl) # Te3[s3>>0] x $s1,2($ra,$tbl) # Te2[s3>>8] x $s2,3($i3,$tbl) # Te1[s3>>16] l $s3,0($s3,$tbl) # Te0[s3>>24] xr $s3,$t3 brct $rounds,.Lenc_loop .align 16 sllg $t1,$s0,`0+3` srlg $t2,$s0,`8-3` ngr $t1,$mask srlg $t3,$s0,`16-3` srl $s0,`24-3` nr $s0,$mask nr $t2,$mask nr $t3,$mask srlg $i1,$s1,`16-3` # i0 sllg $i2,$s1,`0+3` ngr $i2,$mask srlg $i3,$s1,`8-3` srl $s1,`24-3` nr $i1,$mask nr $s1,$mask nr $i3,$mask llgc $s0,2($s0,$tbl) # Te4[s0>>24] llgc $t1,2($t1,$tbl) # Te4[s0>>0] sll $s0,24 llgc $t2,2($t2,$tbl) # Te4[s0>>8] llgc $t3,2($t3,$tbl) # Te4[s0>>16] sll $t2,8 sll $t3,16 llgc $i1,2($i1,$tbl) # Te4[s1>>16] llgc $s1,2($s1,$tbl) # Te4[s1>>24] llgc $i2,2($i2,$tbl) # Te4[s1>>0] llgc $i3,2($i3,$tbl) # Te4[s1>>8] sll $i1,16 sll $s1,24 sll $i3,8 or $s0,$i1 or $s1,$t1 or $t2,$i2 or $t3,$i3 srlg $i1,$s2,`8-3` # i0 srlg $i2,$s2,`16-3` # i1 nr $i1,$mask nr $i2,$mask sllg $i3,$s2,`0+3` srl $s2,`24-3` ngr $i3,$mask nr $s2,$mask sllg $t1,$s3,`0+3` # i0 srlg $ra,$s3,`8-3` # i1 ngr $t1,$mask llgc $i1,2($i1,$tbl) # Te4[s2>>8] llgc $i2,2($i2,$tbl) # Te4[s2>>16] sll $i1,8 llgc $s2,2($s2,$tbl) # Te4[s2>>24] llgc $i3,2($i3,$tbl) # Te4[s2>>0] sll $i2,16 nr $ra,$mask sll $s2,24 or $s0,$i1 or $s1,$i2 or $s2,$t2 or $t3,$i3 srlg $i3,$s3,`16-3` # i2 srl $s3,`24-3` nr $i3,$mask nr $s3,$mask l $t0,16($key) l $t2,20($key) llgc $i1,2($t1,$tbl) # Te4[s3>>0] llgc $i2,2($ra,$tbl) # Te4[s3>>8] llgc $i3,2($i3,$tbl) # Te4[s3>>16] llgc $s3,2($s3,$tbl) # Te4[s3>>24] sll $i2,8 sll $i3,16 sll $s3,24 or $s0,$i1 or $s1,$i2 or $s2,$i3 or $s3,$t3 l${g} $ra,15*$SIZE_T($sp) xr $s0,$t0 xr $s1,$t2 x $s2,24($key) x $s3,28($key) br $ra .size _s390x_AES_encrypt,.-_s390x_AES_encrypt ___ $code.=<<___; .type AES_Td,\@object .align 256 AES_Td: ___ &_data_word( 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742); $code.=<<___; # Td4[256] .byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 .byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb .byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 .byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb .byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d .byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e .byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 .byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 .byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 .byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 .byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda .byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 .byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a .byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 .byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 .byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b .byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea .byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 .byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 .byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e .byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 .byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b .byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 .byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 .byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 .byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f .byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d .byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef .byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 .byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 .byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 .byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d .size AES_Td,.-AES_Td # void AES_decrypt(const unsigned char *inp, unsigned char *out, # const AES_KEY *key) { .globl AES_decrypt .type AES_decrypt,\@function AES_decrypt: ___ $code.=<<___ if (!$softonly); l %r0,240($key) lhi %r1,16 clr %r0,%r1 jl .Ldsoft la %r1,0($key) #la %r2,0($inp) la %r4,0($out) lghi %r3,16 # single block length .long 0xb92e0042 # km %r4,%r2 brc 1,.-4 # can this happen? br %r14 .align 64 .Ldsoft: ___ $code.=<<___; stm${g} %r3,$ra,3*$SIZE_T($sp) llgf $s0,0($inp) llgf $s1,4($inp) llgf $s2,8($inp) llgf $s3,12($inp) larl $tbl,AES_Td bras $ra,_s390x_AES_decrypt l${g} $out,3*$SIZE_T($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) lm${g} %r6,$ra,6*$SIZE_T($sp) br $ra .size AES_decrypt,.-AES_decrypt .type _s390x_AES_decrypt,\@function .align 16 _s390x_AES_decrypt: st${g} $ra,15*$SIZE_T($sp) x $s0,0($key) x $s1,4($key) x $s2,8($key) x $s3,12($key) l $rounds,240($key) llill $mask,`0xff<<3` aghi $rounds,-1 j .Ldec_loop .align 16 .Ldec_loop: srlg $t1,$s0,`16-3` srlg $t2,$s0,`8-3` sllg $t3,$s0,`0+3` srl $s0,`24-3` nr $s0,$mask nr $t1,$mask nr $t2,$mask ngr $t3,$mask sllg $i1,$s1,`0+3` # i0 srlg $i2,$s1,`16-3` srlg $i3,$s1,`8-3` srl $s1,`24-3` ngr $i1,$mask nr $s1,$mask nr $i2,$mask nr $i3,$mask l $s0,0($s0,$tbl) # Td0[s0>>24] l $t1,3($t1,$tbl) # Td1[s0>>16] l $t2,2($t2,$tbl) # Td2[s0>>8] l $t3,1($t3,$tbl) # Td3[s0>>0] x $s0,1($i1,$tbl) # Td3[s1>>0] l $s1,0($s1,$tbl) # Td0[s1>>24] x $t2,3($i2,$tbl) # Td1[s1>>16] x $t3,2($i3,$tbl) # Td2[s1>>8] srlg $i1,$s2,`8-3` # i0 sllg $i2,$s2,`0+3` # i1 srlg $i3,$s2,`16-3` srl $s2,`24-3` nr $i1,$mask ngr $i2,$mask nr $s2,$mask nr $i3,$mask xr $s1,$t1 srlg $ra,$s3,`8-3` # i1 srlg $t1,$s3,`16-3` # i0 nr $ra,$mask la $key,16($key) nr $t1,$mask x $s0,2($i1,$tbl) # Td2[s2>>8] x $s1,1($i2,$tbl) # Td3[s2>>0] l $s2,0($s2,$tbl) # Td0[s2>>24] x $t3,3($i3,$tbl) # Td1[s2>>16] sllg $i3,$s3,`0+3` # i2 srl $s3,`24-3` ngr $i3,$mask nr $s3,$mask xr $s2,$t2 x $s0,0($key) x $s1,4($key) x $s2,8($key) x $t3,12($key) x $s0,3($t1,$tbl) # Td1[s3>>16] x $s1,2($ra,$tbl) # Td2[s3>>8] x $s2,1($i3,$tbl) # Td3[s3>>0] l $s3,0($s3,$tbl) # Td0[s3>>24] xr $s3,$t3 brct $rounds,.Ldec_loop .align 16 l $t1,`2048+0`($tbl) # prefetch Td4 l $t2,`2048+64`($tbl) l $t3,`2048+128`($tbl) l $i1,`2048+192`($tbl) llill $mask,0xff srlg $i3,$s0,24 # i0 srlg $t1,$s0,16 srlg $t2,$s0,8 nr $s0,$mask # i3 nr $t1,$mask srlg $i1,$s1,24 nr $t2,$mask srlg $i2,$s1,16 srlg $ra,$s1,8 nr $s1,$mask # i0 nr $i2,$mask nr $ra,$mask llgc $i3,2048($i3,$tbl) # Td4[s0>>24] llgc $t1,2048($t1,$tbl) # Td4[s0>>16] llgc $t2,2048($t2,$tbl) # Td4[s0>>8] sll $t1,16 llgc $t3,2048($s0,$tbl) # Td4[s0>>0] sllg $s0,$i3,24 sll $t2,8 llgc $s1,2048($s1,$tbl) # Td4[s1>>0] llgc $i1,2048($i1,$tbl) # Td4[s1>>24] llgc $i2,2048($i2,$tbl) # Td4[s1>>16] sll $i1,24 llgc $i3,2048($ra,$tbl) # Td4[s1>>8] sll $i2,16 sll $i3,8 or $s0,$s1 or $t1,$i1 or $t2,$i2 or $t3,$i3 srlg $i1,$s2,8 # i0 srlg $i2,$s2,24 srlg $i3,$s2,16 nr $s2,$mask # i1 nr $i1,$mask nr $i3,$mask llgc $i1,2048($i1,$tbl) # Td4[s2>>8] llgc $s1,2048($s2,$tbl) # Td4[s2>>0] llgc $i2,2048($i2,$tbl) # Td4[s2>>24] llgc $i3,2048($i3,$tbl) # Td4[s2>>16] sll $i1,8 sll $i2,24 or $s0,$i1 sll $i3,16 or $t2,$i2 or $t3,$i3 srlg $i1,$s3,16 # i0 srlg $i2,$s3,8 # i1 srlg $i3,$s3,24 nr $s3,$mask # i2 nr $i1,$mask nr $i2,$mask l${g} $ra,15*$SIZE_T($sp) or $s1,$t1 l $t0,16($key) l $t1,20($key) llgc $i1,2048($i1,$tbl) # Td4[s3>>16] llgc $i2,2048($i2,$tbl) # Td4[s3>>8] sll $i1,16 llgc $s2,2048($s3,$tbl) # Td4[s3>>0] llgc $s3,2048($i3,$tbl) # Td4[s3>>24] sll $i2,8 sll $s3,24 or $s0,$i1 or $s1,$i2 or $s2,$t2 or $s3,$t3 xr $s0,$t0 xr $s1,$t1 x $s2,24($key) x $s3,28($key) br $ra .size _s390x_AES_decrypt,.-_s390x_AES_decrypt ___ $code.=<<___; # void AES_set_encrypt_key(const unsigned char *in, int bits, # AES_KEY *key) { .globl AES_set_encrypt_key .type AES_set_encrypt_key,\@function .align 16 AES_set_encrypt_key: _s390x_AES_set_encrypt_key: lghi $t0,0 cl${g}r $inp,$t0 je .Lminus1 cl${g}r $key,$t0 je .Lminus1 lghi $t0,128 clr $bits,$t0 je .Lproceed lghi $t0,192 clr $bits,$t0 je .Lproceed lghi $t0,256 clr $bits,$t0 je .Lproceed lghi %r2,-2 br %r14 .align 16 .Lproceed: ___ $code.=<<___ if (!$softonly); # convert bits to km(c) code, [128,192,256]->[18,19,20] lhi %r5,-128 lhi %r0,18 ar %r5,$bits srl %r5,6 ar %r5,%r0 larl %r1,OPENSSL_s390xcap_P llihh %r0,0x8000 srlg %r0,%r0,0(%r5) ng %r0,32(%r1) # check availability of both km... ng %r0,48(%r1) # ...and kmc support for given key length jz .Lekey_internal lmg %r0,%r1,0($inp) # just copy 128 bits... stmg %r0,%r1,0($key) lhi %r0,192 cr $bits,%r0 jl 1f lg %r1,16($inp) stg %r1,16($key) je 1f lg %r1,24($inp) stg %r1,24($key) 1: st $bits,236($key) # save bits [for debugging purposes] lgr $t0,%r5 st %r5,240($key) # save km(c) code lghi %r2,0 br %r14 ___ $code.=<<___; .align 16 .Lekey_internal: stm${g} %r4,%r13,4*$SIZE_T($sp) # all non-volatile regs and $key larl $tbl,AES_Te+2048 llgf $s0,0($inp) llgf $s1,4($inp) llgf $s2,8($inp) llgf $s3,12($inp) st $s0,0($key) st $s1,4($key) st $s2,8($key) st $s3,12($key) lghi $t0,128 cr $bits,$t0 jne .Lnot128 llill $mask,0xff lghi $t3,0 # i=0 lghi $rounds,10 st $rounds,240($key) llgfr $t2,$s3 # temp=rk[3] srlg $i1,$s3,8 srlg $i2,$s3,16 srlg $i3,$s3,24 nr $t2,$mask nr $i1,$mask nr $i2,$mask .align 16 .L128_loop: la $t2,0($t2,$tbl) la $i1,0($i1,$tbl) la $i2,0($i2,$tbl) la $i3,0($i3,$tbl) icm $t2,2,0($t2) # Te4[rk[3]>>0]<<8 icm $t2,4,0($i1) # Te4[rk[3]>>8]<<16 icm $t2,8,0($i2) # Te4[rk[3]>>16]<<24 icm $t2,1,0($i3) # Te4[rk[3]>>24] x $t2,256($t3,$tbl) # rcon[i] xr $s0,$t2 # rk[4]=rk[0]^... xr $s1,$s0 # rk[5]=rk[1]^rk[4] xr $s2,$s1 # rk[6]=rk[2]^rk[5] xr $s3,$s2 # rk[7]=rk[3]^rk[6] llgfr $t2,$s3 # temp=rk[3] srlg $i1,$s3,8 srlg $i2,$s3,16 nr $t2,$mask nr $i1,$mask srlg $i3,$s3,24 nr $i2,$mask st $s0,16($key) st $s1,20($key) st $s2,24($key) st $s3,28($key) la $key,16($key) # key+=4 la $t3,4($t3) # i++ brct $rounds,.L128_loop lghi $t0,10 lghi %r2,0 lm${g} %r4,%r13,4*$SIZE_T($sp) br $ra .align 16 .Lnot128: llgf $t0,16($inp) llgf $t1,20($inp) st $t0,16($key) st $t1,20($key) lghi $t0,192 cr $bits,$t0 jne .Lnot192 llill $mask,0xff lghi $t3,0 # i=0 lghi $rounds,12 st $rounds,240($key) lghi $rounds,8 srlg $i1,$t1,8 srlg $i2,$t1,16 srlg $i3,$t1,24 nr $t1,$mask nr $i1,$mask nr $i2,$mask .align 16 .L192_loop: la $t1,0($t1,$tbl) la $i1,0($i1,$tbl) la $i2,0($i2,$tbl) la $i3,0($i3,$tbl) icm $t1,2,0($t1) # Te4[rk[5]>>0]<<8 icm $t1,4,0($i1) # Te4[rk[5]>>8]<<16 icm $t1,8,0($i2) # Te4[rk[5]>>16]<<24 icm $t1,1,0($i3) # Te4[rk[5]>>24] x $t1,256($t3,$tbl) # rcon[i] xr $s0,$t1 # rk[6]=rk[0]^... xr $s1,$s0 # rk[7]=rk[1]^rk[6] xr $s2,$s1 # rk[8]=rk[2]^rk[7] xr $s3,$s2 # rk[9]=rk[3]^rk[8] st $s0,24($key) st $s1,28($key) st $s2,32($key) st $s3,36($key) brct $rounds,.L192_continue lghi $t0,12 lghi %r2,0 lm${g} %r4,%r13,4*$SIZE_T($sp) br $ra .align 16 .L192_continue: lgr $t1,$s3 x $t1,16($key) # rk[10]=rk[4]^rk[9] st $t1,40($key) x $t1,20($key) # rk[11]=rk[5]^rk[10] st $t1,44($key) srlg $i1,$t1,8 srlg $i2,$t1,16 srlg $i3,$t1,24 nr $t1,$mask nr $i1,$mask nr $i2,$mask la $key,24($key) # key+=6 la $t3,4($t3) # i++ j .L192_loop .align 16 .Lnot192: llgf $t0,24($inp) llgf $t1,28($inp) st $t0,24($key) st $t1,28($key) llill $mask,0xff lghi $t3,0 # i=0 lghi $rounds,14 st $rounds,240($key) lghi $rounds,7 srlg $i1,$t1,8 srlg $i2,$t1,16 srlg $i3,$t1,24 nr $t1,$mask nr $i1,$mask nr $i2,$mask .align 16 .L256_loop: la $t1,0($t1,$tbl) la $i1,0($i1,$tbl) la $i2,0($i2,$tbl) la $i3,0($i3,$tbl) icm $t1,2,0($t1) # Te4[rk[7]>>0]<<8 icm $t1,4,0($i1) # Te4[rk[7]>>8]<<16 icm $t1,8,0($i2) # Te4[rk[7]>>16]<<24 icm $t1,1,0($i3) # Te4[rk[7]>>24] x $t1,256($t3,$tbl) # rcon[i] xr $s0,$t1 # rk[8]=rk[0]^... xr $s1,$s0 # rk[9]=rk[1]^rk[8] xr $s2,$s1 # rk[10]=rk[2]^rk[9] xr $s3,$s2 # rk[11]=rk[3]^rk[10] st $s0,32($key) st $s1,36($key) st $s2,40($key) st $s3,44($key) brct $rounds,.L256_continue lghi $t0,14 lghi %r2,0 lm${g} %r4,%r13,4*$SIZE_T($sp) br $ra .align 16 .L256_continue: lgr $t1,$s3 # temp=rk[11] srlg $i1,$s3,8 srlg $i2,$s3,16 srlg $i3,$s3,24 nr $t1,$mask nr $i1,$mask nr $i2,$mask la $t1,0($t1,$tbl) la $i1,0($i1,$tbl) la $i2,0($i2,$tbl) la $i3,0($i3,$tbl) llgc $t1,0($t1) # Te4[rk[11]>>0] icm $t1,2,0($i1) # Te4[rk[11]>>8]<<8 icm $t1,4,0($i2) # Te4[rk[11]>>16]<<16 icm $t1,8,0($i3) # Te4[rk[11]>>24]<<24 x $t1,16($key) # rk[12]=rk[4]^... st $t1,48($key) x $t1,20($key) # rk[13]=rk[5]^rk[12] st $t1,52($key) x $t1,24($key) # rk[14]=rk[6]^rk[13] st $t1,56($key) x $t1,28($key) # rk[15]=rk[7]^rk[14] st $t1,60($key) srlg $i1,$t1,8 srlg $i2,$t1,16 srlg $i3,$t1,24 nr $t1,$mask nr $i1,$mask nr $i2,$mask la $key,32($key) # key+=8 la $t3,4($t3) # i++ j .L256_loop .Lminus1: lghi %r2,-1 br $ra .size AES_set_encrypt_key,.-AES_set_encrypt_key # void AES_set_decrypt_key(const unsigned char *in, int bits, # AES_KEY *key) { .globl AES_set_decrypt_key .type AES_set_decrypt_key,\@function .align 16 AES_set_decrypt_key: #st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers and $key! bras $ra,_s390x_AES_set_encrypt_key #l${g} $key,4*$SIZE_T($sp) l${g} $ra,14*$SIZE_T($sp) ltgr %r2,%r2 bnzr $ra ___ $code.=<<___ if (!$softonly); #l $t0,240($key) lhi $t1,16 cr $t0,$t1 jl .Lgo oill $t0,0x80 # set "decrypt" bit st $t0,240($key) br $ra ___ $code.=<<___; .align 16 .Lgo: lgr $rounds,$t0 #llgf $rounds,240($key) la $i1,0($key) sllg $i2,$rounds,4 la $i2,0($i2,$key) srl $rounds,1 lghi $t1,-16 .align 16 .Linv: lmg $s0,$s1,0($i1) lmg $s2,$s3,0($i2) stmg $s0,$s1,0($i2) stmg $s2,$s3,0($i1) la $i1,16($i1) la $i2,0($t1,$i2) brct $rounds,.Linv ___ $mask80=$i1; $mask1b=$i2; $maskfe=$i3; $code.=<<___; llgf $rounds,240($key) aghi $rounds,-1 sll $rounds,2 # (rounds-1)*4 llilh $mask80,0x8080 llilh $mask1b,0x1b1b llilh $maskfe,0xfefe oill $mask80,0x8080 oill $mask1b,0x1b1b oill $maskfe,0xfefe .align 16 .Lmix: l $s0,16($key) # tp1 lr $s1,$s0 ngr $s1,$mask80 srlg $t1,$s1,7 slr $s1,$t1 nr $s1,$mask1b sllg $t1,$s0,1 nr $t1,$maskfe xr $s1,$t1 # tp2 lr $s2,$s1 ngr $s2,$mask80 srlg $t1,$s2,7 slr $s2,$t1 nr $s2,$mask1b sllg $t1,$s1,1 nr $t1,$maskfe xr $s2,$t1 # tp4 lr $s3,$s2 ngr $s3,$mask80 srlg $t1,$s3,7 slr $s3,$t1 nr $s3,$mask1b sllg $t1,$s2,1 nr $t1,$maskfe xr $s3,$t1 # tp8 xr $s1,$s0 # tp2^tp1 xr $s2,$s0 # tp4^tp1 rll $s0,$s0,24 # = ROTATE(tp1,8) xr $s2,$s3 # ^=tp8 xr $s0,$s1 # ^=tp2^tp1 xr $s1,$s3 # tp2^tp1^tp8 xr $s0,$s2 # ^=tp4^tp1^tp8 rll $s1,$s1,8 rll $s2,$s2,16 xr $s0,$s1 # ^= ROTATE(tp8^tp2^tp1,24) rll $s3,$s3,24 xr $s0,$s2 # ^= ROTATE(tp8^tp4^tp1,16) xr $s0,$s3 # ^= ROTATE(tp8,8) st $s0,16($key) la $key,4($key) brct $rounds,.Lmix lm${g} %r6,%r13,6*$SIZE_T($sp)# as was saved by AES_set_encrypt_key! lghi %r2,0 br $ra .size AES_set_decrypt_key,.-AES_set_decrypt_key ___ ######################################################################## # void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, # size_t length, const AES_KEY *key, # unsigned char *ivec, const int enc) { my $inp="%r2"; my $out="%r4"; # length and out are swapped my $len="%r3"; my $key="%r5"; my $ivp="%r6"; $code.=<<___; .globl AES_cbc_encrypt .type AES_cbc_encrypt,\@function .align 16 AES_cbc_encrypt: xgr %r3,%r4 # flip %r3 and %r4, out and len xgr %r4,%r3 xgr %r3,%r4 ___ $code.=<<___ if (!$softonly); lhi %r0,16 cl %r0,240($key) jh .Lcbc_software lg %r0,0($ivp) # copy ivec lg %r1,8($ivp) stmg %r0,%r1,16($sp) lmg %r0,%r1,0($key) # copy key, cover 256 bit stmg %r0,%r1,32($sp) lmg %r0,%r1,16($key) stmg %r0,%r1,48($sp) l %r0,240($key) # load kmc code lghi $key,15 # res=len%16, len-=res; ngr $key,$len sl${g}r $len,$key la %r1,16($sp) # parameter block - ivec || key jz .Lkmc_truncated .long 0xb92f0042 # kmc %r4,%r2 brc 1,.-4 # pay attention to "partial completion" ltr $key,$key jnz .Lkmc_truncated .Lkmc_done: lmg %r0,%r1,16($sp) # copy ivec to caller stg %r0,0($ivp) stg %r1,8($ivp) br $ra .align 16 .Lkmc_truncated: ahi $key,-1 # it's the way it's encoded in mvc tmll %r0,0x80 jnz .Lkmc_truncated_dec lghi %r1,0 stg %r1,16*$SIZE_T($sp) stg %r1,16*$SIZE_T+8($sp) bras %r1,1f mvc 16*$SIZE_T(1,$sp),0($inp) 1: ex $key,0(%r1) la %r1,16($sp) # restore parameter block la $inp,16*$SIZE_T($sp) lghi $len,16 .long 0xb92f0042 # kmc %r4,%r2 j .Lkmc_done .align 16 .Lkmc_truncated_dec: st${g} $out,4*$SIZE_T($sp) la $out,16*$SIZE_T($sp) lghi $len,16 .long 0xb92f0042 # kmc %r4,%r2 l${g} $out,4*$SIZE_T($sp) bras %r1,2f mvc 0(1,$out),16*$SIZE_T($sp) 2: ex $key,0(%r1) j .Lkmc_done .align 16 .Lcbc_software: ___ $code.=<<___; stm${g} $key,$ra,5*$SIZE_T($sp) lhi %r0,0 cl %r0,`$stdframe+$SIZE_T-4`($sp) je .Lcbc_decrypt larl $tbl,AES_Te llgf $s0,0($ivp) llgf $s1,4($ivp) llgf $s2,8($ivp) llgf $s3,12($ivp) lghi $t0,16 sl${g}r $len,$t0 brc 4,.Lcbc_enc_tail # if borrow .Lcbc_enc_loop: stm${g} $inp,$out,2*$SIZE_T($sp) x $s0,0($inp) x $s1,4($inp) x $s2,8($inp) x $s3,12($inp) lgr %r4,$key bras $ra,_s390x_AES_encrypt lm${g} $inp,$key,2*$SIZE_T($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) la $inp,16($inp) la $out,16($out) lghi $t0,16 lt${g}r $len,$len jz .Lcbc_enc_done sl${g}r $len,$t0 brc 4,.Lcbc_enc_tail # if borrow j .Lcbc_enc_loop .align 16 .Lcbc_enc_done: l${g} $ivp,6*$SIZE_T($sp) st $s0,0($ivp) st $s1,4($ivp) st $s2,8($ivp) st $s3,12($ivp) lm${g} %r7,$ra,7*$SIZE_T($sp) br $ra .align 16 .Lcbc_enc_tail: aghi $len,15 lghi $t0,0 stg $t0,16*$SIZE_T($sp) stg $t0,16*$SIZE_T+8($sp) bras $t1,3f mvc 16*$SIZE_T(1,$sp),0($inp) 3: ex $len,0($t1) lghi $len,0 la $inp,16*$SIZE_T($sp) j .Lcbc_enc_loop .align 16 .Lcbc_decrypt: larl $tbl,AES_Td lg $t0,0($ivp) lg $t1,8($ivp) stmg $t0,$t1,16*$SIZE_T($sp) .Lcbc_dec_loop: stm${g} $inp,$out,2*$SIZE_T($sp) llgf $s0,0($inp) llgf $s1,4($inp) llgf $s2,8($inp) llgf $s3,12($inp) lgr %r4,$key bras $ra,_s390x_AES_decrypt lm${g} $inp,$key,2*$SIZE_T($sp) sllg $s0,$s0,32 sllg $s2,$s2,32 lr $s0,$s1 lr $s2,$s3 lg $t0,0($inp) lg $t1,8($inp) xg $s0,16*$SIZE_T($sp) xg $s2,16*$SIZE_T+8($sp) lghi $s1,16 sl${g}r $len,$s1 brc 4,.Lcbc_dec_tail # if borrow brc 2,.Lcbc_dec_done # if zero stg $s0,0($out) stg $s2,8($out) stmg $t0,$t1,16*$SIZE_T($sp) la $inp,16($inp) la $out,16($out) j .Lcbc_dec_loop .Lcbc_dec_done: stg $s0,0($out) stg $s2,8($out) .Lcbc_dec_exit: lm${g} %r6,$ra,6*$SIZE_T($sp) stmg $t0,$t1,0($ivp) br $ra .align 16 .Lcbc_dec_tail: aghi $len,15 stg $s0,16*$SIZE_T($sp) stg $s2,16*$SIZE_T+8($sp) bras $s1,4f mvc 0(1,$out),16*$SIZE_T($sp) 4: ex $len,0($s1) j .Lcbc_dec_exit .size AES_cbc_encrypt,.-AES_cbc_encrypt ___ } ######################################################################## # void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, # size_t blocks, const AES_KEY *key, # const unsigned char *ivec) { my $inp="%r2"; my $out="%r4"; # blocks and out are swapped my $len="%r3"; my $key="%r5"; my $iv0="%r5"; my $ivp="%r6"; my $fp ="%r7"; $code.=<<___; .globl AES_ctr32_encrypt .type AES_ctr32_encrypt,\@function .align 16 AES_ctr32_encrypt: xgr %r3,%r4 # flip %r3 and %r4, $out and $len xgr %r4,%r3 xgr %r3,%r4 llgfr $len,$len # safe in ctr32 subroutine even in 64-bit case ___ $code.=<<___ if (!$softonly); l %r0,240($key) lhi %r1,16 clr %r0,%r1 jl .Lctr32_software stm${g} %r6,$s3,6*$SIZE_T($sp) slgr $out,$inp la %r1,0($key) # %r1 is permanent copy of $key lg $iv0,0($ivp) # load ivec lg $ivp,8($ivp) # prepare and allocate stack frame at the top of 4K page # with 1K reserved for eventual signal handling lghi $s0,-1024-256-16# guarantee at least 256-bytes buffer lghi $s1,-4096 algr $s0,$sp lgr $fp,$sp ngr $s0,$s1 # align at page boundary slgr $fp,$s0 # total buffer size lgr $s2,$sp lghi $s1,1024+16 # sl[g]fi is extended-immediate facility slgr $fp,$s1 # deduct reservation to get usable buffer size # buffer size is at lest 256 and at most 3072+256-16 la $sp,1024($s0) # alloca srlg $fp,$fp,4 # convert bytes to blocks, minimum 16 st${g} $s2,0($sp) # back-chain st${g} $fp,$SIZE_T($sp) slgr $len,$fp brc 1,.Lctr32_hw_switch # not zero, no borrow algr $fp,$len # input is shorter than allocated buffer lghi $len,0 st${g} $fp,$SIZE_T($sp) .Lctr32_hw_switch: ___ $code.=<<___ if (!$softonly && 0);# kmctr code was measured to be ~12% slower llgfr $s0,%r0 lgr $s1,%r1 larl %r1,OPENSSL_s390xcap_P llihh %r0,0x8000 # check if kmctr supports the function code srlg %r0,%r0,0($s0) ng %r0,64(%r1) # check kmctr capability vector lgr %r0,$s0 lgr %r1,$s1 jz .Lctr32_km_loop ####### kmctr code algr $out,$inp # restore $out lgr $s1,$len # $s1 undertakes $len j .Lctr32_kmctr_loop .align 16 .Lctr32_kmctr_loop: la $s2,16($sp) lgr $s3,$fp .Lctr32_kmctr_prepare: stg $iv0,0($s2) stg $ivp,8($s2) la $s2,16($s2) ahi $ivp,1 # 32-bit increment, preserves upper half brct $s3,.Lctr32_kmctr_prepare #la $inp,0($inp) # inp sllg $len,$fp,4 # len #la $out,0($out) # out la $s2,16($sp) # iv .long 0xb92da042 # kmctr $out,$s2,$inp brc 1,.-4 # pay attention to "partial completion" slgr $s1,$fp brc 1,.Lctr32_kmctr_loop # not zero, no borrow algr $fp,$s1 lghi $s1,0 brc 4+1,.Lctr32_kmctr_loop # not zero l${g} $sp,0($sp) lm${g} %r6,$s3,6*$SIZE_T($sp) br $ra .align 16 ___ $code.=<<___ if (!$softonly); .Lctr32_km_loop: la $s2,16($sp) lgr $s3,$fp .Lctr32_km_prepare: stg $iv0,0($s2) stg $ivp,8($s2) la $s2,16($s2) ahi $ivp,1 # 32-bit increment, preserves upper half brct $s3,.Lctr32_km_prepare la $s0,16($sp) # inp sllg $s1,$fp,4 # len la $s2,16($sp) # out .long 0xb92e00a8 # km %r10,%r8 brc 1,.-4 # pay attention to "partial completion" la $s2,16($sp) lgr $s3,$fp slgr $s2,$inp .Lctr32_km_xor: lg $s0,0($inp) lg $s1,8($inp) xg $s0,0($s2,$inp) xg $s1,8($s2,$inp) stg $s0,0($out,$inp) stg $s1,8($out,$inp) la $inp,16($inp) brct $s3,.Lctr32_km_xor slgr $len,$fp brc 1,.Lctr32_km_loop # not zero, no borrow algr $fp,$len lghi $len,0 brc 4+1,.Lctr32_km_loop # not zero l${g} $s0,0($sp) l${g} $s1,$SIZE_T($sp) la $s2,16($sp) .Lctr32_km_zap: stg $s0,0($s2) stg $s0,8($s2) la $s2,16($s2) brct $s1,.Lctr32_km_zap la $sp,0($s0) lm${g} %r6,$s3,6*$SIZE_T($sp) br $ra .align 16 .Lctr32_software: ___ $code.=<<___; stm${g} $key,$ra,5*$SIZE_T($sp) sl${g}r $inp,$out larl $tbl,AES_Te llgf $t1,12($ivp) .Lctr32_loop: stm${g} $inp,$out,2*$SIZE_T($sp) llgf $s0,0($ivp) llgf $s1,4($ivp) llgf $s2,8($ivp) lgr $s3,$t1 st $t1,16*$SIZE_T($sp) lgr %r4,$key bras $ra,_s390x_AES_encrypt lm${g} $inp,$ivp,2*$SIZE_T($sp) llgf $t1,16*$SIZE_T($sp) x $s0,0($inp,$out) x $s1,4($inp,$out) x $s2,8($inp,$out) x $s3,12($inp,$out) stm $s0,$s3,0($out) la $out,16($out) ahi $t1,1 # 32-bit increment brct $len,.Lctr32_loop lm${g} %r6,$ra,6*$SIZE_T($sp) br $ra .size AES_ctr32_encrypt,.-AES_ctr32_encrypt ___ } ######################################################################## # void AES_xts_encrypt(const char *inp,char *out,size_t len, # const AES_KEY *key1, const AES_KEY *key2, # const unsigned char iv[16]); # { my $inp="%r2"; my $out="%r4"; # len and out are swapped my $len="%r3"; my $key1="%r5"; # $i1 my $key2="%r6"; # $i2 my $fp="%r7"; # $i3 my $tweak=16*$SIZE_T+16; # or $stdframe-16, bottom of the frame... $code.=<<___; .type _s390x_xts_km,\@function .align 16 _s390x_xts_km: ___ $code.=<<___ if(1); llgfr $s0,%r0 # put aside the function code lghi $s1,0x7f nr $s1,%r0 larl %r1,OPENSSL_s390xcap_P llihh %r0,0x8000 srlg %r0,%r0,32($s1) # check for 32+function code ng %r0,32(%r1) # check km capability vector lgr %r0,$s0 # restore the function code la %r1,0($key1) # restore $key1 jz .Lxts_km_vanilla lmg $i2,$i3,$tweak($sp) # put aside the tweak value algr $out,$inp oill %r0,32 # switch to xts function code aghi $s1,-18 # sllg $s1,$s1,3 # (function code - 18)*8, 0 or 16 la %r1,$tweak-16($sp) slgr %r1,$s1 # parameter block position lmg $s0,$s3,0($key1) # load 256 bits of key material, stmg $s0,$s3,0(%r1) # and copy it to parameter block. # yes, it contains junk and overlaps # with the tweak in 128-bit case. # it's done to avoid conditional # branch. stmg $i2,$i3,$tweak($sp) # "re-seat" the tweak value .long 0xb92e0042 # km %r4,%r2 brc 1,.-4 # pay attention to "partial completion" lrvg $s0,$tweak+0($sp) # load the last tweak lrvg $s1,$tweak+8($sp) stmg %r0,%r3,$tweak-32($sp) # wipe copy of the key nill %r0,0xffdf # switch back to original function code la %r1,0($key1) # restore pointer to $key1 slgr $out,$inp llgc $len,2*$SIZE_T-1($sp) nill $len,0x0f # $len%=16 br $ra .align 16 .Lxts_km_vanilla: ___ $code.=<<___; # prepare and allocate stack frame at the top of 4K page # with 1K reserved for eventual signal handling lghi $s0,-1024-256-16# guarantee at least 256-bytes buffer lghi $s1,-4096 algr $s0,$sp lgr $fp,$sp ngr $s0,$s1 # align at page boundary slgr $fp,$s0 # total buffer size lgr $s2,$sp lghi $s1,1024+16 # sl[g]fi is extended-immediate facility slgr $fp,$s1 # deduct reservation to get usable buffer size # buffer size is at lest 256 and at most 3072+256-16 la $sp,1024($s0) # alloca nill $fp,0xfff0 # round to 16*n st${g} $s2,0($sp) # back-chain nill $len,0xfff0 # redundant st${g} $fp,$SIZE_T($sp) slgr $len,$fp brc 1,.Lxts_km_go # not zero, no borrow algr $fp,$len # input is shorter than allocated buffer lghi $len,0 st${g} $fp,$SIZE_T($sp) .Lxts_km_go: lrvg $s0,$tweak+0($s2) # load the tweak value in little-endian lrvg $s1,$tweak+8($s2) la $s2,16($sp) # vector of ascending tweak values slgr $s2,$inp srlg $s3,$fp,4 j .Lxts_km_start .Lxts_km_loop: la $s2,16($sp) slgr $s2,$inp srlg $s3,$fp,4 .Lxts_km_prepare: lghi $i1,0x87 srag $i2,$s1,63 # broadcast upper bit ngr $i1,$i2 # rem algr $s0,$s0 alcgr $s1,$s1 xgr $s0,$i1 .Lxts_km_start: lrvgr $i1,$s0 # flip byte order lrvgr $i2,$s1 stg $i1,0($s2,$inp) stg $i2,8($s2,$inp) xg $i1,0($inp) xg $i2,8($inp) stg $i1,0($out,$inp) stg $i2,8($out,$inp) la $inp,16($inp) brct $s3,.Lxts_km_prepare slgr $inp,$fp # rewind $inp la $s2,0($out,$inp) lgr $s3,$fp .long 0xb92e00aa # km $s2,$s2 brc 1,.-4 # pay attention to "partial completion" la $s2,16($sp) slgr $s2,$inp srlg $s3,$fp,4 .Lxts_km_xor: lg $i1,0($out,$inp) lg $i2,8($out,$inp) xg $i1,0($s2,$inp) xg $i2,8($s2,$inp) stg $i1,0($out,$inp) stg $i2,8($out,$inp) la $inp,16($inp) brct $s3,.Lxts_km_xor slgr $len,$fp brc 1,.Lxts_km_loop # not zero, no borrow algr $fp,$len lghi $len,0 brc 4+1,.Lxts_km_loop # not zero l${g} $i1,0($sp) # back-chain llgf $fp,`2*$SIZE_T-4`($sp) # bytes used la $i2,16($sp) srlg $fp,$fp,4 .Lxts_km_zap: stg $i1,0($i2) stg $i1,8($i2) la $i2,16($i2) brct $fp,.Lxts_km_zap la $sp,0($i1) llgc $len,2*$SIZE_T-1($i1) nill $len,0x0f # $len%=16 bzr $ra # generate one more tweak... lghi $i1,0x87 srag $i2,$s1,63 # broadcast upper bit ngr $i1,$i2 # rem algr $s0,$s0 alcgr $s1,$s1 xgr $s0,$i1 ltr $len,$len # clear zero flag br $ra .size _s390x_xts_km,.-_s390x_xts_km .globl AES_xts_encrypt .type AES_xts_encrypt,\@function .align 16 AES_xts_encrypt: xgr %r3,%r4 # flip %r3 and %r4, $out and $len xgr %r4,%r3 xgr %r3,%r4 ___ $code.=<<___ if ($SIZE_T==4); llgfr $len,$len ___ $code.=<<___; st${g} $len,1*$SIZE_T($sp) # save copy of $len srag $len,$len,4 # formally wrong, because it expands # sign byte, but who can afford asking # to process more than 2^63-1 bytes? # I use it, because it sets condition # code... bcr 8,$ra # abort if zero (i.e. less than 16) ___ $code.=<<___ if (!$softonly); llgf %r0,240($key2) lhi %r1,16 clr %r0,%r1 jl .Lxts_enc_software st${g} $ra,5*$SIZE_T($sp) stm${g} %r6,$s3,6*$SIZE_T($sp) sllg $len,$len,4 # $len&=~15 slgr $out,$inp # generate the tweak value l${g} $s3,$stdframe($sp) # pointer to iv la $s2,$tweak($sp) lmg $s0,$s1,0($s3) lghi $s3,16 stmg $s0,$s1,0($s2) la %r1,0($key2) # $key2 is not needed anymore .long 0xb92e00aa # km $s2,$s2, generate the tweak brc 1,.-4 # can this happen? l %r0,240($key1) la %r1,0($key1) # $key1 is not needed anymore bras $ra,_s390x_xts_km jz .Lxts_enc_km_done aghi $inp,-16 # take one step back la $i3,0($out,$inp) # put aside real $out .Lxts_enc_km_steal: llgc $i1,16($inp) llgc $i2,0($out,$inp) stc $i1,0($out,$inp) stc $i2,16($out,$inp) la $inp,1($inp) brct $len,.Lxts_enc_km_steal la $s2,0($i3) lghi $s3,16 lrvgr $i1,$s0 # flip byte order lrvgr $i2,$s1 xg $i1,0($s2) xg $i2,8($s2) stg $i1,0($s2) stg $i2,8($s2) .long 0xb92e00aa # km $s2,$s2 brc 1,.-4 # can this happen? lrvgr $i1,$s0 # flip byte order lrvgr $i2,$s1 xg $i1,0($i3) xg $i2,8($i3) stg $i1,0($i3) stg $i2,8($i3) .Lxts_enc_km_done: stg $sp,$tweak+0($sp) # wipe tweak stg $sp,$tweak+8($sp) l${g} $ra,5*$SIZE_T($sp) lm${g} %r6,$s3,6*$SIZE_T($sp) br $ra .align 16 .Lxts_enc_software: ___ $code.=<<___; stm${g} %r6,$ra,6*$SIZE_T($sp) slgr $out,$inp l${g} $s3,$stdframe($sp) # ivp llgf $s0,0($s3) # load iv llgf $s1,4($s3) llgf $s2,8($s3) llgf $s3,12($s3) stm${g} %r2,%r5,2*$SIZE_T($sp) la $key,0($key2) larl $tbl,AES_Te bras $ra,_s390x_AES_encrypt # generate the tweak lm${g} %r2,%r5,2*$SIZE_T($sp) stm $s0,$s3,$tweak($sp) # save the tweak j .Lxts_enc_enter .align 16 .Lxts_enc_loop: lrvg $s1,$tweak+0($sp) # load the tweak in little-endian lrvg $s3,$tweak+8($sp) lghi %r1,0x87 srag %r0,$s3,63 # broadcast upper bit ngr %r1,%r0 # rem algr $s1,$s1 alcgr $s3,$s3 xgr $s1,%r1 lrvgr $s1,$s1 # flip byte order lrvgr $s3,$s3 srlg $s0,$s1,32 # smash the tweak to 4x32-bits stg $s1,$tweak+0($sp) # save the tweak llgfr $s1,$s1 srlg $s2,$s3,32 stg $s3,$tweak+8($sp) llgfr $s3,$s3 la $inp,16($inp) # $inp+=16 .Lxts_enc_enter: x $s0,0($inp) # ^=*($inp) x $s1,4($inp) x $s2,8($inp) x $s3,12($inp) stm${g} %r2,%r3,2*$SIZE_T($sp) # only two registers are changing la $key,0($key1) bras $ra,_s390x_AES_encrypt lm${g} %r2,%r5,2*$SIZE_T($sp) x $s0,$tweak+0($sp) # ^=tweak x $s1,$tweak+4($sp) x $s2,$tweak+8($sp) x $s3,$tweak+12($sp) st $s0,0($out,$inp) st $s1,4($out,$inp) st $s2,8($out,$inp) st $s3,12($out,$inp) brct${g} $len,.Lxts_enc_loop llgc $len,`2*$SIZE_T-1`($sp) nill $len,0x0f # $len%16 jz .Lxts_enc_done la $i3,0($inp,$out) # put aside real $out .Lxts_enc_steal: llgc %r0,16($inp) llgc %r1,0($out,$inp) stc %r0,0($out,$inp) stc %r1,16($out,$inp) la $inp,1($inp) brct $len,.Lxts_enc_steal la $out,0($i3) # restore real $out # generate last tweak... lrvg $s1,$tweak+0($sp) # load the tweak in little-endian lrvg $s3,$tweak+8($sp) lghi %r1,0x87 srag %r0,$s3,63 # broadcast upper bit ngr %r1,%r0 # rem algr $s1,$s1 alcgr $s3,$s3 xgr $s1,%r1 lrvgr $s1,$s1 # flip byte order lrvgr $s3,$s3 srlg $s0,$s1,32 # smash the tweak to 4x32-bits stg $s1,$tweak+0($sp) # save the tweak llgfr $s1,$s1 srlg $s2,$s3,32 stg $s3,$tweak+8($sp) llgfr $s3,$s3 x $s0,0($out) # ^=*(inp)|stolen cipther-text x $s1,4($out) x $s2,8($out) x $s3,12($out) st${g} $out,4*$SIZE_T($sp) la $key,0($key1) bras $ra,_s390x_AES_encrypt l${g} $out,4*$SIZE_T($sp) x $s0,`$tweak+0`($sp) # ^=tweak x $s1,`$tweak+4`($sp) x $s2,`$tweak+8`($sp) x $s3,`$tweak+12`($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) .Lxts_enc_done: stg $sp,$tweak+0($sp) # wipe tweak stg $sp,$twesk+8($sp) lm${g} %r6,$ra,6*$SIZE_T($sp) br $ra .size AES_xts_encrypt,.-AES_xts_encrypt ___ # void AES_xts_decrypt(const char *inp,char *out,size_t len, # const AES_KEY *key1, const AES_KEY *key2, # const unsigned char iv[16]); # $code.=<<___; .globl AES_xts_decrypt .type AES_xts_decrypt,\@function .align 16 AES_xts_decrypt: xgr %r3,%r4 # flip %r3 and %r4, $out and $len xgr %r4,%r3 xgr %r3,%r4 ___ $code.=<<___ if ($SIZE_T==4); llgfr $len,$len ___ $code.=<<___; st${g} $len,1*$SIZE_T($sp) # save copy of $len aghi $len,-16 bcr 4,$ra # abort if less than zero. formally # wrong, because $len is unsigned, # but who can afford asking to # process more than 2^63-1 bytes? tmll $len,0x0f jnz .Lxts_dec_proceed aghi $len,16 .Lxts_dec_proceed: ___ $code.=<<___ if (!$softonly); llgf %r0,240($key2) lhi %r1,16 clr %r0,%r1 jl .Lxts_dec_software st${g} $ra,5*$SIZE_T($sp) stm${g} %r6,$s3,6*$SIZE_T($sp) nill $len,0xfff0 # $len&=~15 slgr $out,$inp # generate the tweak value l${g} $s3,$stdframe($sp) # pointer to iv la $s2,$tweak($sp) lmg $s0,$s1,0($s3) lghi $s3,16 stmg $s0,$s1,0($s2) la %r1,0($key2) # $key2 is not needed past this point .long 0xb92e00aa # km $s2,$s2, generate the tweak brc 1,.-4 # can this happen? l %r0,240($key1) la %r1,0($key1) # $key1 is not needed anymore ltgr $len,$len jz .Lxts_dec_km_short bras $ra,_s390x_xts_km jz .Lxts_dec_km_done lrvgr $s2,$s0 # make copy in reverse byte order lrvgr $s3,$s1 j .Lxts_dec_km_2ndtweak .Lxts_dec_km_short: llgc $len,`2*$SIZE_T-1`($sp) nill $len,0x0f # $len%=16 lrvg $s0,$tweak+0($sp) # load the tweak lrvg $s1,$tweak+8($sp) lrvgr $s2,$s0 # make copy in reverse byte order lrvgr $s3,$s1 .Lxts_dec_km_2ndtweak: lghi $i1,0x87 srag $i2,$s1,63 # broadcast upper bit ngr $i1,$i2 # rem algr $s0,$s0 alcgr $s1,$s1 xgr $s0,$i1 lrvgr $i1,$s0 # flip byte order lrvgr $i2,$s1 xg $i1,0($inp) xg $i2,8($inp) stg $i1,0($out,$inp) stg $i2,8($out,$inp) la $i2,0($out,$inp) lghi $i3,16 .long 0xb92e0066 # km $i2,$i2 brc 1,.-4 # can this happen? lrvgr $i1,$s0 lrvgr $i2,$s1 xg $i1,0($out,$inp) xg $i2,8($out,$inp) stg $i1,0($out,$inp) stg $i2,8($out,$inp) la $i3,0($out,$inp) # put aside real $out .Lxts_dec_km_steal: llgc $i1,16($inp) llgc $i2,0($out,$inp) stc $i1,0($out,$inp) stc $i2,16($out,$inp) la $inp,1($inp) brct $len,.Lxts_dec_km_steal lgr $s0,$s2 lgr $s1,$s3 xg $s0,0($i3) xg $s1,8($i3) stg $s0,0($i3) stg $s1,8($i3) la $s0,0($i3) lghi $s1,16 .long 0xb92e0088 # km $s0,$s0 brc 1,.-4 # can this happen? xg $s2,0($i3) xg $s3,8($i3) stg $s2,0($i3) stg $s3,8($i3) .Lxts_dec_km_done: stg $sp,$tweak+0($sp) # wipe tweak stg $sp,$tweak+8($sp) l${g} $ra,5*$SIZE_T($sp) lm${g} %r6,$s3,6*$SIZE_T($sp) br $ra .align 16 .Lxts_dec_software: ___ $code.=<<___; stm${g} %r6,$ra,6*$SIZE_T($sp) srlg $len,$len,4 slgr $out,$inp l${g} $s3,$stdframe($sp) # ivp llgf $s0,0($s3) # load iv llgf $s1,4($s3) llgf $s2,8($s3) llgf $s3,12($s3) stm${g} %r2,%r5,2*$SIZE_T($sp) la $key,0($key2) larl $tbl,AES_Te bras $ra,_s390x_AES_encrypt # generate the tweak lm${g} %r2,%r5,2*$SIZE_T($sp) larl $tbl,AES_Td lt${g}r $len,$len stm $s0,$s3,$tweak($sp) # save the tweak jz .Lxts_dec_short j .Lxts_dec_enter .align 16 .Lxts_dec_loop: lrvg $s1,$tweak+0($sp) # load the tweak in little-endian lrvg $s3,$tweak+8($sp) lghi %r1,0x87 srag %r0,$s3,63 # broadcast upper bit ngr %r1,%r0 # rem algr $s1,$s1 alcgr $s3,$s3 xgr $s1,%r1 lrvgr $s1,$s1 # flip byte order lrvgr $s3,$s3 srlg $s0,$s1,32 # smash the tweak to 4x32-bits stg $s1,$tweak+0($sp) # save the tweak llgfr $s1,$s1 srlg $s2,$s3,32 stg $s3,$tweak+8($sp) llgfr $s3,$s3 .Lxts_dec_enter: x $s0,0($inp) # tweak^=*(inp) x $s1,4($inp) x $s2,8($inp) x $s3,12($inp) stm${g} %r2,%r3,2*$SIZE_T($sp) # only two registers are changing la $key,0($key1) bras $ra,_s390x_AES_decrypt lm${g} %r2,%r5,2*$SIZE_T($sp) x $s0,$tweak+0($sp) # ^=tweak x $s1,$tweak+4($sp) x $s2,$tweak+8($sp) x $s3,$tweak+12($sp) st $s0,0($out,$inp) st $s1,4($out,$inp) st $s2,8($out,$inp) st $s3,12($out,$inp) la $inp,16($inp) brct${g} $len,.Lxts_dec_loop llgc $len,`2*$SIZE_T-1`($sp) nill $len,0x0f # $len%16 jz .Lxts_dec_done # generate pair of tweaks... lrvg $s1,$tweak+0($sp) # load the tweak in little-endian lrvg $s3,$tweak+8($sp) lghi %r1,0x87 srag %r0,$s3,63 # broadcast upper bit ngr %r1,%r0 # rem algr $s1,$s1 alcgr $s3,$s3 xgr $s1,%r1 lrvgr $i2,$s1 # flip byte order lrvgr $i3,$s3 stmg $i2,$i3,$tweak($sp) # save the 1st tweak j .Lxts_dec_2ndtweak .align 16 .Lxts_dec_short: llgc $len,`2*$SIZE_T-1`($sp) nill $len,0x0f # $len%16 lrvg $s1,$tweak+0($sp) # load the tweak in little-endian lrvg $s3,$tweak+8($sp) .Lxts_dec_2ndtweak: lghi %r1,0x87 srag %r0,$s3,63 # broadcast upper bit ngr %r1,%r0 # rem algr $s1,$s1 alcgr $s3,$s3 xgr $s1,%r1 lrvgr $s1,$s1 # flip byte order lrvgr $s3,$s3 srlg $s0,$s1,32 # smash the tweak to 4x32-bits stg $s1,$tweak-16+0($sp) # save the 2nd tweak llgfr $s1,$s1 srlg $s2,$s3,32 stg $s3,$tweak-16+8($sp) llgfr $s3,$s3 x $s0,0($inp) # tweak_the_2nd^=*(inp) x $s1,4($inp) x $s2,8($inp) x $s3,12($inp) stm${g} %r2,%r3,2*$SIZE_T($sp) la $key,0($key1) bras $ra,_s390x_AES_decrypt lm${g} %r2,%r5,2*$SIZE_T($sp) x $s0,$tweak-16+0($sp) # ^=tweak_the_2nd x $s1,$tweak-16+4($sp) x $s2,$tweak-16+8($sp) x $s3,$tweak-16+12($sp) st $s0,0($out,$inp) st $s1,4($out,$inp) st $s2,8($out,$inp) st $s3,12($out,$inp) la $i3,0($out,$inp) # put aside real $out .Lxts_dec_steal: llgc %r0,16($inp) llgc %r1,0($out,$inp) stc %r0,0($out,$inp) stc %r1,16($out,$inp) la $inp,1($inp) brct $len,.Lxts_dec_steal la $out,0($i3) # restore real $out lm $s0,$s3,$tweak($sp) # load the 1st tweak x $s0,0($out) # tweak^=*(inp)|stolen cipher-text x $s1,4($out) x $s2,8($out) x $s3,12($out) st${g} $out,4*$SIZE_T($sp) la $key,0($key1) bras $ra,_s390x_AES_decrypt l${g} $out,4*$SIZE_T($sp) x $s0,$tweak+0($sp) # ^=tweak x $s1,$tweak+4($sp) x $s2,$tweak+8($sp) x $s3,$tweak+12($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) stg $sp,$tweak-16+0($sp) # wipe 2nd tweak stg $sp,$tweak-16+8($sp) .Lxts_dec_done: stg $sp,$tweak+0($sp) # wipe tweak stg $sp,$twesk+8($sp) lm${g} %r6,$ra,6*$SIZE_T($sp) br $ra .size AES_xts_decrypt,.-AES_xts_decrypt ___ } $code.=<<___; .string "AES for s390x, CRYPTOGAMS by <appro\@openssl.org>" ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; print $code; close STDOUT; # force flush
google/google-ctf
third_party/edk2/CryptoPkg/Library/OpensslLib/openssl/crypto/aes/asm/aes-s390x.pl
Perl
apache-2.0
53,166
package DDG::Goodie::GuitarChords; # ABSTRACT: Returns diagrams of guitar chords use DDG::Goodie; use strict; with 'DDG::GoodieRole::ImageLoader'; # guitar script is stored in share directory # including this way, because it limits duplicated code my $g = share("chords.pm"); do "$g"; our %chord_lists; #from chords.pm zci answer_type => 'guitarchord'; zci is_cached => 1; triggers startend => ('guitar chord'); handle remainder => sub { if (my $c //= check_chord($_)) { my $f = $c; # filenames use '_' instead of parenthesies $f =~ s/[\(\)]/_/g; $f =~ s/([^dim])m/$1minor/g; $f =~ s/M/major/g; return heading => "$c", answer => "$c", html => "<div class='text--secondary'>Guitar chord diagram for $c</div>" . get_chord_img($f); } return; }; # Checks a chord to make sure it's valid and formats it so # that it will match a filename in the share directory. sub check_chord { if ($_[0] =~ /^(?<a>[a-gA-G])(?<b>#|b)?\s*(?<c>dim|min|maj|add|aug|m|M)?\s*(?<d>M|maj|m|min)?(?<e>[0-9]?(sus[0-9])?)?(\/(?<f>(#|b)?[0-9]+))?$/) { my ($a,$b,$c,$d,$e,$f,$r); $a = uc($+{'a'}); $b = $+{'b'} if $+{'b'}; if ($c = $+{'c'}) { $c = 'm' if ($c =~ /^(min|m)$/); $c = 'M' if ($c =~ /^(maj|M)$/); } if ($d = $+{'d'}) { $d = 'm' if ($d =~ /^(min|m)$/); $d = 'M' if ($d =~ /^(maj|M)$/); } $e = $+{'e'} if $+{'e'}; $f = '('.$+{'f'}.')' if $+{'f'}; $r = $a if $a; $r .= $b if $b; $r .= $c if $c; $r .= $d if $d; $r .= $e if $e; $r .= $f if $f; if (exists($chord_lists{$r})) { return $r; } } return; } # Returns an image tag with the correct filename and width. sub get_chord_img { goodie_img_tag({filename=>$_[0].'.png', width=>78}); } 1;
aleksandar-todorovic/zeroclickinfo-goodies
lib/DDG/Goodie/GuitarChords.pm
Perl
apache-2.0
1,936
#! c:\perl\bin\perl.exe #----------------------------------------------------------- # typedurlstime.pl # Plugin for Registry Ripper, NTUSER.DAT edition - gets the # TypedURLsTime values/data from Windows 8 systems # # Change history # 20120613 - created # # References # http://dfstream.blogspot.com/2012/05/windows-8-typedurlstime.html # # Notes: New entries aren't added to the key until the current # instance of IE is terminated. # # copyright 2012 Quantum Analytics Research, LLC # Author: H. Carvey, keydet89@yahoo.com #----------------------------------------------------------- package typedurlstime; use strict; my %config = (hive => "NTUSER\.DAT", hasShortDescr => 1, hasDescr => 0, hasRefs => 1, osmask => 22, version => 20120613); sub getConfig{return %config} sub getShortDescr { return "Returns contents of user's TypedURLsTime key."; } sub getDescr{} sub getRefs {} sub getHive {return $config{hive};} sub getVersion {return $config{version};} my $VERSION = getVersion(); sub pluginmain { my $class = shift; my $ntuser = shift; ::logMsg("Launching typedurlstime v.".$VERSION); ::rptMsg("typedurlstime v.".$VERSION); # banner ::rptMsg("(".$config{hive}.") ".getShortDescr()."\n"); # banner my $reg = Parse::Win32Registry->new($ntuser); my $root_key = $reg->get_root_key; my $key_path = 'Software\\Microsoft\\Internet Explorer\\TypedURLsTime'; my $key; if ($key = $root_key->get_subkey($key_path)) { ::rptMsg("TypedURLsTime"); ::rptMsg($key_path); ::rptMsg("LastWrite Time ".gmtime($key->get_timestamp())." (UTC)"); my @vals = $key->get_list_of_values(); if (scalar(@vals) > 0) { my %urls; # Retrieve values and load into a hash for sorting foreach my $v (@vals) { my $val = $v->get_name(); my ($t0,$t1) = unpack("VV",$v->get_data()); my $data = ::getTime($t0,$t1); my $tag = (split(/url/,$val))[1]; $urls{$tag} = $val.":".$data; } # Print sorted content to report file foreach my $u (sort {$a <=> $b} keys %urls) { my ($val,$data) = split(/:/,$urls{$u},2); my $url; eval { $url = $root_key->get_subkey('Software\\Microsoft\\Internet Explorer\\TypedURLs')->get_value($val)->get_data(); }; if ($data == 0) { ::rptMsg(" ".$val." -> ".$data); } else { ::rptMsg(" ".$val." -> ".gmtime($data)." Z (".$url.")"); } } } else { ::rptMsg($key_path." has no values."); } } else { ::rptMsg($key_path." not found."); } } 1;
dgrove727/autopsy
thirdparty/rr-full/plugins/typedurlstime.pl
Perl
apache-2.0
2,587
=encoding utf8 =head1 NAME perl5122delta - what is new for perl v5.12.2 =head1 DESCRIPTION This document describes differences between the 5.12.1 release and the 5.12.2 release. If you are upgrading from an earlier major version, such as 5.10.1, first read L<perl5120delta>, which describes differences between 5.10.1 and 5.12.0, as well as L<perl5121delta>, which describes earlier changes in the 5.12 stable release series. =head1 Incompatible Changes There are no changes intentionally incompatible with 5.12.1. If any exist, they are bugs and reports are welcome. =head1 Core Enhancements Other than the bug fixes listed below, there should be no user-visible changes to the core language in this release. =head1 Modules and Pragmata =head2 New Modules and Pragmata This release does not introduce any new modules or pragmata. =head2 Pragmata Changes In the previous release, C<no I<VERSION>;> statements triggered a bug which could cause L<feature> bundles to be loaded and L<strict> mode to be enabled unintentionally. =head2 Updated Modules =over 4 =item C<Carp> Upgraded from version 1.16 to 1.17. L<Carp> now detects incomplete L<caller()|perlfunc/"caller EXPR"> overrides and avoids using bogus C<@DB::args>. To provide backtraces, Carp relies on particular behaviour of the caller built-in. Carp now detects if other code has overridden this with an incomplete implementation, and modifies its backtrace accordingly. Previously incomplete overrides would cause incorrect values in backtraces (best case), or obscure fatal errors (worst case) This fixes certain cases of C<Bizarre copy of ARRAY> caused by modules overriding C<caller()> incorrectly. =item C<CPANPLUS> A patch to F<cpanp-run-perl> has been backported from CPANPLUS C<0.9004>. This resolves L<RT #55964|http://rt.cpan.org/Public/Bug/Display.html?id=55964> and L<RT #57106|http://rt.cpan.org/Public/Bug/Display.html?id=57106>, both of which related to failures to install distributions that use C<Module::Install::DSL>. =item C<File::Glob> A regression which caused a failure to find C<CORE::GLOBAL::glob> after loading C<File::Glob> to crash has been fixed. Now, it correctly falls back to external globbing via C<pp_glob>. =item C<File::Copy> C<File::Copy::copy(FILE, DIR)> is now documented. =item C<File::Spec> Upgraded from version 3.31 to 3.31_01. Several portability fixes were made in C<File::Spec::VMS>: a colon is now recognized as a delimiter in native filespecs; caret-escaped delimiters are recognized for better handling of extended filespecs; C<catpath()> returns an empty directory rather than the current directory if the input directory name is empty; C<abs2rel()> properly handles Unix-style input. =back =head1 Utility Changes =over =item * F<perlbug> now always gives the reporter a chance to change the email address it guesses for them. =item * F<perlbug> should no longer warn about uninitialized values when using the C<-d> and C<-v> options. =back =head1 Changes to Existing Documentation =over =item * The existing policy on backward-compatibility and deprecation has been added to L<perlpolicy>, along with definitions of terms like I<deprecation>. =item * L<perlfunc/srand>'s usage has been clarified. =item * The entry for L<perlfunc/die> was reorganized to emphasize its role in the exception mechanism. =item * Perl's L<INSTALL> file has been clarified to explicitly state that Perl requires a C89 compliant ANSI C Compiler. =item * L<IO::Socket>'s C<getsockopt()> and C<setsockopt()> have been documented. =item * F<alarm()>'s inability to interrupt blocking IO on Windows has been documented. =item * L<Math::TrulyRandom> hasn't been updated since 1996 and has been removed as a recommended solution for random number generation. =item * L<perlrun> has been updated to clarify the behaviour of octal flags to F<perl>. =item * To ease user confusion, C<$#> and C<$*>, two special variables that were removed in earlier versions of Perl have been documented. =item * The version of L<perlfaq> shipped with the Perl core has been updated from the official FAQ version, which is now maintained in the C<briandfoy/perlfaq> branch of the Perl repository at L<git://perl5.git.perl.org/perl.git>. =back =head1 Installation and Configuration Improvements =head2 Configuration improvements =over =item * The C<d_u32align> configuration probe on ARM has been fixed. =back =head2 Compilation improvements =over =item * An "C<incompatible operand types>" error in ternary expressions when building with C<clang> has been fixed. =item * Perl now skips setuid C<File::Copy> tests on partitions it detects to be mounted as C<nosuid>. =back =head1 Selected Bug Fixes =over 4 =item * A possible segfault in the C<T_PRTOBJ> default typemap has been fixed. =item * A possible memory leak when using L<caller()|perlfunc/"caller EXPR"> to set C<@DB::args> has been fixed. =item * Several memory leaks when loading XS modules were fixed. =item * C<unpack()> now handles scalar context correctly for C<%32H> and C<%32u>, fixing a potential crash. C<split()> would crash because the third item on the stack wasn't the regular expression it expected. C<unpack("%2H", ...)> would return both the unpacked result and the checksum on the stack, as would C<unpack("%2u", ...)>. L<[perl #73814]|http://rt.perl.org/rt3/Ticket/Display.html?id=73814> =item * Perl now avoids using memory after calling C<free()> in F<pp_require> when there are CODEREFs in C<@INC>. =item * A bug that could cause "C<Unknown error>" messages when "C<call_sv(code, G_EVAL)>" is called from an XS destructor has been fixed. =item * The implementation of the C<open $fh, 'E<gt>' \$buffer> feature now supports get/set magic and thus tied buffers correctly. =item * The C<pp_getc>, C<pp_tell>, and C<pp_eof> opcodes now make room on the stack for their return values in cases where no argument was passed in. =item * When matching unicode strings under some conditions inappropriate backtracking would result in a C<Malformed UTF-8 character (fatal)> error. This should no longer occur. See L<[perl #75680]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=75680> =back =head1 Platform Specific Notes =head2 AIX =over =item * F<README.aix> has been updated with information about the XL C/C++ V11 compiler suite. =back =head2 Windows =over =item * When building Perl with the mingw64 x64 cross-compiler C<incpath>, C<libpth>, C<ldflags>, C<lddlflags> and C<ldflags_nolargefiles> values in F<Config.pm> and F<Config_heavy.pl> were not previously being set correctly because, with that compiler, the include and lib directories are not immediately below C<$(CCHOME)>. =back =head2 VMS =over =item * F<git_version.h> is now installed on VMS. This was an oversight in v5.12.0 which caused some extensions to fail to build. =item * Several memory leaks in L<stat()|perlfunc/"stat FILEHANDLE"> have been fixed. =item * A memory leak in C<Perl_rename()> due to a double allocation has been fixed. =item * A memory leak in C<vms_fid_to_name()> (used by C<realpath()> and C<realname()>) has been fixed. =back =head1 Acknowledgements Perl 5.12.2 represents approximately three months of development since Perl 5.12.1 and contains approximately 2,000 lines of changes across 100 files from 36 authors. Perl continues to flourish into its third decade thanks to a vibrant community of users and developers. The following people are known to have contributed the improvements that became Perl 5.12.2: Abigail, Ævar Arnfjörð Bjarmason, Ben Morrow, brian d foy, Brian Phillips, Chas. Owens, Chris 'BinGOs' Williams, Chris Williams, Craig A. Berry, Curtis Jewell, Dan Dascalescu, David Golden, David Mitchell, Father Chrysostomos, Florian Ragwitz, George Greer, H.Merijn Brand, Jan Dubois, Jesse Vincent, Jim Cromie, Karl Williamson, Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯, Leon Brocard, Maik Hentsche, Matt S Trout, Nicholas Clark, Rafael Garcia-Suarez, Rainer Tammer, Ricardo Signes, Salvador Ortiz Garcia, Sisyphus, Slaven Rezic, Steffen Mueller, Tony Cook, Vincent Pit and Yves Orton. =head1 Reporting Bugs If you find what you think is a bug, you might check the articles recently posted to the comp.lang.perl.misc newsgroup and the perl bug database at http://rt.perl.org/perlbug/ . There may also be information at http://www.perl.org/ , the Perl Home Page. If you believe you have an unreported bug, please run the B<perlbug> program included with your release. Be sure to trim your bug down to a tiny but sufficient test case. Your bug report, along with the output of C<perl -V>, will be sent off to perlbug@perl.org to be analysed by the Perl porting team. If the bug you are reporting has security implications, which make it inappropriate to send to a publicly archived mailing list, then please send it to perl5-security-report@perl.org. This points to a closed subscription unarchived mailing list, which includes all the core committers, who will be able to help assess the impact of issues, figure out a resolution, and help co-ordinate the release of patches to mitigate or fix the problem across all platforms on which Perl is supported. Please only use this address for security issues in the Perl core, not for modules independently distributed on CPAN. =head1 SEE ALSO The F<Changes> file for an explanation of how to view exhaustive details on what changed. The F<INSTALL> file for how to build Perl. The F<README> file for general stuff. The F<Artistic> and F<Copying> files for copyright information. =cut
liuyangning/WX_web
xampp/perl/lib/pods/perl5122delta.pod
Perl
mit
9,603
package OpenGL::Spec; # A very simple task further complicated by the fact that some people # can't read, others use legacy Operating Systems, and others don't give # a damn about using a halfway decent text editor. # # The code to parse the _template_ is so simple and straightforward... # yet the code to parse the real spec files is this mess. my %typemap = ( bitfield => "GLbitfield", boolean => "GLboolean", # fsck up in EXT_vertex_array Boolean => "GLboolean", byte => "GLbyte", clampd => "GLclampd", clampf => "GLclampf", double => "GLdouble", enum => "GLenum", # Intel fsck up Glenum => "GLenum", float => "GLfloat", half => "GLuint", int => "GLint", short => "GLshort", sizei => "GLsizei", ubyte => "GLubyte", uint => "GLuint", ushort => "GLushort", DMbuffer => "void *", # ARB VBO introduces these sizeiptrARB => "GLsizeiptrARB", intptrARB => "GLintptrARB", # ARB shader objects introduces these, charARB is at least 8 bits, # handleARB is at least 32 bits charARB => "GLcharARB", handleARB => "GLhandleARB", # GLX 1.3 defines new types which might not be available at compile time #GLXFBConfig => "void*", #GLXFBConfigID => "XID", #GLXContextID => "XID", #GLXWindow => "XID", #GLXPbuffer => "XID", # Weird stuff for some SGIX extension #GLXFBConfigSGIX => "void*", #GLXFBConfigIDSGIX => "XID", ); my %void_typemap = ( void => "GLvoid", ); my $section_re = qr{^[A-Z]}; my $function_re = qr{^(.+) ([a-z][a-z0-9_]*) \((.+)\)$}i; my $token_re = qr{^([A-Z0-9][A-Z0-9_]*):?\s+((?:0x)?[0-9A-F]+)(.*)$}; my $prefix_re = qr{^(?:AGL | GLX | WGL)_}x; my $eofnc_re = qr{ \);?$ | ^$ }x; my $function_re = qr{^(.+) ([a-z][a-z0-9_]*) \((.+)\)$}i; my $prefix_re = qr{^(?:gl | agl | wgl | glX)}x; my $types_re = __compile_wordlist_cap(keys %typemap); my $voidtype_re = __compile_wordlist_cap(keys %void_typemap); sub new($) { my $class = shift; my $self = { section => {} }; $self->{filename} = shift; local $/; open(my $fh, "<$self->{filename}") or die "Can't open $self->{filename}"; my $content = <$fh>; my $section; my $s = $self->{section}; $content =~ s{[ \t]+$}{}mg; # Join lines that end with a word-character and ones that *begin* # with one $content =~ s{(\w)\n(\w)}{$1 $2}sg; foreach (split /\n/, $content) { if (/$section_re/) { chomp; s/^Name String$/Name Strings/; # Fix common mistake $section = $_; $s->{$section} = ""; } elsif (defined $section and exists $s->{$section}) { s{^\s+}{}mg; # Remove leading whitespace $s->{$section} .= $_ . "\n"; } } $s->{$_} =~ s{(?:^\n+|\n+$)}{}s foreach keys %$s; bless $self, $class; } sub sections() { my $self = shift; keys %{$self->{section}}; } sub name() { my $self = shift; $self->{section}->{Name}; } sub name_strings() { my $self = shift; split("\n", $self->{section}->{"Name Strings"}); } sub tokens() { my $self = shift; my %tokens = (); foreach (split /\n/, $self->{section}->{"New Tokens"}) { next unless /$token_re/; my ($name, $value) = ($1, $2); $name =~ s{^}{GL_} unless $name =~ /$prefix_re/; $tokens{$name} = $value; } return %tokens; } sub functions() { my $self = shift; my %functions = (); my @fnc = (); foreach (split /\n/, $self->{section}->{"New Procedures and Functions"}) { push @fnc, $_ unless ($_ eq "" or $_ eq "None"); next unless /$eofnc_re/; if (__normalize_proto(@fnc) =~ /$function_re/) { my ($return, $name, $parms) = ($1, $2, $3); if (!__ignore_function($name, $extname)) { $name =~ s/^/gl/ unless $name =~ /$prefix_re/; if ($name =~ /^gl/ && $name !~ /^glX/) { $return =~ s/$types_re/$typemap{$1}/g; $return =~ s/$voidtype_re/$void_typemap{$1}/g; $parms =~ s/$types_re/$typemap{$1}/g; $parms =~ s/$voidtype_re/$void_typemap{$1}/g; } $functions{$name} = { rtype => $return, parms => $parms, }; } } @fnc = (); } return %functions; } sub __normalize_proto { local $_ = join(" ", @_); s/\s+/ /g; # multiple whitespace -> single space s/\s*\(\s*/ \(/; # exactly one space before ( and none after s/\s*\)\s*/\)/; # no after before or after ) s/\s*\*([a-zA-Z])/\* $1/; # "* identifier" XXX: g missing? s/\*wgl/\* wgl/; # "* wgl" XXX: why doesn't the s/\*glX/\* glX/; # "* glX" previous re catch this? s/\.\.\./void/; # ... -> void s/;$//; # remove ; at the end of the line return $_; } sub __ignore_function { return 0; } sub __compile_regex { my $regex = join('', @_); return qr/$regex/ } sub __compile_wordlist_cap { __compile_regex('\b(', join('|', @_), ')\b'); }
andresodio/lager
viewer/external/glew-1.9.0/auto/lib/OpenGL/Spec.pm
Perl
mit
5,621
# # $Header: svn://svn/SWM/trunk/web/MoveCombos.pm 8251 2013-04-08 09:00:53Z rlee $ # package MoveCombos; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(getMoveSelectBoxes); use strict; sub getMoveSelectBoxes { my($Data, $divID, $fromlabel, $tolabel, $fromdata, $todata, $width, $height, $activeorder) =@_; my $fromdatastr=''; my $todatastr=''; $width ||= 270; $height ||= 360; for my $i (@{$fromdata}) { my $name=$i->[1] || next; $fromdatastr.='<li id = "ms'.$divID.'-'.$i->[0].'" class = "movecombobox-item">'.$name.'</li>'; } for my $i (@{$todata}) { my $name=$i->[1] || next; $todatastr.='<li id = "ms'.$divID.'-'.$i->[0].'" class = "movecombobox-item">'.$name.'</li>'; } my $js=qq~ movecombos('$divID', '$activeorder'); ~; my $page = qq[ <div id = "$divID" class = "movecomboboxes_wrapper"> <fieldset class = "movecomboboxes_box_wrapper" style = "width:].$width.qq[px;height:].$height.qq[px;"> <legend>$fromlabel</legend> <ul id = "leftbox_$divID" class = "movecomboboxes movecomboxes-left" style = "width:].$width.qq[px;height:].($height-20).qq[px">$fromdatastr </ul> </fieldset> <fieldset class = "movecomboboxes_box_wrapper" style = "width:].$width.qq[px;height:].$height.qq[px;"> <legend>$tolabel</legend> <ul id = "rightbox_$divID" class = "movecomboboxes movecomboxes-right" style = "width:].$width.qq[px;height:].($height-20).qq[px">$todatastr </ul> </fieldset> </div> ]; $Data->{'AddToPage'}->add('js_bottom','file','js/movecomboboxes.js'); $Data->{'AddToPage'}->add('js_bottom','inline',$js); return $page; } 1;
facascante/slimerp
fifs/web/MoveCombos.pm
Perl
mit
1,600
package CXGN::Stock::Catalog; use Moose; use Data::Dumper; extends 'CXGN::JSONProp'; # a general human readable description of the stock has 'description' => ( isa => 'Str', is => 'rw' ); # a list of representative images, given as image_ids has 'images' => ( isa => 'Maybe[ArrayRef]', is => 'rw' ); # availability status: in_stock, delayed, currently_unavailable ... has 'availability' => ( isa => 'Str', is => 'rw' ); # list of hashrefs like { stock_center => { name => ..., count_available => ..., delivery_time => } } has 'order_source' => ( isa => 'ArrayRef', is => 'rw'); # center that generates clones or seed has 'material_source' => ( isa => 'Str', is => 'rw'); # item type such as single accession or a set of 10 accessions has 'item_type' => ( isa => 'Str', is => 'rw'); # the breeding program this clones originated from has 'breeding_program' => ( isa => 'Int', is => 'rw'); # has 'category' => ( isa => 'Str', is => 'rw' ); has 'contact_person_id' => ( isa => 'Int', is => 'rw') ; sub BUILD { my $self = shift; my $args = shift; $self->prop_table('stockprop'); $self->prop_namespace('Stock::Stockprop'); $self->prop_primary_key('stockprop_id'); $self->prop_type('stock_catalog_json'); $self->cv_name('stock_property'); $self->allowed_fields( [ qw | item_type category description material_source breeding_program availability contact_person_id images | ] ); $self->parent_table('stock'); $self->parent_primary_key('stock_id'); $self->load(); } sub get_catalog_items { my $self = shift; my $schema = $self->bcs_schema(); my $type = $self->prop_type(); my $type_id = $self->_prop_type_id(); my $key_ref = $self->allowed_fields(); my @fields = @$key_ref; my $catalog_rs = $schema->resultset("Stock::Stockprop")->search({type_id => $type_id }, { order_by => {-asc => 'stock_id'} }); my @catalog_list; while (my $r = $catalog_rs->next()){ my @each_row = (); my $catalog_stock_id = $r->stock_id(); push @each_row, $catalog_stock_id; my $item_detail_json = $r->value(); my $detail_hash = JSON::Any->jsonToObj($item_detail_json); foreach my $field (@fields){ push @each_row, $detail_hash->{$field}; } push @catalog_list, [@each_row]; } # print STDERR "CATALOG LIST =".Dumper(\@catalog_list)."\n"; return \@catalog_list; } sub get_item_details { my $self = shift; my $args = shift; my $schema = $self->bcs_schema(); my $item_id = $self->parent_id(); my $type = $self->prop_type(); my $type_id = $self->_prop_type_id(); my $key_ref = $self->allowed_fields(); my @fields = @$key_ref; my @item_details; my $item_details_rs = $schema->resultset("Stock::Stockprop")->find({stock_id => $item_id, type_id => $type_id}); my $details_json = $item_details_rs->value(); my $detail_hash = JSON::Any->jsonToObj($details_json); foreach my $field (@fields){ push @item_details, $detail_hash->{$field}; } # print STDERR "ITEM DETAILS =".Dumper(\@item_details)."\n"; return \@item_details; } 1;
solgenomics/sgn
lib/CXGN/Stock/Catalog.pm
Perl
mit
3,144
# vi:fdm=marker fdl=0 # $Id: Basic.pm,v 1.3 2006/01/25 22:23:29 jettero Exp $ package Statistics::Basic; use strict; no warnings; use Carp; our $VERSION = "0.42"; 1; __END__ # Below is stub documentation for your module. You better edit it! =head1 NAME Statistics::Basic A collection of very basic statistics formulae for vectors. =head1 SYNOPSIS # for use with one vector: Statistics::Basic::Mean; Statistics::Basic::Median; Statistics::Basic::Mode; Statistics::Basic::Variance; Statistics::Basic::StdDev; # for use with two vectors: Statistics::Basic::CoVariance; Statistics::Basic::Correlation; =head1 EXAMPLES my $mean = Statistics::Basic::Mean->new($array_ref)->query; print "$mean\n"; # hooray # That works, but I needed to calculate a LOT of means for a lot of # arrays of the same size. Furthermore, I needed them to operate FIFO # style. So, they do: my $mo = new Statistics::Basic::Mean([1..3]); print $mo->query, "\n"; # the avearge of 1, 2, 3 is 2 $mo->insert(4); # Keeps the vector the same size automatically print $mo->query, "\n"; # so, the average of 2, 3, 4 is 3 # You might need to keep a running average, so I included a growing # insert $mo->ginsert(5); # Expands the vector size by one and appends a 5 print $mo->query, "\n"; # so, the average is of 2, 3, 4, 5 is 7/2 # And last, you might need the mean of [3, 7] after all the above $mo->set_vector([2,3]); # *poof*, the vector is 2, 3! print $mo->query, "\n"; # and the average is now 5/2! Tadda! # These functions all work pretty much the same for ::StdDev and # ::Variance but they work slightly differently for CoVariance and # Correlation. # Not suprisingly, the correlation of [1..3] and [1..3] is 1.0 my $co = new Statistics::Basic::Correlation( [1..3], [1..3] ); print $co->query, "\n"; # Cut the correlation of [1..3, 7] and [1..3, 5] is less than 1 $co->ginsert( 7, 5 ); print $co->query, "\n"; =head1 BUGS Besides the lack of documentation? Well, I'm sure there's a bunch. I've tried to come up with a comprehensive suite of tests, but it's difficult to think of everything. If you spot any bugs, please tell me. =head1 ENV VARIABLES =head2 DEBUG Try setting $ENV{DEBUG}=1; or $ENV{DEBUG}=2; to see the internals. Also, from your bash prompt you can 'DEBUG=1 perl ./myprog.pl' to enable debugging dynamically. =head2 UNBIAS This module uses the sum(X - mean(X))/N definition of variance. If you wish to use the unbiased, sum(X-mean(X)/(N-1) definition, then set the $ENV{UNBIAS}=1; # And if you thought that was useful, then give a shout out to: # Robert McGehee <xxxxxxxx@wso.williams.edu>, for he requested it. =head1 AUTHOR Please contact me with ANY suggestions, no matter how pedantic. Jettero Heller <japh@voltar-confed.org> =head1 CONTRIBS http://search.cpan.org/~orien/ (some modules and tests) =head1 COPYRIGHT GPL! I included a gpl.txt for your reading enjoyment. Though, additionally, I will say that I'll be tickled if you were to include this package in any commercial endeavor. Also, any thoughts to the effect that using this module will somehow make your commercial package GPL should be washed away. I hereby release you from any such silly conditions. This package and any modifications you make to it must remain GPL. Any programs you (or your company) write shall remain yours (and under whatever copyright you choose) even if you use this package's intended and/or exported interfaces in them. =head1 SEE ALSO Most of the documentation is very thin. Sorry. The modules with their own documentation (no matter how thin) are listed below. Statistics::Basic::LeastSquareFit =cut
AstraZeneca-NGS/Seq2C
libraries/Statistics/Basic.pm
Perl
mit
3,812
# Show LEs in full format # # Sip Records: # - Request type / Response code # - CSeq number and original request type # - ts_ini # - Component class # - last_ts (time elapsed since last message) # - req_ts (time elapsed for a response since corresponding request) # # name resolution records: # - origin URI # - ts ini # - time elapsed for name resolution # - result (OK or ERROR) use strict; use warnings; use ordererlib; use statlib; use lm_env; use JSON::XS; sub name_to_string { my ($ref_namemsg) = @_; if (defined $ref_namemsg->{type}) { return "N:" . $ref_namemsg->{from} . "\t" . $ref_namemsg->{ts_ini} . "\t" . $ref_namemsg->{ts_diff} . "\t" . $ref_namemsg->{result} . "\t" . "\n" } } sub sip_to_string { my ($ref_sipmsg) = @_; if (defined $ref_sipmsg->{'via'}) { my $type; my $tab = ""; my $origin = &find_origin($ref_sipmsg, \%COMP_NET_ID); if (defined $ref_sipmsg->{'req'}) { $type = "Req-$ref_sipmsg->{'req'}"; } elsif (defined $ref_sipmsg->{'res'}) { $type = "Res-$ref_sipmsg->{'res'}"; $tab = " "; } my $last_ts = $ref_sipmsg->{last_ts}; my $req_ts = $ref_sipmsg->{req_ts}; return $tab . "$type C:$ref_sipmsg->{'cseq'} " . " $ref_sipmsg->{tsms} " . $ref_sipmsg->{component} . "\t" #. " <- " . $ref_sipmsg->{origin} . "\t" . (defined $last_ts ? $last_ts : "") . "\t" . (defined $req_ts ? $req_ts : "") . "\t" . "\n"; } } sub report{ my ($key, $r_le) = @_; print "$key\n"; print "\tFrom: " . $r_le->[0]->{from_uri} . "\n"; print "\tTo: " . $r_le->[0]->{to_uri} . "\n"; #&time_diff_com($r_le); foreach my $ev(@{$r_le}) { print sip_to_string($ev); print name_to_string($ev); } print "\n"; } ## MAIN - Loop ## while (<STDIN>) { my ($key, $type, $msg) = split(/\t\s*/); my $r_le = decode_json($msg); &report($key, $r_le); }
sandrovicente/bbk-pj
colmat/viewer.pl
Perl
mit
2,143
#!/usr/bin/perl use strict; use warnings; my $n = <STDIN>; chomp $n; while ($n>0){ my $s = <STDIN>; chomp $s; my $r = getEvenAndOdd($s); print $r->[0]." ".$r->[1]."\n"; $n--; } sub getEvenAndOdd{ my $s = shift; my @a = split "",$s; my $even,$odd=(); for (my $i=0; $i<scalar(@a); $i++){ if ($i%2==0){ $even.=$a[$i]; }else{ $odd.=$a[$i]; } } return [$even, $odd] }
MarsBighead/mustang
Perl/even-odds-in-string.pl
Perl
mit
438
# 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/Q713JNUf8G/asia. Olson data version 2016a # # Do not edit this file directly. # package DateTime::TimeZone::Asia::Kathmandu; $DateTime::TimeZone::Asia::Kathmandu::VERSION = '1.95'; use strict; use Class::Singleton 1.03; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Asia::Kathmandu::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, # utc_start 60557739524, # utc_end 1919-12-31 18:18:44 (Wed) DateTime::TimeZone::NEG_INFINITY, # local_start 60557760000, # local_end 1920-01-01 00:00:00 (Thu) 20476, 0, 'LMT', ], [ 60557739524, # utc_start 1919-12-31 18:18:44 (Wed) 62640585000, # utc_end 1985-12-31 18:30:00 (Tue) 60557759324, # local_start 1919-12-31 23:48:44 (Wed) 62640604800, # local_end 1986-01-01 00:00:00 (Wed) 19800, 0, 'IST', ], [ 62640585000, # utc_start 1985-12-31 18:30:00 (Tue) DateTime::TimeZone::INFINITY, # utc_end 62640605700, # local_start 1986-01-01 00:15:00 (Wed) DateTime::TimeZone::INFINITY, # local_end 20700, 0, 'NPT', ], ]; sub olson_version {'2016a'} sub has_dst_changes {0} sub _max_year {2026} sub _new_instance { return shift->_init( @_, spans => $spans ); } 1;
jkb78/extrajnm
local/lib/perl5/DateTime/TimeZone/Asia/Kathmandu.pm
Perl
mit
1,468
print ' <!-- /Content --> <div class="footer"> served by <a href="https://github.com/oliworx/nanohttp">nanoHttp</a> </div> </div><!-- /Page --> </body> </html> ';
oliworx/nanohttp
html/lib/footer.pl
Perl
mit
172
use bytes; #===================================================================================== # SetVariablesForKUC.perl # by Shinsuke Mori # Last change : 14 May 2008 #===================================================================================== # µ¡ ǽ : µþÅÔÂç³Ø¥³¡¼¥Ñ¥¹¤Î¤¿¤á¤ÎÄê¿ô¤ÎÄêµÁ # # Ãí °Õ : ¤Ê¤· #------------------------------------------------------------------------------------- # set variables #------------------------------------------------------------------------------------- $CTEMPL = "../../../corpus/KUC%02d.morphs"; # ¥³¡¼¥Ñ¥¹¤Î¥Õ¥¡¥¤¥ë̾¤ÎÀ¸À®¤Î¿÷·¿ @Part = qw(´¶Æ°»ì¡§¡ö¡§¡ö¡§¡ö ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¥¿·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¥¿·ÏÏ¢ÍѥƷÁ ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËܾò·ï·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¸ì´´ ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§Ê¸¸ì´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§Ê¸¸ìÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§¥¿·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§¸ì´´ ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊÆÃ¼ì¡§¥¿·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊÆÃ¼ì¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊÆÃ¼ì¡§´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¿¥ë·ÁÍÆ»ì¡§´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥¿¥ë·ÁÍÆ»ì¡§¸ì´´ ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎ󥿷Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎó´ðËÜ¿äÎÌ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎóÆÃ¼ìÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¸ì´´ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¹Îó´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¹Îó´ðËÜ¿äÎÌ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¸ì´´ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ìÆÃ¼ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ìÆÃ¼ì¡§¥ÀÎóÆÃ¼ìÏ¢ÂηÁ ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ìÆÃ¼ì¡§´ðËÜ·Á ·ÁÍÆ»ì¡§¡ö¡§¥Ê·ÁÍÆ»ìÆÃ¼ì¡§¸ì´´ »Ø¼¨»ì¡§Éû»ì·ÁÂֻؼ¨»ì¡§¡ö¡§¡ö »Ø¼¨»ì¡§Ì¾»ì·ÁÂֻؼ¨»ì¡§¡ö¡§¡ö »Ø¼¨»ì¡§Ï¢Âλì·ÁÂֻؼ¨»ì¡§¡ö¡§¡ö ½õ»ì¡§³Ê½õ»ì¡§¡ö¡§¡ö ½õ»ì¡§½ª½õ»ì¡§¡ö¡§¡ö ½õ»ì¡§Àܳ½õ»ì¡§¡ö¡§¡ö ½õ»ì¡§Éû½õ»ì¡§¡ö¡§¡ö ½õư»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§¥¤·ÁÍÆ»ì¥¤ÃÊ¡§´ðËÜÏ¢ÍÑ·Á ½õư»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ½õư»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ½õư»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎóÆÃ¼ìÏ¢ÂηÁ ½õư»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§¥Ê¥Î·ÁÍÆ»ì¡§¸ì´´ ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍÑ¥¸¥ã·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜ¿äÎÌ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¢¥ëÎ󥿷ÏÏ¢ÍѥƷÁ ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¢¥ëÎó´ðËÜ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¢¥ëÎó´ðËÜ¿äÎÌ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¹Îó´ðËÜ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¥Ç¥¹Îó´ðËÜ¿äÎÌ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§¥Ê·ÁÍÆ»ì¡§¸ì´´ ½õư»ì¡§¡ö¡§½õư»ì¤¯·¿¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤¯·¿¡§´ðËÜÏ¢ÍÑ·Á ½õư»ì¡§¡ö¡§½õư»ì¤¯·¿¡§Ê¸¸ìÏ¢ÂηÁ ½õư»ì¡§¡ö¡§½õư»ì¤½¤¦¤À·¿¡§¥Ç¥¹Îó´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤½¤¦¤À·¿¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤À¤í¤¦·¿¡§¥ÀÎó´ðËܾò·ï·Á ½õư»ì¡§¡ö¡§½õư»ì¤À¤í¤¦·¿¡§¥Ç¥¹Îó´ðËÜ¿äÎÌ·Á ½õư»ì¡§¡ö¡§½õư»ì¤À¤í¤¦·¿¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§¥¿·ÏÏ¢ÍѥƷÁ ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§²»ÊØ´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§´ðËܾò·ï·Á ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§´ðËÜÏ¢ÍÑ·Á ½õư»ì¡§¡ö¡§½õư»ì¤Ì·¿¡§Ê¸¸ìÏ¢ÂηÁ ½õư»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷Á ½õư»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎóÆÃ¼ìÏ¢ÂηÁ ½õư»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¹Îó´ðËÜ·Á ½õư»ì¡§¡ö¡§È½Äê»ì¡§´ðËÜ·Á ½õư»ì¡§¡ö¡§Ìµ³èÍÑ·¿¡§´ðËÜ·Á Àܳ»ì¡§¡ö¡§¡ö¡§¡ö ÀÜÆ¬¼­¡§¥Ê·ÁÍÆ»ìÀÜÆ¬¼­¡§¡ö¡§¡ö ÀÜÆ¬¼­¡§Ì¾»ìÀÜÆ¬¼­¡§¡ö¡§¡ö ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¥¿·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§²»Êؾò·ï·Á£² ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËÜ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËܾò·ï·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËÜ¿äÎÌ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥¤·ÁÍÆ»ì¥¢¥¦¥ªÃÊ¡§¸ì´´ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎ󥿷Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê¥Î·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§´ðËÜ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­½Ò¸ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¸ì´´ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­Ì¾»ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­Ì¾»ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­Ì¾»ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§¥ÀÎó´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§·ÁÍÆ»ìÀ­Ì¾»ìÀÜÈø¼­¡§¥Ê·ÁÍÆ»ì¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ì¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ì¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ì¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ì¡§Ì¤Á³·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ìÍè¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ìÍè¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥«ÊÑÆ°»ìÍè¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥µÊÑÆ°»ì¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥µÊÑÆ°»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥µÊÑÆ°»ì¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥µÊÑÆ°»ì¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§¥µÊÑÆ°»ì¡§Ì¤Á³·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹Ô¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹Ô¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§°Õ»Ö·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËܾò·ï·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§Ì¤Á³·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·ÏÏ¢ÍÑ¥¿¥ê·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¡§Ì¤Á³·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥é¹Ô¥¤·Á¡§Ì¿Îá·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥ï¹Ô¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥ï¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËܾò·ï·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§°Õ»Ö·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§Ì¤Á³·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­ÆÀ¤ë·¿¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§¥¿·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§¥¿·Ï¾ò·ï·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§¥¿·ÏÏ¢ÍÑ¥¿¥ê·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§°Õ»Ö·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§´ðËÜ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§´ðËܾò·ï·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§´ðËÜÏ¢ÍÑ·Á ÀÜÈø¼­¡§Æ°»ìÀ­ÀÜÈø¼­¡§Ê첻ư»ì¡§Ì¤Á³·Á ÀÜÈø¼­¡§Ì¾»ìÀ­½Ò¸ìÀÜÈø¼­¡§¡ö¡§¡ö ÀÜÈø¼­¡§Ì¾»ìÀ­ÆÃ¼ìÀÜÈø¼­¡§¡ö¡§¡ö ÀÜÈø¼­¡§Ì¾»ìÀ­Ì¾»ì½õ¿ô¼­¡§¡ö¡§¡ö ÀÜÈø¼­¡§Ì¾»ìÀ­Ì¾»ìÀÜÈø¼­¡§¡ö¡§¡ö ư»ì¡§¡ö¡§¥«ÊÑÆ°»ì¡§¥¿·Á ư»ì¡§¡ö¡§¥«ÊÑÆ°»ì¡§´ðËÜ·Á ư»ì¡§¡ö¡§¥«ÊÑÆ°»ìÍè¡§¥¿·Á ư»ì¡§¡ö¡§¥«ÊÑÆ°»ìÍè¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§¥«ÊÑÆ°»ìÍè¡§´ðËÜ·Á ư»ì¡§¡ö¡§¥«ÊÑÆ°»ìÍè¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§¥«ÊÑÆ°»ìÍ衧̤Á³·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§¥¿·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§¥¿·Ï¾ò·ï·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§¥¿·ÏÏ¢ÍÑ¥¿¥ê·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§°Õ»Ö·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§´ðËÜ·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§Ê¸¸ì´ðËÜ·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§Ê¸¸ì̤Á³·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§Ê¸¸ìÌ¿Îá·Á ư»ì¡§¡ö¡§¥µÊÑÆ°»ì¡§Ì¤Á³·Á ư»ì¡§¡ö¡§¥¶ÊÑÆ°»ì¡§¥¿·Á ư»ì¡§¡ö¡§¥¶ÊÑÆ°»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§¥¶ÊÑÆ°»ì¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§¥¿·Ï¾ò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§°Õ»Ö·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹Ô¡§Ì¿Îá·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§°Õ»Ö·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥«¹ÔÂ¥²»ÊØ·Á¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¬¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¬¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¬¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¬¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¬¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§¸ì´´ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥µ¹Ô¡§Ì¿Îá·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥¿¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ê¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ê¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ê¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ð¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ð¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ð¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ð¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Ð¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§°Õ»Ö·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥Þ¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·Ï¾ò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·ÏÏ¢ÍÑ¥¿¥ê·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§°Õ»Ö·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§¸ì´´ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥é¹Ô¥¤·Á¡§Ì¿Îá·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§¥¿·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§Ì¤Á³·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ô¡§Ì¿Îá·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ôʸ¸ì²»ÊØ·Á¡§´ðËÜ·Á ư»ì¡§¡ö¡§»Ò²»Æ°»ì¥ï¹Ôʸ¸ì²»ÊØ·Á¡§Ì¤Á³·Á ư»ì¡§¡ö¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§¥¿·Á ư»ì¡§¡ö¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§´ðËÜ·Á ư»ì¡§¡ö¡§Æ°»ìÀ­ÀÜÈø¼­¤Þ¤¹·¿¡§Ì¤Á³·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§¥¿·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§¥¿·ÏÏ¢ÍѥƷÁ ư»ì¡§¡ö¡§Ê첻ư»ì¡§°Õ»Ö·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§´ðËÜ·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§´ðËܾò·ï·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§´ðËÜÏ¢ÍÑ·Á ư»ì¡§¡ö¡§Ê첻ư»ì¡§¸ì´´ ư»ì¡§¡ö¡§Ê첻ư»ì¡§Ì¤Á³·Á ÆÃ¼ì¡§³ç¸Ì»Ï¡§¡ö¡§¡ö ÆÃ¼ì¡§³ç¸Ì½ª¡§¡ö¡§¡ö ÆÃ¼ì¡§µ­¹æ¡§¡ö¡§¡ö ÆÃ¼ì¡§¶çÅÀ¡§¡ö¡§¡ö ÆÃ¼ì¡§ÆÉÅÀ¡§¡ö¡§¡ö ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷Ͼò·ï·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷ÏÏ¢ÍÑ¥¸¥ã·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷ÏÏ¢ÍÑ¥¿¥ê·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎ󥿷ÏÏ¢ÍѥƷÁ ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎó´ðËÜ¿äÎÌ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎó´ðËÜÏ¢ÂηÁ ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥ÀÎóÆÃ¼ìÏ¢ÂηÁ ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¢¥ëÎ󥿷Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¢¥ëÎ󥿷ÏÏ¢ÍѥƷÁ ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¢¥ëÎó´ðËÜ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¢¥ëÎó´ðËÜ¿äÎÌ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¢¥ëÎó´ðËÜÏ¢ÍÑ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¹Î󥿷Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¹Îó´ðËÜ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§¥Ç¥¹Îó´ðËÜ¿äÎÌ·Á ȽÄê»ì¡§¡ö¡§È½Äê»ì¡§´ðËÜ·Á ÈÏáÆ³°¡§¡ö¡§¡ö¡§¡ö Éû»ì¡§¡ö¡§¡ö¡§¡ö ̾»ì¡§¥µÊÑ̾»ì¡§¡ö¡§¡ö ̾»ì¡§·Á¼°Ì¾»ì¡§¡ö¡§¡ö ̾»ì¡§¸Çͭ̾»ì¡§¡ö¡§¡ö ̾»ì¡§»þÁê̾»ì¡§¡ö¡§¡ö ̾»ì¡§¿ô»ì¡§¡ö¡§¡ö ̾»ì¡§ÉáÄÌ̾»ì¡§¡ö¡§¡ö ̾»ì¡§Éû»ìŪ̾»ì¡§¡ö¡§¡ö Ï¢Âλ졧¡ö¡§¡ö¡§¡ö); @PartCode = map(sprintf("%04d", $_), (0 .. $#Part)); %Part = map(($Part[$_] => $_), (0..$#Part)); @UTPart = map($UT . $_, @Part); @Tokens = ($UT, $BT, @Part); #===================================================================================== # END #=====================================================================================
tkd53/KKConv
lib/perl/dofile/SetVariablesForKUC.perl
Perl
mit
14,726
#!/usr/local/bin/perl ############################################################################## # This script annotates tab-delimited vcf summary files with sequence motif # and mutation category information, and counts the number of mutable motifs # in the reference genome ############################################################################## ############################################################################## #Initialize inputs, options, and defaults and define errors ############################################################################## use strict; use warnings; use POSIX; use File::Basename; use File::Path qw(make_path); use Benchmark; use FindBin; # use lib "$FindBin::Bin"; use FaSlice; use YAML::XS 'LoadFile'; use feature 'say'; my $relpath = $FindBin::Bin; my $configpath = dirname(dirname($relpath)); my $config = LoadFile("$configpath/_config.yaml"); # print "Script will run with the following parameters:\n"; # for (sort keys %{$config}) { # say "$_: $config->{$_}"; # } # my $adj = $config->{adj}; # my $adj=1; my $mac = $config->{mac}; my $binw = $config->{binw}; my $data = $config->{data}; # my $bin_scheme = $config->{bin_scheme}; # my $bin_scheme = "band"; my $parentdir = $config->{parentdir}; my $count_motifs = $config->{count_motifs}; my $expand_summ = $config->{expand_summ}; use lib "$FindBin::Bin/../lib"; use SmaugFunctions qw(forkExecWait getRef getMotif); my $chr=$ARGV[0]; my $adj=$ARGV[1]; ############################################################################## #Process inputs ############################################################################## my $subseq=2; if ($adj!=0) { $subseq = $adj*2+1; } my $bw=$binw/1000; ############################################################################## # Read in files and initialize outputs ############################################################################## # my $in_path = "/net/bipolar/jedidiah/testpipe/summaries"; # my $out_path = "$parentdir/output/${subseq}bp_${bw}k_${mac}_${data}2"; my $out_path = "$parentdir/motif_counts/$subseq-mers/$data"; make_path("$out_path"); ############################################################################## # Counts possible mutable sites per bin for 6 main categories # and for local sequence analysis if selected ############################################################################## if($count_motifs eq "TRUE"){ my $start_time=new Benchmark; print "Counting motifs...\n"; # print "seqlength: $length\n"; my $fname; if($data eq "full"){ $fname = "$parentdir/reference_data/human_g1k_v37/chr$chr.fasta.gz"; } elsif($data eq "mask"){ $fname = "$parentdir/reference_data/human_g1k_v37_mask/chr$chr.fasta.gz"; } # if ( -e "$fname$chr.fasta.gz" ) { $fname = "$fname$chr.fasta.gz"; } my $fa; my $startpos; my $endpos; my @motifs; my $header; my $bin_out; my @schemes = qw( fixed band ); foreach my $bin_scheme (@schemes){ if($bin_scheme eq "fixed"){ print "Getting fixed bins\n"; my $fixedfile = "$parentdir/reference_data/genome.${bw}kb.sorted.bed"; open my $fixedFH, '<', $fixedfile or die "$fixedfile: $!"; $fa = FaSlice->new(file=>$fname, oob=>'N', size=>$binw); $bin_out = "$out_path/chr$chr.$subseq-mer_motifs_${data}.txt"; $header = "CHR\tMotif\tnMotifs\n"; readWindows($fixedFH, $bin_out, $header, $fa); close $fixedFH; if($adj==1){ $bin_out = "$out_path/chr$chr.$subseq-mer_motifs_${bw}kb_${data}.txt"; open my $fixedFH, '<', $fixedfile or die "$fixedfile: $!"; $header = "CHR\tSTART\tEND\tBIN\tMotif\tnMotifs\n"; readWindows2($fixedFH, $bin_out, $header, $fa); } } elsif(($bin_scheme eq "band") && ($adj==1)) { print "getting bands\n"; my $bandfile = "$parentdir/reference_data/cytoBand.txt"; open my $bandFH, '<', $bandfile or die "$bandfile: $!"; $fa = FaSlice->new(file=>$fname, oob=>'N',size=>1_000_000); $bin_out = "$out_path/chr$chr.$subseq-mer_motifs_band_${data}.txt"; $header = "CHR\tSTART\tEND\tBAND\tgieStain\tBIN\tMotif\tnMotifs\n"; readWindows2($bandFH, $bin_out, $header, $fa); } } my $end_time=new Benchmark; my $difference = timediff($end_time, $start_time); print "Done. "; print "Runtime: ", timestr($difference), "\n"; } sub readWindows { my $windowFH = shift; my $bin_out = shift; my $header = shift; my $fa = shift; my $startpos; my $endpos; my @motifs; my $bandno = 1; open(my $outFH, '>', $bin_out) or die "can't write to $bin_out: $!\n"; print $outFH $header; my %full_count=(); # my $tmpseq = $fa->get_slice($chr, 1, 1000000); # @motifs = ($tmpseq =~ /(?=([ACGT]{$subseq}))/g); @motifs = glob "{A,C,G,T}"x $subseq; $full_count{$_}++ for @motifs; while(<$windowFH>){ chomp; my @line=split(/\t/, $_); my $chrind=$line[0]; if($chrind eq "chr$chr"){ $startpos = $line[1]+1; $endpos = $line[2]+$subseq-1; my $binseq = $fa->get_slice($chr, $startpos, $endpos); @motifs = ($binseq =~ /(?=([ACGT]{$subseq}))/g); # get overall load my %tri_count=(); $tri_count{$_}++ for @motifs; foreach my $motif (sort keys %tri_count) { my $altmotif = $motif; $altmotif =~ tr/ACGT/TGCA/; $altmotif = reverse $altmotif; # my $seqp = "$motif\($altmotif\)"; my $sum; if(exists($tri_count{$motif}) && exists($tri_count{$altmotif})){ $sum=$tri_count{$motif}+$tri_count{$altmotif}; } elsif(exists($tri_count{$motif}) && !exists($tri_count{$altmotif})) { $sum=$tri_count{$motif}; } elsif(!exists($tri_count{$motif}) && exists($tri_count{$altmotif})) { $sum=$tri_count{$altmotif}; } $full_count{$motif}=$full_count{$motif}+$sum; # print $outFH "$first\t$bin\t$seqp\t$sum\n"; } # writeCounts($_, $bandno, \@motifs, $outFH); $bandno = $bandno+1; } } foreach my $motif (sort keys %full_count){ my $altmotif = $motif; $altmotif =~ tr/ACGT/TGCA/; $altmotif = reverse $altmotif; my $seqp = "$motif\($altmotif\)"; my $sum = $full_count{$motif}; # print $outFH "$first\t$bin\t$seqp\t$sum\n"; print $outFH "$chr\t$seqp\t$sum\n"; } close $outFH; } sub readWindows2 { my $windowFH = shift; my $bin_out = shift; my $header = shift; my $fa = shift; my $startpos; my $endpos; my @motifs; my $bandno = 1; open(my $outFH, '>', $bin_out) or die "can't write to $bin_out: $!\n"; print $outFH $header; while(<$windowFH>){ chomp; my @line=split(/\t/, $_); my $chrind=$line[0]; if($chrind eq "chr$chr"){ $startpos = $line[1]+1; $endpos = $line[2]+$subseq-1; my $binseq = $fa->get_slice($chr, $startpos, $endpos); @motifs = ($binseq =~ /(?=([ACGT]{$subseq}))/g); my %tri_count=(); $tri_count{$_}++ for @motifs; foreach my $motif (sort keys %tri_count) { my $altmotif = $motif; $altmotif =~ tr/ACGT/TGCA/; $altmotif = reverse $altmotif; my $seqp = "$motif\($altmotif\)"; my $sum; if(exists($tri_count{$motif}) && exists($tri_count{$altmotif})){ $sum=$tri_count{$motif}+$tri_count{$altmotif}; } elsif(exists($tri_count{$motif}) && !exists($tri_count{$altmotif})) { $sum=$tri_count{$motif}; } elsif(!exists($tri_count{$motif}) && exists($tri_count{$altmotif})) { $sum=$tri_count{$altmotif}; } print $outFH "$_\t$bandno\t$seqp\t$sum\n"; } # writeCounts($_, $bandno, \@motifs, $outFH); $bandno = $bandno+1; } } close $outFH; } ############################################################################## # Read motif counts from hash table, sum counts symmetric motifs and write out # counting strategy modified from https://www.biostars.org/p/5143/ ############################################################################## sub writeCounts { my $first = $_[0]; my $bin = $_[1]; my @motifs = @{$_[2]}; my $outFH = $_[3]; my %tri_count=(); $tri_count{$_}++ for @motifs; foreach my $motif (sort keys %tri_count) { my $altmotif = $motif; $altmotif =~ tr/ACGT/TGCA/; $altmotif = reverse $altmotif; my $seqp = "$motif\($altmotif\)"; my $sum; if(exists($tri_count{$motif}) && exists($tri_count{$altmotif})){ $sum=$tri_count{$motif}+$tri_count{$altmotif}; } elsif(exists($tri_count{$motif}) && !exists($tri_count{$altmotif})) { $sum=$tri_count{$motif}; } elsif(!exists($tri_count{$motif}) && exists($tri_count{$altmotif})) { $sum=$tri_count{$altmotif}; } print $outFH "$first\t$bin\t$seqp\t$sum\n"; } }
carjed/smaug-genetics
data_mgmt/data_prep/count_motifs.pl
Perl
mit
8,699
package Paws::EC2::GroupIdentifier; use Moose; has GroupId => (is => 'ro', isa => 'Str', request_name => 'groupId', traits => ['NameInRequest']); has GroupName => (is => 'ro', isa => 'Str', request_name => 'groupName', traits => ['NameInRequest']); 1; ### main pod documentation begin ### =head1 NAME Paws::EC2::GroupIdentifier =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::EC2::GroupIdentifier object: $service_obj->Method(Att1 => { GroupId => $value, ..., GroupName => $value }); =head3 Results returned from an API call Use accessors for each attribute. If Att1 is expected to be an Paws::EC2::GroupIdentifier object: $result = $service_obj->Method(...); $result->Att1->GroupId =head1 DESCRIPTION This class has no description =head1 ATTRIBUTES =head2 GroupId => Str The ID of the security group. =head2 GroupName => Str The name of the security group. =head1 SEE ALSO This class forms part of L<Paws>, describing an object used in L<Paws::EC2> =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
ioanrogers/aws-sdk-perl
auto-lib/Paws/EC2/GroupIdentifier.pm
Perl
apache-2.0
1,462
# 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::V8::Common::UserListRuleInfo; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { ruleItemGroups => $args->{ruleItemGroups}, ruleType => $args->{ruleType}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V8/Common/UserListRuleInfo.pm
Perl
apache-2.0
1,078
# # Ensembl module for Bio::EnsEMBL::Compara::AlignSlice::Exon # # Original author: Javier Herrero <jherrero@ebi.ac.uk> # # Copyright EnsEMBL Team # # You may distribute this module under the same terms as perl itself # pod documentation - main docs before the code =head1 NAME Bio::EnsEMBL::Compara::AlignSlice::Exon - Description =head1 INHERITANCE This module inherits attributes and methods from Bio::EnsEMBL::Exon module =head1 SYNOPSIS use Bio::EnsEMBL::Compara::AlignSlice::Exon; my $exon = new Bio::EnsEMBL::Compara::AlignSlice::Exon( ); SET VALUES GET VALUES =head1 OBJECT ATTRIBUTES =over =item exon original Bio::EnsEMBL::Exon object =item slice Bio::EnsEMBL::Slice object on which this Bio::EnsEMBL::Compara::AlignSlice::Exon is defined =item cigar_line A string describing the mapping of this exon on the slice =item phase This exon results from the mapping of a real exon. It may suffer indels and duplications during the process which makes this mapped exon unreadable by a translation machinery. The phase is set to -1 by default. =item end_phase This exon results from the mapping of a real exon. It may suffer indels and duplications during the process which makes this mapped exon unreadable by a translation machinery. The end_phase is set to -1 by default. =back =head1 AUTHORS Javier Herrero (jherrero@ebi.ac.uk) =head1 COPYRIGHT Copyright (c) 2004. EnsEMBL Team You may distribute this module under the same terms as perl itself =head1 CONTACT This modules is part of the EnsEMBL project (http://www.ensembl.org) Questions can be posted to the ensembl-dev mailing list: ensembl-dev@ebi.ac.uk =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut # Let the code begin... package Bio::EnsEMBL::Compara::AlignSlice::Exon; use strict; use Bio::EnsEMBL::Exon; use Bio::EnsEMBL::Utils::Argument qw(rearrange); use Bio::EnsEMBL::Utils::Exception qw(throw warning info); our @ISA = qw(Bio::EnsEMBL::Exon); =head2 new (CONSTRUCTOR) Arg[1] : a reference to a hash where keys can be: -exon -adaptor -reference_slice Example : my $align_slice = new Bio::EnsEMBL::Compara::AlignSlice( -exon => $original_exon -reference_slice => $reference_slice, ); Description: Creates a new Bio::EnsEMBL::AlignSlice::Exon object Returntype : Bio::EnsEMBL::Compara::AlignSlice::Exon object Exceptions : return an object with no start, end nor strand if the exon cannot be mapped on the reference Slice. =cut sub new { my ($class, @args) = @_; my $self = {}; bless($self, $class); my ($exon, $align_slice, $from_mapper, $to_mapper, $original_rank) = rearrange([qw( EXON ALIGN_SLICE FROM_MAPPER TO_MAPPER ORIGINAL_RANK )], @args); $self->exon($exon) if (defined ($exon)); # $self->genomic_align($genomic_align) if (defined($genomic_align)); # $self->from_genomic_align_id($from_genomic_align_id) if (defined($from_genomic_align_id)); # $self->to_genomic_align_id($to_genomic_align_id) if (defined($to_genomic_align_id)); $self->slice($align_slice) if (defined($align_slice)); $self->original_rank($original_rank) if (defined($original_rank)); $self->phase(-1); $self->end_phase(-1); return $self->map_Exon_on_Slice($from_mapper, $to_mapper); } =head2 copy (CONSTRUCTOR) Arg[1] : none Example : my $new_align_slice = $old_align_slice->copy() Description: Creates a new Bio::EnsEMBL::AlignSlice::Exon object which is an exact copy of the calling object Returntype : Bio::EnsEMBL::Compara::AlignSlice::Exon object Exceptions : Caller : $obeject->methodname =cut sub copy { my ($self) = @_; my $copy; while (my ($key, $value) = each %$self) { $copy->{$key} = $value; } bless($copy, ref($self)); return $copy; } =head2 slice Arg[1] : (optional) Bio::EnsEMBL::Slice $reference_slice Example : $align_exon->slice($reference_slice); Example : $reference_slice = $align_exon->slice(); Description: Get/set the attribute slice. This method is overloaded in order to map original coordinates onto the reference Slice. Returntype : Bio::EnsEMBL::Slice object Exceptions : =cut sub slice { my ($self, $slice) = @_; if (defined($slice)) { $self->{'slice'} = $slice; } return $self->{'slice'}; } =head2 original_rank Arg[1] : (optional) integer $original_rank Example : $align_exon->original_rank(5); Example : $original_rank = $align_exon->original_rank(); Description: Get/set the attribute original_rank. The orignal_rank is the position of the orginal Exon in the original Transcript Returntype : integer Exceptions : =cut sub original_rank { my ($self, $original_rank) = @_; if (defined($original_rank)) { $self->{'original_rank'} = $original_rank; } return $self->{'original_rank'}; } =head2 map_Exon_on_Slice Arg[1] : Bio::EnsEMBL::Mapper $from_mapper Arg[2] : Bio::EnsEMBL::Mapper $to_mapper Example : $align_exon->map_Exon_on_Slice($from_mapper, $to_mapper); Description: This function takes the original exon and maps it on the slice using the mappers. Returntype : Bio::EnsEMBL::Compara::AlignSlice::Exon object Exceptions : returns undef if not enough information is provided Exceptions : returns undef if no piece of the original exon can be mapped. Caller : new =cut sub map_Exon_on_Slice { my ($self, $from_mapper, $to_mapper) = @_; my $original_exon = $self->exon; my $slice = $self->slice; if (!defined($slice) or !defined($original_exon) or !defined($from_mapper)) { return $self; } my @alignment_coords = $from_mapper->map_coordinates( "sequence", # $self->genomic_align->dbID, $original_exon->slice->start + $original_exon->start - 1, $original_exon->slice->start + $original_exon->end - 1, $original_exon->strand, "sequence" # $from_mapper->from ); my $aligned_start; my $aligned_end; my $aligned_strand = 0; my $aligned_sequence = ""; my $aligned_cigar = ""; my $global_alignment_coord_start; my $global_alignment_coord_end; my $last_alignment_coord_end; my $last_alignment_coord_start; foreach my $alignment_coord (@alignment_coords) { ## $alignment_coord refer to genomic_align_block: (1 to genomic_align_block->length) [+] if ($alignment_coord->isa("Bio::EnsEMBL::Mapper::Coordinate")) { if ($alignment_coord->strand == 1) { if ($last_alignment_coord_end) { # Consider gap between this piece and the previous as a deletion my $length = $alignment_coord->start - $last_alignment_coord_end - 1; $aligned_cigar .= $length if ($length>1); $aligned_cigar .= "D" if ($length); } $last_alignment_coord_end = $alignment_coord->end; $global_alignment_coord_start = $alignment_coord->start if (!$global_alignment_coord_start); $global_alignment_coord_end = $alignment_coord->end; } else { if ($last_alignment_coord_start) { # Consider gap between this piece and the previous as a deletion my $length = $last_alignment_coord_start - $alignment_coord->end - 1; $aligned_cigar .= $length if ($length>1); $aligned_cigar .= "D" if ($length); } $last_alignment_coord_start = $alignment_coord->start; $global_alignment_coord_end = $alignment_coord->end if (!$global_alignment_coord_end); $global_alignment_coord_start = $alignment_coord->start; } } else { # This piece is outside of the alignment -> consider as an insertion my $length = $alignment_coord->length; $aligned_cigar .= $length if ($length>1); $aligned_cigar .= "I" if ($length); next; } if (!defined($to_mapper)) { ## Mapping on the alignment (expanded mode) if ($alignment_coord->strand == 1) { $aligned_strand = 1; $aligned_start = $alignment_coord->start if (!$aligned_start); $aligned_end = $alignment_coord->end; } else { $aligned_strand = -1; $aligned_start = $alignment_coord->start; $aligned_end = $alignment_coord->end if (!$aligned_end); } my $num = $alignment_coord->end - $alignment_coord->start + 1; $aligned_cigar .= $num if ($num > 1); $aligned_cigar .= "M" if ($num); } else { ## Mapping on the reference_Slice (collapsed mode) my @mapped_coords = $to_mapper->map_coordinates( "alignment", # $self->genomic_align->genomic_align_block->dbID, $alignment_coord->start, $alignment_coord->end, $alignment_coord->strand, "alignment" # $to_mapper->to ); foreach my $mapped_coord (@mapped_coords) { ## $mapped_coord refer to reference_slice if ($mapped_coord->isa("Bio::EnsEMBL::Mapper::Coordinate")) { if ($alignment_coord->strand == 1) { $aligned_strand = 1; $aligned_start = $mapped_coord->start if (!$aligned_start); $aligned_end = $mapped_coord->end; } else { $aligned_strand = -1; $aligned_start = $mapped_coord->start; $aligned_end = $mapped_coord->end if (!$aligned_end); } my $num = $mapped_coord->end - $mapped_coord->start + 1; $aligned_cigar .= $num if ($num > 1); $aligned_cigar .= "M" if ($num); } else { my $num = $mapped_coord->end - $mapped_coord->start + 1; $aligned_cigar .= $num if ($num > 1); $aligned_cigar .= "I" if ($num); } } } } if ($aligned_strand == 0) { ## the whole sequence maps on a gap $self->{start} = undef; $self->{end} = undef; $self->{strand} = undef; return $self; } ## Set coordinates on "slice" coordinates $self->start($aligned_start - $slice->start + 1); $self->end($aligned_end - $slice->start + 1); $self->strand($aligned_strand); $self->cigar_line($aligned_cigar); if ($self->start > $slice->length or $self->end < 1) { $self->{start} = undef; $self->{end} = undef; $self->{strand} = undef; return $self; } return $self; } =head2 exon Arg[1] : (optional) Bio::EnsEMBL::Exon $original_exon Example : $align_exon->exon($original_exon); Example : $start = $align_exon->start(); Description: Get/set the attribute start. This method is overloaded in order to return the starting postion on the AlignSlice instead of the original one. Original starting position may be retrieved using the SUPER::start() method or the orginal_start() method Returntype : Bio::EnsEMBL::Exon object Exceptions : =cut sub exon { my ($self, $exon) = @_; if (defined($exon)) { $self->{'exon'} = $exon; $self->stable_id($exon->stable_id) if (defined($exon->stable_id)); } return $self->{'exon'}; } =head2 cigar_line Arg[1] : (optional) string $cigar_line Example : $align_exon->cigar_line($cigar_line); Example : $cigar_line = $align_exon->cigar_line(); Description: Get/set the attribute cigar_line. Returntype : string Exceptions : none Caller : object->methodname =cut sub cigar_line { my ($self, $cigar_line) = @_; if (defined($cigar_line)) { $self->{'cigar_line'} = $cigar_line; } return $self->{'cigar_line'}; } sub get_aligned_start { my ($self) = @_; my $cigar_line = $self->cigar_line; if (defined($cigar_line)) { my @cig = ( $cigar_line =~ /(\d*[GMDI])/g ); my $cigType = substr( $cig[0], -1, 1 ); my $cigCount = substr( $cig[0], 0 ,-1 ); $cigCount = 1 unless ($cigCount =~ /^\d+$/); next if ($cigCount == 0); if ($cigType eq "I") { return (1 + $cigCount); } else { return 1; } } return undef; } sub get_aligned_end { my ($self) = @_; my $cigar_line = $self->cigar_line; if (defined($cigar_line)) { my @cig = ( $cigar_line =~ /(\d*[GMDI])/g ); my $cigType = substr( $cig[-1], -1, 1 ); my $cigCount = substr( $cig[-1], 0 ,-1 ); $cigCount = 1 unless ($cigCount =~ /^\d+$/); next if ($cigCount == 0); if ($cigType eq "I") { return ($self->exon->end - $self->exon->start + 1 - $cigCount); } else { return ($self->exon->end - $self->exon->start + 1); } } return undef; } =head2 seq Arg [1] : none Example : my $seq_str = $exon->seq->seq; Description: Retrieves the dna sequence of this Exon. Returned in a Bio::Seq object. Note that the sequence may include UTRs (or even be entirely UTR). Returntype : Bio::Seq or undef Exceptions : warning if argument passed, warning if exon does not have attatched slice warning if exon strand is not defined (or 0) Caller : general =cut sub seq { my ($self, $seq) = @_; if (defined($seq)) { $self->{'_seq_cache'} = $seq->seq(); } ## Use _template_seq if defined. It is a concatenation of several original ## exon sequences and is produced during the merging of align_exons. if(!defined($self->{'_seq_cache'})) { my $seq = &_get_aligned_sequence_from_original_sequence_and_cigar_line( ($self->{'_template_seq'} or $self->exon->seq->seq), $self->cigar_line, "ref" ); $self->{'_seq_cache'} = $seq; } return Bio::Seq->new( -seq => $self->{'_seq_cache'}, -id => $self->stable_id, -moltype => 'dna', -alphabet => 'dna', ); } =head2 append_Exon Arg [1] : Example : Description: Returntype : Exceptions : Caller : =cut sub append_Exon { my ($self, $exon, $gap_length) = @_; $self->seq(new Bio::Seq(-seq => $self->seq->seq.("-"x$gap_length).$exon->seq->seq)); ## As it is possible to merge two partially repeated parts of an Exon, ## the merging is done by concatenating both cigar_lines with the right ## number of gaps in the middle. The underlaying sequence must be lengthen ## accordingly. This is stored in the _template_seq private attribute if (defined($self->{'_template_seq'})) { $self->{'_template_seq'} .= $self->exon->seq->seq } else { $self->{'_template_seq'} = $self->exon->seq->seq x 2; } if ($gap_length) { $gap_length = "" if ($gap_length == 1); $self->cigar_line( $self->cigar_line. $gap_length."D". $exon->cigar_line); } else { $self->cigar_line( $self->cigar_line. $exon->cigar_line); } return $self; } =head2 prepend_Exon Arg [1] : Example : Description: Returntype : Exceptions : Caller : =cut sub prepend_Exon { my ($self, $exon, $gap_length) = @_; $self->seq(new Bio::Seq(-seq => $exon->seq->seq.("-"x$gap_length).$self->seq->seq)); ## As it is possible to merge two partially repeated parts of an Exon, ## the merging is done by concatenating both cigar_lines with the right ## number of gaps in the middle. The underlaying sequence must be lengthen ## accordingly. This is stored in the _template_seq private attribute if (defined($self->{'_template_seq'})) { $self->{'_template_seq'} .= $self->exon->seq->seq } else { $self->{'_template_seq'} = $self->exon->seq->seq x 2; } if ($gap_length) { $gap_length = "" if ($gap_length == 1); $self->cigar_line( $exon->cigar_line. $gap_length."D". $self->cigar_line); } else { $self->cigar_line( $exon->cigar_line. $self->cigar_line); } return $self; } =head2 _get_aligned_sequence_from_original_sequence_and_cigar_line Arg [1] : string $original_sequence Arg [1] : string $cigar_line Example : $aligned_sequence = _get_aligned_sequence_from_original_sequence_and_cigar_line( "CGTAACTGATGTTA", "3MD8M2D3M") Description: get gapped sequence from original one and cigar line Returntype : string $aligned_sequence Exceptions : thrown if cigar_line does not match sequence length Caller : methodname =cut sub _get_aligned_sequence_from_original_sequence_and_cigar_line { my ($original_sequence, $cigar_line, $mode) = @_; my $aligned_sequence = ""; $mode ||= ""; return undef if (!$original_sequence or !$cigar_line); my $seq_pos = 0; my @cig = ( $cigar_line =~ /(\d*[GMDI])/g ); for my $cigElem ( @cig ) { my $cigType = substr( $cigElem, -1, 1 ); my $cigCount = substr( $cigElem, 0 ,-1 ); $cigCount = 1 unless ($cigCount =~ /^\d+$/); if( $cigType eq "M" ) { $aligned_sequence .= substr($original_sequence, $seq_pos, $cigCount); $seq_pos += $cigCount; } elsif( $cigType eq "G" || $cigType eq "D") { $aligned_sequence .= "-" x $cigCount; } elsif( $cigType eq "I") { $aligned_sequence .= "-" x $cigCount if ($mode ne "ref"); $seq_pos += $cigCount; } } throw("Cigar line ($seq_pos) does not match sequence lenght (".length($original_sequence).")") if ($seq_pos != length($original_sequence)); return $aligned_sequence; } 1;
adamsardar/perl-libs-custom
EnsemblAPI/ensembl-compara/modules/Bio/EnsEMBL/Compara/AlignSlice/Exon.pm
Perl
apache-2.0
17,429
# # Copyright 2021 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package apps::protocols::snmp::mode::responsetime; use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); sub prefix_output { my ($self, %options) = @_; return 'SNMP Agent '; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_output' } ]; $self->{maps_counters}->{global} = [ { label => 'rta', nlabel => 'roundtrip.time.average.milliseconds', set => { key_values => [ { name => 'rta' } ], output_template => 'rta %.3fms', perfdatas => [ { label => 'rta', template => '%.3f', min => 0, unit => 'ms' } ] } }, { label => 'rtmax', nlabel => 'roundtrip.time.maximum.milliseconds', display_ok => 0, set => { key_values => [ { name => 'rtmax' } ], perfdatas => [ { label => 'rtmax', template => '%.3f', min => 0, unit => 'ms' } ] } }, { label => 'rtmin', nlabel => 'roundtrip.time.minimum.milliseconds', display_ok => 0, set => { key_values => [ { name => 'rtmin' } ], perfdatas => [ { label => 'rtmin', template => '%.3f', min => 0, unit => 'ms' } ] } }, { label => 'pl', nlabel => 'packets.loss.percentage', set => { key_values => [ { name => 'pl' } ], output_template => 'lost %s%%', perfdatas => [ { label => 'pl', template => '%s', min => 0, max => 100, unit => '%' } ] } } ]; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { 'timeout:s' => { name => 'timeout' }, 'packets:s' => { name => 'packets' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); $self->{option_timeout} = 5; $self->{option_packets} = 5; if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /(\d+)/) { $self->{option_timeout} = $1; } if (defined($self->{option_results}->{packets}) && $self->{option_results}->{packets} =~ /(\d+)/) { $self->{option_packets} = $1; } $options{snmp}->set_snmp_connect_params(Timeout => $self->{option_timeout} * (10**6)); $options{snmp}->set_snmp_connect_params(Retries => 0); $options{snmp}->set_snmp_params(subsetleef => 1); } sub manage_selection { my ($self, %options) = @_; my $sysDescr = '.1.3.6.1.2.1.1.1.0'; my $total_time_elapsed = 0; my $max_time_elapsed = 0; my $min_time_elapsed = 0; my $total_packet_lost = 0; for (my $i = 0; $i < $self->{option_packets}; $i++) { my $timing0 = [gettimeofday]; my $return = $options{snmp}->get_leef(oids => [$sysDescr], nothing_quit => 0, dont_quit => 1); my $timeelapsed = tv_interval($timing0, [gettimeofday]); if (!defined($return)) { $total_packet_lost++; } else { $total_time_elapsed += $timeelapsed; $max_time_elapsed = $timeelapsed if ($timeelapsed > $max_time_elapsed); $min_time_elapsed = $timeelapsed if ($timeelapsed < $min_time_elapsed || $min_time_elapsed == 0); } } $self->{global} = { rta => ($self->{option_packets} > $total_packet_lost) ? $total_time_elapsed * 1000 / ($self->{option_packets} - $total_packet_lost) : 0, rtmax => $max_time_elapsed * 1000, rtmin => $min_time_elapsed * 1000, pl => int($total_packet_lost * 100 / $self->{option_packets}) }; } 1; __END__ =head1 MODE Check SNMP agent response time. =over 8 =item B<--filter-counters> Only display some counters (regexp can be used). Example : --filter-counters='rta' =item B<--timeout> Set timeout in seconds (Default: 5). =item B<--packets> Number of packets to send (Default: 5). =item B<--warning-rta> Response time threshold warning in milliseconds =item B<--critical-rta> Response time threshold critical in milliseconds =item B<--warning-pl> Packets lost threshold warning in % =item B<--critical-pl> Packets lost threshold critical in % =back =cut
Tpo76/centreon-plugins
apps/protocols/snmp/mode/responsetime.pm
Perl
apache-2.0
5,279
# # Copyright 2022 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package storage::ibm::storwize::ssh::mode::components::portsas; use strict; use warnings; sub load { my ($self) = @_; $self->{ssh_commands} .= 'echo "==========lsportsas=========="; lsportsas -delim : ; echo "===============";'; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking portsas"); $self->{components}->{portsas} = {name => 'portsas', total => 0, skip => 0}; return if ($self->check_filter(section => 'portsas')); return if ($self->{results} !~ /==========lsportsas==.*?\n(.*?)==============/msi); my $content = $1; my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { next if ($self->check_filter(section => 'portsas', instance => $_->{id})); $self->{components}->{portsas}->{total}++; my $name = $_->{node_name} . "." . $_->{WWPN}; $self->{output}->output_add( long_msg => sprintf( "port sas '%s' status is '%s' [instance: %s].", $name, $_->{status}, $_->{id} ) ); my $exit = $self->get_severity(section => 'portsas', value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, short_msg => sprintf( "Port sas '%s' status is '%s'", $name, $_->{status} ) ); } } } 1;
centreon/centreon-plugins
storage/ibm/storwize/ssh/mode/components/portsas.pm
Perl
apache-2.0
2,356
=head1 LICENSE Copyright [1999-2015] 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 # POD documentation - main docs before the code =head1 NAME Bio::EnsEMBL::Compara::Production::EPOanchors::LoadDnaFragRegion =head1 SYNOPSIS $self->fetch_input(); $self->run(); $self->write_output(); writes to database =head1 DESCRIPTION Module to set up the production database for generating multiple alignments usng Ortheus. =head1 AUTHOR - compara This modules is part of the Ensembl project http://www.ensembl.org Email http://lists.ensembl.org/mailman/listinfo/dev =head1 CONTACT This modules is part of the EnsEMBL project (http://www.ensembl.org) Questions can be posted to the ensembl-dev mailing list: http://lists.ensembl.org/mailman/listinfo/dev =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut package Bio::EnsEMBL::Compara::Production::EPOanchors::LoadDnaFragRegion; use strict; use Data::Dumper; use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::Utils::Exception qw(warning deprecate throw); use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable'); sub fetch_input { my ($self) = @_; my (%DF,%SEG,%Zero_st,%StartEnd,@Zero_st,$synteny_region_id); open(IN, $self->param('enredo_output_file')) or die; { local $/ = "block"; while(<IN>){ next if /#/; $synteny_region_id++; foreach my $seg(split("\n", $_)){ next unless $seg=~/:/; my($species,$chromosome,$start,$end,$strand) = $seg=~/^([\w:]+):([^\:]+):(\d+):(\d+) \[(.*)\]/; # %StartEnd : this is a hack, as not all adjacent enredo blocks have a 2 bp overlap (~20% dont), # so we cant just say "($start,$end) = ($start+1,$end-1);" my$loc_string = join(":", $species,$chromosome,$start,$end,$strand); push( @{ $StartEnd{$species}{$chromosome} }, [ $start, $end, $strand, $synteny_region_id, $loc_string ] ); $DF{$species}++; $Zero_st{$synteny_region_id}++ unless $strand; # catch the synteny_region_id if there is a least one zero strand $SEG{$synteny_region_id}{$loc_string}++; } } } # fix the start and ends of genomic coordinates with overlaps foreach my $species(sort keys %StartEnd){ foreach my $chromosome(sort keys %{ $StartEnd{$species} }){ our $arr; *arr = \$StartEnd{$species}{$chromosome}; @$arr = sort {$a->[0] <=> $b->[0]} @$arr; for(my$i=1;$i<@$arr;$i++){ if($arr->[$i]->[0] == $arr->[$i-1]->[1] - 1){ $arr->[$i-1]->[1] -= 1; $arr->[$i]->[0] += 1; } } } } # replace the original coordinates with a 2 bp overlap with the non-overlapping coordinates foreach my $species(sort keys %StartEnd){ foreach my $chromosome(sort keys %{ $StartEnd{$species} }){ our $arr; *arr = \$StartEnd{$species}{$chromosome}; for(my$i=0;$i<@$arr;$i++){ my $new_coords = join(":", $species, $chromosome, @{ $arr->[$i] }[0..2]); unless($new_coords eq $arr->[$i]->[4]){ delete( $SEG{$arr->[$i]->[3] }{ $arr->[$i]->[4] } ); # remove the original overlapping segment $SEG{ $arr->[$i]->[3] }{ $new_coords }--; # replace it with the the non-ovelapping segment } } } } $self->param('genome_dbs', [ keys %DF ]); $self->param('synteny_regions', \%SEG); $self->param('zero_st_sy_ids', \%Zero_st); # hack to filter out zero strand synteny_region_ids foreach my $synteny_region_id(keys %Zero_st){ push(@Zero_st, { zero_st_synteny_region_id => $synteny_region_id }); } $self->param('dfrs_with_zero_st', \@Zero_st); } sub write_output { my ($self) = @_; # sort the species names from the enredo output files my $ancestal_db = $self->param('ancestral_db'); my $genome_dbs_names_from_file = join(":", sort {$a cmp $b} @{ $self->param('genome_dbs') }, $ancestal_db->{'-species'}) . ":"; # get the genome_db names from the genome_db table in the production db my $genome_db_adaptor = $self->compara_dba()->get_adaptor("GenomeDB"); my $genome_db_names_from_db; foreach my $genome_db(sort {$a->name cmp $b->name} @{ $genome_db_adaptor->fetch_all }){ $genome_db_names_from_db .= $genome_db->name.":"; } # check the species names from the file against those from the db die "species from enredo file ($genome_dbs_names_from_file) are not the same as the set of species in the database ($genome_db_names_from_db)", $! unless ( "$genome_dbs_names_from_file" eq "$genome_db_names_from_db" ); my (%DNAFRAGS, @synteny_region_ids); # populate dnafrag_region table my $sth1 = $self->dbc->prepare("INSERT INTO dnafrag_region VALUES (?,?,?,?,?)"); my $sth2 = $self->dbc->prepare("INSERT INTO synteny_region VALUES (?,?)"); foreach my $synteny_region_id(sort {$a <=> $b} keys %{ $self->param('synteny_regions') }){ $sth2->execute($synteny_region_id,$self->param('epo_mlss_id')); foreach my $dnafrag_region(keys %{ $self->param('synteny_regions')->{$synteny_region_id} }){ my($species_name,$dnafrag_name,$start,$end,$strand)=split(":", $dnafrag_region); # we have the dnafrag_name from the file but we need the dnafrag_id from the db # get only the dnafrags used by enredo unless (exists($DNAFRAGS{$species_name}{$dnafrag_name})) { my $dnaf_sth = $self->dbc->prepare("SELECT df.dnafrag_id FROM dnafrag df INNER JOIN genome_db " . "gdb ON gdb.genome_db_id = df.genome_db_id WHERE gdb.name = ? AND df.name = ?"); $dnaf_sth->execute($species_name,$dnafrag_name); while(my $dnafrag_info = $dnaf_sth->fetchrow_arrayref()) { $DNAFRAGS{ $species_name }{ $dnafrag_name } = $dnafrag_info->[0]; } } $sth1->execute($synteny_region_id,$DNAFRAGS{$species_name}{$dnafrag_name},$start,$end,$strand); } unless(exists($self->param('zero_st_sy_ids')->{$synteny_region_id})){ # dont create ortheus jobs for the synteny_regions with one or more zero strands push(@synteny_region_ids, {synteny_region_id => $synteny_region_id}); } } # add the MTs to the dnafrag_region table if($self->param('addMT')) { my $max_synteny_region_id = $synteny_region_ids[-1]->{'synteny_region_id'} + 1; $sth2->execute($max_synteny_region_id, $self->param('epo_mlss_id')); my $sth_mt = $self->dbc->prepare("SELECT dnafrag_id, length FROM dnafrag WHERE name =\"MT\""); $sth_mt->execute; foreach my $dnafrag_region ( @{ $sth_mt->fetchall_arrayref } ) { $sth1->execute($max_synteny_region_id, $dnafrag_region->[0], 1, $dnafrag_region->[1], 1); } push(@synteny_region_ids, {synteny_region_id => $max_synteny_region_id}); } $self->dataflow_output_id( $self->param('dfrs_with_zero_st'), 2 ); # zero strand, so flow to a job factory to set up bl2seq jobs $self->dataflow_output_id( \@synteny_region_ids, 3 ); # no zero strand, so flow to a job factory to set up ortheus } 1;
ckongEbi/ensembl-compara
modules/Bio/EnsEMBL/Compara/Production/EPOanchors/LoadDnaFragRegion.pm
Perl
apache-2.0
7,325
#!/usr/bin/perl # # Migrate configuration from OpenSSL to NSS use Cwd; use Getopt::Std; BEGIN { $NSSDir = cwd(); $SSLCACertificatePath = ""; $SSLCACertificateFile = ""; $SSLCertificateFile = ""; $SSLCARevocationPath = ""; $SSLCARevocationFile = ""; $SSLCertificateKeyFile = ""; $passphrase = 0; } %skip = ( "SSLRandomSeed" => "", "SSLSessionCache" => "", "SSLMutex" => "", "SSLCertificateChainFile" => "", "SSLVerifyDepth" => "" , "SSLCryptoDevice" => "" , "LoadModule" => "" , ); %insert = ( "NSSSessionCacheTimeout", "NSSSessionCacheSize 10000\nNSSSession3CacheTimeout 86400\n",); getopts('ch'); if ($opt_h) { print "Usage: migrate.pl -c\n"; print "\t-c convert the certificates\n"; exit(); } open (NSS, "> nss.conf") or die "Unable to open nss.conf: $!.\n"; open (SSL, "< ssl.conf") or die "Unable to open ssl.conf: $!.\n"; while (<SSL>) { my $comment = 0; # skip blank lines and comments if (/^#/ || /^\s*$/) { print NSS $_; next; } m/(\w+)\s+(.+)/; $stmt = $1; $value = $2; # Handle the special cases if ($stmt eq "SSLVerifyClient" && $value eq "optional_no_ca") { print NSS "# Replaced optional_no_ca with optional\n"; print NSS "SSLVerifyClient optional\n"; next; } if ($stmt eq "SSLCipherSuite") { print NSS "NSSCipherSuite ", get_ciphers($val), "\n"; print NSS "NSSProtocol SSLv3,TLSv1\n"; $comment = 1; } elsif ($stmt eq "SSLCACertificatePath") { $SSLCACertificatePath = $value; $comment = 1; } elsif ($stmt eq "SSLCACertificateFile") { $SSLCACertificateFile = $value; $comment = 1; } elsif ($stmt eq "SSLCertificateFile") { print NSS "NSSCertificateDatabase $NSSDir\n"; print NSS "NSSNickName Server-Cert\n"; $SSLCertificateFile = $value; $comment = 1; } elsif ($stmt eq "SSLCertificateKeyFile") { $SSLCertificateKeyFile = $value; $comment = 1; } elsif ($stmt eq "SSLCARevocationPath") { $SSLCARevocationPath = $value; $comment = 1; } elsif ($stmt eq "SSLCARevocationFile") { $SSLCARevocationFile = $value; $comment = 1; } elsif ($stmt eq "SSLPassPhraseDialog") { print NSS "NSSPassPhraseHelper /usr/local/bin/nss_pcache\n"; $passphrase = 1; $comment = 1; } if (exists($skip{$stmt})) { print NSS "# Skipping, not applicable in mod_nss\n"; print NSS "##$_"; next; } # Fix up any remaining directive names s/^SSL/NSS/; if (exists($insert{$stmt})) { print NSS "$_"; print NSS $insert{$stmt}; next; } # Fall-through to print whatever is left if ($comment) { print NSS "##$_"; $comment = 0; } else { print NSS $_; } } if ($passphrase == 0) { # NOTE: Located at '/usr/sbin/nss_pcache' prior to 'mod_nss-1.0.9'. print NSS "NSSPassPhraseHelper /usr/libexec/nss_pcache\n"; } close(NSS); close(SSL); # # Create NSS certificate database and import any existing certificates # if ($opt_c) { print "Creating NSS certificate database.\n"; run_command("certutil -N -d $NSSDir"); # Convert the certificate into pkcs12 format if ($SSLCertificateFile ne "" && $SSLCertificateKeyFile ne "") { my $subject = get_cert_subject($SSLCertificateFile); print "Importing certificate $subject as \"Server-Cert\".\n"; run_command("openssl pkcs12 -export -in $SSLCertificateFile -inkey $SSLCertificateKeyFile -out server.p12 -name \"Server-Cert\" -passout pass:foo"); run_command("pk12util -i server.p12 -d $NSSDir -W foo"); } if ($SSLCACertificateFile ne "") { my $subject = get_cert_subject($SSLCACertificateFile); if ($subject ne "") { print "Importing CA certificate $subject\n"; run_command("certutil -A -n \"$subject\" -t \"CT,,\" -d $NSSDir -a -i $SSLCACertificateFile"); } } if ($SSLCACertificatePath ne "") { opendir(DIR, $SSLCACertificatePath) or die "can't opendir $SSLCACertificatePath: $!"; while (defined($file = readdir(DIR))) { next if -d $file; # we can operate directly on the hash files so don't have to worry # about any SKIPME's. if ($file =~ /hash.*/) { my $subject = get_cert_subject("$SSLCACertificatePath/$file"); if ($subject ne "") { print "Importing CA certificate $subject\n"; run_command("certutil -A -n \"$subject\" -t \"CT,,\" -d $NSSDir -a -i $SSLCACertificatePath/$file"); } } } closedir(DIR); } if ($SSLCARevocationFile ne "") { print "Importing CRL file $CARevocationFile\n"; # Convert to DER format run_command("openssl crl -in $SSLCARevocationFile -out /tmp/crl.tmp -inform PEM -outform DER"); run_command("crlutil -I -t 1 -d $NSSDir -i /tmp/crl.tmp"); unlink("/tmp/crl.tmp"); } if ($SSLCARevocationPath ne "") { opendir(DIR, $SSLCARevocationPath) or die "can't opendir $SSLCARevocationPath: $!"; while (defined($file = readdir(DIR))) { next if -d $file; # we can operate directly on the hash files so don't have to worry # about any SKIPME's. if ($file =~ /hash.*/) { my $subject = get_cert_subject("$SSLCARevocationPath/$file"); if ($subject ne "") { print "Importing CRL file $file\n"; # Convert to DER format run_command("openssl crl -in $SSLCARevocationPath/$file -out /tmp/crl.tmp -inform PEM -outform DER"); run_command("crlutil -I -t 1 -d $NSSDir -i /tmp/crl.tmp"); unlink("/tmp/crl.tmp"); } } } closedir(DIR); } } print "Conversion complete.\n"; print "You will need to:\n"; print " - rename/remove ssl.conf or Apache will not start.\n"; print " - verify the location of nss_pcache. It is set as /usr/local/bin/nss_pcache\n"; exit(0); # Migrate configuration from OpenSSL to NSS sub get_ciphers { my $str = shift; %cipher_list = ( "rc4" => ":ALL:SSLv2:RSA:MD5:MEDIUM:RC4:", "rc4export" => ":ALL:SSLv2:RSA:EXP:EXPORT40:MD5:RC4:", "rc2" => ":ALL:SSLv2:RSA:MD5:MEDIUM:RC2:", "rc2export" => ":ALL:SSLv2:RSA:EXP:EXPORT40:MD5:RC2:", "des" => ":ALL:SSLv2:RSA:EXP:EXPORT56:MD5:DES:LOW:", "desede3" => ":ALL:SSLv2:RSA:MD5:3DES:HIGH:", "rsa_rc4_128_md5" => ":ALL:SSLv3:TLSv1:RSA:MD5:RC4:MEDIUM:", "rsa_rc4_128_sha" => ":ALL:SSLv3:TLSv1:RSA:SHA:RC4:MEDIUM:", "rsa_3des_sha" => ":ALL:SSLv3:TLSv1:RSA:SHA:3DES:HIGH:", "rsa_des_sha" => ":ALL:SSLv3:TLSv1:RSA:SHA:DES:LOW:", "rsa_rc4_40_md5" => ":ALL:SSLv3:TLSv1:RSA:EXP:EXPORT40:RC4:", "rsa_rc2_40_md5" => ":ALL:SSLv3:TLSv1:RSA:EXP:EXPORT40:RC2:", "rsa_null_md5" => ":SSLv3:TLSv1:RSA:MD5:NULL:", "rsa_null_sha" => ":SSLv3:TLSv1:RSA:SHA:NULL:", "rsa_des_56_sha" => ":ALL:SSLv3:TLSv1:RSA:DES:SHA:EXP:EXPORT56:", "rsa_rc4_56_sha" => ":ALL:SSLv3:TLSv1:RSA:RC4:SHA:EXP:EXPORT56:", ); $NUM_CIPHERS = 16; for ($i = 0; $i < $NUM_CIPHERS; $i++) { $selected[$i] = 0; } # Don't need to worry about the ordering properties of "+" because # NSS always chooses the "best" cipher anyway. You can't specify # preferred order. # -1: this cipher is completely out # 0: this cipher is currently unselected, but maybe added later # 1: this cipher is selected @s = split(/:/, $str); for ($i = 0; $i <= $#s; $i++) { $j = 0; $val = 1; # ! means this cipher is disabled forever if ($s[$i] =~ /^!/) { $val = -1; ($s[$i] =~ s/^!//); } elsif ($s[$i] =~ /^-/) { $val = 0; ($s[$i] =~ s/^-//); } elsif ($s[$i] =~ /^+/) { ($s[$i] =~ s/^+//); } for $cipher (sort keys %cipher_list) { $match = 0; # For embedded + we do an AND for all options if ($s[$i] =~ m/(\w+\+)+/) { @sub = split(/^\+/, $s[$i]); $match = 1; for ($k = 0; $k <=$#sub; $k++) { if ($cipher_list{$cipher} !=~ m/:$sub[$k]:/) { $match = 0; } } } else { # straightforward match if ($cipher_list{$cipher} =~ m/:$s[$i]:/) { $match = 1; } } if ($match && $selected[$j] != -1) { $selected[$j] = $val; } $j++; } } # NSS doesn't honor the order of a cipher list, it uses the "strongest" # cipher available. So we'll print out the ciphers as SSLv2, SSLv3 and # the NSS ciphers not available in OpenSSL. $str = "SSLv2:SSLv3"; @s = split(/:/, $str); $ciphersuite = ""; for ($i = 0; $i <= $#s; $i++) { $j = 0; for $cipher (sort keys %cipher_list) { if ($cipher_list{$cipher} =~ m/:$s[$i]:/) { if ($selected[$j]) { $ciphersuite .= "+"; } else { $ciphersuite .= "-"; } $ciphersuite .= $cipher . ","; } $j++; } } $ciphersuite .= "-fortezza,-fortezza_rc4_128_sha,-fortezza_null,-fips_des_sha,+fips_3des_sha,-rsa_aes_128_sha,-rsa_aes_256_sha"; return $ciphersuite; } # Given the filename of a PEM file, use openssl to fetch the certificate # subject sub get_cert_subject { my $file = shift; my $subject = ""; return "" if ! -T $file; $subject = `openssl x509 -subject < $file | head -1`; $subject =~ s/subject= \///; # Remove leading subject= \ $subject =~ s/\//,/g; # Replace / with , as separator $subject =~ s/Email=.*(,){0,1}//; # Remove Email attribute $subject =~ s/,$//; # Remove any trailing commas chomp($subject); return $subject; } # # Wrapper around the system() command sub run_command { my @args = shift; my $status = 0; $status = 0xffff & system(@args); return if ($status == 0); print "Command '@args' failed: $!\n"; exit; }
shawnwhit/httpd_modnss
migrate.pl
Perl
apache-2.0
10,620
=head1 LICENSE Copyright [1999-2016] 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. =head1 CONTACT Please email comments or questions to the public Ensembl developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. Questions may also be sent to the Ensembl help desk at <http://www.ensembl.org/Help/Contact>. =head1 NAME =head1 SYNOPSIS =head1 DESCRIPTION =cut package Bio::EnsEMBL::Funcgen::Frip; use strict; use Bio::EnsEMBL::Utils::Exception qw( deprecate ); use Bio::EnsEMBL::Funcgen::GenericGetSetFunctionality qw( _generic_get_or_set _generic_fetch ); use Role::Tiny::With; with 'Bio::EnsEMBL::Funcgen::GenericConstructor'; sub _constructor_parameters { return { dbID => 'dbID', adaptor => 'adaptor', frip => 'frip', total_reads => 'total_reads', peak_calling_id => 'peak_calling_id', }; } sub dbID { return shift->_generic_get_or_set('dbID', @_); } sub adaptor {return shift->_generic_get_or_set('adaptor', @_);} sub frip { return shift->_generic_get_or_set('frip', @_); } sub total_reads { return shift->_generic_get_or_set('total_reads', @_); } sub peak_calling_id { return shift->_generic_get_or_set('peak_calling_id', @_); } sub get_PeakCalling { return shift->_generic_fetch('peak_calling', 'get_PeakCallingAdaptor', 'peak_calling_id'); } =head2 summary_as_hash Example : $summary = $frip->summary_as_hash; Description : Returns summary in a hash reference. Returns : Hashref of descriptive strings Status : Intended for internal use (REST) =cut sub summary_as_hash { my $self = shift; my $peak_calling = $self->get_PeakCalling; return { frip => $self->frip, total_reads => $self->total_reads, peak_calling => $peak_calling->summary_as_hash, }; } 1;
Ensembl/ensembl-funcgen
modules/Bio/EnsEMBL/Funcgen/Frip.pm
Perl
apache-2.0
2,443
#!/usr/bin/env perl use strict; use Data::Dumper; use Bio::EnsEMBL::Registry; use Getopt::Long; =head1 load_probeset_to_transcript_assignments.pl \ --registry /homes/mnuhn/work_dir_probemapping/lib/ensembl-funcgen/registry.pm \ --species homo_sapiens \ --array_name foobar \ --probe_transcript_assignments_file /nfs/nobackup/ensembl/mnuhn/array_mapping/temp/homo_sapiens/probeset_to_transcript_file.pl =cut my $probe_transcript_assignments_file; my $species; my $registry; my $array_name; GetOptions ( 'registry=s' => \$registry, 'species=s' => \$species, 'array_name=s' => \$array_name, 'probe_transcript_assignments_file=s' => \$probe_transcript_assignments_file, ); use Bio::EnsEMBL::Utils::Logger; my $logger = Bio::EnsEMBL::Utils::Logger->new(); $logger->init_log; Bio::EnsEMBL::Registry->load_all($registry); my $funcgen_db_adaptor = Bio::EnsEMBL::Registry->get_DBAdaptor($species, 'funcgen'); my $funcgen_dbc = $funcgen_db_adaptor->dbc; my $mysql_base_cmd = 'mysql' . ' --host=' . $funcgen_dbc->host . ' --port=' . $funcgen_dbc->port . ' --user=' . $funcgen_dbc->username . ' --password=' . $funcgen_dbc->password . ' ' . $funcgen_dbc->dbname . ' -e ' ; my @load_command = map { $mysql_base_cmd . "'" . $_ . "'" } ( 'load data local infile "' . $probe_transcript_assignments_file . '" into table probe_transcript (probe_id, stable_id, description);', ); foreach my $current_load_command (@load_command) { $logger->info("Running:\n"); $logger->info("$current_load_command\n"); my $exit_code = system($current_load_command); if ($exit_code != 0) { $logger->error("Failure when running command\n$current_load_command\n"); } } $logger->info("Done.\n"); $logger->finish_log;
Ensembl/ensembl-funcgen
scripts/array_mapping/load_probe_to_transcript_assignments.pl
Perl
apache-2.0
1,781
package VMOMI::HostConfigFault; use parent 'VMOMI::VimFault'; use strict; use warnings; our @class_ancestors = ( 'VimFault', 'MethodFault', ); our @class_members = ( ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/HostConfigFault.pm
Perl
apache-2.0
398
# # Copyright 2018 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 hardware::server::hp::ilo::xmlapi::custom::api; use strict; use warnings; use IO::Socket::SSL; use LWP::UserAgent; use XML::Simple; sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; if (!defined($options{output})) { print "Class Custom: Need to specify 'output' argument.\n"; exit 3; } if (!defined($options{options})) { $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); $options{output}->option_exit(); } if (!defined($options{noptions})) { $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "timeout:s" => { name => 'timeout', default => 30 }, "port:s" => { name => 'port', default => 443 }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, 'ssl-opt:s%' => { name => 'ssl_opt' }, "force-ilo3" => { name => 'force_ilo3' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XML API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; return $self; } sub set_options { my ($self, %options) = @_; $self->{option_results} = $options{option_results}; } sub set_defaults { my ($self, %options) = @_; foreach (keys %{$options{default}}) { if ($_ eq $self->{mode}) { for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { foreach my $opt (keys %{$options{default}->{$_}[$i]}) { if (!defined($self->{option_results}->{$opt}[$i])) { $self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt}; } } } } } } sub check_options { my ($self, %options) = @_; if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { $self->{output}->add_option_msg(short_msg => "Need to set hostname option."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{username}) || $self->{option_results}->{username} eq '') { $self->{output}->add_option_msg(short_msg => "Need to set username option."); $self->{output}->option_exit(); } if (!defined($self->{option_results}->{password})) { $self->{output}->add_option_msg(short_msg => "Need to set password option."); $self->{output}->option_exit(); } $self->{ssl_opts} = ''; if (!defined($self->{option_results}->{ssl_opt})) { $self->{ssl_opts} = 'SSL_verify_mode => SSL_VERIFY_NONE'; } else { foreach (keys %{$self->{option_results}->{ssl_opt}}) { $self->{ssl_opts} .= "$_ => " . $self->{option_results}->{ssl_opt}->{$_} . ", "; } } return 0; } sub find_ilo_version { my ($self, %options) = @_; ($self->{ilo2}, $self->{ilo3}) = (0, 0); my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}); if (!$client) { $self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR"); $self->{output}->option_exit(); } print $client 'POST /ribcl HTTP/1.1' . "\r\n"; print $client "HOST: me" . "\r\n"; # Mandatory for http 1.1 print $client "User-Agent: locfg-Perl-script/3.0\r\n"; print $client "Content-length: 30" . "\r\n"; # Mandatory for http 1.1 print $client 'Connection: Close' . "\r\n"; # Required print $client "\r\n"; # End of http header print $client "<RIBCL VERSION=\"2.0\"></RIBCL>\r\n"; # Used by Content-length my $ln = <$client>; if ($ln =~ m/HTTP.1.1 200 OK/) { $self->{ilo3} = 1; } else { $self->{ilo2} = 1; } close $client; } sub get_ilo2_data { my ($self, %options) = @_; my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}); if (!$client) { $self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR"); $self->{output}->option_exit(); } print $client '<?xml version="1.0"?>' . "\r\n"; print $client '<RIBCL VERSION="2.21">' . "\r\n"; print $client '<LOGIN USER_LOGIN="' . $self->{option_results}->{username} . '" PASSWORD="' . $self->{option_results}->{password} . '">' . "\r\n"; print $client '<SERVER_INFO MODE="read">' . "\r\n"; print $client '<GET_EMBEDDED_HEALTH />' . "\r\n"; print $client '</SERVER_INFO>' . "\r\n"; print $client '</LOGIN>' . "\r\n"; print $client '</RIBCL>' . "\r\n"; while (my $line = <$client>) { $self->{content} .= $line; } close $client; } sub get_ilo3_data { my ($self, %options) = @_; my $xml_script = "<RIBCL VERSION=\"2.21\"> <LOGIN USER_LOGIN=\"$self->{option_results}->{username}\" PASSWORD=\"$self->{option_results}->{password}\"> <SERVER_INFO MODE=\"read\"> <GET_EMBEDDED_HEALTH /> </SERVER_INFO> </LOGIN> </RIBCL> "; my $ua = LWP::UserAgent->new(keep_alive => 0, protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout}); my $req = HTTP::Request->new(POST => "https://" . $self->{option_results}->{hostname} . '/ribcl'); $req->content_length(length($xml_script)); $req->content($xml_script); $req->header(TE => 'chunked'); $req->header(Connection => 'Close'); my $context = new IO::Socket::SSL::SSL_Context(eval $self->{ssl_opts}); IO::Socket::SSL::set_default_context($context); my $response = $ua->request($req); $self->{content} = $response->content; if (!$response->is_success) { $self->{output}->add_option_msg(short_msg => "Cannot get data: $response->status_line"); $self->{output}->option_exit(); } } sub check_ilo_error { my ($self, %options) = @_; # Looking for: # <RESPONSE # STATUS="0x005F" # MESSAGE='Login credentials rejected.' # /> while ($self->{content} =~ /<response[^>]*?status="0x(.*?)"[^>]*?message='(.*?)'/msig) { my ($status_code, $message) = ($1, $2); if ($status_code !~ /^0+$/) { $self->{output}->add_option_msg(short_msg => "Cannot get data: $2"); $self->{output}->option_exit(); } } } sub change_shitty_xml { my ($self, %options) = @_; # Can be like that the root <RIBCL VERSION="2.22" /> ???!! $options{response} =~ s/<RIBCL VERSION="(.*?)"\s*\/>/<RIBCL VERSION="$1">/mg; # ILO2 can send: # <DRIVES> # <Backplane firmware version="Unknown", enclosure addr="224"/> # <Drive Bay: "1"; status: "Ok"; uid led: "Off"> # <Drive Bay: "2"; status: "Ok"; uid led: "Off"> # <Drive Bay: "3"; status: "Not Installed"; uid led: "Off"> # <Drive Bay: "4"; status: "Not Installed"; uid led: "Off"> # <Backplane firmware version="1.16own", enclosure addr="226"/> # <Drive Bay: "5"; status: "Not Installed"; uid led: "Off"> # <Drive Bay: "6"; status: "Not Installed"; uid led: "Off"> # <Drive Bay: "7"; status: "Not Installed"; uid led: "Off"> # <Drive Bay: "8"; status: "Not Installed"; uid led: "Off"> # </DRIVES> $options{response} =~ s/<Backplane firmware version="(.*?)", enclosure addr="(.*?)"/<BACKPLANE FIRMWARE_VERSION="$1" ENCLOSURE_ADDR="$2"/mg; $options{response} =~ s/<Drive Bay: "(.*?)"; status: "(.*?)"; uid led: "(.*?)">/<DRIVE_BAY NUM="$1" STATUS="$2" UID_LED="$3" \/>/mg; #Other shitty xml: # <BACKPLANE> #  <ENCLOSURE_ADDR VALUE="224"/> # <DRIVE_BAY VALUE = "1"/> #  <PRODUCT_ID VALUE = "EG0300FCVBF"/> #  <STATUS VALUE = "Ok"/> #  <UID_LED VALUE = "Off"/> # <DRIVE_BAY VALUE = "2"/> #  <PRODUCT_ID VALUE = "EH0146FARUB"/> #  <STATUS VALUE = "Ok"/> #  <UID_LED VALUE = "Off"/> # <DRIVE_BAY VALUE = "3"/> #  <PRODUCT_ID VALUE = "EH0146FBQDC"/> #  <STATUS VALUE = "Ok"/> #  <UID_LED VALUE = "Off"/> # <DRIVE_BAY VALUE = "4"/> #  <PRODUCT_ID VALUE = "N/A"/> #  <STATUS VALUE = "Not Installed"/> #  <UID_LED VALUE = "Off"/> # </BACKPLANE> $options{response} =~ s/<DRIVE_BAY\s+VALUE\s*=\s*"(.*?)".*?<STATUS\s+VALUE\s*=\s*"(.*?)".*?<UID_LED\s+VALUE\s*=\s*"(.*?)".*?\/>/<DRIVE_BAY NUM="$1" STATUS="$2" UID_LED="$3" \/>/msg; # 3rd variant, known as the ArnoMLT variant # <BACKPLANE> # <FIRMWARE VERSION="1.16"/> # <ENCLOSURE ADDR="224"/> # <DRIVE BAY="1"/> # <PRODUCT ID="EG0300FCVBF"/> # <DRIVE_STATUS VALUE="Ok"/> # <UID LED="Off"/> # <DRIVE BAY="2"/> # <PRODUCT ID="EH0146FARUB"/> # <DRIVE_STATUS VALUE="Ok"/> # <UID LED="Off"/> # <DRIVE BAY="3"/> # <PRODUCT ID="EH0146FBQDC"/> # <DRIVE_STATUS VALUE="Ok"/> # <UID LED="Off"/> # <DRIVE BAY="4"/> # <PRODUCT ID="N/A"/> # <DRIVE_STATUS VALUE="Not Installed"/> # <UID LED="Off"/> # </BACKPLANE> $options{response} =~ s/<FIRMWARE\s+VERSION\s*=\s*"(.*?)".*?<ENCLOSURE\s+ADDR\s*=\s*"(.*?)".*?\/>/<BACKPLANE FIRMWARE_VERSION="$1" ENCLOSURE_ADDR="$2"/mg; $options{response} =~ s/<DRIVE\s+BAY\s*=\s*"(.*?)".*?<DRIVE_STATUS\s+VALUE\s*=\s*"(.*?)".*?<UID\s+LED\s*=\s*"(.*?)".*?\/>/<DRIVE_BAY NUM="$1" STATUS="$2" UID_LED="$3" \/>/msg; return $options{response}; } sub get_ilo_response { my ($self, %options) = @_; # ilo result is so shitty. We get the good result from size... my ($length, $response) = (0, ''); foreach (split /<\?xml.*?\?>/, $self->{content}) { if (length($_) > $length) { $response = $_; $length = length($_); } } $response = $self->change_shitty_xml(response => $response); my $xml_result; eval { $xml_result = XMLin($response, ForceArray => ['FAN', 'TEMP', 'MODULE', 'SUPPLY', 'PROCESSOR', 'NIC', 'SMART_STORAGE_BATTERY', 'CONTROLLER', 'DRIVE_ENCLOSURE', 'LOGICAL_DRIVE', 'PHYSICAL_DRIVE', 'DRIVE_BAY', 'BACKPLANE']); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@"); $self->{output}->option_exit(); } return $xml_result; } sub get_ilo_data { my ($self, %options) = @_; $self->{content} = ''; if (!defined($self->{option_results}->{force_ilo3})) { $self->find_ilo_version(); } else { $self->{ilo3} = 1; } if ($self->{ilo3} == 1) { $self->get_ilo3_data(); } else { $self->get_ilo2_data(); } $self->{content} =~ s/\r//sg; $self->{output}->output_add(long_msg => $self->{content}, debug => 1); $self->check_ilo_error(); return $self->get_ilo_response(); } 1; __END__ =head1 NAME ILO API =head1 SYNOPSIS ilo api =head1 XML API OPTIONS =over 8 =item B<--hostname> Hostname to query. =item B<--username> ILO username. =item B<--password> ILO password. =item B<--port> ILO Port (Default: 443). =item B<--timeout> Set timeout (Default: 30). =item B<--force-ilo3> Don't try to find ILO version. =item B<--ssl-opt> Set SSL Options (--ssl-opt="SSL_version=SSLv3"). Default: --ssl-opt="SSL_verify_mode=SSL_VERIFY_NONE" =back =head1 DESCRIPTION B<custom>. =cut
wilfriedcomte/centreon-plugins
hardware/server/hp/ilo/xmlapi/custom/api.pm
Perl
apache-2.0
12,845
# # Copyright 2016 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for # service performance. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # package centreon::common::radlan::mode::cpu; use base qw(centreon::plugins::mode); use strict; use warnings; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { "warning:s" => { name => 'warning', default => '' }, "critical:s" => { name => 'critical', default => '' }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); ($self->{warn1s}, $self->{warn1m}, $self->{warn5m}) = split /,/, $self->{option_results}->{warning}; ($self->{crit1s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical}; if (($self->{perfdata}->threshold_validate(label => 'warn1s', value => $self->{warn1s})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn1s} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warn5m', value => $self->{warn5m})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit1s', value => $self->{crit1s})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit1s} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit5m', value => $self->{crit5})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; my $oid_rlCpuUtilEnable = '.1.3.6.1.4.1.89.1.6.0'; my $oid_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.89.1.7.0'; my $oid_rlCpuUtilDuringLastMinute = '.1.3.6.1.4.1.89.1.8.0'; my $oid_rlCpuUtilDuringLast5Minutes = '.1.3.6.1.4.1.89.1.9.0'; $self->{result} = $self->{snmp}->get_leef(oids => [ $oid_rlCpuUtilEnable, $oid_rlCpuUtilDuringLastSecond, $oid_rlCpuUtilDuringLastMinute, $oid_rlCpuUtilDuringLast5Minutes ], nothing_quit => 1); if (defined($self->{result}->{$oid_rlCpuUtilEnable}) && $self->{result}->{$oid_rlCpuUtilEnable} == 1) { my $cpu1sec = $self->{result}->{$oid_rlCpuUtilDuringLastSecond}; my $cpu1min = $self->{result}->{$oid_rlCpuUtilDuringLastMinute}; my $cpu5min = $self->{result}->{$oid_rlCpuUtilDuringLast5Minutes}; my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1sec, threshold => [ { label => 'crit1s', exit_litteral => 'critical' }, { label => 'warn1s', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min, threshold => [ { label => 'crit1m', exit_litteral => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' } ]); my $exit3 = $self->{perfdata}->threshold_check(value => $cpu5min, threshold => [ { label => 'crit5m', exit_litteral => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]); my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Usage: %.2f%% (1sec), %.2f%% (1min), %.2f%% (5min)", $cpu1sec, $cpu1min, $cpu5min)); $self->{output}->perfdata_add(label => "cpu_1s", unit => '%', value => $cpu1sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1s'), min => 0, max => 100); $self->{output}->perfdata_add(label => "cpu_1m", unit => '%', value => $cpu1min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), min => 0, max => 100); $self->{output}->perfdata_add(label => "cpu_5m", unit => '%', value => $cpu5min, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), min => 0, max => 100); } else { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => sprintf("CPU measurement is not enabled.")); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check cpu usage (RADLAN-rndMng). =over 8 =item B<--warning> Threshold warning in percent (1s,1min,5min). =item B<--critical> Threshold critical in percent (1s,1min,5min). =back =cut
golgoth31/centreon-plugins
centreon/common/radlan/mode/cpu.pm
Perl
apache-2.0
6,957
#!/usr/bin/env perl # Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute # Copyright [2016-2018] 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. use warnings ; use strict; use Bio::EnsEMBL::DBSQL::DBConnection; use Bio::EnsEMBL::DBSQL::ProteinAlignFeatureAdaptor; use Bio::EnsEMBL::Pipeline::SeqFetcher::Mfetch; use Bio::EnsEMBL::Pipeline::Analysis; use Bio::EnsEMBL::Utils::Exception qw ( throw warning ) ; use Bio::EnsEMBL::Utils::Exception qw ( throw warning ) ; use Bio::EnsEMBL::Analysis::Tools::Utilities qw ( get_input_arg ) ; use Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor; use Bio::EnsEMBL::Pipeline::DBSQL::AnalysisAdaptor; use Getopt::Long; $|=1; # SETTING THE DEFAULT VALUES FOR DB-CONNECTION ETC my %opt = ( #infile => "acc.all" , infile => "tmp.acc" , outfile => "fasta.seq" , ); # &GetOptions( \%opt , 'infile=s', 'outfile=s', ) ; # read file with acc's to fetch my @all_acc ; open (PAF,$opt{infile}) || die " cant read file $opt{infile}\n" ; for ( <PAF> ) { chomp ; push @all_acc , $_ ; } close(PAF); # create Mfetch seqfetcher my $obj = Bio::EnsEMBL::Pipeline::SeqFetcher::Mfetch->new(); $obj->verbose(0); $obj->options("-d emblrelease"); # chunk acc ... my @hit_id_chunks; print " have " .scalar(@all_acc) . " ids to investigate ...\n" ; while ( @all_acc) { my @tmp = splice @all_acc, 0, 5000 ; push @hit_id_chunks, \@tmp ; } system("rm $opt{outfile}") ; my ( $entries, $not_found ) ; my @all_not_found ; my $count = 0 ; for my $acc_ref ( @hit_id_chunks ) { ($entries, $not_found ) = @{$obj->get_Seq_BatchFetch($acc_ref) } ; for ( @$entries ) { open (FA,">>$opt{outfile}") || die "cant write to file $opt{outfile}\n" ; print FA "$_\n" ; close(FA) ; $count++ if /^>/; } print " $count entries found \n" ; push @all_not_found , @$not_found ; print scalar( @all_not_found) . " entries not found \n" ; } # # single fetchs with wildcards - second round # print "\nNo description found by mfetch for " . scalar(@all_not_found) . " entries !!!! - we try with wildcards now ... \n" ; my @not_found_2 ; my @wildcard_found ; for my $acc ( @all_not_found ) { print "trying $acc\n" ; my @entry = @{$obj->get_Seq_by_acc_wildcard($acc)} ; if ( scalar(@entry > 0 )) { push @wildcard_found, @entry ; }else { warning( "No entry found for $acc\% with wildcard-search ") ; push @not_found_2, $acc ; } } for ( @wildcard_found) { open (FA,">>$opt{outfile}") || die "cant write to file $opt{outfile}\n" ; print FA "$_\n" ; close(FA) ; $count++ if /^>/; } open (A,">no_acc_found.txt") || die "Can't write to file \n" ; for ( @not_found_2) { print; print A "entry_really_not_found_by_mfetch_for $_\n" ; } close(A);
kiwiroy/ensembl-analysis
scripts/genebuild/get_cdna_seq_for_acc_batch.pl
Perl
apache-2.0
3,618
=head1 NAME Changes =head1 Description Refer to this document to learn what changes were made to the documents since you read them last time. The most recent changes are listed first. =head1 ??? (format: Sat Nov 12 20:34:23 CET 2002) * ... [...] * ... [...] =cut
Distrotech/mod_perl
docs/src/contribute/docs/Changes_template.pod
Perl
apache-2.0
282
=head1 Perl 6 Summary for 2005-11-14 through 2005-11-21 All~ Welcome to another Perl 6 Summary. The attentive among you may notice that this one is on time. I am not sure how that happened, but we will try and keep it up. On a complete side note, I think there should be a Perl guild of some sort on World of Warcraft. It should probably be horde if there is, both because I hate the alliance and because it fits better. =head2 Perl 6 Language As usual for Pugs, most development continued off list. L<http://planetsix.perl.org/> =head3 Too Lazy? Luke Palmer posted a problem he was having with pugs. Warnock applies (which likely means it was made into a test and fixed). L<http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/9d5012c0b3e5079a/6bdb59de0fab8246#6bdb59de0fab8246> =head3 Assigning to Named Subrules Jerry Gay had a question about the semantics of assigning to named subrules in PGE. Patrick explained that it created an array of capture objects. L<http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/9dc568a5a0391365/d8ee99798212f58a#d8ee99798212f58a> =head3 Keyed Access to Match Objects Jerry Gay was having trouble with keyed access to match objects. After some discussion he implemented the keyed routine he needed and threatened to implement a few more. L<http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/16c8af4290e75b22/e529fe533110ecbe#e529fe533110ecbe> =head3 PGE Now C< compreg >s Patrick announced that PGE was now a better citizen in the parrot world, using compreg to locate the compiler instead of find_global. L<http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/eb50bb834327a5ab/b77c56575c3ebfbe#b77c56575c3ebfbe> =head2 Parrot I am going to get an English muffin. More in a moment... much better. Peanut butter is a wonderful thing. Where was I? =head3 Character Classes Done Jerry Gay wondered if the TODO about strings and character classes was still open. Patrick said it was resolved and should be closed. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/ca6c07bfaee9f1d4/b55caddf2dfc400a#b55caddf2dfc400a> =head3 rx_grammar.pl Progress? Jerry Gay wondered if rx_grammar.pl had seen any work lately. Warnock applies. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/64c78fe69846258d/7c1b88c491deac16#7c1b88c491deac16> =head3 N Registers No Longer Get Whacked Leo, thanks to his new calling scheme, closed an RT ticket from Dec 2004. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/1a49ff84b16b7198/1a377bd2d11060ef#1a377bd2d11060ef> =head3 Report SVN Revision in parrotbug? Jerry Gay resurrected an old ticket wondering whether to add a revision field to RT tickets. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/cd7dfe074c37d174/c3fccf655c51904a#c3fccf655c51904a> =head3 Making Parrot Potable Florian Ragwitz was having trouble drinking Parrot so he wants to expend some effort to make it more potable. Apparently it does not get drunk so well by many machines in debian's build farms and he would like to fix it. When he asked how best to do his work (so as not to upset to many), Chip suggested a local SVK mirror. Hopefully after he is done even more people will be able to enjoy drinking the Parrot kool-aid. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/d803b7f2b8417727/605393cd96d69be7#605393cd96d69be7> =head3 pbc_merge Requires LINK_DYNAMIC Nick Glencross provided a patch fixing pbc_merge on HP-UX. François Perrad noted that it was also problem on Win32. Jonathan Worthington explained that he was aware of the problem and that the dependency on the dynamic libraries would soon be removed. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/42b907bf01d66a2a/212755db03cce8a1#212755db03cce8a1> =head3 Compilable Option Will Coleda wants a -c option which will only tell you if the code is compilable for Parrot. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/8f5f6021f1406a07/635ab82c100fa52d#635ab82c100fa52d> =head3 Clerihewsiwhatsit? Inspired by Piers's inspiration from his name, Roger Browne wrote a Clerihew. Piers and Roger scare me. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/6e39f1b1c84792dd/23f7b21652dfe022#23f7b21652dfe022> =head3 Debug Segments There was much discussion about what sort of interface to expose to HLL for debug segments. It looks like something good will come out of it all. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/b0d36dafb42d96c4/4b9140e96ecbc701#4b9140e96ecbc701> =head3 "Amber for Parrot" version 0.3.1 Announced, Roger Browne displaying Amber 0.3.1 aroun': this latest version, magic cookie, is more than just a rookie. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/760810ec5160f2ab/70741c55ab3815fa#70741c55ab3815fa> =head3 t/library/streams.t Failing Patrick is still having trouble with t/library/streams.t. It sounds like he would appreciate help, but Warnock applies. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/1535345f3306e138/01b1a6bdfb5e2a6f#01b1a6bdfb5e2a6f> =head3 PGE::glob Issues Will Coleda spotted a problem with PGE::Glob. Patrick fixed it. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/859b7c3b313aa140/de0b3b571aec6cb9#de0b3b571aec6cb9> =head3 C< find_word_boundary > Unneeded Patrick posted his explanation of why find_word_boundary was an unneeded opcode. Too that end he posted a patch updating t/op/string_cs.t. Warnock applies to both thoughts. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/0b0dc706caf34982/5908986db872e3d7#5908986db872e3d7> L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/fe28c6d9555fcca9/4ca61d7331cc256c#4ca61d7331cc256c> =head3 Coroutines Trample Scratchpads Nick Glencross noted that coroutine_3.pasm was trampling some memory. Leo said that scratchpads were on their way out. Nick wondered if the ticket should be closed now, or when this is fixed. I vote that we not close tickets until the problem is gone, but Warnock applies. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/ba3acad8cc01d330/e07c73b1b14ecec3#e07c73b1b14ecec3> =head3 MD5 Broken Chip noticed that MD5 was horribly broken recently. He decided that parrot should avoid it in favor of the SHA-2 family and maybe Whirlpool. If you are a crypto dork, you have your job cut out for you. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/1b33ec021704caa6/fa2107632828f6cb#fa2107632828f6cb> =head TODONE! remove $(MAKE_C) Joshua Hoblitt joyously closed an RT ticket about removing $(MAKE_C). L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/ab7660806ca6b225/e27261481f068261#e27261481f068261> =head3 inconsistent dll linkage Jerry Gay announce that the last MSVC 7.1 compiler warning had him thoroughly confused. Ron Blaschke explained the problem and suggested two solutions. I wonder if we have a clean windows build now? L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/937691fd89bf2b89/22931e95370ba697#22931e95370ba697> =head3 STM and Cycle Counting Erik Paulson explained that he was looking into adding STM to parrot, but wanted some sort of cycle counter. Leo explained what his rough idea for implementing this had been and suggested a way to implement the cycle counter with a minimum of slow down for everyone else. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/945c682af42c038b/c690a4a9bce7c0be#c690a4a9bce7c0be> =head3 Branching to Nonexistent Labels Jonathan Worthington was having fun making parrot segfault with malformed PIR. Leo put a stop to some of his fun. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/d7458f2a4f239e28/8b9d63453646a4d4#8b9d63453646a4d4> =head3 Changing Default File Handles chromatic wants to be able to reopen his file handles for Parrot::Test. Jerry Gay suggest some sort of freopen opcode. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/421a54eb55fdfeab/866f5e2b7c04a60c#866f5e2b7c04a60c> =head3 New pmc syntax for HLLs Will Coleda stole some of Ambers type registration magic, but he made it a little sugarier syntactically. So Roger Browne stole back. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/27c5730226210376/5f7274fad212101b#5f7274fad212101b> =head3 Call Frame Access Chip began to pontificate about how one should access call frames. Chip suggested using a PMC, but Leo thought that would be too slow. It looks like the preliminary decision was to go with methods on the interpreter PMC. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/609fc6101532949c/d593b0069ea729a0#d593b0069ea729a0> =head3 test suite refactoring Jerry Gay posted an idea for how to refactor the test suite to make it a little less scattered about. Response was positive and he began working. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/a90eb8e5243fc2e2/d43bb21ae39f2c51#d43bb21ae39f2c51> =head3 RESPONSIBLE_PARTIES Joshua Hoblitt made Jerry Gay the responsible/culpable party for the test suite. Jerry Gay, having successfully drunk the kool-aid, was honored. L<http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/743a913188ceecc4/eb934c1c08832acf#eb934c1c08832acf> =head2 Perl 6 Language I want a cookie. Sadly there are none in the house. =head3 but, but, but... optimizations! Aaron Sherman wondered if chained buts would be optimized to one big anonymous class or would generate intermediate classes. Larry thought that maybe C< $b but C | D | E | F; > would be the syntax to use to get the first behavior and C< $b but C but D but E but F; > would provide the second. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/3254713549f08b08/3cfdbb9e1e8f1916#3cfdbb9e1e8f1916> =head3 Too Lazy? In an attempt to dewarnock himself, Luke Palmer changed audiences and expanded his question to allow for the autoloading of functions that were not found initially. Austin Hastings provided a few thoughts. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/d2a29bf0743bfb8a/f62cad068f431c06#f62cad068f431c06> =head3 Filling a Role Different Ways Christopher D. Malon posted an analysis of how he would like to fill roles in several different ways depending on whim. Warnock applied. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/cbe74c028340926e/da1758af0e39db19#da1758af0e39db19> =head3 Signature of C< => >? Joshua Choi wondered what the signature of => would be. Larry explained that it was undeclarable. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/24442afd2e433c30/7b03fc019968b112#7b03fc019968b112> =head3 s:g/grep/$something_better/ Ilmari Vacklin though that perhaps grep should be renamed to something better like filter. Some voiced their support for grep. I would guess that this is not going to change, although I did like the generalization for allowing arbitrary binning of items by returning an int from the block... L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/dd29618fec14cec9/4d97d50ab80cee5b#4d97d50ab80cee5b> L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/58fe5b1b2a2e2eb9/c310e61b6ef80262#c310e61b6ef80262> =head3 Private Behavior in Roles Ovid was having trouble with Class::Trait not hiding its imports. Larry explained that in Perl 6 importation would be lexically scoped to solve this problem. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/01a4f062b13a215a/e6731cfc2e1eb110#e6731cfc2e1eb110> =head3 Using Hyphens in Identifiers Daniel Brockman wondered about allowing hyphens in identifiers. C<@a[$i-1] + @a[$i+1]> convinced him it would be a bad idea. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/245e28632af8731e/5acf6612f2f68743#5acf6612f2f68743> =head3 Lvalue Reverse Juerd noticed that reverse in Perl 5 is quasi-lvalue-ish because of an optimization in for. He wants it to be made either fully or not at all an lvalue. People seem to agree. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/58c07ba51836f67a/d96a7660f7e45366#d96a7660f7e45366> =head3 The Once and Future Flipflop Ingo Blechschmidt wondered how till (the new flipflop operator) would work. Larry explained that it was a macro and Ingo was enlightened. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/d96fd1dc838c0bc0/d80f02c50aaba8b4#d80f02c50aaba8b4> =head3 multi-dimensional argument lists Ingo Blechschmidt was a little confused with multidimensional argument lists (such as that of zip). Much explanation ensued. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/215213b56405f298/bc35e105e7c8c180#bc35e105e7c8c180> =head3 statement_control? Rob Kinyon wondered what things were statement control items like for. Comments both helpful and snarky were offered. Fortunately the snarky ones were later apologized for. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/716cc00c900c7093/9614bc329fe4b75d#9614bc329fe4b75d> =head3 Where Has Ponie Run? Joshua Gatcomb wondered what the state of Ponie is. I must admit to wondering the exact same thing silently earlier this week. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/7f39c2e9d28e1b54/d9850edd26060582#d9850edd26060582> =head3 Combining Unicode Escapes Ruud H.G. van Tol (who has one of the cooler names I have seen lately) wondered about providing a nice syntax for escaping several Unicode sequences in a row. Larry explained that he already had it and pointed him to the latest set of apocalypses. L<http://groups.google.com/group/perl.perl6.language/browse_frm/thread/22fc5d41c69c7153/e8596c28d0e6fd89#e8596c28d0e6fd89> =head2 The usual footer To post to any of these mailing lists please subscribe by sending email to <perl6-internals-subscribe@perl.org>, <perl6-language-subscribe@perl.org>, or <perl6-compiler-subscribe@perl.org>. If you find these summaries useful or enjoyable, please consider contributing to the Perl Foundation to help support the development of Perl. You might also like to send feedback to ubermatt@gmail.com L<http://donate.perl-foundation.org/> -- The Perl Foundation L<http://dev.perl.org/perl6/> -- Perl 6 Development site L<http://planet.parrotcode.org/> -- Parrot Blog aggregator
autarch/perlweb
docs/dev/perl6/list-summaries/2005/p6summary.2005-11-21.pod
Perl
apache-2.0
14,867
# # Copyright 2019 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 database::informix::sql::mode::checkpoints; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { "warning-cp:s" => { name => 'warning_cp', }, "critical-cp:s" => { name => 'critical_cp', }, "warning-flush:s" => { name => 'warning_flush', }, "critical-flush:s" => { name => 'critical_flush', }, "warning-crit:s" => { name => 'warning_crit', }, "critical-crit:s" => { name => 'critical_crit', }, "warning-block:s" => { name => 'warning_block', }, "critical-block:s" => { name => 'critical_block', }, "filter-trigger:s" => { name => 'filter_trigger', }, }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning-cp', value => $self->{option_results}->{warning_cp})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning-cp threshold '" . $self->{option_results}->{warning_cp} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-cp', value => $self->{option_results}->{critical_cp})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical-cp threshold '" . $self->{option_results}->{critical_cp} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warning-flush', value => $self->{option_results}->{warning_flush})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning-flush threshold '" . $self->{option_results}->{warning_flush} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-flush', value => $self->{option_results}->{critical_flush})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical-flush threshold '" . $self->{option_results}->{critical_flush} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warning-crit', value => $self->{option_results}->{warning_crit})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning-crit threshold '" . $self->{option_results}->{warning_crit} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-crit', value => $self->{option_results}->{critical_crit})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical-crit threshold '" . $self->{option_results}->{critical_crit} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warning-block', value => $self->{option_results}->{warning_block})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning-block threshold '" . $self->{option_results}->{warning_block} . "'."); $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical-block', value => $self->{option_results}->{critical_block})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong critical-block threshold '" . $self->{option_results}->{critical_block} . "'."); $self->{output}->option_exit(); } } sub run { my ($self, %options) = @_; # $options{sql} = sqlmode object $self->{sql} = $options{sql}; $self->{sql}->connect(); $self->{sql}->query(query => q{ SELECT intvl, caller, cp_time, block_time, flush_time, crit_time FROM syscheckpoint }); $self->{output}->output_add(severity => 'OK', short_msg => "All checkpoint times are ok."); my $count = 0; while ((my $row = $self->{sql}->fetchrow_hashref())) { my $id = $row->{intvl}; my $name = centreon::plugins::misc::trim($row->{caller}); my ($cp_time, $block_time, $flush_time, $crit_time) = ($row->{cp_time}, $row->{block_time}, $row->{flush_time}, $row->{crit_time}); next if (defined($self->{option_results}->{filter_trigger}) && $name !~ /$self->{option_results}->{filter_trigger}/); $count++; my $exit1 = $self->{perfdata}->threshold_check(value => $cp_time, threshold => [ { label => 'critical-cp', 'exit_litteral' => 'critical' }, { label => 'warning-cp', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $block_time, threshold => [ { label => 'critical-block', 'exit_litteral' => 'critical' }, { label => 'warning-block', exit_litteral => 'warning' } ]); my $exit3 = $self->{perfdata}->threshold_check(value => $flush_time, threshold => [ { label => 'critical-flush', 'exit_litteral' => 'critical' }, { label => 'warning-flush', exit_litteral => 'warning' } ]); my $exit4 = $self->{perfdata}->threshold_check(value => $crit_time, threshold => [ { label => 'critical-crit', 'exit_litteral' => 'critical' }, { label => 'warning-crit', exit_litteral => 'warning' } ]); my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4 ]); $self->{output}->output_add(long_msg => sprintf("Checkpoint %s %s : Total Time %.4f, Block Time %.4f, Flush Time %.4f, Ckpt Time %.4f", $name, $id, $cp_time, $block_time, $flush_time, $crit_time) ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Checkpoint %s %s : Total Time %.4f, Block Time %.4f, Flush Time %.4f, Ckpt Time %.4f", $name, $id, $cp_time, $block_time, $flush_time, $crit_time) ); } $self->{output}->perfdata_add(label => 'cp_' . $name . "_" . $id, value => sprintf("%.4f", $cp_time), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_cp'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_cp'), min => 0); $self->{output}->perfdata_add(label => 'block_' . $name . "_" . $id, value => sprintf("%.4f", $block_time), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_block'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_block'), min => 0); $self->{output}->perfdata_add(label => 'flush_' . $name . "_" . $id, value => sprintf("%.4f", $flush_time), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_flush'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_flush'), min => 0); $self->{output}->perfdata_add(label => 'crit_' . $name . "_" . $id, value => sprintf("%.4f", $crit_time), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_crit'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_crit'), min => 0); } if ($count == 0) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => "Cannot find checkpoints (maybe the --name filter option)."); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check Informix Checkpoints. 4 values: - cp_time: Total checkpoint duration from request time to checkpoint completion. - flush_time: Time taken to flush all the bufferpools. - crit_time: This is the amount of time it takes for all transactions to recognize a checkpoint has been requested. - block_time: Transaction blocking time. =over 8 =item B<--warning-cp> Threshold warning 'cp_time' in seconds. =item B<--critical-cp> Threshold critical 'cp_time' in seconds. =item B<--warning-flush> Threshold warning 'flush_time' in seconds. =item B<--critical-flush> Threshold critical 'flush_time' in seconds. =item B<--warning-crit> Threshold warning 'crit_time' in seconds. =item B<--critical-crit> Threshold critical 'crit_time' in seconds. =item B<--warning-block> Threshold warning 'block_time' in seconds. =item B<--critical-block> Threshold critical 'block_time' in seconds. =item B<--filter-trigger> Filter events that can trigger a checkpoint with a regexp. =back =cut
Sims24/centreon-plugins
database/informix/sql/mode/checkpoints.pm
Perl
apache-2.0
10,278
use strict; package main; print("<html>\n"); print(" <head>\n"); print(" <meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">\n"); print(" <title>PerfStat Tool: Status And Performance Monitoring</title>\n"); print(" <link rel=\"stylesheet\" type=\"text/css\" href=\"../../../appRez/styleSheets/contentFrame.css\" media=\"screen\">\n"); print(" <link rel=\"stylesheet\" type=\"text/css\" href=\"../../../appRez/styleSheets/forms.css\" media=\"screen\">\n"); print(" <script language=\"javascript\" src=\"../../../appRez/javaScripts/contentFrame.js\"></script>\n"); print(" <script language=\"javascript\" src=\"../../../appRez/javaScripts/pm.displayHostGroupGraphs.js\"></script>\n"); print(" </head>\n"); print(" <body>\n"); print(" <div class=\"navHeader\">\n"); my $formula0=$sessionObj->param("groupViewStatus") ne "shared" ? "My HostGroups" : "Shared HostGroups";my $formula1=$sessionObj->param("hostGroupID");my $formula2=$graphSize;my $formula3=$customSize;my $formula4=$graphLayout;print(" Performance Monitor :: $formula0 :: <a onclick=\"top.bottomFrame.document.getElementById('perfmonFrameset').cols='250,*';\" href=\"../selectHGGraphs/index.pl?hostGroupID=$formula1&graphSize=$formula2&customSize=$formula3&graphLayout=$formula4\">Host Group Graphs</a>\n"); print(" </div>\n"); print(" <table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" class=\"table1\" width=\"100%\">\n"); print(" <tr>\n"); print(" <td class=\"tdTop\" nowrap=\"nowrap\" valign=\"middle\" align=\"left\">Create Graph(s)</td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <form name=\"outputHostGroupGraphs\" action=\"index.pl\" method=\"post\">\n"); print(" <td class=\"darkGray\" align=\"left\" valign=\"top\">\n"); my $formula5=$sessionObj->param("hostGroupID");print(" <input type=\"hidden\" name=\"hostGroupID\" value=\"$formula5\">\n"); my $formula6=$sessionObj->param("hostName");print(" <input type=\"hidden\" name=\"hostName\" value=\"$formula6\">\n"); print(" <input type=\"hidden\" name=\"hgGraphHolderArray\" value=\"\">\n"); print(" <table>\n"); print(" <tr>\n"); print(" <td><span class=\"table1Text1\">Layout:</span></td>\n"); print(" <td>\n"); print(" <select name=\"graphLayout\" size=\"1\">\n"); my $formula7=$graphLayout eq "1" ? "selected" : "";;print(" <option value=\"1\" $formula7>1 Column</option>\n"); my $formula8=$graphLayout eq "2" ? "selected" : "";;print(" <option value=\"2\" $formula8>2 Column</option>\n"); my $formula9=$graphLayout eq "3" ? "selected" : "";;print(" <option value=\"3\" $formula9>3 Column</option>\n"); my $formula10=$graphLayout eq "4" ? "selected" : "";;print(" <option value=\"4\" $formula10>4 Column</option>\n"); print(" </select>\n"); print(" </td>\n"); print(" <td><img src=\"../../../appRez/images/common/spacer.gif\" height=\"6\" width=\"4\" border=\"0\"></td>\n"); print(" <td nowrap><span class=\"table1Text1\">Graph Size:</span></td>\n"); print(" <td>\n"); print(" <select name=\"graphSize\" size=\"1\" onChange=\"document.outputHostGroupGraphs.customSize.value=''\">\n"); my $formula11=$graphSize eq "custom" ? "selected" : "";;print(" <option value=\"custom\" $formula11>Custom</option>\n"); my $formula12=$graphSize eq "small" ? "selected" : "";;print(" <option value=\"small\" $formula12>Small</option>\n"); my $formula13=$graphSize eq "medium" ? "selected" : "";;print(" <option value=\"medium\" $formula13>Medium</option>\n"); my $formula14=$graphSize eq "large" ? "selected" : "";;print(" <option value=\"large\" $formula14>Large</option>\n"); print(" </select>\n"); print(" </td>\n"); print(" <td><img src=\"../../../appRez/images/common/spacer.gif\" height=\"6\" width=\"4\" border=\"0\"></td>\n"); print(" <td nowrap><span class=\"table1Text1\">Custom Size:</span></td>\n"); my $formula15=$customSize;print(" <td><input type=\"text\" name=\"customSize\" value=\"$formula15\" size=\"3\" maxlength=\"3\" onFocus=\"document.outputHostGroupGraphs.graphSize.options[0].selected=true\"></td>\n"); print(" <td><span class=\"table1Text1\">%</span></td>\n"); print(" <td><img src=\"../../../appRez/images/common/spacer.gif\" height=\"6\" width=\"4\" border=\"0\"></td>\n"); print(" <td><input class=\"liteButton\" type=\"button\" value=\"Create\" onClick=\"top.topFrame.displayHostGroupGraphs();\"></td>\n"); print(" </tr>\n"); print(" </table>\n"); print(" </td>\n"); print(" </form>\n"); print(" </tr>\n"); print(" </table>\n"); print(" <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"); my $refinedGraphHolderArrayLen = @$refinedGraphHolderArray; my $graphDrawCounter = $graphLayout; for (my $count = 0; $count < $refinedGraphHolderArrayLen; $count++) { my $graphHash = $refinedGraphHolderArray->[$count]; my $hgName = $graphHash->{'hgName'}; my $serviceName = $graphHash->{'serviceName'}; my $graphName = $graphHash->{'graphName'}; my $intervalName = $graphHash->{'intervalName'}; my $graphType = $graphHash->{'graphType'}; if ($graphDrawCounter % $graphLayout == 0) { print(" <tr valign=\"top\" align=\"center\">\n"); print(" <td>\n"); print(" <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"table1\">\n"); print(" <tr>\n"); my $formula16=$hgName;my $formula17=$serviceName;my $formula18=$graphName;my $formula19=$intervalName;print(" <td class=\"tdTop\" nowrap=\"nowrap\">$formula16 :: $formula17 :: $formula18 :: $formula19</td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <td class=\"liteGray\" nowrap valign=\"middle\" align=\"center\">\n"); if ($graphType eq "bar") { my $formula20=$hgName;my $formula21=$serviceName;my $formula22=$graphName;my $formula23=$intervalName;my $formula24=$graphScale;print(" <img src=\"../../../appLib/graphs/hostgroupGraphs/singleServiceGraphs/drawGDGraph/index.pl?action=drawGraph&hgName=$formula20&serviceName=$formula21&graphName=$formula22&intervalName=$formula23&graphScale=$formula24&graphType=bar\" border=\"0\">\n"); } elsif ($graphType eq "pie") { my $formula25=$hgName;my $formula26=$serviceName;my $formula27=$graphName;my $formula28=$intervalName;my $formula29=$graphScale;print(" <img src=\"../../../appLib/graphs/hostgroupGraphs/singleServiceGraphs/drawGDGraph/index.pl?action=drawGraph&hgName=$formula25&serviceName=$formula26&graphName=$formula27&intervalName=$formula28&graphScale=$formula29&graphType=pie\" border=\"0\">\n"); } print(" </td>\n"); print(" </tr>\n"); print(" </table>\n"); print(" </td>\n"); } else { print(" <td><img src=\"../../../appRez/images/common/spacer.gif\" height=\"6\" width=\"4\" border=\"0\"></td>\n"); print(" <td>\n"); print(" <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"table1\">\n"); print(" <tr>\n"); my $formula30=$hgName;my $formula31=$serviceName;my $formula32=$graphName;my $formula33=$intervalName;print(" <td class=\"tdTop\" nowrap=\"nowrap\">$formula30 :: $formula31 :: $formula32 :: $formula33</td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <td class=\"liteGray\" nowrap valign=\"middle\" align=\"center\">\n"); if ($graphType eq "bar") { my $formula34=$hgName;my $formula35=$serviceName;my $formula36=$graphName;my $formula37=$intervalName;my $formula38=$graphScale;print(" <img src=\"../../../appLib/graphs/hostgroupGraphs/singleServiceGraphs/drawGDGraph/index.pl?action=drawGraph&hgName=$formula34&serviceName=$formula35&graphName=$formula36&intervalName=$formula37&graphScale=$formula38&graphType=bar\" border=\"0\">\n"); } elsif ($graphType eq "pie") { my $formula39=$hgName;my $formula40=$serviceName;my $formula41=$graphName;my $formula42=$intervalName;my $formula43=$graphScale;print(" <img src=\"../../../appLib/graphs/hostgroupGraphs/singleServiceGraphs/drawGDGraph/index.pl?action=drawGraph&hgName=$formula39&serviceName=$formula40&graphName=$formula41&intervalName=$formula42&graphScale=$formula43&graphType=pie\" border=\"0\">\n"); } print(" </td> \n"); print(" </tr>\n"); print(" </table>\n"); print(" </td>\n"); } $graphDrawCounter++; } print(" </tr>\n"); print(" </table>\n"); print(" </body>\n"); print("</html>\n");
ktenzer/perfstat
ui/perfMonitor/content/displayHGGraphs/dsp_hostGroupGraphs.pl
Perl
apache-2.0
8,356
:- module(dfta1, [dfta/5,fdfta/4,test/0, genTest/1, %writeDFTA/2, flatten_denotes/2]). :- use_module(readprog). :- use_module(cartprod). :- use_module(balanced_tree). :- use_module(library(lists)). /*%%%CIAO :- use_module(timer_ciao). */%%%CIAO %%%SICS/* :- use_module(timer_sics). %%%SICS*/ :- use_module(sigma). :- use_module(setops). test :- fdfta('~/Desktop/Henning/parsetypes.pl','~/Desktop/Henning/mymeta.pl',outex1,d), fdfta('~/Research/LP/NFTA-New/dnftype.pl','~/Research/LP/Exs/dnf.pl',outex2,d), fdfta('Tests/matrix2.pl','Tests/trans.pl',outex3,d), fdfta('Tests/ringtypes.pl','Tests/podelski.pl',outex4,d), fdfta('Tests/matrixtype.pl','Tests/trans.pl',outex5,d), fdfta('Tests/pictype.pl','Tests/picsim.pl',outpic,d). fdfta(RegTypeFile,Prog,Outfile,SDV) :- dfta(RegTypeFile,Prog,DFTA1,StateNames,SDV), open(Outfile,write,S), writeStateNames(S,StateNames), applyNames(DFTA1,StateNames,DFTA), writeConstrainedDFTA(S,DFTA), close(S). dfta(RegTypeFile,Prog,DFTA,StateNames,SDV) :- start_time, readprog(RegTypeFile,Cls), fsigma(Prog,Sigma), SigmaV=['$VAR'/0,'$CONST'/0|Sigma], makeDelta(Cls,SigmaV,Delta,SDV), initQMaps(Delta,QMap,QD0,StateMap,ConstMap), initFMap(SigmaV,FMap0), buildStates(QD0,SigmaV,QMap,StateMap,FMap0,QD0,FMapFinal,QDFinal), renameStates(QDFinal,1,root,StateNames), makeSmallDeltaD(SigmaV,FMapFinal,ConstMap,StateMap,DFTA,[]), end_time('Determinization time: ', user_output), writeStats(QDFinal,DFTA). makeDelta(Cls,Sigma,Delta,d) :- userTransitions(Cls,Delta,DeltaAny,0,M1), deltaAny(Sigma,DeltaAny,[],M1,_). makeDelta(Cls,Sigma,Delta,sd) :- userTransitions(Cls,Delta,DeltaAny,0,M1), deltaStatic(Sigma,DeltaAny,DeltaStatic,M1,M2), deltaAny(Sigma,DeltaStatic,[],M2,_). makeDelta(Cls,Sigma,Delta,sdv) :- userTransitions(Cls,Delta,DeltaAny,0,M1), deltaStatic(Sigma,DeltaAny,DeltaStatic,M1,M2), deltaAny(Sigma,DeltaStatic,DeltaVar,M2,M3), deltaVar(M3,DeltaVar). makeDelta(Cls,Sigma,Delta,dv) :- userTransitions(Cls,Delta,DeltaAny,0,M1), deltaAny(Sigma,DeltaAny,DeltaVar,M1,M2), deltaVar(M2,DeltaVar). makeDelta(Cls,Sigma,Delta,sdvn) :- userTransitions(Cls,Delta,DeltaAny,0,M1), deltaNonvar(Sigma,DeltaAny,DeltaNonvar,M1,M2), deltaStatic(Sigma,DeltaNonvar,DeltaStatic,M2,M3), deltaAny(Sigma,DeltaStatic,DeltaVar,M3,M4), deltaVar(M4,DeltaVar). userTransitions([predicates(_)|Cls],D0,D1,M0,M1) :- userTransitions(Cls,D0,D1,M0,M1). userTransitions([clause(((L->R):- true),[])|Cls],[transition(M1,(L->R))|D0],D1,M0,M2) :- M1 is M0+1, userTransitions(Cls,D0,D1,M1,M2). userTransitions([],D,D,M,M). deltaAny([],D,D,M,M). deltaAny([F/N|Fs],[transition(M1,(L->dynamic))|D0],D1,M0,M2) :- M1 is M0+1, anyargs(N,As), L=..[F|As], deltaAny(Fs,D0,D1,M1,M2). anyargs(0,[]). anyargs(J,[dynamic|As]) :- J>0, J1 is J-1, anyargs(J1,As). deltaStatic([],D,D,M,M). deltaStatic(['$VAR'/0|Fs],D0,D1,M0,M1) :- !, deltaStatic(Fs,D0,D1,M0,M1). deltaStatic([F/N|Fs],[transition(M1,(L->static))|D0],D1,M0,M2) :- M1 is M0+1, staticargs(N,As), L=..[F|As], deltaStatic(Fs,D0,D1,M1,M2). staticargs(0,[]). staticargs(J,[static|As]) :- J>0, J1 is J-1, staticargs(J1,As). deltaNonvar([],D,D,M,M). deltaNonvar(['$VAR'/0|Fs],D0,D1,M0,M1) :- !, deltaNonvar(Fs,D0,D1,M0,M1). deltaNonvar([F/N|Fs],[transition(M1,(L->nonvar))|D0],D1,M0,M2) :- M1 is M0+1, anyargs(N,As), L=..[F|As], deltaNonvar(Fs,D0,D1,M1,M2). deltaVar(M,[transition(M,('$VAR'->var))]). % initialise the fmap. fmap(f,j) = a set of sets of transitions, initially empty initFMap(Sigma,FMap) :- initFMap3(Sigma,root,FMap). initFMap3([],FMap,FMap). initFMap3([F/N|Sigma],FMap0,FMap2) :- initEachArg(N,F/N,FMap0,FMap1), initFMap3(Sigma,FMap1,FMap2). initEachArg(0,_,F,F). initEachArg(J,F,F0,F2) :- J>0, insert_tree(F0,key(F,J),[],F1), J1 is J-1, initEachArg(J1,F,F1,F2). intersectAll([],[]). intersectAll([A],A). intersectAll([A1,A2|As],S) :- intersectAll([A2|As],S1), setintersect(A1,S1,S). unionAll([],[]). unionAll([X|Xs],Ys) :- unionAll(Xs,Zs), setunion(X,Zs,Ys). % create the index QMap % QMap(q,f,j) = {t1,...,tm} iff for all transitions t1...tm, % where ti = f(qi1,..,qin) -> qi, qij = q. % Initialise the set of states QD. initQMaps(Delta,QMap,QD,StateMap,ConstMap) :- initQMaps7(Delta,root,QMap,root,ConstMap,root,StateMap), traverseVal_tree(ConstMap,QD1), makeset(QD1,QD). initQMaps7([],Q,Q,QD,QD,SM,SM). initQMaps7([transition(N,(L->R))|Delta],Q0,Q1,QD0,QD2,SM0,SM2) :- functor(L,C,0), !, addMapValueOrd(C,R,QD0,QD1), insert_tree(SM0,N,R,SM1), initQMaps7(Delta,Q0,Q1,QD1,QD2,SM1,SM2). initQMaps7([transition(N,(L->R))|Delta],Q0,Q2,QD0,QD1,SM0,SM2) :- functor(L,F,M), insertMapValues(M,F/M,L,N,Q0,Q1), insert_tree(SM0,N,R,SM1), initQMaps7(Delta,Q1,Q2,QD0,QD1,SM1,SM2). insertMapValues(0,_,_,_,Q,Q). insertMapValues(J,F,L,N,Q0,Q2) :- J > 0, arg(J,L,Q), addMapValue(key(Q,F,J),N,Q0,Q1), J1 is J-1, insertMapValues(J1,F,L,N,Q1,Q2). addMapValue(K,N,Q0,Q1) :- search_replace_tree(Q0,K,Ns,Q1,Ns1), !, setunion([N],Ns,Ns1). addMapValue(K,N,Q0,Q1) :- insert_tree(Q0,K,[N],Q1). addMapValueOrd(K,N,Q0,Q1) :- search_replace_tree(Q0,K,Ns,Q1,Ns1), !, insertOrd(N,Ns,Ns1). addMapValueOrd(K,N,Q0,Q1) :- insert_tree(Q0,K,[N],Q1). insertOrd(N,[],[N]). insertOrd(N,[N|Ns],[N|Ns]) :- !. insertOrd(N,[N1|Ns],[N,N1|Ns]) :- N @< N1, !. insertOrd(N,[N1|Ns],[N1|Ns1]) :- insertOrd(N,Ns,Ns1). % The main processing loop. buildStates([],_,_,_,FMap,QD,FMap,QD) :- !. buildStates(QDNew,Sigma,QMap,StateMap,FMap0,QD0,FMap2,QD2) :- %write('*'),nl, eachFunctorStates(Sigma,QDNew,QMap,StateMap,FMap0,FMap1,QD0,[],QDNew1), setunion(QDNew1,QD0,QD1), buildStates(QDNew1,Sigma,QMap,StateMap,FMap1,QD1,FMap2,QD2). eachFunctorStates([],_,_,_,FMap,FMap,_,QDNew,QDNew). eachFunctorStates([_/0|Sigma],QDNew,QMap,StateMap,FMap0,FMap1,QD,QDNew0,QDNew1) :- eachFunctorStates(Sigma,QDNew,QMap,StateMap,FMap0,FMap1,QD,QDNew0,QDNew1). eachFunctorStates([F/N|Sigma],QDNew,QMap,StateMap,FMap0,FMap2,QD,QDNew0,QDNew2) :- N>0, extendFMap(N,F/N,QMap,QDNew,FMap0,FMap1,JMaps), cartprod(JMaps,ProdF), findNewStates(ProdF,QD,StateMap,QDNew0,QDNew1), eachFunctorStates(Sigma,QDNew,QMap,StateMap,FMap1,FMap2,QD,QDNew1,QDNew2). extendFMap(0,_,_,_,FMap0,FMap0,[]). extendFMap(J,F,QMap,QDNew,FMap0,FMap2,[JMap|Js]) :- J > 0, updateFMap(FMap0,F,J,QMap,QDNew,FMap1,JMap), J1 is J-1, extendFMap(J1,F,QMap,QDNew,FMap1,FMap2,Js). updateFMap(FMap0,F,J,QMap,QDNew,FMap1,TTs) :- getQDMapVals(QDNew,QMap,F,J,QDMapVals), search_replace_tree(FMap0,key(F,J),JMap0,FMap1,JMap), insertQVals(QDMapVals,JMap0,JMap), getTTs(JMap,TTs). getQDMapVals([],_,_,_,[]). getQDMapVals([Q|QDNew],QMap,F,J,[Ts-Q|TTs]) :- qdmap(QMap,Q,F,J,Ts), getQDMapVals(QDNew,QMap,F,J,TTs). insertQVals([],JMap,JMap). insertQVals([Ts-Q|QTs],JMap0,JMap2) :- insertQVal(Ts,Q,JMap0,JMap1), insertQVals(QTs,JMap1,JMap2). insertQVal(Ts,Q,[],[Ts-[Q]]). insertQVal(Ts,Q,[Ts-Qs|TTs],[Ts-Qs1|TTs]) :- !, insertVal(Q,Qs,Qs1). insertQVal(Ts,Q,[Ts1-Qs|TTs],[Ts1-Qs|TTs1]) :- insertQVal(Ts,Q,TTs,TTs1). getTTs([],[]). getTTs([Ts-_|JMap],[Ts|TTs]) :- getTTs(JMap,TTs). qdmap(QMap,Q,F,J,Ts) :- qmapVals(Q,QMap,F,J,Ts1), unionAll(Ts1,Ts2), sort(Ts2,Ts). qmapVals([],_,_,_,[]). qmapVals([Q|Qs],QMap,F,J,[TsQ|Ts]) :- search_tree(QMap,key(Q,F,J),TsQ), !, qmapVals(Qs,QMap,F,J,Ts). qmapVals([_|Qs],QMap,F,J,Ts) :- qmapVals(Qs,QMap,F,J,Ts). findNewStates([],_,_,QD,QD). findNewStates([T|Ts],QD,StateMap,QD0,QD2) :- intersectAll(T,Trs), getStates(Trs,StateMap,S), % S is always nonempty since dynamic is present. checkNew(S,QD,QD0,QD1), findNewStates(Ts,QD,StateMap,QD1,QD2). getStates([],_,[]). getStates([T|Ts],StateMap,S) :- search_tree(StateMap,T,State), getStates(Ts,StateMap,S1), insertOrd(State,S1,S). %checkNew([],_,QD,QD) :- % !. checkNew(S,QD,QD0,QD0) :- member(S,QD), !. checkNew(S,_,QD0,QD1) :- setunion([S],QD0,QD1). makeSmallDeltaD([],_,_,_,D,D). makeSmallDeltaD([F/0|Sigma],FMap,ConstMap,StateMap,[(F->S)|D0],D1) :- search_tree(ConstMap,F,S), makeSmallDeltaD(Sigma,FMap,ConstMap,StateMap,D0,D1). makeSmallDeltaD([F/N|Sigma],FMap,ConstMap,StateMap,D0,D3) :- N>0, fmapArgs(0,N,F,FMap,FJs), makeDontCareTransitions(FJs,FJs1,F/N,StateMap,D0,D1), cartprod(FJs1,Tuples), makeCompactTransitions(Tuples,F,StateMap,D1,D2), makeSmallDeltaD(Sigma,FMap,ConstMap,StateMap,D2,D3). makeCompactTransitions([],_,_,D,D). makeCompactTransitions([T|Tuples],F,StateMap,[(L->R)|D0],D1) :- getQTTs(T,Qss,Ts), intersectAll(Ts,Trs), getStates(Trs,StateMap,S1), sort(S1,R), L =..[F|Qss], makeCompactTransitions(Tuples,F,StateMap,D0,D1). fmapArgs(N,N,_,_,[]). fmapArgs(J,N,F,FMap,[FJ1|FJs]) :- J < N, J1 is J+1, search_tree(FMap,key(F/N,J1),FJ1), fmapArgs(J1,N,F,FMap,FJs). getQTTs([],[],[]). getQTTs([Ts-Qs|JMap],[Qs|Qss],[Ts|TTs]) :- getQTTs(JMap,Qss,TTs). makeDontCareTransitions(FJs,FJs1,F,StateMap,D0,D1) :- intersectArgs(FJs,IJs), findFixedArgs(FJs,IJs,1,F,StateMap,FJs1,D0,D1). intersectArgs([],[]). intersectArgs([FJ|FJs],[Ts1|TTs]) :- getQTTs(FJ,_,Ts), intersectAll(Ts,Ts1), intersectArgs(FJs,TTs). findFixedArgs([],_,_,_,_,[],D,D). findFixedArgs([FJ|FJs],IJs,K,F,StateMap,[FJ1|FJs1],D0,D2) :- removeKth(K,IJs,IJs1), intersectAll(IJs1,Int), getStates(Int,StateMap,S1), sort(S1,S), genDontCareTrans(FJ,S,F,K,StateMap,FJ1,D0,D1), K1 is K+1, findFixedArgs(FJs,IJs,K1,F,StateMap,FJs1,D1,D2). genDontCareTrans([],_,_,_,_,[],D,D). genDontCareTrans([Ts-Qs|FJ],S,F/N,J,StateMap,FJ1,[(L->S2)|D0],D2) :- getStates(Ts,StateMap,S1), sort(S1,S2), subset(S2,S), % don't care condition !, functor(L,F,N), arg(J,L,Qs), dontcareVars(N,J,L), %genDontCare(Qs,F,J,S2,D0,D1), genDontCareTrans(FJ,S,F/N,J,StateMap,FJ1,D0,D2). genDontCareTrans([X|FJ],S,F,J,StateMap,[X|FJ1],D0,D1) :- genDontCareTrans(FJ,S,F,J,StateMap,FJ1,D0,D1). genDontCare([],_,_,_,D,D). genDontCare([Q|Qs],F/N,J,S,[(L->S)|D0],D1) :- functor(L,F,N), arg(J,L,Q), %prettyvars(L), % does not exist in SICStus - so use dontcareVars/3 dontcareVars(N,J,L), genDontCare(Qs,F/N,J,S,D0,D1). dontcareVars(0,_,_). dontcareVars(J,J,L) :- !, J1 is J-1, dontcareVars(J1,J,L). dontcareVars(K,J,L) :- K > 0, arg(K,L,'$VAR'('_')), % dont care variable K1 is K-1, dontcareVars(K1,J,L). removeKth(1,[_|Xs],Xs) :- !. removeKth(N,[X|Xs],[X|Xs1]) :- N1 is N-1, removeKth(N1,Xs,Xs1). writelist([]). writelist([X|Xs]) :- write(user_output,X), nl(user_output), writelist(Xs). %---- test generation for worst case automata (see TATA book) genTest(N) :- N > 0, N1 is N+1, makeStates(N1,Qs), makeTransitionsF(Qs,Fs,Gs), makeTransitionsG(Qs,Gs,[]), writeTransitions(N,Fs). makeStates(0,[q]). makeStates(J,[QJ|Qs]) :- J>0, name(q,Q), name(J,JN), append(Q,JN,QJN), name(QJ,QJN), J1 is J-1, makeStates(J1,Qs). makeTransitionsF([q1,q],[(f(q) -> q1),(f(q) -> q)|Fs],Fs). makeTransitionsF([Q1,Q|Qs],[(f(Q) -> Q1)|Fs0],Fs1) :- Q \== q, makeTransitionsF([Q|Qs],Fs0,Fs1). makeTransitionsG([q1,q],[(g(q) -> q),(a -> q)|Fs],Fs). makeTransitionsG([Q1,Q|Qs],[(g(Q) -> Q1)|Fs0],Fs1) :- Q \== q, makeTransitionsG([Q|Qs],Fs0,Fs1). %---- end of test generation renameStates([],_,S,S). renameStates([Q|Qs],K,S0,S2) :- nextState(K,Qk,K1), insert_tree(S0,Q,Qk,S1), renameStates(Qs,K1,S1,S2). nextState(K,Qk,K1) :- name(q,Pre), name(K,Suff), append(Pre,Suff,QKName), name(Qk,QKName), K1 is K+1. applyNames([],_,[]). /* applyNames([(L->R)|Ts],SNs,[(L1->R1)|Ts1]) :- dontCareTrans(L), !, L=..[F|Xs], renameEach(Xs,Ys,SNs), search_tree(SNs,R,R1), L1=..[F|Ys], applyNames(Ts,SNs,Ts1). */ applyNames([(L->R)|Ts],SNs,[(L1->R1)|Ts1]) :- L=..[F|Xs], renameEachSet(Xs,Ys,SNs), search_tree(SNs,R,R1), L1=..[F|Ys], applyNames(Ts,SNs,Ts1). renameEachSet([],[],_). renameEachSet(['$VAR'(N)|Xs],['$VAR'(N)|Ys],SNs) :- % don't care argument !, renameEachSet(Xs,Ys,SNs). renameEachSet([Xs|Zs],[Xs1|Zs1],SNs) :- renameEach(Xs,Xs1,SNs), renameEachSet(Zs,Zs1,SNs). renameEach([],[],_). renameEach(['$VAR'(N)|Xs],['$VAR'(N)|Ys],SNs) :- % don't care argument !, renameEach(Xs,Ys,SNs). renameEach([X|Xs],[Y|Ys],SNs) :- search_tree(SNs,X,Y), renameEach(Xs,Ys,SNs). writeTransitions(N,Fs) :- name(testNFTA,X), name(N,M), append(X,M,Y), name(F,Y), open(F,write,S), writeTrans(Fs,S), close(S). writeTrans([],_). writeTrans([T|Ts],S) :- write(S,T), write(S,'.'), nl(S), writeTrans(Ts,S). writeStateNames(S,StateNames) :- traverse_tree(StateNames,SNs), writeStateNames2(SNs,S). writeStateNames2([],_). writeStateNames2([rec(State,Q)|SNs],S) :- write(S,'% '), write(S,Q), write(S, ' = '), write(S,State), nl(S), writeStateNames2(SNs,S). writeConstrainedDFTA(_,[]). /* writeConstrainedDFTA(FO,[(L->R)|Xs]) :- dontCareTrans(L), !, flatten_denotes(denotes(L,R),Den), writeq(FO,Den), write(FO,'.'), nl(FO), writeConstrainedDFTA(FO,Xs). */ writeConstrainedDFTA(FO,[(L->R)|Xs]) :- functor(L,F,N), functor(L1,F,N), flatten_denotes(denotes(L1,R),Den), makeConstraints(1,N,L,L1,Cs), numbervars(L1,0,_), writeq(FO,Den), writeConstraints(Cs,FO), writeConstrainedDFTA(FO,Xs). dontCareTrans(L) :- L =.. [_|Xs], member('$VAR'('_'),Xs). flatten_denotes(denotes(T,V),Den) :- T =.. [F|Xs], name(denotes,Dn), name(F,Fn), append(Dn,[95|Fn],DFn), name(DF,DFn), append(Xs,[V],Ys), Den =.. [DF|Ys]. makeConstraints(J,N,_,_,[]) :- J > N. makeConstraints(J,N,L,L1,Cs) :- J =< N, arg(J,L,'$VAR'('_')), % don't care, so no need for constraint !, arg(J,L1,'$VAR'('_')), J1 is J+1, makeConstraints(J1,N,L,L1,Cs). makeConstraints(J,N,L,L1,Cs) :- J =< N, arg(J,L,[D]), % singleton set, so no need for constraint !, arg(J,L1,D), J1 is J+1, makeConstraints(J1,N,L,L1,Cs). makeConstraints(J,N,L,L1,[member(X,D)|Cs]) :- J =< N, arg(J,L,D), arg(J,L1,X), J1 is J+1, makeConstraints(J1,N,L,L1,Cs). writeStats(QDFinal,DFTA) :- nl(user_output), length(QDFinal,QK), write(user_output,'Number of states :'), write(QK), nl(user_output), %writelist(QDFinal), %nl(user_output), length(DFTA,K), write(user_output,'Number of transitions :'), write(K), nl(user_output), %writelist(DFTA), write(user_output,'-------------'), nl(user_output). writeConstraints([],F0) :- write(F0,'.'), nl(F0). writeConstraints([C|Cs],F0) :- write(F0,' :-'), nl(F0), write(F0,' '), write(F0,C), writeCs(Cs,F0). writeCs([],F0) :- write(F0,'.'), nl(F0). writeCs([C|Cs],F0) :- write(F0,','), nl(F0), write(F0,' '), write(F0,C), writeCs(Cs,F0).
leuschel/logen
old_logen/filter_prop/dfta1.pl
Perl
apache-2.0
14,528
package Sisimai::Reason; use feature ':5.10'; use strict; use warnings; use Module::Load ''; my $RetryReasons = __PACKAGE__->retry; sub retry { # Reason list better to retry detecting an error reason # @return [Array] Reason list return [ 'undefined', 'onhold', 'systemerror', 'securityerror', 'networkerror' ]; } sub index { # All the error reason list Sisimai support # @return [Array] Reason list return [ qw| Blocked ContentError ExceedLimit Expired Filtered HasMoved HostUnknown MailboxFull MailerError MesgTooBig NetworkError NotAccept OnHold Rejected NoRelaying SpamDetected SecurityError Suspend SystemError SystemFull TooManyConn UserUnknown SyntaxError | ]; } sub get { # Detect the bounce reason # @param [Sisimai::Data] argvs Parsed email object # @return [String, Undef] Bounce reason or Undef if the argument # is missing or invalid object # @see anotherone my $class = shift; my $argvs = shift // return undef; return undef unless ref $argvs eq 'Sisimai::Data'; unless( grep { $argvs->reason eq $_ } @$RetryReasons ) { # Return reason text already decided except reason match with the # regular expression of ->retry() method. return $argvs->reason if length $argvs->reason; } return 'delivered' if $argvs->deliverystatus =~ m/\A2[.]/; my $statuscode = $argvs->deliverystatus || ''; my $reasontext = ''; my $classorder = [ 'MailboxFull', 'MesgTooBig', 'ExceedLimit', 'Suspend', 'HasMoved', 'NoRelaying', 'UserUnknown', 'Filtered', 'Rejected', 'HostUnknown', 'SpamDetected', 'TooManyConn', 'Blocked', ]; if( $argvs->diagnostictype eq 'SMTP' || $argvs->diagnostictype eq '' ) { # Diagnostic-Code: SMTP; ... or empty value for my $e ( @$classorder ) { # Check the value of Diagnostic-Code: and the value of Status:, it is a # deliverystats, with true() method in each Sisimai::Reason::* class. my $p = 'Sisimai::Reason::'.$e; Module::Load::load( $p ); next unless $p->true( $argvs ); $reasontext = $p->text; last; } } if( not $reasontext || $reasontext eq 'undefined' ) { # Bounce reason is not detected yet. $reasontext = __PACKAGE__->anotherone( $argvs ); if( $reasontext eq 'undefined' || $reasontext eq '' ) { # Action: delayed => "expired" $reasontext ||= 'expired' if $argvs->action eq 'delayed'; $reasontext ||= 'onhold' if length $argvs->diagnosticcode; } $reasontext ||= 'undefined'; } return $reasontext; } sub anotherone { # Detect the other bounce reason, fall back method for get() # @param [Sisimai::Data] argvs Parsed email object # @return [String, Undef] Bounce reason or Undef if the argument # is missing or invalid object # @see get my $class = shift; my $argvs = shift // return undef; return undef unless ref $argvs eq 'Sisimai::Data'; return $argvs->reason if $argvs->reason; my $statuscode = $argvs->deliverystatus // ''; my $diagnostic = $argvs->diagnosticcode // ''; my $commandtxt = $argvs->smtpcommand // ''; my $reasontext = ''; my $classorder = [ 'MailboxFull', 'SpamDetected', 'SecurityError', 'SystemError', 'NetworkError', 'Suspend', 'Expired', 'ContentError', 'SystemFull', 'NotAccept', 'MailerError', ]; require Sisimai::SMTP::Status; $reasontext = Sisimai::SMTP::Status->name( $statuscode ); if( $reasontext eq '' || $reasontext eq 'userunknown' || grep { $reasontext eq $_ } @$RetryReasons ) { # Could not decide the reason by the value of Status: for my $e ( @$classorder ) { # Trying to match with other patterns in Sisimai::Reason::* classes my $p = 'Sisimai::Reason::'.$e; Module::Load::load( $p ); next unless $p->match( $diagnostic ); $reasontext = lc $e; last; } if( not $reasontext ) { # Check the value of Status: my $v = substr( $statuscode, 0, 3 ); if( $v eq '5.6' || $v eq '4.6' ) { # X.6.0 Other or undefined media error $reasontext = 'contenterror'; } elsif( $v eq '5.7' || $v eq '4.7' ) { # X.7.0 Other or undefined security status $reasontext = 'securityerror'; } elsif( $argvs->diagnostictype =~ qr/\AX-(?:UNIX|POSTFIX)\z/ ) { # Diagnostic-Code: X-UNIX; ... $reasontext = 'mailererror'; } else { # 50X Syntax Error? require Sisimai::Reason::SyntaxError; $reasontext = 'syntaxerror' if Sisimai::Reason::SyntaxError->true( $argvs ); } } if( not $reasontext ) { # Check the value of Action: field, first if( $argvs->action =~ /\A(?:delayed|expired)/ ) { # Action: delayed, expired $reasontext = 'expired'; } else { # Check the value of SMTP command if( $commandtxt =~ m/\A(?:EHLO|HELO)\z/ ) { # Rejected at connection or after EHLO|HELO $reasontext = 'blocked'; } } } } return $reasontext; } 1; __END__ =encoding utf-8 =head1 NAME Sisimai::Reason - Detect the bounce reason =head1 SYNOPSIS use Sisimai::Reason; =head1 DESCRIPTION Sisimai::Reason detects the bounce reason from the content of Sisimai::Data object as an argument of get() method. This class is called only Sisimai::Data class. =head1 CLASS METHODS =head2 C<B<get( I<Sisimai::Data Object> )>> C<get()> detects the bounce reason. =head2 C<B<anotherone( I<Sisimai::Data object> )>> C<anotherone()> is a method for detecting the bounce reason, it works as a fall back method of get() and called only from get() method. C<match()> detects the bounce reason from given text as a error message. =head1 LIST OF BOUNCE REASONS C<Sisimai::Reason->get()> detects the reason of bounce with parsing the bounced messages. The following reasons will be set in the value of C<reason> property of Sisimai::Data instance. =head2 C<blocked> This is the error that SMTP connection was rejected due to a client IP address or a hostname, or the parameter of C<HELO/EHLO> command. This reason has added in Sisimai 4.0.0 and does not exist in any version of bounceHammer. <kijitora@example.net>: Connected to 192.0.2.112 but my name was rejected. Remote host said: 501 5.0.0 Invalid domain name =head2 C<contenterror> This is the error that a destination mail server has rejected email due to header format of the email like the following. Sisimai will set C<contenterror> to the reason of email bounce if the value of Status: field in a bounce email is C<5.6.*>. =over =item - 8 bit data in message header =item - Too many “Received” headers =item - Invalid MIME headers =back ... while talking to g5.example.net.: >>> DATA <<< 550 5.6.9 improper use of 8-bit data in message header 554 5.0.0 Service unavailable =head2 C<delivered> This is NOT AN ERROR and means the message you sent has delivered to recipients successfully. Final-Recipient: rfc822; kijitora@neko.nyaan.jp Action: deliverable Status: 2.1.5 Remote-MTA: dns; home.neko.nyaan.jp Diagnostic-Code: SMTP; 250 2.1.5 OK =head2 C<exceedlimit> This is the error that a message was rejected due to an email exceeded the limit. The value of D.S.N. is C<5.2.3>. This reason is almost the same as C<MesgTooBig>, we think. ... while talking to mx.example.org.: >>> MAIL From:<kijitora@example.co.jp> SIZE=16600348 <<< 552 5.2.3 Message size exceeds fixed maximum message size (10485760) 554 5.0.0 Service unavailable =head2 C<expired> This is the error that delivery time has expired due to connection failure or network error and the message you sent has been in the queue for long time. =head2 C<feedback> The message you sent was forwarded to the sender as a complaint message from your mailbox provider. When Sismai has set C<feedback> to the reason, the value of C<feedbacktype> is also set like the following parsed data. =head2 C<filtered> This is the error that an email has been rejected by a header content after SMTP DATA command. In Japanese cellular phones, the error will incur that a sender's email address or a domain is rejected by recipient's email configuration. Sisimai will set C<filtered> to the reason of email bounce if the value of Status: field in a bounce email is C<5.2.0> or C<5.2.1>. This error reason is almost the same as UserUnknown. ... while talking to mfsmax.ntt.example.ne.jp.: >>> DATA <<< 550 Unknown user kijitora@ntt.example.ne.jp 554 5.0.0 Service unavailable =head2 C<hasmoved> This is the error that a user's mailbox has moved (and is not forwarded automatically). Sisimai will set C<hasmoved> to the reason of email bounce if the value of Status: field in a bounce email is C<5.1.6>. <kijitora@example.go.jp>: host mx1.example.go.jp[192.0.2.127] said: 550 5.1.6 recipient no longer on server: kijitora@example.go.jp (in reply to RCPT TO command) =head2 C<hostunknown> This is the error that a domain part (Right hand side of @ sign) of a recipient's email address does not exist. In many case, the domain part is misspelled, or the domain name has been expired. Sisimai will set C<hostunknown> to the reason of email bounce if the value of Status: field in a bounce mail is C<5.1.2>. Your message to the following recipients cannot be delivered: <kijitora@example.cat>: <<< No such domain. =head2 C<mailboxfull> This is the error that a recipient's mailbox is full. Sisimai will set C<mailboxfull> to the reason of email bounce if the value of Status: field in a bounce email is C<4.2.2> or C<5.2.2>. Action: failed Status: 5.2.2 Diagnostic-Code: smtp;550 5.2.2 <kijitora@example.jp>... Mailbox Full =head2 C<mailererror> This is the error that a mailer program has not exited successfully or exited unexpectedly on a destination mail server. X-Actual-Recipient: X-Unix; |/home/kijitora/mail/catch.php Diagnostic-Code: X-Unix; 255 =head2 C<mesgtoobig> This is the error that a sent email size is too big for a destination mail server. In many case, There are many attachment files with email, or the file size is too large. Sisimai will set C<mesgtoobig> to the reason of email bounce if the value of Status: field in a bounce email is C<5.3.4>. Action: failure Status: 553 Exceeded maximum inbound message size =head2 C<notaccept> This is the error that a destination mail server does ( or can ) not accept any email. In many case, the server is high load or under the maintenance. Sisimai will set C<notaccept> to the reason of email bounce if the value of Status: field in a bounce email is C<5.3.2> or the value of SMTP reply code is 556. =head2 C<onhold> Sisimai will set C<onhold> to the reason of email bounce if there is no (or less) detailed information about email bounce for judging the reason. =head2 C<rejected> This is the error that a connection to destination server was rejected by a sender's email address (envelope from). Sisimai set C<rejected> to the reason of email bounce if the value of Status: field in a bounce email is C<5.1.8> or the connection has been rejected due to the argument of SMTP MAIL command. <kijitora@example.org>: Connected to 192.0.2.225 but sender was rejected. Remote host said: 550 5.7.1 <root@nijo.example.jp>... Access denied =head2 C<norelaying> This is the error that SMTP connection rejected with error message C<Relaying Denied>. This reason does not exist in any version of bounceHammer. ... while talking to mailin-01.mx.example.com.: >>> RCPT To:<kijitora@example.org> <<< 554 5.7.1 <kijitora@example.org>: Relay access denied 554 5.0.0 Service unavailable =head2 C<securityerror> This is the error that a security violation was detected on a destination mail server. Depends on the security policy on the server, there is any virus in the email, a sender's email address is camouflaged address. Sisimai will set C<securityerror> to the reason of email bounce if the value of Status: field in a bounce email is C<5.7.*>. Status: 5.7.0 Remote-MTA: DNS; gmail-smtp-in.l.google.com Diagnostic-Code: SMTP; 552-5.7.0 Our system detected an illegal attachment on your message. Please =head2 C<suspend> This is the error that a recipient account is being suspended due to unpaid or other reasons. =head2 C<networkerror> This is the error that SMTP connection failed due to DNS look up failure or other network problems. This reason has added in Sisimai 4.1.12 and does not exist in any version of bounceHammer. A message is delayed for more than 10 minutes for the following list of recipients: kijitora@neko.example.jp: Network error on destination MXs =head2 C<spamdetected> This is the error that the message you sent was rejected by C<spam> filter which is running on the remote host. This reason has added in Sisimai 4.1.25 and does not exist in any version of bounceHammer. Action: failed Status: 5.7.1 Diagnostic-Code: smtp; 550 5.7.1 Message content rejected, UBE, id=00000-00-000 Last-Attempt-Date: Thu, 9 Apr 2008 23:34:45 +0900 (JST) =head2 C<systemerror> This is the error that an email has bounced due to system error on the remote host such as LDAP connection failure or other internal system error. <kijitora@example.net>: Unable to contact LDAP server. (#4.4.3)I'm not going to try again; this message has been in the queue too long. =head2 C<systemfull> This is the error that a destination mail server's disk (or spool) is full. Sisimai will set C<systemfull> to the reason of email bounce if the value of Status: field in a bounce email is C<4.3.1> or C<5.3.1>. =head2 C<toomanyconn> This is the error that SMTP connection was rejected temporarily due to too many concurrency connections to the remote server. This reason has added in Sisimai 4.1.26 and does not exist in any version of bounceHammer. <kijitora@example.ne.jp>: host mx02.example.ne.jp[192.0.1.20] said: 452 4.3.2 Connection rate limit exceeded. (in reply to MAIL FROM command) =head2 C<userunknown> This is the error that a local part (Left hand side of @ sign) of a recipient's email address does not exist. In many case, a user has changed internet service provider, or has quit company, or the local part is misspelled. Sisimai will set C<userunknown> to the reason of email bounce if the value of Status: field in a bounce email is C<5.1.1>, or connection was refused at SMTP RCPT command, or the contents of Diagnostic-Code: field represents that it is unknown user. <kijitora@example.co.jp>: host mx01.example.co.jp[192.0.2.8] said: 550 5.1.1 Address rejected kijitora@example.co.jp (in reply to RCPT TO command) =head2 C<undefined> Sisimai could not detect the error reason. In many case, error message is written in non-English or there are no enough error message in a bounce email to decide the reason. =head2 C<vacation> This is the reason that the recipient is out of office. The bounce message is generated and returned from auto responder program. This reason has added in Sisimai 4.1.28 and does not exist in any version of bounceHammer. =head1 SEE ALSO L<Sisimai::ARF> L<http://tools.ietf.org/html/rfc5965> L<http://libsisimai.org/reason/> =head1 AUTHOR azumakuniyuki =head1 COPYRIGHT Copyright (C) 2014-2016 azumakuniyuki, All rights reserved. =head1 LICENSE This software is distributed under The BSD 2-Clause License. =cut
jcbf/Sisimai
lib/Sisimai/Reason.pm
Perl
bsd-2-clause
16,075
package Tapper::Schema::TestrunDB::Result::Host; BEGIN { $Tapper::Schema::TestrunDB::Result::Host::AUTHORITY = 'cpan:TAPPER'; } { $Tapper::Schema::TestrunDB::Result::Host::VERSION = '4.1.3'; } use 5.010; use strict; use warnings; use parent 'DBIx::Class'; __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); __PACKAGE__->table("host"); __PACKAGE__->add_columns ( "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, }, "name", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, }, "comment", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, }, "free", { data_type => "TINYINT", default_value => "0", is_nullable => 1, }, "active", { data_type => "TINYINT", default_value => "0", is_nullable => 1, }, "is_deleted", { data_type => "TINYINT", default_value => "0", is_nullable => 1, }, # deleted hosts need to be kept in db to show old testruns correctly "created_at", { data_type => "TIMESTAMP", default_value => \'CURRENT_TIMESTAMP', is_nullable => 1, }, # ' "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 1, }, ); __PACKAGE__->set_primary_key("id"); (my $basepkg = __PACKAGE__) =~ s/::\w+$//; __PACKAGE__->add_unique_constraint( constraint_name => [ qw/name/ ] ); __PACKAGE__->has_many ( testrunschedulings => "${basepkg}::TestrunScheduling", { 'foreign.host_id' => 'self.id' }); __PACKAGE__->has_many ( queuehosts => "${basepkg}::QueueHost", { 'foreign.host_id' => 'self.id' }); __PACKAGE__->has_many ( denied_from_queue => "${basepkg}::DeniedHost", { 'foreign.host_id' => 'self.id' }); __PACKAGE__->has_many ( features => "${basepkg}::HostFeature", { 'foreign.host_id' => 'self.id' }); 1; __END__ =pod =encoding utf-8 =head1 NAME Tapper::Schema::TestrunDB::Result::Host =head1 SYNOPSIS Abstraction for the database table. use Tapper::Schema::TestrunDB; =head1 NAME Tapper::Schema::TestrunDB::Testrun - A ResultSet description =head1 AUTHOR AMD OSRC Tapper Team, C<< <tapper at amd64.org> >> =head1 BUGS None. =head1 COPYRIGHT & LICENSE Copyright 2008-2011 AMD OSRC Tapper Team, all rights reserved. This program is released under the following license: freebsd =head1 AUTHOR AMD OSRC Tapper Team <tapper@amd64.org> =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2013 by Advanced Micro Devices, Inc.. This is free software, licensed under: The (two-clause) FreeBSD License =cut
gitpan/Tapper-Schema
lib/Tapper/Schema/TestrunDB/Result/Host.pm
Perl
bsd-2-clause
2,984
=encoding utf8 =head1 NAME Crypt::PKCS11::CK_X9_42_MQV_DERIVE_PARAMS - Perl interface to PKCS #11 CK_X9_42_MQV_DERIVE_PARAMS structure =head1 SYNPOSIS use Crypt::PKCS11::CK_X9_42_MQV_DERIVE_PARAMS; my $obj = Crypt::PKCS11::CK_X9_42_MQV_DERIVE_PARAMS->new; $obj->set...; $obj->get...; =head1 DESCRIPTION This is the Perl interface for the C structure CK_X9_42_MQV_DERIVE_PARAMS in PKCS #11. See PKCS #11 documentation for more information about the structure and what it is used for. =head1 METHODS =over 4 =item $obj = Crypt::PKCS11::CK_X9_42_MQV_DERIVE_PARAMS->new Returns a new Crypt::PKCS11::CK_X9_42_MQV_DERIVE_PARAMS object. =item $rv = $obj->get_kdf($kdf) Retrieve the value B<kdf> from the structure into C<$kdf>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $kdf = $obj->kdf Returns the value B<kdf> from the structure or undef on error. =item $rv = $obj->set_kdf($kdf) Set the value B<kdf> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $rv = $obj->get_pOtherInfo($pOtherInfo) Retrieve the value B<pOtherInfo> from the structure into C<$pOtherInfo>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $pOtherInfo = $obj->pOtherInfo Returns the value B<pOtherInfo> from the structure or undef on error. =item $rv = $obj->set_pOtherInfo($pOtherInfo) Set the value B<pOtherInfo> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $rv = $obj->get_pPublicData($pPublicData) Retrieve the value B<pPublicData> from the structure into C<$pPublicData>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $pPublicData = $obj->pPublicData Returns the value B<pPublicData> from the structure or undef on error. =item $rv = $obj->set_pPublicData($pPublicData) Set the value B<pPublicData> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $rv = $obj->get_hPrivateData($hPrivateData) Retrieve the value B<hPrivateData> from the structure into C<$hPrivateData>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $hPrivateData = $obj->hPrivateData Returns the value B<hPrivateData> from the structure or undef on error. =item $rv = $obj->set_hPrivateData($hPrivateData) Set the value B<hPrivateData> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $rv = $obj->get_pPublicData2($pPublicData2) Retrieve the value B<pPublicData2> from the structure into C<$pPublicData2>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $pPublicData2 = $obj->pPublicData2 Returns the value B<pPublicData2> from the structure or undef on error. =item $rv = $obj->set_pPublicData2($pPublicData2) Set the value B<pPublicData2> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $rv = $obj->get_publicKey($publicKey) Retrieve the value B<publicKey> from the structure into C<$publicKey>. Returns C<CKR_OK> on success otherwise a CKR describing the error. =item $publicKey = $obj->publicKey Returns the value B<publicKey> from the structure or undef on error. =item $rv = $obj->set_publicKey($publicKey) Set the value B<publicKey> in the structure. Returns C<CKR_OK> on success otherwise a CKR describing the error. =back =head1 PRIVATE METHODS These are the private methods used within the module and should not be used elsewhere. =over 4 =item $bytes = $obj->toBytes Return the structure represented as bytes or undef on error. =item $rv = $obj->fromBytes($bytes) Sets the structure from a representation in bytes. Returns C<CKR_OK> on success otherwise a CKR describing the error. =back =head1 NOTE Derived from the RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) =head1 AUTHOR Jerry Lundström <lundstrom.jerry@gmail.com> =head1 REPORTING BUGS Report bugs at https://github.com/mkinstab/p5-Crypt-PKCS11/issues . =head1 LICENSE Copyright (c) 2015-2016 Jerry Lundström <lundstrom.jerry@gmail.com> Copyright (c) 2016 make install AB Copyright (c) 2015 .SE (The Internet Infrastructure Foundation) 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 HOLDER 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.
dotse/p5-Crypt-PKCS11
lib/Crypt/PKCS11/CK_X9_42_MQV_DERIVE_PARAMS.pod
Perl
bsd-2-clause
5,498
#lang pollen ◊headline{pollen-count} ◊define-meta[publish-date]{12/08/2015} ◊define-meta[categories]{pollen, racket, programming} ◊define-meta[toc]{true} ◊define-meta[comments]{true} ◊section{Introducing pollen-count} ◊link["https://github.com/malcolmstill/pollen-count"]{◊code{pollen-count}} is a ◊link["http://racket-lang.org"]{Racket} library for use with ◊link["http://pollenpub.com/"]{Pollen}. It allows for numbering of sections, figures, tables, etc. and cross references to these numbers. The source code is ◊link["https://github.com/malcolmstill/pollen-count"]{available on Github}. ◊section[#:label "sec:enum"]{Enumerations} ◊link["https://github.com/malcolmstill/pollen-count"]{◊code{pollen-count}} is designed to enumerate sections, figures, tables, etc. To do this the required number of counters is defined along with a hashmap of tags and counters. Any time a tag in the hashmap is encountered its associated counter will be incremented and the new value stored with that instance of the tag. Counters can specify a parent counter. A ◊code{print} function associated with the counter will concatenate its number with its parent's number with a specified separator. The function to make a counter is ◊code{make-counter}, its argument list is defined as follows: ◊highlight['racket]{ (make-counter initial render [parent #f] [separator "."]) } ◊code{initial} is a ◊code{number} (this will likely always be ◊code{0}), ◊code{render} is a function taking a ◊code{number} and returning a ◊code{string} (used when the count is printed: typically you'll use ◊code{number->string} but you might want to use ◊code{Alpha} to replace, for example, the number ◊code{1} with "A"), ◊code{parent} is another ◊code{counter}, and ◊code{separator} is an optional ◊code{string} to use between this counter's count and its parent's when printed. Example code for making counters: ◊highlight['racket]{ #| Define counters and map of tags to counters |# (define section-counter (make-counter 0 number->string)) (define subsection-counter (make-counter 0 number->string section-counter)) (define subsubsection-counter (make-counter 0 number->string subsection-counter)) (define figure-counter (make-counter 0 number->string)) (define footnote-counter (make-counter 0 number->string)) (define tag-counters (hash 'section section-counter 'subsection subsection-counter 'subsubsection subsubsection-counter 'figure figure-counter 'footnote footnote-counter)) } ◊section{References} The other function of ◊link["https://github.com/malcolmstill/pollen-count"]{◊code{pollen-count}} is to references. The library will recognise two tags ◊code{ref} and ◊code{hyperref}, examples are shown below: ◊highlight['racket]{ See Figure ◊"◊"ref{fig:tree}. See also ◊"◊"hyperref["Figure "]{fig:tree2}. } The difference between the two is that ◊code{ref} is simply replaced by the number associated with ◊code{fig:tree} whereas ◊code{hyperref} generates a hyperlink with some additional specified text (so that the word "Figure" is also included as part of the link). You are now asking where ◊code{fig:tree} and ◊code{fig:tree2} are specified. The other half of references are labels. The library recognise the tag ◊code{label}. For example, in this blog I specify sections with the ◊code{section} tag. If I want to then ◊code{ref} this section I add a ◊code{label} within this section: ◊highlight['racket]{ ◊"◊"section{Introduction ◊"◊"label{sec:intro}} } Somewhere else in the document I can then reference the introduction: ◊highlight['racket]{ As stated in ◊"◊"hyperref["Section "]{sec:intro}... } ◊section{Generation} The enumerations and references will typically be applied in the ◊code{root} function specified in ◊code{directory-require.rkt}. The function ◊code{numebr-and-xref} is provided by ◊link["https://github.com/malcolmstill/pollen-count"]{◊code{pollen-count}}. It takes as arguments the hashmap of tags to counters as explained in ◊hyperref["Section "]{sec:enum} and the document ◊code{txexpr} and returns another ◊code{txexpr} which includes the substituted references. For example: ◊highlight['racket]{ (define refd (number-and-xref tag-counters xs-nohead)) } At that point ◊code{refd} has not replaced the text of the ◊code{section} tag with the numbered equivalent. The number is stored as an attribute called ◊code{data-number}. In my blog code I then replace the ◊code{section} tag with an appropriate ◊code{h} tag and modify the text to include the generated number. The following function takes care of this but it is not part of ◊link["https://github.com/malcolmstill/pollen-count"]{◊code{pollen-count}}. ◊highlight['racket]{ #| Function to replace section tags after numbering |# (define (make-section tx heading) (make-txexpr heading (if (attrs-have-key? tx 'id) (get-attrs tx) (merge-attrs (get-attrs tx) 'id (gensym))) (if (attrs-have-key? tx 'data-number) (append (list (attr-ref tx 'data-number) ". ") (get-elements tx)) (get-elements tx)))) } ◊section{Installation} The library can be installed with the following command: ◊highlight['bash]{ raco pkg install git://github.com/malcolmstill/pollen-count } I have also uploaded the library to ◊link["http://pkgs.racket-lang.org/"]{http://pkgs.racket-lang.org/} so it should be available at some point in the package catalog (though this is the first time I'm trying to do this so I could well have made a mistake). ◊section{To do} There are a number of improvements for the library that I have in mind and I need to put together some scribble documentation. If you have any issues or suggestions please use the issues page on Github. ◊section{Further reading} The source code for this blog is ◊link["https://github.com/malcolmstill/mstill.io"]{available on Github}. This may be useful for understanding the usage outlined above.
malcolmstill/mstill.io
blog/pollen-count.html.pm
Perl
bsd-3-clause
6,040
# Copyright (c) 2003 # The funknet.org Group. # # 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. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by The funknet.org # Group and its contributors. # 4. Neither the name of the Group 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 GROUP 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 GROUP 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 Funknet::Config::CLI; use strict; use Funknet::Config::CLI::Secrets; use Funknet::Config::CLI::Zebra; use Funknet::Config::CLI::IOS; use Funknet::ConfigFile::Tools; =head1 NAME Funknet::Config::CLI =head1 SYNOPSIS my $cli = Funknet::Config::CLI->new(); @local_tun = $cli->get_interfaces; my $cli = Funknet::Config::CLI->new(); my $bgp = $cli->get_bgp; =head1 DESCRIPTION This module is the base class for the router-specific methods for retrieving data from the Zebra and IOS command-line interfaces. The constructor returns an object containing all the information required to connect to the router (address/username/passwords), blessed into the appropriate class depending on the local_router config param. =head1 METHODS get_bgp and get_access_list are implemented in both IOS.pm and Zebra.pm, but accessed through an object returned from the constructor of this module. =head2 get_bgp This method retrieves the BGP configuration from the running router. The data structure is returned as a hashref. The top level data structure is Funknet::Config::BGP, which contains the routes advertised (network statements) for this BGP router. (todo: add other BGP configuration statements to this object - ebgp multihop etc.) The BGP object contains a list of Neighbor objects, which represent the currently configured sessions. =head2 get_access_list This method retrieves an access list from the router. It translates the 'sho ip prefix-list $name' output into the config commands form generated by RtConfig. (todo: this.) =head2 get_as Given an IP address, this method attempts to find the AS from the local systems BGP table. Returns undef if it's not found. Untested on IOS. =head2 check_login XXX stubbed out for now A sort of internal method, but called from the constructor of CLI.pm. Checks that the relevant authentication information is available, including enable. (todo: argument to make enable password optional?) =head2 login / logout Pair of subs to manage connections to the router CLI. login creates the Net::Telnet object and stashes it. You should access this through $obj->{t}. logout calls close on that, and also undefs it. login won't create a new N::T object unless $self->{t} is undef, so do call logout... FIXME: if login decides to reuse a N::T object have it do a 'ping' of some sort to make sure it's still awake? =cut sub new { my ($class, %args) = @_; my $self = bless {}, $class; my $l = Funknet::ConfigFile::Tools->local; $self->{_username} = Funknet::Config::CLI::Secrets->username( $l->{host} ); $self->{_password} = Funknet::Config::CLI::Secrets->password( $l->{host} ); $self->{_enable} = Funknet::Config::CLI::Secrets->enable( $l->{host} ); # see if the caller wants a persistent connection to zebra # (this is used by Funknet::Tools::Traceroute and probably # should be elsewhere). if ($args{Persist}) { $self->{_persist} = 1; } # see if the caller requested Debug. if so, the trace from Net::Telnet will # show up on STDOUT. if ($args{Debug}) { $self->{_debug} = 1; } # rebless into relevant class # if we're Zebra, and host is localhost, then use vtysh (AF_UNIX) # else use Zebra (AF_INET). $l->{router} eq 'ios' and bless $self, 'Funknet::Config::CLI::IOS'; if (defined $l->{bgpd_vty} && $l->{host} eq "127.0.0.1") { $l->{router} eq 'zebra' and bless $self, 'Funknet::Config::CLI::Zebra::Vtysh'; } else { $l->{router} eq 'zebra' and bless $self, 'Funknet::Config::CLI::Zebra::Telnet'; } # check we have the correct details or don't return the object. $self->check_login or return undef; return $self; } =head2 exec_cmd Runs the specified command in user mode, and returns the text (supports looking-glass functions). Doesn't do any checking of the command itself, caller must do that. =cut sub exec_cmd { my ($self, $cmd) = @_; $self->login; my @output = $self->{t}->cmd($cmd); $self->logout; return wantarray ? @output : join '', @output; } 1;
chrisa/funknet-tools
lib/Funknet/Config/CLI.pm
Perl
bsd-3-clause
5,823
package App::Netdisco::Util::Permission; use Dancer qw/:syntax :script/; use Dancer::Plugin::DBIC 'schema'; use Scalar::Util 'blessed'; use NetAddr::IP::Lite ':lower'; use base 'Exporter'; our @EXPORT = (); our @EXPORT_OK = qw/check_acl/; our %EXPORT_TAGS = (all => \@EXPORT_OK); =head1 NAME App::Netdisco::Util::Permission =head1 DESCRIPTION Helper subroutines to support parts of the Netdisco application. There are no default exports, however the C<:all> tag will export all subroutines. =head1 EXPORT_OK =head2 check_acl( $ip, \@config ) Given an IP address, returns true if any of the items in C<< \@config >> matches that address, otherwise returns false. Normally you use C<check_no> and C<check_only>, passing the name of the configuration setting to load. This helper instead requires not the name of the setting, but its value. =cut sub check_acl { my ($thing, $config) = @_; my $real_ip = (blessed $thing ? $thing->ip : $thing); my $addr = NetAddr::IP::Lite->new($real_ip); foreach my $item (@$config) { if (ref qr// eq ref $item) { my $name = hostname_from_ip($addr->addr) or next; return 1 if $name =~ $item; next; } if ($item =~ m/^([^:]+)\s*:\s*([^:]+)$/) { my $prop = $1; my $match = $2; # if not in storage, we can't do much with device properties next unless blessed $thing and $thing->in_storage; # lazy version of vendor: and model: if ($thing->can($prop) and defined $thing->$prop and $thing->$prop =~ m/^$match$/) { return 1; } next; } if ($item =~ m/([a-f0-9]+)-([a-f0-9]+)$/i) { my $first = $1; my $last = $2; if ($item =~ m/:/) { next unless $addr->bits == 128; $first = hex $first; $last = hex $last; (my $header = $item) =~ s/:[^:]+$/:/; foreach my $part ($first .. $last) { my $ip = NetAddr::IP::Lite->new($header . sprintf('%x',$part) . '/128') or next; return 1 if $ip == $addr; } } else { next unless $addr->bits == 32; (my $header = $item) =~ s/\.[^.]+$/./; foreach my $part ($first .. $last) { my $ip = NetAddr::IP::Lite->new($header . $part . '/32') or next; return 1 if $ip == $addr; } } next; } my $ip = NetAddr::IP::Lite->new($item) or next; next unless $ip->bits == $addr->bits; return 1 if $ip->contains($addr); } return 0; } 1;
gitpan/App-Netdisco
lib/App/Netdisco/Util/Permission.pm
Perl
bsd-3-clause
2,734
#ExStart:1 use lib 'lib'; use strict; use warnings; use utf8; use File::Slurp; # From CPAN use JSON; use AsposeStorageCloud::StorageApi; use AsposeStorageCloud::ApiClient; use AsposeStorageCloud::Configuration; use AsposeCellsCloud::CellsApi; use AsposeCellsCloud::ApiClient; use AsposeCellsCloud::Configuration; my $configFile = '../Config/config.json'; my $configPropsText = read_file($configFile); my $configProps = decode_json($configPropsText); my $data_path = '../../../Data/'; my $out_path = $configProps->{'out_folder'}; $AsposeCellsCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeCellsCloud::Configuration::api_key = $configProps->{'api_key'}; $AsposeCellsCloud::Configuration::debug = 1; $AsposeStorageCloud::Configuration::app_sid = $configProps->{'app_sid'}; $AsposeStorageCloud::Configuration::api_key = $configProps->{'api_key'}; # Instantiate Aspose.Storage and Aspose.Cells API SDK my $storageApi = AsposeStorageCloud::StorageApi->new(); my $cellsApi = AsposeCellsCloud::CellsApi->new(); # Set input file name my $name = 'Sample_Test_Book.xls'; my $sheetName = 'Sheet1'; my $rowIndex = 0; # Upload file to aspose cloud storage my $response = $storageApi->PutCreate(Path => $name, file => $data_path.$name); # Invoke Aspose.Cells Cloud SDK API to add an empty row in a worksheet $response = $cellsApi->PutInsertWorksheetRow(name=> $name, sheetName=>$sheetName, rowIndex=>$rowIndex); if($response->{'Status'} eq 'OK'){ # Download updated Workbook from storage server my $output_file = $out_path. $name; $response = $storageApi->GetDownload(Path => $name);; write_file($output_file, { binmode => ":raw" }, $response->{'Content'}); } #ExEnd:1
asposecells/Aspose_Cells_Cloud
Examples/Perl/Rows/AddEmptyRowInWorksheet.pl
Perl
mit
1,716
#!/usr/bin/perl use strict; use warnings; use feature 'switch'; use Getopt::Long; my $compress = 1; my ( @flags, %hashFlags, $outFile ); GetOptions( 'compress!' => \$compress, 'flag=s' => \@flags, 'out=s' => \$outFile, ); @flags = split ( ',', join(',', @flags) ); @hashFlags{@flags} = (); die 'Please specify input file' unless $ARGV[0]; my $inFile = $ARGV[0]; my ( $file, $content, @condStack ); open ( $file, $inFile ) or die "Could not open $inFile for read: $!"; sub findFlag ($) { return 1 unless %hashFlags; my @flags = split ( ',', $_[0] ); foreach (@flags) { return 0 if ( ( substr($_, 0, 1) ne '!' && exists $hashFlags{$_} ) || ( substr($_, 0, 1) eq '!' && !exists $hashFlags{substr($_, 1)} ) ); } return 1; } while ( <$file> ) { if ( m{^\s*//\s*#if\s+(.*)$} ) { push @condStack, findFlag($1); } elsif ( m{^\s*//\s*#elseif\s+(.*)$} ) { given ($condStack[-1]) { $condStack[-1] = 2 when 0; $condStack[-1] = findFlag($1) when 1; die "ERROR: unpaired #elseif in line $." when undef; } } elsif ( m{^\s*//\s*#else\s*$} ) { given ($condStack[-1]) { $condStack[-1] = 2 when 0; $condStack[-1] = 0 when 1; die "ERROR: unpaired #else in line $." when undef; } } elsif ( m{^\s*//\s*#endif\s*$} ) { defined pop @condStack or die "ERROR: unpaired #endif in line $."; } elsif ( !grep { $_ } @condStack ) { s{ \${(\w+)} }{ no strict 'refs'; exists $ENV{$1} ? $ENV{$1} : "\${$1}"; }egx; $content .= $_; } } close $file; die "ERROR: unpaired #if" if @condStack; if ( $compress ) { if ( substr($inFile, -4) eq '.css' ) { for ( $content ) { s/\n//g; s/\s*([{},+~>:;])\s*/$1/g; s/;}/}/g; } } elsif ( substr($inFile, -5) eq '.html' ) { for ( $content ) { s/\n//g; } } elsif ( substr($inFile, -3) eq '.js' ) { unless ( -e 'compiler.jar' ) { system('wget -q http://closure-compiler.googlecode.com/files/compiler-latest.tar.gz') == 0 or die 'Failed to download Google Closure Compiler'; system 'tar -xzf compiler-latest.tar.gz compiler.jar'; unlink 'compiler-latest.tar.gz'; } open ( $file, '>', 'body.js' ) and print $file $content and close $file; $content = `java -jar compiler.jar --charset=UTF-8 --compilation_level SIMPLE_OPTIMIZATIONS --js=body.js`; unlink 'body.js'; die 'Error during compression' unless $content; } } open ( $file, '>'.($outFile || '-') ) or die "Could not write to output file $outFile: $!"; print $file $content and close $file;
wozai/weibo-content-filter
compile.pl
Perl
mit
2,464
# OpenXPKI::Server::Workflow::Validator::Bulk # Written by Alexander Klink for the OpenXPKI project 2007 # Copyright (c) 2007 by The OpenXPKI Project package OpenXPKI::Server::Workflow::Validator::Bulk; use strict; use warnings; use base qw( Workflow::Validator ); use OpenXPKI::Server::Context qw( CTX ); use OpenXPKI::Debug; use OpenXPKI::Exception; use DateTime; sub validate { my ( $self, $wf, $bulk ) = @_; if (! defined $bulk) { return 1; } if ($bulk != 1) { OpenXPKI::Exception->throw( message => 'I18N_OPENXPKI_SERVER_WORKFLOW_VALIDATOR_BULK_NOT_UNDEF_OR_ONE', ); } return 1; } 1; __END__ =head1 NAME OpenXPKI::Server::Workflow::Validator::Bulk =head1 SYNOPSIS <action name="create_csr"> <validator name="Bulk" class="OpenXPKI::Server::Workflow::Validator::Bulk"> </validator> </action> =head1 DESCRIPTION This validator checks whether the bulk parameter is either not present or 1.
mrscotty/openxpki
core/server/OpenXPKI/Server/Workflow/Validator/Bulk.pm
Perl
apache-2.0
979
package VMOMI::PerformanceManager; use parent 'VMOMI::ManagedObject'; use strict; use warnings; our @class_ancestors = ( 'ManagedObject', ); our @class_members = ( ['description', 'PerformanceDescription', 0, 1], ['historicalInterval', 'PerfInterval', 1, 0], ['perfCounter', 'PerfCounterInfo', 1, 0], ); sub get_class_ancestors { return @class_ancestors; } sub get_class_members { my $class = shift; my @super_members = $class->SUPER::get_class_members(); return (@super_members, @class_members); } 1;
stumpr/p5-vmomi
lib/VMOMI/PerformanceManager.pm
Perl
apache-2.0
539
=pod =head1 NAME EVP_SIGNATURE-DSA - The B<EVP_PKEY> DSA signature implementation =head1 DESCRIPTION Support for computing DSA signatures. See L<EVP_PKEY-DSA(7)> for information related to DSA keys. =head2 Signature Parameters The following signature parameters can be set using EVP_PKEY_CTX_set_params(). This may be called after EVP_PKEY_sign_init() or EVP_PKEY_verify_init(), and before calling EVP_PKEY_sign() or EVP_PKEY_verify(). =over 4 =item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string> =item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string> The settable parameters are described in L<provider-signature(7)>. =back The following signature parameters can be retrieved using EVP_PKEY_CTX_get_params(). =over 4 =item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string> =item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string> The gettable parameters are described in L<provider-signature(7)>. =back =head1 SEE ALSO L<EVP_PKEY_CTX_set_params(3)>, L<EVP_PKEY_sign(3)>, L<EVP_PKEY_verify(3)>, L<provider-signature(7)>, =head1 COPYRIGHT Copyright 2020 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 L<https://www.openssl.org/source/license.html>. =cut
jens-maus/amissl
openssl/doc/man7/EVP_SIGNATURE-DSA.pod
Perl
bsd-3-clause
1,425
#!/bin/perl -w # Creates a zip file, adding the given directories and files. # Usage: # perl zip.pl zipfile.zip file [...] use strict; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); die "usage: $0 zipfile.zip file [...]\n" if (scalar(@ARGV) < 2); my $zipName = shift(@ARGV); my $zip = Archive::Zip->new(); foreach my $memberName (map { glob } @ARGV) { if (-d $memberName) { warn "Can't add tree $memberName\n" if $zip->addTree($memberName, $memberName) != AZ_OK; } else { $zip->addFile($memberName) or warn "Can't add file $memberName\n"; } } my $status = $zip->writeToFileNamed($zipName); exit $status;
GdZ/scriptfile
tool-kit/perl-modules/Archive/examples/zip.pl
Perl
mit
662
#!/usr/bin/perl ################################################################################## # # USAGE: perl get_seq_by_id.pl [header or headers separated by spaces] # # Created by jennifer shelton # Script creates new fasta files including all sequences corresponding to the headers given as input # perl get_seq_by_id.pl tcas_3770 ################################################################################## use strict; use warnings; use Bio::Seq; use Bio::SeqIO; use Bio::DB::Fasta; #makes a searchable db from my fasta file # use List::Util qw(max); # use List::Util qw(sum); ############################################################################### ############## notes ################## ############################################################################### my $infile_fasta = "sample.fasta"; # give the name of your file my $out = "seq_got_by_id.fasta"; my $db = Bio::DB::Fasta->new("$infile_fasta"); my $seq_out = Bio::SeqIO->new('-file' => ">$out",'-format' => 'fasta'); #Create new fasta outfile object. for my $header (@ARGV) { my $seq_obj = $db->get_Seq_by_id($header); #get fasta file $seq_out->write_seq($seq_obj); }
idworkin/read-cleaning-format-conversion
KSU_bioinfo_lab/get_seq_by_id.pl
Perl
mit
1,210
#------------------------------------------------------------------------------ # File: SonyIDC.pm # # Description: Read/write Sony IDC information # # Revisions: 2010/01/05 - P. Harvey Created #------------------------------------------------------------------------------ package Image::ExifTool::SonyIDC; use strict; use vars qw($VERSION); use Image::ExifTool qw(:DataAccess :Utils); use Image::ExifTool::Exif; $VERSION = '1.08'; # Sony IDC tags (ref PH) %Image::ExifTool::SonyIDC::Main = ( WRITE_PROC => \&Image::ExifTool::Exif::WriteExif, CHECK_PROC => \&Image::ExifTool::Exif::CheckExif, GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, NOTES => 'Tags written by the Sony Image Data Converter utility in ARW images.', SET_GROUP1 => 1, 0x201 => { Name => 'IDCPreviewStart', IsOffset => 1, OffsetPair => 0x202, DataTag => 'IDCPreview', Writable => 'int32u', Protected => 2, }, 0x202 => { Name => 'IDCPreviewLength', OffsetPair => 0x201, DataTag => 'IDCPreview', Writable => 'int32u', Protected => 2, }, 0x8000 => { Name => 'IDCCreativeStyle', Writable => 'int32u', PrintConvColumns => 2, PrintConv => { 1 => 'Camera Setting', 2 => 'Standard', 3 => 'Real', 4 => 'Vivid', 5 => 'Adobe RGB', 6 => 'A100 Standard', # shows up as '-' in IDC menu 7 => 'Neutral', 8 => 'Portrait', 9 => 'Landscape', 10 => 'Clear', 11 => 'Deep', 12 => 'Light', 13 => 'Sunset', 14 => 'Night View', 15 => 'Autumn Leaves', 16 => 'B&W', 17 => 'Sepia', }, }, 0x8001 => { Name => 'CreativeStyleWasChanged', Writable => 'int32u', Notes => 'set if the creative style was ever changed', # (even if it was changed back again later) PrintConv => { 0 => 'No', 1 => 'Yes' }, }, 0x8002 => { Name => 'PresetWhiteBalance', Writable => 'int32u', PrintConv => { 1 => 'Camera Setting', 2 => 'Color Temperature', 3 => 'Specify Gray Point', 4 => 'Daylight', 5 => 'Cloudy', 6 => 'Shade', 7 => 'Cool White Fluorescent', 8 => 'Day Light Fluorescent', 9 => 'Day White Fluorescent', 10 => 'Warm White Fluorescent', 11 => 'Tungsten', 12 => 'Flash', 13 => 'Auto', }, }, 0x8013 => { Name => 'ColorTemperatureAdj', Writable => 'int16u' }, 0x8014 => { Name => 'PresetWhiteBalanceAdj',Writable => 'int32s' }, 0x8015 => { Name => 'ColorCorrection', Writable => 'int32s' }, 0x8016 => { Name => 'SaturationAdj', Writable => 'int32s' }, 0x8017 => { Name => 'ContrastAdj', Writable => 'int32s' }, 0x8018 => { Name => 'BrightnessAdj', Writable => 'int32s', PrintConv => 'sprintf("%.2f", $val/300)', #JR PrintConvInv => '$val * 300', }, 0x8019 => { Name => 'HueAdj', Writable => 'int32s' }, 0x801a => { Name => 'SharpnessAdj', Writable => 'int32s' }, 0x801b => { Name => 'SharpnessOvershoot', Writable => 'int32s' }, 0x801c => { Name => 'SharpnessUndershoot', Writable => 'int32s' }, 0x801d => { Name => 'SharpnessThreshold', Writable => 'int32s' }, 0x801e => { Name => 'NoiseReductionMode', Writable => 'int16u', PrintConv => { 0 => 'Off', 1 => 'On', }, }, 0x8021 => { Name => 'GrayPoint', Writable => 'int16u', Count => 4, }, 0x8022 => { Name => 'D-RangeOptimizerMode', Writable => 'int16u', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual', }, }, 0x8023 => { Name => 'D-RangeOptimizerValue', Writable => 'int32s' }, 0x8024 => { Name => 'D-RangeOptimizerHighlight',Writable => 'int32s' }, 0x8026 => { Name => 'HighlightColorDistortReduct', Writable => 'int16u', PrintConv => { 0 => 'Standard', 1 => 'Advanced', }, }, 0x8027 => { Name => 'NoiseReductionValue', Writable => 'int32s', ValueConv => '($val + 100) / 2', ValueConvInv => '$val * 2 - 100', }, 0x8028 => { Name => 'EdgeNoiseReduction', Writable => 'int32s', ValueConv => '($val + 100) / 2', ValueConvInv => '$val * 2 - 100', }, 0x8029 => { Name => 'ColorNoiseReduction', Writable => 'int32s', ValueConv => '($val + 100) / 2', ValueConvInv => '$val * 2 - 100', }, 0x802d => { Name => 'D-RangeOptimizerShadow', Writable => 'int32s' }, 0x8030 => { Name => 'PeripheralIllumCentralRadius', Writable => 'int32s' }, 0x8031 => { Name => 'PeripheralIllumCentralValue', Writable => 'int32s' }, 0x8032 => { Name => 'PeripheralIllumPeriphValue', Writable => 'int32s' }, 0x8040 => { #JR Name => 'DistortionCompensation', Writable => 'int32s', PrintConv => { -1 => 'n/a', # (fixed by lens) 1 => 'On', 2 => 'Off', }, }, 0x9000 => { Name => 'ToneCurveBrightnessX', Writable => 'int16u', Count => -1, }, 0x9001 => { Name => 'ToneCurveRedX', Writable => 'int16u', Count => -1, }, 0x9002 => { Name => 'ToneCurveGreenX', Writable => 'int16u', Count => -1, }, 0x9003 => { Name => 'ToneCurveBlueX', Writable => 'int16u', Count => -1, }, 0x9004 => { Name => 'ToneCurveBrightnessY', Writable => 'int16u', Count => -1, }, 0x9005 => { Name => 'ToneCurveRedY', Writable => 'int16u', Count => -1, }, 0x9006 => { Name => 'ToneCurveGreenY', Writable => 'int16u', Count => -1, }, 0x9007 => { Name => 'ToneCurveBlueY', Writable => 'int16u', Count => -1, }, 0x900d => { #JR Name => 'ChromaticAberrationCorrection', # "Magnification Chromatic Aberration" Writable => 'int32s', PrintConv => { 1 => 'On', 2 => 'Off' }, }, 0x900e => { #JR Name => 'InclinationCorrection', Writable => 'int32u', PrintConv => { 0 => 'Off', 1 => 'On' }, }, 0x900f => { #JR Name => 'InclinationAngle', Writable => 'int32s', PrintConv => 'sprintf("%.1f deg", $val/1000)', PrintConvInv => 'ToFloat($val) * 1000', }, 0x9010 => { #JR Name => 'Cropping', Writable => 'int32u', PrintConv => { 0 => 'Off', 1 => 'On' }, }, 0x9011 => { #JR Name => 'CropArea', Writable => 'int32u', Count => 4, }, 0x9012 => { #JR Name => 'PreviewImageSize', Writable => 'int32u', Count => 2, }, 0x9013 => { #JR (ARQ images) Name => 'PxShiftPeriphEdgeNR', Writable => 'int32s', PrintConv => { 0 => 'Off', 1 => 'On' }, }, 0x9014 => { #JR (ARQ images) Name => 'PxShiftPeriphEdgeNRValue', Writable => 'int32s', PrintConv => 'sprintf("%.1f", $val/10)', PrintConvInv => '$val * 10', }, 0x9017 => { Name => 'WhitesAdj', Writable => 'int32s' }, #JR 0x9018 => { Name => 'BlacksAdj', Writable => 'int32s' }, #JR 0x9019 => { Name => 'HighlightsAdj', Writable => 'int32s' }, #JR 0x901a => { Name => 'ShadowsAdj', Writable => 'int32s' }, #JR 0xd000 => { Name => 'CurrentVersion', Writable => 'int32u' }, 0xd001 => { Name => 'VersionIFD', Groups => { 1 => 'Version0' }, Flags => 'SubIFD', Notes => 'there is one VersionIFD for each entry in the "Version Stack"', SubDirectory => { DirName => 'Version0', TagTable => 'Image::ExifTool::SonyIDC::Main', Start => '$val', Base => '$start', MaxSubdirs => 20, # (IDC v3.0 writes max. 10) RelativeBase => 1, # needed to write SubIFD with relative offsets }, }, 0xd100 => { Name => 'VersionCreateDate', Writable => 'string', Groups => { 2 => 'Time' }, Notes => 'date/time when this entry was created in the "Version Stack"', Shift => 'Time', PrintConv => '$self->ConvertDateTime($val)', PrintConvInv => '$self->InverseDateTime($val,0)', }, 0xd101 => { Name => 'VersionModifyDate', Writable => 'string', Groups => { 2 => 'Time' }, Shift => 'Time', PrintConv => '$self->ConvertDateTime($val)', PrintConvInv => '$self->InverseDateTime($val,0)', }, ); # extract IDC preview images as composite tags %Image::ExifTool::SonyIDC::Composite = ( GROUPS => { 2 => 'Image' }, IDCPreviewImage => { Groups => { 2 => 'Preview' }, Require => { 0 => 'IDCPreviewStart', 1 => 'IDCPreviewLength', }, # extract all preview images (not just one) RawConv => q{ @grps = $self->GetGroup($$val{0}); require Image::ExifTool::SonyIDC; Image::ExifTool::SonyIDC::ExtractPreviews($self); }, }, ); # add our composite tags Image::ExifTool::AddCompositeTags('Image::ExifTool::SonyIDC'); # set "Permanent" flag for all tags { my $key; foreach $key (TagTableKeys(\%Image::ExifTool::SonyIDC::Main)) { $Image::ExifTool::SonyIDC::Main{$key}{Permanent} = 1; } } #------------------------------------------------------------------------------ # Extract all IDC preview images # Inputs: 0) ExifTool object ref # Returns: data for "IDCPreviewImage" tag (which I have never seen), # or undef if there was no preview in the SonyIDC IFD sub ExtractPreviews($) { my $et = shift; my $i = 1; my $xtra = ' (1)'; my $preview; # loop through all available IDC preview images in the order they were found for (;;) { my $key = "IDCPreviewStart$xtra"; unless (defined $$et{VALUE}{$key}) { last unless $xtra; $xtra = ''; # do the last tag extracted last next; } # run through IDC preview images in the same order they were extracted my $off = $et->GetValue($key, 'ValueConv') or last; my $len = $et->GetValue("IDCPreviewLength$xtra", 'ValueConv') or last; # get stack version from number in group 1 name my $grp1 = $et->GetGroup($key, 1); if ($grp1 =~ /(\d+)$/) { my $tag = "IDCPreviewImage$1"; unless ($Image::ExifTool::Extra{$tag}) { AddTagToTable(\%Image::ExifTool::Extra, $tag, { Name => $tag, Groups => { 0 => 'Composite', 1 => 'Composite', 2 => 'Preview'}, }); } my $val = Image::ExifTool::Exif::ExtractImage($et, $off, $len, $tag); $et->FoundTag($tag, $val, $et->GetGroup($key)); } else { $preview = Image::ExifTool::Exif::ExtractImage($et, $off, $len, 'IDCPreviewImage'); } # step to next set of tags unless we are done last unless $xtra; ++$i; $xtra = " ($i)"; } return $preview; } 1; # end __END__ =head1 NAME Image::ExifTool::SonyIDC - Read/write Sony IDC information =head1 SYNOPSIS This module is used by Image::ExifTool =head1 DESCRIPTION This module contains definitions required by Image::ExifTool to read and write Sony Image Data Converter version 3.0 metadata in ARW images. =head1 AUTHOR Copyright 2003-2020, Phil Harvey (philharvey66 at gmail.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L<Image::ExifTool::TagNames/SonyIDC Tags>, L<Image::ExifTool(3pm)|Image::ExifTool> =cut
mkjanke/Focus-Points
focuspoints.lrdevplugin/bin/exiftool/lib/Image/ExifTool/SonyIDC.pm
Perl
apache-2.0
12,237
# 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. package AI::MXNet::Random; use strict; use warnings; use Scalar::Util qw/blessed/; use AI::MXNet::Base; use AI::MXNet::NDArray::Base; use AI::MXNet::Function::Parameters; =head1 NAME AI::MXNet::Random - Handling of randomization in MXNet. =cut =head1 DESCRIPTION Handling of randomization in MXNet. =cut =head2 seed Seed the random number generators in mxnet. This seed will affect behavior of functions in this module, as well as results from executors that contains Random number such as Dropout operators. Parameters ---------- $seed_state : int The random number seed. :$ctx : [Str|AI::MXNet::Context] The device context of the generator. The default Str is "all" which means seeding random number generators of all devices. Notes ----- Random number generators in MXNet are device specific. mx->random->seed($seed_state) sets the state of each generator using $seed_state and the device id. Therefore, random numbers generated from different devices can be different even if they are seeded using the same seed. To produce identical random number sequences independent of the device id, set optional ctx argument. For example mx->random->seed($seed_state, ctx => mx->gpu(0)) This produces the same sequence of random numbers independent of the device id, but the sequence can be different on different kind of devices as MXNet's random number generators for CPU and GPU use different algorithms. =cut method seed(Int $seed_state, Str|AI::MXNet::Context :$ctx='all') { if(not ref $ctx) { confess("ctx argument could be either string 'all' or AI::MXNet::Context") unless $ctx eq 'all'; check_call(AI::MXNetCAPI::RandomSeed($seed_state)); } else { check_call(AI::MXNetCAPI::RandomSeedContext($seed_state, $ctx->device_type_id, $ctx->device_id)); } } sub AUTOLOAD { my $sub = $AI::MXNet::Random::AUTOLOAD; $sub =~ s/.*:://; shift; my %updated; my %defaults = ( ctx => AI::MXNet::Context->current_ctx, shape => 1, out => 1 ); my @args; my @tmp = @_; if($sub eq 'randn') { $sub = 'normal'; my @shape; while(defined $tmp[0] and $tmp[0] =~ /^\d+$/) { push @shape, shift(@tmp); } if(@shape) { push @tmp, (shape => \@shape); } %defaults = (%defaults, loc => 0, scale => 1); } if(ref $tmp[-1] eq 'HASH') { my @kwargs = %{ pop(@tmp) }; push @tmp, @kwargs; } while(@tmp >= 2 and not ref $tmp[-2]) { if(exists $defaults{$tmp[-2]}) { my $v = pop(@tmp); my $k = pop(@tmp); if(defined $v) { $updated{$k} = 1; $defaults{$k} = $v; } } else { unshift @args, pop(@tmp); unshift @args, pop(@tmp); } } unshift @args, @tmp; if(blessed($defaults{out}) and not exists $updated{shape}) { delete $defaults{shape}; } delete $defaults{out} unless blessed $defaults{out}; if($sub eq 'exponential') { my $changed = 0; for my $i (0..@args-1) { if(not ref $args[$i] and $args[$i] eq 'scale') { $args[$i] = 'lam'; $args[$i+1] = 1/$args[$i+1]; $changed = 1; } } $args[0] = 1/$args[0] unless $changed; } if(grep { blessed($_) and $_->isa('AI::MXNet::NDArray') } @args) { if($sub eq 'normal') { my %mapping = qw/loc mu scale sigma/; @args = map { (not ref $_ and exists $mapping{$_}) ? $mapping{$_} : $_ } @args } $sub = "_sample_$sub"; delete $defaults{shape} if not exists $updated{shape}; delete $defaults{ctx}; return AI::MXNet::NDArray->$sub(@args, %defaults); } else { $sub = "_random_$sub"; } return AI::MXNet::NDArray->$sub(@args, %defaults); } 1;
dmlc/mxnet
perl-package/AI-MXNet/lib/AI/MXNet/Random.pm
Perl
apache-2.0
4,947
#!/usr/bin/perl -w use strict; my $SOUPER = $ENV{"SOUPER"}; die unless defined $SOUPER; my $SPATH = "${SOUPER}/third_party/llvm/Release/bin"; my $passes1 = "-sroa"; my $passes2 = "$passes1 -sccp -inline"; my $passes3 = "$passes2 -adce"; my $sflags = "-load ${SOUPER}/build/libsouperPass.so -souper -external-cache-souper -z3-path=/usr/bin/z3 -solver-timeout=60 -solver-use-quantifiers"; sub runit ($) { my $cmd = shift; print "<$cmd>\n"; my $res = (system "$cmd"); my $exit_value = $? >> 8; return $exit_value; } my $cfile; my $exe; for (my $i=0; $i<scalar(@ARGV); $i++) { my $a = $ARGV[$i]; if ($a =~ /\.c$/) { die if defined $cfile; $cfile = $a; } if ($a eq "-o") { die if defined $exe; $exe = $ARGV[$i+1]; } } die unless defined $cfile; # die unless defined $exe; my $root = $cfile; die unless ($root =~ s/\.c$//); runit("$SPATH/clang -w -c -emit-llvm -I/home/regehr/csmith/runtime -O0 $cfile") == 0 or die(); runit("$SPATH/opt $passes1 ${root}.bc -o ${root}2.bc") == 0 or die(); runit("$SPATH/opt $sflags ${root}2.bc -o ${root}3.bc") == 0 or die(); runit("$SPATH/opt $passes2 ${root}3.bc -o ${root}4.bc") == 0 or die(); runit("$SPATH/opt $sflags ${root}4.bc -o ${root}5.bc") == 0 or die(); runit("$SPATH/opt $passes3 ${root}5.bc -o ${root}6.bc") == 0 or die(); runit("$SPATH/opt $sflags ${root}6.bc -o ${root}7.bc") == 0 or die(); runit("$SPATH/opt $passes3 ${root}7.bc -o ${root}8.bc") == 0 or die(); if (defined $exe) { runit("$SPATH/clang ${root}8.bc -o $exe"); }
DmitryOlshansky/dsmith
driver/souper.pl
Perl
bsd-2-clause
1,564
use strict; use Config::Simple; use Data::Dumper; =head1 NAME kb-get-service-port =head1 DESCRIPTION Read the deployment configuration file to determine the service port that the given service should be using. As a side effect we scan all the services in the deployment and fail hard if there are multiple services defined with the same port. =cut @ARGV == 1 or die "Usage: $0 service-name\n"; my $service_name = shift; my $cfg_file = $ENV{KB_DEPLOYMENT_CONFIG}; if ($cfg_file eq '') { die "No KB_DEPLOYMENT_CONFIG environment variable is defined\n"; } if (! -e $cfg_file) { die "Deployment config file $cfg_file does not exist\n"; } my $cfg = Config::Simple->new(); $cfg->read($cfg_file); my %cfg = $cfg->vars; my %port_seen; my @dups; for my $var (keys %cfg) { if ($var =~ /^(.*)\.service-port$/) { my $service = $1; my $port = $cfg{$var}; if ($port_seen{$port}) { push(@dups,"Services $port_seen{$port} and $service both use port $port\n"); } $port_seen{$port} = $service; } } if (@dups) { die "Duplicate port assignments found:\n" . join("", @dups); } my $port = $cfg{"$service_name.service-port"}; if (!defined($port)) { die "Configuration file $cfg_file does not define a port for servcie $service_name\n"; } print "$port\n";
eapearson/ui-common-dos
unused/deprecated/kbase_labs/scripts/kb-get-service-port.pl
Perl
mit
1,285